sketchi 0.6.1 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/sketchi.js +43 -43
package/sketchi.js CHANGED
@@ -1,15 +1,15 @@
1
1
  #!/usr/bin/env node
2
- import{createRequire as e}from"node:module";let t=e(import.meta.url);var r,n,i,a,s={5776(e){let t={to:(e,t)=>t?`\x1b[${t+1};${e+1}H`:`\x1b[${e+1}G`,move(e,t){let r="";return e<0?r+=`\x1b[${-e}D`:e>0&&(r+=`\x1b[${e}C`),t<0?r+=`\x1b[${-t}A`:t>0&&(r+=`\x1b[${t}B`),r},up:(e=1)=>`\x1b[${e}A`,down:(e=1)=>`\x1b[${e}B`,forward:(e=1)=>`\x1b[${e}C`,backward:(e=1)=>`\x1b[${e}D`,nextLine:(e=1)=>"\x1b[E".repeat(e),prevLine:(e=1)=>"\x1b[F".repeat(e),left:"\x1b[G",hide:"\x1b[?25l",show:"\x1b[?25h",save:"\x1b7",restore:"\x1b8"},r={screen:"\x1b[2J",up:(e=1)=>"\x1b[1J".repeat(e),down:(e=1)=>"\x1b[J".repeat(e),line:"\x1b[2K",lineEnd:"\x1b[K",lineStart:"\x1b[1K",lines(e){let r="";for(let n=0;n<e;n++)r+=this.line+(n<e-1?t.up():"");return e&&(r+=t.left),r}};e.exports={cursor:t,scroll:{up:(e=1)=>"\x1b[S".repeat(e),down:(e=1)=>"\x1b[T".repeat(e)},erase:r,beep:"\x07"}},6121(e,r,n){let i,a,s,o,l,d,c,u,f,p,h,m,g,y,b,v,_,x,w,k,S,I,$,E,O,C,T,M,P,A,N;var R,j,D,U,F,B=n(719),L=n(2842),z=n(6526),W=n(1594);let J=(e,t)=>t(z.oJ(e)?0:B.nn(e.cause)?130:X(B.iw(e.cause))),Y="~effect/Runtime/errorExitCode",X=e=>{if("object"==typeof e&&null!==e&&Y in e){let t=e[Y];if("number"==typeof t)return t}return 1},q="~effect/Runtime/errorReported",G=(a=({fiber:e,teardown:t})=>{let r=!1;function n(){r=!0,e.interruptUnsafe(e.id)}e.addObserver(e=>{process.removeListener("SIGINT",n),process.removeListener("SIGTERM",n),t(e,e=>{(r||0!==e)&&process.exit(e)})}),process.on("SIGINT",n),process.on("SIGTERM",n)},(0,W.XY)(e=>L.yw5(e[0]),(e,t)=>{let r=t?.disableErrorReporting===!0?L.MY7(e):L.MY7(L.dGm(e,e=>B.nn(e)?L.rIH:(e=>{if("object"==typeof e&&null!==e&&q in e){let t=e[q];if("boolean"==typeof t)return t}return!0})(B.iw(e))?L.vVN(e):L.rIH));try{let e=globalThis.setInterval(W.Yi,0x7fffffff);r.addObserver(()=>{clearInterval(e)})}catch{}return a({fiber:r,teardown:t?.teardown??J})}));var V=n(5633),H=n(9237),K=n(3614),Q=n(664),Z=n(3265),ee=n(1179),et=n(1587),er=n(4942);let en="~effect/PlatformError";class ei extends er.rN("BadArgument"){get message(){return`${this.module}.${this.method}${this.description?`: ${this.description}`:""}`}}class ea extends er.$D{get message(){return`${this._tag}: ${this.module}.${this.method}${void 0!==this.pathOrDescriptor?` (${this.pathOrDescriptor})`:""}${this.description?`: ${this.description}`:""}`}}class es extends er.rN("PlatformError"){constructor(e){"cause"in e?super({reason:e,cause:e.cause}):super({reason:e})}[en]=en;get message(){return this.reason.message}}let eo=e=>new es(new ea(e)),el=e=>new es(new ei(e));var ed=n(3952),ec=n(2449);let eu="~effect/MutableRef",ef={[eu]:eu,...ec.fU,toJSON(){return{_id:"MutableRef",current:(0,ed.aB)(this.current)}}},ep=e=>{let t=Object.create(ef);return t.current=e,t};var eh=n(1554),em=n(4233),eg=n(3753),ey=n(9771),eb=n(6297);let ev=Symbol.for("effect/MutableList/Empty"),e_=e=>{let t=e.head;t.offset>=1024&&t===e.tail&&t.mutable&&(t.array.length-t.offset)*8<=t.offset&&(e.head=e.tail={array:t.array.slice(t.offset),mutable:!0,offset:0,next:void 0})},ex=()=>({array:[],mutable:!0,offset:0,next:void 0}),ew=(e,t)=>{e.tail?e.tail.mutable||(e.tail.next=ex(),e.tail=e.tail.next):e.head=e.tail=ex(),e.tail.array.push(t),e.length++},ek=e=>{e.head=e.tail=void 0,e.length=0},eS=e=>{if(!e.head)return ev;let t=e.head.array[e.head.offset];return e.head.mutable&&(e.head.array[e.head.offset]=void 0),e.head.offset++,e.length--,e.head.offset===e.head.array.length?e.head.next?e.head=e.head.next:ek(e):e_(e),t},eI={_A:W.D_,_E:W.D_},e$={"~effect/Queue":eI,"~effect/Queue/Enqueue":eI,"~effect/Queue/Dequeue":eI,...ec.fU,toJSON(){return{_id:"effect/Queue",state:this.state._tag,size:eF(this)}}},eE=e=>ec.R6(t=>{let r=Object.create(e$);return r.dispatcher=t.currentDispatcher,r.capacity=e?.capacity??1/0,r.strategy=e?.strategy??"suspend",r.messages={head:void 0,tail:void 0,length:0},r.scheduleRunning=!1,r.state={_tag:"Open",takers:new Set,offers:new Set,awaiters:new Set},eb.PyW(r)}),eO=(0,W.XY)(2,(e,t)=>eb.DYE(()=>eC(e,t)?eL:"Open"===e.state._tag&&"suspend"===e.strategy?eV(e,t):eB)),eC=(e,t)=>"Open"===e.state._tag&&(e.messages.length>=e.capacity?"sliding"===e.strategy?(eS(e.messages),ew(e.messages,t),!0):e.capacity<=0&&e.state.takers.size>0&&(ew(e.messages,t),eJ(e),!0):(ew(e.messages,t),eY(e),!0)),eT=(0,W.XY)(2,(e,t)=>eb.OH5(()=>eM(e,t))),eM=(e,t)=>{if("Open"!==e.state._tag)return!1;let r=ec.cb(t),n=eb.il9(r,ez);return 0===e.state.offers.size&&0===e.messages.length?e0(e,n):(e.state={...e.state,_tag:"Closing",exit:n},eY(e)),!0},eP=e=>eM(e,ec.OE(ec.RS())),eA=e=>eb.OH5(()=>eN(e)),eN=e=>{if("Done"===e.state._tag)return!1;ek(e.messages);let t=e.state.offers;for(let r of(e0(e,"Open"===e.state._tag?eW:e.state.exit),t))eK(r);return!0},eR=e=>ej(e,1,1/0),ej=(0,W.XY)(3,(e,t,r)=>(t=ey.S(t),r=ey.S(r),eb.DYE(()=>eX(e,t,r)??eb.hgn(eG(e,()=>eq(e,t)),ej(e,t,r))))),eD=e=>eb.DYE(()=>eU(e)??eb.hgn(eG(e,()=>eq(e,1)),eD(e))),eU=e=>{if("Done"===e.state._tag)return e.state.exit;if(e.messages.length>0){let t=eS(e.messages);return eZ(e),ec.xt(t)}if(e.capacity<=0&&e.state.offers.size>0){let t=eQ(e.state.offers);return eZ(e),ec.xt(t)}},eF=e=>"Done"===e.state._tag?0:e.messages.length,eB=ec.xt(!1),eL=ec.xt(!0),ez=ec.Rk(ec.RS()),eW=eb._sz(),eJ=e=>{if("Done"!==e.state._tag&&0!==e.state.takers.size){for(let t of e.state.takers)if(t.ready()&&(e.state.takers.delete(t),t.resume(eb.x5l),0===e.messages.length))break}},eY=e=>{e.scheduleRunning||"Done"===e.state._tag||0===e.state.takers.size||(e.scheduleRunning=!0,e.dispatcher.scheduleTask(()=>{e.scheduleRunning=!1,eJ(e)},0))},eX=(e,t,r)=>{if("Done"===e.state._tag)return e.state.exit;if(r<=0||t<=0)return ec.xt([]);if(!eq(e,t))return;let n=e.messages.length>0?((e,t)=>{if((t=ey.S(t))<=0||!e.head)return[];if((t=Math.min(t,e.length))===e.length&&e.head?.offset===0&&!e.head.next){let t=e.head.array;return ek(e),t}let r=Array(t),n=0,i=e.head;for(;i;){for(;i.offset<i.array.length;)if(r[n++]=i.array[i.offset],i.mutable&&(i.array[i.offset]=void 0),i.offset++,n===t)return e.head=i.offset===i.array.length&&i.next?i.next:i,e.length-=t,0===e.length?ek(e):e_(e),r;i=i.next}return ek(e),r})(e.messages,r):[eQ(e.state.offers)];return eZ(e),ec.xt(n)},eq=(e,t)=>e.messages.length>=("Closing"===e.state._tag?1:Math.min(t,e.capacity||1))||e.capacity<=0&&"Done"!==e.state._tag&&e.state.offers.size>0,eG=(e,t)=>eb.E2r(r=>{if("Done"===e.state._tag)return r(e.state.exit);if(t())return r(eb.x5l);let n={ready:t,resume:r};return e.state.takers.add(n),eb.OH5(()=>{"Done"!==e.state._tag&&e.state.takers.delete(n)})}),eV=(e,t)=>eb.E2r(r=>eC(e,t)?r(eL):eH(e,{_tag:"Single",message:t,resume:r})),eH=(e,t)=>{if("Open"!==e.state._tag)return eK(t);let r=e.state.offers;return r.add(t),eb.OH5(()=>{"Done"!==e.state._tag&&(r.delete(t),"Closing"===e.state._tag&&0===r.size&&0===e.messages.length&&e0(e,e.state.exit))})},eK=e=>"Single"===e._tag?e.resume(eB):e.resume(ec.xt(e.remaining.slice(e.offset))),eQ=e=>{let t=e.values().next().value;if("Single"===t._tag)return e.delete(t),t.resume(eL),t.message;let r=t.remaining[t.offset++];return t.offset===t.remaining.length&&(e.delete(t),t.resume(ec.xt([]))),r},eZ=e=>{if("Done"===e.state._tag)return eg.Og(e.state.exit.cause);if(0===e.state.offers.size)return"Closing"===e.state._tag&&0===e.messages.length&&(e0(e,e.state.exit),eg.Og(e.state.exit.cause));for(let t of e.state.offers){let r=e.capacity-e.messages.length;if(r<=0)break;if("Single"===t._tag)ew(e.messages,t.message),e.state.offers.delete(t),t.resume(eL);else{for(;t.offset<t.remaining.length;t.offset++){if(0===r)return!1;ew(e.messages,t.remaining[t.offset]),r--}e.state.offers.delete(t),t.resume(ec.xt([]))}}return!1},e0=(e,t)=>{if("Done"===e.state._tag)return;let r=e.state;for(let n of(e.state={_tag:"Done",exit:t},r.takers))n.resume(t);for(let e of(r.takers.clear(),r.awaiters))e(t);r.awaiters.clear()};var e1=n(5744);let e2="~effect/Channel",e5=e=>(0,em.i5)(e,e2),e3={[e2]:{_Env:W.D_,_InErr:W.D_,_InElem:W.D_,_OutErr:W.D_,_OutElem:W.D_},pipe(){return(0,eh.tT)(this,arguments)}},e6=e=>{let t=Object.create(e3);return t.transform=(t,r)=>L.Tyx(e(t,r),e=>L.PyW(L.ATB(e))),t},e8=(e,t)=>e6((r,n)=>L.qIB(e4(e)(r,n),e=>t(e,n))),e9=e=>e6((t,r)=>e),e4=e=>e.transform,e7=e9(L.PyW(B.Vw()));L.ZmZ;let te=(0,W.XY)(2,(e,t)=>e8(e,e=>L.OH5(()=>{let r=0;return L.TjK(e,e=>t(e,r++))}))),tt=(0,W.XY)(2,(e,t)=>tr(e,e=>L.PyW(t(e)))),tr=(0,W.XY)(2,(e,t)=>e8(e,e=>L.PyW(eg.m8(e,e=>L.qIB(t(e),B.Vw))))),tn=(0,W.XY)(e=>e5(e[0])&&e5(e[1]),(e,t,r)=>{let n;return n=L.D9k(function*(n,i,a){let s=r?.haltStrategy??"both",o=yield*eE({capacity:0});yield*e1.U9(a,eA(o));let l=0,d=(e,t,r)=>e4(t)(n,r).pipe(L.qIB(e=>e.pipe(L.qIB(e=>eO(o,e)),L.i4r)),L.S5A(t=>L.hgn(e1.VN(r,eg.aU(t)),function(e,t){if(l++,!eg.Og(t))return eT(o,t);switch(s){case"both":return 2===l?eT(o,t):L.rIH;case"left":case"right":return e===s?eT(o,t):L.rIH;case"either":return eT(o,t)}}(e,t))),L.ar0(a));return yield*d("left",e,e1.Fp(a)),yield*d("right",t,e1.Fp(a)),eD(o)}),e6(L.D9k(function*(e,t){let r=e1.Fp(t),i=e=>e1.VN(r,eg.aU(e)),a=yield*L.S5A(n(e,t,r),i);return L.S5A(a,i)}))}),ti=(0,W.XY)(2,(e,t)=>e6((r,n)=>L.qIB(e4(e)(r,n),e=>e4(t)(e,n)))),ta=e=>e6((t,r)=>{let n;return L.PyW(L.DYE(()=>n||e.pipe(e1.Gt(r),L.qIB(e=>e4(e)(t,r)),L.qIB(e=>n=e))))}),ts=(e,t,r)=>L.DYE(()=>{let n=e1.LZ(),i=e4(e)(B.Vw(),n);return eg.m8(L.qIB(i,t),r||L.PyW).pipe(L.cfM(e=>e1.VN(n,e)))}),to=(0,W.XY)(2,(e,t)=>ts(e,e=>L.i4r(L.qIB(e,t),{disableYield:!0}))),tl=(0,W.XY)(3,(e,t,r)=>L.DYE(()=>{let n=t();return ts(e,e=>L.iMI({while:W.ue,body:()=>e,step:e=>{n=r(n,e)}}),()=>L.PyW(n))})),td=(0,W.XY)(3,(e,t,r)=>L.DYE(()=>{let n=t();return ts(e,e=>L.iMI({while:W.ue,body:(0,W.dY)(e.pipe(L.qIB(e=>r(n,e)),L.TjK(e=>{n=e}))),step:W.Yi}),()=>L.PyW(n))})),tc=(e,t)=>e4(e)(B.Vw(),t),tu="~effect/Sink",tf=L.PyW([void 0]),tp={[tu]:{_A:W.D_,_In:W.D_,_L:W.D_,_E:W.D_,_R:W.D_},pipe(){return(0,eh.tT)(this,arguments)}},th=e=>(0,em.i5)(e,tu),tm=e=>tg((t,r)=>e4(e)(t,r).pipe(L.qIB(L.i4r({disableYield:!0})),eg.m8(L.PyW))),tg=e=>{let t=Object.create(tp);return t.transform=e,t},ty=e=>e6((t,r)=>L.PyW(L.qIB(e.transform(t,r),B.Vw)));L.ZmZ;let tb=tg(e=>eg.m8(L.i4r(e,{disableYield:!0}),()=>tf));et.none,et.isNone,et.none;let tv=e=>tm(ta(L.TjK(e,ty))),t_={_R:W.D_,_E:W.D_,_A:W.D_},tx=function(e){this.channel=e};tx.prototype={"~effect/Stream":t_,pipe(){return(0,eh.tT)(this,arguments)}};let tw=e=>(0,em.i5)(e,"~effect/Stream"),tk=e=>new tx(e),tS=e=>e.channel,tI=tk(e7),t$=e=>{let t;return tk((t=()=>e().channel,e6((e,r)=>L.DYE(()=>e4(t())(e,r)))))},tE=e=>{let t;return Q.ET(e)?tk((t=L.PyW(e),e9(L.OH5(()=>{let e=!1;return L.DYE(()=>e?B.Vw():(e=!0,t))})))):tI},tO=e=>tk(ta(L.TjK(e,tS))),tC=(0,W.XY)(2,(e,t)=>t$(()=>{let r=0;return tk(te(e.channel,Q.Tj(e=>t(e,r++))))})),tT=(0,W.XY)(e=>tw(e[0])&&tw(e[1]),(e,t,r)=>tk(tn(tS(e),tS(t),r))),tM=(0,W.XY)(2,(e,t)=>{let r;return r=(e,r)=>L.OH5(()=>{let n,i,a=L.DYE(()=>{if(void 0!==i){let e=i;return i=void 0,L.PyW(e)}return e}).pipe(L.MfU(e=>(n=z.fJ(e),B.Vw()))),s=L.TjK(L.DYE(()=>t.transform(a,r)),([e,t])=>(i=t,Q.of(e)));return L.DYE(()=>n||s)}),tk(e6((t,n)=>L.qIB(tc(e.channel,n),e=>r(e,n))))}),tP=(0,W.XY)(e=>tw(e[0]),(e,t)=>t$(()=>{let r=new TextDecoder(t?.encoding);return tC(e,e=>r.decode(e,{stream:!0}))})),tA=(0,W.XY)(2,(e,t)=>L.Pxi(r=>tc(e.channel,r).pipe(L.qIB(e=>t.transform(e,r)),L.TjK(([e])=>e)))),tN=(0,W.XY)(3,(e,t,r)=>td(e.channel,t,(e,t)=>{let n=0,i=e;return L.TjK(L.iMI({while:()=>n<t.length,body:()=>r(i,t[n]),step(e){i=e,n++}}),()=>i)})),tR=((e,t)=>to(e.channel,t),"~effect/FileSystem"),tj=ee.kl("effect/FileSystem"),tD="~effect/FileSystem/File";class tU extends(ee.kl())("effect/FileSystem/WatchBackend"){}let tF="~effect/Path",tB=ee.kl("effect/Path");var tL=n(3811),tz=n(9315);function tW(){return Object.assign(e=>e,{option:e=>et.some(e),result:e=>tz.Py(e),is:e=>!0})}let tJ=tW(),tY=tW(),tX="~effect/process/ChildProcessSpawner/ChildProcessHandle",tq={[tX]:tX,...ed.os,toJSON(){return{_id:"ChildProcessHandle",pid:this.pid}}},tG=e=>Object.setPrototypeOf({...e},tq);class tV extends(ee.kl())("effect/process/ChildProcessSpawner"){}let tH="~effect/process/ChildProcess",tK={...tL.bp({label:"Command",evaluate(e){return ee.fp(e.context,tV).spawn(this)}}),[tH]:tH},tQ=(e,t,r)=>Object.assign(Object.create(tK),{_tag:"StandardCommand",command:e,args:t,options:r}),tZ=function(...e){if(t0(e[0])){let[t,...r]=e,n=t5(t,r);return tQ(n[0]??"",n.slice(1),{})}if("object"==typeof e[0]&&!Array.isArray(e[0])&&!t0(e[0])){let t=e[0];return function(e,...r){let n=t5(e,r);return tQ(n[0]??"",n.slice(1),t)}}if("string"==typeof e[0]&&!Array.isArray(e[1])){let[t,r={}]=e;return tQ(t,[],r)}let[t,r=[],n={}]=e;return tQ(t,r,n)},t0=e=>Array.isArray(e)&&"raw"in e&&Array.isArray(e.raw),t1=e=>{let t=/^fd(\d+)$/.exec(e);if(null===t)return;let r=parseInt(t[1],10);return r>=3?r:void 0},t2=e=>`fd${e}`,t5=(e,t)=>{let r=[];for(let[n,i]of e.entries())r=t3(e,t,r,i,n);return r},t3=(e,t,r,n,i)=>{let a=e.raw[i];if(void 0===a)throw Error(`Invalid backslash sequence: ${e.raw[i]}`);let{hasLeadingWhitespace:s,hasTrailingWhitespace:o,tokens:l}=t4(n,a),d=t7(r,l,s);if(i===t.length)return d;let c=t[i];return t7(d,Array.isArray(c)?c.map(e=>t6(e)):[t6(c)],o)},t6=e=>"string"==typeof e?e:String(e),t8=new Set([" "," ","\r","\n"]),t9={x:3,u:5},t4=(e,t)=>{if(0===t.length)return{tokens:[],hasLeadingWhitespace:!1,hasTrailingWhitespace:!1};let r=t8.has(t[0]),n=[],i=0;for(let r=0,a=0;r<e.length;r+=1,a+=1){let s=t[a];if(t8.has(s))i!==r&&n.push(e.slice(i,r)),i=r+1;else if("\\"===s){let e=t[a+1];if("\n"===e)r-=1,a+=1;else if("u"===e&&"{"===t[a+2]){let e=t.indexOf("}",a+3);parseInt(t.slice(a+3,e),16)>65535&&(r+=1),a=e}else a+=t9[e]??1}}let a=i===e.length;return a||n.push(e.slice(i)),{tokens:n,hasLeadingWhitespace:r,hasTrailingWhitespace:a}},t7=(e,t,r)=>r||0===e.length||0===t.length?[...e,...t]:[...e.slice(0,-1),`${e.at(-1)}${t.at(0)}`,...t.slice(1)],re=t("node:child_process"),rt=t("node:stream"),rr=(e,t)=>(r,[n])=>{let i="Unknown";switch(r.code){case"ENOENT":i="NotFound";break;case"EACCES":i="PermissionDenied";break;case"EEXIST":i="AlreadyExists";break;case"EISDIR":case"ENOTDIR":case"ELOOP":i="BadResource";break;case"EBUSY":i="Busy"}return eo({_tag:i,module:e,method:t,pathOrDescriptor:n,syscall:r.syscall,cause:r})},rn=e=>tm(tt(ri(e),e=>[e])),ri=e=>e6(t=>{let r=e.evaluate();return L.PyW(ra({...e,writable:r,pull:t}))}),ra=e=>e.pull.pipe(L.qIB(t=>{let r=0;return L.E2r(n=>{let i=!1,a=()=>{for(;r<t.length;){if(i)return;if(!e.writable.write(t[r++],e.encoding)){i||e.writable.once("drain",a);return}}i||n(L.rIH)};return a(),L.OH5(()=>{i=!0,e.writable.off("drain",a)})})}),L.i4r({disableYield:!0}),!1!==e.endOnDone?eg.m8(t=>"closed"in e.writable&&e.writable.closed?B.Vw(t):L.E2r(r=>{let n=()=>r(B.Vw(t));return e.writable.once("finish",n),e.writable.end(),L.OH5(()=>{e.writable.off("finish",n)})})):W.D_,L.KT6(L.E2r(t=>{let r=r=>t(L.fJG(e.onError(r)));return e.writable.once("error",r),L.OH5(()=>{e.writable.off("error",r)})})));eb.zFM,eb.C6p;let rs=eb.D7p;eb.INJ;let ro=eb.mKq;eb.eGS,eb.DKo,eb.$MQ;let rl=eb.Iku,rd=eb.vTQ,rc=eb.zzk;eb.Fbb;let ru=e=>tk(rf(e)),rf=e=>e6((t,r)=>rp({scope:r,readable:e.evaluate(),onError:e.onError??rh,chunkSize:e.chunkSize,closeOnDone:e.closeOnDone})),rp=e=>{let t=e.readable,r=e.closeOnDone??!0,n=e.exit??ep(void 0),i=e.latch??rc(!1);function a(){i.openUnsafe()}function s(t){n.current=z.fJ(e.onError(t)),i.openUnsafe()}function o(){n.current=z.fJ(B.RS()),i.openUnsafe()}t.on("readable",a),t.once("error",s),t.once("end",o);let l=L.DYE(function r(){let a=e.readable.read(e.chunkSize);if(null===a)return n.current?n.current:t.readableEnded?L.fJG(B.RS()):(i.closeUnsafe(),L.qIB(i.await,r));let s=Q.of(a);for(;null!==(a=e.readable.read(e.chunkSize));)s.push(a);return L.PyW(s)});return L.as(e1.U9(e.scope,L.OH5(()=>{t.off("readable",a),t.off("error",s),t.off("end",o),r&&"closed"in e.readable&&!e.readable.closed&&e.readable.destroy()})),l)};rt.Readable;let rh=e=>new B.Bk(e),rm=e=>e instanceof globalThis.Error?e:new globalThis.Error(String(e)),rg=(e,t,r)=>{let{commands:n}=rx(r),i=n.reduce((e,t)=>{let r=`${t.command} ${t.args.join(" ")}`;return 0===e.length?r:`${e} | ${r}`},"");return rr("ChildProcess",e)(t,[i])},ry=(e,t)=>{if(!H.NJ(t))return!0;if("win32"===globalThis.process.platform)return!1;try{return globalThis.process.kill(-e.pid,0),!0}catch{return!1}},rb=(e,t=()=>{})=>re.execFile("taskkill",["/pid",String(e.pid),"/T","/F"],{windowsHide:!0},t),rv=L.JkU(function*(){let e,t,r=yield*tj,n=yield*tB,i=L.D9k(function*(e){if(!em.b0(e.cwd))return yield*r.access(e.cwd),n.resolve(e.cwd)}),a=e=>th(e)?"pipe":e,s=e=>{let t={stream:"pipe",encoding:"utf-8",endOnDone:!0};return em.b0(e.stdin)?t:"string"==typeof e.stdin||tw(e.stdin)?{...t,stream:e.stdin}:{stream:e.stdin.stream,encoding:e.stdin.encoding??t.encoding,endOnDone:e.stdin.endOnDone??t.endOnDone}},o=(e,t)=>{let r=e[t];return em.b0(r)?{stream:"pipe"}:"string"==typeof r||th(r)?{stream:r}:{stream:r.stream}},l=L.D9k(function*(e,t,r){if(0===r.length)return{getInputFd:()=>tb,getOutputFd:()=>tI};let n=new Map,i=new Map;for(let{config:a,fd:s}of r){let r=t.stdio[s];switch(a.type){case"input":{let t=tb;r&&"write"in r&&(t=rn({evaluate:()=>r,onError:t=>rg(`fromWritable(fd${s})`,rm(t),e)})),a.stream&&(yield*L.x6Z(tA(a.stream,t))),n.set(s,t);break}case"output":{let t=tI;if(r&&"read"in r){let n=new rt.PassThrough;r.on("error",e=>n.destroy(e)),r.pipe(n),t=ru({evaluate:()=>n,onError:t=>rg(`fromReadable(fd${s})`,rm(t),e)})}a.sink&&(t=tM(t,a.sink)),i.set(s,t)}}}return{getInputFd:e=>n.get(e)??tb,getOutputFd:e=>i.get(e)??tI}}),d=(e,t,r)=>L.E2r(n=>{let i,a=Date.now()+r,s=()=>{clearTimeout(i),e.removeListener("exit",o)},o=()=>{if(clearTimeout(i),Date.now()>=a||!ry(e,t)){s(),n(L.rIH);return}i=setTimeout(o,10)};return e.on("exit",o),o(),L.OH5(s)}),c=L.D9k(function*(e,t,r,n){let i=r=>("win32"===globalThis.process.platform?L.E2r(r=>{rb(t,t=>{t?r(L.fJG(rg("kill",rm(t),e))):r(L.rIH)})}):L.SvU({try:()=>{globalThis.process.kill(-t.pid,r)},catch:t=>rg("kill",rm(t),e)})).pipe(L.MfU(()=>L.DYE(()=>{if(!t.kill(r)){let t=new globalThis.Error("Failed to kill child process");return L.fJG(rg("kill",t,e))}return L.rIH})));yield*i(n?.killSignal??"SIGTERM"),em.b0(n?.forceKillAfter)?yield*d(t,r,1e3):(yield*d(t,r,K.kE(n.forceKillAfter)),ry(t,r)&&(yield*i("SIGKILL"),yield*d(t,r,1e3))),yield*H.Tx(r)}),u=(e,t)=>{let r=t??"stdout";switch(r){case"stdout":return e.stdout;case"stderr":return e.stderr;case"all":return e.all;default:{let t=t1(r);if(em.EA(t))return e.getOutputFd(t);return e.stdout}}},f=L.D9k(function*(e){switch(e._tag){case"StandardCommand":{var t,r,n;let d,u,f,p,h,m,g,y,b=s(e.options),v=o(e.options,"stdout"),_=o(e.options,"stderr"),x=(e=>{if(em.b0(e.additionalFds))return[];let t=[];for(let[r,n]of Object.entries(e.additionalFds)){let e=t1(r);em.EA(e)&&t.push({fd:e,config:n})}return t.sort((e,t)=>e.fd-t.fd)})(e.options),w=!0,k=yield*i(e.options),S=(d=e.options).extendEnv?{...globalThis.process.env,...d.env}:d.env,I=((e,t,r,n)=>{let i,s=[tw(i=e.stream)?"pipe":i,a(t.stream),a(r.stream)];if(0===n.length)return s;let o=n.reduce((e,{fd:t})=>Math.max(e,t),2);for(let e=3;e<=o;e++)s[e]="ignore";for(let{fd:e}of n)s[e]="pipe";return s})(b,v,_,x),[$,E]=yield*L.Q56((t=e.options,r={cwd:k,env:S,stdio:I},n=process.platform,u=t.detached??"win32"!==n,f={...r,detached:u,shell:t.shell,windowsHide:t.windowsHide??!u},L.E2r(t=>{let r=H.LZ(),n=re.spawn(e.command,e.args,f);return n.on("error",r=>{t(L.fJG(rg("spawn",r,e)))}),n.on("exit",(...e)=>{H.$w(r,z.Py(e))}),n.on("spawn",()=>{t(L.PyW([n,r]))}),L.OH5(()=>{n.kill("SIGTERM")})})),L.D9k(function*([t,r]){if(yield*H.$L(r)){let[n]=yield*H.Tx(r);0!==n&&em.Pe(n)?yield*L.XeO(c(e,t,r,e.options)):w&&"win32"!==process.platform&&!1!==e.options.detached&&(yield*L.XeO(c(e,t,r,e.options)));return}w&&(yield*L.XeO(c(e,t,r,e.options)))})),O=tY($.pid);$.on("exit",t=>{0!==t&&em.Pe(t)&&((e,t)=>{if("win32"===globalThis.process.platform)return rb(e);try{globalThis.process.kill(-e.pid,t)}catch{}})($,e.options.killSignal??"SIGTERM")});let C=L.OH5(()=>{w||($.ref(),w=!0)}),T=L.OH5(()=>(w&&($.unref(),w=!1),C)),M=yield*L.DYE(()=>{let t=tb;return(em.Pe($.stdin)&&(t=rn({evaluate:()=>$.stdin,onError:t=>rg("fromWritable(stdin)",rm(t),e),endOnDone:b.endOnDone,encoding:b.encoding})),tw(b.stream))?L.as(L.x6Z(tA(b.stream,t)),t):L.PyW(t)}),{all:P,stderr:A,stdout:N}=(h=$.stdout?(p=new rt.PassThrough,$.stdout.on("error",e=>p.destroy(e)),$.stdout.pipe(p),ru({evaluate:()=>p,onError:t=>rg("fromReadable(stdout)",rm(t),e)})):tI,g=$.stderr?(m=new rt.PassThrough,$.stderr.on("error",e=>m.destroy(e)),$.stderr.pipe(m),ru({evaluate:()=>m,onError:t=>rg("fromReadable(stderr)",rm(t),e)})):tI,th(v.stream)&&(h=tM(h,v.stream)),th(_.stream)&&(g=tM(g,_.stream)),y=tT(h,g),{stdout:h,stderr:g,all:y}),{getInputFd:R,getOutputFd:j}=yield*l(e,$,x),D=L.TjK(H.$L(E),e=>!e);return tG({pid:O,exitCode:L.qIB(H.Tx(E),([t,r])=>{if(em.Pe(t))return L.PyW(tJ(t));let n=new globalThis.Error(`Process interrupted due to receipt of signal: '${r}'`);return L.fJG(rg("exitCode",n,e))}),isRunning:D,kill:t=>c(e,$,E,t),stdin:M,stdout:N,stderr:A,all:P,getInputFd:R,getOutputFd:j,unref:T})}case"PipedCommand":{let{commands:t,pipeOptions:r}=rx(e),[n,...i]=t,a=[(yield*f(n))];for(let e=0;e<i.length;e++){let t=i[e],n=r[e]??{},o=s(t.options),l=tO(L.PyW(u(a[a.length-1],n.from))),d=n.to??"stdin";if("stdin"===d)a.push((yield*f(tZ(t.command,t.args,{...t.options,stdin:{...o,stream:l}}))));else{let e=t1(d);if(em.EA(e)){let r=t2(e),n=t.options.additionalFds??{};a.push((yield*f(tZ(t.command,t.args,{...t.options,additionalFds:{...n,[r]:{type:"input",stream:l}}}))))}else a.push((yield*f(tZ(t.command,t.args,{...t.options,stdin:{...o,stream:l}}))))}}let o=a[a.length-1],l=L.JkU(function*(){let e=[];for(let t of a)e.push((yield*t.unref));return L.jJl([...e].reverse(),e=>e,{discard:!0})});return tG({pid:o.pid,exitCode:o.exitCode,isRunning:o.isRunning,kill:e=>L.jJl([...a].reverse(),t=>L.XeO(t.kill(e)),{discard:!0}),stdin:a[0].stdin,stdout:o.stdout,stderr:o.stderr,all:o.all,getInputFd:o.getInputFd,getOutputFd:o.getOutputFd,unref:l})}}});return e=(e,t)=>f(e).pipe(L.TjK(e=>tP(t?.includeStderr===!0?e.all:e.stdout)),tO),t=(t,r)=>e(t,r).channel.pipe(ti(e6((e,t)=>L.OH5(()=>{let t="",r=!1,n=et.none(),i=L.DYE(()=>"Some"===n._tag?B.Vw(n.value):eg.tv(e,{onSuccess:a,onFailure:L.ATB,onDone:e=>{if(n=et.some(e),t.length>0){let e=t;return t="",r=!1,L.PyW([e])}return B.Vw(e)}}));function a(e){let n=function(e){let n=[];function i(e){0===t.length?n.push(e):(n.push(t+e),t="")}for(let n=0;n<e.length;n++){let a=e[n];if(0!==a.length){let e=0,n=a.indexOf("\r"),s=a.indexOf("\n");for(r&&(0===s&&(e=1,s=a.indexOf("\n",e)),r=!1);-1!==n||-1!==s;)-1===n||-1!==s&&s<n?(i(a.substring(e,s)),e=s+1,s=a.indexOf("\n",e)):(i(a.substring(e,n)),a.length===n+1?(r=!0,e=a.length,n=-1):(e=n+(s===n+1?2:1),n=a.indexOf("\r",e),s=a.indexOf("\n",e)));t+=a.substring(e)}}return Q.ET(n)?n:null}(e);return null!==n?L.PyW(n):i}return i}))),tk),tV.of({spawn:f,exitCode:e=>L.P1j(L.qIB(f(e),e=>e.exitCode)),streamString:e,streamLines:t,lines:(e,r)=>tl(t(e,r).channel,()=>[],(e,t)=>{for(let r=0;r<t.length;r++)e.push(t[r]);return e}),string:(t,r)=>tl(e(t,r).channel,()=>"",(e,t)=>e+t.join(""))})}),r_=V.QZ(tV,rv),rx=e=>{let t=[],r=[],n=e=>{switch(e._tag){case"StandardCommand":t.push(e);break;case"PipedCommand":n(e.left),r.push(e.options),n(e.right)}};if(n(e),0===t.length)throw Error("flattenCommand produced empty commands array");let[i,...a]=t;return{commands:[i,...a],pipeOptions:r}},rw="0123456789ABCDEFGHJKMNPQRSTVWXYZ",rk=e=>e.toString(16).padStart(2,"0"),rS=e=>[e.subarray(0,4),e.subarray(4,6),e.subarray(6,8),e.subarray(8,10),e.subarray(10,16)].map(e=>Array.from(e,rk).join("")).join("-"),rI=()=>globalThis.crypto.getRandomValues(new Uint8Array(16));function r$(e=rI()){return e[6]=15&e[6]|64,e[8]=63&e[8]|128,e}function rE(e,t=rI()){let r=Math.min(Math.max(0,Math.trunc(e)),0xffffffffffff);return t[0]=Math.floor(r/0x10000000000),t[1]=255&Math.floor(r/0x100000000),t[2]=255&Math.floor(r/0x1000000),t[3]=255&Math.floor(r/65536),t[4]=255&Math.floor(r/256),t[5]=255&r,t[6]=15&t[6]|112,t[8]=63&t[8]|128,t}let rO="~effect/Crypto",rC=ee.kl("effect/Crypto");var rT=n(7598);let rM=(s=(U={randomBytes:rT.randomBytes,digest:(e,t)=>L.SvU({try:()=>Uint8Array.from(rT.createHash((e=>{switch(e){case"SHA-1":return"sha1";case"SHA-256":return"sha256";case"SHA-384":return"sha384";case"SHA-512":return"sha512"}})(e)).update(t).digest()),catch:e=>eo({module:"Crypto",method:"digest",_tag:"Unknown",description:"Could not compute digest",cause:e})})}).randomBytes,o=e=>(31&e[0])*0x1000000000000+0x10000000000*e[1]+0x100000000*e[2]+0x1000000*e[3]+65536*e[4]+256*e[5]+e[6],l=()=>o(s(7))/0x20000000000000,d=()=>{for(;;){let e=s(7),t=o(e);if((32&e[0])==0)return t+Number.MIN_SAFE_INTEGER;if(t<Number.MAX_SAFE_INTEGER)return t+1}},rC.of({[rO]:rO,randomBytes:e=>{let t,r;return L.TjK((t="randomBytes",Number.isSafeInteger(r=e)&&r>=0?L.PyW(r):L.fJG(el({module:"Crypto",method:t,description:"size must be a non-negative safe integer"}))),s)},nextDoubleUnsafe:l,nextIntUnsafe:d,digest:U.digest,random:L.OH5(()=>l()),randomBoolean:L.OH5(()=>l()>.5),randomInt:L.OH5(()=>d()),randomBetween:(e,t)=>L.OH5(()=>((e,t,r)=>{let n=r*(t-e)+e;if(n!==t||e>=t||!Number.isFinite(t))return n;if(0===t)return -5e-324;let i=new DataView(new ArrayBuffer(8));i.setFloat64(0,t);let a=i.getBigUint64(0);return i.setBigUint64(0,t>0?a-BigInt(1):a+BigInt(1)),i.getFloat64(0)})(e,t,l())),randomIntBetween(e,t,r){let n=+(r?.halfOpen!==!0);return L.OH5(()=>{let r=Math.ceil(e),i=Math.floor(t);return Math.floor(l()*(i-r+n))+r})},randomShuffle:e=>L.OH5(()=>{let t=Array.from(e);for(let e=t.length-1;e>=1;e-=1){let r=Math.min(e,Math.floor(l()*(e+1))),n=t[e];t[e]=t[r],t[r]=n}return t}),randomUUIDv4:L.OH5(()=>{let e;return rS(void 0===(e=s(16))?r$():r$(e))}),randomUUIDv7:L.RKA(e=>{let t,r;return L.PyW((t=e.currentTimeMillisUnsafe(),rS(void 0===(r=s(16))?rE(t):rE(t,r))))}),randomULID:L.RKA(e=>L.PyW(((e,t)=>{if(10!==t.length)throw Error(`ULID randomness must be exactly 10 bytes, received ${t.length}`);let r=Math.min(Math.max(0,Math.trunc(e)),0xffffffffffff),n="";for(let e=45;e>=0;e-=5)n+=rw[31&Math.floor(r/2**e)];let i=0,a=0;for(let e of t){for(i=i<<8|e,a+=8;a>=5;)a-=5,n+=rw[i>>>a&31];i&=(1<<a)-1}return n})(e.currentTimeMillisUnsafe(),s(10))))})),rP=V.Py(rC,rM);var rA=n(5053);let rN=t("node:fs"),rR=t("node:os"),rj=t("node:path");var rD=n.t(rj,2);let rU=e=>t=>el({module:"FileSystem",method:e,description:t.message??String(t)}),rF=(e,t)=>{let r=Number(e);if(!Number.isSafeInteger(r))throw RangeError(`${t} exceeds the safe integer range: ${e}`);return r},rB=e=>et.flatMap(et.fromNullishOr(e),rA.Ro),rL=(e,t)=>L.SvU({try:()=>rF(e,"position"),catch:rU(t)}),rz=(c=(0,L._r7)(rN.access,rr("FileSystem","access"),rU("access")),(e,t)=>{let r=rN.constants.F_OK;return t?.readable&&(r|=rN.constants.R_OK),t?.writable&&(r|=rN.constants.W_OK),c(e,r)}),rW=(u=(0,L._r7)(rN.cp,rr("FileSystem","copy"),rU("copy")),(e,t,r)=>u(e,t,{force:r?.overwrite??!1,preserveTimestamps:r?.preserveTimestamps??!1,recursive:!0})),rJ=(f=(0,L._r7)(rN.copyFile,rr("FileSystem","copyFile"),rU("copyFile")),(e,t)=>f(e,t)),rY=(p=(0,L._r7)(rN.chmod,rr("FileSystem","chmod"),rU("chmod")),(e,t)=>p(e,t)),rX=(h=(0,L._r7)(rN.chown,rr("FileSystem","chown"),rU("chown")),(e,t,r)=>h(e,t,r)),rq=(m=(0,L._r7)(rN.glob,rr("FileSystem","glob"),rU("glob")),(e,t)=>m(e,{cwd:t?.root,exclude:t?.exclude})),rG=(g=(0,L._r7)(rN.link,rr("FileSystem","link"),rU("link")),(e,t)=>g(e,t)),rV=(y=(0,L._r7)(rN.mkdir,rr("FileSystem","makeDirectory"),rU("makeDirectory")),(e,t)=>y(e,{recursive:t?.recursive??!1,mode:t?.mode})),rH=e=>{let t=(0,L._r7)(rN.mkdtemp,rr("FileSystem",e),rU(e));return e=>L.DYE(()=>{let r=e?.prefix??"",n="string"==typeof e?.directory?rj.join(e.directory,"."):rR.tmpdir();return t(r?rj.join(n,r):n+"/")})},rK=rH("makeTempDirectory"),rQ=e=>{let t=(0,L._r7)(rN.rm,rr("FileSystem",e),rU(e));return(e,r)=>t(e,{recursive:r?.recursive??!1,force:r?.force??!1})},rZ=rQ("remove"),r0=(b=rH("makeTempDirectoryScoped"),v=rQ("makeTempDirectoryScoped"),e=>L.Q56(b(e),e=>L.QgK(v(e,{recursive:!0})))),r1=(F="open",_=(0,L._r7)(rN.open,rr("FileSystem",F),rU(F)),x=(0,L._r7)(rN.close,rr("FileSystem",F),rU(F)),(e,t)=>(0,W.Fs)(L.Q56(_(e,t?.flag??"r",t?.mode),e=>L.QgK(x(e))),L.TjK(e=>r2(e,t?.flag?.startsWith("a")??!1)))),r2=(()=>{let e=e=>(0,L._r7)(rN.read,rr("FileSystem",e),rU(e)),t=e("read"),r=e("readAlloc"),n=(0,L._r7)(rN.fstat,rr("FileSystem","stat"),rU("stat")),i=(0,L._r7)(rN.ftruncate,rr("FileSystem","truncate"),rU("truncate")),a=(0,L._r7)(rN.fsync,rr("FileSystem","sync"),rU("sync")),s=e=>(0,L._r7)(rN.write,rr("FileSystem",e),rU(e)),o=s("write"),l=s("writeAll");class d{[tD];fd;append;position=BigInt(0);constructor(e,t){this[tD]=tD,this.fd=e,this.append=t}get stat(){return L.qIB(n(this.fd,{bigint:!0}),nt)}get sync(){return a(this.fd)}seek(e,t){return L.DYE(()=>{let r="start"===t?e:this.position+e;return r<BigInt(0)?L.fJG(el({module:"FileSystem",method:"seek",description:"Cannot seek before the start of the file"})):(this.position=r,L.PyW(r))})}read(e){return L.DYE(()=>{let r=this.position;return L.TjK(t(this.fd,{buffer:e,position:r}),e=>(this.position=r+BigInt(e),e))})}readAlloc(e){return L.DYE(()=>{try{if(!Number.isInteger(e)||e<0)throw RangeError("size must be a non-negative integer");let t=Buffer.allocUnsafeSlow(e),n=this.position;return L.TjK(r(this.fd,{buffer:t,position:n}),r=>{if(0===r)return et.none();if(this.position=n+BigInt(r),r===e)return et.some(t);let i=Buffer.allocUnsafeSlow(r);return t.copy(i,0,0,r),et.some(i)})}catch(e){return L.fJG(rU("readAlloc")(e))}})}truncate(e){return L.TjK(i(this.fd,e||void 0),()=>{if(!this.append){let t=BigInt(e??0);this.position>t&&(this.position=t)}})}write(e){return L.DYE(()=>{let t=this.position;return L.qIB(this.append?L.PyW(void 0):rL(t,"write"),r=>L.TjK(o(this.fd,e,void 0,void 0,r),e=>(this.append||(this.position=t+BigInt(e)),e)))})}writeAllChunk(e){return L.DYE(()=>{let t=this.position;return L.qIB(this.append?L.PyW(void 0):rL(t,"writeAll"),r=>L.qIB(l(this.fd,e,void 0,void 0,r),r=>0===r?L.fJG(eo({module:"FileSystem",method:"writeAll",_tag:"WriteZero",pathOrDescriptor:this.fd,description:"write returned 0 bytes written"})):(this.append||(this.position=t+BigInt(r)),r<e.length?this.writeAllChunk(e.subarray(r)):L.rIH)))})}writeAll(e){return 0===e.length?L.rIH:this.writeAllChunk(e)}}return(e,t)=>new d(e,t)})(),r5=e=>{let t=rH(e);return L.D9k(function*(e){let r=yield*t(e),n=rT.randomBytes(6).toString("hex"),i=rj.join(r,e?.suffix?`${n}${e.suffix}`:n);return yield*ns(i,new Uint8Array(0)),i})},r3=r5("makeTempFile"),r6=(w=r5("makeTempFileScoped"),k=rQ("makeTempFileScoped"),e=>L.Q56(w(e),e=>L.QgK(k(rj.dirname(e),{recursive:!0})))),r8=(e,t)=>L.$mh({try:()=>rN.promises.readdir(e,t),catch:t=>rr("FileSystem","readDirectory")(t,[e])}),r9=e=>L.E2r((t,r)=>{try{rN.readFile(e,{signal:r},(r,n)=>{r?t(L.fJG(rr("FileSystem","readFile")(r,[e]))):t(L.PyW(n))})}catch(e){t(L.fJG(rU("readFile")(e)))}}),r4=(S=(0,L._r7)(rN.readlink,rr("FileSystem","readLink"),rU("readLink")),e=>S(e)),r7=(I=(0,L._r7)(rN.realpath,rr("FileSystem","realPath"),rU("realPath")),e=>I(e)),ne=($=(0,L._r7)(rN.rename,rr("FileSystem","rename"),rU("rename")),(e,t)=>$(e,t)),nt=e=>L.SvU({try:()=>({type:e.isFile()?"File":e.isDirectory()?"Directory":e.isSymbolicLink()?"SymbolicLink":e.isBlockDevice()?"BlockDevice":e.isCharacterDevice()?"CharacterDevice":e.isFIFO()?"FIFO":e.isSocket()?"Socket":"Unknown",mtime:et.fromNullishOr(e.mtime),atime:et.fromNullishOr(e.atime),birthtime:et.fromNullishOr(e.birthtime),dev:rF(e.dev,"dev"),rdev:rB(e.rdev),ino:rB(e.ino),mode:rF(e.mode,"mode"),nlink:rB(e.nlink),uid:rB(e.uid),gid:rB(e.gid),size:Z.ee(e.size),blksize:void 0!==e.blksize?et.some(Z.ee(e.blksize)):et.none(),blocks:rB(e.blocks)}),catch:rU("stat")}),nr=(E=(0,L._r7)(rN.stat,rr("FileSystem","stat"),rU("stat")),e=>L.qIB(E(e,{bigint:!0}),nt)),nn=(O=(0,L._r7)(rN.symlink,rr("FileSystem","symlink"),rU("symlink")),(e,t)=>O(e,t)),ni=(C=(0,L._r7)(rN.truncate,rr("FileSystem","truncate"),rU("truncate")),(e,t)=>C(e,t)),na=(T=(0,L._r7)(rN.utimes,rr("FileSystem","utime"),rU("utime")),(e,t,r)=>T(e,t,r)),ns=(e,t,r)=>L.E2r((n,i)=>{try{rN.writeFile(e,t,{signal:i,flag:r?.flag,mode:r?.mode},t=>{t?n(L.fJG(rr("FileSystem","writeFile")(t,[e]))):n(L.rIH)})}catch(e){n(L.fJG(rU("writeFile")(e)))}}),no=L.TjK(L.Nav(tU),e=>{let t;return t={access:rz,chmod:rY,chown:rX,copy:rW,copyFile:rJ,glob:rq,link:rG,makeDirectory:rV,makeTempDirectory:rK,makeTempDirectoryScoped:r0,makeTempFile:r3,makeTempFileScoped:r6,open:r1,readDirectory:r8,readFile:r9,readLink:r4,realPath:r7,remove:rZ,rename:ne,stat:nr,symlink:nn,truncate:ni,utimes:na,watch:(t,r)=>nr(t).pipe(L.TjK(n=>e.pipe(et.flatMap(e=>e.register(t,n,r)),et.getOrElse(()=>{let e,i;return tk((e=e=>L.Q56(L.OH5(()=>{let i="Directory"===n.type?t:rj.dirname(t),a=rN.watch(t,{recursive:r?.recursive??!1},(t,r)=>{if(r)switch(t){case"rename":return void L.MY7(L.tvg(nr(rj.resolve(i,r)),{onSuccess:t=>eO(e,{_tag:"Create",path:r}),onFailure:t=>eO(e,{_tag:"Remove",path:r})}));case"change":return void eC(e,{_tag:"Update",path:r})}});return a.on("error",r=>{eM(e,B.fJ(eo({module:"FileSystem",_tag:"Unknown",method:"watch",pathOrDescriptor:t,cause:r})))}),a.on("close",()=>{eP(e)}),a}),e=>L.OH5(()=>e.close())),i=void 0,e6((t,r)=>L.TjK(eE({capacity:i?.bufferSize,strategy:i?.strategy}).pipe(L.Mim(e=>e1.U9(r,eA(e))),L.Mim(t=>L.ar0(e1.Gt(e(t),r),r))),eR))))}))),tO),writeFile:ns},tj.of({...t,[tR]:tR,exists:e=>(0,W.Fs)(t.access(e),L.as(!0),L.KuX("PlatformError",e=>"NotFound"===e.reason._tag?L.PyW(!1):L.fJG(e))),readFileString:(e,r)=>L.qIB(t.readFile(e),e=>L.SvU({try:()=>new TextDecoder(r).decode(e),catch:e=>el({module:"FileSystem",method:"readFileString",description:"invalid encoding",cause:e})})),stream:L.D9k(function*(e,r){let n=yield*t.open(e,{flag:"r"}),i=r?.offset===void 0?void 0:Z.bN(r.offset);i&&(yield*n.seek(i,"start"));let a=r?.bytesToRead===void 0?void 0:Z.bN(r.bytesToRead),s=BigInt(0),o=Number(BigInt(r?.chunkSize??65536)),l=n.readAlloc(o);return tk(e9(L.PyW(L.qIB(L.DYE(()=>void 0!==a&&a<=s?B.Vw():void 0!==a&&a-s<o?n.readAlloc(Number(a-s)):l),et.match({onNone:()=>B.Vw(),onSome:e=>(s+=BigInt(e.length),L.PyW(Q.of(e)))})))))},tO),sink:(e,r)=>(0,W.Fs)(t.open(e,{...r,flag:r?.flag??"w"}),L.TjK(e=>{let t,r;return t=t=>e.writeAll(t),r=L.jJl(e=>t(e),{discard:!0}),tg(e=>e.pipe(L.qIB(r),L.i4r({disableYield:!0}),eg.m8(()=>tf)))}),tv),writeFileString:(e,r,n)=>L.qIB(L.SvU({try:()=>new TextEncoder().encode(r),catch:e=>el({module:"FileSystem",method:"writeFileString",description:"could not encode string",cause:e})}),r=>t.writeFile(e,r,n))})}),nl=(V.QZ(tj))(no),nd=t("node:url"),nc=e=>({fromFileUrl:t=>L.SvU({try:()=>nd.fileURLToPath(t,{windows:e}),catch:e=>new ei({module:"Path",method:"fromFileUrl",cause:e})}),toFileUrl:t=>L.SvU({try:()=>nd.pathToFileURL(t,{windows:e}),catch:e=>new ei({module:"Path",method:"toFileUrl",cause:e})})});rj.posix,rj.win32;let nu=(V.Py(tB))({[tF]:tF,...rD,...nc(void 0)}),nf="~effect/Stdio",np=ee.kl(nf),nh=V.Py(np,(M={args:L.OH5(()=>process.argv.slice(2)),stdinIsTerminal:L.OH5(()=>!0===process.stdin.isTTY),stdoutIsTerminal:L.OH5(()=>!0===process.stdout.isTTY),stdout:e=>rn({evaluate:()=>process.stdout,onError:e=>eo({module:"Stdio",method:"stdout",_tag:"Unknown",cause:e}),endOnDone:e?.endOnDone??!1}),stderr:e=>rn({evaluate:()=>process.stderr,onError:e=>eo({module:"Stdio",method:"stderr",_tag:"Unknown",cause:e}),endOnDone:e?.endOnDone??!1}),stdin:ru({evaluate:()=>process.stdin,onError:e=>eo({module:"Stdio",method:"stdin",_tag:"Unknown",cause:e}),closeOnDone:!1})},{[nf]:nf,stdinIsTerminal:L.PyW(!1),stdoutIsTerminal:L.PyW(!1),...M})),nm={_tag:"Empty"},ng={_tag:"Closed"},ny={_A:W.D_,_E:W.D_};class nb{"~effect/RcRef"=ny;pipe(){return(0,eh.tT)(this,arguments)}state=nm;acquire;context;scope;idleTimeToLive;constructor(e,t,r,n){this.acquire=e,this.context=t,this.scope=r,this.idleTimeToLive=n}}let nv=(e,t,r)=>L.cfM(r(rs(t.fiber)),r=>{let n=t.acquired;return void 0!==n?z.N6(r)?n_(e,n):L.rIH:--t.awaiters>0||e.state!==t?L.rIH:(e.state=nm,ro(t.fiber))}),n_=(e,t)=>{if(t.refCount--,t.refCount>0)return L.rIH;let r=e.idleTimeToLive;return void 0===r||t.invalidated?(e.state===t&&(e.state=nm),e1.VN(t.scope,z.rI)):(K.MI(r)&&(t.fiber=L.FcF(n=>L.qIB(n(L.yy4(r)),()=>e.state===t&&0===t.refCount?(e.state=nm,e1.VN(t.scope,z.rI)):L.rIH)).pipe(L.yeE(L.OH5(()=>{t.fiber=void 0})),L.eJC(e.context),rd(e.scope))),L.rIH)},nx=e=>L.FcF(t=>L.qIB(L.z8E,r=>L.qIB(((e,t)=>{switch(e.state._tag){case"Closed":return L.GaK;case"Acquired":{let t=e.state;return t.refCount++,t.fiber?L.as(ro(t.fiber),t):L.PyW(t)}case"Acquiring":{let r=e.state;return r.awaiters++,nv(e,r,t)}case"Empty":{let r={_tag:"Acquiring",fiber:void 0,awaiters:1,acquired:void 0};e.state=r;let n=e1.LZ(),i=L.PpN(e.acquire,ee.WQ(e.context,e1.HG,n)).pipe(L.qIB(t=>{if(e.state!==r)return L.GaK;let i={_tag:"Acquired",value:t,scope:n,fiber:void 0,refCount:r.awaiters,invalidated:!1};return e.state=i,r.acquired=i,L.PyW(i)}),L.cfM(t=>z.oJ(t)?L.rIH:(e.state===r&&(e.state=nm),e1.VN(n,t))));return r.fiber=L.eJC(rl().context)(i),nv(e,r,t)}}})(e,t),t=>L.as(e1.a6(r,()=>n_(e,t)),t.value))));var nw=n(2718);let nk="~effect/Terminal",nS="~effect/Terminal/QuitError";class nI extends(nw.$DH("QuitError"))({_tag:nw.TcI("QuitError")}){[nS]=nS}let n$=ee.kl("effect/Terminal"),nE=t("node:readline"),nO=L.D9k(function*(e=nT){let t,r,n=process.stdin,i=process.stdout,a=yield*eE(),s=n.readableEnded,o=!1,l=()=>{s=!0,o||eP(a)};n.once("end",l),yield*L.U9h(()=>L.OH5(()=>n.off("end",l)));let d=yield*(t={acquire:L.Q56(L.OH5(()=>{let e=nE.createInterface({input:n,escapeCodeTimeout:50}),t=e=>eC(a,e),r=()=>{o=!1,eP(a)};return o=!0,nE.emitKeypressEvents(n,e),e.on("line",t),e.once("close",r),n.isTTY&&n.setRawMode(!0),{rl:e,onClose:r,onLine:t}}),({rl:e,onClose:t,onLine:r})=>L.OH5(()=>{o=!1,e.off("line",r),e.off("close",t),n.isTTY&&n.setRawMode(!1),e.close(),s&&eP(a)})),idleTimeToLive:"10 millis"},L.R6R(e=>{let r=e.context,n=ee.Jt(r,e1.HG),i=new nb(t.acquire,r,n,void 0!==t.idleTimeToLive?K.bN(t.idleTimeToLive):void 0);return L.as(e1.a6(n,()=>{let e=i.state;return(i.state=ng,"Acquired"===e._tag)?e1.VN(e.scope,z.rI):"Acquiring"===e._tag?ro(e.fiber):L.rIH}),i)})),c=L.OH5(()=>i.columns??0),u=L.OH5(()=>i.rows??0),f=L.JkU(function*(){let t=yield*eE(),r=(r,n)=>{let i={input:et.fromUndefinedOr(r),key:{name:n.name??"",ctrl:!!n.ctrl,meta:!!n.meta,shift:!!n.shift}};eC(t,i),e(i)&&eP(t)},i=setInterval(()=>{},0x7fffffff),a=()=>{clearInterval(i),eP(t)};return yield*L.U9h(()=>L.OH5(()=>{clearInterval(i),n.off("keypress",r),n.off("end",a)})),n.on("keypress",r),s?a():(yield*nx(d),n.once("end",a)),t});return r={columns:c,rows:u,readInput:f,readLine:L.DYE(()=>eb.DYE(()=>{let e=eU(a);return void 0===e?eb.PyW(et.none()):"Success"===e._tag?eb.PyW(et.some(e.value)):eb.PyW(et.none())}).pipe(L.qIB(et.match({onNone:()=>L.P1j(L.hgn(nx(d),eD(a))),onSome:L.PyW})),L.xm_(()=>new nI({})))),display:e=>L.rfi(L.E2r(t=>{i.write(e,e=>em.uy(e)?t(L.rIH):t(L.fJG(el({module:"Terminal",method:"display",description:"Failed to write prompt to stdout",cause:e}))))}))},n$.of({...r,[nk]:nk})}),nC=V.QZ(n$,nO(nT));function nT(e){return e.key.ctrl&&("c"===e.key.name||"d"===e.key.name)}let nM=V.S5(r_,V.Um(nl,rP,nu,nh,nC));var nP=n(3178),nA=n(7086);class nN extends nw.rNF()("CliFilesystemError",{cause:nw.kld(),operation:nw.QfV,path:nw.QfV,message:nw.QfV}){}class nR extends nw.rNF()("CliInputError",{code:nw.xCb(["input_read_failed","invalid_json","interactive_stdin"]),message:nw.QfV,hint:nw.QfV}){}class nj extends nw.rNF()("CliValidationError",{message:nw.QfV,hint:nw.QfV,details:nw.O31(nw.QfV)}){}class nD extends nw.rNF()("CliBuildError",{status:nw.QfV,message:nw.QfV,hint:nw.QfV,details:nw.O31(nw.QfV)}){}class nU extends nw.rNF()("CliGenerationError",{code:nw.xCb(["provider_failure","generation_timeout","malformed_output","invalid_generated_document","unsupported_diagram_type"]),message:nw.QfV,hint:nw.QfV,details:nw.O31(nw.QfV)}){}class nF extends nw.rNF()("CliCanvasError",{code:nw.xCb(["canvas_rejected","canvas_timeout","endpoint_failure","malformed_response","network_failure"]),message:nw.QfV,hint:nw.QfV,details:nw.O31(nw.QfV)}){}class nB extends nw.rNF()("CliInteractiveError",{code:nw.xCb(["cancelled","prompt_failed"]),message:nw.QfV,hint:nw.QfV}){}class nL extends nw.rNF()("CliStorageError",{code:nw.xCb(["diagram_not_found","diagram_already_exists","diagram_busy","detached_edit","patch_source_unavailable","patch_conflict","replacement_conflict","restore_conflict","revision_not_found","corrupt_revision","corrupt_record","unsafe_storage_entry","storage_commit_failed"]),diagramId:nw.Qrq(nw.QfV),message:nw.QfV,hint:nw.QfV}){}class nz extends nw.rNF()("CliShareError",{code:nw.xCb(["invalid_share_link","unsupported_scene","share_payload_too_large","share_crypto_failed","share_transport_failed","share_timeout","share_api_changed","share_link_unavailable"]),message:nw.QfV,hint:nw.QfV,details:nw.O31(nw.QfV)}){}class nW extends nw.rNF()("CliExportError",{code:nw.xCb(["format_unavailable","invalid_destination","render_failed","invalid_render_artifact","render_limit_exceeded","unsupported_render_glyph","rasterization_failed","export_write_failed"]),diagramId:nw.Qrq(nw.QfV),storagePath:nw.Qrq(nw.QfV),recoveryCommand:nw.Qrq(nw.QfV),details:nw.Qrq(nw.O31(nw.QfV)),format:nw.QfV,message:nw.QfV,hint:nw.QfV}){}function nJ(e){return"string"==typeof e||"number"==typeof e||"symbol"==typeof e}let nY=nA.ID(),nX=nw._Re(nP.Ky,{errors:"all"}),nq=nw._Re(nP.e5,{errors:"all"}),nG=nw._Re(nP.nu,{errors:"all"}),nV=nw._Re(nP.y1,{errors:"all"});function nH(e){return nj.make({message:"The canonical diagram document is invalid.",hint:'Use {"type":"flowchart","spec":...}, {"type":"mindmap","spec":...}, or {"type":"sequence","spec":...}.',details:e})}function nK(e){return nY(e).issues.map(e=>{var t;let r=(e.path??[]).flatMap(e=>{let t=nJ(e)?e:null!==e&&"object"==typeof e&&"key"in e&&nJ(e.key)?e.key:void 0;return void 0===t?[]:[t]});return`${0===(t=["spec",...r]).length?"document":t.map(e=>"number"==typeof e?`[${e}]`:String(e)).join(".")}: ${e.message}`})}function nQ(e){if(!("object"!=typeof e||null===e||Array.isArray(e))&&"type"in e&&"spec"in e)return{type:e.type,spec:e.spec}}let nZ=L.fn("sketchi.cli.document.decodeCanonical")(function*(e){let t=nQ(e);return t?"flowchart"===t.type?{type:"flowchart",spec:yield*nX(t.spec).pipe(L.xm_(e=>nH(nK(e.issue))))}:"mindmap"===t.type?{type:"mindmap",spec:yield*nq(t.spec).pipe(L.xm_(e=>nH(nK(e.issue))))}:"sequence"===t.type?{type:"sequence",spec:yield*nG(t.spec).pipe(L.xm_(e=>nH(nK(e.issue))))}:yield*nH(['document.type: Expected "flowchart", "mindmap", or "sequence".']):yield*nH(["document: Expected an object with type and spec."])}),n0=L.fn("sketchi.cli.document.parseJson")(function*(e){let t=yield*L.SvU({try:()=>JSON.parse(e),catch:()=>nR.make({code:"invalid_json",message:"The input is not valid JSON.",hint:"Pass one complete canonical document object."})});return yield*nZ(t)}),n1=L.fn("sketchi.cli.document.decodeStored")(function*(e){let t=nQ(e);return t?.type!=="canvas"?yield*nZ(e):{type:"canvas",spec:yield*nV(t.spec).pipe(L.xm_(e=>nH(nK(e.issue))))}});function n2(e){return`${JSON.stringify(e,null,2)}
3
- `}function n5(e){let t=e.spec.id?.trim();return t||e.spec.title.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||`sketchi-${e.type}`}function n3(e){return/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}$/.test(e)?L.PyW(e):L.fJG(nj.make({message:`Diagram id "${e}" is not safe for local storage.`,hint:"Use 1-128 ASCII letters, digits, dots, underscores, or hyphens; start with a letter or digit.",details:["spec.id"]}))}class n6 extends ee.kl()("@sketchi/cli/DiagramBuilder"){}function n8(e){let t=e.ref?.path?` (${e.ref.path})`:"";return`${e.code}${t}: ${e.message}`}function n9(e,t){let r=e.formats.find(e=>e.format===t);return r?.inline!==void 0?L.PyW(r.inline):L.fJG(nD.make({status:"missing_inline_artifact",message:`Code Mode did not return the ${t} artifact inline.`,hint:"Rebuild the document with the required offline artifact formats.",details:[t]}))}function n4(e){let t=nP.Uh.safeParse(e);return t.success?L.PyW(t.data):L.fJG(nD.make({status:"invalid_scene_artifact",message:"Code Mode returned an invalid scene artifact.",hint:"Inspect the Code Mode build/export boundary.",details:t.error.issues.map(e=>e.message)}))}function n7(e){let t=nP.yE.safeParse(e);return t.success?L.PyW(t.data):L.fJG(nD.make({status:"invalid_excalidraw_artifact",message:"Code Mode returned an invalid Excalidraw artifact.",hint:"Inspect the Code Mode build/export boundary.",details:t.error.issues.map(e=>e.message)}))}let ie=V.QZ(n6,L.JkU(function*(){let e=yield*nP.Ov,t=yield*nP.UA;return{build:L.fn("sketchi.cli.diagram.build")(function*(r){let n;if(!(n="flowchart"===r.type?yield*(0,nP.XV)({spec:r.spec,options:{artifactFormats:["scene","excalidraw"],inlineArtifacts:["scene","excalidraw"]}}).pipe(L.PfK(nP.Ov,e),L.PfK(nP.UA,t)):"mindmap"===r.type?yield*(0,nP.r8)({spec:r.spec,options:{artifactFormats:["scene","excalidraw"],inlineArtifacts:["scene","excalidraw"]}}).pipe(L.PfK(nP.Ov,e),L.PfK(nP.UA,t)):yield*(0,nP.rC)({spec:r.spec,options:{artifactFormats:["scene","excalidraw"],inlineArtifacts:["scene","excalidraw"]}}).pipe(L.PfK(nP.Ov,e),L.PfK(nP.UA,t))).ok){let e,t,r,i;return yield*(e=n.issues[0],t=e?.message??`Code Mode failed with ${n.status}.`,r=e?.hint??"Repair the document and retry.",i=n.issues.map(n8),"invalid_input"===n.status||"invalid_flowchart"===n.status||"invalid_mindmap"===n.status||"invalid_sequence"===n.status||"quality_failed"===n.status?nj.make({message:t,hint:r,details:i}):"storage_failed"===n.status?nL.make({code:"storage_commit_failed",message:t,hint:r}):nD.make({status:n.status,message:t,hint:r,details:i}))}let i=yield*n3(n5(r)),a=yield*n9(n.artifact,"scene").pipe(L.qIB(n4)),s=yield*n9(n.artifact,"excalidraw").pipe(L.qIB(n7));return{id:i,type:r.type,title:r.spec.title,document:r,scene:a,excalidraw:s}})}})),it=t("node:fs/promises");class ir extends ee.kl()("@sketchi/cli/LocalFileSystem"){}function ii(e,t,r){return nN.make({cause:r,operation:e,path:t,message:`Filesystem ${e} failed for ${t}.`})}function ia(e,t){return"object"==typeof e&&null!==e&&"code"in e&&e.code===t}let is=V.Py(ir,{makeDirectory:(e,t=!1)=>L.$mh({try:()=>(0,it.mkdir)(e,{recursive:t}).then(()=>void 0),catch:t=>ii("make-directory",e,t)}),tryWriteText:(e,t)=>L.$mh({try:async()=>{try{let r=await (0,it.open)(e,rN.constants.O_WRONLY|rN.constants.O_CREAT|rN.constants.O_EXCL|rN.constants.O_NOFOLLOW,384);try{await r.writeFile(t,{encoding:"utf8"}),await r.sync()}finally{await r.close()}return!0}catch(e){if(ia(e,"EEXIST"))return!1;throw e}},catch:t=>ii("write-exclusive",e,t)}),tryLinkFile:(e,t)=>L.$mh({try:async()=>{try{return await (0,it.link)(e,t),!0}catch(e){if(ia(e,"EEXIST")||ia(e,"ENOENT"))return!1;throw e}},catch:r=>ii("link-exclusive",`${e} -> ${t}`,r)}),makeTempDirectory:(e,t)=>L.$mh({try:()=>(0,it.mkdtemp)((0,rj.join)(e,t)),catch:t=>ii("make-temp-directory",e,t)}),list:e=>L.$mh({try:async()=>(await (0,it.readdir)(e,{withFileTypes:!0})).map(e=>({name:e.name,kind:e.isFile()?"file":e.isDirectory()?"directory":e.isSymbolicLink()?"symbolic-link":"other"})),catch:t=>ii("read-directory",e,t)}),kind:e=>L.$mh({try:async()=>{try{let t=await (0,it.lstat)(e);if(t.isFile())return"file";if(t.isDirectory())return"directory";if(t.isSymbolicLink())return"symbolic-link";return"other"}catch(e){if(ia(e,"ENOENT"))return"missing";if(ia(e,"ELOOP"))return"symbolic-link";throw e}},catch:t=>ii("stat",e,t)}),realPath:e=>L.$mh({try:()=>(0,it.realpath)(e),catch:t=>ii("resolve",e,t)}),readText:e=>L.$mh({try:async()=>{let t=await (0,it.open)(e,rN.constants.O_RDONLY|rN.constants.O_NOFOLLOW);try{return await t.readFile({encoding:"utf8"})}finally{await t.close()}},catch:t=>ii("read",e,t)}),readBytes:e=>L.$mh({try:async()=>{let t=await (0,it.open)(e,rN.constants.O_RDONLY|rN.constants.O_NOFOLLOW);try{return new Uint8Array(await t.readFile())}finally{await t.close()}},catch:t=>ii("read",e,t)}),writeText:(e,t,r=!1)=>L.$mh({try:async()=>{let n=rN.constants.O_WRONLY|rN.constants.O_CREAT|rN.constants.O_NOFOLLOW|(r?rN.constants.O_TRUNC:rN.constants.O_EXCL),i=await (0,it.open)(e,n,384);try{await i.writeFile(t,{encoding:"utf8"}),await i.sync()}finally{await i.close()}},catch:t=>ii("write",e,t)}),writeBytes:(e,t,r=!1)=>L.$mh({try:async()=>{let n=rN.constants.O_WRONLY|rN.constants.O_CREAT|rN.constants.O_NOFOLLOW|(r?rN.constants.O_TRUNC:rN.constants.O_EXCL),i=await (0,it.open)(e,n,384);try{await i.writeFile(t),await i.sync()}finally{await i.close()}},catch:t=>ii("write",e,t)}),rename:(e,t)=>L.$mh({try:()=>(0,it.rename)(e,t),catch:r=>ii("rename",`${e} -> ${t}`,r)}),tryRenameDirectory:(e,t)=>L.$mh({try:async()=>{try{return await (0,it.rename)(e,t),!0}catch(e){if(ia(e,"EEXIST")||ia(e,"ENOTEMPTY"))return!1;if(ia(e,"EPERM"))try{if((await (0,it.lstat)(t)).isDirectory())return!1}catch{}throw e}},catch:r=>ii("rename-exclusive-directory",`${e} -> ${t}`,r)}),removeFile:e=>L.$mh({try:async()=>{try{return await (0,it.unlink)(e),!0}catch(e){if(ia(e,"ENOENT"))return!1;throw e}},catch:t=>ii("remove-file",e,t)}),remove:e=>L.$mh({try:()=>(0,it.rm)(e,{recursive:!0,force:!0}),catch:t=>ii("remove",e,t)})});function io(e,t){return nj.make({message:e,hint:"Provide operations and optional options or intent only.",details:t})}let il=L.fn("sketchi.cli.patch.decodeInput")(function*(e){if("object"!=typeof e||null===e||Array.isArray(e))return yield*io("The diagram patch request is invalid.",["patch: Expected an object."]);if("source"in e)return yield*io("The diagram patch request cannot supply source.",["source: The CLI binds the stored scene."]);if("requestId"in e)return yield*io("The diagram patch request cannot supply requestId.",["requestId: The CLI owns the patch request id."]);let t=nP.Er.safeParse({...e,requestId:"cli-patch-validation",source:{scene:{kind:"canvas",version:1,diagramId:"validation",title:"Validation",width:1,height:1,accentColor:"#000000",backgroundColor:"#ffffff",elements:[],layers:[],layouts:[],zOrder:[]}}});return t.success?{operations:t.data.operations,...t.data.options?{options:t.data.options}:{},...t.data.intent?{intent:t.data.intent}:{}}:yield*io("The diagram patch request is invalid.",t.error.issues.map(e=>e.message))}),id=L.fn("sketchi.cli.patch.parseJson")(function*(e){let t=yield*L.SvU({try:()=>JSON.parse(e),catch:()=>nR.make({code:"invalid_json",message:"The patch input is not valid JSON.",hint:"Pass one complete diagram patch request object."})});return yield*il(t)});class ic extends ee.kl()("@sketchi/cli/DiagramPatcher"){}function iu(e){let t=e.ref?.path?` (${e.ref.path})`:"";return`${e.code}${t}: ${e.message}`}function ip(e,t){let r=e.formats.find(e=>e.format===t);return r?.inline!==void 0?L.PyW(r.inline):L.fJG(nD.make({status:"missing_inline_artifact",message:`Code Mode did not return the patched ${t} artifact inline.`,hint:"Retry the offline patch with the required artifact formats.",details:[t]}))}function ih(e){let t=nP.Uh.safeParse(e);return t.success?L.PyW(t.data):L.fJG(nD.make({status:"invalid_scene_artifact",message:"Code Mode returned an invalid patched scene artifact.",hint:"Inspect the Code Mode patch/export boundary.",details:t.error.issues.map(e=>e.message)}))}function im(e){let t=nP.yE.safeParse(e);return t.success?L.PyW(t.data):L.fJG(nD.make({status:"invalid_excalidraw_artifact",message:"Code Mode returned an invalid patched Excalidraw artifact.",hint:"Inspect the Code Mode patch/export boundary.",details:t.error.issues.map(e=>e.message)}))}let ig=V.QZ(ic,L.JkU(function*(){let e=yield*nP.Ov,t=yield*nP.UA;return{patch:L.fn("sketchi.cli.diagram.patch")(function*(r,n,i){let a=yield*(0,nP.OF)({requestId:i,source:{scene:r},operations:n.operations,options:{...n.options,artifactFormats:["scene","excalidraw"],inlineArtifacts:["scene","excalidraw"]},...n.intent?{intent:n.intent}:{}}).pipe(L.PfK(nP.Ov,e),L.PfK(nP.UA,t));if(!a.ok){let e,t,r,n;return yield*(e=a.issues[0],t=e?.message??`Code Mode patch failed with ${a.status}.`,r=e?.hint??"Repair the patch request and retry.",n=a.issues.map(iu),"invalid_input"===a.status||"target_not_found"===a.status||"unsupported_operation"===a.status||"connectivity_changed"===a.status?nj.make({message:t,hint:r,details:n}):"storage_failed"===a.status?nL.make({code:"storage_commit_failed",message:t,hint:r}):nD.make({status:a.status,message:t,hint:r,details:n}))}return{scene:yield*ip(a.artifact,"scene").pipe(L.qIB(ih)),excalidraw:yield*ip(a.artifact,"excalidraw").pipe(L.qIB(im))}})}}));class iy extends ee.kl()("@sketchi/cli/InputReader"){}function ib(e,t){return L.SvU({try:()=>new TextDecoder("utf-8",{fatal:!0}).decode(e),catch:()=>nR.make({code:"input_read_failed",message:"stdin"===t?"Standard input is not valid UTF-8.":"The input file is not valid UTF-8.",hint:"Provide one complete UTF-8 JSON document and retry."})})}let iv=function(e=()=>!0===process.stdin.isTTY){return V.QZ(iy,L.JkU(function*(){let t=yield*ir,r=yield*np;return{read:L.fn("sketchi.cli.input.read")(function*(n,i={content:"JSON document"}){if("InlineJson"===n._tag)return n.value;if("-"!==n.path){let e=yield*t.readBytes(n.path).pipe(L.xm_(()=>nR.make({code:"input_read_failed",message:`Unable to read input file ${n.path}.`,hint:"Check the path and file permissions, then retry."})));return yield*ib(e,"file")}if(e())return yield*nR.make({code:"interactive_stdin",message:`${i.content} input requires piped or redirected stdin.`,hint:"share link"===i.content?"Pipe one complete Excalidraw share link to --link -.":"Pipe one JSON document, or use --file PATH / --json VALUE."});let a=yield*tN(r.stdin,()=>({chunks:[],size:0}),(e,t)=>{let r=t.byteLength+e.size;return void 0!==i.maxBytes&&r>i.maxBytes?L.fJG(nR.make({code:"input_read_failed",message:`Standard input exceeds the ${String(i.maxBytes)} byte limit for a ${i.content}.`,hint:`Pipe one complete ${i.content} within the documented limit.`})):L.PyW({chunks:[...e.chunks,t],size:r})}).pipe(L.xm_(e=>e instanceof nR?e:nR.make({code:"input_read_failed",message:`Unable to read the ${i.content} from stdin.`,hint:`Pipe one complete UTF-8 ${i.content} and retry.`})));return yield*ib(function(e){let t=new Uint8Array(e.reduce((e,t)=>e+t.byteLength,0)),r=0;for(let n of e)t.set(n,r),r+=n.byteLength;return t}(a.chunks),"stdin")})}}))}(),i_=L.fn("sketchi.cli.input.readDocument")(function*(e){let t=yield*iy,r=yield*t.read(e);return yield*n0(r)}),ix=L.fn("sketchi.cli.input.readPatch")(function*(e){let t=yield*iy,r=yield*t.read(e,{content:"patch request"});return yield*id(r)}),iw=t("node:zlib");var ik=n(6771);let iS=1,iI="manifest.json",i$="document.json",iE="scene.json",iO="diagram.excalidraw",iC="diagram.png",iT="revisions";class iM extends nw.Xsx("DiagramRecordManifest")({schemaVersion:nw.uSQ(iS),id:nw.QfV,type:nw.xCb(["canvas","flowchart","mindmap","sequence"]),title:nw.QfV,revision:nw.Aiz.check(nw.yJO(0)),authority:nw.xCb(["canonical","patched","detached"]).pipe(nw.E$i(L.PyW("canonical"))),formats:nw.O31(nw.xCb(["scene","excalidraw","png"]))}){}function iP(e){return{id:e.manifest.id,type:e.manifest.type,title:e.manifest.title,revision:e.manifest.revision,formats:e.manifest.formats,authority:e.authority,documentAuthoritative:e.documentAuthoritative}}function iA(e){return String(e).padStart(6,"0")}var iN=n(8689),iR=n(5030);let ij="https://json.excalidraw.com/api/v2/",iD=["rectangle","ellipse","diamond","arrow","line","freedraw","text"],iU=new Set(iD),iF=new TextEncoder,iB=new TextDecoder("utf-8",{fatal:!0}),iL=iF.encode(JSON.stringify({version:2,compression:"pako@1",encryption:"AES-GCM"}));function iz(e,t,r,n=[]){return nz.make({code:e,message:t,hint:r,details:n})}function iW(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function iJ(e){return"number"==typeof e&&Number.isFinite(e)}function iY(e,t,r){new DataView(e.buffer,e.byteOffset,e.byteLength).setUint32(t,r)}function iX(e,t){if(t+4>e.byteLength)throw Error("truncated chunk header");return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint32(t)}function iq(e,t){if(e.byteLength<4+4*t||1!==iX(e,0))throw Error("unsupported chunk format");let r=[],n=4;for(let i=0;i<t;i+=1){let t=iX(e,n),i=(n+=4)+t;if(i>e.byteLength)throw Error("truncated chunk");r.push(e.subarray(n,i)),n=i}if(n!==e.byteLength)throw Error("unexpected trailing chunk");return r}function iG(e){if(!/^[A-Za-z0-9_-]{22}$/.test(e))throw Error("invalid AES key encoding");let t=Buffer.from(e,"base64url");if(16!==t.byteLength)throw Error("invalid AES key length");return t}function iV(e,t){return crypto.subtle.importKey("raw",Uint8Array.from(iG(e)),{name:"AES-GCM",length:128},!1,[t])}function iH(e){if(!iW(e)||"excalidraw"!==e.type||!iJ(e.version)||"string"!=typeof e.source||!Array.isArray(e.elements)||!iW(e.appState)||!(void 0===e.files||iW(e.files)))throw Error("invalid Excalidraw artifact shape");return{type:e.type,version:e.version,source:e.source,elements:e.elements,appState:e.appState,files:e.files??{}}}function iK(e,t){return"string"!=typeof e||!t.has(e)}function iQ(e,t){if("number"==typeof e)return Number.isFinite(e)?void 0:`${t} must be finite`;if(Array.isArray(e))for(let r of e){let e=iQ(r,`${t} item`);if(e)return e}else if(iW(e))for(let r of Object.values(e)){let e=iQ(r,`${t} property`);if(e)return e}}function iZ(e){return L.SvU({try:()=>{let t=iH(e);if(iW(e)&&"libraryItems"in e)throw Error("Excalidraw library state is unsupported");if(t.elements.length>1e4)throw Error("element count exceeds 10000");if(Object.keys(t.files).length>0)throw Error("binary files are unsupported");let r=new Set;for(let[e,n]of t.elements.entries()){if(!iW(n)||"string"!=typeof n.id)throw Error(`elements[${String(e)}].id is invalid`);if(r.has(n.id))throw Error(`elements[${String(e)}].id is duplicated`);r.add(n.id)}for(let[e,n]of t.elements.entries()){let t=function(e,t,r){let n=`elements[${String(t)}]`;if(!iW(e)||"string"!=typeof e.id||0===e.id.length||"string"!=typeof e.type)return`elements[${String(t)}] is not an Excalidraw element`;if(!iU.has(e.type))return`${n}.type is unsupported`;if("link"in e&&null!==e.link&&void 0!==e.link||"fileId"in e)return`${n} contains an external resource`;let i=iQ(e,n);if(i)return i;for(let t of["x","y","width","height","angle"])if(!iJ(e[t]))return`${n}.${t} must be finite`;if("text"===e.type){if(5!==e.fontFamily)return`${n}.fontFamily must be ${String(5)}`;if("string"!=typeof e.text)return`${n}.text is invalid`}if(["arrow","line","freedraw"].includes(e.type)&&(!Array.isArray(e.points)||e.points.some(e=>!Array.isArray(e)||e.length<2||!iJ(e[0])||!iJ(e[1]))))return`${n}.points contains invalid geometry`;for(let t of["containerId","frameId"])if(null!==e[t]&&void 0!==e[t]&&iK(e[t],r))return`${n}.${t} is an invalid element reference`;for(let t of["startBinding","endBinding"]){let i=e[t];if(null!=i&&(!iW(i)||iK(i.elementId,r)))return`${n}.${t} is an invalid element binding`}let a=e.boundElements;if(null!=a&&(!Array.isArray(a)||a.some(e=>!iW(e)||iK(e.id,r))))return`${n}.boundElements contains an invalid element reference`}(n,e,r);if(t)throw Error(t)}let n=(0,iR.Gd)(t.elements);if(n)throw Error(n);let i=function(e){if("viewBackgroundColor"in e&&"string"!=typeof e.viewBackgroundColor)return"appState.viewBackgroundColor must be a string";if("gridModeEnabled"in e&&"boolean"!=typeof e.gridModeEnabled)return"appState.gridModeEnabled must be boolean";for(let t of["gridSize","gridStep"])if(t in e&&null!==e[t]&&!iJ(e[t]))return`appState.${t} must be finite or null`;if("lockedMultiSelections"in e){let t=e.lockedMultiSelections;if(!iW(t))return"appState.lockedMultiSelections must be an object";for(let[e,r]of Object.entries(t))if(0===e.length||!0!==r)return"appState.lockedMultiSelections contains an invalid lock entry"}return iQ(e,"appState")}(t.appState);if(i)throw Error(i);return e},catch:e=>iz("unsupported_scene","The Excalidraw scene is unsupported by share/pull v1.",`Use only ${iD.join(", ")} elements, Excalifont fontFamily ${String(5)}, and no files or images.`,[e instanceof Error?e.message:"invalid scene"])})}function i0(e){let t=new Uint8Array(4);return iY(t,0,e),t}class i1 extends ee.kl()("@sketchi/cli/StorageRoot"){}function i2(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}let i5=[[0,0,8,8],[4,0,8,8],[0,4,4,8],[2,0,4,4],[0,2,2,4],[1,0,2,2],[0,1,1,2]];function i3(e,t,r){return e<=t?0:Math.ceil((e-t)/r)}function i6(e){let t,r,n,i,a,s=[137,80,78,71,13,10,26,10];if(e.byteLength<33||s.some((t,r)=>e[r]!==t))return!1;let o=s.length,l=0,d=!1,c=!1,u=!1,f=[];for(;o+12<=e.byteLength;){let s=i2(e,o),p=o+12+s;if(p>e.byteLength)break;let h=o+4,m=e.subarray(h,h+4),g=e=>e>=65&&e<=90||e>=97&&e<=122;if(4!==m.byteLength||!m.every(g)||(32&m[2])!=0)break;let y=String.fromCharCode(...m);if(0===l&&("IHDR"!==y||13!==s))break;if("IHDR"===y){if(0!==l||13!==s)return!1;t=i2(e,o+8),r=i2(e,o+12),i=e[o+16],n=e[o+17],a=e[o+20];let d={0:[1,2,4,8,16],2:[8,16],3:[1,2,4,8],4:[8,16],6:[8,16]};if(0===t||0===r||t>0x7fffffff||r>0x7fffffff||void 0===n||void 0===i||!d[n]?.includes(i)||0!==e[o+18]||0!==e[o+19]||![0,1].includes(a??-1))break}else if("PLTE"===y){if(d||c||0===s||s%3!=0||s>768||0===n||4===n||3===n&&void 0!==i&&s/3>2**i)return!1;d=!0}else if("IDAT"===y){if(u||3===n&&!d)return!1;c=!0,f.push(e.subarray(o+8,o+8+s))}else if("IEND"===y){if(0!==s||!c||3===n&&!d)break}else{c&&(u=!0);let t=e[h];if(void 0===t||(32&t)==0)break}let b=i2(e,o+8+s);if(function(e){let t=0xffffffff;for(let r of e){t^=r;for(let e=0;e<8;e+=1)t=t>>>1^(1&t?0xedb88320:0)}return(0xffffffff^t)>>>0}(e.subarray(h,o+8+s))!==b)break;if(o=p,l+=1,"IEND"===y)return o===e.byteLength&&void 0!==t&&void 0!==r&&void 0!==i&&void 0!==n&&void 0!==a&&function(e,t,r,n,i,a){let s={0:1,2:3,3:1,4:2,6:4}[i];if(void 0===s)return!1;let o=function(e,t,r,n){let i=[],a=0;for(let[s,o,l,d]of 0===n?[[0,0,1,1]]:i5){let n=i3(e,s,l),c=i3(t,o,d);if(0===n||0===c)continue;let u=Math.ceil(n*r/8)+1;if(u>0x1000000-a||c>Math.floor((0x1000000-a)/u))return null;a+=c*u,i.push({rows:c,rowBytes:u})}return i}(t,r,s*n,a);if(null===o)return!1;let l=o.reduce((e,t)=>e+t.rows*t.rowBytes,0);try{let t=function(e){let t=new Uint8Array(e.reduce((e,t)=>e+t.byteLength,0)),r=0;for(let n of e)t.set(n,r),r+=n.byteLength;return t}(e),r=(0,iw.inflateSync)(t,{info:!0,maxOutputLength:0x1000000});if(r.engine.bytesWritten!==t.byteLength)return!1;let n=r.buffer;if(n.byteLength!==l)return!1;let i=0;for(let e of o)for(let t=0;t<e.rows;t+=1){if((n[i]??5)>4)return!1;i+=e.rowBytes}return i===n.byteLength}catch{return!1}}(f,t,r,i,n,a)}return!1}class i8 extends ee.kl()("@sketchi/cli/DiagramStore"){}let i9=".locks",i4="free.",i7="owner.",ae=".owner-candidate.",at=".json",ar="recovery",an=".backup.",ai=`.stage.${String(process.pid)}.`,aa=ik.ji("10 millis").pipe(ik.jB({times:50})),as=V.Py(i1,{path:(0,rj.join)((0,rR.homedir)(),".sketchi","diagrams")});function ao(e,t,r,n){return nL.make({code:e,message:t,hint:r,...n?{diagramId:n}:{}})}function al(e){return Buffer.from(e,"utf8").toString("base64url")}function ad(e,t){return e<t?-1:+(e>t)}function ac(e,t){let r=e.replace(/(?:\/|\.json)$/u,"").replace(/^0+/u,""),n=t.replace(/(?:\/|\.json)$/u,"").replace(/^0+/u,""),i=r.length-n.length;return 0!==i?i:ad(r,n)||ad(e,t)}function au(e){if(!Number.isSafeInteger(e)||e<=0)return!1;try{return process.kill(e,0),!0}catch(e){return"object"==typeof e&&null!==e&&"code"in e&&"EPERM"===e.code}}function af(e,t){return"object"==typeof e.cause&&null!==e.cause&&"code"in e.cause&&e.cause.code===t}function ap(e,t){return(0,rj.join)(e,t)}function ah(e){switch(e){case"scene":return iE;case"excalidraw":return iO;case"png":return iC}}function am(e,t){return ao("unsafe_storage_entry",`Unsafe local storage entry at ${e}.`,"Replace symbolic links or special files with ordinary Sketchi record files.",t)}let ag=V.QZ(i8,L.JkU(function*(){let e=yield*ir,t=yield*i1,r=L.fn("sketchi.cli.storage.ensureOwnedDirectory")(function*(t){let r=yield*e.kind(t);if("missing"===r&&(yield*e.makeDirectory(t).pipe(L.MfU(e=>af(e,"EEXIST")?L.rIH:L.fJG(e))),r=yield*e.kind(t)),"directory"!==r)return yield*am(t)}),n=L.fn("sketchi.cli.storage.ensureRoot")(function*(){yield*r((0,rj.dirname)(t.path)),yield*r(t.path),yield*r((0,rj.join)(t.path,i9))}),i=L.fn("sketchi.cli.storage.assertSafeTree")(function*(t,r){for(let n of yield*e.list(t)){let e=(0,rj.join)(t,n.name);if("symbolic-link"===n.kind||"other"===n.kind)return yield*am(e,r);"directory"===n.kind&&(yield*i(e,r))}}),a=L.fn("sketchi.cli.storage.recoverStages")(function*(r){for(let n of[...r??(yield*e.list(t.path))].sort((e,t)=>ad(e.name,t.name))){if(!n.name.startsWith(".stage."))continue;let r=function(e){let t=Number(e.split(".").at(-2));return Number.isSafeInteger(t)?t:void 0}(n.name);void 0!==r&&au(r)||(yield*e.remove((0,rj.join)(t.path,n.name)))}}),s=L.fn("sketchi.cli.storage.recoverRecordTransactions")(function*(r){let n=`${an}${al(r)}.`;for(let i of[...yield*e.list(t.path)].filter(e=>e.name.startsWith(n)).sort((e,t)=>ad(e.name,t.name))){let n=(0,rj.join)(t.path,i.name),a=ap(t.path,r);"missing"===(yield*e.kind(a))?yield*e.rename(n,a):yield*e.remove(n)}}),o=e=>(0,rj.join)(t.path,i9,`${al(e)}.lock`),l=L.fn("sketchi.cli.storage.initializeLockDirectory")(function*(r){let n=o(r),i=yield*e.kind(n);if("directory"===i)return n;if("missing"!==i)return yield*am(n,r);let a=(0,rj.join)(t.path,i9);return yield*L.jGc(e.makeTempDirectory(a,`.init.${al(r)}.`),t=>L.JkU(function*(){let i=crypto.randomUUID();return(yield*e.writeText((0,rj.join)(t,`${i4}${i}${at}`),n2({token:i})),(yield*e.tryRenameDirectory(t,n))||"directory"===(yield*e.kind(n)))?n:yield*am(n,r)}),t=>e.remove(t))}),d=e=>ao("diagram_busy",`Diagram "${e}" is being changed by another Sketchi process.`,"Wait for that command to finish, then retry.",e),c=L.fn("sketchi.cli.storage.readLockEntries")(function*(t,r){let n=[...yield*e.list(t)].sort((e,t)=>ad(e.name,t.name)),i=[];for(let a of n){let n=(0,rj.join)(t,a.name);if("file"!==a.kind)return yield*am(n,r);let s=function(e){if(!e.startsWith(i4)||!e.endsWith(at))return;let t=e.slice(i4.length,-at.length).split(".");if(1!==t.length&&2!==t.length||t.some(e=>!/^[a-zA-Z0-9_-]+$/.test(e)))return;let[r,n]=t;if(r)return{token:r,...n?{releasedOwnerToken:n}:{}}}(a.name);if(s){i.push({name:a.name,path:n,state:"free",token:s.token,...s.releasedOwnerToken?{releasedOwnerToken:s.releasedOwnerToken}:{}});continue}if(a.name.startsWith(i4))return yield*am(n,r);let o=function(e){if(!e.startsWith(ae)||!e.endsWith(at))return;let t=e.slice(ae.length,-at.length);return/^[a-zA-Z0-9_-]+$/.test(t)?t:void 0}(a.name);if(o){i.push({name:a.name,path:n,state:"unpublished-owner",token:o});continue}if(a.name.startsWith(ae)||!a.name.startsWith(i7)||!a.name.endsWith(at))return yield*am(n,r);let l=function(e){try{let t=JSON.parse(e);return"object"==typeof t&&null!==t&&"pid"in t&&"number"==typeof t.pid&&"token"in t&&"string"==typeof t.token&&t.token.length>0?{pid:t.pid,token:t.token}:void 0}catch{return}}((yield*e.readText(n).pipe(L.xm_(e=>af(e,"ENOENT")?d(r):e))));if(!l)return yield*d(r);if(a.name!==`${i7}${l.token}${at}`)return yield*am(n,r);i.push({name:a.name,path:n,token:l.token,state:au(l.pid)?"live-owner":"stale-owner"})}return i}),u=L.fn("sketchi.cli.storage.acquireLockOnce")(function*(t){let r=yield*l(t),n=yield*c(r,t),i=new Set(n.flatMap(e=>e.releasedOwnerToken?[e.releasedOwnerToken]:[]));if(n.some(e=>"live-owner"===e.state&&!i.has(e.token)))return yield*d(t);let a=n.find(e=>"free"===e.state)??n.find(e=>"stale-owner"===e.state);if(!a){let n=(0,rj.join)(r,`${i4}${ar}${at}`);if(!(yield*e.tryWriteText(n,n2({token:ar}))))return yield*d(t);a={name:`${i4}${ar}${at}`,path:n,state:"free",token:ar}}let s=crypto.randomUUID(),o=(0,rj.join)(r,`${i7}${s}${at}`),u=(0,rj.join)(r,`${ae}${s}${at}`);return yield*L.rfi(L.jGc(L.PyW(u),()=>L.JkU(function*(){if(yield*e.writeText(u,n2({pid:process.pid,token:s})),!(yield*e.tryLinkFile(u,o)))return yield*d(t);if(!(yield*e.removeFile(a.path).pipe(L.MfU(t=>e.removeFile(o).pipe(L.hgn(L.fJG(t)))))))return yield*e.removeFile(o),yield*d(t);for(let t of n)t.path!==a.path&&(yield*e.removeFile(t.path).pipe(L.MfU(()=>L.rIH)));return{directory:r,ownerPath:o,token:s}}),t=>e.removeFile(t).pipe(L.MfU(()=>L.rIH))))}),f=L.fn("sketchi.cli.storage.releaseLock")(function*(t,r){let n=crypto.randomUUID(),i=(0,rj.join)(r.directory,`${i4}${n}.${r.token}${at}`),a=n2({token:n,releasedOwnerToken:r.token});if(!(yield*e.tryWriteText(i,a).pipe(L.MfU(()=>e.kind(i).pipe(L.TjK(e=>"file"===e))),L.MfU(()=>L.PyW(!1))))){if(yield*e.removeFile(r.ownerPath))return;return yield*ao("storage_commit_failed",`Diagram "${t}" lock ownership changed before release.`,"Retry after the active Sketchi command finishes.",t)}if(!(yield*e.removeFile(r.ownerPath).pipe(L.YWq({onFailure:()=>!0,onSuccess:e=>e}))))return yield*e.removeFile(i).pipe(L.MfU(()=>L.rIH)),yield*ao("storage_commit_failed",`Diagram "${t}" lock ownership changed before release.`,"Retry after the active Sketchi command finishes.",t)}),p=e=>ao("diagram_not_found",`Diagram "${e}" does not exist.`,"Run sketchi list to discover stored diagram ids.",e),h=(r,i,l=!1,d=!1)=>L.JkU(function*(){let c;if(l){let n=ap(t.path,r),i=yield*e.kind(n);if("missing"===i){let n=yield*e.kind(t.path);if("missing"===n)return yield*p(r);if("directory"!==n)return yield*am(t.path,r);let i=o(r),a=yield*e.kind(i);if("missing"===a){let n=yield*e.list(t.path),i=`${an}${al(r)}.`;if(!n.some(e=>e.name===r||e.name.startsWith(i)))return yield*p(r)}else if("directory"!==a)return yield*am(i,r)}else if("directory"!==i)return yield*am(n,r)}return d||(yield*n(),yield*a()),yield*L.jGc((c=u(r),l?c.pipe(L.L5P({schedule:aa,while:e=>"CliStorageError"===e._tag&&"diagram_busy"===e.code})):c),()=>s(r).pipe(L.hgn(i)),e=>f(r,e).pipe(L.MfU(()=>L.rIH)))}),m=L.fn("sketchi.cli.storage.decodeManifest")(function*(t,r){let n=yield*e.readText(t),i=yield*L.SvU({try:()=>JSON.parse(n),catch:()=>ao("corrupt_record",`Diagram "${r}" has an invalid manifest.`,"Inspect manifest.json and restore it from a known-good backup.",r)});return yield*nw._Re(iM)(i).pipe(L.xm_(()=>ao("corrupt_record",`Diagram "${r}" has an incompatible manifest.`,`Expected manifest schema version ${String(1)}.`,r)))}),g=L.fn("sketchi.cli.storage.decodeDocument")(function*(t,r){let n=yield*e.readText(t),i=yield*L.SvU({try:()=>JSON.parse(n),catch:()=>ao("corrupt_record",`Diagram "${r}" has invalid document JSON.`,"Recover a prior canonical document from the revisions directory.",r)});return yield*n1(i).pipe(L.xm_(()=>ao("corrupt_record",`Diagram "${r}" has an invalid canonical document.`,"Recover a prior canonical document from the revisions directory.",r)))}),y=L.fn("sketchi.cli.storage.loadUnlocked")(function*(r){let n=ap(t.path,r),a=yield*e.kind(n);if("missing"===a)return yield*ao("diagram_not_found",`Diagram "${r}" does not exist.`,"Run sketchi list to discover stored diagram ids.",r);if("directory"!==a)return yield*am(n,r);yield*i(n,r);let s=yield*m((0,rj.join)(n,iI),r);if(s.id!==r)return yield*ao("corrupt_record",`Diagram directory "${r}" contains manifest id "${s.id}".`,"Make the directory name and manifest id agree before retrying.",r);let o=yield*g((0,rj.join)(n,i$),r);if(s.type!==o.type||s.title!==o.spec.title)return yield*ao("corrupt_record",`Diagram "${r}" manifest does not match its canonical document.`,"Recover the canonical document and rebuild the record with sketchi edit.",r);for(let t of[iE,iO])if((yield*e.kind((0,rj.join)(n,t)))!=="file")return yield*ao("corrupt_record",`Diagram "${r}" is missing required artifact ${t}.`,"Recover the canonical document and rebuild the record with sketchi edit.",r);let l=yield*e.kind((0,rj.join)(n,iC));if("file"!==l&&"missing"!==l)return yield*am((0,rj.join)(n,iC),r);if("file"===l&&!i6((yield*e.readBytes((0,rj.join)(n,iC)))))return yield*ao("corrupt_record",`Diagram "${r}" has an invalid stored PNG artifact.`,"Recover a valid prior revision or rebuild the record.",r);let d="detached"===s.authority?"file"===l?["excalidraw","png"]:["excalidraw"]:"file"===l?["scene","excalidraw","png"]:["scene","excalidraw"];if(s.formats.length!==d.length||s.formats.some((e,t)=>e!==d[t]))return yield*ao("corrupt_record",`Diagram "${r}" manifest formats do not match stored artifacts.`,"Recover the canonical document and rebuild the record with sketchi edit.",r);let c=(0,rj.join)(n,iT),u=[];for(let t of yield*e.list(c)){if("file"===t.kind&&/^\d{6,}\.json$/u.test(t.name)){u.push(t.name);continue}if("directory"===t.kind&&/^\d{6,}$/u.test(t.name)){u.push(`${t.name}/`);continue}return yield*am((0,rj.join)(c,t.name),r)}return u.sort(ac),{manifest:s,document:o,revisions:u,authority:s.authority,documentAuthoritative:"canonical"===s.authority}}),b=L.fn("sketchi.cli.storage.copySafeTree")(function*(t,r,n){for(let i of yield*e.list(t)){let a=(0,rj.join)(t,i.name),s=(0,rj.join)(r,i.name);if("directory"===i.kind)yield*e.makeDirectory(s),yield*b(a,s,n);else{if("file"!==i.kind)return yield*am(a,n);let t=yield*e.readBytes(a);yield*e.writeBytes(s,t)}}}),v=L.fn("sketchi.cli.storage.copyRecordSnapshot")(function*(t,r,n){for(let i of(yield*e.makeDirectory(r),yield*e.list(t))){if(i.name===iT)continue;let a=(0,rj.join)(t,i.name),s=(0,rj.join)(r,i.name);if("file"!==i.kind)return yield*am(a,n);yield*e.writeBytes(s,(yield*e.readBytes(a)))}}),_=L.fn("sketchi.cli.storage.commitStage")(function*(r,n){let i=ap(t.path,r),a=(0,rj.join)(t.path,`${an}${al(r)}.${String(process.pid)}.${crypto.randomUUID()}`);yield*e.rename(i,a),(yield*e.rename(n,i).pipe(L.tvg({onFailure:t=>e.rename(a,i).pipe(L.tvg({onFailure:()=>L.fJG(ao("storage_commit_failed",`Atomic storage commit and rollback both failed for "${r}".`,"Retry; Sketchi will recover the backup transaction before the next operation.",r)),onSuccess:()=>L.fJG(t)})),onSuccess:()=>L.PyW(!0)})))&&(yield*e.remove(a).pipe(L.MfU(()=>L.rIH)))}),x=L.fn("sketchi.cli.storage.snapshotCurrent")(function*(r,n,i){let a=(0,rj.join)(n,iT,iA(i));if((yield*e.kind(a))!=="missing")return yield*ao("corrupt_record",`Diagram "${r}" already has a snapshot for current revision ${String(i)}.`,"Inspect the revisions directory before retrying.",r);yield*v(ap(t.path,r),a,r)}),w=L.fn("sketchi.cli.storage.writeBuilt")(function*(t,r,n){yield*e.makeDirectory((0,rj.join)(t,iT),!0),yield*e.writeText((0,rj.join)(t,i$),n2(r.document),!0),yield*e.writeText((0,rj.join)(t,iE),n2(r.scene),!0),yield*e.writeText((0,rj.join)(t,iO),n2(r.excalidraw),!0);let i=(0,rj.join)(t,iC);yield*e.remove(i),r.png&&(yield*e.writeBytes(i,r.png)),yield*e.writeText((0,rj.join)(t,iI),n2(n),!0)}),k=L.fn("sketchi.cli.storage.create")(function*(r){return yield*h(r.id,L.JkU(function*(){let n=ap(t.path,r.id);if((yield*e.kind(n))!=="missing")return yield*ao("diagram_already_exists",`Diagram "${r.id}" already exists.`,"Use sketchi edit for full-document replacement.",r.id);let i=iM.make({schemaVersion:1,id:r.id,type:r.type,title:r.title,revision:1,authority:"canonical",formats:r.png?["scene","excalidraw","png"]:["scene","excalidraw"]});return yield*L.jGc(e.makeTempDirectory(t.path,ai),t=>L.JkU(function*(){return yield*w(t,r,i),yield*e.rename(t,n),{manifest:i,document:r.document,revisions:[],authority:"canonical",documentAuthoritative:!0}}),t=>e.remove(t))}))}),S=L.fn("sketchi.cli.storage.edit")(function*(r,n){return yield*h(r,L.JkU(function*(){let i=yield*y(r);if("canonical"!==i.authority)return yield*ao("detached_edit",`Diagram "${r}" does not have an authoritative canonical document.`,"Restore a canonical revision before editing this diagram.",r);if(n.id!==r)return yield*ao("storage_commit_failed",`Edited document id "${n.id}" does not match "${r}".`,"Keep spec.id equal to the diagram id being edited.",r);let a=ap(t.path,r),s=iM.make({schemaVersion:1,id:r,type:n.type,title:n.title,revision:i.manifest.revision+1,authority:"canonical",formats:n.png?["scene","excalidraw","png"]:["scene","excalidraw"]});return yield*L.jGc(e.makeTempDirectory(t.path,ai),e=>L.JkU(function*(){return yield*b(a,e,r),yield*x(r,e,i.manifest.revision),yield*w(e,n,s),yield*_(r,e),{manifest:s,document:n.document,revisions:[...i.revisions,`${iA(i.manifest.revision)}/`].sort(ac),authority:"canonical",documentAuthoritative:!0}}),t=>e.remove(t))}))}),I=e=>ao("patch_source_unavailable",`Diagram "${e}" has no current authoritative scene to patch.`,"Restore a canonical or patched revision before patching this diagram.",e),$=L.fn("sketchi.cli.storage.readPatchSourceUnlocked")(function*(r){let n=yield*y(r);if("detached"===n.authority||!n.manifest.formats.includes("scene"))return yield*I(r);let i=(0,rj.join)(ap(t.path,r),iE),a=yield*e.readText(i),s=yield*L.OH5(()=>{try{return nP.Uh.safeParse(JSON.parse(a))}catch{return}});return s?.success&&s.data.diagramId===r?{revision:n.manifest.revision,scene:s.data}:yield*ao("corrupt_record",`Diagram "${r}" has an invalid current scene artifact.`,"Restore a valid prior revision before patching this diagram.",r)}),E=L.fn("sketchi.cli.storage.readPatchSource")(e=>h(e,$(e),!0)),O=L.fn("sketchi.cli.storage.commitPatch")(function*(r,n,i){return yield*h(r,L.JkU(function*(){let a=yield*y(r);if(a.manifest.revision!==n)return yield*ao("patch_conflict",`Diagram "${r}" changed before the patch could commit.`,"Run sketchi show, verify the current record, and retry the patch if it is still intended.",r);if("detached"===a.authority||!a.manifest.formats.includes("scene"))return yield*I(r);if(i.scene.diagramId!==r)return yield*ao("storage_commit_failed",`Patched scene id "${i.scene.diagramId}" does not match "${r}".`,"Retry the patch against the named stored diagram.",r);let s=ap(t.path,r),o=iM.make({schemaVersion:1,id:r,type:a.manifest.type,title:a.manifest.title,revision:a.manifest.revision+1,authority:"patched",formats:["scene","excalidraw"]});return yield*L.jGc(e.makeTempDirectory(t.path,ai),t=>L.JkU(function*(){return yield*b(s,t,r),yield*x(r,t,a.manifest.revision),yield*e.writeText((0,rj.join)(t,iE),n2(i.scene),!0),yield*e.writeText((0,rj.join)(t,iO),n2(i.excalidraw),!0),yield*e.remove((0,rj.join)(t,iC)),yield*e.writeText((0,rj.join)(t,iI),n2(o),!0),yield*_(r,t),{manifest:o,document:a.document,revisions:[...a.revisions,`${iA(a.manifest.revision)}/`].sort(ac),authority:"patched",documentAuthoritative:!1}}),t=>e.remove(t))}))}),C=(e,t)=>ao("corrupt_revision",`Diagram "${e}" revision ${String(t)} is corrupt.`,"Choose another revision or repair the corrupt snapshot.",e),T=L.fn("sketchi.cli.storage.validateArchivedJson")(function*(t,r,n){let i=yield*e.readText(t);return yield*L.SvU({try:()=>{let e=JSON.parse(i);if("object"!=typeof e||null===e)throw Error("archived JSON must contain an object");return e},catch:()=>C(r,n)})}),M=L.fn("sketchi.cli.storage.validateArchivedArtifact")(function*(e,t,r,n,i){let a=yield*T(e,n,i);if(!("scene"===t?nP.Uh.safeParse(a):nP.yE.safeParse(a)).success)return yield*C(n,i);"excalidraw"===t&&"detached"===r&&(yield*iZ(a).pipe(L.xm_(()=>C(n,i))))}),P=L.fn("sketchi.cli.storage.validateArchivedPng")(function*(t,r,n){if(!i6((yield*e.readBytes(t))))return yield*C(r,n)}),A=L.fn("sketchi.cli.storage.readRevisionUnlocked")(function*(r,n){yield*y(r);let a=(0,rj.join)(ap(t.path,r),iT),s=(0,rj.join)(a,iA(n)),o=yield*e.kind(s);if("directory"===o){yield*i(s,r);let t=yield*m((0,rj.join)(s,iI),r).pipe(L.xm_(()=>C(r,n))),a=yield*g((0,rj.join)(s,i$),r).pipe(L.xm_(()=>C(r,n)));if(t.id!==r||t.revision!==n||t.type!==a.type||t.title!==a.spec.title)return yield*ao("corrupt_revision",`Diagram "${r}" revision ${String(n)} has inconsistent metadata.`,"Choose another revision or repair the corrupt snapshot.",r);for(let[i,a]of[[iE,"scene"],[iO,"excalidraw"]]){let o=(0,rj.join)(s,i);if((yield*e.kind(o))!=="file")return yield*ao("corrupt_revision",`Diagram "${r}" revision ${String(n)} is missing ${i}.`,"Choose another revision or repair the corrupt snapshot.",r);yield*M(o,a,t.authority,r,n).pipe(L.xm_(e=>"CliFilesystemError"===e._tag?C(r,n):e))}let o=yield*e.kind((0,rj.join)(s,iC));if("file"!==o&&"missing"!==o)return yield*am((0,rj.join)(s,iC),r);"file"===o&&(yield*P((0,rj.join)(s,iC),r,n).pipe(L.xm_(e=>"CliFilesystemError"===e._tag?C(r,n):e)));let l="detached"!==t.authority?"file"===o?["scene","excalidraw","png"]:["scene","excalidraw"]:"file"===o?["excalidraw","png"]:["excalidraw"];return t.formats.length!==l.length||t.formats.some((e,t)=>e!==l[t])?yield*ao("corrupt_revision",`Diagram "${r}" revision ${String(n)} has inconsistent formats.`,"Choose another revision or repair the corrupt snapshot.",r):{_tag:"FullSnapshot",revision:n}}if("missing"!==o)return yield*am(s,r);let l=(0,rj.join)(a,`${String(n).padStart(6,"0")}.json`),d=yield*e.kind(l);if("missing"===d)return yield*ao("revision_not_found",`Diagram "${r}" has no revision ${String(n)}.`,"Run sketchi show to inspect the available revision paths.",r);if("file"!==d)return yield*am(l,r);let c=yield*nZ((yield*T(l,r,n))).pipe(L.xm_(()=>ao("corrupt_revision",`Diagram "${r}" revision ${String(n)} is corrupt.`,"Choose another revision or repair the legacy revision file.",r)));return{_tag:"LegacyDocument",revision:n,document:c}}),N=L.fn("sketchi.cli.storage.replaceWithDetached")(function*(r,n,i){return yield*h(r,L.JkU(function*(){let a=yield*y(r);if(void 0!==i&&a.manifest.revision!==i)return yield*ao("replacement_conflict",`Diagram "${r}" changed before the pulled replacement could commit.`,"Run sketchi show, verify the current record, and retry the pull if it is still intended.",r);let s=ap(t.path,r),o=iM.make({schemaVersion:1,id:r,type:a.manifest.type,title:a.manifest.title,revision:a.manifest.revision+1,authority:"detached",formats:["excalidraw"]});return yield*L.jGc(e.makeTempDirectory(t.path,ai),t=>L.JkU(function*(){return yield*b(s,t,r),yield*x(r,t,a.manifest.revision),yield*e.writeBytes((0,rj.join)(t,iO),n,!0),yield*e.remove((0,rj.join)(t,iC)),yield*e.writeText((0,rj.join)(t,iI),n2(o),!0),yield*_(r,t),{manifest:o,document:a.document,revisions:[...a.revisions,`${iA(a.manifest.revision)}/`].sort(ac),authority:"detached",documentAuthoritative:!1}}),t=>e.remove(t))}))}),R=L.fn("sketchi.cli.storage.readRevision")((e,t)=>h(e,A(e,t),!0)),j=L.fn("sketchi.cli.storage.restore")(function*(r,n,i){return yield*h(r,L.JkU(function*(){let a=yield*y(r),s=yield*A(r,n);if("LegacyDocument"===s._tag){if("canonical"!==a.authority||!i)return yield*ao("restore_conflict",`Legacy revision ${String(n)} requires a canonical rebuild for "${r}".`,"Restore a full canonical snapshot, or provide the rebuilt legacy document.",r);if(i.id!==r||n2(i.document)!==n2(s.document))return yield*ao("storage_commit_failed",`Legacy revision ${String(n)} rebuild does not match its archived document.`,"Rebuild the exact archived canonical document before restoring.",r)}let o=ap(t.path,r);return yield*L.jGc(e.makeTempDirectory(t.path,ai),t=>L.JkU(function*(){yield*b(o,t,r),yield*x(r,t,a.manifest.revision);let l=[...a.revisions,`${iA(a.manifest.revision)}/`].sort(ac),d=yield*"FullSnapshot"===s._tag?L.JkU(function*(){let i=(0,rj.join)(t,iT,iA(n));for(let r of yield*e.list(t))r.name!==iT&&(yield*e.remove((0,rj.join)(t,r.name)));yield*b(i,t,r);let s=(0,rj.join)(t,iI),o=yield*e.readText(s);yield*m(s,r);let d=yield*g((0,rj.join)(t,i$),r),c=function(e,t){let r=0,n=-1,i=-1;for(let t=0;t<e.length;t+=1){let a,s=e[t];if("{"===s){r+=1;continue}if("}"===s){r-=1;continue}if('"'!==s)continue;let o=t,l=!1;for(t+=1;t<e.length;t+=1){let r=e[t];if(l)l=!1;else if("\\"===r)l=!0;else if('"'===r)break}if(t>=e.length||1!==r)continue;try{a=JSON.parse(e.slice(o,t+1))}catch{return}if("revision"!==a)continue;let d=t+1;for(;/\s/u.test(e[d]??"");)d+=1;if(":"!==e[d])continue;for(d+=1;/\s/u.test(e[d]??"");)d+=1;let c=/^-?\d+/u.exec(e.slice(d));if(!c)return;let u=d+c[0].length,f=u;for(;/\s/u.test(e[f]??"");)f+=1;if(","!==e[f]&&"}"!==e[f]||-1!==n)return;n=d,i=u}return -1===n?void 0:`${e.slice(0,n)}${String(t)}${e.slice(i)}`}(o,a.manifest.revision+1);if(void 0===c)return yield*C(r,n);yield*e.writeText(s,c,!0);let u=yield*m(s,r);return{manifest:u,document:d,revisions:l,authority:u.authority,documentAuthoritative:"canonical"===u.authority}}):L.JkU(function*(){if(!i)return yield*ao("storage_commit_failed",`Legacy revision ${String(n)} has no rebuilt document.`,"Rebuild the archived canonical document before restoring.",r);let e=iM.make({schemaVersion:1,id:r,type:i.type,title:i.title,revision:a.manifest.revision+1,authority:"canonical",formats:i.png?["scene","excalidraw","png"]:["scene","excalidraw"]});return yield*w(t,i,e),{manifest:e,document:i.document,revisions:l,authority:"canonical",documentAuthoritative:!0}});return yield*_(r,t),{diagram:d,restoredFromRevision:n}}),t=>e.remove(t))}))}),D=L.fn("sketchi.cli.storage.show")(e=>h(e,y(e),!0));return{create:k,edit:S,readPatchSource:E,commitPatch:O,replaceWithDetached:N,readRevision:R,restore:j,show:D,list:L.fn("sketchi.cli.storage.list")(function*(){yield*n();let r=yield*e.list(t.path);yield*a(r);let i=new Set;for(let e of r){if("directory"===e.kind&&!e.name.startsWith(".")){i.add(e.name);continue}if(!e.name.startsWith(an))continue;let t=function(e){try{let t=Buffer.from(e,"base64url").toString("utf8");return/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}$/.test(t)?t:void 0}catch{return}}(e.name.split(".")[2]??"");t&&i.add(t)}return yield*L.jJl([...i].sort(ad),e=>h(e,y(e),!0,!0).pipe(L.Ket,L.TjK(t=>{if(tz.oJ(t))return iP(t.success);let r=t.failure;return{id:e,status:"unavailable",code:"CliStorageError"===r._tag?r.code:"filesystem_error",message:r.message,hint:"CliStorageError"===r._tag?r.hint:"Check local paths and permissions, then retry."}})),{concurrency:4})}),readExportSource:L.fn("sketchi.cli.storage.readExportSource")(function*(r,n){return yield*h(r,L.JkU(function*(){let i=yield*y(r);if(i.manifest.formats.includes(n))return{_tag:"StoredArtifact",bytes:yield*e.readBytes((0,rj.join)(ap(t.path,r),ah(n)))};if("png"!==n)return yield*nW.make({code:"format_unavailable",format:n,message:`Diagram "${r}" has no stored ${n} artifact.`,hint:"Edit the diagram to rebuild its local artifacts."});if("detached"===i.authority)return{_tag:"RenderPng",excalidraw:yield*e.readBytes((0,rj.join)(ap(t.path,r),ah("excalidraw")))};for(let e of["scene","excalidraw"])if(!i.manifest.formats.includes(e))return yield*nW.make({code:"format_unavailable",format:e,message:`Diagram "${r}" has no stored ${e} artifact.`,hint:"Edit the diagram to rebuild its local artifacts."});let[a,s]=yield*L.Q7R([e.readBytes((0,rj.join)(ap(t.path,r),ah("scene"))),e.readBytes((0,rj.join)(ap(t.path,r),ah("excalidraw")))]);return{_tag:"RenderPng",scene:a,excalidraw:s}}),!0)})}})),ay=L.fn("sketchi.cli.export.writeFile")(function*(e,t){let r=yield*ir,n=yield*i1,i=(0,rj.resolve)(e),a=(0,rj.dirname)(i),s=()=>nW.make({code:"export_write_failed",format:(0,rj.basename)(e),message:`Export destination directory does not exist: ${a}.`,hint:"Create the destination directory and retry."}),o=yield*r.realPath(a).pipe(L.xm_(s));if((yield*r.kind(o))!=="directory")return yield*s();let l=yield*r.realPath(n.path),d=(0,rj.join)(o,(0,rj.basename)(i)),c=(0,rj.relative)(l,d);if(""===c||!(".."===c||c.startsWith(".."+rj.sep)||(0,rj.isAbsolute)(c)))return yield*nW.make({code:"invalid_destination",format:(0,rj.basename)(e),message:`Export destination is inside Sketchi's diagram storage: ${e}.`,hint:"Choose a destination outside ~/.sketchi/diagrams so the stored record remains valid."});let u=(0,rj.join)(o,`.${(0,rj.basename)(e)}.sketchi.${String(process.pid)}.${crypto.randomUUID()}`);return yield*L.jGc(L.PyW(u),n=>r.writeBytes(n,t).pipe(L.hgn(r.rename(n,d)),L.xm_(()=>nW.make({code:"export_write_failed",format:(0,rj.basename)(e),message:`Unable to write export destination ${e}.`,hint:"Check the destination path and permissions, then retry."}))),e=>r.remove(e))}),ab="90 seconds",av=L.fn("sketchi.cli.response.readBoundedBody")(function*(e,t,r,n=r){let i,a=e.body,s=Number(e.headers.get("content-length"));if(Number.isFinite(s)&&s>t)return a&&(yield*L.$mh({try:()=>a.cancel(),catch:r}).pipe(L.XeO)),yield*L.fJG(r());if(!a)return new Uint8Array;let o=yield*tk((i={evaluate:()=>a,onError:n},e6((e,t)=>{var r;let n,a,s;return n=(r={scope:t,readable:i.evaluate(),onError:i.onError,releaseLockOnEnd:i.releaseLockOnEnd}).readable.getReader(),a=r.exit??ep(void 0),s=L.DYE(()=>a.current?a.current:L.khu(L.$mh({try:()=>n.read(),catch:r.onError}),{onFailure:e=>a.current??L.ATB(e),onSuccess:({done:e,value:t})=>a.current?a.current:e?B.Vw():L.PyW(Q.of(t))})),L.as(e1.U9(r.scope,r.releaseLockOnEnd?L.OH5(()=>n.releaseLock()):L.ivC(()=>n.cancel().catch(W.Yi))),s)}))).pipe(tN(()=>({chunks:[],size:0}),(e,n)=>{let i=e.size+n.byteLength;return i>t?L.fJG(r()):(e.chunks.push(n),L.PyW({chunks:e.chunks,size:i}))})),l=new Uint8Array(o.size),d=0;for(let e of o.chunks)l.set(e,d),d+=e.byteLength;return l}),a_=L.fn("sketchi.cli.response.readBoundedText")(function*(e,t,r,n=r){let i=yield*av(e,t,r,n);return yield*L.SvU({try:()=>new TextDecoder("utf-8",{fatal:!0}).decode(i),catch:r})}),ax="https://playground.sketchi.app/api/v1/canvases/create",aw="SKETCHI_CANVAS_ENDPOINT",ak=nA.ID();function aS(e){return ak(e.issue).issues.map(e=>{let t=(e.path??[]).map(e=>"object"==typeof e&&null!==e&&"key"in e?String(e.key):String(e)).join(".");return`${t||"spec"}: ${e.message}`})}let aI=nw._Re(nP.y1,{errors:"all"}),a$=nw._Re(nP.JH,{errors:"all"}),aE=L.fn("sketchi.cli.canvas.parseSpec")(function*(e){let t=yield*L.SvU({try:()=>JSON.parse(e),catch:()=>nR.make({code:"invalid_json",message:"The CanvasSpec input is not valid JSON.",hint:"Pass one complete CanvasSpec JSON object."})});return yield*aI(t).pipe(L.xm_(e=>nj.make({message:"The CanvasSpec document is invalid.",hint:"Use the version 1 CanvasSpec contract documented by sketchi docs.",details:aS(e)})))}),aO=L.fn("sketchi.cli.canvas.readSpecInput")(function*(e){let t=yield*iy,r=yield*t.read(e,{content:"CanvasSpec document"});return yield*aE(r)});function aC(){return nF.make({code:"network_failure",message:"The Sketchi create-canvas API could not be reached.",hint:"Check the network connection and endpoint, then retry.",details:["transport"]})}function aT(e=[]){return nF.make({code:"malformed_response",message:"The Sketchi create-canvas API returned an unreadable response.",hint:"Retry once; if the response remains invalid, report the endpoint.",details:e})}function aM(e){return nF.make({code:"endpoint_failure",message:`The Sketchi create-canvas API responded with HTTP ${String(e)}.`,hint:"Check the endpoint and retry.",details:[`http_status:${String(e)}`]})}let aP=L.fn("sketchi.cli.canvas.request")(function*(e){var t,r,n,i,a,s;let o=yield*L.$mh({try:t=>globalThis.fetch(e.endpoint,{method:"POST",headers:{"content-type":"application/json","x-sketchi-client":"sketchi-cli"},body:JSON.stringify({spec:e.spec,options:{artifactFormats:["scene","excalidraw"],inlineArtifacts:["excalidraw"]}}),signal:t}),catch:aC}),l=yield*a_(o,0x1000000,aT,aC),d=yield*L.SvU({try:()=>JSON.parse(l),catch:()=>aT()}),c=yield*a$(d).pipe(L.xm_(e=>o.ok?aT(aS(e)):aM(o.status)));if(!c.ok)switch(c.status){case"export_failed":case"render_failed":case"storage_failed":return yield*(t=c.status,r=o.status,n=c.issues,nF.make({code:"endpoint_failure",message:`The Sketchi create-canvas API failed with status ${t}.`,hint:"Retry once; if the failure persists, report the endpoint and status.",details:[`status:${t}`,`http_status:${String(r)}`,...n.map(e=>`${e.code}: ${e.message}`)]}));case"invalid_canvas":case"invalid_input":case"limit_exceeded":let u;return yield*(i=c.status,a=o.status,u=(s=c.issues)[0],nF.make({code:"canvas_rejected",message:u?.message??"The create-canvas API rejected the CanvasSpec.",hint:"Correct the reported CanvasSpec issue and retry.",details:[`status:${i}`,`http_status:${String(a)}`,...s.map(e=>`${e.code}: ${e.message}`)]}))}return o.ok?c:yield*aM(o.status)},L.mgX({duration:ab,orElse:()=>L.fJG(nF.make({code:"canvas_timeout",message:"The Sketchi canvas API request timed out.",hint:"Retry once; if it persists, check the endpoint and try a smaller canvas.",details:[]}))})),aA=L.fn("sketchi.cli.canvas.create")(function*(e){let t=yield*i8;yield*n3(e.spec.diagramId).pipe(L.xm_(e=>nj.make({message:e.message,hint:e.hint,details:["spec.diagramId"]})));let r=yield*aP(e);if(r.normalizedSpec.diagramId!==e.spec.diagramId)return yield*aT(["normalizedSpec.diagramId does not match submitted spec.diagramId"]);let n=r.artifact.formats.find(e=>"excalidraw"===e.format);if(n?.inline===void 0)return yield*aT(["artifact.formats.excalidraw.inline"]);let i=nP.yE.safeParse(n.inline);if(!i.success)return yield*aT(i.error.issues.map(e=>`${e.path.join(".")}: ${e.message}`));let a=yield*n3(r.normalizedSpec.diagramId).pipe(L.xm_(()=>aT(["normalizedSpec.diagramId is not storage-safe"])));if(r.artifact.diagramId!==a)return yield*aT(["artifact.diagramId does not match normalizedSpec.diagramId"]);let s={id:a,type:"canvas",title:r.normalizedSpec.title,document:{type:"canvas",spec:r.normalizedSpec},scene:r.normalizedSpec,excalidraw:i.data},o=yield*t.create(s);return{artifactId:r.artifact.artifactId,diagram:o}});var aN=n(1688);class aR extends ee.kl()("@sketchi/cli/CliPngRenderer"){}let aj=V.Py(aR,{renderPng:function(e){return L.$mh({try:async()=>(await Promise.all([n.e(548),n.e(869)]).then(n.bind(n,7665))).renderPngBytes(e),catch:e=>e instanceof aN.FG?e:aN.FG.make({cause:e,code:"rasterization_failed",stage:"rasterization",message:"Unable to rasterize the stored diagram as PNG.",details:[]})})},normalizeExcalidraw:function(e){return L.$mh({try:async()=>(await Promise.all([n.e(548),n.e(869)]).then(n.bind(n,7665))).normalizeExcalidrawArtifact(e),catch:e=>e instanceof aN.FG?e:aN.FG.make({cause:e,code:"invalid_render_artifact",stage:"artifact",message:"Unable to restore the Excalidraw share artifact.",details:[]})})}});class aD extends ee.kl()("@sketchi/cli/DiagramExporter"){}function aU(e,t){let r=`sketchi export ${e} --format png --dest ${e}.png`;return nW.make({code:t?.code??"invalid_render_artifact",format:"png",diagramId:e,storagePath:`~/.sketchi/diagrams/${e}`,recoveryCommand:r,message:t?.message??"Unable to read the stored PNG source artifacts.",hint:`The canonical record is preserved. Retry with: ${r}`,details:t?[`stage:${t.stage}`,...t.details]:["stage:artifact"]})}function aF(e,t){return L.SvU({try:()=>JSON.parse(new TextDecoder().decode(t)),catch:()=>aU(e)})}let aB=V.QZ(aD,L.JkU(function*(){let e=yield*i8,t=yield*aR,r=L.fn("sketchi.cli.export.renderPng")(function*(e,r){let n=yield*aF(e,r.excalidraw),i=nP.yE.safeParse(n);if(!i.success)return yield*aU(e);let a=r.scene?nP.Uh.safeParse((yield*aF(e,r.scene))):void 0;if(a&&!a.success)return yield*aU(e);let s=yield*t.renderPng({...a?.success?{scene:a.data}:{},excalidraw:i.data}).pipe(L.xm_(t=>aU(e,t)));return s instanceof Uint8Array?s:new Uint8Array(s)});return{exportArtifact:L.fn("sketchi.cli.export.artifact")(function*(t,n){let i=yield*e.readExportSource(t,n);return"StoredArtifact"===i._tag?i.bytes:yield*r(t,i)})}})),aL="gemini-3.1-flash-lite",az="https://playground.sketchi.app/api/v1/generate",aW="SKETCHI_GENERATE_ENDPOINT";function aJ(){return nU.make({code:"provider_failure",message:"The Sketchi generate API could not be reached.",hint:"Check your network connection and retry. create/show/edit/list/export/restore remain offline; share and pull are separate explicit network commands.",details:["transport"]})}function aY(){return nU.make({code:"malformed_output",message:"The Sketchi generate API returned an unreadable response.",hint:"Retry once; if it persists, report the prompt without secrets.",details:[]})}function aX(){return nU.make({code:"invalid_generated_document",message:"The generated diagram failed Sketchi schema or semantic validation.",hint:"Refine the prompt with concrete diagram content, then retry.",details:[]})}let aq=nw._kM({status:nw.Qrq(nw.QfV),issues:nw.Qrq(nw.O31(nw._kM({message:nw.Qrq(nw.QfV),hint:nw.Qrq(nw.QfV)})))}),aG=nw._Re(nw.mj7(aq)),aV=nw.$r1.check(nw.HNH(e=>void 0!==e)),aH=nw._kM({ok:nw.uSQ(!0),diagram:nw._kM({document:aV,scene:aV,excalidraw:aV}),generation:nw._kM({model:nw.ukk,provider:nw.ukk})}),aK=nw._Re(nw.mj7(aH)),aQ=L.fn("sketchi.cli.generate.request")(function*(e){let t=yield*L.$mh({try:t=>globalThis.fetch(e.endpoint,{method:"POST",headers:{"content-type":"application/json","x-sketchi-client":"sketchi-cli"},body:JSON.stringify({prompt:e.prompt,...e.type?{type:e.type}:{},model:e.model}),signal:t}),catch:()=>aJ()}),r=yield*a_(t,0x1000000,aY,aJ);if(!t.ok){let e=yield*aG(r).pipe(L.xm_(aY));return yield*function(e,t){let r=t.issues?.[0],n=[`http_status:${String(e)}`,...(t.issues??[]).flatMap(e=>[...e.message?[e.message]:[],...e.hint?[e.hint]:[]])];switch(t.status){case"generation_timeout":return nU.make({code:"generation_timeout",message:r?.message??"The generate API timed out.",hint:r?.hint??"Retry once; if it persists, try a shorter prompt.",details:n});case"malformed_output":return nU.make({code:"malformed_output",message:r?.message??"The generate API returned unreadable model output.",hint:r?.hint??"Retry once; if it persists, try another prompt.",details:n});case"invalid_input":case"invalid_generated_document":case"quality_failed":return nU.make({code:"invalid_generated_document",message:r?.message??"The generated diagram failed Sketchi validation.",hint:r?.hint??"Refine the prompt with concrete content, then retry.",details:n});case"unsupported_diagram_type":return nU.make({code:"unsupported_diagram_type",message:r?.message??"Sketchi does not natively support the requested diagram type.",hint:r?.hint??"Request a flowchart, mindmap, or sequence diagram instead.",details:n});default:return nU.make({code:"provider_failure",message:r?.message??`The Sketchi generate API responded with HTTP ${String(e)}.`,hint:r?.hint??"Retry once; if it persists, report the prompt without secrets.",details:n})}}(t.status,e)}let n=yield*aK(r).pipe(L.xm_(aY));return{...n.diagram,...n.generation}},L.mgX({duration:ab,orElse:()=>L.fJG(nU.make({code:"generation_timeout",message:"The Sketchi generate API request timed out.",hint:"Retry once; if it persists, try a shorter prompt.",details:[]}))})),aZ=L.fn("sketchi.cli.generate")(function*(e){var t,r;let n,i,a=yield*i8,s=yield*aQ(e),o=yield*nZ(s.document).pipe(L.xm_(()=>aX())),l=yield*n3(n5(o)).pipe(L.xm_(()=>aX())),d=yield*(t=s.scene,(n=nP.Uh.safeParse(t)).success?L.PyW(n.data):L.fJG(aY())),c=yield*(r=s.excalidraw,(i=nP.yE.safeParse(r)).success?L.PyW(i.data):L.fJG(aY())),u={id:l,type:o.type,title:o.spec.title,document:o,scene:d,excalidraw:c};return{diagram:yield*a.create(u),model:s.model,provider:s.provider}});function a0(e,t){switch(t){case"png":return`${e}.png`;case"excalidraw":return`${e}.excalidraw`;case"scene":return`${e}.scene.json`}}let a1=L.fn("sketchi.cli.exportCreatedDiagram")(function*(e,t,r){let n=yield*aD,i=e.manifest.id,a=function(e,t,r){switch(r._tag){case"Default":return a0(e,t);case"CurrentDirectory":return(0,rj.resolve)(r.cwd,a0(e,"png"));case"ProjectDiagrams":return(0,rj.resolve)(r.cwd,"diagrams",a0(e,"png"));case"Custom":return r.path}}(i,t,r),s=yield*n.exportArtifact(i,t).pipe(L.xm_(e=>a2(e,i,t)));return yield*L.JkU(function*(){if("-"!==a){if("ProjectDiagrams"===r._tag){let e=yield*ir;yield*e.makeDirectory((0,rj.join)(r.cwd,"diagrams"),!0)}yield*ay(a,s)}}).pipe(L.xm_(e=>a2(e,i,t))),{id:i,format:t,destination:a,sizeBytes:s.byteLength,..."-"===a?{stdoutBytes:s}:{}}});function a2(e,t,r){let n=a0(t,r),i=`sketchi export ${t} --format ${r} --dest ${n}`,a="CliExportError"===e._tag?e.details:"CliStorageError"===e._tag?[`storage_error:${e.code}`]:[`filesystem_operation:${e.operation}`,`path:${e.path}`];return nW.make({code:"CliExportError"===e._tag?e.code:"CliStorageError"===e._tag?"invalid_render_artifact":"export_write_failed",diagramId:t,storagePath:`~/.sketchi/diagrams/${t}`,recoveryCommand:i,...a?{details:a}:{},format:r,message:e.message,hint:`The local record is preserved. Retry with: ${i}`})}let a5=L.fn("sketchi.cli.generateWorkflow")(function*(e){let t=yield*aZ(e),r=yield*a1(t.diagram,e.format,e.destination);return{generated:t,artifact:r}}),a3=t("node:util"),a6=t("node:process"),a8=(P=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,e=>{let t=0;for(P.lastIndex=0;P.test(e);)t+=1;return e.length-t}),a9=e=>12288===e||e>=65281&&e<=65376||e>=65504&&e<=65510,a4=e=>8987===e||9001===e||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e>=131072&&e<=196605||e>=196608&&e<=262141,a7=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,se=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,st=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,sr=/\t{1,1000}/y,sn=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu,si=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,sa=/\p{M}+/gu,ss={limit:1/0,ellipsis:""},so=(e,t={},r={})=>{let n=t.limit??1/0,i=t.ellipsis??"",a=t?.ellipsisWidth??(i?so(i,ss,r).width:0),s=r.controlWidth??0,o=r.tabWidth??8,l=r.emojiWidth??2,d=r.regularWidth??1,c=r.wideWidth??2,u=[[si,d],[a7,0],[se,s],[sr,o],[sn,l],[st,c]],f=0,p=0,h=e.length,m=0,g=!1,y=h,b=Math.max(0,n-a),v=0,_=0,x=0,w=0;e:for(;;){if(_>v||p>=h&&p>f){for(let t of(m=0,(e.slice(v,_)||e.slice(f,p)).replaceAll(sa,""))){let e=t.codePointAt(0)||0;if(x+(w=a9(e)?2:a4(e)?c:d)>b&&(y=Math.min(y,Math.max(v,f)+m)),x+w>n){g=!0;break e}m+=t.length,x+=w}v=_=0}if(p>=h)break;for(let t=0,r=u.length;t<r;t++){let[r,i]=u[t];if(r.lastIndex=p,r.test(e)){if(x+(w=(m=r===st?a8(e.slice(p,r.lastIndex)):r===sn?1:r.lastIndex-p)*i)>b&&(y=Math.min(y,p+Math.floor((b-x)/i))),x+w>n){g=!0;break e}x+=w,v=f,_=p,p=f=r.lastIndex;continue e}}p+=1}return{width:g?b:x,index:g?y:h,truncated:g,ellipsed:g&&n>=a}},sl={limit:1/0,ellipsis:"",ellipsisWidth:0},sd=(e,t={})=>so(e,sl,t).width,sc="]8;;",su=RegExp(`(?:\\[(?<code>\\d+)m|\\${sc}(?<uri>.*)\x07)`,"y"),sf=e=>e>=30&&e<=37||e>=90&&e<=97?39:e>=40&&e<=47||e>=100&&e<=107?49:1===e||2===e?22:3===e?23:4===e?24:7===e?27:8===e?28:9===e?29:0===e?0:void 0,sp=e=>`\x1b[${e}m`,sh=e=>`\x1b${sc}${e}\x07`,sm=(e,t,r)=>{let n=t[Symbol.iterator](),i=!1,a=!1,s=e.at(-1),o=void 0===s?0:sd(s),l=n.next(),d=n.next(),c=0;for(;!l.done;){let s=l.value,u=sd(s);o+u<=r?e[e.length-1]+=s:(e.push(s),o=0),("\x1b"===s||"›"===s)&&(i=!0,a=t.startsWith(sc,c+1)),i?a?"\x07"===s&&(i=!1,a=!1):"m"===s&&(i=!1):(o+=u)!==r||d.done||(e.push(""),o=0),l=d,d=n.next(),c+=s.length}s=e.at(-1),!o&&void 0!==s&&s.length&&e.length>1&&(e[e.length-2]+=e.pop())},sg=/\r?\n/;function sy(e,t,r){return String(e).normalize().split(sg).map(e=>((e,t,r={})=>{let n,i;if(!1!==r.trim&&""===e.trim())return"";let a="",s=e.split(" "),o=[""],l=0;for(let e=0;e<s.length;e++){let n=s[e];if(!1!==r.trim){let e=o.at(-1)??"",t=e.trimStart();e.length!==t.length&&(o[o.length-1]=t,l=sd(t))}0!==e&&(l>=t&&(!1===r.wordWrap||!1===r.trim)&&(o.push(""),l=0),(l||!1===r.trim)&&(o[o.length-1]+=" ",l++));let i=sd(n);if(r.hard&&i>t){let e=1+Math.floor((i-(t-l)-1)/t);Math.floor((i-1)/t)<e&&o.push(""),sm(o,n,t),l=sd(o.at(-1)??"");continue}if(l+i>t&&l&&i){if(!1===r.wordWrap&&l<t){sm(o,n,t),l=sd(o.at(-1)??"");continue}o.push(""),l=0}if(l+i>t&&!1===r.wordWrap){sm(o,n,t),l=sd(o.at(-1)??"");continue}o[o.length-1]+=n,l+=i}!1!==r.trim&&(o=o.map(e=>(e=>{let t=e.split(" "),r=t.length;for(;r&&!sd(t[r-1]);)r--;return r===t.length?e:t.slice(0,r).join(" ")+t.slice(r).join("")})(e)));let d=o.join("\n"),c=!1;for(let e=0;e<d.length;e++){let t=d[e];if(a+=t,c)c=!1;else if(c=t>="\uD800"&&t<="\uDBFF")continue;if("\x1b"===t||"›"===t){su.lastIndex=e+1;let t=su.exec(d),r=t?.groups;if(r?.code!==void 0){let e=Number.parseFloat(r.code);n=39===e?void 0:e}else r?.uri!==void 0&&(i=0===r.uri.length?void 0:r.uri)}if("\n"===d[e+1]){i&&(a+=sh(""));let e=n?sf(n):void 0;n&&e&&(a+=sp(e))}else"\n"===t&&(n&&sf(n)&&(a+=sp(n)),i&&(a+=sh(i)))}return a})(e,t,r)).join("\n")}var sb=n(5776);let sv=t("node:tty");function s_(e,t,r){if(!r.some(e=>!e.disabled))return e;let n=e+t,i=Math.max(r.length-1,0),a=n<0?i:n>i?0:n;return r[a]?.disabled?s_(a,t<0?-1:1,r):a}let sx={actions:new Set(["up","down","left","right","space","enter","cancel"]),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["\x03","cancel"],["escape","cancel"]]),messages:{cancel:"Canceled",error:"Something went wrong"},withGuide:!0,accessible:void 0,date:{monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],messages:{required:"Please enter a valid date",invalidMonth:"There are only 12 months in a year",invalidDay:(e,t)=>`There are only ${e} days in ${t}`,afterMin:e=>`Date must be on or after ${e.toISOString().slice(0,10)}`,beforeMax:e=>`Date must be on or before ${e.toISOString().slice(0,10)}`}}};function sw(e,t){if("string"==typeof e)return sx.aliases.get(e)===t;for(let r of e)if(void 0!==r&&sw(r,t))return!0;return!1}let sk=globalThis.process.platform.startsWith("win"),sS=Symbol("clack:cancel");function sI(e,t){e.isTTY&&e.setRawMode(t)}let s$=e=>"columns"in e&&"number"==typeof e.columns?e.columns:80,sE=e=>"rows"in e&&"number"==typeof e.rows?e.rows:20;function sO(e,t,r,n=r,i=r,a){return sy(t,s$(e??a6.stdout)-r.length,{hard:!0,trim:!1}).split(`
2
+ import{createRequire as e}from"node:module";let t=e(import.meta.url);var r,n,i,a,s={5776(e){let t={to:(e,t)=>t?`\x1b[${t+1};${e+1}H`:`\x1b[${e+1}G`,move(e,t){let r="";return e<0?r+=`\x1b[${-e}D`:e>0&&(r+=`\x1b[${e}C`),t<0?r+=`\x1b[${-t}A`:t>0&&(r+=`\x1b[${t}B`),r},up:(e=1)=>`\x1b[${e}A`,down:(e=1)=>`\x1b[${e}B`,forward:(e=1)=>`\x1b[${e}C`,backward:(e=1)=>`\x1b[${e}D`,nextLine:(e=1)=>"\x1b[E".repeat(e),prevLine:(e=1)=>"\x1b[F".repeat(e),left:"\x1b[G",hide:"\x1b[?25l",show:"\x1b[?25h",save:"\x1b7",restore:"\x1b8"},r={screen:"\x1b[2J",up:(e=1)=>"\x1b[1J".repeat(e),down:(e=1)=>"\x1b[J".repeat(e),line:"\x1b[2K",lineEnd:"\x1b[K",lineStart:"\x1b[1K",lines(e){let r="";for(let n=0;n<e;n++)r+=this.line+(n<e-1?t.up():"");return e&&(r+=t.left),r}};e.exports={cursor:t,scroll:{up:(e=1)=>"\x1b[S".repeat(e),down:(e=1)=>"\x1b[T".repeat(e)},erase:r,beep:"\x07"}},1833(e,r,n){let i,a,s,o,l,d,c,u,f,p,h,m,g,y,v,b,_,x,w,k,S,I,$,E,O,C,T,M,A,N;var P,R,j,D,U,F=n(719),B=n(2842),L=n(6526),z=n(1594);let W=(e,t)=>t(L.oJ(e)?0:F.nn(e.cause)?130:Y(F.iw(e.cause))),J="~effect/Runtime/errorExitCode",Y=e=>{if("object"==typeof e&&null!==e&&J in e){let t=e[J];if("number"==typeof t)return t}return 1},X="~effect/Runtime/errorReported",q=(a=({fiber:e,teardown:t})=>{let r=!1;function n(){r=!0,e.interruptUnsafe(e.id)}e.addObserver(e=>{process.removeListener("SIGINT",n),process.removeListener("SIGTERM",n),t(e,e=>{(r||0!==e)&&process.exit(e)})}),process.on("SIGINT",n),process.on("SIGTERM",n)},(0,z.XY)(e=>B.yw5(e[0]),(e,t)=>{let r=t?.disableErrorReporting===!0?B.MY7(e):B.MY7(B.dGm(e,e=>F.nn(e)?B.rIH:(e=>{if("object"==typeof e&&null!==e&&X in e){let t=e[X];if("boolean"==typeof t)return t}return!0})(F.iw(e))?B.vVN(e):B.rIH));try{let e=globalThis.setInterval(z.Yi,0x7fffffff);r.addObserver(()=>{clearInterval(e)})}catch{}return a({fiber:r,teardown:t?.teardown??W})}));var G=n(5633),V=n(9237),H=n(3614),K=n(664),Q=n(3265),Z=n(1179),ee=n(1587),et=n(4942);let er="~effect/PlatformError";class en extends et.rN("BadArgument"){get message(){return`${this.module}.${this.method}${this.description?`: ${this.description}`:""}`}}class ei extends et.$D{get message(){return`${this._tag}: ${this.module}.${this.method}${void 0!==this.pathOrDescriptor?` (${this.pathOrDescriptor})`:""}${this.description?`: ${this.description}`:""}`}}class ea extends et.rN("PlatformError"){constructor(e){"cause"in e?super({reason:e,cause:e.cause}):super({reason:e})}[er]=er;get message(){return this.reason.message}}let es=e=>new ea(new ei(e)),eo=e=>new ea(new en(e));var el=n(3952),ed=n(2449);let ec="~effect/MutableRef",eu={[ec]:ec,...ed.fU,toJSON(){return{_id:"MutableRef",current:(0,el.aB)(this.current)}}},ef=e=>{let t=Object.create(eu);return t.current=e,t};var ep=n(1554),eh=n(4233),em=n(3753),eg=n(9771),ey=n(6297);let ev=Symbol.for("effect/MutableList/Empty"),eb=e=>{let t=e.head;t.offset>=1024&&t===e.tail&&t.mutable&&(t.array.length-t.offset)*8<=t.offset&&(e.head=e.tail={array:t.array.slice(t.offset),mutable:!0,offset:0,next:void 0})},e_=()=>({array:[],mutable:!0,offset:0,next:void 0}),ex=(e,t)=>{e.tail?e.tail.mutable||(e.tail.next=e_(),e.tail=e.tail.next):e.head=e.tail=e_(),e.tail.array.push(t),e.length++},ew=e=>{e.head=e.tail=void 0,e.length=0},ek=e=>{if(!e.head)return ev;let t=e.head.array[e.head.offset];return e.head.mutable&&(e.head.array[e.head.offset]=void 0),e.head.offset++,e.length--,e.head.offset===e.head.array.length?e.head.next?e.head=e.head.next:ew(e):eb(e),t},eS={_A:z.D_,_E:z.D_},eI={"~effect/Queue":eS,"~effect/Queue/Enqueue":eS,"~effect/Queue/Dequeue":eS,...ed.fU,toJSON(){return{_id:"effect/Queue",state:this.state._tag,size:eU(this)}}},e$=e=>ed.R6(t=>{let r=Object.create(eI);return r.dispatcher=t.currentDispatcher,r.capacity=e?.capacity??1/0,r.strategy=e?.strategy??"suspend",r.messages={head:void 0,tail:void 0,length:0},r.scheduleRunning=!1,r.state={_tag:"Open",takers:new Set,offers:new Set,awaiters:new Set},ey.PyW(r)}),eE=(0,z.XY)(2,(e,t)=>ey.DYE(()=>eO(e,t)?eB:"Open"===e.state._tag&&"suspend"===e.strategy?eG(e,t):eF)),eO=(e,t)=>"Open"===e.state._tag&&(e.messages.length>=e.capacity?"sliding"===e.strategy?(ek(e.messages),ex(e.messages,t),!0):e.capacity<=0&&e.state.takers.size>0&&(ex(e.messages,t),eW(e),!0):(ex(e.messages,t),eJ(e),!0)),eC=(0,z.XY)(2,(e,t)=>ey.OH5(()=>eT(e,t))),eT=(e,t)=>{if("Open"!==e.state._tag)return!1;let r=ed.cb(t),n=ey.il9(r,eL);return 0===e.state.offers.size&&0===e.messages.length?eZ(e,n):(e.state={...e.state,_tag:"Closing",exit:n},eJ(e)),!0},eM=e=>eT(e,ed.OE(ed.RS())),eA=e=>ey.OH5(()=>eN(e)),eN=e=>{if("Done"===e.state._tag)return!1;ew(e.messages);let t=e.state.offers;for(let r of(eZ(e,"Open"===e.state._tag?ez:e.state.exit),t))eH(r);return!0},eP=e=>eR(e,1,1/0),eR=(0,z.XY)(3,(e,t,r)=>(t=eg.S(t),r=eg.S(r),ey.DYE(()=>eY(e,t,r)??ey.hgn(eq(e,()=>eX(e,t)),eR(e,t,r))))),ej=e=>ey.DYE(()=>eD(e)??ey.hgn(eq(e,()=>eX(e,1)),ej(e))),eD=e=>{if("Done"===e.state._tag)return e.state.exit;if(e.messages.length>0){let t=ek(e.messages);return eQ(e),ed.xt(t)}if(e.capacity<=0&&e.state.offers.size>0){let t=eK(e.state.offers);return eQ(e),ed.xt(t)}},eU=e=>"Done"===e.state._tag?0:e.messages.length,eF=ed.xt(!1),eB=ed.xt(!0),eL=ed.Rk(ed.RS()),ez=ey._sz(),eW=e=>{if("Done"!==e.state._tag&&0!==e.state.takers.size){for(let t of e.state.takers)if(t.ready()&&(e.state.takers.delete(t),t.resume(ey.x5l),0===e.messages.length))break}},eJ=e=>{e.scheduleRunning||"Done"===e.state._tag||0===e.state.takers.size||(e.scheduleRunning=!0,e.dispatcher.scheduleTask(()=>{e.scheduleRunning=!1,eW(e)},0))},eY=(e,t,r)=>{if("Done"===e.state._tag)return e.state.exit;if(r<=0||t<=0)return ed.xt([]);if(!eX(e,t))return;let n=e.messages.length>0?((e,t)=>{if((t=eg.S(t))<=0||!e.head)return[];if((t=Math.min(t,e.length))===e.length&&e.head?.offset===0&&!e.head.next){let t=e.head.array;return ew(e),t}let r=Array(t),n=0,i=e.head;for(;i;){for(;i.offset<i.array.length;)if(r[n++]=i.array[i.offset],i.mutable&&(i.array[i.offset]=void 0),i.offset++,n===t)return e.head=i.offset===i.array.length&&i.next?i.next:i,e.length-=t,0===e.length?ew(e):eb(e),r;i=i.next}return ew(e),r})(e.messages,r):[eK(e.state.offers)];return eQ(e),ed.xt(n)},eX=(e,t)=>e.messages.length>=("Closing"===e.state._tag?1:Math.min(t,e.capacity||1))||e.capacity<=0&&"Done"!==e.state._tag&&e.state.offers.size>0,eq=(e,t)=>ey.E2r(r=>{if("Done"===e.state._tag)return r(e.state.exit);if(t())return r(ey.x5l);let n={ready:t,resume:r};return e.state.takers.add(n),ey.OH5(()=>{"Done"!==e.state._tag&&e.state.takers.delete(n)})}),eG=(e,t)=>ey.E2r(r=>eO(e,t)?r(eB):eV(e,{_tag:"Single",message:t,resume:r})),eV=(e,t)=>{if("Open"!==e.state._tag)return eH(t);let r=e.state.offers;return r.add(t),ey.OH5(()=>{"Done"!==e.state._tag&&(r.delete(t),"Closing"===e.state._tag&&0===r.size&&0===e.messages.length&&eZ(e,e.state.exit))})},eH=e=>"Single"===e._tag?e.resume(eF):e.resume(ed.xt(e.remaining.slice(e.offset))),eK=e=>{let t=e.values().next().value;if("Single"===t._tag)return e.delete(t),t.resume(eB),t.message;let r=t.remaining[t.offset++];return t.offset===t.remaining.length&&(e.delete(t),t.resume(ed.xt([]))),r},eQ=e=>{if("Done"===e.state._tag)return em.Og(e.state.exit.cause);if(0===e.state.offers.size)return"Closing"===e.state._tag&&0===e.messages.length&&(eZ(e,e.state.exit),em.Og(e.state.exit.cause));for(let t of e.state.offers){let r=e.capacity-e.messages.length;if(r<=0)break;if("Single"===t._tag)ex(e.messages,t.message),e.state.offers.delete(t),t.resume(eB);else{for(;t.offset<t.remaining.length;t.offset++){if(0===r)return!1;ex(e.messages,t.remaining[t.offset]),r--}e.state.offers.delete(t),t.resume(ed.xt([]))}}return!1},eZ=(e,t)=>{if("Done"===e.state._tag)return;let r=e.state;for(let n of(e.state={_tag:"Done",exit:t},r.takers))n.resume(t);for(let e of(r.takers.clear(),r.awaiters))e(t);r.awaiters.clear()};var e0=n(5744);let e1="~effect/Channel",e2=e=>(0,eh.i5)(e,e1),e5={[e1]:{_Env:z.D_,_InErr:z.D_,_InElem:z.D_,_OutErr:z.D_,_OutElem:z.D_},pipe(){return(0,ep.tT)(this,arguments)}},e3=e=>{let t=Object.create(e5);return t.transform=(t,r)=>B.Tyx(e(t,r),e=>B.PyW(B.ATB(e))),t},e6=(e,t)=>e3((r,n)=>B.qIB(e9(e)(r,n),e=>t(e,n))),e8=e=>e3((t,r)=>e),e9=e=>e.transform,e4=e8(B.PyW(F.Vw()));B.ZmZ;let e7=(0,z.XY)(2,(e,t)=>e6(e,e=>B.OH5(()=>{let r=0;return B.TjK(e,e=>t(e,r++))}))),te=(0,z.XY)(2,(e,t)=>tt(e,e=>B.PyW(t(e)))),tt=(0,z.XY)(2,(e,t)=>e6(e,e=>B.PyW(em.m8(e,e=>B.qIB(t(e),F.Vw))))),tr=(0,z.XY)(e=>e2(e[0])&&e2(e[1]),(e,t,r)=>{let n;return n=B.D9k(function*(n,i,a){let s=r?.haltStrategy??"both",o=yield*e$({capacity:0});yield*e0.U9(a,eA(o));let l=0,d=(e,t,r)=>e9(t)(n,r).pipe(B.qIB(e=>e.pipe(B.qIB(e=>eE(o,e)),B.i4r)),B.S5A(t=>B.hgn(e0.VN(r,em.aU(t)),function(e,t){if(l++,!em.Og(t))return eC(o,t);switch(s){case"both":return 2===l?eC(o,t):B.rIH;case"left":case"right":return e===s?eC(o,t):B.rIH;case"either":return eC(o,t)}}(e,t))),B.ar0(a));return yield*d("left",e,e0.Fp(a)),yield*d("right",t,e0.Fp(a)),ej(o)}),e3(B.D9k(function*(e,t){let r=e0.Fp(t),i=e=>e0.VN(r,em.aU(e)),a=yield*B.S5A(n(e,t,r),i);return B.S5A(a,i)}))}),tn=(0,z.XY)(2,(e,t)=>e3((r,n)=>B.qIB(e9(e)(r,n),e=>e9(t)(e,n)))),ti=e=>e3((t,r)=>{let n;return B.PyW(B.DYE(()=>n||e.pipe(e0.Gt(r),B.qIB(e=>e9(e)(t,r)),B.qIB(e=>n=e))))}),ta=(e,t,r)=>B.DYE(()=>{let n=e0.LZ(),i=e9(e)(F.Vw(),n);return em.m8(B.qIB(i,t),r||B.PyW).pipe(B.cfM(e=>e0.VN(n,e)))}),ts=(0,z.XY)(2,(e,t)=>ta(e,e=>B.i4r(B.qIB(e,t),{disableYield:!0}))),to=(0,z.XY)(3,(e,t,r)=>B.DYE(()=>{let n=t();return ta(e,e=>B.iMI({while:z.ue,body:()=>e,step:e=>{n=r(n,e)}}),()=>B.PyW(n))})),tl=(0,z.XY)(3,(e,t,r)=>B.DYE(()=>{let n=t();return ta(e,e=>B.iMI({while:z.ue,body:(0,z.dY)(e.pipe(B.qIB(e=>r(n,e)),B.TjK(e=>{n=e}))),step:z.Yi}),()=>B.PyW(n))})),td=(e,t)=>e9(e)(F.Vw(),t),tc="~effect/Sink",tu=B.PyW([void 0]),tf={[tc]:{_A:z.D_,_In:z.D_,_L:z.D_,_E:z.D_,_R:z.D_},pipe(){return(0,ep.tT)(this,arguments)}},tp=e=>(0,eh.i5)(e,tc),th=e=>tm((t,r)=>e9(e)(t,r).pipe(B.qIB(B.i4r({disableYield:!0})),em.m8(B.PyW))),tm=e=>{let t=Object.create(tf);return t.transform=e,t},tg=e=>e3((t,r)=>B.PyW(B.qIB(e.transform(t,r),F.Vw)));B.ZmZ;let ty=tm(e=>em.m8(B.i4r(e,{disableYield:!0}),()=>tu));ee.none,ee.isNone,ee.none;let tv=e=>th(ti(B.TjK(e,tg))),tb={_R:z.D_,_E:z.D_,_A:z.D_},t_=function(e){this.channel=e};t_.prototype={"~effect/Stream":tb,pipe(){return(0,ep.tT)(this,arguments)}};let tx=e=>(0,eh.i5)(e,"~effect/Stream"),tw=e=>new t_(e),tk=e=>e.channel,tS=tw(e4),tI=e=>{let t;return tw((t=()=>e().channel,e3((e,r)=>B.DYE(()=>e9(t())(e,r)))))},t$=e=>{let t;return K.ET(e)?tw((t=B.PyW(e),e8(B.OH5(()=>{let e=!1;return B.DYE(()=>e?F.Vw():(e=!0,t))})))):tS},tE=e=>tw(ti(B.TjK(e,tk))),tO=(0,z.XY)(2,(e,t)=>tI(()=>{let r=0;return tw(e7(e.channel,K.Tj(e=>t(e,r++))))})),tC=(0,z.XY)(e=>tx(e[0])&&tx(e[1]),(e,t,r)=>tw(tr(tk(e),tk(t),r))),tT=(0,z.XY)(2,(e,t)=>{let r;return r=(e,r)=>B.OH5(()=>{let n,i,a=B.DYE(()=>{if(void 0!==i){let e=i;return i=void 0,B.PyW(e)}return e}).pipe(B.MfU(e=>(n=L.fJ(e),F.Vw()))),s=B.TjK(B.DYE(()=>t.transform(a,r)),([e,t])=>(i=t,K.of(e)));return B.DYE(()=>n||s)}),tw(e3((t,n)=>B.qIB(td(e.channel,n),e=>r(e,n))))}),tM=(0,z.XY)(e=>tx(e[0]),(e,t)=>tI(()=>{let r=new TextDecoder(t?.encoding);return tO(e,e=>r.decode(e,{stream:!0}))})),tA=(0,z.XY)(2,(e,t)=>B.Pxi(r=>td(e.channel,r).pipe(B.qIB(e=>t.transform(e,r)),B.TjK(([e])=>e)))),tN=(0,z.XY)(3,(e,t,r)=>tl(e.channel,t,(e,t)=>{let n=0,i=e;return B.TjK(B.iMI({while:()=>n<t.length,body:()=>r(i,t[n]),step(e){i=e,n++}}),()=>i)})),tP=((e,t)=>ts(e.channel,t),"~effect/FileSystem"),tR=Z.kl("effect/FileSystem"),tj="~effect/FileSystem/File";class tD extends(Z.kl())("effect/FileSystem/WatchBackend"){}let tU="~effect/Path",tF=Z.kl("effect/Path");var tB=n(3811),tL=n(9315);function tz(){return Object.assign(e=>e,{option:e=>ee.some(e),result:e=>tL.Py(e),is:e=>!0})}let tW=tz(),tJ=tz(),tY="~effect/process/ChildProcessSpawner/ChildProcessHandle",tX={[tY]:tY,...el.os,toJSON(){return{_id:"ChildProcessHandle",pid:this.pid}}},tq=e=>Object.setPrototypeOf({...e},tX);class tG extends(Z.kl())("effect/process/ChildProcessSpawner"){}let tV="~effect/process/ChildProcess",tH={...tB.bp({label:"Command",evaluate(e){return Z.fp(e.context,tG).spawn(this)}}),[tV]:tV},tK=(e,t,r)=>Object.assign(Object.create(tH),{_tag:"StandardCommand",command:e,args:t,options:r}),tQ=function(...e){if(tZ(e[0])){let[t,...r]=e,n=t2(t,r);return tK(n[0]??"",n.slice(1),{})}if("object"==typeof e[0]&&!Array.isArray(e[0])&&!tZ(e[0])){let t=e[0];return function(e,...r){let n=t2(e,r);return tK(n[0]??"",n.slice(1),t)}}if("string"==typeof e[0]&&!Array.isArray(e[1])){let[t,r={}]=e;return tK(t,[],r)}let[t,r=[],n={}]=e;return tK(t,r,n)},tZ=e=>Array.isArray(e)&&"raw"in e&&Array.isArray(e.raw),t0=e=>{let t=/^fd(\d+)$/.exec(e);if(null===t)return;let r=parseInt(t[1],10);return r>=3?r:void 0},t1=e=>`fd${e}`,t2=(e,t)=>{let r=[];for(let[n,i]of e.entries())r=t5(e,t,r,i,n);return r},t5=(e,t,r,n,i)=>{let a=e.raw[i];if(void 0===a)throw Error(`Invalid backslash sequence: ${e.raw[i]}`);let{hasLeadingWhitespace:s,hasTrailingWhitespace:o,tokens:l}=t9(n,a),d=t4(r,l,s);if(i===t.length)return d;let c=t[i];return t4(d,Array.isArray(c)?c.map(e=>t3(e)):[t3(c)],o)},t3=e=>"string"==typeof e?e:String(e),t6=new Set([" "," ","\r","\n"]),t8={x:3,u:5},t9=(e,t)=>{if(0===t.length)return{tokens:[],hasLeadingWhitespace:!1,hasTrailingWhitespace:!1};let r=t6.has(t[0]),n=[],i=0;for(let r=0,a=0;r<e.length;r+=1,a+=1){let s=t[a];if(t6.has(s))i!==r&&n.push(e.slice(i,r)),i=r+1;else if("\\"===s){let e=t[a+1];if("\n"===e)r-=1,a+=1;else if("u"===e&&"{"===t[a+2]){let e=t.indexOf("}",a+3);parseInt(t.slice(a+3,e),16)>65535&&(r+=1),a=e}else a+=t8[e]??1}}let a=i===e.length;return a||n.push(e.slice(i)),{tokens:n,hasLeadingWhitespace:r,hasTrailingWhitespace:a}},t4=(e,t,r)=>r||0===e.length||0===t.length?[...e,...t]:[...e.slice(0,-1),`${e.at(-1)}${t.at(0)}`,...t.slice(1)],t7=t("node:child_process"),re=t("node:stream"),rt=(e,t)=>(r,[n])=>{let i="Unknown";switch(r.code){case"ENOENT":i="NotFound";break;case"EACCES":i="PermissionDenied";break;case"EEXIST":i="AlreadyExists";break;case"EISDIR":case"ENOTDIR":case"ELOOP":i="BadResource";break;case"EBUSY":i="Busy"}return es({_tag:i,module:e,method:t,pathOrDescriptor:n,syscall:r.syscall,cause:r})},rr=e=>th(te(rn(e),e=>[e])),rn=e=>e3(t=>{let r=e.evaluate();return B.PyW(ri({...e,writable:r,pull:t}))}),ri=e=>e.pull.pipe(B.qIB(t=>{let r=0;return B.E2r(n=>{let i=!1,a=()=>{for(;r<t.length;){if(i)return;if(!e.writable.write(t[r++],e.encoding)){i||e.writable.once("drain",a);return}}i||n(B.rIH)};return a(),B.OH5(()=>{i=!0,e.writable.off("drain",a)})})}),B.i4r({disableYield:!0}),!1!==e.endOnDone?em.m8(t=>"closed"in e.writable&&e.writable.closed?F.Vw(t):B.E2r(r=>{let n=()=>r(F.Vw(t));return e.writable.once("finish",n),e.writable.end(),B.OH5(()=>{e.writable.off("finish",n)})})):z.D_,B.KT6(B.E2r(t=>{let r=r=>t(B.fJG(e.onError(r)));return e.writable.once("error",r),B.OH5(()=>{e.writable.off("error",r)})})));ey.zFM,ey.C6p;let ra=ey.D7p;ey.INJ;let rs=ey.mKq;ey.eGS,ey.DKo,ey.$MQ;let ro=ey.Iku,rl=ey.vTQ,rd=ey.zzk;ey.Fbb;let rc=e=>tw(ru(e)),ru=e=>e3((t,r)=>rf({scope:r,readable:e.evaluate(),onError:e.onError??rp,chunkSize:e.chunkSize,closeOnDone:e.closeOnDone})),rf=e=>{let t=e.readable,r=e.closeOnDone??!0,n=e.exit??ef(void 0),i=e.latch??rd(!1);function a(){i.openUnsafe()}function s(t){n.current=L.fJ(e.onError(t)),i.openUnsafe()}function o(){n.current=L.fJ(F.RS()),i.openUnsafe()}t.on("readable",a),t.once("error",s),t.once("end",o);let l=B.DYE(function r(){let a=e.readable.read(e.chunkSize);if(null===a)return n.current?n.current:t.readableEnded?B.fJG(F.RS()):(i.closeUnsafe(),B.qIB(i.await,r));let s=K.of(a);for(;null!==(a=e.readable.read(e.chunkSize));)s.push(a);return B.PyW(s)});return B.as(e0.U9(e.scope,B.OH5(()=>{t.off("readable",a),t.off("error",s),t.off("end",o),r&&"closed"in e.readable&&!e.readable.closed&&e.readable.destroy()})),l)};re.Readable;let rp=e=>new F.Bk(e),rh=e=>e instanceof globalThis.Error?e:new globalThis.Error(String(e)),rm=(e,t,r)=>{let{commands:n}=r_(r),i=n.reduce((e,t)=>{let r=`${t.command} ${t.args.join(" ")}`;return 0===e.length?r:`${e} | ${r}`},"");return rt("ChildProcess",e)(t,[i])},rg=(e,t)=>{if(!V.NJ(t))return!0;if("win32"===globalThis.process.platform)return!1;try{return globalThis.process.kill(-e.pid,0),!0}catch{return!1}},ry=(e,t=()=>{})=>t7.execFile("taskkill",["/pid",String(e.pid),"/T","/F"],{windowsHide:!0},t),rv=B.JkU(function*(){let e,t,r=yield*tR,n=yield*tF,i=B.D9k(function*(e){if(!eh.b0(e.cwd))return yield*r.access(e.cwd),n.resolve(e.cwd)}),a=e=>tp(e)?"pipe":e,s=e=>{let t={stream:"pipe",encoding:"utf-8",endOnDone:!0};return eh.b0(e.stdin)?t:"string"==typeof e.stdin||tx(e.stdin)?{...t,stream:e.stdin}:{stream:e.stdin.stream,encoding:e.stdin.encoding??t.encoding,endOnDone:e.stdin.endOnDone??t.endOnDone}},o=(e,t)=>{let r=e[t];return eh.b0(r)?{stream:"pipe"}:"string"==typeof r||tp(r)?{stream:r}:{stream:r.stream}},l=B.D9k(function*(e,t,r){if(0===r.length)return{getInputFd:()=>ty,getOutputFd:()=>tS};let n=new Map,i=new Map;for(let{config:a,fd:s}of r){let r=t.stdio[s];switch(a.type){case"input":{let t=ty;r&&"write"in r&&(t=rr({evaluate:()=>r,onError:t=>rm(`fromWritable(fd${s})`,rh(t),e)})),a.stream&&(yield*B.x6Z(tA(a.stream,t))),n.set(s,t);break}case"output":{let t=tS;if(r&&"read"in r){let n=new re.PassThrough;r.on("error",e=>n.destroy(e)),r.pipe(n),t=rc({evaluate:()=>n,onError:t=>rm(`fromReadable(fd${s})`,rh(t),e)})}a.sink&&(t=tT(t,a.sink)),i.set(s,t)}}}return{getInputFd:e=>n.get(e)??ty,getOutputFd:e=>i.get(e)??tS}}),d=(e,t,r)=>B.E2r(n=>{let i,a=Date.now()+r,s=()=>{clearTimeout(i),e.removeListener("exit",o)},o=()=>{if(clearTimeout(i),Date.now()>=a||!rg(e,t)){s(),n(B.rIH);return}i=setTimeout(o,10)};return e.on("exit",o),o(),B.OH5(s)}),c=B.D9k(function*(e,t,r,n){let i=r=>("win32"===globalThis.process.platform?B.E2r(r=>{ry(t,t=>{t?r(B.fJG(rm("kill",rh(t),e))):r(B.rIH)})}):B.SvU({try:()=>{globalThis.process.kill(-t.pid,r)},catch:t=>rm("kill",rh(t),e)})).pipe(B.MfU(()=>B.DYE(()=>{if(!t.kill(r)){let t=new globalThis.Error("Failed to kill child process");return B.fJG(rm("kill",t,e))}return B.rIH})));yield*i(n?.killSignal??"SIGTERM"),eh.b0(n?.forceKillAfter)?yield*d(t,r,1e3):(yield*d(t,r,H.kE(n.forceKillAfter)),rg(t,r)&&(yield*i("SIGKILL"),yield*d(t,r,1e3))),yield*V.Tx(r)}),u=(e,t)=>{let r=t??"stdout";switch(r){case"stdout":return e.stdout;case"stderr":return e.stderr;case"all":return e.all;default:{let t=t0(r);if(eh.EA(t))return e.getOutputFd(t);return e.stdout}}},f=B.D9k(function*(e){switch(e._tag){case"StandardCommand":{var t,r,n;let d,u,f,p,h,m,g,y,v=s(e.options),b=o(e.options,"stdout"),_=o(e.options,"stderr"),x=(e=>{if(eh.b0(e.additionalFds))return[];let t=[];for(let[r,n]of Object.entries(e.additionalFds)){let e=t0(r);eh.EA(e)&&t.push({fd:e,config:n})}return t.sort((e,t)=>e.fd-t.fd)})(e.options),w=!0,k=yield*i(e.options),S=(d=e.options).extendEnv?{...globalThis.process.env,...d.env}:d.env,I=((e,t,r,n)=>{let i,s=[tx(i=e.stream)?"pipe":i,a(t.stream),a(r.stream)];if(0===n.length)return s;let o=n.reduce((e,{fd:t})=>Math.max(e,t),2);for(let e=3;e<=o;e++)s[e]="ignore";for(let{fd:e}of n)s[e]="pipe";return s})(v,b,_,x),[$,E]=yield*B.Q56((t=e.options,r={cwd:k,env:S,stdio:I},n=process.platform,u=t.detached??"win32"!==n,f={...r,detached:u,shell:t.shell,windowsHide:t.windowsHide??!u},B.E2r(t=>{let r=V.LZ(),n=t7.spawn(e.command,e.args,f);return n.on("error",r=>{t(B.fJG(rm("spawn",r,e)))}),n.on("exit",(...e)=>{V.$w(r,L.Py(e))}),n.on("spawn",()=>{t(B.PyW([n,r]))}),B.OH5(()=>{n.kill("SIGTERM")})})),B.D9k(function*([t,r]){if(yield*V.$L(r)){let[n]=yield*V.Tx(r);0!==n&&eh.Pe(n)?yield*B.XeO(c(e,t,r,e.options)):w&&"win32"!==process.platform&&!1!==e.options.detached&&(yield*B.XeO(c(e,t,r,e.options)));return}w&&(yield*B.XeO(c(e,t,r,e.options)))})),O=tJ($.pid);$.on("exit",t=>{0!==t&&eh.Pe(t)&&((e,t)=>{if("win32"===globalThis.process.platform)return ry(e);try{globalThis.process.kill(-e.pid,t)}catch{}})($,e.options.killSignal??"SIGTERM")});let C=B.OH5(()=>{w||($.ref(),w=!0)}),T=B.OH5(()=>(w&&($.unref(),w=!1),C)),M=yield*B.DYE(()=>{let t=ty;return(eh.Pe($.stdin)&&(t=rr({evaluate:()=>$.stdin,onError:t=>rm("fromWritable(stdin)",rh(t),e),endOnDone:v.endOnDone,encoding:v.encoding})),tx(v.stream))?B.as(B.x6Z(tA(v.stream,t)),t):B.PyW(t)}),{all:A,stderr:N,stdout:P}=(h=$.stdout?(p=new re.PassThrough,$.stdout.on("error",e=>p.destroy(e)),$.stdout.pipe(p),rc({evaluate:()=>p,onError:t=>rm("fromReadable(stdout)",rh(t),e)})):tS,g=$.stderr?(m=new re.PassThrough,$.stderr.on("error",e=>m.destroy(e)),$.stderr.pipe(m),rc({evaluate:()=>m,onError:t=>rm("fromReadable(stderr)",rh(t),e)})):tS,tp(b.stream)&&(h=tT(h,b.stream)),tp(_.stream)&&(g=tT(g,_.stream)),y=tC(h,g),{stdout:h,stderr:g,all:y}),{getInputFd:R,getOutputFd:j}=yield*l(e,$,x),D=B.TjK(V.$L(E),e=>!e);return tq({pid:O,exitCode:B.qIB(V.Tx(E),([t,r])=>{if(eh.Pe(t))return B.PyW(tW(t));let n=new globalThis.Error(`Process interrupted due to receipt of signal: '${r}'`);return B.fJG(rm("exitCode",n,e))}),isRunning:D,kill:t=>c(e,$,E,t),stdin:M,stdout:P,stderr:N,all:A,getInputFd:R,getOutputFd:j,unref:T})}case"PipedCommand":{let{commands:t,pipeOptions:r}=r_(e),[n,...i]=t,a=[(yield*f(n))];for(let e=0;e<i.length;e++){let t=i[e],n=r[e]??{},o=s(t.options),l=tE(B.PyW(u(a[a.length-1],n.from))),d=n.to??"stdin";if("stdin"===d)a.push((yield*f(tQ(t.command,t.args,{...t.options,stdin:{...o,stream:l}}))));else{let e=t0(d);if(eh.EA(e)){let r=t1(e),n=t.options.additionalFds??{};a.push((yield*f(tQ(t.command,t.args,{...t.options,additionalFds:{...n,[r]:{type:"input",stream:l}}}))))}else a.push((yield*f(tQ(t.command,t.args,{...t.options,stdin:{...o,stream:l}}))))}}let o=a[a.length-1],l=B.JkU(function*(){let e=[];for(let t of a)e.push((yield*t.unref));return B.jJl([...e].reverse(),e=>e,{discard:!0})});return tq({pid:o.pid,exitCode:o.exitCode,isRunning:o.isRunning,kill:e=>B.jJl([...a].reverse(),t=>B.XeO(t.kill(e)),{discard:!0}),stdin:a[0].stdin,stdout:o.stdout,stderr:o.stderr,all:o.all,getInputFd:o.getInputFd,getOutputFd:o.getOutputFd,unref:l})}}});return e=(e,t)=>f(e).pipe(B.TjK(e=>tM(t?.includeStderr===!0?e.all:e.stdout)),tE),t=(t,r)=>e(t,r).channel.pipe(tn(e3((e,t)=>B.OH5(()=>{let t="",r=!1,n=ee.none(),i=B.DYE(()=>"Some"===n._tag?F.Vw(n.value):em.tv(e,{onSuccess:a,onFailure:B.ATB,onDone:e=>{if(n=ee.some(e),t.length>0){let e=t;return t="",r=!1,B.PyW([e])}return F.Vw(e)}}));function a(e){let n=function(e){let n=[];function i(e){0===t.length?n.push(e):(n.push(t+e),t="")}for(let n=0;n<e.length;n++){let a=e[n];if(0!==a.length){let e=0,n=a.indexOf("\r"),s=a.indexOf("\n");for(r&&(0===s&&(e=1,s=a.indexOf("\n",e)),r=!1);-1!==n||-1!==s;)-1===n||-1!==s&&s<n?(i(a.substring(e,s)),e=s+1,s=a.indexOf("\n",e)):(i(a.substring(e,n)),a.length===n+1?(r=!0,e=a.length,n=-1):(e=n+(s===n+1?2:1),n=a.indexOf("\r",e),s=a.indexOf("\n",e)));t+=a.substring(e)}}return K.ET(n)?n:null}(e);return null!==n?B.PyW(n):i}return i}))),tw),tG.of({spawn:f,exitCode:e=>B.P1j(B.qIB(f(e),e=>e.exitCode)),streamString:e,streamLines:t,lines:(e,r)=>to(t(e,r).channel,()=>[],(e,t)=>{for(let r=0;r<t.length;r++)e.push(t[r]);return e}),string:(t,r)=>to(e(t,r).channel,()=>"",(e,t)=>e+t.join(""))})}),rb=G.QZ(tG,rv),r_=e=>{let t=[],r=[],n=e=>{switch(e._tag){case"StandardCommand":t.push(e);break;case"PipedCommand":n(e.left),r.push(e.options),n(e.right)}};if(n(e),0===t.length)throw Error("flattenCommand produced empty commands array");let[i,...a]=t;return{commands:[i,...a],pipeOptions:r}},rx="0123456789ABCDEFGHJKMNPQRSTVWXYZ",rw=e=>e.toString(16).padStart(2,"0"),rk=e=>[e.subarray(0,4),e.subarray(4,6),e.subarray(6,8),e.subarray(8,10),e.subarray(10,16)].map(e=>Array.from(e,rw).join("")).join("-"),rS=()=>globalThis.crypto.getRandomValues(new Uint8Array(16));function rI(e=rS()){return e[6]=15&e[6]|64,e[8]=63&e[8]|128,e}function r$(e,t=rS()){let r=Math.min(Math.max(0,Math.trunc(e)),0xffffffffffff);return t[0]=Math.floor(r/0x10000000000),t[1]=255&Math.floor(r/0x100000000),t[2]=255&Math.floor(r/0x1000000),t[3]=255&Math.floor(r/65536),t[4]=255&Math.floor(r/256),t[5]=255&r,t[6]=15&t[6]|112,t[8]=63&t[8]|128,t}let rE="~effect/Crypto",rO=Z.kl("effect/Crypto");var rC=n(7598);let rT=(s=(D={randomBytes:rC.randomBytes,digest:(e,t)=>B.SvU({try:()=>Uint8Array.from(rC.createHash((e=>{switch(e){case"SHA-1":return"sha1";case"SHA-256":return"sha256";case"SHA-384":return"sha384";case"SHA-512":return"sha512"}})(e)).update(t).digest()),catch:e=>es({module:"Crypto",method:"digest",_tag:"Unknown",description:"Could not compute digest",cause:e})})}).randomBytes,o=e=>(31&e[0])*0x1000000000000+0x10000000000*e[1]+0x100000000*e[2]+0x1000000*e[3]+65536*e[4]+256*e[5]+e[6],l=()=>o(s(7))/0x20000000000000,d=()=>{for(;;){let e=s(7),t=o(e);if((32&e[0])==0)return t+Number.MIN_SAFE_INTEGER;if(t<Number.MAX_SAFE_INTEGER)return t+1}},rO.of({[rE]:rE,randomBytes:e=>{let t,r;return B.TjK((t="randomBytes",Number.isSafeInteger(r=e)&&r>=0?B.PyW(r):B.fJG(eo({module:"Crypto",method:t,description:"size must be a non-negative safe integer"}))),s)},nextDoubleUnsafe:l,nextIntUnsafe:d,digest:D.digest,random:B.OH5(()=>l()),randomBoolean:B.OH5(()=>l()>.5),randomInt:B.OH5(()=>d()),randomBetween:(e,t)=>B.OH5(()=>((e,t,r)=>{let n=r*(t-e)+e;if(n!==t||e>=t||!Number.isFinite(t))return n;if(0===t)return -5e-324;let i=new DataView(new ArrayBuffer(8));i.setFloat64(0,t);let a=i.getBigUint64(0);return i.setBigUint64(0,t>0?a-BigInt(1):a+BigInt(1)),i.getFloat64(0)})(e,t,l())),randomIntBetween(e,t,r){let n=+(r?.halfOpen!==!0);return B.OH5(()=>{let r=Math.ceil(e),i=Math.floor(t);return Math.floor(l()*(i-r+n))+r})},randomShuffle:e=>B.OH5(()=>{let t=Array.from(e);for(let e=t.length-1;e>=1;e-=1){let r=Math.min(e,Math.floor(l()*(e+1))),n=t[e];t[e]=t[r],t[r]=n}return t}),randomUUIDv4:B.OH5(()=>{let e;return rk(void 0===(e=s(16))?rI():rI(e))}),randomUUIDv7:B.RKA(e=>{let t,r;return B.PyW((t=e.currentTimeMillisUnsafe(),rk(void 0===(r=s(16))?r$(t):r$(t,r))))}),randomULID:B.RKA(e=>B.PyW(((e,t)=>{if(10!==t.length)throw Error(`ULID randomness must be exactly 10 bytes, received ${t.length}`);let r=Math.min(Math.max(0,Math.trunc(e)),0xffffffffffff),n="";for(let e=45;e>=0;e-=5)n+=rx[31&Math.floor(r/2**e)];let i=0,a=0;for(let e of t){for(i=i<<8|e,a+=8;a>=5;)a-=5,n+=rx[i>>>a&31];i&=(1<<a)-1}return n})(e.currentTimeMillisUnsafe(),s(10))))})),rM=G.Py(rO,rT);var rA=n(5053);let rN=t("node:fs"),rP=t("node:os"),rR=t("node:path");var rj=n.t(rR,2);let rD=e=>t=>eo({module:"FileSystem",method:e,description:t.message??String(t)}),rU=(e,t)=>{let r=Number(e);if(!Number.isSafeInteger(r))throw RangeError(`${t} exceeds the safe integer range: ${e}`);return r},rF=e=>ee.flatMap(ee.fromNullishOr(e),rA.Ro),rB=(e,t)=>B.SvU({try:()=>rU(e,"position"),catch:rD(t)}),rL=(c=(0,B._r7)(rN.access,rt("FileSystem","access"),rD("access")),(e,t)=>{let r=rN.constants.F_OK;return t?.readable&&(r|=rN.constants.R_OK),t?.writable&&(r|=rN.constants.W_OK),c(e,r)}),rz=(u=(0,B._r7)(rN.cp,rt("FileSystem","copy"),rD("copy")),(e,t,r)=>u(e,t,{force:r?.overwrite??!1,preserveTimestamps:r?.preserveTimestamps??!1,recursive:!0})),rW=(f=(0,B._r7)(rN.copyFile,rt("FileSystem","copyFile"),rD("copyFile")),(e,t)=>f(e,t)),rJ=(p=(0,B._r7)(rN.chmod,rt("FileSystem","chmod"),rD("chmod")),(e,t)=>p(e,t)),rY=(h=(0,B._r7)(rN.chown,rt("FileSystem","chown"),rD("chown")),(e,t,r)=>h(e,t,r)),rX=(m=(0,B._r7)(rN.glob,rt("FileSystem","glob"),rD("glob")),(e,t)=>m(e,{cwd:t?.root,exclude:t?.exclude})),rq=(g=(0,B._r7)(rN.link,rt("FileSystem","link"),rD("link")),(e,t)=>g(e,t)),rG=(y=(0,B._r7)(rN.mkdir,rt("FileSystem","makeDirectory"),rD("makeDirectory")),(e,t)=>y(e,{recursive:t?.recursive??!1,mode:t?.mode})),rV=e=>{let t=(0,B._r7)(rN.mkdtemp,rt("FileSystem",e),rD(e));return e=>B.DYE(()=>{let r=e?.prefix??"",n="string"==typeof e?.directory?rR.join(e.directory,"."):rP.tmpdir();return t(r?rR.join(n,r):n+"/")})},rH=rV("makeTempDirectory"),rK=e=>{let t=(0,B._r7)(rN.rm,rt("FileSystem",e),rD(e));return(e,r)=>t(e,{recursive:r?.recursive??!1,force:r?.force??!1})},rQ=rK("remove"),rZ=(v=rV("makeTempDirectoryScoped"),b=rK("makeTempDirectoryScoped"),e=>B.Q56(v(e),e=>B.QgK(b(e,{recursive:!0})))),r0=(U="open",_=(0,B._r7)(rN.open,rt("FileSystem",U),rD(U)),x=(0,B._r7)(rN.close,rt("FileSystem",U),rD(U)),(e,t)=>(0,z.Fs)(B.Q56(_(e,t?.flag??"r",t?.mode),e=>B.QgK(x(e))),B.TjK(e=>r1(e,t?.flag?.startsWith("a")??!1)))),r1=(()=>{let e=e=>(0,B._r7)(rN.read,rt("FileSystem",e),rD(e)),t=e("read"),r=e("readAlloc"),n=(0,B._r7)(rN.fstat,rt("FileSystem","stat"),rD("stat")),i=(0,B._r7)(rN.ftruncate,rt("FileSystem","truncate"),rD("truncate")),a=(0,B._r7)(rN.fsync,rt("FileSystem","sync"),rD("sync")),s=e=>(0,B._r7)(rN.write,rt("FileSystem",e),rD(e)),o=s("write"),l=s("writeAll");class d{[tj];fd;append;position=BigInt(0);constructor(e,t){this[tj]=tj,this.fd=e,this.append=t}get stat(){return B.qIB(n(this.fd,{bigint:!0}),ne)}get sync(){return a(this.fd)}seek(e,t){return B.DYE(()=>{let r="start"===t?e:this.position+e;return r<BigInt(0)?B.fJG(eo({module:"FileSystem",method:"seek",description:"Cannot seek before the start of the file"})):(this.position=r,B.PyW(r))})}read(e){return B.DYE(()=>{let r=this.position;return B.TjK(t(this.fd,{buffer:e,position:r}),e=>(this.position=r+BigInt(e),e))})}readAlloc(e){return B.DYE(()=>{try{if(!Number.isInteger(e)||e<0)throw RangeError("size must be a non-negative integer");let t=Buffer.allocUnsafeSlow(e),n=this.position;return B.TjK(r(this.fd,{buffer:t,position:n}),r=>{if(0===r)return ee.none();if(this.position=n+BigInt(r),r===e)return ee.some(t);let i=Buffer.allocUnsafeSlow(r);return t.copy(i,0,0,r),ee.some(i)})}catch(e){return B.fJG(rD("readAlloc")(e))}})}truncate(e){return B.TjK(i(this.fd,e||void 0),()=>{if(!this.append){let t=BigInt(e??0);this.position>t&&(this.position=t)}})}write(e){return B.DYE(()=>{let t=this.position;return B.qIB(this.append?B.PyW(void 0):rB(t,"write"),r=>B.TjK(o(this.fd,e,void 0,void 0,r),e=>(this.append||(this.position=t+BigInt(e)),e)))})}writeAllChunk(e){return B.DYE(()=>{let t=this.position;return B.qIB(this.append?B.PyW(void 0):rB(t,"writeAll"),r=>B.qIB(l(this.fd,e,void 0,void 0,r),r=>0===r?B.fJG(es({module:"FileSystem",method:"writeAll",_tag:"WriteZero",pathOrDescriptor:this.fd,description:"write returned 0 bytes written"})):(this.append||(this.position=t+BigInt(r)),r<e.length?this.writeAllChunk(e.subarray(r)):B.rIH)))})}writeAll(e){return 0===e.length?B.rIH:this.writeAllChunk(e)}}return(e,t)=>new d(e,t)})(),r2=e=>{let t=rV(e);return B.D9k(function*(e){let r=yield*t(e),n=rC.randomBytes(6).toString("hex"),i=rR.join(r,e?.suffix?`${n}${e.suffix}`:n);return yield*na(i,new Uint8Array(0)),i})},r5=r2("makeTempFile"),r3=(w=r2("makeTempFileScoped"),k=rK("makeTempFileScoped"),e=>B.Q56(w(e),e=>B.QgK(k(rR.dirname(e),{recursive:!0})))),r6=(e,t)=>B.$mh({try:()=>rN.promises.readdir(e,t),catch:t=>rt("FileSystem","readDirectory")(t,[e])}),r8=e=>B.E2r((t,r)=>{try{rN.readFile(e,{signal:r},(r,n)=>{r?t(B.fJG(rt("FileSystem","readFile")(r,[e]))):t(B.PyW(n))})}catch(e){t(B.fJG(rD("readFile")(e)))}}),r9=(S=(0,B._r7)(rN.readlink,rt("FileSystem","readLink"),rD("readLink")),e=>S(e)),r4=(I=(0,B._r7)(rN.realpath,rt("FileSystem","realPath"),rD("realPath")),e=>I(e)),r7=($=(0,B._r7)(rN.rename,rt("FileSystem","rename"),rD("rename")),(e,t)=>$(e,t)),ne=e=>B.SvU({try:()=>({type:e.isFile()?"File":e.isDirectory()?"Directory":e.isSymbolicLink()?"SymbolicLink":e.isBlockDevice()?"BlockDevice":e.isCharacterDevice()?"CharacterDevice":e.isFIFO()?"FIFO":e.isSocket()?"Socket":"Unknown",mtime:ee.fromNullishOr(e.mtime),atime:ee.fromNullishOr(e.atime),birthtime:ee.fromNullishOr(e.birthtime),dev:rU(e.dev,"dev"),rdev:rF(e.rdev),ino:rF(e.ino),mode:rU(e.mode,"mode"),nlink:rF(e.nlink),uid:rF(e.uid),gid:rF(e.gid),size:Q.ee(e.size),blksize:void 0!==e.blksize?ee.some(Q.ee(e.blksize)):ee.none(),blocks:rF(e.blocks)}),catch:rD("stat")}),nt=(E=(0,B._r7)(rN.stat,rt("FileSystem","stat"),rD("stat")),e=>B.qIB(E(e,{bigint:!0}),ne)),nr=(O=(0,B._r7)(rN.symlink,rt("FileSystem","symlink"),rD("symlink")),(e,t)=>O(e,t)),nn=(C=(0,B._r7)(rN.truncate,rt("FileSystem","truncate"),rD("truncate")),(e,t)=>C(e,t)),ni=(T=(0,B._r7)(rN.utimes,rt("FileSystem","utime"),rD("utime")),(e,t,r)=>T(e,t,r)),na=(e,t,r)=>B.E2r((n,i)=>{try{rN.writeFile(e,t,{signal:i,flag:r?.flag,mode:r?.mode},t=>{t?n(B.fJG(rt("FileSystem","writeFile")(t,[e]))):n(B.rIH)})}catch(e){n(B.fJG(rD("writeFile")(e)))}}),ns=B.TjK(B.Nav(tD),e=>{let t;return t={access:rL,chmod:rJ,chown:rY,copy:rz,copyFile:rW,glob:rX,link:rq,makeDirectory:rG,makeTempDirectory:rH,makeTempDirectoryScoped:rZ,makeTempFile:r5,makeTempFileScoped:r3,open:r0,readDirectory:r6,readFile:r8,readLink:r9,realPath:r4,remove:rQ,rename:r7,stat:nt,symlink:nr,truncate:nn,utimes:ni,watch:(t,r)=>nt(t).pipe(B.TjK(n=>e.pipe(ee.flatMap(e=>e.register(t,n,r)),ee.getOrElse(()=>{let e,i;return tw((e=e=>B.Q56(B.OH5(()=>{let i="Directory"===n.type?t:rR.dirname(t),a=rN.watch(t,{recursive:r?.recursive??!1},(t,r)=>{if(r)switch(t){case"rename":return void B.MY7(B.tvg(nt(rR.resolve(i,r)),{onSuccess:t=>eE(e,{_tag:"Create",path:r}),onFailure:t=>eE(e,{_tag:"Remove",path:r})}));case"change":return void eO(e,{_tag:"Update",path:r})}});return a.on("error",r=>{eT(e,F.fJ(es({module:"FileSystem",_tag:"Unknown",method:"watch",pathOrDescriptor:t,cause:r})))}),a.on("close",()=>{eM(e)}),a}),e=>B.OH5(()=>e.close())),i=void 0,e3((t,r)=>B.TjK(e$({capacity:i?.bufferSize,strategy:i?.strategy}).pipe(B.Mim(e=>e0.U9(r,eA(e))),B.Mim(t=>B.ar0(e0.Gt(e(t),r),r))),eP))))}))),tE),writeFile:na},tR.of({...t,[tP]:tP,exists:e=>(0,z.Fs)(t.access(e),B.as(!0),B.KuX("PlatformError",e=>"NotFound"===e.reason._tag?B.PyW(!1):B.fJG(e))),readFileString:(e,r)=>B.qIB(t.readFile(e),e=>B.SvU({try:()=>new TextDecoder(r).decode(e),catch:e=>eo({module:"FileSystem",method:"readFileString",description:"invalid encoding",cause:e})})),stream:B.D9k(function*(e,r){let n=yield*t.open(e,{flag:"r"}),i=r?.offset===void 0?void 0:Q.bN(r.offset);i&&(yield*n.seek(i,"start"));let a=r?.bytesToRead===void 0?void 0:Q.bN(r.bytesToRead),s=BigInt(0),o=Number(BigInt(r?.chunkSize??65536)),l=n.readAlloc(o);return tw(e8(B.PyW(B.qIB(B.DYE(()=>void 0!==a&&a<=s?F.Vw():void 0!==a&&a-s<o?n.readAlloc(Number(a-s)):l),ee.match({onNone:()=>F.Vw(),onSome:e=>(s+=BigInt(e.length),B.PyW(K.of(e)))})))))},tE),sink:(e,r)=>(0,z.Fs)(t.open(e,{...r,flag:r?.flag??"w"}),B.TjK(e=>{let t,r;return t=t=>e.writeAll(t),r=B.jJl(e=>t(e),{discard:!0}),tm(e=>e.pipe(B.qIB(r),B.i4r({disableYield:!0}),em.m8(()=>tu)))}),tv),writeFileString:(e,r,n)=>B.qIB(B.SvU({try:()=>new TextEncoder().encode(r),catch:e=>eo({module:"FileSystem",method:"writeFileString",description:"could not encode string",cause:e})}),r=>t.writeFile(e,r,n))})}),no=(G.QZ(tR))(ns),nl=t("node:url"),nd=e=>({fromFileUrl:t=>B.SvU({try:()=>nl.fileURLToPath(t,{windows:e}),catch:e=>new en({module:"Path",method:"fromFileUrl",cause:e})}),toFileUrl:t=>B.SvU({try:()=>nl.pathToFileURL(t,{windows:e}),catch:e=>new en({module:"Path",method:"toFileUrl",cause:e})})});rR.posix,rR.win32;let nc=(G.Py(tF))({[tU]:tU,...rj,...nd(void 0)}),nu="~effect/Stdio",nf=Z.kl(nu),np=G.Py(nf,(M={args:B.OH5(()=>process.argv.slice(2)),stdinIsTerminal:B.OH5(()=>!0===process.stdin.isTTY),stdoutIsTerminal:B.OH5(()=>!0===process.stdout.isTTY),stdout:e=>rr({evaluate:()=>process.stdout,onError:e=>es({module:"Stdio",method:"stdout",_tag:"Unknown",cause:e}),endOnDone:e?.endOnDone??!1}),stderr:e=>rr({evaluate:()=>process.stderr,onError:e=>es({module:"Stdio",method:"stderr",_tag:"Unknown",cause:e}),endOnDone:e?.endOnDone??!1}),stdin:rc({evaluate:()=>process.stdin,onError:e=>es({module:"Stdio",method:"stdin",_tag:"Unknown",cause:e}),closeOnDone:!1})},{[nu]:nu,stdinIsTerminal:B.PyW(!1),stdoutIsTerminal:B.PyW(!1),...M})),nh={_tag:"Empty"},nm={_tag:"Closed"},ng={_A:z.D_,_E:z.D_};class ny{"~effect/RcRef"=ng;pipe(){return(0,ep.tT)(this,arguments)}state=nh;acquire;context;scope;idleTimeToLive;constructor(e,t,r,n){this.acquire=e,this.context=t,this.scope=r,this.idleTimeToLive=n}}let nv=(e,t,r)=>B.cfM(r(ra(t.fiber)),r=>{let n=t.acquired;return void 0!==n?L.N6(r)?nb(e,n):B.rIH:--t.awaiters>0||e.state!==t?B.rIH:(e.state=nh,rs(t.fiber))}),nb=(e,t)=>{if(t.refCount--,t.refCount>0)return B.rIH;let r=e.idleTimeToLive;return void 0===r||t.invalidated?(e.state===t&&(e.state=nh),e0.VN(t.scope,L.rI)):(H.MI(r)&&(t.fiber=B.FcF(n=>B.qIB(n(B.yy4(r)),()=>e.state===t&&0===t.refCount?(e.state=nh,e0.VN(t.scope,L.rI)):B.rIH)).pipe(B.yeE(B.OH5(()=>{t.fiber=void 0})),B.eJC(e.context),rl(e.scope))),B.rIH)},n_=e=>B.FcF(t=>B.qIB(B.z8E,r=>B.qIB(((e,t)=>{switch(e.state._tag){case"Closed":return B.GaK;case"Acquired":{let t=e.state;return t.refCount++,t.fiber?B.as(rs(t.fiber),t):B.PyW(t)}case"Acquiring":{let r=e.state;return r.awaiters++,nv(e,r,t)}case"Empty":{let r={_tag:"Acquiring",fiber:void 0,awaiters:1,acquired:void 0};e.state=r;let n=e0.LZ(),i=B.PpN(e.acquire,Z.WQ(e.context,e0.HG,n)).pipe(B.qIB(t=>{if(e.state!==r)return B.GaK;let i={_tag:"Acquired",value:t,scope:n,fiber:void 0,refCount:r.awaiters,invalidated:!1};return e.state=i,r.acquired=i,B.PyW(i)}),B.cfM(t=>L.oJ(t)?B.rIH:(e.state===r&&(e.state=nh),e0.VN(n,t))));return r.fiber=B.eJC(ro().context)(i),nv(e,r,t)}}})(e,t),t=>B.as(e0.a6(r,()=>nb(e,t)),t.value))));var nx=n(2718);let nw="~effect/Terminal",nk="~effect/Terminal/QuitError";class nS extends(nx.$DH("QuitError"))({_tag:nx.TcI("QuitError")}){[nk]=nk}let nI=Z.kl("effect/Terminal"),n$=t("node:readline"),nE=B.D9k(function*(e=nC){let t,r,n=process.stdin,i=process.stdout,a=yield*e$(),s=n.readableEnded,o=!1,l=()=>{s=!0,o||eM(a)};n.once("end",l),yield*B.U9h(()=>B.OH5(()=>n.off("end",l)));let d=yield*(t={acquire:B.Q56(B.OH5(()=>{let e=n$.createInterface({input:n,escapeCodeTimeout:50}),t=e=>eO(a,e),r=()=>{o=!1,eM(a)};return o=!0,n$.emitKeypressEvents(n,e),e.on("line",t),e.once("close",r),n.isTTY&&n.setRawMode(!0),{rl:e,onClose:r,onLine:t}}),({rl:e,onClose:t,onLine:r})=>B.OH5(()=>{o=!1,e.off("line",r),e.off("close",t),n.isTTY&&n.setRawMode(!1),e.close(),s&&eM(a)})),idleTimeToLive:"10 millis"},B.R6R(e=>{let r=e.context,n=Z.Jt(r,e0.HG),i=new ny(t.acquire,r,n,void 0!==t.idleTimeToLive?H.bN(t.idleTimeToLive):void 0);return B.as(e0.a6(n,()=>{let e=i.state;return(i.state=nm,"Acquired"===e._tag)?e0.VN(e.scope,L.rI):"Acquiring"===e._tag?rs(e.fiber):B.rIH}),i)})),c=B.OH5(()=>i.columns??0),u=B.OH5(()=>i.rows??0),f=B.JkU(function*(){let t=yield*e$(),r=(r,n)=>{let i={input:ee.fromUndefinedOr(r),key:{name:n.name??"",ctrl:!!n.ctrl,meta:!!n.meta,shift:!!n.shift}};eO(t,i),e(i)&&eM(t)},i=setInterval(()=>{},0x7fffffff),a=()=>{clearInterval(i),eM(t)};return yield*B.U9h(()=>B.OH5(()=>{clearInterval(i),n.off("keypress",r),n.off("end",a)})),n.on("keypress",r),s?a():(yield*n_(d),n.once("end",a)),t});return r={columns:c,rows:u,readInput:f,readLine:B.DYE(()=>ey.DYE(()=>{let e=eD(a);return void 0===e?ey.PyW(ee.none()):"Success"===e._tag?ey.PyW(ee.some(e.value)):ey.PyW(ee.none())}).pipe(B.qIB(ee.match({onNone:()=>B.P1j(B.hgn(n_(d),ej(a))),onSome:B.PyW})),B.xm_(()=>new nS({})))),display:e=>B.rfi(B.E2r(t=>{i.write(e,e=>eh.uy(e)?t(B.rIH):t(B.fJG(eo({module:"Terminal",method:"display",description:"Failed to write prompt to stdout",cause:e}))))}))},nI.of({...r,[nw]:nw})}),nO=G.QZ(nI,nE(nC));function nC(e){return e.key.ctrl&&("c"===e.key.name||"d"===e.key.name)}let nT=G.S5(rb,G.Um(no,rM,nc,np,nO));var nM=n(3178);class nA extends nx.rNF()("CliFilesystemError",{cause:nx.kld(),operation:nx.QfV,path:nx.QfV,message:nx.QfV}){}class nN extends nx.rNF()("CliInputError",{code:nx.xCb(["input_read_failed","invalid_json","interactive_stdin"]),message:nx.QfV,hint:nx.QfV}){}class nP extends nx.rNF()("CliValidationError",{message:nx.QfV,hint:nx.QfV,details:nx.O31(nx.QfV)}){}class nR extends nx.rNF()("CliBuildError",{status:nx.QfV,message:nx.QfV,hint:nx.QfV,details:nx.O31(nx.QfV)}){}class nj extends nx.rNF()("CliGenerationError",{code:nx.xCb(["provider_failure","generation_timeout","malformed_output","invalid_generated_document","unsupported_diagram_type"]),message:nx.QfV,hint:nx.QfV,details:nx.O31(nx.QfV)}){}class nD extends nx.rNF()("CliCanvasError",{code:nx.xCb(["canvas_rejected","canvas_timeout","endpoint_failure","malformed_response","network_failure"]),message:nx.QfV,hint:nx.QfV,details:nx.O31(nx.QfV)}){}class nU extends nx.rNF()("CliInteractiveError",{code:nx.xCb(["cancelled","prompt_failed"]),message:nx.QfV,hint:nx.QfV}){}class nF extends nx.rNF()("CliStorageError",{code:nx.xCb(["diagram_not_found","diagram_already_exists","diagram_busy","detached_edit","patch_source_unavailable","patch_conflict","replacement_conflict","restore_conflict","revision_not_found","corrupt_revision","corrupt_record","unsafe_storage_entry","storage_commit_failed"]),diagramId:nx.Qrq(nx.QfV),message:nx.QfV,hint:nx.QfV}){}class nB extends nx.rNF()("CliShareError",{code:nx.xCb(["invalid_share_link","unsupported_scene","share_payload_too_large","share_crypto_failed","share_transport_failed","share_timeout","share_api_changed","share_link_unavailable"]),message:nx.QfV,hint:nx.QfV,details:nx.O31(nx.QfV)}){}class nL extends nx.rNF()("CliExportError",{code:nx.xCb(["format_unavailable","invalid_destination","render_failed","invalid_render_artifact","render_limit_exceeded","unsupported_render_glyph","rasterization_failed","export_write_failed"]),diagramId:nx.Qrq(nx.QfV),storagePath:nx.Qrq(nx.QfV),recoveryCommand:nx.Qrq(nx.QfV),details:nx.Qrq(nx.O31(nx.QfV)),format:nx.QfV,message:nx.QfV,hint:nx.QfV}){}let nz=["scene","excalidraw"],nW=B.fn("sketchi.cli.codeMode.with")(function*(e,t,r){return yield*r({artifactFormats:[...nz],inlineArtifacts:[...nz]}).pipe(B.PfK(nM.Ov,e),B.PfK(nM.UA,t))});function nJ(e,t){let r=e.issues[0],n=r?.message??`Code Mode${"patch"===t?" patch":""} failed with ${e.status}.`,i=r?.hint??("patch"===t?"Repair the patch request and retry.":"Repair the document and retry."),a=e.issues.map(e=>`${e.code}${e.ref?.path?` (${e.ref.path})`:""}: ${e.message}`);return("patch"===t?["invalid_input","target_not_found","unsupported_operation","connectivity_changed"]:["invalid_input","invalid_flowchart","invalid_mindmap","invalid_sequence","quality_failed"]).includes(e.status)?nP.make({message:n,hint:i,details:a}):"storage_failed"===e.status?nF.make({code:"storage_commit_failed",message:n,hint:i}):nR.make({status:e.status,message:n,hint:i,details:a})}let nY=B.fn("sketchi.cli.codeMode.decodeArtifacts")(function*(e,t){let r="patch"===t?"patched ":"",n="patch"===t?"Inspect the Code Mode patch/export boundary.":"Inspect the Code Mode build/export boundary.",i=n=>{let i=e.formats.find(e=>e.format===n);return i?.inline!==void 0?B.PyW(i.inline):B.fJG(nR.make({status:"missing_inline_artifact",message:`Code Mode did not return the ${r}${n} artifact inline.`,hint:"patch"===t?"Retry the offline patch with the required artifact formats.":"Rebuild the document with the required offline artifact formats.",details:[n]}))},a=e.formats.find(e=>"scene"===e.format),s="export"!==t||a?nM.Uh.safeParse((yield*i("scene"))):void 0;if(s&&!s.success)return yield*nR.make({status:"invalid_scene_artifact",message:`Code Mode returned an invalid ${r}scene artifact.`,hint:n,details:s.error.issues.map(e=>e.message)});let o=nM.yE.safeParse((yield*i("excalidraw")));return o.success?{...s?.success?{scene:s.data}:{},excalidraw:o.data}:yield*nR.make({status:"invalid_excalidraw_artifact",message:`Code Mode returned an invalid ${r}Excalidraw artifact.`,hint:n,details:o.error.issues.map(e=>e.message)})});var nX=n(7086);function nq(e){return"string"==typeof e||"number"==typeof e||"symbol"==typeof e}let nG=nX.ID(),nV=nx._Re(nM.Ky,{errors:"all"}),nH=nx._Re(nM.e5,{errors:"all"}),nK=nx._Re(nM.nu,{errors:"all"}),nQ=nx._Re(nM.y1,{errors:"all"});function nZ(e){return nP.make({message:"The canonical diagram document is invalid.",hint:'Use {"type":"flowchart","spec":...}, {"type":"mindmap","spec":...}, or {"type":"sequence","spec":...}.',details:e})}function n0(e){return nG(e).issues.map(e=>{var t;let r=(e.path??[]).flatMap(e=>{let t=nq(e)?e:null!==e&&"object"==typeof e&&"key"in e&&nq(e.key)?e.key:void 0;return void 0===t?[]:[t]});return`${0===(t=["spec",...r]).length?"document":t.map(e=>"number"==typeof e?`[${e}]`:String(e)).join(".")}: ${e.message}`})}function n1(e){if(!("object"!=typeof e||null===e||Array.isArray(e))&&"type"in e&&"spec"in e)return{type:e.type,spec:e.spec}}let n2=B.fn("sketchi.cli.document.decodeCanonical")(function*(e){let t=n1(e);return t?"flowchart"===t.type?{type:"flowchart",spec:yield*nV(t.spec).pipe(B.xm_(e=>nZ(n0(e.issue))))}:"mindmap"===t.type?{type:"mindmap",spec:yield*nH(t.spec).pipe(B.xm_(e=>nZ(n0(e.issue))))}:"sequence"===t.type?{type:"sequence",spec:yield*nK(t.spec).pipe(B.xm_(e=>nZ(n0(e.issue))))}:yield*nZ(['document.type: Expected "flowchart", "mindmap", or "sequence".']):yield*nZ(["document: Expected an object with type and spec."])}),n5=B.fn("sketchi.cli.document.parseJson")(function*(e){let t=yield*B.SvU({try:()=>JSON.parse(e),catch:()=>nN.make({code:"invalid_json",message:"The input is not valid JSON.",hint:"Pass one complete canonical document object."})});return yield*n2(t)}),n3=B.fn("sketchi.cli.document.decodeStored")(function*(e){let t=n1(e);return t?.type!=="canvas"?yield*n2(e):{type:"canvas",spec:yield*nQ(t.spec).pipe(B.xm_(e=>nZ(n0(e.issue))))}});function n6(e){return`${JSON.stringify(e,null,2)}
3
+ `}function n8(e){let t=e.spec.id?.trim();return t||e.spec.title.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||`sketchi-${e.type}`}function n9(e){return/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}$/.test(e)?B.PyW(e):B.fJG(nP.make({message:`Diagram id "${e}" is not safe for local storage.`,hint:"Use 1-128 ASCII letters, digits, dots, underscores, or hyphens; start with a letter or digit.",details:["spec.id"]}))}class n4 extends Z.kl()("@sketchi/cli/DiagramBuilder"){}let n7=G.QZ(n4,B.JkU(function*(){let e=yield*nM.Ov,t=yield*nM.UA;return{build:B.fn("sketchi.cli.diagram.build")(function*(r){let n=yield*nW(e,t,e=>"flowchart"===r.type?(0,nM.XV)({spec:r.spec,options:e}):"mindmap"===r.type?(0,nM.r8)({spec:r.spec,options:e}):(0,nM.rC)({spec:r.spec,options:e}));if(!n.ok)return yield*nJ(n,"build");let i=yield*n9(n8(r)),{scene:a,excalidraw:s}=yield*nY(n.artifact,"build");return{id:i,type:r.type,title:r.spec.title,document:r,scene:a,excalidraw:s}})}})),ie=t("node:fs/promises");class it extends Z.kl()("@sketchi/cli/LocalFileSystem"){}function ir(e,t,r){return nA.make({cause:r,operation:e,path:t,message:`Filesystem ${e} failed for ${t}.`})}function ii(e,t){return"object"==typeof e&&null!==e&&"code"in e&&e.code===t}function ia(e){return e.reason.cause??e}let is=G.QZ(it,B.TjK(tR,function(e){let t=B.fn("sketchi.cli.fs.kind")(function*(t){let r=yield*e.readLink(t).pipe(B.Ket);if("Success"===r._tag)return"symbolic-link";let n=ia(r.failure);return ii(n,"ENOENT")?"missing":ii(n,"ELOOP")?"symbolic-link":ii(n,"EINVAL")?yield*e.stat(t).pipe(B.TjK(e=>"File"===e.type?"file":"Directory"===e.type?"directory":"SymbolicLink"===e.type?"symbolic-link":"other"),B.MfU(e=>{let r=ia(e);return ii(r,"ENOENT")?B.PyW("missing"):ii(r,"ELOOP")?B.PyW("symbolic-link"):B.fJG(ir("stat",t,r))})):yield*ir("stat",t,n)}),r=(e,t)=>r=>ir(e,t,ia(r));return{makeDirectory:(t,n=!1)=>e.makeDirectory(t,{recursive:n}).pipe(B.xm_(r("make-directory",t))),tryWriteText:(e,t)=>B.$mh({try:async r=>{try{let n=await (0,ie.open)(e,rN.constants.O_WRONLY|rN.constants.O_CREAT|rN.constants.O_EXCL|rN.constants.O_NOFOLLOW,384);try{await n.writeFile(t,{encoding:"utf8",signal:r}),await n.sync()}finally{await n.close()}return!0}catch(e){if(ii(e,"EEXIST"))return!1;throw e}},catch:t=>ir("write-exclusive",e,t)}),tryLinkFile:(t,r)=>e.link(t,r).pipe(B.as(!0),B.MfU(e=>{let n=ia(e);return ii(n,"EEXIST")||ii(n,"ENOENT")?B.PyW(!1):B.fJG(ir("link-exclusive",`${t} -> ${r}`,n))})),makeTempDirectory:(t,n)=>e.makeTempDirectory({directory:t,prefix:n}).pipe(B.xm_(r("make-temp-directory",t))),list:n=>e.readDirectory(n).pipe(B.xm_(r("read-directory",n)),B.qIB(e=>B.jJl(e,e=>t((0,rR.join)(n,e)).pipe(B.TjK(t=>"missing"===t?[]:[{name:e,kind:t}]))).pipe(B.TjK(e=>e.flat())))),kind:t,realPath:t=>e.realPath(t).pipe(B.xm_(r("resolve",t))),readText:e=>B.$mh({try:async t=>{let r=await (0,ie.open)(e,rN.constants.O_RDONLY|rN.constants.O_NOFOLLOW);try{return await r.readFile({encoding:"utf8",signal:t})}finally{await r.close()}},catch:t=>ir("read",e,t)}),readBytes:e=>B.$mh({try:async t=>{let r=await (0,ie.open)(e,rN.constants.O_RDONLY|rN.constants.O_NOFOLLOW);try{return new Uint8Array(await r.readFile({signal:t}))}finally{await r.close()}},catch:t=>ir("read",e,t)}),writeText:(e,t,r=!1)=>B.$mh({try:async n=>{let i=rN.constants.O_WRONLY|rN.constants.O_CREAT|rN.constants.O_NOFOLLOW|(r?rN.constants.O_TRUNC:rN.constants.O_EXCL),a=await (0,ie.open)(e,i,384);try{await a.writeFile(t,{encoding:"utf8",signal:n}),await a.sync()}finally{await a.close()}},catch:t=>ir("write",e,t)}),writeBytes:(e,t,r=!1)=>B.$mh({try:async n=>{let i=rN.constants.O_WRONLY|rN.constants.O_CREAT|rN.constants.O_NOFOLLOW|(r?rN.constants.O_TRUNC:rN.constants.O_EXCL),a=await (0,ie.open)(e,i,384);try{await a.writeFile(t,{signal:n}),await a.sync()}finally{await a.close()}},catch:t=>ir("write",e,t)}),rename:(t,n)=>e.rename(t,n).pipe(B.xm_(r("rename",`${t} -> ${n}`))),tryRenameDirectory:(r,n)=>e.rename(r,n).pipe(B.as(!0),B.MfU(e=>B.JkU(function*(){let i=ia(e);return!(ii(i,"EEXIST")||ii(i,"ENOTEMPTY")||ii(i,"EPERM")&&(yield*t(n).pipe(B.MfU(()=>B.PyW("missing"))))==="directory")&&(yield*ir("rename-exclusive-directory",`${r} -> ${n}`,i))}))),removeFile:t=>e.remove(t).pipe(B.as(!0),B.MfU(e=>{let r=ia(e);return ii(r,"ENOENT")?B.PyW(!1):B.fJG(ir("remove-file",t,r))})),remove:t=>e.remove(t,{recursive:!0,force:!0}).pipe(B.xm_(r("remove",t)))}})),io=nx._kM({operations:nM.x3.fields.operations,options:nM.x3.fields.options,intent:nM.x3.fields.intent});function il(e,t){return nP.make({message:e,hint:"Provide operations and optional options or intent only.",details:t})}let id=B.fn("sketchi.cli.patch.decodeInput")(function*(e){if("object"!=typeof e||null===e||Array.isArray(e))return yield*il("The diagram patch request is invalid.",["patch: Expected an object."]);if("source"in e)return yield*il("The diagram patch request cannot supply source.",["source: The CLI binds the stored scene."]);if("requestId"in e)return yield*il("The diagram patch request cannot supply requestId.",["requestId: The CLI owns the patch request id."]);let t=(0,nM.ie)(io,e);return t.success?{operations:t.data.operations,...t.data.options?{options:t.data.options}:{},...t.data.intent?{intent:t.data.intent}:{}}:yield*il("The diagram patch request is invalid.",t.error.issues.map(e=>e.message))}),ic=B.fn("sketchi.cli.patch.parseJson")(function*(e){let t=yield*B.SvU({try:()=>JSON.parse(e),catch:()=>nN.make({code:"invalid_json",message:"The patch input is not valid JSON.",hint:"Pass one complete diagram patch request object."})});return yield*id(t)});class iu extends Z.kl()("@sketchi/cli/DiagramPatcher"){}let ip=G.QZ(iu,B.JkU(function*(){let e=yield*nM.Ov,t=yield*nM.UA;return{patch:B.fn("sketchi.cli.diagram.patch")(function*(r,n,i){let a=yield*nW(e,t,e=>(0,nM.OF)({requestId:i,source:{scene:r},operations:n.operations,options:{...n.options,...e},...n.intent?{intent:n.intent}:{}}));if(!a.ok)return yield*nJ(a,"patch");let{scene:s,excalidraw:o}=yield*nY(a.artifact,"patch");return{scene:s,excalidraw:o}})}}));class ih extends Z.kl()("@sketchi/cli/InputReader"){}function im(e,t){return B.SvU({try:()=>new TextDecoder("utf-8",{fatal:!0}).decode(e),catch:()=>nN.make({code:"input_read_failed",message:"stdin"===t?"Standard input is not valid UTF-8.":"The input file is not valid UTF-8.",hint:"Provide one complete UTF-8 JSON document and retry."})})}let ig=function(e=()=>!0===process.stdin.isTTY){return G.QZ(ih,B.JkU(function*(){let t=yield*it,r=yield*nf;return{read:B.fn("sketchi.cli.input.read")(function*(n,i={content:"JSON document"}){if("InlineJson"===n._tag)return n.value;if("-"!==n.path){let e=yield*t.readBytes(n.path).pipe(B.xm_(()=>nN.make({code:"input_read_failed",message:`Unable to read input file ${n.path}.`,hint:"Check the path and file permissions, then retry."})));return yield*im(e,"file")}if(e())return yield*nN.make({code:"interactive_stdin",message:`${i.content} input requires piped or redirected stdin.`,hint:"share link"===i.content?"Pipe one complete Excalidraw share link to --link -.":"Pipe one JSON document, or use --file PATH / --json VALUE."});let a=yield*tN(r.stdin,()=>({chunks:[],size:0}),(e,t)=>{let r=t.byteLength+e.size;return void 0!==i.maxBytes&&r>i.maxBytes?B.fJG(nN.make({code:"input_read_failed",message:`Standard input exceeds the ${String(i.maxBytes)} byte limit for a ${i.content}.`,hint:`Pipe one complete ${i.content} within the documented limit.`})):B.PyW({chunks:[...e.chunks,t],size:r})}).pipe(B.xm_(e=>e instanceof nN?e:nN.make({code:"input_read_failed",message:`Unable to read the ${i.content} from stdin.`,hint:`Pipe one complete UTF-8 ${i.content} and retry.`})));return yield*im(function(e){let t=new Uint8Array(e.reduce((e,t)=>e+t.byteLength,0)),r=0;for(let n of e)t.set(n,r),r+=n.byteLength;return t}(a.chunks),"stdin")})}}))}(),iy=B.fn("sketchi.cli.input.readDocument")(function*(e){let t=yield*ih,r=yield*t.read(e);return yield*n5(r)}),iv=B.fn("sketchi.cli.input.readPatch")(function*(e){let t=yield*ih,r=yield*t.read(e,{content:"patch request"});return yield*ic(r)});var ib=n(6771);let i_=1,ix="manifest.json",iw="document.json",ik="scene.json",iS="diagram.excalidraw",iI="diagram.png",i$="revisions";class iE extends nx.Xsx("DiagramRecordManifest")({schemaVersion:nx.uSQ(i_),id:nx.QfV,type:nx.xCb(["canvas","flowchart","mindmap","sequence"]),title:nx.QfV,revision:nx.Aiz.check(nx.yJO(0)),authority:nx.xCb(["canonical","patched","detached"]).pipe(nx.E$i(B.PyW("canonical"))),formats:nx.O31(nx.xCb(["scene","excalidraw","png"]))}){}function iO(e){return{id:e.manifest.id,type:e.manifest.type,title:e.manifest.title,revision:e.manifest.revision,formats:e.manifest.formats,authority:e.authority,documentAuthoritative:"canonical"===e.authority}}function iC(e){return String(e).padStart(6,"0")}let iT=t("node:zlib");var iM=n(8689),iA=n(5030);let iN="https://json.excalidraw.com/api/v2/",iP=["rectangle","ellipse","diamond","arrow","line","freedraw","text"],iR=new Set(iP),ij=new TextEncoder,iD=new TextDecoder("utf-8",{fatal:!0}),iU=ij.encode(JSON.stringify({version:2,compression:"pako@1",encryption:"AES-GCM"}));function iF(e,t,r,n=[]){return nB.make({code:e,message:t,hint:r,details:n})}function iB(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function iL(e){return"number"==typeof e&&Number.isFinite(e)}function iz(e,t,r){new DataView(e.buffer,e.byteOffset,e.byteLength).setUint32(t,r)}function iW(e,t){if(t+4>e.byteLength)throw Error("truncated chunk header");return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint32(t)}function iJ(e,t){if(e.byteLength<4+4*t||1!==iW(e,0))throw Error("unsupported chunk format");let r=[],n=4;for(let i=0;i<t;i+=1){let t=iW(e,n),i=(n+=4)+t;if(i>e.byteLength)throw Error("truncated chunk");r.push(e.subarray(n,i)),n=i}if(n!==e.byteLength)throw Error("unexpected trailing chunk");return r}function iY(e){if(!/^[A-Za-z0-9_-]{22}$/.test(e))throw Error("invalid AES key encoding");let t=Buffer.from(e,"base64url");if(16!==t.byteLength)throw Error("invalid AES key length");return t}function iX(e,t){return crypto.subtle.importKey("raw",Uint8Array.from(iY(e)),{name:"AES-GCM",length:128},!1,[t])}function iq(e){if(!iB(e)||"excalidraw"!==e.type||!iL(e.version)||"string"!=typeof e.source||!Array.isArray(e.elements)||!iB(e.appState)||!(void 0===e.files||iB(e.files)))throw Error("invalid Excalidraw artifact shape");return{type:e.type,version:e.version,source:e.source,elements:e.elements,appState:e.appState,files:e.files??{}}}function iG(e,t){return"string"!=typeof e||!t.has(e)}function iV(e,t){if("number"==typeof e)return Number.isFinite(e)?void 0:`${t} must be finite`;if(Array.isArray(e))for(let r of e){let e=iV(r,`${t} item`);if(e)return e}else if(iB(e))for(let r of Object.values(e)){let e=iV(r,`${t} property`);if(e)return e}}function iH(e){return B.SvU({try:()=>{let t=iq(e);if(iB(e)&&"libraryItems"in e)throw Error("Excalidraw library state is unsupported");if(t.elements.length>1e4)throw Error("element count exceeds 10000");if(Object.keys(t.files).length>0)throw Error("binary files are unsupported");let r=new Set;for(let[e,n]of t.elements.entries()){if(!iB(n)||"string"!=typeof n.id)throw Error(`elements[${String(e)}].id is invalid`);if(r.has(n.id))throw Error(`elements[${String(e)}].id is duplicated`);r.add(n.id)}for(let[e,n]of t.elements.entries()){let t=function(e,t,r){let n=`elements[${String(t)}]`;if(!iB(e)||"string"!=typeof e.id||0===e.id.length||"string"!=typeof e.type)return`elements[${String(t)}] is not an Excalidraw element`;if(!iR.has(e.type))return`${n}.type is unsupported`;if("link"in e&&null!==e.link&&void 0!==e.link||"fileId"in e)return`${n} contains an external resource`;let i=iV(e,n);if(i)return i;for(let t of["x","y","width","height","angle"])if(!iL(e[t]))return`${n}.${t} must be finite`;if("text"===e.type){if(5!==e.fontFamily)return`${n}.fontFamily must be ${String(5)}`;if("string"!=typeof e.text)return`${n}.text is invalid`}if(["arrow","line","freedraw"].includes(e.type)&&(!Array.isArray(e.points)||e.points.some(e=>!Array.isArray(e)||e.length<2||!iL(e[0])||!iL(e[1]))))return`${n}.points contains invalid geometry`;for(let t of["containerId","frameId"])if(null!==e[t]&&void 0!==e[t]&&iG(e[t],r))return`${n}.${t} is an invalid element reference`;for(let t of["startBinding","endBinding"]){let i=e[t];if(null!=i&&(!iB(i)||iG(i.elementId,r)))return`${n}.${t} is an invalid element binding`}let a=e.boundElements;if(null!=a&&(!Array.isArray(a)||a.some(e=>!iB(e)||iG(e.id,r))))return`${n}.boundElements contains an invalid element reference`}(n,e,r);if(t)throw Error(t)}let n=(0,iA.Gd)(t.elements);if(n)throw Error(n);let i=function(e){if("viewBackgroundColor"in e&&"string"!=typeof e.viewBackgroundColor)return"appState.viewBackgroundColor must be a string";if("gridModeEnabled"in e&&"boolean"!=typeof e.gridModeEnabled)return"appState.gridModeEnabled must be boolean";for(let t of["gridSize","gridStep"])if(t in e&&null!==e[t]&&!iL(e[t]))return`appState.${t} must be finite or null`;if("lockedMultiSelections"in e){let t=e.lockedMultiSelections;if(!iB(t))return"appState.lockedMultiSelections must be an object";for(let[e,r]of Object.entries(t))if(0===e.length||!0!==r)return"appState.lockedMultiSelections contains an invalid lock entry"}return iV(e,"appState")}(t.appState);if(i)throw Error(i);return e},catch:e=>iF("unsupported_scene","The Excalidraw scene is unsupported by share/pull v1.",`Use only ${iP.join(", ")} elements, Excalifont fontFamily ${String(5)}, and no files or images.`,[e instanceof Error?e.message:"invalid scene"])})}function iK(e){let t=new Uint8Array(4);return iz(t,0,e),t}let iQ=nx._kM({buffer:nx.SEl,engine:nx._kM({bytesWritten:nx.wNn})});function iZ(e){let t=0xffffffff;for(let r of e){t^=r;for(let e=0;e<8;e+=1)t=t>>>1^(1&t?0xedb88320:0)}return(0xffffffff^t)>>>0}function i0(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}let i1=[[0,0,8,8],[4,0,8,8],[0,4,4,8],[2,0,4,4],[0,2,2,4],[1,0,2,2],[0,1,1,2]];function i2(e,t,r){return e<=t?0:Math.ceil((e-t)/r)}function i5(e){let t,r,n,i,a,s=[137,80,78,71,13,10,26,10];if(e.byteLength<33||s.some((t,r)=>e[r]!==t))return!1;let o=s.length,l=0,d=!1,c=!1,u=!1,f=[];for(;o+12<=e.byteLength;){let s=i0(e,o),p=o+12+s;if(p>e.byteLength)break;let h=o+4,m=e.subarray(h,h+4),g=e=>e>=65&&e<=90||e>=97&&e<=122;if(4!==m.byteLength||!m.every(g)||(32&m[2])!=0)break;let y=String.fromCharCode(...m);if(0===l&&("IHDR"!==y||13!==s))break;if("IHDR"===y){if(0!==l||13!==s)return!1;t=i0(e,o+8),r=i0(e,o+12),i=e[o+16],n=e[o+17],a=e[o+20];let d={0:[1,2,4,8,16],2:[8,16],3:[1,2,4,8],4:[8,16],6:[8,16]};if(0===t||0===r||t>0x7fffffff||r>0x7fffffff||void 0===n||void 0===i||!d[n]?.includes(i)||0!==e[o+18]||0!==e[o+19]||![0,1].includes(a??-1))break}else if("PLTE"===y){if(d||c||0===s||s%3!=0||s>768||0===n||4===n||3===n&&void 0!==i&&s/3>2**i)return!1;d=!0}else if("IDAT"===y){if(u||3===n&&!d)return!1;c=!0,f.push(e.subarray(o+8,o+8+s))}else if("IEND"===y){if(0!==s||!c||3===n&&!d)break}else{c&&(u=!0);let t=e[h];if(void 0===t||(32&t)==0)break}let v=i0(e,o+8+s);if(iZ(e.subarray(h,o+8+s))!==v)break;if(o=p,l+=1,"IEND"===y)return o===e.byteLength&&void 0!==t&&void 0!==r&&void 0!==i&&void 0!==n&&void 0!==a&&function(e,t,r,n,i,a){let s={0:1,2:3,3:1,4:2,6:4}[i];if(void 0===s)return!1;let o=function(e,t,r,n){let i=[],a=0;for(let[s,o,l,d]of 0===n?[[0,0,1,1]]:i1){let n=i2(e,s,l),c=i2(t,o,d);if(0===n||0===c)continue;let u=Math.ceil(n*r/8)+1;if(u>0x1000000-a||c>Math.floor((0x1000000-a)/u))return null;a+=c*u,i.push({rows:c,rowBytes:u})}return i}(t,r,s*n,a);if(null===o)return!1;let l=o.reduce((e,t)=>e+t.rows*t.rowBytes,0);try{let t=function(e){let t=new Uint8Array(e.reduce((e,t)=>e+t.byteLength,0)),r=0;for(let n of e)t.set(n,r),r+=n.byteLength;return t}(e),r=(0,iT.inflateSync)(t,{info:!0,maxOutputLength:0x1000000}),n=nx.svK(iQ)(r);if(n.engine.bytesWritten!==t.byteLength)return!1;let i=n.buffer;if(i.byteLength!==l)return!1;let a=0;for(let e of o)for(let t=0;t<e.rows;t+=1){if((i[a]??5)>4)return!1;a+=e.rowBytes}return a===i.byteLength}catch{return!1}}(f,t,r,i,n,a)}return!1}class i3 extends Z.kl()("@sketchi/cli/StorageRoot"){}class i6 extends Z.kl()("@sketchi/cli/DiagramStore"){}let i8=".locks",i9="free.",i4="owner.",i7=".owner-candidate.",ae=".json",at="recovery",ar=".backup.",an=`.stage.${String(process.pid)}.`,ai=ib.ji("10 millis").pipe(ib.jB({times:50})),aa=G.Py(i3,{path:(0,rR.join)((0,rP.homedir)(),".sketchi","diagrams")});function as(e,t,r,n){return nF.make({code:e,message:t,hint:r,...n?{diagramId:n}:{}})}function ao(e){return Buffer.from(e,"utf8").toString("base64url")}function al(e,t){return e<t?-1:+(e>t)}function ad(e,t){let r=e.replace(/(?:\/|\.json)$/u,"").replace(/^0+/u,""),n=t.replace(/(?:\/|\.json)$/u,"").replace(/^0+/u,""),i=r.length-n.length;return 0!==i?i:al(r,n)||al(e,t)}function ac(e,t){let r="detached"===e?["excalidraw"]:["scene","excalidraw"];return t?[...r,"png"]:r}function au(e){if(!Number.isSafeInteger(e)||e<=0)return!1;try{return process.kill(e,0),!0}catch(e){return"object"==typeof e&&null!==e&&"code"in e&&"EPERM"===e.code}}function af(e,t){return"object"==typeof e.cause&&null!==e.cause&&"code"in e.cause&&e.cause.code===t}function ap(e,t){return(0,rR.join)(e,t)}function ah(e){switch(e){case"scene":return ik;case"excalidraw":return iS;case"png":return iI}}function am(e,t){return as("unsafe_storage_entry",`Unsafe local storage entry at ${e}.`,"Replace symbolic links or special files with ordinary Sketchi record files.",t)}let ag=G.QZ(i6,B.JkU(function*(){let e=yield*it,t=yield*i3,r=B.fn("sketchi.cli.storage.ensureOwnedDirectory")(function*(t){let r=yield*e.kind(t);if("missing"===r&&(yield*e.makeDirectory(t).pipe(B.MfU(e=>af(e,"EEXIST")?B.rIH:B.fJG(e))),r=yield*e.kind(t)),"directory"!==r)return yield*am(t)}),n=B.fn("sketchi.cli.storage.ensureRoot")(function*(){yield*r((0,rR.dirname)(t.path)),yield*r(t.path),yield*r((0,rR.join)(t.path,i8))}),i=B.fn("sketchi.cli.storage.assertSafeTree")(function*(t,r){for(let n of yield*e.list(t)){let e=(0,rR.join)(t,n.name);if("symbolic-link"===n.kind||"other"===n.kind)return yield*am(e,r);"directory"===n.kind&&(yield*i(e,r))}}),a=B.fn("sketchi.cli.storage.recoverStages")(function*(r){for(let n of[...r??(yield*e.list(t.path))].sort((e,t)=>al(e.name,t.name))){if(!n.name.startsWith(".stage."))continue;let r=function(e){let t=Number(e.split(".").at(-2));return Number.isSafeInteger(t)?t:void 0}(n.name);void 0!==r&&au(r)||(yield*e.remove((0,rR.join)(t.path,n.name)))}}),s=B.fn("sketchi.cli.storage.recoverRecordTransactions")(function*(r){let n=`${ar}${ao(r)}.`;for(let i of[...yield*e.list(t.path)].filter(e=>e.name.startsWith(n)).sort((e,t)=>al(e.name,t.name))){let n=(0,rR.join)(t.path,i.name),a=ap(t.path,r);"missing"===(yield*e.kind(a))?yield*e.rename(n,a):yield*e.remove(n)}}),o=e=>(0,rR.join)(t.path,i8,`${ao(e)}.lock`),l=B.fn("sketchi.cli.storage.initializeLockDirectory")(function*(r){let n=o(r),i=yield*e.kind(n);if("directory"===i)return n;if("missing"!==i)return yield*am(n,r);let a=(0,rR.join)(t.path,i8);return yield*B.jGc(e.makeTempDirectory(a,`.init.${ao(r)}.`),t=>B.JkU(function*(){let i=crypto.randomUUID();return(yield*e.writeText((0,rR.join)(t,`${i9}${i}${ae}`),n6({token:i})),(yield*e.tryRenameDirectory(t,n))||"directory"===(yield*e.kind(n)))?n:yield*am(n,r)}),t=>e.remove(t))}),d=e=>as("diagram_busy",`Diagram "${e}" is being changed by another Sketchi process.`,"Wait for that command to finish, then retry.",e),c=B.fn("sketchi.cli.storage.readLockEntries")(function*(t,r){let n=[...yield*e.list(t)].sort((e,t)=>al(e.name,t.name)),i=[];for(let a of n){let n=(0,rR.join)(t,a.name);if("file"!==a.kind)return yield*am(n,r);let s=function(e){if(!e.startsWith(i9)||!e.endsWith(ae))return;let t=e.slice(i9.length,-ae.length).split(".");if(1!==t.length&&2!==t.length||t.some(e=>!/^[a-zA-Z0-9_-]+$/.test(e)))return;let[r,n]=t;if(r)return{token:r,...n?{releasedOwnerToken:n}:{}}}(a.name);if(s){i.push({name:a.name,path:n,state:"free",token:s.token,...s.releasedOwnerToken?{releasedOwnerToken:s.releasedOwnerToken}:{}});continue}if(a.name.startsWith(i9))return yield*am(n,r);let o=function(e){if(!e.startsWith(i7)||!e.endsWith(ae))return;let t=e.slice(i7.length,-ae.length);return/^[a-zA-Z0-9_-]+$/.test(t)?t:void 0}(a.name);if(o){i.push({name:a.name,path:n,state:"unpublished-owner",token:o});continue}if(a.name.startsWith(i7)||!a.name.startsWith(i4)||!a.name.endsWith(ae))return yield*am(n,r);let l=function(e){try{let t=JSON.parse(e);return"object"==typeof t&&null!==t&&"pid"in t&&"number"==typeof t.pid&&"token"in t&&"string"==typeof t.token&&t.token.length>0?{pid:t.pid,token:t.token}:void 0}catch{return}}((yield*e.readText(n).pipe(B.xm_(e=>af(e,"ENOENT")?d(r):e))));if(!l)return yield*d(r);if(a.name!==`${i4}${l.token}${ae}`)return yield*am(n,r);i.push({name:a.name,path:n,token:l.token,state:au(l.pid)?"live-owner":"stale-owner"})}return i}),u=B.fn("sketchi.cli.storage.acquireLockOnce")(function*(t){let r=yield*l(t),n=yield*c(r,t),i=new Set(n.flatMap(e=>e.releasedOwnerToken?[e.releasedOwnerToken]:[]));if(n.some(e=>"live-owner"===e.state&&!i.has(e.token)))return yield*d(t);let a=n.find(e=>"free"===e.state)??n.find(e=>"stale-owner"===e.state);if(!a){let n=(0,rR.join)(r,`${i9}${at}${ae}`);if(!(yield*e.tryWriteText(n,n6({token:at}))))return yield*d(t);a={name:`${i9}${at}${ae}`,path:n,state:"free",token:at}}let s=crypto.randomUUID(),o=(0,rR.join)(r,`${i4}${s}${ae}`),u=(0,rR.join)(r,`${i7}${s}${ae}`);return yield*B.rfi(B.jGc(B.PyW(u),()=>B.JkU(function*(){if(yield*e.writeText(u,n6({pid:process.pid,token:s})),!(yield*e.tryLinkFile(u,o)))return yield*d(t);if(!(yield*e.removeFile(a.path).pipe(B.MfU(t=>e.removeFile(o).pipe(B.hgn(B.fJG(t)))))))return yield*e.removeFile(o),yield*d(t);for(let t of n)t.path!==a.path&&(yield*e.removeFile(t.path).pipe(B.MfU(()=>B.rIH)));return{directory:r,ownerPath:o,token:s}}),t=>e.removeFile(t).pipe(B.MfU(()=>B.rIH))))}),f=B.fn("sketchi.cli.storage.releaseLock")(function*(t,r){let n=crypto.randomUUID(),i=(0,rR.join)(r.directory,`${i9}${n}.${r.token}${ae}`),a=n6({token:n,releasedOwnerToken:r.token});if(!(yield*e.tryWriteText(i,a).pipe(B.MfU(()=>e.kind(i).pipe(B.TjK(e=>"file"===e))),B.MfU(()=>B.PyW(!1))))){if(yield*e.removeFile(r.ownerPath))return;return yield*as("storage_commit_failed",`Diagram "${t}" lock ownership changed before release.`,"Retry after the active Sketchi command finishes.",t)}if(!(yield*e.removeFile(r.ownerPath).pipe(B.YWq({onFailure:()=>!0,onSuccess:e=>e}))))return yield*e.removeFile(i).pipe(B.MfU(()=>B.rIH)),yield*as("storage_commit_failed",`Diagram "${t}" lock ownership changed before release.`,"Retry after the active Sketchi command finishes.",t)}),p=e=>as("diagram_not_found",`Diagram "${e}" does not exist.`,"Run sketchi list to discover stored diagram ids.",e),h=(r,i,l=!1,d=!1)=>B.JkU(function*(){let c;if(l){let n=ap(t.path,r),i=yield*e.kind(n);if("missing"===i){let n=yield*e.kind(t.path);if("missing"===n)return yield*p(r);if("directory"!==n)return yield*am(t.path,r);let i=o(r),a=yield*e.kind(i);if("missing"===a){let n=yield*e.list(t.path),i=`${ar}${ao(r)}.`;if(!n.some(e=>e.name===r||e.name.startsWith(i)))return yield*p(r)}else if("directory"!==a)return yield*am(i,r)}else if("directory"!==i)return yield*am(n,r)}return d||(yield*n(),yield*a()),yield*B.jGc((c=u(r),l?c.pipe(B.L5P({schedule:ai,while:e=>"CliStorageError"===e._tag&&"diagram_busy"===e.code})):c),()=>s(r).pipe(B.hgn(i)),e=>f(r,e).pipe(B.MfU(()=>B.rIH)))}),m=B.fn("sketchi.cli.storage.decodeManifest")(function*(t,r){let n=yield*e.readText(t),i=yield*B.SvU({try:()=>JSON.parse(n),catch:()=>as("corrupt_record",`Diagram "${r}" has an invalid manifest.`,"Inspect manifest.json and restore it from a known-good backup.",r)});return yield*nx._Re(iE)(i).pipe(B.xm_(()=>as("corrupt_record",`Diagram "${r}" has an incompatible manifest.`,`Expected manifest schema version ${String(1)}.`,r)))}),g=B.fn("sketchi.cli.storage.decodeDocument")(function*(t,r){let n=yield*e.readText(t),i=yield*B.SvU({try:()=>JSON.parse(n),catch:()=>as("corrupt_record",`Diagram "${r}" has invalid document JSON.`,"Recover a prior canonical document from the revisions directory.",r)});return yield*n3(i).pipe(B.xm_(()=>as("corrupt_record",`Diagram "${r}" has an invalid canonical document.`,"Recover a prior canonical document from the revisions directory.",r)))}),y=B.fn("sketchi.cli.storage.loadUnlocked")(function*(r){var n;let a,s=ap(t.path,r),o=yield*e.kind(s);if("missing"===o)return yield*as("diagram_not_found",`Diagram "${r}" does not exist.`,"Run sketchi list to discover stored diagram ids.",r);if("directory"!==o)return yield*am(s,r);yield*i(s,r);let l=yield*m((0,rR.join)(s,ix),r);if(l.id!==r)return yield*as("corrupt_record",`Diagram directory "${r}" contains manifest id "${l.id}".`,"Make the directory name and manifest id agree before retrying.",r);let d=yield*g((0,rR.join)(s,iw),r);if(l.type!==d.type||l.title!==d.spec.title)return yield*as("corrupt_record",`Diagram "${r}" manifest does not match its canonical document.`,"Recover the canonical document and rebuild the record with sketchi edit.",r);for(let t of[ik,iS])if((yield*e.kind((0,rR.join)(s,t)))!=="file")return yield*as("corrupt_record",`Diagram "${r}" is missing required artifact ${t}.`,"Recover the canonical document and rebuild the record with sketchi edit.",r);let c=yield*e.kind((0,rR.join)(s,iI));if("file"!==c&&"missing"!==c)return yield*am((0,rR.join)(s,iI),r);if("file"===c&&(a=(n=yield*e.readBytes((0,rR.join)(s,iI))).byteLength-12,!(n.byteLength>=45&&[137,80,78,71,13,10,26,10].every((e,t)=>n[t]===e)&&13===i0(n,8)&&"IHDR"===String.fromCharCode(...n.subarray(12,16))&&i0(n,16)>0&&i0(n,20)>0)||iZ(n.subarray(12,29))!==i0(n,29)||0!==i0(n,a)||"IEND"!==String.fromCharCode(...n.subarray(a+4,a+8))||iZ(n.subarray(a+4,a+8))!==i0(n,a+8)))return yield*as("corrupt_record",`Diagram "${r}" has an invalid stored PNG artifact.`,"Recover a valid prior revision or rebuild the record.",r);let u=ac(l.authority,"file"===c);if(l.formats.length!==u.length||l.formats.some((e,t)=>e!==u[t]))return yield*as("corrupt_record",`Diagram "${r}" manifest formats do not match stored artifacts.`,"Recover the canonical document and rebuild the record with sketchi edit.",r);let f=(0,rR.join)(s,i$),p=[];for(let t of yield*e.list(f)){if("file"===t.kind&&/^\d{6,}\.json$/u.test(t.name)){p.push(t.name);continue}if("directory"===t.kind&&/^\d{6,}$/u.test(t.name)){p.push(`${t.name}/`);continue}return yield*am((0,rR.join)(f,t.name),r)}return p.sort(ad),{manifest:l,document:d,revisions:p,authority:l.authority}}),v=B.fn("sketchi.cli.storage.copySafeTree")(function*(t,r,n){for(let i of yield*e.list(t)){let a=(0,rR.join)(t,i.name),s=(0,rR.join)(r,i.name);if("directory"===i.kind)yield*e.makeDirectory(s),yield*v(a,s,n);else{if("file"!==i.kind)return yield*am(a,n);let t=yield*e.readBytes(a);yield*e.writeBytes(s,t)}}}),b=B.fn("sketchi.cli.storage.copyRecordSnapshot")(function*(t,r,n){for(let i of(yield*e.makeDirectory(r),yield*e.list(t))){if(i.name===i$)continue;let a=(0,rR.join)(t,i.name),s=(0,rR.join)(r,i.name);if("file"!==i.kind)return yield*am(a,n);yield*e.writeBytes(s,(yield*e.readBytes(a)))}}),_=B.fn("sketchi.cli.storage.commitStage")(function*(r,n){let i=ap(t.path,r),a=(0,rR.join)(t.path,`${ar}${ao(r)}.${String(process.pid)}.${crypto.randomUUID()}`);yield*e.rename(i,a),(yield*e.rename(n,i).pipe(B.tvg({onFailure:t=>e.rename(a,i).pipe(B.tvg({onFailure:()=>B.fJG(as("storage_commit_failed",`Atomic storage commit and rollback both failed for "${r}".`,"Retry; Sketchi will recover the backup transaction before the next operation.",r)),onSuccess:()=>B.fJG(t)})),onSuccess:()=>B.PyW(!0)})))&&(yield*e.remove(a).pipe(B.MfU(()=>B.rIH)))}),x=B.fn("sketchi.cli.storage.snapshotCurrent")(function*(r,n,i){let a=(0,rR.join)(n,i$,iC(i));if((yield*e.kind(a))!=="missing")return yield*as("corrupt_record",`Diagram "${r}" already has a snapshot for current revision ${String(i)}.`,"Inspect the revisions directory before retrying.",r);yield*b(ap(t.path,r),a,r)}),w=B.fn("sketchi.cli.storage.writeBuilt")(function*(t,r){if(r.png&&!i5(r.png))return yield*as("corrupt_record",`Diagram "${r.id}" has an invalid stored PNG artifact.`,"Recover a valid prior revision or rebuild the record.",r.id);yield*e.makeDirectory((0,rR.join)(t,i$),!0),yield*e.writeText((0,rR.join)(t,iw),n6(r.document),!0),yield*e.writeText((0,rR.join)(t,ik),n6(r.scene),!0),yield*e.writeText((0,rR.join)(t,iS),n6(r.excalidraw),!0);let n=(0,rR.join)(t,iI);yield*e.remove(n),r.png&&(yield*e.writeBytes(n,r.png))}),k=B.fn("sketchi.cli.storage.transition")(function*(r,n,i){return yield*h(r,B.JkU(function*(){let a=yield*y(r),s=yield*n(a);return yield*B.jGc(e.makeTempDirectory(t.path,an),n=>B.JkU(function*(){yield*v(ap(t.path,r),n,r),yield*x(r,n,a.manifest.revision);let o=yield*i(n,a,s);return yield*e.writeText((0,rR.join)(n,ix),n6(o.manifest),!0),yield*_(r,n),{...o,revisions:[...a.revisions,`${iC(a.manifest.revision)}/`].sort(ad),authority:o.manifest.authority}}),t=>e.remove(t))}))}),S=B.fn("sketchi.cli.storage.create")(function*(r){return yield*h(r.id,B.JkU(function*(){let n=ap(t.path,r.id);if((yield*e.kind(n))!=="missing")return yield*as("diagram_already_exists",`Diagram "${r.id}" already exists.`,"Use sketchi edit for full-document replacement.",r.id);let i=iE.make({schemaVersion:1,id:r.id,type:r.type,title:r.title,revision:1,authority:"canonical",formats:ac("canonical",void 0!==r.png)});return yield*B.jGc(e.makeTempDirectory(t.path,an),t=>B.JkU(function*(){return yield*w(t,r),yield*e.writeText((0,rR.join)(t,ix),n6(i),!0),yield*e.rename(t,n),{manifest:i,document:r.document,revisions:[],authority:"canonical"}}),t=>e.remove(t))}))}),I=B.fn("sketchi.cli.storage.edit")((e,t)=>k(e,r=>B.JkU(function*(){return"canonical"!==r.authority?yield*as("detached_edit",`Diagram "${e}" does not have an authoritative canonical document.`,"Restore a canonical revision before editing this diagram.",e):t.id!==e?yield*as("storage_commit_failed",`Edited document id "${t.id}" does not match "${e}".`,"Keep spec.id equal to the diagram id being edited.",e):iE.make({schemaVersion:1,id:e,type:t.type,title:t.title,revision:r.manifest.revision+1,authority:"canonical",formats:ac("canonical",void 0!==t.png)})}),(e,r,n)=>w(e,t).pipe(B.as({manifest:n,document:t.document})))),$=e=>as("patch_source_unavailable",`Diagram "${e}" has no current authoritative scene to patch.`,"Restore a canonical or patched revision before patching this diagram.",e),E=B.fn("sketchi.cli.storage.readPatchSourceUnlocked")(function*(r){let n=yield*y(r);if("detached"===n.authority||!n.manifest.formats.includes("scene"))return yield*$(r);let i=(0,rR.join)(ap(t.path,r),ik),a=yield*e.readText(i),s=yield*B.OH5(()=>{try{return nM.Uh.safeParse(JSON.parse(a))}catch{return}});return s?.success&&s.data.diagramId===r?{revision:n.manifest.revision,scene:s.data}:yield*as("corrupt_record",`Diagram "${r}" has an invalid current scene artifact.`,"Restore a valid prior revision before patching this diagram.",r)}),O=B.fn("sketchi.cli.storage.readPatchSource")(e=>h(e,E(e),!0)),C=B.fn("sketchi.cli.storage.commitPatch")((t,r,n)=>k(t,e=>B.JkU(function*(){return e.manifest.revision!==r?yield*as("patch_conflict",`Diagram "${t}" changed before the patch could commit.`,"Run sketchi show, verify the current record, and retry the patch if it is still intended.",t):"detached"!==e.authority&&e.manifest.formats.includes("scene")?n.scene.diagramId!==t?yield*as("storage_commit_failed",`Patched scene id "${n.scene.diagramId}" does not match "${t}".`,"Retry the patch against the named stored diagram.",t):iE.make({schemaVersion:1,id:t,type:e.manifest.type,title:e.manifest.title,revision:e.manifest.revision+1,authority:"patched",formats:ac("patched",!1)}):yield*$(t)}),(t,r,i)=>B.JkU(function*(){return yield*e.writeText((0,rR.join)(t,ik),n6(n.scene),!0),yield*e.writeText((0,rR.join)(t,iS),n6(n.excalidraw),!0),yield*e.remove((0,rR.join)(t,iI)),{manifest:i,document:r.document}}))),T=(e,t)=>as("corrupt_revision",`Diagram "${e}" revision ${String(t)} is corrupt.`,"Choose another revision or repair the corrupt snapshot.",e),M=B.fn("sketchi.cli.storage.validateArchivedJson")(function*(t,r,n){let i=yield*e.readText(t);return yield*B.SvU({try:()=>{let e=JSON.parse(i);if("object"!=typeof e||null===e)throw Error("archived JSON must contain an object");return e},catch:()=>T(r,n)})}),A=B.fn("sketchi.cli.storage.validateArchivedArtifact")(function*(e,t,r,n,i){let a=yield*M(e,n,i);if(!("scene"===t?nM.Uh.safeParse(a):nM.yE.safeParse(a)).success)return yield*T(n,i);"excalidraw"===t&&"detached"===r&&(yield*iH(a).pipe(B.xm_(()=>T(n,i))))}),N=B.fn("sketchi.cli.storage.validateArchivedPng")(function*(t,r,n){if(!i5((yield*e.readBytes(t))))return yield*T(r,n)}),P=B.fn("sketchi.cli.storage.readRevisionUnlocked")(function*(r,n){let a=(0,rR.join)(ap(t.path,r),i$),s=(0,rR.join)(a,iC(n)),o=yield*e.kind(s);if("directory"===o){yield*i(s,r);let t=yield*m((0,rR.join)(s,ix),r).pipe(B.xm_(()=>T(r,n))),a=yield*g((0,rR.join)(s,iw),r).pipe(B.xm_(()=>T(r,n)));if(t.id!==r||t.revision!==n||t.type!==a.type||t.title!==a.spec.title)return yield*as("corrupt_revision",`Diagram "${r}" revision ${String(n)} has inconsistent metadata.`,"Choose another revision or repair the corrupt snapshot.",r);for(let[i,a]of[[ik,"scene"],[iS,"excalidraw"]]){let o=(0,rR.join)(s,i);if((yield*e.kind(o))!=="file")return yield*as("corrupt_revision",`Diagram "${r}" revision ${String(n)} is missing ${i}.`,"Choose another revision or repair the corrupt snapshot.",r);yield*A(o,a,t.authority,r,n).pipe(B.xm_(e=>"CliFilesystemError"===e._tag?T(r,n):e))}let o=yield*e.kind((0,rR.join)(s,iI));if("file"!==o&&"missing"!==o)return yield*am((0,rR.join)(s,iI),r);"file"===o&&(yield*N((0,rR.join)(s,iI),r,n).pipe(B.xm_(e=>"CliFilesystemError"===e._tag?T(r,n):e)));let l=ac(t.authority,"file"===o);return t.formats.length!==l.length||t.formats.some((e,t)=>e!==l[t])?yield*as("corrupt_revision",`Diagram "${r}" revision ${String(n)} has inconsistent formats.`,"Choose another revision or repair the corrupt snapshot.",r):{_tag:"FullSnapshot",revision:n}}if("missing"!==o)return yield*am(s,r);let l=(0,rR.join)(a,`${String(n).padStart(6,"0")}.json`),d=yield*e.kind(l);if("missing"===d)return yield*as("revision_not_found",`Diagram "${r}" has no revision ${String(n)}.`,"Run sketchi show to inspect the available revision paths.",r);if("file"!==d)return yield*am(l,r);let c=yield*n2((yield*M(l,r,n))).pipe(B.xm_(()=>as("corrupt_revision",`Diagram "${r}" revision ${String(n)} is corrupt.`,"Choose another revision or repair the legacy revision file.",r)));return{_tag:"LegacyDocument",revision:n,document:c}}),R=B.fn("sketchi.cli.storage.replaceWithDetached")((t,r,n)=>k(t,e=>B.JkU(function*(){return void 0!==n&&e.manifest.revision!==n?yield*as("replacement_conflict",`Diagram "${t}" changed before the pulled replacement could commit.`,"Run sketchi show, verify the current record, and retry the pull if it is still intended.",t):iE.make({schemaVersion:1,id:t,type:e.manifest.type,title:e.manifest.title,revision:e.manifest.revision+1,authority:"detached",formats:ac("detached",!1)})}),(t,n,i)=>B.JkU(function*(){return yield*e.writeBytes((0,rR.join)(t,iS),r,!0),yield*e.remove((0,rR.join)(t,iI)),{manifest:i,document:n.document}}))),j=B.fn("sketchi.cli.storage.readRevision")((e,t)=>h(e,y(e).pipe(B.hgn(P(e,t))),!0)),D=B.fn("sketchi.cli.storage.restore")(function*(t,r,n){return{diagram:yield*k(t,e=>B.JkU(function*(){let i=yield*P(t,r);if("LegacyDocument"===i._tag){if("canonical"!==e.authority||!n)return yield*as("restore_conflict",`Legacy revision ${String(r)} requires a canonical rebuild for "${t}".`,"Restore a full canonical snapshot, or provide the rebuilt legacy document.",t);if(n.id!==t||n6(n.document)!==n6(i.document))return yield*as("storage_commit_failed",`Legacy revision ${String(r)} rebuild does not match its archived document.`,"Rebuild the exact archived canonical document before restoring.",t)}return i}),(i,a,s)=>B.JkU(function*(){if("FullSnapshot"===s._tag){let n=(0,rR.join)(i,i$,iC(r));for(let t of yield*e.list(i))t.name!==i$&&(yield*e.remove((0,rR.join)(i,t.name)));yield*v(n,i,t);let s=yield*m((0,rR.join)(i,ix),t),o=yield*g((0,rR.join)(i,iw),t);return{manifest:iE.make({...s,revision:a.manifest.revision+1}),document:o}}if(!n)return yield*as("storage_commit_failed",`Legacy revision ${String(r)} has no rebuilt document.`,"Rebuild the archived canonical document before restoring.",t);let o=iE.make({schemaVersion:1,id:t,type:n.type,title:n.title,revision:a.manifest.revision+1,authority:"canonical",formats:ac("canonical",void 0!==n.png)});return yield*w(i,n),{manifest:o,document:n.document}})),restoredFromRevision:r}}),U=B.fn("sketchi.cli.storage.show")(e=>h(e,y(e),!0));return{create:S,edit:I,readPatchSource:O,commitPatch:C,replaceWithDetached:R,readRevision:j,restore:D,show:U,list:B.fn("sketchi.cli.storage.list")(function*(){yield*n();let r=yield*e.list(t.path);yield*a(r);let i=new Set;for(let e of r){if("directory"===e.kind&&!e.name.startsWith(".")){i.add(e.name);continue}if(!e.name.startsWith(ar))continue;let t=function(e){try{let t=Buffer.from(e,"base64url").toString("utf8");return/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}$/.test(t)?t:void 0}catch{return}}(e.name.split(".")[2]??"");t&&i.add(t)}return yield*B.jJl([...i].sort(al),e=>h(e,y(e),!0,!0).pipe(B.Ket,B.TjK(t=>{if(tL.oJ(t))return iO(t.success);let r=t.failure;return{id:e,status:"unavailable",code:"CliStorageError"===r._tag?r.code:"filesystem_error",message:r.message,hint:"CliStorageError"===r._tag?r.hint:"Check local paths and permissions, then retry."}})),{concurrency:4})}),readExportSource:B.fn("sketchi.cli.storage.readExportSource")(function*(r,n){return yield*h(r,B.JkU(function*(){let i=yield*y(r);if(i.manifest.formats.includes(n)){let i=yield*e.readBytes((0,rR.join)(ap(t.path,r),ah(n)));return"png"!==n||i5(i)?{_tag:"StoredArtifact",bytes:i}:yield*as("corrupt_record",`Diagram "${r}" has an invalid stored PNG artifact.`,"Recover a valid prior revision or rebuild the record.",r)}if("png"!==n)return yield*nL.make({code:"format_unavailable",format:n,message:`Diagram "${r}" has no stored ${n} artifact.`,hint:"Edit the diagram to rebuild its local artifacts."});if("detached"===i.authority)return{_tag:"RenderPng",excalidraw:yield*e.readBytes((0,rR.join)(ap(t.path,r),ah("excalidraw")))};for(let e of["scene","excalidraw"])if(!i.manifest.formats.includes(e))return yield*nL.make({code:"format_unavailable",format:e,message:`Diagram "${r}" has no stored ${e} artifact.`,hint:"Edit the diagram to rebuild its local artifacts."});let[a,s]=yield*B.Q7R([e.readBytes((0,rR.join)(ap(t.path,r),ah("scene"))),e.readBytes((0,rR.join)(ap(t.path,r),ah("excalidraw")))]);return{_tag:"RenderPng",scene:a,excalidraw:s}}),!0)})}})),ay=B.fn("sketchi.cli.export.writeFile")(function*(e,t){let r=yield*it,n=yield*i3,i=(0,rR.resolve)(e),a=(0,rR.dirname)(i),s=()=>nL.make({code:"export_write_failed",format:(0,rR.basename)(e),message:`Export destination directory does not exist: ${a}.`,hint:"Create the destination directory and retry."}),o=yield*r.realPath(a).pipe(B.xm_(s));if((yield*r.kind(o))!=="directory")return yield*s();let l=yield*r.realPath(n.path),d=(0,rR.join)(o,(0,rR.basename)(i)),c=(0,rR.relative)(l,d);if(""===c||!(".."===c||c.startsWith(".."+rR.sep)||(0,rR.isAbsolute)(c)))return yield*nL.make({code:"invalid_destination",format:(0,rR.basename)(e),message:`Export destination is inside Sketchi's diagram storage: ${e}.`,hint:"Choose a destination outside ~/.sketchi/diagrams so the stored record remains valid."});let u=(0,rR.join)(o,`.${(0,rR.basename)(e)}.sketchi.${String(process.pid)}.${crypto.randomUUID()}`);return yield*B.jGc(B.PyW(u),n=>r.writeBytes(n,t).pipe(B.hgn(r.rename(n,d)),B.xm_(()=>nL.make({code:"export_write_failed",format:(0,rR.basename)(e),message:`Unable to write export destination ${e}.`,hint:"Check the destination path and permissions, then retry."}))),e=>r.remove(e))}),av="90 seconds",ab=B.fn("sketchi.cli.response.readBoundedBody")(function*(e,t,r,n=r){let i,a=e.body,s=Number(e.headers.get("content-length"));if(Number.isFinite(s)&&s>t)return a&&(yield*B.$mh({try:()=>a.cancel(),catch:r}).pipe(B.XeO)),yield*B.fJG(r());if(!a)return new Uint8Array;let o=yield*tw((i={evaluate:()=>a,onError:n},e3((e,t)=>{var r;let n,a,s;return n=(r={scope:t,readable:i.evaluate(),onError:i.onError,releaseLockOnEnd:i.releaseLockOnEnd}).readable.getReader(),a=r.exit??ef(void 0),s=B.DYE(()=>a.current?a.current:B.khu(B.$mh({try:()=>n.read(),catch:r.onError}),{onFailure:e=>a.current??B.ATB(e),onSuccess:({done:e,value:t})=>a.current?a.current:e?F.Vw():B.PyW(K.of(t))})),B.as(e0.U9(r.scope,r.releaseLockOnEnd?B.OH5(()=>n.releaseLock()):B.ivC(()=>n.cancel().catch(z.Yi))),s)}))).pipe(tN(()=>({chunks:[],size:0}),(e,n)=>{let i=e.size+n.byteLength;return i>t?B.fJG(r()):(e.chunks.push(n),B.PyW({chunks:e.chunks,size:i}))})),l=new Uint8Array(o.size),d=0;for(let e of o.chunks)l.set(e,d),d+=e.byteLength;return l}),a_=B.fn("sketchi.cli.response.readBoundedText")(function*(e,t,r,n=r){let i=yield*ab(e,t,r,n);return yield*B.SvU({try:()=>new TextDecoder("utf-8",{fatal:!0}).decode(i),catch:r})}),ax="https://playground.sketchi.app/api/v1/canvases/create",aw="SKETCHI_CANVAS_ENDPOINT",ak=nX.ID();function aS(e){return ak(e.issue).issues.map(e=>{let t=(e.path??[]).map(e=>"object"==typeof e&&null!==e&&"key"in e?String(e.key):String(e)).join(".");return`${t||"spec"}: ${e.message}`})}let aI=nx._Re(nM.y1,{errors:"all"}),a$=nx._Re(nM.JH,{errors:"all"}),aE=B.fn("sketchi.cli.canvas.parseSpec")(function*(e){let t=yield*B.SvU({try:()=>JSON.parse(e),catch:()=>nN.make({code:"invalid_json",message:"The CanvasSpec input is not valid JSON.",hint:"Pass one complete CanvasSpec JSON object."})});return yield*aI(t).pipe(B.xm_(e=>nP.make({message:"The CanvasSpec document is invalid.",hint:"Use the version 1 CanvasSpec contract documented by sketchi docs.",details:aS(e)})))}),aO=B.fn("sketchi.cli.canvas.readSpecInput")(function*(e){let t=yield*ih,r=yield*t.read(e,{content:"CanvasSpec document"});return yield*aE(r)});function aC(){return nD.make({code:"network_failure",message:"The Sketchi create-canvas API could not be reached.",hint:"Check the network connection and endpoint, then retry.",details:["transport"]})}function aT(e=[]){return nD.make({code:"malformed_response",message:"The Sketchi create-canvas API returned an unreadable response.",hint:"Retry once; if the response remains invalid, report the endpoint.",details:e})}function aM(e){return nD.make({code:"endpoint_failure",message:`The Sketchi create-canvas API responded with HTTP ${String(e)}.`,hint:"Check the endpoint and retry.",details:[`http_status:${String(e)}`]})}let aA=B.fn("sketchi.cli.canvas.request")(function*(e){var t,r,n,i,a,s;let o=yield*B.$mh({try:t=>globalThis.fetch(e.endpoint,{method:"POST",headers:{"content-type":"application/json","x-sketchi-client":"sketchi-cli"},body:JSON.stringify({spec:e.spec,options:{artifactFormats:["scene","excalidraw"],inlineArtifacts:["excalidraw"]}}),signal:t}),catch:aC}),l=yield*a_(o,0x1000000,aT,aC),d=yield*B.SvU({try:()=>JSON.parse(l),catch:()=>aT()}),c=yield*a$(d).pipe(B.xm_(e=>o.ok?aT(aS(e)):aM(o.status)));if(!c.ok)switch(c.status){case"export_failed":case"render_failed":case"storage_failed":return yield*(t=c.status,r=o.status,n=c.issues,nD.make({code:"endpoint_failure",message:`The Sketchi create-canvas API failed with status ${t}.`,hint:"Retry once; if the failure persists, report the endpoint and status.",details:[`status:${t}`,`http_status:${String(r)}`,...n.map(e=>`${e.code}: ${e.message}`)]}));case"invalid_canvas":case"invalid_input":case"limit_exceeded":let u;return yield*(i=c.status,a=o.status,u=(s=c.issues)[0],nD.make({code:"canvas_rejected",message:u?.message??"The create-canvas API rejected the CanvasSpec.",hint:"Correct the reported CanvasSpec issue and retry.",details:[`status:${i}`,`http_status:${String(a)}`,...s.map(e=>`${e.code}: ${e.message}`)]}))}return o.ok?c:yield*aM(o.status)},B.mgX({duration:av,orElse:()=>B.fJG(nD.make({code:"canvas_timeout",message:"The Sketchi canvas API request timed out.",hint:"Retry once; if it persists, check the endpoint and try a smaller canvas.",details:[]}))})),aN=B.fn("sketchi.cli.canvas.create")(function*(e){let t=yield*i6;yield*n9(e.spec.diagramId).pipe(B.xm_(e=>nP.make({message:e.message,hint:e.hint,details:["spec.diagramId"]})));let r=yield*aA(e);if(r.normalizedSpec.diagramId!==e.spec.diagramId)return yield*aT(["normalizedSpec.diagramId does not match submitted spec.diagramId"]);let n=r.artifact.formats.find(e=>"excalidraw"===e.format);if(n?.inline===void 0)return yield*aT(["artifact.formats.excalidraw.inline"]);let i=nM.yE.safeParse(n.inline);if(!i.success)return yield*aT(i.error.issues.map(e=>`${e.path.join(".")}: ${e.message}`));let a=yield*n9(r.normalizedSpec.diagramId).pipe(B.xm_(()=>aT(["normalizedSpec.diagramId is not storage-safe"])));if(r.artifact.diagramId!==a)return yield*aT(["artifact.diagramId does not match normalizedSpec.diagramId"]);let s={id:a,type:"canvas",title:r.normalizedSpec.title,document:{type:"canvas",spec:r.normalizedSpec},scene:r.normalizedSpec,excalidraw:i.data},o=yield*t.create(s);return{artifactId:r.artifact.artifactId,diagram:o}});var aP=n(1688);class aR extends Z.kl()("@sketchi/cli/CliPngRenderer"){}let aj=G.Py(aR,{renderPng:function(e){return B.$mh({try:async()=>(await Promise.all([n.e(548),n.e(869)]).then(n.bind(n,7665))).renderPngBytes(e),catch:e=>e instanceof aP.FG?e:aP.FG.make({cause:e,code:"rasterization_failed",stage:"rasterization",message:"Unable to rasterize the stored diagram as PNG.",details:[]})})},normalizeExcalidraw:function(e){return B.$mh({try:async()=>(await Promise.all([n.e(548),n.e(869)]).then(n.bind(n,7665))).normalizeExcalidrawArtifact(e),catch:e=>e instanceof aP.FG?e:aP.FG.make({cause:e,code:"invalid_render_artifact",stage:"artifact",message:"Unable to restore the Excalidraw share artifact.",details:[]})})}});class aD extends Z.kl()("@sketchi/cli/DiagramExporter"){}function aU(e,t){let r=`sketchi export ${e} --format png --dest ${e}.png`;return nL.make({code:t?.code??"invalid_render_artifact",format:"png",diagramId:e,storagePath:`~/.sketchi/diagrams/${e}`,recoveryCommand:r,message:t?.message??"Unable to read the stored PNG source artifacts.",hint:`The canonical record is preserved. Retry with: ${r}`,details:t?[`stage:${t.stage}`,...t.details]:["stage:artifact"]})}function aF(e,t){return B.SvU({try:()=>JSON.parse(new TextDecoder().decode(t)),catch:()=>aU(e)})}let aB=G.QZ(aD,B.JkU(function*(){let e=yield*i6,t=yield*aR,r=B.fn("sketchi.cli.export.renderPng")(function*(e,r){let n=[{format:"excalidraw",inline:yield*aF(e,r.excalidraw)}];r.scene&&n.unshift({format:"scene",inline:yield*aF(e,r.scene)});let i=yield*nY({formats:n},"export").pipe(B.xm_(()=>aU(e)));return yield*t.renderPng({...i}).pipe(B.xm_(t=>aU(e,t)))});return{exportArtifact:B.fn("sketchi.cli.export.artifact")(function*(t,n){let i=yield*e.readExportSource(t,n);return"StoredArtifact"===i._tag?i.bytes:yield*r(t,i)})}})),aL="gemini-3.1-flash-lite",az="https://playground.sketchi.app/api/v1/generate",aW="SKETCHI_GENERATE_ENDPOINT";function aJ(){return nj.make({code:"provider_failure",message:"The Sketchi generate API could not be reached.",hint:"Check your network connection and retry. create/show/edit/list/export/restore remain offline; share and pull are separate explicit network commands.",details:["transport"]})}function aY(){return nj.make({code:"malformed_output",message:"The Sketchi generate API returned an unreadable response.",hint:"Retry once; if it persists, report the prompt without secrets.",details:[]})}function aX(){return nj.make({code:"invalid_generated_document",message:"The generated diagram failed Sketchi schema or semantic validation.",hint:"Refine the prompt with concrete diagram content, then retry.",details:[]})}let aq=nx._kM({status:nx.Qrq(nx.QfV),issues:nx.Qrq(nx.O31(nx._kM({message:nx.Qrq(nx.QfV),hint:nx.Qrq(nx.QfV)})))}),aG=nx._Re(nx.mj7(aq)),aV=nx.$r1.check(nx.HNH(e=>void 0!==e)),aH=nx._kM({ok:nx.uSQ(!0),diagram:nx._kM({document:aV,scene:aV,excalidraw:aV}),generation:nx._kM({model:nx.ukk,provider:nx.ukk})}),aK=nx._Re(nx.mj7(aH)),aQ=B.fn("sketchi.cli.generate.request")(function*(e){let t=yield*B.$mh({try:t=>globalThis.fetch(e.endpoint,{method:"POST",headers:{"content-type":"application/json","x-sketchi-client":"sketchi-cli"},body:JSON.stringify({prompt:e.prompt,...e.type?{type:e.type}:{},model:e.model}),signal:t}),catch:()=>aJ()}),r=yield*a_(t,0x1000000,aY,aJ);if(!t.ok){let e=yield*aG(r).pipe(B.xm_(aY));return yield*function(e,t){let r=t.issues?.[0],n=[`http_status:${String(e)}`,...(t.issues??[]).flatMap(e=>[...e.message?[e.message]:[],...e.hint?[e.hint]:[]])];switch(t.status){case"generation_timeout":return nj.make({code:"generation_timeout",message:r?.message??"The generate API timed out.",hint:r?.hint??"Retry once; if it persists, try a shorter prompt.",details:n});case"malformed_output":return nj.make({code:"malformed_output",message:r?.message??"The generate API returned unreadable model output.",hint:r?.hint??"Retry once; if it persists, try another prompt.",details:n});case"invalid_input":case"invalid_generated_document":case"quality_failed":return nj.make({code:"invalid_generated_document",message:r?.message??"The generated diagram failed Sketchi validation.",hint:r?.hint??"Refine the prompt with concrete content, then retry.",details:n});case"unsupported_diagram_type":return nj.make({code:"unsupported_diagram_type",message:r?.message??"Sketchi does not natively support the requested diagram type.",hint:r?.hint??"Request a flowchart, mindmap, or sequence diagram instead.",details:n});default:return nj.make({code:"provider_failure",message:r?.message??`The Sketchi generate API responded with HTTP ${String(e)}.`,hint:r?.hint??"Retry once; if it persists, report the prompt without secrets.",details:n})}}(t.status,e)}let n=yield*aK(r).pipe(B.xm_(aY));return{...n.diagram,...n.generation}},B.mgX({duration:av,orElse:()=>B.fJG(nj.make({code:"generation_timeout",message:"The Sketchi generate API request timed out.",hint:"Retry once; if it persists, try a shorter prompt.",details:[]}))})),aZ=B.fn("sketchi.cli.generate")(function*(e){var t,r;let n,i,a=yield*i6,s=yield*aQ(e),o=yield*n2(s.document).pipe(B.xm_(()=>aX())),l=yield*n9(n8(o)).pipe(B.xm_(()=>aX())),d=yield*(t=s.scene,(n=nM.Uh.safeParse(t)).success?B.PyW(n.data):B.fJG(aY())),c=yield*(r=s.excalidraw,(i=nM.yE.safeParse(r)).success?B.PyW(i.data):B.fJG(aY())),u={id:l,type:o.type,title:o.spec.title,document:o,scene:d,excalidraw:c};return{diagram:yield*a.create(u),model:s.model,provider:s.provider}});function a0(e,t){switch(t){case"png":return`${e}.png`;case"excalidraw":return`${e}.excalidraw`;case"scene":return`${e}.scene.json`}}let a1=B.fn("sketchi.cli.exportCreatedDiagram")(function*(e,t,r){let n=yield*aD,i=e.manifest.id,a=function(e,t,r){switch(r._tag){case"Default":return a0(e,t);case"CurrentDirectory":return(0,rR.resolve)(r.cwd,a0(e,"png"));case"ProjectDiagrams":return(0,rR.resolve)(r.cwd,"diagrams",a0(e,"png"));case"Custom":return r.path}}(i,t,r),s=yield*n.exportArtifact(i,t).pipe(B.xm_(e=>a2(e,i,t)));return yield*B.JkU(function*(){if("-"!==a){if("ProjectDiagrams"===r._tag){let e=yield*it;yield*e.makeDirectory((0,rR.join)(r.cwd,"diagrams"),!0)}yield*ay(a,s)}}).pipe(B.xm_(e=>a2(e,i,t))),{id:i,format:t,destination:a,sizeBytes:s.byteLength,..."-"===a?{stdoutBytes:s}:{}}});function a2(e,t,r){let n=a0(t,r),i=`sketchi export ${t} --format ${r} --dest ${n}`,a="CliExportError"===e._tag?e.details:"CliStorageError"===e._tag?[`storage_error:${e.code}`]:[`filesystem_operation:${e.operation}`,`path:${e.path}`];return nL.make({code:"CliExportError"===e._tag?e.code:"CliStorageError"===e._tag?"invalid_render_artifact":"export_write_failed",diagramId:t,storagePath:`~/.sketchi/diagrams/${t}`,recoveryCommand:i,...a?{details:a}:{},format:r,message:e.message,hint:`The local record is preserved. Retry with: ${i}`})}let a5=B.fn("sketchi.cli.generateWorkflow")(function*(e){let t=yield*aZ(e),r=yield*a1(t.diagram,e.format,e.destination);return{generated:t,artifact:r}}),a3=t("node:util"),a6=t("node:process"),a8=(A=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,e=>{let t=0;for(A.lastIndex=0;A.test(e);)t+=1;return e.length-t}),a9=e=>12288===e||e>=65281&&e<=65376||e>=65504&&e<=65510,a4=e=>8987===e||9001===e||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e>=131072&&e<=196605||e>=196608&&e<=262141,a7=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,se=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,st=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,sr=/\t{1,1000}/y,sn=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu,si=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,sa=/\p{M}+/gu,ss={limit:1/0,ellipsis:""},so=(e,t={},r={})=>{let n=t.limit??1/0,i=t.ellipsis??"",a=t?.ellipsisWidth??(i?so(i,ss,r).width:0),s=r.controlWidth??0,o=r.tabWidth??8,l=r.emojiWidth??2,d=r.regularWidth??1,c=r.wideWidth??2,u=[[si,d],[a7,0],[se,s],[sr,o],[sn,l],[st,c]],f=0,p=0,h=e.length,m=0,g=!1,y=h,v=Math.max(0,n-a),b=0,_=0,x=0,w=0;e:for(;;){if(_>b||p>=h&&p>f){for(let t of(m=0,(e.slice(b,_)||e.slice(f,p)).replaceAll(sa,""))){let e=t.codePointAt(0)||0;if(x+(w=a9(e)?2:a4(e)?c:d)>v&&(y=Math.min(y,Math.max(b,f)+m)),x+w>n){g=!0;break e}m+=t.length,x+=w}b=_=0}if(p>=h)break;for(let t=0,r=u.length;t<r;t++){let[r,i]=u[t];if(r.lastIndex=p,r.test(e)){if(x+(w=(m=r===st?a8(e.slice(p,r.lastIndex)):r===sn?1:r.lastIndex-p)*i)>v&&(y=Math.min(y,p+Math.floor((v-x)/i))),x+w>n){g=!0;break e}x+=w,b=f,_=p,p=f=r.lastIndex;continue e}}p+=1}return{width:g?v:x,index:g?y:h,truncated:g,ellipsed:g&&n>=a}},sl={limit:1/0,ellipsis:"",ellipsisWidth:0},sd=(e,t={})=>so(e,sl,t).width,sc="]8;;",su=RegExp(`(?:\\[(?<code>\\d+)m|\\${sc}(?<uri>.*)\x07)`,"y"),sf=e=>e>=30&&e<=37||e>=90&&e<=97?39:e>=40&&e<=47||e>=100&&e<=107?49:1===e||2===e?22:3===e?23:4===e?24:7===e?27:8===e?28:9===e?29:0===e?0:void 0,sp=e=>`\x1b[${e}m`,sh=e=>`\x1b${sc}${e}\x07`,sm=(e,t,r)=>{let n=t[Symbol.iterator](),i=!1,a=!1,s=e.at(-1),o=void 0===s?0:sd(s),l=n.next(),d=n.next(),c=0;for(;!l.done;){let s=l.value,u=sd(s);o+u<=r?e[e.length-1]+=s:(e.push(s),o=0),("\x1b"===s||"›"===s)&&(i=!0,a=t.startsWith(sc,c+1)),i?a?"\x07"===s&&(i=!1,a=!1):"m"===s&&(i=!1):(o+=u)!==r||d.done||(e.push(""),o=0),l=d,d=n.next(),c+=s.length}s=e.at(-1),!o&&void 0!==s&&s.length&&e.length>1&&(e[e.length-2]+=e.pop())},sg=/\r?\n/;function sy(e,t,r){return String(e).normalize().split(sg).map(e=>((e,t,r={})=>{let n,i;if(!1!==r.trim&&""===e.trim())return"";let a="",s=e.split(" "),o=[""],l=0;for(let e=0;e<s.length;e++){let n=s[e];if(!1!==r.trim){let e=o.at(-1)??"",t=e.trimStart();e.length!==t.length&&(o[o.length-1]=t,l=sd(t))}0!==e&&(l>=t&&(!1===r.wordWrap||!1===r.trim)&&(o.push(""),l=0),(l||!1===r.trim)&&(o[o.length-1]+=" ",l++));let i=sd(n);if(r.hard&&i>t){let e=1+Math.floor((i-(t-l)-1)/t);Math.floor((i-1)/t)<e&&o.push(""),sm(o,n,t),l=sd(o.at(-1)??"");continue}if(l+i>t&&l&&i){if(!1===r.wordWrap&&l<t){sm(o,n,t),l=sd(o.at(-1)??"");continue}o.push(""),l=0}if(l+i>t&&!1===r.wordWrap){sm(o,n,t),l=sd(o.at(-1)??"");continue}o[o.length-1]+=n,l+=i}!1!==r.trim&&(o=o.map(e=>(e=>{let t=e.split(" "),r=t.length;for(;r&&!sd(t[r-1]);)r--;return r===t.length?e:t.slice(0,r).join(" ")+t.slice(r).join("")})(e)));let d=o.join("\n"),c=!1;for(let e=0;e<d.length;e++){let t=d[e];if(a+=t,c)c=!1;else if(c=t>="\uD800"&&t<="\uDBFF")continue;if("\x1b"===t||"›"===t){su.lastIndex=e+1;let t=su.exec(d),r=t?.groups;if(r?.code!==void 0){let e=Number.parseFloat(r.code);n=39===e?void 0:e}else r?.uri!==void 0&&(i=0===r.uri.length?void 0:r.uri)}if("\n"===d[e+1]){i&&(a+=sh(""));let e=n?sf(n):void 0;n&&e&&(a+=sp(e))}else"\n"===t&&(n&&sf(n)&&(a+=sp(n)),i&&(a+=sh(i)))}return a})(e,t,r)).join("\n")}var sv=n(5776);let sb=t("node:tty");function s_(e,t,r){if(!r.some(e=>!e.disabled))return e;let n=e+t,i=Math.max(r.length-1,0),a=n<0?i:n>i?0:n;return r[a]?.disabled?s_(a,t<0?-1:1,r):a}let sx={actions:new Set(["up","down","left","right","space","enter","cancel"]),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["\x03","cancel"],["escape","cancel"]]),messages:{cancel:"Canceled",error:"Something went wrong"},withGuide:!0,accessible:void 0,date:{monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],messages:{required:"Please enter a valid date",invalidMonth:"There are only 12 months in a year",invalidDay:(e,t)=>`There are only ${e} days in ${t}`,afterMin:e=>`Date must be on or after ${e.toISOString().slice(0,10)}`,beforeMax:e=>`Date must be on or before ${e.toISOString().slice(0,10)}`}}};function sw(e,t){if("string"==typeof e)return sx.aliases.get(e)===t;for(let r of e)if(void 0!==r&&sw(r,t))return!0;return!1}let sk=globalThis.process.platform.startsWith("win"),sS=Symbol("clack:cancel");function sI(e,t){e.isTTY&&e.setRawMode(t)}let s$=e=>"columns"in e&&"number"==typeof e.columns?e.columns:80,sE=e=>"rows"in e&&"number"==typeof e.rows?e.rows:20;function sO(e,t,r,n=r,i=r,a){return sy(t,s$(e??a6.stdout)-r.length,{hard:!0,trim:!1}).split(`
4
4
  `).map((e,t,s)=>{let o=a?a(e,t):e;return 0===t?`${n}${o}`:t===s.length-1?`${i}${o}`:`${r}${o}`}).join(`
5
- `)}class sC{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame="";_subscribers=new Map;_cursor=0;state="initial";error="";value;userInput="";get accessible(){var e=this.opts.accessible;if(void 0!==e)return e;if(void 0!==sx.accessible)return sx.accessible;let t=process.env.ACCESSIBLE;return void 0!==t&&""!==t&&"0"!==t&&"false"!==t}constructor(e,t=!0){let{input:r=a6.stdin,output:n=a6.stdout,render:i,signal:a,...s}=e;this.opts=s,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=i.bind(this),this._track=t,this._abortSignal=a,this.input=r,this.output=n}unsubscribe(){this._subscribers.clear()}setSubscriber(e,t){let r=this._subscribers.get(e)??[];r.push(t),this._subscribers.set(e,r)}on(e,t){this.setSubscriber(e,{cb:t})}once(e,t){this.setSubscriber(e,{cb:t,once:!0})}emit(e,...t){let r=this._subscribers.get(e)??[],n=[];for(let e of r)e.cb(...t),e.once&&n.push(()=>r.splice(r.indexOf(e),1));for(let e of n)e()}prompt(){return new Promise(e=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),e(sS);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}this.rl=nE.createInterface({input:this.input,tabSize:2,prompt:"",escapeCodeTimeout:50,terminal:!0}),this.rl.prompt(),void 0!==this.opts.initialUserInput&&this._setUserInput(this.opts.initialUserInput,!0),this.input.on("keypress",this.onKeypress),sI(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(sb.cursor.show),this.output.off("resize",this.render),sI(this.input,!1),e(this.value)}),this.once("cancel",()=>{this.output.write(sb.cursor.show),this.output.off("resize",this.render),sI(this.input,!1),e(sS)})})}_isActionKey(e,t){return" "===e}_shouldSubmit(e,t){return!0}_setValue(e){this.value=e,this.emit("value",this.value)}_setUserInput(e,t){this.userInput=e??"",this.emit("userInput",this.userInput),t&&this._track&&this.rl&&(this.rl.write(this.userInput),this._cursor=this.rl.cursor)}_clearUserInput(){this.rl?.write(null,{ctrl:!0,name:"u"}),this._setUserInput("")}async onKeypress(e,t){if("validating"!==this.state){if(this._track&&"return"!==t.name&&(t.name&&this._isActionKey(e,t)&&this.rl?.write(null,{ctrl:!0,name:"h"}),this._cursor=this.rl?.cursor??0,this._setUserInput(this.rl?.line)),"error"===this.state&&(this.state="active"),t?.name&&(!this._track&&sx.aliases.has(t.name)&&this.emit("cursor",sx.aliases.get(t.name)),sx.actions.has(t.name)&&this.emit("cursor",t.name)),e&&("y"===e.toLowerCase()||"n"===e.toLowerCase())&&this.emit("confirm","y"===e.toLowerCase()),this.emit("key",e,t),t?.name==="return"&&this._shouldSubmit(e,t)){if(this.opts.validate){let e,t=function(e,t){if("~standard"in e){let r=e["~standard"].validate(t);return r instanceof Promise?r.then(e=>e.issues?.at(0)?.message):r.issues?.at(0)?.message}return e(t)}(this.opts.validate,this.value);t instanceof Promise?(this.state="validating",this.render(),e=await t):e=t,e&&(this.error=e instanceof Error?e.message:e,this.state="error",this.rl?.write(this.userInput))}"error"!==this.state&&(this.state="submit")}sw([e,t?.name,t?.sequence],"cancel")&&(this.state="cancel"),("submit"===this.state||"cancel"===this.state)&&this.emit("finalize"),this.render(),("submit"===this.state||"cancel"===this.state)&&this.close()}}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(`
5
+ `)}class sC{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame="";_subscribers=new Map;_cursor=0;state="initial";error="";value;userInput="";get accessible(){var e=this.opts.accessible;if(void 0!==e)return e;if(void 0!==sx.accessible)return sx.accessible;let t=process.env.ACCESSIBLE;return void 0!==t&&""!==t&&"0"!==t&&"false"!==t}constructor(e,t=!0){let{input:r=a6.stdin,output:n=a6.stdout,render:i,signal:a,...s}=e;this.opts=s,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=i.bind(this),this._track=t,this._abortSignal=a,this.input=r,this.output=n}unsubscribe(){this._subscribers.clear()}setSubscriber(e,t){let r=this._subscribers.get(e)??[];r.push(t),this._subscribers.set(e,r)}on(e,t){this.setSubscriber(e,{cb:t})}once(e,t){this.setSubscriber(e,{cb:t,once:!0})}emit(e,...t){let r=this._subscribers.get(e)??[],n=[];for(let e of r)e.cb(...t),e.once&&n.push(()=>r.splice(r.indexOf(e),1));for(let e of n)e()}prompt(){return new Promise(e=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),e(sS);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}this.rl=n$.createInterface({input:this.input,tabSize:2,prompt:"",escapeCodeTimeout:50,terminal:!0}),this.rl.prompt(),void 0!==this.opts.initialUserInput&&this._setUserInput(this.opts.initialUserInput,!0),this.input.on("keypress",this.onKeypress),sI(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(sv.cursor.show),this.output.off("resize",this.render),sI(this.input,!1),e(this.value)}),this.once("cancel",()=>{this.output.write(sv.cursor.show),this.output.off("resize",this.render),sI(this.input,!1),e(sS)})})}_isActionKey(e,t){return" "===e}_shouldSubmit(e,t){return!0}_setValue(e){this.value=e,this.emit("value",this.value)}_setUserInput(e,t){this.userInput=e??"",this.emit("userInput",this.userInput),t&&this._track&&this.rl&&(this.rl.write(this.userInput),this._cursor=this.rl.cursor)}_clearUserInput(){this.rl?.write(null,{ctrl:!0,name:"u"}),this._setUserInput("")}async onKeypress(e,t){if("validating"!==this.state){if(this._track&&"return"!==t.name&&(t.name&&this._isActionKey(e,t)&&this.rl?.write(null,{ctrl:!0,name:"h"}),this._cursor=this.rl?.cursor??0,this._setUserInput(this.rl?.line)),"error"===this.state&&(this.state="active"),t?.name&&(!this._track&&sx.aliases.has(t.name)&&this.emit("cursor",sx.aliases.get(t.name)),sx.actions.has(t.name)&&this.emit("cursor",t.name)),e&&("y"===e.toLowerCase()||"n"===e.toLowerCase())&&this.emit("confirm","y"===e.toLowerCase()),this.emit("key",e,t),t?.name==="return"&&this._shouldSubmit(e,t)){if(this.opts.validate){let e,t=function(e,t){if("~standard"in e){let r=e["~standard"].validate(t);return r instanceof Promise?r.then(e=>e.issues?.at(0)?.message):r.issues?.at(0)?.message}return e(t)}(this.opts.validate,this.value);t instanceof Promise?(this.state="validating",this.render(),e=await t):e=t,e&&(this.error=e instanceof Error?e.message:e,this.state="error",this.rl?.write(this.userInput))}"error"!==this.state&&(this.state="submit")}sw([e,t?.name,t?.sequence],"cancel")&&(this.state="cancel"),("submit"===this.state||"cancel"===this.state)&&this.emit("finalize"),this.render(),("submit"===this.state||"cancel"===this.state)&&this.close()}}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(`
6
6
  `),sI(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let e=sy(this._prevFrame,process.stdout.columns,{hard:!0,trim:!1}).split(`
7
- `).length-1;this.output.write(sb.cursor.move(-999,-1*e))}render(){let e=sy(this._render(this)??"",process.stdout.columns,{hard:!0,trim:!1});if(e!==this._prevFrame){if("initial"===this.state)this.output.write(sb.cursor.hide);else{let t=function(e,t){if(e===t)return;let r=e.split(`
7
+ `).length-1;this.output.write(sv.cursor.move(-999,-1*e))}render(){let e=sy(this._render(this)??"",process.stdout.columns,{hard:!0,trim:!1});if(e!==this._prevFrame){if("initial"===this.state)this.output.write(sv.cursor.hide);else{let t=function(e,t){if(e===t)return;let r=e.split(`
8
8
  `),n=t.split(`
9
- `),i=Math.max(r.length,n.length),a=[];for(let e=0;e<i;e++)r[e]!==n[e]&&a.push(e);return{lines:a,numLinesBefore:r.length,numLinesAfter:n.length,numLines:i}}(this._prevFrame,e),r=sE(this.output);if(this.restoreCursor(),t){let n=Math.max(0,t.numLinesAfter-r),i=Math.max(0,t.numLinesBefore-r),a=t.lines.find(e=>e>=n);if(void 0===a){this._prevFrame=e;return}if(1===t.lines.length){this.output.write(sb.cursor.move(0,a-i)),this.output.write(sb.erase.lines(1));let t=e.split(`
10
- `);this.output.write(t[a]),this._prevFrame=e,this.output.write(sb.cursor.move(0,t.length-a-1));return}if(t.lines.length>1){if(n<i)a=n;else{let e=a-i;e>0&&this.output.write(sb.cursor.move(0,e))}this.output.write(sb.erase.down());let t=e.split(`
9
+ `),i=Math.max(r.length,n.length),a=[];for(let e=0;e<i;e++)r[e]!==n[e]&&a.push(e);return{lines:a,numLinesBefore:r.length,numLinesAfter:n.length,numLines:i}}(this._prevFrame,e),r=sE(this.output);if(this.restoreCursor(),t){let n=Math.max(0,t.numLinesAfter-r),i=Math.max(0,t.numLinesBefore-r),a=t.lines.find(e=>e>=n);if(void 0===a){this._prevFrame=e;return}if(1===t.lines.length){this.output.write(sv.cursor.move(0,a-i)),this.output.write(sv.erase.lines(1));let t=e.split(`
10
+ `);this.output.write(t[a]),this._prevFrame=e,this.output.write(sv.cursor.move(0,t.length-a-1));return}if(t.lines.length>1){if(n<i)a=n;else{let e=a-i;e>0&&this.output.write(sv.cursor.move(0,e))}this.output.write(sv.erase.down());let t=e.split(`
11
11
  `).slice(a);this.output.write(t.join(`
12
- `)),this._prevFrame=e;return}}this.output.write(sb.erase.down())}this.output.write(e),"initial"===this.state&&(this.state="active"),this._prevFrame=e}}}let sT=class extends sC{options;cursor=0;get _selectedValue(){return this.options[this.cursor]}changeValue(){let e=this._selectedValue;this.value=void 0===e?void 0:e.value}constructor(e){super(e,!1),this.options=e.options;let t=this.options.findIndex(({value:t})=>t===e.initialValue),r=-1===t?0:t;this.cursor=this.options[r]?.disabled?s_(r,1,this.options):r,this.changeValue(),this.on("cursor",e=>{switch(e){case"left":case"up":this.cursor=s_(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=s_(this.cursor,1,this.options)}this.changeValue()})}};class sM extends sC{get userInputWithCursor(){if("submit"===this.state)return this.userInput;let e=this.userInput;if(this.cursor>=e.length)return`${this.userInput}█`;let t=e.slice(0,this.cursor),r=e.slice(this.cursor,this.cursor+1),n=e.slice(this.cursor+1);return`${t}${(0,a3.styleText)("inverse",r)}${n}`}get cursor(){return this._cursor}constructor(e){super({...e,initialUserInput:e.initialUserInput??e.initialValue}),this.on("userInput",e=>{this._setValue(e)}),this.on("finalize",()=>{this.value||(this.value=e.defaultValue),void 0===this.value&&(this.value="")})}}let sP="win32"!==a6.platform?"linux"!==a6.env.TERM:!!a6.env.CI||!!a6.env.WT_SESSION||!!a6.env.TERMINUS_SUBLIME||"{cmd::Cmder}"===a6.env.ConEmuTask||"Terminus-Sublime"===a6.env.TERM_PROGRAM||"vscode"===a6.env.TERM_PROGRAM||"xterm-256color"===a6.env.TERM||"alacritty"===a6.env.TERM||"JetBrains-JediTerm"===a6.env.TERMINAL_EMULATOR,sA=(e,t)=>sP?e:t,sN=sA("◆","*"),sR=sA("■","x"),sj=sA("▲","x"),sD=sA("◇","o"),sU=sA("┌","T"),sF=sA("│","|"),sB=sA("└","—"),sL=sA("●",">"),sz=sA("○"," "),sW=e=>{switch(e){case"initial":case"active":return(0,a3.styleText)("cyan",sN);case"cancel":return(0,a3.styleText)("red",sR);case"error":return(0,a3.styleText)("yellow",sj);case"submit":return(0,a3.styleText)("green",sD);case"validating":return(0,a3.styleText)("dim",sN)}},sJ=(e,t,r,n,i,a=!1)=>{let s=t,o=0;if(a)for(let t=n-1;t>=r;t--){let r=e[t];if(r&&(s-=r.length),o++,s<=i)break}else for(let t=r;t<n;t++){let r=e[t];if(r&&(s-=r.length),o++,s<=i)break}return{lineCount:s,removals:o}};(0,a3.styleText)("dim","↑/↓"),(0,a3.styleText)("dim","Space:"),(0,a3.styleText)("dim","Enter:");let sY=e=>(0,a3.styleText)("magenta",e);sA("─","-"),sA("━","="),sA("█","#");let sX=[`${(0,a3.styleText)("dim","↑/↓")} to navigate`,`${(0,a3.styleText)("dim","Enter:")} confirm`],sq=(e,t)=>e.includes(`
12
+ `)),this._prevFrame=e;return}}this.output.write(sv.erase.down())}this.output.write(e),"initial"===this.state&&(this.state="active"),this._prevFrame=e}}}let sT=class extends sC{options;cursor=0;get _selectedValue(){return this.options[this.cursor]}changeValue(){let e=this._selectedValue;this.value=void 0===e?void 0:e.value}constructor(e){super(e,!1),this.options=e.options;let t=this.options.findIndex(({value:t})=>t===e.initialValue),r=-1===t?0:t;this.cursor=this.options[r]?.disabled?s_(r,1,this.options):r,this.changeValue(),this.on("cursor",e=>{switch(e){case"left":case"up":this.cursor=s_(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=s_(this.cursor,1,this.options)}this.changeValue()})}};class sM extends sC{get userInputWithCursor(){if("submit"===this.state)return this.userInput;let e=this.userInput;if(this.cursor>=e.length)return`${this.userInput}█`;let t=e.slice(0,this.cursor),r=e.slice(this.cursor,this.cursor+1),n=e.slice(this.cursor+1);return`${t}${(0,a3.styleText)("inverse",r)}${n}`}get cursor(){return this._cursor}constructor(e){super({...e,initialUserInput:e.initialUserInput??e.initialValue}),this.on("userInput",e=>{this._setValue(e)}),this.on("finalize",()=>{this.value||(this.value=e.defaultValue),void 0===this.value&&(this.value="")})}}let sA="win32"!==a6.platform?"linux"!==a6.env.TERM:!!a6.env.CI||!!a6.env.WT_SESSION||!!a6.env.TERMINUS_SUBLIME||"{cmd::Cmder}"===a6.env.ConEmuTask||"Terminus-Sublime"===a6.env.TERM_PROGRAM||"vscode"===a6.env.TERM_PROGRAM||"xterm-256color"===a6.env.TERM||"alacritty"===a6.env.TERM||"JetBrains-JediTerm"===a6.env.TERMINAL_EMULATOR,sN=(e,t)=>sA?e:t,sP=sN("◆","*"),sR=sN("■","x"),sj=sN("▲","x"),sD=sN("◇","o"),sU=sN("┌","T"),sF=sN("│","|"),sB=sN("└","—"),sL=sN("●",">"),sz=sN("○"," "),sW=e=>{switch(e){case"initial":case"active":return(0,a3.styleText)("cyan",sP);case"cancel":return(0,a3.styleText)("red",sR);case"error":return(0,a3.styleText)("yellow",sj);case"submit":return(0,a3.styleText)("green",sD);case"validating":return(0,a3.styleText)("dim",sP)}},sJ=(e,t,r,n,i,a=!1)=>{let s=t,o=0;if(a)for(let t=n-1;t>=r;t--){let r=e[t];if(r&&(s-=r.length),o++,s<=i)break}else for(let t=r;t<n;t++){let r=e[t];if(r&&(s-=r.length),o++,s<=i)break}return{lineCount:s,removals:o}};(0,a3.styleText)("dim","↑/↓"),(0,a3.styleText)("dim","Space:"),(0,a3.styleText)("dim","Enter:");let sY=e=>(0,a3.styleText)("magenta",e);sN("─","-"),sN("━","="),sN("█","#");let sX=[`${(0,a3.styleText)("dim","↑/↓")} to navigate`,`${(0,a3.styleText)("dim","Enter:")} confirm`],sq=(e,t)=>e.includes(`
13
13
  `)?e.split(`
14
14
  `).map(e=>t(e)).join(`
15
15
  `):t(e),sG=e=>{let t=(e,t)=>{if(void 0===e)return"";let r=e.label??String(e.value);switch(t){case"disabled":return`${(0,a3.styleText)("gray",sz)} ${sq(r,e=>(0,a3.styleText)("gray",e))}${e.hint?` ${(0,a3.styleText)("dim",`(${e.hint??"disabled"})`)}`:""}`;case"selected":return`${sq(r,e=>(0,a3.styleText)("dim",e))}`;case"active":return`${(0,a3.styleText)("green",sL)} ${r}${e.hint?` ${(0,a3.styleText)("dim",`(${e.hint})`)}`:""}`;case"cancelled":return`${sq(r,e=>(0,a3.styleText)(["strikethrough","dim"],e))}`;default:return`${(0,a3.styleText)("dim",sz)} ${sq(r,e=>(0,a3.styleText)("dim",e))}`}},r=e.showInstructions??!0;return new sT({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue,render(){let n=e.withGuide??sx.withGuide,i=`${sW(this.state)} `,a=`${(e=>{switch(e){case"initial":case"active":return(0,a3.styleText)("cyan",sF);case"cancel":return(0,a3.styleText)("red",sF);case"error":return(0,a3.styleText)("yellow",sF);case"submit":return(0,a3.styleText)("green",sF)}})(this.state)} `,s=sO(e.output,e.message,a,i),o=`${n?`${(0,a3.styleText)("gray",sF)}
@@ -17,8 +17,8 @@ import{createRequire as e}from"node:module";let t=e(import.meta.url);var r,n,i,a
17
17
  `;switch(this.state){case"submit":{let r=n?`${(0,a3.styleText)("gray",sF)} `:"",i=sO(e.output,t(this.options[this.cursor],"selected"),r);return`${o}${i}`}case"cancel":{let r=n?`${(0,a3.styleText)("gray",sF)} `:"",i=sO(e.output,t(this.options[this.cursor],"cancelled"),r);return`${o}${i}${n?`
18
18
  ${(0,a3.styleText)("gray",sF)}`:""}`}default:{let i,a=n?`${(0,a3.styleText)("cyan",sF)} `:"",s=o.split(`
19
19
  `).length,l=r?(i=[`${n?`${(0,a3.styleText)("cyan",sF)} `:""}${sX.join(" • ")}`],n&&i.push((0,a3.styleText)("cyan",sB)),i):n?[(0,a3.styleText)("cyan",sB)]:[],d=l.join(`
20
- `),c=l.length+1;return`${o}${a}${(({cursor:e,options:t,style:r,output:n=process.stdout,maxItems:i=1/0,columnPadding:a=0,rowPadding:s=4})=>{let o=s$(n)-a,l=sE(n),d=(0,a3.styleText)("dim","..."),c=Math.max(l-s,0),u=Math.max(Math.min(i,c),5),f=0;e>=u-3&&(f=Math.max(Math.min(e-u+3,t.length-u),0));let p=u<t.length&&f>0,h=u<t.length&&f+u<t.length,m=Math.min(f+u,t.length),g=[],y=0;p&&y++,h&&y++;let b=f+ +!!p,v=m-!!h;for(let n=b;n<v;n++){let i=t[n],a=sy(i?r(i,n===e):"",o,{hard:!0,trim:!1}).split(`
21
- `);g.push(a),y+=a.length}if(y>c){let t=0,r=0,n=y,i=e-b,a=c,s=()=>sJ(g,n,i+1,g.length,a,!0);p?({lineCount:n,removals:t}=sJ(g,n,0,i,a),n>a&&(h||(a-=1),{lineCount:n,removals:r}=s())):(h||(a-=1),{lineCount:n,removals:r}=s(),n>a&&(a-=1,{lineCount:n,removals:t}=sJ(g,n,0,i,a))),t>0&&(p=!0,g.splice(0,t)),r>0&&(h=!0,g.splice(g.length-r,r))}let _=[];for(let e of(p&&_.push(d),g))for(let t of e)_.push(t);return h&&_.push(d),_})({output:e.output,cursor:this.cursor,options:this.options,maxItems:e.maxItems,columnPadding:a.length,rowPadding:s+c,style:(e,r)=>t(e,e.disabled?"disabled":r?"active":"inactive")}).join(`
20
+ `),c=l.length+1;return`${o}${a}${(({cursor:e,options:t,style:r,output:n=process.stdout,maxItems:i=1/0,columnPadding:a=0,rowPadding:s=4})=>{let o=s$(n)-a,l=sE(n),d=(0,a3.styleText)("dim","..."),c=Math.max(l-s,0),u=Math.max(Math.min(i,c),5),f=0;e>=u-3&&(f=Math.max(Math.min(e-u+3,t.length-u),0));let p=u<t.length&&f>0,h=u<t.length&&f+u<t.length,m=Math.min(f+u,t.length),g=[],y=0;p&&y++,h&&y++;let v=f+ +!!p,b=m-!!h;for(let n=v;n<b;n++){let i=t[n],a=sy(i?r(i,n===e):"",o,{hard:!0,trim:!1}).split(`
21
+ `);g.push(a),y+=a.length}if(y>c){let t=0,r=0,n=y,i=e-v,a=c,s=()=>sJ(g,n,i+1,g.length,a,!0);p?({lineCount:n,removals:t}=sJ(g,n,0,i,a),n>a&&(h||(a-=1),{lineCount:n,removals:r}=s())):(h||(a-=1),{lineCount:n,removals:r}=s(),n>a&&(a-=1,{lineCount:n,removals:t}=sJ(g,n,0,i,a))),t>0&&(p=!0,g.splice(0,t)),r>0&&(h=!0,g.splice(g.length-r,r))}let _=[];for(let e of(p&&_.push(d),g))for(let t of e)_.push(t);return h&&_.push(d),_})({output:e.output,cursor:this.cursor,options:this.options,maxItems:e.maxItems,columnPadding:a.length,rowPadding:s+c,style:(e,r)=>t(e,e.disabled?"disabled":r?"active":"inactive")}).join(`
22
22
  ${a}`)}
23
23
  ${d}
24
24
  `}}}}).prompt()};(0,a3.styleText)("gray",sF);let sV=e=>new sM({validate:e.validate,placeholder:e.placeholder,defaultValue:e.defaultValue,initialValue:e.initialValue,output:e.output,signal:e.signal,input:e.input,render(){let t=e?.withGuide??sx.withGuide,r=`${t?`${(0,a3.styleText)("gray",sF)}
@@ -31,30 +31,30 @@ ${a}${e}
31
31
  `}case"submit":{let e=a?`${t?" ":""}${(0,a3.styleText)("dim",a)}`:"",n=t?(0,a3.styleText)("gray",sF):"";return`${r}${n}${e}`}case"cancel":{let e=a?` ${(0,a3.styleText)(["strikethrough","dim"],a)}`:"",n=t?(0,a3.styleText)("gray",sF):"";return`${r}${n}${e}${a.trim()?`
32
32
  ${n}`:""}`}default:{let e=t?`${(0,a3.styleText)("cyan",sF)} `:"",n=t?(0,a3.styleText)("cyan",sB):"";return`${r}${e}${i}
33
33
  ${n}
34
- `}}}}).prompt();var sH=n(485),sK=n.n(sH);class sQ extends ee.kl()("@sketchi/cli/GenerateWizard"){}function sZ(){return nB.make({code:"prompt_failed",message:"Sketchi could not read the interactive prompt.",hint:"Retry in a terminal, or pass --prompt for noninteractive use."})}function s0(e){return e===sS?L.OH5(()=>((e="")=>{let t=(void 0)??process.stdout,r=(void 0)??sx.withGuide?`${(0,a3.styleText)("gray",sB)} `:"";t.write(`${r}${(0,a3.styleText)("red",e)}
34
+ `}}}}).prompt();var sH=n(485),sK=n.n(sH);class sQ extends Z.kl()("@sketchi/cli/GenerateWizard"){}function sZ(){return nU.make({code:"prompt_failed",message:"Sketchi could not read the interactive prompt.",hint:"Retry in a terminal, or pass --prompt for noninteractive use."})}function s0(e){return e===sS?B.OH5(()=>((e="")=>{let t=(void 0)??process.stdout,r=(void 0)??sx.withGuide?`${(0,a3.styleText)("gray",sB)} `:"";t.write(`${r}${(0,a3.styleText)("red",e)}
35
35
 
36
- `)})("Generation cancelled.")).pipe(L.hgn(L.fJG(nB.make({code:"cancelled",message:"Generation was cancelled.",hint:"Run sketchi generate again when you are ready."})))):L.PyW(e)}let s1=L.$mh({try:e=>sV({signal:e,message:"What should Sketchi draw?",placeholder:"Map release approval with pass and revise branches",validate:e=>void 0!==e&&e.trim().length>0?void 0:"Enter a diagram description."}),catch:sZ}).pipe(L.qIB(s0)),s2=L.$mh({try:e=>sG({signal:e,message:"Diagram type",initialValue:"flowchart",options:[{value:"flowchart",label:"Flowchart",hint:"best for processes and decisions"},{value:"mindmap",label:"Mind map",hint:"best for ideas and topics"},{value:"sequence",label:"Sequence diagram",hint:"best for ordered participant interactions"}]}),catch:sZ}).pipe(L.qIB(s0)),s5=L.$mh({try:e=>sG({signal:e,message:"Save the PNG",initialValue:"current",options:[{value:"current",label:"Current directory",hint:"<generated-id>.png"},{value:"project",label:"Project diagrams folder",hint:"diagrams/<generated-id>.png"},{value:"custom",label:"Custom path",hint:"same semantics as --dest"}]}),catch:sZ}).pipe(L.qIB(s0));function s3(e){return void 0===e||0===e.trim().length?"Enter a file path.":"-"===e.trim()?"Interactive generation cannot write PNG bytes to stdout. Enter a file path.":void 0}let s6=L.$mh({try:e=>sV({signal:e,message:"PNG destination",placeholder:"./diagram.png",validate:s3}),catch:sZ}).pipe(L.qIB(s0)),s8=L.fn("sketchi.cli.generateWizard.destination")(function*(){let e=yield*s5;return"current"===e?{_tag:"CurrentDirectory"}:"project"===e?{_tag:"ProjectDiagrams"}:{_tag:"Custom",path:(yield*s6).trim()}}),s9=L.fn("sketchi.cli.generateWizard.ask")(function*(e){yield*L.OH5(()=>((e="")=>{let t=(void 0)??process.stdout,r=(void 0)??sx.withGuide?`${(0,a3.styleText)("gray",sU)} `:"";t.write(`${r}${e}
37
- `)})("Create a diagram with Sketchi"));let t=yield*s1,r=e.type??(yield*s2),n=e.destination??(yield*s8());return{prompt:t.trim(),type:r,destination:n}}),s4=L.Q56(L.OH5(()=>{let e=(({indicator:e="dots",onCancel:t,output:r=process.stdout,cancelMessage:n,errorMessage:i,frames:a=sP?["◒","◐","◓","◑"]:["•","o","O","0"],delay:s=sP?80:120,signal:o,...l}={})=>{let d="true"===process.env.CI,c,u,f=!1,p=!1,h="",m,g=performance.now(),y=s$(r),b=l?.styleFrame??sY,v=e=>{let r=e>1?i??sx.messages.error:n??sx.messages.cancel;p=1===e,f&&(I(r,e),p&&"function"==typeof t&&t())},_=()=>v(2),x=()=>v(1),w=()=>{if(void 0===m)return;d&&r.write(`
36
+ `)})("Generation cancelled.")).pipe(B.hgn(B.fJG(nU.make({code:"cancelled",message:"Generation was cancelled.",hint:"Run sketchi generate again when you are ready."})))):B.PyW(e)}let s1=B.$mh({try:e=>sV({signal:e,message:"What should Sketchi draw?",placeholder:"Map release approval with pass and revise branches",validate:e=>void 0!==e&&e.trim().length>0?void 0:"Enter a diagram description."}),catch:sZ}).pipe(B.qIB(s0)),s2=B.$mh({try:e=>sG({signal:e,message:"Diagram type",initialValue:"flowchart",options:[{value:"flowchart",label:"Flowchart",hint:"best for processes and decisions"},{value:"mindmap",label:"Mind map",hint:"best for ideas and topics"},{value:"sequence",label:"Sequence diagram",hint:"best for ordered participant interactions"}]}),catch:sZ}).pipe(B.qIB(s0)),s5=B.$mh({try:e=>sG({signal:e,message:"Save the PNG",initialValue:"current",options:[{value:"current",label:"Current directory",hint:"<generated-id>.png"},{value:"project",label:"Project diagrams folder",hint:"diagrams/<generated-id>.png"},{value:"custom",label:"Custom path",hint:"same semantics as --dest"}]}),catch:sZ}).pipe(B.qIB(s0));function s3(e){return void 0===e||0===e.trim().length?"Enter a file path.":"-"===e.trim()?"Interactive generation cannot write PNG bytes to stdout. Enter a file path.":void 0}let s6=B.$mh({try:e=>sV({signal:e,message:"PNG destination",placeholder:"./diagram.png",validate:s3}),catch:sZ}).pipe(B.qIB(s0)),s8=B.fn("sketchi.cli.generateWizard.destination")(function*(){let e=yield*s5;return"current"===e?{_tag:"CurrentDirectory"}:"project"===e?{_tag:"ProjectDiagrams"}:{_tag:"Custom",path:(yield*s6).trim()}}),s9=B.fn("sketchi.cli.generateWizard.ask")(function*(e){yield*B.OH5(()=>((e="")=>{let t=(void 0)??process.stdout,r=(void 0)??sx.withGuide?`${(0,a3.styleText)("gray",sU)} `:"";t.write(`${r}${e}
37
+ `)})("Create a diagram with Sketchi"));let t=yield*s1,r=e.type??(yield*s2),n=e.destination??(yield*s8());return{prompt:t.trim(),type:r,destination:n}}),s4=B.Q56(B.OH5(()=>{let e=(({indicator:e="dots",onCancel:t,output:r=process.stdout,cancelMessage:n,errorMessage:i,frames:a=sA?["◒","◐","◓","◑"]:["•","o","O","0"],delay:s=sA?80:120,signal:o,...l}={})=>{let d="true"===process.env.CI,c,u,f=!1,p=!1,h="",m,g=performance.now(),y=s$(r),v=l?.styleFrame??sY,b=e=>{let r=e>1?i??sx.messages.error:n??sx.messages.cancel;p=1===e,f&&(I(r,e),p&&"function"==typeof t&&t())},_=()=>b(2),x=()=>b(1),w=()=>{if(void 0===m)return;d&&r.write(`
38
38
  `);let e=sy(m,y,{hard:!0,trim:!1}).split(`
39
- `);e.length>1&&r.write(sb.cursor.up(e.length-1)),r.write(sb.cursor.to(0)),r.write(sb.erase.down())},k=e=>{let t=(performance.now()-e)/1e3,r=Math.floor(t/60),n=Math.floor(t%60);return r>0?`[${r}m ${n}s]`:`[${n}s]`},S=l.withGuide??sx.withGuide,I=(t="",n=0,i=!1)=>{if(!f)return;f=!1,clearInterval(u),w();let a=0===n?(0,a3.styleText)("green",sD):1===n?(0,a3.styleText)("red",sR):(0,a3.styleText)("red",sj);h=t??h,i||("timer"===e?r.write(`${a} ${h} ${k(g)}
39
+ `);e.length>1&&r.write(sv.cursor.up(e.length-1)),r.write(sv.cursor.to(0)),r.write(sv.erase.down())},k=e=>{let t=(performance.now()-e)/1e3,r=Math.floor(t/60),n=Math.floor(t%60);return r>0?`[${r}m ${n}s]`:`[${n}s]`},S=l.withGuide??sx.withGuide,I=(t="",n=0,i=!1)=>{if(!f)return;f=!1,clearInterval(u),w();let a=0===n?(0,a3.styleText)("green",sD):1===n?(0,a3.styleText)("red",sR):(0,a3.styleText)("red",sj);h=t??h,i||("timer"===e?r.write(`${a} ${h} ${k(g)}
40
40
  `):r.write(`${a} ${h}
41
- `)),process.removeListener("uncaughtExceptionMonitor",_),process.removeListener("unhandledRejection",_),process.removeListener("SIGINT",x),process.removeListener("SIGTERM",x),process.removeListener("exit",v),o&&o.removeEventListener("abort",x),c()};return{start:(t="")=>{f=!0,c=function({input:e=a6.stdin,output:t=a6.stdout,overwrite:r=!0,hideCursor:n=!0}={}){let i=nE.createInterface({input:e,output:t,prompt:"",tabSize:1});nE.emitKeypressEvents(e,i),e instanceof sv.ReadStream&&e.isTTY&&e.setRawMode(!0);let a=(i,{name:s,sequence:o})=>{if(sw([String(i),s,o],"cancel")){n&&t.write(sb.cursor.show),process.exit(0);return}r&&nE.moveCursor(t,"return"===s?0:-1,"return"===s?-1:0,()=>{nE.clearLine(t,1,()=>{e.once("keypress",a)})})};return n&&t.write(sb.cursor.hide),e.once("keypress",a),()=>{e.off("keypress",a),n&&t.write(sb.cursor.show),e instanceof sv.ReadStream&&e.isTTY&&!sk&&e.setRawMode(!1),i.terminal=!1,i.close()}}({output:r}),h=t.replace(/\.+$/,""),g=performance.now(),S&&r.write(`${(0,a3.styleText)("gray",sF)}
42
- `);let n=0,i=0;process.on("uncaughtExceptionMonitor",_),process.on("unhandledRejection",_),process.on("SIGINT",x),process.on("SIGTERM",x),process.on("exit",v),o&&o.addEventListener("abort",x),u=setInterval(()=>{let t;if(d&&h===m)return;w(),m=h;let s=b(a[n]);if(d)t=`${s} ${h}...`;else if("timer"===e)t=`${s} ${h} ${k(g)}`;else{let e=".".repeat(Math.floor(i)).slice(0,3);t=`${s} ${h}${e}`}let o=sy(t,y,{hard:!0,trim:!1});r.write(o),n=n+1<a.length?n+1:0,i=i<4?i+.125:0},s)},stop:(e="")=>I(e,0),message:(e="")=>{h=(e??h).replace(/\.+$/,"")},cancel:(e="")=>I(e,1),error:(e="")=>I(e,2),clear:()=>I("",0,!0),get isCancelled(){return p}}})({output:process.stdout}),t=!1;return e.start("Sketchi is drawing"),{succeed:r=>L.OH5(()=>{t||(t=!0,e.stop(r))}),finish:r=>L.OH5(()=>{t||(t=!0,z.N6(r)?e.error("Generation stopped"):e.clear())})}}),(e,t)=>e.finish(t)).pipe(L.TjK(e=>({succeed:e.succeed}))),s7=V.Py(sQ,{ask:s9,activity:s4}),oe=eb.z4N,ot=e=>ec.R6(t=>e(t.getRef(oe))),or=(...e)=>ot(t=>eb.OH5(()=>{t.error(...e)})),on=(...e)=>ot(t=>eb.OH5(()=>{t.log(...e)})),oi="~effect/cli/CliError";class oa extends(nw.rNF(`${oi}/UnrecognizedOption`))("UnrecognizedOption",{option:nw.QfV,command:nw.lqM(nw.O31(nw.QfV)),suggestions:nw.O31(nw.QfV)}){[oi]=oi;get message(){let e=this.suggestions.length>0?`
41
+ `)),process.removeListener("uncaughtExceptionMonitor",_),process.removeListener("unhandledRejection",_),process.removeListener("SIGINT",x),process.removeListener("SIGTERM",x),process.removeListener("exit",b),o&&o.removeEventListener("abort",x),c()};return{start:(t="")=>{f=!0,c=function({input:e=a6.stdin,output:t=a6.stdout,overwrite:r=!0,hideCursor:n=!0}={}){let i=n$.createInterface({input:e,output:t,prompt:"",tabSize:1});n$.emitKeypressEvents(e,i),e instanceof sb.ReadStream&&e.isTTY&&e.setRawMode(!0);let a=(i,{name:s,sequence:o})=>{if(sw([String(i),s,o],"cancel")){n&&t.write(sv.cursor.show),process.exit(0);return}r&&n$.moveCursor(t,"return"===s?0:-1,"return"===s?-1:0,()=>{n$.clearLine(t,1,()=>{e.once("keypress",a)})})};return n&&t.write(sv.cursor.hide),e.once("keypress",a),()=>{e.off("keypress",a),n&&t.write(sv.cursor.show),e instanceof sb.ReadStream&&e.isTTY&&!sk&&e.setRawMode(!1),i.terminal=!1,i.close()}}({output:r}),h=t.replace(/\.+$/,""),g=performance.now(),S&&r.write(`${(0,a3.styleText)("gray",sF)}
42
+ `);let n=0,i=0;process.on("uncaughtExceptionMonitor",_),process.on("unhandledRejection",_),process.on("SIGINT",x),process.on("SIGTERM",x),process.on("exit",b),o&&o.addEventListener("abort",x),u=setInterval(()=>{let t;if(d&&h===m)return;w(),m=h;let s=v(a[n]);if(d)t=`${s} ${h}...`;else if("timer"===e)t=`${s} ${h} ${k(g)}`;else{let e=".".repeat(Math.floor(i)).slice(0,3);t=`${s} ${h}${e}`}let o=sy(t,y,{hard:!0,trim:!1});r.write(o),n=n+1<a.length?n+1:0,i=i<4?i+.125:0},s)},stop:(e="")=>I(e,0),message:(e="")=>{h=(e??h).replace(/\.+$/,"")},cancel:(e="")=>I(e,1),error:(e="")=>I(e,2),clear:()=>I("",0,!0),get isCancelled(){return p}}})({output:process.stdout}),t=!1;return e.start("Sketchi is drawing"),{succeed:r=>B.OH5(()=>{t||(t=!0,e.stop(r))}),finish:r=>B.OH5(()=>{t||(t=!0,L.N6(r)?e.error("Generation stopped"):e.clear())})}}),(e,t)=>e.finish(t)).pipe(B.TjK(e=>({succeed:e.succeed}))),s7=G.Py(sQ,{ask:s9,activity:s4}),oe=ey.z4N,ot=e=>ed.R6(t=>e(t.getRef(oe))),or=(...e)=>ot(t=>ey.OH5(()=>{t.error(...e)})),on=(...e)=>ot(t=>ey.OH5(()=>{t.log(...e)})),oi="~effect/cli/CliError";class oa extends(nx.rNF(`${oi}/UnrecognizedOption`))("UnrecognizedOption",{option:nx.QfV,command:nx.lqM(nx.O31(nx.QfV)),suggestions:nx.O31(nx.QfV)}){[oi]=oi;get message(){let e=this.suggestions.length>0?`
43
43
 
44
44
  Did you mean this?
45
- ${this.suggestions.join("\n ")}`:"";return(this.command?`Unrecognized flag: ${this.option} in command ${this.command.join(" ")}`:`Unrecognized flag: ${this.option}`)+e}}class os extends(nw.rNF(`${oi}/DuplicateOption`))("DuplicateOption",{option:nw.QfV,parentCommand:nw.QfV,childCommand:nw.QfV}){[oi]=oi;get message(){return`Duplicate flag name "${this.option}" in parent command "${this.parentCommand}" and subcommand "${this.childCommand}". Parent will always claim this flag (Mode A semantics). Consider renaming one of them to avoid confusion.`}}class oo extends(nw.rNF(`${oi}/MissingOption`))("MissingOption",{option:nw.QfV}){[oi]=oi;get message(){return`Missing required flag: --${this.option}`}}class ol extends(nw.rNF(`${oi}/MissingArgument`))("MissingArgument",{argument:nw.QfV}){[oi]=oi;get message(){return`Missing required argument: ${this.argument}`}}class od extends(nw.rNF(`${oi}/UnexpectedArgument`))("UnexpectedArgument",{arguments:nw.O31(nw.QfV)}){[oi]=oi;get message(){let e=1===this.arguments.length?"argument":"arguments";return`Unexpected positional ${e}: ${this.arguments.map(e=>JSON.stringify(e)).join(", ")}`}}class oc extends(nw.rNF(`${oi}/InvalidValue`))("InvalidValue",{option:nw.QfV,value:nw.QfV,expected:nw.QfV,kind:nw.gPz([nw.uSQ("flag"),nw.uSQ("argument")])}){[oi]=oi;get message(){let e=this.expected.startsWith("Expected ")||this.expected.startsWith("Expected:")?this.expected:`Expected: ${this.expected}`;return"argument"===this.kind?`Invalid value for argument <${this.option}>: "${this.value}". ${e}`:0===this.value.length?`Missing value for flag --${this.option}. ${e}`:`Invalid value for flag --${this.option}: "${this.value}". ${e}`}}class ou extends(nw.rNF(`${oi}/UnknownSubcommand`))("UnknownSubcommand",{subcommand:nw.QfV,parent:nw.lqM(nw.O31(nw.QfV)),suggestions:nw.O31(nw.QfV)}){[oi]=oi;get message(){let e=this.suggestions.length>0?`
45
+ ${this.suggestions.join("\n ")}`:"";return(this.command?`Unrecognized flag: ${this.option} in command ${this.command.join(" ")}`:`Unrecognized flag: ${this.option}`)+e}}class os extends(nx.rNF(`${oi}/DuplicateOption`))("DuplicateOption",{option:nx.QfV,parentCommand:nx.QfV,childCommand:nx.QfV}){[oi]=oi;get message(){return`Duplicate flag name "${this.option}" in parent command "${this.parentCommand}" and subcommand "${this.childCommand}". Parent will always claim this flag (Mode A semantics). Consider renaming one of them to avoid confusion.`}}class oo extends(nx.rNF(`${oi}/MissingOption`))("MissingOption",{option:nx.QfV}){[oi]=oi;get message(){return`Missing required flag: --${this.option}`}}class ol extends(nx.rNF(`${oi}/MissingArgument`))("MissingArgument",{argument:nx.QfV}){[oi]=oi;get message(){return`Missing required argument: ${this.argument}`}}class od extends(nx.rNF(`${oi}/UnexpectedArgument`))("UnexpectedArgument",{arguments:nx.O31(nx.QfV)}){[oi]=oi;get message(){let e=1===this.arguments.length?"argument":"arguments";return`Unexpected positional ${e}: ${this.arguments.map(e=>JSON.stringify(e)).join(", ")}`}}class oc extends(nx.rNF(`${oi}/InvalidValue`))("InvalidValue",{option:nx.QfV,value:nx.QfV,expected:nx.QfV,kind:nx.gPz([nx.uSQ("flag"),nx.uSQ("argument")])}){[oi]=oi;get message(){let e=this.expected.startsWith("Expected ")||this.expected.startsWith("Expected:")?this.expected:`Expected: ${this.expected}`;return"argument"===this.kind?`Invalid value for argument <${this.option}>: "${this.value}". ${e}`:0===this.value.length?`Missing value for flag --${this.option}. ${e}`:`Invalid value for flag --${this.option}: "${this.value}". ${e}`}}class ou extends(nx.rNF(`${oi}/UnknownSubcommand`))("UnknownSubcommand",{subcommand:nx.QfV,parent:nx.lqM(nx.O31(nx.QfV)),suggestions:nx.O31(nx.QfV)}){[oi]=oi;get message(){let e=this.suggestions.length>0?`
46
46
 
47
47
  Did you mean this?
48
- ${this.suggestions.join("\n ")}`:"";return this.parent?`Unknown subcommand "${this.subcommand}" for "${this.parent.join(" ")}"${e}`:`Unknown subcommand "${this.subcommand}"${e}`}}class of extends(nw.rNF(`${oi}/UserError`))("UserError",{cause:nw.kld(),userMessage:nw.Qrq(nw.QfV)}){[oi]=oi;[q]=!0;get message(){return this.userMessage?this.userMessage:"string"==typeof this.cause&&this.cause?this.cause:this.cause instanceof Error&&this.cause.message?this.cause.message:"An error occurred"}}let op=nw.gPz([oa,os,oo,ol,od,oc,ou,of]);class oh extends(nw.rNF(`${oi}/ShowHelp`))("ShowHelp",{commandPath:nw.O31(nw.QfV),errors:nw.O31(op)}){[oi]=oi;[Y]=+!!this.errors.length;[q]=!1;get message(){return"Help requested"}}var om=n(1958);let og={"~effect/cli/Primitive":{_A:W.D_}},oy=nw.is(nw.L39),ob=nw.is(nw.o5J),ov=e=>"Boolean"===e._tag,o_=(e,t)=>Object.assign(Object.create(og),{_tag:e,parse:t}),ox=(e,t)=>{let r=nw.lHk(t),n=nw._Re(r);return o_(e,e=>L.xm_(n(e),e=>e.message))},ow=ox("Boolean",nw.$Cd);nw.wYs;let ok=ox("Int",nw.Aiz);nw.n96;let oS=o_("String",e=>L.PyW(e)),oI=(()=>L.fJG("This option does not accept values"),e=>{switch(e._tag){case"Boolean":return"boolean";case"String":case"Redacted":return"string";case"Int":return"integer";case"Finite":return"number";case"Date":return"date";case"Path":return"path";case"Choice":return"choice";case"FileText":case"FileParse":case"FileSchema":return"file";case"KeyValuePair":return"key=value";case"Never":return"none";default:return"value"}}),o$=e=>"Choice"===e._tag?e.choiceKeys:void 0,oE=e=>"Path"===e._tag?e.pathType:void 0,oO="~effect/cli/Param",oC="argument",oT={[oO]:{_A:W.D_},pipe(){return(0,eh.tT)(this,arguments)}},oM=e=>"flag"===e.kind,oP=e=>Object.setPrototypeOf({_tag:"Single",...e,description:e.description??et.none(),aliases:e.aliases??[],hidden:e.hidden??!1,parse:t=>e.kind===oC?oX(e.name,e.primitiveType,t):oq(e.name,e.primitiveType,t)},oT),oA=(e,t)=>oP({name:t,primitiveType:oS,kind:e}),oN=(e,t,r)=>{let n,i;return oP({name:t,primitiveType:(n=new Map(r),i=r.map(([e])=>(0,om.GP)(e)).join(" | "),Object.assign(o_("Choice",e=>n.has(e)?L.PyW(n.get(e)):L.fJG(i)),{choiceKeys:r.map(([e])=>e)})),kind:e})},oR=/^-+/,oj=(0,W.XY)(2,(e,t)=>oK(e,e=>oP({...e,aliases:[...e.aliases,t.replace(oR,"")]}))),oD=(0,W.XY)(2,(e,t)=>oK(e,e=>oP({...e,description:et.some(t)}))),oU=(0,W.XY)(2,(e,t)=>Object.assign(Object.create(oT),{_tag:"Map",kind:e.kind,param:e,f:t,parse:r=>L.TjK(e.parse(r),([e,r])=>[e,t(r)])})),oF=(e,t,r=[])=>{let n=r.map(e=>()=>e().parse);return Object.assign(Object.create(oT),{_tag:"Transform",kind:e.kind,param:e,alternatives:r,f:t,parse:t(e.parse,n)})},oB=(0,W.XY)(2,(e,t)=>oF(e,e=>r=>L.qIB(e(r),([e,r])=>t(r).pipe(L.TjK(t=>[e,t]))))),oL=e=>Object.assign(Object.create(oT),{_tag:"Optional",kind:e.kind,param:e,parse:t=>e.parse(t).pipe(L.TjK(([e,t])=>[e,et.some(t)]),L.loE({MissingOption:()=>L.PyW([t.arguments,et.none()]),MissingArgument:()=>L.PyW([t.arguments,et.none()])}))}),oz=(0,W.XY)(2,(e,t)=>L.yw5(t)?oB(oL(e),et.match({onNone:()=>t,onSome:L.PyW})):oU(oL(e),et.getOrElse(()=>t))),oW=(0,W.XY)(3,(e,t,r)=>oB(e,L.D9k(function*(n){let i=t(n);if(et.isSome(i))return i.value;let a=oZ(e);return yield*new oc({option:a.name,value:globalThis.String(n),expected:r(n),kind:a.kind})}))),oJ=(0,W.XY)(3,(e,t,r)=>oW(e,et.liftPredicate(t),r)),oY=(0,W.XY)(2,(e,t)=>oK(e,e=>oP({...e,typeName:t}))),oX=L.D9k(function*(e,t,r){if(0===r.arguments.length)return yield*new ol({argument:e});let n=r.arguments[0],i=yield*L.xm_(t.parse(n),t=>new oc({option:e,value:n,expected:t,kind:"argument"}));return[r.arguments.slice(1),i]}),oq=L.D9k(function*(e,t,r){let n=r.flags[e];if(void 0===n||0===n.length)return yield*new oo({option:e});let i=n[0],a=yield*L.xm_(t.parse(i),t=>new oc({option:e,value:i,expected:t,kind:"flag"}));return[r.arguments,a]}),oG=L.D9k(function*(e,t,r,n){let i=[],a=n?.min??0,s=n?.max??1/0,o=0,l=r.arguments;for(;l.length>0&&o<s;){let[t,n]=yield*e.parse({flags:r.flags,arguments:l});i.push(n),l=t,o++}return o<a?yield*0===o?new ol({argument:t.name}):new oc({option:t.name,value:`${o} values`,expected:`at least ${a} value${1===a?"":"s"}`,kind:t.kind}):[l,i]}),oV=L.D9k(function*(e,t,r,n){let i=[],a=[t.name,...t.aliases].flatMap(e=>r.flags[e]??[]),s=a.length;if(em.EA(n?.min)&&s<n.min)return yield*0===s?new oo({option:t.name}):new oc({option:t.name,value:`${s} occurrences`,expected:`at least ${n.min} value${1===n.min?"":"s"}`,kind:t.kind});if(em.EA(n?.max)&&s>n.max)return yield*new oc({option:t.name,value:`${s} occurrences`,expected:`at most ${n.max} value${1===n.max?"":"s"}`,kind:t.kind});for(let r of a){let[,n]=yield*e.parse({flags:{[t.name]:[r]},arguments:[]});i.push(n)}return[r.arguments,i]}),oH=(e,t)=>{switch(e._tag){case"Single":return t.Single(e);case"Map":return t.Map(e);case"Transform":return t.Transform(e);case"Optional":return t.Optional(e);case"Variadic":return t.Variadic(e)}},oK=(e,t)=>oH(e,{Single:e=>t(e),Map:e=>oU(oK(e.param,t),e.f),Transform:e=>oF(oK(e.param,t),e.f,e.alternatives.map(e=>()=>oK(e(),t))),Optional:e=>oL(oK(e.param,t)),Variadic:e=>{var r,n;let i;return r=oK(e.param,t),n={min:et.getOrUndefined(e.min),max:et.getOrUndefined(e.max)},i=oZ(r),Object.assign(Object.create(oT),{_tag:"Variadic",kind:r.kind,param:r,min:et.fromUndefinedOr(n?.min),max:et.fromUndefinedOr(n?.max),parse:e=>"argument"===i.kind?oG(r,i,e,n):oV(r,i,e,n)})}}),oQ=e=>oH(e,{Single:e=>[e],Map:e=>oQ(e.param),Transform:e=>[...oQ(e.param),...e.alternatives.flatMap(e=>oQ(e()))],Optional:e=>oQ(e.param),Variadic:e=>oQ(e.param)}),oZ=e=>{let t=oQ(e);if(0===t.length)throw Error("No Single param found in param structure");if(t.length>1)throw Error(`Multiple Single params found: ${t.map(e=>e.name).join(", ")}`);return t[0]},o0=e=>oH(e,{Single:()=>({isOptional:!1,isVariadic:!1,variadicMin:et.none(),variadicMax:et.none()}),Map:e=>o0(e.param),Transform:e=>o0(e.param),Optional:e=>({...o0(e.param),isOptional:!0}),Variadic:e=>({...o0(e.param),isVariadic:!0,variadicMin:e.min,variadicMax:e.max})});var o1=n(4600);let o2=ee.Or("effect/cli/CliOutput",{defaultValue:()=>o3()}),o5=e=>e.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/g,e=>`\\x${e.charCodeAt(0).toString(16).padStart(2,"0")}`),o3=e=>{let t=globalThis.process,r="object"==typeof t&&null!==t,n=e?.colors!==void 0?e.colors:r&&"object"==typeof t.stdout&&null!==t.stdout&&!0===t.stdout.isTTY&&!t.env?.NO_COLOR,i=n?{bold:e=>`\x1b[1m${e}\x1b[0m`,dim:e=>`\x1b[2m${e}\x1b[0m`,cyan:e=>`\x1b[36m${e}\x1b[0m`,green:e=>`\x1b[32m${e}\x1b[0m`,blue:e=>`\x1b[34m${e}\x1b[0m`,yellow:e=>`\x1b[33m${e}\x1b[0m`,magenta:e=>`\x1b[35m${e}\x1b[0m`}:{bold:e=>e,dim:e=>e,cyan:e=>e,green:e=>e,blue:e=>e,yellow:e=>e,magenta:e=>e},a=n?"\x1b[0m":"",s=n?"\x1b[31m":"",o=n?"\x1b[1m":"";return{formatHelpDoc:e=>lr(e,i),formatCliError:e=>o5(e.message),formatError:e=>`
48
+ ${this.suggestions.join("\n ")}`:"";return this.parent?`Unknown subcommand "${this.subcommand}" for "${this.parent.join(" ")}"${e}`:`Unknown subcommand "${this.subcommand}"${e}`}}class of extends(nx.rNF(`${oi}/UserError`))("UserError",{cause:nx.kld(),userMessage:nx.Qrq(nx.QfV)}){[oi]=oi;[X]=!0;get message(){return this.userMessage?this.userMessage:"string"==typeof this.cause&&this.cause?this.cause:this.cause instanceof Error&&this.cause.message?this.cause.message:"An error occurred"}}let op=nx.gPz([oa,os,oo,ol,od,oc,ou,of]);class oh extends(nx.rNF(`${oi}/ShowHelp`))("ShowHelp",{commandPath:nx.O31(nx.QfV),errors:nx.O31(op)}){[oi]=oi;[J]=+!!this.errors.length;[X]=!1;get message(){return"Help requested"}}var om=n(1958);let og={"~effect/cli/Primitive":{_A:z.D_}},oy=nx.is(nx.L39),ov=nx.is(nx.o5J),ob=e=>"Boolean"===e._tag,o_=(e,t)=>Object.assign(Object.create(og),{_tag:e,parse:t}),ox=(e,t)=>{let r=nx.lHk(t),n=nx._Re(r);return o_(e,e=>B.xm_(n(e),e=>e.message))},ow=ox("Boolean",nx.$Cd);nx.wYs;let ok=ox("Int",nx.Aiz);nx.n96;let oS=o_("String",e=>B.PyW(e)),oI=(()=>B.fJG("This option does not accept values"),e=>{switch(e._tag){case"Boolean":return"boolean";case"String":case"Redacted":return"string";case"Int":return"integer";case"Finite":return"number";case"Date":return"date";case"Path":return"path";case"Choice":return"choice";case"FileText":case"FileParse":case"FileSchema":return"file";case"KeyValuePair":return"key=value";case"Never":return"none";default:return"value"}}),o$=e=>"Choice"===e._tag?e.choiceKeys:void 0,oE=e=>"Path"===e._tag?e.pathType:void 0,oO="~effect/cli/Param",oC="argument",oT={[oO]:{_A:z.D_},pipe(){return(0,ep.tT)(this,arguments)}},oM=e=>"flag"===e.kind,oA=e=>Object.setPrototypeOf({_tag:"Single",...e,description:e.description??ee.none(),aliases:e.aliases??[],hidden:e.hidden??!1,parse:t=>e.kind===oC?oG(e.name,e.primitiveType,t):oV(e.name,e.primitiveType,t)},oT),oN=(e,t)=>oA({name:t,primitiveType:oS,kind:e}),oP=(e,t,r)=>{let n,i;return oA({name:t,primitiveType:(n=new Map(r),i=r.map(([e])=>(0,om.GP)(e)).join(" | "),Object.assign(o_("Choice",e=>n.has(e)?B.PyW(n.get(e)):B.fJG(i)),{choiceKeys:r.map(([e])=>e)})),kind:e})},oR=/^-+/,oj=(0,z.XY)(2,(e,t)=>oZ(e,e=>oA({...e,aliases:[...e.aliases,t.replace(oR,"")]}))),oD=(0,z.XY)(2,(e,t)=>oZ(e,e=>oA({...e,description:ee.some(t)}))),oU=(0,z.XY)(2,(e,t)=>Object.assign(Object.create(oT),{_tag:"Map",kind:e.kind,param:e,f:t,parse:r=>B.TjK(e.parse(r),([e,r])=>[e,t(r)])})),oF=(e,t,r=[])=>{let n=r.map(e=>()=>e().parse);return Object.assign(Object.create(oT),{_tag:"Transform",kind:e.kind,param:e,alternatives:r,f:t,parse:t(e.parse,n)})},oB=(0,z.XY)(2,(e,t)=>oF(e,e=>r=>B.qIB(e(r),([e,r])=>t(r).pipe(B.TjK(t=>[e,t]))))),oL=e=>Object.assign(Object.create(oT),{_tag:"Optional",kind:e.kind,param:e,parse:t=>e.parse(t).pipe(B.TjK(([e,t])=>[e,ee.some(t)]),B.loE({MissingOption:()=>B.PyW([t.arguments,ee.none()]),MissingArgument:()=>B.PyW([t.arguments,ee.none()])}))}),oz=(0,z.XY)(2,(e,t)=>B.yw5(t)?oB(oL(e),ee.match({onNone:()=>t,onSome:B.PyW})):oU(oL(e),ee.getOrElse(()=>t))),oW=(e,t)=>{let r=o1(e);return Object.assign(Object.create(oT),{_tag:"Variadic",kind:e.kind,param:e,min:ee.fromUndefinedOr(t?.min),max:ee.fromUndefinedOr(t?.max),parse:n=>"argument"===r.kind?oH(e,r,n,t):oK(e,r,n,t)})},oJ=(0,z.XY)(2,(e,t)=>{if(t<0)throw Error("atLeast: min must be non-negative");return oW(e,{min:t})}),oY=(0,z.XY)(3,(e,t,r)=>oB(e,B.D9k(function*(n){let i=t(n);if(ee.isSome(i))return i.value;let a=o1(e);return yield*new oc({option:a.name,value:globalThis.String(n),expected:r(n),kind:a.kind})}))),oX=(0,z.XY)(3,(e,t,r)=>oY(e,ee.liftPredicate(t),r)),oq=(0,z.XY)(2,(e,t)=>oZ(e,e=>oA({...e,typeName:t}))),oG=B.D9k(function*(e,t,r){if(0===r.arguments.length)return yield*new ol({argument:e});let n=r.arguments[0],i=yield*B.xm_(t.parse(n),t=>new oc({option:e,value:n,expected:t,kind:"argument"}));return[r.arguments.slice(1),i]}),oV=B.D9k(function*(e,t,r){let n=r.flags[e];if(void 0===n||0===n.length)return yield*new oo({option:e});let i=n[0],a=yield*B.xm_(t.parse(i),t=>new oc({option:e,value:i,expected:t,kind:"flag"}));return[r.arguments,a]}),oH=B.D9k(function*(e,t,r,n){let i=[],a=n?.min??0,s=n?.max??1/0,o=0,l=r.arguments;for(;l.length>0&&o<s;){let[t,n]=yield*e.parse({flags:r.flags,arguments:l});i.push(n),l=t,o++}return o<a?yield*0===o?new ol({argument:t.name}):new oc({option:t.name,value:`${o} values`,expected:`at least ${a} value${1===a?"":"s"}`,kind:t.kind}):[l,i]}),oK=B.D9k(function*(e,t,r,n){let i=[],a=[t.name,...t.aliases].flatMap(e=>r.flags[e]??[]),s=a.length;if(eh.EA(n?.min)&&s<n.min)return yield*0===s?new oo({option:t.name}):new oc({option:t.name,value:`${s} occurrences`,expected:`at least ${n.min} value${1===n.min?"":"s"}`,kind:t.kind});if(eh.EA(n?.max)&&s>n.max)return yield*new oc({option:t.name,value:`${s} occurrences`,expected:`at most ${n.max} value${1===n.max?"":"s"}`,kind:t.kind});for(let r of a){let[,n]=yield*e.parse({flags:{[t.name]:[r]},arguments:[]});i.push(n)}return[r.arguments,i]}),oQ=(e,t)=>{switch(e._tag){case"Single":return t.Single(e);case"Map":return t.Map(e);case"Transform":return t.Transform(e);case"Optional":return t.Optional(e);case"Variadic":return t.Variadic(e)}},oZ=(e,t)=>oQ(e,{Single:e=>t(e),Map:e=>oU(oZ(e.param,t),e.f),Transform:e=>oF(oZ(e.param,t),e.f,e.alternatives.map(e=>()=>oZ(e(),t))),Optional:e=>oL(oZ(e.param,t)),Variadic:e=>oW(oZ(e.param,t),{min:ee.getOrUndefined(e.min),max:ee.getOrUndefined(e.max)})}),o0=e=>oQ(e,{Single:e=>[e],Map:e=>o0(e.param),Transform:e=>[...o0(e.param),...e.alternatives.flatMap(e=>o0(e()))],Optional:e=>o0(e.param),Variadic:e=>o0(e.param)}),o1=e=>{let t=o0(e);if(0===t.length)throw Error("No Single param found in param structure");if(t.length>1)throw Error(`Multiple Single params found: ${t.map(e=>e.name).join(", ")}`);return t[0]},o2=e=>oQ(e,{Single:()=>({isOptional:!1,isVariadic:!1,variadicMin:ee.none(),variadicMax:ee.none()}),Map:e=>o2(e.param),Transform:e=>o2(e.param),Optional:e=>({...o2(e.param),isOptional:!0}),Variadic:e=>({...o2(e.param),isVariadic:!0,variadicMin:e.min,variadicMax:e.max})});var o5=n(4600);let o3=Z.Or("effect/cli/CliOutput",{defaultValue:()=>o8()}),o6=e=>e.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/g,e=>`\\x${e.charCodeAt(0).toString(16).padStart(2,"0")}`),o8=e=>{let t=globalThis.process,r="object"==typeof t&&null!==t,n=e?.colors!==void 0?e.colors:r&&"object"==typeof t.stdout&&null!==t.stdout&&!0===t.stdout.isTTY&&!t.env?.NO_COLOR,i=n?{bold:e=>`\x1b[1m${e}\x1b[0m`,dim:e=>`\x1b[2m${e}\x1b[0m`,cyan:e=>`\x1b[36m${e}\x1b[0m`,green:e=>`\x1b[32m${e}\x1b[0m`,blue:e=>`\x1b[34m${e}\x1b[0m`,yellow:e=>`\x1b[33m${e}\x1b[0m`,magenta:e=>`\x1b[35m${e}\x1b[0m`}:{bold:e=>e,dim:e=>e,cyan:e=>e,green:e=>e,blue:e=>e,yellow:e=>e,magenta:e=>e},a=n?"\x1b[0m":"",s=n?"\x1b[31m":"",o=n?"\x1b[1m":"";return{formatHelpDoc:e=>li(e,i),formatCliError:e=>o6(e.message),formatError:e=>`
49
49
  ${o}${s}ERROR${a}
50
- ${o5(e.message)}${a}`,formatErrors:e=>{if(0===e.length)return"";if(1===e.length)return`
50
+ ${o6(e.message)}${a}`,formatErrors:e=>{if(0===e.length)return"";if(1===e.length)return`
51
51
  ${o}${s}ERROR${a}
52
- ${o5(e[0].message)}${a}`;let t=new Map;for(let r of e){let e=r._tag??"Error",n=t.get(e)??[];n.push(r),t.set(e,n)}let r=[];for(let[,e]of(r.push(`
53
- ${o}${s}ERRORS${a}`),t))for(let t of e)r.push(` ${o5(t.message)}${a}`);return r.join("\n")},formatVersion:(e,t)=>`${i.bold(e)} ${i.dim("v")}${i.bold(t)}`}},o6=new Intl.Segmenter(void 0,{granularity:"grapheme"}),o8=/[\p{Mark}\p{Control}\p{Default_Ignorable_Code_Point}]/gu,o9=/\p{Emoji_Presentation}/u,o4=e=>{var t;let r=e.replace(o8,"");return 0===r.length?0:o9.test(e)||e.includes("️")?2:!((t=r.codePointAt(0))<4352)&&(t<=4447||9001===t||9002===t||t>=11904&&t<=12350||t>=12352&&t<=42191||t>=44032&&t<=55203||t>=63744&&t<=64255||t>=65040&&t<=65049||t>=65072&&t<=65135||t>=65280&&t<=65376||t>=65504&&t<=65510||t>=110592&&t<=111359||t>=127488&&t<=127569||t>=131072&&t<=262141)?2:1},o7=e=>{let t=0;for(let{segment:r}of o6.segment(e.replace(/\u001B\[[0-9;]*m/g,"")))t+=o4(r);return t},le=(e,t)=>{let r=Math.max(...e.map(e=>o7(e.left)))+4,n=void 0===t?r:Math.min(r,t);return e.map(({left:e,right:t})=>{let r;return` ${r=Math.max(0,Math.max(n,o7(e)+1)-o7(e)),e+" ".repeat(r)}${t}`}).join("\n")},lt=(e,t)=>t?`${e}, ${t}`:e,lr=(e,t)=>{let r=[];if(e.description&&(r.push(t.bold("DESCRIPTION")),r.push(` ${e.description}`),r.push("")),r.push(t.bold("USAGE")),r.push(` ${t.cyan(e.usage)}`),r.push(""),e.args&&e.args.length>0){r.push(t.bold("ARGUMENTS"));let n=e.args.map(e=>{let r=e.name;e.variadic&&(r+="...");let n=t.green(r),i=t.dim(e.type),a=`${n} ${i}`,s=e.required?"":t.dim(" (optional)");return{left:a,right:et.getOrElse(e.description,()=>"")+s}});r.push(le(n,25)),r.push("")}if(e.flags.length>0){r.push(t.bold("FLAGS"));let n=e.flags.map(e=>{let r=[];for(let n of(r.push(t.green(`--${e.name}`)),e.aliases))r.push(t.green(n));return{left:r.join(", ")+("boolean"!==e.type?` ${t.dim(e.type)}`:""),right:et.getOrElse(e.description,()=>"")}});r.push(le(n)),r.push("")}if(e.globalFlags&&e.globalFlags.length>0){r.push(t.bold("GLOBAL FLAGS"));let n=e.globalFlags.map(e=>{let r=[];for(let n of(r.push(t.green(`--${e.name}`)),e.aliases))r.push(t.green(n));return{left:r.join(", ")+("boolean"!==e.type?` ${t.dim(e.type)}`:""),right:et.getOrElse(e.description,()=>"")}});r.push(le(n)),r.push("")}if(e.subcommands&&e.subcommands.length>0){let n=e.subcommands.find(e=>void 0===e.group);for(let i of(n&&(r.push(t.bold("SUBCOMMANDS")),r.push(le(n.commands.map(e=>({left:t.cyan(lt(e.name,e.alias)),right:e.shortDescription??e.description})),20)),e.subcommands.length>1&&r.push("")),e.subcommands))void 0!==i.group&&(r.push(t.bold(`${i.group}:`)),r.push(le(i.commands.map(e=>({left:t.cyan(lt(e.name,e.alias)),right:e.shortDescription??e.description})),20)),r.push(""))}if(e.examples&&e.examples.length>0){r.push(t.bold("EXAMPLES"));let n=!0,i=!1;for(let a of e.examples)a.description?(n||r.push(""),r.push(` ${t.dim(`# ${a.description}`)}`)):i&&r.push(""),r.push(` ${t.cyan(a.command)}`),n=!1,i=!!a.description;r.push("")}return""===r[r.length-1]&&r.pop(),r.join("\n")},ln=e=>e.replace(/[^a-zA-Z0-9_]/g,"_"),li=e=>{let t=[`--${e.name}`];for(let r of e.aliases)t.push(1===r.length?`-${r}`:`--${r}`);return"Boolean"===e.type._tag&&t.push(`--no-${e.name}`),t},la=(e,t)=>`${e} "$cur" "$_comp_word" ${t.map(e=>`'${e.replace(/'/g,"'\\''")}'`).join(" ")}`,ls=(e,t)=>{switch(e._tag){case"Boolean":default:return;case"Choice":return la(t,e.values);case"Path":if("directory"===e.pathType)return'COMPREPLY=( $(compgen -d -- "$cur") )';return'COMPREPLY=( $(compgen -f -- "$cur") )'}},lo=(e,t,r,n)=>{let i=[...t,e.name],a=`_${i.map(ln).join("_")}`;r.push(`${a}()`),r.push("{"),r.push(" local cur prev words cword i"),r.push(0===t.length?" local _command_index=0":' local _command_index="$1"'),r.push(' _init_completion -n "$COMP_WORDBREAKS" || return'),0===t.length&&r.push(' local _comp_word="$2"'),r.push("");let s=e.flags.filter(e=>"Boolean"!==e.type._tag);if(s.length>0){for(let e of(r.push(" # Flag value completions"),r.push(' case "$prev" in'),s)){let t=[`--${e.name}`];for(let r of e.aliases)t.push(1===r.length?`-${r}`:`--${r}`);let i=ls(e.type,n);i&&(r.push(` ${t.join("|")})`),r.push(` ${i}`),r.push(" return"),r.push(" ;;"))}r.push(" esac"),r.push("")}if(e.subcommands.length>0){for(let t of(r.push(" # Subcommand dispatch"),r.push(" local cmd _skip_next=0"),r.push(" for ((i = _command_index + 1; i < cword; i++)); do"),r.push(" if (( _skip_next )); then"),r.push(" _skip_next=0"),r.push(" continue"),r.push(" fi"),r.push(' case "${words[i]}" in'),e.flags)){if("Boolean"===t.type._tag)continue;let e=li(t);r.push(` ${e.join("|")}) _skip_next=1 ;;`),r.push(` ${e.map(e=>`${e}=*`).join("|")}) ;;`)}for(let t of e.subcommands){let e=`_${[...i,t.name].map(ln).join("_")}`;r.push(` ${t.name})`),r.push(` ${e} "$i"`),r.push(" return"),r.push(" ;;")}r.push(" esac"),r.push(" done"),r.push("")}((e,t)=>{if(0===e.length)return;let r=e.map(li);t.push(` local ${r.map((e,t)=>`_used_${t}=""`).join(" ")}`),t.push(" for ((i = 1; i < cword; i++)); do"),t.push(' case "${words[i]%%=*}" in'),r.forEach((e,r)=>{t.push(` ${e.join("|")}) _used_${r}=1 ;;`)}),t.push(" esac"),t.push(" done"),t.push(' local _filtered_flags=""'),r.forEach((e,r)=>{t.push(` [[ -n "$_used_${r}" ]] || _filtered_flags+=" ${e.join(" ")}"`)}),t.push("")})(e.flags,r),(e.flags.length>0||e.subcommands.length>0)&&(r.push(" # Complete flags (filtered) and subcommands"),r.push(' if [[ "$cur" == -* ]]; then'),e.flags.length>0&&r.push(' COMPREPLY=( $(compgen -W "$_filtered_flags" -- "$cur") )'),r.push(" return"),r.push(" fi"),r.push(""));let o=e.arguments.flatMap((e,t)=>{let r=((e,t)=>{switch(e._tag){case"Choice":return la(t,e.values);case"Path":if("directory"===e.pathType)return'COMPREPLY=( $(compgen -d -- "$cur") )';return'COMPREPLY=( $(compgen -f -- "$cur") )';default:return}})(e.type,n);return void 0===r?[]:[{argument:e,completion:r,index:t}]});if(o.length>0){for(let t of(r.push(" # Positional argument completions"),r.push(" local _position=0 _skip_next=0 _end_of_options=0"),r.push(" for ((i = _command_index + 1; i < cword; i++)); do"),r.push(" if (( _skip_next )); then"),r.push(" _skip_next=0"),r.push(" continue"),r.push(" fi"),r.push(" if (( _end_of_options )); then"),r.push(" ((_position += 1))"),r.push(" continue"),r.push(" fi"),r.push(' case "${words[i]}" in'),r.push(" --) _end_of_options=1 ;;"),e.flags)){let e=li(t);"Boolean"===t.type._tag?r.push(` ${e.join("|")}) ;;`):(r.push(` ${e.join("|")}) _skip_next=1 ;;`),r.push(` ${e.map(e=>`${e}=*`).join("|")}) ;;`))}for(let{argument:e,completion:t,index:n}of(r.push(" -*) ;;"),r.push(" *) ((_position += 1)) ;;"),r.push(" esac"),r.push(" done"),r.push(' case "$_position" in'),o))e.variadic||(r.push(` ${n})`),r.push(` ${t}`),r.push(" return"),r.push(" ;;"));r.push(" esac");let t=o.find(({argument:e})=>e.variadic);void 0!==t&&(r.push(` if (( _position >= ${t.index} )); then`),r.push(` ${t.completion}`),r.push(" return"),r.push(" fi"))}else if(e.subcommands.length>0){let t=e.subcommands.map(e=>e.name);r.push(` COMPREPLY=( $(compgen -W '${t.join(" ")}' -- "$cur") )`)}for(let t of(r.push("}"),r.push(""),e.subcommands))lo(t,i,r,n)},ll=e=>e.replace(/\\/g,"\\\\").replace(/'/g,"\\'"),ld=e=>ll(e.replace(/[^A-Za-z0-9_.,/@%+-]/gu,"\\$&")),lc=e=>{let t=[];for(let r of e.aliases)1===r.length&&t.push(`-s ${r}`);for(let r of(t.push(e.name),e.aliases))r.length>1&&t.push(r);return"Boolean"===e.type._tag&&t.push(`no-${e.name}`),`not __fish_contains_opt ${t.join(" ")}`},lu=e=>{let t=[`--${e.name}`];for(let r of e.aliases)t.push(1===r.length?`-${r}`:`--${r}`);return`begin; ${lc(e)}; or contains -- (commandline -poc)[-1] ${t.join(" ")}; end`},lf=e=>{let t=[`-l ${e.name}`];for(let r of e.aliases)1===r.length?t.push(`-s ${r}`):t.push(`-l ${r}`);e.description&&t.push(`-d '${ll(e.description)}'`);let r=lp(e.type);return r&&t.push(r),t},lp=e=>{switch(e._tag){case"Boolean":return;case"Choice":return`-r -f -a '${e.values.map(ld).join(" ")}'`;case"Path":return e.pathType,"-r -F";default:return"-r -f"}},lh=e=>{switch(e._tag){case"Choice":return`-r -f -a '${e.values.map(ld).join(" ")}'`;case"Path":return"-r -F";default:return}},lm=(e,t,r,n)=>{let i=((e,t)=>{if(0===e.length)return t.length>0?"__fish_use_subcommand":"";let r=e.map(e=>`__fish_seen_subcommand_from ${e}`).join("; and ");return t.length>0?`${r}; and not __fish_seen_subcommand_from ${t.join(" ")}`:r})(r,t.subcommands.map(e=>e.name)),a=i?`-n '${i}'`:"";if(!t.arguments.some(e=>"Path"===e.type._tag)){let t=[`complete -c ${e}`];a&&t.push(a),t.push("-f"),n.push(t.join(" "))}for(let r of t.subcommands){let t=[`complete -c ${e}`];a&&t.push(a),t.push(`-f -a '${ll(r.name)}'`),r.description&&t.push(`-d '${ll(r.description)}'`),n.push(t.join(" "))}for(let r of t.flags){let t="Boolean"===r.type._tag,a=t?lc(r):lu(r),s=i?`${i}; and ${a}`:a,o=s?`-n '${s}'`:"",l=[`complete -c ${e}`];if(o&&l.push(o),l.push(...lf(r)),n.push(l.join(" ")),t){let t=[`complete -c ${e}`];o&&t.push(o),t.push(`-l no-${r.name}`),r.description&&t.push(`-d '${ll(`Disable ${r.name}`)}'`),n.push(t.join(" "))}}if(t.flags.length>0){let r='not string match -q -- "-*" (commandline -ct)',a=i?`${i}; and ${r}`:r;for(let r of t.flags){let t=`${a}; and ${lc(r)}`,i="Boolean"===r.type._tag,s=[`complete -c ${e}`];if(s.push(`-n '${t}'`),s.push(`-f -a '--${r.name}'`),r.description&&s.push(`-d '${ll(r.description)}'`),n.push(s.join(" ")),i){let i=[`complete -c ${e}`];i.push(`-n '${t}'`),i.push(`-f -a '--no-${r.name}'`),r.description&&i.push(`-d '${ll(`Disable ${r.name}`)}'`),n.push(i.join(" "))}}}for(let r of t.arguments){let t=lh(r.type);if(t){let i=[`complete -c ${e}`];a&&i.push(a),i.push(t),r.description&&i.push(`-d '${ll(r.description)}'`),n.push(i.join(" "))}}for(let i of t.subcommands)lm(e,i,[...r,i.name],n)},lg=e=>e.replace(/\\/g,"\\\\").replace(/'/g,"'\\''").replace(/:/g,"\\:"),ly=e=>e.replace(/[^A-Za-z0-9_.,/@%+-]/gu,"\\$&").replace(/'/g,"'\\''"),lb=e=>e.replace(/[^a-zA-Z0-9_]/g,"_"),lv=e=>{let t=[],r=e.description?`[${lg(e.description)}]`:"",n=(e=>{switch(e._tag){case"Boolean":return"";case"Choice":return`:value:(${e.values.map(ly).join(" ")})`;case"Path":return"directory"===e.pathType?":directory:_directories":":file:_files";case"Int":return":integer:";case"Finite":return":float:";case"Date":return":date:";default:return":value:"}})(e.type),i=`(${(e=>{let t=[`--${e.name}`];for(let r of e.aliases)t.push(1===r.length?`-${r}`:`--${r}`);return"Boolean"===e.type._tag&&t.push(`--no-${e.name}`),t})(e).join(" ")})`;for(let a of(t.push(`'${i}--${e.name}${r}${n}'`),e.aliases)){let e=1===a.length?"-":"--";t.push(`'${i}${e}${a}${r}${n}'`)}if("Boolean"===e.type._tag){let r=e.description?`[${lg(`Disable ${e.name}`)}]`:"";t.push(`'${i}--no-${e.name}${r}'`)}return t},l_=e=>{let t=e.description?lg(e.description):e.name,r=(e=>{switch(e._tag){case"Choice":return`(${e.values.map(ly).join(" ")})`;case"Path":return"directory"===e.pathType?"_directories":"_files";default:return""}})(e.type),n=e.variadic?"*":"";return`'${n}:${t}:${r}'`},lx=(e,t,r)=>{let n=[...t,e.name],i=`_${n.map(lb).join("_")}`;if(r.push(`${i}() {`),e.subcommands.length>0){for(let t of(r.push(" local context state state_descr line"),r.push(" typeset -A opt_args"),r.push(""),r.push(" local -a commands"),r.push(" commands=("),e.subcommands)){let e=t.description?lg(t.description):"";r.push(` '${t.name}:${e}'`)}for(let t of(r.push(" )"),r.push(""),r.push(" local -a specs"),r.push(" specs=("),e.flags))for(let e of lv(t))r.push(` ${e}`);if(e.arguments.length>0){for(let t of(r.push(" -"),r.push(" parent-arguments"),e.arguments))r.push(` ${l_(t)}`);r.push(" -"),r.push(" subcommands")}for(let t of(r.push(" '1:command:->command'"),r.push(" '*::arg:->args'"),r.push(" )"),r.push(""),r.push(' _arguments -C "${specs[@]}"'),r.push(""),r.push(' case "$state" in'),r.push(" command)"),r.push(" _describe -t commands 'commands' commands"),r.push(" ;;"),r.push(" args)"),r.push(' case "$words[1]" in'),e.subcommands)){let e=`_${[...n,t.name].map(lb).join("_")}`;r.push(` ${t.name})`),r.push(` ${e}`),r.push(" ;;")}r.push(" esac"),r.push(" ;;"),r.push(" esac")}else{let t=[];for(let r of e.flags)t.push(...lv(r));for(let r of e.arguments)t.push(l_(r));if(t.length>0){for(let e of(r.push(" local -a specs"),r.push(" specs=("),t))r.push(` ${e}`);r.push(" )"),r.push(' _arguments "${specs[@]}"')}}for(let t of(r.push("}"),r.push(""),e.subcommands))lx(t,n,r)},lw=e=>oP({name:e,primitiveType:ow,kind:"flag"}),lk=(e,t)=>oN("flag",e,t.map(e=>[e,e])),lS=(0,W.XY)(2,(e,t)=>oj(e,t)),lI=(0,W.XY)(2,(e,t)=>oD(e,t)),l$=(0,W.XY)(2,(e,t)=>oY(e,t)),lE=e=>oL(e),lO=(0,W.XY)(2,(e,t)=>oU(e,t)),lC=(0,W.XY)(3,(e,t,r)=>oJ(e,t,r));var lT=n(2275);let lM="~effect/cli/Command/Config/Internal",lP=e=>{let t=[],r=[],n=[];return{[lM]:lM,flags:r,arguments:n,orderedParams:t,tree:function e(i){let a=Object.create(null);for(let s of Object.keys(i))a[s]=function i(a){if(Array.isArray(a))return{_tag:"Array",children:a.map(e=>i(e))};if(!em.i5(a,oO))return{_tag:"Nested",tree:e(a)};{let e=t.length;return t.push(a),"argument"===a.kind?n.push(a):r.push(a),{_tag:"Param",index:e}}}(i[s]);return a}(e)}},lA=lP({}),lN=(e,t)=>{switch(e._tag){case"Param":return{_tag:"Param",index:e.index+t};case"Array":return{_tag:"Array",children:e.children.map(e=>lN(e,t))};case"Nested":return{_tag:"Nested",tree:lR(e.tree,t)}}},lR=(e,t)=>{let r=Object.create(null);for(let n of Object.keys(e))r[n]=lN(e[n],t);return r},lj=(e,t)=>{let r=e.orderedParams.length;return{[lM]:lM,flags:[...e.flags,...t.flags],arguments:[...e.arguments,...t.arguments],orderedParams:[...e.orderedParams,...t.orderedParams],tree:Object.assign(Object.create(null),e.tree,lR(t.tree,r))}},lD=(e,t)=>{let r={};for(let n of Object.keys(e))lT.x(r,n,function e(r){switch(r._tag){case"Param":return t[r.index];case"Array":return r.children.map(t=>e(t));case"Nested":return lD(r.tree,t)}}(e[n]));return r},lU="~effect/cli/Command",lF=e=>e,lB={...tL.bp({label:"Command",evaluate(){return lF(this).service}})},lL=e=>{let t=e.config,r=e.contextConfig??lA,n=e.service??ee.kl(`${lU}/${e.name}`),i=e.annotations??ee.Ie(),a=e.globalFlags??[],s=e.subcommands??[],o=e.parse??lJ(t),l=e.parseContext??lJ(r,{allowLeftovers:!0});return Object.assign(Object.create(lB),{[lU]:lU,name:e.name,examples:e.examples??[],annotations:i,globalFlags:a,subcommands:s,unlisted:e.unlisted??!1,config:t,contextConfig:r,service:n,parse:o,parseContext:l,handle:(t,r)=>em.EA(e.handle)?e.handle(t,r):L.fJG(new oh({commandPath:r,errors:[]})),buildHelpDoc:r=>{let n=[],a=[];for(let e of t.arguments){let t=oQ(e),r=o0(e);for(let e of t)n.push({name:e.name,type:e.typeName??oI(e.primitiveType),description:e.description,required:!r.isOptional&&(!r.isVariadic||et.exists(r.variadicMin,e=>e>0)),variadic:r.isVariadic})}let o=r.length>0?r.join(" "):e.name;for(let e of(s.some(e=>e.commands.some(e=>!e.unlisted))&&(o+=" <subcommand>"),o+=" [flags]",n)){let t=e.variadic?`<${e.name}...>`:`<${e.name}>`;o+=` ${e.required?t:`[${t}]`}`}for(let e of t.flags){let t=oQ(e),r=o0(e);for(let e of t)e.hidden||a.push(lz(e,r))}let l=[];for(let e of s){let t=e.commands.filter(e=>!e.unlisted);0!==t.length&&l.push({group:e.group,commands:Q.Tj(t,e=>({name:e.name,alias:e.alias,shortDescription:e.shortDescription,description:e.description??""}))})}let d=e.examples??[];return{description:e.description??"",usage:o,flags:a,annotations:i,...n.length>0&&{args:n},...l.length>0&&{subcommands:l},...d.length>0&&{examples:d}}},...em.EA(e.description)?{description:e.description}:{},...em.EA(e.shortDescription)?{shortDescription:e.shortDescription}:{},...em.EA(e.alias)?{alias:e.alias}:{}})},lz=(e,t)=>{let r=e.aliases.map(e=>1===e.length?`-${e}`:`--${e}`);return{name:e.name,aliases:r,type:e.typeName??oI(e.primitiveType),description:lW(e.description,o$(e.primitiveType)),required:"Boolean"!==e.primitiveType._tag&&!t.isOptional}},lW=(e,t)=>{if(void 0===t||0===t.length)return e;let r=`(choices: ${t.join(", ")})`;return et.match(e,{onNone:()=>et.some(r),onSome:e=>et.some(`${e} ${r}`)})},lJ=(e,t)=>L.D9k(function*(r){let n={flags:r.flags,arguments:r.arguments},[i,a]=yield*lY(n,e.orderedParams);return t?.allowLeftovers!==!0&&i.length>0?yield*new od({arguments:i}):lD(e.tree,a)}),lY=L.D9k(function*(e,t){let r=[],n=e.arguments;for(let i of t){let[t,a]=yield*i.parse({flags:e.flags,arguments:n});r.push(a),n=t}return[n,r]}),lX=(e,t,r)=>{let n=lF(e),i=new Set;for(let e of(r?.contextConfig??n.contextConfig).flags)for(let t of oQ(e))i.add(t.name);for(let r of t)for(let t of lF(r).config.flags)for(let n of oQ(t))if(i.has(n.name))throw new os({option:n.name,parentCommand:e.name,childCommand:r.name})},lq=e=>{switch(e.primitiveType._tag){case"Boolean":return{_tag:"Boolean"};case"Int":return{_tag:"Int"};case"Finite":return{_tag:"Finite"};case"Date":return{_tag:"Date"};case"Choice":return{_tag:"Choice",values:o$(e.primitiveType)??[]};case"Path":return{_tag:"Path",pathType:oE(e.primitiveType)??"either"};case"FileText":case"FileParse":case"FileSchema":return{_tag:"Path",pathType:"file"};default:return{_tag:"String"}}},lG=e=>{switch(e.primitiveType._tag){case"Int":return{_tag:"Int"};case"Finite":return{_tag:"Finite"};case"Date":return{_tag:"Date"};case"Choice":return{_tag:"Choice",values:o$(e.primitiveType)??[]};case"Path":return{_tag:"Path",pathType:oE(e.primitiveType)??"either"};case"FileText":case"FileParse":case"FileSchema":return{_tag:"Path",pathType:"file"};default:return{_tag:"String"}}},lV=(e,t=[])=>{let r=lF(e),n=r.config,i=[],a=new Set;for(let[e,r]of[...n.flags,...t].entries())for(let t of oQ(r))"flag"===t.kind&&!t.hidden&&(e>=n.flags.length&&a.has(t.name)||(a.add(t.name),i.push({name:t.name,aliases:t.aliases,description:et.getOrUndefined(t.description),type:lq(t)})));let s=[];for(let e of n.arguments){let t=oQ(e),r=o0(e);for(let e of t)"argument"===e.kind&&s.push({name:e.name,description:et.getOrUndefined(e.description),required:!r.isOptional,variadic:r.isVariadic,type:lG(e)})}let o=[],l=[...t,...r.contextConfig.flags];for(let t of e.subcommands)for(let e of t.commands){if(e.unlisted)continue;let t=lV(e,l);o.push(t),e.alias&&e.alias!==e.name&&o.push({...t,name:e.alias})}return{name:e.name,description:e.shortDescription??e.description,flags:i,arguments:s,subcommands:o}},lH=e=>{let t=new Set,r=[];for(let n of e)t.has(n)||(t.add(n),r.push(n));return r},lK=(e,t)=>{let r=[e],n=e;for(let e=1;e<t.length;e++){let i,a=t[e];for(let e of n.subcommands)if(i=e.commands.find(e=>e.name===a))break;if(!i)break;r.push(i),n=i}return r},lQ=(e,t,r)=>{let n=lK(e,t).flatMap(e=>lF(e).globalFlags);return lH([...r,...n])},lZ=(e,t,r)=>L.JkU(function*(){let n=lK(e,t),i=lF(n.length>0?n[n.length-1]:e).buildHelpDoc(t),a=((e,t)=>{if(e.length<=1)return[];let r=new Set(t.map(e=>e.name)),n=[];for(let t of e.slice(0,-1))for(let e of lF(t).contextConfig.flags){let t=oQ(e),i=o0(e);for(let e of t)!r.has(e.name)&&(e.hidden||(r.add(e.name),n.push(lz(e,i))))}return n})(n,i.flags),s=lQ(e,t,r),o=[];for(let e of s){let t=oQ(e.flag),r=o0(e.flag);for(let e of t)e.hidden||o.push({...lz(e,r),required:!1})}return{...i,flags:[...a,...i.flags],globalFlags:o}}),l0=e=>({_tag:"Action",flag:e.flag,run:e.run}),l1=0,l2=l0({flag:(lw("help")).pipe(lS("h"),lI("Show help information"),oz(!1)),run:L.D9k(function*(e,{builtIns:t,command:r,commandPath:n}){let i=yield*o2,a=yield*lZ(r,n,t);yield*on(i.formatHelpDoc(a))})}),l5=l0({flag:(lw("version")).pipe(lS("v"),lI("Show version information"),oz(!1)),run:L.D9k(function*(e,{command:t,version:r}){let n=yield*o2;yield*on(n.formatVersion(t.name,r))})}),l3=l0({flag:(lw("wizard")).pipe(lI("Start wizard mode for a command"),oz(!1)),run:()=>L.rIH}),l6=l0({flag:(lk("completions",["bash","zsh","fish","sh"])).pipe(lE,lO(e=>et.map(e,e=>"sh"===e?"bash":e)),l$("<bash|zsh|fish|sh>"),lI("Print shell completion script")),run:L.D9k(function*(e,{command:t}){if(et.isNone(e))return;let r=lV(t);yield*on(((e,t,r)=>{switch(t){case"bash":return((e,t)=>{let r=[],n=ln(e),i=`_${n}--choices`;return r.push(`###-begin-${e.replace(/'/g,"'\\''")}-completions-###`),r.push("#"),r.push("# Static completion script for Bash"),r.push("#"),r.push("# Installation:"),r.push(`# ${e.replace(/'/g,"'\\''")} --completions bash >> ~/.bashrc`),r.push("#"),r.push(""),r.push("if ! type _init_completion &>/dev/null; then"),r.push(" _init_completion()"),r.push(" {"),r.push(" COMPREPLY=()"),r.push(' local _i _j=0 _piece _line="$COMP_LINE"'),r.push(' words=("${COMP_WORDS[0]}")'),r.push(" cword=0"),r.push(' _line="${_line#*"${COMP_WORDS[0]}"}"'),r.push(" for ((_i = 1; _i < ${#COMP_WORDS[@]}; _i++)); do"),r.push(' _piece="${COMP_WORDS[_i]}"'),r.push(' if [[ "$_line" == [[:blank:]]* ]]; then'),r.push(" ((_j++))"),r.push(' words[_j]="$_piece"'),r.push(" else"),r.push(' words[_j]="${words[_j]}$_piece"'),r.push(" fi"),r.push(" ((_i == COMP_CWORD)) && cword=$_j"),r.push(' _line="${_line#*"$_piece"}"'),r.push(" done"),r.push(' cur="${words[cword]}"'),r.push(' prev=""'),r.push(' ((cword > 0)) && prev="${words[cword-1]}"'),r.push(" return 0"),r.push(" }"),r.push("fi"),r.push(""),r.push(`${i}()`),r.push("{"),r.push(' local _cur="$1" _word="$2"; shift 2'),r.push(""),r.push(' local _head="${_cur%"$_word"}"'),r.push(' local _open=""'),r.push(' case "$_head" in'),r.push(" *\\') _open=\"'\" ;;"),r.push(" *\\\") _open='\"' ;;"),r.push(" esac"),r.push(""),r.push(' local _prefix="$_cur" _committed="$_head"'),r.push(" _prefix=${_prefix//\\\\/}; _prefix=${_prefix//\\\"/}; _prefix=${_prefix//\\'/}"),r.push(" _committed=${_committed//\\\\/}; _committed=${_committed//\\\"/}; _committed=${_committed//\\'/}"),r.push(""),r.push(" COMPREPLY=()"),r.push(" local _choice _rest _match"),r.push(' for _choice in "$@"; do'),r.push(' [[ "$_choice" == "$_prefix"* ]] || continue'),r.push(' _rest="${_choice#"$_committed"}"'),r.push(' case "$_open" in'),r.push(' "\'")'),r.push(' if [[ "$_head" == "\'" ]]; then'),r.push(" _match=${_rest//\\'/\\'\\\\\\'\\'}"),r.push(" else"),r.push(' [[ "$_rest" == *\\\'* ]] && continue'),r.push(' _match="$_rest"'),r.push(" fi"),r.push(" ;;"),r.push(" '\"')"),r.push(' _match="${_rest//\\\\/\\\\\\\\}"'),r.push(' _match="${_match//\\$/\\\\$}"'),r.push(' _match="${_match//\\`/\\\\\\`}"'),r.push(' _match="${_match//\\"/\\\\\\"}"'),r.push(" ;;"),r.push(" *)"),r.push(" printf -v _match '%q' \"$_rest\""),r.push(' [[ -z "$_head" && "$_match" == \'~\'* ]] && _match="\\\\$_match"'),r.push(" ;;"),r.push(" esac"),r.push(' [[ -n "$_open" && "$_match" == *"$_open" ]] && _match+="$_open"'),r.push(' COMPREPLY+=("$_match")'),r.push(" done"),r.push("}"),r.push(""),lo(t,[],r,i),r.push(`complete -F _${n} ${e.replace(/'/g,"'\\''")}`),r.push(`###-end-${e.replace(/'/g,"'\\''")}-completions-###`),r.join("\n")})(e,r);case"zsh":let n,i;return n=[],i=lb(e),n.push(`#compdef ${e}`),n.push(`###-begin-${e}-completions-###`),n.push("#"),n.push("# Static completion script for Zsh"),n.push("#"),n.push("# Installation:"),n.push(`# ${e} --completions zsh > ~/.zsh/completions/_${e}`),n.push("# then add ~/.zsh/completions to your fpath"),n.push("#"),n.push(""),lx(r,[],n),n.push("# Handle both direct invocation and autoload"),n.push('if [[ "${zsh_eval_context[-1]}" == "loadautofunc" ]]; then'),n.push(` _${i} "$@"`),n.push("else"),n.push(` compdef _${i} ${e}`),n.push("fi"),n.push(`###-end-${e}-completions-###`),n.join("\n");case"fish":let a;return(a=[]).push(`###-begin-${e}-completions-###`),a.push("#"),a.push("# Static completion script for Fish"),a.push("#"),a.push("# Installation:"),a.push(`# ${e} --completions fish > ~/.config/fish/completions/${e}.fish`),a.push("#"),a.push(""),lm(e,r,[],a),a.push(""),a.push(`###-end-${e}-completions-###`),a.join("\n")}})(t.name,e.value,r))})}),l8=(A="log-level",e=>(l1+=1,Object.assign(ee.kl(`effect/cli/GlobalFlag/${A}/${l1}`),{_tag:"Setting",id:A,flag:e.flag})))({flag:oN("flag","log-level",[["all","All"],["trace","Trace"],["debug","Debug"],["info","Info"],["warn","Warn"],["warning","Warn"],["error","Error"],["fatal","Fatal"],["none","None"]]).pipe(lE,lI("Sets the minimum log level"),l$("<all|trace|debug|info|warn|warning|error|fatal|none>"))}),l9=[l2,l5,l3,l6,l8];class l4 extends ee.Or("effect/cli/CliConfig",{defaultValue:()=>l7}){}let l7={builtIns:l9},de=/^-(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?$/,dt=e=>{let t=[];for(let r of e)if(!r.startsWith("-")||de.test(r))t.push({_tag:"Value",value:r});else if(r.startsWith("--")){let e=r.indexOf("=");if(-1!==e){let n=r.slice(2,e),i=r.slice(e+1);t.push({_tag:"LongOption",name:n,raw:r,value:i})}else t.push({_tag:"LongOption",name:r.slice(2),raw:r})}else if(r.length>1){let e=r.slice(1),n=e.indexOf("=");if(-1!==n){let r=e.slice(0,n),i=e.slice(n+1);t.push({_tag:"ShortOption",flag:r,raw:`-${r}`,value:i})}else for(let r of e)t.push({_tag:"ShortOption",flag:r,raw:`-${r}`})}else t.push({_tag:"Value",value:r});return t},dr=(e,t)=>{let r=t.map(t=>[((e,t)=>{let r=e.length,n=t.length,i=Array.from({length:r+1},()=>Array(n+1).fill(0));for(let e=0;e<=r;e++)i[e][0]=e;for(let e=0;e<=n;e++)i[0][e]=e;for(let a=1;a<=r;a++)for(let r=1;r<=n;r++){let n=+(e[a-1]!==t[r-1]);i[a][r]=Math.min(i[a-1][r]+1,i[a][r-1]+1,i[a-1][r-1]+n)}return i[r][n]})(e,t),t]).filter(([e])=>e<=2).sort(([e],[t])=>e-t);if(0===r.length)return[];let n=r[0][0];return r.filter(([e])=>e===n).map(([,e])=>e)},dn=e=>et.match(e.subcommand,{onNone:()=>[],onSome:e=>[e.name,...dn(e.parsedInput)]}),di=(e,t,r=[])=>L.JkU(function*(){let{tokens:n,trailingOperands:i}=e,a=[...r,t.name],s=lF(t),o=s.config.flags.flatMap(oQ).filter(oM),l=ds(o),d=s.contextConfig.flags.flatMap(oQ).filter(oM),c=ds(d),u=new Set(d.map(e=>e.name)),f=dw(n,{command:t,commandPath:a,flagRegistry:l,inheritedFlagRegistry:c,localFlagNames:o.filter(e=>!u.has(e.name)).map(e=>e.name)});if("Leaf"===f._tag)return{flags:f.flags,arguments:[...f.arguments,...i],subcommand:et.none(),...f.errors.length>0&&{errors:f.errors}};let p={tokens:f.childTokens,trailingOperands:i},h=yield*di(p,f.sub,a),m=[...f.errors,...h.errors??[]];return{flags:f.flags,arguments:[],subcommand:et.some({name:f.sub.name,parsedInput:h}),...m.length>0&&{errors:m}}}),da=e=>{let t=0;return{peek:()=>e[t],take:()=>e[t++],rest:()=>e.slice(t)}},ds=e=>{let t=new Map;for(let r of e){if(t.has(r.name))throw Error(`Duplicate flag name "${r.name}" in command definition`);for(let e of(t.set(r.name,r),r.aliases)){if(t.has(e))throw Error(`Duplicate flag/alias "${e}" in command definition (conflicts with "${t.get(e).name}")`);t.set(e,r)}}return{params:e,index:t}},dl=e=>{let t=new Map,r=(e,r)=>{let n=t.get(e);if(n&&n!==r)throw Error(`Duplicate subcommand name/alias "${e}" in command definition (conflicts with "${n.name}")`);t.set(e,r)};for(let t of e)for(let e of t.commands)r(e.name,e),e.alias&&e.alias!==e.name&&r(e.alias,e);return t},dd=e=>Object.fromEntries(e.map(e=>[e.name,[]])),dc=e=>"LongOption"===e._tag||"ShortOption"===e._tag,du=e=>"LongOption"===e._tag?e.name:e.flag,df=(e,t)=>{let r=du(e),n=t.index.get(r);if(n&&n.name===r)return{param:n,negated:!1};if("LongOption"===e._tag&&e.name.startsWith("no-")){let r=e.name.slice(3),n=t.index.get(r);if(n&&n.name===r&&ov(n.primitiveType))return{param:n,negated:!0}}if(n)return{param:n,negated:!1}},dp=(e,t,r)=>new oc({option:t.name,value:r,expected:`omit the value and use ${e.raw} by itself to set --${t.name} to false`,kind:"flag"}),dh=e=>e?._tag==="Value"&&(oy(e.value)||ob(e.value))?e.value:void 0,dm=(e,t,r,n=!1)=>{let i=dg(e,t,r,n);switch(i._tag){case"Value":return{_tag:"Value",value:i.value};case"Error":return{_tag:"Error",error:i.error}}},dg=(e,t,r,n=!1)=>{let i;if(n){if(void 0!==t.value)return{_tag:"Error",error:dp(t,r,t.value),tokens:[]};let n=dh(e.peek());if(void 0!==n){let i=e.take();return{_tag:"Error",error:dp(t,r,n),tokens:void 0===i?[]:[i]}}return{_tag:"Value",value:"false",tokens:[]}}if(void 0!==t.value)return{_tag:"Value",value:t.value,tokens:[]};if(ov(r.primitiveType)){let t=dh(e.peek()),r=void 0!==t?e.take():void 0;return{_tag:"Value",value:t??"true",tokens:void 0===r?[]:[r]}}let a=e.peek();if(a?._tag==="Value"){let t=e.take();return{_tag:"Value",value:a.value,tokens:void 0===t?[]:[t]}}return{_tag:"Error",error:(i=o$(r.primitiveType),new oc({option:r.name,value:"",expected:void 0===i?r.typeName??oI(r.primitiveType):i.join(" | "),kind:"flag"})),tokens:[]}},dy=(e,t)=>{for(let r of t){let t=df(e,r);if(void 0!==t)return t}},db=(e,t,r,n)=>{e.push(r);let i=dg(t,r,n.param,n.negated);e.push(...i.tokens)},dv=(e,t,r,n,i)=>{let a=da(t);dg(a,e,r.param,r.negated);for(let e=a.take();e;e=a.take()){if(dc(e)){let t=dy(e,i);void 0!==t&&dg(a,e,t.param,t.negated);continue}if("Value"===e._tag)return n.has(e.value)}return!1},d_=(e,t,r,n)=>{let{commandPath:i,flagRegistry:a}=r,s=df(e,a);if(!s)return void n.errors.push(((e,t,r)=>{let n="LongOption"===e._tag?`--${e.name}`:`-${e.flag}`,i=[];for(let e of t)if(!e.hidden)for(let t of(i.push(e.name),ov(e.primitiveType)&&i.push(`no-${e.name}`),e.aliases))i.push(t);return new oa({option:n,suggestions:dr(du(e),i).map(e=>1===e.length?`-${e}`:`--${e}`),command:r})})(e,a.params,i));let o=dm(t,e,s.param,s.negated);"Error"===o._tag?n.errors.push(o.error):n.flags.add(s.param.name,o.value)},dx=(e,t,r,n)=>{if("AwaitingFirstValue"===n.mode._tag){let i=((e,t,r,n)=>{let{command:i,commandPath:a,inheritedFlagRegistry:s,localFlagNames:o}=r,l=dl(i.subcommands),d=l.get(e);if(d){let e=[...a,d.name],r=n.flags.snapshot();for(let t of o){let i=r[t];void 0!==i&&i.length>0&&n.errors.push(new oa({option:`--${t}`,suggestions:[],command:e}))}let i=((e,t)=>{let r=dd(t.params),n=[],i=[],a=da(e);for(let e=a.take();e;e=a.take()){if(!dc(e)){n.push(e);continue}let s=df(e,t);if(!s){n.push(e);continue}let o=dm(a,e,s.param,s.negated);if("Error"===o._tag){i.push(o.error);continue}void 0!==o.value&&r[s.param.name].push(o.value)}return{flagMap:r,remainder:n,errors:i}})(t.rest(),s);return n.flags.merge(i.flagMap),n.errors.push(...i.errors),{_tag:"Subcommand",result:{_tag:"Sub",flags:n.flags.snapshot(),sub:d,childTokens:i.remainder,errors:n.errors}}}if(!(lF(i).config.arguments.length>0)&&l.size>0){let t=[];for(let[e,r]of l)r.unlisted||t.push(e);let r=dr(e,t);n.errors.push(new ou({subcommand:e,parent:a,suggestions:r}))}return{_tag:"Argument"}})(e,t,r,n);if("Subcommand"===i._tag)return i.result;n.mode={_tag:"CollectingArguments"}}n.arguments.push(e)},dw=(e,t)=>{let r,n=da(e),i={flags:(r=dd(t.flagRegistry.params),{add:(e,t)=>{void 0!==t&&r[e].push(t)},merge:e=>{for(let t in e){let n=e[t];if(n?.length)for(let e=0;e<n.length;e++)r[t].push(n[e])}},snapshot:()=>r}),arguments:[],errors:[],mode:{_tag:"AwaitingFirstValue"}};for(let e=n.take();e;e=n.take()){if(dc(e)){d_(e,n,t,i);continue}if("Value"===e._tag){let r=dx(e.value,n,t,i);if(r)return r}}return{_tag:"Leaf",flags:i.flags.snapshot(),arguments:i.arguments,errors:i.errors}};var dk=n(7011),dS=n(7876),dI=n(2860);em.Et,dI.wN,dS.wN;let d$=(0,W.XY)(2,(e,t)=>{let r=Math.pow(10,t);return Math.round(e*r)/r}),dE=(e,...t)=>{let r=t.flat();return`${r.join("")}${e}\x1b[0m`},dO={prefix:"?",arrowUp:"↑",arrowDown:"↓",checkboxOn:"☒",checkboxOff:"☐",tick:"✔",ellipsis:"…",pointerSmall:"›",pointer:"❯",descriptionSeparator:"- ",passwordMask:"*",toggleSeparator:"/",primaryColor:"\x1b[96m",mutedColor:"\x1b[90m",successColor:"\x1b[32m",errorColor:"\x1b[31m",submittedColor:"\x1b[37m"},dC={...dO,checkboxOn:"[*]",checkboxOff:"[ ]",tick:"√",ellipsis:"...",pointerSmall:"»",pointer:">"},dT=ee.Or("effect/cli/Prompt/Theme",{defaultValue:e=>({..."win32"===process.platform?dC:dO,...e})}),dM=e=>L.TjK(dT,t=>({...t,...e.theme})),dP=e=>dE(e,"\x1b[1m"),dA=(e,t)=>dE(e,((...e)=>e)("\x1b[3m",t)),dN=(e,...t)=>0===e.length?"":dE(e,...t),dR=(e,t)=>0===e.length?t:e+" "+t,dj=e=>{let t={initial:!1,...e,label:{confirm:"yes",deny:"no",...e.label},placeholder:{defaultConfirm:"(Y/n)",defaultDeny:"(y/N)",...e.placeholder}};return dD({value:t.initial},{render:d2(t),process:e=>d6(e,t.initial),clear:dQ(t)})},dD=(e,...t)=>{let[r,n]=1===t.length?[void 0,t[0]]:[t[0],t[1]],i=Object.create(dY);return i._tag="Loop",i.initialState=e,i.render=n.render,i.process=n.process,i.clear=n.clear,i.events=r,i},dU=(0,W.XY)(2,(e,t)=>{let r=Object.create(dY);return r._tag="OnSuccess",r.prompt=e,r.onSuccess=t,r}),dF=e=>{let t={default:0,min:globalThis.Number.NEGATIVE_INFINITY,max:globalThis.Number.POSITIVE_INFINITY,incrementBy:1,decrementBy:1,validate:e=>e<t.min?L.fJG(`${e} must be greater than or equal to ${t.min}`):e>t.max?L.fJG(`${e} must be less than or equal to ${t.max}`):L.PyW(e),...e},r=void 0===e.default?"":`${t.default}`;return dD({cursor:r.length,value:r,error:et.none()},{render:cw(t),process:ck(t),clear:cm(t)})},dB=(0,W.XY)(2,(e,t)=>dU(e,e=>dW(t(e)))),dL=L.D9k(function*(e){let t=yield*n$,r=yield*t.readInput;return yield*dX(e,t,r)},L.xm_(()=>new nI({})),L.P1j),dz=e=>{let t={maxPerPage:10,...e};return dD((e=>{let t=0,r=-1;for(let t=0;t<e.length;t++)if(!0===e[t].selected){if(-1!==r)throw Error("InvalidArgumentException: only a single choice can be selected by default for Prompt.Select");r=t}return -1!==r&&(t=r),t})(t.choices),{render:cM(t),process:cA(t),clear:cP(t)})},dW=e=>{let t=Object.create(dY);return t._tag="Succeed",t.value=e,t},dJ=e=>{let t={initial:!1,active:"on",inactive:"off",...e};return dD(t.initial,{render:cV(t),process:cH,clear:()=>cz(t)})},dY={...tL.bp({label:"Prompt",evaluate(){return dL(this)}}),"~effect/cli/Prompt":{_Output:e=>e}},dX=(e,t,r)=>L.DYE(()=>{switch(e._tag){case"Loop":return dq(e,t,r);case"OnSuccess":return L.qIB(dX(e.prompt,t,r),n=>dX(e.onSuccess(n),t,r));case"Succeed":return L.PyW(e.value)}}),dq=L.D9k(function*(e,t,r){let n=L.yw5(e.initialState)?yield*e.initialState:e.initialState,i=dG.NextFrame({state:n}),a="";for(;;){let s=yield*e.render(n,i);if(yield*L.QgK(t.display(a+s)),a="",e.events){let t=eD(r).pipe(L.TjK(e=>({_tag:"Input",input:e}))),a=yield*L.KT6(t,eD(e.events).pipe(L.TjK(e=>({_tag:"Event",value:e}))));i=yield*e.process(a,n)}else{let t=yield*eD(r);i=yield*e.process(t,n)}switch(i._tag){case"Beep":continue;case"NextFrame":a=yield*e.clear(n,i),n=i.state;continue;case"Submit":{a=yield*e.clear(n,i);let r=yield*e.render(n,i);return yield*L.QgK(t.display(a+r)),i.value}}}},(e,t,r)=>L.yeE(e,L.QgK(r.display("\x1b[?25h")))),dG=er.Ij(),dV=(e,t)=>{if(0===t)return"\x1b[2K\x1b[1G";let r=0;for(let n of e.split(dK))r+=1+Math.floor(Math.max(n.length-1,0)/t);var n=r;let i="";for(let e=0;e<n;e++)i+="\x1b[2K"+(e<n-1?"\x1b[1A":"");return n>0&&(i+="\x1b[G"),i},dH=(e,t,r)=>{if(void 0!==r&&r.length>0){let n;return((e=1)=>`\x1b[${e}B`)((n=r.split(dK),0===t?n.length:(0,W.Fs)(Q.Tj(n,e=>Math.ceil(e.length/t)),Q.TS(0,(e,t)=>e+t))))+dV(`
54
- ${r}`,t)+dV(e,t)}return dV(e,t)},dK=/\r?\n/,dQ=e=>L.D9k(function*(t,r){let n=yield*n$,i=yield*n.columns,a=yield*dM(e);return dV(dZ(t.value?e.placeholder.defaultConfirm:e.placeholder.defaultDeny,a.prefix,a.pointerSmall,e,{plain:!0}),i)+"\x1b[2K\x1b[G"}),dZ=(e,t,r,n,i)=>cp(e,n.message,t,r,i),d0=L.D9k(function*(e,t){let r=yield*dM(t),n=dN(r.prefix,r.primaryColor),i=dN(r.pointerSmall,r.mutedColor);return"\x1b[?25l"+dZ(dE(e.value?t.placeholder.defaultConfirm:t.placeholder.defaultDeny,r.mutedColor),n,i,t)}),d1=L.D9k(function*(e,t){let r=yield*dM(t),n=dN(r.tick,r.successColor),i=dN(r.ellipsis,r.mutedColor);return dZ(e?t.label.confirm:t.label.deny,n,i,t)+"\n"}),d2=e=>(t,r)=>dG.$match(r,{Beep:()=>L.PyW("\x07"),NextFrame:({state:t})=>d0(t,e),Submit:({value:t})=>d1(t,e)}),d5=/^y|t$/,d3=/^n|f$/,d6=(e,t)=>{let r=et.getOrElse(e.input,()=>"");return"enter"===e.key.name||"return"===e.key.name?L.PyW(dG.Submit({value:t})):d5.test(r.toLowerCase())?L.PyW(dG.Submit({value:!0})):d3.test(r.toLowerCase())?L.PyW(dG.Submit({value:!1})):L.PyW(dG.Beep())},d8=(e,t,r=!1)=>Q.TS(e.dateParts,"",(n,i,a)=>{let s=i.toString();return a!==e.cursor||r?n+s:n+dE(s,((...e)=>e)("\x1b[4m",t.primaryColor))}),d9=(e,t,r,n,i)=>cp(r,n.message,e,t,i),d4=L.D9k(function*(e,t){let r=yield*dM(t);return"\x1b[?25l"+d9(dN(r.prefix,r.primaryColor),dN(r.pointerSmall,r.mutedColor),d8(e,r),t)+((e,t,r)=>{if(et.isSome(e.error)){let n=e.error.value.split(dK);if(Q.ET(n))return"\x1b[s\n"+dR(dN(t,r.errorColor),Q.Tj(n,e=>dA(e,r.errorColor)).join("\n"))+"\x1b[u"}return""})(e,r.pointerSmall,r)}),d7=L.D9k(function*(e,t){let r=yield*dM(t);return d9(dN(r.tick,r.successColor),dN(r.ellipsis,r.mutedColor),d8(e,r,!0),t)+"\n"}),ce={months:["January","February","March","April","May","June","July","August","September","October","November","December"],monthsShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],weekdays:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],weekdaysShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]},ct=/\\(.)|"((?:\\["\\]|[^"])+)"|(D[Do]?|d{3,4}|d)|(M{1,4})|(YY(?:YY)?)|([aA])|([Hh]{1,2})|(m{1,2})|(s{1,2})|(S{1,4})|./g,cr={1:({token:e,...t})=>new ci({token:e.replace(/\\(.)/g,"$1"),...t}),2:e=>new cd(e),3:e=>new cc(e),4:e=>new cu(e),5:e=>new cf(e),6:e=>new cl(e),7:e=>new co(e),8:e=>new cs(e),9:e=>new ca(e)};class cn{token;date;parts;locales;constructor(e){this.token=e.token,this.locales=e.locales,this.date=e.date||new globalThis.Date,this.parts=e.parts||[this]}isToken(){return!1}nextPart(){let e=et.getOrElse(Q.g9(this.parts,e=>e===this),()=>0);return Q.i8(this.parts.slice(e+1),e=>!e.isToken())}previousPart(){let e=Q.g9(this.parts,e=>e===this);return et.isSome(e)?Q.Uk(this.parts.slice(0,e.value),e=>!e.isToken()):et.none()}toString(){return globalThis.String(this.date)}}class ci extends cn{increment(){}decrement(){}setValue(e){this.token=this.token+e}isToken(){return!0}toString(){return this.token}}class ca extends cn{increment(){this.date.setMilliseconds(this.date.getMilliseconds()+1)}decrement(){this.date.setMilliseconds(this.date.getMilliseconds()-1)}setValue(e){this.date.setMilliseconds(globalThis.Number.parseInt(e.slice(-this.token.length)))}toString(){return`${this.date.getMilliseconds()}`.padStart(4,"0").substring(0,this.token.length)}}class cs extends cn{increment(){this.date.setSeconds(this.date.getSeconds()+1)}decrement(){this.date.setSeconds(this.date.getSeconds()-1)}setValue(e){this.date.setSeconds(globalThis.Number.parseInt(e.slice(-2)))}toString(){let e=`${this.date.getSeconds()}`;return this.token.length>1?e.padStart(2,"0"):e}}class co extends cn{increment(){this.date.setMinutes(this.date.getMinutes()+1)}decrement(){this.date.setMinutes(this.date.getMinutes()-1)}setValue(e){this.date.setMinutes(globalThis.Number.parseInt(e.slice(-2)))}toString(){let e=`${this.date.getMinutes()}`;return this.token.length>1?e.padStart(2,"0"):e}}class cl extends cn{increment(){this.date.setHours(this.date.getHours()+1)}decrement(){this.date.setHours(this.date.getHours()-1)}setValue(e){this.date.setHours(globalThis.Number.parseInt(e.slice(-2)))}toString(){let e=/h/.test(this.token)?this.date.getHours()%12||12:this.date.getHours();return this.token.length>1?`${e}`.padStart(2,"0"):`${e}`}}class cd extends cn{increment(){this.date.setDate(this.date.getDate()+1)}decrement(){this.date.setDate(this.date.getDate()-1)}setValue(e){this.date.setDate(globalThis.Number.parseInt(e.slice(-2)))}toString(){let e=this.date.getDate(),t=this.date.getDay();switch(this.token){case"DD":return`${e}`.padStart(2,"0");case"Do":return`${e}${this.ordinalIndicator(e)}`;case"d":return`${t+1}`;case"ddd":return this.locales.weekdaysShort[t];case"dddd":return this.locales.weekdays[t];default:return`${e}`}}ordinalIndicator(e){if(e>=11&&e<=13)return"th";switch(e%10){case 1:return"st";case 2:return"nd";case 3:return"rd";default:return"th"}}}class cc extends cn{increment(){this.date.setMonth(this.date.getMonth()+1)}decrement(){this.date.setMonth(this.date.getMonth()-1)}setValue(e){let t=globalThis.Number.parseInt(e.slice(-2))-1;this.date.setMonth(t<0?0:t)}toString(){let e=this.date.getMonth();switch(this.token.length){case 2:return`${e+1}`.padStart(2,"0");case 3:return this.locales.monthsShort[e];case 4:return this.locales.months[e];default:return`${e+1}`}}}class cu extends cn{increment(){this.date.setFullYear(this.date.getFullYear()+1)}decrement(){this.date.setFullYear(this.date.getFullYear()-1)}setValue(e){this.date.setFullYear(globalThis.Number.parseInt(e.slice(-4)))}toString(){let e=`${this.date.getFullYear()}`.padStart(4,"0");return 2===this.token.length?e.slice(-2):e}}class cf extends cn{increment(){this.date.setHours((this.date.getHours()+12)%24)}decrement(){this.increment()}setValue(e){}toString(){let e=this.date.getHours()>=12?"pm":"am";return/A/.test(this.token)?e.toUpperCase():e}}let cp=(e,t,r,n,i)=>{let a=0===r.length?"":r+" ",s=t=>{let r=a+t;return n.length>0&&(r+=" "+n),e.length>0?r+=" "+e:n.length>0&&(r+=" "),r},o=i?.plain===!0?e=>e:dP;return Q.YW(t.split(dK),{onEmpty:()=>s(""),onNonEmpty:e=>s(Q.Tj(e,e=>o(e)).join("\n"))})},ch=(e,t,r,n)=>{if(!e.disabled&&e.description&&t){let t=r.descriptionSeparator+e.description;return n?.plain===!0?t:dE(t,r.mutedColor)}return""},cm=e=>L.D9k(function*(t,r){let n=yield*n$,i=yield*n.columns,a=yield*dM(e),s=cg(t,a.pointerSmall,a,{plain:!0});return dH(cy(t,a.prefix,a.pointerSmall,e,a,{plain:!0}),i,s)+"\x1b[2K\x1b[G"}),cg=(e,t,r,n)=>et.isSome(e.error)?Q.YW(e.error.value.split(dK),{onEmpty:()=>"",onNonEmpty:e=>n?.plain===!0?dR(t,e.join("\n")):"\x1b[s\n"+dR(dN(t,r.errorColor),Q.Tj(e,e=>dA(e,r.errorColor)).join("\n"))+"\x1b[u"}):"",cy=(e,t,r,n,i,a,s=!1)=>{let o;return cp((o=""===e.value?"":`${e.value}`,s||a?.plain===!0?o:dE(o,et.isSome(e.error)?i.errorColor:((...e)=>e)("\x1b[4m",i.primaryColor))),n.message,t,r,a)},cb=L.D9k(function*(e,t){let r=yield*dM(t),n=dN(r.prefix,r.primaryColor),i=dN(r.pointerSmall,r.mutedColor),a=cg(e,r.pointerSmall,r);return cy(e,n,i,t,r)+a}),cv=L.D9k(function*(e,t){let r=yield*dM(t);return cy(e,dN(r.tick,r.successColor),dN(r.ellipsis,r.mutedColor),t,r,void 0,!0)+"\n"}),c_=e=>{if(e.value.length<=0)return L.PyW(dG.Beep());let t=e.value.slice(0,e.value.length-1);return L.PyW(dG.NextFrame({state:{...e,value:t,error:et.none()}}))},cx=e=>L.PyW(dG.NextFrame({state:{...e,cursor:0,value:"",error:et.none()}})),cw=e=>(t,r)=>dG.$match(r,{Beep:()=>L.PyW("\x07"),NextFrame:({state:t})=>cb(t,e),Submit:()=>cv(t,e)}),ck=e=>(t,r)=>{if(t.key.ctrl&&"u"===t.key.name)return cx(r);switch(t.key.name){case"backspace":return c_(r);case"k":case"up":return L.PyW(dG.NextFrame({state:{...r,value:""===r.value||"-"===r.value?`${e.incrementBy}`:`${globalThis.Number.parseInt(r.value)+e.incrementBy}`,error:et.none()}}));case"j":case"down":return L.PyW(dG.NextFrame({state:{...r,value:""===r.value||"-"===r.value?`-${e.decrementBy}`:`${globalThis.Number.parseInt(r.value)-e.decrementBy}`,error:et.none()}}));case"enter":case"return":{let t=globalThis.Number.parseInt(r.value);if(globalThis.Number.isNaN(t))return L.PyW(dG.NextFrame({state:{...r,error:et.some("Must provide an integer value")}}));return L.YWq(e.validate(t),{onFailure:e=>dG.NextFrame({state:{...r,error:et.some(e)}}),onSuccess:e=>dG.Submit({value:e})})}default:var n=et.getOrElse(t.input,()=>"");if(0===r.value.length&&"-"===n)return L.PyW(dG.NextFrame({state:{...r,value:"-",error:et.none()}}));let i=globalThis.Number.parseInt(r.value+n);return globalThis.Number.isNaN(i)?L.PyW(dG.Beep()):L.PyW(dG.NextFrame({state:{...r,value:`${i}`,error:et.none()}}))}},cS=(e,t,r,n)=>void 0===r.message?void 0:cp("",r.message,e,t,n),cI=(e,t)=>void 0===e?t:e+"\n"+t,c$=(e,t,r,n,i,a)=>{var s,o;let l,d=(s=n===r.startIndex&&r.startIndex>0,o=n===r.endIndex-1&&r.endIndex<t.length,l=Math.max(i.arrowUp.length,i.arrowDown.length),s?i.arrowUp.padEnd(l):o?i.arrowDown.padEnd(l):" ".repeat(l));if(a?.plain===!0)return e===n?i.pointer+d:d+" ".repeat(i.pointer.length);if(t[n].disabled){let t=((...e)=>e)("\x1b[1m",i.mutedColor);return e===n?dN(i.pointer,t)+d:d+" ".repeat(i.pointer.length)}return e===n?dN(i.pointer,i.primaryColor)+d:d+" ".repeat(i.pointer.length)},cE=(e,t,r,n)=>{if(n?.plain===!0)return e.title;let i=e.title;return t?e.disabled?dE(i,((...e)=>e)("\x1b[4m",r.mutedColor)):dE(i,((...e)=>e)("\x1b[4m",r.primaryColor)):e.disabled?dE(i,((...e)=>e)("\x1b[9m",r.mutedColor)):i},cO=(e,t,r,n)=>{let i=t.choices,a=cK(e,i.length,t.maxPerPage),s=[];for(let t=a.startIndex;t<a.endIndex;t++){let o=i[t],l=e===t,d=c$(e,i,a,t,r,n),c=cE(o,l,r,n),u=ch(o,l,r,n);s.push(d+c+" "+u)}return s.join("\n")},cC=L.D9k(function*(e,t){let r=yield*dM(t),n=cO(e,t,r);return"\x1b[?25l"+cI(cS(dN(r.prefix,r.primaryColor),dN(r.pointerSmall,r.mutedColor),t),n)}),cT=L.D9k(function*(e,t){let r=yield*dM(t),n=t.choices[e].title,i=dN(r.tick,r.successColor);return(cS(i,dN(r.ellipsis,r.mutedColor),t)??i)+" "+dE(n,r.submittedColor)+"\n"}),cM=e=>(t,r)=>dG.$match(r,{Beep:()=>L.PyW("\x07"),NextFrame:({state:t})=>cC(t,e),Submit:()=>cT(t,e)}),cP=e=>L.D9k(function*(t,r){let n=yield*n$,i=yield*n.columns,a=yield*dM(e);return dV(cI(cS(a.prefix,a.pointerSmall,e,{plain:!0}),cO(t,e,a,{plain:!0})),i)+"\x1b[2K\x1b[G"}),cA=e=>(t,r)=>{var n;switch(t.key.name){case"k":case"up":return n=e.choices,0===r?L.PyW(dG.NextFrame({state:n.length-1})):L.PyW(dG.NextFrame({state:r-1}));case"j":case"down":return r===e.choices.length-1?L.PyW(dG.NextFrame({state:0})):L.PyW(dG.NextFrame({state:r+1}));case"tab":let i;return i=e.choices,L.PyW(dG.NextFrame({state:(r+1)%i.length}));case"enter":case"return":{let t=e.choices[r];if(t.disabled)return L.PyW(dG.Beep());return L.PyW(dG.Submit({value:t.value}))}default:return L.PyW(dG.Beep())}},cN=L.D9k(function*(e,t){let r=yield*n$,n=yield*r.columns,i=yield*dM(t),a=cR(e,i.pointerSmall,i,{plain:!0});return dH(cj(e,i.prefix,i.pointerSmall,t,i,{plain:!0}),n,a)+"\x1b[2K\x1b[G"}),cR=(e,t,r,n)=>et.isSome(e.error)?Q.YW(e.error.value.split(dK),{onEmpty:()=>"",onNonEmpty:e=>n?.plain===!0?dR(t,e.join("\n")):"\x1b[s\n"+dR(dN(t,r.errorColor),Q.Tj(e,e=>dA(e,r.errorColor)).join("\n"))+"\x1b[u"}):"",cj=(e,t,r,n,i,a,s=!1)=>cp(((e,t,r,n,i)=>{let a=e.value;if(i?.plain===!0)switch(t.type){case"hidden":return"";case"password":return r.passwordMask.repeat(a.length);case"text":return a}if(0===a.length)return"";let s=et.isSome(e.error)?r.errorColor:n?r.submittedColor:((...e)=>e)("\x1b[4m",r.primaryColor);switch(t.type){case"hidden":return"";case"password":return dN(r.passwordMask.repeat(a.length),s);case"text":return dE(a,s)}})(e,n,i,s,a),n.message,t,r,a),cD=L.D9k(function*(e,t){let r=yield*dM(t),n=cj(e,dN(r.prefix,r.primaryColor),dN(r.pointerSmall,r.mutedColor),t,r),i=cR(e,r.pointerSmall,r),a="password"===t.type?r.passwordMask.length:1;return n+i+((e,t=0)=>{let r="";return t<0&&(r+=`\x1b[${-t}A`),t>0&&(r+=`\x1b[${t}B`),e>0&&(r+=`\x1b[${e}C`),e<0&&(r+=`\x1b[${-e}D`),r})((e.cursor-e.value.length)*a)}),cU=L.D9k(function*(e,t){let r=yield*dM(t);return cj(e,dN(r.tick,r.successColor),dN(r.ellipsis,r.mutedColor),t,r,void 0,!0)+"\n"}),cF=e=>L.PyW(dG.NextFrame({state:{...e,cursor:0,error:et.none()}})),cB=e=>L.PyW(dG.NextFrame({state:{...e,cursor:e.value.length,error:et.none()}})),cL=(e,t)=>{let r={default:"",type:t,validate:L.PyW,...e};return dD({cursor:r.default.length,value:r.default,error:et.none()},{render:(e,t)=>dG.$match(t,{Beep:()=>L.PyW("\x07"),NextFrame:({state:e})=>cD(e,r),Submit:()=>cU(e,r)}),process:(e,t)=>{if(e.key.ctrl)switch(e.key.name){case"u":return L.PyW(dG.NextFrame({state:{...t,cursor:0,value:"",error:et.none()}}));case"a":return cF(t);case"e":return cB(t);default:return L.PyW(dG.Beep())}switch(e.key.name){case"backspace":var n;if(t.cursor<=0)return L.PyW(dG.Beep());let i=t.value.slice(0,t.cursor-1),a=t.value.slice(t.cursor),s=t.cursor-1,o=`${i}${a}`;return L.PyW(dG.NextFrame({state:{...t,cursor:s,value:o,error:et.none()}}));case"left":if(t.cursor<=0)return L.PyW(dG.Beep());let l=t.cursor-1;return L.PyW(dG.NextFrame({state:{...t,cursor:l,error:et.none()}}));case"right":if(t.cursor>=t.value.length)return L.PyW(dG.Beep());let d=Math.min(t.cursor+1,t.value.length);return L.PyW(dG.NextFrame({state:{...t,cursor:d,error:et.none()}}));case"home":return cF(t);case"end":return cB(t);case"enter":case"return":{let e=t.value;return L.YWq(r.validate(e),{onFailure:r=>dG.NextFrame({state:{...t,value:e,error:et.some(r)}}),onSuccess:e=>dG.Submit({value:e})})}case"tab":if(t.value===r.default)return L.PyW(dG.Beep());let c=0===t.value.length?r.default:t.value;return L.PyW(dG.NextFrame({state:{...t,value:c,cursor:c.length,error:et.none()}}));default:let u,f,p,h;return n=et.getOrElse(e.input,()=>""),u=t.value.slice(0,t.cursor),f=t.value.slice(t.cursor),p=`${u}${n}${f}`,h=t.cursor+n.length,L.PyW(dG.NextFrame({state:{...t,cursor:h,value:p,error:et.none()}}))}},clear:(e,t)=>cN(e,r)})},cz=L.D9k(function*(e){let t=yield*n$,r=yield*t.columns,n=yield*dM(e);return dV(cp(e.active+" "+dR(n.toggleSeparator,e.inactive),e.message,n.prefix,n.pointerSmall,{plain:!0}),r)+"\x1b[2K\x1b[G"}),cW=(e,t,r,n=!1)=>{let i=dN(r.toggleSeparator,r.mutedColor),a=((...e)=>e)("\x1b[4m",n?r.submittedColor:r.primaryColor),s=e?t.inactive:dE(t.inactive,a);return(e?dE(t.active,a):t.active)+" "+dR(i,s)},cJ=(e,t,r,n)=>cp(e,n.message,t,r),cY=L.D9k(function*(e,t){let r=yield*dM(t),n=dN(r.prefix,r.primaryColor),i=dN(r.pointerSmall,r.mutedColor);return"\x1b[?25l"+cJ(cW(e,t,r),n,i,t)}),cX=L.D9k(function*(e,t){let r=yield*dM(t),n=dN(r.tick,r.successColor),i=dN(r.ellipsis,r.mutedColor);return cJ(cW(e,t,r,!0),n,i,t)+"\n"}),cq=L.PyW(dG.NextFrame({state:!0})),cG=L.PyW(dG.NextFrame({state:!1})),cV=e=>(t,r)=>{switch(r._tag){case"Beep":return L.PyW("\x07");case"NextFrame":return cY(t,e);case"Submit":return cX(t,e)}},cH=(e,t)=>{switch(e.key.name){case"0":case"j":case"delete":case"right":case"down":return cG;case"1":case"k":case"left":case"up":return cq;case" ":case"tab":return t?cG:cq;case"enter":case"return":return L.PyW(dG.Submit({value:t}));default:return L.PyW(dG.Beep())}},cK=(e,t,r)=>{let n=void 0===r?t:r,i=Math.min(t-n,e-Math.floor(n/2));i<0&&(i=0);let a=Math.min(i+n,t);return{startIndex:i,endIndex:a}},cQ=L.D9k(function*(e,t){let r=t?.commandPath??[e.name],n=cZ(e,r),i=(t?.prefix??r).map(e=>c3(e));return yield*c4(i),yield*c0(n,i,n===e?"ROOT":n.name),{args:i.map(e=>e.value),displayArgs:i.map(e=>e.displayValue)}}),cZ=(e,t)=>{let r=e;for(let e of t.slice(1)){let t=r.subcommands.flatMap(e=>e.commands).find(t=>t.name===e||t.alias===e);if(void 0===t)break;r=t}return r},c0=L.D9k(function*(e,t,r){let n=lF(e),i=e.subcommands.flatMap(e=>e.commands.filter(e=>!e.unlisted)),a=0===i.length?n.config:n.contextConfig;if(a.flags.length>0){for(let e of(yield*on(c7(r,"FLAGS")),a.flags))t.push(...yield*c2(e));(a.arguments.length>0||i.length>0)&&(yield*c4(t))}if(a.arguments.length>0){for(let e of(yield*on(c7(r,"ARGUMENTS")),a.arguments))t.push(...yield*c2(e));i.length>0&&(yield*c4(t))}if(0===i.length)return;let s=yield*dL(dz({message:"Command",choices:i.map(e=>({title:e.name,value:e,...void 0!==e.shortDescription?{description:e.shortDescription}:void 0!==e.description?{description:e.description}:{}}))}));yield*on(),t.push(c3(s.name)),c1(s)&&(yield*c4(t)),yield*c0(s,t,s.name)}),c1=e=>e.subcommands.some(e=>e.commands.some(e=>!e.unlisted))||lF(e).config.orderedParams.length>0,c2=L.D9k(function*(e){let t=oZ(e),r=o0(e);if(r.isOptional&&!(yield*dL(dj({message:`Set ${c8(t)}?`,initial:!1}))))return yield*on(),[];let n=r.isVariadic?yield*dL(dF({message:`${c8(t)} count`,default:et.getOrElse(r.variadicMin,()=>0),min:et.getOrElse(r.variadicMin,()=>0),...et.isSome(r.variadicMax)?{max:r.variadicMax.value}:{}})):1,i=[];for(let e=0;e<n;e++)i.push((yield*c5(t)));let a="flag"===t.kind?{flags:{[t.name]:i.map(e=>e.value)},arguments:[]}:{flags:{},arguments:i.map(e=>e.value)};return(yield*e.parse(a),yield*on(),t.kind===oC)?i:i.flatMap(e=>e.value.startsWith("-")&&e.value.length>1?[c3(`--${t.name}=${e.value}`,`--${t.name}=${e.displayValue}`)]:[c3(`--${t.name}`),e])}),c5=e=>{var t,r;let n=c6(e);switch(e.primitiveType._tag){case"Boolean":return L.TjK(dL(dj({message:n,label:{confirm:"true",deny:"false"},placeholder:{defaultConfirm:"(T/f)",defaultDeny:"(t/F)"}})),e=>c3(String(e)));case"Choice":{let t=o$(e.primitiveType)??[];return L.TjK(dL(dz({message:n,choices:t.map(e=>({title:e,value:e}))})),c3)}case"Date":let i,a,s,o,l,d;return L.TjK(dL((t={message:n},s=(a=((e,t,r)=>{let n=[],i=null;for(;i=ct.exec(e);){let e=i.shift(),a=i.findIndex(e=>void 0!==e);if(a in cr){let s=i[a]||e;n.push(cr[a]({token:s,date:t,parts:n,locales:r}))}else n.push(new ci({token:i[a]||e,date:t,parts:n,locales:r}))}let a=n.reduce((e,t)=>{let r=e[e.length-1];return t.isToken()&&void 0!==r&&r.isToken()?r.setValue(t.token):e.push(t),e},Q.Ie());return n.splice(0,n.length,...a),n})((i={initial:new globalThis.Date,dateMask:"YYYY-MM-DD HH:mm:ss",validate:L.PyW,...t,locales:{...ce,...t.locales}}).dateMask,i.initial,i.locales)).findIndex(e=>!e.isToken()),dD({dateParts:a,typed:"",cursor:s,value:i.initial,error:et.none()},{render:(o=i,(e,t)=>dG.$match(t,{Beep:()=>L.PyW("\x07"),NextFrame:({state:e})=>d4(e,o),Submit:()=>d7(e,o)})),process:(l=i,(e,t)=>{switch(e.key.name){case"left":let r;return L.PyW((r=t.dateParts[t.cursor].previousPart(),et.isSome(r)?dG.NextFrame({state:{...t,typed:"",cursor:t.dateParts.indexOf(r.value)}}):dG.Beep()));case"right":let n;return L.PyW((n=t.dateParts[t.cursor].nextPart(),et.isSome(n)?dG.NextFrame({state:{...t,typed:"",cursor:t.dateParts.indexOf(n.value)}}):dG.Beep()));case"k":case"up":return L.PyW((t.dateParts[t.cursor].increment(),dG.NextFrame({state:{...t,typed:""}})));case"j":case"down":return L.PyW((t.dateParts[t.cursor].decrement(),dG.NextFrame({state:{...t,typed:""}})));case"tab":let i,a;return L.PyW((i=t.dateParts[t.cursor].nextPart(),a=et.match(i,{onNone:()=>t.dateParts.findIndex(e=>!e.isToken()),onSome:e=>t.dateParts.indexOf(e)}),dG.NextFrame({state:{...t,typed:"",cursor:a}})));case"enter":case"return":return L.YWq(l.validate(t.value),{onFailure:e=>dG.NextFrame({state:{...t,error:et.some(e)}}),onSuccess:e=>dG.Submit({value:e})});default:return L.PyW(((e,t)=>{if(/\d/.test(e)){let r=t.typed+e;return t.dateParts[t.cursor].setValue(r),dG.NextFrame({state:{...t,typed:r}})}return dG.Beep()})(et.getOrElse(e.input,()=>""),t))}}),clear:(d=i,L.D9k(function*(e,t){let r=yield*n$,n=yield*r.columns,i=yield*dM(d),a=Q.TS(e.dateParts,"",(e,t)=>e+t.toString());return dH(d9(i.prefix,i.pointerSmall,a,d,{plain:!0}),n,et.isSome(e.error)?Q.YW(e.error.value.split(dK),{onEmpty:()=>"",onNonEmpty:e=>dR(i.pointerSmall,e.join("\n"))}):"")+"\x1b[2K\x1b[G"}))}))),e=>c3(e.toISOString()));case"Finite":let c,u,f,p;return L.TjK(dL((r={message:n},c={default:0,min:globalThis.Number.NEGATIVE_INFINITY,max:globalThis.Number.POSITIVE_INFINITY,incrementBy:1,decrementBy:1,precision:2,validate:e=>e<c.min?L.fJG(`${e} must be greater than or equal to ${c.min}`):e>c.max?L.fJG(`${e} must be less than or equal to ${c.max}`):L.PyW(e),...r},dD({cursor:(u=void 0===r.default?"":`${c.default}`).length,value:u,error:et.none()},{render:(f=c,(e,t)=>dG.$match(t,{Beep:()=>L.PyW("\x07"),NextFrame:({state:e})=>cb(e,f),Submit:()=>cv(e,f)})),process:(p=c,(e,t)=>{if(e.key.ctrl&&"u"===e.key.name)return cx(t);switch(e.key.name){case"backspace":return c_(t);case"k":case"up":return L.PyW(dG.NextFrame({state:{...t,value:""===t.value||"-"===t.value?`${p.incrementBy}`:`${globalThis.Number.parseFloat(t.value)+p.incrementBy}`,error:et.none()}}));case"j":case"down":return L.PyW(dG.NextFrame({state:{...t,value:""===t.value||"-"===t.value?`-${p.decrementBy}`:`${globalThis.Number.parseFloat(t.value)-p.decrementBy}`,error:et.none()}}));case"enter":case"return":{let e=globalThis.Number.parseFloat(t.value);if(globalThis.Number.isNaN(e))return L.PyW(dG.NextFrame({state:{...t,error:et.some("Must provide a floating point value")}}));return L.qIB(L.OH5(()=>d$(e,p.precision)),e=>L.YWq(p.validate(e),{onFailure:e=>dG.NextFrame({state:{...t,error:et.some(e)}}),onSuccess:e=>dG.Submit({value:e})}))}default:var r=et.getOrElse(e.input,()=>"");if("."===r&&t.value.includes("."))return L.PyW(dG.Beep());if(0===t.value.length&&"-"===r)return L.PyW(dG.NextFrame({state:{...t,value:"-",error:et.none()}}));let n=globalThis.Number.parseFloat(t.value+r);return globalThis.Number.isNaN(n)?L.PyW(dG.Beep()):L.PyW(dG.NextFrame({state:{...t,value:"."===r?`${n}.`:t.value.includes(".")&&/^\d$/.test(r)?t.value+r:`${n}`,error:et.none()}}))}}),clear:cm(c)}))),e=>c3(String(e)));case"Int":return L.TjK(dL(dF({message:n})),e=>c3(String(e)));case"Redacted":return L.TjK(dL(cL({message:n},"password").pipe(dB(dk.L8))),e=>c3(dk.Uq(e),"<redacted>"));default:return L.TjK(dL(cL({message:n},"text")),c3)}},c3=(e,t=e)=>({value:e,displayValue:t}),c6=e=>c8(e),c8=e=>{let t=et.getOrUndefined(e.description)?.trim(),r="flag"===e.kind&&void 0!==t&&t.length<=32?t:c9(e.name);return"flag"===e.kind?`${r} (${"flag"===e.kind?`--${e.name}`:e.name})`:r},c9=e=>{let t=e.split(/[-_]+/).filter(e=>e.length>0);return 0===t.length?e:[t[0][0].toUpperCase()+t[0].slice(1),...t.slice(1)].join(" ")},c4=e=>on(un("Current command",e.map(e=>e.displayValue),"\x1b[35m")),c7=(e,t)=>`${dE(e.toUpperCase(),"\x1b[1m","\x1b[96m")} ${dE("·","\x1b[90m")} ${dE(t,"\x1b[1m","\x1b[37m")}`,ue=(e,t,r)=>[`${dE(e,"\x1b[1m","\x1b[96m")} ${dE(`v${t}`,"\x1b[37m")} ${dE("· Command wizard","\x1b[1m","\x1b[37m")}`,...void 0===r||0===r.length?[]:[r],dE("Build a command interactively. Press Ctrl+C to cancel.","\x1b[90m"),""].join("\n"),ut=e=>un("Command ready",e,"\x1b[96m","\x1b[32m"),ur=()=>`
55
- ${dE("Wizard cancelled.","\x1b[31m")}`,un=(e,t,r,n="\x1b[37m")=>{let i=ui(t);return[dE(e,"\x1b[1m",n),...i.map(e=>dE(e,r)),""].join("\n")},ui=e=>{let t=" $ ",r=" ",n=e.map(ua),i=[],a=t;for(let e of n){let n=a===t||a===r?"":" ";a.length+n.length+e.length>88&&a!==t?(i.push(`${a} \\`),a=`${r}${e}`):a+=`${n}${e}`}return a!==t&&i.push(a),i},ua=e=>/^[A-Za-z0-9_./:@%+=,-]+$/.test(e)?e:`'${e.replaceAll("'","'\"'\"'")}'`,us=e=>em.i5(e,lU),uo=(e,t,r)=>lL({name:e,config:lP(t??{}),...em.EA(r)?{handle:r}:{}}),ul=(0,W.XY)(2,(e,t)=>{let r=(e=>{let t=[],r=new Map,n=(e,n)=>{t.push(n);let i=r.get(e);i?i.push(n):r.set(e,[n])};for(let t of e){if(us(t)){n(void 0,t);continue}for(let e of t.commands)n(t.group,e)}let i=[],a=r.get(void 0);for(let[e,t]of(a&&a.length>0&&i.push({group:void 0,commands:a}),r))void 0!==e&&i.push({group:e,commands:t});return{flat:t,groups:i}})(t);lX(e,r.flat);let n=lF(e),i=new Map(r.flat.map(e=>[e.name,lF(e)])),a=Symbol("effect/cli/SubcommandState"),s=L.D9k(function*(e){if(et.isNone(e.subcommand))return yield*n.parse(e);let t=i.get(e.subcommand.value.name);if(!t)return yield*n.parse(e);let r=yield*n.parseContext(e),s=yield*t.parse(e.subcommand.value.parsedInput);return{...r,[a]:{name:t.name,result:s}}}),o=L.D9k(function*(e,t){let r=e[a];if(r){let a=i.get(r.name);return a?yield*a.handle(r.result,[...t,a.name]).pipe(L.PfK(n.service,e)):yield*new oh({commandPath:t,errors:[]})}return yield*n.handle(e,t)});return lL({name:n.name,config:n.config,contextConfig:n.contextConfig,description:n.description,shortDescription:n.shortDescription,alias:n.alias,unlisted:n.unlisted,annotations:n.annotations,globalFlags:n.globalFlags,examples:n.examples,service:n.service,subcommands:r.groups,parse:s,parseContext:n.parseContext,handle:o})}),ud=(0,W.XY)(2,(e,t)=>{let r=lF(e),n=lP(t),i=lj(r.config,n),a=lj(r.contextConfig,n);r.subcommands.length>0&&lX(e,r.subcommands.flatMap(e=>e.commands),{contextConfig:a});let s=lJ(n,{allowLeftovers:!0}),o=L.D9k(function*(e){let t=yield*r.parse(e),n=yield*s(e);return{...t,...n}}),l=L.D9k(function*(e){let t=yield*r.parseContext(e),n=yield*s(e);return{...t,...n}});return lL({name:r.name,config:i,contextConfig:a,description:r.description,shortDescription:r.shortDescription,alias:r.alias,unlisted:r.unlisted,annotations:r.annotations,globalFlags:r.globalFlags,examples:r.examples,service:r.service,subcommands:r.subcommands,parse:o,parseContext:l,handle:(e,t)=>r.handle(e,t)})}),uc=(0,W.XY)(2,(e,t)=>lL({...lF(e),description:t})),uu=(0,W.XY)(2,(e,t)=>lL({...lF(e),shortDescription:t})),uf=(0,W.XY)(2,(e,t)=>lL({...lF(e),examples:t})),up=(e,t)=>{let r=lF(e);return L.D9k(function*(n){let i,a,s,o,l,d,{builtIns:c}=yield*l4,{tokens:u,trailingOperands:f}=-1===(i=n.indexOf("--"))?{tokens:dt(n),trailingOperands:[]}:{tokens:dt(n.slice(0,i)),trailingOperands:n.slice(i+1)},p=lH([...c,...(a=[],(s=e=>{for(let t of lF(e).globalFlags)a.push(t);for(let t of e.subcommands)for(let e of t.commands)s(e)})(e),lH(a))]),h=ds(p.flatMap(e=>oQ(e.flag)).filter(oM)),{flagMap:m,remainder:g,errors:y}=(o=dd(h.params),l=[],d=(e,t,r)=>{let n=ds(lF(t).config.flags.flatMap(oQ).filter(oM)),i=ds(lF(t).contextConfig.flags.flatMap(oQ).filter(oM)),a=dl(t.subcommands),s=da(e),c=[],u=!0;for(let e=s.take();e;e=s.take()){if(dc(e)){let t=dy(e,r);if(void 0!==t){db(c,s,e,t);continue}let d=df(e,i);if(void 0!==d){db(c,s,e,d);continue}let f=df(e,n),p=df(e,h);if(void 0!==f&&(void 0===p||!u||!dv(e,s.rest(),f,a,[n,i,h]))){db(c,s,e,f);continue}if(void 0!==p){let t=dg(s,e,p.param,p.negated);if("Error"===t._tag){l.push(t.error);continue}void 0!==t.value&&o[p.param.name].push(t.value);continue}c.push(e);continue}if("Value"===e._tag&&u){let t=a.get(e.value);if(void 0!==t)return c.push(e),c.push(...d(s.rest(),t,[...r,i])),c;u=!1}c.push(e)}return c},{flagMap:o,remainder:d(u,e,[]),errors:l}),b={flags:m,arguments:[]},v=yield*di({tokens:g,trailingOperands:f},e),_=[e.name,...dn(v)],x={builtIns:c,command:e,commandPath:_,version:t.version},w=lQ(e,_,c),k=((e,t,r,n)=>{let i=new Set(t),a=[],s=new Set;for(let t of e)if(!i.has(t))for(let e of oQ(t.flag)){let t=r[e.name];if(!t||0===t.length)continue;let i=`--${e.name}`;s.has(i)||(s.add(i),a.push(new oa({option:i,suggestions:[],command:n})))}return a})(p,w,m,_);if(k.length>0||y.length>0){let e=v.errors??[];return yield*new oh({commandPath:_,errors:[...y,...k,...e]})}for(let r of w){if("Action"!==r._tag||!oQ(r.flag).some(e=>{let t=m[e.name];return void 0!==t&&t.length>0}))continue;let[,i]=yield*r.flag.parse(b);if(r===l3)return yield*L.JkU(function*(){yield*on(ue(e.name,t.version,e.description));let r=[e.name,...n.filter(e=>"--wizard"!==e&&!e.startsWith("--wizard="))],i=yield*cQ(e,{commandPath:_,prefix:r});yield*on(ut(i.displayArgs)),(yield*dL(dJ({message:"Run this command?",initial:!0,active:"yes",inactive:"no"})))&&(yield*on(),yield*up(e,{...t,renderErrors:!1})(i.args.slice(1)))}).pipe(L.KuX("QuitError",()=>on(ur())));yield*r.run(i,x);return}if(v.errors&&v.errors.length>0)return yield*new oh({commandPath:_,errors:v.errors});let S=yield*L.Ket(r.parse(v));if("Failure"===S._tag)return yield*new oh({commandPath:_,errors:[S.failure]});let I=r.handle(S.success,[e.name]),$=w.includes(l8)?(yield*l8.flag.parse(b))[1]:et.none();for(let e of(I=L.PfK(I,l8,$),w)){if("Setting"!==e._tag||e===l8)continue;let[,t]=yield*e.flag.parse(b);I=L.PfK(I,e,t)}let E=et.match($,{onNone:()=>ee.Ie(),onSome:e=>ee.L8(o1.zQ,e)});yield*L.PpN(I,E)},L.osR(e=>em.i5(e,oi)&&"ShowHelp"===e._tag?tz.Py(e):tz.fJ(e),r=>{let n;return L.hgn((n=!1!==t.renderErrors,L.JkU(function*(){let{builtIns:t}=yield*l4,i=yield*o2,a=yield*lZ(e,r.commandPath,t);yield*on(i.formatHelpDoc(a)),n&&r.errors.length>0&&(yield*or(i.formatErrors(r.errors)))})),L.fJG(r))}),L.osR(e=>!1!==t.renderErrors&&em.i5(e,oi)&&"UserError"===e._tag?tz.Py(e):tz.fJ(e),e=>L.hgn(L.JkU(function*(){let t=yield*o2;yield*or(t.formatError(e)),e[q]=!1}),L.fJG(e))),L.osR(e=>em.i5(e,nS)?tz.Py(e):tz.fJ(e),e=>L.GaK))},uh=/(?:https:\/\/(?:www\.)?excalidraw\.com\/)?#json=[A-Za-z0-9_-]+,[A-Za-z0-9_-]{22,}/gu;function um(e){return e.replace(uh,"[redacted-share-link]")}let ug=(e=0)=>t=>`\x1b[${t+e}m`,uy=(e=0)=>t=>`\x1b[${38+e};5;${t}m`,ub=(e=0)=>(t,r,n)=>`\x1b[${38+e};2;${t};${r};${n}m`,uv=e=>`\x1b[58;5;${e<90?e-30:e-90+8}m`,u_={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],underlineDouble:["4:2",24],underlineCurly:["4:3",24],underlineDotted:["4:4",24],underlineDashed:["4:5",24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]},underlineColor:{underlineBlack:["58;5;0",59],underlineRed:["58;5;1",59],underlineGreen:["58;5;2",59],underlineYellow:["58;5;3",59],underlineBlue:["58;5;4",59],underlineMagenta:["58;5;5",59],underlineCyan:["58;5;6",59],underlineWhite:["58;5;7",59],underlineBlackBright:["58;5;8",59],underlineGray:["58;5;8",59],underlineGrey:["58;5;8",59],underlineRedBright:["58;5;9",59],underlineGreenBright:["58;5;10",59],underlineYellowBright:["58;5;11",59],underlineBlueBright:["58;5;12",59],underlineMagentaBright:["58;5;13",59],underlineCyanBright:["58;5;14",59],underlineWhiteBright:["58;5;15",59]}};Object.keys(u_.modifier);let ux=Object.keys(u_.color),uw=Object.keys(u_.bgColor);Object.keys(u_.underlineColor),[...ux,...uw];let uk=function(){let e=new Map;for(let[t,r]of Object.entries(u_)){for(let[t,n]of Object.entries(r))u_[t]={open:`\x1b[${n[0]}m`,close:`\x1b[${n[1]}m`},r[t]=u_[t],e.set(Number.parseInt(n[0],10),n[1]);Object.defineProperty(u_,t,{value:r,enumerable:!1})}return Object.defineProperty(u_,"codes",{value:e,enumerable:!1}),u_.color.close="\x1b[39m",u_.bgColor.close="\x1b[49m",u_.underlineColor.close="\x1b[59m",u_.color.ansi=ug(),u_.color.ansi256=uy(),u_.color.ansi16m=ub(),u_.bgColor.ansi=ug(10),u_.bgColor.ansi256=uy(10),u_.bgColor.ansi16m=ub(10),u_.underlineColor.ansi=uv,u_.underlineColor.ansi256=uy(20),u_.underlineColor.ansi16m=ub(20),Object.defineProperties(u_,{rgbToAnsi256:{value:(e,t,r)=>e===t&&t===r?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(r/255*5),enumerable:!1},hexToRgb:{value(e){let t=/[\da-f]{6}|[\da-f]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[r]=t;3===r.length&&(r=[...r].map(e=>e+e).join(""));let n=Number.parseInt(r,16);return[n>>16&255,n>>8&255,255&n]},enumerable:!1},hexToAnsi256:{value:e=>u_.rgbToAnsi256(...u_.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){let t,r,n;if(e<8)return 30+e;if(e<16)return 90+(e-8);if(e>=232)r=t=((e-232)*10+8)/255,n=t;else{let i=(e-=16)%36;t=Math.floor(e/36)/5,r=Math.floor(i/6)/5,n=i%6/5}let i=2*Math.max(t,r,n);if(0===i)return 30;let a=30+(Math.round(n)<<2|Math.round(r)<<1|Math.round(t));return 2===i&&(a+=60),a},enumerable:!1},rgbToAnsi:{value:(e,t,r)=>u_.ansi256ToAnsi(u_.rgbToAnsi256(e,t,r)),enumerable:!1},hexToAnsi:{value:e=>u_.ansi256ToAnsi(u_.hexToAnsi256(e)),enumerable:!1}}),u_}();function uS(e,t=globalThis.Deno?globalThis.Deno.args:a6.argv){let r=e.startsWith("-")?"":1===e.length?"-":"--",n=t.indexOf(r+e),i=t.indexOf("--");return -1!==n&&(-1===i||n<i)}let{env:uI}=a6;function u$(){return/^\d+$/.test(uI.FORCE_COLOR)}function uE(e,t={}){var r;return 0!==(r=function(e,{streamIsTTY:t,sniffFlags:r=!0}={}){let n="FORCE_COLOR"in uI?"false"===uI.FORCE_COLOR?0:"true"===uI.FORCE_COLOR||0===uI.FORCE_COLOR.length?1:u$()?Math.min(Number.parseInt(uI.FORCE_COLOR,10),3):void 0:void 0;void 0!==n&&(i=n);let a=r?i:n;if(0===a)return 0;if(r){if(uS("color=16m")||uS("color=full")||uS("color=truecolor"))return 3;if(uS("color=256"))return 2}if(void 0!==a&&u$())return a;if("TF_BUILD"in uI&&"AGENT_NAME"in uI)return 1;if(e&&!t&&void 0===a)return 0;let s=a||0;if("dumb"===uI.TERM)return s;if("win32"===a6.platform){let e=rR.release().split(".");return Number(e[0])>=10&&Number(e[2])>=10586?Number(e[2])>=14931?3:2:1}if("CI"in uI)return["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some(e=>e in uI)?3:["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(e=>e in uI)||"codeship"===uI.CI_NAME?1:s;if("TEAMCITY_VERSION"in uI)return+!!/^(?:9\.0*[1-9]\d*\.|\d{2,}\.)/.test(uI.TEAMCITY_VERSION);if("truecolor"===uI.COLORTERM||"xterm-kitty"===uI.TERM||"xterm-ghostty"===uI.TERM||"wezterm"===uI.TERM)return 3;if("TERM_PROGRAM"in uI){let e=Number.parseInt((uI.TERM_PROGRAM_VERSION||"").split(".",1)[0],10);switch(uI.TERM_PROGRAM){case"iTerm.app":return e>=3?3:2;case"Apple_Terminal":return 2}}return/-256(?:color)?$/i.test(uI.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(uI.TERM)||"COLORTERM"in uI?1:s}(e,{streamIsTTY:e&&e.isTTY,...t}))&&{level:r,hasBasic:!0,has256:r>=2,has16m:r>=3}}uS("no-color")||uS("no-colors")||uS("color=false")||uS("color=never")?i=0:(uS("color")||uS("colors")||uS("color=true")||uS("color=always"))&&(i=1);let{stdout:uO,stderr:uC}={stdout:uE({isTTY:sv.isatty(1)}),stderr:uE({isTTY:sv.isatty(2)})},uT=Symbol("GENERATOR"),uM=Symbol("STYLER"),uP=Symbol("IS_EMPTY"),uA=Symbol("LEVEL"),uN=Object.create(null),uR=e=>{if(!Number.isSafeInteger(e)||e<0||e>3)throw Error("The `level` should be an integer from 0 to 3")};class uj{constructor(e){return uD(e)}}let uD=e=>{let t=(...e)=>e.join(" ");return((e,t={})=>{void 0!==t.level&&uR(t.level);let r=uO?uO.level:0;e[uA]=void 0===t.level?r:t.level})(t,e),Object.setPrototypeOf(t,uU.prototype),t};function uU(e){return uD(e)}for(let[e,t]of(Object.setPrototypeOf(uU.prototype,Function.prototype),Object.entries(uk)))uN[e]={get(){let r=uz(this,uL(t.open,t.close,this[uM]),this[uP]);return Object.defineProperty(this,e,{value:r}),r}};uN.visible={get(){let e=uz(this,this[uM],!0);return Object.defineProperty(this,"visible",{value:e}),e}};let uF=(e,t)=>{let r=uk[t];if("rgb"===e){let e=(e,t,n)=>r.ansi(uk.rgbToAnsi(e,t,n));return[e,e,(e,t,n)=>r.ansi256(uk.rgbToAnsi256(e,t,n)),r.ansi16m]}if("hex"===e){let e=e=>r.ansi(uk.hexToAnsi(e));return[e,e,e=>r.ansi256(uk.hexToAnsi256(e)),e=>r.ansi16m(...uk.hexToRgb(e))]}let n=e=>r.ansi(uk.ansi256ToAnsi(e));return[n,n,r.ansi256,r.ansi256]};for(let e of["rgb","hex","ansi256"]){let t=e[0].toUpperCase()+e.slice(1);for(let[r,n]of[[e,"color"],["bg"+t,"bgColor"],["underline"+t,"underlineColor"]]){let{close:t}=uk[n],i=uF(e,n);uN[r]={get(){let e=function(e,r,n){return uz(this,uL(i[this.level](e,r,n),t,this[uM]),this[uP])};return Object.defineProperty(this,r,{value:e}),e}}}}let uB=Object.defineProperties(()=>{},{...uN,level:{enumerable:!0,get(){return this[uT].level},set(e){this[uT].level=e}}}),uL=(e,t,r)=>{let n,i;return void 0===r?(n=e,i=t):(n=r.openAll+e,i=t+r.closeAll),{open:e,close:t,openAll:n,closeAll:i,parent:r}},uz=(e,t,r)=>{let n=(...e)=>1===e.length?uW(n,""+e[0]):2===e.length?uW(n,`${e[0]??""} ${e[1]??""}`):uW(n,e.join(" "));return Object.setPrototypeOf(n,uB),n[uT]=e[uT]??e,n[uM]=t,n[uP]=r,n},uW=(e,t)=>{if(e[uT][uA]<=0||!t)return e[uP]?"":t;let r=e[uM];if(void 0===r)return t;let{openAll:n,closeAll:i}=r;if(t.includes("\x1b"))for(;void 0!==r;)t=function(e,t,r){let n=e.indexOf(t);if(-1===n)return e;let i=t.length,a=0,s="";do s+=e.slice(a,n)+t+r,a=n+i,n=e.indexOf(t,a);while(-1!==n)return s+e.slice(a)}(t,r.close,r.open),r=r.parent;let a=t.indexOf("\n");return -1!==a&&(t=function(e,t,r,n){let i=0,a="";do{let s="\r"===e[n-1];a+=e.slice(i,s?n-1:n)+t+(s?"\r\n":"\n")+r,i=n+1,n=e.indexOf("\n",i)}while(-1!==n)return a+e.slice(i)}(t,i,n,a)),n+t+i};Object.defineProperties(uU.prototype,{...uN,level:{enumerable:!0,get(){return this[uA]},set(e){uR(e),this[uA]=e}}}),uD(void 0),uD({level:uC?uC.level:0});let uJ=function({onlyFirst:e=!1}={}){return RegExp("(?:(?:\\u001B\\]|\\u009D)[^\\u0007\\u001B\\u009C\\u009D]*(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]",e?void 0:"g")}(),uY=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],uX=[12288,12288,65281,65376,65504,65510],uq=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101594,101631,101664,101760,101874,101888,102801,102816,102866,110576,110579,110581,110587,110589,110590,110592,110888,110898,110898,110928,110930,110933,110933,110948,110952,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127406,127406,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128729,128732,128735,128747,128748,128756,128764,128986,128986,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129734,129736,129736,129740,129757,129759,129771,129775,129786,131072,196605,196608,262141],uG=(e,t)=>{let r=0,n=Math.floor(e.length/2)-1;for(;r<=n;){let i=Math.floor((r+n)/2),a=2*i;if(t<e[a])n=i-1;else{if(!(t>e[a+1]))return!0;r=i+1}}return!1},[uV,uH]=function(e){let t=e[0],r=e[1];for(let n=0;n<e.length;n+=2){let i=e[n],a=e[n+1];if(19968>=i&&19968<=a)return[i,a];a-i>r-t&&(t=i,r=a)}return[t,r]}(uq);function uK(e,{ambiguousAsWide:t=!1}={}){if(!Number.isSafeInteger(e))throw TypeError(`Expected a code point, got \`${typeof e}\`.`);return!(e<12288)&&!(e>65510)&&uG(uX,e)||e>=uV&&e<=uH||!(e<4352)&&!(e>262141)&&uG(uq,e)||t&&!(e<161)&&!(e>1114109)&&uG(uY,e)?2:1}let uQ=new Intl.Segmenter,uZ=/[^\p{Default_Ignorable_Code_Point}\p{Control}\p{Format}\p{Nonspacing_Mark}\p{Enclosing_Mark}\p{Surrogate}]/v,u0=/\p{Spacing_Mark}/v,u1=/^\p{RGI_Emoji}$/v,u2=/^[\d#*]\u20E3$/,u5=/\p{Extended_Pictographic}/gu;function u3(e){return e>=4352&&e<=4447||e>=43360&&e<=43388}function u6(e){return e>=4448&&e<=4519||e>=55216&&e<=55238}function u8(e){return e>=4520&&e<=4607||e>=55243&&e<=55291}function u9(e,t={}){if("string"!=typeof e||0===e.length)return 0;let{ambiguousIsNarrow:r=!0,countAnsiEscapeCodes:n=!1}=t,i=e;if(!n&&(i.includes("\x1b")||i.includes("›"))&&(i=function(e){if("string"!=typeof e)throw TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.includes("\x1b")||e.includes("›")?e.replace(uJ,""):e}(i)),0===i.length)return 0;if(/^[\u0020-\u007E]*$/.test(i))return i.length;let a=0,s={ambiguousAsWide:!r};for(let{segment:e}of uQ.segment(i)){let t=function(e){let t=e.search(uZ);return -1===t?void 0:e.slice(t)}(e);if(void 0===t)continue;if(u1.test(e)||function(e){if(e.length>50)return!1;if(u2.test(e))return!0;if(e.includes("‍")){let t=e.match(u5);return null!==t&&t.length>=2}return!1}(e)){a+=2;continue}let r=function(e,t){let r=[];for(let t of e)uZ.test(t)&&r.push(t.codePointAt(0));if(0===r.length)return;let n=0;for(let e=0;e<r.length;e++){let i=r[e];if(!(u3(i)||u6(i)||u8(i))){if(0===n)return;for(let i=e;i<r.length;i++)n+=uK(r[i],t);break}if(u3(i)&&u6(r[e+1])){n+=2,e+=u8(r[e+2])?2:1;continue}n+=uK(i,t)}return n}(t,s);if(void 0!==r){a+=r;continue}a+=uK(t.codePointAt(0),s),a+=function(e,t){let r=0,n=!0;for(let i of e){if(n){n=!1;continue}(u0.test(i)||i>="＀"&&i<="￯")&&(r+=uK(i.codePointAt(0),t))}return r}(t,s)}return a}let u4=(e=0)=>t=>`\x1b[${t+e}m`,u7=(e=0)=>t=>`\x1b[${38+e};5;${t}m`,fe=(e=0)=>(t,r,n)=>`\x1b[${38+e};2;${t};${r};${n}m`,ft={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(ft.modifier);let fr=Object.keys(ft.color),fn=Object.keys(ft.bgColor);[...fr,...fn];let fi=function(){let e=new Map;for(let[t,r]of Object.entries(ft)){for(let[t,n]of Object.entries(r))ft[t]={open:`\x1b[${n[0]}m`,close:`\x1b[${n[1]}m`},r[t]=ft[t],e.set(n[0],n[1]);Object.defineProperty(ft,t,{value:r,enumerable:!1})}return Object.defineProperty(ft,"codes",{value:e,enumerable:!1}),ft.color.close="\x1b[39m",ft.bgColor.close="\x1b[49m",ft.color.ansi=u4(),ft.color.ansi256=u7(),ft.color.ansi16m=fe(),ft.bgColor.ansi=u4(10),ft.bgColor.ansi256=u7(10),ft.bgColor.ansi16m=fe(10),Object.defineProperties(ft,{rgbToAnsi256:{value:(e,t,r)=>e===t&&t===r?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(r/255*5),enumerable:!1},hexToRgb:{value(e){let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[r]=t;3===r.length&&(r=[...r].map(e=>e+e).join(""));let n=Number.parseInt(r,16);return[n>>16&255,n>>8&255,255&n]},enumerable:!1},hexToAnsi256:{value:e=>ft.rgbToAnsi256(...ft.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){let t,r,n;if(e<8)return 30+e;if(e<16)return 90+(e-8);if(e>=232)r=t=((e-232)*10+8)/255,n=t;else{let i=(e-=16)%36;t=Math.floor(e/36)/5,r=Math.floor(i/6)/5,n=i%6/5}let i=2*Math.max(t,r,n);if(0===i)return 30;let a=30+(Math.round(n)<<2|Math.round(r)<<1|Math.round(t));return 2===i&&(a+=60),a},enumerable:!1},rgbToAnsi:{value:(e,t,r)=>ft.ansi256ToAnsi(ft.rgbToAnsi256(e,t,r)),enumerable:!1},hexToAnsi:{value:e=>ft.ansi256ToAnsi(ft.hexToAnsi256(e)),enumerable:!1}}),ft}(),fa=new Set(["\x1b","›"]),fs=[...fa].join(""),fo="(?:\x07|\x1b\\\\)",fl=String.raw`[^\u0000-\u001F\u007F-\u009F]*`,fd=String.raw`8;(?<parameters>[^;\u0000-\u001F\u007F-\u009F]*);(?<uri>${fl})${fo}`,fc=`${fl}${fo}`,fu=RegExp(`(?:\x1b\\[|\x9b)(?:(?<sgr>[0-9;:]*)m|[0-?]*[ -/]*[@-~])|\x1b\\](?:${fd}|${fc})`,"y"),ff=new Set(fi.codes.values());ff.delete(0);let fp=new Intl.Segmenter,fh=e=>u9(e,{countAnsiEscapeCodes:!0}),fm=RegExp(`[${fs}]`,"g"),fg=RegExp(`[\\n${fs}]`,"g"),fy=/^[ -~]*$/,fb=e=>`\x1b[${e}m`,fv=(e,t="")=>`\x1b]8;${t};${e}\x07`,f_=(e,t)=>{if(fa.has(e[t]))return fu.lastIndex=t,fu.exec(e)??void 0},fx=(e,t,r=()=>{})=>{let n=0,i=0;for(;i<e.length;){fm.lastIndex=i;let a=fm.exec(e);if(!a)break;let s=f_(e,a.index);if(!s){i=a.index+1;continue}a.index>n&&t(e.slice(n,a.index)),r(s[0]),n=i=a.index+s[0].length}n<e.length&&t(e.slice(n))},fw=e=>{let t="";return fx(e,e=>{t+=e}),fh(t)},fk=e=>{let t=e.split(":"),r=Number.parseInt(t[0],10),n=Number.parseInt(t[1],10);if(![38,48,58].includes(r))return;if(5===n&&3===t.length&&/^\d+$/.test(t[2]))return{code:r,open:e,hasArguments:!0};if(2!==n)return;let i=6===t.length?t.slice(3):t.slice(2),a=6===t.length?t[2]:void 0;if(3===i.length&&i.every(e=>/^\d+$/.test(e))&&(void 0===a||/^\d*$/.test(a)))return{code:r,open:e,hasArguments:!0}},fS=e=>{let t=e.split(";"),r=[];for(let e=0;e<t.length;e++){let n=t[e];if(n.includes(":")){let e=fk(n);e&&r.push(e);continue}let i=""===n?0:Number.parseInt(n,10);if(Number.isFinite(i)){if(38===i||48===i||58===i){if(e+1>=t.length)break;let n=Number.parseInt(t[e+1],10),a=Number.parseInt(t[e+2],10);if(5===n&&Number.isFinite(a)){r.push({code:i,open:[i,n,a].join(";"),hasArguments:!0}),e+=2;continue}let s=Number.parseInt(t[e+2],10),o=Number.parseInt(t[e+3],10),l=Number.parseInt(t[e+4],10);if(2===n&&Number.isFinite(s)&&Number.isFinite(o)&&Number.isFinite(l)){r.push({code:i,open:[i,n,s,o,l].join(";"),hasArguments:!0}),e+=4;continue}break}r.push({code:i,open:String(i),hasArguments:!1})}}return r},fI=(e,t)=>{let r=e.findIndex(e=>e.family===t);-1!==r&&e.splice(r,1)},f$=(e,t)=>{fI(e,t.family),e.push(t)},fE=(e,t)=>{if(0===e)return t.length=0,!0;if(39===e)return fI(t,"foreground"),!0;if(49===e)return fI(t,"background"),!0;if(59===e)return fI(t,"underlineColor"),!0;if(ff.has(e)){for(let r=t.length-1;r>=0;r--){let n=t[r];n.family.startsWith("modifier-")&&n.close===e&&t.splice(r,1)}return!0}return!1},fO=(e,t)=>{let{code:r}=e;if(fE(r,t))return;let n=(e=>{let{code:t,open:r,hasArguments:n}=e;return t>=30&&t<=37||t>=90&&t<=97||38===t&&n?{family:"foreground",open:r,close:39}:t>=40&&t<=47||t>=100&&t<=107||48===t&&n?{family:"background",open:r,close:49}:58===t&&n?{family:"underlineColor",open:r,close:59}:void 0})(e);if(n)return void f$(t,n);let i=fi.codes.get(r);void 0!==i&&0!==i&&f$(t,{family:`modifier-${r}`,open:e.open,close:i})},fC=(e,t)=>{for(let r of fS(e))fO(r,t)},fT=(e,t)=>{for(let{code:r}of fS(e))fE(r,t)},fM=(e,t,r)=>{let n=t;for(;n<e.length;){let t=f_(e,n);if(!t)break;void 0!==t.groups.sgr&&fT(t.groups.sgr,r),n+=t[0].length}},fP=e=>[...e].reverse().map(e=>fb(e.close)).join(""),fA=e=>e.map(e=>fb(e.open)).join(""),fN=(e,t,r,n)=>{let i,a=(i=[],fx(t,e=>{if(fy.test(e)){for(let t of e)i.push({value:t,width:1});return}for(let{segment:t}of fp.segment(e))i.push({value:t,width:fh(t)})},e=>{i.push({value:e,width:0})}),i),s=n;for(let t=0;t<a.length;t++){let n=a[t];n.width>0&&s>0&&s+n.width>r&&(e.push(""),s=0),e[e.length-1]+=n.value,(s+=n.width)===r&&t<a.length-1&&(e.push(""),s=0)}return!s&&e.at(-1).length>0&&e.length>1&&(e[e.length-2]+=e.pop()),fw(e.at(-1))},fR=[" pppppppppppp "," pppppppppppppp ","pppppppppppeeppp","ppppppppppfeeepp","pppppppppcffeepp","ppppppppcccffppp","pppppppcccccpppp","ppppppcccccppppp","pppppcccccpppppp","ppppwccccppppppp","pppwwwccpppppppp","pppkwwwppppppppp","pppkkwpppppppppp","pppppppppppppppp"," pppppppppppppp "," pppppppppppp "],fj={s:["....","....",".###","#...",".##.","...#","###.","...."],k:["#...","#...","#..#","#.#.","##..","#.#.","#..#","...."],e:["....","....",".##.","#..#","####","#...",".###","...."],t:[".#.",".#.","###",".#.",".#.",".#.",".##","..."],c:["....","....",".###","#...","#...","#...",".###","...."],h:["#...","#...","#.#.","##.#","#..#","#..#","#..#","...."],i:["#",".","#","#","#","#","#","."]},fD={p:{dark:{red:158,green:124,blue:140,ansi256:138},light:{red:143,green:112,blue:127,ansi256:96}},c:{dark:{red:250,green:248,blue:247,ansi256:231},light:{red:250,green:248,blue:247,ansi256:231}},w:{dark:{red:214,green:186,blue:152,ansi256:180},light:{red:214,green:186,blue:152,ansi256:180}},k:{dark:{red:58,green:50,blue:54,ansi256:237},light:{red:58,green:50,blue:54,ansi256:237}},f:{dark:{red:186,green:190,blue:196,ansi256:250},light:{red:186,green:190,blue:196,ansi256:250}},e:{dark:{red:222,green:152,blue:158,ansi256:175},light:{red:222,green:152,blue:158,ansi256:175}}},fU={dark:{red:195,green:154,blue:172,ansi256:181},light:{red:111,green:84,blue:98,ansi256:95}},fF={dark:{red:246,green:241,blue:231,ansi256:255},light:{red:26,green:23,blue:18,ansi256:234}},fB={dark:{red:216,green:204,blue:177,ansi256:187},light:{red:76,green:70,blue:57,ansi256:239}},fL=[[0,0,0],[205,0,0],[0,205,0],[205,205,0],[0,0,238],[205,0,205],[0,205,205],[229,229,229],[127,127,127],[255,0,0],[0,255,0],[255,255,0],[92,92,255],[255,0,255],[0,255,255],[255,255,255]];function fz(e,t,r,n="plain"){if("none"===r.colors)return e;let i=new uj({level:"truecolor"===r.colors?3:2}),a="truecolor"===r.colors?i.rgb(t.red,t.green,t.blue):i.ansi256(t.ansi256);return"bold"===n?a.bold(e):a(e)}function fW(e,t){return fz(e,fU[t.background],t,"bold")}function fJ(e,t){return fz(e,fF[t.background],t,"bold")}function fY(e,t){return fz(e,fB[t.background],t)}function fX(e,t){let r=new uj({level:"truecolor"===t.colors?3:2});return"truecolor"===t.colors?r.rgb(e.red,e.green,e.blue):r.ansi256(e.ansi256)}function fq(e,t){let r=fD[e];return void 0===r?void 0:r[t.background]}function fG(e,t,r,n=u9(e)){var i,a;let s,o=Math.max(16,r-u9(e));return`${e}${(i={hard:!0,trim:!0},(a=String(t),s="",fx(a,e=>{s+=e.normalize()},e=>{s+=e}),s).replaceAll("\r\n","\n").split("\n").map(e=>((e,t,r={})=>{if(!1!==r.trim&&""===e.trim())return"";let n=(e=>{let t={value:"",plainText:""},r=[t];for(let n of(fx(e,e=>{let n=e.split(" ");t.value+=n[0],t.plainText+=n[0];for(let e=1;e<n.length;e++)t={value:n[e],plainText:n[e]},r.push(t)},e=>{t.value+=e}),r))n.width=fh(n.plainText);return r})(e),i=[""],a=0,s=-1,o=!0;for(let e of n){let n=i.length-1;if(!1!==r.trim&&s!==n){let e=i[n],t=e.trimStart();t.length!==e.length&&(i[n]=t,a=fw(t)),t.length>0&&(s=n)}if(o?o=!1:(a>=t&&(!1===r.wordWrap||!1===r.trim)&&(i.push(""),a=0),(a>0||!1===r.trim)&&(i[i.length-1]+=" ",a++)),r.hard&&!1!==r.wordWrap&&e.width>t){let r=t-a,n=1+Math.floor((e.width-r-1)/t);Math.floor((e.width-1)/t)<n&&(i.push(""),a=0),a=fN(i,e.value,t,a);continue}if(a+e.width>t&&a>0&&e.width>0){if(!1===r.wordWrap&&a<t){a=fN(i,e.value,t,a);continue}i.push(""),a=0}if(a+e.width>t&&!1===r.wordWrap){a=fN(i,e.value,t,a);continue}i[i.length-1]+=e.value,a+=e.width}return!1!==r.trim&&(i=i.map(e=>(e=>{if(!e.includes(" "))return e;let t=[];fx(e,e=>{t.push({value:e,isEscape:!1})},e=>{t.push({value:e,isEscape:!0})});for(let e=t.length-1;e>=0;e--){let r=t[e];if(r.isEscape)continue;let n=r.value.length;for(;n>0&&" "===r.value[n-1];)n--;if(r.value=r.value.slice(0,n),fh(r.value)>0)break}return t.map(e=>e.value).join("")})(e))),(e=>{let t,r="",n=[],i=0,a=0;for(;i<e.length;){fg.lastIndex=i;let s=fg.exec(e);if(!s)break;if(i=s.index,"\n"!==s[0]){let r=f_(e,i);if(!r){i++;continue}let{groups:a}=r;void 0!==a.sgr?fC(a.sgr,n):void 0!==a.uri&&(t=0===a.uri.length?void 0:{parameters:a.parameters,uri:a.uri}),i+=r[0].length;continue}if(r+=e.slice(a,i),i>a&&(t&&(r+=fv("")),r+=fP(n)),r+="\n",a=++i,i<e.length&&"\n"!==e[i]){let a=[...n];fM(e,i,a),r+=fA(a),t&&(r+=fv(t.uri,t.parameters))}}return r+e.slice(a)})(i.join("\n"))})((e=>{if(!e.includes(" "))return e;let t=0,r="",n="";return fx(e,e=>{let i=e.split(" ");for(let[e,a]of i.entries())if(r+=a,n+=a,e<i.length-1){t+=fh(n),n="";let e=8-t%8;r+=" ".repeat(e),t+=e}},e=>{r+=e}),r})(e),o,i)).join("\n")).replaceAll("\n",`
56
- ${" ".repeat(n)}`)}`}function fV(e,t,r,n,i=8){if(n<52)return[` ${fJ(e,r)}`,fG(" ",fY(t,r),n)].join("\n");let a=e.padEnd(i);return fG(` ${fJ(a,r)} `,fY(t,r),n)}function fH(e){let t=Math.max(32,e.width??80);return[function(e){let t=Math.max(32,e.width??80),r=fG(" ",fY("describe it. sketchi draws it.",e),t);if("none"===e.colors||!1===e.unicode)return[` ${fz("sketchi",fF[e.background],e,"bold")}`,r].join("\n");let n=function(e){let t=Array.from({length:8},(e,t)=>[..."sketchi"].map((e,r)=>`${fj[e]?.[t]??""}${6===r?"":"."}`).join("")),r=fF[e.background],n=[];for(let i=0;i<t.length;i+=2){let a="";for(let e=0;e<(t[i]?.length??0);e+=1){let r=t[i]?.[e]==="#",n=t[i+1]?.[e]==="#";a+=r&&n?"█":r?"▀":n?"▄":" "}n.push("none"===e.colors?a:fX(r,e)(a))}return n}(e);if(t<50)return[...n.map(e=>` ${e}`),"",r].join("\n");let i=function(e){let t=[];for(let r=0;r<fR.length;r+=2){let n="";for(let t=0;t<16;t+=1){let i=fq(fR[r]?.[t]??" ",e),a=fq(fR[r+1]?.[t]??" ",e);void 0===i&&void 0===a?n+=" ":void 0===i?n+=fX(a,e)("▄"):void 0===a?n+=fX(i,e)("▀"):n+=function(e,t,r){let n=new uj({level:"truecolor"===r.colors?3:2}),i="truecolor"===r.colors?n.bgRgb(t.red,t.green,t.blue):n.bgAnsi256(t.ansi256);return"truecolor"===r.colors?i.rgb(e.red,e.green,e.blue)("▀"):i.ansi256(e.ansi256)("▀")}(i,a,e)}t.push(n)}return t}(e),a=(i.length-n.length)/2,s=" ".repeat(2);return[...i.map((e,t)=>{let r=n[t-a];return` ${e}${void 0===r?"":`${s}${r}`}`}),"",r].join("\n")}(e),"",fW("START HERE",e),fG(` ${fJ("sketchi generate",e)} `,fY("interactive",e),t),fG(" ",fJ('sketchi generate --prompt "Map release approval with pass and revise branches"',e),t),fG(" ",fY("Writes <generated-id>.png in this directory. No account or API key needed.",e),t),fV("canvas","Build and export a typed Universal CanvasSpec.",e,t),"",fW("WORK WITH A DIAGRAM",e),fV("show","Inspect a local diagram.",e,t),fV("edit","Replace its canonical document.",e,t),fV("export","Write PNG, Excalidraw, or scene bytes.",e,t),fV("share","Create an encrypted Excalidraw link.",e,t),"",fG("",fY("sketchi docs for every command. Add --output json for automation.",e),t)].join("\n")}function fK(e){if(!Number.isInteger(e)||e<0||e>255)return;if(e<16){let[t,r,n]=fL[e]??[0,0,0];return{red:t,green:r,blue:n}}if(e<232){let t=[0,95,135,175,215,255],r=e-16,n=t[Math.floor(r/36)]??0;return{red:n,green:t[Math.floor(r%36/6)]??0,blue:t[r%6]??0}}let t=8+(e-232)*10;return{red:t,green:t,blue:t}}function fQ(e){let t=e=>{let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4};return .2126*t(e.red)+.7152*t(e.green)+.0722*t(e.blue)}function fZ(e,t){return(Math.max(fQ(e),fQ(t))+.05)/(Math.min(fQ(e),fQ(t))+.05)}function f0(e,t,r){let n=e=>"truecolor"===r?e:fK(e.ansi256)??e;return Math.min(fZ(e,n(fU[t])),fZ(e,n(fF[t])),fZ(e,n(fB[t])))}let f1=new Set(["generate","canvas","docs","create","show","edit","patch","list","restore","share","pull","export"]);function f2(e){return{_tag:"File",path:e}}function f5(e){return{_tag:"InlineJson",value:e}}function f3(e="canonical document"){let t=oA("flag","file").pipe(l$("PATH|-"),lI(`Read one ${e} from PATH, or stdin with -.`),lO(f2)),r=oA("flag","json").pipe(l$("VALUE"),lI(`Read one ${e} from inline JSON.`),lO(f5));return{source:Object.assign(Object.create(Object.getPrototypeOf(t)),t,{parse:e=>{let n=e.flags.file?.length??0,i=e.flags.json?.length??0;return 1===n&&0===i?t.parse(e):0===n&&1===i?r.parse(e):L.fJG(new oc({option:"file/--json",value:0===n&&0===i?"neither provided":"more than one source provided",expected:"exactly one of --file PATH|- or --json VALUE",kind:"flag"}))}}),jsonInput:lE(r)}}function f6(e,t,r){return new oc({option:e,value:t,expected:r,kind:"flag"})}function f8(e){for(let[t,r]of e.entries()){if("--"===r)break;if("--output"===r)return"json"===e[t+1]?"json":"text";if(r.startsWith("--output="))return"--output=json"===r?"json":"text"}return"text"}class f9 extends ee.kl()("@sketchi/cli/OutputWriter"){}class f4 extends nw.rNF()("CliCommandExit",{exitCode:nw.wNn}){}function f7(e){return nN.make({cause:e,operation:"write-output",path:"standard stream",message:"Unable to write command output."})}let pe=V.QZ(f9,L.JkU(function*(){let e=yield*np;return{stdout:t=>((...e)=>tE(e))(t).pipe(tA(e.stdout()),L.xm_(f7)),stderr:t=>((...e)=>tE(e))(t).pipe(tA(e.stderr()),L.xm_(f7))}}));function pt(e){let t=e.details?.map(e=>` - ${e}`).join("\n");return[`error: ${e.code}`,e.message,...e.diagramId?[`diagram: ${e.diagramId}`]:[],...e.storagePath?[`storage: ${e.storagePath}`]:[],...e.recoveryCommand?[`recovery: ${e.recoveryCommand}`]:[],`next: ${e.hint}`,...t?["details:",t]:[]].join("\n")+"\n"}let pr=L.fn("sketchi.cli.output.failure")(function*(e,t,r){let n=yield*f9,i=function(e){switch(e._tag){case"CliFilesystemError":return{code:"filesystem_error",message:e.message,hint:"Check local paths and permissions, then retry."};case"CliInputError":case"CliInteractiveError":case"CliStorageError":return{code:e.code,message:e.message,hint:e.hint};case"CliValidationError":return{code:"invalid_document",message:e.message,hint:e.hint,details:e.details};case"CliBuildError":return{code:"build_failed",message:e.message,hint:e.hint,details:e.details};case"CliCanvasError":case"CliGenerationError":case"CliShareError":return{code:e.code,message:e.message,hint:e.hint,details:e.details};case"CliExportError":return{code:e.code,message:e.message,hint:e.hint,...e.details?{details:e.details}:{},...e.diagramId?{diagramId:e.diagramId}:{},...e.storagePath?{storagePath:e.storagePath}:{},...e.recoveryCommand?{recoveryCommand:e.recoveryCommand}:{}}}}(r),a="json"===t?n2({ok:!1,command:e,error:i}):pt(i);return yield*n.stderr(um(a)),yield*f4.make({exitCode:function(e){switch(e._tag){case"CliInputError":return"interactive_stdin"===e.code?2:3;case"CliValidationError":return 3;case"CliBuildError":return 4;case"CliGenerationError":switch(e.code){case"invalid_generated_document":case"unsupported_diagram_type":return 3;case"provider_failure":return 10;case"generation_timeout":return 11;case"malformed_output":return 12}case"CliCanvasError":switch(e.code){case"canvas_rejected":return 4;case"endpoint_failure":case"network_failure":return 10;case"canvas_timeout":return 11;case"malformed_response":return 12}case"CliInteractiveError":return"cancelled"===e.code?2:1;case"CliStorageError":if("diagram_not_found"===e.code||"revision_not_found"===e.code)return 5;if("diagram_already_exists"===e.code||"diagram_busy"===e.code||"detached_edit"===e.code||"patch_conflict"===e.code||"replacement_conflict"===e.code||"restore_conflict"===e.code)return 6;return 7;case"CliFilesystemError":return 7;case"CliExportError":return 8;case"CliShareError":return"share_transport_failed"===e.code||"share_timeout"===e.code||"share_api_changed"===e.code||"share_link_unavailable"===e.code?13:3}}(r)})}),pn=L.fn("sketchi.cli.output.success")(function*(e,t,r,n,i="stdout"){let a=yield*f9,s="json"===t?n2({ok:!0,command:e,data:r}):n;yield*a[i](s.endsWith("\n")?s:`${s}
57
- `)});function pi(e,t,r,n,i=e=>e){return r.pipe(L.tvg({onFailure:r=>pr(e,t,r),onSuccess:r=>pn(e,t,i(r),n(r))}))}function pa(e,t,r){return nz.make({code:e,message:t,hint:r,details:[]})}function ps(){return pa("share_timeout","The Excalidraw storage request timed out.","Retry once. The unofficial third-party backend may be unavailable.")}function po(){return pa("share_transport_failed","The Excalidraw storage request failed.","Retry once. The unofficial third-party backend may be unavailable.")}let pl=L.fn("sketchi.cli.share.request")(function*(e,t){return yield*L.$mh({try:r=>fetch(e,{...t,redirect:"error",signal:r}),catch:po})}),pd=nw._Re(nw._kM({id:nw.QfV,data:nw.QfV})),pc=nw._Re(nw.mj7(nw.$r1));function pu(){return pa("share_api_changed","The Excalidraw storage API returned an unexpected response.","The unofficial API may have changed; update Sketchi compatibility before retrying.")}class pf extends ee.kl()("@sketchi/cli/ShareTransport"){}let pp=V.Py(pf,{upload:L.fn("sketchi.cli.share.transport.upload")(function*(e){let t=yield*pl("https://json.excalidraw.com/api/v2/post/",{method:"POST",body:Uint8Array.from(e)}),r=yield*a_(t,65536,po);if(!t.ok)return yield*po();let n=yield*pc(r).pipe(L.xm_(po)),i=yield*pd(n).pipe(L.xm_(pu));return/^[A-Za-z0-9_-]{1,128}$/.test(i.id)&&i.data===`${ij}${i.id}`?i.id:yield*pu()},L.mgX({duration:15e3,orElse:()=>L.fJG(ps())})),download:L.fn("sketchi.cli.share.transport.download")(function*(e){let t=yield*pl(`${ij}${e}`,{method:"GET"});return 404===t.status?yield*pa("share_link_unavailable","The Excalidraw share link is unavailable.","Verify the complete bearer link or ask its sender to export a new link."):t.ok?yield*av(t,2097152,po):yield*po()},L.mgX({duration:15e3,orElse:()=>L.fJG(ps())}))});class ph extends ee.kl()("@sketchi/cli/LinkOpener"){}let pm=L.fn("sketchi.cli.share.terminateOpener")(e=>L.E2r(t=>{e.onExit(()=>t(L.rIH)),e.onError(()=>t(L.rIH)),e.kill("SIGTERM")||t(L.rIH)}).pipe(L.wRz("250 millis"),L.KuX("TimeoutError",()=>L.OH5(()=>{e.kill("SIGKILL")})))),pg=function(e=(e,t,r)=>{let n=(0,re.spawn)(e,[...t],r);return{onError:e=>{n.once("error",e)},onExit:e=>{n.once("exit",e)},kill:e=>n.kill(e)}},t=process.platform,r=3e3){return V.Py(ph,{open:n=>L.E2r(r=>{let i=function(e,t){switch(t){case"darwin":return{command:"open",args:[e]};case"win32":return{command:"cmd.exe",args:["/d","/s","/c","start","",e]};default:return{command:"xdg-open",args:[e]}}}(n,t),a=e(i.command,i.args,{shell:!1,stdio:"ignore"});return a.onError(()=>r(L.PyW({status:"unconfirmed",reason:"missing_executable"}))),a.onExit(e=>r(L.PyW(0===e?{status:"accepted"}:{status:"unconfirmed",reason:"nonzero_exit"}))),pm(a)}).pipe(L.wRz(r),L.KuX("TimeoutError",()=>L.PyW({status:"unconfirmed",reason:"timeout"})))})}();class py extends ee.kl()("@sketchi/cli/ExcalidrawShare"){}let pb=V.QZ(py,L.JkU(function*(){let e=yield*pf;return{share:L.fn("sketchi.cli.share.upload")(function*(t){var r;let n=yield*iZ(t).pipe(L.qIB(()=>L.SvU({try:()=>{var e;let r=iH(t);return iF.encode(JSON.stringify({type:r.type,version:r.version,source:r.source,elements:r.elements,appState:(e=r.appState,Object.fromEntries(["gridSize","gridStep","gridModeEnabled","viewBackgroundColor","lockedMultiSelections"].flatMap(t=>t in e?[[t,e[t]]]:[])))},null,2))},catch:()=>iz("unsupported_scene","The Excalidraw scene could not be serialized.","Inspect the local diagram.excalidraw artifact and retry.")}))),i=Buffer.from(crypto.getRandomValues(new Uint8Array(16))).toString("base64url"),a=yield*L.$mh({try:async()=>{if(n.byteLength>0xfffff0)throw iz("share_payload_too_large","The Excalidraw share contents exceed 16 MiB.","Reduce the drawing size and retry.");let e=2097136-iL.byteLength-12-16,t=await function(e,t){let r=iF.encode("null"),n=[i0(1),i0(r.byteLength),r,i0(e.byteLength),e],i=new iN.Gy({chunkSize:65536}),a=[],s=0;for(let[e,r]of(i.onData=e=>{let r=e instanceof Uint8Array?e:new Uint8Array(e);if((s+=r.byteLength)>t)throw iz("share_payload_too_large","The encrypted Excalidraw share payload exceeds 2 MiB.","Reduce the drawing size and retry.");a.push(r)},n.entries()))if(i.push(r,e===n.length-1),0!==i.err)throw Error(i.msg);let o=new Uint8Array(s),l=0;for(let e of a)o.set(e,l),l+=e.byteLength;return o}(n,e),r=Uint8Array.from((void 0)??crypto.getRandomValues(new Uint8Array(12)));if(12!==r.byteLength)throw Error("invalid IV length");let a=new Uint8Array(await crypto.subtle.encrypt({name:"AES-GCM",iv:Uint8Array.from(r)},await iV(i,"encrypt"),Uint8Array.from(t)));var s=[iL,r,a];let o=new Uint8Array(4+s.reduce((e,t)=>e+4+t.byteLength,0));iY(o,0,1);let l=4;for(let e of s)iY(o,l,e.byteLength),l+=4,o.set(e,l),l+=e.byteLength;return o},catch:e=>e instanceof nz?e:iz("share_crypto_failed","The Excalidraw share payload could not be encrypted.","Retry the command. If it persists, inspect the local artifact.")});return{link:(r={id:yield*e.upload(a),key:i},`https://excalidraw.com/#json=${r.id},${r.key}`)}}),pull:L.fn("sketchi.cli.share.pull")(function*(t){var r;let n=yield*iF.encode(t).byteLength>4096?L.fJG(iz("invalid_share_link","The Excalidraw share link is invalid.","Provide one complete https://excalidraw.com/#json=ID,KEY link.",["link exceeds 4 KiB"])):L.SvU({try:()=>{let e=/^https:\/\/(www\.)?excalidraw\.com\/#json=([A-Za-z0-9_-]{1,128}),([A-Za-z0-9_-]{22})$/u.exec(t);if(!e?.[2]||!e[3])throw Error("invalid raw URL grammar");let r=new URL(t),n=`https://${e[1]??""}excalidraw.com/#json=${e[2]},${e[3]}`;if(r.href!==n)throw Error("URL normalization changed the supplied link");return iG(e[3]),{id:e[2],key:e[3]}},catch:()=>iz("invalid_share_link","The Excalidraw share link is invalid.","Provide one complete https://excalidraw.com/#json=ID,KEY link.")}),i=yield*e.download(n.id);return yield*(r=n.key,i.byteLength>2097152?L.fJG(iz("share_payload_too_large","The Excalidraw share payload exceeds 2 MiB.","Use a smaller supported Excalidraw link.")):L.$mh({try:async()=>{let[e,t,n]=iq(i,3);if(!e||!t||!n||12!==t.byteLength)throw Error("invalid encrypted payload chunks");let a=JSON.parse(iB.decode(e));if(!iW(a)||2!==a.version||"pako@1"!==a.compression||"AES-GCM"!==a.encryption)throw Error("unsupported encoding metadata");let s=new Uint8Array(await crypto.subtle.decrypt({name:"AES-GCM",iv:Uint8Array.from(t)},await iV(r,"decrypt"),Uint8Array.from(n))),o=(0,iw.inflateSync)(s,{maxOutputLength:0x1000001});if(o.byteLength>0x1000000)throw Error("decompressed payload exceeds 16 MiB");let l=iq(o,2);if(!l[0]||!l[1])throw Error("invalid inner chunk count");if("null"!==iB.decode(l[0]))throw Error("unsupported contents metadata");return!function(e){let t=iB.decode(e),r=0,n=!1,i=!1;for(let e of t){if(n){i?i=!1:"\\"===e?i=!0:'"'===e&&(n=!1);continue}if('"'===e)n=!0;else if("{"===e||"["===e){if((r+=1)>64)throw Error("JSON structure exceeds depth 64")}else if(("}"===e||"]"===e)&&(r-=1)<0)throw Error("unbalanced JSON structure")}if(0!==r||n)throw Error("incomplete JSON structure")}(l[1]),JSON.parse(iB.decode(l[1]))},catch:e=>e instanceof RangeError||e instanceof Error&&(e.message.includes("maxOutputLength")||e.message.includes("larger than"))?iz("share_payload_too_large","The decompressed Excalidraw share payload exceeds 16 MiB.","Use a smaller supported Excalidraw link."):iz("share_crypto_failed","The Excalidraw share payload could not be decrypted or decoded.","Verify that the complete bearer link is correct and uses current format v2.")}))})}}));function pv(e){return nz.make({code:"unsupported_scene",message:"The pulled Excalidraw scene cannot be rendered safely.",hint:"Use a supported, renderable Excalidraw scene and retry.",details:[e.message]})}let p_=L.fn("sketchi.cli.preflightPullTarget")(function*(e){let t=yield*n3(e),r=yield*i8,n=yield*r.show(t);return{id:t,observed:n}}),px=L.fn("sketchi.cli.pullIntoStore")(function*(e,t,r){let n=r??(yield*p_(e)),i=n.id,a=yield*i8,s=yield*py,o=yield*aR,l=yield*s.pull(t);yield*iZ(l);let d=yield*o.normalizeExcalidraw(l).pipe(L.xm_(pv));return yield*iZ(d),yield*o.renderPng({excalidraw:d}).pipe(L.xm_(pv)),{diagram:yield*a.replaceWithDetached(i,new TextEncoder().encode(n2(d)),n.observed.manifest.revision),sourceIdentity:"unverified"}}),pw=`Sketchi CLI contracts for agents and automation.
52
+ ${o6(e[0].message)}${a}`;let t=new Map;for(let r of e){let e=r._tag??"Error",n=t.get(e)??[];n.push(r),t.set(e,n)}let r=[];for(let[,e]of(r.push(`
53
+ ${o}${s}ERRORS${a}`),t))for(let t of e)r.push(` ${o6(t.message)}${a}`);return r.join("\n")},formatVersion:(e,t)=>`${i.bold(e)} ${i.dim("v")}${i.bold(t)}`}},o9=new Intl.Segmenter(void 0,{granularity:"grapheme"}),o4=/[\p{Mark}\p{Control}\p{Default_Ignorable_Code_Point}]/gu,o7=/\p{Emoji_Presentation}/u,le=e=>{var t;let r=e.replace(o4,"");return 0===r.length?0:o7.test(e)||e.includes("️")?2:!((t=r.codePointAt(0))<4352)&&(t<=4447||9001===t||9002===t||t>=11904&&t<=12350||t>=12352&&t<=42191||t>=44032&&t<=55203||t>=63744&&t<=64255||t>=65040&&t<=65049||t>=65072&&t<=65135||t>=65280&&t<=65376||t>=65504&&t<=65510||t>=110592&&t<=111359||t>=127488&&t<=127569||t>=131072&&t<=262141)?2:1},lt=e=>{let t=0;for(let{segment:r}of o9.segment(e.replace(/\u001B\[[0-9;]*m/g,"")))t+=le(r);return t},lr=(e,t)=>{let r=Math.max(...e.map(e=>lt(e.left)))+4,n=void 0===t?r:Math.min(r,t);return e.map(({left:e,right:t})=>{let r;return` ${r=Math.max(0,Math.max(n,lt(e)+1)-lt(e)),e+" ".repeat(r)}${t}`}).join("\n")},ln=(e,t)=>t?`${e}, ${t}`:e,li=(e,t)=>{let r=[];if(e.description&&(r.push(t.bold("DESCRIPTION")),r.push(` ${e.description}`),r.push("")),r.push(t.bold("USAGE")),r.push(` ${t.cyan(e.usage)}`),r.push(""),e.args&&e.args.length>0){r.push(t.bold("ARGUMENTS"));let n=e.args.map(e=>{let r=e.name;e.variadic&&(r+="...");let n=t.green(r),i=t.dim(e.type),a=`${n} ${i}`,s=e.required?"":t.dim(" (optional)");return{left:a,right:ee.getOrElse(e.description,()=>"")+s}});r.push(lr(n,25)),r.push("")}if(e.flags.length>0){r.push(t.bold("FLAGS"));let n=e.flags.map(e=>{let r=[];for(let n of(r.push(t.green(`--${e.name}`)),e.aliases))r.push(t.green(n));return{left:r.join(", ")+("boolean"!==e.type?` ${t.dim(e.type)}`:""),right:ee.getOrElse(e.description,()=>"")}});r.push(lr(n)),r.push("")}if(e.globalFlags&&e.globalFlags.length>0){r.push(t.bold("GLOBAL FLAGS"));let n=e.globalFlags.map(e=>{let r=[];for(let n of(r.push(t.green(`--${e.name}`)),e.aliases))r.push(t.green(n));return{left:r.join(", ")+("boolean"!==e.type?` ${t.dim(e.type)}`:""),right:ee.getOrElse(e.description,()=>"")}});r.push(lr(n)),r.push("")}if(e.subcommands&&e.subcommands.length>0){let n=e.subcommands.find(e=>void 0===e.group);for(let i of(n&&(r.push(t.bold("SUBCOMMANDS")),r.push(lr(n.commands.map(e=>({left:t.cyan(ln(e.name,e.alias)),right:e.shortDescription??e.description})),20)),e.subcommands.length>1&&r.push("")),e.subcommands))void 0!==i.group&&(r.push(t.bold(`${i.group}:`)),r.push(lr(i.commands.map(e=>({left:t.cyan(ln(e.name,e.alias)),right:e.shortDescription??e.description})),20)),r.push(""))}if(e.examples&&e.examples.length>0){r.push(t.bold("EXAMPLES"));let n=!0,i=!1;for(let a of e.examples)a.description?(n||r.push(""),r.push(` ${t.dim(`# ${a.description}`)}`)):i&&r.push(""),r.push(` ${t.cyan(a.command)}`),n=!1,i=!!a.description;r.push("")}return""===r[r.length-1]&&r.pop(),r.join("\n")},la=e=>e.replace(/[^a-zA-Z0-9_]/g,"_"),ls=e=>{let t=[`--${e.name}`];for(let r of e.aliases)t.push(1===r.length?`-${r}`:`--${r}`);return"Boolean"===e.type._tag&&t.push(`--no-${e.name}`),t},lo=(e,t)=>`${e} "$cur" "$_comp_word" ${t.map(e=>`'${e.replace(/'/g,"'\\''")}'`).join(" ")}`,ll=(e,t)=>{switch(e._tag){case"Boolean":default:return;case"Choice":return lo(t,e.values);case"Path":if("directory"===e.pathType)return'COMPREPLY=( $(compgen -d -- "$cur") )';return'COMPREPLY=( $(compgen -f -- "$cur") )'}},ld=(e,t,r,n)=>{let i=[...t,e.name],a=`_${i.map(la).join("_")}`;r.push(`${a}()`),r.push("{"),r.push(" local cur prev words cword i"),r.push(0===t.length?" local _command_index=0":' local _command_index="$1"'),r.push(' _init_completion -n "$COMP_WORDBREAKS" || return'),0===t.length&&r.push(' local _comp_word="$2"'),r.push("");let s=e.flags.filter(e=>"Boolean"!==e.type._tag);if(s.length>0){for(let e of(r.push(" # Flag value completions"),r.push(' case "$prev" in'),s)){let t=[`--${e.name}`];for(let r of e.aliases)t.push(1===r.length?`-${r}`:`--${r}`);let i=ll(e.type,n);i&&(r.push(` ${t.join("|")})`),r.push(` ${i}`),r.push(" return"),r.push(" ;;"))}r.push(" esac"),r.push("")}if(e.subcommands.length>0){for(let t of(r.push(" # Subcommand dispatch"),r.push(" local cmd _skip_next=0"),r.push(" for ((i = _command_index + 1; i < cword; i++)); do"),r.push(" if (( _skip_next )); then"),r.push(" _skip_next=0"),r.push(" continue"),r.push(" fi"),r.push(' case "${words[i]}" in'),e.flags)){if("Boolean"===t.type._tag)continue;let e=ls(t);r.push(` ${e.join("|")}) _skip_next=1 ;;`),r.push(` ${e.map(e=>`${e}=*`).join("|")}) ;;`)}for(let t of e.subcommands){let e=`_${[...i,t.name].map(la).join("_")}`;r.push(` ${t.name})`),r.push(` ${e} "$i"`),r.push(" return"),r.push(" ;;")}r.push(" esac"),r.push(" done"),r.push("")}((e,t)=>{if(0===e.length)return;let r=e.map(ls);t.push(` local ${r.map((e,t)=>`_used_${t}=""`).join(" ")}`),t.push(" for ((i = 1; i < cword; i++)); do"),t.push(' case "${words[i]%%=*}" in'),r.forEach((e,r)=>{t.push(` ${e.join("|")}) _used_${r}=1 ;;`)}),t.push(" esac"),t.push(" done"),t.push(' local _filtered_flags=""'),r.forEach((e,r)=>{t.push(` [[ -n "$_used_${r}" ]] || _filtered_flags+=" ${e.join(" ")}"`)}),t.push("")})(e.flags,r),(e.flags.length>0||e.subcommands.length>0)&&(r.push(" # Complete flags (filtered) and subcommands"),r.push(' if [[ "$cur" == -* ]]; then'),e.flags.length>0&&r.push(' COMPREPLY=( $(compgen -W "$_filtered_flags" -- "$cur") )'),r.push(" return"),r.push(" fi"),r.push(""));let o=e.arguments.flatMap((e,t)=>{let r=((e,t)=>{switch(e._tag){case"Choice":return lo(t,e.values);case"Path":if("directory"===e.pathType)return'COMPREPLY=( $(compgen -d -- "$cur") )';return'COMPREPLY=( $(compgen -f -- "$cur") )';default:return}})(e.type,n);return void 0===r?[]:[{argument:e,completion:r,index:t}]});if(o.length>0){for(let t of(r.push(" # Positional argument completions"),r.push(" local _position=0 _skip_next=0 _end_of_options=0"),r.push(" for ((i = _command_index + 1; i < cword; i++)); do"),r.push(" if (( _skip_next )); then"),r.push(" _skip_next=0"),r.push(" continue"),r.push(" fi"),r.push(" if (( _end_of_options )); then"),r.push(" ((_position += 1))"),r.push(" continue"),r.push(" fi"),r.push(' case "${words[i]}" in'),r.push(" --) _end_of_options=1 ;;"),e.flags)){let e=ls(t);"Boolean"===t.type._tag?r.push(` ${e.join("|")}) ;;`):(r.push(` ${e.join("|")}) _skip_next=1 ;;`),r.push(` ${e.map(e=>`${e}=*`).join("|")}) ;;`))}for(let{argument:e,completion:t,index:n}of(r.push(" -*) ;;"),r.push(" *) ((_position += 1)) ;;"),r.push(" esac"),r.push(" done"),r.push(' case "$_position" in'),o))e.variadic||(r.push(` ${n})`),r.push(` ${t}`),r.push(" return"),r.push(" ;;"));r.push(" esac");let t=o.find(({argument:e})=>e.variadic);void 0!==t&&(r.push(` if (( _position >= ${t.index} )); then`),r.push(` ${t.completion}`),r.push(" return"),r.push(" fi"))}else if(e.subcommands.length>0){let t=e.subcommands.map(e=>e.name);r.push(` COMPREPLY=( $(compgen -W '${t.join(" ")}' -- "$cur") )`)}for(let t of(r.push("}"),r.push(""),e.subcommands))ld(t,i,r,n)},lc=e=>e.replace(/\\/g,"\\\\").replace(/'/g,"\\'"),lu=e=>lc(e.replace(/[^A-Za-z0-9_.,/@%+-]/gu,"\\$&")),lf=e=>{let t=[];for(let r of e.aliases)1===r.length&&t.push(`-s ${r}`);for(let r of(t.push(e.name),e.aliases))r.length>1&&t.push(r);return"Boolean"===e.type._tag&&t.push(`no-${e.name}`),`not __fish_contains_opt ${t.join(" ")}`},lp=e=>{let t=[`--${e.name}`];for(let r of e.aliases)t.push(1===r.length?`-${r}`:`--${r}`);return`begin; ${lf(e)}; or contains -- (commandline -poc)[-1] ${t.join(" ")}; end`},lh=e=>{let t=[`-l ${e.name}`];for(let r of e.aliases)1===r.length?t.push(`-s ${r}`):t.push(`-l ${r}`);e.description&&t.push(`-d '${lc(e.description)}'`);let r=lm(e.type);return r&&t.push(r),t},lm=e=>{switch(e._tag){case"Boolean":return;case"Choice":return`-r -f -a '${e.values.map(lu).join(" ")}'`;case"Path":return e.pathType,"-r -F";default:return"-r -f"}},lg=e=>{switch(e._tag){case"Choice":return`-r -f -a '${e.values.map(lu).join(" ")}'`;case"Path":return"-r -F";default:return}},ly=(e,t,r,n)=>{let i=((e,t)=>{if(0===e.length)return t.length>0?"__fish_use_subcommand":"";let r=e.map(e=>`__fish_seen_subcommand_from ${e}`).join("; and ");return t.length>0?`${r}; and not __fish_seen_subcommand_from ${t.join(" ")}`:r})(r,t.subcommands.map(e=>e.name)),a=i?`-n '${i}'`:"";if(!t.arguments.some(e=>"Path"===e.type._tag)){let t=[`complete -c ${e}`];a&&t.push(a),t.push("-f"),n.push(t.join(" "))}for(let r of t.subcommands){let t=[`complete -c ${e}`];a&&t.push(a),t.push(`-f -a '${lc(r.name)}'`),r.description&&t.push(`-d '${lc(r.description)}'`),n.push(t.join(" "))}for(let r of t.flags){let t="Boolean"===r.type._tag,a=t?lf(r):lp(r),s=i?`${i}; and ${a}`:a,o=s?`-n '${s}'`:"",l=[`complete -c ${e}`];if(o&&l.push(o),l.push(...lh(r)),n.push(l.join(" ")),t){let t=[`complete -c ${e}`];o&&t.push(o),t.push(`-l no-${r.name}`),r.description&&t.push(`-d '${lc(`Disable ${r.name}`)}'`),n.push(t.join(" "))}}if(t.flags.length>0){let r='not string match -q -- "-*" (commandline -ct)',a=i?`${i}; and ${r}`:r;for(let r of t.flags){let t=`${a}; and ${lf(r)}`,i="Boolean"===r.type._tag,s=[`complete -c ${e}`];if(s.push(`-n '${t}'`),s.push(`-f -a '--${r.name}'`),r.description&&s.push(`-d '${lc(r.description)}'`),n.push(s.join(" ")),i){let i=[`complete -c ${e}`];i.push(`-n '${t}'`),i.push(`-f -a '--no-${r.name}'`),r.description&&i.push(`-d '${lc(`Disable ${r.name}`)}'`),n.push(i.join(" "))}}}for(let r of t.arguments){let t=lg(r.type);if(t){let i=[`complete -c ${e}`];a&&i.push(a),i.push(t),r.description&&i.push(`-d '${lc(r.description)}'`),n.push(i.join(" "))}}for(let i of t.subcommands)ly(e,i,[...r,i.name],n)},lv=e=>e.replace(/\\/g,"\\\\").replace(/'/g,"'\\''").replace(/:/g,"\\:"),lb=e=>e.replace(/[^A-Za-z0-9_.,/@%+-]/gu,"\\$&").replace(/'/g,"'\\''"),l_=e=>e.replace(/[^a-zA-Z0-9_]/g,"_"),lx=e=>{let t=[],r=e.description?`[${lv(e.description)}]`:"",n=(e=>{switch(e._tag){case"Boolean":return"";case"Choice":return`:value:(${e.values.map(lb).join(" ")})`;case"Path":return"directory"===e.pathType?":directory:_directories":":file:_files";case"Int":return":integer:";case"Finite":return":float:";case"Date":return":date:";default:return":value:"}})(e.type),i=`(${(e=>{let t=[`--${e.name}`];for(let r of e.aliases)t.push(1===r.length?`-${r}`:`--${r}`);return"Boolean"===e.type._tag&&t.push(`--no-${e.name}`),t})(e).join(" ")})`;for(let a of(t.push(`'${i}--${e.name}${r}${n}'`),e.aliases)){let e=1===a.length?"-":"--";t.push(`'${i}${e}${a}${r}${n}'`)}if("Boolean"===e.type._tag){let r=e.description?`[${lv(`Disable ${e.name}`)}]`:"";t.push(`'${i}--no-${e.name}${r}'`)}return t},lw=e=>{let t=e.description?lv(e.description):e.name,r=(e=>{switch(e._tag){case"Choice":return`(${e.values.map(lb).join(" ")})`;case"Path":return"directory"===e.pathType?"_directories":"_files";default:return""}})(e.type),n=e.variadic?"*":"";return`'${n}:${t}:${r}'`},lk=(e,t,r)=>{let n=[...t,e.name],i=`_${n.map(l_).join("_")}`;if(r.push(`${i}() {`),e.subcommands.length>0){for(let t of(r.push(" local context state state_descr line"),r.push(" typeset -A opt_args"),r.push(""),r.push(" local -a commands"),r.push(" commands=("),e.subcommands)){let e=t.description?lv(t.description):"";r.push(` '${t.name}:${e}'`)}for(let t of(r.push(" )"),r.push(""),r.push(" local -a specs"),r.push(" specs=("),e.flags))for(let e of lx(t))r.push(` ${e}`);if(e.arguments.length>0){for(let t of(r.push(" -"),r.push(" parent-arguments"),e.arguments))r.push(` ${lw(t)}`);r.push(" -"),r.push(" subcommands")}for(let t of(r.push(" '1:command:->command'"),r.push(" '*::arg:->args'"),r.push(" )"),r.push(""),r.push(' _arguments -C "${specs[@]}"'),r.push(""),r.push(' case "$state" in'),r.push(" command)"),r.push(" _describe -t commands 'commands' commands"),r.push(" ;;"),r.push(" args)"),r.push(' case "$words[1]" in'),e.subcommands)){let e=`_${[...n,t.name].map(l_).join("_")}`;r.push(` ${t.name})`),r.push(` ${e}`),r.push(" ;;")}r.push(" esac"),r.push(" ;;"),r.push(" esac")}else{let t=[];for(let r of e.flags)t.push(...lx(r));for(let r of e.arguments)t.push(lw(r));if(t.length>0){for(let e of(r.push(" local -a specs"),r.push(" specs=("),t))r.push(` ${e}`);r.push(" )"),r.push(' _arguments "${specs[@]}"')}}for(let t of(r.push("}"),r.push(""),e.subcommands))lk(t,n,r)},lS=e=>oA({name:e,primitiveType:ow,kind:"flag"}),lI=(e,t)=>oP("flag",e,t.map(e=>[e,e])),l$=(0,z.XY)(2,(e,t)=>oj(e,t)),lE=(0,z.XY)(2,(e,t)=>oD(e,t)),lO=(0,z.XY)(2,(e,t)=>oq(e,t)),lC=e=>oL(e),lT=(0,z.XY)(2,(e,t)=>oU(e,t)),lM=(0,z.XY)(2,(e,t)=>oB(e,t)),lA=(0,z.XY)(2,(e,t)=>oJ(e,t)),lN=(0,z.XY)(3,(e,t,r)=>oX(e,t,r));var lP=n(2275);let lR="~effect/cli/Command/Config/Internal",lj=e=>{let t=[],r=[],n=[];return{[lR]:lR,flags:r,arguments:n,orderedParams:t,tree:function e(i){let a=Object.create(null);for(let s of Object.keys(i))a[s]=function i(a){if(Array.isArray(a))return{_tag:"Array",children:a.map(e=>i(e))};if(!eh.i5(a,oO))return{_tag:"Nested",tree:e(a)};{let e=t.length;return t.push(a),"argument"===a.kind?n.push(a):r.push(a),{_tag:"Param",index:e}}}(i[s]);return a}(e)}},lD=lj({}),lU=(e,t)=>{switch(e._tag){case"Param":return{_tag:"Param",index:e.index+t};case"Array":return{_tag:"Array",children:e.children.map(e=>lU(e,t))};case"Nested":return{_tag:"Nested",tree:lF(e.tree,t)}}},lF=(e,t)=>{let r=Object.create(null);for(let n of Object.keys(e))r[n]=lU(e[n],t);return r},lB=(e,t)=>{let r=e.orderedParams.length;return{[lR]:lR,flags:[...e.flags,...t.flags],arguments:[...e.arguments,...t.arguments],orderedParams:[...e.orderedParams,...t.orderedParams],tree:Object.assign(Object.create(null),e.tree,lF(t.tree,r))}},lL=(e,t)=>{let r={};for(let n of Object.keys(e))lP.x(r,n,function e(r){switch(r._tag){case"Param":return t[r.index];case"Array":return r.children.map(t=>e(t));case"Nested":return lL(r.tree,t)}}(e[n]));return r},lz="~effect/cli/Command",lW=e=>e,lJ={...tB.bp({label:"Command",evaluate(){return lW(this).service}})},lY=e=>{let t=e.config,r=e.contextConfig??lD,n=e.service??Z.kl(`${lz}/${e.name}`),i=e.annotations??Z.Ie(),a=e.globalFlags??[],s=e.subcommands??[],o=e.parse??lG(t),l=e.parseContext??lG(r,{allowLeftovers:!0});return Object.assign(Object.create(lJ),{[lz]:lz,name:e.name,examples:e.examples??[],annotations:i,globalFlags:a,subcommands:s,unlisted:e.unlisted??!1,config:t,contextConfig:r,service:n,parse:o,parseContext:l,handle:(t,r)=>eh.EA(e.handle)?e.handle(t,r):B.fJG(new oh({commandPath:r,errors:[]})),buildHelpDoc:r=>{let n=[],a=[];for(let e of t.arguments){let t=o0(e),r=o2(e);for(let e of t)n.push({name:e.name,type:e.typeName??oI(e.primitiveType),description:e.description,required:!r.isOptional&&(!r.isVariadic||ee.exists(r.variadicMin,e=>e>0)),variadic:r.isVariadic})}let o=r.length>0?r.join(" "):e.name;for(let e of(s.some(e=>e.commands.some(e=>!e.unlisted))&&(o+=" <subcommand>"),o+=" [flags]",n)){let t=e.variadic?`<${e.name}...>`:`<${e.name}>`;o+=` ${e.required?t:`[${t}]`}`}for(let e of t.flags){let t=o0(e),r=o2(e);for(let e of t)e.hidden||a.push(lX(e,r))}let l=[];for(let e of s){let t=e.commands.filter(e=>!e.unlisted);0!==t.length&&l.push({group:e.group,commands:K.Tj(t,e=>({name:e.name,alias:e.alias,shortDescription:e.shortDescription,description:e.description??""}))})}let d=e.examples??[];return{description:e.description??"",usage:o,flags:a,annotations:i,...n.length>0&&{args:n},...l.length>0&&{subcommands:l},...d.length>0&&{examples:d}}},...eh.EA(e.description)?{description:e.description}:{},...eh.EA(e.shortDescription)?{shortDescription:e.shortDescription}:{},...eh.EA(e.alias)?{alias:e.alias}:{}})},lX=(e,t)=>{let r=e.aliases.map(e=>1===e.length?`-${e}`:`--${e}`);return{name:e.name,aliases:r,type:e.typeName??oI(e.primitiveType),description:lq(e.description,o$(e.primitiveType)),required:"Boolean"!==e.primitiveType._tag&&!t.isOptional}},lq=(e,t)=>{if(void 0===t||0===t.length)return e;let r=`(choices: ${t.join(", ")})`;return ee.match(e,{onNone:()=>ee.some(r),onSome:e=>ee.some(`${e} ${r}`)})},lG=(e,t)=>B.D9k(function*(r){let n={flags:r.flags,arguments:r.arguments},[i,a]=yield*lV(n,e.orderedParams);return t?.allowLeftovers!==!0&&i.length>0?yield*new od({arguments:i}):lL(e.tree,a)}),lV=B.D9k(function*(e,t){let r=[],n=e.arguments;for(let i of t){let[t,a]=yield*i.parse({flags:e.flags,arguments:n});r.push(a),n=t}return[n,r]}),lH=(e,t,r)=>{let n=lW(e),i=new Set;for(let e of(r?.contextConfig??n.contextConfig).flags)for(let t of o0(e))i.add(t.name);for(let r of t)for(let t of lW(r).config.flags)for(let n of o0(t))if(i.has(n.name))throw new os({option:n.name,parentCommand:e.name,childCommand:r.name})},lK=e=>{switch(e.primitiveType._tag){case"Boolean":return{_tag:"Boolean"};case"Int":return{_tag:"Int"};case"Finite":return{_tag:"Finite"};case"Date":return{_tag:"Date"};case"Choice":return{_tag:"Choice",values:o$(e.primitiveType)??[]};case"Path":return{_tag:"Path",pathType:oE(e.primitiveType)??"either"};case"FileText":case"FileParse":case"FileSchema":return{_tag:"Path",pathType:"file"};default:return{_tag:"String"}}},lQ=e=>{switch(e.primitiveType._tag){case"Int":return{_tag:"Int"};case"Finite":return{_tag:"Finite"};case"Date":return{_tag:"Date"};case"Choice":return{_tag:"Choice",values:o$(e.primitiveType)??[]};case"Path":return{_tag:"Path",pathType:oE(e.primitiveType)??"either"};case"FileText":case"FileParse":case"FileSchema":return{_tag:"Path",pathType:"file"};default:return{_tag:"String"}}},lZ=(e,t=[])=>{let r=lW(e),n=r.config,i=[],a=new Set;for(let[e,r]of[...n.flags,...t].entries())for(let t of o0(r))"flag"===t.kind&&!t.hidden&&(e>=n.flags.length&&a.has(t.name)||(a.add(t.name),i.push({name:t.name,aliases:t.aliases,description:ee.getOrUndefined(t.description),type:lK(t)})));let s=[];for(let e of n.arguments){let t=o0(e),r=o2(e);for(let e of t)"argument"===e.kind&&s.push({name:e.name,description:ee.getOrUndefined(e.description),required:!r.isOptional,variadic:r.isVariadic,type:lQ(e)})}let o=[],l=[...t,...r.contextConfig.flags];for(let t of e.subcommands)for(let e of t.commands){if(e.unlisted)continue;let t=lZ(e,l);o.push(t),e.alias&&e.alias!==e.name&&o.push({...t,name:e.alias})}return{name:e.name,description:e.shortDescription??e.description,flags:i,arguments:s,subcommands:o}},l0=e=>{let t=new Set,r=[];for(let n of e)t.has(n)||(t.add(n),r.push(n));return r},l1=(e,t)=>{let r=[e],n=e;for(let e=1;e<t.length;e++){let i,a=t[e];for(let e of n.subcommands)if(i=e.commands.find(e=>e.name===a))break;if(!i)break;r.push(i),n=i}return r},l2=(e,t,r)=>{let n=l1(e,t).flatMap(e=>lW(e).globalFlags);return l0([...r,...n])},l5=(e,t,r)=>B.JkU(function*(){let n=l1(e,t),i=lW(n.length>0?n[n.length-1]:e).buildHelpDoc(t),a=((e,t)=>{if(e.length<=1)return[];let r=new Set(t.map(e=>e.name)),n=[];for(let t of e.slice(0,-1))for(let e of lW(t).contextConfig.flags){let t=o0(e),i=o2(e);for(let e of t)!r.has(e.name)&&(e.hidden||(r.add(e.name),n.push(lX(e,i))))}return n})(n,i.flags),s=l2(e,t,r),o=[];for(let e of s){let t=o0(e.flag),r=o2(e.flag);for(let e of t)e.hidden||o.push({...lX(e,r),required:!1})}return{...i,flags:[...a,...i.flags],globalFlags:o}}),l3=e=>({_tag:"Action",flag:e.flag,run:e.run}),l6=0,l8=l3({flag:(lS("help")).pipe(l$("h"),lE("Show help information"),oz(!1)),run:B.D9k(function*(e,{builtIns:t,command:r,commandPath:n}){let i=yield*o3,a=yield*l5(r,n,t);yield*on(i.formatHelpDoc(a))})}),l9=l3({flag:(lS("version")).pipe(l$("v"),lE("Show version information"),oz(!1)),run:B.D9k(function*(e,{command:t,version:r}){let n=yield*o3;yield*on(n.formatVersion(t.name,r))})}),l4=l3({flag:(lS("wizard")).pipe(lE("Start wizard mode for a command"),oz(!1)),run:()=>B.rIH}),l7=l3({flag:(lI("completions",["bash","zsh","fish","sh"])).pipe(lC,lT(e=>ee.map(e,e=>"sh"===e?"bash":e)),lO("<bash|zsh|fish|sh>"),lE("Print shell completion script")),run:B.D9k(function*(e,{command:t}){if(ee.isNone(e))return;let r=lZ(t);yield*on(((e,t,r)=>{switch(t){case"bash":return((e,t)=>{let r=[],n=la(e),i=`_${n}--choices`;return r.push(`###-begin-${e.replace(/'/g,"'\\''")}-completions-###`),r.push("#"),r.push("# Static completion script for Bash"),r.push("#"),r.push("# Installation:"),r.push(`# ${e.replace(/'/g,"'\\''")} --completions bash >> ~/.bashrc`),r.push("#"),r.push(""),r.push("if ! type _init_completion &>/dev/null; then"),r.push(" _init_completion()"),r.push(" {"),r.push(" COMPREPLY=()"),r.push(' local _i _j=0 _piece _line="$COMP_LINE"'),r.push(' words=("${COMP_WORDS[0]}")'),r.push(" cword=0"),r.push(' _line="${_line#*"${COMP_WORDS[0]}"}"'),r.push(" for ((_i = 1; _i < ${#COMP_WORDS[@]}; _i++)); do"),r.push(' _piece="${COMP_WORDS[_i]}"'),r.push(' if [[ "$_line" == [[:blank:]]* ]]; then'),r.push(" ((_j++))"),r.push(' words[_j]="$_piece"'),r.push(" else"),r.push(' words[_j]="${words[_j]}$_piece"'),r.push(" fi"),r.push(" ((_i == COMP_CWORD)) && cword=$_j"),r.push(' _line="${_line#*"$_piece"}"'),r.push(" done"),r.push(' cur="${words[cword]}"'),r.push(' prev=""'),r.push(' ((cword > 0)) && prev="${words[cword-1]}"'),r.push(" return 0"),r.push(" }"),r.push("fi"),r.push(""),r.push(`${i}()`),r.push("{"),r.push(' local _cur="$1" _word="$2"; shift 2'),r.push(""),r.push(' local _head="${_cur%"$_word"}"'),r.push(' local _open=""'),r.push(' case "$_head" in'),r.push(" *\\') _open=\"'\" ;;"),r.push(" *\\\") _open='\"' ;;"),r.push(" esac"),r.push(""),r.push(' local _prefix="$_cur" _committed="$_head"'),r.push(" _prefix=${_prefix//\\\\/}; _prefix=${_prefix//\\\"/}; _prefix=${_prefix//\\'/}"),r.push(" _committed=${_committed//\\\\/}; _committed=${_committed//\\\"/}; _committed=${_committed//\\'/}"),r.push(""),r.push(" COMPREPLY=()"),r.push(" local _choice _rest _match"),r.push(' for _choice in "$@"; do'),r.push(' [[ "$_choice" == "$_prefix"* ]] || continue'),r.push(' _rest="${_choice#"$_committed"}"'),r.push(' case "$_open" in'),r.push(' "\'")'),r.push(' if [[ "$_head" == "\'" ]]; then'),r.push(" _match=${_rest//\\'/\\'\\\\\\'\\'}"),r.push(" else"),r.push(' [[ "$_rest" == *\\\'* ]] && continue'),r.push(' _match="$_rest"'),r.push(" fi"),r.push(" ;;"),r.push(" '\"')"),r.push(' _match="${_rest//\\\\/\\\\\\\\}"'),r.push(' _match="${_match//\\$/\\\\$}"'),r.push(' _match="${_match//\\`/\\\\\\`}"'),r.push(' _match="${_match//\\"/\\\\\\"}"'),r.push(" ;;"),r.push(" *)"),r.push(" printf -v _match '%q' \"$_rest\""),r.push(' [[ -z "$_head" && "$_match" == \'~\'* ]] && _match="\\\\$_match"'),r.push(" ;;"),r.push(" esac"),r.push(' [[ -n "$_open" && "$_match" == *"$_open" ]] && _match+="$_open"'),r.push(' COMPREPLY+=("$_match")'),r.push(" done"),r.push("}"),r.push(""),ld(t,[],r,i),r.push(`complete -F _${n} ${e.replace(/'/g,"'\\''")}`),r.push(`###-end-${e.replace(/'/g,"'\\''")}-completions-###`),r.join("\n")})(e,r);case"zsh":let n,i;return n=[],i=l_(e),n.push(`#compdef ${e}`),n.push(`###-begin-${e}-completions-###`),n.push("#"),n.push("# Static completion script for Zsh"),n.push("#"),n.push("# Installation:"),n.push(`# ${e} --completions zsh > ~/.zsh/completions/_${e}`),n.push("# then add ~/.zsh/completions to your fpath"),n.push("#"),n.push(""),lk(r,[],n),n.push("# Handle both direct invocation and autoload"),n.push('if [[ "${zsh_eval_context[-1]}" == "loadautofunc" ]]; then'),n.push(` _${i} "$@"`),n.push("else"),n.push(` compdef _${i} ${e}`),n.push("fi"),n.push(`###-end-${e}-completions-###`),n.join("\n");case"fish":let a;return(a=[]).push(`###-begin-${e}-completions-###`),a.push("#"),a.push("# Static completion script for Fish"),a.push("#"),a.push("# Installation:"),a.push(`# ${e} --completions fish > ~/.config/fish/completions/${e}.fish`),a.push("#"),a.push(""),ly(e,r,[],a),a.push(""),a.push(`###-end-${e}-completions-###`),a.join("\n")}})(t.name,e.value,r))})}),de=(N="log-level",e=>(l6+=1,Object.assign(Z.kl(`effect/cli/GlobalFlag/${N}/${l6}`),{_tag:"Setting",id:N,flag:e.flag})))({flag:oP("flag","log-level",[["all","All"],["trace","Trace"],["debug","Debug"],["info","Info"],["warn","Warn"],["warning","Warn"],["error","Error"],["fatal","Fatal"],["none","None"]]).pipe(lC,lE("Sets the minimum log level"),lO("<all|trace|debug|info|warn|warning|error|fatal|none>"))}),dt=[l8,l9,l4,l7,de];class dr extends Z.Or("effect/cli/CliConfig",{defaultValue:()=>dn}){}let dn={builtIns:dt},di=/^-(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?$/,da=e=>{let t=[];for(let r of e)if(!r.startsWith("-")||di.test(r))t.push({_tag:"Value",value:r});else if(r.startsWith("--")){let e=r.indexOf("=");if(-1!==e){let n=r.slice(2,e),i=r.slice(e+1);t.push({_tag:"LongOption",name:n,raw:r,value:i})}else t.push({_tag:"LongOption",name:r.slice(2),raw:r})}else if(r.length>1){let e=r.slice(1),n=e.indexOf("=");if(-1!==n){let r=e.slice(0,n),i=e.slice(n+1);t.push({_tag:"ShortOption",flag:r,raw:`-${r}`,value:i})}else for(let r of e)t.push({_tag:"ShortOption",flag:r,raw:`-${r}`})}else t.push({_tag:"Value",value:r});return t},ds=(e,t)=>{let r=t.map(t=>[((e,t)=>{let r=e.length,n=t.length,i=Array.from({length:r+1},()=>Array(n+1).fill(0));for(let e=0;e<=r;e++)i[e][0]=e;for(let e=0;e<=n;e++)i[0][e]=e;for(let a=1;a<=r;a++)for(let r=1;r<=n;r++){let n=+(e[a-1]!==t[r-1]);i[a][r]=Math.min(i[a-1][r]+1,i[a][r-1]+1,i[a-1][r-1]+n)}return i[r][n]})(e,t),t]).filter(([e])=>e<=2).sort(([e],[t])=>e-t);if(0===r.length)return[];let n=r[0][0];return r.filter(([e])=>e===n).map(([,e])=>e)},dl=e=>ee.match(e.subcommand,{onNone:()=>[],onSome:e=>[e.name,...dl(e.parsedInput)]}),dd=(e,t,r=[])=>B.JkU(function*(){let{tokens:n,trailingOperands:i}=e,a=[...r,t.name],s=lW(t),o=s.config.flags.flatMap(o0).filter(oM),l=du(o),d=s.contextConfig.flags.flatMap(o0).filter(oM),c=du(d),u=new Set(d.map(e=>e.name)),f=d$(n,{command:t,commandPath:a,flagRegistry:l,inheritedFlagRegistry:c,localFlagNames:o.filter(e=>!u.has(e.name)).map(e=>e.name)});if("Leaf"===f._tag)return{flags:f.flags,arguments:[...f.arguments,...i],subcommand:ee.none(),...f.errors.length>0&&{errors:f.errors}};let p={tokens:f.childTokens,trailingOperands:i},h=yield*dd(p,f.sub,a),m=[...f.errors,...h.errors??[]];return{flags:f.flags,arguments:[],subcommand:ee.some({name:f.sub.name,parsedInput:h}),...m.length>0&&{errors:m}}}),dc=e=>{let t=0;return{peek:()=>e[t],take:()=>e[t++],rest:()=>e.slice(t)}},du=e=>{let t=new Map;for(let r of e){if(t.has(r.name))throw Error(`Duplicate flag name "${r.name}" in command definition`);for(let e of(t.set(r.name,r),r.aliases)){if(t.has(e))throw Error(`Duplicate flag/alias "${e}" in command definition (conflicts with "${t.get(e).name}")`);t.set(e,r)}}return{params:e,index:t}},df=e=>{let t=new Map,r=(e,r)=>{let n=t.get(e);if(n&&n!==r)throw Error(`Duplicate subcommand name/alias "${e}" in command definition (conflicts with "${n.name}")`);t.set(e,r)};for(let t of e)for(let e of t.commands)r(e.name,e),e.alias&&e.alias!==e.name&&r(e.alias,e);return t},dp=e=>Object.fromEntries(e.map(e=>[e.name,[]])),dh=e=>"LongOption"===e._tag||"ShortOption"===e._tag,dm=e=>"LongOption"===e._tag?e.name:e.flag,dg=(e,t)=>{let r=dm(e),n=t.index.get(r);if(n&&n.name===r)return{param:n,negated:!1};if("LongOption"===e._tag&&e.name.startsWith("no-")){let r=e.name.slice(3),n=t.index.get(r);if(n&&n.name===r&&ob(n.primitiveType))return{param:n,negated:!0}}if(n)return{param:n,negated:!1}},dy=(e,t,r)=>new oc({option:t.name,value:r,expected:`omit the value and use ${e.raw} by itself to set --${t.name} to false`,kind:"flag"}),dv=e=>e?._tag==="Value"&&(oy(e.value)||ov(e.value))?e.value:void 0,db=(e,t,r,n=!1)=>{let i=d_(e,t,r,n);switch(i._tag){case"Value":return{_tag:"Value",value:i.value};case"Error":return{_tag:"Error",error:i.error}}},d_=(e,t,r,n=!1)=>{let i;if(n){if(void 0!==t.value)return{_tag:"Error",error:dy(t,r,t.value),tokens:[]};let n=dv(e.peek());if(void 0!==n){let i=e.take();return{_tag:"Error",error:dy(t,r,n),tokens:void 0===i?[]:[i]}}return{_tag:"Value",value:"false",tokens:[]}}if(void 0!==t.value)return{_tag:"Value",value:t.value,tokens:[]};if(ob(r.primitiveType)){let t=dv(e.peek()),r=void 0!==t?e.take():void 0;return{_tag:"Value",value:t??"true",tokens:void 0===r?[]:[r]}}let a=e.peek();if(a?._tag==="Value"){let t=e.take();return{_tag:"Value",value:a.value,tokens:void 0===t?[]:[t]}}return{_tag:"Error",error:(i=o$(r.primitiveType),new oc({option:r.name,value:"",expected:void 0===i?r.typeName??oI(r.primitiveType):i.join(" | "),kind:"flag"})),tokens:[]}},dx=(e,t)=>{for(let r of t){let t=dg(e,r);if(void 0!==t)return t}},dw=(e,t,r,n)=>{e.push(r);let i=d_(t,r,n.param,n.negated);e.push(...i.tokens)},dk=(e,t,r,n,i)=>{let a=dc(t);d_(a,e,r.param,r.negated);for(let e=a.take();e;e=a.take()){if(dh(e)){let t=dx(e,i);void 0!==t&&d_(a,e,t.param,t.negated);continue}if("Value"===e._tag)return n.has(e.value)}return!1},dS=(e,t,r,n)=>{let{commandPath:i,flagRegistry:a}=r,s=dg(e,a);if(!s)return void n.errors.push(((e,t,r)=>{let n="LongOption"===e._tag?`--${e.name}`:`-${e.flag}`,i=[];for(let e of t)if(!e.hidden)for(let t of(i.push(e.name),ob(e.primitiveType)&&i.push(`no-${e.name}`),e.aliases))i.push(t);return new oa({option:n,suggestions:ds(dm(e),i).map(e=>1===e.length?`-${e}`:`--${e}`),command:r})})(e,a.params,i));let o=db(t,e,s.param,s.negated);"Error"===o._tag?n.errors.push(o.error):n.flags.add(s.param.name,o.value)},dI=(e,t,r,n)=>{if("AwaitingFirstValue"===n.mode._tag){let i=((e,t,r,n)=>{let{command:i,commandPath:a,inheritedFlagRegistry:s,localFlagNames:o}=r,l=df(i.subcommands),d=l.get(e);if(d){let e=[...a,d.name],r=n.flags.snapshot();for(let t of o){let i=r[t];void 0!==i&&i.length>0&&n.errors.push(new oa({option:`--${t}`,suggestions:[],command:e}))}let i=((e,t)=>{let r=dp(t.params),n=[],i=[],a=dc(e);for(let e=a.take();e;e=a.take()){if(!dh(e)){n.push(e);continue}let s=dg(e,t);if(!s){n.push(e);continue}let o=db(a,e,s.param,s.negated);if("Error"===o._tag){i.push(o.error);continue}void 0!==o.value&&r[s.param.name].push(o.value)}return{flagMap:r,remainder:n,errors:i}})(t.rest(),s);return n.flags.merge(i.flagMap),n.errors.push(...i.errors),{_tag:"Subcommand",result:{_tag:"Sub",flags:n.flags.snapshot(),sub:d,childTokens:i.remainder,errors:n.errors}}}if(!(lW(i).config.arguments.length>0)&&l.size>0){let t=[];for(let[e,r]of l)r.unlisted||t.push(e);let r=ds(e,t);n.errors.push(new ou({subcommand:e,parent:a,suggestions:r}))}return{_tag:"Argument"}})(e,t,r,n);if("Subcommand"===i._tag)return i.result;n.mode={_tag:"CollectingArguments"}}n.arguments.push(e)},d$=(e,t)=>{let r,n=dc(e),i={flags:(r=dp(t.flagRegistry.params),{add:(e,t)=>{void 0!==t&&r[e].push(t)},merge:e=>{for(let t in e){let n=e[t];if(n?.length)for(let e=0;e<n.length;e++)r[t].push(n[e])}},snapshot:()=>r}),arguments:[],errors:[],mode:{_tag:"AwaitingFirstValue"}};for(let e=n.take();e;e=n.take()){if(dh(e)){dS(e,n,t,i);continue}if("Value"===e._tag){let r=dI(e.value,n,t,i);if(r)return r}}return{_tag:"Leaf",flags:i.flags.snapshot(),arguments:i.arguments,errors:i.errors}};var dE=n(7011),dO=n(7876),dC=n(2860);eh.Et,dC.wN,dO.wN;let dT=(0,z.XY)(2,(e,t)=>{let r=Math.pow(10,t);return Math.round(e*r)/r}),dM=(e,...t)=>{let r=t.flat();return`${r.join("")}${e}\x1b[0m`},dA={prefix:"?",arrowUp:"↑",arrowDown:"↓",checkboxOn:"☒",checkboxOff:"☐",tick:"✔",ellipsis:"…",pointerSmall:"›",pointer:"❯",descriptionSeparator:"- ",passwordMask:"*",toggleSeparator:"/",primaryColor:"\x1b[96m",mutedColor:"\x1b[90m",successColor:"\x1b[32m",errorColor:"\x1b[31m",submittedColor:"\x1b[37m"},dN={...dA,checkboxOn:"[*]",checkboxOff:"[ ]",tick:"√",ellipsis:"...",pointerSmall:"»",pointer:">"},dP=Z.Or("effect/cli/Prompt/Theme",{defaultValue:e=>({..."win32"===process.platform?dN:dA,...e})}),dR=e=>B.TjK(dP,t=>({...t,...e.theme})),dj=e=>dM(e,"\x1b[1m"),dD=(e,t)=>dM(e,((...e)=>e)("\x1b[3m",t)),dU=(e,...t)=>0===e.length?"":dM(e,...t),dF=(e,t)=>0===e.length?t:e+" "+t,dB=e=>{let t={initial:!1,...e,label:{confirm:"yes",deny:"no",...e.label},placeholder:{defaultConfirm:"(Y/n)",defaultDeny:"(y/N)",...e.placeholder}};return dL({value:t.initial},{render:d8(t),process:e=>d7(e,t.initial),clear:d2(t)})},dL=(e,...t)=>{let[r,n]=1===t.length?[void 0,t[0]]:[t[0],t[1]],i=Object.create(dV);return i._tag="Loop",i.initialState=e,i.render=n.render,i.process=n.process,i.clear=n.clear,i.events=r,i},dz=(0,z.XY)(2,(e,t)=>{let r=Object.create(dV);return r._tag="OnSuccess",r.prompt=e,r.onSuccess=t,r}),dW=e=>{let t={default:0,min:globalThis.Number.NEGATIVE_INFINITY,max:globalThis.Number.POSITIVE_INFINITY,incrementBy:1,decrementBy:1,validate:e=>e<t.min?B.fJG(`${e} must be greater than or equal to ${t.min}`):e>t.max?B.fJG(`${e} must be less than or equal to ${t.max}`):B.PyW(e),...e},r=void 0===e.default?"":`${t.default}`;return dL({cursor:r.length,value:r,error:ee.none()},{render:c$(t),process:cE(t),clear:cb(t)})},dJ=(0,z.XY)(2,(e,t)=>dz(e,e=>dq(t(e)))),dY=B.D9k(function*(e){let t=yield*nI,r=yield*t.readInput;return yield*dH(e,t,r)},B.xm_(()=>new nS({})),B.P1j),dX=e=>{let t={maxPerPage:10,...e};return dL((e=>{let t=0,r=-1;for(let t=0;t<e.length;t++)if(!0===e[t].selected){if(-1!==r)throw Error("InvalidArgumentException: only a single choice can be selected by default for Prompt.Select");r=t}return -1!==r&&(t=r),t})(t.choices),{render:cR(t),process:cD(t),clear:cj(t)})},dq=e=>{let t=Object.create(dV);return t._tag="Succeed",t.value=e,t},dG=e=>{let t={initial:!1,active:"on",inactive:"off",...e};return dL(t.initial,{render:cZ(t),process:c0,clear:()=>cX(t)})},dV={...tB.bp({label:"Prompt",evaluate(){return dY(this)}}),"~effect/cli/Prompt":{_Output:e=>e}},dH=(e,t,r)=>B.DYE(()=>{switch(e._tag){case"Loop":return dK(e,t,r);case"OnSuccess":return B.qIB(dH(e.prompt,t,r),n=>dH(e.onSuccess(n),t,r));case"Succeed":return B.PyW(e.value)}}),dK=B.D9k(function*(e,t,r){let n=B.yw5(e.initialState)?yield*e.initialState:e.initialState,i=dQ.NextFrame({state:n}),a="";for(;;){let s=yield*e.render(n,i);if(yield*B.QgK(t.display(a+s)),a="",e.events){let t=ej(r).pipe(B.TjK(e=>({_tag:"Input",input:e}))),a=yield*B.KT6(t,ej(e.events).pipe(B.TjK(e=>({_tag:"Event",value:e}))));i=yield*e.process(a,n)}else{let t=yield*ej(r);i=yield*e.process(t,n)}switch(i._tag){case"Beep":continue;case"NextFrame":a=yield*e.clear(n,i),n=i.state;continue;case"Submit":{a=yield*e.clear(n,i);let r=yield*e.render(n,i);return yield*B.QgK(t.display(a+r)),i.value}}}},(e,t,r)=>B.yeE(e,B.QgK(r.display("\x1b[?25h")))),dQ=et.Ij(),dZ=(e,t)=>{if(0===t)return"\x1b[2K\x1b[1G";let r=0;for(let n of e.split(d1))r+=1+Math.floor(Math.max(n.length-1,0)/t);var n=r;let i="";for(let e=0;e<n;e++)i+="\x1b[2K"+(e<n-1?"\x1b[1A":"");return n>0&&(i+="\x1b[G"),i},d0=(e,t,r)=>{if(void 0!==r&&r.length>0){let n;return((e=1)=>`\x1b[${e}B`)((n=r.split(d1),0===t?n.length:(0,z.Fs)(K.Tj(n,e=>Math.ceil(e.length/t)),K.TS(0,(e,t)=>e+t))))+dZ(`
54
+ ${r}`,t)+dZ(e,t)}return dZ(e,t)},d1=/\r?\n/,d2=e=>B.D9k(function*(t,r){let n=yield*nI,i=yield*n.columns,a=yield*dR(e);return dZ(d5(t.value?e.placeholder.defaultConfirm:e.placeholder.defaultDeny,a.prefix,a.pointerSmall,e,{plain:!0}),i)+"\x1b[2K\x1b[G"}),d5=(e,t,r,n,i)=>cy(e,n.message,t,r,i),d3=B.D9k(function*(e,t){let r=yield*dR(t),n=dU(r.prefix,r.primaryColor),i=dU(r.pointerSmall,r.mutedColor);return"\x1b[?25l"+d5(dM(e.value?t.placeholder.defaultConfirm:t.placeholder.defaultDeny,r.mutedColor),n,i,t)}),d6=B.D9k(function*(e,t){let r=yield*dR(t),n=dU(r.tick,r.successColor),i=dU(r.ellipsis,r.mutedColor);return d5(e?t.label.confirm:t.label.deny,n,i,t)+"\n"}),d8=e=>(t,r)=>dQ.$match(r,{Beep:()=>B.PyW("\x07"),NextFrame:({state:t})=>d3(t,e),Submit:({value:t})=>d6(t,e)}),d9=/^y|t$/,d4=/^n|f$/,d7=(e,t)=>{let r=ee.getOrElse(e.input,()=>"");return"enter"===e.key.name||"return"===e.key.name?B.PyW(dQ.Submit({value:t})):d9.test(r.toLowerCase())?B.PyW(dQ.Submit({value:!0})):d4.test(r.toLowerCase())?B.PyW(dQ.Submit({value:!1})):B.PyW(dQ.Beep())},ce=(e,t,r=!1)=>K.TS(e.dateParts,"",(n,i,a)=>{let s=i.toString();return a!==e.cursor||r?n+s:n+dM(s,((...e)=>e)("\x1b[4m",t.primaryColor))}),ct=(e,t,r,n,i)=>cy(r,n.message,e,t,i),cr=B.D9k(function*(e,t){let r=yield*dR(t);return"\x1b[?25l"+ct(dU(r.prefix,r.primaryColor),dU(r.pointerSmall,r.mutedColor),ce(e,r),t)+((e,t,r)=>{if(ee.isSome(e.error)){let n=e.error.value.split(d1);if(K.ET(n))return"\x1b[s\n"+dF(dU(t,r.errorColor),K.Tj(n,e=>dD(e,r.errorColor)).join("\n"))+"\x1b[u"}return""})(e,r.pointerSmall,r)}),cn=B.D9k(function*(e,t){let r=yield*dR(t);return ct(dU(r.tick,r.successColor),dU(r.ellipsis,r.mutedColor),ce(e,r,!0),t)+"\n"}),ci={months:["January","February","March","April","May","June","July","August","September","October","November","December"],monthsShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],weekdays:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],weekdaysShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]},ca=/\\(.)|"((?:\\["\\]|[^"])+)"|(D[Do]?|d{3,4}|d)|(M{1,4})|(YY(?:YY)?)|([aA])|([Hh]{1,2})|(m{1,2})|(s{1,2})|(S{1,4})|./g,cs={1:({token:e,...t})=>new cl({token:e.replace(/\\(.)/g,"$1"),...t}),2:e=>new cp(e),3:e=>new ch(e),4:e=>new cm(e),5:e=>new cg(e),6:e=>new cf(e),7:e=>new cu(e),8:e=>new cc(e),9:e=>new cd(e)};class co{token;date;parts;locales;constructor(e){this.token=e.token,this.locales=e.locales,this.date=e.date||new globalThis.Date,this.parts=e.parts||[this]}isToken(){return!1}nextPart(){let e=ee.getOrElse(K.g9(this.parts,e=>e===this),()=>0);return K.i8(this.parts.slice(e+1),e=>!e.isToken())}previousPart(){let e=K.g9(this.parts,e=>e===this);return ee.isSome(e)?K.Uk(this.parts.slice(0,e.value),e=>!e.isToken()):ee.none()}toString(){return globalThis.String(this.date)}}class cl extends co{increment(){}decrement(){}setValue(e){this.token=this.token+e}isToken(){return!0}toString(){return this.token}}class cd extends co{increment(){this.date.setMilliseconds(this.date.getMilliseconds()+1)}decrement(){this.date.setMilliseconds(this.date.getMilliseconds()-1)}setValue(e){this.date.setMilliseconds(globalThis.Number.parseInt(e.slice(-this.token.length)))}toString(){return`${this.date.getMilliseconds()}`.padStart(4,"0").substring(0,this.token.length)}}class cc extends co{increment(){this.date.setSeconds(this.date.getSeconds()+1)}decrement(){this.date.setSeconds(this.date.getSeconds()-1)}setValue(e){this.date.setSeconds(globalThis.Number.parseInt(e.slice(-2)))}toString(){let e=`${this.date.getSeconds()}`;return this.token.length>1?e.padStart(2,"0"):e}}class cu extends co{increment(){this.date.setMinutes(this.date.getMinutes()+1)}decrement(){this.date.setMinutes(this.date.getMinutes()-1)}setValue(e){this.date.setMinutes(globalThis.Number.parseInt(e.slice(-2)))}toString(){let e=`${this.date.getMinutes()}`;return this.token.length>1?e.padStart(2,"0"):e}}class cf extends co{increment(){this.date.setHours(this.date.getHours()+1)}decrement(){this.date.setHours(this.date.getHours()-1)}setValue(e){this.date.setHours(globalThis.Number.parseInt(e.slice(-2)))}toString(){let e=/h/.test(this.token)?this.date.getHours()%12||12:this.date.getHours();return this.token.length>1?`${e}`.padStart(2,"0"):`${e}`}}class cp extends co{increment(){this.date.setDate(this.date.getDate()+1)}decrement(){this.date.setDate(this.date.getDate()-1)}setValue(e){this.date.setDate(globalThis.Number.parseInt(e.slice(-2)))}toString(){let e=this.date.getDate(),t=this.date.getDay();switch(this.token){case"DD":return`${e}`.padStart(2,"0");case"Do":return`${e}${this.ordinalIndicator(e)}`;case"d":return`${t+1}`;case"ddd":return this.locales.weekdaysShort[t];case"dddd":return this.locales.weekdays[t];default:return`${e}`}}ordinalIndicator(e){if(e>=11&&e<=13)return"th";switch(e%10){case 1:return"st";case 2:return"nd";case 3:return"rd";default:return"th"}}}class ch extends co{increment(){this.date.setMonth(this.date.getMonth()+1)}decrement(){this.date.setMonth(this.date.getMonth()-1)}setValue(e){let t=globalThis.Number.parseInt(e.slice(-2))-1;this.date.setMonth(t<0?0:t)}toString(){let e=this.date.getMonth();switch(this.token.length){case 2:return`${e+1}`.padStart(2,"0");case 3:return this.locales.monthsShort[e];case 4:return this.locales.months[e];default:return`${e+1}`}}}class cm extends co{increment(){this.date.setFullYear(this.date.getFullYear()+1)}decrement(){this.date.setFullYear(this.date.getFullYear()-1)}setValue(e){this.date.setFullYear(globalThis.Number.parseInt(e.slice(-4)))}toString(){let e=`${this.date.getFullYear()}`.padStart(4,"0");return 2===this.token.length?e.slice(-2):e}}class cg extends co{increment(){this.date.setHours((this.date.getHours()+12)%24)}decrement(){this.increment()}setValue(e){}toString(){let e=this.date.getHours()>=12?"pm":"am";return/A/.test(this.token)?e.toUpperCase():e}}let cy=(e,t,r,n,i)=>{let a=0===r.length?"":r+" ",s=t=>{let r=a+t;return n.length>0&&(r+=" "+n),e.length>0?r+=" "+e:n.length>0&&(r+=" "),r},o=i?.plain===!0?e=>e:dj;return K.YW(t.split(d1),{onEmpty:()=>s(""),onNonEmpty:e=>s(K.Tj(e,e=>o(e)).join("\n"))})},cv=(e,t,r,n)=>{if(!e.disabled&&e.description&&t){let t=r.descriptionSeparator+e.description;return n?.plain===!0?t:dM(t,r.mutedColor)}return""},cb=e=>B.D9k(function*(t,r){let n=yield*nI,i=yield*n.columns,a=yield*dR(e),s=c_(t,a.pointerSmall,a,{plain:!0});return d0(cx(t,a.prefix,a.pointerSmall,e,a,{plain:!0}),i,s)+"\x1b[2K\x1b[G"}),c_=(e,t,r,n)=>ee.isSome(e.error)?K.YW(e.error.value.split(d1),{onEmpty:()=>"",onNonEmpty:e=>n?.plain===!0?dF(t,e.join("\n")):"\x1b[s\n"+dF(dU(t,r.errorColor),K.Tj(e,e=>dD(e,r.errorColor)).join("\n"))+"\x1b[u"}):"",cx=(e,t,r,n,i,a,s=!1)=>{let o;return cy((o=""===e.value?"":`${e.value}`,s||a?.plain===!0?o:dM(o,ee.isSome(e.error)?i.errorColor:((...e)=>e)("\x1b[4m",i.primaryColor))),n.message,t,r,a)},cw=B.D9k(function*(e,t){let r=yield*dR(t),n=dU(r.prefix,r.primaryColor),i=dU(r.pointerSmall,r.mutedColor),a=c_(e,r.pointerSmall,r);return cx(e,n,i,t,r)+a}),ck=B.D9k(function*(e,t){let r=yield*dR(t);return cx(e,dU(r.tick,r.successColor),dU(r.ellipsis,r.mutedColor),t,r,void 0,!0)+"\n"}),cS=e=>{if(e.value.length<=0)return B.PyW(dQ.Beep());let t=e.value.slice(0,e.value.length-1);return B.PyW(dQ.NextFrame({state:{...e,value:t,error:ee.none()}}))},cI=e=>B.PyW(dQ.NextFrame({state:{...e,cursor:0,value:"",error:ee.none()}})),c$=e=>(t,r)=>dQ.$match(r,{Beep:()=>B.PyW("\x07"),NextFrame:({state:t})=>cw(t,e),Submit:()=>ck(t,e)}),cE=e=>(t,r)=>{if(t.key.ctrl&&"u"===t.key.name)return cI(r);switch(t.key.name){case"backspace":return cS(r);case"k":case"up":return B.PyW(dQ.NextFrame({state:{...r,value:""===r.value||"-"===r.value?`${e.incrementBy}`:`${globalThis.Number.parseInt(r.value)+e.incrementBy}`,error:ee.none()}}));case"j":case"down":return B.PyW(dQ.NextFrame({state:{...r,value:""===r.value||"-"===r.value?`-${e.decrementBy}`:`${globalThis.Number.parseInt(r.value)-e.decrementBy}`,error:ee.none()}}));case"enter":case"return":{let t=globalThis.Number.parseInt(r.value);if(globalThis.Number.isNaN(t))return B.PyW(dQ.NextFrame({state:{...r,error:ee.some("Must provide an integer value")}}));return B.YWq(e.validate(t),{onFailure:e=>dQ.NextFrame({state:{...r,error:ee.some(e)}}),onSuccess:e=>dQ.Submit({value:e})})}default:var n=ee.getOrElse(t.input,()=>"");if(0===r.value.length&&"-"===n)return B.PyW(dQ.NextFrame({state:{...r,value:"-",error:ee.none()}}));let i=globalThis.Number.parseInt(r.value+n);return globalThis.Number.isNaN(i)?B.PyW(dQ.Beep()):B.PyW(dQ.NextFrame({state:{...r,value:`${i}`,error:ee.none()}}))}},cO=(e,t,r,n)=>void 0===r.message?void 0:cy("",r.message,e,t,n),cC=(e,t)=>void 0===e?t:e+"\n"+t,cT=(e,t,r,n,i,a)=>{var s,o;let l,d=(s=n===r.startIndex&&r.startIndex>0,o=n===r.endIndex-1&&r.endIndex<t.length,l=Math.max(i.arrowUp.length,i.arrowDown.length),s?i.arrowUp.padEnd(l):o?i.arrowDown.padEnd(l):" ".repeat(l));if(a?.plain===!0)return e===n?i.pointer+d:d+" ".repeat(i.pointer.length);if(t[n].disabled){let t=((...e)=>e)("\x1b[1m",i.mutedColor);return e===n?dU(i.pointer,t)+d:d+" ".repeat(i.pointer.length)}return e===n?dU(i.pointer,i.primaryColor)+d:d+" ".repeat(i.pointer.length)},cM=(e,t,r,n)=>{if(n?.plain===!0)return e.title;let i=e.title;return t?e.disabled?dM(i,((...e)=>e)("\x1b[4m",r.mutedColor)):dM(i,((...e)=>e)("\x1b[4m",r.primaryColor)):e.disabled?dM(i,((...e)=>e)("\x1b[9m",r.mutedColor)):i},cA=(e,t,r,n)=>{let i=t.choices,a=c1(e,i.length,t.maxPerPage),s=[];for(let t=a.startIndex;t<a.endIndex;t++){let o=i[t],l=e===t,d=cT(e,i,a,t,r,n),c=cM(o,l,r,n),u=cv(o,l,r,n);s.push(d+c+" "+u)}return s.join("\n")},cN=B.D9k(function*(e,t){let r=yield*dR(t),n=cA(e,t,r);return"\x1b[?25l"+cC(cO(dU(r.prefix,r.primaryColor),dU(r.pointerSmall,r.mutedColor),t),n)}),cP=B.D9k(function*(e,t){let r=yield*dR(t),n=t.choices[e].title,i=dU(r.tick,r.successColor);return(cO(i,dU(r.ellipsis,r.mutedColor),t)??i)+" "+dM(n,r.submittedColor)+"\n"}),cR=e=>(t,r)=>dQ.$match(r,{Beep:()=>B.PyW("\x07"),NextFrame:({state:t})=>cN(t,e),Submit:()=>cP(t,e)}),cj=e=>B.D9k(function*(t,r){let n=yield*nI,i=yield*n.columns,a=yield*dR(e);return dZ(cC(cO(a.prefix,a.pointerSmall,e,{plain:!0}),cA(t,e,a,{plain:!0})),i)+"\x1b[2K\x1b[G"}),cD=e=>(t,r)=>{var n;switch(t.key.name){case"k":case"up":return n=e.choices,0===r?B.PyW(dQ.NextFrame({state:n.length-1})):B.PyW(dQ.NextFrame({state:r-1}));case"j":case"down":return r===e.choices.length-1?B.PyW(dQ.NextFrame({state:0})):B.PyW(dQ.NextFrame({state:r+1}));case"tab":let i;return i=e.choices,B.PyW(dQ.NextFrame({state:(r+1)%i.length}));case"enter":case"return":{let t=e.choices[r];if(t.disabled)return B.PyW(dQ.Beep());return B.PyW(dQ.Submit({value:t.value}))}default:return B.PyW(dQ.Beep())}},cU=B.D9k(function*(e,t){let r=yield*nI,n=yield*r.columns,i=yield*dR(t),a=cF(e,i.pointerSmall,i,{plain:!0});return d0(cB(e,i.prefix,i.pointerSmall,t,i,{plain:!0}),n,a)+"\x1b[2K\x1b[G"}),cF=(e,t,r,n)=>ee.isSome(e.error)?K.YW(e.error.value.split(d1),{onEmpty:()=>"",onNonEmpty:e=>n?.plain===!0?dF(t,e.join("\n")):"\x1b[s\n"+dF(dU(t,r.errorColor),K.Tj(e,e=>dD(e,r.errorColor)).join("\n"))+"\x1b[u"}):"",cB=(e,t,r,n,i,a,s=!1)=>cy(((e,t,r,n,i)=>{let a=e.value;if(i?.plain===!0)switch(t.type){case"hidden":return"";case"password":return r.passwordMask.repeat(a.length);case"text":return a}if(0===a.length)return"";let s=ee.isSome(e.error)?r.errorColor:n?r.submittedColor:((...e)=>e)("\x1b[4m",r.primaryColor);switch(t.type){case"hidden":return"";case"password":return dU(r.passwordMask.repeat(a.length),s);case"text":return dM(a,s)}})(e,n,i,s,a),n.message,t,r,a),cL=B.D9k(function*(e,t){let r=yield*dR(t),n=cB(e,dU(r.prefix,r.primaryColor),dU(r.pointerSmall,r.mutedColor),t,r),i=cF(e,r.pointerSmall,r),a="password"===t.type?r.passwordMask.length:1;return n+i+((e,t=0)=>{let r="";return t<0&&(r+=`\x1b[${-t}A`),t>0&&(r+=`\x1b[${t}B`),e>0&&(r+=`\x1b[${e}C`),e<0&&(r+=`\x1b[${-e}D`),r})((e.cursor-e.value.length)*a)}),cz=B.D9k(function*(e,t){let r=yield*dR(t);return cB(e,dU(r.tick,r.successColor),dU(r.ellipsis,r.mutedColor),t,r,void 0,!0)+"\n"}),cW=e=>B.PyW(dQ.NextFrame({state:{...e,cursor:0,error:ee.none()}})),cJ=e=>B.PyW(dQ.NextFrame({state:{...e,cursor:e.value.length,error:ee.none()}})),cY=(e,t)=>{let r={default:"",type:t,validate:B.PyW,...e};return dL({cursor:r.default.length,value:r.default,error:ee.none()},{render:(e,t)=>dQ.$match(t,{Beep:()=>B.PyW("\x07"),NextFrame:({state:e})=>cL(e,r),Submit:()=>cz(e,r)}),process:(e,t)=>{if(e.key.ctrl)switch(e.key.name){case"u":return B.PyW(dQ.NextFrame({state:{...t,cursor:0,value:"",error:ee.none()}}));case"a":return cW(t);case"e":return cJ(t);default:return B.PyW(dQ.Beep())}switch(e.key.name){case"backspace":var n;if(t.cursor<=0)return B.PyW(dQ.Beep());let i=t.value.slice(0,t.cursor-1),a=t.value.slice(t.cursor),s=t.cursor-1,o=`${i}${a}`;return B.PyW(dQ.NextFrame({state:{...t,cursor:s,value:o,error:ee.none()}}));case"left":if(t.cursor<=0)return B.PyW(dQ.Beep());let l=t.cursor-1;return B.PyW(dQ.NextFrame({state:{...t,cursor:l,error:ee.none()}}));case"right":if(t.cursor>=t.value.length)return B.PyW(dQ.Beep());let d=Math.min(t.cursor+1,t.value.length);return B.PyW(dQ.NextFrame({state:{...t,cursor:d,error:ee.none()}}));case"home":return cW(t);case"end":return cJ(t);case"enter":case"return":{let e=t.value;return B.YWq(r.validate(e),{onFailure:r=>dQ.NextFrame({state:{...t,value:e,error:ee.some(r)}}),onSuccess:e=>dQ.Submit({value:e})})}case"tab":if(t.value===r.default)return B.PyW(dQ.Beep());let c=0===t.value.length?r.default:t.value;return B.PyW(dQ.NextFrame({state:{...t,value:c,cursor:c.length,error:ee.none()}}));default:let u,f,p,h;return n=ee.getOrElse(e.input,()=>""),u=t.value.slice(0,t.cursor),f=t.value.slice(t.cursor),p=`${u}${n}${f}`,h=t.cursor+n.length,B.PyW(dQ.NextFrame({state:{...t,cursor:h,value:p,error:ee.none()}}))}},clear:(e,t)=>cU(e,r)})},cX=B.D9k(function*(e){let t=yield*nI,r=yield*t.columns,n=yield*dR(e);return dZ(cy(e.active+" "+dF(n.toggleSeparator,e.inactive),e.message,n.prefix,n.pointerSmall,{plain:!0}),r)+"\x1b[2K\x1b[G"}),cq=(e,t,r,n=!1)=>{let i=dU(r.toggleSeparator,r.mutedColor),a=((...e)=>e)("\x1b[4m",n?r.submittedColor:r.primaryColor),s=e?t.inactive:dM(t.inactive,a);return(e?dM(t.active,a):t.active)+" "+dF(i,s)},cG=(e,t,r,n)=>cy(e,n.message,t,r),cV=B.D9k(function*(e,t){let r=yield*dR(t),n=dU(r.prefix,r.primaryColor),i=dU(r.pointerSmall,r.mutedColor);return"\x1b[?25l"+cG(cq(e,t,r),n,i,t)}),cH=B.D9k(function*(e,t){let r=yield*dR(t),n=dU(r.tick,r.successColor),i=dU(r.ellipsis,r.mutedColor);return cG(cq(e,t,r,!0),n,i,t)+"\n"}),cK=B.PyW(dQ.NextFrame({state:!0})),cQ=B.PyW(dQ.NextFrame({state:!1})),cZ=e=>(t,r)=>{switch(r._tag){case"Beep":return B.PyW("\x07");case"NextFrame":return cV(t,e);case"Submit":return cH(t,e)}},c0=(e,t)=>{switch(e.key.name){case"0":case"j":case"delete":case"right":case"down":return cQ;case"1":case"k":case"left":case"up":return cK;case" ":case"tab":return t?cQ:cK;case"enter":case"return":return B.PyW(dQ.Submit({value:t}));default:return B.PyW(dQ.Beep())}},c1=(e,t,r)=>{let n=void 0===r?t:r,i=Math.min(t-n,e-Math.floor(n/2));i<0&&(i=0);let a=Math.min(i+n,t);return{startIndex:i,endIndex:a}},c2=B.D9k(function*(e,t){let r=t?.commandPath??[e.name],n=c5(e,r),i=(t?.prefix??r).map(e=>c4(e));return yield*ur(i),yield*c3(n,i,n===e?"ROOT":n.name),{args:i.map(e=>e.value),displayArgs:i.map(e=>e.displayValue)}}),c5=(e,t)=>{let r=e;for(let e of t.slice(1)){let t=r.subcommands.flatMap(e=>e.commands).find(t=>t.name===e||t.alias===e);if(void 0===t)break;r=t}return r},c3=B.D9k(function*(e,t,r){let n=lW(e),i=e.subcommands.flatMap(e=>e.commands.filter(e=>!e.unlisted)),a=0===i.length?n.config:n.contextConfig;if(a.flags.length>0){for(let e of(yield*on(un(r,"FLAGS")),a.flags))t.push(...yield*c8(e));(a.arguments.length>0||i.length>0)&&(yield*ur(t))}if(a.arguments.length>0){for(let e of(yield*on(un(r,"ARGUMENTS")),a.arguments))t.push(...yield*c8(e));i.length>0&&(yield*ur(t))}if(0===i.length)return;let s=yield*dY(dX({message:"Command",choices:i.map(e=>({title:e.name,value:e,...void 0!==e.shortDescription?{description:e.shortDescription}:void 0!==e.description?{description:e.description}:{}}))}));yield*on(),t.push(c4(s.name)),c6(s)&&(yield*ur(t)),yield*c3(s,t,s.name)}),c6=e=>e.subcommands.some(e=>e.commands.some(e=>!e.unlisted))||lW(e).config.orderedParams.length>0,c8=B.D9k(function*(e){let t=o1(e),r=o2(e);if(r.isOptional&&!(yield*dY(dB({message:`Set ${ue(t)}?`,initial:!1}))))return yield*on(),[];let n=r.isVariadic?yield*dY(dW({message:`${ue(t)} count`,default:ee.getOrElse(r.variadicMin,()=>0),min:ee.getOrElse(r.variadicMin,()=>0),...ee.isSome(r.variadicMax)?{max:r.variadicMax.value}:{}})):1,i=[];for(let e=0;e<n;e++)i.push((yield*c9(t)));let a="flag"===t.kind?{flags:{[t.name]:i.map(e=>e.value)},arguments:[]}:{flags:{},arguments:i.map(e=>e.value)};return(yield*e.parse(a),yield*on(),t.kind===oC)?i:i.flatMap(e=>e.value.startsWith("-")&&e.value.length>1?[c4(`--${t.name}=${e.value}`,`--${t.name}=${e.displayValue}`)]:[c4(`--${t.name}`),e])}),c9=e=>{var t,r;let n=c7(e);switch(e.primitiveType._tag){case"Boolean":return B.TjK(dY(dB({message:n,label:{confirm:"true",deny:"false"},placeholder:{defaultConfirm:"(T/f)",defaultDeny:"(t/F)"}})),e=>c4(String(e)));case"Choice":{let t=o$(e.primitiveType)??[];return B.TjK(dY(dX({message:n,choices:t.map(e=>({title:e,value:e}))})),c4)}case"Date":let i,a,s,o,l,d;return B.TjK(dY((t={message:n},s=(a=((e,t,r)=>{let n=[],i=null;for(;i=ca.exec(e);){let e=i.shift(),a=i.findIndex(e=>void 0!==e);if(a in cs){let s=i[a]||e;n.push(cs[a]({token:s,date:t,parts:n,locales:r}))}else n.push(new cl({token:i[a]||e,date:t,parts:n,locales:r}))}let a=n.reduce((e,t)=>{let r=e[e.length-1];return t.isToken()&&void 0!==r&&r.isToken()?r.setValue(t.token):e.push(t),e},K.Ie());return n.splice(0,n.length,...a),n})((i={initial:new globalThis.Date,dateMask:"YYYY-MM-DD HH:mm:ss",validate:B.PyW,...t,locales:{...ci,...t.locales}}).dateMask,i.initial,i.locales)).findIndex(e=>!e.isToken()),dL({dateParts:a,typed:"",cursor:s,value:i.initial,error:ee.none()},{render:(o=i,(e,t)=>dQ.$match(t,{Beep:()=>B.PyW("\x07"),NextFrame:({state:e})=>cr(e,o),Submit:()=>cn(e,o)})),process:(l=i,(e,t)=>{switch(e.key.name){case"left":let r;return B.PyW((r=t.dateParts[t.cursor].previousPart(),ee.isSome(r)?dQ.NextFrame({state:{...t,typed:"",cursor:t.dateParts.indexOf(r.value)}}):dQ.Beep()));case"right":let n;return B.PyW((n=t.dateParts[t.cursor].nextPart(),ee.isSome(n)?dQ.NextFrame({state:{...t,typed:"",cursor:t.dateParts.indexOf(n.value)}}):dQ.Beep()));case"k":case"up":return B.PyW((t.dateParts[t.cursor].increment(),dQ.NextFrame({state:{...t,typed:""}})));case"j":case"down":return B.PyW((t.dateParts[t.cursor].decrement(),dQ.NextFrame({state:{...t,typed:""}})));case"tab":let i,a;return B.PyW((i=t.dateParts[t.cursor].nextPart(),a=ee.match(i,{onNone:()=>t.dateParts.findIndex(e=>!e.isToken()),onSome:e=>t.dateParts.indexOf(e)}),dQ.NextFrame({state:{...t,typed:"",cursor:a}})));case"enter":case"return":return B.YWq(l.validate(t.value),{onFailure:e=>dQ.NextFrame({state:{...t,error:ee.some(e)}}),onSuccess:e=>dQ.Submit({value:e})});default:return B.PyW(((e,t)=>{if(/\d/.test(e)){let r=t.typed+e;return t.dateParts[t.cursor].setValue(r),dQ.NextFrame({state:{...t,typed:r}})}return dQ.Beep()})(ee.getOrElse(e.input,()=>""),t))}}),clear:(d=i,B.D9k(function*(e,t){let r=yield*nI,n=yield*r.columns,i=yield*dR(d),a=K.TS(e.dateParts,"",(e,t)=>e+t.toString());return d0(ct(i.prefix,i.pointerSmall,a,d,{plain:!0}),n,ee.isSome(e.error)?K.YW(e.error.value.split(d1),{onEmpty:()=>"",onNonEmpty:e=>dF(i.pointerSmall,e.join("\n"))}):"")+"\x1b[2K\x1b[G"}))}))),e=>c4(e.toISOString()));case"Finite":let c,u,f,p;return B.TjK(dY((r={message:n},c={default:0,min:globalThis.Number.NEGATIVE_INFINITY,max:globalThis.Number.POSITIVE_INFINITY,incrementBy:1,decrementBy:1,precision:2,validate:e=>e<c.min?B.fJG(`${e} must be greater than or equal to ${c.min}`):e>c.max?B.fJG(`${e} must be less than or equal to ${c.max}`):B.PyW(e),...r},dL({cursor:(u=void 0===r.default?"":`${c.default}`).length,value:u,error:ee.none()},{render:(f=c,(e,t)=>dQ.$match(t,{Beep:()=>B.PyW("\x07"),NextFrame:({state:e})=>cw(e,f),Submit:()=>ck(e,f)})),process:(p=c,(e,t)=>{if(e.key.ctrl&&"u"===e.key.name)return cI(t);switch(e.key.name){case"backspace":return cS(t);case"k":case"up":return B.PyW(dQ.NextFrame({state:{...t,value:""===t.value||"-"===t.value?`${p.incrementBy}`:`${globalThis.Number.parseFloat(t.value)+p.incrementBy}`,error:ee.none()}}));case"j":case"down":return B.PyW(dQ.NextFrame({state:{...t,value:""===t.value||"-"===t.value?`-${p.decrementBy}`:`${globalThis.Number.parseFloat(t.value)-p.decrementBy}`,error:ee.none()}}));case"enter":case"return":{let e=globalThis.Number.parseFloat(t.value);if(globalThis.Number.isNaN(e))return B.PyW(dQ.NextFrame({state:{...t,error:ee.some("Must provide a floating point value")}}));return B.qIB(B.OH5(()=>dT(e,p.precision)),e=>B.YWq(p.validate(e),{onFailure:e=>dQ.NextFrame({state:{...t,error:ee.some(e)}}),onSuccess:e=>dQ.Submit({value:e})}))}default:var r=ee.getOrElse(e.input,()=>"");if("."===r&&t.value.includes("."))return B.PyW(dQ.Beep());if(0===t.value.length&&"-"===r)return B.PyW(dQ.NextFrame({state:{...t,value:"-",error:ee.none()}}));let n=globalThis.Number.parseFloat(t.value+r);return globalThis.Number.isNaN(n)?B.PyW(dQ.Beep()):B.PyW(dQ.NextFrame({state:{...t,value:"."===r?`${n}.`:t.value.includes(".")&&/^\d$/.test(r)?t.value+r:`${n}`,error:ee.none()}}))}}),clear:cb(c)}))),e=>c4(String(e)));case"Int":return B.TjK(dY(dW({message:n})),e=>c4(String(e)));case"Redacted":return B.TjK(dY(cY({message:n},"password").pipe(dJ(dE.L8))),e=>c4(dE.Uq(e),"<redacted>"));default:return B.TjK(dY(cY({message:n},"text")),c4)}},c4=(e,t=e)=>({value:e,displayValue:t}),c7=e=>ue(e),ue=e=>{let t=ee.getOrUndefined(e.description)?.trim(),r="flag"===e.kind&&void 0!==t&&t.length<=32?t:ut(e.name);return"flag"===e.kind?`${r} (${"flag"===e.kind?`--${e.name}`:e.name})`:r},ut=e=>{let t=e.split(/[-_]+/).filter(e=>e.length>0);return 0===t.length?e:[t[0][0].toUpperCase()+t[0].slice(1),...t.slice(1)].join(" ")},ur=e=>on(uo("Current command",e.map(e=>e.displayValue),"\x1b[35m")),un=(e,t)=>`${dM(e.toUpperCase(),"\x1b[1m","\x1b[96m")} ${dM("·","\x1b[90m")} ${dM(t,"\x1b[1m","\x1b[37m")}`,ui=(e,t,r)=>[`${dM(e,"\x1b[1m","\x1b[96m")} ${dM(`v${t}`,"\x1b[37m")} ${dM("· Command wizard","\x1b[1m","\x1b[37m")}`,...void 0===r||0===r.length?[]:[r],dM("Build a command interactively. Press Ctrl+C to cancel.","\x1b[90m"),""].join("\n"),ua=e=>uo("Command ready",e,"\x1b[96m","\x1b[32m"),us=()=>`
55
+ ${dM("Wizard cancelled.","\x1b[31m")}`,uo=(e,t,r,n="\x1b[37m")=>{let i=ul(t);return[dM(e,"\x1b[1m",n),...i.map(e=>dM(e,r)),""].join("\n")},ul=e=>{let t=" $ ",r=" ",n=e.map(ud),i=[],a=t;for(let e of n){let n=a===t||a===r?"":" ";a.length+n.length+e.length>88&&a!==t?(i.push(`${a} \\`),a=`${r}${e}`):a+=`${n}${e}`}return a!==t&&i.push(a),i},ud=e=>/^[A-Za-z0-9_./:@%+=,-]+$/.test(e)?e:`'${e.replaceAll("'","'\"'\"'")}'`,uc=e=>eh.i5(e,lz),uu=(e,t,r)=>lY({name:e,config:lj(t??{}),...eh.EA(r)?{handle:r}:{}}),uf=(0,z.XY)(2,(e,t)=>{let r=(e=>{let t=[],r=new Map,n=(e,n)=>{t.push(n);let i=r.get(e);i?i.push(n):r.set(e,[n])};for(let t of e){if(uc(t)){n(void 0,t);continue}for(let e of t.commands)n(t.group,e)}let i=[],a=r.get(void 0);for(let[e,t]of(a&&a.length>0&&i.push({group:void 0,commands:a}),r))void 0!==e&&i.push({group:e,commands:t});return{flat:t,groups:i}})(t);lH(e,r.flat);let n=lW(e),i=new Map(r.flat.map(e=>[e.name,lW(e)])),a=Symbol("effect/cli/SubcommandState"),s=B.D9k(function*(e){if(ee.isNone(e.subcommand))return yield*n.parse(e);let t=i.get(e.subcommand.value.name);if(!t)return yield*n.parse(e);let r=yield*n.parseContext(e),s=yield*t.parse(e.subcommand.value.parsedInput);return{...r,[a]:{name:t.name,result:s}}}),o=B.D9k(function*(e,t){let r=e[a];if(r){let a=i.get(r.name);return a?yield*a.handle(r.result,[...t,a.name]).pipe(B.PfK(n.service,e)):yield*new oh({commandPath:t,errors:[]})}return yield*n.handle(e,t)});return lY({name:n.name,config:n.config,contextConfig:n.contextConfig,description:n.description,shortDescription:n.shortDescription,alias:n.alias,unlisted:n.unlisted,annotations:n.annotations,globalFlags:n.globalFlags,examples:n.examples,service:n.service,subcommands:r.groups,parse:s,parseContext:n.parseContext,handle:o})}),up=(0,z.XY)(2,(e,t)=>{let r=lW(e),n=lj(t),i=lB(r.config,n),a=lB(r.contextConfig,n);r.subcommands.length>0&&lH(e,r.subcommands.flatMap(e=>e.commands),{contextConfig:a});let s=lG(n,{allowLeftovers:!0}),o=B.D9k(function*(e){let t=yield*r.parse(e),n=yield*s(e);return{...t,...n}}),l=B.D9k(function*(e){let t=yield*r.parseContext(e),n=yield*s(e);return{...t,...n}});return lY({name:r.name,config:i,contextConfig:a,description:r.description,shortDescription:r.shortDescription,alias:r.alias,unlisted:r.unlisted,annotations:r.annotations,globalFlags:r.globalFlags,examples:r.examples,service:r.service,subcommands:r.subcommands,parse:o,parseContext:l,handle:(e,t)=>r.handle(e,t)})}),uh=(0,z.XY)(2,(e,t)=>lY({...lW(e),description:t})),um=(0,z.XY)(2,(e,t)=>lY({...lW(e),shortDescription:t})),ug=(0,z.XY)(2,(e,t)=>lY({...lW(e),examples:t})),uy=(e,t)=>{let r=lW(e);return B.D9k(function*(n){let i,a,s,o,l,d,{builtIns:c}=yield*dr,{tokens:u,trailingOperands:f}=-1===(i=n.indexOf("--"))?{tokens:da(n),trailingOperands:[]}:{tokens:da(n.slice(0,i)),trailingOperands:n.slice(i+1)},p=l0([...c,...(a=[],(s=e=>{for(let t of lW(e).globalFlags)a.push(t);for(let t of e.subcommands)for(let e of t.commands)s(e)})(e),l0(a))]),h=du(p.flatMap(e=>o0(e.flag)).filter(oM)),{flagMap:m,remainder:g,errors:y}=(o=dp(h.params),l=[],d=(e,t,r)=>{let n=du(lW(t).config.flags.flatMap(o0).filter(oM)),i=du(lW(t).contextConfig.flags.flatMap(o0).filter(oM)),a=df(t.subcommands),s=dc(e),c=[],u=!0;for(let e=s.take();e;e=s.take()){if(dh(e)){let t=dx(e,r);if(void 0!==t){dw(c,s,e,t);continue}let d=dg(e,i);if(void 0!==d){dw(c,s,e,d);continue}let f=dg(e,n),p=dg(e,h);if(void 0!==f&&(void 0===p||!u||!dk(e,s.rest(),f,a,[n,i,h]))){dw(c,s,e,f);continue}if(void 0!==p){let t=d_(s,e,p.param,p.negated);if("Error"===t._tag){l.push(t.error);continue}void 0!==t.value&&o[p.param.name].push(t.value);continue}c.push(e);continue}if("Value"===e._tag&&u){let t=a.get(e.value);if(void 0!==t)return c.push(e),c.push(...d(s.rest(),t,[...r,i])),c;u=!1}c.push(e)}return c},{flagMap:o,remainder:d(u,e,[]),errors:l}),v={flags:m,arguments:[]},b=yield*dd({tokens:g,trailingOperands:f},e),_=[e.name,...dl(b)],x={builtIns:c,command:e,commandPath:_,version:t.version},w=l2(e,_,c),k=((e,t,r,n)=>{let i=new Set(t),a=[],s=new Set;for(let t of e)if(!i.has(t))for(let e of o0(t.flag)){let t=r[e.name];if(!t||0===t.length)continue;let i=`--${e.name}`;s.has(i)||(s.add(i),a.push(new oa({option:i,suggestions:[],command:n})))}return a})(p,w,m,_);if(k.length>0||y.length>0){let e=b.errors??[];return yield*new oh({commandPath:_,errors:[...y,...k,...e]})}for(let r of w){if("Action"!==r._tag||!o0(r.flag).some(e=>{let t=m[e.name];return void 0!==t&&t.length>0}))continue;let[,i]=yield*r.flag.parse(v);if(r===l4)return yield*B.JkU(function*(){yield*on(ui(e.name,t.version,e.description));let r=[e.name,...n.filter(e=>"--wizard"!==e&&!e.startsWith("--wizard="))],i=yield*c2(e,{commandPath:_,prefix:r});yield*on(ua(i.displayArgs)),(yield*dY(dG({message:"Run this command?",initial:!0,active:"yes",inactive:"no"})))&&(yield*on(),yield*uy(e,{...t,renderErrors:!1})(i.args.slice(1)))}).pipe(B.KuX("QuitError",()=>on(us())));yield*r.run(i,x);return}if(b.errors&&b.errors.length>0)return yield*new oh({commandPath:_,errors:b.errors});let S=yield*B.Ket(r.parse(b));if("Failure"===S._tag)return yield*new oh({commandPath:_,errors:[S.failure]});let I=r.handle(S.success,[e.name]),$=w.includes(de)?(yield*de.flag.parse(v))[1]:ee.none();for(let e of(I=B.PfK(I,de,$),w)){if("Setting"!==e._tag||e===de)continue;let[,t]=yield*e.flag.parse(v);I=B.PfK(I,e,t)}let E=ee.match($,{onNone:()=>Z.Ie(),onSome:e=>Z.L8(o5.zQ,e)});yield*B.PpN(I,E)},B.osR(e=>eh.i5(e,oi)&&"ShowHelp"===e._tag?tL.Py(e):tL.fJ(e),r=>{let n;return B.hgn((n=!1!==t.renderErrors,B.JkU(function*(){let{builtIns:t}=yield*dr,i=yield*o3,a=yield*l5(e,r.commandPath,t);yield*on(i.formatHelpDoc(a)),n&&r.errors.length>0&&(yield*or(i.formatErrors(r.errors)))})),B.fJG(r))}),B.osR(e=>!1!==t.renderErrors&&eh.i5(e,oi)&&"UserError"===e._tag?tL.Py(e):tL.fJ(e),e=>B.hgn(B.JkU(function*(){let t=yield*o3;yield*or(t.formatError(e)),e[X]=!1}),B.fJG(e))),B.osR(e=>eh.i5(e,nk)?tL.Py(e):tL.fJ(e),e=>B.GaK))},uv=/(?:https:\/\/(?:www\.)?excalidraw\.com\/)?#json=[A-Za-z0-9_-]+,[A-Za-z0-9_-]{22,}/gu;function ub(e){return e.replace(uv,"[redacted-share-link]")}let u_=(e=0)=>t=>`\x1b[${t+e}m`,ux=(e=0)=>t=>`\x1b[${38+e};5;${t}m`,uw=(e=0)=>(t,r,n)=>`\x1b[${38+e};2;${t};${r};${n}m`,uk=e=>`\x1b[58;5;${e<90?e-30:e-90+8}m`,uS={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],underlineDouble:["4:2",24],underlineCurly:["4:3",24],underlineDotted:["4:4",24],underlineDashed:["4:5",24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]},underlineColor:{underlineBlack:["58;5;0",59],underlineRed:["58;5;1",59],underlineGreen:["58;5;2",59],underlineYellow:["58;5;3",59],underlineBlue:["58;5;4",59],underlineMagenta:["58;5;5",59],underlineCyan:["58;5;6",59],underlineWhite:["58;5;7",59],underlineBlackBright:["58;5;8",59],underlineGray:["58;5;8",59],underlineGrey:["58;5;8",59],underlineRedBright:["58;5;9",59],underlineGreenBright:["58;5;10",59],underlineYellowBright:["58;5;11",59],underlineBlueBright:["58;5;12",59],underlineMagentaBright:["58;5;13",59],underlineCyanBright:["58;5;14",59],underlineWhiteBright:["58;5;15",59]}};Object.keys(uS.modifier);let uI=Object.keys(uS.color),u$=Object.keys(uS.bgColor);Object.keys(uS.underlineColor),[...uI,...u$];let uE=function(){let e=new Map;for(let[t,r]of Object.entries(uS)){for(let[t,n]of Object.entries(r))uS[t]={open:`\x1b[${n[0]}m`,close:`\x1b[${n[1]}m`},r[t]=uS[t],e.set(Number.parseInt(n[0],10),n[1]);Object.defineProperty(uS,t,{value:r,enumerable:!1})}return Object.defineProperty(uS,"codes",{value:e,enumerable:!1}),uS.color.close="\x1b[39m",uS.bgColor.close="\x1b[49m",uS.underlineColor.close="\x1b[59m",uS.color.ansi=u_(),uS.color.ansi256=ux(),uS.color.ansi16m=uw(),uS.bgColor.ansi=u_(10),uS.bgColor.ansi256=ux(10),uS.bgColor.ansi16m=uw(10),uS.underlineColor.ansi=uk,uS.underlineColor.ansi256=ux(20),uS.underlineColor.ansi16m=uw(20),Object.defineProperties(uS,{rgbToAnsi256:{value:(e,t,r)=>e===t&&t===r?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(r/255*5),enumerable:!1},hexToRgb:{value(e){let t=/[\da-f]{6}|[\da-f]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[r]=t;3===r.length&&(r=[...r].map(e=>e+e).join(""));let n=Number.parseInt(r,16);return[n>>16&255,n>>8&255,255&n]},enumerable:!1},hexToAnsi256:{value:e=>uS.rgbToAnsi256(...uS.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){let t,r,n;if(e<8)return 30+e;if(e<16)return 90+(e-8);if(e>=232)r=t=((e-232)*10+8)/255,n=t;else{let i=(e-=16)%36;t=Math.floor(e/36)/5,r=Math.floor(i/6)/5,n=i%6/5}let i=2*Math.max(t,r,n);if(0===i)return 30;let a=30+(Math.round(n)<<2|Math.round(r)<<1|Math.round(t));return 2===i&&(a+=60),a},enumerable:!1},rgbToAnsi:{value:(e,t,r)=>uS.ansi256ToAnsi(uS.rgbToAnsi256(e,t,r)),enumerable:!1},hexToAnsi:{value:e=>uS.ansi256ToAnsi(uS.hexToAnsi256(e)),enumerable:!1}}),uS}();function uO(e,t=globalThis.Deno?globalThis.Deno.args:a6.argv){let r=e.startsWith("-")?"":1===e.length?"-":"--",n=t.indexOf(r+e),i=t.indexOf("--");return -1!==n&&(-1===i||n<i)}let{env:uC}=a6;function uT(){return/^\d+$/.test(uC.FORCE_COLOR)}function uM(e,t={}){var r;return 0!==(r=function(e,{streamIsTTY:t,sniffFlags:r=!0}={}){let n="FORCE_COLOR"in uC?"false"===uC.FORCE_COLOR?0:"true"===uC.FORCE_COLOR||0===uC.FORCE_COLOR.length?1:uT()?Math.min(Number.parseInt(uC.FORCE_COLOR,10),3):void 0:void 0;void 0!==n&&(i=n);let a=r?i:n;if(0===a)return 0;if(r){if(uO("color=16m")||uO("color=full")||uO("color=truecolor"))return 3;if(uO("color=256"))return 2}if(void 0!==a&&uT())return a;if("TF_BUILD"in uC&&"AGENT_NAME"in uC)return 1;if(e&&!t&&void 0===a)return 0;let s=a||0;if("dumb"===uC.TERM)return s;if("win32"===a6.platform){let e=rP.release().split(".");return Number(e[0])>=10&&Number(e[2])>=10586?Number(e[2])>=14931?3:2:1}if("CI"in uC)return["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some(e=>e in uC)?3:["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(e=>e in uC)||"codeship"===uC.CI_NAME?1:s;if("TEAMCITY_VERSION"in uC)return+!!/^(?:9\.0*[1-9]\d*\.|\d{2,}\.)/.test(uC.TEAMCITY_VERSION);if("truecolor"===uC.COLORTERM||"xterm-kitty"===uC.TERM||"xterm-ghostty"===uC.TERM||"wezterm"===uC.TERM)return 3;if("TERM_PROGRAM"in uC){let e=Number.parseInt((uC.TERM_PROGRAM_VERSION||"").split(".",1)[0],10);switch(uC.TERM_PROGRAM){case"iTerm.app":return e>=3?3:2;case"Apple_Terminal":return 2}}return/-256(?:color)?$/i.test(uC.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(uC.TERM)||"COLORTERM"in uC?1:s}(e,{streamIsTTY:e&&e.isTTY,...t}))&&{level:r,hasBasic:!0,has256:r>=2,has16m:r>=3}}uO("no-color")||uO("no-colors")||uO("color=false")||uO("color=never")?i=0:(uO("color")||uO("colors")||uO("color=true")||uO("color=always"))&&(i=1);let{stdout:uA,stderr:uN}={stdout:uM({isTTY:sb.isatty(1)}),stderr:uM({isTTY:sb.isatty(2)})},uP=Symbol("GENERATOR"),uR=Symbol("STYLER"),uj=Symbol("IS_EMPTY"),uD=Symbol("LEVEL"),uU=Object.create(null),uF=e=>{if(!Number.isSafeInteger(e)||e<0||e>3)throw Error("The `level` should be an integer from 0 to 3")};class uB{constructor(e){return uL(e)}}let uL=e=>{let t=(...e)=>e.join(" ");return((e,t={})=>{void 0!==t.level&&uF(t.level);let r=uA?uA.level:0;e[uD]=void 0===t.level?r:t.level})(t,e),Object.setPrototypeOf(t,uz.prototype),t};function uz(e){return uL(e)}for(let[e,t]of(Object.setPrototypeOf(uz.prototype,Function.prototype),Object.entries(uE)))uU[e]={get(){let r=uX(this,uY(t.open,t.close,this[uR]),this[uj]);return Object.defineProperty(this,e,{value:r}),r}};uU.visible={get(){let e=uX(this,this[uR],!0);return Object.defineProperty(this,"visible",{value:e}),e}};let uW=(e,t)=>{let r=uE[t];if("rgb"===e){let e=(e,t,n)=>r.ansi(uE.rgbToAnsi(e,t,n));return[e,e,(e,t,n)=>r.ansi256(uE.rgbToAnsi256(e,t,n)),r.ansi16m]}if("hex"===e){let e=e=>r.ansi(uE.hexToAnsi(e));return[e,e,e=>r.ansi256(uE.hexToAnsi256(e)),e=>r.ansi16m(...uE.hexToRgb(e))]}let n=e=>r.ansi(uE.ansi256ToAnsi(e));return[n,n,r.ansi256,r.ansi256]};for(let e of["rgb","hex","ansi256"]){let t=e[0].toUpperCase()+e.slice(1);for(let[r,n]of[[e,"color"],["bg"+t,"bgColor"],["underline"+t,"underlineColor"]]){let{close:t}=uE[n],i=uW(e,n);uU[r]={get(){let e=function(e,r,n){return uX(this,uY(i[this.level](e,r,n),t,this[uR]),this[uj])};return Object.defineProperty(this,r,{value:e}),e}}}}let uJ=Object.defineProperties(()=>{},{...uU,level:{enumerable:!0,get(){return this[uP].level},set(e){this[uP].level=e}}}),uY=(e,t,r)=>{let n,i;return void 0===r?(n=e,i=t):(n=r.openAll+e,i=t+r.closeAll),{open:e,close:t,openAll:n,closeAll:i,parent:r}},uX=(e,t,r)=>{let n=(...e)=>1===e.length?uq(n,""+e[0]):2===e.length?uq(n,`${e[0]??""} ${e[1]??""}`):uq(n,e.join(" "));return Object.setPrototypeOf(n,uJ),n[uP]=e[uP]??e,n[uR]=t,n[uj]=r,n},uq=(e,t)=>{if(e[uP][uD]<=0||!t)return e[uj]?"":t;let r=e[uR];if(void 0===r)return t;let{openAll:n,closeAll:i}=r;if(t.includes("\x1b"))for(;void 0!==r;)t=function(e,t,r){let n=e.indexOf(t);if(-1===n)return e;let i=t.length,a=0,s="";do s+=e.slice(a,n)+t+r,a=n+i,n=e.indexOf(t,a);while(-1!==n)return s+e.slice(a)}(t,r.close,r.open),r=r.parent;let a=t.indexOf("\n");return -1!==a&&(t=function(e,t,r,n){let i=0,a="";do{let s="\r"===e[n-1];a+=e.slice(i,s?n-1:n)+t+(s?"\r\n":"\n")+r,i=n+1,n=e.indexOf("\n",i)}while(-1!==n)return a+e.slice(i)}(t,i,n,a)),n+t+i};Object.defineProperties(uz.prototype,{...uU,level:{enumerable:!0,get(){return this[uD]},set(e){uF(e),this[uD]=e}}}),uL(void 0),uL({level:uN?uN.level:0});let uG=function({onlyFirst:e=!1}={}){return RegExp("(?:(?:\\u001B\\]|\\u009D)[^\\u0007\\u001B\\u009C\\u009D]*(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]",e?void 0:"g")}(),uV=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],uH=[12288,12288,65281,65376,65504,65510],uK=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101594,101631,101664,101760,101874,101888,102801,102816,102866,110576,110579,110581,110587,110589,110590,110592,110888,110898,110898,110928,110930,110933,110933,110948,110952,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127406,127406,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128729,128732,128735,128747,128748,128756,128764,128986,128986,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129734,129736,129736,129740,129757,129759,129771,129775,129786,131072,196605,196608,262141],uQ=(e,t)=>{let r=0,n=Math.floor(e.length/2)-1;for(;r<=n;){let i=Math.floor((r+n)/2),a=2*i;if(t<e[a])n=i-1;else{if(!(t>e[a+1]))return!0;r=i+1}}return!1},[uZ,u0]=function(e){let t=e[0],r=e[1];for(let n=0;n<e.length;n+=2){let i=e[n],a=e[n+1];if(19968>=i&&19968<=a)return[i,a];a-i>r-t&&(t=i,r=a)}return[t,r]}(uK);function u1(e,{ambiguousAsWide:t=!1}={}){if(!Number.isSafeInteger(e))throw TypeError(`Expected a code point, got \`${typeof e}\`.`);return!(e<12288)&&!(e>65510)&&uQ(uH,e)||e>=uZ&&e<=u0||!(e<4352)&&!(e>262141)&&uQ(uK,e)||t&&!(e<161)&&!(e>1114109)&&uQ(uV,e)?2:1}let u2=new Intl.Segmenter,u5=/[^\p{Default_Ignorable_Code_Point}\p{Control}\p{Format}\p{Nonspacing_Mark}\p{Enclosing_Mark}\p{Surrogate}]/v,u3=/\p{Spacing_Mark}/v,u6=/^\p{RGI_Emoji}$/v,u8=/^[\d#*]\u20E3$/,u9=/\p{Extended_Pictographic}/gu;function u4(e){return e>=4352&&e<=4447||e>=43360&&e<=43388}function u7(e){return e>=4448&&e<=4519||e>=55216&&e<=55238}function fe(e){return e>=4520&&e<=4607||e>=55243&&e<=55291}function ft(e,t={}){if("string"!=typeof e||0===e.length)return 0;let{ambiguousIsNarrow:r=!0,countAnsiEscapeCodes:n=!1}=t,i=e;if(!n&&(i.includes("\x1b")||i.includes("›"))&&(i=function(e){if("string"!=typeof e)throw TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.includes("\x1b")||e.includes("›")?e.replace(uG,""):e}(i)),0===i.length)return 0;if(/^[\u0020-\u007E]*$/.test(i))return i.length;let a=0,s={ambiguousAsWide:!r};for(let{segment:e}of u2.segment(i)){let t=function(e){let t=e.search(u5);return -1===t?void 0:e.slice(t)}(e);if(void 0===t)continue;if(u6.test(e)||function(e){if(e.length>50)return!1;if(u8.test(e))return!0;if(e.includes("‍")){let t=e.match(u9);return null!==t&&t.length>=2}return!1}(e)){a+=2;continue}let r=function(e,t){let r=[];for(let t of e)u5.test(t)&&r.push(t.codePointAt(0));if(0===r.length)return;let n=0;for(let e=0;e<r.length;e++){let i=r[e];if(!(u4(i)||u7(i)||fe(i))){if(0===n)return;for(let i=e;i<r.length;i++)n+=u1(r[i],t);break}if(u4(i)&&u7(r[e+1])){n+=2,e+=fe(r[e+2])?2:1;continue}n+=u1(i,t)}return n}(t,s);if(void 0!==r){a+=r;continue}a+=u1(t.codePointAt(0),s),a+=function(e,t){let r=0,n=!0;for(let i of e){if(n){n=!1;continue}(u3.test(i)||i>="＀"&&i<="￯")&&(r+=u1(i.codePointAt(0),t))}return r}(t,s)}return a}let fr=(e=0)=>t=>`\x1b[${t+e}m`,fn=(e=0)=>t=>`\x1b[${38+e};5;${t}m`,fi=(e=0)=>(t,r,n)=>`\x1b[${38+e};2;${t};${r};${n}m`,fa={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(fa.modifier);let fs=Object.keys(fa.color),fo=Object.keys(fa.bgColor);[...fs,...fo];let fl=function(){let e=new Map;for(let[t,r]of Object.entries(fa)){for(let[t,n]of Object.entries(r))fa[t]={open:`\x1b[${n[0]}m`,close:`\x1b[${n[1]}m`},r[t]=fa[t],e.set(n[0],n[1]);Object.defineProperty(fa,t,{value:r,enumerable:!1})}return Object.defineProperty(fa,"codes",{value:e,enumerable:!1}),fa.color.close="\x1b[39m",fa.bgColor.close="\x1b[49m",fa.color.ansi=fr(),fa.color.ansi256=fn(),fa.color.ansi16m=fi(),fa.bgColor.ansi=fr(10),fa.bgColor.ansi256=fn(10),fa.bgColor.ansi16m=fi(10),Object.defineProperties(fa,{rgbToAnsi256:{value:(e,t,r)=>e===t&&t===r?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(r/255*5),enumerable:!1},hexToRgb:{value(e){let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[r]=t;3===r.length&&(r=[...r].map(e=>e+e).join(""));let n=Number.parseInt(r,16);return[n>>16&255,n>>8&255,255&n]},enumerable:!1},hexToAnsi256:{value:e=>fa.rgbToAnsi256(...fa.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){let t,r,n;if(e<8)return 30+e;if(e<16)return 90+(e-8);if(e>=232)r=t=((e-232)*10+8)/255,n=t;else{let i=(e-=16)%36;t=Math.floor(e/36)/5,r=Math.floor(i/6)/5,n=i%6/5}let i=2*Math.max(t,r,n);if(0===i)return 30;let a=30+(Math.round(n)<<2|Math.round(r)<<1|Math.round(t));return 2===i&&(a+=60),a},enumerable:!1},rgbToAnsi:{value:(e,t,r)=>fa.ansi256ToAnsi(fa.rgbToAnsi256(e,t,r)),enumerable:!1},hexToAnsi:{value:e=>fa.ansi256ToAnsi(fa.hexToAnsi256(e)),enumerable:!1}}),fa}(),fd=new Set(["\x1b","›"]),fc=[...fd].join(""),fu="(?:\x07|\x1b\\\\)",ff=String.raw`[^\u0000-\u001F\u007F-\u009F]*`,fp=String.raw`8;(?<parameters>[^;\u0000-\u001F\u007F-\u009F]*);(?<uri>${ff})${fu}`,fh=`${ff}${fu}`,fm=RegExp(`(?:\x1b\\[|\x9b)(?:(?<sgr>[0-9;:]*)m|[0-?]*[ -/]*[@-~])|\x1b\\](?:${fp}|${fh})`,"y"),fg=new Set(fl.codes.values());fg.delete(0);let fy=new Intl.Segmenter,fv=e=>ft(e,{countAnsiEscapeCodes:!0}),fb=RegExp(`[${fc}]`,"g"),f_=RegExp(`[\\n${fc}]`,"g"),fx=/^[ -~]*$/,fw=e=>`\x1b[${e}m`,fk=(e,t="")=>`\x1b]8;${t};${e}\x07`,fS=(e,t)=>{if(fd.has(e[t]))return fm.lastIndex=t,fm.exec(e)??void 0},fI=(e,t,r=()=>{})=>{let n=0,i=0;for(;i<e.length;){fb.lastIndex=i;let a=fb.exec(e);if(!a)break;let s=fS(e,a.index);if(!s){i=a.index+1;continue}a.index>n&&t(e.slice(n,a.index)),r(s[0]),n=i=a.index+s[0].length}n<e.length&&t(e.slice(n))},f$=e=>{let t="";return fI(e,e=>{t+=e}),fv(t)},fE=e=>{let t=e.split(":"),r=Number.parseInt(t[0],10),n=Number.parseInt(t[1],10);if(![38,48,58].includes(r))return;if(5===n&&3===t.length&&/^\d+$/.test(t[2]))return{code:r,open:e,hasArguments:!0};if(2!==n)return;let i=6===t.length?t.slice(3):t.slice(2),a=6===t.length?t[2]:void 0;if(3===i.length&&i.every(e=>/^\d+$/.test(e))&&(void 0===a||/^\d*$/.test(a)))return{code:r,open:e,hasArguments:!0}},fO=e=>{let t=e.split(";"),r=[];for(let e=0;e<t.length;e++){let n=t[e];if(n.includes(":")){let e=fE(n);e&&r.push(e);continue}let i=""===n?0:Number.parseInt(n,10);if(Number.isFinite(i)){if(38===i||48===i||58===i){if(e+1>=t.length)break;let n=Number.parseInt(t[e+1],10),a=Number.parseInt(t[e+2],10);if(5===n&&Number.isFinite(a)){r.push({code:i,open:[i,n,a].join(";"),hasArguments:!0}),e+=2;continue}let s=Number.parseInt(t[e+2],10),o=Number.parseInt(t[e+3],10),l=Number.parseInt(t[e+4],10);if(2===n&&Number.isFinite(s)&&Number.isFinite(o)&&Number.isFinite(l)){r.push({code:i,open:[i,n,s,o,l].join(";"),hasArguments:!0}),e+=4;continue}break}r.push({code:i,open:String(i),hasArguments:!1})}}return r},fC=(e,t)=>{let r=e.findIndex(e=>e.family===t);-1!==r&&e.splice(r,1)},fT=(e,t)=>{fC(e,t.family),e.push(t)},fM=(e,t)=>{if(0===e)return t.length=0,!0;if(39===e)return fC(t,"foreground"),!0;if(49===e)return fC(t,"background"),!0;if(59===e)return fC(t,"underlineColor"),!0;if(fg.has(e)){for(let r=t.length-1;r>=0;r--){let n=t[r];n.family.startsWith("modifier-")&&n.close===e&&t.splice(r,1)}return!0}return!1},fA=(e,t)=>{let{code:r}=e;if(fM(r,t))return;let n=(e=>{let{code:t,open:r,hasArguments:n}=e;return t>=30&&t<=37||t>=90&&t<=97||38===t&&n?{family:"foreground",open:r,close:39}:t>=40&&t<=47||t>=100&&t<=107||48===t&&n?{family:"background",open:r,close:49}:58===t&&n?{family:"underlineColor",open:r,close:59}:void 0})(e);if(n)return void fT(t,n);let i=fl.codes.get(r);void 0!==i&&0!==i&&fT(t,{family:`modifier-${r}`,open:e.open,close:i})},fN=(e,t)=>{for(let r of fO(e))fA(r,t)},fP=(e,t)=>{for(let{code:r}of fO(e))fM(r,t)},fR=(e,t,r)=>{let n=t;for(;n<e.length;){let t=fS(e,n);if(!t)break;void 0!==t.groups.sgr&&fP(t.groups.sgr,r),n+=t[0].length}},fj=e=>[...e].reverse().map(e=>fw(e.close)).join(""),fD=e=>e.map(e=>fw(e.open)).join(""),fU=(e,t,r,n)=>{let i,a=(i=[],fI(t,e=>{if(fx.test(e)){for(let t of e)i.push({value:t,width:1});return}for(let{segment:t}of fy.segment(e))i.push({value:t,width:fv(t)})},e=>{i.push({value:e,width:0})}),i),s=n;for(let t=0;t<a.length;t++){let n=a[t];n.width>0&&s>0&&s+n.width>r&&(e.push(""),s=0),e[e.length-1]+=n.value,(s+=n.width)===r&&t<a.length-1&&(e.push(""),s=0)}return!s&&e.at(-1).length>0&&e.length>1&&(e[e.length-2]+=e.pop()),f$(e.at(-1))},fF=[" pppppppppppp "," pppppppppppppp ","pppppppppppeeppp","ppppppppppfeeepp","pppppppppcffeepp","ppppppppcccffppp","pppppppcccccpppp","ppppppcccccppppp","pppppcccccpppppp","ppppwccccppppppp","pppwwwccpppppppp","pppkwwwppppppppp","pppkkwpppppppppp","pppppppppppppppp"," pppppppppppppp "," pppppppppppp "],fB={s:["....","....",".###","#...",".##.","...#","###.","...."],k:["#...","#...","#..#","#.#.","##..","#.#.","#..#","...."],e:["....","....",".##.","#..#","####","#...",".###","...."],t:[".#.",".#.","###",".#.",".#.",".#.",".##","..."],c:["....","....",".###","#...","#...","#...",".###","...."],h:["#...","#...","#.#.","##.#","#..#","#..#","#..#","...."],i:["#",".","#","#","#","#","#","."]},fL={p:{dark:{red:158,green:124,blue:140,ansi256:138},light:{red:143,green:112,blue:127,ansi256:96}},c:{dark:{red:250,green:248,blue:247,ansi256:231},light:{red:250,green:248,blue:247,ansi256:231}},w:{dark:{red:214,green:186,blue:152,ansi256:180},light:{red:214,green:186,blue:152,ansi256:180}},k:{dark:{red:58,green:50,blue:54,ansi256:237},light:{red:58,green:50,blue:54,ansi256:237}},f:{dark:{red:186,green:190,blue:196,ansi256:250},light:{red:186,green:190,blue:196,ansi256:250}},e:{dark:{red:222,green:152,blue:158,ansi256:175},light:{red:222,green:152,blue:158,ansi256:175}}},fz={dark:{red:195,green:154,blue:172,ansi256:181},light:{red:111,green:84,blue:98,ansi256:95}},fW={dark:{red:246,green:241,blue:231,ansi256:255},light:{red:26,green:23,blue:18,ansi256:234}},fJ={dark:{red:216,green:204,blue:177,ansi256:187},light:{red:76,green:70,blue:57,ansi256:239}},fY=[[0,0,0],[205,0,0],[0,205,0],[205,205,0],[0,0,238],[205,0,205],[0,205,205],[229,229,229],[127,127,127],[255,0,0],[0,255,0],[255,255,0],[92,92,255],[255,0,255],[0,255,255],[255,255,255]];function fX(e,t){let r=fL[e];return void 0===r?void 0:r[t.background]}function fq(e,t,r,n=ft(e)){var i,a;let s,o=Math.max(16,r-ft(e));return`${e}${(i={hard:!0,trim:!0},(a=String(t),s="",fI(a,e=>{s+=e.normalize()},e=>{s+=e}),s).replaceAll("\r\n","\n").split("\n").map(e=>((e,t,r={})=>{if(!1!==r.trim&&""===e.trim())return"";let n=(e=>{let t={value:"",plainText:""},r=[t];for(let n of(fI(e,e=>{let n=e.split(" ");t.value+=n[0],t.plainText+=n[0];for(let e=1;e<n.length;e++)t={value:n[e],plainText:n[e]},r.push(t)},e=>{t.value+=e}),r))n.width=fv(n.plainText);return r})(e),i=[""],a=0,s=-1,o=!0;for(let e of n){let n=i.length-1;if(!1!==r.trim&&s!==n){let e=i[n],t=e.trimStart();t.length!==e.length&&(i[n]=t,a=f$(t)),t.length>0&&(s=n)}if(o?o=!1:(a>=t&&(!1===r.wordWrap||!1===r.trim)&&(i.push(""),a=0),(a>0||!1===r.trim)&&(i[i.length-1]+=" ",a++)),r.hard&&!1!==r.wordWrap&&e.width>t){let r=t-a,n=1+Math.floor((e.width-r-1)/t);Math.floor((e.width-1)/t)<n&&(i.push(""),a=0),a=fU(i,e.value,t,a);continue}if(a+e.width>t&&a>0&&e.width>0){if(!1===r.wordWrap&&a<t){a=fU(i,e.value,t,a);continue}i.push(""),a=0}if(a+e.width>t&&!1===r.wordWrap){a=fU(i,e.value,t,a);continue}i[i.length-1]+=e.value,a+=e.width}return!1!==r.trim&&(i=i.map(e=>(e=>{if(!e.includes(" "))return e;let t=[];fI(e,e=>{t.push({value:e,isEscape:!1})},e=>{t.push({value:e,isEscape:!0})});for(let e=t.length-1;e>=0;e--){let r=t[e];if(r.isEscape)continue;let n=r.value.length;for(;n>0&&" "===r.value[n-1];)n--;if(r.value=r.value.slice(0,n),fv(r.value)>0)break}return t.map(e=>e.value).join("")})(e))),(e=>{let t,r="",n=[],i=0,a=0;for(;i<e.length;){f_.lastIndex=i;let s=f_.exec(e);if(!s)break;if(i=s.index,"\n"!==s[0]){let r=fS(e,i);if(!r){i++;continue}let{groups:a}=r;void 0!==a.sgr?fN(a.sgr,n):void 0!==a.uri&&(t=0===a.uri.length?void 0:{parameters:a.parameters,uri:a.uri}),i+=r[0].length;continue}if(r+=e.slice(a,i),i>a&&(t&&(r+=fk("")),r+=fj(n)),r+="\n",a=++i,i<e.length&&"\n"!==e[i]){let a=[...n];fR(e,i,a),r+=fD(a),t&&(r+=fk(t.uri,t.parameters))}}return r+e.slice(a)})(i.join("\n"))})((e=>{if(!e.includes(" "))return e;let t=0,r="",n="";return fI(e,e=>{let i=e.split(" ");for(let[e,a]of i.entries())if(r+=a,n+=a,e<i.length-1){t+=fv(n),n="";let e=8-t%8;r+=" ".repeat(e),t+=e}},e=>{r+=e}),r})(e),o,i)).join("\n")).replaceAll("\n",`
56
+ ${" ".repeat(n)}`)}`}function fG(e,t,r,n,i=8){if(n<52)return[` ${r.command(e)}`,fq(" ",r.description(t),n)].join("\n");let a=e.padEnd(i);return fq(` ${r.command(a)} `,r.description(t),n)}function fV(e){let t,r,n,i=(t=new uB({level:"none"===e.colors?0:"truecolor"===e.colors?3:2}),r=(r,n=t)=>"truecolor"===e.colors?n.rgb(r.red,r.green,r.blue):n.ansi256(r.ansi256),n=(e,t,n=!1)=>{let i=r(t);return n?i.bold(e):i(e)},{foreground:r,pair:(n,i)=>r(n,"truecolor"===e.colors?t.bgRgb(i.red,i.green,i.blue):t.bgAnsi256(i.ansi256))("▀"),heading:t=>n(t,fz[e.background],!0),command:t=>n(t,fW[e.background],!0),description:t=>n(t,fJ[e.background])}),a=Math.max(32,e.width??80);return[function(e,t){let r=Math.max(32,e.width??80),n=fq(" ",t.description("describe it. sketchi draws it."),r);if("none"===e.colors||!1===e.unicode)return[` ${t.command("sketchi")}`,n].join("\n");let i=function(e,t){let r=Array.from({length:8},(e,t)=>[..."sketchi"].map((e,r)=>`${fB[e]?.[t]??""}${6===r?"":"."}`).join("")),n=fW[e.background],i=[];for(let a=0;a<r.length;a+=2){let s="";for(let e=0;e<(r[a]?.length??0);e+=1){let t=r[a]?.[e]==="#",n=r[a+1]?.[e]==="#";s+=t&&n?"█":t?"▀":n?"▄":" "}i.push("none"===e.colors?s:t.foreground(n)(s))}return i}(e,t);if(r<50)return[...i.map(e=>` ${e}`),"",n].join("\n");let a=function(e,t){let r=[];for(let n=0;n<fF.length;n+=2){let i="";for(let r=0;r<16;r+=1){let a=fX(fF[n]?.[r]??" ",e),s=fX(fF[n+1]?.[r]??" ",e);void 0===a&&void 0===s?i+=" ":void 0===a&&void 0!==s?i+=t.foreground(s)("▄"):void 0!==a&&void 0===s?i+=t.foreground(a)("▀"):void 0!==a&&void 0!==s&&(i+=t.pair(a,s))}r.push(i)}return r}(e,t),s=(a.length-i.length)/2,o=" ".repeat(2);return[...a.map((e,t)=>{let r=i[t-s];return` ${e}${void 0===r?"":`${o}${r}`}`}),"",n].join("\n")}(e,i),"",i.heading("START HERE"),fq(` ${i.command("sketchi generate")} `,i.description("interactive"),a),fq(" ",i.command('sketchi generate --prompt "Map release approval with pass and revise branches"'),a),fq(" ",i.description("Writes <generated-id>.png in this directory. No account or API key needed."),a),fG("canvas","Build and export a typed Universal CanvasSpec.",i,a),"",i.heading("WORK WITH A DIAGRAM"),fG("show","Inspect a local diagram.",i,a),fG("edit","Replace its canonical document.",i,a),fG("export","Write PNG, Excalidraw, or scene bytes.",i,a),fG("share","Create an encrypted Excalidraw link.",i,a),"",fq("",i.description("sketchi docs for every command. Add --output json for automation."),a)].join("\n")}function fH(e){if(!Number.isInteger(e)||e<0||e>255)return;if(e<16){let[t,r,n]=fY[e]??[0,0,0];return{red:t,green:r,blue:n}}if(e<232){let t=[0,95,135,175,215,255],r=e-16,n=t[Math.floor(r/36)]??0;return{red:n,green:t[Math.floor(r%36/6)]??0,blue:t[r%6]??0}}let t=8+(e-232)*10;return{red:t,green:t,blue:t}}function fK(e){let t=e=>{let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4};return .2126*t(e.red)+.7152*t(e.green)+.0722*t(e.blue)}function fQ(e,t){return(Math.max(fK(e),fK(t))+.05)/(Math.min(fK(e),fK(t))+.05)}function fZ(e,t,r){let n=e=>"truecolor"===r?e:fH(e.ansi256)??e;return Math.min(fQ(e,n(fz[t])),fQ(e,n(fW[t])),fQ(e,n(fJ[t])))}let f0=new Set(["generate","canvas","docs","create","show","edit","patch","list","restore","share","pull","export"]);function f1(e="canonical document"){return{fileInput:oN("flag","file").pipe(lO("PATH|-"),lE(`Read one ${e} from PATH, or stdin with -.`),lA(1),lC),jsonInput:oN("flag","json").pipe(lO("VALUE"),lE(`Read one ${e} from inline JSON.`),lA(1),lC)}}let f2=B.fn("sketchi.cli.input.source")(function*(e){let t=ee.getOrElse(e.fileInput,()=>[]),r=ee.getOrElse(e.jsonInput,()=>[]);return 1===t.length&&0===r.length?{_tag:"File",path:t[0]}:0===t.length&&1===r.length?{_tag:"InlineJson",value:r[0]}:yield*f5("file/--json",0===t.length&&0===r.length?"neither provided":"more than one source provided","exactly one of --file PATH|- or --json VALUE")});function f5(e,t,r){return new oc({option:e,value:t,expected:r,kind:"flag"})}function f3(e){for(let[t,r]of e.entries()){if("--"===r)break;if("--output"===r)return"json"===e[t+1]?"json":"text";if(r.startsWith("--output="))return"--output=json"===r?"json":"text"}return"text"}class f6 extends Z.kl()("@sketchi/cli/OutputWriter"){}class f8 extends nx.rNF()("CliCommandExit",{exitCode:nx.wNn}){}function f9(e){return nA.make({cause:e,operation:"write-output",path:"standard stream",message:"Unable to write command output."})}let f4=G.QZ(f6,B.JkU(function*(){let e=yield*nf;return{stdout:t=>((...e)=>t$(e))(t).pipe(tA(e.stdout()),B.xm_(f9)),stderr:t=>((...e)=>t$(e))(t).pipe(tA(e.stderr()),B.xm_(f9))}}));function f7(e){let t=e.details?.map(e=>` - ${e}`).join("\n");return[`error: ${e.code}`,e.message,...e.diagramId?[`diagram: ${e.diagramId}`]:[],...e.storagePath?[`storage: ${e.storagePath}`]:[],...e.recoveryCommand?[`recovery: ${e.recoveryCommand}`]:[],`next: ${e.hint}`,...t?["details:",t]:[]].join("\n")+"\n"}let pe=B.fn("sketchi.cli.output.failure")(function*(e,t,r){let n=yield*f6,i=function(e){switch(e._tag){case"CliFilesystemError":return{code:"filesystem_error",message:e.message,hint:"Check local paths and permissions, then retry."};case"CliInputError":case"CliInteractiveError":case"CliStorageError":return{code:e.code,message:e.message,hint:e.hint};case"CliValidationError":return{code:"invalid_document",message:e.message,hint:e.hint,details:e.details};case"CliBuildError":return{code:"build_failed",message:e.message,hint:e.hint,details:e.details};case"CliCanvasError":case"CliGenerationError":case"CliShareError":return{code:e.code,message:e.message,hint:e.hint,details:e.details};case"CliExportError":return{code:e.code,message:e.message,hint:e.hint,...e.details?{details:e.details}:{},...e.diagramId?{diagramId:e.diagramId}:{},...e.storagePath?{storagePath:e.storagePath}:{},...e.recoveryCommand?{recoveryCommand:e.recoveryCommand}:{}}}}(r),a="json"===t?n6({ok:!1,command:e,error:i}):f7(i);return yield*n.stderr(ub(a)),yield*f8.make({exitCode:function(e){switch(e._tag){case"CliInputError":return"interactive_stdin"===e.code?2:3;case"CliValidationError":return 3;case"CliBuildError":return 4;case"CliGenerationError":switch(e.code){case"invalid_generated_document":case"unsupported_diagram_type":return 3;case"provider_failure":return 10;case"generation_timeout":return 11;case"malformed_output":return 12}case"CliCanvasError":switch(e.code){case"canvas_rejected":return 4;case"endpoint_failure":case"network_failure":return 10;case"canvas_timeout":return 11;case"malformed_response":return 12}case"CliInteractiveError":return"cancelled"===e.code?2:1;case"CliStorageError":if("diagram_not_found"===e.code||"revision_not_found"===e.code)return 5;if("diagram_already_exists"===e.code||"diagram_busy"===e.code||"detached_edit"===e.code||"patch_conflict"===e.code||"replacement_conflict"===e.code||"restore_conflict"===e.code)return 6;return 7;case"CliFilesystemError":return 7;case"CliExportError":return 8;case"CliShareError":return"share_transport_failed"===e.code||"share_timeout"===e.code||"share_api_changed"===e.code||"share_link_unavailable"===e.code?13:3}}(r)})}),pt=B.fn("sketchi.cli.output.success")(function*(e,t,r,n,i="stdout"){let a=yield*f6,s="json"===t?n6({ok:!0,command:e,data:r}):n;yield*a[i](s.endsWith("\n")?s:`${s}
57
+ `)});function pr(e,t,r,n,i=e=>e){return r.pipe(B.tvg({onFailure:r=>pe(e,t,r),onSuccess:r=>pt(e,t,i(r),n(r))}))}let pn=B.fn("sketchi.cli.output.artifact")(function*(e,t,r,n,i,a,s){return yield*r.pipe(B.tvg({onFailure:r=>pe(e,t,r),onSuccess:r=>B.JkU(function*(){let o=yield*f6,l=n(r).stdoutBytes;l&&(yield*o.stdout(l)),yield*pt(e,t,a(r),i(r),s(r))})}))});function pi(e,t,r){return nB.make({code:e,message:t,hint:r,details:[]})}function pa(){return pi("share_timeout","The Excalidraw storage request timed out.","Retry once. The unofficial third-party backend may be unavailable.")}function ps(){return pi("share_transport_failed","The Excalidraw storage request failed.","Retry once. The unofficial third-party backend may be unavailable.")}let po=B.fn("sketchi.cli.share.request")(function*(e,t){return yield*B.$mh({try:r=>fetch(e,{...t,redirect:"error",signal:r}),catch:ps})}),pl=nx._Re(nx._kM({id:nx.QfV,data:nx.QfV})),pd=nx._Re(nx.mj7(nx.$r1));function pc(){return pi("share_api_changed","The Excalidraw storage API returned an unexpected response.","The unofficial API may have changed; update Sketchi compatibility before retrying.")}class pu extends Z.kl()("@sketchi/cli/ShareTransport"){}let pf=G.Py(pu,{upload:B.fn("sketchi.cli.share.transport.upload")(function*(e){let t=yield*po("https://json.excalidraw.com/api/v2/post/",{method:"POST",body:Uint8Array.from(e)}),r=yield*a_(t,65536,ps);if(!t.ok)return yield*ps();let n=yield*pd(r).pipe(B.xm_(ps)),i=yield*pl(n).pipe(B.xm_(pc));return/^[A-Za-z0-9_-]{1,128}$/.test(i.id)&&i.data===`${iN}${i.id}`?i.id:yield*pc()},B.mgX({duration:15e3,orElse:()=>B.fJG(pa())})),download:B.fn("sketchi.cli.share.transport.download")(function*(e){let t=yield*po(`${iN}${e}`,{method:"GET"});return 404===t.status?yield*pi("share_link_unavailable","The Excalidraw share link is unavailable.","Verify the complete bearer link or ask its sender to export a new link."):t.ok?yield*ab(t,2097152,ps):yield*ps()},B.mgX({duration:15e3,orElse:()=>B.fJG(pa())}))});class pp extends Z.kl()("@sketchi/cli/LinkOpener"){}let ph=B.fn("sketchi.cli.share.terminateOpener")(e=>B.E2r(t=>{e.onExit(()=>t(B.rIH)),e.onError(()=>t(B.rIH)),e.kill("SIGTERM")||t(B.rIH)}).pipe(B.wRz("250 millis"),B.KuX("TimeoutError",()=>B.OH5(()=>{e.kill("SIGKILL")})))),pm=function(e=(e,t,r)=>{let n=(0,t7.spawn)(e,[...t],r);return{onError:e=>{n.once("error",e)},onExit:e=>{n.once("exit",e)},kill:e=>n.kill(e)}},t=process.platform,r=3e3){return G.Py(pp,{open:n=>B.E2r(r=>{let i=function(e,t){switch(t){case"darwin":return{command:"open",args:[e]};case"win32":return{command:"cmd.exe",args:["/d","/s","/c","start","",e]};default:return{command:"xdg-open",args:[e]}}}(n,t),a=e(i.command,i.args,{shell:!1,stdio:"ignore"});return a.onError(()=>r(B.PyW({status:"unconfirmed",reason:"missing_executable"}))),a.onExit(e=>r(B.PyW(0===e?{status:"accepted"}:{status:"unconfirmed",reason:"nonzero_exit"}))),ph(a)}).pipe(B.wRz(r),B.KuX("TimeoutError",()=>B.PyW({status:"unconfirmed",reason:"timeout"})))})}();class pg extends Z.kl()("@sketchi/cli/ExcalidrawShare"){}let py=G.QZ(pg,B.JkU(function*(){let e=yield*pu;return{share:B.fn("sketchi.cli.share.upload")(function*(t){var r;let n=yield*iH(t).pipe(B.qIB(()=>B.SvU({try:()=>{var e;let r=iq(t);return ij.encode(JSON.stringify({type:r.type,version:r.version,source:r.source,elements:r.elements,appState:(e=r.appState,Object.fromEntries(["gridSize","gridStep","gridModeEnabled","viewBackgroundColor","lockedMultiSelections"].flatMap(t=>t in e?[[t,e[t]]]:[])))},null,2))},catch:()=>iF("unsupported_scene","The Excalidraw scene could not be serialized.","Inspect the local diagram.excalidraw artifact and retry.")}))),i=Buffer.from(crypto.getRandomValues(new Uint8Array(16))).toString("base64url"),a=yield*B.$mh({try:async()=>{if(n.byteLength>0xfffff0)throw iF("share_payload_too_large","The Excalidraw share contents exceed 16 MiB.","Reduce the drawing size and retry.");let e=2097136-iU.byteLength-12-16,t=await function(e,t){let r=ij.encode("null"),n=[iK(1),iK(r.byteLength),r,iK(e.byteLength),e],i=new iM.Gy({chunkSize:65536}),a=[],s=0;for(let[e,r]of(i.onData=e=>{let r=e instanceof Uint8Array?e:new Uint8Array(e);if((s+=r.byteLength)>t)throw iF("share_payload_too_large","The encrypted Excalidraw share payload exceeds 2 MiB.","Reduce the drawing size and retry.");a.push(r)},n.entries()))if(i.push(r,e===n.length-1),0!==i.err)throw Error(i.msg);let o=new Uint8Array(s),l=0;for(let e of a)o.set(e,l),l+=e.byteLength;return o}(n,e),r=Uint8Array.from((void 0)??crypto.getRandomValues(new Uint8Array(12)));if(12!==r.byteLength)throw Error("invalid IV length");let a=new Uint8Array(await crypto.subtle.encrypt({name:"AES-GCM",iv:Uint8Array.from(r)},await iX(i,"encrypt"),Uint8Array.from(t)));var s=[iU,r,a];let o=new Uint8Array(4+s.reduce((e,t)=>e+4+t.byteLength,0));iz(o,0,1);let l=4;for(let e of s)iz(o,l,e.byteLength),l+=4,o.set(e,l),l+=e.byteLength;return o},catch:e=>e instanceof nB?e:iF("share_crypto_failed","The Excalidraw share payload could not be encrypted.","Retry the command. If it persists, inspect the local artifact.")});return{link:(r={id:yield*e.upload(a),key:i},`https://excalidraw.com/#json=${r.id},${r.key}`)}}),pull:B.fn("sketchi.cli.share.pull")(function*(t){var r;let n=yield*ij.encode(t).byteLength>4096?B.fJG(iF("invalid_share_link","The Excalidraw share link is invalid.","Provide one complete https://excalidraw.com/#json=ID,KEY link.",["link exceeds 4 KiB"])):B.SvU({try:()=>{let e=/^https:\/\/(www\.)?excalidraw\.com\/#json=([A-Za-z0-9_-]{1,128}),([A-Za-z0-9_-]{22})$/u.exec(t);if(!e?.[2]||!e[3])throw Error("invalid raw URL grammar");let r=new URL(t),n=`https://${e[1]??""}excalidraw.com/#json=${e[2]},${e[3]}`;if(r.href!==n)throw Error("URL normalization changed the supplied link");return iY(e[3]),{id:e[2],key:e[3]}},catch:()=>iF("invalid_share_link","The Excalidraw share link is invalid.","Provide one complete https://excalidraw.com/#json=ID,KEY link.")}),i=yield*e.download(n.id);return yield*(r=n.key,i.byteLength>2097152?B.fJG(iF("share_payload_too_large","The Excalidraw share payload exceeds 2 MiB.","Use a smaller supported Excalidraw link.")):B.$mh({try:async()=>{let[e,t,n]=iJ(i,3);if(!e||!t||!n||12!==t.byteLength)throw Error("invalid encrypted payload chunks");let a=JSON.parse(iD.decode(e));if(!iB(a)||2!==a.version||"pako@1"!==a.compression||"AES-GCM"!==a.encryption)throw Error("unsupported encoding metadata");let s=new Uint8Array(await crypto.subtle.decrypt({name:"AES-GCM",iv:Uint8Array.from(t)},await iX(r,"decrypt"),Uint8Array.from(n))),o=(0,iT.inflateSync)(s,{maxOutputLength:0x1000001});if(o.byteLength>0x1000000)throw Error("decompressed payload exceeds 16 MiB");let l=iJ(o,2);if(!l[0]||!l[1])throw Error("invalid inner chunk count");if("null"!==iD.decode(l[0]))throw Error("unsupported contents metadata");return!function(e){let t=iD.decode(e),r=0,n=!1,i=!1;for(let e of t){if(n){i?i=!1:"\\"===e?i=!0:'"'===e&&(n=!1);continue}if('"'===e)n=!0;else if("{"===e||"["===e){if((r+=1)>64)throw Error("JSON structure exceeds depth 64")}else if(("}"===e||"]"===e)&&(r-=1)<0)throw Error("unbalanced JSON structure")}if(0!==r||n)throw Error("incomplete JSON structure")}(l[1]),JSON.parse(iD.decode(l[1]))},catch:e=>e instanceof RangeError||e instanceof Error&&(e.message.includes("maxOutputLength")||e.message.includes("larger than"))?iF("share_payload_too_large","The decompressed Excalidraw share payload exceeds 16 MiB.","Use a smaller supported Excalidraw link."):iF("share_crypto_failed","The Excalidraw share payload could not be decrypted or decoded.","Verify that the complete bearer link is correct and uses current format v2.")}))})}}));function pv(e){return nB.make({code:"unsupported_scene",message:"The pulled Excalidraw scene cannot be rendered safely.",hint:"Use a supported, renderable Excalidraw scene and retry.",details:[e.message]})}let pb=B.fn("sketchi.cli.preflightPullTarget")(function*(e){let t=yield*n9(e),r=yield*i6,n=yield*r.show(t);return{id:t,observed:n}}),p_=B.fn("sketchi.cli.pullIntoStore")(function*(e,t,r){let n=r??(yield*pb(e)),i=n.id,a=yield*i6,s=yield*pg,o=yield*aR,l=yield*s.pull(t);yield*iH(l);let d=yield*o.normalizeExcalidraw(l).pipe(B.xm_(pv));return yield*iH(d),yield*o.renderPng({excalidraw:d}).pipe(B.xm_(pv)),{diagram:yield*a.replaceWithDetached(i,new TextEncoder().encode(n6(d)),n.observed.manifest.revision),sourceIdentity:"unverified"}}),px=`Sketchi CLI contracts for agents and automation.
58
58
 
59
59
  Command map:
60
60
  Start with generate for prompt-to-PNG or canvas for an authored CanvasSpec. Use show, list,
@@ -118,8 +118,8 @@ Input and output contracts:
118
118
  Share/pull safety limits:
119
119
  links 4 KiB; encrypted bodies 2 MiB; inflated contents 16 MiB; 10,000 elements;
120
120
  JSON depth 64; element dimensions ${String(8192)}; canvas dimensions
121
- ${String(8192)}; canvas area ${String(iR.Z4)} square units; final PNG
122
- ${String(iR.ce)} pixels. Limits are checked before encryption or raster allocation.
121
+ ${String(8192)}; canvas area ${String(iA.Z4)} square units; final PNG
122
+ ${String(iA.ce)} pixels. Limits are checked before encryption or raster allocation.
123
123
 
124
124
  Offline boundary and storage:
125
125
  create, patch, show, edit, list, export, and restore use no model, remote agent, MCP server, login,
@@ -150,18 +150,18 @@ Revision recovery and next steps:
150
150
  Use restore --revision N to recover through the CLI without consuming the selected snapshot.
151
151
  Start with generate for a prompt, canvas for CanvasSpec, or create for accepted canonical JSON.
152
152
  Every returned id supports show, list, and export. Edit and patch are only for flowchart,
153
- mindmap, and sequence records; create a new canvas to replace a Universal CanvasSpec.`,pk=lk("output",["text","json"]).pipe(oz("text"),lI("Result presentation format."),l$("text|json")),pS=uo("sketchi").pipe(ud({output:pk}),uc("Turn one prompt into a validated PNG and editable local diagram."),uu("Turn a prompt into a validated PNG and editable local diagram.")),pI=uo("docs",{},()=>L.JkU(function*(){let{output:e}=yield*pS;yield*pn("docs",e,{documentation:pw},pw)})).pipe(uc("Print the complete CLI contracts for agents, automation, storage, formats, safety limits, and errors."),uu("Print complete agent and automation documentation."));function p$(e){return`~/.sketchi/diagrams/${e}`}function pE(e){return e.revisions.map(t=>`${p$(e.manifest.id)}/revisions/${t}`)}function pO(e){return{...iP(e),storagePath:p$(e.manifest.id),revisions:pE(e),document:e.document}}function pC(){return nz.make({code:"unsupported_scene",message:"The linked Excalidraw scene cannot be rendered by this Sketchi CLI.",hint:"Use only the supported v1 elements and Excalifont text, then export a new link.",details:[]})}let pT=L.fn("sketchi.cli.pull.readLink")(function*(e){if("-"!==e)return e;let t=yield*iy;return(yield*t.read({_tag:"File",path:"-"},{content:"share link",maxBytes:4096})).trim()});function pM(e,t){return`${e}: ${t.manifest.id}
153
+ mindmap, and sequence records; create a new canvas to replace a Universal CanvasSpec.`,pw=lI("output",["text","json"]).pipe(oz("text"),lE("Result presentation format."),lO("text|json")),pk=uu("sketchi").pipe(up({output:pw}),uh("Turn one prompt into a validated PNG and editable local diagram."),um("Turn a prompt into a validated PNG and editable local diagram.")),pS=uu("docs",{},()=>B.JkU(function*(){let{output:e}=yield*pk;yield*pt("docs",e,{documentation:px},px)})).pipe(uh("Print the complete CLI contracts for agents, automation, storage, formats, safety limits, and errors."),um("Print complete agent and automation documentation."));function pI(e){return`~/.sketchi/diagrams/${e}`}function p$(e){return e.revisions.map(t=>`${pI(e.manifest.id)}/revisions/${t}`)}function pE(e){return{...iO(e),storagePath:pI(e.manifest.id),revisions:p$(e),document:e.document}}function pO(){return nB.make({code:"unsupported_scene",message:"The linked Excalidraw scene cannot be rendered by this Sketchi CLI.",hint:"Use only the supported v1 elements and Excalifont text, then export a new link.",details:[]})}let pC=B.fn("sketchi.cli.pull.readLink")(function*(e){if("-"!==e)return e;let t=yield*ih;return(yield*t.read({_tag:"File",path:"-"},{content:"share link",maxBytes:4096})).trim()});function pT(e,t){return`${e}: ${t.manifest.id}
154
154
  type: ${t.manifest.type}
155
155
  title: ${t.manifest.title}
156
156
  revision: ${String(t.manifest.revision)}
157
157
  authority: ${t.authority}
158
- document authoritative: ${String(t.documentAuthoritative)}
158
+ document authoritative: ${String("canonical"===t.authority)}
159
159
  formats: ${t.manifest.formats.join(",")}
160
- storage: ${p$(t.manifest.id)}`}function pP(e,t){return t.pipe(L.tvg({onFailure:t=>pr("generate",e,t),onSuccess:t=>L.JkU(function*(){var r;let n=yield*f9;t.artifact.stdoutBytes&&(yield*n.stdout(t.artifact.stdoutBytes)),yield*pn("generate",e,{...{...pO((r=t.generated).diagram),generation:{model:r.model,provider:r.provider}},export:pq(t.artifact)},function(e){var t;if(e.interactive)return`created: ${e.generated.diagram.manifest.id}
160
+ storage: ${pI(t.manifest.id)}`}function pM(e){var t;return{...{...pE((t=e.generated).diagram),generation:{model:t.model,provider:t.provider}},export:pH(e.artifact)}}function pA(e){var t;if(e.interactive)return`created: ${e.generated.diagram.manifest.id}
161
161
  artifact: ${e.artifact.destination}
162
162
  next:
163
163
  sketchi show ${e.generated.diagram.manifest.id}
164
- sketchi export ${e.generated.diagram.manifest.id} --format excalidraw --dest ${e.generated.diagram.manifest.id}.excalidraw`;let r=pG(e.artifact);return[[pM("created",(t=e.generated).diagram).replace(/^created:/u,"generated:"),`provider: ${t.provider}`,`model: ${t.model}`].join("\n"),`format: ${e.artifact.format}`,`destination: ${e.artifact.destination}`,`bytes: ${String(e.artifact.sizeBytes)}`,...r?[`hint: ${r}`]:[]].join("\n")}(t),"-"===t.artifact.destination?"stderr":"stdout")})}))}function pA(e){let t=pE(e);return[`id: ${e.manifest.id}`,`type: ${e.manifest.type}`,`title: ${e.manifest.title}`,`revision: ${String(e.manifest.revision)}`,`authority: ${e.authority}`,`document authoritative: ${String(e.documentAuthoritative)}`,`formats: ${e.manifest.formats.join(",")}`,`revisions: ${0===t.length?"none":t.join(",")}`,"document:",n2(e.document).trimEnd()].join("\n")}function pN(e){return 0===e.length?"no diagrams":["id type revision authority document-authoritative formats title",...e.map(e=>"status"in e?[e.id,`unavailable:${e.code}`,"- - - -",e.message].join(" "):[e.id,e.type,String(e.revision),e.authority,String(e.documentAuthoritative),e.formats.join(","),e.title].join(" "))].join("\n")}let pR=`Create one persisted diagram and export its PNG by default. With no --prompt, Sketchi opens a short wizard only when stdin and stdout are human TTYs, output is text, and CI is absent. Pipes, redirects, CI, and --output json never prompt or block; pass --prompt for every script and automation path. This is one of Sketchi's four explicit network commands (generate, canvas, share, pull). It makes one unauthenticated HTTPS POST to the public Sketchi generate API and needs no token, key, account, or login.
164
+ sketchi export ${e.generated.diagram.manifest.id} --format excalidraw --dest ${e.generated.diagram.manifest.id}.excalidraw`;let r=pK(e.artifact);return[[pT("created",(t=e.generated).diagram).replace(/^created:/u,"generated:"),`provider: ${t.provider}`,`model: ${t.model}`].join("\n"),`format: ${e.artifact.format}`,`destination: ${e.artifact.destination}`,`bytes: ${String(e.artifact.sizeBytes)}`,...r?[`hint: ${r}`]:[]].join("\n")}function pN(e,t){return pn("generate",e,t,e=>e.artifact,pA,pM,e=>"-"===e.artifact.destination?"stderr":"stdout")}function pP(e){let t=p$(e);return[`id: ${e.manifest.id}`,`type: ${e.manifest.type}`,`title: ${e.manifest.title}`,`revision: ${String(e.manifest.revision)}`,`authority: ${e.authority}`,`document authoritative: ${String("canonical"===e.authority)}`,`formats: ${e.manifest.formats.join(",")}`,`revisions: ${0===t.length?"none":t.join(",")}`,"document:",n6(e.document).trimEnd()].join("\n")}function pR(e){return 0===e.length?"no diagrams":["id type revision authority document-authoritative formats title",...e.map(e=>"status"in e?[e.id,`unavailable:${e.code}`,"- - - -",e.message].join(" "):[e.id,e.type,String(e.revision),e.authority,String(e.documentAuthoritative),e.formats.join(","),e.title].join(" "))].join("\n")}let pj=`Create one persisted diagram and export its PNG by default. With no --prompt, Sketchi opens a short wizard only when stdin and stdout are human TTYs, output is text, and CI is absent. Pipes, redirects, CI, and --output json never prompt or block; pass --prompt for every script and automation path. This is one of Sketchi's four explicit network commands (generate, canvas, share, pull). It makes one unauthenticated HTTPS POST to the public Sketchi generate API and needs no token, key, account, or login.
165
165
 
166
166
  Everyday wizard:
167
167
  The wizard asks only for prompt text, flowchart (default), mind map, or sequence diagram, and a PNG destination.
@@ -195,7 +195,7 @@ Errors and next steps:
195
195
  a rejected or invalid generated document uses 3, conflict uses 6, and storage uses 7.
196
196
  With --dest -, stdout contains artifact bytes only and all status uses stderr. On success, pass
197
197
  the returned id to show, edit, list, or export. For strictly offline manual authoring, accepted
198
- canonical JSON examples, and full error contracts, run sketchi docs.`,pj=uo("generate",{prompt:lE(oA("flag","prompt").pipe(lI("Diagram request text sent directly without interactive prompts."),l$("TEXT"))),type:lE(lk("type",["flowchart","mindmap","sequence","er","architecture","swimlane","state-machine"]).pipe(lI("Authoritative type; unsupported native requests fail clearly; omit for model selection."),l$("TYPE"))),model:oA("flag","model").pipe(oz(aL),lI(`Server-routed generation model id; default ${aL}.`),l$("MODEL")),endpoint:oA("flag","endpoint").pipe(oz(process.env[aW]?.trim()||az),lI("Unauthenticated generate API URL; defaults to the production Sketchi endpoint."),l$("URL")),format:lE(lk("format",["png","excalidraw","scene"]).pipe(lI("Artifact exported after generation; default png."),l$("png|excalidraw|scene"))),destination:lE(oA("flag","dest").pipe(lI("Artifact destination; defaults from the generated id, or - for stdout."),l$("PATH|-")))},e=>L.JkU(function*(){let{output:t}=yield*pS,r=et.getOrUndefined(e.prompt),n=et.getOrUndefined(e.type),i=et.getOrUndefined(e.format),a=et.getOrUndefined(e.destination);if(void 0===r){if(!function({stdinIsTTY:e,stdoutIsTTY:t,output:r,continuousIntegration:n}){return e&&t&&"text"===r&&!n}({stdinIsTTY:!0===process.stdin.isTTY,stdoutIsTTY:!0===process.stdout.isTTY,output:t,continuousIntegration:sK()}))return yield*new oo({option:"prompt"});if(void 0!==i&&"png"!==i)return yield*f6("format",i,"png when --prompt is omitted; pass --prompt for excalidraw or scene generation");if("-"===a)return yield*f6("dest",a,"a file path when --prompt is omitted; pass --prompt to write an artifact to stdout");if(void 0!==n&&"flowchart"!==n&&"mindmap"!==n&&"sequence"!==n)return yield*f6("type",n,"flowchart, mindmap, or sequence in the interactive wizard; pass --prompt to receive the typed unsupported-type error");let r=yield*sQ;return void(yield*pP(t,L.P1j(L.JkU(function*(){let t=yield*r.ask({...void 0===n?{}:{type:n},...void 0===a?{}:{destination:{_tag:"Custom",path:a}}}),i=yield*r.activity,s=yield*a5({endpoint:e.endpoint,model:e.model,prompt:t.prompt,type:t.type,format:"png",destination:function(e){switch(e._tag){case"CurrentDirectory":return{_tag:"CurrentDirectory",cwd:process.cwd()};case"ProjectDiagrams":return{_tag:"ProjectDiagrams",cwd:process.cwd()};case"Custom":return e}}(t.destination)});return yield*i.succeed("Diagram ready"),{...s,interactive:!0}}))))}yield*pP(t,a5({endpoint:e.endpoint,model:e.model,prompt:r,...n?{type:n}:{},format:i??"png",destination:void 0===a?{_tag:"Default"}:{_tag:"Custom",path:a}}).pipe(L.TjK(e=>({...e,interactive:!1}))))})).pipe(uc(pR),uu("Create a PNG with the wizard or a direct --prompt."),uf([{command:'sketchi generate --prompt "Map release approval with pass and revise branches"',description:`Generate a flowchart with ${aL} and write its PNG.`},{command:'sketchi generate --prompt "Organize launch readiness" --type mindmap --format excalidraw --dest launch.excalidraw --output json',description:"Generate a mindmap and write editable Excalidraw."},{command:'sketchi generate --prompt "Show Browser calling API" --type sequence --dest request-sequence.png',description:"Generate a native sequence diagram and write its PNG."}])),pD=`Build a complete Universal CanvasSpec through Sketchi's public create-canvas API, preserve the validated scene and Excalidraw result in the local store, and export PNG by default. This command is direct and noninteractive: pass exactly one CanvasSpec with --file PATH, --file - for piped stdin, or --json VALUE.
198
+ canonical JSON examples, and full error contracts, run sketchi docs.`,pD=uu("generate",{prompt:lC(oN("flag","prompt").pipe(lE("Diagram request text sent directly without interactive prompts."),lO("TEXT"))),type:lC(lI("type",["flowchart","mindmap","sequence","er","architecture","swimlane","state-machine"]).pipe(lE("Authoritative type; unsupported native requests fail clearly; omit for model selection."),lO("TYPE"))),model:oN("flag","model").pipe(oz(aL),lE(`Server-routed generation model id; default ${aL}.`),lO("MODEL")),endpoint:oN("flag","endpoint").pipe(oz(process.env[aW]?.trim()||az),lE("Unauthenticated generate API URL; defaults to the production Sketchi endpoint."),lO("URL")),format:lC(lI("format",["png","excalidraw","scene"]).pipe(lE("Artifact exported after generation; default png."),lO("png|excalidraw|scene"))),destination:lC(oN("flag","dest").pipe(lE("Artifact destination; defaults from the generated id, or - for stdout."),lO("PATH|-")))},e=>B.JkU(function*(){let{output:t}=yield*pk,r=ee.getOrUndefined(e.prompt),n=ee.getOrUndefined(e.type),i=ee.getOrUndefined(e.format),a=ee.getOrUndefined(e.destination);if(void 0===r){if(!function({stdinIsTTY:e,stdoutIsTTY:t,output:r,continuousIntegration:n}){return e&&t&&"text"===r&&!n}({stdinIsTTY:!0===process.stdin.isTTY,stdoutIsTTY:!0===process.stdout.isTTY,output:t,continuousIntegration:sK()}))return yield*new oo({option:"prompt"});if(void 0!==i&&"png"!==i)return yield*f5("format",i,"png when --prompt is omitted; pass --prompt for excalidraw or scene generation");if("-"===a)return yield*f5("dest",a,"a file path when --prompt is omitted; pass --prompt to write an artifact to stdout");if(void 0!==n&&"flowchart"!==n&&"mindmap"!==n&&"sequence"!==n)return yield*f5("type",n,"flowchart, mindmap, or sequence in the interactive wizard; pass --prompt to receive the typed unsupported-type error");let r=yield*sQ;return void(yield*pN(t,B.P1j(B.JkU(function*(){let t=yield*r.ask({...void 0===n?{}:{type:n},...void 0===a?{}:{destination:{_tag:"Custom",path:a}}}),i=yield*r.activity,s=yield*a5({endpoint:e.endpoint,model:e.model,prompt:t.prompt,type:t.type,format:"png",destination:function(e){switch(e._tag){case"CurrentDirectory":return{_tag:"CurrentDirectory",cwd:process.cwd()};case"ProjectDiagrams":return{_tag:"ProjectDiagrams",cwd:process.cwd()};case"Custom":return e}}(t.destination)});return yield*i.succeed("Diagram ready"),{...s,interactive:!0}}))))}yield*pN(t,a5({endpoint:e.endpoint,model:e.model,prompt:r,...n?{type:n}:{},format:i??"png",destination:void 0===a?{_tag:"Default"}:{_tag:"Custom",path:a}}).pipe(B.TjK(e=>({...e,interactive:!1}))))})).pipe(uh(pj),um("Create a PNG with the wizard or a direct --prompt."),ug([{command:'sketchi generate --prompt "Map release approval with pass and revise branches"',description:`Generate a flowchart with ${aL} and write its PNG.`},{command:'sketchi generate --prompt "Organize launch readiness" --type mindmap --format excalidraw --dest launch.excalidraw --output json',description:"Generate a mindmap and write editable Excalidraw."},{command:'sketchi generate --prompt "Show Browser calling API" --type sequence --dest request-sequence.png',description:"Generate a native sequence diagram and write its PNG."}]));function pU(e){return{...pE(e.diagram),remoteArtifactId:e.artifactId,export:pH(e.artifact)}}function pF(e){let t=pK(e.artifact);return[pT("created",e.diagram).replace(/^created:/u,"canvas:"),`remote artifact: ${e.artifactId}`,`format: ${e.artifact.format}`,`destination: ${e.artifact.destination}`,`bytes: ${String(e.artifact.sizeBytes)}`,...t?[`hint: ${t}`]:[]].join("\n")}let pB=`Build a complete Universal CanvasSpec through Sketchi's public create-canvas API, preserve the validated scene and Excalidraw result in the local store, and export PNG by default. This command is direct and noninteractive: pass exactly one CanvasSpec with --file PATH, --file - for piped stdin, or --json VALUE.
199
199
 
200
200
  Network and options:
201
201
  Endpoint: ${ax}
@@ -210,33 +210,33 @@ Input and failures:
210
210
  Input must be the CanvasSpec object itself, not a create-canvas request wrapper and not raw
211
211
  Excalidraw JSON. Interactive stdin is rejected with exit 2. Invalid JSON or CanvasSpec exits 3;
212
212
  a typed server rejection exits 4; network/endpoint failure exits 10; a request timeout after
213
- ${ab} exits 11 (canvas_timeout); malformed response exits 12.
213
+ ${av} exits 11 (canvas_timeout); malformed response exits 12.
214
214
  The local record is committed before export, so a destination failure reports a concrete
215
215
  sketchi export recovery command. The existing sketchi create command remains the strictly
216
- offline path for accepted flowchart, mindmap, and sequence documents.`,pU=uo("canvas",{...f3("CanvasSpec document"),endpoint:oA("flag","endpoint").pipe(oz(process.env[aw]?.trim()||ax),lI("Unauthenticated create-canvas API URL; defaults to production."),l$("URL")),format:lk("format",["png","excalidraw","scene"]).pipe(oz("png"),lI("Artifact exported after the canvas is created."),l$("png|excalidraw|scene")),destination:lE(oA("flag","dest").pipe(lI("Artifact destination; defaults from diagramId, or - for stdout."),l$("PATH|-")))},({destination:e,endpoint:t,format:r,source:n})=>L.JkU(function*(){let{output:i}=yield*pS,a=L.JkU(function*(){let i=yield*aO(n),a=yield*aA({endpoint:t,spec:i}),s=yield*a1(a.diagram,r,et.match(e,{onNone:()=>({_tag:"Default"}),onSome:e=>({_tag:"Custom",path:e})}));return{...a,artifact:s}});yield*a.pipe(L.tvg({onFailure:e=>pr("canvas",i,e),onSuccess:e=>L.JkU(function*(){let t,r=yield*f9;e.artifact.stdoutBytes&&(yield*r.stdout(e.artifact.stdoutBytes)),yield*pn("canvas",i,{...pO(e.diagram),remoteArtifactId:e.artifactId,export:pq(e.artifact)},(t=pG(e.artifact),[pM("created",e.diagram).replace(/^created:/u,"canvas:"),`remote artifact: ${e.artifactId}`,`format: ${e.artifact.format}`,`destination: ${e.artifact.destination}`,`bytes: ${String(e.artifact.sizeBytes)}`,...t?[`hint: ${t}`]:[]].join("\n")),"-"===e.artifact.destination?"stderr":"stdout")})}))})).pipe(uc(pD),uu("Build and export a typed Universal CanvasSpec."),uf([{command:"sketchi canvas --file canvas.json --output json",description:"Build a CanvasSpec, store it locally, and write its PNG."},{command:"sketchi canvas --file - --format excalidraw --dest canvas.excalidraw",description:"Read CanvasSpec from stdin and export editable Excalidraw."}])),pF=uo("create",f3(),({source:e})=>L.JkU(function*(){let{output:t}=yield*pS,r=yield*n6,n=yield*i8,i=L.JkU(function*(){let t=yield*i_(e),i=yield*r.build(t);return yield*n.create(i)});yield*pi("create",t,i,e=>pM("created",e),pO)})).pipe(uc("Create one local diagram from exactly one canonical document source. The document is validated and built before the record directory is committed atomically. --file - rejects an interactive TTY with exit 2."),uu("Create a local diagram from canonical JSON."),uf([{command:"sketchi create --file diagram.json",description:"Create from a UTF-8 JSON file."},{command:"printf '%s' '{...}' | sketchi create --file - --output json",description:"Create from noninteractive stdin with a JSON result."}])),pB=uo("show",{diagramId:oA(oC,"diagram-id")},({diagramId:e})=>L.JkU(function*(){let{output:t}=yield*pS,r=yield*i8,n=n3(e).pipe(L.qIB(e=>r.show(e)));yield*pi("show",t,n,pA,pO)})).pipe(uc("Show current authority, documentAuthoritative state, retained document provenance, manifest formats, and recoverable revision paths for DIAGRAM_ID. This is strictly offline and does not rebuild or mutate the record."),uu("Inspect one local diagram."),uf([{command:"sketchi show release-flow --output json",description:"Read a record as a stable JSON envelope."}])),pL=uo("edit",{diagramId:oA(oC,"diagram-id"),...f3()},({diagramId:e,source:t})=>L.JkU(function*(){let{output:r}=yield*pS,n=yield*n6,i=yield*i8,a=L.JkU(function*(){let r=yield*n3(e),a=yield*i_(t),s=yield*n.build(a);return s.id!==r?yield*nj.make({message:`Edited document id "${s.id}" does not match "${r}".`,hint:"Keep spec.id equal to the diagram id being edited.",details:["spec.id"]}):yield*i.edit(r,s)});yield*pi("edit",r,a,e=>pM("edited",e),pO)})).pipe(uc("Replace the complete canonical document for DIAGRAM_ID. Sketchi validates and builds first, preserves the prior full authority state under revisions/, and atomically swaps the record. Patched and detached records refuse edit because their canonical document is no longer authoritative. The new spec.id must match DIAGRAM_ID."),uu("Replace a canonical diagram document."),uf([{command:"sketchi edit release-flow --file revised.json",description:"Replace a document and retain the prior revision."}])),pz=uo("patch",{diagramId:oA(oC,"diagram-id"),...f3("patch request")},({diagramId:e,source:t})=>L.JkU(function*(){let{output:r}=yield*pS,n=yield*ic,i=yield*i8,a=L.JkU(function*(){let r=yield*n3(e),a=yield*ix(t),s=yield*i.readPatchSource(r),o=yield*n.patch(s.scene,a,`cli-patch-${r}-${String(s.revision+1)}`);return yield*i.commitPatch(r,s.revision,o)});yield*pi("patch",r,a,e=>pM("patched",e),pO)})).pipe(uc("Apply Sketchi semantic setStyle, setDefaultStyle, setShape, translate, replaceText, or rerouteEdges operations to the current stored scene. The CLI owns source and requestId; input contains operations plus optional options or intent. The prior full revision is recoverable, document.json remains unchanged provenance, stale stored PNG is removed, and the patched scene becomes authoritative. This command is strictly offline. Edit remains blocked until a canonical revision is restored."),uu("Apply semantic edits to a stored diagram."),uf([{command:'sketchi patch release-flow --json \'{"operations":[{"op":"setStyle","selector":{"nodeIds":["review","approve"]},"style":{"fillColor":"#dbeafe","strokeColor":"#2563eb","textColor":"#1e3a8a"}}]}\'',description:"Color selected nodes through semantic ids."},{command:"sketchi patch release-flow --file patch.json --output json",description:"Patch from a file, then export or restore the reported diagram revision."}])),pW=uo("list",{},()=>L.JkU(function*(){let{output:e}=yield*pS,t=yield*i8;yield*pi("list",e,t.list(),pN)})).pipe(uc("List local diagrams in ascending id order with type, revision, authority, documentAuthoritative, current stored formats, and retained title provenance. The command is deterministic, strictly offline, and read-only."),uu("List local diagrams."),uf([{command:"sketchi list --output json",description:"List records as a stable JSON envelope."}])),pJ=uo("share",{diagramId:oA(oC,"diagram-id"),open:lw("open").pipe(lI("Hand the bearer link to the default OS browser opener."))},({diagramId:e,open:t})=>L.JkU(function*(){let{output:r}=yield*pS,n=yield*i8,i=yield*py,a=yield*ph,s=L.JkU(function*(){let r=yield*n3(e),s=yield*n.readExportSource(r,"excalidraw");if("StoredArtifact"!==s._tag)return yield*nz.make({code:"unsupported_scene",message:`Diagram "${r}" has no authoritative Excalidraw artifact.`,hint:"Restore or rebuild the diagram before sharing it.",details:[]});let o=yield*L.SvU({try:()=>JSON.parse(new TextDecoder().decode(s.bytes)),catch:pC}),l=yield*i.share(o),d=t?yield*a.open(l.link):{status:"not_requested"};return{id:r,link:l.link,open:d,hint:"this immutable link is a bearer snapshot: anyone with the full URL can decrypt it, so share it only with the intended user. Browser edits do not update this link; after editing, choose Save to… → Export to Link and return the new link for sketchi pull."}});yield*s.pipe(L.tvg({onFailure:e=>pr("share",r,e),onSuccess:e=>L.JkU(function*(){if(yield*pn("share",r,e,`shared: ${e.id}
216
+ offline path for accepted flowchart, mindmap, and sequence documents.`,pL=uu("canvas",{...f1("CanvasSpec document"),endpoint:oN("flag","endpoint").pipe(oz(process.env[aw]?.trim()||ax),lE("Unauthenticated create-canvas API URL; defaults to production."),lO("URL")),format:lI("format",["png","excalidraw","scene"]).pipe(oz("png"),lE("Artifact exported after the canvas is created."),lO("png|excalidraw|scene")),destination:lC(oN("flag","dest").pipe(lE("Artifact destination; defaults from diagramId, or - for stdout."),lO("PATH|-")))},({destination:e,endpoint:t,format:r,fileInput:n,jsonInput:i})=>B.JkU(function*(){let{output:a}=yield*pk,s=yield*f2({fileInput:n,jsonInput:i}),o=B.JkU(function*(){let n=yield*aO(s),i=yield*aN({endpoint:t,spec:n}),a=yield*a1(i.diagram,r,ee.match(e,{onNone:()=>({_tag:"Default"}),onSome:e=>({_tag:"Custom",path:e})}));return{...i,artifact:a}});yield*pn("canvas",a,o,e=>e.artifact,pF,pU,e=>"-"===e.artifact.destination?"stderr":"stdout")})).pipe(uh(pB),um("Build and export a typed Universal CanvasSpec."),ug([{command:"sketchi canvas --file canvas.json --output json",description:"Build a CanvasSpec, store it locally, and write its PNG."},{command:"sketchi canvas --file - --format excalidraw --dest canvas.excalidraw",description:"Read CanvasSpec from stdin and export editable Excalidraw."}])),pz=uu("create",f1(),({fileInput:e,jsonInput:t})=>B.JkU(function*(){let{output:r}=yield*pk,n=yield*f2({fileInput:e,jsonInput:t}),i=yield*n4,a=yield*i6,s=B.JkU(function*(){let e=yield*iy(n),t=yield*i.build(e);return yield*a.create(t)});yield*pr("create",r,s,e=>pT("created",e),pE)})).pipe(uh("Create one local diagram from exactly one canonical document source. The document is validated and built before the record directory is committed atomically. --file - rejects an interactive TTY with exit 2."),um("Create a local diagram from canonical JSON."),ug([{command:"sketchi create --file diagram.json",description:"Create from a UTF-8 JSON file."},{command:"printf '%s' '{...}' | sketchi create --file - --output json",description:"Create from noninteractive stdin with a JSON result."}])),pW=uu("show",{diagramId:oN(oC,"diagram-id")},({diagramId:e})=>B.JkU(function*(){let{output:t}=yield*pk,r=yield*i6,n=n9(e).pipe(B.qIB(e=>r.show(e)));yield*pr("show",t,n,pP,pE)})).pipe(uh("Show current authority, documentAuthoritative state, retained document provenance, manifest formats, and recoverable revision paths for DIAGRAM_ID. This is strictly offline and does not rebuild or mutate the record."),um("Inspect one local diagram."),ug([{command:"sketchi show release-flow --output json",description:"Read a record as a stable JSON envelope."}])),pJ=uu("edit",{diagramId:oN(oC,"diagram-id"),...f1()},({diagramId:e,fileInput:t,jsonInput:r})=>B.JkU(function*(){let{output:n}=yield*pk,i=yield*f2({fileInput:t,jsonInput:r}),a=yield*n4,s=yield*i6,o=B.JkU(function*(){let t=yield*n9(e),r=yield*iy(i),n=yield*a.build(r);return n.id!==t?yield*nP.make({message:`Edited document id "${n.id}" does not match "${t}".`,hint:"Keep spec.id equal to the diagram id being edited.",details:["spec.id"]}):yield*s.edit(t,n)});yield*pr("edit",n,o,e=>pT("edited",e),pE)})).pipe(uh("Replace the complete canonical document for DIAGRAM_ID. Sketchi validates and builds first, preserves the prior full authority state under revisions/, and atomically swaps the record. Patched and detached records refuse edit because their canonical document is no longer authoritative. The new spec.id must match DIAGRAM_ID."),um("Replace a canonical diagram document."),ug([{command:"sketchi edit release-flow --file revised.json",description:"Replace a document and retain the prior revision."}])),pY=uu("patch",{diagramId:oN(oC,"diagram-id"),...f1("patch request")},({diagramId:e,fileInput:t,jsonInput:r})=>B.JkU(function*(){let{output:n}=yield*pk,i=yield*f2({fileInput:t,jsonInput:r}),a=yield*iu,s=yield*i6,o=B.JkU(function*(){let t=yield*n9(e),r=yield*iv(i),n=yield*s.readPatchSource(t),o=yield*a.patch(n.scene,r,`cli-patch-${t}-${String(n.revision+1)}`);return yield*s.commitPatch(t,n.revision,o)});yield*pr("patch",n,o,e=>pT("patched",e),pE)})).pipe(uh("Apply Sketchi semantic setStyle, setDefaultStyle, setShape, translate, replaceText, or rerouteEdges operations to the current stored scene. The CLI owns source and requestId; input contains operations plus optional options or intent. The prior full revision is recoverable, document.json remains unchanged provenance, stale stored PNG is removed, and the patched scene becomes authoritative. This command is strictly offline. Edit remains blocked until a canonical revision is restored."),um("Apply semantic edits to a stored diagram."),ug([{command:'sketchi patch release-flow --json \'{"operations":[{"op":"setStyle","selector":{"nodeIds":["review","approve"]},"style":{"fillColor":"#dbeafe","strokeColor":"#2563eb","textColor":"#1e3a8a"}}]}\'',description:"Color selected nodes through semantic ids."},{command:"sketchi patch release-flow --file patch.json --output json",description:"Patch from a file, then export or restore the reported diagram revision."}])),pX=uu("list",{},()=>B.JkU(function*(){let{output:e}=yield*pk,t=yield*i6;yield*pr("list",e,t.list(),pR)})).pipe(uh("List local diagrams in ascending id order with type, revision, authority, documentAuthoritative, current stored formats, and retained title provenance. The command is deterministic, strictly offline, and read-only."),um("List local diagrams."),ug([{command:"sketchi list --output json",description:"List records as a stable JSON envelope."}])),pq=uu("share",{diagramId:oN(oC,"diagram-id"),open:lS("open").pipe(lE("Hand the bearer link to the default OS browser opener."))},({diagramId:e,open:t})=>B.JkU(function*(){let{output:r}=yield*pk,n=yield*i6,i=yield*pg,a=yield*pp,s=B.JkU(function*(){let r=yield*n9(e),s=yield*n.readExportSource(r,"excalidraw");if("StoredArtifact"!==s._tag)return yield*nB.make({code:"unsupported_scene",message:`Diagram "${r}" has no authoritative Excalidraw artifact.`,hint:"Restore or rebuild the diagram before sharing it.",details:[]});let o=yield*B.SvU({try:()=>JSON.parse(new TextDecoder().decode(s.bytes)),catch:pO}),l=yield*i.share(o),d=t?yield*a.open(l.link):{status:"not_requested"};return{id:r,link:l.link,open:d,hint:"this immutable link is a bearer snapshot: anyone with the full URL can decrypt it, so share it only with the intended user. Browser edits do not update this link; after editing, choose Save to… → Export to Link and return the new link for sketchi pull."}});yield*s.pipe(B.tvg({onFailure:e=>pe("share",r,e),onSuccess:e=>B.JkU(function*(){if(yield*pt("share",r,e,`shared: ${e.id}
217
217
  link: ${e.link}
218
218
  open: ${e.open.status}
219
- hint: ${e.hint}`),"text"===r&&"unconfirmed"===e.open.status){let e=yield*f9;yield*e.stderr("notice: the OS browser opener could not be confirmed; the share link is still valid.\n")}})}))})).pipe(uc(`Encrypt and upload the current authoritative Excalidraw artifact as one immutable excalidraw.com bearer snapshot. This makes exactly one credential-free HTTPS request. The storage service can observe connection metadata, timing, and ciphertext size; retention is uncontrolled, and Sketchi cannot revoke or delete a link. Anyone with the full URL can decrypt it. Supported elements: rectangle, ellipse, diamond, arrow, line, freedraw, text; text must use Excalifont fontFamily 5; files and images are rejected. Render limits: element dimension ${String(8192)}, canvas dimension ${String(8192)}, canvas area ${String(iR.Z4)}, final PNG pixels ${String(iR.ce)}. --open is opt-in and only confirms whether the OS accepted the request.`),uu("Share an encrypted Excalidraw snapshot.")),pY=uo("pull",{diagramId:oA(oC,"diagram-id"),link:(j="URL|-",D="Excalidraw bearer share URL, or - for noninteractive stdin.",Object.assign(Object.create(Object.getPrototypeOf(N=oA("flag",R="link").pipe(l$(j),lI(D)))),N,{parse:e=>(e.flags[R]?.length??0)===1?N.parse(e):L.fJG(new oc({option:R,value:(e.flags[R]?.length??0)===0?"not provided":"provided more than once",expected:`exactly one --${R} ${j}`,kind:"flag"}))}))},({diagramId:e,link:t})=>L.JkU(function*(){let{output:r}=yield*pS,n=L.JkU(function*(){let r=yield*p_(e),n=yield*pT(t);return yield*px(e,n,r)});yield*pi("pull",r,n,({diagram:e})=>`pulled: ${e.manifest.id}
219
+ hint: ${e.hint}`),"text"===r&&"unconfirmed"===e.open.status){let e=yield*f6;yield*e.stderr("notice: the OS browser opener could not be confirmed; the share link is still valid.\n")}})}))})).pipe(uh(`Encrypt and upload the current authoritative Excalidraw artifact as one immutable excalidraw.com bearer snapshot. This makes exactly one credential-free HTTPS request. The storage service can observe connection metadata, timing, and ciphertext size; retention is uncontrolled, and Sketchi cannot revoke or delete a link. Anyone with the full URL can decrypt it. Supported elements: rectangle, ellipse, diamond, arrow, line, freedraw, text; text must use Excalifont fontFamily 5; files and images are rejected. Render limits: element dimension ${String(8192)}, canvas dimension ${String(8192)}, canvas area ${String(iA.Z4)}, final PNG pixels ${String(iA.ce)}. --open is opt-in and only confirms whether the OS accepted the request.`),um("Share an encrypted Excalidraw snapshot.")),pG=uu("pull",{diagramId:oN(oC,"diagram-id"),link:(R="URL|-",j="Excalidraw bearer share URL, or - for noninteractive stdin.",oN("flag",P="link").pipe(lO(R),lE(j),lA(0),lM(e=>1===e.length?B.PyW(e[0]):B.fJG(f5(P,0===e.length?"not provided":"provided more than once",`exactly one --${P} ${R}`)))))},({diagramId:e,link:t})=>B.JkU(function*(){let{output:r}=yield*pk,n=B.JkU(function*(){let r=yield*pb(e),n=yield*pC(t);return yield*p_(e,n,r)});yield*pr("pull",r,n,({diagram:e})=>`pulled: ${e.manifest.id}
220
220
  revision: ${String(e.manifest.revision)}
221
221
  authority: ${e.authority}
222
- source identity: unverified`,({diagram:e,sourceIdentity:t})=>({id:e.manifest.id,revision:e.manifest.revision,authority:e.authority,documentAuthoritative:e.documentAuthoritative,formats:e.manifest.formats,revisions:pE(e),sourceIdentity:t}))})).pipe(uc(`Fetch exactly one current-format excalidraw.com bearer snapshot, decrypt it locally, restore and strictly validate it, prove detached PNG renderability, then atomically preserve the prior full record and replace diagram.excalidraw as detached authority. The link carries no trusted Sketchi identity and may be unrelated to DIAGRAM_ID. This makes exactly one credential-free HTTPS request and never echoes or stores the input link or key. Supported elements: rectangle, ellipse, diamond, arrow, line, freedraw, text; text must use Excalifont fontFamily 5; files, images, external resources, and other fonts are rejected. Render limits: element dimension ${String(8192)}, canvas dimension ${String(8192)}, canvas area ${String(iR.Z4)}, final PNG pixels ${String(iR.ce)}.`),uu("Pull browser edits from an Excalidraw link.")),pX=uo("restore",{diagramId:oA(oC,"diagram-id"),revision:oP({name:"revision",primitiveType:ok,kind:"flag"}).pipe(lC(e=>e>0,e=>`Expected a positive revision, got ${String(e)}`),l$("N"),lI("Archived revision number to restore without consuming it."))},({diagramId:e,revision:t})=>L.JkU(function*(){let{output:r}=yield*pS,n=yield*i8,i=yield*n6,a=L.JkU(function*(){let r=yield*n3(e),a=yield*n.readRevision(r,t);return"LegacyDocument"===a._tag?yield*i.build(a.document).pipe(L.qIB(e=>n.restore(r,t,e))):yield*n.restore(r,t)});yield*pi("restore",r,a,e=>`restored: ${e.diagram.manifest.id}
222
+ source identity: unverified`,({diagram:e,sourceIdentity:t})=>({id:e.manifest.id,revision:e.manifest.revision,authority:e.authority,documentAuthoritative:"canonical"===e.authority,formats:e.manifest.formats,revisions:p$(e),sourceIdentity:t}))})).pipe(uh(`Fetch exactly one current-format excalidraw.com bearer snapshot, decrypt it locally, restore and strictly validate it, prove detached PNG renderability, then atomically preserve the prior full record and replace diagram.excalidraw as detached authority. The link carries no trusted Sketchi identity and may be unrelated to DIAGRAM_ID. This makes exactly one credential-free HTTPS request and never echoes or stores the input link or key. Supported elements: rectangle, ellipse, diamond, arrow, line, freedraw, text; text must use Excalifont fontFamily 5; files, images, external resources, and other fonts are rejected. Render limits: element dimension ${String(8192)}, canvas dimension ${String(8192)}, canvas area ${String(iA.Z4)}, final PNG pixels ${String(iA.ce)}.`),um("Pull browser edits from an Excalidraw link.")),pV=uu("restore",{diagramId:oN(oC,"diagram-id"),revision:oA({name:"revision",primitiveType:ok,kind:"flag"}).pipe(lN(e=>e>0,e=>`Expected a positive revision, got ${String(e)}`),lO("N"),lE("Archived revision number to restore without consuming it."))},({diagramId:e,revision:t})=>B.JkU(function*(){let{output:r}=yield*pk,n=yield*i6,i=yield*n4,a=B.JkU(function*(){let r=yield*n9(e),a=yield*n.readRevision(r,t);return"LegacyDocument"===a._tag?yield*i.build(a.document).pipe(B.qIB(e=>n.restore(r,t,e))):yield*n.restore(r,t)});yield*pr("restore",r,a,e=>`restored: ${e.diagram.manifest.id}
223
223
  from revision: ${String(e.restoredFromRevision)}
224
224
  revision: ${String(e.diagram.manifest.revision)}
225
- authority: ${e.diagram.authority}`,e=>({id:e.diagram.manifest.id,restoredFromRevision:e.restoredFromRevision,revision:e.diagram.manifest.revision,authority:e.diagram.authority,documentAuthoritative:e.diagram.documentAuthoritative,formats:e.diagram.manifest.formats,revisions:pE(e.diagram)}))})).pipe(uc("Strictly offline recovery. Archive the current full state first, then restore revision N byte-for-byte without consuming it and commit at the next monotonic revision. Full snapshots restore artifacts and authority without rebuilding; legacy document-only revisions rebuild only while the record remains canonical."),uu("Restore a retained diagram revision."));function pq(e){let t=pG(e);return{id:e.id,format:e.format,destination:e.destination,sizeBytes:e.sizeBytes,...t?{hint:t}:{}}}function pG(e){let t=[...e.destination].map(e=>{let t=e.codePointAt(0)??0;return t<32||t>=128&&t<=159||127===t||8232===t||8233===t||"%<>#?\\".includes(e)?encodeURIComponent(e):e}).join("");return"png"===e.format&&"-"!==e.destination?`to show this diagram to the user, display the exported file as an inline markdown image, e.g. ![${e.id}](<${t}>)`:void 0}let pV=uo("export",{diagramId:oA(oC,"diagram-id"),format:lk("format",["scene","excalidraw","png"]).pipe(lI("Artifact format to export or render on demand."),l$("scene|excalidraw|png")),destination:oA("flag","dest").pipe(lI("Artifact byte destination path, or - for stdout."),l$("PATH|-"))},({destination:e,diagramId:t,format:r})=>L.JkU(function*(){let{output:n}=yield*pS,i=yield*aD,a=L.JkU(function*(){let n=yield*n3(t),a=yield*i.exportArtifact(n,r);return"-"!==e&&(yield*ay(e,a)),{id:n,format:r,destination:e,sizeBytes:a.byteLength,..."-"===e?{stdoutBytes:a}:{}}});yield*a.pipe(L.tvg({onFailure:e=>pr("export",n,e),onSuccess:e=>L.JkU(function*(){let t=yield*f9;e.stdoutBytes&&(yield*t.stdout(e.stdoutBytes));let r=pq(e),i=pG(e),a=[`exported: ${e.id}`,`format: ${e.format}`,`destination: ${e.destination}`,`bytes: ${String(e.sizeBytes)}`,...i?[`hint: ${i}`]:[]].join("\n");yield*pn("export",n,r,a,"stderr")})}))})).pipe(uc("Strictly offline export of a current stored artifact or on-demand PNG. Canonical PNG uses scene plus Excalidraw; detached PNG restores diagram.excalidraw directly, uses its viewBackgroundColor, and adds no stale canonical title. Detached scene export is unavailable. Rendering never starts a browser or network request and never writes the PNG back. Status always uses stderr, so --dest - leaves stdout byte-only. Render or write failures exit 8."),uu("Export scene, Excalidraw, or PNG bytes."),uf([{command:"sketchi export release-flow --format excalidraw --dest release.excalidraw",description:"Write an Excalidraw artifact atomically to a file."},{command:"sketchi export release-flow --format scene --dest - > scene.json",description:"Pipe raw scene bytes without status contamination."}])),pH=pS.pipe(ul([pj,pU,pI,pF,pB,pL,pz,pW,pX,pJ,pY,pV])),pK=L.fn("sketchi.cli.run")(function*(e){let t,r,n,i,a,s,o,l,d,c=f8(e);return yield*(t=o3({colors:!1}),r=e.some(e=>"--help"===e||"-h"===e||"--version"===e||"-v"===e),n="json"===f8(e),i=e.find(e=>f1.has(e)),a=e.every((t,r)=>"--output"===t||"--output=text"===t||"--output=json"===t||"--output"===e[r-1]&&("text"===t||"json"===t)),s=void 0===i&&(0===e.length||r||a),o=i??"sketchi",l={...t,formatHelpDoc:e=>{let i=t.formatHelpDoc(e).replace(/[ \t]+$/gmu,"");return n&&s?`${JSON.stringify({ok:!0,command:"sketchi",data:{help:fH({colors:"none",background:"dark"})}},null,2)}
226
- `:n&&!r?"":s?function(){let e,t,r=void 0===process.stdout.columns||process.stdout.columns<=0?80:process.stdout.columns,n=function(e=process.env){if("dumb"===e.TERM||"linux"===e.TERM)return!1;let t=[e.LC_ALL,e.LC_CTYPE,e.LANG].find(e=>void 0!==e&&e.length>0);return void 0!==t&&/(?:^|[._-])utf-?8(?:@|$)/iu.test(t)}();if(void 0!==process.env.NO_COLOR||"dumb"===process.env.TERM||"ansi"===process.env.TERM||!0!==process.stdout.isTTY)return fH({colors:"none",background:"dark",unicode:n,width:r});let i=process.stdout.hasColors(0x1000000)?"truecolor":process.stdout.hasColors(256)?"ansi256":"none";if("none"===i)return fH({colors:"none",background:"dark",unicode:n,width:r});let a=(e=process.env.COLORFGBG,(t=e?.split(";").at(-1))&&/^\d+$/u.test(t)?function(e,t){let r=fK(e);if(void 0===r)return{background:"dark",readable:!1};let n=f0(r,"dark",t),i=f0(r,"light",t);return{background:n>=i?"dark":"light",readable:Math.max(n,i)>=4.5}}(Number(t),i):{background:"dark",readable:!0});return a.readable?fH({colors:i,background:a.background,unicode:n,width:r}):fH({colors:"none",background:a.background,unicode:n,width:r})}():i},formatErrors:e=>{let r=e.map(e=>t.formatCliError(e)).join("; "),a=`Run sketchi${i?` ${i}`:""} --help for usage.`;return um(n?`${JSON.stringify({ok:!1,command:o,error:{code:"usage_error",message:r,hint:a}},null,2)}
225
+ authority: ${e.diagram.authority}`,e=>({id:e.diagram.manifest.id,restoredFromRevision:e.restoredFromRevision,revision:e.diagram.manifest.revision,authority:e.diagram.authority,documentAuthoritative:"canonical"===e.diagram.authority,formats:e.diagram.manifest.formats,revisions:p$(e.diagram)}))})).pipe(uh("Strictly offline recovery. Archive the current full state first, then restore revision N byte-for-byte without consuming it and commit at the next monotonic revision. Full snapshots restore artifacts and authority without rebuilding; legacy document-only revisions rebuild only while the record remains canonical."),um("Restore a retained diagram revision."));function pH(e){let t=pK(e);return{id:e.id,format:e.format,destination:e.destination,sizeBytes:e.sizeBytes,...t?{hint:t}:{}}}function pK(e){let t=[...e.destination].map(e=>{let t=e.codePointAt(0)??0;return t<32||t>=128&&t<=159||127===t||8232===t||8233===t||"%<>#?\\".includes(e)?encodeURIComponent(e):e}).join("");return"png"===e.format&&"-"!==e.destination?`to show this diagram to the user, display the exported file as an inline markdown image, e.g. ![${e.id}](<${t}>)`:void 0}let pQ=uu("export",{diagramId:oN(oC,"diagram-id"),format:lI("format",["scene","excalidraw","png"]).pipe(lE("Artifact format to export or render on demand."),lO("scene|excalidraw|png")),destination:oN("flag","dest").pipe(lE("Artifact byte destination path, or - for stdout."),lO("PATH|-"))},({destination:e,diagramId:t,format:r})=>B.JkU(function*(){let{output:n}=yield*pk,i=yield*aD,a=B.JkU(function*(){let n=yield*n9(t),a=yield*i.exportArtifact(n,r);return"-"!==e&&(yield*ay(e,a)),{id:n,format:r,destination:e,sizeBytes:a.byteLength,..."-"===e?{stdoutBytes:a}:{}}});yield*pn("export",n,a,e=>e,e=>{let t=pK(e);return[`exported: ${e.id}`,`format: ${e.format}`,`destination: ${e.destination}`,`bytes: ${String(e.sizeBytes)}`,...t?[`hint: ${t}`]:[]].join("\n")},pH,()=>"stderr")})).pipe(uh("Strictly offline export of a current stored artifact or on-demand PNG. Canonical PNG uses scene plus Excalidraw; detached PNG restores diagram.excalidraw directly, uses its viewBackgroundColor, and adds no stale canonical title. Detached scene export is unavailable. Rendering never starts a browser or network request and never writes the PNG back. Status always uses stderr, so --dest - leaves stdout byte-only. Render or write failures exit 8."),um("Export scene, Excalidraw, or PNG bytes."),ug([{command:"sketchi export release-flow --format excalidraw --dest release.excalidraw",description:"Write an Excalidraw artifact atomically to a file."},{command:"sketchi export release-flow --format scene --dest - > scene.json",description:"Pipe raw scene bytes without status contamination."}])),pZ=pk.pipe(uf([pD,pL,pS,pz,pW,pJ,pY,pX,pV,pq,pG,pQ])),p0=B.fn("sketchi.cli.run")(function*(e){let t,r,n,i,a,s,o,l,d,c=f3(e);return yield*(t=o8({colors:!1}),r=e.some(e=>"--help"===e||"-h"===e||"--version"===e||"-v"===e),n="json"===f3(e),i=e.find(e=>f0.has(e)),a=e.every((t,r)=>"--output"===t||"--output=text"===t||"--output=json"===t||"--output"===e[r-1]&&("text"===t||"json"===t)),s=void 0===i&&(0===e.length||r||a),o=i??"sketchi",l={...t,formatHelpDoc:e=>{let i,a,o,l,d,c,u=t.formatHelpDoc(e).replace(/[ \t]+$/gmu,"");return n&&s?`${JSON.stringify({ok:!0,command:"sketchi",data:{help:fV({colors:"none",background:"dark"})}},null,2)}
226
+ `:n&&!r?"":s?(i=void 0===process.stdout.columns||process.stdout.columns<=0?80:process.stdout.columns,a=function(e=process.env){if("dumb"===e.TERM||"linux"===e.TERM)return!1;let t=[e.LC_ALL,e.LC_CTYPE,e.LANG].find(e=>void 0!==e&&e.length>0);return void 0!==t&&/(?:^|[._-])utf-?8(?:@|$)/iu.test(t)}(),fV({colors:(c="none"==(o=void 0!==process.env.NO_COLOR||"dumb"===process.env.TERM||"ansi"===process.env.TERM||!0!==process.stdout.isTTY?"none":process.stdout.hasColors(0x1000000)?"truecolor":process.stdout.hasColors(256)?"ansi256":"none")?{background:"dark",readable:!0}:(l=process.env.COLORFGBG,(d=l?.split(";").at(-1))&&/^\d+$/u.test(d)?function(e,t){let r=fH(e);if(void 0===r)return{background:"dark",readable:!1};let n=fZ(r,"dark",t),i=fZ(r,"light",t);return{background:n>=i?"dark":"light",readable:Math.max(n,i)>=4.5}}(Number(d),o):{background:"dark",readable:!0})).readable?o:"none",background:c.background,unicode:a,width:i})):u},formatErrors:e=>{let r=e.map(e=>t.formatCliError(e)).join("; "),a=`Run sketchi${i?` ${i}`:""} --help for usage.`;return ub(n?`${JSON.stringify({ok:!1,command:o,error:{code:"usage_error",message:r,hint:a}},null,2)}
227
227
  `:`error: usage_error
228
228
  ${r}
229
229
  next: ${a}
230
- `)}},d=new Proxy(globalThis.console,{get(e,t,r){if("log"===t)return(...t)=>{(1!==t.length||""!==t[0])&&e.log(...t)};let n=Reflect.get(e,t,r);return"function"==typeof n?n.bind(e):n}}),up(pH,{version:"0.6.1"})(e).pipe(L.sFT(e=>em.i5(e,oi)&&"ShowHelp"!==e._tag?or(l.formatErrors([e])):L.rIH),L.PfK(l4,{builtIns:[l2,l5,l6]}),L.PfK(o2,l),L.PfK(oe,d))).pipe(L.khu({onFailure:e=>L.JkU(function*(){let t,r=et.getOrUndefined(B.L$(e));if(r instanceof f4)return r.exitCode;if(r instanceof nN)return 7;let n=function(e){if(em.i5(e,oi))return"ShowHelp"===e._tag?2*(e.errors.length>0):2}(r);if(void 0!==n)return n;let i=yield*f9;return yield*i.stderr((t={code:"internal_error",message:"Sketchi could not complete the command.",hint:"Retry once; if it persists, report the command and inputs without secrets."},"json"===c?n2({ok:!1,command:"sketchi",error:t}):pt(t))).pipe(L.MfU(()=>L.rIH)),1}),onSuccess:()=>L.PyW(0)}))}),pQ=V.Um(nP.Tx,(0,nP.rR)({createId:e=>`${e}_offline_cli`})),pZ=V.Gt(ie,pQ),p0=V.Gt(ig,pQ),p1=V.Um(is,as),p2=V.Gt(ag,p1),p5=V.Gt(aB,V.Um(p2,aj)),p3=V.Gt(pb,pp),p6=V.Um(is,as,pZ,p0,p2,p5,aj,p3,pg,iv.pipe(V.Gt(is)),pe,s7),p8=V.S5(p6,nM);G(pK(process.argv.slice(2)).pipe(L.Mim(e=>L.OH5(()=>{process.exitCode=e})),L.Gte(p8)),{disableErrorReporting:!0})},1688(e,t,r){var n=r(2718);let i=n.xCb(["invalid_render_artifact","render_limit_exceeded","unsupported_render_glyph","rasterization_failed"]),a=n.xCb(["artifact","geometry","font","rasterization"]);class s extends n.rNF()("HeadlessPngRenderError",{cause:n.kld(),code:i,stage:a,message:n.QfV,details:n.O31(n.QfV)}){}r.d(t,{FG:()=>s})},5030(e,t,r){function n(e,t,r,n){return{code:e,message:t,...void 0===r?{}:{observed:r},...void 0===n?{}:{limit:n}}}function i(e,t=0){let r=1/0,a=1/0,s=-1/0,o=-1/0;for(let t of e){var l;if(!("object"==typeof(l=t)&&null!==l&&!Array.isArray(l)&&"number"==typeof t.x&&Number.isFinite(t.x)&&"number"==typeof t.y&&Number.isFinite(t.y)&&"number"==typeof t.width&&Number.isFinite(t.width)&&"number"==typeof t.height&&Number.isFinite(t.height)))return n("invalid_geometry","element geometry is invalid");let e=Math.abs(t.width),i=Math.abs(t.height);if(e>8192||i>8192)return n("element_dimension",`element dimension exceeds ${String(8192)}`,Math.max(e,i),8192);let d=Math.hypot(e,i)/2,c=t.x+t.width/2,u=t.y+t.height/2;r=Math.min(r,c-d),a=Math.min(a,u-d),s=Math.max(s,c+d),o=Math.max(o,u+d)}if(0===e.length)return;let d=s-r,c=o-a;if(d>8192||c>8192)return n("canvas_dimension",`canvas dimension exceeds ${String(8192)}`,Math.max(d,c),8192);let u=d*c;if(u>6291456)return n("canvas_area",`canvas area exceeds ${String(6291456)}`,u,6291456);let f=(d+40)*1*((c+40+t)*1);if(f>0x1800000)return n("output_pixels",`PNG output exceeds ${String(0x1800000)} pixels at minimum scale`,f,0x1800000)}function a(e,t=0){return i(e,t)?.message}function s(e,t){if(!Number.isFinite(e)||!Number.isFinite(t)||e<=0||t<=0)return n("invalid_geometry","rendered SVG dimensions are invalid");let r=Math.min(2,16384/e,16384/t,Math.sqrt(0x1800000/(e*t)));if(r<1){let r=e*t;return r>0x1800000?n("output_pixels",`PNG output exceeds ${String(0x1800000)} pixels at minimum scale`,r,0x1800000):n("output_dimension","rendered SVG dimension exceeds the PNG limit at minimum scale",Math.max(e,t),16384)}return Math.max(1,Math.floor(1e3*r)/1e3)}r.d(t,{Gd:()=>a,Ts:()=>i,Yu:()=>s},{Z4:6291456,ce:0x1800000})},6982(e){e.exports=t("crypto")},7598(e){e.exports=t("node:crypto")},76(e,t,r){let n=r(9095),i=process.env;function a(e){return"string"==typeof e?!!i[e]:"env"in e?i[e.env]&&i[e.env].includes(e.includes):"any"in e?e.any.some(function(e){return!!i[e]}):Object.keys(e).every(function(t){return i[t]===e[t]})}Object.defineProperty(t,"_vendors",{value:n.map(function(e){return e.constant})}),t.name=null,t.isPR=null,t.id=null,"false"!==i.CI&&n.forEach(function(e){let r=(Array.isArray(e.env)?e.env:[e.env]).every(function(e){return a(e)});t[e.constant]=r,r&&(t.name=e.name,t.isPR=function(e){switch(typeof e.pr){case"string":return!!i[e.pr];case"object":if("env"in e.pr)if("any"in e.pr)return e.pr.any.some(function(t){return i[e.pr.env]===t});else return e.pr.env in i&&i[e.pr.env]!==e.pr.ne;if("any"in e.pr)return e.pr.any.some(function(e){return!!i[e]});return a(e.pr);default:return null}}(e),t.id=e.constant)}),t.isCI=!!("false"!==i.CI&&(i.BUILD_ID||i.BUILD_NUMBER||i.CI||i.CI_APP_ID||i.CI_BUILD_ID||i.CI_BUILD_NUMBER||i.CI_NAME||i.CONTINUOUS_INTEGRATION||i.RUN_ID||t.name))},485(e,t,r){e.exports=r(76).isCI},664(e,t,r){r.d(t,{CN:()=>p,BC:()=>g,Ie:()=>I,pb:()=>O,i8:()=>w,g9:()=>x,Uk:()=>k,Ts:()=>h,CZ:()=>y,ET:()=>b,HV:()=>v,T9:()=>M,Tj:()=>E,YW:()=>m,of:()=>$,jB:()=>C,TS:()=>T,di:()=>S});var n=r(7876),i=r(1594);let a=e=>e.length>0;var s=r(9771),o=r(592),l=r(1587),d=r(2860),c=r(915),u=r(9315);let f=globalThis.Array,p=e=>new f(s.S(e)),h=e=>f.isArray(e)?e:f.from(e);c.Wo,l.toArray;let m=(0,i.XY)(2,(e,{onEmpty:t,onNonEmpty:r})=>b(e)?r(e):t()),g=(0,i.XY)(2,(e,t)=>[...e,t]);f.isArray;let y=a,b=a,v=e=>b(e)?l.some(_(e)):l.none(),_=e=>e[e.length-1],x=(0,i.XY)(2,(e,t)=>{let r=0;for(let n of e){if(t(n,r))return l.some(r);r++}return l.none()}),w=o.i8,k=(0,i.XY)(2,(e,t)=>{let r=h(e);for(let e=r.length-1;e>=0;e--){let n=r[e],i=t(n,e);if("boolean"==typeof i){if(i)return l.some(n)}else if(l.isSome(i))return i}return l.none()}),S=(0,i.XY)(2,(e,t)=>{let r=f.from(e);return r.sort(t),r}),I=()=>[],$=e=>[e],E=(0,i.XY)(2,(e,t)=>e.map(t)),O=(0,i.XY)(2,(e,t)=>{let r=h(e),n=[];for(let e=0;e<r.length;e++)t(r[e],e)&&n.push(r[e]);return n}),C=(0,i.XY)(2,(e,t)=>{let r=[],n=[],i=0;for(let a of e){let e=t(a,i++);u.oJ(e)?r.push(e.success):n.push(e.failure)}return[r,n]}),T=(0,i.XY)(3,(e,t,r)=>h(e).reduce((e,t,n)=>r(e,t,n),t));d.O3;let M=n.O3},5053(e,t,r){var n=r(9519),i=r(7876),a=r(1594),s=r(1587),o=r(2860),l=r(4233),d=r(636);let c=globalThis.BigInt,u=c(0);l.sI;let f=(0,a.XY)(2,(e,t)=>e+t),p=o.Qw,h=i.Qw,m=o.hl(p),g=o.bi(p),y=o.yJ(p),b=o.OW(p),v=o.Bt(p),_=o.qE(p),x=o.jk(p),w=o.T9(p),k=d.L((e,t)=>e+t,u),S=n.T9(p),I=n.jk(p);r.d(t,{},{K0:I,OW:b,Ro:e=>e>c(Number.MAX_SAFE_INTEGER)||e<c(Number.MIN_SAFE_INTEGER)?s.none():s.some(Number(e)),T9:w,Tq:v,aD:k,bi:g,cz:f,hl:m,jk:x,pH:p,qE:_,rs:h,sO:S,yJ:y})},3265(e,t,r){var n=r(5053),i=r(1587);let a=BigInt(0),s=BigInt(1),o=BigInt(1e3),l=BigInt(1024),d=[{symbol:"B",factor:s,names:["B","byte","bytes"]},{symbol:"kB",factor:o,names:["kB","kilobyte","kilobytes"]},{symbol:"MB",factor:o**BigInt(2),names:["MB","megabyte","megabytes"]},{symbol:"GB",factor:o**BigInt(3),names:["GB","gigabyte","gigabytes"]},{symbol:"TB",factor:o**BigInt(4),names:["TB","terabyte","terabytes"]},{symbol:"PB",factor:o**BigInt(5),names:["PB","petabyte","petabytes"]},{symbol:"EB",factor:o**BigInt(6),names:["EB","exabyte","exabytes"]},{symbol:"ZB",factor:o**BigInt(7),names:["ZB","zettabyte","zettabytes"]},{symbol:"YB",factor:o**BigInt(8),names:["YB","yottabyte","yottabytes"]},{symbol:"RB",factor:o**BigInt(9),names:["RB","ronnabyte","ronnabytes"]},{symbol:"QB",factor:o**BigInt(10),names:["QB","quettabyte","quettabytes"]}],c=[d[0],{symbol:"KiB",factor:l,names:["KiB","kibibyte","kibibytes"]},{symbol:"MiB",factor:l**BigInt(2),names:["MiB","mebibyte","mebibytes"]},{symbol:"GiB",factor:l**BigInt(3),names:["GiB","gibibyte","gibibytes"]},{symbol:"TiB",factor:l**BigInt(4),names:["TiB","tebibyte","tebibytes"]},{symbol:"PiB",factor:l**BigInt(5),names:["PiB","pebibyte","pebibytes"]},{symbol:"EiB",factor:l**BigInt(6),names:["EiB","exbibyte","exbibytes"]},{symbol:"ZiB",factor:l**BigInt(7),names:["ZiB","zebibyte","zebibytes"]},{symbol:"YiB",factor:l**BigInt(8),names:["YiB","yobibyte","yobibytes"]}],u=new Map([...d,...c.slice(1)].flatMap(e=>e.names.map(t=>[t,e]))),f=e=>{throw Error(`Invalid ByteSize: ${e}`)},p=e=>!Number.isSafeInteger(e)||e<0?f(`expected a non-negative safe integer, received ${e}`):BigInt(e),h=e=>{let t=/^\s*(\d+)(?:\.(\d+))?\s*([A-Za-z]+)\s*$/.exec(e);if(null===t)return f(`unsupported syntax ${JSON.stringify(e)}`);let r=u.get(t[3]);if(void 0===r)return f(`unsupported unit ${JSON.stringify(t[3])}`);let n=t[2]??"",i=BigInt(10)**BigInt(n.length),s=BigInt(t[1]+n)*r.factor;return s%i!==a?f(`${JSON.stringify(e)} does not represent an integral number of bytes`):s/i},m=i.liftThrowable(h),g=e=>{switch(typeof e){case"bigint":if(e<a)return f(`expected a non-negative bigint, received ${e}`);return e;case"number":return p(e);case"string":return h(e)}return f(`unsupported input ${e}`)},y=i.liftThrowable(g),b=n.Ro;n.pH,n.rs,n.Tq,n.jk,n.T9,n.qE,n.hl,n.bi,n.yJ,n.OW,n.cz,n.aD,n.sO,n.K0,r.d(t,{},{Dg:e=>e,Ro:b,bN:g,ee:e=>"bigint"==typeof e?g(e):p(e),lX:y,sH:m,yp:e=>"bigint"==typeof e&&e>=a})},719(e,t,r){var n=r(2449),i=r(6297);n.PX,n.B4,n.Aj,n.Wg;let a=n.lC;n.Xb,n.ik;let s=n.b5;n.DH;let o=n.OE,l=n.Iu;i.nIy,i.ORc;let d=i.nn5,c=i.O$X;n.h2;let u=i.ReC;i.myX,i.QE5,i.khU;let f=i.L$u;i.gpn,i.k7S,i.BbX;let p=i.prj;i.tU5,i.h74,i.Bou,i.RJ6;let h=i.GyP;n.PW,n.qB,n.Xm;let m=n.$L;n.q_;let g=n.RS,y=n.Vw;i.DQo,i.c8t,i.MUS,i.t8c,i._y;let b=i.qwd;i.ASO,i.F7W,i.Aub,i.cOF,i.Rft,i.RD4,i.Kkt,i.PnV;let v=i.Bk6;n.Eh,i.tQ6,i.On5,r.d(t,{},{$L:m,Bk:v,F_:l,L$:f,RS:g,Tj:c,Vw:y,fJ:o,iw:u,j9:h,kO:s,lC:a,nn:d,pr:p,qw:b})},4238(e,t,r){var n=r(6297);n.a1U,n.RKA;let i=n.Rud;n.s0X,n.T13,r.d(t,{},{Ru:i})},9519(e,t,r){function n(e){return{combine:e}}function i(e){return n((t,r)=>-1===e(t,r)?t:r)}function a(e){return n((t,r)=>1===e(t,r)?t:r)}r.d(t,{L8:()=>n,T9:()=>a,jk:()=>i})},1179(e,t,r){var n=r(3811),i=r(3332),a=r(1594),s=r(5033),o=r(2449),l=r(1587),d=r(4233);let c="~effect/Context/Service",u=function(){let e=function(){};Object.setPrototypeOf(e,f);let t=(t,r)=>(e.key=t,r?.defaultValue&&(e[h]=h,e.defaultValue=r.defaultValue),r?.make&&(e.make=r.make),r?.fiberCached&&p.add(t),e);return arguments.length>0?t(arguments[0],arguments[1]):t},f={[c]:c,...n.bp({label:"Service",evaluate(e){return(0,o.xt)(P(e.context,this))}}),toJSON(){return{_id:"Service",key:this.key}},of:e=>e,context(e){return $(this,e)},use(e){return(0,o.R6)(t=>e(P(t.context,this)))},useSync(e){return(0,o.R6)(t=>(0,o.xt)(e(P(t.context,this))))}},p=new Set,h="~effect/Context/Reference",m="~effect/Context",g=(e,t,r,n)=>{let i=Object.create(w);return i.cacheRoot=e??i,i.base=t,i.overlay=r,i.depth=n,i._flat=void 0,i.baseHits=0,i},y=(e,t)=>{t&&(y(e,t.parent),e.set(t.key,t.value))},b=e=>{if(e._flat)return e._flat;if(!e.overlay)return e._flat=e.base;let t=new Map(e.base);return y(t,e.overlay),e._flat=t},v=Symbol(),_=(e,t)=>{for(let r=e.overlay;r;r=r.parent)if(r.key===t)return r.value;let r=e.base.get(t);return void 0!==r||e.base.has(t)?(e.overlay&&++e.baseHits>=e.base.size&&e.baseHits>=8&&(e.base=b(e),e.overlay=void 0,e.depth=0),r):v},x=e=>g(void 0,e,void 0,0),w={get mapUnsafe(){return b(this)},...o.fU,[m]:{_Services:e=>e},toJSON(){return{_id:"Context",services:Array.from(this.mapUnsafe).map(([e,t])=>({key:e,value:t}))}},[i.HR](e){if(!k(e))return!1;let t=this.mapUnsafe,r=e.mapUnsafe;if(t.size!==r.size)return!1;for(let[e,n]of t)if(!r.has(e)||!i.aI(n,r.get(e)))return!1;return!0},[s.HR](){return s.ai(this.mapUnsafe.size)}},k=e=>(0,d.i5)(e,m),S=e=>!!e[h],I=x(new Map),$=(e,t)=>x(new Map([[e.key,t]])),E=(0,a.XY)(3,(e,t,r)=>O(e,t.key,r)),O=(e,t,r)=>{let n=p.has(t)?void 0:e.cacheRoot;if(e.depth>=8){let i=new Map(e.mapUnsafe);return i.set(t,r),g(n,i,void 0,0)}return g(n,e.base,{key:t,value:r,parent:e.overlay},e.depth+1)},C=(0,a.XY)(2,(e,t)=>T(e,t.key)),T=(e,t)=>{let r=_(e,t);return r===v?void 0:r},M=(0,a.XY)(2,(e,t)=>{let r=_(e,t.key);if(r===v){if(S(t))return N(t);throw R(t)}return r}),P=M,A="~effect/Context/defaultValue",N=e=>A in e?e[A]:e[A]=e.defaultValue(),R=e=>{let t=Error(`Service not found${e.key?`: ${String(e.key)}`:""}`);if(t.stack){let e=t.stack.split("\n");e.splice(1,3),t.stack=e.join("\n")}return t},j=(0,a.XY)(2,(e,t)=>{let r=_(e,t.key);return r!==v?l.some(r):S(t)?l.some(N(t)):l.none()}),D=(0,a.XY)(2,(e,t)=>{let r;return 0===e.mapUnsafe.size?t:0===t.mapUnsafe.size?e:((e=>t.mapUnsafe.forEach((t,r)=>e.set(r,t)))(r=new Map(e.mapUnsafe)),x(r))});r.d(t,{},{Ie:()=>I,Jt:P,L8:$,LZ:x,Or:u,Pf:(e,t)=>e.cacheRoot===t.cacheRoot,Ub:T,Um:(...e)=>{let t=new Map;for(let r=0;r<e.length;r++)e[r].mapUnsafe.forEach((e,r)=>{t.set(r,e)});return x(t)},WQ:E,Y6:C,aE:k,fp:M,h1:D,kl:u,om:j})},4942(e,t,r){var n=r(2449),i=r(2275),a=r(1554),s=r(4233);let o=class extends a.Xs{constructor(e){super(),e&&i.z(this,e)}};function l(){if(1==arguments.length){let e=arguments[0];return function(t){return e[t._tag](t)}}let e=arguments[0],t=arguments[1];return t[e._tag](e)}let d=n.$D,c=n.rN;r.d(t,{},{$D:d,Ij:()=>new Proxy({},{get:(e,t,r)=>"$is"===t?s.$J:"$match"===t?l:e=>({...e,_tag:t})}),Xs:o,rN:c})},9237(e,t,r){var n=r(1594),i=r(6297),a=r(1554);let s={"~effect/Deferred":{_A:n.D_,_E:n.D_},pipe(){return(0,a.tT)(this,arguments)}},o=function(){this.resumes=void 0,this.effect=void 0};o.prototype=s;let l=e=>void 0!==e.effect;r.d(t,{},{$L:e=>i.OH5(()=>l(e)),$w:(e,t)=>{if(e.effect)return!1;if(e.effect=t,e.resumes){let r=e.resumes;e.resumes=void 0;for(let e=0;e<r.length;e++)r[e](t)}return!0},LZ:()=>new o,NJ:l,Tx:e=>i.E2r(t=>e.effect?t(e.effect):(e.resumes??=[],e.resumes.push(t),i.OH5(()=>{let r=e.resumes;if(void 0===r)return;let n=r.indexOf(t);n>=0&&r.splice(n,1)})))})},3614(e,t,r){var n=r(3332),i=r(1594),a=r(5033),s=r(3952),o=r(2860),l=r(1554),d=r(4233);let c="~effect/Duration",u=BigInt(0),f=BigInt(1),p=BigInt(2),h=BigInt(10),m=BigInt(24),g=BigInt(60),y=BigInt(1e3),b=BigInt(1e6),v=e=>BigInt(e<0?Math.ceil(e-.5):Math.floor(e+.5)),_=(e,t)=>{let r=e.indexOf(".");if(-1===r)return BigInt(e)*t;let n="-"===e[0],i=e.slice(r+1),a=h**BigInt(i.length),s=(BigInt(e.slice(+!!n,r))*a+BigInt(i))*t,o=s/a+(s%a*p>=a?f:u);return n?-o:o},x=/^(-?\d+(?:\.\d+)?)\s+(nanos?|micros?|millis?|seconds?|minutes?|hours?|days?|weeks?)$/,w=e=>{switch(typeof e){case"number":return N(e);case"bigint":return A(e);case"string":{if("Infinity"===e)return M;if("-Infinity"===e)return P;let t=x.exec(e);if(!t)break;let[r,n,i]=t;if("nano"===i||"nanos"===i)return A(_(n,f));if("micro"===i||"micros"===i)return A(_(n,y));let a=Number(n);switch(i){case"milli":case"millis":return N(a);case"second":case"seconds":return R(a);case"minute":case"minutes":return j(a);case"hour":case"hours":return D(a);case"day":case"days":return U(a);case"week":case"weeks":return F(a)}break}case"object":{if(null===e)break;if(c in e)return e;if(Array.isArray(e)){if(2!==e.length||!e.every(d.Et))return k(e);if(Number.isNaN(e[0])||Number.isNaN(e[1]))return T;if(-1/0===e[0]||-1/0===e[1])return P;if(1/0===e[0]||1/0===e[1])return M;return O(v(1e9*e[0]+e[1]))}let t=0;if(e.weeks&&(t+=6048e5*e.weeks),e.days&&(t+=864e5*e.days),e.hours&&(t+=36e5*e.hours),e.minutes&&(t+=6e4*e.minutes),e.seconds&&(t+=1e3*e.seconds),e.milliseconds&&(t+=e.milliseconds),!e.microseconds&&!e.nanoseconds)return O(t);return O(v(1e6*t+(e.microseconds??0)*1e3+(e.nanoseconds??0)))}}return k(e)},k=e=>{throw Error(`Invalid Input: ${e}`)},S={_tag:"Millis",millis:0},I={_tag:"Infinity"},$={_tag:"NegativeInfinity"},E={[c]:c,[a.HR](){switch(this.value._tag){case"Millis":{let e=1e6*this.value.millis;return Number.isFinite(e)?a.tW(v(e)):a.ai(this.value.millis)}case"Nanos":return a.tW(this.value.nanos);default:return a.QK(this.value)}},[n.HR](e){return C(e)&&Y(this,e)},toString(){switch(this.value._tag){case"Infinity":return"Infinity";case"NegativeInfinity":return"-Infinity";case"Nanos":return`${this.value.nanos} nanos`;case"Millis":return`${this.value.millis} millis`}},toJSON(){switch(this.value._tag){case"Millis":return{_id:"Duration",_tag:"Millis",millis:this.value.millis};case"Nanos":return{_id:"Duration",_tag:"Nanos",nanos:String(this.value.nanos)};case"Infinity":return{_id:"Duration",_tag:"Infinity"};case"NegativeInfinity":return{_id:"Duration",_tag:"NegativeInfinity"}}},[s.FX](){return this.toJSON()},pipe(){return(0,l.tT)(this,arguments)}},O=e=>{let t=Object.create(E);return"number"==typeof e?isNaN(e)||0===e||Object.is(e,-0)?t.value=S:Number.isFinite(e)?Number.isInteger(e)?t.value={_tag:"Millis",millis:e}:t.value={_tag:"Nanos",nanos:v(1e6*e)}:t.value=e>0?I:$:e===u?t.value=S:t.value={_tag:"Nanos",nanos:e},t},C=e=>(0,d.i5)(e,c),T=O(0),M=O(1/0),P=O(-1/0),A=e=>O(e),N=e=>O(e),R=e=>O(1e3*e),j=e=>O(6e4*e),D=e=>O(36e5*e),U=e=>O(864e5*e),F=e=>O(6048e5*e),B=e=>{let t=w(e);switch(t.value._tag){case"Infinity":case"NegativeInfinity":throw Error("Cannot convert infinite duration to nanos");case"Nanos":return t.value.nanos;case"Millis":return v(1e6*t.value.millis)}},L=(0,i.XY)(2,(e,t)=>{switch(e.value._tag){case"Millis":return t.onMillis(e.value.millis);case"Nanos":return t.onNanos(e.value.nanos);case"Infinity":return t.onInfinity();case"NegativeInfinity":return(t.onNegativeInfinity??t.onInfinity)()}}),z=(0,i.XY)(3,(e,t,r)=>"Infinity"===e.value._tag||"NegativeInfinity"===e.value._tag||"Infinity"===t.value._tag||"NegativeInfinity"===t.value._tag?r.onInfinity(e,t):"Millis"===e.value._tag?"Millis"===t.value._tag?r.onMillis(e.value.millis,t.value.millis):r.onNanos(B(e),t.value.nanos):r.onNanos(e.value.nanos,B(t))),W=o.L8((e,t)=>z(e,t,{onMillis:(e,t)=>e<t?-1:+(e>t),onNanos:(e,t)=>e<t?-1:+(e>t),onInfinity:(e,t)=>e.value._tag===t.value._tag?0:"Infinity"===e.value._tag?1:"NegativeInfinity"===e.value._tag||"Infinity"===t.value._tag?-1:1})),J=o.bi(W),Y=(0,i.XY)(2,(e,t)=>z(e,t,{onMillis:(e,t)=>e===t,onNanos:(e,t)=>e===t,onInfinity:(e,t)=>e.value._tag===t.value._tag})),X=e=>{if("Infinity"===e.value._tag)return"Infinity";if("NegativeInfinity"===e.value._tag)return"-Infinity";if((e=>{switch(e.value._tag){case"Millis":return 0===e.value.millis;case"Nanos":return e.value.nanos===u;case"Infinity":case"NegativeInfinity":return!1}})(e))return"0";if((e=>{switch(e.value._tag){case"Millis":return e.value.millis<0;case"Nanos":return e.value.nanos<u;case"NegativeInfinity":return!0;case"Infinity":return!1}})(e))return"-"+X((e=>{switch(e.value._tag){case"Infinity":case"NegativeInfinity":return M;case"Millis":return e.value.millis<0?O(-e.value.millis):e;case"Nanos":return e.value.nanos<u?O(-e.value.nanos):e}})(e));let t=(e=>{if("Infinity"===e.value._tag)return{days:1/0,hours:1/0,minutes:1/0,seconds:1/0,millis:1/0,nanos:1/0};if("NegativeInfinity"===e.value._tag)return{days:-1/0,hours:-1/0,minutes:-1/0,seconds:-1/0,millis:-1/0,nanos:-1/0};let t=B(e),r=t<u,n=r?-t:t,i=n/b,a=i/y,s=a/g,o=s/g,l=r?-1:1;return{days:l*Number(o/m),hours:l*Number(o%m),minutes:l*Number(s%g),seconds:l*Number(a%g),millis:l*Number(i%y),nanos:l*Number(n%b)}})(e),r=[];return 0!==t.days&&r.push(`${t.days}d`),0!==t.hours&&r.push(`${t.hours}h`),0!==t.minutes&&r.push(`${t.minutes}m`),0!==t.seconds&&r.push(`${t.seconds}s`),0!==t.millis&&r.push(`${t.millis}ms`),0!==t.nanos&&r.push(`${t.nanos}ns`),r.join(" ")};r.d(t,{},{GP:X,MI:e=>"Infinity"!==e.value._tag&&"NegativeInfinity"!==e.value._tag,Tn:M,YA:R,bN:w,bi:J,cF:A,fP:e=>L(w(e),{onMillis:e=>e/1e3,onNanos:e=>Number(e)/1e9,onInfinity:()=>1/0,onNegativeInfinity:()=>-1/0}),kE:e=>L(w(e),{onMillis:i.D_,onNanos:e=>Number(e)/1e6,onInfinity:()=>1/0,onNegativeInfinity:()=>-1/0}),n$:C,ne:N,qv:P,v_:T})},2842(e,t,r){r.d(t,{Q56:()=>e_,jGc:()=>ex,U9h:()=>ew,Q7R:()=>w,hgn:()=>z,swY:()=>ez,Muk:()=>eT,as:()=>G,E2r:()=>M,MfU:()=>V,Tyx:()=>Q,osR:()=>Z,KuX:()=>H,loE:()=>K,RKA:()=>eB,_32:()=>eM,F_Q:()=>D,_r7:()=>eW,yeE:()=>ek,NS5:()=>X,fJG:()=>N,ATB:()=>R,pVV:()=>j,qIB:()=>L,Ab9:()=>eq,fn:()=>eF,D9k:()=>eU,vCS:()=>eG,jJl:()=>k,i4r:()=>eC,ar0:()=>eA,x6Z:()=>eN,yUA:()=>B,JkU:()=>A,XeO:()=>ea,GaK:()=>e$,yw5:()=>x,vVN:()=>eL,TjK:()=>q,q7Y:()=>eX,jkJ:()=>eJ,xm_:()=>ee,Z9x:()=>eY,YWq:()=>ec,khu:()=>eu,tvg:()=>ef,ZmZ:()=>P,S5A:()=>eS,cfM:()=>eI,uKv:()=>Y,QgK:()=>et,ivC:()=>I,Gte:()=>ep,PpN:()=>eh,PfK:()=>eg,KT6:()=>ed,Ket:()=>J,L5P:()=>ei,MY7:()=>eR,eJC:()=>ej,lKS:()=>eD,z8E:()=>ey,P1j:()=>eb,Pxi:()=>ev,Nav:()=>em,yy4:()=>el,PyW:()=>E,DYE:()=>O,OH5:()=>C,Mim:()=>W,dGm:()=>en,sFT:()=>er,wRz:()=>es,mgX:()=>eo,SvU:()=>U,$mh:()=>$,rfi:()=>eE,FcF:()=>eO,rIH:()=>T,iMI:()=>S,R6R:()=>F,fRP:()=>eP});var n=r(1594),i=r(2449),a=r(6297),s=(r(3614),r(1179));r(9315);var o=r(6771),l=r(5633);let d=(0,n.XY)(e=>(0,i.yw)(e[0]),(e,t,r)=>{let n;return s.aE(t)?a.PpN(e,t):(n=Array.isArray(t)?l.Um(...t):t,a.Pxi(t=>a.qIB(r?.local?l.H7(n,l.j6(),t):l.LT(n,t),t=>a.PpN(e,t))))});var c=r(1587),u=r(3753),f=r(6481);(e,t,r)=>a.qIB(o.xn(t),t=>{let n=o.d3.defaultValue();return a.h_t(a.i4r(a.Mim(a.qIB(a.DYE(()=>a.PfK(e,o.d3,n)),t),e=>a.OH5(()=>{n=e})),{disableYield:!0}),e=>i.$L(e)?a.PyW(e.value):r(e,0===n.attempt?c.none():c.some(n)))});let p=(0,n.XY)(3,(e,t,r)=>a.qIB(o.xn(t),t=>{let n,i=o.d3.defaultValue(),s=a.h_t(a.DYE(()=>a.PfK(e,o.d3,i)),e=>(n=e,a.qIB(t(e),e=>(i=e,s))));return u.m8(s,e=>(0,f.s)(()=>r(n,e)))})),h=(0,n.XY)(2,(e,t)=>p(e,"function"==typeof t?t(n.D_):o.GM(t)?t:g(t),a.fJG)),m=o.le(o.i4),g=e=>{let t=e.schedule?o.le(e.schedule):m;return e.while&&(t=o.E6(t,({input:t})=>{let r=e.while(t);return i.yw(r)?r:a.PyW(r)})),e.until&&(t=o.E6(t,({input:t})=>{let r=e.until(t);return i.yw(r)?a.TjK(r,e=>!e):a.PyW(!r)})),void 0!==e.times&&(t=o.E6(t,({attempt:t})=>a.PyW(t<=e.times))),t},y=o.t5(1);var b=r(2275);let v=r(3332).Xq({_E:e=>e,_A:e=>e,_R:e=>e});({...i.In,"~effect/Request":v}),r(3909);var _=r(4600);i.$n;let x=i.yw,w=a.Q7R;a.jBG,a.TSs,a.tfT,a.i8i,a.kAe;let k=a.jJl;a.d5f;let S=a.iMI,I=a.ivC,$=a.$mh,E=a.PyW;a.lwU,a.nGE;let O=a.DYE,C=a.OH5,T=a.rIH;a.Vxk;let M=a.E2r,P=a.ZmZ;a.Do,a.JrD,a.uVU,a.oIE;let A=a.JkU,N=a.fJG;a.gOk;let R=a.ATB,j=a.pVV,D=a.F_Q,U=a.SvU;a.m9E,a.KN3;let F=i.R6;i.Hq;let B=a.yUA;a.sVm,a.pkL,a.bJ;let L=a.qIB;a.Bqz;let z=a.hgn,W=a.Mim,J=a.Ket,Y=a.uKv,X=a.NS5,q=a.TjK,G=a.as;a.Xx$,a.NLW,a.UUz,a.yU6,a.OYO;let V=a.h_t,H=a.KuX,K=a.loE;a.AXC,a.zt4,a.scW;let Q=a.Tyx;a.Fig,a.XWm;let Z=a.osR;a.U9Y,a.sJf,a.rNk;let ee=a.xm_;a.UcN;let et=a.QgK,er=a.sFT;a.k$L;let en=a.dGm;a.cA6,a.bKC,a.nAi,a.u4Y;let ei=h;a._Sg;let ea=a.XeO;a.GrF,a.$$g,a.DM4,a.Dd;let es=a.wRz;a.D52;let eo=a.mgX;a.cbG;let el=a.yy4;a.ayu,a.Vdx,a.FfP,a.O4F;let ed=a.KT6;a.pbD,a.x1Q,a.E8K,a.Pm0,a.VtY,a.W$I,a.ahH,a.z7s;let ec=a.YWq;a.G$Q,a.D$$,a.NZb,a.wR5;let eu=a.khu,ef=a.tvg;a.N6O,a.oJd,a._OA,a.sxi;let ep=d,eh=a.PpN;a.oao,a.euC;let em=a.Nav;a.r_d,a.bUZ,a.L_I;let eg=a.PfK;a.c7E;let ey=a.z8E,eb=a.P1j,ev=a.Pxi,e_=a.Q56;a.N24;let ex=a.jGc,ew=a.U9h,ek=a.yeE,eS=a.S5A;a.BeE,a.iKM,a.r7h;let eI=a.cfM;a.fGe,a.uRq,a.PO3,a.Rgn,a.CJw;let e$=a.GaK;a.Inz,a.nAr;let eE=a.rfi,eO=a.FcF;a.eMl,a.dsN;let eC=a.i4r;a.aAq,a.Xrv,a.kJM,a._o1,a.nDN,a.MaT;let eT=a.Muk;a.ww9;let eM=a._32;a.Wj8,a.Fu6,a.WbR,a.A_r,a.Z98,a.Rd$,a.gvr;let eP=a.fRP;a.zr8,a.hq,a.zhn;let eA=a.ar0,eN=a.x6Z;a.yxg,a.PCg,a.pEE,a.ABT;let eR=a.MY7,ej=a.eJC;a.lSz,a.bPG,a.pR5,a.v2Q,a.NpQ,a.jqV,a.HZF,a.lE;let eD=a.lKS;a.rfH;let eU=a.D9k,eF=a.fn,eB=a.RKA;a.lIX;let eL=a.lIX("Error"),ez=(0,n.XY)(e=>x(e[0]),(e,...t)=>a.bUZ(e,_.iL,e=>{let r=1===t.length?{...e,...t[0]}:{...e};return 1===t.length||b.x(r,t[0],t[1]),r}));a.gsV;let eW=(e,t,r)=>(...n)=>M(i=>{try{e(...n,(e,r)=>{e?i(N(t?t(e,n):e)):i(E(r))})}catch(e){i(r?N(r(e,n)):D(e))}}),eJ=a.jkJ,eY=a.Z9x,eX=a.q7Y,eq=a.Ab9;a.UVN;let eG=a.vCS},3811(e,t,r){var n=r(2449);r.d(t,{},{bp:e=>(0,n.yj)({op:e.label,[n._3]:e.evaluate})})},3332(e,t,r){var n=r(5033),i=r(5844),a=r(4233);let s="~effect/Equal";function o(){return 1==arguments.length?e=>l(e,arguments[0]):l(arguments[0],arguments[1])}function l(e,t){if(e===t)return!0;if(null==e||null==t)return!1;let r=typeof e;return r===typeof t&&("number"===r&&e!=e&&t!=t||!("object"!==r&&"function"!==r||i.J3.has(e)||i.J3.has(t))&&function(e,t){let r=c.length;for(let n=r;n-- >0;)if(c[n]===e&&u[n]===t)return!0;if(r)return d(e,t);let n=f.get(e);n||f.set(e,n=new WeakMap);let i=n.get(t);return void 0===i&&n.set(t,i=d(e,t)),i}(e,t))}function d(e,t){c.push(e),u.push(t);try{return function(e,t){if(n.tW(e)!==n.tW(t))return!1;if(e instanceof Date){if(!(t instanceof Date))return!1;let r=e.getTime(),n=t.getTime();return r===n||Number.isNaN(r)&&Number.isNaN(n)}if(e instanceof RegExp)return t instanceof RegExp&&e.toString()===t.toString();let r=y(e);if(r!==y(t)||"function"==typeof e&&!r)return!1;if(r)return e[s](t);if(Array.isArray(e))return!!Array.isArray(t)&&e.length===t.length&&function(e,t){for(let r=0;r<e.length;r++)if(!l(e[r],t[r]))return!1;return!0}(e,t);if(ArrayBuffer.isView(e)){let r=e instanceof DataView;return!!ArrayBuffer.isView(t)&&e.byteLength===t.byteLength&&r===t instanceof DataView&&(r?p((0,i.j)(e),(0,i.j)(t)):p(e,t))}if(e instanceof Map)return t instanceof Map&&e.size===t.size&&h(e,t,m,g);else if(e instanceof Set)return t instanceof Set&&e.size===t.size&&h(e,t,n.tW,l);var a=e,o=t;let d=(0,i.Xp)(a),c=(0,i.Xp)(o);if(d.size!==c.size)return!1;for(let e of d)if(!c.has(e)||!l(a[e],o[e]))return!1;return!0}(e,t)}finally{c.pop(),u.pop()}}let c=[],u=[],f=new WeakMap;function p(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}function h(e,t,r,n){let i=new Map;for(let e of t){let t=r(e),n=i.get(t);n?n.push(e):i.set(t,[e])}e:for(let t of e){let e=i.get(r(t));if(e){for(let r=0;r<e.length;r++)if(n(t,e[r])){e[r]=e[e.length-1],e.pop();continue e}}return!1}return!0}let m=e=>n.tW(e[0]),g=(e,t)=>l(e[0],t[0])&&l(e[1],t[1]),y=e=>(0,a.i5)(e,s);r.d(t,{aI:()=>o},{HR:s,Xq:e=>(i.J3.add(e),e),jI:()=>o})},7876(e,t,r){let n=e=>(t,r)=>t===r||e(t,r),i=(e,t)=>e===t,a=n((e,t)=>globalThis.Number.isNaN(e)&&globalThis.Number.isNaN(t));function s(e){return n((t,r)=>{if(t.length!==r.length)return!1;for(let n=0;n<t.length;n++)if(!e[n](t[n],r[n]))return!1;return!0})}function o(e){return n((t,r)=>{if(t.length!==r.length)return!1;for(let n=0;n<t.length;n++)if(!e(t[n],r[n]))return!1;return!0})}function l(e){let t=Reflect.ownKeys(e);return n((r,n)=>{for(let i of t)if(!e[i](r[i],n[i]))return!1;return!0})}r.d(t,{O3:()=>o,_k:()=>l,rd:()=>s},{L8:n,Qw:i,YZ:()=>i,wN:a})},6526(e,t,r){var n=r(2449),i=r(6297);n.IH,n.b9;let a=n.xt,s=n.cb,o=n.Rk;n.V2,i._sz;let l=i.x5l,d=i.CoE,c=i.VE1;i._mh,i.YDM,i.lNM,i.K$2,i.GUt,i.HIt,i.yJo,i._OD,i.jCT,i.Wtn,i.v9O,i.zPu,i.EkE,i.Hox,i.ely,i.kMI,i.Sv3,i.lgw,r.d(t,{},{AT:s,N6:c,Py:a,fJ:o,oJ:d,rI:l})},1958(e,t,r){var n=r(4233),i=r(1279);function a(e,t){let r=t?.space??0,a=new WeakSet,l=r?"number"==typeof r?" ".repeat(r):r:"",u=(e,t)=>{let r=e?.constructor;return r&&r!==Object.prototype.constructor&&r.name?`${r.name}(${t})`:t};return function e(r,f=0){try{return function(r,f=0){if("string"==typeof r)return JSON.stringify(r);if("number"==typeof r||null==r||"boolean"==typeof r||"symbol"==typeof r)return String(r);if("bigint"==typeof r)return String(r)+"n";if("object"==typeof r||"function"==typeof r){let p;if(a.has(r))return s;if(a.add(r),i.uC in r)p=e((0,i.f6)(r),f);else if(Array.isArray(r)){let t,n;p=!l||r.length<=1?`[${r.map(t=>e(t,f)).join(",")}]`:`[
230
+ `)}},d=new Proxy(globalThis.console,{get(e,t,r){if("log"===t)return(...t)=>{(1!==t.length||""!==t[0])&&e.log(...t)};let n=Reflect.get(e,t,r);return"function"==typeof n?n.bind(e):n}}),uy(pZ,{version:"0.6.2"})(e).pipe(B.sFT(e=>eh.i5(e,oi)&&"ShowHelp"!==e._tag?or(l.formatErrors([e])):B.rIH),B.PfK(dr,{builtIns:[l8,l9,l7]}),B.PfK(o3,l),B.PfK(oe,d))).pipe(B.khu({onFailure:e=>B.JkU(function*(){let t,r=ee.getOrUndefined(F.L$(e));if(r instanceof f8)return r.exitCode;if(r instanceof nA)return 7;let n=function(e){if(eh.i5(e,oi))return"ShowHelp"===e._tag?2*(e.errors.length>0):2}(r);if(void 0!==n)return n;let i=yield*f6;return yield*i.stderr((t={code:"internal_error",message:"Sketchi could not complete the command.",hint:"Retry once; if it persists, report the command and inputs without secrets."},"json"===c?n6({ok:!1,command:"sketchi",error:t}):f7(t))).pipe(B.MfU(()=>B.rIH)),1}),onSuccess:()=>B.PyW(0)}))}),p1=G.Um(nM.Tx,(0,nM.rR)({createId:e=>`${e}_offline_cli`})),p2=G.Gt(n7,p1),p5=G.Gt(ip,p1),p3=G.Um(is,aa),p6=G.Gt(ag,p3),p8=G.Gt(aB,G.Um(p6,aj)),p9=G.Gt(py,pf),p4=G.Um(is,aa,p2,p5,p6,p8,aj,p9,pm,ig.pipe(G.Gt(is)),f4,s7),p7=G.S5(p4,nT);q(p0(process.argv.slice(2)).pipe(B.Mim(e=>B.OH5(()=>{process.exitCode=e})),B.Gte(p7)),{disableErrorReporting:!0})},1688(e,t,r){var n=r(2718);let i=n.xCb(["invalid_render_artifact","render_limit_exceeded","unsupported_render_glyph","rasterization_failed"]),a=n.xCb(["artifact","geometry","font","rasterization"]);class s extends n.rNF()("HeadlessPngRenderError",{cause:n.kld(),code:i,stage:a,message:n.QfV,details:n.O31(n.QfV)}){}r.d(t,{FG:()=>s})},5030(e,t,r){function n(e,t,r,n){return{code:e,message:t,...void 0===r?{}:{observed:r},...void 0===n?{}:{limit:n}}}function i(e,t=0){let r=1/0,a=1/0,s=-1/0,o=-1/0;for(let t of e){var l;if(!("object"==typeof(l=t)&&null!==l&&!Array.isArray(l)&&"number"==typeof t.x&&Number.isFinite(t.x)&&"number"==typeof t.y&&Number.isFinite(t.y)&&"number"==typeof t.width&&Number.isFinite(t.width)&&"number"==typeof t.height&&Number.isFinite(t.height)))return n("invalid_geometry","element geometry is invalid");let e=Math.abs(t.width),i=Math.abs(t.height);if(e>8192||i>8192)return n("element_dimension",`element dimension exceeds ${String(8192)}`,Math.max(e,i),8192);let d=Math.hypot(e,i)/2,c=t.x+t.width/2,u=t.y+t.height/2;r=Math.min(r,c-d),a=Math.min(a,u-d),s=Math.max(s,c+d),o=Math.max(o,u+d)}if(0===e.length)return;let d=s-r,c=o-a;if(d>8192||c>8192)return n("canvas_dimension",`canvas dimension exceeds ${String(8192)}`,Math.max(d,c),8192);let u=d*c;if(u>6291456)return n("canvas_area",`canvas area exceeds ${String(6291456)}`,u,6291456);let f=(d+40)*1*((c+40+t)*1);if(f>0x1800000)return n("output_pixels",`PNG output exceeds ${String(0x1800000)} pixels at minimum scale`,f,0x1800000)}function a(e,t=0){return i(e,t)?.message}function s(e,t){if(!Number.isFinite(e)||!Number.isFinite(t)||e<=0||t<=0)return n("invalid_geometry","rendered SVG dimensions are invalid");let r=Math.min(2,16384/e,16384/t,Math.sqrt(0x1800000/(e*t)));if(r<1){let r=e*t;return r>0x1800000?n("output_pixels",`PNG output exceeds ${String(0x1800000)} pixels at minimum scale`,r,0x1800000):n("output_dimension","rendered SVG dimension exceeds the PNG limit at minimum scale",Math.max(e,t),16384)}return Math.max(1,Math.floor(1e3*r)/1e3)}r.d(t,{Gd:()=>a,Ts:()=>i,Yu:()=>s},{Z4:6291456,ce:0x1800000})},6982(e){e.exports=t("crypto")},7598(e){e.exports=t("node:crypto")},76(e,t,r){let n=r(9095),i=process.env;function a(e){return"string"==typeof e?!!i[e]:"env"in e?i[e.env]&&i[e.env].includes(e.includes):"any"in e?e.any.some(function(e){return!!i[e]}):Object.keys(e).every(function(t){return i[t]===e[t]})}Object.defineProperty(t,"_vendors",{value:n.map(function(e){return e.constant})}),t.name=null,t.isPR=null,t.id=null,"false"!==i.CI&&n.forEach(function(e){let r=(Array.isArray(e.env)?e.env:[e.env]).every(function(e){return a(e)});t[e.constant]=r,r&&(t.name=e.name,t.isPR=function(e){switch(typeof e.pr){case"string":return!!i[e.pr];case"object":if("env"in e.pr)if("any"in e.pr)return e.pr.any.some(function(t){return i[e.pr.env]===t});else return e.pr.env in i&&i[e.pr.env]!==e.pr.ne;if("any"in e.pr)return e.pr.any.some(function(e){return!!i[e]});return a(e.pr);default:return null}}(e),t.id=e.constant)}),t.isCI=!!("false"!==i.CI&&(i.BUILD_ID||i.BUILD_NUMBER||i.CI||i.CI_APP_ID||i.CI_BUILD_ID||i.CI_BUILD_NUMBER||i.CI_NAME||i.CONTINUOUS_INTEGRATION||i.RUN_ID||t.name))},485(e,t,r){e.exports=r(76).isCI},664(e,t,r){r.d(t,{CN:()=>p,BC:()=>g,Ie:()=>I,pb:()=>O,i8:()=>w,g9:()=>x,Uk:()=>k,Ts:()=>h,CZ:()=>y,ET:()=>v,HV:()=>b,T9:()=>M,Tj:()=>E,YW:()=>m,of:()=>$,jB:()=>C,TS:()=>T,di:()=>S});var n=r(7876),i=r(1594);let a=e=>e.length>0;var s=r(9771),o=r(592),l=r(1587),d=r(2860),c=r(915),u=r(9315);let f=globalThis.Array,p=e=>new f(s.S(e)),h=e=>f.isArray(e)?e:f.from(e);c.Wo,l.toArray;let m=(0,i.XY)(2,(e,{onEmpty:t,onNonEmpty:r})=>v(e)?r(e):t()),g=(0,i.XY)(2,(e,t)=>[...e,t]);f.isArray;let y=a,v=a,b=e=>v(e)?l.some(_(e)):l.none(),_=e=>e[e.length-1],x=(0,i.XY)(2,(e,t)=>{let r=0;for(let n of e){if(t(n,r))return l.some(r);r++}return l.none()}),w=o.i8,k=(0,i.XY)(2,(e,t)=>{let r=h(e);for(let e=r.length-1;e>=0;e--){let n=r[e],i=t(n,e);if("boolean"==typeof i){if(i)return l.some(n)}else if(l.isSome(i))return i}return l.none()}),S=(0,i.XY)(2,(e,t)=>{let r=f.from(e);return r.sort(t),r}),I=()=>[],$=e=>[e],E=(0,i.XY)(2,(e,t)=>e.map(t)),O=(0,i.XY)(2,(e,t)=>{let r=h(e),n=[];for(let e=0;e<r.length;e++)t(r[e],e)&&n.push(r[e]);return n}),C=(0,i.XY)(2,(e,t)=>{let r=[],n=[],i=0;for(let a of e){let e=t(a,i++);u.oJ(e)?r.push(e.success):n.push(e.failure)}return[r,n]}),T=(0,i.XY)(3,(e,t,r)=>h(e).reduce((e,t,n)=>r(e,t,n),t));d.O3;let M=n.O3},5053(e,t,r){var n=r(9519),i=r(7876),a=r(1594),s=r(1587),o=r(2860),l=r(4233),d=r(636);let c=globalThis.BigInt,u=c(0);l.sI;let f=(0,a.XY)(2,(e,t)=>e+t),p=o.Qw,h=i.Qw,m=o.hl(p),g=o.bi(p),y=o.yJ(p),v=o.OW(p),b=o.Bt(p),_=o.qE(p),x=o.jk(p),w=o.T9(p),k=d.L((e,t)=>e+t,u),S=n.T9(p),I=n.jk(p);r.d(t,{},{K0:I,OW:v,Ro:e=>e>c(Number.MAX_SAFE_INTEGER)||e<c(Number.MIN_SAFE_INTEGER)?s.none():s.some(Number(e)),T9:w,Tq:b,aD:k,bi:g,cz:f,hl:m,jk:x,pH:p,qE:_,rs:h,sO:S,yJ:y})},3265(e,t,r){var n=r(5053),i=r(1587);let a=BigInt(0),s=BigInt(1),o=BigInt(1e3),l=BigInt(1024),d=[{symbol:"B",factor:s,names:["B","byte","bytes"]},{symbol:"kB",factor:o,names:["kB","kilobyte","kilobytes"]},{symbol:"MB",factor:o**BigInt(2),names:["MB","megabyte","megabytes"]},{symbol:"GB",factor:o**BigInt(3),names:["GB","gigabyte","gigabytes"]},{symbol:"TB",factor:o**BigInt(4),names:["TB","terabyte","terabytes"]},{symbol:"PB",factor:o**BigInt(5),names:["PB","petabyte","petabytes"]},{symbol:"EB",factor:o**BigInt(6),names:["EB","exabyte","exabytes"]},{symbol:"ZB",factor:o**BigInt(7),names:["ZB","zettabyte","zettabytes"]},{symbol:"YB",factor:o**BigInt(8),names:["YB","yottabyte","yottabytes"]},{symbol:"RB",factor:o**BigInt(9),names:["RB","ronnabyte","ronnabytes"]},{symbol:"QB",factor:o**BigInt(10),names:["QB","quettabyte","quettabytes"]}],c=[d[0],{symbol:"KiB",factor:l,names:["KiB","kibibyte","kibibytes"]},{symbol:"MiB",factor:l**BigInt(2),names:["MiB","mebibyte","mebibytes"]},{symbol:"GiB",factor:l**BigInt(3),names:["GiB","gibibyte","gibibytes"]},{symbol:"TiB",factor:l**BigInt(4),names:["TiB","tebibyte","tebibytes"]},{symbol:"PiB",factor:l**BigInt(5),names:["PiB","pebibyte","pebibytes"]},{symbol:"EiB",factor:l**BigInt(6),names:["EiB","exbibyte","exbibytes"]},{symbol:"ZiB",factor:l**BigInt(7),names:["ZiB","zebibyte","zebibytes"]},{symbol:"YiB",factor:l**BigInt(8),names:["YiB","yobibyte","yobibytes"]}],u=new Map([...d,...c.slice(1)].flatMap(e=>e.names.map(t=>[t,e]))),f=e=>{throw Error(`Invalid ByteSize: ${e}`)},p=e=>!Number.isSafeInteger(e)||e<0?f(`expected a non-negative safe integer, received ${e}`):BigInt(e),h=e=>{let t=/^\s*(\d+)(?:\.(\d+))?\s*([A-Za-z]+)\s*$/.exec(e);if(null===t)return f(`unsupported syntax ${JSON.stringify(e)}`);let r=u.get(t[3]);if(void 0===r)return f(`unsupported unit ${JSON.stringify(t[3])}`);let n=t[2]??"",i=BigInt(10)**BigInt(n.length),s=BigInt(t[1]+n)*r.factor;return s%i!==a?f(`${JSON.stringify(e)} does not represent an integral number of bytes`):s/i},m=i.liftThrowable(h),g=e=>{switch(typeof e){case"bigint":if(e<a)return f(`expected a non-negative bigint, received ${e}`);return e;case"number":return p(e);case"string":return h(e)}return f(`unsupported input ${e}`)},y=i.liftThrowable(g),v=n.Ro;n.pH,n.rs,n.Tq,n.jk,n.T9,n.qE,n.hl,n.bi,n.yJ,n.OW,n.cz,n.aD,n.sO,n.K0,r.d(t,{},{Dg:e=>e,Ro:v,bN:g,ee:e=>"bigint"==typeof e?g(e):p(e),lX:y,sH:m,yp:e=>"bigint"==typeof e&&e>=a})},719(e,t,r){var n=r(2449),i=r(6297);n.PX,n.B4,n.Aj,n.Wg;let a=n.lC;n.Xb,n.ik;let s=n.b5;n.DH;let o=n.OE,l=n.Iu;i.nIy,i.ORc;let d=i.nn5,c=i.O$X;n.h2;let u=i.ReC;i.myX,i.QE5,i.khU;let f=i.L$u;i.gpn,i.k7S,i.BbX;let p=i.prj;i.tU5,i.h74,i.Bou,i.RJ6;let h=i.GyP;n.PW,n.qB,n.Xm;let m=n.$L;n.q_;let g=n.RS,y=n.Vw;i.DQo,i.c8t,i.MUS,i.t8c,i._y;let v=i.qwd;i.ASO,i.F7W,i.Aub,i.cOF,i.Rft,i.RD4,i.Kkt,i.PnV;let b=i.Bk6;n.Eh,i.tQ6,i.On5,r.d(t,{},{$L:m,Bk:b,F_:l,L$:f,RS:g,Tj:c,Vw:y,fJ:o,iw:u,j9:h,kO:s,lC:a,nn:d,pr:p,qw:v})},4238(e,t,r){var n=r(6297);n.a1U,n.RKA;let i=n.Rud;n.s0X,n.T13,r.d(t,{},{Ru:i})},9519(e,t,r){function n(e){return{combine:e}}function i(e){return n((t,r)=>-1===e(t,r)?t:r)}function a(e){return n((t,r)=>1===e(t,r)?t:r)}r.d(t,{L8:()=>n,T9:()=>a,jk:()=>i})},1179(e,t,r){var n=r(3811),i=r(3332),a=r(1594),s=r(5033),o=r(2449),l=r(1587),d=r(4233);let c="~effect/Context/Service",u=function(){let e=function(){};Object.setPrototypeOf(e,f);let t=(t,r)=>(e.key=t,r?.defaultValue&&(e[h]=h,e.defaultValue=r.defaultValue),r?.make&&(e.make=r.make),r?.fiberCached&&p.add(t),e);return arguments.length>0?t(arguments[0],arguments[1]):t},f={[c]:c,...n.bp({label:"Service",evaluate(e){return(0,o.xt)(A(e.context,this))}}),toJSON(){return{_id:"Service",key:this.key}},of:e=>e,context(e){return $(this,e)},use(e){return(0,o.R6)(t=>e(A(t.context,this)))},useSync(e){return(0,o.R6)(t=>(0,o.xt)(e(A(t.context,this))))}},p=new Set,h="~effect/Context/Reference",m="~effect/Context",g=(e,t,r,n)=>{let i=Object.create(w);return i.cacheRoot=e??i,i.base=t,i.overlay=r,i.depth=n,i._flat=void 0,i.baseHits=0,i},y=(e,t)=>{t&&(y(e,t.parent),e.set(t.key,t.value))},v=e=>{if(e._flat)return e._flat;if(!e.overlay)return e._flat=e.base;let t=new Map(e.base);return y(t,e.overlay),e._flat=t},b=Symbol(),_=(e,t)=>{for(let r=e.overlay;r;r=r.parent)if(r.key===t)return r.value;let r=e.base.get(t);return void 0!==r||e.base.has(t)?(e.overlay&&++e.baseHits>=e.base.size&&e.baseHits>=8&&(e.base=v(e),e.overlay=void 0,e.depth=0),r):b},x=e=>g(void 0,e,void 0,0),w={get mapUnsafe(){return v(this)},...o.fU,[m]:{_Services:e=>e},toJSON(){return{_id:"Context",services:Array.from(this.mapUnsafe).map(([e,t])=>({key:e,value:t}))}},[i.HR](e){if(!k(e))return!1;let t=this.mapUnsafe,r=e.mapUnsafe;if(t.size!==r.size)return!1;for(let[e,n]of t)if(!r.has(e)||!i.aI(n,r.get(e)))return!1;return!0},[s.HR](){return s.ai(this.mapUnsafe.size)}},k=e=>(0,d.i5)(e,m),S=e=>!!e[h],I=x(new Map),$=(e,t)=>x(new Map([[e.key,t]])),E=(0,a.XY)(3,(e,t,r)=>O(e,t.key,r)),O=(e,t,r)=>{let n=p.has(t)?void 0:e.cacheRoot;if(e.depth>=8){let i=new Map(e.mapUnsafe);return i.set(t,r),g(n,i,void 0,0)}return g(n,e.base,{key:t,value:r,parent:e.overlay},e.depth+1)},C=(0,a.XY)(2,(e,t)=>T(e,t.key)),T=(e,t)=>{let r=_(e,t);return r===b?void 0:r},M=(0,a.XY)(2,(e,t)=>{let r=_(e,t.key);if(r===b){if(S(t))return P(t);throw R(t)}return r}),A=M,N="~effect/Context/defaultValue",P=e=>N in e?e[N]:e[N]=e.defaultValue(),R=e=>{let t=Error(`Service not found${e.key?`: ${String(e.key)}`:""}`);if(t.stack){let e=t.stack.split("\n");e.splice(1,3),t.stack=e.join("\n")}return t},j=(0,a.XY)(2,(e,t)=>{let r=_(e,t.key);return r!==b?l.some(r):S(t)?l.some(P(t)):l.none()}),D=(0,a.XY)(2,(e,t)=>{let r;return 0===e.mapUnsafe.size?t:0===t.mapUnsafe.size?e:((e=>t.mapUnsafe.forEach((t,r)=>e.set(r,t)))(r=new Map(e.mapUnsafe)),x(r))});r.d(t,{},{Ie:()=>I,Jt:A,L8:$,LZ:x,Or:u,Pf:(e,t)=>e.cacheRoot===t.cacheRoot,Ub:T,Um:(...e)=>{let t=new Map;for(let r=0;r<e.length;r++)e[r].mapUnsafe.forEach((e,r)=>{t.set(r,e)});return x(t)},WQ:E,Y6:C,aE:k,fp:M,h1:D,kl:u,om:j})},4942(e,t,r){var n=r(2449),i=r(2275),a=r(1554),s=r(4233);let o=class extends a.Xs{constructor(e){super(),e&&i.z(this,e)}};function l(){if(1==arguments.length){let e=arguments[0];return function(t){return e[t._tag](t)}}let e=arguments[0],t=arguments[1];return t[e._tag](e)}let d=n.$D,c=n.rN;r.d(t,{},{$D:d,Ij:()=>new Proxy({},{get:(e,t,r)=>"$is"===t?s.$J:"$match"===t?l:e=>({...e,_tag:t})}),Xs:o,rN:c})},9237(e,t,r){var n=r(1594),i=r(6297),a=r(1554);let s={"~effect/Deferred":{_A:n.D_,_E:n.D_},pipe(){return(0,a.tT)(this,arguments)}},o=function(){this.resumes=void 0,this.effect=void 0};o.prototype=s;let l=e=>void 0!==e.effect;r.d(t,{},{$L:e=>i.OH5(()=>l(e)),$w:(e,t)=>{if(e.effect)return!1;if(e.effect=t,e.resumes){let r=e.resumes;e.resumes=void 0;for(let e=0;e<r.length;e++)r[e](t)}return!0},LZ:()=>new o,NJ:l,Tx:e=>i.E2r(t=>e.effect?t(e.effect):(e.resumes??=[],e.resumes.push(t),i.OH5(()=>{let r=e.resumes;if(void 0===r)return;let n=r.indexOf(t);n>=0&&r.splice(n,1)})))})},3614(e,t,r){var n=r(3332),i=r(1594),a=r(5033),s=r(3952),o=r(2860),l=r(1554),d=r(4233);let c="~effect/Duration",u=BigInt(0),f=BigInt(1),p=BigInt(2),h=BigInt(10),m=BigInt(24),g=BigInt(60),y=BigInt(1e3),v=BigInt(1e6),b=e=>BigInt(e<0?Math.ceil(e-.5):Math.floor(e+.5)),_=(e,t)=>{let r=e.indexOf(".");if(-1===r)return BigInt(e)*t;let n="-"===e[0],i=e.slice(r+1),a=h**BigInt(i.length),s=(BigInt(e.slice(+!!n,r))*a+BigInt(i))*t,o=s/a+(s%a*p>=a?f:u);return n?-o:o},x=/^(-?\d+(?:\.\d+)?)\s+(nanos?|micros?|millis?|seconds?|minutes?|hours?|days?|weeks?)$/,w=e=>{switch(typeof e){case"number":return P(e);case"bigint":return N(e);case"string":{if("Infinity"===e)return M;if("-Infinity"===e)return A;let t=x.exec(e);if(!t)break;let[r,n,i]=t;if("nano"===i||"nanos"===i)return N(_(n,f));if("micro"===i||"micros"===i)return N(_(n,y));let a=Number(n);switch(i){case"milli":case"millis":return P(a);case"second":case"seconds":return R(a);case"minute":case"minutes":return j(a);case"hour":case"hours":return D(a);case"day":case"days":return U(a);case"week":case"weeks":return F(a)}break}case"object":{if(null===e)break;if(c in e)return e;if(Array.isArray(e)){if(2!==e.length||!e.every(d.Et))return k(e);if(Number.isNaN(e[0])||Number.isNaN(e[1]))return T;if(-1/0===e[0]||-1/0===e[1])return A;if(1/0===e[0]||1/0===e[1])return M;return O(b(1e9*e[0]+e[1]))}let t=0;if(e.weeks&&(t+=6048e5*e.weeks),e.days&&(t+=864e5*e.days),e.hours&&(t+=36e5*e.hours),e.minutes&&(t+=6e4*e.minutes),e.seconds&&(t+=1e3*e.seconds),e.milliseconds&&(t+=e.milliseconds),!e.microseconds&&!e.nanoseconds)return O(t);return O(b(1e6*t+(e.microseconds??0)*1e3+(e.nanoseconds??0)))}}return k(e)},k=e=>{throw Error(`Invalid Input: ${e}`)},S={_tag:"Millis",millis:0},I={_tag:"Infinity"},$={_tag:"NegativeInfinity"},E={[c]:c,[a.HR](){switch(this.value._tag){case"Millis":{let e=1e6*this.value.millis;return Number.isFinite(e)?a.tW(b(e)):a.ai(this.value.millis)}case"Nanos":return a.tW(this.value.nanos);default:return a.QK(this.value)}},[n.HR](e){return C(e)&&Y(this,e)},toString(){switch(this.value._tag){case"Infinity":return"Infinity";case"NegativeInfinity":return"-Infinity";case"Nanos":return`${this.value.nanos} nanos`;case"Millis":return`${this.value.millis} millis`}},toJSON(){switch(this.value._tag){case"Millis":return{_id:"Duration",_tag:"Millis",millis:this.value.millis};case"Nanos":return{_id:"Duration",_tag:"Nanos",nanos:String(this.value.nanos)};case"Infinity":return{_id:"Duration",_tag:"Infinity"};case"NegativeInfinity":return{_id:"Duration",_tag:"NegativeInfinity"}}},[s.FX](){return this.toJSON()},pipe(){return(0,l.tT)(this,arguments)}},O=e=>{let t=Object.create(E);return"number"==typeof e?isNaN(e)||0===e||Object.is(e,-0)?t.value=S:Number.isFinite(e)?Number.isInteger(e)?t.value={_tag:"Millis",millis:e}:t.value={_tag:"Nanos",nanos:b(1e6*e)}:t.value=e>0?I:$:e===u?t.value=S:t.value={_tag:"Nanos",nanos:e},t},C=e=>(0,d.i5)(e,c),T=O(0),M=O(1/0),A=O(-1/0),N=e=>O(e),P=e=>O(e),R=e=>O(1e3*e),j=e=>O(6e4*e),D=e=>O(36e5*e),U=e=>O(864e5*e),F=e=>O(6048e5*e),B=e=>{let t=w(e);switch(t.value._tag){case"Infinity":case"NegativeInfinity":throw Error("Cannot convert infinite duration to nanos");case"Nanos":return t.value.nanos;case"Millis":return b(1e6*t.value.millis)}},L=(0,i.XY)(2,(e,t)=>{switch(e.value._tag){case"Millis":return t.onMillis(e.value.millis);case"Nanos":return t.onNanos(e.value.nanos);case"Infinity":return t.onInfinity();case"NegativeInfinity":return(t.onNegativeInfinity??t.onInfinity)()}}),z=(0,i.XY)(3,(e,t,r)=>"Infinity"===e.value._tag||"NegativeInfinity"===e.value._tag||"Infinity"===t.value._tag||"NegativeInfinity"===t.value._tag?r.onInfinity(e,t):"Millis"===e.value._tag?"Millis"===t.value._tag?r.onMillis(e.value.millis,t.value.millis):r.onNanos(B(e),t.value.nanos):r.onNanos(e.value.nanos,B(t))),W=o.L8((e,t)=>z(e,t,{onMillis:(e,t)=>e<t?-1:+(e>t),onNanos:(e,t)=>e<t?-1:+(e>t),onInfinity:(e,t)=>e.value._tag===t.value._tag?0:"Infinity"===e.value._tag?1:"NegativeInfinity"===e.value._tag||"Infinity"===t.value._tag?-1:1})),J=o.bi(W),Y=(0,i.XY)(2,(e,t)=>z(e,t,{onMillis:(e,t)=>e===t,onNanos:(e,t)=>e===t,onInfinity:(e,t)=>e.value._tag===t.value._tag})),X=e=>{if("Infinity"===e.value._tag)return"Infinity";if("NegativeInfinity"===e.value._tag)return"-Infinity";if((e=>{switch(e.value._tag){case"Millis":return 0===e.value.millis;case"Nanos":return e.value.nanos===u;case"Infinity":case"NegativeInfinity":return!1}})(e))return"0";if((e=>{switch(e.value._tag){case"Millis":return e.value.millis<0;case"Nanos":return e.value.nanos<u;case"NegativeInfinity":return!0;case"Infinity":return!1}})(e))return"-"+X((e=>{switch(e.value._tag){case"Infinity":case"NegativeInfinity":return M;case"Millis":return e.value.millis<0?O(-e.value.millis):e;case"Nanos":return e.value.nanos<u?O(-e.value.nanos):e}})(e));let t=(e=>{if("Infinity"===e.value._tag)return{days:1/0,hours:1/0,minutes:1/0,seconds:1/0,millis:1/0,nanos:1/0};if("NegativeInfinity"===e.value._tag)return{days:-1/0,hours:-1/0,minutes:-1/0,seconds:-1/0,millis:-1/0,nanos:-1/0};let t=B(e),r=t<u,n=r?-t:t,i=n/v,a=i/y,s=a/g,o=s/g,l=r?-1:1;return{days:l*Number(o/m),hours:l*Number(o%m),minutes:l*Number(s%g),seconds:l*Number(a%g),millis:l*Number(i%y),nanos:l*Number(n%v)}})(e),r=[];return 0!==t.days&&r.push(`${t.days}d`),0!==t.hours&&r.push(`${t.hours}h`),0!==t.minutes&&r.push(`${t.minutes}m`),0!==t.seconds&&r.push(`${t.seconds}s`),0!==t.millis&&r.push(`${t.millis}ms`),0!==t.nanos&&r.push(`${t.nanos}ns`),r.join(" ")};r.d(t,{},{GP:X,MI:e=>"Infinity"!==e.value._tag&&"NegativeInfinity"!==e.value._tag,Tn:M,YA:R,bN:w,bi:J,cF:N,fP:e=>L(w(e),{onMillis:e=>e/1e3,onNanos:e=>Number(e)/1e9,onInfinity:()=>1/0,onNegativeInfinity:()=>-1/0}),kE:e=>L(w(e),{onMillis:i.D_,onNanos:e=>Number(e)/1e6,onInfinity:()=>1/0,onNegativeInfinity:()=>-1/0}),n$:C,ne:P,qv:A,v_:T})},2842(e,t,r){r.d(t,{Q56:()=>e_,jGc:()=>ex,U9h:()=>ew,Q7R:()=>w,hgn:()=>z,swY:()=>ez,Muk:()=>eT,as:()=>G,E2r:()=>M,MfU:()=>V,Tyx:()=>Q,osR:()=>Z,KuX:()=>H,loE:()=>K,RKA:()=>eB,_32:()=>eM,F_Q:()=>D,_r7:()=>eW,yeE:()=>ek,NS5:()=>X,fJG:()=>P,ATB:()=>R,pVV:()=>j,qIB:()=>L,Ab9:()=>eq,fn:()=>eF,D9k:()=>eU,vCS:()=>eG,jJl:()=>k,i4r:()=>eC,ar0:()=>eN,x6Z:()=>eP,yUA:()=>B,JkU:()=>N,XeO:()=>ea,GaK:()=>e$,yw5:()=>x,vVN:()=>eL,TjK:()=>q,q7Y:()=>eX,jkJ:()=>eJ,xm_:()=>ee,Z9x:()=>eY,YWq:()=>ec,khu:()=>eu,tvg:()=>ef,ZmZ:()=>A,S5A:()=>eS,cfM:()=>eI,uKv:()=>Y,QgK:()=>et,ivC:()=>I,Gte:()=>ep,PpN:()=>eh,PfK:()=>eg,KT6:()=>ed,Ket:()=>J,L5P:()=>ei,MY7:()=>eR,eJC:()=>ej,lKS:()=>eD,z8E:()=>ey,P1j:()=>ev,Pxi:()=>eb,Nav:()=>em,yy4:()=>el,PyW:()=>E,DYE:()=>O,OH5:()=>C,Mim:()=>W,dGm:()=>en,sFT:()=>er,wRz:()=>es,mgX:()=>eo,SvU:()=>U,$mh:()=>$,rfi:()=>eE,FcF:()=>eO,rIH:()=>T,iMI:()=>S,R6R:()=>F,fRP:()=>eA});var n=r(1594),i=r(2449),a=r(6297),s=(r(3614),r(1179));r(9315);var o=r(6771),l=r(5633);let d=(0,n.XY)(e=>(0,i.yw)(e[0]),(e,t,r)=>{let n;return s.aE(t)?a.PpN(e,t):(n=Array.isArray(t)?l.Um(...t):t,a.Pxi(t=>a.qIB(r?.local?l.H7(n,l.j6(),t):l.LT(n,t),t=>a.PpN(e,t))))});var c=r(1587),u=r(3753),f=r(6481);(e,t,r)=>a.qIB(o.xn(t),t=>{let n=o.d3.defaultValue();return a.h_t(a.i4r(a.Mim(a.qIB(a.DYE(()=>a.PfK(e,o.d3,n)),t),e=>a.OH5(()=>{n=e})),{disableYield:!0}),e=>i.$L(e)?a.PyW(e.value):r(e,0===n.attempt?c.none():c.some(n)))});let p=(0,n.XY)(3,(e,t,r)=>a.qIB(o.xn(t),t=>{let n,i=o.d3.defaultValue(),s=a.h_t(a.DYE(()=>a.PfK(e,o.d3,i)),e=>(n=e,a.qIB(t(e),e=>(i=e,s))));return u.m8(s,e=>(0,f.s)(()=>r(n,e)))})),h=(0,n.XY)(2,(e,t)=>p(e,"function"==typeof t?t(n.D_):o.GM(t)?t:g(t),a.fJG)),m=o.le(o.i4),g=e=>{let t=e.schedule?o.le(e.schedule):m;return e.while&&(t=o.E6(t,({input:t})=>{let r=e.while(t);return i.yw(r)?r:a.PyW(r)})),e.until&&(t=o.E6(t,({input:t})=>{let r=e.until(t);return i.yw(r)?a.TjK(r,e=>!e):a.PyW(!r)})),void 0!==e.times&&(t=o.E6(t,({attempt:t})=>a.PyW(t<=e.times))),t},y=o.t5(1);var v=r(2275);let b=r(3332).Xq({_E:e=>e,_A:e=>e,_R:e=>e});({...i.In,"~effect/Request":b}),r(3909);var _=r(4600);i.$n;let x=i.yw,w=a.Q7R;a.jBG,a.TSs,a.tfT,a.i8i,a.kAe;let k=a.jJl;a.d5f;let S=a.iMI,I=a.ivC,$=a.$mh,E=a.PyW;a.lwU,a.nGE;let O=a.DYE,C=a.OH5,T=a.rIH;a.Vxk;let M=a.E2r,A=a.ZmZ;a.Do,a.JrD,a.uVU,a.oIE;let N=a.JkU,P=a.fJG;a.gOk;let R=a.ATB,j=a.pVV,D=a.F_Q,U=a.SvU;a.m9E,a.KN3;let F=i.R6;i.Hq;let B=a.yUA;a.sVm,a.pkL,a.bJ;let L=a.qIB;a.Bqz;let z=a.hgn,W=a.Mim,J=a.Ket,Y=a.uKv,X=a.NS5,q=a.TjK,G=a.as;a.Xx$,a.NLW,a.UUz,a.yU6,a.OYO;let V=a.h_t,H=a.KuX,K=a.loE;a.AXC,a.zt4,a.scW;let Q=a.Tyx;a.Fig,a.XWm;let Z=a.osR;a.U9Y,a.sJf,a.rNk;let ee=a.xm_;a.UcN;let et=a.QgK,er=a.sFT;a.k$L;let en=a.dGm;a.cA6,a.bKC,a.nAi,a.u4Y;let ei=h;a._Sg;let ea=a.XeO;a.GrF,a.$$g,a.DM4,a.Dd;let es=a.wRz;a.D52;let eo=a.mgX;a.cbG;let el=a.yy4;a.ayu,a.Vdx,a.FfP,a.O4F;let ed=a.KT6;a.pbD,a.x1Q,a.E8K,a.Pm0,a.VtY,a.W$I,a.ahH,a.z7s;let ec=a.YWq;a.G$Q,a.D$$,a.NZb,a.wR5;let eu=a.khu,ef=a.tvg;a.N6O,a.oJd,a._OA,a.sxi;let ep=d,eh=a.PpN;a.oao,a.euC;let em=a.Nav;a.r_d,a.bUZ,a.L_I;let eg=a.PfK;a.c7E;let ey=a.z8E,ev=a.P1j,eb=a.Pxi,e_=a.Q56;a.N24;let ex=a.jGc,ew=a.U9h,ek=a.yeE,eS=a.S5A;a.BeE,a.iKM,a.r7h;let eI=a.cfM;a.fGe,a.uRq,a.PO3,a.Rgn,a.CJw;let e$=a.GaK;a.Inz,a.nAr;let eE=a.rfi,eO=a.FcF;a.eMl,a.dsN;let eC=a.i4r;a.aAq,a.Xrv,a.kJM,a._o1,a.nDN,a.MaT;let eT=a.Muk;a.ww9;let eM=a._32;a.Wj8,a.Fu6,a.WbR,a.A_r,a.Z98,a.Rd$,a.gvr;let eA=a.fRP;a.zr8,a.hq,a.zhn;let eN=a.ar0,eP=a.x6Z;a.yxg,a.PCg,a.pEE,a.ABT;let eR=a.MY7,ej=a.eJC;a.lSz,a.bPG,a.pR5,a.v2Q,a.NpQ,a.jqV,a.HZF,a.lE;let eD=a.lKS;a.rfH;let eU=a.D9k,eF=a.fn,eB=a.RKA;a.lIX;let eL=a.lIX("Error"),ez=(0,n.XY)(e=>x(e[0]),(e,...t)=>a.bUZ(e,_.iL,e=>{let r=1===t.length?{...e,...t[0]}:{...e};return 1===t.length||v.x(r,t[0],t[1]),r}));a.gsV;let eW=(e,t,r)=>(...n)=>M(i=>{try{e(...n,(e,r)=>{e?i(P(t?t(e,n):e)):i(E(r))})}catch(e){i(r?P(r(e,n)):D(e))}}),eJ=a.jkJ,eY=a.Z9x,eX=a.q7Y,eq=a.Ab9;a.UVN;let eG=a.vCS},3811(e,t,r){var n=r(2449);r.d(t,{},{bp:e=>(0,n.yj)({op:e.label,[n._3]:e.evaluate})})},3332(e,t,r){var n=r(5033),i=r(5844),a=r(4233);let s="~effect/Equal";function o(){return 1==arguments.length?e=>l(e,arguments[0]):l(arguments[0],arguments[1])}function l(e,t){if(e===t)return!0;if(null==e||null==t)return!1;let r=typeof e;return r===typeof t&&("number"===r&&e!=e&&t!=t||!("object"!==r&&"function"!==r||i.J3.has(e)||i.J3.has(t))&&function(e,t){let r=c.length;for(let n=r;n-- >0;)if(c[n]===e&&u[n]===t)return!0;if(r)return d(e,t);let n=f.get(e);n||f.set(e,n=new WeakMap);let i=n.get(t);return void 0===i&&n.set(t,i=d(e,t)),i}(e,t))}function d(e,t){c.push(e),u.push(t);try{return function(e,t){if(n.tW(e)!==n.tW(t))return!1;if(e instanceof Date){if(!(t instanceof Date))return!1;let r=e.getTime(),n=t.getTime();return r===n||Number.isNaN(r)&&Number.isNaN(n)}if(e instanceof RegExp)return t instanceof RegExp&&e.toString()===t.toString();let r=y(e);if(r!==y(t)||"function"==typeof e&&!r)return!1;if(r)return e[s](t);if(Array.isArray(e))return!!Array.isArray(t)&&e.length===t.length&&function(e,t){for(let r=0;r<e.length;r++)if(!l(e[r],t[r]))return!1;return!0}(e,t);if(ArrayBuffer.isView(e)){let r=e instanceof DataView;return!!ArrayBuffer.isView(t)&&e.byteLength===t.byteLength&&r===t instanceof DataView&&(r?p((0,i.j)(e),(0,i.j)(t)):p(e,t))}if(e instanceof Map)return t instanceof Map&&e.size===t.size&&h(e,t,m,g);else if(e instanceof Set)return t instanceof Set&&e.size===t.size&&h(e,t,n.tW,l);var a=e,o=t;let d=(0,i.Xp)(a),c=(0,i.Xp)(o);if(d.size!==c.size)return!1;for(let e of d)if(!c.has(e)||!l(a[e],o[e]))return!1;return!0}(e,t)}finally{c.pop(),u.pop()}}let c=[],u=[],f=new WeakMap;function p(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}function h(e,t,r,n){let i=new Map;for(let e of t){let t=r(e),n=i.get(t);n?n.push(e):i.set(t,[e])}e:for(let t of e){let e=i.get(r(t));if(e){for(let r=0;r<e.length;r++)if(n(t,e[r])){e[r]=e[e.length-1],e.pop();continue e}}return!1}return!0}let m=e=>n.tW(e[0]),g=(e,t)=>l(e[0],t[0])&&l(e[1],t[1]),y=e=>(0,a.i5)(e,s);r.d(t,{aI:()=>o},{HR:s,Xq:e=>(i.J3.add(e),e),jI:()=>o})},7876(e,t,r){let n=e=>(t,r)=>t===r||e(t,r),i=(e,t)=>e===t,a=n((e,t)=>globalThis.Number.isNaN(e)&&globalThis.Number.isNaN(t));function s(e){return n((t,r)=>{if(t.length!==r.length)return!1;for(let n=0;n<t.length;n++)if(!e[n](t[n],r[n]))return!1;return!0})}function o(e){return n((t,r)=>{if(t.length!==r.length)return!1;for(let n=0;n<t.length;n++)if(!e(t[n],r[n]))return!1;return!0})}function l(e){let t=Reflect.ownKeys(e);return n((r,n)=>{for(let i of t)if(!e[i](r[i],n[i]))return!1;return!0})}r.d(t,{O3:()=>o,_k:()=>l,rd:()=>s},{L8:n,Qw:i,YZ:()=>i,wN:a})},6526(e,t,r){var n=r(2449),i=r(6297);n.IH,n.b9;let a=n.xt,s=n.cb,o=n.Rk;n.V2,i._sz;let l=i.x5l,d=i.CoE,c=i.VE1;i._mh,i.YDM,i.lNM,i.K$2,i.GUt,i.HIt,i.yJo,i._OD,i.jCT,i.Wtn,i.v9O,i.zPu,i.EkE,i.Hox,i.ely,i.kMI,i.Sv3,i.lgw,r.d(t,{},{AT:s,N6:c,Py:a,fJ:o,oJ:d,rI:l})},1958(e,t,r){var n=r(4233),i=r(1279);function a(e,t){let r=t?.space??0,a=new WeakSet,l=r?"number"==typeof r?" ".repeat(r):r:"",u=(e,t)=>{let r=e?.constructor;return r&&r!==Object.prototype.constructor&&r.name?`${r.name}(${t})`:t};return function e(r,f=0){try{return function(r,f=0){if("string"==typeof r)return JSON.stringify(r);if("number"==typeof r||null==r||"boolean"==typeof r||"symbol"==typeof r)return String(r);if("bigint"==typeof r)return String(r)+"n";if("object"==typeof r||"function"==typeof r){let p;if(a.has(r))return s;if(a.add(r),i.uC in r)p=e((0,i.f6)(r),f);else if(Array.isArray(r)){let t,n;p=!l||r.length<=1?`[${r.map(t=>e(t,f)).join(",")}]`:`[
231
231
  ${t=f+1,l.repeat(t)}${r.map(t=>e(t,f+1)).join(",\n"+(n=f+1,l.repeat(n)))}
232
232
  ${l.repeat(f)}]`}else if(r instanceof Date)p=d(r);else if(!t?.ignoreToString&&n.i5(r,"toString")&&"function"==typeof r.toString&&r.toString!==Object.prototype.toString&&r.toString!==Array.prototype.toString){let t=function(e){try{let t=e.toString();return"string"==typeof t?t:String(t)}catch{return"[toString threw]"}}(r);p=r instanceof Error&&void 0!==r.cause?`${t} (cause: ${e(r.cause,f)})`:t}else if(Symbol.iterator in r)p=`${r.constructor.name}(${e(Array.from(r),f)})`;else{let t=(e=>{try{return Reflect.ownKeys(e)}catch{return["[ownKeys threw]"]}})(r);if(!l||t.length<=1){let n=`{${t.map(t=>`${o(t)}:${e(c(r,t),f)}`).join(",")}}`;p=u(r,n)}else{let n=`{
233
233
  ${t.map(t=>{let n;return`${n=f+1,l.repeat(n)}${o(t)}: ${e(c(r,t),f+1)}`}).join(",\n")}
234
- ${l.repeat(f)}}`;p=u(r,n)}}return a.delete(r),p}return String(r)}(r,f)}catch{return("object"==typeof r&&null!==r||"function"==typeof r)&&a.delete(r),"[inspection threw]"}}(e,0)}let s="[Circular]";function o(e){return"string"==typeof e?JSON.stringify(e):String(e)}function l(e){return e.map(e=>`[${o(e)}]`).join("")}function d(e){try{return e.toISOString()}catch{return"Invalid Date"}}function c(e,t){try{return e[t]}catch{return"[property access threw]"}}function u(e,t){let r=[];return JSON.stringify(e,function(e,t){let s=Object.getOwnPropertyDescriptor(this,e)?.value,o=n.i5(s,i.uC)?(0,i.E$)(s):(0,i.E$)(t);if("bigint"==typeof o)return a(o);if("object"!=typeof o||null===o)return o;let l=o instanceof Error&&!n.i5(o,"toJSON")?{...o,name:o.name,message:o.message}:o;for(;r.length>0&&r[r.length-1]!==this;)r.pop();if(!r.includes(o))return r.push(o),l!==o&&r.push(l),l},t?.space)??"null"}r.d(t,{GP:()=>a,IB:()=>u,Yq:()=>d,_r:()=>o,jV:()=>l})},1594(e,t,r){var n=r(1554);let i=e=>()=>e,a=i(!0),s=i(!1),o=i(null),l=i(void 0);function d(e,...t){return(0,n.tT)(e,t)}function c(e,t,r,n,i,a,s,o,l){switch(arguments.length){case 1:return e;case 2:return function(){return t(e.apply(this,arguments))};case 3:return function(){return r(t(e.apply(this,arguments)))};case 4:return function(){return n(r(t(e.apply(this,arguments))))};case 5:return function(){return i(n(r(t(e.apply(this,arguments)))))};case 6:return function(){return a(i(n(r(t(e.apply(this,arguments))))))};case 7:return function(){return s(a(i(n(r(t(e.apply(this,arguments)))))))};case 8:return function(){return o(s(a(i(n(r(t(e.apply(this,arguments))))))))};case 9:return function(){return l(o(s(a(i(n(r(t(e.apply(this,arguments)))))))))}}}function u(e){let t=new WeakMap;return r=>{let n=t.get(r);if(void 0!==n)return n;let i=e(r);return t.set(r,i),i}}function f(e){let t=new WeakMap;return r=>{let n=t.get(r);if(void 0!==n)return n;let i=e(r);return t.set(r,i),i!==r&&t.set(i,i),i}}r.d(t,{Bj:()=>u,Fs:()=>d,L3:()=>c,qE:()=>f},{D_:e=>e,MN:l,XR:o,XY:function(e,t){if("function"==typeof e)return function(){return e(arguments)?t.apply(this,arguments):e=>t(e,...arguments)};switch(e){case 0:case 1:throw RangeError(`Invalid arity ${e}`);case 2:return function(e,r){return arguments.length>=2?t(e,r):function(r){return t(r,e)}};case 3:return function(e,r,n){return arguments.length>=3?t(e,r,n):function(n){return t(n,e,r)}};default:return function(){if(arguments.length>=e)return t.apply(this,arguments);let r=arguments;return function(e){return t(e,...r)}}}},Yi:l,dY:i,f4:s,ue:a})},5033(e,t,r){r.d(t,{YO:()=>b,kg:()=>c,tW:()=>o,ai:()=>p,ky:()=>u,yT:()=>l,Yj:()=>h,QK:()=>g,uN:()=>m,HR:()=>s});var n=r(1594),i=r(5844);let a=0,s="~effect/Hash",o=e=>{switch(typeof e){case"number":return p(e);case"bigint":return h(e.toString(10));case"string":return h(e);case"function":case"object":if(null===e);else if(e instanceof Date){if(Number.isNaN(e.getTime()))return h("Invalid Date");return h(e.toISOString())}else{let t;if(e instanceof RegExp)return h(e.toString());if(i.J3.has(e))return l(e);let r=k.get(e);if(void 0!==r)return r;if(S.has(e))return a++,h("[Circular]");S.add(e);let n=a;try{t=s in e?e[s]():"function"==typeof e?l(e):e instanceof DataView?b((0,i.j)(e)):Array.isArray(e)||ArrayBuffer.isView(e)?b(e):e instanceof Map?v(e):e instanceof Set?x(e):g(e)}finally{S.delete(e)}return n===a&&k.set(e,t),t}}return u(d(h(String(e))))},l=e=>(w.has(e)||w.set(e,u(0x100000000*Math.random()|0)),w.get(e)),d=e=>(e^=e>>>16,e=Math.imul(e,0x85ebca6b),e^=e>>>13,(e=Math.imul(e,0xc2b2ae35))^e>>>16),c=(0,n.XY)(2,(e,t)=>d(Math.imul(e,0x9e3779b1)+Math.imul(t,0x85ebca6b))),u=e=>0xbfffffff&e|e>>>1&0x40000000,f=new DataView(new ArrayBuffer(8)),p=e=>{let t=0|e;return t===e?u(t):(f.setFloat64(0,e!=e?0/0:e),u(c(f.getInt32(0),f.getInt32(4))))},h=e=>{let t=5381,r=e.length;for(;r;)t=33*t^e.charCodeAt(--r);return u(t)},m=(e,t)=>{let r=12289;for(let n of t)r^=c(o(n),o(e[n]));return u(r)},g=e=>m(e,(0,i.Xp)(e)),y=(e,t)=>r=>{let n=e;for(let e of r)n^=t(e);return u(n)},b=e=>{let t=6151;for(let r of e)t=c(t,o(r));return u(t)},v=y(h("Map"),([e,t])=>c(o(e),o(t))),_=h("Set"),x=y(_,e=>c(_,o(e))),w=new WeakMap,k=new WeakMap,S=new WeakSet},3952(e,t,r){var n=r(1958),i=r(4233),a=r(1279);let s=Symbol.for("nodejs.util.inspect.custom"),o=e=>{try{if(e=(0,a.E$)(e),i.i5(e,"toJSON")&&i.Tn(e.toJSON)&&0===e.toJSON.length)return e.toJSON();if(Array.isArray(e))return e.map(o);return e}catch{return"[toJSON threw]"}};r.d(t,{},{FX:s,ZK:(e,t=2)=>{if("string"==typeof e)return e;try{return"object"==typeof e?(0,n.IB)(e,{space:t}):(0,n.GP)(e,{space:t})}catch{return String(e)}},aB:o,os:{toJSON(){return o(this)},[s](){return this.toJSON()},toString(){return(0,n.GP)(this.toJSON())}}})},592(e,t,r){var n=r(1594),i=r(1587),a=r(4233);let s=(0,n.XY)(2,(e,t)=>{let r=0;for(let n of e){let e=t(n,r);if((0,a.Lm)(e)){if(e)return i.some(n)}else if(i.isSome(e))return e;r++}return i.none()}),o=(0,n.XY)(2,(e,t)=>({[Symbol.iterator](){let r=e[Symbol.iterator](),n=0;return{next(){let e=r.next();for(;!e.done;){if(t(e.value,n++))return{done:!1,value:e.value};e=r.next()}return{done:!0,value:void 0}}}}}));r.d(t,{},{i8:s,pb:o})},5633(e,t,r){var n=r(1179),i=r(9237),a=r(1594),s=r(2449),o=r(6297),l=r(1554),d=r(5744);let c="~effect/Layer/MemoMap",u=(e,t)=>"Closed"!==t.state._tag&&(e.observers++,o.MbZ(t,{},e.finalizer),!0),f={"~effect/Layer":{_ROut:a.D_,_E:a.D_,_RIn:a.D_},pipe(){return(0,l.tT)(this,arguments)}},p=e=>{let t=Object.create(f);return t.build=e,t},h=e=>p((t,r)=>{let n=d.Fp(r);return o.cfM(e(t,n),e=>"Failure"===e._tag?d.VN(n,e):o.rIH)});class m{get[c](){return c}parent;constructor(e){this.parent=e}map=new Map;get(e,t){let r=this.map.get(e);return r?(u(r,t),r.deferred.effect??i.Tx(r.deferred)):this.parent?.get(e,t)}getOrElseMemoize(e,t,r){return o.DYE(()=>{let n;return o.r7h(o.DYE(()=>{var a;let s,l=this.get(e,t);if(l)return l;let c=(a=this,s={observers:0,deferred:i.LZ(),scope:d.LZ(),finalizer:t=>o.DYE(()=>--s.observers>0?o.rIH:(a.map.delete(e),d.VN(s.scope,t)))});return u(c,t)?(n=c.deferred,this.map.set(e,c),r(this,c.scope)):r(this,t)}),e=>{n&&i.$w(n,e)})})}}let g=()=>new m;class y extends(n.kl())("effect/Layer/CurrentMemoMap"){static forkOrCreate(e){let t=n.Y6(e,y);return t?new m(t):g()}}let b=(0,a.XY)(3,(e,t,r)=>o.PfK(o.TjK(e.build(t,r),n.WQ(y,t)),y,t)),v=(0,a.XY)(2,(e,t)=>s.R6(r=>b(e,y.forkOrCreate(r.context),t))),_=e=>p((0,a.dY)(o.PyW(e))),x=(e,t)=>w(o.TjK(t,t=>n.L8(e,t))),w=e=>{var t;let r;return t=(t,r)=>d.Gt(e,r),r=h((e,n)=>e.getOrElseMemoize(r,n,t))},k=(e,t,r)=>{let i=d.Fp(r,"parallel");return o.jJl(e,e=>e.build(t,d.Fp(i,"sequential")),{concurrency:e.length}).pipe(o.TjK(e=>n.Um(...e)))},S=(e,t,r)=>h((n,i)=>o.qIB(Array.isArray(t)?k(t,n,i):t.build(n,i),t=>e.build(n,i).pipe(o.PpN(t),o.TjK(e=>r(e,t))))),I=(0,a.XY)(2,(e,t)=>S(e,t,a.D_)),$=(0,a.XY)(2,(e,t)=>S(e,t,(e,t)=>n.h1(t,e)));r.d(t,{},{Gt:I,H7:b,LT:v,Py:function(){return 1==arguments.length?e=>_(n.L8(arguments[0],e)):_(n.L8(arguments[0],arguments[1]))},QZ:function(){return 1==arguments.length?e=>x(arguments[0],e):x(arguments[0],arguments[1])},S5:$,Um:(...e)=>h((t,r)=>k(e,t,r)),j6:g})},1587(e,t,r){r.r(t);var n=r(9519),i=r(3332),a=r(7876),s=r(1594),o=r(7425),l=r(7731),d=r(2275),c=r(2563),u=r(2860),f=r(4233),p=r(636);let h=()=>l.dv,m=l.zN,g=l.oL,y=l.$I,b=l.Ru,v=(0,s.XY)(2,(e,{onNone:t,onSome:r})=>y(e)?t():r(e.value)),_=c.Oz,x=c.L8,w=(0,s.XY)(2,(e,t)=>y(e)?t():e.value),k=(0,s.XY)(2,(e,t)=>y(e)?t():e),S=(0,s.XY)(2,(e,t)=>y(e)?m(t()):e),I=(0,s.XY)(2,(e,t)=>y(e)?M(t(),c.Py):M(e,c.fJ)),$=e=>null==e?h():m(e),E=w(s.XR),O=w(s.MN),C=(0,s.XY)(2,(e,t)=>{if(b(e))return e.value;throw t()}),T=C(()=>Error("getOrThrow called on a None")),M=(0,s.XY)(2,(e,t)=>y(e)?h():m(t(e.value))),P=(0,s.XY)(2,(e,t)=>M(e,()=>t)),A=P(void 0),N=m(void 0),R=(0,s.XY)(2,(e,t)=>y(e)?h():t(e.value)),j=(0,s.XY)(2,(e,t)=>R(e,e=>{let r=(0,f.Tn)(t)?t(e):t;return g(r)?r:m(r)})),D=(0,s.XY)(2,(e,t)=>y(e)?h():$(t(e.value))),U=R(s.D_),F=(0,s.XY)(2,(e,t)=>R(e,()=>t)),B=(0,s.XY)(2,(e,t)=>z(e,()=>t)),L=(0,s.XY)(2,(e,t)=>r=>R(e(r),t)),z=(0,s.XY)(2,(e,t)=>R(e,e=>M(t(e),()=>e))),W=(0,s.XY)(2,(e,t)=>b(e)&&b(t)?m([e.value,t.value]):h()),J=(0,s.XY)(2,(e,t)=>{if(y(e))return h();let r=[e.value];for(let e of t){if(y(e))return h();r.push(e.value)}return m(r)}),Y=(0,s.XY)(3,(e,t,r)=>M(W(e,t),([e,t])=>r(e,t))),X=(0,s.XY)(3,(e,t,r)=>{let n=t;for(let t of e)b(t)&&(n=r(n,t.value));return n}),q=(0,s.XY)(2,(e,t)=>{if(y(e))return[h(),h()];let r=t(e.value);return c.N6(r)?[h(),m(r.failure)]:[m(r.success),h()]}),G=(0,s.XY)(2,(e,t)=>{if(y(e))return h();let r=t(e.value);return c.oJ(r)?m(r.success):h()}),V=(0,s.XY)(2,(e,t)=>y(e)?h():t(e.value)?m(e.value):h()),H=(0,s.XY)(2,(e,t)=>t(e)?m(e):h()),K=e=>(0,s.XY)(2,(t,r)=>!y(t)&&e(t.value,r)),Q=K(i.jI()),Z=(0,s.XY)(2,(e,t)=>!y(e)&&t(e.value)),ee=o.Jr(M),et=o.zM(M),er=o.oI(M,R),en=m({});function ei(e){return p.L((t,r)=>y(t)?r:y(r)?t:m(e.combine(t.value,r.value)),h())}function ea(e){return n.L8((t,r)=>y(t)||y(r)?h():m(e.combine(t.value,r.value)))}function es(e){let t=ea(e).combine,r=m(e.initialValue);return p.L(t,r,e=>{let n=r;for(let r of e)if(y(n=t(n,r)))break;return n})}r.d(t,{makeCombinerFailFast:()=>ea,makeReducer:()=>ei,makeReducerFailFast:()=>es},{Do:en,all:e=>{if(Symbol.iterator in e){let t=[];for(let r of e){if(y(r))return h();t.push(r.value)}return m(t)}let t={};for(let r of Object.keys(e)){let n=e[r];if(y(n))return h();d.x(t,r,n.value)}return m(t)},andThen:j,as:P,asVoid:A,bind:er,bindTo:ee,composeK:L,contains:Q,containsWith:K,exists:Z,filter:V,filterMap:G,firstSomeOf:e=>{let t=h();for(t of e)if(b(t))break;return t},flatMap:R,flatMapNullishOr:D,flatten:U,fromIterable:e=>{for(let t of e)return m(t);return h()},fromNullOr:e=>null===e?h():m(e),fromNullishOr:$,fromUndefinedOr:e=>void 0===e?h():m(e),gen:(...e)=>{let t=(1===e.length?e[0]:e[1].bind(e[0]))(),r=t.next();for(;!r.done;){let e=r.value;if(y(e))return e;r=t.next(e.value)}return m(r.value)},getFailure:x,getOrElse:w,getOrNull:E,getOrThrow:T,getOrThrowWith:C,getOrUndefined:O,getSuccess:_,isNone:y,isOption:g,isSome:b,let:et,lift2:e=>(0,s.XY)(2,(t,r)=>Y(t,r,e)),liftNullishOr:e=>(...t)=>$(e(...t)),liftPredicate:H,liftThrowable:e=>(...t)=>{try{return m(e(...t))}catch{return h()}},makeEquivalence:e=>a.L8((t,r)=>y(t)?y(r):!y(r)&&e(t.value,r.value)),makeOrder:e=>u.L8((t,r)=>b(t)?b(r)?e(t.value,r.value):1:-1),map:M,match:v,none:h,orElse:k,orElseResult:I,orElseSome:S,partitionMap:q,product:W,productMany:J,reduceCompact:X,some:m,tap:z,toArray:e=>y(e)?[]:[e.value],toRefinement:e=>t=>b(e(t)),void:N,zipLeft:B,zipRight:F,zipWith:Y})},2860(e,t,r){var n=r(1594);function i(e){return(t,r)=>t===r?0:e(t,r)}let a=i((e,t)=>e<t?-1:1),s=i((e,t)=>globalThis.Number.isNaN(e)&&globalThis.Number.isNaN(t)?0:globalThis.Number.isNaN(e)?-1:globalThis.Number.isNaN(t)?1:e<t?-1:1),o=i((e,t)=>e<t?-1:1),l=(0,n.XY)(2,(e,t)=>i((r,n)=>e(t(r),t(n)))),d=l(s,e=>e.getTime());function c(e){return i((t,r)=>{let n=e.length;for(let i=0;i<n;i++){let n=e[i](t[i],r[i]);if(0!==n)return n}return 0})}function u(e){return i((t,r)=>{let n=t.length,i=r.length,a=Math.min(n,i);for(let n=0;n<a;n++){let i=e(t[n],r[n]);if(0!==i)return i}return s(n,i)})}function f(e){let t=Object.keys(e);return i((r,n)=>{for(let i of t){let t=e[i](r[i],n[i]);if(0!==t)return t}return 0})}let p=e=>(0,n.XY)(2,(t,r)=>-1===e(t,r)),h=e=>(0,n.XY)(2,(t,r)=>1===e(t,r)),m=e=>(0,n.XY)(2,(t,r)=>t===r||1>e(t,r)?t:r),g=e=>(0,n.XY)(2,(t,r)=>t===r||e(t,r)>-1?t:r);r.d(t,{L8:()=>i,O3:()=>u,_k:()=>f,rd:()=>c},{Bt:e=>(0,n.XY)(2,(t,r)=>!p(e)(t,r.minimum)&&!h(e)(t,r.maximum)),OW:e=>(0,n.XY)(2,(t,r)=>-1!==e(t,r)),Qf:a,Qw:o,T9:g,bi:e=>(0,n.XY)(2,(t,r)=>1!==e(t,r)),hl:p,jk:m,n9:d,qE:e=>(0,n.XY)(2,(t,r)=>m(e)(r.maximum,g(e)(r.minimum,t))),wN:s,yJ:h,zQ:l})},1554(e,t,r){let n=(e,t)=>{switch(t.length){case 0:return e;case 1:return t[0](e);case 2:return t[1](t[0](e));case 3:return t[2](t[1](t[0](e)));case 4:return t[3](t[2](t[1](t[0](e))));case 5:return t[4](t[3](t[2](t[1](t[0](e)))));case 6:return t[5](t[4](t[3](t[2](t[1](t[0](e))))));case 7:return t[6](t[5](t[4](t[3](t[2](t[1](t[0](e)))))));case 8:return t[7](t[6](t[5](t[4](t[3](t[2](t[1](t[0](e))))))));case 9:return t[8](t[7](t[6](t[5](t[4](t[3](t[2](t[1](t[0](e)))))))));default:{let r=e;for(let e=0,n=t.length;e<n;e++)r=t[e](r);return r}}},i={pipe(){return n(this,arguments)}},a=function(){function e(){}return e.prototype=i,e}();r.d(t,{},{Xs:a,bp:i,tT:n})},4233(e,t,r){var n=r(1594);function i(e){return"string"==typeof e}function a(e){return"number"==typeof e}function s(e){return"boolean"==typeof e}function o(e){return"bigint"==typeof e}function l(e){return"symbol"==typeof e}function d(e){return i(e)||a(e)||l(e)}function c(e){return"function"==typeof e}function u(e){return void 0===e}function f(e){return void 0!==e}function p(e){return null!==e}function h(e){return null==e}function m(e){return null!=e}function g(e){return!1}function y(e){return!0}function b(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function v(e){return"object"==typeof e&&null!==e||c(e)}let _=(0,n.XY)(2,(e,t)=>v(e)&&t in e),x=(0,n.XY)(2,(e,t)=>_(e,"_tag")&&e._tag===t);function w(e){return e instanceof Error}function k(e){return e instanceof Date}function S(e){return _(e,Symbol.iterator)||i(e)}function I(e){return e instanceof RegExp}r.d(t,{$P:()=>k,Bm:()=>l,EA:()=>f,Et:()=>a,Fw:()=>v,Gv:()=>b,Kg:()=>i,Lm:()=>s,Pd:()=>g,Pe:()=>p,Tn:()=>c,Vq:()=>m,b0:()=>u,bJ:()=>w,gd:()=>I,hL:()=>d,sI:()=>o,t8:()=>y,uy:()=>h,xZ:()=>S},{$J:x,i5:_})},3753(e,t,r){var n=r(719),i=r(6526),a=r(1594),s=r(6297),o=r(9315);let l=(0,a.XY)(2,(e,t)=>s.rNk(e,u,e=>t(e))),d=e=>"Fail"===e._tag&&n.$L(e.error),c=e=>{let t,r=!1;for(let n of e.reasons)d(n)?t??=n.error:"Interrupt"!==n._tag&&(r=!0);return void 0===t?o.fJ(e):r?o.fJ(n.kO(e.reasons.filter(e=>!d(e)))):o.Py(t)},u=e=>{let t=c(e);return o.N6(t)?t:o.Py(t.success.value)},f=(0,a.XY)(2,(e,t)=>s.khu(e,{onSuccess:t.onSuccess,onFailure:e=>{let r=c(e);return o.N6(r)?t.onFailure(r.failure):t.onDone(r.success.value)}}));r.d(t,{},{Og:e=>e.reasons.some(d),aU:e=>{let t=c(e);return o.N6(t)?i.AT(t.failure):i.Py(t.success.value)},m8:l,tv:f})},915(e,t,r){var n=r(1594),i=r(2275);let a=(0,n.XY)(2,(e,t)=>{let r=[];for(let n of l(e))r.push(t(n,e[n]));return r})((e,t)=>[e,t]),s=(0,n.XY)(2,(e,t)=>Object.hasOwn(e,t)),o=(0,n.XY)(2,(e,t)=>{let r={...e};for(let n of l(e))i.x(r,n,t(e[n],n));return r}),l=e=>Object.keys(e);i.x,r.d(t,{},{T9:e=>{let t=(0,n.XY)(2,(t,r)=>{for(let n of l(t))if(!s(r,n)||!e(t[n],r[n]))return!1;return!0});return(e,r)=>t(e,r)&&t(r,e)},Tj:o,Wo:a})},1279(e,t,r){var n=r(1554),i=r(4233);let a=Symbol.for("~effect/Redactable");function s(e){return(0,i.i5)(e,a)?o(e):e}function o(e){return e[a](globalThis[l]?.context??c)}let l="~effect/Fiber/currentFiber",d=new Map,c={"~effect/Context":{},base:d,depth:0,mapUnsafe:d,pipe(){return(0,n.tT)(this,arguments)}};r.d(t,{E$:()=>s,f6:()=>o},{fL:l,uC:a})},7011(e,t,r){r.d(t,{L8:()=>d,Uq:()=>u});var n=r(3332),i=r(5033),a=r(2449);let s=new WeakMap;var o=r(4233);let l="~effect/Redacted",d=(e,t)=>{let r=Object.create(c);return t?.label&&(r.label=t.label),s.set(r,e),r},c={[l]:{_A:e=>e},label:void 0,...a.fU,toJSON(){return this.toString()},toString(){return`<redacted${(0,o.Kg)(this.label)?":"+this.label:""}>`},[i.HR](){return i.tW(s.get(this))},[n.HR](e){return(0,o.i5)(e,l)&&n.aI(s.get(this),s.get(e))}},u=e=>{if(s.has(e))return s.get(e);throw Error("Unable to get redacted value"+(e.label?` with label: "${e.label}"`:""))}},636(e,t,r){function n(e,t,r){return{combine:e,initialValue:t,combineAll:r??(r=>{let n=t;for(let t of r)n=e(n,t);return n})}}r.d(t,{L:()=>n})},4600(e,t,r){var n=r(6297),i=r(6712);let a=i.iL;i.Gl,i.d8,i.vA;let s=i.zQ;i.rf,i.ce,i.ls,i.nU,i.aG,n.d$_,n.olX,r.d(t,{},{iL:a,zQ:s})},9315(e,t,r){var n=r(1594),i=r(7731),a=r(2563);let s=a.Py,o=a.fJ;a.sV,a.aI;let l=a.N6,d=a.oJ;a.Oz,a.L8;let c=(0,n.XY)(2,(e,t)=>l(e)?o(t(e.failure)):e),u=(0,n.XY)(2,(e,t)=>d(e)?s(t(e.success)):e),f=(0,n.XY)(2,(e,{onFailure:t,onSuccess:r})=>l(e)?t(e.failure):r(e.success)),p=(0,n.XY)(2,(e,t)=>{if(d(e))return e.success;throw t(e.failure)})(n.D_),h=(0,n.XY)(2,(e,t)=>l(e)?o(e.failure):t(e.success));i.dv,r.d(t,{},{Gp:p,N6:l,Py:s,Tj:u,YW:f,fJ:o,oJ:d,qI:h,xm:c})},6771(e,t,r){var n=r(719),i=r(1179),a=r(3614),s=r(1594),o=r(2449),l=r(6297),d=r(1554),c=r(4233),u=r(3753);let f="~effect/Schedule",p=i.Or("effect/Schedule/CurrentMetadata",{defaultValue:(0,s.dY)({input:void 0,output:void 0,duration:a.v_,attempt:0,start:0,now:0,elapsed:0,elapsedSincePrevious:0})}),h={[f]:{_Out:s.D_,_In:s.D_,_Env:s.D_},pipe(){return(0,d.tT)(this,arguments)}},m=e=>{let t=Object.create(h);return t.step=e,t},g=()=>{let e,t,r=0;return(n,i)=>{void 0===t&&(t=n);let a=n-t,s=void 0===e?0:n-e;return e=n,{input:i,attempt:++r,start:t,now:n,elapsed:a,elapsedSincePrevious:s}}},y=e=>l.Tyx(e.step,e=>l.PyW(()=>l.ATB(e))),b=e=>{let t,r=a.bN(e);return t=l.PyW(e=>l.PyW([e.attempt-1,r])),m(l.TjK(t,e=>{let t=g();return(r,n)=>e(t(r,n))}))},v=(0,s.XY)(2,(e,t)=>{let r=void 0===t.duration?void 0:a.bN(t.duration);return _(e,({attempt:e,elapsed:n})=>l.PyW((void 0===t.times||e<=t.times)&&(void 0===r||a.bi(a.ne(n),r))))}),_=(0,s.XY)(2,(e,t)=>m(l.TjK(y(e),e=>{let r=g();return(i,a)=>l.qIB(e(i,a),e=>{let[s,d]=e,c=t({...r(i,a),output:s,duration:d});return l.qIB((0,o.yw)(c)?c:l.PyW(c),t=>t?l.PyW(e):n.Vw(s))})}))),x=b(a.v_);r.d(t,{},{E6:_,GM:e=>(0,c.i5)(e,f),d3:p,i4:x,jB:v,ji:b,le:e=>m(l.TjK(y(e),e=>(t,r)=>u.tv(e(t,r),{onSuccess:e=>l.PyW([r,e[1]]),onFailure:l.ATB,onDone:()=>n.Vw(r)}))),t5:e=>_(x,({attempt:t})=>l.PyW(t<=e)),xn:e=>l.RKA(t=>l.TjK(y(e),e=>{let r=g();return n=>l.DYE(()=>{let i=t.currentTimeMillisUnsafe();return l.qIB(e(i,n),([e,t])=>{let a=r(i,n);return a.output=e,a.duration=t,l.as(l.yy4(t),a)})})}))})},3909(e,t,r){var n=r(1179);let i=n.Or("effect/Scheduler",{fiberCached:!0,defaultValue:()=>new d}),a=e=>{let t=!1;return Promise.resolve().then(()=>{t||e()}),()=>{t=!0}},s="setImmediate"in globalThis?e=>{let t=globalThis.setImmediate(e);return()=>globalThis.clearImmediate(t)}:e=>{let t=setTimeout(e,0);return()=>clearTimeout(t)},o=e=>{try{return s(e)}catch{return a(e)}};class l{buckets=[];scheduleTask(e,t){let r,n=this.buckets,i=n.length,a=0;for(;a<i&&!(n[a][0]>t);a++)r=n[a];r&&r[0]===t?r[1].push(e):a===i?n.push([t,[e]]):n.splice(a,0,[t,[e]])}drain(){let e=this.buckets;return this.buckets=[],e}}class d{executionMode;setImmediate;constructor(e="async",t){this.executionMode=e,this.setImmediate=t??("sync"===e?a:o)}shouldYield(e){return e.currentOpCount>=e.cache.maxOpsBeforeYield}makeDispatcher(){return new c(this.setImmediate)}}class c{tasks=new l;running=void 0;setImmediate;constructor(e=o){this.setImmediate=e}scheduleTask(e,t){this.tasks.scheduleTask(e,t),void 0===this.running&&(this.running=this.setImmediate(this.afterScheduled))}afterScheduled=()=>{this.running=void 0,this.runTasks()};runTasks(){let e=this.tasks.drain();for(let t=0;t<e.length;t++){let r=e[t][1];for(let e=0;e<r.length;e++)r[e]()}}flush(){for(;this.tasks.buckets.length>0;)void 0!==this.running&&(this.running(),this.running=void 0),this.runTasks()}}let u=n.Or("effect/Scheduler/MaxOpsBeforeYield",{fiberCached:!0,defaultValue:()=>2048}),f=n.Or("effect/Scheduler/PreventSchedulerYield",{fiberCached:!0,defaultValue:()=>!1});r.d(t,{FG:()=>d},{Zm:u,_F:i,hf:f})},2718(e,t,r){let n,i,a,s,o,l,d,c,u,f;r.d(t,{O31:()=>rV,v8c:()=>rJ,$Cd:()=>r6,Xsx:()=>nC,n96:()=>n_,kld:()=>nb,$DH:()=>nT,o5J:()=>r3,wYs:()=>nn,Aiz:()=>nu,uSQ:()=>rU,xCb:()=>rQ,ukk:()=>ng,T9y:()=>rZ,wNn:()=>rW,pHd:()=>nk,mSG:()=>rG,QfV:()=>rz,_kM:()=>rq,rNF:()=>nM,L39:()=>r5,gPz:()=>rK,$r1:()=>rF,usV:()=>rI,hzj:()=>rk,GLL:()=>r2,_Re:()=>rC,q$Z:()=>rT,svK:()=>rM,mj7:()=>nw,is:()=>rO,Bt9:()=>nc,MIs:()=>ni,yJO:()=>no,OWK:()=>nl,biW:()=>nd,NYj:()=>nh,tJb:()=>nf,Pto:()=>nr,nfo:()=>ne,HNH:()=>nt,fXn:()=>rH,Wa3:()=>rR,lqM:()=>rN,Qrq:()=>rA,DYE:()=>r1,TcI:()=>r7,lHk:()=>nA,O3D:()=>rD,_oz:()=>nP,rcy:()=>rE,AxX:()=>rj,tiU:()=>r4,E$i:()=>r9});var p,h,m,g=r(3332),y=r(5033),b=r(3952),v=r(1587),_=r(2860),x=r(1554),w=r(4233);let k="~effect/BigDecimal",S={[k]:k,[y.HR](){let e=M(this);return y.kg(y.Yj(String(e.value)),y.ai(e.scale))},[g.HR](e){return I(e)&&0===R(this,e)},toString(){return`BigDecimal(${D(this)})`},toJSON(){return{_id:"BigDecimal",value:String(this.value),scale:this.scale}},[b.FX](){return this.toJSON()},pipe(){return(0,x.tT)(this,arguments)}},I=e=>(0,w.i5)(e,k),$=(e,t)=>{let r=((e,t)=>{if(!Number.isSafeInteger(t))throw RangeError(`Scale must be a safe integer, got ${t}`);let r=Object.create(S);return r.value=e,r.scale=t,r})(e,t);return r.normalized=r,r},E=BigInt(0),O=BigInt(1),C=BigInt(10),T=$(E,0),M=e=>{if(void 0===e.normalized)if(e.value===E)e.normalized=T;else{let t=`${e.value}`,r=t.length;for(;"0"===t[r-1];)r--;e.normalized=$(BigInt(t.slice(0,r)),e.scale-(t.length-r))}return e.normalized},P=[O],A=(e,t)=>e===t?0:e<t?-1:1,N=(e,t)=>{let r=`${e.value<E?-e.value:e.value}`,n=`${t.value<E?-t.value:t.value}`,i=BigInt(r.length-n.length)-BigInt(e.scale)+BigInt(t.scale);if(i!==E)return i<E?-1:1;let a=Math.max(r.length,n.length);return _.Qf(r.padEnd(a,"0"),n.padEnd(a,"0"))},R=(e,t)=>{if(e.scale===t.scale)return A(e.value,t.value);let r=j(e),n=j(t);if(r!==n)return r<n?-1:1;if(0===r)return 0;let i=e.scale-t.scale,a=Math.abs(i);if(a>100)return -1===r?N(t,e):N(e,t);let s=P[a]??=C**BigInt(a);return i>0?A(e.value,t.value*s):A(e.value*s,t.value)},j=e=>e.value===E?0:e.value<E?-1:1,D=e=>{let t=M(e);if(Math.abs(t.scale)>=16)return U(t);let r=t.value<E,n=`${r?-t.value:t.value}`,i=t.scale>0?n.padStart(t.scale+1,"0"):n.padEnd(n.length-t.scale,"0"),a=i.length-t.scale,s=t.scale>0?`${i.slice(0,a)}.${i.slice(a)}`:i;return r?`-${s}`:s},U=e=>{if(F(e))return"0e+0";let t=M(e),r=`${t.value}`,n=t.value<E?2:1,i=r.slice(0,n),a=r.slice(n),s=a.length-t.scale;return`${i}${""===a?"":`.${a}`}e${s>=0?"+":""}${s}`},F=e=>e.value===E;var B=r(3265),L=r(719),z=r(4942),W=r(1179),J=r(1594),Y=r(4238),X=r(3614),q=r(7876),G=r(6297);let V="~effect/DateTime",H="~effect/DateTime/TimeZone",K={[V]:V,pipe(){return(0,x.tT)(this,arguments)},[b.FX](){return this.toString()},toJSON(){return eh(this).toJSON()}},Q={...K,_tag:"Utc",[y.HR](){return y.ai(this.epochMilliseconds)},[g.HR](e){return ei(e)&&"Utc"===e._tag&&this.epochMilliseconds===e.epochMilliseconds},toString(){return`DateTime.Utc(${eh(this).toJSON()})`}},Z={...K,_tag:"Zoned",[y.HR](){return y.kg(y.ai(this.epochMilliseconds))(y.tW(this.zone))},[g.HR](e){return ei(e)&&"Zoned"===e._tag&&this.epochMilliseconds===e.epochMilliseconds&&g.aI(this.zone,e.zone)},toString(){return`DateTime.Zoned(${eC(this)})`}},ee={[H]:H,[b.FX](){return this.toString()}},et={...ee,_tag:"Named",[y.HR](){return y.Yj(`Named:${this.id}`)},[g.HR](e){return es(e)&&"Named"===e._tag&&this.id===e.id},toString(){return`TimeZone.Named(${this.id})`},toJSON(){return{_id:"TimeZone",_tag:"Named",id:this.id}}},er={...ee,_tag:"Offset",[y.HR](){return y.Yj(`Offset:${this.offset}`)},[g.HR](e){return es(e)&&"Offset"===e._tag&&this.offset===e.offset},toString(){return`TimeZone.Offset(${ey(this.offset)})`},toJSON(){return{_id:"TimeZone",_tag:"Offset",offset:this.offset}}},en=(e,t,r)=>{let n=Object.create(Z);return n.epochMilliseconds=e,n.zone=t,Object.defineProperty(n,"partsUtc",{value:r,enumerable:!1,writable:!0}),Object.defineProperty(n,"adjustedEpochMillis",{value:void 0,enumerable:!1,writable:!0}),Object.defineProperty(n,"partsAdjusted",{value:void 0,enumerable:!1,writable:!0}),n},ei=e=>w.i5(e,V),ea=e=>ei(e[0]),es=e=>w.i5(e,H),eo=e=>{let t=Object.create(Q);return t.epochMilliseconds=e,Object.defineProperty(t,"partsUtc",{value:void 0,enumerable:!1,writable:!0}),t},el=e=>{let t=e.getTime();if(Number.isNaN(t))throw new L.qw("Invalid date");return eo(t)},ed=e=>/Z|GMT|[+-]\d{2}$|[+-]\d{2}:?\d{2}$|\]$/.test(e),ec=v.liftThrowable(e=>{if(ei(e))return e;if(e instanceof Date)return el(e);if("object"==typeof e){if("epochMilliseconds"in e)return el(new Date(e.epochMilliseconds));let t=new Date(0);return ev(t,e),el(t)}return"string"!=typeof e||ed(e)?el(new Date(e)):el(new Date(e+"Z"))});Y.Ru,(e,t,r)=>r?.adjustForTimeZone===!0?e_(e.epochMilliseconds,t,r?.disambiguation??"compatible"):en(e.epochMilliseconds,t,e.partsUtc);let eu=new Map,ef={day:"numeric",month:"numeric",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"longOffset",fractionalSecondDigits:3,hourCycle:"h23"},ep=v.liftThrowable(e=>{let t=eu.get(e);if(void 0!==t)return t;try{let t=(e=>{let t=e.resolvedOptions().timeZone,r=eu.get(t);if(void 0!==r)return r;let n=Object.create(et);return n.id=t,n.format=e,eu.set(t,n),n})(new Intl.DateTimeFormat("en-US",{...ef,timeZone:e}));return eu.set(e,t),t}catch{throw new L.qw(`Invalid time zone: ${e}`)}}),eh=e=>new Date(e.epochMilliseconds),em=e=>{if("Utc"===e._tag)return new Date(e.epochMilliseconds);if("Offset"===e.zone._tag)return new Date(e.epochMilliseconds+e.zone.offset);if(void 0!==e.adjustedEpochMilliseconds)return new Date(e.adjustedEpochMilliseconds);let t=e.zone.format.formatToParts(e.epochMilliseconds).filter(e=>"literal"!==e.type),r=new Date(0);return r.setUTCFullYear(Number(t[2].value),Number(t[0].value)-1,Number(t[1].value)),r.setUTCHours(Number(t[3].value),Number(t[4].value),Number(t[5].value),t[6]?.type==="fractionalSecond"?Number(t[6].value):(e.epochMilliseconds%1e3+1e3)%1e3),e.adjustedEpochMilliseconds=r.getTime(),r},eg=e=>em(e).getTime()-eb(e),ey=e=>{let t=Math.abs(e),r=Math.floor(t/36e5),n=Math.round(t%36e5/6e4);return 60===n&&(r+=1,n=0),`${e<0?"-":"+"}${String(r).padStart(2,"0")}:${String(n).padStart(2,"0")}`},eb=e=>e.epochMilliseconds,ev=(e,t)=>{if((void 0!==t.year||void 0!==t.month||void 0!==t.day)&&e.setUTCFullYear(t.year??e.getUTCFullYear(),void 0!==t.month?t.month-1:e.getUTCMonth(),t.day??e.getUTCDate()),void 0!==t.weekDay){let r=t.weekDay-e.getUTCDay();e.setUTCDate(e.getUTCDate()+r)}void 0!==t.hour&&e.setUTCHours(t.hour),void 0!==t.minute&&e.setUTCMinutes(t.minute),void 0!==t.second&&e.setUTCSeconds(t.second),void 0!==t.millisecond&&e.setUTCMilliseconds(t.millisecond)},e_=(e,t,r)=>{if("Offset"===t._tag)return en(e-t.offset,t);let n=ek(e-864e5,e,t),i=ek(e+864e5,e,t);if(n===i)return en(e-n,t);let a=n-i;if(n<i){if(ek(e-i,e,t)===i)return en(e-i,t);let a=en(e-n,t);if(e!==em(a).getTime())switch(r){case"reject":{let r=new Date(e).toISOString();throw RangeError(`Gap time: ${r} does not exist in time zone ${t.id}`)}case"earlier":return en(e-i,t)}return a}if(ek(e-n,e,t)===n){if("earlier"===r||"compatible"===r||ek(e-n+a,e+a,t)===n)return en(e-n,t);if("reject"===r){let r=new Date(e).toISOString();throw RangeError(`Ambiguous time: ${r} occurs twice in time zone ${t.id}`)}}return en(e-i,t)},ex=/([+-])(\d{2}):(\d{2})$/,ew=e=>{let t=ex.exec(e);if(null===t)return null;let[,r,n,i]=t;return("+"===r?1:-1)*(60*Number(n)+Number(i))*6e4},ek=(e,t,r)=>{let n=r.format.formatToParts(e).find(e=>"timeZoneName"===e.type)?.value??"";if("GMT"===n)return 0;let i=ew(n);return null===i?eg(en(t,r)):i},eS=(0,J.XY)(ea,(e,t,r)=>{if("Utc"===e._tag){let r=eh(e);return t(r),eo(r.getTime())}let n=new Date(em(e).getTime());return t(n),e_(n.getTime(),e.zone,r?.disambiguation??"compatible")}),eI=((e,t)=>eI(e,e=>{let r=new Date(e);return t(r),r.getTime()}),(0,J.XY)(2,(e,t)=>{let r=t(eb(e));return"Utc"===e._tag?eo(r):en(r,e.zone)})),e$=((e,t)=>t(em(e)),(0,J.XY)(2,(e,t)=>t(eh(e)))),eE=(e,t)=>{e.setTime(e.getTime()+t)},eO=((e,t)=>eS(e,e=>{if(t.milliseconds&&eE(e,t.milliseconds),t.seconds&&eE(e,1e3*t.seconds),t.minutes&&eE(e,60*t.minutes*1e3),t.hours&&eE(e,60*t.hours*6e4),t.days&&e.setUTCDate(e.getUTCDate()+t.days),t.weeks&&e.setUTCDate(e.getUTCDate()+7*t.weeks),t.months){let r=e.getUTCDate();e.setUTCMonth(e.getUTCMonth()+t.months+1,0),r<e.getUTCDate()&&e.setUTCDate(r)}if(t.years){let r=e.getUTCDate(),n=e.getUTCMonth();e.setUTCFullYear(e.getUTCFullYear()+t.years,n+1,0),r<e.getUTCDate()&&e.setUTCDate(r)}}),e=>{let t=em(e);return"Utc"===e._tag?t.toISOString():`${t.toISOString().slice(0,-1)}${ey(eg(e))}`}),eC=e=>"Offset"===e.zone._tag?eO(e):`${eO(e)}[${e.zone.id}]`;r(5633);var eT=r(2842),eM=(r(2997),r(6526)),eP=r(1958),eA=r(2275),eN=r(915),eR=r(9315);let ej="~effect/http/Cookies",eD="~effect/http/Cookies/Cookie",eU="~effect/http/Cookies/CookieError";class eF extends z.$D{}class eB extends z.rN("CookiesError"){static fromReason(e,t){return new eB({reason:new eF({_tag:e,cause:t})})}[eU]=eU;get message(){return this.reason._tag}}({[ej]:ej,...b.os,toJSON(){return{_id:"effect/Cookies",cookies:eN.Tj(this.cookies,e=>e.toJSON())}},pipe(){return(0,x.tT)(this,arguments)}}),{[eD]:eD,...b.os,toJSON(){return{_id:"effect/Cookies/Cookie",name:this.name,value:this.value,options:this.options}}};var eL=r(1279),ez=r(7011);let eW=Symbol.for("~effect/http/Headers"),eJ=Object.defineProperties(Object.create(null),{[eW]:{value:eW},[eL.uC]:{value(e){return eX(this,W.Jt(e,eq))}},toJSON:{value(){return eL.E$(this)}},[g.HR]:{value(e){return eY(this,e)}},[y.HR]:{value(){return y.QK(this)}},toString:{value:b.os.toString},[b.FX]:{value:b.os[b.FX]}}),eY=eN.T9(q.YZ()),eX=(0,J.XY)(2,(e,t)=>{let r={...e},n=t=>{if("string"==typeof t){let n=t.toLowerCase();n in e&&(r[n]=ez.L8(e[n]))}else for(let n in e)-1!==n.search(t)&&(r[n]=ez.L8(e[n]))};if(Array.isArray(t))for(let e=0;e<t.length;e++)n(t[e]);else n(t);return r}),eq=W.Or("effect/Headers/CurrentRedactedNames",{defaultValue:()=>["authorization","cookie","set-cookie","x-api-key"]});var eG=r(664),eV=r(2449);let eH=q.rd;_.rd;let eK="~effect/http/UrlParams",eQ={...eV.fU,[eK]:eK,[Symbol.iterator](){return this.params[Symbol.iterator]()},toJSON(){return{_id:"UrlParams",params:Object.fromEntries(this.params)}},[g.HR](e){return eZ(this,e)},[y.HR](){return y.YO(this.params.flat())}},eZ=q.L8((e,t)=>e0(e.params,t.params)),e0=eG.T9(eH([q.YZ(),q.YZ()]));var e1=r(2840),e2=r(2109),e5=r(8253),e3=r(7086),e6=r(587);let e8=(e,t,r)=>e===e6.Rr?r(t):eT.Ab9(e,r);function e9(e){if("Middleware"===e._tag)return(t,r,n)=>e4(t===e6.Rr?e.decode(e6.Py(e6.zL(r)),n):e.decode(eT.jkJ(t,e6.zL),n));let t=e.decode;switch(t._tag){case"Passthrough":return(e,t)=>e===e6.Rr?e6.Py(t):e;case"Transform":{let e=e=>e===e6.LO?e6.r2:e6.Py(t.transform(e));return(t,r)=>e8(t,r,e)}case"TransformOptional":{let e=e=>e6.e8(t.transform(e6.zL(e)));return(t,r)=>e8(t,r,e)}case"TransformEffect":return(e,r,n)=>e8(e,r,e=>e===e6.LO?e6.r2:t.transform(e,n));case"TransformOptionalEffect":return(e,r,n)=>e8(e,r,e=>e4(t.transform(e6.zL(e),n)))}}let e4=e=>eT.Ab9(e,e6.e8),e7=(e,t,r,n)=>eT.Tyx(n,n=>eT.pVV(()=>L.Tj(n,n=>new e3.Wi(e,n,t,r))));function te(e,t){let r,n=t(e);return e.context?.constructorDefault===void 0?n:(r=e.context.constructorDefault,(t,i)=>{if(t!==e6.LO&&void 0!==t)return n(t,i);if((0,G.OY)(r)&&"Success"===r._tag){let e=n(r[eV.a2],i);return e===e6.Rr?r:e}return eT.Ab9(e7(e,t,i,r),e=>{let t=n(e,i);return t===e6.Rr?e6.Py(e):t})})}function tt(e,t,r,n,i){let a,s,o;if("Declaration"===e._tag)for(let r of e.typeParameters)t(r);let l=r?e2.gR(e):void 0,d=l?(o=e9(l.link.transformation),(e,r)=>e===e6.LO?e6.r2:l.isConstructed(e)?e6.Rr:o((s??=t(l.link.to))(e,r),e,r)):n??e.getParser(t,r),c=e.checks,u=e.encoding,f=u?.map(e=>e9(e.transformation)),p=e.encodingChecks;if(!u&&!c&&!p)return d;let h=(t,r)=>{let n=d(t,r);if(p&&!r.disableChecks)if((0,G.OY)(n)){if("Success"===n._tag){let i=n===e6.Rr?t:n[eV.a2];if(t!==e6.LO&&i!==e6.LO){let i=e2.Lp(p,t,void 0,e,r);i&&(n=eT.fJG(new e3.eC(e,i,t,r)))}}}else n=eT.qIB(n,n=>{if(t!==e6.LO&&n!==e6.LO){let n=e2.Lp(p,t,void 0,e,r);if(n)return eT.fJG(new e3.eC(e,n,t,r))}return eT.PyW(n)});if(c&&!r.disableChecks)if((0,G.OY)(n)){if("Success"===n._tag){let i=n===e6.Rr?t:n[eV.a2];if(i===e6.LO)return n;let a=e2.Lp(c,i,void 0,e,r);a&&(n=eT.fJG(new e3.eC(e,a,i,r)))}}else n=eT.qIB(n,t=>{if(t!==e6.LO){let n=e2.Lp(c,t,void 0,e,r);if(n)return eT.fJG(new e3.eC(e,n,t,r))}return eT.PyW(t)});return n},m=void 0===i?h:i(h);return u?(r,n)=>{let i=a??=u.map(e=>t(e.to)),s=r,o=i[i.length-1](r,n);for(let e=u.length-1;e>=0;e--)if(o=f[e](o,s,n),0!==e){let t=i[e-1];o="Success"===o._tag?t(s=o[eV.a2],n):eT.Ab9(o,e=>{let r=t(e,n);return r===e6.Rr?e6.Py(e):r})}if("Success"===o._tag){let e=m(o[eV.a2],n);return e===e6.Rr?o:e}return o=e7(e,r,n,o),eT.Ab9(o,e=>{let t=m(e,n);return t===e6.Rr?e6.Py(e):t})}:m}let tr=Symbol(),tn=new WeakMap,ti=e=>tc(e).parser,ta=e=>tc(e).makeEffect,ts=e=>te(e,ta);class to{ast;constructor(e){this.ast=e}get decodeEffect(){return this.cachedDecodeEffect??=tt(this.ast,ti)}get parser(){return this.decodeEffect}get makeEffect(){return this.cachedMakeEffect??=tt(this.ast,ta,ts)}}class tl extends to{compiled;resolve;constructor(e,t,r){super(e),this.compiled=t,this.resolve=r}save(e,t){return Object.defineProperty(this,e,{value:t}),t}operation(e){let t=this.compiled;return"function"==typeof t?t(this.ast,this.resolve,e):t?.[e]}get is(){return this.save("is",this.operation("is"))}get decode(){return this.save("decode",this.operation("decode"))}get make(){return this.save("make",this.operation("make"))}get decodeEffect(){return this.save("decodeEffect",this.operation("decodeEffect")??tt(this.ast,e=>td(this.resolve,e,"parser")))}get parser(){var e,t;let r,n=this.decode;return void 0===n?this.decodeEffect:this.save("parser",(e=n,t=()=>this.decodeEffect,(n,i)=>{if(n!==e6.LO)try{let t=e(n,i);if(t!==tr)return t===n?e6.Rr:e6.Py(t)}catch(e){return eT.F_Q(e)}return(r??=t())(n,i)}))}get makeEffect(){let e=this.operation("makeEffect");if(void 0!==e)return this.save("makeEffect",e);let t=e=>td(this.resolve,e,"makeEffect");return this.save("makeEffect",tt(this.ast,t,e=>te(e,t)))}}function td(e,t,r){let n,i=e(t);return void 0===i.compiled||Object.hasOwn(i,r)?i[r]:(e,t)=>(n??=i[r])(e,t)}function tc(e){let t=tn.get(e);if(void 0!==t)return t;let r=void 0===n?new to(e):new tl(e,n(e,tc),tc);return tn.set(e,r),r}function tu(e){let t,r=e.ast;return(e,n)=>(t??=ty(t_,e2.Ax(r)))(e,n?.disableChecks?n?.parseOptions?{...n.parseOptions,disableChecks:!0}:{disableChecks:!0}:n?.parseOptions)}function tf(e){let t=tu(e);return(e,r)=>{let n=eT.lKS(t(e,r));return eM.oJ(n)?v.some(n.value):(e5.q(n.cause,"Option adapter can only return none for schema issues"),v.none())}}function tp(e){var t;let r,n;return t=e2.Ax(e.ast),(e,i)=>{r??=tc(t);let a=i?.disableChecks?i.parseOptions?{...i.parseOptions,disableChecks:!0}:{disableChecks:!0}:i?.parseOptions??e2.vr,s=r.make;if(void 0!==s&&e!==e6.LO){let t;try{t=s(e,a)}catch(e){throw e5.q(L.F_(e),"Constructor adapter can only throw schema issues"),e}if(t!==tr&&t!==e6.LO)return t}var o=function(e,t){return e===e6.Rr?eT.PyW(t):(0,G.OY)(e)?e[eV.a2]===e6.LO?tg(e6.LO):e:eT.Ab9(e,tg)}((n??=r.makeEffect)(e,a),e);let l=eT.lKS(o);if(eM.oJ(l))return l.value;throw Error("Schema validation failed",{cause:e5.q(l.cause,"Constructor adapter can only throw schema issues")})}}function th(e,t){let r=ty(tv,e.ast);return void 0===t?r:(e,n)=>r(e,tm(t,n))}let tm=(e,t)=>t?{...e,...t}:e,tg=e=>e===e6.LO?eT.fJG(new e3.h6):eT.PyW(e);function ty(e,t){let r;return(n,i)=>{let a=(r??=e(t))(n,i??e2.vr);return a===e6.Rr?eT.PyW(n):(0,G.OY)(a)?a[eV.a2]===e6.LO?tg(e6.LO):a:eT.Ab9(a,tg)}}function tb(e){return(t,r)=>eT.lKS(e(t,r))}let tv=e=>tc(e).parser,t_=e=>tc(e).makeEffect,tx="~effect/Schema/Schema",tw=Symbol(),tk={[tx]:tx,get make(){let e=tp(this);return Object.defineProperty(this,"make",{value:e,enumerable:!0}),e},get makeEffect(){let e=tu(this);return Object.defineProperty(this,"makeEffect",{value:e,enumerable:!0}),e},get makeOption(){let e=tf(this);return Object.defineProperty(this,"makeOption",{value:e,enumerable:!0}),e},pipe(){return x.tT(this,arguments)},annotate(e){return this.rebuild(e2.fz(this.ast,e))},annotateKey(e){return this.rebuild(e2.us(this.ast,e))},check(...e){return this.rebuild(e2.EJ(this.ast,e))},rebuild(e){return tS(e,this[tw])}};function tS(e,t){let r=Object.setPrototypeOf(function(){},tk);return t&&(Object.hasOwn(t,"name")||Object.hasOwn(t,"length")||Object.hasOwn(t,"__proto__"))?Object.defineProperties(r,Object.getOwnPropertyDescriptors({...t})):Object.assign(r,t),r[tw]=t,r.ast=e,r}var tI=r(3909);function t$(e){return eM.oJ(e)?e.value:{issues:[{message:L.j9(e.cause)}]}}var tE=r(2981),tO=r(7268);let tC=e2.B9(e=>{let t=function(e,t){switch(e._tag){case"Declaration":{let r=e.annotations?.toCodecJson??e.annotations?.toCodec;if(!w.Tn(r))return e2.ES(e,[e2.Gf]);let n=r(e.typeParameters.map(e=>tS(e2.O3(e))));return void 0===n?e:e2.ES(e,[e2.Td(n,t)])}case"Unknown":return e2.ES(e,[e2.Gf]);case"ObjectKeyword":return e2.ES(e,[e2.W5]);case"Undefined":case"Void":case"Literal":case"Number":return e.toCodecJson();case"UniqueSymbol":case"Symbol":case"BigInt":return e.toCodecStringTree();case"Objects":return tM(e),e.recur(t,e2.xw);case"Union":{let r=tA(e.types);if(r!==e.types)return new e2.gP(r,e.options,e.annotations,e.checks,e.encoding,e.context,e.encodingChecks).recur(t);return e.recur(t)}case"Arrays":case"Suspend":return e.recur(t)}return e}(e,tC),r=e.context;return t===e||void 0===r?t:e2.Q0(t,tT(r))});function tT(e){return void 0===e.constructorDefault?e:new e2.ob(e.isOptional,e.isMutable,void 0,e.annotations)}function tM(e){if(e.propertySignatures.some(e=>"string"!=typeof e.name))throw new globalThis.Error("Objects property names must be strings",{cause:e})}function tP(e){return t=>{let r=[...t].sort((t,r)=>e(e2.O3(t))-e(e2.O3(r)));return r.some((e,r)=>e!==t[r])?r:t}}let tA=tP(e=>{switch(e._tag){case"BigInt":case"Symbol":case"UniqueSymbol":return 0;default:return 1}}),tN=(0,J.Bj)(e=>{let t=function(e,t){switch(e._tag){case"Declaration":{let r=e.annotations?.toCodecIso??e.annotations?.toCodec;if(w.Tn(r)){let n=r(e.typeParameters.map(e=>tS(e)));return e2.ES(e,[e2.Td(n,t)])}break}case"Arrays":case"Objects":case"Union":case"Suspend":return e.recur(t)}return e}(e,tN);return t!==e&&void 0!==e.context?e2.Q0(t,tT(e.context)):t}),tR=tP(e=>{switch(e._tag){case"Null":case"Boolean":case"Number":case"BigInt":case"Symbol":case"UniqueSymbol":return 0;default:return 1}}),tj=new e2.N_(new e2.uS("null"),new tO.IT(tE.pd(()=>null),tE.pd(()=>"null"))),tD=new e2.N_(new e2.gP([new e2.uS("true"),new e2.uS("false")]),new tO.IT(tE.pd(e=>"true"===e),tE.Qf())),tU=new tO.IT(tE.pd(e=>"string"==typeof e?[e]:e),tE.le()),tF=e=>e.transformation===tU,tB=e2.B9(e=>{let t=function(e,t,r){switch(e._tag){case"Declaration":{let n=e.typeParameters.map(e=>tS(t(e2.O3(e)))),i=e.annotations?.toCodecStringTree;if(w.Tn(i)){let r=i(n);if(void 0===r)return e;return e2.ES(e,[e2.Td(r,t)])}let a=e.annotations?.toCodecJson,s=w.Tn(a)?a(n):void 0,o=void 0===s?e.annotations?.toCodec:void 0,l=s??(w.Tn(o)?o(n):void 0);return void 0===l?r(e):e2.ES(e,[e2.Td(l,t)])}case"Null":return e2.ES(e,[tj]);case"Boolean":return e2.ES(e,[tD]);case"Unknown":case"ObjectKeyword":return e2.ES(e,[e2.tC]);case"Enum":case"Number":case"Literal":case"UniqueSymbol":case"Symbol":case"BigInt":return e.toCodecStringTree();case"Objects":return tM(e),e.recur(t,e2.xw);case"Union":{let r=tR(e.types);if(r!==e.types)return new e2.gP(r,e.options,e.annotations,e.checks,e.encoding,e.context,e.encodingChecks).recur(t);return e.recur(t)}case"Arrays":case"Suspend":return e.recur(t)}return e}(e,tB,e=>{throw new globalThis.Error("Missing structural codec for StringTree",{cause:e})});return t!==e&&void 0!==e.context?e2.Q0(t,tT(e.context)):t},{stopAt:tF}),tL=e=>e2.dK(e)?e2.Qr(e2.L5):e2.L5,tz=e2.B9(e=>{var t;let r="Declaration"===(t=e)._tag||"Arrays"===t._tag||"Objects"===t._tag||"Union"===t._tag||"Suspend"===t._tag?t.recur(tz):t;if(e2.tF(r)){let t=e2.GL(new e2.gP([new e2.DO(r.isMutable,r.elements.map(tL),r.rest.map(tL)),e2.Yj],{mode:"anyOf"}),r,tU);return e2.dK(e)?e2.Qr(t):t}return r},{stopAt:tF}),tW=["$anchor","$defs","$dynamicAnchor","$dynamicRef","$vocabulary","contentSchema","dependentRequired","dependentSchemas","maxContains","minContains","prefixItems","unevaluatedItems","unevaluatedProperties"];function tJ(e,t){return t.length>0&&(e+=`
235
- at ${(0,eP.jV)(t)}`),Error(e)}function tY(e){return`#/$defs/${encodeURI(e.replace(/~/g,"~0").replace(/\//g,"~1")).replace(/#/g,"%23")}`}[...tW],[...tW],w.gd;let tX=new Set([...e1.UI,e1.R4,...e1.L1]);function tq(e,t){if(void 0===e)return;let r={},n=e.title;"string"==typeof n&&(r.title=n);let i=e.description,a=e.expected;"string"==typeof i?r.description=i:t?.generateDescriptions===!0&&"string"==typeof a&&(r.description=a);let s=e.default;e2.Fh(s)&&(r.default=s);let o=e.examples;Array.isArray(o)&&e2.Fh(o)&&(r.examples=o);let l=e.readOnly;"boolean"==typeof l&&(r.readOnly=l);let d=e.writeOnly;"boolean"==typeof d&&(r.writeOnly=d);let c=e.format;"string"==typeof c&&(r.format=c);let u=e.contentEncoding;"string"==typeof u&&(r.contentEncoding=u);let f=e.contentMediaType;"string"==typeof f&&(r.contentMediaType=f);let p=e.contentSchema;if(e2.Fh(p)&&(r.contentSchema=p),t?.includeAnnotationKey!==void 0)for(let[n,i]of Object.entries(e))!tX.has(n)&&t.includeAnnotationKey(n)&&e2.Fh(i)&&eA.x(r,n,i);return 0===Object.keys(r).length?void 0:r}let tG="|type|format|pattern|multipleOf|minimum|maximum|exclusiveMinimum|exclusiveMaximum|minLength|maxLength|minItems|maxItems|uniqueItems|minProperties|maxProperties|propertyNames|";function tV(e,t){return Object.keys(e).every(e=>t.includes(`|${e}|`))}function tH(e,t){return"string"!=typeof e.$ref&&t.every(t=>!Object.hasOwn(e,t))}let tK="|title|description|default|examples|readOnly|writeOnly|",tQ=tG+tK;function tZ(e,t,r){if(0===Object.keys(e).length)return t;let n=Object.keys(t);if(0===n.length)return e;let i="number"===e.type||"integer"===e.type?e.type:void 0,a=function(e){if(!Array.isArray(e.anyOf)||2!==e.anyOf.length||e.anyOf[0]?.type!=="number")return!1;let t=e.anyOf[1];return t?.type==="string"&&Array.isArray(t.enum)&&3===t.enum.length&&t.enum.includes("NaN")&&t.enum.includes("Infinity")&&t.enum.includes("-Infinity")}(e);if(void 0!==i||a){let n=function e(t){let r="number"===t.type||"integer"===t.type?t.type:void 0,n=t;if(void 0!==r&&(n={...t},delete n.type),Array.isArray(n.allOf)){let t=[],i=!1;for(let a of n.allOf){let n=e(a);void 0!==n.type&&(i=!0,(void 0===r||"integer"===n.type)&&(r=n.type)),Object.keys(n.schema).length>0&&t.push(n.schema)}if(i){let{allOf:e,...r}=n;n=0===t.length?r:{...r,allOf:t}}}return{type:r,schema:n}}(t);if(void 0!==n.type){let t="integer"===i||"integer"===n.type?"integer":"number",s={...e,type:t};a&&delete s.anyOf;let o=Object.keys(n.schema);return 0===o.length?s:tV(n.schema,tK)&&tH(s,o)?{...s,...n.schema}:tZ(s,n.schema,r)}}if(r&&tH(e,n))return{...e,...t};let s=Array.isArray(t.allOf)&&1===n.length?t.allOf:[t];return Array.isArray(e.allOf)?{...e,allOf:[...e.allOf,...s]}:"string"==typeof e.$ref?{allOf:[e,...s]}:{...e,allOf:s}}function t0(e,t=new Set){return"boolean"==typeof e?e:!!t.has(e)||(t.add(e),e.every(e=>t0(e,t)))}function t1(e){switch(e._tag){case"Literal":return globalThis.String(e.literal).replace(/[/\\^$*+?.()|[\]{}]/g,"\\$&");case"String":return e2.XV;case"Number":return e2.bm;case"TemplateLiteral":return e.parts.map(t1).join("");case"Union":return`(?:${e.types.map(t1).join("|")})`;default:throw tJ("Invalid schema representation document",[])}}let t2=({identifier:e})=>e;function t5(e){return void 0===e?void 0:{annotations:e}}let t3="~effect/Schema/SchemaError";var t6=r(5340);let t8="~effect/net/NetAddress";class t9 extends z.rN("NetAddressError"){}let t4=e=>(0,w.i5)(e,t8),t7=e=>t4(e)&&"Ipv4Address"===e._tag,re=e=>t4(e)&&"Ipv6Address"===e._tag,rt=e=>t4(e)&&"InetAddressV4"===e._tag,rr=e=>t4(e)&&"InetAddressV6"===e._tag,rn={_tag:"Ipv4Address",[t8]:t8,[g.HR](e){return t7(e)&&this.value===e.value},[y.HR](){return y.ky(y.kg(ro,0|this.value))},toString(){return rf(this)},toJSON(){return this.toString()},[b.FX](){return this.toJSON()}},ri={_tag:"Ipv6Address",[t8]:t8,[g.HR](e){return!!re(e)&&this.w0===e.w0&&this.w1===e.w1&&this.w2===e.w2&&this.w3===e.w3},[y.HR](){let e=y.kg(rl,0|this.w0);return e=y.kg(e,0|this.w1),e=y.kg(e,0|this.w2),y.ky(y.kg(e,0|this.w3))},toString(){return rf(this)},toJSON(){return this.toString()},[b.FX](){return this.toJSON()}},ra={_tag:"MacAddress",[t8]:t8,[g.HR](e){let t;return t4(t=e)&&"MacAddress"===t._tag&&rs(this.bytes,e.bytes)},[y.HR](){return y.kg(rd,y.YO(this.bytes))},toString(){return ru(this)},toJSON(){return this.toString()},[b.FX](){return this.toJSON()}},rs=(e,t)=>{if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0},ro=y.Yj("Ipv4Address"),rl=y.Yj("Ipv6Address"),rd=y.Yj("MacAddress"),rc=e=>[e>>>24,e>>>16&255,e>>>8&255,255&e],ru=e=>Array.from(e.bytes,e=>e.toString(16).padStart(2,"0")).join(":"),rf=e=>{if(t7(e))return rc(e.value).join(".");let t=(e=>{let{w0:t,w1:r,w2:n,w3:i}=e;return[t>>>16,65535&t,r>>>16,65535&r,n>>>16,65535&n,i>>>16,65535&i]})(e);if(rp(e))return`::ffff:${t[6]>>8}.${255&t[6]}.${t[7]>>8}.${255&t[7]}`;let r=-1,n=0,i=-1;for(let e=0;e<=8;e++)e<8&&0===t[e]?-1===i&&(i=e):-1!==i&&(e-i>n&&(r=i,n=e-i),i=-1);if(n<2)return t.map(e=>e.toString(16)).join(":");let a=t.slice(0,r).map(e=>e.toString(16)).join(":"),s=t.slice(r+n).map(e=>e.toString(16)).join(":");return`${a}::${s}`},rp=e=>{let{w0:t,w1:r,w2:n}=e;return 0===t&&0===r&&65535===n},rh=(g.HR,y.HR,b.FX,g.HR,y.HR,b.FX,e=>{let t=rf(e.address)+(rr(e)&&0!==e.scopeId?`%${e.scopeId}`:"");return rt(e)?`${t}:${e.port}`:`[${t}]:${e.port}`});g.HR,y.HR,b.FX;let rm="~effect/net/IpInterface",rg=e=>(0,w.i5)(e,rm),ry={_tag:"IpInterface",[rm]:rm,[g.HR](e){return rg(e)&&this.prefixLength===e.prefixLength&&g.aI(this.address,e.address)},[y.HR](){return y.kg(y.tW(this.address),y.ai(this.prefixLength))},toString(){return rb(this)},toJSON(){return this.toString()},[b.FX](){return this.toJSON()}},rb=e=>`${rf(e.address)}/${e.prefixLength}`,rv="~effect/net/IpNetwork",r_=e=>(0,w.i5)(e,rv),rx={_tag:"IpNetwork",[rv]:rv,[g.HR](e){return r_(e)&&this.prefixLength===e.prefixLength&&g.aI(this.address,e.address)},[y.HR](){return y.kg(y.tW(this.address),y.ai(this.prefixLength))},toString(){return rw(this)},toJSON(){return this.toString()},[b.FX](){return this.toJSON()}},rw=e=>`${rf(e.address)}/${e.prefixLength}`;function rk(){return(e,t,r)=>rP(new e2.D6(e.map(e2.hu),e=>t(e.map(e=>rP(e))),r))}function rS(e,t){return rk()([],()=>(t,r,n)=>e(t)?eT.PyW(t):eT.fJG(new e3.eE(r,t,n)),t)}function rI(e){return t=>t.rebuild(e2.us(t.ast,e))}q._k,_._k;class r$ extends z.rN("SchemaError"){[t3]=t3;constructor(e){let t=(0,t6.jt)();(0,t6.ft)(0);try{super({issue:e})}finally{(0,t6.ft)(t)}}get message(){return e3.EN(this.issue)}toString(){return`SchemaError(${this.message})`}}function rE(e,t){let r=th(e),n={errors:"all",...t?.parseOptions},i=e3.ID(t),a=e=>{let t=new tI.FG("sync"),a=eT.MY7(eT.YWq(r(e,n),{onFailure:i,onSuccess:e=>({value:e})}),{scheduler:t});a.currentDispatcher?.flush();let s=a.pollUnsafe();return s?t$(s):new Promise(e=>{a.addObserver(t=>{e(t$(t))})})};return"~standard"in e?("validate"in e["~standard"]||Object.assign(e["~standard"],{validate:a}),e):Object.assign(e,{"~standard":{version:1,vendor:"effect",validate:a}})}let rO=function(e){var t;let r,n;return t=e.ast,r=e2.Ax(t),n=e=>{let t;return(t=tb(ty(tv,r)),n=e=>{let r=t(e,e2.vr);return!!eM.oJ(r)||(e5.q(r.cause,"Type guard adapter can only return false for schema issues"),!1)})(e)},e=>n(e)};function rC(e,t){let r=th(e,t);return(e,t)=>{var n,i;return n=r(e,t),(0,G.OY)(n)?(i=n,eM.oJ(i)?i:eM.AT(L.Tj(i.cause,e=>new r$(e)))):eT.Tyx(n,e=>eT.pVV(()=>L.Tj(e,e=>new r$(e))))}}function rT(e,t){let r,n=(r=tb(th(e,t)),(e,t)=>{let n=r(e,t);return eM.oJ(n)?eR.Py(n.value):eR.fJ(e5.q(n.cause,"Result adapter can only return schema issues"))});return(e,t)=>eR.xm(n(e,t),e=>new r$(e))}function rM(e,t){let r=rC(e,t);return(e,t)=>(function(e){let t=eT.lKS(e);if(eM.oJ(t))return t.value;throw function(e,t){let r;for(let n of e.reasons){if(!L.lC(n)||!function(e){return w.i5(e,t3)&&e[t3]===t3}(n.error))throw new globalThis.Error(t,{cause:e});r??=n.error}if(void 0===r)throw new globalThis.Error(t,{cause:e});return r}(t.cause,"Sync adapter can only throw schema errors")})(r(e,t))}let rP=tS,rA=e=>rP(e2.Qr(e.ast),{schema:e}),rN=e=>{let t=r0(e);return rP(e2.lq(e.ast),{schema:t})},rR=e=>rP(e2.W(e.ast),{schema:e}),rj=e=>rP(e2.Ax(e.ast),{schema:e}),rD=e=>rP(e2.O3(e.ast),{schema:e});function rU(e){let t=rP(new e2.uS(e),{literal:e,transform:r=>t.pipe(r2(rU(r),{decode:tE.pd(()=>r),encode:tE.pd(()=>e)}))});return t}e2.Zm,e2.bz;let rF=rP(e2.L5),rB=rP(e2.ch),rL=rP(e2.Vx),rz=rP(e2.Yj),rW=rP(e2.ai),rJ=rP(e2.zM),rY=rP(e2.HR);function rX(e,t){return rP(e,{fields:t,mapFields(e,t){let r=e(this.fields);return rX(e2.w3(r,t?.unsafePreserveChecks?this.ast.checks:void 0),r)}})}function rq(e){return rX(e2.w3(e,void 0),e)}function rG(e,t){return rP(e2.g1(e.ast,t.ast),{key:e,value:t})}e2.we,e2.rI,e2.ZG;let rV=e=>rP(new e2.DO(!1,[],[e.ast]),{value:e}),rH=e=>rP(e2.fX(e.ast),{schema:e});function rK(e,t){return function e(t,r){return rP(t,{members:r,mapMembers(t,r){let n=t(this.members);return e(e2.KC(n,this.ast.options,r?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}(e2.KC(e,t,void 0),e)}function rQ(e){let t=e.map(rU);return rP(e2.KC(t,void 0,void 0),{literals:e,members:t,mapMembers(e){return rK(e(this.members))},pick:e=>rQ(e),transform:e=>rK(t.map((t,r)=>t.transform(e[r])))})}let rZ=e=>rK([e,rB]),r0=e=>rK([e,rL]);function r1(e){return rP(new e2.V3(()=>e().ast))}function r2(e,t){return r=>rP(e2.GL(r.ast,e.ast,t?tO.w8(t):tO.le()),{from:r,to:e})}let r5=rQ(["true","yes","on","1","y"]),r3=rQ(["false","no","off","0","n"]),r6=(rQ([...r5.literals,...r3.literals])).pipe(r2(rJ,tO.pd({decode:e=>"true"===e||"yes"===e||"on"===e||"1"===e||"y"===e,encode:e=>e?"true":"false"})));function r8(e){return eT.Tyx(e,e=>eT.pVV(()=>L.Tj(e,e=>e.issue)))}function r9(e,t){let r=t?.encodingStrategy==="omit"?tE.cJ():tE.le();return t=>rA(rD(t)).pipe(r2(t,{decode:tE.IQ(r8(e)),encode:r}))}function r4(e,t){let r=t?.encodingStrategy==="omit"?tE.cJ():tE.le();return t=>rN(rD(t)).pipe(r2(t,{decode:tE.IQ(r8(e)),encode:r}))}function r7(e){var t;return rU(e).pipe((t=eT.PyW(e),e=>rP(e2.Ez(e.ast,t),{schema:e})))}function ne(){return(e,t)=>new e2.N_(e.ast,tO.w8(t))}let nt=e2.HN;function nr(e,t){let r=e.source,n=e.flags,i=/^[dg]*uy?$/.test(n),a=""===n?`new RegExp(${(0,eP.GP)(r)})`:`new RegExp(${(0,eP.GP)(r)}, ${(0,eP.GP)(n)})`;return e2.Pt(e,{toJsonSchema:()=>i?{pattern:n.endsWith("y")?`^(?:${r})`:r}:[{},!0],toCode:()=>({runtime:`Schema.isPattern(${a})`}),...t})}let nn=rP(e2.E2),ni=e2.MI;function na(e){let t=_.OW(e.order),r=e.formatter??eP.GP;return(n,i)=>nt(e=>t(e,n),{expected:`a value greater than or equal to ${r(n)}`,arbitraryConstraint:{order:e.order,minimum:n},...e.annotate?.(n),...i})}function ns(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${(0,eP.GP)(e)}`);return e}let no=(p={order:_.wN,annotate:e=>({representation:{id:"effect/schema/isGreaterThan",payload:{exclusiveMinimum:ns(e)}},toJsonSchema:()=>({exclusiveMinimum:e}),toCode:()=>({runtime:`Schema.isGreaterThan(${(0,eP.GP)(e)})`})})},i=_.yJ(p.order),a=p.formatter??eP.GP,(e,t)=>nt(t=>i(t,e),{expected:`a value greater than ${a(e)}`,arbitraryConstraint:{order:p.order,minimum:e,exclusiveMinimum:!0},...p.annotate?.(e),...t})),nl=na({order:_.wN,annotate:e=>({representation:{id:"effect/schema/isGreaterThanOrEqualTo",payload:{minimum:ns(e)}},toJsonSchema:()=>({minimum:e}),toCode:()=>({runtime:`Schema.isGreaterThanOrEqualTo(${(0,eP.GP)(e)})`})})});_.wN;let nd=(h={order:_.wN,annotate:e=>({representation:{id:"effect/schema/isLessThanOrEqualTo",payload:{maximum:ns(e)}},toJsonSchema:()=>({maximum:e}),toCode:()=>({runtime:`Schema.isLessThanOrEqualTo(${(0,eP.GP)(e)})`})})},s=_.bi(h.order),o=h.formatter??eP.GP,(e,t)=>nt(t=>s(t,e),{expected:`a value less than or equal to ${o(e)}`,arbitraryConstraint:{order:h.order,maximum:e},...h.annotate?.(e),...t})),nc=(m={order:_.wN,annotate:e=>{let t=!!e.exclusiveMinimum||void 0,r=!!e.exclusiveMaximum||void 0;return{representation:{id:"effect/schema/isBetween",payload:{minimum:ns(e.minimum),maximum:ns(e.maximum),...t&&{exclusiveMinimum:t},...r&&{exclusiveMaximum:r}}},toJsonSchema:()=>({[t?"exclusiveMinimum":"minimum"]:e.minimum,[r?"exclusiveMaximum":"maximum"]:e.maximum}),toCode:()=>({runtime:`Schema.isBetween({ minimum: ${(0,eP.GP)(e.minimum)}, maximum: ${(0,eP.GP)(e.maximum)}, exclusiveMinimum: ${(0,eP.GP)(t)}, exclusiveMaximum: ${(0,eP.GP)(r)} })`})}}},l=_.OW(m.order),d=_.yJ(m.order),c=_.bi(m.order),u=_.hl(m.order),f=m.formatter??eP.GP,(e,t)=>{let r=e.exclusiveMinimum?d:l,n=e.exclusiveMaximum?u:c;return nt(t=>r(t,e.minimum)&&n(t,e.maximum),{expected:`a value between ${f(e.minimum)}${e.exclusiveMinimum?" (excluded)":""} and ${f(e.maximum)}${e.exclusiveMaximum?" (excluded)":""}`,arbitraryConstraint:{order:m.order,minimum:e.minimum,maximum:e.maximum,...e.exclusiveMinimum&&{exclusiveMinimum:!0},...e.exclusiveMaximum&&{exclusiveMaximum:!0}},...m.annotate?.(e),...t})}),nu=rW.check(nt(e=>globalThis.Number.isSafeInteger(e),{expected:"an integer",representation:{id:"effect/schema/isInt",payload:null},toJsonSchema:()=>[{type:"integer"},!0],toCode:()=>({runtime:"Schema.isInt()"}),arbitraryConstraint:{number:"integer"}}));function nf(e,t){return np(e=nm(e),Math.ceil(e/2),t)}function np(e,t,r){return nt(t=>t.length>=e,{expected:`a value with a length of at least ${e}`,representation:{id:"effect/schema/isMinLength",payload:{minLength:e}},toJsonSchema:({type:r})=>"string"===r?e<=1?{minLength:t}:[{minLength:t},!0]:"array"===r?{minItems:e}:void 0===r?[{minLength:t,minItems:e},!0]:[{},!0],toCode:()=>({runtime:`Schema.isMinLength(${e})`}),[e1.C3]:!0,arbitraryConstraint:{minLength:e},...r})}function nh(e,t){return e=nm(e),nt(t=>t.length<=e,{expected:`a value with a length of at most ${e}`,representation:{id:"effect/schema/isMaxLength",payload:{maxLength:e}},toJsonSchema:({type:t})=>"string"===t?0===e?{maxLength:e}:[{maxLength:e},!0]:"array"===t?{maxItems:e}:void 0===t?[{maxLength:e,maxItems:e},!0]:[{},!0],toCode:()=>({runtime:`Schema.isMaxLength(${e})`}),[e1.C3]:!0,arbitraryConstraint:{maxLength:e},...t})}function nm(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${e}`);return Math.max(0,Math.floor(e))}_.n9,_.n9,_.n9,_.n9,_.n9,_.Qw,_.Qw,_.Qw,_.Qw,_.Qw;let ng=rz.check(np(1,1,void 0)),ny=[];function nb(e){let t=e?.includeStack===!0|2*(e?.excludeCause===!0),r=ny[t];if(void 0!==r)return r;let n=nN.pipe(r2(rF,tO.sm((e=>{switch(e){case 0:return;case 1:return{includeStack:!0};case 2:return{excludeCause:!0};case 3:return{includeStack:!0,excludeCause:!0}}})(t))));return ny[t]=n,n}let nv=rz.annotate({expected:"a string that will be decoded as a Date"}),n_=rS(e=>e instanceof globalThis.Date&&!globalThis.Number.isNaN(e.getTime()),{representation:{id:"effect/schema/Date",payload:null},toCode:()=>({runtime:"Schema.Date",Type:"globalThis.Date"}),expected:"a valid Date",toCodecJson:()=>ne()(nv,tO.YZ)}),nx=rz.annotate({expected:"a string that will be decoded as JSON",contentMediaType:"application/json"});function nw(e,t){return nx.pipe(r2(e,tO.mj(t)))}tO.R7;let nk=rK([nn,rY,rz]);B.yp;X.n$,e=>w.i5(e,eD);let nS=globalThis.Symbol.for("immer-draftable"),nI={};function n$(e,t,r,n,i){var a,s,o;let l,d=(a=r,s=t,o=n,e=>{if(void 0!==l)return l;let t=nE(s),r=r=>r instanceof e||w.i5(r,t),n=new tO.IT(tE.pd(t=>new e(t,{"~payload":{token:nI,value:t}})),tE.le());return l=r2(rP(new e2.D6([a.ast],()=>(e,t,n)=>r(e)?eT.PyW(e):eT.fJG(new e3.eE(t,e,n)),{identifier:s,[e1.py]:([e])=>({isConstructed:r,link:new e2.N_(e,n)}),toCodec:([e])=>new e2.N_(e.ast,n),toEquivalence:([e])=>e,toFormatter:([t])=>r=>`${e.identifier}(${t(r)})`,[e1.I_]:e2.SL(a.ast),...o})),n)(a)}),c=nE(t),u=class extends e{constructor(...[e,t]){let n=t?.["~payload"],i=n?.token===nI?n.value:r.make(e??{},t);super(i,{...t,disableChecks:!0,"~payload":{token:nI,value:i}})}static [tx]=tx;get[c](){return c}static [nS]=!0;static identifier=t;static fields=r.fields;static get ast(){return d(this).ast}static pipe(){return x.tT(this,arguments)}static rebuild(e){return d(this).rebuild(e)}static make(e,t){return tp(d(this))(e??{},t)}static makeOption(e,t){return tf(d(this))(e??{},t)}static makeEffect(e,t){return d(this).makeEffect(e??{},t)}static annotate(e){return this.rebuild(e2.fz(this.ast,e))}static annotateKey(e){return this.rebuild(e2.us(this.ast,e))}static check(...e){return this.rebuild(e2.EJ(this.ast,e))}static extend(e){return(t,n)=>{let a=nO(t)?t:rq(t),s={...r.fields,...a.fields},o=e2.w3(s,r.ast.checks,{identifier:e});return n$(this,e,rX(e2.EJ(o,a.ast.checks),s),n,i)}}static mapFields(e,t){return r.mapFields(e,t)}};return void 0!==i&&Object.assign(u.prototype,i(t)),u}function nE(e){return`~effect/Schema/Class/${e}`}function nO(e){return w.i5(e,tx)&&e[tx]===tx}let nC=e=>(t,r)=>{let n=nO(t)?t:rq(t);return n$(z.Xs,e,n,r,e=>({toString(){return`${e}(${(0,eP.GP)({...this})})`}}))},nT=e=>(t,r)=>{let n=nO(t)?t:rq(t);return n$(eV.$D,e,n,r,e=>({name:e}))},nM=e=>(t,r,n)=>{let i=nO(r)?r.mapFields(e=>({_tag:r7(t),...e}),{unsafePreserveChecks:!0}):rq({_tag:r7(t),...r});return nT(e??t)(i,n)};function nP(e,t){var r;let n;return r=function(e,t){let{references:r,representations:n}=function(e,t){let r={},n=new Map,i=new Set,a=new Map,s=new Set;for(let t of e)(function e(t){let r=d(t),n=r.ast;if(r.occurrences++,s.has(r)){r.isRecursive=!0;return}if(!(r.occurrences>1)){switch(s.add(r),function t(r){r?.forEach(r=>{r.annotations?.representation?.schemas?.forEach(t=>e(e2.Ax(t))),"FilterGroup"===r._tag&&t(r.checks)})}(n.checks),n._tag){case"Declaration":case"Arrays":case"Objects":case"Union":n.recur(t=>(e(t),t));break;case"TemplateLiteral":n.parts.forEach(e);break;case"Suspend":e(n.thunk())}s.delete(r)}})(t);let o=t?.referencePolicy??t2;for(let e of a.values())for(let t of e.values()){let e=o({ast:t.ast,occurrences:t.occurrences,identifier:t.identifier});if(void 0!==e){let r=e!==t.identifier&&e.endsWith("_")?"":"_";t.reference=l(e,t,r)}else t.isRecursive&&(t.reference=l(`${t.ast._tag}_`,t,""))}return{representations:eG.Tj(e,e=>c(e)),references:r};function l(e,t,r="_"){let i=e,a=0;for(;n.has(i);){if(n.get(i)===t)return i;i=`${e}${r}${++a}`}return n.set(i,t),i}function d(e){let t=e2.S5(e),r=e2.v1(t),n=e1.KE(t),i=void 0===n?(t!==e?e1.KE(e):void 0)??e1.CD(t):void 0;void 0!==i&&(n=`${i}Encoded`);let s=a.get(r);void 0===s&&(s=new Map,a.set(r,s));let o=s.get(n);return void 0===o&&(o={ast:r,identifier:n,fallback:i,occurrences:0,isRecursive:!1,reference:void 0},s.set(n,o)),o}function c(e){let t=d(e),n=t.ast,a=t.reference;if(void 0!==a){let e,s=void 0===t.identifier?n:void 0!==(e=t.fallback)?e1.CD(n)===e?n:e2.fz(n,{[e1.R4]:e}):a===t.identifier?n:e2.fz(n,{identifier:a});if(!Object.hasOwn(r,a)&&!i.has(a)){i.add(a);let e=u(s);i.delete(a),eA.x(r,a,e)}return{_tag:"Reference",$ref:a}}return u(n)}function u(e){var t;let r=(t=e.checks,t?.map(f)??[]);switch(e._tag){case"Declaration":return{_tag:"Declaration",typeParameters:e.typeParameters.map(e=>c(e)),checks:r,...function(e){if(void 0===e)return;let{representation:t,...r}=e;return{...void 0===t?void 0:{representation:t},...0===Object.keys(r).length?void 0:{annotations:r}}}(e.annotations)};case"Null":case"Undefined":case"Void":case"Never":case"Unknown":case"Any":case"String":case"Boolean":case"Number":case"BigInt":case"Symbol":case"ObjectKeyword":return{_tag:e._tag,checks:r,...t5(e.annotations)};case"Literal":return{_tag:"Literal",literal:e.literal,checks:r,...t5(e.annotations)};case"UniqueSymbol":return{_tag:"UniqueSymbol",symbol:e.symbol,checks:r,...t5(e.annotations)};case"Enum":return{_tag:"Enum",enums:e.enums,checks:r,...t5(e.annotations)};case"TemplateLiteral":return{_tag:"TemplateLiteral",parts:e.parts.map(e=>c(e)),checks:r,...t5(e.annotations)};case"Arrays":return{_tag:"Arrays",elements:e.elements.map(e=>{let t=e2.S5(e),r=t.context?.annotations;return{isOptional:e2.dK(t),type:c(e),...t5(r)}}),rest:e.rest.map(e=>c(e)),checks:r,...t5(e.annotations)};case"Objects":return{_tag:"Objects",propertySignatures:e.propertySignatures.map(e=>{let t=e2.S5(e.type),r=t.context?.annotations;return{name:e.name,type:c(e.type),isOptional:e2.dK(t),isMutable:e2.bV(t),...t5(r)}}),indexSignatures:e.indexSignatures.map(e=>({parameter:c(e.parameter),type:c(e.type)})),checks:r,...t5(e.annotations)};case"Union":return{_tag:"Union",types:e.types.map(e=>c(e)),...void 0===e.options?{}:{options:e.options},checks:r,...t5(e.annotations)};case"Suspend":return{_tag:"Suspend",checks:[],thunk:c(e.thunk()),...t5(e.annotations)}}}function f(e){switch(e._tag){case"Filter":return{_tag:"Filter",aborted:e.aborted,...p(e.annotations)};case"FilterGroup":return{_tag:"FilterGroup",checks:eG.Tj(e.checks,f),...p(e.annotations)}}}function p(e){if(void 0===e)return;let{representation:t,...r}=e,n=void 0===t?void 0:void 0===t.schemas?t:{...t,schemas:t.schemas.map(e=>c(e2.Ax(e)))};return{...void 0===n?void 0:{representation:n},...0===Object.keys(r).length?void 0:{annotations:r}}}}([e],t);return{representation:n[0],references:r}}(tC(e.ast),t),{dialect:(n=function(e,t,r,n){let i=new Map,a=new Map,s=new WeakMap,o=new Map,l=new Map,d=Object.keys(r);for(let e of d)h(e,["references",e]);let c=eG.Tj(e,(e,r)=>y(e,t[r],[]));for(let[e,t]of o.values())if(!t0(e))for(let e of t)Array.isArray(e.oneOf)&&(e.anyOf=e.oneOf,delete e.oneOf);for(let e of d){let t=function(e){if("Reference"===e._tag)return;let t=0===e.checks.length?e.annotations:e.checks[e.checks.length-1].annotations;return"string"!=typeof t?.identifier&&"string"==typeof t?.[e1.R4]?t[e1.R4]:void 0}(r[e]);if(void 0===t)continue;let n=i.get(e)[0],s=l.get(t),o=s?.find(e=>g.aI(i.get(e)[0],n));void 0===o?void 0===s?l.set(t,[e]):s.push(e):a.set(e,o)}let u=eG.Tj(c,m),f={};for(let e of d)a.has(e)||eA.x(f,e,m(i.get(e)[0]));return{dialect:"draft-2020-12",schemas:u,definitions:f};function p(e){return Array.isArray(e.oneOf)&&o.get(e.oneOf)?.[1].push(e),e}function h(e,t){if(!Object.hasOwn(r,e))throw tJ(`Invalid reference ${e}`,[...t,"$ref"]);let n=i.get(e);if(void 0!==n)return n;let a=[{},[]];return i.set(e,a),a[0]=y(r[e],["references",e],a[1]),a}function m(e){var t,r;return t=e=>{let t=function(e){if(0===e.length||"#"===e)return"";if(!e.startsWith("#"))return;let t=e.slice(1);try{if(encodeURI(t).replace(/%25/g,"%").replace(/#/g,"%23")!==t)return;let e=decodeURIComponent(t);return e.startsWith("/")&&!/~(?:[^01]|$)/.test(e)?e:void 0}catch{return}}(e);if(void 0===t){if(/^#(?:\/|%2f)/i.test(e))throw Error(`Invalid JSON Pointer URI fragment ${JSON.stringify(e)}`);return e}if(!t.startsWith("/$defs/"))return e;let r=t.indexOf("/",7),n=a.get(t.slice(7,r<0?void 0:r).replace(/~1/g,"/").replace(/~0/g,"~"));return void 0===n?e:e.replace(/^#(?:\/|%2f).*?(?:\/|%2f).*?(?=\/|%2f|$)/i,tY(n))},r=e=>{var r,n;r=e,n=t,"string"==typeof r.$ref&&eA.x(r,"$ref",n(r.$ref,"$ref")),"string"==typeof r.$dynamicRef&&eA.x(r,"$dynamicRef",n(r.$dynamicRef,"$dynamicRef"))},function e(t,n,i=!1){var a;if(!w.Gv(t))return t;let s=n||!i&&"string"==typeof(a=t.$id)&&a.length>0&&"#"!==a[0],o={};for(let r of Object.keys(t)){let n=t[r],i=n;switch(r){case"$defs":case"properties":case"patternProperties":case"dependentSchemas":i=function(e,t){if(!w.Gv(e))return;let r={};for(let n of Object.keys(e))eA.x(r,n,t(e[n],n));return r}(n,t=>e(t,s))??n;break;case"allOf":case"anyOf":case"oneOf":case"prefixItems":i=Array.isArray(n)?n.map(t=>e(t,s)):n;break;case"not":case"additionalProperties":case"propertyNames":case"unevaluatedProperties":case"items":case"contains":case"unevaluatedItems":case"if":case"then":case"else":case"contentSchema":i=e(n,s)}eA.x(o,r,i)}return r(o),o}(e,!1,!0)}function y(e,t,i){if("Reference"===e._tag)return i.push(h(e.$ref,t)[1]),{$ref:tY(e.$ref)};let a=s.get(e);if(void 0!==a)return i.push(a[1]),a[0];let l=[];i.push(l);let d=function(e,t,i){switch(e._tag){case"Any":case"Unknown":return{};case"ObjectKeyword":return{anyOf:[{type:"object"},{type:"array"}]};case"Void":case"Undefined":case"Null":return{type:"null"};case"BigInt":return{type:"string",allOf:[{pattern:"^-?\\d+$"}]};case"Symbol":return{type:"string",allOf:[{pattern:"^Symbol\\(([\\s\\S]*)\\)$"}]};case"UniqueSymbol":return void 0===globalThis.Symbol.keyFor(e.symbol)?{not:{}}:{type:"string",enum:[globalThis.String(e.symbol)]};case"Declaration":return i.push(!1),{};case"Suspend":return y(e.thunk,[...t,"thunk"],i);case"Never":return{not:{}};case"String":return{type:"string"};case"Number":return{anyOf:[{type:"number"},{type:"string",enum:["NaN","Infinity","-Infinity"]}]};case"Boolean":return{type:"boolean"};case"Literal":{let t=e.literal;return"bigint"==typeof t?{type:"string",enum:[globalThis.String(t)]}:{type:typeof t,enum:[t]}}case"Enum":{let r=e.enums.map(([e,r],n)=>{if("number"==typeof r&&!globalThis.Number.isFinite(r))throw tJ(`Invalid numeric enum value ${globalThis.String(r)}`,[...t,"enums",n,1]);return{type:typeof r,enum:[r],title:e}});return 0===r.length?{not:{}}:{anyOf:r}}case"TemplateLiteral":return{type:"string",pattern:`^${e.parts.map(t1).join("")}$`};case"Arrays":{if(e.rest.length>1)throw tJ("Invalid schema representation document",[...t,"rest"]);let r={type:"array"},a=e.elements.length,s=e.elements.map((e,r)=>{e.isOptional&&a--;let s=y(e.type,[...t,"elements",r,"type"],i),o=tq(e.annotations,n);return void 0===o?s:p(tZ(s,o))});if(s.length>0?(r.prefixItems=s,r.maxItems=e.elements.length,a>0&&(r.minItems=a)):r.items=!1,1===e.rest.length){delete r.maxItems;let n=y(e.rest[0],[...t,"rest",0],i);Object.keys(n).length>0?r.items=n:delete r.items}return r}case"Objects":{if(0===e.propertySignatures.length&&0===e.indexSignatures.length)return{not:{type:"null"}};let a={type:"object"},s={},o=[];for(let r=0;r<e.propertySignatures.length;r++){let a=e.propertySignatures[r];if("string"!=typeof a.name)throw tJ("Invalid schema representation document",[...t,"propertySignatures",r,"name"]);let l=a.name,d=y(a.type,[...t,"propertySignatures",r,"type"],i),c=tq(a.annotations,n);eA.x(s,l,void 0===c?d:p(tZ(d,c))),a.isOptional||o.push(l)}e.propertySignatures.length>0&&(a.properties=s),o.length>0&&(a.required=o);let l={},d=[],c=[],u=!1;for(let n=0;n<e.indexSignatures.length;n++){let a=e.indexSignatures[n],s=y(a.type,[...t,"indexSignatures",n,"type"],i);g.aI(s,{not:{}})&&(s=!1),c.push(s);let o=function e(t,n,i){switch(t._tag){case"Reference":{if(!Object.hasOwn(r,t.$ref))throw tJ(`Invalid reference ${t.$ref}`,[...n,"$ref"]);if(h(t.$ref,n),i.has(t.$ref))return;let a=new Set(i).add(t.$ref);return e(r[t.$ref],["references",t.$ref],a)}case"String":{if(0===t.checks.length)return[];if(1!==t.checks.length||"Filter"!==t.checks[0]._tag||t.checks[0].annotations?.toJsonSchema===void 0)return;let e=[],r=y(t,n,e);if(!t0(e))return;return"string"===r.type&&"string"==typeof r.pattern&&tV(r,"|type|pattern|title|description|default|examples|readOnly|writeOnly|")?[r.pattern]:void 0}case"TemplateLiteral":return 0===t.checks.length?[`^${t.parts.map(t1).join("")}$`]:void 0;case"Union":{if(0===t.types.length||t.checks.length>0||t.options?.mode==="oneOf")return;let r=[];for(let a=0;a<t.types.length;a++){let s=e(t.types[a],[...n,"types",a],i);if(void 0===s)return;if(0===s.length)return[];r.push(...s)}return r}default:throw tJ("Invalid schema representation document",n)}}(a.parameter,[...t,"indexSignatures",n,"parameter"],new Set);if(void 0===o){u=!0,i.push(!1);continue}if(0===o.length)d.push(s);else for(let e of o){let t=l[e];eA.x(l,e,void 0===t?s:!1!==t&&!1!==s&&p(tZ(t,s)))}}let f=Object.keys(l).length>0;if(f&&(a.patternProperties=l),u&&n?.onExcessProperty==="error"){let r=[];e.propertySignatures.length>0&&r.push({enum:Object.keys(s)});for(let n=0;n<e.indexSignatures.length;n++)r.push(y(e.indexSignatures[n].parameter,[...t,"indexSignatures",n,"parameter"],i));a.propertyNames=1===r.length?r[0]:{anyOf:r},a.additionalProperties=1===c.length?c[0]:{anyOf:c},d.length>0&&(a.allOf=d.map(e=>({type:"object",additionalProperties:e})))}else 0===d.length?a.additionalProperties=u||n?.onExcessProperty!=="error":1!==d.length||0!==e.propertySignatures.length||f?d.length>0&&(a.allOf=d.map(e=>({type:"object",additionalProperties:e}))):a.additionalProperties=d[0];return"object"==typeof a.additionalProperties&&null!==a.additionalProperties&&0===Object.keys(a.additionalProperties).length&&delete a.additionalProperties,a}case"Union":{let r=[],n=e.types.map((e,n)=>y(e,[...t,"types",n],r));if(i.push(r),0===n.length)return{not:{}};let a=e.options?.mode??"anyOf";if("anyOf"===a&&n.length>1){let e=function(e){let t,r=[];for(let n of e){if(2!==Object.keys(n).length||void 0===n.type||!Array.isArray(n.enum)||0===n.enum.length)return;if(void 0===t)t=n.type;else if(n.type!==t)return;for(let e of n.enum){if(r.includes(e))return;r.push(e)}}return{type:t,enum:r}}(n);if(void 0!==e)return e}return"oneOf"===a&&o.set(n,[r,[]]),{[a]:n}}}}(e,t,l),c=tq(e.annotations,n);void 0!==c&&(d={...d,...c});for(let r=0;r<e.checks.length;r++){var u;let i="string"==typeof d.type&&("string"===(u=d.type)||"number"===u||"boolean"===u||"array"===u||"object"===u||"null"===u||"integer"===u)?d.type:void 0,a=function e(t,r,i,a){let s=t.annotations,o=s?.toJsonSchema;if(void 0!==o){let e=o({type:r,schemas:t.representation?.schemas?.map((e,t)=>y(e,[...i,"representation","schemas",t],a))??[]}),l=Array.isArray(e);l&&a.push(!1);let d=l?e[0]:e,c=tq(s,n),u=void 0===c?d:{...d,...c},f=void 0===c?tG:tQ;return[u,!!("Filter"===t._tag&&tV(u,f)&&(void 0===c||tV(c,tK)))||void 0]}if("Filter"===t._tag)return void a.push(!1);let l=t.checks.flatMap((t,n)=>{let s=e(t,r,[...i,"checks",n],a);return void 0===s?[]:[s[0]]});if(0===l.length)return;let d=tq(s,n),c={allOf:l};return[void 0===d?c:{...c,...d}]}(e.checks[r],i,[...t,"checks",r],l);void 0!==a&&(d=tZ(d,...a))}return s.set(e,[d,l]),p(d)}}([r.representation],[["representation"]],r.references,t)).dialect,schema:n.schemas[0],definitions:n.definitions}}let nA=function(e){return tS(tB(e.ast),{schema:e})},nN=rP(e2.fz(e2.LM,{toCode:()=>({runtime:"Schema.Json",Type:"Schema.Json"})}));e2.BF},2109(e,t,r){var n=r(664),i=r(719),a=r(2842),s=r(6526),o=r(1958),l=r(1594),d=r(6297),c=r(2275),u=r(2840),f=r(8253),p=r(587),h=r(2449),m=r(1554),g=r(4233),y=r(2981),b=r(7086),v=r(7268);function _(e){return t=>t._tag===e}let x=_("Declaration"),w=_("Never"),k=_("String"),S=_("Number"),I=_("Boolean"),$=_("Literal"),E=_("UniqueSymbol"),O=_("Arrays"),C=_("Objects"),T=_("Suspend"),M=class{to;transformation;constructor(e,t){this.to=e,this.transformation=t}},P={},A=class{isOptional;isMutable;constructorDefault;annotations;constructor(e,t,r,n){this.isOptional=e,this.isMutable=t,this.constructorDefault=r,this.annotations=n}},N="~effect/Schema";class R{[N]=N;annotations;checks;encoding;context;constructor(e,t,r,n){this.annotations=e,this.checks=t,this.encoding=r,this.context=n}toString(){return`<${this._tag}>`}}let j=class extends R{_tag="Declaration";typeParameters;run;encodingChecks;encodingRun;constructor(e,t,r,n,i,a,s,o){super(r,n,i,a),this.typeParameters=e,this.run=t,this.encodingChecks=s,this.encodingRun=o}getParser(){let e;return(t,r)=>t===p.LO?p.r2:(e??=this.run(this.typeParameters))(t,this,r)}_rebuild(e,t,r,n,i){let a=e0(this.typeParameters,e);return a===this.typeParameters&&t===this.checks&&r===this.encodingChecks&&n===this.run&&i===this.encodingRun?this:new j(a,n,this.annotations,t,void 0,this.context,r,i)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks,this.run,this.encodingRun)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks,this.encodingRun??this.run,this.run)}getExpected(){let e=this.annotations?.expected;return"string"==typeof e?e:"<Declaration>"}},D=new class extends R{_tag="Null";getParser(){return ta(this,null)}getExpected(){return"null"}},U=class extends R{_tag="Undefined";getParser(){return ta(this,void 0)}toCodecJson(){return eW(this,[F])}getExpected(){return"undefined"}},F=new M(D,new v.IT(y.pd(()=>void 0),y.pd(()=>null))),B=new U,L=new class extends R{_tag="Void";getParser(){let e=p.Py(void 0);return t=>t===p.LO?p.r2:e}toCodecJson(){return eW(this,[F])}getExpected(){return"void"}},z=new class extends R{_tag="Never";getParser(){return ts(this,g.Pd)}getExpected(){return"never"}},W=new class extends R{_tag="Any";getParser(){return ts(this,g.t8)}getExpected(){return"any"}},J=new class extends R{_tag="Unknown";getParser(){return ts(this,g.t8)}getExpected(){return"unknown"}},Y=new class extends R{_tag="ObjectKeyword";getParser(){return ts(this,g.Fw)}getExpected(){return"object | array | function"}},X=class extends R{_tag="Literal";literal;constructor(e,t,r,n,i){if(super(t,r,n,i),"number"==typeof e&&!globalThis.Number.isFinite(e))throw Error(`A numeric literal must be finite, got ${(0,o.GP)(e)}`);this.literal=e}getParser(){return ta(this,this.literal)}matchPart(e,t){return e===globalThis.String(this.literal)?this.literal:void 0}toCodecJson(){return"bigint"==typeof this.literal?q(this):this}toCodecStringTree(){return"string"==typeof this.literal?this:q(this)}getExpected(){return"string"==typeof this.literal?JSON.stringify(this.literal):globalThis.String(this.literal)}};function q(e){let t=globalThis.String(e.literal);return eW(e,[new M(new X(t),new v.IT(y.pd(()=>e.literal),y.pd(()=>t)))])}let G=new class extends R{_tag="String";getParser(){return ts(this,g.Kg)}matchPart(e,t){let r=this.checks;return r&&!t.disableChecks&&t_(r,e,void 0,this,t)?void 0:e}getExpected(){return"string"}};function V(e,t){return e.some(e=>e.annotations?.representation?.id===t||"FilterGroup"===e._tag&&V(e.checks,t))}let H=new class extends R{_tag="Number";getParser(){return ts(this,g.Et)}matchKey(e,t){return this._match(tu,e,t)}matchPart(e,t){return this._match(tc,e,t)}_match(e,t,r){if(!e.test(t))return;let n=globalThis.Number(t);return r.disableChecks||!this.checks?n:t_(this.checks,n,void 0,this,r)?void 0:n}toCodecJson(){return this.checks&&(V(this.checks,"effect/schema/isFinite")||V(this.checks,"effect/schema/isInt"))?this:eW(this,[eU])}toCodecStringTree(){return this.toCodecJson()===this?eW(this,[tp]):eW(this,[th])}getExpected(){return"number"}},K=new class extends R{_tag="Boolean";getParser(){return ts(this,g.Lm)}getExpected(){return"boolean"}},Q=new class extends R{_tag="Symbol";getParser(){return ts(this,g.Bm)}matchKey(e,t){return t.disableChecks||!this.checks?e:t_(this.checks,e,void 0,this,t)?void 0:e}toCodecStringTree(){return eW(this,[tv])}getExpected(){return"symbol"}},Z=new class extends R{_tag="BigInt";getParser(){return ts(this,g.sI)}matchPart(e,t){if(!tm.test(e))return;let r=globalThis.BigInt(e);return t.disableChecks||!this.checks?r:t_(this.checks,r,void 0,this,t)?void 0:r}toCodecStringTree(){return eW(this,[ty])}getExpected(){return"bigint"}},ee=class extends R{_tag="Arrays";isMutable;elements;rest;encodingChecks;constructor(e,t,r,n,i,a,s,o){super(n,i,a,s),this.isMutable=e,this.elements=t,this.rest=r,this.encodingChecks=o;let l=!1;for(let e=0;e<t.length;e++)if(te(t[e]))l=!0;else if(l)throw Error("A required element cannot follow an optional element. ts(1257)");if(l&&r.length>1)throw Error("A required element cannot follow an optional element. ts(1257)");for(let e=1;e<r.length;e++)if(te(r[e]))throw Error("An optional element cannot follow a rest element. ts(1266)")}getParser(e,t=e){let r,n,i=this,s=i.elements.length,o=Math.max(0,i.rest.length-1);function l(e,t){return t<s?r[t]:t>=e?n[t-e+1]:n[0]}let c=e=>{let{input:t,len:r,options:n}=e;if(0===i.rest.length&&r>s)for(let o=s;o<r;o++){let r=new b.vF(i,t[o],n),s=new b.gm([o],r);if("all"!==n.errors)return a.fJG(new b.eC(i,[s],t,n));e.issues?e.issues.push(s):e.issues=[s]}return e.issues?a.fJG(new b.eC(i,e.issues,t,n)):p.Py(e.output)},u=(e,t)=>{let r=e.length,n={ast:i,getParser:l,input:e,len:r,tailThreshold:Math.max(s,r-o),output:new globalThis.Array(r),issues:void 0,options:t},f=0===i.rest.length?s:Math.max(r,s+o),p=void 0===t.concurrency?1:(0,d.Akf)(t.concurrency),h=1===p?er(n,e,0,f):en(n,e,{concurrency:p,end:f});if(!h)return c(n);if((0,d.OY)(h))return a.Ab9(h,()=>c(n));let m=!0;return a.DYE(()=>m?(m=!1,a.qIB(h,()=>c(n))):u(e,t))};return(e,s)=>{if(e===p.LO)return p.r2;try{if(!Array.isArray(e))return a.fJG(new b.eE(i,e,s));return r||(r=i.elements.map(e=>({ast:e,parser:t(e)})),n=i.rest.map(e=>({ast:e,parser:t(e)}))),u(e,s)}catch(e){return a.F_Q(e)}}}_rebuild(e,t,r){let n=e0(this.elements,e),i=e0(this.rest,e);return n===this.elements&&i===this.rest&&t===this.checks&&r===this.encodingChecks?this:new ee(this.isMutable,n,i,this.annotations,t,void 0,this.context,r)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}getExpected(){return"array"}},et={onItem(e,t,r){let n=r<e.len?t:p.LO;return e.getParser(e.tailThreshold,r).parser(n,e.options)},step:function(e,t,r,n){if("Failure"===r._tag)return ei(e,e.ast,n,r);let i=r===p.Rr?t:r[h.a2];if(i!==p.LO)e.output[n]=i;else{let t=e.getParser(e.tailThreshold,n);if(te(t.ast))return;let r=new b.gm([n],new b.Mw(t.ast.context?.annotations));if("all"!==e.options.errors)return s.fJ(new b.eC(e.ast,[r],e.input,e.options));e.issues?e.issues.push(r):e.issues=[r]}}},er=(0,d.h$X)()(et),en=(0,d.U1p)()(et),ei=(e,t,r,n)=>{if(0===n.cause.reasons.length)return n;let a=f.R(n.cause);if(void 0===a)return s.AT(i.Tj(n.cause,n=>new b.eC(t,[new b.gm([r],n)],e.input,e.options)));let o=new b.gm([r],a);if("all"!==e.options.errors)return s.fJ(new b.eC(t,[o],e.input,e.options));e.issues?e.issues.push(o):e.issues=[o]},ea="[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?";function es(e,t,r=P){let n,i;return function t(a){switch(a._tag){case"String":case"TemplateLiteral":return(n??=Object.keys(e)).filter(e=>void 0!==a.matchPart(e,r));case"Number":return(n??=Object.keys(e)).filter(e=>void 0!==a.matchKey(e,r));case"Symbol":return(i??=Object.getOwnPropertySymbols(e)).filter(t=>Object.prototype.propertyIsEnumerable.call(e,t)&&void 0!==a.matchKey(t,r));case"Union":return[...new Set(a.types.flatMap(t))];default:return[]}}(to(tn(t)))}let eo=class{name;type;constructor(e,t){this.name=e,this.type=t}},el=class{parameter;type;constructor(e,t){if(!(function e(t){switch(t._tag){case"String":case"Number":case"Symbol":case"TemplateLiteral":return!0;case"Union":return t.types.every(e);default:return!1}}(e)&&function e(t){let r=eY(t);switch(r._tag){case"String":case"Number":case"Symbol":case"TemplateLiteral":return!0;case"Union":return r.types.every(e);default:return!1}}(e)))throw Error(`Invalid index signature parameter ${e._tag}`);if(this.parameter=e,this.type=t,te(t)&&!function e(t){switch(t._tag){case"Undefined":return!0;case"Union":return t.types.some(e);default:return!1}}(t))throw Error("Cannot use `Schema.optionalKey` with index signatures, use `Schema.optional` instead.")}},ed=class extends R{_tag="Objects";propertySignatures;indexSignatures;encodingChecks;constructor(e,t,r,n,i,a,s){super(r,n,i,a),this.propertySignatures=e,this.indexSignatures=t,this.encodingChecks=s}getParser(e,t=e){let r,i,o,l=this,u=l.propertySignatures.length,f=l.indexSignatures.length;if(!u&&!f)return ts(l,g.Vq);let m=()=>(r||(r=l.propertySignatures.map(e=>({parser:t(e.type),name:e.name,type:e.type})),i=f?l.indexSignatures.map(r=>({is:r,parserKey:e(to(r.parameter)),parserValue:t(r.type)})):void 0),r),y=()=>{let e=new Set(l.propertySignatures.map(e=>"number"==typeof e.name?globalThis.String(e.name):e.name)),t=(t,r,n,i,a)=>{if("Failure"===a._tag)return ei(t,l,r,a)??s.rI;let o=a===p.Rr?i:a[h.a2];if(n!==p.LO&&o!==p.LO){if(u&&(e.has(r)||e.has("number"==typeof n?globalThis.String(n):n)))return s.rI;c.x(t.out,n,o)}return s.rI},o=(e,r,n,i)=>{if(!i){let t=n.parserKey(r,e.options);if(!(0,d.OY)(t))return a.qIB(a.NS5(t),t=>o(e,r,n,t));i=t}if("Failure"===i._tag)return ei(e,l,r,i)??s.rI;let c=i===p.Rr?r:i[h.a2],u=e.input[r],f=n.parserValue(u,e.options);return(0,d.OY)(f)?t(e,r,c,u,f):a.qIB(a.NS5(f),n=>t(e,r,c,u,n))},g=(e,r,n)=>{let i=e.input[r],s=n.parserValue(i,e.options);return(0,d.OY)(s)?t(e,r,r,i,s):a.qIB(a.NS5(s),n=>t(e,r,r,i,n))},y=f?(0,d.U1p)()({onItem:(e,[t,r])=>r.is.parameter===G?g(e,t,r):o(e,t,r),step:(e,t,r)=>"Failure"===r._tag?r:void 0}):void 0;return a.vCS(function*(t,s){if(t===p.LO)return p.LO;if(!("object"==typeof t&&null!==t&&!Array.isArray(t)))return yield*a.fJG(new b.eE(l,t,s));m();let c={},h={ast:l,input:t,out:c,issues:void 0,options:s},v="all"===s.errors,_="error"===s.onExcessProperty,x=void 0===s.concurrency?1:(0,d.Akf)(s.concurrency),w=f&&_?l.indexSignatures.map(e=>es(t,e.parameter,s)):void 0;if(_){let r=w?new Set(e):e;if(w)for(let e of w)for(let t of e)r.add(t);let n=Reflect.ownKeys(t);for(let e=0;e<n.length;e++){let i=n[e];if(!r.has(i)&&Object.prototype.propertyIsEnumerable.call(t,i)){let e=new b.vF(l,t[i],s),r=new b.gm([i],e);if(!v)return yield*a.fJG(new b.eC(l,[r],t,s));h.issues?h.issues.push(r):h.issues=[r];continue}}}if(u){let e=1===x?ef(h,r):ep(h,r,{concurrency:x});e&&(yield*e)}if(f&&1===x)for(let e=0;e<f;e++){let r=i[e],n=r.is.parameter===G?g:o,a=w?.[e]??(r.is.parameter===G?Object.keys(t):es(t,r.is.parameter,s));for(let e=0;e<a.length;e++){let t=n(h,a[e],r);if((0,d.OY)(t)){if("Failure"===t._tag)return yield*t}else yield*t}}else if(y){let e=n.Ie();for(let r=0;r<f;r++){let n=i[r],a=w?.[r]??(n.is.parameter===G?Object.keys(t):es(t,n.is.parameter,s));for(let t=0;t<a.length;t++)e.push([a[t],n])}let r=y(h,e,{concurrency:x});r&&(yield*r)}return h.issues?yield*a.fJG(new b.eC(l,h.issues,t,s)):c})};if(f)return y();let v=(e,t,n)=>{let i=r[t];return a.qIB(a.NS5(n),n=>{let s=ec(e,i,n);if(s)return s;let o=()=>p.Py(e.out),l=ef(e,r.slice(t+1));return l?a.Ab9(l,o):o()})};return(e,t)=>{if(e===p.LO)return p.r2;if("all"===t.errors||void 0!==t.onExcessProperty||void 0!==t.concurrency&&1!==(0,d.Akf)(t.concurrency))return(o??=y())(e,t);if(!("object"==typeof e&&null!==e&&!Array.isArray(e)))return a.fJG(new b.eE(l,e,t));let r=m(),n={},i={ast:l,input:e,out:n,issues:void 0,options:t};try{for(let a=0;a<r.length;a++){let s=r[a],o=s.name,l=eI(e,o),u=l?e[o]:p.LO,f=s.parser(u,t);if(!(0,d.OY)(f))return v(i,a,f);if(f===p.Rr){l&&c.x(n,o,u);continue}let h=ec(i,s,f);if(h)return h}}catch(e){return a.F_Q(e)}return p.Py(n)}}_rebuild(e,t,r,n){let i=e0(this.propertySignatures,t=>{let r=e(t.type);return r===t.type?t:new eo(t.name,r)}),a=e0(this.indexSignatures,r=>{let n=t(r.parameter),i=e(r.type);return n===r.parameter&&i===r.type?r:new el(n,i)});return i===this.propertySignatures&&a===this.indexSignatures&&r===this.checks&&n===this.encodingChecks?this:new ed(i,a,this.annotations,r,void 0,this.context,n)}flip(e){return this._rebuild(e,e,this.encodingChecks,this.checks)}recur(e,t=e){return this._rebuild(e,t,this.checks,this.encodingChecks)}getExpected(){return 0===this.propertySignatures.length&&0===this.indexSignatures.length?"object | array":"object"}};function ec(e,t,r){if("Failure"===r._tag)return ei(e,e.ast,t.name,r);if(r===p.Rr)return;let n=r[h.a2];if(n!==p.LO)return void c.x(e.out,t.name,n);if(delete e.out[t.name],!te(t.type)){let r=new b.gm([t.name],new b.Mw(t.type.context?.annotations));return"all"!==e.options.errors?s.fJ(new b.eC(e.ast,[r],e.input,e.options)):void(e.issues?e.issues.push(r):e.issues=[r])}}let eu={onItem(e,t){if(!eI(e.input,t.name))return t.parser(p.LO,e.options);let r=e.input[t.name];return c.x(e.out,t.name,r),t.parser(r,e.options)},step:ec},ef=(0,d.h$X)()(eu),ep=(0,d.U1p)()(eu);function eh(e,t){return e?t?[...e,...t]:e:t}function em(e,t,r){return new ed(Reflect.ownKeys(e).map(t=>new eo(t,e[t].ast)),[],r,t)}function eg(e){return e.ast}function ey(e,t){return new ee(!1,e.map(e=>e.ast),[],void 0,t)}function eb(e,t,r){return new e$(e.map(eg),t,void 0,r)}function ev(e){if(e.encoding)throw Error("mutable does not support encodings");return new ee(!0,e.elements,e.rest,e.annotations,e.checks,void 0,e.context,e.encodingChecks)}let e_=(0,l.qE)(e=>{for(;;){if(T(e))return J;let t=e.encoding;if(!t)return e.recur?.(e_,l.D_)??e;if(t.some(e=>"Middleware"===e.transformation._tag&&e.transformation.decode!==l.D_))return J;e=t[t.length-1].to}});function ex(e){switch(e._tag){default:return[];case"Declaration":{let t=e.annotations?.[u.I_];return Array.isArray(t)?t:[]}case"Objects":return e.propertySignatures.flatMap(e=>{let t=e.type;if(!te(t)){if($(t))return[{key:e.name,literal:t.literal}];if(E(t))return[{key:e.name,literal:t.symbol}]}return[]});case"Arrays":return e.elements.flatMap((e,t)=>{if(!te(e)){if($(e))return[{key:t,literal:e.literal}];if(E(e))return[{key:t,literal:e.symbol}]}return[]});case"Union":{if(0===e.types.length)return[];let t=e.types.map(e=>ex(e_(e)));return t[0].filter(e=>t.every(t=>t.some(t=>t.key===e.key&&t.literal===e.literal)))}case"Suspend":return ex(e.thunk())}}let ew=new WeakMap,ek=Object.freeze([]),eS=e=>null===e?"null":Array.isArray(e)?"array":typeof e,eI=(e,t)=>"__proto__"===t?Object.hasOwn(e,t):t in e,e$=class extends R{_tag="Union";types;options;encodingChecks;constructor(e,t,r,n,i,a,s){super(r,n,i,a),this.types=e,this.options=t,this.encodingChecks=s}getParser(e,t){let r,n=this,i=void 0!==t,s=[],o=t=>s[t]??=e(n.types[t]);return(e,t)=>{if(e===p.LO)return p.r2;let s=(r??=function(e){let t,r,n,i=ew.get(e);if(i)return i;let a=0,s=!0,o=[];for(let i=0;i<e.length;i++){let l=e_(e[i]);if(w(l))continue;if($(l)||E(l)){n??=new Map;let e=$(l)?l.literal:l.symbol;o[i]=e;let t=n.get(e);t||n.set(e,t=[]),t.push(i)}else s=!1;let d=ex(l);if(d.length)for(let{key:e,literal:r}of(t??=new Map,a++,d)){let n=t.get(e);n||t.set(e,n=[new Map,new Set]),n[1].add(i);let a=n[0].get(r);a||n[0].set(r,a=new Set),a.add(i)}else for(let e of(r??={},function e(t){switch(t._tag){case"Null":return["null"];case"Undefined":return["undefined"];case"String":case"TemplateLiteral":return["string"];case"Number":return["number"];case"Boolean":return["boolean"];case"Symbol":case"UniqueSymbol":return["symbol"];case"BigInt":return["bigint"];case"Arrays":return["array"];case"ObjectKeyword":return["object","array","function"];case"Objects":return t.propertySignatures.length||t.indexSignatures.length?["object"]:["string","number","boolean","symbol","bigint","object","array","function"];case"Enum":return Array.from(new Set(t.enums.map(([,e])=>typeof e)));case"Literal":return[typeof t.literal];case"Union":return Array.from(new Set(t.types.flatMap(e)));default:return["null","undefined","string","number","boolean","symbol","bigint","object","array","function"]}}(l)))(r[e]??=[]).push(i)}let l={},d=e=>l[e]??=Object.freeze(r?.[e]??ek);if(s&&n)n.forEach(Object.freeze),i=e=>n.get(e)??ek;else if(t?.size!==1||r)if(t){let e;for(let r of t)(!e||r[1][0].size>e[1][0].size)&&r[1][1].size===a&&(e=r);i=(n,i)=>{let a,s=eS(n);if(!g.Fw(n))return d(s);let o=new Set(r?.[s]);if(e){let[t,[r]]=e,l=eI(n,t),c=l?n[t]:void 0;if(l&&(!i||void 0!==c)){let e=r.get(c);if(!e)return d(s);for(let t of e)o.add(t);a=t}}if(void 0===a)for(let[e,[r,a]]of t){let t=eI(n,e),s=t?n[e]:void 0;if(t&&(!i||void 0!==s)){let e=r.get(s);if(e)for(let t of e)o.add(t)}else if(i)for(let e of a)o.add(e)}for(let[e,[r,s]]of t){if(e===a)continue;let t=eI(n,e),l=t?n[e]:void 0;if(t&&(!i||void 0!==l)){let e=r.get(l);for(let t of o)s.has(t)&&!e?.has(t)&&o.delete(t)}}return Array.from(o).sort((e,t)=>e-t)}}else i=e=>{let t=d(eS(e));return n?t.filter(t=>void 0===o[t]||o[t]===e):t};else{let[r,[n]]=t.entries().next().value,a=new Map;for(let[e,t]of n)a.set(e,Object.freeze(Array.from(t)));let s=Object.freeze(e.map((e,t)=>t));i=(e,t)=>{if(g.Fw(e)){let n=eI(e,r)?e[r]:void 0;if(void 0!==n)return a.get(n)??ek;if(t)return s}return ek}}return ew.set(e,i),i}(n.types))(e,i);if(0===s.length)return a.fJG(new b.W(n,[],e,t));if(1===s.length){let r=o(s[0])(e,t);return"Success"===r._tag?r:(0,d.OY)(r)?eE(n,r.cause,e,t):(l=n,c=r,u=e,f=t,a.Tyx(c,e=>eE(l,e,u,f)))}var l,c,u,f,h,m,y=n,v=o,_=s,x=e,k=t;let S={ast:y,parser:v,input:x,out:void 0,successes:y.options?.mode==="oneOf"?[]:void 0,issues:void 0,options:k},I=eO(S,_);if(!I)return S.out?S.out:a.fJG(new b.W(y,S.issues??[],x,k));return h=I,m=S,a.Ab9(h,e=>m.out===p.Rr?a.PyW(m.input):m.out?m.out:a.fJG(new b.W(m.ast,m.issues??[],m.input,m.options)))}}_rebuild(e,t,r){let n=e0(this.types,e);return n===this.types&&t===this.checks&&r===this.encodingChecks?this:new e$(n,this.options,this.annotations,t,void 0,this.context,r)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}matchPart(e,t){for(let r of this.types){let n=r.matchPart(e,t);if(void 0!==n)return n}}getExpected(e){let t=this.annotations?.expected;return"string"==typeof t?t:0===this.types.length?"never":Array.from(new Set(this.types.map(t=>{let r=tn(t);switch(r._tag){case"Arrays":{let t=r.elements.filter($);if(t.length>0)return`${eT(r.isMutable)}[ ${t.map(t=>e(t)+(t.context?.isOptional?"?":"")).join(", ")}, ... ]`;break}case"Objects":{let t=r.propertySignatures.filter(e=>$(e.type));if(t.length>0)return`{ ${t.map(t=>`${eT(t.type.context?.isMutable)}${(0,o._r)(t.name)}${t.type.context?.isOptional?"?":""}: ${e(t.type)}`).join(", ")}, ... }`}}return e(r)}))).join(" | ")}};function eE(e,t,r,n){let i=f.R(t);return i?s.fJ(new b.W(e,[i],r,n)):s.AT(t)}let eO=(0,d.h$X)()({onItem:(e,t)=>e.parser(t)(e.input,e.options),step(e,t,r){if("Failure"===r._tag){let t=f.R(r.cause);if(void 0===t)return r;e.issues?e.issues.push(t):e.issues=[t]}else{if(e.out&&e.successes)return e.successes.push(e.ast.types[t]),s.fJ(new b.E8(e.ast,e.successes,e.input,e.options));if(e.out=r,!e.successes)return s.rI;e.successes.push(e.ast.types[t])}}}),eC=new e$([new X("Infinity"),new X("-Infinity"),new X("NaN")]);function eT(e){return e?"":"readonly "}let eM=class extends R{_tag="Suspend";thunk;constructor(e,t,r,n,i){let a;if(r)throw Error("Cannot add checks to Suspend");super(t,void 0,n,i),this.thunk=()=>a??=e()}getParser(e){let t;return(r,n)=>(t??=e(this.thunk()))(r,n)}recur(e){return new eM(()=>e(this.thunk()),this.annotations,void 0,void 0,this.context)}getExpected(e){return e(this.thunk())}},eP=class extends m.Xs{_tag="Filter";run;annotations;aborted;constructor(e,t,r=!1){super(),this.run=e,this.annotations=t,this.aborted=r}annotate(e){return new eP(this.run,{...this.annotations,...e},this.aborted)}abort(){return new eP(this.run,this.annotations,!0)}and(e,t){return new eA([this,e],t)}},eA=class extends m.Xs{_tag="FilterGroup";checks;annotations;constructor(e,t){super(),this.checks=e,this.annotations=t}annotate(e){return new eA(this.checks,{...this.annotations,...e})}and(e,t){return new eA([this,e],t)}};function eN(e,t,r=!1){return new eP((t,r,n)=>b.PY(r,e(t,r,n),t,n),t,r)}function eR(e,t){return new eP((t,r,n)=>e(t)?void 0:new b.h6(void 0,t,n),t,!0)}function ej(e){return eN(e=>globalThis.Number.isFinite(e),{expected:"a finite number",representation:{id:"effect/schema/isFinite",payload:null},toJsonSchema:()=>({type:"number"}),toCode:()=>({runtime:"Schema.isFinite()"}),arbitraryConstraint:{number:"finite"},...e})}let eD=eG(H,[ej()]),eU=new M(new e$([eD,eC]),new v.IT(y.wN(),y.pd(e=>globalThis.Number.isFinite(e)?e:globalThis.String(e))));function eF(e,t){let r=new globalThis.RegExp(e),n={source:r.source,flags:r.flags};return eN(e=>(r.lastIndex=0,r.test(e)),{expected:`a string matching the RegExp ${n.source}`,representation:{id:"effect/schema/isPattern",payload:n},toJsonSchema:()=>[{},!0],arbitraryConstraint:{patterns:[n]},...t})}let eB=new WeakMap;function eL(e,t){let r=Object.assign(Object.create(Object.getPrototypeOf(e)),e,t);return Reflect.ownKeys(t).every(e=>"context"===e||"encoding"===e)&&eB.set(r,ez(e)),r}function ez(e){let t=eB.get(e);if(void 0!==t)return t;if(void 0===e.encoding)return e;let r=Object.assign(Object.create(Object.getPrototypeOf(e)),e,{encoding:void 0});return eB.set(e,r),r}function eW(e,t){return e.encoding===t?e:eL(e,{encoding:t})}function eJ(e,t){if(e.context===t)return e;let r=ez(e);return r.context===t&&r.encoding===e.encoding?r:eL(e,{context:t})}function eY(e){return e.encoding?eY(e.encoding[e.encoding.length-1].to):e}function eX(e,t){if(e.checks){let r=e.checks[e.checks.length-1];return eq(e,n.BC(e.checks.slice(0,-1),r.annotate(t)))}return eL(e,{annotations:{...e.annotations,...t}})}function eq(e,t){if("Suspend"===e._tag&&t)throw Error("Cannot add checks to Suspend");return e.checks===t?e:eL(e,{checks:t})}function eG(e,t){return eq(e,eh(e.checks,t))}function eV(e,t){let r=t(e.to);return r===e.to?e:new M(r,e.transformation)}function eH(e,t){let r=e[e.length-1],i=eV(r,t);return i===r?e:n.BC(e.slice(0,e.length-1),i)}function eK(e){return t=>t.encoding?eW(t,eH(t.encoding,e)):t}function eQ(e,t){return eK(e=>eJ(e,t))(e)}function eZ(e,t){return(0,l.qE)(function r(n){if(n.encoding){let e=n.encoding[n.encoding.length-1];return t?.stopAt?.(e)?n:eW(n,eH(n.encoding,r))}return e(n)})}function e0(e,t){let r;for(let n=0;n<e.length;n++){let i=e[n],a=t(i);if(r)r[n]=a;else if(a!==i){r=Array(e.length);for(let t=0;t<n;t++)r[t]=e[t];r[n]=a}}return r??e}function e1(e,t){let r=e.context?new A(e.context.isOptional,e.context.isMutable,e.context.constructorDefault,{...e.context.annotations,...t}):new A(!1,!1,void 0,t);return eJ(e,r)}let e2=(0,l.qE)(e=>{let t=e.context?!1===e.context.isOptional?new A(!0,e.context.isMutable,e.context.constructorDefault,e.context.annotations):e.context:new A(!0,!1);return e5(eJ(e,t))}),e5=eK(e2),e3=(0,l.Bj)(e=>e2(new e$([e,B]))),e6=(0,l.qE)(e=>{let t=e.context?!1===e.context.isMutable?new A(e.context.isOptional,!0,e.context.constructorDefault,e.context.annotations):e.context:new A(!1,!0);return e8(eJ(e,t))}),e8=eK(e6);function e9(e,t){let r=e.context?new A(e.context.isOptional,e.context.isMutable,t,e.context.annotations):new A(!1,!1,t);return eJ(e,r)}function e4(e,t,r){let n;return n=new M(e,r),eW(t,t.encoding?[...t.encoding,n]:[n])}function e7(e,t){let r,n,{literals:i,parameters:a}=(r=[],n=[],!function e(t){switch(t._tag){case"Literal":g.hL(t.literal)&&!r.includes(t.literal)&&r.push(t.literal);return;case"UniqueSymbol":r.includes(t.symbol)||r.push(t.symbol);return;case"Never":return;case"Union":for(let r=0;r<t.types.length;r++)e(t.types[r]);return;default:n.push(t)}}(e),{literals:r,parameters:n});return new ed(i.map(e=>new eo(e,t)),a.map(e=>new el(e,t)))}function te(e){return e.context?.isOptional??!1}function tt(e){return e.context?.isMutable??!1}let tr=(0,l.qE)(e=>{let t=ez(e);if(t!==e){let r=tr(t);return r===t&&void 0===e.encoding?e:eJ(r,e.context)}let r="recur"in e?e.recur(tr):e;if("encodingChecks"in r&&r.encodingChecks){let t,i,a=(t=!0,"recur"in e&&e.recur(function e(r){return(t=t&&!r.encoding&&!T(r))&&"recur"in r&&r.recur(e),r}),t)?r.encodingChecks:O(r)||C(r)||x(r)&&r.typeParameters.length>0?(i=r.encodingChecks.flatMap(function e(t){return!function e(t){return t.annotations?.[u.C3]===!0||"FilterGroup"===t._tag&&t.checks.every(e)}(t)?"FilterGroup"===t._tag?t.checks.flatMap(e):[]:[t]}),n.CZ(i)?i:void 0):void 0;return eL(r,{encodingChecks:void 0,checks:eh(r.checks,a)})}return r}),tn=(0,l.qE)(e=>tr(ti(e))),ti=(0,l.Bj)(e=>{if(e.encoding)return function(e,t){let r=t.length,n=t[r-1],i=[new M(ti(eW(e,void 0)),t[0].transformation.flip())];for(let e=1;e<r;e++)i.unshift(new M(ti(t[e-1].to),t[e].transformation.flip()));let a=ti(n.to);return a.encoding?eW(a,[...a.encoding,...i]):eW(a,i)}(e,e.encoding);let t=ez(e);if(t!==e){let r=ti(t);return r===t?e:eJ(r,e.context)}return"flip"in e?e.flip(ti):"recur"in e?e.recur(ti):e});function ta(e,t){let r=0===t?p.Rr:p.Py(t);return(n,i)=>n===p.LO?p.r2:n===t?r:a.fJG(new b.eE(e,n,i))}function ts(e,t){return(r,n)=>r===p.LO?p.r2:t(r)?p.Rr:a.fJG(new b.eE(e,r,n))}let to=eZ(e=>{switch(e._tag){default:return e;case"Number":return e.toCodecStringTree();case"Union":return e.recur(to)}}),tl=eZ(e=>{switch(e._tag){default:return e;case"Symbol":case"UniqueSymbol":return e.toCodecStringTree();case"Union":return e.recur(tl)}}),td=eZ(e=>{switch(e._tag){default:return e;case"Number":case"Literal":case"BigInt":return e.toCodecStringTree();case"Union":return e.recur(td)}}),tc=new globalThis.RegExp(`^${ea}$`),tu=new globalThis.RegExp(`^(?:${ea}|Infinity|-Infinity|NaN)$`),tf=eG(G,[eF(tc,{expected:"a string representing a finite number",representation:{id:"effect/schema/isStringFinite",payload:null},toJsonSchema:()=>({pattern:tc.source})})]),tp=new M(tf,v.ZK),th=new M(new e$([tf,eC]),v.ZK),tm=new globalThis.RegExp("^-?\\d+$"),tg=eG(G,[eF(tm,{expected:"a string representing a bigint",representation:{id:"effect/schema/isStringBigInt",payload:null},toJsonSchema:()=>({pattern:tm.source}),expected:"a string representing a bigint"})]),ty=new M(tg,v.R7),tb=new globalThis.RegExp("^Symbol\\(([\\s\\S]*)\\)$"),tv=new M(eG(G,[eF(tb,{expected:"a string representing a symbol",representation:{id:"effect/schema/isStringSymbol",payload:null},toJsonSchema:()=>({pattern:tb.source})})]),new v.IT(y.pd(e=>globalThis.Symbol.for(tb.exec(e)[1])),y.ez((e,t)=>void 0!==globalThis.Symbol.keyFor(e)?a.PyW(globalThis.String(e)):a.fJG(new b.cw({message:"cannot serialize to string, Symbol is not registered"},e,t)))));function t_(e,t,r,n,i){for(let a=0;a<e.length;a++){let s=e[a];if("FilterGroup"===s._tag){if((r=t_(s.checks,t,r,n,i))&&("all"!==i.errors||r[r.length-1].filter.aborted))break}else{let e=s.run(t,n,i);if(e){let n=new b.dJ(s,e,t,i);if(r?r.push(n):r=[n],"all"!==i.errors||s.aborted)break}}}return r}function tx(e){if(!x(e))return;let t=e.annotations?.[u.py];return g.Tn(t)?t(e.typeParameters):void 0}function tw(e){return null===e||"string"==typeof e||"boolean"==typeof e||"number"==typeof e&&globalThis.Number.isFinite(e)}function tk(e){return void 0===e||"string"==typeof e}function tS(e,t){let r=new WeakMap,n=[];e:for(;;){if("object"!=typeof e||null===e){if(!t(e))return!1}else{let t=e,i=r.get(t);if(!1===i)return!1;if(void 0===i){let e=Array.isArray(t);if(!e){let e=Object.getPrototypeOf(t);if(null!==e&&e!==Object.prototype&&null!==Object.getPrototypeOf(e))return!1}r.set(t,!1),n.push({value:t,keys:e?t.length:Object.keys(t),index:0})}}for(;n.length>0;){let t=n[n.length-1],i=t.keys;if("number"==typeof i){if(t.index<i){e=t.value[t.index++];continue e}}else if(t.index<i.length){e=t.value[i[t.index++]];continue e}r.set(t.value,!0),n.pop()}return!0}}function tI(e){return tS(e,tw)}u.hd,u.ip,u.KE,u.DQ,u.Pk;let t$=new j([],()=>(e,t,r)=>tI(e)?p.Rr:a.fJG(new b.eE(t,e,r)),{representation:{id:"effect/schema/Json",payload:null},expected:"JSON value",toCodecJson:()=>void 0,toCodecStringTree:()=>tT}),tE=eX(t$,{representation:{id:"effect/schema/MutableJson",payload:null}}),tO=new M(t$,v.le()),tC=new M(new e$([new ee(!1,[],[t$]),new ed([],[new el(G,t$)])]),v.le()),tT=new M(new j([],()=>(e,t,r)=>tS(e,tk)?p.Rr:a.fJG(new b.eE(t,e,r)),{expected:"StringTree",toCodecStringTree:()=>void 0}),v.le());r.d(t,{B9:()=>eZ,D$:()=>eR,EJ:()=>eG,ES:()=>eW,Ez:()=>e9,Fh:()=>tI,GL:()=>e4,HN:()=>eN,KC:()=>eb,Lp:()=>t_,MI:()=>ej,PV:()=>ey,Pt:()=>eF,Q0:()=>eQ,S5:()=>eY,SL:()=>ex,Td:()=>eV,bV:()=>tt,dK:()=>te,fX:()=>ev,fz:()=>eX,g1:()=>e7,gR:()=>tx,hu:()=>eg,us:()=>e1,v1:()=>ez,w3:()=>em},{Ax:tr,BF:tE,D6:j,DO:ee,E2:eD,Et:S,Gf:tO,HR:Q,Kg:k,L5:J,LM:t$,Lm:I,N_:M,Nt:tg,O3:tn,Qr:e2,RP:C,UU:ti,V3:eM,Vx:B,W:e6,W5:tC,XV:"[\\s\\S]*?",Yj:G,ZG:Y,Zm:z,ai:H,bm:ea,bz:W,c$:$,ch:D,gP:e$,lq:e3,ob:A,rI:L,tC:tT,tF:O,uS:X,vr:P,we:Z,xw:tl,zM:K})},2981(e,t,r){r.d(t,{Qw:()=>O,n9:()=>C,wN:()=>E,Qf:()=>$,y4:()=>R,$T:()=>j,$X:()=>D,UD:()=>U,EF:()=>F,xQ:()=>B,mF:()=>z,WG:()=>P,DX:()=>A,mU:()=>N,_p:()=>L,J5:()=>b,cJ:()=>S,qF:()=>T,le:()=>_,sd:()=>M,pd:()=>x,ez:()=>w,IQ:()=>I});var n,i,a=r(2842),s=r(2997),o=r(9315),l=r(9913);let d=e=>s.lF(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_"),c=e=>{let t=e.replace(/[\n\r]/g,""),r=t.length;if(r%4==1)return o.fJ(new l.Ug({module:"Base64Url",kind:"Decode",input:t,message:`Length should be a multiple of 4, but is ${r}`}));if(!/^[-_A-Z0-9]*?={0,2}$/i.test(t))return o.fJ(new l.Ug({module:"Base64Url",kind:"Decode",input:t,message:"Invalid input"}));let n=r%4==2?`${t}==`:r%4==3?`${t}=`:t;return n=n.replace(/-/g,"+").replace(/_/g,"/"),s.D4(n)},u=new TextDecoder;var f=r(1229),p=r(1587),h=r(1554),m=r(4233),g=r(7086);let y=e=>Object.assign(Object.create(h.bp),e),b=(n=()=>"Encoding is not supported",i=(e,t)=>{let r={message:n()};return p.isSome(e)?new g.cw(r,e.value,t):new g.cw(r)},k((e,t)=>a.fJG(i(e,t)))),v=y({_tag:"Passthrough"});function _(){return v}function x(e){return y({_tag:"Transform",transform:e})}function w(e){return y({_tag:"TransformEffect",transform:e})}function k(e){return y({_tag:"TransformOptionalEffect",transform:e})}function S(){return y({_tag:"TransformOptional",transform:()=>p.none()})}function I(e){return k(t=>{let r=p.filter(t,m.EA);return p.isSome(r)?a.PyW(r):a.jkJ(e,p.some)})}function $(){return x(globalThis.String)}function E(){return x(globalThis.Number)}function O(){return x(globalThis.BigInt)}function C(){return x(e=>new globalThis.Date(e))}function T(e){return w((t,r)=>a.SvU({try:()=>JSON.parse(t,e?.reviver),catch:()=>new g.h6({expected:"a valid JSON string"},t,r)}))}function M(e){return w((t,r)=>a.SvU({try:()=>{let r=JSON.stringify(t,e?.replacer,e?.space);if(void 0===r)throw TypeError("Value cannot be represented as JSON");return r},catch:()=>new g.h6({expected:"a JSON-serializable value"},t,r)}))}function P(){return x(s.lF)}function A(){return x(d)}function N(){return x(f.lF)}function R(){return w((e,t)=>a.Z9x(a.yUA(s.D4(e)),()=>new g.h6({expected:"a valid Base64 string"},e,t)))}function j(){return w((e,t)=>o.YW(s.sc(e),{onFailure:()=>a.fJG(new g.h6({expected:"a valid Base64 string"},e,t)),onSuccess:a.PyW}))}function D(){return w((e,t)=>o.YW(c(e),{onFailure:()=>a.fJG(new g.h6({expected:"a valid Base64Url string"},e,t)),onSuccess:a.PyW}))}function U(){return w((e,t)=>o.YW(o.Tj(c(e),e=>u.decode(e)),{onFailure:()=>a.fJG(new g.h6({expected:"a valid Base64Url string"},e,t)),onSuccess:a.PyW}))}function F(){return w((e,t)=>o.YW(f.D4(e),{onFailure:()=>a.fJG(new g.h6({expected:"a valid hexadecimal string"},e,t)),onSuccess:a.PyW}))}function B(){return w((e,t)=>o.YW(f.sc(e),{onFailure:()=>a.fJG(new g.h6({expected:"a valid hexadecimal string"},e,t)),onSuccess:a.PyW}))}function L(){return x(encodeURIComponent)}function z(){return w((e,t)=>{try{return a.PyW(globalThis.decodeURIComponent(e))}catch{return a.fJG(new g.h6({expected:"a valid URI component"},e,t))}})}m.Kg},7086(e,t,r){var n=r(664),i=r(1958),a=r(2840),s=r(587),o=r(4233);let l="~effect/SchemaIssue/Issue";function d(e){return(0,o.i5)(e,l)&&e[l]===l}function c(e){return Object.hasOwn(e,"input")}class u{[l]=l;constructor(e,t){t?.reportInput===!0&&e!==s.LO&&(this.input=e)}}let f=class extends u{_tag="Filter";filter;issue;constructor(e,t,r,n){super(r,n),this.filter=e,this.issue=t}},p=class extends u{_tag="Encoding";ast;issue;constructor(e,t,r,n){super(r,n),this.ast=e,this.issue=t}},h=class extends u{_tag="Pointer";path;issue;constructor(e,t){super(),this.path=e,this.issue=t}},m=class extends u{_tag="MissingKey";annotations;constructor(e){super(),this.annotations=e}},g=class extends u{_tag="UnexpectedKey";ast;constructor(e,t,r){super(t,r),this.ast=e}},y=class extends u{_tag="Composite";ast;issues;constructor(e,t,r,n){super(r,n),this.ast=e,this.issues=t}},b=class extends u{_tag="InvalidType";ast;constructor(e,t,r){super(t,r),this.ast=e}},v=class extends u{_tag="InvalidValue";annotations;constructor(e,t,r){super(t,r),this.annotations=e}},_=class extends u{_tag="Forbidden";annotations;constructor(e,t,r){super(t,r),this.annotations=e}},x=class extends u{_tag="AnyOf";ast;issues;constructor(e,t,r,n){super(r,n),this.ast=e,this.issues=t}},w=class extends u{_tag="OneOf";ast;successes;constructor(e,t,r,n){super(r,n),this.ast=e,this.successes=t}};function k(e,t,r){if(d(e))return e;if("string"==typeof e)return new v({message:e},t,r);let n="string"==typeof e.issue?new v({message:e.issue},t,r):e.issue;return new h(e.path,n)}function S(e,t,r,i){if(Array.isArray(t)){if(!n.ET(t))return;return 1===t.length?k(t[0],r,i):new y(e,n.Tj(t,e=>k(e,r,i)),r,i)}if(void 0!==t)return"boolean"==typeof t?t?void 0:new v(void 0,r,i):k(t,r,i)}let I=e=>{let t=P(e);if(void 0!==t)return t;switch(e._tag){case"InvalidType":return T(a.bo(e.ast),e);case"InvalidValue":{let t=C(e);if(void 0!==t)return T(t,e);let r=O(e);return void 0===r?"Expected a valid value":`Invalid data ${r}`}case"MissingKey":return"Missing key";case"UnexpectedKey":{let t=O(e);return void 0===t?"Expected no excess property":`Unexpected key with value ${t}`}case"Forbidden":return"Forbidden operation";case"OneOf":{let t=O(e);return void 0===t?"Expected exactly one member to match":`Expected exactly one member to match the input ${t}`}}},$=e=>P(e.issue)??P(e);function E(e){return t=>({issues:function e(t,r,n,i){switch(t._tag){case"Filter":{let a=i(t);if(void 0!==a)return[{path:r,message:a}];if("InvalidValue"!==t.issue._tag)return e(t.issue,r,n,i);let s=C(t.issue);return[{path:r,message:void 0===s?T(M(t.filter),t):T(s,t.issue)}]}case"Encoding":return e(t.issue,r,n,i);case"Pointer":return e(t.issue,[...r,...t.path],n,i);case"Composite":return t.issues.flatMap(t=>e(t,r,n,i));case"AnyOf":if(0===t.issues.length)return[{path:r,message:P(t)??T(a.bo(t.ast),t)}];return t.issues.flatMap(t=>e(t,r,n,i));default:return[{path:r,message:n(t)}]}}(t,[],e?.leafHook??I,e?.checkHook??$)})}function O(e){return c(e)?(0,i.GP)(e.input):void 0}function C(e){let t=e.annotations?.expected;return"string"==typeof t?t:void 0}function T(e,t){let r=O(t);return void 0===r?`Expected ${e}`:`Expected ${e}, got ${r}`}function M(e){let t=e.annotations?.expected;if("string"==typeof t)return t;switch(e._tag){case"Filter":return"<filter>";case"FilterGroup":return e.checks.map(e=>M(e)).join(" & ")}}function P(e){if("Pointer"===e._tag)return;if("Encoding"===e._tag)return P(e.issue);let t="Filter"===e._tag?e.filter.annotations:"annotations"in e?e.annotations:e.ast.annotations,r=t?.["MissingKey"===e._tag?"messageMissingKey":"UnexpectedKey"===e._tag?"messageUnexpectedKey":"message"];if("string"==typeof r)return r}r.d(t,{ID:()=>E,PY:()=>S,bZ:()=>c,gh:()=>d},{E8:w,EN:e=>(function e(t,r){let n;switch(t._tag){case"Filter":{let i=$(t);if(void 0!==i)n=i;else{if("InvalidValue"!==t.issue._tag)return e(t.issue,r);let i=C(t.issue);n=void 0===i?T(M(t.filter),t):T(i,t.issue)}break}case"Encoding":return e(t.issue,r);case"Pointer":return e(t.issue,r+(0,i.jV)(t.path));case"Composite":case"AnyOf":if("Composite"===t._tag||t.issues.length>0)return t.issues.map(t=>e(t,r)).join("\n");n=P(t)??T(a.bo(t.ast),t);break;default:n=I(t)}return r?`${n}
236
- at ${r}`:n})(e,""),Mw:m,W:x,Wi:p,cw:_,dJ:f,eC:y,eE:b,gm:h,h6:v,vF:g,vp:I})},7268(e,t,r){var n=r(3265),i=r(2842),a=r(1958),s=r(1587),o=r(1554),l=r(4233),d=r(2981),c=r(7086);let u=class extends o.Xs{_tag="Middleware";decode;encode;constructor(e,t){super(),this.decode=e,this.encode=t}flip(){return new u(this.encode,this.decode)}},f="~effect/SchemaTransformation/Transformation",p=class extends o.Xs{[f]=f;_tag="Transformation";decode;encode;constructor(e,t){super(),this.decode=e,this.encode=t}flip(){return new p(this.encode,this.decode)}};function h(e){return new p(d.ez(e.decode),d.ez(e.encode))}function m(e){return new p(d.pd(e.decode),d.pd(e.encode))}let g=new p(d.le(),d.le());function y(){return g}let b=new p(d.wN(),d.Qf()),v=new p(d.Qw(),d.Qf()),_=new p(d.n9(),d.pd(a.Yq)),x=new p(d.n9(),d.pd(e=>e.getTime())),w=h({decode:(e,t)=>s.match(n.sH(e),{onNone:()=>i.fJG(new c.h6({expected:"a valid ByteSize string"},e,t)),onSome:i.PyW}),encode:e=>i.PyW(`${e} ${e===BigInt(1)?"byte":"bytes"}`)}),k=h({decode:(e,t)=>s.match(n.lX(e),{onNone:()=>i.fJG(new c.h6({expected:"a non-negative bigint byte count"},e,t)),onSome:i.PyW}),encode:e=>i.PyW(n.Dg(e))}),S=h({decode:(e,t)=>s.match(n.lX(e),{onNone:()=>i.fJG(new c.h6({expected:"a non-negative safe-integer byte count"},e,t)),onSome:i.PyW}),encode:(e,t)=>s.match(n.Ro(e),{onNone:()=>i.fJG(new c.h6({expected:"a ByteSize representable as a safe integer"},e,t)),onSome:i.PyW})}),I=e=>{let t;return l.Gv(e)&&"string"==typeof e.message?(t=Object.hasOwn(e,"cause")?Error(e.message,{cause:I(e.cause)}):Error(e.message),"string"==typeof e.name&&"Error"!==e.name&&(t.name=e.name),"string"==typeof e.stack&&(t.stack=e.stack),t):e},$=h({decode:(e,t)=>URL.canParse(e)?i.PyW(new URL(e)):i.fJG(new c.h6({expected:"a valid URL string"},e,t)),encode:e=>i.PyW(e.href)}),E=new p(d.y4(),d.WG()),O=new p(d.$T(),d.WG()),C=new p(d.UD(),d.DX()),T=new p(d.xQ(),d.mU()),M=new p(d.mF(),d._p());function P(e){return new p(d.qF(e??{}),d.sd(e))}r.d(t,{ez:()=>h,le:()=>y,mj:()=>P,pd:()=>m},{$l:k,Ct:O,HO:x,IT:p,LL:C,NX:S,Pe:w,Pp:M,R7:v,U0:E,Y5:T,YZ:_,ZK:b,nY:$,sm:e=>{let t,r;return m({decode:I,encode:(t=new WeakSet,r=n=>{if(l.bJ(n)){var i;let a;if(t.has(n))return"[Circular]";t.add(n);let s=(i=r,a={name:n.name,message:"string"==typeof n.message?n.message:""},e?.includeStack&&"string"==typeof n.stack&&(a.stack=n.stack),e?.excludeCause||void 0===n.cause||(a.cause=i(n.cause)),a);return t.delete(n),s}try{let e=(0,a.IB)(n);return void 0===e?(0,a.GP)(n):JSON.parse(e)}catch{return(0,a.GP)(n)}})})},w8:e=>l.i5(e,f)&&e[f]===f?e:new p(e.decode,e.encode)})},5744(e,t,r){var n=r(6297);n.kWD,n.obm;let i=n.DLK;n.RWE;let a=n.d97,s=n.AAo,o=n.Uio,l=n.iLB;n.Z$R;let d=n.pSt,c=n.vDJ;n.fou,n.mdu,r.d(t,{},{Fp:d,Gt:s,HG:i,LZ:a,U9:l,VN:c,a6:o})},2707(e,t,r){var n=r(1179),i=r(1229),a=r(1594),s=r(1587);let o="effect/Tracer/ParentSpan";class l extends(n.kl())(o,{fiberCached:!0}){}let d=n.Or("effect/Tracer/DisablePropagation",{defaultValue:a.f4}),c=n.Or("effect/Tracer/CurrentTraceLevel",{defaultValue:()=>"Info"}),u=n.Or("effect/Tracer/MinimumTraceLevel",{defaultValue:()=>"All"}),f="effect/Tracer",p=n.Or(f,{fiberCached:!0,defaultValue:()=>h}),h={span:e=>new m(e)};class m{_tag="Span";sampled;name;parent;annotations;links;startTime;kind;status;_traceId=void 0;_spanId=void 0;_attributes=void 0;_events=void 0;constructor(e){this.name=e.name,this.parent=e.parent,this.annotations=e.annotations,this.links=e.links,this.startTime=e.startTime,this.kind=e.kind,this.sampled=e.sampled,this.status={_tag:"Started",startTime:e.startTime}}get traceId(){return this._traceId??=s.getOrUndefined(this.parent)?.traceId??i.yT(32)}get spanId(){return this._spanId??=i.yT(16)}get attributes(){return this._attributes??=new Map}get events(){return this._events??=[]}end(e,t){this.status={_tag:"Ended",endTime:e,exit:t,startTime:this.status.startTime}}attribute(e,t){this.attributes.set(e,t)}event(e,t,r){this.events.push([e,t,r??{}])}addLinks(e){this.links.push(...e)}}r.d(t,{Tv:()=>l,W1:()=>m},{DW:d,EW:u,RL:f,Vv:h,WG:o,pX:c,sh:p})},6481(e,t,r){let n,i;var a=r(5340);class s{constructor(e){this.value=e,this.done=!1}next(e){return this.done?(this.value=e,this):(this.done=!0,{value:this.value,done:!1})}}let o=(i={[n="~effect/Utils/internal"]:e=>e()},0!==(0,a.jt)()&&i[n](()=>Error().stack)?.includes(n)===!0?i[n]:({[n]:e=>e()})[n]);r.d(t,{B:()=>s},{s:o})},2997(e,t,r){var n=r(9315),i=r(9913);let a=e=>{let t=l(e),r=t.length;if(r%4!=0)return n.fJ(new i.Ug({kind:"Decode",module:"Base64",input:t,message:`Length must be a multiple of 4, but is ${r}`}));let a=t.indexOf("=");if(-1!==a&&(a<r-2||a===r-2&&"="!==t[r-1]))return n.fJ(new i.Ug({kind:"Decode",module:"Base64",input:t,message:"Found a '=' character, but it is not at the end"}));try{let e=t.endsWith("==")?2:+!!t.endsWith("="),i=new Uint8Array(r/4*3-e);for(let e=0,n=0;e<r;e+=4,n+=3){let r=u(t.charCodeAt(e))<<18|u(t.charCodeAt(e+1))<<12|u(t.charCodeAt(e+2))<<6|u(t.charCodeAt(e+3));i[n]=r>>16,i[n+1]=r>>8&255,i[n+2]=255&r}return n.Py(i)}catch(e){return n.fJ(new i.Ug({kind:"Decode",module:"Base64",input:t,message:e instanceof Error?e.message:"Invalid input"}))}},s=new TextEncoder,o=new TextDecoder,l=e=>e.replace(/[\n\r]/g,""),d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c=(new Uint8Array(123)).fill(255);for(let e=0;e<d.length;e++)c[d.charCodeAt(e)]=e;c[61]=0;let u=e=>{if(e>=c.length||255===c[e])throw TypeError(`Invalid character ${String.fromCharCode(e)}`);return c[e]};r.d(t,{},{D4:a,lF:e=>(e=>{let t,r=e.length,n="";for(t=2;t<r;t+=3)n+=d[e[t-2]>>2],n+=d[(3&e[t-2])<<4|e[t-1]>>4],n+=d[(15&e[t-1])<<2|e[t]>>6],n+=d[63&e[t]];return t===r+1&&(n+=d[e[t-2]>>2],n+=d[(3&e[t-2])<<4],n+="=="),t===r&&(n+=d[e[t-2]>>2],n+=d[(3&e[t-2])<<4|e[t-1]>>4],n+=d[(15&e[t-1])<<2],n+="="),n})("string"==typeof e?s.encode(e):e),sc:e=>n.Tj(a(e),e=>o.decode(e))})},9913(e,t,r){var n=r(4942);let i="~effect/encoding/EncodingError";class a extends n.rN("EncodingError"){[i]=i}r.d(t,{Ug:()=>a})},1229(e,t,r){var n=r(9315),i=r(9913);let a=Uint8Array.from("0123456789abcdef",e=>e.charCodeAt(0)),s=()=>0x100000000*Math.random()>>>0,o=()=>{let e=s();return String.fromCharCode(a[e>>>28],a[e>>>24&15],a[e>>>20&15],a[e>>>16&15],a[e>>>12&15],a[e>>>8&15],a[e>>>4&15],a[15&e])},l=e=>{let t=new TextEncoder().encode(e);if(t.length%2!=0)return n.fJ(new i.Ug({module:"Hex",kind:"Decode",input:e,message:`Length must be a multiple of 2, but is ${t.length}`}));try{let e=t.length/2,r=new Uint8Array(e);for(let n=0;n<e;n++){let e=p(t[2*n]),i=p(t[2*n+1]);r[n]=e<<4|i}return n.Py(r)}catch(t){return n.fJ(new i.Ug({module:"Hex",kind:"Decode",input:e,message:t instanceof Error?t.message:"Invalid input"}))}},d=new TextEncoder,c=new TextDecoder,u=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0")),f=e=>{let t="";for(let r=0;r<e.length;r++)t+=u[e[r]];return t},p=e=>{if(48<=e&&e<=57)return e-48;if(97<=e&&e<=102)return e-97+10;if(65<=e&&e<=70)return e-65+10;throw TypeError("Invalid input")};r.d(t,{},{D4:l,lF:e=>"string"==typeof e?f(d.encode(e)):f(e),sc:e=>n.Tj(l(e),e=>c.decode(e)),yT:e=>{switch(e){case 16:let t,r;return t=s(),r=s(),String.fromCharCode(a[t>>>28],a[t>>>24&15],a[t>>>20&15],a[t>>>16&15],a[t>>>12&15],a[t>>>8&15],a[t>>>4&15],a[15&t],a[r>>>28],a[r>>>24&15],a[r>>>20&15],a[r>>>16&15],a[r>>>12&15],a[r>>>8&15],a[r>>>4&15],a[15&r]);case 32:let n,i,l,d;return n=s(),i=s(),l=s(),d=s(),String.fromCharCode(a[n>>>28],a[n>>>24&15],a[n>>>20&15],a[n>>>16&15],a[n>>>12&15],a[n>>>8&15],a[n>>>4&15],a[15&n],a[i>>>28],a[i>>>24&15],a[i>>>20&15],a[i>>>16&15],a[i>>>12&15],a[i>>>8&15],a[i>>>4&15],a[15&i],a[l>>>28],a[l>>>24&15],a[l>>>20&15],a[l>>>16&15],a[l>>>12&15],a[l>>>8&15],a[l>>>4&15],a[15&l],a[d>>>28],a[d>>>24&15],a[d>>>20&15],a[d>>>16&15],a[d>>>12&15],a[d>>>8&15],a[d>>>4&15],a[15&d]);default:{let t="";for(let r=e>>>3;r>0;r--)t+=o();return t}}}})},2449(e,t,r){let n;var i=r(3332),a=r(1958),s=r(1594),o=r(5033),l=r(3952),d=r(1554),c=r(4233),u=r(6481),f=r(2275);let p="~effect/Effect",h="~effect/Exit",m={_A:s.D_,_E:s.D_,_R:s.D_},g=`${p}/identifier`,y=`${p}/args`,b=`${p}/evaluate`,v=`${p}/successCont`,_=`${p}/failureCont`,x=`${p}/ensureCont`,w=Symbol.for("effect/Effect/Yield"),k={pipe(){return(0,d.tT)(this,arguments)},toJSON(){return{...this}},toString(){return(0,a.GP)(this.toJSON(),{ignoreToString:!0,space:2})},[l.FX](){return this.toJSON()}},S={[o.HR](){return o.uN(this,Object.keys(this))},[i.HR](e){let t=Object.keys(this),r=Object.keys(e);if(t.length!==r.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!==r[n]||!i.aI(this[t[n]],e[t[n]]))return!1;return!0}},I={[p]:m,...k,[Symbol.iterator](){return new u.B(this)},toJSON(){return{_id:"Effect",op:this[g],...y in this?{args:this[y]}:void 0}}},$=e=>(0,c.i5)(e,h),E="~effect/Cause",O="~effect/Cause/Reason",C=e=>(0,c.i5)(e,E);class T{constructor(e){this[E]=E,this.reasons=e}pipe(){return(0,d.tT)(this,arguments)}toJSON(){return{_id:"Cause",failures:this.reasons.map(e=>e.toJSON())}}toString(){return`Cause(${(0,a.GP)(this.reasons)})`}[l.FX](){return this.toJSON()}[i.HR](e){return C(e)&&this.reasons.length===e.reasons.length&&this.reasons.every((t,r)=>i.aI(t,e.reasons[r]))}[o.HR](){return o.YO(this.reasons)}}let M=new WeakMap;class P{[O];annotations;_tag;constructor(e,t,r){if(this[O]=O,this._tag=e,t!==A&&"object"==typeof r&&null!==r&&t.size>0){let e=M.get(r);e&&(t=new Map([...e,...t])),M.set(r,t)}this.annotations=t}annotate(e,t){if(0===e.mapUnsafe.size)return this;let r=new Map(this.annotations);e.mapUnsafe.forEach((e,n)=>{t?.overwrite!==!0&&r.has(n)||r.set(n,e)});let n=Object.assign(Object.create(Object.getPrototypeOf(this)),this);return n.annotations=r,n}pipe(){return(0,d.tT)(this,arguments)}toString(){return(0,a.GP)(this)}[l.FX](){return this.toString()}}let A=new Map;class N extends P{constructor(e,t=A){super("Fail",t,e),this.error=e}toString(){return`Fail(${(0,a.GP)(this.error)})`}toJSON(){return{_tag:"Fail",error:this.error}}[i.HR](e){return z(e)&&i.aI(this.error,e.error)&&i.aI(this.annotations,e.annotations)}[o.HR](){return o.kg(o.Yj(this._tag))(o.kg(o.tW(this.error))(o.tW(this.annotations)))}}let R=e=>new T(e),j=(0,s.XY)(2,(e,t)=>{if(0===e.reasons.length)return t;if(0===t.reasons.length)return e;let r=new T(((e,t)=>{let r=new Map,n=[];for(let a of e.concat(t)){let e=o.tW(a),t=r.get(e);if(void 0===t)r.set(e,[a]);else{if(t.some(e=>i.aI(e,a)))continue;t.push(a)}n.push(a)}return n})(e.reasons,t.reasons));return i.aI(e,r)?e:r}),D=new T([]),U=e=>new T([new N(e)]);class F extends P{constructor(e,t=A){super("Die",t,e),this.defect=e}toString(){return`Die(${(0,a.GP)(this.defect)})`}toJSON(){return{_tag:"Die",defect:this.defect}}[i.HR](e){return W(e)&&i.aI(this.defect,e.defect)&&i.aI(this.annotations,e.annotations)}[o.HR](){return o.kg(o.Yj(this._tag))(o.kg(o.tW(this.defect))(o.tW(this.annotations)))}}let B=e=>new T([new F(e)]),L=(0,s.XY)(e=>C(e[0]),(e,t,r)=>0===t.mapUnsafe.size?e:new T(e.reasons.map(e=>e.annotate(t,r)))),z=e=>"Fail"===e._tag,W=e=>"Die"===e._tag;function J(e){return Q("Effect.evaluate: Not implemented")}let Y=e=>({...I,[g]:e.op,[b]:e[b]??J,[v]:e[v],[_]:e[_],[x]:e[x]}),X=e=>{let t=Y(e),r=function(e){this[y]=e};return r.prototype=t,function(e){return new r(e)}},q=e=>{let t={[h]:h,_tag:e.op,get[e.prop](){return this[y]},...Y(e),toString(){return`${e.op}(${(0,a.GP)(this[y])})`},toJSON(){return{_id:"Exit",_tag:e.op,[e.prop]:this[y]}},[i.HR](e){return $(e)&&e._tag===this._tag&&i.aI(this[y],e[y])},[o.HR](){return o.kg(o.Yj(e.op),o.tW(this[y]))}},r=function(e){this[y]=e};return r.prototype=t,function(e){return new r(e)}},G=q({op:"Success",prop:"value",[b](e){let t=e.getCont(v);return t?t[v](this[y],e,this):e.yieldWith(this)}}),V={key:"effect/Cause/StackTrace"},H=q({op:"Failure",prop:"cause",[b](e){let t=this[y],r=!1;e.cache.stackFrame&&(t=L(t,{mapUnsafe:new Map([[V.key,e.cache.stackFrame]])}),r=!0);let n=e.getCont(_),i=e._interruptedCause;if(i&&e.interruptible){let a=!1;for(;n&&e.interruptible;)a||=g in n,n=e.getCont(_);a&&(t=R(t.reasons.filter(e=>"Fail"!==e._tag))),t=j(t,i),r=!0}return n?n[_](t,e,r?void 0:this):e.yieldWith(r?H(t):this)}}),K=e=>H(U(e)),Q=e=>H(B(e)),Z=X({op:"WithFiber",[b](e){return this[y](e)}}),ee=X({op:"WithFiberSucceed",[b](e){let t=this[y](e),r=e.getCont(v);return r?r[v](t,e):e.yieldWith(G(t))}}),et=function(){class e extends globalThis.Error{}let t=Y({op:"YieldableError",[b](){return K(this)}});return delete t.toString,Object.assign(e.prototype,t),e}(),er=(n=Symbol.for("effect/Data/Error/plainArgs"),class extends et{constructor(e){super(e?.message,e?.cause?{cause:e.cause}:void 0),e&&(f.z(this,e),Object.defineProperty(this,n,{value:e,enumerable:!1}))}toJSON(){return{...this[n],...this}}}),en=e=>{class t extends er{_tag=e}return t.prototype.name=e,t},ei="~effect/Cause/NoSuchElementError";class ea extends en("NoSuchElementError"){[ei]=ei;constructor(e){super({message:e})}}let es="~effect/Cause/Done",eo={[es]:es,_tag:"Done",value:void 0},el=e=>void 0===e?eo:{[es]:es,_tag:"Done",value:e},ed=K(eo);r.d(t,{ET:()=>P,Xm:()=>ea,dM:()=>N,s0:()=>T},{$D:er,$L:e=>(0,c.i5)(e,es),$n:p,Aj:C,B4:O,DH:D,Eh:L,GN:w,Hq:ee,IH:h,In:S,Iu:B,OE:U,PW:e=>(0,c.i5)(e,ei),PX:E,QJ:{key:"effect/Cause/InterruptorStackTrace"},R6:Z,RS:el,Rk:K,Sc:_,Uf:X,V2:Q,Vw:e=>void 0===e?ed:K(el(e)),Wg:e=>(0,c.i5)(e,O),Xb:W,_3:b,a2:y,b5:R,b9:$,cb:H,dO:A,ee:v,fU:k,h2:j,ik:e=>"Interrupt"===e._tag,lC:z,qB:ei,q_:es,rN:en,u4:x,xt:G,yj:Y,yw:e=>(0,c.i5)(e,p),z8:V})},9771(e,t,r){r.d(t,{},{S:e=>e>0?Math.floor(e):0})},7425(e,t,r){var n=r(1594);r.d(t,{},{Jr:e=>(0,n.XY)(2,(t,r)=>e(t,e=>({[r]:e}))),oI:(e,t)=>(0,n.XY)(3,(r,n,i)=>t(r,t=>e(i(t),e=>({...t,[n]:e})))),zM:e=>(0,n.XY)(3,(t,r,n)=>e(t,e=>({...e,[r]:n(e)})))})},6297(e,t,r){let n,i,a,s,o,l,d,c,u,f;r.d(t,{RD4:()=>aA,cOF:()=>aM,a1U:()=>af,z4N:()=>aD,d$_:()=>aB,Do:()=>iI,Aub:()=>aT,F7W:()=>aO,qwd:()=>aE,t8c:()=>aI,olX:()=>aL,obm:()=>nu,kWD:()=>nc,MUS:()=>aS,DQo:()=>aw,Bk6:()=>aj,Kkt:()=>aN,dsN:()=>n7,N24:()=>nq,Q56:()=>nA,jGc:()=>nX,U9h:()=>nN,Q7R:()=>ie,hgn:()=>tS,ww9:()=>ad,gsV:()=>az,Muk:()=>al,as:()=>tu,Xx$:()=>tw,NLW:()=>t$,PCg:()=>iP,oIE:()=>iE,JrD:()=>i$,PO3:()=>nQ,CJw:()=>nG,Rgn:()=>nK,E2r:()=>te,Tyx:()=>rw,rNk:()=>r$,sJf:()=>rI,Fig:()=>rC,UVN:()=>tL,osR:()=>rD,XWm:()=>rj,U9Y:()=>rO,AXC:()=>rB,zt4:()=>rL,KuX:()=>rU,loE:()=>rF,h_t:()=>rE,On5:()=>ei,Bou:()=>Z,nIy:()=>W,h74:()=>ee,O$X:()=>ea,GyP:()=>em,RJ6:()=>eo,ReC:()=>es,RKA:()=>ay,_OA:()=>ro,sxi:()=>rd,Wj8:()=>au,_32:()=>ac,Rud:()=>av,s0X:()=>a_,cbG:()=>na,F_Q:()=>eZ,OY:()=>tN,yeE:()=>nF,u4Y:()=>rG,NS5:()=>nt,Hox:()=>t9,ely:()=>t4,yJo:()=>tG,HIt:()=>tq,K$2:()=>tJ,GUt:()=>tY,jCT:()=>tH,_OD:()=>tV,lgw:()=>rt,Sv3:()=>re,kMI:()=>t7,YDM:()=>tQ,_mh:()=>tZ,lNM:()=>tK,_sz:()=>tz,VE1:()=>tX,CoE:()=>tW,v9O:()=>t1,EkE:()=>t5,zPu:()=>t2,Wtn:()=>t8,x5l:()=>t0,il9:()=>t6,fJG:()=>eL,ATB:()=>eB,pVV:()=>eQ,gOk:()=>e0,pEE:()=>e8,zFM:()=>eM,C6p:()=>eP,ABT:()=>e9,mKq:()=>eR,DKo:()=>eD,$MQ:()=>eU,eGS:()=>ej,D7p:()=>eA,INJ:()=>eN,vTQ:()=>ij,pbD:()=>iw,x1Q:()=>ik,E8K:()=>iS,VtY:()=>i_,ahH:()=>ix,Pm0:()=>iv,W$I:()=>ry,BbX:()=>H,k7S:()=>V,khU:()=>X,L$u:()=>q,QE5:()=>Y,i8i:()=>ia,kAe:()=>io,tU5:()=>Q,Dd:()=>rq,qIB:()=>tP,Ab9:()=>tR,Bqz:()=>tj,UUz:()=>tk,fn:()=>ts,D9k:()=>tn,vCS:()=>tl,jJl:()=>ic,i4r:()=>rx,zhn:()=>iC,yxg:()=>iM,ar0:()=>iA,x6Z:()=>iN,bJ:()=>eX,sVm:()=>eJ,yUA:()=>eY,JkU:()=>tr,Iku:()=>ek,gpn:()=>G,myX:()=>J,prj:()=>K,nn5:()=>er,d5f:()=>iu,XeO:()=>rV,GrF:()=>rH,GaK:()=>nZ,Inz:()=>n8,eMl:()=>n4,Rft:()=>aP,ASO:()=>aC,N6O:()=>nn,_y:()=>a$,oJd:()=>ni,c8t:()=>ak,PnV:()=>aR,U1p:()=>iy,h$X:()=>im,uVU:()=>iO,A_r:()=>ar,lIX:()=>aX,ORc:()=>z,Fbb:()=>iQ,zzk:()=>iK,Z98:()=>i9,Rd$:()=>i4,TjK:()=>tD,UcN:()=>rJ,q7Y:()=>tB,jkJ:()=>tU,xm_:()=>rW,Z9x:()=>tF,YWq:()=>r4,D$$:()=>r8,NZb:()=>ne,khu:()=>rZ,wR5:()=>tA,G$Q:()=>r7,tvg:()=>r9,T13:()=>ax,ZmZ:()=>tt,S5A:()=>nz,iKM:()=>nJ,BeE:()=>nW,cfM:()=>nU,uRq:()=>nL,fGe:()=>nB,r7h:()=>nj,nAr:()=>nY,uKv:()=>rK,QgK:()=>rY,DM4:()=>rX,jBG:()=>it,ivC:()=>e5,PpN:()=>ru,AAo:()=>nC,PfK:()=>rf,c7E:()=>rh,O4F:()=>tT,Vdx:()=>tO,FfP:()=>tC,KT6:()=>tM,tQ6:()=>en,TSs:()=>ir,aAq:()=>rv,Xrv:()=>r_,Akf:()=>ih,Ket:()=>rQ,bPG:()=>iF,lSz:()=>iU,MY7:()=>iD,eJC:()=>iR,pR5:()=>iW,NpQ:()=>iL,jqV:()=>iB,v2Q:()=>iz,HZF:()=>iq,lKS:()=>iY,rfH:()=>iJ,lE:()=>iX,_Sg:()=>tE,z8E:()=>nO,iLB:()=>nx,Uio:()=>n_,MbZ:()=>nw,vDJ:()=>np,fou:()=>nh,Z$R:()=>nb,pSt:()=>nv,RWE:()=>nE,d97:()=>nS,DLK:()=>nf,mdu:()=>nM,P1j:()=>nT,Pxi:()=>nP,euC:()=>rr,Nav:()=>rn,oao:()=>rc,yy4:()=>ab,Fu6:()=>ae,WbR:()=>at,PyW:()=>eF,lwU:()=>eH,nGE:()=>eV,DYE:()=>eW,OH5:()=>ez,Mim:()=>tI,dGm:()=>rT,bKC:()=>rP,cA6:()=>rM,nAi:()=>rR,sFT:()=>rA,k$L:()=>rN,ayu:()=>nd,wRz:()=>no,D52:()=>nl,mgX:()=>ns,kJM:()=>iZ,pkL:()=>eK,SvU:()=>e2,$mh:()=>e3,Vxk:()=>aV,rfi:()=>n0,FcF:()=>n9,scW:()=>rz,r_d:()=>ri,bUZ:()=>ra,L_I:()=>rs,gvr:()=>ai,tfT:()=>ii,rIH:()=>e1,z7s:()=>rb,iMI:()=>id,$$g:()=>aH,hq:()=>as,fRP:()=>ao,zr8:()=>i7,_o1:()=>i0,nDN:()=>i1,MaT:()=>i2,m9E:()=>eG,KN3:()=>eq,yU6:()=>rm,OYO:()=>rg});var p=r(664),h=r(1179),m=r(3614),g=r(3332),y=r(1594),b=r(1587),v=r(4233),_=r(9315);v.Kg,v.Et,v.Lm,v.sI,v.Bm,v.$P;let x=(0,y.XY)(2,(e,t)=>r=>{let n=e(r);if(_.N6(n))return _.fJ(r);let i=t(n.success);return _.N6(i)?_.fJ(r):i});var w=r(1958),k=r(5033),S=r(3952),I=r(592),$=r(2860),E=r(1554),O=r(1279),C=r(3909),T=r(2707),M=r(6481),P=r(2449),A=r(7425),N=r(7258),R=r(2275),j=r(6712),D=r(5340);let U=e=>{if(e?.captureStackTrace===!1||e?.captureStackTrace!==void 0&&"boolean"!=typeof e.captureStackTrace)return e;let t=(0,D.jt)();if(0===t&&e?.captureStackTrace!==!0)return{...e,captureStackTrace:!1};(0,D.ft)(3);let r=Error();return(0,D.ft)(t),{...e,captureStackTrace:B(()=>r.stack)}},F=e=>t=>{let r;return()=>{if(void 0!==r)return r;let n=t();if(!n)return;let i=n.split("\n");if(void 0!==i[e])return r=i[e].trim()}},B=F(3);class L extends P.ET{constructor(e,t=P.dO){super("Interrupt",t,"Interrupted"),this.fiberId=e}toString(){return`Interrupt(${this.fiberId})`}toJSON(){return{_tag:"Interrupt",fiberId:this.fiberId}}[g.HR](e){return(0,P.ik)(e)&&this.fiberId===e.fiberId&&this.annotations===e.annotations}[k.HR](){return k.kg(k.Yj(`${this._tag}:${this.fiberId}`))(k.yT(this.annotations))}}let z=e=>new L(e),W=e=>new P.s0([new L(e)]),J=e=>e.reasons.some(P.lC),Y=e=>{let t=e.reasons.find(P.lC);return t?_.Py(t):_.fJ(e)},X=e=>{for(let t=0;t<e.reasons.length;t++){let r=e.reasons[t];if("Fail"===r._tag)return _.Py(r.error)}return _.fJ(e)},q=e=>{let t=X(e);return _.N6(t)?b.none():b.some(t.success)},G=e=>e.reasons.some(P.Xb),V=e=>{let t=e.reasons.find(P.Xb);return t?_.Py(t):_.fJ(e)},H=e=>{let t=e.reasons.find(P.Xb);return t?_.Py(t.defect):_.fJ(e)},K=e=>e.reasons.some(P.ik),Q=e=>{let t=e.reasons.find(P.ik);return t?_.Py(t):_.fJ(e)},Z=e=>{let t;for(let r=0;r<e.reasons.length;r++){let n=e.reasons[r];"Interrupt"===n._tag&&(t??=new Set,void 0!==n.fiberId&&t.add(n.fiberId))}return t?_.Py(t):_.fJ(e)},ee=e=>{let t=Z(e);return _.N6(t)?et:t.success},et=new Set,er=e=>e.reasons.length>0&&e.reasons.every(P.ik),en=e=>h.LZ(e.annotations),ei=e=>{let t=new Map;for(let r of e.reasons)if(r.annotations.size>0)for(let[e,n]of r.annotations)t.set(e,n);return h.LZ(t)},ea=(0,y.XY)(2,(e,t)=>{let r=!1,n=e.reasons.map(e=>(0,P.lC)(e)?(r=!0,new P.dM(t(e.error),e.annotations)):e);return r?(0,P.b5)(n):e}),es=e=>{let t;for(let r of e.reasons){if("Fail"===r._tag)return r.error;"Die"===r._tag&&(t??=r)}return void 0!==t?t.defect:new globalThis.Error(e.reasons.length>0?"All fibers interrupted without error":"Empty cause")},eo=(e,t)=>{let r=[],n=[];if(0===e.reasons.length)return r;let i=(0,D.jt)();0!==i&&(0,D.ft)(1);try{for(let i of e.reasons){if("Interrupt"===i._tag){n.push(i);continue}r.push(el("Die"===i._tag?i.defect:i.error,i.annotations,t))}if(0===r.length){let e=Error("The fiber was interrupted by:");e.name="InterruptCause",e.stack=ep(e,n);let i=new globalThis.Error("All fibers interrupted without error",{cause:e});i.name="InterruptError",i.stack=`${i.name}: ${i.message}`,r.push(el(i,n[0].annotations,t))}}finally{0!==i&&(0,D.ft)(i)}return r},el=(e,t,r)=>{let n,i=typeof e;if(e&&"object"===i){if(n=new globalThis.Error(ed(e),{cause:e.cause?el(e.cause):void 0}),"string"==typeof e.name&&(n.name=e.name),"string"==typeof e.stack)n.stack=eu(e.stack,n,t);else{let e=`${n.name}: ${n.message}`;n.stack=t?ef(e,t):e}for(let t of(r?.includeCauseInStack&&(n.stack=eg(n)),Object.keys(e)))t in n||(n[t]=e[t])}else n=new globalThis.Error(!e?`Unknown error: ${e}`:"string"===i?e:(0,w.IB)(e));return n},ed=e=>{if("string"==typeof e.message)return e.message;if("function"==typeof e.toString&&e.toString!==Object.prototype.toString&&e.toString!==Array.prototype.toString)try{return e.toString()}catch{}return(0,w.IB)(e)},ec=/\((.*)\)/g,eu=(e,t,r)=>{let n=`${t.name}: ${t.message}`,i=(e.startsWith(n)?e.slice(n.length):e).split("\n"),a=[n];for(let e=1;e<i.length&&!/Generator\.next|~effect\/(?:Effect|Utils)/.test(i[e]);e++)a.push(i[e]);return r?ef(a.join("\n"),r):a.join("\n")},ef=(e,t)=>{let r=t?.get(P.z8.key);return r&&(e=`${e}
237
- ${eh(r)}`),e},ep=(e,t)=>{let r=[`${e.name}: ${e.message}`];for(let e of t){let t=void 0!==e.fiberId?`#${e.fiberId}`:"unknown",n=e.annotations.get(P.QJ.key);r.push(` at fiber (${t})`),n&&r.push(eh(n))}return r.join("\n")},eh=e=>{let t=[],r=e,n=0;for(;r&&n<10;){let e=r.stack();if(e){let n=e.matchAll(ec),i=!1;for(let[,e]of n)i=!0,t.push(` at ${r.name} (${e})`);i||t.push(` at ${r.name} (${e.replace(/^at /,"")})`)}else t.push(` at ${r.name}`);r=r.parent,n++}return t.join("\n")},em=e=>eo(e).map(eg).join("\n"),eg=e=>e.cause?`${e.stack} {
234
+ ${l.repeat(f)}}`;p=u(r,n)}}return a.delete(r),p}return String(r)}(r,f)}catch{return("object"==typeof r&&null!==r||"function"==typeof r)&&a.delete(r),"[inspection threw]"}}(e,0)}let s="[Circular]";function o(e){return"string"==typeof e?JSON.stringify(e):String(e)}function l(e){return e.map(e=>`[${o(e)}]`).join("")}function d(e){try{return e.toISOString()}catch{return"Invalid Date"}}function c(e,t){try{return e[t]}catch{return"[property access threw]"}}function u(e,t){let r=[];return JSON.stringify(e,function(e,t){let s=Object.getOwnPropertyDescriptor(this,e)?.value,o=n.i5(s,i.uC)?(0,i.E$)(s):(0,i.E$)(t);if("bigint"==typeof o)return a(o);if("object"!=typeof o||null===o)return o;let l=o instanceof Error&&!n.i5(o,"toJSON")?{...o,name:o.name,message:o.message}:o;for(;r.length>0&&r[r.length-1]!==this;)r.pop();if(!r.includes(o))return r.push(o),l!==o&&r.push(l),l},t?.space)??"null"}r.d(t,{GP:()=>a,IB:()=>u,Yq:()=>d,_r:()=>o,jV:()=>l})},1594(e,t,r){var n=r(1554);let i=e=>()=>e,a=i(!0),s=i(!1),o=i(null),l=i(void 0);function d(e,...t){return(0,n.tT)(e,t)}function c(e,t,r,n,i,a,s,o,l){switch(arguments.length){case 1:return e;case 2:return function(){return t(e.apply(this,arguments))};case 3:return function(){return r(t(e.apply(this,arguments)))};case 4:return function(){return n(r(t(e.apply(this,arguments))))};case 5:return function(){return i(n(r(t(e.apply(this,arguments)))))};case 6:return function(){return a(i(n(r(t(e.apply(this,arguments))))))};case 7:return function(){return s(a(i(n(r(t(e.apply(this,arguments)))))))};case 8:return function(){return o(s(a(i(n(r(t(e.apply(this,arguments))))))))};case 9:return function(){return l(o(s(a(i(n(r(t(e.apply(this,arguments)))))))))}}}function u(e){let t=new WeakMap;return r=>{let n=t.get(r);if(void 0!==n)return n;let i=e(r);return t.set(r,i),i}}function f(e){let t=new WeakMap;return r=>{let n=t.get(r);if(void 0!==n)return n;let i=e(r);return t.set(r,i),i!==r&&t.set(i,i),i}}r.d(t,{Bj:()=>u,Fs:()=>d,L3:()=>c,qE:()=>f},{D_:e=>e,MN:l,XR:o,XY:function(e,t){if("function"==typeof e)return function(){return e(arguments)?t.apply(this,arguments):e=>t(e,...arguments)};switch(e){case 0:case 1:throw RangeError(`Invalid arity ${e}`);case 2:return function(e,r){return arguments.length>=2?t(e,r):function(r){return t(r,e)}};case 3:return function(e,r,n){return arguments.length>=3?t(e,r,n):function(n){return t(n,e,r)}};default:return function(){if(arguments.length>=e)return t.apply(this,arguments);let r=arguments;return function(e){return t(e,...r)}}}},Yi:l,dY:i,f4:s,ue:a})},5033(e,t,r){r.d(t,{YO:()=>v,kg:()=>c,tW:()=>o,ai:()=>p,ky:()=>u,yT:()=>l,Yj:()=>h,QK:()=>g,uN:()=>m,HR:()=>s});var n=r(1594),i=r(5844);let a=0,s="~effect/Hash",o=e=>{switch(typeof e){case"number":return p(e);case"bigint":return h(e.toString(10));case"string":return h(e);case"function":case"object":if(null===e);else if(e instanceof Date){if(Number.isNaN(e.getTime()))return h("Invalid Date");return h(e.toISOString())}else{let t;if(e instanceof RegExp)return h(e.toString());if(i.J3.has(e))return l(e);let r=k.get(e);if(void 0!==r)return r;if(S.has(e))return a++,h("[Circular]");S.add(e);let n=a;try{t=s in e?e[s]():"function"==typeof e?l(e):e instanceof DataView?v((0,i.j)(e)):Array.isArray(e)||ArrayBuffer.isView(e)?v(e):e instanceof Map?b(e):e instanceof Set?x(e):g(e)}finally{S.delete(e)}return n===a&&k.set(e,t),t}}return u(d(h(String(e))))},l=e=>(w.has(e)||w.set(e,u(0x100000000*Math.random()|0)),w.get(e)),d=e=>(e^=e>>>16,e=Math.imul(e,0x85ebca6b),e^=e>>>13,(e=Math.imul(e,0xc2b2ae35))^e>>>16),c=(0,n.XY)(2,(e,t)=>d(Math.imul(e,0x9e3779b1)+Math.imul(t,0x85ebca6b))),u=e=>0xbfffffff&e|e>>>1&0x40000000,f=new DataView(new ArrayBuffer(8)),p=e=>{let t=0|e;return t===e?u(t):(f.setFloat64(0,e!=e?0/0:e),u(c(f.getInt32(0),f.getInt32(4))))},h=e=>{let t=5381,r=e.length;for(;r;)t=33*t^e.charCodeAt(--r);return u(t)},m=(e,t)=>{let r=12289;for(let n of t)r^=c(o(n),o(e[n]));return u(r)},g=e=>m(e,(0,i.Xp)(e)),y=(e,t)=>r=>{let n=e;for(let e of r)n^=t(e);return u(n)},v=e=>{let t=6151;for(let r of e)t=c(t,o(r));return u(t)},b=y(h("Map"),([e,t])=>c(o(e),o(t))),_=h("Set"),x=y(_,e=>c(_,o(e))),w=new WeakMap,k=new WeakMap,S=new WeakSet},3952(e,t,r){var n=r(1958),i=r(4233),a=r(1279);let s=Symbol.for("nodejs.util.inspect.custom"),o=e=>{try{if(e=(0,a.E$)(e),i.i5(e,"toJSON")&&i.Tn(e.toJSON)&&0===e.toJSON.length)return e.toJSON();if(Array.isArray(e))return e.map(o);return e}catch{return"[toJSON threw]"}};r.d(t,{},{FX:s,ZK:(e,t=2)=>{if("string"==typeof e)return e;try{return"object"==typeof e?(0,n.IB)(e,{space:t}):(0,n.GP)(e,{space:t})}catch{return String(e)}},aB:o,os:{toJSON(){return o(this)},[s](){return this.toJSON()},toString(){return(0,n.GP)(this.toJSON())}}})},592(e,t,r){var n=r(1594),i=r(1587),a=r(4233);let s=(0,n.XY)(2,(e,t)=>{let r=0;for(let n of e){let e=t(n,r);if((0,a.Lm)(e)){if(e)return i.some(n)}else if(i.isSome(e))return e;r++}return i.none()}),o=(0,n.XY)(2,(e,t)=>({[Symbol.iterator](){let r=e[Symbol.iterator](),n=0;return{next(){let e=r.next();for(;!e.done;){if(t(e.value,n++))return{done:!1,value:e.value};e=r.next()}return{done:!0,value:void 0}}}}}));r.d(t,{},{i8:s,pb:o})},5633(e,t,r){var n=r(1179),i=r(9237),a=r(1594),s=r(2449),o=r(6297),l=r(1554),d=r(5744);let c="~effect/Layer/MemoMap",u=(e,t)=>"Closed"!==t.state._tag&&(e.observers++,o.MbZ(t,{},e.finalizer),!0),f={"~effect/Layer":{_ROut:a.D_,_E:a.D_,_RIn:a.D_},pipe(){return(0,l.tT)(this,arguments)}},p=e=>{let t=Object.create(f);return t.build=e,t},h=e=>p((t,r)=>{let n=d.Fp(r);return o.cfM(e(t,n),e=>"Failure"===e._tag?d.VN(n,e):o.rIH)});class m{get[c](){return c}parent;constructor(e){this.parent=e}map=new Map;get(e,t){let r=this.map.get(e);return r?(u(r,t),r.deferred.effect??i.Tx(r.deferred)):this.parent?.get(e,t)}getOrElseMemoize(e,t,r){return o.DYE(()=>{let n;return o.r7h(o.DYE(()=>{var a;let s,l=this.get(e,t);if(l)return l;let c=(a=this,s={observers:0,deferred:i.LZ(),scope:d.LZ(),finalizer:t=>o.DYE(()=>--s.observers>0?o.rIH:(a.map.delete(e),d.VN(s.scope,t)))});return u(c,t)?(n=c.deferred,this.map.set(e,c),r(this,c.scope)):r(this,t)}),e=>{n&&i.$w(n,e)})})}}let g=()=>new m;class y extends(n.kl())("effect/Layer/CurrentMemoMap"){static forkOrCreate(e){let t=n.Y6(e,y);return t?new m(t):g()}}let v=(0,a.XY)(3,(e,t,r)=>o.PfK(o.TjK(e.build(t,r),n.WQ(y,t)),y,t)),b=(0,a.XY)(2,(e,t)=>s.R6(r=>v(e,y.forkOrCreate(r.context),t))),_=e=>p((0,a.dY)(o.PyW(e))),x=(e,t)=>w(o.TjK(t,t=>n.L8(e,t))),w=e=>{var t;let r;return t=(t,r)=>d.Gt(e,r),r=h((e,n)=>e.getOrElseMemoize(r,n,t))},k=(e,t,r)=>{let i=d.Fp(r,"parallel");return o.jJl(e,e=>e.build(t,d.Fp(i,"sequential")),{concurrency:e.length}).pipe(o.TjK(e=>n.Um(...e)))},S=(e,t,r)=>h((n,i)=>o.qIB(Array.isArray(t)?k(t,n,i):t.build(n,i),t=>e.build(n,i).pipe(o.PpN(t),o.TjK(e=>r(e,t))))),I=(0,a.XY)(2,(e,t)=>S(e,t,a.D_)),$=(0,a.XY)(2,(e,t)=>S(e,t,(e,t)=>n.h1(t,e)));r.d(t,{},{Gt:I,H7:v,LT:b,Py:function(){return 1==arguments.length?e=>_(n.L8(arguments[0],e)):_(n.L8(arguments[0],arguments[1]))},QZ:function(){return 1==arguments.length?e=>x(arguments[0],e):x(arguments[0],arguments[1])},S5:$,Um:(...e)=>h((t,r)=>k(e,t,r)),j6:g})},1587(e,t,r){r.r(t);var n=r(9519),i=r(3332),a=r(7876),s=r(1594),o=r(7425),l=r(7731),d=r(2275),c=r(2563),u=r(2860),f=r(4233),p=r(636);let h=()=>l.dv,m=l.zN,g=l.oL,y=l.$I,v=l.Ru,b=(0,s.XY)(2,(e,{onNone:t,onSome:r})=>y(e)?t():r(e.value)),_=c.Oz,x=c.L8,w=(0,s.XY)(2,(e,t)=>y(e)?t():e.value),k=(0,s.XY)(2,(e,t)=>y(e)?t():e),S=(0,s.XY)(2,(e,t)=>y(e)?m(t()):e),I=(0,s.XY)(2,(e,t)=>y(e)?M(t(),c.Py):M(e,c.fJ)),$=e=>null==e?h():m(e),E=w(s.XR),O=w(s.MN),C=(0,s.XY)(2,(e,t)=>{if(v(e))return e.value;throw t()}),T=C(()=>Error("getOrThrow called on a None")),M=(0,s.XY)(2,(e,t)=>y(e)?h():m(t(e.value))),A=(0,s.XY)(2,(e,t)=>M(e,()=>t)),N=A(void 0),P=m(void 0),R=(0,s.XY)(2,(e,t)=>y(e)?h():t(e.value)),j=(0,s.XY)(2,(e,t)=>R(e,e=>{let r=(0,f.Tn)(t)?t(e):t;return g(r)?r:m(r)})),D=(0,s.XY)(2,(e,t)=>y(e)?h():$(t(e.value))),U=R(s.D_),F=(0,s.XY)(2,(e,t)=>R(e,()=>t)),B=(0,s.XY)(2,(e,t)=>z(e,()=>t)),L=(0,s.XY)(2,(e,t)=>r=>R(e(r),t)),z=(0,s.XY)(2,(e,t)=>R(e,e=>M(t(e),()=>e))),W=(0,s.XY)(2,(e,t)=>v(e)&&v(t)?m([e.value,t.value]):h()),J=(0,s.XY)(2,(e,t)=>{if(y(e))return h();let r=[e.value];for(let e of t){if(y(e))return h();r.push(e.value)}return m(r)}),Y=(0,s.XY)(3,(e,t,r)=>M(W(e,t),([e,t])=>r(e,t))),X=(0,s.XY)(3,(e,t,r)=>{let n=t;for(let t of e)v(t)&&(n=r(n,t.value));return n}),q=(0,s.XY)(2,(e,t)=>{if(y(e))return[h(),h()];let r=t(e.value);return c.N6(r)?[h(),m(r.failure)]:[m(r.success),h()]}),G=(0,s.XY)(2,(e,t)=>{if(y(e))return h();let r=t(e.value);return c.oJ(r)?m(r.success):h()}),V=(0,s.XY)(2,(e,t)=>y(e)?h():t(e.value)?m(e.value):h()),H=(0,s.XY)(2,(e,t)=>t(e)?m(e):h()),K=e=>(0,s.XY)(2,(t,r)=>!y(t)&&e(t.value,r)),Q=K(i.jI()),Z=(0,s.XY)(2,(e,t)=>!y(e)&&t(e.value)),ee=o.Jr(M),et=o.zM(M),er=o.oI(M,R),en=m({});function ei(e){return p.L((t,r)=>y(t)?r:y(r)?t:m(e.combine(t.value,r.value)),h())}function ea(e){return n.L8((t,r)=>y(t)||y(r)?h():m(e.combine(t.value,r.value)))}function es(e){let t=ea(e).combine,r=m(e.initialValue);return p.L(t,r,e=>{let n=r;for(let r of e)if(y(n=t(n,r)))break;return n})}r.d(t,{makeCombinerFailFast:()=>ea,makeReducer:()=>ei,makeReducerFailFast:()=>es},{Do:en,all:e=>{if(Symbol.iterator in e){let t=[];for(let r of e){if(y(r))return h();t.push(r.value)}return m(t)}let t={};for(let r of Object.keys(e)){let n=e[r];if(y(n))return h();d.x(t,r,n.value)}return m(t)},andThen:j,as:A,asVoid:N,bind:er,bindTo:ee,composeK:L,contains:Q,containsWith:K,exists:Z,filter:V,filterMap:G,firstSomeOf:e=>{let t=h();for(t of e)if(v(t))break;return t},flatMap:R,flatMapNullishOr:D,flatten:U,fromIterable:e=>{for(let t of e)return m(t);return h()},fromNullOr:e=>null===e?h():m(e),fromNullishOr:$,fromUndefinedOr:e=>void 0===e?h():m(e),gen:(...e)=>{let t=(1===e.length?e[0]:e[1].bind(e[0]))(),r=t.next();for(;!r.done;){let e=r.value;if(y(e))return e;r=t.next(e.value)}return m(r.value)},getFailure:x,getOrElse:w,getOrNull:E,getOrThrow:T,getOrThrowWith:C,getOrUndefined:O,getSuccess:_,isNone:y,isOption:g,isSome:v,let:et,lift2:e=>(0,s.XY)(2,(t,r)=>Y(t,r,e)),liftNullishOr:e=>(...t)=>$(e(...t)),liftPredicate:H,liftThrowable:e=>(...t)=>{try{return m(e(...t))}catch{return h()}},makeEquivalence:e=>a.L8((t,r)=>y(t)?y(r):!y(r)&&e(t.value,r.value)),makeOrder:e=>u.L8((t,r)=>v(t)?v(r)?e(t.value,r.value):1:-1),map:M,match:b,none:h,orElse:k,orElseResult:I,orElseSome:S,partitionMap:q,product:W,productMany:J,reduceCompact:X,some:m,tap:z,toArray:e=>y(e)?[]:[e.value],toRefinement:e=>t=>v(e(t)),void:P,zipLeft:B,zipRight:F,zipWith:Y})},2860(e,t,r){var n=r(1594);function i(e){return(t,r)=>t===r?0:e(t,r)}let a=i((e,t)=>e<t?-1:1),s=i((e,t)=>globalThis.Number.isNaN(e)&&globalThis.Number.isNaN(t)?0:globalThis.Number.isNaN(e)?-1:globalThis.Number.isNaN(t)?1:e<t?-1:1),o=i((e,t)=>e<t?-1:1),l=(0,n.XY)(2,(e,t)=>i((r,n)=>e(t(r),t(n)))),d=l(s,e=>e.getTime());function c(e){return i((t,r)=>{let n=e.length;for(let i=0;i<n;i++){let n=e[i](t[i],r[i]);if(0!==n)return n}return 0})}function u(e){return i((t,r)=>{let n=t.length,i=r.length,a=Math.min(n,i);for(let n=0;n<a;n++){let i=e(t[n],r[n]);if(0!==i)return i}return s(n,i)})}function f(e){let t=Object.keys(e);return i((r,n)=>{for(let i of t){let t=e[i](r[i],n[i]);if(0!==t)return t}return 0})}let p=e=>(0,n.XY)(2,(t,r)=>-1===e(t,r)),h=e=>(0,n.XY)(2,(t,r)=>1===e(t,r)),m=e=>(0,n.XY)(2,(t,r)=>t===r||1>e(t,r)?t:r),g=e=>(0,n.XY)(2,(t,r)=>t===r||e(t,r)>-1?t:r);r.d(t,{L8:()=>i,O3:()=>u,_k:()=>f,rd:()=>c},{Bt:e=>(0,n.XY)(2,(t,r)=>!p(e)(t,r.minimum)&&!h(e)(t,r.maximum)),OW:e=>(0,n.XY)(2,(t,r)=>-1!==e(t,r)),Qf:a,Qw:o,T9:g,bi:e=>(0,n.XY)(2,(t,r)=>1!==e(t,r)),hl:p,jk:m,n9:d,qE:e=>(0,n.XY)(2,(t,r)=>m(e)(r.maximum,g(e)(r.minimum,t))),wN:s,yJ:h,zQ:l})},1554(e,t,r){let n=(e,t)=>{switch(t.length){case 0:return e;case 1:return t[0](e);case 2:return t[1](t[0](e));case 3:return t[2](t[1](t[0](e)));case 4:return t[3](t[2](t[1](t[0](e))));case 5:return t[4](t[3](t[2](t[1](t[0](e)))));case 6:return t[5](t[4](t[3](t[2](t[1](t[0](e))))));case 7:return t[6](t[5](t[4](t[3](t[2](t[1](t[0](e)))))));case 8:return t[7](t[6](t[5](t[4](t[3](t[2](t[1](t[0](e))))))));case 9:return t[8](t[7](t[6](t[5](t[4](t[3](t[2](t[1](t[0](e)))))))));default:{let r=e;for(let e=0,n=t.length;e<n;e++)r=t[e](r);return r}}},i={pipe(){return n(this,arguments)}},a=function(){function e(){}return e.prototype=i,e}();r.d(t,{},{Xs:a,bp:i,tT:n})},4233(e,t,r){var n=r(1594);function i(e){return"string"==typeof e}function a(e){return"number"==typeof e}function s(e){return"boolean"==typeof e}function o(e){return"bigint"==typeof e}function l(e){return"symbol"==typeof e}function d(e){return i(e)||a(e)||l(e)}function c(e){return"function"==typeof e}function u(e){return void 0===e}function f(e){return void 0!==e}function p(e){return null!==e}function h(e){return null==e}function m(e){return null!=e}function g(e){return!1}function y(e){return!0}function v(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function b(e){return"object"==typeof e&&null!==e||c(e)}let _=(0,n.XY)(2,(e,t)=>b(e)&&t in e),x=(0,n.XY)(2,(e,t)=>_(e,"_tag")&&e._tag===t);function w(e){return e instanceof Error}function k(e){return e instanceof Date}function S(e){return _(e,Symbol.iterator)||i(e)}function I(e){return e instanceof RegExp}r.d(t,{$P:()=>k,Bm:()=>l,EA:()=>f,Et:()=>a,Fw:()=>b,Gv:()=>v,Kg:()=>i,Lm:()=>s,Pd:()=>g,Pe:()=>p,Tn:()=>c,Vq:()=>m,b0:()=>u,bJ:()=>w,gd:()=>I,hL:()=>d,sI:()=>o,t8:()=>y,uy:()=>h,xZ:()=>S},{$J:x,i5:_})},3753(e,t,r){var n=r(719),i=r(6526),a=r(1594),s=r(6297),o=r(9315);let l=(0,a.XY)(2,(e,t)=>s.rNk(e,u,e=>t(e))),d=e=>"Fail"===e._tag&&n.$L(e.error),c=e=>{let t,r=!1;for(let n of e.reasons)d(n)?t??=n.error:"Interrupt"!==n._tag&&(r=!0);return void 0===t?o.fJ(e):r?o.fJ(n.kO(e.reasons.filter(e=>!d(e)))):o.Py(t)},u=e=>{let t=c(e);return o.N6(t)?t:o.Py(t.success.value)},f=(0,a.XY)(2,(e,t)=>s.khu(e,{onSuccess:t.onSuccess,onFailure:e=>{let r=c(e);return o.N6(r)?t.onFailure(r.failure):t.onDone(r.success.value)}}));r.d(t,{},{Og:e=>e.reasons.some(d),aU:e=>{let t=c(e);return o.N6(t)?i.AT(t.failure):i.Py(t.success.value)},m8:l,tv:f})},915(e,t,r){var n=r(1594),i=r(2275);let a=(0,n.XY)(2,(e,t)=>{let r=[];for(let n of l(e))r.push(t(n,e[n]));return r})((e,t)=>[e,t]),s=(0,n.XY)(2,(e,t)=>Object.hasOwn(e,t)),o=(0,n.XY)(2,(e,t)=>{let r={...e};for(let n of l(e))i.x(r,n,t(e[n],n));return r}),l=e=>Object.keys(e);i.x,r.d(t,{},{T9:e=>{let t=(0,n.XY)(2,(t,r)=>{for(let n of l(t))if(!s(r,n)||!e(t[n],r[n]))return!1;return!0});return(e,r)=>t(e,r)&&t(r,e)},Tj:o,Wo:a})},1279(e,t,r){var n=r(1554),i=r(4233);let a=Symbol.for("~effect/Redactable");function s(e){return(0,i.i5)(e,a)?o(e):e}function o(e){return e[a](globalThis[l]?.context??c)}let l="~effect/Fiber/currentFiber",d=new Map,c={"~effect/Context":{},base:d,depth:0,mapUnsafe:d,pipe(){return(0,n.tT)(this,arguments)}};r.d(t,{E$:()=>s,f6:()=>o},{fL:l,uC:a})},7011(e,t,r){r.d(t,{L8:()=>d,Uq:()=>u});var n=r(3332),i=r(5033),a=r(2449);let s=new WeakMap;var o=r(4233);let l="~effect/Redacted",d=(e,t)=>{let r=Object.create(c);return t?.label&&(r.label=t.label),s.set(r,e),r},c={[l]:{_A:e=>e},label:void 0,...a.fU,toJSON(){return this.toString()},toString(){return`<redacted${(0,o.Kg)(this.label)?":"+this.label:""}>`},[i.HR](){return i.tW(s.get(this))},[n.HR](e){return(0,o.i5)(e,l)&&n.aI(s.get(this),s.get(e))}},u=e=>{if(s.has(e))return s.get(e);throw Error("Unable to get redacted value"+(e.label?` with label: "${e.label}"`:""))}},636(e,t,r){function n(e,t,r){return{combine:e,initialValue:t,combineAll:r??(r=>{let n=t;for(let t of r)n=e(n,t);return n})}}r.d(t,{L:()=>n})},4600(e,t,r){var n=r(6297),i=r(6712);let a=i.iL;i.Gl,i.d8,i.vA;let s=i.zQ;i.rf,i.ce,i.ls,i.nU,i.aG,n.d$_,n.olX,r.d(t,{},{iL:a,zQ:s})},9315(e,t,r){var n=r(1594),i=r(7731),a=r(2563);let s=a.Py,o=a.fJ;a.sV,a.aI;let l=a.N6,d=a.oJ;a.Oz,a.L8;let c=(0,n.XY)(2,(e,t)=>l(e)?o(t(e.failure)):e),u=(0,n.XY)(2,(e,t)=>d(e)?s(t(e.success)):e),f=(0,n.XY)(2,(e,{onFailure:t,onSuccess:r})=>l(e)?t(e.failure):r(e.success)),p=(0,n.XY)(2,(e,t)=>{if(d(e))return e.success;throw t(e.failure)})(n.D_),h=(0,n.XY)(2,(e,t)=>l(e)?o(e.failure):t(e.success));i.dv,r.d(t,{},{Gp:p,N6:l,Py:s,Tj:u,YW:f,fJ:o,oJ:d,qI:h,xm:c})},6771(e,t,r){var n=r(719),i=r(1179),a=r(3614),s=r(1594),o=r(2449),l=r(6297),d=r(1554),c=r(4233),u=r(3753);let f="~effect/Schedule",p=i.Or("effect/Schedule/CurrentMetadata",{defaultValue:(0,s.dY)({input:void 0,output:void 0,duration:a.v_,attempt:0,start:0,now:0,elapsed:0,elapsedSincePrevious:0})}),h={[f]:{_Out:s.D_,_In:s.D_,_Env:s.D_},pipe(){return(0,d.tT)(this,arguments)}},m=e=>{let t=Object.create(h);return t.step=e,t},g=()=>{let e,t,r=0;return(n,i)=>{void 0===t&&(t=n);let a=n-t,s=void 0===e?0:n-e;return e=n,{input:i,attempt:++r,start:t,now:n,elapsed:a,elapsedSincePrevious:s}}},y=e=>l.Tyx(e.step,e=>l.PyW(()=>l.ATB(e))),v=e=>{let t,r=a.bN(e);return t=l.PyW(e=>l.PyW([e.attempt-1,r])),m(l.TjK(t,e=>{let t=g();return(r,n)=>e(t(r,n))}))},b=(0,s.XY)(2,(e,t)=>{let r=void 0===t.duration?void 0:a.bN(t.duration);return _(e,({attempt:e,elapsed:n})=>l.PyW((void 0===t.times||e<=t.times)&&(void 0===r||a.bi(a.ne(n),r))))}),_=(0,s.XY)(2,(e,t)=>m(l.TjK(y(e),e=>{let r=g();return(i,a)=>l.qIB(e(i,a),e=>{let[s,d]=e,c=t({...r(i,a),output:s,duration:d});return l.qIB((0,o.yw)(c)?c:l.PyW(c),t=>t?l.PyW(e):n.Vw(s))})}))),x=v(a.v_);r.d(t,{},{E6:_,GM:e=>(0,c.i5)(e,f),d3:p,i4:x,jB:b,ji:v,le:e=>m(l.TjK(y(e),e=>(t,r)=>u.tv(e(t,r),{onSuccess:e=>l.PyW([r,e[1]]),onFailure:l.ATB,onDone:()=>n.Vw(r)}))),t5:e=>_(x,({attempt:t})=>l.PyW(t<=e)),xn:e=>l.RKA(t=>l.TjK(y(e),e=>{let r=g();return n=>l.DYE(()=>{let i=t.currentTimeMillisUnsafe();return l.qIB(e(i,n),([e,t])=>{let a=r(i,n);return a.output=e,a.duration=t,l.as(l.yy4(t),a)})})}))})},3909(e,t,r){var n=r(1179);let i=n.Or("effect/Scheduler",{fiberCached:!0,defaultValue:()=>new d}),a=e=>{let t=!1;return Promise.resolve().then(()=>{t||e()}),()=>{t=!0}},s="setImmediate"in globalThis?e=>{let t=globalThis.setImmediate(e);return()=>globalThis.clearImmediate(t)}:e=>{let t=setTimeout(e,0);return()=>clearTimeout(t)},o=e=>{try{return s(e)}catch{return a(e)}};class l{buckets=[];scheduleTask(e,t){let r,n=this.buckets,i=n.length,a=0;for(;a<i&&!(n[a][0]>t);a++)r=n[a];r&&r[0]===t?r[1].push(e):a===i?n.push([t,[e]]):n.splice(a,0,[t,[e]])}drain(){let e=this.buckets;return this.buckets=[],e}}class d{executionMode;setImmediate;constructor(e="async",t){this.executionMode=e,this.setImmediate=t??("sync"===e?a:o)}shouldYield(e){return e.currentOpCount>=e.cache.maxOpsBeforeYield}makeDispatcher(){return new c(this.setImmediate)}}class c{tasks=new l;running=void 0;setImmediate;constructor(e=o){this.setImmediate=e}scheduleTask(e,t){this.tasks.scheduleTask(e,t),void 0===this.running&&(this.running=this.setImmediate(this.afterScheduled))}afterScheduled=()=>{this.running=void 0,this.runTasks()};runTasks(){let e=this.tasks.drain();for(let t=0;t<e.length;t++){let r=e[t][1];for(let e=0;e<r.length;e++)r[e]()}}flush(){for(;this.tasks.buckets.length>0;)void 0!==this.running&&(this.running(),this.running=void 0),this.runTasks()}}let u=n.Or("effect/Scheduler/MaxOpsBeforeYield",{fiberCached:!0,defaultValue:()=>2048}),f=n.Or("effect/Scheduler/PreventSchedulerYield",{fiberCached:!0,defaultValue:()=>!1});r.d(t,{FG:()=>d},{Zm:u,_F:i,hf:f})},2718(e,t,r){let n,i,a,s,o,l,d,c,u,f;r.d(t,{O31:()=>rH,v8c:()=>rY,$Cd:()=>r8,Xsx:()=>nA,n96:()=>nx,kld:()=>nb,$DH:()=>nN,o5J:()=>r6,wYs:()=>ni,Aiz:()=>nf,uSQ:()=>rF,xCb:()=>rZ,ukk:()=>ny,T9y:()=>r0,wNn:()=>rJ,pHd:()=>nS,mSG:()=>rV,QfV:()=>rW,_kM:()=>rG,rNF:()=>nP,L39:()=>r3,SEl:()=>n$,gPz:()=>rQ,$r1:()=>rB,usV:()=>r$,hzj:()=>rS,GLL:()=>r5,_Re:()=>rT,q$Z:()=>rM,svK:()=>rA,mj7:()=>nk,is:()=>rC,Bt9:()=>nu,MIs:()=>na,yJO:()=>nl,OWK:()=>nd,biW:()=>nc,NYj:()=>nm,tJb:()=>np,Pto:()=>nn,nfo:()=>nt,HNH:()=>nr,fXn:()=>rK,Wa3:()=>rj,lqM:()=>rR,Qrq:()=>rP,DYE:()=>r2,TcI:()=>ne,lHk:()=>nj,O3D:()=>rU,_oz:()=>nR,rcy:()=>rO,AxX:()=>rD,tiU:()=>r7,E$i:()=>r4});var p,h,m,g,y=r(3332),v=r(5033),b=r(3952),_=r(1587),x=r(2860),w=r(1554),k=r(4233);let S="~effect/BigDecimal",I={[S]:S,[v.HR](){let e=A(this);return v.kg(v.Yj(String(e.value)),v.ai(e.scale))},[y.HR](e){return $(e)&&0===j(this,e)},toString(){return`BigDecimal(${U(this)})`},toJSON(){return{_id:"BigDecimal",value:String(this.value),scale:this.scale}},[b.FX](){return this.toJSON()},pipe(){return(0,w.tT)(this,arguments)}},$=e=>(0,k.i5)(e,S),E=(e,t)=>{let r=((e,t)=>{if(!Number.isSafeInteger(t))throw RangeError(`Scale must be a safe integer, got ${t}`);let r=Object.create(I);return r.value=e,r.scale=t,r})(e,t);return r.normalized=r,r},O=BigInt(0),C=BigInt(1),T=BigInt(10),M=E(O,0),A=e=>{if(void 0===e.normalized)if(e.value===O)e.normalized=M;else{let t=`${e.value}`,r=t.length;for(;"0"===t[r-1];)r--;e.normalized=E(BigInt(t.slice(0,r)),e.scale-(t.length-r))}return e.normalized},N=[C],P=(e,t)=>e===t?0:e<t?-1:1,R=(e,t)=>{let r=`${e.value<O?-e.value:e.value}`,n=`${t.value<O?-t.value:t.value}`,i=BigInt(r.length-n.length)-BigInt(e.scale)+BigInt(t.scale);if(i!==O)return i<O?-1:1;let a=Math.max(r.length,n.length);return x.Qf(r.padEnd(a,"0"),n.padEnd(a,"0"))},j=(e,t)=>{if(e.scale===t.scale)return P(e.value,t.value);let r=D(e),n=D(t);if(r!==n)return r<n?-1:1;if(0===r)return 0;let i=e.scale-t.scale,a=Math.abs(i);if(a>100)return -1===r?R(t,e):R(e,t);let s=N[a]??=T**BigInt(a);return i>0?P(e.value,t.value*s):P(e.value*s,t.value)},D=e=>e.value===O?0:e.value<O?-1:1,U=e=>{let t=A(e);if(Math.abs(t.scale)>=16)return F(t);let r=t.value<O,n=`${r?-t.value:t.value}`,i=t.scale>0?n.padStart(t.scale+1,"0"):n.padEnd(n.length-t.scale,"0"),a=i.length-t.scale,s=t.scale>0?`${i.slice(0,a)}.${i.slice(a)}`:i;return r?`-${s}`:s},F=e=>{if(B(e))return"0e+0";let t=A(e),r=`${t.value}`,n=t.value<O?2:1,i=r.slice(0,n),a=r.slice(n),s=a.length-t.scale;return`${i}${""===a?"":`.${a}`}e${s>=0?"+":""}${s}`},B=e=>e.value===O;var L=r(3265),z=r(719),W=r(4942),J=r(1179),Y=r(1594),X=r(4238),q=r(3614),G=r(7876),V=r(6297);let H="~effect/DateTime",K="~effect/DateTime/TimeZone",Q={[H]:H,pipe(){return(0,w.tT)(this,arguments)},[b.FX](){return this.toString()},toJSON(){return em(this).toJSON()}},Z={...Q,_tag:"Utc",[v.HR](){return v.ai(this.epochMilliseconds)},[y.HR](e){return ea(e)&&"Utc"===e._tag&&this.epochMilliseconds===e.epochMilliseconds},toString(){return`DateTime.Utc(${em(this).toJSON()})`}},ee={...Q,_tag:"Zoned",[v.HR](){return v.kg(v.ai(this.epochMilliseconds))(v.tW(this.zone))},[y.HR](e){return ea(e)&&"Zoned"===e._tag&&this.epochMilliseconds===e.epochMilliseconds&&y.aI(this.zone,e.zone)},toString(){return`DateTime.Zoned(${eT(this)})`}},et={[K]:K,[b.FX](){return this.toString()}},er={...et,_tag:"Named",[v.HR](){return v.Yj(`Named:${this.id}`)},[y.HR](e){return eo(e)&&"Named"===e._tag&&this.id===e.id},toString(){return`TimeZone.Named(${this.id})`},toJSON(){return{_id:"TimeZone",_tag:"Named",id:this.id}}},en={...et,_tag:"Offset",[v.HR](){return v.Yj(`Offset:${this.offset}`)},[y.HR](e){return eo(e)&&"Offset"===e._tag&&this.offset===e.offset},toString(){return`TimeZone.Offset(${ev(this.offset)})`},toJSON(){return{_id:"TimeZone",_tag:"Offset",offset:this.offset}}},ei=(e,t,r)=>{let n=Object.create(ee);return n.epochMilliseconds=e,n.zone=t,Object.defineProperty(n,"partsUtc",{value:r,enumerable:!1,writable:!0}),Object.defineProperty(n,"adjustedEpochMillis",{value:void 0,enumerable:!1,writable:!0}),Object.defineProperty(n,"partsAdjusted",{value:void 0,enumerable:!1,writable:!0}),n},ea=e=>k.i5(e,H),es=e=>ea(e[0]),eo=e=>k.i5(e,K),el=e=>{let t=Object.create(Z);return t.epochMilliseconds=e,Object.defineProperty(t,"partsUtc",{value:void 0,enumerable:!1,writable:!0}),t},ed=e=>{let t=e.getTime();if(Number.isNaN(t))throw new z.qw("Invalid date");return el(t)},ec=e=>/Z|GMT|[+-]\d{2}$|[+-]\d{2}:?\d{2}$|\]$/.test(e),eu=_.liftThrowable(e=>{if(ea(e))return e;if(e instanceof Date)return ed(e);if("object"==typeof e){if("epochMilliseconds"in e)return ed(new Date(e.epochMilliseconds));let t=new Date(0);return e_(t,e),ed(t)}return"string"!=typeof e||ec(e)?ed(new Date(e)):ed(new Date(e+"Z"))});X.Ru,(e,t,r)=>r?.adjustForTimeZone===!0?ex(e.epochMilliseconds,t,r?.disambiguation??"compatible"):ei(e.epochMilliseconds,t,e.partsUtc);let ef=new Map,ep={day:"numeric",month:"numeric",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"longOffset",fractionalSecondDigits:3,hourCycle:"h23"},eh=_.liftThrowable(e=>{let t=ef.get(e);if(void 0!==t)return t;try{let t=(e=>{let t=e.resolvedOptions().timeZone,r=ef.get(t);if(void 0!==r)return r;let n=Object.create(er);return n.id=t,n.format=e,ef.set(t,n),n})(new Intl.DateTimeFormat("en-US",{...ep,timeZone:e}));return ef.set(e,t),t}catch{throw new z.qw(`Invalid time zone: ${e}`)}}),em=e=>new Date(e.epochMilliseconds),eg=e=>{if("Utc"===e._tag)return new Date(e.epochMilliseconds);if("Offset"===e.zone._tag)return new Date(e.epochMilliseconds+e.zone.offset);if(void 0!==e.adjustedEpochMilliseconds)return new Date(e.adjustedEpochMilliseconds);let t=e.zone.format.formatToParts(e.epochMilliseconds).filter(e=>"literal"!==e.type),r=new Date(0);return r.setUTCFullYear(Number(t[2].value),Number(t[0].value)-1,Number(t[1].value)),r.setUTCHours(Number(t[3].value),Number(t[4].value),Number(t[5].value),t[6]?.type==="fractionalSecond"?Number(t[6].value):(e.epochMilliseconds%1e3+1e3)%1e3),e.adjustedEpochMilliseconds=r.getTime(),r},ey=e=>eg(e).getTime()-eb(e),ev=e=>{let t=Math.abs(e),r=Math.floor(t/36e5),n=Math.round(t%36e5/6e4);return 60===n&&(r+=1,n=0),`${e<0?"-":"+"}${String(r).padStart(2,"0")}:${String(n).padStart(2,"0")}`},eb=e=>e.epochMilliseconds,e_=(e,t)=>{if((void 0!==t.year||void 0!==t.month||void 0!==t.day)&&e.setUTCFullYear(t.year??e.getUTCFullYear(),void 0!==t.month?t.month-1:e.getUTCMonth(),t.day??e.getUTCDate()),void 0!==t.weekDay){let r=t.weekDay-e.getUTCDay();e.setUTCDate(e.getUTCDate()+r)}void 0!==t.hour&&e.setUTCHours(t.hour),void 0!==t.minute&&e.setUTCMinutes(t.minute),void 0!==t.second&&e.setUTCSeconds(t.second),void 0!==t.millisecond&&e.setUTCMilliseconds(t.millisecond)},ex=(e,t,r)=>{if("Offset"===t._tag)return ei(e-t.offset,t);let n=eS(e-864e5,e,t),i=eS(e+864e5,e,t);if(n===i)return ei(e-n,t);let a=n-i;if(n<i){if(eS(e-i,e,t)===i)return ei(e-i,t);let a=ei(e-n,t);if(e!==eg(a).getTime())switch(r){case"reject":{let r=new Date(e).toISOString();throw RangeError(`Gap time: ${r} does not exist in time zone ${t.id}`)}case"earlier":return ei(e-i,t)}return a}if(eS(e-n,e,t)===n){if("earlier"===r||"compatible"===r||eS(e-n+a,e+a,t)===n)return ei(e-n,t);if("reject"===r){let r=new Date(e).toISOString();throw RangeError(`Ambiguous time: ${r} occurs twice in time zone ${t.id}`)}}return ei(e-i,t)},ew=/([+-])(\d{2}):(\d{2})$/,ek=e=>{let t=ew.exec(e);if(null===t)return null;let[,r,n,i]=t;return("+"===r?1:-1)*(60*Number(n)+Number(i))*6e4},eS=(e,t,r)=>{let n=r.format.formatToParts(e).find(e=>"timeZoneName"===e.type)?.value??"";if("GMT"===n)return 0;let i=ek(n);return null===i?ey(ei(t,r)):i},eI=(0,Y.XY)(es,(e,t,r)=>{if("Utc"===e._tag){let r=em(e);return t(r),el(r.getTime())}let n=new Date(eg(e).getTime());return t(n),ex(n.getTime(),e.zone,r?.disambiguation??"compatible")}),e$=((e,t)=>e$(e,e=>{let r=new Date(e);return t(r),r.getTime()}),(0,Y.XY)(2,(e,t)=>{let r=t(eb(e));return"Utc"===e._tag?el(r):ei(r,e.zone)})),eE=((e,t)=>t(eg(e)),(0,Y.XY)(2,(e,t)=>t(em(e)))),eO=(e,t)=>{e.setTime(e.getTime()+t)},eC=((e,t)=>eI(e,e=>{if(t.milliseconds&&eO(e,t.milliseconds),t.seconds&&eO(e,1e3*t.seconds),t.minutes&&eO(e,60*t.minutes*1e3),t.hours&&eO(e,60*t.hours*6e4),t.days&&e.setUTCDate(e.getUTCDate()+t.days),t.weeks&&e.setUTCDate(e.getUTCDate()+7*t.weeks),t.months){let r=e.getUTCDate();e.setUTCMonth(e.getUTCMonth()+t.months+1,0),r<e.getUTCDate()&&e.setUTCDate(r)}if(t.years){let r=e.getUTCDate(),n=e.getUTCMonth();e.setUTCFullYear(e.getUTCFullYear()+t.years,n+1,0),r<e.getUTCDate()&&e.setUTCDate(r)}}),e=>{let t=eg(e);return"Utc"===e._tag?t.toISOString():`${t.toISOString().slice(0,-1)}${ev(ey(e))}`}),eT=e=>"Offset"===e.zone._tag?eC(e):`${eC(e)}[${e.zone.id}]`;r(5633);var eM=r(2842),eA=(r(2997),r(6526)),eN=r(1958),eP=r(2275),eR=r(915),ej=r(9315);let eD="~effect/http/Cookies",eU="~effect/http/Cookies/Cookie",eF="~effect/http/Cookies/CookieError";class eB extends W.$D{}class eL extends W.rN("CookiesError"){static fromReason(e,t){return new eL({reason:new eB({_tag:e,cause:t})})}[eF]=eF;get message(){return this.reason._tag}}({[eD]:eD,...b.os,toJSON(){return{_id:"effect/Cookies",cookies:eR.Tj(this.cookies,e=>e.toJSON())}},pipe(){return(0,w.tT)(this,arguments)}}),{[eU]:eU,...b.os,toJSON(){return{_id:"effect/Cookies/Cookie",name:this.name,value:this.value,options:this.options}}};var ez=r(1279),eW=r(7011);let eJ=Symbol.for("~effect/http/Headers"),eY=Object.defineProperties(Object.create(null),{[eJ]:{value:eJ},[ez.uC]:{value(e){return eq(this,J.Jt(e,eG))}},toJSON:{value(){return ez.E$(this)}},[y.HR]:{value(e){return eX(this,e)}},[v.HR]:{value(){return v.QK(this)}},toString:{value:b.os.toString},[b.FX]:{value:b.os[b.FX]}}),eX=eR.T9(G.YZ()),eq=(0,Y.XY)(2,(e,t)=>{let r={...e},n=t=>{if("string"==typeof t){let n=t.toLowerCase();n in e&&(r[n]=eW.L8(e[n]))}else for(let n in e)-1!==n.search(t)&&(r[n]=eW.L8(e[n]))};if(Array.isArray(t))for(let e=0;e<t.length;e++)n(t[e]);else n(t);return r}),eG=J.Or("effect/Headers/CurrentRedactedNames",{defaultValue:()=>["authorization","cookie","set-cookie","x-api-key"]});var eV=r(664),eH=r(2449);let eK=G.rd;x.rd;let eQ="~effect/http/UrlParams",eZ={...eH.fU,[eQ]:eQ,[Symbol.iterator](){return this.params[Symbol.iterator]()},toJSON(){return{_id:"UrlParams",params:Object.fromEntries(this.params)}},[y.HR](e){return e0(this,e)},[v.HR](){return v.YO(this.params.flat())}},e0=G.L8((e,t)=>e1(e.params,t.params)),e1=eV.T9(eK([G.YZ(),G.YZ()]));var e2=r(2840),e5=r(2109),e3=r(8253),e6=r(7086),e8=r(587);let e9=(e,t,r)=>e===e8.Rr?r(t):eM.Ab9(e,r);function e4(e){if("Middleware"===e._tag)return(t,r,n)=>e7(t===e8.Rr?e.decode(e8.Py(e8.zL(r)),n):e.decode(eM.jkJ(t,e8.zL),n));let t=e.decode;switch(t._tag){case"Passthrough":return(e,t)=>e===e8.Rr?e8.Py(t):e;case"Transform":{let e=e=>e===e8.LO?e8.r2:e8.Py(t.transform(e));return(t,r)=>e9(t,r,e)}case"TransformOptional":{let e=e=>e8.e8(t.transform(e8.zL(e)));return(t,r)=>e9(t,r,e)}case"TransformEffect":return(e,r,n)=>e9(e,r,e=>e===e8.LO?e8.r2:t.transform(e,n));case"TransformOptionalEffect":return(e,r,n)=>e9(e,r,e=>e7(t.transform(e8.zL(e),n)))}}let e7=e=>eM.Ab9(e,e8.e8),te=(e,t,r,n)=>eM.Tyx(n,n=>eM.pVV(()=>z.Tj(n,n=>new e6.Wi(e,n,t,r))));function tt(e,t){let r,n=t(e);return e.context?.constructorDefault===void 0?n:(r=e.context.constructorDefault,(t,i)=>{if(t!==e8.LO&&void 0!==t)return n(t,i);if((0,V.OY)(r)&&"Success"===r._tag){let e=n(r[eH.a2],i);return e===e8.Rr?r:e}return eM.Ab9(te(e,t,i,r),e=>{let t=n(e,i);return t===e8.Rr?e8.Py(e):t})})}function tr(e,t,r,n,i){let a,s,o;if("Declaration"===e._tag)for(let r of e.typeParameters)t(r);let l=r?e5.gR(e):void 0,d=l?(o=e4(l.link.transformation),(e,r)=>e===e8.LO?e8.r2:l.isConstructed(e)?e8.Rr:o((s??=t(l.link.to))(e,r),e,r)):n??e.getParser(t,r),c=e.checks,u=e.encoding,f=u?.map(e=>e4(e.transformation)),p=e.encodingChecks;if(!u&&!c&&!p)return d;let h=(t,r)=>{let n=d(t,r);if(p&&!r.disableChecks)if((0,V.OY)(n)){if("Success"===n._tag){let i=n===e8.Rr?t:n[eH.a2];if(t!==e8.LO&&i!==e8.LO){let i=e5.Lp(p,t,void 0,e,r);i&&(n=eM.fJG(new e6.eC(e,i,t,r)))}}}else n=eM.qIB(n,n=>{if(t!==e8.LO&&n!==e8.LO){let n=e5.Lp(p,t,void 0,e,r);if(n)return eM.fJG(new e6.eC(e,n,t,r))}return eM.PyW(n)});if(c&&!r.disableChecks)if((0,V.OY)(n)){if("Success"===n._tag){let i=n===e8.Rr?t:n[eH.a2];if(i===e8.LO)return n;let a=e5.Lp(c,i,void 0,e,r);a&&(n=eM.fJG(new e6.eC(e,a,i,r)))}}else n=eM.qIB(n,t=>{if(t!==e8.LO){let n=e5.Lp(c,t,void 0,e,r);if(n)return eM.fJG(new e6.eC(e,n,t,r))}return eM.PyW(t)});return n},m=void 0===i?h:i(h);return u?(r,n)=>{let i=a??=u.map(e=>t(e.to)),s=r,o=i[i.length-1](r,n);for(let e=u.length-1;e>=0;e--)if(o=f[e](o,s,n),0!==e){let t=i[e-1];o="Success"===o._tag?t(s=o[eH.a2],n):eM.Ab9(o,e=>{let r=t(e,n);return r===e8.Rr?e8.Py(e):r})}if("Success"===o._tag){let e=m(o[eH.a2],n);return e===e8.Rr?o:e}return o=te(e,r,n,o),eM.Ab9(o,e=>{let t=m(e,n);return t===e8.Rr?e8.Py(e):t})}:m}let tn=Symbol(),ti=new WeakMap,ta=e=>tu(e).parser,ts=e=>tu(e).makeEffect,to=e=>tt(e,ts);class tl{ast;constructor(e){this.ast=e}get decodeEffect(){return this.cachedDecodeEffect??=tr(this.ast,ta)}get parser(){return this.decodeEffect}get makeEffect(){return this.cachedMakeEffect??=tr(this.ast,ts,to)}}class td extends tl{compiled;resolve;constructor(e,t,r){super(e),this.compiled=t,this.resolve=r}save(e,t){return Object.defineProperty(this,e,{value:t}),t}operation(e){let t=this.compiled;return"function"==typeof t?t(this.ast,this.resolve,e):t?.[e]}get is(){return this.save("is",this.operation("is"))}get decode(){return this.save("decode",this.operation("decode"))}get make(){return this.save("make",this.operation("make"))}get decodeEffect(){return this.save("decodeEffect",this.operation("decodeEffect")??tr(this.ast,e=>tc(this.resolve,e,"parser")))}get parser(){var e,t;let r,n=this.decode;return void 0===n?this.decodeEffect:this.save("parser",(e=n,t=()=>this.decodeEffect,(n,i)=>{if(n!==e8.LO)try{let t=e(n,i);if(t!==tn)return t===n?e8.Rr:e8.Py(t)}catch(e){return eM.F_Q(e)}return(r??=t())(n,i)}))}get makeEffect(){let e=this.operation("makeEffect");if(void 0!==e)return this.save("makeEffect",e);let t=e=>tc(this.resolve,e,"makeEffect");return this.save("makeEffect",tr(this.ast,t,e=>tt(e,t)))}}function tc(e,t,r){let n,i=e(t);return void 0===i.compiled||Object.hasOwn(i,r)?i[r]:(e,t)=>(n??=i[r])(e,t)}function tu(e){let t=ti.get(e);if(void 0!==t)return t;let r=void 0===n?new tl(e):new td(e,n(e,tu),tu);return ti.set(e,r),r}function tf(e){let t,r=e.ast;return(e,n)=>(t??=tv(tx,e5.Ax(r)))(e,n?.disableChecks?n?.parseOptions?{...n.parseOptions,disableChecks:!0}:{disableChecks:!0}:n?.parseOptions)}function tp(e){let t=tf(e);return(e,r)=>{let n=eM.lKS(t(e,r));return eA.oJ(n)?_.some(n.value):(e3.q(n.cause,"Option adapter can only return none for schema issues"),_.none())}}function th(e){var t;let r,n;return t=e5.Ax(e.ast),(e,i)=>{r??=tu(t);let a=i?.disableChecks?i.parseOptions?{...i.parseOptions,disableChecks:!0}:{disableChecks:!0}:i?.parseOptions??e5.vr,s=r.make;if(void 0!==s&&e!==e8.LO){let t;try{t=s(e,a)}catch(e){throw e3.q(z.F_(e),"Constructor adapter can only throw schema issues"),e}if(t!==tn&&t!==e8.LO)return t}var o=function(e,t){return e===e8.Rr?eM.PyW(t):(0,V.OY)(e)?e[eH.a2]===e8.LO?ty(e8.LO):e:eM.Ab9(e,ty)}((n??=r.makeEffect)(e,a),e);let l=eM.lKS(o);if(eA.oJ(l))return l.value;throw Error("Schema validation failed",{cause:e3.q(l.cause,"Constructor adapter can only throw schema issues")})}}function tm(e,t){let r=tv(t_,e.ast);return void 0===t?r:(e,n)=>r(e,tg(t,n))}let tg=(e,t)=>t?{...e,...t}:e,ty=e=>e===e8.LO?eM.fJG(new e6.h6):eM.PyW(e);function tv(e,t){let r;return(n,i)=>{let a=(r??=e(t))(n,i??e5.vr);return a===e8.Rr?eM.PyW(n):(0,V.OY)(a)?a[eH.a2]===e8.LO?ty(e8.LO):a:eM.Ab9(a,ty)}}function tb(e){return(t,r)=>eM.lKS(e(t,r))}let t_=e=>tu(e).parser,tx=e=>tu(e).makeEffect,tw="~effect/Schema/Schema",tk=Symbol(),tS={[tw]:tw,get make(){let e=th(this);return Object.defineProperty(this,"make",{value:e,enumerable:!0}),e},get makeEffect(){let e=tf(this);return Object.defineProperty(this,"makeEffect",{value:e,enumerable:!0}),e},get makeOption(){let e=tp(this);return Object.defineProperty(this,"makeOption",{value:e,enumerable:!0}),e},pipe(){return w.tT(this,arguments)},annotate(e){return this.rebuild(e5.fz(this.ast,e))},annotateKey(e){return this.rebuild(e5.us(this.ast,e))},check(...e){return this.rebuild(e5.EJ(this.ast,e))},rebuild(e){return tI(e,this[tk])}};function tI(e,t){let r=Object.setPrototypeOf(function(){},tS);return t&&(Object.hasOwn(t,"name")||Object.hasOwn(t,"length")||Object.hasOwn(t,"__proto__"))?Object.defineProperties(r,Object.getOwnPropertyDescriptors({...t})):Object.assign(r,t),r[tk]=t,r.ast=e,r}var t$=r(3909);function tE(e){return eA.oJ(e)?e.value:{issues:[{message:z.j9(e.cause)}]}}var tO=r(2981),tC=r(7268);let tT=e5.B9(e=>{let t=function(e,t){switch(e._tag){case"Declaration":{let r=e.annotations?.toCodecJson??e.annotations?.toCodec;if(!k.Tn(r))return e5.ES(e,[e5.Gf]);let n=r(e.typeParameters.map(e=>tI(e5.O3(e))));return void 0===n?e:e5.ES(e,[e5.Td(n,t)])}case"Unknown":return e5.ES(e,[e5.Gf]);case"ObjectKeyword":return e5.ES(e,[e5.W5]);case"Undefined":case"Void":case"Literal":case"Number":return e.toCodecJson();case"UniqueSymbol":case"Symbol":case"BigInt":return e.toCodecStringTree();case"Objects":return tA(e),e.recur(t,e5.xw);case"Union":{let r=tP(e.types);if(r!==e.types)return new e5.gP(r,e.options,e.annotations,e.checks,e.encoding,e.context,e.encodingChecks).recur(t);return e.recur(t)}case"Arrays":case"Suspend":return e.recur(t)}return e}(e,tT),r=e.context;return t===e||void 0===r?t:e5.Q0(t,tM(r))});function tM(e){return void 0===e.constructorDefault?e:new e5.ob(e.isOptional,e.isMutable,void 0,e.annotations)}function tA(e){if(e.propertySignatures.some(e=>"string"!=typeof e.name))throw new globalThis.Error("Objects property names must be strings",{cause:e})}function tN(e){return t=>{let r=[...t].sort((t,r)=>e(e5.O3(t))-e(e5.O3(r)));return r.some((e,r)=>e!==t[r])?r:t}}let tP=tN(e=>{switch(e._tag){case"BigInt":case"Symbol":case"UniqueSymbol":return 0;default:return 1}}),tR=(0,Y.Bj)(e=>{let t=function(e,t){switch(e._tag){case"Declaration":{let r=e.annotations?.toCodecIso??e.annotations?.toCodec;if(k.Tn(r)){let n=r(e.typeParameters.map(e=>tI(e)));return e5.ES(e,[e5.Td(n,t)])}break}case"Arrays":case"Objects":case"Union":case"Suspend":return e.recur(t)}return e}(e,tR);return t!==e&&void 0!==e.context?e5.Q0(t,tM(e.context)):t}),tj=tN(e=>{switch(e._tag){case"Null":case"Boolean":case"Number":case"BigInt":case"Symbol":case"UniqueSymbol":return 0;default:return 1}}),tD=new e5.N_(new e5.uS("null"),new tC.IT(tO.pd(()=>null),tO.pd(()=>"null"))),tU=new e5.N_(new e5.gP([new e5.uS("true"),new e5.uS("false")]),new tC.IT(tO.pd(e=>"true"===e),tO.Qf())),tF=new tC.IT(tO.pd(e=>"string"==typeof e?[e]:e),tO.le()),tB=e=>e.transformation===tF,tL=e5.B9(e=>{let t=function(e,t,r){switch(e._tag){case"Declaration":{let n=e.typeParameters.map(e=>tI(t(e5.O3(e)))),i=e.annotations?.toCodecStringTree;if(k.Tn(i)){let r=i(n);if(void 0===r)return e;return e5.ES(e,[e5.Td(r,t)])}let a=e.annotations?.toCodecJson,s=k.Tn(a)?a(n):void 0,o=void 0===s?e.annotations?.toCodec:void 0,l=s??(k.Tn(o)?o(n):void 0);return void 0===l?r(e):e5.ES(e,[e5.Td(l,t)])}case"Null":return e5.ES(e,[tD]);case"Boolean":return e5.ES(e,[tU]);case"Unknown":case"ObjectKeyword":return e5.ES(e,[e5.tC]);case"Enum":case"Number":case"Literal":case"UniqueSymbol":case"Symbol":case"BigInt":return e.toCodecStringTree();case"Objects":return tA(e),e.recur(t,e5.xw);case"Union":{let r=tj(e.types);if(r!==e.types)return new e5.gP(r,e.options,e.annotations,e.checks,e.encoding,e.context,e.encodingChecks).recur(t);return e.recur(t)}case"Arrays":case"Suspend":return e.recur(t)}return e}(e,tL,e=>{throw new globalThis.Error("Missing structural codec for StringTree",{cause:e})});return t!==e&&void 0!==e.context?e5.Q0(t,tM(e.context)):t},{stopAt:tB}),tz=e=>e5.dK(e)?e5.Qr(e5.L5):e5.L5,tW=e5.B9(e=>{var t;let r="Declaration"===(t=e)._tag||"Arrays"===t._tag||"Objects"===t._tag||"Union"===t._tag||"Suspend"===t._tag?t.recur(tW):t;if(e5.tF(r)){let t=e5.GL(new e5.gP([new e5.DO(r.isMutable,r.elements.map(tz),r.rest.map(tz)),e5.Yj],{mode:"anyOf"}),r,tF);return e5.dK(e)?e5.Qr(t):t}return r},{stopAt:tB}),tJ=["$anchor","$defs","$dynamicAnchor","$dynamicRef","$vocabulary","contentSchema","dependentRequired","dependentSchemas","maxContains","minContains","prefixItems","unevaluatedItems","unevaluatedProperties"];function tY(e,t){return t.length>0&&(e+=`
235
+ at ${(0,eN.jV)(t)}`),Error(e)}function tX(e){return`#/$defs/${encodeURI(e.replace(/~/g,"~0").replace(/\//g,"~1")).replace(/#/g,"%23")}`}[...tJ],[...tJ],k.gd;let tq=new Set([...e2.UI,e2.R4,...e2.L1]);function tG(e,t){if(void 0===e)return;let r={},n=e.title;"string"==typeof n&&(r.title=n);let i=e.description,a=e.expected;"string"==typeof i?r.description=i:t?.generateDescriptions===!0&&"string"==typeof a&&(r.description=a);let s=e.default;e5.Fh(s)&&(r.default=s);let o=e.examples;Array.isArray(o)&&e5.Fh(o)&&(r.examples=o);let l=e.readOnly;"boolean"==typeof l&&(r.readOnly=l);let d=e.writeOnly;"boolean"==typeof d&&(r.writeOnly=d);let c=e.format;"string"==typeof c&&(r.format=c);let u=e.contentEncoding;"string"==typeof u&&(r.contentEncoding=u);let f=e.contentMediaType;"string"==typeof f&&(r.contentMediaType=f);let p=e.contentSchema;if(e5.Fh(p)&&(r.contentSchema=p),t?.includeAnnotationKey!==void 0)for(let[n,i]of Object.entries(e))!tq.has(n)&&t.includeAnnotationKey(n)&&e5.Fh(i)&&eP.x(r,n,i);return 0===Object.keys(r).length?void 0:r}let tV="|type|format|pattern|multipleOf|minimum|maximum|exclusiveMinimum|exclusiveMaximum|minLength|maxLength|minItems|maxItems|uniqueItems|minProperties|maxProperties|propertyNames|";function tH(e,t){return Object.keys(e).every(e=>t.includes(`|${e}|`))}function tK(e,t){return"string"!=typeof e.$ref&&t.every(t=>!Object.hasOwn(e,t))}let tQ="|title|description|default|examples|readOnly|writeOnly|",tZ=tV+tQ;function t0(e,t,r){if(0===Object.keys(e).length)return t;let n=Object.keys(t);if(0===n.length)return e;let i="number"===e.type||"integer"===e.type?e.type:void 0,a=function(e){if(!Array.isArray(e.anyOf)||2!==e.anyOf.length||e.anyOf[0]?.type!=="number")return!1;let t=e.anyOf[1];return t?.type==="string"&&Array.isArray(t.enum)&&3===t.enum.length&&t.enum.includes("NaN")&&t.enum.includes("Infinity")&&t.enum.includes("-Infinity")}(e);if(void 0!==i||a){let n=function e(t){let r="number"===t.type||"integer"===t.type?t.type:void 0,n=t;if(void 0!==r&&(n={...t},delete n.type),Array.isArray(n.allOf)){let t=[],i=!1;for(let a of n.allOf){let n=e(a);void 0!==n.type&&(i=!0,(void 0===r||"integer"===n.type)&&(r=n.type)),Object.keys(n.schema).length>0&&t.push(n.schema)}if(i){let{allOf:e,...r}=n;n=0===t.length?r:{...r,allOf:t}}}return{type:r,schema:n}}(t);if(void 0!==n.type){let t="integer"===i||"integer"===n.type?"integer":"number",s={...e,type:t};a&&delete s.anyOf;let o=Object.keys(n.schema);return 0===o.length?s:tH(n.schema,tQ)&&tK(s,o)?{...s,...n.schema}:t0(s,n.schema,r)}}if(r&&tK(e,n))return{...e,...t};let s=Array.isArray(t.allOf)&&1===n.length?t.allOf:[t];return Array.isArray(e.allOf)?{...e,allOf:[...e.allOf,...s]}:"string"==typeof e.$ref?{allOf:[e,...s]}:{...e,allOf:s}}function t1(e,t=new Set){return"boolean"==typeof e?e:!!t.has(e)||(t.add(e),e.every(e=>t1(e,t)))}function t2(e){switch(e._tag){case"Literal":return globalThis.String(e.literal).replace(/[/\\^$*+?.()|[\]{}]/g,"\\$&");case"String":return e5.XV;case"Number":return e5.bm;case"TemplateLiteral":return e.parts.map(t2).join("");case"Union":return`(?:${e.types.map(t2).join("|")})`;default:throw tY("Invalid schema representation document",[])}}let t5=({identifier:e})=>e;function t3(e){return void 0===e?void 0:{annotations:e}}let t6="~effect/Schema/SchemaError";var t8=r(5340);let t9="~effect/net/NetAddress";class t4 extends W.rN("NetAddressError"){}let t7=e=>(0,k.i5)(e,t9),re=e=>t7(e)&&"Ipv4Address"===e._tag,rt=e=>t7(e)&&"Ipv6Address"===e._tag,rr=e=>t7(e)&&"InetAddressV4"===e._tag,rn=e=>t7(e)&&"InetAddressV6"===e._tag,ri={_tag:"Ipv4Address",[t9]:t9,[y.HR](e){return re(e)&&this.value===e.value},[v.HR](){return v.ky(v.kg(rl,0|this.value))},toString(){return rp(this)},toJSON(){return this.toString()},[b.FX](){return this.toJSON()}},ra={_tag:"Ipv6Address",[t9]:t9,[y.HR](e){return!!rt(e)&&this.w0===e.w0&&this.w1===e.w1&&this.w2===e.w2&&this.w3===e.w3},[v.HR](){let e=v.kg(rd,0|this.w0);return e=v.kg(e,0|this.w1),e=v.kg(e,0|this.w2),v.ky(v.kg(e,0|this.w3))},toString(){return rp(this)},toJSON(){return this.toString()},[b.FX](){return this.toJSON()}},rs={_tag:"MacAddress",[t9]:t9,[y.HR](e){let t;return t7(t=e)&&"MacAddress"===t._tag&&ro(this.bytes,e.bytes)},[v.HR](){return v.kg(rc,v.YO(this.bytes))},toString(){return rf(this)},toJSON(){return this.toString()},[b.FX](){return this.toJSON()}},ro=(e,t)=>{if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0},rl=v.Yj("Ipv4Address"),rd=v.Yj("Ipv6Address"),rc=v.Yj("MacAddress"),ru=e=>[e>>>24,e>>>16&255,e>>>8&255,255&e],rf=e=>Array.from(e.bytes,e=>e.toString(16).padStart(2,"0")).join(":"),rp=e=>{if(re(e))return ru(e.value).join(".");let t=(e=>{let{w0:t,w1:r,w2:n,w3:i}=e;return[t>>>16,65535&t,r>>>16,65535&r,n>>>16,65535&n,i>>>16,65535&i]})(e);if(rh(e))return`::ffff:${t[6]>>8}.${255&t[6]}.${t[7]>>8}.${255&t[7]}`;let r=-1,n=0,i=-1;for(let e=0;e<=8;e++)e<8&&0===t[e]?-1===i&&(i=e):-1!==i&&(e-i>n&&(r=i,n=e-i),i=-1);if(n<2)return t.map(e=>e.toString(16)).join(":");let a=t.slice(0,r).map(e=>e.toString(16)).join(":"),s=t.slice(r+n).map(e=>e.toString(16)).join(":");return`${a}::${s}`},rh=e=>{let{w0:t,w1:r,w2:n}=e;return 0===t&&0===r&&65535===n},rm=(y.HR,v.HR,b.FX,y.HR,v.HR,b.FX,e=>{let t=rp(e.address)+(rn(e)&&0!==e.scopeId?`%${e.scopeId}`:"");return rr(e)?`${t}:${e.port}`:`[${t}]:${e.port}`});y.HR,v.HR,b.FX;let rg="~effect/net/IpInterface",ry=e=>(0,k.i5)(e,rg),rv={_tag:"IpInterface",[rg]:rg,[y.HR](e){return ry(e)&&this.prefixLength===e.prefixLength&&y.aI(this.address,e.address)},[v.HR](){return v.kg(v.tW(this.address),v.ai(this.prefixLength))},toString(){return rb(this)},toJSON(){return this.toString()},[b.FX](){return this.toJSON()}},rb=e=>`${rp(e.address)}/${e.prefixLength}`,r_="~effect/net/IpNetwork",rx=e=>(0,k.i5)(e,r_),rw={_tag:"IpNetwork",[r_]:r_,[y.HR](e){return rx(e)&&this.prefixLength===e.prefixLength&&y.aI(this.address,e.address)},[v.HR](){return v.kg(v.tW(this.address),v.ai(this.prefixLength))},toString(){return rk(this)},toJSON(){return this.toString()},[b.FX](){return this.toJSON()}},rk=e=>`${rp(e.address)}/${e.prefixLength}`;function rS(){return(e,t,r)=>rN(new e5.D6(e.map(e5.hu),e=>t(e.map(e=>rN(e))),r))}function rI(e,t){return rS()([],()=>(t,r,n)=>e(t)?eM.PyW(t):eM.fJG(new e6.eE(r,t,n)),t)}function r$(e){return t=>t.rebuild(e5.us(t.ast,e))}G._k,x._k;class rE extends W.rN("SchemaError"){[t6]=t6;constructor(e){let t=(0,t8.jt)();(0,t8.ft)(0);try{super({issue:e})}finally{(0,t8.ft)(t)}}get message(){return e6.EN(this.issue)}toString(){return`SchemaError(${this.message})`}}function rO(e,t){let r=tm(e),n={errors:"all",...t?.parseOptions},i=e6.ID(t),a=e=>{let t=new t$.FG("sync"),a=eM.MY7(eM.YWq(r(e,n),{onFailure:i,onSuccess:e=>({value:e})}),{scheduler:t});a.currentDispatcher?.flush();let s=a.pollUnsafe();return s?tE(s):new Promise(e=>{a.addObserver(t=>{e(tE(t))})})};return"~standard"in e?("validate"in e["~standard"]||Object.assign(e["~standard"],{validate:a}),e):Object.assign(e,{"~standard":{version:1,vendor:"effect",validate:a}})}let rC=function(e){var t;let r,n;return t=e.ast,r=e5.Ax(t),n=e=>{let t;return(t=tb(tv(t_,r)),n=e=>{let r=t(e,e5.vr);return!!eA.oJ(r)||(e3.q(r.cause,"Type guard adapter can only return false for schema issues"),!1)})(e)},e=>n(e)};function rT(e,t){let r=tm(e,t);return(e,t)=>{var n,i;return n=r(e,t),(0,V.OY)(n)?(i=n,eA.oJ(i)?i:eA.AT(z.Tj(i.cause,e=>new rE(e)))):eM.Tyx(n,e=>eM.pVV(()=>z.Tj(e,e=>new rE(e))))}}function rM(e,t){let r,n=(r=tb(tm(e,t)),(e,t)=>{let n=r(e,t);return eA.oJ(n)?ej.Py(n.value):ej.fJ(e3.q(n.cause,"Result adapter can only return schema issues"))});return(e,t)=>ej.xm(n(e,t),e=>new rE(e))}function rA(e,t){let r=rT(e,t);return(e,t)=>(function(e){let t=eM.lKS(e);if(eA.oJ(t))return t.value;throw function(e,t){let r;for(let n of e.reasons){if(!z.lC(n)||!function(e){return k.i5(e,t6)&&e[t6]===t6}(n.error))throw new globalThis.Error(t,{cause:e});r??=n.error}if(void 0===r)throw new globalThis.Error(t,{cause:e});return r}(t.cause,"Sync adapter can only throw schema errors")})(r(e,t))}let rN=tI,rP=e=>rN(e5.Qr(e.ast),{schema:e}),rR=e=>{let t=r1(e);return rN(e5.lq(e.ast),{schema:t})},rj=e=>rN(e5.W(e.ast),{schema:e}),rD=e=>rN(e5.Ax(e.ast),{schema:e}),rU=e=>rN(e5.O3(e.ast),{schema:e});function rF(e){let t=rN(new e5.uS(e),{literal:e,transform:r=>t.pipe(r5(rF(r),{decode:tO.pd(()=>r),encode:tO.pd(()=>e)}))});return t}e5.Zm,e5.bz;let rB=rN(e5.L5),rL=rN(e5.ch),rz=rN(e5.Vx),rW=rN(e5.Yj),rJ=rN(e5.ai),rY=rN(e5.zM),rX=rN(e5.HR);function rq(e,t){return rN(e,{fields:t,mapFields(e,t){let r=e(this.fields);return rq(e5.w3(r,t?.unsafePreserveChecks?this.ast.checks:void 0),r)}})}function rG(e){return rq(e5.w3(e,void 0),e)}function rV(e,t){return rN(e5.g1(e.ast,t.ast),{key:e,value:t})}e5.we,e5.rI,e5.ZG;let rH=e=>rN(new e5.DO(!1,[],[e.ast]),{value:e}),rK=e=>rN(e5.fX(e.ast),{schema:e});function rQ(e,t){return function e(t,r){return rN(t,{members:r,mapMembers(t,r){let n=t(this.members);return e(e5.KC(n,this.ast.options,r?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}(e5.KC(e,t,void 0),e)}function rZ(e){let t=e.map(rF);return rN(e5.KC(t,void 0,void 0),{literals:e,members:t,mapMembers(e){return rQ(e(this.members))},pick:e=>rZ(e),transform:e=>rQ(t.map((t,r)=>t.transform(e[r])))})}let r0=e=>rQ([e,rL]),r1=e=>rQ([e,rz]);function r2(e){return rN(new e5.V3(()=>e().ast))}function r5(e,t){return r=>rN(e5.GL(r.ast,e.ast,t?tC.w8(t):tC.le()),{from:r,to:e})}let r3=rZ(["true","yes","on","1","y"]),r6=rZ(["false","no","off","0","n"]),r8=(rZ([...r3.literals,...r6.literals])).pipe(r5(rY,tC.pd({decode:e=>"true"===e||"yes"===e||"on"===e||"1"===e||"y"===e,encode:e=>e?"true":"false"})));function r9(e){return eM.Tyx(e,e=>eM.pVV(()=>z.Tj(e,e=>e.issue)))}function r4(e,t){let r=t?.encodingStrategy==="omit"?tO.cJ():tO.le();return t=>rP(rU(t)).pipe(r5(t,{decode:tO.IQ(r9(e)),encode:r}))}function r7(e,t){let r=t?.encodingStrategy==="omit"?tO.cJ():tO.le();return t=>rR(rU(t)).pipe(r5(t,{decode:tO.IQ(r9(e)),encode:r}))}function ne(e){var t;return rF(e).pipe((t=eM.PyW(e),e=>rN(e5.Ez(e.ast,t),{schema:e})))}function nt(){return(e,t)=>new e5.N_(e.ast,tC.w8(t))}let nr=e5.HN;function nn(e,t){let r=e.source,n=e.flags,i=/^[dg]*uy?$/.test(n),a=""===n?`new RegExp(${(0,eN.GP)(r)})`:`new RegExp(${(0,eN.GP)(r)}, ${(0,eN.GP)(n)})`;return e5.Pt(e,{toJsonSchema:()=>i?{pattern:n.endsWith("y")?`^(?:${r})`:r}:[{},!0],toCode:()=>({runtime:`Schema.isPattern(${a})`}),...t})}let ni=rN(e5.E2),na=e5.MI;function ns(e){let t=x.OW(e.order),r=e.formatter??eN.GP;return(n,i)=>nr(e=>t(e,n),{expected:`a value greater than or equal to ${r(n)}`,arbitraryConstraint:{order:e.order,minimum:n},...e.annotate?.(n),...i})}function no(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${(0,eN.GP)(e)}`);return e}let nl=(h={order:x.wN,annotate:e=>({representation:{id:"effect/schema/isGreaterThan",payload:{exclusiveMinimum:no(e)}},toJsonSchema:()=>({exclusiveMinimum:e}),toCode:()=>({runtime:`Schema.isGreaterThan(${(0,eN.GP)(e)})`})})},i=x.yJ(h.order),a=h.formatter??eN.GP,(e,t)=>nr(t=>i(t,e),{expected:`a value greater than ${a(e)}`,arbitraryConstraint:{order:h.order,minimum:e,exclusiveMinimum:!0},...h.annotate?.(e),...t})),nd=ns({order:x.wN,annotate:e=>({representation:{id:"effect/schema/isGreaterThanOrEqualTo",payload:{minimum:no(e)}},toJsonSchema:()=>({minimum:e}),toCode:()=>({runtime:`Schema.isGreaterThanOrEqualTo(${(0,eN.GP)(e)})`})})});x.wN;let nc=(m={order:x.wN,annotate:e=>({representation:{id:"effect/schema/isLessThanOrEqualTo",payload:{maximum:no(e)}},toJsonSchema:()=>({maximum:e}),toCode:()=>({runtime:`Schema.isLessThanOrEqualTo(${(0,eN.GP)(e)})`})})},s=x.bi(m.order),o=m.formatter??eN.GP,(e,t)=>nr(t=>s(t,e),{expected:`a value less than or equal to ${o(e)}`,arbitraryConstraint:{order:m.order,maximum:e},...m.annotate?.(e),...t})),nu=(g={order:x.wN,annotate:e=>{let t=!!e.exclusiveMinimum||void 0,r=!!e.exclusiveMaximum||void 0;return{representation:{id:"effect/schema/isBetween",payload:{minimum:no(e.minimum),maximum:no(e.maximum),...t&&{exclusiveMinimum:t},...r&&{exclusiveMaximum:r}}},toJsonSchema:()=>({[t?"exclusiveMinimum":"minimum"]:e.minimum,[r?"exclusiveMaximum":"maximum"]:e.maximum}),toCode:()=>({runtime:`Schema.isBetween({ minimum: ${(0,eN.GP)(e.minimum)}, maximum: ${(0,eN.GP)(e.maximum)}, exclusiveMinimum: ${(0,eN.GP)(t)}, exclusiveMaximum: ${(0,eN.GP)(r)} })`})}}},l=x.OW(g.order),d=x.yJ(g.order),c=x.bi(g.order),u=x.hl(g.order),f=g.formatter??eN.GP,(e,t)=>{let r=e.exclusiveMinimum?d:l,n=e.exclusiveMaximum?u:c;return nr(t=>r(t,e.minimum)&&n(t,e.maximum),{expected:`a value between ${f(e.minimum)}${e.exclusiveMinimum?" (excluded)":""} and ${f(e.maximum)}${e.exclusiveMaximum?" (excluded)":""}`,arbitraryConstraint:{order:g.order,minimum:e.minimum,maximum:e.maximum,...e.exclusiveMinimum&&{exclusiveMinimum:!0},...e.exclusiveMaximum&&{exclusiveMaximum:!0}},...g.annotate?.(e),...t})}),nf=rJ.check(nr(e=>globalThis.Number.isSafeInteger(e),{expected:"an integer",representation:{id:"effect/schema/isInt",payload:null},toJsonSchema:()=>[{type:"integer"},!0],toCode:()=>({runtime:"Schema.isInt()"}),arbitraryConstraint:{number:"integer"}}));function np(e,t){return nh(e=ng(e),Math.ceil(e/2),t)}function nh(e,t,r){return nr(t=>t.length>=e,{expected:`a value with a length of at least ${e}`,representation:{id:"effect/schema/isMinLength",payload:{minLength:e}},toJsonSchema:({type:r})=>"string"===r?e<=1?{minLength:t}:[{minLength:t},!0]:"array"===r?{minItems:e}:void 0===r?[{minLength:t,minItems:e},!0]:[{},!0],toCode:()=>({runtime:`Schema.isMinLength(${e})`}),[e2.C3]:!0,arbitraryConstraint:{minLength:e},...r})}function nm(e,t){return e=ng(e),nr(t=>t.length<=e,{expected:`a value with a length of at most ${e}`,representation:{id:"effect/schema/isMaxLength",payload:{maxLength:e}},toJsonSchema:({type:t})=>"string"===t?0===e?{maxLength:e}:[{maxLength:e},!0]:"array"===t?{maxItems:e}:void 0===t?[{maxLength:e,maxItems:e},!0]:[{},!0],toCode:()=>({runtime:`Schema.isMaxLength(${e})`}),[e2.C3]:!0,arbitraryConstraint:{maxLength:e},...t})}function ng(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${e}`);return Math.max(0,Math.floor(e))}x.n9,x.n9,x.n9,x.n9,x.n9,x.Qw,x.Qw,x.Qw,x.Qw,x.Qw;let ny=rW.check(nh(1,1,void 0)),nv=[];function nb(e){let t=e?.includeStack===!0|2*(e?.excludeCause===!0),r=nv[t];if(void 0!==r)return r;let n=nD.pipe(r5(rB,tC.sm((e=>{switch(e){case 0:return;case 1:return{includeStack:!0};case 2:return{excludeCause:!0};case 3:return{includeStack:!0,excludeCause:!0}}})(t))));return nv[t]=n,n}let n_=rW.annotate({expected:"a string that will be decoded as a Date"}),nx=rI(e=>e instanceof globalThis.Date&&!globalThis.Number.isNaN(e.getTime()),{representation:{id:"effect/schema/Date",payload:null},toCode:()=>({runtime:"Schema.Date",Type:"globalThis.Date"}),expected:"a valid Date",toCodecJson:()=>nt()(n_,tC.YZ)}),nw=rW.annotate({expected:"a string that will be decoded as JSON",contentMediaType:"application/json"});function nk(e,t){return nw.pipe(r5(e,tC.mj(t)))}tC.R7;let nS=rQ([ni,rX,rW]),nI=rW.annotate({expected:"a base64 encoded string that will be decoded as Uint8Array",format:"byte",contentEncoding:"base64"}),n$=(p=globalThis.Uint8Array,rI(e=>e instanceof p,{representation:{id:"effect/schema/Uint8Array",payload:null},toCode:()=>({runtime:"Schema.Uint8Array",Type:"globalThis.Uint8Array"}),expected:"Uint8Array",toCodecJson:()=>nt()(nI,tC.U0)}));L.yp;q.n$,e=>k.i5(e,eU);let nE=globalThis.Symbol.for("immer-draftable"),nO={};function nC(e,t,r,n,i){var a,s,o;let l,d=(a=r,s=t,o=n,e=>{if(void 0!==l)return l;let t=nT(s),r=r=>r instanceof e||k.i5(r,t),n=new tC.IT(tO.pd(t=>new e(t,{"~payload":{token:nO,value:t}})),tO.le());return l=r5(rN(new e5.D6([a.ast],()=>(e,t,n)=>r(e)?eM.PyW(e):eM.fJG(new e6.eE(t,e,n)),{identifier:s,[e2.py]:([e])=>({isConstructed:r,link:new e5.N_(e,n)}),toCodec:([e])=>new e5.N_(e.ast,n),toEquivalence:([e])=>e,toFormatter:([t])=>r=>`${e.identifier}(${t(r)})`,[e2.I_]:e5.SL(a.ast),...o})),n)(a)}),c=nT(t),u=class extends e{constructor(...[e,t]){let n=t?.["~payload"],i=n?.token===nO?n.value:r.make(e??{},t);super(i,{...t,disableChecks:!0,"~payload":{token:nO,value:i}})}static [tw]=tw;get[c](){return c}static [nE]=!0;static identifier=t;static fields=r.fields;static get ast(){return d(this).ast}static pipe(){return w.tT(this,arguments)}static rebuild(e){return d(this).rebuild(e)}static make(e,t){return th(d(this))(e??{},t)}static makeOption(e,t){return tp(d(this))(e??{},t)}static makeEffect(e,t){return d(this).makeEffect(e??{},t)}static annotate(e){return this.rebuild(e5.fz(this.ast,e))}static annotateKey(e){return this.rebuild(e5.us(this.ast,e))}static check(...e){return this.rebuild(e5.EJ(this.ast,e))}static extend(e){return(t,n)=>{let a=nM(t)?t:rG(t),s={...r.fields,...a.fields},o=e5.w3(s,r.ast.checks,{identifier:e});return nC(this,e,rq(e5.EJ(o,a.ast.checks),s),n,i)}}static mapFields(e,t){return r.mapFields(e,t)}};return void 0!==i&&Object.assign(u.prototype,i(t)),u}function nT(e){return`~effect/Schema/Class/${e}`}function nM(e){return k.i5(e,tw)&&e[tw]===tw}let nA=e=>(t,r)=>{let n=nM(t)?t:rG(t);return nC(W.Xs,e,n,r,e=>({toString(){return`${e}(${(0,eN.GP)({...this})})`}}))},nN=e=>(t,r)=>{let n=nM(t)?t:rG(t);return nC(eH.$D,e,n,r,e=>({name:e}))},nP=e=>(t,r,n)=>{let i=nM(r)?r.mapFields(e=>({_tag:ne(t),...e}),{unsafePreserveChecks:!0}):rG({_tag:ne(t),...r});return nN(e??t)(i,n)};function nR(e,t){var r;let n;return r=function(e,t){let{references:r,representations:n}=function(e,t){let r={},n=new Map,i=new Set,a=new Map,s=new Set;for(let t of e)(function e(t){let r=d(t),n=r.ast;if(r.occurrences++,s.has(r)){r.isRecursive=!0;return}if(!(r.occurrences>1)){switch(s.add(r),function t(r){r?.forEach(r=>{r.annotations?.representation?.schemas?.forEach(t=>e(e5.Ax(t))),"FilterGroup"===r._tag&&t(r.checks)})}(n.checks),n._tag){case"Declaration":case"Arrays":case"Objects":case"Union":n.recur(t=>(e(t),t));break;case"TemplateLiteral":n.parts.forEach(e);break;case"Suspend":e(n.thunk())}s.delete(r)}})(t);let o=t?.referencePolicy??t5;for(let e of a.values())for(let t of e.values()){let e=o({ast:t.ast,occurrences:t.occurrences,identifier:t.identifier});if(void 0!==e){let r=e!==t.identifier&&e.endsWith("_")?"":"_";t.reference=l(e,t,r)}else t.isRecursive&&(t.reference=l(`${t.ast._tag}_`,t,""))}return{representations:eV.Tj(e,e=>c(e)),references:r};function l(e,t,r="_"){let i=e,a=0;for(;n.has(i);){if(n.get(i)===t)return i;i=`${e}${r}${++a}`}return n.set(i,t),i}function d(e){let t=e5.S5(e),r=e5.v1(t),n=e2.KE(t),i=void 0===n?(t!==e?e2.KE(e):void 0)??e2.CD(t):void 0;void 0!==i&&(n=`${i}Encoded`);let s=a.get(r);void 0===s&&(s=new Map,a.set(r,s));let o=s.get(n);return void 0===o&&(o={ast:r,identifier:n,fallback:i,occurrences:0,isRecursive:!1,reference:void 0},s.set(n,o)),o}function c(e){let t=d(e),n=t.ast,a=t.reference;if(void 0!==a){let e,s=void 0===t.identifier?n:void 0!==(e=t.fallback)?e2.CD(n)===e?n:e5.fz(n,{[e2.R4]:e}):a===t.identifier?n:e5.fz(n,{identifier:a});if(!Object.hasOwn(r,a)&&!i.has(a)){i.add(a);let e=u(s);i.delete(a),eP.x(r,a,e)}return{_tag:"Reference",$ref:a}}return u(n)}function u(e){var t;let r=(t=e.checks,t?.map(f)??[]);switch(e._tag){case"Declaration":return{_tag:"Declaration",typeParameters:e.typeParameters.map(e=>c(e)),checks:r,...function(e){if(void 0===e)return;let{representation:t,...r}=e;return{...void 0===t?void 0:{representation:t},...0===Object.keys(r).length?void 0:{annotations:r}}}(e.annotations)};case"Null":case"Undefined":case"Void":case"Never":case"Unknown":case"Any":case"String":case"Boolean":case"Number":case"BigInt":case"Symbol":case"ObjectKeyword":return{_tag:e._tag,checks:r,...t3(e.annotations)};case"Literal":return{_tag:"Literal",literal:e.literal,checks:r,...t3(e.annotations)};case"UniqueSymbol":return{_tag:"UniqueSymbol",symbol:e.symbol,checks:r,...t3(e.annotations)};case"Enum":return{_tag:"Enum",enums:e.enums,checks:r,...t3(e.annotations)};case"TemplateLiteral":return{_tag:"TemplateLiteral",parts:e.parts.map(e=>c(e)),checks:r,...t3(e.annotations)};case"Arrays":return{_tag:"Arrays",elements:e.elements.map(e=>{let t=e5.S5(e),r=t.context?.annotations;return{isOptional:e5.dK(t),type:c(e),...t3(r)}}),rest:e.rest.map(e=>c(e)),checks:r,...t3(e.annotations)};case"Objects":return{_tag:"Objects",propertySignatures:e.propertySignatures.map(e=>{let t=e5.S5(e.type),r=t.context?.annotations;return{name:e.name,type:c(e.type),isOptional:e5.dK(t),isMutable:e5.bV(t),...t3(r)}}),indexSignatures:e.indexSignatures.map(e=>({parameter:c(e.parameter),type:c(e.type)})),checks:r,...t3(e.annotations)};case"Union":return{_tag:"Union",types:e.types.map(e=>c(e)),...void 0===e.options?{}:{options:e.options},checks:r,...t3(e.annotations)};case"Suspend":return{_tag:"Suspend",checks:[],thunk:c(e.thunk()),...t3(e.annotations)}}}function f(e){switch(e._tag){case"Filter":return{_tag:"Filter",aborted:e.aborted,...p(e.annotations)};case"FilterGroup":return{_tag:"FilterGroup",checks:eV.Tj(e.checks,f),...p(e.annotations)}}}function p(e){if(void 0===e)return;let{representation:t,...r}=e,n=void 0===t?void 0:void 0===t.schemas?t:{...t,schemas:t.schemas.map(e=>c(e5.Ax(e)))};return{...void 0===n?void 0:{representation:n},...0===Object.keys(r).length?void 0:{annotations:r}}}}([e],t);return{representation:n[0],references:r}}(tT(e.ast),t),{dialect:(n=function(e,t,r,n){let i=new Map,a=new Map,s=new WeakMap,o=new Map,l=new Map,d=Object.keys(r);for(let e of d)h(e,["references",e]);let c=eV.Tj(e,(e,r)=>g(e,t[r],[]));for(let[e,t]of o.values())if(!t1(e))for(let e of t)Array.isArray(e.oneOf)&&(e.anyOf=e.oneOf,delete e.oneOf);for(let e of d){let t=function(e){if("Reference"===e._tag)return;let t=0===e.checks.length?e.annotations:e.checks[e.checks.length-1].annotations;return"string"!=typeof t?.identifier&&"string"==typeof t?.[e2.R4]?t[e2.R4]:void 0}(r[e]);if(void 0===t)continue;let n=i.get(e)[0],s=l.get(t),o=s?.find(e=>y.aI(i.get(e)[0],n));void 0===o?void 0===s?l.set(t,[e]):s.push(e):a.set(e,o)}let u=eV.Tj(c,m),f={};for(let e of d)a.has(e)||eP.x(f,e,m(i.get(e)[0]));return{dialect:"draft-2020-12",schemas:u,definitions:f};function p(e){return Array.isArray(e.oneOf)&&o.get(e.oneOf)?.[1].push(e),e}function h(e,t){if(!Object.hasOwn(r,e))throw tY(`Invalid reference ${e}`,[...t,"$ref"]);let n=i.get(e);if(void 0!==n)return n;let a=[{},[]];return i.set(e,a),a[0]=g(r[e],["references",e],a[1]),a}function m(e){var t,r;return t=e=>{let t=function(e){if(0===e.length||"#"===e)return"";if(!e.startsWith("#"))return;let t=e.slice(1);try{if(encodeURI(t).replace(/%25/g,"%").replace(/#/g,"%23")!==t)return;let e=decodeURIComponent(t);return e.startsWith("/")&&!/~(?:[^01]|$)/.test(e)?e:void 0}catch{return}}(e);if(void 0===t){if(/^#(?:\/|%2f)/i.test(e))throw Error(`Invalid JSON Pointer URI fragment ${JSON.stringify(e)}`);return e}if(!t.startsWith("/$defs/"))return e;let r=t.indexOf("/",7),n=a.get(t.slice(7,r<0?void 0:r).replace(/~1/g,"/").replace(/~0/g,"~"));return void 0===n?e:e.replace(/^#(?:\/|%2f).*?(?:\/|%2f).*?(?=\/|%2f|$)/i,tX(n))},r=e=>{var r,n;r=e,n=t,"string"==typeof r.$ref&&eP.x(r,"$ref",n(r.$ref,"$ref")),"string"==typeof r.$dynamicRef&&eP.x(r,"$dynamicRef",n(r.$dynamicRef,"$dynamicRef"))},function e(t,n,i=!1){var a;if(!k.Gv(t))return t;let s=n||!i&&"string"==typeof(a=t.$id)&&a.length>0&&"#"!==a[0],o={};for(let r of Object.keys(t)){let n=t[r],i=n;switch(r){case"$defs":case"properties":case"patternProperties":case"dependentSchemas":i=function(e,t){if(!k.Gv(e))return;let r={};for(let n of Object.keys(e))eP.x(r,n,t(e[n],n));return r}(n,t=>e(t,s))??n;break;case"allOf":case"anyOf":case"oneOf":case"prefixItems":i=Array.isArray(n)?n.map(t=>e(t,s)):n;break;case"not":case"additionalProperties":case"propertyNames":case"unevaluatedProperties":case"items":case"contains":case"unevaluatedItems":case"if":case"then":case"else":case"contentSchema":i=e(n,s)}eP.x(o,r,i)}return r(o),o}(e,!1,!0)}function g(e,t,i){if("Reference"===e._tag)return i.push(h(e.$ref,t)[1]),{$ref:tX(e.$ref)};let a=s.get(e);if(void 0!==a)return i.push(a[1]),a[0];let l=[];i.push(l);let d=function(e,t,i){switch(e._tag){case"Any":case"Unknown":return{};case"ObjectKeyword":return{anyOf:[{type:"object"},{type:"array"}]};case"Void":case"Undefined":case"Null":return{type:"null"};case"BigInt":return{type:"string",allOf:[{pattern:"^-?\\d+$"}]};case"Symbol":return{type:"string",allOf:[{pattern:"^Symbol\\(([\\s\\S]*)\\)$"}]};case"UniqueSymbol":return void 0===globalThis.Symbol.keyFor(e.symbol)?{not:{}}:{type:"string",enum:[globalThis.String(e.symbol)]};case"Declaration":return i.push(!1),{};case"Suspend":return g(e.thunk,[...t,"thunk"],i);case"Never":return{not:{}};case"String":return{type:"string"};case"Number":return{anyOf:[{type:"number"},{type:"string",enum:["NaN","Infinity","-Infinity"]}]};case"Boolean":return{type:"boolean"};case"Literal":{let t=e.literal;return"bigint"==typeof t?{type:"string",enum:[globalThis.String(t)]}:{type:typeof t,enum:[t]}}case"Enum":{let r=e.enums.map(([e,r],n)=>{if("number"==typeof r&&!globalThis.Number.isFinite(r))throw tY(`Invalid numeric enum value ${globalThis.String(r)}`,[...t,"enums",n,1]);return{type:typeof r,enum:[r],title:e}});return 0===r.length?{not:{}}:{anyOf:r}}case"TemplateLiteral":return{type:"string",pattern:`^${e.parts.map(t2).join("")}$`};case"Arrays":{if(e.rest.length>1)throw tY("Invalid schema representation document",[...t,"rest"]);let r={type:"array"},a=e.elements.length,s=e.elements.map((e,r)=>{e.isOptional&&a--;let s=g(e.type,[...t,"elements",r,"type"],i),o=tG(e.annotations,n);return void 0===o?s:p(t0(s,o))});if(s.length>0?(r.prefixItems=s,r.maxItems=e.elements.length,a>0&&(r.minItems=a)):r.items=!1,1===e.rest.length){delete r.maxItems;let n=g(e.rest[0],[...t,"rest",0],i);Object.keys(n).length>0?r.items=n:delete r.items}return r}case"Objects":{if(0===e.propertySignatures.length&&0===e.indexSignatures.length)return{not:{type:"null"}};let a={type:"object"},s={},o=[];for(let r=0;r<e.propertySignatures.length;r++){let a=e.propertySignatures[r];if("string"!=typeof a.name)throw tY("Invalid schema representation document",[...t,"propertySignatures",r,"name"]);let l=a.name,d=g(a.type,[...t,"propertySignatures",r,"type"],i),c=tG(a.annotations,n);eP.x(s,l,void 0===c?d:p(t0(d,c))),a.isOptional||o.push(l)}e.propertySignatures.length>0&&(a.properties=s),o.length>0&&(a.required=o);let l={},d=[],c=[],u=!1;for(let n=0;n<e.indexSignatures.length;n++){let a=e.indexSignatures[n],s=g(a.type,[...t,"indexSignatures",n,"type"],i);y.aI(s,{not:{}})&&(s=!1),c.push(s);let o=function e(t,n,i){switch(t._tag){case"Reference":{if(!Object.hasOwn(r,t.$ref))throw tY(`Invalid reference ${t.$ref}`,[...n,"$ref"]);if(h(t.$ref,n),i.has(t.$ref))return;let a=new Set(i).add(t.$ref);return e(r[t.$ref],["references",t.$ref],a)}case"String":{if(0===t.checks.length)return[];if(1!==t.checks.length||"Filter"!==t.checks[0]._tag||t.checks[0].annotations?.toJsonSchema===void 0)return;let e=[],r=g(t,n,e);if(!t1(e))return;return"string"===r.type&&"string"==typeof r.pattern&&tH(r,"|type|pattern|title|description|default|examples|readOnly|writeOnly|")?[r.pattern]:void 0}case"TemplateLiteral":return 0===t.checks.length?[`^${t.parts.map(t2).join("")}$`]:void 0;case"Union":{if(0===t.types.length||t.checks.length>0||t.options?.mode==="oneOf")return;let r=[];for(let a=0;a<t.types.length;a++){let s=e(t.types[a],[...n,"types",a],i);if(void 0===s)return;if(0===s.length)return[];r.push(...s)}return r}default:throw tY("Invalid schema representation document",n)}}(a.parameter,[...t,"indexSignatures",n,"parameter"],new Set);if(void 0===o){u=!0,i.push(!1);continue}if(0===o.length)d.push(s);else for(let e of o){let t=l[e];eP.x(l,e,void 0===t?s:!1!==t&&!1!==s&&p(t0(t,s)))}}let f=Object.keys(l).length>0;if(f&&(a.patternProperties=l),u&&n?.onExcessProperty==="error"){let r=[];e.propertySignatures.length>0&&r.push({enum:Object.keys(s)});for(let n=0;n<e.indexSignatures.length;n++)r.push(g(e.indexSignatures[n].parameter,[...t,"indexSignatures",n,"parameter"],i));a.propertyNames=1===r.length?r[0]:{anyOf:r},a.additionalProperties=1===c.length?c[0]:{anyOf:c},d.length>0&&(a.allOf=d.map(e=>({type:"object",additionalProperties:e})))}else 0===d.length?a.additionalProperties=u||n?.onExcessProperty!=="error":1!==d.length||0!==e.propertySignatures.length||f?d.length>0&&(a.allOf=d.map(e=>({type:"object",additionalProperties:e}))):a.additionalProperties=d[0];return"object"==typeof a.additionalProperties&&null!==a.additionalProperties&&0===Object.keys(a.additionalProperties).length&&delete a.additionalProperties,a}case"Union":{let r=[],n=e.types.map((e,n)=>g(e,[...t,"types",n],r));if(i.push(r),0===n.length)return{not:{}};let a=e.options?.mode??"anyOf";if("anyOf"===a&&n.length>1){let e=function(e){let t,r=[];for(let n of e){if(2!==Object.keys(n).length||void 0===n.type||!Array.isArray(n.enum)||0===n.enum.length)return;if(void 0===t)t=n.type;else if(n.type!==t)return;for(let e of n.enum){if(r.includes(e))return;r.push(e)}}return{type:t,enum:r}}(n);if(void 0!==e)return e}return"oneOf"===a&&o.set(n,[r,[]]),{[a]:n}}}}(e,t,l),c=tG(e.annotations,n);void 0!==c&&(d={...d,...c});for(let r=0;r<e.checks.length;r++){var u;let i="string"==typeof d.type&&("string"===(u=d.type)||"number"===u||"boolean"===u||"array"===u||"object"===u||"null"===u||"integer"===u)?d.type:void 0,a=function e(t,r,i,a){let s=t.annotations,o=s?.toJsonSchema;if(void 0!==o){let e=o({type:r,schemas:t.representation?.schemas?.map((e,t)=>g(e,[...i,"representation","schemas",t],a))??[]}),l=Array.isArray(e);l&&a.push(!1);let d=l?e[0]:e,c=tG(s,n),u=void 0===c?d:{...d,...c},f=void 0===c?tV:tZ;return[u,!!("Filter"===t._tag&&tH(u,f)&&(void 0===c||tH(c,tQ)))||void 0]}if("Filter"===t._tag)return void a.push(!1);let l=t.checks.flatMap((t,n)=>{let s=e(t,r,[...i,"checks",n],a);return void 0===s?[]:[s[0]]});if(0===l.length)return;let d=tG(s,n),c={allOf:l};return[void 0===d?c:{...c,...d}]}(e.checks[r],i,[...t,"checks",r],l);void 0!==a&&(d=t0(d,...a))}return s.set(e,[d,l]),p(d)}}([r.representation],[["representation"]],r.references,t)).dialect,schema:n.schemas[0],definitions:n.definitions}}let nj=function(e){return tI(tL(e.ast),{schema:e})},nD=rN(e5.fz(e5.LM,{toCode:()=>({runtime:"Schema.Json",Type:"Schema.Json"})}));e5.BF},2109(e,t,r){var n=r(664),i=r(719),a=r(2842),s=r(6526),o=r(1958),l=r(1594),d=r(6297),c=r(2275),u=r(2840),f=r(8253),p=r(587),h=r(2449),m=r(1554),g=r(4233),y=r(2981),v=r(7086),b=r(7268);function _(e){return t=>t._tag===e}let x=_("Declaration"),w=_("Never"),k=_("String"),S=_("Number"),I=_("Boolean"),$=_("Literal"),E=_("UniqueSymbol"),O=_("Arrays"),C=_("Objects"),T=_("Union"),M=_("Suspend"),A=class{to;transformation;constructor(e,t){this.to=e,this.transformation=t}},N={},P=class{isOptional;isMutable;constructorDefault;annotations;constructor(e,t,r,n){this.isOptional=e,this.isMutable=t,this.constructorDefault=r,this.annotations=n}},R="~effect/Schema";class j{[R]=R;annotations;checks;encoding;context;constructor(e,t,r,n){this.annotations=e,this.checks=t,this.encoding=r,this.context=n}toString(){return`<${this._tag}>`}}let D=class extends j{_tag="Declaration";typeParameters;run;encodingChecks;encodingRun;constructor(e,t,r,n,i,a,s,o){super(r,n,i,a),this.typeParameters=e,this.run=t,this.encodingChecks=s,this.encodingRun=o}getParser(){let e;return(t,r)=>t===p.LO?p.r2:(e??=this.run(this.typeParameters))(t,this,r)}_rebuild(e,t,r,n,i){let a=e1(this.typeParameters,e);return a===this.typeParameters&&t===this.checks&&r===this.encodingChecks&&n===this.run&&i===this.encodingRun?this:new D(a,n,this.annotations,t,void 0,this.context,r,i)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks,this.run,this.encodingRun)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks,this.encodingRun??this.run,this.run)}getExpected(){let e=this.annotations?.expected;return"string"==typeof e?e:"<Declaration>"}},U=new class extends j{_tag="Null";getParser(){return ts(this,null)}getExpected(){return"null"}},F=class extends j{_tag="Undefined";getParser(){return ts(this,void 0)}toCodecJson(){return eJ(this,[B])}getExpected(){return"undefined"}},B=new A(U,new b.IT(y.pd(()=>void 0),y.pd(()=>null))),L=new F,z=new class extends j{_tag="Void";getParser(){let e=p.Py(void 0);return t=>t===p.LO?p.r2:e}toCodecJson(){return eJ(this,[B])}getExpected(){return"void"}},W=new class extends j{_tag="Never";getParser(){return to(this,g.Pd)}getExpected(){return"never"}},J=new class extends j{_tag="Any";getParser(){return to(this,g.t8)}getExpected(){return"any"}},Y=new class extends j{_tag="Unknown";getParser(){return to(this,g.t8)}getExpected(){return"unknown"}},X=new class extends j{_tag="ObjectKeyword";getParser(){return to(this,g.Fw)}getExpected(){return"object | array | function"}},q=class extends j{_tag="Literal";literal;constructor(e,t,r,n,i){if(super(t,r,n,i),"number"==typeof e&&!globalThis.Number.isFinite(e))throw Error(`A numeric literal must be finite, got ${(0,o.GP)(e)}`);this.literal=e}getParser(){return ts(this,this.literal)}matchPart(e,t){return e===globalThis.String(this.literal)?this.literal:void 0}toCodecJson(){return"bigint"==typeof this.literal?G(this):this}toCodecStringTree(){return"string"==typeof this.literal?this:G(this)}getExpected(){return"string"==typeof this.literal?JSON.stringify(this.literal):globalThis.String(this.literal)}};function G(e){let t=globalThis.String(e.literal);return eJ(e,[new A(new q(t),new b.IT(y.pd(()=>e.literal),y.pd(()=>t)))])}let V=new class extends j{_tag="String";getParser(){return to(this,g.Kg)}matchPart(e,t){let r=this.checks;return r&&!t.disableChecks&&tx(r,e,void 0,this,t)?void 0:e}getExpected(){return"string"}};function H(e,t){return e.some(e=>e.annotations?.representation?.id===t||"FilterGroup"===e._tag&&H(e.checks,t))}let K=new class extends j{_tag="Number";getParser(){return to(this,g.Et)}matchKey(e,t){return this._match(tf,e,t)}matchPart(e,t){return this._match(tu,e,t)}_match(e,t,r){if(!e.test(t))return;let n=globalThis.Number(t);return r.disableChecks||!this.checks?n:tx(this.checks,n,void 0,this,r)?void 0:n}toCodecJson(){return this.checks&&(H(this.checks,"effect/schema/isFinite")||H(this.checks,"effect/schema/isInt"))?this:eJ(this,[eF])}toCodecStringTree(){return this.toCodecJson()===this?eJ(this,[th]):eJ(this,[tm])}getExpected(){return"number"}},Q=new class extends j{_tag="Boolean";getParser(){return to(this,g.Lm)}getExpected(){return"boolean"}},Z=new class extends j{_tag="Symbol";getParser(){return to(this,g.Bm)}matchKey(e,t){return t.disableChecks||!this.checks?e:tx(this.checks,e,void 0,this,t)?void 0:e}toCodecStringTree(){return eJ(this,[t_])}getExpected(){return"symbol"}},ee=new class extends j{_tag="BigInt";getParser(){return to(this,g.sI)}matchPart(e,t){if(!tg.test(e))return;let r=globalThis.BigInt(e);return t.disableChecks||!this.checks?r:tx(this.checks,r,void 0,this,t)?void 0:r}toCodecStringTree(){return eJ(this,[tv])}getExpected(){return"bigint"}},et=class extends j{_tag="Arrays";isMutable;elements;rest;encodingChecks;constructor(e,t,r,n,i,a,s,o){super(n,i,a,s),this.isMutable=e,this.elements=t,this.rest=r,this.encodingChecks=o;let l=!1;for(let e=0;e<t.length;e++)if(tt(t[e]))l=!0;else if(l)throw Error("A required element cannot follow an optional element. ts(1257)");if(l&&r.length>1)throw Error("A required element cannot follow an optional element. ts(1257)");for(let e=1;e<r.length;e++)if(tt(r[e]))throw Error("An optional element cannot follow a rest element. ts(1266)")}getParser(e,t=e){let r,n,i=this,s=i.elements.length,o=Math.max(0,i.rest.length-1);function l(e,t){return t<s?r[t]:t>=e?n[t-e+1]:n[0]}let c=e=>{let{input:t,len:r,options:n}=e;if(0===i.rest.length&&r>s)for(let o=s;o<r;o++){let r=new v.vF(i,t[o],n),s=new v.gm([o],r);if("all"!==n.errors)return a.fJG(new v.eC(i,[s],t,n));e.issues?e.issues.push(s):e.issues=[s]}return e.issues?a.fJG(new v.eC(i,e.issues,t,n)):p.Py(e.output)},u=(e,t)=>{let r=e.length,n={ast:i,getParser:l,input:e,len:r,tailThreshold:Math.max(s,r-o),output:new globalThis.Array(r),issues:void 0,options:t},f=0===i.rest.length?s:Math.max(r,s+o),p=void 0===t.concurrency?1:(0,d.Akf)(t.concurrency),h=1===p?en(n,e,0,f):ei(n,e,{concurrency:p,end:f});if(!h)return c(n);if((0,d.OY)(h))return a.Ab9(h,()=>c(n));let m=!0;return a.DYE(()=>m?(m=!1,a.qIB(h,()=>c(n))):u(e,t))};return(e,s)=>{if(e===p.LO)return p.r2;try{if(!Array.isArray(e))return a.fJG(new v.eE(i,e,s));return r||(r=i.elements.map(e=>({ast:e,parser:t(e)})),n=i.rest.map(e=>({ast:e,parser:t(e)}))),u(e,s)}catch(e){return a.F_Q(e)}}}_rebuild(e,t,r){let n=e1(this.elements,e),i=e1(this.rest,e);return n===this.elements&&i===this.rest&&t===this.checks&&r===this.encodingChecks?this:new et(this.isMutable,n,i,this.annotations,t,void 0,this.context,r)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}getExpected(){return"array"}},er={onItem(e,t,r){let n=r<e.len?t:p.LO;return e.getParser(e.tailThreshold,r).parser(n,e.options)},step:function(e,t,r,n){if("Failure"===r._tag)return ea(e,e.ast,n,r);let i=r===p.Rr?t:r[h.a2];if(i!==p.LO)e.output[n]=i;else{let t=e.getParser(e.tailThreshold,n);if(tt(t.ast))return;let r=new v.gm([n],new v.Mw(t.ast.context?.annotations));if("all"!==e.options.errors)return s.fJ(new v.eC(e.ast,[r],e.input,e.options));e.issues?e.issues.push(r):e.issues=[r]}}},en=(0,d.h$X)()(er),ei=(0,d.U1p)()(er),ea=(e,t,r,n)=>{if(0===n.cause.reasons.length)return n;let a=f.R(n.cause);if(void 0===a)return s.AT(i.Tj(n.cause,n=>new v.eC(t,[new v.gm([r],n)],e.input,e.options)));let o=new v.gm([r],a);if("all"!==e.options.errors)return s.fJ(new v.eC(t,[o],e.input,e.options));e.issues?e.issues.push(o):e.issues=[o]},es="[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?";function eo(e,t,r=N){let n,i;return function t(a){switch(a._tag){case"String":case"TemplateLiteral":return(n??=Object.keys(e)).filter(e=>void 0!==a.matchPart(e,r));case"Number":return(n??=Object.keys(e)).filter(e=>void 0!==a.matchKey(e,r));case"Symbol":return(i??=Object.getOwnPropertySymbols(e)).filter(t=>Object.prototype.propertyIsEnumerable.call(e,t)&&void 0!==a.matchKey(t,r));case"Union":return[...new Set(a.types.flatMap(t))];default:return[]}}(tl(ti(t)))}let el=class{name;type;constructor(e,t){this.name=e,this.type=t}},ed=class{parameter;type;constructor(e,t){if(!(function e(t){switch(t._tag){case"String":case"Number":case"Symbol":case"TemplateLiteral":return!0;case"Union":return t.types.every(e);default:return!1}}(e)&&function e(t){let r=eX(t);switch(r._tag){case"String":case"Number":case"Symbol":case"TemplateLiteral":return!0;case"Union":return r.types.every(e);default:return!1}}(e)))throw Error(`Invalid index signature parameter ${e._tag}`);if(this.parameter=e,this.type=t,tt(t)&&!function e(t){switch(t._tag){case"Undefined":return!0;case"Union":return t.types.some(e);default:return!1}}(t))throw Error("Cannot use `Schema.optionalKey` with index signatures, use `Schema.optional` instead.")}},ec=class extends j{_tag="Objects";propertySignatures;indexSignatures;encodingChecks;constructor(e,t,r,n,i,a,s){super(r,n,i,a),this.propertySignatures=e,this.indexSignatures=t,this.encodingChecks=s}getParser(e,t=e){let r,i,o,l=this,u=l.propertySignatures.length,f=l.indexSignatures.length;if(!u&&!f)return to(l,g.Vq);let m=()=>(r||(r=l.propertySignatures.map(e=>({parser:t(e.type),name:e.name,type:e.type})),i=f?l.indexSignatures.map(r=>({is:r,parserKey:e(tl(r.parameter)),parserValue:t(r.type)})):void 0),r),y=()=>{let e=new Set(l.propertySignatures.map(e=>"number"==typeof e.name?globalThis.String(e.name):e.name)),t=(t,r,n,i,a)=>{if("Failure"===a._tag)return ea(t,l,r,a)??s.rI;let o=a===p.Rr?i:a[h.a2];if(n!==p.LO&&o!==p.LO){if(u&&(e.has(r)||e.has("number"==typeof n?globalThis.String(n):n)))return s.rI;c.x(t.out,n,o)}return s.rI},o=(e,r,n,i)=>{if(!i){let t=n.parserKey(r,e.options);if(!(0,d.OY)(t))return a.qIB(a.NS5(t),t=>o(e,r,n,t));i=t}if("Failure"===i._tag)return ea(e,l,r,i)??s.rI;let c=i===p.Rr?r:i[h.a2],u=e.input[r],f=n.parserValue(u,e.options);return(0,d.OY)(f)?t(e,r,c,u,f):a.qIB(a.NS5(f),n=>t(e,r,c,u,n))},g=(e,r,n)=>{let i=e.input[r],s=n.parserValue(i,e.options);return(0,d.OY)(s)?t(e,r,r,i,s):a.qIB(a.NS5(s),n=>t(e,r,r,i,n))},y=f?(0,d.U1p)()({onItem:(e,[t,r])=>r.is.parameter===V?g(e,t,r):o(e,t,r),step:(e,t,r)=>"Failure"===r._tag?r:void 0}):void 0;return a.vCS(function*(t,s){if(t===p.LO)return p.LO;if(!("object"==typeof t&&null!==t&&!Array.isArray(t)))return yield*a.fJG(new v.eE(l,t,s));m();let c={},h={ast:l,input:t,out:c,issues:void 0,options:s},b="all"===s.errors,_="error"===s.onExcessProperty,x=void 0===s.concurrency?1:(0,d.Akf)(s.concurrency),w=f&&_?l.indexSignatures.map(e=>eo(t,e.parameter,s)):void 0;if(_){let r=w?new Set(e):e;if(w)for(let e of w)for(let t of e)r.add(t);let n=Reflect.ownKeys(t);for(let e=0;e<n.length;e++){let i=n[e];if(!r.has(i)&&Object.prototype.propertyIsEnumerable.call(t,i)){let e=new v.vF(l,t[i],s),r=new v.gm([i],e);if(!b)return yield*a.fJG(new v.eC(l,[r],t,s));h.issues?h.issues.push(r):h.issues=[r];continue}}}if(u){let e=1===x?ep(h,r):eh(h,r,{concurrency:x});e&&(yield*e)}if(f&&1===x)for(let e=0;e<f;e++){let r=i[e],n=r.is.parameter===V?g:o,a=w?.[e]??(r.is.parameter===V?Object.keys(t):eo(t,r.is.parameter,s));for(let e=0;e<a.length;e++){let t=n(h,a[e],r);if((0,d.OY)(t)){if("Failure"===t._tag)return yield*t}else yield*t}}else if(y){let e=n.Ie();for(let r=0;r<f;r++){let n=i[r],a=w?.[r]??(n.is.parameter===V?Object.keys(t):eo(t,n.is.parameter,s));for(let t=0;t<a.length;t++)e.push([a[t],n])}let r=y(h,e,{concurrency:x});r&&(yield*r)}return h.issues?yield*a.fJG(new v.eC(l,h.issues,t,s)):c})};if(f)return y();let b=(e,t,n)=>{let i=r[t];return a.qIB(a.NS5(n),n=>{let s=eu(e,i,n);if(s)return s;let o=()=>p.Py(e.out),l=ep(e,r.slice(t+1));return l?a.Ab9(l,o):o()})};return(e,t)=>{if(e===p.LO)return p.r2;if("all"===t.errors||void 0!==t.onExcessProperty||void 0!==t.concurrency&&1!==(0,d.Akf)(t.concurrency))return(o??=y())(e,t);if(!("object"==typeof e&&null!==e&&!Array.isArray(e)))return a.fJG(new v.eE(l,e,t));let r=m(),n={},i={ast:l,input:e,out:n,issues:void 0,options:t};try{for(let a=0;a<r.length;a++){let s=r[a],o=s.name,l=e$(e,o),u=l?e[o]:p.LO,f=s.parser(u,t);if(!(0,d.OY)(f))return b(i,a,f);if(f===p.Rr){l&&c.x(n,o,u);continue}let h=eu(i,s,f);if(h)return h}}catch(e){return a.F_Q(e)}return p.Py(n)}}_rebuild(e,t,r,n){let i=e1(this.propertySignatures,t=>{let r=e(t.type);return r===t.type?t:new el(t.name,r)}),a=e1(this.indexSignatures,r=>{let n=t(r.parameter),i=e(r.type);return n===r.parameter&&i===r.type?r:new ed(n,i)});return i===this.propertySignatures&&a===this.indexSignatures&&r===this.checks&&n===this.encodingChecks?this:new ec(i,a,this.annotations,r,void 0,this.context,n)}flip(e){return this._rebuild(e,e,this.encodingChecks,this.checks)}recur(e,t=e){return this._rebuild(e,t,this.checks,this.encodingChecks)}getExpected(){return 0===this.propertySignatures.length&&0===this.indexSignatures.length?"object | array":"object"}};function eu(e,t,r){if("Failure"===r._tag)return ea(e,e.ast,t.name,r);if(r===p.Rr)return;let n=r[h.a2];if(n!==p.LO)return void c.x(e.out,t.name,n);if(delete e.out[t.name],!tt(t.type)){let r=new v.gm([t.name],new v.Mw(t.type.context?.annotations));return"all"!==e.options.errors?s.fJ(new v.eC(e.ast,[r],e.input,e.options)):void(e.issues?e.issues.push(r):e.issues=[r])}}let ef={onItem(e,t){if(!e$(e.input,t.name))return t.parser(p.LO,e.options);let r=e.input[t.name];return c.x(e.out,t.name,r),t.parser(r,e.options)},step:eu},ep=(0,d.h$X)()(ef),eh=(0,d.U1p)()(ef);function em(e,t){return e?t?[...e,...t]:e:t}function eg(e,t,r){return new ec(Reflect.ownKeys(e).map(t=>new el(t,e[t].ast)),[],r,t)}function ey(e){return e.ast}function ev(e,t){return new et(!1,e.map(e=>e.ast),[],void 0,t)}function eb(e,t,r){return new eE(e.map(ey),t,void 0,r)}function e_(e){if(e.encoding)throw Error("mutable does not support encodings");return new et(!0,e.elements,e.rest,e.annotations,e.checks,void 0,e.context,e.encodingChecks)}let ex=(0,l.qE)(e=>{for(;;){if(M(e))return Y;let t=e.encoding;if(!t)return e.recur?.(ex,l.D_)??e;if(t.some(e=>"Middleware"===e.transformation._tag&&e.transformation.decode!==l.D_))return Y;e=t[t.length-1].to}});function ew(e){switch(e._tag){default:return[];case"Declaration":{let t=e.annotations?.[u.I_];return Array.isArray(t)?t:[]}case"Objects":return e.propertySignatures.flatMap(e=>{let t=e.type;if(!tt(t)){if($(t))return[{key:e.name,literal:t.literal}];if(E(t))return[{key:e.name,literal:t.symbol}]}return[]});case"Arrays":return e.elements.flatMap((e,t)=>{if(!tt(e)){if($(e))return[{key:t,literal:e.literal}];if(E(e))return[{key:t,literal:e.symbol}]}return[]});case"Union":{if(0===e.types.length)return[];let t=e.types.map(e=>ew(ex(e)));return t[0].filter(e=>t.every(t=>t.some(t=>t.key===e.key&&t.literal===e.literal)))}case"Suspend":return ew(e.thunk())}}let ek=new WeakMap,eS=Object.freeze([]),eI=e=>null===e?"null":Array.isArray(e)?"array":typeof e,e$=(e,t)=>"__proto__"===t?Object.hasOwn(e,t):t in e,eE=class extends j{_tag="Union";types;options;encodingChecks;constructor(e,t,r,n,i,a,s){super(r,n,i,a),this.types=e,this.options=t,this.encodingChecks=s}getParser(e,t){let r,n=this,i=void 0!==t,s=[],o=t=>s[t]??=e(n.types[t]);return(e,t)=>{if(e===p.LO)return p.r2;let s=(r??=function(e){let t,r,n,i=ek.get(e);if(i)return i;let a=0,s=!0,o=[];for(let i=0;i<e.length;i++){let l=ex(e[i]);if(w(l))continue;if($(l)||E(l)){n??=new Map;let e=$(l)?l.literal:l.symbol;o[i]=e;let t=n.get(e);t||n.set(e,t=[]),t.push(i)}else s=!1;let d=ew(l);if(d.length)for(let{key:e,literal:r}of(t??=new Map,a++,d)){let n=t.get(e);n||t.set(e,n=[new Map,new Set]),n[1].add(i);let a=n[0].get(r);a||n[0].set(r,a=new Set),a.add(i)}else for(let e of(r??={},function e(t){switch(t._tag){case"Null":return["null"];case"Undefined":return["undefined"];case"String":case"TemplateLiteral":return["string"];case"Number":return["number"];case"Boolean":return["boolean"];case"Symbol":case"UniqueSymbol":return["symbol"];case"BigInt":return["bigint"];case"Arrays":return["array"];case"ObjectKeyword":return["object","array","function"];case"Objects":return t.propertySignatures.length||t.indexSignatures.length?["object"]:["string","number","boolean","symbol","bigint","object","array","function"];case"Enum":return Array.from(new Set(t.enums.map(([,e])=>typeof e)));case"Literal":return[typeof t.literal];case"Union":return Array.from(new Set(t.types.flatMap(e)));default:return["null","undefined","string","number","boolean","symbol","bigint","object","array","function"]}}(l)))(r[e]??=[]).push(i)}let l={},d=e=>l[e]??=Object.freeze(r?.[e]??eS);if(s&&n)n.forEach(Object.freeze),i=e=>n.get(e)??eS;else if(t?.size!==1||r)if(t){let e;for(let r of t)(!e||r[1][0].size>e[1][0].size)&&r[1][1].size===a&&(e=r);i=(n,i)=>{let a,s=eI(n);if(!g.Fw(n))return d(s);let o=new Set(r?.[s]);if(e){let[t,[r]]=e,l=e$(n,t),c=l?n[t]:void 0;if(l&&(!i||void 0!==c)){let e=r.get(c);if(!e)return d(s);for(let t of e)o.add(t);a=t}}if(void 0===a)for(let[e,[r,a]]of t){let t=e$(n,e),s=t?n[e]:void 0;if(t&&(!i||void 0!==s)){let e=r.get(s);if(e)for(let t of e)o.add(t)}else if(i)for(let e of a)o.add(e)}for(let[e,[r,s]]of t){if(e===a)continue;let t=e$(n,e),l=t?n[e]:void 0;if(t&&(!i||void 0!==l)){let e=r.get(l);for(let t of o)s.has(t)&&!e?.has(t)&&o.delete(t)}}return Array.from(o).sort((e,t)=>e-t)}}else i=e=>{let t=d(eI(e));return n?t.filter(t=>void 0===o[t]||o[t]===e):t};else{let[r,[n]]=t.entries().next().value,a=new Map;for(let[e,t]of n)a.set(e,Object.freeze(Array.from(t)));let s=Object.freeze(e.map((e,t)=>t));i=(e,t)=>{if(g.Fw(e)){let n=e$(e,r)?e[r]:void 0;if(void 0!==n)return a.get(n)??eS;if(t)return s}return eS}}return ek.set(e,i),i}(n.types))(e,i);if(0===s.length)return a.fJG(new v.W(n,[],e,t));if(1===s.length){let r=o(s[0])(e,t);return"Success"===r._tag?r:(0,d.OY)(r)?eO(n,r.cause,e,t):(l=n,c=r,u=e,f=t,a.Tyx(c,e=>eO(l,e,u,f)))}var l,c,u,f,h,m,y=n,b=o,_=s,x=e,k=t;let S={ast:y,parser:b,input:x,out:void 0,successes:y.options?.mode==="oneOf"?[]:void 0,issues:void 0,options:k},I=eC(S,_);if(!I)return S.out?S.out:a.fJG(new v.W(y,S.issues??[],x,k));return h=I,m=S,a.Ab9(h,e=>m.out===p.Rr?a.PyW(m.input):m.out?m.out:a.fJG(new v.W(m.ast,m.issues??[],m.input,m.options)))}}_rebuild(e,t,r){let n=e1(this.types,e);return n===this.types&&t===this.checks&&r===this.encodingChecks?this:new eE(n,this.options,this.annotations,t,void 0,this.context,r)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}matchPart(e,t){for(let r of this.types){let n=r.matchPart(e,t);if(void 0!==n)return n}}getExpected(e){let t=this.annotations?.expected;return"string"==typeof t?t:0===this.types.length?"never":Array.from(new Set(this.types.map(t=>{let r=ti(t);switch(r._tag){case"Arrays":{let t=r.elements.filter($);if(t.length>0)return`${eM(r.isMutable)}[ ${t.map(t=>e(t)+(t.context?.isOptional?"?":"")).join(", ")}, ... ]`;break}case"Objects":{let t=r.propertySignatures.filter(e=>$(e.type));if(t.length>0)return`{ ${t.map(t=>`${eM(t.type.context?.isMutable)}${(0,o._r)(t.name)}${t.type.context?.isOptional?"?":""}: ${e(t.type)}`).join(", ")}, ... }`}}return e(r)}))).join(" | ")}};function eO(e,t,r,n){let i=f.R(t);return i?s.fJ(new v.W(e,[i],r,n)):s.AT(t)}let eC=(0,d.h$X)()({onItem:(e,t)=>e.parser(t)(e.input,e.options),step(e,t,r){if("Failure"===r._tag){let t=f.R(r.cause);if(void 0===t)return r;e.issues?e.issues.push(t):e.issues=[t]}else{if(e.out&&e.successes)return e.successes.push(e.ast.types[t]),s.fJ(new v.E8(e.ast,e.successes,e.input,e.options));if(e.out=r,!e.successes)return s.rI;e.successes.push(e.ast.types[t])}}}),eT=new eE([new q("Infinity"),new q("-Infinity"),new q("NaN")]);function eM(e){return e?"":"readonly "}let eA=class extends j{_tag="Suspend";thunk;constructor(e,t,r,n,i){let a;if(r)throw Error("Cannot add checks to Suspend");super(t,void 0,n,i),this.thunk=()=>a??=e()}getParser(e){let t;return(r,n)=>(t??=e(this.thunk()))(r,n)}recur(e){return new eA(()=>e(this.thunk()),this.annotations,void 0,void 0,this.context)}getExpected(e){return e(this.thunk())}},eN=class extends m.Xs{_tag="Filter";run;annotations;aborted;constructor(e,t,r=!1){super(),this.run=e,this.annotations=t,this.aborted=r}annotate(e){return new eN(this.run,{...this.annotations,...e},this.aborted)}abort(){return new eN(this.run,this.annotations,!0)}and(e,t){return new eP([this,e],t)}},eP=class extends m.Xs{_tag="FilterGroup";checks;annotations;constructor(e,t){super(),this.checks=e,this.annotations=t}annotate(e){return new eP(this.checks,{...this.annotations,...e})}and(e,t){return new eP([this,e],t)}};function eR(e,t,r=!1){return new eN((t,r,n)=>v.PY(r,e(t,r,n),t,n),t,r)}function ej(e,t){return new eN((t,r,n)=>e(t)?void 0:new v.h6(void 0,t,n),t,!0)}function eD(e){return eR(e=>globalThis.Number.isFinite(e),{expected:"a finite number",representation:{id:"effect/schema/isFinite",payload:null},toJsonSchema:()=>({type:"number"}),toCode:()=>({runtime:"Schema.isFinite()"}),arbitraryConstraint:{number:"finite"},...e})}let eU=eV(K,[eD()]),eF=new A(new eE([eU,eT]),new b.IT(y.wN(),y.pd(e=>globalThis.Number.isFinite(e)?e:globalThis.String(e))));function eB(e,t){let r=new globalThis.RegExp(e),n={source:r.source,flags:r.flags};return eR(e=>(r.lastIndex=0,r.test(e)),{expected:`a string matching the RegExp ${n.source}`,representation:{id:"effect/schema/isPattern",payload:n},toJsonSchema:()=>[{},!0],arbitraryConstraint:{patterns:[n]},...t})}let eL=new WeakMap;function ez(e,t){let r=Object.assign(Object.create(Object.getPrototypeOf(e)),e,t);return Reflect.ownKeys(t).every(e=>"context"===e||"encoding"===e)&&eL.set(r,eW(e)),r}function eW(e){let t=eL.get(e);if(void 0!==t)return t;if(void 0===e.encoding)return e;let r=Object.assign(Object.create(Object.getPrototypeOf(e)),e,{encoding:void 0});return eL.set(e,r),r}function eJ(e,t){return e.encoding===t?e:ez(e,{encoding:t})}function eY(e,t){if(e.context===t)return e;let r=eW(e);return r.context===t&&r.encoding===e.encoding?r:ez(e,{context:t})}function eX(e){return e.encoding?eX(e.encoding[e.encoding.length-1].to):e}function eq(e,t){if(e.checks){let r=e.checks[e.checks.length-1];return eG(e,n.BC(e.checks.slice(0,-1),r.annotate(t)))}return ez(e,{annotations:{...e.annotations,...t}})}function eG(e,t){if("Suspend"===e._tag&&t)throw Error("Cannot add checks to Suspend");return e.checks===t?e:ez(e,{checks:t})}function eV(e,t){return eG(e,em(e.checks,t))}function eH(e,t){let r=t(e.to);return r===e.to?e:new A(r,e.transformation)}function eK(e,t){let r=e[e.length-1],i=eH(r,t);return i===r?e:n.BC(e.slice(0,e.length-1),i)}function eQ(e){return t=>t.encoding?eJ(t,eK(t.encoding,e)):t}function eZ(e,t){return eQ(e=>eY(e,t))(e)}function e0(e,t){return(0,l.qE)(function r(n){if(n.encoding){let e=n.encoding[n.encoding.length-1];return t?.stopAt?.(e)?n:eJ(n,eK(n.encoding,r))}return e(n)})}function e1(e,t){let r;for(let n=0;n<e.length;n++){let i=e[n],a=t(i);if(r)r[n]=a;else if(a!==i){r=Array(e.length);for(let t=0;t<n;t++)r[t]=e[t];r[n]=a}}return r??e}function e2(e,t){let r=e.context?new P(e.context.isOptional,e.context.isMutable,e.context.constructorDefault,{...e.context.annotations,...t}):new P(!1,!1,void 0,t);return eY(e,r)}let e5=(0,l.qE)(e=>{let t=e.context?!1===e.context.isOptional?new P(!0,e.context.isMutable,e.context.constructorDefault,e.context.annotations):e.context:new P(!0,!1);return e3(eY(e,t))}),e3=eQ(e5),e6=(0,l.Bj)(e=>e5(new eE([e,L]))),e8=(0,l.qE)(e=>{let t=e.context?!1===e.context.isMutable?new P(e.context.isOptional,!0,e.context.constructorDefault,e.context.annotations):e.context:new P(!1,!0);return e9(eY(e,t))}),e9=eQ(e8);function e4(e,t){let r=e.context?new P(e.context.isOptional,e.context.isMutable,t,e.context.annotations):new P(!1,!1,t);return eY(e,r)}function e7(e,t,r){let n;return n=new A(e,r),eJ(t,t.encoding?[...t.encoding,n]:[n])}function te(e,t){let r,n,{literals:i,parameters:a}=(r=[],n=[],!function e(t){switch(t._tag){case"Literal":g.hL(t.literal)&&!r.includes(t.literal)&&r.push(t.literal);return;case"UniqueSymbol":r.includes(t.symbol)||r.push(t.symbol);return;case"Never":return;case"Union":for(let r=0;r<t.types.length;r++)e(t.types[r]);return;default:n.push(t)}}(e),{literals:r,parameters:n});return new ec(i.map(e=>new el(e,t)),a.map(e=>new ed(e,t)))}function tt(e){return e.context?.isOptional??!1}function tr(e){return e.context?.isMutable??!1}let tn=(0,l.qE)(e=>{let t=eW(e);if(t!==e){let r=tn(t);return r===t&&void 0===e.encoding?e:eY(r,e.context)}let r="recur"in e?e.recur(tn):e;if("encodingChecks"in r&&r.encodingChecks){let t,i,a=(t=!0,"recur"in e&&e.recur(function e(r){return(t=t&&!r.encoding&&!M(r))&&"recur"in r&&r.recur(e),r}),t)?r.encodingChecks:O(r)||C(r)||x(r)&&r.typeParameters.length>0?(i=r.encodingChecks.flatMap(function e(t){return!function e(t){return t.annotations?.[u.C3]===!0||"FilterGroup"===t._tag&&t.checks.every(e)}(t)?"FilterGroup"===t._tag?t.checks.flatMap(e):[]:[t]}),n.CZ(i)?i:void 0):void 0;return ez(r,{encodingChecks:void 0,checks:em(r.checks,a)})}return r}),ti=(0,l.qE)(e=>tn(ta(e))),ta=(0,l.Bj)(e=>{if(e.encoding)return function(e,t){let r=t.length,n=t[r-1],i=[new A(ta(eJ(e,void 0)),t[0].transformation.flip())];for(let e=1;e<r;e++)i.unshift(new A(ta(t[e-1].to),t[e].transformation.flip()));let a=ta(n.to);return a.encoding?eJ(a,[...a.encoding,...i]):eJ(a,i)}(e,e.encoding);let t=eW(e);if(t!==e){let r=ta(t);return r===t?e:eY(r,e.context)}return"flip"in e?e.flip(ta):"recur"in e?e.recur(ta):e});function ts(e,t){let r=0===t?p.Rr:p.Py(t);return(n,i)=>n===p.LO?p.r2:n===t?r:a.fJG(new v.eE(e,n,i))}function to(e,t){return(r,n)=>r===p.LO?p.r2:t(r)?p.Rr:a.fJG(new v.eE(e,r,n))}let tl=e0(e=>{switch(e._tag){default:return e;case"Number":return e.toCodecStringTree();case"Union":return e.recur(tl)}}),td=e0(e=>{switch(e._tag){default:return e;case"Symbol":case"UniqueSymbol":return e.toCodecStringTree();case"Union":return e.recur(td)}}),tc=e0(e=>{switch(e._tag){default:return e;case"Number":case"Literal":case"BigInt":return e.toCodecStringTree();case"Union":return e.recur(tc)}}),tu=new globalThis.RegExp(`^${es}$`),tf=new globalThis.RegExp(`^(?:${es}|Infinity|-Infinity|NaN)$`),tp=eV(V,[eB(tu,{expected:"a string representing a finite number",representation:{id:"effect/schema/isStringFinite",payload:null},toJsonSchema:()=>({pattern:tu.source})})]),th=new A(tp,b.ZK),tm=new A(new eE([tp,eT]),b.ZK),tg=new globalThis.RegExp("^-?\\d+$"),ty=eV(V,[eB(tg,{expected:"a string representing a bigint",representation:{id:"effect/schema/isStringBigInt",payload:null},toJsonSchema:()=>({pattern:tg.source}),expected:"a string representing a bigint"})]),tv=new A(ty,b.R7),tb=new globalThis.RegExp("^Symbol\\(([\\s\\S]*)\\)$"),t_=new A(eV(V,[eB(tb,{expected:"a string representing a symbol",representation:{id:"effect/schema/isStringSymbol",payload:null},toJsonSchema:()=>({pattern:tb.source})})]),new b.IT(y.pd(e=>globalThis.Symbol.for(tb.exec(e)[1])),y.ez((e,t)=>void 0!==globalThis.Symbol.keyFor(e)?a.PyW(globalThis.String(e)):a.fJG(new v.cw({message:"cannot serialize to string, Symbol is not registered"},e,t)))));function tx(e,t,r,n,i){for(let a=0;a<e.length;a++){let s=e[a];if("FilterGroup"===s._tag){if((r=tx(s.checks,t,r,n,i))&&("all"!==i.errors||r[r.length-1].filter.aborted))break}else{let e=s.run(t,n,i);if(e){let n=new v.dJ(s,e,t,i);if(r?r.push(n):r=[n],"all"!==i.errors||s.aborted)break}}}return r}function tw(e){if(!x(e))return;let t=e.annotations?.[u.py];return g.Tn(t)?t(e.typeParameters):void 0}function tk(e){return null===e||"string"==typeof e||"boolean"==typeof e||"number"==typeof e&&globalThis.Number.isFinite(e)}function tS(e){return void 0===e||"string"==typeof e}function tI(e,t){let r=new WeakMap,n=[];e:for(;;){if("object"!=typeof e||null===e){if(!t(e))return!1}else{let t=e,i=r.get(t);if(!1===i)return!1;if(void 0===i){let e=Array.isArray(t);if(!e){let e=Object.getPrototypeOf(t);if(null!==e&&e!==Object.prototype&&null!==Object.getPrototypeOf(e))return!1}r.set(t,!1),n.push({value:t,keys:e?t.length:Object.keys(t),index:0})}}for(;n.length>0;){let t=n[n.length-1],i=t.keys;if("number"==typeof i){if(t.index<i){e=t.value[t.index++];continue e}}else if(t.index<i.length){e=t.value[i[t.index++]];continue e}r.set(t.value,!0),n.pop()}return!0}}function t$(e){return tI(e,tk)}u.hd,u.ip,u.KE,u.DQ,u.Pk;let tE=new D([],()=>(e,t,r)=>t$(e)?p.Rr:a.fJG(new v.eE(t,e,r)),{representation:{id:"effect/schema/Json",payload:null},expected:"JSON value",toCodecJson:()=>void 0,toCodecStringTree:()=>tM}),tO=eq(tE,{representation:{id:"effect/schema/MutableJson",payload:null}}),tC=new A(tE,b.le()),tT=new A(new eE([new et(!1,[],[tE]),new ec([],[new ed(V,tE)])]),b.le()),tM=new A(new D([],()=>(e,t,r)=>tI(e,tS)?p.Rr:a.fJG(new v.eE(t,e,r)),{expected:"StringTree",toCodecStringTree:()=>void 0}),b.le());r.d(t,{B9:()=>e0,D$:()=>ej,EJ:()=>eV,ES:()=>eJ,Ez:()=>e4,Fh:()=>t$,GL:()=>e7,HN:()=>eR,KC:()=>eb,Lp:()=>tx,MI:()=>eD,PV:()=>ev,Pt:()=>eB,Q0:()=>eZ,S5:()=>eX,SL:()=>ew,Td:()=>eH,bV:()=>tr,dK:()=>tt,fX:()=>e_,fz:()=>eq,g1:()=>te,gR:()=>tw,hu:()=>ey,us:()=>e2,v1:()=>eW,w3:()=>eg},{Ax:tn,BF:tO,D6:D,DO:et,E2:eU,Et:S,Gf:tC,HR:Z,Kg:k,L5:Y,LM:tE,Lm:I,N_:A,Nt:ty,O3:ti,Qr:e5,RP:C,UU:ta,V3:eA,Vx:L,W:e8,W5:tT,XV:"[\\s\\S]*?",Yj:V,ZG:X,Zm:W,ai:K,bm:es,bz:J,c$:$,ch:U,gP:eE,lq:e6,mi:T,ob:P,rI:z,tC:tM,tF:O,uS:q,vr:N,we:ee,xw:td,zM:Q})},2981(e,t,r){r.d(t,{Qw:()=>O,n9:()=>C,wN:()=>E,Qf:()=>$,y4:()=>R,$T:()=>j,$X:()=>D,UD:()=>U,EF:()=>F,xQ:()=>B,mF:()=>z,WG:()=>A,DX:()=>N,mU:()=>P,_p:()=>L,J5:()=>v,cJ:()=>S,qF:()=>T,le:()=>_,sd:()=>M,pd:()=>x,ez:()=>w,IQ:()=>I});var n,i,a=r(2842),s=r(2997),o=r(9315),l=r(9913);let d=e=>s.lF(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_"),c=e=>{let t=e.replace(/[\n\r]/g,""),r=t.length;if(r%4==1)return o.fJ(new l.Ug({module:"Base64Url",kind:"Decode",input:t,message:`Length should be a multiple of 4, but is ${r}`}));if(!/^[-_A-Z0-9]*?={0,2}$/i.test(t))return o.fJ(new l.Ug({module:"Base64Url",kind:"Decode",input:t,message:"Invalid input"}));let n=r%4==2?`${t}==`:r%4==3?`${t}=`:t;return n=n.replace(/-/g,"+").replace(/_/g,"/"),s.D4(n)},u=new TextDecoder;var f=r(1229),p=r(1587),h=r(1554),m=r(4233),g=r(7086);let y=e=>Object.assign(Object.create(h.bp),e),v=(n=()=>"Encoding is not supported",i=(e,t)=>{let r={message:n()};return p.isSome(e)?new g.cw(r,e.value,t):new g.cw(r)},k((e,t)=>a.fJG(i(e,t)))),b=y({_tag:"Passthrough"});function _(){return b}function x(e){return y({_tag:"Transform",transform:e})}function w(e){return y({_tag:"TransformEffect",transform:e})}function k(e){return y({_tag:"TransformOptionalEffect",transform:e})}function S(){return y({_tag:"TransformOptional",transform:()=>p.none()})}function I(e){return k(t=>{let r=p.filter(t,m.EA);return p.isSome(r)?a.PyW(r):a.jkJ(e,p.some)})}function $(){return x(globalThis.String)}function E(){return x(globalThis.Number)}function O(){return x(globalThis.BigInt)}function C(){return x(e=>new globalThis.Date(e))}function T(e){return w((t,r)=>a.SvU({try:()=>JSON.parse(t,e?.reviver),catch:()=>new g.h6({expected:"a valid JSON string"},t,r)}))}function M(e){return w((t,r)=>a.SvU({try:()=>{let r=JSON.stringify(t,e?.replacer,e?.space);if(void 0===r)throw TypeError("Value cannot be represented as JSON");return r},catch:()=>new g.h6({expected:"a JSON-serializable value"},t,r)}))}function A(){return x(s.lF)}function N(){return x(d)}function P(){return x(f.lF)}function R(){return w((e,t)=>a.Z9x(a.yUA(s.D4(e)),()=>new g.h6({expected:"a valid Base64 string"},e,t)))}function j(){return w((e,t)=>o.YW(s.sc(e),{onFailure:()=>a.fJG(new g.h6({expected:"a valid Base64 string"},e,t)),onSuccess:a.PyW}))}function D(){return w((e,t)=>o.YW(c(e),{onFailure:()=>a.fJG(new g.h6({expected:"a valid Base64Url string"},e,t)),onSuccess:a.PyW}))}function U(){return w((e,t)=>o.YW(o.Tj(c(e),e=>u.decode(e)),{onFailure:()=>a.fJG(new g.h6({expected:"a valid Base64Url string"},e,t)),onSuccess:a.PyW}))}function F(){return w((e,t)=>o.YW(f.D4(e),{onFailure:()=>a.fJG(new g.h6({expected:"a valid hexadecimal string"},e,t)),onSuccess:a.PyW}))}function B(){return w((e,t)=>o.YW(f.sc(e),{onFailure:()=>a.fJG(new g.h6({expected:"a valid hexadecimal string"},e,t)),onSuccess:a.PyW}))}function L(){return x(encodeURIComponent)}function z(){return w((e,t)=>{try{return a.PyW(globalThis.decodeURIComponent(e))}catch{return a.fJG(new g.h6({expected:"a valid URI component"},e,t))}})}m.Kg},7086(e,t,r){var n=r(664),i=r(1958),a=r(2840),s=r(587),o=r(4233);let l="~effect/SchemaIssue/Issue";function d(e){return(0,o.i5)(e,l)&&e[l]===l}function c(e){return Object.hasOwn(e,"input")}class u{[l]=l;constructor(e,t){t?.reportInput===!0&&e!==s.LO&&(this.input=e)}}let f=class extends u{_tag="Filter";filter;issue;constructor(e,t,r,n){super(r,n),this.filter=e,this.issue=t}},p=class extends u{_tag="Encoding";ast;issue;constructor(e,t,r,n){super(r,n),this.ast=e,this.issue=t}},h=class extends u{_tag="Pointer";path;issue;constructor(e,t){super(),this.path=e,this.issue=t}},m=class extends u{_tag="MissingKey";annotations;constructor(e){super(),this.annotations=e}},g=class extends u{_tag="UnexpectedKey";ast;constructor(e,t,r){super(t,r),this.ast=e}},y=class extends u{_tag="Composite";ast;issues;constructor(e,t,r,n){super(r,n),this.ast=e,this.issues=t}},v=class extends u{_tag="InvalidType";ast;constructor(e,t,r){super(t,r),this.ast=e}},b=class extends u{_tag="InvalidValue";annotations;constructor(e,t,r){super(t,r),this.annotations=e}},_=class extends u{_tag="Forbidden";annotations;constructor(e,t,r){super(t,r),this.annotations=e}},x=class extends u{_tag="AnyOf";ast;issues;constructor(e,t,r,n){super(r,n),this.ast=e,this.issues=t}},w=class extends u{_tag="OneOf";ast;successes;constructor(e,t,r,n){super(r,n),this.ast=e,this.successes=t}};function k(e,t,r){if(d(e))return e;if("string"==typeof e)return new b({message:e},t,r);let n="string"==typeof e.issue?new b({message:e.issue},t,r):e.issue;return new h(e.path,n)}function S(e,t,r,i){if(Array.isArray(t)){if(!n.ET(t))return;return 1===t.length?k(t[0],r,i):new y(e,n.Tj(t,e=>k(e,r,i)),r,i)}if(void 0!==t)return"boolean"==typeof t?t?void 0:new b(void 0,r,i):k(t,r,i)}let I=e=>{let t=A(e);if(void 0!==t)return t;switch(e._tag){case"InvalidType":return T(a.bo(e.ast),e);case"InvalidValue":{let t=C(e);if(void 0!==t)return T(t,e);let r=O(e);return void 0===r?"Expected a valid value":`Invalid data ${r}`}case"MissingKey":return"Missing key";case"UnexpectedKey":{let t=O(e);return void 0===t?"Expected no excess property":`Unexpected key with value ${t}`}case"Forbidden":return"Forbidden operation";case"OneOf":{let t=O(e);return void 0===t?"Expected exactly one member to match":`Expected exactly one member to match the input ${t}`}}},$=e=>A(e.issue)??A(e);function E(e){return t=>({issues:function e(t,r,n,i){switch(t._tag){case"Filter":{let a=i(t);if(void 0!==a)return[{path:r,message:a}];if("InvalidValue"!==t.issue._tag)return e(t.issue,r,n,i);let s=C(t.issue);return[{path:r,message:void 0===s?T(M(t.filter),t):T(s,t.issue)}]}case"Encoding":return e(t.issue,r,n,i);case"Pointer":return e(t.issue,[...r,...t.path],n,i);case"Composite":return t.issues.flatMap(t=>e(t,r,n,i));case"AnyOf":if(0===t.issues.length)return[{path:r,message:A(t)??T(a.bo(t.ast),t)}];return t.issues.flatMap(t=>e(t,r,n,i));default:return[{path:r,message:n(t)}]}}(t,[],e?.leafHook??I,e?.checkHook??$)})}function O(e){return c(e)?(0,i.GP)(e.input):void 0}function C(e){let t=e.annotations?.expected;return"string"==typeof t?t:void 0}function T(e,t){let r=O(t);return void 0===r?`Expected ${e}`:`Expected ${e}, got ${r}`}function M(e){let t=e.annotations?.expected;if("string"==typeof t)return t;switch(e._tag){case"Filter":return"<filter>";case"FilterGroup":return e.checks.map(e=>M(e)).join(" & ")}}function A(e){if("Pointer"===e._tag)return;if("Encoding"===e._tag)return A(e.issue);let t="Filter"===e._tag?e.filter.annotations:"annotations"in e?e.annotations:e.ast.annotations,r=t?.["MissingKey"===e._tag?"messageMissingKey":"UnexpectedKey"===e._tag?"messageUnexpectedKey":"message"];if("string"==typeof r)return r}r.d(t,{ID:()=>E,PY:()=>S,bZ:()=>c,gh:()=>d},{E8:w,EN:e=>(function e(t,r){let n;switch(t._tag){case"Filter":{let i=$(t);if(void 0!==i)n=i;else{if("InvalidValue"!==t.issue._tag)return e(t.issue,r);let i=C(t.issue);n=void 0===i?T(M(t.filter),t):T(i,t.issue)}break}case"Encoding":return e(t.issue,r);case"Pointer":return e(t.issue,r+(0,i.jV)(t.path));case"Composite":case"AnyOf":if("Composite"===t._tag||t.issues.length>0)return t.issues.map(t=>e(t,r)).join("\n");n=A(t)??T(a.bo(t.ast),t);break;default:n=I(t)}return r?`${n}
236
+ at ${r}`:n})(e,""),Mw:m,VY:$,W:x,Wi:p,cw:_,dJ:f,eC:y,eE:v,gm:h,h6:b,vF:g,vp:I})},7268(e,t,r){var n=r(3265),i=r(2842),a=r(1958),s=r(1587),o=r(1554),l=r(4233),d=r(2981),c=r(7086);let u=class extends o.Xs{_tag="Middleware";decode;encode;constructor(e,t){super(),this.decode=e,this.encode=t}flip(){return new u(this.encode,this.decode)}},f="~effect/SchemaTransformation/Transformation",p=class extends o.Xs{[f]=f;_tag="Transformation";decode;encode;constructor(e,t){super(),this.decode=e,this.encode=t}flip(){return new p(this.encode,this.decode)}};function h(e){return new p(d.ez(e.decode),d.ez(e.encode))}function m(e){return new p(d.pd(e.decode),d.pd(e.encode))}let g=new p(d.le(),d.le());function y(){return g}let v=new p(d.wN(),d.Qf()),b=new p(d.Qw(),d.Qf()),_=new p(d.n9(),d.pd(a.Yq)),x=new p(d.n9(),d.pd(e=>e.getTime())),w=h({decode:(e,t)=>s.match(n.sH(e),{onNone:()=>i.fJG(new c.h6({expected:"a valid ByteSize string"},e,t)),onSome:i.PyW}),encode:e=>i.PyW(`${e} ${e===BigInt(1)?"byte":"bytes"}`)}),k=h({decode:(e,t)=>s.match(n.lX(e),{onNone:()=>i.fJG(new c.h6({expected:"a non-negative bigint byte count"},e,t)),onSome:i.PyW}),encode:e=>i.PyW(n.Dg(e))}),S=h({decode:(e,t)=>s.match(n.lX(e),{onNone:()=>i.fJG(new c.h6({expected:"a non-negative safe-integer byte count"},e,t)),onSome:i.PyW}),encode:(e,t)=>s.match(n.Ro(e),{onNone:()=>i.fJG(new c.h6({expected:"a ByteSize representable as a safe integer"},e,t)),onSome:i.PyW})}),I=e=>{let t;return l.Gv(e)&&"string"==typeof e.message?(t=Object.hasOwn(e,"cause")?Error(e.message,{cause:I(e.cause)}):Error(e.message),"string"==typeof e.name&&"Error"!==e.name&&(t.name=e.name),"string"==typeof e.stack&&(t.stack=e.stack),t):e},$=h({decode:(e,t)=>URL.canParse(e)?i.PyW(new URL(e)):i.fJG(new c.h6({expected:"a valid URL string"},e,t)),encode:e=>i.PyW(e.href)}),E=new p(d.y4(),d.WG()),O=new p(d.$T(),d.WG()),C=new p(d.UD(),d.DX()),T=new p(d.xQ(),d.mU()),M=new p(d.mF(),d._p());function A(e){return new p(d.qF(e??{}),d.sd(e))}r.d(t,{ez:()=>h,le:()=>y,mj:()=>A,pd:()=>m},{$l:k,Ct:O,HO:x,IT:p,LL:C,NX:S,Pe:w,Pp:M,R7:b,U0:E,Y5:T,YZ:_,ZK:v,nY:$,sm:e=>{let t,r;return m({decode:I,encode:(t=new WeakSet,r=n=>{if(l.bJ(n)){var i;let a;if(t.has(n))return"[Circular]";t.add(n);let s=(i=r,a={name:n.name,message:"string"==typeof n.message?n.message:""},e?.includeStack&&"string"==typeof n.stack&&(a.stack=n.stack),e?.excludeCause||void 0===n.cause||(a.cause=i(n.cause)),a);return t.delete(n),s}try{let e=(0,a.IB)(n);return void 0===e?(0,a.GP)(n):JSON.parse(e)}catch{return(0,a.GP)(n)}})})},w8:e=>l.i5(e,f)&&e[f]===f?e:new p(e.decode,e.encode)})},5744(e,t,r){var n=r(6297);n.kWD,n.obm;let i=n.DLK;n.RWE;let a=n.d97,s=n.AAo,o=n.Uio,l=n.iLB;n.Z$R;let d=n.pSt,c=n.vDJ;n.fou,n.mdu,r.d(t,{},{Fp:d,Gt:s,HG:i,LZ:a,U9:l,VN:c,a6:o})},2707(e,t,r){var n=r(1179),i=r(1229),a=r(1594),s=r(1587);let o="effect/Tracer/ParentSpan";class l extends(n.kl())(o,{fiberCached:!0}){}let d=n.Or("effect/Tracer/DisablePropagation",{defaultValue:a.f4}),c=n.Or("effect/Tracer/CurrentTraceLevel",{defaultValue:()=>"Info"}),u=n.Or("effect/Tracer/MinimumTraceLevel",{defaultValue:()=>"All"}),f="effect/Tracer",p=n.Or(f,{fiberCached:!0,defaultValue:()=>h}),h={span:e=>new m(e)};class m{_tag="Span";sampled;name;parent;annotations;links;startTime;kind;status;_traceId=void 0;_spanId=void 0;_attributes=void 0;_events=void 0;constructor(e){this.name=e.name,this.parent=e.parent,this.annotations=e.annotations,this.links=e.links,this.startTime=e.startTime,this.kind=e.kind,this.sampled=e.sampled,this.status={_tag:"Started",startTime:e.startTime}}get traceId(){return this._traceId??=s.getOrUndefined(this.parent)?.traceId??i.yT(32)}get spanId(){return this._spanId??=i.yT(16)}get attributes(){return this._attributes??=new Map}get events(){return this._events??=[]}end(e,t){this.status={_tag:"Ended",endTime:e,exit:t,startTime:this.status.startTime}}attribute(e,t){this.attributes.set(e,t)}event(e,t,r){this.events.push([e,t,r??{}])}addLinks(e){this.links.push(...e)}}r.d(t,{Tv:()=>l,W1:()=>m},{DW:d,EW:u,RL:f,Vv:h,WG:o,pX:c,sh:p})},6481(e,t,r){let n,i;var a=r(5340);class s{constructor(e){this.value=e,this.done=!1}next(e){return this.done?(this.value=e,this):(this.done=!0,{value:this.value,done:!1})}}let o=(i={[n="~effect/Utils/internal"]:e=>e()},0!==(0,a.jt)()&&i[n](()=>Error().stack)?.includes(n)===!0?i[n]:({[n]:e=>e()})[n]);r.d(t,{B:()=>s},{s:o})},2997(e,t,r){var n=r(9315),i=r(9913);let a=e=>{let t=l(e),r=t.length;if(r%4!=0)return n.fJ(new i.Ug({kind:"Decode",module:"Base64",input:t,message:`Length must be a multiple of 4, but is ${r}`}));let a=t.indexOf("=");if(-1!==a&&(a<r-2||a===r-2&&"="!==t[r-1]))return n.fJ(new i.Ug({kind:"Decode",module:"Base64",input:t,message:"Found a '=' character, but it is not at the end"}));try{let e=t.endsWith("==")?2:+!!t.endsWith("="),i=new Uint8Array(r/4*3-e);for(let e=0,n=0;e<r;e+=4,n+=3){let r=u(t.charCodeAt(e))<<18|u(t.charCodeAt(e+1))<<12|u(t.charCodeAt(e+2))<<6|u(t.charCodeAt(e+3));i[n]=r>>16,i[n+1]=r>>8&255,i[n+2]=255&r}return n.Py(i)}catch(e){return n.fJ(new i.Ug({kind:"Decode",module:"Base64",input:t,message:e instanceof Error?e.message:"Invalid input"}))}},s=new TextEncoder,o=new TextDecoder,l=e=>e.replace(/[\n\r]/g,""),d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c=(new Uint8Array(123)).fill(255);for(let e=0;e<d.length;e++)c[d.charCodeAt(e)]=e;c[61]=0;let u=e=>{if(e>=c.length||255===c[e])throw TypeError(`Invalid character ${String.fromCharCode(e)}`);return c[e]};r.d(t,{},{D4:a,lF:e=>(e=>{let t,r=e.length,n="";for(t=2;t<r;t+=3)n+=d[e[t-2]>>2],n+=d[(3&e[t-2])<<4|e[t-1]>>4],n+=d[(15&e[t-1])<<2|e[t]>>6],n+=d[63&e[t]];return t===r+1&&(n+=d[e[t-2]>>2],n+=d[(3&e[t-2])<<4],n+="=="),t===r&&(n+=d[e[t-2]>>2],n+=d[(3&e[t-2])<<4|e[t-1]>>4],n+=d[(15&e[t-1])<<2],n+="="),n})("string"==typeof e?s.encode(e):e),sc:e=>n.Tj(a(e),e=>o.decode(e))})},9913(e,t,r){var n=r(4942);let i="~effect/encoding/EncodingError";class a extends n.rN("EncodingError"){[i]=i}r.d(t,{Ug:()=>a})},1229(e,t,r){var n=r(9315),i=r(9913);let a=Uint8Array.from("0123456789abcdef",e=>e.charCodeAt(0)),s=()=>0x100000000*Math.random()>>>0,o=()=>{let e=s();return String.fromCharCode(a[e>>>28],a[e>>>24&15],a[e>>>20&15],a[e>>>16&15],a[e>>>12&15],a[e>>>8&15],a[e>>>4&15],a[15&e])},l=e=>{let t=new TextEncoder().encode(e);if(t.length%2!=0)return n.fJ(new i.Ug({module:"Hex",kind:"Decode",input:e,message:`Length must be a multiple of 2, but is ${t.length}`}));try{let e=t.length/2,r=new Uint8Array(e);for(let n=0;n<e;n++){let e=p(t[2*n]),i=p(t[2*n+1]);r[n]=e<<4|i}return n.Py(r)}catch(t){return n.fJ(new i.Ug({module:"Hex",kind:"Decode",input:e,message:t instanceof Error?t.message:"Invalid input"}))}},d=new TextEncoder,c=new TextDecoder,u=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0")),f=e=>{let t="";for(let r=0;r<e.length;r++)t+=u[e[r]];return t},p=e=>{if(48<=e&&e<=57)return e-48;if(97<=e&&e<=102)return e-97+10;if(65<=e&&e<=70)return e-65+10;throw TypeError("Invalid input")};r.d(t,{},{D4:l,lF:e=>"string"==typeof e?f(d.encode(e)):f(e),sc:e=>n.Tj(l(e),e=>c.decode(e)),yT:e=>{switch(e){case 16:let t,r;return t=s(),r=s(),String.fromCharCode(a[t>>>28],a[t>>>24&15],a[t>>>20&15],a[t>>>16&15],a[t>>>12&15],a[t>>>8&15],a[t>>>4&15],a[15&t],a[r>>>28],a[r>>>24&15],a[r>>>20&15],a[r>>>16&15],a[r>>>12&15],a[r>>>8&15],a[r>>>4&15],a[15&r]);case 32:let n,i,l,d;return n=s(),i=s(),l=s(),d=s(),String.fromCharCode(a[n>>>28],a[n>>>24&15],a[n>>>20&15],a[n>>>16&15],a[n>>>12&15],a[n>>>8&15],a[n>>>4&15],a[15&n],a[i>>>28],a[i>>>24&15],a[i>>>20&15],a[i>>>16&15],a[i>>>12&15],a[i>>>8&15],a[i>>>4&15],a[15&i],a[l>>>28],a[l>>>24&15],a[l>>>20&15],a[l>>>16&15],a[l>>>12&15],a[l>>>8&15],a[l>>>4&15],a[15&l],a[d>>>28],a[d>>>24&15],a[d>>>20&15],a[d>>>16&15],a[d>>>12&15],a[d>>>8&15],a[d>>>4&15],a[15&d]);default:{let t="";for(let r=e>>>3;r>0;r--)t+=o();return t}}}})},2449(e,t,r){let n;var i=r(3332),a=r(1958),s=r(1594),o=r(5033),l=r(3952),d=r(1554),c=r(4233),u=r(6481),f=r(2275);let p="~effect/Effect",h="~effect/Exit",m={_A:s.D_,_E:s.D_,_R:s.D_},g=`${p}/identifier`,y=`${p}/args`,v=`${p}/evaluate`,b=`${p}/successCont`,_=`${p}/failureCont`,x=`${p}/ensureCont`,w=Symbol.for("effect/Effect/Yield"),k={pipe(){return(0,d.tT)(this,arguments)},toJSON(){return{...this}},toString(){return(0,a.GP)(this.toJSON(),{ignoreToString:!0,space:2})},[l.FX](){return this.toJSON()}},S={[o.HR](){return o.uN(this,Object.keys(this))},[i.HR](e){let t=Object.keys(this),r=Object.keys(e);if(t.length!==r.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!==r[n]||!i.aI(this[t[n]],e[t[n]]))return!1;return!0}},I={[p]:m,...k,[Symbol.iterator](){return new u.B(this)},toJSON(){return{_id:"Effect",op:this[g],...y in this?{args:this[y]}:void 0}}},$=e=>(0,c.i5)(e,h),E="~effect/Cause",O="~effect/Cause/Reason",C=e=>(0,c.i5)(e,E);class T{constructor(e){this[E]=E,this.reasons=e}pipe(){return(0,d.tT)(this,arguments)}toJSON(){return{_id:"Cause",failures:this.reasons.map(e=>e.toJSON())}}toString(){return`Cause(${(0,a.GP)(this.reasons)})`}[l.FX](){return this.toJSON()}[i.HR](e){return C(e)&&this.reasons.length===e.reasons.length&&this.reasons.every((t,r)=>i.aI(t,e.reasons[r]))}[o.HR](){return o.YO(this.reasons)}}let M=new WeakMap;class A{[O];annotations;_tag;constructor(e,t,r){if(this[O]=O,this._tag=e,t!==N&&"object"==typeof r&&null!==r&&t.size>0){let e=M.get(r);e&&(t=new Map([...e,...t])),M.set(r,t)}this.annotations=t}annotate(e,t){if(0===e.mapUnsafe.size)return this;let r=new Map(this.annotations);e.mapUnsafe.forEach((e,n)=>{t?.overwrite!==!0&&r.has(n)||r.set(n,e)});let n=Object.assign(Object.create(Object.getPrototypeOf(this)),this);return n.annotations=r,n}pipe(){return(0,d.tT)(this,arguments)}toString(){return(0,a.GP)(this)}[l.FX](){return this.toString()}}let N=new Map;class P extends A{constructor(e,t=N){super("Fail",t,e),this.error=e}toString(){return`Fail(${(0,a.GP)(this.error)})`}toJSON(){return{_tag:"Fail",error:this.error}}[i.HR](e){return z(e)&&i.aI(this.error,e.error)&&i.aI(this.annotations,e.annotations)}[o.HR](){return o.kg(o.Yj(this._tag))(o.kg(o.tW(this.error))(o.tW(this.annotations)))}}let R=e=>new T(e),j=(0,s.XY)(2,(e,t)=>{if(0===e.reasons.length)return t;if(0===t.reasons.length)return e;let r=new T(((e,t)=>{let r=new Map,n=[];for(let a of e.concat(t)){let e=o.tW(a),t=r.get(e);if(void 0===t)r.set(e,[a]);else{if(t.some(e=>i.aI(e,a)))continue;t.push(a)}n.push(a)}return n})(e.reasons,t.reasons));return i.aI(e,r)?e:r}),D=new T([]),U=e=>new T([new P(e)]);class F extends A{constructor(e,t=N){super("Die",t,e),this.defect=e}toString(){return`Die(${(0,a.GP)(this.defect)})`}toJSON(){return{_tag:"Die",defect:this.defect}}[i.HR](e){return W(e)&&i.aI(this.defect,e.defect)&&i.aI(this.annotations,e.annotations)}[o.HR](){return o.kg(o.Yj(this._tag))(o.kg(o.tW(this.defect))(o.tW(this.annotations)))}}let B=e=>new T([new F(e)]),L=(0,s.XY)(e=>C(e[0]),(e,t,r)=>0===t.mapUnsafe.size?e:new T(e.reasons.map(e=>e.annotate(t,r)))),z=e=>"Fail"===e._tag,W=e=>"Die"===e._tag;function J(e){return Q("Effect.evaluate: Not implemented")}let Y=e=>({...I,[g]:e.op,[v]:e[v]??J,[b]:e[b],[_]:e[_],[x]:e[x]}),X=e=>{let t=Y(e),r=function(e){this[y]=e};return r.prototype=t,function(e){return new r(e)}},q=e=>{let t={[h]:h,_tag:e.op,get[e.prop](){return this[y]},...Y(e),toString(){return`${e.op}(${(0,a.GP)(this[y])})`},toJSON(){return{_id:"Exit",_tag:e.op,[e.prop]:this[y]}},[i.HR](e){return $(e)&&e._tag===this._tag&&i.aI(this[y],e[y])},[o.HR](){return o.kg(o.Yj(e.op),o.tW(this[y]))}},r=function(e){this[y]=e};return r.prototype=t,function(e){return new r(e)}},G=q({op:"Success",prop:"value",[v](e){let t=e.getCont(b);return t?t[b](this[y],e,this):e.yieldWith(this)}}),V={key:"effect/Cause/StackTrace"},H=q({op:"Failure",prop:"cause",[v](e){let t=this[y],r=!1;e.cache.stackFrame&&(t=L(t,{mapUnsafe:new Map([[V.key,e.cache.stackFrame]])}),r=!0);let n=e.getCont(_),i=e._interruptedCause;if(i&&e.interruptible){let a=!1;for(;n&&e.interruptible;)a||=g in n,n=e.getCont(_);a&&(t=R(t.reasons.filter(e=>"Fail"!==e._tag))),t=j(t,i),r=!0}return n?n[_](t,e,r?void 0:this):e.yieldWith(r?H(t):this)}}),K=e=>H(U(e)),Q=e=>H(B(e)),Z=X({op:"WithFiber",[v](e){return this[y](e)}}),ee=X({op:"WithFiberSucceed",[v](e){let t=this[y](e),r=e.getCont(b);return r?r[b](t,e):e.yieldWith(G(t))}}),et=function(){class e extends globalThis.Error{}let t=Y({op:"YieldableError",[v](){return K(this)}});return delete t.toString,Object.assign(e.prototype,t),e}(),er=(n=Symbol.for("effect/Data/Error/plainArgs"),class extends et{constructor(e){super(e?.message,e?.cause?{cause:e.cause}:void 0),e&&(f.z(this,e),Object.defineProperty(this,n,{value:e,enumerable:!1}))}toJSON(){return{...this[n],...this}}}),en=e=>{class t extends er{_tag=e}return t.prototype.name=e,t},ei="~effect/Cause/NoSuchElementError";class ea extends en("NoSuchElementError"){[ei]=ei;constructor(e){super({message:e})}}let es="~effect/Cause/Done",eo={[es]:es,_tag:"Done",value:void 0},el=e=>void 0===e?eo:{[es]:es,_tag:"Done",value:e},ed=K(eo);r.d(t,{ET:()=>A,Xm:()=>ea,dM:()=>P,s0:()=>T},{$D:er,$L:e=>(0,c.i5)(e,es),$n:p,Aj:C,B4:O,DH:D,Eh:L,GN:w,Hq:ee,IH:h,In:S,Iu:B,OE:U,PW:e=>(0,c.i5)(e,ei),PX:E,QJ:{key:"effect/Cause/InterruptorStackTrace"},R6:Z,RS:el,Rk:K,Sc:_,Uf:X,V2:Q,Vw:e=>void 0===e?ed:K(el(e)),Wg:e=>(0,c.i5)(e,O),Xb:W,_3:v,a2:y,b5:R,b9:$,cb:H,dO:N,ee:b,fU:k,h2:j,ik:e=>"Interrupt"===e._tag,lC:z,qB:ei,q_:es,rN:en,u4:x,xt:G,yj:Y,yw:e=>(0,c.i5)(e,p),z8:V})},9771(e,t,r){r.d(t,{},{S:e=>e>0?Math.floor(e):0})},7425(e,t,r){var n=r(1594);r.d(t,{},{Jr:e=>(0,n.XY)(2,(t,r)=>e(t,e=>({[r]:e}))),oI:(e,t)=>(0,n.XY)(3,(r,n,i)=>t(r,t=>e(i(t),e=>({...t,[n]:e})))),zM:e=>(0,n.XY)(3,(t,r,n)=>e(t,e=>({...e,[r]:n(e)})))})},6297(e,t,r){let n,i,a,s,o,l,d,c,u,f;r.d(t,{RD4:()=>aN,cOF:()=>aM,a1U:()=>af,z4N:()=>aD,d$_:()=>aB,Do:()=>iI,Aub:()=>aT,F7W:()=>aO,qwd:()=>aE,t8c:()=>aI,olX:()=>aL,obm:()=>nu,kWD:()=>nc,MUS:()=>aS,DQo:()=>aw,Bk6:()=>aj,Kkt:()=>aP,dsN:()=>n7,N24:()=>nq,Q56:()=>nN,jGc:()=>nX,U9h:()=>nP,Q7R:()=>ie,hgn:()=>tS,ww9:()=>ad,gsV:()=>az,Muk:()=>al,as:()=>tu,Xx$:()=>tw,NLW:()=>t$,PCg:()=>iA,oIE:()=>iE,JrD:()=>i$,PO3:()=>nQ,CJw:()=>nG,Rgn:()=>nK,E2r:()=>te,Tyx:()=>rw,rNk:()=>r$,sJf:()=>rI,Fig:()=>rC,UVN:()=>tL,osR:()=>rD,XWm:()=>rj,U9Y:()=>rO,AXC:()=>rB,zt4:()=>rL,KuX:()=>rU,loE:()=>rF,h_t:()=>rE,On5:()=>ei,Bou:()=>Z,nIy:()=>W,h74:()=>ee,O$X:()=>ea,GyP:()=>em,RJ6:()=>eo,ReC:()=>es,RKA:()=>ay,_OA:()=>ro,sxi:()=>rd,Wj8:()=>au,_32:()=>ac,Rud:()=>ab,s0X:()=>a_,cbG:()=>na,F_Q:()=>eZ,OY:()=>tP,yeE:()=>nF,u4Y:()=>rG,NS5:()=>nt,Hox:()=>t9,ely:()=>t4,yJo:()=>tG,HIt:()=>tq,K$2:()=>tJ,GUt:()=>tY,jCT:()=>tH,_OD:()=>tV,lgw:()=>rt,Sv3:()=>re,kMI:()=>t7,YDM:()=>tQ,_mh:()=>tZ,lNM:()=>tK,_sz:()=>tz,VE1:()=>tX,CoE:()=>tW,v9O:()=>t1,EkE:()=>t5,zPu:()=>t2,Wtn:()=>t8,x5l:()=>t0,il9:()=>t6,fJG:()=>eL,ATB:()=>eB,pVV:()=>eQ,gOk:()=>e0,pEE:()=>e8,zFM:()=>eM,C6p:()=>eA,ABT:()=>e9,mKq:()=>eR,DKo:()=>eD,$MQ:()=>eU,eGS:()=>ej,D7p:()=>eN,INJ:()=>eP,vTQ:()=>ij,pbD:()=>iw,x1Q:()=>ik,E8K:()=>iS,VtY:()=>i_,ahH:()=>ix,Pm0:()=>ib,W$I:()=>ry,BbX:()=>H,k7S:()=>V,khU:()=>X,L$u:()=>q,QE5:()=>Y,i8i:()=>ia,kAe:()=>io,tU5:()=>Q,Dd:()=>rq,qIB:()=>tA,Ab9:()=>tR,Bqz:()=>tj,UUz:()=>tk,fn:()=>ts,D9k:()=>tn,vCS:()=>tl,jJl:()=>ic,i4r:()=>rx,zhn:()=>iC,yxg:()=>iM,ar0:()=>iN,x6Z:()=>iP,bJ:()=>eX,sVm:()=>eJ,yUA:()=>eY,JkU:()=>tr,Iku:()=>ek,gpn:()=>G,myX:()=>J,prj:()=>K,nn5:()=>er,d5f:()=>iu,XeO:()=>rV,GrF:()=>rH,GaK:()=>nZ,Inz:()=>n8,eMl:()=>n4,Rft:()=>aA,ASO:()=>aC,N6O:()=>nn,_y:()=>a$,oJd:()=>ni,c8t:()=>ak,PnV:()=>aR,U1p:()=>iy,h$X:()=>im,uVU:()=>iO,A_r:()=>ar,lIX:()=>aX,ORc:()=>z,Fbb:()=>iQ,zzk:()=>iK,Z98:()=>i9,Rd$:()=>i4,TjK:()=>tD,UcN:()=>rJ,q7Y:()=>tB,jkJ:()=>tU,xm_:()=>rW,Z9x:()=>tF,YWq:()=>r4,D$$:()=>r8,NZb:()=>ne,khu:()=>rZ,wR5:()=>tN,G$Q:()=>r7,tvg:()=>r9,T13:()=>ax,ZmZ:()=>tt,S5A:()=>nz,iKM:()=>nJ,BeE:()=>nW,cfM:()=>nU,uRq:()=>nL,fGe:()=>nB,r7h:()=>nj,nAr:()=>nY,uKv:()=>rK,QgK:()=>rY,DM4:()=>rX,jBG:()=>it,ivC:()=>e5,PpN:()=>ru,AAo:()=>nC,PfK:()=>rf,c7E:()=>rh,O4F:()=>tT,Vdx:()=>tO,FfP:()=>tC,KT6:()=>tM,tQ6:()=>en,TSs:()=>ir,aAq:()=>rb,Xrv:()=>r_,Akf:()=>ih,Ket:()=>rQ,bPG:()=>iF,lSz:()=>iU,MY7:()=>iD,eJC:()=>iR,pR5:()=>iW,NpQ:()=>iL,jqV:()=>iB,v2Q:()=>iz,HZF:()=>iq,lKS:()=>iY,rfH:()=>iJ,lE:()=>iX,_Sg:()=>tE,z8E:()=>nO,iLB:()=>nx,Uio:()=>n_,MbZ:()=>nw,vDJ:()=>np,fou:()=>nh,Z$R:()=>nv,pSt:()=>nb,RWE:()=>nE,d97:()=>nS,DLK:()=>nf,mdu:()=>nM,P1j:()=>nT,Pxi:()=>nA,euC:()=>rr,Nav:()=>rn,oao:()=>rc,yy4:()=>av,Fu6:()=>ae,WbR:()=>at,PyW:()=>eF,lwU:()=>eH,nGE:()=>eV,DYE:()=>eW,OH5:()=>ez,Mim:()=>tI,dGm:()=>rT,bKC:()=>rA,cA6:()=>rM,nAi:()=>rR,sFT:()=>rN,k$L:()=>rP,ayu:()=>nd,wRz:()=>no,D52:()=>nl,mgX:()=>ns,kJM:()=>iZ,pkL:()=>eK,SvU:()=>e2,$mh:()=>e3,Vxk:()=>aV,rfi:()=>n0,FcF:()=>n9,scW:()=>rz,r_d:()=>ri,bUZ:()=>ra,L_I:()=>rs,gvr:()=>ai,tfT:()=>ii,rIH:()=>e1,z7s:()=>rv,iMI:()=>id,$$g:()=>aH,hq:()=>as,fRP:()=>ao,zr8:()=>i7,_o1:()=>i0,nDN:()=>i1,MaT:()=>i2,m9E:()=>eG,KN3:()=>eq,yU6:()=>rm,OYO:()=>rg});var p=r(664),h=r(1179),m=r(3614),g=r(3332),y=r(1594),v=r(1587),b=r(4233),_=r(9315);b.Kg,b.Et,b.Lm,b.sI,b.Bm,b.$P;let x=(0,y.XY)(2,(e,t)=>r=>{let n=e(r);if(_.N6(n))return _.fJ(r);let i=t(n.success);return _.N6(i)?_.fJ(r):i});var w=r(1958),k=r(5033),S=r(3952),I=r(592),$=r(2860),E=r(1554),O=r(1279),C=r(3909),T=r(2707),M=r(6481),A=r(2449),N=r(7425),P=r(7258),R=r(2275),j=r(6712),D=r(5340);let U=e=>{if(e?.captureStackTrace===!1||e?.captureStackTrace!==void 0&&"boolean"!=typeof e.captureStackTrace)return e;let t=(0,D.jt)();if(0===t&&e?.captureStackTrace!==!0)return{...e,captureStackTrace:!1};(0,D.ft)(3);let r=Error();return(0,D.ft)(t),{...e,captureStackTrace:B(()=>r.stack)}},F=e=>t=>{let r;return()=>{if(void 0!==r)return r;let n=t();if(!n)return;let i=n.split("\n");if(void 0!==i[e])return r=i[e].trim()}},B=F(3);class L extends A.ET{constructor(e,t=A.dO){super("Interrupt",t,"Interrupted"),this.fiberId=e}toString(){return`Interrupt(${this.fiberId})`}toJSON(){return{_tag:"Interrupt",fiberId:this.fiberId}}[g.HR](e){return(0,A.ik)(e)&&this.fiberId===e.fiberId&&this.annotations===e.annotations}[k.HR](){return k.kg(k.Yj(`${this._tag}:${this.fiberId}`))(k.yT(this.annotations))}}let z=e=>new L(e),W=e=>new A.s0([new L(e)]),J=e=>e.reasons.some(A.lC),Y=e=>{let t=e.reasons.find(A.lC);return t?_.Py(t):_.fJ(e)},X=e=>{for(let t=0;t<e.reasons.length;t++){let r=e.reasons[t];if("Fail"===r._tag)return _.Py(r.error)}return _.fJ(e)},q=e=>{let t=X(e);return _.N6(t)?v.none():v.some(t.success)},G=e=>e.reasons.some(A.Xb),V=e=>{let t=e.reasons.find(A.Xb);return t?_.Py(t):_.fJ(e)},H=e=>{let t=e.reasons.find(A.Xb);return t?_.Py(t.defect):_.fJ(e)},K=e=>e.reasons.some(A.ik),Q=e=>{let t=e.reasons.find(A.ik);return t?_.Py(t):_.fJ(e)},Z=e=>{let t;for(let r=0;r<e.reasons.length;r++){let n=e.reasons[r];"Interrupt"===n._tag&&(t??=new Set,void 0!==n.fiberId&&t.add(n.fiberId))}return t?_.Py(t):_.fJ(e)},ee=e=>{let t=Z(e);return _.N6(t)?et:t.success},et=new Set,er=e=>e.reasons.length>0&&e.reasons.every(A.ik),en=e=>h.LZ(e.annotations),ei=e=>{let t=new Map;for(let r of e.reasons)if(r.annotations.size>0)for(let[e,n]of r.annotations)t.set(e,n);return h.LZ(t)},ea=(0,y.XY)(2,(e,t)=>{let r=!1,n=e.reasons.map(e=>(0,A.lC)(e)?(r=!0,new A.dM(t(e.error),e.annotations)):e);return r?(0,A.b5)(n):e}),es=e=>{let t;for(let r of e.reasons){if("Fail"===r._tag)return r.error;"Die"===r._tag&&(t??=r)}return void 0!==t?t.defect:new globalThis.Error(e.reasons.length>0?"All fibers interrupted without error":"Empty cause")},eo=(e,t)=>{let r=[],n=[];if(0===e.reasons.length)return r;let i=(0,D.jt)();0!==i&&(0,D.ft)(1);try{for(let i of e.reasons){if("Interrupt"===i._tag){n.push(i);continue}r.push(el("Die"===i._tag?i.defect:i.error,i.annotations,t))}if(0===r.length){let e=Error("The fiber was interrupted by:");e.name="InterruptCause",e.stack=ep(e,n);let i=new globalThis.Error("All fibers interrupted without error",{cause:e});i.name="InterruptError",i.stack=`${i.name}: ${i.message}`,r.push(el(i,n[0].annotations,t))}}finally{0!==i&&(0,D.ft)(i)}return r},el=(e,t,r)=>{let n,i=typeof e;if(e&&"object"===i){if(n=new globalThis.Error(ed(e),{cause:e.cause?el(e.cause):void 0}),"string"==typeof e.name&&(n.name=e.name),"string"==typeof e.stack)n.stack=eu(e.stack,n,t);else{let e=`${n.name}: ${n.message}`;n.stack=t?ef(e,t):e}for(let t of(r?.includeCauseInStack&&(n.stack=eg(n)),Object.keys(e)))t in n||(n[t]=e[t])}else n=new globalThis.Error(!e?`Unknown error: ${e}`:"string"===i?e:(0,w.IB)(e));return n},ed=e=>{if("string"==typeof e.message)return e.message;if("function"==typeof e.toString&&e.toString!==Object.prototype.toString&&e.toString!==Array.prototype.toString)try{return e.toString()}catch{}return(0,w.IB)(e)},ec=/\((.*)\)/g,eu=(e,t,r)=>{let n=`${t.name}: ${t.message}`,i=(e.startsWith(n)?e.slice(n.length):e).split("\n"),a=[n];for(let e=1;e<i.length&&!/Generator\.next|~effect\/(?:Effect|Utils)/.test(i[e]);e++)a.push(i[e]);return r?ef(a.join("\n"),r):a.join("\n")},ef=(e,t)=>{let r=t?.get(A.z8.key);return r&&(e=`${e}
237
+ ${eh(r)}`),e},ep=(e,t)=>{let r=[`${e.name}: ${e.message}`];for(let e of t){let t=void 0!==e.fiberId?`#${e.fiberId}`:"unknown",n=e.annotations.get(A.QJ.key);r.push(` at fiber (${t})`),n&&r.push(eh(n))}return r.join("\n")},eh=e=>{let t=[],r=e,n=0;for(;r&&n<10;){let e=r.stack();if(e){let n=e.matchAll(ec),i=!1;for(let[,e]of n)i=!0,t.push(` at ${r.name} (${e})`);i||t.push(` at ${r.name} (${e.replace(/^at /,"")})`)}else t.push(` at ${r.name}`);r=r.parent,n++}return t.join("\n")},em=e=>eo(e).map(eg).join("\n"),eg=e=>e.cause?`${e.stack} {
238
238
  ${ey(e.cause," ")}
239
239
  }`:e.stack,ey=(e,t)=>{let r=e.stack.split("\n"),n=`${t}[cause]: ${r[0]}`;for(let e=1,i=r.length;e<i;e++)n+=`
240
240
  ${t}${r[e]}`;return e.cause&&(n+=` {
241
241
  ${ey(e.cause,`${t} `)}
242
- ${t}}`),n},eb="~effect/Fiber",ev={_A:y.D_,_E:y.D_},e_={id:0},ex=(()=>{try{return globalThis.process?.getBuiltinModule?.("node:async_hooks")?.AsyncResource}catch{return}})(),ew=()=>void 0===ex?void 0:new ex("effect/Fiber"),ek=()=>globalThis[O.fL];class eS{constructor(e,t=!0){this.setContext(e),this.id=++e_.id,this.currentOpCount=0,this.interruptible=t,this._stack=[],this._observers=void 0,this._exit=void 0,this._children=void 0,this._interruptedCause=void 0,this._yielded=void 0,this._running=!1,this._deferredInterrupt=!1,this._parent=void 0,this._asyncContext=void 0,this.cache.runtimeMetrics?.recordFiberStart(this.context)}get[eb](){return ev}get currentDispatcher(){return this._dispatcher??=this.cache.scheduler.makeDispatcher()}getRef(e){return h.Jt(this.context,e)}addObserver(e){return this._exit?(e(this._exit),y.Yi):(void 0===this._observers?this._observers=[e]:this._observers.push(e),()=>this.removeObserver(e))}removeObserver(e){if(this._exit||void 0===this._observers)return;let t=this._observers.indexOf(e);t>=0&&this._observers.splice(t,1)}interruptUnsafe(e,t){if(this._exit)return;let r=W(e);this.cache.stackFrame&&(r=(0,P.Eh)(r,h.L8(P.z8,this.cache.stackFrame))),t&&(r=(0,P.Eh)(r,t)),this._interruptedCause=this._interruptedCause?(0,P.h2)(this._interruptedCause,r):r,this.interruptible&&(this._running?this._deferredInterrupt=!0:this.evaluate(eB(this._interruptedCause)))}pollUnsafe(){return this._exit}evaluate(e){if(this._exit)return;if(void 0!==this._asyncContext){let t=this._asyncContext;return this._asyncContext=void 0,t.runInAsyncScope(this.evaluate,this,e)}if(void 0!==this._yielded){let e=this._yielded;this._yielded=void 0,e()}let t=this.runLoop(e);if(t===P.GN){this._asyncContext=ew();return}let r=eO.interruptChildren&&eO.interruptChildren(this);if(void 0!==r)return this.evaluate(tP(r,()=>t));if(this._exit=t,this.cache.runtimeMetrics?.recordFiberEnd(this.context,this._exit),this._parent&&(this._parent._children?.delete(this),this._parent=void 0),void 0!==this._observers){let e=this._observers;this._observers=void 0;for(let r=0;r<e.length;r++)e[r](t)}this._stack.length=0,this._children=void 0,this.context=h.Ie()}runLoop(e){let t=globalThis[O.fL];globalThis[O.fL]=this;let r=this._running;this._running=!0;let n=!1,i=e;this.currentOpCount=0;try{for(;;){this._deferredInterrupt&&(this._deferredInterrupt=!1,i=eB(this._interruptedCause)),this.currentOpCount++;let e=this.cache;if(!n&&!e.preventYield&&e.scheduler.shouldYield(this)){n=!0;let e=i;i=tP(eG,()=>e)}if((i=e.tracerContext?e.tracerContext(i,this):i[P._3](this))===P.GN){let e=this._yielded;if(P.IH in e)return this._deferredInterrupt=!1,this._yielded=void 0,e;if(this._deferredInterrupt){this._yielded=void 0,e();continue}return P.GN}}}catch(e){if(!(0,v.i5)(i,P._3))return(0,P.V2)(`Fiber.runLoop: Not a valid effect: ${String(i)}`);return this.runLoop((0,P.V2)(e))}finally{this._running=r,globalThis[O.fL]=t}}getCont(e){if(this._deferredInterrupt)return this._deferredInterrupt=!1,e$;for(;;){let t=this._stack.pop();if(!t)return;let r=t[P.u4];if(void 0!==r){let n=r.call(t,this);if(n)return n[e]=n,n}if(t[e])return t}}succeedWith(e){if((++this.currentOpCount&eE-1)==0)return(0,P.xt)(e);let t=this.getCont(P.ee);return t?t[P.ee](e,this):this.yieldWith((0,P.xt)(e))}yieldWith(e){return this._yielded=e,P.GN}children(){return this._children??=new Set}pipe(){return(0,E.tT)(this,arguments)}setContext(e){let t=this.context;if(this.context=e,void 0!==t&&h.Pf(t,e))return;let r=e.cacheRoot,n=r._fiberCache??=eI(e);this.cache?.scheduler!==n.scheduler&&(this._dispatcher=void 0),this.cache=n}get currentSpanLocal(){let e=this.cache.span;return e?._tag==="Span"?e:void 0}}let eI=e=>{let t=h.Ub(e,T.RL);return{scheduler:h.Jt(e,C._F),tracer:t,tracerContext:t?t.context:void 0,tracerEnabled:h.Jt(e,j.rf),span:h.Ub(e,T.WG),logLevel:h.Jt(e,j.Gl),minimumLogLevel:h.Jt(e,j.zQ),stackFrame:h.Jt(e,j.vA),runtimeMetrics:h.Ub(e,N.F),maxOpsBeforeYield:h.Jt(e,C.Zm),preventYield:h.Jt(e,C.hf)}},e$={[P.ee]:(e,t)=>eB(t._interruptedCause),[P.Sc]:(e,t)=>eB(t._interruptedCause)},eE=32,eO={interruptChildren:void 0},eC=e=>{if(!e.cache.stackFrame)return;let t=new Map;return t.set(P.QJ.key,e.cache.stackFrame),h.LZ(t)},eT=e=>{if(void 0!==e._children&&0!==e._children.size)return eD(e._children)},eM=e=>e._exit?eF(e._exit):te(t=>e._exit?t(eF(e._exit)):ez(e.addObserver(e=>t(eF(e))))),eP=e=>te(t=>{let r,n=e[Symbol.iterator](),i=[];return!function e(){let a=n.next();for(;!a.done;){if(a.value._exit){i.push(a.value._exit),a=n.next();continue}r=a.value.addObserver(t=>{i.push(t),e()});return}t(eF(i))}(),ez(()=>r?.())}),eA=e=>e._exit?e._exit:te(t=>e._exit?t(e._exit):ez(e.addObserver(t))),eN=e=>te(t=>{let r=Array.from(e);if(0===r.length)return t(eF(p.Ie()));let n=Array(r.length),i=p.Ie(),a=()=>{for(let e=0;e<i.length;e++)r[e].removeObserver(i[e])},s=0,o=!1;for(let e=0;e<r.length&&!o;e++){let l=i=>{if(s++,"Failure"===i._tag)return o=!0,a(),t(i);n[e]=i.value,s===r.length&&t(eF(n))};i.push(l),r[e].addObserver(l)}return ez(()=>{o=!0,a()})}),eR=e=>(0,P.R6)(t=>ej(e,t.id)),ej=(0,y.XY)(e=>(0,v.i5)(e[0],eb),(e,t,r)=>(0,P.R6)(n=>{let i=eC(n);return i=i&&r?h.h1(i,r):i??r,e.interruptUnsafe(t,i),t$(eM(e))})),eD=e=>(0,P.R6)(t=>{let r=eC(t),n=p.Ie();for(let i of e)i.interruptUnsafe(t.id,r),n.push(i);return t$(eP(n))}),eU=(0,y.XY)(2,(e,t)=>(0,P.R6)(r=>{let n=eC(r),i=p.Ie();for(let r of e)r.interruptUnsafe(t,n),i.push(r);return t$(eP(i))})),eF=P.xt,eB=P.cb,eL=P.Rk,ez=(0,P.Uf)({op:"Sync",[P._3](e){let t=this[P.a2](),r=e.getCont(P.ee);return r?r[P.ee](t,e):e.yieldWith((0,P.xt)(t))}}),eW=(0,P.Uf)({op:"Suspend",[P._3](e){return this[P.a2]()}}),eJ=(0,y.XY)(e=>e.length>=2||b.isOption(e[0]),(e,t)=>b.isNone(e)?eL(t?t():new P.Xm("Effect.fromOption: Option.none")):eF(e.value)),eY=_.YW({onFailure:eL,onSuccess:eF}),eX=e=>null==e?eL(new P.Xm):eF(e),eq=(0,P.Uf)({op:"Yield",[P._3](e){let t=!1;return e.currentDispatcher.scheduleTask(()=>{t||e.evaluate(t0)},this[P.a2]??0),e.yieldWith(()=>{t=!0})}}),eG=eq(0),eV=e=>eF(b.some(e)),eH=eF(b.none()),eK=e=>b.isNone(e)?eH:tD(e.value,b.some),eQ=e=>eW(()=>eB(e())),eZ=e=>(0,P.V2)(e),e0=e=>eW(()=>eL(e())),e1=eF(void 0),e2=e=>{let t="function"==typeof e?e:e.try,r="function"==typeof e?e=>new aj(e,"An error occurred in Effect.try"):e.catch;return eW(()=>{try{return eF(t())}catch(e){return eL(r(e))}})},e5=e=>e4(function(t,r){e(r).then(e=>t(eF(e)),e=>t(eZ(e)))},0!==e.length),e3=e=>{let t="function"==typeof e?e:e.try,r="function"==typeof e?e=>new aj(e,"An error occurred in Effect.tryPromise"):e.catch;return e4(function(e,n){let i=e=>eW(()=>{try{return eL((0,M.s)(()=>r(e)))}catch(e){return eZ(e)}});try{t(n).then(t=>e(eF(t)),t=>e(i(t)))}catch(t){e(i(t))}},0!==t.length)},e6=e=>(0,P.R6)(t=>e(t.id)),e8=(0,P.R6)(eF),e9=e6(eF),e4=(n=(0,P.yj)({op:"Async",[P._3](e){let t=!1,r=!1,n=this.withSignal?new AbortController:void 0,i=this.register.call(e.cache.scheduler,n=>{t||(t=!0,r?e.evaluate(n):r=n)},n?.signal);return!1!==r?r:(r=!0,e._yielded=()=>{t=!0},void 0===n&&void 0===i||e._stack.push(e7(()=>(t=!0,n?.abort(),i??t0))),P.GN)}}),(i=function(e,t){this.register=e,this.withSignal=t}).prototype=n,function(e,t){return new i(e,t)}),e7=(0,P.Uf)({op:"AsyncFinalizer",[P.u4](e){e.interruptible&&(e.interruptible=!1,e._stack.push(n2))},[P.Sc](e,t){return K(e)?tP(ng((0,P.cb)(e),this[P.a2]()),()=>eB(e)):eB(e)}}),te=e=>e4(e,e.length>=2),tt=te(y.Yi),tr=(...e)=>{if(1===e.length){let t=e[0];return eW(()=>tc(t()))}let[t,r]=e;return eW(()=>tc(r.call(t.self)))},tn=(e,...t)=>{let r=0===t.length?function(){return eW(()=>tc(e.apply(this,arguments)))}:function(){let r=eW(()=>tc(e.apply(this,arguments)));for(let e=0;e<t.length;e++)r=t[e](r,...arguments);return r};return ti(e.length,r)},ti=(e,t)=>Object.defineProperty(t,"length",{value:e,configurable:!0}),ta=F(2),ts=function(){let e,t="string"==typeof arguments[0],r=t?arguments[0]:"Effect.fn",n=t?arguments[1]:void 0,i=(0,D.jt)();return(0!==i&&((0,D.ft)(2),e=new globalThis.Error,(0,D.ft)(i)),t)?(i,...a)=>to(r,i,e,a,t,n):to(r,arguments[0],e,Array.prototype.slice.call(arguments,1),t,n)},to=(e,t,r,n,i,a)=>{let s="function"==typeof t?t:n.shift().bind(t.self),o=`${e} (definition)`,l=r?ta(()=>r.stack):y.MN;return ti(s.length,function(...t){let r,d=eW(()=>{let e=s.apply(this,arguments);return(0,P.yw)(e)?e:tc(e)});for(let e=0;e<n.length;e++)d=n[e](d,...t);if(!(0,P.yw)(d))return d;let c=(0,D.jt)();return 0!==c&&((0,D.ft)(2),r=new globalThis.Error,(0,D.ft)(c)),ra(i?ai(e,a,e=>aa(d,e)):d,j.vA,t=>({name:e,stack:r?ta(()=>r.stack):y.MN,parent:{name:o,stack:l,parent:t}}))})},tl=(e,...t)=>ti(e.length,0===t.length?function(){return td(()=>e.apply(this,arguments))}:function(){let r=td(()=>e.apply(this,arguments));for(let e of t)r=e(r,...arguments);return r}),td=e=>{try{let t,r=e();for(;;){let n=r.next(t);if(n.done)return eF(n.value);let i=n.value;if(i&&"Success"===i._tag){t=i.value;continue}{if(i&&"Failure"===i._tag)return n.value;let t=!0;return eW(()=>t?(t=!1,tP(n.value,e=>tc(r,e))):eW(()=>tc(e())))}}}catch(e){return eZ(e)}},tc=(a=(0,P.yj)({op:"Iterator",[P.ee](e,t){let r=this.iterator;for(;;){let n=r.next(e);if(n.done)return eF(n.value);if(!tN(n.value))return t._stack.push(this),n.value;if("Failure"===n.value._tag)return n.value;e=n.value.value}},[P._3](e){return this[P.ee](this.initial,e)}}),(s=function(e,t){this.iterator=e,this.initial=t}).prototype=a,function(e,t){return new s(e,t)}),tu=(0,y.XY)(2,(e,t)=>new th(e,tm,eF(t))),tf=function(e){return e._stack.push(this),this[P.a2]},tp=(0,P.yj)({op:"OnSuccess",[P._3]:tf}),th=function(e,t,r){this[P.a2]=e,this[P.ee]=t,this.payload=r};th.prototype=tp;let tm=function(){return this.payload},tg=function(e,t){return t.succeedWith(this.payload)},ty=(o="~effect/Effect/stackProbe",({[o]:function(){return Error().stack}})[o]()?.includes("[as "+o+"]")===!0),tb=function(e,t){let r=this.payload;return t.succeedWith(ty?r(e):(0,M.s)(()=>r(e)))},tv=function(e){return(0,this.payload)(e)},t_=function(e){return new th((0,this.payload)(e),tg,e)},tx=function(e){return new th(this.payload,tg,e)},tw=e=>tD(e,b.some),tk=e=>r9(e,{onFailure:eF,onSuccess:eL}),tS=(0,y.XY)(2,(e,t)=>new th(e,(0,P.yw)(t)?tm:tv,t)),tI=(0,y.XY)(2,(e,t)=>new th(e,(0,P.yw)(t)?tx:t_,t)),t$=e=>new th(e,tm,t0),tE=e=>rw(e,eL),tO=(e,t)=>(0,P.R6)(r=>{let n=new Set;return nD(r,()=>0===n.size?void 0:eD(n)),te(i=>{let a=p.Ts(e),s=a.length,o=0,l=!1,d=[],c=(e,n,a)=>{if(o++,"Failure"===e._tag){d.push(...e.cause.reasons),o>=s&&i(eB((0,P.b5)(d)));return}let c=!l;l=!0,i(e),c&&t?.onWinner&&t.onWinner({fiber:n,index:a,parentFiber:r})};for(let e=0;e<s;e++){let t=iT(r,a[e],!0,!0,!1);if(n.add(t),t.addObserver(r=>{n.delete(t),c(r,t,e)}),l)break}})}),tC=(e,t)=>(0,P.R6)(r=>{let n=new Set;return nD(r,()=>0===n.size?void 0:eD(n)),te(i=>{let a=!1,s=0;for(let o of e){if(a)break;let e=s++,l=iT(r,o,!0,!0,!1);n.add(l),l.addObserver(s=>{n.delete(l);let o=!a;a=!0,i(s),o&&t?.onWinner&&t.onWinner({fiber:l,index:e,parentFiber:r})})}})}),tT=(0,y.XY)(e=>(0,P.yw)(e[1]),(e,t,r)=>tO([e,t],r)),tM=(0,y.XY)(e=>(0,P.yw)(e[1]),(e,t,r)=>tC([e,t],r)),tP=(0,y.XY)(2,(e,t)=>new th(e,tv,t)),tA=(0,y.XY)(2,(e,t)=>tN(e)?"Success"===e._tag?t.onSuccess(e.value):t.onFailure(e.cause):rZ(e,t)),tN=e=>void 0!==e[P.IH],tR=(0,y.XY)(2,(e,t)=>tN(e)?"Success"===e._tag?t(e.value):e:tP(e,t)),tj=e=>tP(e,y.D_),tD=(0,y.XY)(2,(e,t)=>new th(e,tb,t)),tU=(0,y.XY)(2,(e,t)=>tN(e)?t1(e,t):tD(e,t)),tF=(0,y.XY)(2,(e,t)=>tN(e)?t2(e,t):rW(e,t)),tB=(0,y.XY)(2,(e,t)=>tN(e)?t5(e,t):rJ(e,t)),tL=(0,y.XY)(2,(e,t)=>{if(tN(e)){if("Success"===e._tag)return e;let r=X(e.cause);return _.N6(r)?e:t(r.success)}return rE(e,t)}),tz=e=>(0,P.cb)(W(e)),tW=e=>"Success"===e._tag,tJ=e=>"Success"===e._tag?_.Py(e):_.fJ(e),tY=e=>"Success"===e._tag?_.Py(e.value):_.fJ(e),tX=e=>"Failure"===e._tag,tq=e=>"Failure"===e._tag?_.Py(e):_.fJ(e),tG=e=>"Failure"===e._tag?_.Py(e.cause):_.fJ(e),tV=x(tG,X),tH=x(tG,H),tK=e=>"Failure"===e._tag&&K(e.cause),tQ=e=>"Failure"===e._tag&&G(e.cause),tZ=e=>"Failure"===e._tag&&J(e.cause),t0=(0,P.xt)(void 0),t1=(0,y.XY)(2,(e,t)=>"Success"===e._tag?(0,P.xt)(t(e.value)):e),t2=(0,y.XY)(2,(e,t)=>{if("Success"===e._tag)return e;let r=X(e.cause);return _.N6(r)?e:(0,P.Rk)(t(r.success))}),t5=(0,y.XY)(2,(e,t)=>{if("Success"===e._tag)return(0,P.xt)(t.onSuccess(e.value));let r=X(e.cause);return _.N6(r)?e:(0,P.Rk)(t.onFailure(r.success))}),t3=(0,y.XY)(2,(e,t)=>tW(e)?(0,P.xt)(t):e),t6=(0,y.XY)(2,(e,t)=>tW(e)?t:e),t8=(0,y.XY)(2,(e,t)=>tW(e)?t.onSuccess(e.value):t.onFailure(e.cause)),t9=t3(void 0),t4=e=>{let t=[];for(let r of e)"Failure"===r._tag&&t.push(...r.cause.reasons);return 0===t.length?t0:(0,P.cb)((0,P.b5)(t))},t7=e=>tW(e)?b.some(e.value):b.none(),re=e=>tX(e)?b.some(e.cause):b.none(),rt=e=>{let t=tV(e);return _.N6(t)?b.none():b.some(t.success)},rr=e=>e,rn=e=>(0,P.R6)(t=>eF(h.om(t.context,e))),ri=(0,y.XY)(2,(e,t)=>(0,P.R6)(r=>{let n=r.context,i=t(n);return n===i||(r.setContext(i),nD(r,()=>{r.setContext(n)})),e})),ra=(0,y.XY)(3,(e,t,r)=>ri(e,e=>{let n=h.fp(e,t),i=r(n);return n===i?e:h.WQ(e,t,i)})),rs=(e,t,r)=>n0((0,P.R6)(n=>{let i=h.fp(n.context,e),a=t(i);return n.setContext(h.WQ(n.context,e,a)),n_(h.fp(n.context,nf),t=>{let s,o=h.om(n.context,e);if(b.isNone(o))return e1;let l=o.value;if(r?.reset===void 0){if(l!==a)return e1;s=i}else s=r.reset(i,a,l);return n.setContext(h.WQ(n.context,e,s)),e1})})),ro=()=>rl,rl=(0,P.R6)(e=>eF(e.context)),rd=e=>(0,P.R6)(t=>e(t.context)),rc=(0,y.XY)(2,(e,t)=>ri(e,(0,y.dY)(t))),ru=(0,y.XY)(2,(e,t)=>tN(e)?e:ri(e,h.h1(t))),rf=function(){return 1==arguments.length?(0,y.XY)(2,(e,t)=>rp(e,arguments[0],t)):(0,y.XY)(3,(e,t,r)=>rp(e,t,r)).apply(this,arguments)},rp=(e,t,r)=>ri(e,h.WQ(t,r)),rh=(0,y.XY)(3,(e,t,r)=>tP(r,r=>rf(e,t,r))),rm=(0,y.XY)(e=>(0,P.yw)(e[1]),(e,t,r)=>rg(e,t,(e,t)=>[e,t],r)),rg=(0,y.XY)(e=>(0,P.yw)(e[1]),(e,t,r,n)=>n?.concurrent?tD(ie([e,t],{concurrency:2}),([e,t])=>r(e,t)):tP(e,e=>tD(t,t=>r(e,t)))),ry=(0,y.XY)(e=>(0,P.yw)(e[0]),(e,t,r)=>iv(e,t,r?e=>eL(r(e)):()=>eL(new P.Xm))),rb=(0,y.XY)(2,(e,t)=>tP(t,t=>t?tw(e):eH)),rv=(0,y.XY)(2,(e,t)=>Array.from({length:t},()=>e)),r_=(0,y.XY)(e=>(0,P.yw)(e[0]),(e,t,r)=>ie(rv(e,t),r)),rx=(0,y.XY)(e=>(0,P.yw)(e[0]),(e,t)=>id({while:y.ue,body:(0,y.dY)(t?.disableYield?e:tP(e,e=>eG)),step:y.Yi})),rw=(0,y.XY)(2,(e,t)=>new rS(e,1!==t.length?e=>t(e):t)),rk=(0,P.yj)({op:"OnFailure",[P._3]:tf}),rS=function(e,t){this[P.a2]=e,this[P.Sc]=t};rS.prototype=rk;let rI=(0,y.XY)(3,(e,t,r)=>rw(e,e=>t(e)?r(e):eB(e))),r$=(0,y.XY)(3,(e,t,r)=>rw(e,e=>{let n=t(e);return _.N6(n)?eB(n.failure):r(n.success,e)})),rE=(0,y.XY)(2,(e,t)=>r$(e,X,e=>t(e))),rO=e=>r9(e,{onFailure:e=>(0,P.PW)(e)?eH:eL(e),onSuccess:eV}),rC=(0,y.XY)(2,(e,t)=>r$(e,H,t)),rT=(0,y.XY)(2,(e,t)=>rw(e,e=>tS(t(e),eB(e)))),rM=(0,y.XY)(3,(e,t,r)=>rI(e,t,e=>tS(r(e),eB(e)))),rP=(0,y.XY)(3,(e,t,r)=>rw(e,e=>{let n=t(e);return _.N6(n)?eB(e):tS(r(n.success,e),eB(e))})),rA=(0,y.XY)(2,(e,t)=>rP(e,X,e=>t(e))),rN=(0,y.XY)(3,(e,t,r)=>{let n=Array.isArray(t)?e=>(0,v.i5)(e,"_tag")&&t.includes(e._tag):(0,v.$J)(t);return rA(e,e=>n(e)?r(e):e1)}),rR=(0,y.XY)(2,(e,t)=>rP(e,H,e=>t(e))),rj=(0,y.XY)(e=>(0,P.yw)(e[0]),(e,t,r,n)=>rw(e,e=>{let i=X(e);return _.N6(i)?eB(i.failure):t(i.success)?r(i.success):n?n(i.success):eB(e)})),rD=(0,y.XY)(e=>(0,P.yw)(e[0]),(e,t,r,n)=>rw(e,e=>{let i=X(e);if(_.N6(i))return eB(i.failure);let a=t(i.success);return _.N6(a)?n?n(a.failure):eB(e):r(a.success)})),rU=(0,y.XY)(e=>(0,P.yw)(e[0]),(e,t,r,n)=>rj(e,Array.isArray(t)?e=>(0,v.i5)(e,"_tag")&&t.includes(e._tag):(0,v.$J)(t),r,n)),rF=(0,y.XY)(e=>(0,P.yw)(e[0]),(e,t,r)=>{let n;return rD(e,e=>(n??=Object.keys(t),(0,v.i5)(e,"_tag")&&(0,v.Kg)(e._tag)&&n.includes(e._tag)?_.Py(e):_.fJ(e)),e=>t[e._tag](e),r)}),rB=(0,y.XY)(e=>(0,P.yw)(e[0]),(e,t,r,n,i)=>rj(e,e=>(0,v.$J)(e,t)&&(0,v.i5)(e,"reason")&&(void 0!==i||(0,v.$J)(e.reason,r)),e=>{let t=e.reason;return(0,v.$J)(t,r)?n(t,e):i?i(t,e):eL(e)})),rL=(0,y.XY)(e=>(0,P.yw)(e[0]),(e,t,r,n)=>{let i;return rj(e,e=>(0,v.$J)(e,t)&&(0,v.i5)(e,"reason")&&(0,v.i5)(e.reason,"_tag")&&(0,v.Kg)(e.reason._tag)&&(void 0!==n||(i??=Object.keys(r)).includes(e.reason._tag)),e=>{let t=e.reason;return(i??=Object.keys(r)).includes(t._tag)?r[t._tag](t,e):n?n(t,e):eL(e)})}),rz=(0,y.XY)(2,(e,t)=>rD(e,e=>(0,v.$J)(e,t)&&(0,v.i5)(e,"reason")?_.Py(e.reason):_.fJ(e),eL)),rW=(0,y.XY)(2,(e,t)=>rE(e,e=>e0(()=>t(e)))),rJ=(0,y.XY)(2,(e,t)=>r9(e,{onFailure:e=>e0(()=>t.onFailure(e)),onSuccess:e=>ez(()=>t.onSuccess(e))})),rY=e=>rE(e,eZ),rX=(0,y.XY)(2,(e,t)=>rE(e,e=>ez(()=>t(e)))),rq=e=>eW(()=>{let t=e[Symbol.iterator](),r=t.next();return r.done?eZ(Error("Received an empty collection of effects")):function e(r){let n=t.next();return n.done?r.value:rE(r.value,t=>e(n))}(r)}),rG=e=>rE(e,t=>tP(eG,()=>rG(e))),rV=(0,y.XY)(e=>(0,P.yw)(e[0]),(e,t)=>{if(!t?.log)return r9(e,{onFailure:e=>e1,onSuccess:e=>e1});let r=aX(!0===t.log?void 0:t.log);return rZ(e,{onFailure(e){let n=Y(e);return _.N6(n)?eB(n.failure):void 0===t.message?r(e):r(t.message,e)},onSuccess:e=>e1})}),rH=(0,y.XY)(e=>(0,P.yw)(e[0]),(e,t)=>{if(!t?.log)return rZ(e,{onFailure:e=>e1,onSuccess:e=>e1});let r=aX(!0===t.log?void 0:t.log);return rZ(e,{onFailure:e=>void 0===t.message?r(e):r(t.message,e),onSuccess:e=>e1})}),rK=e=>r4(e,{onFailure:b.none,onSuccess:b.some}),rQ=e=>r7(e,{onFailure:_.fJ,onSuccess:_.Py}),rZ=(0,y.XY)(2,(e,t)=>new r1(e,1!==t.onSuccess.length?e=>t.onSuccess(e):t.onSuccess,1!==t.onFailure.length?e=>t.onFailure(e):t.onFailure)),r0=(0,P.yj)({op:"OnSuccessAndFailure",[P._3]:tf}),r1=function(e,t,r){this[P.a2]=e,this[P.ee]=t,this[P.Sc]=r};r1.prototype=r0;let r2=function(e,t){let r=this.payload;return t.succeedWith(ty?r.onSuccess(e):(0,M.s)(()=>r.onSuccess(e)))},r5=(e,t)=>{let r=(0,P.yj)({op:e,[P._3]:tf,[P.ee]:r2,[P.Sc]:t}),n=function(e,t){this[P.a2]=e,this.payload=t};return n.prototype=r,n},r3=r5("Match",function(e,t){let r=e.reasons.find(P.lC);if(void 0===r)return eB(e);let n=this.payload;return t.succeedWith(ty?n.onFailure(r.error):(0,M.s)(()=>n.onFailure(r.error)))}),r6=r5("MatchCause",function(e,t){let r=this.payload;return t.succeedWith(ty?r.onFailure(e):(0,M.s)(()=>r.onFailure(e)))}),r8=(0,y.XY)(2,(e,t)=>new r6(e,t)),r9=(0,y.XY)(2,(e,t)=>rZ(e,{onFailure:e=>{let r=e.reasons.find(P.lC);return r?t.onFailure(r.error):eB(e)},onSuccess:t.onSuccess})),r4=(0,y.XY)(2,(e,t)=>new r3(e,t)),r7=(0,y.XY)(2,(e,t)=>{if(tN(e)){if("Success"===e._tag)return(0,P.xt)(t.onSuccess(e.value));let r=X(e.cause);return _.N6(r)?e:(0,P.xt)(t.onFailure(r.success))}return r4(e,t)}),ne=(0,y.XY)(2,(e,t)=>tN(e)?"Success"===e._tag?(0,P.xt)(t.onSuccess(e.value)):(0,P.xt)(t.onFailure(e.cause)):r8(e,t)),nt=e=>tN(e)?(0,P.xt)(e):nr(e),nr=(0,P.Uf)({op:"Exit",[P._3](e){return e._stack.push(this),this[P.a2]},[P.ee]:(e,t,r)=>t.succeedWith(r??(0,P.xt)(e)),[P.Sc]:(e,t,r)=>t.succeedWith(r??(0,P.cb)(e))}),nn=r7({onFailure:()=>!0,onSuccess:()=>!1}),ni=r7({onFailure:()=>!1,onSuccess:()=>!0}),na=(0,y.XY)(2,(e,t)=>tS(ab(t),e)),ns=(0,y.XY)(2,(e,t)=>tP(nl(e,t.duration),e=>b.isNone(e)?t.orElse():eF(e.value))),no=(0,y.XY)(2,(e,t)=>{let r=m.bN(t);return ns(e,{duration:r,orElse:()=>eL(new aS(`Operation timed out after '${m.GP(r)}'`))})}),nl=(0,y.XY)(2,(e,t)=>tM(tw(e),tu(ab(t),b.none()))),nd=e=>ay(t=>{let r=t.monotonicTimeNanosUnsafe();return tD(e,e=>[m.cF(t.monotonicTimeNanosUnsafe()-r),e])}),nc="~effect/Scope",nu="~effect/Scope/Closeable",nf=h.kl("effect/Scope"),np=(e,t)=>(0,P.R6)(r=>{let n=nh(e,t);return void 0===n?e1:(n6(r),n)}),nh=(e,t)=>{let r=e.state;if("Closed"===r._tag||(e.state={_tag:"Closed",exit:t},void 0!==e.parent&&nk(e.parent,e),"Empty"===r._tag))return;if(void 0!==r.finalizer)return nm(r.finalizer,t);let n=r.finalizers;return 1===n.size?nm(n.values().next().value,t):ny(e,n,t)},nm=(e,t)=>{try{return e(t)}catch(e){return(0,P.V2)(e)}},ng=(e,t)=>tW(e)?t:rw(t,t=>eB((0,P.h2)(e.cause,t))),ny=tn(function*(e,t,r){let n=[],i=[],a=Array.from(t.values()),s=ek();for(let t=a.length-1;t>=0;t--){let o=a[t];"sequential"===e.strategy?n.push((yield*nt(nm(o,r)))):i.push(iT(s,nm(o,r),!0,!0,"inherit"))}return i.length>0&&(n=yield*eP(i)),yield*t4(n)}),nb=(e,t)=>ez(()=>nv(e,t)),nv=(e,t)=>{let r=nI(t,e);return"Closed"===e.state._tag?r.state=e.state:nw(e,r,e=>np(r,e)),r},n_=(e,t)=>eW(()=>"Closed"===e.state._tag?t(e.state.exit):(nw(e,{},t),e1)),nx=(e,t)=>n_(e,(0,y.dY)(t)),nw=(e,t,r)=>{if("Empty"===e.state._tag)e.state={_tag:"Open",finalizerKey:t,finalizer:r,finalizers:void 0};else if("Open"===e.state._tag){let n=e.state;void 0!==n.finalizer&&(n.finalizers=new Map([[n.finalizerKey,n.finalizer]]),n.finalizerKey=void 0,n.finalizer=void 0),n.finalizers.set(t,r)}},nk=(e,t)=>{if("Open"!==e.state._tag)return;let r=e.state;r.finalizerKey===t?e.state=n$:void 0!==r.finalizers&&(r.finalizers.delete(t),0===r.finalizers.size&&(e.state=n$))},nS=e=>nI(e,void 0),nI=(e="sequential",t)=>({[nu]:nu,[nc]:nc,strategy:e,parent:t,state:n$}),n$={_tag:"Empty"},nE=e=>ez(()=>nS(e)),nO=nf,nC=rf(nf),nT=e=>(0,P.R6)(t=>{let r=t.context,n=nS();return t.setContext(h.WQ(t.context,nf,n)),nD(t,e=>(t.setContext(r),nh(n,e))),e}),nM=(0,y.XY)(2,(e,t)=>nU(nC(e,t),e=>eW(()=>nh(t,e)??e1))),nP=e=>eW(()=>{let t=nS();return nU(e(t),e=>eW(()=>nh(t,e)??e1))}),nA=(e,t,r)=>rd(n=>n9(i=>tP(nO,a=>tI(r?.interruptible?i(e):e,e=>n_(a,r=>ru(t(e,r),n)))))),nN=e=>tP(nO,t=>rd(r=>n_(t,t=>ru(e(t),r)))),nR=(l=(0,P.yj)({op:"OnExit",[P._3](e){return e._stack.push(this),this.effect},[P.u4](e){e.interruptible&&!0!==this.interruptible&&(e._stack.push(n2),e.interruptible=!1)},[P.ee](e,t,r){let n;r??=(0,P.xt)(e);try{n=this.onExit(r)}catch(e){n=(0,P.V2)(e)}return n?tP(n,e=>r):r},[P.Sc](e,t,r){let n;r??=(0,P.cb)(e);try{n=this.onExit(r)}catch(e){n=(0,P.V2)(e)}return n?tP(ng(r,n),e=>r):r}}),(d=function(e,t,r){this.effect=e,this.onExit=t,this.interruptible=r}).prototype=l,d),nj=(e,t,r)=>new nR(e,t,r),nD=(e,t)=>{e._stack.push(new nR(void 0,t,void 0))},nU=(0,y.XY)(2,nj),nF=(0,y.XY)(2,(e,t)=>nU(e,e=>t)),nB=(0,y.XY)(3,(e,t,r)=>nU(e,e=>t(e)?r(e):e1)),nL=(0,y.XY)(3,(e,t,r)=>nU(e,e=>{let n=t(e);return _.N6(n)?e1:r(n.success,e)})),nz=(0,y.XY)(2,(e,t)=>nL(e,tG,t)),nW=(0,y.XY)(3,(e,t,r)=>nB(e,e=>"Failure"===e._tag&&t(e.cause),e=>r(e.cause))),nJ=(0,y.XY)(3,(e,t,r)=>nU(e,e=>{if("Failure"!==e._tag)return e1;let n=t(e.cause);return _.N6(n)?e1:r(n.success,e.cause)})),nY=(0,y.XY)(2,(e,t)=>nJ(Z,t)(e)),nX=(e,t,r)=>n9(n=>tP(e,e=>nj(eW(()=>n(t(e))),t=>r(e,t),!0))),nq=e=>nA(e,e=>(0,v.i5)(e,Symbol.asyncDispose)?e5(()=>e[Symbol.asyncDispose]()):ez(()=>e[Symbol.dispose]())),nG=(0,y.XY)(2,(e,t)=>ez(()=>nH(e,"function"==typeof t?e=>m.kE(m.bN(t(e))):(0,y.dY)(m.kE(m.bN(t)))))),nV=(0,y.dY)(1/0),nH=(e,t)=>{let r,n,i=0,a=(e,t)=>(t.awaiters++,nD(e,()=>{if(!(--t.awaiters>0)&&n===t)return n=void 0,eR(t.fiber)}),eA(t.fiber));return[(0,P.R6)(s=>{if(void 0!==n)return a(s,n);if(void 0!==r&&(1/0===i||s.getRef(af).currentTimeMillisUnsafe()<i))return r;r=void 0;let o=s.getRef(af),l={fiber:void 0,awaiters:0};return n=l,l.fiber=iT(s,nj(e,e=>{if(n!==l||(n=void 0,tK(e)))return;let a=t(e);i=1/0===a?1/0:o.currentTimeMillisUnsafe()+a,r=e}),!0,!0),l.fiber._exit??a(s,l)}),ez(()=>{r=void 0})]},nK=(0,y.XY)(2,(e,t)=>tD(nG(e,t),e=>e[0])),nQ=e=>ez(()=>nH(e,nV)[0]),nZ=(0,P.R6)(e=>eB(W(e.id))),n0=e=>(0,P.R6)(t=>(t.interruptible&&(t.interruptible=!1,t._stack.push(n2)),e)),n1=(0,P.Uf)({op:"SetInterruptible",[P.u4](e){if(e.interruptible=this[P.a2],e._interruptedCause&&e.interruptible)return()=>eB(e._interruptedCause)}}),n2=n1(!0),n5=n1(!1),n3=e=>{if(e.interruptible=!0,e._stack.push(n5),e._interruptedCause)return eB(e._interruptedCause)},n6=e=>{e.interruptible&&(e.interruptible=!1,e._stack.push(n2))},n8=e=>(0,P.R6)(t=>t.interruptible?e:n3(t)??e),n9=e=>(0,P.R6)(t=>t.interruptible?(t.interruptible=!1,t._stack.push(n2),e(n8)):e(y.D_)),n4=e=>(0,P.R6)(t=>{if(t.interruptible)return e(y.D_);let r=n3(t),n=e(n0);return r??n}),n7=tD(nA(ez(()=>new AbortController),e=>ez(()=>e.abort())),e=>e.signal),ie=(e,t)=>(0,v.xZ)(e)?t?.mode==="result"?ic(e,rQ,t):ic(e,y.D_,t):t?.discard?"result"===t.mode?ic(Object.values(e),rQ,t):ic(Object.values(e),y.D_,t):eW(()=>{let r={};return tu(ic(Object.entries(e),([e,n])=>tD(t?.mode==="result"?rQ(n):n,t=>{R.x(r,e,t)}),{discard:!0,concurrency:t?.concurrency}),r)}),it=(0,y.XY)(e=>(0,v.xZ)(e[0])&&!(0,P.yw)(e[0]),(e,t,r)=>tD(ic(e,(e,r)=>rQ(t(e,r)),r),e=>p.jB(e,y.D_))),ir=(0,y.XY)(3,(e,t,r)=>{let n=p.Ts(e);return 0===n.length?ez(t):eW(()=>{let e=0,i=t();return tD(id({while:()=>e<n.length,body:()=>r(i,n[e],e),step(t){i=t,e++}}),()=>i)})}),ii=(0,y.XY)(e=>(0,v.xZ)(e[0])&&!(0,P.yw)(e[0]),(e,t,r)=>tP(it(e,t,{concurrency:r?.concurrency}),([e,t])=>p.CZ(t)?eL(t):r?.discard?e1:eF(e))),ia=(0,y.XY)(e=>(0,v.xZ)(e[0])&&!(0,P.yw)(e[0]),(e,t)=>eW(()=>{let r=e[Symbol.iterator](),n=r.next();return n.done?eF(b.none()):is(r,0,t,n.value)})),is=(e,t,r,n)=>tP(r(n,t),i=>{if(i)return eF(b.some(n));let a=e.next();return a.done?eF(b.none()):is(e,t+1,r,a.value)}),io=(0,y.XY)(e=>(0,v.xZ)(e[0])&&!(0,P.yw)(e[0]),(e,t)=>eW(()=>{let r=e[Symbol.iterator](),n=r.next();return n.done?eF(b.none()):il(r,0,t,n.value)})),il=(e,t,r,n)=>tP(r(n,t),n=>{if(_.oJ(n))return eF(b.some(n.success));let i=e.next();return i.done?eF(b.none()):il(e,t+1,r,i.value)}),id=(0,P.Uf)({op:"While",[P.ee](e,t){return(this[P.a2].step(e),this[P.a2].while())?(t._stack.push(this),this[P.a2].body()):t0},[P._3](e){return this[P.a2].while()?(e._stack.push(this),this[P.a2].body()):t0}}),ic=(0,y.XY)(e=>"function"==typeof e[1],(e,t,r)=>eW(()=>{let n=ih(r?.concurrency);if(1===n)return ip(e,t,r);let i=p.Ts(e),a=i.length;if(0===a)return r?.discard?e1:eF([]);let s=r?.discard?void 0:Array(a),o=ib({f:t,out:s},i,{concurrency:n});return o?tu(o,s):eF(s)})),iu=e=>tP(e,e=>{let t=e[Symbol.iterator]().next();return t.done?eL(new P.Xm):eF(t.value)}),ip=(e,t,r)=>eW(()=>{let n=r?.discard?void 0:[],i=e[Symbol.iterator](),a=i.next(),s=0;return tu(id({while:()=>!a.done,body:()=>t(a.value,s++),step:e=>{n&&n.push(e),a=i.next()}}),n)}),ih=e=>"unbounded"===e?1/0:Math.max(1,e??1),im=()=>e=>{let t=e.onItem,r=e.step,n=(e,t,n,a,s)=>tP(nt(s),s=>r(e,t[n],s,n)??i(e,t,n+1,a)??e1),i=(e,i,a=0,s=i.length)=>{for(;a<s;a++){let o=i[a],l=t(e,o,a);if(!tN(l))return n(e,i,a,s,l);let d=r(e,o,l,a);if(d)return"Failure"===d._tag?d:void 0}};return i},ig=e=>{let t=e.onItem,r=e.step;return(e,n,i)=>{let a,s,o,l,d,c=0,u=i.end??n.length,f=i.concurrency,p=!1,h=e=>{let t=(0,P.V2)(e);return l=t,p=!0,s&&s.size>0?tP(n0(eD(Array.from(s))),()=>l??t):t},m=()=>{let i=!1;for(;!l&&c<u;c++){let u=n[c],g=d??t(e,u,c);if(tN(g)){if(l=r(e,u,g,c))break}else{if(!a)return te(e=>{let t;a=ek(),s=new Set,d=g,o=e;try{t=m()}catch(t){return e(h(t))}return t?e(t):eW(()=>(l??=t0,tP(s?eD(s):e1,()=>l?._tag==="Failure"?l:e1)))});d=void 0;let t=iT(a,g,!0,!0,"inherit");if(t._exit){if(l=r(e,u,t._exit,c))break;continue}s.add(t);let n=c;if(t.addObserver(a=>{s.delete(t);try{if(l){if("Failure"===a._tag){let e=a.cause.reasons.filter(e=>"Interrupt"!==e._tag);if(e.length>0){let t=(0,P.b5)(e);l=(0,P.cb)("Failure"===l._tag?(0,P.h2)(l.cause,t):t)}}}else{let t=r(e,u,a,n);t&&(l=t,m())}if(i){let e=m();e&&o(e)}else p&&0===s.size&&o(l??e1)}catch(e){o(h(e))}}),s.size<f)continue;i=!0,c++;return}}if(p=!0,l){if(s&&s.size>0){let e=eC(a);s.forEach(t=>t.interruptUnsafe(a.id,e));return}if(o||"Failure"===l._tag)return l}else if(o)if(!s)return t0;else 0===s.size&&o(e1)};return m()}},iy=()=>e=>ig(e),ib=ig({onItem:(e,t,r)=>e.f(t,r),step(e,t,r,n){if("Failure"===r._tag)return r;e.out&&(e.out[n]=r.value)}}),iv=(0,y.XY)(3,(e,t,r)=>tP(e,e=>t(e)?eF(e):r(e))),i_=(0,y.XY)(3,(e,t,r)=>tP(e,e=>{let n=t(e);return _.N6(n)?r(n.failure):eF(n.success)})),ix=(0,y.XY)(e=>(0,P.yw)(e[0]),(e,t,r)=>i_(e,t,r?e=>eL(r(e)):()=>eL(new P.Xm))),iw=(0,y.XY)(e=>(0,v.xZ)(e[0])&&!(0,P.yw)(e[0]),(e,t,r)=>eW(()=>{let n=[];return tu(ic(e,(e,r)=>{let i=t(e,r);return"boolean"==typeof i?(i&&n.push(e),e1):tD(i,t=>{t&&n.push(e)})},{discard:!0,concurrency:r?.concurrency}),n)})),ik=(0,y.XY)(e=>(0,v.xZ)(e[0])&&!(0,P.yw)(e[0]),(e,t)=>eW(()=>{let r=[];for(let n of e){let e=t(n);_.oJ(e)&&r.push(e.success)}return eF(r)})),iS=(0,y.XY)(e=>(0,v.xZ)(e[0])&&!(0,P.yw)(e[0]),(e,t,r)=>eW(()=>{let n=[];return tu(ic(e,e=>tD(t(e),e=>{_.oJ(e)&&n.push(e.success)}),{discard:!0,concurrency:r?.concurrency}),n)})),iI=eF({}),i$=A.Jr(tD),iE=A.oI(tD,tP),iO=A.zM(tD),iC=(0,y.XY)(e=>(0,P.yw)(e[0]),(e,t)=>(0,P.R6)(r=>(eO.interruptChildren??=eT,eF(iT(r,e,t?.startImmediately,!1,t?.uninterruptible??!1))))),iT=(e,t,r=!1,n=!1,i=!1)=>{let a="inherit"===i?e.interruptible:!i,s=new eS(e.context,a);return r?s.evaluate(t):(s._asyncContext=ew(),e.currentDispatcher.scheduleTask(()=>s.evaluate(t),0)),n||s._exit||(e.children().add(s),s._parent=e),s},iM=(0,y.XY)(e=>(0,P.yw)(e[0]),(e,t)=>(0,P.R6)(r=>eF(iT(r,e,t?.startImmediately,!0,t?.uninterruptible)))),iP=e=>(0,P.R6)(t=>{let r=t._children&&new Set(t._children),n=t.interruptible;return nj(e,e=>{let i=t._children;if(void 0===i||0===i.size)return e1;r&&(i=I.pb(i,e=>!r.has(e)));let a=t$(eP(i));return n?n8(a):a})}),iA=(0,y.XY)(e=>(0,P.yw)(e[0]),(e,t,r)=>(0,P.R6)(n=>{let i=iT(n,e,r?.startImmediately,!0,r?.uninterruptible);if(!i._exit)if("Closed"!==t.state._tag){let e={};nw(t,e,()=>e6(e=>e===i.id?e1:eR(i))),i.addObserver(()=>nk(t,e))}else i.interruptUnsafe(n.id,eC(n));return eF(i)})),iN=(0,y.XY)(e=>(0,P.yw)(e[0]),(e,t)=>tP(nO,r=>iA(e,r,t))),iR=e=>(t,r)=>{let n=new eS(r?.scheduler?h.WQ(e,C._F,r.scheduler):e,r?.uninterruptible!==!0);if(n.evaluate(t),n._exit)return n;if(r?.signal)if(r.signal.aborted)n.interruptUnsafe();else{let e=()=>n.interruptUnsafe();r.signal.addEventListener("abort",e,{once:!0}),n.addObserver(()=>r.signal.removeEventListener("abort",e))}return r?.onFiberStart&&r.onFiberStart(n),n},ij=(0,y.XY)(2,(e,t)=>{if(e._exit)return e;if("Closed"===t.state._tag)return e.interruptUnsafe(e.id),e;let r={};return nw(t,r,()=>eR(e)),e.addObserver(()=>nk(t,r)),e}),iD=iR(h.Ie()),iU=e=>{let t=iR(e);return(e,r)=>{let n=t(e,r);return r?.onExit&&n.addObserver(r.onExit),e=>n.interruptUnsafe(e)}},iF=iU(h.Ie()),iB=e=>{let t=iR(e);return(e,r)=>{let n=t(e,r);return new Promise(e=>{n.addObserver(t=>e(t))})}},iL=iB(h.Ie()),iz=e=>{let t=iB(e);return(e,r)=>t(e,r).then(e=>{if("Failure"===e._tag)throw es(e.cause);return e.value})},iW=iz(h.Ie()),iJ=e=>{let t=iR(e);return e=>{if(tN(e))return e;let r=t(e,{scheduler:new C.FG("sync")});return r._dispatcher?.flush(),r._exit??(0,P.V2)(new aA(r))}},iY=iJ(h.Ie()),iX=e=>{let t=iJ(e);return e=>{let r=t(e);if("Failure"===r._tag)throw es(r.cause);return r.value}},iq=iX(h.Ie()),iG=eF(!0),iV=eF(!1);class iH{waiters=[];scheduled=void 0;_isOpen;constructor(e){this._isOpen=e}scheduleUnsafe(e){if(0===this.waiters.length)return iG;if(void 0===this.scheduled)this.scheduled=this.waiters,e.currentDispatcher.scheduleTask(this.flushScheduled,0);else for(let e=0;e<this.waiters.length;e++)this.scheduled.push(this.waiters[e]);return this.waiters=[],iG}flushScheduled=()=>{if(void 0===this.scheduled)return;let e=this.scheduled;this.scheduled=void 0;for(let t=0;t<e.length;t++)e[t](t0)};flushWaiters(){let e=this.waiters;this.waiters=[],this.flushScheduled();for(let t=0;t<e.length;t++)e[t](t0)}open=(0,P.R6)(e=>this._isOpen?iV:(this._isOpen=!0,this.scheduleUnsafe(e)));release=(0,P.R6)(e=>this._isOpen?iV:this.scheduleUnsafe(e));openUnsafe(){return!this._isOpen&&(this._isOpen=!0,this.flushWaiters(),!0)}await=te(e=>this._isOpen?e(e1):(this.waiters.push(e),ez(()=>{let t=this.waiters.indexOf(e);-1!==t?this.waiters.splice(t,1):void 0!==this.scheduled&&-1!==(t=this.scheduled.indexOf(e))&&this.scheduled.splice(t,1)})));closeUnsafe(){return!!this._isOpen&&(this._isOpen=!1,!0)}close=ez(()=>this.closeUnsafe());whenOpen=e=>tP(this.await,()=>e);isOpen(){return this._isOpen}}let iK=e=>new iH(e??!1),iQ=e=>ez(()=>iK(e)),iZ=(0,P.R6)(e=>eF(e.getRef(T.sh))),i0=(0,y.XY)(2,(e,t)=>rf(e,T.sh,t)),i1=rf(j.rf),i2=rf(j.nU),i5=BigInt(0),i3={_tag:"Span",spanId:"noop",traceId:"noop",sampled:!1,status:{_tag:"Ended",startTime:i5,endTime:i5,exit:t0},attributes:new Map,links:[],kind:"internal",attribute(){},event(){},end(){},addLinks(){}},i6=e=>e?h.Jt(e.annotations,T.DW)?"Span"===e._tag?i6(b.getOrUndefined(e.parent)):b.none():b.some(e):b.none(),i8=(e,t,r)=>{let n,i=!e.cache.tracerEnabled||r?.annotations&&h.Jt(r.annotations,T.DW),a=r?.parent!==void 0?b.some(r.parent):r?.root?b.none():i6(e.cache.span);if(i){let e;e={name:t,parent:a,annotations:h.WQ(r?.annotations??h.Ie(),T.DW,!0)},n=Object.assign(Object.create(i3),e)}else{let i=e.cache.tracer??T.Vv,s=e.getRef(af),o=e.getRef(j.nU),l=e.getRef(j.ce),d=e.getRef(j.ls),c=r?.level??e.getRef(T.pX),u=r?.links!==void 0?[...d,...r.links]:0===d.length?[]:d.slice();for(let d in n=i.span({name:t,parent:a,annotations:r?.annotations??h.Ie(),links:u,startTime:o?s.currentTimeNanosUnsafe():i5,kind:r?.kind??"internal",root:r?.root??b.isNone(a),sampled:r?.sampled??((!b.isSome(a)||!1!==a.value.sampled)&&!aF(e.getRef(T.EW),c))}),l)n.attribute(d,l[d]);if(r?.attributes!==void 0)for(let e in r.attributes)n.attribute(e,r.attributes[e])}return n},i9=(e,t)=>(0,P.R6)(r=>eF(i8(r,e,t))),i4=(e,t)=>n0((0,P.R6)(r=>{let n=h.fp(r.context,nf),i=i8(r,e,t??{}),a=r.getRef(af),s=r.getRef(j.nU);return tu(n_(n,e=>an(i,e,a,s)),i)})),i7=function(){let e="string"!=typeof arguments[0],t=e?arguments[1]:arguments[0],r=U(e?arguments[2]:arguments[1]);if(e){let e=arguments[0];return tP(i4(t,r),t=>as(e,t,r))}return e=>tP(i4(t,r),t=>as(e,t,r))},ae=j.ce,at=j.ls,ar=(0,y.XY)(e=>(0,P.yw)(e[0]),(e,t,r={})=>{let n=(Array.isArray(t)?t:[t]).map(e=>({span:e,attributes:r}));return ra(e,j.ls,e=>[...e,...n])}),an=(e,t,r,n)=>ez(()=>{"Ended"!==e.status._tag&&e.end(n?r.currentTimeNanosUnsafe():i5,t)}),ai=(e,...t)=>{let r=1===t.length?void 0:t[0],n=t[t.length-1];return(0,P.R6)(t=>{let i=i8(t,e,r),a=t.getRef(af),s=t.getRef(j.nU);return nD(t,e=>an(i,e,a,s)),n(i)})},aa=rf(T.Tv),as=function(){let e=(0,P.yw)(arguments[0]),t=e?arguments[1]:arguments[0],r=e?arguments[2]:arguments[1],n=y.D_;if("Span"===t._tag){var i,a;r=U(r),i=t.name,a="function"==typeof(a=r?.captureStackTrace)?a:y.MN,n=ra(j.vA,e=>({name:i,stack:a,parent:e}))}return e?aa(n(arguments[0]),t):e=>aa(n(e),t)},ao=function(){let e="string"!=typeof arguments[0],t=e?arguments[1]:arguments[0],r=U(arguments[2]);if(e){let e=arguments[0];return ai(t,arguments[2],t=>as(e,t,r))}let n="function"==typeof arguments[1]?arguments[1]:void 0,i=n?void 0:arguments[1];return(e,...a)=>ai(t,n?n(...a):i,t=>as(e,t,r))},al=(0,y.XY)(e=>(0,P.yw)(e[0]),(e,...t)=>ra(e,j.ce,e=>{let r=1===t.length?{...e,...t[0]}:{...e};return 1===t.length||R.x(r,t[0],t[1]),r})),ad=(...e)=>(0,P.R6)(t=>{let r=t.currentSpanLocal;if(r)if(1===e.length)for(let[t,n]of Object.entries(e[0]))r.attribute(t,n);else r.attribute(e[0],e[1]);return e1}),ac=(0,P.R6)(e=>{let t=e.currentSpanLocal;return t?eF(t):eL(new P.Xm)}),au=(c=T.Tv,(0,P.R6)(e=>eJ(h.om(e.context,c)))),af=h.Or("effect/Clock",{defaultValue:()=>new ap});class ap{currentTimeMillisUnsafe(){return Date.now()}currentTimeMillis=ez(()=>this.currentTimeMillisUnsafe());currentTimeNanosUnsafe(){return ag()}currentTimeNanos=ez(()=>this.currentTimeNanosUnsafe());monotonicTimeNanosUnsafe(){return am()}monotonicTimeNanos=ez(()=>this.monotonicTimeNanosUnsafe());sleep(e){return this.sleepMillis(m.kE(e))}sleepMillis(e){return e<=0?eG:Number.isFinite(e)?te(t=>{let r=e>0x7fffffff?this.sleepMillis(e-0x7fffffff):e1,n=setTimeout(()=>t(r),Math.min(e,0x7fffffff));return ez(()=>clearTimeout(n))}):tt}}let ah=BigInt(1e6),am=function(){let e=globalThis.process?.hrtime;if("function"==typeof e?.bigint)return()=>e.bigint();if("u">typeof performance&&"function"==typeof performance.now)return()=>BigInt(Math.round(1e6*performance.now()));let t=BigInt(0);return()=>{let e=BigInt(Date.now())*ah;return e>t&&(t=e),t}}(),ag=(f=BigInt(1e9),()=>{let e=am(),t=BigInt(Date.now())*ah;if(void 0===u)u=t-e;else{let r=u+e;(t>r?t-r:r-t)>f&&(u=t-e)}return u+e}),ay=e=>(0,P.R6)(t=>e(t.getRef(af))),ab=e=>ay(t=>t.sleep(m.bN(e))),av=ay(e=>e.currentTimeMillis),a_=ay(e=>e.currentTimeNanos),ax=ay(e=>e.monotonicTimeNanos),aw="~effect/Cause/TimeoutError",ak=e=>(0,v.i5)(e,aw);class aS extends(0,P.rN)("TimeoutError"){[aw]=aw;constructor(e){super({message:e})}}let aI="~effect/Cause/IllegalArgumentError",a$=e=>(0,v.i5)(e,aI);class aE extends(0,P.rN)("IllegalArgumentError"){[aI]=aI;constructor(e){super({message:e})}}let aO="~effect/Cause/ExceededCapacityError",aC=e=>(0,v.i5)(e,aO);class aT extends(0,P.rN)("ExceededCapacityError"){[aO]=aO;constructor(e){super({message:e})}}let aM="~effect/Cause/AsyncFiberError",aP=e=>(0,v.i5)(e,aM);class aA extends(0,P.rN)("AsyncFiberError"){[aM]=aM;constructor(e){super({message:"An asynchronous Effect was executed with Effect.runSync",fiber:e})}}let aN="~effect/Cause/UnknownError",aR=e=>(0,v.i5)(e,aN);class aj extends(0,P.rN)("UnknownError"){[aN]=aN;constructor(e,t){super({message:t,cause:e})}}let aD=h.Or("effect/Console",{defaultValue:()=>globalThis.console}),aU=$.zQ($.wN,e=>{switch(e){case"All":return Number.MIN_SAFE_INTEGER;case"Fatal":return 5e4;case"Error":return 4e4;case"Warn":return 3e4;case"Info":return 2e4;case"Debug":return 1e4;case"Trace":return 0;case"None":return Number.MAX_SAFE_INTEGER}}),aF=$.yJ(aU),aB=h.Or("effect/Logger/CurrentLoggers",{defaultValue:()=>new Set([aq,aG])}),aL=h.Or("effect/Logger/LogToStderr",{defaultValue:y.f4}),az=function(){let e="string"==typeof arguments[0]?[[arguments[0],arguments[1]]]:Object.entries(arguments[0]);return n0((0,P.R6)(t=>{let r=t.getRef(j.iL),n={...r};for(let t=0;t<e.length;t++){let[r,i]=e[t];R.x(n,r,i)}return t.setContext(h.WQ(t.context,j.iL,n)),n_(h.fp(t.context,nf),n=>{let i=t.getRef(j.iL),a={...i};for(let t=0;t<e.length;t++){let[n,s]=e[t];(i[n]===s||Object.is(i[n],s))&&(Object.hasOwn(r,n)?R.x(a,n,r[n]):delete a[n])}return t.setContext(h.WQ(t.context,j.iL,a)),e1})}))},aW={"~effect/Logger":{_Message:y.D_,_Output:y.D_},pipe(){return(0,E.tT)(this,arguments)}},aJ=e=>{let t=Object.create(aW);return t.log=e,t},aY=(e,t)=>{let r=e[0].replace(/[\s="]/g,"_");return`${r}=${t-e[1]}ms`},aX=e=>(...t)=>{let r;for(let e=0,n=t.length;e<n;e++){let n=t[e];(0,P.Aj)(n)&&(r?t.splice(e,1):t=t.slice(0,e).concat(t.slice(e+1)),r=r?(0,P.b5)(r.reasons.concat(n.reasons)):n,e--)}return void 0===r&&(r=P.DH),(0,P.R6)(n=>{let i=e??n.cache.logLevel;if(aF(n.cache.minimumLogLevel,i))return e1;let a=n.getRef(af),s=n.getRef(aB);if(s.size>0){let e=new Date(a.currentTimeMillisUnsafe());for(let a of s)a.log({cause:r,fiber:n,date:e,logLevel:i,message:t})}return e1})},aq=aJ(({cause:e,date:t,fiber:r,logLevel:n,message:i})=>{let a=Array.isArray(i)?i.slice():[i];e.reasons.length>0&&a.push(em(e));let s=t.getTime(),o=r.getRef(j.d8),l="";for(let e of o)l+=` ${aY(e,s)}`;let d=r.getRef(j.iL);Object.keys(d).length>0&&a.push(d);let c=r.getRef(aD);(r.getRef(aL)?c.error:c.log)(`[${t.getHours().toString().padStart(2,"0")}:${t.getMinutes().toString().padStart(2,"0")}:${t.getSeconds().toString().padStart(2,"0")}.${t.getMilliseconds().toString().padStart(3,"0")}] ${n.toUpperCase()} (#${r.id})${l}:`,...a)}),aG=aJ(({cause:e,fiber:t,logLevel:r,message:n})=>{let i=t.getRef(af),a=t.getRef(j.iL),s=t.cache.span;if(void 0===s||"ExternalSpan"===s._tag)return;let o={};for(let[e,t]of Object.entries(a))R.x(o,e,t);o["effect.fiberId"]=t.id,o["effect.logLevel"]=r.toUpperCase(),e.reasons.length>0&&(o["effect.cause"]=em(e)),s.event((0,S.ZK)(Array.isArray(n)&&1===n.length?n[0]:n),i.currentTimeNanosUnsafe(),o)}),aV=eF(void 0),aH=(0,y.XY)(e=>(0,P.yw)(e[0]),(e,t)=>nz(e,e=>(0,P.R6)(r=>(aK(r,e,t?.defectsOnly),e1)))),aK=(e,t,r)=>{let n=e.getRef(j.oQ);if(0===n.size||r&&!G(t))return;let i={cause:t,fiber:e,timestamp:e.getRef(af).currentTimeNanosUnsafe()};n.forEach(e=>e.report(i))}},5844(e,t,r){let n=new WeakSet;r.d(t,{},{J3:n,Xp:e=>{let t=new Set(Reflect.ownKeys(e));if(e.constructor===Object)return t;e instanceof Error&&t.delete("stack");let r=Object.getPrototypeOf(e),n=r;for(;null!==n&&n!==Object.prototype;){let e=Reflect.ownKeys(n);for(let r=0;r<e.length;r++)t.add(e[r]);n=Object.getPrototypeOf(n)}return t.has("constructor")&&"function"==typeof e.constructor&&r===e.constructor.prototype&&t.delete("constructor"),t},j:e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength)})},7258(e,t,r){r.d(t,{},{F:"effect/Metric/FiberRuntimeMetrics"})},7731(e,t,r){var n=r(3332),i=r(1958),a=r(5033),s=r(3952),o=r(4233),l=r(6481),d=r(2449);let c="~effect/Option",u={[c]:{_A:e=>e},...d.fU,[Symbol.iterator](){return new l.B(this)}},f=Object.defineProperty(Object.assign(Object.create(u),{_tag:"Some",_op:"Some",[n.HR](e){return m(e)&&y(e)&&n.aI(this.value,e.value)},[a.HR](){return a.kg(a.tW(this._tag))(a.tW(this.value))},toString(){return`some(${(0,i.GP)(this.value)})`},toJSON(){return{_id:"Option",_tag:this._tag,value:(0,s.aB)(this.value)}}}),"valueOrUndefined",{get(){return this.value}}),p=a.tW("None"),h=Object.assign(Object.create(u),{_tag:"None",_op:"None",valueOrUndefined:void 0,[n.HR]:e=>m(e)&&g(e),[a.HR]:()=>p,toString:()=>"none()",toJSON(){return{_id:"Option",_tag:this._tag}}}),m=e=>(0,o.i5)(e,c),g=e=>"None"===e._tag,y=e=>"Some"===e._tag,b=Object.create(h),v=function(e){this.value=e};v.prototype=f,r.d(t,{},{$I:g,Ru:y,dv:b,oL:m,zN:e=>new v(e)})},2275(e,t,r){function n(e,t,r){"__proto__"===t?Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0}):e[t]=r}function i(e,t){for(let r of Reflect.ownKeys(t))Object.prototype.propertyIsEnumerable.call(t,r)&&n(e,r,t[r])}r.d(t,{x:()=>n,z:()=>i})},6712(e,t,r){var n=r(1179),i=r(1594);let a=n.Or("effect/ErrorReporter/CurrentErrorReporters",{defaultValue:()=>new Set}),s=n.Or("effect/References/CurrentStackFrame",{fiberCached:!0,defaultValue:i.MN}),o=n.Or("effect/References/TracerEnabled",{fiberCached:!0,defaultValue:i.ue}),l=n.Or("effect/References/TracerTimingEnabled",{defaultValue:i.ue}),d=n.Or("effect/References/TracerSpanAnnotations",{defaultValue:()=>({})}),c=n.Or("effect/References/TracerSpanLinks",{defaultValue:()=>[]}),u=n.Or("effect/References/CurrentLogAnnotations",{defaultValue:()=>({})}),f=n.Or("effect/References/CurrentLogLevel",{fiberCached:!0,defaultValue:()=>"Info"}),p=n.Or("effect/References/MinimumLogLevel",{fiberCached:!0,defaultValue:()=>"Info"}),h=n.Or("effect/References/UnhandledLogLevel",{defaultValue:()=>"Error"}),m=n.Or("effect/References/CurrentLogSpans",{defaultValue:()=>[]});r.d(t,{},{Gl:f,aG:h,ce:d,d8:m,iL:u,ls:c,nU:l,oQ:a,rf:o,vA:s,zQ:p})},2563(e,t,r){var n=r(3332),i=r(1958),a=r(1594),s=r(5033),o=r(3952),l=r(4233),d=r(6481),c=r(2449),u=r(7731);let f="~effect/Result",p={[f]:{_A:e=>e,_E:e=>e},...c.fU,[Symbol.iterator](){return new d.B(this)}},h=Object.assign(Object.create(p),{_tag:"Success",_op:"Success",[n.HR](e){return g(e)&&b(e)&&n.aI(this.success,e.success)},[s.HR](){return s.kg(s.tW(this._tag))(s.tW(this.success))},toString(){return`success(${(0,i.GP)(this.success)})`},toJSON(){return{_id:"Result",_tag:this._tag,value:(0,o.aB)(this.success)}}}),m=Object.assign(Object.create(p),{_tag:"Failure",_op:"Failure",[n.HR](e){return g(e)&&y(e)&&n.aI(this.failure,e.failure)},[s.HR](){return s.kg(s.tW(this._tag))(s.tW(this.failure))},toString(){return`failure(${(0,i.GP)(this.failure)})`},toJSON(){return{_id:"Result",_tag:this._tag,failure:(0,o.aB)(this.failure)}}}),g=e=>(0,l.i5)(e,f),y=e=>"Failure"===e._tag,b=e=>"Success"===e._tag,v=function(e){this.failure=e};v.prototype=m;let _=e=>new v(e),x=function(e){this.success=e};x.prototype=h;let w=e=>new x(e),k=(0,a.XY)(2,(e,t)=>u.$I(e)?_(t()):w(e.value));r.d(t,{},{L8:e=>b(e)?u.dv:u.zN(e.failure),N6:y,Oz:e=>y(e)?u.dv:u.zN(e.success),Py:w,aI:g,fJ:_,oJ:b,sV:k})},2840(e,t,r){var n=r(1594);function i(e){return e.checks?e.checks[e.checks.length-1].annotations:e.annotations}function a(e){return t=>i(t)?.[e]}let s="~structural",o="~identifier",l="~sentinels",d=a("identifier"),c=a(o),u=a("title"),f=a("description"),p=(0,n.Bj)(e=>{let t=i(e)?.identifier;return"string"==typeof t?t:e.getExpected(p)}),h=new Set([l,s,"representation","arbitraryConstraint","toJsonSchema","toCode","toEquivalence","toFormatter","toCodec","toCodecJson","toCodecStringTree","toCodecIso","toCodecArbitrary"]);r.d(t,{hd:()=>i,ip:()=>a},{C3:s,CD:c,DQ:u,I_:l,KE:d,L1:["title","description","default","examples","readOnly","writeOnly","format","contentEncoding","contentMediaType","contentSchema"],Pk:f,R4:o,UI:h,bo:p,py:"~constructor"})},8253(e,t,r){var n=r(719),i=r(7086);function a(e){let t;for(let r of e.reasons){if(!n.lC(r)||!i.gh(r.error))return;t??=r.error}return t}function s(e,t){let r=a(e);if(void 0===r)throw Error(t,{cause:e});return r}r.d(t,{R:()=>a,q:()=>s})},587(e,t,r){var n=r(6526),i=r(1587);let a=Symbol(),s=n.Py,o=s(a),l=s(a);r.d(t,{},{LO:a,Py:s,Rr:l,e8:e=>"None"===e._tag?o:s(e.value),r2:o,zL:e=>e===a?i.none():i.some(e)})},5340(e,t,r){let n,i=void 0===(n=Object.getOwnPropertyDescriptor(Error,"stackTraceLimit"))?Object.isExtensible(Error):Object.hasOwn(n,"writable")?!0===n.writable:void 0!==n.set;r.d(t,{},{ft:e=>{i&&(Error.stackTraceLimit=e)},jt:()=>Error.stackTraceLimit})},8689(e,t,r){let n,i,a,s,o;function l(e){let t=e.length;for(;--t>=0;)e[t]=0}let d=573,c=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),u=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),f=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),p=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),h=Array(576);l(h);let m=Array(60);l(m);let g=Array(512);l(g);let y=Array(256);l(y);let b=Array(29);l(b);let v=Array(30);function _(e,t,r,n,i){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=e&&e.length}function x(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}l(v);let w=e=>e<256?g[e]:g[256+(e>>>7)],k=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},S=(e,t,r)=>{e.bi_valid>16-r?(e.bi_buf|=t<<e.bi_valid&65535,k(e,e.bi_buf),e.bi_buf=t>>16-e.bi_valid,e.bi_valid+=r-16):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=r)},I=(e,t,r)=>{S(e,r[2*t],r[2*t+1])},$=(e,t)=>{let r=0;do r|=1&e,e>>>=1,r<<=1;while(--t>0)return r>>>1},E=(e,t,r)=>{let n,i,a=Array(16),s=0;for(n=1;n<=15;n++)a[n]=s=s+r[n-1]<<1;for(i=0;i<=t;i++){let t=e[2*i+1];0!==t&&(e[2*i]=$(a[t]++,t))}},O=e=>{let t;for(t=0;t<286;t++)e.dyn_ltree[2*t]=0;for(t=0;t<30;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0},C=e=>{e.bi_valid>8?k(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},T=(e,t,r,n)=>{let i=2*t,a=2*r;return e[i]<e[a]||e[i]===e[a]&&n[t]<=n[r]},M=(e,t,r)=>{let n=e.heap[r],i=r<<1;for(;i<=e.heap_len&&(i<e.heap_len&&T(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!T(t,n,e.heap[i],e.depth));)e.heap[r]=e.heap[i],r=i,i<<=1;e.heap[r]=n},P=(e,t,r)=>{let n,i,a,s,o=0;if(0!==e.last_lit)do n=e.pending_buf[e.d_buf+2*o]<<8|e.pending_buf[e.d_buf+2*o+1],i=e.pending_buf[e.l_buf+o],o++,0===n?I(e,i,t):(I(e,(a=y[i])+256+1,t),0!==(s=c[a])&&S(e,i-=b[a],s),I(e,a=w(--n),r),0!==(s=u[a])&&S(e,n-=v[a],s));while(o<e.last_lit)I(e,256,t)},A=(e,t)=>{let r,n,i,a=t.dyn_tree,s=t.stat_desc.static_tree,o=t.stat_desc.has_stree,l=t.stat_desc.elems,c=-1;for(e.heap_len=0,e.heap_max=d,r=0;r<l;r++)0!==a[2*r]?(e.heap[++e.heap_len]=c=r,e.depth[r]=0):a[2*r+1]=0;for(;e.heap_len<2;)a[2*(i=e.heap[++e.heap_len]=c<2?++c:0)]=1,e.depth[i]=0,e.opt_len--,o&&(e.static_len-=s[2*i+1]);for(t.max_code=c,r=e.heap_len>>1;r>=1;r--)M(e,a,r);i=l;do r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],M(e,a,1),n=e.heap[1],e.heap[--e.heap_max]=r,e.heap[--e.heap_max]=n,a[2*i]=a[2*r]+a[2*n],e.depth[i]=(e.depth[r]>=e.depth[n]?e.depth[r]:e.depth[n])+1,a[2*r+1]=a[2*n+1]=i,e.heap[1]=i++,M(e,a,1);while(e.heap_len>=2)e.heap[--e.heap_max]=e.heap[1],((e,t)=>{let r,n,i,a,s,o,l=t.dyn_tree,c=t.max_code,u=t.stat_desc.static_tree,f=t.stat_desc.has_stree,p=t.stat_desc.extra_bits,h=t.stat_desc.extra_base,m=t.stat_desc.max_length,g=0;for(a=0;a<=15;a++)e.bl_count[a]=0;for(l[2*e.heap[e.heap_max]+1]=0,r=e.heap_max+1;r<d;r++)(a=l[2*l[2*(n=e.heap[r])+1]+1]+1)>m&&(a=m,g++),l[2*n+1]=a,!(n>c)&&(e.bl_count[a]++,s=0,n>=h&&(s=p[n-h]),o=l[2*n],e.opt_len+=o*(a+s),f&&(e.static_len+=o*(u[2*n+1]+s)));if(0!==g){do{for(a=m-1;0===e.bl_count[a];)a--;e.bl_count[a]--,e.bl_count[a+1]+=2,e.bl_count[m]--,g-=2}while(g>0)for(a=m;0!==a;a--)for(n=e.bl_count[a];0!==n;)!((i=e.heap[--r])>c)&&(l[2*i+1]!==a&&(e.opt_len+=(a-l[2*i+1])*l[2*i],l[2*i+1]=a),n--)}})(e,t),E(a,c,e.bl_count)},N=(e,t,r)=>{let n,i,a=-1,s=t[1],o=0,l=7,d=4;for(0===s&&(l=138,d=3),t[(r+1)*2+1]=65535,n=0;n<=r;n++)i=s,s=t[(n+1)*2+1],++o<l&&i===s||(o<d?e.bl_tree[2*i]+=o:0!==i?(i!==a&&e.bl_tree[2*i]++,e.bl_tree[32]++):o<=10?e.bl_tree[34]++:e.bl_tree[36]++,o=0,a=i,0===s?(l=138,d=3):i===s?(l=6,d=3):(l=7,d=4))},R=(e,t,r)=>{let n,i,a=-1,s=t[1],o=0,l=7,d=4;for(0===s&&(l=138,d=3),n=0;n<=r;n++)if(i=s,s=t[(n+1)*2+1],!(++o<l)||i!==s){if(o<d)do I(e,i,e.bl_tree);while(0!=--o)else 0!==i?(i!==a&&(I(e,i,e.bl_tree),o--),I(e,16,e.bl_tree),S(e,o-3,2)):o<=10?(I(e,17,e.bl_tree),S(e,o-3,3)):(I(e,18,e.bl_tree),S(e,o-11,7));o=0,a=i,0===s?(l=138,d=3):i===s?(l=6,d=3):(l=7,d=4)}},j=!1,D=(e,t,r,n)=>{S(e,0+ +!!n,3),C(e),k(e,r),k(e,~r),e.pending_buf.set(e.window.subarray(t,t+r),e.pending),e.pending+=r};var U={_tr_init:e=>{j||((()=>{let e,t,r,s,o,l=Array(16);for(s=0,r=0;s<28;s++)for(b[s]=r,e=0;e<1<<c[s];e++)y[r++]=s;for(y[r-1]=s,o=0,s=0;s<16;s++)for(v[s]=o,e=0;e<1<<u[s];e++)g[o++]=s;for(o>>=7;s<30;s++)for(v[s]=o<<7,e=0;e<1<<u[s]-7;e++)g[256+o++]=s;for(t=0;t<=15;t++)l[t]=0;for(e=0;e<=143;)h[2*e+1]=8,e++,l[8]++;for(;e<=255;)h[2*e+1]=9,e++,l[9]++;for(;e<=279;)h[2*e+1]=7,e++,l[7]++;for(;e<=287;)h[2*e+1]=8,e++,l[8]++;for(E(h,287,l),e=0;e<30;e++)m[2*e+1]=5,m[2*e]=$(e,5);n=new _(h,c,257,286,15),i=new _(m,u,0,30,15),a=new _([],f,0,19,7)})(),j=!0),e.l_desc=new x(e.dyn_ltree,n),e.d_desc=new x(e.dyn_dtree,i),e.bl_desc=new x(e.bl_tree,a),e.bi_buf=0,e.bi_valid=0,O(e)},_tr_stored_block:D,_tr_flush_block:(e,t,r,n)=>{let i,a,s=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=(e=>{let t,r=0xf3ffc07f;for(t=0;t<=31;t++,r>>>=1)if(1&r&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<256;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0})(e)),A(e,e.l_desc),A(e,e.d_desc),s=(e=>{let t;for(N(e,e.dyn_ltree,e.l_desc.max_code),N(e,e.dyn_dtree,e.d_desc.max_code),A(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*p[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),i=e.opt_len+3+7>>>3,(a=e.static_len+3+7>>>3)<=i&&(i=a)):i=a=r+5,r+4<=i&&-1!==t?D(e,t,r,n):4===e.strategy||a===i?(S(e,2+ +!!n,3),P(e,h,m)):(S(e,4+ +!!n,3),((e,t,r,n)=>{let i;for(S(e,t-257,5),S(e,r-1,5),S(e,n-4,4),i=0;i<n;i++)S(e,e.bl_tree[2*p[i]+1],3);R(e,e.dyn_ltree,t-1),R(e,e.dyn_dtree,r-1)})(e,e.l_desc.max_code+1,e.d_desc.max_code+1,s+1),P(e,e.dyn_ltree,e.dyn_dtree)),O(e),n&&C(e)},_tr_tally:(e,t,r)=>(e.pending_buf[e.d_buf+2*e.last_lit]=t>>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&r,e.last_lit++,0===t?e.dyn_ltree[2*r]++:(e.matches++,t--,e.dyn_ltree[(y[r]+256+1)*2]++,e.dyn_dtree[2*w(t)]++),e.last_lit===e.lit_bufsize-1),_tr_align:e=>{S(e,2,3),I(e,256,h),16===e.bi_valid?(k(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}},F=(e,t,r,n)=>{let i=65535&e,a=e>>>16&65535,s=0;for(;0!==r;){s=r>2e3?2e3:r,r-=s;do a=a+(i=i+t[n++]|0)|0;while(--s)i%=65521,a%=65521}return i|a<<16};let B=new Uint32Array((()=>{let e,t=[];for(var r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=1&e?0xedb88320^e>>>1:e>>>1;t[r]=e}return t})());var L=(e,t,r,n)=>{let i=n+r;e^=-1;for(let r=n;r<i;r++)e=e>>>8^B[(e^t[r])&255];return -1^e},z={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},W={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};let{_tr_init:J,_tr_stored_block:Y,_tr_flush_block:X,_tr_tally:q,_tr_align:G}=U,{Z_NO_FLUSH:V,Z_PARTIAL_FLUSH:H,Z_FULL_FLUSH:K,Z_FINISH:Q,Z_BLOCK:Z,Z_OK:ee,Z_STREAM_END:et,Z_STREAM_ERROR:er,Z_DATA_ERROR:en,Z_BUF_ERROR:ei,Z_DEFAULT_COMPRESSION:ea,Z_FILTERED:es,Z_HUFFMAN_ONLY:eo,Z_RLE:el,Z_FIXED:ed,Z_DEFAULT_STRATEGY:ec,Z_UNKNOWN:eu,Z_DEFLATED:ef}=W,ep=573,eh=(e,t)=>(e.msg=z[t],t),em=e=>(e<<1)-9*(e>4),eg=e=>{let t=e.length;for(;--t>=0;)e[t]=0},ey=(e,t,r)=>(t<<e.hash_shift^r)&e.hash_mask,eb=e=>{let t=e.state,r=t.pending;r>e.avail_out&&(r=e.avail_out),0!==r&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+r),e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,0===t.pending&&(t.pending_out=0))},ev=(e,t)=>{X(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,eb(e.strm)},e_=(e,t)=>{e.pending_buf[e.pending++]=t},ex=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},ew=(e,t,r,n)=>{let i=e.avail_in;return(i>n&&(i=n),0===i)?0:(e.avail_in-=i,t.set(e.input.subarray(e.next_in,e.next_in+i),r),1===e.state.wrap?e.adler=F(e.adler,t,i,r):2===e.state.wrap&&(e.adler=L(e.adler,t,i,r)),e.next_in+=i,e.total_in+=i,i)},ek=(e,t)=>{let r,n,i=e.max_chain_length,a=e.strstart,s=e.prev_length,o=e.nice_match,l=e.strstart>e.w_size-262?e.strstart-(e.w_size-262):0,d=e.window,c=e.w_mask,u=e.prev,f=e.strstart+258,p=d[a+s-1],h=d[a+s];e.prev_length>=e.good_match&&(i>>=2),o>e.lookahead&&(o=e.lookahead);do{if(d[(r=t)+s]!==h||d[r+s-1]!==p||d[r]!==d[a]||d[++r]!==d[a+1])continue;a+=2,r++;do;while(d[++a]===d[++r]&&d[++a]===d[++r]&&d[++a]===d[++r]&&d[++a]===d[++r]&&d[++a]===d[++r]&&d[++a]===d[++r]&&d[++a]===d[++r]&&d[++a]===d[++r]&&a<f)if(n=258-(f-a),a=f-258,n>s){if(e.match_start=t,s=n,n>=o)break;p=d[a+s-1],h=d[a+s]}}while((t=u[t&c])>l&&0!=--i)return s<=e.lookahead?s:e.lookahead},eS=e=>{let t,r,n,i,a,s=e.w_size;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=s+(s-262)){e.window.set(e.window.subarray(s,s+s),0),e.match_start-=s,e.strstart-=s,e.block_start-=s,t=r=e.hash_size;do n=e.head[--t],e.head[t]=n>=s?n-s:0;while(--r)t=r=s;do n=e.prev[--t],e.prev[t]=n>=s?n-s:0;while(--r)i+=s}if(0===e.strm.avail_in)break;if(r=ew(e.strm,e.window,e.strstart+e.lookahead,i),e.lookahead+=r,e.lookahead+e.insert>=3)for(a=e.strstart-e.insert,e.ins_h=e.window[a],e.ins_h=ey(e,e.ins_h,e.window[a+1]);e.insert&&(e.ins_h=ey(e,e.ins_h,e.window[a+3-1]),e.prev[a&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=a,a++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead<262&&0!==e.strm.avail_in)},eI=(e,t)=>{let r,n;for(;;){if(e.lookahead<262){if(eS(e),e.lookahead<262&&t===V)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=ey(e,e.ins_h,e.window[e.strstart+3-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==r&&e.strstart-r<=e.w_size-262&&(e.match_length=ek(e,r)),e.match_length>=3)if(n=q(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do e.strstart++,e.ins_h=ey(e,e.ins_h,e.window[e.strstart+3-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart;while(0!=--e.match_length)e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=ey(e,e.ins_h,e.window[e.strstart+1]);else n=q(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(ev(e,!1),0===e.strm.avail_out))return 1}return(e.insert=e.strstart<2?e.strstart:2,t===Q)?(ev(e,!0),0===e.strm.avail_out)?3:4:e.last_lit&&(ev(e,!1),0===e.strm.avail_out)?1:2},e$=(e,t)=>{let r,n,i;for(;;){if(e.lookahead<262){if(eS(e),e.lookahead<262&&t===V)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=ey(e,e.ins_h,e.window[e.strstart+3-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==r&&e.prev_length<e.max_lazy_match&&e.strstart-r<=e.w_size-262&&(e.match_length=ek(e,r),e.match_length<=5&&(e.strategy===es||3===e.match_length&&e.strstart-e.match_start>4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-3,n=q(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=i&&(e.ins_h=ey(e,e.ins_h,e.window[e.strstart+3-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart);while(0!=--e.prev_length)if(e.match_available=0,e.match_length=2,e.strstart++,n&&(ev(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if((n=q(e,0,e.window[e.strstart-1]))&&ev(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return(e.match_available&&(n=q(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===Q)?(ev(e,!0),0===e.strm.avail_out)?3:4:e.last_lit&&(ev(e,!1),0===e.strm.avail_out)?1:2};function eE(e,t,r,n,i){this.good_length=e,this.max_lazy=t,this.nice_length=r,this.max_chain=n,this.func=i}let eO=[new eE(0,0,0,0,(e,t)=>{let r=65535;for(65535>e.pending_buf_size-5&&(r=e.pending_buf_size-5);;){if(e.lookahead<=1){if(eS(e),0===e.lookahead&&t===V)return 1;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;let n=e.block_start+r;if((0===e.strstart||e.strstart>=n)&&(e.lookahead=e.strstart-n,e.strstart=n,ev(e,!1),0===e.strm.avail_out)||e.strstart-e.block_start>=e.w_size-262&&(ev(e,!1),0===e.strm.avail_out))return 1}return(e.insert=0,t===Q)?(ev(e,!0),0===e.strm.avail_out)?3:4:(e.strstart>e.block_start&&(ev(e,!1),e.strm.avail_out),1)}),new eE(4,4,8,4,eI),new eE(4,5,16,8,eI),new eE(4,6,32,32,eI),new eE(4,4,16,16,e$),new eE(8,16,32,32,e$),new eE(8,16,128,128,e$),new eE(8,32,128,256,e$),new eE(32,128,258,1024,e$),new eE(32,258,258,4096,e$)];function eC(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=ef,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(2*ep),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),eg(this.dyn_ltree),eg(this.dyn_dtree),eg(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),eg(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),eg(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}var eT=(e,t)=>{let r,n;if(!e||!e.state||t>Z||t<0)return e?eh(e,er):er;let i=e.state;if(!e.output||!e.input&&0!==e.avail_in||666===i.status&&t!==Q)return eh(e,0===e.avail_out?ei:er);i.strm=e;let a=i.last_flush;if(i.last_flush=t,42===i.status)if(2===i.wrap)e.adler=0,e_(i,31),e_(i,139),e_(i,8),i.gzhead?(e_(i,+!!i.gzhead.text+2*!!i.gzhead.hcrc+4*!!i.gzhead.extra+8*!!i.gzhead.name+16*!!i.gzhead.comment),e_(i,255&i.gzhead.time),e_(i,i.gzhead.time>>8&255),e_(i,i.gzhead.time>>16&255),e_(i,i.gzhead.time>>24&255),e_(i,9===i.level?2:4*(i.strategy>=eo||i.level<2)),e_(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(e_(i,255&i.gzhead.extra.length),e_(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=L(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(e_(i,0),e_(i,0),e_(i,0),e_(i,0),e_(i,0),e_(i,9===i.level?2:4*(i.strategy>=eo||i.level<2)),e_(i,3),i.status=113);else{let t=ef+(i.w_bits-8<<4)<<8;t|=(i.strategy>=eo||i.level<2?0:i.level<6?1:6===i.level?2:3)<<6,0!==i.strstart&&(t|=32),t+=31-t%31,i.status=113,ex(i,t),0!==i.strstart&&(ex(i,e.adler>>>16),ex(i,65535&e.adler)),e.adler=1}if(69===i.status)if(i.gzhead.extra){for(r=i.pending;i.gzindex<(65535&i.gzhead.extra.length)&&(i.pending!==i.pending_buf_size||(i.gzhead.hcrc&&i.pending>r&&(e.adler=L(e.adler,i.pending_buf,i.pending-r,r)),eb(e),r=i.pending,i.pending!==i.pending_buf_size));)e_(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>r&&(e.adler=L(e.adler,i.pending_buf,i.pending-r,r)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=73)}else i.status=73;if(73===i.status)if(i.gzhead.name){r=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>r&&(e.adler=L(e.adler,i.pending_buf,i.pending-r,r)),eb(e),r=i.pending,i.pending===i.pending_buf_size)){n=1;break}n=i.gzindex<i.gzhead.name.length?255&i.gzhead.name.charCodeAt(i.gzindex++):0,e_(i,n)}while(0!==n)i.gzhead.hcrc&&i.pending>r&&(e.adler=L(e.adler,i.pending_buf,i.pending-r,r)),0===n&&(i.gzindex=0,i.status=91)}else i.status=91;if(91===i.status)if(i.gzhead.comment){r=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>r&&(e.adler=L(e.adler,i.pending_buf,i.pending-r,r)),eb(e),r=i.pending,i.pending===i.pending_buf_size)){n=1;break}n=i.gzindex<i.gzhead.comment.length?255&i.gzhead.comment.charCodeAt(i.gzindex++):0,e_(i,n)}while(0!==n)i.gzhead.hcrc&&i.pending>r&&(e.adler=L(e.adler,i.pending_buf,i.pending-r,r)),0===n&&(i.status=103)}else i.status=103;if(103===i.status&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&eb(e),i.pending+2<=i.pending_buf_size&&(e_(i,255&e.adler),e_(i,e.adler>>8&255),e.adler=0,i.status=113)):i.status=113),0!==i.pending){if(eb(e),0===e.avail_out)return i.last_flush=-1,ee}else if(0===e.avail_in&&em(t)<=em(a)&&t!==Q)return eh(e,ei);if(666===i.status&&0!==e.avail_in)return eh(e,ei);if(0!==e.avail_in||0!==i.lookahead||t!==V&&666!==i.status){let r=i.strategy===eo?((e,t)=>{let r;for(;;){if(0===e.lookahead&&(eS(e),0===e.lookahead)){if(t===V)return 1;break}if(e.match_length=0,r=q(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(ev(e,!1),0===e.strm.avail_out))return 1}return(e.insert=0,t===Q)?(ev(e,!0),0===e.strm.avail_out)?3:4:e.last_lit&&(ev(e,!1),0===e.strm.avail_out)?1:2})(i,t):i.strategy===el?((e,t)=>{let r,n,i,a,s=e.window;for(;;){if(e.lookahead<=258){if(eS(e),e.lookahead<=258&&t===V)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(n=s[i=e.strstart-1])===s[++i]&&n===s[++i]&&n===s[++i]){a=e.strstart+258;do;while(n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&i<a)e.match_length=258-(a-i),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(r=q(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=q(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(ev(e,!1),0===e.strm.avail_out))return 1}return(e.insert=0,t===Q)?(ev(e,!0),0===e.strm.avail_out)?3:4:e.last_lit&&(ev(e,!1),0===e.strm.avail_out)?1:2})(i,t):eO[i.level].func(i,t);if((3===r||4===r)&&(i.status=666),1===r||3===r)return 0===e.avail_out&&(i.last_flush=-1),ee;if(2===r&&(t===H?G(i):t!==Z&&(Y(i,0,0,!1),t===K&&(eg(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),eb(e),0===e.avail_out))return i.last_flush=-1,ee}return t!==Q?ee:i.wrap<=0?et:(2===i.wrap?(e_(i,255&e.adler),e_(i,e.adler>>8&255),e_(i,e.adler>>16&255),e_(i,e.adler>>24&255),e_(i,255&e.total_in),e_(i,e.total_in>>8&255),e_(i,e.total_in>>16&255),e_(i,e.total_in>>24&255)):(ex(i,e.adler>>>16),ex(i,65535&e.adler)),eb(e),i.wrap>0&&(i.wrap=-i.wrap),0!==i.pending?ee:et)},eM=e=>{if(!e||!e.state)return er;let t=e.state.status;return 42!==t&&69!==t&&73!==t&&91!==t&&103!==t&&113!==t&&666!==t?eh(e,er):(e.state=null,113===t?eh(e,en):ee)};let eP=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var eA=function(e){let t=Array.prototype.slice.call(arguments,1);for(;t.length;){let r=t.shift();if(r){if("object"!=typeof r)throw TypeError(r+"must be non-object");for(let t in r)eP(r,t)&&(e[t]=r[t])}}return e},eN=e=>{let t=0;for(let r=0,n=e.length;r<n;r++)t+=e[r].length;let r=new Uint8Array(t);for(let t=0,n=0,i=e.length;t<i;t++){let i=e[t];r.set(i,n),n+=i.length}return r};let eR=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){eR=!1}let ej=new Uint8Array(256);for(let e=0;e<256;e++)ej[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;ej[254]=ej[254]=1;var eD=e=>{let t,r,n,i,a,s=e.length,o=0;for(i=0;i<s;i++)(64512&(r=e.charCodeAt(i)))==55296&&i+1<s&&(64512&(n=e.charCodeAt(i+1)))==56320&&(r=65536+(r-55296<<10)+(n-56320),i++),o+=r<128?1:r<2048?2:r<65536?3:4;for(t=new Uint8Array(o),a=0,i=0;a<o;i++)(64512&(r=e.charCodeAt(i)))==55296&&i+1<s&&(64512&(n=e.charCodeAt(i+1)))==56320&&(r=65536+(r-55296<<10)+(n-56320),i++),r<128?t[a++]=r:(r<2048?t[a++]=192|r>>>6:(r<65536?t[a++]=224|r>>>12:(t[a++]=240|r>>>18,t[a++]=128|r>>>12&63),t[a++]=128|r>>>6&63),t[a++]=128|63&r);return t},eU=(e,t)=>{let r,n,i=t||e.length,a=Array(2*i);for(n=0,r=0;r<i;){let t=e[r++];if(t<128){a[n++]=t;continue}let s=ej[t];if(s>4){a[n++]=65533,r+=s-1;continue}for(t&=2===s?31:3===s?15:7;s>1&&r<i;)t=t<<6|63&e[r++],s--;if(s>1){a[n++]=65533;continue}t<65536?a[n++]=t:(t-=65536,a[n++]=55296|t>>10&1023,a[n++]=56320|1023&t)}var s=n;if(s<65534&&a.subarray&&eR)return String.fromCharCode.apply(null,a.length===s?a:a.subarray(0,s));let o="";for(let e=0;e<s;e++)o+=String.fromCharCode(a[e]);return o},eF=(e,t)=>{(t=t||e.length)>e.length&&(t=e.length);let r=t-1;for(;r>=0&&(192&e[r])==128;)r--;return r<0||0===r?t:r+ej[e[r]]>t?r:t},eB=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};let eL=Object.prototype.toString,{Z_NO_FLUSH:ez,Z_SYNC_FLUSH:eW,Z_FULL_FLUSH:eJ,Z_FINISH:eY,Z_OK:eX,Z_STREAM_END:eq,Z_DEFAULT_COMPRESSION:eG,Z_DEFAULT_STRATEGY:eV,Z_DEFLATED:eH}=W;function eK(e){let t,r;this.options=eA({level:eG,method:eH,chunkSize:16384,windowBits:15,memLevel:8,strategy:eV},e||{});let n=this.options;n.raw&&n.windowBits>0?n.windowBits=-n.windowBits:n.gzip&&n.windowBits>0&&n.windowBits<16&&(n.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new eB,this.strm.avail_out=0;let i=((e,t,r,n,i,a)=>{var s,o;let l;if(!e)return er;let d=1;if(t===ea&&(t=6),n<0?(d=0,n=-n):n>15&&(d=2,n-=16),i<1||i>9||r!==ef||n<8||n>15||t<0||t>9||a<0||a>ed)return eh(e,er);8===n&&(n=9);let c=new eC;return e.state=c,c.strm=e,c.wrap=d,c.gzhead=null,c.w_bits=n,c.w_size=1<<c.w_bits,c.w_mask=c.w_size-1,c.hash_bits=i+7,c.hash_size=1<<c.hash_bits,c.hash_mask=c.hash_size-1,c.hash_shift=~~((c.hash_bits+3-1)/3),c.window=new Uint8Array(2*c.w_size),c.head=new Uint16Array(c.hash_size),c.prev=new Uint16Array(c.w_size),c.lit_bufsize=1<<i+6,c.pending_buf_size=4*c.lit_bufsize,c.pending_buf=new Uint8Array(c.pending_buf_size),c.d_buf=+c.lit_bufsize,c.l_buf=3*c.lit_bufsize,c.level=t,c.strategy=a,c.method=r,(l=(e=>{if(!e||!e.state)return eh(e,er);e.total_in=e.total_out=0,e.data_type=eu;let t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?42:113,e.adler=+(2!==t.wrap),t.last_flush=V,J(t),ee})(s=e))===ee&&((o=s.state).window_size=2*o.w_size,eg(o.head),o.max_lazy_match=eO[o.level].max_lazy,o.good_match=eO[o.level].good_length,o.nice_match=eO[o.level].nice_length,o.max_chain_length=eO[o.level].max_chain,o.strstart=0,o.block_start=0,o.lookahead=0,o.insert=0,o.match_length=o.prev_length=2,o.match_available=0,o.ins_h=0),l})(this.strm,n.level,n.method,n.windowBits,n.memLevel,n.strategy);if(i!==eX)throw Error(z[i]);if(n.header&&(t=this.strm,r=n.header,t&&t.state&&2===t.state.wrap&&(t.state.gzhead=r)),n.dictionary){let e;if(e="string"==typeof n.dictionary?eD(n.dictionary):"[object ArrayBuffer]"===eL.call(n.dictionary)?new Uint8Array(n.dictionary):n.dictionary,(i=((e,t)=>{let r=t.length;if(!e||!e.state)return er;let n=e.state,i=n.wrap;if(2===i||1===i&&42!==n.status||n.lookahead)return er;if(1===i&&(e.adler=F(e.adler,t,r,0)),n.wrap=0,r>=n.w_size){0===i&&(eg(n.head),n.strstart=0,n.block_start=0,n.insert=0);let e=new Uint8Array(n.w_size);e.set(t.subarray(r-n.w_size,r),0),t=e,r=n.w_size}let a=e.avail_in,s=e.next_in,o=e.input;for(e.avail_in=r,e.next_in=0,e.input=t,eS(n);n.lookahead>=3;){let e=n.strstart,t=n.lookahead-2;do n.ins_h=ey(n,n.ins_h,n.window[e+3-1]),n.prev[e&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=e,e++;while(--t)n.strstart=e,n.lookahead=2,eS(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=2,n.match_available=0,e.next_in=s,e.input=o,e.avail_in=a,n.wrap=i,ee})(this.strm,e))!==eX)throw Error(z[i]);this._dict_set=!0}}function eQ(e,t){let r=new eK(t);if(r.push(e,!0),r.err)throw r.msg||z[r.err];return r.result}eK.prototype.push=function(e,t){let r,n,i=this.strm,a=this.options.chunkSize;if(this.ended)return!1;for(n=t===~~t?t:!0===t?eY:ez,"string"==typeof e?i.input=eD(e):"[object ArrayBuffer]"===eL.call(e)?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;;){if(0===i.avail_out&&(i.output=new Uint8Array(a),i.next_out=0,i.avail_out=a),(n===eW||n===eJ)&&i.avail_out<=6){this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;continue}if((r=eT(i,n))===eq)return i.next_out>0&&this.onData(i.output.subarray(0,i.next_out)),r=eM(this.strm),this.onEnd(r),this.ended=!0,r===eX;if(0===i.avail_out){this.onData(i.output);continue}if(n>0&&i.next_out>0){this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;continue}if(0===i.avail_in)break}return!0},eK.prototype.onData=function(e){this.chunks.push(e)},eK.prototype.onEnd=function(e){e===eX&&(this.result=eN(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var eZ=function(e,t){let r,n,i,a,s,o,l,d,c,u,f,p,h,m,g,y,b,v,_,x,w,k,S,I,$=e.state;r=e.next_in,S=e.input,n=r+(e.avail_in-5),i=e.next_out,I=e.output,a=i-(t-e.avail_out),s=i+(e.avail_out-257),o=$.dmax,l=$.wsize,d=$.whave,c=$.wnext,u=$.window,f=$.hold,p=$.bits,h=$.lencode,m=$.distcode,g=(1<<$.lenbits)-1,y=(1<<$.distbits)-1;t:do for(p<15&&(f+=S[r++]<<p,p+=8,f+=S[r++]<<p,p+=8),b=h[f&g];;){if(f>>>=v=b>>>24,p-=v,0==(v=b>>>16&255))I[i++]=65535&b;else if(16&v)for(_=65535&b,(v&=15)&&(p<v&&(f+=S[r++]<<p,p+=8),_+=f&(1<<v)-1,f>>>=v,p-=v),p<15&&(f+=S[r++]<<p,p+=8,f+=S[r++]<<p,p+=8),b=m[f&y];;){if(f>>>=v=b>>>24,p-=v,16&(v=b>>>16&255)){if(x=65535&b,p<(v&=15)&&(f+=S[r++]<<p,(p+=8)<v&&(f+=S[r++]<<p,p+=8)),(x+=f&(1<<v)-1)>o){e.msg="invalid distance too far back",$.mode=30;break t}if(f>>>=v,p-=v,x>(v=i-a)){if((v=x-v)>d&&$.sane){e.msg="invalid distance too far back",$.mode=30;break t}if(w=0,k=u,0===c){if(w+=l-v,v<_){_-=v;do I[i++]=u[w++];while(--v)w=i-x,k=I}}else if(c<v){if(w+=l+c-v,(v-=c)<_){_-=v;do I[i++]=u[w++];while(--v)if(w=0,c<_){_-=v=c;do I[i++]=u[w++];while(--v)w=i-x,k=I}}}else if(w+=c-v,v<_){_-=v;do I[i++]=u[w++];while(--v)w=i-x,k=I}for(;_>2;)I[i++]=k[w++],I[i++]=k[w++],I[i++]=k[w++],_-=3;_&&(I[i++]=k[w++],_>1&&(I[i++]=k[w++]))}else{w=i-x;do I[i++]=I[w++],I[i++]=I[w++],I[i++]=I[w++],_-=3;while(_>2)_&&(I[i++]=I[w++],_>1&&(I[i++]=I[w++]))}}else if((64&v)==0){b=m[(65535&b)+(f&(1<<v)-1)];continue}else{e.msg="invalid distance code",$.mode=30;break t}break}else if((64&v)==0){b=h[(65535&b)+(f&(1<<v)-1)];continue}else if(32&v){$.mode=12;break t}else{e.msg="invalid literal/length code",$.mode=30;break t}break}while(r<n&&i<s)r-=_=p>>3,p-=_<<3,f&=(1<<p)-1,e.next_in=r,e.next_out=i,e.avail_in=r<n?5+(n-r):5-(r-n),e.avail_out=i<s?257+(s-i):257-(i-s),$.hold=f,$.bits=p};let e0=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),e1=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),e2=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),e5=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var e3=(e,t,r,n,i,a,s,o)=>{let l,d,c,u,f,p,h,m,g,y=o.bits,b=0,v=0,_=0,x=0,w=0,k=0,S=0,I=0,$=0,E=0,O=null,C=0,T=new Uint16Array(16),M=new Uint16Array(16),P=null,A=0;for(b=0;b<=15;b++)T[b]=0;for(v=0;v<n;v++)T[t[r+v]]++;for(w=y,x=15;x>=1&&0===T[x];x--);if(w>x&&(w=x),0===x)return i[a++]=0x1400000,i[a++]=0x1400000,o.bits=1,0;for(_=1;_<x&&0===T[_];_++);for(w<_&&(w=_),I=1,b=1;b<=15;b++)if(I<<=1,(I-=T[b])<0)return -1;if(I>0&&(0===e||1!==x))return -1;for(M[1]=0,b=1;b<15;b++)M[b+1]=M[b]+T[b];for(v=0;v<n;v++)0!==t[r+v]&&(s[M[t[r+v]]++]=v);if(0===e?(O=P=s,p=19):1===e?(O=e0,C-=257,P=e1,A-=257,p=256):(O=e2,P=e5,p=-1),E=0,v=0,b=_,f=a,k=w,S=0,c=-1,u=($=1<<w)-1,1===e&&$>852||2===e&&$>592)return 1;for(;;){h=b-S,s[v]<p?(m=0,g=s[v]):s[v]>p?(m=P[A+s[v]],g=O[C+s[v]]):(m=96,g=0),l=1<<b-S,_=d=1<<k;do i[f+(E>>S)+(d-=l)]=h<<24|m<<16|g;while(0!==d)for(l=1<<b-1;E&l;)l>>=1;if(0!==l?(E&=l-1,E+=l):E=0,v++,0==--T[b]){if(b===x)break;b=t[r+s[v]]}if(b>w&&(E&u)!==c){for(0===S&&(S=w),f+=_,I=1<<(k=b-S);k+S<x&&!((I-=T[k+S])<=0);)k++,I<<=1;if($+=1<<k,1===e&&$>852||2===e&&$>592)return 1;i[c=E&u]=w<<24|k<<16|f-a}}return 0!==E&&(i[f+E]=b-S<<24|4194304),o.bits=w,0};let{Z_FINISH:e6,Z_BLOCK:e8,Z_TREES:e9,Z_OK:e4,Z_STREAM_END:e7,Z_NEED_DICT:te,Z_STREAM_ERROR:tt,Z_DATA_ERROR:tr,Z_MEM_ERROR:tn,Z_BUF_ERROR:ti,Z_DEFLATED:ta}=W,ts=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function to(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}let tl=e=>{if(!e||!e.state)return tt;let t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,(e=>{if(!e||!e.state)return tt;let t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=1,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,e4})(e)},td=!0,tc=e=>{if(td){s=new Int32Array(512),o=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(e3(1,e.lens,0,288,s,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;e3(2,e.lens,0,32,o,0,e.work,{bits:5}),td=!1}e.lencode=s,e.lenbits=9,e.distcode=o,e.distbits=5},tu=(e,t,r,n)=>{let i,a=e.state;return null===a.window&&(a.wsize=1<<a.wbits,a.wnext=0,a.whave=0,a.window=new Uint8Array(a.wsize)),n>=a.wsize?(a.window.set(t.subarray(r-a.wsize,r),0),a.wnext=0,a.whave=a.wsize):((i=a.wsize-a.wnext)>n&&(i=n),a.window.set(t.subarray(r-n,r-n+i),a.wnext),(n-=i)?(a.window.set(t.subarray(r-n,r),0),a.wnext=n,a.whave=a.wsize):(a.wnext+=i,a.wnext===a.wsize&&(a.wnext=0),a.whave<a.wsize&&(a.whave+=i))),0};var tf=(e,t)=>{let r,n,i,a,s,o,l,d,c,u,f,p,h,m,g,y,b,v,_,x,w,k,S,I,$=0,E=new Uint8Array(4),O=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return tt;12===(r=e.state).mode&&(r.mode=13),s=e.next_out,i=e.output,l=e.avail_out,a=e.next_in,n=e.input,o=e.avail_in,d=r.hold,c=r.bits,u=o,f=l,k=e4;r:for(;;)switch(r.mode){case 1:if(0===r.wrap){r.mode=13;break}for(;c<16;){if(0===o)break r;o--,d+=n[a++]<<c,c+=8}if(2&r.wrap&&35615===d){r.check=0,E[0]=255&d,E[1]=d>>>8&255,r.check=L(r.check,E,2,0),d=0,c=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&d)<<8)+(d>>8))%31){e.msg="incorrect header check",r.mode=30;break}if((15&d)!==ta){e.msg="unknown compression method",r.mode=30;break}if(d>>>=4,c-=4,w=(15&d)+8,0===r.wbits)r.wbits=w;else if(w>r.wbits){e.msg="invalid window size",r.mode=30;break}r.dmax=1<<r.wbits,e.adler=r.check=1,r.mode=512&d?10:12,d=0,c=0;break;case 2:for(;c<16;){if(0===o)break r;o--,d+=n[a++]<<c,c+=8}if(r.flags=d,(255&r.flags)!==ta){e.msg="unknown compression method",r.mode=30;break}if(57344&r.flags){e.msg="unknown header flags set",r.mode=30;break}r.head&&(r.head.text=d>>8&1),512&r.flags&&(E[0]=255&d,E[1]=d>>>8&255,r.check=L(r.check,E,2,0)),d=0,c=0,r.mode=3;case 3:for(;c<32;){if(0===o)break r;o--,d+=n[a++]<<c,c+=8}r.head&&(r.head.time=d),512&r.flags&&(E[0]=255&d,E[1]=d>>>8&255,E[2]=d>>>16&255,E[3]=d>>>24&255,r.check=L(r.check,E,4,0)),d=0,c=0,r.mode=4;case 4:for(;c<16;){if(0===o)break r;o--,d+=n[a++]<<c,c+=8}r.head&&(r.head.xflags=255&d,r.head.os=d>>8),512&r.flags&&(E[0]=255&d,E[1]=d>>>8&255,r.check=L(r.check,E,2,0)),d=0,c=0,r.mode=5;case 5:if(1024&r.flags){for(;c<16;){if(0===o)break r;o--,d+=n[a++]<<c,c+=8}r.length=d,r.head&&(r.head.extra_len=d),512&r.flags&&(E[0]=255&d,E[1]=d>>>8&255,r.check=L(r.check,E,2,0)),d=0,c=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&((p=r.length)>o&&(p=o),p&&(r.head&&(w=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Uint8Array(r.head.extra_len)),r.head.extra.set(n.subarray(a,a+p),w)),512&r.flags&&(r.check=L(r.check,n,p,a)),o-=p,a+=p,r.length-=p),r.length))break r;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(0===o)break r;p=0;do w=n[a+p++],r.head&&w&&r.length<65536&&(r.head.name+=String.fromCharCode(w));while(w&&p<o)if(512&r.flags&&(r.check=L(r.check,n,p,a)),o-=p,a+=p,w)break r}else r.head&&(r.head.name=null);r.length=0,r.mode=8;case 8:if(4096&r.flags){if(0===o)break r;p=0;do w=n[a+p++],r.head&&w&&r.length<65536&&(r.head.comment+=String.fromCharCode(w));while(w&&p<o)if(512&r.flags&&(r.check=L(r.check,n,p,a)),o-=p,a+=p,w)break r}else r.head&&(r.head.comment=null);r.mode=9;case 9:if(512&r.flags){for(;c<16;){if(0===o)break r;o--,d+=n[a++]<<c,c+=8}if(d!==(65535&r.check)){e.msg="header crc mismatch",r.mode=30;break}d=0,c=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=12;break;case 10:for(;c<32;){if(0===o)break r;o--,d+=n[a++]<<c,c+=8}e.adler=r.check=ts(d),d=0,c=0,r.mode=11;case 11:if(0===r.havedict)return e.next_out=s,e.avail_out=l,e.next_in=a,e.avail_in=o,r.hold=d,r.bits=c,te;e.adler=r.check=1,r.mode=12;case 12:if(t===e8||t===e9)break r;case 13:if(r.last){d>>>=7&c,c-=7&c,r.mode=27;break}for(;c<3;){if(0===o)break r;o--,d+=n[a++]<<c,c+=8}switch(r.last=1&d,c-=1,3&(d>>>=1)){case 0:r.mode=14;break;case 1:if(tc(r),r.mode=20,t===e9){d>>>=2,c-=2;break r}break;case 2:r.mode=17;break;case 3:e.msg="invalid block type",r.mode=30}d>>>=2,c-=2;break;case 14:for(d>>>=7&c,c-=7&c;c<32;){if(0===o)break r;o--,d+=n[a++]<<c,c+=8}if((65535&d)!=(d>>>16^65535)){e.msg="invalid stored block lengths",r.mode=30;break}if(r.length=65535&d,d=0,c=0,r.mode=15,t===e9)break r;case 15:r.mode=16;case 16:if(p=r.length){if(p>o&&(p=o),p>l&&(p=l),0===p)break r;i.set(n.subarray(a,a+p),s),o-=p,a+=p,l-=p,s+=p,r.length-=p;break}r.mode=12;break;case 17:for(;c<14;){if(0===o)break r;o--,d+=n[a++]<<c,c+=8}if(r.nlen=(31&d)+257,c-=5,r.ndist=(31&(d>>>=5))+1,c-=5,r.ncode=(15&(d>>>=5))+4,d>>>=4,c-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=30;break}r.have=0,r.mode=18;case 18:for(;r.have<r.ncode;){for(;c<3;){if(0===o)break r;o--,d+=n[a++]<<c,c+=8}r.lens[O[r.have++]]=7&d,d>>>=3,c-=3}for(;r.have<19;)r.lens[O[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,S={bits:r.lenbits},k=e3(0,r.lens,0,19,r.lencode,0,r.work,S),r.lenbits=S.bits,k){e.msg="invalid code lengths set",r.mode=30;break}r.have=0,r.mode=19;case 19:for(;r.have<r.nlen+r.ndist;){for(;g=($=r.lencode[d&(1<<r.lenbits)-1])>>>24,y=$>>>16&255,b=65535&$,!(g<=c);){if(0===o)break r;o--,d+=n[a++]<<c,c+=8}if(b<16)d>>>=g,c-=g,r.lens[r.have++]=b;else{if(16===b){for(I=g+2;c<I;){if(0===o)break r;o--,d+=n[a++]<<c,c+=8}if(d>>>=g,c-=g,0===r.have){e.msg="invalid bit length repeat",r.mode=30;break}w=r.lens[r.have-1],p=3+(3&d),d>>>=2,c-=2}else if(17===b){for(I=g+3;c<I;){if(0===o)break r;o--,d+=n[a++]<<c,c+=8}d>>>=g,c-=g,w=0,p=3+(7&d),d>>>=3,c-=3}else{for(I=g+7;c<I;){if(0===o)break r;o--,d+=n[a++]<<c,c+=8}d>>>=g,c-=g,w=0,p=11+(127&d),d>>>=7,c-=7}if(r.have+p>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=30;break}for(;p--;)r.lens[r.have++]=w}}if(30===r.mode)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=30;break}if(r.lenbits=9,S={bits:r.lenbits},k=e3(1,r.lens,0,r.nlen,r.lencode,0,r.work,S),r.lenbits=S.bits,k){e.msg="invalid literal/lengths set",r.mode=30;break}if(r.distbits=6,r.distcode=r.distdyn,S={bits:r.distbits},k=e3(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,S),r.distbits=S.bits,k){e.msg="invalid distances set",r.mode=30;break}if(r.mode=20,t===e9)break r;case 20:r.mode=21;case 21:if(o>=6&&l>=258){e.next_out=s,e.avail_out=l,e.next_in=a,e.avail_in=o,r.hold=d,r.bits=c,eZ(e,f),s=e.next_out,i=e.output,l=e.avail_out,a=e.next_in,n=e.input,o=e.avail_in,d=r.hold,c=r.bits,12===r.mode&&(r.back=-1);break}for(r.back=0;g=($=r.lencode[d&(1<<r.lenbits)-1])>>>24,y=$>>>16&255,b=65535&$,!(g<=c);){if(0===o)break r;o--,d+=n[a++]<<c,c+=8}if(y&&(240&y)==0){for(v=g,_=y,x=b;g=($=r.lencode[x+((d&(1<<v+_)-1)>>v)])>>>24,y=$>>>16&255,b=65535&$,!(v+g<=c);){if(0===o)break r;o--,d+=n[a++]<<c,c+=8}d>>>=v,c-=v,r.back+=v}if(d>>>=g,c-=g,r.back+=g,r.length=b,0===y){r.mode=26;break}if(32&y){r.back=-1,r.mode=12;break}if(64&y){e.msg="invalid literal/length code",r.mode=30;break}r.extra=15&y,r.mode=22;case 22:if(r.extra){for(I=r.extra;c<I;){if(0===o)break r;o--,d+=n[a++]<<c,c+=8}r.length+=d&(1<<r.extra)-1,d>>>=r.extra,c-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;g=($=r.distcode[d&(1<<r.distbits)-1])>>>24,y=$>>>16&255,b=65535&$,!(g<=c);){if(0===o)break r;o--,d+=n[a++]<<c,c+=8}if((240&y)==0){for(v=g,_=y,x=b;g=($=r.distcode[x+((d&(1<<v+_)-1)>>v)])>>>24,y=$>>>16&255,b=65535&$,!(v+g<=c);){if(0===o)break r;o--,d+=n[a++]<<c,c+=8}d>>>=v,c-=v,r.back+=v}if(d>>>=g,c-=g,r.back+=g,64&y){e.msg="invalid distance code",r.mode=30;break}r.offset=b,r.extra=15&y,r.mode=24;case 24:if(r.extra){for(I=r.extra;c<I;){if(0===o)break r;o--,d+=n[a++]<<c,c+=8}r.offset+=d&(1<<r.extra)-1,d>>>=r.extra,c-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=30;break}r.mode=25;case 25:if(0===l)break r;if(p=f-l,r.offset>p){if((p=r.offset-p)>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=30;break}p>r.wnext?(p-=r.wnext,h=r.wsize-p):h=r.wnext-p,p>r.length&&(p=r.length),m=r.window}else m=i,h=s-r.offset,p=r.length;p>l&&(p=l),l-=p,r.length-=p;do i[s++]=m[h++];while(--p)0===r.length&&(r.mode=21);break;case 26:if(0===l)break r;i[s++]=r.length,l--,r.mode=21;break;case 27:if(r.wrap){for(;c<32;){if(0===o)break r;o--,d|=n[a++]<<c,c+=8}if(f-=l,e.total_out+=f,r.total+=f,f&&(e.adler=r.check=r.flags?L(r.check,i,f,s-f):F(r.check,i,f,s-f)),f=l,(r.flags?d:ts(d))!==r.check){e.msg="incorrect data check",r.mode=30;break}d=0,c=0}r.mode=28;case 28:if(r.wrap&&r.flags){for(;c<32;){if(0===o)break r;o--,d+=n[a++]<<c,c+=8}if(d!==(0|r.total)){e.msg="incorrect length check",r.mode=30;break}d=0,c=0}r.mode=29;case 29:k=e7;break r;case 30:k=tr;break r;case 31:return tn;default:return tt}return e.next_out=s,e.avail_out=l,e.next_in=a,e.avail_in=o,r.hold=d,r.bits=c,(r.wsize||f!==e.avail_out&&r.mode<30&&(r.mode<27||t!==e6))&&tu(e,e.output,e.next_out,f-e.avail_out),u-=e.avail_in,f-=e.avail_out,e.total_in+=u,e.total_out+=f,r.total+=f,r.wrap&&f&&(e.adler=r.check=r.flags?L(r.check,i,f,e.next_out-f):F(r.check,i,f,e.next_out-f)),e.data_type=r.bits+64*!!r.last+128*(12===r.mode)+256*(20===r.mode||15===r.mode),(0===u&&0===f||t===e6)&&k===e4&&(k=ti),k},tp=e=>{if(!e||!e.state)return tt;let t=e.state;return t.window&&(t.window=null),e.state=null,e4},th=(e,t)=>{let r,n=t.length;return e&&e.state&&(0===(r=e.state).wrap||11===r.mode)?11===r.mode&&F(1,t,n,0)!==r.check?tr:tu(e,t,n,n)?(r.mode=31,tn):(r.havedict=1,e4):tt},tm=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};let tg=Object.prototype.toString,{Z_NO_FLUSH:ty,Z_FINISH:tb,Z_OK:tv,Z_STREAM_END:t_,Z_NEED_DICT:tx,Z_STREAM_ERROR:tw,Z_DATA_ERROR:tk,Z_MEM_ERROR:tS}=W;function tI(e){this.options=eA({chunkSize:65536,windowBits:15,to:""},e||{});let t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),t.windowBits>=0&&t.windowBits<16&&!(e&&e.windowBits)&&(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(15&t.windowBits)==0&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new eB,this.strm.avail_out=0;let r=((e,t)=>{if(!e)return tt;let r=new to;e.state=r,r.window=null;let n=((e,t)=>{let r;if(!e||!e.state)return tt;let n=e.state;return(t<0?(r=0,t=-t):(r=(t>>4)+1,t<48&&(t&=15)),t&&(t<8||t>15))?tt:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,tl(e))})(e,t);return n!==e4&&(e.state=null),n})(this.strm,t.windowBits);if(r!==tv||(this.header=new tm,((e,t)=>{if(!e||!e.state)return;let r=e.state;return(2&r.wrap)==0||(r.head=t,t.done=!1)})(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=eD(t.dictionary):"[object ArrayBuffer]"===tg.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw)&&(r=th(this.strm,t.dictionary))!==tv))throw Error(z[r])}function t$(e,t){let r=new tI(t);if(r.push(e),r.err)throw r.msg||z[r.err];return r.result}tI.prototype.push=function(e,t){let r,n,i,a=this.strm,s=this.options.chunkSize,o=this.options.dictionary;if(this.ended)return!1;for(n=t===~~t?t:!0===t?tb:ty,"[object ArrayBuffer]"===tg.call(e)?a.input=new Uint8Array(e):a.input=e,a.next_in=0,a.avail_in=a.input.length;;){for(0===a.avail_out&&(a.output=new Uint8Array(s),a.next_out=0,a.avail_out=s),(r=tf(a,n))===tx&&o&&((r=th(a,o))===tv?r=tf(a,n):r===tk&&(r=tx));a.avail_in>0&&r===t_&&a.state.wrap>0&&0!==e[a.next_in];)tl(a),r=tf(a,n);switch(r){case tw:case tk:case tx:case tS:return this.onEnd(r),this.ended=!0,!1}if(i=a.avail_out,a.next_out&&(0===a.avail_out||r===t_))if("string"===this.options.to){let e=eF(a.output,a.next_out),t=a.next_out-e,r=eU(a.output,e);a.next_out=t,a.avail_out=s-t,t&&a.output.set(a.output.subarray(e,e+t),0),this.onData(r)}else this.onData(a.output.length===a.next_out?a.output:a.output.subarray(0,a.next_out));if(r!==tv||0!==i){if(r===t_)return r=tp(this.strm),this.onEnd(r),this.ended=!0,!0;if(0===a.avail_in)break}}return!0},tI.prototype.onData=function(e){this.chunks.push(e)},tI.prototype.onEnd=function(e){e===tv&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=eN(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};let{Deflate:tE,deflate:tO,deflateRaw:tC,gzip:tT}={Deflate:eK,deflate:eQ,deflateRaw:function(e,t){return(t=t||{}).raw=!0,eQ(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,eQ(e,t)},constants:W},{Inflate:tM,inflate:tP,inflateRaw:tA,ungzip:tN}={Inflate:tI,inflate:t$,inflateRaw:function(e,t){return(t=t||{}).raw=!0,t$(e,t)},ungzip:t$,constants:W};r.d(t,{Gy:()=>tE,Kc:()=>tO,UD:()=>tP})},3178(e,t,r){let n;r.d(t,{Er:()=>rP,y1:()=>t7,Ov:()=>r5,Tx:()=>ne,UA:()=>iH,JH:()=>r0,yE:()=>rs,Ky:()=>tc,e5:()=>tU,Uh:()=>re,nu:()=>ty,OF:()=>aK,XV:()=>aG,r8:()=>aV,rC:()=>aH,rR:()=>iK});var i=r(2718),a=r(1179),s=r(2842),o=r(4238),l=r(5633),d=r(2109),c=r(7086),u=r(9315),f=r(2981);let p=i.ukk,h=i.mSG(i.QfV,i.$r1),m=Object.freeze({paper:"#f6f1e7",card:"#fffdf8",ink:"#1a1712",accent:"#8f707f"}),g=Object.freeze({accentColor:m.accent,backgroundColor:m.card});function y(e,t){return e.pipe(i.tiU(s.PyW(t)))}function b(e,t){return i.svK(e,{errors:"all"})(t)}let v=c.ID();function _(e){return Object.assign(e,{parse:t=>b(e,t),safeParse:t=>{let r;return r=i.q$Z(e,{errors:"all"})(t),u.oJ(r)?{data:r.success,success:!0}:{error:{issues:v(r.failure.issue).issues.map(e=>({message:e.message,path:(e.path??[]).map(e=>"object"==typeof e?e.key:e)}))},success:!1}}})}let x=i.xCb(["flowchart","mindmap"]),w=i.xCb(["TB","BT","LR","RL"]),k=i.xCb(["straight","orthogonal","curved"]);class S extends i.Xsx("DiagramNode")({id:p,label:p,group:i.lqM(p),kind:i.lqM(p),metadata:y(h,{})}){}_(S);class I extends i.Xsx("DiagramEdge")({id:p,source:p,target:p,label:i.lqM(p),metadata:y(h,{})}){}_(I);let $=i.QfV.check(i.Pto(/^#[0-9a-fA-F]{6}$/));class E extends i.Xsx("DiagramStyle")({accentColor:y($,g.accentColor),backgroundColor:y($,g.backgroundColor)}){}_(E);class O extends i.Xsx("DiagramLayout")({direction:y(w,"LR"),edgeRouting:y(k,"orthogonal")}){}_(O);class C extends i.Xsx("IntermediateDiagram")({id:p,title:p,type:y(x,"flowchart"),nodes:i.O31(S).pipe(i.fXn).check(i.tJb(1)),edges:y(i.O31(I).pipe(i.fXn),[]),layout:y(O,{direction:"LR",edgeRouting:"orthogonal"}),style:y(E,g),metadata:y(h,{})}){}_(C);class T extends Error{constructor(e){super(e),this.name="DiagramValidationError"}}let M=e=>{let t=new Set;for(let r of e){if(t.has(r))return r;t.add(r)}};function P(e){let t=M(e.nodes.map(e=>e.id));if(t)throw new T(`Duplicate node id "${t}" is not allowed.`);let r=M(e.edges.map(e=>e.id));if(r)throw new T(`Duplicate edge id "${r}" is not allowed.`);let n=new Set(e.nodes.map(e=>e.id));for(let t of e.edges){if(!n.has(t.source))throw new T(`Edge "${t.id}" references missing source node "${t.source}".`);if(!n.has(t.target))throw new T(`Edge "${t.id}" references missing target node "${t.target}".`);if(t.source===t.target)throw new T(`Edge "${t.id}" cannot connect node "${t.source}" to itself.`)}return e}function A(e){return P(b(C,e))}let N="flowchart",R=i.xCb(["duplicate_node_id","duplicate_edge_id","missing_edge_source","missing_edge_target","self_loop","missing_start","multiple_starts","missing_end","start_has_incoming","end_has_outgoing","unreachable_node","missing_outgoing_edge","underbranched_decision","unlabeled_decision_branch","duplicate_decision_branch_label","nonterminating_node","flowchart_too_large"]);class j extends i.Xsx("FlowchartValidationIssueRef")({kind:i.xCb(["diagram","node","edge"]),id:i.lqM(i.ukk),path:i.lqM(i.ukk)}){}i.Xsx("FlowchartValidationIssue")({code:R,ref:i.lqM(j),message:i.ukk,hint:i.ukk});let D=i.xCb(["start","process","decision","end"]);class U extends S.extend("FlowchartNode")({kind:D,description:i.lqM(i.ukk)}){}class F extends I.extend("FlowchartEdge")({label:i.lqM(i.ukk)}){}class B extends C.extend("FlowchartDiagram")({type:i.uSQ(N),nodes:i.O31(U).pipe(i.fXn).check(i.tJb(2)),edges:i.O31(F).pipe(i.fXn).check(i.tJb(1))}){}let L=_(B);function z(e){let t=new Set,r=new Set;for(let n of e)t.has(n)?r.add(n):t.add(n);return[...r]}function W(e,t,r){let n=new Set,i=[...e];for(let e=0;e<i.length;e+=1){let a=i[e];if(!(void 0===a||n.has(a)))for(let e of(n.add(a),t.get(a)??[]))i.push(r(e))}return n}function J(e){let t=[],r=new Set(e.nodes.map(e=>e.id)),{incoming:n,outgoing:i}=function(e){let t=new Map,r=new Map;for(let n of e)t.set(n.target,[...t.get(n.target)??[],n]),r.set(n.source,[...r.get(n.source)??[],n]);return{incoming:t,outgoing:r}}(e.edges);for(let r of(e.nodes.length>24&&t.push({code:"flowchart_too_large",ref:{kind:"diagram",id:e.id,path:"nodes"},message:`Flowchart has ${e.nodes.length} nodes; the supported maximum is 24.`,hint:"Split the workflow or combine lower-signal steps."}),e.edges.length>64&&t.push({code:"flowchart_too_large",ref:{kind:"diagram",id:e.id,path:"edges"},message:`Flowchart has ${e.edges.length} edges; the supported maximum is 64.`,hint:"Split the workflow or remove lower-signal connections."}),z(e.nodes.map(e=>e.id))))t.push({code:"duplicate_node_id",ref:{kind:"node",id:r,path:"nodes"},message:`Node id "${r}" is used more than once.`,hint:"Give every node a stable unique id."});for(let r of z(e.edges.map(e=>e.id)))t.push({code:"duplicate_edge_id",ref:{kind:"edge",id:r,path:"edges"},message:`Edge id "${r}" is used more than once.`,hint:"Give every edge a stable unique id."});for(let n of e.edges)r.has(n.source)||t.push({code:"missing_edge_source",ref:{kind:"edge",id:n.id,path:"edges.source"},message:`Edge "${n.id}" references missing source node "${n.source}".`,hint:"Set edge.source to one of the diagram node ids."}),r.has(n.target)||t.push({code:"missing_edge_target",ref:{kind:"edge",id:n.id,path:"edges.target"},message:`Edge "${n.id}" references missing target node "${n.target}".`,hint:"Set edge.target to one of the diagram node ids."}),n.source===n.target&&t.push({code:"self_loop",ref:{kind:"edge",id:n.id},message:`Edge "${n.id}" connects node "${n.source}" to itself.`,hint:"Connect the edge to a different target node."});let a=e.nodes.filter(e=>"start"===e.kind),s=e.nodes.filter(e=>"end"===e.kind);for(let r of(0===a.length?t.push({code:"missing_start",ref:{kind:"diagram",id:e.id,path:"nodes"},message:"Flowchart must contain exactly one start node.",hint:'Mark the first node in the flow with kind: "start".'}):a.length>1&&t.push({code:"multiple_starts",ref:{kind:"diagram",id:e.id,path:"nodes"},message:`Flowchart has ${a.length} start nodes.`,hint:"Keep one start node and change the others to process, decision, or end."}),0===s.length&&t.push({code:"missing_end",ref:{kind:"diagram",id:e.id,path:"nodes"},message:"Flowchart must contain at least one end node.",hint:'Add an end node or mark terminal outcomes with kind: "end".'}),e.nodes)){let e=n.get(r.id)??[],a=i.get(r.id)??[];"start"===r.kind&&e.length>0&&t.push({code:"start_has_incoming",ref:{kind:"node",id:r.id},message:`Start node "${r.id}" cannot have incoming edges.`,hint:"Route the start node only to later nodes."}),"end"===r.kind&&a.length>0&&t.push({code:"end_has_outgoing",ref:{kind:"node",id:r.id},message:`End node "${r.id}" cannot have outgoing edges.`,hint:"End nodes must be terminal outcomes."}),"end"!==r.kind&&0===a.length&&t.push({code:"missing_outgoing_edge",ref:{kind:"node",id:r.id},message:`Node "${r.id}" must have at least one outgoing edge.`,hint:'Connect it to the next step, or mark it as kind: "end".'}),"decision"===r.kind&&t.push(...function(e,t){let r=[];t.length<2&&r.push({code:"underbranched_decision",ref:{kind:"node",id:e.id},message:`Decision node "${e.id}" must have at least two outgoing branches.`,hint:"Add at least two outgoing edges for the decision outcomes."});let n=t.map(e=>e.label?.trim()??"");for(let n of t.filter(e=>!e.label?.trim()))r.push({code:"unlabeled_decision_branch",ref:{kind:"edge",id:n.id,path:"edges.label"},message:`Decision node "${e.id}" has an outgoing branch without a label.`,hint:'Add a short branch label such as "yes", "no", "approved", or "rejected".'});for(let t of z(n.filter(e=>e.length>0).map(e=>e.toLowerCase())))r.push({code:"duplicate_decision_branch_label",ref:{kind:"node",id:e.id},message:`Decision node "${e.id}" repeats branch label "${t}".`,hint:"Make every outgoing branch label from the same decision unique."});return r}(r,a))}let o=1===a.length?a[0]:void 0;if(o){let r=W([o.id],i,e=>e.target);for(let n of e.nodes)r.has(n.id)||t.push({code:"unreachable_node",ref:{kind:"node",id:n.id},message:`Node "${n.id}" is not reachable from the start node.`,hint:"Connect every node to the flow that begins at the single start node."});if(s.length>0){let a=W(s.map(e=>e.id),n,e=>e.source);for(let n of e.nodes)r.has(n.id)&&!a.has(n.id)&&(i.get(n.id)?.length??0)>0&&t.push({code:"nonterminating_node",ref:{kind:"node",id:n.id},message:`Node "${n.id}" cannot reach an end node.`,hint:"Add an eventual exit from this path to an end node; retry loops are valid when they retain an exit."})}}return t.slice(0,20)}class Y extends T{issues;constructor(e){super(e[0]?.message??"Flowchart failed semantic validation."),this.issues=e,this.name="FlowchartValidationError"}}function X(e){let t=J(e);if(t.length>0)throw new Y(t);return e}let q=X(b(B,{id:"onboarding-flow",title:"Sketchi onboarding decision flow",type:N,nodes:[{id:"prompt",label:"Prompt received",kind:"start"},{id:"requirements",label:"Extract requirements",kind:"process"},{id:"clear",label:"Scope clear?",kind:"decision"},{id:"draft",label:"Draft typed IR",kind:"process"},{id:"review",label:"Review diagram",kind:"end"}],edges:[{id:"prompt-requirements",source:"prompt",target:"requirements"},{id:"requirements-clear",source:"requirements",target:"clear"},{id:"clear-draft",source:"clear",target:"draft",label:"yes"},{id:"clear-review",source:"clear",target:"review",label:"no"},{id:"draft-review",source:"draft",target:"review"}],layout:{direction:"TB",edgeRouting:"orthogonal"}}));X(b(B,{id:"pharma-batch-disposition",title:"Pharma batch disposition flow",type:N,nodes:[{id:"batch-received",label:"Batch received",kind:"start"},{id:"qa-review",label:"QA reviews Certificate of Analysis",kind:"process"},{id:"passes-specs",label:"Passes specs?",kind:"decision"},{id:"final-review",label:"QA Manager final review",kind:"process"},{id:"packaging",label:"Send to packaging",kind:"end"},{id:"investigate",label:"Investigate retesting",kind:"process"},{id:"reject",label:"Reject batch",kind:"end"}],edges:[{id:"batch-qa",source:"batch-received",target:"qa-review"},{id:"qa-specs",source:"qa-review",target:"passes-specs"},{id:"specs-pass",source:"passes-specs",target:"final-review",label:"yes"},{id:"specs-investigate",source:"passes-specs",target:"investigate",label:"retest"},{id:"specs-reject",source:"passes-specs",target:"reject",label:"reject"},{id:"review-packaging",source:"final-review",target:"packaging"},{id:"investigate-review",source:"investigate",target:"final-review"}],layout:{direction:"TB",edgeRouting:"orthogonal"}}));let G="mindmap";class V extends i.Xsx("MindmapNodeMetadata")({depth:i.Aiz.check(i.OWK(0)),siblingIndex:i.Aiz.check(i.OWK(0))}){}class H extends S.extend("MindmapNode")({kind:i.xCb(["root","topic"]),metadata:V}){}class K extends i.Xsx("MindmapEdgeMetadata")({depth:i.Aiz.check(i.yJO(0)),siblingIndex:i.Aiz.check(i.OWK(0))}){}class Q extends I.extend("MindmapEdge")({metadata:K}){}class Z extends C.extend("MindmapDiagram")({type:i.uSQ(G),nodes:i.O31(H).pipe(i.fXn).check(i.tJb(2)),edges:i.O31(Q).pipe(i.fXn).check(i.tJb(1))}){}function ee(e){return function(e){P(e);let t=e.nodes.filter(e=>"root"===e.kind);if(1!==t.length)throw new T(`Mindmap must contain exactly one root topic; found ${t.length}.`);let r=t[0];if(!r||0!==r.metadata.depth)throw new T("Mindmap root topic must have depth 0.");let n=new Map,i=new Map(e.nodes.map(e=>[e.id,e])),a=new Map;for(let t of e.edges){n.set(t.target,(n.get(t.target)??0)+1);let e=i.get(t.source)?.metadata.depth,r=i.get(t.target),s=r?.metadata.depth;if(void 0===e||s!==e+1)throw new T(`Mindmap edge "${t.id}" must connect a topic to its immediate child.`);if(!r||t.metadata.depth!==r.metadata.depth||t.metadata.siblingIndex!==r.metadata.siblingIndex)throw new T(`Mindmap edge "${t.id}" metadata must match its child topic.`);a.set(t.source,[...a.get(t.source)??[],r.metadata.siblingIndex])}for(let t of e.nodes){let e=n.get(t.id)??0;if(t.id===r.id?0!==e:1!==e)throw new T(`Mindmap topic "${t.id}" must have ${t.id===r.id?"no parent":"exactly one parent"}.`)}for(let[e,t]of a){let r=t.map((e,t)=>t);if([...t].sort((e,t)=>e-t).some((e,t)=>e!==r[t]))throw new T(`Mindmap children of "${e}" must use contiguous sibling ordering from 0.`)}return e}(b(Z,e))}_(Z);let et=ee({id:"public-mindmap-capability",title:"Public mindmap generation",type:G,nodes:[{id:"topic-0",label:"Public mindmaps",kind:"root",metadata:{depth:0,siblingIndex:0}},{id:"topic-0-0",label:"Semantic input",kind:"topic",metadata:{depth:1,siblingIndex:0}},{id:"topic-0-0-0",label:"Nested topics",kind:"topic",metadata:{depth:2,siblingIndex:0}},{id:"topic-0-0-1",label:"Stable ordering",kind:"topic",metadata:{depth:2,siblingIndex:1}},{id:"topic-0-1",label:"Artifact output",kind:"topic",metadata:{depth:1,siblingIndex:1}},{id:"topic-0-1-0",label:"Scene",kind:"topic",metadata:{depth:2,siblingIndex:0}},{id:"topic-0-1-1",label:"Excalidraw",kind:"topic",metadata:{depth:2,siblingIndex:1}}],edges:[{id:"branch-0-0",source:"topic-0",target:"topic-0-0",metadata:{depth:1,siblingIndex:0}},{id:"branch-0-0-0",source:"topic-0-0",target:"topic-0-0-0",metadata:{depth:2,siblingIndex:0}},{id:"branch-0-0-1",source:"topic-0-0",target:"topic-0-0-1",metadata:{depth:2,siblingIndex:1}},{id:"branch-0-1",source:"topic-0",target:"topic-0-1",metadata:{depth:1,siblingIndex:1}},{id:"branch-0-1-0",source:"topic-0-1",target:"topic-0-1-0",metadata:{depth:2,siblingIndex:0}},{id:"branch-0-1-1",source:"topic-0-1",target:"topic-0-1-1",metadata:{depth:2,siblingIndex:1}}],layout:{direction:"LR",edgeRouting:"curved"}});A(q),A(et);let er=Object.freeze({maxDimension:16384,maxElements:600,maxGroupsPerElement:16,maxLayouts:128,maxLayers:64,maxPointsPerElement:256,maxSerializedBytes:15e5,maxTextLength:4096,maxZOrderEntries:600});function en(e){let t=new Set;for(let r of e){if(t.has(r))return r;t.add(r)}}function ei(e){return"x"in e&&"y"in e}function ea(e){let t=[];0===e.elements.length&&t.push({code:"empty_canvas",message:"CanvasSpec must contain at least one element.",path:"elements"}),e.elements.length>er.maxElements&&t.push({code:"limit_exceeded",message:`Canvas exceeds ${er.maxElements} elements.`,path:"elements"}),e.layers.length>er.maxLayers&&t.push({code:"limit_exceeded",message:`Canvas exceeds ${er.maxLayers} layers.`,path:"layers"}),e.layouts.length>er.maxLayouts&&t.push({code:"limit_exceeded",message:`Canvas exceeds ${er.maxLayouts} layout primitives.`,path:"layouts"}),(e.width>er.maxDimension||e.height>er.maxDimension)&&t.push({code:"limit_exceeded",message:`Canvas dimensions may not exceed ${er.maxDimension}.`,path:"width"});let r=en(e.elements.map(e=>e.id));r&&t.push({code:"duplicate_element_id",elementId:r,message:`Duplicate element id "${r}" is not allowed.`,path:"elements"});let n=en(e.layers.map(e=>e.id));n&&t.push({code:"duplicate_layer_id",message:`Duplicate layer id "${n}" is not allowed.`,path:"layers"});let i=en(e.zOrder);i&&t.push({code:"unknown_z_order_element",elementId:i,message:`zOrder contains duplicate element "${i}".`,path:"zOrder"}),e.zOrder.length>er.maxZOrderEntries&&t.push({code:"limit_exceeded",message:`zOrder exceeds ${er.maxZOrderEntries} entries.`,path:"zOrder"});let a=new Map(e.elements.map(e=>[e.id,e])),s=e.elements.filter(e=>"node"===e.type),o=new Map(s.map(e=>[e.nodeId,e])),l=en(s.map(e=>e.nodeId));l&&t.push({code:"invalid_binding",message:`Duplicate nodeId "${l}" makes connector bindings ambiguous.`,path:"elements"});let d=en(e.elements.flatMap(e=>"arrow"===e.type?[e.edgeId]:[]));d&&t.push({code:"invalid_binding",message:`Duplicate edgeId "${d}" makes connector selection ambiguous.`,path:"elements"});let c=en(e.elements.flatMap(e=>"text"===e.type&&e.containerId?[e.containerId]:[]));c&&t.push({code:"invalid_binding",elementId:c,message:`Container "${c}" has more than one bound text element.`,path:"elements"});let u=new Set(e.layers.map(e=>e.id));e.elements.forEach((e,r)=>{let n,i;if(t.push(...(n=[],i=`elements[${r}]`,"width"in e&&"height"in e&&(!(e.width>0)||!(e.height>0))&&n.push({code:"invalid_geometry",elementId:e.id,message:`Element "${e.id}" must have positive width and height.`,path:i}),"points"in e&&void 0!==e.points&&e.points.length>er.maxPointsPerElement&&n.push({code:"limit_exceeded",elementId:e.id,message:`Element "${e.id}" exceeds ${er.maxPointsPerElement} points.`,path:`${i}.points`}),"text"in e&&e.text.length>er.maxTextLength&&n.push({code:"limit_exceeded",elementId:e.id,message:`Text element "${e.id}" exceeds ${er.maxTextLength} characters.`,path:`${i}.text`}),"node"===e.type&&"polygon"===e.shape&&(!e.points||e.points.length<3)&&n.push({code:"invalid_polygon",elementId:e.id,message:`Polygon "${e.id}" requires at least three points.`,path:`${i}.points`}),e.groupIds&&e.groupIds.length>er.maxGroupsPerElement&&n.push({code:"limit_exceeded",elementId:e.id,message:`Element "${e.id}" exceeds ${er.maxGroupsPerElement} groups.`,path:`${i}.groupIds`}),n)),e.frameId){let n=a.get(e.frameId);n&&"frame"===n.type||t.push({code:"invalid_composition",elementId:e.id,message:`Element "${e.id}" references missing frame "${e.frameId}".`,path:`elements[${r}].frameId`})}if(e.layerId&&!u.has(e.layerId)&&t.push({code:"invalid_composition",elementId:e.id,message:`Element "${e.id}" references missing layer "${e.layerId}".`,path:`elements[${r}].layerId`}),e.groupIds&&en(e.groupIds)&&t.push({code:"invalid_composition",elementId:e.id,message:`Element "${e.id}" contains duplicate group ids.`,path:`elements[${r}].groupIds`}),"text"===e.type&&e.containerId){let n=a.get(e.containerId);n&&("node"===n.type||"arrow"===n.type)||t.push({code:"invalid_binding",elementId:e.id,message:`Text "${e.id}" references unsupported container "${e.containerId}".`,path:`elements[${r}].containerId`})}if("arrow"===e.type&&(o.has(e.sourceNodeId)||t.push({code:"invalid_binding",elementId:e.id,message:`Connector "${e.id}" references missing source "${e.sourceNodeId}".`,path:`elements[${r}].sourceNodeId`}),o.has(e.targetNodeId)||t.push({code:"invalid_binding",elementId:e.id,message:`Connector "${e.id}" references missing target "${e.targetNodeId}".`,path:`elements[${r}].targetNodeId`})),"line"===e.type)for(let[n,i]of[["startBinding",e.startBinding],["endBinding",e.endBinding]]){let s=i?a.get(i.elementId):void 0;i&&(!s||"node"!==s.type&&"frame"!==s.type)&&t.push({code:"invalid_binding",elementId:e.id,message:`Line "${e.id}" references missing binding "${i.elementId}".`,path:`elements[${r}].${n}`})}});let f=new Set(e.zOrder);for(let r of e.elements)f.has(r.id)||t.push({code:"missing_z_order_element",elementId:r.id,message:`Element "${r.id}" is missing from zOrder.`,path:"zOrder"});for(let r of e.zOrder)a.has(r)||t.push({code:"unknown_z_order_element",elementId:r,message:`zOrder references missing element "${r}".`,path:"zOrder"});for(let[r,n]of e.layouts.entries())for(let e of n.ids){let n=a.get(e);n&&ei(n)||t.push({code:"unknown_layout_target",elementId:e,message:`Layout references missing or non-positioned element "${e}".`,path:`layouts[${r}].ids`})}for(let r of e.elements.filter(e=>"frame"===e.type)){let e=new Set([r.id]),n=r.frameId;for(;n;){if(e.has(n)){t.push({code:"invalid_composition",elementId:r.id,message:`Frame "${r.id}" participates in a frame nesting cycle.`,path:"elements"});break}e.add(n);let i=a.get(n);n=i?.type==="frame"?i.frameId:void 0}}return t}function es(e){if("text"===e.type){let t=e.text.split("\n");return{x:e.x,y:e.y,width:e.maxWidth??Math.max(...t.map(e=>e.length))*e.fontSize*.62,height:t.length*e.fontSize*1.35}}return{x:e.x,y:e.y,width:e.width,height:e.height}}function eo(e,t){let r=new Map(e.map(e=>[e.id,e]));return t.flatMap(e=>{let t=r.get(e);return t&&ei(t)?[t]:[]})}function el(e,t){return e.map(e=>{var r,n;let i=t.get(e.id);return i?(r=i.x,n=i.y,ei(e)?{...e,x:r,y:n}:e):e})}function ed(e,t){return"x"===t?e.x:e.y}function ec(e,t){return"x"===t?e.width:e.height}function eu(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}function ef(e,t){let r=eu(e),n=t.x-r.x,i=t.y-r.y;return Math.abs(n)>=Math.abs(i)?{x:n>=0?e.x+e.width:e.x,y:r.y}:{x:r.x,y:i>=0?e.y+e.height:e.y}}let ep=/[,;]\s*(?:id|label|kind|group|source|target|title|direction|nodes|edges)\s*:?\s*$/i;function eh(e){let t=e.trim();for(;;){let e=t.replace(ep,"").trim();if(e===t)return t;t=e}}class em extends i.Xsx("ContractSchemaIssue")({code:eA("custom"),message:i.QfV,path:i.O31(i.pHd)},{identifier:void 0}){}class eg extends i.rNF()("ContractSchemaError",{issues:i.O31(i.O3D(em))}){}let ey=e=>{var t;if("InvalidType"!==e._tag)return c.vp(e);let r=c.bZ(e)?e.input:void 0;return`Invalid input: expected ${t=e.ast,d.Kg(t)?"string":d.Et(t)?"number":d.Lm(t)?"boolean":d.tF(t)?"array":d.RP(t)?"object":d.c$(t)?JSON.stringify(t.literal):"value"}, received ${null===r?"null":Array.isArray(r)?"array":typeof r}`},eb=c.ID({leafHook:ey});function ev(e){return"string"==typeof e||"number"==typeof e||"symbol"==typeof e}function e_(e,t){let r,n=i.q$Z(e,{errors:"all",reportInput:!0})(t);return u.oJ(n)?{data:n.success,success:!0}:{error:new eg({issues:(r=eb(n.failure.issue).issues.map(e=>{let t=(e.path??[]).flatMap(e=>{let t=ev(e)?e:null!==e&&"object"==typeof e&&"key"in e&&ev(e.key)?e.key:void 0;return void 0===t?[]:[t]});return{code:"custom",message:e.message,path:e.message.startsWith("Invalid discriminator value.")?[...t,"op"]:t}})).length>1&&r.every(e=>"source"===e.path[0])?[{code:"custom",message:"Invalid input",path:["source"]}]:r}),success:!1}}function ex(e){return Object.assign(e,{parse:t=>(function(e,t){let r=e_(e,t);if(r.success)return r.data;throw r.error})(e,t),safeParse:t=>e_(e,t)})}let ew=new Set(["x-sketchi-default","x-sketchi-one-of","const","exclusiveMaximum","exclusiveMinimum","maximum","maxLength","minimum","minItems","minLength","pattern"]),ek="x-sketchi-default",eS="x-sketchi-one-of";function eI(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function e$(e){let t=i._oz(i.AxX(e),{includeAnnotationKey:e=>ew.has(e),onExcessProperty:"error"});return function e(t){if(Array.isArray(t))return t.map(e);if(!eI(t))return t;let r=Object.fromEntries(Object.entries(t).map(([t,r])=>[t,e(r)])),n=!0===r[eS];delete r[eS],n&&Array.isArray(r.anyOf)&&(r.oneOf=r.anyOf,delete r.anyOf);let i=r.allOf;if(Array.isArray(i)){let e=[];for(let t of i)eI(t)&&Object.hasOwn(t,ek)?r.default=t[ek]:e.push(t);0===e.length?delete r.allOf:r.allOf=e}return r}({$schema:"https://json-schema.org/draft/2020-12/schema",...t.schema,...0===Object.keys(t.definitions).length?{}:{$defs:t.definitions}})}function eE(e){return i.O31(e).pipe(i.fXn).check(i.tJb(1,{message:"Too small: expected array to have >=1 items"}))}function eO(e){return i.Qrq(e)}function eC(e){return e.pipe(i.usV({messageMissingKey:"Invalid input: expected string, received undefined"}))}function eT(e){return e.pipe(i.usV({messageMissingKey:"Invalid input: expected object, received undefined"}))}function eM(e){return e.pipe(i.usV({messageMissingKey:"Invalid input: expected array, received undefined"}))}function eP(e){return i.xCb(e).annotate({message:`Invalid option: expected one of ${e.map(e=>JSON.stringify(e)).join("|")}`})}function eA(e){return ej(e,i.QfV)}function eN(e){return ej(e,i.wNn)}function eR(e){return ej(e,i.v8c)}function ej(e,t){let r=i.hzj()([],()=>(t,r,n)=>t===e?s.PyW(e):s.fJG(new c.eE(r,t,n)),{message:`Invalid literal value, expected ${JSON.stringify(e)}`,toCodecJson:()=>i.nfo()(t.annotate({const:e}),{decode:f.pd(()=>e),encode:f.pd(e=>e)})});return i.uSQ(e).pipe(i.GLL(r))}let eD=i.QfV.check(i.tJb(1,{message:"Too small: expected string to have >=1 characters"})),eU=eC(eD),eF=i.wYs,eB=i.wNn.check(i.MIs(),i.yJO(0,{message:"Too small: expected number to be >0"})),eL=/^#[0-9a-fA-F]{6}$/u;function ez(e){return i.QfV.annotate(void 0===e?{}:{default:e}).check(i.Pto(eL,{message:`Invalid string: must match pattern /${eL.source}/`}))}let eW=ez();ex(eW);let eJ=["excalidraw","scene","png"],eY=["excalidraw","scene"],eX=Object.assign(ex(eP(eJ)),{options:eJ}),eq=Object.assign(ex(eP(eY)),{options:eY});class eG extends i.Xsx("ArtifactProvenance")({sourceArtifactId:eU.pipe(i.Wa3)},{identifier:void 0}){}ex(eG);let eV=["missing_field","invalid_type","invalid_enum","invalid_color","duplicate_node_id","duplicate_edge_id","missing_edge_source","missing_edge_target","self_loop","missing_start","multiple_starts","missing_end","start_has_incoming","end_has_outgoing","unreachable_node","nonterminating_node","missing_outgoing_edge","underbranched_decision","unlabeled_decision_branch","duplicate_decision_branch_label","disconnected_graph","flowchart_too_large","mindmap_too_deep","mindmap_too_large","request_too_large","generic_label","label_too_long","quality_below_threshold","render_failed","text_overflow","arrow_binding_invalid","arrow_overlap","export_invalid_scene","storage_read_failed","storage_write_failed","unsupported_artifact_format","patch_source_unavailable","unknown_patch_target","unsupported_patch_operation","patch_preserve_connectivity_failed","patch_output_invalid","duplicate_element_id","duplicate_layer_id","invalid_canvas_binding","invalid_canvas_composition","invalid_canvas_geometry","invalid_polygon","canvas_limit_exceeded","invalid_z_order","unknown_layout_target"],eH=Object.assign(ex(eP(eV)),{options:eV}),eK=eP(["request","diagram","node","edge","element","layer","artifact"]),eQ=eP(["input","canvas","flowchart","mindmap","quality","render","export","storage"]);class eZ extends i.Xsx("CodeModeIssueRef")({kind:eK,id:eO(eD),path:eO(eD)},{identifier:void 0}){}ex(eZ);class e0 extends i.Xsx("CodeModeIssue")({code:eH,severity:eP(["error","warning"]),stage:eQ,ref:eO(eZ),message:eU,hint:eU},{identifier:void 0}){}ex(e0);let e1=["start","process","decision","end"],e2=Object.assign(ex(eP(e1)),{options:e1}),e5=["setDefaultStyle","setStyle","setShape","translate","replaceText","rerouteEdges","insert","remove","replace","reorder","group","ungroup"];Object.assign(ex(eP(e5)),{options:e5});class e3 extends i.Xsx("FlowchartSpecNode")({id:eU,label:eU,kind:e2,description:eO(eD)},{identifier:void 0}){}class e6 extends i.Xsx("FlowchartSpecEdge")({id:eO(eD),source:eU,target:eU,label:eO(eD)},{identifier:void 0}){}let e8=eP(["TB","LR"]),e9=e8.annotate({default:"TB"}).pipe(i.E$i(s.PyW("TB")));class e4 extends i.Xsx("FlowchartSpecLayout")({direction:e9},{identifier:void 0}){}let e7=g.accentColor,te=ez(e7).pipe(i.E$i(s.PyW(e7))),tt=g.backgroundColor,tr=ez(tt).pipe(i.E$i(s.PyW(tt)));class tn extends i.Xsx("FlowchartSpecStyle")({accentColor:te,backgroundColor:tr},{identifier:void 0}){}let ti=[],ta=i.O31(e6).pipe(i.fXn).annotate({default:ti}).pipe(i.E$i(s.PyW(ti))),ts={direction:"TB"},to=e4.annotate({default:ts}).pipe(i.E$i(s.PyW(ts)),i.usV({[ek]:ts})),tl={accentColor:g.accentColor,backgroundColor:g.backgroundColor},td=tn.annotate({default:tl}).pipe(i.E$i(s.PyW(tl)),i.usV({[ek]:tl}));class tc extends i.Xsx("FlowchartSpec")({id:eO(eD),title:eU,nodes:eM(eE(e3)),edges:ta,layout:to,style:td},{identifier:void 0}){}ex(tc),ex(e3),ex(e6),ex(e4),ex(tn);class tu extends i.Xsx("SequenceParticipantSpec")({id:eU,label:eU,kind:eO(eD)},{identifier:void 0}){}class tf extends i.Xsx("SequenceMessageSpec")({id:eO(eD),source:eU,target:eU,label:eU,type:eO(eP(["message","return"])),style:eO(eP(["solid","dashed"]))},{identifier:void 0}){}let tp=[],th=i.O31(tf).pipe(i.fXn).annotate({default:tp}).pipe(i.E$i(s.PyW(tp))),tm={accentColor:g.accentColor,backgroundColor:g.backgroundColor},tg=i._kM({accentColor:ez(e7).pipe(i.E$i(s.PyW(e7))),backgroundColor:ez(tt).pipe(i.E$i(s.PyW(tt)))}).annotate({default:tm}).pipe(i.E$i(s.PyW(tm)));class ty extends i.Xsx("SequenceDiagramSpec")({id:eO(eD),title:eU,participants:eM(eE(tu)),messages:th,style:tg},{identifier:void 0}){}ex(ty),ex(tu),ex(tf);let tb=eO(eE(eX)),tv=eO(i.O31(eq).pipe(i.fXn)),t_=eO(i.wNn.check(i.MIs(),i.OWK(0,{message:"Too small: expected number to be >=0"}),i.biW(10,{message:"Too big: expected number to be <=10"})));class tx extends i.Xsx("BuildFlowchartOptions")({artifactFormats:tb,inlineArtifacts:tv,minQualityScore:t_},{identifier:void 0}){}ex(eO(tx));class tw extends i.Xsx("BuildFlowchartRequest")({requestId:eO(eD),spec:eT(tc),options:eO(tx)},{identifier:void 0}){}let tk=tc.mapFields(({id:e,title:t,nodes:r,edges:n,layout:i})=>({id:e,title:t,nodes:r,edges:n,layout:i})),tS=i._kM({requestId:eO(eD),spec:eT(tk)}),tI=i.rcy(tS,{leafHook:ey,parseOptions:{errors:"all"}});Object.assign(tI["~standard"],{jsonSchema:{input:()=>e$(tS),output:()=>e$(tS)}});let t$=Object.assign(ex(tw),{omit:e=>tI});class tE extends i.Xsx("BuildSequenceDiagramRequest")({requestId:eO(eD),spec:eT(ty),options:eO(tx)},{identifier:void 0}){}let tO=ex(tE),tC=i.QfV.check(i.tJb(1,{message:"Too small: expected string to have >=1 characters"}),i.HNH(function(e){let t=eh(e);return t.length>0&&!/^(?:""|''|``)$/.test(t)},{message:"Must contain semantic text after normalization."})),tT=eT(i.DYE(()=>tM).annotate({identifier:"__schema0"})),tM=i._kM({label:eC(tC),children:i.Qrq(i.O31(tT).pipe(i.fXn))});ex(tT);class tP extends i.Xsx("MindmapSpecLayout")({direction:eP(["LR","RL"]).annotate({default:"LR"}).pipe(i.E$i(s.PyW("LR")))},{identifier:void 0}){}let tA={direction:"LR"},tN=tP.annotate({default:tA}).pipe(i.E$i(s.PyW(tA)),i.usV({[ek]:tA})),tR={accentColor:g.accentColor,backgroundColor:g.backgroundColor},tj=i._kM({accentColor:ez(e7).pipe(i.E$i(s.PyW(tR.accentColor))),backgroundColor:ez(tR.backgroundColor).pipe(i.E$i(s.PyW(tR.backgroundColor)))}).annotate({default:tR}).pipe(i.E$i(s.PyW(tR))),tD=i._kM({id:eO(eD),title:eC(tC),root:tT,layout:tN,style:tj});class tU extends i.Xsx("MindmapSpec")(tD,{identifier:void 0}){}ex(tU);let tF=i._kM({requestId:eO(eD),spec:eT(tD),options:eO(tx)});i.Xsx("BuildMindmapRequest")(tF,{identifier:void 0});let tB=ex(tF);class tL extends i.Xsx("ScenePoint")({x:eF.pipe(i.Wa3),y:eF.pipe(i.Wa3)},{identifier:void 0}){}ex(tL);let tz={frameId:eO(eD).pipe(i.Wa3),groupIds:eO(i.O31(eD).pipe(i.fXn).annotate({maxItems:er.maxGroupsPerElement})).pipe(i.Wa3),layerId:eO(eD).pipe(i.Wa3),locked:eO(i.v8c).pipe(i.Wa3),opacity:eO(i.wNn.check(i.MIs(),i.Bt9({minimum:0,maximum:100}))).pipe(i.Wa3),zIndex:eO(i.Aiz).pipe(i.Wa3)},tW={fillColor:eO(eW).pipe(i.Wa3),fillStyle:eO(eP(["cross-hatch","hachure","solid"])).pipe(i.Wa3),roughness:eO(eP([0,1,2])).pipe(i.Wa3),strokeColor:eO(eW).pipe(i.Wa3),strokeStyle:eO(eP(["dashed","dotted","solid"])).pipe(i.Wa3),strokeWidth:eO(eP([1,2,4])).pipe(i.Wa3)},tJ=i.T9y(eP(["arrow","bar","circle","diamond","triangle"])),tY=i.O31(tL).pipe(i.fXn).check(i.tJb(2,{message:"Too small: expected array to have >=2 items"}),i.NYj(er.maxPointsPerElement,{message:`Too big: expected array to have <=${er.maxPointsPerElement} items`}));class tX extends i.Xsx("NodeSceneElement")({...tz,...tW,type:eA("node"),id:eU,nodeId:eU,kind:eO(eD),rendererRole:eO(eP(["sequence-lifeline"])),shape:eP(["rectangle","ellipse","diamond","circle","polygon"]).pipe(i.Wa3),points:eO(tY).pipe(i.Wa3),textColor:eO(eW).pipe(i.Wa3),x:eF.pipe(i.Wa3),y:eF.pipe(i.Wa3),width:eB.pipe(i.Wa3),height:eB.pipe(i.Wa3),label:eU.pipe(i.Wa3)},{identifier:void 0}){}class tq extends i.Xsx("TextSceneElement")({...tz,type:eA("text"),id:eU,containerId:eO(eD),textColor:eO(eW).pipe(i.Wa3),x:eF.pipe(i.Wa3),y:eF.pipe(i.Wa3),text:eU.pipe(i.Wa3),fontSize:eB,fontFamily:eO(eP(["hand","mono","sans"])),maxWidth:eO(eB),textAlign:eO(eP(["center","left","right"])),verticalAlign:eO(eP(["bottom","middle","top"]))},{identifier:void 0}){}class tG extends i.Xsx("ArrowSceneElement")({...tz,...tW,type:eA("arrow"),id:eU,edgeId:eU,sourceNodeId:eU,targetNodeId:eU.pipe(i.Wa3),startArrowhead:eO(tJ).pipe(i.Wa3),endArrowhead:eO(tJ).pipe(i.Wa3),textColor:eO(eW).pipe(i.Wa3),points:eM(tY).pipe(i.Wa3),label:eO(eD).pipe(i.Wa3)},{identifier:void 0}){}class tV extends i.Xsx("CanvasLineBinding")({elementId:eU,focus:eO(eF),gap:eO(eF)},{identifier:void 0}){}class tH extends i.Xsx("LineSceneElement")({...tz,...tW,type:eA("line"),id:eU,points:eM(tY).pipe(i.Wa3),startBinding:eO(tV).pipe(i.Wa3),endBinding:eO(tV).pipe(i.Wa3),startArrowhead:eO(tJ).pipe(i.Wa3),endArrowhead:eO(tJ).pipe(i.Wa3),label:eO(eD).pipe(i.Wa3),textColor:eO(eW).pipe(i.Wa3)},{identifier:void 0}){}class tK extends i.Xsx("FrameSceneElement")({...tz,...tW,type:eA("frame"),id:eU,name:eO(eD).pipe(i.Wa3),x:eF.pipe(i.Wa3),y:eF.pipe(i.Wa3),width:eB.pipe(i.Wa3),height:eB.pipe(i.Wa3)},{identifier:void 0}){}class tQ extends i.Xsx("CanvasLayer")({id:eU,name:eO(eD),locked:eO(i.v8c),visible:eO(i.v8c)},{identifier:void 0}){}let tZ=eM(eE(eD));class t0 extends i.Xsx("CanvasFlowLayout")({type:eP(["row","column","stack"]),ids:tZ,x:eO(eF),y:eO(eF),gap:eO(eF)},{identifier:void 0}){}class t1 extends i.Xsx("CanvasGridLayout")({type:eA("grid"),ids:tZ,columns:i.Aiz.check(i.OWK(1,{message:"Too small: expected number to be >=1"})),x:eO(eF),y:eO(eF),columnGap:eO(eF),rowGap:eO(eF)},{identifier:void 0}){}class t2 extends i.Xsx("CanvasAlignLayout")({type:eA("align"),ids:tZ,axis:eP(["x","y"]),alignment:eP(["center","end","start"])},{identifier:void 0}){}class t5 extends i.Xsx("CanvasDistributeLayout")({type:eA("distribute"),ids:tZ,axis:eP(["x","y"]),gap:eO(eF)},{identifier:void 0}){}ex(tX),ex(tq),ex(tG),ex(tH),ex(tK);let t3=i.gPz([tX,tq,tG,tH,tK],{mode:"oneOf"}).annotate({[eS]:!0}),t6=i.gPz([t0,t1,t2,t5],{mode:"oneOf"}),t8=i.O31(tQ).pipe(i.fXn).annotate({default:[],maxItems:er.maxLayers}).pipe(i.E$i(s.PyW([]))),t9=i.O31(t6).pipe(i.fXn).annotate({default:[],maxItems:er.maxLayouts}).pipe(i.E$i(s.PyW([]))),t4=i.O31(eD).pipe(i.fXn).annotate({default:[],maxItems:er.maxZOrderEntries}).pipe(i.E$i(s.PyW([])));class t7 extends i.Xsx("CanvasSpec")({kind:eA("canvas"),version:eN(1),diagramId:eU,title:eU,width:eB.pipe(i.Wa3),height:eB.pipe(i.Wa3),accentColor:eW.pipe(i.Wa3),backgroundColor:eW.pipe(i.Wa3),elements:eM(i.O31(t3).pipe(i.fXn).annotate({maxItems:er.maxElements})),layers:t8,layouts:t9,zOrder:t4},{identifier:void 0}){}let re=ex(t7);class rt extends i.Xsx("CreateCanvasRequest")({requestId:eO(eD),spec:eT(t7),options:eO(tx)},{identifier:void 0}){}let rr=ex(rt),rn=i.mSG(i.QfV,i.$r1).check(i.HNH(e=>"string"==typeof e.id&&e.id.length>0&&"string"==typeof e.type&&e.type.length>0,{message:"Invalid input"}));ex(rn);class ri extends i.Xsx("ExcalidrawScene")({appState:i.mSG(i.QfV,i.$r1),elements:i.O31(rn).pipe(i.fXn)},{identifier:void 0}){}ex(ri);class ra extends ri.extend("ExcalidrawFile")({files:i.mSG(i.QfV,i.$r1),source:eU,type:eA("excalidraw"),version:eN(2)},{identifier:void 0}){}let rs=ex(ra);class ro extends i.Xsx("GetArtifactRequest")({artifactId:eU,format:eO(eX),inline:eO(i.v8c)},{identifier:void 0}){}let rl=ex(ro);class rd extends i.Xsx("DiagramSelector")({ids:eO(i.O31(eD).pipe(i.fXn)),nodeIds:eO(i.O31(eD).pipe(i.fXn)),edgeIds:eO(i.O31(eD).pipe(i.fXn)),kinds:eO(i.O31(e2).pipe(i.fXn)),labels:eO(i.O31(eD).pipe(i.fXn)),scope:eO(eP(["all","nodes","edges"]))},{identifier:void 0}){}ex(rd);class rc extends i.Xsx("DiagramStylePatch")({strokeColor:eO(eW),fillColor:eO(eW),textColor:eO(eW),backgroundColor:eO(eW)},{identifier:void 0}){}ex(rc);let ru=["rectangle","diamond","ellipse","circle","polygon"],rf=Object.assign(ex(eP(ru)),{options:ru});class rp extends i.Xsx("SetDefaultStyleOperation")({op:eA("setDefaultStyle"),style:eT(rc)},{identifier:void 0}){}class rh extends i.Xsx("SetStyleOperation")({op:eA("setStyle"),selector:eT(rd),style:eT(rc)},{identifier:void 0}){}class rm extends i.Xsx("SetShapeOperation")({op:eA("setShape"),selector:eT(rd),shape:rf},{identifier:void 0}){}class rg extends i.Xsx("TranslateOperation")({op:eA("translate"),selector:eT(rd),dx:eF,dy:eF},{identifier:void 0}){}class ry extends i.Xsx("ReplaceTextOperation")({op:eA("replaceText"),selector:eT(rd),text:eU},{identifier:void 0}){}class rb extends i.Xsx("RerouteEdgesOperation")({op:eA("rerouteEdges"),selector:eO(rd)},{identifier:void 0}){}let rv=eM(eE(eD));class r_ extends i.Xsx("InsertElementsOperation")({op:eA("insert"),elements:eM(eE(t3)),beforeId:eO(eD),afterId:eO(eD)},{identifier:void 0}){}class rx extends i.Xsx("RemoveElementsOperation")({op:eA("remove"),selector:eT(rd)},{identifier:void 0}){}class rw extends i.Xsx("ReplaceElementOperation")({op:eA("replace"),id:eU,element:eT(t3)},{identifier:void 0}){}class rk extends i.Xsx("ReorderElementsOperation")({op:eA("reorder"),ids:rv,beforeId:eO(eD),afterId:eO(eD)},{identifier:void 0}){}class rS extends i.Xsx("GroupElementsOperation")({op:eA("group"),ids:rv,groupId:eU},{identifier:void 0}){}class rI extends i.Xsx("UngroupElementsOperation")({op:eA("ungroup"),ids:rv,groupId:eO(eD)},{identifier:void 0}){}let r$=i.gPz([rp,rh,rm,rg,ry,rb,r_,rx,rw,rk,rS,rI],{mode:"oneOf"}).annotate({[eS]:!0,message:`Invalid discriminator value. Expected ${e5.map(e=>`'${e}'`).join(" | ")}`});class rE extends i.Xsx("ArtifactPatchSource")({artifactId:eU,format:eO(eA("scene"))},{identifier:void 0}){}class rO extends i.Xsx("InlineScenePatchSource")({scene:eT(t7)},{identifier:void 0}){}let rC=i.gPz([rE,rO]).annotate({message:"Invalid input"});class rT extends i.Xsx("ApplyDiagramPatchOptions")({artifactFormats:tb,inlineArtifacts:tv,preserveConnectivity:eO(i.v8c)},{identifier:void 0}){}ex(eO(rT));class rM extends i.Xsx("ApplyDiagramPatchRequest")({requestId:eO(eD),source:rC.annotateKey({messageMissingKey:"Invalid input"}),operations:eM(eE(r$)),options:eO(rT),intent:eO(eD)},{identifier:void 0}){}let rP=ex(rM),rA=i._kM({id:eD,title:eD,nodes:i.O31(e3).pipe(i.fXn),edges:i.O31(e6.mapFields(e=>({...e,id:eD}))).pipe(i.fXn),layout:i._kM({direction:e8}),style:i._kM({accentColor:eW,backgroundColor:eW})}),rN=i._kM({id:eD,label:eD,children:i.O31(i.DYE(()=>rN)).pipe(i.fXn)}),rR=i._kM({id:eD,title:eD,root:rN,layout:i._kM({direction:eP(["LR","RL"])}),style:i._kM({accentColor:eW,backgroundColor:eW})}),rj=i._kM({id:eD,title:eD,participants:i.O31(tu).pipe(i.fXn),messages:i.O31(tf.mapFields(e=>({...e,id:eD}))).pipe(i.fXn),style:i._kM({accentColor:eW,backgroundColor:eW})}),rD=i._kM({code:i.QfV,passed:i.v8c,severity:eP(["error","warning"]),message:i.QfV,refs:i.O31(eZ).pipe(i.fXn)}),rU=i._kM({accepted:i.v8c,score:i.wNn,threshold:i.wNn,summary:i._kM({nodeCount:i.wNn,edgeCount:i.wNn}),checks:i.O31(rD).pipe(i.fXn)}),rF=i._kM({format:eX,mimeType:i.QfV,url:eO(i.QfV),expiresAt:eO(i.QfV),inline:eO(i.$r1),sizeBytes:eO(i.wNn)}),rB=i._kM({artifactId:i.QfV,diagramId:i.QfV,formats:i.O31(rF).pipe(i.fXn),provenance:eO(eG),preview:eO(rF)}),rL=i._kM({artifactId:eO(i.QfV),diagramId:eO(i.QfV),formats:eO(i.O31(rF).pipe(i.fXn))});class rz extends i.Xsx("BuildFlowchartAccepted")({ok:eR(!0),status:eA("accepted"),buildId:i.QfV,requestId:eO(i.QfV),normalizedSpec:rA,quality:rU,artifact:rB,issues:i.O31(e0).pipe(i.fXn)},{identifier:void 0}){}class rW extends i.Xsx("BuildFlowchartRejected")({ok:eR(!1),status:eP(["invalid_input","invalid_flowchart","quality_failed","render_failed","export_failed","storage_failed"]),buildId:eO(i.QfV),requestId:eO(i.QfV),normalizedSpec:eO(rA),quality:eO(rU),partial:eO(rL),issues:i.O31(e0).pipe(i.fXn)},{identifier:void 0}){}i.gPz([rz,rW]);class rJ extends i.Xsx("BuildMindmapAccepted")({ok:eR(!0),status:eA("accepted"),buildId:i.QfV,requestId:eO(i.QfV),normalizedSpec:rR,quality:rU,artifact:rB,issues:i.O31(e0).pipe(i.fXn)},{identifier:void 0}){}class rY extends i.Xsx("BuildMindmapRejected")({ok:eR(!1),status:eP(["invalid_input","invalid_mindmap","quality_failed","render_failed","export_failed","storage_failed"]),buildId:eO(i.QfV),requestId:eO(i.QfV),normalizedSpec:eO(rR),quality:eO(rU),partial:eO(rL),issues:i.O31(e0).pipe(i.fXn)},{identifier:void 0}){}i.gPz([rJ,rY]);class rX extends i.Xsx("BuildSequenceDiagramAccepted")({ok:eR(!0),status:eA("accepted"),buildId:i.QfV,requestId:eO(i.QfV),normalizedSpec:rj,quality:rU,artifact:rB,issues:i.O31(e0).pipe(i.fXn)},{identifier:void 0}){}class rq extends i.Xsx("BuildSequenceDiagramRejected")({ok:eR(!1),status:eP(["invalid_input","invalid_sequence","quality_failed","render_failed","export_failed","storage_failed"]),buildId:eO(i.QfV),requestId:eO(i.QfV),normalizedSpec:eO(rj),quality:eO(rU),partial:eO(rL),issues:i.O31(e0).pipe(i.fXn)},{identifier:void 0}){}i.gPz([rX,rq]);class rG extends i.Xsx("GetArtifactAccepted")({ok:eR(!0),artifactId:i.QfV,diagramId:i.QfV,format:eX,mimeType:i.QfV,url:eO(i.QfV),expiresAt:eO(i.QfV),inline:eO(i.$r1),sizeBytes:eO(i.wNn),provenance:eO(eG)},{identifier:void 0}){}class rV extends i.Xsx("GetArtifactRejected")({ok:eR(!1),status:eP(["invalid_input","not_found","format_unavailable","expired","storage_failed"]),issues:i.O31(e0).pipe(i.fXn)},{identifier:void 0}){}i.gPz([rG,rV]);class rH extends i.Xsx("ApplyDiagramPatchAccepted")({ok:eR(!0),status:eA("accepted"),patchId:i.QfV,requestId:eO(i.QfV),sourceArtifactId:eO(i.QfV),artifact:rB,issues:i.O31(e0).pipe(i.fXn)},{identifier:void 0}){}class rK extends i.Xsx("ApplyDiagramPatchRejected")({ok:eR(!1),status:eP(["invalid_input","source_unavailable","target_not_found","unsupported_operation","connectivity_changed","render_failed","export_failed","storage_failed"]),patchId:eO(i.QfV),requestId:eO(i.QfV),sourceArtifactId:eO(i.QfV),partial:eO(rL),issues:i.O31(e0).pipe(i.fXn)},{identifier:void 0}){}i.gPz([rH,rK]);class rQ extends i.Xsx("CreateCanvasAccepted")({ok:eR(!0),status:eA("accepted"),buildId:i.QfV,requestId:eO(i.QfV),normalizedSpec:t7,artifact:rB,issues:i.O31(e0).pipe(i.fXn)},{identifier:void 0}){}class rZ extends i.Xsx("CreateCanvasRejected")({ok:eR(!1),status:eP(["invalid_input","invalid_canvas","limit_exceeded","render_failed","export_failed","storage_failed"]),buildId:eO(i.QfV),requestId:eO(i.QfV),normalizedSpec:eO(t7),partial:eO(rL),issues:i.O31(e0).pipe(i.fXn)},{identifier:void 0}){}let r0=i.gPz([rQ,rZ]),r1=i.xCb(["read","readManifest","write"]);class r2 extends i.rNF()("CodeModeArtifactStorageError",{cause:i.kld(),message:i.QfV,operation:r1}){}class r5 extends a.kl()("@sketchi/diagram-agent/CodeModeArtifactStorage"){}let r3={excalidraw:"application/vnd.excalidraw+json",png:"image/png",scene:"application/vnd.sketchi.scene+json"};function r6(e){return"excalidraw"===e||"scene"===e}function r8(e){return{format:e.format,mimeType:e.mimeType,sizeBytes:e.sizeBytes}}function r9(e){return structuredClone(e)}function r4(e){return new TextEncoder().encode(JSON.stringify(e)).length}function r7(e){return t=>{var r;return r2.make({cause:t,message:(r="write"===e?"Artifact storage failed.":"Artifact read failed.",t instanceof Error?t.message:r),operation:e})}}let ne=l.QZ(r5)(s.Q56(s.OH5(function(){let e=new Map,t=new Map;return{close:s.OH5(()=>{t.clear(),e.clear()}),storage:{read:s.fn("codeMode.artifacts.memory.read")(function*(e,r){return yield*s.SvU({try:()=>{let n=t.get(`${e}:${r}`);return n?{...n,data:r9(n.data)}:null},catch:r7("read")})}),readManifest:s.fn("codeMode.artifacts.memory.readManifest")(function*(t){return yield*s.SvU({try:()=>{let r=e.get(t);return r?r9(r):null},catch:r7("readManifest")})}),write:s.fn("codeMode.artifacts.memory.write")(function*(r){let n=yield*o.Ru;return yield*s.SvU({try:()=>{var i;let a,s=r.formats.map(r8),o=r.provenance?r9(r.provenance):void 0,l={artifactId:r.artifactId,diagramId:r.diagramId,formats:s,...o?{provenance:o}:{},createdAt:new Date(n).toISOString()};for(let n of(e.set(r.artifactId,l),r.formats))t.set(`${r.artifactId}:${n.format}`,{...n,data:r9(n.data)});let d=r.formats.map(e=>{var t;return t=r.inlineFormats,{format:e.format,mimeType:e.mimeType,...r6(e.format)&&t.includes(e.format)?{inline:e.data}:{},sizeBytes:e.sizeBytes}});return a=(i={artifactId:r.artifactId,diagramId:r.diagramId,formats:d,...r.provenance?{provenance:r9(r.provenance)}:{}}).formats.find(e=>"scene"===e.format),{artifactId:i.artifactId,diagramId:i.diagramId,formats:i.formats,...i.provenance?{provenance:i.provenance}:{},...a?{preview:a}:{}}},catch:r7("write")})})}}}),e=>e.close).pipe(s.TjK(e=>e.storage)));function nt(e,t="storage_write_failed"){return{code:t,severity:"error",stage:"storage",message:e,hint:"Retry the request; if it keeps failing, inspect the artifact store binding."}}function nr(e){return new Map(e.map((e,t)=>[e.id,t]))}function nn(e){return{type:"text",id:`label:${e.nodeId}`,containerId:e.id,x:e.x+e.width/2,y:e.y+e.height/2,text:e.label,fontSize:14,maxWidth:Math.max(1,e.width-36)}}function ni(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}function na(e,t,r){return Math.min(r,Math.max(t,e))}function ns(e,t,r=0){let n,i=(n="top"===t||"bottom"===t?e.width/2-16:e.height/2-16)>0?na(r,-n,n):0,a=ni(e),s=e.width/2,o=e.height/2;if("diamond"===e.shape&&s>0&&o>0){if("top"===t||"bottom"===t){let e=a.x+i,r=o*(1-Math.abs(i)/s);return{x:e,y:"top"===t?a.y-r:a.y+r}}let e=a.y+i,r=s*(1-Math.abs(i)/o);return{x:"left"===t?a.x-r:a.x+r,y:e}}if(("ellipse"===e.shape||"circle"===e.shape)&&s>0&&o>0){if("top"===t||"bottom"===t){let e=a.x+i,r=o*Math.sqrt(Math.max(0,1-(i/s)**2));return{x:e,y:"top"===t?a.y-r:a.y+r}}let e=a.y+i,r=s*Math.sqrt(Math.max(0,1-(i/o)**2));return{x:"left"===t?a.x-r:a.x+r,y:e}}switch(t){case"top":return{x:e.x+e.width/2+i,y:e.y};case"right":return{x:e.x+e.width,y:e.y+e.height/2+i};case"bottom":return{x:e.x+e.width/2+i,y:e.y+e.height};case"left":return{x:e.x,y:e.y+e.height/2+i}}}function no(e){return`${e.edgeId}:${e.endpoint}`}function nl(e){let t=[];for(let r of e){let e=t[t.length-1];e&&e.x===r.x&&e.y===r.y||t.push(r)}let r=t[0];return r?[r,...t.slice(1)]:[{x:0,y:0}]}function nd(e,t,r){return e>t+.01&&e<r-.01}function nc(e,t,r,n){return Math.min(t,n)-Math.max(e,r)>.01}function nu(e,t,r){let n=0;for(let i=0;i<e.length-1;i+=1){let a=e[i],s=e[i+1];if(a&&s)for(let e of t)!r.has(e.nodeId)&&(a.y===s.y?nd(a.y,e.y,e.y+e.height)&&nc(Math.min(a.x,s.x),Math.max(a.x,s.x),e.x,e.x+e.width):a.x===s.x&&nd(a.x,e.x,e.x+e.width)&&nc(Math.min(a.y,s.y),Math.max(a.y,s.y),e.y,e.y+e.height))&&(n+=1)}return n}function nf(e){let t=0;for(let r=0;r<e.length-1;r+=1){let n=e[r],i=e[r+1];n&&i&&(t+=Math.abs(i.x-n.x)+Math.abs(i.y-n.y))}return t}function np(e){let t=[];for(let r=0;r<e.points.length-1;r+=1){let n=e.points[r],i=e.points[r+1];if(n&&i){if(n.y===i.y){t.push({arrowId:e.arrowId,isFirstSegment:0===r,isLastSegment:r===e.points.length-2,max:Math.max(n.x,i.x),min:Math.min(n.x,i.x),orientation:"horizontal",segmentIndex:r,sourceNodeId:e.sourceNodeId,staticCoordinate:n.y,targetNodeId:e.targetNodeId});continue}n.x===i.x&&t.push({arrowId:e.arrowId,isFirstSegment:0===r,isLastSegment:r===e.points.length-2,max:Math.max(n.y,i.y),min:Math.min(n.y,i.y),orientation:"vertical",segmentIndex:r,sourceNodeId:e.sourceNodeId,staticCoordinate:n.x,targetNodeId:e.targetNodeId})}}return t.filter(e=>e.max-e.min>.01)}function nh(e,t){return Math.min(e.max,t.max)-Math.max(e.min,t.min)}function nm(e,t,r){let n=np({arrowId:`edge:${r.edge.id}`,points:e,sourceNodeId:r.edge.source,targetNodeId:r.edge.target}),i=t.flatMap(e=>np({arrowId:e.id,points:e.points,sourceNodeId:e.sourceNodeId,targetNodeId:e.targetNodeId})),a=0;for(let e of n)for(let t of i)e.arrowId===t.arrowId||e.orientation!==t.orientation||Math.abs(e.staticCoordinate-t.staticCoordinate)>.01||e.isFirstSegment&&t.isFirstSegment&&e.sourceNodeId===t.sourceNodeId||e.isLastSegment&&t.isLastSegment&&e.targetNodeId===t.targetNodeId||.01>=nh(e,t)||(a+=1);return a}function ng(e,t){let r=np({arrowId:`edge:${t.edge.id}`,points:e,sourceNodeId:t.edge.source,targetNodeId:t.edge.target}),n=0;for(let e=0;e<r.length;e+=1){let t=r[e];if(t)for(let i=e+1;i<r.length;i+=1){let e=r[i];!e||t.orientation!==e.orientation||Math.abs(t.staticCoordinate-e.staticCoordinate)>.01||.01>=nh(t,e)||(n+=1)}}return n}function ny(e){let t=e[0],r=e[e.length-1];if(!t||!r)return 0;let n=e.map(e=>e.x),i=e.map(e=>e.y),a=0;return r.x<t.x?a+=Math.max(0,Math.max(...n)-t.x):r.x>t.x&&(a+=Math.max(0,t.x-Math.min(...n))),r.y<t.y?a+=Math.max(0,Math.max(...i)-t.y):r.y>t.y&&(a+=Math.max(0,t.y-Math.min(...i))),a}function nb(e){let t=e[0],r=e[e.length-1];if(!t||!r)return 0;let n=e.map(e=>e.x),i=e.map(e=>e.y),a=0;return r.x<t.x?a+=Math.max(0,r.x-Math.min(...n)):r.x>t.x&&(a+=Math.max(0,Math.max(...n)-r.x)),r.y<t.y?a+=Math.max(0,r.y-Math.min(...i)):r.y>t.y&&(a+=Math.max(0,Math.max(...i)-r.y)),a}function nv(e,t,r){switch(r){case"top":return t.y<e.y;case"right":return t.x>e.x;case"bottom":return t.y>e.y;case"left":return t.x<e.x}}function n_(e,t){let r=e[0],n=e[1],i=e[e.length-1],a=e[e.length-2],s=0;return n&&nv(r,n,t.sourceEdge)&&(s+=1),a&&i&&nv(i,a,t.targetEdge)&&(s+=1),s}function nx(e,t,r){switch(t){case"top":return{x:e.x,y:e.y-r};case"right":return{x:e.x+r,y:e.y};case"bottom":return{x:e.x,y:e.y+r};case"left":return{x:e.x-r,y:e.y}}}function nw(e,t,r,n,i){var a;let s,o=Math.abs(r.x-t.x)>=Math.abs(r.y-t.y),l=new Set([e.source.nodeId,e.target.nodeId]),d=Math.min(...n.map(e=>e.x)),c=Math.max(...n.map(e=>e.x+e.width)),u=Math.min(...n.map(e=>e.y)),f=Math.max(...n.map(e=>e.y+e.height)),p="left"===e.sourceEdge||"left"===e.targetEdge||ni(e.target).x<ni(e.source).x,h="top"===e.sourceEdge||"top"===e.targetEdge||ni(e.source).y<=ni(e.target).y,m=18*e.index,g=d-56-m,y=c+56+m,b=u-48-m,v=f+48+m,_=e.index%4*18/2,x=Math.min(e.source.x,e.target.x)-56-_,w=Math.max(e.source.x+e.source.width,e.target.x+e.target.width)+56+_,k=Math.min(e.source.y,e.target.y)-48-_,S=Math.max(e.source.y+e.source.height,e.target.y+e.target.height)+48+_,I=p?g:y,$=p?y:g,E=h?b:v,O=h?v:b,C=p?x:w,T=p?w:x,M=h?k:S,P=h?S:k,A=[0,36+e.index%4*18],N=(n,i)=>{let a=i>0?nx(t,e.sourceEdge,i):t,s=i>0?nx(r,e.targetEdge,i):r;return nl([t,a,{x:n,y:a.y},{x:n,y:s.y},s,r])},R=(n,i)=>{let a=i>0?nx(t,e.sourceEdge,i):t,s=i>0?nx(r,e.targetEdge,i):r;return nl([t,a,{x:a.x,y:n},{x:s.x,y:n},s,r])},j=[...A.map(e=>R(M,e)),...A.map(e=>R(P,e)),...A.map(e=>N(C,e)),...A.map(e=>N(T,e)),...A.map(e=>R(E,e)),...A.map(e=>R(O,e)),...A.map(e=>N(I,e)),...A.map(e=>N($,e))],D=[...A.map(e=>N(C,e)),...A.map(e=>N(T,e)),...A.map(e=>R(M,e)),...A.map(e=>R(P,e)),...A.map(e=>N(I,e)),...A.map(e=>N($,e)),...A.map(e=>R(E,e)),...A.map(e=>R(O,e))];return(s=(a=o?j:D)[0])?a.slice(1).reduce((t,r)=>{let a=nu(t,n,l),s=nu(r,n,l);if(s<a)return r;if(a<s)return t;let o=ng(t,e),d=ng(r,e);if(d<o)return r;if(o<d)return t;let c=nm(t,i,e),u=nm(r,i,e);if(u<c)return r;if(c<u)return t;let f=n_(t,e),p=n_(r,e);if(p>f)return r;if(f>p)return t;let h=ny(t),m=ny(r);if(m<h)return r;if(h<m)return t;let g=nb(t),y=nb(r);return y<g?r:g<y?t:nf(r)<nf(t)?r:t},s):[{x:0,y:0}]}function nk(e){return e.flatMap(e=>"arrow"===e.type||"line"===e.type?[...e.points]:"text"===e.type?[{x:e.x,y:e.y},{x:e.x+(e.maxWidth??e.text.length),y:e.y+e.fontSize}]:[{x:e.x,y:e.y},{x:e.x+e.width,y:e.y+e.height}])}function nS(e,t,r){return{x:e.x+t,y:e.y+r}}function nI(e){var t;let r,n,i,a,s,o=A(e),l=function(e){let t="TB"===e.layout.direction||"BT"===e.layout.direction,r=new Map(e.nodes.map(e=>{let t,r,n,i,a;return[e.id,(a=(i=e.label.split("\n").flatMap(e=>(function(e){if(e.length<=18)return[e];let t=[],r="";for(let n of e.split(" ")){if(n.length>18){r&&(t.push(r),r=""),t.push(...function(e){if(e.length<=18)return[e];let t=[];for(let r=0;r<e.length;r+=18)t.push(e.slice(r,r+18));return t}(n));continue}let e=r?`${r} ${n}`:n;if(e.length<=18){r=e;continue}t.push(r),r=n}return r&&t.push(r),t})(e)).join("\n")).split("\n"),t={text:i,width:Math.ceil(14*Math.max(...a.map(e=>e.length))*.62+36),height:Math.ceil(14*a.length*1.35+28)},n="start"===(r=e.kind?.toLowerCase())||"end"===r?"ellipse":"decision"===r?"diamond":"rectangle",{type:"node",id:`node:${e.id}`,nodeId:e.id,...e.kind?{kind:e.kind}:{},shape:n,x:0,y:0,width:Math.max(184,t.width+("diamond"===n?32:20*("ellipse"===n))),height:Math.max(72,t.height+32*("diamond"===n)),label:t.text})]})),n=function(e){let t=new Map,r=new Map;for(let n of e)t.set(n.target,[...t.get(n.target)??[],n]),r.set(n.source,[...r.get(n.source)??[],n]);return{incoming:t,outgoing:r}}(e.edges),i=function(e,t,r){let n=new Map,i=new Set;function a(e){for(let t of(n.set(e,"visiting"),r.get(e)??[])){let e=n.get(t.target);if("visiting"===e){i.add(t.id);continue}e||a(t.target)}n.set(e,"visited")}let s=e.nodes.find(e=>0===(t.get(e.id)??[]).length)??e.nodes[0];for(let t of(s&&a(s.id),e.nodes))n.has(t.id)||a(t.id);return i}(e,n.incoming,n.outgoing),a=function(e,t,r){let n=nr(e.nodes),i=new Map(e.nodes.map(e=>[e.id,0])),a=new Map(e.nodes.map(e=>[e.id,0]));for(let t of e.edges)r.has(t.id)||i.set(t.target,(i.get(t.target)??0)+1);let s=[];for(let t of e.nodes)(i.get(t.id)??0)===0&&s.push(t.id);let o=new Set;for(let e=0;e<s.length;e+=1){let l=s[e];if(!l||o.has(l))continue;o.add(l);let d=a.get(l)??0;for(let e of t.outgoing.get(l)??[]){if(r.has(e.id))continue;a.set(e.target,Math.max(a.get(e.target)??0,d+1));let t=(i.get(e.target)??0)-1;i.set(e.target,t),0===t&&function(e,t,r){let n=r.get(t)??Number.MAX_SAFE_INTEGER,i=e.findIndex(e=>(r.get(e)??Number.MAX_SAFE_INTEGER)>n);-1===i?e.push(t):e.splice(i,0,t)}(s,e.target,n)}}for(let n of e.nodes){if(o.has(n.id))continue;let e=(t.incoming.get(n.id)??[]).filter(e=>!r.has(e.id)).map(e=>a.get(e.source)??0);a.set(n.id,e.length>0?Math.max(...e)+1:0)}return a}(e,n,i),s=Array.from((function(e,t,r,n,i){let a=nr(e.nodes),s=new Map;for(let n of e.nodes){let e=r.get(n.id)??0,i=t.get(n.id);i&&s.set(e,[...s.get(e)??[],i])}for(let e=0;e<4;e+=1)for(let e of Array.from(s.keys()).sort((e,t)=>e-t)){let t=s.get(e);if(!t||t.length<2)continue;let r=new Map;(s.get(e-1)??[]).forEach((e,t)=>{r.set(e.nodeId,t)});let o=new Map;(s.get(e+1)??[]).forEach((e,t)=>{o.set(e.nodeId,t)});let l=e=>{let t=[...(n.incoming.get(e.nodeId)??[]).filter(e=>!i.has(e.id)).map(e=>r.get(e.source)).filter(e=>void 0!==e),...(n.outgoing.get(e.nodeId)??[]).filter(e=>!i.has(e.id)).map(e=>o.get(e.target)).filter(e=>void 0!==e)];return 0===t.length?a.get(e.nodeId)??Number.MAX_SAFE_INTEGER:t.reduce((e,t)=>e+t,0)/t.length};s.set(e,[...t].sort((e,t)=>{let r=l(e)-l(t);return Math.abs(r)>.001?r:(a.get(e.nodeId)??Number.MAX_SAFE_INTEGER)-(a.get(t.nodeId)??Number.MAX_SAFE_INTEGER)}))}return s})(e,r,a,n,i).entries()).sort(([e],[t])=>e-t).map(([e,r])=>({breadth:r.reduce((e,r,n)=>e+(t?r.width:r.height)+112*(n>0),0),depth:Math.max(...r.map(e=>t?e.height:e.width)),rank:e,shapes:r})),o=Math.max(...s.map(e=>e.breadth)),l=48,d=[];for(let e of s){let r=48+Math.max(0,o-e.breadth)/2;for(let n of e.shapes)t?(d.push({...n,x:r,y:l+Math.max(0,e.depth-n.height)/2}),r+=n.width+112):(d.push({...n,x:l+Math.max(0,e.depth-n.width)/2,y:r}),r+=n.height+112);l+=e.depth+96}if("BT"===e.layout.direction){let e=Math.max(...d.map(e=>e.y+e.height));return d.map(t=>({...t,y:48+e-t.y-t.height}))}if("RL"===e.layout.direction){let e=Math.max(...d.map(e=>e.x+e.width));return d.map(t=>({...t,x:48+e-t.x-t.width}))}return d}(o),d=new Map(l.map(e=>[e.nodeId,e])),c=o.edges.map((e,t)=>(function(e,t,r,n){let i=r.get(e.source),a=r.get(e.target);if(!i||!a)throw Error(`Cannot render edge "${e.id}" with unresolved nodes.`);let{sourceEdge:s,targetEdge:o}=function(e,t,r){let n=ni(e),i=ni(t),a=i.x-n.x,s=i.y-n.y,o=e.kind?.toLowerCase();if("LR"===r||"RL"===r)return a>=0?{sourceEdge:"right",targetEdge:"left"}:{sourceEdge:"left",targetEdge:"right"};if(s<0)return!(Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)>.01)&&Math.abs(a)>Math.abs(s)?{sourceEdge:a>0?"right":"left",targetEdge:"bottom"}:{sourceEdge:"top",targetEdge:"bottom"};let l="decision"===o&&s>e.height+96;return"decision"===o&&s>0&&(0!==a||l)?{sourceEdge:a<0?"left":"right",targetEdge:"top"}:s>0?{sourceEdge:"bottom",targetEdge:"top"}:Math.abs(a)>Math.abs(s)?a>0?{sourceEdge:"right",targetEdge:"left"}:{sourceEdge:"left",targetEdge:"right"}:s>0?{sourceEdge:"bottom",targetEdge:"top"}:{sourceEdge:"top",targetEdge:"bottom"}}(i,a,n);return{edge:e,index:t,source:i,sourceEdge:s,target:a,targetEdge:o}})(e,t,d,o.layout.direction)),u=function(e){let t=new Map;for(let s of e){var r,n,i,a;let e=(r=s.source.nodeId,n=s.sourceEdge,`${r}:${n}`),o=(i=s.target.nodeId,a=s.targetEdge,`${i}:${a}`);t.set(e,[...t.get(e)??[],{edgeId:s.edge.id,endpoint:"source"}]),t.set(o,[...t.get(o)??[],{edgeId:s.edge.id,endpoint:"target"}])}let s=new Map;for(let e of t.values())e.forEach((t,r)=>{s.set(no(t),(r-(e.length-1)/2)*18)});return s}(c),f=[];for(let e of c)f.push(function(e,t,r,n,i,a){let{edge:s,source:o,sourceEdge:l,target:d,targetEdge:c}=e,u=ns(o,l,r.get(no({edgeId:s.id,endpoint:"source"}))??0),f=ns(d,c,r.get(no({edgeId:s.id,endpoint:"target"}))??0),p=nl([u,f]);if(function(e,t,r){let n=ni(e),i=ni(t);switch(r){case"TB":return i.y<n.y;case"BT":return i.y>n.y;case"LR":return i.x<n.x;case"RL":return i.x>n.x}}(o,d,a))p=nw(e,u,f,n,i);else if("orthogonal"===t&&u.x!==f.x&&u.y!==f.y){var h,m,g;let t,r,n,i=e.index%4*18,a=(h=u.y,m=f.y,g=f.y<u.y?-i:i,t=h+(m-h)/2,(r=Math.min(h,m)+18)<(n=Math.max(h,m)-18)?na(t+g,r,n):t),s="left"===l?{x:u.x-36-i,y:u.y}:"right"===l?{x:u.x+36+i,y:u.y}:u,o="left"===c?{x:f.x-36-i,y:f.y}:"right"===c?{x:f.x+36+i,y:f.y}:f;p=nl([u,s,{x:s.x,y:a},{x:o.x,y:a},o,f])}return"orthogonal"===t&&(nu(p,n,new Set([o.nodeId,d.nodeId]))>0||ng(p,e)>0||nm(p,i,e)>0)&&(p=nw(e,u,f,n,i)),{type:"arrow",id:`edge:${s.id}`,edgeId:s.id,sourceNodeId:s.source,targetNodeId:s.target,points:p,...s.label?{label:s.label}:{}}}(e,o.layout.edgeRouting,u,l,f,o.layout.direction));let p=l.map(nn),h=(i=Math.max(0,48-(n={x:Math.min(...(r=nk(t=[...f,...l,...p])).map(e=>e.x)),y:Math.min(...r.map(e=>e.y))}).x),a=Math.max(0,48-n.y),0===i&&0===a?[...t]:t.map(e=>"arrow"===e.type?{...e,points:function(e,t,r){let[n,...i]=e;return[nS(n,t,r),...i.map(e=>nS(e,t,r))]}(e.points,i,a)}:"line"===e.type?{...e,points:function(e,t,r){let[n,i,...a]=e;return[nS(n,t,r),nS(i,t,r),...a.map(e=>nS(e,t,r))]}(e.points,i,a)}:{...e,x:e.x+i,y:e.y+a})),m={width:Math.max(...(s=nk(h)).map(e=>e.x))+48,height:Math.max(...s.map(e=>e.y))+48},g=[...l.map(e=>e.id),...p.map(e=>e.id),...f.map(e=>e.id)];return{kind:"canvas",version:1,diagramId:o.id,title:o.title,width:m.width,height:m.height,accentColor:o.style.accentColor,backgroundColor:o.style.backgroundColor,elements:h,layers:[],layouts:[],zOrder:g}}let n$="sequence-lifeline";function nE(e){return`${e}:lifeline`}let nO="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",nC=nO.slice(10),nT=new Map;function nM(e){let t=nT.get(e);if(void 0===t){t=new Uint8Array(256);for(let r=0;r<e.length;r++)t[e.charCodeAt(r)]=r;nT.set(e,t)}return t}function nP(e,t,r,n){let i=r[0];if(null!=t&&e>=t)throw Error(e+" >= "+t);if(e.slice(-1)===i||t&&t.slice(-1)===i)throw Error("trailing zero");if(t){let a=0;for(;(e[a]||i)===t[a];)a++;if(a>0)return t.slice(0,a)+nP(e.slice(a),t.slice(a),r,n)}let a=e?n[e.charCodeAt(0)]:0,s=null!=t?n[t.charCodeAt(0)]:r.length;return s-a>1?r[Math.round(.5*(a+s))]:t&&t.length>1?t.slice(0,1):r[a]+nP(e.slice(1),null,r,n)}function nA(e,t,r){if(e.length!==nN(e[0],t,r))throw Error("invalid integer part of order key: "+e)}function nN(e,t,r){let n=r[e.charCodeAt(0)];if(t[n]===e){let e=t.length/2;return n<e?e-n+1:n-e+2}throw Error("invalid order key head: "+e)}function nR(e,t,r){let n=nN(e[0],t,r);if(n>e.length)throw Error("invalid order key: "+e);return e.slice(0,n)}function nj(e,t,r,n){if(nF(e,t,r))throw Error("invalid order key: "+e);let i=nR(e,r,n);if(e.slice(i.length).slice(-1)===t[0])throw Error("invalid order key: "+e)}function nD(e,t,r,n,i){nA(e,n,i);let a=e[0],s=t[0],o="";for(let n=e.length-1;n>=1;n--){let i=r[e.charCodeAt(n)]+1;if(i!==t.length)return a+e.slice(1,n)+t[i]+o;o=s+o}let l=i[a.charCodeAt(0)];if(l===n.length-1)return null;let d=n[l+1],c=nN(d,n,i)-nN(a,n,i);return d+(c>0?o+s:c<0?o.slice(1):o)}let nU=new Map;function nF(e,t,r){let n=nU.get(r);void 0===n&&(n=new Map,nU.set(r,n));let i=t.charCodeAt(0),a=n.get(i);return void 0===a&&(a=r[0]+t[0].repeat(r.length/2),n.set(i,a)),e===a}function nB(e){for(let t=1;t<e.length;t++)if(e.charCodeAt(t-1)>=e.charCodeAt(t))return!1;return!0}function nL(e){for(let t=0;t<e.length;t++)if(e.charCodeAt(t)>255)return!1;return!0}let nz=new Set,nW=new Set,nJ=new Set(["rectangle","ellipse","diamond"]),nY=m.ink;function nX(e){return"number"==typeof e&&Number.isFinite(e)?e:null}function nq(e){if(!Array.isArray(e)||e.length<2)return null;let t=nX(e[0]),r=nX(e[1]);return null===t||null===r?null:[t,r]}function nG(e){let t=nX(e.x),r=nX(e.y),n=nX(e.width),i=nX(e.height);return null===t||null===r||null===n||null===i?null:{x:t,y:r,width:n,height:i}}function nV(e){return 1e-4>Math.abs(e-.5)?.5001:e}function nH(e,t){let r=nG(e);return r&&0!==r.width&&0!==r.height?[nV((t.x-r.x)/r.width),nV((t.y-r.y)/r.height)]:null}function nK(e,t){return{elementId:e?.id??"",focus:0,gap:0,fixedPoint:e?nH(e,t):null}}function nQ(e,t,r){let n=function(e){let t=0x811c9dc5;for(let r of e)t^=r.charCodeAt(0),t=Math.imul(t,0x1000193);return Math.abs(t)||1}(e);return{id:e,angle:0,fillStyle:r&&"fillStyle"in r?r.fillStyle??"solid":"solid",frameId:r?.frameId??null,groupIds:[...r?.groupIds??[]],index:t,isDeleted:!1,link:null,locked:r?.locked??!1,opacity:r?.opacity??100,roughness:r&&"roughness"in r?r.roughness??1:1,seed:n,strokeStyle:r&&"strokeStyle"in r?r.strokeStyle??"solid":"solid",strokeWidth:r&&"strokeWidth"in r?r.strokeWidth??2:2,updated:1,version:1,versionNonce:n+1}}function nZ(e,t){return Math.ceil(e.split("\n").length*t*1.35)}function n0(e){var t,r;let n=Math.max(1,Math.min(e.maxWidth,(t=e.text,r=e.fontSize,Math.ceil(Math.max(...t.split("\n").map(e=>e.length))*r*.62)))),i=nZ(e.text,e.fontSize);return{...nQ(e.id,e.index,e.element),...void 0===e.locked?{}:{locked:e.locked},type:"text",x:e.x-n/2,y:e.y-i/2,width:n,height:i,backgroundColor:"transparent",boundElements:null,containerId:e.containerId??null,fontFamily:e.element?.fontFamily==="mono"?3:e.element?.fontFamily==="sans"?2:5,fontSize:e.fontSize,lineHeight:1.35,originalText:e.text,roundness:null,strokeColor:e.textColor??nY,text:e.text,textAlign:e.element?.textAlign??"center",verticalAlign:e.element?.verticalAlign??"middle",autoResize:!0}}function n1(e){return e.points[e.points.length-1]??e.points[0]}function n2(e,t,r){if(!e)return null;let n=t.get(e.elementId);return n?{elementId:e.elementId,focus:e.focus??0,gap:e.gap??0,fixedPoint:nH(n,r)}:null}function n5(e){return"node"===e.type}function n3(e){return"text"===e.type}function n6(e){return"arrow"===e.type}function n8(e){return"line"===e.type}function n9(e){return"frame"===e.type}function n4(e){var t;let r,n,i,a,s,o,l,d=(r=new Map(e.layers.map(e=>[e.id,e])),i=new Set((n=e.elements.filter(e=>{let t=e.layerId?r.get(e.layerId):void 0;return t?.visible!==!1})).flatMap(e=>"node"===e.type?[e.nodeId]:[])),s=new Set((a=n.filter(e=>"arrow"!==e.type||i.has(e.sourceNodeId)&&i.has(e.targetNodeId))).flatMap(e=>"text"===e.type?[]:[e.id])),l=new Set((o=a.filter(e=>"text"!==e.type||!e.containerId||s.has(e.containerId))).map(e=>e.id)),o.map(e=>{let t=e.layerId?r.get(e.layerId):void 0;return{...e.frameId&&!l.has(e.frameId)?(({frameId:e,...t})=>t)(e):e,...t?.locked===!0?{locked:!0}:{}}})),c=d.filter(n5),u=d.filter(n3),f=new Set(d.map(e=>e.id)),p=new Map,h=new Set(u.flatMap(e=>e.containerId?[e.containerId]:[]));for(let e of c){if(h.has(e.id)||e.rendererRole===n$)continue;let t=`__sketchi_node_label__${e.id}`,r=t,n=2;for(;f.has(r);)r=`${t}:${n}`,n+=1;f.add(r),p.set(r,e.id),u.push({type:"text",id:r,containerId:e.id,...e.frameId?{frameId:e.frameId}:{},...e.groupIds?{groupIds:[...e.groupIds]}:{},...e.layerId?{layerId:e.layerId}:{},...void 0!==e.locked?{locked:e.locked}:{},...void 0!==e.opacity?{opacity:e.opacity}:{},...e.textColor?{textColor:e.textColor}:{},x:e.x+e.width/2,y:e.y+e.height/2,text:e.label,fontSize:16,maxWidth:Math.max(1,e.width-24)})}let m=new Map(u.map(e=>[e.containerId??"",e])),g=d.filter(n6),y=d.filter(n8),b=function(e,t,r){let n=new Map,i=new Map(e.map(e=>[e.nodeId,e.id]));for(let e of t)for(let t of[e.sourceNodeId,e.targetNodeId]){let r=i.get(t);r&&n.set(r,[...n.get(r)??[],e.id])}for(let e of r)for(let t of[e.startBinding,e.endBinding])t&&n.set(t.elementId,[...n.get(t.elementId)??[],e.id]);return n}(c,g,y),v=new Map,_=[],x=null,w=()=>{let e=function(e,t,r,n){if(void 0!==n){var i=n;if(!nW.has(i)){if(i.length<2||i.length%2!=0||!nB(i))throw Error("intDigits must be an even number of at least 2 characters in strictly ascending character code order: "+i);if(!nL(i))throw Error("intDigits must be single-byte (char code 0-255): "+i);nW.add(i)}}else n=r??nC;if(void 0!==r){var a=r;if(!nz.has(a)){if(a.length<2||!nB(a))throw Error("digits must be at least 2 characters in strictly ascending character code order: "+a);if(!nL(a))throw Error("digits must be single-byte (char code 0-255): "+a);nz.add(a)}}else r=nO;let s=nM(r),o=nM(n);if(null!=e&&nj(e,r,n,o),null!=t&&nj(t,r,n,o),null!=e&&null!=t&&e>t){let r=e;e=t,t=r}if(null==e){if(null==t)return n[n.length/2]+r[0];let e=nR(t,n,o),i=t.slice(e.length);if(nF(e,r,n))return e+nP("",i,r,s);if(e<t)return e;let a=function(e,t,r,n,i){nA(e,n,i);let a=e[0],s=t[t.length-1],o="";for(let n=e.length-1;n>=1;n--){let i=r[e.charCodeAt(n)]-1;if(-1!==i)return a+e.slice(1,n)+t[i]+o;o=s+o}let l=i[a.charCodeAt(0)];if(0===l)return null;let d=n[l-1],c=nN(d,n,i)-nN(a,n,i);return d+(c>0?o+s:c<0?o.slice(1):o)}(e,r,s,n,o);if(null==a)throw Error("cannot decrement any more");return a}if(null==t){let t=nR(e,n,o),i=e.slice(t.length),a=nD(t,r,s,n,o);return null==a?t+nP(i,null,r,s):a}let l=nR(e,n,o),d=e.slice(l.length),c=nR(t,n,o),u=t.slice(c.length);if(l===c)return l+nP(d,u,r,s);let f=nD(l,r,s,n,o);if(null==f)throw Error("cannot increment any more");return f<t?f:l+nP(d,null,r,s)}(x,null);return x=e,e};for(let t of c){let r=m.get(t.id),n=function(e){let t=e.text?nZ(e.text.text,e.text.fontSize)+18:0,r=Math.max(e.shape.height,t),n="circle"===e.shape.shape?"ellipse":e.shape.shape,i=[...e.text&&"polygon"!==e.shape.shape?[{id:e.text.id,type:"text"}]:[],...e.arrowIds.map(e=>({id:e,type:"arrow"}))];if("polygon"===e.shape.shape){let t=e.shape.points??[{x:e.shape.width/2,y:0},{x:e.shape.width,y:e.shape.height},{x:0,y:e.shape.height}],[r,...n]=t;return{...nQ(e.shape.id,e.index,e.shape),type:"line",x:e.shape.x,y:e.shape.y,width:e.shape.width,height:e.shape.height,backgroundColor:e.shape.fillColor??"transparent",boundElements:e.arrowIds.map(e=>({id:e,type:"arrow"})),customData:{sketchiShape:"polygon"},endArrowhead:null,endBinding:null,lastCommittedPoint:null,points:[...t,r].map(e=>[e.x,e.y]),roundness:null,startArrowhead:null,startBinding:null,strokeColor:e.shape.strokeColor??e.scene.accentColor}}return{...nQ(e.shape.id,e.index,e.shape),type:n,x:e.shape.x,y:e.shape.y,width:e.shape.width,height:r,backgroundColor:e.shape.fillColor??"transparent",boundElements:i.length>0?i:null,roundness:"rectangle"===n?{type:3}:null,strokeColor:e.shape.strokeColor??e.scene.accentColor,...e.shape.rendererRole===n$?{customData:{sketchiRendererRole:n$}}:{}}}({scene:e,shape:t,arrowIds:b.get(t.id)??[],index:w(),...r?{text:r}:{}});v.set(t.nodeId,n),_.push(n)}for(let r of d.filter(n9)){let n={...nQ((t={element:r,index:w(),scene:e}).element.id,t.index,t.element),type:"frame",x:t.element.x,y:t.element.y,width:t.element.width,height:t.element.height,backgroundColor:t.element.fillColor??"transparent",boundElements:null,name:t.element.name??null,roundness:null,strokeColor:t.element.strokeColor??t.scene.accentColor},i=b.get(r.id)??[];n.boundElements=i.length?i.map(e=>({id:e,type:"arrow"})):null,_.push(n)}for(let e of u){let t=e.containerId&&(c.some(t=>t.id===e.containerId&&"polygon"!==t.shape)||g.some(t=>t.id===e.containerId));_.push(n0({element:e,id:e.id,index:w(),...t?{containerId:e.containerId}:{},fontSize:e.fontSize,maxWidth:e.maxWidth??160,...e.textColor?{textColor:e.textColor}:{},text:e.text,x:e.x,y:e.y}))}for(let t of g){let r=m.get(t.id);_.push(function(e){let t=e.arrow.points[0],r=n1(e.arrow),n=e.arrow.points.length>2;return{...nQ(e.arrow.id,e.index,e.arrow),type:"arrow",x:t.x,y:t.y,width:r.x-t.x,height:r.y-t.y,backgroundColor:"transparent",boundElements:e.text?[{id:e.text.id,type:"text"}]:e.arrow.label?[{id:`${e.arrow.id}:label`,type:"text"}]:null,elbowed:n,endArrowhead:void 0===e.arrow.endArrowhead?"arrow":e.arrow.endArrowhead,endBinding:nK(e.targetShape,r),...n?{fixedSegments:[],startIsSpecial:null,endIsSpecial:null}:{},points:e.arrow.points.map(e=>[e.x-t.x,e.y-t.y]),roundness:n?null:{type:2},startArrowhead:e.arrow.startArrowhead??null,startBinding:nK(e.sourceShape,t),strokeColor:e.arrow.strokeColor??e.scene.accentColor,strokeStyle:e.arrow.strokeStyle??"solid"}}({arrow:t,scene:e,index:w(),sourceShape:v.get(t.sourceNodeId),targetShape:v.get(t.targetNodeId),...r?{text:r}:{}}));let n=t.label&&!r?function(e){if(!e.arrow.label)return null;let t=e.arrow.points[0],r=n1(e.arrow);return n0({id:`${e.arrow.id}:label`,index:e.index,containerId:e.arrow.id,fontSize:13,...void 0===e.arrow.locked?{}:{locked:e.arrow.locked},maxWidth:160,...e.arrow.textColor?{textColor:e.arrow.textColor}:{},text:e.arrow.label,x:(t.x+r.x)/2,y:(t.y+r.y)/2-10})}({arrow:t,index:w()}):null;n&&_.push(n)}let k=new Map(_.map(e=>[e.id,e]));for(let t of y)if(_.push(function(e){let[t,...r]=e.element.points,n=r[r.length-1]??t,i=void 0!==e.element.startArrowhead||void 0!==e.element.endArrowhead||void 0!==e.element.startBinding||void 0!==e.element.endBinding,a=i&&e.element.points.length>2;return{...nQ(e.element.id,e.index,e.element),type:i?"arrow":"line",x:t.x,y:t.y,width:n.x-t.x,height:n.y-t.y,backgroundColor:e.element.fillColor??"transparent",boundElements:null,...i?{elbowed:a}:{},endArrowhead:e.element.endArrowhead??null,endBinding:n2(e.element.endBinding,e.elementsById,n),...a?{fixedSegments:[],startIsSpecial:null,endIsSpecial:null}:{},points:e.element.points.map(e=>[e.x-t.x,e.y-t.y]),roundness:e.element.points.length>2&&!a?{type:2}:null,startArrowhead:e.element.startArrowhead??null,startBinding:n2(e.element.startBinding,e.elementsById,t),strokeColor:e.element.strokeColor??e.scene.accentColor}}({element:t,elementsById:k,index:w(),scene:e})),t.label){let e=t.points[0],r=t.points[t.points.length-1]??e;_.push(n0({id:`${t.id}:label`,index:w(),fontSize:13,...void 0===t.locked?{}:{locked:t.locked},maxWidth:160,...t.textColor?{textColor:t.textColor}:{},text:t.label,x:(e.x+r.x)/2,y:(e.y+r.y)/2-10}))}let S=new Map(e.zOrder.map((e,t)=>[e,t])),I=e=>{if(S.has(e.id))return e.id;let t=p.get(e.id);return t||(e.id.endsWith(":label")?e.id.slice(0,-6):e.id)};for(let e of(_.sort((e,t)=>(S.get(I(e))??Number.MAX_SAFE_INTEGER)-(S.get(I(t))??Number.MAX_SAFE_INTEGER)),x=null,_))e.index=w();return{appState:{viewBackgroundColor:e.backgroundColor,zoom:{value:Math.max(.42,Math.round(100*Math.min(1,860/Math.max(e.width,1),340/Math.max(e.height,1)))/100)}},elements:_}}function n7(e,t){let r=e[t];if(!(r&&"object"==typeof r))return null;let n=r.elementId;return"string"==typeof n?n:null}function ie(e){return nq(e)}function it(e){let t=nX(e.x)??0,r=nX(e.y)??0,n=n7(e,"startBinding"),i=n7(e,"endBinding"),a=Array.isArray(e.points)?e.points.map(ie).filter(e=>!!e):[],s=[];for(let o=0;o<a.length-1;o+=1){let l=a[o],d=a[o+1];if(!l||!d)continue;let[c,u]=l,[f,p]=d,h=t+c,m=r+u,g=t+f,y=r+p;if(.001>=Math.abs(m-y)){s.push({arrowId:e.id,endBindingElementId:i,isLastSegment:o===a.length-2,max:Math.max(h,g),min:Math.min(h,g),orientation:"horizontal",segmentIndex:o,startBindingElementId:n,staticCoordinate:m});continue}.001>=Math.abs(h-g)&&s.push({arrowId:e.id,endBindingElementId:i,isLastSegment:o===a.length-2,max:Math.max(m,y),min:Math.min(m,y),orientation:"vertical",segmentIndex:o,startBindingElementId:n,staticCoordinate:h})}return s.filter(e=>e.max-e.min>.001)}function ir(e,t,r){return e>t+.01&&e<r-.01}function ii(e,t,r,n){return Math.min(t,n)-Math.max(e,r)>.01}function ia(e){if(nJ.has(e.type)||"frame"===e.type)return!0;let t=e.customData;return"line"===e.type&&null!==t&&"object"==typeof t&&"polygon"===t.sketchiShape}function is(e,t,r){return e>=t-.01&&e<=r+.01}function io(e,t){return .01>=Math.abs(e-t)}function il(e){let t=[],r=new Map(e.elements.map(e=>[e.id,e])),n=new Set(e.elements.filter(ia).map(e=>e.id));for(let i of(0===e.elements.length&&t.push({code:"empty-scene",message:"Excalidraw scene must contain at least one shape."}),e.elements)){if("arrow"===i.type){let e=!0===i.elbowed;for(let a of((Array.isArray(i.points)?i.points:[]).length>2&&!e&&t.push({code:"invalid-elbow-binding",elementId:i.id,message:`Arrow "${i.id}" has an orthogonal route but is not marked elbowed.`}),e&&null!==i.fixedSegments&&!Array.isArray(i.fixedSegments)&&t.push({code:"invalid-elbow-binding",elementId:i.id,message:`Elbow arrow "${i.id}" is missing fixedSegments metadata.`}),["startBinding","endBinding"])){if(null===i[a]||void 0===i[a])continue;let s=n7(i,a);if(!(s&&n.has(s))){t.push({code:"missing-arrow-binding",elementId:i.id,message:`Arrow "${i.id}" has invalid ${a}.`});continue}let o=r.get(s);o&&!function(e,t,r){let n=e.boundElements;return!!Array.isArray(n)&&n.some(e=>!!(e&&"object"==typeof e)&&e.id===t&&e.type===r)}(o,i.id,"arrow")&&t.push({code:"missing-bound-arrow",elementId:o.id,message:`Shape "${o.id}" does not include bound arrow "${i.id}".`});let l=function(e,t){let r=nX(e.x)??0,n=nX(e.y)??0,i=Array.isArray(e.points)?e.points.map(ie).filter(e=>!!e):[],a="startBinding"===t?i[0]:i[i.length-1];return a?{x:r+a[0],y:n+a[1]}:null}(i,a);if(o&&l&&!function(e,t){let r=nG(t);if(!r)return!1;if("diamond"===t.type){let t=r.width/2,n=r.height/2;if(0===t||0===n)return!1;let i=r.x+t,a=r.y+n;return io(Math.abs(e.x-i)/t+Math.abs(e.y-a)/n,1)}if("ellipse"===t.type){let t=r.width/2,n=r.height/2;if(0===t||0===n)return!1;let i=r.x+t,a=r.y+n;return io(((e.x-i)/t)**2+((e.y-a)/n)**2,1)}let n=(io(e.x,r.x)||io(e.x,r.x+r.width))&&is(e.y,r.y,r.y+r.height),i=(io(e.y,r.y)||io(e.y,r.y+r.height))&&is(e.x,r.x,r.x+r.width);return n||i}(l,o)&&t.push({code:"arrow-endpoint-off-shape",elementId:i.id,message:`Arrow "${i.id}" ${a} endpoint does not land on "${o.id}".`}),o&&l&&e){let e=function(e,t){let r=e[t];return r&&"object"==typeof r?nq(r.fixedPoint):null}(i,a);e&&function(e,t,r){let n=nG(r);if(!n)return!1;let i=1e-4>Math.abs(e[0]-.5001)?.5:e[0],a=1e-4>Math.abs(e[1]-.5001)?.5:e[1];return io(n.x+i*n.width,t.x)&&io(n.y+a*n.height,t.y)}(e,l,o)||t.push({code:"invalid-elbow-binding",elementId:i.id,message:`Elbow arrow "${i.id}" has invalid ${a} fixedPoint metadata.`})}}}if("text"===i.type){let e=i.containerId;if("string"!=typeof e)continue;let n=r.get(e);if(!n){t.push({code:"missing-container",elementId:i.id,message:`Text "${i.id}" references missing container "${e}".`});continue}let a="number"==typeof i.width?i.width:0,s="number"==typeof i.height?i.height:0,o="number"==typeof n.width?n.width:0,l="number"==typeof n.height?n.height:0;ia(n)&&(a+24>o||s+18>l)&&t.push({code:"text-overflow",elementId:i.id,message:`Text "${i.id}" does not fit inside "${e}".`})}}return t.push(...function(e){let t=e.filter(e=>"arrow"===e.type).flatMap(it),r=e.filter(ia),n=[],i=new Set;for(let e of t)for(let t of r){if(function(e){let t=e.customData;return null!==t&&"object"==typeof t&&t.sketchiRendererRole===n$}(t)||t.id===e.startBindingElementId||t.id===e.endBindingElementId)continue;let r=nG(t);if(!r||("horizontal"===e.orientation?!(ir(e.staticCoordinate,r.y,r.y+r.height)&&ii(e.min,e.max,r.x,r.x+r.width)):!(ir(e.staticCoordinate,r.x,r.x+r.width)&&ii(e.min,e.max,r.y,r.y+r.height))))continue;let a=`${e.arrowId}:${e.segmentIndex}:${t.id}`;i.has(a)||(i.add(a),n.push({code:"arrow-segment-through-node",elementId:e.arrowId,message:`Arrow "${e.arrowId}" passes through shape "${t.id}".`}))}return n}(e.elements)),t.push(...function(e){let t=e.filter(e=>"arrow"===e.type).flatMap(it),r=[],n=new Set;for(let e=0;e<t.length;e+=1){let i=t[e];if(i)for(let a=e+1;a<t.length;a+=1){let e=t[a];if(!e||i.arrowId===e.arrowId||i.orientation!==e.orientation||Math.abs(i.staticCoordinate-e.staticCoordinate)>.001||0===i.segmentIndex&&0===e.segmentIndex&&null!==i.startBindingElementId&&i.startBindingElementId===e.startBindingElementId||i.isLastSegment&&e.isLastSegment&&null!==i.endBindingElementId&&i.endBindingElementId===e.endBindingElementId||Math.min(i.max,e.max)-Math.max(i.min,e.min)<=.001)continue;let s=[i.arrowId,i.segmentIndex,e.arrowId,e.segmentIndex].sort().join(":");n.has(s)||(n.add(s),r.push({code:"overlapping-arrow-segment",elementId:i.arrowId,message:`Arrow "${i.arrowId}" overlaps arrow "${e.arrowId}".`}))}}return r}(e.elements)),{ok:0===t.length,issues:t}}var id=r(664);r(3614);var ic=r(1594),iu=r(6297),ip=r(7258),ih=r(2275),im=r(2860),ig=r(1554),iy=r(4233);let ib=a.Or("effect/Metric/CurrentMetricAttributes",{defaultValue:()=>({})}),iv=a.Or("effect/Metric/MetricRegistry",{defaultValue:()=>new Map}),i_="~effect/Metric";class ix{[i_]=i_;#e;#t="";id;description;attributes;constructor(e,t,r){this.id=e,this.description=t,this.attributes=r}valueUnsafe(e){return this.hook(e).get(e)}modifyUnsafe(e,t){return this.hook(t).modify(e,t)}updateUnsafe(e,t){return this.hook(t).update(e,t)}hook(e){var t;let r,n=a.Jt(e,ib);n!==this.#e&&(this.#e=n,this.#t=(t=this,r=Object.entries(iC(this.attributes,n)).sort((e,t)=>e[0]<t[0]?-1:+(e[0]>t[0])),JSON.stringify([t.type,t.id,t.description,r])));let i=a.Jt(e,iv),s=i.get(this.#t);return iy.b0(s)&&(s={id:this.id,type:this.type,description:this.description,attributes:Object.keys(n).length>0?iC(this.attributes,n):this.attributes,hooks:this.createHooks()},i.set(this.#t,s)),s.hooks}pipe(){return(0,ig.tT)(this,arguments)}}let iw=BigInt(0);class ik extends ix{type="Counter";#r;#n;constructor(e,t){super(e,t?.description,iT(t?.attributes)),this.#r=t?.bigint??!1,this.#n=t?.incremental??!1}createHooks(){let e=this.#r?iw:0,t=this.#n?this.#r?e=>e>=iw:e=>e>=0:e=>!0;return iO(()=>({count:e,incremental:this.#n}),r=>{t(r)&&(e+=r)})}}class iS extends ix{type;metric;valueUnsafe;updateUnsafe;modifyUnsafe;constructor(e,t,r,n){super(e.id,e.description,e.attributes),this.metric=e,this.valueUnsafe=t,this.updateUnsafe=r,this.modifyUnsafe=n,this.type=e.type}createHooks(){return this.metric.createHooks()}}let iI=(e,t)=>new ik(e,t),i$=(0,ic.XY)(2,(e,t)=>iu.sxi(r=>iu.OH5(()=>e.updateUnsafe(t,r)))),iE=(0,ic.XY)(2,(e,t)=>{var r;let n,i,s=(r=t,i={},e=>{let t=a.Jt(e,ib);return t!==n&&(n=t,i=iC(t,r)),a.WQ(e,ib,i)});return new iS(e,t=>e.valueUnsafe(s(t)),(t,r)=>e.updateUnsafe(t,s(r)),(t,r)=>e.modifyUnsafe(t,s(r)))});function iO(e,t,r){return{get:e,update:t,modify:r??t}}function iC(e,t){return{...iT(e),...iT(t)}}function iT(e){return iy.EA(e)&&Array.isArray(e)?e.reduce((e,[t,r])=>(ih.x(e,t,r),e),{}):e}ip.F,ip.F,ic.MN;var iM=r(1587),iP=(r(6526),r(719),r(2707));[...new Set(["artifact_count","artifact_format","artifact_kind","attempt","cache_mode","duration_ms","error_category","error_tag","failure_category","format_count","method","model","operation","outcome","provider","request_kind","retry_kind","sink","status","status_code","surface","timeout_kind","timeout_ms"])];let iA={metric:()=>void 0},iN=a.Or("@sketchi/observability/TelemetryExporter",{defaultValue:()=>iA}),iR=a.Or("@sketchi/observability/TelemetryCorrelation",{defaultValue:()=>({})});function ij(e){let t=e?.trim();if(t&&!(t.length>128)&&/^[A-Za-z0-9][A-Za-z0-9._:-]*$/.test(t))return t}function iD(e){let t=ij(e.artifactId),r=ij(e.attemptId),n=ij(e.projectId),i=ij(e.requestId),a=ij(e.runId),s=ij(e.scenarioId),o=ij(e.traceId);return{...t?{artifactId:t}:{},...r?{attemptId:r}:{},...n?{projectId:n}:{},...i?{requestId:i}:{},...a?{runId:a}:{},...s?{scenarioId:s}:{},...o?{traceId:o}:{}}}function iU(e,t){return s.JkU(function*(){let r=iD({...yield*iR,...iD(t)}),n={...r.artifactId?{"sketchi.artifact_id":r.artifactId}:{},...r.attemptId?{"sketchi.attempt_id":r.attemptId}:{},...r.projectId?{"sketchi.project_id":r.projectId}:{},...r.requestId?{"sketchi.request_id":r.requestId}:{},...r.runId?{"sketchi.run_id":r.runId}:{},...r.scenarioId?{"sketchi.scenario_id":r.scenarioId}:{},...r.traceId?{"sketchi.trace_id":r.traceId}:{}};return yield*e.pipe(s.PfK(iR,r),s.Muk(n),s.swY(n))})}a.Or("@sketchi/observability/TelemetryResource",{defaultValue:()=>({serviceName:"sketchi"})});let iF=s.fn(function*(e,t,r={}){let n=function(e){let t={artifact_kind:e.artifactKind,failure_category:e.failureCategory,operation:e.operation,outcome:e.outcome,provider:e.provider,retry_kind:e.retryKind,sink:e.sink,surface:e.surface,timeout_kind:e.timeoutKind},r={};for(let[e,n]of Object.entries(t)){let t=ij(n);t&&(r[e]=t)}return r}(r);yield*i$(iE(e,n),t);let i=yield*iN,a=iM.getOrUndefined((yield*s._32.pipe(s.uKv)));yield*s.OH5(()=>i.metric({attributes:n,metric:e.id,metricType:e.type,...a?{spanId:a.spanId,traceId:a.traceId}:{},value:t}))});iP.W1;let iB=/^(node|step|item|box|thing|process|task)\s*\d*$/i,iL=/^(diagram|untitled|flowchart|chart|sketch)$/i;function iz(e){return e.map(e=>({kind:"node",id:e.id}))}function iW(e){if(void 0===e)return;let t=eh(e);return t.length>0?t:void 0}let iJ=["excalidraw","scene"],iY=["scene"];m.card,m.accent,m.ink;let iX=iI("sketchi_codemode_requests",{description:"Code Mode boundary requests by terminal outcome",incremental:!0}),iq=iI("sketchi_codemode_failures",{description:"Code Mode boundary failures by typed status",incremental:!0}),iG=iI("sketchi_codemode_artifacts",{description:"Code Mode artifacts accepted at workflow boundaries",incremental:!0}),iV=new class e extends ix{type="Histogram";#i;constructor(e,t){super(e,t?.description,iT(t?.attributes)),this.#i=t.boundaries}createHooks(){let e=this.#i,t=e.length,r=new Uint32Array(t+1),n=new Float64Array(t),i=0,a=0,s=Number.MAX_VALUE,o=-Number.MAX_VALUE;return id.Tj(id.di(e,im.wN),(e,t)=>{n[t]=e}),iO(()=>({buckets:(()=>{let e=id.CN(t),i=0;for(let a=0;a<t;a++){let t=n[a];i+=r[a],e[a]=[t,i]}return e})(),count:i,min:s,max:o,sum:a}),e=>{let l=0,d=t;for(;l!==d;){let t=Math.floor(l+(d-l)/2);e<=n[t]?d=t:l=t,d===l+1&&(e<=n[l]?d=l:l=d)}r[l]=r[l]+1,i+=1,a+=e,e<s&&(s=e),e>o&&(o=e)})}}("sketchi_codemode_duration_ms",{description:"Code Mode boundary duration in milliseconds",boundaries:(n=[1,5,10,25,50,100,250,500,1e3,2500,5e3,1e4],id.BC(id.pb(new Set(n),e=>e>0),1/0))});class iH extends a.kl()("@sketchi/diagram-agent/CodeModeRuntimeEnvironment"){}function iK(e={}){return l.Py(iH,{createId:e.createId??i9,...e.renderer?{renderer:e.renderer}:{},...e.artifactUrl?{artifactUrl:e.artifactUrl}:{}})}function iQ(e){return null===e||"object"!=typeof e||Array.isArray(e)?void 0:Object.fromEntries(Object.entries(e))}function iZ(e,t,r){let n,i,a,l;return iU(s.JkU(function*(){let t=yield*o.Ru,n=yield*r,i=yield*o.Ru,a=n.ok?"success":"failure",s=n.ok?void 0:n.status??"unknown_failure";yield*iF(iX,1,{...s?{failureCategory:s}:{},operation:e,outcome:a,surface:"code_mode"}),yield*iF(iV,i-t,{...s?{failureCategory:s}:{},operation:e,outcome:a,surface:"code_mode"}),s&&(yield*iF(iq,1,{failureCategory:s,operation:e,surface:"code_mode"}));let l="buildFlowchart"===e?"flowchart":"buildMindmap"===e?"mindmap":"buildSequenceDiagram"===e?"sequence":"createCanvas"===e?"canvas":"applyDiagramPatch"===e?"patch":void 0;return n.ok&&l&&(yield*iF(iG,1,{artifactKind:l,operation:e,surface:"code_mode"})),n}),(n=iQ(t),i=iQ(n?.source),a="string"==typeof n?.artifactId?n.artifactId:"string"==typeof i?.artifactId?i.artifactId:void 0,l="string"==typeof n?.requestId?n.requestId:void 0,{...a?{artifactId:a}:{},...l?{requestId:l}:{}}))}l.Py(iH,{createId:i9});class i0 extends i.rNF()("CodeModeArtifactExportError",{cause:i.kld(),message:i.QfV,optionPath:i.v8c}){}class i1 extends i.rNF()("BuildFlowchartFailure",{message:i.QfV,status:i.xCb(["invalid_input","invalid_flowchart","quality_failed","render_failed","export_failed","storage_failed"])}){context;constructor(e){super({message:e.context.issues[0]?.message??e.status,status:e.status}),this.context=e.context}}class i2 extends i.rNF()("BuildMindmapFailure",{message:i.QfV,status:i.xCb(["invalid_input","invalid_mindmap","quality_failed","render_failed","export_failed","storage_failed"])}){context;constructor(e){super({message:e.context.issues[0]?.message??e.status,status:e.status}),this.context=e.context}}class i5 extends i.rNF()("BuildSequenceDiagramFailure",{message:i.QfV,status:i.xCb(["invalid_input","invalid_sequence","quality_failed","render_failed","export_failed","storage_failed"])}){context;constructor(e){super({message:e.context.issues[0]?.message??e.status,status:e.status}),this.context=e.context}}class i3 extends i.rNF()("CreateCanvasFailure",{message:i.QfV,status:i.xCb(["invalid_input","invalid_canvas","limit_exceeded","render_failed","export_failed","storage_failed"])}){context;constructor(e){super({message:e.context.issues[0]?.message??e.status,status:e.status}),this.context=e.context}}class i6 extends i.rNF()("GetArtifactFailure",{message:i.QfV,status:i.xCb(["invalid_input","not_found","format_unavailable","expired","storage_failed"])}){issues;constructor(e){super({message:e.issues[0]?.message??e.status,status:e.status}),this.issues=e.issues}}class i8 extends i.rNF()("ApplyDiagramPatchFailure",{message:i.QfV,status:i.xCb(["invalid_input","source_unavailable","target_not_found","unsupported_operation","connectivity_changed","render_failed","export_failed","storage_failed"])}){context;constructor(e){super({message:e.context.issues[0]?.message??e.status,status:e.status}),this.context=e.context}}function i9(e){return`${e}_${globalThis.crypto.randomUUID()}`}function i4(e){return{code:e.code,severity:e.severity??"error",stage:e.stage,...e.ref?{ref:e.ref}:{},message:e.message,hint:e.hint}}function i7(e){return 0===e.length?"input":e.map(e=>"number"==typeof e?`[${e}]`:String(e)).join(".")}function ae(e){let t=i7(e.path);return at(t)?"unsupported_patch_operation":e.message.startsWith("Invalid input: expected")?"invalid_type":e.message.startsWith("Invalid option:")?"invalid_enum":t.toLowerCase().includes("color")?"invalid_color":"input"===t?"invalid_type":"missing_field"}function at(e){return/^operations\.\[\d+\]\.op$/.test(e)}function ar(e){let t=e.issues.slice(0,20).map(e=>{let t=i7(e.path);return i4({code:ae(e),stage:"input",ref:{kind:"request",path:t},message:e.message,hint:at(t)?`Use one of: ${e5.join(", ")}. For label edits, use replaceText with selector plus text.`:"source"===t?"Pass source: { artifactId } from an accepted build or patch, or source: { scene } for inline Sketchi scene patching.":`Fix ${t} so it matches the Code Mode API contract.`})});return e.issues.length>20&&t.push(i4({code:"invalid_type",stage:"input",ref:{kind:"request",path:"input"},message:`${e.issues.length-20} additional input issues were omitted.`,hint:"Fix the summarized request shape before retrying."})),t}function an(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)}function ai(e){if(void 0===e)return;let t=eh(e);return t.length>0?t:void 0}function aa(e){return e.checks.map(e=>{var t;return i4({code:"generic_label"===(t=e.code)||"label_too_long"===t||"disconnected_graph"===t?t:"quality_below_threshold",severity:e.severity,stage:"quality",message:e.message,hint:"error"===e.severity?"Repair the structural issue and call buildFlowchart again.":"Improve the labels or scope before styling the artifact."})})}function as(e){return e?.artifactFormats??iJ}function ao(e){return e?.inlineArtifacts??iY}let al=s.fn("codeMode.artifacts.exportFormats")(function*(e){let t=[];for(let a of e.formats){var r,n,i;let o=yield*(r=e,"scene"===(n=a)?s.PyW(r.scene):"excalidraw"===n?s.PyW(function(e,t={}){return{type:"excalidraw",version:2,source:t.source??"https://sketchi.app",elements:e.elements,appState:e.appState,files:{}}}(r.excalidraw)):r.renderer?r.renderer.renderPng({scene:r.scene,excalidraw:r.excalidraw}).pipe(s.xm_(e=>i0.make({cause:e,message:e instanceof Error?e.message:"Artifact export failed.",optionPath:!1}))):s.fJG(i0.make({cause:Error("PNG artifact rendering is not configured for this runtime."),message:"PNG artifact rendering is not configured for this runtime.",optionPath:!0})));t.push({format:a,mimeType:r3[a],data:o,sizeBytes:(i=o)instanceof ArrayBuffer||i instanceof Uint8Array?i.byteLength:r4(i)})}return t});function ad(e){return[i4({code:"render_failed",stage:"export",...e.optionPath?{ref:{kind:"artifact",path:"options.artifactFormats"}}:{},message:e.message,hint:e.optionPath?"Use the hosted Studio Code Mode runtime with its Cloudflare Browser Run binding, or omit png from artifactFormats.":"Retry the request; if it keeps failing, inspect the configured renderer."})]}function ac(e){return e.map(e=>i4({code:"overlapping-arrow-segment"===e.code?"arrow_overlap":"text-overflow"===e.code?"text_overflow":e.code.includes("binding")||e.code.includes("bound")||e.code.includes("endpoint")?"arrow_binding_invalid":"export_invalid_scene",stage:"export",ref:e.elementId?{kind:"artifact",id:e.elementId}:{kind:"artifact"},message:e.message,hint:"Inspect the rendered scene and retry with a simpler layout or patch."}))}function au(e){return e.slice(0,20).map(e=>i4({code:function(e){switch(e.code){case"duplicate_element_id":return"duplicate_element_id";case"duplicate_layer_id":return"duplicate_layer_id";case"empty_canvas":case"invalid_geometry":return"invalid_canvas_geometry";case"invalid_binding":return"invalid_canvas_binding";case"invalid_composition":return"invalid_canvas_composition";case"invalid_polygon":return"invalid_polygon";case"limit_exceeded":return"canvas_limit_exceeded";case"missing_z_order_element":case"unknown_z_order_element":return"invalid_z_order";case"unknown_layout_target":return"unknown_layout_target"}}(e),stage:"canvas",ref:e.elementId?{kind:"element",id:e.elementId,path:e.path}:{kind:"diagram",path:e.path},message:e.message,hint:"Repair the referenced CanvasSpec field and call createCanvas again."}))}function af(e){return ac(e.filter(e=>"overlapping-arrow-segment"!==e.code&&"arrow-segment-through-node"!==e.code))}function ap(e){let t=[];for(let r of e.elements){if("arrow"===r.type){let e=r.points[0],n=r.points[1],i=r.points.slice(2);if(!e||!n)return null;let a=[e,n,...i];t.push({...r,type:"arrow",id:r.id,edgeId:r.edgeId,sourceNodeId:r.sourceNodeId,targetNodeId:r.targetNodeId,...r.strokeColor?{strokeColor:r.strokeColor}:{},...r.strokeStyle?{strokeStyle:r.strokeStyle}:{},...r.textColor?{textColor:r.textColor}:{},points:a,...r.label?{label:r.label}:{}});continue}if("node"===r.type){let n=r.points;if("polygon"===r.shape&&(!n||!n[0]||!n[1]||!n[2]))return null;t.push({type:"node",id:r.id,nodeId:r.nodeId,...r.kind?{kind:r.kind}:{},shape:r.shape,...r.fillColor?{fillColor:r.fillColor}:{},...r.strokeColor?{strokeColor:r.strokeColor}:{},x:r.x,y:r.y,width:r.width,height:r.height,label:r.label,...r.frameId?{frameId:r.frameId}:{},...r.groupIds?{groupIds:[...r.groupIds]}:{},...r.layerId?{layerId:r.layerId}:{},...void 0!==r.locked?{locked:r.locked}:{},...void 0!==r.opacity?{opacity:r.opacity}:{},...void 0!==r.zIndex?{zIndex:r.zIndex}:{},...r.fillStyle?{fillStyle:r.fillStyle}:{},...void 0!==r.roughness?{roughness:r.roughness}:{},...r.strokeStyle?{strokeStyle:r.strokeStyle}:{},...void 0!==r.strokeWidth?{strokeWidth:r.strokeWidth}:{},..."sequence-lifeline"===r.rendererRole&&function(e,t){let r=":lifeline";if(!t.nodeId.endsWith(r)||t.id!==`node:${t.nodeId}`||"rectangle"!==t.shape||2!==t.width||t.height<120)return!1;let n=t.nodeId.slice(0,-r.length);if(0===n.length)return!1;let i=e.elements.find(e=>"node"===e.type&&e.id===`node:${n}`&&e.nodeId===n);return!!i&&.01>=Math.abs(t.x+t.width/2-(i.x+i.width/2))&&t.y>=i.y+i.height-.01}(e,r)?{rendererRole:r.rendererRole}:{},...r.textColor?{textColor:r.textColor}:{},..."polygon"===r.shape&&n?.[0]&&n[1]&&n[2]?{points:[n[0],n[1],n[2],...n.slice(3)]}:{}});continue}if("line"===r.type){let e=r.points[0],n=r.points[1];if(!e||!n)return null;t.push({...r,points:[e,n,...r.points.slice(2)]});continue}t.push(structuredClone(r))}return{kind:e.kind,version:e.version,diagramId:e.diagramId,title:e.title,width:e.width,height:e.height,accentColor:e.accentColor,backgroundColor:e.backgroundColor,elements:t,layers:structuredClone(e.layers),layouts:structuredClone(e.layouts),zOrder:[...e.zOrder]}}function ah(e){return structuredClone(e)}function am(e){return e.elements.flatMap(e=>"arrow"===e.type?[`arrow:${e.id}:${e.sourceNodeId}->${e.targetNodeId}`]:"line"===e.type?[`line:${e.id}:${e.startBinding?.elementId??""}->${e.endBinding?.elementId??""}`]:[]).sort()}function ag(e){return e.elements.filter(e=>"node"===e.type)}function ay(e){return e.elements.filter(e=>"text"===e.type)}function ab(e){return e.elements.filter(e=>"arrow"===e.type)}function av(e,t){if(!e||0===e.length||!t)return!1;let r=t.trim().toLowerCase();return e.some(e=>e.trim().toLowerCase()===r)}function a_(e,t){let r=t?.scope??"all",n=!!(t&&((t.ids?.length??0)>0||(t.nodeIds?.length??0)>0||(t.edgeIds?.length??0)>0||(t.kinds?.length??0)>0||(t.labels?.length??0)>0)),i=new Set(t?.ids??[]),a=new Set(t?.nodeIds??[]),s=new Set(t?.edgeIds??[]),o=new Set(t?.kinds??[]),l=ag(e).filter(e=>"edges"!==r&&(!t||!n||i.has(e.id)||a.has(e.nodeId)||!!e.kind&&[...o].some(t=>t===e.kind)||av(t.labels,e.label))),d=ab(e).filter(e=>"nodes"!==r&&(!t||!n||i.has(e.id)||s.has(e.edgeId)||av(t.labels,e.label))),c=new Set(l.map(e=>e.id)),u=new Set(d.map(e=>e.id));return{arrows:d,nodes:l,texts:ay(e).filter(e=>t&&n?i.has(e.id)||!!e.containerId&&c.has(e.containerId)||!!e.containerId&&u.has(e.containerId)||av(t.labels,e.text):"nodes"===r?!!e.containerId&&c.has(e.containerId):"edges"!==r||!!e.containerId&&u.has(e.containerId))}}function ax(e){return i4({code:"unknown_patch_target",stage:"flowchart",ref:{kind:"request",path:"operations.selector"},message:`Patch operation "${e.op}" did not match any scene element.`,hint:"Use nodeIds, edgeIds, ids, kinds, labels, or scope values that exist in the accepted artifact."})}function aw(e,t){return ay(e).find(e=>e.containerId===t)}function ak(e,t){let r=new Set(t);for(let t of ab(e))(r.has(t.sourceNodeId)||r.has(t.targetNodeId))&&a$(e,t)}function aS(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}function aI(e,t,r){let n=aS(e),i=aS(t),a=i.x-n.x,s=i.y-n.y;return Math.abs(a)>Math.abs(s)?a>=0&&r||a<0&&!r?{x:e.x+e.width,y:n.y}:{x:e.x,y:n.y}:s>=0&&r||s<0&&!r?{x:n.x,y:e.y+e.height}:{x:n.x,y:e.y}}function a$(e,t){let r,n,i=new Map(ag(e).map(e=>[e.nodeId,e])),a=i.get(t.sourceNodeId),s=i.get(t.targetNodeId);if(!a||!s)return[i4({code:"patch_output_invalid",stage:"render",ref:{kind:"edge",id:t.edgeId},message:`Arrow "${t.id}" references a node that is not in the scene.`,hint:"Rebuild the diagram with buildFlowchart or buildMindmap before applying visual patches."})];let o=aI(a,s,!0),l=aI(s,a,!1);if(Math.abs(l.y-o.y)>=Math.abs(l.x-o.x)){let e=(o.y+l.y)/2;t.points=[o,{x:o.x,y:e},{x:l.x,y:e},l]}else{let e=(o.x+l.x)/2;t.points=[o,{x:e,y:o.y},{x:e,y:l.y},l]}return r=aw(e,t.id),n=function(e){let t=e[0],r=e[e.length-1];if(t&&r)return{x:(t.x+r.x)/2,y:(t.y+r.y)/2-10}}(t.points),r&&n&&(r.x=n.x,r.y=n.y),[]}function aE(e){let t=[e.width],r=[e.height];for(let n of ag(e))t.push(n.x+n.width),r.push(n.y+n.height);for(let n of ay(e))t.push(n.x+(n.maxWidth??0)),r.push(n.y+n.fontSize);for(let n of ab(e))for(let e of n.points)t.push(e.x),r.push(e.y);for(let n of e.elements){if("line"===n.type)for(let e of n.points)t.push(e.x),r.push(e.y);"frame"===n.type&&(t.push(n.x+n.width),r.push(n.y+n.height))}e.width=Math.max(...t)+48,e.height=Math.max(...r)+48}function aO(e,t,r){if(!t||!r){if(t){let r=e.indexOf(t);return r>=0?r:void 0}if(r){let t=e.indexOf(r);return t>=0?t+1:void 0}return e.length}}function aC(e,t){return[i4({code:"patch_output_invalid",stage:"canvas",ref:{kind:"request",path:"operations"},message:t,hint:`Repair the ${e.op} operation and preserve unique, stable element ids.`})]}let aT=s.fn("codeMode.patch.resolveSource")(function*(e){if("scene"in e.source)return{scene:ah(e.source.scene)};let t=yield*r5,r=yield*t.readManifest(e.source.artifactId).pipe(s.xm_(e=>new i8({status:"storage_failed",context:{issues:[nt(e.message,"storage_read_failed")]}})));if(!r||r.artifactId!==e.source.artifactId||!r.formats.some(e=>"scene"===e.format))return yield*new i8({status:"source_unavailable",context:{issues:[i4({code:"patch_source_unavailable",stage:"storage",ref:{kind:"artifact",id:e.source.artifactId},message:`Artifact "${e.source.artifactId}" does not have a valid source manifest.`,hint:"Rebuild with the appropriate build operation and patch the accepted artifact id."})]}});let n=yield*t.read(e.source.artifactId,"scene").pipe(s.xm_(e=>new i8({status:"storage_failed",context:{issues:[nt(e.message,"storage_read_failed")]}})));if(!n)return yield*new i8({status:"source_unavailable",context:{issues:[i4({code:"patch_source_unavailable",stage:"storage",ref:{kind:"artifact",id:e.source.artifactId},message:`Scene artifact "${e.source.artifactId}" is not available.`,hint:"Call buildFlowchart or buildMindmap first, then patch the accepted artifact id."})]}});let i=re.safeParse(n.data);return i.success?{scene:ah(i.data),sourceArtifactId:e.source.artifactId}:yield*new i8({status:"source_unavailable",context:{issues:[i4({code:"patch_source_unavailable",stage:"storage",ref:{kind:"artifact",id:e.source.artifactId},message:`Scene artifact "${e.source.artifactId}" could not be decoded.`,hint:"Rebuild with the appropriate build operation and patch the new artifact."})]}})});function aM(e){return e?{requestId:e}:{}}function aP(e,t){if(!t)return e;let r=e.formats.map(r=>({...r,url:t({artifactId:e.artifactId,format:r.format})})),n=e.preview?r.find(t=>t.format===e.preview?.format):void 0;return{...e,formats:r,...n?{preview:n}:{}}}function aA(e){return{diagramId:e.diagramId,formats:[{format:"scene",mimeType:r3.scene,inline:e,sizeBytes:r4(e)}]}}function aN(e){return{ok:!1,status:e.status,...e.context.buildId?{buildId:e.context.buildId}:{},...e.context.requestId?{requestId:e.context.requestId}:{},...e.context.normalizedSpec?{normalizedSpec:e.context.normalizedSpec}:{},...e.context.quality?{quality:e.context.quality}:{},...e.context.partial?{partial:e.context.partial}:{},issues:e.context.issues}}function aR(e){return{ok:!1,status:e.status,...e.context.buildId?{buildId:e.context.buildId}:{},...e.context.requestId?{requestId:e.context.requestId}:{},...e.context.normalizedSpec?{normalizedSpec:e.context.normalizedSpec}:{},...e.context.quality?{quality:e.context.quality}:{},...e.context.partial?{partial:e.context.partial}:{},issues:e.context.issues}}function aj(e){return{ok:!1,status:e.status,...e.context.buildId?{buildId:e.context.buildId}:{},...e.context.requestId?{requestId:e.context.requestId}:{},...e.context.normalizedSpec?{normalizedSpec:e.context.normalizedSpec}:{},...e.context.quality?{quality:e.context.quality}:{},...e.context.partial?{partial:e.context.partial}:{},issues:e.context.issues}}function aD(e){return{ok:!1,status:e.status,...e.context.buildId?{buildId:e.context.buildId}:{},...e.context.requestId?{requestId:e.context.requestId}:{},...e.context.normalizedSpec?{normalizedSpec:e.context.normalizedSpec}:{},...e.context.partial?{partial:e.context.partial}:{},issues:e.context.issues}}function aU(e){return{ok:!1,status:e.status,issues:e.issues}}function aF(e){return{ok:!1,status:e.status,...e.context.patchId?{patchId:e.context.patchId}:{},...e.context.requestId?{requestId:e.context.requestId}:{},...e.context.sourceArtifactId?{sourceArtifactId:e.context.sourceArtifactId}:{},...e.context.partial?{partial:e.context.partial}:{},issues:e.context.issues}}function aB(e,t){return nt(e.message,t)}let aL=s.fn("codeMode.buildMindmap.workflow")(function*(e){let t=yield*s.OH5(()=>(function(e){let t=iQ(iQ(iQ(e)?.spec)?.root);if(!t)return[];let r=[{depth:0,topic:t}],n=1;for(;r.length>0;){let e=r.pop();if(!e)continue;if(e.depth>8)return[i4({code:"mindmap_too_deep",stage:"mindmap",ref:{kind:"request",path:"spec.root.children"},message:"Mindmap depth exceeds the supported maximum of 8.",hint:"Combine overly deep topics into a shallower hierarchy."})];let t=e.topic.children;if(Array.isArray(t)){if((n+=t.length)>100)return[i4({code:"mindmap_too_large",stage:"mindmap",ref:{kind:"request",path:"spec.root"},message:"Mindmap exceeds the supported maximum of 100 topic slots.",hint:"Split this hierarchy into smaller focused mindmaps."})];for(let n=t.length-1;n>=0;n-=1){let i=iQ(t[n]);i&&r.push({depth:e.depth+1,topic:i})}}}return[]})(e)).pipe(s.fRP("codeMode.buildMindmap.preflight"));if(t.length>0)return yield*new i2({status:"invalid_mindmap",context:{issues:t}});let r=yield*s.OH5(()=>tB.safeParse(e)).pipe(s.fRP("codeMode.buildMindmap.parse"));if(!r.success)return yield*new i2({status:"invalid_input",context:{issues:ar(r.error)}});let n=yield*iH,i=yield*r5,a=r.data,o=yield*s.OH5(()=>n.createId("build")),l=yield*s.OH5(()=>{var e;let t,r;return e=a.spec,t=(e,r)=>({id:`topic-${r.join("-")}`,label:eh(e.label),children:(e.children??[]).map((e,n)=>t(e,[...r,n]))}),r=eh(e.title),{id:ai(e.id)??(an(r)||"sketchi-mindmap"),title:r,root:t(e.root,[0]),layout:{direction:e.layout.direction},style:{...g}}}).pipe(s.fRP("codeMode.buildMindmap.normalize")),d={buildId:o,...aM(a.requestId),normalizedSpec:l},c=yield*s.OH5(()=>{let e,t,r,n,i;return e=0,t=0,(r=(n,i)=>{e+=1,t=Math.max(t,i),n.children.forEach(e=>r(e,i+1))})(l.root,0),i=[],(n={count:e,depth:t}).count<2&&i.push(i4({code:"disconnected_graph",stage:"mindmap",ref:{kind:"diagram",id:l.id},message:"Mindmap root must contain at least one child topic.",hint:"Add one or more nested topics under spec.root.children."})),n.depth>8&&i.push(i4({code:"mindmap_too_deep",stage:"mindmap",ref:{kind:"diagram",id:l.id},message:`Mindmap depth ${n.depth} exceeds the supported maximum of 8.`,hint:"Combine overly deep topics into a shallower hierarchy."})),n.count>100&&i.push(i4({code:"mindmap_too_large",stage:"mindmap",ref:{kind:"diagram",id:l.id},message:`Mindmap has ${n.count} topics; the supported maximum is 100.`,hint:"Split this hierarchy into smaller focused mindmaps."})),i}).pipe(s.fRP("codeMode.buildMindmap.validate"));if(c.length>0)return yield*new i2({status:"invalid_mindmap",context:{...d,issues:c}});let u=yield*s.SvU({try:()=>{let e,t,r;return e=[],t=[],(r=(n,i,a,s)=>{e.push({id:n.id,label:n.label,kind:0===i?"root":"topic",metadata:{depth:i,siblingIndex:a}}),s&&t.push({id:`branch-${n.id.slice(6)}`,source:s,target:n.id,metadata:{depth:i,siblingIndex:a}}),n.children.forEach((e,t)=>r(e,i+1,t,n.id))})(l.root,0,0),ee({id:l.id,title:l.title,type:"mindmap",nodes:e,edges:t,layout:{direction:l.layout.direction,edgeRouting:"curved"},style:{...g}})},catch:e=>new i2({status:"invalid_mindmap",context:{...d,issues:[i4({code:"disconnected_graph",stage:"mindmap",ref:{kind:"diagram",id:l.id},message:e instanceof Error?e.message:"Mindmap failed core validation.",hint:"Repair the nested topic hierarchy and call buildMindmap again."})]}})}).pipe(s.fRP("codeMode.buildMindmap.canonicalize")),f=yield*s.OH5(()=>{var e;let t,r;return e=a.options?.minQualityScore??8,{accepted:(r=Math.max(0,10-2*(t=u.nodes.filter(e=>/^(topic|branch|item|mindmap)$/i.test(e.label.trim()))).length))>=e,score:r,threshold:e,summary:{nodeCount:u.nodes.length,edgeCount:u.edges.length},checks:t.map(e=>({code:"generic_label",passed:!1,severity:"warning",message:`Topic "${e.label}" is too generic.`,refs:[{kind:"node",id:e.id}]}))}}).pipe(s.fRP("codeMode.buildMindmap.quality")),p={...d,quality:f};if(!f.accepted)return yield*new i2({status:"quality_failed",context:{...p,issues:aa(f)}});let h=yield*s.SvU({try:()=>nI(u),catch:e=>new i2({status:"render_failed",context:{...p,issues:[i4({code:"render_failed",stage:"render",ref:{kind:"diagram",id:l.id},message:e instanceof Error?e.message:"Unable to render mindmap scene.",hint:"Simplify the hierarchy or retry with a smaller mindmap."})]}})}).pipe(s.fRP("codeMode.buildMindmap.render")),{excalidraw:m,exportValidation:y}=yield*s.OH5(()=>{let e=n4(h);return{excalidraw:e,exportValidation:il(e)}}).pipe(s.fRP("codeMode.buildMindmap.exportValidate")),b={...p,partial:aA(h)};if(!y.ok)return yield*new i2({status:"export_failed",context:{...b,issues:ac(y.issues)}});let v=yield*al({formats:as(a.options),scene:h,excalidraw:m,renderer:n.renderer}).pipe(s.xm_(e=>new i2({status:"export_failed",context:{...b,issues:ad(e)}}))),_=yield*s.OH5(()=>n.createId("artifact")),x=yield*iU(i.write({artifactId:_,diagramId:h.diagramId,formats:v,inlineFormats:ao(a.options)}),{artifactId:_,...a.requestId?{requestId:a.requestId}:{}}).pipe(s.xm_(e=>new i2({status:"storage_failed",context:{...p,partial:{diagramId:h.diagramId},issues:[aB(e,"storage_write_failed")]}})));return{ok:!0,status:"accepted",buildId:o,...aM(a.requestId),normalizedSpec:l,quality:f,artifact:aP(x,n.artifactUrl),issues:[]}}),az=s.fn("codeMode.buildSequenceDiagram.workflow")(function*(e){yield*s.rIH.pipe(s.fRP("codeMode.buildSequenceDiagram.preflight"));let t=yield*s.OH5(()=>tO.safeParse(e)).pipe(s.fRP("codeMode.buildSequenceDiagram.parse"));if(!t.success)return yield*new i5({status:"invalid_input",context:{issues:ar(t.error)}});let r=yield*iH,n=yield*r5,i=t.data,a=yield*s.OH5(()=>r.createId("build")),o=yield*s.OH5(()=>{var e;let t;return t=eh((e=i.spec).title),{id:ai(e.id)??(an(t)||"sketchi-sequence"),title:t,participants:e.participants.map(e=>({id:eh(e.id),label:eh(e.label),...e.kind?{kind:eh(e.kind)}:{}})),messages:e.messages.map((e,t)=>({id:ai(e.id)??`message-${t+1}-${an(e.source)}-${an(e.target)}`,source:eh(e.source),target:eh(e.target),label:eh(e.label),...e.type?{type:e.type}:{},...e.style?{style:e.style}:{}})),style:{...g}}}).pipe(s.fRP("codeMode.buildSequenceDiagram.normalize")),l={buildId:a,...aM(i.requestId),normalizedSpec:o},d=yield*s.OH5(()=>{let e,t,r,n;return e=[],t=new Set,o.participants.forEach((r,n)=>{t.has(r.id)&&e.push(i4({code:"duplicate_node_id",stage:"input",ref:{kind:"request",path:`spec.participants.[${n}].id`},message:`Participant id "${r.id}" is duplicated.`,hint:"Give every participant a unique stable id and update message references."})),t.add(r.id)}),r=new Map(o.participants.map((e,t)=>[e.id,t])),o.participants.forEach(t=>{let n=nE(t.id),i=r.get(n);void 0!==i&&e.push(i4({code:"duplicate_node_id",stage:"input",ref:{kind:"request",path:`spec.participants.[${i}].id`},message:`Participant id "${n}" collides with the generated lifeline for "${t.id}".`,hint:"Rename the participant so its id does not equal another participant id followed by :lifeline."}))}),n=new Set,o.messages.forEach((r,i)=>{n.has(r.id)&&e.push(i4({code:"duplicate_edge_id",stage:"input",ref:{kind:"request",path:`spec.messages.[${i}].id`},message:`Message id "${r.id}" is duplicated.`,hint:"Give every message a unique id or omit message ids to generate them deterministically."})),n.add(r.id),t.has(r.source)||e.push(i4({code:"missing_edge_source",stage:"input",ref:{kind:"request",path:`spec.messages.[${i}].source`},message:`Message source "${r.source}" is not a participant.`,hint:"Use the id of a participant declared in spec.participants."})),t.has(r.target)||e.push(i4({code:"missing_edge_target",stage:"input",ref:{kind:"request",path:`spec.messages.[${i}].target`},message:`Message target "${r.target}" is not a participant.`,hint:"Use the id of a participant declared in spec.participants."})),r.source===r.target&&e.push(i4({code:"self_loop",stage:"input",ref:{kind:"request",path:`spec.messages.[${i}]`},message:`Message "${r.id}" is self-referential.`,hint:"Choose a different target participant; self messages are not supported."}))}),e}).pipe(s.fRP("codeMode.buildSequenceDiagram.validate"));if(d.length>0)return yield*new i5({status:"invalid_sequence",context:{...l,issues:d}});let c=yield*s.OH5(()=>{var e;return{accepted:10>=(e=i.options?.minQualityScore??8),score:10,threshold:e,summary:{nodeCount:o.participants.length,edgeCount:o.messages.length},checks:[]}}).pipe(s.fRP("codeMode.buildSequenceDiagram.quality")),u={...l,quality:c};if(!c.accepted)return yield*new i5({status:"quality_failed",context:{...u,issues:aa(c)}});let f=yield*s.SvU({try:()=>(function(e){let t=new Set(e.participants.map(e=>e.id));for(let r of e.participants){let e=nE(r.id);if(t.has(e))throw Error(`Sequence participant "${e}" collides with the generated lifeline for "${r.id}".`)}let r=Math.max(184,184+88*Math.max(0,e.messages.length-1))-120+56,n=new Map,i=[],a=[],s=[];e.participants.forEach((t,o)=>{let l=48+320*o,d=l+90;n.set(t.id,d),i.push({type:"node",id:`node:${t.id}`,nodeId:t.id,...t.kind?{kind:t.kind}:{},shape:"rectangle",x:l,y:48,width:180,height:72,label:t.label}),a.push({type:"text",id:`label:${t.id}`,containerId:`node:${t.id}`,x:d,y:84,text:t.label,fontSize:14,maxWidth:156}),s.push({type:"node",id:`node:${nE(t.id)}`,nodeId:nE(t.id),rendererRole:n$,shape:"rectangle",fillColor:e.style.backgroundColor,strokeColor:e.style.accentColor,x:d-1,y:120,width:2,height:r,label:`${t.label} lifeline`})});let o=e.messages.map((e,t)=>{let r=n.get(e.source),i=n.get(e.target);if(void 0===r||void 0===i)throw Error(`Sequence message "${e.id}" references an unknown participant.`);if(r===i)throw Error(`Sequence message "${e.id}" cannot target its source participant.`);let a=184+88*t,s=i>r?1:-1;return{type:"arrow",id:`arrow:${e.id}`,edgeId:e.id,sourceNodeId:nE(e.source),targetNodeId:nE(e.target),..."return"===e.type?{strokeColor:"#6b7280"}:{},..."dashed"===e.style||"return"===e.type?{strokeStyle:"dashed"}:{},points:[{x:r+2*s/2,y:a},{x:i-2*s/2,y:a}],label:e.label}}),l=[...o,...s,...i,...a],d=[...s.map(e=>e.id),...i.map(e=>e.id),...a.map(e=>e.id),...o.map(e=>e.id)];return{kind:"canvas",version:1,diagramId:e.id,title:e.title,width:276+320*Math.max(0,e.participants.length-1),height:120+r+48,accentColor:e.style.accentColor,backgroundColor:e.style.backgroundColor,elements:l,layers:[],layouts:[],zOrder:d}})(o),catch:e=>new i5({status:"render_failed",context:{...u,issues:[i4({code:"render_failed",stage:"render",ref:{kind:"diagram",id:o.id},message:e instanceof Error?e.message:"Unable to render sequence diagram scene.",hint:"Repair the participant/message structure and retry."})]}})}).pipe(s.fRP("codeMode.buildSequenceDiagram.render")),{excalidraw:p,validation:h}=yield*s.OH5(()=>{let e=n4(f);return{excalidraw:e,validation:il(e)}}).pipe(s.fRP("codeMode.buildSequenceDiagram.exportValidate")),m={...u,partial:aA(f)};if(!h.ok)return yield*new i5({status:"export_failed",context:{...m,issues:ac(h.issues)}});let y=yield*al({formats:as(i.options),scene:f,excalidraw:p,renderer:r.renderer}).pipe(s.xm_(e=>new i5({status:"export_failed",context:{...m,issues:ad(e)}}))),b=yield*s.OH5(()=>r.createId("artifact")),v=yield*iU(n.write({artifactId:b,diagramId:f.diagramId,formats:y,inlineFormats:ao(i.options)}),{artifactId:b,...i.requestId?{requestId:i.requestId}:{}}).pipe(s.xm_(e=>new i5({status:"storage_failed",context:{...u,issues:[aB(e,"storage_write_failed")]}})));return{ok:!0,status:"accepted",buildId:a,...aM(i.requestId),normalizedSpec:o,quality:c,artifact:aP(v,r.artifactUrl),issues:[]}}),aW=s.fn("codeMode.createCanvas.workflow")(function*(e){let t=yield*s.OH5(()=>rr.safeParse(e)).pipe(s.fRP("codeMode.createCanvas.parse"));if(!t.success)return yield*new i3({status:"invalid_input",context:{issues:ar(t.error)}});let r=yield*iH,n=yield*r5,i=t.data,a=yield*s.OH5(()=>r.createId("build")),o={buildId:a,...aM(i.requestId)};if(r4(i.spec)>er.maxSerializedBytes)return yield*new i3({status:"limit_exceeded",context:{...o,issues:[i4({code:"canvas_limit_exceeded",stage:"canvas",ref:{kind:"request",path:"spec"},message:`CanvasSpec exceeds ${er.maxSerializedBytes} serialized bytes.`,hint:"Split the visualization into a smaller canvas or reduce repeated text and points."})]}});let l=yield*s.OH5(()=>ap(i.spec)).pipe(s.fRP("codeMode.createCanvas.normalize"));if(!l)return yield*new i3({status:"invalid_canvas",context:{...o,issues:[i4({code:"invalid_canvas_geometry",stage:"canvas",ref:{kind:"request",path:"spec.elements"},message:"CanvasSpec contains an invalid point list.",hint:"Provide at least two points for lines/connectors and three points for polygons."})]}});let d=yield*s.OH5(()=>(function(e){var t;let r,n,i=[...e.elements];for(let t of e.layouts)i=function(e,t){switch(t.type){case"row":case"column":case"stack":return function(e,t){let r=eo(e,t.ids),n=r[0];if(!n)return[...e];let i=es(n),a=t.x??i.x,s=t.y??i.y,o="stack"===t.type?t.gap??0:t.gap??32,l=new Map,d="column"===t.type?s:a;for(let e of r){let r=es(e);l.set(e.id,{x:"column"===t.type||"stack"===t.type?a:d,y:"column"===t.type?d:s}),"stack"!==t.type&&(d+=("column"===t.type?r.height:r.width)+o)}return el(e,l)}(e,t);case"grid":return function(e,t){let r=eo(e,t.ids);if(0===r.length)return[...e];let n=Math.max(1,Math.floor(t.columns)),i=r.map(es),a=Array.from({length:n},(e,t)=>Math.max(0,...i.filter((e,r)=>r%n===t).map(e=>e.width))),s=Array.from({length:Math.ceil(r.length/n)},(e,t)=>Math.max(0,...i.filter((e,r)=>Math.floor(r/n)===t).map(e=>e.height))),o=i[0];if(!o)return[...e];let l=t.x??o.x,d=t.y??o.y,c=t.columnGap??32,u=t.rowGap??32,f=new Map;return r.forEach((e,t)=>{let r=t%n,i=Math.floor(t/n);f.set(e.id,{x:l+a.slice(0,r).reduce((e,t)=>e+t,0)+c*r,y:d+s.slice(0,i).reduce((e,t)=>e+t,0)+u*i})}),el(e,f)}(e,t);case"align":return function(e,t){let r=eo(e,t.ids);if(0===r.length)return[...e];let n=r.map(es),i=n.map(e=>ed(e,t.axis)),a=n.map(e=>ed(e,t.axis)+ec(e,t.axis)),s=n.map(e=>ed(e,t.axis)+ec(e,t.axis)/2),o="start"===t.alignment?Math.min(...i):"end"===t.alignment?Math.max(...a):s.reduce((e,t)=>e+t,0)/s.length,l=new Map;return r.forEach((e,r)=>{let i=n[r];if(!i)return;let a="start"===t.alignment?o:"end"===t.alignment?o-ec(i,t.axis):o-ec(i,t.axis)/2;l.set(e.id,{x:"x"===t.axis?a:i.x,y:"y"===t.axis?a:i.y})}),el(e,l)}(e,t);case"distribute":return function(e,t){let r=eo(e,t.ids).sort((e,r)=>ed(es(e),t.axis)-ed(es(r),t.axis));if(r.length<2)return[...e];let n=r.map(es),i=n[0],a=n[n.length-1];if(!i||!a)return[...e];let s=ed(i,t.axis),o=ed(a,t.axis)+ec(a,t.axis),l=n.reduce((e,r)=>e+ec(r,t.axis),0),d=t.gap??Math.max(0,(o-s-l)/(r.length-1)),c=new Map,u=s;return r.forEach((e,r)=>{let i=n[r];i&&(c.set(e.id,{x:"x"===t.axis?u:i.x,y:"y"===t.axis?u:i.y}),u+=ec(i,t.axis)+d)}),el(e,c)}(e,t)}}(i,t);let a=(r=(t=i=function(e){let t=new Map(e.filter(e=>"node"===e.type).map(e=>[e.nodeId,e])),r=new Map;for(let t of e)("node"===t.type||"frame"===t.type)&&r.set(t.id,t);let n=e.map(e=>{if("arrow"===e.type){let r=t.get(e.sourceNodeId),n=t.get(e.targetNodeId);return r&&n?{...e,points:[ef(r,eu(n)),...e.points.slice(1,-1),ef(n,eu(r))]}:e}if("line"===e.type){let t=e.startBinding?r.get(e.startBinding.elementId):void 0,n=e.endBinding?r.get(e.endBinding.elementId):void 0;if(!t&&!n)return e;let i=[e.points[0],e.points[1],...e.points.slice(2)];return t&&(i[0]=ef(t,n?eu(n):i[i.length-1]??i[0])),n&&(i[i.length-1]=ef(n,t?eu(t):i[0])),{...e,points:i}}return e}),i=new Map(n.map(e=>[e.id,e]));return n.map(e=>{if("text"!==e.type||!e.containerId)return e;let t=i.get(e.containerId);if(t?.type==="node"){let r=eu(t);return{...e,x:r.x,y:r.y}}if(t?.type==="arrow"){let r=t.points[0],n=t.points[t.points.length-1]??r;return{...e,x:(r.x+n.x)/2,y:(r.y+n.y)/2}}return e})}(i)).filter(ei).map(es),n=t.filter(e=>"arrow"===e.type||"line"===e.type),{width:Math.max(1,...r.map(e=>e.x+e.width),...n.flatMap(e=>e.points.map(e=>e.x)))+48,height:Math.max(1,...r.map(e=>e.y+e.height),...n.flatMap(e=>e.points.map(e=>e.y)))+48}),s=e.zOrder.length?[...e.zOrder]:i.map((e,t)=>({element:e,index:t})).sort((e,t)=>(e.element.zIndex??e.index)-(t.element.zIndex??t.index)).map(({element:e})=>e.id);return{...e,width:Math.max(e.width,a.width),height:Math.max(e.height,a.height),elements:i,zOrder:s}})(l)).pipe(s.fRP("codeMode.createCanvas.layout")),c=yield*s.OH5(()=>ea(d)).pipe(s.fRP("codeMode.createCanvas.validate"));if(c.length>0){let e=au(c);return yield*new i3({status:e.some(e=>"canvas_limit_exceeded"===e.code)?"limit_exceeded":"invalid_canvas",context:{...o,normalizedSpec:d,issues:e}})}let{excalidraw:u,validation:f}=yield*s.OH5(()=>{let e=n4(d);return{excalidraw:e,validation:il(e)}}).pipe(s.fRP("codeMode.createCanvas.exportValidate")),p=af(f.issues),h={...o,normalizedSpec:d,partial:aA(d)};if(p.length>0)return yield*new i3({status:"export_failed",context:{...h,issues:p}});let m=yield*al({formats:as(i.options),scene:d,excalidraw:u,renderer:r.renderer}).pipe(s.xm_(e=>new i3({status:"export_failed",context:{...h,issues:ad(e)}}))),g=yield*s.OH5(()=>r.createId("artifact")),y=yield*iU(n.write({artifactId:g,diagramId:d.diagramId,formats:m,inlineFormats:ao(i.options)}),{artifactId:g,...i.requestId?{requestId:i.requestId}:{}}).pipe(s.xm_(e=>new i3({status:"storage_failed",context:{...h,issues:[aB(e,"storage_write_failed")]}})));return{ok:!0,status:"accepted",buildId:a,...aM(i.requestId),normalizedSpec:d,artifact:aP(y,r.artifactUrl),issues:[]}}),aJ=s.fn("codeMode.buildFlowchart.workflow")(function*(e){let t=yield*s.OH5(()=>t$.safeParse(e)).pipe(s.fRP("codeMode.buildFlowchart.parse"));if(!t.success)return yield*new i1({status:"invalid_input",context:{issues:ar(t.error)}});let r=yield*iH,n=yield*r5,i=t.data,a=as(i.options),o=yield*s.OH5(()=>r.createId("build")),l=yield*s.OH5(()=>{var e;let t;return t=eh((e=i.spec).title),{id:iW(e.id)??(t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"sketchi-flowchart"),title:t,nodes:e.nodes.map(e=>({id:eh(e.id),label:eh(e.label),kind:e.kind,...e.description?{description:eh(e.description)}:{}})),edges:e.edges.map((e,t)=>({id:iW(e.id)??`edge-${t+1}`,source:eh(e.source),target:eh(e.target),...e.label?{label:eh(e.label)}:{}})),layout:{direction:e.layout.direction},style:{...g}}}).pipe(s.fRP("codeMode.buildFlowchart.normalize")),d={buildId:o,...aM(i.requestId),normalizedSpec:l},c=yield*s.OH5(()=>L.safeParse({id:l.id,title:l.title,type:"flowchart",nodes:l.nodes.map(e=>({...e,metadata:{}})),edges:l.edges.map(e=>({...e,metadata:{}})),layout:{direction:l.layout.direction,edgeRouting:"orthogonal"},style:l.style,metadata:{}})).pipe(s.fRP("codeMode.buildFlowchart.parseCanonical"));if(!c.success){var u;return yield*new i1({status:"invalid_flowchart",context:{...d,issues:(u=c.error,u.issues.slice(0,20).map(e=>{let t=function(e,t){let r=i7(e.path),n="input"===r?"spec":`spec.${r}`,[i,a]=e.path;if("nodes"===i&&"number"==typeof a){let e=t.nodes[a]?.id;return{kind:"node",...e?{id:e}:{},path:n}}if("edges"===i&&"number"==typeof a){let e=t.edges[a]?.id;return{kind:"edge",...e?{id:e}:{},path:n}}return{kind:"diagram",id:t.id,path:n}}(e,l);return i4({code:ae(e),stage:"flowchart",ref:t,message:e.message,hint:`Fix ${t.path??"spec"} so normalization produces a valid canonical flowchart value.`})}))}})}let f=c.data,p=yield*s.OH5(()=>J(f).map(e=>{let t=function(e){if(e)return{kind:e.kind,...e.id?{id:e.id}:{},...e.path?{path:`spec.${e.path}`}:{}}}(e.ref);return i4({code:e.code,stage:"flowchart",...t?{ref:t}:{},message:e.message,hint:e.hint})})).pipe(s.fRP("codeMode.buildFlowchart.validate"));if(p.length>0)return yield*new i1({status:"invalid_flowchart",context:{...d,issues:p}});yield*s.OH5(()=>X(f)).pipe(s.fRP("codeMode.buildFlowchart.assertValid"));let h=yield*s.OH5(()=>(function(e,t){let r=[],n=0,i=(e,t,i,a=!1)=>{n+=e,r.push({...i,passed:!1,severity:a?"error":"warning",message:t})},a=new Map,s=new Map;for(let t of e.edges)a.set(t.source,(a.get(t.source)??0)+1),a.set(t.target,(a.get(t.target)??0)+1),s.set(t.source,[...s.get(t.source)??[],t]);if(e.nodes.length>1&&0===e.edges.length)i(5,"no edges at all — every node floats unconnected",{code:"disconnected_graph",refs:iz(e.nodes)},!0);else{let t=e.nodes.filter(e=>(a.get(e.id)??0)===0);t.length>0&&e.nodes.length>1&&i(Math.min(1.5*t.length,4.5),`unconnected node(s): ${t.map(e=>e.id).join(", ")}`,{code:"disconnected_graph",refs:iz(t)},!0);let r=function(e){let t=new Map;for(let r of e.nodes)t.set(r.id,[]);for(let r of e.edges)t.get(r.source)?.push(r.target),t.get(r.target)?.push(r.source);let r=new Set,n=0;for(let i of e.nodes){if(r.has(i.id))continue;n+=1;let e=[i.id];for(r.add(i.id);e.length>0;){let n=e.pop();if(void 0===n)break;for(let i of t.get(n)??[])r.has(i)||(r.add(i),e.push(i))}}return n}(e);r>1&&0===t.length&&i(2,`diagram splits into ${r} disconnected islands`,{code:"disconnected_graph",refs:iz(e.nodes)},!0)}e.nodes.length<3?i(2,"too sparse — a useful flow needs at least 3 nodes",{code:"graph_too_sparse",refs:[{kind:"diagram",id:e.id,path:"spec.nodes"}]}):e.nodes.length>24&&i(2,"too dense — trim or merge nodes (24 max)",{code:"graph_too_dense",refs:[{kind:"diagram",id:e.id,path:"spec.nodes"}]});let o=new Map;for(let t of e.nodes){let e=t.label.trim().toLowerCase();o.set(e,(o.get(e)??0)+1)}let l=[...o.entries()].filter(([,e])=>e>1);l.length>0&&i(Math.min(l.length,3),`duplicate label(s): ${l.map(([e])=>`"${e}"`).join(", ")}`,{code:"duplicate_label",refs:iz(e.nodes.filter(e=>(o.get(e.label.trim().toLowerCase())??0)>1))});let d=0,c=0;for(let t of e.nodes){if("decision"!==t.kind){t.label.endsWith("?")&&i(0,`question label on non-decision node "${t.id}"; use kind "decision" only for branch points`,{code:"question_label_not_decision",refs:iz([t])});continue}let e=s.get(t.id)??[];e.length<2?(d+=1,i(0,`decision "${t.id}" needs at least 2 outgoing branches`,{code:"underbranched_decision",refs:iz([t])},!0)):e.some(e=>!e.label)&&(c+=1,i(0,`label every branch out of decision "${t.id}" (yes/no, …)`,{code:"unlabeled_decision_branch",refs:iz([t])}))}n+=Math.min(1.5*d,4.5)+Math.min(c,3);let u=e.nodes.filter(e=>e.label.length>42);u.length>0&&i(Math.min(.5*u.length,2),`shorten label(s): ${u.map(e=>e.id).join(", ")}`,{code:"label_too_long",refs:iz(u)});let f=e.nodes.filter(e=>iB.test(e.label.trim()));f.length>0&&i(Math.min(f.length,3),`generic label(s) say nothing: ${f.map(e=>`"${e.label}"`).join(", ")}`,{code:"generic_label",refs:iz(f)}),(e.title.trim().length<4||iL.test(e.title.trim()))&&i(.5,"give the diagram a specific title",{code:"weak_title",refs:[{kind:"diagram",id:e.id,path:"spec.title"}]});let p=Math.max(0,Math.round((10-n)*10)/10);return{accepted:p>=t&&!r.some(e=>"error"===e.severity),score:p,threshold:t,summary:{nodeCount:e.nodes.length,edgeCount:e.edges.length},checks:r}})(f,i.options?.minQualityScore??8)).pipe(s.fRP("codeMode.buildFlowchart.quality")),m={...d,quality:h};if(!h.accepted)return yield*new i1({status:"quality_failed",context:{...m,issues:aa(h)}});let y=yield*s.SvU({try:()=>nI(f),catch:e=>new i1({status:"render_failed",context:{...m,issues:[i4({code:"render_failed",stage:"render",ref:{kind:"diagram",id:l.id},message:e instanceof Error?e.message:"Unable to render flowchart scene.",hint:"Simplify the graph or retry with a smaller flowchart."})]}})}).pipe(s.fRP("codeMode.buildFlowchart.render")),{excalidraw:b,validation:v}=yield*s.OH5(()=>{let e=n4(y);return{excalidraw:e,validation:il(e)}}).pipe(s.fRP("codeMode.buildFlowchart.exportValidate")),_={...m,partial:aA(y)};if(!v.ok)return yield*new i1({status:"export_failed",context:{..._,issues:ac(v.issues)}});let x=yield*al({formats:a,scene:y,excalidraw:b,renderer:r.renderer}).pipe(s.xm_(e=>new i1({status:"export_failed",context:{..._,issues:ad(e)}}))),w=yield*s.OH5(()=>r.createId("artifact")),k=yield*iU(n.write({artifactId:w,diagramId:y.diagramId,formats:x,inlineFormats:ao(i.options)}),{artifactId:w,...i.requestId?{requestId:i.requestId}:{}}).pipe(s.xm_(e=>new i1({status:"storage_failed",context:{...m,issues:[aB(e,"storage_write_failed")]}})));return{ok:!0,status:"accepted",buildId:o,...aM(i.requestId),normalizedSpec:l,quality:h,artifact:aP(k,r.artifactUrl),issues:[]}}),aY=s.fn("codeMode.getArtifact.workflow")(function*(e){let t=yield*s.OH5(()=>rl.safeParse(e)).pipe(s.fRP("codeMode.getArtifact.parse"));if(!t.success)return yield*new i6({status:"invalid_input",issues:ar(t.error)});let r=yield*iH,n=yield*r5,i=t.data,a=yield*n.readManifest(i.artifactId).pipe(s.xm_(e=>new i6({status:"storage_failed",issues:[aB(e,"storage_read_failed")]})));if(!a)return yield*new i6({status:"not_found",issues:[i4({code:"patch_source_unavailable",stage:"storage",ref:{kind:"artifact",id:i.artifactId},message:`Artifact "${i.artifactId}" was not found.`,hint:"Use the artifactId returned by buildFlowchart or applyDiagramPatch."})]});let o=i.format??"scene";if(!a.formats.some(e=>e.format===o))return yield*new i6({status:"format_unavailable",issues:[i4({code:"unsupported_artifact_format",stage:"storage",ref:{kind:"artifact",id:i.artifactId},message:`Artifact "${i.artifactId}" does not include format "${o}".`,hint:"Request a format listed in the artifact bundle."})]});let l=yield*n.read(i.artifactId,o).pipe(s.xm_(e=>new i6({status:"storage_failed",issues:[aB(e,"storage_read_failed")]})));return l?{ok:!0,artifactId:i.artifactId,diagramId:a.diagramId,format:o,mimeType:l.mimeType,...r.artifactUrl?{url:r.artifactUrl({artifactId:i.artifactId,format:o})}:{},...!0!==i.inline||!r6(o)?{}:{inline:l.data},sizeBytes:l.sizeBytes,...a.provenance?{provenance:a.provenance}:{}}:yield*new i6({status:"format_unavailable",issues:[i4({code:"patch_source_unavailable",stage:"storage",ref:{kind:"artifact",id:i.artifactId},message:`Artifact "${i.artifactId}" format "${o}" could not be read.`,hint:"Retry retrieval or rebuild the artifact."})]})}),aX=s.fn("codeMode.applyDiagramPatch.workflow")(function*(e){let t=yield*s.OH5(()=>rP.safeParse(e)).pipe(s.fRP("codeMode.applyDiagramPatch.parse"));if(!t.success)return yield*new i8({status:"invalid_input",context:{issues:ar(t.error)}});let r=yield*iH,n=yield*r5,i=t.data,a=yield*s.OH5(()=>r.createId("patch")),o={patchId:a,...aM(i.requestId)},l=as(i.options),d=yield*aT(i).pipe(s.xm_(e=>new i8({status:e.status,context:{...o,...e.context}}))),c={...o,...d.sourceArtifactId?{sourceArtifactId:d.sourceArtifactId}:{}},u=d.scene,f=am(u),p=yield*s.OH5(()=>{for(let e of i.operations){let t=function(e,t){switch(t.op){case"setDefaultStyle":case"setStyle":if(t.style.backgroundColor&&(e.backgroundColor=t.style.backgroundColor),"setDefaultStyle"===t.op){for(let r of(t.style.strokeColor&&(e.accentColor=t.style.strokeColor),ag(e)))t.style.fillColor&&(r.fillColor=t.style.fillColor),t.style.strokeColor&&(r.strokeColor=t.style.strokeColor),t.style.textColor&&(r.textColor=t.style.textColor);for(let r of ab(e))t.style.strokeColor&&(r.strokeColor=t.style.strokeColor),t.style.textColor&&(r.textColor=t.style.textColor);for(let r of ay(e))t.style.textColor&&(r.textColor=t.style.textColor);return[]}let r=a_(e,t.selector);if(0===r.nodes.length&&0===r.arrows.length&&0===r.texts.length)return[ax(t)];for(let n of r.nodes)if(t.style.fillColor&&(n.fillColor=t.style.fillColor),t.style.strokeColor&&(n.strokeColor=t.style.strokeColor),t.style.textColor){n.textColor=t.style.textColor;let r=aw(e,n.id);r&&(r.textColor=t.style.textColor)}for(let n of r.arrows)if(t.style.strokeColor&&(n.strokeColor=t.style.strokeColor),t.style.textColor){n.textColor=t.style.textColor;let r=aw(e,n.id);r&&(r.textColor=t.style.textColor)}for(let e of r.texts)t.style.textColor&&(e.textColor=t.style.textColor);return[];case"setShape":let n=a_(e,t.selector);if(0===n.nodes.length)return[ax(t)];let i=[];for(let r of n.nodes){if(r.shape=t.shape,"polygon"===t.shape?r.points=[{x:r.width/2,y:0},{x:r.width,y:r.height/2},{x:r.width/2,y:r.height},{x:0,y:r.height/2}]:delete r.points,"circle"===t.shape){let e=Math.max(r.width,r.height);r.x-=(e-r.width)/2,r.y-=(e-r.height)/2,r.width=e,r.height=e,i.push(r.nodeId)}!function(e,t){let r=aw(e,t.id);r&&(r.x=t.x+t.width/2,r.y=t.y+t.height/2)}(e,r)}return ak(e,i),[];case"translate":return function(e,t){let r=a_(e,t.selector);if(0===r.nodes.length&&0===r.arrows.length&&0===r.texts.length)return[ax(t)];let n=new Set,i=new Set;for(let a of r.nodes){a.x+=t.dx,a.y+=t.dy,n.add(a.nodeId);let r=aw(e,a.id);r&&(r.x+=t.dx,r.y+=t.dy,i.add(r.id))}for(let n of r.arrows){n.points=n.points.map(e=>{var r,n;return r=t.dx,n=t.dy,{x:e.x+r,y:e.y+n}});let r=aw(e,n.id);r&&(r.x+=t.dx,r.y+=t.dy,i.add(r.id))}for(let e of r.texts)i.has(e.id)||(e.x+=t.dx,e.y+=t.dy);return ak(e,[...n]),aE(e),[]}(e,t);case"replaceText":let a=a_(e,t.selector);if(0===a.nodes.length&&0===a.arrows.length&&0===a.texts.length)return[ax(t)];for(let r of a.nodes){r.label=t.text;let n=aw(e,r.id);n&&(n.text=t.text)}for(let r of a.arrows){r.label=t.text;let n=aw(e,r.id);n&&(n.text=t.text)}for(let e of a.texts)e.text=t.text;return[];case"rerouteEdges":let s;return 0===(s=a_(e,t.selector)).arrows.length?[ax(t)]:s.arrows.flatMap(t=>a$(e,t));case"insert":let o=new Set(e.elements.map(e=>e.id)),l=t.elements.map(e=>e.id);if(new Set(l).size!==l.length||l.some(e=>o.has(e)))return aC(t,"Inserted elements must use ids that are unique within the canvas.");let d=aO(e.zOrder,t.beforeId,t.afterId);return void 0===d?aC(t,"Insert specifies an unknown anchor or both beforeId and afterId."):(e.elements.push(...t.elements.map(e=>structuredClone(e))),e.zOrder.splice(d,0,...l),[]);case"remove":return function(e,t){let r=function(e,t){let r=a_(e,t),n=new Set([...r.nodes.map(e=>e.id),...r.arrows.map(e=>e.id),...r.texts.map(e=>e.id)]),i=new Set(t.ids??[]);for(let t of e.elements)i.has(t.id)&&n.add(t.id);return n}(e,t.selector);if(0===r.size)return[ax(t)];let n=new Set(e.elements.flatMap(e=>"node"===e.type&&r.has(e.id)?[e.nodeId]:[]));for(let t of e.elements)("text"===t.type&&t.containerId&&r.has(t.containerId)||"arrow"===t.type&&(n.has(t.sourceNodeId)||n.has(t.targetNodeId))||"line"===t.type&&(t.startBinding&&r.has(t.startBinding.elementId)||t.endBinding&&r.has(t.endBinding.elementId)))&&r.add(t.id);let i=e.elements.filter(e=>!r.has(e.id)).map(e=>{if(e.frameId&&r.has(e.frameId)){let{frameId:t,...r}=e;return r}return e});e.elements.splice(0,e.elements.length,...i);let a=e.zOrder.filter(e=>!r.has(e));e.zOrder.splice(0,e.zOrder.length,...a);let s=e.layouts.map(e=>({...e,ids:e.ids.filter(e=>!r.has(e))})).filter(e=>e.ids.length>0);return e.layouts.splice(0,e.layouts.length,...s),aE(e),[]}(e,t);case"replace":let c;return(c=e.elements.findIndex(e=>e.id===t.id))<0?[ax(t)]:t.element.id!==t.id?aC(t,"Replacement element id must match the stable id being replaced."):(e.elements.splice(c,1,structuredClone(t.element)),aE(e),[]);case"reorder":let u=new Set(t.ids);if(u.size!==t.ids.length||t.ids.some(t=>!e.zOrder.includes(t)))return aC(t,"Reorder ids must be unique ids already present in zOrder.");let f=e.zOrder.filter(e=>!u.has(e)),p=aO(f,t.beforeId,t.afterId);return void 0===p?aC(t,"Reorder specifies an unknown anchor or both beforeId and afterId."):(f.splice(p,0,...t.ids),e.zOrder.splice(0,e.zOrder.length,...f),[]);case"group":case"ungroup":let h=new Set(t.ids);if(t.ids.some(t=>!e.elements.some(e=>e.id===t)))return[ax(t)];let m=e.elements.map(e=>h.has(e.id)?"group"===t.op?{...e,groupIds:[...new Set([...e.groupIds??[],t.groupId])]}:{...e,groupIds:t.groupId?(e.groupIds??[]).filter(e=>e!==t.groupId):[]}:e);return e.elements.splice(0,e.elements.length,...m),[]}}(u,e);if(t.length>0)return t}return[]}).pipe(s.fRP("codeMode.applyDiagramPatch.operations"));if(p.length>0)return yield*new i8({status:p[0]?.code==="unknown_patch_target"?"target_not_found":"unsupported_operation",context:{...c,issues:p}});if(i.options?.preserveConnectivity!==!1){let e=am(u);if(!(f.length===e.length&&f.every((t,r)=>t===e[r])))return yield*new i8({status:"connectivity_changed",context:{...c,issues:[i4({code:"patch_preserve_connectivity_failed",stage:"flowchart",ref:{kind:"diagram",id:u.diagramId},message:"Patch changed the diagram edge connectivity.",hint:"Use buildFlowchart for process-graph structure or buildMindmap for hierarchy structure."})]}})}let h=yield*s.OH5(()=>ap(u)).pipe(s.fRP("codeMode.applyDiagramPatch.normalize"));if(!h)return yield*new i8({status:"render_failed",context:{...c,issues:[i4({code:"patch_output_invalid",stage:"render",ref:{kind:"diagram",id:u.diagramId},message:"Patched scene has an invalid arrow point list.",hint:"Reroute edges or rebuild the flowchart artifact."})]}});let m=yield*s.OH5(()=>ea(h)).pipe(s.fRP("codeMode.applyDiagramPatch.validate"));if(m.length>0)return yield*new i8({status:"render_failed",context:{...c,partial:aA(h),issues:au(m)}});let{excalidraw:g,validation:y}=yield*s.OH5(()=>{let e=n4(h);return{excalidraw:e,validation:il(e)}}).pipe(s.fRP("codeMode.applyDiagramPatch.exportValidate")),b={...c,partial:aA(h)},v=af(y.issues);if(v.length>0)return yield*new i8({status:"export_failed",context:{...b,issues:v}});let _=yield*al({formats:l,scene:h,excalidraw:g,renderer:r.renderer}).pipe(s.xm_(e=>new i8({status:"export_failed",context:{...b,issues:ad(e)}}))),x=yield*s.OH5(()=>r.createId("artifact")),w=yield*iU(n.write({artifactId:x,diagramId:h.diagramId,formats:_,inlineFormats:ao(i.options),...d.sourceArtifactId?{provenance:{sourceArtifactId:d.sourceArtifactId}}:{}}),{artifactId:x,...i.requestId?{requestId:i.requestId}:{}}).pipe(s.xm_(e=>new i8({status:"storage_failed",context:{...c,issues:[aB(e,"storage_write_failed")]}})));return{ok:!0,status:"accepted",patchId:a,...aM(i.requestId),...d.sourceArtifactId?{sourceArtifactId:d.sourceArtifactId}:{},artifact:aP(w,r.artifactUrl),issues:[]}});function aq(e,t){return e.pipe(s.YWq({onFailure:t,onSuccess:e=>e}))}let aG=s.fn("codeMode.buildFlowchart")(e=>iZ("buildFlowchart",e,aq(aJ(e),aN))),aV=s.fn("codeMode.buildMindmap")(e=>iZ("buildMindmap",e,aq(aL(e),aR))),aH=s.fn("codeMode.buildSequenceDiagram")(e=>iZ("buildSequenceDiagram",e,aq(az(e),aj)));s.fn("codeMode.createCanvas")(e=>iZ("createCanvas",e,aq(aW(e),aD))),s.fn("codeMode.getArtifact")(e=>iZ("getArtifact",e,aq(aY(e),aU)));let aK=s.fn("codeMode.applyDiagramPatch")(e=>iZ("applyDiagramPatch",e,aq(aX(e),aF)))},9095(e){e.exports=JSON.parse('[{"name":"Agola CI","constant":"AGOLA","env":"AGOLA_GIT_REF","pr":"AGOLA_PULL_REQUEST_ID"},{"name":"Alpic","constant":"ALPIC","env":"ALPIC_HOST"},{"name":"Appcircle","constant":"APPCIRCLE","env":"AC_APPCIRCLE","pr":{"env":"AC_GIT_PR","ne":"false"}},{"name":"AppVeyor","constant":"APPVEYOR","env":"APPVEYOR","pr":"APPVEYOR_PULL_REQUEST_NUMBER"},{"name":"AWS CodeBuild","constant":"CODEBUILD","env":"CODEBUILD_BUILD_ARN","pr":{"env":"CODEBUILD_WEBHOOK_EVENT","any":["PULL_REQUEST_CREATED","PULL_REQUEST_UPDATED","PULL_REQUEST_REOPENED"]}},{"name":"Azure Pipelines","constant":"AZURE_PIPELINES","env":"TF_BUILD","pr":{"BUILD_REASON":"PullRequest"}},{"name":"Bamboo","constant":"BAMBOO","env":"bamboo_planKey"},{"name":"Bitbucket Pipelines","constant":"BITBUCKET","env":"BITBUCKET_COMMIT","pr":"BITBUCKET_PR_ID"},{"name":"Bitrise","constant":"BITRISE","env":"BITRISE_IO","pr":"BITRISE_PULL_REQUEST"},{"name":"Buddy","constant":"BUDDY","env":"BUDDY_WORKSPACE_ID","pr":"BUDDY_EXECUTION_PULL_REQUEST_ID"},{"name":"Buildkite","constant":"BUILDKITE","env":"BUILDKITE","pr":{"env":"BUILDKITE_PULL_REQUEST","ne":"false"}},{"name":"CircleCI","constant":"CIRCLE","env":"CIRCLECI","pr":"CIRCLE_PULL_REQUEST"},{"name":"Cirrus CI","constant":"CIRRUS","env":"CIRRUS_CI","pr":"CIRRUS_PR"},{"name":"Cloudflare Pages","constant":"CLOUDFLARE_PAGES","env":"CF_PAGES"},{"name":"Cloudflare Workers","constant":"CLOUDFLARE_WORKERS","env":"WORKERS_CI"},{"name":"Codefresh","constant":"CODEFRESH","env":"CF_BUILD_ID","pr":{"any":["CF_PULL_REQUEST_NUMBER","CF_PULL_REQUEST_ID"]}},{"name":"Codemagic","constant":"CODEMAGIC","env":"CM_BUILD_ID","pr":"CM_PULL_REQUEST"},{"name":"Codeship","constant":"CODESHIP","env":{"CI_NAME":"codeship"}},{"name":"Drone","constant":"DRONE","env":"DRONE","pr":{"DRONE_BUILD_EVENT":"pull_request"}},{"name":"dsari","constant":"DSARI","env":"DSARI"},{"name":"Earthly","constant":"EARTHLY","env":"EARTHLY_CI"},{"name":"Expo Application Services","constant":"EAS","env":"EAS_BUILD"},{"name":"Gerrit","constant":"GERRIT","env":"GERRIT_PROJECT"},{"name":"Gitea Actions","constant":"GITEA_ACTIONS","env":"GITEA_ACTIONS"},{"name":"GitHub Actions","constant":"GITHUB_ACTIONS","env":"GITHUB_ACTIONS","pr":{"GITHUB_EVENT_NAME":"pull_request"}},{"name":"GitLab CI","constant":"GITLAB","env":"GITLAB_CI","pr":"CI_MERGE_REQUEST_ID"},{"name":"GoCD","constant":"GOCD","env":"GO_PIPELINE_LABEL"},{"name":"Google Cloud Build","constant":"GOOGLE_CLOUD_BUILD","env":"BUILDER_OUTPUT"},{"name":"Harness CI","constant":"HARNESS","env":"HARNESS_BUILD_ID"},{"name":"Heroku","constant":"HEROKU","env":{"env":"NODE","includes":"/app/.heroku/node/bin/node"}},{"name":"Hudson","constant":"HUDSON","env":"HUDSON_URL"},{"name":"Jenkins","constant":"JENKINS","env":["JENKINS_URL","BUILD_ID"],"pr":{"any":["ghprbPullId","CHANGE_ID"]}},{"name":"LayerCI","constant":"LAYERCI","env":"LAYERCI","pr":"LAYERCI_PULL_REQUEST"},{"name":"Magnum CI","constant":"MAGNUM","env":"MAGNUM"},{"name":"Netlify CI","constant":"NETLIFY","env":"NETLIFY","pr":{"env":"PULL_REQUEST","ne":"false"}},{"name":"Nevercode","constant":"NEVERCODE","env":"NEVERCODE","pr":{"env":"NEVERCODE_PULL_REQUEST","ne":"false"}},{"name":"Prow","constant":"PROW","env":"PROW_JOB_ID"},{"name":"ReleaseHub","constant":"RELEASEHUB","env":"RELEASE_BUILD_ID"},{"name":"Render","constant":"RENDER","env":"RENDER","pr":{"IS_PULL_REQUEST":"true"}},{"name":"Sail CI","constant":"SAIL","env":"SAILCI","pr":"SAIL_PULL_REQUEST_NUMBER"},{"name":"Screwdriver","constant":"SCREWDRIVER","env":"SCREWDRIVER","pr":{"env":"SD_PULL_REQUEST","ne":"false"}},{"name":"Semaphore","constant":"SEMAPHORE","env":"SEMAPHORE","pr":"PULL_REQUEST_NUMBER"},{"name":"Sourcehut","constant":"SOURCEHUT","env":{"CI_NAME":"sourcehut"}},{"name":"Strider CD","constant":"STRIDER","env":"STRIDER"},{"name":"TaskCluster","constant":"TASKCLUSTER","env":["TASK_ID","RUN_ID"]},{"name":"TeamCity","constant":"TEAMCITY","env":"TEAMCITY_VERSION"},{"name":"Travis CI","constant":"TRAVIS","env":"TRAVIS","pr":{"env":"TRAVIS_PULL_REQUEST","ne":"false"}},{"name":"Vela","constant":"VELA","env":"VELA","pr":{"VELA_PULL_REQUEST":"1"}},{"name":"Vercel","constant":"VERCEL","env":{"any":["NOW_BUILDER","VERCEL"]},"pr":"VERCEL_GIT_PULL_REQUEST_ID"},{"name":"Visual Studio App Center","constant":"APPCENTER","env":"APPCENTER_BUILD_ID"},{"name":"Woodpecker","constant":"WOODPECKER","env":{"CI":"woodpecker"},"pr":{"CI_BUILD_EVENT":"pull_request"}},{"name":"Xcode Cloud","constant":"XCODE_CLOUD","env":"CI_XCODE_PROJECT","pr":"CI_PULL_REQUEST_NUMBER"},{"name":"Xcode Server","constant":"XCODE_SERVER","env":"XCS"}]')}},o={};function l(e){var t=o[e];if(void 0!==t)return t.exports;var r=o[e]={exports:{}};return s[e].call(r.exports,r,r.exports,l),r.exports}l.m=s,l.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return l.d(t,{a:t}),t},n=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,l.t=function(e,t){if(1&t&&(e=this(e)),8&t||"object"==typeof e&&e&&(4&t&&e.__esModule||16&t&&"function"==typeof e.then))return e;var i=Object.create(null);l.r(i);var a={};r=r||[null,n({}),n([]),n(n)];for(var s=2&t&&e;("object"==typeof s||"function"==typeof s)&&!~r.indexOf(s);s=n(s))Object.getOwnPropertyNames(s).forEach(t=>{a[t]=()=>e[t]});return a.default=()=>e,l.d(i,a),i},l.d=(e,t,r)=>{var n=(t,r)=>{for(var n in t)l.o(t,n)&&!l.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,[r]:t[n]})};n(t,"get"),n(r,"value")},l.f={},l.e=e=>Promise.all(Object.keys(l.f).reduce((t,r)=>(l.f[r](e,t),t),[])),l.u=e=>"chunks/"+e+"."+({548:"416192d3a8231af0",869:"cb4ed780b3b9a21a"})[e]+".js",l.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),l.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},l.nc=void 0,i={889:0},a=e=>{var t,r,n=e.__rspack_esm_ids,a=e.__webpack_modules__,s=e.__rspack_esm_runtime,o=0;for(t in a)l.o(a,t)&&(l.m[t]=a[t]);for(s&&s(l);o<n.length;o++)r=n[o],l.o(i,r)&&i[r]&&i[r][0](),i[n[o]]=0},l.f.j=function(e,t){var r=l.o(i,e)?i[e]:void 0;if(0!==r)if(r)t.push(r[1]);else{var n=import("./"+l.u(e)).then(a,t=>{throw 0!==i[e]&&(i[e]=void 0),t}),n=Promise.race([n,new Promise(t=>{r=i[e]=[t]})]);t.push(r[1]=n)}},l(6121);
242
+ ${t}}`),n},ev="~effect/Fiber",eb={_A:y.D_,_E:y.D_},e_={id:0},ex=(()=>{try{return globalThis.process?.getBuiltinModule?.("node:async_hooks")?.AsyncResource}catch{return}})(),ew=()=>void 0===ex?void 0:new ex("effect/Fiber"),ek=()=>globalThis[O.fL];class eS{constructor(e,t=!0){this.setContext(e),this.id=++e_.id,this.currentOpCount=0,this.interruptible=t,this._stack=[],this._observers=void 0,this._exit=void 0,this._children=void 0,this._interruptedCause=void 0,this._yielded=void 0,this._running=!1,this._deferredInterrupt=!1,this._parent=void 0,this._asyncContext=void 0,this.cache.runtimeMetrics?.recordFiberStart(this.context)}get[ev](){return eb}get currentDispatcher(){return this._dispatcher??=this.cache.scheduler.makeDispatcher()}getRef(e){return h.Jt(this.context,e)}addObserver(e){return this._exit?(e(this._exit),y.Yi):(void 0===this._observers?this._observers=[e]:this._observers.push(e),()=>this.removeObserver(e))}removeObserver(e){if(this._exit||void 0===this._observers)return;let t=this._observers.indexOf(e);t>=0&&this._observers.splice(t,1)}interruptUnsafe(e,t){if(this._exit)return;let r=W(e);this.cache.stackFrame&&(r=(0,A.Eh)(r,h.L8(A.z8,this.cache.stackFrame))),t&&(r=(0,A.Eh)(r,t)),this._interruptedCause=this._interruptedCause?(0,A.h2)(this._interruptedCause,r):r,this.interruptible&&(this._running?this._deferredInterrupt=!0:this.evaluate(eB(this._interruptedCause)))}pollUnsafe(){return this._exit}evaluate(e){if(this._exit)return;if(void 0!==this._asyncContext){let t=this._asyncContext;return this._asyncContext=void 0,t.runInAsyncScope(this.evaluate,this,e)}if(void 0!==this._yielded){let e=this._yielded;this._yielded=void 0,e()}let t=this.runLoop(e);if(t===A.GN){this._asyncContext=ew();return}let r=eO.interruptChildren&&eO.interruptChildren(this);if(void 0!==r)return this.evaluate(tA(r,()=>t));if(this._exit=t,this.cache.runtimeMetrics?.recordFiberEnd(this.context,this._exit),this._parent&&(this._parent._children?.delete(this),this._parent=void 0),void 0!==this._observers){let e=this._observers;this._observers=void 0;for(let r=0;r<e.length;r++)e[r](t)}this._stack.length=0,this._children=void 0,this.context=h.Ie()}runLoop(e){let t=globalThis[O.fL];globalThis[O.fL]=this;let r=this._running;this._running=!0;let n=!1,i=e;this.currentOpCount=0;try{for(;;){this._deferredInterrupt&&(this._deferredInterrupt=!1,i=eB(this._interruptedCause)),this.currentOpCount++;let e=this.cache;if(!n&&!e.preventYield&&e.scheduler.shouldYield(this)){n=!0;let e=i;i=tA(eG,()=>e)}if((i=e.tracerContext?e.tracerContext(i,this):i[A._3](this))===A.GN){let e=this._yielded;if(A.IH in e)return this._deferredInterrupt=!1,this._yielded=void 0,e;if(this._deferredInterrupt){this._yielded=void 0,e();continue}return A.GN}}}catch(e){if(!(0,b.i5)(i,A._3))return(0,A.V2)(`Fiber.runLoop: Not a valid effect: ${String(i)}`);return this.runLoop((0,A.V2)(e))}finally{this._running=r,globalThis[O.fL]=t}}getCont(e){if(this._deferredInterrupt)return this._deferredInterrupt=!1,e$;for(;;){let t=this._stack.pop();if(!t)return;let r=t[A.u4];if(void 0!==r){let n=r.call(t,this);if(n)return n[e]=n,n}if(t[e])return t}}succeedWith(e){if((++this.currentOpCount&eE-1)==0)return(0,A.xt)(e);let t=this.getCont(A.ee);return t?t[A.ee](e,this):this.yieldWith((0,A.xt)(e))}yieldWith(e){return this._yielded=e,A.GN}children(){return this._children??=new Set}pipe(){return(0,E.tT)(this,arguments)}setContext(e){let t=this.context;if(this.context=e,void 0!==t&&h.Pf(t,e))return;let r=e.cacheRoot,n=r._fiberCache??=eI(e);this.cache?.scheduler!==n.scheduler&&(this._dispatcher=void 0),this.cache=n}get currentSpanLocal(){let e=this.cache.span;return e?._tag==="Span"?e:void 0}}let eI=e=>{let t=h.Ub(e,T.RL);return{scheduler:h.Jt(e,C._F),tracer:t,tracerContext:t?t.context:void 0,tracerEnabled:h.Jt(e,j.rf),span:h.Ub(e,T.WG),logLevel:h.Jt(e,j.Gl),minimumLogLevel:h.Jt(e,j.zQ),stackFrame:h.Jt(e,j.vA),runtimeMetrics:h.Ub(e,P.F),maxOpsBeforeYield:h.Jt(e,C.Zm),preventYield:h.Jt(e,C.hf)}},e$={[A.ee]:(e,t)=>eB(t._interruptedCause),[A.Sc]:(e,t)=>eB(t._interruptedCause)},eE=32,eO={interruptChildren:void 0},eC=e=>{if(!e.cache.stackFrame)return;let t=new Map;return t.set(A.QJ.key,e.cache.stackFrame),h.LZ(t)},eT=e=>{if(void 0!==e._children&&0!==e._children.size)return eD(e._children)},eM=e=>e._exit?eF(e._exit):te(t=>e._exit?t(eF(e._exit)):ez(e.addObserver(e=>t(eF(e))))),eA=e=>te(t=>{let r,n=e[Symbol.iterator](),i=[];return!function e(){let a=n.next();for(;!a.done;){if(a.value._exit){i.push(a.value._exit),a=n.next();continue}r=a.value.addObserver(t=>{i.push(t),e()});return}t(eF(i))}(),ez(()=>r?.())}),eN=e=>e._exit?e._exit:te(t=>e._exit?t(e._exit):ez(e.addObserver(t))),eP=e=>te(t=>{let r=Array.from(e);if(0===r.length)return t(eF(p.Ie()));let n=Array(r.length),i=p.Ie(),a=()=>{for(let e=0;e<i.length;e++)r[e].removeObserver(i[e])},s=0,o=!1;for(let e=0;e<r.length&&!o;e++){let l=i=>{if(s++,"Failure"===i._tag)return o=!0,a(),t(i);n[e]=i.value,s===r.length&&t(eF(n))};i.push(l),r[e].addObserver(l)}return ez(()=>{o=!0,a()})}),eR=e=>(0,A.R6)(t=>ej(e,t.id)),ej=(0,y.XY)(e=>(0,b.i5)(e[0],ev),(e,t,r)=>(0,A.R6)(n=>{let i=eC(n);return i=i&&r?h.h1(i,r):i??r,e.interruptUnsafe(t,i),t$(eM(e))})),eD=e=>(0,A.R6)(t=>{let r=eC(t),n=p.Ie();for(let i of e)i.interruptUnsafe(t.id,r),n.push(i);return t$(eA(n))}),eU=(0,y.XY)(2,(e,t)=>(0,A.R6)(r=>{let n=eC(r),i=p.Ie();for(let r of e)r.interruptUnsafe(t,n),i.push(r);return t$(eA(i))})),eF=A.xt,eB=A.cb,eL=A.Rk,ez=(0,A.Uf)({op:"Sync",[A._3](e){let t=this[A.a2](),r=e.getCont(A.ee);return r?r[A.ee](t,e):e.yieldWith((0,A.xt)(t))}}),eW=(0,A.Uf)({op:"Suspend",[A._3](e){return this[A.a2]()}}),eJ=(0,y.XY)(e=>e.length>=2||v.isOption(e[0]),(e,t)=>v.isNone(e)?eL(t?t():new A.Xm("Effect.fromOption: Option.none")):eF(e.value)),eY=_.YW({onFailure:eL,onSuccess:eF}),eX=e=>null==e?eL(new A.Xm):eF(e),eq=(0,A.Uf)({op:"Yield",[A._3](e){let t=!1;return e.currentDispatcher.scheduleTask(()=>{t||e.evaluate(t0)},this[A.a2]??0),e.yieldWith(()=>{t=!0})}}),eG=eq(0),eV=e=>eF(v.some(e)),eH=eF(v.none()),eK=e=>v.isNone(e)?eH:tD(e.value,v.some),eQ=e=>eW(()=>eB(e())),eZ=e=>(0,A.V2)(e),e0=e=>eW(()=>eL(e())),e1=eF(void 0),e2=e=>{let t="function"==typeof e?e:e.try,r="function"==typeof e?e=>new aj(e,"An error occurred in Effect.try"):e.catch;return eW(()=>{try{return eF(t())}catch(e){return eL(r(e))}})},e5=e=>e4(function(t,r){e(r).then(e=>t(eF(e)),e=>t(eZ(e)))},0!==e.length),e3=e=>{let t="function"==typeof e?e:e.try,r="function"==typeof e?e=>new aj(e,"An error occurred in Effect.tryPromise"):e.catch;return e4(function(e,n){let i=e=>eW(()=>{try{return eL((0,M.s)(()=>r(e)))}catch(e){return eZ(e)}});try{t(n).then(t=>e(eF(t)),t=>e(i(t)))}catch(t){e(i(t))}},0!==t.length)},e6=e=>(0,A.R6)(t=>e(t.id)),e8=(0,A.R6)(eF),e9=e6(eF),e4=(n=(0,A.yj)({op:"Async",[A._3](e){let t=!1,r=!1,n=this.withSignal?new AbortController:void 0,i=this.register.call(e.cache.scheduler,n=>{t||(t=!0,r?e.evaluate(n):r=n)},n?.signal);return!1!==r?r:(r=!0,e._yielded=()=>{t=!0},void 0===n&&void 0===i||e._stack.push(e7(()=>(t=!0,n?.abort(),i??t0))),A.GN)}}),(i=function(e,t){this.register=e,this.withSignal=t}).prototype=n,function(e,t){return new i(e,t)}),e7=(0,A.Uf)({op:"AsyncFinalizer",[A.u4](e){e.interruptible&&(e.interruptible=!1,e._stack.push(n2))},[A.Sc](e,t){return K(e)?tA(ng((0,A.cb)(e),this[A.a2]()),()=>eB(e)):eB(e)}}),te=e=>e4(e,e.length>=2),tt=te(y.Yi),tr=(...e)=>{if(1===e.length){let t=e[0];return eW(()=>tc(t()))}let[t,r]=e;return eW(()=>tc(r.call(t.self)))},tn=(e,...t)=>{let r=0===t.length?function(){return eW(()=>tc(e.apply(this,arguments)))}:function(){let r=eW(()=>tc(e.apply(this,arguments)));for(let e=0;e<t.length;e++)r=t[e](r,...arguments);return r};return ti(e.length,r)},ti=(e,t)=>Object.defineProperty(t,"length",{value:e,configurable:!0}),ta=F(2),ts=function(){let e,t="string"==typeof arguments[0],r=t?arguments[0]:"Effect.fn",n=t?arguments[1]:void 0,i=(0,D.jt)();return(0!==i&&((0,D.ft)(2),e=new globalThis.Error,(0,D.ft)(i)),t)?(i,...a)=>to(r,i,e,a,t,n):to(r,arguments[0],e,Array.prototype.slice.call(arguments,1),t,n)},to=(e,t,r,n,i,a)=>{let s="function"==typeof t?t:n.shift().bind(t.self),o=`${e} (definition)`,l=r?ta(()=>r.stack):y.MN;return ti(s.length,function(...t){let r,d=eW(()=>{let e=s.apply(this,arguments);return(0,A.yw)(e)?e:tc(e)});for(let e=0;e<n.length;e++)d=n[e](d,...t);if(!(0,A.yw)(d))return d;let c=(0,D.jt)();return 0!==c&&((0,D.ft)(2),r=new globalThis.Error,(0,D.ft)(c)),ra(i?ai(e,a,e=>aa(d,e)):d,j.vA,t=>({name:e,stack:r?ta(()=>r.stack):y.MN,parent:{name:o,stack:l,parent:t}}))})},tl=(e,...t)=>ti(e.length,0===t.length?function(){return td(()=>e.apply(this,arguments))}:function(){let r=td(()=>e.apply(this,arguments));for(let e of t)r=e(r,...arguments);return r}),td=e=>{try{let t,r=e();for(;;){let n=r.next(t);if(n.done)return eF(n.value);let i=n.value;if(i&&"Success"===i._tag){t=i.value;continue}{if(i&&"Failure"===i._tag)return n.value;let t=!0;return eW(()=>t?(t=!1,tA(n.value,e=>tc(r,e))):eW(()=>tc(e())))}}}catch(e){return eZ(e)}},tc=(a=(0,A.yj)({op:"Iterator",[A.ee](e,t){let r=this.iterator;for(;;){let n=r.next(e);if(n.done)return eF(n.value);if(!tP(n.value))return t._stack.push(this),n.value;if("Failure"===n.value._tag)return n.value;e=n.value.value}},[A._3](e){return this[A.ee](this.initial,e)}}),(s=function(e,t){this.iterator=e,this.initial=t}).prototype=a,function(e,t){return new s(e,t)}),tu=(0,y.XY)(2,(e,t)=>new th(e,tm,eF(t))),tf=function(e){return e._stack.push(this),this[A.a2]},tp=(0,A.yj)({op:"OnSuccess",[A._3]:tf}),th=function(e,t,r){this[A.a2]=e,this[A.ee]=t,this.payload=r};th.prototype=tp;let tm=function(){return this.payload},tg=function(e,t){return t.succeedWith(this.payload)},ty=(o="~effect/Effect/stackProbe",({[o]:function(){return Error().stack}})[o]()?.includes("[as "+o+"]")===!0),tv=function(e,t){let r=this.payload;return t.succeedWith(ty?r(e):(0,M.s)(()=>r(e)))},tb=function(e){return(0,this.payload)(e)},t_=function(e){return new th((0,this.payload)(e),tg,e)},tx=function(e){return new th(this.payload,tg,e)},tw=e=>tD(e,v.some),tk=e=>r9(e,{onFailure:eF,onSuccess:eL}),tS=(0,y.XY)(2,(e,t)=>new th(e,(0,A.yw)(t)?tm:tb,t)),tI=(0,y.XY)(2,(e,t)=>new th(e,(0,A.yw)(t)?tx:t_,t)),t$=e=>new th(e,tm,t0),tE=e=>rw(e,eL),tO=(e,t)=>(0,A.R6)(r=>{let n=new Set;return nD(r,()=>0===n.size?void 0:eD(n)),te(i=>{let a=p.Ts(e),s=a.length,o=0,l=!1,d=[],c=(e,n,a)=>{if(o++,"Failure"===e._tag){d.push(...e.cause.reasons),o>=s&&i(eB((0,A.b5)(d)));return}let c=!l;l=!0,i(e),c&&t?.onWinner&&t.onWinner({fiber:n,index:a,parentFiber:r})};for(let e=0;e<s;e++){let t=iT(r,a[e],!0,!0,!1);if(n.add(t),t.addObserver(r=>{n.delete(t),c(r,t,e)}),l)break}})}),tC=(e,t)=>(0,A.R6)(r=>{let n=new Set;return nD(r,()=>0===n.size?void 0:eD(n)),te(i=>{let a=!1,s=0;for(let o of e){if(a)break;let e=s++,l=iT(r,o,!0,!0,!1);n.add(l),l.addObserver(s=>{n.delete(l);let o=!a;a=!0,i(s),o&&t?.onWinner&&t.onWinner({fiber:l,index:e,parentFiber:r})})}})}),tT=(0,y.XY)(e=>(0,A.yw)(e[1]),(e,t,r)=>tO([e,t],r)),tM=(0,y.XY)(e=>(0,A.yw)(e[1]),(e,t,r)=>tC([e,t],r)),tA=(0,y.XY)(2,(e,t)=>new th(e,tb,t)),tN=(0,y.XY)(2,(e,t)=>tP(e)?"Success"===e._tag?t.onSuccess(e.value):t.onFailure(e.cause):rZ(e,t)),tP=e=>void 0!==e[A.IH],tR=(0,y.XY)(2,(e,t)=>tP(e)?"Success"===e._tag?t(e.value):e:tA(e,t)),tj=e=>tA(e,y.D_),tD=(0,y.XY)(2,(e,t)=>new th(e,tv,t)),tU=(0,y.XY)(2,(e,t)=>tP(e)?t1(e,t):tD(e,t)),tF=(0,y.XY)(2,(e,t)=>tP(e)?t2(e,t):rW(e,t)),tB=(0,y.XY)(2,(e,t)=>tP(e)?t5(e,t):rJ(e,t)),tL=(0,y.XY)(2,(e,t)=>{if(tP(e)){if("Success"===e._tag)return e;let r=X(e.cause);return _.N6(r)?e:t(r.success)}return rE(e,t)}),tz=e=>(0,A.cb)(W(e)),tW=e=>"Success"===e._tag,tJ=e=>"Success"===e._tag?_.Py(e):_.fJ(e),tY=e=>"Success"===e._tag?_.Py(e.value):_.fJ(e),tX=e=>"Failure"===e._tag,tq=e=>"Failure"===e._tag?_.Py(e):_.fJ(e),tG=e=>"Failure"===e._tag?_.Py(e.cause):_.fJ(e),tV=x(tG,X),tH=x(tG,H),tK=e=>"Failure"===e._tag&&K(e.cause),tQ=e=>"Failure"===e._tag&&G(e.cause),tZ=e=>"Failure"===e._tag&&J(e.cause),t0=(0,A.xt)(void 0),t1=(0,y.XY)(2,(e,t)=>"Success"===e._tag?(0,A.xt)(t(e.value)):e),t2=(0,y.XY)(2,(e,t)=>{if("Success"===e._tag)return e;let r=X(e.cause);return _.N6(r)?e:(0,A.Rk)(t(r.success))}),t5=(0,y.XY)(2,(e,t)=>{if("Success"===e._tag)return(0,A.xt)(t.onSuccess(e.value));let r=X(e.cause);return _.N6(r)?e:(0,A.Rk)(t.onFailure(r.success))}),t3=(0,y.XY)(2,(e,t)=>tW(e)?(0,A.xt)(t):e),t6=(0,y.XY)(2,(e,t)=>tW(e)?t:e),t8=(0,y.XY)(2,(e,t)=>tW(e)?t.onSuccess(e.value):t.onFailure(e.cause)),t9=t3(void 0),t4=e=>{let t=[];for(let r of e)"Failure"===r._tag&&t.push(...r.cause.reasons);return 0===t.length?t0:(0,A.cb)((0,A.b5)(t))},t7=e=>tW(e)?v.some(e.value):v.none(),re=e=>tX(e)?v.some(e.cause):v.none(),rt=e=>{let t=tV(e);return _.N6(t)?v.none():v.some(t.success)},rr=e=>e,rn=e=>(0,A.R6)(t=>eF(h.om(t.context,e))),ri=(0,y.XY)(2,(e,t)=>(0,A.R6)(r=>{let n=r.context,i=t(n);return n===i||(r.setContext(i),nD(r,()=>{r.setContext(n)})),e})),ra=(0,y.XY)(3,(e,t,r)=>ri(e,e=>{let n=h.fp(e,t),i=r(n);return n===i?e:h.WQ(e,t,i)})),rs=(e,t,r)=>n0((0,A.R6)(n=>{let i=h.fp(n.context,e),a=t(i);return n.setContext(h.WQ(n.context,e,a)),n_(h.fp(n.context,nf),t=>{let s,o=h.om(n.context,e);if(v.isNone(o))return e1;let l=o.value;if(r?.reset===void 0){if(l!==a)return e1;s=i}else s=r.reset(i,a,l);return n.setContext(h.WQ(n.context,e,s)),e1})})),ro=()=>rl,rl=(0,A.R6)(e=>eF(e.context)),rd=e=>(0,A.R6)(t=>e(t.context)),rc=(0,y.XY)(2,(e,t)=>ri(e,(0,y.dY)(t))),ru=(0,y.XY)(2,(e,t)=>tP(e)?e:ri(e,h.h1(t))),rf=function(){return 1==arguments.length?(0,y.XY)(2,(e,t)=>rp(e,arguments[0],t)):(0,y.XY)(3,(e,t,r)=>rp(e,t,r)).apply(this,arguments)},rp=(e,t,r)=>ri(e,h.WQ(t,r)),rh=(0,y.XY)(3,(e,t,r)=>tA(r,r=>rf(e,t,r))),rm=(0,y.XY)(e=>(0,A.yw)(e[1]),(e,t,r)=>rg(e,t,(e,t)=>[e,t],r)),rg=(0,y.XY)(e=>(0,A.yw)(e[1]),(e,t,r,n)=>n?.concurrent?tD(ie([e,t],{concurrency:2}),([e,t])=>r(e,t)):tA(e,e=>tD(t,t=>r(e,t)))),ry=(0,y.XY)(e=>(0,A.yw)(e[0]),(e,t,r)=>ib(e,t,r?e=>eL(r(e)):()=>eL(new A.Xm))),rv=(0,y.XY)(2,(e,t)=>tA(t,t=>t?tw(e):eH)),rb=(0,y.XY)(2,(e,t)=>Array.from({length:t},()=>e)),r_=(0,y.XY)(e=>(0,A.yw)(e[0]),(e,t,r)=>ie(rb(e,t),r)),rx=(0,y.XY)(e=>(0,A.yw)(e[0]),(e,t)=>id({while:y.ue,body:(0,y.dY)(t?.disableYield?e:tA(e,e=>eG)),step:y.Yi})),rw=(0,y.XY)(2,(e,t)=>new rS(e,1!==t.length?e=>t(e):t)),rk=(0,A.yj)({op:"OnFailure",[A._3]:tf}),rS=function(e,t){this[A.a2]=e,this[A.Sc]=t};rS.prototype=rk;let rI=(0,y.XY)(3,(e,t,r)=>rw(e,e=>t(e)?r(e):eB(e))),r$=(0,y.XY)(3,(e,t,r)=>rw(e,e=>{let n=t(e);return _.N6(n)?eB(n.failure):r(n.success,e)})),rE=(0,y.XY)(2,(e,t)=>r$(e,X,e=>t(e))),rO=e=>r9(e,{onFailure:e=>(0,A.PW)(e)?eH:eL(e),onSuccess:eV}),rC=(0,y.XY)(2,(e,t)=>r$(e,H,t)),rT=(0,y.XY)(2,(e,t)=>rw(e,e=>tS(t(e),eB(e)))),rM=(0,y.XY)(3,(e,t,r)=>rI(e,t,e=>tS(r(e),eB(e)))),rA=(0,y.XY)(3,(e,t,r)=>rw(e,e=>{let n=t(e);return _.N6(n)?eB(e):tS(r(n.success,e),eB(e))})),rN=(0,y.XY)(2,(e,t)=>rA(e,X,e=>t(e))),rP=(0,y.XY)(3,(e,t,r)=>{let n=Array.isArray(t)?e=>(0,b.i5)(e,"_tag")&&t.includes(e._tag):(0,b.$J)(t);return rN(e,e=>n(e)?r(e):e1)}),rR=(0,y.XY)(2,(e,t)=>rA(e,H,e=>t(e))),rj=(0,y.XY)(e=>(0,A.yw)(e[0]),(e,t,r,n)=>rw(e,e=>{let i=X(e);return _.N6(i)?eB(i.failure):t(i.success)?r(i.success):n?n(i.success):eB(e)})),rD=(0,y.XY)(e=>(0,A.yw)(e[0]),(e,t,r,n)=>rw(e,e=>{let i=X(e);if(_.N6(i))return eB(i.failure);let a=t(i.success);return _.N6(a)?n?n(a.failure):eB(e):r(a.success)})),rU=(0,y.XY)(e=>(0,A.yw)(e[0]),(e,t,r,n)=>rj(e,Array.isArray(t)?e=>(0,b.i5)(e,"_tag")&&t.includes(e._tag):(0,b.$J)(t),r,n)),rF=(0,y.XY)(e=>(0,A.yw)(e[0]),(e,t,r)=>{let n;return rD(e,e=>(n??=Object.keys(t),(0,b.i5)(e,"_tag")&&(0,b.Kg)(e._tag)&&n.includes(e._tag)?_.Py(e):_.fJ(e)),e=>t[e._tag](e),r)}),rB=(0,y.XY)(e=>(0,A.yw)(e[0]),(e,t,r,n,i)=>rj(e,e=>(0,b.$J)(e,t)&&(0,b.i5)(e,"reason")&&(void 0!==i||(0,b.$J)(e.reason,r)),e=>{let t=e.reason;return(0,b.$J)(t,r)?n(t,e):i?i(t,e):eL(e)})),rL=(0,y.XY)(e=>(0,A.yw)(e[0]),(e,t,r,n)=>{let i;return rj(e,e=>(0,b.$J)(e,t)&&(0,b.i5)(e,"reason")&&(0,b.i5)(e.reason,"_tag")&&(0,b.Kg)(e.reason._tag)&&(void 0!==n||(i??=Object.keys(r)).includes(e.reason._tag)),e=>{let t=e.reason;return(i??=Object.keys(r)).includes(t._tag)?r[t._tag](t,e):n?n(t,e):eL(e)})}),rz=(0,y.XY)(2,(e,t)=>rD(e,e=>(0,b.$J)(e,t)&&(0,b.i5)(e,"reason")?_.Py(e.reason):_.fJ(e),eL)),rW=(0,y.XY)(2,(e,t)=>rE(e,e=>e0(()=>t(e)))),rJ=(0,y.XY)(2,(e,t)=>r9(e,{onFailure:e=>e0(()=>t.onFailure(e)),onSuccess:e=>ez(()=>t.onSuccess(e))})),rY=e=>rE(e,eZ),rX=(0,y.XY)(2,(e,t)=>rE(e,e=>ez(()=>t(e)))),rq=e=>eW(()=>{let t=e[Symbol.iterator](),r=t.next();return r.done?eZ(Error("Received an empty collection of effects")):function e(r){let n=t.next();return n.done?r.value:rE(r.value,t=>e(n))}(r)}),rG=e=>rE(e,t=>tA(eG,()=>rG(e))),rV=(0,y.XY)(e=>(0,A.yw)(e[0]),(e,t)=>{if(!t?.log)return r9(e,{onFailure:e=>e1,onSuccess:e=>e1});let r=aX(!0===t.log?void 0:t.log);return rZ(e,{onFailure(e){let n=Y(e);return _.N6(n)?eB(n.failure):void 0===t.message?r(e):r(t.message,e)},onSuccess:e=>e1})}),rH=(0,y.XY)(e=>(0,A.yw)(e[0]),(e,t)=>{if(!t?.log)return rZ(e,{onFailure:e=>e1,onSuccess:e=>e1});let r=aX(!0===t.log?void 0:t.log);return rZ(e,{onFailure:e=>void 0===t.message?r(e):r(t.message,e),onSuccess:e=>e1})}),rK=e=>r4(e,{onFailure:v.none,onSuccess:v.some}),rQ=e=>r7(e,{onFailure:_.fJ,onSuccess:_.Py}),rZ=(0,y.XY)(2,(e,t)=>new r1(e,1!==t.onSuccess.length?e=>t.onSuccess(e):t.onSuccess,1!==t.onFailure.length?e=>t.onFailure(e):t.onFailure)),r0=(0,A.yj)({op:"OnSuccessAndFailure",[A._3]:tf}),r1=function(e,t,r){this[A.a2]=e,this[A.ee]=t,this[A.Sc]=r};r1.prototype=r0;let r2=function(e,t){let r=this.payload;return t.succeedWith(ty?r.onSuccess(e):(0,M.s)(()=>r.onSuccess(e)))},r5=(e,t)=>{let r=(0,A.yj)({op:e,[A._3]:tf,[A.ee]:r2,[A.Sc]:t}),n=function(e,t){this[A.a2]=e,this.payload=t};return n.prototype=r,n},r3=r5("Match",function(e,t){let r=e.reasons.find(A.lC);if(void 0===r)return eB(e);let n=this.payload;return t.succeedWith(ty?n.onFailure(r.error):(0,M.s)(()=>n.onFailure(r.error)))}),r6=r5("MatchCause",function(e,t){let r=this.payload;return t.succeedWith(ty?r.onFailure(e):(0,M.s)(()=>r.onFailure(e)))}),r8=(0,y.XY)(2,(e,t)=>new r6(e,t)),r9=(0,y.XY)(2,(e,t)=>rZ(e,{onFailure:e=>{let r=e.reasons.find(A.lC);return r?t.onFailure(r.error):eB(e)},onSuccess:t.onSuccess})),r4=(0,y.XY)(2,(e,t)=>new r3(e,t)),r7=(0,y.XY)(2,(e,t)=>{if(tP(e)){if("Success"===e._tag)return(0,A.xt)(t.onSuccess(e.value));let r=X(e.cause);return _.N6(r)?e:(0,A.xt)(t.onFailure(r.success))}return r4(e,t)}),ne=(0,y.XY)(2,(e,t)=>tP(e)?"Success"===e._tag?(0,A.xt)(t.onSuccess(e.value)):(0,A.xt)(t.onFailure(e.cause)):r8(e,t)),nt=e=>tP(e)?(0,A.xt)(e):nr(e),nr=(0,A.Uf)({op:"Exit",[A._3](e){return e._stack.push(this),this[A.a2]},[A.ee]:(e,t,r)=>t.succeedWith(r??(0,A.xt)(e)),[A.Sc]:(e,t,r)=>t.succeedWith(r??(0,A.cb)(e))}),nn=r7({onFailure:()=>!0,onSuccess:()=>!1}),ni=r7({onFailure:()=>!1,onSuccess:()=>!0}),na=(0,y.XY)(2,(e,t)=>tS(av(t),e)),ns=(0,y.XY)(2,(e,t)=>tA(nl(e,t.duration),e=>v.isNone(e)?t.orElse():eF(e.value))),no=(0,y.XY)(2,(e,t)=>{let r=m.bN(t);return ns(e,{duration:r,orElse:()=>eL(new aS(`Operation timed out after '${m.GP(r)}'`))})}),nl=(0,y.XY)(2,(e,t)=>tM(tw(e),tu(av(t),v.none()))),nd=e=>ay(t=>{let r=t.monotonicTimeNanosUnsafe();return tD(e,e=>[m.cF(t.monotonicTimeNanosUnsafe()-r),e])}),nc="~effect/Scope",nu="~effect/Scope/Closeable",nf=h.kl("effect/Scope"),np=(e,t)=>(0,A.R6)(r=>{let n=nh(e,t);return void 0===n?e1:(n6(r),n)}),nh=(e,t)=>{let r=e.state;if("Closed"===r._tag||(e.state={_tag:"Closed",exit:t},void 0!==e.parent&&nk(e.parent,e),"Empty"===r._tag))return;if(void 0!==r.finalizer)return nm(r.finalizer,t);let n=r.finalizers;return 1===n.size?nm(n.values().next().value,t):ny(e,n,t)},nm=(e,t)=>{try{return e(t)}catch(e){return(0,A.V2)(e)}},ng=(e,t)=>tW(e)?t:rw(t,t=>eB((0,A.h2)(e.cause,t))),ny=tn(function*(e,t,r){let n=[],i=[],a=Array.from(t.values()),s=ek();for(let t=a.length-1;t>=0;t--){let o=a[t];"sequential"===e.strategy?n.push((yield*nt(nm(o,r)))):i.push(iT(s,nm(o,r),!0,!0,"inherit"))}return i.length>0&&(n=yield*eA(i)),yield*t4(n)}),nv=(e,t)=>ez(()=>nb(e,t)),nb=(e,t)=>{let r=nI(t,e);return"Closed"===e.state._tag?r.state=e.state:nw(e,r,e=>np(r,e)),r},n_=(e,t)=>eW(()=>"Closed"===e.state._tag?t(e.state.exit):(nw(e,{},t),e1)),nx=(e,t)=>n_(e,(0,y.dY)(t)),nw=(e,t,r)=>{if("Empty"===e.state._tag)e.state={_tag:"Open",finalizerKey:t,finalizer:r,finalizers:void 0};else if("Open"===e.state._tag){let n=e.state;void 0!==n.finalizer&&(n.finalizers=new Map([[n.finalizerKey,n.finalizer]]),n.finalizerKey=void 0,n.finalizer=void 0),n.finalizers.set(t,r)}},nk=(e,t)=>{if("Open"!==e.state._tag)return;let r=e.state;r.finalizerKey===t?e.state=n$:void 0!==r.finalizers&&(r.finalizers.delete(t),0===r.finalizers.size&&(e.state=n$))},nS=e=>nI(e,void 0),nI=(e="sequential",t)=>({[nu]:nu,[nc]:nc,strategy:e,parent:t,state:n$}),n$={_tag:"Empty"},nE=e=>ez(()=>nS(e)),nO=nf,nC=rf(nf),nT=e=>(0,A.R6)(t=>{let r=t.context,n=nS();return t.setContext(h.WQ(t.context,nf,n)),nD(t,e=>(t.setContext(r),nh(n,e))),e}),nM=(0,y.XY)(2,(e,t)=>nU(nC(e,t),e=>eW(()=>nh(t,e)??e1))),nA=e=>eW(()=>{let t=nS();return nU(e(t),e=>eW(()=>nh(t,e)??e1))}),nN=(e,t,r)=>rd(n=>n9(i=>tA(nO,a=>tI(r?.interruptible?i(e):e,e=>n_(a,r=>ru(t(e,r),n)))))),nP=e=>tA(nO,t=>rd(r=>n_(t,t=>ru(e(t),r)))),nR=(l=(0,A.yj)({op:"OnExit",[A._3](e){return e._stack.push(this),this.effect},[A.u4](e){e.interruptible&&!0!==this.interruptible&&(e._stack.push(n2),e.interruptible=!1)},[A.ee](e,t,r){let n;r??=(0,A.xt)(e);try{n=this.onExit(r)}catch(e){n=(0,A.V2)(e)}return n?tA(n,e=>r):r},[A.Sc](e,t,r){let n;r??=(0,A.cb)(e);try{n=this.onExit(r)}catch(e){n=(0,A.V2)(e)}return n?tA(ng(r,n),e=>r):r}}),(d=function(e,t,r){this.effect=e,this.onExit=t,this.interruptible=r}).prototype=l,d),nj=(e,t,r)=>new nR(e,t,r),nD=(e,t)=>{e._stack.push(new nR(void 0,t,void 0))},nU=(0,y.XY)(2,nj),nF=(0,y.XY)(2,(e,t)=>nU(e,e=>t)),nB=(0,y.XY)(3,(e,t,r)=>nU(e,e=>t(e)?r(e):e1)),nL=(0,y.XY)(3,(e,t,r)=>nU(e,e=>{let n=t(e);return _.N6(n)?e1:r(n.success,e)})),nz=(0,y.XY)(2,(e,t)=>nL(e,tG,t)),nW=(0,y.XY)(3,(e,t,r)=>nB(e,e=>"Failure"===e._tag&&t(e.cause),e=>r(e.cause))),nJ=(0,y.XY)(3,(e,t,r)=>nU(e,e=>{if("Failure"!==e._tag)return e1;let n=t(e.cause);return _.N6(n)?e1:r(n.success,e.cause)})),nY=(0,y.XY)(2,(e,t)=>nJ(Z,t)(e)),nX=(e,t,r)=>n9(n=>tA(e,e=>nj(eW(()=>n(t(e))),t=>r(e,t),!0))),nq=e=>nN(e,e=>(0,b.i5)(e,Symbol.asyncDispose)?e5(()=>e[Symbol.asyncDispose]()):ez(()=>e[Symbol.dispose]())),nG=(0,y.XY)(2,(e,t)=>ez(()=>nH(e,"function"==typeof t?e=>m.kE(m.bN(t(e))):(0,y.dY)(m.kE(m.bN(t)))))),nV=(0,y.dY)(1/0),nH=(e,t)=>{let r,n,i=0,a=(e,t)=>(t.awaiters++,nD(e,()=>{if(!(--t.awaiters>0)&&n===t)return n=void 0,eR(t.fiber)}),eN(t.fiber));return[(0,A.R6)(s=>{if(void 0!==n)return a(s,n);if(void 0!==r&&(1/0===i||s.getRef(af).currentTimeMillisUnsafe()<i))return r;r=void 0;let o=s.getRef(af),l={fiber:void 0,awaiters:0};return n=l,l.fiber=iT(s,nj(e,e=>{if(n!==l||(n=void 0,tK(e)))return;let a=t(e);i=1/0===a?1/0:o.currentTimeMillisUnsafe()+a,r=e}),!0,!0),l.fiber._exit??a(s,l)}),ez(()=>{r=void 0})]},nK=(0,y.XY)(2,(e,t)=>tD(nG(e,t),e=>e[0])),nQ=e=>ez(()=>nH(e,nV)[0]),nZ=(0,A.R6)(e=>eB(W(e.id))),n0=e=>(0,A.R6)(t=>(t.interruptible&&(t.interruptible=!1,t._stack.push(n2)),e)),n1=(0,A.Uf)({op:"SetInterruptible",[A.u4](e){if(e.interruptible=this[A.a2],e._interruptedCause&&e.interruptible)return()=>eB(e._interruptedCause)}}),n2=n1(!0),n5=n1(!1),n3=e=>{if(e.interruptible=!0,e._stack.push(n5),e._interruptedCause)return eB(e._interruptedCause)},n6=e=>{e.interruptible&&(e.interruptible=!1,e._stack.push(n2))},n8=e=>(0,A.R6)(t=>t.interruptible?e:n3(t)??e),n9=e=>(0,A.R6)(t=>t.interruptible?(t.interruptible=!1,t._stack.push(n2),e(n8)):e(y.D_)),n4=e=>(0,A.R6)(t=>{if(t.interruptible)return e(y.D_);let r=n3(t),n=e(n0);return r??n}),n7=tD(nN(ez(()=>new AbortController),e=>ez(()=>e.abort())),e=>e.signal),ie=(e,t)=>(0,b.xZ)(e)?t?.mode==="result"?ic(e,rQ,t):ic(e,y.D_,t):t?.discard?"result"===t.mode?ic(Object.values(e),rQ,t):ic(Object.values(e),y.D_,t):eW(()=>{let r={};return tu(ic(Object.entries(e),([e,n])=>tD(t?.mode==="result"?rQ(n):n,t=>{R.x(r,e,t)}),{discard:!0,concurrency:t?.concurrency}),r)}),it=(0,y.XY)(e=>(0,b.xZ)(e[0])&&!(0,A.yw)(e[0]),(e,t,r)=>tD(ic(e,(e,r)=>rQ(t(e,r)),r),e=>p.jB(e,y.D_))),ir=(0,y.XY)(3,(e,t,r)=>{let n=p.Ts(e);return 0===n.length?ez(t):eW(()=>{let e=0,i=t();return tD(id({while:()=>e<n.length,body:()=>r(i,n[e],e),step(t){i=t,e++}}),()=>i)})}),ii=(0,y.XY)(e=>(0,b.xZ)(e[0])&&!(0,A.yw)(e[0]),(e,t,r)=>tA(it(e,t,{concurrency:r?.concurrency}),([e,t])=>p.CZ(t)?eL(t):r?.discard?e1:eF(e))),ia=(0,y.XY)(e=>(0,b.xZ)(e[0])&&!(0,A.yw)(e[0]),(e,t)=>eW(()=>{let r=e[Symbol.iterator](),n=r.next();return n.done?eF(v.none()):is(r,0,t,n.value)})),is=(e,t,r,n)=>tA(r(n,t),i=>{if(i)return eF(v.some(n));let a=e.next();return a.done?eF(v.none()):is(e,t+1,r,a.value)}),io=(0,y.XY)(e=>(0,b.xZ)(e[0])&&!(0,A.yw)(e[0]),(e,t)=>eW(()=>{let r=e[Symbol.iterator](),n=r.next();return n.done?eF(v.none()):il(r,0,t,n.value)})),il=(e,t,r,n)=>tA(r(n,t),n=>{if(_.oJ(n))return eF(v.some(n.success));let i=e.next();return i.done?eF(v.none()):il(e,t+1,r,i.value)}),id=(0,A.Uf)({op:"While",[A.ee](e,t){return(this[A.a2].step(e),this[A.a2].while())?(t._stack.push(this),this[A.a2].body()):t0},[A._3](e){return this[A.a2].while()?(e._stack.push(this),this[A.a2].body()):t0}}),ic=(0,y.XY)(e=>"function"==typeof e[1],(e,t,r)=>eW(()=>{let n=ih(r?.concurrency);if(1===n)return ip(e,t,r);let i=p.Ts(e),a=i.length;if(0===a)return r?.discard?e1:eF([]);let s=r?.discard?void 0:Array(a),o=iv({f:t,out:s},i,{concurrency:n});return o?tu(o,s):eF(s)})),iu=e=>tA(e,e=>{let t=e[Symbol.iterator]().next();return t.done?eL(new A.Xm):eF(t.value)}),ip=(e,t,r)=>eW(()=>{let n=r?.discard?void 0:[],i=e[Symbol.iterator](),a=i.next(),s=0;return tu(id({while:()=>!a.done,body:()=>t(a.value,s++),step:e=>{n&&n.push(e),a=i.next()}}),n)}),ih=e=>"unbounded"===e?1/0:Math.max(1,e??1),im=()=>e=>{let t=e.onItem,r=e.step,n=(e,t,n,a,s)=>tA(nt(s),s=>r(e,t[n],s,n)??i(e,t,n+1,a)??e1),i=(e,i,a=0,s=i.length)=>{for(;a<s;a++){let o=i[a],l=t(e,o,a);if(!tP(l))return n(e,i,a,s,l);let d=r(e,o,l,a);if(d)return"Failure"===d._tag?d:void 0}};return i},ig=e=>{let t=e.onItem,r=e.step;return(e,n,i)=>{let a,s,o,l,d,c=0,u=i.end??n.length,f=i.concurrency,p=!1,h=e=>{let t=(0,A.V2)(e);return l=t,p=!0,s&&s.size>0?tA(n0(eD(Array.from(s))),()=>l??t):t},m=()=>{let i=!1;for(;!l&&c<u;c++){let u=n[c],g=d??t(e,u,c);if(tP(g)){if(l=r(e,u,g,c))break}else{if(!a)return te(e=>{let t;a=ek(),s=new Set,d=g,o=e;try{t=m()}catch(t){return e(h(t))}return t?e(t):eW(()=>(l??=t0,tA(s?eD(s):e1,()=>l?._tag==="Failure"?l:e1)))});d=void 0;let t=iT(a,g,!0,!0,"inherit");if(t._exit){if(l=r(e,u,t._exit,c))break;continue}s.add(t);let n=c;if(t.addObserver(a=>{s.delete(t);try{if(l){if("Failure"===a._tag){let e=a.cause.reasons.filter(e=>"Interrupt"!==e._tag);if(e.length>0){let t=(0,A.b5)(e);l=(0,A.cb)("Failure"===l._tag?(0,A.h2)(l.cause,t):t)}}}else{let t=r(e,u,a,n);t&&(l=t,m())}if(i){let e=m();e&&o(e)}else p&&0===s.size&&o(l??e1)}catch(e){o(h(e))}}),s.size<f)continue;i=!0,c++;return}}if(p=!0,l){if(s&&s.size>0){let e=eC(a);s.forEach(t=>t.interruptUnsafe(a.id,e));return}if(o||"Failure"===l._tag)return l}else if(o)if(!s)return t0;else 0===s.size&&o(e1)};return m()}},iy=()=>e=>ig(e),iv=ig({onItem:(e,t,r)=>e.f(t,r),step(e,t,r,n){if("Failure"===r._tag)return r;e.out&&(e.out[n]=r.value)}}),ib=(0,y.XY)(3,(e,t,r)=>tA(e,e=>t(e)?eF(e):r(e))),i_=(0,y.XY)(3,(e,t,r)=>tA(e,e=>{let n=t(e);return _.N6(n)?r(n.failure):eF(n.success)})),ix=(0,y.XY)(e=>(0,A.yw)(e[0]),(e,t,r)=>i_(e,t,r?e=>eL(r(e)):()=>eL(new A.Xm))),iw=(0,y.XY)(e=>(0,b.xZ)(e[0])&&!(0,A.yw)(e[0]),(e,t,r)=>eW(()=>{let n=[];return tu(ic(e,(e,r)=>{let i=t(e,r);return"boolean"==typeof i?(i&&n.push(e),e1):tD(i,t=>{t&&n.push(e)})},{discard:!0,concurrency:r?.concurrency}),n)})),ik=(0,y.XY)(e=>(0,b.xZ)(e[0])&&!(0,A.yw)(e[0]),(e,t)=>eW(()=>{let r=[];for(let n of e){let e=t(n);_.oJ(e)&&r.push(e.success)}return eF(r)})),iS=(0,y.XY)(e=>(0,b.xZ)(e[0])&&!(0,A.yw)(e[0]),(e,t,r)=>eW(()=>{let n=[];return tu(ic(e,e=>tD(t(e),e=>{_.oJ(e)&&n.push(e.success)}),{discard:!0,concurrency:r?.concurrency}),n)})),iI=eF({}),i$=N.Jr(tD),iE=N.oI(tD,tA),iO=N.zM(tD),iC=(0,y.XY)(e=>(0,A.yw)(e[0]),(e,t)=>(0,A.R6)(r=>(eO.interruptChildren??=eT,eF(iT(r,e,t?.startImmediately,!1,t?.uninterruptible??!1))))),iT=(e,t,r=!1,n=!1,i=!1)=>{let a="inherit"===i?e.interruptible:!i,s=new eS(e.context,a);return r?s.evaluate(t):(s._asyncContext=ew(),e.currentDispatcher.scheduleTask(()=>s.evaluate(t),0)),n||s._exit||(e.children().add(s),s._parent=e),s},iM=(0,y.XY)(e=>(0,A.yw)(e[0]),(e,t)=>(0,A.R6)(r=>eF(iT(r,e,t?.startImmediately,!0,t?.uninterruptible)))),iA=e=>(0,A.R6)(t=>{let r=t._children&&new Set(t._children),n=t.interruptible;return nj(e,e=>{let i=t._children;if(void 0===i||0===i.size)return e1;r&&(i=I.pb(i,e=>!r.has(e)));let a=t$(eA(i));return n?n8(a):a})}),iN=(0,y.XY)(e=>(0,A.yw)(e[0]),(e,t,r)=>(0,A.R6)(n=>{let i=iT(n,e,r?.startImmediately,!0,r?.uninterruptible);if(!i._exit)if("Closed"!==t.state._tag){let e={};nw(t,e,()=>e6(e=>e===i.id?e1:eR(i))),i.addObserver(()=>nk(t,e))}else i.interruptUnsafe(n.id,eC(n));return eF(i)})),iP=(0,y.XY)(e=>(0,A.yw)(e[0]),(e,t)=>tA(nO,r=>iN(e,r,t))),iR=e=>(t,r)=>{let n=new eS(r?.scheduler?h.WQ(e,C._F,r.scheduler):e,r?.uninterruptible!==!0);if(n.evaluate(t),n._exit)return n;if(r?.signal)if(r.signal.aborted)n.interruptUnsafe();else{let e=()=>n.interruptUnsafe();r.signal.addEventListener("abort",e,{once:!0}),n.addObserver(()=>r.signal.removeEventListener("abort",e))}return r?.onFiberStart&&r.onFiberStart(n),n},ij=(0,y.XY)(2,(e,t)=>{if(e._exit)return e;if("Closed"===t.state._tag)return e.interruptUnsafe(e.id),e;let r={};return nw(t,r,()=>eR(e)),e.addObserver(()=>nk(t,r)),e}),iD=iR(h.Ie()),iU=e=>{let t=iR(e);return(e,r)=>{let n=t(e,r);return r?.onExit&&n.addObserver(r.onExit),e=>n.interruptUnsafe(e)}},iF=iU(h.Ie()),iB=e=>{let t=iR(e);return(e,r)=>{let n=t(e,r);return new Promise(e=>{n.addObserver(t=>e(t))})}},iL=iB(h.Ie()),iz=e=>{let t=iB(e);return(e,r)=>t(e,r).then(e=>{if("Failure"===e._tag)throw es(e.cause);return e.value})},iW=iz(h.Ie()),iJ=e=>{let t=iR(e);return e=>{if(tP(e))return e;let r=t(e,{scheduler:new C.FG("sync")});return r._dispatcher?.flush(),r._exit??(0,A.V2)(new aN(r))}},iY=iJ(h.Ie()),iX=e=>{let t=iJ(e);return e=>{let r=t(e);if("Failure"===r._tag)throw es(r.cause);return r.value}},iq=iX(h.Ie()),iG=eF(!0),iV=eF(!1);class iH{waiters=[];scheduled=void 0;_isOpen;constructor(e){this._isOpen=e}scheduleUnsafe(e){if(0===this.waiters.length)return iG;if(void 0===this.scheduled)this.scheduled=this.waiters,e.currentDispatcher.scheduleTask(this.flushScheduled,0);else for(let e=0;e<this.waiters.length;e++)this.scheduled.push(this.waiters[e]);return this.waiters=[],iG}flushScheduled=()=>{if(void 0===this.scheduled)return;let e=this.scheduled;this.scheduled=void 0;for(let t=0;t<e.length;t++)e[t](t0)};flushWaiters(){let e=this.waiters;this.waiters=[],this.flushScheduled();for(let t=0;t<e.length;t++)e[t](t0)}open=(0,A.R6)(e=>this._isOpen?iV:(this._isOpen=!0,this.scheduleUnsafe(e)));release=(0,A.R6)(e=>this._isOpen?iV:this.scheduleUnsafe(e));openUnsafe(){return!this._isOpen&&(this._isOpen=!0,this.flushWaiters(),!0)}await=te(e=>this._isOpen?e(e1):(this.waiters.push(e),ez(()=>{let t=this.waiters.indexOf(e);-1!==t?this.waiters.splice(t,1):void 0!==this.scheduled&&-1!==(t=this.scheduled.indexOf(e))&&this.scheduled.splice(t,1)})));closeUnsafe(){return!!this._isOpen&&(this._isOpen=!1,!0)}close=ez(()=>this.closeUnsafe());whenOpen=e=>tA(this.await,()=>e);isOpen(){return this._isOpen}}let iK=e=>new iH(e??!1),iQ=e=>ez(()=>iK(e)),iZ=(0,A.R6)(e=>eF(e.getRef(T.sh))),i0=(0,y.XY)(2,(e,t)=>rf(e,T.sh,t)),i1=rf(j.rf),i2=rf(j.nU),i5=BigInt(0),i3={_tag:"Span",spanId:"noop",traceId:"noop",sampled:!1,status:{_tag:"Ended",startTime:i5,endTime:i5,exit:t0},attributes:new Map,links:[],kind:"internal",attribute(){},event(){},end(){},addLinks(){}},i6=e=>e?h.Jt(e.annotations,T.DW)?"Span"===e._tag?i6(v.getOrUndefined(e.parent)):v.none():v.some(e):v.none(),i8=(e,t,r)=>{let n,i=!e.cache.tracerEnabled||r?.annotations&&h.Jt(r.annotations,T.DW),a=r?.parent!==void 0?v.some(r.parent):r?.root?v.none():i6(e.cache.span);if(i){let e;e={name:t,parent:a,annotations:h.WQ(r?.annotations??h.Ie(),T.DW,!0)},n=Object.assign(Object.create(i3),e)}else{let i=e.cache.tracer??T.Vv,s=e.getRef(af),o=e.getRef(j.nU),l=e.getRef(j.ce),d=e.getRef(j.ls),c=r?.level??e.getRef(T.pX),u=r?.links!==void 0?[...d,...r.links]:0===d.length?[]:d.slice();for(let d in n=i.span({name:t,parent:a,annotations:r?.annotations??h.Ie(),links:u,startTime:o?s.currentTimeNanosUnsafe():i5,kind:r?.kind??"internal",root:r?.root??v.isNone(a),sampled:r?.sampled??((!v.isSome(a)||!1!==a.value.sampled)&&!aF(e.getRef(T.EW),c))}),l)n.attribute(d,l[d]);if(r?.attributes!==void 0)for(let e in r.attributes)n.attribute(e,r.attributes[e])}return n},i9=(e,t)=>(0,A.R6)(r=>eF(i8(r,e,t))),i4=(e,t)=>n0((0,A.R6)(r=>{let n=h.fp(r.context,nf),i=i8(r,e,t??{}),a=r.getRef(af),s=r.getRef(j.nU);return tu(n_(n,e=>an(i,e,a,s)),i)})),i7=function(){let e="string"!=typeof arguments[0],t=e?arguments[1]:arguments[0],r=U(e?arguments[2]:arguments[1]);if(e){let e=arguments[0];return tA(i4(t,r),t=>as(e,t,r))}return e=>tA(i4(t,r),t=>as(e,t,r))},ae=j.ce,at=j.ls,ar=(0,y.XY)(e=>(0,A.yw)(e[0]),(e,t,r={})=>{let n=(Array.isArray(t)?t:[t]).map(e=>({span:e,attributes:r}));return ra(e,j.ls,e=>[...e,...n])}),an=(e,t,r,n)=>ez(()=>{"Ended"!==e.status._tag&&e.end(n?r.currentTimeNanosUnsafe():i5,t)}),ai=(e,...t)=>{let r=1===t.length?void 0:t[0],n=t[t.length-1];return(0,A.R6)(t=>{let i=i8(t,e,r),a=t.getRef(af),s=t.getRef(j.nU);return nD(t,e=>an(i,e,a,s)),n(i)})},aa=rf(T.Tv),as=function(){let e=(0,A.yw)(arguments[0]),t=e?arguments[1]:arguments[0],r=e?arguments[2]:arguments[1],n=y.D_;if("Span"===t._tag){var i,a;r=U(r),i=t.name,a="function"==typeof(a=r?.captureStackTrace)?a:y.MN,n=ra(j.vA,e=>({name:i,stack:a,parent:e}))}return e?aa(n(arguments[0]),t):e=>aa(n(e),t)},ao=function(){let e="string"!=typeof arguments[0],t=e?arguments[1]:arguments[0],r=U(arguments[2]);if(e){let e=arguments[0];return ai(t,arguments[2],t=>as(e,t,r))}let n="function"==typeof arguments[1]?arguments[1]:void 0,i=n?void 0:arguments[1];return(e,...a)=>ai(t,n?n(...a):i,t=>as(e,t,r))},al=(0,y.XY)(e=>(0,A.yw)(e[0]),(e,...t)=>ra(e,j.ce,e=>{let r=1===t.length?{...e,...t[0]}:{...e};return 1===t.length||R.x(r,t[0],t[1]),r})),ad=(...e)=>(0,A.R6)(t=>{let r=t.currentSpanLocal;if(r)if(1===e.length)for(let[t,n]of Object.entries(e[0]))r.attribute(t,n);else r.attribute(e[0],e[1]);return e1}),ac=(0,A.R6)(e=>{let t=e.currentSpanLocal;return t?eF(t):eL(new A.Xm)}),au=(c=T.Tv,(0,A.R6)(e=>eJ(h.om(e.context,c)))),af=h.Or("effect/Clock",{defaultValue:()=>new ap});class ap{currentTimeMillisUnsafe(){return Date.now()}currentTimeMillis=ez(()=>this.currentTimeMillisUnsafe());currentTimeNanosUnsafe(){return ag()}currentTimeNanos=ez(()=>this.currentTimeNanosUnsafe());monotonicTimeNanosUnsafe(){return am()}monotonicTimeNanos=ez(()=>this.monotonicTimeNanosUnsafe());sleep(e){return this.sleepMillis(m.kE(e))}sleepMillis(e){return e<=0?eG:Number.isFinite(e)?te(t=>{let r=e>0x7fffffff?this.sleepMillis(e-0x7fffffff):e1,n=setTimeout(()=>t(r),Math.min(e,0x7fffffff));return ez(()=>clearTimeout(n))}):tt}}let ah=BigInt(1e6),am=function(){let e=globalThis.process?.hrtime;if("function"==typeof e?.bigint)return()=>e.bigint();if("u">typeof performance&&"function"==typeof performance.now)return()=>BigInt(Math.round(1e6*performance.now()));let t=BigInt(0);return()=>{let e=BigInt(Date.now())*ah;return e>t&&(t=e),t}}(),ag=(f=BigInt(1e9),()=>{let e=am(),t=BigInt(Date.now())*ah;if(void 0===u)u=t-e;else{let r=u+e;(t>r?t-r:r-t)>f&&(u=t-e)}return u+e}),ay=e=>(0,A.R6)(t=>e(t.getRef(af))),av=e=>ay(t=>t.sleep(m.bN(e))),ab=ay(e=>e.currentTimeMillis),a_=ay(e=>e.currentTimeNanos),ax=ay(e=>e.monotonicTimeNanos),aw="~effect/Cause/TimeoutError",ak=e=>(0,b.i5)(e,aw);class aS extends(0,A.rN)("TimeoutError"){[aw]=aw;constructor(e){super({message:e})}}let aI="~effect/Cause/IllegalArgumentError",a$=e=>(0,b.i5)(e,aI);class aE extends(0,A.rN)("IllegalArgumentError"){[aI]=aI;constructor(e){super({message:e})}}let aO="~effect/Cause/ExceededCapacityError",aC=e=>(0,b.i5)(e,aO);class aT extends(0,A.rN)("ExceededCapacityError"){[aO]=aO;constructor(e){super({message:e})}}let aM="~effect/Cause/AsyncFiberError",aA=e=>(0,b.i5)(e,aM);class aN extends(0,A.rN)("AsyncFiberError"){[aM]=aM;constructor(e){super({message:"An asynchronous Effect was executed with Effect.runSync",fiber:e})}}let aP="~effect/Cause/UnknownError",aR=e=>(0,b.i5)(e,aP);class aj extends(0,A.rN)("UnknownError"){[aP]=aP;constructor(e,t){super({message:t,cause:e})}}let aD=h.Or("effect/Console",{defaultValue:()=>globalThis.console}),aU=$.zQ($.wN,e=>{switch(e){case"All":return Number.MIN_SAFE_INTEGER;case"Fatal":return 5e4;case"Error":return 4e4;case"Warn":return 3e4;case"Info":return 2e4;case"Debug":return 1e4;case"Trace":return 0;case"None":return Number.MAX_SAFE_INTEGER}}),aF=$.yJ(aU),aB=h.Or("effect/Logger/CurrentLoggers",{defaultValue:()=>new Set([aq,aG])}),aL=h.Or("effect/Logger/LogToStderr",{defaultValue:y.f4}),az=function(){let e="string"==typeof arguments[0]?[[arguments[0],arguments[1]]]:Object.entries(arguments[0]);return n0((0,A.R6)(t=>{let r=t.getRef(j.iL),n={...r};for(let t=0;t<e.length;t++){let[r,i]=e[t];R.x(n,r,i)}return t.setContext(h.WQ(t.context,j.iL,n)),n_(h.fp(t.context,nf),n=>{let i=t.getRef(j.iL),a={...i};for(let t=0;t<e.length;t++){let[n,s]=e[t];(i[n]===s||Object.is(i[n],s))&&(Object.hasOwn(r,n)?R.x(a,n,r[n]):delete a[n])}return t.setContext(h.WQ(t.context,j.iL,a)),e1})}))},aW={"~effect/Logger":{_Message:y.D_,_Output:y.D_},pipe(){return(0,E.tT)(this,arguments)}},aJ=e=>{let t=Object.create(aW);return t.log=e,t},aY=(e,t)=>{let r=e[0].replace(/[\s="]/g,"_");return`${r}=${t-e[1]}ms`},aX=e=>(...t)=>{let r;for(let e=0,n=t.length;e<n;e++){let n=t[e];(0,A.Aj)(n)&&(r?t.splice(e,1):t=t.slice(0,e).concat(t.slice(e+1)),r=r?(0,A.b5)(r.reasons.concat(n.reasons)):n,e--)}return void 0===r&&(r=A.DH),(0,A.R6)(n=>{let i=e??n.cache.logLevel;if(aF(n.cache.minimumLogLevel,i))return e1;let a=n.getRef(af),s=n.getRef(aB);if(s.size>0){let e=new Date(a.currentTimeMillisUnsafe());for(let a of s)a.log({cause:r,fiber:n,date:e,logLevel:i,message:t})}return e1})},aq=aJ(({cause:e,date:t,fiber:r,logLevel:n,message:i})=>{let a=Array.isArray(i)?i.slice():[i];e.reasons.length>0&&a.push(em(e));let s=t.getTime(),o=r.getRef(j.d8),l="";for(let e of o)l+=` ${aY(e,s)}`;let d=r.getRef(j.iL);Object.keys(d).length>0&&a.push(d);let c=r.getRef(aD);(r.getRef(aL)?c.error:c.log)(`[${t.getHours().toString().padStart(2,"0")}:${t.getMinutes().toString().padStart(2,"0")}:${t.getSeconds().toString().padStart(2,"0")}.${t.getMilliseconds().toString().padStart(3,"0")}] ${n.toUpperCase()} (#${r.id})${l}:`,...a)}),aG=aJ(({cause:e,fiber:t,logLevel:r,message:n})=>{let i=t.getRef(af),a=t.getRef(j.iL),s=t.cache.span;if(void 0===s||"ExternalSpan"===s._tag)return;let o={};for(let[e,t]of Object.entries(a))R.x(o,e,t);o["effect.fiberId"]=t.id,o["effect.logLevel"]=r.toUpperCase(),e.reasons.length>0&&(o["effect.cause"]=em(e)),s.event((0,S.ZK)(Array.isArray(n)&&1===n.length?n[0]:n),i.currentTimeNanosUnsafe(),o)}),aV=eF(void 0),aH=(0,y.XY)(e=>(0,A.yw)(e[0]),(e,t)=>nz(e,e=>(0,A.R6)(r=>(aK(r,e,t?.defectsOnly),e1)))),aK=(e,t,r)=>{let n=e.getRef(j.oQ);if(0===n.size||r&&!G(t))return;let i={cause:t,fiber:e,timestamp:e.getRef(af).currentTimeNanosUnsafe()};n.forEach(e=>e.report(i))}},5844(e,t,r){let n=new WeakSet;r.d(t,{},{J3:n,Xp:e=>{let t=new Set(Reflect.ownKeys(e));if(e.constructor===Object)return t;e instanceof Error&&t.delete("stack");let r=Object.getPrototypeOf(e),n=r;for(;null!==n&&n!==Object.prototype;){let e=Reflect.ownKeys(n);for(let r=0;r<e.length;r++)t.add(e[r]);n=Object.getPrototypeOf(n)}return t.has("constructor")&&"function"==typeof e.constructor&&r===e.constructor.prototype&&t.delete("constructor"),t},j:e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength)})},7258(e,t,r){r.d(t,{},{F:"effect/Metric/FiberRuntimeMetrics"})},7731(e,t,r){var n=r(3332),i=r(1958),a=r(5033),s=r(3952),o=r(4233),l=r(6481),d=r(2449);let c="~effect/Option",u={[c]:{_A:e=>e},...d.fU,[Symbol.iterator](){return new l.B(this)}},f=Object.defineProperty(Object.assign(Object.create(u),{_tag:"Some",_op:"Some",[n.HR](e){return m(e)&&y(e)&&n.aI(this.value,e.value)},[a.HR](){return a.kg(a.tW(this._tag))(a.tW(this.value))},toString(){return`some(${(0,i.GP)(this.value)})`},toJSON(){return{_id:"Option",_tag:this._tag,value:(0,s.aB)(this.value)}}}),"valueOrUndefined",{get(){return this.value}}),p=a.tW("None"),h=Object.assign(Object.create(u),{_tag:"None",_op:"None",valueOrUndefined:void 0,[n.HR]:e=>m(e)&&g(e),[a.HR]:()=>p,toString:()=>"none()",toJSON(){return{_id:"Option",_tag:this._tag}}}),m=e=>(0,o.i5)(e,c),g=e=>"None"===e._tag,y=e=>"Some"===e._tag,v=Object.create(h),b=function(e){this.value=e};b.prototype=f,r.d(t,{},{$I:g,Ru:y,dv:v,oL:m,zN:e=>new b(e)})},2275(e,t,r){function n(e,t,r){"__proto__"===t?Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0}):e[t]=r}function i(e,t){for(let r of Reflect.ownKeys(t))Object.prototype.propertyIsEnumerable.call(t,r)&&n(e,r,t[r])}r.d(t,{x:()=>n,z:()=>i})},6712(e,t,r){var n=r(1179),i=r(1594);let a=n.Or("effect/ErrorReporter/CurrentErrorReporters",{defaultValue:()=>new Set}),s=n.Or("effect/References/CurrentStackFrame",{fiberCached:!0,defaultValue:i.MN}),o=n.Or("effect/References/TracerEnabled",{fiberCached:!0,defaultValue:i.ue}),l=n.Or("effect/References/TracerTimingEnabled",{defaultValue:i.ue}),d=n.Or("effect/References/TracerSpanAnnotations",{defaultValue:()=>({})}),c=n.Or("effect/References/TracerSpanLinks",{defaultValue:()=>[]}),u=n.Or("effect/References/CurrentLogAnnotations",{defaultValue:()=>({})}),f=n.Or("effect/References/CurrentLogLevel",{fiberCached:!0,defaultValue:()=>"Info"}),p=n.Or("effect/References/MinimumLogLevel",{fiberCached:!0,defaultValue:()=>"Info"}),h=n.Or("effect/References/UnhandledLogLevel",{defaultValue:()=>"Error"}),m=n.Or("effect/References/CurrentLogSpans",{defaultValue:()=>[]});r.d(t,{},{Gl:f,aG:h,ce:d,d8:m,iL:u,ls:c,nU:l,oQ:a,rf:o,vA:s,zQ:p})},2563(e,t,r){var n=r(3332),i=r(1958),a=r(1594),s=r(5033),o=r(3952),l=r(4233),d=r(6481),c=r(2449),u=r(7731);let f="~effect/Result",p={[f]:{_A:e=>e,_E:e=>e},...c.fU,[Symbol.iterator](){return new d.B(this)}},h=Object.assign(Object.create(p),{_tag:"Success",_op:"Success",[n.HR](e){return g(e)&&v(e)&&n.aI(this.success,e.success)},[s.HR](){return s.kg(s.tW(this._tag))(s.tW(this.success))},toString(){return`success(${(0,i.GP)(this.success)})`},toJSON(){return{_id:"Result",_tag:this._tag,value:(0,o.aB)(this.success)}}}),m=Object.assign(Object.create(p),{_tag:"Failure",_op:"Failure",[n.HR](e){return g(e)&&y(e)&&n.aI(this.failure,e.failure)},[s.HR](){return s.kg(s.tW(this._tag))(s.tW(this.failure))},toString(){return`failure(${(0,i.GP)(this.failure)})`},toJSON(){return{_id:"Result",_tag:this._tag,failure:(0,o.aB)(this.failure)}}}),g=e=>(0,l.i5)(e,f),y=e=>"Failure"===e._tag,v=e=>"Success"===e._tag,b=function(e){this.failure=e};b.prototype=m;let _=e=>new b(e),x=function(e){this.success=e};x.prototype=h;let w=e=>new x(e),k=(0,a.XY)(2,(e,t)=>u.$I(e)?_(t()):w(e.value));r.d(t,{},{L8:e=>v(e)?u.dv:u.zN(e.failure),N6:y,Oz:e=>y(e)?u.dv:u.zN(e.success),Py:w,aI:g,fJ:_,oJ:v,sV:k})},2840(e,t,r){var n=r(1594);function i(e){return e.checks?e.checks[e.checks.length-1].annotations:e.annotations}function a(e){return t=>i(t)?.[e]}let s="~structural",o="~identifier",l="~sentinels",d=a("identifier"),c=a(o),u=a("title"),f=a("description"),p=(0,n.Bj)(e=>{let t=i(e)?.identifier;return"string"==typeof t?t:e.getExpected(p)}),h=new Set([l,s,"representation","arbitraryConstraint","toJsonSchema","toCode","toEquivalence","toFormatter","toCodec","toCodecJson","toCodecStringTree","toCodecIso","toCodecArbitrary"]);r.d(t,{hd:()=>i,ip:()=>a},{C3:s,CD:c,DQ:u,I_:l,KE:d,L1:["title","description","default","examples","readOnly","writeOnly","format","contentEncoding","contentMediaType","contentSchema"],Pk:f,R4:o,UI:h,bo:p,py:"~constructor"})},8253(e,t,r){var n=r(719),i=r(7086);function a(e){let t;for(let r of e.reasons){if(!n.lC(r)||!i.gh(r.error))return;t??=r.error}return t}function s(e,t){let r=a(e);if(void 0===r)throw Error(t,{cause:e});return r}r.d(t,{R:()=>a,q:()=>s})},587(e,t,r){var n=r(6526),i=r(1587);let a=Symbol(),s=n.Py,o=s(a),l=s(a);r.d(t,{},{LO:a,Py:s,Rr:l,e8:e=>"None"===e._tag?o:s(e.value),r2:o,zL:e=>e===a?i.none():i.some(e)})},5340(e,t,r){let n,i=void 0===(n=Object.getOwnPropertyDescriptor(Error,"stackTraceLimit"))?Object.isExtensible(Error):Object.hasOwn(n,"writable")?!0===n.writable:void 0!==n.set;r.d(t,{},{ft:e=>{i&&(Error.stackTraceLimit=e)},jt:()=>Error.stackTraceLimit})},8689(e,t,r){let n,i,a,s,o;function l(e){let t=e.length;for(;--t>=0;)e[t]=0}let d=573,c=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),u=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),f=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),p=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),h=Array(576);l(h);let m=Array(60);l(m);let g=Array(512);l(g);let y=Array(256);l(y);let v=Array(29);l(v);let b=Array(30);function _(e,t,r,n,i){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=e&&e.length}function x(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}l(b);let w=e=>e<256?g[e]:g[256+(e>>>7)],k=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},S=(e,t,r)=>{e.bi_valid>16-r?(e.bi_buf|=t<<e.bi_valid&65535,k(e,e.bi_buf),e.bi_buf=t>>16-e.bi_valid,e.bi_valid+=r-16):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=r)},I=(e,t,r)=>{S(e,r[2*t],r[2*t+1])},$=(e,t)=>{let r=0;do r|=1&e,e>>>=1,r<<=1;while(--t>0)return r>>>1},E=(e,t,r)=>{let n,i,a=Array(16),s=0;for(n=1;n<=15;n++)a[n]=s=s+r[n-1]<<1;for(i=0;i<=t;i++){let t=e[2*i+1];0!==t&&(e[2*i]=$(a[t]++,t))}},O=e=>{let t;for(t=0;t<286;t++)e.dyn_ltree[2*t]=0;for(t=0;t<30;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0},C=e=>{e.bi_valid>8?k(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},T=(e,t,r,n)=>{let i=2*t,a=2*r;return e[i]<e[a]||e[i]===e[a]&&n[t]<=n[r]},M=(e,t,r)=>{let n=e.heap[r],i=r<<1;for(;i<=e.heap_len&&(i<e.heap_len&&T(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!T(t,n,e.heap[i],e.depth));)e.heap[r]=e.heap[i],r=i,i<<=1;e.heap[r]=n},A=(e,t,r)=>{let n,i,a,s,o=0;if(0!==e.last_lit)do n=e.pending_buf[e.d_buf+2*o]<<8|e.pending_buf[e.d_buf+2*o+1],i=e.pending_buf[e.l_buf+o],o++,0===n?I(e,i,t):(I(e,(a=y[i])+256+1,t),0!==(s=c[a])&&S(e,i-=v[a],s),I(e,a=w(--n),r),0!==(s=u[a])&&S(e,n-=b[a],s));while(o<e.last_lit)I(e,256,t)},N=(e,t)=>{let r,n,i,a=t.dyn_tree,s=t.stat_desc.static_tree,o=t.stat_desc.has_stree,l=t.stat_desc.elems,c=-1;for(e.heap_len=0,e.heap_max=d,r=0;r<l;r++)0!==a[2*r]?(e.heap[++e.heap_len]=c=r,e.depth[r]=0):a[2*r+1]=0;for(;e.heap_len<2;)a[2*(i=e.heap[++e.heap_len]=c<2?++c:0)]=1,e.depth[i]=0,e.opt_len--,o&&(e.static_len-=s[2*i+1]);for(t.max_code=c,r=e.heap_len>>1;r>=1;r--)M(e,a,r);i=l;do r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],M(e,a,1),n=e.heap[1],e.heap[--e.heap_max]=r,e.heap[--e.heap_max]=n,a[2*i]=a[2*r]+a[2*n],e.depth[i]=(e.depth[r]>=e.depth[n]?e.depth[r]:e.depth[n])+1,a[2*r+1]=a[2*n+1]=i,e.heap[1]=i++,M(e,a,1);while(e.heap_len>=2)e.heap[--e.heap_max]=e.heap[1],((e,t)=>{let r,n,i,a,s,o,l=t.dyn_tree,c=t.max_code,u=t.stat_desc.static_tree,f=t.stat_desc.has_stree,p=t.stat_desc.extra_bits,h=t.stat_desc.extra_base,m=t.stat_desc.max_length,g=0;for(a=0;a<=15;a++)e.bl_count[a]=0;for(l[2*e.heap[e.heap_max]+1]=0,r=e.heap_max+1;r<d;r++)(a=l[2*l[2*(n=e.heap[r])+1]+1]+1)>m&&(a=m,g++),l[2*n+1]=a,!(n>c)&&(e.bl_count[a]++,s=0,n>=h&&(s=p[n-h]),o=l[2*n],e.opt_len+=o*(a+s),f&&(e.static_len+=o*(u[2*n+1]+s)));if(0!==g){do{for(a=m-1;0===e.bl_count[a];)a--;e.bl_count[a]--,e.bl_count[a+1]+=2,e.bl_count[m]--,g-=2}while(g>0)for(a=m;0!==a;a--)for(n=e.bl_count[a];0!==n;)!((i=e.heap[--r])>c)&&(l[2*i+1]!==a&&(e.opt_len+=(a-l[2*i+1])*l[2*i],l[2*i+1]=a),n--)}})(e,t),E(a,c,e.bl_count)},P=(e,t,r)=>{let n,i,a=-1,s=t[1],o=0,l=7,d=4;for(0===s&&(l=138,d=3),t[(r+1)*2+1]=65535,n=0;n<=r;n++)i=s,s=t[(n+1)*2+1],++o<l&&i===s||(o<d?e.bl_tree[2*i]+=o:0!==i?(i!==a&&e.bl_tree[2*i]++,e.bl_tree[32]++):o<=10?e.bl_tree[34]++:e.bl_tree[36]++,o=0,a=i,0===s?(l=138,d=3):i===s?(l=6,d=3):(l=7,d=4))},R=(e,t,r)=>{let n,i,a=-1,s=t[1],o=0,l=7,d=4;for(0===s&&(l=138,d=3),n=0;n<=r;n++)if(i=s,s=t[(n+1)*2+1],!(++o<l)||i!==s){if(o<d)do I(e,i,e.bl_tree);while(0!=--o)else 0!==i?(i!==a&&(I(e,i,e.bl_tree),o--),I(e,16,e.bl_tree),S(e,o-3,2)):o<=10?(I(e,17,e.bl_tree),S(e,o-3,3)):(I(e,18,e.bl_tree),S(e,o-11,7));o=0,a=i,0===s?(l=138,d=3):i===s?(l=6,d=3):(l=7,d=4)}},j=!1,D=(e,t,r,n)=>{S(e,0+ +!!n,3),C(e),k(e,r),k(e,~r),e.pending_buf.set(e.window.subarray(t,t+r),e.pending),e.pending+=r};var U={_tr_init:e=>{j||((()=>{let e,t,r,s,o,l=Array(16);for(s=0,r=0;s<28;s++)for(v[s]=r,e=0;e<1<<c[s];e++)y[r++]=s;for(y[r-1]=s,o=0,s=0;s<16;s++)for(b[s]=o,e=0;e<1<<u[s];e++)g[o++]=s;for(o>>=7;s<30;s++)for(b[s]=o<<7,e=0;e<1<<u[s]-7;e++)g[256+o++]=s;for(t=0;t<=15;t++)l[t]=0;for(e=0;e<=143;)h[2*e+1]=8,e++,l[8]++;for(;e<=255;)h[2*e+1]=9,e++,l[9]++;for(;e<=279;)h[2*e+1]=7,e++,l[7]++;for(;e<=287;)h[2*e+1]=8,e++,l[8]++;for(E(h,287,l),e=0;e<30;e++)m[2*e+1]=5,m[2*e]=$(e,5);n=new _(h,c,257,286,15),i=new _(m,u,0,30,15),a=new _([],f,0,19,7)})(),j=!0),e.l_desc=new x(e.dyn_ltree,n),e.d_desc=new x(e.dyn_dtree,i),e.bl_desc=new x(e.bl_tree,a),e.bi_buf=0,e.bi_valid=0,O(e)},_tr_stored_block:D,_tr_flush_block:(e,t,r,n)=>{let i,a,s=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=(e=>{let t,r=0xf3ffc07f;for(t=0;t<=31;t++,r>>>=1)if(1&r&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<256;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0})(e)),N(e,e.l_desc),N(e,e.d_desc),s=(e=>{let t;for(P(e,e.dyn_ltree,e.l_desc.max_code),P(e,e.dyn_dtree,e.d_desc.max_code),N(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*p[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),i=e.opt_len+3+7>>>3,(a=e.static_len+3+7>>>3)<=i&&(i=a)):i=a=r+5,r+4<=i&&-1!==t?D(e,t,r,n):4===e.strategy||a===i?(S(e,2+ +!!n,3),A(e,h,m)):(S(e,4+ +!!n,3),((e,t,r,n)=>{let i;for(S(e,t-257,5),S(e,r-1,5),S(e,n-4,4),i=0;i<n;i++)S(e,e.bl_tree[2*p[i]+1],3);R(e,e.dyn_ltree,t-1),R(e,e.dyn_dtree,r-1)})(e,e.l_desc.max_code+1,e.d_desc.max_code+1,s+1),A(e,e.dyn_ltree,e.dyn_dtree)),O(e),n&&C(e)},_tr_tally:(e,t,r)=>(e.pending_buf[e.d_buf+2*e.last_lit]=t>>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&r,e.last_lit++,0===t?e.dyn_ltree[2*r]++:(e.matches++,t--,e.dyn_ltree[(y[r]+256+1)*2]++,e.dyn_dtree[2*w(t)]++),e.last_lit===e.lit_bufsize-1),_tr_align:e=>{S(e,2,3),I(e,256,h),16===e.bi_valid?(k(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}},F=(e,t,r,n)=>{let i=65535&e,a=e>>>16&65535,s=0;for(;0!==r;){s=r>2e3?2e3:r,r-=s;do a=a+(i=i+t[n++]|0)|0;while(--s)i%=65521,a%=65521}return i|a<<16};let B=new Uint32Array((()=>{let e,t=[];for(var r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=1&e?0xedb88320^e>>>1:e>>>1;t[r]=e}return t})());var L=(e,t,r,n)=>{let i=n+r;e^=-1;for(let r=n;r<i;r++)e=e>>>8^B[(e^t[r])&255];return -1^e},z={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},W={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};let{_tr_init:J,_tr_stored_block:Y,_tr_flush_block:X,_tr_tally:q,_tr_align:G}=U,{Z_NO_FLUSH:V,Z_PARTIAL_FLUSH:H,Z_FULL_FLUSH:K,Z_FINISH:Q,Z_BLOCK:Z,Z_OK:ee,Z_STREAM_END:et,Z_STREAM_ERROR:er,Z_DATA_ERROR:en,Z_BUF_ERROR:ei,Z_DEFAULT_COMPRESSION:ea,Z_FILTERED:es,Z_HUFFMAN_ONLY:eo,Z_RLE:el,Z_FIXED:ed,Z_DEFAULT_STRATEGY:ec,Z_UNKNOWN:eu,Z_DEFLATED:ef}=W,ep=573,eh=(e,t)=>(e.msg=z[t],t),em=e=>(e<<1)-9*(e>4),eg=e=>{let t=e.length;for(;--t>=0;)e[t]=0},ey=(e,t,r)=>(t<<e.hash_shift^r)&e.hash_mask,ev=e=>{let t=e.state,r=t.pending;r>e.avail_out&&(r=e.avail_out),0!==r&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+r),e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,0===t.pending&&(t.pending_out=0))},eb=(e,t)=>{X(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,ev(e.strm)},e_=(e,t)=>{e.pending_buf[e.pending++]=t},ex=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},ew=(e,t,r,n)=>{let i=e.avail_in;return(i>n&&(i=n),0===i)?0:(e.avail_in-=i,t.set(e.input.subarray(e.next_in,e.next_in+i),r),1===e.state.wrap?e.adler=F(e.adler,t,i,r):2===e.state.wrap&&(e.adler=L(e.adler,t,i,r)),e.next_in+=i,e.total_in+=i,i)},ek=(e,t)=>{let r,n,i=e.max_chain_length,a=e.strstart,s=e.prev_length,o=e.nice_match,l=e.strstart>e.w_size-262?e.strstart-(e.w_size-262):0,d=e.window,c=e.w_mask,u=e.prev,f=e.strstart+258,p=d[a+s-1],h=d[a+s];e.prev_length>=e.good_match&&(i>>=2),o>e.lookahead&&(o=e.lookahead);do{if(d[(r=t)+s]!==h||d[r+s-1]!==p||d[r]!==d[a]||d[++r]!==d[a+1])continue;a+=2,r++;do;while(d[++a]===d[++r]&&d[++a]===d[++r]&&d[++a]===d[++r]&&d[++a]===d[++r]&&d[++a]===d[++r]&&d[++a]===d[++r]&&d[++a]===d[++r]&&d[++a]===d[++r]&&a<f)if(n=258-(f-a),a=f-258,n>s){if(e.match_start=t,s=n,n>=o)break;p=d[a+s-1],h=d[a+s]}}while((t=u[t&c])>l&&0!=--i)return s<=e.lookahead?s:e.lookahead},eS=e=>{let t,r,n,i,a,s=e.w_size;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=s+(s-262)){e.window.set(e.window.subarray(s,s+s),0),e.match_start-=s,e.strstart-=s,e.block_start-=s,t=r=e.hash_size;do n=e.head[--t],e.head[t]=n>=s?n-s:0;while(--r)t=r=s;do n=e.prev[--t],e.prev[t]=n>=s?n-s:0;while(--r)i+=s}if(0===e.strm.avail_in)break;if(r=ew(e.strm,e.window,e.strstart+e.lookahead,i),e.lookahead+=r,e.lookahead+e.insert>=3)for(a=e.strstart-e.insert,e.ins_h=e.window[a],e.ins_h=ey(e,e.ins_h,e.window[a+1]);e.insert&&(e.ins_h=ey(e,e.ins_h,e.window[a+3-1]),e.prev[a&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=a,a++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead<262&&0!==e.strm.avail_in)},eI=(e,t)=>{let r,n;for(;;){if(e.lookahead<262){if(eS(e),e.lookahead<262&&t===V)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=ey(e,e.ins_h,e.window[e.strstart+3-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==r&&e.strstart-r<=e.w_size-262&&(e.match_length=ek(e,r)),e.match_length>=3)if(n=q(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do e.strstart++,e.ins_h=ey(e,e.ins_h,e.window[e.strstart+3-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart;while(0!=--e.match_length)e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=ey(e,e.ins_h,e.window[e.strstart+1]);else n=q(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(eb(e,!1),0===e.strm.avail_out))return 1}return(e.insert=e.strstart<2?e.strstart:2,t===Q)?(eb(e,!0),0===e.strm.avail_out)?3:4:e.last_lit&&(eb(e,!1),0===e.strm.avail_out)?1:2},e$=(e,t)=>{let r,n,i;for(;;){if(e.lookahead<262){if(eS(e),e.lookahead<262&&t===V)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=ey(e,e.ins_h,e.window[e.strstart+3-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==r&&e.prev_length<e.max_lazy_match&&e.strstart-r<=e.w_size-262&&(e.match_length=ek(e,r),e.match_length<=5&&(e.strategy===es||3===e.match_length&&e.strstart-e.match_start>4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-3,n=q(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=i&&(e.ins_h=ey(e,e.ins_h,e.window[e.strstart+3-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart);while(0!=--e.prev_length)if(e.match_available=0,e.match_length=2,e.strstart++,n&&(eb(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if((n=q(e,0,e.window[e.strstart-1]))&&eb(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return(e.match_available&&(n=q(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===Q)?(eb(e,!0),0===e.strm.avail_out)?3:4:e.last_lit&&(eb(e,!1),0===e.strm.avail_out)?1:2};function eE(e,t,r,n,i){this.good_length=e,this.max_lazy=t,this.nice_length=r,this.max_chain=n,this.func=i}let eO=[new eE(0,0,0,0,(e,t)=>{let r=65535;for(65535>e.pending_buf_size-5&&(r=e.pending_buf_size-5);;){if(e.lookahead<=1){if(eS(e),0===e.lookahead&&t===V)return 1;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;let n=e.block_start+r;if((0===e.strstart||e.strstart>=n)&&(e.lookahead=e.strstart-n,e.strstart=n,eb(e,!1),0===e.strm.avail_out)||e.strstart-e.block_start>=e.w_size-262&&(eb(e,!1),0===e.strm.avail_out))return 1}return(e.insert=0,t===Q)?(eb(e,!0),0===e.strm.avail_out)?3:4:(e.strstart>e.block_start&&(eb(e,!1),e.strm.avail_out),1)}),new eE(4,4,8,4,eI),new eE(4,5,16,8,eI),new eE(4,6,32,32,eI),new eE(4,4,16,16,e$),new eE(8,16,32,32,e$),new eE(8,16,128,128,e$),new eE(8,32,128,256,e$),new eE(32,128,258,1024,e$),new eE(32,258,258,4096,e$)];function eC(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=ef,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(2*ep),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),eg(this.dyn_ltree),eg(this.dyn_dtree),eg(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),eg(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),eg(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}var eT=(e,t)=>{let r,n;if(!e||!e.state||t>Z||t<0)return e?eh(e,er):er;let i=e.state;if(!e.output||!e.input&&0!==e.avail_in||666===i.status&&t!==Q)return eh(e,0===e.avail_out?ei:er);i.strm=e;let a=i.last_flush;if(i.last_flush=t,42===i.status)if(2===i.wrap)e.adler=0,e_(i,31),e_(i,139),e_(i,8),i.gzhead?(e_(i,+!!i.gzhead.text+2*!!i.gzhead.hcrc+4*!!i.gzhead.extra+8*!!i.gzhead.name+16*!!i.gzhead.comment),e_(i,255&i.gzhead.time),e_(i,i.gzhead.time>>8&255),e_(i,i.gzhead.time>>16&255),e_(i,i.gzhead.time>>24&255),e_(i,9===i.level?2:4*(i.strategy>=eo||i.level<2)),e_(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(e_(i,255&i.gzhead.extra.length),e_(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=L(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(e_(i,0),e_(i,0),e_(i,0),e_(i,0),e_(i,0),e_(i,9===i.level?2:4*(i.strategy>=eo||i.level<2)),e_(i,3),i.status=113);else{let t=ef+(i.w_bits-8<<4)<<8;t|=(i.strategy>=eo||i.level<2?0:i.level<6?1:6===i.level?2:3)<<6,0!==i.strstart&&(t|=32),t+=31-t%31,i.status=113,ex(i,t),0!==i.strstart&&(ex(i,e.adler>>>16),ex(i,65535&e.adler)),e.adler=1}if(69===i.status)if(i.gzhead.extra){for(r=i.pending;i.gzindex<(65535&i.gzhead.extra.length)&&(i.pending!==i.pending_buf_size||(i.gzhead.hcrc&&i.pending>r&&(e.adler=L(e.adler,i.pending_buf,i.pending-r,r)),ev(e),r=i.pending,i.pending!==i.pending_buf_size));)e_(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>r&&(e.adler=L(e.adler,i.pending_buf,i.pending-r,r)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=73)}else i.status=73;if(73===i.status)if(i.gzhead.name){r=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>r&&(e.adler=L(e.adler,i.pending_buf,i.pending-r,r)),ev(e),r=i.pending,i.pending===i.pending_buf_size)){n=1;break}n=i.gzindex<i.gzhead.name.length?255&i.gzhead.name.charCodeAt(i.gzindex++):0,e_(i,n)}while(0!==n)i.gzhead.hcrc&&i.pending>r&&(e.adler=L(e.adler,i.pending_buf,i.pending-r,r)),0===n&&(i.gzindex=0,i.status=91)}else i.status=91;if(91===i.status)if(i.gzhead.comment){r=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>r&&(e.adler=L(e.adler,i.pending_buf,i.pending-r,r)),ev(e),r=i.pending,i.pending===i.pending_buf_size)){n=1;break}n=i.gzindex<i.gzhead.comment.length?255&i.gzhead.comment.charCodeAt(i.gzindex++):0,e_(i,n)}while(0!==n)i.gzhead.hcrc&&i.pending>r&&(e.adler=L(e.adler,i.pending_buf,i.pending-r,r)),0===n&&(i.status=103)}else i.status=103;if(103===i.status&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&ev(e),i.pending+2<=i.pending_buf_size&&(e_(i,255&e.adler),e_(i,e.adler>>8&255),e.adler=0,i.status=113)):i.status=113),0!==i.pending){if(ev(e),0===e.avail_out)return i.last_flush=-1,ee}else if(0===e.avail_in&&em(t)<=em(a)&&t!==Q)return eh(e,ei);if(666===i.status&&0!==e.avail_in)return eh(e,ei);if(0!==e.avail_in||0!==i.lookahead||t!==V&&666!==i.status){let r=i.strategy===eo?((e,t)=>{let r;for(;;){if(0===e.lookahead&&(eS(e),0===e.lookahead)){if(t===V)return 1;break}if(e.match_length=0,r=q(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(eb(e,!1),0===e.strm.avail_out))return 1}return(e.insert=0,t===Q)?(eb(e,!0),0===e.strm.avail_out)?3:4:e.last_lit&&(eb(e,!1),0===e.strm.avail_out)?1:2})(i,t):i.strategy===el?((e,t)=>{let r,n,i,a,s=e.window;for(;;){if(e.lookahead<=258){if(eS(e),e.lookahead<=258&&t===V)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(n=s[i=e.strstart-1])===s[++i]&&n===s[++i]&&n===s[++i]){a=e.strstart+258;do;while(n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&i<a)e.match_length=258-(a-i),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(r=q(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=q(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(eb(e,!1),0===e.strm.avail_out))return 1}return(e.insert=0,t===Q)?(eb(e,!0),0===e.strm.avail_out)?3:4:e.last_lit&&(eb(e,!1),0===e.strm.avail_out)?1:2})(i,t):eO[i.level].func(i,t);if((3===r||4===r)&&(i.status=666),1===r||3===r)return 0===e.avail_out&&(i.last_flush=-1),ee;if(2===r&&(t===H?G(i):t!==Z&&(Y(i,0,0,!1),t===K&&(eg(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),ev(e),0===e.avail_out))return i.last_flush=-1,ee}return t!==Q?ee:i.wrap<=0?et:(2===i.wrap?(e_(i,255&e.adler),e_(i,e.adler>>8&255),e_(i,e.adler>>16&255),e_(i,e.adler>>24&255),e_(i,255&e.total_in),e_(i,e.total_in>>8&255),e_(i,e.total_in>>16&255),e_(i,e.total_in>>24&255)):(ex(i,e.adler>>>16),ex(i,65535&e.adler)),ev(e),i.wrap>0&&(i.wrap=-i.wrap),0!==i.pending?ee:et)},eM=e=>{if(!e||!e.state)return er;let t=e.state.status;return 42!==t&&69!==t&&73!==t&&91!==t&&103!==t&&113!==t&&666!==t?eh(e,er):(e.state=null,113===t?eh(e,en):ee)};let eA=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var eN=function(e){let t=Array.prototype.slice.call(arguments,1);for(;t.length;){let r=t.shift();if(r){if("object"!=typeof r)throw TypeError(r+"must be non-object");for(let t in r)eA(r,t)&&(e[t]=r[t])}}return e},eP=e=>{let t=0;for(let r=0,n=e.length;r<n;r++)t+=e[r].length;let r=new Uint8Array(t);for(let t=0,n=0,i=e.length;t<i;t++){let i=e[t];r.set(i,n),n+=i.length}return r};let eR=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){eR=!1}let ej=new Uint8Array(256);for(let e=0;e<256;e++)ej[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;ej[254]=ej[254]=1;var eD=e=>{let t,r,n,i,a,s=e.length,o=0;for(i=0;i<s;i++)(64512&(r=e.charCodeAt(i)))==55296&&i+1<s&&(64512&(n=e.charCodeAt(i+1)))==56320&&(r=65536+(r-55296<<10)+(n-56320),i++),o+=r<128?1:r<2048?2:r<65536?3:4;for(t=new Uint8Array(o),a=0,i=0;a<o;i++)(64512&(r=e.charCodeAt(i)))==55296&&i+1<s&&(64512&(n=e.charCodeAt(i+1)))==56320&&(r=65536+(r-55296<<10)+(n-56320),i++),r<128?t[a++]=r:(r<2048?t[a++]=192|r>>>6:(r<65536?t[a++]=224|r>>>12:(t[a++]=240|r>>>18,t[a++]=128|r>>>12&63),t[a++]=128|r>>>6&63),t[a++]=128|63&r);return t},eU=(e,t)=>{let r,n,i=t||e.length,a=Array(2*i);for(n=0,r=0;r<i;){let t=e[r++];if(t<128){a[n++]=t;continue}let s=ej[t];if(s>4){a[n++]=65533,r+=s-1;continue}for(t&=2===s?31:3===s?15:7;s>1&&r<i;)t=t<<6|63&e[r++],s--;if(s>1){a[n++]=65533;continue}t<65536?a[n++]=t:(t-=65536,a[n++]=55296|t>>10&1023,a[n++]=56320|1023&t)}var s=n;if(s<65534&&a.subarray&&eR)return String.fromCharCode.apply(null,a.length===s?a:a.subarray(0,s));let o="";for(let e=0;e<s;e++)o+=String.fromCharCode(a[e]);return o},eF=(e,t)=>{(t=t||e.length)>e.length&&(t=e.length);let r=t-1;for(;r>=0&&(192&e[r])==128;)r--;return r<0||0===r?t:r+ej[e[r]]>t?r:t},eB=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};let eL=Object.prototype.toString,{Z_NO_FLUSH:ez,Z_SYNC_FLUSH:eW,Z_FULL_FLUSH:eJ,Z_FINISH:eY,Z_OK:eX,Z_STREAM_END:eq,Z_DEFAULT_COMPRESSION:eG,Z_DEFAULT_STRATEGY:eV,Z_DEFLATED:eH}=W;function eK(e){let t,r;this.options=eN({level:eG,method:eH,chunkSize:16384,windowBits:15,memLevel:8,strategy:eV},e||{});let n=this.options;n.raw&&n.windowBits>0?n.windowBits=-n.windowBits:n.gzip&&n.windowBits>0&&n.windowBits<16&&(n.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new eB,this.strm.avail_out=0;let i=((e,t,r,n,i,a)=>{var s,o;let l;if(!e)return er;let d=1;if(t===ea&&(t=6),n<0?(d=0,n=-n):n>15&&(d=2,n-=16),i<1||i>9||r!==ef||n<8||n>15||t<0||t>9||a<0||a>ed)return eh(e,er);8===n&&(n=9);let c=new eC;return e.state=c,c.strm=e,c.wrap=d,c.gzhead=null,c.w_bits=n,c.w_size=1<<c.w_bits,c.w_mask=c.w_size-1,c.hash_bits=i+7,c.hash_size=1<<c.hash_bits,c.hash_mask=c.hash_size-1,c.hash_shift=~~((c.hash_bits+3-1)/3),c.window=new Uint8Array(2*c.w_size),c.head=new Uint16Array(c.hash_size),c.prev=new Uint16Array(c.w_size),c.lit_bufsize=1<<i+6,c.pending_buf_size=4*c.lit_bufsize,c.pending_buf=new Uint8Array(c.pending_buf_size),c.d_buf=+c.lit_bufsize,c.l_buf=3*c.lit_bufsize,c.level=t,c.strategy=a,c.method=r,(l=(e=>{if(!e||!e.state)return eh(e,er);e.total_in=e.total_out=0,e.data_type=eu;let t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?42:113,e.adler=+(2!==t.wrap),t.last_flush=V,J(t),ee})(s=e))===ee&&((o=s.state).window_size=2*o.w_size,eg(o.head),o.max_lazy_match=eO[o.level].max_lazy,o.good_match=eO[o.level].good_length,o.nice_match=eO[o.level].nice_length,o.max_chain_length=eO[o.level].max_chain,o.strstart=0,o.block_start=0,o.lookahead=0,o.insert=0,o.match_length=o.prev_length=2,o.match_available=0,o.ins_h=0),l})(this.strm,n.level,n.method,n.windowBits,n.memLevel,n.strategy);if(i!==eX)throw Error(z[i]);if(n.header&&(t=this.strm,r=n.header,t&&t.state&&2===t.state.wrap&&(t.state.gzhead=r)),n.dictionary){let e;if(e="string"==typeof n.dictionary?eD(n.dictionary):"[object ArrayBuffer]"===eL.call(n.dictionary)?new Uint8Array(n.dictionary):n.dictionary,(i=((e,t)=>{let r=t.length;if(!e||!e.state)return er;let n=e.state,i=n.wrap;if(2===i||1===i&&42!==n.status||n.lookahead)return er;if(1===i&&(e.adler=F(e.adler,t,r,0)),n.wrap=0,r>=n.w_size){0===i&&(eg(n.head),n.strstart=0,n.block_start=0,n.insert=0);let e=new Uint8Array(n.w_size);e.set(t.subarray(r-n.w_size,r),0),t=e,r=n.w_size}let a=e.avail_in,s=e.next_in,o=e.input;for(e.avail_in=r,e.next_in=0,e.input=t,eS(n);n.lookahead>=3;){let e=n.strstart,t=n.lookahead-2;do n.ins_h=ey(n,n.ins_h,n.window[e+3-1]),n.prev[e&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=e,e++;while(--t)n.strstart=e,n.lookahead=2,eS(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=2,n.match_available=0,e.next_in=s,e.input=o,e.avail_in=a,n.wrap=i,ee})(this.strm,e))!==eX)throw Error(z[i]);this._dict_set=!0}}function eQ(e,t){let r=new eK(t);if(r.push(e,!0),r.err)throw r.msg||z[r.err];return r.result}eK.prototype.push=function(e,t){let r,n,i=this.strm,a=this.options.chunkSize;if(this.ended)return!1;for(n=t===~~t?t:!0===t?eY:ez,"string"==typeof e?i.input=eD(e):"[object ArrayBuffer]"===eL.call(e)?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;;){if(0===i.avail_out&&(i.output=new Uint8Array(a),i.next_out=0,i.avail_out=a),(n===eW||n===eJ)&&i.avail_out<=6){this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;continue}if((r=eT(i,n))===eq)return i.next_out>0&&this.onData(i.output.subarray(0,i.next_out)),r=eM(this.strm),this.onEnd(r),this.ended=!0,r===eX;if(0===i.avail_out){this.onData(i.output);continue}if(n>0&&i.next_out>0){this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;continue}if(0===i.avail_in)break}return!0},eK.prototype.onData=function(e){this.chunks.push(e)},eK.prototype.onEnd=function(e){e===eX&&(this.result=eP(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var eZ=function(e,t){let r,n,i,a,s,o,l,d,c,u,f,p,h,m,g,y,v,b,_,x,w,k,S,I,$=e.state;r=e.next_in,S=e.input,n=r+(e.avail_in-5),i=e.next_out,I=e.output,a=i-(t-e.avail_out),s=i+(e.avail_out-257),o=$.dmax,l=$.wsize,d=$.whave,c=$.wnext,u=$.window,f=$.hold,p=$.bits,h=$.lencode,m=$.distcode,g=(1<<$.lenbits)-1,y=(1<<$.distbits)-1;t:do for(p<15&&(f+=S[r++]<<p,p+=8,f+=S[r++]<<p,p+=8),v=h[f&g];;){if(f>>>=b=v>>>24,p-=b,0==(b=v>>>16&255))I[i++]=65535&v;else if(16&b)for(_=65535&v,(b&=15)&&(p<b&&(f+=S[r++]<<p,p+=8),_+=f&(1<<b)-1,f>>>=b,p-=b),p<15&&(f+=S[r++]<<p,p+=8,f+=S[r++]<<p,p+=8),v=m[f&y];;){if(f>>>=b=v>>>24,p-=b,16&(b=v>>>16&255)){if(x=65535&v,p<(b&=15)&&(f+=S[r++]<<p,(p+=8)<b&&(f+=S[r++]<<p,p+=8)),(x+=f&(1<<b)-1)>o){e.msg="invalid distance too far back",$.mode=30;break t}if(f>>>=b,p-=b,x>(b=i-a)){if((b=x-b)>d&&$.sane){e.msg="invalid distance too far back",$.mode=30;break t}if(w=0,k=u,0===c){if(w+=l-b,b<_){_-=b;do I[i++]=u[w++];while(--b)w=i-x,k=I}}else if(c<b){if(w+=l+c-b,(b-=c)<_){_-=b;do I[i++]=u[w++];while(--b)if(w=0,c<_){_-=b=c;do I[i++]=u[w++];while(--b)w=i-x,k=I}}}else if(w+=c-b,b<_){_-=b;do I[i++]=u[w++];while(--b)w=i-x,k=I}for(;_>2;)I[i++]=k[w++],I[i++]=k[w++],I[i++]=k[w++],_-=3;_&&(I[i++]=k[w++],_>1&&(I[i++]=k[w++]))}else{w=i-x;do I[i++]=I[w++],I[i++]=I[w++],I[i++]=I[w++],_-=3;while(_>2)_&&(I[i++]=I[w++],_>1&&(I[i++]=I[w++]))}}else if((64&b)==0){v=m[(65535&v)+(f&(1<<b)-1)];continue}else{e.msg="invalid distance code",$.mode=30;break t}break}else if((64&b)==0){v=h[(65535&v)+(f&(1<<b)-1)];continue}else if(32&b){$.mode=12;break t}else{e.msg="invalid literal/length code",$.mode=30;break t}break}while(r<n&&i<s)r-=_=p>>3,p-=_<<3,f&=(1<<p)-1,e.next_in=r,e.next_out=i,e.avail_in=r<n?5+(n-r):5-(r-n),e.avail_out=i<s?257+(s-i):257-(i-s),$.hold=f,$.bits=p};let e0=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),e1=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),e2=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),e5=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var e3=(e,t,r,n,i,a,s,o)=>{let l,d,c,u,f,p,h,m,g,y=o.bits,v=0,b=0,_=0,x=0,w=0,k=0,S=0,I=0,$=0,E=0,O=null,C=0,T=new Uint16Array(16),M=new Uint16Array(16),A=null,N=0;for(v=0;v<=15;v++)T[v]=0;for(b=0;b<n;b++)T[t[r+b]]++;for(w=y,x=15;x>=1&&0===T[x];x--);if(w>x&&(w=x),0===x)return i[a++]=0x1400000,i[a++]=0x1400000,o.bits=1,0;for(_=1;_<x&&0===T[_];_++);for(w<_&&(w=_),I=1,v=1;v<=15;v++)if(I<<=1,(I-=T[v])<0)return -1;if(I>0&&(0===e||1!==x))return -1;for(M[1]=0,v=1;v<15;v++)M[v+1]=M[v]+T[v];for(b=0;b<n;b++)0!==t[r+b]&&(s[M[t[r+b]]++]=b);if(0===e?(O=A=s,p=19):1===e?(O=e0,C-=257,A=e1,N-=257,p=256):(O=e2,A=e5,p=-1),E=0,b=0,v=_,f=a,k=w,S=0,c=-1,u=($=1<<w)-1,1===e&&$>852||2===e&&$>592)return 1;for(;;){h=v-S,s[b]<p?(m=0,g=s[b]):s[b]>p?(m=A[N+s[b]],g=O[C+s[b]]):(m=96,g=0),l=1<<v-S,_=d=1<<k;do i[f+(E>>S)+(d-=l)]=h<<24|m<<16|g;while(0!==d)for(l=1<<v-1;E&l;)l>>=1;if(0!==l?(E&=l-1,E+=l):E=0,b++,0==--T[v]){if(v===x)break;v=t[r+s[b]]}if(v>w&&(E&u)!==c){for(0===S&&(S=w),f+=_,I=1<<(k=v-S);k+S<x&&!((I-=T[k+S])<=0);)k++,I<<=1;if($+=1<<k,1===e&&$>852||2===e&&$>592)return 1;i[c=E&u]=w<<24|k<<16|f-a}}return 0!==E&&(i[f+E]=v-S<<24|4194304),o.bits=w,0};let{Z_FINISH:e6,Z_BLOCK:e8,Z_TREES:e9,Z_OK:e4,Z_STREAM_END:e7,Z_NEED_DICT:te,Z_STREAM_ERROR:tt,Z_DATA_ERROR:tr,Z_MEM_ERROR:tn,Z_BUF_ERROR:ti,Z_DEFLATED:ta}=W,ts=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function to(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}let tl=e=>{if(!e||!e.state)return tt;let t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,(e=>{if(!e||!e.state)return tt;let t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=1,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,e4})(e)},td=!0,tc=e=>{if(td){s=new Int32Array(512),o=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(e3(1,e.lens,0,288,s,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;e3(2,e.lens,0,32,o,0,e.work,{bits:5}),td=!1}e.lencode=s,e.lenbits=9,e.distcode=o,e.distbits=5},tu=(e,t,r,n)=>{let i,a=e.state;return null===a.window&&(a.wsize=1<<a.wbits,a.wnext=0,a.whave=0,a.window=new Uint8Array(a.wsize)),n>=a.wsize?(a.window.set(t.subarray(r-a.wsize,r),0),a.wnext=0,a.whave=a.wsize):((i=a.wsize-a.wnext)>n&&(i=n),a.window.set(t.subarray(r-n,r-n+i),a.wnext),(n-=i)?(a.window.set(t.subarray(r-n,r),0),a.wnext=n,a.whave=a.wsize):(a.wnext+=i,a.wnext===a.wsize&&(a.wnext=0),a.whave<a.wsize&&(a.whave+=i))),0};var tf=(e,t)=>{let r,n,i,a,s,o,l,d,c,u,f,p,h,m,g,y,v,b,_,x,w,k,S,I,$=0,E=new Uint8Array(4),O=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return tt;12===(r=e.state).mode&&(r.mode=13),s=e.next_out,i=e.output,l=e.avail_out,a=e.next_in,n=e.input,o=e.avail_in,d=r.hold,c=r.bits,u=o,f=l,k=e4;r:for(;;)switch(r.mode){case 1:if(0===r.wrap){r.mode=13;break}for(;c<16;){if(0===o)break r;o--,d+=n[a++]<<c,c+=8}if(2&r.wrap&&35615===d){r.check=0,E[0]=255&d,E[1]=d>>>8&255,r.check=L(r.check,E,2,0),d=0,c=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&d)<<8)+(d>>8))%31){e.msg="incorrect header check",r.mode=30;break}if((15&d)!==ta){e.msg="unknown compression method",r.mode=30;break}if(d>>>=4,c-=4,w=(15&d)+8,0===r.wbits)r.wbits=w;else if(w>r.wbits){e.msg="invalid window size",r.mode=30;break}r.dmax=1<<r.wbits,e.adler=r.check=1,r.mode=512&d?10:12,d=0,c=0;break;case 2:for(;c<16;){if(0===o)break r;o--,d+=n[a++]<<c,c+=8}if(r.flags=d,(255&r.flags)!==ta){e.msg="unknown compression method",r.mode=30;break}if(57344&r.flags){e.msg="unknown header flags set",r.mode=30;break}r.head&&(r.head.text=d>>8&1),512&r.flags&&(E[0]=255&d,E[1]=d>>>8&255,r.check=L(r.check,E,2,0)),d=0,c=0,r.mode=3;case 3:for(;c<32;){if(0===o)break r;o--,d+=n[a++]<<c,c+=8}r.head&&(r.head.time=d),512&r.flags&&(E[0]=255&d,E[1]=d>>>8&255,E[2]=d>>>16&255,E[3]=d>>>24&255,r.check=L(r.check,E,4,0)),d=0,c=0,r.mode=4;case 4:for(;c<16;){if(0===o)break r;o--,d+=n[a++]<<c,c+=8}r.head&&(r.head.xflags=255&d,r.head.os=d>>8),512&r.flags&&(E[0]=255&d,E[1]=d>>>8&255,r.check=L(r.check,E,2,0)),d=0,c=0,r.mode=5;case 5:if(1024&r.flags){for(;c<16;){if(0===o)break r;o--,d+=n[a++]<<c,c+=8}r.length=d,r.head&&(r.head.extra_len=d),512&r.flags&&(E[0]=255&d,E[1]=d>>>8&255,r.check=L(r.check,E,2,0)),d=0,c=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&((p=r.length)>o&&(p=o),p&&(r.head&&(w=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Uint8Array(r.head.extra_len)),r.head.extra.set(n.subarray(a,a+p),w)),512&r.flags&&(r.check=L(r.check,n,p,a)),o-=p,a+=p,r.length-=p),r.length))break r;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(0===o)break r;p=0;do w=n[a+p++],r.head&&w&&r.length<65536&&(r.head.name+=String.fromCharCode(w));while(w&&p<o)if(512&r.flags&&(r.check=L(r.check,n,p,a)),o-=p,a+=p,w)break r}else r.head&&(r.head.name=null);r.length=0,r.mode=8;case 8:if(4096&r.flags){if(0===o)break r;p=0;do w=n[a+p++],r.head&&w&&r.length<65536&&(r.head.comment+=String.fromCharCode(w));while(w&&p<o)if(512&r.flags&&(r.check=L(r.check,n,p,a)),o-=p,a+=p,w)break r}else r.head&&(r.head.comment=null);r.mode=9;case 9:if(512&r.flags){for(;c<16;){if(0===o)break r;o--,d+=n[a++]<<c,c+=8}if(d!==(65535&r.check)){e.msg="header crc mismatch",r.mode=30;break}d=0,c=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=12;break;case 10:for(;c<32;){if(0===o)break r;o--,d+=n[a++]<<c,c+=8}e.adler=r.check=ts(d),d=0,c=0,r.mode=11;case 11:if(0===r.havedict)return e.next_out=s,e.avail_out=l,e.next_in=a,e.avail_in=o,r.hold=d,r.bits=c,te;e.adler=r.check=1,r.mode=12;case 12:if(t===e8||t===e9)break r;case 13:if(r.last){d>>>=7&c,c-=7&c,r.mode=27;break}for(;c<3;){if(0===o)break r;o--,d+=n[a++]<<c,c+=8}switch(r.last=1&d,c-=1,3&(d>>>=1)){case 0:r.mode=14;break;case 1:if(tc(r),r.mode=20,t===e9){d>>>=2,c-=2;break r}break;case 2:r.mode=17;break;case 3:e.msg="invalid block type",r.mode=30}d>>>=2,c-=2;break;case 14:for(d>>>=7&c,c-=7&c;c<32;){if(0===o)break r;o--,d+=n[a++]<<c,c+=8}if((65535&d)!=(d>>>16^65535)){e.msg="invalid stored block lengths",r.mode=30;break}if(r.length=65535&d,d=0,c=0,r.mode=15,t===e9)break r;case 15:r.mode=16;case 16:if(p=r.length){if(p>o&&(p=o),p>l&&(p=l),0===p)break r;i.set(n.subarray(a,a+p),s),o-=p,a+=p,l-=p,s+=p,r.length-=p;break}r.mode=12;break;case 17:for(;c<14;){if(0===o)break r;o--,d+=n[a++]<<c,c+=8}if(r.nlen=(31&d)+257,c-=5,r.ndist=(31&(d>>>=5))+1,c-=5,r.ncode=(15&(d>>>=5))+4,d>>>=4,c-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=30;break}r.have=0,r.mode=18;case 18:for(;r.have<r.ncode;){for(;c<3;){if(0===o)break r;o--,d+=n[a++]<<c,c+=8}r.lens[O[r.have++]]=7&d,d>>>=3,c-=3}for(;r.have<19;)r.lens[O[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,S={bits:r.lenbits},k=e3(0,r.lens,0,19,r.lencode,0,r.work,S),r.lenbits=S.bits,k){e.msg="invalid code lengths set",r.mode=30;break}r.have=0,r.mode=19;case 19:for(;r.have<r.nlen+r.ndist;){for(;g=($=r.lencode[d&(1<<r.lenbits)-1])>>>24,y=$>>>16&255,v=65535&$,!(g<=c);){if(0===o)break r;o--,d+=n[a++]<<c,c+=8}if(v<16)d>>>=g,c-=g,r.lens[r.have++]=v;else{if(16===v){for(I=g+2;c<I;){if(0===o)break r;o--,d+=n[a++]<<c,c+=8}if(d>>>=g,c-=g,0===r.have){e.msg="invalid bit length repeat",r.mode=30;break}w=r.lens[r.have-1],p=3+(3&d),d>>>=2,c-=2}else if(17===v){for(I=g+3;c<I;){if(0===o)break r;o--,d+=n[a++]<<c,c+=8}d>>>=g,c-=g,w=0,p=3+(7&d),d>>>=3,c-=3}else{for(I=g+7;c<I;){if(0===o)break r;o--,d+=n[a++]<<c,c+=8}d>>>=g,c-=g,w=0,p=11+(127&d),d>>>=7,c-=7}if(r.have+p>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=30;break}for(;p--;)r.lens[r.have++]=w}}if(30===r.mode)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=30;break}if(r.lenbits=9,S={bits:r.lenbits},k=e3(1,r.lens,0,r.nlen,r.lencode,0,r.work,S),r.lenbits=S.bits,k){e.msg="invalid literal/lengths set",r.mode=30;break}if(r.distbits=6,r.distcode=r.distdyn,S={bits:r.distbits},k=e3(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,S),r.distbits=S.bits,k){e.msg="invalid distances set",r.mode=30;break}if(r.mode=20,t===e9)break r;case 20:r.mode=21;case 21:if(o>=6&&l>=258){e.next_out=s,e.avail_out=l,e.next_in=a,e.avail_in=o,r.hold=d,r.bits=c,eZ(e,f),s=e.next_out,i=e.output,l=e.avail_out,a=e.next_in,n=e.input,o=e.avail_in,d=r.hold,c=r.bits,12===r.mode&&(r.back=-1);break}for(r.back=0;g=($=r.lencode[d&(1<<r.lenbits)-1])>>>24,y=$>>>16&255,v=65535&$,!(g<=c);){if(0===o)break r;o--,d+=n[a++]<<c,c+=8}if(y&&(240&y)==0){for(b=g,_=y,x=v;g=($=r.lencode[x+((d&(1<<b+_)-1)>>b)])>>>24,y=$>>>16&255,v=65535&$,!(b+g<=c);){if(0===o)break r;o--,d+=n[a++]<<c,c+=8}d>>>=b,c-=b,r.back+=b}if(d>>>=g,c-=g,r.back+=g,r.length=v,0===y){r.mode=26;break}if(32&y){r.back=-1,r.mode=12;break}if(64&y){e.msg="invalid literal/length code",r.mode=30;break}r.extra=15&y,r.mode=22;case 22:if(r.extra){for(I=r.extra;c<I;){if(0===o)break r;o--,d+=n[a++]<<c,c+=8}r.length+=d&(1<<r.extra)-1,d>>>=r.extra,c-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;g=($=r.distcode[d&(1<<r.distbits)-1])>>>24,y=$>>>16&255,v=65535&$,!(g<=c);){if(0===o)break r;o--,d+=n[a++]<<c,c+=8}if((240&y)==0){for(b=g,_=y,x=v;g=($=r.distcode[x+((d&(1<<b+_)-1)>>b)])>>>24,y=$>>>16&255,v=65535&$,!(b+g<=c);){if(0===o)break r;o--,d+=n[a++]<<c,c+=8}d>>>=b,c-=b,r.back+=b}if(d>>>=g,c-=g,r.back+=g,64&y){e.msg="invalid distance code",r.mode=30;break}r.offset=v,r.extra=15&y,r.mode=24;case 24:if(r.extra){for(I=r.extra;c<I;){if(0===o)break r;o--,d+=n[a++]<<c,c+=8}r.offset+=d&(1<<r.extra)-1,d>>>=r.extra,c-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=30;break}r.mode=25;case 25:if(0===l)break r;if(p=f-l,r.offset>p){if((p=r.offset-p)>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=30;break}p>r.wnext?(p-=r.wnext,h=r.wsize-p):h=r.wnext-p,p>r.length&&(p=r.length),m=r.window}else m=i,h=s-r.offset,p=r.length;p>l&&(p=l),l-=p,r.length-=p;do i[s++]=m[h++];while(--p)0===r.length&&(r.mode=21);break;case 26:if(0===l)break r;i[s++]=r.length,l--,r.mode=21;break;case 27:if(r.wrap){for(;c<32;){if(0===o)break r;o--,d|=n[a++]<<c,c+=8}if(f-=l,e.total_out+=f,r.total+=f,f&&(e.adler=r.check=r.flags?L(r.check,i,f,s-f):F(r.check,i,f,s-f)),f=l,(r.flags?d:ts(d))!==r.check){e.msg="incorrect data check",r.mode=30;break}d=0,c=0}r.mode=28;case 28:if(r.wrap&&r.flags){for(;c<32;){if(0===o)break r;o--,d+=n[a++]<<c,c+=8}if(d!==(0|r.total)){e.msg="incorrect length check",r.mode=30;break}d=0,c=0}r.mode=29;case 29:k=e7;break r;case 30:k=tr;break r;case 31:return tn;default:return tt}return e.next_out=s,e.avail_out=l,e.next_in=a,e.avail_in=o,r.hold=d,r.bits=c,(r.wsize||f!==e.avail_out&&r.mode<30&&(r.mode<27||t!==e6))&&tu(e,e.output,e.next_out,f-e.avail_out),u-=e.avail_in,f-=e.avail_out,e.total_in+=u,e.total_out+=f,r.total+=f,r.wrap&&f&&(e.adler=r.check=r.flags?L(r.check,i,f,e.next_out-f):F(r.check,i,f,e.next_out-f)),e.data_type=r.bits+64*!!r.last+128*(12===r.mode)+256*(20===r.mode||15===r.mode),(0===u&&0===f||t===e6)&&k===e4&&(k=ti),k},tp=e=>{if(!e||!e.state)return tt;let t=e.state;return t.window&&(t.window=null),e.state=null,e4},th=(e,t)=>{let r,n=t.length;return e&&e.state&&(0===(r=e.state).wrap||11===r.mode)?11===r.mode&&F(1,t,n,0)!==r.check?tr:tu(e,t,n,n)?(r.mode=31,tn):(r.havedict=1,e4):tt},tm=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};let tg=Object.prototype.toString,{Z_NO_FLUSH:ty,Z_FINISH:tv,Z_OK:tb,Z_STREAM_END:t_,Z_NEED_DICT:tx,Z_STREAM_ERROR:tw,Z_DATA_ERROR:tk,Z_MEM_ERROR:tS}=W;function tI(e){this.options=eN({chunkSize:65536,windowBits:15,to:""},e||{});let t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),t.windowBits>=0&&t.windowBits<16&&!(e&&e.windowBits)&&(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(15&t.windowBits)==0&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new eB,this.strm.avail_out=0;let r=((e,t)=>{if(!e)return tt;let r=new to;e.state=r,r.window=null;let n=((e,t)=>{let r;if(!e||!e.state)return tt;let n=e.state;return(t<0?(r=0,t=-t):(r=(t>>4)+1,t<48&&(t&=15)),t&&(t<8||t>15))?tt:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,tl(e))})(e,t);return n!==e4&&(e.state=null),n})(this.strm,t.windowBits);if(r!==tb||(this.header=new tm,((e,t)=>{if(!e||!e.state)return;let r=e.state;return(2&r.wrap)==0||(r.head=t,t.done=!1)})(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=eD(t.dictionary):"[object ArrayBuffer]"===tg.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw)&&(r=th(this.strm,t.dictionary))!==tb))throw Error(z[r])}function t$(e,t){let r=new tI(t);if(r.push(e),r.err)throw r.msg||z[r.err];return r.result}tI.prototype.push=function(e,t){let r,n,i,a=this.strm,s=this.options.chunkSize,o=this.options.dictionary;if(this.ended)return!1;for(n=t===~~t?t:!0===t?tv:ty,"[object ArrayBuffer]"===tg.call(e)?a.input=new Uint8Array(e):a.input=e,a.next_in=0,a.avail_in=a.input.length;;){for(0===a.avail_out&&(a.output=new Uint8Array(s),a.next_out=0,a.avail_out=s),(r=tf(a,n))===tx&&o&&((r=th(a,o))===tb?r=tf(a,n):r===tk&&(r=tx));a.avail_in>0&&r===t_&&a.state.wrap>0&&0!==e[a.next_in];)tl(a),r=tf(a,n);switch(r){case tw:case tk:case tx:case tS:return this.onEnd(r),this.ended=!0,!1}if(i=a.avail_out,a.next_out&&(0===a.avail_out||r===t_))if("string"===this.options.to){let e=eF(a.output,a.next_out),t=a.next_out-e,r=eU(a.output,e);a.next_out=t,a.avail_out=s-t,t&&a.output.set(a.output.subarray(e,e+t),0),this.onData(r)}else this.onData(a.output.length===a.next_out?a.output:a.output.subarray(0,a.next_out));if(r!==tb||0!==i){if(r===t_)return r=tp(this.strm),this.onEnd(r),this.ended=!0,!0;if(0===a.avail_in)break}}return!0},tI.prototype.onData=function(e){this.chunks.push(e)},tI.prototype.onEnd=function(e){e===tb&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=eP(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};let{Deflate:tE,deflate:tO,deflateRaw:tC,gzip:tT}={Deflate:eK,deflate:eQ,deflateRaw:function(e,t){return(t=t||{}).raw=!0,eQ(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,eQ(e,t)},constants:W},{Inflate:tM,inflate:tA,inflateRaw:tN,ungzip:tP}={Inflate:tI,inflate:t$,inflateRaw:function(e,t){return(t=t||{}).raw=!0,t$(e,t)},ungzip:t$,constants:W};r.d(t,{Gy:()=>tE,Kc:()=>tO,UD:()=>tA})},3178(e,t,r){let n;r.d(t,{x3:()=>rT,y1:()=>t4,Ov:()=>r2,Tx:()=>r9,UA:()=>iY,JH:()=>rZ,yE:()=>ra,Ky:()=>tf,e5:()=>tD,Uh:()=>t7,nu:()=>ty,OF:()=>aq,XV:()=>aJ,r8:()=>aY,rC:()=>aX,rR:()=>iX,ie:()=>eb});var i=r(2718),a=r(1179),s=r(2842),o=r(4238),l=r(5633),d=r(2109),c=r(7086),u=r(9315),f=r(2981);let p=i.ukk,h=i.mSG(i.QfV,i.$r1),m=Object.freeze({paper:"#f6f1e7",card:"#fffdf8",ink:"#1a1712",accent:"#8f707f"}),g=Object.freeze({accentColor:m.accent,backgroundColor:m.card});function y(e,t){return e.pipe(i.tiU(s.PyW(t)))}function v(e,t){return i.svK(e,{errors:"all"})(t)}let b=c.ID();function _(e){return Object.assign(e,{parse:t=>v(e,t),safeParse:t=>{let r;return r=i.q$Z(e,{errors:"all"})(t),u.oJ(r)?{data:r.success,success:!0}:{error:{issues:b(r.failure.issue).issues.map(e=>({message:e.message,path:(e.path??[]).map(e=>"object"==typeof e?e.key:e)}))},success:!1}}})}let x=i.xCb(["flowchart","mindmap"]),w=i.xCb(["TB","BT","LR","RL"]),k=i.xCb(["straight","orthogonal","curved"]);class S extends i.Xsx("DiagramNode")({id:p,label:p,group:i.lqM(p),kind:i.lqM(p),metadata:y(h,{})}){}_(S);class I extends i.Xsx("DiagramEdge")({id:p,source:p,target:p,label:i.lqM(p),metadata:y(h,{})}){}_(I);let $=i.QfV.check(i.Pto(/^#[0-9a-fA-F]{6}$/));class E extends i.Xsx("DiagramStyle")({accentColor:y($,g.accentColor),backgroundColor:y($,g.backgroundColor)}){}_(E);class O extends i.Xsx("DiagramLayout")({direction:y(w,"LR"),edgeRouting:y(k,"orthogonal")}){}_(O);class C extends i.Xsx("IntermediateDiagram")({id:p,title:p,type:y(x,"flowchart"),nodes:i.O31(S).pipe(i.fXn).check(i.tJb(1)),edges:y(i.O31(I).pipe(i.fXn),[]),layout:y(O,{direction:"LR",edgeRouting:"orthogonal"}),style:y(E,g),metadata:y(h,{})}){}_(C);class T extends Error{constructor(e){super(e),this.name="DiagramValidationError"}}let M=e=>{let t=new Set;for(let r of e){if(t.has(r))return r;t.add(r)}};function A(e){let t=M(e.nodes.map(e=>e.id));if(t)throw new T(`Duplicate node id "${t}" is not allowed.`);let r=M(e.edges.map(e=>e.id));if(r)throw new T(`Duplicate edge id "${r}" is not allowed.`);let n=new Set(e.nodes.map(e=>e.id));for(let t of e.edges){if(!n.has(t.source))throw new T(`Edge "${t.id}" references missing source node "${t.source}".`);if(!n.has(t.target))throw new T(`Edge "${t.id}" references missing target node "${t.target}".`);if(t.source===t.target)throw new T(`Edge "${t.id}" cannot connect node "${t.source}" to itself.`)}return e}function N(e){return A(v(C,e))}let P="flowchart",R=i.xCb(["duplicate_node_id","duplicate_edge_id","missing_edge_source","missing_edge_target","self_loop","missing_start","multiple_starts","missing_end","start_has_incoming","end_has_outgoing","unreachable_node","missing_outgoing_edge","underbranched_decision","unlabeled_decision_branch","duplicate_decision_branch_label","nonterminating_node","flowchart_too_large"]);class j extends i.Xsx("FlowchartValidationIssueRef")({kind:i.xCb(["diagram","node","edge"]),id:i.lqM(i.ukk),path:i.lqM(i.ukk)}){}i.Xsx("FlowchartValidationIssue")({code:R,ref:i.lqM(j),message:i.ukk,hint:i.ukk});let D=i.xCb(["start","process","decision","end"]);class U extends S.extend("FlowchartNode")({kind:D,description:i.lqM(i.ukk)}){}class F extends I.extend("FlowchartEdge")({label:i.lqM(i.ukk)}){}class B extends C.extend("FlowchartDiagram")({type:i.uSQ(P),nodes:i.O31(U).pipe(i.fXn).check(i.tJb(2)),edges:i.O31(F).pipe(i.fXn).check(i.tJb(1))}){}let L=_(B);function z(e){let t=new Set,r=new Set;for(let n of e)t.has(n)?r.add(n):t.add(n);return[...r]}function W(e,t,r){let n=new Set,i=[...e];for(let e=0;e<i.length;e+=1){let a=i[e];if(!(void 0===a||n.has(a)))for(let e of(n.add(a),t.get(a)??[]))i.push(r(e))}return n}function J(e){let t=[],r=new Set(e.nodes.map(e=>e.id)),{incoming:n,outgoing:i}=function(e){let t=new Map,r=new Map;for(let n of e)t.set(n.target,[...t.get(n.target)??[],n]),r.set(n.source,[...r.get(n.source)??[],n]);return{incoming:t,outgoing:r}}(e.edges);for(let r of(e.nodes.length>24&&t.push({code:"flowchart_too_large",ref:{kind:"diagram",id:e.id,path:"nodes"},message:`Flowchart has ${e.nodes.length} nodes; the supported maximum is 24.`,hint:"Split the workflow or combine lower-signal steps."}),e.edges.length>64&&t.push({code:"flowchart_too_large",ref:{kind:"diagram",id:e.id,path:"edges"},message:`Flowchart has ${e.edges.length} edges; the supported maximum is 64.`,hint:"Split the workflow or remove lower-signal connections."}),z(e.nodes.map(e=>e.id))))t.push({code:"duplicate_node_id",ref:{kind:"node",id:r,path:"nodes"},message:`Node id "${r}" is used more than once.`,hint:"Give every node a stable unique id."});for(let r of z(e.edges.map(e=>e.id)))t.push({code:"duplicate_edge_id",ref:{kind:"edge",id:r,path:"edges"},message:`Edge id "${r}" is used more than once.`,hint:"Give every edge a stable unique id."});for(let n of e.edges)r.has(n.source)||t.push({code:"missing_edge_source",ref:{kind:"edge",id:n.id,path:"edges.source"},message:`Edge "${n.id}" references missing source node "${n.source}".`,hint:"Set edge.source to one of the diagram node ids."}),r.has(n.target)||t.push({code:"missing_edge_target",ref:{kind:"edge",id:n.id,path:"edges.target"},message:`Edge "${n.id}" references missing target node "${n.target}".`,hint:"Set edge.target to one of the diagram node ids."}),n.source===n.target&&t.push({code:"self_loop",ref:{kind:"edge",id:n.id},message:`Edge "${n.id}" connects node "${n.source}" to itself.`,hint:"Connect the edge to a different target node."});let a=e.nodes.filter(e=>"start"===e.kind),s=e.nodes.filter(e=>"end"===e.kind);for(let r of(0===a.length?t.push({code:"missing_start",ref:{kind:"diagram",id:e.id,path:"nodes"},message:"Flowchart must contain exactly one start node.",hint:'Mark the first node in the flow with kind: "start".'}):a.length>1&&t.push({code:"multiple_starts",ref:{kind:"diagram",id:e.id,path:"nodes"},message:`Flowchart has ${a.length} start nodes.`,hint:"Keep one start node and change the others to process, decision, or end."}),0===s.length&&t.push({code:"missing_end",ref:{kind:"diagram",id:e.id,path:"nodes"},message:"Flowchart must contain at least one end node.",hint:'Add an end node or mark terminal outcomes with kind: "end".'}),e.nodes)){let e=n.get(r.id)??[],a=i.get(r.id)??[];"start"===r.kind&&e.length>0&&t.push({code:"start_has_incoming",ref:{kind:"node",id:r.id},message:`Start node "${r.id}" cannot have incoming edges.`,hint:"Route the start node only to later nodes."}),"end"===r.kind&&a.length>0&&t.push({code:"end_has_outgoing",ref:{kind:"node",id:r.id},message:`End node "${r.id}" cannot have outgoing edges.`,hint:"End nodes must be terminal outcomes."}),"end"!==r.kind&&0===a.length&&t.push({code:"missing_outgoing_edge",ref:{kind:"node",id:r.id},message:`Node "${r.id}" must have at least one outgoing edge.`,hint:'Connect it to the next step, or mark it as kind: "end".'}),"decision"===r.kind&&t.push(...function(e,t){let r=[];t.length<2&&r.push({code:"underbranched_decision",ref:{kind:"node",id:e.id},message:`Decision node "${e.id}" must have at least two outgoing branches.`,hint:"Add at least two outgoing edges for the decision outcomes."});let n=t.map(e=>e.label?.trim()??"");for(let n of t.filter(e=>!e.label?.trim()))r.push({code:"unlabeled_decision_branch",ref:{kind:"edge",id:n.id,path:"edges.label"},message:`Decision node "${e.id}" has an outgoing branch without a label.`,hint:'Add a short branch label such as "yes", "no", "approved", or "rejected".'});for(let t of z(n.filter(e=>e.length>0).map(e=>e.toLowerCase())))r.push({code:"duplicate_decision_branch_label",ref:{kind:"node",id:e.id},message:`Decision node "${e.id}" repeats branch label "${t}".`,hint:"Make every outgoing branch label from the same decision unique."});return r}(r,a))}let o=1===a.length?a[0]:void 0;if(o){let r=W([o.id],i,e=>e.target);for(let n of e.nodes)r.has(n.id)||t.push({code:"unreachable_node",ref:{kind:"node",id:n.id},message:`Node "${n.id}" is not reachable from the start node.`,hint:"Connect every node to the flow that begins at the single start node."});if(s.length>0){let a=W(s.map(e=>e.id),n,e=>e.source);for(let n of e.nodes)r.has(n.id)&&!a.has(n.id)&&(i.get(n.id)?.length??0)>0&&t.push({code:"nonterminating_node",ref:{kind:"node",id:n.id},message:`Node "${n.id}" cannot reach an end node.`,hint:"Add an eventual exit from this path to an end node; retry loops are valid when they retain an exit."})}}return t.slice(0,20)}class Y extends T{issues;constructor(e){super(e[0]?.message??"Flowchart failed semantic validation."),this.issues=e,this.name="FlowchartValidationError"}}function X(e){let t=J(e);if(t.length>0)throw new Y(t);return e}let q=X(v(B,{id:"onboarding-flow",title:"Sketchi onboarding decision flow",type:P,nodes:[{id:"prompt",label:"Prompt received",kind:"start"},{id:"requirements",label:"Extract requirements",kind:"process"},{id:"clear",label:"Scope clear?",kind:"decision"},{id:"draft",label:"Draft typed IR",kind:"process"},{id:"review",label:"Review diagram",kind:"end"}],edges:[{id:"prompt-requirements",source:"prompt",target:"requirements"},{id:"requirements-clear",source:"requirements",target:"clear"},{id:"clear-draft",source:"clear",target:"draft",label:"yes"},{id:"clear-review",source:"clear",target:"review",label:"no"},{id:"draft-review",source:"draft",target:"review"}],layout:{direction:"TB",edgeRouting:"orthogonal"}}));X(v(B,{id:"pharma-batch-disposition",title:"Pharma batch disposition flow",type:P,nodes:[{id:"batch-received",label:"Batch received",kind:"start"},{id:"qa-review",label:"QA reviews Certificate of Analysis",kind:"process"},{id:"passes-specs",label:"Passes specs?",kind:"decision"},{id:"final-review",label:"QA Manager final review",kind:"process"},{id:"packaging",label:"Send to packaging",kind:"end"},{id:"investigate",label:"Investigate retesting",kind:"process"},{id:"reject",label:"Reject batch",kind:"end"}],edges:[{id:"batch-qa",source:"batch-received",target:"qa-review"},{id:"qa-specs",source:"qa-review",target:"passes-specs"},{id:"specs-pass",source:"passes-specs",target:"final-review",label:"yes"},{id:"specs-investigate",source:"passes-specs",target:"investigate",label:"retest"},{id:"specs-reject",source:"passes-specs",target:"reject",label:"reject"},{id:"review-packaging",source:"final-review",target:"packaging"},{id:"investigate-review",source:"investigate",target:"final-review"}],layout:{direction:"TB",edgeRouting:"orthogonal"}}));let G="mindmap";class V extends i.Xsx("MindmapNodeMetadata")({depth:i.Aiz.check(i.OWK(0)),siblingIndex:i.Aiz.check(i.OWK(0))}){}class H extends S.extend("MindmapNode")({kind:i.xCb(["root","topic"]),metadata:V}){}class K extends i.Xsx("MindmapEdgeMetadata")({depth:i.Aiz.check(i.yJO(0)),siblingIndex:i.Aiz.check(i.OWK(0))}){}class Q extends I.extend("MindmapEdge")({metadata:K}){}class Z extends C.extend("MindmapDiagram")({type:i.uSQ(G),nodes:i.O31(H).pipe(i.fXn).check(i.tJb(2)),edges:i.O31(Q).pipe(i.fXn).check(i.tJb(1))}){}function ee(e){return function(e){A(e);let t=e.nodes.filter(e=>"root"===e.kind);if(1!==t.length)throw new T(`Mindmap must contain exactly one root topic; found ${t.length}.`);let r=t[0];if(!r||0!==r.metadata.depth)throw new T("Mindmap root topic must have depth 0.");let n=new Map,i=new Map(e.nodes.map(e=>[e.id,e])),a=new Map;for(let t of e.edges){n.set(t.target,(n.get(t.target)??0)+1);let e=i.get(t.source)?.metadata.depth,r=i.get(t.target),s=r?.metadata.depth;if(void 0===e||s!==e+1)throw new T(`Mindmap edge "${t.id}" must connect a topic to its immediate child.`);if(!r||t.metadata.depth!==r.metadata.depth||t.metadata.siblingIndex!==r.metadata.siblingIndex)throw new T(`Mindmap edge "${t.id}" metadata must match its child topic.`);a.set(t.source,[...a.get(t.source)??[],r.metadata.siblingIndex])}for(let t of e.nodes){let e=n.get(t.id)??0;if(t.id===r.id?0!==e:1!==e)throw new T(`Mindmap topic "${t.id}" must have ${t.id===r.id?"no parent":"exactly one parent"}.`)}for(let[e,t]of a){let r=t.map((e,t)=>t);if([...t].sort((e,t)=>e-t).some((e,t)=>e!==r[t]))throw new T(`Mindmap children of "${e}" must use contiguous sibling ordering from 0.`)}return e}(v(Z,e))}_(Z);let et=ee({id:"public-mindmap-capability",title:"Public mindmap generation",type:G,nodes:[{id:"topic-0",label:"Public mindmaps",kind:"root",metadata:{depth:0,siblingIndex:0}},{id:"topic-0-0",label:"Semantic input",kind:"topic",metadata:{depth:1,siblingIndex:0}},{id:"topic-0-0-0",label:"Nested topics",kind:"topic",metadata:{depth:2,siblingIndex:0}},{id:"topic-0-0-1",label:"Stable ordering",kind:"topic",metadata:{depth:2,siblingIndex:1}},{id:"topic-0-1",label:"Artifact output",kind:"topic",metadata:{depth:1,siblingIndex:1}},{id:"topic-0-1-0",label:"Scene",kind:"topic",metadata:{depth:2,siblingIndex:0}},{id:"topic-0-1-1",label:"Excalidraw",kind:"topic",metadata:{depth:2,siblingIndex:1}}],edges:[{id:"branch-0-0",source:"topic-0",target:"topic-0-0",metadata:{depth:1,siblingIndex:0}},{id:"branch-0-0-0",source:"topic-0-0",target:"topic-0-0-0",metadata:{depth:2,siblingIndex:0}},{id:"branch-0-0-1",source:"topic-0-0",target:"topic-0-0-1",metadata:{depth:2,siblingIndex:1}},{id:"branch-0-1",source:"topic-0",target:"topic-0-1",metadata:{depth:1,siblingIndex:1}},{id:"branch-0-1-0",source:"topic-0-1",target:"topic-0-1-0",metadata:{depth:2,siblingIndex:0}},{id:"branch-0-1-1",source:"topic-0-1",target:"topic-0-1-1",metadata:{depth:2,siblingIndex:1}}],layout:{direction:"LR",edgeRouting:"curved"}});N(q),N(et);let er=Object.freeze({maxDimension:16384,maxElements:600,maxGroupsPerElement:16,maxLayouts:128,maxLayers:64,maxPointsPerElement:256,maxSerializedBytes:15e5,maxTextLength:4096,maxZOrderEntries:600});function en(e){let t=new Set;for(let r of e){if(t.has(r))return r;t.add(r)}}function ei(e){return"x"in e&&"y"in e}function ea(e){let t=[];0===e.elements.length&&t.push({code:"empty_canvas",message:"CanvasSpec must contain at least one element.",path:"elements"}),e.elements.length>er.maxElements&&t.push({code:"limit_exceeded",message:`Canvas exceeds ${er.maxElements} elements.`,path:"elements"}),e.layers.length>er.maxLayers&&t.push({code:"limit_exceeded",message:`Canvas exceeds ${er.maxLayers} layers.`,path:"layers"}),e.layouts.length>er.maxLayouts&&t.push({code:"limit_exceeded",message:`Canvas exceeds ${er.maxLayouts} layout primitives.`,path:"layouts"}),(e.width>er.maxDimension||e.height>er.maxDimension)&&t.push({code:"limit_exceeded",message:`Canvas dimensions may not exceed ${er.maxDimension}.`,path:"width"});let r=en(e.elements.map(e=>e.id));r&&t.push({code:"duplicate_element_id",elementId:r,message:`Duplicate element id "${r}" is not allowed.`,path:"elements"});let n=en(e.layers.map(e=>e.id));n&&t.push({code:"duplicate_layer_id",message:`Duplicate layer id "${n}" is not allowed.`,path:"layers"});let i=en(e.zOrder);i&&t.push({code:"duplicate_z_order_element",elementId:i,message:`zOrder contains duplicate element "${i}".`,path:"zOrder"}),e.zOrder.length>er.maxZOrderEntries&&t.push({code:"limit_exceeded",message:`zOrder exceeds ${er.maxZOrderEntries} entries.`,path:"zOrder"});let a=new Map(e.elements.map(e=>[e.id,e])),s=e.elements.filter(e=>"node"===e.type),o=new Map(s.map(e=>[e.nodeId,e])),l=en(s.map(e=>e.nodeId));l&&t.push({code:"invalid_binding",message:`Duplicate nodeId "${l}" makes connector bindings ambiguous.`,path:"elements"});let d=en(e.elements.flatMap(e=>"arrow"===e.type?[e.edgeId]:[]));d&&t.push({code:"invalid_binding",message:`Duplicate edgeId "${d}" makes connector selection ambiguous.`,path:"elements"});let c=en(e.elements.flatMap(e=>"text"===e.type&&e.containerId?[e.containerId]:[]));c&&t.push({code:"invalid_binding",elementId:c,message:`Container "${c}" has more than one bound text element.`,path:"elements"});let u=new Map(e.layers.map(e=>[e.id,e])),f=new Set(u.keys()),p=e=>!e.layerId||u.get(e.layerId)?.visible!==!1,h=new Map;for(let[t,r]of e.elements.entries())"text"===r.type&&r.containerId&&p(r)&&h.set(r.containerId,{element:r,index:t});e.elements.forEach((e,r)=>{let n,i;if(t.push(...(n=[],i=`elements[${r}]`,"width"in e&&"height"in e&&(!(e.width>0)||!(e.height>0))&&n.push({code:"invalid_geometry",elementId:e.id,message:`Element "${e.id}" must have positive width and height.`,path:i}),"points"in e&&void 0!==e.points&&e.points.length>er.maxPointsPerElement&&n.push({code:"limit_exceeded",elementId:e.id,message:`Element "${e.id}" exceeds ${er.maxPointsPerElement} points.`,path:`${i}.points`}),"text"in e&&e.text.length>er.maxTextLength&&n.push({code:"limit_exceeded",elementId:e.id,message:`Text element "${e.id}" exceeds ${er.maxTextLength} characters.`,path:`${i}.text`}),"node"===e.type&&"polygon"===e.shape&&(!e.points||e.points.length<3)&&n.push({code:"invalid_polygon",elementId:e.id,message:`Polygon "${e.id}" requires at least three points.`,path:`${i}.points`}),e.groupIds&&e.groupIds.length>er.maxGroupsPerElement&&n.push({code:"limit_exceeded",elementId:e.id,message:`Element "${e.id}" exceeds ${er.maxGroupsPerElement} groups.`,path:`${i}.groupIds`}),n)),"node"===e.type&&"polygon"!==e.shape&&p(e)){let n=h.get(e.id);if(n||"sequence-lifeline"!==e.rendererRole){let i=n?.element.text??e.label,a=n?.element.fontSize??16,s=n?n.element.maxWidth??160:Math.max(1,e.width-24),o=i.split("\n"),l=Math.max(1,Math.min(s,o.reduce((e,t)=>Math.max(e,t.length*a*.62),0))),d=Math.ceil(o.length*a*1.35);(l+24>e.width||d+18>e.height)&&t.push({code:"label_overflow",elementId:n?.element.id??e.id,message:`Label does not fit inside node "${e.id}" without changing its geometry.`,path:n?`elements[${n.index}].text`:`elements[${r}].label`})}}if(e.frameId){let n=a.get(e.frameId);n&&"frame"===n.type||t.push({code:"invalid_composition",elementId:e.id,message:`Element "${e.id}" references missing frame "${e.frameId}".`,path:`elements[${r}].frameId`})}if(e.layerId&&!f.has(e.layerId)&&t.push({code:"invalid_composition",elementId:e.id,message:`Element "${e.id}" references missing layer "${e.layerId}".`,path:`elements[${r}].layerId`}),e.groupIds&&en(e.groupIds)&&t.push({code:"invalid_composition",elementId:e.id,message:`Element "${e.id}" contains duplicate group ids.`,path:`elements[${r}].groupIds`}),"text"===e.type&&e.containerId){let n=a.get(e.containerId);n&&("node"===n.type||"arrow"===n.type)||t.push({code:"invalid_binding",elementId:e.id,message:`Text "${e.id}" references unsupported container "${e.containerId}".`,path:`elements[${r}].containerId`})}if("arrow"===e.type&&(o.has(e.sourceNodeId)||t.push({code:"invalid_binding",elementId:e.id,message:`Connector "${e.id}" references missing source "${e.sourceNodeId}".`,path:`elements[${r}].sourceNodeId`}),o.has(e.targetNodeId)||t.push({code:"invalid_binding",elementId:e.id,message:`Connector "${e.id}" references missing target "${e.targetNodeId}".`,path:`elements[${r}].targetNodeId`})),"line"===e.type)for(let[n,i]of[["startBinding",e.startBinding],["endBinding",e.endBinding]]){let s=i?a.get(i.elementId):void 0;i&&(!s||"node"!==s.type&&"frame"!==s.type)&&t.push({code:"invalid_binding",elementId:e.id,message:`Line "${e.id}" references missing binding "${i.elementId}".`,path:`elements[${r}].${n}`})}});let m=new Set(e.zOrder);for(let r of e.elements)m.has(r.id)||t.push({code:"missing_z_order_element",elementId:r.id,message:`Element "${r.id}" is missing from zOrder.`,path:"zOrder"});for(let r of e.zOrder)a.has(r)||t.push({code:"unknown_z_order_element",elementId:r,message:`zOrder references missing element "${r}".`,path:"zOrder"});for(let[r,n]of e.layouts.entries())for(let e of n.ids){let n=a.get(e);n&&ei(n)||t.push({code:"unknown_layout_target",elementId:e,message:`Layout references missing or non-positioned element "${e}".`,path:`layouts[${r}].ids`})}for(let r of e.elements.filter(e=>"frame"===e.type)){let e=new Set([r.id]),n=r.frameId;for(;n;){if(e.has(n)){t.push({code:"invalid_composition",elementId:r.id,message:`Frame "${r.id}" participates in a frame nesting cycle.`,path:"elements"});break}e.add(n);let i=a.get(n);n=i?.type==="frame"?i.frameId:void 0}}return t}function es(e){if("text"===e.type){let t=e.text.split("\n");return{x:e.x,y:e.y,width:e.maxWidth??Math.max(...t.map(e=>e.length))*e.fontSize*.62,height:t.length*e.fontSize*1.35}}return{x:e.x,y:e.y,width:e.width,height:e.height}}function eo(e,t){let r=new Map(e.map(e=>[e.id,e]));return t.flatMap(e=>{let t=r.get(e);return t&&ei(t)?[t]:[]})}function el(e,t){return e.map(e=>{var r,n;let i=t.get(e.id);return i?(r=i.x,n=i.y,ei(e)?{...e,x:r,y:n}:e):e})}function ed(e,t){return"x"===t?e.x:e.y}function ec(e,t){return"x"===t?e.width:e.height}function eu(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}function ef(e,t){let r=eu(e),n=t.x-r.x,i=t.y-r.y;return Math.abs(n)>=Math.abs(i)?{x:n>=0?e.x+e.width:e.x,y:r.y}:{x:r.x,y:i>=0?e.y+e.height:e.y}}let ep=/[,;]\s*(?:id|label|kind|group|source|target|title|direction|nodes|edges)\s*:?\s*$/i;function eh(e){let t=e.trim();for(;;){let e=t.replace(ep,"").trim();if(e===t)return t;t=e}}class em extends i.Xsx("ContractSchemaIssue")({code:eP("custom"),issueTag:i.xCb(["Filter","InvalidType","InvalidValue","MissingKey","UnexpectedKey","Forbidden","OneOf","AnyOf"]),astKind:i.Qrq(i.QfV),missingKeyCode:i.Qrq(i.uSQ("invalid_type")),message:i.QfV,path:i.O31(i.pHd)},{identifier:void 0}){}class eg extends i.rNF()("ContractSchemaError",{issues:i.O31(i.O3D(em))}){}let ey=e=>{var t;if("InvalidType"!==e._tag)return c.vp(e);let r=c.bZ(e)?e.input:void 0;return`Invalid input: expected ${t=e.ast,d.Kg(t)?"string":d.Et(t)?"number":d.Lm(t)?"boolean":d.tF(t)?"array":d.RP(t)?"object":d.c$(t)?JSON.stringify(t.literal):"value"}, received ${null===r?"null":Array.isArray(r)?"array":typeof r}`},ev=c.ID({leafHook:ey});function eb(e,t){var r;let n,a,s=i.q$Z(e,{errors:"all",reportInput:!0})(t);return u.oJ(s)?{data:s.success,success:!0}:{error:new eg({issues:(r=s.failure,n=[],((a=(e,t,r)=>{switch(e._tag){case"Pointer":return a(e.issue,[...t,...e.path],r);case"Encoding":return a(e.issue,t,r);case"Composite":for(let r of e.issues)a(r,t,e.ast);return;case"AnyOf":if(e.issues.length>0){for(let r of e.issues)a(r,t,e.ast);return}break;case"Filter":if(void 0===c.VY(e)&&"InvalidValue"!==e.issue._tag)return a(e.issue,t,r)}let i="ast"in e?e.ast:r,s="MissingKey"===e._tag&&e.annotations?.[eI]==="invalid_type"?"invalid_type":void 0,o=i&&d.mi(i)&&i.types.every(d.c$)?"LiteralUnion":i?._tag,l=i?.annotations?.[eS],u="string"==typeof l?[...t,l]:t;for(let t of ev(e).issues)n.push({code:"custom",issueTag:e._tag,...s?{missingKeyCode:s}:{},...o?{astKind:o}:{},message:t.message,path:u})})(r.issue,[]),n.length>1&&n.every(e=>"source"===e.path[0]))?[{code:"custom",issueTag:"AnyOf",astKind:"Union",message:"Invalid input",path:["source"]}]:n)}),success:!1}}function e_(e){return Object.assign(e,{parse:t=>{let r=eb(e,t);if(r.success)return r.data;throw r.error},safeParse:t=>eb(e,t)})}let ex=new Set(["x-sketchi-default","x-sketchi-one-of","const","exclusiveMaximum","exclusiveMinimum","maximum","maxLength","maxItems","minimum","minItems","minLength","pattern"]),ew="x-sketchi-default",ek="x-sketchi-one-of",eS="codeModeDiscriminator",eI="codeModeMissingKeyCode";function e$(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function eE(e){let t=i._oz(i.AxX(e),{includeAnnotationKey:e=>ex.has(e),onExcessProperty:"error"});return function e(t){if(Array.isArray(t))return t.map(e);if(!e$(t))return t;let r=Object.fromEntries(Object.entries(t).map(([t,r])=>[t,e(r)])),n=!0===r[ek];delete r[ek],n&&Array.isArray(r.anyOf)&&(r.oneOf=r.anyOf,delete r.anyOf);let i=r.allOf;if(Array.isArray(i)){let e=[];for(let t of i)e$(t)&&Object.hasOwn(t,ew)?r.default=t[ew]:e.push(t);0===e.length?delete r.allOf:r.allOf=e}return r}({$schema:"https://json-schema.org/draft/2020-12/schema",...t.schema,...0===Object.keys(t.definitions).length?{}:{$defs:t.definitions}})}function eO(e){return i.O31(e).pipe(i.fXn).check(i.tJb(1,{message:"Too small: expected array to have >=1 items"}))}function eC(e){return i.Qrq(e)}function eT(e){return e.pipe(i.usV({[eI]:"invalid_type",messageMissingKey:"Invalid input: expected string, received undefined"}))}function eM(e){return e.pipe(i.usV({[eI]:"invalid_type",messageMissingKey:"Invalid input: expected object, received undefined"}))}function eA(e){return e.pipe(i.usV({[eI]:"invalid_type",messageMissingKey:"Invalid input: expected array, received undefined"}))}function eN(e){return i.xCb(e).annotate({message:`Invalid option: expected one of ${e.map(e=>JSON.stringify(e)).join("|")}`})}function eP(e){return eD(e,i.QfV)}function eR(e){return eD(e,i.wNn)}function ej(e){return eD(e,i.v8c)}function eD(e,t){let r=i.hzj()([],()=>(t,r,n)=>t===e?s.PyW(e):s.fJG(new c.eE(r,t,n)),{message:`Invalid literal value, expected ${JSON.stringify(e)}`,toCodecJson:()=>i.nfo()(t.annotate({const:e}),{decode:f.pd(()=>e),encode:f.pd(e=>e)})});return i.uSQ(e).pipe(i.GLL(r))}let eU=i.QfV.check(i.tJb(1,{message:"Too small: expected string to have >=1 characters"})),eF=eT(eU),eB=i.wYs,eL=i.wNn.check(i.MIs(),i.yJO(0,{message:"Too small: expected number to be >0"})),ez=/^#[0-9a-fA-F]{6}$/u;function eW(e){return i.QfV.annotate(void 0===e?{}:{default:e}).check(i.Pto(ez,{message:`Invalid string: must match pattern /${ez.source}/`}))}let eJ=eW();e_(eJ);let eY=["excalidraw","scene","png"],eX=["excalidraw","scene"],eq=Object.assign(e_(eN(eY)),{options:eY}),eG=Object.assign(e_(eN(eX)),{options:eX});class eV extends i.Xsx("ArtifactProvenance")({sourceArtifactId:eF.pipe(i.Wa3)},{identifier:void 0}){}e_(eV);let eH=["missing_field","invalid_type","invalid_enum","invalid_color","duplicate_node_id","duplicate_edge_id","missing_edge_source","missing_edge_target","self_loop","missing_start","multiple_starts","missing_end","start_has_incoming","end_has_outgoing","unreachable_node","nonterminating_node","missing_outgoing_edge","underbranched_decision","unlabeled_decision_branch","duplicate_decision_branch_label","disconnected_graph","flowchart_too_large","mindmap_too_deep","mindmap_too_large","request_too_large","generic_label","label_too_long","quality_below_threshold","render_failed","text_overflow","arrow_binding_invalid","arrow_overlap","export_invalid_scene","storage_read_failed","storage_write_failed","unsupported_artifact_format","patch_source_unavailable","unknown_patch_target","unsupported_patch_operation","patch_preserve_connectivity_failed","patch_output_invalid","duplicate_element_id","duplicate_layer_id","invalid_canvas_binding","invalid_canvas_composition","invalid_canvas_geometry","invalid_polygon","canvas_limit_exceeded","invalid_z_order","unknown_layout_target"],eK=Object.assign(e_(eN(eH)),{options:eH}),eQ=eN(["request","diagram","node","edge","element","layer","artifact"]),eZ=eN(["input","canvas","flowchart","mindmap","quality","render","export","storage"]);class e0 extends i.Xsx("CodeModeIssueRef")({kind:eQ,id:eC(eU),path:eC(eU)},{identifier:void 0}){}e_(e0);class e1 extends i.Xsx("CodeModeIssue")({code:eK,severity:eN(["error","warning"]),stage:eZ,ref:eC(e0),message:eF,hint:eF},{identifier:void 0}){}let e2=e_(e1),e5=["start","process","decision","end"],e3=Object.assign(e_(eN(e5)),{options:e5}),e6=["setDefaultStyle","setStyle","setShape","translate","replaceText","rerouteEdges","insert","remove","replace","reorder","group","ungroup"];Object.assign(e_(eN(e6)),{options:e6});class e8 extends i.Xsx("FlowchartSpecNode")({id:eF,label:eF,kind:e3,description:eC(eU)},{identifier:void 0}){}class e9 extends i.Xsx("FlowchartSpecEdge")({id:eC(eU),source:eF,target:eF,label:eC(eU)},{identifier:void 0}){}let e4=eN(["TB","LR"]),e7=e4.annotate({default:"TB"}).pipe(i.E$i(s.PyW("TB")));class te extends i.Xsx("FlowchartSpecLayout")({direction:e7},{identifier:void 0}){}let tt=g.accentColor,tr=eW(tt).pipe(i.E$i(s.PyW(tt))),tn=g.backgroundColor,ti=eW(tn).pipe(i.E$i(s.PyW(tn)));class ta extends i.Xsx("FlowchartSpecStyle")({accentColor:tr,backgroundColor:ti},{identifier:void 0}){}let ts=[],to=i.O31(e9).pipe(i.fXn).annotate({default:ts}).pipe(i.E$i(s.PyW(ts))),tl={direction:"TB"},td=te.annotate({default:tl}).pipe(i.E$i(s.PyW(tl)),i.usV({[ew]:tl})),tc={accentColor:g.accentColor,backgroundColor:g.backgroundColor},tu=ta.annotate({default:tc}).pipe(i.E$i(s.PyW(tc)),i.usV({[ew]:tc}));class tf extends i.Xsx("FlowchartSpec")({id:eC(eU),title:eF,nodes:eA(eO(e8)),edges:to,layout:td,style:tu},{identifier:void 0}){}e_(tf),e_(e8),e_(e9),e_(te),e_(ta);class tp extends i.Xsx("SequenceParticipantSpec")({id:eF,label:eF,kind:eC(eU)},{identifier:void 0}){}class th extends i.Xsx("SequenceMessageSpec")({id:eC(eU),source:eF,target:eF,label:eF,type:eC(eN(["message","return"])),style:eC(eN(["solid","dashed"]))},{identifier:void 0}){}let tm=[],tg=i.O31(th).pipe(i.fXn).annotate({default:tm}).pipe(i.E$i(s.PyW(tm)));class ty extends i.Xsx("SequenceDiagramSpec")({id:eC(eU),title:eF,participants:eA(eO(tp)),messages:tg,style:tu},{identifier:void 0}){}e_(ty),e_(tp),e_(th);let tv=eC(eO(eq)),tb=eC(i.O31(eG).pipe(i.fXn)),t_=eC(i.wNn.check(i.MIs(),i.OWK(0,{message:"Too small: expected number to be >=0"}),i.biW(10,{message:"Too big: expected number to be <=10"})));class tx extends i.Xsx("BuildFlowchartOptions")({artifactFormats:tv,inlineArtifacts:tb,minQualityScore:t_},{identifier:void 0}){}e_(eC(tx));class tw extends i.Xsx("BuildFlowchartRequest")({requestId:eC(eU),spec:eM(tf),options:eC(tx)},{identifier:void 0}){}let tk=tf.mapFields(({id:e,title:t,nodes:r,edges:n,layout:i})=>({id:e,title:t,nodes:r,edges:n,layout:i})),tS=i._kM({requestId:eC(eU),spec:eM(tk)}),tI=i.rcy(tS,{leafHook:ey,parseOptions:{errors:"all"}}),t$=Object.assign(tI,{"~standard":{...tI["~standard"],jsonSchema:{input:()=>eE(tS),output:()=>eE(tS)}}}),tE=Object.assign(e_(tw),{omit:e=>t$});class tO extends i.Xsx("BuildSequenceDiagramRequest")({requestId:eC(eU),spec:eM(ty),options:eC(tx)},{identifier:void 0}){}let tC=e_(tO),tT=i.QfV.check(i.tJb(1,{message:"Too small: expected string to have >=1 characters"}),i.HNH(function(e){let t=eh(e);return t.length>0&&!/^(?:""|''|``)$/.test(t)},{message:"Must contain semantic text after normalization."})),tM=eM(i.DYE(()=>tA).annotate({identifier:"__schema0"})),tA=i._kM({label:eT(tT),children:i.Qrq(i.O31(tM).pipe(i.fXn))});e_(tM);class tN extends i.Xsx("MindmapSpecLayout")({direction:eN(["LR","RL"]).annotate({default:"LR"}).pipe(i.E$i(s.PyW("LR")))},{identifier:void 0}){}let tP={direction:"LR"},tR=tN.annotate({default:tP}).pipe(i.E$i(s.PyW(tP)),i.usV({[ew]:tP})),tj=i._kM({id:eC(eU),title:eT(tT),root:tM,layout:tR,style:tu});class tD extends i.Xsx("MindmapSpec")(tj,{identifier:void 0}){}e_(tD);let tU=i._kM({requestId:eC(eU),spec:eM(tj),options:eC(tx)});i.Xsx("BuildMindmapRequest")(tU,{identifier:void 0});let tF=e_(tU);class tB extends i.Xsx("ScenePoint")({x:eB.pipe(i.Wa3),y:eB.pipe(i.Wa3)},{identifier:void 0}){}e_(tB);let tL={frameId:eC(eU).pipe(i.Wa3),groupIds:eC(i.O31(eU).pipe(i.fXn).annotate({maxItems:er.maxGroupsPerElement})).pipe(i.Wa3),layerId:eC(eU).pipe(i.Wa3),locked:eC(i.v8c).pipe(i.Wa3),opacity:eC(i.wNn.check(i.MIs(),i.Bt9({minimum:0,maximum:100}))).pipe(i.Wa3),zIndex:eC(i.Aiz).pipe(i.Wa3)},tz={fillColor:eC(eJ).pipe(i.Wa3),fillStyle:eC(eN(["cross-hatch","hachure","solid"])).pipe(i.Wa3),roughness:eC(eN([0,1,2])).pipe(i.Wa3),strokeColor:eC(eJ).pipe(i.Wa3),strokeStyle:eC(eN(["dashed","dotted","solid"])).pipe(i.Wa3),strokeWidth:eC(eN([1,2,4])).pipe(i.Wa3)},tW=i.T9y(eN(["arrow","bar","circle","diamond","triangle"])),tJ=i.O31(tB).pipe(i.fXn).check(i.tJb(2,{message:"Too small: expected array to have >=2 items"}),i.NYj(er.maxPointsPerElement,{message:`Too big: expected array to have <=${er.maxPointsPerElement} items`}));class tY extends i.Xsx("NodeSceneElement")({...tL,...tz,type:eP("node"),id:eF,nodeId:eF,kind:eC(eU),rendererRole:eC(eN(["sequence-lifeline"])),shape:eN(["rectangle","ellipse","diamond","circle","polygon"]).pipe(i.Wa3),points:eC(tJ).pipe(i.Wa3),textColor:eC(eJ).pipe(i.Wa3),x:eB.pipe(i.Wa3),y:eB.pipe(i.Wa3),width:eL.pipe(i.Wa3),height:eL.pipe(i.Wa3),label:eF.pipe(i.Wa3)},{identifier:void 0}){}class tX extends i.Xsx("TextSceneElement")({...tL,type:eP("text"),id:eF,containerId:eC(eU),textColor:eC(eJ).pipe(i.Wa3),x:eB.pipe(i.Wa3),y:eB.pipe(i.Wa3),text:eF.pipe(i.Wa3),fontSize:eL,fontFamily:eC(eN(["hand","mono","sans"])),maxWidth:eC(eL),textAlign:eC(eN(["center","left","right"])),verticalAlign:eC(eN(["bottom","middle","top"]))},{identifier:void 0}){}class tq extends i.Xsx("ArrowSceneElement")({...tL,...tz,type:eP("arrow"),id:eF,edgeId:eF,sourceNodeId:eF,targetNodeId:eF.pipe(i.Wa3),startArrowhead:eC(tW).pipe(i.Wa3),endArrowhead:eC(tW).pipe(i.Wa3),textColor:eC(eJ).pipe(i.Wa3),points:eA(tJ).pipe(i.Wa3),label:eC(eU).pipe(i.Wa3)},{identifier:void 0}){}class tG extends i.Xsx("CanvasLineBinding")({elementId:eF,focus:eC(eB),gap:eC(eB)},{identifier:void 0}){}class tV extends i.Xsx("LineSceneElement")({...tL,...tz,type:eP("line"),id:eF,points:eA(tJ).pipe(i.Wa3),startBinding:eC(tG).pipe(i.Wa3),endBinding:eC(tG).pipe(i.Wa3),startArrowhead:eC(tW).pipe(i.Wa3),endArrowhead:eC(tW).pipe(i.Wa3),label:eC(eU).pipe(i.Wa3),textColor:eC(eJ).pipe(i.Wa3)},{identifier:void 0}){}class tH extends i.Xsx("FrameSceneElement")({...tL,...tz,type:eP("frame"),id:eF,name:eC(eU).pipe(i.Wa3),x:eB.pipe(i.Wa3),y:eB.pipe(i.Wa3),width:eL.pipe(i.Wa3),height:eL.pipe(i.Wa3)},{identifier:void 0}){}class tK extends i.Xsx("CanvasLayer")({id:eF,name:eC(eU),locked:eC(i.v8c),visible:eC(i.v8c)},{identifier:void 0}){}let tQ=eA(eO(eU));class tZ extends i.Xsx("CanvasFlowLayout")({type:eN(["row","column","stack"]),ids:tQ,x:eC(eB),y:eC(eB),gap:eC(eB)},{identifier:void 0}){}class t0 extends i.Xsx("CanvasGridLayout")({type:eP("grid"),ids:tQ,columns:i.Aiz.check(i.OWK(1,{message:"Too small: expected number to be >=1"})),x:eC(eB),y:eC(eB),columnGap:eC(eB),rowGap:eC(eB)},{identifier:void 0}){}class t1 extends i.Xsx("CanvasAlignLayout")({type:eP("align"),ids:tQ,axis:eN(["x","y"]),alignment:eN(["center","end","start"])},{identifier:void 0}){}class t2 extends i.Xsx("CanvasDistributeLayout")({type:eP("distribute"),ids:tQ,axis:eN(["x","y"]),gap:eC(eB)},{identifier:void 0}){}e_(tY),e_(tX),e_(tq),e_(tV),e_(tH);let t5=i.gPz([tY,tX,tq,tV,tH],{mode:"oneOf"}).annotate({[ek]:!0}),t3=i.gPz([tZ,t0,t1,t2],{mode:"oneOf"}),t6=i.O31(tK).pipe(i.fXn).annotate({default:[],maxItems:er.maxLayers}).pipe(i.E$i(s.PyW([]))),t8=i.O31(t3).pipe(i.fXn).annotate({default:[],maxItems:er.maxLayouts}).pipe(i.E$i(s.PyW([]))),t9=i.O31(eU).pipe(i.fXn).annotate({default:[],maxItems:er.maxZOrderEntries}).pipe(i.E$i(s.PyW([])));class t4 extends i.Xsx("CanvasSpec")({kind:eP("canvas"),version:eR(1),diagramId:eF,title:eF,width:eL.pipe(i.Wa3),height:eL.pipe(i.Wa3),accentColor:eJ.pipe(i.Wa3),backgroundColor:eJ.pipe(i.Wa3),elements:eA(i.O31(t5).pipe(i.fXn).annotate({maxItems:er.maxElements})),layers:t6,layouts:t8,zOrder:t9},{identifier:void 0}){}let t7=e_(t4);class re extends i.Xsx("CreateCanvasRequest")({requestId:eC(eU),spec:eM(t4),options:eC(tx)},{identifier:void 0}){}let rt=e_(re),rr=i.mSG(i.QfV,i.$r1).check(i.HNH(e=>"string"==typeof e.id&&e.id.length>0&&"string"==typeof e.type&&e.type.length>0,{message:"Invalid input"}));e_(rr);class rn extends i.Xsx("ExcalidrawScene")({appState:i.mSG(i.QfV,i.$r1),elements:i.O31(rr).pipe(i.fXn)},{identifier:void 0}){}e_(rn);class ri extends rn.extend("ExcalidrawFile")({files:i.mSG(i.QfV,i.$r1),source:eF,type:eP("excalidraw"),version:eR(2)},{identifier:void 0}){}let ra=e_(ri);class rs extends i.Xsx("GetArtifactRequest")({artifactId:eF,format:eC(eq),inline:eC(i.v8c)},{identifier:void 0}){}let ro=e_(rs);class rl extends i.Xsx("DiagramSelector")({ids:eC(i.O31(eU).pipe(i.fXn)),nodeIds:eC(i.O31(eU).pipe(i.fXn)),edgeIds:eC(i.O31(eU).pipe(i.fXn)),kinds:eC(i.O31(e3).pipe(i.fXn)),labels:eC(i.O31(eU).pipe(i.fXn)),scope:eC(eN(["all","nodes","edges"]))},{identifier:void 0}){}e_(rl);class rd extends i.Xsx("DiagramStylePatch")({strokeColor:eC(eJ),fillColor:eC(eJ),textColor:eC(eJ),backgroundColor:eC(eJ)},{identifier:void 0}){}e_(rd);let rc=["rectangle","diamond","ellipse","circle","polygon"],ru=Object.assign(e_(eN(rc)),{options:rc});class rf extends i.Xsx("SetDefaultStyleOperation")({op:eP("setDefaultStyle"),style:eM(rd)},{identifier:void 0}){}class rp extends i.Xsx("SetStyleOperation")({op:eP("setStyle"),selector:eM(rl),style:eM(rd)},{identifier:void 0}){}class rh extends i.Xsx("SetShapeOperation")({op:eP("setShape"),selector:eM(rl),shape:ru},{identifier:void 0}){}class rm extends i.Xsx("TranslateOperation")({op:eP("translate"),selector:eM(rl),dx:eB,dy:eB},{identifier:void 0}){}class rg extends i.Xsx("ReplaceTextOperation")({op:eP("replaceText"),selector:eM(rl),text:eF},{identifier:void 0}){}class ry extends i.Xsx("RerouteEdgesOperation")({op:eP("rerouteEdges"),selector:eC(rl)},{identifier:void 0}){}let rv=eA(eO(eU));class rb extends i.Xsx("InsertElementsOperation")({op:eP("insert"),elements:eA(eO(t5)),beforeId:eC(eU),afterId:eC(eU)},{identifier:void 0}){}class r_ extends i.Xsx("RemoveElementsOperation")({op:eP("remove"),selector:eM(rl)},{identifier:void 0}){}class rx extends i.Xsx("ReplaceElementOperation")({op:eP("replace"),id:eF,element:eM(t5)},{identifier:void 0}){}class rw extends i.Xsx("ReorderElementsOperation")({op:eP("reorder"),ids:rv,beforeId:eC(eU),afterId:eC(eU)},{identifier:void 0}){}class rk extends i.Xsx("GroupElementsOperation")({op:eP("group"),ids:rv,groupId:eF},{identifier:void 0}){}class rS extends i.Xsx("UngroupElementsOperation")({op:eP("ungroup"),ids:rv,groupId:eC(eU)},{identifier:void 0}){}let rI=i.gPz([rf,rp,rh,rm,rg,ry,rb,r_,rx,rw,rk,rS],{mode:"oneOf"}).annotate({[ek]:!0,[eS]:"op",message:`Invalid discriminator value. Expected ${e6.map(e=>`'${e}'`).join(" | ")}`});class r$ extends i.Xsx("ArtifactPatchSource")({artifactId:eF,format:eC(eP("scene"))},{identifier:void 0}){}class rE extends i.Xsx("InlineScenePatchSource")({scene:eM(t4)},{identifier:void 0}){}let rO=i.gPz([r$,rE]).annotate({message:"Invalid input"});class rC extends i.Xsx("ApplyDiagramPatchOptions")({artifactFormats:tv,inlineArtifacts:tb,preserveConnectivity:eC(i.v8c)},{identifier:void 0}){}e_(eC(rC));class rT extends i.Xsx("ApplyDiagramPatchRequest")({requestId:eC(eU),source:rO.annotateKey({messageMissingKey:"Invalid input"}),operations:eA(eO(rI)),options:eC(rC),intent:eC(eU)},{identifier:void 0}){}let rM=e_(rT);class rA extends i.Xsx("NormalizedMindmapTopic")({id:eU,label:eU,children:i.O31(i.DYE(()=>rA)).pipe(i.fXn)},{identifier:void 0}){}let rN=i._kM({id:eU,title:eU,nodes:i.O31(e8).pipe(i.fXn),edges:i.O31(e9.mapFields(e=>({...e,id:eU}))).pipe(i.fXn),layout:i._kM({direction:e4}),style:i._kM({accentColor:eJ,backgroundColor:eJ})}),rP=i._kM({id:eU,title:eU,root:rA,layout:i._kM({direction:eN(["LR","RL"])}),style:i._kM({accentColor:eJ,backgroundColor:eJ})}),rR=i._kM({id:eU,title:eU,participants:i.O31(tp).pipe(i.fXn),messages:i.O31(th.mapFields(e=>({...e,id:eU}))).pipe(i.fXn),style:i._kM({accentColor:eJ,backgroundColor:eJ})}),rj=i._kM({code:i.QfV,passed:i.v8c,severity:eN(["error","warning"]),message:i.QfV,refs:i.O31(e0).pipe(i.fXn)}),rD=i._kM({accepted:i.v8c,score:i.wNn,threshold:i.wNn,summary:i._kM({nodeCount:i.wNn,edgeCount:i.wNn}),checks:i.O31(rj).pipe(i.fXn)}),rU=i._kM({format:eq,mimeType:i.QfV,url:eC(i.QfV),expiresAt:eC(i.QfV),inline:eC(i.$r1),sizeBytes:eC(i.wNn)}),rF=i._kM({artifactId:i.QfV,diagramId:i.QfV,formats:i.O31(rU).pipe(i.fXn),provenance:eC(eV),preview:eC(rU)}),rB=i._kM({artifactId:eC(i.QfV),diagramId:eC(i.QfV),formats:eC(i.O31(rU).pipe(i.fXn))});class rL extends i.Xsx("BuildFlowchartAccepted")({ok:ej(!0),status:eP("accepted"),buildId:i.QfV,requestId:eC(i.QfV),normalizedSpec:rN,quality:rD,artifact:rF,issues:i.O31(e1).pipe(i.fXn)},{identifier:void 0}){}class rz extends i.Xsx("BuildFlowchartRejected")({ok:ej(!1),status:eN(["invalid_input","invalid_flowchart","quality_failed","render_failed","export_failed","storage_failed"]),buildId:eC(i.QfV),requestId:eC(i.QfV),normalizedSpec:eC(rN),quality:eC(rD),partial:eC(rB),issues:i.O31(e1).pipe(i.fXn)},{identifier:void 0}){}i.gPz([rL,rz]);class rW extends i.Xsx("BuildMindmapAccepted")({ok:ej(!0),status:eP("accepted"),buildId:i.QfV,requestId:eC(i.QfV),normalizedSpec:rP,quality:rD,artifact:rF,issues:i.O31(e1).pipe(i.fXn)},{identifier:void 0}){}class rJ extends i.Xsx("BuildMindmapRejected")({ok:ej(!1),status:eN(["invalid_input","invalid_mindmap","quality_failed","render_failed","export_failed","storage_failed"]),buildId:eC(i.QfV),requestId:eC(i.QfV),normalizedSpec:eC(rP),quality:eC(rD),partial:eC(rB),issues:i.O31(e1).pipe(i.fXn)},{identifier:void 0}){}i.gPz([rW,rJ]);class rY extends i.Xsx("BuildSequenceDiagramAccepted")({ok:ej(!0),status:eP("accepted"),buildId:i.QfV,requestId:eC(i.QfV),normalizedSpec:rR,quality:rD,artifact:rF,issues:i.O31(e1).pipe(i.fXn)},{identifier:void 0}){}class rX extends i.Xsx("BuildSequenceDiagramRejected")({ok:ej(!1),status:eN(["invalid_input","invalid_sequence","quality_failed","render_failed","export_failed","storage_failed"]),buildId:eC(i.QfV),requestId:eC(i.QfV),normalizedSpec:eC(rR),quality:eC(rD),partial:eC(rB),issues:i.O31(e1).pipe(i.fXn)},{identifier:void 0}){}i.gPz([rY,rX]);class rq extends i.Xsx("GetArtifactAccepted")({ok:ej(!0),artifactId:i.QfV,diagramId:i.QfV,format:eq,mimeType:i.QfV,url:eC(i.QfV),expiresAt:eC(i.QfV),inline:eC(i.$r1),sizeBytes:eC(i.wNn),provenance:eC(eV)},{identifier:void 0}){}class rG extends i.Xsx("GetArtifactRejected")({ok:ej(!1),status:eN(["invalid_input","not_found","format_unavailable","expired","storage_failed"]),issues:i.O31(e1).pipe(i.fXn)},{identifier:void 0}){}i.gPz([rq,rG]);class rV extends i.Xsx("ApplyDiagramPatchAccepted")({ok:ej(!0),status:eP("accepted"),patchId:i.QfV,requestId:eC(i.QfV),sourceArtifactId:eC(i.QfV),artifact:rF,issues:i.O31(e1).pipe(i.fXn)},{identifier:void 0}){}class rH extends i.Xsx("ApplyDiagramPatchRejected")({ok:ej(!1),status:eN(["invalid_input","source_unavailable","target_not_found","unsupported_operation","connectivity_changed","render_failed","export_failed","storage_failed"]),patchId:eC(i.QfV),requestId:eC(i.QfV),sourceArtifactId:eC(i.QfV),partial:eC(rB),issues:i.O31(e1).pipe(i.fXn)},{identifier:void 0}){}i.gPz([rV,rH]);class rK extends i.Xsx("CreateCanvasAccepted")({ok:ej(!0),status:eP("accepted"),buildId:i.QfV,requestId:eC(i.QfV),normalizedSpec:t4,artifact:rF,issues:i.O31(e1).pipe(i.fXn)},{identifier:void 0}){}class rQ extends i.Xsx("CreateCanvasRejected")({ok:ej(!1),status:eN(["invalid_input","invalid_canvas","limit_exceeded","render_failed","export_failed","storage_failed"]),buildId:eC(i.QfV),requestId:eC(i.QfV),normalizedSpec:eC(t4),partial:eC(rB),issues:i.O31(e1).pipe(i.fXn)},{identifier:void 0}){}let rZ=i.gPz([rK,rQ]),r0=i.xCb(["read","readManifest","write"]);class r1 extends i.rNF()("CodeModeArtifactStorageError",{cause:i.kld(),message:i.QfV,operation:r0}){}class r2 extends a.kl()("@sketchi/diagram-agent/CodeModeArtifactStorage"){}let r5={excalidraw:"application/vnd.excalidraw+json",png:"image/png",scene:"application/vnd.sketchi.scene+json"};function r3(e){return"excalidraw"===e||"scene"===e}function r6(e){return{format:e.format,mimeType:e.mimeType,sizeBytes:e.sizeBytes}}function r8(e){return new TextEncoder().encode(JSON.stringify(e)).length}let r9=l.QZ(r2)(s.Q56(s.OH5(function(){let e=new Map,t=new Map;return{close:s.OH5(()=>{t.clear(),e.clear()}),storage:{read:s.fn("codeMode.artifacts.memory.read")(function*(e,r){return yield*s.OH5(()=>{let n=t.get(`${e}:${r}`);return n?{...n,data:structuredClone(n.data)}:null})}),readManifest:s.fn("codeMode.artifacts.memory.readManifest")(function*(t){return yield*s.OH5(()=>{let r=e.get(t);return r?structuredClone(r):null})}),write:s.fn("codeMode.artifacts.memory.write")(function*(r){var n;let i=yield*o.Ru;return yield*s.SvU({try:()=>{var n;let a,s=r.formats.map(r6),o=r.provenance?structuredClone(r.provenance):void 0,l={artifactId:r.artifactId,diagramId:r.diagramId,formats:s,...o?{provenance:o}:{},createdAt:new Date(i).toISOString()};for(let n of(e.set(r.artifactId,l),r.formats))t.set(`${r.artifactId}:${n.format}`,{...n,data:structuredClone(n.data)});let d=r.formats.map(e=>{var t;return t=r.inlineFormats,{format:e.format,mimeType:e.mimeType,...r3(e.format)&&t.includes(e.format)?{inline:e.data}:{},sizeBytes:e.sizeBytes}});return a=(n={artifactId:r.artifactId,diagramId:r.diagramId,formats:d,...r.provenance?{provenance:structuredClone(r.provenance)}:{}}).formats.find(e=>"scene"===e.format),{artifactId:n.artifactId,diagramId:n.diagramId,formats:n.formats,...n.provenance?{provenance:n.provenance}:{},...a?{preview:a}:{}}},catch:(n="write",e=>{var t;return r1.make({cause:e,message:(t="Artifact storage failed.",e instanceof Error?e.message:t),operation:n})})})})}}}),e=>e.close).pipe(s.TjK(e=>e.storage)));function r4(e,t="storage_write_failed"){return{code:t,severity:"error",stage:"storage",message:e,hint:"Retry the request; if it keeps failing, inspect the artifact store binding."}}function r7(e){return new Map(e.map((e,t)=>[e.id,t]))}function ne(e){return{type:"text",id:`label:${e.nodeId}`,containerId:e.id,x:e.x+e.width/2,y:e.y+e.height/2,text:e.label,fontSize:14,maxWidth:Math.max(1,e.width-36)}}function nt(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}function nr(e,t,r){return Math.min(r,Math.max(t,e))}function nn(e,t,r=0){let n,i=(n="top"===t||"bottom"===t?e.width/2-16:e.height/2-16)>0?nr(r,-n,n):0,a=nt(e),s=e.width/2,o=e.height/2;if("diamond"===e.shape&&s>0&&o>0){if("top"===t||"bottom"===t){let e=a.x+i,r=o*(1-Math.abs(i)/s);return{x:e,y:"top"===t?a.y-r:a.y+r}}let e=a.y+i,r=s*(1-Math.abs(i)/o);return{x:"left"===t?a.x-r:a.x+r,y:e}}if(("ellipse"===e.shape||"circle"===e.shape)&&s>0&&o>0){if("top"===t||"bottom"===t){let e=a.x+i,r=o*Math.sqrt(Math.max(0,1-(i/s)**2));return{x:e,y:"top"===t?a.y-r:a.y+r}}let e=a.y+i,r=s*Math.sqrt(Math.max(0,1-(i/o)**2));return{x:"left"===t?a.x-r:a.x+r,y:e}}switch(t){case"top":return{x:e.x+e.width/2+i,y:e.y};case"right":return{x:e.x+e.width,y:e.y+e.height/2+i};case"bottom":return{x:e.x+e.width/2+i,y:e.y+e.height};case"left":return{x:e.x,y:e.y+e.height/2+i}}}function ni(e){return`${e.edgeId}:${e.endpoint}`}function na(e){let t=[];for(let r of e){let e=t[t.length-1];e&&e.x===r.x&&e.y===r.y||t.push(r)}let r=t[0];return r?[r,...t.slice(1)]:[{x:0,y:0}]}function ns(e,t,r){return e>t+.01&&e<r-.01}function no(e,t,r,n){return Math.min(t,n)-Math.max(e,r)>.01}function nl(e,t,r){let n=0;for(let i=0;i<e.length-1;i+=1){let a=e[i],s=e[i+1];if(a&&s)for(let e of t)!r.has(e.nodeId)&&(a.y===s.y?ns(a.y,e.y,e.y+e.height)&&no(Math.min(a.x,s.x),Math.max(a.x,s.x),e.x,e.x+e.width):a.x===s.x&&ns(a.x,e.x,e.x+e.width)&&no(Math.min(a.y,s.y),Math.max(a.y,s.y),e.y,e.y+e.height))&&(n+=1)}return n}function nd(e){let t=0;for(let r=0;r<e.length-1;r+=1){let n=e[r],i=e[r+1];n&&i&&(t+=Math.abs(i.x-n.x)+Math.abs(i.y-n.y))}return t}function nc(e){let t=[];for(let r=0;r<e.points.length-1;r+=1){let n=e.points[r],i=e.points[r+1];if(n&&i){if(n.y===i.y){t.push({arrowId:e.arrowId,isFirstSegment:0===r,isLastSegment:r===e.points.length-2,max:Math.max(n.x,i.x),min:Math.min(n.x,i.x),orientation:"horizontal",segmentIndex:r,sourceNodeId:e.sourceNodeId,staticCoordinate:n.y,targetNodeId:e.targetNodeId});continue}n.x===i.x&&t.push({arrowId:e.arrowId,isFirstSegment:0===r,isLastSegment:r===e.points.length-2,max:Math.max(n.y,i.y),min:Math.min(n.y,i.y),orientation:"vertical",segmentIndex:r,sourceNodeId:e.sourceNodeId,staticCoordinate:n.x,targetNodeId:e.targetNodeId})}}return t.filter(e=>e.max-e.min>.01)}function nu(e,t){return Math.min(e.max,t.max)-Math.max(e.min,t.min)}function nf(e,t,r){let n=nc({arrowId:`edge:${r.edge.id}`,points:e,sourceNodeId:r.edge.source,targetNodeId:r.edge.target}),i=t.flatMap(e=>nc({arrowId:e.id,points:e.points,sourceNodeId:e.sourceNodeId,targetNodeId:e.targetNodeId})),a=0;for(let e of n)for(let t of i)e.arrowId===t.arrowId||e.orientation!==t.orientation||Math.abs(e.staticCoordinate-t.staticCoordinate)>.01||e.isFirstSegment&&t.isFirstSegment&&e.sourceNodeId===t.sourceNodeId||e.isLastSegment&&t.isLastSegment&&e.targetNodeId===t.targetNodeId||.01>=nu(e,t)||(a+=1);return a}function np(e,t){let r=nc({arrowId:`edge:${t.edge.id}`,points:e,sourceNodeId:t.edge.source,targetNodeId:t.edge.target}),n=0;for(let e=0;e<r.length;e+=1){let t=r[e];if(t)for(let i=e+1;i<r.length;i+=1){let e=r[i];!e||t.orientation!==e.orientation||Math.abs(t.staticCoordinate-e.staticCoordinate)>.01||.01>=nu(t,e)||(n+=1)}}return n}function nh(e){let t=e[0],r=e[e.length-1];if(!t||!r)return 0;let n=e.map(e=>e.x),i=e.map(e=>e.y),a=0;return r.x<t.x?a+=Math.max(0,Math.max(...n)-t.x):r.x>t.x&&(a+=Math.max(0,t.x-Math.min(...n))),r.y<t.y?a+=Math.max(0,Math.max(...i)-t.y):r.y>t.y&&(a+=Math.max(0,t.y-Math.min(...i))),a}function nm(e){let t=e[0],r=e[e.length-1];if(!t||!r)return 0;let n=e.map(e=>e.x),i=e.map(e=>e.y),a=0;return r.x<t.x?a+=Math.max(0,r.x-Math.min(...n)):r.x>t.x&&(a+=Math.max(0,Math.max(...n)-r.x)),r.y<t.y?a+=Math.max(0,r.y-Math.min(...i)):r.y>t.y&&(a+=Math.max(0,Math.max(...i)-r.y)),a}function ng(e,t,r){switch(r){case"top":return t.y<e.y;case"right":return t.x>e.x;case"bottom":return t.y>e.y;case"left":return t.x<e.x}}function ny(e,t){let r=e[0],n=e[1],i=e[e.length-1],a=e[e.length-2],s=0;return n&&ng(r,n,t.sourceEdge)&&(s+=1),a&&i&&ng(i,a,t.targetEdge)&&(s+=1),s}function nv(e,t,r){switch(t){case"top":return{x:e.x,y:e.y-r};case"right":return{x:e.x+r,y:e.y};case"bottom":return{x:e.x,y:e.y+r};case"left":return{x:e.x-r,y:e.y}}}function nb(e,t,r,n,i){var a;let s,o=Math.abs(r.x-t.x)>=Math.abs(r.y-t.y),l=new Set([e.source.nodeId,e.target.nodeId]),d=Math.min(...n.map(e=>e.x)),c=Math.max(...n.map(e=>e.x+e.width)),u=Math.min(...n.map(e=>e.y)),f=Math.max(...n.map(e=>e.y+e.height)),p="left"===e.sourceEdge||"left"===e.targetEdge||nt(e.target).x<nt(e.source).x,h="top"===e.sourceEdge||"top"===e.targetEdge||nt(e.source).y<=nt(e.target).y,m=18*e.index,g=d-56-m,y=c+56+m,v=u-48-m,b=f+48+m,_=e.index%4*18/2,x=Math.min(e.source.x,e.target.x)-56-_,w=Math.max(e.source.x+e.source.width,e.target.x+e.target.width)+56+_,k=Math.min(e.source.y,e.target.y)-48-_,S=Math.max(e.source.y+e.source.height,e.target.y+e.target.height)+48+_,I=p?g:y,$=p?y:g,E=h?v:b,O=h?b:v,C=p?x:w,T=p?w:x,M=h?k:S,A=h?S:k,N=[0,36+e.index%4*18],P=(n,i)=>{let a=i>0?nv(t,e.sourceEdge,i):t,s=i>0?nv(r,e.targetEdge,i):r;return na([t,a,{x:n,y:a.y},{x:n,y:s.y},s,r])},R=(n,i)=>{let a=i>0?nv(t,e.sourceEdge,i):t,s=i>0?nv(r,e.targetEdge,i):r;return na([t,a,{x:a.x,y:n},{x:s.x,y:n},s,r])},j=[...N.map(e=>R(M,e)),...N.map(e=>R(A,e)),...N.map(e=>P(C,e)),...N.map(e=>P(T,e)),...N.map(e=>R(E,e)),...N.map(e=>R(O,e)),...N.map(e=>P(I,e)),...N.map(e=>P($,e))],D=[...N.map(e=>P(C,e)),...N.map(e=>P(T,e)),...N.map(e=>R(M,e)),...N.map(e=>R(A,e)),...N.map(e=>P(I,e)),...N.map(e=>P($,e)),...N.map(e=>R(E,e)),...N.map(e=>R(O,e))];return(s=(a=o?j:D)[0])?a.slice(1).reduce((t,r)=>{let a=nl(t,n,l),s=nl(r,n,l);if(s<a)return r;if(a<s)return t;let o=np(t,e),d=np(r,e);if(d<o)return r;if(o<d)return t;let c=nf(t,i,e),u=nf(r,i,e);if(u<c)return r;if(c<u)return t;let f=ny(t,e),p=ny(r,e);if(p>f)return r;if(f>p)return t;let h=nh(t),m=nh(r);if(m<h)return r;if(h<m)return t;let g=nm(t),y=nm(r);return y<g?r:g<y?t:nd(r)<nd(t)?r:t},s):[{x:0,y:0}]}function n_(e){return e.flatMap(e=>{if("arrow"===e.type||"line"===e.type)return[...e.points];if("text"===e.type){if(e.containerId)return[];let t=(e.maxWidth??e.text.length)/2,r=e.text.split("\n").length*e.fontSize*1.35/2;return[{x:e.x-t,y:e.y-r},{x:e.x+t,y:e.y+r}]}return[{x:e.x,y:e.y},{x:e.x+e.width,y:e.y+e.height}]})}function nx(e,t,r){return{x:e.x+t,y:e.y+r}}function nw(e){var t;let r,n,i,a,s,o=N(e),l=function(e){let t="TB"===e.layout.direction||"BT"===e.layout.direction,r=new Map(e.nodes.map(e=>{let t,r,n,i,a;return[e.id,(a=(i=e.label.split("\n").flatMap(e=>(function(e){if(e.length<=18)return[e];let t=[],r="";for(let n of e.split(" ")){if(n.length>18){r&&(t.push(r),r=""),t.push(...function(e){if(e.length<=18)return[e];let t=[];for(let r=0;r<e.length;r+=18)t.push(e.slice(r,r+18));return t}(n));continue}let e=r?`${r} ${n}`:n;if(e.length<=18){r=e;continue}t.push(r),r=n}return r&&t.push(r),t})(e)).join("\n")).split("\n"),t={text:i,width:Math.ceil(14*Math.max(...a.map(e=>e.length))*.62+36),height:Math.ceil(14*a.length*1.35+28)},n="start"===(r=e.kind?.toLowerCase())||"end"===r?"ellipse":"decision"===r?"diamond":"rectangle",{type:"node",id:`node:${e.id}`,nodeId:e.id,...e.kind?{kind:e.kind}:{},shape:n,x:0,y:0,width:Math.max(184,t.width+("diamond"===n?32:20*("ellipse"===n))),height:Math.max(72,t.height+32*("diamond"===n)),label:t.text})]})),n=function(e){let t=new Map,r=new Map;for(let n of e)t.set(n.target,[...t.get(n.target)??[],n]),r.set(n.source,[...r.get(n.source)??[],n]);return{incoming:t,outgoing:r}}(e.edges),i=function(e,t,r){let n=new Map,i=new Set;function a(e){for(let t of(n.set(e,"visiting"),r.get(e)??[])){let e=n.get(t.target);if("visiting"===e){i.add(t.id);continue}e||a(t.target)}n.set(e,"visited")}let s=e.nodes.find(e=>0===(t.get(e.id)??[]).length)??e.nodes[0];for(let t of(s&&a(s.id),e.nodes))n.has(t.id)||a(t.id);return i}(e,n.incoming,n.outgoing),a=function(e,t,r){let n=r7(e.nodes),i=new Map(e.nodes.map(e=>[e.id,0])),a=new Map(e.nodes.map(e=>[e.id,0]));for(let t of e.edges)r.has(t.id)||i.set(t.target,(i.get(t.target)??0)+1);let s=[];for(let t of e.nodes)(i.get(t.id)??0)===0&&s.push(t.id);let o=new Set;for(let e=0;e<s.length;e+=1){let l=s[e];if(!l||o.has(l))continue;o.add(l);let d=a.get(l)??0;for(let o of t.outgoing.get(l)??[]){if(r.has(o.id))continue;a.set(o.target,Math.max(a.get(o.target)??0,d+1));let t=(i.get(o.target)??0)-1;i.set(o.target,t),0===t&&function(e,t,r,n){let i=r.get(t)??Number.MAX_SAFE_INTEGER,a=e.findIndex((e,t)=>t>n&&(r.get(e)??Number.MAX_SAFE_INTEGER)>i);-1===a?e.push(t):e.splice(a,0,t)}(s,o.target,n,e)}}for(let n of e.nodes)!function e(n){if(o.has(n))return a.get(n)??0;let i=0;for(let a of t.incoming.get(n)??[])r.has(a.id)||(i=Math.max(i,e(a.source)+1));return o.add(n),a.set(n,i),i}(n.id);return a}(e,n,i),s=Array.from((function(e,t,r,n,i){let a=r7(e.nodes),s=new Map;for(let n of e.nodes){let e=r.get(n.id)??0,i=t.get(n.id);i&&s.set(e,[...s.get(e)??[],i])}for(let e=0;e<4;e+=1)for(let e of Array.from(s.keys()).sort((e,t)=>e-t)){let t=s.get(e);if(!t||t.length<2)continue;let r=new Map;(s.get(e-1)??[]).forEach((e,t)=>{r.set(e.nodeId,t)});let o=new Map;(s.get(e+1)??[]).forEach((e,t)=>{o.set(e.nodeId,t)});let l=e=>{let t=[...(n.incoming.get(e.nodeId)??[]).filter(e=>!i.has(e.id)).map(e=>r.get(e.source)).filter(e=>void 0!==e),...(n.outgoing.get(e.nodeId)??[]).filter(e=>!i.has(e.id)).map(e=>o.get(e.target)).filter(e=>void 0!==e)];return 0===t.length?a.get(e.nodeId)??Number.MAX_SAFE_INTEGER:t.reduce((e,t)=>e+t,0)/t.length};s.set(e,[...t].sort((e,t)=>{let r=l(e)-l(t);return Math.abs(r)>.001?r:(a.get(e.nodeId)??Number.MAX_SAFE_INTEGER)-(a.get(t.nodeId)??Number.MAX_SAFE_INTEGER)}))}return s})(e,r,a,n,i).entries()).sort(([e],[t])=>e-t).map(([e,r])=>({breadth:r.reduce((e,r,n)=>e+(t?r.width:r.height)+112*(n>0),0),depth:Math.max(...r.map(e=>t?e.height:e.width)),rank:e,shapes:r})),o=Math.max(...s.map(e=>e.breadth)),l=48,d=[];for(let e of s){let r=48+Math.max(0,o-e.breadth)/2;for(let n of e.shapes)t?(d.push({...n,x:r,y:l+Math.max(0,e.depth-n.height)/2}),r+=n.width+112):(d.push({...n,x:l+Math.max(0,e.depth-n.width)/2,y:r}),r+=n.height+112);l+=e.depth+96}if("BT"===e.layout.direction){let e=Math.max(...d.map(e=>e.y+e.height));return d.map(t=>({...t,y:48+e-t.y-t.height}))}if("RL"===e.layout.direction){let e=Math.max(...d.map(e=>e.x+e.width));return d.map(t=>({...t,x:48+e-t.x-t.width}))}return d}(o),d=new Map(l.map(e=>[e.nodeId,e])),c=o.edges.map((e,t)=>(function(e,t,r,n){let i=r.get(e.source),a=r.get(e.target);if(!i||!a)throw Error(`Cannot render edge "${e.id}" with unresolved nodes.`);let{sourceEdge:s,targetEdge:o}=function(e,t,r){let n=nt(e),i=nt(t),a=i.x-n.x,s=i.y-n.y,o=e.kind?.toLowerCase();if("LR"===r||"RL"===r)return a>=0?{sourceEdge:"right",targetEdge:"left"}:{sourceEdge:"left",targetEdge:"right"};if(s<0)return!(Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)>.01)&&Math.abs(a)>Math.abs(s)?{sourceEdge:a>0?"right":"left",targetEdge:"bottom"}:{sourceEdge:"top",targetEdge:"bottom"};let l="decision"===o&&s>e.height+96;return"decision"===o&&s>0&&(0!==a||l)?{sourceEdge:a<0?"left":"right",targetEdge:"top"}:s>0?{sourceEdge:"bottom",targetEdge:"top"}:Math.abs(a)>Math.abs(s)?a>0?{sourceEdge:"right",targetEdge:"left"}:{sourceEdge:"left",targetEdge:"right"}:{sourceEdge:"top",targetEdge:"bottom"}}(i,a,n);return{edge:e,index:t,source:i,sourceEdge:s,target:a,targetEdge:o}})(e,t,d,o.layout.direction)),u=function(e){let t=new Map;for(let s of e){var r,n,i,a;let e=(r=s.source.nodeId,n=s.sourceEdge,`${r}:${n}`),o=(i=s.target.nodeId,a=s.targetEdge,`${i}:${a}`);t.set(e,[...t.get(e)??[],{edgeId:s.edge.id,endpoint:"source"}]),t.set(o,[...t.get(o)??[],{edgeId:s.edge.id,endpoint:"target"}])}let s=new Map;for(let e of t.values())e.forEach((t,r)=>{s.set(ni(t),(r-(e.length-1)/2)*18)});return s}(c),f=[];for(let e of c)f.push(function(e,t,r,n,i,a){let{edge:s,source:o,sourceEdge:l,target:d,targetEdge:c}=e,u=nn(o,l,r.get(ni({edgeId:s.id,endpoint:"source"}))??0),f=nn(d,c,r.get(ni({edgeId:s.id,endpoint:"target"}))??0),p=na([u,f]);if(function(e,t,r){let n=nt(e),i=nt(t);switch(r){case"TB":return i.y<n.y;case"BT":return i.y>n.y;case"LR":return i.x<n.x;case"RL":return i.x>n.x}}(o,d,a))p=nb(e,u,f,n,i);else if("orthogonal"===t&&u.x!==f.x&&u.y!==f.y){var h,m,g;let t,r,n,i=e.index%4*18,a=(h=u.y,m=f.y,g=f.y<u.y?-i:i,t=h+(m-h)/2,(r=Math.min(h,m)+18)<(n=Math.max(h,m)-18)?nr(t+g,r,n):t),s="left"===l?{x:u.x-36-i,y:u.y}:"right"===l?{x:u.x+36+i,y:u.y}:u,o="left"===c?{x:f.x-36-i,y:f.y}:"right"===c?{x:f.x+36+i,y:f.y}:f;p=na([u,s,{x:s.x,y:a},{x:o.x,y:a},o,f])}return"orthogonal"===t&&(nl(p,n,new Set([o.nodeId,d.nodeId]))>0||np(p,e)>0||nf(p,i,e)>0)&&(p=nb(e,u,f,n,i)),{type:"arrow",id:`edge:${s.id}`,edgeId:s.id,sourceNodeId:s.source,targetNodeId:s.target,points:p,...s.label?{label:s.label}:{}}}(e,o.layout.edgeRouting,u,l,f,o.layout.direction));let p=l.map(ne),h=(i=Math.max(0,48-(n={x:Math.min(...(r=n_(t=[...f,...l,...p])).map(e=>e.x)),y:Math.min(...r.map(e=>e.y))}).x),a=Math.max(0,48-n.y),0===i&&0===a?[...t]:t.map(e=>"arrow"===e.type?{...e,points:function(e,t,r){let[n,...i]=e;return[nx(n,t,r),...i.map(e=>nx(e,t,r))]}(e.points,i,a)}:"line"===e.type?{...e,points:function(e,t,r){let[n,i,...a]=e;return[nx(n,t,r),nx(i,t,r),...a.map(e=>nx(e,t,r))]}(e.points,i,a)}:{...e,x:e.x+i,y:e.y+a})),m={width:Math.max(...(s=n_(h)).map(e=>e.x))+48,height:Math.max(...s.map(e=>e.y))+48},g=[...l.map(e=>e.id),...p.map(e=>e.id),...f.map(e=>e.id)];return{kind:"canvas",version:1,diagramId:o.id,title:o.title,width:m.width,height:m.height,accentColor:o.style.accentColor,backgroundColor:o.style.backgroundColor,elements:h,layers:[],layouts:[],zOrder:g}}let nk="sequence-lifeline";function nS(e){return`${e}:lifeline`}let nI="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",n$=nI.slice(10),nE=new Map;function nO(e){let t=nE.get(e);if(void 0===t){t=new Uint8Array(256);for(let r=0;r<e.length;r++)t[e.charCodeAt(r)]=r;nE.set(e,t)}return t}function nC(e,t,r,n){let i=r[0];if(null!=t&&e>=t)throw Error(e+" >= "+t);if(e.slice(-1)===i||t&&t.slice(-1)===i)throw Error("trailing zero");if(t){let a=0;for(;(e[a]||i)===t[a];)a++;if(a>0)return t.slice(0,a)+nC(e.slice(a),t.slice(a),r,n)}let a=e?n[e.charCodeAt(0)]:0,s=null!=t?n[t.charCodeAt(0)]:r.length;return s-a>1?r[Math.round(.5*(a+s))]:t&&t.length>1?t.slice(0,1):r[a]+nC(e.slice(1),null,r,n)}function nT(e,t,r){if(e.length!==nM(e[0],t,r))throw Error("invalid integer part of order key: "+e)}function nM(e,t,r){let n=r[e.charCodeAt(0)];if(t[n]===e){let e=t.length/2;return n<e?e-n+1:n-e+2}throw Error("invalid order key head: "+e)}function nA(e,t,r){let n=nM(e[0],t,r);if(n>e.length)throw Error("invalid order key: "+e);return e.slice(0,n)}function nN(e,t,r,n){if(nj(e,t,r))throw Error("invalid order key: "+e);let i=nA(e,r,n);if(e.slice(i.length).slice(-1)===t[0])throw Error("invalid order key: "+e)}function nP(e,t,r,n,i){nT(e,n,i);let a=e[0],s=t[0],o="";for(let n=e.length-1;n>=1;n--){let i=r[e.charCodeAt(n)]+1;if(i!==t.length)return a+e.slice(1,n)+t[i]+o;o=s+o}let l=i[a.charCodeAt(0)];if(l===n.length-1)return null;let d=n[l+1],c=nM(d,n,i)-nM(a,n,i);return d+(c>0?o+s:c<0?o.slice(1):o)}let nR=new Map;function nj(e,t,r){let n=nR.get(r);void 0===n&&(n=new Map,nR.set(r,n));let i=t.charCodeAt(0),a=n.get(i);return void 0===a&&(a=r[0]+t[0].repeat(r.length/2),n.set(i,a)),e===a}function nD(e){for(let t=1;t<e.length;t++)if(e.charCodeAt(t-1)>=e.charCodeAt(t))return!1;return!0}function nU(e){for(let t=0;t<e.length;t++)if(e.charCodeAt(t)>255)return!1;return!0}let nF=new Set,nB=new Set,nL=new Set(["rectangle","ellipse","diamond"]),nz=m.ink;function nW(e){return"number"==typeof e&&Number.isFinite(e)?e:null}function nJ(e){if(!Array.isArray(e)||e.length<2)return null;let t=nW(e[0]),r=nW(e[1]);return null===t||null===r?null:[t,r]}function nY(e){let t=nW(e.x),r=nW(e.y),n=nW(e.width),i=nW(e.height);return null===t||null===r||null===n||null===i?null:{x:t,y:r,width:n,height:i}}function nX(e){return 1e-4>Math.abs(e-.5)?.5001:e}function nq(e,t){let r=nY(e);return r&&0!==r.width&&0!==r.height?[nX((t.x-r.x)/r.width),nX((t.y-r.y)/r.height)]:null}function nG(e,t){return{elementId:e?.id??"",focus:0,gap:0,fixedPoint:e?nq(e,t):null}}function nV(e,t,r){let n=function(e){let t=0x811c9dc5;for(let r of e)t^=r.charCodeAt(0),t=Math.imul(t,0x1000193);return Math.abs(t)||1}(e);return{id:e,angle:0,fillStyle:r&&"fillStyle"in r?r.fillStyle??"solid":"solid",frameId:r?.frameId??null,groupIds:[...r?.groupIds??[]],index:t,isDeleted:!1,link:null,locked:r?.locked??!1,opacity:r?.opacity??100,roughness:r&&"roughness"in r?r.roughness??1:1,seed:n,strokeStyle:r&&"strokeStyle"in r?r.strokeStyle??"solid":"solid",strokeWidth:r&&"strokeWidth"in r?r.strokeWidth??2:2,updated:1,version:1,versionNonce:n+1}}function nH(e){var t,r,n,i;let a=Math.max(1,Math.min(e.maxWidth,(t=e.text,r=e.fontSize,Math.ceil(Math.max(...t.split("\n").map(e=>e.length))*r*.62)))),s=(n=e.text,i=e.fontSize,Math.ceil(n.split("\n").length*i*1.35));return{...nV(e.id,e.index,e.element),...void 0===e.locked?{}:{locked:e.locked},type:"text",x:e.x-a/2,y:e.y-s/2,width:a,height:s,backgroundColor:"transparent",boundElements:null,containerId:e.containerId??null,fontFamily:e.element?.fontFamily==="mono"?3:e.element?.fontFamily==="sans"?2:5,fontSize:e.fontSize,lineHeight:1.35,originalText:e.text,roundness:null,strokeColor:e.textColor??nz,text:e.text,textAlign:e.element?.textAlign??"center",verticalAlign:e.element?.verticalAlign??"middle",autoResize:!0}}function nK(e){return e.points[e.points.length-1]??e.points[0]}function nQ(e,t,r){if(!e)return null;let n=t.get(e.elementId);return n?{elementId:e.elementId,focus:e.focus??0,gap:e.gap??0,fixedPoint:nq(n,r)}:null}function nZ(e){return"node"===e.type}function n0(e){return"text"===e.type}function n1(e){return"arrow"===e.type}function n2(e){return"line"===e.type}function n5(e){return"frame"===e.type}function n3(e,t){let r=e[t];if(!(r&&"object"==typeof r))return null;let n=r.elementId;return"string"==typeof n?n:null}function n6(e){return nJ(e)}function n8(e){let t=nW(e.x)??0,r=nW(e.y)??0,n=n3(e,"startBinding"),i=n3(e,"endBinding"),a=Array.isArray(e.points)?e.points.map(n6).filter(e=>!!e):[],s=[];for(let o=0;o<a.length-1;o+=1){let l=a[o],d=a[o+1];if(!l||!d)continue;let[c,u]=l,[f,p]=d,h=t+c,m=r+u,g=t+f,y=r+p;if(.001>=Math.abs(m-y)){s.push({arrowId:e.id,endBindingElementId:i,isLastSegment:o===a.length-2,max:Math.max(h,g),min:Math.min(h,g),orientation:"horizontal",segmentIndex:o,startBindingElementId:n,staticCoordinate:m});continue}.001>=Math.abs(h-g)&&s.push({arrowId:e.id,endBindingElementId:i,isLastSegment:o===a.length-2,max:Math.max(m,y),min:Math.min(m,y),orientation:"vertical",segmentIndex:o,startBindingElementId:n,staticCoordinate:h})}return s.filter(e=>e.max-e.min>.001)}function n9(e,t,r){return e>t+.01&&e<r-.01}function n4(e,t,r,n){return Math.min(t,n)-Math.max(e,r)>.01}function n7(e){if(nL.has(e.type)||"frame"===e.type)return!0;let t=e.customData;return"line"===e.type&&null!==t&&"object"==typeof t&&"polygon"===t.sketchiShape}function ie(e,t,r){return e>=t-.01&&e<=r+.01}function it(e,t){return .01>=Math.abs(e-t)}var ir=r(664);r(3614);var ii=r(1594),ia=r(6297),is=r(7258),io=r(2275),il=r(2860),id=r(1554),ic=r(4233);let iu=a.Or("effect/Metric/CurrentMetricAttributes",{defaultValue:()=>({})}),ip=a.Or("effect/Metric/MetricRegistry",{defaultValue:()=>new Map}),ih="~effect/Metric";class im{[ih]=ih;#e;#t="";id;description;attributes;constructor(e,t,r){this.id=e,this.description=t,this.attributes=r}valueUnsafe(e){return this.hook(e).get(e)}modifyUnsafe(e,t){return this.hook(t).modify(e,t)}updateUnsafe(e,t){return this.hook(t).update(e,t)}hook(e){var t;let r,n=a.Jt(e,iu);n!==this.#e&&(this.#e=n,this.#t=(t=this,r=Object.entries(ik(this.attributes,n)).sort((e,t)=>e[0]<t[0]?-1:+(e[0]>t[0])),JSON.stringify([t.type,t.id,t.description,r])));let i=a.Jt(e,ip),s=i.get(this.#t);return ic.b0(s)&&(s={id:this.id,type:this.type,description:this.description,attributes:Object.keys(n).length>0?ik(this.attributes,n):this.attributes,hooks:this.createHooks()},i.set(this.#t,s)),s.hooks}pipe(){return(0,id.tT)(this,arguments)}}let ig=BigInt(0);class iy extends im{type="Counter";#r;#n;constructor(e,t){super(e,t?.description,iS(t?.attributes)),this.#r=t?.bigint??!1,this.#n=t?.incremental??!1}createHooks(){let e=this.#r?ig:0,t=this.#n?this.#r?e=>e>=ig:e=>e>=0:e=>!0;return iw(()=>({count:e,incremental:this.#n}),r=>{t(r)&&(e+=r)})}}class iv extends im{type;metric;valueUnsafe;updateUnsafe;modifyUnsafe;constructor(e,t,r,n){super(e.id,e.description,e.attributes),this.metric=e,this.valueUnsafe=t,this.updateUnsafe=r,this.modifyUnsafe=n,this.type=e.type}createHooks(){return this.metric.createHooks()}}let ib=(e,t)=>new iy(e,t),i_=(0,ii.XY)(2,(e,t)=>ia.sxi(r=>ia.OH5(()=>e.updateUnsafe(t,r)))),ix=(0,ii.XY)(2,(e,t)=>{var r;let n,i,s=(r=t,i={},e=>{let t=a.Jt(e,iu);return t!==n&&(n=t,i=ik(t,r)),a.WQ(e,iu,i)});return new iv(e,t=>e.valueUnsafe(s(t)),(t,r)=>e.updateUnsafe(t,s(r)),(t,r)=>e.modifyUnsafe(t,s(r)))});function iw(e,t,r){return{get:e,update:t,modify:r??t}}function ik(e,t){return{...iS(e),...iS(t)}}function iS(e){return ic.EA(e)&&Array.isArray(e)?e.reduce((e,[t,r])=>(io.x(e,t,r),e),{}):e}is.F,is.F,ii.MN;var iI=r(1587),i$=(r(6526),r(719),r(2707));let iE=[["artifactId","sketchi.artifact_id"],["attemptId","sketchi.attempt_id"],["projectId","sketchi.project_id"],["requestId","sketchi.request_id"],["runId","sketchi.run_id"],["scenarioId","sketchi.scenario_id"],["traceId","sketchi.trace_id"]],iO=new Set(["artifact_count","artifact_format","artifact_kind","attempt","cache_mode","duration_ms","error_category","error_tag","failure_category","format_count","method","model","operation","outcome","provider","request_kind","retry_kind","sink","status","status_code","surface","timeout_kind","timeout_ms"]),iC=([...iE.map(([,e])=>e),...iO],{metric:()=>void 0}),iT=a.Or("@sketchi/observability/TelemetryExporter",{defaultValue:()=>iC}),iM=a.Or("@sketchi/observability/TelemetryCorrelation",{defaultValue:()=>({})});function iA(e){let t=e?.trim();if(t&&!(t.length>128)&&/^[A-Za-z0-9][A-Za-z0-9._:-]*$/.test(t))return t}function iN(e,t){return s.JkU(function*(){let r={...yield*iM,...function(e){let t={};for(let[r]of iE){let n=iA(e[r]);n&&(t[r]=n)}return t}(t)},n=function(e){let t={};for(let[r,n]of iE){let i=e[r];i&&(t[n]=i)}return t}(r);return yield*e.pipe(s.PfK(iM,r),s.Muk(n),s.swY(n))})}a.Or("@sketchi/observability/TelemetryResource",{defaultValue:()=>({serviceName:"sketchi"})});let iP=s.fn(function*(e,t,r={}){let n=function(e){let t={artifact_kind:e.artifactKind,failure_category:e.failureCategory,operation:e.operation,outcome:e.outcome,provider:e.provider,retry_kind:e.retryKind,sink:e.sink,surface:e.surface,timeout_kind:e.timeoutKind},r={};for(let[e,n]of Object.entries(t)){let t=iA(n);t&&(r[e]=t)}return r}(r);yield*i_(ix(e,n),t);let i=yield*iT,a=iI.getOrUndefined((yield*s._32.pipe(s.uKv)));yield*s.OH5(()=>i.metric({attributes:n,metric:e.id,metricType:e.type,...a?{spanId:a.spanId,traceId:a.traceId}:{},value:t}))});i$.W1;let iR=/^(node|step|item|box|thing|process|task)\s*\d*$/i,ij=/^(diagram|untitled|flowchart|chart|sketch)$/i;function iD(e){return e.map(e=>({kind:"node",id:e.id}))}function iU(e){if(void 0===e)return;let t=eh(e);return t.length>0?t:void 0}let iF=["excalidraw","scene"],iB=["scene"];m.card,m.accent,m.ink;let iL=ib("sketchi_codemode_requests",{description:"Code Mode boundary requests by terminal outcome",incremental:!0}),iz=ib("sketchi_codemode_failures",{description:"Code Mode boundary failures by typed status",incremental:!0}),iW=ib("sketchi_codemode_artifacts",{description:"Code Mode artifacts accepted at workflow boundaries",incremental:!0}),iJ=new class e extends im{type="Histogram";#i;constructor(e,t){super(e,t?.description,iS(t?.attributes)),this.#i=t.boundaries}createHooks(){let e=this.#i,t=e.length,r=new Uint32Array(t+1),n=new Float64Array(t),i=0,a=0,s=Number.MAX_VALUE,o=-Number.MAX_VALUE;return ir.Tj(ir.di(e,il.wN),(e,t)=>{n[t]=e}),iw(()=>({buckets:(()=>{let e=ir.CN(t),i=0;for(let a=0;a<t;a++){let t=n[a];i+=r[a],e[a]=[t,i]}return e})(),count:i,min:s,max:o,sum:a}),e=>{let l=0,d=t;for(;l!==d;){let t=Math.floor(l+(d-l)/2);e<=n[t]?d=t:l=t,d===l+1&&(e<=n[l]?d=l:l=d)}r[l]=r[l]+1,i+=1,a+=e,e<s&&(s=e),e>o&&(o=e)})}}("sketchi_codemode_duration_ms",{description:"Code Mode boundary duration in milliseconds",boundaries:(n=[1,5,10,25,50,100,250,500,1e3,2500,5e3,1e4],ir.BC(ir.pb(new Set(n),e=>e>0),1/0))});class iY extends a.kl()("@sketchi/diagram-agent/CodeModeRuntimeEnvironment"){}function iX(e={}){return l.Py(iY,{createId:e.createId??i8,...e.renderer?{renderer:e.renderer}:{},...e.artifactUrl?{artifactUrl:e.artifactUrl}:{}})}function iq(e){return null===e||"object"!=typeof e||Array.isArray(e)?void 0:Object.fromEntries(Object.entries(e))}l.Py(iY,{createId:i8});class iG extends i.rNF()("CodeModeArtifactRenderFailed",{cause:i.kld(),message:i.QfV}){}class iV extends i.rNF()("CodeModeArtifactRendererNotConfigured",{message:i.QfV}){}let iH=i._kM({issues:i.O31(i.O3D(e2)).pipe(i.fXn)});class iK extends i.rNF()("ArtifactExportFailure",{status:i.uSQ("export_failed"),issues:iH.fields.issues}){}class iQ extends i.rNF()("ArtifactStorageFailure",{status:i.uSQ("storage_failed"),cause:i.kld(),issues:iH.fields.issues}){}function iZ(e,t,r){class n extends i.rNF()(e,{message:i.QfV,status:t,context:r}){constructor(e){super({...e,message:e.context.issues[0]?.message??e.status},{disableChecks:!0})}}return n}let i0=iZ("BuildFlowchartFailure",rz.fields.status,rz.mapFields(({ok:e,status:t,...r})=>({...r,...iH.fields}))),i1=iZ("BuildMindmapFailure",rJ.fields.status,rJ.mapFields(({ok:e,status:t,...r})=>({...r,...iH.fields}))),i2=iZ("BuildSequenceDiagramFailure",rX.fields.status,rX.mapFields(({ok:e,status:t,...r})=>({...r,...iH.fields}))),i5=iZ("CreateCanvasFailure",rQ.fields.status,rQ.mapFields(({ok:e,status:t,...r})=>({...r,...iH.fields}))),i3=iZ("GetArtifactFailure",rG.fields.status,rG.mapFields(({ok:e,status:t,...r})=>({...r,...iH.fields}))),i6=iZ("ApplyDiagramPatchFailure",rH.fields.status,rH.mapFields(({ok:e,status:t,...r})=>({...r,...iH.fields})));function i8(e){return`${e}_${globalThis.crypto.randomUUID()}`}function i9(e){return{code:e.code,severity:e.severity??"error",stage:e.stage,...e.ref?{ref:e.ref}:{},message:e.message,hint:e.hint}}function i4(e){return 0===e.length?"input":e.map(e=>"number"==typeof e?`[${e}]`:String(e)).join(".")}function i7(e){let t=i4(e.path);return ae(t)?"unsupported_patch_operation":"InvalidType"===e.issueTag||"MissingKey"===e.issueTag&&"invalid_type"===e.missingKeyCode?"invalid_type":"LiteralUnion"===e.astKind&&"AnyOf"===e.issueTag?"invalid_enum":t.toLowerCase().includes("color")?"invalid_color":"input"===t?"invalid_type":"missing_field"}function ae(e){return/^operations\.\[\d+\]\.op$/.test(e)}function at(e){let t=e.issues.slice(0,20).map(e=>{let t=i4(e.path);return i9({code:i7(e),stage:"input",ref:{kind:"request",path:t},message:e.message,hint:ae(t)?`Use one of: ${e6.join(", ")}. For label edits, use replaceText with selector plus text.`:"source"===t?"Pass source: { artifactId } from an accepted build or patch, or source: { scene } for inline Sketchi scene patching.":`Fix ${t} so it matches the Code Mode API contract.`})});return e.issues.length>20&&t.push(i9({code:"invalid_type",stage:"input",ref:{kind:"request",path:"input"},message:`${e.issues.length-20} additional input issues were omitted.`,hint:"Fix the summarized request shape before retrying."})),t}function ar(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)}function an(e){if(void 0===e)return;let t=eh(e);return t.length>0?t:void 0}function ai(e){return e.checks.map(e=>{var t;return i9({code:"generic_label"===(t=e.code)||"label_too_long"===t||"disconnected_graph"===t?t:"quality_below_threshold",severity:e.severity,stage:"quality",message:e.message,hint:"error"===e.severity?"Repair the structural issue and call buildFlowchart again.":"Improve the labels or scope before styling the artifact."})})}function aa(e){return e?.artifactFormats??iF}function as(e){return e?.inlineArtifacts??iB}let ao=s.fn("codeMode.artifacts.exportFormats")(function*(e){let t=[];for(let a of e.formats){var r,n,i;let o=yield*(r=e,"scene"===(n=a)?s.PyW(r.scene):"excalidraw"===n?s.PyW(function(e,t={}){return{type:"excalidraw",version:2,source:t.source??"https://sketchi.app",elements:e.elements,appState:e.appState,files:{}}}(r.excalidraw)):r.renderer?r.renderer.renderPng({scene:r.scene,excalidraw:r.excalidraw}).pipe(s.xm_(e=>iG.make({cause:e,message:e.message}))):s.fJG(iV.make({message:"PNG artifact rendering is not configured for this runtime."})));t.push({format:a,mimeType:r5[a],data:o,sizeBytes:(i=o)instanceof ArrayBuffer||i instanceof Uint8Array?i.byteLength:r8(i)})}return t});function al(e){return e.map(e=>i9({code:"overlapping-arrow-segment"===e.code?"arrow_overlap":"text-overflow"===e.code?"text_overflow":e.code.includes("binding")||e.code.includes("bound")||e.code.includes("endpoint")?"arrow_binding_invalid":"export_invalid_scene",stage:"export",ref:e.elementId?{kind:"artifact",id:e.elementId}:{kind:"artifact"},message:e.message,hint:"Inspect the rendered scene and retry with a simpler layout or patch."}))}function ad(e){return e.slice(0,20).map(e=>i9({code:function(e){switch(e.code){case"duplicate_element_id":return"duplicate_element_id";case"duplicate_layer_id":return"duplicate_layer_id";case"empty_canvas":case"invalid_geometry":case"label_overflow":return"invalid_canvas_geometry";case"invalid_binding":return"invalid_canvas_binding";case"invalid_composition":return"invalid_canvas_composition";case"invalid_polygon":return"invalid_polygon";case"limit_exceeded":return"canvas_limit_exceeded";case"missing_z_order_element":case"duplicate_z_order_element":case"unknown_z_order_element":return"invalid_z_order";case"unknown_layout_target":return"unknown_layout_target"}}(e),stage:"canvas",ref:e.elementId?{kind:"element",id:e.elementId,path:e.path}:{kind:"diagram",path:e.path},message:e.message,hint:"Repair the referenced CanvasSpec field and call createCanvas again."}))}function ac(e){return al(e.filter(e=>"overlapping-arrow-segment"!==e.code&&"arrow-segment-through-node"!==e.code))}function au(e){let t=[];for(let r of e.elements){if("arrow"===r.type){let e=r.points[0],n=r.points[1],i=r.points.slice(2);if(!e||!n)return null;let a=[e,n,...i];t.push({...r,type:"arrow",id:r.id,edgeId:r.edgeId,sourceNodeId:r.sourceNodeId,targetNodeId:r.targetNodeId,...r.strokeColor?{strokeColor:r.strokeColor}:{},...r.strokeStyle?{strokeStyle:r.strokeStyle}:{},...r.textColor?{textColor:r.textColor}:{},points:a,...r.label?{label:r.label}:{}});continue}if("node"===r.type){let n=r.points;if("polygon"===r.shape&&(!n||!n[0]||!n[1]||!n[2]))return null;t.push({type:"node",id:r.id,nodeId:r.nodeId,...r.kind?{kind:r.kind}:{},shape:r.shape,...r.fillColor?{fillColor:r.fillColor}:{},...r.strokeColor?{strokeColor:r.strokeColor}:{},x:r.x,y:r.y,width:r.width,height:r.height,label:r.label,...r.frameId?{frameId:r.frameId}:{},...r.groupIds?{groupIds:[...r.groupIds]}:{},...r.layerId?{layerId:r.layerId}:{},...void 0!==r.locked?{locked:r.locked}:{},...void 0!==r.opacity?{opacity:r.opacity}:{},...void 0!==r.zIndex?{zIndex:r.zIndex}:{},...r.fillStyle?{fillStyle:r.fillStyle}:{},...void 0!==r.roughness?{roughness:r.roughness}:{},...r.strokeStyle?{strokeStyle:r.strokeStyle}:{},...void 0!==r.strokeWidth?{strokeWidth:r.strokeWidth}:{},..."sequence-lifeline"===r.rendererRole&&function(e,t){let r=":lifeline";if(!t.nodeId.endsWith(r)||t.id!==`node:${t.nodeId}`||"rectangle"!==t.shape||2!==t.width||t.height<120)return!1;let n=t.nodeId.slice(0,-r.length);if(0===n.length)return!1;let i=e.elements.find(e=>"node"===e.type&&e.id===`node:${n}`&&e.nodeId===n);return!!i&&.01>=Math.abs(t.x+t.width/2-(i.x+i.width/2))&&t.y>=i.y+i.height-.01}(e,r)?{rendererRole:r.rendererRole}:{},...r.textColor?{textColor:r.textColor}:{},..."polygon"===r.shape&&n?.[0]&&n[1]&&n[2]?{points:[n[0],n[1],n[2],...n.slice(3)]}:{}});continue}if("line"===r.type){let e=r.points[0],n=r.points[1];if(!e||!n)return null;t.push({...r,points:[e,n,...r.points.slice(2)]});continue}t.push(structuredClone(r))}return{kind:e.kind,version:e.version,diagramId:e.diagramId,title:e.title,width:e.width,height:e.height,accentColor:e.accentColor,backgroundColor:e.backgroundColor,elements:t,layers:structuredClone(e.layers),layouts:structuredClone(e.layouts),zOrder:[...e.zOrder]}}function af(e){return structuredClone(e)}function ap(e){return e.elements.flatMap(e=>"arrow"===e.type?[`arrow:${e.id}:${e.sourceNodeId}->${e.targetNodeId}`]:"line"===e.type?[`line:${e.id}:${e.startBinding?.elementId??""}->${e.endBinding?.elementId??""}`]:[]).sort()}function ah(e){return e.elements.filter(e=>"node"===e.type)}function am(e){return e.elements.filter(e=>"text"===e.type)}function ag(e){return e.elements.filter(e=>"arrow"===e.type)}function ay(e,t){if(!e||0===e.length||!t)return!1;let r=t.trim().toLowerCase();return e.some(e=>e.trim().toLowerCase()===r)}function av(e,t){let r=t?.scope??"all",n=!!(t&&((t.ids?.length??0)>0||(t.nodeIds?.length??0)>0||(t.edgeIds?.length??0)>0||(t.kinds?.length??0)>0||(t.labels?.length??0)>0)),i=new Set(t?.ids??[]),a=new Set(t?.nodeIds??[]),s=new Set(t?.edgeIds??[]),o=new Set(t?.kinds??[]),l=ah(e).filter(e=>"edges"!==r&&(!t||!n||i.has(e.id)||a.has(e.nodeId)||!!e.kind&&[...o].some(t=>t===e.kind)||ay(t.labels,e.label))),d=ag(e).filter(e=>"nodes"!==r&&(!t||!n||i.has(e.id)||s.has(e.edgeId)||ay(t.labels,e.label))),c=new Set(l.map(e=>e.id)),u=new Set(d.map(e=>e.id));return{arrows:d,nodes:l,texts:am(e).filter(e=>t&&n?i.has(e.id)||!!e.containerId&&c.has(e.containerId)||!!e.containerId&&u.has(e.containerId)||ay(t.labels,e.text):"nodes"===r?!!e.containerId&&c.has(e.containerId):"edges"!==r||!!e.containerId&&u.has(e.containerId))}}function ab(e){return i9({code:"unknown_patch_target",stage:"flowchart",ref:{kind:"request",path:"operations.selector"},message:`Patch operation "${e.op}" did not match any scene element.`,hint:"Use nodeIds, edgeIds, ids, kinds, labels, or scope values that exist in the accepted artifact."})}function a_(e,t){return am(e).find(e=>e.containerId===t)}function ax(e,t){let r=new Set(t);for(let t of ag(e))(r.has(t.sourceNodeId)||r.has(t.targetNodeId))&&aS(e,t)}function aw(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}function ak(e,t,r){let n=aw(e),i=aw(t),a=i.x-n.x,s=i.y-n.y;return 0===a&&0===s?{x:n.x,y:"source"===r?e.y+e.height:e.y}:Math.abs(a)>Math.abs(s)?a>=0?{x:e.x+e.width,y:n.y}:{x:e.x,y:n.y}:s>=0?{x:n.x,y:e.y+e.height}:{x:n.x,y:e.y}}function aS(e,t){let r,n,i=new Map(ah(e).map(e=>[e.nodeId,e])),a=i.get(t.sourceNodeId),s=i.get(t.targetNodeId);if(!a||!s)return[i9({code:"patch_output_invalid",stage:"render",ref:{kind:"edge",id:t.edgeId},message:`Arrow "${t.id}" references a node that is not in the scene.`,hint:"Rebuild the diagram with buildFlowchart or buildMindmap before applying visual patches."})];let o=ak(a,s,"source"),l=ak(s,a,"target");if(Math.abs(l.y-o.y)>=Math.abs(l.x-o.x)){let e=(o.y+l.y)/2;t.points=[o,{x:o.x,y:e},{x:l.x,y:e},l]}else{let e=(o.x+l.x)/2;t.points=[o,{x:e,y:o.y},{x:e,y:l.y},l]}return r=a_(e,t.id),n=function(e){let t=e[0],r=e[e.length-1];if(t&&r)return{x:(t.x+r.x)/2,y:(t.y+r.y)/2-10}}(t.points),r&&n&&(r.x=n.x,r.y=n.y),[]}function aI(e){let t=e.width,r=e.height;for(let n of e.elements)if("arrow"===n.type||"line"===n.type)for(let e of n.points)t=Math.max(t,e.x),r=Math.max(r,e.y);else"text"===n.type?(t=Math.max(t,n.x+(n.maxWidth??0)),r=Math.max(r,n.y+n.fontSize)):(t=Math.max(t,n.x+n.width),r=Math.max(r,n.y+n.height));e.width=t+48,e.height=r+48}function a$(e,t,r){if(!t||!r){if(t){let r=e.indexOf(t);return r>=0?r:void 0}if(r){let t=e.indexOf(r);return t>=0?t+1:void 0}return e.length}}function aE(e,t){return[i9({code:"patch_output_invalid",stage:"canvas",ref:{kind:"request",path:"operations"},message:t,hint:`Repair the ${e.op} operation and preserve unique, stable element ids.`})]}let aO=s.fn("codeMode.patch.resolveSource")(function*(e){if("scene"in e.source)return{scene:af(e.source.scene)};let t=yield*r2,r=yield*t.readManifest(e.source.artifactId).pipe(s.xm_(e=>new i6({status:"storage_failed",context:{issues:[r4(e.message,"storage_read_failed")]}})));if(!r||r.artifactId!==e.source.artifactId||!r.formats.some(e=>"scene"===e.format))return yield*new i6({status:"source_unavailable",context:{issues:[i9({code:"patch_source_unavailable",stage:"storage",ref:{kind:"artifact",id:e.source.artifactId},message:`Artifact "${e.source.artifactId}" does not have a valid source manifest.`,hint:"Rebuild with the appropriate build operation and patch the accepted artifact id."})]}});let n=yield*t.read(e.source.artifactId,"scene").pipe(s.xm_(e=>new i6({status:"storage_failed",context:{issues:[r4(e.message,"storage_read_failed")]}})));if(!n)return yield*new i6({status:"source_unavailable",context:{issues:[i9({code:"patch_source_unavailable",stage:"storage",ref:{kind:"artifact",id:e.source.artifactId},message:`Scene artifact "${e.source.artifactId}" is not available.`,hint:"Call buildFlowchart or buildMindmap first, then patch the accepted artifact id."})]}});let i=t7.safeParse(n.data);return i.success?{scene:af(i.data),sourceArtifactId:e.source.artifactId}:yield*new i6({status:"source_unavailable",context:{issues:[i9({code:"patch_source_unavailable",stage:"storage",ref:{kind:"artifact",id:e.source.artifactId},message:`Scene artifact "${e.source.artifactId}" could not be decoded.`,hint:"Rebuild with the appropriate build operation and patch the new artifact."})]}})});function aC(e){return e?{requestId:e}:{}}function aT(e){return{diagramId:e.diagramId,formats:[{format:"scene",mimeType:r5.scene,inline:e,sizeBytes:r8(e)}]}}function aM(e){return{ok:!1,status:e.status,...e.context}}function aA(e,t){return r4(e.message,t)}let aN=s.fn("codeMode.artifacts.exportAndStore")(function*(e){let t=yield*iY,r=yield*r2,{excalidraw:n,validation:i}=yield*s.OH5(()=>{let t=function(e){var t;let r,n,i,a,s,o,l,d=(r=new Map(e.layers.map(e=>[e.id,e])),i=new Set((n=e.elements.filter(e=>{let t=e.layerId?r.get(e.layerId):void 0;return t?.visible!==!1})).flatMap(e=>"node"===e.type?[e.nodeId]:[])),s=new Set((a=n.filter(e=>"arrow"!==e.type||i.has(e.sourceNodeId)&&i.has(e.targetNodeId))).flatMap(e=>"text"===e.type?[]:[e.id])),l=new Set((o=a.filter(e=>"text"!==e.type||!e.containerId||s.has(e.containerId))).map(e=>e.id)),o.map(e=>{let t=e.layerId?r.get(e.layerId):void 0;return{...e.frameId&&!l.has(e.frameId)?(({frameId:e,...t})=>t)(e):e,...t?.locked===!0?{locked:!0}:{}}})),c=d.filter(nZ),u=d.filter(n0),f=new Set(d.map(e=>e.id)),p=new Map,h=new Set(u.flatMap(e=>e.containerId?[e.containerId]:[]));for(let e of c){if(h.has(e.id)||e.rendererRole===nk)continue;let t=`__sketchi_node_label__${e.id}`,r=t,n=2;for(;f.has(r);)r=`${t}:${n}`,n+=1;f.add(r),p.set(r,e.id),u.push({type:"text",id:r,containerId:e.id,...e.frameId?{frameId:e.frameId}:{},...e.groupIds?{groupIds:[...e.groupIds]}:{},...e.layerId?{layerId:e.layerId}:{},...void 0!==e.locked?{locked:e.locked}:{},...void 0!==e.opacity?{opacity:e.opacity}:{},...e.textColor?{textColor:e.textColor}:{},x:e.x+e.width/2,y:e.y+e.height/2,text:e.label,fontSize:16,maxWidth:Math.max(1,e.width-24)})}let m=new Map(u.map(e=>[e.containerId??"",e])),g=d.filter(n1),y=d.filter(n2),v=function(e,t,r){let n=new Map,i=new Map(e.map(e=>[e.nodeId,e.id]));for(let e of t)for(let t of[e.sourceNodeId,e.targetNodeId]){let r=i.get(t);r&&n.set(r,[...n.get(r)??[],e.id])}for(let e of r)for(let t of[e.startBinding,e.endBinding])t&&n.set(t.elementId,[...n.get(t.elementId)??[],e.id]);return n}(c,g,y),b=new Map,_=[],x=null,w=()=>{let e=function(e,t,r,n){if(void 0!==n){var i=n;if(!nB.has(i)){if(i.length<2||i.length%2!=0||!nD(i))throw Error("intDigits must be an even number of at least 2 characters in strictly ascending character code order: "+i);if(!nU(i))throw Error("intDigits must be single-byte (char code 0-255): "+i);nB.add(i)}}else n=r??n$;if(void 0!==r){var a=r;if(!nF.has(a)){if(a.length<2||!nD(a))throw Error("digits must be at least 2 characters in strictly ascending character code order: "+a);if(!nU(a))throw Error("digits must be single-byte (char code 0-255): "+a);nF.add(a)}}else r=nI;let s=nO(r),o=nO(n);if(null!=e&&nN(e,r,n,o),null!=t&&nN(t,r,n,o),null!=e&&null!=t&&e>t){let r=e;e=t,t=r}if(null==e){if(null==t)return n[n.length/2]+r[0];let e=nA(t,n,o),i=t.slice(e.length);if(nj(e,r,n))return e+nC("",i,r,s);if(e<t)return e;let a=function(e,t,r,n,i){nT(e,n,i);let a=e[0],s=t[t.length-1],o="";for(let n=e.length-1;n>=1;n--){let i=r[e.charCodeAt(n)]-1;if(-1!==i)return a+e.slice(1,n)+t[i]+o;o=s+o}let l=i[a.charCodeAt(0)];if(0===l)return null;let d=n[l-1],c=nM(d,n,i)-nM(a,n,i);return d+(c>0?o+s:c<0?o.slice(1):o)}(e,r,s,n,o);if(null==a)throw Error("cannot decrement any more");return a}if(null==t){let t=nA(e,n,o),i=e.slice(t.length),a=nP(t,r,s,n,o);return null==a?t+nC(i,null,r,s):a}let l=nA(e,n,o),d=e.slice(l.length),c=nA(t,n,o),u=t.slice(c.length);if(l===c)return l+nC(d,u,r,s);let f=nP(l,r,s,n,o);if(null==f)throw Error("cannot increment any more");return f<t?f:l+nC(d,null,r,s)}(x,null);return x=e,e};for(let t of c){let r=m.get(t.id),n=function(e){let t=e.shape.height,r="circle"===e.shape.shape?"ellipse":e.shape.shape,n=[...e.text&&"polygon"!==e.shape.shape?[{id:e.text.id,type:"text"}]:[],...e.arrowIds.map(e=>({id:e,type:"arrow"}))];if("polygon"===e.shape.shape){let t=e.shape.points??[{x:e.shape.width/2,y:0},{x:e.shape.width,y:e.shape.height},{x:0,y:e.shape.height}],[r,...n]=t;return{...nV(e.shape.id,e.index,e.shape),type:"line",x:e.shape.x,y:e.shape.y,width:e.shape.width,height:e.shape.height,backgroundColor:e.shape.fillColor??"transparent",boundElements:e.arrowIds.map(e=>({id:e,type:"arrow"})),customData:{sketchiShape:"polygon"},endArrowhead:null,endBinding:null,lastCommittedPoint:null,points:[...t,r].map(e=>[e.x,e.y]),roundness:null,startArrowhead:null,startBinding:null,strokeColor:e.shape.strokeColor??e.scene.accentColor}}return{...nV(e.shape.id,e.index,e.shape),type:r,x:e.shape.x,y:e.shape.y,width:e.shape.width,height:t,backgroundColor:e.shape.fillColor??"transparent",boundElements:n.length>0?n:null,roundness:"rectangle"===r?{type:3}:null,strokeColor:e.shape.strokeColor??e.scene.accentColor,...e.shape.rendererRole===nk?{customData:{sketchiRendererRole:nk}}:{}}}({scene:e,shape:t,arrowIds:v.get(t.id)??[],index:w(),...r?{text:r}:{}});b.set(t.nodeId,n),_.push(n)}for(let r of d.filter(n5)){let n={...nV((t={element:r,index:w(),scene:e}).element.id,t.index,t.element),type:"frame",x:t.element.x,y:t.element.y,width:t.element.width,height:t.element.height,backgroundColor:t.element.fillColor??"transparent",boundElements:null,name:t.element.name??null,roundness:null,strokeColor:t.element.strokeColor??t.scene.accentColor},i=v.get(r.id)??[];n.boundElements=i.length?i.map(e=>({id:e,type:"arrow"})):null,_.push(n)}for(let e of u){let t=e.containerId&&(c.some(t=>t.id===e.containerId&&"polygon"!==t.shape)||g.some(t=>t.id===e.containerId));_.push(nH({element:e,id:e.id,index:w(),...t?{containerId:e.containerId}:{},fontSize:e.fontSize,maxWidth:e.maxWidth??160,...e.textColor?{textColor:e.textColor}:{},text:e.text,x:e.x,y:e.y}))}for(let t of g){let r=m.get(t.id);_.push(function(e){let t=e.arrow.points[0],r=nK(e.arrow),n=e.arrow.points.length>2;return{...nV(e.arrow.id,e.index,e.arrow),type:"arrow",x:t.x,y:t.y,width:r.x-t.x,height:r.y-t.y,backgroundColor:"transparent",boundElements:e.text?[{id:e.text.id,type:"text"}]:e.arrow.label?[{id:`${e.arrow.id}:label`,type:"text"}]:null,elbowed:n,endArrowhead:void 0===e.arrow.endArrowhead?"arrow":e.arrow.endArrowhead,endBinding:nG(e.targetShape,r),...n?{fixedSegments:[],startIsSpecial:null,endIsSpecial:null}:{},points:e.arrow.points.map(e=>[e.x-t.x,e.y-t.y]),roundness:n?null:{type:2},startArrowhead:e.arrow.startArrowhead??null,startBinding:nG(e.sourceShape,t),strokeColor:e.arrow.strokeColor??e.scene.accentColor,strokeStyle:e.arrow.strokeStyle??"solid"}}({arrow:t,scene:e,index:w(),sourceShape:b.get(t.sourceNodeId),targetShape:b.get(t.targetNodeId),...r?{text:r}:{}}));let n=t.label&&!r?function(e){if(!e.arrow.label)return null;let t=e.arrow.points[0],r=nK(e.arrow);return nH({id:`${e.arrow.id}:label`,index:e.index,containerId:e.arrow.id,fontSize:13,...void 0===e.arrow.locked?{}:{locked:e.arrow.locked},maxWidth:160,...e.arrow.textColor?{textColor:e.arrow.textColor}:{},text:e.arrow.label,x:(t.x+r.x)/2,y:(t.y+r.y)/2-10})}({arrow:t,index:w()}):null;n&&_.push(n)}let k=new Map(_.map(e=>[e.id,e]));for(let t of y)if(_.push(function(e){let[t,...r]=e.element.points,n=r[r.length-1]??t,i=void 0!==e.element.startArrowhead||void 0!==e.element.endArrowhead||void 0!==e.element.startBinding||void 0!==e.element.endBinding,a=i&&e.element.points.length>2;return{...nV(e.element.id,e.index,e.element),type:i?"arrow":"line",x:t.x,y:t.y,width:n.x-t.x,height:n.y-t.y,backgroundColor:e.element.fillColor??"transparent",boundElements:null,...i?{elbowed:a}:{},endArrowhead:e.element.endArrowhead??null,endBinding:nQ(e.element.endBinding,e.elementsById,n),...a?{fixedSegments:[],startIsSpecial:null,endIsSpecial:null}:{},points:e.element.points.map(e=>[e.x-t.x,e.y-t.y]),roundness:e.element.points.length>2&&!a?{type:2}:null,startArrowhead:e.element.startArrowhead??null,startBinding:nQ(e.element.startBinding,e.elementsById,t),strokeColor:e.element.strokeColor??e.scene.accentColor}}({element:t,elementsById:k,index:w(),scene:e})),t.label){let e=t.points[0],r=t.points[t.points.length-1]??e;_.push(nH({id:`${t.id}:label`,index:w(),fontSize:13,...void 0===t.locked?{}:{locked:t.locked},maxWidth:160,...t.textColor?{textColor:t.textColor}:{},text:t.label,x:(e.x+r.x)/2,y:(e.y+r.y)/2-10}))}let S=new Map(e.zOrder.map((e,t)=>[e,t])),I=e=>{if(S.has(e.id))return e.id;let t=p.get(e.id);return t||(e.id.endsWith(":label")?e.id.slice(0,-6):e.id)};for(let e of(_.sort((e,t)=>(S.get(I(e))??Number.MAX_SAFE_INTEGER)-(S.get(I(t))??Number.MAX_SAFE_INTEGER)),x=null,_))e.index=w();return{appState:{viewBackgroundColor:e.backgroundColor,zoom:{value:Math.max(.42,Math.round(100*Math.min(1,860/Math.max(e.width,1),340/Math.max(e.height,1)))/100)}},elements:_}}(e.scene);return{excalidraw:t,validation:function(e){let t=[],r=new Map(e.elements.map(e=>[e.id,e])),n=new Set(e.elements.filter(n7).map(e=>e.id));for(let i of(0===e.elements.length&&t.push({code:"empty-scene",message:"Excalidraw scene must contain at least one shape."}),e.elements)){if("arrow"===i.type){let e=!0===i.elbowed;for(let a of((Array.isArray(i.points)?i.points:[]).length>2&&!e&&t.push({code:"invalid-elbow-binding",elementId:i.id,message:`Arrow "${i.id}" has an orthogonal route but is not marked elbowed.`}),e&&null!==i.fixedSegments&&!Array.isArray(i.fixedSegments)&&t.push({code:"invalid-elbow-binding",elementId:i.id,message:`Elbow arrow "${i.id}" is missing fixedSegments metadata.`}),["startBinding","endBinding"])){if(null===i[a]||void 0===i[a])continue;let s=n3(i,a);if(!(s&&n.has(s))){t.push({code:"missing-arrow-binding",elementId:i.id,message:`Arrow "${i.id}" has invalid ${a}.`});continue}let o=r.get(s);o&&!function(e,t,r){let n=e.boundElements;return!!Array.isArray(n)&&n.some(e=>!!(e&&"object"==typeof e)&&e.id===t&&e.type===r)}(o,i.id,"arrow")&&t.push({code:"missing-bound-arrow",elementId:o.id,message:`Shape "${o.id}" does not include bound arrow "${i.id}".`});let l=function(e,t){let r=nW(e.x)??0,n=nW(e.y)??0,i=Array.isArray(e.points)?e.points.map(n6).filter(e=>!!e):[],a="startBinding"===t?i[0]:i[i.length-1];return a?{x:r+a[0],y:n+a[1]}:null}(i,a);if(o&&l&&!function(e,t){let r=nY(t);if(!r)return!1;if("diamond"===t.type){let t=r.width/2,n=r.height/2;if(0===t||0===n)return!1;let i=r.x+t,a=r.y+n;return it(Math.abs(e.x-i)/t+Math.abs(e.y-a)/n,1)}if("ellipse"===t.type){let t=r.width/2,n=r.height/2;if(0===t||0===n)return!1;let i=r.x+t,a=r.y+n;return it(((e.x-i)/t)**2+((e.y-a)/n)**2,1)}let n=(it(e.x,r.x)||it(e.x,r.x+r.width))&&ie(e.y,r.y,r.y+r.height),i=(it(e.y,r.y)||it(e.y,r.y+r.height))&&ie(e.x,r.x,r.x+r.width);return n||i}(l,o)&&t.push({code:"arrow-endpoint-off-shape",elementId:i.id,message:`Arrow "${i.id}" ${a} endpoint does not land on "${o.id}".`}),o&&l&&e){let e=function(e,t){let r=e[t];return r&&"object"==typeof r?nJ(r.fixedPoint):null}(i,a);e&&function(e,t,r){let n=nY(r);if(!n)return!1;let i=1e-4>Math.abs(e[0]-.5001)?.5:e[0],a=1e-4>Math.abs(e[1]-.5001)?.5:e[1];return it(n.x+i*n.width,t.x)&&it(n.y+a*n.height,t.y)}(e,l,o)||t.push({code:"invalid-elbow-binding",elementId:i.id,message:`Elbow arrow "${i.id}" has invalid ${a} fixedPoint metadata.`})}}}if("text"===i.type){let e=i.containerId;if("string"!=typeof e)continue;let n=r.get(e);if(!n){t.push({code:"missing-container",elementId:i.id,message:`Text "${i.id}" references missing container "${e}".`});continue}let a="number"==typeof i.width?i.width:0,s="number"==typeof i.height?i.height:0,o="number"==typeof n.width?n.width:0,l="number"==typeof n.height?n.height:0;n7(n)&&(a+24>o||s+18>l)&&t.push({code:"text-overflow",elementId:i.id,message:`Text "${i.id}" does not fit inside "${e}".`})}}return t.push(...function(e){let t=e.filter(e=>"arrow"===e.type).flatMap(n8),r=e.filter(n7),n=[],i=new Set;for(let e of t)for(let t of r){if(function(e){let t=e.customData;return null!==t&&"object"==typeof t&&t.sketchiRendererRole===nk}(t)||t.id===e.startBindingElementId||t.id===e.endBindingElementId)continue;let r=nY(t);if(!r||("horizontal"===e.orientation?!(n9(e.staticCoordinate,r.y,r.y+r.height)&&n4(e.min,e.max,r.x,r.x+r.width)):!(n9(e.staticCoordinate,r.x,r.x+r.width)&&n4(e.min,e.max,r.y,r.y+r.height))))continue;let a=`${e.arrowId}:${e.segmentIndex}:${t.id}`;i.has(a)||(i.add(a),n.push({code:"arrow-segment-through-node",elementId:e.arrowId,message:`Arrow "${e.arrowId}" passes through shape "${t.id}".`}))}return n}(e.elements)),t.push(...function(e){let t=e.filter(e=>"arrow"===e.type).flatMap(n8),r=[],n=new Set;for(let e=0;e<t.length;e+=1){let i=t[e];if(i)for(let a=e+1;a<t.length;a+=1){let e=t[a];if(!e||i.arrowId===e.arrowId||i.orientation!==e.orientation||Math.abs(i.staticCoordinate-e.staticCoordinate)>.001||0===i.segmentIndex&&0===e.segmentIndex&&null!==i.startBindingElementId&&i.startBindingElementId===e.startBindingElementId||i.isLastSegment&&e.isLastSegment&&null!==i.endBindingElementId&&i.endBindingElementId===e.endBindingElementId||Math.min(i.max,e.max)-Math.max(i.min,e.min)<=.001)continue;let s=[i.arrowId,i.segmentIndex,e.arrowId,e.segmentIndex].sort().join(":");n.has(s)||(n.add(s),r.push({code:"overlapping-arrow-segment",elementId:i.arrowId,message:`Arrow "${i.arrowId}" overlaps arrow "${e.arrowId}".`}))}}return r}(e.elements)),{ok:0===t.length,issues:t}}(t)}}).pipe(s.fRP("codeMode.artifacts.exportValidate")),a=e.validationIssues(i.issues);if(a.length>0)return yield*new iK({status:"export_failed",issues:a});let o=yield*ao({formats:e.formats,scene:e.scene,excalidraw:n,renderer:t.renderer}).pipe(s.xm_(e=>new iK({status:"export_failed",issues:[i9({code:"render_failed",stage:"export",..."CodeModeArtifactRendererNotConfigured"===e._tag?{ref:{kind:"artifact",path:"options.artifactFormats"}}:{},message:e.message,hint:"CodeModeArtifactRendererNotConfigured"===e._tag?"Use the hosted Studio Code Mode runtime with its Cloudflare Browser Run binding, or omit png from artifactFormats.":"Retry the request; if it keeps failing, inspect the configured renderer."})]}))),l=yield*s.OH5(()=>t.createId("artifact"));var d=yield*iN(r.write({artifactId:l,diagramId:e.scene.diagramId,formats:o,inlineFormats:e.inlineFormats,...e.provenance?{provenance:e.provenance}:{}}).pipe(s.fRP("codeMode.artifacts.store")),{artifactId:l,...e.requestId?{requestId:e.requestId}:{}}).pipe(s.xm_(e=>new iQ({status:"storage_failed",cause:e,issues:[aA(e,"storage_write_failed")]}))),c=t.artifactUrl;if(!c)return d;let u=d.formats.map(e=>({...e,url:c({artifactId:d.artifactId,format:e.format})})),f=d.preview?u.find(e=>e.format===d.preview?.format):void 0;return{...d,formats:u,...f?{preview:f}:{}}}),aP=s.fn("codeMode.buildMindmap.workflow")(function*(e){var t,r;let n,i,a,o,l,d,c,u,f,p=function(e){let t=iq(iq(iq(e)?.spec)?.root);if(!t)return[];let r=[{depth:0,topic:t}],n=1;for(;r.length>0;){let e=r.pop();if(!e)continue;if(e.depth>8)return[i9({code:"mindmap_too_deep",stage:"mindmap",ref:{kind:"request",path:"spec.root.children"},message:"Mindmap depth exceeds the supported maximum of 8.",hint:"Combine overly deep topics into a shallower hierarchy."})];let t=e.topic.children;if(Array.isArray(t)){if((n+=t.length)>100)return[i9({code:"mindmap_too_large",stage:"mindmap",ref:{kind:"request",path:"spec.root"},message:"Mindmap exceeds the supported maximum of 100 topic slots.",hint:"Split this hierarchy into smaller focused mindmaps."})];for(let n=t.length-1;n>=0;n-=1){let i=iq(t[n]);i&&r.push({depth:e.depth+1,topic:i})}}}return[]}(e);if(p.length>0)return yield*new i1({status:"invalid_mindmap",context:{issues:p}});let h=tF.safeParse(e);if(!h.success)return yield*new i1({status:"invalid_input",context:{issues:at(h.error)}});let m=yield*iY,y=h.data,v=yield*s.OH5(()=>m.createId("build")),b=(t=y.spec,n=(e,t)=>({id:`topic-${t.join("-")}`,label:eh(e.label),children:(e.children??[]).map((e,r)=>n(e,[...t,r]))}),i=eh(t.title),{id:an(t.id)??(ar(i)||"sketchi-mindmap"),title:i,root:n(t.root,[0]),layout:{direction:t.layout.direction},style:{...g}}),_={buildId:v,...aC(y.requestId),normalizedSpec:b},x=(a=0,o=0,(l=(e,t)=>{a+=1,o=Math.max(o,t),e.children.forEach(e=>l(e,t+1))})(b.root,0),c=[],(d={count:a,depth:o}).count<2&&c.push(i9({code:"disconnected_graph",stage:"mindmap",ref:{kind:"diagram",id:b.id},message:"Mindmap root must contain at least one child topic.",hint:"Add one or more nested topics under spec.root.children."})),d.depth>8&&c.push(i9({code:"mindmap_too_deep",stage:"mindmap",ref:{kind:"diagram",id:b.id},message:`Mindmap depth ${d.depth} exceeds the supported maximum of 8.`,hint:"Combine overly deep topics into a shallower hierarchy."})),d.count>100&&c.push(i9({code:"mindmap_too_large",stage:"mindmap",ref:{kind:"diagram",id:b.id},message:`Mindmap has ${d.count} topics; the supported maximum is 100.`,hint:"Split this hierarchy into smaller focused mindmaps."})),c);if(x.length>0)return yield*new i1({status:"invalid_mindmap",context:{..._,issues:x}});let w=yield*s.SvU({try:()=>{let e,t,r;return e=[],t=[],(r=(n,i,a,s)=>{e.push({id:n.id,label:n.label,kind:0===i?"root":"topic",metadata:{depth:i,siblingIndex:a}}),s&&t.push({id:`branch-${n.id.slice(6)}`,source:s,target:n.id,metadata:{depth:i,siblingIndex:a}}),n.children.forEach((e,t)=>r(e,i+1,t,n.id))})(b.root,0,0),ee({id:b.id,title:b.title,type:"mindmap",nodes:e,edges:t,layout:{direction:b.layout.direction,edgeRouting:"curved"},style:{...g}})},catch:e=>new i1({status:"invalid_mindmap",context:{..._,issues:[i9({code:"disconnected_graph",stage:"mindmap",ref:{kind:"diagram",id:b.id},message:e instanceof Error?e.message:"Mindmap failed core validation.",hint:"Repair the nested topic hierarchy and call buildMindmap again."})]}})}),k=(r=y.options?.minQualityScore??8,{accepted:(f=Math.max(0,10-2*(u=w.nodes.filter(e=>/^(topic|branch|item|mindmap)$/i.test(e.label.trim()))).length))>=r,score:f,threshold:r,summary:{nodeCount:w.nodes.length,edgeCount:w.edges.length},checks:u.map(e=>({code:"generic_label",passed:!1,severity:"warning",message:`Topic "${e.label}" is too generic.`,refs:[{kind:"node",id:e.id}]}))}),S={..._,quality:k};if(!k.accepted)return yield*new i1({status:"quality_failed",context:{...S,issues:ai(k)}});let I=yield*s.SvU({try:()=>nw(w),catch:e=>new i1({status:"render_failed",context:{...S,issues:[i9({code:"render_failed",stage:"render",ref:{kind:"diagram",id:b.id},message:e instanceof Error?e.message:"Unable to render mindmap scene.",hint:"Simplify the hierarchy or retry with a smaller mindmap."})]}})}).pipe(s.fRP("codeMode.buildMindmap.render")),$={...S,partial:aT(I)},E=yield*aN({scene:I,formats:aa(y.options),inlineFormats:as(y.options),...y.requestId?{requestId:y.requestId}:{},validationIssues:al}).pipe(s.xm_(e=>new i1({status:e.status,context:{..."export_failed"===e.status?$:{...S,partial:{diagramId:I.diagramId}},issues:e.issues}})));return{ok:!0,status:"accepted",buildId:v,...aC(y.requestId),normalizedSpec:b,quality:k,artifact:E,issues:[]}}),aR=s.fn("codeMode.buildSequenceDiagram.workflow")(function*(e){var t,r;let n,i,a,o,l,d=tC.safeParse(e);if(!d.success)return yield*new i2({status:"invalid_input",context:{issues:at(d.error)}});let c=yield*iY,u=d.data,f=yield*s.OH5(()=>c.createId("build")),p=(n=eh((t=u.spec).title),{id:an(t.id)??(ar(n)||"sketchi-sequence"),title:n,participants:t.participants.map(e=>({id:eh(e.id),label:eh(e.label),...e.kind?{kind:eh(e.kind)}:{}})),messages:t.messages.map((e,t)=>({id:an(e.id)??`message-${t+1}-${ar(e.source)}-${ar(e.target)}`,source:eh(e.source),target:eh(e.target),label:eh(e.label),...e.type?{type:e.type}:{},...e.style?{style:e.style}:{}})),style:{...g}}),h={buildId:f,...aC(u.requestId),normalizedSpec:p},m=(i=[],a=new Set,p.participants.forEach((e,t)=>{a.has(e.id)&&i.push(i9({code:"duplicate_node_id",stage:"input",ref:{kind:"request",path:`spec.participants.[${t}].id`},message:`Participant id "${e.id}" is duplicated.`,hint:"Give every participant a unique stable id and update message references."})),a.add(e.id)}),o=new Map(p.participants.map((e,t)=>[e.id,t])),p.participants.forEach(e=>{let t=nS(e.id),r=o.get(t);void 0!==r&&i.push(i9({code:"duplicate_node_id",stage:"input",ref:{kind:"request",path:`spec.participants.[${r}].id`},message:`Participant id "${t}" collides with the generated lifeline for "${e.id}".`,hint:"Rename the participant so its id does not equal another participant id followed by :lifeline."}))}),l=new Set,p.messages.forEach((e,t)=>{l.has(e.id)&&i.push(i9({code:"duplicate_edge_id",stage:"input",ref:{kind:"request",path:`spec.messages.[${t}].id`},message:`Message id "${e.id}" is duplicated.`,hint:"Give every message a unique id or omit message ids to generate them deterministically."})),l.add(e.id),a.has(e.source)||i.push(i9({code:"missing_edge_source",stage:"input",ref:{kind:"request",path:`spec.messages.[${t}].source`},message:`Message source "${e.source}" is not a participant.`,hint:"Use the id of a participant declared in spec.participants."})),a.has(e.target)||i.push(i9({code:"missing_edge_target",stage:"input",ref:{kind:"request",path:`spec.messages.[${t}].target`},message:`Message target "${e.target}" is not a participant.`,hint:"Use the id of a participant declared in spec.participants."})),e.source===e.target&&i.push(i9({code:"self_loop",stage:"input",ref:{kind:"request",path:`spec.messages.[${t}]`},message:`Message "${e.id}" is self-referential.`,hint:"Choose a different target participant; self messages are not supported."}))}),i);if(m.length>0)return yield*new i2({status:"invalid_sequence",context:{...h,issues:m}});let y={accepted:10>=(r=u.options?.minQualityScore??8),score:10,threshold:r,summary:{nodeCount:p.participants.length,edgeCount:p.messages.length},checks:[]},v={...h,quality:y};if(!y.accepted)return yield*new i2({status:"quality_failed",context:{...v,issues:ai(y)}});let b=yield*s.SvU({try:()=>(function(e){let t=new Set(e.participants.map(e=>e.id));for(let r of e.participants){let e=nS(r.id);if(t.has(e))throw Error(`Sequence participant "${e}" collides with the generated lifeline for "${r.id}".`)}let r=e.participants.reduce((e,t)=>Math.max(e,Math.ceil(14*t.label.split("\n").length*1.35)+18),72),n=48+r,i=n+64,a=i+88*Math.max(0,e.messages.length-1),s=Math.max(i,a)-n+56,o=new Map,l=[],d=[],c=[];e.participants.forEach((t,i)=>{let a=48+320*i,u=a+90;o.set(t.id,u),l.push({type:"node",id:`node:${t.id}`,nodeId:t.id,...t.kind?{kind:t.kind}:{},shape:"rectangle",x:a,y:48,width:180,height:r,label:t.label}),d.push({type:"text",id:`label:${t.id}`,containerId:`node:${t.id}`,x:u,y:48+r/2,text:t.label,fontSize:14,maxWidth:156}),c.push({type:"node",id:`node:${nS(t.id)}`,nodeId:nS(t.id),rendererRole:nk,shape:"rectangle",fillColor:e.style.backgroundColor,strokeColor:e.style.accentColor,x:u-1,y:n,width:2,height:s,label:`${t.label} lifeline`})});let u=e.messages.map((e,t)=>{let r=o.get(e.source),n=o.get(e.target);if(void 0===r||void 0===n)throw Error(`Sequence message "${e.id}" references an unknown participant.`);if(r===n)throw Error(`Sequence message "${e.id}" cannot target its source participant.`);let a=i+88*t,s=n>r?1:-1;return{type:"arrow",id:`arrow:${e.id}`,edgeId:e.id,sourceNodeId:nS(e.source),targetNodeId:nS(e.target),..."return"===e.type?{strokeColor:"#6b7280"}:{},..."dashed"===e.style||"return"===e.type?{strokeStyle:"dashed"}:{},points:[{x:r+2*s/2,y:a},{x:n-2*s/2,y:a}],label:e.label}}),f=[...u,...c,...l,...d],p=[...c.map(e=>e.id),...l.map(e=>e.id),...d.map(e=>e.id),...u.map(e=>e.id)];return{kind:"canvas",version:1,diagramId:e.id,title:e.title,width:276+320*Math.max(0,e.participants.length-1),height:n+s+48,accentColor:e.style.accentColor,backgroundColor:e.style.backgroundColor,elements:f,layers:[],layouts:[],zOrder:p}})(p),catch:e=>new i2({status:"render_failed",context:{...v,issues:[i9({code:"render_failed",stage:"render",ref:{kind:"diagram",id:p.id},message:e instanceof Error?e.message:"Unable to render sequence diagram scene.",hint:"Repair the participant/message structure and retry."})]}})}).pipe(s.fRP("codeMode.buildSequenceDiagram.render")),_=ea(b);if(_.length>0)return yield*new i2({status:"render_failed",context:{...v,issues:ad(_).map(e=>({...e,hint:"Reduce participant label lines, participants, or messages and retry buildSequenceDiagram."}))}});let x={...v,partial:aT(b)},w=yield*aN({scene:b,formats:aa(u.options),inlineFormats:as(u.options),...u.requestId?{requestId:u.requestId}:{},validationIssues:al}).pipe(s.xm_(e=>new i2({status:e.status,context:{..."export_failed"===e.status?x:v,issues:e.issues}})));return{ok:!0,status:"accepted",buildId:f,...aC(u.requestId),normalizedSpec:p,quality:y,artifact:w,issues:[]}}),aj=i._kM({spec:i.$r1,requestId:i.Qrq(i.$r1)}),aD=i._kM({source:i._kM({scene:i.$r1})}),aU=s.fn("codeMode.canvas.serializedLimit")((e,t)=>s.SvU(()=>r8(e)).pipe(s.YWq({onFailure:()=>i9({code:"invalid_type",stage:"input",ref:{kind:"request",path:t},message:"CanvasSpec could not be serialized as JSON.",hint:"Remove non-JSON values or reduce deeply nested fields and retry."}),onSuccess:e=>e<=er.maxSerializedBytes?void 0:i9({code:"canvas_limit_exceeded",stage:"canvas",ref:{kind:"request",path:t},message:`CanvasSpec exceeds ${er.maxSerializedBytes} serialized bytes.`,hint:"Split the visualization into a smaller canvas or reduce repeated text and points."})}))),aF=s.fn("codeMode.createCanvas.workflow")(function*(e){let t=yield*iY,r=yield*s.OH5(()=>t.createId("build")),n=i.q$Z(aj)(e),a=u.oJ(n)?{spec:n.success.spec,requestId:i.is(i.QfV)(n.success.requestId)?n.success.requestId:void 0}:void 0;if(a){let e=yield*aU(a.spec,"spec");if(e)return yield*new i5({status:"canvas_limit_exceeded"===e.code?"limit_exceeded":"invalid_input",context:{buildId:r,...aC(a.requestId),issues:[e]}})}let o=rt.safeParse(e);if(!o.success)return yield*new i5({status:"invalid_input",context:{issues:at(o.error)}});let l=o.data,d={buildId:r,...aC(l.requestId)},c=au(l.spec);if(!c)return yield*new i5({status:"invalid_canvas",context:{...d,issues:[i9({code:"invalid_canvas_geometry",stage:"canvas",ref:{kind:"request",path:"spec.elements"},message:"CanvasSpec contains an invalid point list.",hint:"Provide at least two points for lines/connectors and three points for polygons."})]}});let f=ea(c).filter(e=>"limit_exceeded"===e.code);if(f.length>0)return yield*new i5({status:"limit_exceeded",context:{...d,issues:ad(f)}});let p=function(e){let t=[...e.elements];for(let r of e.layouts)t=function(e,t){switch(t.type){case"row":case"column":case"stack":return function(e,t){let r=eo(e,t.ids),n=r[0];if(!n)return[...e];let i=es(n),a=t.x??i.x,s=t.y??i.y,o="stack"===t.type?t.gap??0:t.gap??32,l=new Map,d="column"===t.type?s:a;for(let e of r){let r=es(e);l.set(e.id,{x:"column"===t.type||"stack"===t.type?a:d,y:"column"===t.type?d:s}),"stack"!==t.type&&(d+=("column"===t.type?r.height:r.width)+o)}return el(e,l)}(e,t);case"grid":return function(e,t){let r=eo(e,t.ids);if(0===r.length)return[...e];let n=Math.max(1,Math.floor(t.columns)),i=r.map(es),a=Array.from({length:n},(e,t)=>Math.max(0,...i.filter((e,r)=>r%n===t).map(e=>e.width))),s=Array.from({length:Math.ceil(r.length/n)},(e,t)=>Math.max(0,...i.filter((e,r)=>Math.floor(r/n)===t).map(e=>e.height))),o=i[0];if(!o)return[...e];let l=t.x??o.x,d=t.y??o.y,c=t.columnGap??32,u=t.rowGap??32,f=new Map;return r.forEach((e,t)=>{let r=t%n,i=Math.floor(t/n);f.set(e.id,{x:l+a.slice(0,r).reduce((e,t)=>e+t,0)+c*r,y:d+s.slice(0,i).reduce((e,t)=>e+t,0)+u*i})}),el(e,f)}(e,t);case"align":return function(e,t){let r=eo(e,t.ids);if(0===r.length)return[...e];let n=r.map(es),i=n.map(e=>ed(e,t.axis)),a=n.map(e=>ed(e,t.axis)+ec(e,t.axis)),s=n.map(e=>ed(e,t.axis)+ec(e,t.axis)/2),o="start"===t.alignment?Math.min(...i):"end"===t.alignment?Math.max(...a):s.reduce((e,t)=>e+t,0)/s.length,l=new Map;return r.forEach((e,r)=>{let i=n[r];if(!i)return;let a="start"===t.alignment?o:"end"===t.alignment?o-ec(i,t.axis):o-ec(i,t.axis)/2;l.set(e.id,{x:"x"===t.axis?a:i.x,y:"y"===t.axis?a:i.y})}),el(e,l)}(e,t);case"distribute":return function(e,t){let r=eo(e,t.ids).sort((e,r)=>ed(es(e),t.axis)-ed(es(r),t.axis));if(r.length<2)return[...e];let n=r.map(es),i=n[0],a=n[n.length-1];if(!i||!a)return[...e];let s=ed(i,t.axis),o=ed(a,t.axis)+ec(a,t.axis),l=n.reduce((e,r)=>e+ec(r,t.axis),0),d=t.gap??Math.max(0,(o-s-l)/(r.length-1)),c=new Map,u=s;return r.forEach((e,r)=>{let i=n[r];i&&(c.set(e.id,{x:"x"===t.axis?u:i.x,y:"y"===t.axis?u:i.y}),u+=ec(i,t.axis)+d)}),el(e,c)}(e,t)}}(t,r);let r=function(e){let t=1,r=1;for(let n of e)if(ei(n)){let e=es(n);t=Math.max(t,e.x+e.width),r=Math.max(r,e.y+e.height)}else if("arrow"===n.type||"line"===n.type)for(let e of n.points)t=Math.max(t,e.x),r=Math.max(r,e.y);return{width:t+48,height:r+48}}(t=function(e){let t=new Map(e.filter(e=>"node"===e.type).map(e=>[e.nodeId,e])),r=new Map;for(let t of e)("node"===t.type||"frame"===t.type)&&r.set(t.id,t);let n=e.map(e=>{if("arrow"===e.type){let r=t.get(e.sourceNodeId),n=t.get(e.targetNodeId);return r&&n?{...e,points:[ef(r,eu(n)),...e.points.slice(1,-1),ef(n,eu(r))]}:e}if("line"===e.type){let t=e.startBinding?r.get(e.startBinding.elementId):void 0,n=e.endBinding?r.get(e.endBinding.elementId):void 0;if(!t&&!n)return e;let i=[e.points[0],e.points[1],...e.points.slice(2)];return t&&(i[0]=ef(t,n?eu(n):i[i.length-1]??i[0])),n&&(i[i.length-1]=ef(n,t?eu(t):i[0])),{...e,points:i}}return e}),i=new Map(n.map(e=>[e.id,e]));return n.map(e=>{if("text"!==e.type||!e.containerId)return e;let t=i.get(e.containerId);if(t?.type==="node"){let r=eu(t);return{...e,x:r.x,y:r.y}}if(t?.type==="arrow"){let r=t.points[0],n=t.points[t.points.length-1]??r;return{...e,x:(r.x+n.x)/2,y:(r.y+n.y)/2}}return e})}(t)),n=e.zOrder.length?[...e.zOrder]:t.map((e,t)=>({element:e,index:t})).sort((e,t)=>(e.element.zIndex??e.index)-(t.element.zIndex??t.index)).map(({element:e})=>e.id);return{...e,width:Math.max(e.width,r.width),height:Math.max(e.height,r.height),elements:t,zOrder:n}}(c),h=ea(p);if(h.length>0){let e=ad(h);return yield*new i5({status:e.some(e=>"canvas_limit_exceeded"===e.code)?"limit_exceeded":"invalid_canvas",context:{...d,normalizedSpec:p,issues:e}})}let m={...d,normalizedSpec:p,partial:aT(p)},g=yield*aN({scene:p,formats:aa(l.options),inlineFormats:as(l.options),...l.requestId?{requestId:l.requestId}:{},validationIssues:ac}).pipe(s.xm_(e=>new i5({status:e.status,context:{...m,issues:e.issues}})));return{ok:!0,status:"accepted",buildId:r,...aC(l.requestId),normalizedSpec:p,artifact:g,issues:[]}}),aB=s.fn("codeMode.buildFlowchart.workflow")(function*(e){var t,r;let n,i=tE.safeParse(e);if(!i.success)return yield*new i0({status:"invalid_input",context:{issues:at(i.error)}});let a=yield*iY,o=i.data,l=yield*s.OH5(()=>a.createId("build")),d=(n=eh((r=o.spec).title),{id:iU(r.id)??(n.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"sketchi-flowchart"),title:n,nodes:r.nodes.map(e=>({id:eh(e.id),label:eh(e.label),kind:e.kind,...e.description?{description:eh(e.description)}:{}})),edges:r.edges.map((e,t)=>({id:iU(e.id)??`edge-${t+1}`,source:eh(e.source),target:eh(e.target),...e.label?{label:eh(e.label)}:{}})),layout:{direction:r.layout.direction},style:{...g}}),c={buildId:l,...aC(o.requestId),normalizedSpec:d},u=eb(L,{id:d.id,title:d.title,type:"flowchart",nodes:d.nodes.map(e=>({...e,metadata:{}})),edges:d.edges.map(e=>({...e,metadata:{}})),layout:{direction:d.layout.direction,edgeRouting:"orthogonal"},style:d.style,metadata:{}});if(!u.success)return yield*new i0({status:"invalid_flowchart",context:{...c,issues:(t=u.error,t.issues.slice(0,20).map(e=>{let t=function(e,t){let r=i4(e.path),n="input"===r?"spec":`spec.${r}`,[i,a]=e.path;if("nodes"===i&&"number"==typeof a){let e=t.nodes[a]?.id;return{kind:"node",...e?{id:e}:{},path:n}}if("edges"===i&&"number"==typeof a){let e=t.edges[a]?.id;return{kind:"edge",...e?{id:e}:{},path:n}}return{kind:"diagram",id:t.id,path:n}}(e,d);return i9({code:i7(e),stage:"flowchart",ref:t,message:e.message,hint:`Fix ${t.path??"spec"} so normalization produces a valid canonical flowchart value.`})}))}});let f=u.data,p=J(f).map(e=>{let t=function(e){if(e)return{kind:e.kind,...e.id?{id:e.id}:{},...e.path?{path:`spec.${e.path}`}:{}}}(e.ref);return i9({code:e.code,stage:"flowchart",...t?{ref:t}:{},message:e.message,hint:e.hint})});if(p.length>0)return yield*new i0({status:"invalid_flowchart",context:{...c,issues:p}});X(f);let h=function(e,t){let r=[],n=0,i=(e,t,i,a=!1)=>{n+=e,r.push({...i,passed:!1,severity:a?"error":"warning",message:t})},a=new Map,s=new Map;for(let t of e.edges)a.set(t.source,(a.get(t.source)??0)+1),a.set(t.target,(a.get(t.target)??0)+1),s.set(t.source,[...s.get(t.source)??[],t]);if(e.nodes.length>1&&0===e.edges.length)i(5,"no edges at all — every node floats unconnected",{code:"disconnected_graph",refs:iD(e.nodes)},!0);else{let t=e.nodes.filter(e=>(a.get(e.id)??0)===0);t.length>0&&e.nodes.length>1&&i(Math.min(1.5*t.length,4.5),`unconnected node(s): ${t.map(e=>e.id).join(", ")}`,{code:"disconnected_graph",refs:iD(t)},!0);let r=function(e){let t=new Map;for(let r of e.nodes)t.set(r.id,[]);for(let r of e.edges)t.get(r.source)?.push(r.target),t.get(r.target)?.push(r.source);let r=new Set,n=0;for(let i of e.nodes){if(r.has(i.id))continue;n+=1;let e=[i.id];for(r.add(i.id);e.length>0;){let n=e.pop();if(void 0===n)break;for(let i of t.get(n)??[])r.has(i)||(r.add(i),e.push(i))}}return n}(e);r>1&&0===t.length&&i(2,`diagram splits into ${r} disconnected islands`,{code:"disconnected_graph",refs:iD(e.nodes)},!0)}e.nodes.length<3?i(2,"too sparse — a useful flow needs at least 3 nodes",{code:"graph_too_sparse",refs:[{kind:"diagram",id:e.id,path:"spec.nodes"}]}):e.nodes.length>24&&i(2,"too dense — trim or merge nodes (24 max)",{code:"graph_too_dense",refs:[{kind:"diagram",id:e.id,path:"spec.nodes"}]});let o=new Map;for(let t of e.nodes){let e=t.label.trim().toLowerCase();o.set(e,(o.get(e)??0)+1)}let l=[...o.entries()].filter(([,e])=>e>1);l.length>0&&i(Math.min(l.length,3),`duplicate label(s): ${l.map(([e])=>`"${e}"`).join(", ")}`,{code:"duplicate_label",refs:iD(e.nodes.filter(e=>(o.get(e.label.trim().toLowerCase())??0)>1))});let d=0,c=0;for(let t of e.nodes){if("decision"!==t.kind){t.label.endsWith("?")&&i(0,`question label on non-decision node "${t.id}"; use kind "decision" only for branch points`,{code:"question_label_not_decision",refs:iD([t])});continue}let e=s.get(t.id)??[];e.length<2?(d+=1,i(0,`decision "${t.id}" needs at least 2 outgoing branches`,{code:"underbranched_decision",refs:iD([t])},!0)):e.some(e=>!e.label)&&(c+=1,i(0,`label every branch out of decision "${t.id}" (yes/no, …)`,{code:"unlabeled_decision_branch",refs:iD([t])}))}n+=Math.min(1.5*d,4.5)+Math.min(c,3);let u=e.nodes.filter(e=>e.label.length>42);u.length>0&&i(Math.min(.5*u.length,2),`shorten label(s): ${u.map(e=>e.id).join(", ")}`,{code:"label_too_long",refs:iD(u)});let f=e.nodes.filter(e=>iR.test(e.label.trim()));f.length>0&&i(Math.min(f.length,3),`generic label(s) say nothing: ${f.map(e=>`"${e.label}"`).join(", ")}`,{code:"generic_label",refs:iD(f)}),(e.title.trim().length<4||ij.test(e.title.trim()))&&i(.5,"give the diagram a specific title",{code:"weak_title",refs:[{kind:"diagram",id:e.id,path:"spec.title"}]});let p=Math.max(0,Math.round((10-n)*10)/10);return{accepted:p>=t&&!r.some(e=>"error"===e.severity),score:p,threshold:t,summary:{nodeCount:e.nodes.length,edgeCount:e.edges.length},checks:r}}(f,o.options?.minQualityScore??8),m={...c,quality:h};if(!h.accepted)return yield*new i0({status:"quality_failed",context:{...m,issues:ai(h)}});let y=yield*s.SvU({try:()=>nw(f),catch:e=>new i0({status:"render_failed",context:{...m,issues:[i9({code:"render_failed",stage:"render",ref:{kind:"diagram",id:d.id},message:e instanceof Error?e.message:"Unable to render flowchart scene.",hint:"Simplify the graph or retry with a smaller flowchart."})]}})}).pipe(s.fRP("codeMode.buildFlowchart.render")),v={...m,partial:aT(y)},b=yield*aN({scene:y,formats:aa(o.options),inlineFormats:as(o.options),...o.requestId?{requestId:o.requestId}:{},validationIssues:al}).pipe(s.xm_(e=>new i0({status:e.status,context:{..."export_failed"===e.status?v:m,issues:e.issues}})));return{ok:!0,status:"accepted",buildId:l,...aC(o.requestId),normalizedSpec:d,quality:h,artifact:b,issues:[]}}),aL=s.fn("codeMode.getArtifact.workflow")(function*(e){let t=ro.safeParse(e);if(!t.success)return yield*new i3({status:"invalid_input",context:{issues:at(t.error)}});let r=yield*iY,n=yield*r2,i=t.data,a=yield*n.readManifest(i.artifactId).pipe(s.xm_(e=>new i3({status:"storage_failed",context:{issues:[aA(e,"storage_read_failed")]}})));if(!a)return yield*new i3({status:"not_found",context:{issues:[i9({code:"patch_source_unavailable",stage:"storage",ref:{kind:"artifact",id:i.artifactId},message:`Artifact "${i.artifactId}" was not found.`,hint:"Use the artifactId returned by buildFlowchart or applyDiagramPatch."})]}});let o=i.format??"scene";if(!a.formats.some(e=>e.format===o))return yield*new i3({status:"format_unavailable",context:{issues:[i9({code:"unsupported_artifact_format",stage:"storage",ref:{kind:"artifact",id:i.artifactId},message:`Artifact "${i.artifactId}" does not include format "${o}".`,hint:"Request a format listed in the artifact bundle."})]}});let l=yield*n.read(i.artifactId,o).pipe(s.xm_(e=>new i3({status:"storage_failed",context:{issues:[aA(e,"storage_read_failed")]}})));return l?{ok:!0,artifactId:i.artifactId,diagramId:a.diagramId,format:o,mimeType:l.mimeType,...r.artifactUrl?{url:r.artifactUrl({artifactId:i.artifactId,format:o})}:{},...!0!==i.inline||!r3(o)?{}:{inline:l.data},sizeBytes:l.sizeBytes,...a.provenance?{provenance:a.provenance}:{}}:yield*new i3({status:"format_unavailable",context:{issues:[i9({code:"patch_source_unavailable",stage:"storage",ref:{kind:"artifact",id:i.artifactId},message:`Artifact "${i.artifactId}" format "${o}" could not be read.`,hint:"Retry retrieval or rebuild the artifact."})]}})}),az=s.fn("codeMode.applyDiagramPatch.workflow")(function*(e){let t,r=i.q$Z(aD)(e),n=u.oJ(r)?yield*aU(r.success.source.scene,"source.scene"):void 0;if(n)return yield*new i6({status:"invalid_input",context:{issues:[n]}});let a=rM.safeParse(e);if(!a.success)return yield*new i6({status:"invalid_input",context:{issues:at(a.error)}});let o=yield*iY,l=a.data,d=yield*s.OH5(()=>o.createId("patch")),c={patchId:d,...aC(l.requestId)},f=yield*aO(l).pipe(s.xm_(e=>new i6({status:e.status,context:{...c,...e.context}}))),p={...c,...f.sourceArtifactId?{sourceArtifactId:f.sourceArtifactId}:{}},h=f.scene;if(h.elements.length>er.maxElements)t=[{code:"limit_exceeded",message:`Canvas exceeds ${er.maxElements} elements.`,path:"elements"}];else{let e=au(h);t=e?ea(e).filter(e=>"limit_exceeded"===e.code):[]}if(t.length>0)return yield*new i6({status:"invalid_input",context:{...p,issues:ad(t)}});let m=ap(h),g=[];for(let e of l.operations)if((g=function(e,t){switch(t.op){case"setDefaultStyle":case"setStyle":if(t.style.backgroundColor&&(e.backgroundColor=t.style.backgroundColor),"setDefaultStyle"===t.op){for(let r of(t.style.strokeColor&&(e.accentColor=t.style.strokeColor),ah(e)))t.style.fillColor&&(r.fillColor=t.style.fillColor),t.style.strokeColor&&(r.strokeColor=t.style.strokeColor),t.style.textColor&&(r.textColor=t.style.textColor);for(let r of ag(e))t.style.strokeColor&&(r.strokeColor=t.style.strokeColor),t.style.textColor&&(r.textColor=t.style.textColor);for(let r of am(e))t.style.textColor&&(r.textColor=t.style.textColor);return[]}let r=av(e,t.selector);if(0===r.nodes.length&&0===r.arrows.length&&0===r.texts.length)return[ab(t)];for(let n of r.nodes)if(t.style.fillColor&&(n.fillColor=t.style.fillColor),t.style.strokeColor&&(n.strokeColor=t.style.strokeColor),t.style.textColor){n.textColor=t.style.textColor;let r=a_(e,n.id);r&&(r.textColor=t.style.textColor)}for(let n of r.arrows)if(t.style.strokeColor&&(n.strokeColor=t.style.strokeColor),t.style.textColor){n.textColor=t.style.textColor;let r=a_(e,n.id);r&&(r.textColor=t.style.textColor)}for(let e of r.texts)t.style.textColor&&(e.textColor=t.style.textColor);return[];case"setShape":let n=av(e,t.selector);if(0===n.nodes.length)return[ab(t)];let i=[];for(let r of n.nodes){if(r.shape=t.shape,"polygon"===t.shape?r.points=[{x:r.width/2,y:0},{x:r.width,y:r.height/2},{x:r.width/2,y:r.height},{x:0,y:r.height/2}]:delete r.points,"circle"===t.shape){let e=Math.max(r.width,r.height);r.x-=(e-r.width)/2,r.y-=(e-r.height)/2,r.width=e,r.height=e,i.push(r.nodeId)}!function(e,t){let r=a_(e,t.id);r&&(r.x=t.x+t.width/2,r.y=t.y+t.height/2)}(e,r)}return ax(e,i),[];case"translate":return function(e,t){let r=av(e,t.selector);if(0===r.nodes.length&&0===r.arrows.length&&0===r.texts.length)return[ab(t)];let n=new Set,i=new Set;for(let a of r.nodes){a.x+=t.dx,a.y+=t.dy,n.add(a.nodeId);let r=a_(e,a.id);r&&(r.x+=t.dx,r.y+=t.dy,i.add(r.id))}for(let n of r.arrows){n.points=n.points.map(e=>{var r,n;return r=t.dx,n=t.dy,{x:e.x+r,y:e.y+n}});let r=a_(e,n.id);r&&(r.x+=t.dx,r.y+=t.dy,i.add(r.id))}for(let e of r.texts)i.has(e.id)||(e.x+=t.dx,e.y+=t.dy);return ax(e,[...n]),aI(e),[]}(e,t);case"replaceText":let a=av(e,t.selector);if(0===a.nodes.length&&0===a.arrows.length&&0===a.texts.length)return[ab(t)];for(let r of a.nodes){r.label=t.text;let n=a_(e,r.id);n&&(n.text=t.text)}for(let r of a.arrows){r.label=t.text;let n=a_(e,r.id);n&&(n.text=t.text)}for(let e of a.texts)e.text=t.text;return[];case"rerouteEdges":let s;return 0===(s=av(e,t.selector)).arrows.length?[ab(t)]:s.arrows.flatMap(t=>aS(e,t));case"insert":let o=new Set(e.elements.map(e=>e.id)),l=t.elements.map(e=>e.id);if(new Set(l).size!==l.length||l.some(e=>o.has(e)))return aE(t,"Inserted elements must use ids that are unique within the canvas.");let d=a$(e.zOrder,t.beforeId,t.afterId);return void 0===d?aE(t,"Insert specifies an unknown anchor or both beforeId and afterId."):(e.elements.push(...t.elements.map(e=>structuredClone(e))),e.zOrder.splice(d,0,...l),[]);case"remove":return function(e,t){let r,n=function(e,t){let r=av(e,t),n=new Set([...r.nodes.map(e=>e.id),...r.arrows.map(e=>e.id),...r.texts.map(e=>e.id)]),i=new Set(t.ids??[]);for(let t of e.elements)i.has(t.id)&&n.add(t.id);return n}(e,t.selector);if(0===n.size)return[ab(t)];let i=new Set(e.elements.flatMap(e=>"node"===e.type&&n.has(e.id)?[e.nodeId]:[]));do for(let t of(r=n.size,e.elements))("text"===t.type&&t.containerId&&n.has(t.containerId)||"arrow"===t.type&&(i.has(t.sourceNodeId)||i.has(t.targetNodeId))||"line"===t.type&&(t.startBinding&&n.has(t.startBinding.elementId)||t.endBinding&&n.has(t.endBinding.elementId)))&&n.add(t.id);while(n.size!==r)let a=e.elements.filter(e=>!n.has(e.id)).map(e=>{if(e.frameId&&n.has(e.frameId)){let{frameId:t,...r}=e;return r}return e});e.elements.splice(0,e.elements.length,...a);let s=e.zOrder.filter(e=>!n.has(e));e.zOrder.splice(0,e.zOrder.length,...s);let o=e.layouts.map(e=>({...e,ids:e.ids.filter(e=>!n.has(e))})).filter(e=>e.ids.length>0);return e.layouts.splice(0,e.layouts.length,...o),aI(e),[]}(e,t);case"replace":let c;return(c=e.elements.findIndex(e=>e.id===t.id))<0?[ab(t)]:t.element.id!==t.id?aE(t,"Replacement element id must match the stable id being replaced."):(e.elements.splice(c,1,structuredClone(t.element)),aI(e),[]);case"reorder":let u=new Set(t.ids);if(u.size!==t.ids.length||t.ids.some(t=>!e.zOrder.includes(t)))return aE(t,"Reorder ids must be unique ids already present in zOrder.");let f=e.zOrder.filter(e=>!u.has(e)),p=a$(f,t.beforeId,t.afterId);return void 0===p?aE(t,"Reorder specifies an unknown anchor or both beforeId and afterId."):(f.splice(p,0,...t.ids),e.zOrder.splice(0,e.zOrder.length,...f),[]);case"group":case"ungroup":let h=new Set(t.ids);if(t.ids.some(t=>!e.elements.some(e=>e.id===t)))return[ab(t)];let m=e.elements.map(e=>h.has(e.id)?"group"===t.op?{...e,groupIds:[...new Set([...e.groupIds??[],t.groupId])]}:{...e,groupIds:t.groupId?(e.groupIds??[]).filter(e=>e!==t.groupId):[]}:e);return e.elements.splice(0,e.elements.length,...m),[]}}(h,e)).length>0)break;if(g.length>0)return yield*new i6({status:g[0]?.code==="unknown_patch_target"?"target_not_found":"unsupported_operation",context:{...p,issues:g}});if(l.options?.preserveConnectivity!==!1){let e=ap(h);if(!(m.length===e.length&&m.every((t,r)=>t===e[r])))return yield*new i6({status:"connectivity_changed",context:{...p,issues:[i9({code:"patch_preserve_connectivity_failed",stage:"flowchart",ref:{kind:"diagram",id:h.diagramId},message:"Patch changed the diagram edge connectivity.",hint:"Use buildFlowchart for process-graph structure or buildMindmap for hierarchy structure."})]}})}let y=au(h);if(!y)return yield*new i6({status:"render_failed",context:{...p,issues:[i9({code:"patch_output_invalid",stage:"render",ref:{kind:"diagram",id:h.diagramId},message:"Patched scene has an invalid arrow point list.",hint:"Reroute edges or rebuild the flowchart artifact."})]}});let v=ea(y);if(v.length>0)return yield*new i6({status:"render_failed",context:{...p,partial:aT(y),issues:ad(v)}});let b={...p,partial:aT(y)},_=yield*aN({scene:y,formats:aa(l.options),inlineFormats:as(l.options),...l.requestId?{requestId:l.requestId}:{},validationIssues:ac,...f.sourceArtifactId?{provenance:{sourceArtifactId:f.sourceArtifactId}}:{}}).pipe(s.xm_(e=>new i6({status:e.status,context:{..."export_failed"===e.status?b:p,issues:e.issues}})));return{ok:!0,status:"accepted",patchId:d,...aC(l.requestId),...f.sourceArtifactId?{sourceArtifactId:f.sourceArtifactId}:{},artifact:_,issues:[]}});function aW(e,t,r){return s.fn(`codeMode.${e}`)(n=>{var i,a,l;let d,c,u,f;return i=e,a=n,l=t(n).pipe(s.YWq({onFailure:r,onSuccess:e=>e})),iN(s.JkU(function*(){let e=yield*o.Ru,t=yield*l,r=yield*o.Ru,n=t.ok?"success":"failure",a=t.ok?void 0:t.status??"unknown_failure";yield*iP(iL,1,{...a?{failureCategory:a}:{},operation:i,outcome:n,surface:"code_mode"}),yield*iP(iJ,r-e,{...a?{failureCategory:a}:{},operation:i,outcome:n,surface:"code_mode"}),a&&(yield*iP(iz,1,{failureCategory:a,operation:i,surface:"code_mode"}));let s="buildFlowchart"===i?"flowchart":"buildMindmap"===i?"mindmap":"buildSequenceDiagram"===i?"sequence":"createCanvas"===i?"canvas":"applyDiagramPatch"===i?"patch":void 0;return t.ok&&s&&(yield*iP(iW,1,{artifactKind:s,operation:i,surface:"code_mode"})),t}),(d=iq(a),c=iq(d?.source),u="string"==typeof d?.artifactId?d.artifactId:"string"==typeof c?.artifactId?c.artifactId:void 0,f="string"==typeof d?.requestId?d.requestId:void 0,{...u?{artifactId:u}:{},...f?{requestId:f}:{}}))})}let aJ=aW("buildFlowchart",aB,aM),aY=aW("buildMindmap",aP,aM),aX=aW("buildSequenceDiagram",aR,aM);aW("createCanvas",aF,aM),aW("getArtifact",aL,aM);let aq=aW("applyDiagramPatch",az,aM)},9095(e){e.exports=JSON.parse('[{"name":"Agola CI","constant":"AGOLA","env":"AGOLA_GIT_REF","pr":"AGOLA_PULL_REQUEST_ID"},{"name":"Alpic","constant":"ALPIC","env":"ALPIC_HOST"},{"name":"Appcircle","constant":"APPCIRCLE","env":"AC_APPCIRCLE","pr":{"env":"AC_GIT_PR","ne":"false"}},{"name":"AppVeyor","constant":"APPVEYOR","env":"APPVEYOR","pr":"APPVEYOR_PULL_REQUEST_NUMBER"},{"name":"AWS CodeBuild","constant":"CODEBUILD","env":"CODEBUILD_BUILD_ARN","pr":{"env":"CODEBUILD_WEBHOOK_EVENT","any":["PULL_REQUEST_CREATED","PULL_REQUEST_UPDATED","PULL_REQUEST_REOPENED"]}},{"name":"Azure Pipelines","constant":"AZURE_PIPELINES","env":"TF_BUILD","pr":{"BUILD_REASON":"PullRequest"}},{"name":"Bamboo","constant":"BAMBOO","env":"bamboo_planKey"},{"name":"Bitbucket Pipelines","constant":"BITBUCKET","env":"BITBUCKET_COMMIT","pr":"BITBUCKET_PR_ID"},{"name":"Bitrise","constant":"BITRISE","env":"BITRISE_IO","pr":"BITRISE_PULL_REQUEST"},{"name":"Buddy","constant":"BUDDY","env":"BUDDY_WORKSPACE_ID","pr":"BUDDY_EXECUTION_PULL_REQUEST_ID"},{"name":"Buildkite","constant":"BUILDKITE","env":"BUILDKITE","pr":{"env":"BUILDKITE_PULL_REQUEST","ne":"false"}},{"name":"CircleCI","constant":"CIRCLE","env":"CIRCLECI","pr":"CIRCLE_PULL_REQUEST"},{"name":"Cirrus CI","constant":"CIRRUS","env":"CIRRUS_CI","pr":"CIRRUS_PR"},{"name":"Cloudflare Pages","constant":"CLOUDFLARE_PAGES","env":"CF_PAGES"},{"name":"Cloudflare Workers","constant":"CLOUDFLARE_WORKERS","env":"WORKERS_CI"},{"name":"Codefresh","constant":"CODEFRESH","env":"CF_BUILD_ID","pr":{"any":["CF_PULL_REQUEST_NUMBER","CF_PULL_REQUEST_ID"]}},{"name":"Codemagic","constant":"CODEMAGIC","env":"CM_BUILD_ID","pr":"CM_PULL_REQUEST"},{"name":"Codeship","constant":"CODESHIP","env":{"CI_NAME":"codeship"}},{"name":"Drone","constant":"DRONE","env":"DRONE","pr":{"DRONE_BUILD_EVENT":"pull_request"}},{"name":"dsari","constant":"DSARI","env":"DSARI"},{"name":"Earthly","constant":"EARTHLY","env":"EARTHLY_CI"},{"name":"Expo Application Services","constant":"EAS","env":"EAS_BUILD"},{"name":"Gerrit","constant":"GERRIT","env":"GERRIT_PROJECT"},{"name":"Gitea Actions","constant":"GITEA_ACTIONS","env":"GITEA_ACTIONS"},{"name":"GitHub Actions","constant":"GITHUB_ACTIONS","env":"GITHUB_ACTIONS","pr":{"GITHUB_EVENT_NAME":"pull_request"}},{"name":"GitLab CI","constant":"GITLAB","env":"GITLAB_CI","pr":"CI_MERGE_REQUEST_ID"},{"name":"GoCD","constant":"GOCD","env":"GO_PIPELINE_LABEL"},{"name":"Google Cloud Build","constant":"GOOGLE_CLOUD_BUILD","env":"BUILDER_OUTPUT"},{"name":"Harness CI","constant":"HARNESS","env":"HARNESS_BUILD_ID"},{"name":"Heroku","constant":"HEROKU","env":{"env":"NODE","includes":"/app/.heroku/node/bin/node"}},{"name":"Hudson","constant":"HUDSON","env":"HUDSON_URL"},{"name":"Jenkins","constant":"JENKINS","env":["JENKINS_URL","BUILD_ID"],"pr":{"any":["ghprbPullId","CHANGE_ID"]}},{"name":"LayerCI","constant":"LAYERCI","env":"LAYERCI","pr":"LAYERCI_PULL_REQUEST"},{"name":"Magnum CI","constant":"MAGNUM","env":"MAGNUM"},{"name":"Netlify CI","constant":"NETLIFY","env":"NETLIFY","pr":{"env":"PULL_REQUEST","ne":"false"}},{"name":"Nevercode","constant":"NEVERCODE","env":"NEVERCODE","pr":{"env":"NEVERCODE_PULL_REQUEST","ne":"false"}},{"name":"Prow","constant":"PROW","env":"PROW_JOB_ID"},{"name":"ReleaseHub","constant":"RELEASEHUB","env":"RELEASE_BUILD_ID"},{"name":"Render","constant":"RENDER","env":"RENDER","pr":{"IS_PULL_REQUEST":"true"}},{"name":"Sail CI","constant":"SAIL","env":"SAILCI","pr":"SAIL_PULL_REQUEST_NUMBER"},{"name":"Screwdriver","constant":"SCREWDRIVER","env":"SCREWDRIVER","pr":{"env":"SD_PULL_REQUEST","ne":"false"}},{"name":"Semaphore","constant":"SEMAPHORE","env":"SEMAPHORE","pr":"PULL_REQUEST_NUMBER"},{"name":"Sourcehut","constant":"SOURCEHUT","env":{"CI_NAME":"sourcehut"}},{"name":"Strider CD","constant":"STRIDER","env":"STRIDER"},{"name":"TaskCluster","constant":"TASKCLUSTER","env":["TASK_ID","RUN_ID"]},{"name":"TeamCity","constant":"TEAMCITY","env":"TEAMCITY_VERSION"},{"name":"Travis CI","constant":"TRAVIS","env":"TRAVIS","pr":{"env":"TRAVIS_PULL_REQUEST","ne":"false"}},{"name":"Vela","constant":"VELA","env":"VELA","pr":{"VELA_PULL_REQUEST":"1"}},{"name":"Vercel","constant":"VERCEL","env":{"any":["NOW_BUILDER","VERCEL"]},"pr":"VERCEL_GIT_PULL_REQUEST_ID"},{"name":"Visual Studio App Center","constant":"APPCENTER","env":"APPCENTER_BUILD_ID"},{"name":"Woodpecker","constant":"WOODPECKER","env":{"CI":"woodpecker"},"pr":{"CI_BUILD_EVENT":"pull_request"}},{"name":"Xcode Cloud","constant":"XCODE_CLOUD","env":"CI_XCODE_PROJECT","pr":"CI_PULL_REQUEST_NUMBER"},{"name":"Xcode Server","constant":"XCODE_SERVER","env":"XCS"}]')}},o={};function l(e){var t=o[e];if(void 0!==t)return t.exports;var r=o[e]={exports:{}};return s[e].call(r.exports,r,r.exports,l),r.exports}l.m=s,l.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return l.d(t,{a:t}),t},n=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,l.t=function(e,t){if(1&t&&(e=this(e)),8&t||"object"==typeof e&&e&&(4&t&&e.__esModule||16&t&&"function"==typeof e.then))return e;var i=Object.create(null);l.r(i);var a={};r=r||[null,n({}),n([]),n(n)];for(var s=2&t&&e;("object"==typeof s||"function"==typeof s)&&!~r.indexOf(s);s=n(s))Object.getOwnPropertyNames(s).forEach(t=>{a[t]=()=>e[t]});return a.default=()=>e,l.d(i,a),i},l.d=(e,t,r)=>{var n=(t,r)=>{for(var n in t)l.o(t,n)&&!l.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,[r]:t[n]})};n(t,"get"),n(r,"value")},l.f={},l.e=e=>Promise.all(Object.keys(l.f).reduce((t,r)=>(l.f[r](e,t),t),[])),l.u=e=>"chunks/"+e+"."+({548:"416192d3a8231af0",869:"cb4ed780b3b9a21a"})[e]+".js",l.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),l.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},l.nc=void 0,i={889:0},a=e=>{var t,r,n=e.__rspack_esm_ids,a=e.__webpack_modules__,s=e.__rspack_esm_runtime,o=0;for(t in a)l.o(a,t)&&(l.m[t]=a[t]);for(s&&s(l);o<n.length;o++)r=n[o],l.o(i,r)&&i[r]&&i[r][0](),i[n[o]]=0},l.f.j=function(e,t){var r=l.o(i,e)?i[e]:void 0;if(0!==r)if(r)t.push(r[1]);else{var n=import("./"+l.u(e)).then(a,t=>{throw 0!==i[e]&&(i[e]=void 0),t}),n=Promise.race([n,new Promise(t=>{r=i[e]=[t]})]);t.push(r[1]=n)}},l(1833);