sketchi 0.3.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -15
- package/THIRD_PARTY_NOTICES +1 -0
- package/chunks/{869.1a34851ea988ddca.js → 869.cacc093c4bbc5a04.js} +1 -1
- package/package.json +1 -1
- package/sketchi.js +53 -40
package/sketchi.js
CHANGED
|
@@ -1,21 +1,26 @@
|
|
|
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={2532(e){let{hasOwnProperty:t}=Object.prototype,r=(e,t={})=>{"string"==typeof t&&(t={section:t}),t.align=!0===t.align,t.newline=!0===t.newline,t.sort=!0===t.sort,t.whitespace=!0===t.whitespace||!0===t.align,t.platform=t.platform||"u">typeof process&&process.platform,t.bracketedArray=!1!==t.bracketedArray;let i="win32"===t.platform?"\r\n":"\n",a=t.whitespace?" = ":"=",o=[],l=t.sort?Object.keys(e).sort():Object.keys(e),c=0;t.align&&(c=s(l.filter(t=>null===e[t]||Array.isArray(e[t])||"object"!=typeof e[t]).map(t=>Array.isArray(e[t])?`${t}[]`:t).concat([""]).reduce((e,t)=>s(e).length>=s(t).length?e:t)).length);let u="",d=t.bracketedArray?"[]":"";for(let t of l){let r=e[t];if(r&&Array.isArray(r))for(let e of r)u+=s(`${t}${d}`).padEnd(c," ")+a+s(e)+i;else r&&"object"==typeof r?o.push(t):u+=s(t).padEnd(c," ")+a+s(r)+i}for(let a of(t.section&&u.length&&(u="["+s(t.section)+"]"+(t.newline?i+i:i)+u),o)){let s=n(a,".").join("\\."),o=(t.section?t.section+".":"")+s,l=r(e[a],{...t,section:o});u.length&&l.length&&(u+=i),u+=l}return u};function n(e,t){var r=0,n=0,i=0,a=[];do if(-1!==(i=e.indexOf(t,r))){if(r=i+t.length,i>0&&"\\"===e[i-1])continue;a.push(e.slice(n,i)),n=i+t.length}while(-1!==i)return a.push(e.slice(n)),a}let i=(e,r={})=>{r.bracketedArray=!1!==r.bracketedArray;let i=Object.create(null),a=i,s=null,l=/^\[([^\]]*)\]\s*$|^([^=]+)(=(.*))?$/i,c=e.split(/[\r\n]+/g),u={};for(let e of c){let n;if(!e||e.match(/^\s*[;#]/)||e.match(/^\s*$/))continue;let c=e.match(l);if(!c)continue;if(void 0!==c[1]){if("__proto__"===(s=o(c[1]))){a=Object.create(null);continue}a=i[s]=i[s]||Object.create(null);continue}let d=o(c[2]);r.bracketedArray?n=d.length>2&&"[]"===d.slice(-2):(u[d]=(u?.[d]||0)+1,n=u[d]>1);let f=n&&d.endsWith("[]")?d.slice(0,-2):d;if("__proto__"===f)continue;let h=!c[3]||o(c[4]),p="true"===h||"false"===h||"null"===h?JSON.parse(h):h;n&&(t.call(a,f)?Array.isArray(a[f])||(a[f]=[a[f]]):a[f]=[]),Array.isArray(a[f])?a[f].push(p):a[f]=p}let d=[];for(let e of Object.keys(i)){if(!t.call(i,e)||"object"!=typeof i[e]||Array.isArray(i[e]))continue;let r=n(e,".");a=i;let s=r.pop(),o=s.replace(/\\\./g,".");for(let e of r)"__proto__"!==e&&(t.call(a,e)&&"object"==typeof a[e]||(a[e]=Object.create(null)),a=a[e]);(a!==i||o!==s)&&(a[o]=i[e],d.push(e))}for(let e of d)delete i[e];return i},a=e=>e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"),s=e=>"string"!=typeof e||e.match(/[=\r\n]/)||e.match(/^\[/)||e.length>1&&a(e)||e!==e.trim()?JSON.stringify(e):e.split(";").join("\\;").split("#").join("\\#"),o=e=>{if(a(e=(e||"").trim())){"'"===e.charAt(0)&&(e=e.slice(1,-1));try{e=JSON.parse(e)}catch{}}else{let t=!1,r="";for(let n=0,i=e.length;n<i;n++){let i=e.charAt(n);if(t)-1!=="\\;#".indexOf(i)?r+=i:r+="\\"+i,t=!1;else if(-1!==";#".indexOf(i))break;else"\\"===i?t=!0:r+=i}return t&&(r+="\\"),r.trim()}return e};e.exports={parse:i,decode:i,stringify:r,encode:r,safe:s,unsafe:o}},3176(e,t,r){var n=r(3633),i=r(4239);e.exports={parse:function(e,t){var r=e.toString(),a=n.parse(r,t);return i.compile(a,r,t)}}},4239(e){e.exports={compile:function(e,t,r){var n=null;if((r=r||{}).useTemporal&&!(n=r.temporal||("u">typeof Temporal?Temporal:null)))throw Error("The `useTemporal` option was set, but no Temporal implementation is available. Use a runtime with global `Temporal` support, or provide an implementation (e.g. from the `@js-temporal/polyfill` package) via the `temporal` option.");for(var i=new Set,a=new Set,s=new Set,o=[],l=new WeakSet,c=b(),u=c,d=e,f,h=0;h<d.length;h++)switch((f=d[h]).type){case"Assign":!function(e){var t=e.key,r=e.value,l=e.offset;Array.isArray(t)||(t=[t]);for(var c=function e(t){if("Array"===t.type)return t.value.map(e);if("InlineTable"===t.type)return function(t){for(var r=b(),n=new Set,i=0;i<t.length;i++){var a=t[i];if("InlineTableValue"===a.type){var s=a.key;Array.isArray(s)||(s=[s]),function(e,t,r,n,i){for(var a=0;a<t.length-1;a++){var s=t[a],o=w(t.slice(0,a+1));void 0===e[s]?e[s]=b():"object"!=typeof e[s]||null===e[s]||Array.isArray(e[s])?p("Cannot redefine existing key '"+o+"'.",n):i&&i.has(o)&&p("Cannot extend inline table '"+o+"'.",n),e=e[s]}var l=t[t.length-1];void 0!==e[l]&&p("Cannot redefine existing key '"+w(t)+"'.",n),e[l]=r}(r,s,e(a.value),a.offset,n),n.add(w(s))}}return r}(t.value);if(n)switch(t.type){case"Date":return n.ZonedDateTime.from(m(t.raw)+t.tz+"["+("Z"===t.tz?"UTC":t.tz)+"]");case"LocalDateTime":return n.PlainDateTime.from(m(t.value));case"LocalDate":return n.PlainDate.from(t.value);case"LocalTime":return n.PlainTime.from(m(t.value))}return t.value}(r),d=u,f=0;f<t.length-1;f++){var h=t[f],g=x(t.slice(0,f+1));void 0===d[h]?(d[h]=b(),i.add(g)):"object"!=typeof d[h]||null===d[h]||Array.isArray(d[h])||a.has(g)?p("Cannot redefine existing key '"+g+"'.",l):s.has(g)&&g!==w(o)&&p("Cannot use dotted keys to extend table '"+g+"' defined elsewhere.",l),d=d[h]}var y=t[t.length-1],v=x(t);void 0!==d[y]&&p("Cannot redefine existing key '"+v+"'.",l),d[y]=c,i.add(v),a.add(v)}(f);break;case"ObjectPath":!function(e){var t=e.value,r=t.map(y).join("."),n=e.offset;i.has(r)&&p("Cannot redefine existing key '"+t+"'.",n),i.add(r),s.add(r),u=g(c,t,b(),n),o=t}(f);break;case"ArrayPath":!function(e){var t=e.value,r=t.map(y).join("."),n=e.offset;if(a.has(r)&&p("Cannot append to statically defined array '"+r+"'.",n),i.forEach(function(e){_(e,r)&&i.delete(e)}),a.forEach(function(e){_(e,r)&&a.delete(e)}),i.add(r),u=g(c,t,function(){var e=[];return l.add(e),e}(),n),o=t,u instanceof Array){var s=b();u.push(s),u=s}else p("Cannot redefine existing key '"+t+"'.",n)}(f)}return c;function p(e,r){var n=function(e){for(var r=1,n=1,i=0;i<e;i++)10===t.charCodeAt(i)?(r++,n=1):n++;return{line:r,column:n}}(r),i=Error(e);throw i.line=n.line,i.column=n.column,i}function m(e){return e.replace(/\.(\d{9})\d+/,".$1")}function g(e,t,r,n){for(var i=e,s=0;s<t.length;s++){var o=t[s],l=w(t.slice(0,s+1));void 0===i[o]?s===t.length-1?i[o]=r:i[o]=b():s!==t.length-1&&a.has(l)&&p("Cannot redefine existing key '"+l+"'.",n),i=i[o],s<t.length-1&&(v(i)||p("Cannot redefine existing key '"+l+"'.",n),i instanceof Array&&(i.length||p("Cannot redefine existing key '"+l+"'.",n),v(i=i[i.length-1])||p("Cannot redefine existing key '"+l+"'.",n)))}return i}function y(e){return e.indexOf(".")>-1?'"'+e+'"':e}function b(){var e=Object.create(null);return l.add(e),e}function v(e){return null!==e&&"object"==typeof e&&l.has(e)}function w(e){return e.map(y).join(".")}function x(e){return w(o.concat(e))}function _(e,t){return e===t||0===e.indexOf(t+".")}}}},3633(e){class t extends SyntaxError{constructor(e,t,r,n){super(e),this.expected=t,this.found=r,this.location=n,this.name="SyntaxError"}format(e){let t="Error: "+this.message;if(this.location){let r=null,n=e.find(e=>e.source===this.location.source);n&&(r=n.text.split(/\r\n|\n|\r/g));let i=this.location.start,a=this.location.source&&"function"==typeof this.location.source.offset?this.location.source.offset(i):i,s=this.location.source+":"+a.line+":"+a.column;if(r){let e=this.location.end,n="".padEnd(a.line.toString().length," "),o=r[i.line-1],l=(i.line===e.line?e.column:o.length+1)-i.column||1;t+="\n --\x3e "+s+"\n"+n+" |\n"+a.line+" | "+o+"\n"+n+" | "+"".padEnd(i.column-1," ")+"".padEnd(l,"^")}else t+="\n at "+s}return t}static buildMessage(e,t){function r(e){return e.codePointAt(0).toString(16).toUpperCase()}let n=Object.prototype.hasOwnProperty.call(RegExp.prototype,"unicode")?RegExp("[\\p{C}\\p{Mn}\\p{Mc}]","gu"):null;function i(e){return n?e.replace(n,e=>"\\u{"+r(e)+"}"):e}function a(e){return i(e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,e=>"\\x0"+r(e)).replace(/[\x10-\x1F\x7F-\x9F]/g,e=>"\\x"+r(e)))}function s(e){return i(e.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,e=>"\\x0"+r(e)).replace(/[\x10-\x1F\x7F-\x9F]/g,e=>"\\x"+r(e)))}let o={literal:e=>'"'+a(e.text)+'"',class(e){let t=e.parts.map(e=>Array.isArray(e)?s(e[0])+"-"+s(e[1]):s(e));return"["+(e.inverted?"^":"")+t.join("")+"]"+(e.unicode?"u":"")},any:()=>"any character",end:()=>"end of input",other:e=>e.description};function l(e){return o[e.type](e)}return"Expected "+function(e){let t=e.map(l);if(t.sort(),t.length>0){let e=1;for(let r=1;r<t.length;r++)t[r-1]!==t[r]&&(t[e]=t[r],e++);t.length=e}switch(t.length){case 1:return t[0];case 2:return t[0]+" or "+t[1];default:return t.slice(0,-1).join(", ")+", or "+t[t.length-1]}}(e)+" but "+(t?'"'+a(t)+'"':"end of input")+" found."}}e.exports={StartRules:["start"],SyntaxError:t,parse:function(e,r){let n,i={},a=(r=void 0!==r?r:{}).grammarSource,s={start:eU},o=eU,l="true",c="false",u=/^[\t -~\x80-\uFFFF]/,d=/^[+\-]/,f=/^[^"\\\0-\b\v-\x1F\x7F\r]/,h=/^[^'\0-\b\v-\x1F\x7F\r]/,p=/^[^"\\\0-\b\n-\x1F\x7F]/,m=/^[^'\0-\b\n-\x1F\x7F]/,g=/^[eE]/,y=/^[0-9_]/,b=/^[1-9]/,v=/^[_]/,w=/^[0-9]/,x=/^[0-9a-fA-F]/,_=/^[0-7]/,k=/^[01]/,S=/^[ \t]/,O=/^[A-Za-z0-9_\-]/,E=/^["\\btnfre]/,$=eN("#",!1),I=eM([" ",[" ","~"],["",""]],!1,!1,!1),A=eN("[",!1),C=eN("]",!1),T=eN(".",!1),N=eN("=",!1),M=eM(["+","-"],!1,!1,!1),P=eN("inf",!1),j=eN("nan",!1),D=eN('"""',!1),U=eN('"',!1),F=eN("'''",!1),R=eN("'",!1),L=eN("\\",!1),B={type:"any"},Y=eN("\r\n",!1),q=eM(['"',"\\",["\0","\b"],["\v","\x1f"],"","\r"],!0,!1,!1),X=eN('""',!1),W=eM(["'",["\0","\b"],["\v","\x1f"],"","\r"],!0,!1,!1),J=eN("''",!1),z=eM(['"',"\\",["\0","\b"],["\n","\x1f"],""],!0,!1,!1),K=eM(["'",["\0","\b"],["\n","\x1f"],""],!0,!1,!1),V=eM(["e","E"],!1,!1,!1),G=eN("0",!1),H=eN("0x",!1),Q=eN("0o",!1),Z=eN("0b",!1),ee=eM([["0","9"],"_"],!1,!1,!1),et=eM([["1","9"]],!1,!1,!1),er=eM(["_"],!1,!1,!1),en=eM([["0","9"]],!1,!1,!1),ei=eM([["0","9"],["a","f"],["A","F"]],!1,!1,!1),ea=eM([["0","7"]],!1,!1,!1),es=eM(["0","1"],!1,!1,!1),eo=eN("true",!1),el=eN("false",!1),ec=eN(",",!1),eu=eN("{",!1),ed=eN("}",!1),ef=eN("-",!1),eh=eN(":",!1),ep=eN("Z",!0),em=eN("T",!0),eg=eN(" ",!1),ey=eM([" "," "],!1,!1,!1),eb=eN("\n",!1),ev=eN("\r",!1),ew=eN("\uFEFF",!1),ex=eM([["A","Z"],["a","z"],["0","9"],"_","-"],!1,!1,!1),e_=eM(['"',"\\","b","t","n","f","r","e"],!1,!1,!1),ek=eN("\\U",!1),eS=eN("\\u",!1),eO=eN("\\x",!1),eE=0|r.peg$currPos,e$=eE,eI=[{line:1,column:1}],eA=eE,eC=r.peg$maxFailExpected||[],eT=0|r.peg$silentFails;if(r.startRule){if(!(r.startRule in s))throw Error("Can't start parsing from rule \""+r.startRule+'".');o=s[r.startRule]}function eN(e,t){return{type:"literal",text:e,ignoreCase:t}}function eM(e,t,r,n){return{type:"class",parts:e,inverted:t,ignoreCase:r,unicode:n}}function eP(t){let r,n=eI[t];if(n)return n;if(t>=eI.length)r=eI.length-1;else for(r=t;!eI[--r];);for(n={line:(n=eI[r]).line,column:n.column};r<t;)10===e.charCodeAt(r)?(n.line++,n.column=1):n.column++,r++;return eI[t]=n,n}function ej(e,t,r){let n=eP(e),i=eP(t),s={source:a,start:{offset:e,line:n.line,column:n.column},end:{offset:t,line:i.line,column:i.column}};return r&&a&&"function"==typeof a.offset&&(s.start=a.offset(s.start),s.end=a.offset(s.end)),s}function eD(e){eE<eA||(eE>eA&&(eA=eE,eC=[]),eC.push(e))}function eU(){let t,r,n,a;for(t=eE,65279===e.charCodeAt(eE)?(a="\uFEFF",eE++):(a=i,0===eT&&eD(ew)),a===i,r=[],n=eF();n!==i;)r.push(n),n=eF();return e$=t,t=tl}function eF(){let t,r,n,a,s,o,l,c;for(t=eE,r=[],n=te();n!==i;)r.push(n),n=te();if((c=eR())===i&&(c=function(){let t,r,n,a,s,o,l,c;if(t=eE,91===e.charCodeAt(eE)?(r="[",eE++):(r=i,0===eT&&eD(A)),r!==i)if(91===e.charCodeAt(eE)?(n="[",eE++):(n=i,0===eT&&eD(A)),n!==i){for(a=[],s=te();s!==i;)a.push(s),s=te();if((s=eL())!==i){for(o=[],l=te();l!==i;)o.push(l),l=te();(93===e.charCodeAt(eE)?(l="]",eE++):(l=i,0===eT&&eD(C)),l!==i&&(93===e.charCodeAt(eE)?(c="]",eE++):(c=i,0===eT&&eD(C)),c!==i))?t=void tf(th("ArrayPath",s,e$=t)):(eE=t,t=i)}else eE=t,t=i}else eE=t,t=i;else eE=t,t=i;if(t===i)if(t=eE,91===e.charCodeAt(eE)?(r="[",eE++):(r=i,0===eT&&eD(A)),r!==i){for(n=[],a=te();a!==i;)n.push(a),a=te();if((a=eL())!==i){for(s=[],o=te();o!==i;)s.push(o),o=te();(93===e.charCodeAt(eE)?(o="]",eE++):(o=i,0===eT&&eD(C)),o!==i)?t=void tf(th("ObjectPath",a,e$=t)):(eE=t,t=i)}else eE=t,t=i}else eE=t,t=i;return t}())===i&&(c=function(){let t,r,n,a,s,o;if(t=eE,(r=e5())!==i){for(n=[],a=te();a!==i;)n.push(a),a=te();if(61===e.charCodeAt(eE)?(a="=",eE++):(a=i,0===eT&&eD(N)),a!==i){for(s=[],o=te();o!==i;)s.push(o),o=te();if((o=eq())!==i)t=void tf(th("Assign",o,e$=t,r));else eE=t,t=i}else eE=t,t=i}else eE=t,t=i;return t}()),(n=c)!==i){for(a=[],s=te();s!==i;)a.push(s),s=te();if((s=eR())===i&&(s=null),o=[],(l=tt())!==i)for(;l!==i;)o.push(l),l=tt();else o=i;o===i&&(o=tn()),o!==i?t=r=[r,n,a,s,o]:(eE=t,t=i)}else eE=t,t=i;if(t===i){if(t=eE,r=[],(n=te())!==i)for(;n!==i;)r.push(n),n=te();else r=i;if(r!==i){if(n=[],(a=tt())!==i)for(;a!==i;)n.push(a),a=tt();else n=i;n===i&&(n=tn()),n!==i?t=r=[r,n]:(eE=t,t=i)}else eE=t,t=i;t===i&&(t=tt())}return t}function eR(){let t,r,n,a;if(t=eE,35===e.charCodeAt(eE)?(r="#",eE++):(r=i,0===eT&&eD($)),r!==i){for(n=[],a=e.charAt(eE),u.test(a)?eE++:(a=i,0===eT&&eD(I));a!==i;)n.push(a),a=e.charAt(eE),u.test(a)?eE++:(a=i,0===eT&&eD(I));t=r=[r,n]}else eE=t,t=i;return t}function eL(){let e,t,r;if(e=eE,t=[],(r=eY())!==i)for(;r!==i;)t.push(r),r=eY();else t=i;if(t!==i)if((r=eB())!==i){var n,a;e$=e,n=t,a=r,e=n.concat(a)}else eE=e,e=i;else eE=e,e=i;return e===i&&(e=eE,(t=eB())!==i&&(e$=e,t=[t]),e=t),e}function eB(){let e,t,r,n,a;for(e=eE,t=[],r=te();r!==i;)t.push(r),r=te();if((r=e8())!==i){for(n=[],a=te();a!==i;)n.push(a),a=te();e$=e,e=r}else eE=e,e=i;return e}function eY(){let t,r,n,a,s;for(t=eE,r=[],n=te();n!==i;)r.push(n),n=te();if((n=e8())!==i){for(a=[],s=te();s!==i;)a.push(s),s=te();(46===e.charCodeAt(eE)?(s=".",eE++):(s=i,0===eT&&eD(T)),s!==i)?(e$=t,t=n):(eE=t,t=i)}else eE=t,t=i;return t}function eq(){let t,r;return(t=eE,e$=eE,++tc>tu&&(tc--,td("Maximum nesting depth of "+tu+" exceeded.",e$)),void 0!==i&&(r=function(){let t,r,n,a,s,o,u,f,h,p,m,b,w,S,O,E,$;if(t=eE,(s=eE,'"""'===e.substr(eE,3)?(o='"""',eE+=3):(o=i,0===eT&&eD(D)),o!==i&&(tt()===i,u=function(){let t,r,n,a,s,o,l,c,u,d,f;for(t=eE,r=[],n=eJ();n!==i;)r.push(n),n=eJ();if(n=[],a=eE,(s=ez())!==i){if(o=[],(l=eJ())!==i)for(;l!==i;)o.push(l),l=eJ();else o=i;o!==i?a=s=[s,o]:(eE=a,a=i)}else eE=a,a=i;for(;a!==i;)if(n.push(a),a=eE,(s=ez())!==i){if(o=[],(l=eJ())!==i)for(;l!==i;)o.push(l),l=eJ();else o=i;o!==i?a=s=[s,o]:(eE=a,a=i)}else eE=a,a=i;return c=eE,'""'===e.substr(eE,2)?(u='""',eE+=2):(u=i,0===eT&&eD(X)),u!==i?(d=eE,eT++,'"""'===e.substr(eE,3)?(f='"""',eE+=3):(f=i,0===eT&&eD(D)),eT--,f!==i?(eE=d,d=void 0):d=i,d!==i?(e$=c,c='""'):(eE=c,c=i)):(eE=c,c=i),c===i&&(c=eE,34===e.charCodeAt(eE)?(u='"',eE++):(u=i,0===eT&&eD(U)),u!==i?(d=eE,eT++,'"""'===e.substr(eE,3)?(f='"""',eE+=3):(f=i,0===eT&&eD(D)),eT--,f!==i?(eE=d,d=void 0):d=i,d!==i?(e$=c,c='"'):(eE=c,c=i)):(eE=c,c=i)),(a=c)===i&&(a=null),e$=t,t=function(e,t,r){for(var n=e.join(""),i=0;i<t.length;i++)n+=t[i][0]+t[i][1].join("");return n+(r||"")}(r,n,a)}(),'"""'===e.substr(eE,3)?(f='"""',eE+=3):(f=i,0===eT&&eD(D)),f!==i))?s=th("String",u,e$=s):(eE=s,s=i),(a=s)===i&&(a=eX())===i&&((h=eE,"'''"===e.substr(eE,3)?(p="'''",eE+=3):(p=i,0===eT&&eD(F)),p!==i&&(tt()===i,m=function(){let t,r,n,a,s,o,l,c,u,d,f;for(t=eE,r=[],n=eK();n!==i;)r.push(n),n=eK();if(n=[],a=eE,(s=eV())!==i){if(o=[],(l=eK())!==i)for(;l!==i;)o.push(l),l=eK();else o=i;o!==i?a=s=[s,o]:(eE=a,a=i)}else eE=a,a=i;for(;a!==i;)if(n.push(a),a=eE,(s=eV())!==i){if(o=[],(l=eK())!==i)for(;l!==i;)o.push(l),l=eK();else o=i;o!==i?a=s=[s,o]:(eE=a,a=i)}else eE=a,a=i;return c=eE,"''"===e.substr(eE,2)?(u="''",eE+=2):(u=i,0===eT&&eD(J)),u!==i?(d=eE,eT++,"'''"===e.substr(eE,3)?(f="'''",eE+=3):(f=i,0===eT&&eD(F)),eT--,f!==i?(eE=d,d=void 0):d=i,d!==i?(e$=c,c="''"):(eE=c,c=i)):(eE=c,c=i),c===i&&(c=eE,39===e.charCodeAt(eE)?(u="'",eE++):(u=i,0===eT&&eD(R)),u!==i?(d=eE,eT++,"'''"===e.substr(eE,3)?(f="'''",eE+=3):(f=i,0===eT&&eD(F)),eT--,f!==i?(eE=d,d=void 0):d=i,d!==i?(e$=c,c="'"):(eE=c,c=i)):(eE=c,c=i)),(a=c)===i&&(a=null),e$=t,t=function(e,t,r){for(var n=e.join(""),i=0;i<t.length;i++)n+=t[i][0]+t[i][1].join("");return n+(r||"")}(r,n,a)}(),"'''"===e.substr(eE,3)?(b="'''",eE+=3):(b=i,0===eT&&eD(F)),b!==i))?h=th("String",m,e$=h):(eE=h,h=i),(a=h)===i)&&(a=eW()),(n=a)===i&&((w=eE,S=e.charAt(eE),d.test(S)?eE++:(S=i,0===eT&&eD(M)),S===i&&(S=null),"inf"===e.substr(eE,3)?(O="inf",eE+=3):(O=i,0===eT&&eD(P)),O!==i)?w=th("Float","-"===S?-1/0:1/0,e$=w):(eE=w,w=i),w===i&&(w=eE,S=e.charAt(eE),d.test(S)?eE++:(S=i,0===eT&&eD(M)),S===i&&(S=null),"nan"===e.substr(eE,3)?(O="nan",eE+=3):(O=i,0===eT&&eD(j)),O!==i?w=th("Float",NaN,e$=w):(eE=w,w=i),w===i&&(w=function(){var t,r,n,a,s,o,l,c,u,f,h;let p,m,g,y,b;if(p=eE,(m=e4())!==i)if((g=e7())!==i)if((y=e9())!==i){let s,o,l,c,u,f,h,g;(s=eE,"z"===(o=e.charAt(eE)).toLowerCase()?eE++:(o=i,0===eT&&eD(ep)),o!==i&&(e$=s,o="Z"),(s=o)===i&&(s=eE,o=eE,l=e.charAt(eE),d.test(l)?eE++:(l=i,0===eT&&eD(M)),l!==i&&(c=ti())!==i&&(u=ti())!==i?(58===e.charCodeAt(eE)?(f=":",eE++):(f=i,0===eT&&eD(eh)),f!==i&&(h=ti())!==i&&(g=ti())!==i?o=l=[l,c,u,f,h,g]:(eE=o,o=i)):(eE=o,o=i),s=o!==i?e.substring(s,eE):o),(b=s)!==i)?(e$=p,t=m,r=y,tp(t,n=e$),tm(r,n),function(e,t){if("Z"!==e&&"z"!==e){var r=(e.charCodeAt(1)-48)*10+e.charCodeAt(2)-48,n=(e.charCodeAt(4)-48)*10+e.charCodeAt(5)-48;r>23&&td("Invalid offset: hour "+r+" out of range.",t),n>59&&td("Invalid offset: minute "+n+" out of range.",t)}}(b,n),(a=th("Date",new Date(t+"T"+r+b),n)).raw=t+"T"+r,a.tz=b,p=a):(eE=p,p=i)}else eE=p,p=i;else eE=p,p=i;else eE=p,p=i;return p===i&&((p=eE,(m=e4())!==i&&(g=e7())!==i&&(y=e9())!==i)?(e$=p,s=m,o=y,tp(s,l=e$),tm(o,l),p=th("LocalDateTime",s+"T"+o,l)):(eE=p,p=i),p===i&&((p=eE,(m=e4())!==i&&(g=eE,eT++,y=e7(),eT--,y===i?g=void 0:(eE=g,g=i),g!==i))?(e$=p,tp(c=m,u=e$),p=th("LocalDate",c,u)):(eE=p,p=i),p===i&&(p=eE,(m=e9())!==i&&(e$=p,tm(f=m,h=e$),m=th("LocalTime",f,h)),p=m))),p}())===i&&(w=function(){let t,r,n,a,s,o,l,c,u,f;if(t=eE,(s=eE,o=e.charAt(eE),d.test(o)?eE++:(o=i,0===eT&&eD(M)),o===i&&(o=null),(l=eQ())!==i&&(46===e.charCodeAt(eE)?(c=".",eE++):(c=i,0===eT&&eD(T)),c!==i&&(u=eE,(u=(f=e0())!==i?e.substring(u,eE):f)!==i)))?(e$=s,s=("-"===o?"-":"")+l+"."+u):(eE=s,s=i),s===i&&((s=eE,o=e.charAt(eE),d.test(o)?eE++:(o=i,0===eT&&eD(M)),o===i&&(o=null),(l=eQ())!==i)?(e$=s,s=("-"===o?"-":"")+l):(eE=s,s=i)),(r=s)!==i)if(n=e.charAt(eE),g.test(n)?eE++:(n=i,0===eT&&eD(V)),n!==i){let n,s,o,l;if((n=eE,s=e.charAt(eE),d.test(s)?eE++:(s=i,0===eT&&eD(M)),s===i&&(s=null),o=eE,(o=(l=e0())!==i?e.substring(o,eE):l)!==i)?(e$=n,n=(s||"")+o):(eE=n,n=i),(a=n)!==i)e$=t,t=th("Float",parseFloat(tg(r+"e"+a)),e$);else eE=t,t=i}else eE=t,t=i;else eE=t,t=i;if(t===i){let n,a,s,o,l,c;t=eE,(n=eE,a=e.charAt(eE),d.test(a)?eE++:(a=i,0===eT&&eD(M)),a===i&&(a=null),(s=eQ())!==i&&(46===e.charCodeAt(eE)?(o=".",eE++):(o=i,0===eT&&eD(T)),o!==i&&(l=eE,(l=(c=e0())!==i?e.substring(l,eE):c)!==i)))?(e$=n,n=("-"===a?"-":"")+s+"."+l):(eE=n,n=i),(r=n)!==i&&(e$=t,r=th("Float",parseFloat(tg(r)),e$)),t=r}return t}())===i&&(w=function(){let t,r,n,a;if(((t=eE,"0x"===e.substr(eE,2)?(r="0x",eE+=2):(r=i,0===eT&&eD(H)),r!==i&&(n=eE,(n=(a=function(){let t,r,n,a,s,o;if(t=eE,r=e.charAt(eE),x.test(r)?eE++:(r=i,0===eT&&eD(ei)),r!==i){for(n=[],a=eE,s=e.charAt(eE),v.test(s)?eE++:(s=i,0===eT&&eD(er)),s===i&&(s=null),o=e.charAt(eE),x.test(o)?eE++:(o=i,0===eT&&eD(ei)),o!==i?a=s=[s,o]:(eE=a,a=i);a!==i;)n.push(a),a=eE,s=e.charAt(eE),v.test(s)?eE++:(s=i,0===eT&&eD(er)),s===i&&(s=null),o=e.charAt(eE),x.test(o)?eE++:(o=i,0===eT&&eD(ei)),o!==i?a=s=[s,o]:(eE=a,a=i);t=r=[r,n]}else eE=t,t=i;return t}())!==i?e.substring(n,eE):a)!==i))?(e$=t,t=th("Integer",parseInt(tg(n),16),e$)):(eE=t,t=i),t===i)&&((t=eE,"0o"===e.substr(eE,2)?(r="0o",eE+=2):(r=i,0===eT&&eD(Q)),r!==i&&(n=eE,(n=(a=function(){let t,r,n,a,s,o;if(t=eE,r=e.charAt(eE),_.test(r)?eE++:(r=i,0===eT&&eD(ea)),r!==i){for(n=[],a=eE,s=e.charAt(eE),v.test(s)?eE++:(s=i,0===eT&&eD(er)),s===i&&(s=null),o=e.charAt(eE),_.test(o)?eE++:(o=i,0===eT&&eD(ea)),o!==i?a=s=[s,o]:(eE=a,a=i);a!==i;)n.push(a),a=eE,s=e.charAt(eE),v.test(s)?eE++:(s=i,0===eT&&eD(er)),s===i&&(s=null),o=e.charAt(eE),_.test(o)?eE++:(o=i,0===eT&&eD(ea)),o!==i?a=s=[s,o]:(eE=a,a=i);t=r=[r,n]}else eE=t,t=i;return t}())!==i?e.substring(n,eE):a)!==i))?(e$=t,t=th("Integer",parseInt(tg(n),8),e$)):(eE=t,t=i),t===i)&&((t=eE,"0b"===e.substr(eE,2)?(r="0b",eE+=2):(r=i,0===eT&&eD(Z)),r!==i&&(n=eE,(n=(a=function(){let t,r,n,a,s,o;if(t=eE,r=e.charAt(eE),k.test(r)?eE++:(r=i,0===eT&&eD(es)),r!==i){for(n=[],a=eE,s=e.charAt(eE),v.test(s)?eE++:(s=i,0===eT&&eD(er)),s===i&&(s=null),o=e.charAt(eE),k.test(o)?eE++:(o=i,0===eT&&eD(es)),o!==i?a=s=[s,o]:(eE=a,a=i);a!==i;)n.push(a),a=eE,s=e.charAt(eE),v.test(s)?eE++:(s=i,0===eT&&eD(er)),s===i&&(s=null),o=e.charAt(eE),k.test(o)?eE++:(o=i,0===eT&&eD(es)),o!==i?a=s=[s,o]:(eE=a,a=i);t=r=[r,n]}else eE=t,t=i;return t}())!==i?e.substring(n,eE):a)!==i))?(e$=t,t=th("Integer",parseInt(tg(n),2),e$)):(eE=t,t=i),t===i)){let n,a,s,o,l,c;t=eE,(n=eE,a=e.charAt(eE),d.test(a)?eE++:(a=i,0===eT&&eD(M)),a===i&&(a=null),48===e.charCodeAt(eE)?(s="0",eE++):(s=i,0===eT&&eD(G)),s!==i&&(o=eE,eT++,l=e.charAt(eE),y.test(l)?eE++:(l=i,0===eT&&eD(ee)),eT--,l===i?o=void 0:(eE=o,o=i),o!==i&&(l=eE,eT++,46===e.charCodeAt(eE)?(c=".",eE++):(c=i,0===eT&&eD(T)),eT--,c===i?l=void 0:(eE=l,l=i),l!==i)))?(e$=n,n=(a||"")+"0"):(eE=n,n=i),n===i&&((n=eE,a=e.charAt(eE),d.test(a)?eE++:(a=i,0===eT&&eD(M)),a===i&&(a=null),s=eE,(s=(o=eZ())!==i?e.substring(s,eE):o)!==i&&(o=eE,eT++,46===e.charCodeAt(eE)?(l=".",eE++):(l=i,0===eT&&eD(T)),eT--,l===i?o=void 0:(eE=o,o=i),o!==i))?(e$=n,n=(a||"")+s):(eE=n,n=i)),(r=n)!==i&&(e$=t,r=th("Integer",parseInt(tg(r),10),e$)),t=r}return t}())),(n=w)===i&&(E=eE,e.substr(eE,4)===l?($=l,eE+=4):($=i,0===eT&&eD(eo)),$!==i&&($=th("Boolean",!0,e$=E)),(E=$)===i&&(E=eE,e.substr(eE,5)===c?($=c,eE+=5):($=i,0===eT&&eD(el)),$!==i&&($=th("Boolean",!1,e$=E)),E=$),(n=E)===i&&(n=function(){let t,r,n,a,s,o,l,c,u,d;if(t=eE,91===e.charCodeAt(eE)?(r="[",eE++):(r=i,0===eT&&eD(A)),r!==i){for(n=[],a=e1();a!==i;)n.push(a),a=e1();93===e.charCodeAt(eE)?(a="]",eE++):(a=i,0===eT&&eD(C)),a!==i?t=th("Array",[],e$=t):(eE=t,t=i)}else eE=t,t=i;if(t===i)if(t=eE,91===e.charCodeAt(eE)?(r="[",eE++):(r=i,0===eT&&eD(A)),r!==i){for(n=[],a=e1();a!==i;)n.push(a),a=e1();if((a=eq())!==i){for(s=[],o=eE,l=[],c=e1();c!==i;)l.push(c),c=e1();if(44===e.charCodeAt(eE)?(c=",",eE++):(c=i,0===eT&&eD(ec)),c!==i){for(u=[],d=e1();d!==i;)u.push(d),d=e1();(d=eq())!==i?(e$=o,o=d):(eE=o,o=i)}else eE=o,o=i;for(;o!==i;){for(s.push(o),o=eE,l=[],c=e1();c!==i;)l.push(c),c=e1();if(44===e.charCodeAt(eE)?(c=",",eE++):(c=i,0===eT&&eD(ec)),c!==i){for(u=[],d=e1();d!==i;)u.push(d),d=e1();(d=eq())!==i?(e$=o,o=d):(eE=o,o=i)}else eE=o,o=i}for(o=[],l=e1();l!==i;)o.push(l),l=e1();for(44===e.charCodeAt(eE)?(l=",",eE++):(l=i,0===eT&&eD(ec)),l===i&&(l=null),c=[],u=e1();u!==i;)c.push(u),u=e1();if(93===e.charCodeAt(eE)?(u="]",eE++):(u=i,0===eT&&eD(C)),u!==i){var f;e$=t,f=a,s.unshift(f),t=th("Array",s,e$)}else eE=t,t=i}else eE=t,t=i}else eE=t,t=i;return t}())===i))&&(n=function(){let t,r,n,a,s,o,l,c,u,d;if(t=eE,123===e.charCodeAt(eE)?(r="{",eE++):(r=i,0===eT&&eD(eu)),r!==i){for(n=[],a=e3();a!==i;)n.push(a),a=e3();125===e.charCodeAt(eE)?(a="}",eE++):(a=i,0===eT&&eD(ed)),a!==i?t=th("InlineTable",[],e$=t):(eE=t,t=i)}else eE=t,t=i;if(t===i)if(t=eE,123===e.charCodeAt(eE)?(r="{",eE++):(r=i,0===eT&&eD(eu)),r!==i){for(n=[],a=e3();a!==i;)n.push(a),a=e3();if((a=e2())!==i){for(s=[],o=eE,l=[],c=e3();c!==i;)l.push(c),c=e3();if(44===e.charCodeAt(eE)?(c=",",eE++):(c=i,0===eT&&eD(ec)),c!==i){for(u=[],d=e3();d!==i;)u.push(d),d=e3();(d=e2())!==i?(e$=o,o=d):(eE=o,o=i)}else eE=o,o=i;for(;o!==i;){for(s.push(o),o=eE,l=[],c=e3();c!==i;)l.push(c),c=e3();if(44===e.charCodeAt(eE)?(c=",",eE++):(c=i,0===eT&&eD(ec)),c!==i){for(u=[],d=e3();d!==i;)u.push(d),d=e3();(d=e2())!==i?(e$=o,o=d):(eE=o,o=i)}else eE=o,o=i}for(o=[],l=e3();l!==i;)o.push(l),l=e3();for(44===e.charCodeAt(eE)?(l=",",eE++):(l=i,0===eT&&eD(ec)),l===i&&(l=null),c=[],u=e3();u!==i;)c.push(u),u=e3();if(125===e.charCodeAt(eE)?(u="}",eE++):(u=i,0===eT&&eD(ed)),u!==i){var f;e$=t,f=a,s.unshift(f),t=th("InlineTable",s,e$)}else eE=t,t=i}else eE=t,t=i}else eE=t,t=i;return t}()),(r=n)!==i){var I;e$=t,I=r,tc--,r=I}return(t=r)===i&&(e$=eE,tc--,t=!1,t=i),t}())!==i)?(e$=t,t=r):(eE=t,t=i),t}function eX(){let t,r,n,a;if(t=eE,34===e.charCodeAt(eE)?(r='"',eE++):(r=i,0===eT&&eD(U)),r!==i){for(n=[],a=eG();a!==i;)n.push(a),a=eG();(34===e.charCodeAt(eE)?(a='"',eE++):(a=i,0===eT&&eD(U)),a!==i)?(e$=t,t=th("String",n.join(""),e$)):(eE=t,t=i)}else eE=t,t=i;return t}function eW(){let t,r,n,a;if(t=eE,39===e.charCodeAt(eE)?(r="'",eE++):(r=i,0===eT&&eD(R)),r!==i){for(n=[],a=eH();a!==i;)n.push(a),a=eH();(39===e.charCodeAt(eE)?(a="'",eE++):(a=i,0===eT&&eD(R)),a!==i)?(e$=t,t=th("String",n.join(""),e$)):(eE=t,t=i)}else eE=t,t=i;return t}function eJ(){let t,r,n;if((t=to())===i&&(t=function(){let t,r,n,a,s,o;if(t=eE,92===e.charCodeAt(eE)?(r="\\",eE++):(r=i,0===eT&&eD(L)),r!==i){for(n=[],a=te();a!==i;)n.push(a),a=te();if((a=tt())!==i){for(s=[],o=tr();o!==i;)s.push(o),o=tr();e$=t,t=""}else eE=t,t=i}else eE=t,t=i;return t}())===i&&(t=eE,92===e.charCodeAt(eE)?(r="\\",eE++):(r=i,0===eT&&eD(L)),r!==i?(e.length>eE?(n=e.charAt(eE),eE++):(n=i,0===eT&&eD(B)),n!==i?t=void td("Invalid escape sequence",e$=t):(eE=t,t=i)):(eE=t,t=i),t===i)&&(t=eE,"\r\n"===e.substr(eE,2)?(r="\r\n",eE+=2):(r=i,0===eT&&eD(Y)),r!==i&&(e$=t,r="\n"),(t=r)===i)){if(t=eE,r=[],n=e.charAt(eE),f.test(n)?eE++:(n=i,0===eT&&eD(q)),n!==i)for(;n!==i;)r.push(n),n=e.charAt(eE),f.test(n)?eE++:(n=i,0===eT&&eD(q));else r=i;t=r!==i?e.substring(t,eE):r}return t}function ez(){let t,r,n,a;return t=eE,'""'===e.substr(eE,2)?(r='""',eE+=2):(r=i,0===eT&&eD(X)),r!==i?(n=eE,eT++,34===e.charCodeAt(eE)?(a='"',eE++):(a=i,0===eT&&eD(U)),eT--,a===i?n=void 0:(eE=n,n=i),n!==i?(e$=t,t='""'):(eE=t,t=i)):(eE=t,t=i),t===i&&(t=eE,34===e.charCodeAt(eE)?(r='"',eE++):(r=i,0===eT&&eD(U)),r!==i?(n=eE,eT++,34===e.charCodeAt(eE)?(a='"',eE++):(a=i,0===eT&&eD(U)),eT--,a===i?n=void 0:(eE=n,n=i),n!==i?(e$=t,t='"'):(eE=t,t=i)):(eE=t,t=i)),t}function eK(){let t,r,n;if(t=eE,"\r\n"===e.substr(eE,2)?(r="\r\n",eE+=2):(r=i,0===eT&&eD(Y)),r!==i&&(e$=t,r="\n"),(t=r)===i){if(t=eE,r=[],n=e.charAt(eE),h.test(n)?eE++:(n=i,0===eT&&eD(W)),n!==i)for(;n!==i;)r.push(n),n=e.charAt(eE),h.test(n)?eE++:(n=i,0===eT&&eD(W));else r=i;t=r!==i?e.substring(t,eE):r}return t}function eV(){let t,r,n,a;return t=eE,"''"===e.substr(eE,2)?(r="''",eE+=2):(r=i,0===eT&&eD(J)),r!==i?(n=eE,eT++,39===e.charCodeAt(eE)?(a="'",eE++):(a=i,0===eT&&eD(R)),eT--,a===i?n=void 0:(eE=n,n=i),n!==i?(e$=t,t="''"):(eE=t,t=i)):(eE=t,t=i),t===i&&(t=eE,39===e.charCodeAt(eE)?(r="'",eE++):(r=i,0===eT&&eD(R)),r!==i?(n=eE,eT++,39===e.charCodeAt(eE)?(a="'",eE++):(a=i,0===eT&&eD(R)),eT--,a===i?n=void 0:(eE=n,n=i),n!==i?(e$=t,t="'"):(eE=t,t=i)):(eE=t,t=i)),t}function eG(){let t,r,n;if((t=to())===i&&(t=eE,92===e.charCodeAt(eE)?(r="\\",eE++):(r=i,0===eT&&eD(L)),r!==i?(e.length>eE?(n=e.charAt(eE),eE++):(n=i,0===eT&&eD(B)),n!==i?t=void td("Invalid escape sequence",e$=t):(eE=t,t=i)):(eE=t,t=i),t===i)){if(t=eE,r=[],n=e.charAt(eE),p.test(n)?eE++:(n=i,0===eT&&eD(z)),n!==i)for(;n!==i;)r.push(n),n=e.charAt(eE),p.test(n)?eE++:(n=i,0===eT&&eD(z));else r=i;t=r!==i?e.substring(t,eE):r}return t}function eH(){let t,r,n;if(t=eE,r=[],n=e.charAt(eE),m.test(n)?eE++:(n=i,0===eT&&eD(K)),n!==i)for(;n!==i;)r.push(n),n=e.charAt(eE),m.test(n)?eE++:(n=i,0===eT&&eD(K));else r=i;return r!==i?e.substring(t,eE):r}function eQ(){let t,r;return t=eE,48===e.charCodeAt(eE)?(r="0",eE++):(r=i,0===eT&&eD(G)),r!==i&&(e$=t,r="0"),(t=r)===i&&(t=eE,t=(r=eZ())!==i?e.substring(t,eE):r),t}function eZ(){let t,r,n,a,s,o;if(t=eE,r=e.charAt(eE),b.test(r)?eE++:(r=i,0===eT&&eD(et)),r!==i){for(n=[],a=eE,s=e.charAt(eE),v.test(s)?eE++:(s=i,0===eT&&eD(er)),s===i&&(s=null),o=e.charAt(eE),w.test(o)?eE++:(o=i,0===eT&&eD(en)),o!==i?a=s=[s,o]:(eE=a,a=i);a!==i;)n.push(a),a=eE,s=e.charAt(eE),v.test(s)?eE++:(s=i,0===eT&&eD(er)),s===i&&(s=null),o=e.charAt(eE),w.test(o)?eE++:(o=i,0===eT&&eD(en)),o!==i?a=s=[s,o]:(eE=a,a=i);t=r=[r,n]}else eE=t,t=i;return t}function e0(){let t,r,n,a,s,o;if(t=eE,r=e.charAt(eE),w.test(r)?eE++:(r=i,0===eT&&eD(en)),r!==i){for(n=[],a=eE,s=e.charAt(eE),v.test(s)?eE++:(s=i,0===eT&&eD(er)),s===i&&(s=null),o=e.charAt(eE),w.test(o)?eE++:(o=i,0===eT&&eD(en)),o!==i?a=s=[s,o]:(eE=a,a=i);a!==i;)n.push(a),a=eE,s=e.charAt(eE),v.test(s)?eE++:(s=i,0===eT&&eD(er)),s===i&&(s=null),o=e.charAt(eE),w.test(o)?eE++:(o=i,0===eT&&eD(en)),o!==i?a=s=[s,o]:(eE=a,a=i);t=r=[r,n]}else eE=t,t=i;return t}function e1(){let e;return(e=te())===i&&(e=tt())===i&&(e=eR()),e}function e2(){let t,r,n,a,s,o;if(t=eE,(r=e5())!==i){for(n=[],a=te();a!==i;)n.push(a),a=te();if(61===e.charCodeAt(eE)?(a="=",eE++):(a=i,0===eT&&eD(N)),a!==i){for(s=[],o=te();o!==i;)s.push(o),o=te();if((o=eq())!==i)t=th("InlineTableValue",o,e$=t,r);else eE=t,t=i}else eE=t,t=i}else eE=t,t=i;return t}function e3(){let e;return(e=te())===i&&(e=tt())===i&&(e=eR()),e}function e5(){let e,t,r,n;if(e=eE,t=[],(r=e6())!==i)for(;r!==i;)t.push(r),r=e6();else t=i;if(t!==i){for(r=[],n=te();n!==i;)r.push(n),n=te();if((n=e8())!==i){var a,s;e$=e,a=t,s=n,e=a.concat(s)}else eE=e,e=i}else eE=e,e=i;return e===i&&(e=eE,(t=e8())!==i&&(e$=e,t=[t]),e=t),e}function e6(){let t,r,n,a,s;for(t=eE,r=[],n=te();n!==i;)r.push(n),n=te();if((n=e8())!==i){for(a=[],s=te();s!==i;)a.push(s),s=te();(46===e.charCodeAt(eE)?(s=".",eE++):(s=i,0===eT&&eD(T)),s!==i)?(e$=t,t=n):(eE=t,t=i)}else eE=t,t=i;return t}function e8(){let t,r,n;return(t=function(){let t,r,n;if(t=eE,r=[],(n=ts())!==i)for(;n!==i;)r.push(n),n=ts();else r=i;return r!==i?e.substring(t,eE):r}())===i&&(r=eE,(n=eX())!==i&&(e$=r,n=n.value),(r=n)===i&&(r=eE,(n=eW())!==i&&(e$=r,n=n.value),r=n),t=r),t}function e4(){let t,r,n,a,s,o,l,c,u,d,f,h;return t=eE,r=eE,(n=ti())!==i&&(a=ti())!==i&&(s=ti())!==i&&(o=ti())!==i?(45===e.charCodeAt(eE)?(l="-",eE++):(l=i,0===eT&&eD(ef)),l!==i&&(c=ti())!==i&&(u=ti())!==i?(45===e.charCodeAt(eE)?(d="-",eE++):(d=i,0===eT&&eD(ef)),d!==i&&(f=ti())!==i&&(h=ti())!==i?r=n=[n,a,s,o,l,c,u,d,f,h]:(eE=r,r=i)):(eE=r,r=i)):(eE=r,r=i),t=r!==i?e.substring(t,eE):r}function e9(){let t,r,n,a,s,o,l,c,u,d,f;if(t=eE,r=eE,n=eE,(a=ti())!==i&&(s=ti())!==i?(58===e.charCodeAt(eE)?(o=":",eE++):(o=i,0===eT&&eD(eh)),o!==i&&(l=ti())!==i&&(c=ti())!==i?(58===e.charCodeAt(eE)?(u=":",eE++):(u=i,0===eT&&eD(eh)),u!==i&&(d=ti())!==i&&(f=ti())!==i?n=a=[a,s,o,l,c,u,d,f]:(eE=n,n=i)):(eE=n,n=i)):(eE=n,n=i),(r=n!==i?e.substring(r,eE):n)!==i){var h,p;(n=function(){let t,r,n,a,s;if(t=eE,r=eE,46===e.charCodeAt(eE)?(n=".",eE++):(n=i,0===eT&&eD(T)),n!==i){if(a=[],(s=ti())!==i)for(;s!==i;)a.push(s),s=ti();else a=i;a!==i?r=n=[n,a]:(eE=r,r=i)}else eE=r,r=i;return r!==i?e.substring(t,eE):r}())===i&&(n=null),e$=t,h=r,t=(p=n)?h+p:h}else eE=t,t=i;return t===i&&((t=eE,r=eE,n=eE,(a=ti())!==i&&(s=ti())!==i?(58===e.charCodeAt(eE)?(o=":",eE++):(o=i,0===eT&&eD(eh)),o!==i&&(l=ti())!==i&&(c=ti())!==i?n=a=[a,s,o,l,c]:(eE=n,n=i)):(eE=n,n=i),(r=n!==i?e.substring(r,eE):n)!==i&&(n=eE,eT++,58===e.charCodeAt(eE)?(a=":",eE++):(a=i,0===eT&&eD(eh)),eT--,a===i?n=void 0:(eE=n,n=i),n!==i))?(e$=t,t=r+":00"):(eE=t,t=i)),t}function e7(){let t,r,n,a;return"t"===(t=e.charAt(eE)).toLowerCase()?eE++:(t=i,0===eT&&eD(em)),t===i&&(t=eE,32===e.charCodeAt(eE)?(r=" ",eE++):(r=i,0===eT&&eD(eg)),r!==i?(n=eE,eT++,a=ti(),eT--,a!==i?(eE=n,n=void 0):n=i,n!==i?t=r=[r,n]:(eE=t,t=i)):(eE=t,t=i)),t}function te(){let t;return t=e.charAt(eE),S.test(t)?eE++:(t=i,0===eT&&eD(ey)),t}function tt(){let t,r,n;return 10===e.charCodeAt(eE)?(t="\n",eE++):(t=i,0===eT&&eD(eb)),t===i&&(t=eE,13===e.charCodeAt(eE)?(r="\r",eE++):(r=i,0===eT&&eD(ev)),r!==i?(10===e.charCodeAt(eE)?(n="\n",eE++):(n=i,0===eT&&eD(eb)),n!==i?t=r=[r,n]:(eE=t,t=i)):(eE=t,t=i)),t}function tr(){let e;return(e=tt())===i&&(e=te()),e}function tn(){let t,r;return t=eE,eT++,e.length>eE?(r=e.charAt(eE),eE++):(r=i,0===eT&&eD(B)),eT--,r===i?t=void 0:(eE=t,t=i),t}function ti(){let t;return t=e.charAt(eE),w.test(t)?eE++:(t=i,0===eT&&eD(en)),t}function ta(){let t;return t=e.charAt(eE),x.test(t)?eE++:(t=i,0===eT&&eD(ei)),t}function ts(){let t;return t=e.charAt(eE),O.test(t)?eE++:(t=i,0===eT&&eD(ex)),t}function to(){let t,r,n,a,s,o,l,c,u,d,f,h,p,m,g;if(t=eE,92===e.charCodeAt(eE)?(r="\\",eE++):(r=i,0===eT&&eD(L)),r!==i)if(n=e.charAt(eE),E.test(n)?eE++:(n=i,0===eT&&eD(e_)),n!==i){var y;e$=t,t="n"===(y=n)?"\n":"t"===y?" ":"r"===y?"\r":"\\"===y?"\\":'"'===y?'"':"b"===y?"\b":"f"===y?"\f":"\x1b"}else eE=t,t=i;else eE=t,t=i;return t===i&&((a=eE,"\\U"===e.substr(eE,2)?(s="\\U",eE+=2):(s=i,0===eT&&eD(ek)),s!==i&&(o=eE,l=eE,(c=ta())!==i&&(u=ta())!==i&&(d=ta())!==i&&(f=ta())!==i&&(h=ta())!==i&&(p=ta())!==i&&(m=ta())!==i&&(g=ta())!==i?l=c=[c,u,d,f,h,p,m,g]:(eE=l,l=i),(o=l!==i?e.substring(o,eE):l)!==i))?(e$=a,a=ty(o)):(eE=a,a=i),a===i&&((a=eE,"\\u"===e.substr(eE,2)?(s="\\u",eE+=2):(s=i,0===eT&&eD(eS)),s!==i&&(o=eE,l=eE,(c=ta())!==i&&(u=ta())!==i&&(d=ta())!==i&&(f=ta())!==i?l=c=[c,u,d,f]:(eE=l,l=i),(o=l!==i?e.substring(o,eE):l)!==i))?(e$=a,a=ty(o)):(eE=a,a=i),a===i&&((a=eE,"\\x"===e.substr(eE,2)?(s="\\x",eE+=2):(s=i,0===eT&&eD(eO)),s!==i&&(o=eE,l=eE,(c=ta())!==i&&(u=ta())!==i?l=c=[c,u]:(eE=l,l=i),(o=l!==i?e.substring(o,eE):l)!==i))?(e$=a,a=ty(o)):(eE=a,a=i))),t=a),t}var tl=[],tc=0,tu=r&&null!=r.maxDepth?r.maxDepth:500;function td(t,r){var n=function(t){for(var r=1,n=1,i=0;i<t;i++)10===e.charCodeAt(i)?(r++,n=1):n++;return{line:r,column:n}}(r),i=Error(t);throw i.line=n.line,i.column=n.column,i}function tf(e){tl.push(e)}function th(e,t,r,n){var i={type:e,value:t,offset:r};return n&&(i.key=n),i}function tp(e,t){var r=1e3*e.charCodeAt(0)+100*e.charCodeAt(1)+10*e.charCodeAt(2)+e.charCodeAt(3)-53328,n=(e.charCodeAt(5)-48)*10+e.charCodeAt(6)-48,i=(e.charCodeAt(8)-48)*10+e.charCodeAt(9)-48;(n<1||n>12)&&td("Invalid date: month "+n+" out of range.",t);var a=[31,28,31,30,31,30,31,31,30,31,30,31];(r%4==0&&r%100!=0||r%400==0)&&(a[1]=29),(i<1||i>a[n-1])&&td("Invalid date: day "+i+" out of range for month "+n+".",t)}function tm(e,t){var r=(e.charCodeAt(0)-48)*10+e.charCodeAt(1)-48,n=(e.charCodeAt(3)-48)*10+e.charCodeAt(4)-48,i=(e.charCodeAt(6)-48)*10+e.charCodeAt(7)-48;r>23&&td("Invalid time: hour "+r+" out of range.",t),n>59&&td("Invalid time: minute "+n+" out of range.",t),i>59&&td("Invalid time: second "+i+" out of range.",t)}function tg(e){return -1===e.indexOf("_")?e:e.replace(/_/g,"")}function ty(e){var t=parseInt(e,16);if(t==t&&!(t<0)&&!(t>1114111)&&(!(t>55295)||!(t<57344)))return String.fromCodePoint(t);td("Invalid Unicode escape code: "+e,e$)}let tb=(n=o())!==i&&eE===e.length;function tv(){var r,a,s;throw n!==i&&eE<e.length&&eD({type:"end"}),r=eC,a=eA<e.length?function(t=eE){let r=e.codePointAt(t);return void 0===r?"":String.fromCodePoint(r)}(eA):null,s=eA<e.length?ej(eA,eA+1):ej(eA,eA),new t(t.buildMessage(r,a),r,a,s)}return r.peg$library?{peg$result:n,peg$currPos:eE,peg$FAILED:i,peg$maxFailExpected:eC,peg$maxFailPos:eA,peg$success:tb,peg$throw:tb?void 0:tv}:tb?n:void tv()}}},5947(e,r,n){let i,a,s,o,l,c,u,d,f,h,p,m,g,y,b,v,w,x,_,k,S,O,E,$,I,A,C;var T,N,M,P,j,D=n(8543),U=n(7720),F=n(7598),R=n(4650);let L=(e,t)=>t(F.oJ(e)?0:D.nn(e.cause)?130:Y(D.iw(e.cause))),B="~effect/Runtime/errorExitCode",Y=e=>{if("object"==typeof e&&null!==e&&B in e){let t=e[B];if("number"==typeof t)return t}return 1},q="~effect/Runtime/errorReported",X=(i=({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,R.XY)(e=>U.yw5(e[0]),(e,t)=>{let r=t?.disableErrorReporting===!0?U.MY7(e):U.MY7(U.dGm(e,e=>D.nn(e)?U.rIH:(e=>{if("object"==typeof e&&null!==e&&q in e){let t=e[q];if("boolean"==typeof t)return t}return!0})(D.iw(e))?U.vVN(e):U.rIH));try{let e=globalThis.setInterval(R.Yi,0x7fffffff);r.addObserver(()=>{clearInterval(e)})}catch{}return i({fiber:r,teardown:t?.teardown??L})}));var W=n(5089),J=n(3717),z=n(8927),K=n(3833),V=n(995);function G(){return Object.assign(e=>e,{option:e=>K.some(e),result:e=>V.Py(e),is:e=>!0})}var H=n(8619),Q=n(2718);let Z="~effect/platform/PlatformError";class ee extends Q.rN("BadArgument"){get message(){return`${this.module}.${this.method}${this.description?`: ${this.description}`:""}`}}class et extends Q.$D{get message(){return`${this._tag}: ${this.module}.${this.method}${void 0!==this.pathOrDescriptor?` (${this.pathOrDescriptor})`:""}${this.description?`: ${this.description}`:""}`}}class er extends Q.rN("PlatformError"){constructor(e){"cause"in e?super({reason:e,cause:e.cause}):super({reason:e})}[Z]=Z;get message(){return this.reason.message}}let en=e=>new er(new et(e)),ei=e=>new er(new ee(e));var ea=n(9138),es=n(5369),eo=n(4505),el=n(8433),ec=n(1136);let eu=Symbol.for("effect/MutableList/Empty"),ed=()=>({array:[],mutable:!0,offset:0,next:void 0}),ef=(e,t)=>{e.tail?e.tail.mutable||(e.tail.next=ed(),e.tail=e.tail.next):e.head=e.tail=ed(),e.tail.array.push(t),e.length++},eh=e=>{e.head=e.tail=void 0,e.length=0},ep=e=>{if(!e.head)return eu;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:eh(e)),t},em={_A:R.D_,_E:R.D_},eg={"~effect/Queue":em,"~effect/Queue/Enqueue":em,"~effect/Queue/Dequeue":em,...el.fU,toJSON(){return{_id:"effect/Queue",state:this.state._tag,size:eI(this)}}},ey=e=>el.R6(t=>{let r=Object.create(eg);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},ec.PyW(r)}),eb=(e,t)=>ec.DYE(()=>{if("Open"!==e.state._tag)return eA;if(e.messages.length>=e.capacity)switch(e.strategy){case"dropping":return eA;case"suspend":if(e.capacity<=0&&e.state.takers.size>0)return ef(e.messages,t),eM(e),eC;return eD(e,t);case"sliding":return ep(e.messages),ef(e.messages,t),eC}return ef(e.messages,t),eP(e),eC}),ev=(e,t)=>"Open"===e.state._tag&&(e.messages.length>=e.capacity?"sliding"===e.strategy?(ep(e.messages),ef(e.messages,t),!0):e.capacity<=0&&e.state.takers.size>0&&(ef(e.messages,t),eM(e),!0):(ef(e.messages,t),eP(e),!0)),ew=(0,R.XY)(2,(e,t)=>ec.OH5(()=>ex(e,t))),ex=(e,t)=>{if("Open"!==e.state._tag)return!1;let r=el.cb(t),n=ec.il9(r,eT);return 0===e.state.offers.size&&0===e.messages.length?eR(e,n):e.state={...e.state,_tag:"Closing",exit:n},!0},e_=e=>ex(e,el.OE(el.RS())),ek=e=>ec.OH5(()=>{if("Done"===e.state._tag)return!0;eh(e.messages);let t=e.state.offers;if(eR(e,"Open"===e.state._tag?eN:e.state.exit),t.size>0){for(let e of t)"Single"===e._tag?e.resume(eA):e.resume(el.xt(e.remaining.slice(e.offset)));t.clear()}return!0}),eS=e=>eO(e,1,1/0),eO=(e,t,r)=>ec.DYE(()=>ej(e,t,r)??ec.hgn(eF(e),eO(e,1,r))),eE=e=>ec.DYE(()=>e$(e)??ec.hgn(eF(e),eE(e))),e$=e=>{if("Done"===e.state._tag)return e.state.exit;if(e.messages.length>0){let t=ep(e.messages);return eU(e),el.xt(t)}if(e.capacity<=0&&e.state.offers.size>0){e.capacity=1,eU(e),e.capacity=0;let t=ep(e.messages);return eU(e),el.xt(t)}},eI=e=>"Done"===e.state._tag?0:e.messages.length,eA=el.xt(!1),eC=el.xt(!0),eT=el.Rk(el.RS()),eN=ec._sz(),eM=e=>{if(e.scheduleRunning=!1,"Done"!==e.state._tag&&0!==e.state.takers.size){for(let t of e.state.takers)if(e.state.takers.delete(t),t(ec.x5l),0===e.messages.length)break}},eP=e=>{e.scheduleRunning||"Done"===e.state._tag||0===e.state.takers.size||(e.scheduleRunning=!0,e.dispatcher.scheduleTask(()=>eM(e),0))},ej=(e,t,r)=>{if("Done"===e.state._tag)return e.state.exit;if(r<=0||t<=0)return el.xt([]);if(e.capacity<=0&&e.state.offers.size>0){e.capacity=1,eU(e),e.capacity=0;let t=[ep(e.messages)];return eU(e),el.xt(t)}if((t=Math.min(t,e.capacity||1))<=e.messages.length){let t=((e,t)=>{if(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 eh(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,e.length-=t,0===e.length&&eh(e),r;i=i.next}return eh(e),r})(e.messages,r);return eU(e),el.xt(t)}},eD=(e,t)=>ec.E2r(r=>{if("Open"!==e.state._tag)return r(eA);let n={_tag:"Single",message:t,resume:r};return e.state.offers.add(n),ec.OH5(()=>{"Open"===e.state._tag&&e.state.offers.delete(n)})}),eU=e=>{if("Done"===e.state._tag)return eo.Og(e.state.exit.cause);if(0===e.state.offers.size)return"Closing"===e.state._tag&&0===e.messages.length&&(eR(e,e.state.exit),eo.Og(e.state.exit.cause));let t=e.capacity-e.messages.length;for(let r of e.state.offers)if(0===t)break;else if("Single"===r._tag)ef(e.messages,r.message),t--,r.resume(eC),e.state.offers.delete(r);else{for(;r.offset<r.remaining.length;r.offset++){if(0===t)return!1;ef(e.messages,r.remaining[r.offset]),t--}r.resume(el.xt([])),e.state.offers.delete(r)}return!1},eF=e=>ec.E2r(t=>"Done"===e.state._tag?t(e.state.exit):(e.state.takers.add(t),ec.OH5(()=>{"Done"!==e.state._tag&&e.state.takers.delete(t)}))),eR=(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(t);for(let e of(r.takers.clear(),r.awaiters))e(t);r.awaiters.clear()};var eL=n(2672);let eB="~effect/Channel",eY=e=>(0,es.i5)(e,eB),eq={[eB]:{_Env:R.D_,_InErr:R.D_,_InElem:R.D_,_OutErr:R.D_,_OutElem:R.D_},pipe(){return(0,ea.tT)(this,arguments)}},eX=e=>{let t=Object.create(eq);return t.transform=(t,r)=>U.Tyx(e(t,r),e=>U.PyW(U.ATB(e))),t},eW=(e,t)=>eX((r,n)=>U.qIB(ez(e)(r,n),e=>t(e,n))),eJ=e=>eX((t,r)=>e),ez=e=>e.transform,eK=eJ(U.PyW(D.Vw()));U.ZmZ;let eV=(0,R.XY)(2,(e,t)=>eW(e,e=>U.OH5(()=>{let r=0;return U.TjK(e,e=>t(e,r++))}))),eG=(0,R.XY)(2,(e,t)=>eH(e,e=>U.PyW(t(e)))),eH=(0,R.XY)(2,(e,t)=>eW(e,e=>U.PyW(eo.m8(e,e=>U.qIB(t(e),D.Vw))))),eQ=(0,R.XY)(e=>eY(e[0])&&eY(e[1]),(e,t,r)=>{let n;return n=U.D9k(function*(n,i,a){let s=r?.haltStrategy??"both",o=yield*ey({capacity:0});yield*eL.U9(a,ek(o));let l=0,c=(e,t,r)=>ez(t)(n,r).pipe(U.qIB(e=>e.pipe(U.qIB(e=>eb(o,e)),U.i4r)),U.S5A(t=>U.hgn(eL.VN(r,eo.aU(t)),function(e,t){if(l++,!eo.Og(t))return ew(o,t);switch(s){case"both":return 2===l?ew(o,t):U.rIH;case"left":case"right":return e===s?ew(o,t):U.rIH;case"either":return ew(o,t)}}(e,t))),U.ar0(a));return yield*c("left",e,eL.Fp(a)),yield*c("right",t,eL.Fp(a)),eE(o)}),eX(U.D9k(function*(e,t){let r=eL.Fp(t),i=e=>eL.VN(r,eo.aU(e)),a=yield*U.S5A(n(e,t,r),i);return U.S5A(a,i)}))}),eZ=(0,R.XY)(2,(e,t)=>eX((r,n)=>U.qIB(ez(e)(r,n),e=>ez(t)(e,n)))),e0=e=>eX((t,r)=>{let n;return U.PyW(U.DYE(()=>n||e.pipe(eL.Gt(r),U.qIB(e=>ez(e)(t,r)),U.qIB(e=>n=e))))}),e1=(e,t,r)=>U.DYE(()=>{let n=eL.LZ(),i=ez(e)(D.Vw(),n);return eo.m8(U.qIB(i,t),r||U.PyW).pipe(U.cfM(e=>eL.VN(n,e)))}),e2=(0,R.XY)(2,(e,t)=>e1(e,e=>U.i4r(U.qIB(e,t),{disableYield:!0}))),e3=(0,R.XY)(3,(e,t,r)=>U.DYE(()=>{let n=t();return e1(e,e=>U.iMI({while:R.ue,body:()=>e,step:e=>{n=r(n,e)}}),()=>U.PyW(n))})),e5=(0,R.XY)(3,(e,t,r)=>U.DYE(()=>{let n=t();return e1(e,e=>U.iMI({while:R.ue,body:(0,R.dY)(e.pipe(U.qIB(e=>r(n,e)),U.TjK(e=>{n=e}))),step:R.Yi}),()=>U.PyW(n))})),e6=(e,t)=>ez(e)(D.Vw(),t),e8="~effect/Sink",e4=U.PyW([void 0]),e9={[e8]:{_A:R.D_,_In:R.D_,_L:R.D_,_E:R.D_,_R:R.D_},pipe(){return(0,ea.tT)(this,arguments)}},e7=e=>(0,es.i5)(e,e8),te=e=>tt((t,r)=>ez(e)(t,r).pipe(U.qIB(U.i4r({disableYield:!0})),eo.m8(U.PyW))),tt=e=>{let t=Object.create(e9);return t.transform=e,t},tr=e=>eX((t,r)=>U.PyW(U.qIB(e.transform(t,r),D.Vw)));U.ZmZ;let tn=tt(e=>eo.m8(U.i4r(e,{disableYield:!0}),()=>e4));K.none,K.isNone,K.none;let ti=e=>te(e0(U.TjK(e,tr))),ta={"~effect/Stream":{_R:R.D_,_E:R.D_,_A:R.D_},pipe(){return(0,ea.tT)(this,arguments)}},ts=e=>(0,es.i5)(e,"~effect/Stream"),to=e=>{let t=Object.create(ta);return t.channel=e,t},tl=e=>e.channel,tc=to(eK),tu=e=>{let t;return to((t=()=>e().channel,eX((e,r)=>U.DYE(()=>ez(t())(e,r)))))},td=e=>{let t;return z.ET(e)?to((t=U.PyW(e),eJ(U.OH5(()=>{let e=!1;return U.DYE(()=>e?D.Vw():(e=!0,t))})))):tc},tf=e=>to(e0(U.TjK(e,tl))),th=(0,R.XY)(2,(e,t)=>tu(()=>{let r=0;return to(eV(e.channel,z.Tj(e=>t(e,r++))))})),tp=(0,R.XY)(e=>ts(e[0])&&ts(e[1]),(e,t,r)=>to(eQ(tl(e),tl(t),r))),tm=(0,R.XY)(2,(e,t)=>{let r;return r=(e,r)=>U.OH5(()=>{let n,i,a=U.DYE(()=>{if(void 0!==i){let e=i;return i=void 0,U.PyW(e)}return e}).pipe(U.MfU(e=>(n=F.fJ(e),D.Vw()))),s=U.TjK(U.DYE(()=>t.transform(a,r)),([e,t])=>(i=t,z.of(e)));return U.DYE(()=>n||s)}),to(eX((t,n)=>U.qIB(e6(e.channel,n),e=>r(e,n))))}),tg=(0,R.XY)(e=>ts(e[0]),(e,t)=>tu(()=>{let r=new TextDecoder(t?.encoding);return th(e,e=>r.decode(e,{stream:!0}))})),ty=(0,R.XY)(2,(e,t)=>U.Pxi(r=>e6(e.channel,r).pipe(U.qIB(e=>t.transform(e,r)),U.TjK(([e])=>e)))),tb=(0,R.XY)(3,(e,t,r)=>e5(e.channel,t,(e,t)=>{let n=0,i=e;return U.TjK(U.iMI({while:()=>n<t.length,body:()=>r(i,t[n]),step(e){i=e,n++}}),()=>i)})),tv=((e,t)=>e2(e.channel,t),"~effect/platform/FileSystem"),tw=e=>"bigint"==typeof e?e:BigInt(e),tx=H.kl("effect/platform/FileSystem"),t_="~effect/platform/FileSystem/File",tk=G();class tS extends H.kl()("effect/platform/FileSystem/WatchBackend"){}let tO="~effect/platform/Path",tE=H.kl("effect/Path");var t$=n(3267),tI=n(6400);let tA=G(),tC=G(),tT="~effect/ChildProcessSpawner/ChildProcessHandle",tN={[tT]:tT,...tI.os,toJSON(){return{_id:"ChildProcessHandle",pid:this.pid}}},tM=e=>Object.assign(Object.create(tN),e);class tP extends H.kl()("effect/process/ChildProcessSpawner"){}let tj="~effect/unstable/process/ChildProcess",tD={...t$.b({label:"Command",evaluate(e){return H.fp(e.context,tP).spawn(this)}}),[tj]:tj},tU=(e,t,r)=>Object.assign(Object.create(tD),{_tag:"StandardCommand",command:e,args:t,options:r}),tF=function(...e){if(tR(e[0])){let[t,...r]=e,n=tY(t,r);return tU(n[0]??"",n.slice(1),{})}if("object"==typeof e[0]&&!Array.isArray(e[0])&&!tR(e[0])){let t=e[0];return function(e,...r){let n=tY(e,r);return tU(n[0]??"",n.slice(1),t)}}if("string"==typeof e[0]&&!Array.isArray(e[1])){let[t,r={}]=e;return tU(t,[],r)}let[t,r=[],n={}]=e;return tU(t,r,n)},tR=e=>Array.isArray(e)&&"raw"in e&&Array.isArray(e.raw),tL=e=>{let t=/^fd(\d+)$/.exec(e);if(null===t)return;let r=parseInt(t[1],10);return r>=3?r:void 0},tB=e=>`fd${e}`,tY=(e,t)=>{let r=[];for(let[n,i]of e.entries())r=tq(e,t,r,i,n);return r},tq=(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}=tz(n,a),c=tK(r,l,s);if(i===t.length)return c;let u=t[i];return tK(c,Array.isArray(u)?u.map(e=>tX(e)):[tX(u)],o)},tX=e=>"string"==typeof e?e:String(e),tW=new Set([" "," ","\r","\n"]),tJ={x:3,u:5},tz=(e,t)=>{if(0===t.length)return{tokens:[],hasLeadingWhitespace:!1,hasTrailingWhitespace:!1};let r=tW.has(t[0]),n=[],i=0;for(let r=0,a=0;r<e.length;r+=1,a+=1){let s=t[a];if(tW.has(s))i!==r&&n.push(e.slice(i,r)),i=r+1;else if("\\"===s){let e=t[a+1];"\n"===e?(r-=1,a+=1):"u"===e&&"{"===t[a+2]?a=t.indexOf("}",a+3):a+=tJ[e]??1}}let a=i===e.length;return a||n.push(e.slice(i)),{tokens:n,hasLeadingWhitespace:r,hasTrailingWhitespace:a}},tK=(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)],tV=t("node:child_process"),tG=t("node:stream"),tH=(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 en({_tag:i,module:e,method:t,pathOrDescriptor:n,syscall:r.syscall,cause:r})},tQ=e=>te(eG(tZ(e),e=>[e])),tZ=e=>eX(t=>{let r=e.evaluate();return U.PyW(t0({...e,writable:r,pull:t}))}),t0=e=>e.pull.pipe(U.qIB(t=>{let r=0;return U.E2r(function n(i){for(;r<t.length;)if(!e.writable.write(t[r++],e.encoding))return void e.writable.once("drain",()=>n(i));i(U.rIH)})}),U.i4r({disableYield:!0}),U.KT6(U.E2r(t=>{let r=r=>t(U.fJG(e.onError(r)));return e.writable.once("error",r),U.OH5(()=>{e.writable.off("error",r)})})),!1!==e.endOnDone?eo.m8(t=>"closed"in e.writable&&e.writable.closed?D.Vw(t):U.E2r(r=>{e.writable.once("finish",()=>r(D.Vw(t))),e.writable.end()})):R.D_);ec.zFM,ec.C6p,ec.D7p,ec.INJ;let t1=ec.mKq;ec.eGS,ec.DKo,ec.$MQ,ec.Iku;let t2=ec.vTQ,t3=ec.zzk;ec.Fbb;let t5="~effect/MutableRef",t6={[t5]:t5,...el.fU,toJSON(){return{_id:"MutableRef",current:(0,tI.aB)(this.current)}}},t8=e=>to(t4(e)),t4=e=>eX((t,r)=>t9({scope:r,readable:e.evaluate(),onError:e.onError??t7,chunkSize:e.chunkSize,closeOnDone:e.closeOnDone})),t9=e=>{var t;let r,n=e.readable,i=e.closeOnDone??!0,a=e.exit??(t=void 0,(r=Object.create(t6)).current=t,r),s=t3(!1);function o(){s.openUnsafe()}function l(t){a.current=F.fJ(e.onError(t)),s.openUnsafe()}function c(){a.current=F.fJ(D.RS()),s.openUnsafe()}n.on("readable",o),n.once("error",l),n.once("end",c);let u=U.DYE(function t(){let r=e.readable.read(e.chunkSize);if(null===r)return a.current?a.current:n.readableEnded?U.fJG(D.RS()):(s.closeUnsafe(),U.qIB(s.await,t));let i=z.of(r);for(;null!==(r=e.readable.read(e.chunkSize));)i.push(r);return U.PyW(i)});return U.as(eL.U9(e.scope,U.OH5(()=>{n.off("readable",o),n.off("error",l),n.off("end",c),i&&"closed"in e.readable&&!e.readable.closed&&e.readable.destroy()})),u)};tG.Readable;let t7=e=>new D.Bk(e),re=e=>e instanceof globalThis.Error?e:new globalThis.Error(String(e)),rt=(e,t,r)=>{let{commands:n}=ri(r),i=n.reduce((e,t)=>{let r=`${t.command} ${t.args.join(" ")}`;return 0===e.length?r:`${e} | ${r}`},"");return tH("ChildProcess",e)(t,[i])},rr=U.JkU(function*(){let e,t,r=yield*tx,n=yield*tE,i=U.D9k(function*(e){if(!es.b0(e.cwd))return yield*r.access(e.cwd),n.resolve(e.cwd)}),a=e=>e7(e)?"pipe":e,s=e=>{let t={stream:"pipe",encoding:"utf-8",endOnDone:!0};return es.b0(e.stdin)?t:"string"==typeof e.stdin||ts(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 es.b0(r)?{stream:"pipe"}:"string"==typeof r||e7(r)?{stream:r}:{stream:r.stream}},l=U.D9k(function*(e,t,r){if(0===r.length)return{getInputFd:()=>tn,getOutputFd:()=>tc};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=tn;r&&"write"in r&&(t=tQ({evaluate:()=>r,onError:t=>rt(`fromWritable(fd${s})`,re(t),e)})),a.stream&&(yield*U.x6Z(ty(a.stream,t))),n.set(s,t);break}case"output":{let t=tc;if(r&&"read"in r){let n=new tG.PassThrough;r.on("error",e=>n.destroy(e)),r.pipe(n),t=t8({evaluate:()=>n,onError:t=>rt(`fromReadable(fd${s})`,re(t),e)})}a.sink&&(t=tm(t,a.sink)),i.set(s,t)}}}return{getInputFd:e=>n.get(e)??tn,getOutputFd:e=>i.get(e)??tc}}),c=(e,t,r)=>"win32"===globalThis.process.platform?U.E2r(r=>{tV.exec(`taskkill /pid ${t.pid} /T /F`,t=>{t?r(U.fJG(rt("kill",re(t),e))):r(U.rIH)})}):U.SvU({try:()=>{globalThis.process.kill(-t.pid,r)},catch:t=>rt("kill",re(t),e)}),u=(e,t,r)=>U.DYE(()=>{if(!t.kill(r)){let t=new globalThis.Error("Failed to kill child process");return U.fJG(rt("kill",t,e))}return U.rIH}),d=(e,t,r)=>n=>{let i=r?.killSignal??"SIGTERM";return es.b0(r?.forceKillAfter)?n(t,e,i):U.mgX(n(t,e,i),{duration:r.forceKillAfter,orElse:()=>n(t,e,"SIGKILL")})},f=(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=tL(r);if(es.EA(t))return e.getOutputFd(t);return e.stdout}}},h=U.D9k(function*(e){switch(e._tag){case"StandardCommand":{let t,r,n,f,h,p,m,g=s(e.options),y=o(e.options,"stdout"),b=o(e.options,"stderr"),v=(e=>{if(es.b0(e.additionalFds))return[];let t=[];for(let[r,n]of Object.entries(e.additionalFds)){let e=tL(r);es.EA(e)&&t.push({fd:e,config:n})}return t.sort((e,t)=>e.fd-t.fd)})(e.options),w=!0,x=yield*i(e.options),_=(t=e.options).extendEnv?{...globalThis.process.env,...t.env}:t.env,k=((e,t,r,n)=>{let i,s=[ts(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})(g,y,b,v),[S,O]=yield*U.Q56((r={cwd:x,env:_,stdio:k,detached:e.options.detached??"win32"!==process.platform,shell:e.options.shell},U.E2r(t=>{let n=J.LZ(),i=tV.spawn(e.command,e.args,r);return i.on("error",r=>{t(U.fJG(rt("spawn",r,e)))}),i.on("exit",(...e)=>{J.$w(n,F.Py(e))}),i.on("spawn",()=>{t(U.PyW([i,n]))}),U.OH5(()=>{i.kill("SIGTERM")})})),U.D9k(function*([t,r]){let n=yield*J.$L(r),i=d(t,e,e.options);if(n){let[e]=yield*J.Tx(r);return 0!==e&&es.Pe(e)?yield*U.XeO(i(c)):yield*U.rIH}return w?yield*i((e,t,n)=>c(e,t,n).pipe(U.MfU(()=>u(e,t,n)),U.hgn(J.Tx(r)))).pipe(U.XeO):yield*U.rIH})),E=tC(S.pid);S.on("exit",t=>{0!==t&&es.Pe(t)&&((e,t)=>{if("win32"===globalThis.process.platform)return tV.exec(`taskkill /pid ${e.pid} /T /F`,()=>{});try{globalThis.process.kill(-e.pid,t)}catch{}})(S,e.options.killSignal??"SIGTERM")});let $=U.OH5(()=>{w||(S.ref(),w=!0)}),I=U.OH5(()=>(w&&(S.unref(),w=!1),$)),A=yield*U.DYE(()=>{let t=tn;return(es.Pe(S.stdin)&&(t=tQ({evaluate:()=>S.stdin,onError:t=>rt("fromWritable(stdin)",re(t),e),endOnDone:g.endOnDone,encoding:g.encoding})),ts(g.stream))?U.as(U.x6Z(ty(g.stream,t)),t):U.PyW(t)}),{all:C,stderr:T,stdout:N}=(f=S.stdout?(n=new tG.PassThrough,S.stdout.on("error",e=>n.destroy(e)),S.stdout.pipe(n),t8({evaluate:()=>n,onError:t=>rt("fromReadable(stdout)",re(t),e)})):tc,p=S.stderr?(h=new tG.PassThrough,S.stderr.on("error",e=>h.destroy(e)),S.stderr.pipe(h),t8({evaluate:()=>h,onError:t=>rt("fromReadable(stderr)",re(t),e)})):tc,e7(y.stream)&&(f=tm(f,y.stream)),e7(b.stream)&&(p=tm(p,b.stream)),m=tp(f,p),{stdout:f,stderr:p,all:m}),{getInputFd:M,getOutputFd:P}=yield*l(e,S,v),j=U.TjK(J.$L(O),e=>!e);return tM({pid:E,exitCode:U.qIB(J.Tx(O),([t,r])=>{if(es.Pe(t))return U.PyW(tA(t));let n=new globalThis.Error(`Process interrupted due to receipt of signal: '${r}'`);return U.fJG(rt("exitCode",n,e))}),isRunning:j,kill:t=>d(S,e,t)((e,t,r)=>c(e,t,r).pipe(U.MfU(()=>u(e,t,r)),U.hgn(J.Tx(O)))).pipe(U.NLW),stdin:A,stdout:N,stderr:T,all:C,getInputFd:M,getOutputFd:P,unref:I})}case"PipedCommand":{let{commands:t,pipeOptions:r}=ri(e),[n,...i]=t,a=[(yield*h(n))];for(let e=0;e<i.length;e++){let t=i[e],n=r[e]??{},o=s(t.options),l=tf(U.PyW(f(a[a.length-1],n.from))),c=n.to??"stdin";if("stdin"===c)a.push((yield*h(tF(t.command,t.args,{...t.options,stdin:{...o,stream:l}}))));else{let e=tL(c);if(es.EA(e)){let r=tB(e),n=t.options.additionalFds??{};a.push((yield*h(tF(t.command,t.args,{...t.options,additionalFds:{...n,[r]:{type:"input",stream:l}}}))))}else a.push((yield*h(tF(t.command,t.args,{...t.options,stdin:{...o,stream:l}}))))}}let o=a[a.length-1],l=U.JkU(function*(){let e=[];for(let t of a)e.push((yield*t.unref));return U.jJl([...e].reverse(),e=>e,{discard:!0})});return tM({pid:o.pid,exitCode:o.exitCode,isRunning:o.isRunning,kill:o.kill,stdin:o.stdin,stdout:o.stdout,stderr:o.stderr,all:o.all,getInputFd:o.getInputFd,getOutputFd:o.getOutputFd,unref:l})}}});return e=(e,t)=>h(e).pipe(U.TjK(e=>tg(t?.includeStderr===!0?e.all:e.stdout)),tf),t=(t,r)=>e(t,r).channel.pipe(eZ(eX((e,t)=>U.OH5(()=>{let t="",r=!1,n=K.none(),i=U.DYE(()=>"Some"===n._tag?D.Vw(n.value):eo.tv(e,{onSuccess:a,onFailure:U.ATB,onDone:e=>{if(n=K.some(e),t.length>0||r){let e=t;return t="",r=!1,U.PyW([e])}return D.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?(i(""),e=1,s=a.indexOf("\n",e)):i(""),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)):a.length===n+1?(r=!0,n=-1):(i(a.substring(e,n)),e=n+(s===n+1?2:1),n=a.indexOf("\r",e),s=a.indexOf("\n",e));t+=a.substring(e,a.length-!!r)}}return z.ET(n)?n:null}(e);return null!==n?U.PyW(n):i}return i}))),to),tP.of({spawn:h,exitCode:e=>U.P1j(U.qIB(h(e),e=>e.exitCode)),streamString:e,streamLines:t,lines:(e,r)=>e3(t(e,r).channel,()=>[],(e,t)=>{for(let r=0;r<t.length;r++)e.push(t[r]);return e}),string:(t,r)=>e3(e(t,r).channel,()=>"",(e,t)=>e+t.join(""))})}),rn=W.QZ(tP,rr),ri=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}},ra="~effect/platform/Crypto",rs=H.kl("effect/Crypto"),ro=e=>e.toString(16).padStart(2,"0"),rl=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,ro).join("")).join("-"),rc=0x1000000000000-1,ru=t("node:crypto"),rd=(a=(P={randomBytes:ru.randomBytes,digest:(e,t)=>U.SvU({try:()=>Uint8Array.from(ru.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=>en({module:"Crypto",method:"digest",_tag:"Unknown",description:"Could not compute digest",cause:e})})}).randomBytes,s=()=>{let e=a(7);return((31&e[0])*0x1000000000000+0x10000000000*e[1]+0x100000000*e[2]+0x1000000*e[3]+65536*e[4]+256*e[5]+e[6])/0x20000000000000},o=()=>Math.floor(s()*(Number.MAX_SAFE_INTEGER-Number.MIN_SAFE_INTEGER+1))+Number.MIN_SAFE_INTEGER,rs.of({[ra]:ra,randomBytes:e=>{let t,r;return U.TjK((t="randomBytes",Number.isSafeInteger(r=e)&&r>=0?U.PyW(r):U.fJG(ei({module:"Crypto",method:t,description:"size must be a non-negative safe integer"}))),a)},nextDoubleUnsafe:s,nextIntUnsafe:o,digest:P.digest,random:U.OH5(()=>s()),randomBoolean:U.OH5(()=>s()>.5),randomInt:U.OH5(()=>o()),randomBetween:(e,t)=>U.OH5(()=>s()*(t-e)+e),randomIntBetween(e,t,r){let n=+(r?.halfOpen!==!0);return U.OH5(()=>{let r=Math.ceil(e),i=Math.floor(t);return Math.floor(s()*(i-r+n))+r})},randomShuffle:e=>U.OH5(()=>{let t=Array.from(e);for(let e=t.length-1;e>=1;e-=1){let r=Math.min(e,Math.floor(s()*(e+1))),n=t[e];t[e]=t[r],t[r]=n}return t}),randomUUIDv4:U.OH5(()=>{let e;return(e=a(16))[6]=15&e[6]|64,e[8]=63&e[8]|128,rl(e)}),randomUUIDv7:U.RKA(e=>{var t,r;let n;return U.PyW((t=e.currentTimeMillisUnsafe(),r=a(16),n=Math.min(Math.max(0,Math.trunc(t)),rc),r[0]=Math.floor(n/0x10000000000),r[1]=255&Math.floor(n/0x100000000),r[2]=255&Math.floor(n/0x1000000),r[3]=255&Math.floor(n/65536),r[4]=255&Math.floor(n/256),r[5]=255&n,r[6]=15&r[6]|112,r[8]=63&r[8]|128,rl(r)))})})),rf=W.Py(rs,rd),rh=t("node:fs"),rp=t("node:os"),rm=t("node:path");var rg=n.t(rm,2);let ry=e=>t=>ei({module:"FileSystem",method:e,description:t.message??String(t)}),rb=(l=(0,U._r7)(rh.access,tH("FileSystem","access"),ry("access")),(e,t)=>{let r=rh.constants.F_OK;return t?.readable&&(r|=rh.constants.R_OK),t?.writable&&(r|=rh.constants.W_OK),l(e,r)}),rv=(c=(0,U._r7)(rh.cp,tH("FileSystem","copy"),ry("copy")),(e,t,r)=>c(e,t,{force:r?.overwrite??!1,preserveTimestamps:r?.preserveTimestamps??!1,recursive:!0})),rw=(u=(0,U._r7)(rh.copyFile,tH("FileSystem","copyFile"),ry("copyFile")),(e,t)=>u(e,t)),rx=(d=(0,U._r7)(rh.chmod,tH("FileSystem","chmod"),ry("chmod")),(e,t)=>d(e,t)),r_=(f=(0,U._r7)(rh.chown,tH("FileSystem","chown"),ry("chown")),(e,t,r)=>f(e,t,r)),rk=(h=(0,U._r7)(rh.glob,tH("FileSystem","glob"),ry("glob")),(e,t)=>h(e,{cwd:t?.root,exclude:t?.exclude})),rS=(p=(0,U._r7)(rh.link,tH("FileSystem","link"),ry("link")),(e,t)=>p(e,t)),rO=(m=(0,U._r7)(rh.mkdir,tH("FileSystem","makeDirectory"),ry("makeDirectory")),(e,t)=>m(e,{recursive:t?.recursive??!1,mode:t?.mode})),rE=e=>{let t=(0,U._r7)(rh.mkdtemp,tH("FileSystem",e),ry(e));return e=>U.DYE(()=>{let r=e?.prefix??"",n="string"==typeof e?.directory?rm.join(e.directory,"."):rp.tmpdir();return t(r?rm.join(n,r):n+"/")})},r$=rE("makeTempDirectory"),rI=e=>{let t=(0,U._r7)(rh.rm,tH("FileSystem",e),ry(e));return(e,r)=>t(e,{recursive:r?.recursive??!1,force:r?.force??!1})},rA=rI("remove"),rC=(g=rE("makeTempDirectoryScoped"),y=rI("makeTempDirectoryScoped"),e=>U.Q56(g(e),e=>U.QgK(y(e,{recursive:!0})))),rT=(j="open",b=(0,U._r7)(rh.open,tH("FileSystem",j),ry(j)),v=(0,U._r7)(rh.close,tH("FileSystem",j),ry(j)),(e,t)=>(0,R.Fs)(U.Q56(b(e,t?.flag??"r",t?.mode),e=>U.QgK(v(e))),U.TjK(e=>rN(tk(e),t?.flag?.startsWith("a")??!1)))),rN=(()=>{let e=e=>(0,U._r7)(rh.read,tH("FileSystem",e),ry(e)),t=e("read"),r=e("readAlloc"),n=(0,U._r7)(rh.fstat,tH("FileSystem","stat"),ry("stat")),i=(0,U._r7)(rh.ftruncate,tH("FileSystem","truncate"),ry("truncate")),a=(0,U._r7)(rh.fsync,tH("FileSystem","sync"),ry("sync")),s=e=>(0,U._r7)(rh.write,tH("FileSystem",e),ry(e)),o=s("write"),l=s("writeAll");class c{[t_];fd;append;position=BigInt(0);constructor(e,t){this[t_]=t_,this.fd=e,this.append=t}get stat(){return U.TjK(n(this.fd),rB)}get sync(){return a(this.fd)}seek(e,t){let r=tw(e);return U.OH5(()=>("start"===t?this.position=r:"current"===t&&(this.position=this.position+r),this.position))}read(e){return U.DYE(()=>{let r=this.position;return U.TjK(t(this.fd,{buffer:e,position:r}),e=>{let t=tw(e);return this.position=r+t,t})})}readAlloc(e){let t=Number(e);return U.DYE(()=>{let e=Buffer.allocUnsafeSlow(t),n=this.position;return U.TjK(r(this.fd,{buffer:e,position:n}),r=>{if(0===r)return K.none();if(this.position=n+BigInt(r),r===t)return K.some(e);let i=Buffer.allocUnsafeSlow(r);return e.copy(i,0,0,r),K.some(i)})})}truncate(e){return U.TjK(i(this.fd,e?Number(e):void 0),()=>{if(!this.append){let t=BigInt(e??0);this.position>t&&(this.position=t)}})}write(e){return U.DYE(()=>{let t=this.position;return U.TjK(o(this.fd,e,void 0,void 0,this.append?void 0:Number(t)),e=>{let r=tw(e);return this.append||(this.position=t+r),r})})}writeAllChunk(e){return U.DYE(()=>{let t=this.position;return U.qIB(l(this.fd,e,void 0,void 0,this.append?void 0:Number(t)),r=>0===r?U.fJG(en({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)):U.rIH))})}writeAll(e){return this.writeAllChunk(e)}}return(e,t)=>new c(e,t)})(),rM=e=>{let t=rE(e);return U.D9k(function*(e){let r=yield*t(e),n=ru.randomBytes(6).toString("hex"),i=rm.join(r,e?.suffix?`${n}${e.suffix}`:n);return yield*rJ(i,new Uint8Array(0)),i})},rP=rM("makeTempFile"),rj=(w=rM("makeTempFileScoped"),x=rI("makeTempFileScoped"),e=>U.Q56(w(e),e=>U.QgK(x(rm.dirname(e),{recursive:!0})))),rD=(e,t)=>U.$mh({try:()=>rh.promises.readdir(e,t),catch:t=>tH("FileSystem","readDirectory")(t,[e])}),rU=e=>U.E2r((t,r)=>{try{rh.readFile(e,{signal:r},(r,n)=>{r?t(U.fJG(tH("FileSystem","readFile")(r,[e]))):t(U.PyW(n))})}catch(e){t(U.fJG(ry("readFile")(e)))}}),rF=(_=(0,U._r7)(rh.readlink,tH("FileSystem","readLink"),ry("readLink")),e=>_(e)),rR=(k=(0,U._r7)(rh.realpath,tH("FileSystem","realPath"),ry("realPath")),e=>k(e)),rL=(S=(0,U._r7)(rh.rename,tH("FileSystem","rename"),ry("rename")),(e,t)=>S(e,t)),rB=e=>({type:e.isFile()?"File":e.isDirectory()?"Directory":e.isSymbolicLink()?"SymbolicLink":e.isBlockDevice()?"BlockDevice":e.isCharacterDevice()?"CharacterDevice":e.isFIFO()?"FIFO":e.isSocket()?"Socket":"Unknown",mtime:K.fromNullishOr(e.mtime),atime:K.fromNullishOr(e.atime),birthtime:K.fromNullishOr(e.birthtime),dev:e.dev,rdev:K.fromNullishOr(e.rdev),ino:K.fromNullishOr(e.ino),mode:e.mode,nlink:K.fromNullishOr(e.nlink),uid:K.fromNullishOr(e.uid),gid:K.fromNullishOr(e.gid),size:tw(e.size),blksize:void 0!==e.blksize?K.some(tw(e.blksize)):K.none(),blocks:K.fromNullishOr(e.blocks)}),rY=(O=(0,U._r7)(rh.stat,tH("FileSystem","stat"),ry("stat")),e=>U.TjK(O(e),rB)),rq=(E=(0,U._r7)(rh.symlink,tH("FileSystem","symlink"),ry("symlink")),(e,t)=>E(e,t)),rX=($=(0,U._r7)(rh.truncate,tH("FileSystem","truncate"),ry("truncate")),(e,t)=>$(e,void 0!==t?Number(t):void 0)),rW=(I=(0,U._r7)(rh.utimes,tH("FileSystem","utime"),ry("utime")),(e,t,r)=>I(e,t,r)),rJ=(e,t,r)=>U.E2r((n,i)=>{try{rh.writeFile(e,t,{signal:i,flag:r?.flag,mode:r?.mode},t=>{t?n(U.fJG(tH("FileSystem","writeFile")(t,[e]))):n(U.rIH)})}catch(e){n(U.fJG(ry("writeFile")(e)))}}),rz=U.TjK(U.Nav(tS),e=>{let t;return t={access:rb,chmod:rx,chown:r_,copy:rv,copyFile:rw,glob:rk,link:rS,makeDirectory:rO,makeTempDirectory:r$,makeTempDirectoryScoped:rC,makeTempFile:rP,makeTempFileScoped:rj,open:rT,readDirectory:rD,readFile:rU,readLink:rF,realPath:rR,remove:rA,rename:rL,stat:rY,symlink:rq,truncate:rX,utimes:rW,watch:t=>rY(t).pipe(U.TjK(r=>e.pipe(K.flatMap(e=>e.register(t,r)),K.getOrElse(()=>{var e;let r;return to((r=e=>U.Q56(U.OH5(()=>{let r=rh.watch(t,{recursive:!0},(t,r)=>{if(r)switch(t){case"rename":return void U.MY7(U.tvg(rY(r),{onSuccess:t=>eb(e,{_tag:"Create",path:r}),onFailure:t=>eb(e,{_tag:"Remove",path:r})}));case"change":return void ev(e,{_tag:"Update",path:r})}});return r.on("error",r=>{ex(e,D.fJ(en({module:"FileSystem",_tag:"Unknown",method:"watch",pathOrDescriptor:t,cause:r})))}),r.on("close",()=>{e_(e)}),r}),e=>U.OH5(()=>e.close())),eX((t,n)=>U.TjK(ey({capacity:e?.bufferSize,strategy:e?.strategy}).pipe(U.Mim(e=>eL.U9(n,ek(e))),U.Mim(e=>U.ar0(eL.Gt(r(e),n),n))),eS))))}))),tf),writeFile:rJ},tx.of({...t,[tv]:tv,exists:e=>(0,R.Fs)(t.access(e),U.as(!0),U.KuX("PlatformError",e=>"NotFound"===e.reason._tag?U.PyW(!1):U.fJG(e))),readFileString:(e,r)=>U.qIB(t.readFile(e),e=>U.SvU({try:()=>new TextDecoder(r).decode(e),catch:e=>ei({module:"FileSystem",method:"readFileString",description:"invalid encoding",cause:e})})),stream:U.D9k(function*(e,r){let n=yield*t.open(e,{flag:"r"});r?.offset&&(yield*n.seek(r.offset,"start"));let i=r?.bytesToRead!==void 0?tw(r.bytesToRead):void 0,a=BigInt(0),s=tw(r?.chunkSize??65536),o=n.readAlloc(s);return to(eJ(U.PyW(U.qIB(U.DYE(()=>void 0!==i&&i<=a?D.Vw():void 0!==i&&i-a<s?n.readAlloc(i-a):o),K.match({onNone:()=>D.Vw(),onSome:e=>(a+=BigInt(e.length),U.PyW(z.of(e)))})))))},tf),sink:(e,r)=>(0,R.Fs)(t.open(e,{flag:"w",...r}),U.TjK(e=>{let t,r;return t=t=>e.writeAll(t),r=U.jJl(e=>t(e),{discard:!0}),tt(e=>e.pipe(U.qIB(r),U.i4r({disableYield:!0}),eo.m8(()=>e4)))}),ti),writeFileString:(e,r,n)=>U.qIB(U.SvU({try:()=>new TextEncoder().encode(r),catch:e=>ei({module:"FileSystem",method:"writeFileString",description:"could not encode string",cause:e})}),r=>t.writeFile(e,r,n))})}),rK=W.QZ(tx)(rz),rV=t("node:url"),rG=e=>U.SvU({try:()=>rV.fileURLToPath(e),catch:e=>new ee({module:"Path",method:"fromFileUrl",cause:e})}),rH=e=>U.SvU({try:()=>rV.pathToFileURL(e),catch:e=>new ee({module:"Path",method:"toFileUrl",cause:e})});rm.posix,rm.win32;let rQ=W.Py(tE)({[tO]:tO,...rg,fromFileUrl:rG,toFileUrl:rH}),rZ="~effect/Stdio",r0=H.kl(rZ),r1=W.Py(r0,{[rZ]:rZ,...{args:U.OH5(()=>process.argv.slice(2)),stdout:e=>tQ({evaluate:()=>process.stdout,onError:e=>en({module:"Stdio",method:"stdout",_tag:"Unknown",cause:e}),endOnDone:e?.endOnDone??!1}),stderr:e=>tQ({evaluate:()=>process.stderr,onError:e=>en({module:"Stdio",method:"stderr",_tag:"Unknown",cause:e}),endOnDone:e?.endOnDone??!1}),stdin:t8({evaluate:()=>process.stdin,onError:e=>en({module:"Stdio",method:"stdin",_tag:"Unknown",cause:e}),closeOnDone:!1})}});var r2=n(2302);class r3{waiters=new Set;taken=0;permits;constructor(e){this.permits=e}get free(){return this.permits-this.taken}take(e){let t=ec.DYE(()=>this.free<e?ec.E2r(r=>{if(this.free>=e)return r(t);let n=()=>{this.free<e||(this.waiters.delete(n),r(t))};return this.waiters.add(n),ec.OH5(()=>{this.waiters.delete(n)})}):(this.taken+=e,ec.PyW(e)));return t}updateTakenUnsafe(e,t){return this.taken=t(this.taken),this.waiters.size>0&&e.currentDispatcher.scheduleTask(()=>{let e=this.waiters.values(),t=e.next();for(;!1===t.done&&this.free>0;)t.value(),t=e.next()},0),this.free}updateTaken(e){return el.R6(t=>ec.PyW(this.updateTakenUnsafe(t,e)))}resize(e){return el.R6(t=>(this.permits=e,this.free<0||this.updateTakenUnsafe(t,e=>e),ec.rIH))}release(e){return this.updateTaken(t=>t-e)}get releaseAll(){return this.updateTaken(e=>0)}withPermits(e){return t=>ec.FcF(r=>ec.qIB(r(this.take(e)),e=>ec.r7h(r(t),()=>{this.updateTakenUnsafe(ec.Iku(),t=>t-e)},!0)))}withPermit=this.withPermits(1);withPermitsIfAvailable(e){return t=>ec.FcF(r=>this.free<e?ec.lwU:(this.taken+=e,ec.r7h(r(ec.Xx$(t)),()=>{this.updateTakenUnsafe(ec.Iku(),t=>t-e)},!0)))}}let r5={_tag:"Empty"},r6={_tag:"Closed"},r8={_A:R.D_,_E:R.D_};class r4{"~effect/RcRef"=r8;pipe(){return(0,ea.tT)(this,arguments)}state=r5;semaphore=(e=>new r3(e))(1);acquire;context;scope;idleTimeToLive;constructor(e,t,r,n){this.acquire=e,this.context=t,this.scope=r,this.idleTimeToLive=n}}let r9=U.D9k(function*(e){let t=yield*U.FcF(t=>{switch(e.state._tag){case"Closed":return U.GaK;case"Acquired":return e.state.refCount++,e.state.fiber?U.as(t1(e.state.fiber),e.state):U.PyW(e.state);case"Empty":{let r=eL.LZ();return e.semaphore.withPermits(1)(t(U.PpN(e.acquire,H.WQ(e.context,eL.HG,r))).pipe(U.TjK(t=>{let n={_tag:"Acquired",value:t,scope:r,fiber:void 0,refCount:1,invalidated:!1};return e.state=n,n})))}}}),r=yield*U.z8E,n=void 0!==e.idleTimeToLive&&r2.MI(e.idleTimeToLive);return yield*eL.a6(r,()=>(t.refCount--,t.refCount>0)?U.rIH:void 0===e.idleTimeToLive?(e.state=r5,eL.VN(t.scope,F.rI)):t.invalidated?eL.VN(t.scope,F.rI):n?(t.fiber=U.yy4(e.idleTimeToLive).pipe(U.qIB(()=>"Acquired"===e.state._tag&&0===e.state.refCount?(e.state=r5,eL.VN(t.scope,F.rI)):U.rIH),U.yeE(U.OH5(()=>{t.fiber=void 0})),U.eJC(e.context),t2(e.scope)),U.rIH):U.rIH),t.value});var r7=n(8861);let ne="~effect/platform/Terminal",nt="effect/platform/Terminal/QuitError";class nr extends r7.PSP("QuitError")({_tag:r7.TcI("QuitError")}){[nt]=nt}let nn=H.kl("effect/platform/Terminal"),ni=t("node:readline"),na=U.D9k(function*(e=no){let t,r,n=process.stdin,i=process.stdout,a=yield*(t={acquire:U.Q56(U.OH5(()=>{let e=ni.createInterface({input:n,escapeCodeTimeout:50});return ni.emitKeypressEvents(n,e),n.isTTY&&n.setRawMode(!0),e}),e=>U.OH5(()=>{n.isTTY&&n.setRawMode(!1),e.close()}))},U.R6R(e=>{let r=e.context,n=H.Jt(r,eL.HG),i=new r4(t.acquire,r,n,t.idleTimeToLive?r2.bN(t.idleTimeToLive):void 0);return U.as(eL.a6(n,()=>{let e="Acquired"===i.state._tag?eL.VN(i.state.scope,F.rI):U.rIH;return i.state=r6,e}),i)})),s=U.OH5(()=>i.columns??0),o=U.OH5(()=>i.rows??0),l=U.JkU(function*(){yield*r9(a);let t=yield*ey(),r=(r,n)=>{let i={input:K.fromUndefinedOr(r),key:{name:n.name??"",ctrl:!!n.ctrl,meta:!!n.meta,shift:!!n.shift}};ev(t,i),e(i)&&e_(t)};return yield*U.U9h(()=>U.OH5(()=>n.off("keypress",r))),n.on("keypress",r),t});return r={columns:s,rows:o,readInput:l,readLine:U.P1j(U.qIB(r9(a),e=>U.E2r(t=>{let r=e=>t(U.PyW(e));return e.once("line",r),U.OH5(()=>e.off("line",r))}))),display:e=>U.rfi(U.E2r(t=>{i.write(e,e=>es.uy(e)?t(U.rIH):t(U.fJG(ei({module:"Terminal",method:"display",description:"Failed to write prompt to stdout",cause:e}))))}))},nn.of({...r,[ne]:ne})}),ns=W.QZ(nn,na(no));function no(e){return e.key.ctrl&&("c"===e.key.name||"d"===e.key.name)}let nl=W.S5(rn,W.Um(rK,rf,rQ,r1,ns));var nc=n(7068),nu=n(6030);class nd extends r7.X0d()("CliFilesystemError",{cause:r7.kld(),operation:r7.QfV,path:r7.QfV,message:r7.QfV}){}class nf extends r7.X0d()("CliInputError",{code:r7.xCb(["input_read_failed","invalid_json","interactive_stdin"]),message:r7.QfV,hint:r7.QfV}){}class nh extends r7.X0d()("CliValidationError",{message:r7.QfV,hint:r7.QfV,details:r7.O31(r7.QfV)}){}class np extends r7.X0d()("CliBuildError",{status:r7.QfV,message:r7.QfV,hint:r7.QfV,details:r7.O31(r7.QfV)}){}class nm extends r7.X0d()("CliGenerationError",{code:r7.xCb(["provider_failure","generation_timeout","malformed_output","invalid_generated_document"]),message:r7.QfV,hint:r7.QfV,details:r7.O31(r7.QfV)}){}class ng extends r7.X0d()("CliStorageError",{code:r7.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:r7.Qrq(r7.QfV),message:r7.QfV,hint:r7.QfV}){}class ny extends r7.X0d()("CliShareError",{code:r7.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:r7.QfV,hint:r7.QfV,details:r7.O31(r7.QfV)}){}class nb extends r7.X0d()("CliExportError",{code:r7.xCb(["format_unavailable","invalid_destination","render_failed","export_write_failed"]),format:r7.QfV,message:r7.QfV,hint:r7.QfV}){}function nv(e){return"string"==typeof e||"number"==typeof e||"symbol"==typeof e}let nw=nu.ID(),nx=r7._Re(nc.Ky,{errors:"all"}),n_=r7._Re(nc.e5,{errors:"all"});function nk(e){return nh.make({message:"The canonical diagram document is invalid.",hint:'Use {"type":"flowchart","spec":...} or {"type":"mindmap","spec":...}.',details:e})}function nS(e){return nw(e).issues.map(e=>{var t;let r=(e.path??[]).flatMap(e=>{let t=nv(e)?e:null!==e&&"object"==typeof e&&"key"in e&&nv(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}`})}let nO=U.fn("sketchi.cli.document.decodeCanonical")(function*(e){let t=function(e){if(!("object"!=typeof e||null===e||Array.isArray(e))&&"type"in e&&"spec"in e)return{type:e.type,spec:e.spec}}(e);return t?"flowchart"===t.type?{type:"flowchart",spec:yield*nx(t.spec).pipe(U.xm_(e=>nk(nS(e.issue))))}:"mindmap"===t.type?{type:"mindmap",spec:yield*n_(t.spec).pipe(U.xm_(e=>nk(nS(e.issue))))}:yield*nk(['document.type: Expected "flowchart" or "mindmap".']):yield*nk(["document: Expected an object with type and spec."])}),nE=U.fn("sketchi.cli.document.parseJson")(function*(e){let t=yield*U.SvU({try:()=>JSON.parse(e),catch:()=>nf.make({code:"invalid_json",message:"The input is not valid JSON.",hint:"Pass one complete canonical document object."})});return yield*nO(t)});function n$(e){return`${JSON.stringify(e,null,2)}
|
|
3
|
-
`}function nI(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 nA(e){return/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}$/.test(e)?U.PyW(e):U.fJG(nh.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 nC extends H.kl()("@sketchi/cli/DiagramBuilder"){}function nT(e){let t=e.ref?.path?` (${e.ref.path})`:"";return`${e.code}${t}: ${e.message}`}function nN(e,t){let r=e.formats.find(e=>e.format===t);return r?.inline!==void 0?U.PyW(r.inline):U.fJG(np.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 nM(e){let t=nc.Uh.safeParse(e);return t.success?U.PyW(t.data):U.fJG(np.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 nP(e){let t=nc.yE.safeParse(e);return t.success?U.PyW(t.data):U.fJG(np.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 nj=W.QZ(nC,U.JkU(function*(){let e=yield*nc.Ov,t=yield*nc.UA;return{build:U.fn("sketchi.cli.diagram.build")(function*(r){let n;if(!(n="flowchart"===r.type?yield*(0,nc.XV)({spec:r.spec,options:{artifactFormats:["scene","excalidraw"],inlineArtifacts:["scene","excalidraw"]}}).pipe(U.PfK(nc.Ov,e),U.PfK(nc.UA,t)):yield*(0,nc.r8)({spec:r.spec,options:{artifactFormats:["scene","excalidraw"],inlineArtifacts:["scene","excalidraw"]}}).pipe(U.PfK(nc.Ov,e),U.PfK(nc.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(nT),"invalid_input"===n.status||"invalid_flowchart"===n.status||"invalid_mindmap"===n.status||"quality_failed"===n.status?nh.make({message:t,hint:r,details:i}):"storage_failed"===n.status?ng.make({code:"storage_commit_failed",message:t,hint:r}):np.make({status:n.status,message:t,hint:r,details:i}))}let i=yield*nA(nI(r)),a=yield*nN(n.artifact,"scene").pipe(U.qIB(nM)),s=yield*nN(n.artifact,"excalidraw").pipe(U.qIB(nP));return{id:i,type:r.type,title:r.spec.title,document:r,scene:a,excalidraw:s}})}})),nD=1,nU="manifest.json",nF="document.json",nR="scene.json",nL="diagram.excalidraw",nB="diagram.png",nY="revisions";class nq extends r7.Xsx("DiagramRecordManifest")({schemaVersion:r7.uSQ(nD),id:r7.QfV,type:r7.xCb(["flowchart","mindmap"]),title:r7.QfV,revision:r7.Aiz.check(r7.yJO(0)),authority:r7.xCb(["canonical","patched","detached"]).pipe(r7.E$i(U.PyW("canonical"))),formats:r7.O31(r7.xCb(["scene","excalidraw","png"]))}){}function nX(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 nW(e){return String(e).padStart(6,"0")}class nJ extends r7.X0d()("HeadlessPngRenderError",{cause:r7.kld(),message:r7.QfV}){}class nz extends H.kl()("@sketchi/cli/CliPngRenderer"){}let nK=W.Py(nz,{renderPng:function(e){return U.$mh({try:async()=>(await Promise.all([n.e(831),n.e(869)]).then(n.bind(n,7665))).renderPngBytes(e),catch:e=>nJ.make({cause:e,message:"Unable to render the stored Excalidraw artifact as PNG."})})},normalizeExcalidraw:function(e){return U.$mh({try:async()=>(await Promise.all([n.e(831),n.e(869)]).then(n.bind(n,7665))).normalizeExcalidrawArtifact(e),catch:e=>nJ.make({cause:e,message:"Unable to restore the Excalidraw share artifact."})})}}),nV=t("node:zlib");var nG=n(3587);let nH=t("node:fs/promises");class nQ extends H.kl()("@sketchi/cli/LocalFileSystem"){}function nZ(e,t,r){return nd.make({cause:r,operation:e,path:t,message:`Filesystem ${e} failed for ${t}.`})}function n0(e,t){return"object"==typeof e&&null!==e&&"code"in e&&e.code===t}let n1=W.Py(nQ,{makeDirectory:(e,t=!1)=>U.$mh({try:()=>(0,nH.mkdir)(e,{recursive:t}).then(()=>void 0),catch:t=>nZ("make-directory",e,t)}),tryWriteText:(e,t)=>U.$mh({try:async()=>{try{let r=await (0,nH.open)(e,rh.constants.O_WRONLY|rh.constants.O_CREAT|rh.constants.O_EXCL|rh.constants.O_NOFOLLOW,384);try{await r.writeFile(t,{encoding:"utf8"}),await r.sync()}finally{await r.close()}return!0}catch(e){if(n0(e,"EEXIST"))return!1;throw e}},catch:t=>nZ("write-exclusive",e,t)}),tryLinkFile:(e,t)=>U.$mh({try:async()=>{try{return await (0,nH.link)(e,t),!0}catch(e){if(n0(e,"EEXIST")||n0(e,"ENOENT"))return!1;throw e}},catch:r=>nZ("link-exclusive",`${e} -> ${t}`,r)}),makeTempDirectory:(e,t)=>U.$mh({try:()=>(0,nH.mkdtemp)((0,rm.join)(e,t)),catch:t=>nZ("make-temp-directory",e,t)}),list:e=>U.$mh({try:async()=>(await (0,nH.readdir)(e,{withFileTypes:!0})).map(e=>({name:e.name,kind:e.isFile()?"file":e.isDirectory()?"directory":e.isSymbolicLink()?"symbolic-link":"other"})),catch:t=>nZ("read-directory",e,t)}),kind:e=>U.$mh({try:async()=>{try{let t=await (0,nH.lstat)(e);if(t.isFile())return"file";if(t.isDirectory())return"directory";if(t.isSymbolicLink())return"symbolic-link";return"other"}catch(e){if(n0(e,"ENOENT"))return"missing";if(n0(e,"ELOOP"))return"symbolic-link";throw e}},catch:t=>nZ("stat",e,t)}),realPath:e=>U.$mh({try:()=>(0,nH.realpath)(e),catch:t=>nZ("resolve",e,t)}),readText:e=>U.$mh({try:async()=>{let t=await (0,nH.open)(e,rh.constants.O_RDONLY|rh.constants.O_NOFOLLOW);try{return await t.readFile({encoding:"utf8"})}finally{await t.close()}},catch:t=>nZ("read",e,t)}),readBytes:e=>U.$mh({try:async()=>{let t=await (0,nH.open)(e,rh.constants.O_RDONLY|rh.constants.O_NOFOLLOW);try{return new Uint8Array(await t.readFile())}finally{await t.close()}},catch:t=>nZ("read",e,t)}),writeText:(e,t,r=!1)=>U.$mh({try:async()=>{let n=rh.constants.O_WRONLY|rh.constants.O_CREAT|rh.constants.O_NOFOLLOW|(r?rh.constants.O_TRUNC:rh.constants.O_EXCL),i=await (0,nH.open)(e,n,384);try{await i.writeFile(t,{encoding:"utf8"}),await i.sync()}finally{await i.close()}},catch:t=>nZ("write",e,t)}),writeBytes:(e,t,r=!1)=>U.$mh({try:async()=>{let n=rh.constants.O_WRONLY|rh.constants.O_CREAT|rh.constants.O_NOFOLLOW|(r?rh.constants.O_TRUNC:rh.constants.O_EXCL),i=await (0,nH.open)(e,n,384);try{await i.writeFile(t),await i.sync()}finally{await i.close()}},catch:t=>nZ("write",e,t)}),rename:(e,t)=>U.$mh({try:()=>(0,nH.rename)(e,t),catch:r=>nZ("rename",`${e} -> ${t}`,r)}),tryRenameDirectory:(e,t)=>U.$mh({try:async()=>{try{return await (0,nH.rename)(e,t),!0}catch(e){if(n0(e,"EEXIST")||n0(e,"ENOTEMPTY"))return!1;if(n0(e,"EPERM"))try{if((await (0,nH.lstat)(t)).isDirectory())return!1}catch{}throw e}},catch:r=>nZ("rename-exclusive-directory",`${e} -> ${t}`,r)}),removeFile:e=>U.$mh({try:async()=>{try{return await (0,nH.unlink)(e),!0}catch(e){if(n0(e,"ENOENT"))return!1;throw e}},catch:t=>nZ("remove-file",e,t)}),remove:e=>U.$mh({try:()=>(0,nH.rm)(e,{recursive:!0,force:!0}),catch:t=>nZ("remove",e,t)})});var n2=n(8689),n3=n(5030);let n5="https://json.excalidraw.com/api/v2/",n6=["rectangle","ellipse","diamond","arrow","line","freedraw","text"],n8=new Set(n6),n4=new TextEncoder,n9=new TextDecoder("utf-8",{fatal:!0}),n7=n4.encode(JSON.stringify({version:2,compression:"pako@1",encryption:"AES-GCM"}));function ie(e,t,r,n=[]){return ny.make({code:e,message:t,hint:r,details:n})}function it(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function ir(e){return"number"==typeof e&&Number.isFinite(e)}function ii(e,t,r){new DataView(e.buffer,e.byteOffset,e.byteLength).setUint32(t,r)}function ia(e,t){if(t+4>e.byteLength)throw Error("truncated chunk header");return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint32(t)}function is(e,t){if(e.byteLength<4+4*t||1!==ia(e,0))throw Error("unsupported chunk format");let r=[],n=4;for(let i=0;i<t;i+=1){let t=ia(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 io(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 il(e,t){return crypto.subtle.importKey("raw",Uint8Array.from(io(e)),{name:"AES-GCM",length:128},!1,[t])}function ic(e){if(!it(e)||"excalidraw"!==e.type||!ir(e.version)||"string"!=typeof e.source||!Array.isArray(e.elements)||!it(e.appState)||!(void 0===e.files||it(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 iu(e,t){return"string"!=typeof e||!t.has(e)}function id(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=id(r,`${t} item`);if(e)return e}else if(it(e))for(let r of Object.values(e)){let e=id(r,`${t} property`);if(e)return e}}function ih(e){return U.SvU({try:()=>{let t=ic(e);if(it(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(!it(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(!it(e)||"string"!=typeof e.id||0===e.id.length||"string"!=typeof e.type)return`elements[${String(t)}] is not an Excalidraw element`;if(!n8.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=id(e,n);if(i)return i;for(let t of["x","y","width","height","angle"])if(!ir(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||!ir(e[0])||!ir(e[1]))))return`${n}.points contains invalid geometry`;for(let t of["containerId","frameId"])if(null!==e[t]&&void 0!==e[t]&&iu(e[t],r))return`${n}.${t} is an invalid element reference`;for(let t of["startBinding","endBinding"]){let i=e[t];if(null!=i&&(!it(i)||iu(i.elementId,r)))return`${n}.${t} is an invalid element binding`}let a=e.boundElements;if(null!=a&&(!Array.isArray(a)||a.some(e=>!it(e)||iu(e.id,r))))return`${n}.boundElements contains an invalid element reference`}(n,e,r);if(t)throw Error(t)}let n=(0,n3.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]&&!ir(e[t]))return`appState.${t} must be finite or null`;if("lockedMultiSelections"in e){let t=e.lockedMultiSelections;if(!it(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 id(e,"appState")}(t.appState);if(i)throw Error(i);return e},catch:e=>ie("unsupported_scene","The Excalidraw scene is unsupported by share/pull v1.",`Use only ${n6.join(", ")} elements, Excalifont fontFamily ${String(5)}, and no files or images.`,[e instanceof Error?e.message:"invalid scene"])})}function ip(e){let t=new Uint8Array(4);return ii(t,0,e),t}class im extends H.kl()("@sketchi/cli/StorageRoot"){}function ig(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}let iy=[[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 ib(e,t,r){return e<=t?0:Math.ceil((e-t)/r)}function iv(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,c=!1,u=!1,d=!1,f=[];for(;o+12<=e.byteLength;){let s=ig(e,o),h=o+12+s;if(h>e.byteLength)break;let p=o+4,m=e.subarray(p,p+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=ig(e,o+8),r=ig(e,o+12),i=e[o+16],n=e[o+17],a=e[o+20];let c={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||!c[n]?.includes(i)||0!==e[o+18]||0!==e[o+19]||![0,1].includes(a??-1))break}else if("PLTE"===y){if(c||u||0===s||s%3!=0||s>768||0===n||4===n||3===n&&void 0!==i&&s/3>2**i)return!1;c=!0}else if("IDAT"===y){if(d||3===n&&!c)return!1;u=!0,f.push(e.subarray(o+8,o+8+s))}else if("IEND"===y){if(0!==s||!u||3===n&&!c)break}else{u&&(d=!0);let t=e[p];if(void 0===t||(32&t)==0)break}let b=ig(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(p,o+8+s))!==b)break;if(o=h,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,c]of 0===n?[[0,0,1,1]]:iy){let n=ib(e,s,l),u=ib(t,o,c);if(0===n||0===u)continue;let d=Math.ceil(n*r/8)+1;if(d>0x1000000-a||u>Math.floor((0x1000000-a)/d))return null;a+=u*d,i.push({rows:u,rowBytes:d})}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,nV.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 iw extends H.kl()("@sketchi/cli/DiagramStore"){}let ix=".locks",i_="free.",ik="owner.",iS=".owner-candidate.",iO=".json",iE="recovery",i$=".backup.",iI=`.stage.${String(process.pid)}.`,iA=nG.ji("10 millis").pipe(nG.jB({times:50})),iC=W.Py(im,{path:(0,rm.join)((0,rp.homedir)(),".sketchi","diagrams")});function iT(e,t,r,n){return ng.make({code:e,message:t,hint:r,...n?{diagramId:n}:{}})}function iN(e){return Buffer.from(e,"utf8").toString("base64url")}function iM(e,t){return e<t?-1:+(e>t)}function iP(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:iM(r,n)||iM(e,t)}function ij(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 iD(e,t){return"object"==typeof e.cause&&null!==e.cause&&"code"in e.cause&&e.cause.code===t}function iU(e,t){return(0,rm.join)(e,t)}function iF(e){switch(e){case"scene":return nR;case"excalidraw":return nL;case"png":return nB}}function iR(e,t){return iT("unsafe_storage_entry",`Unsafe local storage entry at ${e}.`,"Replace symbolic links or special files with ordinary Sketchi record files.",t)}let iL=W.QZ(iw,U.JkU(function*(){let e=yield*nQ,t=yield*im,r=U.fn("sketchi.cli.storage.ensureOwnedDirectory")(function*(t){let r=yield*e.kind(t);if("missing"===r&&(yield*e.makeDirectory(t).pipe(U.MfU(e=>iD(e,"EEXIST")?U.rIH:U.fJG(e))),r=yield*e.kind(t)),"directory"!==r)return yield*iR(t)}),n=U.fn("sketchi.cli.storage.ensureRoot")(function*(){yield*r((0,rm.dirname)(t.path)),yield*r(t.path),yield*r((0,rm.join)(t.path,ix))}),i=U.fn("sketchi.cli.storage.assertSafeTree")(function*(t,r){for(let n of yield*e.list(t)){let e=(0,rm.join)(t,n.name);if("symbolic-link"===n.kind||"other"===n.kind)return yield*iR(e,r);"directory"===n.kind&&(yield*i(e,r))}}),a=U.fn("sketchi.cli.storage.recoverStages")(function*(){for(let r of(yield*n(),[...yield*e.list(t.path)].sort((e,t)=>iM(e.name,t.name)))){if(!r.name.startsWith(".stage."))continue;let n=function(e){let t=Number(e.split(".").at(-2));return Number.isSafeInteger(t)?t:void 0}(r.name);void 0!==n&&ij(n)||(yield*e.remove((0,rm.join)(t.path,r.name)))}}),s=U.fn("sketchi.cli.storage.recoverRecordTransactions")(function*(r){yield*n(),yield*a();let i=`${i$}${iN(r)}.`;for(let n of[...yield*e.list(t.path)].filter(e=>e.name.startsWith(i)).sort((e,t)=>iM(e.name,t.name))){let i=(0,rm.join)(t.path,n.name),a=iU(t.path,r);"missing"===(yield*e.kind(a))?yield*e.rename(i,a):yield*e.remove(i)}}),o=U.fn("sketchi.cli.storage.initializeLockDirectory")(function*(r){let n=(0,rm.join)(t.path,ix,`${iN(r)}.lock`),i=yield*e.kind(n);if("directory"===i)return n;if("missing"!==i)return yield*iR(n,r);let a=(0,rm.join)(t.path,ix);return yield*U.jGc(e.makeTempDirectory(a,`.init.${iN(r)}.`),t=>U.JkU(function*(){let i=crypto.randomUUID();return(yield*e.writeText((0,rm.join)(t,`${i_}${i}${iO}`),n$({token:i})),(yield*e.tryRenameDirectory(t,n))||"directory"===(yield*e.kind(n)))?n:yield*iR(n,r)}),t=>e.remove(t))}),l=e=>iT("diagram_busy",`Diagram "${e}" is being changed by another Sketchi process.`,"Wait for that command to finish, then retry.",e),c=U.fn("sketchi.cli.storage.readLockEntries")(function*(t,r){let n=[...yield*e.list(t)].sort((e,t)=>iM(e.name,t.name)),i=[];for(let a of n){let n=(0,rm.join)(t,a.name);if("file"!==a.kind)return yield*iR(n,r);let s=function(e){if(!e.startsWith(i_)||!e.endsWith(iO))return;let t=e.slice(i_.length,-iO.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(i_))return yield*iR(n,r);let o=function(e){if(!e.startsWith(iS)||!e.endsWith(iO))return;let t=e.slice(iS.length,-iO.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(iS)||!a.name.startsWith(ik)||!a.name.endsWith(iO))return yield*iR(n,r);let c=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(U.xm_(e=>iD(e,"ENOENT")?l(r):e))));if(!c)return yield*l(r);if(a.name!==`${ik}${c.token}${iO}`)return yield*iR(n,r);i.push({name:a.name,path:n,token:c.token,state:ij(c.pid)?"live-owner":"stale-owner"})}return i}),u=U.fn("sketchi.cli.storage.acquireLockOnce")(function*(t){yield*n();let r=yield*o(t),i=yield*c(r,t),a=new Set(i.flatMap(e=>e.releasedOwnerToken?[e.releasedOwnerToken]:[]));if(i.some(e=>"live-owner"===e.state&&!a.has(e.token)))return yield*l(t);let s=i.find(e=>"free"===e.state)??i.find(e=>"stale-owner"===e.state);if(!s){let n=(0,rm.join)(r,`${i_}${iE}${iO}`);if(!(yield*e.tryWriteText(n,n$({token:iE}))))return yield*l(t);s={name:`${i_}${iE}${iO}`,path:n,state:"free",token:iE}}let u=crypto.randomUUID(),d=(0,rm.join)(r,`${ik}${u}${iO}`),f=(0,rm.join)(r,`${iS}${u}${iO}`);return yield*U.rfi(U.jGc(U.PyW(f),()=>U.JkU(function*(){if(yield*e.writeText(f,n$({pid:process.pid,token:u})),!(yield*e.tryLinkFile(f,d)))return yield*l(t);if(!(yield*e.removeFile(s.path).pipe(U.MfU(t=>e.removeFile(d).pipe(U.hgn(U.fJG(t)))))))return yield*e.removeFile(d),yield*l(t);for(let t of i)t.path!==s.path&&(yield*e.removeFile(t.path).pipe(U.MfU(()=>U.rIH)));return{directory:r,ownerPath:d,token:u}}),t=>e.removeFile(t).pipe(U.MfU(()=>U.rIH))))}),d=U.fn("sketchi.cli.storage.releaseLock")(function*(t,r){let n=crypto.randomUUID(),i=(0,rm.join)(r.directory,`${i_}${n}.${r.token}${iO}`),a=n$({token:n,releasedOwnerToken:r.token});if(!(yield*e.writeText(i,a).pipe(U.as(!0),U.MfU(()=>e.tryWriteText(i,a).pipe(U.qIB(t=>t?U.PyW(!0):e.kind(i).pipe(U.TjK(e=>"file"===e))),U.MfU(()=>U.PyW(!1))))))){if(yield*e.removeFile(r.ownerPath))return;return yield*iT("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(U.YWq({onFailure:()=>!0,onSuccess:e=>e}))))return yield*e.removeFile(i).pipe(U.MfU(()=>U.rIH)),yield*iT("storage_commit_failed",`Diagram "${t}" lock ownership changed before release.`,"Retry after the active Sketchi command finishes.",t)}),f=(e,t,r=!1)=>{let n;return U.jGc((n=u(e),r?n.pipe(U.L5P({schedule:iA,while:e=>"CliStorageError"===e._tag&&"diagram_busy"===e.code})):n),()=>s(e).pipe(U.hgn(t)),t=>d(e,t).pipe(U.MfU(()=>U.rIH)))},h=U.fn("sketchi.cli.storage.decodeManifest")(function*(t,r){let n=yield*e.readText(t),i=yield*U.SvU({try:()=>JSON.parse(n),catch:()=>iT("corrupt_record",`Diagram "${r}" has an invalid manifest.`,"Inspect manifest.json and restore it from a known-good backup.",r)});return yield*r7._Re(nq)(i).pipe(U.xm_(()=>iT("corrupt_record",`Diagram "${r}" has an incompatible manifest.`,`Expected manifest schema version ${String(1)}.`,r)))}),p=U.fn("sketchi.cli.storage.decodeDocument")(function*(t,r){let n=yield*e.readText(t),i=yield*U.SvU({try:()=>JSON.parse(n),catch:()=>iT("corrupt_record",`Diagram "${r}" has invalid document JSON.`,"Recover a prior canonical document from the revisions directory.",r)});return yield*nO(i).pipe(U.xm_(()=>iT("corrupt_record",`Diagram "${r}" has an invalid canonical document.`,"Recover a prior canonical document from the revisions directory.",r)))}),m=U.fn("sketchi.cli.storage.loadUnlocked")(function*(r){let n=iU(t.path,r),a=yield*e.kind(n);if("missing"===a)return yield*iT("diagram_not_found",`Diagram "${r}" does not exist.`,"Run sketchi list to discover stored diagram ids.",r);if("directory"!==a)return yield*iR(n,r);yield*i(n,r);let s=yield*h((0,rm.join)(n,nU),r);if(s.id!==r)return yield*iT("corrupt_record",`Diagram directory "${r}" contains manifest id "${s.id}".`,"Make the directory name and manifest id agree before retrying.",r);let o=yield*p((0,rm.join)(n,nF),r);if(s.type!==o.type||s.title!==o.spec.title)return yield*iT("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[nR,nL])if((yield*e.kind((0,rm.join)(n,t)))!=="file")return yield*iT("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,rm.join)(n,nB));if("file"!==l&&"missing"!==l)return yield*iR((0,rm.join)(n,nB),r);if("file"===l&&!iv((yield*e.readBytes((0,rm.join)(n,nB)))))return yield*iT("corrupt_record",`Diagram "${r}" has an invalid stored PNG artifact.`,"Recover a valid prior revision or rebuild the record.",r);let c="detached"===s.authority?"file"===l?["excalidraw","png"]:["excalidraw"]:"file"===l?["scene","excalidraw","png"]:["scene","excalidraw"];if(s.formats.length!==c.length||s.formats.some((e,t)=>e!==c[t]))return yield*iT("corrupt_record",`Diagram "${r}" manifest formats do not match stored artifacts.`,"Recover the canonical document and rebuild the record with sketchi edit.",r);let u=(0,rm.join)(n,nY),d=[];for(let t of yield*e.list(u)){if("file"===t.kind&&/^\d{6,}\.json$/u.test(t.name)){d.push(t.name);continue}if("directory"===t.kind&&/^\d{6,}$/u.test(t.name)){d.push(`${t.name}/`);continue}return yield*iR((0,rm.join)(u,t.name),r)}return d.sort(iP),{manifest:s,document:o,revisions:d,authority:s.authority,documentAuthoritative:"canonical"===s.authority}}),g=U.fn("sketchi.cli.storage.copySafeTree")(function*(t,r,n){for(let i of yield*e.list(t)){let a=(0,rm.join)(t,i.name),s=(0,rm.join)(r,i.name);if("directory"===i.kind)yield*e.makeDirectory(s),yield*g(a,s,n);else{if("file"!==i.kind)return yield*iR(a,n);let t=yield*e.readBytes(a);yield*e.writeBytes(s,t)}}}),y=U.fn("sketchi.cli.storage.copyRecordSnapshot")(function*(t,r,n){for(let i of(yield*e.makeDirectory(r),yield*e.list(t))){if(i.name===nY)continue;let a=(0,rm.join)(t,i.name),s=(0,rm.join)(r,i.name);if("file"!==i.kind)return yield*iR(a,n);yield*e.writeBytes(s,(yield*e.readBytes(a)))}}),b=U.fn("sketchi.cli.storage.commitStage")(function*(r,n){let i=iU(t.path,r),a=(0,rm.join)(t.path,`${i$}${iN(r)}.${String(process.pid)}.${crypto.randomUUID()}`);yield*e.rename(i,a),(yield*e.rename(n,i).pipe(U.tvg({onFailure:t=>e.rename(a,i).pipe(U.tvg({onFailure:()=>U.fJG(iT("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:()=>U.fJG(t)})),onSuccess:()=>U.PyW(!0)})))&&(yield*e.remove(a).pipe(U.MfU(()=>U.rIH)))}),v=U.fn("sketchi.cli.storage.snapshotCurrent")(function*(r,n,i){let a=(0,rm.join)(n,nY,nW(i));if((yield*e.kind(a))!=="missing")return yield*iT("corrupt_record",`Diagram "${r}" already has a snapshot for current revision ${String(i)}.`,"Inspect the revisions directory before retrying.",r);yield*y(iU(t.path,r),a,r)}),w=U.fn("sketchi.cli.storage.writeBuilt")(function*(t,r,n){yield*e.makeDirectory((0,rm.join)(t,nY),!0),yield*e.writeText((0,rm.join)(t,nF),n$(r.document),!0),yield*e.writeText((0,rm.join)(t,nR),n$(r.scene),!0),yield*e.writeText((0,rm.join)(t,nL),n$(r.excalidraw),!0);let i=(0,rm.join)(t,nB);yield*e.remove(i),r.png&&(yield*e.writeBytes(i,r.png)),yield*e.writeText((0,rm.join)(t,nU),n$(n),!0)}),x=U.fn("sketchi.cli.storage.create")(function*(r){return yield*f(r.id,U.JkU(function*(){let n=iU(t.path,r.id);if((yield*e.kind(n))!=="missing")return yield*iT("diagram_already_exists",`Diagram "${r.id}" already exists.`,"Use sketchi edit for full-document replacement.",r.id);let i=nq.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*U.jGc(e.makeTempDirectory(t.path,iI),t=>U.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))}))}),_=U.fn("sketchi.cli.storage.edit")(function*(r,n){return yield*f(r,U.JkU(function*(){let i=yield*m(r);if("canonical"!==i.authority)return yield*iT("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*iT("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=iU(t.path,r),s=nq.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*U.jGc(e.makeTempDirectory(t.path,iI),e=>U.JkU(function*(){return yield*g(a,e,r),yield*v(r,e,i.manifest.revision),yield*w(e,n,s),yield*b(r,e),{manifest:s,document:n.document,revisions:[...i.revisions,`${nW(i.manifest.revision)}/`].sort(iP),authority:"canonical",documentAuthoritative:!0}}),t=>e.remove(t))}))}),k=e=>iT("patch_source_unavailable",`Diagram "${e}" has no current authoritative scene to patch.`,"Restore a canonical or patched revision before patching this diagram.",e),S=U.fn("sketchi.cli.storage.readPatchSourceUnlocked")(function*(r){let n=yield*m(r);if("detached"===n.authority||!n.manifest.formats.includes("scene"))return yield*k(r);let i=(0,rm.join)(iU(t.path,r),nR),a=yield*e.readText(i),s=yield*U.OH5(()=>{try{return nc.Uh.safeParse(JSON.parse(a))}catch{return}});return s?.success&&s.data.diagramId===r?{revision:n.manifest.revision,scene:s.data}:yield*iT("corrupt_record",`Diagram "${r}" has an invalid current scene artifact.`,"Restore a valid prior revision before patching this diagram.",r)}),O=U.fn("sketchi.cli.storage.readPatchSource")(e=>f(e,S(e),!0)),E=U.fn("sketchi.cli.storage.commitPatch")(function*(r,n,i){return yield*f(r,U.JkU(function*(){let a=yield*m(r);if(a.manifest.revision!==n)return yield*iT("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*k(r);if(i.scene.diagramId!==r)return yield*iT("storage_commit_failed",`Patched scene id "${i.scene.diagramId}" does not match "${r}".`,"Retry the patch against the named stored diagram.",r);let s=iU(t.path,r),o=nq.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*U.jGc(e.makeTempDirectory(t.path,iI),t=>U.JkU(function*(){return yield*g(s,t,r),yield*v(r,t,a.manifest.revision),yield*e.writeText((0,rm.join)(t,nR),n$(i.scene),!0),yield*e.writeText((0,rm.join)(t,nL),n$(i.excalidraw),!0),yield*e.remove((0,rm.join)(t,nB)),yield*e.writeText((0,rm.join)(t,nU),n$(o),!0),yield*b(r,t),{manifest:o,document:a.document,revisions:[...a.revisions,`${nW(a.manifest.revision)}/`].sort(iP),authority:"patched",documentAuthoritative:!1}}),t=>e.remove(t))}))}),$=(e,t)=>iT("corrupt_revision",`Diagram "${e}" revision ${String(t)} is corrupt.`,"Choose another revision or repair the corrupt snapshot.",e),I=U.fn("sketchi.cli.storage.validateArchivedJson")(function*(t,r,n){let i=yield*e.readText(t);return yield*U.SvU({try:()=>{let e=JSON.parse(i);if("object"!=typeof e||null===e)throw Error("archived JSON must contain an object");return e},catch:()=>$(r,n)})}),A=U.fn("sketchi.cli.storage.validateArchivedArtifact")(function*(e,t,r,n,i){let a=yield*I(e,n,i);if(!("scene"===t?nc.Uh.safeParse(a):nc.yE.safeParse(a)).success)return yield*$(n,i);"excalidraw"===t&&"detached"===r&&(yield*ih(a).pipe(U.xm_(()=>$(n,i))))}),C=U.fn("sketchi.cli.storage.validateArchivedPng")(function*(t,r,n){if(!iv((yield*e.readBytes(t))))return yield*$(r,n)}),T=U.fn("sketchi.cli.storage.readRevisionUnlocked")(function*(r,n){yield*m(r);let a=(0,rm.join)(iU(t.path,r),nY),s=(0,rm.join)(a,nW(n)),o=yield*e.kind(s);if("directory"===o){yield*i(s,r);let t=yield*h((0,rm.join)(s,nU),r).pipe(U.xm_(()=>$(r,n))),a=yield*p((0,rm.join)(s,nF),r).pipe(U.xm_(()=>$(r,n)));if(t.id!==r||t.revision!==n||t.type!==a.type||t.title!==a.spec.title)return yield*iT("corrupt_revision",`Diagram "${r}" revision ${String(n)} has inconsistent metadata.`,"Choose another revision or repair the corrupt snapshot.",r);for(let[i,a]of[[nR,"scene"],[nL,"excalidraw"]]){let o=(0,rm.join)(s,i);if((yield*e.kind(o))!=="file")return yield*iT("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(U.xm_(e=>"CliFilesystemError"===e._tag?$(r,n):e))}let o=yield*e.kind((0,rm.join)(s,nB));if("file"!==o&&"missing"!==o)return yield*iR((0,rm.join)(s,nB),r);"file"===o&&(yield*C((0,rm.join)(s,nB),r,n).pipe(U.xm_(e=>"CliFilesystemError"===e._tag?$(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*iT("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*iR(s,r);let l=(0,rm.join)(a,`${String(n).padStart(6,"0")}.json`),c=yield*e.kind(l);if("missing"===c)return yield*iT("revision_not_found",`Diagram "${r}" has no revision ${String(n)}.`,"Run sketchi show to inspect the available revision paths.",r);if("file"!==c)return yield*iR(l,r);let u=yield*p(l,r).pipe(U.xm_(e=>"CliStorageError"===e._tag?iT("corrupt_revision",`Diagram "${r}" revision ${String(n)} is corrupt.`,"Choose another revision or repair the legacy revision file.",r):e));return{_tag:"LegacyDocument",revision:n,document:u}}),N=U.fn("sketchi.cli.storage.replaceWithDetached")(function*(r,n,i){return yield*f(r,U.JkU(function*(){let a=yield*m(r);if(void 0!==i&&a.manifest.revision!==i)return yield*iT("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=iU(t.path,r),o=nq.make({schemaVersion:1,id:r,type:a.manifest.type,title:a.manifest.title,revision:a.manifest.revision+1,authority:"detached",formats:["excalidraw"]});return yield*U.jGc(e.makeTempDirectory(t.path,iI),t=>U.JkU(function*(){return yield*g(s,t,r),yield*v(r,t,a.manifest.revision),yield*e.writeBytes((0,rm.join)(t,nL),n,!0),yield*e.remove((0,rm.join)(t,nB)),yield*e.writeText((0,rm.join)(t,nU),n$(o),!0),yield*b(r,t),{manifest:o,document:a.document,revisions:[...a.revisions,`${nW(a.manifest.revision)}/`].sort(iP),authority:"detached",documentAuthoritative:!1}}),t=>e.remove(t))}))}),M=U.fn("sketchi.cli.storage.readRevision")((e,t)=>f(e,T(e,t),!0)),P=U.fn("sketchi.cli.storage.restore")(function*(r,n,i){return yield*f(r,U.JkU(function*(){let a=yield*m(r),s=yield*T(r,n);if("LegacyDocument"===s._tag){if("canonical"!==a.authority||!i)return yield*iT("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||n$(i.document)!==n$(s.document))return yield*iT("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=iU(t.path,r);return yield*U.jGc(e.makeTempDirectory(t.path,iI),t=>U.JkU(function*(){yield*g(o,t,r),yield*v(r,t,a.manifest.revision);let l=[...a.revisions,`${nW(a.manifest.revision)}/`].sort(iP),c=yield*"FullSnapshot"===s._tag?U.JkU(function*(){let i=(0,rm.join)(t,nY,nW(n));for(let r of yield*e.list(t))r.name!==nY&&(yield*e.remove((0,rm.join)(t,r.name)));yield*g(i,t,r);let s=(0,rm.join)(t,nU),o=yield*e.readText(s);yield*h(s,r);let c=yield*p((0,rm.join)(t,nF),r),u=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 c=t+1;for(;/\s/u.test(e[c]??"");)c+=1;if(":"!==e[c])continue;for(c+=1;/\s/u.test(e[c]??"");)c+=1;let u=/^-?\d+/u.exec(e.slice(c));if(!u)return;let d=c+u[0].length,f=d;for(;/\s/u.test(e[f]??"");)f+=1;if(","!==e[f]&&"}"!==e[f]||-1!==n)return;n=c,i=d}return -1===n?void 0:`${e.slice(0,n)}${String(t)}${e.slice(i)}`}(o,a.manifest.revision+1);if(void 0===u)return yield*$(r,n);yield*e.writeText(s,u,!0);let d=yield*h(s,r);return{manifest:d,document:c,revisions:l,authority:d.authority,documentAuthoritative:"canonical"===d.authority}}):U.JkU(function*(){if(!i)return yield*iT("storage_commit_failed",`Legacy revision ${String(n)} has no rebuilt document.`,"Rebuild the archived canonical document before restoring.",r);let e=nq.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*b(r,t),{diagram:c,restoredFromRevision:n}}),t=>e.remove(t))}))}),j=U.fn("sketchi.cli.storage.show")(e=>f(e,m(e),!0)),D=U.fn("sketchi.cli.storage.list")(function*(){yield*n(),yield*a();let r=new Set;for(let n of yield*e.list(t.path)){if("directory"===n.kind&&!n.name.startsWith(".")){r.add(n.name);continue}if(!n.name.startsWith(i$))continue;let e=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}}(n.name.split(".")[2]??"");e&&r.add(e)}let i=[];for(let e of[...r].sort(iM)){let t=yield*j(e);i.push(nX(t))}return i});return{create:x,edit:_,readPatchSource:O,commitPatch:E,replaceWithDetached:N,readRevision:M,restore:P,show:j,list:D,readExportSource:U.fn("sketchi.cli.storage.readExportSource")(function*(r,n){return yield*f(r,U.JkU(function*(){let i=yield*m(r);if(i.manifest.formats.includes(n))return{_tag:"StoredArtifact",bytes:yield*e.readBytes((0,rm.join)(iU(t.path,r),iF(n)))};if("png"!==n)return yield*nb.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,rm.join)(iU(t.path,r),iF("excalidraw")))};for(let e of["scene","excalidraw"])if(!i.manifest.formats.includes(e))return yield*nb.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*U.Q7R([e.readBytes((0,rm.join)(iU(t.path,r),iF("scene"))),e.readBytes((0,rm.join)(iU(t.path,r),iF("excalidraw")))]);return{_tag:"RenderPng",scene:a,excalidraw:s}}),!0)})}})),iB=U.fn("sketchi.cli.export.writeFile")(function*(e,t){let r=yield*nQ,n=yield*im,i=(0,rm.resolve)(e),a=(0,rm.dirname)(i),s=()=>nb.make({code:"export_write_failed",format:(0,rm.basename)(e),message:`Export destination directory does not exist: ${a}.`,hint:"Create the destination directory and retry."}),o=yield*r.realPath(a).pipe(U.xm_(s));if((yield*r.kind(o))!=="directory")return yield*s();let l=yield*r.realPath(n.path),c=(0,rm.join)(o,(0,rm.basename)(i)),u=(0,rm.relative)(l,c);if(""===u||!u.startsWith("..")&&!(0,rm.isAbsolute)(u))return yield*nb.make({code:"invalid_destination",format:(0,rm.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 d=(0,rm.join)(o,`.${(0,rm.basename)(e)}.sketchi.${String(process.pid)}.${crypto.randomUUID()}`);return yield*U.jGc(U.PyW(d),n=>r.writeBytes(n,t).pipe(U.hgn(r.rename(n,c)),U.xm_(()=>nb.make({code:"export_write_failed",format:(0,rm.basename)(e),message:`Unable to write export destination ${e}.`,hint:"Check the destination path and permissions, then retry."}))),e=>r.remove(e))});class iY extends H.kl()("@sketchi/cli/DiagramExporter"){}function iq(){return nb.make({code:"render_failed",format:"png",message:"Unable to render the stored diagram as PNG.",hint:"Verify the stored scene and Excalidraw artifacts, then retry."})}function iX(e){return U.SvU({try:()=>JSON.parse(new TextDecoder().decode(e)),catch:iq})}let iW=W.QZ(iY,U.JkU(function*(){let e=yield*iw,t=yield*nz,r=U.fn("sketchi.cli.export.renderPng")(function*(e){let r=yield*iX(e.excalidraw),n=nc.yE.safeParse(r);if(!n.success)return yield*iq();let i=e.scene?nc.Uh.safeParse((yield*iX(e.scene))):void 0;if(i&&!i.success)return yield*iq();let a=yield*t.renderPng({...i?.success?{scene:i.data}:{},excalidraw:n.data}).pipe(U.xm_(iq));return a instanceof Uint8Array?a:new Uint8Array(a)});return{exportArtifact:U.fn("sketchi.cli.export.artifact")(function*(t,n){let i=yield*e.readExportSource(t,n);return"StoredArtifact"===i._tag?i.bytes:yield*r(i)})}})),iJ="gemini-3.1-flash-lite",iz="https://playground.sketchi.app/api/v1/generate",iK="SKETCHI_GENERATE_ENDPOINT";function iV(){return nm.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 iG(){return nm.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 iH(){return nm.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 iQ=U.fn("sketchi.cli.generate.request")(function*(e){let t=yield*U.$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,type:e.type,model:e.model}),signal:t}),catch:()=>iV()}),r=yield*U.$mh({try:()=>t.text(),catch:()=>iV()});if(!t.ok)return yield*U.fJG(function(e,t){let r=function(e){try{let t=JSON.parse(e);return null!==t&&"object"==typeof t?t:{}}catch{return{}}}(t),n=r.issues?.[0],i=[`http_status:${String(e)}`];switch(r.status){case"generation_timeout":return nm.make({code:"generation_timeout",message:n?.message??"The generate API timed out.",hint:n?.hint??"Retry once; if it persists, try a shorter prompt.",details:i});case"malformed_output":return nm.make({code:"malformed_output",message:n?.message??"The generate API returned unreadable model output.",hint:n?.hint??"Retry once; if it persists, try another prompt.",details:i});case"invalid_input":case"invalid_generated_document":case"quality_failed":return nm.make({code:"invalid_generated_document",message:n?.message??"The generated diagram failed Sketchi validation.",hint:n?.hint??"Refine the prompt with concrete content, then retry.",details:i});default:return nm.make({code:"provider_failure",message:n?.message??`The Sketchi generate API responded with HTTP ${String(e)}.`,hint:n?.hint??"Retry once; if it persists, report the prompt without secrets.",details:i})}}(t.status,r));let n=function(e){let t;try{t=JSON.parse(e)}catch{return}if(null===t||"object"!=typeof t)return;let r=t;if(!0===r.ok&&r.diagram&&void 0!==r.diagram.document&&void 0!==r.diagram.scene&&void 0!==r.diagram.excalidraw)return{document:r.diagram.document,scene:r.diagram.scene,excalidraw:r.diagram.excalidraw,model:"string"==typeof r.generation?.model?r.generation.model:"",provider:"string"==typeof r.generation?.provider?r.generation.provider:"cloudflare-google-ai-studio"}}(r);return n||(yield*U.fJG(iG()))}),iZ=U.fn("sketchi.cli.generate")(function*(e){var t,r;let n,i,a=yield*iw,s=yield*iQ(e),o=yield*nO(s.document).pipe(U.xm_(()=>iH())),l=yield*nA(nI(o)).pipe(U.xm_(()=>iH())),c=yield*(t=s.scene,(n=nc.Uh.safeParse(t)).success?U.PyW(n.data):U.fJG(iG())),u=yield*(r=s.excalidraw,(i=nc.yE.safeParse(r)).success?U.PyW(i.data):U.fJG(iG())),d={id:l,type:o.type,title:o.spec.title,document:o,scene:c,excalidraw:u};return{diagram:yield*a.create(d),model:s.model||e.model,provider:s.provider}}),i0=ec.z4N,i1=e=>el.R6(t=>e(t.getRef(i0))),i2=(...e)=>i1(t=>ec.OH5(()=>{t.error(...e)})),i3=(...e)=>i1(t=>ec.OH5(()=>{t.log(...e)})),i5="~effect/cli/CliError";class i6 extends r7.X0d(`${i5}/UnrecognizedOption`)("UnrecognizedOption",{option:r7.QfV,command:r7.lqM(r7.O31(r7.QfV)),suggestions:r7.O31(r7.QfV)}){[i5]=i5;get message(){let e=this.suggestions.length>0?`
|
|
2
|
+
import{createRequire as e}from"node:module";let t=e(import.meta.url);var r,n,i,a,s={2532(e){let{hasOwnProperty:t}=Object.prototype,r=(e,t={})=>{"string"==typeof t&&(t={section:t}),t.align=!0===t.align,t.newline=!0===t.newline,t.sort=!0===t.sort,t.whitespace=!0===t.whitespace||!0===t.align,t.platform=t.platform||"u">typeof process&&process.platform,t.bracketedArray=!1!==t.bracketedArray;let i="win32"===t.platform?"\r\n":"\n",a=t.whitespace?" = ":"=",o=[],l=t.sort?Object.keys(e).sort():Object.keys(e),c=0;t.align&&(c=s(l.filter(t=>null===e[t]||Array.isArray(e[t])||"object"!=typeof e[t]).map(t=>Array.isArray(e[t])?`${t}[]`:t).concat([""]).reduce((e,t)=>s(e).length>=s(t).length?e:t)).length);let u="",d=t.bracketedArray?"[]":"";for(let t of l){let r=e[t];if(r&&Array.isArray(r))for(let e of r)u+=s(`${t}${d}`).padEnd(c," ")+a+s(e)+i;else r&&"object"==typeof r?o.push(t):u+=s(t).padEnd(c," ")+a+s(r)+i}for(let a of(t.section&&u.length&&(u="["+s(t.section)+"]"+(t.newline?i+i:i)+u),o)){let s=n(a,".").join("\\."),o=(t.section?t.section+".":"")+s,l=r(e[a],{...t,section:o});u.length&&l.length&&(u+=i),u+=l}return u};function n(e,t){var r=0,n=0,i=0,a=[];do if(-1!==(i=e.indexOf(t,r))){if(r=i+t.length,i>0&&"\\"===e[i-1])continue;a.push(e.slice(n,i)),n=i+t.length}while(-1!==i)return a.push(e.slice(n)),a}let i=(e,r={})=>{r.bracketedArray=!1!==r.bracketedArray;let i=Object.create(null),a=i,s=null,l=/^\[([^\]]*)\]\s*$|^([^=]+)(=(.*))?$/i,c=e.split(/[\r\n]+/g),u={};for(let e of c){let n;if(!e||e.match(/^\s*[;#]/)||e.match(/^\s*$/))continue;let c=e.match(l);if(!c)continue;if(void 0!==c[1]){if("__proto__"===(s=o(c[1]))){a=Object.create(null);continue}a=i[s]=i[s]||Object.create(null);continue}let d=o(c[2]);r.bracketedArray?n=d.length>2&&"[]"===d.slice(-2):(u[d]=(u?.[d]||0)+1,n=u[d]>1);let f=n&&d.endsWith("[]")?d.slice(0,-2):d;if("__proto__"===f)continue;let h=!c[3]||o(c[4]),p="true"===h||"false"===h||"null"===h?JSON.parse(h):h;n&&(t.call(a,f)?Array.isArray(a[f])||(a[f]=[a[f]]):a[f]=[]),Array.isArray(a[f])?a[f].push(p):a[f]=p}let d=[];for(let e of Object.keys(i)){if(!t.call(i,e)||"object"!=typeof i[e]||Array.isArray(i[e]))continue;let r=n(e,".");a=i;let s=r.pop(),o=s.replace(/\\\./g,".");for(let e of r)"__proto__"!==e&&(t.call(a,e)&&"object"==typeof a[e]||(a[e]=Object.create(null)),a=a[e]);(a!==i||o!==s)&&(a[o]=i[e],d.push(e))}for(let e of d)delete i[e];return i},a=e=>e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"),s=e=>"string"!=typeof e||e.match(/[=\r\n]/)||e.match(/^\[/)||e.length>1&&a(e)||e!==e.trim()?JSON.stringify(e):e.split(";").join("\\;").split("#").join("\\#"),o=e=>{if(a(e=(e||"").trim())){"'"===e.charAt(0)&&(e=e.slice(1,-1));try{e=JSON.parse(e)}catch{}}else{let t=!1,r="";for(let n=0,i=e.length;n<i;n++){let i=e.charAt(n);if(t)-1!=="\\;#".indexOf(i)?r+=i:r+="\\"+i,t=!1;else if(-1!==";#".indexOf(i))break;else"\\"===i?t=!0:r+=i}return t&&(r+="\\"),r.trim()}return e};e.exports={parse:i,decode:i,stringify:r,encode:r,safe:s,unsafe:o}},3176(e,t,r){var n=r(3633),i=r(4239);e.exports={parse:function(e,t){var r=e.toString(),a=n.parse(r,t);return i.compile(a,r,t)}}},4239(e){e.exports={compile:function(e,t,r){var n=null;if((r=r||{}).useTemporal&&!(n=r.temporal||("u">typeof Temporal?Temporal:null)))throw Error("The `useTemporal` option was set, but no Temporal implementation is available. Use a runtime with global `Temporal` support, or provide an implementation (e.g. from the `@js-temporal/polyfill` package) via the `temporal` option.");for(var i=new Set,a=new Set,s=new Set,o=[],l=new WeakSet,c=b(),u=c,d=e,f,h=0;h<d.length;h++)switch((f=d[h]).type){case"Assign":!function(e){var t=e.key,r=e.value,l=e.offset;Array.isArray(t)||(t=[t]);for(var c=function e(t){if("Array"===t.type)return t.value.map(e);if("InlineTable"===t.type)return function(t){for(var r=b(),n=new Set,i=0;i<t.length;i++){var a=t[i];if("InlineTableValue"===a.type){var s=a.key;Array.isArray(s)||(s=[s]),function(e,t,r,n,i){for(var a=0;a<t.length-1;a++){var s=t[a],o=w(t.slice(0,a+1));void 0===e[s]?e[s]=b():"object"!=typeof e[s]||null===e[s]||Array.isArray(e[s])?p("Cannot redefine existing key '"+o+"'.",n):i&&i.has(o)&&p("Cannot extend inline table '"+o+"'.",n),e=e[s]}var l=t[t.length-1];void 0!==e[l]&&p("Cannot redefine existing key '"+w(t)+"'.",n),e[l]=r}(r,s,e(a.value),a.offset,n),n.add(w(s))}}return r}(t.value);if(n)switch(t.type){case"Date":return n.ZonedDateTime.from(m(t.raw)+t.tz+"["+("Z"===t.tz?"UTC":t.tz)+"]");case"LocalDateTime":return n.PlainDateTime.from(m(t.value));case"LocalDate":return n.PlainDate.from(t.value);case"LocalTime":return n.PlainTime.from(m(t.value))}return t.value}(r),d=u,f=0;f<t.length-1;f++){var h=t[f],g=x(t.slice(0,f+1));void 0===d[h]?(d[h]=b(),i.add(g)):"object"!=typeof d[h]||null===d[h]||Array.isArray(d[h])||a.has(g)?p("Cannot redefine existing key '"+g+"'.",l):s.has(g)&&g!==w(o)&&p("Cannot use dotted keys to extend table '"+g+"' defined elsewhere.",l),d=d[h]}var y=t[t.length-1],v=x(t);void 0!==d[y]&&p("Cannot redefine existing key '"+v+"'.",l),d[y]=c,i.add(v),a.add(v)}(f);break;case"ObjectPath":!function(e){var t=e.value,r=t.map(y).join("."),n=e.offset;i.has(r)&&p("Cannot redefine existing key '"+t+"'.",n),i.add(r),s.add(r),u=g(c,t,b(),n),o=t}(f);break;case"ArrayPath":!function(e){var t=e.value,r=t.map(y).join("."),n=e.offset;if(a.has(r)&&p("Cannot append to statically defined array '"+r+"'.",n),i.forEach(function(e){_(e,r)&&i.delete(e)}),a.forEach(function(e){_(e,r)&&a.delete(e)}),i.add(r),u=g(c,t,function(){var e=[];return l.add(e),e}(),n),o=t,u instanceof Array){var s=b();u.push(s),u=s}else p("Cannot redefine existing key '"+t+"'.",n)}(f)}return c;function p(e,r){var n=function(e){for(var r=1,n=1,i=0;i<e;i++)10===t.charCodeAt(i)?(r++,n=1):n++;return{line:r,column:n}}(r),i=Error(e);throw i.line=n.line,i.column=n.column,i}function m(e){return e.replace(/\.(\d{9})\d+/,".$1")}function g(e,t,r,n){for(var i=e,s=0;s<t.length;s++){var o=t[s],l=w(t.slice(0,s+1));void 0===i[o]?s===t.length-1?i[o]=r:i[o]=b():s!==t.length-1&&a.has(l)&&p("Cannot redefine existing key '"+l+"'.",n),i=i[o],s<t.length-1&&(v(i)||p("Cannot redefine existing key '"+l+"'.",n),i instanceof Array&&(i.length||p("Cannot redefine existing key '"+l+"'.",n),v(i=i[i.length-1])||p("Cannot redefine existing key '"+l+"'.",n)))}return i}function y(e){return e.indexOf(".")>-1?'"'+e+'"':e}function b(){var e=Object.create(null);return l.add(e),e}function v(e){return null!==e&&"object"==typeof e&&l.has(e)}function w(e){return e.map(y).join(".")}function x(e){return w(o.concat(e))}function _(e,t){return e===t||0===e.indexOf(t+".")}}}},3633(e){class t extends SyntaxError{constructor(e,t,r,n){super(e),this.expected=t,this.found=r,this.location=n,this.name="SyntaxError"}format(e){let t="Error: "+this.message;if(this.location){let r=null,n=e.find(e=>e.source===this.location.source);n&&(r=n.text.split(/\r\n|\n|\r/g));let i=this.location.start,a=this.location.source&&"function"==typeof this.location.source.offset?this.location.source.offset(i):i,s=this.location.source+":"+a.line+":"+a.column;if(r){let e=this.location.end,n="".padEnd(a.line.toString().length," "),o=r[i.line-1],l=(i.line===e.line?e.column:o.length+1)-i.column||1;t+="\n --\x3e "+s+"\n"+n+" |\n"+a.line+" | "+o+"\n"+n+" | "+"".padEnd(i.column-1," ")+"".padEnd(l,"^")}else t+="\n at "+s}return t}static buildMessage(e,t){function r(e){return e.codePointAt(0).toString(16).toUpperCase()}let n=Object.prototype.hasOwnProperty.call(RegExp.prototype,"unicode")?RegExp("[\\p{C}\\p{Mn}\\p{Mc}]","gu"):null;function i(e){return n?e.replace(n,e=>"\\u{"+r(e)+"}"):e}function a(e){return i(e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,e=>"\\x0"+r(e)).replace(/[\x10-\x1F\x7F-\x9F]/g,e=>"\\x"+r(e)))}function s(e){return i(e.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,e=>"\\x0"+r(e)).replace(/[\x10-\x1F\x7F-\x9F]/g,e=>"\\x"+r(e)))}let o={literal:e=>'"'+a(e.text)+'"',class(e){let t=e.parts.map(e=>Array.isArray(e)?s(e[0])+"-"+s(e[1]):s(e));return"["+(e.inverted?"^":"")+t.join("")+"]"+(e.unicode?"u":"")},any:()=>"any character",end:()=>"end of input",other:e=>e.description};function l(e){return o[e.type](e)}return"Expected "+function(e){let t=e.map(l);if(t.sort(),t.length>0){let e=1;for(let r=1;r<t.length;r++)t[r-1]!==t[r]&&(t[e]=t[r],e++);t.length=e}switch(t.length){case 1:return t[0];case 2:return t[0]+" or "+t[1];default:return t.slice(0,-1).join(", ")+", or "+t[t.length-1]}}(e)+" but "+(t?'"'+a(t)+'"':"end of input")+" found."}}e.exports={StartRules:["start"],SyntaxError:t,parse:function(e,r){let n,i={},a=(r=void 0!==r?r:{}).grammarSource,s={start:eU},o=eU,l="true",c="false",u=/^[\t -~\x80-\uFFFF]/,d=/^[+\-]/,f=/^[^"\\\0-\b\v-\x1F\x7F\r]/,h=/^[^'\0-\b\v-\x1F\x7F\r]/,p=/^[^"\\\0-\b\n-\x1F\x7F]/,m=/^[^'\0-\b\n-\x1F\x7F]/,g=/^[eE]/,y=/^[0-9_]/,b=/^[1-9]/,v=/^[_]/,w=/^[0-9]/,x=/^[0-9a-fA-F]/,_=/^[0-7]/,k=/^[01]/,S=/^[ \t]/,$=/^[A-Za-z0-9_\-]/,E=/^["\\btnfre]/,O=eN("#",!1),I=eM([" ",[" ","~"],["",""]],!1,!1,!1),A=eN("[",!1),C=eN("]",!1),T=eN(".",!1),N=eN("=",!1),M=eM(["+","-"],!1,!1,!1),P=eN("inf",!1),j=eN("nan",!1),D=eN('"""',!1),U=eN('"',!1),R=eN("'''",!1),F=eN("'",!1),L=eN("\\",!1),B={type:"any"},Y=eN("\r\n",!1),q=eM(['"',"\\",["\0","\b"],["\v","\x1f"],"","\r"],!0,!1,!1),W=eN('""',!1),X=eM(["'",["\0","\b"],["\v","\x1f"],"","\r"],!0,!1,!1),J=eN("''",!1),z=eM(['"',"\\",["\0","\b"],["\n","\x1f"],""],!0,!1,!1),K=eM(["'",["\0","\b"],["\n","\x1f"],""],!0,!1,!1),V=eM(["e","E"],!1,!1,!1),G=eN("0",!1),H=eN("0x",!1),Q=eN("0o",!1),Z=eN("0b",!1),ee=eM([["0","9"],"_"],!1,!1,!1),et=eM([["1","9"]],!1,!1,!1),er=eM(["_"],!1,!1,!1),en=eM([["0","9"]],!1,!1,!1),ei=eM([["0","9"],["a","f"],["A","F"]],!1,!1,!1),ea=eM([["0","7"]],!1,!1,!1),es=eM(["0","1"],!1,!1,!1),eo=eN("true",!1),el=eN("false",!1),ec=eN(",",!1),eu=eN("{",!1),ed=eN("}",!1),ef=eN("-",!1),eh=eN(":",!1),ep=eN("Z",!0),em=eN("T",!0),eg=eN(" ",!1),ey=eM([" "," "],!1,!1,!1),eb=eN("\n",!1),ev=eN("\r",!1),ew=eN("\uFEFF",!1),ex=eM([["A","Z"],["a","z"],["0","9"],"_","-"],!1,!1,!1),e_=eM(['"',"\\","b","t","n","f","r","e"],!1,!1,!1),ek=eN("\\U",!1),eS=eN("\\u",!1),e$=eN("\\x",!1),eE=0|r.peg$currPos,eO=eE,eI=[{line:1,column:1}],eA=eE,eC=r.peg$maxFailExpected||[],eT=0|r.peg$silentFails;if(r.startRule){if(!(r.startRule in s))throw Error("Can't start parsing from rule \""+r.startRule+'".');o=s[r.startRule]}function eN(e,t){return{type:"literal",text:e,ignoreCase:t}}function eM(e,t,r,n){return{type:"class",parts:e,inverted:t,ignoreCase:r,unicode:n}}function eP(t){let r,n=eI[t];if(n)return n;if(t>=eI.length)r=eI.length-1;else for(r=t;!eI[--r];);for(n={line:(n=eI[r]).line,column:n.column};r<t;)10===e.charCodeAt(r)?(n.line++,n.column=1):n.column++,r++;return eI[t]=n,n}function ej(e,t,r){let n=eP(e),i=eP(t),s={source:a,start:{offset:e,line:n.line,column:n.column},end:{offset:t,line:i.line,column:i.column}};return r&&a&&"function"==typeof a.offset&&(s.start=a.offset(s.start),s.end=a.offset(s.end)),s}function eD(e){eE<eA||(eE>eA&&(eA=eE,eC=[]),eC.push(e))}function eU(){let t,r,n,a;for(t=eE,65279===e.charCodeAt(eE)?(a="\uFEFF",eE++):(a=i,0===eT&&eD(ew)),a===i,r=[],n=eR();n!==i;)r.push(n),n=eR();return eO=t,t=tl}function eR(){let t,r,n,a,s,o,l,c;for(t=eE,r=[],n=te();n!==i;)r.push(n),n=te();if((c=eF())===i&&(c=function(){let t,r,n,a,s,o,l,c;if(t=eE,91===e.charCodeAt(eE)?(r="[",eE++):(r=i,0===eT&&eD(A)),r!==i)if(91===e.charCodeAt(eE)?(n="[",eE++):(n=i,0===eT&&eD(A)),n!==i){for(a=[],s=te();s!==i;)a.push(s),s=te();if((s=eL())!==i){for(o=[],l=te();l!==i;)o.push(l),l=te();(93===e.charCodeAt(eE)?(l="]",eE++):(l=i,0===eT&&eD(C)),l!==i&&(93===e.charCodeAt(eE)?(c="]",eE++):(c=i,0===eT&&eD(C)),c!==i))?t=void tf(th("ArrayPath",s,eO=t)):(eE=t,t=i)}else eE=t,t=i}else eE=t,t=i;else eE=t,t=i;if(t===i)if(t=eE,91===e.charCodeAt(eE)?(r="[",eE++):(r=i,0===eT&&eD(A)),r!==i){for(n=[],a=te();a!==i;)n.push(a),a=te();if((a=eL())!==i){for(s=[],o=te();o!==i;)s.push(o),o=te();(93===e.charCodeAt(eE)?(o="]",eE++):(o=i,0===eT&&eD(C)),o!==i)?t=void tf(th("ObjectPath",a,eO=t)):(eE=t,t=i)}else eE=t,t=i}else eE=t,t=i;return t}())===i&&(c=function(){let t,r,n,a,s,o;if(t=eE,(r=e3())!==i){for(n=[],a=te();a!==i;)n.push(a),a=te();if(61===e.charCodeAt(eE)?(a="=",eE++):(a=i,0===eT&&eD(N)),a!==i){for(s=[],o=te();o!==i;)s.push(o),o=te();if((o=eq())!==i)t=void tf(th("Assign",o,eO=t,r));else eE=t,t=i}else eE=t,t=i}else eE=t,t=i;return t}()),(n=c)!==i){for(a=[],s=te();s!==i;)a.push(s),s=te();if((s=eF())===i&&(s=null),o=[],(l=tt())!==i)for(;l!==i;)o.push(l),l=tt();else o=i;o===i&&(o=tn()),o!==i?t=r=[r,n,a,s,o]:(eE=t,t=i)}else eE=t,t=i;if(t===i){if(t=eE,r=[],(n=te())!==i)for(;n!==i;)r.push(n),n=te();else r=i;if(r!==i){if(n=[],(a=tt())!==i)for(;a!==i;)n.push(a),a=tt();else n=i;n===i&&(n=tn()),n!==i?t=r=[r,n]:(eE=t,t=i)}else eE=t,t=i;t===i&&(t=tt())}return t}function eF(){let t,r,n,a;if(t=eE,35===e.charCodeAt(eE)?(r="#",eE++):(r=i,0===eT&&eD(O)),r!==i){for(n=[],a=e.charAt(eE),u.test(a)?eE++:(a=i,0===eT&&eD(I));a!==i;)n.push(a),a=e.charAt(eE),u.test(a)?eE++:(a=i,0===eT&&eD(I));t=r=[r,n]}else eE=t,t=i;return t}function eL(){let e,t,r;if(e=eE,t=[],(r=eY())!==i)for(;r!==i;)t.push(r),r=eY();else t=i;if(t!==i)if((r=eB())!==i){var n,a;eO=e,n=t,a=r,e=n.concat(a)}else eE=e,e=i;else eE=e,e=i;return e===i&&(e=eE,(t=eB())!==i&&(eO=e,t=[t]),e=t),e}function eB(){let e,t,r,n,a;for(e=eE,t=[],r=te();r!==i;)t.push(r),r=te();if((r=e8())!==i){for(n=[],a=te();a!==i;)n.push(a),a=te();eO=e,e=r}else eE=e,e=i;return e}function eY(){let t,r,n,a,s;for(t=eE,r=[],n=te();n!==i;)r.push(n),n=te();if((n=e8())!==i){for(a=[],s=te();s!==i;)a.push(s),s=te();(46===e.charCodeAt(eE)?(s=".",eE++):(s=i,0===eT&&eD(T)),s!==i)?(eO=t,t=n):(eE=t,t=i)}else eE=t,t=i;return t}function eq(){let t,r;return(t=eE,eO=eE,++tc>tu&&(tc--,td("Maximum nesting depth of "+tu+" exceeded.",eO)),void 0!==i&&(r=function(){let t,r,n,a,s,o,u,f,h,p,m,b,w,S,$,E,O;if(t=eE,(s=eE,'"""'===e.substr(eE,3)?(o='"""',eE+=3):(o=i,0===eT&&eD(D)),o!==i&&(tt()===i,u=function(){let t,r,n,a,s,o,l,c,u,d,f;for(t=eE,r=[],n=eJ();n!==i;)r.push(n),n=eJ();if(n=[],a=eE,(s=ez())!==i){if(o=[],(l=eJ())!==i)for(;l!==i;)o.push(l),l=eJ();else o=i;o!==i?a=s=[s,o]:(eE=a,a=i)}else eE=a,a=i;for(;a!==i;)if(n.push(a),a=eE,(s=ez())!==i){if(o=[],(l=eJ())!==i)for(;l!==i;)o.push(l),l=eJ();else o=i;o!==i?a=s=[s,o]:(eE=a,a=i)}else eE=a,a=i;return c=eE,'""'===e.substr(eE,2)?(u='""',eE+=2):(u=i,0===eT&&eD(W)),u!==i?(d=eE,eT++,'"""'===e.substr(eE,3)?(f='"""',eE+=3):(f=i,0===eT&&eD(D)),eT--,f!==i?(eE=d,d=void 0):d=i,d!==i?(eO=c,c='""'):(eE=c,c=i)):(eE=c,c=i),c===i&&(c=eE,34===e.charCodeAt(eE)?(u='"',eE++):(u=i,0===eT&&eD(U)),u!==i?(d=eE,eT++,'"""'===e.substr(eE,3)?(f='"""',eE+=3):(f=i,0===eT&&eD(D)),eT--,f!==i?(eE=d,d=void 0):d=i,d!==i?(eO=c,c='"'):(eE=c,c=i)):(eE=c,c=i)),(a=c)===i&&(a=null),eO=t,t=function(e,t,r){for(var n=e.join(""),i=0;i<t.length;i++)n+=t[i][0]+t[i][1].join("");return n+(r||"")}(r,n,a)}(),'"""'===e.substr(eE,3)?(f='"""',eE+=3):(f=i,0===eT&&eD(D)),f!==i))?s=th("String",u,eO=s):(eE=s,s=i),(a=s)===i&&(a=eW())===i&&((h=eE,"'''"===e.substr(eE,3)?(p="'''",eE+=3):(p=i,0===eT&&eD(R)),p!==i&&(tt()===i,m=function(){let t,r,n,a,s,o,l,c,u,d,f;for(t=eE,r=[],n=eK();n!==i;)r.push(n),n=eK();if(n=[],a=eE,(s=eV())!==i){if(o=[],(l=eK())!==i)for(;l!==i;)o.push(l),l=eK();else o=i;o!==i?a=s=[s,o]:(eE=a,a=i)}else eE=a,a=i;for(;a!==i;)if(n.push(a),a=eE,(s=eV())!==i){if(o=[],(l=eK())!==i)for(;l!==i;)o.push(l),l=eK();else o=i;o!==i?a=s=[s,o]:(eE=a,a=i)}else eE=a,a=i;return c=eE,"''"===e.substr(eE,2)?(u="''",eE+=2):(u=i,0===eT&&eD(J)),u!==i?(d=eE,eT++,"'''"===e.substr(eE,3)?(f="'''",eE+=3):(f=i,0===eT&&eD(R)),eT--,f!==i?(eE=d,d=void 0):d=i,d!==i?(eO=c,c="''"):(eE=c,c=i)):(eE=c,c=i),c===i&&(c=eE,39===e.charCodeAt(eE)?(u="'",eE++):(u=i,0===eT&&eD(F)),u!==i?(d=eE,eT++,"'''"===e.substr(eE,3)?(f="'''",eE+=3):(f=i,0===eT&&eD(R)),eT--,f!==i?(eE=d,d=void 0):d=i,d!==i?(eO=c,c="'"):(eE=c,c=i)):(eE=c,c=i)),(a=c)===i&&(a=null),eO=t,t=function(e,t,r){for(var n=e.join(""),i=0;i<t.length;i++)n+=t[i][0]+t[i][1].join("");return n+(r||"")}(r,n,a)}(),"'''"===e.substr(eE,3)?(b="'''",eE+=3):(b=i,0===eT&&eD(R)),b!==i))?h=th("String",m,eO=h):(eE=h,h=i),(a=h)===i)&&(a=eX()),(n=a)===i&&((w=eE,S=e.charAt(eE),d.test(S)?eE++:(S=i,0===eT&&eD(M)),S===i&&(S=null),"inf"===e.substr(eE,3)?($="inf",eE+=3):($=i,0===eT&&eD(P)),$!==i)?w=th("Float","-"===S?-1/0:1/0,eO=w):(eE=w,w=i),w===i&&(w=eE,S=e.charAt(eE),d.test(S)?eE++:(S=i,0===eT&&eD(M)),S===i&&(S=null),"nan"===e.substr(eE,3)?($="nan",eE+=3):($=i,0===eT&&eD(j)),$!==i?w=th("Float",NaN,eO=w):(eE=w,w=i),w===i&&(w=function(){var t,r,n,a,s,o,l,c,u,f,h;let p,m,g,y,b;if(p=eE,(m=e4())!==i)if((g=e7())!==i)if((y=e9())!==i){let s,o,l,c,u,f,h,g;(s=eE,"z"===(o=e.charAt(eE)).toLowerCase()?eE++:(o=i,0===eT&&eD(ep)),o!==i&&(eO=s,o="Z"),(s=o)===i&&(s=eE,o=eE,l=e.charAt(eE),d.test(l)?eE++:(l=i,0===eT&&eD(M)),l!==i&&(c=ti())!==i&&(u=ti())!==i?(58===e.charCodeAt(eE)?(f=":",eE++):(f=i,0===eT&&eD(eh)),f!==i&&(h=ti())!==i&&(g=ti())!==i?o=l=[l,c,u,f,h,g]:(eE=o,o=i)):(eE=o,o=i),s=o!==i?e.substring(s,eE):o),(b=s)!==i)?(eO=p,t=m,r=y,tp(t,n=eO),tm(r,n),function(e,t){if("Z"!==e&&"z"!==e){var r=(e.charCodeAt(1)-48)*10+e.charCodeAt(2)-48,n=(e.charCodeAt(4)-48)*10+e.charCodeAt(5)-48;r>23&&td("Invalid offset: hour "+r+" out of range.",t),n>59&&td("Invalid offset: minute "+n+" out of range.",t)}}(b,n),(a=th("Date",new Date(t+"T"+r+b),n)).raw=t+"T"+r,a.tz=b,p=a):(eE=p,p=i)}else eE=p,p=i;else eE=p,p=i;else eE=p,p=i;return p===i&&((p=eE,(m=e4())!==i&&(g=e7())!==i&&(y=e9())!==i)?(eO=p,s=m,o=y,tp(s,l=eO),tm(o,l),p=th("LocalDateTime",s+"T"+o,l)):(eE=p,p=i),p===i&&((p=eE,(m=e4())!==i&&(g=eE,eT++,y=e7(),eT--,y===i?g=void 0:(eE=g,g=i),g!==i))?(eO=p,tp(c=m,u=eO),p=th("LocalDate",c,u)):(eE=p,p=i),p===i&&(p=eE,(m=e9())!==i&&(eO=p,tm(f=m,h=eO),m=th("LocalTime",f,h)),p=m))),p}())===i&&(w=function(){let t,r,n,a,s,o,l,c,u,f;if(t=eE,(s=eE,o=e.charAt(eE),d.test(o)?eE++:(o=i,0===eT&&eD(M)),o===i&&(o=null),(l=eQ())!==i&&(46===e.charCodeAt(eE)?(c=".",eE++):(c=i,0===eT&&eD(T)),c!==i&&(u=eE,(u=(f=e0())!==i?e.substring(u,eE):f)!==i)))?(eO=s,s=("-"===o?"-":"")+l+"."+u):(eE=s,s=i),s===i&&((s=eE,o=e.charAt(eE),d.test(o)?eE++:(o=i,0===eT&&eD(M)),o===i&&(o=null),(l=eQ())!==i)?(eO=s,s=("-"===o?"-":"")+l):(eE=s,s=i)),(r=s)!==i)if(n=e.charAt(eE),g.test(n)?eE++:(n=i,0===eT&&eD(V)),n!==i){let n,s,o,l;if((n=eE,s=e.charAt(eE),d.test(s)?eE++:(s=i,0===eT&&eD(M)),s===i&&(s=null),o=eE,(o=(l=e0())!==i?e.substring(o,eE):l)!==i)?(eO=n,n=(s||"")+o):(eE=n,n=i),(a=n)!==i)eO=t,t=th("Float",parseFloat(tg(r+"e"+a)),eO);else eE=t,t=i}else eE=t,t=i;else eE=t,t=i;if(t===i){let n,a,s,o,l,c;t=eE,(n=eE,a=e.charAt(eE),d.test(a)?eE++:(a=i,0===eT&&eD(M)),a===i&&(a=null),(s=eQ())!==i&&(46===e.charCodeAt(eE)?(o=".",eE++):(o=i,0===eT&&eD(T)),o!==i&&(l=eE,(l=(c=e0())!==i?e.substring(l,eE):c)!==i)))?(eO=n,n=("-"===a?"-":"")+s+"."+l):(eE=n,n=i),(r=n)!==i&&(eO=t,r=th("Float",parseFloat(tg(r)),eO)),t=r}return t}())===i&&(w=function(){let t,r,n,a;if(((t=eE,"0x"===e.substr(eE,2)?(r="0x",eE+=2):(r=i,0===eT&&eD(H)),r!==i&&(n=eE,(n=(a=function(){let t,r,n,a,s,o;if(t=eE,r=e.charAt(eE),x.test(r)?eE++:(r=i,0===eT&&eD(ei)),r!==i){for(n=[],a=eE,s=e.charAt(eE),v.test(s)?eE++:(s=i,0===eT&&eD(er)),s===i&&(s=null),o=e.charAt(eE),x.test(o)?eE++:(o=i,0===eT&&eD(ei)),o!==i?a=s=[s,o]:(eE=a,a=i);a!==i;)n.push(a),a=eE,s=e.charAt(eE),v.test(s)?eE++:(s=i,0===eT&&eD(er)),s===i&&(s=null),o=e.charAt(eE),x.test(o)?eE++:(o=i,0===eT&&eD(ei)),o!==i?a=s=[s,o]:(eE=a,a=i);t=r=[r,n]}else eE=t,t=i;return t}())!==i?e.substring(n,eE):a)!==i))?(eO=t,t=th("Integer",parseInt(tg(n),16),eO)):(eE=t,t=i),t===i)&&((t=eE,"0o"===e.substr(eE,2)?(r="0o",eE+=2):(r=i,0===eT&&eD(Q)),r!==i&&(n=eE,(n=(a=function(){let t,r,n,a,s,o;if(t=eE,r=e.charAt(eE),_.test(r)?eE++:(r=i,0===eT&&eD(ea)),r!==i){for(n=[],a=eE,s=e.charAt(eE),v.test(s)?eE++:(s=i,0===eT&&eD(er)),s===i&&(s=null),o=e.charAt(eE),_.test(o)?eE++:(o=i,0===eT&&eD(ea)),o!==i?a=s=[s,o]:(eE=a,a=i);a!==i;)n.push(a),a=eE,s=e.charAt(eE),v.test(s)?eE++:(s=i,0===eT&&eD(er)),s===i&&(s=null),o=e.charAt(eE),_.test(o)?eE++:(o=i,0===eT&&eD(ea)),o!==i?a=s=[s,o]:(eE=a,a=i);t=r=[r,n]}else eE=t,t=i;return t}())!==i?e.substring(n,eE):a)!==i))?(eO=t,t=th("Integer",parseInt(tg(n),8),eO)):(eE=t,t=i),t===i)&&((t=eE,"0b"===e.substr(eE,2)?(r="0b",eE+=2):(r=i,0===eT&&eD(Z)),r!==i&&(n=eE,(n=(a=function(){let t,r,n,a,s,o;if(t=eE,r=e.charAt(eE),k.test(r)?eE++:(r=i,0===eT&&eD(es)),r!==i){for(n=[],a=eE,s=e.charAt(eE),v.test(s)?eE++:(s=i,0===eT&&eD(er)),s===i&&(s=null),o=e.charAt(eE),k.test(o)?eE++:(o=i,0===eT&&eD(es)),o!==i?a=s=[s,o]:(eE=a,a=i);a!==i;)n.push(a),a=eE,s=e.charAt(eE),v.test(s)?eE++:(s=i,0===eT&&eD(er)),s===i&&(s=null),o=e.charAt(eE),k.test(o)?eE++:(o=i,0===eT&&eD(es)),o!==i?a=s=[s,o]:(eE=a,a=i);t=r=[r,n]}else eE=t,t=i;return t}())!==i?e.substring(n,eE):a)!==i))?(eO=t,t=th("Integer",parseInt(tg(n),2),eO)):(eE=t,t=i),t===i)){let n,a,s,o,l,c;t=eE,(n=eE,a=e.charAt(eE),d.test(a)?eE++:(a=i,0===eT&&eD(M)),a===i&&(a=null),48===e.charCodeAt(eE)?(s="0",eE++):(s=i,0===eT&&eD(G)),s!==i&&(o=eE,eT++,l=e.charAt(eE),y.test(l)?eE++:(l=i,0===eT&&eD(ee)),eT--,l===i?o=void 0:(eE=o,o=i),o!==i&&(l=eE,eT++,46===e.charCodeAt(eE)?(c=".",eE++):(c=i,0===eT&&eD(T)),eT--,c===i?l=void 0:(eE=l,l=i),l!==i)))?(eO=n,n=(a||"")+"0"):(eE=n,n=i),n===i&&((n=eE,a=e.charAt(eE),d.test(a)?eE++:(a=i,0===eT&&eD(M)),a===i&&(a=null),s=eE,(s=(o=eZ())!==i?e.substring(s,eE):o)!==i&&(o=eE,eT++,46===e.charCodeAt(eE)?(l=".",eE++):(l=i,0===eT&&eD(T)),eT--,l===i?o=void 0:(eE=o,o=i),o!==i))?(eO=n,n=(a||"")+s):(eE=n,n=i)),(r=n)!==i&&(eO=t,r=th("Integer",parseInt(tg(r),10),eO)),t=r}return t}())),(n=w)===i&&(E=eE,e.substr(eE,4)===l?(O=l,eE+=4):(O=i,0===eT&&eD(eo)),O!==i&&(O=th("Boolean",!0,eO=E)),(E=O)===i&&(E=eE,e.substr(eE,5)===c?(O=c,eE+=5):(O=i,0===eT&&eD(el)),O!==i&&(O=th("Boolean",!1,eO=E)),E=O),(n=E)===i&&(n=function(){let t,r,n,a,s,o,l,c,u,d;if(t=eE,91===e.charCodeAt(eE)?(r="[",eE++):(r=i,0===eT&&eD(A)),r!==i){for(n=[],a=e1();a!==i;)n.push(a),a=e1();93===e.charCodeAt(eE)?(a="]",eE++):(a=i,0===eT&&eD(C)),a!==i?t=th("Array",[],eO=t):(eE=t,t=i)}else eE=t,t=i;if(t===i)if(t=eE,91===e.charCodeAt(eE)?(r="[",eE++):(r=i,0===eT&&eD(A)),r!==i){for(n=[],a=e1();a!==i;)n.push(a),a=e1();if((a=eq())!==i){for(s=[],o=eE,l=[],c=e1();c!==i;)l.push(c),c=e1();if(44===e.charCodeAt(eE)?(c=",",eE++):(c=i,0===eT&&eD(ec)),c!==i){for(u=[],d=e1();d!==i;)u.push(d),d=e1();(d=eq())!==i?(eO=o,o=d):(eE=o,o=i)}else eE=o,o=i;for(;o!==i;){for(s.push(o),o=eE,l=[],c=e1();c!==i;)l.push(c),c=e1();if(44===e.charCodeAt(eE)?(c=",",eE++):(c=i,0===eT&&eD(ec)),c!==i){for(u=[],d=e1();d!==i;)u.push(d),d=e1();(d=eq())!==i?(eO=o,o=d):(eE=o,o=i)}else eE=o,o=i}for(o=[],l=e1();l!==i;)o.push(l),l=e1();for(44===e.charCodeAt(eE)?(l=",",eE++):(l=i,0===eT&&eD(ec)),l===i&&(l=null),c=[],u=e1();u!==i;)c.push(u),u=e1();if(93===e.charCodeAt(eE)?(u="]",eE++):(u=i,0===eT&&eD(C)),u!==i){var f;eO=t,f=a,s.unshift(f),t=th("Array",s,eO)}else eE=t,t=i}else eE=t,t=i}else eE=t,t=i;return t}())===i))&&(n=function(){let t,r,n,a,s,o,l,c,u,d;if(t=eE,123===e.charCodeAt(eE)?(r="{",eE++):(r=i,0===eT&&eD(eu)),r!==i){for(n=[],a=e5();a!==i;)n.push(a),a=e5();125===e.charCodeAt(eE)?(a="}",eE++):(a=i,0===eT&&eD(ed)),a!==i?t=th("InlineTable",[],eO=t):(eE=t,t=i)}else eE=t,t=i;if(t===i)if(t=eE,123===e.charCodeAt(eE)?(r="{",eE++):(r=i,0===eT&&eD(eu)),r!==i){for(n=[],a=e5();a!==i;)n.push(a),a=e5();if((a=e2())!==i){for(s=[],o=eE,l=[],c=e5();c!==i;)l.push(c),c=e5();if(44===e.charCodeAt(eE)?(c=",",eE++):(c=i,0===eT&&eD(ec)),c!==i){for(u=[],d=e5();d!==i;)u.push(d),d=e5();(d=e2())!==i?(eO=o,o=d):(eE=o,o=i)}else eE=o,o=i;for(;o!==i;){for(s.push(o),o=eE,l=[],c=e5();c!==i;)l.push(c),c=e5();if(44===e.charCodeAt(eE)?(c=",",eE++):(c=i,0===eT&&eD(ec)),c!==i){for(u=[],d=e5();d!==i;)u.push(d),d=e5();(d=e2())!==i?(eO=o,o=d):(eE=o,o=i)}else eE=o,o=i}for(o=[],l=e5();l!==i;)o.push(l),l=e5();for(44===e.charCodeAt(eE)?(l=",",eE++):(l=i,0===eT&&eD(ec)),l===i&&(l=null),c=[],u=e5();u!==i;)c.push(u),u=e5();if(125===e.charCodeAt(eE)?(u="}",eE++):(u=i,0===eT&&eD(ed)),u!==i){var f;eO=t,f=a,s.unshift(f),t=th("InlineTable",s,eO)}else eE=t,t=i}else eE=t,t=i}else eE=t,t=i;return t}()),(r=n)!==i){var I;eO=t,I=r,tc--,r=I}return(t=r)===i&&(eO=eE,tc--,t=!1,t=i),t}())!==i)?(eO=t,t=r):(eE=t,t=i),t}function eW(){let t,r,n,a;if(t=eE,34===e.charCodeAt(eE)?(r='"',eE++):(r=i,0===eT&&eD(U)),r!==i){for(n=[],a=eG();a!==i;)n.push(a),a=eG();(34===e.charCodeAt(eE)?(a='"',eE++):(a=i,0===eT&&eD(U)),a!==i)?(eO=t,t=th("String",n.join(""),eO)):(eE=t,t=i)}else eE=t,t=i;return t}function eX(){let t,r,n,a;if(t=eE,39===e.charCodeAt(eE)?(r="'",eE++):(r=i,0===eT&&eD(F)),r!==i){for(n=[],a=eH();a!==i;)n.push(a),a=eH();(39===e.charCodeAt(eE)?(a="'",eE++):(a=i,0===eT&&eD(F)),a!==i)?(eO=t,t=th("String",n.join(""),eO)):(eE=t,t=i)}else eE=t,t=i;return t}function eJ(){let t,r,n;if((t=to())===i&&(t=function(){let t,r,n,a,s,o;if(t=eE,92===e.charCodeAt(eE)?(r="\\",eE++):(r=i,0===eT&&eD(L)),r!==i){for(n=[],a=te();a!==i;)n.push(a),a=te();if((a=tt())!==i){for(s=[],o=tr();o!==i;)s.push(o),o=tr();eO=t,t=""}else eE=t,t=i}else eE=t,t=i;return t}())===i&&(t=eE,92===e.charCodeAt(eE)?(r="\\",eE++):(r=i,0===eT&&eD(L)),r!==i?(e.length>eE?(n=e.charAt(eE),eE++):(n=i,0===eT&&eD(B)),n!==i?t=void td("Invalid escape sequence",eO=t):(eE=t,t=i)):(eE=t,t=i),t===i)&&(t=eE,"\r\n"===e.substr(eE,2)?(r="\r\n",eE+=2):(r=i,0===eT&&eD(Y)),r!==i&&(eO=t,r="\n"),(t=r)===i)){if(t=eE,r=[],n=e.charAt(eE),f.test(n)?eE++:(n=i,0===eT&&eD(q)),n!==i)for(;n!==i;)r.push(n),n=e.charAt(eE),f.test(n)?eE++:(n=i,0===eT&&eD(q));else r=i;t=r!==i?e.substring(t,eE):r}return t}function ez(){let t,r,n,a;return t=eE,'""'===e.substr(eE,2)?(r='""',eE+=2):(r=i,0===eT&&eD(W)),r!==i?(n=eE,eT++,34===e.charCodeAt(eE)?(a='"',eE++):(a=i,0===eT&&eD(U)),eT--,a===i?n=void 0:(eE=n,n=i),n!==i?(eO=t,t='""'):(eE=t,t=i)):(eE=t,t=i),t===i&&(t=eE,34===e.charCodeAt(eE)?(r='"',eE++):(r=i,0===eT&&eD(U)),r!==i?(n=eE,eT++,34===e.charCodeAt(eE)?(a='"',eE++):(a=i,0===eT&&eD(U)),eT--,a===i?n=void 0:(eE=n,n=i),n!==i?(eO=t,t='"'):(eE=t,t=i)):(eE=t,t=i)),t}function eK(){let t,r,n;if(t=eE,"\r\n"===e.substr(eE,2)?(r="\r\n",eE+=2):(r=i,0===eT&&eD(Y)),r!==i&&(eO=t,r="\n"),(t=r)===i){if(t=eE,r=[],n=e.charAt(eE),h.test(n)?eE++:(n=i,0===eT&&eD(X)),n!==i)for(;n!==i;)r.push(n),n=e.charAt(eE),h.test(n)?eE++:(n=i,0===eT&&eD(X));else r=i;t=r!==i?e.substring(t,eE):r}return t}function eV(){let t,r,n,a;return t=eE,"''"===e.substr(eE,2)?(r="''",eE+=2):(r=i,0===eT&&eD(J)),r!==i?(n=eE,eT++,39===e.charCodeAt(eE)?(a="'",eE++):(a=i,0===eT&&eD(F)),eT--,a===i?n=void 0:(eE=n,n=i),n!==i?(eO=t,t="''"):(eE=t,t=i)):(eE=t,t=i),t===i&&(t=eE,39===e.charCodeAt(eE)?(r="'",eE++):(r=i,0===eT&&eD(F)),r!==i?(n=eE,eT++,39===e.charCodeAt(eE)?(a="'",eE++):(a=i,0===eT&&eD(F)),eT--,a===i?n=void 0:(eE=n,n=i),n!==i?(eO=t,t="'"):(eE=t,t=i)):(eE=t,t=i)),t}function eG(){let t,r,n;if((t=to())===i&&(t=eE,92===e.charCodeAt(eE)?(r="\\",eE++):(r=i,0===eT&&eD(L)),r!==i?(e.length>eE?(n=e.charAt(eE),eE++):(n=i,0===eT&&eD(B)),n!==i?t=void td("Invalid escape sequence",eO=t):(eE=t,t=i)):(eE=t,t=i),t===i)){if(t=eE,r=[],n=e.charAt(eE),p.test(n)?eE++:(n=i,0===eT&&eD(z)),n!==i)for(;n!==i;)r.push(n),n=e.charAt(eE),p.test(n)?eE++:(n=i,0===eT&&eD(z));else r=i;t=r!==i?e.substring(t,eE):r}return t}function eH(){let t,r,n;if(t=eE,r=[],n=e.charAt(eE),m.test(n)?eE++:(n=i,0===eT&&eD(K)),n!==i)for(;n!==i;)r.push(n),n=e.charAt(eE),m.test(n)?eE++:(n=i,0===eT&&eD(K));else r=i;return r!==i?e.substring(t,eE):r}function eQ(){let t,r;return t=eE,48===e.charCodeAt(eE)?(r="0",eE++):(r=i,0===eT&&eD(G)),r!==i&&(eO=t,r="0"),(t=r)===i&&(t=eE,t=(r=eZ())!==i?e.substring(t,eE):r),t}function eZ(){let t,r,n,a,s,o;if(t=eE,r=e.charAt(eE),b.test(r)?eE++:(r=i,0===eT&&eD(et)),r!==i){for(n=[],a=eE,s=e.charAt(eE),v.test(s)?eE++:(s=i,0===eT&&eD(er)),s===i&&(s=null),o=e.charAt(eE),w.test(o)?eE++:(o=i,0===eT&&eD(en)),o!==i?a=s=[s,o]:(eE=a,a=i);a!==i;)n.push(a),a=eE,s=e.charAt(eE),v.test(s)?eE++:(s=i,0===eT&&eD(er)),s===i&&(s=null),o=e.charAt(eE),w.test(o)?eE++:(o=i,0===eT&&eD(en)),o!==i?a=s=[s,o]:(eE=a,a=i);t=r=[r,n]}else eE=t,t=i;return t}function e0(){let t,r,n,a,s,o;if(t=eE,r=e.charAt(eE),w.test(r)?eE++:(r=i,0===eT&&eD(en)),r!==i){for(n=[],a=eE,s=e.charAt(eE),v.test(s)?eE++:(s=i,0===eT&&eD(er)),s===i&&(s=null),o=e.charAt(eE),w.test(o)?eE++:(o=i,0===eT&&eD(en)),o!==i?a=s=[s,o]:(eE=a,a=i);a!==i;)n.push(a),a=eE,s=e.charAt(eE),v.test(s)?eE++:(s=i,0===eT&&eD(er)),s===i&&(s=null),o=e.charAt(eE),w.test(o)?eE++:(o=i,0===eT&&eD(en)),o!==i?a=s=[s,o]:(eE=a,a=i);t=r=[r,n]}else eE=t,t=i;return t}function e1(){let e;return(e=te())===i&&(e=tt())===i&&(e=eF()),e}function e2(){let t,r,n,a,s,o;if(t=eE,(r=e3())!==i){for(n=[],a=te();a!==i;)n.push(a),a=te();if(61===e.charCodeAt(eE)?(a="=",eE++):(a=i,0===eT&&eD(N)),a!==i){for(s=[],o=te();o!==i;)s.push(o),o=te();if((o=eq())!==i)t=th("InlineTableValue",o,eO=t,r);else eE=t,t=i}else eE=t,t=i}else eE=t,t=i;return t}function e5(){let e;return(e=te())===i&&(e=tt())===i&&(e=eF()),e}function e3(){let e,t,r,n;if(e=eE,t=[],(r=e6())!==i)for(;r!==i;)t.push(r),r=e6();else t=i;if(t!==i){for(r=[],n=te();n!==i;)r.push(n),n=te();if((n=e8())!==i){var a,s;eO=e,a=t,s=n,e=a.concat(s)}else eE=e,e=i}else eE=e,e=i;return e===i&&(e=eE,(t=e8())!==i&&(eO=e,t=[t]),e=t),e}function e6(){let t,r,n,a,s;for(t=eE,r=[],n=te();n!==i;)r.push(n),n=te();if((n=e8())!==i){for(a=[],s=te();s!==i;)a.push(s),s=te();(46===e.charCodeAt(eE)?(s=".",eE++):(s=i,0===eT&&eD(T)),s!==i)?(eO=t,t=n):(eE=t,t=i)}else eE=t,t=i;return t}function e8(){let t,r,n;return(t=function(){let t,r,n;if(t=eE,r=[],(n=ts())!==i)for(;n!==i;)r.push(n),n=ts();else r=i;return r!==i?e.substring(t,eE):r}())===i&&(r=eE,(n=eW())!==i&&(eO=r,n=n.value),(r=n)===i&&(r=eE,(n=eX())!==i&&(eO=r,n=n.value),r=n),t=r),t}function e4(){let t,r,n,a,s,o,l,c,u,d,f,h;return t=eE,r=eE,(n=ti())!==i&&(a=ti())!==i&&(s=ti())!==i&&(o=ti())!==i?(45===e.charCodeAt(eE)?(l="-",eE++):(l=i,0===eT&&eD(ef)),l!==i&&(c=ti())!==i&&(u=ti())!==i?(45===e.charCodeAt(eE)?(d="-",eE++):(d=i,0===eT&&eD(ef)),d!==i&&(f=ti())!==i&&(h=ti())!==i?r=n=[n,a,s,o,l,c,u,d,f,h]:(eE=r,r=i)):(eE=r,r=i)):(eE=r,r=i),t=r!==i?e.substring(t,eE):r}function e9(){let t,r,n,a,s,o,l,c,u,d,f;if(t=eE,r=eE,n=eE,(a=ti())!==i&&(s=ti())!==i?(58===e.charCodeAt(eE)?(o=":",eE++):(o=i,0===eT&&eD(eh)),o!==i&&(l=ti())!==i&&(c=ti())!==i?(58===e.charCodeAt(eE)?(u=":",eE++):(u=i,0===eT&&eD(eh)),u!==i&&(d=ti())!==i&&(f=ti())!==i?n=a=[a,s,o,l,c,u,d,f]:(eE=n,n=i)):(eE=n,n=i)):(eE=n,n=i),(r=n!==i?e.substring(r,eE):n)!==i){var h,p;(n=function(){let t,r,n,a,s;if(t=eE,r=eE,46===e.charCodeAt(eE)?(n=".",eE++):(n=i,0===eT&&eD(T)),n!==i){if(a=[],(s=ti())!==i)for(;s!==i;)a.push(s),s=ti();else a=i;a!==i?r=n=[n,a]:(eE=r,r=i)}else eE=r,r=i;return r!==i?e.substring(t,eE):r}())===i&&(n=null),eO=t,h=r,t=(p=n)?h+p:h}else eE=t,t=i;return t===i&&((t=eE,r=eE,n=eE,(a=ti())!==i&&(s=ti())!==i?(58===e.charCodeAt(eE)?(o=":",eE++):(o=i,0===eT&&eD(eh)),o!==i&&(l=ti())!==i&&(c=ti())!==i?n=a=[a,s,o,l,c]:(eE=n,n=i)):(eE=n,n=i),(r=n!==i?e.substring(r,eE):n)!==i&&(n=eE,eT++,58===e.charCodeAt(eE)?(a=":",eE++):(a=i,0===eT&&eD(eh)),eT--,a===i?n=void 0:(eE=n,n=i),n!==i))?(eO=t,t=r+":00"):(eE=t,t=i)),t}function e7(){let t,r,n,a;return"t"===(t=e.charAt(eE)).toLowerCase()?eE++:(t=i,0===eT&&eD(em)),t===i&&(t=eE,32===e.charCodeAt(eE)?(r=" ",eE++):(r=i,0===eT&&eD(eg)),r!==i?(n=eE,eT++,a=ti(),eT--,a!==i?(eE=n,n=void 0):n=i,n!==i?t=r=[r,n]:(eE=t,t=i)):(eE=t,t=i)),t}function te(){let t;return t=e.charAt(eE),S.test(t)?eE++:(t=i,0===eT&&eD(ey)),t}function tt(){let t,r,n;return 10===e.charCodeAt(eE)?(t="\n",eE++):(t=i,0===eT&&eD(eb)),t===i&&(t=eE,13===e.charCodeAt(eE)?(r="\r",eE++):(r=i,0===eT&&eD(ev)),r!==i?(10===e.charCodeAt(eE)?(n="\n",eE++):(n=i,0===eT&&eD(eb)),n!==i?t=r=[r,n]:(eE=t,t=i)):(eE=t,t=i)),t}function tr(){let e;return(e=tt())===i&&(e=te()),e}function tn(){let t,r;return t=eE,eT++,e.length>eE?(r=e.charAt(eE),eE++):(r=i,0===eT&&eD(B)),eT--,r===i?t=void 0:(eE=t,t=i),t}function ti(){let t;return t=e.charAt(eE),w.test(t)?eE++:(t=i,0===eT&&eD(en)),t}function ta(){let t;return t=e.charAt(eE),x.test(t)?eE++:(t=i,0===eT&&eD(ei)),t}function ts(){let t;return t=e.charAt(eE),$.test(t)?eE++:(t=i,0===eT&&eD(ex)),t}function to(){let t,r,n,a,s,o,l,c,u,d,f,h,p,m,g;if(t=eE,92===e.charCodeAt(eE)?(r="\\",eE++):(r=i,0===eT&&eD(L)),r!==i)if(n=e.charAt(eE),E.test(n)?eE++:(n=i,0===eT&&eD(e_)),n!==i){var y;eO=t,t="n"===(y=n)?"\n":"t"===y?" ":"r"===y?"\r":"\\"===y?"\\":'"'===y?'"':"b"===y?"\b":"f"===y?"\f":"\x1b"}else eE=t,t=i;else eE=t,t=i;return t===i&&((a=eE,"\\U"===e.substr(eE,2)?(s="\\U",eE+=2):(s=i,0===eT&&eD(ek)),s!==i&&(o=eE,l=eE,(c=ta())!==i&&(u=ta())!==i&&(d=ta())!==i&&(f=ta())!==i&&(h=ta())!==i&&(p=ta())!==i&&(m=ta())!==i&&(g=ta())!==i?l=c=[c,u,d,f,h,p,m,g]:(eE=l,l=i),(o=l!==i?e.substring(o,eE):l)!==i))?(eO=a,a=ty(o)):(eE=a,a=i),a===i&&((a=eE,"\\u"===e.substr(eE,2)?(s="\\u",eE+=2):(s=i,0===eT&&eD(eS)),s!==i&&(o=eE,l=eE,(c=ta())!==i&&(u=ta())!==i&&(d=ta())!==i&&(f=ta())!==i?l=c=[c,u,d,f]:(eE=l,l=i),(o=l!==i?e.substring(o,eE):l)!==i))?(eO=a,a=ty(o)):(eE=a,a=i),a===i&&((a=eE,"\\x"===e.substr(eE,2)?(s="\\x",eE+=2):(s=i,0===eT&&eD(e$)),s!==i&&(o=eE,l=eE,(c=ta())!==i&&(u=ta())!==i?l=c=[c,u]:(eE=l,l=i),(o=l!==i?e.substring(o,eE):l)!==i))?(eO=a,a=ty(o)):(eE=a,a=i))),t=a),t}var tl=[],tc=0,tu=r&&null!=r.maxDepth?r.maxDepth:500;function td(t,r){var n=function(t){for(var r=1,n=1,i=0;i<t;i++)10===e.charCodeAt(i)?(r++,n=1):n++;return{line:r,column:n}}(r),i=Error(t);throw i.line=n.line,i.column=n.column,i}function tf(e){tl.push(e)}function th(e,t,r,n){var i={type:e,value:t,offset:r};return n&&(i.key=n),i}function tp(e,t){var r=1e3*e.charCodeAt(0)+100*e.charCodeAt(1)+10*e.charCodeAt(2)+e.charCodeAt(3)-53328,n=(e.charCodeAt(5)-48)*10+e.charCodeAt(6)-48,i=(e.charCodeAt(8)-48)*10+e.charCodeAt(9)-48;(n<1||n>12)&&td("Invalid date: month "+n+" out of range.",t);var a=[31,28,31,30,31,30,31,31,30,31,30,31];(r%4==0&&r%100!=0||r%400==0)&&(a[1]=29),(i<1||i>a[n-1])&&td("Invalid date: day "+i+" out of range for month "+n+".",t)}function tm(e,t){var r=(e.charCodeAt(0)-48)*10+e.charCodeAt(1)-48,n=(e.charCodeAt(3)-48)*10+e.charCodeAt(4)-48,i=(e.charCodeAt(6)-48)*10+e.charCodeAt(7)-48;r>23&&td("Invalid time: hour "+r+" out of range.",t),n>59&&td("Invalid time: minute "+n+" out of range.",t),i>59&&td("Invalid time: second "+i+" out of range.",t)}function tg(e){return -1===e.indexOf("_")?e:e.replace(/_/g,"")}function ty(e){var t=parseInt(e,16);if(t==t&&!(t<0)&&!(t>1114111)&&(!(t>55295)||!(t<57344)))return String.fromCodePoint(t);td("Invalid Unicode escape code: "+e,eO)}let tb=(n=o())!==i&&eE===e.length;function tv(){var r,a,s;throw n!==i&&eE<e.length&&eD({type:"end"}),r=eC,a=eA<e.length?function(t=eE){let r=e.codePointAt(t);return void 0===r?"":String.fromCodePoint(r)}(eA):null,s=eA<e.length?ej(eA,eA+1):ej(eA,eA),new t(t.buildMessage(r,a),r,a,s)}return r.peg$library?{peg$result:n,peg$currPos:eE,peg$FAILED:i,peg$maxFailExpected:eC,peg$maxFailPos:eA,peg$success:tb,peg$throw:tb?void 0:tv}:tb?n:void tv()}}},4144(e,r,n){let i,a,s,o,l,c,u,d,f,h,p,m,g,y,b,v,w,x,_,k,S,$,E,O,I,A,C;var T,N,M,P,j,D=n(8543),U=n(7720),R=n(7598),F=n(4650);let L=(e,t)=>t(R.oJ(e)?0:D.nn(e.cause)?130:Y(D.iw(e.cause))),B="~effect/Runtime/errorExitCode",Y=e=>{if("object"==typeof e&&null!==e&&B in e){let t=e[B];if("number"==typeof t)return t}return 1},q="~effect/Runtime/errorReported",W=(i=({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,F.XY)(e=>U.yw5(e[0]),(e,t)=>{let r=t?.disableErrorReporting===!0?U.MY7(e):U.MY7(U.dGm(e,e=>D.nn(e)?U.rIH:(e=>{if("object"==typeof e&&null!==e&&q in e){let t=e[q];if("boolean"==typeof t)return t}return!0})(D.iw(e))?U.vVN(e):U.rIH));try{let e=globalThis.setInterval(F.Yi,0x7fffffff);r.addObserver(()=>{clearInterval(e)})}catch{}return i({fiber:r,teardown:t?.teardown??L})}));var X=n(5089),J=n(3717),z=n(8927),K=n(3833),V=n(995);function G(){return Object.assign(e=>e,{option:e=>K.some(e),result:e=>V.Py(e),is:e=>!0})}var H=n(8619),Q=n(2718);let Z="~effect/platform/PlatformError";class ee extends Q.rN("BadArgument"){get message(){return`${this.module}.${this.method}${this.description?`: ${this.description}`:""}`}}class et extends Q.$D{get message(){return`${this._tag}: ${this.module}.${this.method}${void 0!==this.pathOrDescriptor?` (${this.pathOrDescriptor})`:""}${this.description?`: ${this.description}`:""}`}}class er extends Q.rN("PlatformError"){constructor(e){"cause"in e?super({reason:e,cause:e.cause}):super({reason:e})}[Z]=Z;get message(){return this.reason.message}}let en=e=>new er(new et(e)),ei=e=>new er(new ee(e));var ea=n(9138),es=n(5369),eo=n(4505),el=n(8433),ec=n(1136);let eu=Symbol.for("effect/MutableList/Empty"),ed=()=>({array:[],mutable:!0,offset:0,next:void 0}),ef=(e,t)=>{e.tail?e.tail.mutable||(e.tail.next=ed(),e.tail=e.tail.next):e.head=e.tail=ed(),e.tail.array.push(t),e.length++},eh=e=>{e.head=e.tail=void 0,e.length=0},ep=e=>{if(!e.head)return eu;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:eh(e)),t},em={_A:F.D_,_E:F.D_},eg={"~effect/Queue":em,"~effect/Queue/Enqueue":em,"~effect/Queue/Dequeue":em,...el.fU,toJSON(){return{_id:"effect/Queue",state:this.state._tag,size:eI(this)}}},ey=e=>el.R6(t=>{let r=Object.create(eg);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},ec.PyW(r)}),eb=(e,t)=>ec.DYE(()=>{if("Open"!==e.state._tag)return eA;if(e.messages.length>=e.capacity)switch(e.strategy){case"dropping":return eA;case"suspend":if(e.capacity<=0&&e.state.takers.size>0)return ef(e.messages,t),eM(e),eC;return eD(e,t);case"sliding":return ep(e.messages),ef(e.messages,t),eC}return ef(e.messages,t),eP(e),eC}),ev=(e,t)=>"Open"===e.state._tag&&(e.messages.length>=e.capacity?"sliding"===e.strategy?(ep(e.messages),ef(e.messages,t),!0):e.capacity<=0&&e.state.takers.size>0&&(ef(e.messages,t),eM(e),!0):(ef(e.messages,t),eP(e),!0)),ew=(0,F.XY)(2,(e,t)=>ec.OH5(()=>ex(e,t))),ex=(e,t)=>{if("Open"!==e.state._tag)return!1;let r=el.cb(t),n=ec.il9(r,eT);return 0===e.state.offers.size&&0===e.messages.length?eF(e,n):e.state={...e.state,_tag:"Closing",exit:n},!0},e_=e=>ex(e,el.OE(el.RS())),ek=e=>ec.OH5(()=>{if("Done"===e.state._tag)return!0;eh(e.messages);let t=e.state.offers;if(eF(e,"Open"===e.state._tag?eN:e.state.exit),t.size>0){for(let e of t)"Single"===e._tag?e.resume(eA):e.resume(el.xt(e.remaining.slice(e.offset)));t.clear()}return!0}),eS=e=>e$(e,1,1/0),e$=(e,t,r)=>ec.DYE(()=>ej(e,t,r)??ec.hgn(eR(e),e$(e,1,r))),eE=e=>ec.DYE(()=>eO(e)??ec.hgn(eR(e),eE(e))),eO=e=>{if("Done"===e.state._tag)return e.state.exit;if(e.messages.length>0){let t=ep(e.messages);return eU(e),el.xt(t)}if(e.capacity<=0&&e.state.offers.size>0){e.capacity=1,eU(e),e.capacity=0;let t=ep(e.messages);return eU(e),el.xt(t)}},eI=e=>"Done"===e.state._tag?0:e.messages.length,eA=el.xt(!1),eC=el.xt(!0),eT=el.Rk(el.RS()),eN=ec._sz(),eM=e=>{if(e.scheduleRunning=!1,"Done"!==e.state._tag&&0!==e.state.takers.size){for(let t of e.state.takers)if(e.state.takers.delete(t),t(ec.x5l),0===e.messages.length)break}},eP=e=>{e.scheduleRunning||"Done"===e.state._tag||0===e.state.takers.size||(e.scheduleRunning=!0,e.dispatcher.scheduleTask(()=>eM(e),0))},ej=(e,t,r)=>{if("Done"===e.state._tag)return e.state.exit;if(r<=0||t<=0)return el.xt([]);if(e.capacity<=0&&e.state.offers.size>0){e.capacity=1,eU(e),e.capacity=0;let t=[ep(e.messages)];return eU(e),el.xt(t)}if((t=Math.min(t,e.capacity||1))<=e.messages.length){let t=((e,t)=>{if(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 eh(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,e.length-=t,0===e.length&&eh(e),r;i=i.next}return eh(e),r})(e.messages,r);return eU(e),el.xt(t)}},eD=(e,t)=>ec.E2r(r=>{if("Open"!==e.state._tag)return r(eA);let n={_tag:"Single",message:t,resume:r};return e.state.offers.add(n),ec.OH5(()=>{"Open"===e.state._tag&&e.state.offers.delete(n)})}),eU=e=>{if("Done"===e.state._tag)return eo.Og(e.state.exit.cause);if(0===e.state.offers.size)return"Closing"===e.state._tag&&0===e.messages.length&&(eF(e,e.state.exit),eo.Og(e.state.exit.cause));let t=e.capacity-e.messages.length;for(let r of e.state.offers)if(0===t)break;else if("Single"===r._tag)ef(e.messages,r.message),t--,r.resume(eC),e.state.offers.delete(r);else{for(;r.offset<r.remaining.length;r.offset++){if(0===t)return!1;ef(e.messages,r.remaining[r.offset]),t--}r.resume(el.xt([])),e.state.offers.delete(r)}return!1},eR=e=>ec.E2r(t=>"Done"===e.state._tag?t(e.state.exit):(e.state.takers.add(t),ec.OH5(()=>{"Done"!==e.state._tag&&e.state.takers.delete(t)}))),eF=(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(t);for(let e of(r.takers.clear(),r.awaiters))e(t);r.awaiters.clear()};var eL=n(2672);let eB="~effect/Channel",eY=e=>(0,es.i5)(e,eB),eq={[eB]:{_Env:F.D_,_InErr:F.D_,_InElem:F.D_,_OutErr:F.D_,_OutElem:F.D_},pipe(){return(0,ea.tT)(this,arguments)}},eW=e=>{let t=Object.create(eq);return t.transform=(t,r)=>U.Tyx(e(t,r),e=>U.PyW(U.ATB(e))),t},eX=(e,t)=>eW((r,n)=>U.qIB(ez(e)(r,n),e=>t(e,n))),eJ=e=>eW((t,r)=>e),ez=e=>e.transform,eK=eJ(U.PyW(D.Vw()));U.ZmZ;let eV=(0,F.XY)(2,(e,t)=>eX(e,e=>U.OH5(()=>{let r=0;return U.TjK(e,e=>t(e,r++))}))),eG=(0,F.XY)(2,(e,t)=>eH(e,e=>U.PyW(t(e)))),eH=(0,F.XY)(2,(e,t)=>eX(e,e=>U.PyW(eo.m8(e,e=>U.qIB(t(e),D.Vw))))),eQ=(0,F.XY)(e=>eY(e[0])&&eY(e[1]),(e,t,r)=>{let n;return n=U.D9k(function*(n,i,a){let s=r?.haltStrategy??"both",o=yield*ey({capacity:0});yield*eL.U9(a,ek(o));let l=0,c=(e,t,r)=>ez(t)(n,r).pipe(U.qIB(e=>e.pipe(U.qIB(e=>eb(o,e)),U.i4r)),U.S5A(t=>U.hgn(eL.VN(r,eo.aU(t)),function(e,t){if(l++,!eo.Og(t))return ew(o,t);switch(s){case"both":return 2===l?ew(o,t):U.rIH;case"left":case"right":return e===s?ew(o,t):U.rIH;case"either":return ew(o,t)}}(e,t))),U.ar0(a));return yield*c("left",e,eL.Fp(a)),yield*c("right",t,eL.Fp(a)),eE(o)}),eW(U.D9k(function*(e,t){let r=eL.Fp(t),i=e=>eL.VN(r,eo.aU(e)),a=yield*U.S5A(n(e,t,r),i);return U.S5A(a,i)}))}),eZ=(0,F.XY)(2,(e,t)=>eW((r,n)=>U.qIB(ez(e)(r,n),e=>ez(t)(e,n)))),e0=e=>eW((t,r)=>{let n;return U.PyW(U.DYE(()=>n||e.pipe(eL.Gt(r),U.qIB(e=>ez(e)(t,r)),U.qIB(e=>n=e))))}),e1=(e,t,r)=>U.DYE(()=>{let n=eL.LZ(),i=ez(e)(D.Vw(),n);return eo.m8(U.qIB(i,t),r||U.PyW).pipe(U.cfM(e=>eL.VN(n,e)))}),e2=(0,F.XY)(2,(e,t)=>e1(e,e=>U.i4r(U.qIB(e,t),{disableYield:!0}))),e5=(0,F.XY)(3,(e,t,r)=>U.DYE(()=>{let n=t();return e1(e,e=>U.iMI({while:F.ue,body:()=>e,step:e=>{n=r(n,e)}}),()=>U.PyW(n))})),e3=(0,F.XY)(3,(e,t,r)=>U.DYE(()=>{let n=t();return e1(e,e=>U.iMI({while:F.ue,body:(0,F.dY)(e.pipe(U.qIB(e=>r(n,e)),U.TjK(e=>{n=e}))),step:F.Yi}),()=>U.PyW(n))})),e6=(e,t)=>ez(e)(D.Vw(),t),e8="~effect/Sink",e4=U.PyW([void 0]),e9={[e8]:{_A:F.D_,_In:F.D_,_L:F.D_,_E:F.D_,_R:F.D_},pipe(){return(0,ea.tT)(this,arguments)}},e7=e=>(0,es.i5)(e,e8),te=e=>tt((t,r)=>ez(e)(t,r).pipe(U.qIB(U.i4r({disableYield:!0})),eo.m8(U.PyW))),tt=e=>{let t=Object.create(e9);return t.transform=e,t},tr=e=>eW((t,r)=>U.PyW(U.qIB(e.transform(t,r),D.Vw)));U.ZmZ;let tn=tt(e=>eo.m8(U.i4r(e,{disableYield:!0}),()=>e4));K.none,K.isNone,K.none;let ti=e=>te(e0(U.TjK(e,tr))),ta={"~effect/Stream":{_R:F.D_,_E:F.D_,_A:F.D_},pipe(){return(0,ea.tT)(this,arguments)}},ts=e=>(0,es.i5)(e,"~effect/Stream"),to=e=>{let t=Object.create(ta);return t.channel=e,t},tl=e=>e.channel,tc=to(eK),tu=e=>{let t;return to((t=()=>e().channel,eW((e,r)=>U.DYE(()=>ez(t())(e,r)))))},td=e=>{let t;return z.ET(e)?to((t=U.PyW(e),eJ(U.OH5(()=>{let e=!1;return U.DYE(()=>e?D.Vw():(e=!0,t))})))):tc},tf=e=>to(e0(U.TjK(e,tl))),th=(0,F.XY)(2,(e,t)=>tu(()=>{let r=0;return to(eV(e.channel,z.Tj(e=>t(e,r++))))})),tp=(0,F.XY)(e=>ts(e[0])&&ts(e[1]),(e,t,r)=>to(eQ(tl(e),tl(t),r))),tm=(0,F.XY)(2,(e,t)=>{let r;return r=(e,r)=>U.OH5(()=>{let n,i,a=U.DYE(()=>{if(void 0!==i){let e=i;return i=void 0,U.PyW(e)}return e}).pipe(U.MfU(e=>(n=R.fJ(e),D.Vw()))),s=U.TjK(U.DYE(()=>t.transform(a,r)),([e,t])=>(i=t,z.of(e)));return U.DYE(()=>n||s)}),to(eW((t,n)=>U.qIB(e6(e.channel,n),e=>r(e,n))))}),tg=(0,F.XY)(e=>ts(e[0]),(e,t)=>tu(()=>{let r=new TextDecoder(t?.encoding);return th(e,e=>r.decode(e,{stream:!0}))})),ty=(0,F.XY)(2,(e,t)=>U.Pxi(r=>e6(e.channel,r).pipe(U.qIB(e=>t.transform(e,r)),U.TjK(([e])=>e)))),tb=(0,F.XY)(3,(e,t,r)=>e3(e.channel,t,(e,t)=>{let n=0,i=e;return U.TjK(U.iMI({while:()=>n<t.length,body:()=>r(i,t[n]),step(e){i=e,n++}}),()=>i)})),tv=((e,t)=>e2(e.channel,t),"~effect/platform/FileSystem"),tw=e=>"bigint"==typeof e?e:BigInt(e),tx=H.kl("effect/platform/FileSystem"),t_="~effect/platform/FileSystem/File",tk=G();class tS extends H.kl()("effect/platform/FileSystem/WatchBackend"){}let t$="~effect/platform/Path",tE=H.kl("effect/Path");var tO=n(3267),tI=n(6400);let tA=G(),tC=G(),tT="~effect/ChildProcessSpawner/ChildProcessHandle",tN={[tT]:tT,...tI.os,toJSON(){return{_id:"ChildProcessHandle",pid:this.pid}}},tM=e=>Object.assign(Object.create(tN),e);class tP extends H.kl()("effect/process/ChildProcessSpawner"){}let tj="~effect/unstable/process/ChildProcess",tD={...tO.b({label:"Command",evaluate(e){return H.fp(e.context,tP).spawn(this)}}),[tj]:tj},tU=(e,t,r)=>Object.assign(Object.create(tD),{_tag:"StandardCommand",command:e,args:t,options:r}),tR=function(...e){if(tF(e[0])){let[t,...r]=e,n=tY(t,r);return tU(n[0]??"",n.slice(1),{})}if("object"==typeof e[0]&&!Array.isArray(e[0])&&!tF(e[0])){let t=e[0];return function(e,...r){let n=tY(e,r);return tU(n[0]??"",n.slice(1),t)}}if("string"==typeof e[0]&&!Array.isArray(e[1])){let[t,r={}]=e;return tU(t,[],r)}let[t,r=[],n={}]=e;return tU(t,r,n)},tF=e=>Array.isArray(e)&&"raw"in e&&Array.isArray(e.raw),tL=e=>{let t=/^fd(\d+)$/.exec(e);if(null===t)return;let r=parseInt(t[1],10);return r>=3?r:void 0},tB=e=>`fd${e}`,tY=(e,t)=>{let r=[];for(let[n,i]of e.entries())r=tq(e,t,r,i,n);return r},tq=(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}=tz(n,a),c=tK(r,l,s);if(i===t.length)return c;let u=t[i];return tK(c,Array.isArray(u)?u.map(e=>tW(e)):[tW(u)],o)},tW=e=>"string"==typeof e?e:String(e),tX=new Set([" "," ","\r","\n"]),tJ={x:3,u:5},tz=(e,t)=>{if(0===t.length)return{tokens:[],hasLeadingWhitespace:!1,hasTrailingWhitespace:!1};let r=tX.has(t[0]),n=[],i=0;for(let r=0,a=0;r<e.length;r+=1,a+=1){let s=t[a];if(tX.has(s))i!==r&&n.push(e.slice(i,r)),i=r+1;else if("\\"===s){let e=t[a+1];"\n"===e?(r-=1,a+=1):"u"===e&&"{"===t[a+2]?a=t.indexOf("}",a+3):a+=tJ[e]??1}}let a=i===e.length;return a||n.push(e.slice(i)),{tokens:n,hasLeadingWhitespace:r,hasTrailingWhitespace:a}},tK=(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)],tV=t("node:child_process"),tG=t("node:stream"),tH=(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 en({_tag:i,module:e,method:t,pathOrDescriptor:n,syscall:r.syscall,cause:r})},tQ=e=>te(eG(tZ(e),e=>[e])),tZ=e=>eW(t=>{let r=e.evaluate();return U.PyW(t0({...e,writable:r,pull:t}))}),t0=e=>e.pull.pipe(U.qIB(t=>{let r=0;return U.E2r(function n(i){for(;r<t.length;)if(!e.writable.write(t[r++],e.encoding))return void e.writable.once("drain",()=>n(i));i(U.rIH)})}),U.i4r({disableYield:!0}),U.KT6(U.E2r(t=>{let r=r=>t(U.fJG(e.onError(r)));return e.writable.once("error",r),U.OH5(()=>{e.writable.off("error",r)})})),!1!==e.endOnDone?eo.m8(t=>"closed"in e.writable&&e.writable.closed?D.Vw(t):U.E2r(r=>{e.writable.once("finish",()=>r(D.Vw(t))),e.writable.end()})):F.D_);ec.zFM,ec.C6p,ec.D7p,ec.INJ;let t1=ec.mKq;ec.eGS,ec.DKo,ec.$MQ,ec.Iku;let t2=ec.vTQ,t5=ec.zzk;ec.Fbb;let t3="~effect/MutableRef",t6={[t3]:t3,...el.fU,toJSON(){return{_id:"MutableRef",current:(0,tI.aB)(this.current)}}},t8=e=>to(t4(e)),t4=e=>eW((t,r)=>t9({scope:r,readable:e.evaluate(),onError:e.onError??t7,chunkSize:e.chunkSize,closeOnDone:e.closeOnDone})),t9=e=>{var t;let r,n=e.readable,i=e.closeOnDone??!0,a=e.exit??(t=void 0,(r=Object.create(t6)).current=t,r),s=t5(!1);function o(){s.openUnsafe()}function l(t){a.current=R.fJ(e.onError(t)),s.openUnsafe()}function c(){a.current=R.fJ(D.RS()),s.openUnsafe()}n.on("readable",o),n.once("error",l),n.once("end",c);let u=U.DYE(function t(){let r=e.readable.read(e.chunkSize);if(null===r)return a.current?a.current:n.readableEnded?U.fJG(D.RS()):(s.closeUnsafe(),U.qIB(s.await,t));let i=z.of(r);for(;null!==(r=e.readable.read(e.chunkSize));)i.push(r);return U.PyW(i)});return U.as(eL.U9(e.scope,U.OH5(()=>{n.off("readable",o),n.off("error",l),n.off("end",c),i&&"closed"in e.readable&&!e.readable.closed&&e.readable.destroy()})),u)};tG.Readable;let t7=e=>new D.Bk(e),re=e=>e instanceof globalThis.Error?e:new globalThis.Error(String(e)),rt=(e,t,r)=>{let{commands:n}=ri(r),i=n.reduce((e,t)=>{let r=`${t.command} ${t.args.join(" ")}`;return 0===e.length?r:`${e} | ${r}`},"");return tH("ChildProcess",e)(t,[i])},rr=U.JkU(function*(){let e,t,r=yield*tx,n=yield*tE,i=U.D9k(function*(e){if(!es.b0(e.cwd))return yield*r.access(e.cwd),n.resolve(e.cwd)}),a=e=>e7(e)?"pipe":e,s=e=>{let t={stream:"pipe",encoding:"utf-8",endOnDone:!0};return es.b0(e.stdin)?t:"string"==typeof e.stdin||ts(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 es.b0(r)?{stream:"pipe"}:"string"==typeof r||e7(r)?{stream:r}:{stream:r.stream}},l=U.D9k(function*(e,t,r){if(0===r.length)return{getInputFd:()=>tn,getOutputFd:()=>tc};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=tn;r&&"write"in r&&(t=tQ({evaluate:()=>r,onError:t=>rt(`fromWritable(fd${s})`,re(t),e)})),a.stream&&(yield*U.x6Z(ty(a.stream,t))),n.set(s,t);break}case"output":{let t=tc;if(r&&"read"in r){let n=new tG.PassThrough;r.on("error",e=>n.destroy(e)),r.pipe(n),t=t8({evaluate:()=>n,onError:t=>rt(`fromReadable(fd${s})`,re(t),e)})}a.sink&&(t=tm(t,a.sink)),i.set(s,t)}}}return{getInputFd:e=>n.get(e)??tn,getOutputFd:e=>i.get(e)??tc}}),c=(e,t,r)=>"win32"===globalThis.process.platform?U.E2r(r=>{tV.exec(`taskkill /pid ${t.pid} /T /F`,t=>{t?r(U.fJG(rt("kill",re(t),e))):r(U.rIH)})}):U.SvU({try:()=>{globalThis.process.kill(-t.pid,r)},catch:t=>rt("kill",re(t),e)}),u=(e,t,r)=>U.DYE(()=>{if(!t.kill(r)){let t=new globalThis.Error("Failed to kill child process");return U.fJG(rt("kill",t,e))}return U.rIH}),d=(e,t,r)=>n=>{let i=r?.killSignal??"SIGTERM";return es.b0(r?.forceKillAfter)?n(t,e,i):U.mgX(n(t,e,i),{duration:r.forceKillAfter,orElse:()=>n(t,e,"SIGKILL")})},f=(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=tL(r);if(es.EA(t))return e.getOutputFd(t);return e.stdout}}},h=U.D9k(function*(e){switch(e._tag){case"StandardCommand":{let t,r,n,f,h,p,m,g=s(e.options),y=o(e.options,"stdout"),b=o(e.options,"stderr"),v=(e=>{if(es.b0(e.additionalFds))return[];let t=[];for(let[r,n]of Object.entries(e.additionalFds)){let e=tL(r);es.EA(e)&&t.push({fd:e,config:n})}return t.sort((e,t)=>e.fd-t.fd)})(e.options),w=!0,x=yield*i(e.options),_=(t=e.options).extendEnv?{...globalThis.process.env,...t.env}:t.env,k=((e,t,r,n)=>{let i,s=[ts(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})(g,y,b,v),[S,$]=yield*U.Q56((r={cwd:x,env:_,stdio:k,detached:e.options.detached??"win32"!==process.platform,shell:e.options.shell},U.E2r(t=>{let n=J.LZ(),i=tV.spawn(e.command,e.args,r);return i.on("error",r=>{t(U.fJG(rt("spawn",r,e)))}),i.on("exit",(...e)=>{J.$w(n,R.Py(e))}),i.on("spawn",()=>{t(U.PyW([i,n]))}),U.OH5(()=>{i.kill("SIGTERM")})})),U.D9k(function*([t,r]){let n=yield*J.$L(r),i=d(t,e,e.options);if(n){let[e]=yield*J.Tx(r);return 0!==e&&es.Pe(e)?yield*U.XeO(i(c)):yield*U.rIH}return w?yield*i((e,t,n)=>c(e,t,n).pipe(U.MfU(()=>u(e,t,n)),U.hgn(J.Tx(r)))).pipe(U.XeO):yield*U.rIH})),E=tC(S.pid);S.on("exit",t=>{0!==t&&es.Pe(t)&&((e,t)=>{if("win32"===globalThis.process.platform)return tV.exec(`taskkill /pid ${e.pid} /T /F`,()=>{});try{globalThis.process.kill(-e.pid,t)}catch{}})(S,e.options.killSignal??"SIGTERM")});let O=U.OH5(()=>{w||(S.ref(),w=!0)}),I=U.OH5(()=>(w&&(S.unref(),w=!1),O)),A=yield*U.DYE(()=>{let t=tn;return(es.Pe(S.stdin)&&(t=tQ({evaluate:()=>S.stdin,onError:t=>rt("fromWritable(stdin)",re(t),e),endOnDone:g.endOnDone,encoding:g.encoding})),ts(g.stream))?U.as(U.x6Z(ty(g.stream,t)),t):U.PyW(t)}),{all:C,stderr:T,stdout:N}=(f=S.stdout?(n=new tG.PassThrough,S.stdout.on("error",e=>n.destroy(e)),S.stdout.pipe(n),t8({evaluate:()=>n,onError:t=>rt("fromReadable(stdout)",re(t),e)})):tc,p=S.stderr?(h=new tG.PassThrough,S.stderr.on("error",e=>h.destroy(e)),S.stderr.pipe(h),t8({evaluate:()=>h,onError:t=>rt("fromReadable(stderr)",re(t),e)})):tc,e7(y.stream)&&(f=tm(f,y.stream)),e7(b.stream)&&(p=tm(p,b.stream)),m=tp(f,p),{stdout:f,stderr:p,all:m}),{getInputFd:M,getOutputFd:P}=yield*l(e,S,v),j=U.TjK(J.$L($),e=>!e);return tM({pid:E,exitCode:U.qIB(J.Tx($),([t,r])=>{if(es.Pe(t))return U.PyW(tA(t));let n=new globalThis.Error(`Process interrupted due to receipt of signal: '${r}'`);return U.fJG(rt("exitCode",n,e))}),isRunning:j,kill:t=>d(S,e,t)((e,t,r)=>c(e,t,r).pipe(U.MfU(()=>u(e,t,r)),U.hgn(J.Tx($)))).pipe(U.NLW),stdin:A,stdout:N,stderr:T,all:C,getInputFd:M,getOutputFd:P,unref:I})}case"PipedCommand":{let{commands:t,pipeOptions:r}=ri(e),[n,...i]=t,a=[(yield*h(n))];for(let e=0;e<i.length;e++){let t=i[e],n=r[e]??{},o=s(t.options),l=tf(U.PyW(f(a[a.length-1],n.from))),c=n.to??"stdin";if("stdin"===c)a.push((yield*h(tR(t.command,t.args,{...t.options,stdin:{...o,stream:l}}))));else{let e=tL(c);if(es.EA(e)){let r=tB(e),n=t.options.additionalFds??{};a.push((yield*h(tR(t.command,t.args,{...t.options,additionalFds:{...n,[r]:{type:"input",stream:l}}}))))}else a.push((yield*h(tR(t.command,t.args,{...t.options,stdin:{...o,stream:l}}))))}}let o=a[a.length-1],l=U.JkU(function*(){let e=[];for(let t of a)e.push((yield*t.unref));return U.jJl([...e].reverse(),e=>e,{discard:!0})});return tM({pid:o.pid,exitCode:o.exitCode,isRunning:o.isRunning,kill:o.kill,stdin:o.stdin,stdout:o.stdout,stderr:o.stderr,all:o.all,getInputFd:o.getInputFd,getOutputFd:o.getOutputFd,unref:l})}}});return e=(e,t)=>h(e).pipe(U.TjK(e=>tg(t?.includeStderr===!0?e.all:e.stdout)),tf),t=(t,r)=>e(t,r).channel.pipe(eZ(eW((e,t)=>U.OH5(()=>{let t="",r=!1,n=K.none(),i=U.DYE(()=>"Some"===n._tag?D.Vw(n.value):eo.tv(e,{onSuccess:a,onFailure:U.ATB,onDone:e=>{if(n=K.some(e),t.length>0||r){let e=t;return t="",r=!1,U.PyW([e])}return D.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?(i(""),e=1,s=a.indexOf("\n",e)):i(""),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)):a.length===n+1?(r=!0,n=-1):(i(a.substring(e,n)),e=n+(s===n+1?2:1),n=a.indexOf("\r",e),s=a.indexOf("\n",e));t+=a.substring(e,a.length-!!r)}}return z.ET(n)?n:null}(e);return null!==n?U.PyW(n):i}return i}))),to),tP.of({spawn:h,exitCode:e=>U.P1j(U.qIB(h(e),e=>e.exitCode)),streamString:e,streamLines:t,lines:(e,r)=>e5(t(e,r).channel,()=>[],(e,t)=>{for(let r=0;r<t.length;r++)e.push(t[r]);return e}),string:(t,r)=>e5(e(t,r).channel,()=>"",(e,t)=>e+t.join(""))})}),rn=X.QZ(tP,rr),ri=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}},ra="~effect/platform/Crypto",rs=H.kl("effect/Crypto"),ro=e=>e.toString(16).padStart(2,"0"),rl=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,ro).join("")).join("-"),rc=0x1000000000000-1,ru=t("node:crypto"),rd=(a=(P={randomBytes:ru.randomBytes,digest:(e,t)=>U.SvU({try:()=>Uint8Array.from(ru.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=>en({module:"Crypto",method:"digest",_tag:"Unknown",description:"Could not compute digest",cause:e})})}).randomBytes,s=()=>{let e=a(7);return((31&e[0])*0x1000000000000+0x10000000000*e[1]+0x100000000*e[2]+0x1000000*e[3]+65536*e[4]+256*e[5]+e[6])/0x20000000000000},o=()=>Math.floor(s()*(Number.MAX_SAFE_INTEGER-Number.MIN_SAFE_INTEGER+1))+Number.MIN_SAFE_INTEGER,rs.of({[ra]:ra,randomBytes:e=>{let t,r;return U.TjK((t="randomBytes",Number.isSafeInteger(r=e)&&r>=0?U.PyW(r):U.fJG(ei({module:"Crypto",method:t,description:"size must be a non-negative safe integer"}))),a)},nextDoubleUnsafe:s,nextIntUnsafe:o,digest:P.digest,random:U.OH5(()=>s()),randomBoolean:U.OH5(()=>s()>.5),randomInt:U.OH5(()=>o()),randomBetween:(e,t)=>U.OH5(()=>s()*(t-e)+e),randomIntBetween(e,t,r){let n=+(r?.halfOpen!==!0);return U.OH5(()=>{let r=Math.ceil(e),i=Math.floor(t);return Math.floor(s()*(i-r+n))+r})},randomShuffle:e=>U.OH5(()=>{let t=Array.from(e);for(let e=t.length-1;e>=1;e-=1){let r=Math.min(e,Math.floor(s()*(e+1))),n=t[e];t[e]=t[r],t[r]=n}return t}),randomUUIDv4:U.OH5(()=>{let e;return(e=a(16))[6]=15&e[6]|64,e[8]=63&e[8]|128,rl(e)}),randomUUIDv7:U.RKA(e=>{var t,r;let n;return U.PyW((t=e.currentTimeMillisUnsafe(),r=a(16),n=Math.min(Math.max(0,Math.trunc(t)),rc),r[0]=Math.floor(n/0x10000000000),r[1]=255&Math.floor(n/0x100000000),r[2]=255&Math.floor(n/0x1000000),r[3]=255&Math.floor(n/65536),r[4]=255&Math.floor(n/256),r[5]=255&n,r[6]=15&r[6]|112,r[8]=63&r[8]|128,rl(r)))})})),rf=X.Py(rs,rd),rh=t("node:fs"),rp=t("node:os"),rm=t("node:path");var rg=n.t(rm,2);let ry=e=>t=>ei({module:"FileSystem",method:e,description:t.message??String(t)}),rb=(l=(0,U._r7)(rh.access,tH("FileSystem","access"),ry("access")),(e,t)=>{let r=rh.constants.F_OK;return t?.readable&&(r|=rh.constants.R_OK),t?.writable&&(r|=rh.constants.W_OK),l(e,r)}),rv=(c=(0,U._r7)(rh.cp,tH("FileSystem","copy"),ry("copy")),(e,t,r)=>c(e,t,{force:r?.overwrite??!1,preserveTimestamps:r?.preserveTimestamps??!1,recursive:!0})),rw=(u=(0,U._r7)(rh.copyFile,tH("FileSystem","copyFile"),ry("copyFile")),(e,t)=>u(e,t)),rx=(d=(0,U._r7)(rh.chmod,tH("FileSystem","chmod"),ry("chmod")),(e,t)=>d(e,t)),r_=(f=(0,U._r7)(rh.chown,tH("FileSystem","chown"),ry("chown")),(e,t,r)=>f(e,t,r)),rk=(h=(0,U._r7)(rh.glob,tH("FileSystem","glob"),ry("glob")),(e,t)=>h(e,{cwd:t?.root,exclude:t?.exclude})),rS=(p=(0,U._r7)(rh.link,tH("FileSystem","link"),ry("link")),(e,t)=>p(e,t)),r$=(m=(0,U._r7)(rh.mkdir,tH("FileSystem","makeDirectory"),ry("makeDirectory")),(e,t)=>m(e,{recursive:t?.recursive??!1,mode:t?.mode})),rE=e=>{let t=(0,U._r7)(rh.mkdtemp,tH("FileSystem",e),ry(e));return e=>U.DYE(()=>{let r=e?.prefix??"",n="string"==typeof e?.directory?rm.join(e.directory,"."):rp.tmpdir();return t(r?rm.join(n,r):n+"/")})},rO=rE("makeTempDirectory"),rI=e=>{let t=(0,U._r7)(rh.rm,tH("FileSystem",e),ry(e));return(e,r)=>t(e,{recursive:r?.recursive??!1,force:r?.force??!1})},rA=rI("remove"),rC=(g=rE("makeTempDirectoryScoped"),y=rI("makeTempDirectoryScoped"),e=>U.Q56(g(e),e=>U.QgK(y(e,{recursive:!0})))),rT=(j="open",b=(0,U._r7)(rh.open,tH("FileSystem",j),ry(j)),v=(0,U._r7)(rh.close,tH("FileSystem",j),ry(j)),(e,t)=>(0,F.Fs)(U.Q56(b(e,t?.flag??"r",t?.mode),e=>U.QgK(v(e))),U.TjK(e=>rN(tk(e),t?.flag?.startsWith("a")??!1)))),rN=(()=>{let e=e=>(0,U._r7)(rh.read,tH("FileSystem",e),ry(e)),t=e("read"),r=e("readAlloc"),n=(0,U._r7)(rh.fstat,tH("FileSystem","stat"),ry("stat")),i=(0,U._r7)(rh.ftruncate,tH("FileSystem","truncate"),ry("truncate")),a=(0,U._r7)(rh.fsync,tH("FileSystem","sync"),ry("sync")),s=e=>(0,U._r7)(rh.write,tH("FileSystem",e),ry(e)),o=s("write"),l=s("writeAll");class c{[t_];fd;append;position=BigInt(0);constructor(e,t){this[t_]=t_,this.fd=e,this.append=t}get stat(){return U.TjK(n(this.fd),rB)}get sync(){return a(this.fd)}seek(e,t){let r=tw(e);return U.OH5(()=>("start"===t?this.position=r:"current"===t&&(this.position=this.position+r),this.position))}read(e){return U.DYE(()=>{let r=this.position;return U.TjK(t(this.fd,{buffer:e,position:r}),e=>{let t=tw(e);return this.position=r+t,t})})}readAlloc(e){let t=Number(e);return U.DYE(()=>{let e=Buffer.allocUnsafeSlow(t),n=this.position;return U.TjK(r(this.fd,{buffer:e,position:n}),r=>{if(0===r)return K.none();if(this.position=n+BigInt(r),r===t)return K.some(e);let i=Buffer.allocUnsafeSlow(r);return e.copy(i,0,0,r),K.some(i)})})}truncate(e){return U.TjK(i(this.fd,e?Number(e):void 0),()=>{if(!this.append){let t=BigInt(e??0);this.position>t&&(this.position=t)}})}write(e){return U.DYE(()=>{let t=this.position;return U.TjK(o(this.fd,e,void 0,void 0,this.append?void 0:Number(t)),e=>{let r=tw(e);return this.append||(this.position=t+r),r})})}writeAllChunk(e){return U.DYE(()=>{let t=this.position;return U.qIB(l(this.fd,e,void 0,void 0,this.append?void 0:Number(t)),r=>0===r?U.fJG(en({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)):U.rIH))})}writeAll(e){return this.writeAllChunk(e)}}return(e,t)=>new c(e,t)})(),rM=e=>{let t=rE(e);return U.D9k(function*(e){let r=yield*t(e),n=ru.randomBytes(6).toString("hex"),i=rm.join(r,e?.suffix?`${n}${e.suffix}`:n);return yield*rJ(i,new Uint8Array(0)),i})},rP=rM("makeTempFile"),rj=(w=rM("makeTempFileScoped"),x=rI("makeTempFileScoped"),e=>U.Q56(w(e),e=>U.QgK(x(rm.dirname(e),{recursive:!0})))),rD=(e,t)=>U.$mh({try:()=>rh.promises.readdir(e,t),catch:t=>tH("FileSystem","readDirectory")(t,[e])}),rU=e=>U.E2r((t,r)=>{try{rh.readFile(e,{signal:r},(r,n)=>{r?t(U.fJG(tH("FileSystem","readFile")(r,[e]))):t(U.PyW(n))})}catch(e){t(U.fJG(ry("readFile")(e)))}}),rR=(_=(0,U._r7)(rh.readlink,tH("FileSystem","readLink"),ry("readLink")),e=>_(e)),rF=(k=(0,U._r7)(rh.realpath,tH("FileSystem","realPath"),ry("realPath")),e=>k(e)),rL=(S=(0,U._r7)(rh.rename,tH("FileSystem","rename"),ry("rename")),(e,t)=>S(e,t)),rB=e=>({type:e.isFile()?"File":e.isDirectory()?"Directory":e.isSymbolicLink()?"SymbolicLink":e.isBlockDevice()?"BlockDevice":e.isCharacterDevice()?"CharacterDevice":e.isFIFO()?"FIFO":e.isSocket()?"Socket":"Unknown",mtime:K.fromNullishOr(e.mtime),atime:K.fromNullishOr(e.atime),birthtime:K.fromNullishOr(e.birthtime),dev:e.dev,rdev:K.fromNullishOr(e.rdev),ino:K.fromNullishOr(e.ino),mode:e.mode,nlink:K.fromNullishOr(e.nlink),uid:K.fromNullishOr(e.uid),gid:K.fromNullishOr(e.gid),size:tw(e.size),blksize:void 0!==e.blksize?K.some(tw(e.blksize)):K.none(),blocks:K.fromNullishOr(e.blocks)}),rY=($=(0,U._r7)(rh.stat,tH("FileSystem","stat"),ry("stat")),e=>U.TjK($(e),rB)),rq=(E=(0,U._r7)(rh.symlink,tH("FileSystem","symlink"),ry("symlink")),(e,t)=>E(e,t)),rW=(O=(0,U._r7)(rh.truncate,tH("FileSystem","truncate"),ry("truncate")),(e,t)=>O(e,void 0!==t?Number(t):void 0)),rX=(I=(0,U._r7)(rh.utimes,tH("FileSystem","utime"),ry("utime")),(e,t,r)=>I(e,t,r)),rJ=(e,t,r)=>U.E2r((n,i)=>{try{rh.writeFile(e,t,{signal:i,flag:r?.flag,mode:r?.mode},t=>{t?n(U.fJG(tH("FileSystem","writeFile")(t,[e]))):n(U.rIH)})}catch(e){n(U.fJG(ry("writeFile")(e)))}}),rz=U.TjK(U.Nav(tS),e=>{let t;return t={access:rb,chmod:rx,chown:r_,copy:rv,copyFile:rw,glob:rk,link:rS,makeDirectory:r$,makeTempDirectory:rO,makeTempDirectoryScoped:rC,makeTempFile:rP,makeTempFileScoped:rj,open:rT,readDirectory:rD,readFile:rU,readLink:rR,realPath:rF,remove:rA,rename:rL,stat:rY,symlink:rq,truncate:rW,utimes:rX,watch:t=>rY(t).pipe(U.TjK(r=>e.pipe(K.flatMap(e=>e.register(t,r)),K.getOrElse(()=>{var e;let r;return to((r=e=>U.Q56(U.OH5(()=>{let r=rh.watch(t,{recursive:!0},(t,r)=>{if(r)switch(t){case"rename":return void U.MY7(U.tvg(rY(r),{onSuccess:t=>eb(e,{_tag:"Create",path:r}),onFailure:t=>eb(e,{_tag:"Remove",path:r})}));case"change":return void ev(e,{_tag:"Update",path:r})}});return r.on("error",r=>{ex(e,D.fJ(en({module:"FileSystem",_tag:"Unknown",method:"watch",pathOrDescriptor:t,cause:r})))}),r.on("close",()=>{e_(e)}),r}),e=>U.OH5(()=>e.close())),eW((t,n)=>U.TjK(ey({capacity:e?.bufferSize,strategy:e?.strategy}).pipe(U.Mim(e=>eL.U9(n,ek(e))),U.Mim(e=>U.ar0(eL.Gt(r(e),n),n))),eS))))}))),tf),writeFile:rJ},tx.of({...t,[tv]:tv,exists:e=>(0,F.Fs)(t.access(e),U.as(!0),U.KuX("PlatformError",e=>"NotFound"===e.reason._tag?U.PyW(!1):U.fJG(e))),readFileString:(e,r)=>U.qIB(t.readFile(e),e=>U.SvU({try:()=>new TextDecoder(r).decode(e),catch:e=>ei({module:"FileSystem",method:"readFileString",description:"invalid encoding",cause:e})})),stream:U.D9k(function*(e,r){let n=yield*t.open(e,{flag:"r"});r?.offset&&(yield*n.seek(r.offset,"start"));let i=r?.bytesToRead!==void 0?tw(r.bytesToRead):void 0,a=BigInt(0),s=tw(r?.chunkSize??65536),o=n.readAlloc(s);return to(eJ(U.PyW(U.qIB(U.DYE(()=>void 0!==i&&i<=a?D.Vw():void 0!==i&&i-a<s?n.readAlloc(i-a):o),K.match({onNone:()=>D.Vw(),onSome:e=>(a+=BigInt(e.length),U.PyW(z.of(e)))})))))},tf),sink:(e,r)=>(0,F.Fs)(t.open(e,{flag:"w",...r}),U.TjK(e=>{let t,r;return t=t=>e.writeAll(t),r=U.jJl(e=>t(e),{discard:!0}),tt(e=>e.pipe(U.qIB(r),U.i4r({disableYield:!0}),eo.m8(()=>e4)))}),ti),writeFileString:(e,r,n)=>U.qIB(U.SvU({try:()=>new TextEncoder().encode(r),catch:e=>ei({module:"FileSystem",method:"writeFileString",description:"could not encode string",cause:e})}),r=>t.writeFile(e,r,n))})}),rK=X.QZ(tx)(rz),rV=t("node:url"),rG=e=>U.SvU({try:()=>rV.fileURLToPath(e),catch:e=>new ee({module:"Path",method:"fromFileUrl",cause:e})}),rH=e=>U.SvU({try:()=>rV.pathToFileURL(e),catch:e=>new ee({module:"Path",method:"toFileUrl",cause:e})});rm.posix,rm.win32;let rQ=X.Py(tE)({[t$]:t$,...rg,fromFileUrl:rG,toFileUrl:rH}),rZ="~effect/Stdio",r0=H.kl(rZ),r1=X.Py(r0,{[rZ]:rZ,...{args:U.OH5(()=>process.argv.slice(2)),stdout:e=>tQ({evaluate:()=>process.stdout,onError:e=>en({module:"Stdio",method:"stdout",_tag:"Unknown",cause:e}),endOnDone:e?.endOnDone??!1}),stderr:e=>tQ({evaluate:()=>process.stderr,onError:e=>en({module:"Stdio",method:"stderr",_tag:"Unknown",cause:e}),endOnDone:e?.endOnDone??!1}),stdin:t8({evaluate:()=>process.stdin,onError:e=>en({module:"Stdio",method:"stdin",_tag:"Unknown",cause:e}),closeOnDone:!1})}});var r2=n(2302);class r5{waiters=new Set;taken=0;permits;constructor(e){this.permits=e}get free(){return this.permits-this.taken}take(e){let t=ec.DYE(()=>this.free<e?ec.E2r(r=>{if(this.free>=e)return r(t);let n=()=>{this.free<e||(this.waiters.delete(n),r(t))};return this.waiters.add(n),ec.OH5(()=>{this.waiters.delete(n)})}):(this.taken+=e,ec.PyW(e)));return t}updateTakenUnsafe(e,t){return this.taken=t(this.taken),this.waiters.size>0&&e.currentDispatcher.scheduleTask(()=>{let e=this.waiters.values(),t=e.next();for(;!1===t.done&&this.free>0;)t.value(),t=e.next()},0),this.free}updateTaken(e){return el.R6(t=>ec.PyW(this.updateTakenUnsafe(t,e)))}resize(e){return el.R6(t=>(this.permits=e,this.free<0||this.updateTakenUnsafe(t,e=>e),ec.rIH))}release(e){return this.updateTaken(t=>t-e)}get releaseAll(){return this.updateTaken(e=>0)}withPermits(e){return t=>ec.FcF(r=>ec.qIB(r(this.take(e)),e=>ec.r7h(r(t),()=>{this.updateTakenUnsafe(ec.Iku(),t=>t-e)},!0)))}withPermit=this.withPermits(1);withPermitsIfAvailable(e){return t=>ec.FcF(r=>this.free<e?ec.lwU:(this.taken+=e,ec.r7h(r(ec.Xx$(t)),()=>{this.updateTakenUnsafe(ec.Iku(),t=>t-e)},!0)))}}let r3={_tag:"Empty"},r6={_tag:"Closed"},r8={_A:F.D_,_E:F.D_};class r4{"~effect/RcRef"=r8;pipe(){return(0,ea.tT)(this,arguments)}state=r3;semaphore=(e=>new r5(e))(1);acquire;context;scope;idleTimeToLive;constructor(e,t,r,n){this.acquire=e,this.context=t,this.scope=r,this.idleTimeToLive=n}}let r9=U.D9k(function*(e){let t=yield*U.FcF(t=>{switch(e.state._tag){case"Closed":return U.GaK;case"Acquired":return e.state.refCount++,e.state.fiber?U.as(t1(e.state.fiber),e.state):U.PyW(e.state);case"Empty":{let r=eL.LZ();return e.semaphore.withPermits(1)(t(U.PpN(e.acquire,H.WQ(e.context,eL.HG,r))).pipe(U.TjK(t=>{let n={_tag:"Acquired",value:t,scope:r,fiber:void 0,refCount:1,invalidated:!1};return e.state=n,n})))}}}),r=yield*U.z8E,n=void 0!==e.idleTimeToLive&&r2.MI(e.idleTimeToLive);return yield*eL.a6(r,()=>(t.refCount--,t.refCount>0)?U.rIH:void 0===e.idleTimeToLive?(e.state=r3,eL.VN(t.scope,R.rI)):t.invalidated?eL.VN(t.scope,R.rI):n?(t.fiber=U.yy4(e.idleTimeToLive).pipe(U.qIB(()=>"Acquired"===e.state._tag&&0===e.state.refCount?(e.state=r3,eL.VN(t.scope,R.rI)):U.rIH),U.yeE(U.OH5(()=>{t.fiber=void 0})),U.eJC(e.context),t2(e.scope)),U.rIH):U.rIH),t.value});var r7=n(8861);let ne="~effect/platform/Terminal",nt="effect/platform/Terminal/QuitError";class nr extends r7.PSP("QuitError")({_tag:r7.TcI("QuitError")}){[nt]=nt}let nn=H.kl("effect/platform/Terminal"),ni=t("node:readline"),na=U.D9k(function*(e=no){let t,r,n=process.stdin,i=process.stdout,a=yield*(t={acquire:U.Q56(U.OH5(()=>{let e=ni.createInterface({input:n,escapeCodeTimeout:50});return ni.emitKeypressEvents(n,e),n.isTTY&&n.setRawMode(!0),e}),e=>U.OH5(()=>{n.isTTY&&n.setRawMode(!1),e.close()}))},U.R6R(e=>{let r=e.context,n=H.Jt(r,eL.HG),i=new r4(t.acquire,r,n,t.idleTimeToLive?r2.bN(t.idleTimeToLive):void 0);return U.as(eL.a6(n,()=>{let e="Acquired"===i.state._tag?eL.VN(i.state.scope,R.rI):U.rIH;return i.state=r6,e}),i)})),s=U.OH5(()=>i.columns??0),o=U.OH5(()=>i.rows??0),l=U.JkU(function*(){yield*r9(a);let t=yield*ey(),r=(r,n)=>{let i={input:K.fromUndefinedOr(r),key:{name:n.name??"",ctrl:!!n.ctrl,meta:!!n.meta,shift:!!n.shift}};ev(t,i),e(i)&&e_(t)};return yield*U.U9h(()=>U.OH5(()=>n.off("keypress",r))),n.on("keypress",r),t});return r={columns:s,rows:o,readInput:l,readLine:U.P1j(U.qIB(r9(a),e=>U.E2r(t=>{let r=e=>t(U.PyW(e));return e.once("line",r),U.OH5(()=>e.off("line",r))}))),display:e=>U.rfi(U.E2r(t=>{i.write(e,e=>es.uy(e)?t(U.rIH):t(U.fJG(ei({module:"Terminal",method:"display",description:"Failed to write prompt to stdout",cause:e}))))}))},nn.of({...r,[ne]:ne})}),ns=X.QZ(nn,na(no));function no(e){return e.key.ctrl&&("c"===e.key.name||"d"===e.key.name)}let nl=X.S5(rn,X.Um(rK,rf,rQ,r1,ns));var nc=n(5810),nu=n(6030);class nd extends r7.X0d()("CliFilesystemError",{cause:r7.kld(),operation:r7.QfV,path:r7.QfV,message:r7.QfV}){}class nf extends r7.X0d()("CliInputError",{code:r7.xCb(["input_read_failed","invalid_json","interactive_stdin"]),message:r7.QfV,hint:r7.QfV}){}class nh extends r7.X0d()("CliValidationError",{message:r7.QfV,hint:r7.QfV,details:r7.O31(r7.QfV)}){}class np extends r7.X0d()("CliBuildError",{status:r7.QfV,message:r7.QfV,hint:r7.QfV,details:r7.O31(r7.QfV)}){}class nm extends r7.X0d()("CliGenerationError",{code:r7.xCb(["provider_failure","generation_timeout","malformed_output","invalid_generated_document"]),message:r7.QfV,hint:r7.QfV,details:r7.O31(r7.QfV)}){}class ng extends r7.X0d()("CliStorageError",{code:r7.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:r7.Qrq(r7.QfV),message:r7.QfV,hint:r7.QfV}){}class ny extends r7.X0d()("CliShareError",{code:r7.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:r7.QfV,hint:r7.QfV,details:r7.O31(r7.QfV)}){}class nb extends r7.X0d()("CliExportError",{code:r7.xCb(["format_unavailable","invalid_destination","render_failed","export_write_failed"]),format:r7.QfV,message:r7.QfV,hint:r7.QfV}){}function nv(e){return"string"==typeof e||"number"==typeof e||"symbol"==typeof e}let nw=nu.ID(),nx=r7._Re(nc.Ky,{errors:"all"}),n_=r7._Re(nc.e5,{errors:"all"});function nk(e){return nh.make({message:"The canonical diagram document is invalid.",hint:'Use {"type":"flowchart","spec":...} or {"type":"mindmap","spec":...}.',details:e})}function nS(e){return nw(e).issues.map(e=>{var t;let r=(e.path??[]).flatMap(e=>{let t=nv(e)?e:null!==e&&"object"==typeof e&&"key"in e&&nv(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}`})}let n$=U.fn("sketchi.cli.document.decodeCanonical")(function*(e){let t=function(e){if(!("object"!=typeof e||null===e||Array.isArray(e))&&"type"in e&&"spec"in e)return{type:e.type,spec:e.spec}}(e);return t?"flowchart"===t.type?{type:"flowchart",spec:yield*nx(t.spec).pipe(U.xm_(e=>nk(nS(e.issue))))}:"mindmap"===t.type?{type:"mindmap",spec:yield*n_(t.spec).pipe(U.xm_(e=>nk(nS(e.issue))))}:yield*nk(['document.type: Expected "flowchart" or "mindmap".']):yield*nk(["document: Expected an object with type and spec."])}),nE=U.fn("sketchi.cli.document.parseJson")(function*(e){let t=yield*U.SvU({try:()=>JSON.parse(e),catch:()=>nf.make({code:"invalid_json",message:"The input is not valid JSON.",hint:"Pass one complete canonical document object."})});return yield*n$(t)});function nO(e){return`${JSON.stringify(e,null,2)}
|
|
3
|
+
`}function nI(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 nA(e){return/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}$/.test(e)?U.PyW(e):U.fJG(nh.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 nC extends H.kl()("@sketchi/cli/DiagramBuilder"){}function nT(e){let t=e.ref?.path?` (${e.ref.path})`:"";return`${e.code}${t}: ${e.message}`}function nN(e,t){let r=e.formats.find(e=>e.format===t);return r?.inline!==void 0?U.PyW(r.inline):U.fJG(np.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 nM(e){let t=nc.Uh.safeParse(e);return t.success?U.PyW(t.data):U.fJG(np.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 nP(e){let t=nc.yE.safeParse(e);return t.success?U.PyW(t.data):U.fJG(np.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 nj=X.QZ(nC,U.JkU(function*(){let e=yield*nc.Ov,t=yield*nc.UA;return{build:U.fn("sketchi.cli.diagram.build")(function*(r){let n;if(!(n="flowchart"===r.type?yield*(0,nc.XV)({spec:r.spec,options:{artifactFormats:["scene","excalidraw"],inlineArtifacts:["scene","excalidraw"]}}).pipe(U.PfK(nc.Ov,e),U.PfK(nc.UA,t)):yield*(0,nc.r8)({spec:r.spec,options:{artifactFormats:["scene","excalidraw"],inlineArtifacts:["scene","excalidraw"]}}).pipe(U.PfK(nc.Ov,e),U.PfK(nc.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(nT),"invalid_input"===n.status||"invalid_flowchart"===n.status||"invalid_mindmap"===n.status||"quality_failed"===n.status?nh.make({message:t,hint:r,details:i}):"storage_failed"===n.status?ng.make({code:"storage_commit_failed",message:t,hint:r}):np.make({status:n.status,message:t,hint:r,details:i}))}let i=yield*nA(nI(r)),a=yield*nN(n.artifact,"scene").pipe(U.qIB(nM)),s=yield*nN(n.artifact,"excalidraw").pipe(U.qIB(nP));return{id:i,type:r.type,title:r.spec.title,document:r,scene:a,excalidraw:s}})}})),nD=1,nU="manifest.json",nR="document.json",nF="scene.json",nL="diagram.excalidraw",nB="diagram.png",nY="revisions";class nq extends r7.Xsx("DiagramRecordManifest")({schemaVersion:r7.uSQ(nD),id:r7.QfV,type:r7.xCb(["flowchart","mindmap"]),title:r7.QfV,revision:r7.Aiz.check(r7.yJO(0)),authority:r7.xCb(["canonical","patched","detached"]).pipe(r7.E$i(U.PyW("canonical"))),formats:r7.O31(r7.xCb(["scene","excalidraw","png"]))}){}function nW(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 nX(e){return String(e).padStart(6,"0")}class nJ extends r7.X0d()("HeadlessPngRenderError",{cause:r7.kld(),message:r7.QfV}){}class nz extends H.kl()("@sketchi/cli/CliPngRenderer"){}let nK=X.Py(nz,{renderPng:function(e){return U.$mh({try:async()=>(await Promise.all([n.e(831),n.e(869)]).then(n.bind(n,7665))).renderPngBytes(e),catch:e=>nJ.make({cause:e,message:"Unable to render the stored Excalidraw artifact as PNG."})})},normalizeExcalidraw:function(e){return U.$mh({try:async()=>(await Promise.all([n.e(831),n.e(869)]).then(n.bind(n,7665))).normalizeExcalidrawArtifact(e),catch:e=>nJ.make({cause:e,message:"Unable to restore the Excalidraw share artifact."})})}}),nV=t("node:zlib");var nG=n(3587);let nH=t("node:fs/promises");class nQ extends H.kl()("@sketchi/cli/LocalFileSystem"){}function nZ(e,t,r){return nd.make({cause:r,operation:e,path:t,message:`Filesystem ${e} failed for ${t}.`})}function n0(e,t){return"object"==typeof e&&null!==e&&"code"in e&&e.code===t}let n1=X.Py(nQ,{makeDirectory:(e,t=!1)=>U.$mh({try:()=>(0,nH.mkdir)(e,{recursive:t}).then(()=>void 0),catch:t=>nZ("make-directory",e,t)}),tryWriteText:(e,t)=>U.$mh({try:async()=>{try{let r=await (0,nH.open)(e,rh.constants.O_WRONLY|rh.constants.O_CREAT|rh.constants.O_EXCL|rh.constants.O_NOFOLLOW,384);try{await r.writeFile(t,{encoding:"utf8"}),await r.sync()}finally{await r.close()}return!0}catch(e){if(n0(e,"EEXIST"))return!1;throw e}},catch:t=>nZ("write-exclusive",e,t)}),tryLinkFile:(e,t)=>U.$mh({try:async()=>{try{return await (0,nH.link)(e,t),!0}catch(e){if(n0(e,"EEXIST")||n0(e,"ENOENT"))return!1;throw e}},catch:r=>nZ("link-exclusive",`${e} -> ${t}`,r)}),makeTempDirectory:(e,t)=>U.$mh({try:()=>(0,nH.mkdtemp)((0,rm.join)(e,t)),catch:t=>nZ("make-temp-directory",e,t)}),list:e=>U.$mh({try:async()=>(await (0,nH.readdir)(e,{withFileTypes:!0})).map(e=>({name:e.name,kind:e.isFile()?"file":e.isDirectory()?"directory":e.isSymbolicLink()?"symbolic-link":"other"})),catch:t=>nZ("read-directory",e,t)}),kind:e=>U.$mh({try:async()=>{try{let t=await (0,nH.lstat)(e);if(t.isFile())return"file";if(t.isDirectory())return"directory";if(t.isSymbolicLink())return"symbolic-link";return"other"}catch(e){if(n0(e,"ENOENT"))return"missing";if(n0(e,"ELOOP"))return"symbolic-link";throw e}},catch:t=>nZ("stat",e,t)}),realPath:e=>U.$mh({try:()=>(0,nH.realpath)(e),catch:t=>nZ("resolve",e,t)}),readText:e=>U.$mh({try:async()=>{let t=await (0,nH.open)(e,rh.constants.O_RDONLY|rh.constants.O_NOFOLLOW);try{return await t.readFile({encoding:"utf8"})}finally{await t.close()}},catch:t=>nZ("read",e,t)}),readBytes:e=>U.$mh({try:async()=>{let t=await (0,nH.open)(e,rh.constants.O_RDONLY|rh.constants.O_NOFOLLOW);try{return new Uint8Array(await t.readFile())}finally{await t.close()}},catch:t=>nZ("read",e,t)}),writeText:(e,t,r=!1)=>U.$mh({try:async()=>{let n=rh.constants.O_WRONLY|rh.constants.O_CREAT|rh.constants.O_NOFOLLOW|(r?rh.constants.O_TRUNC:rh.constants.O_EXCL),i=await (0,nH.open)(e,n,384);try{await i.writeFile(t,{encoding:"utf8"}),await i.sync()}finally{await i.close()}},catch:t=>nZ("write",e,t)}),writeBytes:(e,t,r=!1)=>U.$mh({try:async()=>{let n=rh.constants.O_WRONLY|rh.constants.O_CREAT|rh.constants.O_NOFOLLOW|(r?rh.constants.O_TRUNC:rh.constants.O_EXCL),i=await (0,nH.open)(e,n,384);try{await i.writeFile(t),await i.sync()}finally{await i.close()}},catch:t=>nZ("write",e,t)}),rename:(e,t)=>U.$mh({try:()=>(0,nH.rename)(e,t),catch:r=>nZ("rename",`${e} -> ${t}`,r)}),tryRenameDirectory:(e,t)=>U.$mh({try:async()=>{try{return await (0,nH.rename)(e,t),!0}catch(e){if(n0(e,"EEXIST")||n0(e,"ENOTEMPTY"))return!1;if(n0(e,"EPERM"))try{if((await (0,nH.lstat)(t)).isDirectory())return!1}catch{}throw e}},catch:r=>nZ("rename-exclusive-directory",`${e} -> ${t}`,r)}),removeFile:e=>U.$mh({try:async()=>{try{return await (0,nH.unlink)(e),!0}catch(e){if(n0(e,"ENOENT"))return!1;throw e}},catch:t=>nZ("remove-file",e,t)}),remove:e=>U.$mh({try:()=>(0,nH.rm)(e,{recursive:!0,force:!0}),catch:t=>nZ("remove",e,t)})});var n2=n(8689),n5=n(5030);let n3="https://json.excalidraw.com/api/v2/",n6=["rectangle","ellipse","diamond","arrow","line","freedraw","text"],n8=new Set(n6),n4=new TextEncoder,n9=new TextDecoder("utf-8",{fatal:!0}),n7=n4.encode(JSON.stringify({version:2,compression:"pako@1",encryption:"AES-GCM"}));function ie(e,t,r,n=[]){return ny.make({code:e,message:t,hint:r,details:n})}function it(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function ir(e){return"number"==typeof e&&Number.isFinite(e)}function ii(e,t,r){new DataView(e.buffer,e.byteOffset,e.byteLength).setUint32(t,r)}function ia(e,t){if(t+4>e.byteLength)throw Error("truncated chunk header");return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint32(t)}function is(e,t){if(e.byteLength<4+4*t||1!==ia(e,0))throw Error("unsupported chunk format");let r=[],n=4;for(let i=0;i<t;i+=1){let t=ia(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 io(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 il(e,t){return crypto.subtle.importKey("raw",Uint8Array.from(io(e)),{name:"AES-GCM",length:128},!1,[t])}function ic(e){if(!it(e)||"excalidraw"!==e.type||!ir(e.version)||"string"!=typeof e.source||!Array.isArray(e.elements)||!it(e.appState)||!(void 0===e.files||it(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 iu(e,t){return"string"!=typeof e||!t.has(e)}function id(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=id(r,`${t} item`);if(e)return e}else if(it(e))for(let r of Object.values(e)){let e=id(r,`${t} property`);if(e)return e}}function ih(e){return U.SvU({try:()=>{let t=ic(e);if(it(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(!it(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(!it(e)||"string"!=typeof e.id||0===e.id.length||"string"!=typeof e.type)return`elements[${String(t)}] is not an Excalidraw element`;if(!n8.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=id(e,n);if(i)return i;for(let t of["x","y","width","height","angle"])if(!ir(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||!ir(e[0])||!ir(e[1]))))return`${n}.points contains invalid geometry`;for(let t of["containerId","frameId"])if(null!==e[t]&&void 0!==e[t]&&iu(e[t],r))return`${n}.${t} is an invalid element reference`;for(let t of["startBinding","endBinding"]){let i=e[t];if(null!=i&&(!it(i)||iu(i.elementId,r)))return`${n}.${t} is an invalid element binding`}let a=e.boundElements;if(null!=a&&(!Array.isArray(a)||a.some(e=>!it(e)||iu(e.id,r))))return`${n}.boundElements contains an invalid element reference`}(n,e,r);if(t)throw Error(t)}let n=(0,n5.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]&&!ir(e[t]))return`appState.${t} must be finite or null`;if("lockedMultiSelections"in e){let t=e.lockedMultiSelections;if(!it(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 id(e,"appState")}(t.appState);if(i)throw Error(i);return e},catch:e=>ie("unsupported_scene","The Excalidraw scene is unsupported by share/pull v1.",`Use only ${n6.join(", ")} elements, Excalifont fontFamily ${String(5)}, and no files or images.`,[e instanceof Error?e.message:"invalid scene"])})}function ip(e){let t=new Uint8Array(4);return ii(t,0,e),t}class im extends H.kl()("@sketchi/cli/StorageRoot"){}function ig(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}let iy=[[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 ib(e,t,r){return e<=t?0:Math.ceil((e-t)/r)}function iv(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,c=!1,u=!1,d=!1,f=[];for(;o+12<=e.byteLength;){let s=ig(e,o),h=o+12+s;if(h>e.byteLength)break;let p=o+4,m=e.subarray(p,p+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=ig(e,o+8),r=ig(e,o+12),i=e[o+16],n=e[o+17],a=e[o+20];let c={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||!c[n]?.includes(i)||0!==e[o+18]||0!==e[o+19]||![0,1].includes(a??-1))break}else if("PLTE"===y){if(c||u||0===s||s%3!=0||s>768||0===n||4===n||3===n&&void 0!==i&&s/3>2**i)return!1;c=!0}else if("IDAT"===y){if(d||3===n&&!c)return!1;u=!0,f.push(e.subarray(o+8,o+8+s))}else if("IEND"===y){if(0!==s||!u||3===n&&!c)break}else{u&&(d=!0);let t=e[p];if(void 0===t||(32&t)==0)break}let b=ig(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(p,o+8+s))!==b)break;if(o=h,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,c]of 0===n?[[0,0,1,1]]:iy){let n=ib(e,s,l),u=ib(t,o,c);if(0===n||0===u)continue;let d=Math.ceil(n*r/8)+1;if(d>0x1000000-a||u>Math.floor((0x1000000-a)/d))return null;a+=u*d,i.push({rows:u,rowBytes:d})}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,nV.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 iw extends H.kl()("@sketchi/cli/DiagramStore"){}let ix=".locks",i_="free.",ik="owner.",iS=".owner-candidate.",i$=".json",iE="recovery",iO=".backup.",iI=`.stage.${String(process.pid)}.`,iA=nG.ji("10 millis").pipe(nG.jB({times:50})),iC=X.Py(im,{path:(0,rm.join)((0,rp.homedir)(),".sketchi","diagrams")});function iT(e,t,r,n){return ng.make({code:e,message:t,hint:r,...n?{diagramId:n}:{}})}function iN(e){return Buffer.from(e,"utf8").toString("base64url")}function iM(e,t){return e<t?-1:+(e>t)}function iP(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:iM(r,n)||iM(e,t)}function ij(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 iD(e,t){return"object"==typeof e.cause&&null!==e.cause&&"code"in e.cause&&e.cause.code===t}function iU(e,t){return(0,rm.join)(e,t)}function iR(e){switch(e){case"scene":return nF;case"excalidraw":return nL;case"png":return nB}}function iF(e,t){return iT("unsafe_storage_entry",`Unsafe local storage entry at ${e}.`,"Replace symbolic links or special files with ordinary Sketchi record files.",t)}let iL=X.QZ(iw,U.JkU(function*(){let e=yield*nQ,t=yield*im,r=U.fn("sketchi.cli.storage.ensureOwnedDirectory")(function*(t){let r=yield*e.kind(t);if("missing"===r&&(yield*e.makeDirectory(t).pipe(U.MfU(e=>iD(e,"EEXIST")?U.rIH:U.fJG(e))),r=yield*e.kind(t)),"directory"!==r)return yield*iF(t)}),n=U.fn("sketchi.cli.storage.ensureRoot")(function*(){yield*r((0,rm.dirname)(t.path)),yield*r(t.path),yield*r((0,rm.join)(t.path,ix))}),i=U.fn("sketchi.cli.storage.assertSafeTree")(function*(t,r){for(let n of yield*e.list(t)){let e=(0,rm.join)(t,n.name);if("symbolic-link"===n.kind||"other"===n.kind)return yield*iF(e,r);"directory"===n.kind&&(yield*i(e,r))}}),a=U.fn("sketchi.cli.storage.recoverStages")(function*(){for(let r of(yield*n(),[...yield*e.list(t.path)].sort((e,t)=>iM(e.name,t.name)))){if(!r.name.startsWith(".stage."))continue;let n=function(e){let t=Number(e.split(".").at(-2));return Number.isSafeInteger(t)?t:void 0}(r.name);void 0!==n&&ij(n)||(yield*e.remove((0,rm.join)(t.path,r.name)))}}),s=U.fn("sketchi.cli.storage.recoverRecordTransactions")(function*(r){yield*n(),yield*a();let i=`${iO}${iN(r)}.`;for(let n of[...yield*e.list(t.path)].filter(e=>e.name.startsWith(i)).sort((e,t)=>iM(e.name,t.name))){let i=(0,rm.join)(t.path,n.name),a=iU(t.path,r);"missing"===(yield*e.kind(a))?yield*e.rename(i,a):yield*e.remove(i)}}),o=U.fn("sketchi.cli.storage.initializeLockDirectory")(function*(r){let n=(0,rm.join)(t.path,ix,`${iN(r)}.lock`),i=yield*e.kind(n);if("directory"===i)return n;if("missing"!==i)return yield*iF(n,r);let a=(0,rm.join)(t.path,ix);return yield*U.jGc(e.makeTempDirectory(a,`.init.${iN(r)}.`),t=>U.JkU(function*(){let i=crypto.randomUUID();return(yield*e.writeText((0,rm.join)(t,`${i_}${i}${i$}`),nO({token:i})),(yield*e.tryRenameDirectory(t,n))||"directory"===(yield*e.kind(n)))?n:yield*iF(n,r)}),t=>e.remove(t))}),l=e=>iT("diagram_busy",`Diagram "${e}" is being changed by another Sketchi process.`,"Wait for that command to finish, then retry.",e),c=U.fn("sketchi.cli.storage.readLockEntries")(function*(t,r){let n=[...yield*e.list(t)].sort((e,t)=>iM(e.name,t.name)),i=[];for(let a of n){let n=(0,rm.join)(t,a.name);if("file"!==a.kind)return yield*iF(n,r);let s=function(e){if(!e.startsWith(i_)||!e.endsWith(i$))return;let t=e.slice(i_.length,-i$.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(i_))return yield*iF(n,r);let o=function(e){if(!e.startsWith(iS)||!e.endsWith(i$))return;let t=e.slice(iS.length,-i$.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(iS)||!a.name.startsWith(ik)||!a.name.endsWith(i$))return yield*iF(n,r);let c=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(U.xm_(e=>iD(e,"ENOENT")?l(r):e))));if(!c)return yield*l(r);if(a.name!==`${ik}${c.token}${i$}`)return yield*iF(n,r);i.push({name:a.name,path:n,token:c.token,state:ij(c.pid)?"live-owner":"stale-owner"})}return i}),u=U.fn("sketchi.cli.storage.acquireLockOnce")(function*(t){yield*n();let r=yield*o(t),i=yield*c(r,t),a=new Set(i.flatMap(e=>e.releasedOwnerToken?[e.releasedOwnerToken]:[]));if(i.some(e=>"live-owner"===e.state&&!a.has(e.token)))return yield*l(t);let s=i.find(e=>"free"===e.state)??i.find(e=>"stale-owner"===e.state);if(!s){let n=(0,rm.join)(r,`${i_}${iE}${i$}`);if(!(yield*e.tryWriteText(n,nO({token:iE}))))return yield*l(t);s={name:`${i_}${iE}${i$}`,path:n,state:"free",token:iE}}let u=crypto.randomUUID(),d=(0,rm.join)(r,`${ik}${u}${i$}`),f=(0,rm.join)(r,`${iS}${u}${i$}`);return yield*U.rfi(U.jGc(U.PyW(f),()=>U.JkU(function*(){if(yield*e.writeText(f,nO({pid:process.pid,token:u})),!(yield*e.tryLinkFile(f,d)))return yield*l(t);if(!(yield*e.removeFile(s.path).pipe(U.MfU(t=>e.removeFile(d).pipe(U.hgn(U.fJG(t)))))))return yield*e.removeFile(d),yield*l(t);for(let t of i)t.path!==s.path&&(yield*e.removeFile(t.path).pipe(U.MfU(()=>U.rIH)));return{directory:r,ownerPath:d,token:u}}),t=>e.removeFile(t).pipe(U.MfU(()=>U.rIH))))}),d=U.fn("sketchi.cli.storage.releaseLock")(function*(t,r){let n=crypto.randomUUID(),i=(0,rm.join)(r.directory,`${i_}${n}.${r.token}${i$}`),a=nO({token:n,releasedOwnerToken:r.token});if(!(yield*e.writeText(i,a).pipe(U.as(!0),U.MfU(()=>e.tryWriteText(i,a).pipe(U.qIB(t=>t?U.PyW(!0):e.kind(i).pipe(U.TjK(e=>"file"===e))),U.MfU(()=>U.PyW(!1))))))){if(yield*e.removeFile(r.ownerPath))return;return yield*iT("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(U.YWq({onFailure:()=>!0,onSuccess:e=>e}))))return yield*e.removeFile(i).pipe(U.MfU(()=>U.rIH)),yield*iT("storage_commit_failed",`Diagram "${t}" lock ownership changed before release.`,"Retry after the active Sketchi command finishes.",t)}),f=(e,t,r=!1)=>{let n;return U.jGc((n=u(e),r?n.pipe(U.L5P({schedule:iA,while:e=>"CliStorageError"===e._tag&&"diagram_busy"===e.code})):n),()=>s(e).pipe(U.hgn(t)),t=>d(e,t).pipe(U.MfU(()=>U.rIH)))},h=U.fn("sketchi.cli.storage.decodeManifest")(function*(t,r){let n=yield*e.readText(t),i=yield*U.SvU({try:()=>JSON.parse(n),catch:()=>iT("corrupt_record",`Diagram "${r}" has an invalid manifest.`,"Inspect manifest.json and restore it from a known-good backup.",r)});return yield*r7._Re(nq)(i).pipe(U.xm_(()=>iT("corrupt_record",`Diagram "${r}" has an incompatible manifest.`,`Expected manifest schema version ${String(1)}.`,r)))}),p=U.fn("sketchi.cli.storage.decodeDocument")(function*(t,r){let n=yield*e.readText(t),i=yield*U.SvU({try:()=>JSON.parse(n),catch:()=>iT("corrupt_record",`Diagram "${r}" has invalid document JSON.`,"Recover a prior canonical document from the revisions directory.",r)});return yield*n$(i).pipe(U.xm_(()=>iT("corrupt_record",`Diagram "${r}" has an invalid canonical document.`,"Recover a prior canonical document from the revisions directory.",r)))}),m=U.fn("sketchi.cli.storage.loadUnlocked")(function*(r){let n=iU(t.path,r),a=yield*e.kind(n);if("missing"===a)return yield*iT("diagram_not_found",`Diagram "${r}" does not exist.`,"Run sketchi list to discover stored diagram ids.",r);if("directory"!==a)return yield*iF(n,r);yield*i(n,r);let s=yield*h((0,rm.join)(n,nU),r);if(s.id!==r)return yield*iT("corrupt_record",`Diagram directory "${r}" contains manifest id "${s.id}".`,"Make the directory name and manifest id agree before retrying.",r);let o=yield*p((0,rm.join)(n,nR),r);if(s.type!==o.type||s.title!==o.spec.title)return yield*iT("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[nF,nL])if((yield*e.kind((0,rm.join)(n,t)))!=="file")return yield*iT("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,rm.join)(n,nB));if("file"!==l&&"missing"!==l)return yield*iF((0,rm.join)(n,nB),r);if("file"===l&&!iv((yield*e.readBytes((0,rm.join)(n,nB)))))return yield*iT("corrupt_record",`Diagram "${r}" has an invalid stored PNG artifact.`,"Recover a valid prior revision or rebuild the record.",r);let c="detached"===s.authority?"file"===l?["excalidraw","png"]:["excalidraw"]:"file"===l?["scene","excalidraw","png"]:["scene","excalidraw"];if(s.formats.length!==c.length||s.formats.some((e,t)=>e!==c[t]))return yield*iT("corrupt_record",`Diagram "${r}" manifest formats do not match stored artifacts.`,"Recover the canonical document and rebuild the record with sketchi edit.",r);let u=(0,rm.join)(n,nY),d=[];for(let t of yield*e.list(u)){if("file"===t.kind&&/^\d{6,}\.json$/u.test(t.name)){d.push(t.name);continue}if("directory"===t.kind&&/^\d{6,}$/u.test(t.name)){d.push(`${t.name}/`);continue}return yield*iF((0,rm.join)(u,t.name),r)}return d.sort(iP),{manifest:s,document:o,revisions:d,authority:s.authority,documentAuthoritative:"canonical"===s.authority}}),g=U.fn("sketchi.cli.storage.copySafeTree")(function*(t,r,n){for(let i of yield*e.list(t)){let a=(0,rm.join)(t,i.name),s=(0,rm.join)(r,i.name);if("directory"===i.kind)yield*e.makeDirectory(s),yield*g(a,s,n);else{if("file"!==i.kind)return yield*iF(a,n);let t=yield*e.readBytes(a);yield*e.writeBytes(s,t)}}}),y=U.fn("sketchi.cli.storage.copyRecordSnapshot")(function*(t,r,n){for(let i of(yield*e.makeDirectory(r),yield*e.list(t))){if(i.name===nY)continue;let a=(0,rm.join)(t,i.name),s=(0,rm.join)(r,i.name);if("file"!==i.kind)return yield*iF(a,n);yield*e.writeBytes(s,(yield*e.readBytes(a)))}}),b=U.fn("sketchi.cli.storage.commitStage")(function*(r,n){let i=iU(t.path,r),a=(0,rm.join)(t.path,`${iO}${iN(r)}.${String(process.pid)}.${crypto.randomUUID()}`);yield*e.rename(i,a),(yield*e.rename(n,i).pipe(U.tvg({onFailure:t=>e.rename(a,i).pipe(U.tvg({onFailure:()=>U.fJG(iT("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:()=>U.fJG(t)})),onSuccess:()=>U.PyW(!0)})))&&(yield*e.remove(a).pipe(U.MfU(()=>U.rIH)))}),v=U.fn("sketchi.cli.storage.snapshotCurrent")(function*(r,n,i){let a=(0,rm.join)(n,nY,nX(i));if((yield*e.kind(a))!=="missing")return yield*iT("corrupt_record",`Diagram "${r}" already has a snapshot for current revision ${String(i)}.`,"Inspect the revisions directory before retrying.",r);yield*y(iU(t.path,r),a,r)}),w=U.fn("sketchi.cli.storage.writeBuilt")(function*(t,r,n){yield*e.makeDirectory((0,rm.join)(t,nY),!0),yield*e.writeText((0,rm.join)(t,nR),nO(r.document),!0),yield*e.writeText((0,rm.join)(t,nF),nO(r.scene),!0),yield*e.writeText((0,rm.join)(t,nL),nO(r.excalidraw),!0);let i=(0,rm.join)(t,nB);yield*e.remove(i),r.png&&(yield*e.writeBytes(i,r.png)),yield*e.writeText((0,rm.join)(t,nU),nO(n),!0)}),x=U.fn("sketchi.cli.storage.create")(function*(r){return yield*f(r.id,U.JkU(function*(){let n=iU(t.path,r.id);if((yield*e.kind(n))!=="missing")return yield*iT("diagram_already_exists",`Diagram "${r.id}" already exists.`,"Use sketchi edit for full-document replacement.",r.id);let i=nq.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*U.jGc(e.makeTempDirectory(t.path,iI),t=>U.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))}))}),_=U.fn("sketchi.cli.storage.edit")(function*(r,n){return yield*f(r,U.JkU(function*(){let i=yield*m(r);if("canonical"!==i.authority)return yield*iT("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*iT("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=iU(t.path,r),s=nq.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*U.jGc(e.makeTempDirectory(t.path,iI),e=>U.JkU(function*(){return yield*g(a,e,r),yield*v(r,e,i.manifest.revision),yield*w(e,n,s),yield*b(r,e),{manifest:s,document:n.document,revisions:[...i.revisions,`${nX(i.manifest.revision)}/`].sort(iP),authority:"canonical",documentAuthoritative:!0}}),t=>e.remove(t))}))}),k=e=>iT("patch_source_unavailable",`Diagram "${e}" has no current authoritative scene to patch.`,"Restore a canonical or patched revision before patching this diagram.",e),S=U.fn("sketchi.cli.storage.readPatchSourceUnlocked")(function*(r){let n=yield*m(r);if("detached"===n.authority||!n.manifest.formats.includes("scene"))return yield*k(r);let i=(0,rm.join)(iU(t.path,r),nF),a=yield*e.readText(i),s=yield*U.OH5(()=>{try{return nc.Uh.safeParse(JSON.parse(a))}catch{return}});return s?.success&&s.data.diagramId===r?{revision:n.manifest.revision,scene:s.data}:yield*iT("corrupt_record",`Diagram "${r}" has an invalid current scene artifact.`,"Restore a valid prior revision before patching this diagram.",r)}),$=U.fn("sketchi.cli.storage.readPatchSource")(e=>f(e,S(e),!0)),E=U.fn("sketchi.cli.storage.commitPatch")(function*(r,n,i){return yield*f(r,U.JkU(function*(){let a=yield*m(r);if(a.manifest.revision!==n)return yield*iT("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*k(r);if(i.scene.diagramId!==r)return yield*iT("storage_commit_failed",`Patched scene id "${i.scene.diagramId}" does not match "${r}".`,"Retry the patch against the named stored diagram.",r);let s=iU(t.path,r),o=nq.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*U.jGc(e.makeTempDirectory(t.path,iI),t=>U.JkU(function*(){return yield*g(s,t,r),yield*v(r,t,a.manifest.revision),yield*e.writeText((0,rm.join)(t,nF),nO(i.scene),!0),yield*e.writeText((0,rm.join)(t,nL),nO(i.excalidraw),!0),yield*e.remove((0,rm.join)(t,nB)),yield*e.writeText((0,rm.join)(t,nU),nO(o),!0),yield*b(r,t),{manifest:o,document:a.document,revisions:[...a.revisions,`${nX(a.manifest.revision)}/`].sort(iP),authority:"patched",documentAuthoritative:!1}}),t=>e.remove(t))}))}),O=(e,t)=>iT("corrupt_revision",`Diagram "${e}" revision ${String(t)} is corrupt.`,"Choose another revision or repair the corrupt snapshot.",e),I=U.fn("sketchi.cli.storage.validateArchivedJson")(function*(t,r,n){let i=yield*e.readText(t);return yield*U.SvU({try:()=>{let e=JSON.parse(i);if("object"!=typeof e||null===e)throw Error("archived JSON must contain an object");return e},catch:()=>O(r,n)})}),A=U.fn("sketchi.cli.storage.validateArchivedArtifact")(function*(e,t,r,n,i){let a=yield*I(e,n,i);if(!("scene"===t?nc.Uh.safeParse(a):nc.yE.safeParse(a)).success)return yield*O(n,i);"excalidraw"===t&&"detached"===r&&(yield*ih(a).pipe(U.xm_(()=>O(n,i))))}),C=U.fn("sketchi.cli.storage.validateArchivedPng")(function*(t,r,n){if(!iv((yield*e.readBytes(t))))return yield*O(r,n)}),T=U.fn("sketchi.cli.storage.readRevisionUnlocked")(function*(r,n){yield*m(r);let a=(0,rm.join)(iU(t.path,r),nY),s=(0,rm.join)(a,nX(n)),o=yield*e.kind(s);if("directory"===o){yield*i(s,r);let t=yield*h((0,rm.join)(s,nU),r).pipe(U.xm_(()=>O(r,n))),a=yield*p((0,rm.join)(s,nR),r).pipe(U.xm_(()=>O(r,n)));if(t.id!==r||t.revision!==n||t.type!==a.type||t.title!==a.spec.title)return yield*iT("corrupt_revision",`Diagram "${r}" revision ${String(n)} has inconsistent metadata.`,"Choose another revision or repair the corrupt snapshot.",r);for(let[i,a]of[[nF,"scene"],[nL,"excalidraw"]]){let o=(0,rm.join)(s,i);if((yield*e.kind(o))!=="file")return yield*iT("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(U.xm_(e=>"CliFilesystemError"===e._tag?O(r,n):e))}let o=yield*e.kind((0,rm.join)(s,nB));if("file"!==o&&"missing"!==o)return yield*iF((0,rm.join)(s,nB),r);"file"===o&&(yield*C((0,rm.join)(s,nB),r,n).pipe(U.xm_(e=>"CliFilesystemError"===e._tag?O(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*iT("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*iF(s,r);let l=(0,rm.join)(a,`${String(n).padStart(6,"0")}.json`),c=yield*e.kind(l);if("missing"===c)return yield*iT("revision_not_found",`Diagram "${r}" has no revision ${String(n)}.`,"Run sketchi show to inspect the available revision paths.",r);if("file"!==c)return yield*iF(l,r);let u=yield*p(l,r).pipe(U.xm_(e=>"CliStorageError"===e._tag?iT("corrupt_revision",`Diagram "${r}" revision ${String(n)} is corrupt.`,"Choose another revision or repair the legacy revision file.",r):e));return{_tag:"LegacyDocument",revision:n,document:u}}),N=U.fn("sketchi.cli.storage.replaceWithDetached")(function*(r,n,i){return yield*f(r,U.JkU(function*(){let a=yield*m(r);if(void 0!==i&&a.manifest.revision!==i)return yield*iT("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=iU(t.path,r),o=nq.make({schemaVersion:1,id:r,type:a.manifest.type,title:a.manifest.title,revision:a.manifest.revision+1,authority:"detached",formats:["excalidraw"]});return yield*U.jGc(e.makeTempDirectory(t.path,iI),t=>U.JkU(function*(){return yield*g(s,t,r),yield*v(r,t,a.manifest.revision),yield*e.writeBytes((0,rm.join)(t,nL),n,!0),yield*e.remove((0,rm.join)(t,nB)),yield*e.writeText((0,rm.join)(t,nU),nO(o),!0),yield*b(r,t),{manifest:o,document:a.document,revisions:[...a.revisions,`${nX(a.manifest.revision)}/`].sort(iP),authority:"detached",documentAuthoritative:!1}}),t=>e.remove(t))}))}),M=U.fn("sketchi.cli.storage.readRevision")((e,t)=>f(e,T(e,t),!0)),P=U.fn("sketchi.cli.storage.restore")(function*(r,n,i){return yield*f(r,U.JkU(function*(){let a=yield*m(r),s=yield*T(r,n);if("LegacyDocument"===s._tag){if("canonical"!==a.authority||!i)return yield*iT("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||nO(i.document)!==nO(s.document))return yield*iT("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=iU(t.path,r);return yield*U.jGc(e.makeTempDirectory(t.path,iI),t=>U.JkU(function*(){yield*g(o,t,r),yield*v(r,t,a.manifest.revision);let l=[...a.revisions,`${nX(a.manifest.revision)}/`].sort(iP),c=yield*"FullSnapshot"===s._tag?U.JkU(function*(){let i=(0,rm.join)(t,nY,nX(n));for(let r of yield*e.list(t))r.name!==nY&&(yield*e.remove((0,rm.join)(t,r.name)));yield*g(i,t,r);let s=(0,rm.join)(t,nU),o=yield*e.readText(s);yield*h(s,r);let c=yield*p((0,rm.join)(t,nR),r),u=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 c=t+1;for(;/\s/u.test(e[c]??"");)c+=1;if(":"!==e[c])continue;for(c+=1;/\s/u.test(e[c]??"");)c+=1;let u=/^-?\d+/u.exec(e.slice(c));if(!u)return;let d=c+u[0].length,f=d;for(;/\s/u.test(e[f]??"");)f+=1;if(","!==e[f]&&"}"!==e[f]||-1!==n)return;n=c,i=d}return -1===n?void 0:`${e.slice(0,n)}${String(t)}${e.slice(i)}`}(o,a.manifest.revision+1);if(void 0===u)return yield*O(r,n);yield*e.writeText(s,u,!0);let d=yield*h(s,r);return{manifest:d,document:c,revisions:l,authority:d.authority,documentAuthoritative:"canonical"===d.authority}}):U.JkU(function*(){if(!i)return yield*iT("storage_commit_failed",`Legacy revision ${String(n)} has no rebuilt document.`,"Rebuild the archived canonical document before restoring.",r);let e=nq.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*b(r,t),{diagram:c,restoredFromRevision:n}}),t=>e.remove(t))}))}),j=U.fn("sketchi.cli.storage.show")(e=>f(e,m(e),!0)),D=U.fn("sketchi.cli.storage.list")(function*(){yield*n(),yield*a();let r=new Set;for(let n of yield*e.list(t.path)){if("directory"===n.kind&&!n.name.startsWith(".")){r.add(n.name);continue}if(!n.name.startsWith(iO))continue;let e=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}}(n.name.split(".")[2]??"");e&&r.add(e)}let i=[];for(let e of[...r].sort(iM)){let t=yield*j(e);i.push(nW(t))}return i});return{create:x,edit:_,readPatchSource:$,commitPatch:E,replaceWithDetached:N,readRevision:M,restore:P,show:j,list:D,readExportSource:U.fn("sketchi.cli.storage.readExportSource")(function*(r,n){return yield*f(r,U.JkU(function*(){let i=yield*m(r);if(i.manifest.formats.includes(n))return{_tag:"StoredArtifact",bytes:yield*e.readBytes((0,rm.join)(iU(t.path,r),iR(n)))};if("png"!==n)return yield*nb.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,rm.join)(iU(t.path,r),iR("excalidraw")))};for(let e of["scene","excalidraw"])if(!i.manifest.formats.includes(e))return yield*nb.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*U.Q7R([e.readBytes((0,rm.join)(iU(t.path,r),iR("scene"))),e.readBytes((0,rm.join)(iU(t.path,r),iR("excalidraw")))]);return{_tag:"RenderPng",scene:a,excalidraw:s}}),!0)})}})),iB=U.fn("sketchi.cli.export.writeFile")(function*(e,t){let r=yield*nQ,n=yield*im,i=(0,rm.resolve)(e),a=(0,rm.dirname)(i),s=()=>nb.make({code:"export_write_failed",format:(0,rm.basename)(e),message:`Export destination directory does not exist: ${a}.`,hint:"Create the destination directory and retry."}),o=yield*r.realPath(a).pipe(U.xm_(s));if((yield*r.kind(o))!=="directory")return yield*s();let l=yield*r.realPath(n.path),c=(0,rm.join)(o,(0,rm.basename)(i)),u=(0,rm.relative)(l,c);if(""===u||!u.startsWith("..")&&!(0,rm.isAbsolute)(u))return yield*nb.make({code:"invalid_destination",format:(0,rm.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 d=(0,rm.join)(o,`.${(0,rm.basename)(e)}.sketchi.${String(process.pid)}.${crypto.randomUUID()}`);return yield*U.jGc(U.PyW(d),n=>r.writeBytes(n,t).pipe(U.hgn(r.rename(n,c)),U.xm_(()=>nb.make({code:"export_write_failed",format:(0,rm.basename)(e),message:`Unable to write export destination ${e}.`,hint:"Check the destination path and permissions, then retry."}))),e=>r.remove(e))});class iY extends H.kl()("@sketchi/cli/DiagramExporter"){}function iq(){return nb.make({code:"render_failed",format:"png",message:"Unable to render the stored diagram as PNG.",hint:"Verify the stored scene and Excalidraw artifacts, then retry."})}function iW(e){return U.SvU({try:()=>JSON.parse(new TextDecoder().decode(e)),catch:iq})}let iX=X.QZ(iY,U.JkU(function*(){let e=yield*iw,t=yield*nz,r=U.fn("sketchi.cli.export.renderPng")(function*(e){let r=yield*iW(e.excalidraw),n=nc.yE.safeParse(r);if(!n.success)return yield*iq();let i=e.scene?nc.Uh.safeParse((yield*iW(e.scene))):void 0;if(i&&!i.success)return yield*iq();let a=yield*t.renderPng({...i?.success?{scene:i.data}:{},excalidraw:n.data}).pipe(U.xm_(iq));return a instanceof Uint8Array?a:new Uint8Array(a)});return{exportArtifact:U.fn("sketchi.cli.export.artifact")(function*(t,n){let i=yield*e.readExportSource(t,n);return"StoredArtifact"===i._tag?i.bytes:yield*r(i)})}})),iJ="gemini-3.1-flash-lite",iz="https://playground.sketchi.app/api/v1/generate",iK="SKETCHI_GENERATE_ENDPOINT";function iV(){return nm.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 iG(){return nm.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 iH(){return nm.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 iQ=U.fn("sketchi.cli.generate.request")(function*(e){let t=yield*U.$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,type:e.type,model:e.model}),signal:t}),catch:()=>iV()}),r=yield*U.$mh({try:()=>t.text(),catch:()=>iV()});if(!t.ok)return yield*U.fJG(function(e,t){let r=function(e){try{let t=JSON.parse(e);return null!==t&&"object"==typeof t?t:{}}catch{return{}}}(t),n=r.issues?.[0],i=[`http_status:${String(e)}`];switch(r.status){case"generation_timeout":return nm.make({code:"generation_timeout",message:n?.message??"The generate API timed out.",hint:n?.hint??"Retry once; if it persists, try a shorter prompt.",details:i});case"malformed_output":return nm.make({code:"malformed_output",message:n?.message??"The generate API returned unreadable model output.",hint:n?.hint??"Retry once; if it persists, try another prompt.",details:i});case"invalid_input":case"invalid_generated_document":case"quality_failed":return nm.make({code:"invalid_generated_document",message:n?.message??"The generated diagram failed Sketchi validation.",hint:n?.hint??"Refine the prompt with concrete content, then retry.",details:i});default:return nm.make({code:"provider_failure",message:n?.message??`The Sketchi generate API responded with HTTP ${String(e)}.`,hint:n?.hint??"Retry once; if it persists, report the prompt without secrets.",details:i})}}(t.status,r));let n=function(e){let t;try{t=JSON.parse(e)}catch{return}if(null===t||"object"!=typeof t)return;let r=t;if(!0===r.ok&&r.diagram&&void 0!==r.diagram.document&&void 0!==r.diagram.scene&&void 0!==r.diagram.excalidraw)return{document:r.diagram.document,scene:r.diagram.scene,excalidraw:r.diagram.excalidraw,model:"string"==typeof r.generation?.model?r.generation.model:"",provider:"string"==typeof r.generation?.provider?r.generation.provider:"cloudflare-google-ai-studio"}}(r);return n||(yield*U.fJG(iG()))}),iZ=U.fn("sketchi.cli.generate")(function*(e){var t,r;let n,i,a=yield*iw,s=yield*iQ(e),o=yield*n$(s.document).pipe(U.xm_(()=>iH())),l=yield*nA(nI(o)).pipe(U.xm_(()=>iH())),c=yield*(t=s.scene,(n=nc.Uh.safeParse(t)).success?U.PyW(n.data):U.fJG(iG())),u=yield*(r=s.excalidraw,(i=nc.yE.safeParse(r)).success?U.PyW(i.data):U.fJG(iG())),d={id:l,type:o.type,title:o.spec.title,document:o,scene:c,excalidraw:u};return{diagram:yield*a.create(d),model:s.model||e.model,provider:s.provider}}),i0=ec.z4N,i1=e=>el.R6(t=>e(t.getRef(i0))),i2=(...e)=>i1(t=>ec.OH5(()=>{t.error(...e)})),i5=(...e)=>i1(t=>ec.OH5(()=>{t.log(...e)})),i3="~effect/cli/CliError";class i6 extends r7.X0d(`${i3}/UnrecognizedOption`)("UnrecognizedOption",{option:r7.QfV,command:r7.lqM(r7.O31(r7.QfV)),suggestions:r7.O31(r7.QfV)}){[i3]=i3;get message(){let e=this.suggestions.length>0?`
|
|
4
4
|
|
|
5
5
|
Did you mean this?
|
|
6
|
-
${this.suggestions.join("\n ")}`:"";return(this.command?`Unrecognized flag: ${this.option} in command ${this.command.join(" ")}`:`Unrecognized flag: ${this.option}`)+e}}class i8 extends r7.X0d(`${
|
|
6
|
+
${this.suggestions.join("\n ")}`:"";return(this.command?`Unrecognized flag: ${this.option} in command ${this.command.join(" ")}`:`Unrecognized flag: ${this.option}`)+e}}class i8 extends r7.X0d(`${i3}/DuplicateOption`)("DuplicateOption",{option:r7.QfV,parentCommand:r7.QfV,childCommand:r7.QfV}){[i3]=i3;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 i4 extends r7.X0d(`${i3}/MissingOption`)("MissingOption",{option:r7.QfV}){[i3]=i3;get message(){return`Missing required flag: --${this.option}`}}class i9 extends r7.X0d(`${i3}/MissingArgument`)("MissingArgument",{argument:r7.QfV}){[i3]=i3;get message(){return`Missing required argument: ${this.argument}`}}class i7 extends r7.X0d(`${i3}/InvalidValue`)("InvalidValue",{option:r7.QfV,value:r7.QfV,expected:r7.QfV,kind:r7.gPz([r7.uSQ("flag"),r7.uSQ("argument")])}){[i3]=i3;get message(){return"argument"===this.kind?`Invalid value for argument <${this.option}>: "${this.value}". Expected: ${this.expected}`:0===this.value.length?`Missing value for flag --${this.option}. Expected: ${this.expected}`:`Invalid value for flag --${this.option}: "${this.value}". Expected: ${this.expected}`}}class ae extends r7.X0d(`${i3}/UnknownSubcommand`)("UnknownSubcomand",{subcommand:r7.QfV,parent:r7.lqM(r7.O31(r7.QfV)),suggestions:r7.O31(r7.QfV)}){[i3]=i3;get message(){let e=this.suggestions.length>0?`
|
|
7
7
|
|
|
8
8
|
Did you mean this?
|
|
9
|
-
${this.suggestions.join("\n ")}`:"";return this.parent?`Unknown subcommand "${this.subcommand}" for "${this.parent.join(" ")}"${e}`:`Unknown subcommand "${this.subcommand}"${e}`}}class at extends r7.X0d(`${
|
|
9
|
+
${this.suggestions.join("\n ")}`:"";return this.parent?`Unknown subcommand "${this.subcommand}" for "${this.parent.join(" ")}"${e}`:`Unknown subcommand "${this.subcommand}"${e}`}}class at extends r7.X0d(`${i3}/UserError`)("UserError",{cause:r7.kld()}){[i3]=i3}let ar=r7.gPz([i6,i8,i4,i9,i7,ae,at]);class an extends r7.X0d(`${i3}/ShowHelp`)("ShowHelp",{commandPath:r7.O31(r7.QfV),errors:r7.O31(ar)}){[i3]=i3;[B]=+!!this.errors.length;[q]=!1;get message(){return"Help requested"}}n(2532),n(3176),n(2976);let ai=H.Or("effect/ConfigProvider",{defaultValue:()=>(function(){var e;let t,r,n=(void 0)??{...globalThis?.process?.env,...import.meta?.env},i=false,a=function(e){let t={};for(let[r,n]of Object.entries(e)){if(void 0===n)continue;let e=r.split("_"),i=t;for(let t of e)i.children??={},i=i.children[t]??={}}return t}(n);return t={_tag:"Source",get:e=>U.PyW(function(e,t,r,n){var i;let a=(i=t[r.map(String).join("_")],""!==i||n?i:void 0),s=function(e,t){if(0===t.length)return e;let r=e;for(let e of t)if(!(r=r?.children?.[String(e)]))return;return r}(e,r),o=s?.children?Object.keys(s.children):[];return 0===o.length?void 0===a?void 0:{_tag:"Value",value:a}:o.every(e=>ao.test(e))?{_tag:"Array",length:Math.max(...o.map(e=>parseInt(e,10)))+1,value:a}:{_tag:"Record",keys:new Set(o),value:a}}(a,n,e,i)),transform:as},e=e=>t.get(t.transform(e)),(r=Object.create(aa)).state=t,r.load=e,r})()}),aa={...el.fU,toJSON:()=>({_id:"ConfigProvider"})},as=e=>e,ao=/^(0|[1-9][0-9]*)$/;ec.LkF,ec.OPA;var al=n(5348);let ac=r7.xCb(["true","yes","on","1","y"]),au=r7.xCb(["false","no","off","0","n"]),ad=r7.xCb([...ac.literals,...au.literals]).pipe(r7.GLL(r7.v8c,al.pd({decode:e=>"true"===e||"yes"===e||"on"===e||"1"===e||"y"===e,encode:e=>e?"true":"false"})));var af=n(6470);let ah={"~effect/cli/Primitive":{_A:F.D_}},ap=r7.is(ac),am=r7.is(au),ag=e=>"Boolean"===e._tag,ay=(e,t)=>Object.assign(Object.create(ah),{_tag:e,parse:t}),ab=(e,t)=>{let r=r7.lHk(t),n=r7._Re(r);return ay(e,e=>U.xm_(n(e),e=>e.message))},av=ab("Boolean",ad);r7.wYs;let aw=ab("Integer",r7.Aiz);r7.Nej;let ax=ay("String",e=>U.PyW(e)),a_=(()=>U.fJG("This option does not accept values"),e=>{switch(e._tag){case"Boolean":return"boolean";case"String":case"Redacted":return"string";case"Integer":return"integer";case"Float":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"None":return"none";default:return"value"}}),ak=e=>"Choice"===e._tag?e.choiceKeys:void 0,aS="~effect/cli/Param",a$="argument",aE={[aS]:{_A:F.D_},pipe(){return(0,ea.tT)(this,arguments)}},aO=e=>"flag"===e.kind,aI=e=>Object.assign(Object.create(aE),{_tag:"Single",...e,description:e.description??K.none(),aliases:e.aliases??[],hidden:e.hidden??!1,parse:t=>e.kind===a$?aY(e.name,e.primitiveType,t):aq(e.name,e.primitiveType,t)}),aA=(e,t)=>aI({name:t,primitiveType:ax,kind:e}),aC=(e,t,r)=>{let n,i;return aI({name:t,primitiveType:(n=new Map(r),i=r.map(([e])=>(0,af.GP)(e)).join(" | "),Object.assign(ay("Choice",e=>n.has(e)?U.PyW(n.get(e)):U.fJG(`Expected ${i}, got ${(0,af.GP)(e)}`)),{choiceKeys:r.map(([e])=>e)})),kind:e})},aT=/^-+/,aN=(0,F.XY)(2,(e,t)=>az(e,e=>aI({...e,aliases:[...e.aliases,t.replace(aT,"")]}))),aM=(0,F.XY)(2,(e,t)=>az(e,e=>aI({...e,description:K.some(t)}))),aP=(0,F.XY)(2,(e,t)=>Object.assign(Object.create(aE),{_tag:"Map",kind:e.kind,param:e,f:t,parse:r=>U.TjK(e.parse(r),([e,r])=>[e,t(r)])})),aj=(e,t)=>Object.assign(Object.create(aE),{_tag:"Transform",kind:e.kind,param:e,f:t,parse:t(e.parse)}),aD=(0,F.XY)(2,(e,t)=>aj(e,e=>r=>U.qIB(e(r),([e,r])=>t(r).pipe(U.TjK(t=>[e,t]))))),aU=e=>{let t=U.D9k(function*(t){let r=aV(e);return aO(r)&&ag(r.primitiveType)&&![r.name,...r.aliases].some(e=>(t.flags[e]??[]).length>0)?[t.arguments,K.none()]:yield*e.parse(t).pipe(U.TjK(([e,t])=>[e,K.some(t)]),U.loE({MissingOption:()=>U.PyW([t.arguments,K.none()]),MissingArgument:()=>U.PyW([t.arguments,K.none()])}))});return Object.assign(Object.create(aE),{_tag:"Optional",kind:e.kind,param:e,parse:t})},aR=(0,F.XY)(2,(e,t)=>U.yw5(t)?aD(aU(e),K.match({onNone:()=>t,onSome:U.PyW})):aP(aU(e),K.getOrElse(()=>t))),aF=(0,F.XY)(3,(e,t,r)=>aD(e,U.D9k(function*(n){let i=t(n);if(K.isSome(i))return i.value;let a=aV(e);return yield*new i7({option:a.name,value:String(n),expected:r(n),kind:a.kind})}))),aL=(0,F.XY)(3,(e,t,r)=>aF(e,K.liftPredicate(t),r)),aB=(0,F.XY)(2,(e,t)=>az(e,e=>aI({...e,typeName:t}))),aY=U.D9k(function*(e,t,r){if(0===r.arguments.length)return yield*new i9({argument:e});let n=r.arguments[0],i=yield*U.xm_(t.parse(n),t=>new i7({option:e,value:n,expected:t,kind:"argument"}));return[r.arguments.slice(1),i]}),aq=U.D9k(function*(e,t,r){let n=r.flags[e];if(void 0===n||0===n.length)if(ag(t))return[r.arguments,!1];else return yield*new i4({option:e});let i=n[0],a=yield*U.xm_(t.parse(i),t=>new i7({option:e,value:i,expected:t,kind:"flag"}));return[r.arguments,a]}),aW=U.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*new i7({option:t.name,value:`${o} values`,expected:`at least ${a} value${1===a?"":"s"}`,kind:t.kind}):[l,i]}),aX=U.D9k(function*(e,t,r,n){let i=[],a=[t.name,...t.aliases].flatMap(e=>r.flags[e]??[]),s=a.length;if(es.EA(n?.min)&&s<n.min)return yield*0===s?new i4({option:t.name}):new i7({option:t.name,value:`${s} occurrences`,expected:`at least ${n.min} value${1===n.min?"":"s"}`,kind:t.kind});if(es.EA(n?.max)&&s>n.max)return yield*new i7({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]}),aJ=(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)}},az=(e,t)=>aJ(e,{Single:e=>t(e),Map:e=>aP(az(e.param,t),e.f),Transform:e=>aj(az(e.param,t),e.f),Optional:e=>aU(az(e.param,t)),Variadic:e=>{var r,n;let i;return r=az(e.param,t),n={min:K.getOrUndefined(e.min),max:K.getOrUndefined(e.max)},i=aV(r),Object.assign(Object.create(aE),{_tag:"Variadic",kind:r.kind,param:r,min:K.fromUndefinedOr(n?.min),max:K.fromUndefinedOr(n?.max),parse:e=>"argument"===i.kind?aW(r,i,e,n):aX(r,i,e,n)})}}),aK=e=>aJ(e,{Single:e=>[e],Map:e=>aK(e.param),Transform:e=>aK(e.param),Optional:e=>aK(e.param),Variadic:e=>aK(e.param)}),aV=e=>{let t=aK(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]},aG=e=>aJ(e,{Single:()=>({isOptional:!1,isVariadic:!1,variadicMin:K.none(),variadicMax:K.none()}),Map:e=>aG(e.param),Transform:e=>aG(e.param),Optional:e=>({...aG(e.param),isOptional:!0}),Variadic:e=>({...aG(e.param),isVariadic:!0,variadicMin:e.min,variadicMax:e.max})});var aH=n(3864);let aQ=H.Or("effect/cli/CliOutput",{defaultValue:()=>aZ()}),aZ=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!=="1",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=>a5(e,i),formatCliError:e=>e.message,formatError:e=>`
|
|
10
10
|
${o}${s}ERROR${a}
|
|
11
11
|
${e.message}${a}`,formatErrors:e=>{if(0===e.length)return"";if(1===e.length)return`
|
|
12
12
|
${o}${s}ERROR${a}
|
|
13
13
|
${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(`
|
|
14
|
-
${o}${s}ERRORS${a}`),t))for(let t of e)r.push(` ${t.message}${a}`);return r.join("\n")},formatVersion:(e,t)=>`${i.bold(e)} ${i.dim("v")}${i.bold(t)}`}},a0=e=>e.replace(/\u001B\[[0-9;]*m/g,"").length,a1=(e,t)=>{let r=Math.max(...e.map(e=>a0(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,n-a0(e)),e+" ".repeat(r)}${t}`}).join("\n")},a2=(e,t)=>t?`${e}, ${t}`:e,a3=(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:K.getOrElse(e.description,()=>"")+s}});r.push(a1(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:K.getOrElse(e.description,()=>"")}});r.push(a1(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:K.getOrElse(e.description,()=>"")}});r.push(a1(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(a1(n.commands.map(e=>({left:t.cyan(a2(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(a1(i.commands.map(e=>({left:t.cyan(a2(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")},a5=e=>e.replace(/[^a-zA-Z0-9_]/g,"_"),a6=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},a8=e=>{switch(e._tag){case"Boolean":default:return;case"Choice":return`COMPREPLY=( $(compgen -W '${e.values.join(" ")}' -- "$cur") )`;case"Path":if("directory"===e.pathType)return'COMPREPLY=( $(compgen -d -- "$cur") )';return'COMPREPLY=( $(compgen -f -- "$cur") )'}},a4=e=>{switch(e._tag){case"Choice":return`COMPREPLY=( $(compgen -W '${e.values.join(" ")}' -- "$cur") )`;case"Path":if("directory"===e.pathType)return'COMPREPLY=( $(compgen -d -- "$cur") )';return'COMPREPLY=( $(compgen -f -- "$cur") )';default:return}},a9=(e,t,r)=>{let n=[...t,e.name],i=`_${n.map(a5).join("_")}`;r.push(`${i}()`),r.push("{"),r.push(" local cur prev words cword"),r.push(" _init_completion || return"),r.push("");let a=e.flags.filter(e=>"Boolean"!==e.type._tag);if(a.length>0){for(let e of(r.push(" # Flag value completions"),r.push(' case "$prev" in'),a)){let t=[`--${e.name}`];for(let r of e.aliases)t.push(1===r.length?`-${r}`:`--${r}`);let n=a8(e.type);n&&(r.push(` ${t.join("|")})`),r.push(` ${n}`),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 i cmd"),r.push(" for ((i = 1; i < cword; i++)); do"),r.push(' case "${words[i]}" in'),e.subcommands)){let e=`_${[...n,t.name].map(a5).join("_")}`;r.push(` ${t.name})`),r.push(` ${e}`),r.push(" return"),r.push(" ;;")}r.push(" esac"),r.push(" done"),r.push("")}((e,t)=>{if(0===e.length)return;t.push(" # Build used-flag filter"),t.push(" local -A _flag_groups");let r=0;for(let n of e){for(let e of a6(n))t.push(` _flag_groups[${e}]=${r}`);r++}t.push(" local -A _used_groups"),t.push(" for ((i = 1; i < cword; i++)); do"),t.push(' local _g="${_flag_groups[${words[i]}]:-}"'),t.push(' [[ -n "$_g" ]] && _used_groups[$_g]=1'),t.push(" done"),t.push(' local _filtered_flags=""'),t.push(` for _f in ${e.flatMap(a6).join(" ")}; do`),t.push(' local _g="${_flag_groups[$_f]:-}"'),t.push(' [[ -z "$_g" || -z "${_used_groups[$_g]:-}" ]] && _filtered_flags+=" $_f"'),t.push(" done"),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 s=e.arguments.filter(e=>void 0!==a4(e.type));if(s.length>0)for(let e of(r.push(" # Positional argument completions"),s)){let t=a4(e.type);r.push(` ${t}`),r.push(" return")}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))a9(t,n,r)},a7=e=>e.replace(/'/g,"\\'"),se=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(" ")}`},st=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 '${a7(e.description)}'`);let r=sr(e.type);return r&&t.push(r),t},sr=e=>{switch(e._tag){case"Boolean":return;case"Choice":return`-r -f -a '${e.values.join(" ")}'`;case"Path":return e.pathType,"-r -F";default:return"-r -f"}},sn=e=>{switch(e._tag){case"Choice":return`-r -f -a '${e.values.join(" ")}'`;case"Path":return"-r -F";default:return}},si=(e,t,r,n)=>{let i=((e,t)=>{if(0===e.length)return t.length>0?"__fish_use_subcommand":"";let r=e[e.length-1];return t.length>0?`__fish_seen_subcommand_from ${r}; and not __fish_seen_subcommand_from ${t.join(" ")}`:`__fish_seen_subcommand_from ${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 '${a7(r.name)}'`),r.description&&t.push(`-d '${a7(r.description)}'`),n.push(t.join(" "))}for(let r of t.flags){let t="Boolean"===r.type._tag,a=t?i?`${i}; and ${se(r)}`:se(r):i,s=a?`-n '${a}'`:"",o=[`complete -c ${e}`];if(s&&o.push(s),o.push(...st(r)),n.push(o.join(" ")),t){let t=[`complete -c ${e}`];s&&t.push(s),t.push(`-l no-${r.name}`),r.description&&t.push(`-d '${a7(`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 ${se(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 '${a7(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 '${a7(`Disable ${r.name}`)}'`),n.push(i.join(" "))}}}for(let r of t.arguments){let t=sn(r.type);if(t){let i=[`complete -c ${e}`];a&&i.push(a),i.push(t),r.description&&i.push(`-d '${a7(r.description)}'`),n.push(i.join(" "))}}for(let i of t.subcommands)si(e,i,[...r,i.name],n)},sa=e=>e.replace(/\\/g,"\\\\").replace(/'/g,"'\\''").replace(/:/g,"\\:"),ss=e=>e.replace(/[^a-zA-Z0-9_]/g,"_"),so=e=>{let t=[],r=e.description?`[${sa(e.description)}]`:"",n=(e=>{switch(e._tag){case"Boolean":return"";case"Choice":return`:value:(${e.values.join(" ")})`;case"Path":return"directory"===e.pathType?":directory:_directories":":file:_files";case"Integer":return":integer:";case"Float":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?`[${sa(`Disable ${e.name}`)}]`:"";t.push(`'${i}--no-${e.name}${r}'`)}return t},sl=e=>{let t=e.description?sa(e.description):e.name,r=(e=>{switch(e._tag){case"Choice":return`(${e.values.join(" ")})`;case"Path":return"directory"===e.pathType?"_directories":"_files";default:return""}})(e.type),n=e.variadic?"*":"";return`'${n}:${t}:${r}'`},sc=(e,t,r)=>{let n=[...t,e.name],i=`_${n.map(ss).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?sa(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 so(t))r.push(` ${e}`);for(let t of e.arguments)r.push(` ${sl(t)}`);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(ss).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(...so(r));for(let r of e.arguments)t.push(sl(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))sc(t,n,r)},su=e=>aI({name:e,primitiveType:av,kind:"flag"}),sd=(e,t)=>aC("flag",e,t.map(e=>[e,e])),sf=(0,R.XY)(2,(e,t)=>aN(e,t)),sh=(0,R.XY)(2,(e,t)=>aM(e,t)),sp=(0,R.XY)(2,(e,t)=>aB(e,t)),sm=e=>aU(e),sg=(0,R.XY)(2,(e,t)=>aP(e,t)),sy=(0,R.XY)(3,(e,t,r)=>aL(e,t,r)),sb="~effect/cli/Command/Config/Internal",sv=e=>{let t=[],r=[],n=[];return{[sb]:sb,flags:r,arguments:n,orderedParams:t,tree:function e(i){let a={};for(let s in i)a[s]=function i(a){if(Array.isArray(a))return{_tag:"Array",children:a.map(e=>i(e))};if(!es.i5(a,aS))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)}},sw=sv({}),sx=(e,t)=>{switch(e._tag){case"Param":return{_tag:"Param",index:e.index+t};case"Array":return{_tag:"Array",children:e.children.map(e=>sx(e,t))};case"Nested":return{_tag:"Nested",tree:s_(e.tree,t)}}},s_=(e,t)=>{let r={};for(let n in e)r[n]=sx(e[n],t);return r},sk=(e,t)=>{let r=e.orderedParams.length;return{[sb]:sb,flags:[...e.flags,...t.flags],arguments:[...e.arguments,...t.arguments],orderedParams:[...e.orderedParams,...t.orderedParams],tree:{...e.tree,...s_(t.tree,r)}}},sS=(e,t)=>{let r={};for(let n in e)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 sS(r.tree,t)}}(e[n]);return r},sO="~effect/cli/Command",sE=e=>e,s$={...t$.b({label:"Command",evaluate(){return sE(this).service}})},sI=e=>{let t=e.config,r=e.contextConfig??sw,n=e.service??H.kl(`${sO}/${e.name}`),i=e.annotations??H.Ie(),a=e.globalFlags??[],s=e.subcommands??[],o=e.parse??sT(t),l=e.parseContext??sT(r);return Object.assign(Object.create(s$),{[sO]:sO,name:e.name,examples:e.examples??[],annotations:i,globalFlags:a,subcommands:s,hidden:e.hidden??!1,config:t,contextConfig:r,service:n,parse:o,parseContext:l,handle:(t,r)=>es.EA(e.handle)?e.handle(t,r):U.fJG(new an({commandPath:r,errors:[]})),buildHelpDoc:r=>{let n=[],a=[];for(let e of t.arguments){let t=aK(e),r=aG(e);for(let e of t)n.push({name:e.name,type:e.typeName??a_(e.primitiveType),description:e.description,required:!r.isOptional,variadic:r.isVariadic})}let o=r.length>0?r.join(" "):e.name;for(let e of(s.some(e=>e.commands.some(e=>!e.hidden))&&(o+=" <subcommand>"),o+=" [flags]",n)){let t=e.variadic?`<${e.name}...>`:`<${e.name}>`;o+=` ${e.required?t:`[${t}]`}`}for(let e of t.flags)for(let t of aK(e))t.hidden||a.push(sA(t));let l=[];for(let e of s){let t=e.commands.filter(e=>!e.hidden);0!==t.length&&l.push({group:e.group,commands:z.Tj(t,e=>({name:e.name,alias:e.alias,shortDescription:e.shortDescription,description:e.description??""}))})}let c=e.examples??[];return{description:e.description??"",usage:o,flags:a,annotations:i,...n.length>0&&{args:n},...l.length>0&&{subcommands:l},...c.length>0&&{examples:c}}},...es.EA(e.description)?{description:e.description}:{},...es.EA(e.shortDescription)?{shortDescription:e.shortDescription}:{},...es.EA(e.alias)?{alias:e.alias}:{}})},sA=e=>{let t=e.aliases.map(e=>1===e.length?`-${e}`:`--${e}`);return{name:e.name,aliases:t,type:e.typeName??a_(e.primitiveType),description:sC(e.description,ak(e.primitiveType)),required:"Boolean"!==e.primitiveType._tag}},sC=(e,t)=>{if(void 0===t||0===t.length)return e;let r=`(choices: ${t.join(", ")})`;return K.match(e,{onNone:()=>K.some(r),onSome:e=>K.some(`${e} ${r}`)})},sT=e=>U.D9k(function*(t){let r={flags:t.flags,arguments:t.arguments},n=yield*sN(r,e.orderedParams);return sS(e.tree,n)}),sN=U.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 r}),sM=(e,t,r)=>{let n=sE(e),i=new Set;for(let e of(r?.contextConfig??n.contextConfig).flags)for(let t of aK(e))i.add(t.name);for(let r of t)for(let t of sE(r).config.flags)for(let n of aK(t))if(i.has(n.name))throw new i8({option:n.name,parentCommand:e.name,childCommand:r.name})},sP=e=>{switch(e.primitiveType._tag){case"Boolean":return{_tag:"Boolean"};case"Integer":return{_tag:"Integer"};case"Float":return{_tag:"Float"};case"Date":return{_tag:"Date"};case"Choice":return{_tag:"Choice",values:ak(e.primitiveType)??[]};case"Path":{let t=e.typeName;return{_tag:"Path",pathType:"file"===t?"file":"directory"===t?"directory":"either"}}default:return{_tag:"String"}}},sj=e=>{switch(e.primitiveType._tag){case"Integer":return{_tag:"Integer"};case"Float":return{_tag:"Float"};case"Date":return{_tag:"Date"};case"Choice":return{_tag:"Choice",values:ak(e.primitiveType)??[]};case"Path":{let t=e.typeName;return{_tag:"Path",pathType:"file"===t?"file":"directory"===t?"directory":"either"}}default:return{_tag:"String"}}},sD=e=>{let t=sE(e).config,r=[];for(let e of t.flags)for(let t of aK(e))"flag"===t.kind&&(t.hidden||r.push({name:t.name,aliases:t.aliases,description:K.getOrUndefined(t.description),type:sP(t)}));let n=[];for(let e of t.arguments){let t=aK(e),r=aG(e);for(let e of t)"argument"===e.kind&&n.push({name:e.name,description:K.getOrUndefined(e.description),required:!r.isOptional,variadic:r.isVariadic,type:sj(e)})}let i=[];for(let t of e.subcommands)for(let e of t.commands)e.hidden||i.push(sD(e));return{name:e.name,description:e.shortDescription??e.description,flags:r,arguments:n,subcommands:i}},sU=e=>{let t=new Set,r=[];for(let n of e)t.has(n)||(t.add(n),r.push(n));return r},sF=(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},sR=(e,t,r)=>sU([...r,...sF(e,t).flatMap(e=>sE(e).globalFlags)]),sL=(e,t,r)=>U.JkU(function*(){let n=sF(e,t),i=sE(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 sE(t).contextConfig.flags)for(let t of aK(e))!r.has(t.name)&&(t.hidden||(r.add(t.name),n.push(sA(t))));return n})(n,i.flags),s=sR(e,t,r),o=[];for(let e of s)for(let t of aK(e.flag))t.hidden||o.push({...sA(t),required:!1});return{...i,flags:[...a,...i.flags],globalFlags:o}}),sB=e=>({_tag:"Action",flag:e.flag,run:e.run}),sY=0,sq=sB({flag:su("help").pipe(sf("h"),sh("Show help information")),run:U.D9k(function*(e,{builtIns:t,command:r,commandPath:n}){let i=yield*aQ,a=yield*sL(r,n,t);yield*i3(i.formatHelpDoc(a))})}),sX=sB({flag:su("version").pipe(sf("v"),sh("Show version information")),run:U.D9k(function*(e,{command:t,version:r}){let n=yield*aQ;yield*i3(n.formatVersion(t.name,r))})}),sW=sB({flag:su("wizard").pipe(sh("Start wizard mode for a command")),run:()=>U.rIH}),sJ=sB({flag:sd("completions",["bash","zsh","fish","sh"]).pipe(sm,sg(e=>K.map(e,e=>"sh"===e?"bash":e)),sp("<bash|zsh|fish|sh>"),sh("Print shell completion script")),run:U.D9k(function*(e,{command:t}){if(K.isNone(e))return;let r=sD(t);yield*i3(((e,t,r)=>{switch(t){case"bash":let n=[],i=a5(e);return n.push(`###-begin-${e.replace(/'/g,"'\\''")}-completions-###`),n.push("#"),n.push("# Static completion script for Bash"),n.push("#"),n.push("# Installation:"),n.push(`# ${e.replace(/'/g,"'\\''")} --completions bash >> ~/.bashrc`),n.push("#"),n.push(""),n.push("if ! type _init_completion &>/dev/null; then"),n.push(" _init_completion()"),n.push(" {"),n.push(" COMPREPLY=()"),n.push(' cur="${COMP_WORDS[COMP_CWORD]}"'),n.push(' prev="${COMP_WORDS[COMP_CWORD-1]}"'),n.push(' words=("${COMP_WORDS[@]}")'),n.push(" cword=$COMP_CWORD"),n.push(" }"),n.push("fi"),n.push(""),a9(r,[],n),n.push(`complete -F _${i} ${e.replace(/'/g,"'\\''")}`),n.push(`###-end-${e.replace(/'/g,"'\\''")}-completions-###`),n.join("\n");case"zsh":let a,s;return a=[],s=ss(e),a.push(`#compdef ${e}`),a.push(`###-begin-${e}-completions-###`),a.push("#"),a.push("# Static completion script for Zsh"),a.push("#"),a.push("# Installation:"),a.push(`# ${e} --completions zsh > ~/.zsh/completions/_${e}`),a.push("# then add ~/.zsh/completions to your fpath"),a.push("#"),a.push(""),sc(r,[],a),a.push("# Handle both direct invocation and autoload"),a.push('if [[ "${zsh_eval_context[-1]}" == "loadautofunc" ]]; then'),a.push(` _${s} "$@"`),a.push("else"),a.push(` compdef _${s} ${e}`),a.push("fi"),a.push(`###-end-${e}-completions-###`),a.join("\n");case"fish":let o;return(o=[]).push(`###-begin-${e}-completions-###`),o.push("#"),o.push("# Static completion script for Fish"),o.push("#"),o.push("# Installation:"),o.push(`# ${e} --completions fish > ~/.config/fish/completions/${e}.fish`),o.push("#"),o.push(""),si(e,r,[],o),o.push(""),o.push(`###-end-${e}-completions-###`),o.join("\n")}})(t.name,e.value,r))})}),sz=(A="log-level",e=>(sY+=1,Object.assign(H.kl(`effect/unstable/cli/GlobalFlag/${A}/${sY}`),{_tag:"Setting",id:A,flag:e.flag})))({flag:aC("flag","log-level",[["all","All"],["trace","Trace"],["debug","Debug"],["info","Info"],["warn","Warn"],["warning","Warn"],["error","Error"],["fatal","Fatal"],["none","None"]]).pipe(sm,sh("Sets the minimum log level"),sp("<all|trace|debug|info|warn|warning|error|fatal|none>"))}),sK=[sq,sX,sW,sJ,sz];class sV extends H.Or("effect/unstable/cli/CliConfig",{defaultValue:()=>sG}){}let sG={builtIns:sK},sH=e=>{let t=[];for(let r of e)if(r.startsWith("-"))if(r.startsWith("--")){let[e,n]=r.slice(2).split("=",2);t.push({_tag:"LongOption",name:e,raw:r,value:n})}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});else t.push({_tag:"Value",value:r});return t},sQ=(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)},sZ=e=>K.match(e.subcommand,{onNone:()=>[],onSome:e=>[e.name,...sZ(e.parsedInput)]}),s0=(e,t,r=[])=>U.JkU(function*(){let{tokens:n,trailingOperands:i}=e,a=[...r,t.name],s=sE(t),o=s.config.flags.flatMap(aK).filter(a$),l=s2(o),c=s.contextConfig.flags.flatMap(aK).filter(a$),u=s2(c),d=new Set(c.map(e=>e.name)),f=oo(n,{command:t,commandPath:a,flagRegistry:l,inheritedFlagRegistry:u,localFlagNames:o.filter(e=>!d.has(e.name)).map(e=>e.name)});if("Leaf"===f._tag)return{flags:f.flags,arguments:[...f.arguments,...i],subcommand:K.none(),...f.errors.length>0&&{errors:f.errors}};let h={tokens:f.childTokens,trailingOperands:[]},p=yield*s0(h,f.sub,a),m=[...f.errors,...p.errors??[]];return{flags:f.flags,arguments:i,subcommand:K.some({name:f.sub.name,parsedInput:p}),...m.length>0&&{errors:m}}}),s1=e=>{let t=0;return{peek:()=>e[t],take:()=>e[t++],rest:()=>e.slice(t)}},s2=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}},s3=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},s5=e=>Object.fromEntries(e.map(e=>[e.name,[]])),s6=e=>"LongOption"===e._tag||"ShortOption"===e._tag,s8=e=>"LongOption"===e._tag?e.name:e.flag,s4=(e,t)=>{let r=s8(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&&ag(n.primitiveType))return{param:n,negated:!0}}if(n)return{param:n,negated:!1}},s9=(e,t,r)=>new i7({option:t.name,value:r,expected:`omit the value and use ${e.raw} by itself to set --${t.name} to false`,kind:"flag"}),s7=e=>e?._tag==="Value"&&(ap(e.value)||am(e.value))?e.value:void 0,oe=(e,t,r,n=!1)=>{let i=ot(e,t,r,n);switch(i._tag){case"Value":return{_tag:"Value",value:i.value};case"Error":return{_tag:"Error",error:i.error}}},ot=(e,t,r,n=!1)=>{let i;if(n){if(void 0!==t.value)return{_tag:"Error",error:s9(t,r,t.value),tokens:[]};let n=s7(e.peek());if(void 0!==n){let i=e.take();return{_tag:"Error",error:s9(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(ag(r.primitiveType)){let t=s7(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=ak(r.primitiveType),new i7({option:r.name,value:"",expected:void 0===i?r.typeName??a_(r.primitiveType):i.join(" | "),kind:"flag"})),tokens:[]}},or=(e,t)=>{for(let r of t){let t=s4(e,r);if(void 0!==t)return t}},on=(e,t,r,n)=>{e.push(r);let i=ot(t,r,n.param,n.negated);e.push(...i.tokens)},oi=(e,t,r,n,i)=>{let a=s1(t);ot(a,e,r.param,r.negated);for(let e=a.take();e;e=a.take()){if(s6(e)){let t=or(e,i);void 0!==t&&ot(a,e,t.param,t.negated);continue}if("Value"===e._tag)return n.has(e.value)}return!1},oa=(e,t,r,n)=>{let{commandPath:i,flagRegistry:a}=r,s=s4(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),ag(e.primitiveType)&&i.push(`no-${e.name}`),e.aliases))i.push(t);return new i6({option:n,suggestions:sQ(s8(e),i).map(e=>1===e.length?`-${e}`:`--${e}`),command:r})})(e,a.params,i));let o=oe(t,e,s.param,s.negated);"Error"===o._tag?n.errors.push(o.error):n.flags.add(s.param.name,o.value)},os=(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=s3(i.subcommands),c=l.get(e);if(c){let e=[...a,c.name],r=n.flags.snapshot();for(let t of o){let i=r[t];void 0!==i&&i.length>0&&n.errors.push(new i6({option:`--${t}`,suggestions:[],command:e}))}let i=((e,t)=>{let r=s5(t.params),n=[],i=[],a=s1(e);for(let e=a.take();e;e=a.take()){if(!s6(e)){n.push(e);continue}let s=s4(e,t);if(!s){n.push(e);continue}let o=oe(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:c,childTokens:i.remainder,errors:n.errors}}}if(!(sE(i).config.arguments.length>0)&&l.size>0){let t=[];for(let[e,r]of l)r.hidden||t.push(e);let r=sQ(e,t);n.errors.push(new ae({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)},oo=(e,t)=>{let r,n=s1(e),i={flags:(r=s5(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(s6(e)){oa(e,n,t,i);continue}if("Value"===e._tag){let r=os(e.value,n,t,i);if(r)return r}}return{_tag:"Leaf",flags:i.flags.snapshot(),arguments:i.arguments,errors:i.errors}};var ol=n(8036),oc=n(4450);let ou=new WeakMap,od="~effect/data/Redacted",of=(e,t)=>{let r=Object.create(oh);return t?.label&&(r.label=t.label),ou.set(r,e),r},oh={[od]:{_A:e=>e},label:void 0,...el.fU,toJSON(){return this.toString()},toString(){return`<redacted${(0,es.Kg)(this.label)?":"+this.label:""}>`},[oc.HR](){return oc.tW(ou.get(this))},[ol.HR](e){return(0,es.i5)(e,od)&&ol.aI(ou.get(this),ou.get(e))}},op=e=>{if(ou.has(e))return ou.get(e);throw Error("Unable to get redacted value"+(e.label?` with label: "${e.label}"`:""))};var om=n(1044),og=n(6364);es.Et,og.wN,om.wN;let oy=(0,R.XY)(2,(e,t)=>{let r=Math.pow(10,t);return Math.round(e*r)/r}),ob=(e,...t)=>{let r=t.flat();return`${r.join("")}${e}[0m`},ov={arrowUp:"↑",arrowDown:"↓",arrowLeft:"←",arrowRight:"→",radioOn:"◉",radioOff:"◯",checkboxOn:"☒",checkboxOff:"☐",tick:"✔",cross:"✖",ellipsis:"…",pointerSmall:"›",line:"─",pointer:"❯"},ow={arrowUp:ov.arrowUp,arrowDown:ov.arrowDown,arrowLeft:ov.arrowLeft,arrowRight:ov.arrowRight,radioOn:"(*)",radioOff:"( )",checkboxOn:"[*]",checkboxOff:"[ ]",tick:"√",cross:"×",ellipsis:"...",pointerSmall:"»",line:"─",pointer:">"},ox=U.TjK(U.OH5(()=>"win32"===process.platform),e=>e?ow:ov),o_=e=>ob(e,"\x1b[1m"),ok=e=>ob(e,((...e)=>e)("\x1b[3m","\x1b[31m")),oS=e=>{let t={initial:!1,...e,label:{confirm:"yes",deny:"no",...e.label},placeholder:{defaultConfirm:"(Y/n)",defaultDeny:"(y/N)",...e.placeholder}};return oO({value:t.initial},{render:oX(t),process:e=>oz(e,t.initial),clear:oL(t)})},oO=(e,...t)=>{let[r,n]=1===t.length?[void 0,t[0]]:[t[0],t[1]],i=Object.create(oM);return i._tag="Loop",i.initialState=e,i.render=n.render,i.process=n.process,i.clear=n.clear,i.events=r,i},oE=(0,R.XY)(2,(e,t)=>{let r=Object.create(oM);return r._tag="OnSuccess",r.prompt=e,r.onSuccess=t,r}),o$=e=>{let t={default:0,min:-1/0,max:1/0,incrementBy:1,decrementBy:1,validate:e=>e<t.min?U.fJG(`${e} must be greater than or equal to ${t.min}`):e>t.max?U.fJG(`${e} must be less than or equal to ${t.max}`):U.PyW(e),...e},r=void 0===e.default?"":`${t.default}`;return oO({cursor:r.length,value:r,error:K.none()},{render:lu(t),process:ld(t),clear:ln(t)})},oI=(0,R.XY)(2,(e,t)=>oE(e,e=>oT(t(e)))),oA=U.D9k(function*(e){let t=yield*nn,r=yield*t.readInput;return yield*oP(e,t,r)},U.xm_(()=>new nr({})),U.P1j),oC=e=>{let t={maxPerPage:10,...e};return oO((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:lb(t),process:lw(t),clear:lv(t)})},oT=e=>{let t=Object.create(oM);return t._tag="Succeed",t.value=e,t},oN=e=>{let t={initial:!1,active:"on",inactive:"off",...e};return oO(t.initial,{render:lD(t),process:lU,clear:()=>lA(t)})},oM={...t$.b({label:"Prompt",evaluate(){return oA(this)}}),"~effect/cli/Prompt":{_Output:e=>e}},oP=(e,t,r)=>U.DYE(()=>{switch(e._tag){case"Loop":return oj(e,t,r);case"OnSuccess":return U.qIB(oP(e.prompt,t,r),n=>oP(e.onSuccess(n),t,r));case"Succeed":return U.PyW(e.value)}}),oj=U.D9k(function*(e,t,r){let n=U.yw5(e.initialState)?yield*e.initialState:e.initialState,i=oD.NextFrame({state:n});for(;;){let a=yield*e.render(n,i);if(yield*U.QgK(t.display(a)),e.events){let t=eE(r).pipe(U.TjK(e=>({_tag:"Input",input:e}))),a=yield*U.KT6(t,eE(e.events).pipe(U.TjK(e=>({_tag:"Event",value:e}))));i=yield*e.process(a,n)}else{let t=yield*eE(r);i=yield*e.process(t,n)}switch(i._tag){case"Beep":continue;case"NextFrame":yield*U.QgK(t.display((yield*e.clear(n,i)))),n=i.state;continue;case"Submit":{yield*U.QgK(t.display((yield*e.clear(n,i))));let r=yield*e.render(n,i);return yield*U.QgK(t.display(r)),i.value}}}},(e,t,r)=>U.yeE(e,U.QgK(r.display("\x1b[?25h")))),oD=Q.Ij(),oU=(e,t)=>{if(0===t){var r;return"\x1b[2K"+(void 0===r?`\x1b${Math.max(1,0)} G`:`\x1b${r+1};${Math.max(1,0)} H`)}let n=0;for(let r of e.split(oR))n+=1+Math.floor(Math.max(r.length-1,0)/t);var i=n;let a="";for(let e=0;e<i;e++)a+="\x1b[2K"+(e<i-1?"\x1b[1A":"");return i>0&&(a+="\x1b[G"),a},oF=(e,t,r)=>{if(void 0!==r&&r.length>0){let n;return((e=1)=>`\x1b[${e}B`)((n=r.split(oR),0===t?n.length:(0,R.Fs)(z.Tj(n,e=>Math.ceil(e.length/t)),z.TS(0,(e,t)=>e+t))))+oU(`
|
|
15
|
-
${r}`,t)+oU(e,t)}return oU(e,t)},
|
|
16
|
-
${o}`,i)+"\x1b[2K\x1b[G"}),lw=e=>(t,r)=>{var n;switch(t.key.name){case"k":case"up":return n=e.choices,0===r?U.PyW(oD.NextFrame({state:n.length-1})):U.PyW(oD.NextFrame({state:r-1}));case"j":case"down":return r===e.choices.length-1?U.PyW(oD.NextFrame({state:0})):U.PyW(oD.NextFrame({state:r+1}));case"tab":let i;return i=e.choices,U.PyW(oD.NextFrame({state:(r+1)%i.length}));case"enter":case"return":{let t=e.choices[r];if(t.disabled)return U.PyW(oD.Beep());return U.PyW(oD.Submit({value:t.value}))}default:return U.PyW(oD.Beep())}},lx=U.D9k(function*(e,t){let r=yield*nn,n=yield*r.columns,i=yield*ox,a=l_(e,i.pointerSmall,{plain:!0});return oF(lk(e,"?",i.pointerSmall,t,{plain:!0}),n,a)+"\x1b[2K\x1b[G"}),l_=(e,t,r)=>K.isSome(e.error)?z.YW(e.error.value.split(oR),{onEmpty:()=>"",onNonEmpty:e=>r?.plain===!0?`${t} ${e.join("\n")}`:"\x1b[s\n"+(ob(t,"\x1b[31m")+" ")+z.Tj(e,e=>ok(e)).join("\n")+"\x1b[u"}):"",lk=(e,t,r,n,i,a=!1)=>lt(((e,t,r,n)=>{let i=e.value;if(n?.plain===!0)switch(t.type){case"hidden":return"";case"password":return"*".repeat(i.length);case"text":return i}let a=K.isSome(e.error)?"\x1b[31m":r?"\x1b[37m":0===e.value.length?"\x1b[90m":((...e)=>e)("\x1b[4m","\x1b[96m");switch(t.type){case"hidden":return"";case"password":return ob("*".repeat(i.length),a);case"text":return ob(i,a)}})(e,n,a,i),n.message,t,r,i),lS=U.D9k(function*(e,t){let r=yield*ox;return lk(e,ob("?","\x1b[96m"),ob(r.pointerSmall,"\x1b[90m"),t)+l_(e,r.pointerSmall)+((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)}),lO=U.D9k(function*(e,t){let r=yield*ox;return lk(e,ob(r.tick,"\x1b[32m"),ob(r.ellipsis,"\x1b[90m"),t,void 0,!0)+"\n"}),lE=e=>U.PyW(oD.NextFrame({state:{...e,cursor:0,error:K.none()}})),l$=e=>U.PyW(oD.NextFrame({state:{...e,cursor:e.value.length,error:K.none()}})),lI=(e,t)=>{let r={default:"",type:t,validate:U.PyW,...e};return oO({cursor:r.default.length,value:r.default,error:K.none()},{render:(e,t)=>oD.$match(t,{Beep:()=>U.PyW("\x07"),NextFrame:({state:e})=>lS(e,r),Submit:()=>lO(e,r)}),process:(e,t)=>{if(e.key.ctrl)switch(e.key.name){case"u":return U.PyW(oD.NextFrame({state:{...t,cursor:0,value:"",error:K.none()}}));case"a":return lE(t);case"e":return l$(t);default:return U.PyW(oD.Beep())}switch(e.key.name){case"backspace":var n;if(t.cursor<=0)return U.PyW(oD.Beep());let i=t.value.slice(0,t.cursor-1),a=t.value.slice(t.cursor),s=t.cursor-1,o=`${i}${a}`;return U.PyW(oD.NextFrame({state:{...t,cursor:s,value:o,error:K.none()}}));case"left":if(t.cursor<=0)return U.PyW(oD.Beep());let l=t.cursor-1;return U.PyW(oD.NextFrame({state:{...t,cursor:l,error:K.none()}}));case"right":if(t.cursor>=t.value.length)return U.PyW(oD.Beep());let c=Math.min(t.cursor+1,t.value.length);return U.PyW(oD.NextFrame({state:{...t,cursor:c,error:K.none()}}));case"home":return lE(t);case"end":return l$(t);case"enter":case"return":{let e=t.value;return U.YWq(r.validate(e),{onFailure:r=>oD.NextFrame({state:{...t,value:e,error:K.some(r)}}),onSuccess:e=>oD.Submit({value:e})})}case"tab":if(t.value===r.default)return U.PyW(oD.Beep());let u=0===t.value.length?r.default:t.value;return U.PyW(oD.NextFrame({state:{...t,value:u,cursor:u.length,error:K.none()}}));default:let d,f,h,p;return n=K.getOrElse(e.input,()=>""),d=t.value.slice(0,t.cursor),f=t.value.slice(t.cursor),h=`${d}${n}${f}`,p=t.cursor+n.length,U.PyW(oD.NextFrame({state:{...t,cursor:p,value:h,error:K.none()}}))}},clear:(e,t)=>lx(e,r)})},lA=U.D9k(function*(e){let t=yield*nn,r=yield*t.columns,n=yield*ox;return oU(lt(`${e.active} / ${e.inactive}`,e.message,"?",n.pointerSmall,{plain:!0}),r)+"\x1b[2K\x1b[G"}),lC=(e,t,r=!1)=>{let n=ob("/","\x1b[90m"),i=((...e)=>e)("\x1b[4m",r?"\x1b[37m":"\x1b[96m"),a=e?t.inactive:ob(t.inactive,i);return(e?ob(t.active,i):t.active)+" "+n+" "+a},lT=(e,t,r,n)=>{let i=n.message.split(oR),a=t+" ";return z.ET(i)?a+z.Tj(i,e=>o_(e)).join("\n")+" "+r+" "+e:a+" "+r+" "+e},lN=U.D9k(function*(e,t){let r=yield*ox,n=ob("?","\x1b[96m"),i=ob(r.pointerSmall,"\x1b[90m");return"\x1b[?25l"+lT(lC(e,t),n,i,t)}),lM=U.D9k(function*(e,t){let r=yield*ox,n=ob(r.tick,"\x1b[32m"),i=ob(r.ellipsis,"\x1b[90m");return lT(lC(e,t,!0),n,i,t)+"\n"}),lP=U.PyW(oD.NextFrame({state:!0})),lj=U.PyW(oD.NextFrame({state:!1})),lD=e=>(t,r)=>{switch(r._tag){case"Beep":return U.PyW("\x07");case"NextFrame":return lN(t,e);case"Submit":return lM(t,e)}},lU=(e,t)=>{switch(e.key.name){case"0":case"j":case"delete":case"right":case"down":return lj;case"1":case"k":case"left":case"up":return lP;case" ":case"tab":return t?lj:lP;case"enter":case"return":return U.PyW(oD.Submit({value:t}));default:return U.PyW(oD.Beep())}},lF=(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}},lR=U.D9k(function*(e,t){let r=t?.commandPath??[e.name],n=lL(e,r),i=[...t?.prefix??r];return yield*lK(i),yield*lB(n,i,n===e?"ROOT":n.name),i}),lL=(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},lB=U.D9k(function*(e,t,r){let n=sE(e),i=e.subcommands.flatMap(e=>e.commands.filter(e=>!e.hidden)),a=0===i.length?n.config:n.contextConfig;if(a.flags.length>0){for(let e of(yield*i3(lV(r,"FLAGS")),a.flags))t.push(...yield*lq(e));(a.arguments.length>0||i.length>0)&&(yield*lK(t))}if(a.arguments.length>0){for(let e of(yield*i3(lV(r,"ARGUMENTS")),a.arguments))t.push(...yield*lq(e));i.length>0&&(yield*lK(t))}if(0===i.length)return;let s=yield*oA(oC({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*i3(),t.push(s.name),lY(s)&&(yield*lK(t)),yield*lB(s,t,s.name)}),lY=e=>e.subcommands.some(e=>e.commands.some(e=>!e.hidden))||sE(e).config.orderedParams.length>0,lq=U.D9k(function*(e){let t=aV(e),r=aG(e);if(r.isOptional&&!(yield*oA(oS({message:`Set ${lJ(t)}?`,initial:!1}))))return yield*i3(),[];let n=r.isVariadic?yield*oA(o$({message:`${lJ(t)} count`,default:K.getOrElse(r.variadicMin,()=>0),min:K.getOrElse(r.variadicMin,()=>0),...K.isSome(r.variadicMax)?{max:r.variadicMax.value}:{}})):1,i=[];for(let e=0;e<n;e++)i.push((yield*lX(t)));let a="flag"===t.kind?{flags:{[t.name]:i},arguments:[]}:{flags:{},arguments:i};return(yield*e.parse(a),yield*i3(),t.kind===aO)?i:i.flatMap(e=>[`--${t.name}`,e])}),lX=e=>{var t,r;let n=lW(e);switch(e.primitiveType._tag){case"Boolean":return U.TjK(oA(oS({message:n,label:{confirm:"true",deny:"false"},placeholder:{defaultConfirm:"(T/f)",defaultDeny:"(t/F)"}})),String);case"Choice":return oA(oC({message:n,choices:(ak(e.primitiveType)??[]).map(e=>({title:e,value:e}))}));case"Date":let i,a,s,o,l,c;return U.TjK(oA((t={message:n},s=(a=((e,t,r)=>{let n=[],i=null;for(;i=oZ.exec(e);){let e=i.shift(),a=i.findIndex(e=>void 0!==e);if(a in o0){let s=i[a]||e;n.push(o0[a]({token:s,date:t,parts:n,locales:r}))}else n.push(new o2({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},z.Ie());return n.splice(0,n.length,...a),n})((i={initial:new Date,dateMask:"YYYY-MM-DD HH:mm:ss",validate:U.PyW,...t,locales:{...oQ,...t.locales}}).dateMask,i.initial,i.locales)).findIndex(e=>!e.isToken()),oO({dateParts:a,typed:"",cursor:s,value:i.initial,error:K.none()},{render:(o=i,(e,t)=>oD.$match(t,{Beep:()=>U.PyW("\x07"),NextFrame:({state:e})=>oG(e,o),Submit:()=>oH(e,o)})),process:(l=i,(e,t)=>{switch(e.key.name){case"left":let r;return U.PyW((r=t.dateParts[t.cursor].previousPart(),K.isSome(r)?oD.NextFrame({state:{...t,typed:"",cursor:t.dateParts.indexOf(r.value)}}):oD.Beep()));case"right":let n;return U.PyW((n=t.dateParts[t.cursor].nextPart(),K.isSome(n)?oD.NextFrame({state:{...t,typed:"",cursor:t.dateParts.indexOf(n.value)}}):oD.Beep()));case"k":case"up":return U.PyW((t.dateParts[t.cursor].increment(),oD.NextFrame({state:{...t,typed:""}})));case"j":case"down":return U.PyW((t.dateParts[t.cursor].decrement(),oD.NextFrame({state:{...t,typed:""}})));case"tab":let i,a;return U.PyW((i=t.dateParts[t.cursor].nextPart(),a=K.match(i,{onNone:()=>t.dateParts.findIndex(e=>!e.isToken()),onSome:e=>t.dateParts.indexOf(e)}),oD.NextFrame({state:{...t,cursor:a}})));case"enter":case"return":return U.YWq(l.validate(t.value),{onFailure:e=>oD.NextFrame({state:{...t,error:K.some(e)}}),onSuccess:e=>oD.Submit({value:e})});default:return U.PyW(((e,t)=>{if(/\d/.test(e)){let r=t.typed+e;return t.dateParts[t.cursor].setValue(r),oD.NextFrame({state:{...t,typed:r}})}return oD.Beep()})(K.getOrElse(e.input,()=>""),t))}}),clear:(c=i,U.D9k(function*(e,t){let r=yield*nn,n=yield*r.columns,i=yield*ox,a=z.TS(e.dateParts,"",(e,t)=>e+t.toString());return oF(oV("?",i.pointerSmall,a,c,{plain:!0}),n,K.isSome(e.error)?z.YW(e.error.value.split(oR),{onEmpty:()=>"",onNonEmpty:e=>`${i.pointerSmall} ${e.join("\n")}`}):"")+"\x1b[2K\x1b[G"}))}))),e=>e.toISOString());case"Float":let u,d,f,h;return U.TjK(oA((u={default:0,min:-1/0,max:1/0,incrementBy:1,decrementBy:1,precision:2,validate:e=>e<u.min?U.fJG(`${e} must be greater than or equal to ${u.min}`):e>u.max?U.fJG(`${e} must be less than or equal to ${u.max}`):U.PyW(e),...r={message:n}},oO({cursor:(d=void 0===r.default?"":`${u.default}`).length,value:d,error:K.none()},{render:(f=u,(e,t)=>oD.$match(t,{Beep:()=>U.PyW("\x07"),NextFrame:({state:e})=>ls(e,f),Submit:()=>lo(e,f)})),process:(h=u,(e,t)=>{if(e.key.ctrl&&"u"===e.key.name)return lc(t);switch(e.key.name){case"backspace":return ll(t);case"k":case"up":return U.PyW(oD.NextFrame({state:{...t,value:""===t.value||"-"===t.value?`${h.incrementBy}`:`${Number.parseFloat(t.value)+h.incrementBy}`,error:K.none()}}));case"j":case"down":return U.PyW(oD.NextFrame({state:{...t,value:""===t.value||"-"===t.value?`-${h.decrementBy}`:`${Number.parseFloat(t.value)-h.decrementBy}`,error:K.none()}}));case"enter":case"return":{let e=Number.parseFloat(t.value);if(Number.isNaN(e))return U.PyW(oD.NextFrame({state:{...t,error:K.some("Must provide a floating point value")}}));return U.qIB(U.OH5(()=>oy(e,h.precision)),e=>U.YWq(h.validate(e),{onFailure:e=>oD.NextFrame({state:{...t,error:K.some(e)}}),onSuccess:e=>oD.Submit({value:e})}))}default:var r=K.getOrElse(e.input,()=>"");if("."===r&&t.value.includes("."))return U.PyW(oD.Beep());if(0===t.value.length&&"-"===r)return U.PyW(oD.NextFrame({state:{...t,value:"-",error:K.none()}}));let n=Number.parseFloat(t.value+r);return Number.isNaN(n)?U.PyW(oD.Beep()):U.PyW(oD.NextFrame({state:{...t,value:"."===r?`${n}.`:`${n}`,error:K.none()}}))}}),clear:ln(u)}))),String);case"Integer":return U.TjK(oA(o$({message:n})),String);case"Redacted":return U.TjK(oA(lI({message:n},"password").pipe(oI(of))),op);default:return oA(lI({message:n},"text"))}},lW=e=>lJ(e),lJ=e=>{let t=K.getOrUndefined(e.description)?.trim(),r="flag"===e.kind&&void 0!==t&&t.length<=32?t:lz(e.name);return"flag"===e.kind?`${r} (${"flag"===e.kind?`--${e.name}`:e.name})`:r},lz=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(" ")},lK=e=>i3(lZ("Current command",e,"\x1b[35m")),lV=(e,t)=>`${ob(e.toUpperCase(),"\x1b[1m","\x1b[96m")} ${ob("·","\x1b[90m")} ${ob(t,"\x1b[1m","\x1b[37m")}`,lG=(e,t,r)=>[`${ob(e,"\x1b[1m","\x1b[96m")} ${ob(`v${t}`,"\x1b[37m")} ${ob("· Command wizard","\x1b[1m","\x1b[37m")}`,...void 0===r||0===r.length?[]:[r],ob("Build a command interactively. Press Ctrl+C to cancel.","\x1b[90m"),""].join("\n"),lH=e=>lZ("Command ready",e,"\x1b[96m","\x1b[32m"),lQ=()=>`
|
|
17
|
-
${ob("Wizard cancelled.","\x1b[31m")}`,lZ=(e,t,r,n="\x1b[37m")=>{let i=l0(t);return[ob(e,"\x1b[1m",n),...i.map(e=>ob(e,r)),""].join("\n")},l0=e=>{let t=" $ ",r=" ",n=e.map(l1),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},l1=e=>/^[A-Za-z0-9_./:@%+=,-]+$/.test(e)?e:`'${e.replaceAll("'","'\"'\"'")}'`,l2=e=>es.i5(e,sO),l3=(e,t,r)=>sI({name:e,config:sv(t??{}),...es.EA(r)?{handle:r}:{}}),l5=(0,R.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(l2(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);sM(e,r.flat);let n=sE(e),i=new Map(r.flat.map(e=>[e.name,sE(e)])),a=Symbol("effect/cli/SubcommandState"),s=U.D9k(function*(e){if(K.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 Object.assign({},r,{[a]:{name:t.name,result:s}})}),o=U.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(U.PfK(n.service,e)):yield*new an({commandPath:t,errors:[]})}return yield*n.handle(e,t)});return sI({name:n.name,config:n.config,contextConfig:n.contextConfig,description:n.description,shortDescription:n.shortDescription,alias:n.alias,annotations:n.annotations,globalFlags:n.globalFlags,examples:n.examples,service:n.service,subcommands:r.groups,parse:s,parseContext:n.parseContext,handle:o})}),l6=(0,R.XY)(2,(e,t)=>{let r=sE(e),n=sv(t),i=sk(r.config,n),a=sk(r.contextConfig,n);r.subcommands.length>0&&sM(e,r.subcommands.flatMap(e=>e.commands),{contextConfig:a});let s=sT(n),o=U.D9k(function*(e){return Object.assign({},(yield*r.parse(e)),(yield*s(e)))}),l=U.D9k(function*(e){return Object.assign({},(yield*r.parseContext(e)),(yield*s(e)))});return sI({name:r.name,config:i,contextConfig:a,description:r.description,shortDescription:r.shortDescription,alias:r.alias,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)})}),l8=(0,R.XY)(2,(e,t)=>sI({...sE(e),description:t})),l4=(0,R.XY)(2,(e,t)=>sI({...sE(e),shortDescription:t})),l9=(0,R.XY)(2,(e,t)=>sI({...sE(e),examples:t})),l7=(e,t)=>{let r=sE(e);return U.D9k(function*(n){let i,a,s,o,l,c,{builtIns:u}=yield*sV,{tokens:d,trailingOperands:f}=-1===(i=n.indexOf("--"))?{tokens:sH(n),trailingOperands:[]}:{tokens:sH(n.slice(0,i)),trailingOperands:n.slice(i+1)},h=sU([...u,...(a=[],(s=e=>{for(let t of sE(e).globalFlags)a.push(t);for(let t of e.subcommands)for(let e of t.commands)s(e)})(e),sU(a))]),p=s2(h.flatMap(e=>aK(e.flag)).filter(a$)),{flagMap:m,remainder:g,errors:y}=(o=s5(p.params),l=[],c=(e,t,r)=>{let n=s2(sE(t).config.flags.flatMap(aK).filter(a$)),i=s2(sE(t).contextConfig.flags.flatMap(aK).filter(a$)),a=s3(t.subcommands),s=s1(e),u=[],d=!0;for(let e=s.take();e;e=s.take()){if(s6(e)){let t=or(e,r);if(void 0!==t){on(u,s,e,t);continue}let c=s4(e,i);if(void 0!==c){on(u,s,e,c);continue}let f=s4(e,n),h=s4(e,p);if(void 0!==f&&(void 0===h||!d||!oi(e,s.rest(),f,a,[n,i,p]))){on(u,s,e,f);continue}if(void 0!==h){let t=ot(s,e,h.param,h.negated);if("Error"===t._tag){l.push(t.error);continue}void 0!==t.value&&o[h.param.name].push(t.value);continue}u.push(e);continue}if("Value"===e._tag&&d){let t=a.get(e.value);if(void 0!==t)return u.push(e),u.push(...c(s.rest(),t,[...r,i])),u;d=!1}u.push(e)}return u},{flagMap:o,remainder:c(d,e,[]),errors:l}),b={flags:m,arguments:[]},v=yield*s0({tokens:g,trailingOperands:f},e),w=[e.name,...sZ(v)],x={builtIns:u,command:e,commandPath:w,version:t.version},_=sR(e,w,u),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 aK(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 i6({option:i,suggestions:[],command:n})))}return a})(h,_,m,w);if(k.length>0||y.length>0){let e=v.errors??[];return yield*new an({commandPath:w,errors:[...y,...k,...e]})}for(let r of _){if("Action"!==r._tag||!aK(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===sW)return yield*U.JkU(function*(){yield*i3(lG(e.name,t.version,e.description));let r=[e.name,...n.filter(e=>"--wizard"!==e&&!e.startsWith("--wizard="))],i=yield*lR(e,{commandPath:w,prefix:r});yield*i3(lH(i)),(yield*oA(oN({message:"Run this command?",initial:!0,active:"yes",inactive:"no"})))&&(yield*i3(),yield*l7(e,t)(i.slice(1)))}).pipe(U.KuX("QuitError",()=>i3(lQ())));yield*r.run(i,x);return}if(v.errors&&v.errors.length>0)return yield*new an({commandPath:w,errors:v.errors});let S=yield*U.Ket(r.parse(v));if("Failure"===S._tag)return yield*new an({commandPath:w,errors:[S.failure]});let O=r.handle(S.success,[e.name]),E=_.includes(sz)?(yield*sz.flag.parse(b))[1]:K.none();for(let e of(O=U.PfK(O,sz,E),_)){if("Setting"!==e._tag||e===sz)continue;let[,t]=yield*e.flag.parse(b);O=U.PfK(O,e,t)}let $=K.match(E,{onNone:()=>H.Ie(),onSome:e=>H.L8(aH.zQ,e)});yield*U.PpN(O,$)},U.osR(e=>es.i5(e,i5)&&"ShowHelp"===e._tag?V.Py(e):V.fJ(e),t=>U.hgn(U.JkU(function*(){let{builtIns:r}=yield*sV,n=yield*aQ,i=yield*sL(e,t.commandPath,r);yield*i3(n.formatHelpDoc(i)),t.errors.length>0&&(yield*i2(n.formatErrors(t.errors)))}),U.fJG(t))),U.osR(e=>es.i5(e,nt)?V.Py(e):V.fJ(e),e=>U.GaK))},ce=/(?:https:\/\/(?:www\.)?excalidraw\.com\/)?#json=[A-Za-z0-9_-]+,[A-Za-z0-9_-]{22,}/gu;function ct(e){return e.replace(ce,"[redacted-share-link]")}let cr=new Set(["generate","create","show","edit","patch","list","restore","share","pull","export"]);function cn(e){return{_tag:"File",path:e}}function ci(e){return{_tag:"InlineJson",value:e}}function ca(e="canonical document"){let t=aA("flag","file").pipe(sp("PATH|-"),sh(`Read one ${e} from PATH, or stdin with -.`),sg(cn)),r=aA("flag","json").pipe(sp("VALUE"),sh(`Read one ${e} from inline JSON.`),sg(ci));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):U.fJG(new i7({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:sm(r)}}function cs(e,t){return nh.make({message:e,hint:"Provide operations and optional options or intent only.",details:t})}let co=U.fn("sketchi.cli.patch.decodeInput")(function*(e){if("object"!=typeof e||null===e||Array.isArray(e))return yield*cs("The diagram patch request is invalid.",["patch: Expected an object."]);if("source"in e)return yield*cs("The diagram patch request cannot supply source.",["source: The CLI binds the stored scene."]);if("requestId"in e)return yield*cs("The diagram patch request cannot supply requestId.",["requestId: The CLI owns the patch request id."]);let t=nc.Er.safeParse({...e,requestId:"cli-patch-validation",source:{scene:{diagramId:"validation",title:"Validation",width:1,height:1,accentColor:"#000000",backgroundColor:"#ffffff",elements:[]}}});return t.success?{operations:t.data.operations,...t.data.options?{options:t.data.options}:{},...t.data.intent?{intent:t.data.intent}:{}}:yield*cs("The diagram patch request is invalid.",t.error.issues.map(e=>e.message))}),cl=U.fn("sketchi.cli.patch.parseJson")(function*(e){let t=yield*U.SvU({try:()=>JSON.parse(e),catch:()=>nf.make({code:"invalid_json",message:"The patch input is not valid JSON.",hint:"Pass one complete diagram patch request object."})});return yield*co(t)});class cc extends H.kl()("@sketchi/cli/DiagramPatcher"){}function cu(e){let t=e.ref?.path?` (${e.ref.path})`:"";return`${e.code}${t}: ${e.message}`}function cd(e,t){let r=e.formats.find(e=>e.format===t);return r?.inline!==void 0?U.PyW(r.inline):U.fJG(np.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 cf(e){let t=nc.Uh.safeParse(e);return t.success?U.PyW(t.data):U.fJG(np.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 ch(e){let t=nc.yE.safeParse(e);return t.success?U.PyW(t.data):U.fJG(np.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 cp=W.QZ(cc,U.JkU(function*(){let e=yield*nc.Ov,t=yield*nc.UA;return{patch:U.fn("sketchi.cli.diagram.patch")(function*(r,n,i){let a=yield*(0,nc.OF)({requestId:i,source:{scene:r},operations:n.operations,options:{...n.options,artifactFormats:["scene","excalidraw"],inlineArtifacts:["scene","excalidraw"]},...n.intent?{intent:n.intent}:{}}).pipe(U.PfK(nc.Ov,e),U.PfK(nc.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(cu),"invalid_input"===a.status||"target_not_found"===a.status||"unsupported_operation"===a.status||"connectivity_changed"===a.status?nh.make({message:t,hint:r,details:n}):"storage_failed"===a.status?ng.make({code:"storage_commit_failed",message:t,hint:r}):np.make({status:a.status,message:t,hint:r,details:n}))}return{scene:yield*cd(a.artifact,"scene").pipe(U.qIB(cf)),excalidraw:yield*cd(a.artifact,"excalidraw").pipe(U.qIB(ch))}})}}));class cm extends H.kl()("@sketchi/cli/InputReader"){}function cg(e,t){return U.SvU({try:()=>new TextDecoder("utf-8",{fatal:!0}).decode(e),catch:()=>nf.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 cy=function(e=()=>!0===process.stdin.isTTY){return W.QZ(cm,U.JkU(function*(){let t=yield*nQ,r=yield*r0;return{read:U.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(U.xm_(()=>nf.make({code:"input_read_failed",message:`Unable to read input file ${n.path}.`,hint:"Check the path and file permissions, then retry."})));return yield*cg(e,"file")}if(e())return yield*nf.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*tb(r.stdin,()=>({chunks:[],size:0}),(e,t)=>{let r=t.byteLength+e.size;return void 0!==i.maxBytes&&r>i.maxBytes?U.fJG(nf.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.`})):U.PyW({chunks:[...e.chunks,t],size:r})}).pipe(U.xm_(e=>e instanceof nf?e:nf.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*cg(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")})}}))}(),cb=U.fn("sketchi.cli.input.readDocument")(function*(e){let t=yield*cm,r=yield*t.read(e);return yield*nE(r)}),cv=U.fn("sketchi.cli.input.readPatch")(function*(e){let t=yield*cm,r=yield*t.read(e,{content:"patch request"});return yield*cl(r)});class cw extends H.kl()("@sketchi/cli/OutputWriter"){}class cx extends r7.X0d()("CliCommandExit",{exitCode:r7.wNn}){}function c_(e){return nd.make({cause:e,operation:"write-output",path:"standard stream",message:"Unable to write command output."})}let ck=W.QZ(cw,U.JkU(function*(){let e=yield*r0;return{stdout:t=>((...e)=>td(e))(t).pipe(ty(e.stdout()),U.xm_(c_)),stderr:t=>((...e)=>td(e))(t).pipe(ty(e.stderr()),U.xm_(c_))}}));function cS(e){let t=e.details?.map(e=>` - ${e}`).join("\n");return[`error: ${e.code}`,e.message,`next: ${e.hint}`,...t?["details:",t]:[]].join("\n")+"\n"}let cO=U.fn("sketchi.cli.output.failure")(function*(e,t,r){let n=yield*cw,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"CliStorageError":case"CliExportError":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"CliGenerationError":case"CliShareError":return{code:e.code,message:e.message,hint:e.hint,details:e.details}}}(r),a="json"===t?n$({ok:!1,command:e,error:i}):cS(i);return yield*n.stderr(ct(a)),yield*cx.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":return 3;case"provider_failure":return 10;case"generation_timeout":return 11;case"malformed_output":return 12}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)})}),cE=U.fn("sketchi.cli.output.success")(function*(e,t,r,n,i="stdout"){let a=yield*cw,s="json"===t?n$({ok:!0,command:e,data:r}):n;yield*a[i](s.endsWith("\n")?s:`${s}
|
|
18
|
-
`)});function
|
|
14
|
+
${o}${s}ERRORS${a}`),t))for(let t of e)r.push(` ${t.message}${a}`);return r.join("\n")},formatVersion:(e,t)=>`${i.bold(e)} ${i.dim("v")}${i.bold(t)}`}},a0=e=>e.replace(/\u001B\[[0-9;]*m/g,"").length,a1=(e,t)=>{let r=Math.max(...e.map(e=>a0(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,n-a0(e)),e+" ".repeat(r)}${t}`}).join("\n")},a2=(e,t)=>t?`${e}, ${t}`:e,a5=(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:K.getOrElse(e.description,()=>"")+s}});r.push(a1(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:K.getOrElse(e.description,()=>"")}});r.push(a1(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:K.getOrElse(e.description,()=>"")}});r.push(a1(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(a1(n.commands.map(e=>({left:t.cyan(a2(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(a1(i.commands.map(e=>({left:t.cyan(a2(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")},a3=e=>e.replace(/[^a-zA-Z0-9_]/g,"_"),a6=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},a8=e=>{switch(e._tag){case"Boolean":default:return;case"Choice":return`COMPREPLY=( $(compgen -W '${e.values.join(" ")}' -- "$cur") )`;case"Path":if("directory"===e.pathType)return'COMPREPLY=( $(compgen -d -- "$cur") )';return'COMPREPLY=( $(compgen -f -- "$cur") )'}},a4=e=>{switch(e._tag){case"Choice":return`COMPREPLY=( $(compgen -W '${e.values.join(" ")}' -- "$cur") )`;case"Path":if("directory"===e.pathType)return'COMPREPLY=( $(compgen -d -- "$cur") )';return'COMPREPLY=( $(compgen -f -- "$cur") )';default:return}},a9=(e,t,r)=>{let n=[...t,e.name],i=`_${n.map(a3).join("_")}`;r.push(`${i}()`),r.push("{"),r.push(" local cur prev words cword"),r.push(" _init_completion || return"),r.push("");let a=e.flags.filter(e=>"Boolean"!==e.type._tag);if(a.length>0){for(let e of(r.push(" # Flag value completions"),r.push(' case "$prev" in'),a)){let t=[`--${e.name}`];for(let r of e.aliases)t.push(1===r.length?`-${r}`:`--${r}`);let n=a8(e.type);n&&(r.push(` ${t.join("|")})`),r.push(` ${n}`),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 i cmd"),r.push(" for ((i = 1; i < cword; i++)); do"),r.push(' case "${words[i]}" in'),e.subcommands)){let e=`_${[...n,t.name].map(a3).join("_")}`;r.push(` ${t.name})`),r.push(` ${e}`),r.push(" return"),r.push(" ;;")}r.push(" esac"),r.push(" done"),r.push("")}((e,t)=>{if(0===e.length)return;t.push(" # Build used-flag filter"),t.push(" local -A _flag_groups");let r=0;for(let n of e){for(let e of a6(n))t.push(` _flag_groups[${e}]=${r}`);r++}t.push(" local -A _used_groups"),t.push(" for ((i = 1; i < cword; i++)); do"),t.push(' local _g="${_flag_groups[${words[i]}]:-}"'),t.push(' [[ -n "$_g" ]] && _used_groups[$_g]=1'),t.push(" done"),t.push(' local _filtered_flags=""'),t.push(` for _f in ${e.flatMap(a6).join(" ")}; do`),t.push(' local _g="${_flag_groups[$_f]:-}"'),t.push(' [[ -z "$_g" || -z "${_used_groups[$_g]:-}" ]] && _filtered_flags+=" $_f"'),t.push(" done"),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 s=e.arguments.filter(e=>void 0!==a4(e.type));if(s.length>0)for(let e of(r.push(" # Positional argument completions"),s)){let t=a4(e.type);r.push(` ${t}`),r.push(" return")}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))a9(t,n,r)},a7=e=>e.replace(/'/g,"\\'"),se=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(" ")}`},st=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 '${a7(e.description)}'`);let r=sr(e.type);return r&&t.push(r),t},sr=e=>{switch(e._tag){case"Boolean":return;case"Choice":return`-r -f -a '${e.values.join(" ")}'`;case"Path":return e.pathType,"-r -F";default:return"-r -f"}},sn=e=>{switch(e._tag){case"Choice":return`-r -f -a '${e.values.join(" ")}'`;case"Path":return"-r -F";default:return}},si=(e,t,r,n)=>{let i=((e,t)=>{if(0===e.length)return t.length>0?"__fish_use_subcommand":"";let r=e[e.length-1];return t.length>0?`__fish_seen_subcommand_from ${r}; and not __fish_seen_subcommand_from ${t.join(" ")}`:`__fish_seen_subcommand_from ${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 '${a7(r.name)}'`),r.description&&t.push(`-d '${a7(r.description)}'`),n.push(t.join(" "))}for(let r of t.flags){let t="Boolean"===r.type._tag,a=t?i?`${i}; and ${se(r)}`:se(r):i,s=a?`-n '${a}'`:"",o=[`complete -c ${e}`];if(s&&o.push(s),o.push(...st(r)),n.push(o.join(" ")),t){let t=[`complete -c ${e}`];s&&t.push(s),t.push(`-l no-${r.name}`),r.description&&t.push(`-d '${a7(`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 ${se(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 '${a7(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 '${a7(`Disable ${r.name}`)}'`),n.push(i.join(" "))}}}for(let r of t.arguments){let t=sn(r.type);if(t){let i=[`complete -c ${e}`];a&&i.push(a),i.push(t),r.description&&i.push(`-d '${a7(r.description)}'`),n.push(i.join(" "))}}for(let i of t.subcommands)si(e,i,[...r,i.name],n)},sa=e=>e.replace(/\\/g,"\\\\").replace(/'/g,"'\\''").replace(/:/g,"\\:"),ss=e=>e.replace(/[^a-zA-Z0-9_]/g,"_"),so=e=>{let t=[],r=e.description?`[${sa(e.description)}]`:"",n=(e=>{switch(e._tag){case"Boolean":return"";case"Choice":return`:value:(${e.values.join(" ")})`;case"Path":return"directory"===e.pathType?":directory:_directories":":file:_files";case"Integer":return":integer:";case"Float":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?`[${sa(`Disable ${e.name}`)}]`:"";t.push(`'${i}--no-${e.name}${r}'`)}return t},sl=e=>{let t=e.description?sa(e.description):e.name,r=(e=>{switch(e._tag){case"Choice":return`(${e.values.join(" ")})`;case"Path":return"directory"===e.pathType?"_directories":"_files";default:return""}})(e.type),n=e.variadic?"*":"";return`'${n}:${t}:${r}'`},sc=(e,t,r)=>{let n=[...t,e.name],i=`_${n.map(ss).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?sa(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 so(t))r.push(` ${e}`);for(let t of e.arguments)r.push(` ${sl(t)}`);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(ss).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(...so(r));for(let r of e.arguments)t.push(sl(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))sc(t,n,r)},su=e=>aI({name:e,primitiveType:av,kind:"flag"}),sd=(e,t)=>aC("flag",e,t.map(e=>[e,e])),sf=(0,F.XY)(2,(e,t)=>aN(e,t)),sh=(0,F.XY)(2,(e,t)=>aM(e,t)),sp=(0,F.XY)(2,(e,t)=>aB(e,t)),sm=e=>aU(e),sg=(0,F.XY)(2,(e,t)=>aP(e,t)),sy=(0,F.XY)(3,(e,t,r)=>aL(e,t,r)),sb="~effect/cli/Command/Config/Internal",sv=e=>{let t=[],r=[],n=[];return{[sb]:sb,flags:r,arguments:n,orderedParams:t,tree:function e(i){let a={};for(let s in i)a[s]=function i(a){if(Array.isArray(a))return{_tag:"Array",children:a.map(e=>i(e))};if(!es.i5(a,aS))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)}},sw=sv({}),sx=(e,t)=>{switch(e._tag){case"Param":return{_tag:"Param",index:e.index+t};case"Array":return{_tag:"Array",children:e.children.map(e=>sx(e,t))};case"Nested":return{_tag:"Nested",tree:s_(e.tree,t)}}},s_=(e,t)=>{let r={};for(let n in e)r[n]=sx(e[n],t);return r},sk=(e,t)=>{let r=e.orderedParams.length;return{[sb]:sb,flags:[...e.flags,...t.flags],arguments:[...e.arguments,...t.arguments],orderedParams:[...e.orderedParams,...t.orderedParams],tree:{...e.tree,...s_(t.tree,r)}}},sS=(e,t)=>{let r={};for(let n in e)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 sS(r.tree,t)}}(e[n]);return r},s$="~effect/cli/Command",sE=e=>e,sO={...tO.b({label:"Command",evaluate(){return sE(this).service}})},sI=e=>{let t=e.config,r=e.contextConfig??sw,n=e.service??H.kl(`${s$}/${e.name}`),i=e.annotations??H.Ie(),a=e.globalFlags??[],s=e.subcommands??[],o=e.parse??sT(t),l=e.parseContext??sT(r);return Object.assign(Object.create(sO),{[s$]:s$,name:e.name,examples:e.examples??[],annotations:i,globalFlags:a,subcommands:s,hidden:e.hidden??!1,config:t,contextConfig:r,service:n,parse:o,parseContext:l,handle:(t,r)=>es.EA(e.handle)?e.handle(t,r):U.fJG(new an({commandPath:r,errors:[]})),buildHelpDoc:r=>{let n=[],a=[];for(let e of t.arguments){let t=aK(e),r=aG(e);for(let e of t)n.push({name:e.name,type:e.typeName??a_(e.primitiveType),description:e.description,required:!r.isOptional,variadic:r.isVariadic})}let o=r.length>0?r.join(" "):e.name;for(let e of(s.some(e=>e.commands.some(e=>!e.hidden))&&(o+=" <subcommand>"),o+=" [flags]",n)){let t=e.variadic?`<${e.name}...>`:`<${e.name}>`;o+=` ${e.required?t:`[${t}]`}`}for(let e of t.flags)for(let t of aK(e))t.hidden||a.push(sA(t));let l=[];for(let e of s){let t=e.commands.filter(e=>!e.hidden);0!==t.length&&l.push({group:e.group,commands:z.Tj(t,e=>({name:e.name,alias:e.alias,shortDescription:e.shortDescription,description:e.description??""}))})}let c=e.examples??[];return{description:e.description??"",usage:o,flags:a,annotations:i,...n.length>0&&{args:n},...l.length>0&&{subcommands:l},...c.length>0&&{examples:c}}},...es.EA(e.description)?{description:e.description}:{},...es.EA(e.shortDescription)?{shortDescription:e.shortDescription}:{},...es.EA(e.alias)?{alias:e.alias}:{}})},sA=e=>{let t=e.aliases.map(e=>1===e.length?`-${e}`:`--${e}`);return{name:e.name,aliases:t,type:e.typeName??a_(e.primitiveType),description:sC(e.description,ak(e.primitiveType)),required:"Boolean"!==e.primitiveType._tag}},sC=(e,t)=>{if(void 0===t||0===t.length)return e;let r=`(choices: ${t.join(", ")})`;return K.match(e,{onNone:()=>K.some(r),onSome:e=>K.some(`${e} ${r}`)})},sT=e=>U.D9k(function*(t){let r={flags:t.flags,arguments:t.arguments},n=yield*sN(r,e.orderedParams);return sS(e.tree,n)}),sN=U.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 r}),sM=(e,t,r)=>{let n=sE(e),i=new Set;for(let e of(r?.contextConfig??n.contextConfig).flags)for(let t of aK(e))i.add(t.name);for(let r of t)for(let t of sE(r).config.flags)for(let n of aK(t))if(i.has(n.name))throw new i8({option:n.name,parentCommand:e.name,childCommand:r.name})},sP=e=>{switch(e.primitiveType._tag){case"Boolean":return{_tag:"Boolean"};case"Integer":return{_tag:"Integer"};case"Float":return{_tag:"Float"};case"Date":return{_tag:"Date"};case"Choice":return{_tag:"Choice",values:ak(e.primitiveType)??[]};case"Path":{let t=e.typeName;return{_tag:"Path",pathType:"file"===t?"file":"directory"===t?"directory":"either"}}default:return{_tag:"String"}}},sj=e=>{switch(e.primitiveType._tag){case"Integer":return{_tag:"Integer"};case"Float":return{_tag:"Float"};case"Date":return{_tag:"Date"};case"Choice":return{_tag:"Choice",values:ak(e.primitiveType)??[]};case"Path":{let t=e.typeName;return{_tag:"Path",pathType:"file"===t?"file":"directory"===t?"directory":"either"}}default:return{_tag:"String"}}},sD=e=>{let t=sE(e).config,r=[];for(let e of t.flags)for(let t of aK(e))"flag"===t.kind&&(t.hidden||r.push({name:t.name,aliases:t.aliases,description:K.getOrUndefined(t.description),type:sP(t)}));let n=[];for(let e of t.arguments){let t=aK(e),r=aG(e);for(let e of t)"argument"===e.kind&&n.push({name:e.name,description:K.getOrUndefined(e.description),required:!r.isOptional,variadic:r.isVariadic,type:sj(e)})}let i=[];for(let t of e.subcommands)for(let e of t.commands)e.hidden||i.push(sD(e));return{name:e.name,description:e.shortDescription??e.description,flags:r,arguments:n,subcommands:i}},sU=e=>{let t=new Set,r=[];for(let n of e)t.has(n)||(t.add(n),r.push(n));return r},sR=(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},sF=(e,t,r)=>sU([...r,...sR(e,t).flatMap(e=>sE(e).globalFlags)]),sL=(e,t,r)=>U.JkU(function*(){let n=sR(e,t),i=sE(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 sE(t).contextConfig.flags)for(let t of aK(e))!r.has(t.name)&&(t.hidden||(r.add(t.name),n.push(sA(t))));return n})(n,i.flags),s=sF(e,t,r),o=[];for(let e of s)for(let t of aK(e.flag))t.hidden||o.push({...sA(t),required:!1});return{...i,flags:[...a,...i.flags],globalFlags:o}}),sB=e=>({_tag:"Action",flag:e.flag,run:e.run}),sY=0,sq=sB({flag:su("help").pipe(sf("h"),sh("Show help information")),run:U.D9k(function*(e,{builtIns:t,command:r,commandPath:n}){let i=yield*aQ,a=yield*sL(r,n,t);yield*i5(i.formatHelpDoc(a))})}),sW=sB({flag:su("version").pipe(sf("v"),sh("Show version information")),run:U.D9k(function*(e,{command:t,version:r}){let n=yield*aQ;yield*i5(n.formatVersion(t.name,r))})}),sX=sB({flag:su("wizard").pipe(sh("Start wizard mode for a command")),run:()=>U.rIH}),sJ=sB({flag:sd("completions",["bash","zsh","fish","sh"]).pipe(sm,sg(e=>K.map(e,e=>"sh"===e?"bash":e)),sp("<bash|zsh|fish|sh>"),sh("Print shell completion script")),run:U.D9k(function*(e,{command:t}){if(K.isNone(e))return;let r=sD(t);yield*i5(((e,t,r)=>{switch(t){case"bash":let n=[],i=a3(e);return n.push(`###-begin-${e.replace(/'/g,"'\\''")}-completions-###`),n.push("#"),n.push("# Static completion script for Bash"),n.push("#"),n.push("# Installation:"),n.push(`# ${e.replace(/'/g,"'\\''")} --completions bash >> ~/.bashrc`),n.push("#"),n.push(""),n.push("if ! type _init_completion &>/dev/null; then"),n.push(" _init_completion()"),n.push(" {"),n.push(" COMPREPLY=()"),n.push(' cur="${COMP_WORDS[COMP_CWORD]}"'),n.push(' prev="${COMP_WORDS[COMP_CWORD-1]}"'),n.push(' words=("${COMP_WORDS[@]}")'),n.push(" cword=$COMP_CWORD"),n.push(" }"),n.push("fi"),n.push(""),a9(r,[],n),n.push(`complete -F _${i} ${e.replace(/'/g,"'\\''")}`),n.push(`###-end-${e.replace(/'/g,"'\\''")}-completions-###`),n.join("\n");case"zsh":let a,s;return a=[],s=ss(e),a.push(`#compdef ${e}`),a.push(`###-begin-${e}-completions-###`),a.push("#"),a.push("# Static completion script for Zsh"),a.push("#"),a.push("# Installation:"),a.push(`# ${e} --completions zsh > ~/.zsh/completions/_${e}`),a.push("# then add ~/.zsh/completions to your fpath"),a.push("#"),a.push(""),sc(r,[],a),a.push("# Handle both direct invocation and autoload"),a.push('if [[ "${zsh_eval_context[-1]}" == "loadautofunc" ]]; then'),a.push(` _${s} "$@"`),a.push("else"),a.push(` compdef _${s} ${e}`),a.push("fi"),a.push(`###-end-${e}-completions-###`),a.join("\n");case"fish":let o;return(o=[]).push(`###-begin-${e}-completions-###`),o.push("#"),o.push("# Static completion script for Fish"),o.push("#"),o.push("# Installation:"),o.push(`# ${e} --completions fish > ~/.config/fish/completions/${e}.fish`),o.push("#"),o.push(""),si(e,r,[],o),o.push(""),o.push(`###-end-${e}-completions-###`),o.join("\n")}})(t.name,e.value,r))})}),sz=(A="log-level",e=>(sY+=1,Object.assign(H.kl(`effect/unstable/cli/GlobalFlag/${A}/${sY}`),{_tag:"Setting",id:A,flag:e.flag})))({flag:aC("flag","log-level",[["all","All"],["trace","Trace"],["debug","Debug"],["info","Info"],["warn","Warn"],["warning","Warn"],["error","Error"],["fatal","Fatal"],["none","None"]]).pipe(sm,sh("Sets the minimum log level"),sp("<all|trace|debug|info|warn|warning|error|fatal|none>"))}),sK=[sq,sW,sX,sJ,sz];class sV extends H.Or("effect/unstable/cli/CliConfig",{defaultValue:()=>sG}){}let sG={builtIns:sK},sH=e=>{let t=[];for(let r of e)if(r.startsWith("-"))if(r.startsWith("--")){let[e,n]=r.slice(2).split("=",2);t.push({_tag:"LongOption",name:e,raw:r,value:n})}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});else t.push({_tag:"Value",value:r});return t},sQ=(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)},sZ=e=>K.match(e.subcommand,{onNone:()=>[],onSome:e=>[e.name,...sZ(e.parsedInput)]}),s0=(e,t,r=[])=>U.JkU(function*(){let{tokens:n,trailingOperands:i}=e,a=[...r,t.name],s=sE(t),o=s.config.flags.flatMap(aK).filter(aO),l=s2(o),c=s.contextConfig.flags.flatMap(aK).filter(aO),u=s2(c),d=new Set(c.map(e=>e.name)),f=oo(n,{command:t,commandPath:a,flagRegistry:l,inheritedFlagRegistry:u,localFlagNames:o.filter(e=>!d.has(e.name)).map(e=>e.name)});if("Leaf"===f._tag)return{flags:f.flags,arguments:[...f.arguments,...i],subcommand:K.none(),...f.errors.length>0&&{errors:f.errors}};let h={tokens:f.childTokens,trailingOperands:[]},p=yield*s0(h,f.sub,a),m=[...f.errors,...p.errors??[]];return{flags:f.flags,arguments:i,subcommand:K.some({name:f.sub.name,parsedInput:p}),...m.length>0&&{errors:m}}}),s1=e=>{let t=0;return{peek:()=>e[t],take:()=>e[t++],rest:()=>e.slice(t)}},s2=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}},s5=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},s3=e=>Object.fromEntries(e.map(e=>[e.name,[]])),s6=e=>"LongOption"===e._tag||"ShortOption"===e._tag,s8=e=>"LongOption"===e._tag?e.name:e.flag,s4=(e,t)=>{let r=s8(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&&ag(n.primitiveType))return{param:n,negated:!0}}if(n)return{param:n,negated:!1}},s9=(e,t,r)=>new i7({option:t.name,value:r,expected:`omit the value and use ${e.raw} by itself to set --${t.name} to false`,kind:"flag"}),s7=e=>e?._tag==="Value"&&(ap(e.value)||am(e.value))?e.value:void 0,oe=(e,t,r,n=!1)=>{let i=ot(e,t,r,n);switch(i._tag){case"Value":return{_tag:"Value",value:i.value};case"Error":return{_tag:"Error",error:i.error}}},ot=(e,t,r,n=!1)=>{let i;if(n){if(void 0!==t.value)return{_tag:"Error",error:s9(t,r,t.value),tokens:[]};let n=s7(e.peek());if(void 0!==n){let i=e.take();return{_tag:"Error",error:s9(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(ag(r.primitiveType)){let t=s7(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=ak(r.primitiveType),new i7({option:r.name,value:"",expected:void 0===i?r.typeName??a_(r.primitiveType):i.join(" | "),kind:"flag"})),tokens:[]}},or=(e,t)=>{for(let r of t){let t=s4(e,r);if(void 0!==t)return t}},on=(e,t,r,n)=>{e.push(r);let i=ot(t,r,n.param,n.negated);e.push(...i.tokens)},oi=(e,t,r,n,i)=>{let a=s1(t);ot(a,e,r.param,r.negated);for(let e=a.take();e;e=a.take()){if(s6(e)){let t=or(e,i);void 0!==t&&ot(a,e,t.param,t.negated);continue}if("Value"===e._tag)return n.has(e.value)}return!1},oa=(e,t,r,n)=>{let{commandPath:i,flagRegistry:a}=r,s=s4(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),ag(e.primitiveType)&&i.push(`no-${e.name}`),e.aliases))i.push(t);return new i6({option:n,suggestions:sQ(s8(e),i).map(e=>1===e.length?`-${e}`:`--${e}`),command:r})})(e,a.params,i));let o=oe(t,e,s.param,s.negated);"Error"===o._tag?n.errors.push(o.error):n.flags.add(s.param.name,o.value)},os=(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=s5(i.subcommands),c=l.get(e);if(c){let e=[...a,c.name],r=n.flags.snapshot();for(let t of o){let i=r[t];void 0!==i&&i.length>0&&n.errors.push(new i6({option:`--${t}`,suggestions:[],command:e}))}let i=((e,t)=>{let r=s3(t.params),n=[],i=[],a=s1(e);for(let e=a.take();e;e=a.take()){if(!s6(e)){n.push(e);continue}let s=s4(e,t);if(!s){n.push(e);continue}let o=oe(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:c,childTokens:i.remainder,errors:n.errors}}}if(!(sE(i).config.arguments.length>0)&&l.size>0){let t=[];for(let[e,r]of l)r.hidden||t.push(e);let r=sQ(e,t);n.errors.push(new ae({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)},oo=(e,t)=>{let r,n=s1(e),i={flags:(r=s3(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(s6(e)){oa(e,n,t,i);continue}if("Value"===e._tag){let r=os(e.value,n,t,i);if(r)return r}}return{_tag:"Leaf",flags:i.flags.snapshot(),arguments:i.arguments,errors:i.errors}};var ol=n(8036),oc=n(4450);let ou=new WeakMap,od="~effect/data/Redacted",of=(e,t)=>{let r=Object.create(oh);return t?.label&&(r.label=t.label),ou.set(r,e),r},oh={[od]:{_A:e=>e},label:void 0,...el.fU,toJSON(){return this.toString()},toString(){return`<redacted${(0,es.Kg)(this.label)?":"+this.label:""}>`},[oc.HR](){return oc.tW(ou.get(this))},[ol.HR](e){return(0,es.i5)(e,od)&&ol.aI(ou.get(this),ou.get(e))}},op=e=>{if(ou.has(e))return ou.get(e);throw Error("Unable to get redacted value"+(e.label?` with label: "${e.label}"`:""))};var om=n(1044),og=n(6364);es.Et,og.wN,om.wN;let oy=(0,F.XY)(2,(e,t)=>{let r=Math.pow(10,t);return Math.round(e*r)/r}),ob=(e,...t)=>{let r=t.flat();return`${r.join("")}${e}[0m`},ov={arrowUp:"↑",arrowDown:"↓",arrowLeft:"←",arrowRight:"→",radioOn:"◉",radioOff:"◯",checkboxOn:"☒",checkboxOff:"☐",tick:"✔",cross:"✖",ellipsis:"…",pointerSmall:"›",line:"─",pointer:"❯"},ow={arrowUp:ov.arrowUp,arrowDown:ov.arrowDown,arrowLeft:ov.arrowLeft,arrowRight:ov.arrowRight,radioOn:"(*)",radioOff:"( )",checkboxOn:"[*]",checkboxOff:"[ ]",tick:"√",cross:"×",ellipsis:"...",pointerSmall:"»",line:"─",pointer:">"},ox=U.TjK(U.OH5(()=>"win32"===process.platform),e=>e?ow:ov),o_=e=>ob(e,"\x1b[1m"),ok=e=>ob(e,((...e)=>e)("\x1b[3m","\x1b[31m")),oS=e=>{let t={initial:!1,...e,label:{confirm:"yes",deny:"no",...e.label},placeholder:{defaultConfirm:"(Y/n)",defaultDeny:"(y/N)",...e.placeholder}};return o$({value:t.initial},{render:oW(t),process:e=>oz(e,t.initial),clear:oL(t)})},o$=(e,...t)=>{let[r,n]=1===t.length?[void 0,t[0]]:[t[0],t[1]],i=Object.create(oM);return i._tag="Loop",i.initialState=e,i.render=n.render,i.process=n.process,i.clear=n.clear,i.events=r,i},oE=(0,F.XY)(2,(e,t)=>{let r=Object.create(oM);return r._tag="OnSuccess",r.prompt=e,r.onSuccess=t,r}),oO=e=>{let t={default:0,min:-1/0,max:1/0,incrementBy:1,decrementBy:1,validate:e=>e<t.min?U.fJG(`${e} must be greater than or equal to ${t.min}`):e>t.max?U.fJG(`${e} must be less than or equal to ${t.max}`):U.PyW(e),...e},r=void 0===e.default?"":`${t.default}`;return o$({cursor:r.length,value:r,error:K.none()},{render:lu(t),process:ld(t),clear:ln(t)})},oI=(0,F.XY)(2,(e,t)=>oE(e,e=>oT(t(e)))),oA=U.D9k(function*(e){let t=yield*nn,r=yield*t.readInput;return yield*oP(e,t,r)},U.xm_(()=>new nr({})),U.P1j),oC=e=>{let t={maxPerPage:10,...e};return o$((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:lb(t),process:lw(t),clear:lv(t)})},oT=e=>{let t=Object.create(oM);return t._tag="Succeed",t.value=e,t},oN=e=>{let t={initial:!1,active:"on",inactive:"off",...e};return o$(t.initial,{render:lD(t),process:lU,clear:()=>lA(t)})},oM={...tO.b({label:"Prompt",evaluate(){return oA(this)}}),"~effect/cli/Prompt":{_Output:e=>e}},oP=(e,t,r)=>U.DYE(()=>{switch(e._tag){case"Loop":return oj(e,t,r);case"OnSuccess":return U.qIB(oP(e.prompt,t,r),n=>oP(e.onSuccess(n),t,r));case"Succeed":return U.PyW(e.value)}}),oj=U.D9k(function*(e,t,r){let n=U.yw5(e.initialState)?yield*e.initialState:e.initialState,i=oD.NextFrame({state:n});for(;;){let a=yield*e.render(n,i);if(yield*U.QgK(t.display(a)),e.events){let t=eE(r).pipe(U.TjK(e=>({_tag:"Input",input:e}))),a=yield*U.KT6(t,eE(e.events).pipe(U.TjK(e=>({_tag:"Event",value:e}))));i=yield*e.process(a,n)}else{let t=yield*eE(r);i=yield*e.process(t,n)}switch(i._tag){case"Beep":continue;case"NextFrame":yield*U.QgK(t.display((yield*e.clear(n,i)))),n=i.state;continue;case"Submit":{yield*U.QgK(t.display((yield*e.clear(n,i))));let r=yield*e.render(n,i);return yield*U.QgK(t.display(r)),i.value}}}},(e,t,r)=>U.yeE(e,U.QgK(r.display("\x1b[?25h")))),oD=Q.Ij(),oU=(e,t)=>{if(0===t){var r;return"\x1b[2K"+(void 0===r?`\x1b${Math.max(1,0)} G`:`\x1b${r+1};${Math.max(1,0)} H`)}let n=0;for(let r of e.split(oF))n+=1+Math.floor(Math.max(r.length-1,0)/t);var i=n;let a="";for(let e=0;e<i;e++)a+="\x1b[2K"+(e<i-1?"\x1b[1A":"");return i>0&&(a+="\x1b[G"),a},oR=(e,t,r)=>{if(void 0!==r&&r.length>0){let n;return((e=1)=>`\x1b[${e}B`)((n=r.split(oF),0===t?n.length:(0,F.Fs)(z.Tj(n,e=>Math.ceil(e.length/t)),z.TS(0,(e,t)=>e+t))))+oU(`
|
|
15
|
+
${r}`,t)+oU(e,t)}return oU(e,t)},oF=/\r?\n/,oL=e=>U.D9k(function*(t,r){let n=yield*nn,i=yield*n.columns,a=yield*ox;return oU(oB(t.value?e.placeholder.defaultConfirm:e.placeholder.defaultDeny,"?",a.pointerSmall,e,{plain:!0}),i)+"\x1b[2K\x1b[G"}),oB=(e,t,r,n,i)=>lt(e,n.message,t,r,i),oY=U.D9k(function*(e,t){let r=yield*ox,n=ob("?","\x1b[96m"),i=ob(r.pointerSmall,"\x1b[90m");return"\x1b[?25l"+oB(ob(e.value?t.placeholder.defaultConfirm:t.placeholder.defaultDeny,"\x1b[90m"),n,i,t)}),oq=U.D9k(function*(e,t){let r=yield*ox,n=ob(r.tick,"\x1b[32m"),i=ob(r.ellipsis,"\x1b[90m");return oB(e?t.label.confirm:t.label.deny,n,i,t)+"\n"}),oW=e=>(t,r)=>oD.$match(r,{Beep:()=>U.PyW("\x07"),NextFrame:({state:t})=>oY(t,e),Submit:({value:t})=>oq(t,e)}),oX=/^y|t$/,oJ=/^n|f$/,oz=(e,t)=>{let r=K.getOrElse(e.input,()=>"");return"enter"===e.key.name||"return"===e.key.name?U.PyW(oD.Submit({value:t})):oX.test(r.toLowerCase())?U.PyW(oD.Submit({value:!0})):oJ.test(r.toLowerCase())?U.PyW(oD.Submit({value:!1})):U.PyW(oD.Beep())},oK=(e,t=!1)=>z.TS(e.dateParts,"",(r,n,i)=>{let a=n.toString();return i!==e.cursor||t?r+a:r+ob(a,((...e)=>e)("\x1b[4m","\x1b[96m"))}),oV=(e,t,r,n,i)=>lt(r,n.message,e,t,i),oG=U.D9k(function*(e,t){let r=yield*ox;return"\x1b[?25l"+oV(ob("?","\x1b[96m"),ob(r.pointerSmall,"\x1b[90m"),oK(e),t)+((e,t)=>{if(K.isSome(e.error)){let r=e.error.value.split(oF);if(z.ET(r))return"\x1b[s\n"+(ob(t,"\x1b[31m")+" ")+z.Tj(r,e=>ok(e)).join("\n")+"\x1b[u"}return""})(e,r.pointerSmall)}),oH=U.D9k(function*(e,t){let r=yield*ox;return oV(ob(r.tick,"\x1b[32m"),ob(r.ellipsis,"\x1b[90m"),oK(e,!0),t)+"\n"}),oQ={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"]},oZ=/\\(.)|"((?:\\["\\]|[^"])+)"|(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,o0={1:({token:e,...t})=>new o2({token:e.replace(/\\(.)/g,"$1"),...t}),2:e=>new o4(e),3:e=>new o9(e),4:e=>new o7(e),5:e=>new le(e),6:e=>new o8(e),7:e=>new o6(e),8:e=>new o3(e),9:e=>new o5(e)};class o1{token;date;parts;locales;constructor(e){this.token=e.token,this.locales=e.locales,this.date=e.date||new Date,this.parts=e.parts||[this]}isToken(){return!1}nextPart(){let e=K.getOrElse(z.g9(this.parts,e=>e===this),()=>0);return z.i8(this.parts.slice(e+1),e=>!e.isToken())}previousPart(){let e=z.g9(this.parts,e=>e===this);return K.isSome(e)?z.Uk(this.parts.slice(0,e.value),e=>!e.isToken()):K.none()}toString(){return String(this.date)}}class o2 extends o1{increment(){}decrement(){}setValue(e){this.token=this.token+e}isToken(){return!0}toString(){return this.token}}class o5 extends o1{increment(){this.date.setMilliseconds(this.date.getMilliseconds()+1)}decrement(){this.date.setMilliseconds(this.date.getMilliseconds()-1)}setValue(e){this.date.setMilliseconds(Number.parseInt(e.slice(-this.token.length)))}toString(){return`${this.date.getMilliseconds()}`.padStart(4,"0").substring(0,this.token.length)}}class o3 extends o1{increment(){this.date.setSeconds(this.date.getSeconds()+1)}decrement(){this.date.setSeconds(this.date.getSeconds()-1)}setValue(e){this.date.setSeconds(Number.parseInt(e.slice(-2)))}toString(){let e=`${this.date.getSeconds()}`;return this.token.length>1?e.padStart(2,"0"):e}}class o6 extends o1{increment(){this.date.setMinutes(this.date.getMinutes()+1)}decrement(){this.date.setMinutes(this.date.getMinutes()-1)}setValue(e){this.date.setMinutes(Number.parseInt(e.slice(-2)))}toString(){let e=`${this.date.getMinutes()}`;return this.token.length>1?e.padStart(2,"0"):e}}class o8 extends o1{increment(){this.date.setHours(this.date.getHours()+1)}decrement(){this.date.setHours(this.date.getHours()-1)}setValue(e){this.date.setHours(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 o4 extends o1{increment(){this.date.setDate(this.date.getDate()+1)}decrement(){this.date.setDate(this.date.getDate()-1)}setValue(e){this.date.setDate(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){switch(e%10){case 1:return"st";case 2:return"nd";case 3:return"rd";default:return"th"}}}class o9 extends o1{increment(){this.date.setMonth(this.date.getMonth()+1)}decrement(){this.date.setMonth(this.date.getMonth()-1)}setValue(e){let t=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 o7 extends o1{increment(){this.date.setFullYear(this.date.getFullYear()+1)}decrement(){this.date.setFullYear(this.date.getFullYear()-1)}setValue(e){this.date.setFullYear(Number.parseInt(e.slice(-4)))}toString(){let e=`${this.date.getFullYear()}`.padStart(4,"0");return 2===this.token.length?e.substring(-2):e}}class le extends o1{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 lt=(e,t,r,n,i)=>{let a=r+" ",s=i?.plain===!0?e=>e:o_;return z.YW(t.split(oF),{onEmpty:()=>a+" "+n+" "+e,onNonEmpty:t=>a+z.Tj(t,e=>s(e)).join("\n")+" "+n+" "+e})},lr=(e,t,r)=>!e.disabled&&e.description&&t?r?.plain===!0?"- "+e.description:ob("- "+e.description,"\x1b[90m"):"",ln=e=>U.D9k(function*(t,r){let n=yield*nn,i=yield*n.columns,a=yield*ox,s=li(t,a.pointerSmall,{plain:!0});return oR(la(t,"?",a.pointerSmall,e,{plain:!0}),i,s)+"\x1b[2K\x1b[G"}),li=(e,t,r)=>K.isSome(e.error)?z.YW(e.error.value.split(oF),{onEmpty:()=>"",onNonEmpty:e=>r?.plain===!0?`${t} ${e.join("\n")}`:"\x1b[s\n"+(ob(t,"\x1b[31m")+" ")+z.Tj(e,e=>ok(e)).join("\n")+"\x1b[u"}):"",la=(e,t,r,n,i,a=!1)=>{let s;return lt((s=""===e.value?"":`${e.value}`,a||i?.plain===!0?s:ob(s,K.isSome(e.error)?"\x1b[31m":((...e)=>e)("\x1b[4m","\x1b[96m"))),n.message,t,r,i)},ls=U.D9k(function*(e,t){let r=yield*ox,n=ob("?","\x1b[96m"),i=ob(r.pointerSmall,"\x1b[90m"),a=li(e,r.pointerSmall);return la(e,n,i,t)+a}),lo=U.D9k(function*(e,t){let r=yield*ox;return la(e,ob(r.tick,"\x1b[32m"),ob(r.ellipsis,"\x1b[90m"),t,void 0,!0)+"\n"}),ll=e=>{if(e.value.length<=0)return U.PyW(oD.Beep());let t=e.value.slice(0,e.value.length-1);return U.PyW(oD.NextFrame({state:{...e,value:t,error:K.none()}}))},lc=e=>U.PyW(oD.NextFrame({state:{...e,cursor:0,value:"",error:K.none()}})),lu=e=>(t,r)=>oD.$match(r,{Beep:()=>U.PyW("\x07"),NextFrame:({state:t})=>ls(t,e),Submit:()=>lo(t,e)}),ld=e=>(t,r)=>{if(t.key.ctrl&&"u"===t.key.name)return lc(r);switch(t.key.name){case"backspace":return ll(r);case"k":case"up":return U.PyW(oD.NextFrame({state:{...r,value:""===r.value||"-"===r.value?`${e.incrementBy}`:`${Number.parseInt(r.value)+e.incrementBy}`,error:K.none()}}));case"j":case"down":return U.PyW(oD.NextFrame({state:{...r,value:""===r.value||"-"===r.value?`-${e.decrementBy}`:`${Number.parseInt(r.value)-e.decrementBy}`,error:K.none()}}));case"enter":case"return":{let t=Number.parseInt(r.value);if(Number.isNaN(t))return U.PyW(oD.NextFrame({state:{...r,error:K.some("Must provide an integer value")}}));return U.YWq(e.validate(t),{onFailure:e=>oD.NextFrame({state:{...r,error:K.some(e)}}),onSuccess:e=>oD.Submit({value:e})})}default:var n=K.getOrElse(t.input,()=>"");if(0===r.value.length&&"-"===n)return U.PyW(oD.NextFrame({state:{...r,value:"-",error:K.none()}}));let i=Number.parseInt(r.value+n);return Number.isNaN(i)?U.PyW(oD.Beep()):U.PyW(oD.NextFrame({state:{...r,value:`${i}`,error:K.none()}}))}},lf=(e,t,r,n)=>lt("",r.message,e,t,n),lh=(e,t,r,n,i,a)=>{let s=" ";if(n===r.startIndex&&r.startIndex>0?s=i.arrowUp:n===r.endIndex-1&&r.endIndex<t.length&&(s=i.arrowDown),a?.plain===!0)return e===n?i.pointer+s:s+" ";if(t[n].disabled){let t=((...e)=>e)("\x1b[1m","\x1b[90m");return e===n?ob(i.pointer,t)+s:s+" "}return e===n?ob(i.pointer,"\x1b[96m")+s:s+" "},lp=(e,t,r)=>{if(r?.plain===!0)return e.title;let n=e.title;return t?e.disabled?ob(n,((...e)=>e)("\x1b[4m","\x1b[90m")):ob(n,((...e)=>e)("\x1b[4m","\x1b[96m")):e.disabled?ob(n,((...e)=>e)("\x1b[9m","\x1b[90m")):n},lm=(e,t,r,n)=>{let i=t.choices,a=lR(e,i.length,t.maxPerPage),s=[];for(let t=a.startIndex;t<a.endIndex;t++){let o=i[t],l=e===t,c=lh(e,i,a,t,r,n),u=lp(o,l,n),d=lr(o,l,n);s.push(c+u+" "+d)}return s.join("\n")},lg=U.D9k(function*(e,t){let r=yield*ox,n=lm(e,t,r);return"\x1b[?25l"+lf(ob("?","\x1b[96m"),ob(r.pointerSmall,"\x1b[90m"),t)+"\n"+n}),ly=U.D9k(function*(e,t){let r=yield*ox,n=t.choices[e].title;return lf(ob(r.tick,"\x1b[32m"),ob(r.ellipsis,"\x1b[90m"),t)+" "+ob(n,"\x1b[37m")+"\n"}),lb=e=>(t,r)=>oD.$match(r,{Beep:()=>U.PyW("\x07"),NextFrame:({state:t})=>lg(t,e),Submit:()=>ly(t,e)}),lv=e=>U.D9k(function*(t,r){let n=yield*nn,i=yield*n.columns,a=yield*ox,s=lf("?",a.pointerSmall,e,{plain:!0}),o=lm(t,e,a,{plain:!0});return oU(`${s}
|
|
16
|
+
${o}`,i)+"\x1b[2K\x1b[G"}),lw=e=>(t,r)=>{var n;switch(t.key.name){case"k":case"up":return n=e.choices,0===r?U.PyW(oD.NextFrame({state:n.length-1})):U.PyW(oD.NextFrame({state:r-1}));case"j":case"down":return r===e.choices.length-1?U.PyW(oD.NextFrame({state:0})):U.PyW(oD.NextFrame({state:r+1}));case"tab":let i;return i=e.choices,U.PyW(oD.NextFrame({state:(r+1)%i.length}));case"enter":case"return":{let t=e.choices[r];if(t.disabled)return U.PyW(oD.Beep());return U.PyW(oD.Submit({value:t.value}))}default:return U.PyW(oD.Beep())}},lx=U.D9k(function*(e,t){let r=yield*nn,n=yield*r.columns,i=yield*ox,a=l_(e,i.pointerSmall,{plain:!0});return oR(lk(e,"?",i.pointerSmall,t,{plain:!0}),n,a)+"\x1b[2K\x1b[G"}),l_=(e,t,r)=>K.isSome(e.error)?z.YW(e.error.value.split(oF),{onEmpty:()=>"",onNonEmpty:e=>r?.plain===!0?`${t} ${e.join("\n")}`:"\x1b[s\n"+(ob(t,"\x1b[31m")+" ")+z.Tj(e,e=>ok(e)).join("\n")+"\x1b[u"}):"",lk=(e,t,r,n,i,a=!1)=>lt(((e,t,r,n)=>{let i=e.value;if(n?.plain===!0)switch(t.type){case"hidden":return"";case"password":return"*".repeat(i.length);case"text":return i}let a=K.isSome(e.error)?"\x1b[31m":r?"\x1b[37m":0===e.value.length?"\x1b[90m":((...e)=>e)("\x1b[4m","\x1b[96m");switch(t.type){case"hidden":return"";case"password":return ob("*".repeat(i.length),a);case"text":return ob(i,a)}})(e,n,a,i),n.message,t,r,i),lS=U.D9k(function*(e,t){let r=yield*ox;return lk(e,ob("?","\x1b[96m"),ob(r.pointerSmall,"\x1b[90m"),t)+l_(e,r.pointerSmall)+((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)}),l$=U.D9k(function*(e,t){let r=yield*ox;return lk(e,ob(r.tick,"\x1b[32m"),ob(r.ellipsis,"\x1b[90m"),t,void 0,!0)+"\n"}),lE=e=>U.PyW(oD.NextFrame({state:{...e,cursor:0,error:K.none()}})),lO=e=>U.PyW(oD.NextFrame({state:{...e,cursor:e.value.length,error:K.none()}})),lI=(e,t)=>{let r={default:"",type:t,validate:U.PyW,...e};return o$({cursor:r.default.length,value:r.default,error:K.none()},{render:(e,t)=>oD.$match(t,{Beep:()=>U.PyW("\x07"),NextFrame:({state:e})=>lS(e,r),Submit:()=>l$(e,r)}),process:(e,t)=>{if(e.key.ctrl)switch(e.key.name){case"u":return U.PyW(oD.NextFrame({state:{...t,cursor:0,value:"",error:K.none()}}));case"a":return lE(t);case"e":return lO(t);default:return U.PyW(oD.Beep())}switch(e.key.name){case"backspace":var n;if(t.cursor<=0)return U.PyW(oD.Beep());let i=t.value.slice(0,t.cursor-1),a=t.value.slice(t.cursor),s=t.cursor-1,o=`${i}${a}`;return U.PyW(oD.NextFrame({state:{...t,cursor:s,value:o,error:K.none()}}));case"left":if(t.cursor<=0)return U.PyW(oD.Beep());let l=t.cursor-1;return U.PyW(oD.NextFrame({state:{...t,cursor:l,error:K.none()}}));case"right":if(t.cursor>=t.value.length)return U.PyW(oD.Beep());let c=Math.min(t.cursor+1,t.value.length);return U.PyW(oD.NextFrame({state:{...t,cursor:c,error:K.none()}}));case"home":return lE(t);case"end":return lO(t);case"enter":case"return":{let e=t.value;return U.YWq(r.validate(e),{onFailure:r=>oD.NextFrame({state:{...t,value:e,error:K.some(r)}}),onSuccess:e=>oD.Submit({value:e})})}case"tab":if(t.value===r.default)return U.PyW(oD.Beep());let u=0===t.value.length?r.default:t.value;return U.PyW(oD.NextFrame({state:{...t,value:u,cursor:u.length,error:K.none()}}));default:let d,f,h,p;return n=K.getOrElse(e.input,()=>""),d=t.value.slice(0,t.cursor),f=t.value.slice(t.cursor),h=`${d}${n}${f}`,p=t.cursor+n.length,U.PyW(oD.NextFrame({state:{...t,cursor:p,value:h,error:K.none()}}))}},clear:(e,t)=>lx(e,r)})},lA=U.D9k(function*(e){let t=yield*nn,r=yield*t.columns,n=yield*ox;return oU(lt(`${e.active} / ${e.inactive}`,e.message,"?",n.pointerSmall,{plain:!0}),r)+"\x1b[2K\x1b[G"}),lC=(e,t,r=!1)=>{let n=ob("/","\x1b[90m"),i=((...e)=>e)("\x1b[4m",r?"\x1b[37m":"\x1b[96m"),a=e?t.inactive:ob(t.inactive,i);return(e?ob(t.active,i):t.active)+" "+n+" "+a},lT=(e,t,r,n)=>{let i=n.message.split(oF),a=t+" ";return z.ET(i)?a+z.Tj(i,e=>o_(e)).join("\n")+" "+r+" "+e:a+" "+r+" "+e},lN=U.D9k(function*(e,t){let r=yield*ox,n=ob("?","\x1b[96m"),i=ob(r.pointerSmall,"\x1b[90m");return"\x1b[?25l"+lT(lC(e,t),n,i,t)}),lM=U.D9k(function*(e,t){let r=yield*ox,n=ob(r.tick,"\x1b[32m"),i=ob(r.ellipsis,"\x1b[90m");return lT(lC(e,t,!0),n,i,t)+"\n"}),lP=U.PyW(oD.NextFrame({state:!0})),lj=U.PyW(oD.NextFrame({state:!1})),lD=e=>(t,r)=>{switch(r._tag){case"Beep":return U.PyW("\x07");case"NextFrame":return lN(t,e);case"Submit":return lM(t,e)}},lU=(e,t)=>{switch(e.key.name){case"0":case"j":case"delete":case"right":case"down":return lj;case"1":case"k":case"left":case"up":return lP;case" ":case"tab":return t?lj:lP;case"enter":case"return":return U.PyW(oD.Submit({value:t}));default:return U.PyW(oD.Beep())}},lR=(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}},lF=U.D9k(function*(e,t){let r=t?.commandPath??[e.name],n=lL(e,r),i=[...t?.prefix??r];return yield*lK(i),yield*lB(n,i,n===e?"ROOT":n.name),i}),lL=(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},lB=U.D9k(function*(e,t,r){let n=sE(e),i=e.subcommands.flatMap(e=>e.commands.filter(e=>!e.hidden)),a=0===i.length?n.config:n.contextConfig;if(a.flags.length>0){for(let e of(yield*i5(lV(r,"FLAGS")),a.flags))t.push(...yield*lq(e));(a.arguments.length>0||i.length>0)&&(yield*lK(t))}if(a.arguments.length>0){for(let e of(yield*i5(lV(r,"ARGUMENTS")),a.arguments))t.push(...yield*lq(e));i.length>0&&(yield*lK(t))}if(0===i.length)return;let s=yield*oA(oC({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*i5(),t.push(s.name),lY(s)&&(yield*lK(t)),yield*lB(s,t,s.name)}),lY=e=>e.subcommands.some(e=>e.commands.some(e=>!e.hidden))||sE(e).config.orderedParams.length>0,lq=U.D9k(function*(e){let t=aV(e),r=aG(e);if(r.isOptional&&!(yield*oA(oS({message:`Set ${lJ(t)}?`,initial:!1}))))return yield*i5(),[];let n=r.isVariadic?yield*oA(oO({message:`${lJ(t)} count`,default:K.getOrElse(r.variadicMin,()=>0),min:K.getOrElse(r.variadicMin,()=>0),...K.isSome(r.variadicMax)?{max:r.variadicMax.value}:{}})):1,i=[];for(let e=0;e<n;e++)i.push((yield*lW(t)));let a="flag"===t.kind?{flags:{[t.name]:i},arguments:[]}:{flags:{},arguments:i};return(yield*e.parse(a),yield*i5(),t.kind===a$)?i:i.flatMap(e=>[`--${t.name}`,e])}),lW=e=>{var t,r;let n=lX(e);switch(e.primitiveType._tag){case"Boolean":return U.TjK(oA(oS({message:n,label:{confirm:"true",deny:"false"},placeholder:{defaultConfirm:"(T/f)",defaultDeny:"(t/F)"}})),String);case"Choice":return oA(oC({message:n,choices:(ak(e.primitiveType)??[]).map(e=>({title:e,value:e}))}));case"Date":let i,a,s,o,l,c;return U.TjK(oA((t={message:n},s=(a=((e,t,r)=>{let n=[],i=null;for(;i=oZ.exec(e);){let e=i.shift(),a=i.findIndex(e=>void 0!==e);if(a in o0){let s=i[a]||e;n.push(o0[a]({token:s,date:t,parts:n,locales:r}))}else n.push(new o2({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},z.Ie());return n.splice(0,n.length,...a),n})((i={initial:new Date,dateMask:"YYYY-MM-DD HH:mm:ss",validate:U.PyW,...t,locales:{...oQ,...t.locales}}).dateMask,i.initial,i.locales)).findIndex(e=>!e.isToken()),o$({dateParts:a,typed:"",cursor:s,value:i.initial,error:K.none()},{render:(o=i,(e,t)=>oD.$match(t,{Beep:()=>U.PyW("\x07"),NextFrame:({state:e})=>oG(e,o),Submit:()=>oH(e,o)})),process:(l=i,(e,t)=>{switch(e.key.name){case"left":let r;return U.PyW((r=t.dateParts[t.cursor].previousPart(),K.isSome(r)?oD.NextFrame({state:{...t,typed:"",cursor:t.dateParts.indexOf(r.value)}}):oD.Beep()));case"right":let n;return U.PyW((n=t.dateParts[t.cursor].nextPart(),K.isSome(n)?oD.NextFrame({state:{...t,typed:"",cursor:t.dateParts.indexOf(n.value)}}):oD.Beep()));case"k":case"up":return U.PyW((t.dateParts[t.cursor].increment(),oD.NextFrame({state:{...t,typed:""}})));case"j":case"down":return U.PyW((t.dateParts[t.cursor].decrement(),oD.NextFrame({state:{...t,typed:""}})));case"tab":let i,a;return U.PyW((i=t.dateParts[t.cursor].nextPart(),a=K.match(i,{onNone:()=>t.dateParts.findIndex(e=>!e.isToken()),onSome:e=>t.dateParts.indexOf(e)}),oD.NextFrame({state:{...t,cursor:a}})));case"enter":case"return":return U.YWq(l.validate(t.value),{onFailure:e=>oD.NextFrame({state:{...t,error:K.some(e)}}),onSuccess:e=>oD.Submit({value:e})});default:return U.PyW(((e,t)=>{if(/\d/.test(e)){let r=t.typed+e;return t.dateParts[t.cursor].setValue(r),oD.NextFrame({state:{...t,typed:r}})}return oD.Beep()})(K.getOrElse(e.input,()=>""),t))}}),clear:(c=i,U.D9k(function*(e,t){let r=yield*nn,n=yield*r.columns,i=yield*ox,a=z.TS(e.dateParts,"",(e,t)=>e+t.toString());return oR(oV("?",i.pointerSmall,a,c,{plain:!0}),n,K.isSome(e.error)?z.YW(e.error.value.split(oF),{onEmpty:()=>"",onNonEmpty:e=>`${i.pointerSmall} ${e.join("\n")}`}):"")+"\x1b[2K\x1b[G"}))}))),e=>e.toISOString());case"Float":let u,d,f,h;return U.TjK(oA((u={default:0,min:-1/0,max:1/0,incrementBy:1,decrementBy:1,precision:2,validate:e=>e<u.min?U.fJG(`${e} must be greater than or equal to ${u.min}`):e>u.max?U.fJG(`${e} must be less than or equal to ${u.max}`):U.PyW(e),...r={message:n}},o$({cursor:(d=void 0===r.default?"":`${u.default}`).length,value:d,error:K.none()},{render:(f=u,(e,t)=>oD.$match(t,{Beep:()=>U.PyW("\x07"),NextFrame:({state:e})=>ls(e,f),Submit:()=>lo(e,f)})),process:(h=u,(e,t)=>{if(e.key.ctrl&&"u"===e.key.name)return lc(t);switch(e.key.name){case"backspace":return ll(t);case"k":case"up":return U.PyW(oD.NextFrame({state:{...t,value:""===t.value||"-"===t.value?`${h.incrementBy}`:`${Number.parseFloat(t.value)+h.incrementBy}`,error:K.none()}}));case"j":case"down":return U.PyW(oD.NextFrame({state:{...t,value:""===t.value||"-"===t.value?`-${h.decrementBy}`:`${Number.parseFloat(t.value)-h.decrementBy}`,error:K.none()}}));case"enter":case"return":{let e=Number.parseFloat(t.value);if(Number.isNaN(e))return U.PyW(oD.NextFrame({state:{...t,error:K.some("Must provide a floating point value")}}));return U.qIB(U.OH5(()=>oy(e,h.precision)),e=>U.YWq(h.validate(e),{onFailure:e=>oD.NextFrame({state:{...t,error:K.some(e)}}),onSuccess:e=>oD.Submit({value:e})}))}default:var r=K.getOrElse(e.input,()=>"");if("."===r&&t.value.includes("."))return U.PyW(oD.Beep());if(0===t.value.length&&"-"===r)return U.PyW(oD.NextFrame({state:{...t,value:"-",error:K.none()}}));let n=Number.parseFloat(t.value+r);return Number.isNaN(n)?U.PyW(oD.Beep()):U.PyW(oD.NextFrame({state:{...t,value:"."===r?`${n}.`:`${n}`,error:K.none()}}))}}),clear:ln(u)}))),String);case"Integer":return U.TjK(oA(oO({message:n})),String);case"Redacted":return U.TjK(oA(lI({message:n},"password").pipe(oI(of))),op);default:return oA(lI({message:n},"text"))}},lX=e=>lJ(e),lJ=e=>{let t=K.getOrUndefined(e.description)?.trim(),r="flag"===e.kind&&void 0!==t&&t.length<=32?t:lz(e.name);return"flag"===e.kind?`${r} (${"flag"===e.kind?`--${e.name}`:e.name})`:r},lz=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(" ")},lK=e=>i5(lZ("Current command",e,"\x1b[35m")),lV=(e,t)=>`${ob(e.toUpperCase(),"\x1b[1m","\x1b[96m")} ${ob("·","\x1b[90m")} ${ob(t,"\x1b[1m","\x1b[37m")}`,lG=(e,t,r)=>[`${ob(e,"\x1b[1m","\x1b[96m")} ${ob(`v${t}`,"\x1b[37m")} ${ob("· Command wizard","\x1b[1m","\x1b[37m")}`,...void 0===r||0===r.length?[]:[r],ob("Build a command interactively. Press Ctrl+C to cancel.","\x1b[90m"),""].join("\n"),lH=e=>lZ("Command ready",e,"\x1b[96m","\x1b[32m"),lQ=()=>`
|
|
17
|
+
${ob("Wizard cancelled.","\x1b[31m")}`,lZ=(e,t,r,n="\x1b[37m")=>{let i=l0(t);return[ob(e,"\x1b[1m",n),...i.map(e=>ob(e,r)),""].join("\n")},l0=e=>{let t=" $ ",r=" ",n=e.map(l1),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},l1=e=>/^[A-Za-z0-9_./:@%+=,-]+$/.test(e)?e:`'${e.replaceAll("'","'\"'\"'")}'`,l2=e=>es.i5(e,s$),l5=(e,t,r)=>sI({name:e,config:sv(t??{}),...es.EA(r)?{handle:r}:{}}),l3=(0,F.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(l2(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);sM(e,r.flat);let n=sE(e),i=new Map(r.flat.map(e=>[e.name,sE(e)])),a=Symbol("effect/cli/SubcommandState"),s=U.D9k(function*(e){if(K.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 Object.assign({},r,{[a]:{name:t.name,result:s}})}),o=U.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(U.PfK(n.service,e)):yield*new an({commandPath:t,errors:[]})}return yield*n.handle(e,t)});return sI({name:n.name,config:n.config,contextConfig:n.contextConfig,description:n.description,shortDescription:n.shortDescription,alias:n.alias,annotations:n.annotations,globalFlags:n.globalFlags,examples:n.examples,service:n.service,subcommands:r.groups,parse:s,parseContext:n.parseContext,handle:o})}),l6=(0,F.XY)(2,(e,t)=>{let r=sE(e),n=sv(t),i=sk(r.config,n),a=sk(r.contextConfig,n);r.subcommands.length>0&&sM(e,r.subcommands.flatMap(e=>e.commands),{contextConfig:a});let s=sT(n),o=U.D9k(function*(e){return Object.assign({},(yield*r.parse(e)),(yield*s(e)))}),l=U.D9k(function*(e){return Object.assign({},(yield*r.parseContext(e)),(yield*s(e)))});return sI({name:r.name,config:i,contextConfig:a,description:r.description,shortDescription:r.shortDescription,alias:r.alias,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)})}),l8=(0,F.XY)(2,(e,t)=>sI({...sE(e),description:t})),l4=(0,F.XY)(2,(e,t)=>sI({...sE(e),shortDescription:t})),l9=(0,F.XY)(2,(e,t)=>sI({...sE(e),examples:t})),l7=(e,t)=>{let r=sE(e);return U.D9k(function*(n){let i,a,s,o,l,c,{builtIns:u}=yield*sV,{tokens:d,trailingOperands:f}=-1===(i=n.indexOf("--"))?{tokens:sH(n),trailingOperands:[]}:{tokens:sH(n.slice(0,i)),trailingOperands:n.slice(i+1)},h=sU([...u,...(a=[],(s=e=>{for(let t of sE(e).globalFlags)a.push(t);for(let t of e.subcommands)for(let e of t.commands)s(e)})(e),sU(a))]),p=s2(h.flatMap(e=>aK(e.flag)).filter(aO)),{flagMap:m,remainder:g,errors:y}=(o=s3(p.params),l=[],c=(e,t,r)=>{let n=s2(sE(t).config.flags.flatMap(aK).filter(aO)),i=s2(sE(t).contextConfig.flags.flatMap(aK).filter(aO)),a=s5(t.subcommands),s=s1(e),u=[],d=!0;for(let e=s.take();e;e=s.take()){if(s6(e)){let t=or(e,r);if(void 0!==t){on(u,s,e,t);continue}let c=s4(e,i);if(void 0!==c){on(u,s,e,c);continue}let f=s4(e,n),h=s4(e,p);if(void 0!==f&&(void 0===h||!d||!oi(e,s.rest(),f,a,[n,i,p]))){on(u,s,e,f);continue}if(void 0!==h){let t=ot(s,e,h.param,h.negated);if("Error"===t._tag){l.push(t.error);continue}void 0!==t.value&&o[h.param.name].push(t.value);continue}u.push(e);continue}if("Value"===e._tag&&d){let t=a.get(e.value);if(void 0!==t)return u.push(e),u.push(...c(s.rest(),t,[...r,i])),u;d=!1}u.push(e)}return u},{flagMap:o,remainder:c(d,e,[]),errors:l}),b={flags:m,arguments:[]},v=yield*s0({tokens:g,trailingOperands:f},e),w=[e.name,...sZ(v)],x={builtIns:u,command:e,commandPath:w,version:t.version},_=sF(e,w,u),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 aK(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 i6({option:i,suggestions:[],command:n})))}return a})(h,_,m,w);if(k.length>0||y.length>0){let e=v.errors??[];return yield*new an({commandPath:w,errors:[...y,...k,...e]})}for(let r of _){if("Action"!==r._tag||!aK(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===sX)return yield*U.JkU(function*(){yield*i5(lG(e.name,t.version,e.description));let r=[e.name,...n.filter(e=>"--wizard"!==e&&!e.startsWith("--wizard="))],i=yield*lF(e,{commandPath:w,prefix:r});yield*i5(lH(i)),(yield*oA(oN({message:"Run this command?",initial:!0,active:"yes",inactive:"no"})))&&(yield*i5(),yield*l7(e,t)(i.slice(1)))}).pipe(U.KuX("QuitError",()=>i5(lQ())));yield*r.run(i,x);return}if(v.errors&&v.errors.length>0)return yield*new an({commandPath:w,errors:v.errors});let S=yield*U.Ket(r.parse(v));if("Failure"===S._tag)return yield*new an({commandPath:w,errors:[S.failure]});let $=r.handle(S.success,[e.name]),E=_.includes(sz)?(yield*sz.flag.parse(b))[1]:K.none();for(let e of($=U.PfK($,sz,E),_)){if("Setting"!==e._tag||e===sz)continue;let[,t]=yield*e.flag.parse(b);$=U.PfK($,e,t)}let O=K.match(E,{onNone:()=>H.Ie(),onSome:e=>H.L8(aH.zQ,e)});yield*U.PpN($,O)},U.osR(e=>es.i5(e,i3)&&"ShowHelp"===e._tag?V.Py(e):V.fJ(e),t=>U.hgn(U.JkU(function*(){let{builtIns:r}=yield*sV,n=yield*aQ,i=yield*sL(e,t.commandPath,r);yield*i5(n.formatHelpDoc(i)),t.errors.length>0&&(yield*i2(n.formatErrors(t.errors)))}),U.fJG(t))),U.osR(e=>es.i5(e,nt)?V.Py(e):V.fJ(e),e=>U.GaK))},ce=/(?:https:\/\/(?:www\.)?excalidraw\.com\/)?#json=[A-Za-z0-9_-]+,[A-Za-z0-9_-]{22,}/gu;function ct(e){return e.replace(ce,"[redacted-share-link]")}let cr=[" ______"," /#####/"," /#####/"," /#####/"," /#####/"," /#####/"," / # /"," /__#/"," /#/"," /"],cn={dark:{red:195,green:154,blue:172,ansi256:181},light:{red:111,green:84,blue:98,ansi256:95}},ci={dark:{red:246,green:241,blue:231,ansi256:255},light:{red:26,green:23,blue:18,ansi256:234}},ca={dark:{red:216,green:204,blue:177,ansi256:187},light:{red:76,green:70,blue:57,ansi256:239}},cs=[[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 co(e,t,r,n="plain"){if("none"===r.colors)return e;let i="truecolor"===r.colors?`38;2;${String(t.red)};${String(t.green)};${String(t.blue)}`:`38;5;${String(t.ansi256)}`;return`\u001b[${"bold"===n?"1;":""}${i}m${e}\u001b[0m`}function cl(e,t){return co(e,cn[t.background],t,"bold")}function cc(e,t){return co(e,ci[t.background],t,"bold")}function cu(e,t){return co(e,ca[t.background],t)}function cd(e){return[[...cr.map(t=>co(t,cn[e.background],e)),"",` ${co("sketchi",ci[e.background],e,"bold")}`,` ${cu("describe it. sketchi draws it.",e)}`].join("\n"),"",cl("START HERE",e),` ${cc("generate",e)} ${cu("Turn one prompt into a validated PNG and editable local diagram.",e)}`,"",cl("EXAMPLE",e),` ${cc('sketchi generate --prompt "Map release approval with pass and revise branches"',e)}`,` ${cu("Writes <generated-id>.png by default. No account or API key needed.",e)}`,"",cl("WORK WITH A DIAGRAM",e),` ${cc("show",e)} ${cu("Inspect a local diagram.",e)}`,` ${cc("edit",e)} ${cu("Replace its canonical document.",e)}`,` ${cc("export",e)} ${cu("Write PNG, Excalidraw, or scene bytes.",e)}`,` ${cc("share",e)} ${cu("Create an encrypted Excalidraw link.",e)}`,"",cl("GO DEEPER",e),` ${cc("sketchi docs",e)} ${cu("Complete command map and automation contracts.",e)}`,` ${cc("sketchi generate --help",e)} ${cu("Every generation option.",e)}`,` ${cc("sketchi <command> --help",e)} ${cu("Targeted help for any command.",e)}`,"",cu("Automation: add --output json. Version: sketchi --version",e)].join("\n")}function cf(e){if(!Number.isInteger(e)||e<0||e>255)return;if(e<16){let[t,r,n]=cs[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 ch(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 cp(e,t){return(Math.max(ch(e),ch(t))+.05)/(Math.min(ch(e),ch(t))+.05)}function cm(e,t,r){let n=e=>"truecolor"===r?e:cf(e.ansi256)??e;return Math.min(cp(e,n(cn[t])),cp(e,n(ci[t])),cp(e,n(ca[t])))}let cg=new Set(["generate","docs","create","show","edit","patch","list","restore","share","pull","export"]);function cy(e){return{_tag:"File",path:e}}function cb(e){return{_tag:"InlineJson",value:e}}function cv(e="canonical document"){let t=aA("flag","file").pipe(sp("PATH|-"),sh(`Read one ${e} from PATH, or stdin with -.`),sg(cy)),r=aA("flag","json").pipe(sp("VALUE"),sh(`Read one ${e} from inline JSON.`),sg(cb));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):U.fJG(new i7({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:sm(r)}}function cw(e,t){return nh.make({message:e,hint:"Provide operations and optional options or intent only.",details:t})}let cx=U.fn("sketchi.cli.patch.decodeInput")(function*(e){if("object"!=typeof e||null===e||Array.isArray(e))return yield*cw("The diagram patch request is invalid.",["patch: Expected an object."]);if("source"in e)return yield*cw("The diagram patch request cannot supply source.",["source: The CLI binds the stored scene."]);if("requestId"in e)return yield*cw("The diagram patch request cannot supply requestId.",["requestId: The CLI owns the patch request id."]);let t=nc.Er.safeParse({...e,requestId:"cli-patch-validation",source:{scene:{diagramId:"validation",title:"Validation",width:1,height:1,accentColor:"#000000",backgroundColor:"#ffffff",elements:[]}}});return t.success?{operations:t.data.operations,...t.data.options?{options:t.data.options}:{},...t.data.intent?{intent:t.data.intent}:{}}:yield*cw("The diagram patch request is invalid.",t.error.issues.map(e=>e.message))}),c_=U.fn("sketchi.cli.patch.parseJson")(function*(e){let t=yield*U.SvU({try:()=>JSON.parse(e),catch:()=>nf.make({code:"invalid_json",message:"The patch input is not valid JSON.",hint:"Pass one complete diagram patch request object."})});return yield*cx(t)});class ck extends H.kl()("@sketchi/cli/DiagramPatcher"){}function cS(e){let t=e.ref?.path?` (${e.ref.path})`:"";return`${e.code}${t}: ${e.message}`}function c$(e,t){let r=e.formats.find(e=>e.format===t);return r?.inline!==void 0?U.PyW(r.inline):U.fJG(np.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 cE(e){let t=nc.Uh.safeParse(e);return t.success?U.PyW(t.data):U.fJG(np.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 cO(e){let t=nc.yE.safeParse(e);return t.success?U.PyW(t.data):U.fJG(np.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 cI=X.QZ(ck,U.JkU(function*(){let e=yield*nc.Ov,t=yield*nc.UA;return{patch:U.fn("sketchi.cli.diagram.patch")(function*(r,n,i){let a=yield*(0,nc.OF)({requestId:i,source:{scene:r},operations:n.operations,options:{...n.options,artifactFormats:["scene","excalidraw"],inlineArtifacts:["scene","excalidraw"]},...n.intent?{intent:n.intent}:{}}).pipe(U.PfK(nc.Ov,e),U.PfK(nc.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(cS),"invalid_input"===a.status||"target_not_found"===a.status||"unsupported_operation"===a.status||"connectivity_changed"===a.status?nh.make({message:t,hint:r,details:n}):"storage_failed"===a.status?ng.make({code:"storage_commit_failed",message:t,hint:r}):np.make({status:a.status,message:t,hint:r,details:n}))}return{scene:yield*c$(a.artifact,"scene").pipe(U.qIB(cE)),excalidraw:yield*c$(a.artifact,"excalidraw").pipe(U.qIB(cO))}})}}));class cA extends H.kl()("@sketchi/cli/InputReader"){}function cC(e,t){return U.SvU({try:()=>new TextDecoder("utf-8",{fatal:!0}).decode(e),catch:()=>nf.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 cT=function(e=()=>!0===process.stdin.isTTY){return X.QZ(cA,U.JkU(function*(){let t=yield*nQ,r=yield*r0;return{read:U.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(U.xm_(()=>nf.make({code:"input_read_failed",message:`Unable to read input file ${n.path}.`,hint:"Check the path and file permissions, then retry."})));return yield*cC(e,"file")}if(e())return yield*nf.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*tb(r.stdin,()=>({chunks:[],size:0}),(e,t)=>{let r=t.byteLength+e.size;return void 0!==i.maxBytes&&r>i.maxBytes?U.fJG(nf.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.`})):U.PyW({chunks:[...e.chunks,t],size:r})}).pipe(U.xm_(e=>e instanceof nf?e:nf.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*cC(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")})}}))}(),cN=U.fn("sketchi.cli.input.readDocument")(function*(e){let t=yield*cA,r=yield*t.read(e);return yield*nE(r)}),cM=U.fn("sketchi.cli.input.readPatch")(function*(e){let t=yield*cA,r=yield*t.read(e,{content:"patch request"});return yield*c_(r)});class cP extends H.kl()("@sketchi/cli/OutputWriter"){}class cj extends r7.X0d()("CliCommandExit",{exitCode:r7.wNn}){}function cD(e){return nd.make({cause:e,operation:"write-output",path:"standard stream",message:"Unable to write command output."})}let cU=X.QZ(cP,U.JkU(function*(){let e=yield*r0;return{stdout:t=>((...e)=>td(e))(t).pipe(ty(e.stdout()),U.xm_(cD)),stderr:t=>((...e)=>td(e))(t).pipe(ty(e.stderr()),U.xm_(cD))}}));function cR(e){let t=e.details?.map(e=>` - ${e}`).join("\n");return[`error: ${e.code}`,e.message,`next: ${e.hint}`,...t?["details:",t]:[]].join("\n")+"\n"}let cF=U.fn("sketchi.cli.output.failure")(function*(e,t,r){let n=yield*cP,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"CliStorageError":case"CliExportError":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"CliGenerationError":case"CliShareError":return{code:e.code,message:e.message,hint:e.hint,details:e.details}}}(r),a="json"===t?nO({ok:!1,command:e,error:i}):cR(i);return yield*n.stderr(ct(a)),yield*cj.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":return 3;case"provider_failure":return 10;case"generation_timeout":return 11;case"malformed_output":return 12}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)})}),cL=U.fn("sketchi.cli.output.success")(function*(e,t,r,n,i="stdout"){let a=yield*cP,s="json"===t?nO({ok:!0,command:e,data:r}):n;yield*a[i](s.endsWith("\n")?s:`${s}
|
|
18
|
+
`)});function cB(e,t,r,n,i=e=>e){return r.pipe(U.tvg({onFailure:r=>cF(e,t,r),onSuccess:r=>cL(e,t,i(r),n(r))}))}function cY(e,t,r){return ny.make({code:e,message:t,hint:r,details:[]})}async function cq(e,t){let r=Number(e.headers.get("content-length"));if(Number.isFinite(r)&&r>t)throw Error("response body exceeds limit");if(!e.body)return new Uint8Array;let n=e.body.getReader(),i=[],a=0;try{for(;;){let e=await n.read();if(e.done)break;if((a+=e.value.byteLength)>t)throw await n.cancel(),Error("response body exceeds limit");i.push(e.value)}}finally{n.releaseLock()}let s=new Uint8Array(a),o=0;for(let e of i)s.set(e,o),o+=e.byteLength;return s}function cW(){return cY("share_timeout","The Excalidraw storage request timed out.","Retry once. The unofficial third-party backend may be unavailable.")}function cX(){return cY("share_transport_failed","The Excalidraw storage request failed.","Retry once. The unofficial third-party backend may be unavailable.")}async function cJ(e,t,r){let n=new AbortController,i=setTimeout(()=>n.abort(),15e3);try{let i=await fetch(e,{...t,redirect:"error",signal:n.signal});return await r(i)}finally{clearTimeout(i)}}class cz extends H.kl()("@sketchi/cli/ShareTransport"){}let cK=X.Py(cz,{upload:e=>U.$mh({try:async()=>await cJ("https://json.excalidraw.com/api/v2/post/",{method:"POST",body:Uint8Array.from(e)},async e=>{let t=await cq(e,65536);if(!e.ok)throw Error("upload HTTP failure");let r=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(t));if("object"!=typeof r||null===r||!("id"in r)||"string"!=typeof r.id||!/^[A-Za-z0-9_-]{1,128}$/.test(r.id)||!("data"in r)||r.data!==`${n3}${r.id}`)throw cY("share_api_changed","The Excalidraw storage API returned an unexpected response.","The unofficial API may have changed; update Sketchi compatibility before retrying.");return r.id}),catch:e=>e instanceof ny?e:e instanceof DOMException&&"AbortError"===e.name?cW():cX()}),download:e=>U.$mh({try:async()=>await cJ(`${n3}${e}`,{method:"GET"},async e=>{if(404===e.status)throw cY("share_link_unavailable","The Excalidraw share link is unavailable.","Verify the complete bearer link or ask its sender to export a new link.");if(!e.ok)throw Error("download HTTP failure");return await cq(e,2097152)}),catch:e=>e instanceof ny?e:e instanceof DOMException&&"AbortError"===e.name?cW():cX()})});class cV extends H.kl()("@sketchi/cli/LinkOpener"){}let cG=function(e=(e,t,r)=>{let n=(0,tV.spawn)(e,[...t],r);return{onError:e=>{n.once("error",e)},onExit:e=>{n.once("exit",e)},kill:()=>n.kill()}},t=process.platform,r=3e3){return X.Py(cV,{open:n=>U.ivC(()=>new Promise(i=>{let a=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),s=e(a.command,a.args,{shell:!1,stdio:"ignore"}),o=!1,l=e=>{o||(o=!0,clearTimeout(c),i(e))};s.onError(()=>l({status:"unconfirmed",reason:"missing_executable"})),s.onExit(e=>l(0===e?{status:"accepted"}:{status:"unconfirmed",reason:"nonzero_exit"}));let c=setTimeout(()=>{s.kill(),l({status:"unconfirmed",reason:"timeout"})},r)}))})}();class cH extends H.kl()("@sketchi/cli/ExcalidrawShare"){}let cQ=X.QZ(cH,U.JkU(function*(){let e=yield*cz;return{share:U.fn("sketchi.cli.share.upload")(function*(t){var r;let n=yield*ih(t).pipe(U.qIB(()=>U.SvU({try:()=>{var e;let r=ic(t);return n4.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:()=>ie("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*U.$mh({try:async()=>{if(n.byteLength>0xfffff0)throw ie("share_payload_too_large","The Excalidraw share contents exceed 16 MiB.","Reduce the drawing size and retry.");let e=2097136-n7.byteLength-12-16,t=await function(e,t){let r=n4.encode("null"),n=[ip(1),ip(r.byteLength),r,ip(e.byteLength),e],i=new n2.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 ie("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 il(i,"encrypt"),Uint8Array.from(t)));var s=[n7,r,a];let o=new Uint8Array(4+s.reduce((e,t)=>e+4+t.byteLength,0));ii(o,0,1);let l=4;for(let e of s)ii(o,l,e.byteLength),l+=4,o.set(e,l),l+=e.byteLength;return o},catch:e=>e instanceof ny?e:ie("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:U.fn("sketchi.cli.share.pull")(function*(t){var r;let n=yield*n4.encode(t).byteLength>4096?U.fJG(ie("invalid_share_link","The Excalidraw share link is invalid.","Provide one complete https://excalidraw.com/#json=ID,KEY link.",["link exceeds 4 KiB"])):U.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 io(e[3]),{id:e[2],key:e[3]}},catch:()=>ie("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?U.fJG(ie("share_payload_too_large","The Excalidraw share payload exceeds 2 MiB.","Use a smaller supported Excalidraw link.")):U.$mh({try:async()=>{let[e,t,n]=is(i,3);if(!e||!t||!n||12!==t.byteLength)throw Error("invalid encrypted payload chunks");let a=JSON.parse(n9.decode(e));if(!it(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 il(r,"decrypt"),Uint8Array.from(n))),o=(0,nV.inflateSync)(s,{maxOutputLength:0x1000001});if(o.byteLength>0x1000000)throw Error("decompressed payload exceeds 16 MiB");let l=is(o,2);if(!l[0]||!l[1])throw Error("invalid inner chunk count");if("null"!==n9.decode(l[0]))throw Error("unsupported contents metadata");return!function(e){let t=n9.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(n9.decode(l[1]))},catch:e=>e instanceof RangeError||e instanceof Error&&(e.message.includes("maxOutputLength")||e.message.includes("larger than"))?ie("share_payload_too_large","The decompressed Excalidraw share payload exceeds 16 MiB.","Use a smaller supported Excalidraw link."):ie("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 cZ(e){return ny.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 c0=U.fn("sketchi.cli.preflightPullTarget")(function*(e){let t=yield*nA(e),r=yield*iw,n=yield*r.show(t);return{id:t,observed:n}}),c1=U.fn("sketchi.cli.pullIntoStore")(function*(e,t,r){let n=r??(yield*c0(e)),i=n.id,a=yield*iw,s=yield*cH,o=yield*nz,l=yield*s.pull(t);yield*ih(l);let c=yield*o.normalizeExcalidraw(l).pipe(U.xm_(cZ));return yield*ih(c),yield*o.renderPng({excalidraw:c}).pipe(U.xm_(cZ)),{diagram:yield*a.replaceWithDetached(i,new TextEncoder().encode(nO(c)),n.observed.manifest.revision),sourceIdentity:"unverified"}}),c2=`Sketchi CLI contracts for agents and automation.
|
|
19
|
+
|
|
20
|
+
Command map:
|
|
21
|
+
Start with generate for prompt-to-PNG. Use show, edit, patch, list, restore, and export for
|
|
22
|
+
local records. Use create for accepted canonical JSON. Share and pull are explicit network
|
|
23
|
+
boundaries for Excalidraw links. Run sketchi COMMAND --help for every flag and example.
|
|
19
24
|
|
|
20
25
|
Manual JSON workflow (strictly offline):
|
|
21
26
|
create a canonical document, apply semantic patches, inspect or replace it, list local records,
|
|
@@ -45,8 +50,9 @@ Explicit network commands (one credential-free HTTPS request each):
|
|
|
45
50
|
Input and output contracts:
|
|
46
51
|
create/edit/patch require exactly one of --file PATH|- or --json VALUE. --file - reads one
|
|
47
52
|
noninteractive UTF-8 JSON document from stdin and exits with usage code 2 on a TTY.
|
|
48
|
-
--json is inline input only. --prompt is noninteractive text.
|
|
49
|
-
|
|
53
|
+
--json is inline input only. --prompt is noninteractive text. generate exports PNG to
|
|
54
|
+
<generated-id>.png by default; --format scene|excalidraw selects another artifact and --dest
|
|
55
|
+
PATH|- overrides its destination. Use --output text|json for result presentation on every command.
|
|
50
56
|
export writes bytes with --dest PATH|- and always writes status to stderr. With --dest -,
|
|
51
57
|
stdout contains only artifact bytes. A successful PNG file export adds a generic inline-Markdown
|
|
52
58
|
display hint for calling agents.
|
|
@@ -54,8 +60,8 @@ Input and output contracts:
|
|
|
54
60
|
Share/pull safety limits:
|
|
55
61
|
links 4 KiB; encrypted bodies 2 MiB; inflated contents 16 MiB; 10,000 elements;
|
|
56
62
|
JSON depth 64; element dimensions ${String(8192)}; canvas dimensions
|
|
57
|
-
${String(8192)}; canvas area ${String(
|
|
58
|
-
${String(
|
|
63
|
+
${String(8192)}; canvas area ${String(n5.Z4)} square units; final PNG
|
|
64
|
+
${String(n5.ce)} pixels. Limits are checked before encryption or raster allocation.
|
|
59
65
|
|
|
60
66
|
Offline boundary and storage:
|
|
61
67
|
create, patch, show, edit, list, export, and restore use no model, remote agent, MCP server, login,
|
|
@@ -67,8 +73,10 @@ Offline boundary and storage:
|
|
|
67
73
|
A pulled record is detached: diagram.excalidraw is authoritative while document.json and
|
|
68
74
|
scene.json remain non-authoritative provenance. A patched record makes scene.json authoritative
|
|
69
75
|
while retaining document.json as provenance. show/list expose these states; edit refuses both.
|
|
70
|
-
Formats are scene, excalidraw, and png.
|
|
71
|
-
|
|
76
|
+
Formats are scene, excalidraw, and png. generate persists the canonical record before exporting
|
|
77
|
+
the requested artifact; a later destination failure leaves that record recoverable. If no PNG is
|
|
78
|
+
stored, export deterministically renders one on demand from the local scene and Excalidraw artifacts,
|
|
79
|
+
without a browser, network, or record write.
|
|
72
80
|
|
|
73
81
|
Exit codes and errors:
|
|
74
82
|
0 success; 1 internal failure; 2 usage or interactive stdin; 3 invalid input/document;
|
|
@@ -82,15 +90,15 @@ Exit codes and errors:
|
|
|
82
90
|
Revision recovery and next steps:
|
|
83
91
|
edit, pull, and restore archive the complete prior authority state before atomic replacement.
|
|
84
92
|
Use restore --revision N to recover through the CLI without consuming the selected snapshot.
|
|
85
|
-
Start with
|
|
86
|
-
edit with a complete replacement document, then export
|
|
93
|
+
Start with generate for a prompt or create for accepted JSON. Use the returned id with show/list,
|
|
94
|
+
edit with a complete replacement document, then export another stored artifact when needed.`,c5=sd("output",["text","json"]).pipe(aR("text"),sh("Result presentation format."),sp("text|json")),c3=l5("sketchi").pipe(l6({output:c5}),l8("Turn one prompt into a validated PNG and editable local diagram."),l4("Turn a prompt into a validated PNG and editable local diagram.")),c6=l5("docs",{},()=>U.JkU(function*(){let{output:e}=yield*c3;yield*cL("docs",e,{documentation:c2},c2)})).pipe(l8("Print the complete CLI contracts for agents, automation, storage, formats, safety limits, and errors."),l4("Print complete agent and automation documentation."));function c8(e){return`~/.sketchi/diagrams/${e}`}function c4(e){return e.revisions.map(t=>`${c8(e.manifest.id)}/revisions/${t}`)}function c9(e){return{...nW(e),storagePath:c8(e.manifest.id),revisions:c4(e),document:e.document}}function c7(){return ny.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 ue=U.fn("sketchi.cli.pull.readLink")(function*(e){if("-"!==e)return e;let t=yield*cA;return(yield*t.read({_tag:"File",path:"-"},{content:"share link",maxBytes:4096})).trim()});function ut(e,t){return`${e}: ${t.manifest.id}
|
|
87
95
|
type: ${t.manifest.type}
|
|
88
96
|
title: ${t.manifest.title}
|
|
89
97
|
revision: ${String(t.manifest.revision)}
|
|
90
98
|
authority: ${t.authority}
|
|
91
99
|
document authoritative: ${String(t.documentAuthoritative)}
|
|
92
100
|
formats: ${t.manifest.formats.join(",")}
|
|
93
|
-
storage: ${
|
|
101
|
+
storage: ${c8(t.manifest.id)}`}function ur(e){let t=c4(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:",nO(e.document).trimEnd()].join("\n")}function un(e){return 0===e.length?"no diagrams":["id type revision authority document-authoritative formats title",...e.map(e=>[e.id,e.type,String(e.revision),e.authority,String(e.documentAuthoritative),e.formats.join(","),e.title].join(" "))].join("\n")}let ui=`Create one persisted diagram from --prompt TEXT and export its PNG by default. This is one of Sketchi's three explicit network commands (generate, share, pull). It makes one unauthenticated HTTPS POST to the public Sketchi generate API and needs no token, key, account, or login.
|
|
94
102
|
|
|
95
103
|
Network and options:
|
|
96
104
|
Endpoint: ${iz}
|
|
@@ -98,36 +106,41 @@ Network and options:
|
|
|
98
106
|
and Excalidraw artifact are returned over plain HTTPS. Sketchi sends no credentials.
|
|
99
107
|
--type defaults to flowchart; --model defaults to ${iJ}.
|
|
100
108
|
Override the endpoint for preview or local testing with ${iK}
|
|
101
|
-
or --endpoint URL. --
|
|
109
|
+
or --endpoint URL. --format defaults to png. Without --dest, the artifact is written as
|
|
110
|
+
<generated-id>.png, <generated-id>.excalidraw, or <generated-id>.scene.json in the current
|
|
111
|
+
directory. --dest PATH|- overrides that path. --output text|json controls only the status envelope.
|
|
102
112
|
|
|
103
113
|
Validation and storage:
|
|
104
114
|
The returned diagram is decoded against Sketchi's canonical package schemas and atomically
|
|
105
115
|
committed through the create store at ~/.sketchi/diagrams/<id>/. The record contains
|
|
106
|
-
manifest.json, document.json, scene.json, and diagram.excalidraw.
|
|
107
|
-
|
|
116
|
+
manifest.json, document.json, scene.json, and diagram.excalidraw. PNG rendering remains lazy
|
|
117
|
+
and is not written back to that record. Network/endpoint/timeout/output/validation/storage
|
|
118
|
+
failures leave no visible record; a later export destination failure leaves the created record.
|
|
108
119
|
|
|
109
120
|
Errors and next steps:
|
|
110
121
|
Exit 10 means a network or endpoint failure, 11 a timeout, and 12 malformed output;
|
|
111
122
|
a rejected or invalid generated document uses 3, conflict uses 6, and storage uses 7.
|
|
112
|
-
|
|
113
|
-
|
|
123
|
+
With --dest -, stdout contains artifact bytes only and all status uses stderr. On success, pass
|
|
124
|
+
the returned id to show, edit, list, or export. For strictly offline manual authoring, accepted
|
|
125
|
+
canonical JSON examples, and full error contracts, run sketchi docs.`,ua=l5("generate",{prompt:aA("flag","prompt").pipe(sh("Diagram request text sent to the public Sketchi generate API."),sp("TEXT")),type:sd("type",["flowchart","mindmap"]).pipe(aR("flowchart"),sh("Requested canonical diagram type; default flowchart."),sp("flowchart|mindmap")),model:aA("flag","model").pipe(aR(iJ),sh(`Server-routed generation model id; default ${iJ}.`),sp("MODEL")),endpoint:aA("flag","endpoint").pipe(aR(process.env[iK]?.trim()||iz),sh("Unauthenticated generate API URL; defaults to the production Sketchi endpoint."),sp("URL")),format:sd("format",["png","excalidraw","scene"]).pipe(aR("png"),sh("Artifact exported after generation; default png."),sp("png|excalidraw|scene")),destination:sm(aA("flag","dest").pipe(sh("Artifact destination; defaults from the generated id, or - for stdout."),sp("PATH|-")))},e=>U.JkU(function*(){let{output:t}=yield*c3,r=yield*iY,n=U.JkU(function*(){let t=yield*iZ(e),n=K.getOrElse(e.destination,()=>(function(e,t){switch(t){case"png":return`${e}.png`;case"excalidraw":return`${e}.excalidraw`;case"scene":return`${e}.scene.json`}})(t.diagram.manifest.id,e.format)),i=yield*r.exportArtifact(t.diagram.manifest.id,e.format);return"-"!==n&&(yield*iB(n,i)),{generated:t,artifact:{id:t.diagram.manifest.id,format:e.format,destination:n,sizeBytes:i.byteLength,..."-"===n?{stdoutBytes:i}:{}}}});yield*n.pipe(U.tvg({onFailure:e=>cF("generate",t,e),onSuccess:e=>U.JkU(function*(){var r,n;let i,a=yield*cP;e.artifact.stdoutBytes&&(yield*a.stdout(e.artifact.stdoutBytes)),yield*cL("generate",t,{...{...c9((r=e.generated).diagram),generation:{model:r.model,provider:r.provider}},export:up(e.artifact)},(i=um(e.artifact),[[ut("created",(n=e.generated).diagram).replace(/^created:/u,"generated:"),`provider: ${n.provider}`,`model: ${n.model}`].join("\n"),`format: ${e.artifact.format}`,`destination: ${e.artifact.destination}`,`bytes: ${String(e.artifact.sizeBytes)}`,...i?[`hint: ${i}`]:[]].join("\n")),"-"===e.artifact.destination?"stderr":"stdout")})}))})).pipe(l8(ui),l4("Generate, persist, and export a PNG from one prompt."),l9([{command:'sketchi generate --prompt "Map release approval with pass and revise branches"',description:`Generate a flowchart with ${iJ} 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."}])),us=l5("create",cv(),({source:e})=>U.JkU(function*(){let{output:t}=yield*c3,r=yield*nC,n=yield*iw,i=U.JkU(function*(){let t=yield*cN(e),i=yield*r.build(t);return yield*n.create(i)});yield*cB("create",t,i,e=>ut("created",e),c9)})).pipe(l8("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."),l4("Create a local diagram from canonical JSON."),l9([{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."}])),uo=l5("show",{diagramId:aA(a$,"diagram-id")},({diagramId:e})=>U.JkU(function*(){let{output:t}=yield*c3,r=yield*iw,n=nA(e).pipe(U.qIB(e=>r.show(e)));yield*cB("show",t,n,ur,c9)})).pipe(l8("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."),l4("Inspect one local diagram."),l9([{command:"sketchi show release-flow --output json",description:"Read a record as a stable JSON envelope."}])),ul=l5("edit",{diagramId:aA(a$,"diagram-id"),...cv()},({diagramId:e,source:t})=>U.JkU(function*(){let{output:r}=yield*c3,n=yield*nC,i=yield*iw,a=U.JkU(function*(){let r=yield*nA(e),a=yield*cN(t),s=yield*n.build(a);return s.id!==r?yield*nh.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*cB("edit",r,a,e=>ut("edited",e),c9)})).pipe(l8("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."),l4("Replace a canonical diagram document."),l9([{command:"sketchi edit release-flow --file revised.json",description:"Replace a document and retain the prior revision."}])),uc=l5("patch",{diagramId:aA(a$,"diagram-id"),...cv("patch request")},({diagramId:e,source:t})=>U.JkU(function*(){let{output:r}=yield*c3,n=yield*ck,i=yield*iw,a=U.JkU(function*(){let r=yield*nA(e),a=yield*cM(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*cB("patch",r,a,e=>ut("patched",e),c9)})).pipe(l8("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."),l4("Apply semantic edits to a stored diagram."),l9([{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."}])),uu=l5("list",{},()=>U.JkU(function*(){let{output:e}=yield*c3,t=yield*iw;yield*cB("list",e,t.list(),un)})).pipe(l8("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."),l4("List local diagrams."),l9([{command:"sketchi list --output json",description:"List records as a stable JSON envelope."}])),ud=l5("share",{diagramId:aA(a$,"diagram-id"),open:su("open").pipe(sh("Hand the bearer link to the default OS browser opener."))},({diagramId:e,open:t})=>U.JkU(function*(){let{output:r}=yield*c3,n=yield*iw,i=yield*cH,a=yield*cV,s=U.JkU(function*(){let r=yield*nA(e),s=yield*n.readExportSource(r,"excalidraw");if("StoredArtifact"!==s._tag)return yield*ny.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*U.SvU({try:()=>JSON.parse(new TextDecoder().decode(s.bytes)),catch:c7}),l=yield*i.share(o),c=t?yield*a.open(l.link):{status:"not_requested"};return{id:r,link:l.link,open:c,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(U.tvg({onFailure:e=>cF("share",r,e),onSuccess:e=>U.JkU(function*(){if(yield*cL("share",r,e,`shared: ${e.id}
|
|
114
126
|
link: ${e.link}
|
|
115
127
|
open: ${e.open.status}
|
|
116
|
-
hint: ${e.hint}`),"text"===r&&"unconfirmed"===e.open.status){let e=yield*
|
|
128
|
+
hint: ${e.hint}`),"text"===r&&"unconfirmed"===e.open.status){let e=yield*cP;yield*e.stderr("notice: the OS browser opener could not be confirmed; the share link is still valid.\n")}})}))})).pipe(l8(`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(n5.Z4)}, final PNG pixels ${String(n5.ce)}. --open is opt-in and only confirms whether the OS accepted the request.`),l4("Share an encrypted Excalidraw snapshot.")),uf=l5("pull",{diagramId:aA(a$,"diagram-id"),link:(N="URL|-",M="Excalidraw bearer share URL, or - for noninteractive stdin.",Object.assign(Object.create(Object.getPrototypeOf(C=aA("flag",T="link").pipe(sp(N),sh(M)))),C,{parse:e=>(e.flags[T]?.length??0)===1?C.parse(e):U.fJG(new i7({option:T,value:(e.flags[T]?.length??0)===0?"not provided":"provided more than once",expected:`exactly one --${T} ${N}`,kind:"flag"}))}))},({diagramId:e,link:t})=>U.JkU(function*(){let{output:r}=yield*c3,n=U.JkU(function*(){let r=yield*c0(e),n=yield*ue(t);return yield*c1(e,n,r)});yield*cB("pull",r,n,({diagram:e})=>`pulled: ${e.manifest.id}
|
|
117
129
|
revision: ${String(e.manifest.revision)}
|
|
118
130
|
authority: ${e.authority}
|
|
119
|
-
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:
|
|
131
|
+
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:c4(e),sourceIdentity:t}))})).pipe(l8(`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(n5.Z4)}, final PNG pixels ${String(n5.ce)}.`),l4("Pull browser edits from an Excalidraw link.")),uh=l5("restore",{diagramId:aA(a$,"diagram-id"),revision:aI({name:"revision",primitiveType:aw,kind:"flag"}).pipe(sy(e=>e>0,e=>`Expected a positive revision, got ${String(e)}`),sp("N"),sh("Archived revision number to restore without consuming it."))},({diagramId:e,revision:t})=>U.JkU(function*(){let{output:r}=yield*c3,n=yield*iw,i=yield*nC,a=U.JkU(function*(){let r=yield*nA(e),a=yield*n.readRevision(r,t);return"LegacyDocument"===a._tag?yield*i.build(a.document).pipe(U.qIB(e=>n.restore(r,t,e))):yield*n.restore(r,t)});yield*cB("restore",r,a,e=>`restored: ${e.diagram.manifest.id}
|
|
120
132
|
from revision: ${String(e.restoredFromRevision)}
|
|
121
133
|
revision: ${String(e.diagram.manifest.revision)}
|
|
122
|
-
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:
|
|
134
|
+
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:c4(e.diagram)}))})).pipe(l8("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."),l4("Restore a retained diagram revision."));function up(e){let t=um(e);return{id:e.id,format:e.format,destination:e.destination,sizeBytes:e.sizeBytes,...t?{hint:t}:{}}}function um(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. `:void 0}let ug=l5("export",{diagramId:aA(a$,"diagram-id"),format:sd("format",["scene","excalidraw","png"]).pipe(sh("Artifact format to export or render on demand."),sp("scene|excalidraw|png")),destination:aA("flag","dest").pipe(sh("Artifact byte destination path, or - for stdout."),sp("PATH|-"))},({destination:e,diagramId:t,format:r})=>U.JkU(function*(){let{output:n}=yield*c3,i=yield*iY,a=U.JkU(function*(){let n=yield*nA(t),a=yield*i.exportArtifact(n,r);return"-"!==e&&(yield*iB(e,a)),{id:n,format:r,destination:e,sizeBytes:a.byteLength,..."-"===e?{stdoutBytes:a}:{}}});yield*a.pipe(U.tvg({onFailure:e=>cF("export",n,e),onSuccess:e=>U.JkU(function*(){let t=yield*cP;e.stdoutBytes&&(yield*t.stdout(e.stdoutBytes));let r=up(e),i=um(e),a=[`exported: ${e.id}`,`format: ${e.format}`,`destination: ${e.destination}`,`bytes: ${String(e.sizeBytes)}`,...i?[`hint: ${i}`]:[]].join("\n");yield*cL("export",n,r,a,"stderr")})}))})).pipe(l8("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."),l4("Export scene, Excalidraw, or PNG bytes."),l9([{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."}])),uy=c3.pipe(l3([ua,c6,us,uo,ul,uc,uu,uh,ud,uf,ug])),ub=U.fn("sketchi.cli.run")(function*(e){let t,r,n,i,a,s,o,l,c,u,d=(t=e.lastIndexOf("--output"))>=0&&"json"===e[t+1]||e.some(e=>"--output=json"===e)?"json":"text";return yield*(r=aZ({colors:!1}),n=e.some(e=>"--help"===e||"-h"===e||"--version"===e||"-v"===e),i=e.some(e=>"--output=json"===e)||e.some((t,r)=>"--output"===t&&"json"===e[r+1]),a=e.find(e=>cg.has(e)),s=e.every((t,r)=>"--output"===t||"--output=text"===t||"--output=json"===t||"--output"===e[r-1]&&("text"===t||"json"===t)),o=void 0===a&&(0===e.length||n||s),l=a??"sketchi",c={...r,formatHelpDoc:e=>{let t=r.formatHelpDoc(e).replace(/[ \t]+$/gmu,"");return i&&o?`${JSON.stringify({ok:!0,command:"sketchi",data:{help:cd({colors:"none",background:"dark"})}},null,2)}
|
|
135
|
+
`:i&&!n?"":o?function(){let e,t;if(void 0!==process.env.NO_COLOR||"dumb"===process.env.TERM||"ansi"===process.env.TERM||!0!==process.stdout.isTTY)return cd({colors:"none",background:"dark"});let r=process.stdout.hasColors(0x1000000)?"truecolor":process.stdout.hasColors(256)?"ansi256":"none";if("none"===r)return cd({colors:"none",background:"dark"});let n=(e=process.env.COLORFGBG,(t=e?.split(";").at(-1))&&/^\d+$/u.test(t)?function(e,t){let r=cf(e);if(void 0===r)return{background:"dark",readable:!1};let n=cm(r,"dark",t),i=cm(r,"light",t);return{background:n>=i?"dark":"light",readable:Math.max(n,i)>=4.5}}(Number(t),r):{background:"dark",readable:!1});return n.readable?cd({colors:r,background:n.background}):cd({colors:"none",background:n.background})}():t},formatErrors:e=>{let t=e.map(e=>r.formatCliError(e)).join("; "),n=`Run sketchi${a?` ${a}`:""} --help for usage.`;return ct(i?`${JSON.stringify({ok:!1,command:l,error:{code:"usage_error",message:t,hint:n}},null,2)}
|
|
123
136
|
`:`error: usage_error
|
|
124
137
|
${t}
|
|
125
138
|
next: ${n}
|
|
126
|
-
`)}},
|
|
139
|
+
`)}},u=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}}),l7(uy,{version:"0.4.1"})(e).pipe(U.sFT(e=>es.i5(e,i3)&&"ShowHelp"!==e._tag?i2(c.formatErrors([e])):U.rIH),U.PfK(sV,{builtIns:[sq,sW,sJ]}),U.PfK(aQ,c),U.PfK(i0,u))).pipe(U.khu({onFailure:e=>U.JkU(function*(){let t,r=K.getOrUndefined(D.L$(e));if(r instanceof cj)return r.exitCode;if(r instanceof nd)return 7;let n=function(e){if(es.i5(e,i3))return"ShowHelp"===e._tag?2*(e.errors.length>0):2}(r);if(void 0!==n)return n;let i=yield*cP;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"===d?nO({ok:!1,command:"sketchi",error:t}):cR(t))).pipe(U.MfU(()=>U.rIH)),1}),onSuccess:()=>U.PyW(0)}))}),uv=X.Um(nc.Tx,(0,nc.rR)({createId:e=>`${e}_offline_cli`})),uw=X.Gt(nj,uv),ux=X.Gt(cI,uv),u_=X.Um(n1,iC),uk=X.Gt(iL,u_),uS=X.Gt(iX,X.Um(uk,nK)),u$=X.Gt(cQ,cK),uE=X.Um(n1,iC,uw,ux,uk,uS,nK,u$,cG,cT.pipe(X.Gt(n1)),cU),uO=X.S5(uE,nl);W(ub(process.argv.slice(2)).pipe(U.Mim(e=>U.OH5(()=>{process.exitCode=e})),U.Gte(uO)),{disableErrorReporting:!0})},5030(e,t,r){function n(e,t=0){let r=1/0,i=1/0,a=-1/0,s=-1/0;for(let t of e){var o;if(!("object"==typeof(o=t)&&null!==o&&!Array.isArray(o)&&"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"element geometry is invalid";let e=Math.abs(t.width),n=Math.abs(t.height);if(e>8192||n>8192)return`element dimension exceeds ${String(8192)}`;let l=Math.hypot(e,n)/2,c=t.x+t.width/2,u=t.y+t.height/2;r=Math.min(r,c-l),i=Math.min(i,u-l),a=Math.max(a,c+l),s=Math.max(s,u+l)}if(0===e.length)return;let l=a-r,c=s-i;return l>8192||c>8192?`canvas dimension exceeds ${String(8192)}`:l*c>4194304?`canvas area exceeds ${String(4194304)}`:(l+40)*2*((c+40+t)*2)>0x1000000?`PNG output exceeds ${String(0x1000000)} pixels`:void 0}function i(e,t){return!Number.isFinite(e)||!Number.isFinite(t)||e<=0||t<=0?"rendered SVG dimensions are invalid":e>16384||t>16384?"rendered SVG dimension exceeds the PNG limit":e*t>0x1000000?`PNG output exceeds ${String(0x1000000)} pixels`:void 0}r.d(t,{Gd:()=>n,n$:()=>i},{Z4:4194304,ce:0x1000000})},181(e){e.exports=t("buffer")},6982(e){e.exports=t("crypto")},932(e){e.exports=t("process")},7876(e,t,r){var n=r(6730),i=r(8376),a=r(73),s=r(7028),o=r(3244),l=r(6225),c=r(9661);function u(e,t,r,n,i,a){let s="block-map"===r.type?o.resolveBlockMap(e,t,r,n,a):"block-seq"===r.type?l.resolveBlockSeq(e,t,r,n,a):c.resolveFlowCollection(e,t,r,n,a),u=s.constructor;return"!"===i||i===u.tagName?s.tag=u.tagName:i&&(s.tag=i),s}t.composeCollection=function(e,t,r,o,l){let c=o.tag,d=c?t.directives.tagName(c.source,e=>l(c,"TAG_RESOLVE_FAILED",e)):null;if("block-seq"===r.type){let{anchor:e,newlineAfterProp:t}=o,r=e&&c?e.offset>c.offset?e:c:e??c;r&&(!t||t.offset<r.offset)&&l(r,"MISSING_CHAR","Missing newline after block sequence props")}let f="block-map"===r.type?"map":"block-seq"===r.type?"seq":"{"===r.start.source?"map":"seq";if(!c||!d||"!"===d||d===a.YAMLMap.tagName&&"map"===f||d===s.YAMLSeq.tagName&&"seq"===f)return u(e,t,r,l,d);let h=t.schema.tags.find(e=>e.tag===d&&e.collection===f);if(!h){let n=t.schema.knownTags[d];if(n?.collection!==f)return n?l(c,"BAD_COLLECTION_TYPE",`${n.tag} used for ${f} collection, but expects ${n.collection??"scalar"}`,!0):l(c,"TAG_RESOLVE_FAILED",`Unresolved tag: ${d}`,!0),u(e,t,r,l,d);t.schema.tags.push(Object.assign({},n,{default:!1})),h=n}let p=u(e,t,r,l,d,h),m=h.resolve?.(p,e=>l(c,"TAG_RESOLVE_FAILED",e),t.options)??p,g=n.isNode(m)?m:new i.Scalar(m);return g.range=p.range,g.tag=d,h?.format&&(g.format=h.format),g}},6040(e,t,r){var n=r(9960),i=r(9724),a=r(4915),s=r(7800);t.composeDoc=function(e,t,{offset:r,start:o,value:l,end:c},u){let d=Object.assign({_directives:t},e),f=new n.Document(void 0,d),h={atKey:!1,atRoot:!0,directives:f.directives,options:f.options,schema:f.schema},p=s.resolveProps(o,{indicator:"doc-start",next:l??c?.[0],offset:r,onError:u,parentIndent:0,startOnNewline:!0});p.found&&(f.directives.docStart=!0,l&&("block-map"===l.type||"block-seq"===l.type)&&!p.hasNewline&&u(p.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),f.contents=l?i.composeNode(h,l,p,u):i.composeEmptyNode(h,p.end,o,null,p,u);let m=f.contents.range[2],g=a.resolveEnd(c,m,!1,u);return g.comment&&(f.comment=g.comment),f.range=[r,m,g.offset],f}},9724(e,t,r){var n=r(2298),i=r(6730),a=r(7876),s=r(5120),o=r(4915),l=r(4898);let c={composeNode:u,composeEmptyNode:d};function u(e,t,r,l){let u,f=e.atKey,{spaceBefore:h,comment:p,anchor:m,tag:g}=r,y=!0;switch(t.type){case"alias":u=function({options:e},{offset:t,source:r,end:i},a){let s=new n.Alias(r.substring(1));""===s.source&&a(t,"BAD_ALIAS","Alias cannot be an empty string"),s.source.endsWith(":")&&a(t+r.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let l=t+r.length,c=o.resolveEnd(i,l,e.strict,a);return s.range=[t,l,c.offset],c.comment&&(s.comment=c.comment),s}(e,t,l),(m||g)&&l(t,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":u=s.composeScalar(e,t,g,l),m&&(u.anchor=m.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{u=a.composeCollection(c,e,t,r,l),m&&(u.anchor=m.source.substring(1))}catch(e){l(t,"RESOURCE_EXHAUSTION",e instanceof Error?e.message:String(e))}break;default:{let e="error"===t.type?t.message:`Unsupported token (type: ${t.type})`;l(t,"UNEXPECTED_TOKEN",e),y=!1}}return u??(u=d(e,t.offset,void 0,null,r,l)),m&&""===u.anchor&&l(m,"BAD_ALIAS","Anchor cannot be an empty string"),f&&e.options.stringKeys&&(!i.isScalar(u)||"string"!=typeof u.value||u.tag&&"tag:yaml.org,2002:str"!==u.tag)&&l(g??t,"NON_STRING_KEY","With stringKeys, all keys must be strings"),h&&(u.spaceBefore=!0),p&&("scalar"===t.type&&""===t.source?u.comment=p:u.commentBefore=p),e.options.keepSourceTokens&&y&&(u.srcToken=t),u}function d(e,t,r,n,{spaceBefore:i,comment:a,anchor:o,tag:c,end:u},f){let h={type:"scalar",offset:l.emptyScalarPosition(t,r,n),indent:-1,source:""},p=s.composeScalar(e,h,c,f);return o&&(p.anchor=o.source.substring(1),""===p.anchor&&f(o,"BAD_ALIAS","Anchor cannot be an empty string")),i&&(p.spaceBefore=!0),a&&(p.comment=a,p.range[2]=u),p}t.composeEmptyNode=d,t.composeNode=u},5120(e,t,r){var n=r(6730),i=r(8376),a=r(2992),s=r(3165);t.composeScalar=function(e,t,r,o){let l,c,{value:u,type:d,comment:f,range:h}="block-scalar"===t.type?a.resolveBlockScalar(e,t,o):s.resolveFlowScalar(t,e.options.strict,o),p=r?e.directives.tagName(r.source,e=>o(r,"TAG_RESOLVE_FAILED",e)):null;l=e.options.stringKeys&&e.atKey?e.schema[n.SCALAR]:p?function(e,t,r,i,a){if("!"===r)return e[n.SCALAR];let s=[];for(let t of e.tags)if(!t.collection&&t.tag===r)if(!t.default||!t.test)return t;else s.push(t);for(let e of s)if(e.test?.test(t))return e;let o=e.knownTags[r];return o&&!o.collection?(e.tags.push(Object.assign({},o,{default:!1,test:void 0})),o):(a(i,"TAG_RESOLVE_FAILED",`Unresolved tag: ${r}`,"tag:yaml.org,2002:str"!==r),e[n.SCALAR])}(e.schema,u,p,r,o):"scalar"===t.type?function({atKey:e,directives:t,schema:r},i,a,s){let o=r.tags.find(t=>(!0===t.default||e&&"key"===t.default)&&t.test?.test(i))||r[n.SCALAR];if(r.compat){let e=r.compat.find(e=>e.default&&e.test?.test(i))??r[n.SCALAR];if(o.tag!==e.tag){let r=t.tagString(o.tag),n=t.tagString(e.tag);s(a,"TAG_RESOLVE_FAILED",`Value may be parsed as either ${r} or ${n}`,!0)}}return o}(e,u,t,o):e.schema[n.SCALAR];try{let a=l.resolve(u,e=>o(r??t,"TAG_RESOLVE_FAILED",e),e.options);c=n.isScalar(a)?a:new i.Scalar(a)}catch(e){o(r??t,"TAG_RESOLVE_FAILED",e instanceof Error?e.message:String(e)),c=new i.Scalar(u)}return c.range=h,c.source=u,d&&(c.type=d),p&&(c.tag=p),l.format&&(c.format=l.format),f&&(c.comment=f),c}},2545(e,t,r){var n=r(932),i=r(7087),a=r(9960),s=r(3409),o=r(6730),l=r(6040),c=r(4915);function u(e){if("number"==typeof e)return[e,e+1];if(Array.isArray(e))return 2===e.length?e:[e[0],e[1]];let{offset:t,source:r}=e;return[t,t+("string"==typeof r?r.length:1)]}function d(e){let t="",r=!1,n=!1;for(let i=0;i<e.length;++i){let a=e[i];switch(a[0]){case"#":t+=(""===t?"":n?"\n\n":"\n")+(a.substring(1)||" "),r=!0,n=!1;break;case"%":e[i+1]?.[0]!=="#"&&(i+=1),r=!1;break;default:r||(n=!0),r=!1}}return{comment:t,afterEmptyLine:n}}t.Composer=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(e,t,r,n)=>{let i=u(e);n?this.warnings.push(new s.YAMLWarning(i,t,r)):this.errors.push(new s.YAMLParseError(i,t,r))},this.directives=new i.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,t){let{comment:r,afterEmptyLine:n}=d(this.prelude);if(r){let i=e.contents;if(t)e.comment=e.comment?`${e.comment}
|
|
127
140
|
${r}`:r;else if(n||e.directives.docStart||!i)e.commentBefore=r;else if(o.isCollection(i)&&!i.flow&&i.items.length>0){let e=i.items[0];o.isPair(e)&&(e=e.key);let t=e.commentBefore;e.commentBefore=t?`${r}
|
|
128
141
|
${t}`:r}else{let e=i.commentBefore;i.commentBefore=e?`${r}
|
|
129
142
|
${e}`:r}}if(t){for(let t=0;t<this.errors.length;++t)e.errors.push(this.errors[t]);for(let t=0;t<this.warnings.length;++t)e.warnings.push(this.warnings[t])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:d(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,r=-1){for(let t of e)yield*this.next(t);yield*this.end(t,r)}*next(e){switch(n.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case"directive":this.directives.add(e.source,(t,r,n)=>{let i=u(e);i[0]+=t,this.onError(i,"BAD_DIRECTIVE",r,n)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let t=l.composeDoc(this.options,this.directives,e,this.onError);this.atDirectives&&!t.directives.docStart&&this.onError(e,"MISSING_CHAR","Missing directives-end/doc-start indicator line"),this.decorate(t,!1),this.doc&&(yield this.doc),this.doc=t,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(e.source);break;case"error":{let t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,r=new s.YAMLParseError(u(e),"UNEXPECTED_TOKEN",t);this.atDirectives||!this.doc?this.errors.push(r):this.doc.errors.push(r);break}case"doc-end":{if(!this.doc){this.errors.push(new s.YAMLParseError(u(e),"UNEXPECTED_TOKEN","Unexpected doc-end without preceding document"));break}this.doc.directives.docEnd=!0;let t=c.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let e=this.doc.comment;this.doc.comment=e?`${e}
|
|
130
|
-
${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new s.YAMLParseError(u(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let e=Object.assign({_directives:this.directives},this.options),r=new a.Document(void 0,e);this.atDirectives&&this.onError(t,"MISSING_CHAR","Missing directives-end indicator line"),r.range=[0,t,t],this.decorate(r,!1),yield r}}}},3244(e,t,r){var n=r(7748),i=r(73),a=r(7800),s=r(6884),o=r(7090),l=r(8388);let c="All mapping items must start at the same column";t.resolveBlockMap=function({composeNode:e,composeEmptyNode:t},r,u,d,f){let h=new(f?.nodeClass??i.YAMLMap)(r.schema);r.atRoot&&(r.atRoot=!1);let p=u.offset,m=null;for(let i of u.items){let{start:f,key:g,sep:y,value:b}=i,v=a.resolveProps(f,{indicator:"explicit-key-ind",next:g??y?.[0],offset:p,onError:d,parentIndent:u.indent,startOnNewline:!0}),w=!v.found;if(w){if(g&&("block-seq"===g.type?d(p,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in g&&g.indent!==u.indent&&d(p,"BAD_INDENT",c)),!v.anchor&&!v.tag&&!y){m=v.end,v.comment&&(h.comment?h.comment+="\n"+v.comment:h.comment=v.comment);continue}(v.newlineAfterProp||s.containsNewline(g))&&d(g??f[f.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else v.found?.indent!==u.indent&&d(p,"BAD_INDENT",c);r.atKey=!0;let x=v.end,_=g?e(r,g,v,d):t(r,x,f,null,v,d);r.schema.compat&&o.flowIndentCheck(u.indent,g,d),r.atKey=!1,l.mapIncludes(r,h.items,_)&&d(x,"DUPLICATE_KEY","Map keys must be unique");let k=a.resolveProps(y??[],{indicator:"map-value-ind",next:b,offset:_.range[2],onError:d,parentIndent:u.indent,startOnNewline:!g||"block-scalar"===g.type});if(p=k.end,k.found){w&&(b?.type!=="block-map"||k.hasNewline||d(p,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),r.options.strict&&v.start<k.found.offset-1024&&d(_.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let a=b?e(r,b,k,d):t(r,p,y,null,k,d);r.schema.compat&&o.flowIndentCheck(u.indent,b,d),p=a.range[2];let s=new n.Pair(_,a);r.options.keepSourceTokens&&(s.srcToken=i),h.items.push(s)}else{w&&d(_.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),k.comment&&(_.comment?_.comment+="\n"+k.comment:_.comment=k.comment);let e=new n.Pair(_);r.options.keepSourceTokens&&(e.srcToken=i),h.items.push(e)}}return m&&m<p&&d(m,"IMPOSSIBLE","Map comment with trailing content"),h.range=[u.offset,p,m??p],h}},2992(e,t,r){var n=r(8376);t.resolveBlockScalar=function(e,t,r){let i=t.offset,a=function({offset:e,props:t},r,n){if("block-scalar-header"!==t[0].type)return n(t[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:i}=t[0],a=i[0],s=0,o="",l=-1;for(let t=1;t<i.length;++t){let r=i[t];if(o||"-"!==r&&"+"!==r){let n=Number(r);!s&&n?s=n:-1===l&&(l=e+t)}else o=r}-1!==l&&n(l,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${i}`);let c=!1,u="",d=i.length;for(let e=1;e<t.length;++e){let i=t[e];switch(i.type){case"space":c=!0;case"newline":d+=i.source.length;break;case"comment":r&&!c&&n(i,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),d+=i.source.length,u=i.source.substring(1);break;case"error":n(i,"UNEXPECTED_TOKEN",i.message),d+=i.source.length;break;default:{let e=`Unexpected token in block scalar header: ${i.type}`;n(i,"UNEXPECTED_TOKEN",e);let t=i.source;t&&"string"==typeof t&&(d+=t.length)}}}return{mode:a,indent:s,chomp:o,comment:u,length:d}}(t,e.options.strict,r);if(!a)return{value:"",type:null,comment:"",range:[i,i,i]};let s=">"===a.mode?n.Scalar.BLOCK_FOLDED:n.Scalar.BLOCK_LITERAL,o=t.source?function(e){let t=e.split(/\n( *)/),r=t[0],n=r.match(/^( *)/),i=[n?.[1]?[n[1],r.slice(n[1].length)]:["",r]];for(let e=1;e<t.length;e+=2)i.push([t[e],t[e+1]]);return i}(t.source):[],l=o.length;for(let e=o.length-1;e>=0;--e){let t=o[e][1];if(""===t||"\r"===t)l=e;else break}if(0===l){let e="+"===a.chomp&&o.length>0?"\n".repeat(Math.max(1,o.length-1)):"",r=i+a.length;return t.source&&(r+=t.source.length),{value:e,type:s,comment:a.comment,range:[i,r,r]}}let c=t.indent+a.indent,u=t.offset+a.length,d=0;for(let t=0;t<l;++t){let[n,i]=o[t];if(""===i||"\r"===i)0===a.indent&&n.length>c&&(c=n.length);else{n.length<c&&r(u+n.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator"),0===a.indent&&(c=n.length),d=t,0!==c||e.atRoot||r(u,"BAD_INDENT","Block scalar values in collections must be indented");break}u+=n.length+i.length+1}for(let e=o.length-1;e>=l;--e)o[e][0].length>c&&(l=e+1);let f="",h="",p=!1;for(let e=0;e<d;++e)f+=o[e][0].slice(c)+"\n";for(let e=d;e<l;++e){let[t,i]=o[e];u+=t.length+i.length+1;let l="\r"===i[i.length-1];if(l&&(i=i.slice(0,-1)),i&&t.length<c){let e=a.indent?"explicit indentation indicator":"first line",n=`Block scalar lines must not be less indented than their ${e}`;r(u-i.length-(l?2:1),"BAD_INDENT",n),t=""}s===n.Scalar.BLOCK_LITERAL?(f+=h+t.slice(c)+i,h="\n"):t.length>c||" "===i[0]?(" "===h?h="\n":p||"\n"!==h||(h="\n\n"),f+=h+t.slice(c)+i,h="\n",p=!0):""===i?"\n"===h?f+="\n":h="\n":(f+=h+i,h=" ",p=!1)}switch(a.chomp){case"-":break;case"+":for(let e=l;e<o.length;++e)f+="\n"+o[e][0].slice(c);"\n"!==f[f.length-1]&&(f+="\n");break;default:f+="\n"}let m=i+a.length+t.source.length;return{value:f,type:s,comment:a.comment,range:[i,m,m]}}},6225(e,t,r){var n=r(7028),i=r(7800),a=r(7090);t.resolveBlockSeq=function({composeNode:e,composeEmptyNode:t},r,s,o,l){let c=new(l?.nodeClass??n.YAMLSeq)(r.schema);r.atRoot&&(r.atRoot=!1),r.atKey&&(r.atKey=!1);let u=s.offset,d=null;for(let{start:n,value:l}of s.items){let f=i.resolveProps(n,{indicator:"seq-item-ind",next:l,offset:u,onError:o,parentIndent:s.indent,startOnNewline:!0});if(!f.found)if(f.anchor||f.tag||l)l?.type==="block-seq"?o(f.end,"BAD_INDENT","All sequence items must start at the same column"):o(u,"MISSING_CHAR","Sequence item without - indicator");else{d=f.end,f.comment&&(c.comment=f.comment);continue}let h=l?e(r,l,f,o):t(r,f.end,n,null,f,o);r.schema.compat&&a.flowIndentCheck(s.indent,l,o),u=h.range[2],c.items.push(h)}return c.range=[s.offset,u,d??u],c}},4915(e,t){t.resolveEnd=function(e,t,r,n){let i="";if(e){let a=!1,s="";for(let o of e){let{source:e,type:l}=o;switch(l){case"space":a=!0;break;case"comment":{r&&!a&&n(o,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let t=e.substring(1)||" ";i?i+=s+t:i=t,s="";break}case"newline":i&&(s+=e),a=!0;break;default:n(o,"UNEXPECTED_TOKEN",`Unexpected ${l} at node end`)}t+=e.length}}return{comment:i,offset:t}}},9661(e,t,r){var n=r(6730),i=r(7748),a=r(73),s=r(7028),o=r(4915),l=r(7800),c=r(6884),u=r(8388);let d="Block collections are not allowed within flow collections",f=e=>e&&("block-map"===e.type||"block-seq"===e.type);t.resolveFlowCollection=function({composeNode:e,composeEmptyNode:t},r,h,p,m){let g="{"===h.start.source,y=g?"flow map":"flow sequence",b=new(m?.nodeClass??(g?a.YAMLMap:s.YAMLSeq))(r.schema);b.flow=!0;let v=r.atRoot;v&&(r.atRoot=!1),r.atKey&&(r.atKey=!1);let w=h.offset+h.start.source.length;for(let s=0;s<h.items.length;++s){let o=h.items[s],{start:m,key:v,sep:x,value:_}=o,k=l.resolveProps(m,{flow:y,indicator:"explicit-key-ind",next:v??x?.[0],offset:w,onError:p,parentIndent:h.indent,startOnNewline:!1});if(!k.found){if(!k.anchor&&!k.tag&&!x&&!_){0===s&&k.comma?p(k.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${y}`):s<h.items.length-1&&p(k.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${y}`),k.comment&&(b.comment?b.comment+="\n"+k.comment:b.comment=k.comment),w=k.end;continue}!g&&r.options.strict&&c.containsNewline(v)&&p(v,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(0===s)k.comma&&p(k.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${y}`);else if(k.comma||p(k.start,"MISSING_CHAR",`Missing , between ${y} items`),k.comment){let e="";e:for(let t of m)switch(t.type){case"comma":case"space":break;case"comment":e=t.source.substring(1);break e;default:break e}if(e){let t=b.items[b.items.length-1];n.isPair(t)&&(t=t.value??t.key),t.comment?t.comment+="\n"+e:t.comment=e,k.comment=k.comment.substring(e.length+1)}}if(g||x||k.found){r.atKey=!0;let n=k.end,s=v?e(r,v,k,p):t(r,n,m,null,k,p);f(v)&&p(s.range,"BLOCK_IN_FLOW",d),r.atKey=!1;let c=l.resolveProps(x??[],{flow:y,indicator:"map-value-ind",next:_,offset:s.range[2],onError:p,parentIndent:h.indent,startOnNewline:!1});if(c.found){if(!g&&!k.found&&r.options.strict){if(x)for(let e of x){if(e===c.found)break;if("newline"===e.type){p(e,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}k.start<c.found.offset-1024&&p(c.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else _&&("source"in _&&_.source?.[0]===":"?p(_,"MISSING_CHAR",`Missing space after : in ${y}`):p(c.start,"MISSING_CHAR",`Missing , or : between ${y} items`));let S=_?e(r,_,c,p):c.found?t(r,c.end,x,null,c,p):null;S?f(_)&&p(S.range,"BLOCK_IN_FLOW",d):c.comment&&(s.comment?s.comment+="\n"+c.comment:s.comment=c.comment);let O=new i.Pair(s,S);if(r.options.keepSourceTokens&&(O.srcToken=o),g)u.mapIncludes(r,b.items,s)&&p(n,"DUPLICATE_KEY","Map keys must be unique"),b.items.push(O);else{let e=new a.YAMLMap(r.schema);e.flow=!0,e.items.push(O);let t=(S??s).range;e.range=[s.range[0],t[1],t[2]],b.items.push(e)}w=S?S.range[2]:c.end}else{let n=_?e(r,_,k,p):t(r,k.end,x,null,k,p);b.items.push(n),w=n.range[2],f(_)&&p(n.range,"BLOCK_IN_FLOW",d)}}let x=g?"}":"]",[_,...k]=h.end,S=w;if(_?.source===x)S=_.offset+_.source.length;else{let e=y[0].toUpperCase()+y.substring(1),t=v?`${e} must end with a ${x}`:`${e} in block collection must be sufficiently indented and end with a ${x}`;p(w,v?"MISSING_CHAR":"BAD_INDENT",t),_&&1!==_.source.length&&k.unshift(_)}if(k.length>0){let e=o.resolveEnd(k,S,r.options.strict,p);e.comment&&(b.comment?b.comment+="\n"+e.comment:b.comment=e.comment),b.range=[h.offset,S,e.offset]}else b.range=[h.offset,S,S];return b}},3165(e,t,r){var n=r(8376),i=r(4915);function a(e){let t,r;try{t=RegExp("(.*?)(?<![ ])[ ]*\r?\n","sy"),r=RegExp("[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?\n","sy")}catch{t=/(.*?)[ \t]*\r?\n/sy,r=/[ \t]*(.*?)[ \t]*\r?\n/sy}let n=t.exec(e);if(!n)return e;let i=n[1],a=" ",s=t.lastIndex;for(r.lastIndex=s;n=r.exec(e);)""===n[1]?"\n"===a?i+=a:a="\n":(i+=a+n[1],a=" "),s=r.lastIndex;let o=/[ \t]*(.*)/sy;return o.lastIndex=s,n=o.exec(e),i+a+(n?.[1]??"")}let s={0:"\0",a:"\x07",b:"\b",e:"\x1b",f:"\f",n:"\n",r:"\r",t:" ",v:"\v",N:"
",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};t.resolveFlowScalar=function(e,t,r){let o,l,{offset:c,type:u,source:d,end:f}=e,h=(e,t,n)=>r(c+e,t,n);switch(u){case"scalar":o=n.Scalar.PLAIN,l=function(e,t){let r="";switch(e[0]){case" ":r="a tab character";break;case",":r="flow indicator character ,";break;case"%":r="directive indicator character %";break;case"|":case">":r=`block scalar indicator ${e[0]}`;break;case"@":case"`":r=`reserved character ${e[0]}`}return r&&t(0,"BAD_SCALAR_START",`Plain value cannot start with ${r}`),a(e)}(d,h);break;case"single-quoted-scalar":var p,m;o=n.Scalar.QUOTE_SINGLE,p=d,m=h,("'"!==p[p.length-1]||1===p.length)&&m(p.length,"MISSING_CHAR","Missing closing 'quote"),l=a(p.slice(1,-1)).replace(/''/g,"'");break;case"double-quoted-scalar":o=n.Scalar.QUOTE_DOUBLE,l=function(e,t){let r="";for(let n=1;n<e.length-1;++n){let i=e[n];if("\r"!==i||"\n"!==e[n+1])if("\n"===i){let{fold:t,offset:i}=function(e,t){let r="",n=e[t+1];for(;(" "===n||" "===n||"\n"===n||"\r"===n)&&("\r"!==n||"\n"===e[t+2]);)"\n"===n&&(r+="\n"),t+=1,n=e[t+1];return r||(r=" "),{fold:r,offset:t}}(e,n);r+=t,n=i}else if("\\"===i){let i=e[++n],a=s[i];if(a)r+=a;else if("\n"===i)for(i=e[n+1];" "===i||" "===i;)i=e[++n+1];else if("\r"===i&&"\n"===e[n+1])for(i=e[++n+1];" "===i||" "===i;)i=e[++n+1];else if("x"===i||"u"===i||"U"===i){let a="x"===i?2:"u"===i?4:8;r+=function(e,t,r,n){let i=e.substr(t,r),a=i.length===r&&/^[0-9a-fA-F]+$/.test(i)?parseInt(i,16):NaN;try{return String.fromCodePoint(a)}catch{let i=e.substr(t-2,r+2);return n(t-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${i}`),i}}(e,n+1,a,t),n+=a}else{let i=e.substr(n-1,2);t(n-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${i}`),r+=i}}else if(" "===i||" "===i){let t=n,a=e[n+1];for(;" "===a||" "===a;)a=e[++n+1];"\n"!==a&&("\r"!==a||"\n"!==e[n+2])&&(r+=n>t?e.slice(t,n+1):i)}else r+=i}return('"'!==e[e.length-1]||1===e.length)&&t(e.length,"MISSING_CHAR",'Missing closing "quote'),r}(d,h);break;default:return r(e,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${u}`),{value:"",type:null,comment:"",range:[c,c+d.length,c+d.length]}}let g=c+d.length,y=i.resolveEnd(f,g,t,r);return{value:l,type:o,comment:y.comment,range:[c,g,y.offset]}}},7800(e,t){t.resolveProps=function(e,{flow:t,indicator:r,next:n,offset:i,onError:a,parentIndent:s,startOnNewline:o}){let l=!1,c=o,u=o,d="",f="",h=!1,p=!1,m=null,g=null,y=null,b=null,v=null,w=null,x=null;for(let i of e)switch(p&&("space"!==i.type&&"newline"!==i.type&&"comma"!==i.type&&a(i.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),p=!1),m&&(c&&"comment"!==i.type&&"newline"!==i.type&&a(m,"TAB_AS_INDENT","Tabs are not allowed as indentation"),m=null),i.type){case"space":!t&&("doc-start"!==r||n?.type!=="flow-collection")&&i.source.includes(" ")&&(m=i),u=!0;break;case"comment":{u||a(i,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let e=i.source.substring(1)||" ";d?d+=f+e:d=e,f="",c=!1;break}case"newline":c?d?d+=i.source:w&&"seq-item-ind"===r||(l=!0):f+=i.source,c=!0,h=!0,(g||y)&&(b=i),u=!0;break;case"anchor":g&&a(i,"MULTIPLE_ANCHORS","A node can have at most one anchor"),i.source.endsWith(":")&&a(i.offset+i.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),g=i,x??(x=i.offset),c=!1,u=!1,p=!0;break;case"tag":y&&a(i,"MULTIPLE_TAGS","A node can have at most one tag"),y=i,x??(x=i.offset),c=!1,u=!1,p=!0;break;case r:(g||y)&&a(i,"BAD_PROP_ORDER",`Anchors and tags must be after the ${i.source} indicator`),w&&a(i,"UNEXPECTED_TOKEN",`Unexpected ${i.source} in ${t??"collection"}`),w=i,c="seq-item-ind"===r||"explicit-key-ind"===r,u=!1;break;case"comma":if(t){v&&a(i,"UNEXPECTED_TOKEN",`Unexpected , in ${t}`),v=i,c=!1,u=!1;break}default:a(i,"UNEXPECTED_TOKEN",`Unexpected ${i.type} token`),c=!1,u=!1}let _=e[e.length-1],k=_?_.offset+_.source.length:i;return p&&n&&"space"!==n.type&&"newline"!==n.type&&"comma"!==n.type&&("scalar"!==n.type||""!==n.source)&&a(n.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),m&&(c&&m.indent<=s||n?.type==="block-map"||n?.type==="block-seq")&&a(m,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:v,found:w,spaceBefore:l,comment:d,hasNewline:h,anchor:g,tag:y,newlineAfterProp:b,end:k,start:x??k}}},6884(e,t){t.containsNewline=function e(t){if(!t)return null;switch(t.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(t.source.includes("\n"))return!0;if(t.end){for(let e of t.end)if("newline"===e.type)return!0}return!1;case"flow-collection":for(let r of t.items){for(let e of r.start)if("newline"===e.type)return!0;if(r.sep){for(let e of r.sep)if("newline"===e.type)return!0}if(e(r.key)||e(r.value))return!0}return!1;default:return!0}}},4898(e,t){t.emptyScalarPosition=function(e,t,r){if(t){r??(r=t.length);for(let n=r-1;n>=0;--n){let r=t[n];switch(r.type){case"space":case"comment":case"newline":e-=r.source.length;continue}for(r=t[++n];r?.type==="space";)e+=r.source.length,r=t[++n];break}}return e}},7090(e,t,r){var n=r(6884);t.flowIndentCheck=function(e,t,r){if(t?.type==="flow-collection"){let i=t.end[0];i.indent===e&&("]"===i.source||"}"===i.source)&&n.containsNewline(t)&&r(i,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}},8388(e,t,r){var n=r(6730);t.mapIncludes=function(e,t,r){let{uniqueKeys:i}=e.options;if(!1===i)return!1;let a="function"==typeof i?i:(e,t)=>e===t||n.isScalar(e)&&n.isScalar(t)&&e.value===t.value;return t.some(e=>a(e.key,r))}},9960(e,t,r){var n=r(2298),i=r(7580),a=r(6730),s=r(7748),o=r(2234),l=r(8227),c=r(5966),u=r(9531),d=r(9768),f=r(7377),h=r(7087);function p(e){if(a.isCollection(e))return!0;throw Error("Expected a YAML collection as document contents")}t.Document=class e{constructor(e,t,r){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,a.NODE_TYPE,{value:a.DOC});let n=null;"function"==typeof t||Array.isArray(t)?n=t:void 0===r&&t&&(r=t,t=void 0);let i=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},r);this.options=i;let{version:s}=i;r?._directives?(this.directives=r._directives.atDocument(),this.directives.yaml.explicit&&(s=this.directives.yaml.version)):this.directives=new h.Directives({version:s}),this.setSchema(s,r),this.contents=void 0===e?null:this.createNode(e,n,r)}clone(){let t=Object.create(e.prototype,{[a.NODE_TYPE]:{value:a.DOC}});return t.commentBefore=this.commentBefore,t.comment=this.comment,t.errors=this.errors.slice(),t.warnings=this.warnings.slice(),t.options=Object.assign({},this.options),this.directives&&(t.directives=this.directives.clone()),t.schema=this.schema.clone(),t.contents=a.isNode(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(e){p(this.contents)&&this.contents.add(e)}addIn(e,t){p(this.contents)&&this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let r=u.anchorNames(this);e.anchor=!t||r.has(t)?u.findNewAnchor(t||"a",r):t}return new n.Alias(e.anchor)}createNode(e,t,r){let n;if("function"==typeof t)e=t.call({"":e},"",e),n=t;else if(Array.isArray(t)){let e=t.filter(e=>"number"==typeof e||e instanceof String||e instanceof Number).map(String);e.length>0&&(t=t.concat(e)),n=t}else void 0===r&&t&&(r=t,t=void 0);let{aliasDuplicateObjects:i,anchorPrefix:s,flow:o,keepUndefined:l,onTagObj:c,tag:d}=r??{},{onAnchor:h,setAnchors:p,sourceObjects:m}=u.createNodeAnchors(this,s||"a"),g={aliasDuplicateObjects:i??!0,keepUndefined:l??!1,onAnchor:h,onTagObj:c,replacer:n,schema:this.schema,sourceObjects:m},y=f.createNode(e,d,g);return o&&a.isCollection(y)&&(y.flow=!0),p(),y}createPair(e,t,r={}){let n=this.createNode(e,null,r),i=this.createNode(t,null,r);return new s.Pair(n,i)}delete(e){return!!p(this.contents)&&this.contents.delete(e)}deleteIn(e){return i.isEmptyPath(e)?null!=this.contents&&(this.contents=null,!0):!!p(this.contents)&&this.contents.deleteIn(e)}get(e,t){return a.isCollection(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return i.isEmptyPath(e)?!t&&a.isScalar(this.contents)?this.contents.value:this.contents:a.isCollection(this.contents)?this.contents.getIn(e,t):void 0}has(e){return!!a.isCollection(this.contents)&&this.contents.has(e)}hasIn(e){return i.isEmptyPath(e)?void 0!==this.contents:!!a.isCollection(this.contents)&&this.contents.hasIn(e)}set(e,t){null==this.contents?this.contents=i.collectionFromPath(this.schema,[e],t):p(this.contents)&&this.contents.set(e,t)}setIn(e,t){i.isEmptyPath(e)?this.contents=t:null==this.contents?this.contents=i.collectionFromPath(this.schema,Array.from(e),t):p(this.contents)&&this.contents.setIn(e,t)}setSchema(e,t={}){let r;switch("number"==typeof e&&(e=String(e)),e){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new h.Directives({version:"1.1"}),r={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=e:this.directives=new h.Directives({version:e}),r={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,r=null;break;default:{let t=JSON.stringify(e);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${t}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(r)this.schema=new l.Schema(Object.assign(r,t));else throw Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:t,mapAsMap:r,maxAliasCount:n,onAnchor:i,reviver:a}={}){let s={anchors:new Map,doc:this,keep:!e,mapAsMap:!0===r,mapKeyWarned:!1,maxAliasCount:"number"==typeof n?n:100},l=o.toJS(this.contents,t??"",s);if("function"==typeof i)for(let{count:e,res:t}of s.anchors.values())i(t,e);return"function"==typeof a?d.applyReviver(a,{"":l},"",l):l}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}toString(e={}){if(this.errors.length>0)throw Error("Document with errors cannot be stringified");if("indent"in e&&(!Number.isInteger(e.indent)||0>=Number(e.indent))){let t=JSON.stringify(e.indent);throw Error(`"indent" option must be a positive integer, not ${t}`)}return c.stringifyDocument(this,e)}}},9531(e,t,r){var n=r(6730),i=r(7995);function a(e){let t=new Set;return i.visit(e,{Value(e,r){r.anchor&&t.add(r.anchor)}}),t}function s(e,t){for(let r=1;;++r){let n=`${e}${r}`;if(!t.has(n))return n}}t.anchorIsValid=function(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let t=JSON.stringify(e);throw Error(`Anchor must not contain whitespace or control characters: ${t}`)}return!0},t.anchorNames=a,t.createNodeAnchors=function(e,t){let r=[],i=new Map,o=null;return{onAnchor:n=>{r.push(n),o??(o=a(e));let i=s(t,o);return o.add(i),i},setAnchors:()=>{for(let e of r){let t=i.get(e);if("object"==typeof t&&t.anchor&&(n.isScalar(t.node)||n.isCollection(t.node)))t.node.anchor=t.anchor;else{let t=Error("Failed to resolve repeated object (this should not happen)");throw t.source=e,t}}},sourceObjects:i}},t.findNewAnchor=s},9768(e,t){t.applyReviver=function e(t,r,n,i){if(i&&"object"==typeof i)if(Array.isArray(i))for(let r=0,n=i.length;r<n;++r){let n=i[r],a=e(t,i,String(r),n);void 0===a?delete i[r]:a!==n&&(i[r]=a)}else if(i instanceof Map)for(let r of Array.from(i.keys())){let n=i.get(r),a=e(t,i,r,n);void 0===a?i.delete(r):a!==n&&i.set(r,a)}else if(i instanceof Set)for(let r of Array.from(i)){let n=e(t,i,r,r);void 0===n?i.delete(r):n!==r&&(i.delete(r),i.add(n))}else for(let[r,n]of Object.entries(i)){let a=e(t,i,r,n);void 0===a?delete i[r]:a!==n&&(i[r]=a)}return t.call(r,n,i)}},7377(e,t,r){var n=r(2298),i=r(6730),a=r(8376);t.createNode=function(e,t,r){let s;if(i.isDocument(e)&&(e=e.contents),i.isNode(e))return e;if(i.isPair(e)){let t=r.schema[i.MAP].createNode?.(r.schema,null,r);return t.items.push(e),t}(e instanceof String||e instanceof Number||e instanceof Boolean||"u">typeof BigInt&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:o,onAnchor:l,onTagObj:c,schema:u,sourceObjects:d}=r;if(o&&e&&"object"==typeof e){if(s=d.get(e))return s.anchor??(s.anchor=l(e)),new n.Alias(s.anchor);s={anchor:null,node:null},d.set(e,s)}t?.startsWith("!!")&&(t="tag:yaml.org,2002:"+t.slice(2));let f=function(e,t,r){if(t){let e=r.filter(e=>e.tag===t),n=e.find(e=>!e.format)??e[0];if(!n)throw Error(`Tag ${t} not found`);return n}return r.find(t=>t.identify?.(e)&&!t.format)}(e,t,u.tags);if(!f){if(e&&"function"==typeof e.toJSON&&(e=e.toJSON()),!e||"object"!=typeof e){let t=new a.Scalar(e);return s&&(s.node=t),t}f=e instanceof Map?u[i.MAP]:Symbol.iterator in Object(e)?u[i.SEQ]:u[i.MAP]}c&&(c(f),delete r.onTagObj);let h=f?.createNode?f.createNode(r.schema,e,r):"function"==typeof f?.nodeClass?.from?f.nodeClass.from(r.schema,e,r):new a.Scalar(e);return t?h.tag=t:f.default||(h.tag=f.tag),s&&(s.node=h),h}},7087(e,t,r){var n=r(6730),i=r(7995);let a={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},s=e=>e.replace(/[!,[\]{}]/g,e=>a[e]);class o{constructor(e,t){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},o.defaultYaml,e),this.tags=Object.assign({},o.defaultTags,t)}clone(){let e=new o(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new o(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:o.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},o.defaultTags)}return e}add(e,t){this.atNextDocument&&(this.yaml={explicit:o.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},o.defaultTags),this.atNextDocument=!1);let r=e.trim().split(/[ \t]+/),n=r.shift();switch(n){case"%TAG":{if(2!==r.length&&(t(0,"%TAG directive should contain exactly two parts"),r.length<2))return!1;let[e,n]=r;return this.tags[e]=n,!0}case"%YAML":{if(this.yaml.explicit=!0,1!==r.length)return t(0,"%YAML directive should contain exactly one part"),!1;let[e]=r;if("1.1"===e||"1.2"===e)return this.yaml.version=e,!0;{let r=/^\d+\.\d+$/.test(e);return t(6,`Unsupported YAML version ${e}`,r),!1}}default:return t(0,`Unknown directive ${n}`,!0),!1}}tagName(e,t){if("!"===e)return"!";if("!"!==e[0])return t(`Not a valid tag: ${e}`),null;if("<"===e[1]){let r=e.slice(2,-1);return"!"===r||"!!"===r?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(">"!==e[e.length-1]&&t("Verbatim tags must end with a >"),r)}let[,r,n]=e.match(/^(.*!)([^!]*)$/s);n||t(`The ${e} tag has no suffix`);let i=this.tags[r];if(i)try{return i+decodeURIComponent(n)}catch(e){return t(String(e)),null}return"!"===r?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,r]of Object.entries(this.tags))if(e.startsWith(r))return t+s(e.substring(r.length));return"!"===e[0]?e:`!<${e}>`}toString(e){let t,r=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],a=Object.entries(this.tags);if(e&&a.length>0&&n.isNode(e.contents)){let r={};i.visit(e.contents,(e,t)=>{n.isNode(t)&&t.tag&&(r[t.tag]=!0)}),t=Object.keys(r)}else t=[];for(let[n,i]of a)("!!"!==n||"tag:yaml.org,2002:"!==i)&&(!e||t.some(e=>e.startsWith(i)))&&r.push(`%TAG ${n} ${i}`);return r.join("\n")}}o.defaultYaml={explicit:!1,version:"1.2"},o.defaultTags={"!!":"tag:yaml.org,2002:"},t.Directives=o},3409(e,t){class r extends Error{constructor(e,t,r,n){super(),this.name=e,this.code=r,this.message=n,this.pos=t}}t.YAMLError=r,t.YAMLParseError=class extends r{constructor(e,t,r){super("YAMLParseError",e,t,r)}},t.YAMLWarning=class extends r{constructor(e,t,r){super("YAMLWarning",e,t,r)}},t.prettifyError=(e,t)=>r=>{if(-1===r.pos[0])return;r.linePos=r.pos.map(e=>t.linePos(e));let{line:n,col:i}=r.linePos[0];r.message+=` at line ${n}, column ${i}`;let a=i-1,s=e.substring(t.lineStarts[n-1],t.lineStarts[n]).replace(/[\n\r]+$/,"");if(a>=60&&s.length>80){let e=Math.min(a-39,s.length-79);s="…"+s.substring(e),a-=e-1}if(s.length>80&&(s=s.substring(0,79)+"…"),n>1&&/^ *$/.test(s.substring(0,a))){let r=e.substring(t.lineStarts[n-2],t.lineStarts[n-1]);r.length>80&&(r=r.substring(0,79)+"…\n"),s=r+s}if(/[^ ]/.test(s)){let e=1,t=r.linePos[1];t?.line===n&&t.col>i&&(e=Math.max(1,Math.min(t.col-i,80-a)));let o=" ".repeat(a)+"^".repeat(e);r.message+=`:
|
|
143
|
+
${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new s.YAMLParseError(u(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let e=Object.assign({_directives:this.directives},this.options),r=new a.Document(void 0,e);this.atDirectives&&this.onError(t,"MISSING_CHAR","Missing directives-end indicator line"),r.range=[0,t,t],this.decorate(r,!1),yield r}}}},3244(e,t,r){var n=r(7748),i=r(73),a=r(7800),s=r(6884),o=r(7090),l=r(8388);let c="All mapping items must start at the same column";t.resolveBlockMap=function({composeNode:e,composeEmptyNode:t},r,u,d,f){let h=new(f?.nodeClass??i.YAMLMap)(r.schema);r.atRoot&&(r.atRoot=!1);let p=u.offset,m=null;for(let i of u.items){let{start:f,key:g,sep:y,value:b}=i,v=a.resolveProps(f,{indicator:"explicit-key-ind",next:g??y?.[0],offset:p,onError:d,parentIndent:u.indent,startOnNewline:!0}),w=!v.found;if(w){if(g&&("block-seq"===g.type?d(p,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in g&&g.indent!==u.indent&&d(p,"BAD_INDENT",c)),!v.anchor&&!v.tag&&!y){m=v.end,v.comment&&(h.comment?h.comment+="\n"+v.comment:h.comment=v.comment);continue}(v.newlineAfterProp||s.containsNewline(g))&&d(g??f[f.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else v.found?.indent!==u.indent&&d(p,"BAD_INDENT",c);r.atKey=!0;let x=v.end,_=g?e(r,g,v,d):t(r,x,f,null,v,d);r.schema.compat&&o.flowIndentCheck(u.indent,g,d),r.atKey=!1,l.mapIncludes(r,h.items,_)&&d(x,"DUPLICATE_KEY","Map keys must be unique");let k=a.resolveProps(y??[],{indicator:"map-value-ind",next:b,offset:_.range[2],onError:d,parentIndent:u.indent,startOnNewline:!g||"block-scalar"===g.type});if(p=k.end,k.found){w&&(b?.type!=="block-map"||k.hasNewline||d(p,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),r.options.strict&&v.start<k.found.offset-1024&&d(_.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let a=b?e(r,b,k,d):t(r,p,y,null,k,d);r.schema.compat&&o.flowIndentCheck(u.indent,b,d),p=a.range[2];let s=new n.Pair(_,a);r.options.keepSourceTokens&&(s.srcToken=i),h.items.push(s)}else{w&&d(_.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),k.comment&&(_.comment?_.comment+="\n"+k.comment:_.comment=k.comment);let e=new n.Pair(_);r.options.keepSourceTokens&&(e.srcToken=i),h.items.push(e)}}return m&&m<p&&d(m,"IMPOSSIBLE","Map comment with trailing content"),h.range=[u.offset,p,m??p],h}},2992(e,t,r){var n=r(8376);t.resolveBlockScalar=function(e,t,r){let i=t.offset,a=function({offset:e,props:t},r,n){if("block-scalar-header"!==t[0].type)return n(t[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:i}=t[0],a=i[0],s=0,o="",l=-1;for(let t=1;t<i.length;++t){let r=i[t];if(o||"-"!==r&&"+"!==r){let n=Number(r);!s&&n?s=n:-1===l&&(l=e+t)}else o=r}-1!==l&&n(l,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${i}`);let c=!1,u="",d=i.length;for(let e=1;e<t.length;++e){let i=t[e];switch(i.type){case"space":c=!0;case"newline":d+=i.source.length;break;case"comment":r&&!c&&n(i,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),d+=i.source.length,u=i.source.substring(1);break;case"error":n(i,"UNEXPECTED_TOKEN",i.message),d+=i.source.length;break;default:{let e=`Unexpected token in block scalar header: ${i.type}`;n(i,"UNEXPECTED_TOKEN",e);let t=i.source;t&&"string"==typeof t&&(d+=t.length)}}}return{mode:a,indent:s,chomp:o,comment:u,length:d}}(t,e.options.strict,r);if(!a)return{value:"",type:null,comment:"",range:[i,i,i]};let s=">"===a.mode?n.Scalar.BLOCK_FOLDED:n.Scalar.BLOCK_LITERAL,o=t.source?function(e){let t=e.split(/\n( *)/),r=t[0],n=r.match(/^( *)/),i=[n?.[1]?[n[1],r.slice(n[1].length)]:["",r]];for(let e=1;e<t.length;e+=2)i.push([t[e],t[e+1]]);return i}(t.source):[],l=o.length;for(let e=o.length-1;e>=0;--e){let t=o[e][1];if(""===t||"\r"===t)l=e;else break}if(0===l){let e="+"===a.chomp&&o.length>0?"\n".repeat(Math.max(1,o.length-1)):"",r=i+a.length;return t.source&&(r+=t.source.length),{value:e,type:s,comment:a.comment,range:[i,r,r]}}let c=t.indent+a.indent,u=t.offset+a.length,d=0;for(let t=0;t<l;++t){let[n,i]=o[t];if(""===i||"\r"===i)0===a.indent&&n.length>c&&(c=n.length);else{n.length<c&&r(u+n.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator"),0===a.indent&&(c=n.length),d=t,0!==c||e.atRoot||r(u,"BAD_INDENT","Block scalar values in collections must be indented");break}u+=n.length+i.length+1}for(let e=o.length-1;e>=l;--e)o[e][0].length>c&&(l=e+1);let f="",h="",p=!1;for(let e=0;e<d;++e)f+=o[e][0].slice(c)+"\n";for(let e=d;e<l;++e){let[t,i]=o[e];u+=t.length+i.length+1;let l="\r"===i[i.length-1];if(l&&(i=i.slice(0,-1)),i&&t.length<c){let e=a.indent?"explicit indentation indicator":"first line",n=`Block scalar lines must not be less indented than their ${e}`;r(u-i.length-(l?2:1),"BAD_INDENT",n),t=""}s===n.Scalar.BLOCK_LITERAL?(f+=h+t.slice(c)+i,h="\n"):t.length>c||" "===i[0]?(" "===h?h="\n":p||"\n"!==h||(h="\n\n"),f+=h+t.slice(c)+i,h="\n",p=!0):""===i?"\n"===h?f+="\n":h="\n":(f+=h+i,h=" ",p=!1)}switch(a.chomp){case"-":break;case"+":for(let e=l;e<o.length;++e)f+="\n"+o[e][0].slice(c);"\n"!==f[f.length-1]&&(f+="\n");break;default:f+="\n"}let m=i+a.length+t.source.length;return{value:f,type:s,comment:a.comment,range:[i,m,m]}}},6225(e,t,r){var n=r(7028),i=r(7800),a=r(7090);t.resolveBlockSeq=function({composeNode:e,composeEmptyNode:t},r,s,o,l){let c=new(l?.nodeClass??n.YAMLSeq)(r.schema);r.atRoot&&(r.atRoot=!1),r.atKey&&(r.atKey=!1);let u=s.offset,d=null;for(let{start:n,value:l}of s.items){let f=i.resolveProps(n,{indicator:"seq-item-ind",next:l,offset:u,onError:o,parentIndent:s.indent,startOnNewline:!0});if(!f.found)if(f.anchor||f.tag||l)l?.type==="block-seq"?o(f.end,"BAD_INDENT","All sequence items must start at the same column"):o(u,"MISSING_CHAR","Sequence item without - indicator");else{d=f.end,f.comment&&(c.comment=f.comment);continue}let h=l?e(r,l,f,o):t(r,f.end,n,null,f,o);r.schema.compat&&a.flowIndentCheck(s.indent,l,o),u=h.range[2],c.items.push(h)}return c.range=[s.offset,u,d??u],c}},4915(e,t){t.resolveEnd=function(e,t,r,n){let i="";if(e){let a=!1,s="";for(let o of e){let{source:e,type:l}=o;switch(l){case"space":a=!0;break;case"comment":{r&&!a&&n(o,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let t=e.substring(1)||" ";i?i+=s+t:i=t,s="";break}case"newline":i&&(s+=e),a=!0;break;default:n(o,"UNEXPECTED_TOKEN",`Unexpected ${l} at node end`)}t+=e.length}}return{comment:i,offset:t}}},9661(e,t,r){var n=r(6730),i=r(7748),a=r(73),s=r(7028),o=r(4915),l=r(7800),c=r(6884),u=r(8388);let d="Block collections are not allowed within flow collections",f=e=>e&&("block-map"===e.type||"block-seq"===e.type);t.resolveFlowCollection=function({composeNode:e,composeEmptyNode:t},r,h,p,m){let g="{"===h.start.source,y=g?"flow map":"flow sequence",b=new(m?.nodeClass??(g?a.YAMLMap:s.YAMLSeq))(r.schema);b.flow=!0;let v=r.atRoot;v&&(r.atRoot=!1),r.atKey&&(r.atKey=!1);let w=h.offset+h.start.source.length;for(let s=0;s<h.items.length;++s){let o=h.items[s],{start:m,key:v,sep:x,value:_}=o,k=l.resolveProps(m,{flow:y,indicator:"explicit-key-ind",next:v??x?.[0],offset:w,onError:p,parentIndent:h.indent,startOnNewline:!1});if(!k.found){if(!k.anchor&&!k.tag&&!x&&!_){0===s&&k.comma?p(k.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${y}`):s<h.items.length-1&&p(k.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${y}`),k.comment&&(b.comment?b.comment+="\n"+k.comment:b.comment=k.comment),w=k.end;continue}!g&&r.options.strict&&c.containsNewline(v)&&p(v,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(0===s)k.comma&&p(k.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${y}`);else if(k.comma||p(k.start,"MISSING_CHAR",`Missing , between ${y} items`),k.comment){let e="";e:for(let t of m)switch(t.type){case"comma":case"space":break;case"comment":e=t.source.substring(1);break e;default:break e}if(e){let t=b.items[b.items.length-1];n.isPair(t)&&(t=t.value??t.key),t.comment?t.comment+="\n"+e:t.comment=e,k.comment=k.comment.substring(e.length+1)}}if(g||x||k.found){r.atKey=!0;let n=k.end,s=v?e(r,v,k,p):t(r,n,m,null,k,p);f(v)&&p(s.range,"BLOCK_IN_FLOW",d),r.atKey=!1;let c=l.resolveProps(x??[],{flow:y,indicator:"map-value-ind",next:_,offset:s.range[2],onError:p,parentIndent:h.indent,startOnNewline:!1});if(c.found){if(!g&&!k.found&&r.options.strict){if(x)for(let e of x){if(e===c.found)break;if("newline"===e.type){p(e,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}k.start<c.found.offset-1024&&p(c.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else _&&("source"in _&&_.source?.[0]===":"?p(_,"MISSING_CHAR",`Missing space after : in ${y}`):p(c.start,"MISSING_CHAR",`Missing , or : between ${y} items`));let S=_?e(r,_,c,p):c.found?t(r,c.end,x,null,c,p):null;S?f(_)&&p(S.range,"BLOCK_IN_FLOW",d):c.comment&&(s.comment?s.comment+="\n"+c.comment:s.comment=c.comment);let $=new i.Pair(s,S);if(r.options.keepSourceTokens&&($.srcToken=o),g)u.mapIncludes(r,b.items,s)&&p(n,"DUPLICATE_KEY","Map keys must be unique"),b.items.push($);else{let e=new a.YAMLMap(r.schema);e.flow=!0,e.items.push($);let t=(S??s).range;e.range=[s.range[0],t[1],t[2]],b.items.push(e)}w=S?S.range[2]:c.end}else{let n=_?e(r,_,k,p):t(r,k.end,x,null,k,p);b.items.push(n),w=n.range[2],f(_)&&p(n.range,"BLOCK_IN_FLOW",d)}}let x=g?"}":"]",[_,...k]=h.end,S=w;if(_?.source===x)S=_.offset+_.source.length;else{let e=y[0].toUpperCase()+y.substring(1),t=v?`${e} must end with a ${x}`:`${e} in block collection must be sufficiently indented and end with a ${x}`;p(w,v?"MISSING_CHAR":"BAD_INDENT",t),_&&1!==_.source.length&&k.unshift(_)}if(k.length>0){let e=o.resolveEnd(k,S,r.options.strict,p);e.comment&&(b.comment?b.comment+="\n"+e.comment:b.comment=e.comment),b.range=[h.offset,S,e.offset]}else b.range=[h.offset,S,S];return b}},3165(e,t,r){var n=r(8376),i=r(4915);function a(e){let t,r;try{t=RegExp("(.*?)(?<![ ])[ ]*\r?\n","sy"),r=RegExp("[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?\n","sy")}catch{t=/(.*?)[ \t]*\r?\n/sy,r=/[ \t]*(.*?)[ \t]*\r?\n/sy}let n=t.exec(e);if(!n)return e;let i=n[1],a=" ",s=t.lastIndex;for(r.lastIndex=s;n=r.exec(e);)""===n[1]?"\n"===a?i+=a:a="\n":(i+=a+n[1],a=" "),s=r.lastIndex;let o=/[ \t]*(.*)/sy;return o.lastIndex=s,n=o.exec(e),i+a+(n?.[1]??"")}let s={0:"\0",a:"\x07",b:"\b",e:"\x1b",f:"\f",n:"\n",r:"\r",t:" ",v:"\v",N:"
",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};t.resolveFlowScalar=function(e,t,r){let o,l,{offset:c,type:u,source:d,end:f}=e,h=(e,t,n)=>r(c+e,t,n);switch(u){case"scalar":o=n.Scalar.PLAIN,l=function(e,t){let r="";switch(e[0]){case" ":r="a tab character";break;case",":r="flow indicator character ,";break;case"%":r="directive indicator character %";break;case"|":case">":r=`block scalar indicator ${e[0]}`;break;case"@":case"`":r=`reserved character ${e[0]}`}return r&&t(0,"BAD_SCALAR_START",`Plain value cannot start with ${r}`),a(e)}(d,h);break;case"single-quoted-scalar":var p,m;o=n.Scalar.QUOTE_SINGLE,p=d,m=h,("'"!==p[p.length-1]||1===p.length)&&m(p.length,"MISSING_CHAR","Missing closing 'quote"),l=a(p.slice(1,-1)).replace(/''/g,"'");break;case"double-quoted-scalar":o=n.Scalar.QUOTE_DOUBLE,l=function(e,t){let r="";for(let n=1;n<e.length-1;++n){let i=e[n];if("\r"!==i||"\n"!==e[n+1])if("\n"===i){let{fold:t,offset:i}=function(e,t){let r="",n=e[t+1];for(;(" "===n||" "===n||"\n"===n||"\r"===n)&&("\r"!==n||"\n"===e[t+2]);)"\n"===n&&(r+="\n"),t+=1,n=e[t+1];return r||(r=" "),{fold:r,offset:t}}(e,n);r+=t,n=i}else if("\\"===i){let i=e[++n],a=s[i];if(a)r+=a;else if("\n"===i)for(i=e[n+1];" "===i||" "===i;)i=e[++n+1];else if("\r"===i&&"\n"===e[n+1])for(i=e[++n+1];" "===i||" "===i;)i=e[++n+1];else if("x"===i||"u"===i||"U"===i){let a="x"===i?2:"u"===i?4:8;r+=function(e,t,r,n){let i=e.substr(t,r),a=i.length===r&&/^[0-9a-fA-F]+$/.test(i)?parseInt(i,16):NaN;try{return String.fromCodePoint(a)}catch{let i=e.substr(t-2,r+2);return n(t-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${i}`),i}}(e,n+1,a,t),n+=a}else{let i=e.substr(n-1,2);t(n-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${i}`),r+=i}}else if(" "===i||" "===i){let t=n,a=e[n+1];for(;" "===a||" "===a;)a=e[++n+1];"\n"!==a&&("\r"!==a||"\n"!==e[n+2])&&(r+=n>t?e.slice(t,n+1):i)}else r+=i}return('"'!==e[e.length-1]||1===e.length)&&t(e.length,"MISSING_CHAR",'Missing closing "quote'),r}(d,h);break;default:return r(e,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${u}`),{value:"",type:null,comment:"",range:[c,c+d.length,c+d.length]}}let g=c+d.length,y=i.resolveEnd(f,g,t,r);return{value:l,type:o,comment:y.comment,range:[c,g,y.offset]}}},7800(e,t){t.resolveProps=function(e,{flow:t,indicator:r,next:n,offset:i,onError:a,parentIndent:s,startOnNewline:o}){let l=!1,c=o,u=o,d="",f="",h=!1,p=!1,m=null,g=null,y=null,b=null,v=null,w=null,x=null;for(let i of e)switch(p&&("space"!==i.type&&"newline"!==i.type&&"comma"!==i.type&&a(i.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),p=!1),m&&(c&&"comment"!==i.type&&"newline"!==i.type&&a(m,"TAB_AS_INDENT","Tabs are not allowed as indentation"),m=null),i.type){case"space":!t&&("doc-start"!==r||n?.type!=="flow-collection")&&i.source.includes(" ")&&(m=i),u=!0;break;case"comment":{u||a(i,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let e=i.source.substring(1)||" ";d?d+=f+e:d=e,f="",c=!1;break}case"newline":c?d?d+=i.source:w&&"seq-item-ind"===r||(l=!0):f+=i.source,c=!0,h=!0,(g||y)&&(b=i),u=!0;break;case"anchor":g&&a(i,"MULTIPLE_ANCHORS","A node can have at most one anchor"),i.source.endsWith(":")&&a(i.offset+i.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),g=i,x??(x=i.offset),c=!1,u=!1,p=!0;break;case"tag":y&&a(i,"MULTIPLE_TAGS","A node can have at most one tag"),y=i,x??(x=i.offset),c=!1,u=!1,p=!0;break;case r:(g||y)&&a(i,"BAD_PROP_ORDER",`Anchors and tags must be after the ${i.source} indicator`),w&&a(i,"UNEXPECTED_TOKEN",`Unexpected ${i.source} in ${t??"collection"}`),w=i,c="seq-item-ind"===r||"explicit-key-ind"===r,u=!1;break;case"comma":if(t){v&&a(i,"UNEXPECTED_TOKEN",`Unexpected , in ${t}`),v=i,c=!1,u=!1;break}default:a(i,"UNEXPECTED_TOKEN",`Unexpected ${i.type} token`),c=!1,u=!1}let _=e[e.length-1],k=_?_.offset+_.source.length:i;return p&&n&&"space"!==n.type&&"newline"!==n.type&&"comma"!==n.type&&("scalar"!==n.type||""!==n.source)&&a(n.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),m&&(c&&m.indent<=s||n?.type==="block-map"||n?.type==="block-seq")&&a(m,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:v,found:w,spaceBefore:l,comment:d,hasNewline:h,anchor:g,tag:y,newlineAfterProp:b,end:k,start:x??k}}},6884(e,t){t.containsNewline=function e(t){if(!t)return null;switch(t.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(t.source.includes("\n"))return!0;if(t.end){for(let e of t.end)if("newline"===e.type)return!0}return!1;case"flow-collection":for(let r of t.items){for(let e of r.start)if("newline"===e.type)return!0;if(r.sep){for(let e of r.sep)if("newline"===e.type)return!0}if(e(r.key)||e(r.value))return!0}return!1;default:return!0}}},4898(e,t){t.emptyScalarPosition=function(e,t,r){if(t){r??(r=t.length);for(let n=r-1;n>=0;--n){let r=t[n];switch(r.type){case"space":case"comment":case"newline":e-=r.source.length;continue}for(r=t[++n];r?.type==="space";)e+=r.source.length,r=t[++n];break}}return e}},7090(e,t,r){var n=r(6884);t.flowIndentCheck=function(e,t,r){if(t?.type==="flow-collection"){let i=t.end[0];i.indent===e&&("]"===i.source||"}"===i.source)&&n.containsNewline(t)&&r(i,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}},8388(e,t,r){var n=r(6730);t.mapIncludes=function(e,t,r){let{uniqueKeys:i}=e.options;if(!1===i)return!1;let a="function"==typeof i?i:(e,t)=>e===t||n.isScalar(e)&&n.isScalar(t)&&e.value===t.value;return t.some(e=>a(e.key,r))}},9960(e,t,r){var n=r(2298),i=r(7580),a=r(6730),s=r(7748),o=r(2234),l=r(8227),c=r(5966),u=r(9531),d=r(9768),f=r(7377),h=r(7087);function p(e){if(a.isCollection(e))return!0;throw Error("Expected a YAML collection as document contents")}t.Document=class e{constructor(e,t,r){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,a.NODE_TYPE,{value:a.DOC});let n=null;"function"==typeof t||Array.isArray(t)?n=t:void 0===r&&t&&(r=t,t=void 0);let i=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},r);this.options=i;let{version:s}=i;r?._directives?(this.directives=r._directives.atDocument(),this.directives.yaml.explicit&&(s=this.directives.yaml.version)):this.directives=new h.Directives({version:s}),this.setSchema(s,r),this.contents=void 0===e?null:this.createNode(e,n,r)}clone(){let t=Object.create(e.prototype,{[a.NODE_TYPE]:{value:a.DOC}});return t.commentBefore=this.commentBefore,t.comment=this.comment,t.errors=this.errors.slice(),t.warnings=this.warnings.slice(),t.options=Object.assign({},this.options),this.directives&&(t.directives=this.directives.clone()),t.schema=this.schema.clone(),t.contents=a.isNode(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(e){p(this.contents)&&this.contents.add(e)}addIn(e,t){p(this.contents)&&this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let r=u.anchorNames(this);e.anchor=!t||r.has(t)?u.findNewAnchor(t||"a",r):t}return new n.Alias(e.anchor)}createNode(e,t,r){let n;if("function"==typeof t)e=t.call({"":e},"",e),n=t;else if(Array.isArray(t)){let e=t.filter(e=>"number"==typeof e||e instanceof String||e instanceof Number).map(String);e.length>0&&(t=t.concat(e)),n=t}else void 0===r&&t&&(r=t,t=void 0);let{aliasDuplicateObjects:i,anchorPrefix:s,flow:o,keepUndefined:l,onTagObj:c,tag:d}=r??{},{onAnchor:h,setAnchors:p,sourceObjects:m}=u.createNodeAnchors(this,s||"a"),g={aliasDuplicateObjects:i??!0,keepUndefined:l??!1,onAnchor:h,onTagObj:c,replacer:n,schema:this.schema,sourceObjects:m},y=f.createNode(e,d,g);return o&&a.isCollection(y)&&(y.flow=!0),p(),y}createPair(e,t,r={}){let n=this.createNode(e,null,r),i=this.createNode(t,null,r);return new s.Pair(n,i)}delete(e){return!!p(this.contents)&&this.contents.delete(e)}deleteIn(e){return i.isEmptyPath(e)?null!=this.contents&&(this.contents=null,!0):!!p(this.contents)&&this.contents.deleteIn(e)}get(e,t){return a.isCollection(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return i.isEmptyPath(e)?!t&&a.isScalar(this.contents)?this.contents.value:this.contents:a.isCollection(this.contents)?this.contents.getIn(e,t):void 0}has(e){return!!a.isCollection(this.contents)&&this.contents.has(e)}hasIn(e){return i.isEmptyPath(e)?void 0!==this.contents:!!a.isCollection(this.contents)&&this.contents.hasIn(e)}set(e,t){null==this.contents?this.contents=i.collectionFromPath(this.schema,[e],t):p(this.contents)&&this.contents.set(e,t)}setIn(e,t){i.isEmptyPath(e)?this.contents=t:null==this.contents?this.contents=i.collectionFromPath(this.schema,Array.from(e),t):p(this.contents)&&this.contents.setIn(e,t)}setSchema(e,t={}){let r;switch("number"==typeof e&&(e=String(e)),e){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new h.Directives({version:"1.1"}),r={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=e:this.directives=new h.Directives({version:e}),r={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,r=null;break;default:{let t=JSON.stringify(e);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${t}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(r)this.schema=new l.Schema(Object.assign(r,t));else throw Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:t,mapAsMap:r,maxAliasCount:n,onAnchor:i,reviver:a}={}){let s={anchors:new Map,doc:this,keep:!e,mapAsMap:!0===r,mapKeyWarned:!1,maxAliasCount:"number"==typeof n?n:100},l=o.toJS(this.contents,t??"",s);if("function"==typeof i)for(let{count:e,res:t}of s.anchors.values())i(t,e);return"function"==typeof a?d.applyReviver(a,{"":l},"",l):l}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}toString(e={}){if(this.errors.length>0)throw Error("Document with errors cannot be stringified");if("indent"in e&&(!Number.isInteger(e.indent)||0>=Number(e.indent))){let t=JSON.stringify(e.indent);throw Error(`"indent" option must be a positive integer, not ${t}`)}return c.stringifyDocument(this,e)}}},9531(e,t,r){var n=r(6730),i=r(7995);function a(e){let t=new Set;return i.visit(e,{Value(e,r){r.anchor&&t.add(r.anchor)}}),t}function s(e,t){for(let r=1;;++r){let n=`${e}${r}`;if(!t.has(n))return n}}t.anchorIsValid=function(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let t=JSON.stringify(e);throw Error(`Anchor must not contain whitespace or control characters: ${t}`)}return!0},t.anchorNames=a,t.createNodeAnchors=function(e,t){let r=[],i=new Map,o=null;return{onAnchor:n=>{r.push(n),o??(o=a(e));let i=s(t,o);return o.add(i),i},setAnchors:()=>{for(let e of r){let t=i.get(e);if("object"==typeof t&&t.anchor&&(n.isScalar(t.node)||n.isCollection(t.node)))t.node.anchor=t.anchor;else{let t=Error("Failed to resolve repeated object (this should not happen)");throw t.source=e,t}}},sourceObjects:i}},t.findNewAnchor=s},9768(e,t){t.applyReviver=function e(t,r,n,i){if(i&&"object"==typeof i)if(Array.isArray(i))for(let r=0,n=i.length;r<n;++r){let n=i[r],a=e(t,i,String(r),n);void 0===a?delete i[r]:a!==n&&(i[r]=a)}else if(i instanceof Map)for(let r of Array.from(i.keys())){let n=i.get(r),a=e(t,i,r,n);void 0===a?i.delete(r):a!==n&&i.set(r,a)}else if(i instanceof Set)for(let r of Array.from(i)){let n=e(t,i,r,r);void 0===n?i.delete(r):n!==r&&(i.delete(r),i.add(n))}else for(let[r,n]of Object.entries(i)){let a=e(t,i,r,n);void 0===a?delete i[r]:a!==n&&(i[r]=a)}return t.call(r,n,i)}},7377(e,t,r){var n=r(2298),i=r(6730),a=r(8376);t.createNode=function(e,t,r){let s;if(i.isDocument(e)&&(e=e.contents),i.isNode(e))return e;if(i.isPair(e)){let t=r.schema[i.MAP].createNode?.(r.schema,null,r);return t.items.push(e),t}(e instanceof String||e instanceof Number||e instanceof Boolean||"u">typeof BigInt&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:o,onAnchor:l,onTagObj:c,schema:u,sourceObjects:d}=r;if(o&&e&&"object"==typeof e){if(s=d.get(e))return s.anchor??(s.anchor=l(e)),new n.Alias(s.anchor);s={anchor:null,node:null},d.set(e,s)}t?.startsWith("!!")&&(t="tag:yaml.org,2002:"+t.slice(2));let f=function(e,t,r){if(t){let e=r.filter(e=>e.tag===t),n=e.find(e=>!e.format)??e[0];if(!n)throw Error(`Tag ${t} not found`);return n}return r.find(t=>t.identify?.(e)&&!t.format)}(e,t,u.tags);if(!f){if(e&&"function"==typeof e.toJSON&&(e=e.toJSON()),!e||"object"!=typeof e){let t=new a.Scalar(e);return s&&(s.node=t),t}f=e instanceof Map?u[i.MAP]:Symbol.iterator in Object(e)?u[i.SEQ]:u[i.MAP]}c&&(c(f),delete r.onTagObj);let h=f?.createNode?f.createNode(r.schema,e,r):"function"==typeof f?.nodeClass?.from?f.nodeClass.from(r.schema,e,r):new a.Scalar(e);return t?h.tag=t:f.default||(h.tag=f.tag),s&&(s.node=h),h}},7087(e,t,r){var n=r(6730),i=r(7995);let a={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},s=e=>e.replace(/[!,[\]{}]/g,e=>a[e]);class o{constructor(e,t){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},o.defaultYaml,e),this.tags=Object.assign({},o.defaultTags,t)}clone(){let e=new o(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new o(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:o.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},o.defaultTags)}return e}add(e,t){this.atNextDocument&&(this.yaml={explicit:o.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},o.defaultTags),this.atNextDocument=!1);let r=e.trim().split(/[ \t]+/),n=r.shift();switch(n){case"%TAG":{if(2!==r.length&&(t(0,"%TAG directive should contain exactly two parts"),r.length<2))return!1;let[e,n]=r;return this.tags[e]=n,!0}case"%YAML":{if(this.yaml.explicit=!0,1!==r.length)return t(0,"%YAML directive should contain exactly one part"),!1;let[e]=r;if("1.1"===e||"1.2"===e)return this.yaml.version=e,!0;{let r=/^\d+\.\d+$/.test(e);return t(6,`Unsupported YAML version ${e}`,r),!1}}default:return t(0,`Unknown directive ${n}`,!0),!1}}tagName(e,t){if("!"===e)return"!";if("!"!==e[0])return t(`Not a valid tag: ${e}`),null;if("<"===e[1]){let r=e.slice(2,-1);return"!"===r||"!!"===r?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(">"!==e[e.length-1]&&t("Verbatim tags must end with a >"),r)}let[,r,n]=e.match(/^(.*!)([^!]*)$/s);n||t(`The ${e} tag has no suffix`);let i=this.tags[r];if(i)try{return i+decodeURIComponent(n)}catch(e){return t(String(e)),null}return"!"===r?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,r]of Object.entries(this.tags))if(e.startsWith(r))return t+s(e.substring(r.length));return"!"===e[0]?e:`!<${e}>`}toString(e){let t,r=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],a=Object.entries(this.tags);if(e&&a.length>0&&n.isNode(e.contents)){let r={};i.visit(e.contents,(e,t)=>{n.isNode(t)&&t.tag&&(r[t.tag]=!0)}),t=Object.keys(r)}else t=[];for(let[n,i]of a)("!!"!==n||"tag:yaml.org,2002:"!==i)&&(!e||t.some(e=>e.startsWith(i)))&&r.push(`%TAG ${n} ${i}`);return r.join("\n")}}o.defaultYaml={explicit:!1,version:"1.2"},o.defaultTags={"!!":"tag:yaml.org,2002:"},t.Directives=o},3409(e,t){class r extends Error{constructor(e,t,r,n){super(),this.name=e,this.code=r,this.message=n,this.pos=t}}t.YAMLError=r,t.YAMLParseError=class extends r{constructor(e,t,r){super("YAMLParseError",e,t,r)}},t.YAMLWarning=class extends r{constructor(e,t,r){super("YAMLWarning",e,t,r)}},t.prettifyError=(e,t)=>r=>{if(-1===r.pos[0])return;r.linePos=r.pos.map(e=>t.linePos(e));let{line:n,col:i}=r.linePos[0];r.message+=` at line ${n}, column ${i}`;let a=i-1,s=e.substring(t.lineStarts[n-1],t.lineStarts[n]).replace(/[\n\r]+$/,"");if(a>=60&&s.length>80){let e=Math.min(a-39,s.length-79);s="…"+s.substring(e),a-=e-1}if(s.length>80&&(s=s.substring(0,79)+"…"),n>1&&/^ *$/.test(s.substring(0,a))){let r=e.substring(t.lineStarts[n-2],t.lineStarts[n-1]);r.length>80&&(r=r.substring(0,79)+"…\n"),s=r+s}if(/[^ ]/.test(s)){let e=1,t=r.linePos[1];t?.line===n&&t.col>i&&(e=Math.max(1,Math.min(t.col-i,80-a)));let o=" ".repeat(a)+"^".repeat(e);r.message+=`:
|
|
131
144
|
|
|
132
145
|
${s}
|
|
133
146
|
${o}
|
|
@@ -140,22 +153,22 @@ ${t.indent}${u}`:u}},8143(e,t,r){var n=r(6730),i=r(6203),a=r(3202);function s({i
|
|
|
140
153
|
${c}${l}${t}`:"\n";return`${e}
|
|
141
154
|
${l}${y}`}}:function({comment:e,items:t},r,{blockItemPrefix:o,flowChars:l,itemIndent:c,onChompKeep:u,onComment:d}){let f,{indent:h,options:{commentString:p}}=r,m=Object.assign({},r,{indent:c,type:null}),g=!1,y=[];for(let e=0;e<t.length;++e){let l=t[e],u=null;if(n.isNode(l))!g&&l.spaceBefore&&y.push(""),s(r,y,l.commentBefore,g),l.comment&&(u=l.comment);else if(n.isPair(l)){let e=n.isNode(l.key)?l.key:null;e&&(!g&&e.spaceBefore&&y.push(""),s(r,y,e.commentBefore,g))}g=!1;let d=i.stringify(l,m,()=>u=null,()=>g=!0);u&&(d+=a.lineComment(d,c,p(u))),g&&u&&(g=!1),y.push(o+d)}if(0===y.length)f=l.start+l.end;else{f=y[0];for(let e=1;e<y.length;++e){let t=y[e];f+=t?`
|
|
142
155
|
${h}${t}`:"\n"}}return e?(f+="\n"+a.indentComment(p(e),h),d&&d()):g&&u&&u(),f})(e,t,r)}},3202(e,t){function r(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}t.indentComment=r,t.lineComment=(e,t,n)=>e.endsWith("\n")?r(n,t):n.includes("\n")?"\n"+r(n,t):(e.endsWith(" ")?"":" ")+n,t.stringifyComment=e=>e.replace(/^(?!$)(?: $)?/gm,"#")},5966(e,t,r){var n=r(6730),i=r(6203),a=r(3202);t.stringifyDocument=function(e,t){let r=[],s=!0===t.directives;if(!1!==t.directives&&e.directives){let t=e.directives.toString(e);t?(r.push(t),s=!0):e.directives.docStart&&(s=!0)}s&&r.push("---");let o=i.createStringifyContext(e,t),{commentString:l}=o.options;if(e.commentBefore){1!==r.length&&r.unshift("");let t=l(e.commentBefore);r.unshift(a.indentComment(t,""))}let c=!1,u=null;if(e.contents){if(n.isNode(e.contents)){if(e.contents.spaceBefore&&s&&r.push(""),e.contents.commentBefore){let t=l(e.contents.commentBefore);r.push(a.indentComment(t,""))}o.forceBlockIndent=!!e.comment,u=e.contents.comment}let t=u?void 0:()=>c=!0,d=i.stringify(e.contents,o,()=>u=null,t);u&&(d+=a.lineComment(d,"",l(u))),("|"===d[0]||">"===d[0])&&"---"===r[r.length-1]?r[r.length-1]=`--- ${d}`:r.push(d)}else r.push(i.stringify(e.contents,o));if(e.directives?.docEnd)if(e.comment){let t=l(e.comment);t.includes("\n")?(r.push("..."),r.push(a.indentComment(t,""))):r.push(`... ${t}`)}else r.push("...");else{let t=e.comment;t&&c&&(t=t.replace(/^\n+/,"")),t&&((!c||u)&&""!==r[r.length-1]&&r.push(""),r.push(a.indentComment(l(t),"")))}return r.join("\n")+"\n"}},4374(e,t){t.stringifyNumber=function({format:e,minFractionDigits:t,tag:r,value:n}){if("bigint"==typeof n)return String(n);let i="number"==typeof n?n:Number(n);if(!isFinite(i))return isNaN(i)?".nan":i<0?"-.inf":".inf";let a=Object.is(n,-0)?"-0":JSON.stringify(n);if(!e&&t&&(!r||"tag:yaml.org,2002:float"===r)&&/^-?\d/.test(a)&&!a.includes("e")){let e=a.indexOf(".");e<0&&(e=a.length,a+=".");let r=t-(a.length-e-1);for(;r-- >0;)a+="0"}return a}},4711(e,t,r){var n=r(6730),i=r(8376),a=r(6203),s=r(3202);t.stringifyPair=function({key:e,value:t},r,o,l){let c,u,d,{allNullValues:f,doc:h,indent:p,indentStep:m,options:{commentString:g,indentSeq:y,simpleKeys:b}}=r,v=n.isNode(e)&&e.comment||null;if(b){if(v)throw Error("With simple keys, key nodes cannot have comments");if(n.isCollection(e)||!n.isNode(e)&&"object"==typeof e)throw Error("With simple keys, collection cannot be used as a key value")}let w=!b&&(!e||v&&null==t&&!r.inFlow||n.isCollection(e)||(n.isScalar(e)?e.type===i.Scalar.BLOCK_FOLDED||e.type===i.Scalar.BLOCK_LITERAL:"object"==typeof e));r=Object.assign({},r,{allNullValues:!1,implicitKey:!w&&(b||!f),indent:p+m});let x=!1,_=!1,k=a.stringify(e,r,()=>x=!0,()=>_=!0);if(!w&&!r.inFlow&&k.length>1024){if(b)throw Error("With simple keys, single line scalar must not span more than 1024 characters");w=!0}if(r.inFlow){if(f||null==t)return x&&o&&o(),""===k?"?":w?`? ${k}`:k}else if(f&&!b||null==t&&w)return k=`? ${k}`,v&&!x?k+=s.lineComment(k,r.indent,g(v)):_&&l&&l(),k;x&&(v=null),w?(v&&(k+=s.lineComment(k,r.indent,g(v))),k=`? ${k}
|
|
143
|
-
${p}:`):(k=`${k}:`,v&&(k+=s.lineComment(k,r.indent,g(v)))),n.isNode(t)?(c=!!t.spaceBefore,u=t.commentBefore,d=t.comment):(c=!1,u=null,d=null,t&&"object"==typeof t&&(t=h.createNode(t))),r.implicitKey=!1,!w&&!v&&n.isScalar(t)&&(r.indentAtStart=k.length+1),_=!1,!(!y&&m.length>=2&&!r.inFlow&&!w&&n.isSeq(t))||t.flow||t.tag||t.anchor||(r.indent=r.indent.substring(2));let S=!1
|
|
144
|
-
${s.indentComment(e,r.indent)}`}""
|
|
145
|
-
${r.indent}`:"\n"===E&&d&&(E="\n\n")}else if(!w&&n.isCollection(t)){let e
|
|
146
|
-
${r.indent}`)}}else(""
|
|
147
|
-
${r}`)+"'";return t.implicitKey?n:a.foldFlowLines(n,r,a.FOLD_FLOW,s(t,!1))}function c(e,t){let r,{singleQuote:n}=t.options;if(!1===n)r=o;else{let t=e.includes('"'),i=e.includes("'");r=t&&!i?l:i&&!t?o:n?l:o}return r(e,t)}try{n=RegExp("(^|(?<!\n))\n+(?!\n|$)","g")}catch{n=/\n+(?!\n|$)/g}function u({comment:e,type:t,value:r},o,l,d){let f,h,p,m,{blockQuote:g,commentString:y,lineWidth:b}=o.options;if(!g||/\n[\t ]+$/.test(r))return c(r,o);let v=o.indent||(o.forceBlockIndent||(m=r,/^(%|---|\.\.\.)/m.test(m))?" ":""),w="literal"===g||"folded"!==g&&t!==i.Scalar.BLOCK_FOLDED&&(t===i.Scalar.BLOCK_LITERAL||!function(e,t,r){if(!t||t<0)return!1;let n=t-r,i=e.length;if(i<=n)return!1;for(let t=0,r=0;t<i;++t)if("\n"===e[t]){if(t-r>n)return!0;if(i-(r=t+1)<=n)return!1}return!0}(r,b,v.length));if(!r)return w?"|\n":">\n";for(h=r.length;h>0;--h){let e=r[h-1];if("\n"!==e&&" "!==e&&" "!==e)break}let x=r.substring(h),_=x.indexOf("\n");-1===_?f="-":r===x||_!==x.length-1?(f="+",d&&d()):f="",x&&(r=r.slice(0,-x.length),"\n"===x[x.length-1]&&(x=x.slice(0,-1)),x=x.replace(n,`$&${v}`));let k=!1,S=-1;for(p=0;p<r.length;++p){let e=r[p];if(" "===e)k=!0;else if("\n"===e)S=p;else break}let
|
|
148
|
-
${v}${c}`}return r=r.replace(/\n+/g,`$&${v}`),`|${
|
|
149
|
-
${v}${
|
|
150
|
-
${h}`);if(d){let e=e=>e.default&&"tag:yaml.org,2002:str"!==e.tag&&e.test?.test(g),{compat:r,tags:n}=t.doc.schema;if(n.some(e)||r?.some(e))return c(l,t)}return f?g:a.foldFlowLines(g,h,a.FOLD_FLOW,s(t,!1))}(h,t,r,n);default:return null}},g=m(p);if(null===g){let{defaultKeyType:e,defaultStringType:r}=t.options,n=d&&e||r;if(null===(g=m(n)))throw Error(`Unsupported default string type ${n}`)}return g}},7995(e,t,r){var n=r(6730);let i=Symbol("break visit"),a=Symbol("skip children"),s=Symbol("remove node");function o(e,t){let r=d(t);n.isDocument(e)?l(null,e.contents,r,Object.freeze([e]))===s&&(e.contents=null):l(null,e,r,Object.freeze([]))}function l(e,t,r,a){let o=f(e,t,r,a);if(n.isNode(o)||n.isPair(o))return h(e,a,o),l(e,o,r,a);if("symbol"!=typeof o){if(n.isCollection(t)){a=Object.freeze(a.concat(t));for(let e=0;e<t.items.length;++e){let n=l(e,t.items[e],r,a);if("number"==typeof n)e=n-1;else{if(n===i)return i;n===s&&(t.items.splice(e,1),e-=1)}}}else if(n.isPair(t)){a=Object.freeze(a.concat(t));let e=l("key",t.key,r,a);if(e===i)return i;e===s&&(t.key=null);let n=l("value",t.value,r,a);if(n===i)return i;n===s&&(t.value=null)}}return o}async function c(e,t){let r=d(t);n.isDocument(e)?await u(null,e.contents,r,Object.freeze([e]))===s&&(e.contents=null):await u(null,e,r,Object.freeze([]))}async function u(e,t,r,a){let o=await f(e,t,r,a);if(n.isNode(o)||n.isPair(o))return h(e,a,o),u(e,o,r,a);if("symbol"!=typeof o){if(n.isCollection(t)){a=Object.freeze(a.concat(t));for(let e=0;e<t.items.length;++e){let n=await u(e,t.items[e],r,a);if("number"==typeof n)e=n-1;else{if(n===i)return i;n===s&&(t.items.splice(e,1),e-=1)}}}else if(n.isPair(t)){a=Object.freeze(a.concat(t));let e=await u("key",t.key,r,a);if(e===i)return i;e===s&&(t.key=null);let n=await u("value",t.value,r,a);if(n===i)return i;n===s&&(t.value=null)}}return o}function d(e){return"object"==typeof e&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function f(e,t,r,i){return"function"==typeof r?r(e,t,i):n.isMap(t)?r.Map?.(e,t,i):n.isSeq(t)?r.Seq?.(e,t,i):n.isPair(t)?r.Pair?.(e,t,i):n.isScalar(t)?r.Scalar?.(e,t,i):n.isAlias(t)?r.Alias?.(e,t,i):void 0}function h(e,t,r){let i=t[t.length-1];if(n.isCollection(i))i.items[e]=r;else if(n.isPair(i))"key"===e?i.key=r:i.value=r;else if(n.isDocument(i))i.contents=r;else{let e=n.isAlias(i)?"alias":"scalar";throw Error(`Cannot replace node with ${e} parent`)}}o.BREAK=i,o.SKIP=a,o.REMOVE=s,c.BREAK=i,c.SKIP=a,c.REMOVE=s,t.visit=o,t.visitAsync=c},8927(e,t,r){r.d(t,{CN:()=>h,BC:()=>g,Ie:()=>A,pb:()=>N,i8:()=>S,g9:()=>k,Uk:()=>O,Ts:()=>p,CZ:()=>b,ET:()=>v,HV:()=>x,Tj:()=>T,YW:()=>m,of:()=>C,jB:()=>M,TS:()=>P,di:()=>E,KC:()=>I});var n=r(8036),i=r(1044),a=r(4650);let s=e=>e.length>0;var o=r(8496),l=r(3833),c=r(6364),u=r(8099),d=r(995);let f=globalThis.Array,h=e=>new f(e),p=e=>f.isArray(e)?e:f.from(e);u.Wo,l.toArray;let m=(0,a.XY)(2,(e,{onEmpty:t,onNonEmpty:r})=>v(e)?r(e):t()),g=(0,a.XY)(2,(e,t)=>[...e,t]),y=(0,a.XY)(2,(e,t)=>p(e).concat(p(t)));f.isArray;let b=s,v=s,w=(0,a.XY)(2,(e,t)=>{let r=Math.floor(t);if(r<0||r>=e.length)throw Error(`Index out of bounds: ${r}`);return e[r]})(0),x=e=>v(e)?l.some(_(e)):l.none(),_=e=>e[e.length-1],k=(0,a.XY)(2,(e,t)=>{let r=0;for(let n of e){if(t(n,r))return l.some(r);r++}return l.none()}),S=o.i8,O=(0,a.XY)(2,(e,t)=>{let r=p(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()}),E=(0,a.XY)(2,(e,t)=>{let r=f.from(e);return r.sort(t),r}),$=(0,a.XY)(3,(e,t,r)=>{let n=p(e),i=p(t);return v(n)?v(i)?j(r)(y(n,i)):n:i}),I=(0,a.XY)(2,(e,t)=>$(e,t,n.jI())),A=()=>[],C=e=>[e],T=(0,a.XY)(2,(e,t)=>e.map(t)),N=(0,a.XY)(2,(e,t)=>{let r=p(e),n=[];for(let e=0;e<r.length;e++)t(r[e],e)&&n.push(r[e]);return n}),M=(0,a.XY)(2,(e,t)=>{let r=[],n=[],i=0;for(let a of e){let e=t(a,i++);d.oJ(e)?n.push(e.success):r.push(e.failure)}return[r,n]}),P=(0,a.XY)(3,(e,t,r)=>p(e).reduce((e,t,n)=>r(e,t,n),t));c.O3,i.O3;let j=(0,a.XY)(2,(e,t)=>{let r=p(e);if(v(r)){let e=[w(r)];for(let n of r.slice(1))e.every(e=>!t(n,e))&&e.push(n);return e}return[]})},631(e,t,r){var n=r(8036),i=r(1044),a=r(4650),s=r(4450),o=r(6400),l=r(3833),c=r(6364),u=r(9138),d=r(5369);let f=/^[+-]?\d+$/,h="~effect/BigDecimal",p={[h]:h,[s.HR](){let e=k(this);return s.kg(s.tW(e.value),s.ai(e.scale))},[n.HR](e){return m(e)&&T(this,e)},toString(){return`BigDecimal(${N(this)})`},toJSON(){return{_id:"BigDecimal",value:String(this.value),scale:this.scale}},[o.FX](){return this.toJSON()},pipe(){return(0,u.tT)(this,arguments)}},m=e=>(0,d.i5)(e,h),g=(e,t)=>{let r=Object.create(p);return r.value=e,r.scale=t,r},y=(e,t)=>{if(e!==b&&e%x===b)throw RangeError("Value must be normalized");let r=g(e,t);return r.normalized=r,r},b=BigInt(0),v=BigInt(1),w=BigInt(-1),x=BigInt(10),_=y(b,0),k=e=>{if(void 0===e.normalized)if(e.value===b)e.normalized=_;else{let t=`${e.value}`,r=0;for(let e=t.length-1;e>=0;e--)if("0"===t[e])r++;else break;0===r&&(e.normalized=e);let n=BigInt(t.substring(0,t.length-r)),i=e.scale-r;e.normalized=y(n,i)}return e.normalized},S=(0,a.XY)(2,(e,t)=>t>e.scale?g(e.value*x**BigInt(t-e.scale),t):t<e.scale?g(e.value/x**BigInt(e.scale-t),t):e),O=(0,a.XY)(2,(e,t)=>t.value===b?e:e.value===b?t:e.scale>t.scale?g(S(t,e.scale).value+e.value,e.scale):e.scale<t.scale?g(S(e,t.scale).value+t.value,t.scale):g(e.value+t.value,e.scale)),E=c.L8((e,t)=>{let r=c.wN(A(e),A(t));return 0!==r?r:e.scale>t.scale?c.Qw(e.value,S(t,e.scale).value):e.scale<t.scale?c.Qw(S(e,t.scale).value,t.value):c.Qw(e.value,t.value)}),$=c.hl(E),I=c.yJ(E),A=e=>e.value===b?0:e.value<b?-1:1,C=i.L8((e,t)=>e.scale>t.scale?S(t,e.scale).value===e.value:e.scale<t.scale?S(e,t.scale).value===t.value:e.value===t.value),T=(0,a.XY)(2,(e,t)=>C(e,t)),N=e=>{let t,r,n=k(e);if(Math.abs(n.scale)>=16)return M(n);let i=n.value<b,a=i?`${n.value}`.substring(1):`${n.value}`;if(n.scale>=a.length)t="0",r="0".repeat(n.scale-a.length)+a;else{let e=a.length-n.scale;if(e>a.length){let n=e-a.length;t=`${a}${"0".repeat(n)}`,r=""}else r=a.slice(e),t=a.slice(0,e)}let s=""===r?t:`${t}.${r}`;return i?`-${s}`:s},M=e=>{if(P(e))return"0e+0";let t=k(e),r=`${(t.value<b?g(-t.value,t.scale):t).value}`,n=r.slice(0,1),i=r.slice(1),a=`${j(t)?"-":""}${n}`;""!==i&&(a+=`.${i}`);let s=i.length-t.scale;return`${a}e${s>=0?"+":""}${s}`},P=e=>e.value===b,j=e=>e.value<b,D=e=>m(e[0]),U=(0,a.XY)(D,(e,t=0)=>e.scale<=t?e:g(e.value/x**BigInt(e.scale-t),t)),F=(0,a.XY)(D,(e,t=0)=>{let r=U(e,t);return e.value>b&&$(r,e)?O(r,g(v,t)):r}),R=(0,a.XY)(D,(e,t=0)=>{let r=U(e,t);return j(e)&&I(r,e)?O(r,g(w,t)):r});r.d(t,{},{GP:N,L8:g,RI:R,hs:S,mk:F,pH:E,rs:C,s5:m,sH:e=>{let t,r,n,i;if(""===e)return l.some(_);let a=e.search(/[eE]/);if(-1!==a){let n=e.slice(a+1);if(t=e.slice(0,a),r=Number(n),""===t||!Number.isSafeInteger(r)||!f.test(n))return l.none()}else t=e,r=0;let s=t.search(/\./);if(-1!==s){let e=t.slice(0,s),r=t.slice(s+1);n=`${e}${r}`,i=r.length}else n=t,i=0;if(!f.test(n))return l.none();let o=i-r;return Number.isSafeInteger(o)?l.some(g(BigInt(n),o)):l.none()}})},8543(e,t,r){var n=r(8433),i=r(1136);n.PX,n.B4,n.Aj,n.Wg;let a=n.lC;n.Xb,n.ik,n.b5,n.DH;let s=n.OE;n.Iu,i.nIy,i.ORc;let o=i.nn5,l=i.O$X;i.h2c;let c=i.ReC;i.myX,i.QE5;let u=i.khU,d=i.L$u;i.gpn,i.k7S,i.BbX;let f=i.prj;i.tU5,i.h74,i.Bou,i.RJ6;let h=i.GyP;n.PW,n.qB,n.Xm;let p=n.$L;n.q_;let m=n.RS,g=n.Vw;i.DQo,i.c8t,i.MUS,i.t8c,i._y;let y=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:p,Bk:b,L$:d,RS:m,Tj:l,Vw:g,fJ:s,iw:c,j9:h,kh:u,lC:a,nn:o,pr:f,qw:y})},190(e,t,r){var n=r(1136);n.a1U,n.RKA;let i=n.Rud;n.s0X,r.d(t,{},{Ru:i})},8619(e,t,r){var n=r(3267),i=r(8036),a=r(4650),s=r(4450),o=r(8433),l=r(3628),c=r(3833),u=r(5369);let d="~effect/Context/Service",f=function(){let e=(0,l.jt)();(0,l.ft)(2);let t=Error();(0,l.ft)(e);let r=function(){};return(Object.setPrototypeOf(r,h),Object.defineProperty(r,"stack",{get:()=>t.stack}),arguments.length>0)?(r.key=arguments[0],arguments[1]?.defaultValue&&(r[p]=p,r.defaultValue=arguments[1].defaultValue),r):function(e,t){return r.key=e,t?.make&&(r.make=t.make),r}},h={[d]:d,...n.b({label:"Service",evaluate(e){return(0,o.xt)(S(e.context,this))}}),toJSON(){return{_id:"Service",key:this.key,stack:this.stack}},of:e=>e,context(e){return w(this,e)},use(e){return(0,o.R6)(t=>e(S(t.context,this)))},useSync(e){return(0,o.R6)(t=>(0,o.xt)(e(S(t.context,this))))}},p="~effect/Context/Reference",m="~effect/Context",g=e=>{let t=Object.create(y);return t.mapUnsafe=e,t.mutable=!1,t},y={...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(!b(e)||this.mapUnsafe.size!==e.mapUnsafe.size)return!1;for(let t of this.mapUnsafe.keys())if(!e.mapUnsafe.has(t)||!i.aI(this.mapUnsafe.get(t),e.mapUnsafe.get(t)))return!1;return!0},[s.HR](){return s.ai(this.mapUnsafe.size)}},b=e=>(0,u.i5)(e,m),v=g(new Map),w=(e,t)=>g(new Map([[e.key,t]])),x=(0,a.XY)(3,(e,t,r)=>C(e,e=>{e.set(t.key,r)})),_=(0,a.XY)(2,(e,t)=>e.mapUnsafe.get(t.key)),k=(0,a.XY)(2,(e,t)=>{if(!e.mapUnsafe.has(t.key)){if(p in t)return E(t);throw $(t)}return e.mapUnsafe.get(t.key)}),S=k,O="~effect/Context/defaultValue",E=e=>O in e?e[O]:e[O]=e.defaultValue(),$=e=>{let t=Error(`Service not found${e.key?`: ${String(e.key)}`:""}`);if(e.stack){let r=e.stack.split("\n");if(r.length>2){let e=r[2].match(/at (.*)/);e&&(t.message=t.message+` (defined at ${e[1]})`)}}if(t.stack){let e=t.stack.split("\n");e.splice(1,3),t.stack=e.join("\n")}return t},I=(0,a.XY)(2,(e,t)=>e.mapUnsafe.has(t.key)?c.some(e.mapUnsafe.get(t.key)):(0,u.i5)(t,p)?c.some(E(t)):c.none()),A=(0,a.XY)(2,(e,t)=>0===e.mapUnsafe.size?t:0===t.mapUnsafe.size?e:C(e,e=>{t.mapUnsafe.forEach((t,r)=>e.set(r,t))})),C=(e,t)=>{if(e.mutable)return t(e.mapUnsafe),e;let r=new Map(e.mapUnsafe);return t(r),g(r)};r.d(t,{},{Ie:()=>v,Jt:S,L8:w,LZ:g,Or:f,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 g(t)},WQ:x,Y6:_,aE:b,fp:k,h1:A,kA:(e,t)=>e.mapUnsafe.has(t.key)?e.mapUnsafe.get(t.key):E(t),kl:f,om:I})},2718(e,t,r){var n=r(8433),i=r(9138),a=r(5369);let s=class extends i.Xs{constructor(e){super(),e&&Object.assign(this,e)}};function o(){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 l=n.$D,c=n.rN;r.d(t,{},{$D:l,Ij:()=>new Proxy({},{get:(e,t,r)=>"$is"===t?a.$J:"$match"===t?o:e=>({...e,_tag:t})}),Xs:s,rN:c})},4705(e,t,r){r.d(t,{rs:()=>ef,pH:()=>eh,dv:()=>eE,Rd:()=>e$,tn:()=>ep,Ar:()=>es,kQ:()=>eo,rg:()=>ec,lU:()=>el,rr:()=>eu,Ry:()=>ed,L8:()=>eg,MO:()=>ey,TT:()=>em,yF:()=>eS,Xy:()=>eO,yT:()=>eb,ez:()=>e_,y3:()=>ex,k9:()=>ev,ko:()=>ew,xV:()=>ek}),r(8619);var n=r(4650),i=r(8543),a=r(190),s=(r(2302),r(8036)),o=r(1044),l=r(4450),c=r(6400),u=r(3833),d=r(6364),f=r(9138),h=r(5369);r(1136);let p="~effect/time/DateTime",m="~effect/time/DateTime/TimeZone",g={[p]:p,pipe(){return(0,f.tT)(this,arguments)},[c.FX](){return this.toString()},toJSON(){return X(this).toJSON()}},y={...g,_tag:"Utc",[l.HR](){return l.ai(this.epochMilliseconds)},[s.HR](e){return k(e)&&"Utc"===e._tag&&this.epochMilliseconds===e.epochMilliseconds},toString(){return`DateTime.Utc(${X(this).toJSON()})`}},b={...g,_tag:"Zoned",[l.HR](){return l.kg(l.ai(this.epochMilliseconds))(l.tW(this.zone))},[s.HR](e){return k(e)&&"Zoned"===e._tag&&this.epochMilliseconds===e.epochMilliseconds&&s.aI(this.zone,e.zone)},toString(){return`DateTime.Zoned(${ea(this)})`}},v={[m]:m,[c.FX](){return this.toString()}},w={...v,_tag:"Named",[l.HR](){return l.Yj(`Named:${this.id}`)},[s.HR](e){return O(e)&&"Named"===e._tag&&this.id===e.id},toString(){return`TimeZone.Named(${this.id})`},toJSON(){return{_id:"TimeZone",_tag:"Named",id:this.id}}},x={...v,_tag:"Offset",[l.HR](){return l.Yj(`Offset:${this.offset}`)},[s.HR](e){return O(e)&&"Offset"===e._tag&&this.offset===e.offset},toString(){return`TimeZone.Offset(${z(this.offset)})`},toJSON(){return{_id:"TimeZone",_tag:"Offset",offset:this.offset}}},_=(e,t,r)=>{let n=Object.create(b);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},k=e=>h.i5(e,p),S=e=>k(e[0]),O=e=>h.i5(e,m),E=e=>"Zoned"===e._tag,$=o.L8((e,t)=>e.epochMilliseconds===t.epochMilliseconds),I=d.L8((e,t)=>e.epochMilliseconds<t.epochMilliseconds?-1:+(e.epochMilliseconds>t.epochMilliseconds)),A=e=>{let t=Object.create(y);return t.epochMilliseconds=e,Object.defineProperty(t,"partsUtc",{value:void 0,enumerable:!1,writable:!0}),t},C=e=>{let t=e.getTime();if(Number.isNaN(t))throw new i.qw("Invalid date");return A(t)},T=e=>{if(k(e))return e;if(e instanceof Date)return C(e);if("object"==typeof e){if("epochMilliseconds"in e)return A(e.epochMilliseconds);let t=new Date(0);return V(t,e),C(t)}return"string"!=typeof e||N(e)?C(new Date(e)):C(new Date(e+"Z"))},N=e=>/Z|GMT|[+-]\d{2}$|[+-]\d{2}:?\d{2}$|\]$/.test(e),M=(e,t)=>{let r,n=t?.timeZone;if(void 0===n&&k(e)&&E(e))return e;let a=T(e);if(a.epochMilliseconds<-86399999568e5||a.epochMilliseconds>86399999496e5)throw RangeError(`Epoch millis out of range: ${a.epochMilliseconds}`);if(void 0===n&&"object"==typeof e&&"timeZoneId"in e&&(n=e.timeZoneId),void 0===n)r=L(-60*new Date(a.epochMilliseconds).getTimezoneOffset()*1e3);else if(O(n))r=n;else if("number"==typeof n)r=L(n);else{let e=q(n);if(u.isNone(e))throw new i.qw(`Invalid time zone: ${n}`);r=e.value}return t?.adjustForTimeZone!==!0?_(a.epochMilliseconds,r,a.partsUtc):G(a.epochMilliseconds,r,t?.disambiguation??"compatible")},P=u.liftThrowable(M),j=u.liftThrowable(T),D=/^(.{17,35})\[(.+)\]$/;a.Ru,a.Ru,(e,t,r)=>r?.adjustForTimeZone===!0?G(e.epochMilliseconds,t,r?.disambiguation??"compatible"):_(e.epochMilliseconds,t,e.partsUtc);let U=new Map,F={day:"numeric",month:"numeric",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"longOffset",fractionalSecondDigits:3,hourCycle:"h23"},R=e=>{if(U.has(e))return U.get(e);try{var t=new Intl.DateTimeFormat("en-US",{...F,timeZone:e});let r=t.resolvedOptions().timeZone;if(U.has(r))return U.get(r);let n=Object.create(w);return n.id=r,n.format=t,U.set(r,n),n}catch{throw new i.qw(`Invalid time zone: ${e}`)}},L=e=>{let t=Object.create(x);return t.offset=e,t},B=u.liftThrowable(R),Y=/^(?:GMT|[+-])/,q=e=>{if(Y.test(e)){let t=Q(e);return null===t?u.none():u.some(L(t))}return B(e)},X=e=>new Date(e.epochMilliseconds),W=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),Number(t[6].value)),e.adjustedEpochMilliseconds=r.getTime(),r},J=e=>W(e).getTime()-K(e),z=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")}`},K=e=>e.epochMilliseconds,V=(e,t)=>{if(void 0!==t.year&&e.setUTCFullYear(t.year),void 0!==t.month&&e.setUTCMonth(t.month-1),void 0!==t.day&&e.setUTCDate(t.day),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)},G=(e,t,r)=>{if("Offset"===t._tag)return _(e-t.offset,t);let n=Z(e-864e5,e,t),i=Z(e+864e5,e,t);if(n===i)return _(e-n,t);let a=n-i;if(n<i){if(Z(e-i,e,t)===i)return _(e-i,t);let a=_(e-n,t);if(e!==W(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 _(e-i,t)}return a}if(Z(e-n,e,t)===n){if("earlier"===r||"compatible"===r||Z(e-n+a,e+a,t)===n)return _(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 _(e-i,t)},H=/([+-])(\d{2}):(\d{2})$/,Q=e=>{let t=H.exec(e);if(null===t)return null;let[,r,n,i]=t;return("+"===r?1:-1)*(60*Number(n)+Number(i))*6e4},Z=(e,t,r)=>{let n=r.format.formatToParts(e).find(e=>"timeZoneName"===e.type)?.value??"";if("GMT"===n)return 0;let i=Q(n);return null===i?J(_(t,r)):i},ee=(0,n.XY)(S,(e,t,r)=>{if("Utc"===e._tag){let r=X(e);return t(r),A(r.getTime())}let n=new Date(W(e).getTime());return t(n),G(n.getTime(),e.zone,r?.disambiguation??"compatible")}),et=((e,t)=>et(e,e=>{let r=new Date(e);return t(r),r.getTime()}),(0,n.XY)(2,(e,t)=>{let r=t(K(e));return"Utc"===e._tag?A(r):_(r,e.zone)})),er=((e,t)=>t(W(e)),(0,n.XY)(2,(e,t)=>t(X(e)))),en=(e,t)=>{e.setTime(e.getTime()+t)},ei=((e,t)=>ee(e,e=>{if(t.milliseconds&&en(e,t.milliseconds),t.seconds&&en(e,1e3*t.seconds),t.minutes&&en(e,60*t.minutes*1e3),t.hours&&en(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=W(e);return"Utc"===e._tag?t.toISOString():`${t.toISOString().slice(0,-1)}${z(J(e))}`}),ea=e=>"Offset"===e.zone._tag?ei(e):`${ei(e)}[${e.zone.id}]`;r(5089);let es=k,eo=O,el=e=>O(e)&&"Offset"===e._tag,ec=e=>O(e)&&"Named"===e._tag,eu=e=>"Utc"===e._tag,ed=E,ef=$,eh=I,ep=C,em=M,eg=j,ey=e=>{let t=D.exec(e);if(null===t){let t=Q(e);return null!==t?P(e,{timeZone:t}):u.none()}let[,r,n]=t;return P(r,{timeZone:n})},eb=e=>A(e.epochMilliseconds),ev=R,ew=L,ex=B,e_=q,ek=e=>"Offset"===e._tag?z(e.offset):e.id,eS=X,eO=K,eE=e=>X(e).toISOString(),e$=ea},3717(e,t,r){var n=r(4650),i=r(1136),a=r(9138);let s={"~effect/Deferred":{_A:n.D_,_E:n.D_},pipe(){return(0,a.tT)(this,arguments)}},o=(0,n.XY)(2,(e,t)=>i.OH5(()=>l(e,t))),l=(e,t)=>{if(e.effect)return!1;if(e.effect=t,e.resumes){for(let r=0;r<e.resumes.length;r++)e.resumes[r](t);e.resumes=void 0}return!0};r.d(t,{},{$L:e=>i.OH5(()=>void 0!==e.effect),$w:l,LZ:()=>{let e=Object.create(s);return e.resumes=void 0,e.effect=void 0,e},Tx:e=>i.E2r(t=>e.effect?t(e.effect):(e.resumes??=[],e.resumes.push(t),i.OH5(()=>{let r=e.resumes.indexOf(t);e.resumes.splice(r,1)}))),Vw:o})},2302(e,t,r){var n=r(8036),i=r(4650),a=r(4450),s=r(6400),o=r(3833),l=r(6364),c=r(9138),u=r(5369);let d="~effect/time/Duration",f=BigInt(0),h=BigInt(1),p=BigInt(1e3),m=e=>BigInt(e<0?Math.ceil(e-.5):Math.floor(e+.5)),g=(e,t)=>e.includes(".")?m(Number(e)*Number(t)):BigInt(e)*t,y=/^(-?\d+(?:\.\d+)?)\s+(nanos?|micros?|millis?|seconds?|minutes?|hours?|days?|weeks?)$/,b=e=>{switch(typeof e){case"number":return T(e);case"bigint":return C(e);case"string":{if("Infinity"===e)return I;if("-Infinity"===e)return A;let t=y.exec(e);if(!t)break;let[r,n,i]=t;if("nano"===i||"nanos"===i)return C(g(n,h));if("micro"===i||"micros"===i)return C(g(n,p));let a=Number(n);switch(i){case"milli":case"millis":return T(a);case"second":case"seconds":return N(a);case"minute":case"minutes":return M(a);case"hour":case"hours":return P(a);case"day":case"days":return j(a);case"week":case"weeks":return D(a)}break}case"object":{if(null===e)break;if(d in e)return e;if(Array.isArray(e)){if(2!==e.length||!e.every(u.Et))return v(e);if(Number.isNaN(e[0])||Number.isNaN(e[1]))return $;if(e[0]===-1/0||e[1]===-1/0)return A;if(e[0]===1/0||e[1]===1/0)return I;return O(m(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(m(1e6*t+(e.microseconds??0)*1e3+(e.nanoseconds??0)))}}return v(e)},v=e=>{throw Error(`Invalid Input: ${e}`)},w=o.liftThrowable(b),x={_tag:"Millis",millis:0},_={_tag:"Infinity"},k={_tag:"NegativeInfinity"},S={[d]:d,[a.HR](){return a.QK(this.value)},[n.HR](e){return E(e)&&X(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,c.tT)(this,arguments)}},O=e=>{let t=Object.create(S);return"number"==typeof e?isNaN(e)||0===e||Object.is(e,-0)?t.value=x:Number.isFinite(e)?Number.isInteger(e)?t.value={_tag:"Millis",millis:e}:t.value={_tag:"Nanos",nanos:m(1e6*e)}:t.value=e>0?_:k:e===f?t.value=x:t.value={_tag:"Nanos",nanos:e},t},E=e=>(0,u.i5)(e,d),$=O(0),I=O(1/0),A=O(-1/0),C=e=>O(e),T=e=>O(e),N=e=>O(1e3*e),M=e=>O(6e4*e),P=e=>O(36e5*e),j=e=>O(864e5*e),D=e=>O(6048e5*e),U=e=>{let t=b(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 m(1e6*t.value.millis)}},F=o.liftThrowable(U),R=(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)()}}),L=(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(U(e),t.value.nanos):r.onNanos(e.value.nanos,U(t))),B=l.L8((e,t)=>L(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})),Y=(e,t)=>L(e,t,{onMillis:(e,t)=>e===t,onNanos:(e,t)=>e===t,onInfinity:(e,t)=>e.value._tag===t.value._tag}),q=l.bi(B),X=(0,i.XY)(2,(e,t)=>Y(e,t));r.d(t,{},{MI:e=>"Infinity"!==e.value._tag&&"NegativeInfinity"!==e.value._tag,Tn:I,bN:b,bi:q,cF:C,kE:e=>R(b(e),{onMillis:i.D_,onNanos:e=>Number(e)/1e6,onInfinity:()=>1/0,onNegativeInfinity:()=>-1/0}),lX:w,n$:E,ne:T,qv:A,rs:Y,tb:F,v_:$})},7720(e,t,r){r.d(t,{Q56:()=>ex,jGc:()=>e_,U9h:()=>ek,Q7R:()=>x,hgn:()=>q,swY:()=>eq,Muk:()=>eT,as:()=>V,NLW:()=>G,E2r:()=>N,MfU:()=>H,Tyx:()=>ee,osR:()=>et,KuX:()=>Q,loE:()=>Z,RKA:()=>eB,_32:()=>eN,_r7:()=>eX,yeE:()=>eS,NS5:()=>z,fJG:()=>j,ATB:()=>D,pVV:()=>U,qIB:()=>Y,Ab9:()=>eK,fn:()=>eL,D9k:()=>eR,vCS:()=>eV,jJl:()=>_,i4r:()=>eC,ar0:()=>eP,x6Z:()=>ej,yUA:()=>B,JkU:()=>P,XeO:()=>eo,GaK:()=>e$,yw5:()=>w,vVN:()=>eY,TjK:()=>K,q7Y:()=>ez,jkJ:()=>eW,xm_:()=>er,Z9x:()=>eJ,YWq:()=>ed,khu:()=>ef,tvg:()=>eh,ZmZ:()=>M,S5A:()=>eO,cfM:()=>eE,uKv:()=>J,QgK:()=>en,ivC:()=>S,Gte:()=>ep,PpN:()=>em,PfK:()=>ey,KT6:()=>eu,Ket:()=>W,L5P:()=>es,MY7:()=>eD,eJC:()=>eU,lKS:()=>eF,z8E:()=>eb,P1j:()=>ev,Pxi:()=>ew,Nav:()=>eg,yy4:()=>ec,PyW:()=>E,lwU:()=>$,nGE:()=>I,DYE:()=>A,OH5:()=>C,Mim:()=>X,dGm:()=>ea,sFT:()=>ei,mgX:()=>el,SvU:()=>R,$mh:()=>O,rfi:()=>eI,FcF:()=>eA,rIH:()=>T,iMI:()=>k,R6R:()=>L,fRP:()=>eM});var n=r(4650),i=r(8433),a=r(1136),s=r(8619);r(995);var o=r(3587),l=r(5089);let c=(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 u=r(3833),d=r(4505),f=r(3537);(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?u.none():u.some(n)))});let h=(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 d.m8(s,e=>(0,f.s)(()=>r(n,e)))})),p=(0,n.XY)(2,(e,t)=>h(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),b=r(8036).Xq({_E:e=>e,_A:e=>e,_R:e=>e});({...i.In,"~effect/Request":b}),r(8469);var v=r(3864);i.$n;let w=i.yw,x=a.Q7R;a.jBG,a.tfT,a.i8i,a.kAe;let _=a.jJl,k=a.iMI,S=a.ivC,O=a.$mh,E=a.PyW,$=a.lwU,I=a.nGE,A=a.DYE,C=a.OH5,T=a.rIH;a.Vxk;let N=a.E2r,M=a.ZmZ;a.Do,a.JrD,a.uVU,a.oIE;let P=a.JkU,j=a.fJG;a.gOk;let D=a.ATB,U=a.pVV,F=a.F_Q,R=a.SvU;a.m9E,a.KN3;let L=i.R6,B=a.yUA;a.sVm,a.pkL,a.bJ;let Y=a.qIB;a.Bqz;let q=a.hgn,X=a.Mim,W=a.Ket,J=a.uKv,z=a.NS5,K=a.TjK,V=a.as;a.Xx$;let G=a.NLW;a.UUz,a.yU6,a.OYO;let H=a.h_t,Q=a.KuX,Z=a.loE;a.AXC,a.zt4,a.scW;let ee=a.Tyx;a.Fig,a.XWm;let et=a.osR;a.U9Y,a.sJf,a.rNk;let er=a.xm_;a.UcN;let en=a.QgK,ei=a.sFT;a.k$L;let ea=a.dGm;a.cA6,a.bKC,a.nAi,a.u4Y;let es=p;a._Sg;let eo=a.XeO;a.GrF,a.$$g,a.DM4,a.Dd,a.wRz,a.D52;let el=a.mgX;a.cbG;let ec=a.yy4;a.ayu,a.Vdx,a.FfP,a.O4F;let eu=a.KT6;a.pbD,a.x1Q,a.E8K,a.Pm0,a.VtY,a.W$I,a.ahH,a.z7s;let ed=a.YWq;a.G$Q,a.D$$,a.NZb,a.wR5;let ef=a.khu,eh=a.tvg;a.N6O,a.oJd,a._OA,a.sxi;let ep=c,em=a.PpN;a.oao,a.euC;let eg=a.Nav;a.r_d,a.bUZ;let ey=a.PfK;a.c7E,a.KyM;let eb=a.z8E,ev=a.P1j,ew=a.Pxi,ex=a.Q56;a.N24;let e_=a.jGc,ek=a.U9h,eS=a.yeE,eO=a.S5A;a.BeE,a.iKM,a.r7h;let eE=a.cfM;a.fGe,a.uRq,a.PO3,a.Rgn,a.CJw;let e$=a.GaK;a.Inz,a.nAr;let eI=a.rfi,eA=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 eN=a._32;a.Wj8,a.Fu6,a.WbR,a.A_r,a.Z98,a.Rd$,a.gvr;let eM=a.fRP;a.zr8,a.hq,a.zhn;let eP=a.ar0,ej=a.x6Z;a.yxg,a.PCg,a.pEE,a.ABT;let eD=a.MY7,eU=a.eJC;a.lSz,a.bPG,a.pR5,a.v2Q,a.NpQ,a.jqV,a.HZF,a.lE;let eF=a.lKS;a.rfH;let eR=a.D9k,eL=a.fn,eB=a.RKA;a.lIX;let eY=a.lIX("Error"),eq=(0,n.XY)(e=>w(e[0]),(e,...t)=>a.bUZ(e,v.iL,e=>{let r={...e};return 1===t.length?Object.assign(r,t[0]):r[t[0]]=t[1],r}));a.gsV;let eX=(e,t,r)=>(...n)=>N(i=>{try{e(...n,(e,r)=>{e?i(j(t?t(e,n):e)):i(E(r))})}catch(e){i(r?j(r(e,n)):F(e))}}),eW=a.jkJ,eJ=a.Z9x,ez=a.q7Y,eK=a.Ab9;a.UVN;let eV=a.vCS},3267(e,t,r){var n=r(8433);r.d(t,{},{b:e=>(0,n.yj)({op:e.label,[n._3]:e.evaluate})})},8983(e,t,r){var n=r(2718),i=r(995);let a="~effect/encoding/EncodingError";class s extends n.rN("EncodingError"){[a]=a}let o=e=>{let t=f(e),r=t.length;if(r%4!=0)return i.fJ(new s({kind:"Decode",module:"Base64",input:t,message:`Length must be a multiple of 4, but is ${r}`}));let n=t.indexOf("=");if(-1!==n&&(n<r-2||n===r-2&&"="!==t[r-1]))return i.fJ(new s({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("="),n=new Uint8Array(r/4*3-e);for(let e=0,i=0;e<r;e+=4,i+=3){let r=p(t.charCodeAt(e))<<18|p(t.charCodeAt(e+1))<<12|p(t.charCodeAt(e+2))<<6|p(t.charCodeAt(e+3));n[i]=r>>16,n[i+1]=r>>8&255,n[i+2]=255&r}return i.Py(n)}catch(e){return i.fJ(new s({kind:"Decode",module:"Base64",input:t,message:e instanceof Error?e.message:"Invalid input"}))}},l=e=>{let t=f(e),r=t.length;if(r%4==1)return i.fJ(new s({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 i.fJ(new s({module:"Base64Url",kind:"Decode",input:t,message:"Invalid input"}));let n=r%4==2?`${t}==`:r%4==3?`${t}=`:t;return o(n=n.replace(/-/g,"+").replace(/_/g,"/"))},c=e=>{let t=new TextEncoder().encode(e);if(t.length%2!=0)return i.fJ(new s({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=v(t[2*n]),i=v(t[2*n+1]);r[n]=e<<4|i}return i.Py(r)}catch(t){return i.fJ(new s({module:"Hex",kind:"Decode",input:e,message:t instanceof Error?t.message:"Invalid input"}))}},u=new TextEncoder,d=new TextDecoder,f=e=>e.replace(/[\n\r]/g,""),h=e=>{let t,r=e.length,n="";for(t=2;t<r;t+=3)n+=m[e[t-2]>>2],n+=m[(3&e[t-2])<<4|e[t-1]>>4],n+=m[(15&e[t-1])<<2|e[t]>>6],n+=m[63&e[t]];return t===r+1&&(n+=m[e[t-2]>>2],n+=m[(3&e[t-2])<<4],n+="=="),t===r&&(n+=m[e[t-2]>>2],n+=m[(3&e[t-2])<<4|e[t-1]>>4],n+=m[(15&e[t-1])<<2],n+="="),n};function p(e){if(e>=g.length)throw TypeError(`Invalid character ${String.fromCharCode(e)}`);let t=g[e];if(255===t)throw TypeError(`Invalid character ${String.fromCharCode(e)}`);return t}let m=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9","+","/"],g=[255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,62,255,255,255,63,52,53,54,55,56,57,58,59,60,61,255,255,255,0,255,255,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,255,255,255,255,255,255,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],y=e=>h(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_"),b=e=>{let t="";for(let r=0;r<e.length;++r)t+=w[e[r]];return t},v=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")},w=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];r.d(t,{},{$T:e=>i.Tj(o(e),e=>d.decode(e)),$X:l,DX:e=>"string"==typeof e?y(u.encode(e)):y(e),EF:c,UD:e=>i.Tj(l(e),e=>d.decode(e)),WG:e=>"string"==typeof e?h(u.encode(e)):h(e),mU:e=>"string"==typeof e?b(u.encode(e)):b(e),xQ:e=>i.Tj(c(e),e=>d.decode(e)),y4:o})},8036(e,t,r){var n,i,a,s=r(4450),o=r(6516),l=r(5369);let c="~effect/interfaces/Equal";function u(){return 1==arguments.length?e=>d(e,arguments[0]):d(arguments[0],arguments[1])}function d(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||o.J.has(e)||o.J.has(t))&&function(e,t,r){let n=m.get(e);if(n){if(n.has(t))return n.get(t)}else n=new WeakMap,m.set(e,n);let i=r(e,t);n.set(t,i);let a=m.get(t);return a||(a=new WeakMap,m.set(t,a)),a.set(e,i),i}(e,t,p))}let f=new WeakSet,h=new WeakSet;function p(e,t){if(s.tW(e)!==s.tW(t))return!1;if(e instanceof Date)return t instanceof Date&&e.toISOString()===t.toISOString();if(e instanceof RegExp)return t instanceof RegExp&&e.toString()===t.toString();let r=b(e),n=b(t);if(r!==n)return!1;let i=r&&n;return("function"!=typeof e||!!i)&&function(e,t,r){let n=f.has(e),i=h.has(t);if(n&&i)return!0;if(n||i)return!1;f.add(e),h.add(t);let a=r();return f.delete(e),h.delete(t),a}(e,t,()=>{if(i)return e[c](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(!d(e[r],t[r]))return!1;return!0}(e,t);if(ArrayBuffer.isView(e))return!!ArrayBuffer.isView(t)&&e.byteLength===t.byteLength&&function(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}(e,t);if(e instanceof Map)return t instanceof Map&&e.size===t.size&&g(e,t);if(e instanceof Set)return t instanceof Set&&e.size===t.size&&y(e,t);var r=e,n=t;let a=(0,o.X)(r),s=(0,o.X)(n);if(a.size!==s.size)return!1;for(let e of a)if(!s.has(e)||!d(r[e],n[e]))return!1;return!0})}let m=new WeakMap,g=(n=d,i=d,function(e,t){for(let[r,a]of e){let e=!1;for(let[s,o]of t)if(n(r,s)&&i(a,o)){e=!0;break}if(!e)return!1}return!0}),y=(a=d,function(e,t){for(let r of e){let e=!1;for(let n of t)if(a(r,n)){e=!0;break}if(!e)return!1}return!0}),b=e=>(0,l.i5)(e,c);r.d(t,{aI:()=>u},{HR:c,Xq:e=>(o.J.add(e),e),jI:()=>u})},1044(e,t,r){let n=e=>(t,r)=>t===r||e(t,r),i=n((e,t)=>globalThis.Number.isNaN(e)&&globalThis.Number.isNaN(t));function a(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 s(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:()=>a,_k:()=>s},{L8:n,wN:i})},7598(e,t,r){var n=r(8433),i=r(1136);n.IH,n.b9;let a=n.xt,s=n.cb,o=n.Rk;n.V2,i._sz;let l=i.x5l,c=i.CoE,u=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:u,Py:a,fJ:o,oJ:c,rI:l})},956(e,t,r){var n=r(4650),i=r(3833),a=r(5369),s=r(995);a.Kg,a.Et,a.Lm,a.sI,a.Bm,a.$P;let o=(0,n.XY)(2,(e,t)=>r=>{let n=e(r);if(s.N6(n))return s.fJ(r);let i=t(n.success);return s.N6(i)?s.fJ(r):i});r.d(t,{},{Bh:o,zL:e=>t=>{let r=e(t);return s.N6(r)?i.none():i.some(r.success)}})},6470(e,t,r){var n=r(5369),i=r(1743);let a="[Circular]";function s(e){return"string"==typeof e?JSON.stringify(e):String(e)}function o(e){return e.map(e=>`[${s(e)}]`).join("")}function l(e){try{return e.toISOString()}catch{return"Invalid Date"}}function c(e,t){let r=[];return JSON.stringify(e,function(e,t){let n=(0,i.E$)(t);if("object"!=typeof n||null===n)return n;for(;r.length>0&&r[r.length-1]!==this;)r.pop();if(!r.includes(n))return r.push(n),n},t?.space)}r.d(t,{GP:()=>function e(t,r){let o=r?.space??0,c=new WeakSet,u=o?"number"==typeof o?" ".repeat(o):o:"",d=(e,t)=>{let r=e?.constructor;return r&&r!==Object.prototype.constructor&&r.name?`${r.name}(${t})`:t};return function t(o,f=0){if(Array.isArray(o)){let e,r;if(c.has(o))return a;if(c.add(o),!u||o.length<=1)return`[${o.map(e=>t(e,f)).join(",")}]`;let n=o.map(e=>t(e,f+1)).join(",\n"+(e=f+1,u.repeat(e)));return`[
|
|
156
|
+
${p}:`):(k=`${k}:`,v&&(k+=s.lineComment(k,r.indent,g(v)))),n.isNode(t)?(c=!!t.spaceBefore,u=t.commentBefore,d=t.comment):(c=!1,u=null,d=null,t&&"object"==typeof t&&(t=h.createNode(t))),r.implicitKey=!1,!w&&!v&&n.isScalar(t)&&(r.indentAtStart=k.length+1),_=!1,!(!y&&m.length>=2&&!r.inFlow&&!w&&n.isSeq(t))||t.flow||t.tag||t.anchor||(r.indent=r.indent.substring(2));let S=!1,$=a.stringify(t,r,()=>S=!0,()=>_=!0),E=" ";if(v||c||u){if(E=c?"\n":"",u){let e=g(u);E+=`
|
|
157
|
+
${s.indentComment(e,r.indent)}`}""!==$||r.inFlow?E+=`
|
|
158
|
+
${r.indent}`:"\n"===E&&d&&(E="\n\n")}else if(!w&&n.isCollection(t)){let e=$[0],n=$.indexOf("\n"),i=-1!==n,a=r.inFlow??t.flow??0===t.items.length;if(i||!a){let t=!1;if(i&&("&"===e||"!"===e)){let r=$.indexOf(" ");"&"===e&&-1!==r&&r<n&&"!"===$[r+1]&&(r=$.indexOf(" ",r+1)),(-1===r||n<r)&&(t=!0)}t||(E=`
|
|
159
|
+
${r.indent}`)}}else(""===$||"\n"===$[0])&&(E="");return k+=E+$,r.inFlow?S&&o&&o():d&&!S?k+=s.lineComment(k,r.indent,g(d)):_&&l&&l(),k}},4286(e,t,r){let n;var i=r(8376),a=r(3980);let s=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth});function o(e,t){let r=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return r;let{implicitKey:n}=t,i=t.options.doubleQuotedMinMultiLineLength,o=t.indent||(/^(%|---|\.\.\.)/m.test(e)?" ":""),l="",c=0;for(let e=0,t=r[e];t;t=r[++e])if(" "===t&&"\\"===r[e+1]&&"n"===r[e+2]&&(l+=r.slice(c,e)+"\\ ",e+=1,c=e,t="\\"),"\\"===t)switch(r[e+1]){case"u":{l+=r.slice(c,e);let t=r.substr(e+2,4);switch(t){case"0000":l+="\\0";break;case"0007":l+="\\a";break;case"000b":l+="\\v";break;case"001b":l+="\\e";break;case"0085":l+="\\N";break;case"00a0":l+="\\_";break;case"2028":l+="\\L";break;case"2029":l+="\\P";break;default:"00"===t.substr(0,2)?l+="\\x"+t.substr(2):l+=r.substr(e,6)}e+=5,c=e+1}break;case"n":if(n||'"'===r[e+2]||r.length<i)e+=1;else{for(l+=r.slice(c,e)+"\n\n";"\\"===r[e+2]&&"n"===r[e+3]&&'"'!==r[e+4];)l+="\n",e+=2;l+=o," "===r[e+2]&&(l+="\\"),e+=1,c=e+1}break;default:e+=1}return l=c?l+r.slice(c):r,n?l:a.foldFlowLines(l,o,a.FOLD_QUOTED,s(t,!1))}function l(e,t){if(!1===t.options.singleQuote||t.implicitKey&&e.includes("\n")||/[ \t]\n|\n[ \t]/.test(e))return o(e,t);let r=t.indent||(/^(%|---|\.\.\.)/m.test(e)?" ":""),n="'"+e.replace(/'/g,"''").replace(/\n+/g,`$&
|
|
160
|
+
${r}`)+"'";return t.implicitKey?n:a.foldFlowLines(n,r,a.FOLD_FLOW,s(t,!1))}function c(e,t){let r,{singleQuote:n}=t.options;if(!1===n)r=o;else{let t=e.includes('"'),i=e.includes("'");r=t&&!i?l:i&&!t?o:n?l:o}return r(e,t)}try{n=RegExp("(^|(?<!\n))\n+(?!\n|$)","g")}catch{n=/\n+(?!\n|$)/g}function u({comment:e,type:t,value:r},o,l,d){let f,h,p,m,{blockQuote:g,commentString:y,lineWidth:b}=o.options;if(!g||/\n[\t ]+$/.test(r))return c(r,o);let v=o.indent||(o.forceBlockIndent||(m=r,/^(%|---|\.\.\.)/m.test(m))?" ":""),w="literal"===g||"folded"!==g&&t!==i.Scalar.BLOCK_FOLDED&&(t===i.Scalar.BLOCK_LITERAL||!function(e,t,r){if(!t||t<0)return!1;let n=t-r,i=e.length;if(i<=n)return!1;for(let t=0,r=0;t<i;++t)if("\n"===e[t]){if(t-r>n)return!0;if(i-(r=t+1)<=n)return!1}return!0}(r,b,v.length));if(!r)return w?"|\n":">\n";for(h=r.length;h>0;--h){let e=r[h-1];if("\n"!==e&&" "!==e&&" "!==e)break}let x=r.substring(h),_=x.indexOf("\n");-1===_?f="-":r===x||_!==x.length-1?(f="+",d&&d()):f="",x&&(r=r.slice(0,-x.length),"\n"===x[x.length-1]&&(x=x.slice(0,-1)),x=x.replace(n,`$&${v}`));let k=!1,S=-1;for(p=0;p<r.length;++p){let e=r[p];if(" "===e)k=!0;else if("\n"===e)S=p;else break}let $=r.substring(0,S<p?S+1:p);$&&(r=r.substring($.length),$=$.replace(/\n+/g,`$&${v}`));let E=v?"2":"1",O=(k?E:"")+f;if(e&&(O+=" "+y(e.replace(/ ?[\r\n]+/g," ")),l&&l()),!w){let e=r.replace(/\n+/g,"\n$&").replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${v}`),n=!1,l=s(o,!0);"folded"!==g&&t!==i.Scalar.BLOCK_FOLDED&&(l.onOverflow=()=>{n=!0});let c=a.foldFlowLines(`${$}${e}${x}`,v,a.FOLD_BLOCK,l);if(!n)return`>${O}
|
|
161
|
+
${v}${c}`}return r=r.replace(/\n+/g,`$&${v}`),`|${O}
|
|
162
|
+
${v}${$}${r}${x}`}t.stringifyString=function(e,t,r,n){let{implicitKey:d,inFlow:f}=t,h="string"==typeof e.value?e:Object.assign({},e,{value:String(e.value)}),{type:p}=e;p!==i.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(h.value)&&(p=i.Scalar.QUOTE_DOUBLE);let m=e=>{switch(e){case i.Scalar.BLOCK_FOLDED:case i.Scalar.BLOCK_LITERAL:return d||f?c(h.value,t):u(h,t,r,n);case i.Scalar.QUOTE_DOUBLE:return o(h.value,t);case i.Scalar.QUOTE_SINGLE:return l(h.value,t);case i.Scalar.PLAIN:return function(e,t,r,n){let{type:o,value:l}=e,{actualString:d,implicitKey:f,indent:h,indentStep:p,inFlow:m}=t;if(f&&l.includes("\n")||m&&/[[\]{},]/.test(l))return c(l,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(l))return f||m||!l.includes("\n")?c(l,t):u(e,t,r,n);if(!f&&!m&&o!==i.Scalar.PLAIN&&l.includes("\n"))return u(e,t,r,n);if(/^(%|---|\.\.\.)/m.test(l)){if(""===h)return t.forceBlockIndent=!0,u(e,t,r,n);else if(f&&h===p)return c(l,t)}let g=l.replace(/\n+/g,`$&
|
|
163
|
+
${h}`);if(d){let e=e=>e.default&&"tag:yaml.org,2002:str"!==e.tag&&e.test?.test(g),{compat:r,tags:n}=t.doc.schema;if(n.some(e)||r?.some(e))return c(l,t)}return f?g:a.foldFlowLines(g,h,a.FOLD_FLOW,s(t,!1))}(h,t,r,n);default:return null}},g=m(p);if(null===g){let{defaultKeyType:e,defaultStringType:r}=t.options,n=d&&e||r;if(null===(g=m(n)))throw Error(`Unsupported default string type ${n}`)}return g}},7995(e,t,r){var n=r(6730);let i=Symbol("break visit"),a=Symbol("skip children"),s=Symbol("remove node");function o(e,t){let r=d(t);n.isDocument(e)?l(null,e.contents,r,Object.freeze([e]))===s&&(e.contents=null):l(null,e,r,Object.freeze([]))}function l(e,t,r,a){let o=f(e,t,r,a);if(n.isNode(o)||n.isPair(o))return h(e,a,o),l(e,o,r,a);if("symbol"!=typeof o){if(n.isCollection(t)){a=Object.freeze(a.concat(t));for(let e=0;e<t.items.length;++e){let n=l(e,t.items[e],r,a);if("number"==typeof n)e=n-1;else{if(n===i)return i;n===s&&(t.items.splice(e,1),e-=1)}}}else if(n.isPair(t)){a=Object.freeze(a.concat(t));let e=l("key",t.key,r,a);if(e===i)return i;e===s&&(t.key=null);let n=l("value",t.value,r,a);if(n===i)return i;n===s&&(t.value=null)}}return o}async function c(e,t){let r=d(t);n.isDocument(e)?await u(null,e.contents,r,Object.freeze([e]))===s&&(e.contents=null):await u(null,e,r,Object.freeze([]))}async function u(e,t,r,a){let o=await f(e,t,r,a);if(n.isNode(o)||n.isPair(o))return h(e,a,o),u(e,o,r,a);if("symbol"!=typeof o){if(n.isCollection(t)){a=Object.freeze(a.concat(t));for(let e=0;e<t.items.length;++e){let n=await u(e,t.items[e],r,a);if("number"==typeof n)e=n-1;else{if(n===i)return i;n===s&&(t.items.splice(e,1),e-=1)}}}else if(n.isPair(t)){a=Object.freeze(a.concat(t));let e=await u("key",t.key,r,a);if(e===i)return i;e===s&&(t.key=null);let n=await u("value",t.value,r,a);if(n===i)return i;n===s&&(t.value=null)}}return o}function d(e){return"object"==typeof e&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function f(e,t,r,i){return"function"==typeof r?r(e,t,i):n.isMap(t)?r.Map?.(e,t,i):n.isSeq(t)?r.Seq?.(e,t,i):n.isPair(t)?r.Pair?.(e,t,i):n.isScalar(t)?r.Scalar?.(e,t,i):n.isAlias(t)?r.Alias?.(e,t,i):void 0}function h(e,t,r){let i=t[t.length-1];if(n.isCollection(i))i.items[e]=r;else if(n.isPair(i))"key"===e?i.key=r:i.value=r;else if(n.isDocument(i))i.contents=r;else{let e=n.isAlias(i)?"alias":"scalar";throw Error(`Cannot replace node with ${e} parent`)}}o.BREAK=i,o.SKIP=a,o.REMOVE=s,c.BREAK=i,c.SKIP=a,c.REMOVE=s,t.visit=o,t.visitAsync=c},8927(e,t,r){r.d(t,{CN:()=>h,BC:()=>g,Ie:()=>A,pb:()=>N,i8:()=>S,g9:()=>k,Uk:()=>$,Ts:()=>p,CZ:()=>b,ET:()=>v,HV:()=>x,Tj:()=>T,YW:()=>m,of:()=>C,jB:()=>M,TS:()=>P,di:()=>E,KC:()=>I});var n=r(8036),i=r(1044),a=r(4650);let s=e=>e.length>0;var o=r(8496),l=r(3833),c=r(6364),u=r(8099),d=r(995);let f=globalThis.Array,h=e=>new f(e),p=e=>f.isArray(e)?e:f.from(e);u.Wo,l.toArray;let m=(0,a.XY)(2,(e,{onEmpty:t,onNonEmpty:r})=>v(e)?r(e):t()),g=(0,a.XY)(2,(e,t)=>[...e,t]),y=(0,a.XY)(2,(e,t)=>p(e).concat(p(t)));f.isArray;let b=s,v=s,w=(0,a.XY)(2,(e,t)=>{let r=Math.floor(t);if(r<0||r>=e.length)throw Error(`Index out of bounds: ${r}`);return e[r]})(0),x=e=>v(e)?l.some(_(e)):l.none(),_=e=>e[e.length-1],k=(0,a.XY)(2,(e,t)=>{let r=0;for(let n of e){if(t(n,r))return l.some(r);r++}return l.none()}),S=o.i8,$=(0,a.XY)(2,(e,t)=>{let r=p(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()}),E=(0,a.XY)(2,(e,t)=>{let r=f.from(e);return r.sort(t),r}),O=(0,a.XY)(3,(e,t,r)=>{let n=p(e),i=p(t);return v(n)?v(i)?j(r)(y(n,i)):n:i}),I=(0,a.XY)(2,(e,t)=>O(e,t,n.jI())),A=()=>[],C=e=>[e],T=(0,a.XY)(2,(e,t)=>e.map(t)),N=(0,a.XY)(2,(e,t)=>{let r=p(e),n=[];for(let e=0;e<r.length;e++)t(r[e],e)&&n.push(r[e]);return n}),M=(0,a.XY)(2,(e,t)=>{let r=[],n=[],i=0;for(let a of e){let e=t(a,i++);d.oJ(e)?n.push(e.success):r.push(e.failure)}return[r,n]}),P=(0,a.XY)(3,(e,t,r)=>p(e).reduce((e,t,n)=>r(e,t,n),t));c.O3,i.O3;let j=(0,a.XY)(2,(e,t)=>{let r=p(e);if(v(r)){let e=[w(r)];for(let n of r.slice(1))e.every(e=>!t(n,e))&&e.push(n);return e}return[]})},631(e,t,r){var n=r(8036),i=r(1044),a=r(4650),s=r(4450),o=r(6400),l=r(3833),c=r(6364),u=r(9138),d=r(5369);let f=/^[+-]?\d+$/,h="~effect/BigDecimal",p={[h]:h,[s.HR](){let e=k(this);return s.kg(s.tW(e.value),s.ai(e.scale))},[n.HR](e){return m(e)&&T(this,e)},toString(){return`BigDecimal(${N(this)})`},toJSON(){return{_id:"BigDecimal",value:String(this.value),scale:this.scale}},[o.FX](){return this.toJSON()},pipe(){return(0,u.tT)(this,arguments)}},m=e=>(0,d.i5)(e,h),g=(e,t)=>{let r=Object.create(p);return r.value=e,r.scale=t,r},y=(e,t)=>{if(e!==b&&e%x===b)throw RangeError("Value must be normalized");let r=g(e,t);return r.normalized=r,r},b=BigInt(0),v=BigInt(1),w=BigInt(-1),x=BigInt(10),_=y(b,0),k=e=>{if(void 0===e.normalized)if(e.value===b)e.normalized=_;else{let t=`${e.value}`,r=0;for(let e=t.length-1;e>=0;e--)if("0"===t[e])r++;else break;0===r&&(e.normalized=e);let n=BigInt(t.substring(0,t.length-r)),i=e.scale-r;e.normalized=y(n,i)}return e.normalized},S=(0,a.XY)(2,(e,t)=>t>e.scale?g(e.value*x**BigInt(t-e.scale),t):t<e.scale?g(e.value/x**BigInt(e.scale-t),t):e),$=(0,a.XY)(2,(e,t)=>t.value===b?e:e.value===b?t:e.scale>t.scale?g(S(t,e.scale).value+e.value,e.scale):e.scale<t.scale?g(S(e,t.scale).value+t.value,t.scale):g(e.value+t.value,e.scale)),E=c.L8((e,t)=>{let r=c.wN(A(e),A(t));return 0!==r?r:e.scale>t.scale?c.Qw(e.value,S(t,e.scale).value):e.scale<t.scale?c.Qw(S(e,t.scale).value,t.value):c.Qw(e.value,t.value)}),O=c.hl(E),I=c.yJ(E),A=e=>e.value===b?0:e.value<b?-1:1,C=i.L8((e,t)=>e.scale>t.scale?S(t,e.scale).value===e.value:e.scale<t.scale?S(e,t.scale).value===t.value:e.value===t.value),T=(0,a.XY)(2,(e,t)=>C(e,t)),N=e=>{let t,r,n=k(e);if(Math.abs(n.scale)>=16)return M(n);let i=n.value<b,a=i?`${n.value}`.substring(1):`${n.value}`;if(n.scale>=a.length)t="0",r="0".repeat(n.scale-a.length)+a;else{let e=a.length-n.scale;if(e>a.length){let n=e-a.length;t=`${a}${"0".repeat(n)}`,r=""}else r=a.slice(e),t=a.slice(0,e)}let s=""===r?t:`${t}.${r}`;return i?`-${s}`:s},M=e=>{if(P(e))return"0e+0";let t=k(e),r=`${(t.value<b?g(-t.value,t.scale):t).value}`,n=r.slice(0,1),i=r.slice(1),a=`${j(t)?"-":""}${n}`;""!==i&&(a+=`.${i}`);let s=i.length-t.scale;return`${a}e${s>=0?"+":""}${s}`},P=e=>e.value===b,j=e=>e.value<b,D=e=>m(e[0]),U=(0,a.XY)(D,(e,t=0)=>e.scale<=t?e:g(e.value/x**BigInt(e.scale-t),t)),R=(0,a.XY)(D,(e,t=0)=>{let r=U(e,t);return e.value>b&&O(r,e)?$(r,g(v,t)):r}),F=(0,a.XY)(D,(e,t=0)=>{let r=U(e,t);return j(e)&&I(r,e)?$(r,g(w,t)):r});r.d(t,{},{GP:N,L8:g,RI:F,hs:S,mk:R,pH:E,rs:C,s5:m,sH:e=>{let t,r,n,i;if(""===e)return l.some(_);let a=e.search(/[eE]/);if(-1!==a){let n=e.slice(a+1);if(t=e.slice(0,a),r=Number(n),""===t||!Number.isSafeInteger(r)||!f.test(n))return l.none()}else t=e,r=0;let s=t.search(/\./);if(-1!==s){let e=t.slice(0,s),r=t.slice(s+1);n=`${e}${r}`,i=r.length}else n=t,i=0;if(!f.test(n))return l.none();let o=i-r;return Number.isSafeInteger(o)?l.some(g(BigInt(n),o)):l.none()}})},8543(e,t,r){var n=r(8433),i=r(1136);n.PX,n.B4,n.Aj,n.Wg;let a=n.lC;n.Xb,n.ik,n.b5,n.DH;let s=n.OE;n.Iu,i.nIy,i.ORc;let o=i.nn5,l=i.O$X;i.h2c;let c=i.ReC;i.myX,i.QE5;let u=i.khU,d=i.L$u;i.gpn,i.k7S,i.BbX;let f=i.prj;i.tU5,i.h74,i.Bou,i.RJ6;let h=i.GyP;n.PW,n.qB,n.Xm;let p=n.$L;n.q_;let m=n.RS,g=n.Vw;i.DQo,i.c8t,i.MUS,i.t8c,i._y;let y=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:p,Bk:b,L$:d,RS:m,Tj:l,Vw:g,fJ:s,iw:c,j9:h,kh:u,lC:a,nn:o,pr:f,qw:y})},190(e,t,r){var n=r(1136);n.a1U,n.RKA;let i=n.Rud;n.s0X,r.d(t,{},{Ru:i})},8619(e,t,r){var n=r(3267),i=r(8036),a=r(4650),s=r(4450),o=r(8433),l=r(3628),c=r(3833),u=r(5369);let d="~effect/Context/Service",f=function(){let e=(0,l.jt)();(0,l.ft)(2);let t=Error();(0,l.ft)(e);let r=function(){};return(Object.setPrototypeOf(r,h),Object.defineProperty(r,"stack",{get:()=>t.stack}),arguments.length>0)?(r.key=arguments[0],arguments[1]?.defaultValue&&(r[p]=p,r.defaultValue=arguments[1].defaultValue),r):function(e,t){return r.key=e,t?.make&&(r.make=t.make),r}},h={[d]:d,...n.b({label:"Service",evaluate(e){return(0,o.xt)(S(e.context,this))}}),toJSON(){return{_id:"Service",key:this.key,stack:this.stack}},of:e=>e,context(e){return w(this,e)},use(e){return(0,o.R6)(t=>e(S(t.context,this)))},useSync(e){return(0,o.R6)(t=>(0,o.xt)(e(S(t.context,this))))}},p="~effect/Context/Reference",m="~effect/Context",g=e=>{let t=Object.create(y);return t.mapUnsafe=e,t.mutable=!1,t},y={...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(!b(e)||this.mapUnsafe.size!==e.mapUnsafe.size)return!1;for(let t of this.mapUnsafe.keys())if(!e.mapUnsafe.has(t)||!i.aI(this.mapUnsafe.get(t),e.mapUnsafe.get(t)))return!1;return!0},[s.HR](){return s.ai(this.mapUnsafe.size)}},b=e=>(0,u.i5)(e,m),v=g(new Map),w=(e,t)=>g(new Map([[e.key,t]])),x=(0,a.XY)(3,(e,t,r)=>C(e,e=>{e.set(t.key,r)})),_=(0,a.XY)(2,(e,t)=>e.mapUnsafe.get(t.key)),k=(0,a.XY)(2,(e,t)=>{if(!e.mapUnsafe.has(t.key)){if(p in t)return E(t);throw O(t)}return e.mapUnsafe.get(t.key)}),S=k,$="~effect/Context/defaultValue",E=e=>$ in e?e[$]:e[$]=e.defaultValue(),O=e=>{let t=Error(`Service not found${e.key?`: ${String(e.key)}`:""}`);if(e.stack){let r=e.stack.split("\n");if(r.length>2){let e=r[2].match(/at (.*)/);e&&(t.message=t.message+` (defined at ${e[1]})`)}}if(t.stack){let e=t.stack.split("\n");e.splice(1,3),t.stack=e.join("\n")}return t},I=(0,a.XY)(2,(e,t)=>e.mapUnsafe.has(t.key)?c.some(e.mapUnsafe.get(t.key)):(0,u.i5)(t,p)?c.some(E(t)):c.none()),A=(0,a.XY)(2,(e,t)=>0===e.mapUnsafe.size?t:0===t.mapUnsafe.size?e:C(e,e=>{t.mapUnsafe.forEach((t,r)=>e.set(r,t))})),C=(e,t)=>{if(e.mutable)return t(e.mapUnsafe),e;let r=new Map(e.mapUnsafe);return t(r),g(r)};r.d(t,{},{Ie:()=>v,Jt:S,L8:w,LZ:g,Or:f,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 g(t)},WQ:x,Y6:_,aE:b,fp:k,h1:A,kA:(e,t)=>e.mapUnsafe.has(t.key)?e.mapUnsafe.get(t.key):E(t),kl:f,om:I})},2718(e,t,r){var n=r(8433),i=r(9138),a=r(5369);let s=class extends i.Xs{constructor(e){super(),e&&Object.assign(this,e)}};function o(){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 l=n.$D,c=n.rN;r.d(t,{},{$D:l,Ij:()=>new Proxy({},{get:(e,t,r)=>"$is"===t?a.$J:"$match"===t?o:e=>({...e,_tag:t})}),Xs:s,rN:c})},4705(e,t,r){r.d(t,{rs:()=>ef,pH:()=>eh,dv:()=>eE,Rd:()=>eO,tn:()=>ep,Ar:()=>es,kQ:()=>eo,rg:()=>ec,lU:()=>el,rr:()=>eu,Ry:()=>ed,L8:()=>eg,MO:()=>ey,TT:()=>em,yF:()=>eS,Xy:()=>e$,yT:()=>eb,ez:()=>e_,y3:()=>ex,k9:()=>ev,ko:()=>ew,xV:()=>ek}),r(8619);var n=r(4650),i=r(8543),a=r(190),s=(r(2302),r(8036)),o=r(1044),l=r(4450),c=r(6400),u=r(3833),d=r(6364),f=r(9138),h=r(5369);r(1136);let p="~effect/time/DateTime",m="~effect/time/DateTime/TimeZone",g={[p]:p,pipe(){return(0,f.tT)(this,arguments)},[c.FX](){return this.toString()},toJSON(){return W(this).toJSON()}},y={...g,_tag:"Utc",[l.HR](){return l.ai(this.epochMilliseconds)},[s.HR](e){return k(e)&&"Utc"===e._tag&&this.epochMilliseconds===e.epochMilliseconds},toString(){return`DateTime.Utc(${W(this).toJSON()})`}},b={...g,_tag:"Zoned",[l.HR](){return l.kg(l.ai(this.epochMilliseconds))(l.tW(this.zone))},[s.HR](e){return k(e)&&"Zoned"===e._tag&&this.epochMilliseconds===e.epochMilliseconds&&s.aI(this.zone,e.zone)},toString(){return`DateTime.Zoned(${ea(this)})`}},v={[m]:m,[c.FX](){return this.toString()}},w={...v,_tag:"Named",[l.HR](){return l.Yj(`Named:${this.id}`)},[s.HR](e){return $(e)&&"Named"===e._tag&&this.id===e.id},toString(){return`TimeZone.Named(${this.id})`},toJSON(){return{_id:"TimeZone",_tag:"Named",id:this.id}}},x={...v,_tag:"Offset",[l.HR](){return l.Yj(`Offset:${this.offset}`)},[s.HR](e){return $(e)&&"Offset"===e._tag&&this.offset===e.offset},toString(){return`TimeZone.Offset(${z(this.offset)})`},toJSON(){return{_id:"TimeZone",_tag:"Offset",offset:this.offset}}},_=(e,t,r)=>{let n=Object.create(b);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},k=e=>h.i5(e,p),S=e=>k(e[0]),$=e=>h.i5(e,m),E=e=>"Zoned"===e._tag,O=o.L8((e,t)=>e.epochMilliseconds===t.epochMilliseconds),I=d.L8((e,t)=>e.epochMilliseconds<t.epochMilliseconds?-1:+(e.epochMilliseconds>t.epochMilliseconds)),A=e=>{let t=Object.create(y);return t.epochMilliseconds=e,Object.defineProperty(t,"partsUtc",{value:void 0,enumerable:!1,writable:!0}),t},C=e=>{let t=e.getTime();if(Number.isNaN(t))throw new i.qw("Invalid date");return A(t)},T=e=>{if(k(e))return e;if(e instanceof Date)return C(e);if("object"==typeof e){if("epochMilliseconds"in e)return A(e.epochMilliseconds);let t=new Date(0);return V(t,e),C(t)}return"string"!=typeof e||N(e)?C(new Date(e)):C(new Date(e+"Z"))},N=e=>/Z|GMT|[+-]\d{2}$|[+-]\d{2}:?\d{2}$|\]$/.test(e),M=(e,t)=>{let r,n=t?.timeZone;if(void 0===n&&k(e)&&E(e))return e;let a=T(e);if(a.epochMilliseconds<-86399999568e5||a.epochMilliseconds>86399999496e5)throw RangeError(`Epoch millis out of range: ${a.epochMilliseconds}`);if(void 0===n&&"object"==typeof e&&"timeZoneId"in e&&(n=e.timeZoneId),void 0===n)r=L(-60*new Date(a.epochMilliseconds).getTimezoneOffset()*1e3);else if($(n))r=n;else if("number"==typeof n)r=L(n);else{let e=q(n);if(u.isNone(e))throw new i.qw(`Invalid time zone: ${n}`);r=e.value}return t?.adjustForTimeZone!==!0?_(a.epochMilliseconds,r,a.partsUtc):G(a.epochMilliseconds,r,t?.disambiguation??"compatible")},P=u.liftThrowable(M),j=u.liftThrowable(T),D=/^(.{17,35})\[(.+)\]$/;a.Ru,a.Ru,(e,t,r)=>r?.adjustForTimeZone===!0?G(e.epochMilliseconds,t,r?.disambiguation??"compatible"):_(e.epochMilliseconds,t,e.partsUtc);let U=new Map,R={day:"numeric",month:"numeric",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"longOffset",fractionalSecondDigits:3,hourCycle:"h23"},F=e=>{if(U.has(e))return U.get(e);try{var t=new Intl.DateTimeFormat("en-US",{...R,timeZone:e});let r=t.resolvedOptions().timeZone;if(U.has(r))return U.get(r);let n=Object.create(w);return n.id=r,n.format=t,U.set(r,n),n}catch{throw new i.qw(`Invalid time zone: ${e}`)}},L=e=>{let t=Object.create(x);return t.offset=e,t},B=u.liftThrowable(F),Y=/^(?:GMT|[+-])/,q=e=>{if(Y.test(e)){let t=Q(e);return null===t?u.none():u.some(L(t))}return B(e)},W=e=>new Date(e.epochMilliseconds),X=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),Number(t[6].value)),e.adjustedEpochMilliseconds=r.getTime(),r},J=e=>X(e).getTime()-K(e),z=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")}`},K=e=>e.epochMilliseconds,V=(e,t)=>{if(void 0!==t.year&&e.setUTCFullYear(t.year),void 0!==t.month&&e.setUTCMonth(t.month-1),void 0!==t.day&&e.setUTCDate(t.day),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)},G=(e,t,r)=>{if("Offset"===t._tag)return _(e-t.offset,t);let n=Z(e-864e5,e,t),i=Z(e+864e5,e,t);if(n===i)return _(e-n,t);let a=n-i;if(n<i){if(Z(e-i,e,t)===i)return _(e-i,t);let a=_(e-n,t);if(e!==X(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 _(e-i,t)}return a}if(Z(e-n,e,t)===n){if("earlier"===r||"compatible"===r||Z(e-n+a,e+a,t)===n)return _(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 _(e-i,t)},H=/([+-])(\d{2}):(\d{2})$/,Q=e=>{let t=H.exec(e);if(null===t)return null;let[,r,n,i]=t;return("+"===r?1:-1)*(60*Number(n)+Number(i))*6e4},Z=(e,t,r)=>{let n=r.format.formatToParts(e).find(e=>"timeZoneName"===e.type)?.value??"";if("GMT"===n)return 0;let i=Q(n);return null===i?J(_(t,r)):i},ee=(0,n.XY)(S,(e,t,r)=>{if("Utc"===e._tag){let r=W(e);return t(r),A(r.getTime())}let n=new Date(X(e).getTime());return t(n),G(n.getTime(),e.zone,r?.disambiguation??"compatible")}),et=((e,t)=>et(e,e=>{let r=new Date(e);return t(r),r.getTime()}),(0,n.XY)(2,(e,t)=>{let r=t(K(e));return"Utc"===e._tag?A(r):_(r,e.zone)})),er=((e,t)=>t(X(e)),(0,n.XY)(2,(e,t)=>t(W(e)))),en=(e,t)=>{e.setTime(e.getTime()+t)},ei=((e,t)=>ee(e,e=>{if(t.milliseconds&&en(e,t.milliseconds),t.seconds&&en(e,1e3*t.seconds),t.minutes&&en(e,60*t.minutes*1e3),t.hours&&en(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=X(e);return"Utc"===e._tag?t.toISOString():`${t.toISOString().slice(0,-1)}${z(J(e))}`}),ea=e=>"Offset"===e.zone._tag?ei(e):`${ei(e)}[${e.zone.id}]`;r(5089);let es=k,eo=$,el=e=>$(e)&&"Offset"===e._tag,ec=e=>$(e)&&"Named"===e._tag,eu=e=>"Utc"===e._tag,ed=E,ef=O,eh=I,ep=C,em=M,eg=j,ey=e=>{let t=D.exec(e);if(null===t){let t=Q(e);return null!==t?P(e,{timeZone:t}):u.none()}let[,r,n]=t;return P(r,{timeZone:n})},eb=e=>A(e.epochMilliseconds),ev=F,ew=L,ex=B,e_=q,ek=e=>"Offset"===e._tag?z(e.offset):e.id,eS=W,e$=K,eE=e=>W(e).toISOString(),eO=ea},3717(e,t,r){var n=r(4650),i=r(1136),a=r(9138);let s={"~effect/Deferred":{_A:n.D_,_E:n.D_},pipe(){return(0,a.tT)(this,arguments)}},o=(0,n.XY)(2,(e,t)=>i.OH5(()=>l(e,t))),l=(e,t)=>{if(e.effect)return!1;if(e.effect=t,e.resumes){for(let r=0;r<e.resumes.length;r++)e.resumes[r](t);e.resumes=void 0}return!0};r.d(t,{},{$L:e=>i.OH5(()=>void 0!==e.effect),$w:l,LZ:()=>{let e=Object.create(s);return e.resumes=void 0,e.effect=void 0,e},Tx:e=>i.E2r(t=>e.effect?t(e.effect):(e.resumes??=[],e.resumes.push(t),i.OH5(()=>{let r=e.resumes.indexOf(t);e.resumes.splice(r,1)}))),Vw:o})},2302(e,t,r){var n=r(8036),i=r(4650),a=r(4450),s=r(6400),o=r(3833),l=r(6364),c=r(9138),u=r(5369);let d="~effect/time/Duration",f=BigInt(0),h=BigInt(1),p=BigInt(1e3),m=e=>BigInt(e<0?Math.ceil(e-.5):Math.floor(e+.5)),g=(e,t)=>e.includes(".")?m(Number(e)*Number(t)):BigInt(e)*t,y=/^(-?\d+(?:\.\d+)?)\s+(nanos?|micros?|millis?|seconds?|minutes?|hours?|days?|weeks?)$/,b=e=>{switch(typeof e){case"number":return T(e);case"bigint":return C(e);case"string":{if("Infinity"===e)return I;if("-Infinity"===e)return A;let t=y.exec(e);if(!t)break;let[r,n,i]=t;if("nano"===i||"nanos"===i)return C(g(n,h));if("micro"===i||"micros"===i)return C(g(n,p));let a=Number(n);switch(i){case"milli":case"millis":return T(a);case"second":case"seconds":return N(a);case"minute":case"minutes":return M(a);case"hour":case"hours":return P(a);case"day":case"days":return j(a);case"week":case"weeks":return D(a)}break}case"object":{if(null===e)break;if(d in e)return e;if(Array.isArray(e)){if(2!==e.length||!e.every(u.Et))return v(e);if(Number.isNaN(e[0])||Number.isNaN(e[1]))return O;if(e[0]===-1/0||e[1]===-1/0)return A;if(e[0]===1/0||e[1]===1/0)return I;return $(m(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 $(t);return $(m(1e6*t+(e.microseconds??0)*1e3+(e.nanoseconds??0)))}}return v(e)},v=e=>{throw Error(`Invalid Input: ${e}`)},w=o.liftThrowable(b),x={_tag:"Millis",millis:0},_={_tag:"Infinity"},k={_tag:"NegativeInfinity"},S={[d]:d,[a.HR](){return a.QK(this.value)},[n.HR](e){return E(e)&&W(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,c.tT)(this,arguments)}},$=e=>{let t=Object.create(S);return"number"==typeof e?isNaN(e)||0===e||Object.is(e,-0)?t.value=x:Number.isFinite(e)?Number.isInteger(e)?t.value={_tag:"Millis",millis:e}:t.value={_tag:"Nanos",nanos:m(1e6*e)}:t.value=e>0?_:k:e===f?t.value=x:t.value={_tag:"Nanos",nanos:e},t},E=e=>(0,u.i5)(e,d),O=$(0),I=$(1/0),A=$(-1/0),C=e=>$(e),T=e=>$(e),N=e=>$(1e3*e),M=e=>$(6e4*e),P=e=>$(36e5*e),j=e=>$(864e5*e),D=e=>$(6048e5*e),U=e=>{let t=b(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 m(1e6*t.value.millis)}},R=o.liftThrowable(U),F=(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)()}}),L=(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(U(e),t.value.nanos):r.onNanos(e.value.nanos,U(t))),B=l.L8((e,t)=>L(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})),Y=(e,t)=>L(e,t,{onMillis:(e,t)=>e===t,onNanos:(e,t)=>e===t,onInfinity:(e,t)=>e.value._tag===t.value._tag}),q=l.bi(B),W=(0,i.XY)(2,(e,t)=>Y(e,t));r.d(t,{},{MI:e=>"Infinity"!==e.value._tag&&"NegativeInfinity"!==e.value._tag,Tn:I,bN:b,bi:q,cF:C,kE:e=>F(b(e),{onMillis:i.D_,onNanos:e=>Number(e)/1e6,onInfinity:()=>1/0,onNegativeInfinity:()=>-1/0}),lX:w,n$:E,ne:T,qv:A,rs:Y,tb:R,v_:O})},7720(e,t,r){r.d(t,{Q56:()=>ex,jGc:()=>e_,U9h:()=>ek,Q7R:()=>x,hgn:()=>q,swY:()=>eq,Muk:()=>eT,as:()=>V,NLW:()=>G,E2r:()=>N,MfU:()=>H,Tyx:()=>ee,osR:()=>et,KuX:()=>Q,loE:()=>Z,RKA:()=>eB,_32:()=>eN,_r7:()=>eW,yeE:()=>eS,NS5:()=>z,fJG:()=>j,ATB:()=>D,pVV:()=>U,qIB:()=>Y,Ab9:()=>eK,fn:()=>eL,D9k:()=>eF,vCS:()=>eV,jJl:()=>_,i4r:()=>eC,ar0:()=>eP,x6Z:()=>ej,yUA:()=>B,JkU:()=>P,XeO:()=>eo,GaK:()=>eO,yw5:()=>w,vVN:()=>eY,TjK:()=>K,q7Y:()=>ez,jkJ:()=>eX,xm_:()=>er,Z9x:()=>eJ,YWq:()=>ed,khu:()=>ef,tvg:()=>eh,ZmZ:()=>M,S5A:()=>e$,cfM:()=>eE,uKv:()=>J,QgK:()=>en,ivC:()=>S,Gte:()=>ep,PpN:()=>em,PfK:()=>ey,KT6:()=>eu,Ket:()=>X,L5P:()=>es,MY7:()=>eD,eJC:()=>eU,lKS:()=>eR,z8E:()=>eb,P1j:()=>ev,Pxi:()=>ew,Nav:()=>eg,yy4:()=>ec,PyW:()=>E,lwU:()=>O,nGE:()=>I,DYE:()=>A,OH5:()=>C,Mim:()=>W,dGm:()=>ea,sFT:()=>ei,mgX:()=>el,SvU:()=>F,$mh:()=>$,rfi:()=>eI,FcF:()=>eA,rIH:()=>T,iMI:()=>k,R6R:()=>L,fRP:()=>eM});var n=r(4650),i=r(8433),a=r(1136),s=r(8619);r(995);var o=r(3587),l=r(5089);let c=(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 u=r(3833),d=r(4505),f=r(3537);(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?u.none():u.some(n)))});let h=(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 d.m8(s,e=>(0,f.s)(()=>r(n,e)))})),p=(0,n.XY)(2,(e,t)=>h(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),b=r(8036).Xq({_E:e=>e,_A:e=>e,_R:e=>e});({...i.In,"~effect/Request":b}),r(8469);var v=r(3864);i.$n;let w=i.yw,x=a.Q7R;a.jBG,a.tfT,a.i8i,a.kAe;let _=a.jJl,k=a.iMI,S=a.ivC,$=a.$mh,E=a.PyW,O=a.lwU,I=a.nGE,A=a.DYE,C=a.OH5,T=a.rIH;a.Vxk;let N=a.E2r,M=a.ZmZ;a.Do,a.JrD,a.uVU,a.oIE;let P=a.JkU,j=a.fJG;a.gOk;let D=a.ATB,U=a.pVV,R=a.F_Q,F=a.SvU;a.m9E,a.KN3;let L=i.R6,B=a.yUA;a.sVm,a.pkL,a.bJ;let Y=a.qIB;a.Bqz;let q=a.hgn,W=a.Mim,X=a.Ket,J=a.uKv,z=a.NS5,K=a.TjK,V=a.as;a.Xx$;let G=a.NLW;a.UUz,a.yU6,a.OYO;let H=a.h_t,Q=a.KuX,Z=a.loE;a.AXC,a.zt4,a.scW;let ee=a.Tyx;a.Fig,a.XWm;let et=a.osR;a.U9Y,a.sJf,a.rNk;let er=a.xm_;a.UcN;let en=a.QgK,ei=a.sFT;a.k$L;let ea=a.dGm;a.cA6,a.bKC,a.nAi,a.u4Y;let es=p;a._Sg;let eo=a.XeO;a.GrF,a.$$g,a.DM4,a.Dd,a.wRz,a.D52;let el=a.mgX;a.cbG;let ec=a.yy4;a.ayu,a.Vdx,a.FfP,a.O4F;let eu=a.KT6;a.pbD,a.x1Q,a.E8K,a.Pm0,a.VtY,a.W$I,a.ahH,a.z7s;let ed=a.YWq;a.G$Q,a.D$$,a.NZb,a.wR5;let ef=a.khu,eh=a.tvg;a.N6O,a.oJd,a._OA,a.sxi;let ep=c,em=a.PpN;a.oao,a.euC;let eg=a.Nav;a.r_d,a.bUZ;let ey=a.PfK;a.c7E,a.KyM;let eb=a.z8E,ev=a.P1j,ew=a.Pxi,ex=a.Q56;a.N24;let e_=a.jGc,ek=a.U9h,eS=a.yeE,e$=a.S5A;a.BeE,a.iKM,a.r7h;let eE=a.cfM;a.fGe,a.uRq,a.PO3,a.Rgn,a.CJw;let eO=a.GaK;a.Inz,a.nAr;let eI=a.rfi,eA=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 eN=a._32;a.Wj8,a.Fu6,a.WbR,a.A_r,a.Z98,a.Rd$,a.gvr;let eM=a.fRP;a.zr8,a.hq,a.zhn;let eP=a.ar0,ej=a.x6Z;a.yxg,a.PCg,a.pEE,a.ABT;let eD=a.MY7,eU=a.eJC;a.lSz,a.bPG,a.pR5,a.v2Q,a.NpQ,a.jqV,a.HZF,a.lE;let eR=a.lKS;a.rfH;let eF=a.D9k,eL=a.fn,eB=a.RKA;a.lIX;let eY=a.lIX("Error"),eq=(0,n.XY)(e=>w(e[0]),(e,...t)=>a.bUZ(e,v.iL,e=>{let r={...e};return 1===t.length?Object.assign(r,t[0]):r[t[0]]=t[1],r}));a.gsV;let eW=(e,t,r)=>(...n)=>N(i=>{try{e(...n,(e,r)=>{e?i(j(t?t(e,n):e)):i(E(r))})}catch(e){i(r?j(r(e,n)):R(e))}}),eX=a.jkJ,eJ=a.Z9x,ez=a.q7Y,eK=a.Ab9;a.UVN;let eV=a.vCS},3267(e,t,r){var n=r(8433);r.d(t,{},{b:e=>(0,n.yj)({op:e.label,[n._3]:e.evaluate})})},8983(e,t,r){var n=r(2718),i=r(995);let a="~effect/encoding/EncodingError";class s extends n.rN("EncodingError"){[a]=a}let o=e=>{let t=f(e),r=t.length;if(r%4!=0)return i.fJ(new s({kind:"Decode",module:"Base64",input:t,message:`Length must be a multiple of 4, but is ${r}`}));let n=t.indexOf("=");if(-1!==n&&(n<r-2||n===r-2&&"="!==t[r-1]))return i.fJ(new s({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("="),n=new Uint8Array(r/4*3-e);for(let e=0,i=0;e<r;e+=4,i+=3){let r=p(t.charCodeAt(e))<<18|p(t.charCodeAt(e+1))<<12|p(t.charCodeAt(e+2))<<6|p(t.charCodeAt(e+3));n[i]=r>>16,n[i+1]=r>>8&255,n[i+2]=255&r}return i.Py(n)}catch(e){return i.fJ(new s({kind:"Decode",module:"Base64",input:t,message:e instanceof Error?e.message:"Invalid input"}))}},l=e=>{let t=f(e),r=t.length;if(r%4==1)return i.fJ(new s({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 i.fJ(new s({module:"Base64Url",kind:"Decode",input:t,message:"Invalid input"}));let n=r%4==2?`${t}==`:r%4==3?`${t}=`:t;return o(n=n.replace(/-/g,"+").replace(/_/g,"/"))},c=e=>{let t=new TextEncoder().encode(e);if(t.length%2!=0)return i.fJ(new s({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=v(t[2*n]),i=v(t[2*n+1]);r[n]=e<<4|i}return i.Py(r)}catch(t){return i.fJ(new s({module:"Hex",kind:"Decode",input:e,message:t instanceof Error?t.message:"Invalid input"}))}},u=new TextEncoder,d=new TextDecoder,f=e=>e.replace(/[\n\r]/g,""),h=e=>{let t,r=e.length,n="";for(t=2;t<r;t+=3)n+=m[e[t-2]>>2],n+=m[(3&e[t-2])<<4|e[t-1]>>4],n+=m[(15&e[t-1])<<2|e[t]>>6],n+=m[63&e[t]];return t===r+1&&(n+=m[e[t-2]>>2],n+=m[(3&e[t-2])<<4],n+="=="),t===r&&(n+=m[e[t-2]>>2],n+=m[(3&e[t-2])<<4|e[t-1]>>4],n+=m[(15&e[t-1])<<2],n+="="),n};function p(e){if(e>=g.length)throw TypeError(`Invalid character ${String.fromCharCode(e)}`);let t=g[e];if(255===t)throw TypeError(`Invalid character ${String.fromCharCode(e)}`);return t}let m=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9","+","/"],g=[255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,62,255,255,255,63,52,53,54,55,56,57,58,59,60,61,255,255,255,0,255,255,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,255,255,255,255,255,255,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],y=e=>h(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_"),b=e=>{let t="";for(let r=0;r<e.length;++r)t+=w[e[r]];return t},v=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")},w=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];r.d(t,{},{$T:e=>i.Tj(o(e),e=>d.decode(e)),$X:l,DX:e=>"string"==typeof e?y(u.encode(e)):y(e),EF:c,UD:e=>i.Tj(l(e),e=>d.decode(e)),WG:e=>"string"==typeof e?h(u.encode(e)):h(e),mU:e=>"string"==typeof e?b(u.encode(e)):b(e),xQ:e=>i.Tj(c(e),e=>d.decode(e)),y4:o})},8036(e,t,r){var n,i,a,s=r(4450),o=r(6516),l=r(5369);let c="~effect/interfaces/Equal";function u(){return 1==arguments.length?e=>d(e,arguments[0]):d(arguments[0],arguments[1])}function d(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||o.J.has(e)||o.J.has(t))&&function(e,t,r){let n=m.get(e);if(n){if(n.has(t))return n.get(t)}else n=new WeakMap,m.set(e,n);let i=r(e,t);n.set(t,i);let a=m.get(t);return a||(a=new WeakMap,m.set(t,a)),a.set(e,i),i}(e,t,p))}let f=new WeakSet,h=new WeakSet;function p(e,t){if(s.tW(e)!==s.tW(t))return!1;if(e instanceof Date)return t instanceof Date&&e.toISOString()===t.toISOString();if(e instanceof RegExp)return t instanceof RegExp&&e.toString()===t.toString();let r=b(e),n=b(t);if(r!==n)return!1;let i=r&&n;return("function"!=typeof e||!!i)&&function(e,t,r){let n=f.has(e),i=h.has(t);if(n&&i)return!0;if(n||i)return!1;f.add(e),h.add(t);let a=r();return f.delete(e),h.delete(t),a}(e,t,()=>{if(i)return e[c](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(!d(e[r],t[r]))return!1;return!0}(e,t);if(ArrayBuffer.isView(e))return!!ArrayBuffer.isView(t)&&e.byteLength===t.byteLength&&function(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}(e,t);if(e instanceof Map)return t instanceof Map&&e.size===t.size&&g(e,t);if(e instanceof Set)return t instanceof Set&&e.size===t.size&&y(e,t);var r=e,n=t;let a=(0,o.X)(r),s=(0,o.X)(n);if(a.size!==s.size)return!1;for(let e of a)if(!s.has(e)||!d(r[e],n[e]))return!1;return!0})}let m=new WeakMap,g=(n=d,i=d,function(e,t){for(let[r,a]of e){let e=!1;for(let[s,o]of t)if(n(r,s)&&i(a,o)){e=!0;break}if(!e)return!1}return!0}),y=(a=d,function(e,t){for(let r of e){let e=!1;for(let n of t)if(a(r,n)){e=!0;break}if(!e)return!1}return!0}),b=e=>(0,l.i5)(e,c);r.d(t,{aI:()=>u},{HR:c,Xq:e=>(o.J.add(e),e),jI:()=>u})},1044(e,t,r){let n=e=>(t,r)=>t===r||e(t,r),i=n((e,t)=>globalThis.Number.isNaN(e)&&globalThis.Number.isNaN(t));function a(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 s(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:()=>a,_k:()=>s},{L8:n,wN:i})},7598(e,t,r){var n=r(8433),i=r(1136);n.IH,n.b9;let a=n.xt,s=n.cb,o=n.Rk;n.V2,i._sz;let l=i.x5l,c=i.CoE,u=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:u,Py:a,fJ:o,oJ:c,rI:l})},956(e,t,r){var n=r(4650),i=r(3833),a=r(5369),s=r(995);a.Kg,a.Et,a.Lm,a.sI,a.Bm,a.$P;let o=(0,n.XY)(2,(e,t)=>r=>{let n=e(r);if(s.N6(n))return s.fJ(r);let i=t(n.success);return s.N6(i)?s.fJ(r):i});r.d(t,{},{Bh:o,zL:e=>t=>{let r=e(t);return s.N6(r)?i.none():i.some(r.success)}})},6470(e,t,r){var n=r(5369),i=r(1743);let a="[Circular]";function s(e){return"string"==typeof e?JSON.stringify(e):String(e)}function o(e){return e.map(e=>`[${s(e)}]`).join("")}function l(e){try{return e.toISOString()}catch{return"Invalid Date"}}function c(e,t){let r=[];return JSON.stringify(e,function(e,t){let n=(0,i.E$)(t);if("object"!=typeof n||null===n)return n;for(;r.length>0&&r[r.length-1]!==this;)r.pop();if(!r.includes(n))return r.push(n),n},t?.space)}r.d(t,{GP:()=>function e(t,r){let o=r?.space??0,c=new WeakSet,u=o?"number"==typeof o?" ".repeat(o):o:"",d=(e,t)=>{let r=e?.constructor;return r&&r!==Object.prototype.constructor&&r.name?`${r.name}(${t})`:t};return function t(o,f=0){if(Array.isArray(o)){let e,r;if(c.has(o))return a;if(c.add(o),!u||o.length<=1)return`[${o.map(e=>t(e,f)).join(",")}]`;let n=o.map(e=>t(e,f+1)).join(",\n"+(e=f+1,u.repeat(e)));return`[
|
|
151
164
|
${r=f+1,u.repeat(r)}${n}
|
|
152
165
|
${u.repeat(f)}]`}if(o instanceof Date)return l(o);if(!r?.ignoreToString&&n.i5(o,"toString")&&"function"==typeof o.toString&&o.toString!==Object.prototype.toString&&o.toString!==Array.prototype.toString){let e=function(e){try{let t=e.toString();return"string"==typeof t?t:String(t)}catch{return"[toString threw]"}}(o);return o instanceof Error&&o.cause?`${e} (cause: ${t(o.cause,f)})`:e}if("string"==typeof o)return JSON.stringify(o);if("number"==typeof o||null==o||"boolean"==typeof o||"symbol"==typeof o)return String(o);if("bigint"==typeof o)return String(o)+"n";if("object"==typeof o||"function"==typeof o){if(c.has(o))return a;if(c.add(o),i.uC in o)return e((0,i.f6)(o));if(Symbol.iterator in o)return`${o.constructor.name}(${t(Array.from(o),f)})`;let r=(e=>{try{return Reflect.ownKeys(e)}catch{return["[ownKeys threw]"]}})(o);if(!u||r.length<=1){let e=`{${r.map(e=>`${s(e)}:${t(o[e],f)}`).join(",")}}`;return d(o,e)}let n=`{
|
|
153
166
|
${r.map(e=>{let r;return`${r=f+1,u.repeat(r)}${s(e)}: ${t(o[e],f+1)}`}).join(",\n")}
|
|
154
|
-
${u.repeat(f)}}`;return d(o,n)}return String(o)}(t,0)},IB:()=>c,Yq:()=>l,_r:()=>s,jV:()=>o})},4650(e,t,r){var n=r(9138);let i=e=>()=>e,a=i(!0),s=i(!1),o=i(null),l=i(void 0);function c(e,...t){return(0,n.tT)(e,t)}function u(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 d(e){let t=new WeakMap;return r=>{if(t.has(r))return t.get(r);let n=e(r);return t.set(r,n),n}}r.d(t,{Bj:()=>d,Fs:()=>c,L3:()=>u},{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})},4450(e,t,r){var n=r(4650),i=r(6516),a=r(5369);let s="~effect/interfaces/Hash",o=e=>{switch(typeof e){case"number":return f(e);case"bigint":return h(e.toString(10));case"boolean":case"symbol":return h(String(e));case"string":return h(e);case"undefined":return h("undefined");case"function":case"object":if(null===e)return h("null");{if(e instanceof Date)return h(e.toISOString());if(e instanceof RegExp)return h(e.toString());if(i.J.has(e))return l(e);if(x.has(e))return x.get(e);let t=function(e,t){if(_.has(e))return h("[Circular]");_.add(e);let r=t();return _.delete(e),r}(e,()=>{if(d(e))return e[s]();if("function"==typeof e)return l(e);if(Array.isArray(e)||ArrayBuffer.isView(e))return y(e);if(e instanceof Map)return b(e);if(e instanceof Set)return v(e);return m(e)});return x.set(e,t),t}default:throw Error(`BUG: unhandled typeof ${typeof e} - please report an issue at https://github.com/Effect-TS/effect/issues`)}},l=e=>(w.has(e)||w.set(e,f(Math.floor(Math.random()*Number.MAX_SAFE_INTEGER))),w.get(e)),c=(0,n.XY)(2,(e,t)=>53*e^t),u=e=>0xbfffffff&e|e>>>1&0x40000000,d=e=>(0,a.i5)(e,s),f=e=>{if(e!=e)return h("NaN");if(e===1/0)return h("Infinity");if(e===-1/0)return h("-Infinity");let t=0|e;for(t!==e&&(t^=0xffffffff*e);e>0xffffffff;)t^=e/=0xffffffff;return u(t)},h=e=>{let t=5381,r=e.length;for(;r;)t=33*t^e.charCodeAt(--r);return u(t)},p=(e,t)=>{let r=12289;for(let n of t)r^=c(o(n),o(e[n]));return u(r)},m=e=>p(e,(0,i.X)(e)),g=(e,t)=>r=>{let n=e;for(let e of r)n^=t(e);return u(n)},y=g(6151,o),b=g(h("Map"),([e,t])=>c(o(e),o(t))),v=g(h("Set"),o),w=new WeakMap,x=new WeakMap,_=new WeakSet;r.d(t,{},{HR:s,QK:m,YO:y,Yj:h,ai:f,kg:c,tW:o,uN:p,yT:l})},6400(e,t,r){var n=r(6470),i=r(5369),a=r(1743);let s=Symbol.for("nodejs.util.inspect.custom"),o=e=>{try{if(i.i5(e,"toJSON")&&i.Tn(e.toJSON)&&0===e.toJSON.length)return e.toJSON();if(Array.isArray(e))return e.map(o)}catch{return"[toJSON threw]"}return(0,a.E$)(e)};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}):String(e)}catch{return String(e)}},aB:o,os:{toJSON(){return o(this)},[s](){return this.toJSON()},toString(){return(0,n.GP)(this.toJSON())}}})},8496(e,t,r){var n=r(4650),i=r(3833),a=r(5369);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})},5089(e,t,r){var n=r(8619),i=r(3717),a=r(4650),s=r(8433),o=r(1136),l=r(9138),c=r(2672);let u="~effect/Layer/MemoMap",d={"~effect/Layer":{_ROut:a.D_,_E:a.D_,_RIn:a.D_},pipe(){return(0,l.tT)(this,arguments)}},f=e=>{let t=Object.create(d);return t.build=e,t},h=e=>f((t,r)=>{let n=c.Fp(r);return o.cfM(e(t,n),e=>"Failure"===e._tag?c.VN(n,e):o.rIH)});class p{get[u](){return u}parent;constructor(e){this.parent=e}map=new Map;get(e,t){let r=this.map.get(e);if(r)return r.observers++,o.hgn(o.Uio(t,e=>r.finalizer(e)),r.effect);return this.parent?.get(e,t)}getOrElseMemoize(e,t,r){var n;let a,s,l,u=this.get(e,t);return u?u:(n=this,a=c.LZ(),s=i.LZ(),l={observers:1,effect:i.Tx(s),finalizer:t=>o.DYE(()=>(l.observers--,0===l.observers)?(n.map.delete(e),c.VN(a,t)):o.rIH)},n.map.set(e,l),o.Uio(t,l.finalizer).pipe(o.qIB(()=>r(n,a)),o.cfM(e=>(l.effect=e,i.Vw(s,e)))))}}let m=()=>new p;class g extends n.kl()("effect/Layer/CurrentMemoMap"){static forkOrCreate(e){let t=n.Y6(e,g);return t?new p(t):m()}}let y=(0,a.XY)(3,(e,t,r)=>o.PfK(o.TjK(e.build(t,r),n.WQ(g,t)),g,t)),b=(0,a.XY)(2,(e,t)=>s.R6(r=>y(e,g.forkOrCreate(r.context),t))),v=e=>f((0,a.dY)(o.PyW(e))),w=(e,t)=>x(o.TjK(t,t=>n.L8(e,t))),x=e=>{var t;let r;return t=(t,r)=>c.Gt(e,r),r=h((e,n)=>e.getOrElseMemoize(r,n,t))},_=(e,t,r)=>{let i=c.Fp(r,"parallel");return o.jJl(e,e=>e.build(t,c.Fp(i,"sequential")),{concurrency:e.length}).pipe(o.TjK(e=>n.Um(...e)))},k=(e,t,r)=>h((n,i)=>o.qIB(Array.isArray(t)?_(t,n,i):t.build(n,i),t=>e.build(n,i).pipe(o.PpN(t),o.TjK(e=>r(e,t))))),S=(0,a.XY)(2,(e,t)=>k(e,t,a.D_)),O=(0,a.XY)(2,(e,t)=>k(e,t,(e,t)=>n.h1(t,e)));r.d(t,{},{Gt:S,H7:y,LT:b,Py:function(){return 1==arguments.length?e=>v(n.L8(arguments[0],e)):v(n.L8(arguments[0],arguments[1]))},QZ:function(){return 1==arguments.length?e=>w(arguments[0],e):w(arguments[0],arguments[1])},S5:O,Um:(...e)=>h((t,r)=>_(e,t,r)),j6:m})},3833(e,t,r){r.r(t),r.d(t,{Do:()=>eh,all:()=>G,andThen:()=>B,as:()=>U,asVoid:()=>F,bind:()=>ef,bindTo:()=>eu,composeK:()=>J,contains:()=>el,containsWith:()=>eo,exists:()=>ec,filter:()=>er,filterMap:()=>et,firstSomeOf:()=>E,flatMap:()=>L,flatMapNullishOr:()=>Y,flatten:()=>q,fromIterable:()=>v,fromNullOr:()=>A,fromNullishOr:()=>$,fromUndefinedOr:()=>I,gen:()=>ep,getFailure:()=>x,getOrElse:()=>_,getOrNull:()=>T,getOrThrow:()=>j,getOrThrowWith:()=>P,getOrUndefined:()=>N,getSuccess:()=>w,isNone:()=>m,isOption:()=>p,isSome:()=>g,let:()=>ed,lift2:()=>ea,liftNullishOr:()=>C,liftPredicate:()=>es,liftThrowable:()=>M,makeCombinerFailFast:()=>eg,makeEquivalence:()=>en,makeOrder:()=>ei,makeReducer:()=>em,makeReducerFailFast:()=>ey,map:()=>D,match:()=>y,none:()=>f,orElse:()=>k,orElseResult:()=>O,orElseSome:()=>S,partitionMap:()=>ee,product:()=>K,productMany:()=>V,reduceCompact:()=>Q,some:()=>h,tap:()=>z,toArray:()=>Z,toRefinement:()=>b,void:()=>R,zipLeft:()=>W,zipRight:()=>X,zipWith:()=>H});var n=r(8036),i=r(1044),a=r(4650),s=r(2849),o=r(5091),l=r(4403),c=r(6364),u=r(5369);function d(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})}}let f=()=>o.dv,h=o.zN,p=o.oL,m=o.$I,g=o.Ru,y=(0,a.XY)(2,(e,{onNone:t,onSome:r})=>m(e)?t():r(e.value)),b=e=>t=>g(e(t)),v=e=>{for(let t of e)return h(t);return f()},w=l.Oz,x=l.L8,_=(0,a.XY)(2,(e,t)=>m(e)?t():e.value),k=(0,a.XY)(2,(e,t)=>m(e)?t():e),S=(0,a.XY)(2,(e,t)=>m(e)?h(t()):e),O=(0,a.XY)(2,(e,t)=>m(e)?D(t(),l.Py):D(e,l.fJ)),E=e=>{let t=f();for(t of e)if(g(t))break;return t},$=e=>null==e?f():h(e),I=e=>void 0===e?f():h(e),A=e=>null===e?f():h(e),C=e=>(...t)=>$(e(...t)),T=_(a.XR),N=_(a.MN),M=e=>(...t)=>{try{return h(e(...t))}catch{return f()}},P=(0,a.XY)(2,(e,t)=>{if(g(e))return e.value;throw t()}),j=P(()=>Error("getOrThrow called on a None")),D=(0,a.XY)(2,(e,t)=>m(e)?f():h(t(e.value))),U=(0,a.XY)(2,(e,t)=>D(e,()=>t)),F=U(void 0),R=h(void 0),L=(0,a.XY)(2,(e,t)=>m(e)?f():t(e.value)),B=(0,a.XY)(2,(e,t)=>L(e,e=>{let r=(0,u.Tn)(t)?t(e):t;return p(r)?r:h(r)})),Y=(0,a.XY)(2,(e,t)=>m(e)?f():$(t(e.value))),q=L(a.D_),X=(0,a.XY)(2,(e,t)=>L(e,()=>t)),W=(0,a.XY)(2,(e,t)=>z(e,()=>t)),J=(0,a.XY)(2,(e,t)=>r=>L(e(r),t)),z=(0,a.XY)(2,(e,t)=>L(e,e=>D(t(e),()=>e))),K=(e,t)=>g(e)&&g(t)?h([e.value,t.value]):f(),V=(e,t)=>{if(m(e))return f();let r=[e.value];for(let e of t){if(m(e))return f();r.push(e.value)}return h(r)},G=e=>{if(Symbol.iterator in e){let t=[];for(let r of e){if(m(r))return f();t.push(r.value)}return h(t)}let t={};for(let r of Object.keys(e)){let n=e[r];if(m(n))return f();t[r]=n.value}return h(t)},H=(0,a.XY)(3,(e,t,r)=>D(K(e,t),([e,t])=>r(e,t))),Q=(0,a.XY)(3,(e,t,r)=>{let n=t;for(let t of e)g(t)&&(n=r(n,t.value));return n}),Z=e=>m(e)?[]:[e.value],ee=(0,a.XY)(2,(e,t)=>{if(m(e))return[f(),f()];let r=t(e.value);return l.N6(r)?[h(r.failure),f()]:[f(),h(r.success)]}),et=(0,a.XY)(2,(e,t)=>{if(m(e))return f();let r=t(e.value);return l.oJ(r)?h(r.success):f()}),er=(0,a.XY)(2,(e,t)=>m(e)?f():t(e.value)?h(e.value):f()),en=e=>i.L8((t,r)=>m(t)?m(r):!m(r)&&e(t.value,r.value)),ei=e=>c.L8((t,r)=>g(t)?g(r)?e(t.value,r.value):1:-1),ea=e=>(0,a.XY)(2,(t,r)=>H(t,r,e)),es=(0,a.XY)(2,(e,t)=>t(e)?h(e):f()),eo=e=>(0,a.XY)(2,(t,r)=>!m(t)&&e(t.value,r)),el=eo(n.jI()),ec=(0,a.XY)(2,(e,t)=>!m(e)&&t(e.value)),eu=s.Jr(D),ed=s.zM(D),ef=s.oI(D,L),eh=h({}),ep=(...e)=>{let t=(1===e.length?e[0]:e[1].bind(e[0]))(),r=t.next();for(;!r.done;){let e=r.value;if(m(e))return e;r=t.next(e.value)}return h(r.value)};function em(e){return d((t,r)=>m(t)?r:m(r)?t:h(e.combine(t.value,r.value)),f())}function eg(e){return{combine:(t,r)=>m(t)||m(r)?f():h(e.combine(t.value,r.value))}}function ey(e){let t=eg(e).combine,r=h(e.initialValue);return d(t,r,e=>{let n=r;for(let r of e)if(m(n=t(n,r)))break;return n})}},6364(e,t,r){var n=r(4650);function i(e){return(t,r)=>t===r?0:e(t,r)}let a=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),s=i((e,t)=>e<t?-1:1),o=(0,n.XY)(2,(e,t)=>i((r,n)=>e(t(r),t(n)))),l=o(a,e=>e.getTime());function c(e){return i((t,r)=>{let n=t.length,i=r.length,s=Math.min(n,i);for(let n=0;n<s;n++){let i=e(t[n],r[n]);if(0!==i)return i}return a(n,i)})}function u(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 d=e=>(0,n.XY)(2,(t,r)=>-1===e(t,r)),f=e=>(0,n.XY)(2,(t,r)=>1===e(t,r)),h=e=>(0,n.XY)(2,(t,r)=>t===r||1>e(t,r)?t:r),p=e=>(0,n.XY)(2,(t,r)=>t===r||e(t,r)>-1?t:r);r.d(t,{L8:()=>i,O3:()=>c,_k:()=>u},{Bt:e=>(0,n.XY)(2,(t,r)=>!d(e)(t,r.minimum)&&!f(e)(t,r.maximum)),OW:e=>(0,n.XY)(2,(t,r)=>-1!==e(t,r)),Qw:s,T9:p,bi:e=>(0,n.XY)(2,(t,r)=>1!==e(t,r)),hl:d,jk:h,n9:l,qE:e=>(0,n.XY)(2,(t,r)=>h(e)(r.maximum,p(e)(r.minimum,t))),wN:a,yJ:f,zQ:o})},9138(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,tT:n})},5369(e,t,r){var n=r(4650);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 c(e){return i(e)||a(e)||l(e)}function u(e){return"function"==typeof e}function d(e){return void 0===e}function f(e){return void 0!==e}function h(e){return null!==e}function p(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||u(e)}let w=(0,n.XY)(2,(e,t)=>v(e)&&t in e),x=(0,n.XY)(2,(e,t)=>w(e,"_tag")&&e._tag===t);function _(e){return e instanceof Error}function k(e){return e instanceof Date}function S(e){return w(e,Symbol.iterator)||i(e)}function O(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:()=>h,Tn:()=>u,Vq:()=>m,b0:()=>d,bJ:()=>_,gd:()=>O,hL:()=>c,sI:()=>o,t8:()=>y,uy:()=>p,xZ:()=>S},{$J:x,i5:w})},4505(e,t,r){var n=r(8543),i=r(7598),a=r(956),s=r(4650),o=r(1136),l=r(995);let c=(0,s.XY)(2,(e,t)=>o.rNk(e,f,e=>t(e))),u=e=>"Fail"===e._tag&&n.$L(e.error),d=a.Bh(n.kh,e=>n.$L(e)?l.Py(e):l.fJ(e));n.kh;let f=a.Bh(n.kh,e=>n.$L(e)?l.Py(e.value):l.fJ(e)),h=(0,s.XY)(2,(e,t)=>o.khu(e,{onSuccess:t.onSuccess,onFailure:e=>{let r=d(e);return l.N6(r)?t.onFailure(r.failure):t.onDone(r.success.value)}}));r.d(t,{},{Og:e=>e.reasons.some(u),aU:e=>{let t=d(e);return l.N6(t)?i.AT(t.failure):i.Py(t.success.value)},m8:c,tv:h})},8099(e,t,r){var n=r(4650);let i=(0,n.XY)(2,(e,t)=>{let r=[];for(let n of o(e))r.push(t(n,e[n]));return r})((e,t)=>[e,t]),a=(0,n.XY)(2,(e,t)=>{let r={...e};for(let n of o(e))r[n]=t(e[n],n);return r}),s=(0,n.XY)(2,(e,t)=>{let r={};for(let n of o(e))t(e[n],n)&&(r[n]=e[n]);return r}),o=e=>Object.keys(e);r.d(t,{},{DM:e=>0===Object.keys(e).length,Tj:a,Wo:i,pb:s})},1743(e,t,r){var n=r(9138),i=r(5369);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",c={"~effect/Context":{},mapUnsafe:new Map,pipe(){return(0,n.tT)(this,arguments)}};r.d(t,{E$:()=>s,f6:()=>o},{fL:l,uC:a})},3864(e,t,r){var n=r(1136),i=r(8344);i.F8;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})},995(e,t,r){var n=r(4650),i=r(5091),a=r(4403);let s=a.Py,o=a.fJ;a.sV,a.aI;let l=a.N6,c=a.oJ;a.Oz,a.L8;let u=(0,n.XY)(2,(e,t)=>l(e)?o(t(e.failure)):s(e.success)),d=(0,n.XY)(2,(e,t)=>c(e)?s(t(e.success)):o(e.failure)),f=(0,n.XY)(2,(e,{onFailure:t,onSuccess:r})=>l(e)?t(e.failure):r(e.success));i.dv,r.d(t,{},{N6:l,Py:s,Tj:d,YW:f,fJ:o,oJ:c,xm:u})},3587(e,t,r){var n=r(8543),i=r(8619),a=r(2302),s=r(4650),o=r(8433),l=r(1136),c=r(9138),u=r(5369),d=r(4505);let f="~effect/Schedule",h=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})}),p={[f]:{_Out:s.D_,_In:s.D_,_Env:s.D_},pipe(){return(0,c.tT)(this,arguments)}},m=e=>{let t=Object.create(p);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 w(e,({attempt:e,elapsed:n})=>l.PyW((void 0===t.times||e<=t.times)&&(void 0===r||a.bi(a.ne(n),r))))}),w=(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,c]=e,u=t({...r(i,a),output:s,duration:c});return l.qIB((0,o.yw)(u)?u:l.PyW(u),t=>t?l.PyW(e):n.Vw(s))})}))),x=b(a.v_);r.d(t,{},{E6:w,GM:e=>(0,u.i5)(e,f),d3:h,i4:x,jB:v,ji:b,le:e=>m(l.TjK(y(e),e=>(t,r)=>d.tv(e(t,r),{onSuccess:e=>l.PyW([r,e[1]]),onFailure:l.ATB,onDone:()=>n.Vw(r)}))),t5:e=>w(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)})})}))})},8469(e,t,r){var n=r(8619);let i=n.Or("effect/Scheduler",{defaultValue:()=>new o}),a="setImmediate"in globalThis?e=>{let t=globalThis.setImmediate(e);return()=>globalThis.clearImmediate(t)}:e=>{let t=setTimeout(e,0);return()=>clearTimeout(t)};class s{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 o{executionMode;setImmediate;constructor(e="async",t=a){this.executionMode=e,this.setImmediate=t}shouldYield(e){return e.currentOpCount>=e.maxOpsBeforeYield}makeDispatcher(){return new l(this.setImmediate)}}class l{tasks=new s;running=void 0;setImmediate;constructor(e=a){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 c=n.Or("effect/Scheduler/MaxOpsBeforeYield",{defaultValue:()=>2048}),u=n.Or("effect/Scheduler/PreventSchedulerYield",{defaultValue:()=>!1});r.d(t,{FG:()=>o},{Zm:c,_F:i,hf:u})},8861(e,t,r){let n,i,a,s;r.d(t,{O31:()=>eS,v8c:()=>ev,Xsx:()=>e2,Nej:()=>ez,kld:()=>eX,PSP:()=>e3,wYs:()=>eK,Aiz:()=>eV,uSQ:()=>ep,xCb:()=>function e(t){let r=t.map(ep);return es(E.KC(r,"anyOf",void 0),{literals:t,members:r,mapMembers(e){return eE(e(this.members))},pick:t=>e(t),transform:e=>eE(r.map((t,r)=>t.transform(e[r])))})},ukk:()=>eY,wNn:()=>eb,pHd:()=>eG,mSG:()=>ek,QfV:()=>ey,_kM:()=>e_,X0d:()=>e5,gPz:()=>eE,$r1:()=>em,rvE:()=>Q,usV:()=>Z,hzj:()=>H,GLL:()=>eC,_Re:()=>en,q$Z:()=>ei,svK:()=>ea,is:()=>er,MIs:()=>eF,yJO:()=>eR,OWK:()=>eL,tJb:()=>eB,Pto:()=>eU,nfo:()=>ej,HNH:()=>eD,fXn:()=>eO,Wa3:()=>ec,lqM:()=>el,Qrq:()=>eo,YPB:()=>eA,DYE:()=>eI,TcI:()=>eP,lHk:()=>e8,O3D:()=>ed,_oz:()=>e6,rcy:()=>et,AxX:()=>eu,tiU:()=>eM,E$i:()=>eN});var o,l,c,u,d,f,h=r(631),p=r(8543),m=r(2718),g=r(4705),y=r(2302),b=r(7720),v=(r(8983),r(7598)),w=r(6470),x=r(8433),_=r(8927),k=r(8036),S=r(5369),O=r(8099);S.gd;var E=r(9177),$=r(4888),I=r(9138);let A="~effect/SchemaError/SchemaError";class C extends m.rN("SchemaError"){[A]=A;constructor(e){super({issue:e})}get message(){return this.issue.toString()}toString(){return`SchemaError(${this.message})`}}var T=r(4858);let N="~effect/Schema/Schema",M={[N]:N,pipe(){return I.tT(this,arguments)},annotate(e){return this.rebuild(E.fz(this.ast,e))},annotateKey(e){return this.rebuild(E.us(this.ast,e))},check(...e){return this.rebuild(E.EJ(this.ast,e))}};function P(e,t){let r=Object.create(M);t&&Object.assign(r,t),r.ast=e,r.rebuild=e=>P(e,t);let n=T.o(r);return r.makeEffect=(e,t)=>j(n(e,t)),r.make=T.L8(r),r.makeOption=T.YY(r),r}function j(e){return b.Tyx(e,e=>b.pVV(()=>p.Tj(e,e=>new C(e))))}let D=U(function(e){switch(e._tag){case"BigInt":case"Symbol":case"UniqueSymbol":return 0;default:return 1}});function U(e){return t=>{let r=new Map;for(let e=0;e<t.length;e++)r.set(E.O3(t[e]),e);let n=[...t].sort((t,n)=>{t=E.O3(t),n=E.O3(n);let i=e(t),a=e(n);return i!==a?i-a:r.get(t)-r.get(n)});return n.some((e,r)=>e!==t[r])?n:t}}let F=new Set(["~structural","~sentinels","meta","arbitrary","toArbitrary","toEquivalence","toFormatter","toCodec","toCodecJson","toCodecIso",E.YA]),R=new Set(["title","description","default","examples","readOnly","writeOnly","format","contentEncoding","contentMediaType","contentSchema"]);function L(e){if(void 0!==e){let t=O.pb(e,(e,t)=>!F.has(t));if(!O.DM(t))return{annotations:t}}}function B(e,t){return e.some(e=>{switch(e._tag){case"Filter":return e.meta._tag===t;case"FilterGroup":return B(e.checks,t)}})}function Y(e,t){if(0===Object.keys(e).length)return t;let r=Object.keys(t).length;if(0===r)return e;let n=Array.isArray(t.allOf)&&1===r?t.allOf:[t];return Array.isArray(e.allOf)?{...e,allOf:[...e.allOf,...n]}:"string"==typeof e.$ref?{allOf:[e,...n]}:{...e,allOf:n}}function q(e){switch(e._tag){case"Literal":return globalThis.String(e.literal).replace(/[/\\^$*+?.()|[\]{}]/g,"\\$&");case"String":return E.XV;case"Number":return E.bm;case"TemplateLiteral":return e.parts.map(q).join("");case"Union":return e.types.map(q).join("|");default:throw new globalThis.Error("Unsupported part",{cause:e})}}var X=r(3833),W=r(6364),J=r(995),z=r(8469),K=r(6310),V=r(6030),G=r(5348);function H(){return(e,t,r)=>es(new E.D6(e.map(E.hu),e=>t(e.map(e=>es(e))),r))}r(1044)._k,W._k;function Q(e){return t=>eh(eh(t).annotate(e))}function Z(e){return t=>t.rebuild(E.us(t.ast,e))}function ee(e){return v.oJ(e)?e.value:{issues:[{message:p.j9(e.cause)}]}}function et(e,t){let r=T._R(e),n={errors:"all",...t?.parseOptions},i=V.ID(t),a=e=>{let t=new z.FG,a=b.MY7(b.YWq(r(e,n),{onFailure:i,onSuccess:e=>({value:e})}),{scheduler:t});a.currentDispatcher?.flush();let s=a.pollUnsafe();return s?ee(s):new Promise(e=>{a.addObserver(t=>{e(ee(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 er=T.is;function en(e,t){let r=T._R(e,t);return(e,t)=>j(r(e,t))}function ei(e,t){let r=T.q$(e,t);return(e,t)=>J.xm(r(e,t),e=>new C(e))}function ea(e,t){let r=en(e,t);return(e,t)=>(function(e){let t=b.lKS(e);if(v.oJ(t))return t.value;throw function(e,t){let r;for(let i of e.reasons){var n;if(!p.lC(i)||(n=i.error,!S.i5(n,A)))throw new globalThis.Error(t,{cause:e});r??=i.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))}T.kv,T.y9,T.mR,T.IQ,T.GP;let es=P,eo=e=>es(E.Qr(e.ast),{schema:e}),el=e=>eo(e$(e)),ec=e=>es(E.W(e.ast),{schema:e}),eu=e=>es(E.Ax(e.ast),{schema:e}),ed=e=>es(E.O3(e.ast),{schema:e}),ef="~effect/Schema/flip";function eh(e){return S.i5(e,ef)&&e[ef]===ef?e.schema.rebuild(E.UU(e.ast)):es(E.UU(e.ast),{[ef]:ef,schema:e})}function ep(e){let t=es(new E.uS(e),{literal:e,transform:r=>t.pipe(eC(ep(r),{decode:K.pd(()=>r),encode:K.pd(()=>e)}))});return t}E.Zm,E.bz;let em=es(E.L5);E.ch;let eg=es(E.Vx),ey=es(E.Yj),eb=es(E.ai),ev=es(E.zM),ew=es(E.HR);function ex(e,t){return es(e,{fields:t,mapFields(e,t){let r=e(this.fields);return ex(E.w3(r,t?.unsafePreserveChecks?this.ast.checks:void 0),r)}})}function e_(e){return ex(E.w3(e,void 0),e)}function ek(e,t,r){let n=r?.keyValueCombiner?.decode||r?.keyValueCombiner?.encode?new E.E$(r.keyValueCombiner.decode,r.keyValueCombiner.encode):void 0;return es(E.g1(e.ast,t.ast,n),{key:e,value:t})}E.we,E.rI,E.ZG;let eS=e=>es(new E.DO(!1,[],[e.ast]),{value:e}),eO=e=>es(new E.DO(!0,e.ast.elements,e.ast.rest),{schema:e});function eE(e,t){return function e(t,r){return es(t,{members:r,mapMembers(t,r){let n=t(this.members);return e(E.KC(n,this.ast.mode,r?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}(E.KC(e,t?.mode??"anyOf",void 0),e)}let e$=e=>eE([e,eg]);function eI(e){return es(new E.V3(()=>e().ast))}function eA(e,t){return r=>es(E.EJ(r.ast,[E.D$(e,t)]),{schema:r})}function eC(e,t){return r=>es(E.GL(r.ast,e.ast,t?G.L8(t):G.le()),{from:r,to:e})}function eT(e){return b.Tyx(e,e=>b.pVV(()=>p.Tj(e,e=>e.issue)))}function eN(e,t){let r=t?.encodingStrategy==="omit"?K.cJ():K.le();return t=>eo(ed(t)).pipe(eC(t,{decode:K.IQ(eT(e)),encode:r}))}function eM(e,t){let r=t?.encodingStrategy==="omit"?K.cJ():K.le();return t=>el(ed(t)).pipe(eC(t,{decode:K.IQ(eT(e)),encode:r}))}function eP(e){var t;return ep(e).pipe((t=b.PyW(e),e=>es(E.Ez(e.ast,eT(t)),{schema:e})))}function ej(){return(e,t)=>new E.N_(e.ast,G.L8(t))}let eD=E.HN,eU=E.Pt;function eF(e){return eD(e=>globalThis.Number.isFinite(e),{expected:"a finite number",meta:{_tag:"isFinite"},arbitrary:{constraint:{noInfinity:!0,noNaN:!0}},...e})}E.bk,E.ZB,E.IZ;let eR=(f={order:W.wN,annotate:e=>({meta:{_tag:"isGreaterThan",exclusiveMinimum:e}})},n=W.yJ(f.order),i=f.formatter??w.GP,(e,t)=>eD(t=>n(t,e),{expected:`a value greater than ${i(e)}`,arbitrary:{constraint:{ordered:{order:f.order,minimum:e,exclusiveMinimum:!0}}},...f.annotate?.(e),...t})),eL=(o={order:W.wN,annotate:e=>({meta:{_tag:"isGreaterThanOrEqualTo",minimum:e}})},a=W.OW(o.order),s=o.formatter??w.GP,(e,t)=>eD(t=>a(t,e),{expected:`a value greater than or equal to ${s(e)}`,arbitrary:{constraint:{ordered:{order:o.order,minimum:e}}},...o.annotate?.(e),...t}));function eB(e,t){return e=Math.max(0,Math.floor(e)),eD(t=>t.length>=e,{expected:`a value with a length of at least ${e}`,meta:{_tag:"isMinLength",minLength:e},[E.C3]:!0,arbitrary:{constraint:{minLength:e}},...t})}W.wN,W.wN,W.wN,W.n9,W.n9,W.n9,W.n9,W.n9,W.Qw,W.Qw,W.Qw,W.Qw,W.Qw,h.pH,h.pH,h.pH,h.pH,h.pH;let eY=ey.check(eB(1,void 0)),eq=[];function eX(e){let t=e?.includeStack===!0|2*(e?.excludeCause===!0),r=eq[t];if(void 0!==r)return r;let n=tr.pipe(eC(em,G.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 eq[t]=n,n}G.nY;let eW=ey.annotate({expected:"a string in ISO 8601 format that will be decoded as a Date"}),eJ=(l=globalThis.Date,c={typeConstructor:{_tag:"Date"},generation:{runtime:"Schema.Date",Type:"globalThis.Date"},expected:"Date",toCodecJson:()=>ej()(eW,G.YZ),toArbitrary:()=>(e,t)=>e.date(function(e,t){let r={...void 0};if(delete r.valid,e?.valid&&(r.noInvalidDate=!0),t?.minimum!==void 0){let e=(0,t.minimum),n=t.exclusiveMinimum?new globalThis.Date(e.getTime()+1):e;(void 0===r.min||n.getTime()>r.min.getTime())&&(r.min=n)}if(t?.maximum!==void 0){let e=(0,t.maximum),n=t.exclusiveMaximum?new globalThis.Date(e.getTime()-1):e;(void 0===r.max||n.getTime()<r.max.getTime())&&(r.max=n)}return r}(t?.constraint,t?.constraint?.ordered?.order===W.n9?t.constraint.ordered:void 0))},u=e=>e instanceof l,d=c,H()([],()=>(e,t)=>u(e)?b.PyW(e):b.fJG(new V.eE(t,X.some(e))),d));G.YZ,G.HO;let ez=eJ.check(eD(e=>!isNaN(e.getTime()),{expected:"a valid date",meta:{_tag:"isDateValid"},arbitrary:{constraint:{valid:!0}},...void 0}));y.n$,G.EJ,G.m8,G.PE;h.s5,G.dG;let eK=eb.check(eF()),eV=eb.check(eD(e=>globalThis.Number.isSafeInteger(e),{expected:"an integer",meta:{_tag:"isInt"},arbitrary:{constraint:{integer:!0}},...void 0}));G.ZK,G.ZK,G.R7,G.Ct,G.LL,G.Y5,G.Pp;let eG=eE([eK,ew,ey]);G.U0,g.yF,G.Nh,g.Xy,g.lU,g.rg,G.yd,g.kQ,G.XU,G.d9;let eH=globalThis.Symbol.for("immer-draftable"),eQ={};function eZ(e,t,r,n,i){var a,s,o;let l,c=(a=r,s=t,o=n,e=>{if(void 0!==l)return l;let t=new G.IT(K.pd(t=>new e(t)),K.le());return l=eC(es(new E.D6([a.ast],()=>(t,r)=>t instanceof e||S.i5(t,e0(s))?b.PyW(t):b.fJG(new V.eE(r,X.some(t))),{identifier:s,[E.YA]:([e])=>new E.N_(e,t),toCodec:([e])=>new E.N_(e.ast,t),toArbitrary:([t])=>()=>({arbitrary:t.arbitrary.map(t=>new e(t)),terminal:t.terminal?.map(t=>new e(t))}),toFormatter:([t])=>r=>`${e.identifier}(${t(r)})`,"~sentinels":E.SL(a.ast),...o})),t)(a)}),u=e0(t),d=class extends e{constructor(...[e,t]){let n=t?.["~payload"],i=n?.token===eQ?n.value:r.make(e??{},t);super(i,{...t,disableChecks:!0,"~payload":{token:eQ,value:i}})}static [N]=N;get[u](){return u}static [eH]=!0;static identifier=t;static fields=r.fields;static get ast(){return c(this).ast}static pipe(){return I.tT(this,arguments)}static rebuild(e){return c(this).rebuild(e)}static make(e,t){return new this(e,t)}static makeOption(e,t){return T.YY(c(this))(e??{},t)}static makeEffect(e,t){return c(this).makeEffect(e??{},t)}static annotate(e){return this.rebuild(E.fz(this.ast,e))}static annotateKey(e){return this.rebuild(E.us(this.ast,e))}static check(...e){return this.rebuild(E.EJ(this.ast,e))}static extend(e){return(t,n)=>{let a=e1(t)?t:e_(t),s={...r.fields,...a.fields},o=E.w3(s,r.ast.checks,{identifier:e});return eZ(this,e,ex(E.EJ(o,a.ast.checks),s),n,i)}}static mapFields(e,t){return r.mapFields(e,t)}};return void 0!==i&&Object.assign(d.prototype,i(t)),d}function e0(e){return`~effect/Schema/Class/${e}`}function e1(e){return S.i5(e,N)&&e[N]===N}let e2=e=>(t,r)=>{let n=e1(t)?t:e_(t);return eZ(m.Xs,e,n,r,e=>({toString(){return`${e}(${(0,w.GP)({...this})})`}}))},e3=e=>(t,r)=>{let n=e1(t)?t:e_(t);return eZ(x.$D,e,n,r,e=>({name:e}))},e5=e=>(t,r,n)=>{let i=e1(r)?r.mapFields(e=>({_tag:eP(t),...e}),{unsafePreserveChecks:!0}):e_({_tag:eP(t),...r});return e3(e??t)(i,n)};function e6(e,t){let r=function(e,t){let{definitions:r,dialect:n,schemas:i}=function(e,t){let r=t?.generateDescriptions??!1,n=t?.additionalProperties??!1,i=t?.includeAnnotationKey,a=O.Tj(e.references,e=>s(e));return{dialect:"draft-2020-12",schemas:_.Tj(e.representations,e=>s(e)),definitions:a};function s(t){let r=function(t){switch(t._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":case"UniqueSymbol":return{type:"string",allOf:[{pattern:"^Symbol\\((.*)\\)$"}]};case"Declaration":return s(t.encodedSchema);case"Suspend":return s(t.thunk);case"Reference":return{$ref:`#/$defs/${t.$ref.replace(/~/g,"~0").replace(/\//g,"~1")}`};case"Never":return{not:{}};case"String":{let e={type:"string"};return void 0!==t.contentMediaType&&(e.contentMediaType=t.contentMediaType),void 0!==t.contentSchema&&(e.contentSchema=s(t.contentSchema)),e}case"Number":return B(t.checks,"isInt")?{type:"integer"}:B(t.checks,"isFinite")?{type:"number"}:{anyOf:[{type:"number"},{type:"string",enum:["NaN"]},{type:"string",enum:["Infinity"]},{type:"string",enum:["-Infinity"]}]};case"Boolean":return{type:"boolean"};case"Literal":{let e=t.literal;if("string"==typeof e)return{type:"string",enum:[e]};if("number"==typeof e)return{type:"number",enum:[e]};if("boolean"==typeof e)return{type:"boolean",enum:[e]};return{type:"string",enum:[String(e)]}}case"Enum":return s({_tag:"Union",types:t.enums.map(([e,t])=>({_tag:"Literal",literal:t,annotations:{title:e}})),mode:"anyOf",annotations:t.annotations});case"TemplateLiteral":{let e=t.parts.map(q).join("");return{type:"string",pattern:`^${e}$`}}case"Arrays":{if(t.rest.length>1)throw new globalThis.Error("Generating a JSON Schema for post-rest elements is not supported");let e={type:"array"},r=t.elements.length,n=t.elements.map(e=>{e.isOptional&&r--;let t=s(e.type),n=o(e.annotations);return n?Y(t,n):t});if(n.length>0?(e.prefixItems=n,e.maxItems=t.elements.length,r>0&&(e.minItems=r)):e.items=!1,t.rest.length>0){delete e.maxItems;let r=s(t.rest[0]);Object.keys(r).length>0?e.items=r:delete e.items}return e}case"Objects":{if(0===t.propertySignatures.length&&0===t.indexSignatures.length)return{anyOf:[{type:"object"},{type:"array"}]};let r={type:"object"},i={},a=[];for(let e of t.propertySignatures){let t=e.name;if("string"!=typeof t)throw new globalThis.Error(`Unsupported property signature name: ${(0,w.GP)(t)}`);let r=s(e.type),n=o(e.annotations);i[t]=n?Y(r,n):r,e.isOptional||a.push(t)}Object.keys(i).length>0&&(r.properties=i),a.length>0&&(r.required=a),r.additionalProperties=n;let l={};for(let n of t.indexSignatures){let t=s(n.type);1===Object.keys(t).length&&"not"in t&&(t=!1);let i=function t(r){switch(r._tag){default:throw new globalThis.Error(`Unsupported index signature parameter: ${r._tag}`);case"Reference":return t(e.references[r.$ref]);case"String":return function e(t){return t.flatMap(t=>{switch(t._tag){case"Filter":if("regExp"in t.meta)return[t.meta.regExp.source];return[];case"FilterGroup":return e(t.checks)}})}(r.checks);case"TemplateLiteral":return[`^${r.parts.map(q).join("")}$`];case"Union":return r.types.flatMap(t)}}(n.parameter);if(i.length>0)for(let e of i)l[e]=t;else r.additionalProperties=t}return Object.keys(l).length>0&&(r.patternProperties=l,delete r.additionalProperties),S.Gv(r.additionalProperties)&&O.DM(r.additionalProperties)&&delete r.additionalProperties,r}case"Union":{let e=t.types.map(s);if(0===e.length)return{not:{}};if(e.length>1){let t=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)r.push(e)}return{type:t,enum:r}}(e);if(t)return t}return"anyOf"===t.mode?{anyOf:e}:{oneOf:e}}}}(t);if("annotations"in t){let e=o(t.annotations);e&&(r={...r,...e})}if("checks"in t){var i,a;for(let e of(i=t.checks,a=r.type,i.map(function e(t){switch(t._tag){case"Filter":var r=t,n=a;let i=r.meta;if(!i)return;let l=function(e){switch(e._tag){case"isMinLength":return"array"===n?{minItems:e.minLength}:{minLength:e.minLength};case"isMaxLength":return"array"===n?{maxItems:e.maxLength}:{maxLength:e.maxLength};case"isLengthBetween":return"array"===n?{allOf:[{minItems:e.minimum},{maxItems:e.maximum}]}:{allOf:[{minLength:e.minimum},{maxLength:e.maximum}]};case"isPattern":case"isGUID":case"isULID":case"isBase64":case"isBase64Url":case"isStartsWith":case"isEndsWith":case"isIncludes":case"isUppercased":case"isLowercased":case"isCapitalized":case"isUncapitalized":case"isTrimmed":case"isStringFinite":case"isStringBigInt":case"isStringSymbol":return{pattern:e.regExp.source};case"isUUID":return{pattern:e.regExp.source,format:"uuid"};case"isFinite":case"isInt":return;case"isMultipleOf":return{multipleOf:e.divisor};case"isGreaterThanOrEqualTo":return{minimum:e.minimum};case"isLessThanOrEqualTo":return{maximum:e.maximum};case"isGreaterThan":return{exclusiveMinimum:e.exclusiveMinimum};case"isLessThan":return{exclusiveMaximum:e.exclusiveMaximum};case"isBetween":return{[e.exclusiveMinimum?"exclusiveMinimum":"minimum"]:e.minimum,[e.exclusiveMaximum?"exclusiveMaximum":"maximum"]:e.maximum};case"isUnique":return{uniqueItems:!0};case"isMinProperties":return{minProperties:e.minProperties};case"isMaxProperties":return{maxProperties:e.maxProperties};case"isPropertiesLengthBetween":return{minProperties:e.minimum,maxProperties:e.maximum};case"isPropertyNames":return{propertyNames:s(e.propertyNames)};case"isDateValid":return{format:"date-time"}}}(i),c=o(r.annotations);return c&&(l={...l,...c}),l;case"FilterGroup":{let r=t.checks.map(e).filter(e=>void 0!==e);if(0===r.length)return;let n={allOf:r},i=o(t.annotations);return i&&(n={...n,...i}),n}}}).filter(e=>void 0!==e)))r=Y(r,e)}return r}function o(e){if(void 0===e)return;let t={};if("string"==typeof e.title&&(t.title=e.title),"string"==typeof e.description?t.description=e.description:r&&"string"==typeof e.expected&&(t.description=e.expected),void 0!==e.default&&(t.default=e.default),Array.isArray(e.examples)&&(t.examples=e.examples),"boolean"==typeof e.readOnly&&(t.readOnly=e.readOnly),"boolean"==typeof e.writeOnly&&(t.writeOnly=e.writeOnly),"string"==typeof e.format&&(t.format=e.format),"string"==typeof e.contentEncoding&&(t.contentEncoding=e.contentEncoding),"string"==typeof e.contentMediaType&&(t.contentMediaType=e.contentMediaType),i)for(let[r,n]of Object.entries(e))!(void 0===n||R.has(r))&&i(r)&&(t[r]=n);if(Object.keys(t).length>0)return t}}({representations:[e.representation],references:e.references},t);return{dialect:n,schema:i[0],definitions:r}}(function(e){let{references:t,representations:r}=function(e){let t={},r=new Map,n=new Set,i=new Set;return{representations:_.Tj(e,e=>s(e)),references:t};function a(e){let t=e,r=0;for(;n.has(t);)t=`${e}${++r}`;return n.add(t),t}function s(e,n){let l=r.get(e);if(void 0!==l)return{_tag:"Reference",$ref:l};let c=E.S5(e),u=$.KE(e)??n;if(e!==c)return s(c,u);if(void 0!==u){let n=a(u);r.set(e,n);let i=o(e),s=t[u];return void 0!==s&&k.aI(i,s)?(r.set(e,u),{_tag:"Reference",$ref:u}):(t[n]=i,{_tag:"Reference",$ref:n})}if(i.has(e)){let t=a(`${e._tag}_`);return r.set(e,t),{_tag:"Reference",$ref:t}}i.add(e);let d=o(e);i.delete(e);let f=r.get(e);return void 0!==f?(t[f]=d,{_tag:"Reference",$ref:f}):d}function o(e){let t=L(e.annotations);switch(e._tag){case"Declaration":{let r,n=s((r=e.annotations?.toCodecJson??e.annotations?.toCodec,S.Tn(r)?E.ES(e,[r(e.typeParameters.map(e=>P(E.O3(e))))]):E.ch));return{_tag:"Declaration",typeParameters:e.typeParameters.map(e=>s(e)),encodedSchema:n,checks:l(e.checks),...t}}case"Null":case"Undefined":case"Void":case"Never":case"Unknown":case"Any":case"Boolean":case"Symbol":case"ObjectKeyword":return{_tag:e._tag,...t};case"String":{let r=e.annotations?.contentMediaType,n=e.annotations?.contentSchema;return{_tag:e._tag,checks:l(e.checks),...t,..."string"==typeof r&&E.zm(n)?{contentSchema:s(n)}:void 0}}case"Number":case"BigInt":return{_tag:e._tag,checks:l(e.checks),...t};case"Literal":return{_tag:e._tag,literal:e.literal,...t};case"UniqueSymbol":return{_tag:e._tag,symbol:e.symbol,...t};case"Enum":return{_tag:e._tag,enums:e.enums,...t};case"TemplateLiteral":return{_tag:e._tag,parts:e.parts.map(e=>s(e)),...t};case"Arrays":return{_tag:e._tag,elements:e.elements.map(e=>{let t=E.S5(e);return{isOptional:E.dK(t),type:s(e),...L(t.context?.annotations)}}),rest:e.rest.map(e=>s(e)),checks:l(e.checks),...t};case"Objects":return{_tag:e._tag,propertySignatures:e.propertySignatures.map(e=>{let t=E.S5(e.type);return{name:e.name,type:s(e.type),isOptional:E.dK(t),isMutable:E.bV(t),...L(t.context?.annotations)}}),indexSignatures:e.indexSignatures.map(e=>({parameter:s(e.parameter),type:s(e.type)})),checks:l(e.checks),...t};case"Union":{let r=D(e.types);return{_tag:e._tag,types:r.map(e=>s(e)),mode:e.mode,...t}}case"Suspend":return{_tag:"Suspend",checks:[],thunk:s(e.thunk()),...t}}}function l(e){return e?e.map(function(e){switch(e._tag){case"Filter":{let t=e.annotations?.meta;if(t)return{_tag:"Filter",meta:"isPropertyNames"===t._tag?{_tag:"isPropertyNames",propertyNames:s(t.propertyNames)}:t,...L(e.annotations)};return}case"FilterGroup":{let t=l(e.checks);if(_.CZ(t))return{_tag:"FilterGroup",checks:t,...L(e.annotations)}}}}).filter(e=>void 0!==e):[]}}([e]);return{representation:r[0],references:t}}(e.ast),t);return{dialect:"draft-2020-12",schema:r.schema,definitions:r.definitions}}function e8(e){return es(te(e.ast),{schema:e})}let e4=U(function(e){switch(e._tag){case"Null":case"Boolean":case"Number":case"BigInt":case"Symbol":case"UniqueSymbol":return 0;default:return 1}}),e9=new E.N_(new E.uS("null"),new G.IT(K.pd(()=>null),K.pd(()=>"null"))),e7=new E.N_(new E.gP([new E.uS("true"),new E.uS("false")],"anyOf"),new G.IT(K.pd(e=>"true"===e),K.Qf())),te=E.oZ(e=>{if(E.mi(e)&&e.annotations?.["~effect/Schema/SERIALIZER_ENSURE_ARRAY"]===!0)return e;let t=function(e,t,r){switch(e._tag){case"Declaration":{let n=e.annotations?.toCodecJson??e.annotations?.toCodec;if(S.Tn(n)){let r=n(E.HC(e)?e.typeParameters.map(e=>es(t(E.O3(e)))):[]),i=t(r.to);return E.ES(e,i===r.to?[r]:[new E.N_(i,r.transformation)])}return r(e)}case"Null":return E.ES(e,[e9]);case"Boolean":return E.ES(e,[e7]);case"Unknown":case"ObjectKeyword":return E.ES(e,[E.tC]);case"Enum":case"Number":case"Literal":case"UniqueSymbol":case"Symbol":case"BigInt":return e.toCodecStringTree();case"Objects":if(e.propertySignatures.some(e=>"string"!=typeof e.name))throw new globalThis.Error("Objects property names must be strings",{cause:e});return e.recur(t,E.xw);case"Union":{let r=e4(e.types);if(r!==e.types)return new E.gP(r,e.mode,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,te,e=>E.ES(e,[tt]));return t!==e&&E.dK(e)?E.nj(t):t}),tt=new E.N_(E.Vx,new G.IT(K.le(),K.pd(()=>void 0))),tr=es(E.LM);E.BF},9177(e,t,r){r.d(t,{DO:()=>Z,YA:()=>tc,D6:()=>D,bm:()=>en,LM:()=>td,E$:()=>ea,N_:()=>T,uS:()=>W,BF:()=>tf,XV:()=>e5,C3:()=>tu,V3:()=>ek,gP:()=>eb,fz:()=>eN,us:()=>eR,bz:()=>Y,EJ:()=>eP,oZ:()=>eU,we:()=>Q,Nt:()=>tn,zM:()=>G,Lp:()=>tl,SL:()=>em,GL:()=>eW,vr:()=>N,UU:()=>eH,hu:()=>ef,S5:()=>function e(t){return t.encoding?e(t.encoding[t.encoding.length-1].to):t},zm:()=>w,tF:()=>I,Lm:()=>O,HC:()=>x,c$:()=>E,bV:()=>eK,Et:()=>S,RP:()=>A,dK:()=>ez,Pt:()=>eI,Kg:()=>k,ZB:()=>tr,bk:()=>e4,IZ:()=>to,mi:()=>C,HN:()=>eE,D$:()=>e$,W:()=>eq,Zm:()=>B,ch:()=>U,ai:()=>V,ZG:()=>X,Qr:()=>eB,nj:()=>eL,xw:()=>e2,g1:()=>eJ,ES:()=>eC,Yj:()=>z,w3:()=>ed,HR:()=>H,O3:()=>eG,Ax:()=>eV,PV:()=>eh,Vx:()=>R,KC:()=>ep,L5:()=>q,tC:()=>th,rI:()=>L,Ez:()=>eX});var n=r(8927),i=r(8543),a=r(7720),s=r(7598),o=r(6470),l=r(4650),c=r(1136);function u(e,t,r){return"__proto__"===t?Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0}):e[t]=r,e}var d=r(4888),f=r(8045),h=r(3833),p=r(9138),m=r(5369),g=r(6310),y=r(6030),b=r(5348);function v(e){return t=>t._tag===e}function w(e){return m.i5(e,P)&&e[P]===P}let x=v("Declaration"),_=v("Never"),k=v("String"),S=v("Number"),O=v("Boolean"),E=v("Literal"),$=v("UniqueSymbol"),I=v("Arrays"),A=v("Objects"),C=v("Union");class T{to;transformation;constructor(e,t){this.to=e,this.transformation=t}}let N={};class M{isOptional;isMutable;defaultValue;annotations;constructor(e,t,r,n){this.isOptional=e,this.isMutable=t,this.defaultValue=r,this.annotations=n}}let P="~effect/Schema";class j{[P]=P;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}>`}}class D extends j{_tag="Declaration";typeParameters;run;encodingChecks;constructor(e,t,r,n,i,a,s){super(r,n,i,a),this.typeParameters=e,this.run=t,this.encodingChecks=s}getParser(){let e=this.run(this.typeParameters);return(t,r)=>h.isNone(t)?a.lwU:a.jkJ(e(t.value,this,r),h.some)}_rebuild(e,t,r){let n=eF(this.typeParameters,e);return n===this.typeParameters&&t===this.checks&&r===this.encodingChecks?this:new D(n,this.run,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(){let e=this.annotations?.expected;return"string"==typeof e?e:"<Declaration>"}}let U=new class extends j{_tag="Null";getParser(){return eQ(this,null)}getExpected(){return"null"}},F=new T(U,new b.IT(g.pd(()=>void 0),g.pd(()=>null))),R=new class extends j{_tag="Undefined";getParser(){return eQ(this,void 0)}toCodecJson(){return eC(this,[F])}getExpected(){return"undefined"}},L=new class extends j{_tag="Void";getParser(){var e;let t;return e=void 0,t=a.nGE(e),e=>"None"===e._tag?a.lwU:t}toCodecJson(){return eC(this,[F])}getExpected(){return"void"}},B=new class extends j{_tag="Never";getParser(){return eZ(this,m.Pd)}getExpected(){return"never"}},Y=new class extends j{_tag="Any";getParser(){return eZ(this,m.t8)}getExpected(){return"any"}},q=new class extends j{_tag="Unknown";getParser(){return eZ(this,m.t8)}getExpected(){return"unknown"}},X=new class extends j{_tag="ObjectKeyword";getParser(){return eZ(this,m.Fw)}getExpected(){return"object | array | function"}};class W 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 eQ(this,this.literal)}matchPart(e,t){return e===globalThis.String(this.literal)?this.literal:void 0}toCodecJson(){return"bigint"==typeof this.literal?J(this):this}toCodecStringTree(){return"string"==typeof this.literal?this:J(this)}getExpected(){return"string"==typeof this.literal?JSON.stringify(this.literal):globalThis.String(this.literal)}}function J(e){let t=globalThis.String(e.literal);return eC(e,[new T(new W(t),new b.IT(g.pd(()=>e.literal),g.pd(()=>t)))])}let z=new class extends j{_tag="String";getParser(){return eZ(this,m.Kg)}matchPart(e,t){return e0(this,e,t)}getExpected(){return"string"}};function K(e,t){return e.some(e=>{switch(e._tag){case"Filter":return e.annotations?.meta?._tag===t;case"FilterGroup":return K(e.checks,t)}})}let V=new class extends j{_tag="Number";getParser(){return eZ(this,m.Et)}matchKey(e,t){return this._match(e8,e,t)}matchPart(e,t){return this._match(e6,e,t)}_match(e,t,r){return e.test(t)?e0(this,globalThis.Number(t),r):void 0}toCodecJson(){return this.checks&&(K(this.checks,"isFinite")||K(this.checks,"isInt"))?this:eC(this,[ex])}toCodecStringTree(){return this.checks&&(K(this.checks,"isFinite")||K(this.checks,"isInt"))?eC(this,[e7]):eC(this,[te])}getExpected(){return"number"}},G=new class extends j{_tag="Boolean";getParser(){return eZ(this,m.Lm)}getExpected(){return"boolean"}},H=new class extends j{_tag="Symbol";getParser(){return eZ(this,m.Bm)}matchKey(e,t){return e0(this,e,t)}toCodecStringTree(){return eC(this,[ts])}getExpected(){return"symbol"}},Q=new class extends j{_tag="BigInt";getParser(){return eZ(this,m.sI)}matchPart(e,t){return tt.test(e)?e0(this,globalThis.BigInt(e),t):void 0}toCodecStringTree(){return eC(this,[ti])}getExpected(){return"bigint"}};class Z 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=t.findIndex(ez);if(-1!==l&&(t.slice(l+1).some(e=>!ez(e))||r.length>1))throw Error("A required element cannot follow an optional element. ts(1257)");if(r.length>1&&r.slice(1).some(ez))throw Error("An optional element cannot follow a rest element. ts(1266)")}getParser(e){let t=this,r=t.elements.map(t=>({ast:t,parser:e(t)})),n=t.rest.map(t=>({ast:t,parser:e(t)})),i=r.length,[s,...o]=n,l=o.length;function c(e,t){return t<i?r[t]:t>=e?o[t-e]:s}return a.vCS(function*(e,r){if("None"===e._tag)return e;let n=e.value;if(!Array.isArray(n))return yield*a.fJG(new y.eE(t,e));let s=n.length,o={ast:t,getParser:c,oinput:e,len:s,tailThreshold:Math.max(i,s-l),output:new globalThis.Array(s),issues:void 0,options:r},u=et(r?.concurrency),d=ee(o,n,{concurrency:u?.concurrency,end:0===t.rest.length?i:Math.max(s,i+l)});if(d&&(yield*d),0===t.rest.length&&s>i)for(let l=i;l<=s-1;l++){let i=new y.gm([l],new y.vF(t,n[l]));if("all"!==r.errors)return yield*a.fJG(new y.eC(t,e,[i]));o.issues?o.issues.push(i):o.issues=[i]}return o.issues?yield*a.fJG(new y.eC(t,e,o.issues)):h.some(o.output)})}_rebuild(e,t,r){let n=eF(this.elements,e),i=eF(this.rest,e);return n===this.elements&&i===this.rest&&t===this.checks&&r===this.encodingChecks?this:new Z(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"}}let ee=(0,c.h$X)()({onItem(e,t,r){let n=r<e.len?h.some(t):h.none();return e.getParser(e.tailThreshold,r).parser(n,e.options)},step(e,t,r,n){if("Failure"===r._tag)return er(e,e.ast,n,r);if("Some"===r.value._tag)e.output[n]=r.value.value;else{let t=e.getParser(e.tailThreshold,n);if(ez(t.ast))return;let r=new y.gm([n],new y.Mw(t.ast.context?.annotations));if("all"!==e.options.errors)return s.fJ(new y.eC(e.ast,e.oinput,[r]));e.issues?e.issues.push(r):e.issues=[r]}}}),et=e=>(e="unbounded"===e?1/0:e??1)>1?{concurrency:e}:void 0,er=(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 y.eC(t,e.oinput,[new y.gm([r],n)])));let o=new y.gm([r],a);if("all"!==e.options.errors)return s.fJ(new y.eC(t,e.oinput,[o]));e.issues?e.issues.push(o):e.issues=[o]},en="[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?";class ei{name;type;constructor(e,t){this.name=e,this.type=t}}class ea{decode;encode;constructor(e,t){this.decode=e,this.encode=t}flip(){return new ea(this.encode,this.decode)}}function es(e){switch(e._tag){case"String":case"Number":case"Symbol":case"TemplateLiteral":return!0;case"Union":return e.types.every(es);default:return!1}}class eo{parameter;type;merge;constructor(e,t,r){if(!(es(e)&&es(eG(e))))throw Error(`Invalid index signature parameter ${e._tag}`);if(this.parameter=e,this.type=t,this.merge=r,ez(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.")}}class el 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;let o=e.map(e=>e.name).filter((e,t,r)=>r.indexOf(e)!==t);if(o.length>0)throw Error(`Duplicate identifiers: ${JSON.stringify(o)}. ts(2300)`)}getParser(e){let t=this,r=[],i=new Set,s=[];for(let n of t.propertySignatures)r.push(n.name),i.add(n.name),s.push({ps:n,parser:e(n.type),name:n.name,type:n.type});let o=t.indexSignatures.length;if(0===t.propertySignatures.length&&0===t.indexSignatures.length)return eZ(t,m.Vq);let l=o>0?(0,c.h$X)()({onItem:a.vCS(function*(r,[n,s]){let o=e(e1(s.parameter))(h.some(n),r.options),l=(0,c.OY)(o)?o:yield*a.NS5(o);if("Failure"===l._tag){let e=er(r,t,n,l);e&&(yield*e);return}let d=h.some(r.input[n]),f=e(s.type)(d,r.options),p=(0,c.OY)(f)?f:yield*a.NS5(f);if("Failure"===p._tag){let e=er(r,t,n,p);e&&(yield*e);return}if("Some"===l.value._tag&&"Some"===p.value._tag){let e=l.value.value;if(i.has(n)||i.has(e))return;let t=p.value.value;if(s.merge&&s.merge.decode&&Object.hasOwn(r.out,e)){let[n,i]=s.merge.decode.combine([e,r.out[e]],[e,t]);u(r.out,n,i)}else u(r.out,e,t)}}),step:(e,t,r)=>"Failure"===r._tag?r:void 0}):void 0;return a.vCS(function*(e,c){let d;if("None"===e._tag)return e;let f=e.value;if(!("object"==typeof f&&null!==f&&!Array.isArray(f)))return yield*a.fJG(new y.eE(t,e));let p={},m={ast:t,oinput:e,input:f,out:p,issues:void 0,options:c},g="all"===c.errors,b="error"===c.onExcessProperty,v="preserve"===c.onExcessProperty;if(0===t.indexSignatures.length&&(b||v)){d=Reflect.ownKeys(f);for(let r=0;r<d.length;r++){let n=d[r];if(!i.has(n))if(b){let r=new y.gm([n],new y.vF(t,f[n]));if(!g)return yield*a.fJG(new y.eC(t,e,[r]));m.issues?m.issues.push(r):m.issues=[r];continue}else u(p,n,f[n])}}let w=et(c?.concurrency),x=ec(m,s,w);if(x&&(yield*x),l){let e=n.Ie();for(let r=0;r<o;r++){let n=t.indexSignatures[r],i=function(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(e=>void 0!==a.matchKey(e,r));case"Union":return[...new Set(a.types.flatMap(t))];default:return[]}}(e1(eG(t)))}(f,n.parameter,c);for(let t=0;t<i.length;t++){let r=i[t];e.push([r,n])}}let r=l(m,e,w);r&&(yield*r)}if(m.issues)return yield*a.fJG(new y.eC(t,e,m.issues));if("original"===c.propertyOrder){let e=(d??Reflect.ownKeys(f)).concat(r),t={};for(let r of e)Object.hasOwn(p,r)&&u(t,r,p[r]);return h.some(t)}return h.some(p)})}_rebuild(e,t,r,n,i){let a=eF(this.propertySignatures,t=>{let r=e(t.type);return r===t.type?t:new ei(t.name,r)}),s=eF(this.indexSignatures,n=>{let i=t(n.parameter),a=e(n.type),s=r?n.merge?.flip():n.merge;return i===n.parameter&&a===n.type&&s===n.merge?n:new eo(i,a,s)});return a===this.propertySignatures&&s===this.indexSignatures&&n===this.checks&&i===this.encodingChecks?this:new el(a,s,this.annotations,n,void 0,this.context,i)}flip(e){return this._rebuild(e,e,!0,this.encodingChecks,this.checks)}recur(e,t=e){return this._rebuild(e,t,!1,this.checks,this.encodingChecks)}getExpected(){return 0===this.propertySignatures.length&&0===this.indexSignatures.length?"object | array":"object"}}let ec=(0,c.h$X)()({onItem(e,t){let r=Object.hasOwn(e.input,t.name)?h.some(e.input[t.name]):h.none();return t.parser(r,e.options)},step(e,t,r){if("Failure"===r._tag)return er(e,e.ast,t.name,r);if("Some"===r.value._tag)u(e.out,t.name,r.value.value);else if(!ez(t.type)){let r=new y.gm([t.name],new y.Mw(t.type.context?.annotations));return"all"!==e.options.errors?s.fJ(new y.eC(e.ast,e.oinput,[r])):void(e.issues?e.issues.push(r):e.issues=[r])}}});function eu(e,t){return e?t?[...e,...t]:e:t}function ed(e,t,r){return new el(Reflect.ownKeys(e).map(t=>new ei(t,e[t].ast)),[],r,t)}function ef(e){return e.ast}function eh(e,t){return new Z(!1,e.map(e=>e.ast),[],void 0,t)}function ep(e,t,r){return new eb(e.map(ef),t,void 0,r)}function em(e){switch(e._tag){default:return[];case"Declaration":{let t=e.annotations?.["~sentinels"];return Array.isArray(t)?t:[]}case"Objects":return e.propertySignatures.flatMap(e=>{let t=e.type;if(!ez(t)){if(E(t))return[{key:e.name,literal:t.literal}];if($(t))return[{key:e.name,literal:t.symbol}]}return[]});case"Arrays":return e.elements.flatMap((e,t)=>E(e)&&!ez(e)?[{key:t,literal:e.literal}]:[]);case"Suspend":return em(e.thunk())}}let eg=new WeakMap;function ey(e){return t=>{let r=eG(t);return"Literal"===r._tag?r.literal===e:"UniqueSymbol"!==r._tag||r.symbol===e}}class eb extends j{_tag="Union";types;mode;encodingChecks;constructor(e,t,r,n,i,a,s){super(r,n,i,a),this.types=e,this.mode=t,this.encodingChecks=s}getParser(e){let t=this;return(r,n)=>{if("None"===r._tag)return a.PyW(r);let i=r.value,s=function(e,t){let r=function(e){let t=eg.get(e);if(t)return t;t={};for(let r=0;r<e.length;r++){let n=eG(e[r]);if(_(n))continue;let i=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"]:["object","array"];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"]}}(n),a=em(n);for(let e of(t.byType??={},i))(t.byType[e]??=[]).push(r);if(a.length>0)for(let{key:e,literal:n}of(t.bySentinel??=new Map,a)){let i=t.bySentinel.get(e);i||t.bySentinel.set(e,i=new Map);let a=i.get(n);a||i.set(n,a=[]),a.push(r)}else for(let e of(t.otherwise??={},i))(t.otherwise[e]??=[]).push(r)}return eg.set(e,t),t}(t),n=null===e?"null":Array.isArray(e)?"array":typeof e;if(r.bySentinel){let i=r.otherwise?.[n]??[];if("object"===n||"array"===n){let n=new Set(i);for(let[t,i]of r.bySentinel)if(Object.hasOwn(e,t)){let r=i.get(e[t]);if(r)for(let e of r)n.add(e)}return Array.from(n).sort((e,t)=>e-t).map(e=>t[e]).filter(ey(e))}return i.map(e=>t[e])}return(r.byType?.[n]??[]).map(e=>t[e]).filter(ey(e))}(i,t.types),o={ast:t,recur:e,oinput:r,input:i,out:void 0,successes:[],issues:void 0,options:n},l=et(n?.concurrency),c=ev(o,s,l?{...l,orderedStep:!0}:void 0);return c?a.qIB(c,e=>o.out?a.PyW(o.out):a.fJG(new y.W(t,i,o.issues??[]))):o.out?a.PyW(o.out):a.fJG(new y.W(t,i,o.issues??[]))}}_rebuild(e,t,r){let n=eF(this.types,e);return n===this.types&&t===this.checks&&r===this.encodingChecks?this:new eb(n,this.mode,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=eG(t);switch(r._tag){case"Arrays":{let t=r.elements.filter(E);if(t.length>0)return`${e_(r.isMutable)}[ ${t.map(t=>e(t)+(t.context?.isOptional?"?":"")).join(", ")}, ... ]`;break}case"Objects":{let t=r.propertySignatures.filter(e=>E(e.type));if(t.length>0)return`{ ${t.map(t=>`${e_(t.type.context?.isMutable)}${(0,o._r)(t.name)}${t.type.context?.isOptional?"?":""}: ${e(t.type)}`).join(", ")}, ... }`}}return e(r)}))).join(" | ")}}let ev=(0,c.h$X)()({onItem:(e,t)=>e.recur(t)(e.oinput,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&&"oneOf"===e.ast.mode)return e.successes.push(t),s.fJ(new y.E8(e.ast,e.input,e.successes));if(e.out=r.value,e.successes.push(t),"anyOf"===e.ast.mode)return s.rI}}}),ew=new eb([new W("Infinity"),new W("-Infinity"),new W("NaN")],"anyOf"),ex=new T(new eb([V,ew],"anyOf"),new b.IT(g.wN(),g.pd(e=>globalThis.Number.isFinite(e)?e:globalThis.String(e))));function e_(e){return e?"":"readonly "}class ek extends j{_tag="Suspend";thunk;constructor(e,t,r,n,i){let a,s;if(void 0!==r)throw Error("Cannot add checks to Suspend");super(t,void 0,n,i),this.thunk=(s=!1,()=>(s||(a=e(),s=!0),a))}getParser(e){return e(this.thunk())}recur(e){return new ek(()=>e(this.thunk()),this.annotations,void 0,void 0,this.context)}getExpected(e){return e(this.thunk())}}class eS extends p.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 eS(this.run,{...this.annotations,...e},this.aborted)}abort(){return new eS(this.run,this.annotations,!0)}and(e,t){return new eO([this,e],t)}}class eO extends p.Xs{_tag="FilterGroup";checks;annotations;constructor(e,t){super(),this.checks=e,this.annotations=t}annotate(e){return new eO(this.checks,{...this.annotations,...e})}and(e,t){return new eO([this,e],t)}}function eE(e,t,r=!1){return new eS((t,r,n)=>y.L8(t,r,e(t,r,n)),t,r)}function e$(e,t){return new eS(t=>e(t)?void 0:new y.h6(h.some(t)),t,!0)}function eI(e,t){let r=e.source;return eE(t=>e.test(t),{expected:`a string matching the RegExp ${r}`,meta:{_tag:"isPattern",regExp:e},arbitrary:{constraint:{patterns:[e.source]}},...t})}function eA(e,t){let r=Object.getOwnPropertyDescriptors(e);return t(r),Object.create(Object.getPrototypeOf(e),r)}function eC(e,t){return e.encoding===t?e:eA(e,e=>{e.encoding.value=t})}function eT(e,t){return e.context===t?e:eA(e,e=>{e.context.value=t})}function eN(e,t){if(e.checks){let r=e.checks[e.checks.length-1];return eM(e,n.BC(e.checks.slice(0,-1),r.annotate(t)))}return eA(e,e=>{e.annotations.value={...e.annotations.value,...t}})}function eM(e,t){if("Suspend"===e._tag&&void 0!==t)throw Error("Cannot add checks to Suspend");return e.checks===t?e:eA(e,e=>{e.checks.value=t})}function eP(e,t){return eM(e,eu(e.checks,t))}function ej(e,t){let r=e[e.length-1],i=t(r.to);return i!==r.to?n.BC(e.slice(0,e.length-1),new T(i,r.transformation)):e}function eD(e){return t=>t.encoding?eC(t,ej(t.encoding,e)):t}function eU(e){return(0,l.Bj)(function t(r){return r.encoding?eC(r,ej(r.encoding,t)):e(r)})}function eF(e,t){let r=!1,n=Array(e.length);for(let i=0;i<e.length;i++){let a=e[i],s=t(a);s!==a&&(r=!0),n[i]=s}return r?n:e}function eR(e,t){let r=e.context?new M(e.context.isOptional,e.context.isMutable,e.context.defaultValue,{...e.context.annotations,...t}):new M(!1,!1,void 0,t);return eT(e,r)}let eL=eD(eB);function eB(e){let t=e.context?!1===e.context.isOptional?new M(!0,e.context.isMutable,e.context.defaultValue,e.context.annotations):e.context:new M(!0,!1);return eL(eT(e,t))}let eY=eD(eq);function eq(e){let t=e.context?!1===e.context.isMutable?new M(e.context.isOptional,!0,e.context.defaultValue,e.context.annotations):e.context:new M(!1,!0);return eY(eT(e,t))}function eX(e,t){let r=[new T(q,new b.IT(g.IQ(t),g.le()))],n=e.context?new M(e.context.isOptional,e.context.isMutable,r,e.context.annotations):new M(!1,!1,r);return eT(e,n)}function eW(e,t,r){let n;return n=new T(e,r),eC(t,t.encoding?[...t.encoding,n]:[n])}function eJ(e,t,r){let n,i,{literals:a,parameters:s}=(n=[],i=[],!function e(t){switch(t._tag){case"Literal":m.hL(t.literal)&&n.push(t.literal);return;case"UniqueSymbol":n.push(t.symbol);return;case"Never":return;case"Union":for(let r=0;r<t.types.length;r++)e(t.types[r]);return;default:i.push(t)}}(e),{literals:n,parameters:i});return new el(a.map(e=>new ei(e,t)),s.map(e=>new eo(e,t,r)))}function ez(e){return e.context?.isOptional??!1}function eK(e){return e.context?.isMutable??!1}let eV=(0,l.Bj)(e=>{if(e.encoding)return eV(eC(e,void 0));let t=e.recur?.(eV)??e,r=t.encodingChecks;return r?eA(t,n=>{n.encodingChecks.value=void 0,t===e&&(n.checks.value=eu(t.checks,r))}):t}),eG=(0,l.Bj)(e=>eV(eH(e))),eH=(0,l.Bj)(e=>e.encoding?function(e,t){let r=t.length,n=t[r-1],i=[new T(eH(eC(e,void 0)),t[0].transformation.flip())];for(let e=1;e<r;e++)i.unshift(new T(eH(t[e-1].to),t[e].transformation.flip()));let a=eH(n.to);return a.encoding?eC(a,[...a.encoding,...i]):eC(a,i)}(e,e.encoding):e.flip?.(eH)??e.recur?.(eH)??e);function eQ(e,t){let r=a.nGE(t);return n=>"None"===n._tag?a.lwU:n.value===t?r:a.fJG(new y.eE(e,n))}function eZ(e,t){return r=>"None"===r._tag?a.lwU:t(r.value)?a.PyW(r):a.fJG(new y.eE(e,r))}function e0(e,t,r){if(r?.disableChecks||void 0===e.checks)return t;let n=[];return tl(e.checks,t,n,e,r),0===n.length?t:void 0}let e1=eU(e=>{switch(e._tag){default:return e;case"Number":return e.toCodecStringTree();case"Union":return e.recur(e1)}}),e2=eU(e=>{switch(e._tag){default:return e;case"Symbol":case"UniqueSymbol":return e.toCodecStringTree();case"Union":return e.recur(e2)}}),e3=eU(e=>{switch(e._tag){default:return e;case"Number":case"Literal":case"BigInt":return e.toCodecStringTree();case"Union":return e.recur(e3)}}),e5="[\\s\\S]*?",e6=new globalThis.RegExp(`^${en}$`),e8=new globalThis.RegExp(`(?:${en}|Infinity|-Infinity|NaN)`);function e4(e){return eI(e6,{expected:"a string representing a finite number",meta:{_tag:"isStringFinite",regExp:e6},...e})}let e9=eP(z,[e4()]),e7=new T(e9,b.ZK),te=new T(new eb([e9,ew],"anyOf"),b.ZK),tt=new globalThis.RegExp("^-?\\d+$");function tr(e){return eI(tt,{expected:"a string representing a bigint",meta:{_tag:"isStringBigInt",regExp:tt},...e})}let tn=eP(z,[tr({expected:"a string representing a bigint"})]),ti=new T(tn,b.R7),ta=new globalThis.RegExp("^Symbol\\((.*)\\)$"),ts=new T(eP(z,[to()]),new b.IT(g.pd(e=>globalThis.Symbol.for(ta.exec(e)[1])),g.K$(e=>void 0!==globalThis.Symbol.keyFor(e)?a.PyW(globalThis.String(e)):a.fJG(new y.cw(h.some(e),{message:"cannot serialize to string, Symbol is not registered"})))));function to(e){return eI(ta,{expected:"a string representing a symbol",meta:{_tag:"isStringSymbol",regExp:ta},...e})}function tl(e,t,r,n,i){for(let a=0;a<e.length;a++){let s=e[a];if("FilterGroup"===s._tag)tl(s.checks,t,r,n,i);else{let e=s.run(t,n,i);if(e&&(r.push(new y.dJ(t,s,e)),s.aborted||i?.errors!=="all"))return}}}let tc="~effect/Schema/Class",tu="~structural";d.hd,d.ip,d.KE,d.DQ,d.Pk;let td=new D([],()=>(e,t)=>{let r,n;return(r=new Set,n=new Set,function e(t){if(null===t||"string"==typeof t||"boolean"==typeof t)return!0;if("number"==typeof t)return globalThis.Number.isFinite(t);if("object"!=typeof t||void 0===t||r.has(t))return!1;if(n.has(t))return!0;let i=Array.isArray(t);if(!i){let e=Object.getPrototypeOf(t);if(null!==e&&null!==Object.getPrototypeOf(e))return!1}r.add(t);let a=i?t.every(e):Object.keys(t).every(r=>e(t[r]));return r.delete(t),a&&n.add(t),a}(e))?a.PyW(e):a.fJG(new y.eE(t,h.some(e)))},{typeConstructor:{_tag:"effect/Json"},generation:{runtime:"Schema.Json",Type:"Schema.Json"},expected:"JSON value",toCodecJson:()=>new T(q,b.le()),toArbitrary:()=>e=>e.jsonValue()}),tf=eN(td,{typeConstructor:{_tag:"effect/MutableJson"},generation:{runtime:"Schema.MutableJson",Type:"Schema.MutableJson"}}),th=new T(new D([],()=>(e,t)=>{let r;return(r=new Set,function e(t){return void 0===t||"string"==typeof t||!("object"!=typeof t||null===t||r.has(t))&&((r.add(t),Array.isArray(t))?t.every(e):Object.keys(t).every(r=>e(t[r])))}(e))?a.PyW(e):a.fJG(new y.eE(t,h.some(e)))},{expected:"StringTree"}),b.le())},6310(e,t,r){var n=r(4705),i=r(7720),a=r(8983),s=r(3833),o=r(9138),l=r(5369),c=r(995),u=r(6030);class d extends o.Xs{run;constructor(e){super(),this.run=e}map(e){return new d((t,r)=>this.run(t,r).pipe(i.jkJ(s.map(e))))}compose(e){return h(this)?e:h(e)?this:new d((t,r)=>this.run(t,r).pipe(i.Ab9(t=>e.run(t,r))))}}let f=new d(i.PyW);function h(e){return e.run===f.run}function p(){return f}function m(e){var t;return t=s.map(e),new d(e=>i.PyW(t(e)))}function g(e){var t;return t=(t,r)=>e(t,r).pipe(i.jkJ(s.some)),new d((e,r)=>s.isNone(e)?i.lwU:t(e.value,r))}function y(){return new d(()=>i.lwU)}function b(e){return new d(t=>{let r=s.filter(t,l.EA);return s.isSome(r)?i.PyW(r):i.jkJ(e,s.some)})}function v(){return m(globalThis.String)}function w(){return m(globalThis.Number)}function x(){return m(globalThis.BigInt)}function _(){return m(e=>new globalThis.Date(e))}function k(){return m(a.WG)}function S(){return m(a.DX)}function O(){return m(a.mU)}function E(){return g(e=>i.Z9x(i.yUA(a.y4(e)),t=>new u.h6(s.some(e),{message:t.message})))}function $(){return g(e=>c.YW(a.$T(e),{onFailure:t=>i.fJG(new u.h6(s.some(e),{message:t.message})),onSuccess:i.PyW}))}function I(){return g(e=>c.YW(a.$X(e),{onFailure:t=>i.fJG(new u.h6(s.some(e),{message:t.message})),onSuccess:i.PyW}))}function A(){return g(e=>c.YW(a.UD(e),{onFailure:t=>i.fJG(new u.h6(s.some(e),{message:t.message})),onSuccess:i.PyW}))}function C(){return g(e=>c.YW(a.EF(e),{onFailure:t=>i.fJG(new u.h6(s.some(e),{message:t.message})),onSuccess:i.PyW}))}function T(){return g(e=>c.YW(a.xQ(e),{onFailure:t=>i.fJG(new u.h6(s.some(e),{message:t.message})),onSuccess:i.PyW}))}function N(){return m(encodeURIComponent)}function M(){return g(e=>{try{return i.PyW(globalThis.decodeURIComponent(e))}catch(t){return i.fJG(new u.h6(s.some(e),{message:t instanceof URIError?t.message:"Invalid URI component"}))}})}function P(){return g(e=>s.match(n.L8(e),{onNone:()=>i.fJG(new u.h6(s.some(e),{message:"Invalid DateTime input"})),onSome:e=>i.PyW(n.yT(e))}))}l.Kg,r.d(t,{$T:()=>$,$X:()=>I,A0:()=>P,DX:()=>S,EF:()=>C,IQ:()=>b,K$:()=>g,Qf:()=>v,Qw:()=>x,UD:()=>A,WG:()=>k,_p:()=>N,cJ:()=>y,le:()=>p,mF:()=>M,mU:()=>O,n9:()=>_,pd:()=>m,uB:()=>d,wN:()=>w,xQ:()=>T,y4:()=>E})},6030(e,t,r){var n=r(8927),i=r(6470),a=r(4888),s=r(3833),o=r(5369);let l="~effect/SchemaIssue/Issue";function c(e){return(0,o.i5)(e,l)}class u{[l]=l;toString(){return A(this)}}class d extends u{_tag="Filter";actual;filter;issue;constructor(e,t,r){super(),this.actual=e,this.filter=t,this.issue=r}}class f extends u{_tag="Encoding";ast;actual;issue;constructor(e,t,r){super(),this.ast=e,this.actual=t,this.issue=r}}class h extends u{_tag="Pointer";path;issue;constructor(e,t){super(),this.path=e,this.issue=t}}class p extends u{_tag="MissingKey";annotations;constructor(e){super(),this.annotations=e}}class m extends u{_tag="UnexpectedKey";ast;actual;constructor(e,t){super(),this.ast=e,this.actual=t}}class g extends u{_tag="Composite";ast;actual;issues;constructor(e,t,r){super(),this.ast=e,this.actual=t,this.issues=r}}class y extends u{_tag="InvalidType";ast;actual;constructor(e,t){super(),this.ast=e,this.actual=t}}class b extends u{_tag="InvalidValue";actual;annotations;constructor(e,t){super(),this.actual=e,this.annotations=t}}class v extends u{_tag="Forbidden";actual;annotations;constructor(e,t){super(),this.actual=e,this.annotations=t}}class w extends u{_tag="AnyOf";ast;actual;issues;constructor(e,t,r){super(),this.ast=e,this.actual=t,this.issues=r}}class x extends u{_tag="OneOf";ast;actual;successes;constructor(e,t,r){super(),this.ast=e,this.actual=t,this.successes=r}}function _(e,t){if(c(t))return t;if("string"==typeof t)return new b(s.some(e),{message:t});let r="string"==typeof t.issue?new b(s.some(e),{message:t.issue}):t.issue;return new h(t.path,r)}function k(e,t,r){if(Array.isArray(r))return n.ET(r)?1===r.length?_(e,r[0]):new g(t,s.some(e),n.Tj(r,t=>_(e,t))):void 0;if(void 0!==r)return"boolean"==typeof r?r?void 0:new b(s.some(e)):_(e,r)}let S=e=>{let t=T(e);if(void 0!==t)return t;switch(e._tag){case"InvalidType":return $(a.bo(e.ast),M(e.actual));case"InvalidValue":return`Invalid data ${M(e.actual)}`;case"MissingKey":return"Missing key";case"UnexpectedKey":return`Unexpected key with value ${(0,i.GP)(e.actual)}`;case"Forbidden":return"Forbidden operation";case"OneOf":return`Expected exactly one member to match the input ${(0,i.GP)(e.actual)}`}},O=e=>T(e.issue)??T(e);function E(e){return t=>({issues:I(t,[],e?.leafHook??S,e?.checkHook??O)})}function $(e,t){return`Expected ${e}, got ${t}`}function I(e,t,r,n){switch(e._tag){case"Filter":{let a=n(e);if(void 0!==a)return[{path:t,message:a}];if("InvalidValue"===e.issue._tag)return[{path:t,message:$(function e(t){let r=t.annotations?.expected;if("string"==typeof r)return r;switch(t._tag){case"Filter":return"<filter>";case"FilterGroup":return t.checks.map(t=>e(t)).join(" & ")}}(e.filter),(0,i.GP)(e.actual))}];return I(e.issue,t,r,n)}case"Encoding":return I(e.issue,t,r,n);case"Pointer":return I(e.issue,[...t,...e.path],r,n);case"Composite":return e.issues.flatMap(e=>I(e,t,r,n));case"AnyOf":{let s=T(e);if(0===e.issues.length){if(void 0!==s)return[{path:t,message:s}];return[{path:t,message:$(a.bo(e.ast),(0,i.GP)(e.actual))}]}return e.issues.flatMap(e=>I(e,t,r,n))}default:return[{path:t,message:r(e)}]}}let A=e=>I(e,[],S,O).map(C).join("\n");function C(e){let t=e.message;if(e.path&&e.path.length>0){let r=(0,i.jV)(e.path);t+=`
|
|
155
|
-
at ${r}`}return t}function T(e){switch(e._tag){case"InvalidType":case"OneOf":case"Composite":case"AnyOf":return N(e.ast.annotations);case"InvalidValue":case"Forbidden":return N(e.annotations);case"MissingKey":return N(e.annotations,"messageMissingKey");case"UnexpectedKey":return N(e.ast.annotations,"messageUnexpectedKey");case"Filter":return N(e.filter.annotations);case"Encoding":return T(e.issue)}}function N(e,t="message"){let r=e?.[t];if("string"==typeof r)return r}function M(e){return s.isNone(e)?"no value provided":(0,i.GP)(e.value)}r.d(t,{E8:()=>x,ID:()=>E,L8:()=>k,Mw:()=>p,W:()=>w,Wi:()=>f,cw:()=>v,dJ:()=>d,eC:()=>g,eE:()=>y,gh:()=>c,gm:()=>h,h6:()=>b,vF:()=>m},{vp:S})},4858(e,t,r){var n=r(8927),i=r(8543),a=r(7720),s=r(7598),o=r(4650),l=r(8045),c=r(3833),u=r(5369),d=r(995),f=r(9177),h=r(6030);let p=(0,o.Bj)(e=>{switch(e._tag){case"Declaration":{let t=e.annotations?.[f.YA];if(u.Tn(t)){let r=t(e.typeParameters),n=p(r.to);return f.ES(e,n===r.to?[r]:[new f.N_(n,r.transformation)])}return e}case"Objects":case"Arrays":return e.recur(e=>{let t=e.context?.defaultValue;return t?f.ES(p(e),t):p(e)});case"Suspend":return e.recur(p);default:return e}});function m(e){let t=O(p(f.Ax(e.ast)));return(e,r)=>t(e,r?.disableChecks?r?.parseOptions?{...r.parseOptions,disableChecks:!0}:{disableChecks:!0}:r?.parseOptions)}function g(e){let t=m(e);return(e,r)=>{let n=a.lKS(t(e,r));return s.oJ(n)?c.some(n.value):(l.q(n.cause,"Option adapter can only return none for schema issues"),c.none())}}function y(e){let t=m(e);return(e,r)=>{let n=a.lKS(t(e,r));if(s.oJ(n))return n.value;let i=l.q(n.cause,"Constructor adapter can only throw schema issues");throw Error(i.toString(),{cause:i})}}function b(e){var t;let r;return t=e.ast,r=E(O(f.Ax(t))),e=>{let t=r(e,f.vr);return!!s.oJ(t)||(l.q(t.cause,"Type guard adapter can only return false for schema issues"),!1)}}function v(e,t){let r=E(O(f.Ax(e.ast)))(t,f.vr);if(s.N6(r)){let e=l.q(r.cause,"Assertion adapter can only throw schema issues");throw Error(e.toString(),{cause:e})}}function w(e,t){let r=O(e.ast);return void 0===t?r:(e,n)=>r(e,S(t,n))}function x(e,t){return $(w(e,t))}function _(e,t){let r;return r=E(w(e,t)),(e,t)=>{let n=r(e,t);return s.oJ(n)?d.Py(n.value):d.fJ(l.q(n.cause,"Result adapter can only return schema issues"))}}function k(e,t){let r;return $((r=O(f.UU(e.ast)),void 0===t?r:(e,n)=>r(e,S(t,n))))}let S=(e,t)=>void 0===t?e:{...e,...t};function O(e){let t=A(e);return(e,r)=>a.Ab9(t(c.some(e),r??f.vr),e=>"None"===e._tag?a.fJG(new h.h6(e)):a.PyW(e.value))}function E(e){return(t,r)=>a.lKS(e(t,r))}function $(e){let t=E(e);return(e,r)=>{let n=t(e,r);return s.oJ(n)?c.some(n.value):(l.q(n.cause,"Option adapter can only return none for schema issues"),c.none())}}function I(e,t){return a.Tyx(e,e=>a.pVV(()=>i.Tj(e,t)))}let A=(0,o.Bj)(e=>{let t,r=e.checks,i=e.encoding,s=i?.length??0,o=e.encodingChecks,l=(r?r[r.length-1].annotations:e.annotations)?.parseOptions;if(!e.context&&!i&&!r&&!o)return(r,n)=>(t??=e.getParser(A),l&&(n={...n,...l}),t(r,n));let u=f.tF(e)||f.RP(e)||f.HC(e)&&e.typeParameters.length>0,d=r&&u?r.filter(e=>e.annotations?.[f.C3]):void 0;return(u,p)=>{let m;if(l&&(p={...p,...l}),i){for(let e=s-1;e>=0;e--){let t=i[e],r=A(t.to);if(m=m?a.Ab9(m,e=>r(e,p)):r(u,p),"Transformation"===t.transformation._tag){let e=t.transformation.decode;m=a.Ab9(m,t=>e.run(t,p))}else m=t.transformation.decode(m,p)}m=I(m,t=>new h.Wi(e,u,t))}t??=e.getParser(A);let g=i=>{let s=t(i,p);return o&&!p?.disableChecks&&(s=a.Ab9(s,t=>{if(c.isSome(i)&&c.isSome(t)){let t=[];if(f.Lp(o,i.value,t,e,p),n.CZ(t))return a.fJG(new h.eC(e,i,t))}return a.PyW(t)})),r&&!p?.disableChecks&&(p?.errors==="all"&&d&&d.length>0&&c.isSome(i)&&(s=I(s,t=>{let r=[];return f.Lp(d,i.value,r,e,p),n.CZ(r)?"Composite"===t._tag&&t.ast===e?new h.eC(e,t.actual,[...t.issues,...r]):new h.eC(e,i,[t,...r]):t})),s=a.Ab9(s,t=>{if(c.isSome(t)){let i=t.value,s=[];if(f.Lp(r,i,s,e,p),n.CZ(s))return a.fJG(new h.eC(e,t,s))}return a.PyW(t)})),s};return m?a.Ab9(m,g):g(u)}});r.d(t,{IQ:()=>k,L8:()=>y,YY:()=>g,_R:()=>w,is:()=>b,kv:()=>v,o:()=>m,q$:()=>_,y9:()=>x},{GP:k,mR:x})},5348(e,t,r){var n=r(631),i=r(4705),a=r(2302),s=r(7720),o=r(6470),l=r(3833),c=r(5369),u=r(6310),d=r(6030);let f="~effect/SchemaTransformation/Transformation";class h{[f]=f;_tag="Transformation";decode;encode;constructor(e,t){this.decode=e,this.encode=t}flip(){return new h(this.encode,this.decode)}compose(e){return new h(this.decode.compose(e.decode),e.encode.compose(this.encode))}}function p(e){return new h(u.K$(e.decode),u.K$(e.encode))}function m(e){return new h(u.pd(e.decode),u.pd(e.encode))}let g=new h(u.le(),u.le());function y(){return g}let b=new h(u.wN(),u.Qf()),v=new h(u.Qw(),u.Qf()),w=new h(u.n9(),u.pd(o.Yq)),x=new h(u.n9(),u.pd(e=>e.getTime())),_=p({decode:e=>l.match(a.lX(e),{onNone:()=>s.fJG(new d.h6(l.some(e),{message:`Invalid Duration string: ${e}`})),onSome:s.PyW}),encode:e=>s.PyW(globalThis.String(e))}),k=p({decode:e=>s.PyW(a.cF(e)),encode:e=>l.match(a.tb(e),{onNone:()=>s.fJG(new d.h6(l.some(e),{message:`Unable to encode ${e} into a bigint`})),onSome:e=>s.PyW(e)})}),S=m({decode:e=>a.ne(e),encode:e=>a.kE(e)}),O=e=>{let t;return c.Gv(e)&&"string"==typeof e.message?(t=Object.hasOwn(e,"cause")?Error(e.message,{cause:O(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},E=p({decode:e=>URL.canParse(e)?s.PyW(new URL(e)):s.fJG(new d.h6(l.some(e),{message:`Invalid URL string: ${e}`})),encode:e=>s.PyW(e.href)}),$=p({decode:e=>{let t=n.sH(e);return l.isNone(t)?s.fJG(new d.h6(l.some(e),{message:`Invalid BigDecimal string: ${e}`})):s.PyW(t.value)},encode:e=>s.PyW(n.GP(e))}),I=new h(u.y4(),u.WG()),A=new h(u.$T(),u.WG()),C=new h(u.UD(),u.DX()),T=new h(u.xQ(),u.mU()),N=new h(u.mF(),u._p()),M=m({decode:e=>i.ko(e),encode:e=>e.offset}),P=p({decode:e=>l.match(i.y3(e),{onNone:()=>s.fJG(new d.h6(l.some(e),{message:`Invalid IANA time zone: ${e}`})),onSome:s.PyW}),encode:e=>s.PyW(e.id)}),j=p({decode:e=>l.match(i.ez(e),{onNone:()=>s.fJG(new d.h6(l.some(e),{message:`Invalid time zone: ${e}`})),onSome:s.PyW}),encode:e=>s.PyW(i.xV(e))}),D=p({decode:e=>l.match(i.L8(e),{onNone:()=>s.fJG(new d.h6(l.some(e),{message:`Invalid UTC DateTime string: ${e}`})),onSome:e=>s.PyW(i.yT(e))}),encode:e=>s.PyW(i.dv(e))}),U=p({decode:e=>l.match(i.MO(e),{onNone:()=>s.fJG(new d.h6(l.some(e),{message:`Invalid Zoned DateTime string: ${e}`})),onSome:s.PyW}),encode:e=>s.PyW(i.Rd(e))});r.d(t,{IT:()=>h,K$:()=>p,le:()=>y,pd:()=>m},{Ct:A,EJ:_,HO:x,I9:M,L8:e=>c.i5(e,f)?e:new h(e.decode,e.encode),LL:C,Nh:D,PE:S,Pp:N,R7:v,U0:I,XU:j,Y5:T,YZ:w,ZK:b,d9:U,dG:$,m8:k,nY:E,sm:e=>{let t,r;return m({decode:O,encode:(t=new WeakSet,r=n=>{if(c.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,o.IB)(n);return void 0===e?(0,o.GP)(n):JSON.parse(e)}catch{return(0,o.GP)(n)}})})},yd:P})},2672(e,t,r){var n=r(1136);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 c=n.pSt,u=n.vDJ;n.fou,n.mdu,r.d(t,{},{Fp:c,Gt:s,HG:i,LZ:a,U9:l,VN:u,a6:o})},755(e,t,r){let n,i;var a=r(8619),s=r(4650),o=r(3833);let l="effect/Tracer/ParentSpan";class c extends a.kl()(l){}let u=a.Or("effect/Tracer/DisablePropagation",{defaultValue:s.f4}),d=a.Or("effect/Tracer/CurrentTraceLevel",{defaultValue:()=>"Info"}),f=a.Or("effect/Tracer/MinimumTraceLevel",{defaultValue:()=>"All"}),h="effect/Tracer",p=a.Or(h,{defaultValue:()=>({span:e=>new m(e)})});class m{_tag="Span";spanId;traceId="native";sampled;name;parent;annotations;links;startTime;kind;status;attributes;events=[];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},this.attributes=new Map,this.traceId=o.getOrUndefined(e.parent)?.traceId??g(32),this.spanId=g(16)}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)}}let g=(i=(n="abcdef0123456789").length,function(e){let t="";for(let r=0;r<e;r++)t+=n.charAt(Math.floor(Math.random()*i));return t});r.d(t,{Tv:()=>c,W1:()=>m},{DW:u,EW:f,RL:h,WG:l,pX:d,sh:p})},3537(e,t,r){let n,i;class a{called=!1;self;constructor(e){this.self=e}next(e){return this.called?{value:e,done:!0}:(this.called=!0,{value:this.self,done:!1})}[Symbol.iterator](){return new a(this.self)}}let s=(i={[n="~effect/Utils/internal"]:e=>e()},i[n](()=>Error().stack)?.includes(n)===!0?i[n]:({[n]:e=>e()})[n]);r.d(t,{B:()=>a},{s:s})},8433(e,t,r){let n;var i=r(8036),a=r(6470),s=r(4650),o=r(4450),l=r(6400),c=r(9138),u=r(5369),d=r(3537);let f="~effect/Effect",h="~effect/Exit",p={_A:s.D_,_E:s.D_,_R:s.D_},m=`${f}/identifier`,g=`${f}/args`,y=`${f}/evaluate`,b=`${f}/successCont`,v=`${f}/failureCont`,w=`${f}/ensureCont`,x=Symbol.for("effect/Effect/Yield"),_={pipe(){return(0,c.tT)(this,arguments)},toJSON(){return{...this}},toString(){return(0,a.GP)(this.toJSON(),{ignoreToString:!0,space:2})},[l.FX](){return this.toJSON()}},k={[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}},S={[f]:p,..._,[Symbol.iterator](){return new d.B(this)},toJSON(){return{_id:"Effect",op:this[m],...g in this?{args:this[g]}:void 0}}},O=e=>(0,u.i5)(e,h),E="~effect/Cause",$="~effect/Cause/Reason",I=e=>(0,u.i5)(e,E);class A{[E];reasons;constructor(e){this[E]=E,this.reasons=e}pipe(){return(0,c.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 I(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 C=new WeakMap;class T{[$];annotations;_tag;constructor(e,t,r){if(this[$]=$,this._tag=e,t!==N&&"object"==typeof r&&null!==r&&t.size>0){let e=C.get(r);e&&(t=new Map([...e,...t])),C.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,c.tT)(this,arguments)}toString(){return(0,a.GP)(this)}[l.FX](){return this.toString()}}let N=new Map;class M extends T{error;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 R(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 P=new A([]),j=e=>new A([new M(e)]);class D extends T{defect;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 L(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 U=e=>new A([new D(e)]),F=(0,s.XY)(e=>I(e[0]),(e,t,r)=>0===t.mapUnsafe.size?e:new A(e.reasons.map(e=>e.annotate(t,r)))),R=e=>"Fail"===e._tag,L=e=>"Die"===e._tag;function B(e){return V("Effect.evaluate: Not implemented")}let Y=e=>({...S,[m]:e.op,[y]:e[y]??B,[b]:e[b],[v]:e[v],[w]:e[w]}),q=e=>{let t=Y(e);return function(){let r=Object.create(t);return r[g]=!1===e.single?arguments:arguments[0],r}},X=e=>{let t={...Y(e),[h]:h,_tag:e.op,get[e.prop](){return this[g]},toString(){return`${e.op}(${(0,a.GP)(this[g])})`},toJSON(){return{_id:"Exit",_tag:e.op,[e.prop]:this[g]}},[i.HR](e){return O(e)&&e._tag===this._tag&&i.aI(this[g],e[g])},[o.HR](){return o.kg(o.Yj(e.op),o.tW(this[g]))}};return function(e){let r=Object.create(t);return r[g]=e,r}},W=X({op:"Success",prop:"value",[y](e){let t=e.getCont(b);return t?t[b](this[g],e,this):e.yieldWith(this)}}),J={key:"effect/Cause/StackTrace"},z=X({op:"Failure",prop:"cause",[y](e){let t=this[g],r=!1;e.currentStackFrame&&(t=F(t,{mapUnsafe:new Map([[J.key,e.currentStackFrame]])}),r=!0);let n=e.getCont(v);for(;e.interruptible&&e._interruptedCause&&n;)n=e.getCont(v);return n?n[v](t,e,r?void 0:this):e.yieldWith(r?this:z(t))}}),K=e=>z(j(e)),V=e=>z(U(e)),G=q({op:"WithFiber",[y](e){return this[g](e)}}),H=function(){class e extends globalThis.Error{}let t=Y({op:"YieldableError",[y](){return K(this)}});return delete t.toString,Object.assign(e.prototype,t),e}(),Q=(n=Symbol.for("effect/Data/Error/plainArgs"),class extends H{constructor(e){super(e?.message,e?.cause?{cause:e.cause}:void 0),e&&(Object.assign(this,e),Object.defineProperty(this,n,{value:e,enumerable:!1}))}toJSON(){return{...this[n],...this}}}),Z=e=>{class t extends Q{_tag=e}return t.prototype.name=e,t},ee="~effect/Cause/NoSuchElementError";class et extends Z("NoSuchElementError"){[ee]=ee;constructor(e){super({message:e})}}let er="~effect/Cause/Done",en={[er]:er,_tag:"Done",value:void 0},ei=e=>void 0===e?en:{[er]:er,_tag:"Done",value:e},ea=K(en);r.d(t,{ET:()=>T,Xm:()=>et,dM:()=>M,s0:()=>A},{$D:Q,$L:e=>(0,u.i5)(e,er),$n:f,Aj:I,B4:$,DH:P,Eh:F,GN:x,IH:h,In:k,Iu:U,OE:j,PW:e=>(0,u.i5)(e,ee),PX:E,QJ:{key:"effect/Cause/InterruptorStackTrace"},R6:G,RS:ei,Rk:K,Sc:v,Uf:q,V2:V,Vw:e=>void 0===e?ea:K(ei(e)),Wg:e=>(0,u.i5)(e,$),Xb:L,_3:y,a2:g,b5:e=>new A(e),b9:O,cb:z,dO:N,ee:b,fU:_,ik:e=>"Interrupt"===e._tag,lC:R,qB:ee,q_:er,rN:Z,u4:w,xt:W,yj:Y,yw:e=>(0,u.i5)(e,f),z8:J})},2849(e,t,r){var n=r(4650);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)})))})},1136(e,t,r){let n,i,a;r.d(t,{RD4:()=>i2,cOF:()=>i0,a1U:()=>iD,z4N:()=>i8,d$_:()=>i7,Do:()=>nz,Aub:()=>iZ,F7W:()=>iH,qwd:()=>iG,t8c:()=>iK,LkF:()=>i4,olX:()=>ae,obm:()=>rK,kWD:()=>rz,MUS:()=>iz,DQo:()=>iW,Bk6:()=>i6,Kkt:()=>i3,dsN:()=>n$,N24:()=>nm,Q56:()=>nn,jGc:()=>np,U9h:()=>ni,Q7R:()=>nI,hgn:()=>tr,ww9:()=>iM,gsV:()=>at,Muk:()=>iN,as:()=>e7,Xx$:()=>te,NLW:()=>ti,PCg:()=>n0,oIE:()=>nV,JrD:()=>nK,PO3:()=>nb,CJw:()=>ng,Rgn:()=>ny,E2r:()=>eQ,Tyx:()=>rt,rNk:()=>ri,sJf:()=>rn,Fig:()=>ro,UVN:()=>tw,osR:()=>rm,XWm:()=>rp,U9Y:()=>rs,AXC:()=>rb,zt4:()=>rv,KuX:()=>rg,loE:()=>ry,h_t:()=>ra,On5:()=>G,h2c:()=>H,Bou:()=>W,nIy:()=>j,h74:()=>J,O$X:()=>Q,GyP:()=>el,RJ6:()=>ee,ReC:()=>Z,RKA:()=>iB,_OA:()=>tV,sxi:()=>tH,Wj8:()=>ij,_32:()=>iP,Rud:()=>iq,s0X:()=>iX,cbG:()=>rY,F_Q:()=>eB,OY:()=>th,yeE:()=>no,u4Y:()=>rE,NS5:()=>rF,Hox:()=>tL,ely:()=>tB,yJo:()=>t$,HIt:()=>tE,K$2:()=>tk,GUt:()=>tS,jCT:()=>tA,_OD:()=>tI,lgw:()=>tX,Sv3:()=>tq,kMI:()=>tY,YDM:()=>tT,_mh:()=>tN,lNM:()=>tC,_sz:()=>tx,VE1:()=>tO,CoE:()=>t_,v9O:()=>tP,EkE:()=>tD,zPu:()=>tj,Wtn:()=>tR,x5l:()=>tM,il9:()=>tF,fJG:()=>eA,ATB:()=>eI,pVV:()=>eL,gOk:()=>eY,pEE:()=>eK,zFM:()=>ev,C6p:()=>ew,ABT:()=>eV,mKq:()=>ek,DKo:()=>eO,$MQ:()=>eE,eGS:()=>eS,D7p:()=>ex,INJ:()=>e_,vTQ:()=>n5,pbD:()=>nX,x1Q:()=>nW,E8K:()=>nJ,VtY:()=>nY,ahH:()=>nq,Pm0:()=>nB,W$I:()=>t8,BbX:()=>Y,k7S:()=>B,khU:()=>F,L$u:()=>R,QE5:()=>U,i8i:()=>nT,kAe:()=>nM,tU5:()=>X,Dd:()=>rO,qIB:()=>tu,Ab9:()=>tp,Bqz:()=>tm,UUz:()=>tt,fn:()=>e5,D9k:()=>e1,vCS:()=>e8,jJl:()=>nD,i4r:()=>re,zhn:()=>nH,yxg:()=>nZ,ar0:()=>n1,x6Z:()=>n2,bJ:()=>eP,sVm:()=>eN,yUA:()=>eM,JkU:()=>e0,Iku:()=>ep,gpn:()=>L,myX:()=>D,prj:()=>q,nn5:()=>K,XeO:()=>r$,GrF:()=>rI,GaK:()=>nv,Inz:()=>nS,eMl:()=>nE,Rft:()=>i1,ASO:()=>iQ,N6O:()=>rL,_y:()=>iV,OPA:()=>i9,oJd:()=>rB,c8t:()=>iJ,PnV:()=>i5,h$X:()=>nR,uVU:()=>nG,A_r:()=>iE,lIX:()=>aa,ORc:()=>P,Fbb:()=>id,zzk:()=>iu,Z98:()=>ix,Rd$:()=>i_,TjK:()=>tg,UcN:()=>r_,q7Y:()=>tv,jkJ:()=>ty,xm_:()=>rx,Z9x:()=>tb,YWq:()=>rj,D$$:()=>rM,NZb:()=>rU,khu:()=>rT,wR5:()=>tf,G$Q:()=>rD,tvg:()=>rP,ZmZ:()=>eZ,S5A:()=>nu,iKM:()=>nf,BeE:()=>nd,cfM:()=>ns,uRq:()=>nc,fGe:()=>nl,r7h:()=>na,nAr:()=>nh,uKv:()=>rA,QgK:()=>rk,DM4:()=>rS,jBG:()=>nA,ivC:()=>eW,PpN:()=>tZ,AAo:()=>r7,PfK:()=>t0,c7E:()=>t2,O4F:()=>tl,Vdx:()=>ts,FfP:()=>to,KT6:()=>tc,tQ6:()=>V,aAq:()=>t9,Xrv:()=>t7,Ket:()=>rC,bPG:()=>n4,lSz:()=>n8,MY7:()=>n6,eJC:()=>n3,pR5:()=>it,NpQ:()=>n7,jqV:()=>n9,v2Q:()=>ie,HZF:()=>is,lKS:()=>ii,rfH:()=>ir,lE:()=>ia,_Sg:()=>ta,z8E:()=>r9,iLB:()=>r2,Uio:()=>r1,vDJ:()=>rG,fou:()=>rH,Z$R:()=>rZ,pSt:()=>r0,RWE:()=>r4,d97:()=>r6,DLK:()=>rV,mdu:()=>nt,P1j:()=>ne,Pxi:()=>nr,euC:()=>tW,Nav:()=>tJ,oao:()=>tQ,yy4:()=>iY,Fu6:()=>iS,WbR:()=>iO,PyW:()=>e$,lwU:()=>eF,nGE:()=>eU,DYE:()=>eT,OH5:()=>eC,Mim:()=>tn,dGm:()=>rl,bKC:()=>ru,cA6:()=>rc,nAi:()=>rh,sFT:()=>rd,k$L:()=>rf,ayu:()=>rJ,wRz:()=>rX,D52:()=>rW,mgX:()=>rq,kJM:()=>ih,pkL:()=>eR,SvU:()=>eX,$mh:()=>eJ,Vxk:()=>al,rfi:()=>nw,FcF:()=>nO,scW:()=>rw,r_d:()=>tz,bUZ:()=>tK,gvr:()=>iI,tfT:()=>nC,rIH:()=>eq,z7s:()=>t4,iMI:()=>nj,KyM:()=>t3,$$g:()=>ac,hq:()=>iC,fRP:()=>iT,zr8:()=>ik,_o1:()=>ip,nDN:()=>im,MaT:()=>ig,m9E:()=>eD,KN3:()=>ej,yU6:()=>t5,OYO:()=>t6});var s=r(8927),o=r(8619),l=r(2302),c=r(8036),u=r(956),d=r(6470),f=r(4650),h=r(4450),p=r(6400),m=r(8496),g=r(3833),y=r(6364),b=r(9138),v=r(5369),w=r(1743),x=r(995),_=r(8469),k=r(755),S=r(3537),O=r(8433),E=r(2849),$=r(9354),I=r(8344),A=r(3628);let C=e=>{if(e?.captureStackTrace===!1||e?.captureStackTrace!==void 0&&"boolean"!=typeof e.captureStackTrace)return e;let t=(0,A.jt)();(0,A.ft)(3);let r=Error();return(0,A.ft)(t),{...e,captureStackTrace:N(()=>r.stack)}},T=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()}},N=T(3);class M extends O.ET{fiberId;constructor(e,t=O.dO){super("Interrupt",t,"Interrupted"),this.fiberId=e}toString(){return`Interrupt(${this.fiberId})`}toJSON(){return{_tag:"Interrupt",fiberId:this.fiberId}}[c.HR](e){return(0,O.ik)(e)&&this.fiberId===e.fiberId&&this.annotations===e.annotations}[h.HR](){return h.kg(h.Yj(`${this._tag}:${this.fiberId}`))(h.yT(this.annotations))}}let P=e=>new M(e),j=e=>new O.s0([new M(e)]),D=e=>e.reasons.some(O.lC),U=e=>{let t=e.reasons.find(O.lC);return t?x.Py(t):x.fJ(e)},F=e=>{for(let t=0;t<e.reasons.length;t++){let r=e.reasons[t];if("Fail"===r._tag)return x.Py(r.error)}return x.fJ(e)},R=u.zL(F),L=e=>e.reasons.some(O.Xb),B=e=>{let t=e.reasons.find(O.Xb);return t?x.Py(t):x.fJ(e)},Y=e=>{let t=e.reasons.find(O.Xb);return t?x.Py(t.defect):x.fJ(e)},q=e=>e.reasons.some(O.ik),X=e=>{let t=e.reasons.find(O.ik);return t?x.Py(t):x.fJ(e)},W=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?x.Py(t):x.fJ(e)},J=e=>{let t=W(e);return x.N6(t)?z:t.success},z=new Set,K=e=>e.reasons.length>0&&e.reasons.every(O.ik),V=e=>o.LZ(e.annotations),G=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 o.LZ(t)},H=(0,f.XY)(2,(e,t)=>{if(0===e.reasons.length)return t;if(0===t.reasons.length)return e;let r=new O.s0(s.KC(e.reasons,t.reasons));return c.aI(e,r)?e:r}),Q=(0,f.XY)(2,(e,t)=>{let r=!1,n=e.reasons.map(e=>(0,O.lC)(e)?(r=!0,new O.dM(t(e.error))):e);return r?(0,O.b5)(n):e}),Z=e=>{let t=(e=>{let t={Fail:[],Die:[],Interrupt:[]};for(let r=0;r<e.reasons.length;r++)t[e.reasons[r]._tag].push(e.reasons[r]);return t})(e);return t.Fail.length>0?t.Fail[0].error:t.Die.length>0?t.Die[0].defect:t.Interrupt.length>0?new globalThis.Error("All fibers interrupted without error"):new globalThis.Error("Empty cause")},ee=(e,t)=>{let r=[],n=[];if(0===e.reasons.length)return r;let i=(0,A.jt)();for(let i of((0,A.ft)(1),e.reasons)){if("Interrupt"===i._tag){n.push(i);continue}r.push(et("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=es(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(et(i,n[0].annotations,t))}return(0,A.ft)(i),r},et=(e,t,r)=>{let n,i=typeof e;if(e&&"object"===i){if(n=new globalThis.Error(er(e),{cause:e.cause?et(e.cause):void 0}),"string"==typeof e.name&&(n.name=e.name),"string"==typeof e.stack)n.stack=ei(e.stack,n,t);else{let e=`${n.name}: ${n.message}`;n.stack=t?ea(e,t):e}for(let t of(r?.includeCauseInStack&&(n.stack=ec(n)),Object.keys(e)))t in n||(n[t]=e[t])}else n=new globalThis.Error(!e?`Unknown error: ${e}`:"string"===i?e:(0,d.IB)(e));return n},er=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,d.IB)(e)},en=/\((.*)\)/g,ei=(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)/.test(i[e]);e++)a.push(i[e]);return r?ea(a.join("\n"),r):a.join("\n")},ea=(e,t)=>{let r=t?.get(O.z8.key);return r&&(e=`${e}
|
|
156
|
-
${eo(r)}`),e},es=(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(
|
|
167
|
+
${u.repeat(f)}}`;return d(o,n)}return String(o)}(t,0)},IB:()=>c,Yq:()=>l,_r:()=>s,jV:()=>o})},4650(e,t,r){var n=r(9138);let i=e=>()=>e,a=i(!0),s=i(!1),o=i(null),l=i(void 0);function c(e,...t){return(0,n.tT)(e,t)}function u(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 d(e){let t=new WeakMap;return r=>{if(t.has(r))return t.get(r);let n=e(r);return t.set(r,n),n}}r.d(t,{Bj:()=>d,Fs:()=>c,L3:()=>u},{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})},4450(e,t,r){var n=r(4650),i=r(6516),a=r(5369);let s="~effect/interfaces/Hash",o=e=>{switch(typeof e){case"number":return f(e);case"bigint":return h(e.toString(10));case"boolean":case"symbol":return h(String(e));case"string":return h(e);case"undefined":return h("undefined");case"function":case"object":if(null===e)return h("null");{if(e instanceof Date)return h(e.toISOString());if(e instanceof RegExp)return h(e.toString());if(i.J.has(e))return l(e);if(x.has(e))return x.get(e);let t=function(e,t){if(_.has(e))return h("[Circular]");_.add(e);let r=t();return _.delete(e),r}(e,()=>{if(d(e))return e[s]();if("function"==typeof e)return l(e);if(Array.isArray(e)||ArrayBuffer.isView(e))return y(e);if(e instanceof Map)return b(e);if(e instanceof Set)return v(e);return m(e)});return x.set(e,t),t}default:throw Error(`BUG: unhandled typeof ${typeof e} - please report an issue at https://github.com/Effect-TS/effect/issues`)}},l=e=>(w.has(e)||w.set(e,f(Math.floor(Math.random()*Number.MAX_SAFE_INTEGER))),w.get(e)),c=(0,n.XY)(2,(e,t)=>53*e^t),u=e=>0xbfffffff&e|e>>>1&0x40000000,d=e=>(0,a.i5)(e,s),f=e=>{if(e!=e)return h("NaN");if(e===1/0)return h("Infinity");if(e===-1/0)return h("-Infinity");let t=0|e;for(t!==e&&(t^=0xffffffff*e);e>0xffffffff;)t^=e/=0xffffffff;return u(t)},h=e=>{let t=5381,r=e.length;for(;r;)t=33*t^e.charCodeAt(--r);return u(t)},p=(e,t)=>{let r=12289;for(let n of t)r^=c(o(n),o(e[n]));return u(r)},m=e=>p(e,(0,i.X)(e)),g=(e,t)=>r=>{let n=e;for(let e of r)n^=t(e);return u(n)},y=g(6151,o),b=g(h("Map"),([e,t])=>c(o(e),o(t))),v=g(h("Set"),o),w=new WeakMap,x=new WeakMap,_=new WeakSet;r.d(t,{},{HR:s,QK:m,YO:y,Yj:h,ai:f,kg:c,tW:o,uN:p,yT:l})},6400(e,t,r){var n=r(6470),i=r(5369),a=r(1743);let s=Symbol.for("nodejs.util.inspect.custom"),o=e=>{try{if(i.i5(e,"toJSON")&&i.Tn(e.toJSON)&&0===e.toJSON.length)return e.toJSON();if(Array.isArray(e))return e.map(o)}catch{return"[toJSON threw]"}return(0,a.E$)(e)};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}):String(e)}catch{return String(e)}},aB:o,os:{toJSON(){return o(this)},[s](){return this.toJSON()},toString(){return(0,n.GP)(this.toJSON())}}})},8496(e,t,r){var n=r(4650),i=r(3833),a=r(5369);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})},5089(e,t,r){var n=r(8619),i=r(3717),a=r(4650),s=r(8433),o=r(1136),l=r(9138),c=r(2672);let u="~effect/Layer/MemoMap",d={"~effect/Layer":{_ROut:a.D_,_E:a.D_,_RIn:a.D_},pipe(){return(0,l.tT)(this,arguments)}},f=e=>{let t=Object.create(d);return t.build=e,t},h=e=>f((t,r)=>{let n=c.Fp(r);return o.cfM(e(t,n),e=>"Failure"===e._tag?c.VN(n,e):o.rIH)});class p{get[u](){return u}parent;constructor(e){this.parent=e}map=new Map;get(e,t){let r=this.map.get(e);if(r)return r.observers++,o.hgn(o.Uio(t,e=>r.finalizer(e)),r.effect);return this.parent?.get(e,t)}getOrElseMemoize(e,t,r){var n;let a,s,l,u=this.get(e,t);return u?u:(n=this,a=c.LZ(),s=i.LZ(),l={observers:1,effect:i.Tx(s),finalizer:t=>o.DYE(()=>(l.observers--,0===l.observers)?(n.map.delete(e),c.VN(a,t)):o.rIH)},n.map.set(e,l),o.Uio(t,l.finalizer).pipe(o.qIB(()=>r(n,a)),o.cfM(e=>(l.effect=e,i.Vw(s,e)))))}}let m=()=>new p;class g extends n.kl()("effect/Layer/CurrentMemoMap"){static forkOrCreate(e){let t=n.Y6(e,g);return t?new p(t):m()}}let y=(0,a.XY)(3,(e,t,r)=>o.PfK(o.TjK(e.build(t,r),n.WQ(g,t)),g,t)),b=(0,a.XY)(2,(e,t)=>s.R6(r=>y(e,g.forkOrCreate(r.context),t))),v=e=>f((0,a.dY)(o.PyW(e))),w=(e,t)=>x(o.TjK(t,t=>n.L8(e,t))),x=e=>{var t;let r;return t=(t,r)=>c.Gt(e,r),r=h((e,n)=>e.getOrElseMemoize(r,n,t))},_=(e,t,r)=>{let i=c.Fp(r,"parallel");return o.jJl(e,e=>e.build(t,c.Fp(i,"sequential")),{concurrency:e.length}).pipe(o.TjK(e=>n.Um(...e)))},k=(e,t,r)=>h((n,i)=>o.qIB(Array.isArray(t)?_(t,n,i):t.build(n,i),t=>e.build(n,i).pipe(o.PpN(t),o.TjK(e=>r(e,t))))),S=(0,a.XY)(2,(e,t)=>k(e,t,a.D_)),$=(0,a.XY)(2,(e,t)=>k(e,t,(e,t)=>n.h1(t,e)));r.d(t,{},{Gt:S,H7:y,LT:b,Py:function(){return 1==arguments.length?e=>v(n.L8(arguments[0],e)):v(n.L8(arguments[0],arguments[1]))},QZ:function(){return 1==arguments.length?e=>w(arguments[0],e):w(arguments[0],arguments[1])},S5:$,Um:(...e)=>h((t,r)=>_(e,t,r)),j6:m})},3833(e,t,r){r.r(t),r.d(t,{Do:()=>eh,all:()=>G,andThen:()=>B,as:()=>U,asVoid:()=>R,bind:()=>ef,bindTo:()=>eu,composeK:()=>J,contains:()=>el,containsWith:()=>eo,exists:()=>ec,filter:()=>er,filterMap:()=>et,firstSomeOf:()=>E,flatMap:()=>L,flatMapNullishOr:()=>Y,flatten:()=>q,fromIterable:()=>v,fromNullOr:()=>A,fromNullishOr:()=>O,fromUndefinedOr:()=>I,gen:()=>ep,getFailure:()=>x,getOrElse:()=>_,getOrNull:()=>T,getOrThrow:()=>j,getOrThrowWith:()=>P,getOrUndefined:()=>N,getSuccess:()=>w,isNone:()=>m,isOption:()=>p,isSome:()=>g,let:()=>ed,lift2:()=>ea,liftNullishOr:()=>C,liftPredicate:()=>es,liftThrowable:()=>M,makeCombinerFailFast:()=>eg,makeEquivalence:()=>en,makeOrder:()=>ei,makeReducer:()=>em,makeReducerFailFast:()=>ey,map:()=>D,match:()=>y,none:()=>f,orElse:()=>k,orElseResult:()=>$,orElseSome:()=>S,partitionMap:()=>ee,product:()=>K,productMany:()=>V,reduceCompact:()=>Q,some:()=>h,tap:()=>z,toArray:()=>Z,toRefinement:()=>b,void:()=>F,zipLeft:()=>X,zipRight:()=>W,zipWith:()=>H});var n=r(8036),i=r(1044),a=r(4650),s=r(2849),o=r(5091),l=r(4403),c=r(6364),u=r(5369);function d(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})}}let f=()=>o.dv,h=o.zN,p=o.oL,m=o.$I,g=o.Ru,y=(0,a.XY)(2,(e,{onNone:t,onSome:r})=>m(e)?t():r(e.value)),b=e=>t=>g(e(t)),v=e=>{for(let t of e)return h(t);return f()},w=l.Oz,x=l.L8,_=(0,a.XY)(2,(e,t)=>m(e)?t():e.value),k=(0,a.XY)(2,(e,t)=>m(e)?t():e),S=(0,a.XY)(2,(e,t)=>m(e)?h(t()):e),$=(0,a.XY)(2,(e,t)=>m(e)?D(t(),l.Py):D(e,l.fJ)),E=e=>{let t=f();for(t of e)if(g(t))break;return t},O=e=>null==e?f():h(e),I=e=>void 0===e?f():h(e),A=e=>null===e?f():h(e),C=e=>(...t)=>O(e(...t)),T=_(a.XR),N=_(a.MN),M=e=>(...t)=>{try{return h(e(...t))}catch{return f()}},P=(0,a.XY)(2,(e,t)=>{if(g(e))return e.value;throw t()}),j=P(()=>Error("getOrThrow called on a None")),D=(0,a.XY)(2,(e,t)=>m(e)?f():h(t(e.value))),U=(0,a.XY)(2,(e,t)=>D(e,()=>t)),R=U(void 0),F=h(void 0),L=(0,a.XY)(2,(e,t)=>m(e)?f():t(e.value)),B=(0,a.XY)(2,(e,t)=>L(e,e=>{let r=(0,u.Tn)(t)?t(e):t;return p(r)?r:h(r)})),Y=(0,a.XY)(2,(e,t)=>m(e)?f():O(t(e.value))),q=L(a.D_),W=(0,a.XY)(2,(e,t)=>L(e,()=>t)),X=(0,a.XY)(2,(e,t)=>z(e,()=>t)),J=(0,a.XY)(2,(e,t)=>r=>L(e(r),t)),z=(0,a.XY)(2,(e,t)=>L(e,e=>D(t(e),()=>e))),K=(e,t)=>g(e)&&g(t)?h([e.value,t.value]):f(),V=(e,t)=>{if(m(e))return f();let r=[e.value];for(let e of t){if(m(e))return f();r.push(e.value)}return h(r)},G=e=>{if(Symbol.iterator in e){let t=[];for(let r of e){if(m(r))return f();t.push(r.value)}return h(t)}let t={};for(let r of Object.keys(e)){let n=e[r];if(m(n))return f();t[r]=n.value}return h(t)},H=(0,a.XY)(3,(e,t,r)=>D(K(e,t),([e,t])=>r(e,t))),Q=(0,a.XY)(3,(e,t,r)=>{let n=t;for(let t of e)g(t)&&(n=r(n,t.value));return n}),Z=e=>m(e)?[]:[e.value],ee=(0,a.XY)(2,(e,t)=>{if(m(e))return[f(),f()];let r=t(e.value);return l.N6(r)?[h(r.failure),f()]:[f(),h(r.success)]}),et=(0,a.XY)(2,(e,t)=>{if(m(e))return f();let r=t(e.value);return l.oJ(r)?h(r.success):f()}),er=(0,a.XY)(2,(e,t)=>m(e)?f():t(e.value)?h(e.value):f()),en=e=>i.L8((t,r)=>m(t)?m(r):!m(r)&&e(t.value,r.value)),ei=e=>c.L8((t,r)=>g(t)?g(r)?e(t.value,r.value):1:-1),ea=e=>(0,a.XY)(2,(t,r)=>H(t,r,e)),es=(0,a.XY)(2,(e,t)=>t(e)?h(e):f()),eo=e=>(0,a.XY)(2,(t,r)=>!m(t)&&e(t.value,r)),el=eo(n.jI()),ec=(0,a.XY)(2,(e,t)=>!m(e)&&t(e.value)),eu=s.Jr(D),ed=s.zM(D),ef=s.oI(D,L),eh=h({}),ep=(...e)=>{let t=(1===e.length?e[0]:e[1].bind(e[0]))(),r=t.next();for(;!r.done;){let e=r.value;if(m(e))return e;r=t.next(e.value)}return h(r.value)};function em(e){return d((t,r)=>m(t)?r:m(r)?t:h(e.combine(t.value,r.value)),f())}function eg(e){return{combine:(t,r)=>m(t)||m(r)?f():h(e.combine(t.value,r.value))}}function ey(e){let t=eg(e).combine,r=h(e.initialValue);return d(t,r,e=>{let n=r;for(let r of e)if(m(n=t(n,r)))break;return n})}},6364(e,t,r){var n=r(4650);function i(e){return(t,r)=>t===r?0:e(t,r)}let a=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),s=i((e,t)=>e<t?-1:1),o=(0,n.XY)(2,(e,t)=>i((r,n)=>e(t(r),t(n)))),l=o(a,e=>e.getTime());function c(e){return i((t,r)=>{let n=t.length,i=r.length,s=Math.min(n,i);for(let n=0;n<s;n++){let i=e(t[n],r[n]);if(0!==i)return i}return a(n,i)})}function u(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 d=e=>(0,n.XY)(2,(t,r)=>-1===e(t,r)),f=e=>(0,n.XY)(2,(t,r)=>1===e(t,r)),h=e=>(0,n.XY)(2,(t,r)=>t===r||1>e(t,r)?t:r),p=e=>(0,n.XY)(2,(t,r)=>t===r||e(t,r)>-1?t:r);r.d(t,{L8:()=>i,O3:()=>c,_k:()=>u},{Bt:e=>(0,n.XY)(2,(t,r)=>!d(e)(t,r.minimum)&&!f(e)(t,r.maximum)),OW:e=>(0,n.XY)(2,(t,r)=>-1!==e(t,r)),Qw:s,T9:p,bi:e=>(0,n.XY)(2,(t,r)=>1!==e(t,r)),hl:d,jk:h,n9:l,qE:e=>(0,n.XY)(2,(t,r)=>h(e)(r.maximum,p(e)(r.minimum,t))),wN:a,yJ:f,zQ:o})},9138(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,tT:n})},5369(e,t,r){var n=r(4650);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 c(e){return i(e)||a(e)||l(e)}function u(e){return"function"==typeof e}function d(e){return void 0===e}function f(e){return void 0!==e}function h(e){return null!==e}function p(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||u(e)}let w=(0,n.XY)(2,(e,t)=>v(e)&&t in e),x=(0,n.XY)(2,(e,t)=>w(e,"_tag")&&e._tag===t);function _(e){return e instanceof Error}function k(e){return e instanceof Date}function S(e){return w(e,Symbol.iterator)||i(e)}function $(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:()=>h,Tn:()=>u,Vq:()=>m,b0:()=>d,bJ:()=>_,gd:()=>$,hL:()=>c,sI:()=>o,t8:()=>y,uy:()=>p,xZ:()=>S},{$J:x,i5:w})},4505(e,t,r){var n=r(8543),i=r(7598),a=r(956),s=r(4650),o=r(1136),l=r(995);let c=(0,s.XY)(2,(e,t)=>o.rNk(e,f,e=>t(e))),u=e=>"Fail"===e._tag&&n.$L(e.error),d=a.Bh(n.kh,e=>n.$L(e)?l.Py(e):l.fJ(e));n.kh;let f=a.Bh(n.kh,e=>n.$L(e)?l.Py(e.value):l.fJ(e)),h=(0,s.XY)(2,(e,t)=>o.khu(e,{onSuccess:t.onSuccess,onFailure:e=>{let r=d(e);return l.N6(r)?t.onFailure(r.failure):t.onDone(r.success.value)}}));r.d(t,{},{Og:e=>e.reasons.some(u),aU:e=>{let t=d(e);return l.N6(t)?i.AT(t.failure):i.Py(t.success.value)},m8:c,tv:h})},8099(e,t,r){var n=r(4650);let i=(0,n.XY)(2,(e,t)=>{let r=[];for(let n of o(e))r.push(t(n,e[n]));return r})((e,t)=>[e,t]),a=(0,n.XY)(2,(e,t)=>{let r={...e};for(let n of o(e))r[n]=t(e[n],n);return r}),s=(0,n.XY)(2,(e,t)=>{let r={};for(let n of o(e))t(e[n],n)&&(r[n]=e[n]);return r}),o=e=>Object.keys(e);r.d(t,{},{DM:e=>0===Object.keys(e).length,Tj:a,Wo:i,pb:s})},1743(e,t,r){var n=r(9138),i=r(5369);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",c={"~effect/Context":{},mapUnsafe:new Map,pipe(){return(0,n.tT)(this,arguments)}};r.d(t,{E$:()=>s,f6:()=>o},{fL:l,uC:a})},3864(e,t,r){var n=r(1136),i=r(8344);i.F8;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})},995(e,t,r){var n=r(4650),i=r(5091),a=r(4403);let s=a.Py,o=a.fJ;a.sV,a.aI;let l=a.N6,c=a.oJ;a.Oz,a.L8;let u=(0,n.XY)(2,(e,t)=>l(e)?o(t(e.failure)):s(e.success)),d=(0,n.XY)(2,(e,t)=>c(e)?s(t(e.success)):o(e.failure)),f=(0,n.XY)(2,(e,{onFailure:t,onSuccess:r})=>l(e)?t(e.failure):r(e.success));i.dv,r.d(t,{},{N6:l,Py:s,Tj:d,YW:f,fJ:o,oJ:c,xm:u})},3587(e,t,r){var n=r(8543),i=r(8619),a=r(2302),s=r(4650),o=r(8433),l=r(1136),c=r(9138),u=r(5369),d=r(4505);let f="~effect/Schedule",h=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})}),p={[f]:{_Out:s.D_,_In:s.D_,_Env:s.D_},pipe(){return(0,c.tT)(this,arguments)}},m=e=>{let t=Object.create(p);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 w(e,({attempt:e,elapsed:n})=>l.PyW((void 0===t.times||e<=t.times)&&(void 0===r||a.bi(a.ne(n),r))))}),w=(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,c]=e,u=t({...r(i,a),output:s,duration:c});return l.qIB((0,o.yw)(u)?u:l.PyW(u),t=>t?l.PyW(e):n.Vw(s))})}))),x=b(a.v_);r.d(t,{},{E6:w,GM:e=>(0,u.i5)(e,f),d3:h,i4:x,jB:v,ji:b,le:e=>m(l.TjK(y(e),e=>(t,r)=>d.tv(e(t,r),{onSuccess:e=>l.PyW([r,e[1]]),onFailure:l.ATB,onDone:()=>n.Vw(r)}))),t5:e=>w(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)})})}))})},8469(e,t,r){var n=r(8619);let i=n.Or("effect/Scheduler",{defaultValue:()=>new o}),a="setImmediate"in globalThis?e=>{let t=globalThis.setImmediate(e);return()=>globalThis.clearImmediate(t)}:e=>{let t=setTimeout(e,0);return()=>clearTimeout(t)};class s{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 o{executionMode;setImmediate;constructor(e="async",t=a){this.executionMode=e,this.setImmediate=t}shouldYield(e){return e.currentOpCount>=e.maxOpsBeforeYield}makeDispatcher(){return new l(this.setImmediate)}}class l{tasks=new s;running=void 0;setImmediate;constructor(e=a){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 c=n.Or("effect/Scheduler/MaxOpsBeforeYield",{defaultValue:()=>2048}),u=n.Or("effect/Scheduler/PreventSchedulerYield",{defaultValue:()=>!1});r.d(t,{FG:()=>o},{Zm:c,_F:i,hf:u})},8861(e,t,r){let n,i,a,s;r.d(t,{O31:()=>eS,v8c:()=>ev,Xsx:()=>e2,Nej:()=>ez,kld:()=>eW,PSP:()=>e5,wYs:()=>eK,Aiz:()=>eV,uSQ:()=>ep,xCb:()=>function e(t){let r=t.map(ep);return es(E.KC(r,"anyOf",void 0),{literals:t,members:r,mapMembers(e){return eE(e(this.members))},pick:t=>e(t),transform:e=>eE(r.map((t,r)=>t.transform(e[r])))})},ukk:()=>eY,wNn:()=>eb,pHd:()=>eG,mSG:()=>ek,QfV:()=>ey,_kM:()=>e_,X0d:()=>e3,gPz:()=>eE,$r1:()=>em,rvE:()=>Q,usV:()=>Z,hzj:()=>H,GLL:()=>eC,_Re:()=>en,q$Z:()=>ei,svK:()=>ea,is:()=>er,MIs:()=>eR,yJO:()=>eF,OWK:()=>eL,tJb:()=>eB,Pto:()=>eU,nfo:()=>ej,HNH:()=>eD,fXn:()=>e$,Wa3:()=>ec,lqM:()=>el,Qrq:()=>eo,YPB:()=>eA,DYE:()=>eI,TcI:()=>eP,lHk:()=>e8,O3D:()=>ed,_oz:()=>e6,rcy:()=>et,AxX:()=>eu,tiU:()=>eM,E$i:()=>eN});var o,l,c,u,d,f,h=r(631),p=r(8543),m=r(2718),g=r(4705),y=r(2302),b=r(7720),v=(r(8983),r(7598)),w=r(6470),x=r(8433),_=r(8927),k=r(8036),S=r(5369),$=r(8099);S.gd;var E=r(9177),O=r(4888),I=r(9138);let A="~effect/SchemaError/SchemaError";class C extends m.rN("SchemaError"){[A]=A;constructor(e){super({issue:e})}get message(){return this.issue.toString()}toString(){return`SchemaError(${this.message})`}}var T=r(4858);let N="~effect/Schema/Schema",M={[N]:N,pipe(){return I.tT(this,arguments)},annotate(e){return this.rebuild(E.fz(this.ast,e))},annotateKey(e){return this.rebuild(E.us(this.ast,e))},check(...e){return this.rebuild(E.EJ(this.ast,e))}};function P(e,t){let r=Object.create(M);t&&Object.assign(r,t),r.ast=e,r.rebuild=e=>P(e,t);let n=T.o(r);return r.makeEffect=(e,t)=>j(n(e,t)),r.make=T.L8(r),r.makeOption=T.YY(r),r}function j(e){return b.Tyx(e,e=>b.pVV(()=>p.Tj(e,e=>new C(e))))}let D=U(function(e){switch(e._tag){case"BigInt":case"Symbol":case"UniqueSymbol":return 0;default:return 1}});function U(e){return t=>{let r=new Map;for(let e=0;e<t.length;e++)r.set(E.O3(t[e]),e);let n=[...t].sort((t,n)=>{t=E.O3(t),n=E.O3(n);let i=e(t),a=e(n);return i!==a?i-a:r.get(t)-r.get(n)});return n.some((e,r)=>e!==t[r])?n:t}}let R=new Set(["~structural","~sentinels","meta","arbitrary","toArbitrary","toEquivalence","toFormatter","toCodec","toCodecJson","toCodecIso",E.YA]),F=new Set(["title","description","default","examples","readOnly","writeOnly","format","contentEncoding","contentMediaType","contentSchema"]);function L(e){if(void 0!==e){let t=$.pb(e,(e,t)=>!R.has(t));if(!$.DM(t))return{annotations:t}}}function B(e,t){return e.some(e=>{switch(e._tag){case"Filter":return e.meta._tag===t;case"FilterGroup":return B(e.checks,t)}})}function Y(e,t){if(0===Object.keys(e).length)return t;let r=Object.keys(t).length;if(0===r)return e;let n=Array.isArray(t.allOf)&&1===r?t.allOf:[t];return Array.isArray(e.allOf)?{...e,allOf:[...e.allOf,...n]}:"string"==typeof e.$ref?{allOf:[e,...n]}:{...e,allOf:n}}function q(e){switch(e._tag){case"Literal":return globalThis.String(e.literal).replace(/[/\\^$*+?.()|[\]{}]/g,"\\$&");case"String":return E.XV;case"Number":return E.bm;case"TemplateLiteral":return e.parts.map(q).join("");case"Union":return e.types.map(q).join("|");default:throw new globalThis.Error("Unsupported part",{cause:e})}}var W=r(3833),X=r(6364),J=r(995),z=r(8469),K=r(6310),V=r(6030),G=r(5348);function H(){return(e,t,r)=>es(new E.D6(e.map(E.hu),e=>t(e.map(e=>es(e))),r))}r(1044)._k,X._k;function Q(e){return t=>eh(eh(t).annotate(e))}function Z(e){return t=>t.rebuild(E.us(t.ast,e))}function ee(e){return v.oJ(e)?e.value:{issues:[{message:p.j9(e.cause)}]}}function et(e,t){let r=T._R(e),n={errors:"all",...t?.parseOptions},i=V.ID(t),a=e=>{let t=new z.FG,a=b.MY7(b.YWq(r(e,n),{onFailure:i,onSuccess:e=>({value:e})}),{scheduler:t});a.currentDispatcher?.flush();let s=a.pollUnsafe();return s?ee(s):new Promise(e=>{a.addObserver(t=>{e(ee(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 er=T.is;function en(e,t){let r=T._R(e,t);return(e,t)=>j(r(e,t))}function ei(e,t){let r=T.q$(e,t);return(e,t)=>J.xm(r(e,t),e=>new C(e))}function ea(e,t){let r=en(e,t);return(e,t)=>(function(e){let t=b.lKS(e);if(v.oJ(t))return t.value;throw function(e,t){let r;for(let i of e.reasons){var n;if(!p.lC(i)||(n=i.error,!S.i5(n,A)))throw new globalThis.Error(t,{cause:e});r??=i.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))}T.kv,T.y9,T.mR,T.IQ,T.GP;let es=P,eo=e=>es(E.Qr(e.ast),{schema:e}),el=e=>eo(eO(e)),ec=e=>es(E.W(e.ast),{schema:e}),eu=e=>es(E.Ax(e.ast),{schema:e}),ed=e=>es(E.O3(e.ast),{schema:e}),ef="~effect/Schema/flip";function eh(e){return S.i5(e,ef)&&e[ef]===ef?e.schema.rebuild(E.UU(e.ast)):es(E.UU(e.ast),{[ef]:ef,schema:e})}function ep(e){let t=es(new E.uS(e),{literal:e,transform:r=>t.pipe(eC(ep(r),{decode:K.pd(()=>r),encode:K.pd(()=>e)}))});return t}E.Zm,E.bz;let em=es(E.L5);E.ch;let eg=es(E.Vx),ey=es(E.Yj),eb=es(E.ai),ev=es(E.zM),ew=es(E.HR);function ex(e,t){return es(e,{fields:t,mapFields(e,t){let r=e(this.fields);return ex(E.w3(r,t?.unsafePreserveChecks?this.ast.checks:void 0),r)}})}function e_(e){return ex(E.w3(e,void 0),e)}function ek(e,t,r){let n=r?.keyValueCombiner?.decode||r?.keyValueCombiner?.encode?new E.E$(r.keyValueCombiner.decode,r.keyValueCombiner.encode):void 0;return es(E.g1(e.ast,t.ast,n),{key:e,value:t})}E.we,E.rI,E.ZG;let eS=e=>es(new E.DO(!1,[],[e.ast]),{value:e}),e$=e=>es(new E.DO(!0,e.ast.elements,e.ast.rest),{schema:e});function eE(e,t){return function e(t,r){return es(t,{members:r,mapMembers(t,r){let n=t(this.members);return e(E.KC(n,this.ast.mode,r?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}(E.KC(e,t?.mode??"anyOf",void 0),e)}let eO=e=>eE([e,eg]);function eI(e){return es(new E.V3(()=>e().ast))}function eA(e,t){return r=>es(E.EJ(r.ast,[E.D$(e,t)]),{schema:r})}function eC(e,t){return r=>es(E.GL(r.ast,e.ast,t?G.L8(t):G.le()),{from:r,to:e})}function eT(e){return b.Tyx(e,e=>b.pVV(()=>p.Tj(e,e=>e.issue)))}function eN(e,t){let r=t?.encodingStrategy==="omit"?K.cJ():K.le();return t=>eo(ed(t)).pipe(eC(t,{decode:K.IQ(eT(e)),encode:r}))}function eM(e,t){let r=t?.encodingStrategy==="omit"?K.cJ():K.le();return t=>el(ed(t)).pipe(eC(t,{decode:K.IQ(eT(e)),encode:r}))}function eP(e){var t;return ep(e).pipe((t=b.PyW(e),e=>es(E.Ez(e.ast,eT(t)),{schema:e})))}function ej(){return(e,t)=>new E.N_(e.ast,G.L8(t))}let eD=E.HN,eU=E.Pt;function eR(e){return eD(e=>globalThis.Number.isFinite(e),{expected:"a finite number",meta:{_tag:"isFinite"},arbitrary:{constraint:{noInfinity:!0,noNaN:!0}},...e})}E.bk,E.ZB,E.IZ;let eF=(f={order:X.wN,annotate:e=>({meta:{_tag:"isGreaterThan",exclusiveMinimum:e}})},n=X.yJ(f.order),i=f.formatter??w.GP,(e,t)=>eD(t=>n(t,e),{expected:`a value greater than ${i(e)}`,arbitrary:{constraint:{ordered:{order:f.order,minimum:e,exclusiveMinimum:!0}}},...f.annotate?.(e),...t})),eL=(o={order:X.wN,annotate:e=>({meta:{_tag:"isGreaterThanOrEqualTo",minimum:e}})},a=X.OW(o.order),s=o.formatter??w.GP,(e,t)=>eD(t=>a(t,e),{expected:`a value greater than or equal to ${s(e)}`,arbitrary:{constraint:{ordered:{order:o.order,minimum:e}}},...o.annotate?.(e),...t}));function eB(e,t){return e=Math.max(0,Math.floor(e)),eD(t=>t.length>=e,{expected:`a value with a length of at least ${e}`,meta:{_tag:"isMinLength",minLength:e},[E.C3]:!0,arbitrary:{constraint:{minLength:e}},...t})}X.wN,X.wN,X.wN,X.n9,X.n9,X.n9,X.n9,X.n9,X.Qw,X.Qw,X.Qw,X.Qw,X.Qw,h.pH,h.pH,h.pH,h.pH,h.pH;let eY=ey.check(eB(1,void 0)),eq=[];function eW(e){let t=e?.includeStack===!0|2*(e?.excludeCause===!0),r=eq[t];if(void 0!==r)return r;let n=tr.pipe(eC(em,G.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 eq[t]=n,n}G.nY;let eX=ey.annotate({expected:"a string in ISO 8601 format that will be decoded as a Date"}),eJ=(l=globalThis.Date,c={typeConstructor:{_tag:"Date"},generation:{runtime:"Schema.Date",Type:"globalThis.Date"},expected:"Date",toCodecJson:()=>ej()(eX,G.YZ),toArbitrary:()=>(e,t)=>e.date(function(e,t){let r={...void 0};if(delete r.valid,e?.valid&&(r.noInvalidDate=!0),t?.minimum!==void 0){let e=(0,t.minimum),n=t.exclusiveMinimum?new globalThis.Date(e.getTime()+1):e;(void 0===r.min||n.getTime()>r.min.getTime())&&(r.min=n)}if(t?.maximum!==void 0){let e=(0,t.maximum),n=t.exclusiveMaximum?new globalThis.Date(e.getTime()-1):e;(void 0===r.max||n.getTime()<r.max.getTime())&&(r.max=n)}return r}(t?.constraint,t?.constraint?.ordered?.order===X.n9?t.constraint.ordered:void 0))},u=e=>e instanceof l,d=c,H()([],()=>(e,t)=>u(e)?b.PyW(e):b.fJG(new V.eE(t,W.some(e))),d));G.YZ,G.HO;let ez=eJ.check(eD(e=>!isNaN(e.getTime()),{expected:"a valid date",meta:{_tag:"isDateValid"},arbitrary:{constraint:{valid:!0}},...void 0}));y.n$,G.EJ,G.m8,G.PE;h.s5,G.dG;let eK=eb.check(eR()),eV=eb.check(eD(e=>globalThis.Number.isSafeInteger(e),{expected:"an integer",meta:{_tag:"isInt"},arbitrary:{constraint:{integer:!0}},...void 0}));G.ZK,G.ZK,G.R7,G.Ct,G.LL,G.Y5,G.Pp;let eG=eE([eK,ew,ey]);G.U0,g.yF,G.Nh,g.Xy,g.lU,g.rg,G.yd,g.kQ,G.XU,G.d9;let eH=globalThis.Symbol.for("immer-draftable"),eQ={};function eZ(e,t,r,n,i){var a,s,o;let l,c=(a=r,s=t,o=n,e=>{if(void 0!==l)return l;let t=new G.IT(K.pd(t=>new e(t)),K.le());return l=eC(es(new E.D6([a.ast],()=>(t,r)=>t instanceof e||S.i5(t,e0(s))?b.PyW(t):b.fJG(new V.eE(r,W.some(t))),{identifier:s,[E.YA]:([e])=>new E.N_(e,t),toCodec:([e])=>new E.N_(e.ast,t),toArbitrary:([t])=>()=>({arbitrary:t.arbitrary.map(t=>new e(t)),terminal:t.terminal?.map(t=>new e(t))}),toFormatter:([t])=>r=>`${e.identifier}(${t(r)})`,"~sentinels":E.SL(a.ast),...o})),t)(a)}),u=e0(t),d=class extends e{constructor(...[e,t]){let n=t?.["~payload"],i=n?.token===eQ?n.value:r.make(e??{},t);super(i,{...t,disableChecks:!0,"~payload":{token:eQ,value:i}})}static [N]=N;get[u](){return u}static [eH]=!0;static identifier=t;static fields=r.fields;static get ast(){return c(this).ast}static pipe(){return I.tT(this,arguments)}static rebuild(e){return c(this).rebuild(e)}static make(e,t){return new this(e,t)}static makeOption(e,t){return T.YY(c(this))(e??{},t)}static makeEffect(e,t){return c(this).makeEffect(e??{},t)}static annotate(e){return this.rebuild(E.fz(this.ast,e))}static annotateKey(e){return this.rebuild(E.us(this.ast,e))}static check(...e){return this.rebuild(E.EJ(this.ast,e))}static extend(e){return(t,n)=>{let a=e1(t)?t:e_(t),s={...r.fields,...a.fields},o=E.w3(s,r.ast.checks,{identifier:e});return eZ(this,e,ex(E.EJ(o,a.ast.checks),s),n,i)}}static mapFields(e,t){return r.mapFields(e,t)}};return void 0!==i&&Object.assign(d.prototype,i(t)),d}function e0(e){return`~effect/Schema/Class/${e}`}function e1(e){return S.i5(e,N)&&e[N]===N}let e2=e=>(t,r)=>{let n=e1(t)?t:e_(t);return eZ(m.Xs,e,n,r,e=>({toString(){return`${e}(${(0,w.GP)({...this})})`}}))},e5=e=>(t,r)=>{let n=e1(t)?t:e_(t);return eZ(x.$D,e,n,r,e=>({name:e}))},e3=e=>(t,r,n)=>{let i=e1(r)?r.mapFields(e=>({_tag:eP(t),...e}),{unsafePreserveChecks:!0}):e_({_tag:eP(t),...r});return e5(e??t)(i,n)};function e6(e,t){let r=function(e,t){let{definitions:r,dialect:n,schemas:i}=function(e,t){let r=t?.generateDescriptions??!1,n=t?.additionalProperties??!1,i=t?.includeAnnotationKey,a=$.Tj(e.references,e=>s(e));return{dialect:"draft-2020-12",schemas:_.Tj(e.representations,e=>s(e)),definitions:a};function s(t){let r=function(t){switch(t._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":case"UniqueSymbol":return{type:"string",allOf:[{pattern:"^Symbol\\((.*)\\)$"}]};case"Declaration":return s(t.encodedSchema);case"Suspend":return s(t.thunk);case"Reference":return{$ref:`#/$defs/${t.$ref.replace(/~/g,"~0").replace(/\//g,"~1")}`};case"Never":return{not:{}};case"String":{let e={type:"string"};return void 0!==t.contentMediaType&&(e.contentMediaType=t.contentMediaType),void 0!==t.contentSchema&&(e.contentSchema=s(t.contentSchema)),e}case"Number":return B(t.checks,"isInt")?{type:"integer"}:B(t.checks,"isFinite")?{type:"number"}:{anyOf:[{type:"number"},{type:"string",enum:["NaN"]},{type:"string",enum:["Infinity"]},{type:"string",enum:["-Infinity"]}]};case"Boolean":return{type:"boolean"};case"Literal":{let e=t.literal;if("string"==typeof e)return{type:"string",enum:[e]};if("number"==typeof e)return{type:"number",enum:[e]};if("boolean"==typeof e)return{type:"boolean",enum:[e]};return{type:"string",enum:[String(e)]}}case"Enum":return s({_tag:"Union",types:t.enums.map(([e,t])=>({_tag:"Literal",literal:t,annotations:{title:e}})),mode:"anyOf",annotations:t.annotations});case"TemplateLiteral":{let e=t.parts.map(q).join("");return{type:"string",pattern:`^${e}$`}}case"Arrays":{if(t.rest.length>1)throw new globalThis.Error("Generating a JSON Schema for post-rest elements is not supported");let e={type:"array"},r=t.elements.length,n=t.elements.map(e=>{e.isOptional&&r--;let t=s(e.type),n=o(e.annotations);return n?Y(t,n):t});if(n.length>0?(e.prefixItems=n,e.maxItems=t.elements.length,r>0&&(e.minItems=r)):e.items=!1,t.rest.length>0){delete e.maxItems;let r=s(t.rest[0]);Object.keys(r).length>0?e.items=r:delete e.items}return e}case"Objects":{if(0===t.propertySignatures.length&&0===t.indexSignatures.length)return{anyOf:[{type:"object"},{type:"array"}]};let r={type:"object"},i={},a=[];for(let e of t.propertySignatures){let t=e.name;if("string"!=typeof t)throw new globalThis.Error(`Unsupported property signature name: ${(0,w.GP)(t)}`);let r=s(e.type),n=o(e.annotations);i[t]=n?Y(r,n):r,e.isOptional||a.push(t)}Object.keys(i).length>0&&(r.properties=i),a.length>0&&(r.required=a),r.additionalProperties=n;let l={};for(let n of t.indexSignatures){let t=s(n.type);1===Object.keys(t).length&&"not"in t&&(t=!1);let i=function t(r){switch(r._tag){default:throw new globalThis.Error(`Unsupported index signature parameter: ${r._tag}`);case"Reference":return t(e.references[r.$ref]);case"String":return function e(t){return t.flatMap(t=>{switch(t._tag){case"Filter":if("regExp"in t.meta)return[t.meta.regExp.source];return[];case"FilterGroup":return e(t.checks)}})}(r.checks);case"TemplateLiteral":return[`^${r.parts.map(q).join("")}$`];case"Union":return r.types.flatMap(t)}}(n.parameter);if(i.length>0)for(let e of i)l[e]=t;else r.additionalProperties=t}return Object.keys(l).length>0&&(r.patternProperties=l,delete r.additionalProperties),S.Gv(r.additionalProperties)&&$.DM(r.additionalProperties)&&delete r.additionalProperties,r}case"Union":{let e=t.types.map(s);if(0===e.length)return{not:{}};if(e.length>1){let t=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)r.push(e)}return{type:t,enum:r}}(e);if(t)return t}return"anyOf"===t.mode?{anyOf:e}:{oneOf:e}}}}(t);if("annotations"in t){let e=o(t.annotations);e&&(r={...r,...e})}if("checks"in t){var i,a;for(let e of(i=t.checks,a=r.type,i.map(function e(t){switch(t._tag){case"Filter":var r=t,n=a;let i=r.meta;if(!i)return;let l=function(e){switch(e._tag){case"isMinLength":return"array"===n?{minItems:e.minLength}:{minLength:e.minLength};case"isMaxLength":return"array"===n?{maxItems:e.maxLength}:{maxLength:e.maxLength};case"isLengthBetween":return"array"===n?{allOf:[{minItems:e.minimum},{maxItems:e.maximum}]}:{allOf:[{minLength:e.minimum},{maxLength:e.maximum}]};case"isPattern":case"isGUID":case"isULID":case"isBase64":case"isBase64Url":case"isStartsWith":case"isEndsWith":case"isIncludes":case"isUppercased":case"isLowercased":case"isCapitalized":case"isUncapitalized":case"isTrimmed":case"isStringFinite":case"isStringBigInt":case"isStringSymbol":return{pattern:e.regExp.source};case"isUUID":return{pattern:e.regExp.source,format:"uuid"};case"isFinite":case"isInt":return;case"isMultipleOf":return{multipleOf:e.divisor};case"isGreaterThanOrEqualTo":return{minimum:e.minimum};case"isLessThanOrEqualTo":return{maximum:e.maximum};case"isGreaterThan":return{exclusiveMinimum:e.exclusiveMinimum};case"isLessThan":return{exclusiveMaximum:e.exclusiveMaximum};case"isBetween":return{[e.exclusiveMinimum?"exclusiveMinimum":"minimum"]:e.minimum,[e.exclusiveMaximum?"exclusiveMaximum":"maximum"]:e.maximum};case"isUnique":return{uniqueItems:!0};case"isMinProperties":return{minProperties:e.minProperties};case"isMaxProperties":return{maxProperties:e.maxProperties};case"isPropertiesLengthBetween":return{minProperties:e.minimum,maxProperties:e.maximum};case"isPropertyNames":return{propertyNames:s(e.propertyNames)};case"isDateValid":return{format:"date-time"}}}(i),c=o(r.annotations);return c&&(l={...l,...c}),l;case"FilterGroup":{let r=t.checks.map(e).filter(e=>void 0!==e);if(0===r.length)return;let n={allOf:r},i=o(t.annotations);return i&&(n={...n,...i}),n}}}).filter(e=>void 0!==e)))r=Y(r,e)}return r}function o(e){if(void 0===e)return;let t={};if("string"==typeof e.title&&(t.title=e.title),"string"==typeof e.description?t.description=e.description:r&&"string"==typeof e.expected&&(t.description=e.expected),void 0!==e.default&&(t.default=e.default),Array.isArray(e.examples)&&(t.examples=e.examples),"boolean"==typeof e.readOnly&&(t.readOnly=e.readOnly),"boolean"==typeof e.writeOnly&&(t.writeOnly=e.writeOnly),"string"==typeof e.format&&(t.format=e.format),"string"==typeof e.contentEncoding&&(t.contentEncoding=e.contentEncoding),"string"==typeof e.contentMediaType&&(t.contentMediaType=e.contentMediaType),i)for(let[r,n]of Object.entries(e))!(void 0===n||F.has(r))&&i(r)&&(t[r]=n);if(Object.keys(t).length>0)return t}}({representations:[e.representation],references:e.references},t);return{dialect:n,schema:i[0],definitions:r}}(function(e){let{references:t,representations:r}=function(e){let t={},r=new Map,n=new Set,i=new Set;return{representations:_.Tj(e,e=>s(e)),references:t};function a(e){let t=e,r=0;for(;n.has(t);)t=`${e}${++r}`;return n.add(t),t}function s(e,n){let l=r.get(e);if(void 0!==l)return{_tag:"Reference",$ref:l};let c=E.S5(e),u=O.KE(e)??n;if(e!==c)return s(c,u);if(void 0!==u){let n=a(u);r.set(e,n);let i=o(e),s=t[u];return void 0!==s&&k.aI(i,s)?(r.set(e,u),{_tag:"Reference",$ref:u}):(t[n]=i,{_tag:"Reference",$ref:n})}if(i.has(e)){let t=a(`${e._tag}_`);return r.set(e,t),{_tag:"Reference",$ref:t}}i.add(e);let d=o(e);i.delete(e);let f=r.get(e);return void 0!==f?(t[f]=d,{_tag:"Reference",$ref:f}):d}function o(e){let t=L(e.annotations);switch(e._tag){case"Declaration":{let r,n=s((r=e.annotations?.toCodecJson??e.annotations?.toCodec,S.Tn(r)?E.ES(e,[r(e.typeParameters.map(e=>P(E.O3(e))))]):E.ch));return{_tag:"Declaration",typeParameters:e.typeParameters.map(e=>s(e)),encodedSchema:n,checks:l(e.checks),...t}}case"Null":case"Undefined":case"Void":case"Never":case"Unknown":case"Any":case"Boolean":case"Symbol":case"ObjectKeyword":return{_tag:e._tag,...t};case"String":{let r=e.annotations?.contentMediaType,n=e.annotations?.contentSchema;return{_tag:e._tag,checks:l(e.checks),...t,..."string"==typeof r&&E.zm(n)?{contentSchema:s(n)}:void 0}}case"Number":case"BigInt":return{_tag:e._tag,checks:l(e.checks),...t};case"Literal":return{_tag:e._tag,literal:e.literal,...t};case"UniqueSymbol":return{_tag:e._tag,symbol:e.symbol,...t};case"Enum":return{_tag:e._tag,enums:e.enums,...t};case"TemplateLiteral":return{_tag:e._tag,parts:e.parts.map(e=>s(e)),...t};case"Arrays":return{_tag:e._tag,elements:e.elements.map(e=>{let t=E.S5(e);return{isOptional:E.dK(t),type:s(e),...L(t.context?.annotations)}}),rest:e.rest.map(e=>s(e)),checks:l(e.checks),...t};case"Objects":return{_tag:e._tag,propertySignatures:e.propertySignatures.map(e=>{let t=E.S5(e.type);return{name:e.name,type:s(e.type),isOptional:E.dK(t),isMutable:E.bV(t),...L(t.context?.annotations)}}),indexSignatures:e.indexSignatures.map(e=>({parameter:s(e.parameter),type:s(e.type)})),checks:l(e.checks),...t};case"Union":{let r=D(e.types);return{_tag:e._tag,types:r.map(e=>s(e)),mode:e.mode,...t}}case"Suspend":return{_tag:"Suspend",checks:[],thunk:s(e.thunk()),...t}}}function l(e){return e?e.map(function(e){switch(e._tag){case"Filter":{let t=e.annotations?.meta;if(t)return{_tag:"Filter",meta:"isPropertyNames"===t._tag?{_tag:"isPropertyNames",propertyNames:s(t.propertyNames)}:t,...L(e.annotations)};return}case"FilterGroup":{let t=l(e.checks);if(_.CZ(t))return{_tag:"FilterGroup",checks:t,...L(e.annotations)}}}}).filter(e=>void 0!==e):[]}}([e]);return{representation:r[0],references:t}}(e.ast),t);return{dialect:"draft-2020-12",schema:r.schema,definitions:r.definitions}}function e8(e){return es(te(e.ast),{schema:e})}let e4=U(function(e){switch(e._tag){case"Null":case"Boolean":case"Number":case"BigInt":case"Symbol":case"UniqueSymbol":return 0;default:return 1}}),e9=new E.N_(new E.uS("null"),new G.IT(K.pd(()=>null),K.pd(()=>"null"))),e7=new E.N_(new E.gP([new E.uS("true"),new E.uS("false")],"anyOf"),new G.IT(K.pd(e=>"true"===e),K.Qf())),te=E.oZ(e=>{if(E.mi(e)&&e.annotations?.["~effect/Schema/SERIALIZER_ENSURE_ARRAY"]===!0)return e;let t=function(e,t,r){switch(e._tag){case"Declaration":{let n=e.annotations?.toCodecJson??e.annotations?.toCodec;if(S.Tn(n)){let r=n(E.HC(e)?e.typeParameters.map(e=>es(t(E.O3(e)))):[]),i=t(r.to);return E.ES(e,i===r.to?[r]:[new E.N_(i,r.transformation)])}return r(e)}case"Null":return E.ES(e,[e9]);case"Boolean":return E.ES(e,[e7]);case"Unknown":case"ObjectKeyword":return E.ES(e,[E.tC]);case"Enum":case"Number":case"Literal":case"UniqueSymbol":case"Symbol":case"BigInt":return e.toCodecStringTree();case"Objects":if(e.propertySignatures.some(e=>"string"!=typeof e.name))throw new globalThis.Error("Objects property names must be strings",{cause:e});return e.recur(t,E.xw);case"Union":{let r=e4(e.types);if(r!==e.types)return new E.gP(r,e.mode,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,te,e=>E.ES(e,[tt]));return t!==e&&E.dK(e)?E.nj(t):t}),tt=new E.N_(E.Vx,new G.IT(K.le(),K.pd(()=>void 0))),tr=es(E.LM);E.BF},9177(e,t,r){r.d(t,{DO:()=>Z,YA:()=>tc,D6:()=>D,bm:()=>en,LM:()=>td,E$:()=>ea,N_:()=>T,uS:()=>X,BF:()=>tf,XV:()=>e3,C3:()=>tu,V3:()=>ek,gP:()=>eb,fz:()=>eN,us:()=>eF,bz:()=>Y,EJ:()=>eP,oZ:()=>eU,we:()=>Q,Nt:()=>tn,zM:()=>G,Lp:()=>tl,SL:()=>em,GL:()=>eX,vr:()=>N,UU:()=>eH,hu:()=>ef,S5:()=>function e(t){return t.encoding?e(t.encoding[t.encoding.length-1].to):t},zm:()=>w,tF:()=>I,Lm:()=>$,HC:()=>x,c$:()=>E,bV:()=>eK,Et:()=>S,RP:()=>A,dK:()=>ez,Pt:()=>eI,Kg:()=>k,ZB:()=>tr,bk:()=>e4,IZ:()=>to,mi:()=>C,HN:()=>eE,D$:()=>eO,W:()=>eq,Zm:()=>B,ch:()=>U,ai:()=>V,ZG:()=>W,Qr:()=>eB,nj:()=>eL,xw:()=>e2,g1:()=>eJ,ES:()=>eC,Yj:()=>z,w3:()=>ed,HR:()=>H,O3:()=>eG,Ax:()=>eV,PV:()=>eh,Vx:()=>F,KC:()=>ep,L5:()=>q,tC:()=>th,rI:()=>L,Ez:()=>eW});var n=r(8927),i=r(8543),a=r(7720),s=r(7598),o=r(6470),l=r(4650),c=r(1136);function u(e,t,r){return"__proto__"===t?Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0}):e[t]=r,e}var d=r(4888),f=r(8045),h=r(3833),p=r(9138),m=r(5369),g=r(6310),y=r(6030),b=r(5348);function v(e){return t=>t._tag===e}function w(e){return m.i5(e,P)&&e[P]===P}let x=v("Declaration"),_=v("Never"),k=v("String"),S=v("Number"),$=v("Boolean"),E=v("Literal"),O=v("UniqueSymbol"),I=v("Arrays"),A=v("Objects"),C=v("Union");class T{to;transformation;constructor(e,t){this.to=e,this.transformation=t}}let N={};class M{isOptional;isMutable;defaultValue;annotations;constructor(e,t,r,n){this.isOptional=e,this.isMutable=t,this.defaultValue=r,this.annotations=n}}let P="~effect/Schema";class j{[P]=P;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}>`}}class D extends j{_tag="Declaration";typeParameters;run;encodingChecks;constructor(e,t,r,n,i,a,s){super(r,n,i,a),this.typeParameters=e,this.run=t,this.encodingChecks=s}getParser(){let e=this.run(this.typeParameters);return(t,r)=>h.isNone(t)?a.lwU:a.jkJ(e(t.value,this,r),h.some)}_rebuild(e,t,r){let n=eR(this.typeParameters,e);return n===this.typeParameters&&t===this.checks&&r===this.encodingChecks?this:new D(n,this.run,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(){let e=this.annotations?.expected;return"string"==typeof e?e:"<Declaration>"}}let U=new class extends j{_tag="Null";getParser(){return eQ(this,null)}getExpected(){return"null"}},R=new T(U,new b.IT(g.pd(()=>void 0),g.pd(()=>null))),F=new class extends j{_tag="Undefined";getParser(){return eQ(this,void 0)}toCodecJson(){return eC(this,[R])}getExpected(){return"undefined"}},L=new class extends j{_tag="Void";getParser(){var e;let t;return e=void 0,t=a.nGE(e),e=>"None"===e._tag?a.lwU:t}toCodecJson(){return eC(this,[R])}getExpected(){return"void"}},B=new class extends j{_tag="Never";getParser(){return eZ(this,m.Pd)}getExpected(){return"never"}},Y=new class extends j{_tag="Any";getParser(){return eZ(this,m.t8)}getExpected(){return"any"}},q=new class extends j{_tag="Unknown";getParser(){return eZ(this,m.t8)}getExpected(){return"unknown"}},W=new class extends j{_tag="ObjectKeyword";getParser(){return eZ(this,m.Fw)}getExpected(){return"object | array | function"}};class X 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 eQ(this,this.literal)}matchPart(e,t){return e===globalThis.String(this.literal)?this.literal:void 0}toCodecJson(){return"bigint"==typeof this.literal?J(this):this}toCodecStringTree(){return"string"==typeof this.literal?this:J(this)}getExpected(){return"string"==typeof this.literal?JSON.stringify(this.literal):globalThis.String(this.literal)}}function J(e){let t=globalThis.String(e.literal);return eC(e,[new T(new X(t),new b.IT(g.pd(()=>e.literal),g.pd(()=>t)))])}let z=new class extends j{_tag="String";getParser(){return eZ(this,m.Kg)}matchPart(e,t){return e0(this,e,t)}getExpected(){return"string"}};function K(e,t){return e.some(e=>{switch(e._tag){case"Filter":return e.annotations?.meta?._tag===t;case"FilterGroup":return K(e.checks,t)}})}let V=new class extends j{_tag="Number";getParser(){return eZ(this,m.Et)}matchKey(e,t){return this._match(e8,e,t)}matchPart(e,t){return this._match(e6,e,t)}_match(e,t,r){return e.test(t)?e0(this,globalThis.Number(t),r):void 0}toCodecJson(){return this.checks&&(K(this.checks,"isFinite")||K(this.checks,"isInt"))?this:eC(this,[ex])}toCodecStringTree(){return this.checks&&(K(this.checks,"isFinite")||K(this.checks,"isInt"))?eC(this,[e7]):eC(this,[te])}getExpected(){return"number"}},G=new class extends j{_tag="Boolean";getParser(){return eZ(this,m.Lm)}getExpected(){return"boolean"}},H=new class extends j{_tag="Symbol";getParser(){return eZ(this,m.Bm)}matchKey(e,t){return e0(this,e,t)}toCodecStringTree(){return eC(this,[ts])}getExpected(){return"symbol"}},Q=new class extends j{_tag="BigInt";getParser(){return eZ(this,m.sI)}matchPart(e,t){return tt.test(e)?e0(this,globalThis.BigInt(e),t):void 0}toCodecStringTree(){return eC(this,[ti])}getExpected(){return"bigint"}};class Z 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=t.findIndex(ez);if(-1!==l&&(t.slice(l+1).some(e=>!ez(e))||r.length>1))throw Error("A required element cannot follow an optional element. ts(1257)");if(r.length>1&&r.slice(1).some(ez))throw Error("An optional element cannot follow a rest element. ts(1266)")}getParser(e){let t=this,r=t.elements.map(t=>({ast:t,parser:e(t)})),n=t.rest.map(t=>({ast:t,parser:e(t)})),i=r.length,[s,...o]=n,l=o.length;function c(e,t){return t<i?r[t]:t>=e?o[t-e]:s}return a.vCS(function*(e,r){if("None"===e._tag)return e;let n=e.value;if(!Array.isArray(n))return yield*a.fJG(new y.eE(t,e));let s=n.length,o={ast:t,getParser:c,oinput:e,len:s,tailThreshold:Math.max(i,s-l),output:new globalThis.Array(s),issues:void 0,options:r},u=et(r?.concurrency),d=ee(o,n,{concurrency:u?.concurrency,end:0===t.rest.length?i:Math.max(s,i+l)});if(d&&(yield*d),0===t.rest.length&&s>i)for(let l=i;l<=s-1;l++){let i=new y.gm([l],new y.vF(t,n[l]));if("all"!==r.errors)return yield*a.fJG(new y.eC(t,e,[i]));o.issues?o.issues.push(i):o.issues=[i]}return o.issues?yield*a.fJG(new y.eC(t,e,o.issues)):h.some(o.output)})}_rebuild(e,t,r){let n=eR(this.elements,e),i=eR(this.rest,e);return n===this.elements&&i===this.rest&&t===this.checks&&r===this.encodingChecks?this:new Z(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"}}let ee=(0,c.h$X)()({onItem(e,t,r){let n=r<e.len?h.some(t):h.none();return e.getParser(e.tailThreshold,r).parser(n,e.options)},step(e,t,r,n){if("Failure"===r._tag)return er(e,e.ast,n,r);if("Some"===r.value._tag)e.output[n]=r.value.value;else{let t=e.getParser(e.tailThreshold,n);if(ez(t.ast))return;let r=new y.gm([n],new y.Mw(t.ast.context?.annotations));if("all"!==e.options.errors)return s.fJ(new y.eC(e.ast,e.oinput,[r]));e.issues?e.issues.push(r):e.issues=[r]}}}),et=e=>(e="unbounded"===e?1/0:e??1)>1?{concurrency:e}:void 0,er=(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 y.eC(t,e.oinput,[new y.gm([r],n)])));let o=new y.gm([r],a);if("all"!==e.options.errors)return s.fJ(new y.eC(t,e.oinput,[o]));e.issues?e.issues.push(o):e.issues=[o]},en="[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?";class ei{name;type;constructor(e,t){this.name=e,this.type=t}}class ea{decode;encode;constructor(e,t){this.decode=e,this.encode=t}flip(){return new ea(this.encode,this.decode)}}function es(e){switch(e._tag){case"String":case"Number":case"Symbol":case"TemplateLiteral":return!0;case"Union":return e.types.every(es);default:return!1}}class eo{parameter;type;merge;constructor(e,t,r){if(!(es(e)&&es(eG(e))))throw Error(`Invalid index signature parameter ${e._tag}`);if(this.parameter=e,this.type=t,this.merge=r,ez(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.")}}class el 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;let o=e.map(e=>e.name).filter((e,t,r)=>r.indexOf(e)!==t);if(o.length>0)throw Error(`Duplicate identifiers: ${JSON.stringify(o)}. ts(2300)`)}getParser(e){let t=this,r=[],i=new Set,s=[];for(let n of t.propertySignatures)r.push(n.name),i.add(n.name),s.push({ps:n,parser:e(n.type),name:n.name,type:n.type});let o=t.indexSignatures.length;if(0===t.propertySignatures.length&&0===t.indexSignatures.length)return eZ(t,m.Vq);let l=o>0?(0,c.h$X)()({onItem:a.vCS(function*(r,[n,s]){let o=e(e1(s.parameter))(h.some(n),r.options),l=(0,c.OY)(o)?o:yield*a.NS5(o);if("Failure"===l._tag){let e=er(r,t,n,l);e&&(yield*e);return}let d=h.some(r.input[n]),f=e(s.type)(d,r.options),p=(0,c.OY)(f)?f:yield*a.NS5(f);if("Failure"===p._tag){let e=er(r,t,n,p);e&&(yield*e);return}if("Some"===l.value._tag&&"Some"===p.value._tag){let e=l.value.value;if(i.has(n)||i.has(e))return;let t=p.value.value;if(s.merge&&s.merge.decode&&Object.hasOwn(r.out,e)){let[n,i]=s.merge.decode.combine([e,r.out[e]],[e,t]);u(r.out,n,i)}else u(r.out,e,t)}}),step:(e,t,r)=>"Failure"===r._tag?r:void 0}):void 0;return a.vCS(function*(e,c){let d;if("None"===e._tag)return e;let f=e.value;if(!("object"==typeof f&&null!==f&&!Array.isArray(f)))return yield*a.fJG(new y.eE(t,e));let p={},m={ast:t,oinput:e,input:f,out:p,issues:void 0,options:c},g="all"===c.errors,b="error"===c.onExcessProperty,v="preserve"===c.onExcessProperty;if(0===t.indexSignatures.length&&(b||v)){d=Reflect.ownKeys(f);for(let r=0;r<d.length;r++){let n=d[r];if(!i.has(n))if(b){let r=new y.gm([n],new y.vF(t,f[n]));if(!g)return yield*a.fJG(new y.eC(t,e,[r]));m.issues?m.issues.push(r):m.issues=[r];continue}else u(p,n,f[n])}}let w=et(c?.concurrency),x=ec(m,s,w);if(x&&(yield*x),l){let e=n.Ie();for(let r=0;r<o;r++){let n=t.indexSignatures[r],i=function(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(e=>void 0!==a.matchKey(e,r));case"Union":return[...new Set(a.types.flatMap(t))];default:return[]}}(e1(eG(t)))}(f,n.parameter,c);for(let t=0;t<i.length;t++){let r=i[t];e.push([r,n])}}let r=l(m,e,w);r&&(yield*r)}if(m.issues)return yield*a.fJG(new y.eC(t,e,m.issues));if("original"===c.propertyOrder){let e=(d??Reflect.ownKeys(f)).concat(r),t={};for(let r of e)Object.hasOwn(p,r)&&u(t,r,p[r]);return h.some(t)}return h.some(p)})}_rebuild(e,t,r,n,i){let a=eR(this.propertySignatures,t=>{let r=e(t.type);return r===t.type?t:new ei(t.name,r)}),s=eR(this.indexSignatures,n=>{let i=t(n.parameter),a=e(n.type),s=r?n.merge?.flip():n.merge;return i===n.parameter&&a===n.type&&s===n.merge?n:new eo(i,a,s)});return a===this.propertySignatures&&s===this.indexSignatures&&n===this.checks&&i===this.encodingChecks?this:new el(a,s,this.annotations,n,void 0,this.context,i)}flip(e){return this._rebuild(e,e,!0,this.encodingChecks,this.checks)}recur(e,t=e){return this._rebuild(e,t,!1,this.checks,this.encodingChecks)}getExpected(){return 0===this.propertySignatures.length&&0===this.indexSignatures.length?"object | array":"object"}}let ec=(0,c.h$X)()({onItem(e,t){let r=Object.hasOwn(e.input,t.name)?h.some(e.input[t.name]):h.none();return t.parser(r,e.options)},step(e,t,r){if("Failure"===r._tag)return er(e,e.ast,t.name,r);if("Some"===r.value._tag)u(e.out,t.name,r.value.value);else if(!ez(t.type)){let r=new y.gm([t.name],new y.Mw(t.type.context?.annotations));return"all"!==e.options.errors?s.fJ(new y.eC(e.ast,e.oinput,[r])):void(e.issues?e.issues.push(r):e.issues=[r])}}});function eu(e,t){return e?t?[...e,...t]:e:t}function ed(e,t,r){return new el(Reflect.ownKeys(e).map(t=>new ei(t,e[t].ast)),[],r,t)}function ef(e){return e.ast}function eh(e,t){return new Z(!1,e.map(e=>e.ast),[],void 0,t)}function ep(e,t,r){return new eb(e.map(ef),t,void 0,r)}function em(e){switch(e._tag){default:return[];case"Declaration":{let t=e.annotations?.["~sentinels"];return Array.isArray(t)?t:[]}case"Objects":return e.propertySignatures.flatMap(e=>{let t=e.type;if(!ez(t)){if(E(t))return[{key:e.name,literal:t.literal}];if(O(t))return[{key:e.name,literal:t.symbol}]}return[]});case"Arrays":return e.elements.flatMap((e,t)=>E(e)&&!ez(e)?[{key:t,literal:e.literal}]:[]);case"Suspend":return em(e.thunk())}}let eg=new WeakMap;function ey(e){return t=>{let r=eG(t);return"Literal"===r._tag?r.literal===e:"UniqueSymbol"!==r._tag||r.symbol===e}}class eb extends j{_tag="Union";types;mode;encodingChecks;constructor(e,t,r,n,i,a,s){super(r,n,i,a),this.types=e,this.mode=t,this.encodingChecks=s}getParser(e){let t=this;return(r,n)=>{if("None"===r._tag)return a.PyW(r);let i=r.value,s=function(e,t){let r=function(e){let t=eg.get(e);if(t)return t;t={};for(let r=0;r<e.length;r++){let n=eG(e[r]);if(_(n))continue;let i=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"]:["object","array"];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"]}}(n),a=em(n);for(let e of(t.byType??={},i))(t.byType[e]??=[]).push(r);if(a.length>0)for(let{key:e,literal:n}of(t.bySentinel??=new Map,a)){let i=t.bySentinel.get(e);i||t.bySentinel.set(e,i=new Map);let a=i.get(n);a||i.set(n,a=[]),a.push(r)}else for(let e of(t.otherwise??={},i))(t.otherwise[e]??=[]).push(r)}return eg.set(e,t),t}(t),n=null===e?"null":Array.isArray(e)?"array":typeof e;if(r.bySentinel){let i=r.otherwise?.[n]??[];if("object"===n||"array"===n){let n=new Set(i);for(let[t,i]of r.bySentinel)if(Object.hasOwn(e,t)){let r=i.get(e[t]);if(r)for(let e of r)n.add(e)}return Array.from(n).sort((e,t)=>e-t).map(e=>t[e]).filter(ey(e))}return i.map(e=>t[e])}return(r.byType?.[n]??[]).map(e=>t[e]).filter(ey(e))}(i,t.types),o={ast:t,recur:e,oinput:r,input:i,out:void 0,successes:[],issues:void 0,options:n},l=et(n?.concurrency),c=ev(o,s,l?{...l,orderedStep:!0}:void 0);return c?a.qIB(c,e=>o.out?a.PyW(o.out):a.fJG(new y.W(t,i,o.issues??[]))):o.out?a.PyW(o.out):a.fJG(new y.W(t,i,o.issues??[]))}}_rebuild(e,t,r){let n=eR(this.types,e);return n===this.types&&t===this.checks&&r===this.encodingChecks?this:new eb(n,this.mode,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=eG(t);switch(r._tag){case"Arrays":{let t=r.elements.filter(E);if(t.length>0)return`${e_(r.isMutable)}[ ${t.map(t=>e(t)+(t.context?.isOptional?"?":"")).join(", ")}, ... ]`;break}case"Objects":{let t=r.propertySignatures.filter(e=>E(e.type));if(t.length>0)return`{ ${t.map(t=>`${e_(t.type.context?.isMutable)}${(0,o._r)(t.name)}${t.type.context?.isOptional?"?":""}: ${e(t.type)}`).join(", ")}, ... }`}}return e(r)}))).join(" | ")}}let ev=(0,c.h$X)()({onItem:(e,t)=>e.recur(t)(e.oinput,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&&"oneOf"===e.ast.mode)return e.successes.push(t),s.fJ(new y.E8(e.ast,e.input,e.successes));if(e.out=r.value,e.successes.push(t),"anyOf"===e.ast.mode)return s.rI}}}),ew=new eb([new X("Infinity"),new X("-Infinity"),new X("NaN")],"anyOf"),ex=new T(new eb([V,ew],"anyOf"),new b.IT(g.wN(),g.pd(e=>globalThis.Number.isFinite(e)?e:globalThis.String(e))));function e_(e){return e?"":"readonly "}class ek extends j{_tag="Suspend";thunk;constructor(e,t,r,n,i){let a,s;if(void 0!==r)throw Error("Cannot add checks to Suspend");super(t,void 0,n,i),this.thunk=(s=!1,()=>(s||(a=e(),s=!0),a))}getParser(e){return e(this.thunk())}recur(e){return new ek(()=>e(this.thunk()),this.annotations,void 0,void 0,this.context)}getExpected(e){return e(this.thunk())}}class eS extends p.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 eS(this.run,{...this.annotations,...e},this.aborted)}abort(){return new eS(this.run,this.annotations,!0)}and(e,t){return new e$([this,e],t)}}class e$ extends p.Xs{_tag="FilterGroup";checks;annotations;constructor(e,t){super(),this.checks=e,this.annotations=t}annotate(e){return new e$(this.checks,{...this.annotations,...e})}and(e,t){return new e$([this,e],t)}}function eE(e,t,r=!1){return new eS((t,r,n)=>y.L8(t,r,e(t,r,n)),t,r)}function eO(e,t){return new eS(t=>e(t)?void 0:new y.h6(h.some(t)),t,!0)}function eI(e,t){let r=e.source;return eE(t=>e.test(t),{expected:`a string matching the RegExp ${r}`,meta:{_tag:"isPattern",regExp:e},arbitrary:{constraint:{patterns:[e.source]}},...t})}function eA(e,t){let r=Object.getOwnPropertyDescriptors(e);return t(r),Object.create(Object.getPrototypeOf(e),r)}function eC(e,t){return e.encoding===t?e:eA(e,e=>{e.encoding.value=t})}function eT(e,t){return e.context===t?e:eA(e,e=>{e.context.value=t})}function eN(e,t){if(e.checks){let r=e.checks[e.checks.length-1];return eM(e,n.BC(e.checks.slice(0,-1),r.annotate(t)))}return eA(e,e=>{e.annotations.value={...e.annotations.value,...t}})}function eM(e,t){if("Suspend"===e._tag&&void 0!==t)throw Error("Cannot add checks to Suspend");return e.checks===t?e:eA(e,e=>{e.checks.value=t})}function eP(e,t){return eM(e,eu(e.checks,t))}function ej(e,t){let r=e[e.length-1],i=t(r.to);return i!==r.to?n.BC(e.slice(0,e.length-1),new T(i,r.transformation)):e}function eD(e){return t=>t.encoding?eC(t,ej(t.encoding,e)):t}function eU(e){return(0,l.Bj)(function t(r){return r.encoding?eC(r,ej(r.encoding,t)):e(r)})}function eR(e,t){let r=!1,n=Array(e.length);for(let i=0;i<e.length;i++){let a=e[i],s=t(a);s!==a&&(r=!0),n[i]=s}return r?n:e}function eF(e,t){let r=e.context?new M(e.context.isOptional,e.context.isMutable,e.context.defaultValue,{...e.context.annotations,...t}):new M(!1,!1,void 0,t);return eT(e,r)}let eL=eD(eB);function eB(e){let t=e.context?!1===e.context.isOptional?new M(!0,e.context.isMutable,e.context.defaultValue,e.context.annotations):e.context:new M(!0,!1);return eL(eT(e,t))}let eY=eD(eq);function eq(e){let t=e.context?!1===e.context.isMutable?new M(e.context.isOptional,!0,e.context.defaultValue,e.context.annotations):e.context:new M(!1,!0);return eY(eT(e,t))}function eW(e,t){let r=[new T(q,new b.IT(g.IQ(t),g.le()))],n=e.context?new M(e.context.isOptional,e.context.isMutable,r,e.context.annotations):new M(!1,!1,r);return eT(e,n)}function eX(e,t,r){let n;return n=new T(e,r),eC(t,t.encoding?[...t.encoding,n]:[n])}function eJ(e,t,r){let n,i,{literals:a,parameters:s}=(n=[],i=[],!function e(t){switch(t._tag){case"Literal":m.hL(t.literal)&&n.push(t.literal);return;case"UniqueSymbol":n.push(t.symbol);return;case"Never":return;case"Union":for(let r=0;r<t.types.length;r++)e(t.types[r]);return;default:i.push(t)}}(e),{literals:n,parameters:i});return new el(a.map(e=>new ei(e,t)),s.map(e=>new eo(e,t,r)))}function ez(e){return e.context?.isOptional??!1}function eK(e){return e.context?.isMutable??!1}let eV=(0,l.Bj)(e=>{if(e.encoding)return eV(eC(e,void 0));let t=e.recur?.(eV)??e,r=t.encodingChecks;return r?eA(t,n=>{n.encodingChecks.value=void 0,t===e&&(n.checks.value=eu(t.checks,r))}):t}),eG=(0,l.Bj)(e=>eV(eH(e))),eH=(0,l.Bj)(e=>e.encoding?function(e,t){let r=t.length,n=t[r-1],i=[new T(eH(eC(e,void 0)),t[0].transformation.flip())];for(let e=1;e<r;e++)i.unshift(new T(eH(t[e-1].to),t[e].transformation.flip()));let a=eH(n.to);return a.encoding?eC(a,[...a.encoding,...i]):eC(a,i)}(e,e.encoding):e.flip?.(eH)??e.recur?.(eH)??e);function eQ(e,t){let r=a.nGE(t);return n=>"None"===n._tag?a.lwU:n.value===t?r:a.fJG(new y.eE(e,n))}function eZ(e,t){return r=>"None"===r._tag?a.lwU:t(r.value)?a.PyW(r):a.fJG(new y.eE(e,r))}function e0(e,t,r){if(r?.disableChecks||void 0===e.checks)return t;let n=[];return tl(e.checks,t,n,e,r),0===n.length?t:void 0}let e1=eU(e=>{switch(e._tag){default:return e;case"Number":return e.toCodecStringTree();case"Union":return e.recur(e1)}}),e2=eU(e=>{switch(e._tag){default:return e;case"Symbol":case"UniqueSymbol":return e.toCodecStringTree();case"Union":return e.recur(e2)}}),e5=eU(e=>{switch(e._tag){default:return e;case"Number":case"Literal":case"BigInt":return e.toCodecStringTree();case"Union":return e.recur(e5)}}),e3="[\\s\\S]*?",e6=new globalThis.RegExp(`^${en}$`),e8=new globalThis.RegExp(`(?:${en}|Infinity|-Infinity|NaN)`);function e4(e){return eI(e6,{expected:"a string representing a finite number",meta:{_tag:"isStringFinite",regExp:e6},...e})}let e9=eP(z,[e4()]),e7=new T(e9,b.ZK),te=new T(new eb([e9,ew],"anyOf"),b.ZK),tt=new globalThis.RegExp("^-?\\d+$");function tr(e){return eI(tt,{expected:"a string representing a bigint",meta:{_tag:"isStringBigInt",regExp:tt},...e})}let tn=eP(z,[tr({expected:"a string representing a bigint"})]),ti=new T(tn,b.R7),ta=new globalThis.RegExp("^Symbol\\((.*)\\)$"),ts=new T(eP(z,[to()]),new b.IT(g.pd(e=>globalThis.Symbol.for(ta.exec(e)[1])),g.K$(e=>void 0!==globalThis.Symbol.keyFor(e)?a.PyW(globalThis.String(e)):a.fJG(new y.cw(h.some(e),{message:"cannot serialize to string, Symbol is not registered"})))));function to(e){return eI(ta,{expected:"a string representing a symbol",meta:{_tag:"isStringSymbol",regExp:ta},...e})}function tl(e,t,r,n,i){for(let a=0;a<e.length;a++){let s=e[a];if("FilterGroup"===s._tag)tl(s.checks,t,r,n,i);else{let e=s.run(t,n,i);if(e&&(r.push(new y.dJ(t,s,e)),s.aborted||i?.errors!=="all"))return}}}let tc="~effect/Schema/Class",tu="~structural";d.hd,d.ip,d.KE,d.DQ,d.Pk;let td=new D([],()=>(e,t)=>{let r,n;return(r=new Set,n=new Set,function e(t){if(null===t||"string"==typeof t||"boolean"==typeof t)return!0;if("number"==typeof t)return globalThis.Number.isFinite(t);if("object"!=typeof t||void 0===t||r.has(t))return!1;if(n.has(t))return!0;let i=Array.isArray(t);if(!i){let e=Object.getPrototypeOf(t);if(null!==e&&null!==Object.getPrototypeOf(e))return!1}r.add(t);let a=i?t.every(e):Object.keys(t).every(r=>e(t[r]));return r.delete(t),a&&n.add(t),a}(e))?a.PyW(e):a.fJG(new y.eE(t,h.some(e)))},{typeConstructor:{_tag:"effect/Json"},generation:{runtime:"Schema.Json",Type:"Schema.Json"},expected:"JSON value",toCodecJson:()=>new T(q,b.le()),toArbitrary:()=>e=>e.jsonValue()}),tf=eN(td,{typeConstructor:{_tag:"effect/MutableJson"},generation:{runtime:"Schema.MutableJson",Type:"Schema.MutableJson"}}),th=new T(new D([],()=>(e,t)=>{let r;return(r=new Set,function e(t){return void 0===t||"string"==typeof t||!("object"!=typeof t||null===t||r.has(t))&&((r.add(t),Array.isArray(t))?t.every(e):Object.keys(t).every(r=>e(t[r])))}(e))?a.PyW(e):a.fJG(new y.eE(t,h.some(e)))},{expected:"StringTree"}),b.le())},6310(e,t,r){var n=r(4705),i=r(7720),a=r(8983),s=r(3833),o=r(9138),l=r(5369),c=r(995),u=r(6030);class d extends o.Xs{run;constructor(e){super(),this.run=e}map(e){return new d((t,r)=>this.run(t,r).pipe(i.jkJ(s.map(e))))}compose(e){return h(this)?e:h(e)?this:new d((t,r)=>this.run(t,r).pipe(i.Ab9(t=>e.run(t,r))))}}let f=new d(i.PyW);function h(e){return e.run===f.run}function p(){return f}function m(e){var t;return t=s.map(e),new d(e=>i.PyW(t(e)))}function g(e){var t;return t=(t,r)=>e(t,r).pipe(i.jkJ(s.some)),new d((e,r)=>s.isNone(e)?i.lwU:t(e.value,r))}function y(){return new d(()=>i.lwU)}function b(e){return new d(t=>{let r=s.filter(t,l.EA);return s.isSome(r)?i.PyW(r):i.jkJ(e,s.some)})}function v(){return m(globalThis.String)}function w(){return m(globalThis.Number)}function x(){return m(globalThis.BigInt)}function _(){return m(e=>new globalThis.Date(e))}function k(){return m(a.WG)}function S(){return m(a.DX)}function $(){return m(a.mU)}function E(){return g(e=>i.Z9x(i.yUA(a.y4(e)),t=>new u.h6(s.some(e),{message:t.message})))}function O(){return g(e=>c.YW(a.$T(e),{onFailure:t=>i.fJG(new u.h6(s.some(e),{message:t.message})),onSuccess:i.PyW}))}function I(){return g(e=>c.YW(a.$X(e),{onFailure:t=>i.fJG(new u.h6(s.some(e),{message:t.message})),onSuccess:i.PyW}))}function A(){return g(e=>c.YW(a.UD(e),{onFailure:t=>i.fJG(new u.h6(s.some(e),{message:t.message})),onSuccess:i.PyW}))}function C(){return g(e=>c.YW(a.EF(e),{onFailure:t=>i.fJG(new u.h6(s.some(e),{message:t.message})),onSuccess:i.PyW}))}function T(){return g(e=>c.YW(a.xQ(e),{onFailure:t=>i.fJG(new u.h6(s.some(e),{message:t.message})),onSuccess:i.PyW}))}function N(){return m(encodeURIComponent)}function M(){return g(e=>{try{return i.PyW(globalThis.decodeURIComponent(e))}catch(t){return i.fJG(new u.h6(s.some(e),{message:t instanceof URIError?t.message:"Invalid URI component"}))}})}function P(){return g(e=>s.match(n.L8(e),{onNone:()=>i.fJG(new u.h6(s.some(e),{message:"Invalid DateTime input"})),onSome:e=>i.PyW(n.yT(e))}))}l.Kg,r.d(t,{$T:()=>O,$X:()=>I,A0:()=>P,DX:()=>S,EF:()=>C,IQ:()=>b,K$:()=>g,Qf:()=>v,Qw:()=>x,UD:()=>A,WG:()=>k,_p:()=>N,cJ:()=>y,le:()=>p,mF:()=>M,mU:()=>$,n9:()=>_,pd:()=>m,uB:()=>d,wN:()=>w,xQ:()=>T,y4:()=>E})},6030(e,t,r){var n=r(8927),i=r(6470),a=r(4888),s=r(3833),o=r(5369);let l="~effect/SchemaIssue/Issue";function c(e){return(0,o.i5)(e,l)}class u{[l]=l;toString(){return A(this)}}class d extends u{_tag="Filter";actual;filter;issue;constructor(e,t,r){super(),this.actual=e,this.filter=t,this.issue=r}}class f extends u{_tag="Encoding";ast;actual;issue;constructor(e,t,r){super(),this.ast=e,this.actual=t,this.issue=r}}class h extends u{_tag="Pointer";path;issue;constructor(e,t){super(),this.path=e,this.issue=t}}class p extends u{_tag="MissingKey";annotations;constructor(e){super(),this.annotations=e}}class m extends u{_tag="UnexpectedKey";ast;actual;constructor(e,t){super(),this.ast=e,this.actual=t}}class g extends u{_tag="Composite";ast;actual;issues;constructor(e,t,r){super(),this.ast=e,this.actual=t,this.issues=r}}class y extends u{_tag="InvalidType";ast;actual;constructor(e,t){super(),this.ast=e,this.actual=t}}class b extends u{_tag="InvalidValue";actual;annotations;constructor(e,t){super(),this.actual=e,this.annotations=t}}class v extends u{_tag="Forbidden";actual;annotations;constructor(e,t){super(),this.actual=e,this.annotations=t}}class w extends u{_tag="AnyOf";ast;actual;issues;constructor(e,t,r){super(),this.ast=e,this.actual=t,this.issues=r}}class x extends u{_tag="OneOf";ast;actual;successes;constructor(e,t,r){super(),this.ast=e,this.actual=t,this.successes=r}}function _(e,t){if(c(t))return t;if("string"==typeof t)return new b(s.some(e),{message:t});let r="string"==typeof t.issue?new b(s.some(e),{message:t.issue}):t.issue;return new h(t.path,r)}function k(e,t,r){if(Array.isArray(r))return n.ET(r)?1===r.length?_(e,r[0]):new g(t,s.some(e),n.Tj(r,t=>_(e,t))):void 0;if(void 0!==r)return"boolean"==typeof r?r?void 0:new b(s.some(e)):_(e,r)}let S=e=>{let t=T(e);if(void 0!==t)return t;switch(e._tag){case"InvalidType":return O(a.bo(e.ast),M(e.actual));case"InvalidValue":return`Invalid data ${M(e.actual)}`;case"MissingKey":return"Missing key";case"UnexpectedKey":return`Unexpected key with value ${(0,i.GP)(e.actual)}`;case"Forbidden":return"Forbidden operation";case"OneOf":return`Expected exactly one member to match the input ${(0,i.GP)(e.actual)}`}},$=e=>T(e.issue)??T(e);function E(e){return t=>({issues:I(t,[],e?.leafHook??S,e?.checkHook??$)})}function O(e,t){return`Expected ${e}, got ${t}`}function I(e,t,r,n){switch(e._tag){case"Filter":{let a=n(e);if(void 0!==a)return[{path:t,message:a}];if("InvalidValue"===e.issue._tag)return[{path:t,message:O(function e(t){let r=t.annotations?.expected;if("string"==typeof r)return r;switch(t._tag){case"Filter":return"<filter>";case"FilterGroup":return t.checks.map(t=>e(t)).join(" & ")}}(e.filter),(0,i.GP)(e.actual))}];return I(e.issue,t,r,n)}case"Encoding":return I(e.issue,t,r,n);case"Pointer":return I(e.issue,[...t,...e.path],r,n);case"Composite":return e.issues.flatMap(e=>I(e,t,r,n));case"AnyOf":{let s=T(e);if(0===e.issues.length){if(void 0!==s)return[{path:t,message:s}];return[{path:t,message:O(a.bo(e.ast),(0,i.GP)(e.actual))}]}return e.issues.flatMap(e=>I(e,t,r,n))}default:return[{path:t,message:r(e)}]}}let A=e=>I(e,[],S,$).map(C).join("\n");function C(e){let t=e.message;if(e.path&&e.path.length>0){let r=(0,i.jV)(e.path);t+=`
|
|
168
|
+
at ${r}`}return t}function T(e){switch(e._tag){case"InvalidType":case"OneOf":case"Composite":case"AnyOf":return N(e.ast.annotations);case"InvalidValue":case"Forbidden":return N(e.annotations);case"MissingKey":return N(e.annotations,"messageMissingKey");case"UnexpectedKey":return N(e.ast.annotations,"messageUnexpectedKey");case"Filter":return N(e.filter.annotations);case"Encoding":return T(e.issue)}}function N(e,t="message"){let r=e?.[t];if("string"==typeof r)return r}function M(e){return s.isNone(e)?"no value provided":(0,i.GP)(e.value)}r.d(t,{E8:()=>x,ID:()=>E,L8:()=>k,Mw:()=>p,W:()=>w,Wi:()=>f,cw:()=>v,dJ:()=>d,eC:()=>g,eE:()=>y,gh:()=>c,gm:()=>h,h6:()=>b,vF:()=>m},{vp:S})},4858(e,t,r){var n=r(8927),i=r(8543),a=r(7720),s=r(7598),o=r(4650),l=r(8045),c=r(3833),u=r(5369),d=r(995),f=r(9177),h=r(6030);let p=(0,o.Bj)(e=>{switch(e._tag){case"Declaration":{let t=e.annotations?.[f.YA];if(u.Tn(t)){let r=t(e.typeParameters),n=p(r.to);return f.ES(e,n===r.to?[r]:[new f.N_(n,r.transformation)])}return e}case"Objects":case"Arrays":return e.recur(e=>{let t=e.context?.defaultValue;return t?f.ES(p(e),t):p(e)});case"Suspend":return e.recur(p);default:return e}});function m(e){let t=$(p(f.Ax(e.ast)));return(e,r)=>t(e,r?.disableChecks?r?.parseOptions?{...r.parseOptions,disableChecks:!0}:{disableChecks:!0}:r?.parseOptions)}function g(e){let t=m(e);return(e,r)=>{let n=a.lKS(t(e,r));return s.oJ(n)?c.some(n.value):(l.q(n.cause,"Option adapter can only return none for schema issues"),c.none())}}function y(e){let t=m(e);return(e,r)=>{let n=a.lKS(t(e,r));if(s.oJ(n))return n.value;let i=l.q(n.cause,"Constructor adapter can only throw schema issues");throw Error(i.toString(),{cause:i})}}function b(e){var t;let r;return t=e.ast,r=E($(f.Ax(t))),e=>{let t=r(e,f.vr);return!!s.oJ(t)||(l.q(t.cause,"Type guard adapter can only return false for schema issues"),!1)}}function v(e,t){let r=E($(f.Ax(e.ast)))(t,f.vr);if(s.N6(r)){let e=l.q(r.cause,"Assertion adapter can only throw schema issues");throw Error(e.toString(),{cause:e})}}function w(e,t){let r=$(e.ast);return void 0===t?r:(e,n)=>r(e,S(t,n))}function x(e,t){return O(w(e,t))}function _(e,t){let r;return r=E(w(e,t)),(e,t)=>{let n=r(e,t);return s.oJ(n)?d.Py(n.value):d.fJ(l.q(n.cause,"Result adapter can only return schema issues"))}}function k(e,t){let r;return O((r=$(f.UU(e.ast)),void 0===t?r:(e,n)=>r(e,S(t,n))))}let S=(e,t)=>void 0===t?e:{...e,...t};function $(e){let t=A(e);return(e,r)=>a.Ab9(t(c.some(e),r??f.vr),e=>"None"===e._tag?a.fJG(new h.h6(e)):a.PyW(e.value))}function E(e){return(t,r)=>a.lKS(e(t,r))}function O(e){let t=E(e);return(e,r)=>{let n=t(e,r);return s.oJ(n)?c.some(n.value):(l.q(n.cause,"Option adapter can only return none for schema issues"),c.none())}}function I(e,t){return a.Tyx(e,e=>a.pVV(()=>i.Tj(e,t)))}let A=(0,o.Bj)(e=>{let t,r=e.checks,i=e.encoding,s=i?.length??0,o=e.encodingChecks,l=(r?r[r.length-1].annotations:e.annotations)?.parseOptions;if(!e.context&&!i&&!r&&!o)return(r,n)=>(t??=e.getParser(A),l&&(n={...n,...l}),t(r,n));let u=f.tF(e)||f.RP(e)||f.HC(e)&&e.typeParameters.length>0,d=r&&u?r.filter(e=>e.annotations?.[f.C3]):void 0;return(u,p)=>{let m;if(l&&(p={...p,...l}),i){for(let e=s-1;e>=0;e--){let t=i[e],r=A(t.to);if(m=m?a.Ab9(m,e=>r(e,p)):r(u,p),"Transformation"===t.transformation._tag){let e=t.transformation.decode;m=a.Ab9(m,t=>e.run(t,p))}else m=t.transformation.decode(m,p)}m=I(m,t=>new h.Wi(e,u,t))}t??=e.getParser(A);let g=i=>{let s=t(i,p);return o&&!p?.disableChecks&&(s=a.Ab9(s,t=>{if(c.isSome(i)&&c.isSome(t)){let t=[];if(f.Lp(o,i.value,t,e,p),n.CZ(t))return a.fJG(new h.eC(e,i,t))}return a.PyW(t)})),r&&!p?.disableChecks&&(p?.errors==="all"&&d&&d.length>0&&c.isSome(i)&&(s=I(s,t=>{let r=[];return f.Lp(d,i.value,r,e,p),n.CZ(r)?"Composite"===t._tag&&t.ast===e?new h.eC(e,t.actual,[...t.issues,...r]):new h.eC(e,i,[t,...r]):t})),s=a.Ab9(s,t=>{if(c.isSome(t)){let i=t.value,s=[];if(f.Lp(r,i,s,e,p),n.CZ(s))return a.fJG(new h.eC(e,t,s))}return a.PyW(t)})),s};return m?a.Ab9(m,g):g(u)}});r.d(t,{IQ:()=>k,L8:()=>y,YY:()=>g,_R:()=>w,is:()=>b,kv:()=>v,o:()=>m,q$:()=>_,y9:()=>x},{GP:k,mR:x})},5348(e,t,r){var n=r(631),i=r(4705),a=r(2302),s=r(7720),o=r(6470),l=r(3833),c=r(5369),u=r(6310),d=r(6030);let f="~effect/SchemaTransformation/Transformation";class h{[f]=f;_tag="Transformation";decode;encode;constructor(e,t){this.decode=e,this.encode=t}flip(){return new h(this.encode,this.decode)}compose(e){return new h(this.decode.compose(e.decode),e.encode.compose(this.encode))}}function p(e){return new h(u.K$(e.decode),u.K$(e.encode))}function m(e){return new h(u.pd(e.decode),u.pd(e.encode))}let g=new h(u.le(),u.le());function y(){return g}let b=new h(u.wN(),u.Qf()),v=new h(u.Qw(),u.Qf()),w=new h(u.n9(),u.pd(o.Yq)),x=new h(u.n9(),u.pd(e=>e.getTime())),_=p({decode:e=>l.match(a.lX(e),{onNone:()=>s.fJG(new d.h6(l.some(e),{message:`Invalid Duration string: ${e}`})),onSome:s.PyW}),encode:e=>s.PyW(globalThis.String(e))}),k=p({decode:e=>s.PyW(a.cF(e)),encode:e=>l.match(a.tb(e),{onNone:()=>s.fJG(new d.h6(l.some(e),{message:`Unable to encode ${e} into a bigint`})),onSome:e=>s.PyW(e)})}),S=m({decode:e=>a.ne(e),encode:e=>a.kE(e)}),$=e=>{let t;return c.Gv(e)&&"string"==typeof e.message?(t=Object.hasOwn(e,"cause")?Error(e.message,{cause:$(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},E=p({decode:e=>URL.canParse(e)?s.PyW(new URL(e)):s.fJG(new d.h6(l.some(e),{message:`Invalid URL string: ${e}`})),encode:e=>s.PyW(e.href)}),O=p({decode:e=>{let t=n.sH(e);return l.isNone(t)?s.fJG(new d.h6(l.some(e),{message:`Invalid BigDecimal string: ${e}`})):s.PyW(t.value)},encode:e=>s.PyW(n.GP(e))}),I=new h(u.y4(),u.WG()),A=new h(u.$T(),u.WG()),C=new h(u.UD(),u.DX()),T=new h(u.xQ(),u.mU()),N=new h(u.mF(),u._p()),M=m({decode:e=>i.ko(e),encode:e=>e.offset}),P=p({decode:e=>l.match(i.y3(e),{onNone:()=>s.fJG(new d.h6(l.some(e),{message:`Invalid IANA time zone: ${e}`})),onSome:s.PyW}),encode:e=>s.PyW(e.id)}),j=p({decode:e=>l.match(i.ez(e),{onNone:()=>s.fJG(new d.h6(l.some(e),{message:`Invalid time zone: ${e}`})),onSome:s.PyW}),encode:e=>s.PyW(i.xV(e))}),D=p({decode:e=>l.match(i.L8(e),{onNone:()=>s.fJG(new d.h6(l.some(e),{message:`Invalid UTC DateTime string: ${e}`})),onSome:e=>s.PyW(i.yT(e))}),encode:e=>s.PyW(i.dv(e))}),U=p({decode:e=>l.match(i.MO(e),{onNone:()=>s.fJG(new d.h6(l.some(e),{message:`Invalid Zoned DateTime string: ${e}`})),onSome:s.PyW}),encode:e=>s.PyW(i.Rd(e))});r.d(t,{IT:()=>h,K$:()=>p,le:()=>y,pd:()=>m},{Ct:A,EJ:_,HO:x,I9:M,L8:e=>c.i5(e,f)?e:new h(e.decode,e.encode),LL:C,Nh:D,PE:S,Pp:N,R7:v,U0:I,XU:j,Y5:T,YZ:w,ZK:b,d9:U,dG:O,m8:k,nY:E,sm:e=>{let t,r;return m({decode:$,encode:(t=new WeakSet,r=n=>{if(c.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,o.IB)(n);return void 0===e?(0,o.GP)(n):JSON.parse(e)}catch{return(0,o.GP)(n)}})})},yd:P})},2672(e,t,r){var n=r(1136);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 c=n.pSt,u=n.vDJ;n.fou,n.mdu,r.d(t,{},{Fp:c,Gt:s,HG:i,LZ:a,U9:l,VN:u,a6:o})},755(e,t,r){let n,i;var a=r(8619),s=r(4650),o=r(3833);let l="effect/Tracer/ParentSpan";class c extends a.kl()(l){}let u=a.Or("effect/Tracer/DisablePropagation",{defaultValue:s.f4}),d=a.Or("effect/Tracer/CurrentTraceLevel",{defaultValue:()=>"Info"}),f=a.Or("effect/Tracer/MinimumTraceLevel",{defaultValue:()=>"All"}),h="effect/Tracer",p=a.Or(h,{defaultValue:()=>({span:e=>new m(e)})});class m{_tag="Span";spanId;traceId="native";sampled;name;parent;annotations;links;startTime;kind;status;attributes;events=[];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},this.attributes=new Map,this.traceId=o.getOrUndefined(e.parent)?.traceId??g(32),this.spanId=g(16)}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)}}let g=(i=(n="abcdef0123456789").length,function(e){let t="";for(let r=0;r<e;r++)t+=n.charAt(Math.floor(Math.random()*i));return t});r.d(t,{Tv:()=>c,W1:()=>m},{DW:u,EW:f,RL:h,WG:l,pX:d,sh:p})},3537(e,t,r){let n,i;class a{called=!1;self;constructor(e){this.self=e}next(e){return this.called?{value:e,done:!0}:(this.called=!0,{value:this.self,done:!1})}[Symbol.iterator](){return new a(this.self)}}let s=(i={[n="~effect/Utils/internal"]:e=>e()},i[n](()=>Error().stack)?.includes(n)===!0?i[n]:({[n]:e=>e()})[n]);r.d(t,{B:()=>a},{s:s})},8433(e,t,r){let n;var i=r(8036),a=r(6470),s=r(4650),o=r(4450),l=r(6400),c=r(9138),u=r(5369),d=r(3537);let f="~effect/Effect",h="~effect/Exit",p={_A:s.D_,_E:s.D_,_R:s.D_},m=`${f}/identifier`,g=`${f}/args`,y=`${f}/evaluate`,b=`${f}/successCont`,v=`${f}/failureCont`,w=`${f}/ensureCont`,x=Symbol.for("effect/Effect/Yield"),_={pipe(){return(0,c.tT)(this,arguments)},toJSON(){return{...this}},toString(){return(0,a.GP)(this.toJSON(),{ignoreToString:!0,space:2})},[l.FX](){return this.toJSON()}},k={[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}},S={[f]:p,..._,[Symbol.iterator](){return new d.B(this)},toJSON(){return{_id:"Effect",op:this[m],...g in this?{args:this[g]}:void 0}}},$=e=>(0,u.i5)(e,h),E="~effect/Cause",O="~effect/Cause/Reason",I=e=>(0,u.i5)(e,E);class A{[E];reasons;constructor(e){this[E]=E,this.reasons=e}pipe(){return(0,c.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 I(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 C=new WeakMap;class T{[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=C.get(r);e&&(t=new Map([...e,...t])),C.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,c.tT)(this,arguments)}toString(){return(0,a.GP)(this)}[l.FX](){return this.toString()}}let N=new Map;class M extends T{error;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 F(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 P=new A([]),j=e=>new A([new M(e)]);class D extends T{defect;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 L(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 U=e=>new A([new D(e)]),R=(0,s.XY)(e=>I(e[0]),(e,t,r)=>0===t.mapUnsafe.size?e:new A(e.reasons.map(e=>e.annotate(t,r)))),F=e=>"Fail"===e._tag,L=e=>"Die"===e._tag;function B(e){return V("Effect.evaluate: Not implemented")}let Y=e=>({...S,[m]:e.op,[y]:e[y]??B,[b]:e[b],[v]:e[v],[w]:e[w]}),q=e=>{let t=Y(e);return function(){let r=Object.create(t);return r[g]=!1===e.single?arguments:arguments[0],r}},W=e=>{let t={...Y(e),[h]:h,_tag:e.op,get[e.prop](){return this[g]},toString(){return`${e.op}(${(0,a.GP)(this[g])})`},toJSON(){return{_id:"Exit",_tag:e.op,[e.prop]:this[g]}},[i.HR](e){return $(e)&&e._tag===this._tag&&i.aI(this[g],e[g])},[o.HR](){return o.kg(o.Yj(e.op),o.tW(this[g]))}};return function(e){let r=Object.create(t);return r[g]=e,r}},X=W({op:"Success",prop:"value",[y](e){let t=e.getCont(b);return t?t[b](this[g],e,this):e.yieldWith(this)}}),J={key:"effect/Cause/StackTrace"},z=W({op:"Failure",prop:"cause",[y](e){let t=this[g],r=!1;e.currentStackFrame&&(t=R(t,{mapUnsafe:new Map([[J.key,e.currentStackFrame]])}),r=!0);let n=e.getCont(v);for(;e.interruptible&&e._interruptedCause&&n;)n=e.getCont(v);return n?n[v](t,e,r?void 0:this):e.yieldWith(r?this:z(t))}}),K=e=>z(j(e)),V=e=>z(U(e)),G=q({op:"WithFiber",[y](e){return this[g](e)}}),H=function(){class e extends globalThis.Error{}let t=Y({op:"YieldableError",[y](){return K(this)}});return delete t.toString,Object.assign(e.prototype,t),e}(),Q=(n=Symbol.for("effect/Data/Error/plainArgs"),class extends H{constructor(e){super(e?.message,e?.cause?{cause:e.cause}:void 0),e&&(Object.assign(this,e),Object.defineProperty(this,n,{value:e,enumerable:!1}))}toJSON(){return{...this[n],...this}}}),Z=e=>{class t extends Q{_tag=e}return t.prototype.name=e,t},ee="~effect/Cause/NoSuchElementError";class et extends Z("NoSuchElementError"){[ee]=ee;constructor(e){super({message:e})}}let er="~effect/Cause/Done",en={[er]:er,_tag:"Done",value:void 0},ei=e=>void 0===e?en:{[er]:er,_tag:"Done",value:e},ea=K(en);r.d(t,{ET:()=>T,Xm:()=>et,dM:()=>M,s0:()=>A},{$D:Q,$L:e=>(0,u.i5)(e,er),$n:f,Aj:I,B4:O,DH:P,Eh:R,GN:x,IH:h,In:k,Iu:U,OE:j,PW:e=>(0,u.i5)(e,ee),PX:E,QJ:{key:"effect/Cause/InterruptorStackTrace"},R6:G,RS:ei,Rk:K,Sc:v,Uf:q,V2:V,Vw:e=>void 0===e?ea:K(ei(e)),Wg:e=>(0,u.i5)(e,O),Xb:L,_3:y,a2:g,b5:e=>new A(e),b9:$,cb:z,dO:N,ee:b,fU:_,ik:e=>"Interrupt"===e._tag,lC:F,qB:ee,q_:er,rN:Z,u4:w,xt:X,yj:Y,yw:e=>(0,u.i5)(e,f),z8:J})},2849(e,t,r){var n=r(4650);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)})))})},1136(e,t,r){let n,i,a;r.d(t,{RD4:()=>i2,cOF:()=>i0,a1U:()=>iD,z4N:()=>i8,d$_:()=>i7,Do:()=>nz,Aub:()=>iZ,F7W:()=>iH,qwd:()=>iG,t8c:()=>iK,LkF:()=>i4,olX:()=>ae,obm:()=>rK,kWD:()=>rz,MUS:()=>iz,DQo:()=>iX,Bk6:()=>i6,Kkt:()=>i5,dsN:()=>nO,N24:()=>nm,Q56:()=>nn,jGc:()=>np,U9h:()=>ni,Q7R:()=>nI,hgn:()=>tr,ww9:()=>iM,gsV:()=>at,Muk:()=>iN,as:()=>e7,Xx$:()=>te,NLW:()=>ti,PCg:()=>n0,oIE:()=>nV,JrD:()=>nK,PO3:()=>nb,CJw:()=>ng,Rgn:()=>ny,E2r:()=>eQ,Tyx:()=>rt,rNk:()=>ri,sJf:()=>rn,Fig:()=>ro,UVN:()=>tw,osR:()=>rm,XWm:()=>rp,U9Y:()=>rs,AXC:()=>rb,zt4:()=>rv,KuX:()=>rg,loE:()=>ry,h_t:()=>ra,On5:()=>G,h2c:()=>H,Bou:()=>X,nIy:()=>j,h74:()=>J,O$X:()=>Q,GyP:()=>el,RJ6:()=>ee,ReC:()=>Z,RKA:()=>iB,_OA:()=>tV,sxi:()=>tH,Wj8:()=>ij,_32:()=>iP,Rud:()=>iq,s0X:()=>iW,cbG:()=>rY,F_Q:()=>eB,OY:()=>th,yeE:()=>no,u4Y:()=>rE,NS5:()=>rR,Hox:()=>tL,ely:()=>tB,yJo:()=>tO,HIt:()=>tE,K$2:()=>tk,GUt:()=>tS,jCT:()=>tA,_OD:()=>tI,lgw:()=>tW,Sv3:()=>tq,kMI:()=>tY,YDM:()=>tT,_mh:()=>tN,lNM:()=>tC,_sz:()=>tx,VE1:()=>t$,CoE:()=>t_,v9O:()=>tP,EkE:()=>tD,zPu:()=>tj,Wtn:()=>tF,x5l:()=>tM,il9:()=>tR,fJG:()=>eA,ATB:()=>eI,pVV:()=>eL,gOk:()=>eY,pEE:()=>eK,zFM:()=>ev,C6p:()=>ew,ABT:()=>eV,mKq:()=>ek,DKo:()=>e$,$MQ:()=>eE,eGS:()=>eS,D7p:()=>ex,INJ:()=>e_,vTQ:()=>n3,pbD:()=>nW,x1Q:()=>nX,E8K:()=>nJ,VtY:()=>nY,ahH:()=>nq,Pm0:()=>nB,W$I:()=>t8,BbX:()=>Y,k7S:()=>B,khU:()=>R,L$u:()=>F,QE5:()=>U,i8i:()=>nT,kAe:()=>nM,tU5:()=>W,Dd:()=>r$,qIB:()=>tu,Ab9:()=>tp,Bqz:()=>tm,UUz:()=>tt,fn:()=>e3,D9k:()=>e1,vCS:()=>e8,jJl:()=>nD,i4r:()=>re,zhn:()=>nH,yxg:()=>nZ,ar0:()=>n1,x6Z:()=>n2,bJ:()=>eP,sVm:()=>eN,yUA:()=>eM,JkU:()=>e0,Iku:()=>ep,gpn:()=>L,myX:()=>D,prj:()=>q,nn5:()=>K,XeO:()=>rO,GrF:()=>rI,GaK:()=>nv,Inz:()=>nS,eMl:()=>nE,Rft:()=>i1,ASO:()=>iQ,N6O:()=>rL,_y:()=>iV,OPA:()=>i9,oJd:()=>rB,c8t:()=>iJ,PnV:()=>i3,h$X:()=>nF,uVU:()=>nG,A_r:()=>iE,lIX:()=>aa,ORc:()=>P,Fbb:()=>id,zzk:()=>iu,Z98:()=>ix,Rd$:()=>i_,TjK:()=>tg,UcN:()=>r_,q7Y:()=>tv,jkJ:()=>ty,xm_:()=>rx,Z9x:()=>tb,YWq:()=>rj,D$$:()=>rM,NZb:()=>rU,khu:()=>rT,wR5:()=>tf,G$Q:()=>rD,tvg:()=>rP,ZmZ:()=>eZ,S5A:()=>nu,iKM:()=>nf,BeE:()=>nd,cfM:()=>ns,uRq:()=>nc,fGe:()=>nl,r7h:()=>na,nAr:()=>nh,uKv:()=>rA,QgK:()=>rk,DM4:()=>rS,jBG:()=>nA,ivC:()=>eX,PpN:()=>tZ,AAo:()=>r7,PfK:()=>t0,c7E:()=>t2,O4F:()=>tl,Vdx:()=>ts,FfP:()=>to,KT6:()=>tc,tQ6:()=>V,aAq:()=>t9,Xrv:()=>t7,Ket:()=>rC,bPG:()=>n4,lSz:()=>n8,MY7:()=>n6,eJC:()=>n5,pR5:()=>it,NpQ:()=>n7,jqV:()=>n9,v2Q:()=>ie,HZF:()=>is,lKS:()=>ii,rfH:()=>ir,lE:()=>ia,_Sg:()=>ta,z8E:()=>r9,iLB:()=>r2,Uio:()=>r1,vDJ:()=>rG,fou:()=>rH,Z$R:()=>rZ,pSt:()=>r0,RWE:()=>r4,d97:()=>r6,DLK:()=>rV,mdu:()=>nt,P1j:()=>ne,Pxi:()=>nr,euC:()=>tX,Nav:()=>tJ,oao:()=>tQ,yy4:()=>iY,Fu6:()=>iS,WbR:()=>i$,PyW:()=>eO,lwU:()=>eR,nGE:()=>eU,DYE:()=>eT,OH5:()=>eC,Mim:()=>tn,dGm:()=>rl,bKC:()=>ru,cA6:()=>rc,nAi:()=>rh,sFT:()=>rd,k$L:()=>rf,ayu:()=>rJ,wRz:()=>rW,D52:()=>rX,mgX:()=>rq,kJM:()=>ih,pkL:()=>eF,SvU:()=>eW,$mh:()=>eJ,Vxk:()=>al,rfi:()=>nw,FcF:()=>n$,scW:()=>rw,r_d:()=>tz,bUZ:()=>tK,gvr:()=>iI,tfT:()=>nC,rIH:()=>eq,z7s:()=>t4,iMI:()=>nj,KyM:()=>t5,$$g:()=>ac,hq:()=>iC,fRP:()=>iT,zr8:()=>ik,_o1:()=>ip,nDN:()=>im,MaT:()=>ig,m9E:()=>eD,KN3:()=>ej,yU6:()=>t3,OYO:()=>t6});var s=r(8927),o=r(8619),l=r(2302),c=r(8036),u=r(956),d=r(6470),f=r(4650),h=r(4450),p=r(6400),m=r(8496),g=r(3833),y=r(6364),b=r(9138),v=r(5369),w=r(1743),x=r(995),_=r(8469),k=r(755),S=r(3537),$=r(8433),E=r(2849),O=r(9354),I=r(8344),A=r(3628);let C=e=>{if(e?.captureStackTrace===!1||e?.captureStackTrace!==void 0&&"boolean"!=typeof e.captureStackTrace)return e;let t=(0,A.jt)();(0,A.ft)(3);let r=Error();return(0,A.ft)(t),{...e,captureStackTrace:N(()=>r.stack)}},T=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()}},N=T(3);class M extends $.ET{fiberId;constructor(e,t=$.dO){super("Interrupt",t,"Interrupted"),this.fiberId=e}toString(){return`Interrupt(${this.fiberId})`}toJSON(){return{_tag:"Interrupt",fiberId:this.fiberId}}[c.HR](e){return(0,$.ik)(e)&&this.fiberId===e.fiberId&&this.annotations===e.annotations}[h.HR](){return h.kg(h.Yj(`${this._tag}:${this.fiberId}`))(h.yT(this.annotations))}}let P=e=>new M(e),j=e=>new $.s0([new M(e)]),D=e=>e.reasons.some($.lC),U=e=>{let t=e.reasons.find($.lC);return t?x.Py(t):x.fJ(e)},R=e=>{for(let t=0;t<e.reasons.length;t++){let r=e.reasons[t];if("Fail"===r._tag)return x.Py(r.error)}return x.fJ(e)},F=u.zL(R),L=e=>e.reasons.some($.Xb),B=e=>{let t=e.reasons.find($.Xb);return t?x.Py(t):x.fJ(e)},Y=e=>{let t=e.reasons.find($.Xb);return t?x.Py(t.defect):x.fJ(e)},q=e=>e.reasons.some($.ik),W=e=>{let t=e.reasons.find($.ik);return t?x.Py(t):x.fJ(e)},X=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?x.Py(t):x.fJ(e)},J=e=>{let t=X(e);return x.N6(t)?z:t.success},z=new Set,K=e=>e.reasons.length>0&&e.reasons.every($.ik),V=e=>o.LZ(e.annotations),G=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 o.LZ(t)},H=(0,f.XY)(2,(e,t)=>{if(0===e.reasons.length)return t;if(0===t.reasons.length)return e;let r=new $.s0(s.KC(e.reasons,t.reasons));return c.aI(e,r)?e:r}),Q=(0,f.XY)(2,(e,t)=>{let r=!1,n=e.reasons.map(e=>(0,$.lC)(e)?(r=!0,new $.dM(t(e.error))):e);return r?(0,$.b5)(n):e}),Z=e=>{let t=(e=>{let t={Fail:[],Die:[],Interrupt:[]};for(let r=0;r<e.reasons.length;r++)t[e.reasons[r]._tag].push(e.reasons[r]);return t})(e);return t.Fail.length>0?t.Fail[0].error:t.Die.length>0?t.Die[0].defect:t.Interrupt.length>0?new globalThis.Error("All fibers interrupted without error"):new globalThis.Error("Empty cause")},ee=(e,t)=>{let r=[],n=[];if(0===e.reasons.length)return r;let i=(0,A.jt)();for(let i of((0,A.ft)(1),e.reasons)){if("Interrupt"===i._tag){n.push(i);continue}r.push(et("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=es(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(et(i,n[0].annotations,t))}return(0,A.ft)(i),r},et=(e,t,r)=>{let n,i=typeof e;if(e&&"object"===i){if(n=new globalThis.Error(er(e),{cause:e.cause?et(e.cause):void 0}),"string"==typeof e.name&&(n.name=e.name),"string"==typeof e.stack)n.stack=ei(e.stack,n,t);else{let e=`${n.name}: ${n.message}`;n.stack=t?ea(e,t):e}for(let t of(r?.includeCauseInStack&&(n.stack=ec(n)),Object.keys(e)))t in n||(n[t]=e[t])}else n=new globalThis.Error(!e?`Unknown error: ${e}`:"string"===i?e:(0,d.IB)(e));return n},er=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,d.IB)(e)},en=/\((.*)\)/g,ei=(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)/.test(i[e]);e++)a.push(i[e]);return r?ea(a.join("\n"),r):a.join("\n")},ea=(e,t)=>{let r=t?.get($.z8.key);return r&&(e=`${e}
|
|
169
|
+
${eo(r)}`),e},es=(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($.QJ.key);r.push(` at fiber (${t})`),n&&r.push(eo(n))}return r.join("\n")},eo=e=>{let t=[],r=e,n=0;for(;r&&n<10;){let e=r.stack();if(e){let n=e.matchAll(en),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")},el=e=>ee(e).map(ec).join("\n"),ec=e=>e.cause?`${e.stack} {
|
|
157
170
|
${eu(e.cause," ")}
|
|
158
171
|
}`:e.stack,eu=(e,t)=>{let r=e.stack.split("\n"),n=`${t}[cause]: ${r[0]}`;for(let e=1,i=r.length;e<i;e++)n+=`
|
|
159
172
|
${t}${r[e]}`;return e.cause&&(n+=` {
|
|
160
173
|
${eu(e.cause,`${t} `)}
|
|
161
|
-
${t}}`),n},ed="~effect/Fiber/dev",ef={_A:f.D_,_E:f.D_},eh={id:0},ep=()=>globalThis[w.fL];class em{constructor(e,t=!0){this[ed]=ef,this.setContext(e),this.id=++eh.id,this.currentOpCount=0,this.currentLoopCount=0,this.interruptible=t,this._stack=[],this._observers=[],this._exit=void 0,this._children=void 0,this._interruptedCause=void 0,this._yielded=void 0,this.runtimeMetrics?.recordFiberStart(this.context)}[ed];id;interruptible;currentOpCount;currentLoopCount;_stack;_observers;_exit;_currentExit;_children;_interruptedCause;_yielded;context;currentScheduler;currentTracerContext;currentSpan;currentLogLevel;minimumLogLevel;currentStackFrame;runtimeMetrics;maxOpsBeforeYield;currentPreventYield;_dispatcher=void 0;get currentDispatcher(){return this._dispatcher??=this.currentScheduler.makeDispatcher()}getRef(e){return o.kA(this.context,e)}addObserver(e){return this._exit?(e(this._exit),f.Yi):(this._observers.push(e),()=>{let t=this._observers.indexOf(e);t>=0&&this._observers.splice(t,1)})}interruptUnsafe(e,t){if(this._exit)return;let r=j(e);this.currentStackFrame&&(r=(0,O.Eh)(r,o.L8(O.z8,this.currentStackFrame))),t&&(r=(0,O.Eh)(r,t)),this._interruptedCause=this._interruptedCause?H(this._interruptedCause,r):r,this.interruptible&&this.evaluate(eI(this._interruptedCause))}pollUnsafe(){return this._exit}evaluate(e){if(this._exit)return;if(void 0!==this._yielded){let e=this._yielded;this._yielded=void 0,e()}let t=this.runLoop(e);if(t===O.GN)return;let r=eg.interruptChildren&&eg.interruptChildren(this);if(void 0!==r)return this.evaluate(tu(r,()=>t));this._exit=t,this.runtimeMetrics?.recordFiberEnd(this.context,this._exit);for(let e=0;e<this._observers.length;e++)this._observers[e](t);this._observers.length=0}runLoop(e){let t=globalThis[w.fL];globalThis[w.fL]=this;let r=!1,n=e;this.currentOpCount=0;let i=++this.currentLoopCount;try{for(;;){if(this.currentOpCount++,!r&&!this.currentPreventYield&&this.currentScheduler.shouldYield(this)){r=!0;let e=n;n=tu(eD,()=>e)}if(n=this.currentTracerContext?this.currentTracerContext(n,this):n[O._3](this),i!==this.currentLoopCount)return O.GN;if(n===O.GN){let e=this._yielded;if(O.IH in e)return this._yielded=void 0,e;return O.GN}}}catch(e){if(!(0,v.i5)(n,O._3))return(0,O.V2)(`Fiber.runLoop: Not a valid effect: ${String(n)}`);return this.runLoop((0,O.V2)(e))}finally{globalThis[w.fL]=t}}getCont(e){for(;;){let t=this._stack.pop();if(!t)return;let r=t[O.u4]&&t[O.u4](this);if(r)return r[e]=r,r;if(t[e])return t}}yieldWith(e){return this._yielded=e,O.GN}children(){return this._children??=new Set}pipe(){return(0,b.tT)(this,arguments)}setContext(e){this.context=e;let t=this.getRef(_._F);t!==this.currentScheduler&&(this.currentScheduler=t,this._dispatcher=void 0),this.currentSpan=e.mapUnsafe.get(k.WG),this.currentLogLevel=this.getRef(I.Gl),this.minimumLogLevel=this.getRef(I.zQ),this.currentStackFrame=e.mapUnsafe.get(I.vA.key),this.maxOpsBeforeYield=this.getRef(_.Zm),this.currentPreventYield=this.getRef(_.hf),this.runtimeMetrics=e.mapUnsafe.get($.F);let r=e.mapUnsafe.get(k.RL);this.currentTracerContext=r?r.context:void 0}get currentSpanLocal(){return this.currentSpan?._tag==="Span"?this.currentSpan:void 0}}let eg={interruptChildren:void 0},ey=e=>{if(!e.currentStackFrame)return;let t=new Map;return t.set(O.z8.key,e.currentStackFrame),o.LZ(t)},eb=e=>{if(void 0!==e._children&&0!==e._children.size)return eO(e._children)},ev=e=>e._exit?e$(e._exit):eQ(t=>e._exit?t(e$(e._exit)):eC(e.addObserver(e=>t(e$(e))))),ew=e=>eQ(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(e$(i))}(),eC(()=>r?.())}),ex=e=>e._exit?e._exit:eQ(t=>e._exit?t(e._exit):eC(e.addObserver(t))),e_=e=>eQ(t=>{let r=Array.from(e);if(0===r.length)return t(e$(s.Ie()));let n=Array(r.length),i=s.Ie(),a=0,o=!1;for(let e=0;e<r.length&&!o;e++)i.push(r[e].addObserver(s=>{if(a++,"Failure"===s._tag)return o=!0,i.forEach(e=>e()),t(s);n[e]=s.value,a===r.length&&t(e$(n))}))}),ek=e=>(0,O.R6)(t=>eS(e,t.id)),eS=(0,f.XY)(e=>(0,v.i5)(e[0],ed),(e,t,r)=>(0,O.R6)(n=>{let i=ey(n);return i=i&&r?o.h1(i,r):i??r,e.interruptUnsafe(t,i),ti(ev(e))})),eO=e=>(0,O.R6)(t=>{let r=ey(t),n=s.Ie();for(let i of e)i.interruptUnsafe(t.id,r),n.push(i);return ti(ew(n))}),eE=(0,f.XY)(2,(e,t)=>(0,O.R6)(r=>{let n=ey(r),i=s.Ie();for(let r of e)r.interruptUnsafe(t,n),i.push(r);return ti(ew(i))})),e$=O.xt,eI=O.cb,eA=O.Rk,eC=(0,O.Uf)({op:"Sync",[O._3](e){let t=this[O.a2](),r=e.getCont(O.ee);return r?r[O.ee](t,e):e.yieldWith((0,O.xt)(t))}}),eT=(0,O.Uf)({op:"Suspend",[O._3](e){return this[O.a2]()}}),eN=(0,f.XY)(e=>e.length>=2||g.isOption(e[0]),(e,t)=>g.isNone(e)?eA(t?t():new O.Xm("Effect.fromOption: Option.none")):e$(e.value)),eM=x.YW({onFailure:eA,onSuccess:e$}),eP=e=>null==e?eA(new O.Xm):e$(e),ej=(0,O.Uf)({op:"Yield",[O._3](e){let t=!1;return e.currentDispatcher.scheduleTask(()=>{t||e.evaluate(tM)},this[O.a2]??0),e.yieldWith(()=>{t=!0})}}),eD=ej(0),eU=e=>e$(g.some(e)),eF=e$(g.none()),eR=e=>g.isNone(e)?eF:tg(e.value,g.some),eL=e=>eT(()=>eI((0,S.s)(e))),eB=e=>(0,O.V2)(e),eY=e=>eT(()=>eA((0,S.s)(e))),eq=e$(void 0),eX=e=>{let t="function"==typeof e?e:e.try,r="function"==typeof e?e=>new i6(e,"An error occurred in Effect.try"):e.catch;return eT(()=>{try{return e$((0,S.s)(t))}catch(e){return eA((0,S.s)(()=>r(e)))}})},eW=e=>eG(function(t,r){(0,S.s)(()=>e(r)).then(e=>t(e$(e)),e=>t(eB(e)))},0!==e.length),eJ=e=>{let t="function"==typeof e?e:e.try,r="function"==typeof e?e=>new i6(e,"An error occurred in Effect.tryPromise"):e.catch;return eG(function(e,n){let i=t=>{try{e(eA((0,S.s)(()=>r(t))))}catch(t){e(eB(t))}};try{(0,S.s)(()=>t(n)).then(t=>e(e$(t)),i)}catch(e){i(e)}},0!==t.length)},ez=e=>(0,O.R6)(t=>e(t.id)),eK=(0,O.R6)(e$),eV=ez(e$),eG=(0,O.Uf)({op:"Async",single:!1,[O._3](e){let t=(0,S.s)(()=>this[O.a2][0].bind(e.currentScheduler)),r=!1,n=!1,i=this[O.a2][1]?new AbortController:void 0,a=t(t=>{r||(r=!0,n?e.evaluate(t):n=t)},i?.signal);return!1!==n?n:(n=!0,e._yielded=()=>{r=!0},void 0===i&&void 0===a||e._stack.push(eH(()=>(r=!0,i?.abort(),a??tM))),O.GN)}}),eH=(0,O.Uf)({op:"AsyncFinalizer",[O.u4](e){e.interruptible&&(e.interruptible=!1,e._stack.push(n_))},[O.Sc](e,t){return q(e)?tu(this[O.a2](),()=>eI(e)):eI(e)}}),eQ=e=>eG(e,e.length>=2),eZ=eQ(f.Yi),e0=(...e)=>eT(()=>e9(1===e.length?e[0]():e[1].call(e[0].self))),e1=(e,...t)=>{let r=0===t.length?function(){return eT(()=>e9(e.apply(this,arguments)))}:function(){let r=eT(()=>e9(e.apply(this,arguments)));for(let e=0;e<t.length;e++)r=t[e](r,...arguments);return r};return e2(e.length,r)},e2=(e,t)=>Object.defineProperty(t,"length",{value:e,configurable:!0}),e3=T(2),e5=function(){let e="string"==typeof arguments[0],t=e?arguments[0]:"Effect.fn",r=e?arguments[1]:void 0,n=(0,A.jt)();(0,A.ft)(2);let i=new globalThis.Error;return((0,A.ft)(n),e)?(n,...a)=>e6(t,n,i,a,e,r):e6(t,arguments[0],i,Array.prototype.slice.call(arguments,1),e,r)},e6=(e,t,r,n,i,a)=>{let s="function"==typeof t?t:n.pop().bind(t.self);return e2(s.length,function(...t){let o=eT(()=>{let e=s.apply(this,arguments);return(0,O.yw)(e)?e:e9(e)});for(let e=0;e<n.length;e++)o=n[e](o,...t);if(!(0,O.yw)(o))return o;let l=(0,A.jt)();(0,A.ft)(2);let c=new globalThis.Error;return(0,A.ft)(l),tK(i?iI(e,a,e=>iA(o,e)):o,I.vA,t=>({name:e,stack:e3(()=>c.stack),parent:{name:`${e} (definition)`,stack:e3(()=>r.stack),parent:t}}))})},e8=(e,...t)=>e2(e.length,0===t.length?function(){return e4(()=>e.apply(this,arguments))}:function(){let r=e4(()=>e.apply(this,arguments));for(let e of t)r=e(r);return r}),e4=e=>{try{let t,r=e();for(;;){let n=r.next(t);if(n.done)return e$(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 eT(()=>t?(t=!1,tu(n.value,e=>e9(r,e))):eT(()=>e9(e())))}}}catch(e){return eB(e)}},e9=(0,O.Uf)({op:"Iterator",single:!1,[O.ee](e,t){let r=this[O.a2][0];for(;;){let n=r.next(e);if(n.done)return e$(n.value);if(!th(n.value))return t._stack.push(this),n.value;if("Failure"===n.value._tag)return n.value;e=n.value.value}},[O._3](e){return this[O.ee](this[O.a2][1],e)}}),e7=(0,f.XY)(2,(e,t)=>{let r=e$(t);return tu(e,e=>r)}),te=e=>tg(e,g.some),tt=e=>rP(e,{onFailure:e$,onSuccess:eA}),tr=(0,f.XY)(2,(e,t)=>tu(e,e=>(0,O.yw)(t)?t:(0,S.s)(()=>t(e)))),tn=(0,f.XY)(2,(e,t)=>tu(e,e=>e7((0,O.yw)(t)?t:(0,S.s)(()=>t(e)),e))),ti=e=>tu(e,e=>tM),ta=e=>rt(e,eA),ts=(e,t)=>(0,O.R6)(r=>eQ(n=>{let i=s.Ts(e),a=i.length,o=0,l=!1,c=new Set,u=[],d=(e,i,s)=>{if(o++,"Failure"===e._tag){u.push(...e.cause.reasons),o>=a&&n(eI((0,O.b5)(u)));return}let d=!l;l=!0,n(0===c.size?e:tu(nw(eO(c)),()=>e)),d&&t?.onWinner&&t.onWinner({fiber:i,index:s,parentFiber:r})};for(let e=0;e<a;e++){let t=nQ(r,i[e],!0,!0,!1);if(c.add(t),t.addObserver(r=>{c.delete(t),d(r,t,e)}),l)break}return eO(c)})),to=(e,t)=>(0,O.R6)(r=>eQ(n=>{let i=!1,a=new Set,s=e=>{i=!0,n(0===a.size?e:tu(nw(eO(a)),()=>e))},o=0;for(let n of e){if(i)break;let e=o++,l=nQ(r,n,!0,!0,!1);a.add(l),l.addObserver(n=>{a.delete(l);let o=!i;s(n),o&&t?.onWinner&&t.onWinner({fiber:l,index:e,parentFiber:r})})}return eO(a)})),tl=(0,f.XY)(e=>(0,O.yw)(e[1]),(e,t,r)=>ts([e,t],r)),tc=(0,f.XY)(e=>(0,O.yw)(e[1]),(e,t,r)=>to([e,t],r)),tu=(0,f.XY)(2,(e,t)=>{let r=Object.create(td);return r[O.a2]=e,r[O.ee]=1!==t.length?e=>t(e):t,r}),td=(0,O.yj)({op:"OnSuccess",[O._3](e){return e._stack.push(this),this[O.a2]}}),tf=(0,f.XY)(2,(e,t)=>th(e)?"Success"===e._tag?t.onSuccess(e.value):t.onFailure(e.cause):rT(e,t)),th=e=>O.IH in e,tp=(0,f.XY)(2,(e,t)=>th(e)?"Success"===e._tag?t(e.value):e:tu(e,t)),tm=e=>tu(e,f.D_),tg=(0,f.XY)(2,(e,t)=>tu(e,e=>e$((0,S.s)(()=>t(e))))),ty=(0,f.XY)(2,(e,t)=>th(e)?tP(e,t):tg(e,t)),tb=(0,f.XY)(2,(e,t)=>th(e)?tj(e,t):rx(e,t)),tv=(0,f.XY)(2,(e,t)=>th(e)?tD(e,t):r_(e,t)),tw=(0,f.XY)(2,(e,t)=>{if(th(e)){if("Success"===e._tag)return e;let r=F(e.cause);return x.N6(r)?e:t(r.success)}return ra(e,t)}),tx=e=>(0,O.cb)(j(e)),t_=e=>"Success"===e._tag,tk=e=>"Success"===e._tag?x.Py(e):x.fJ(e),tS=e=>"Success"===e._tag?x.Py(e.value):x.fJ(e),tO=e=>"Failure"===e._tag,tE=e=>"Failure"===e._tag?x.Py(e):x.fJ(e),t$=e=>"Failure"===e._tag?x.Py(e.cause):x.fJ(e),tI=u.Bh(t$,F),tA=u.Bh(t$,Y),tC=e=>"Failure"===e._tag&&q(e.cause),tT=e=>"Failure"===e._tag&&L(e.cause),tN=e=>"Failure"===e._tag&&D(e.cause),tM=(0,O.xt)(void 0),tP=(0,f.XY)(2,(e,t)=>"Success"===e._tag?(0,O.xt)(t(e.value)):e),tj=(0,f.XY)(2,(e,t)=>{if("Success"===e._tag)return e;let r=F(e.cause);return x.N6(r)?e:(0,O.Rk)(t(r.success))}),tD=(0,f.XY)(2,(e,t)=>{if("Success"===e._tag)return(0,O.xt)(t.onSuccess(e.value));let r=F(e.cause);return x.N6(r)?e:(0,O.Rk)(t.onFailure(r.success))}),tU=(0,f.XY)(2,(e,t)=>t_(e)?(0,O.xt)(t):e),tF=(0,f.XY)(2,(e,t)=>t_(e)?t:e),tR=(0,f.XY)(2,(e,t)=>t_(e)?t.onSuccess(e.value):t.onFailure(e.cause)),tL=tU(void 0),tB=e=>{let t=[];for(let r of e)"Failure"===r._tag&&t.push(...r.cause.reasons);return 0===t.length?tM:(0,O.cb)((0,O.b5)(t))},tY=e=>t_(e)?g.some(e.value):g.none(),tq=e=>tO(e)?g.some(e.cause):g.none(),tX=e=>{let t=tI(e);return x.N6(t)?g.none():g.some(t.success)},tW=e=>e,tJ=e=>(0,O.R6)(t=>e$(o.om(t.context,e))),tz=(0,f.XY)(2,(e,t)=>(0,O.R6)(r=>{let n=r.context,i=t(n);return n===i?e:(r.setContext(i),na(e,()=>{r.setContext(n)}))})),tK=(0,f.XY)(3,(e,t,r)=>tz(e,e=>{let n=o.fp(e,t),i=r(n);return n===i?e:o.WQ(e,t,i)})),tV=()=>tG,tG=(0,O.R6)(e=>e$(e.context)),tH=e=>(0,O.R6)(t=>e(t.context)),tQ=(0,f.XY)(2,(e,t)=>tz(e,(0,f.dY)(t))),tZ=(0,f.XY)(2,(e,t)=>th(e)?e:tz(e,o.h1(t))),t0=function(){return 1==arguments.length?(0,f.XY)(2,(e,t)=>t1(e,arguments[0],t)):(0,f.XY)(3,(e,t,r)=>t1(e,t,r)).apply(this,arguments)},t1=(e,t,r)=>tz(e,e=>e.mapUnsafe.get(t.key)===r?e:o.WQ(e,t,r)),t2=(0,f.XY)(3,(e,t,r)=>tu(r,r=>t0(e,t,r))),t3=t0(I.F8),t5=(0,f.XY)(e=>(0,O.yw)(e[1]),(e,t,r)=>t6(e,t,(e,t)=>[e,t],r)),t6=(0,f.XY)(e=>(0,O.yw)(e[1]),(e,t,r,n)=>n?.concurrent?tg(nI([e,t],{concurrency:2}),([e,t])=>(0,S.s)(()=>r(e,t))):tu(e,e=>tg(t,t=>(0,S.s)(()=>r(e,t))))),t8=(0,f.XY)(e=>(0,O.yw)(e[0]),(e,t,r)=>nB(e,t,r?e=>eA(r(e)):()=>eA(new O.Xm))),t4=(0,f.XY)(2,(e,t)=>tu(t,t=>t?te(e):eF)),t9=(0,f.XY)(2,(e,t)=>Array.from({length:t},()=>e)),t7=(0,f.XY)(e=>(0,O.yw)(e[0]),(e,t,r)=>nI(t9(e,t),r)),re=(0,f.XY)(e=>(0,O.yw)(e[0]),(e,t)=>nj({while:f.ue,body:(0,f.dY)(t?.disableYield?e:tu(e,e=>eD)),step:f.Yi})),rt=(0,f.XY)(2,(e,t)=>{let r=Object.create(rr);return r[O.a2]=e,r[O.Sc]=1!==t.length?e=>t(e):t,r}),rr=(0,O.yj)({op:"OnFailure",[O._3](e){return e._stack.push(this),this[O.a2]}}),rn=(0,f.XY)(3,(e,t,r)=>rt(e,e=>t(e)?(0,S.s)(()=>r(e)):eI(e))),ri=(0,f.XY)(3,(e,t,r)=>rt(e,e=>{let n=t(e);return x.N6(n)?eI(n.failure):(0,S.s)(()=>r(n.success,e))})),ra=(0,f.XY)(2,(e,t)=>ri(e,F,e=>t(e))),rs=e=>rP(e,{onFailure:e=>(0,O.PW)(e)?eF:eA(e),onSuccess:eU}),ro=(0,f.XY)(2,(e,t)=>ri(e,Y,t)),rl=(0,f.XY)(2,(e,t)=>rt(e,e=>tr((0,S.s)(()=>t(e)),eI(e)))),rc=(0,f.XY)(3,(e,t,r)=>rn(e,t,e=>tr((0,S.s)(()=>r(e)),eI(e)))),ru=(0,f.XY)(3,(e,t,r)=>rt(e,e=>{let n=t(e);return x.N6(n)?eI(e):tr((0,S.s)(()=>r(n.success,e)),eI(e))})),rd=(0,f.XY)(2,(e,t)=>ru(e,F,e=>t(e))),rf=(0,f.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 rd(e,e=>n(e)?r(e):eq)}),rh=(0,f.XY)(2,(e,t)=>ru(e,Y,e=>t(e))),rp=(0,f.XY)(e=>(0,O.yw)(e[0]),(e,t,r,n)=>rt(e,e=>{let i=F(e);return x.N6(i)?eI(i.failure):t(i.success)?(0,S.s)(()=>r(i.success)):n?(0,S.s)(()=>n(i.success)):eI(e)})),rm=(0,f.XY)(e=>(0,O.yw)(e[0]),(e,t,r,n)=>rt(e,e=>{let i=F(e);if(x.N6(i))return eI(i.failure);let a=t(i.success);return x.N6(a)?n?(0,S.s)(()=>n(a.failure)):eI(e):(0,S.s)(()=>r(a.success))})),rg=(0,f.XY)(e=>(0,O.yw)(e[0]),(e,t,r,n)=>rp(e,Array.isArray(t)?e=>(0,v.i5)(e,"_tag")&&t.includes(e._tag):(0,v.$J)(t),r,n)),ry=(0,f.XY)(e=>(0,O.yw)(e[0]),(e,t,r)=>{let n;return rm(e,e=>(n??=Object.keys(t),(0,v.i5)(e,"_tag")&&(0,v.Kg)(e._tag)&&n.includes(e._tag)?x.Py(e):x.fJ(e)),e=>(0,S.s)(()=>t[e._tag](e)),r)}),rb=(0,f.XY)(e=>(0,O.yw)(e[0]),(e,t,r,n,i)=>rp(e,e=>(0,v.$J)(e,t)&&(0,v.i5)(e,"reason"),e=>{let t=e.reason;return(0,v.$J)(t,r)?n(t,e):i?(0,S.s)(()=>i(t,e)):eA(e)})),rv=(0,f.XY)(e=>(0,O.yw)(e[0]),(e,t,r,n)=>{let i;return rp(e,e=>(0,v.$J)(e,t)&&(0,v.i5)(e,"reason")&&(0,v.i5)(e.reason,"_tag")&&(0,v.Kg)(e.reason._tag),e=>{let t=e.reason;return(i??=Object.keys(r)).includes(t._tag)?(0,S.s)(()=>r[t._tag](t,e)):n?(0,S.s)(()=>n(t,e)):eA(e)})}),rw=(0,f.XY)(2,(e,t)=>rm(e,e=>(0,v.$J)(e,t)&&(0,v.i5)(e,"reason")?x.Py(e.reason):x.fJ(e),eA)),rx=(0,f.XY)(2,(e,t)=>ra(e,e=>eY(()=>t(e)))),r_=(0,f.XY)(2,(e,t)=>rP(e,{onFailure:e=>eY(()=>t.onFailure(e)),onSuccess:e=>eC(()=>t.onSuccess(e))})),rk=e=>ra(e,eB),rS=(0,f.XY)(2,(e,t)=>ra(e,e=>eC(t))),rO=e=>eT(()=>{let t=e[Symbol.iterator](),r=t.next();return r.done?eB(Error("Received an empty collection of effects")):function e(r){let n=t.next();return n.done?r.value:ra(r.value,t=>e(n))}(r)}),rE=e=>ra(e,t=>tu(eD,()=>rE(e))),r$=(0,f.XY)(e=>(0,O.yw)(e[0]),(e,t)=>{if(!t?.log)return rP(e,{onFailure:e=>eq,onSuccess:e=>eq});let r=aa(!0===t.log?void 0:t.log);return rT(e,{onFailure(e){let n=U(e);return x.N6(n)?eI(n.failure):void 0===t.message?r(e):r(t.message,e)},onSuccess:e=>eq})}),rI=(0,f.XY)(e=>(0,O.yw)(e[0]),(e,t)=>{if(!t?.log)return rT(e,{onFailure:e=>eq,onSuccess:e=>eq});let r=aa(!0===t.log?void 0:t.log);return rT(e,{onFailure:e=>void 0===t.message?r(e):r(t.message,e),onSuccess:e=>eq})}),rA=e=>rj(e,{onFailure:g.none,onSuccess:g.some}),rC=e=>rD(e,{onFailure:x.fJ,onSuccess:x.Py}),rT=(0,f.XY)(2,(e,t)=>{let r=Object.create(rN);return r[O.a2]=e,r[O.ee]=1!==t.onSuccess.length?e=>t.onSuccess(e):t.onSuccess,r[O.Sc]=1!==t.onFailure.length?e=>t.onFailure(e):t.onFailure,r}),rN=(0,O.yj)({op:"OnSuccessAndFailure",[O._3](e){return e._stack.push(this),this[O.a2]}}),rM=(0,f.XY)(2,(e,t)=>rT(e,{onFailure:e=>eC(()=>t.onFailure(e)),onSuccess:e=>eC(()=>t.onSuccess(e))})),rP=(0,f.XY)(2,(e,t)=>rT(e,{onFailure:e=>{let r=e.reasons.find(O.lC);return r?(0,S.s)(()=>t.onFailure(r.error)):eI(e)},onSuccess:t.onSuccess})),rj=(0,f.XY)(2,(e,t)=>rP(e,{onFailure:e=>eC(()=>t.onFailure(e)),onSuccess:e=>eC(()=>t.onSuccess(e))})),rD=(0,f.XY)(2,(e,t)=>{if(th(e)){if("Success"===e._tag)return(0,O.xt)(t.onSuccess(e.value));let r=F(e.cause);return x.N6(r)?e:(0,O.xt)(t.onFailure(r.success))}return rj(e,t)}),rU=(0,f.XY)(2,(e,t)=>th(e)?"Success"===e._tag?(0,O.xt)(t.onSuccess(e.value)):(0,O.xt)(t.onFailure(e.cause)):rM(e,t)),rF=e=>th(e)?(0,O.xt)(e):rR(e),rR=(0,O.Uf)({op:"Exit",[O._3](e){return e._stack.push(this),this[O.a2]},[O.ee]:(e,t,r)=>e$(r??(0,O.xt)(e)),[O.Sc]:(e,t,r)=>e$(r??(0,O.cb)(e))}),rL=rD({onFailure:()=>!0,onSuccess:()=>!1}),rB=rD({onFailure:()=>!1,onSuccess:()=>!0}),rY=(0,f.XY)(2,(e,t)=>tr(iY(t),e)),rq=(0,f.XY)(2,(e,t)=>tc(e,tu(iY(t.duration),t.orElse))),rX=(0,f.XY)(2,(e,t)=>rq(e,{duration:t,orElse:()=>eA(new iz)})),rW=(0,f.XY)(2,(e,t)=>tc(te(e),e7(iY(t),g.none()))),rJ=e=>iB(t=>{let r=t.currentTimeNanosUnsafe();return tg(e,e=>[l.cF(t.currentTimeNanosUnsafe()-r),e])}),rz="~effect/Scope",rK="~effect/Scope/Closeable",rV=o.kl("effect/Scope"),rG=(e,t)=>eT(()=>rH(e,t)??eq),rH=(e,t)=>{if("Closed"===e.state._tag)return;let r={_tag:"Closed",exit:t};if("Empty"===e.state._tag){e.state=r;return}let{finalizers:n}=e.state;return(e.state=r,0===n.size)?void 0:1===n.size?n.values().next().value(t):rQ(e,n,t)},rQ=e1(function*(e,t,r){let n=[],i=[],a=Array.from(t.values()),s=ep();for(let t=a.length-1;t>=0;t--){let o=a[t];"sequential"===e.strategy?n.push((yield*rF(o(r)))):i.push(nQ(s,o(r),!0,!0,"inherit"))}return i.length>0&&(n=yield*ew(i)),yield*tB(n)}),rZ=(e,t)=>eC(()=>r0(e,t)),r0=(e,t)=>{let r=r6(t);if("Closed"===e.state._tag)return r.state=e.state,r;let n={};return r3(e,n,e=>rG(r,e)),r3(r,n,t=>eC(()=>r5(e,n))),r},r1=(e,t)=>eT(()=>"Closed"===e.state._tag?t(e.state.exit):(r3(e,{},t),eq)),r2=(e,t)=>r1(e,(0,f.dY)(t)),r3=(e,t,r)=>{"Empty"===e.state._tag?e.state={_tag:"Open",finalizers:new Map([[t,r]])}:"Open"===e.state._tag&&e.state.finalizers.set(t,r)},r5=(e,t)=>{"Open"===e.state._tag&&e.state.finalizers.delete(t)},r6=(e="sequential")=>({[rK]:rK,[rz]:rz,strategy:e,state:r8}),r8={_tag:"Empty"},r4=e=>eC(()=>r6(e)),r9=rV,r7=t0(rV),ne=e=>(0,O.R6)(t=>{let r=t.context,n=r6();return t.setContext(o.WQ(t.context,rV,n)),na(e,e=>(t.setContext(r),rH(n,e)))}),nt=(0,f.XY)(2,(e,t)=>ns(r7(e,t),e=>eT(()=>rH(t,e)??eq))),nr=e=>eT(()=>{let t=r6();return ns(e(t),e=>eT(()=>rH(t,e)??eq))}),nn=(e,t,r)=>tH(n=>nO(i=>tu(r9,a=>tn(r?.interruptible?i(e):e,e=>r1(a,r=>tZ(t(e,r),n)))))),ni=e=>tu(r9,t=>tH(r=>r1(t,t=>tZ(e(t),r)))),na=(0,O.Uf)({op:"OnExit",single:!1,[O._3](e){return e._stack.push(this),this[O.a2][0]},[O.u4](e){e.interruptible&&!0!==this[O.a2][2]&&(e._stack.push(n_),e.interruptible=!1)},[O.ee](e,t,r){r??=(0,O.xt)(e);let n=this[O.a2][1](r);return n?tu(n,e=>r):r},[O.Sc](e,t,r){r??=(0,O.cb)(e);let n=this[O.a2][1](r);return n?tu(n,e=>r):r}}),ns=(0,f.XY)(2,na),no=(0,f.XY)(2,(e,t)=>ns(e,e=>t)),nl=(0,f.XY)(3,(e,t,r)=>ns(e,e=>t(e)?r(e):eq)),nc=(0,f.XY)(3,(e,t,r)=>ns(e,e=>{let n=t(e);return x.N6(n)?eq:r(n.success,e)})),nu=(0,f.XY)(2,(e,t)=>nc(e,t$,t)),nd=(0,f.XY)(3,(e,t,r)=>nl(e,e=>"Failure"===e._tag&&t(e.cause),e=>r(e.cause))),nf=(0,f.XY)(3,(e,t,r)=>ns(e,e=>{if("Failure"!==e._tag)return eq;let n=t(e.cause);return x.N6(n)?eq:r(n.success,e.cause)})),nh=(0,f.XY)(2,(e,t)=>nf(W,t)(e)),np=(e,t,r)=>nO(n=>tu(e,e=>na(n(t(e)),t=>r(e,t),!0))),nm=e=>nn(e,e=>(0,v.i5)(e,Symbol.asyncDispose)?eW(()=>e[Symbol.asyncDispose]()):eC(()=>e[Symbol.dispose]())),ng=(0,f.XY)(2,(e,t)=>eC(()=>{let r,n=l.kE(l.bN(t)),i=Number.isFinite(n),a=iu(!1),s=0,o=!1,c=tu(a.await,()=>r);return[(0,O.R6)(t=>{let l=t.getRef(iD),u=i?l.currentTimeMillisUnsafe():0;return o||u<s?r??c:(o=!0,a.closeUnsafe(),r=void 0,ns(e,e=>eC(()=>{o=!1,s=l.currentTimeMillisUnsafe()+n,r=e,a.openUnsafe()})))}),eC(()=>{s=0,a.closeUnsafe(),r=void 0})]})),ny=(0,f.XY)(2,(e,t)=>tg(ng(e,t),e=>e[0])),nb=e=>ny(e,l.Tn),nv=(0,O.R6)(e=>eI(j(e.id))),nw=e=>(0,O.R6)(t=>(t.interruptible&&(t.interruptible=!1,t._stack.push(n_)),e)),nx=(0,O.Uf)({op:"SetInterruptible",[O.u4](e){if(e.interruptible=this[O.a2],e._interruptedCause&&e.interruptible)return()=>eI(e._interruptedCause)}}),n_=nx(!0),nk=nx(!1),nS=e=>(0,O.R6)(t=>t.interruptible?e:(t.interruptible=!0,t._stack.push(nk),t._interruptedCause)?eI(t._interruptedCause):e),nO=e=>(0,O.R6)(t=>t.interruptible?(t.interruptible=!1,t._stack.push(n_),e(nS)):e(f.D_)),nE=e=>(0,O.R6)(t=>t.interruptible?e(f.D_):(t.interruptible=!0,t._stack.push(nk),e(nw))),n$=tg(nn(eC(()=>new AbortController),e=>eC(()=>e.abort())),e=>e.signal),nI=(e,t)=>(0,v.xZ)(e)?t?.mode==="result"?nD(e,rC,t):nD(e,f.D_,t):t?.discard?"result"===t.mode?nD(Object.values(e),rC,t):nD(Object.values(e),f.D_,t):eT(()=>{let r={};return e7(nD(Object.entries(e),([e,n])=>tg(t?.mode==="result"?rC(n):n,t=>{r[e]=t}),{discard:!0,concurrency:t?.concurrency}),r)}),nA=(0,f.XY)(e=>(0,v.xZ)(e[0])&&!(0,O.yw)(e[0]),(e,t,r)=>tg(nD(e,(e,r)=>rC(t(e,r)),r),e=>s.jB(e,f.D_))),nC=(0,f.XY)(e=>(0,v.xZ)(e[0])&&!(0,O.yw)(e[0]),(e,t,r)=>tu(nA(e,t,{concurrency:r?.concurrency}),([e,t])=>s.CZ(e)?eA(e):r?.discard?eq:e$(t))),nT=(0,f.XY)(e=>(0,v.xZ)(e[0])&&!(0,O.yw)(e[0]),(e,t)=>eT(()=>{let r=e[Symbol.iterator](),n=r.next();return n.done?e$(g.none()):nN(r,0,t,n.value)})),nN=(e,t,r,n)=>tu(r(n,t),i=>{if(i)return e$(g.some(n));let a=e.next();return a.done?e$(g.none()):nN(e,t+1,r,a.value)}),nM=(0,f.XY)(e=>(0,v.xZ)(e[0])&&!(0,O.yw)(e[0]),(e,t)=>eT(()=>{let r=e[Symbol.iterator](),n=r.next();return n.done?e$(g.none()):nP(r,0,t,n.value)})),nP=(e,t,r,n)=>tu(r(n,t),n=>{if(x.oJ(n))return e$(g.some(n.success));let i=e.next();return i.done?e$(g.none()):nP(e,t+1,r,i.value)}),nj=(0,O.Uf)({op:"While",[O.ee](e,t){return(this[O.a2].step(e),this[O.a2].while())?(t._stack.push(this),this[O.a2].body()):tM},[O._3](e){return this[O.a2].while()?(e._stack.push(this),this[O.a2].body()):tM}}),nD=(0,f.XY)(e=>"function"==typeof e[1],(e,t,r)=>(0,O.R6)(n=>{let i=r?.concurrency==="inherit"?n.getRef(I.F8):r?.concurrency??1,a="unbounded"===i?1/0:Math.max(1,i);if(1===a)return nU(e,t,r);let o=s.Ts(e),l=o.length;if(0===l)return r?.discard?eq:e$([]);let c=r?.discard?void 0:Array(l),u=nL({f:t,out:c},o,{concurrency:a});return u?e7(u,c):e$(c)})),nU=(e,t,r)=>eT(()=>{let n=r?.discard?void 0:[],i=e[Symbol.iterator](),a=i.next(),s=0;return e7(nj({while:()=>!a.done,body:()=>t(a.value,s++),step:e=>{n&&n.push(e),a=i.next()}}),n)}),nF=e=>{let t=e.onItem,r=e.step;return(e,n,i)=>{let a,s,o,l,c,u=i?.start??0,d=i?.end??n.length,f=i?.concurrency??1,h=i?.orderedStep===!0&&f>1,p=!1,m=!1,g=u,y=h?Array(d):void 0,b=(t,i,a)=>{if(!h)return r(e,t,i,a);if(l)return l;for(y[a]=i;g<d;){let t=y[g];if(void 0===t)return;y[g]=void 0;let i=g++,a=r(e,n[i],t,i);if(a)return a}},v=()=>{let r=!1;for(;!l&&u<d;u++){let i=n[u],d=c??t(e,i,u);if(th(d)){if(l=b(i,d,u))break}else{if(1===f)return tu(rF(d),e=>(l=b(i,e,u),u++,l??v()??eq));if(!a)return eQ(e=>{a=ep(),c=d,o=e;let t=v();return t?e(t):eT(()=>(l=tM,m=!0,s?eO(s):eq))});c=void 0;let e=nQ(a,d,!0,!0,"inherit");if(e._exit){if(l=b(i,e._exit,u))break;continue}s?s.add(e):s=new Set([e]);let t=u;if(e.addObserver(n=>{if(s.delete(e),l){if(!m&&"Failure"===n._tag)for(let e of n.cause.reasons)if("Interrupt"===e._tag)continue;else"Failure"===l._tag?l.cause.reasons.push(e):l=(0,O.cb)((0,O.b5)([e]))}else{let e=b(i,n,t);e&&(l="Failure"===e._tag?(0,O.cb)((0,O.b5)(e.cause.reasons.slice())):e,v())}if(r){let e=v();e&&o(e)}else p&&0===s.size&&o(l??eq)}),s.size<f)continue;r=!0,u++;return}}if(p=!0,l){if(s&&s.size>0){let e=ey(a);s.forEach(t=>t.interruptUnsafe(a.id,e));return}if(o||"Failure"===l._tag)return l}else if(o)if(!s)return tM;else 0===s.size&&o(eq)};return v()}},nR=()=>nF,nL=nF({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)}}),nB=(0,f.XY)(3,(e,t,r)=>tu(e,e=>t(e)?e$(e):r(e))),nY=(0,f.XY)(3,(e,t,r)=>tu(e,e=>{let n=t(e);return x.N6(n)?r(n.failure):e$(n.success)})),nq=(0,f.XY)(e=>(0,O.yw)(e[0]),(e,t,r)=>nY(e,t,r?e=>eA(r(e)):()=>eA(new O.Xm))),nX=(0,f.XY)(e=>(0,v.xZ)(e[0])&&!(0,O.yw)(e[0]),(e,t,r)=>eT(()=>{let n=[];return e7(nD(e,(e,r)=>{let i=t(e,r);return"boolean"==typeof i?(i&&n.push(e),eq):tg(i,t=>{t&&n.push(e)})},{discard:!0,concurrency:r?.concurrency}),n)})),nW=(0,f.XY)(e=>(0,v.xZ)(e[0])&&!(0,O.yw)(e[0]),(e,t)=>eT(()=>{let r=[];for(let n of e){let e=t(n);x.oJ(e)&&r.push(e.success)}return e$(r)})),nJ=(0,f.XY)(e=>(0,v.xZ)(e[0])&&!(0,O.yw)(e[0]),(e,t,r)=>eT(()=>{let n=[];return e7(nD(e,e=>tg(t(e),e=>{x.oJ(e)&&n.push(e.success)}),{discard:!0,concurrency:r?.concurrency}),n)})),nz=e$({}),nK=E.Jr(tg),nV=E.oI(tg,tu),nG=E.zM(tg),nH=(0,f.XY)(e=>(0,O.yw)(e[0]),(e,t)=>(0,O.R6)(r=>(eg.interruptChildren??=eb,e$(nQ(r,e,t?.startImmediately,!1,t?.uninterruptible??!1))))),nQ=(e,t,r=!1,n=!1,i=!1)=>{let a="inherit"===i?e.interruptible:!i,s=new em(e.context,a);return r?s.evaluate(t):e.currentDispatcher.scheduleTask(()=>s.evaluate(t),0),n||s._exit||(e.children().add(s),s.addObserver(()=>e._children.delete(s))),s},nZ=(0,f.XY)(e=>(0,O.yw)(e[0]),(e,t)=>(0,O.R6)(r=>e$(nQ(r,e,t?.startImmediately,!0,t?.uninterruptible)))),n0=e=>(0,O.R6)(t=>{let r=t._children&&s.Ts(t._children);return ns(e,e=>{let n=t._children;return void 0===n||0===n.size?eq:(r&&(n=m.pb(n,e=>!r.includes(e))),ti(ew(n)))})}),n1=(0,f.XY)(e=>(0,O.yw)(e[0]),(e,t,r)=>(0,O.R6)(n=>{let i=nQ(n,e,r?.startImmediately,!0,r?.uninterruptible);if(!i._exit)if("Closed"!==t.state._tag){let e={};r3(t,e,()=>ez(e=>e===i.id?eq:ek(i))),i.addObserver(()=>r5(t,e))}else i.interruptUnsafe(n.id,ey(n));return e$(i)})),n2=(0,f.XY)(e=>(0,O.yw)(e[0]),(e,t)=>tu(r9,r=>n1(e,r,t))),n3=e=>(t,r)=>{let n=new em(r?.scheduler?o.WQ(e,_._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},n5=(0,f.XY)(2,(e,t)=>{if(e._exit)return e;if("Closed"===t.state._tag)return e.interruptUnsafe(e.id),e;let r={};return r3(t,r,()=>ek(e)),e.addObserver(()=>r5(t,r)),e}),n6=n3(o.Ie()),n8=e=>{let t=n3(e);return(e,r)=>{let n=t(e,r);return r?.onExit&&n.addObserver(r.onExit),e=>n.interruptUnsafe(e)}},n4=n8(o.Ie()),n9=e=>{let t=n3(e);return(e,r)=>{let n=t(e,r);return new Promise(e=>{n.addObserver(t=>e(t))})}},n7=n9(o.Ie()),ie=e=>{let t=n9(e);return(e,r)=>t(e,r).then(e=>{if("Failure"===e._tag)throw Z(e.cause);return e.value})},it=ie(o.Ie()),ir=e=>{let t=n3(e);return e=>{if(th(e))return e;let r=t(e,{scheduler:new _.FG("sync")});return r.currentDispatcher?.flush(),r._exit??(0,O.V2)(new i2(r))}},ii=ir(o.Ie()),ia=e=>{let t=ir(e);return e=>{let r=t(e);if("Failure"===r._tag)throw Z(r.cause);return r.value}},is=ia(o.Ie()),io=e$(!0),il=e$(!1);class ic{waiters=[];scheduled=!1;_isOpen;constructor(e){this._isOpen=e}scheduleUnsafe(e){return this.scheduled||0===this.waiters.length||(this.scheduled=!0,e.currentDispatcher.scheduleTask(this.flushWaiters,0)),io}flushWaiters=()=>{this.scheduled=!1;let e=this.waiters;this.waiters=[];for(let t=0;t<e.length;t++)e[t](tM)};open=(0,O.R6)(e=>this._isOpen?il:(this._isOpen=!0,this.scheduleUnsafe(e)));release=(0,O.R6)(e=>this._isOpen?il:this.scheduleUnsafe(e));openUnsafe(){return!this._isOpen&&(this._isOpen=!0,this.flushWaiters(),!0)}await=eQ(e=>this._isOpen?e(eq):(this.waiters.push(e),eC(()=>{let t=this.waiters.indexOf(e);-1!==t&&this.waiters.splice(t,1)})));closeUnsafe(){return!!this._isOpen&&(this._isOpen=!1,!0)}close=eC(()=>this.closeUnsafe());whenOpen=e=>tu(this.await,()=>e);isOpen(){return this._isOpen}}let iu=e=>new ic(e??!1),id=e=>eC(()=>iu(e)),ih=(0,O.R6)(e=>e$(e.getRef(k.sh))),ip=(0,f.XY)(2,(e,t)=>t0(e,k.sh,t)),im=t0(I.rf),ig=t0(I.nU),iy=BigInt(0),ib={_tag:"Span",spanId:"noop",traceId:"noop",sampled:!1,status:{_tag:"Ended",startTime:iy,endTime:iy,exit:tM},attributes:new Map,links:[],kind:"internal",attribute(){},event(){},end(){},addLinks(){}},iv=e=>e?o.Jt(e.annotations,k.DW)?"Span"===e._tag?iv(g.getOrUndefined(e.parent)):g.none():g.some(e):g.none(),iw=(e,t,r)=>{let n,i=!e.getRef(I.rf)||r?.annotations&&o.Jt(r.annotations,k.DW),a=r?.parent!==void 0?g.some(r.parent):r?.root?g.none():iv(e.currentSpan);if(i){let e;e={name:t,parent:a,annotations:o.WQ(r?.annotations??o.Ie(),k.DW,!0)},n=Object.assign(Object.create(ib),e)}else{let i=e.getRef(k.sh),s=e.getRef(iD),l=e.getRef(I.nU),c=e.getRef(I.ce),u=e.getRef(I.ls),d=r?.level??e.getRef(k.pX),f=r?.links!==void 0?[...u,...r.links]:u.slice();for(let[u,h]of(n=i.span({name:t,parent:a,annotations:r?.annotations??o.Ie(),links:f,startTime:l?s.currentTimeNanosUnsafe():BigInt(0),kind:r?.kind??"internal",root:r?.root??g.isNone(a),sampled:r?.sampled??((!g.isSome(a)||!1!==a.value.sampled)&&!i9(e.getRef(k.EW),d))}),Object.entries(c)))n.attribute(u,h);if(r?.attributes!==void 0)for(let[e,t]of Object.entries(r.attributes))n.attribute(e,t)}return n},ix=(e,t)=>(0,O.R6)(r=>e$(iw(r,e,t))),i_=(e,t)=>nw((0,O.R6)(r=>{let n=o.fp(r.context,rV),i=iw(r,e,t??{}),a=r.getRef(iD),s=r.getRef(I.nU);return e7(r1(n,e=>i$(i,e,a,s)),i)})),ik=function(){let e="string"!=typeof arguments[0],t=e?arguments[1]:arguments[0],r=C(e?arguments[2]:arguments[1]);if(e){let e=arguments[0];return tu(i_(t,r),t=>iC(e,t,r))}return e=>tu(i_(t,r),t=>iC(e,t,r))},iS=I.ce,iO=I.ls,iE=(0,f.XY)(e=>(0,O.yw)(e[0]),(e,t,r={})=>{let n=(Array.isArray(t)?t:[t]).map(e=>({span:e,attributes:r}));return tK(e,I.ls,e=>[...e,...n])}),i$=(e,t,r,n)=>eC(()=>{"Ended"!==e.status._tag&&e.end(n?r.currentTimeNanosUnsafe():iy,t)}),iI=(e,...t)=>{let r=1===t.length?void 0:t[0],n=t[t.length-1];return(0,O.R6)(t=>{let i=iw(t,e,r),a=t.getRef(iD);return ns((0,S.s)(()=>n(i)),e=>eC(()=>{"Ended"!==i.status._tag&&i.end(a.currentTimeNanosUnsafe(),e)}))})},iA=t0(k.Tv),iC=function(){let e=(0,O.yw)(arguments[0]),t=e?arguments[1]:arguments[0],r=e?arguments[2]:arguments[1],n=f.D_;if("Span"===t._tag){var i,a;r=C(r),i=t.name,a="function"==typeof(a=r?.captureStackTrace)?a:f.MN,n=tK(I.vA,e=>({name:i,stack:a,parent:e}))}return e?iA(n(arguments[0]),t):e=>iA(n(e),t)},iT=function(){let e="string"!=typeof arguments[0],t=e?arguments[1]:arguments[0],r=C(arguments[2]);if(e){let e=arguments[0];return iI(t,arguments[2],t=>iC(e,t,r))}let n="function"==typeof arguments[1]?arguments[1]:void 0,i=n?void 0:arguments[1];return(e,...a)=>iI(t,n?n(...a):i,t=>iC(e,t,r))},iN=(0,f.XY)(e=>(0,O.yw)(e[0]),(e,...t)=>tK(e,I.ce,e=>{let r={...e};return 1===t.length?Object.assign(r,t[0]):r[t[0]]=t[1],r})),iM=(...e)=>(0,O.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 eq}),iP=(0,O.R6)(e=>{let t=e.currentSpanLocal;return t?e$(t):eA(new O.Xm)}),ij=(n=k.Tv,(0,O.R6)(e=>e.context.mapUnsafe.has(n.key)?e$(o.fp(e.context,n)):eA(new O.Xm))),iD=o.Or("effect/Clock",{defaultValue:()=>new iF}),iU=0x80000000-1;class iF{currentTimeMillisUnsafe(){return Date.now()}currentTimeMillis=eC(()=>this.currentTimeMillisUnsafe());currentTimeNanosUnsafe(){return iL()}currentTimeNanos=eC(()=>this.currentTimeNanosUnsafe());sleep(e){return this.sleepMillis(l.kE(e))}sleepMillis(e){return e<=0?eD:Number.isFinite(e)?eQ(t=>{let r=e>iU?this.sleepMillis(e-iU):eq,n=setTimeout(()=>t(r),Math.min(e,iU));return eC(()=>clearTimeout(n))}):eZ}}let iR=(a=BigInt(1e6),"u"<typeof performance||void 0===performance.now?()=>BigInt(Date.now())*a:()=>(i??=BigInt(Date.now())*a-BigInt(Math.round(1e6*performance.now())))+BigInt(Math.round(1e6*performance.now()))),iL=function(){let e="object"==typeof process&&"hrtime"in process&&"function"==typeof process.hrtime.bigint?process.hrtime:void 0;if(!e)return iR;let t=BigInt(Date.now())*BigInt(1e6)-e.bigint();return()=>t+e.bigint()}(),iB=e=>(0,O.R6)(t=>e(t.getRef(iD))),iY=e=>iB(t=>t.sleep(l.bN(e))),iq=iB(e=>e.currentTimeMillis),iX=iB(e=>e.currentTimeNanos),iW="~effect/Cause/TimeoutError",iJ=e=>(0,v.i5)(e,iW);class iz extends(0,O.rN)("TimeoutError"){[iW]=iW;constructor(e){super({message:e})}}let iK="~effect/Cause/IllegalArgumentError",iV=e=>(0,v.i5)(e,iK);class iG extends(0,O.rN)("IllegalArgumentError"){[iK]=iK;constructor(e){super({message:e})}}let iH="~effect/Cause/ExceededCapacityError",iQ=e=>(0,v.i5)(e,iH);class iZ extends(0,O.rN)("ExceededCapacityError"){[iH]=iH;constructor(e){super({message:e})}}let i0="~effect/Cause/AsyncFiberError",i1=e=>(0,v.i5)(e,i0);class i2 extends(0,O.rN)("AsyncFiberError"){[i0]=i0;constructor(e){super({message:"An asynchronous Effect was executed with Effect.runSync",fiber:e})}}let i3="~effect/Cause/UnknownError",i5=e=>(0,v.i5)(e,i3);class i6 extends(0,O.rN)("UnknownError"){[i3]=i3;constructor(e,t){super({message:t,cause:e})}}let i8=o.Or("effect/Console/CurrentConsole",{defaultValue:()=>globalThis.console}),i4=y.zQ(y.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}}),i9=y.yJ(i4),i7=o.Or("effect/Loggers/CurrentLoggers",{defaultValue:()=>new Set([as,ao])}),ae=o.Or("effect/Logger/LogToStderr",{defaultValue:f.f4}),at=function(){let e="string"==typeof arguments[0]?[[arguments[0],arguments[1]]]:Object.entries(arguments[0]);return nw((0,O.R6)(t=>{let r=t.getRef(I.iL),n={...r};for(let t=0;t<e.length;t++){let[r,i]=e[t];n[r]=i}return t.setContext(o.WQ(t.context,I.iL,n)),r1(o.fp(t.context,rV),n=>{let i=t.getRef(I.iL),a={...i};for(let t=0;t<e.length;t++){let[n,s]=e[t];i[n]===s&&(n in r?a[n]=r[n]:delete a[n])}return t.setContext(o.WQ(t.context,I.iL,a)),eq})}))},ar={"~effect/Logger":{_Message:f.D_,_Output:f.D_},pipe(){return(0,b.tT)(this,arguments)}},an=e=>{let t=Object.create(ar);return t.log=e,t},ai=(e,t)=>{let r=e[0].replace(/[\s="]/g,"_");return`${r}=${t-e[1]}ms`},aa=e=>(...t)=>{let r;for(let e=0,n=t.length;e<n;e++){let n=t[e];(0,O.Aj)(n)&&(r?t.splice(e,1):t=t.slice(0,e).concat(t.slice(e+1)),r=r?(0,O.b5)(r.reasons.concat(n.reasons)):n,e--)}return void 0===r&&(r=O.DH),(0,O.R6)(n=>{let i=e??n.currentLogLevel;if(i9(n.minimumLogLevel,i))return eq;let a=n.getRef(iD),s=n.getRef(i7);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 eq})},as=an(({cause:e,date:t,fiber:r,logLevel:n,message:i})=>{let a=Array.isArray(i)?i.slice():[i];e.reasons.length>0&&a.push(el(e));let s=t.getTime(),o=r.getRef(I.d8),l="";for(let e of o)l+=` ${ai(e,s)}`;let c=r.getRef(I.iL);Object.keys(c).length>0&&a.push(c);let u=r.getRef(i8);(r.getRef(ae)?u.error:u.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)}),ao=an(({cause:e,fiber:t,logLevel:r,message:n})=>{let i=t.getRef(iD),a=t.getRef(I.iL),s=t.currentSpan;if(void 0===s||"ExternalSpan"===s._tag)return;let o={};for(let[e,t]of Object.entries(a))o[e]=t;o["effect.fiberId"]=t.id,o["effect.logLevel"]=r.toUpperCase(),e.reasons.length>0&&(o["effect.cause"]=el(e)),s.event((0,p.ZK)(Array.isArray(n)&&1===n.length?n[0]:n),i.currentTimeNanosUnsafe(),o)}),al=e$(void 0),ac=(0,f.XY)(e=>(0,O.yw)(e[0]),(e,t)=>nu(e,e=>(0,O.R6)(r=>(au(r,e,t?.defectsOnly),eq)))),au=(e,t,r)=>{let n=e.getRef(I.oQ);if(0===n.size||r&&!L(t))return;let i={cause:t,fiber:e,timestamp:e.getRef(iD).currentTimeNanosUnsafe()};n.forEach(e=>e.report(i))}},6516(e,t,r){let n=new WeakSet;r.d(t,{},{J:n,X: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}})},9354(e,t,r){r.d(t,{},{F:"effect/observability/Metric/FiberRuntimeMetricsKey"})},5091(e,t,r){var n=r(8036),i=r(6470),a=r(4450),s=r(6400),o=r(5369),l=r(3537),c=r(8433);let u="~effect/data/Option",d={[u]:{_A:e=>e},...c.fU,[Symbol.iterator](){return new l.B(this)}},f=Object.defineProperty(Object.assign(Object.create(d),{_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}}),h=a.tW("None"),p=Object.assign(Object.create(d),{_tag:"None",_op:"None",valueOrUndefined:void 0,[n.HR]:e=>m(e)&&g(e),[a.HR]:()=>h,toString:()=>"none()",toJSON(){return{_id:"Option",_tag:this._tag}}}),m=e=>(0,o.i5)(e,u),g=e=>"None"===e._tag,y=e=>"Some"===e._tag,b=Object.create(p);r.d(t,{},{$I:g,Ru:y,dv:b,oL:m,zN:e=>{let t=Object.create(f);return t.value=e,t}})},8344(e,t,r){var n=r(8619),i=r(4650);let a=n.Or("effect/References/CurrentConcurrency",{defaultValue:()=>"unbounded"}),s=n.Or("effect/ErrorReporter/CurrentErrorReporters",{defaultValue:()=>new Set}),o=n.Or("effect/References/CurrentStackFrame",{defaultValue:i.MN}),l=n.Or("effect/References/TracerEnabled",{defaultValue:i.ue}),c=n.Or("effect/References/TracerTimingEnabled",{defaultValue:i.ue}),u=n.Or("effect/References/TracerSpanAnnotations",{defaultValue:()=>({})}),d=n.Or("effect/References/TracerSpanLinks",{defaultValue:()=>[]}),f=n.Or("effect/References/CurrentLogAnnotations",{defaultValue:()=>({})}),h=n.Or("effect/References/CurrentLogLevel",{defaultValue:()=>"Info"}),p=n.Or("effect/References/MinimumLogLevel",{defaultValue:()=>"Info"}),m=n.Or("effect/References/UnhandledLogLevel",{defaultValue:()=>"Error"}),g=n.Or("effect/References/CurrentLogSpans",{defaultValue:()=>[]});r.d(t,{},{F8:a,Gl:h,aG:m,ce:u,d8:g,iL:f,ls:d,nU:c,oQ:s,rf:l,vA:o,zQ:p})},4403(e,t,r){var n=r(8036),i=r(6470),a=r(4650),s=r(4450),o=r(6400),l=r(5369),c=r(3537),u=r(8433),d=r(5091);let f="~effect/data/Result",h={[f]:{_A:e=>e,_E:e=>e},...u.fU,[Symbol.iterator](){return new c.B(this)}},p=Object.assign(Object.create(h),{_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(h),{_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=e=>{let t=Object.create(m);return t.failure=e,t},w=e=>{let t=Object.create(p);return t.success=e,t},x=(0,a.XY)(2,(e,t)=>d.$I(e)?v(t()):w(e.value));r.d(t,{},{L8:e=>b(e)?d.dv:d.zN(e.failure),N6:y,Oz:e=>y(e)?d.dv:d.zN(e.success),Py:w,aI:g,fJ:v,oJ:b,sV:x})},4888(e,t,r){var n=r(4650);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=a("identifier"),o=a("title"),l=a("description"),c=(0,n.Bj)(e=>{let t=s(e);return"string"==typeof t?t:e.getExpected(c)});r.d(t,{hd:()=>i,ip:()=>a},{DQ:o,KE:s,Pk:l,bo:c})},8045(e,t,r){var n=r(8543),i=r(6030);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})},3628(e,t,r){let n,i=Object.getOwnPropertyDescriptor,a=Object.prototype.hasOwnProperty,s=Object.isExtensible,o=void 0===(n=i(Error,"stackTraceLimit"))?s(Error):a.call(n,"writable")?!0===n.writable:void 0!==n.set;r.d(t,{},{ft:e=>{o&&(Error.stackTraceLimit=e)},jt:()=>Error.stackTraceLimit})},1580(e,t,r){let n="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function i(e,t,r){let n=r[0];if(null!=t&&e>=t)throw Error(e+" >= "+t);if(e.slice(-1)===n||t&&t.slice(-1)===n)throw Error("trailing zero");if(t){let a=0;for(;(e[a]||n)===t[a];)a++;if(a>0)return t.slice(0,a)+i(e.slice(a),t.slice(a),r)}let a=e?r.indexOf(e[0]):0,s=null!=t?r.indexOf(t[0]):r.length;return s-a>1?r[Math.round(.5*(a+s))]:t&&t.length>1?t.slice(0,1):r[a]+i(e.slice(1),null,r)}function a(e){if(e.length!==s(e[0]))throw Error("invalid integer part of order key: "+e)}function s(e){if(e>="a"&&e<="z")return e.charCodeAt(0)-97+2;if(e>="A"&&e<="Z")return 90-e.charCodeAt(0)+2;throw Error("invalid order key head: "+e)}function o(e){let t=s(e[0]);if(t>e.length)throw Error("invalid order key: "+e);return e.slice(0,t)}function l(e,t){if(e==="A"+t[0].repeat(26))throw Error("invalid order key: "+e);let r=o(e);if(e.slice(r.length).slice(-1)===t[0])throw Error("invalid order key: "+e)}function c(e,t){a(e);let[r,...n]=e.split(""),i=!0;for(let e=n.length-1;i&&e>=0;e--){let r=t.indexOf(n[e])+1;r===t.length?n[e]=t[0]:(n[e]=t[r],i=!1)}if(!i)return r+n.join("");{if("Z"===r)return"a"+t[0];if("z"===r)return null;let e=String.fromCharCode(r.charCodeAt(0)+1);return e>"a"?n.push(t[0]):n.pop(),e+n.join("")}}function u(e,t,r=n){if(null!=e&&l(e,r),null!=t&&l(t,r),null!=e&&null!=t&&e>=t)throw Error(e+" >= "+t);if(null==e){if(null==t)return"a"+r[0];let e=o(t),n=t.slice(e.length);if(e==="A"+r[0].repeat(26))return e+i("",n,r);if(e<t)return e;let s=function(e,t){a(e);let[r,...n]=e.split(""),i=!0;for(let e=n.length-1;i&&e>=0;e--){let r=t.indexOf(n[e])-1;-1===r?n[e]=t.slice(-1):(n[e]=t[r],i=!1)}if(!i)return r+n.join("");{if("a"===r)return"Z"+t.slice(-1);if("A"===r)return null;let e=String.fromCharCode(r.charCodeAt(0)-1);return e<"Z"?n.push(t.slice(-1)):n.pop(),e+n.join("")}}(e,r);if(null==s)throw Error("cannot decrement any more");return s}if(null==t){let t=o(e),n=e.slice(t.length),a=c(t,r);return null==a?t+i(n,null,r):a}let s=o(e),d=e.slice(s.length),f=o(t),h=t.slice(f.length);if(s===f)return s+i(d,h,r);let p=c(s,r);if(null==p)throw Error("cannot increment any more");return p<t?p:s+i(d,null,r)}r.d(t,{TU:()=>u,YT:()=>function e(t,r,i,a=n){if(0===i)return[];if(1===i)return[u(t,r,a)];if(null==r){let e=u(t,r,a),n=[e];for(let t=0;t<i-1;t++)n.push(e=u(e,r,a));return n}if(null==t){let e=u(t,r,a),n=[e];for(let r=0;r<i-1;r++)n.push(e=u(t,e,a));return n.reverse(),n}let s=Math.floor(i/2),o=u(t,r,a);return[...e(t,o,s,a),o,...e(o,r,i-s-1,a)]}})},8689(e,t,r){let n,i,a,s,o;function l(e){let t=e.length;for(;--t>=0;)e[t]=0}let c=573,u=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]),d=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]),h=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),p=Array(576);l(p);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 w(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 _=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)},O=(e,t,r)=>{S(e,r[2*t],r[2*t+1])},E=(e,t)=>{let r=0;do r|=1&e,e>>>=1,r<<=1;while(--t>0)return r>>>1},$=(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]=E(a[t]++,t))}},I=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},A=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},C=(e,t,r,n)=>{let i=2*t,a=2*r;return e[i]<e[a]||e[i]===e[a]&&n[t]<=n[r]},T=(e,t,r)=>{let n=e.heap[r],i=r<<1;for(;i<=e.heap_len&&(i<e.heap_len&&C(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!C(t,n,e.heap[i],e.depth));)e.heap[r]=e.heap[i],r=i,i<<=1;e.heap[r]=n},N=(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?O(e,i,t):(O(e,(a=y[i])+256+1,t),0!==(s=u[a])&&S(e,i-=b[a],s),O(e,a=_(--n),r),0!==(s=d[a])&&S(e,n-=v[a],s));while(o<e.last_lit)O(e,256,t)},M=(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,u=-1;for(e.heap_len=0,e.heap_max=c,r=0;r<l;r++)0!==a[2*r]?(e.heap[++e.heap_len]=u=r,e.depth[r]=0):a[2*r+1]=0;for(;e.heap_len<2;)a[2*(i=e.heap[++e.heap_len]=u<2?++u:0)]=1,e.depth[i]=0,e.opt_len--,o&&(e.static_len-=s[2*i+1]);for(t.max_code=u,r=e.heap_len>>1;r>=1;r--)T(e,a,r);i=l;do r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],T(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++,T(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,u=t.max_code,d=t.stat_desc.static_tree,f=t.stat_desc.has_stree,h=t.stat_desc.extra_bits,p=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<c;r++)(a=l[2*l[2*(n=e.heap[r])+1]+1]+1)>m&&(a=m,g++),l[2*n+1]=a,!(n>u)&&(e.bl_count[a]++,s=0,n>=p&&(s=h[n-p]),o=l[2*n],e.opt_len+=o*(a+s),f&&(e.static_len+=o*(d[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])>u)&&(l[2*i+1]!==a&&(e.opt_len+=(a-l[2*i+1])*l[2*i],l[2*i+1]=a),n--)}})(e,t),$(a,u,e.bl_count)},P=(e,t,r)=>{let n,i,a=-1,s=t[1],o=0,l=7,c=4;for(0===s&&(l=138,c=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<c?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,c=3):i===s?(l=6,c=3):(l=7,c=4))},j=(e,t,r)=>{let n,i,a=-1,s=t[1],o=0,l=7,c=4;for(0===s&&(l=138,c=3),n=0;n<=r;n++)if(i=s,s=t[(n+1)*2+1],!(++o<l)||i!==s){if(o<c)do O(e,i,e.bl_tree);while(0!=--o)else 0!==i?(i!==a&&(O(e,i,e.bl_tree),o--),O(e,16,e.bl_tree),S(e,o-3,2)):o<=10?(O(e,17,e.bl_tree),S(e,o-3,3)):(O(e,18,e.bl_tree),S(e,o-11,7));o=0,a=i,0===s?(l=138,c=3):i===s?(l=6,c=3):(l=7,c=4)}},D=!1,U=(e,t,r,n)=>{S(e,0+ +!!n,3),A(e),k(e,r),k(e,~r),e.pending_buf.set(e.window.subarray(t,t+r),e.pending),e.pending+=r};var F={_tr_init:e=>{D||((()=>{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<<u[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<<d[s];e++)g[o++]=s;for(o>>=7;s<30;s++)for(v[s]=o<<7,e=0;e<1<<d[s]-7;e++)g[256+o++]=s;for(t=0;t<=15;t++)l[t]=0;for(e=0;e<=143;)p[2*e+1]=8,e++,l[8]++;for(;e<=255;)p[2*e+1]=9,e++,l[9]++;for(;e<=279;)p[2*e+1]=7,e++,l[7]++;for(;e<=287;)p[2*e+1]=8,e++,l[8]++;for($(p,287,l),e=0;e<30;e++)m[2*e+1]=5,m[2*e]=E(e,5);n=new w(p,u,257,286,15),i=new w(m,d,0,30,15),a=new w([],f,0,19,7)})(),D=!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,I(e)},_tr_stored_block:U,_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)),M(e,e.l_desc),M(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),M(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*h[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?U(e,t,r,n):4===e.strategy||a===i?(S(e,2+ +!!n,3),N(e,p,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*h[i]+1],3);j(e,e.dyn_ltree,t-1),j(e,e.dyn_dtree,r-1)})(e,e.l_desc.max_code+1,e.d_desc.max_code+1,s+1),N(e,e.dyn_ltree,e.dyn_dtree)),I(e),n&&A(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*_(t)]++),e.last_lit===e.lit_bufsize-1),_tr_align:e=>{S(e,2,3),O(e,256,p),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)}},R=(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 L=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 B=(e,t,r,n)=>{let i=n+r;e^=-1;for(let r=n;r<i;r++)e=e>>>8^L[(e^t[r])&255];return -1^e},Y={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"},q={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:X,_tr_stored_block:W,_tr_flush_block:J,_tr_tally:z,_tr_align:K}=F,{Z_NO_FLUSH:V,Z_PARTIAL_FLUSH:G,Z_FULL_FLUSH:H,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:ec,Z_DEFAULT_STRATEGY:eu,Z_UNKNOWN:ed,Z_DEFLATED:ef}=q,eh=573,ep=(e,t)=>(e.msg=Y[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)=>{J(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,eb(e.strm)},ew=(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},e_=(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=R(e.adler,t,i,r):2===e.state.wrap&&(e.adler=B(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,c=e.window,u=e.w_mask,d=e.prev,f=e.strstart+258,h=c[a+s-1],p=c[a+s];e.prev_length>=e.good_match&&(i>>=2),o>e.lookahead&&(o=e.lookahead);do{if(c[(r=t)+s]!==p||c[r+s-1]!==h||c[r]!==c[a]||c[++r]!==c[a+1])continue;a+=2,r++;do;while(c[++a]===c[++r]&&c[++a]===c[++r]&&c[++a]===c[++r]&&c[++a]===c[++r]&&c[++a]===c[++r]&&c[++a]===c[++r]&&c[++a]===c[++r]&&c[++a]===c[++r]&&a<f)if(n=258-(f-a),a=f-258,n>s){if(e.match_start=t,s=n,n>=o)break;h=c[a+s-1],p=c[a+s]}}while((t=d[t&u])>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=e_(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)},eO=(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=z(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=z(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},eE=(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=z(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=z(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=z(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 e$(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 eI=[new e$(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 e$(4,4,8,4,eO),new e$(4,5,16,8,eO),new e$(4,6,32,32,eO),new e$(4,4,16,16,eE),new e$(8,16,32,32,eE),new e$(8,16,128,128,eE),new e$(8,32,128,256,eE),new e$(32,128,258,1024,eE),new e$(32,258,258,4096,eE)];function eA(){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*eh),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 eC=(e,t)=>{let r,n;if(!e||!e.state||t>Z||t<0)return e?ep(e,er):er;let i=e.state;if(!e.output||!e.input&&0!==e.avail_in||666===i.status&&t!==Q)return ep(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,ew(i,31),ew(i,139),ew(i,8),i.gzhead?(ew(i,+!!i.gzhead.text+2*!!i.gzhead.hcrc+4*!!i.gzhead.extra+8*!!i.gzhead.name+16*!!i.gzhead.comment),ew(i,255&i.gzhead.time),ew(i,i.gzhead.time>>8&255),ew(i,i.gzhead.time>>16&255),ew(i,i.gzhead.time>>24&255),ew(i,9===i.level?2:4*(i.strategy>=eo||i.level<2)),ew(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(ew(i,255&i.gzhead.extra.length),ew(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=B(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(ew(i,0),ew(i,0),ew(i,0),ew(i,0),ew(i,0),ew(i,9===i.level?2:4*(i.strategy>=eo||i.level<2)),ew(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=B(e.adler,i.pending_buf,i.pending-r,r)),eb(e),r=i.pending,i.pending!==i.pending_buf_size));)ew(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>r&&(e.adler=B(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=B(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,ew(i,n)}while(0!==n)i.gzhead.hcrc&&i.pending>r&&(e.adler=B(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=B(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,ew(i,n)}while(0!==n)i.gzhead.hcrc&&i.pending>r&&(e.adler=B(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&&(ew(i,255&e.adler),ew(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 ep(e,ei);if(666===i.status&&0!==e.avail_in)return ep(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=z(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=z(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=z(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):eI[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===G?K(i):t!==Z&&(W(i,0,0,!1),t===H&&(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?(ew(i,255&e.adler),ew(i,e.adler>>8&255),ew(i,e.adler>>16&255),ew(i,e.adler>>24&255),ew(i,255&e.total_in),ew(i,e.total_in>>8&255),ew(i,e.total_in>>16&255),ew(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)},eT=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?ep(e,er):(e.state=null,113===t?ep(e,en):ee)};let eN=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var eM=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)eN(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 ej=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){ej=!1}let eD=new Uint8Array(256);for(let e=0;e<256;e++)eD[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;eD[254]=eD[254]=1;var eU=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},eF=(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=eD[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&&ej)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},eR=(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+eD[e[r]]>t?r:t},eL=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 eB=Object.prototype.toString,{Z_NO_FLUSH:eY,Z_SYNC_FLUSH:eq,Z_FULL_FLUSH:eX,Z_FINISH:eW,Z_OK:eJ,Z_STREAM_END:ez,Z_DEFAULT_COMPRESSION:eK,Z_DEFAULT_STRATEGY:eV,Z_DEFLATED:eG}=q;function eH(e){let t,r;this.options=eM({level:eK,method:eG,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 eL,this.strm.avail_out=0;let i=((e,t,r,n,i,a)=>{var s,o;let l;if(!e)return er;let c=1;if(t===ea&&(t=6),n<0?(c=0,n=-n):n>15&&(c=2,n-=16),i<1||i>9||r!==ef||n<8||n>15||t<0||t>9||a<0||a>ec)return ep(e,er);8===n&&(n=9);let u=new eA;return e.state=u,u.strm=e,u.wrap=c,u.gzhead=null,u.w_bits=n,u.w_size=1<<u.w_bits,u.w_mask=u.w_size-1,u.hash_bits=i+7,u.hash_size=1<<u.hash_bits,u.hash_mask=u.hash_size-1,u.hash_shift=~~((u.hash_bits+3-1)/3),u.window=new Uint8Array(2*u.w_size),u.head=new Uint16Array(u.hash_size),u.prev=new Uint16Array(u.w_size),u.lit_bufsize=1<<i+6,u.pending_buf_size=4*u.lit_bufsize,u.pending_buf=new Uint8Array(u.pending_buf_size),u.d_buf=+u.lit_bufsize,u.l_buf=3*u.lit_bufsize,u.level=t,u.strategy=a,u.method=r,(l=(e=>{if(!e||!e.state)return ep(e,er);e.total_in=e.total_out=0,e.data_type=ed;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,X(t),ee})(s=e))===ee&&((o=s.state).window_size=2*o.w_size,eg(o.head),o.max_lazy_match=eI[o.level].max_lazy,o.good_match=eI[o.level].good_length,o.nice_match=eI[o.level].nice_length,o.max_chain_length=eI[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!==eJ)throw Error(Y[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?eU(n.dictionary):"[object ArrayBuffer]"===eB.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=R(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))!==eJ)throw Error(Y[i]);this._dict_set=!0}}function eQ(e,t){let r=new eH(t);if(r.push(e,!0),r.err)throw r.msg||Y[r.err];return r.result}eH.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?eW:eY,"string"==typeof e?i.input=eU(e):"[object ArrayBuffer]"===eB.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===eq||n===eX)&&i.avail_out<=6){this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;continue}if((r=eC(i,n))===ez)return i.next_out>0&&this.onData(i.output.subarray(0,i.next_out)),r=eT(this.strm),this.onEnd(r),this.ended=!0,r===eJ;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},eH.prototype.onData=function(e){this.chunks.push(e)},eH.prototype.onEnd=function(e){e===eJ&&(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,c,u,d,f,h,p,m,g,y,b,v,w,x,_,k,S,O,E=e.state;r=e.next_in,S=e.input,n=r+(e.avail_in-5),i=e.next_out,O=e.output,a=i-(t-e.avail_out),s=i+(e.avail_out-257),o=E.dmax,l=E.wsize,c=E.whave,u=E.wnext,d=E.window,f=E.hold,h=E.bits,p=E.lencode,m=E.distcode,g=(1<<E.lenbits)-1,y=(1<<E.distbits)-1;t:do for(h<15&&(f+=S[r++]<<h,h+=8,f+=S[r++]<<h,h+=8),b=p[f&g];;){if(f>>>=v=b>>>24,h-=v,0==(v=b>>>16&255))O[i++]=65535&b;else if(16&v)for(w=65535&b,(v&=15)&&(h<v&&(f+=S[r++]<<h,h+=8),w+=f&(1<<v)-1,f>>>=v,h-=v),h<15&&(f+=S[r++]<<h,h+=8,f+=S[r++]<<h,h+=8),b=m[f&y];;){if(f>>>=v=b>>>24,h-=v,16&(v=b>>>16&255)){if(x=65535&b,h<(v&=15)&&(f+=S[r++]<<h,(h+=8)<v&&(f+=S[r++]<<h,h+=8)),(x+=f&(1<<v)-1)>o){e.msg="invalid distance too far back",E.mode=30;break t}if(f>>>=v,h-=v,x>(v=i-a)){if((v=x-v)>c&&E.sane){e.msg="invalid distance too far back",E.mode=30;break t}if(_=0,k=d,0===u){if(_+=l-v,v<w){w-=v;do O[i++]=d[_++];while(--v)_=i-x,k=O}}else if(u<v){if(_+=l+u-v,(v-=u)<w){w-=v;do O[i++]=d[_++];while(--v)if(_=0,u<w){w-=v=u;do O[i++]=d[_++];while(--v)_=i-x,k=O}}}else if(_+=u-v,v<w){w-=v;do O[i++]=d[_++];while(--v)_=i-x,k=O}for(;w>2;)O[i++]=k[_++],O[i++]=k[_++],O[i++]=k[_++],w-=3;w&&(O[i++]=k[_++],w>1&&(O[i++]=k[_++]))}else{_=i-x;do O[i++]=O[_++],O[i++]=O[_++],O[i++]=O[_++],w-=3;while(w>2)w&&(O[i++]=O[_++],w>1&&(O[i++]=O[_++]))}}else if((64&v)==0){b=m[(65535&b)+(f&(1<<v)-1)];continue}else{e.msg="invalid distance code",E.mode=30;break t}break}else if((64&v)==0){b=p[(65535&b)+(f&(1<<v)-1)];continue}else if(32&v){E.mode=12;break t}else{e.msg="invalid literal/length code",E.mode=30;break t}break}while(r<n&&i<s)r-=w=h>>3,h-=w<<3,f&=(1<<h)-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),E.hold=f,E.bits=h};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]),e3=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 e5=(e,t,r,n,i,a,s,o)=>{let l,c,u,d,f,h,p,m,g,y=o.bits,b=0,v=0,w=0,x=0,_=0,k=0,S=0,O=0,E=0,$=0,I=null,A=0,C=new Uint16Array(16),T=new Uint16Array(16),N=null,M=0;for(b=0;b<=15;b++)C[b]=0;for(v=0;v<n;v++)C[t[r+v]]++;for(_=y,x=15;x>=1&&0===C[x];x--);if(_>x&&(_=x),0===x)return i[a++]=0x1400000,i[a++]=0x1400000,o.bits=1,0;for(w=1;w<x&&0===C[w];w++);for(_<w&&(_=w),O=1,b=1;b<=15;b++)if(O<<=1,(O-=C[b])<0)return -1;if(O>0&&(0===e||1!==x))return -1;for(T[1]=0,b=1;b<15;b++)T[b+1]=T[b]+C[b];for(v=0;v<n;v++)0!==t[r+v]&&(s[T[t[r+v]]++]=v);if(0===e?(I=N=s,h=19):1===e?(I=e0,A-=257,N=e1,M-=257,h=256):(I=e2,N=e3,h=-1),$=0,v=0,b=w,f=a,k=_,S=0,u=-1,d=(E=1<<_)-1,1===e&&E>852||2===e&&E>592)return 1;for(;;){p=b-S,s[v]<h?(m=0,g=s[v]):s[v]>h?(m=N[M+s[v]],g=I[A+s[v]]):(m=96,g=0),l=1<<b-S,w=c=1<<k;do i[f+($>>S)+(c-=l)]=p<<24|m<<16|g;while(0!==c)for(l=1<<b-1;$&l;)l>>=1;if(0!==l?($&=l-1,$+=l):$=0,v++,0==--C[b]){if(b===x)break;b=t[r+s[v]]}if(b>_&&($&d)!==u){for(0===S&&(S=_),f+=w,O=1<<(k=b-S);k+S<x&&!((O-=C[k+S])<=0);)k++,O<<=1;if(E+=1<<k,1===e&&E>852||2===e&&E>592)return 1;i[u=$&d]=_<<24|k<<16|f-a}}return 0!==$&&(i[f+$]=b-S<<24|4194304),o.bits=_,0};let{Z_FINISH:e6,Z_BLOCK:e8,Z_TREES:e4,Z_OK:e9,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}=q,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,e9})(e)},tc=!0,tu=e=>{if(tc){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(e5(1,e.lens,0,288,s,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;e5(2,e.lens,0,32,o,0,e.work,{bits:5}),tc=!1}e.lencode=s,e.lenbits=9,e.distcode=o,e.distbits=5},td=(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,c,u,d,f,h,p,m,g,y,b,v,w,x,_,k,S,O,E=0,$=new Uint8Array(4),I=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,c=r.hold,u=r.bits,d=o,f=l,k=e9;r:for(;;)switch(r.mode){case 1:if(0===r.wrap){r.mode=13;break}for(;u<16;){if(0===o)break r;o--,c+=n[a++]<<u,u+=8}if(2&r.wrap&&35615===c){r.check=0,$[0]=255&c,$[1]=c>>>8&255,r.check=B(r.check,$,2,0),c=0,u=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&c)<<8)+(c>>8))%31){e.msg="incorrect header check",r.mode=30;break}if((15&c)!==ta){e.msg="unknown compression method",r.mode=30;break}if(c>>>=4,u-=4,_=(15&c)+8,0===r.wbits)r.wbits=_;else if(_>r.wbits){e.msg="invalid window size",r.mode=30;break}r.dmax=1<<r.wbits,e.adler=r.check=1,r.mode=512&c?10:12,c=0,u=0;break;case 2:for(;u<16;){if(0===o)break r;o--,c+=n[a++]<<u,u+=8}if(r.flags=c,(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=c>>8&1),512&r.flags&&($[0]=255&c,$[1]=c>>>8&255,r.check=B(r.check,$,2,0)),c=0,u=0,r.mode=3;case 3:for(;u<32;){if(0===o)break r;o--,c+=n[a++]<<u,u+=8}r.head&&(r.head.time=c),512&r.flags&&($[0]=255&c,$[1]=c>>>8&255,$[2]=c>>>16&255,$[3]=c>>>24&255,r.check=B(r.check,$,4,0)),c=0,u=0,r.mode=4;case 4:for(;u<16;){if(0===o)break r;o--,c+=n[a++]<<u,u+=8}r.head&&(r.head.xflags=255&c,r.head.os=c>>8),512&r.flags&&($[0]=255&c,$[1]=c>>>8&255,r.check=B(r.check,$,2,0)),c=0,u=0,r.mode=5;case 5:if(1024&r.flags){for(;u<16;){if(0===o)break r;o--,c+=n[a++]<<u,u+=8}r.length=c,r.head&&(r.head.extra_len=c),512&r.flags&&($[0]=255&c,$[1]=c>>>8&255,r.check=B(r.check,$,2,0)),c=0,u=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&((h=r.length)>o&&(h=o),h&&(r.head&&(_=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+h),_)),512&r.flags&&(r.check=B(r.check,n,h,a)),o-=h,a+=h,r.length-=h),r.length))break r;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(0===o)break r;h=0;do _=n[a+h++],r.head&&_&&r.length<65536&&(r.head.name+=String.fromCharCode(_));while(_&&h<o)if(512&r.flags&&(r.check=B(r.check,n,h,a)),o-=h,a+=h,_)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;h=0;do _=n[a+h++],r.head&&_&&r.length<65536&&(r.head.comment+=String.fromCharCode(_));while(_&&h<o)if(512&r.flags&&(r.check=B(r.check,n,h,a)),o-=h,a+=h,_)break r}else r.head&&(r.head.comment=null);r.mode=9;case 9:if(512&r.flags){for(;u<16;){if(0===o)break r;o--,c+=n[a++]<<u,u+=8}if(c!==(65535&r.check)){e.msg="header crc mismatch",r.mode=30;break}c=0,u=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(;u<32;){if(0===o)break r;o--,c+=n[a++]<<u,u+=8}e.adler=r.check=ts(c),c=0,u=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=c,r.bits=u,te;e.adler=r.check=1,r.mode=12;case 12:if(t===e8||t===e4)break r;case 13:if(r.last){c>>>=7&u,u-=7&u,r.mode=27;break}for(;u<3;){if(0===o)break r;o--,c+=n[a++]<<u,u+=8}switch(r.last=1&c,u-=1,3&(c>>>=1)){case 0:r.mode=14;break;case 1:if(tu(r),r.mode=20,t===e4){c>>>=2,u-=2;break r}break;case 2:r.mode=17;break;case 3:e.msg="invalid block type",r.mode=30}c>>>=2,u-=2;break;case 14:for(c>>>=7&u,u-=7&u;u<32;){if(0===o)break r;o--,c+=n[a++]<<u,u+=8}if((65535&c)!=(c>>>16^65535)){e.msg="invalid stored block lengths",r.mode=30;break}if(r.length=65535&c,c=0,u=0,r.mode=15,t===e4)break r;case 15:r.mode=16;case 16:if(h=r.length){if(h>o&&(h=o),h>l&&(h=l),0===h)break r;i.set(n.subarray(a,a+h),s),o-=h,a+=h,l-=h,s+=h,r.length-=h;break}r.mode=12;break;case 17:for(;u<14;){if(0===o)break r;o--,c+=n[a++]<<u,u+=8}if(r.nlen=(31&c)+257,u-=5,r.ndist=(31&(c>>>=5))+1,u-=5,r.ncode=(15&(c>>>=5))+4,c>>>=4,u-=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(;u<3;){if(0===o)break r;o--,c+=n[a++]<<u,u+=8}r.lens[I[r.have++]]=7&c,c>>>=3,u-=3}for(;r.have<19;)r.lens[I[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,S={bits:r.lenbits},k=e5(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=(E=r.lencode[c&(1<<r.lenbits)-1])>>>24,y=E>>>16&255,b=65535&E,!(g<=u);){if(0===o)break r;o--,c+=n[a++]<<u,u+=8}if(b<16)c>>>=g,u-=g,r.lens[r.have++]=b;else{if(16===b){for(O=g+2;u<O;){if(0===o)break r;o--,c+=n[a++]<<u,u+=8}if(c>>>=g,u-=g,0===r.have){e.msg="invalid bit length repeat",r.mode=30;break}_=r.lens[r.have-1],h=3+(3&c),c>>>=2,u-=2}else if(17===b){for(O=g+3;u<O;){if(0===o)break r;o--,c+=n[a++]<<u,u+=8}c>>>=g,u-=g,_=0,h=3+(7&c),c>>>=3,u-=3}else{for(O=g+7;u<O;){if(0===o)break r;o--,c+=n[a++]<<u,u+=8}c>>>=g,u-=g,_=0,h=11+(127&c),c>>>=7,u-=7}if(r.have+h>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=30;break}for(;h--;)r.lens[r.have++]=_}}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=e5(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=e5(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===e4)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=c,r.bits=u,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,c=r.hold,u=r.bits,12===r.mode&&(r.back=-1);break}for(r.back=0;g=(E=r.lencode[c&(1<<r.lenbits)-1])>>>24,y=E>>>16&255,b=65535&E,!(g<=u);){if(0===o)break r;o--,c+=n[a++]<<u,u+=8}if(y&&(240&y)==0){for(v=g,w=y,x=b;g=(E=r.lencode[x+((c&(1<<v+w)-1)>>v)])>>>24,y=E>>>16&255,b=65535&E,!(v+g<=u);){if(0===o)break r;o--,c+=n[a++]<<u,u+=8}c>>>=v,u-=v,r.back+=v}if(c>>>=g,u-=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(O=r.extra;u<O;){if(0===o)break r;o--,c+=n[a++]<<u,u+=8}r.length+=c&(1<<r.extra)-1,c>>>=r.extra,u-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;g=(E=r.distcode[c&(1<<r.distbits)-1])>>>24,y=E>>>16&255,b=65535&E,!(g<=u);){if(0===o)break r;o--,c+=n[a++]<<u,u+=8}if((240&y)==0){for(v=g,w=y,x=b;g=(E=r.distcode[x+((c&(1<<v+w)-1)>>v)])>>>24,y=E>>>16&255,b=65535&E,!(v+g<=u);){if(0===o)break r;o--,c+=n[a++]<<u,u+=8}c>>>=v,u-=v,r.back+=v}if(c>>>=g,u-=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(O=r.extra;u<O;){if(0===o)break r;o--,c+=n[a++]<<u,u+=8}r.offset+=c&(1<<r.extra)-1,c>>>=r.extra,u-=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(h=f-l,r.offset>h){if((h=r.offset-h)>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=30;break}h>r.wnext?(h-=r.wnext,p=r.wsize-h):p=r.wnext-h,h>r.length&&(h=r.length),m=r.window}else m=i,p=s-r.offset,h=r.length;h>l&&(h=l),l-=h,r.length-=h;do i[s++]=m[p++];while(--h)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(;u<32;){if(0===o)break r;o--,c|=n[a++]<<u,u+=8}if(f-=l,e.total_out+=f,r.total+=f,f&&(e.adler=r.check=r.flags?B(r.check,i,f,s-f):R(r.check,i,f,s-f)),f=l,(r.flags?c:ts(c))!==r.check){e.msg="incorrect data check",r.mode=30;break}c=0,u=0}r.mode=28;case 28:if(r.wrap&&r.flags){for(;u<32;){if(0===o)break r;o--,c+=n[a++]<<u,u+=8}if(c!==(0|r.total)){e.msg="incorrect length check",r.mode=30;break}c=0,u=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=c,r.bits=u,(r.wsize||f!==e.avail_out&&r.mode<30&&(r.mode<27||t!==e6))&&td(e,e.output,e.next_out,f-e.avail_out),d-=e.avail_in,f-=e.avail_out,e.total_in+=d,e.total_out+=f,r.total+=f,r.wrap&&f&&(e.adler=r.check=r.flags?B(r.check,i,f,e.next_out-f):R(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===d&&0===f||t===e6)&&k===e9&&(k=ti),k},th=e=>{if(!e||!e.state)return tt;let t=e.state;return t.window&&(t.window=null),e.state=null,e9},tp=(e,t)=>{let r,n=t.length;return e&&e.state&&(0===(r=e.state).wrap||11===r.mode)?11===r.mode&&R(1,t,n,0)!==r.check?tr:td(e,t,n,n)?(r.mode=31,tn):(r.havedict=1,e9):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:tw,Z_NEED_DICT:tx,Z_STREAM_ERROR:t_,Z_DATA_ERROR:tk,Z_MEM_ERROR:tS}=q;function tO(e){this.options=eM({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 eL,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!==e9&&(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=eU(t.dictionary):"[object ArrayBuffer]"===tg.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw)&&(r=tp(this.strm,t.dictionary))!==tv))throw Error(Y[r])}function tE(e,t){let r=new tO(t);if(r.push(e),r.err)throw r.msg||Y[r.err];return r.result}tO.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=tp(a,o))===tv?r=tf(a,n):r===tk&&(r=tx));a.avail_in>0&&r===tw&&a.state.wrap>0&&0!==e[a.next_in];)tl(a),r=tf(a,n);switch(r){case t_: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===tw))if("string"===this.options.to){let e=eR(a.output,a.next_out),t=a.next_out-e,r=eF(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===tw)return r=th(this.strm),this.onEnd(r),this.ended=!0,!0;if(0===a.avail_in)break}}return!0},tO.prototype.onData=function(e){this.chunks.push(e)},tO.prototype.onEnd=function(e){e===tv&&("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:t$,deflate:tI,deflateRaw:tA,gzip:tC}={Deflate:eH,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:q},{Inflate:tT,inflate:tN,inflateRaw:tM,ungzip:tP}={Inflate:tO,inflate:tE,inflateRaw:function(e,t){return(t=t||{}).raw=!0,tE(e,t)},ungzip:tE,constants:q};r.d(t,{Gy:()=>t$,Kc:()=>tI,UD:()=>tN})},7068(e,t,r){let n;r.d(t,{Er:()=>th,Ov:()=>tj,Tx:()=>tY,UA:()=>nW,yE:()=>e5,Ky:()=>eb,e5:()=>eW,Uh:()=>e0,OF:()=>iF,XV:()=>iD,r8:()=>iU,rR:()=>nJ});var i=r(8861),a=r(8619),s=r(7720),o=r(190),l=r(5089),c=r(9177),u=r(6030),d=r(3833),f=r(995),h=r(4858),p=r(6310);let m=/[,;]\s*(?:id|label|kind|group|source|target|title|direction|nodes|edges)\s*:?\s*$/i;function g(e){let t=e.trim();for(;;){let e=t.replace(m,"").trim();if(e===t)return t;t=e}}class y extends i.Xsx("ContractSchemaIssue")({code:N("custom"),message:i.QfV,path:i.O31(i.pHd)},{identifier:void 0}){}class b extends i.X0d()("ContractSchemaError",{issues:i.O31(i.O3D(y))}){}let v=e=>{var t;if("InvalidType"!==e._tag)return u.vp(e);let r=d.isSome(e.actual)?e.actual.value:void 0;return`Invalid input: expected ${t=e.ast,c.Kg(t)?"string":c.Et(t)?"number":c.Lm(t)?"boolean":c.tF(t)?"array":c.RP(t)?"object":c.c$(t)?JSON.stringify(t.literal):"value"}, received ${null===r?"null":Array.isArray(r)?"array":typeof r}`},w=u.ID({leafHook:v});function x(e){return"string"==typeof e||"number"==typeof e||"symbol"==typeof e}function _(e,t){let r,n=i.q$Z(e,{errors:"all"})(t);return f.oJ(n)?{data:n.success,success:!0}:{error:new b({issues:(r=w(n.failure.issue).issues.map(e=>{let t=(e.path??[]).flatMap(e=>{let t=x(e)?e:null!==e&&"object"==typeof e&&"key"in e&&x(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 k(e){return Object.assign(e,{parse:t=>(function(e,t){let r=_(e,t);if(r.success)return r.data;throw r.error})(e,t),safeParse:t=>_(e,t)})}let S=new Set(["const","exclusiveMaximum","exclusiveMinimum","maximum","maxLength","minimum","minItems","minLength","pattern"]);function O(e){let t=i._oz(i.AxX(e),{includeAnnotationKey:e=>S.has(e)});return{$schema:"https://json-schema.org/draft/2020-12/schema",...t.schema,...0===Object.keys(t.definitions).length?{}:{$defs:t.definitions}}}function E(e){return i.O31(e).pipe(i.fXn).annotate({minItems:1}).check(i.HNH(e=>e.length>=1,{message:"Too small: expected array to have >=1 items"}))}function $(e){let t=i.hzj()([e],([e])=>(t,r,n)=>void 0===t?s.PyW(void 0):h._R(e)(t,n),{toCodecJson:([e])=>i.nfo()(e,{decode:p.le({strict:!1}),encode:new p.uB(e=>s.PyW(d.filter(e,e=>void 0!==e)))})});return i.Qrq(t)}function I(e){return e.pipe(i.usV({messageMissingKey:"Invalid input: expected string, received undefined"}))}function A(e){return e.pipe(i.usV({messageMissingKey:"Invalid input: expected object, received undefined"}))}function C(e){return e.pipe(i.usV({messageMissingKey:"Invalid input: expected array, received undefined"}))}function T(e){return i.xCb(e).annotate({message:`Invalid option: expected one of ${e.map(e=>JSON.stringify(e)).join("|")}`})}function N(e){return i.uSQ(e).pipe(i.GLL(i.QfV.annotate({const:e}).pipe(i.YPB(t=>t===e,{message:`Invalid literal value, expected ${JSON.stringify(e)}`}))))}function M(e){return i.uSQ(e).pipe(i.GLL(i.wNn.annotate({const:e}).pipe(i.YPB(t=>t===e,{message:`Invalid literal value, expected ${JSON.stringify(e)}`}))))}function P(e){return i.uSQ(e).pipe(i.GLL(i.v8c.annotate({const:e}).pipe(i.YPB(t=>t===e,{message:`Invalid literal value, expected ${JSON.stringify(e)}`}))))}let j=i.QfV.annotate({minLength:1}).check(i.HNH(e=>e.length>=1,{message:"Too small: expected string to have >=1 characters"})),D=I(j),U=i.wYs,F=i.wNn.annotate({exclusiveMinimum:0}).check(i.MIs(),i.HNH(e=>e>0,{message:"Too small: expected number to be >0"})),R=/^#[0-9a-fA-F]{6}$/;function L(e){return i.QfV.annotate({pattern:R.source,...void 0===e?{}:{default:e}}).check(i.HNH(e=>R.test(e),{message:`Invalid string: must match pattern /${R.source}/`}))}let B=L();k(B);let Y=["excalidraw","scene","png"],q=["excalidraw","scene"],X=Object.assign(k(T(Y)),{options:Y}),W=Object.assign(k(T(q)),{options:q});class J extends i.Xsx("ArtifactProvenance")({sourceArtifactId:D.pipe(i.Wa3)},{identifier:void 0}){}k(J);let z=["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"],K=Object.assign(k(T(z)),{options:z}),V=T(["request","diagram","node","edge","artifact"]),G=T(["input","flowchart","mindmap","quality","render","export","storage"]);class H extends i.Xsx("CodeModeIssueRef")({kind:V,id:$(j),path:$(j)},{identifier:void 0}){}k(H);class Q extends i.Xsx("CodeModeIssue")({code:K,severity:T(["error","warning"]),stage:G,ref:$(H),message:D,hint:D},{identifier:void 0}){}k(Q);let Z=["start","process","decision","end"],ee=Object.assign(k(T(Z)),{options:Z}),et=["setDefaultStyle","setStyle","setShape","translate","replaceText","rerouteEdges"];Object.assign(k(T(et)),{options:et});class er extends i.Xsx("FlowchartSpecNode")({id:D,label:D,kind:ee,description:$(j)},{identifier:void 0}){}class en extends i.Xsx("FlowchartSpecEdge")({id:$(j),source:D,target:D,label:$(j)},{identifier:void 0}){}let ei=T(["TB","LR"]),ea=ei.annotate({default:"TB"}).pipe(i.tiU(s.PyW("TB")));class es extends i.Xsx("FlowchartSpecLayout")({direction:ea},{identifier:void 0}){}let eo="#000000",el=L(eo).pipe(i.tiU(s.PyW(eo))),ec="#ffffff",eu=L(ec).pipe(i.tiU(s.PyW(ec)));class ed extends i.Xsx("FlowchartSpecStyle")({accentColor:el,backgroundColor:eu},{identifier:void 0}){}let ef=[],eh=i.O31(en).pipe(i.fXn).annotate({default:ef}).pipe(i.tiU(s.PyW(ef))),ep={direction:"TB"},em=es.annotate({default:ep}).pipe(i.tiU(s.PyW(ep))),eg={accentColor:"#000000",backgroundColor:"#ffffff"},ey=ed.annotate({default:eg}).pipe(i.tiU(s.PyW(eg)));class eb extends i.Xsx("FlowchartSpec")({id:$(j),title:D,nodes:C(E(er)),edges:eh,layout:em,style:ey},{identifier:void 0}){}k(eb),k(er),k(en),k(es),k(ed);class ev extends i.Xsx("SequenceParticipantSpec")({id:D,label:D,kind:$(j)},{identifier:void 0}){}class ew extends i.Xsx("SequenceMessageSpec")({id:$(j),source:D,target:D,label:D,type:$(T(["message","return"])),style:$(T(["solid","dashed"]))},{identifier:void 0}){}let ex=[],e_=i.O31(ew).pipe(i.fXn).annotate({default:ex}).pipe(i.tiU(s.PyW(ex))),ek={accentColor:"#000000",backgroundColor:"#ffffff"},eS=i._kM({accentColor:L(eo).pipe(i.tiU(s.PyW(eo))),backgroundColor:L(ec).pipe(i.tiU(s.PyW(ec)))}).annotate({default:ek}).pipe(i.tiU(s.PyW(ek)));class eO extends i.Xsx("SequenceDiagramSpec")({id:$(j),title:D,participants:C(E(ev)),messages:e_,style:eS},{identifier:void 0}){}k(eO),k(ev),k(ew);let eE=$(E(X)),e$=$(i.O31(W).pipe(i.fXn)),eI=$(i.wNn.annotate({minimum:0,maximum:10}).check(i.MIs(),i.HNH(e=>e>=0,{message:"Too small: expected number to be >=0"}),i.HNH(e=>e<=10,{message:"Too big: expected number to be <=10"})));class eA extends i.Xsx("BuildFlowchartOptions")({artifactFormats:eE,inlineArtifacts:e$,minQualityScore:eI},{identifier:void 0}){}k($(eA));class eC extends i.Xsx("BuildFlowchartRequest")({requestId:$(j),spec:A(eb),options:$(eA)},{identifier:void 0}){}let eT=eC.mapFields(({requestId:e,spec:t})=>({requestId:e,spec:t})),eN=i.rcy(eT,{leafHook:v,parseOptions:{errors:"all"}});Object.assign(eN["~standard"],{jsonSchema:{input:()=>O(eT),output:()=>O(eT)}});let eM=Object.assign(k(eC),{omit:e=>eN});class eP extends i.Xsx("BuildSequenceDiagramRequest")({requestId:$(j),spec:A(eO),options:$(eA)},{identifier:void 0}){}let ej=k(eP),eD=i.QfV.annotate({minLength:1}).check(i.HNH(e=>e.length>=1,{message:"Too small: expected string to have >=1 characters"}),i.HNH(function(e){let t=g(e);return t.length>0&&!/^(?:""|''|``)$/.test(t)},{message:"Must contain semantic text after normalization."})),eU=A(i.DYE(()=>eF).annotate({identifier:"__schema0"})),eF=i._kM({label:I(eD),children:i.Qrq(i.O31(eU).pipe(i.fXn))});k(eU);class eR extends i.Xsx("MindmapSpecLayout")({direction:T(["LR","RL"]).annotate({default:"LR"}).pipe(i.tiU(s.PyW("LR")))},{identifier:void 0}){}let eL={direction:"LR"},eB=eR.annotate({default:eL}).pipe(i.tiU(s.PyW(eL))),eY={accentColor:"#7c3aed",backgroundColor:"#ffffff"},eq=i._kM({accentColor:L(eo).pipe(i.tiU(s.PyW(eY.accentColor))),backgroundColor:L(eY.backgroundColor).pipe(i.tiU(s.PyW(eY.backgroundColor)))}).annotate({default:eY}).pipe(i.tiU(s.PyW(eY))),eX=i._kM({id:$(j),title:I(eD),root:eU,layout:eB,style:eq});class eW extends i.Xsx("MindmapSpec")(eX,{identifier:void 0}){}k(eW);let eJ=i._kM({requestId:$(j),spec:A(eX),options:$(eA)});i.Xsx("BuildMindmapRequest")(eJ,{identifier:void 0});let ez=k(eJ);class eK extends i.Xsx("ScenePoint")({x:U.pipe(i.Wa3),y:U.pipe(i.Wa3)},{identifier:void 0}){}k(eK);class eV extends i.Xsx("NodeSceneElement")({type:N("node"),id:D,nodeId:D,kind:$(j),rendererRole:$(T(["sequence-lifeline"])),shape:T(["rectangle","ellipse","diamond","circle"]).pipe(i.Wa3),fillColor:$(B).pipe(i.Wa3),strokeColor:$(B).pipe(i.Wa3),textColor:$(B).pipe(i.Wa3),x:U.pipe(i.Wa3),y:U.pipe(i.Wa3),width:F.pipe(i.Wa3),height:F.pipe(i.Wa3),label:D.pipe(i.Wa3)},{identifier:void 0}){}class eG extends i.Xsx("TextSceneElement")({type:N("text"),id:D,containerId:$(j),textColor:$(B).pipe(i.Wa3),x:U.pipe(i.Wa3),y:U.pipe(i.Wa3),text:D.pipe(i.Wa3),fontSize:F,maxWidth:$(F)},{identifier:void 0}){}class eH extends i.Xsx("ArrowSceneElement")({type:N("arrow"),id:D,edgeId:D,sourceNodeId:D,targetNodeId:D.pipe(i.Wa3),strokeColor:$(B).pipe(i.Wa3),strokeStyle:$(T(["dashed","dotted","solid"])).pipe(i.Wa3),textColor:$(B).pipe(i.Wa3),points:C(i.O31(eK).pipe(i.fXn)).annotate({minItems:2}).check(i.HNH(e=>e.length>=2,{message:"Too small: expected array to have >=2 items"})).pipe(i.Wa3),label:$(j).pipe(i.Wa3)},{identifier:void 0}){}k(eV),k(eG),k(eH);let eQ=i.gPz([eV,eG,eH],{mode:"oneOf"});class eZ extends i.Xsx("RenderedDiagramScene")({diagramId:D,title:D,width:F.pipe(i.Wa3),height:F.pipe(i.Wa3),accentColor:B.pipe(i.Wa3),backgroundColor:B.pipe(i.Wa3),elements:C(i.O31(eQ).pipe(i.fXn))},{identifier:void 0}){}let e0=k(eZ),e1=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"}));k(e1);class e2 extends i.Xsx("ExcalidrawScene")({appState:i.mSG(i.QfV,i.$r1),elements:i.O31(e1).pipe(i.fXn)},{identifier:void 0}){}k(e2);class e3 extends e2.extend("ExcalidrawFile")({files:i.mSG(i.QfV,i.$r1),source:D,type:N("excalidraw"),version:M(2)},{identifier:void 0}){}let e5=k(e3);class e6 extends i.Xsx("GetArtifactRequest")({artifactId:D,format:$(X),inline:$(i.v8c)},{identifier:void 0}){}let e8=k(e6);class e4 extends i.Xsx("DiagramSelector")({ids:$(i.O31(j).pipe(i.fXn)),nodeIds:$(i.O31(j).pipe(i.fXn)),edgeIds:$(i.O31(j).pipe(i.fXn)),kinds:$(i.O31(ee).pipe(i.fXn)),labels:$(i.O31(j).pipe(i.fXn)),scope:$(T(["all","nodes","edges"]))},{identifier:void 0}){}k(e4);class e9 extends i.Xsx("DiagramStylePatch")({strokeColor:$(B),fillColor:$(B),textColor:$(B),backgroundColor:$(B)},{identifier:void 0}){}k(e9);let e7=["rectangle","diamond","ellipse","circle"],te=Object.assign(k(T(e7)),{options:e7});class tt extends i.Xsx("SetDefaultStyleOperation")({op:N("setDefaultStyle"),style:A(e9)},{identifier:void 0}){}class tr extends i.Xsx("SetStyleOperation")({op:N("setStyle"),selector:A(e4),style:A(e9)},{identifier:void 0}){}class tn extends i.Xsx("SetShapeOperation")({op:N("setShape"),selector:A(e4),shape:te},{identifier:void 0}){}class ti extends i.Xsx("TranslateOperation")({op:N("translate"),selector:A(e4),dx:U,dy:U},{identifier:void 0}){}class ta extends i.Xsx("ReplaceTextOperation")({op:N("replaceText"),selector:A(e4),text:D},{identifier:void 0}){}class ts extends i.Xsx("RerouteEdgesOperation")({op:N("rerouteEdges"),selector:$(e4)},{identifier:void 0}){}let to=i.gPz([tt,tr,tn,ti,ta,ts],{mode:"oneOf"}).annotate({message:`Invalid discriminator value. Expected ${et.map(e=>`'${e}'`).join(" | ")}`});class tl extends i.Xsx("ArtifactPatchSource")({artifactId:D,format:$(N("scene"))},{identifier:void 0}){}class tc extends i.Xsx("InlineScenePatchSource")({scene:A(eZ)},{identifier:void 0}){}let tu=i.gPz([tl,tc]).annotate({message:"Invalid input"});class td extends i.Xsx("ApplyDiagramPatchOptions")({artifactFormats:eE,inlineArtifacts:e$,preserveConnectivity:$(i.v8c)},{identifier:void 0}){}k($(td));class tf extends i.Xsx("ApplyDiagramPatchRequest")({requestId:$(j),source:tu.annotateKey({messageMissingKey:"Invalid input"}),operations:C(E(to)).pipe(i.rvE({minItems:1})),options:$(td),intent:$(j)},{identifier:void 0}){}let th=k(tf),tp=i._kM({id:j,title:j,nodes:i.O31(er).pipe(i.fXn),edges:i.O31(en.mapFields(e=>({...e,id:j}))).pipe(i.fXn),layout:i._kM({direction:ei}),style:i._kM({accentColor:B,backgroundColor:B})}),tm=i._kM({id:j,label:j,children:i.O31(i.DYE(()=>tm)).pipe(i.fXn)}),tg=i._kM({id:j,title:j,root:tm,layout:i._kM({direction:T(["LR","RL"])}),style:i._kM({accentColor:B,backgroundColor:B})}),ty=i._kM({id:j,title:j,participants:i.O31(ev).pipe(i.fXn),messages:i.O31(ew.mapFields(e=>({...e,id:j}))).pipe(i.fXn),style:i._kM({accentColor:B,backgroundColor:B})}),tb=i._kM({code:i.QfV,passed:i.v8c,severity:T(["error","warning"]),message:i.QfV,refs:i.O31(H).pipe(i.fXn)}),tv=i._kM({accepted:i.v8c,score:i.wNn,threshold:i.wNn,summary:i._kM({nodeCount:i.wNn,edgeCount:i.wNn}),checks:i.O31(tb).pipe(i.fXn)}),tw=i._kM({format:X,mimeType:i.QfV,url:$(i.QfV),expiresAt:$(i.QfV),inline:$(i.$r1),sizeBytes:$(i.wNn)}),tx=i._kM({artifactId:i.QfV,diagramId:i.QfV,formats:i.O31(tw).pipe(i.fXn),provenance:$(J),preview:$(tw)}),t_=i._kM({artifactId:$(i.QfV),diagramId:$(i.QfV),formats:$(i.O31(tw).pipe(i.fXn))});class tk extends i.Xsx("BuildFlowchartAccepted")({ok:P(!0),status:N("accepted"),buildId:i.QfV,requestId:$(i.QfV),normalizedSpec:tp,quality:tv,artifact:tx,issues:i.O31(Q).pipe(i.fXn)},{identifier:void 0}){}class tS extends i.Xsx("BuildFlowchartRejected")({ok:P(!1),status:T(["invalid_input","invalid_flowchart","quality_failed","render_failed","export_failed","storage_failed"]),buildId:$(i.QfV),requestId:$(i.QfV),normalizedSpec:$(tp),quality:$(tv),partial:$(t_),issues:i.O31(Q).pipe(i.fXn)},{identifier:void 0}){}i.gPz([tk,tS]);class tO extends i.Xsx("BuildMindmapAccepted")({ok:P(!0),status:N("accepted"),buildId:i.QfV,requestId:$(i.QfV),normalizedSpec:tg,quality:tv,artifact:tx,issues:i.O31(Q).pipe(i.fXn)},{identifier:void 0}){}class tE extends i.Xsx("BuildMindmapRejected")({ok:P(!1),status:T(["invalid_input","invalid_mindmap","quality_failed","render_failed","export_failed","storage_failed"]),buildId:$(i.QfV),requestId:$(i.QfV),normalizedSpec:$(tg),quality:$(tv),partial:$(t_),issues:i.O31(Q).pipe(i.fXn)},{identifier:void 0}){}i.gPz([tO,tE]);class t$ extends i.Xsx("BuildSequenceDiagramAccepted")({ok:P(!0),status:N("accepted"),buildId:i.QfV,requestId:$(i.QfV),normalizedSpec:ty,quality:tv,artifact:tx,issues:i.O31(Q).pipe(i.fXn)},{identifier:void 0}){}class tI extends i.Xsx("BuildSequenceDiagramRejected")({ok:P(!1),status:T(["invalid_input","invalid_sequence","quality_failed","render_failed","export_failed","storage_failed"]),buildId:$(i.QfV),requestId:$(i.QfV),normalizedSpec:$(ty),quality:$(tv),partial:$(t_),issues:i.O31(Q).pipe(i.fXn)},{identifier:void 0}){}i.gPz([t$,tI]);class tA extends i.Xsx("GetArtifactAccepted")({ok:P(!0),artifactId:i.QfV,diagramId:i.QfV,format:X,mimeType:i.QfV,url:$(i.QfV),expiresAt:$(i.QfV),inline:$(i.$r1),sizeBytes:$(i.wNn),provenance:$(J)},{identifier:void 0}){}class tC extends i.Xsx("GetArtifactRejected")({ok:P(!1),status:T(["invalid_input","not_found","format_unavailable","expired","storage_failed"]),issues:i.O31(Q).pipe(i.fXn)},{identifier:void 0}){}i.gPz([tA,tC]);class tT extends i.Xsx("ApplyDiagramPatchAccepted")({ok:P(!0),status:N("accepted"),patchId:i.QfV,requestId:$(i.QfV),sourceArtifactId:$(i.QfV),artifact:tx,issues:i.O31(Q).pipe(i.fXn)},{identifier:void 0}){}class tN extends i.Xsx("ApplyDiagramPatchRejected")({ok:P(!1),status:T(["invalid_input","source_unavailable","target_not_found","unsupported_operation","connectivity_changed","render_failed","export_failed","storage_failed"]),patchId:$(i.QfV),requestId:$(i.QfV),sourceArtifactId:$(i.QfV),partial:$(t_),issues:i.O31(Q).pipe(i.fXn)},{identifier:void 0}){}i.gPz([tT,tN]);let tM=i.xCb(["read","readManifest","write"]);class tP extends i.X0d()("CodeModeArtifactStorageError",{cause:i.kld(),message:i.QfV,operation:tM}){}class tj extends a.kl()("@sketchi/diagram-agent/CodeModeArtifactStorage"){}let tD={excalidraw:"application/vnd.excalidraw+json",png:"image/png",scene:"application/vnd.sketchi.scene+json"};function tU(e){return"excalidraw"===e||"scene"===e}function tF(e){return{format:e.format,mimeType:e.mimeType,sizeBytes:e.sizeBytes}}function tR(e){return structuredClone(e)}function tL(e){return new TextEncoder().encode(JSON.stringify(e)).length}function tB(e){return t=>{var r;return tP.make({cause:t,message:(r="write"===e?"Artifact storage failed.":"Artifact read failed.",t instanceof Error?t.message:r),operation:e})}}let tY=l.QZ(tj)(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:tR(n.data)}:null},catch:tB("read")})}),readManifest:s.fn("codeMode.artifacts.memory.readManifest")(function*(t){return yield*s.SvU({try:()=>{let r=e.get(t);return r?tR(r):null},catch:tB("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(tF),o=r.provenance?tR(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:tR(n.data)});let c=r.formats.map(e=>{var t;return t=r.inlineFormats,{format:e.format,mimeType:e.mimeType,...tU(e.format)&&t.includes(e.format)?{inline:e.data}:{},sizeBytes:e.sizeBytes}});return a=(i={artifactId:r.artifactId,diagramId:r.diagramId,formats:c,...r.provenance?{provenance:tR(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:tB("write")})})}}}),e=>e.close).pipe(s.TjK(e=>e.storage)));function tq(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."}}let tX=i.ukk,tW=i.mSG(i.QfV,i.$r1);function tJ(e,t){return e.pipe(i.tiU(s.PyW(t)))}function tz(e,t){return i.svK(e,{errors:"all"})(t)}let tK=u.ID();function tV(e){return Object.assign(e,{parse:t=>tz(e,t),safeParse:t=>{let r;return r=i.q$Z(e,{errors:"all"})(t),f.oJ(r)?{data:r.success,success:!0}:{error:{issues:tK(r.failure.issue).issues.map(e=>({message:e.message,path:(e.path??[]).map(e=>"object"==typeof e?e.key:e)}))},success:!1}}})}let tG=i.xCb(["flowchart","mindmap"]),tH=i.xCb(["TB","BT","LR","RL"]),tQ=i.xCb(["straight","orthogonal","curved"]);class tZ extends i.Xsx("DiagramNode")({id:tX,label:tX,group:i.lqM(tX),kind:i.lqM(tX),metadata:tJ(tW,{})}){}tV(tZ);class t0 extends i.Xsx("DiagramEdge")({id:tX,source:tX,target:tX,label:i.lqM(tX),metadata:tJ(tW,{})}){}tV(t0);let t1=i.QfV.check(i.Pto(/^#[0-9a-fA-F]{6}$/));class t2 extends i.Xsx("DiagramStyle")({accentColor:tJ(t1,"#0f766e"),backgroundColor:tJ(t1,"#ffffff")}){}tV(t2);class t3 extends i.Xsx("DiagramLayout")({direction:tJ(tH,"LR"),edgeRouting:tJ(tQ,"orthogonal")}){}tV(t3);class t5 extends i.Xsx("IntermediateDiagram")({id:tX,title:tX,type:tJ(tG,"flowchart"),nodes:i.O31(tZ).pipe(i.fXn).check(i.tJb(1)),edges:tJ(i.O31(t0).pipe(i.fXn),[]),layout:tJ(t3,{direction:"LR",edgeRouting:"orthogonal"}),style:tJ(t2,{accentColor:"#0f766e",backgroundColor:"#ffffff"}),metadata:tJ(tW,{})}){}tV(t5);class t6 extends Error{constructor(e){super(e),this.name="DiagramValidationError"}}let t8=e=>{let t=new Set;for(let r of e){if(t.has(r))return r;t.add(r)}};function t4(e){let t=t8(e.nodes.map(e=>e.id));if(t)throw new t6(`Duplicate node id "${t}" is not allowed.`);let r=t8(e.edges.map(e=>e.id));if(r)throw new t6(`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 t6(`Edge "${t.id}" references missing source node "${t.source}".`);if(!n.has(t.target))throw new t6(`Edge "${t.id}" references missing target node "${t.target}".`);if(t.source===t.target)throw new t6(`Edge "${t.id}" cannot connect node "${t.source}" to itself.`)}return e}function t9(e){return t4(tz(t5,e))}let t7="flowchart",re=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 rt extends i.Xsx("FlowchartValidationIssueRef")({kind:i.xCb(["diagram","node","edge"]),id:i.lqM(i.ukk),path:i.lqM(i.ukk)}){}i.Xsx("FlowchartValidationIssue")({code:re,ref:i.lqM(rt),message:i.ukk,hint:i.ukk});let rr=i.xCb(["start","process","decision","end"]);class rn extends tZ.extend("FlowchartNode")({kind:rr,description:i.lqM(i.ukk)}){}class ri extends t0.extend("FlowchartEdge")({label:i.lqM(i.ukk)}){}class ra extends t5.extend("FlowchartDiagram")({type:i.uSQ(t7),nodes:i.O31(rn).pipe(i.fXn).check(i.tJb(2)),edges:i.O31(ri).pipe(i.fXn).check(i.tJb(1))}){}let rs=tV(ra);function ro(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 rl(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 rc(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."}),ro(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 ro(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 ro(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=rl([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=rl(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 ru extends t6{issues;constructor(e){super(e[0]?.message??"Flowchart failed semantic validation."),this.issues=e,this.name="FlowchartValidationError"}}function rd(e){let t=rc(e);if(t.length>0)throw new ru(t);return e}let rf=rd(tz(ra,{id:"onboarding-flow",title:"Sketchi onboarding decision flow",type:t7,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"},style:{accentColor:"#0f766e",backgroundColor:"#ffffff"}}));rd(tz(ra,{id:"pharma-batch-disposition",title:"Pharma batch disposition flow",type:t7,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"},style:{accentColor:"#0f766e",backgroundColor:"#ffffff"}}));let rh="mindmap";class rp extends i.Xsx("MindmapNodeMetadata")({depth:i.Aiz.check(i.OWK(0)),siblingIndex:i.Aiz.check(i.OWK(0))}){}class rm extends tZ.extend("MindmapNode")({kind:i.xCb(["root","topic"]),metadata:rp}){}class rg extends i.Xsx("MindmapEdgeMetadata")({depth:i.Aiz.check(i.yJO(0)),siblingIndex:i.Aiz.check(i.OWK(0))}){}class ry extends t0.extend("MindmapEdge")({metadata:rg}){}class rb extends t5.extend("MindmapDiagram")({type:i.uSQ(rh),nodes:i.O31(rm).pipe(i.fXn).check(i.tJb(2)),edges:i.O31(ry).pipe(i.fXn).check(i.tJb(1))}){}function rv(e){return function(e){t4(e);let t=e.nodes.filter(e=>"root"===e.kind);if(1!==t.length)throw new t6(`Mindmap must contain exactly one root topic; found ${t.length}.`);let r=t[0];if(!r||0!==r.metadata.depth)throw new t6("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 t6(`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 t6(`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 t6(`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 t6(`Mindmap children of "${e}" must use contiguous sibling ordering from 0.`)}return e}(tz(rb,e))}tV(rb);let rw=rv({id:"public-mindmap-capability",title:"Public mindmap generation",type:rh,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"},style:{accentColor:"#7c3aed",backgroundColor:"#ffffff"}});function rx(e){return new Map(e.map((e,t)=>[e.id,t]))}function r_(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 rk(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}function rS(e,t,r){return Math.min(r,Math.max(t,e))}function rO(e,t,r=0){let n,i=(n="top"===t||"bottom"===t?e.width/2-16:e.height/2-16)>0?rS(r,-n,n):0,a=rk(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 rE(e){return`${e.edgeId}:${e.endpoint}`}t9(rf),t9(rw);function r$(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 rI(e,t,r){return e>t+.01&&e<r-.01}function rA(e,t,r,n){return Math.min(t,n)-Math.max(e,r)>.01}function rC(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?rI(a.y,e.y,e.y+e.height)&&rA(Math.min(a.x,s.x),Math.max(a.x,s.x),e.x,e.x+e.width):a.x===s.x&&rI(a.x,e.x,e.x+e.width)&&rA(Math.min(a.y,s.y),Math.max(a.y,s.y),e.y,e.y+e.height))&&(n+=1)}return n}function rT(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 rN(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 rM(e,t){return Math.min(e.max,t.max)-Math.max(e.min,t.min)}function rP(e,t,r){let n=rN({arrowId:`edge:${r.edge.id}`,points:e,sourceNodeId:r.edge.source,targetNodeId:r.edge.target}),i=t.flatMap(e=>rN({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>=rM(e,t)||(a+=1);return a}function rj(e,t){let r=rN({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>=rM(t,e)||(n+=1)}}return n}function rD(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 rU(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 rF(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 rR(e,t){let r=e[0],n=e[1],i=e[e.length-1],a=e[e.length-2],s=0;return n&&rF(r,n,t.sourceEdge)&&(s+=1),a&&i&&rF(i,a,t.targetEdge)&&(s+=1),s}function rL(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 rB(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]),c=Math.min(...n.map(e=>e.x)),u=Math.max(...n.map(e=>e.x+e.width)),d=Math.min(...n.map(e=>e.y)),f=Math.max(...n.map(e=>e.y+e.height)),h="left"===e.sourceEdge||"left"===e.targetEdge||rk(e.target).x<rk(e.source).x,p="top"===e.sourceEdge||"top"===e.targetEdge||rk(e.source).y<=rk(e.target).y,m=18*e.index,g=c-56-m,y=u+56+m,b=d-48-m,v=f+48+m,w=h?g:y,x=h?y:g,_=p?b:v,k=p?v:b,S=[0,36+e.index%4*18],O=(n,i)=>{let a=i>0?rL(t,e.sourceEdge,i):t,s=i>0?rL(r,e.targetEdge,i):r;return r$([t,a,{x:n,y:a.y},{x:n,y:s.y},s,r])},E=(n,i)=>{let a=i>0?rL(t,e.sourceEdge,i):t,s=i>0?rL(r,e.targetEdge,i):r;return r$([t,a,{x:a.x,y:n},{x:s.x,y:n},s,r])},$=[...S.map(e=>E(_,e)),...S.map(e=>E(k,e)),...S.map(e=>O(w,e)),...S.map(e=>O(x,e))],I=[...S.map(e=>O(w,e)),...S.map(e=>O(x,e)),...S.map(e=>E(_,e)),...S.map(e=>E(k,e))];return(s=(a=o?$:I)[0])?a.slice(1).reduce((t,r)=>{let a=rC(t,n,l),s=rC(r,n,l);if(s<a)return r;if(a<s)return t;let o=rj(t,e),c=rj(r,e);if(c<o)return r;if(o<c)return t;let u=rP(t,i,e),d=rP(r,i,e);if(d<u)return r;if(u<d)return t;let f=rR(t,e),h=rR(r,e);if(h>f)return r;if(f>h)return t;let p=rD(t),m=rD(r);if(m<p)return r;if(p<m)return t;let g=rU(t),y=rU(r);return y<g?r:g<y?t:rT(r)<rT(t)?r:t},s):[{x:0,y:0}]}function rY(e){return e.flatMap(e=>"arrow"===e.type?[...e.points]:[{x:e.x,y:e.y},{x:e.x+("node"===e.type?e.width:e.maxWidth??e.text.length),y:e.y+("node"===e.type?e.height:e.fontSize)}])}function rq(e,t,r){return{x:e.x+t,y:e.y+r}}function rX(e){var t;let r,n,i,a,s,o=t9(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=rx(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 c=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,c+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=rx(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,c=[];for(let e of s){let r=48+Math.max(0,o-e.breadth)/2;for(let n of e.shapes)t?(c.push({...n,x:r,y:l+Math.max(0,e.depth-n.height)/2}),r+=n.width+112):(c.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(...c.map(e=>e.y+e.height));return c.map(t=>({...t,y:48+e-t.y-t.height}))}if("RL"===e.layout.direction){let e=Math.max(...c.map(e=>e.x+e.width));return c.map(t=>({...t,x:48+e-t.x-t.width}))}return c}(o),c=new Map(l.map(e=>[e.nodeId,e])),u=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=rk(e),i=rk(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,c,o.layout.direction)),d=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(rE(t),(r-(e.length-1)/2)*18)});return s}(u),f=[];for(let e of u)f.push(function(e,t,r,n,i,a){let{edge:s,source:o,sourceEdge:l,target:c,targetEdge:u}=e,d=rO(o,l,r.get(rE({edgeId:s.id,endpoint:"source"}))??0),f=rO(c,u,r.get(rE({edgeId:s.id,endpoint:"target"}))??0),h=r$([d,f]);if(function(e,t,r){let n=rk(e),i=rk(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,c,a))h=rB(e,d,f,n,i);else if("orthogonal"===t&&d.x!==f.x&&d.y!==f.y){var p,m,g;let t,r,n,i=e.index%4*18,a=(p=d.y,m=f.y,g=f.y<d.y?-i:i,t=p+(m-p)/2,(r=Math.min(p,m)+18)<(n=Math.max(p,m)-18)?rS(t+g,r,n):t),s="left"===l?{x:d.x-36-i,y:d.y}:"right"===l?{x:d.x+36+i,y:d.y}:d,o="left"===u?{x:f.x-36-i,y:f.y}:"right"===u?{x:f.x+36+i,y:f.y}:f;h=r$([d,s,{x:s.x,y:a},{x:o.x,y:a},o,f])}return"orthogonal"===t&&(rC(h,n,new Set([o.nodeId,c.nodeId]))>0||rj(h,e)>0||rP(h,i,e)>0)&&(h=rB(e,d,f,n,i)),{type:"arrow",id:`edge:${s.id}`,edgeId:s.id,sourceNodeId:s.source,targetNodeId:s.target,points:h,...s.label?{label:s.label}:{}}}(e,o.layout.edgeRouting,d,l,f,o.layout.direction));let h=l.map(r_),p=(i=Math.max(0,48-(n={x:Math.min(...(r=rY(t=[...f,...l,...h])).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[rq(n,t,r),...i.map(e=>rq(e,t,r))]}(e.points,i,a)}:{...e,x:e.x+i,y:e.y+a})),m={width:Math.max(...(s=rY(p)).map(e=>e.x))+48,height:Math.max(...s.map(e=>e.y))+48};return{diagramId:o.id,title:o.title,width:m.width,height:m.height,accentColor:o.style.accentColor,backgroundColor:o.style.backgroundColor,elements:p}}let rW="sequence-lifeline";function rJ(e){return`${e}:lifeline`}var rz=r(1580);let rK=new Set(["rectangle","ellipse","diamond"]);function rV(e){return"number"==typeof e&&Number.isFinite(e)?e:null}function rG(e){if(!Array.isArray(e)||e.length<2)return null;let t=rV(e[0]),r=rV(e[1]);return null===t||null===r?null:[t,r]}function rH(e){let t=rV(e.x),r=rV(e.y),n=rV(e.width),i=rV(e.height);return null===t||null===r||null===n||null===i?null:{x:t,y:r,width:n,height:i}}function rQ(e){return 1e-4>Math.abs(e-.5)?.5001:e}function rZ(e,t){let r;return{elementId:e?.id??"",focus:0,gap:0,fixedPoint:e?(r=rH(e))&&0!==r.width&&0!==r.height?[rQ((t.x-r.x)/r.width),rQ((t.y-r.y)/r.height)]:null:null}}function r0(e,t){let r=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:"solid",frameId:null,groupIds:[],index:t,isDeleted:!1,link:null,locked:!1,opacity:100,roughness:1,seed:r,strokeStyle:"solid",strokeWidth:2,updated:1,version:1,versionNonce:r+1}}function r1(e,t){return Math.ceil(e.split("\n").length*t*1.35)}function r2(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=r1(e.text,e.fontSize);return{...r0(e.id,e.index),type:"text",x:e.x-n/2,y:e.y-i/2,width:n,height:i,backgroundColor:"transparent",boundElements:null,containerId:e.containerId,fontFamily:5,fontSize:e.fontSize,lineHeight:1.35,originalText:e.text,roundness:null,strokeColor:e.textColor??"#1e1e1e",text:e.text,textAlign:"center",verticalAlign:"middle",autoResize:!0}}function r3(e){return e.points[e.points.length-1]??e.points[0]}function r5(e){return"node"===e.type}function r6(e){return"text"===e.type}function r8(e){return"arrow"===e.type}function r4(e){let t=e.elements.filter(r5),r=new Map(e.elements.filter(r6).map(e=>[e.containerId??"",e])),n=e.elements.filter(r8),i=function(e){let t=new Map;for(let r of e)for(let e of[r.sourceNodeId,r.targetNodeId]){let n=`node:${e}`;t.set(n,[...t.get(n)??[],r.id])}return t}(n),a=new Map,s=[],o=null,l=()=>{let e=(0,rz.TU)(o,null);return o=e,e};for(let n of t){let t=r.get(n.id),o=function(e){let t=e.text?r1(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?[{id:e.text.id,type:"text"}]:[],...e.arrowIds.map(e=>({id:e,type:"arrow"}))];return{...r0(e.shape.id,e.index),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===rW?{customData:{sketchiRendererRole:rW}}:{}}}({scene:e,shape:n,arrowIds:i.get(n.id)??[],index:l(),...t?{text:t}:{}});a.set(n.nodeId,o),s.push(o)}for(let t of e.elements.filter(r6))t.containerId&&s.push(r2({id:t.id,index:l(),containerId:t.containerId,fontSize:t.fontSize,maxWidth:t.maxWidth??160,...t.textColor?{textColor:t.textColor}:{},text:t.text,x:t.x,y:t.y}));for(let t of n){s.push(function(e){let t=e.arrow.points[0],r=r3(e.arrow),n=e.arrow.points.length>2;return{...r0(e.arrow.id,e.index),type:"arrow",x:t.x,y:t.y,width:r.x-t.x,height:r.y-t.y,backgroundColor:"transparent",boundElements:e.arrow.label?[{id:`${e.arrow.id}:label`,type:"text"}]:null,elbowed:n,endArrowhead:"arrow",endBinding:rZ(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:null,startBinding:rZ(e.sourceShape,t),strokeColor:e.arrow.strokeColor??e.scene.accentColor,strokeStyle:e.arrow.strokeStyle??"solid"}}({arrow:t,scene:e,index:l(),sourceShape:a.get(t.sourceNodeId),targetShape:a.get(t.targetNodeId)}));let r=t.label?function(e){if(!e.arrow.label)return null;let t=e.arrow.points[0],r=r3(e.arrow);return r2({id:`${e.arrow.id}:label`,index:e.index,containerId:e.arrow.id,fontSize:13,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:l()}):null;r&&s.push(r)}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:s}}function r9(e,t){let r=e[t];if(!(r&&"object"==typeof r))return null;let n=r.elementId;return"string"==typeof n?n:null}function r7(e){return rG(e)}function ne(e){let t=rV(e.x)??0,r=rV(e.y)??0,n=r9(e,"startBinding"),i=r9(e,"endBinding"),a=Array.isArray(e.points)?e.points.map(r7).filter(e=>!!e):[],s=[];for(let o=0;o<a.length-1;o+=1){let l=a[o],c=a[o+1];if(!l||!c)continue;let[u,d]=l,[f,h]=c,p=t+u,m=r+d,g=t+f,y=r+h;if(.001>=Math.abs(m-y)){s.push({arrowId:e.id,endBindingElementId:i,isLastSegment:o===a.length-2,max:Math.max(p,g),min:Math.min(p,g),orientation:"horizontal",segmentIndex:o,startBindingElementId:n,staticCoordinate:m});continue}.001>=Math.abs(p-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:p})}return s.filter(e=>e.max-e.min>.001)}function nt(e,t,r){return e>t+.01&&e<r-.01}function nr(e,t,r,n){return Math.min(t,n)-Math.max(e,r)>.01}function nn(e,t,r){return e>=t-.01&&e<=r+.01}function ni(e,t){return .01>=Math.abs(e-t)}function na(e){let t=[],r=new Map(e.elements.map(e=>[e.id,e])),n=new Set(e.elements.filter(e=>rK.has(e.type)).map(e=>e.id));for(let i of(0===n.size&&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"])){let s=r9(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=rV(e.x)??0,n=rV(e.y)??0,i=Array.isArray(e.points)?e.points.map(r7).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=rH(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 ni(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 ni(((e.x-i)/t)**2+((e.y-a)/n)**2,1)}let n=(ni(e.x,r.x)||ni(e.x,r.x+r.width))&&nn(e.y,r.y,r.y+r.height),i=(ni(e.y,r.y)||ni(e.y,r.y+r.height))&&nn(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?rG(r.fixedPoint):null}(i,a);e&&function(e,t,r){let n=rH(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 ni(n.x+i*n.width,t.x)&&ni(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;rK.has(n.type)&&(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(ne),r=e.filter(e=>rK.has(e.type)),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===rW}(t)||t.id===e.startBindingElementId||t.id===e.endBindingElementId)continue;let r=rH(t);if(!r||("horizontal"===e.orientation?!(nt(e.staticCoordinate,r.y,r.y+r.height)&&nr(e.min,e.max,r.x,r.x+r.width)):!(nt(e.staticCoordinate,r.x,r.x+r.width)&&nr(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(ne),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 ns=r(8927);r(2302);var no=r(4650),nl=r(1136),nc=r(9354),nu=r(6364),nd=r(9138),nf=r(5369);let nh=a.Or("effect/Metric/CurrentMetricAttributes",{defaultValue:()=>({})}),np=a.Or("~effect/observability/Metric/MetricRegistryKey",{defaultValue:()=>new Map}),nm="~effect/observability/Metric";class ng{[nm]=nm;#e=new WeakMap;#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){let t=a.Jt(e,nh);if(0===Object.keys(t).length)return nf.EA(this.#t)||(this.#t=this.getOrCreate(e,this.attributes)),this.#t.hooks;let r=nS(this.attributes,t),n=this.#e.get(r);return nf.EA(n)||(n=this.getOrCreate(e,r),this.#e.set(r,n)),n.hooks}getOrCreate(e,t){var r,n,i;let s,o=(r=this,n=t,s=`${r.type}:${r.id}`,nf.EA(r.description)&&(s+=`:${r.description}`),nf.EA(n)&&(s+=`:${(Array.isArray(i=n)?i:Object.entries(i)).map(([e,t])=>`${e}=${t}`).join(",")}`),s),l=a.Jt(e,np);if(l.has(o))return l.get(o);let c=this.createHooks(),u={id:this.id,type:this.type,description:this.description,attributes:nO(t),hooks:c};return l.set(o,u),u}pipe(){return(0,nd.tT)(this,arguments)}}let ny=BigInt(0);class nb extends ng{type="Counter";#r;#n;constructor(e,t){super(e,t?.description,nO(t?.attributes)),this.#r=t?.bigint??!1,this.#n=t?.incremental??!1}createHooks(){let e=this.#r?ny:0,t=this.#n?this.#r?e=>e>=ny:e=>e>=0:e=>!0;return nk(()=>({count:e,incremental:this.#n}),r=>{t(r)&&(e+=r)})}}class nv extends ng{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 nw=(e,t)=>new nb(e,t),nx=(0,no.XY)(2,(e,t)=>nl.sxi(r=>nl.OH5(()=>e.updateUnsafe(t,r)))),n_=(0,no.XY)(2,(e,t)=>new nv(e,r=>e.valueUnsafe(nE(r,t)),(r,n)=>e.updateUnsafe(r,nE(n,t)),(r,n)=>e.modifyUnsafe(r,nE(n,t))));function nk(e,t,r){return{get:e,update:t,modify:r??t}}function nS(e,t){return{...nO(e),...nO(t)}}function nO(e){return nf.EA(e)&&Array.isArray(e)?e.reduce((e,[t,r])=>(e[t]=r,e),{}):e}function nE(e,t){let r=nS(a.Jt(e,nh),t);return a.WQ(e,nh,r)}nc.F,nc.F,no.MN,r(7598),r(8543);var n$=r(755);[...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 nI={metric:()=>void 0},nA=a.Or("@sketchi/observability/TelemetryExporter",{defaultValue:()=>nI}),nC=a.Or("@sketchi/observability/TelemetryCorrelation",{defaultValue:()=>({})});function nT(e){let t=e?.trim();if(t&&!(t.length>128)&&/^[A-Za-z0-9][A-Za-z0-9._:-]*$/.test(t))return t}function nN(e){let t=nT(e.artifactId),r=nT(e.attemptId),n=nT(e.projectId),i=nT(e.requestId),a=nT(e.runId),s=nT(e.scenarioId),o=nT(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 nM(e,t){return s.JkU(function*(){let r=nN({...yield*nC,...nN(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(nC,r),s.Muk(n),s.swY(n))})}a.Or("@sketchi/observability/TelemetryResource",{defaultValue:()=>({serviceName:"sketchi"})});let nP=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=nT(n);t&&(r[e]=t)}return r}(r);yield*nx(n_(e,n),t);let i=yield*nA,a=d.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}))});n$.W1;let nj=/^(node|step|item|box|thing|process|task)\s*\d*$/i,nD=/^(diagram|untitled|flowchart|chart|sketch)$/i;function nU(e){return"decision"===e.kind||e.label.endsWith("?")}function nF(e){if(void 0===e)return;let t=g(e);return t.length>0?t:void 0}let nR=["excalidraw","scene"],nL=["scene"],nB=nw("sketchi_codemode_requests",{description:"Code Mode boundary requests by terminal outcome",incremental:!0}),nY=nw("sketchi_codemode_failures",{description:"Code Mode boundary failures by typed status",incremental:!0}),nq=nw("sketchi_codemode_artifacts",{description:"Code Mode artifacts accepted at workflow boundaries",incremental:!0}),nX=new class e extends ng{type="Histogram";#i;constructor(e,t){super(e,t?.description,nO(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=5e-324;return ns.Tj(ns.di(e,nu.wN),(e,t)=>{n[t]=e}),nk(()=>({buckets:(()=>{let e=ns.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,c=t;for(;l!==c;){let t=Math.floor(l+(c-l)/2);e<=n[t]?c=t:l=t,c===l+1&&(e<=n[l]?c=l:l=c)}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],ns.BC(ns.pb(new Set(n),e=>e>0),1/0))});class nW extends a.kl()("@sketchi/diagram-agent/CodeModeRuntimeEnvironment"){}function nJ(e={}){return l.Py(nW,{createId:e.createId??n1,...e.renderer?{renderer:e.renderer}:{},...e.artifactUrl?{artifactUrl:e.artifactUrl}:{}})}function nz(e){return null===e||"object"!=typeof e||Array.isArray(e)?void 0:Object.fromEntries(Object.entries(e))}function nK(e,t,r){let n,i,a,l;return nM(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*nP(nB,1,{...s?{failureCategory:s}:{},operation:e,outcome:a,surface:"code_mode"}),yield*nP(nX,i-t,{...s?{failureCategory:s}:{},operation:e,outcome:a,surface:"code_mode"}),s&&(yield*nP(nY,1,{failureCategory:s,operation:e,surface:"code_mode"}));let l="buildFlowchart"===e?"flowchart":"buildMindmap"===e?"mindmap":"buildSequenceDiagram"===e?"sequence":"applyDiagramPatch"===e?"patch":void 0;return n.ok&&l&&(yield*nP(nq,1,{artifactKind:l,operation:e,surface:"code_mode"})),n}),(n=nz(t),i=nz(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(nW,{createId:n1});class nV extends i.X0d()("CodeModeArtifactExportError",{cause:i.kld(),message:i.QfV,optionPath:i.v8c}){}class nG extends i.X0d()("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 nH extends i.X0d()("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 nQ extends i.X0d()("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 nZ extends i.X0d()("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 n0 extends i.X0d()("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 n1(e){return`${e}_${globalThis.crypto.randomUUID()}`}function n2(e){return{code:e.code,severity:e.severity??"error",stage:e.stage,...e.ref?{ref:e.ref}:{},message:e.message,hint:e.hint}}function n3(e){return 0===e.length?"input":e.map(e=>"number"==typeof e?`[${e}]`:String(e)).join(".")}function n5(e){let t=n3(e.path);return n6(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 n6(e){return/^operations\.\[\d+\]\.op$/.test(e)}function n8(e){let t=e.issues.slice(0,20).map(e=>{let t=n3(e.path);return n2({code:n5(e),stage:"input",ref:{kind:"request",path:t},message:e.message,hint:n6(t)?`Use one of: ${et.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(n2({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 n4(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)}function n9(e){if(void 0===e)return;let t=g(e);return t.length>0?t:void 0}function n7(e){return e.checks.map(e=>{var t;return n2({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 ie(e){return e?.artifactFormats??nR}function it(e){return e?.inlineArtifacts??nL}let ir=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=>nV.make({cause:e,message:e instanceof Error?e.message:"Artifact export failed.",optionPath:!1}))):s.fJG(nV.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:tD[a],data:o,sizeBytes:(i=o)instanceof ArrayBuffer||i instanceof Uint8Array?i.byteLength:tL(i)})}return t});function ii(e){return[n2({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 ia(e){return e.map(e=>n2({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 is(e){return structuredClone(e)}function io(e){return e.elements.filter(e=>"arrow"===e.type).map(e=>`${e.edgeId}:${e.sourceNodeId}->${e.targetNodeId}`).sort()}function il(e){return e.elements.filter(e=>"node"===e.type)}function ic(e){return e.elements.filter(e=>"text"===e.type)}function iu(e){return e.elements.filter(e=>"arrow"===e.type)}function id(e,t){if(!e||0===e.length||!t)return!1;let r=t.trim().toLowerCase();return e.some(e=>e.trim().toLowerCase()===r)}function ih(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=il(e).filter(e=>"edges"!==r&&(!t||!n||i.has(e.id)||a.has(e.nodeId)||!!e.kind&&[...o].some(t=>t===e.kind)||id(t.labels,e.label))),c=iu(e).filter(e=>"nodes"!==r&&(!t||!n||i.has(e.id)||s.has(e.edgeId)||id(t.labels,e.label))),u=new Set(l.map(e=>e.id)),d=new Set(c.map(e=>e.id));return{arrows:c,nodes:l,texts:ic(e).filter(e=>t&&n?i.has(e.id)||!!e.containerId&&u.has(e.containerId)||!!e.containerId&&d.has(e.containerId)||id(t.labels,e.text):"nodes"===r?!!e.containerId&&u.has(e.containerId):"edges"!==r||!!e.containerId&&d.has(e.containerId))}}function ip(e){return n2({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 im(e,t){return ic(e).find(e=>e.containerId===t)}function ig(e,t){let r=new Set(t);for(let t of iu(e))(r.has(t.sourceNodeId)||r.has(t.targetNodeId))&&iv(e,t)}function iy(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}function ib(e,t,r){let n=iy(e),i=iy(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 iv(e,t){let r,n,i=new Map(il(e).map(e=>[e.nodeId,e])),a=i.get(t.sourceNodeId),s=i.get(t.targetNodeId);if(!a||!s)return[n2({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=ib(a,s,!0),l=ib(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=im(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),[]}let iw=s.fn("codeMode.patch.resolveSource")(function*(e){if("scene"in e.source)return{scene:is(e.source.scene)};let t=yield*tj,r=yield*t.readManifest(e.source.artifactId).pipe(s.xm_(e=>new n0({status:"storage_failed",context:{issues:[tq(e.message,"storage_read_failed")]}})));if(!r||r.artifactId!==e.source.artifactId||!r.formats.some(e=>"scene"===e.format))return yield*new n0({status:"source_unavailable",context:{issues:[n2({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 n0({status:"storage_failed",context:{issues:[tq(e.message,"storage_read_failed")]}})));if(!n)return yield*new n0({status:"source_unavailable",context:{issues:[n2({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=e0.safeParse(n.data);return i.success?{scene:is(i.data),sourceArtifactId:e.source.artifactId}:yield*new n0({status:"source_unavailable",context:{issues:[n2({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 ix(e){return e?{requestId:e}:{}}function i_(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 ik(e){return{diagramId:e.diagramId,formats:[{format:"scene",mimeType:tD.scene,inline:e,sizeBytes:tL(e)}]}}function iS(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 iO(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 iE(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 i$(e){return{ok:!1,status:e.status,issues:e.issues}}function iI(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 iA(e,t){return tq(e.message,t)}let iC=s.fn("codeMode.buildMindmap.workflow")(function*(e){let t=yield*s.OH5(()=>(function(e){let t=nz(nz(nz(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[n2({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[n2({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=nz(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 nH({status:"invalid_mindmap",context:{issues:t}});let r=yield*s.OH5(()=>ez.safeParse(e)).pipe(s.fRP("codeMode.buildMindmap.parse"));if(!r.success)return yield*new nH({status:"invalid_input",context:{issues:n8(r.error)}});let n=yield*nW,i=yield*tj,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:g(e.label),children:(e.children??[]).map((e,n)=>t(e,[...r,n]))}),r=g(e.title),{id:n9(e.id)??(n4(r)||"sketchi-mindmap"),title:r,root:t(e.root,[0]),layout:{direction:e.layout.direction},style:e.style}}).pipe(s.fRP("codeMode.buildMindmap.normalize")),c={buildId:o,...ix(a.requestId),normalizedSpec:l},u=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(n2({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(n2({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(n2({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(u.length>0)return yield*new nH({status:"invalid_mindmap",context:{...c,issues:u}});let d=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),rv({id:l.id,title:l.title,type:"mindmap",nodes:e,edges:t,layout:{direction:l.layout.direction,edgeRouting:"curved"},style:l.style})},catch:e=>new nH({status:"invalid_mindmap",context:{...c,issues:[n2({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=d.nodes.filter(e=>/^(topic|branch|item|mindmap)$/i.test(e.label.trim()))).length))>=e,score:r,threshold:e,summary:{nodeCount:d.nodes.length,edgeCount:d.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")),h={...c,quality:f};if(!f.accepted)return yield*new nH({status:"quality_failed",context:{...h,issues:n7(f)}});let p=yield*s.SvU({try:()=>rX(d),catch:e=>new nH({status:"render_failed",context:{...h,issues:[n2({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=r4(p);return{excalidraw:e,exportValidation:na(e)}}).pipe(s.fRP("codeMode.buildMindmap.exportValidate")),b={...h,partial:ik(p)};if(!y.ok)return yield*new nH({status:"export_failed",context:{...b,issues:ia(y.issues)}});let v=yield*ir({formats:ie(a.options),scene:p,excalidraw:m,renderer:n.renderer}).pipe(s.xm_(e=>new nH({status:"export_failed",context:{...b,issues:ii(e)}}))),w=yield*s.OH5(()=>n.createId("artifact")),x=yield*nM(i.write({artifactId:w,diagramId:p.diagramId,formats:v,inlineFormats:it(a.options)}),{artifactId:w,...a.requestId?{requestId:a.requestId}:{}}).pipe(s.xm_(e=>new nH({status:"storage_failed",context:{...h,partial:{diagramId:p.diagramId},issues:[iA(e,"storage_write_failed")]}})));return{ok:!0,status:"accepted",buildId:o,...ix(a.requestId),normalizedSpec:l,quality:f,artifact:i_(x,n.artifactUrl),issues:[]}}),iT=s.fn("codeMode.buildSequenceDiagram.workflow")(function*(e){yield*s.rIH.pipe(s.fRP("codeMode.buildSequenceDiagram.preflight"));let t=yield*s.OH5(()=>ej.safeParse(e)).pipe(s.fRP("codeMode.buildSequenceDiagram.parse"));if(!t.success)return yield*new nQ({status:"invalid_input",context:{issues:n8(t.error)}});let r=yield*nW,n=yield*tj,i=t.data,a=yield*s.OH5(()=>r.createId("build")),o=yield*s.OH5(()=>{var e;let t;return t=g((e=i.spec).title),{id:n9(e.id)??(n4(t)||"sketchi-sequence"),title:t,participants:e.participants.map(e=>({id:g(e.id),label:g(e.label),...e.kind?{kind:g(e.kind)}:{}})),messages:e.messages.map((e,t)=>({id:n9(e.id)??`message-${t+1}-${n4(e.source)}-${n4(e.target)}`,source:g(e.source),target:g(e.target),label:g(e.label),...e.type?{type:e.type}:{},...e.style?{style:e.style}:{}})),style:e.style}}).pipe(s.fRP("codeMode.buildSequenceDiagram.normalize")),l={buildId:a,...ix(i.requestId),normalizedSpec:o},c=yield*s.OH5(()=>{let e,t,r,n;return e=[],t=new Set,o.participants.forEach((r,n)=>{t.has(r.id)&&e.push(n2({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=rJ(t.id),i=r.get(n);void 0!==i&&e.push(n2({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(n2({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(n2({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(n2({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(n2({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(c.length>0)return yield*new nQ({status:"invalid_sequence",context:{...l,issues:c}});let u=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")),d={...l,quality:u};if(!u.accepted)return yield*new nQ({status:"quality_failed",context:{...d,issues:n7(u)}});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=rJ(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,c=l+90;n.set(t.id,c),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:c,y:84,text:t.label,fontSize:14,maxWidth:156}),s.push({type:"node",id:`node:${rJ(t.id)}`,nodeId:rJ(t.id),rendererRole:rW,shape:"rectangle",fillColor:e.style.backgroundColor,strokeColor:e.style.accentColor,x:c-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:rJ(e.source),targetNodeId:rJ(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}});return{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:[...o,...s,...i,...a]}})(o),catch:e=>new nQ({status:"render_failed",context:{...d,issues:[n2({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:h,validation:p}=yield*s.OH5(()=>{let e=r4(f);return{excalidraw:e,validation:na(e)}}).pipe(s.fRP("codeMode.buildSequenceDiagram.exportValidate")),m={...d,partial:ik(f)};if(!p.ok)return yield*new nQ({status:"export_failed",context:{...m,issues:ia(p.issues)}});let y=yield*ir({formats:ie(i.options),scene:f,excalidraw:h,renderer:r.renderer}).pipe(s.xm_(e=>new nQ({status:"export_failed",context:{...m,issues:ii(e)}}))),b=yield*s.OH5(()=>r.createId("artifact")),v=yield*nM(n.write({artifactId:b,diagramId:f.diagramId,formats:y,inlineFormats:it(i.options)}),{artifactId:b,...i.requestId?{requestId:i.requestId}:{}}).pipe(s.xm_(e=>new nQ({status:"storage_failed",context:{...d,issues:[iA(e,"storage_write_failed")]}})));return{ok:!0,status:"accepted",buildId:a,...ix(i.requestId),normalizedSpec:o,quality:u,artifact:i_(v,r.artifactUrl),issues:[]}}),iN=s.fn("codeMode.buildFlowchart.workflow")(function*(e){let t=yield*s.OH5(()=>eM.safeParse(e)).pipe(s.fRP("codeMode.buildFlowchart.parse"));if(!t.success)return yield*new nG({status:"invalid_input",context:{issues:n8(t.error)}});let r=yield*nW,n=yield*tj,i=t.data,a=ie(i.options),o=yield*s.OH5(()=>r.createId("build")),l=yield*s.OH5(()=>{var e;let t;return t=g((e=i.spec).title),{id:nF(e.id)??(t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"sketchi-flowchart"),title:t,nodes:e.nodes.map(e=>({id:g(e.id),label:g(e.label),kind:e.kind,...e.description?{description:g(e.description)}:{}})),edges:e.edges.map((e,t)=>({id:nF(e.id)??`edge-${t+1}`,source:g(e.source),target:g(e.target),...e.label?{label:g(e.label)}:{}})),layout:{direction:e.layout.direction},style:{accentColor:e.style.accentColor,backgroundColor:e.style.backgroundColor}}}).pipe(s.fRP("codeMode.buildFlowchart.normalize")),c={buildId:o,...ix(i.requestId),normalizedSpec:l},u=yield*s.OH5(()=>rs.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(!u.success){var d;return yield*new nG({status:"invalid_flowchart",context:{...c,issues:(d=u.error,d.issues.slice(0,20).map(e=>{let t=function(e,t){let r=n3(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 n2({code:n5(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,h=yield*s.OH5(()=>rc(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 n2({code:e.code,stage:"flowchart",...t?{ref:t}:{},message:e.message,hint:e.hint})})).pipe(s.fRP("codeMode.buildFlowchart.validate"));if(h.length>0)return yield*new nG({status:"invalid_flowchart",context:{...c,issues:h}});yield*s.OH5(()=>rd(f)).pipe(s.fRP("codeMode.buildFlowchart.assertValid"));let p=yield*s.OH5(()=>(function(e,t){let r=[],n=0,i=(e,t,i=!1)=>{n+=e,r.push({severity:i?"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",!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(", ")}`,!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`,!0)}e.nodes.length<3?i(2,"too sparse — a useful flow needs at least 3 nodes"):e.nodes.length>24&&i(2,"too dense — trim or merge nodes (24 max)");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(", ")}`);let c=0,u=0;for(let t of e.nodes.filter(nU)){let e=s.get(t.id)??[];e.length<2?(c+=1,r.push({severity:"error",message:`decision "${t.id}" needs at least 2 outgoing branches`})):e.some(e=>!e.label)&&(u+=1,r.push({severity:"warning",message:`label every branch out of decision "${t.id}" (yes/no, …)`}))}n+=Math.min(1.5*c,4.5)+Math.min(u,3);let d=e.nodes.filter(e=>e.label.length>42);d.length>0&&i(Math.min(.5*d.length,2),`shorten label(s): ${d.map(e=>e.id).join(", ")}`);let f=e.nodes.filter(e=>nj.test(e.label.trim()));f.length>0&&i(Math.min(f.length,3),`generic label(s) say nothing: ${f.map(e=>`"${e.label}"`).join(", ")}`),(e.title.trim().length<4||nD.test(e.title.trim()))&&i(.5,"give the diagram a specific title");let h=Math.max(0,Math.round((10-n)*10)/10),p=r.map(e=>{var t;return{code:(t=e.message).includes("generic label")?"generic_label":t.includes("shorten label")?"label_too_long":t.includes("disconnected")?"disconnected_graph":"quality_below_threshold",passed:!1,severity:e.severity,message:e.message,refs:[]}});return{accepted:h>=t&&!p.some(e=>"error"===e.severity),score:h,threshold:t,summary:{nodeCount:e.nodes.length,edgeCount:e.edges.length},checks:p}})(f,i.options?.minQualityScore??8)).pipe(s.fRP("codeMode.buildFlowchart.quality")),m={...c,quality:p};if(!p.accepted)return yield*new nG({status:"quality_failed",context:{...m,issues:n7(p)}});let y=yield*s.SvU({try:()=>rX(f),catch:e=>new nG({status:"render_failed",context:{...m,issues:[n2({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=r4(y);return{excalidraw:e,validation:na(e)}}).pipe(s.fRP("codeMode.buildFlowchart.exportValidate")),w={...m,partial:ik(y)};if(!v.ok)return yield*new nG({status:"export_failed",context:{...w,issues:ia(v.issues)}});let x=yield*ir({formats:a,scene:y,excalidraw:b,renderer:r.renderer}).pipe(s.xm_(e=>new nG({status:"export_failed",context:{...w,issues:ii(e)}}))),_=yield*s.OH5(()=>r.createId("artifact")),k=yield*nM(n.write({artifactId:_,diagramId:y.diagramId,formats:x,inlineFormats:it(i.options)}),{artifactId:_,...i.requestId?{requestId:i.requestId}:{}}).pipe(s.xm_(e=>new nG({status:"storage_failed",context:{...m,issues:[iA(e,"storage_write_failed")]}})));return{ok:!0,status:"accepted",buildId:o,...ix(i.requestId),normalizedSpec:l,quality:p,artifact:i_(k,r.artifactUrl),issues:[]}}),iM=s.fn("codeMode.getArtifact.workflow")(function*(e){let t=yield*s.OH5(()=>e8.safeParse(e)).pipe(s.fRP("codeMode.getArtifact.parse"));if(!t.success)return yield*new nZ({status:"invalid_input",issues:n8(t.error)});let r=yield*nW,n=yield*tj,i=t.data,a=yield*n.readManifest(i.artifactId).pipe(s.xm_(e=>new nZ({status:"storage_failed",issues:[iA(e,"storage_read_failed")]})));if(!a)return yield*new nZ({status:"not_found",issues:[n2({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 nZ({status:"format_unavailable",issues:[n2({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 nZ({status:"storage_failed",issues:[iA(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||!tU(o)?{}:{inline:l.data},sizeBytes:l.sizeBytes,...a.provenance?{provenance:a.provenance}:{}}:yield*new nZ({status:"format_unavailable",issues:[n2({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."})]})}),iP=s.fn("codeMode.applyDiagramPatch.workflow")(function*(e){let t=yield*s.OH5(()=>th.safeParse(e)).pipe(s.fRP("codeMode.applyDiagramPatch.parse"));if(!t.success)return yield*new n0({status:"invalid_input",context:{issues:n8(t.error)}});let r=yield*nW,n=yield*tj,i=t.data,a=yield*s.OH5(()=>r.createId("patch")),o={patchId:a,...ix(i.requestId)},l=ie(i.options),c=yield*iw(i).pipe(s.xm_(e=>new n0({status:e.status,context:{...o,...e.context}}))),u={...o,...c.sourceArtifactId?{sourceArtifactId:c.sourceArtifactId}:{}},d=c.scene,f=io(d),h=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),il(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 iu(e))t.style.strokeColor&&(r.strokeColor=t.style.strokeColor),t.style.textColor&&(r.textColor=t.style.textColor);for(let r of ic(e))t.style.textColor&&(r.textColor=t.style.textColor);return[]}let r=ih(e,t.selector);if(0===r.nodes.length&&0===r.arrows.length&&0===r.texts.length)return[ip(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=im(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=im(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=ih(e,t.selector);if(0===n.nodes.length)return[ip(t)];let i=[];for(let r of n.nodes){if(r.shape=t.shape,"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=im(e,t.id);r&&(r.x=t.x+t.width/2,r.y=t.y+t.height/2)}(e,r)}return ig(e,i),[];case"translate":return function(e,t){let r=ih(e,t.selector);if(0===r.nodes.length&&0===r.arrows.length&&0===r.texts.length)return[ip(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=im(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=im(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 ig(e,[...n]),function(e){let t=[e.width],r=[e.height];for(let n of il(e))t.push(n.x+n.width),r.push(n.y+n.height);for(let n of ic(e))t.push(n.x+(n.maxWidth??0)),r.push(n.y+n.fontSize);for(let n of iu(e))for(let e of n.points)t.push(e.x),r.push(e.y);e.width=Math.max(...t)+48,e.height=Math.max(...r)+48}(e),[]}(e,t);case"replaceText":let a=ih(e,t.selector);if(0===a.nodes.length&&0===a.arrows.length&&0===a.texts.length)return[ip(t)];for(let r of a.nodes){r.label=t.text;let n=im(e,r.id);n&&(n.text=t.text)}for(let r of a.arrows){r.label=t.text;let n=im(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=ih(e,t.selector)).arrows.length?[ip(t)]:s.arrows.flatMap(t=>iv(e,t))}}(d,e);if(t.length>0)return t}return[]}).pipe(s.fRP("codeMode.applyDiagramPatch.operations"));if(h.length>0)return yield*new n0({status:h[0]?.code==="unknown_patch_target"?"target_not_found":"unsupported_operation",context:{...u,issues:h}});if(i.options?.preserveConnectivity!==!1){let e=io(d);if(!(f.length===e.length&&f.every((t,r)=>t===e[r])))return yield*new n0({status:"connectivity_changed",context:{...u,issues:[n2({code:"patch_preserve_connectivity_failed",stage:"flowchart",ref:{kind:"diagram",id:d.diagramId},message:"Patch changed the diagram edge connectivity.",hint:"Use buildFlowchart for process-graph structure or buildMindmap for hierarchy structure."})]}})}let p=yield*s.OH5(()=>(function(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({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){t.push({type:"node",id:r.id,nodeId:r.nodeId,...r.kind?{kind:r.kind}:{},..."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}:{},shape:r.shape,...r.fillColor?{fillColor:r.fillColor}:{},...r.strokeColor?{strokeColor:r.strokeColor}:{},...r.textColor?{textColor:r.textColor}:{},x:r.x,y:r.y,width:r.width,height:r.height,label:r.label});continue}t.push({type:"text",id:r.id,...r.containerId?{containerId:r.containerId}:{},...r.textColor?{textColor:r.textColor}:{},x:r.x,y:r.y,text:r.text,fontSize:r.fontSize,...r.maxWidth?{maxWidth:r.maxWidth}:{}})}return{diagramId:e.diagramId,title:e.title,width:e.width,height:e.height,accentColor:e.accentColor,backgroundColor:e.backgroundColor,elements:t}})(d)).pipe(s.fRP("codeMode.applyDiagramPatch.normalize"));if(!p)return yield*new n0({status:"render_failed",context:{...u,issues:[n2({code:"patch_output_invalid",stage:"render",ref:{kind:"diagram",id:d.diagramId},message:"Patched scene has an invalid arrow point list.",hint:"Reroute edges or rebuild the flowchart artifact."})]}});let{excalidraw:m,validation:g}=yield*s.OH5(()=>{let e=r4(p);return{excalidraw:e,validation:na(e)}}).pipe(s.fRP("codeMode.applyDiagramPatch.exportValidate")),y={...u,partial:ik(p)};if(!g.ok)return yield*new n0({status:"export_failed",context:{...y,issues:ia(g.issues)}});let b=yield*ir({formats:l,scene:p,excalidraw:m,renderer:r.renderer}).pipe(s.xm_(e=>new n0({status:"export_failed",context:{...y,issues:ii(e)}}))),v=yield*s.OH5(()=>r.createId("artifact")),w=yield*nM(n.write({artifactId:v,diagramId:p.diagramId,formats:b,inlineFormats:it(i.options),...c.sourceArtifactId?{provenance:{sourceArtifactId:c.sourceArtifactId}}:{}}),{artifactId:v,...i.requestId?{requestId:i.requestId}:{}}).pipe(s.xm_(e=>new n0({status:"storage_failed",context:{...u,issues:[iA(e,"storage_write_failed")]}})));return{ok:!0,status:"accepted",patchId:a,...ix(i.requestId),...c.sourceArtifactId?{sourceArtifactId:c.sourceArtifactId}:{},artifact:i_(w,r.artifactUrl),issues:[]}});function ij(e,t){return e.pipe(s.YWq({onFailure:t,onSuccess:e=>e}))}let iD=s.fn("codeMode.buildFlowchart")(e=>nK("buildFlowchart",e,ij(iN(e),iS))),iU=s.fn("codeMode.buildMindmap")(e=>nK("buildMindmap",e,ij(iC(e),iO)));s.fn("codeMode.buildSequenceDiagram")(e=>nK("buildSequenceDiagram",e,ij(iT(e),iE))),s.fn("codeMode.getArtifact")(e=>nK("getArtifact",e,ij(iM(e),i$)));let iF=s.fn("codeMode.applyDiagramPatch")(e=>nK("applyDiagramPatch",e,ij(iP(e),iI)))}},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,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+"."+({831:"bdee8e123d2a353d",869:"1a34851ea988ddca"})[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(5947);
|
|
174
|
+
${t}}`),n},ed="~effect/Fiber/dev",ef={_A:f.D_,_E:f.D_},eh={id:0},ep=()=>globalThis[w.fL];class em{constructor(e,t=!0){this[ed]=ef,this.setContext(e),this.id=++eh.id,this.currentOpCount=0,this.currentLoopCount=0,this.interruptible=t,this._stack=[],this._observers=[],this._exit=void 0,this._children=void 0,this._interruptedCause=void 0,this._yielded=void 0,this.runtimeMetrics?.recordFiberStart(this.context)}[ed];id;interruptible;currentOpCount;currentLoopCount;_stack;_observers;_exit;_currentExit;_children;_interruptedCause;_yielded;context;currentScheduler;currentTracerContext;currentSpan;currentLogLevel;minimumLogLevel;currentStackFrame;runtimeMetrics;maxOpsBeforeYield;currentPreventYield;_dispatcher=void 0;get currentDispatcher(){return this._dispatcher??=this.currentScheduler.makeDispatcher()}getRef(e){return o.kA(this.context,e)}addObserver(e){return this._exit?(e(this._exit),f.Yi):(this._observers.push(e),()=>{let t=this._observers.indexOf(e);t>=0&&this._observers.splice(t,1)})}interruptUnsafe(e,t){if(this._exit)return;let r=j(e);this.currentStackFrame&&(r=(0,$.Eh)(r,o.L8($.z8,this.currentStackFrame))),t&&(r=(0,$.Eh)(r,t)),this._interruptedCause=this._interruptedCause?H(this._interruptedCause,r):r,this.interruptible&&this.evaluate(eI(this._interruptedCause))}pollUnsafe(){return this._exit}evaluate(e){if(this._exit)return;if(void 0!==this._yielded){let e=this._yielded;this._yielded=void 0,e()}let t=this.runLoop(e);if(t===$.GN)return;let r=eg.interruptChildren&&eg.interruptChildren(this);if(void 0!==r)return this.evaluate(tu(r,()=>t));this._exit=t,this.runtimeMetrics?.recordFiberEnd(this.context,this._exit);for(let e=0;e<this._observers.length;e++)this._observers[e](t);this._observers.length=0}runLoop(e){let t=globalThis[w.fL];globalThis[w.fL]=this;let r=!1,n=e;this.currentOpCount=0;let i=++this.currentLoopCount;try{for(;;){if(this.currentOpCount++,!r&&!this.currentPreventYield&&this.currentScheduler.shouldYield(this)){r=!0;let e=n;n=tu(eD,()=>e)}if(n=this.currentTracerContext?this.currentTracerContext(n,this):n[$._3](this),i!==this.currentLoopCount)return $.GN;if(n===$.GN){let e=this._yielded;if($.IH in e)return this._yielded=void 0,e;return $.GN}}}catch(e){if(!(0,v.i5)(n,$._3))return(0,$.V2)(`Fiber.runLoop: Not a valid effect: ${String(n)}`);return this.runLoop((0,$.V2)(e))}finally{globalThis[w.fL]=t}}getCont(e){for(;;){let t=this._stack.pop();if(!t)return;let r=t[$.u4]&&t[$.u4](this);if(r)return r[e]=r,r;if(t[e])return t}}yieldWith(e){return this._yielded=e,$.GN}children(){return this._children??=new Set}pipe(){return(0,b.tT)(this,arguments)}setContext(e){this.context=e;let t=this.getRef(_._F);t!==this.currentScheduler&&(this.currentScheduler=t,this._dispatcher=void 0),this.currentSpan=e.mapUnsafe.get(k.WG),this.currentLogLevel=this.getRef(I.Gl),this.minimumLogLevel=this.getRef(I.zQ),this.currentStackFrame=e.mapUnsafe.get(I.vA.key),this.maxOpsBeforeYield=this.getRef(_.Zm),this.currentPreventYield=this.getRef(_.hf),this.runtimeMetrics=e.mapUnsafe.get(O.F);let r=e.mapUnsafe.get(k.RL);this.currentTracerContext=r?r.context:void 0}get currentSpanLocal(){return this.currentSpan?._tag==="Span"?this.currentSpan:void 0}}let eg={interruptChildren:void 0},ey=e=>{if(!e.currentStackFrame)return;let t=new Map;return t.set($.z8.key,e.currentStackFrame),o.LZ(t)},eb=e=>{if(void 0!==e._children&&0!==e._children.size)return e$(e._children)},ev=e=>e._exit?eO(e._exit):eQ(t=>e._exit?t(eO(e._exit)):eC(e.addObserver(e=>t(eO(e))))),ew=e=>eQ(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(eO(i))}(),eC(()=>r?.())}),ex=e=>e._exit?e._exit:eQ(t=>e._exit?t(e._exit):eC(e.addObserver(t))),e_=e=>eQ(t=>{let r=Array.from(e);if(0===r.length)return t(eO(s.Ie()));let n=Array(r.length),i=s.Ie(),a=0,o=!1;for(let e=0;e<r.length&&!o;e++)i.push(r[e].addObserver(s=>{if(a++,"Failure"===s._tag)return o=!0,i.forEach(e=>e()),t(s);n[e]=s.value,a===r.length&&t(eO(n))}))}),ek=e=>(0,$.R6)(t=>eS(e,t.id)),eS=(0,f.XY)(e=>(0,v.i5)(e[0],ed),(e,t,r)=>(0,$.R6)(n=>{let i=ey(n);return i=i&&r?o.h1(i,r):i??r,e.interruptUnsafe(t,i),ti(ev(e))})),e$=e=>(0,$.R6)(t=>{let r=ey(t),n=s.Ie();for(let i of e)i.interruptUnsafe(t.id,r),n.push(i);return ti(ew(n))}),eE=(0,f.XY)(2,(e,t)=>(0,$.R6)(r=>{let n=ey(r),i=s.Ie();for(let r of e)r.interruptUnsafe(t,n),i.push(r);return ti(ew(i))})),eO=$.xt,eI=$.cb,eA=$.Rk,eC=(0,$.Uf)({op:"Sync",[$._3](e){let t=this[$.a2](),r=e.getCont($.ee);return r?r[$.ee](t,e):e.yieldWith((0,$.xt)(t))}}),eT=(0,$.Uf)({op:"Suspend",[$._3](e){return this[$.a2]()}}),eN=(0,f.XY)(e=>e.length>=2||g.isOption(e[0]),(e,t)=>g.isNone(e)?eA(t?t():new $.Xm("Effect.fromOption: Option.none")):eO(e.value)),eM=x.YW({onFailure:eA,onSuccess:eO}),eP=e=>null==e?eA(new $.Xm):eO(e),ej=(0,$.Uf)({op:"Yield",[$._3](e){let t=!1;return e.currentDispatcher.scheduleTask(()=>{t||e.evaluate(tM)},this[$.a2]??0),e.yieldWith(()=>{t=!0})}}),eD=ej(0),eU=e=>eO(g.some(e)),eR=eO(g.none()),eF=e=>g.isNone(e)?eR:tg(e.value,g.some),eL=e=>eT(()=>eI((0,S.s)(e))),eB=e=>(0,$.V2)(e),eY=e=>eT(()=>eA((0,S.s)(e))),eq=eO(void 0),eW=e=>{let t="function"==typeof e?e:e.try,r="function"==typeof e?e=>new i6(e,"An error occurred in Effect.try"):e.catch;return eT(()=>{try{return eO((0,S.s)(t))}catch(e){return eA((0,S.s)(()=>r(e)))}})},eX=e=>eG(function(t,r){(0,S.s)(()=>e(r)).then(e=>t(eO(e)),e=>t(eB(e)))},0!==e.length),eJ=e=>{let t="function"==typeof e?e:e.try,r="function"==typeof e?e=>new i6(e,"An error occurred in Effect.tryPromise"):e.catch;return eG(function(e,n){let i=t=>{try{e(eA((0,S.s)(()=>r(t))))}catch(t){e(eB(t))}};try{(0,S.s)(()=>t(n)).then(t=>e(eO(t)),i)}catch(e){i(e)}},0!==t.length)},ez=e=>(0,$.R6)(t=>e(t.id)),eK=(0,$.R6)(eO),eV=ez(eO),eG=(0,$.Uf)({op:"Async",single:!1,[$._3](e){let t=(0,S.s)(()=>this[$.a2][0].bind(e.currentScheduler)),r=!1,n=!1,i=this[$.a2][1]?new AbortController:void 0,a=t(t=>{r||(r=!0,n?e.evaluate(t):n=t)},i?.signal);return!1!==n?n:(n=!0,e._yielded=()=>{r=!0},void 0===i&&void 0===a||e._stack.push(eH(()=>(r=!0,i?.abort(),a??tM))),$.GN)}}),eH=(0,$.Uf)({op:"AsyncFinalizer",[$.u4](e){e.interruptible&&(e.interruptible=!1,e._stack.push(n_))},[$.Sc](e,t){return q(e)?tu(this[$.a2](),()=>eI(e)):eI(e)}}),eQ=e=>eG(e,e.length>=2),eZ=eQ(f.Yi),e0=(...e)=>eT(()=>e9(1===e.length?e[0]():e[1].call(e[0].self))),e1=(e,...t)=>{let r=0===t.length?function(){return eT(()=>e9(e.apply(this,arguments)))}:function(){let r=eT(()=>e9(e.apply(this,arguments)));for(let e=0;e<t.length;e++)r=t[e](r,...arguments);return r};return e2(e.length,r)},e2=(e,t)=>Object.defineProperty(t,"length",{value:e,configurable:!0}),e5=T(2),e3=function(){let e="string"==typeof arguments[0],t=e?arguments[0]:"Effect.fn",r=e?arguments[1]:void 0,n=(0,A.jt)();(0,A.ft)(2);let i=new globalThis.Error;return((0,A.ft)(n),e)?(n,...a)=>e6(t,n,i,a,e,r):e6(t,arguments[0],i,Array.prototype.slice.call(arguments,1),e,r)},e6=(e,t,r,n,i,a)=>{let s="function"==typeof t?t:n.pop().bind(t.self);return e2(s.length,function(...t){let o=eT(()=>{let e=s.apply(this,arguments);return(0,$.yw)(e)?e:e9(e)});for(let e=0;e<n.length;e++)o=n[e](o,...t);if(!(0,$.yw)(o))return o;let l=(0,A.jt)();(0,A.ft)(2);let c=new globalThis.Error;return(0,A.ft)(l),tK(i?iI(e,a,e=>iA(o,e)):o,I.vA,t=>({name:e,stack:e5(()=>c.stack),parent:{name:`${e} (definition)`,stack:e5(()=>r.stack),parent:t}}))})},e8=(e,...t)=>e2(e.length,0===t.length?function(){return e4(()=>e.apply(this,arguments))}:function(){let r=e4(()=>e.apply(this,arguments));for(let e of t)r=e(r);return r}),e4=e=>{try{let t,r=e();for(;;){let n=r.next(t);if(n.done)return eO(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 eT(()=>t?(t=!1,tu(n.value,e=>e9(r,e))):eT(()=>e9(e())))}}}catch(e){return eB(e)}},e9=(0,$.Uf)({op:"Iterator",single:!1,[$.ee](e,t){let r=this[$.a2][0];for(;;){let n=r.next(e);if(n.done)return eO(n.value);if(!th(n.value))return t._stack.push(this),n.value;if("Failure"===n.value._tag)return n.value;e=n.value.value}},[$._3](e){return this[$.ee](this[$.a2][1],e)}}),e7=(0,f.XY)(2,(e,t)=>{let r=eO(t);return tu(e,e=>r)}),te=e=>tg(e,g.some),tt=e=>rP(e,{onFailure:eO,onSuccess:eA}),tr=(0,f.XY)(2,(e,t)=>tu(e,e=>(0,$.yw)(t)?t:(0,S.s)(()=>t(e)))),tn=(0,f.XY)(2,(e,t)=>tu(e,e=>e7((0,$.yw)(t)?t:(0,S.s)(()=>t(e)),e))),ti=e=>tu(e,e=>tM),ta=e=>rt(e,eA),ts=(e,t)=>(0,$.R6)(r=>eQ(n=>{let i=s.Ts(e),a=i.length,o=0,l=!1,c=new Set,u=[],d=(e,i,s)=>{if(o++,"Failure"===e._tag){u.push(...e.cause.reasons),o>=a&&n(eI((0,$.b5)(u)));return}let d=!l;l=!0,n(0===c.size?e:tu(nw(e$(c)),()=>e)),d&&t?.onWinner&&t.onWinner({fiber:i,index:s,parentFiber:r})};for(let e=0;e<a;e++){let t=nQ(r,i[e],!0,!0,!1);if(c.add(t),t.addObserver(r=>{c.delete(t),d(r,t,e)}),l)break}return e$(c)})),to=(e,t)=>(0,$.R6)(r=>eQ(n=>{let i=!1,a=new Set,s=e=>{i=!0,n(0===a.size?e:tu(nw(e$(a)),()=>e))},o=0;for(let n of e){if(i)break;let e=o++,l=nQ(r,n,!0,!0,!1);a.add(l),l.addObserver(n=>{a.delete(l);let o=!i;s(n),o&&t?.onWinner&&t.onWinner({fiber:l,index:e,parentFiber:r})})}return e$(a)})),tl=(0,f.XY)(e=>(0,$.yw)(e[1]),(e,t,r)=>ts([e,t],r)),tc=(0,f.XY)(e=>(0,$.yw)(e[1]),(e,t,r)=>to([e,t],r)),tu=(0,f.XY)(2,(e,t)=>{let r=Object.create(td);return r[$.a2]=e,r[$.ee]=1!==t.length?e=>t(e):t,r}),td=(0,$.yj)({op:"OnSuccess",[$._3](e){return e._stack.push(this),this[$.a2]}}),tf=(0,f.XY)(2,(e,t)=>th(e)?"Success"===e._tag?t.onSuccess(e.value):t.onFailure(e.cause):rT(e,t)),th=e=>$.IH in e,tp=(0,f.XY)(2,(e,t)=>th(e)?"Success"===e._tag?t(e.value):e:tu(e,t)),tm=e=>tu(e,f.D_),tg=(0,f.XY)(2,(e,t)=>tu(e,e=>eO((0,S.s)(()=>t(e))))),ty=(0,f.XY)(2,(e,t)=>th(e)?tP(e,t):tg(e,t)),tb=(0,f.XY)(2,(e,t)=>th(e)?tj(e,t):rx(e,t)),tv=(0,f.XY)(2,(e,t)=>th(e)?tD(e,t):r_(e,t)),tw=(0,f.XY)(2,(e,t)=>{if(th(e)){if("Success"===e._tag)return e;let r=R(e.cause);return x.N6(r)?e:t(r.success)}return ra(e,t)}),tx=e=>(0,$.cb)(j(e)),t_=e=>"Success"===e._tag,tk=e=>"Success"===e._tag?x.Py(e):x.fJ(e),tS=e=>"Success"===e._tag?x.Py(e.value):x.fJ(e),t$=e=>"Failure"===e._tag,tE=e=>"Failure"===e._tag?x.Py(e):x.fJ(e),tO=e=>"Failure"===e._tag?x.Py(e.cause):x.fJ(e),tI=u.Bh(tO,R),tA=u.Bh(tO,Y),tC=e=>"Failure"===e._tag&&q(e.cause),tT=e=>"Failure"===e._tag&&L(e.cause),tN=e=>"Failure"===e._tag&&D(e.cause),tM=(0,$.xt)(void 0),tP=(0,f.XY)(2,(e,t)=>"Success"===e._tag?(0,$.xt)(t(e.value)):e),tj=(0,f.XY)(2,(e,t)=>{if("Success"===e._tag)return e;let r=R(e.cause);return x.N6(r)?e:(0,$.Rk)(t(r.success))}),tD=(0,f.XY)(2,(e,t)=>{if("Success"===e._tag)return(0,$.xt)(t.onSuccess(e.value));let r=R(e.cause);return x.N6(r)?e:(0,$.Rk)(t.onFailure(r.success))}),tU=(0,f.XY)(2,(e,t)=>t_(e)?(0,$.xt)(t):e),tR=(0,f.XY)(2,(e,t)=>t_(e)?t:e),tF=(0,f.XY)(2,(e,t)=>t_(e)?t.onSuccess(e.value):t.onFailure(e.cause)),tL=tU(void 0),tB=e=>{let t=[];for(let r of e)"Failure"===r._tag&&t.push(...r.cause.reasons);return 0===t.length?tM:(0,$.cb)((0,$.b5)(t))},tY=e=>t_(e)?g.some(e.value):g.none(),tq=e=>t$(e)?g.some(e.cause):g.none(),tW=e=>{let t=tI(e);return x.N6(t)?g.none():g.some(t.success)},tX=e=>e,tJ=e=>(0,$.R6)(t=>eO(o.om(t.context,e))),tz=(0,f.XY)(2,(e,t)=>(0,$.R6)(r=>{let n=r.context,i=t(n);return n===i?e:(r.setContext(i),na(e,()=>{r.setContext(n)}))})),tK=(0,f.XY)(3,(e,t,r)=>tz(e,e=>{let n=o.fp(e,t),i=r(n);return n===i?e:o.WQ(e,t,i)})),tV=()=>tG,tG=(0,$.R6)(e=>eO(e.context)),tH=e=>(0,$.R6)(t=>e(t.context)),tQ=(0,f.XY)(2,(e,t)=>tz(e,(0,f.dY)(t))),tZ=(0,f.XY)(2,(e,t)=>th(e)?e:tz(e,o.h1(t))),t0=function(){return 1==arguments.length?(0,f.XY)(2,(e,t)=>t1(e,arguments[0],t)):(0,f.XY)(3,(e,t,r)=>t1(e,t,r)).apply(this,arguments)},t1=(e,t,r)=>tz(e,e=>e.mapUnsafe.get(t.key)===r?e:o.WQ(e,t,r)),t2=(0,f.XY)(3,(e,t,r)=>tu(r,r=>t0(e,t,r))),t5=t0(I.F8),t3=(0,f.XY)(e=>(0,$.yw)(e[1]),(e,t,r)=>t6(e,t,(e,t)=>[e,t],r)),t6=(0,f.XY)(e=>(0,$.yw)(e[1]),(e,t,r,n)=>n?.concurrent?tg(nI([e,t],{concurrency:2}),([e,t])=>(0,S.s)(()=>r(e,t))):tu(e,e=>tg(t,t=>(0,S.s)(()=>r(e,t))))),t8=(0,f.XY)(e=>(0,$.yw)(e[0]),(e,t,r)=>nB(e,t,r?e=>eA(r(e)):()=>eA(new $.Xm))),t4=(0,f.XY)(2,(e,t)=>tu(t,t=>t?te(e):eR)),t9=(0,f.XY)(2,(e,t)=>Array.from({length:t},()=>e)),t7=(0,f.XY)(e=>(0,$.yw)(e[0]),(e,t,r)=>nI(t9(e,t),r)),re=(0,f.XY)(e=>(0,$.yw)(e[0]),(e,t)=>nj({while:f.ue,body:(0,f.dY)(t?.disableYield?e:tu(e,e=>eD)),step:f.Yi})),rt=(0,f.XY)(2,(e,t)=>{let r=Object.create(rr);return r[$.a2]=e,r[$.Sc]=1!==t.length?e=>t(e):t,r}),rr=(0,$.yj)({op:"OnFailure",[$._3](e){return e._stack.push(this),this[$.a2]}}),rn=(0,f.XY)(3,(e,t,r)=>rt(e,e=>t(e)?(0,S.s)(()=>r(e)):eI(e))),ri=(0,f.XY)(3,(e,t,r)=>rt(e,e=>{let n=t(e);return x.N6(n)?eI(n.failure):(0,S.s)(()=>r(n.success,e))})),ra=(0,f.XY)(2,(e,t)=>ri(e,R,e=>t(e))),rs=e=>rP(e,{onFailure:e=>(0,$.PW)(e)?eR:eA(e),onSuccess:eU}),ro=(0,f.XY)(2,(e,t)=>ri(e,Y,t)),rl=(0,f.XY)(2,(e,t)=>rt(e,e=>tr((0,S.s)(()=>t(e)),eI(e)))),rc=(0,f.XY)(3,(e,t,r)=>rn(e,t,e=>tr((0,S.s)(()=>r(e)),eI(e)))),ru=(0,f.XY)(3,(e,t,r)=>rt(e,e=>{let n=t(e);return x.N6(n)?eI(e):tr((0,S.s)(()=>r(n.success,e)),eI(e))})),rd=(0,f.XY)(2,(e,t)=>ru(e,R,e=>t(e))),rf=(0,f.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 rd(e,e=>n(e)?r(e):eq)}),rh=(0,f.XY)(2,(e,t)=>ru(e,Y,e=>t(e))),rp=(0,f.XY)(e=>(0,$.yw)(e[0]),(e,t,r,n)=>rt(e,e=>{let i=R(e);return x.N6(i)?eI(i.failure):t(i.success)?(0,S.s)(()=>r(i.success)):n?(0,S.s)(()=>n(i.success)):eI(e)})),rm=(0,f.XY)(e=>(0,$.yw)(e[0]),(e,t,r,n)=>rt(e,e=>{let i=R(e);if(x.N6(i))return eI(i.failure);let a=t(i.success);return x.N6(a)?n?(0,S.s)(()=>n(a.failure)):eI(e):(0,S.s)(()=>r(a.success))})),rg=(0,f.XY)(e=>(0,$.yw)(e[0]),(e,t,r,n)=>rp(e,Array.isArray(t)?e=>(0,v.i5)(e,"_tag")&&t.includes(e._tag):(0,v.$J)(t),r,n)),ry=(0,f.XY)(e=>(0,$.yw)(e[0]),(e,t,r)=>{let n;return rm(e,e=>(n??=Object.keys(t),(0,v.i5)(e,"_tag")&&(0,v.Kg)(e._tag)&&n.includes(e._tag)?x.Py(e):x.fJ(e)),e=>(0,S.s)(()=>t[e._tag](e)),r)}),rb=(0,f.XY)(e=>(0,$.yw)(e[0]),(e,t,r,n,i)=>rp(e,e=>(0,v.$J)(e,t)&&(0,v.i5)(e,"reason"),e=>{let t=e.reason;return(0,v.$J)(t,r)?n(t,e):i?(0,S.s)(()=>i(t,e)):eA(e)})),rv=(0,f.XY)(e=>(0,$.yw)(e[0]),(e,t,r,n)=>{let i;return rp(e,e=>(0,v.$J)(e,t)&&(0,v.i5)(e,"reason")&&(0,v.i5)(e.reason,"_tag")&&(0,v.Kg)(e.reason._tag),e=>{let t=e.reason;return(i??=Object.keys(r)).includes(t._tag)?(0,S.s)(()=>r[t._tag](t,e)):n?(0,S.s)(()=>n(t,e)):eA(e)})}),rw=(0,f.XY)(2,(e,t)=>rm(e,e=>(0,v.$J)(e,t)&&(0,v.i5)(e,"reason")?x.Py(e.reason):x.fJ(e),eA)),rx=(0,f.XY)(2,(e,t)=>ra(e,e=>eY(()=>t(e)))),r_=(0,f.XY)(2,(e,t)=>rP(e,{onFailure:e=>eY(()=>t.onFailure(e)),onSuccess:e=>eC(()=>t.onSuccess(e))})),rk=e=>ra(e,eB),rS=(0,f.XY)(2,(e,t)=>ra(e,e=>eC(t))),r$=e=>eT(()=>{let t=e[Symbol.iterator](),r=t.next();return r.done?eB(Error("Received an empty collection of effects")):function e(r){let n=t.next();return n.done?r.value:ra(r.value,t=>e(n))}(r)}),rE=e=>ra(e,t=>tu(eD,()=>rE(e))),rO=(0,f.XY)(e=>(0,$.yw)(e[0]),(e,t)=>{if(!t?.log)return rP(e,{onFailure:e=>eq,onSuccess:e=>eq});let r=aa(!0===t.log?void 0:t.log);return rT(e,{onFailure(e){let n=U(e);return x.N6(n)?eI(n.failure):void 0===t.message?r(e):r(t.message,e)},onSuccess:e=>eq})}),rI=(0,f.XY)(e=>(0,$.yw)(e[0]),(e,t)=>{if(!t?.log)return rT(e,{onFailure:e=>eq,onSuccess:e=>eq});let r=aa(!0===t.log?void 0:t.log);return rT(e,{onFailure:e=>void 0===t.message?r(e):r(t.message,e),onSuccess:e=>eq})}),rA=e=>rj(e,{onFailure:g.none,onSuccess:g.some}),rC=e=>rD(e,{onFailure:x.fJ,onSuccess:x.Py}),rT=(0,f.XY)(2,(e,t)=>{let r=Object.create(rN);return r[$.a2]=e,r[$.ee]=1!==t.onSuccess.length?e=>t.onSuccess(e):t.onSuccess,r[$.Sc]=1!==t.onFailure.length?e=>t.onFailure(e):t.onFailure,r}),rN=(0,$.yj)({op:"OnSuccessAndFailure",[$._3](e){return e._stack.push(this),this[$.a2]}}),rM=(0,f.XY)(2,(e,t)=>rT(e,{onFailure:e=>eC(()=>t.onFailure(e)),onSuccess:e=>eC(()=>t.onSuccess(e))})),rP=(0,f.XY)(2,(e,t)=>rT(e,{onFailure:e=>{let r=e.reasons.find($.lC);return r?(0,S.s)(()=>t.onFailure(r.error)):eI(e)},onSuccess:t.onSuccess})),rj=(0,f.XY)(2,(e,t)=>rP(e,{onFailure:e=>eC(()=>t.onFailure(e)),onSuccess:e=>eC(()=>t.onSuccess(e))})),rD=(0,f.XY)(2,(e,t)=>{if(th(e)){if("Success"===e._tag)return(0,$.xt)(t.onSuccess(e.value));let r=R(e.cause);return x.N6(r)?e:(0,$.xt)(t.onFailure(r.success))}return rj(e,t)}),rU=(0,f.XY)(2,(e,t)=>th(e)?"Success"===e._tag?(0,$.xt)(t.onSuccess(e.value)):(0,$.xt)(t.onFailure(e.cause)):rM(e,t)),rR=e=>th(e)?(0,$.xt)(e):rF(e),rF=(0,$.Uf)({op:"Exit",[$._3](e){return e._stack.push(this),this[$.a2]},[$.ee]:(e,t,r)=>eO(r??(0,$.xt)(e)),[$.Sc]:(e,t,r)=>eO(r??(0,$.cb)(e))}),rL=rD({onFailure:()=>!0,onSuccess:()=>!1}),rB=rD({onFailure:()=>!1,onSuccess:()=>!0}),rY=(0,f.XY)(2,(e,t)=>tr(iY(t),e)),rq=(0,f.XY)(2,(e,t)=>tc(e,tu(iY(t.duration),t.orElse))),rW=(0,f.XY)(2,(e,t)=>rq(e,{duration:t,orElse:()=>eA(new iz)})),rX=(0,f.XY)(2,(e,t)=>tc(te(e),e7(iY(t),g.none()))),rJ=e=>iB(t=>{let r=t.currentTimeNanosUnsafe();return tg(e,e=>[l.cF(t.currentTimeNanosUnsafe()-r),e])}),rz="~effect/Scope",rK="~effect/Scope/Closeable",rV=o.kl("effect/Scope"),rG=(e,t)=>eT(()=>rH(e,t)??eq),rH=(e,t)=>{if("Closed"===e.state._tag)return;let r={_tag:"Closed",exit:t};if("Empty"===e.state._tag){e.state=r;return}let{finalizers:n}=e.state;return(e.state=r,0===n.size)?void 0:1===n.size?n.values().next().value(t):rQ(e,n,t)},rQ=e1(function*(e,t,r){let n=[],i=[],a=Array.from(t.values()),s=ep();for(let t=a.length-1;t>=0;t--){let o=a[t];"sequential"===e.strategy?n.push((yield*rR(o(r)))):i.push(nQ(s,o(r),!0,!0,"inherit"))}return i.length>0&&(n=yield*ew(i)),yield*tB(n)}),rZ=(e,t)=>eC(()=>r0(e,t)),r0=(e,t)=>{let r=r6(t);if("Closed"===e.state._tag)return r.state=e.state,r;let n={};return r5(e,n,e=>rG(r,e)),r5(r,n,t=>eC(()=>r3(e,n))),r},r1=(e,t)=>eT(()=>"Closed"===e.state._tag?t(e.state.exit):(r5(e,{},t),eq)),r2=(e,t)=>r1(e,(0,f.dY)(t)),r5=(e,t,r)=>{"Empty"===e.state._tag?e.state={_tag:"Open",finalizers:new Map([[t,r]])}:"Open"===e.state._tag&&e.state.finalizers.set(t,r)},r3=(e,t)=>{"Open"===e.state._tag&&e.state.finalizers.delete(t)},r6=(e="sequential")=>({[rK]:rK,[rz]:rz,strategy:e,state:r8}),r8={_tag:"Empty"},r4=e=>eC(()=>r6(e)),r9=rV,r7=t0(rV),ne=e=>(0,$.R6)(t=>{let r=t.context,n=r6();return t.setContext(o.WQ(t.context,rV,n)),na(e,e=>(t.setContext(r),rH(n,e)))}),nt=(0,f.XY)(2,(e,t)=>ns(r7(e,t),e=>eT(()=>rH(t,e)??eq))),nr=e=>eT(()=>{let t=r6();return ns(e(t),e=>eT(()=>rH(t,e)??eq))}),nn=(e,t,r)=>tH(n=>n$(i=>tu(r9,a=>tn(r?.interruptible?i(e):e,e=>r1(a,r=>tZ(t(e,r),n)))))),ni=e=>tu(r9,t=>tH(r=>r1(t,t=>tZ(e(t),r)))),na=(0,$.Uf)({op:"OnExit",single:!1,[$._3](e){return e._stack.push(this),this[$.a2][0]},[$.u4](e){e.interruptible&&!0!==this[$.a2][2]&&(e._stack.push(n_),e.interruptible=!1)},[$.ee](e,t,r){r??=(0,$.xt)(e);let n=this[$.a2][1](r);return n?tu(n,e=>r):r},[$.Sc](e,t,r){r??=(0,$.cb)(e);let n=this[$.a2][1](r);return n?tu(n,e=>r):r}}),ns=(0,f.XY)(2,na),no=(0,f.XY)(2,(e,t)=>ns(e,e=>t)),nl=(0,f.XY)(3,(e,t,r)=>ns(e,e=>t(e)?r(e):eq)),nc=(0,f.XY)(3,(e,t,r)=>ns(e,e=>{let n=t(e);return x.N6(n)?eq:r(n.success,e)})),nu=(0,f.XY)(2,(e,t)=>nc(e,tO,t)),nd=(0,f.XY)(3,(e,t,r)=>nl(e,e=>"Failure"===e._tag&&t(e.cause),e=>r(e.cause))),nf=(0,f.XY)(3,(e,t,r)=>ns(e,e=>{if("Failure"!==e._tag)return eq;let n=t(e.cause);return x.N6(n)?eq:r(n.success,e.cause)})),nh=(0,f.XY)(2,(e,t)=>nf(X,t)(e)),np=(e,t,r)=>n$(n=>tu(e,e=>na(n(t(e)),t=>r(e,t),!0))),nm=e=>nn(e,e=>(0,v.i5)(e,Symbol.asyncDispose)?eX(()=>e[Symbol.asyncDispose]()):eC(()=>e[Symbol.dispose]())),ng=(0,f.XY)(2,(e,t)=>eC(()=>{let r,n=l.kE(l.bN(t)),i=Number.isFinite(n),a=iu(!1),s=0,o=!1,c=tu(a.await,()=>r);return[(0,$.R6)(t=>{let l=t.getRef(iD),u=i?l.currentTimeMillisUnsafe():0;return o||u<s?r??c:(o=!0,a.closeUnsafe(),r=void 0,ns(e,e=>eC(()=>{o=!1,s=l.currentTimeMillisUnsafe()+n,r=e,a.openUnsafe()})))}),eC(()=>{s=0,a.closeUnsafe(),r=void 0})]})),ny=(0,f.XY)(2,(e,t)=>tg(ng(e,t),e=>e[0])),nb=e=>ny(e,l.Tn),nv=(0,$.R6)(e=>eI(j(e.id))),nw=e=>(0,$.R6)(t=>(t.interruptible&&(t.interruptible=!1,t._stack.push(n_)),e)),nx=(0,$.Uf)({op:"SetInterruptible",[$.u4](e){if(e.interruptible=this[$.a2],e._interruptedCause&&e.interruptible)return()=>eI(e._interruptedCause)}}),n_=nx(!0),nk=nx(!1),nS=e=>(0,$.R6)(t=>t.interruptible?e:(t.interruptible=!0,t._stack.push(nk),t._interruptedCause)?eI(t._interruptedCause):e),n$=e=>(0,$.R6)(t=>t.interruptible?(t.interruptible=!1,t._stack.push(n_),e(nS)):e(f.D_)),nE=e=>(0,$.R6)(t=>t.interruptible?e(f.D_):(t.interruptible=!0,t._stack.push(nk),e(nw))),nO=tg(nn(eC(()=>new AbortController),e=>eC(()=>e.abort())),e=>e.signal),nI=(e,t)=>(0,v.xZ)(e)?t?.mode==="result"?nD(e,rC,t):nD(e,f.D_,t):t?.discard?"result"===t.mode?nD(Object.values(e),rC,t):nD(Object.values(e),f.D_,t):eT(()=>{let r={};return e7(nD(Object.entries(e),([e,n])=>tg(t?.mode==="result"?rC(n):n,t=>{r[e]=t}),{discard:!0,concurrency:t?.concurrency}),r)}),nA=(0,f.XY)(e=>(0,v.xZ)(e[0])&&!(0,$.yw)(e[0]),(e,t,r)=>tg(nD(e,(e,r)=>rC(t(e,r)),r),e=>s.jB(e,f.D_))),nC=(0,f.XY)(e=>(0,v.xZ)(e[0])&&!(0,$.yw)(e[0]),(e,t,r)=>tu(nA(e,t,{concurrency:r?.concurrency}),([e,t])=>s.CZ(e)?eA(e):r?.discard?eq:eO(t))),nT=(0,f.XY)(e=>(0,v.xZ)(e[0])&&!(0,$.yw)(e[0]),(e,t)=>eT(()=>{let r=e[Symbol.iterator](),n=r.next();return n.done?eO(g.none()):nN(r,0,t,n.value)})),nN=(e,t,r,n)=>tu(r(n,t),i=>{if(i)return eO(g.some(n));let a=e.next();return a.done?eO(g.none()):nN(e,t+1,r,a.value)}),nM=(0,f.XY)(e=>(0,v.xZ)(e[0])&&!(0,$.yw)(e[0]),(e,t)=>eT(()=>{let r=e[Symbol.iterator](),n=r.next();return n.done?eO(g.none()):nP(r,0,t,n.value)})),nP=(e,t,r,n)=>tu(r(n,t),n=>{if(x.oJ(n))return eO(g.some(n.success));let i=e.next();return i.done?eO(g.none()):nP(e,t+1,r,i.value)}),nj=(0,$.Uf)({op:"While",[$.ee](e,t){return(this[$.a2].step(e),this[$.a2].while())?(t._stack.push(this),this[$.a2].body()):tM},[$._3](e){return this[$.a2].while()?(e._stack.push(this),this[$.a2].body()):tM}}),nD=(0,f.XY)(e=>"function"==typeof e[1],(e,t,r)=>(0,$.R6)(n=>{let i=r?.concurrency==="inherit"?n.getRef(I.F8):r?.concurrency??1,a="unbounded"===i?1/0:Math.max(1,i);if(1===a)return nU(e,t,r);let o=s.Ts(e),l=o.length;if(0===l)return r?.discard?eq:eO([]);let c=r?.discard?void 0:Array(l),u=nL({f:t,out:c},o,{concurrency:a});return u?e7(u,c):eO(c)})),nU=(e,t,r)=>eT(()=>{let n=r?.discard?void 0:[],i=e[Symbol.iterator](),a=i.next(),s=0;return e7(nj({while:()=>!a.done,body:()=>t(a.value,s++),step:e=>{n&&n.push(e),a=i.next()}}),n)}),nR=e=>{let t=e.onItem,r=e.step;return(e,n,i)=>{let a,s,o,l,c,u=i?.start??0,d=i?.end??n.length,f=i?.concurrency??1,h=i?.orderedStep===!0&&f>1,p=!1,m=!1,g=u,y=h?Array(d):void 0,b=(t,i,a)=>{if(!h)return r(e,t,i,a);if(l)return l;for(y[a]=i;g<d;){let t=y[g];if(void 0===t)return;y[g]=void 0;let i=g++,a=r(e,n[i],t,i);if(a)return a}},v=()=>{let r=!1;for(;!l&&u<d;u++){let i=n[u],d=c??t(e,i,u);if(th(d)){if(l=b(i,d,u))break}else{if(1===f)return tu(rR(d),e=>(l=b(i,e,u),u++,l??v()??eq));if(!a)return eQ(e=>{a=ep(),c=d,o=e;let t=v();return t?e(t):eT(()=>(l=tM,m=!0,s?e$(s):eq))});c=void 0;let e=nQ(a,d,!0,!0,"inherit");if(e._exit){if(l=b(i,e._exit,u))break;continue}s?s.add(e):s=new Set([e]);let t=u;if(e.addObserver(n=>{if(s.delete(e),l){if(!m&&"Failure"===n._tag)for(let e of n.cause.reasons)if("Interrupt"===e._tag)continue;else"Failure"===l._tag?l.cause.reasons.push(e):l=(0,$.cb)((0,$.b5)([e]))}else{let e=b(i,n,t);e&&(l="Failure"===e._tag?(0,$.cb)((0,$.b5)(e.cause.reasons.slice())):e,v())}if(r){let e=v();e&&o(e)}else p&&0===s.size&&o(l??eq)}),s.size<f)continue;r=!0,u++;return}}if(p=!0,l){if(s&&s.size>0){let e=ey(a);s.forEach(t=>t.interruptUnsafe(a.id,e));return}if(o||"Failure"===l._tag)return l}else if(o)if(!s)return tM;else 0===s.size&&o(eq)};return v()}},nF=()=>nR,nL=nR({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)}}),nB=(0,f.XY)(3,(e,t,r)=>tu(e,e=>t(e)?eO(e):r(e))),nY=(0,f.XY)(3,(e,t,r)=>tu(e,e=>{let n=t(e);return x.N6(n)?r(n.failure):eO(n.success)})),nq=(0,f.XY)(e=>(0,$.yw)(e[0]),(e,t,r)=>nY(e,t,r?e=>eA(r(e)):()=>eA(new $.Xm))),nW=(0,f.XY)(e=>(0,v.xZ)(e[0])&&!(0,$.yw)(e[0]),(e,t,r)=>eT(()=>{let n=[];return e7(nD(e,(e,r)=>{let i=t(e,r);return"boolean"==typeof i?(i&&n.push(e),eq):tg(i,t=>{t&&n.push(e)})},{discard:!0,concurrency:r?.concurrency}),n)})),nX=(0,f.XY)(e=>(0,v.xZ)(e[0])&&!(0,$.yw)(e[0]),(e,t)=>eT(()=>{let r=[];for(let n of e){let e=t(n);x.oJ(e)&&r.push(e.success)}return eO(r)})),nJ=(0,f.XY)(e=>(0,v.xZ)(e[0])&&!(0,$.yw)(e[0]),(e,t,r)=>eT(()=>{let n=[];return e7(nD(e,e=>tg(t(e),e=>{x.oJ(e)&&n.push(e.success)}),{discard:!0,concurrency:r?.concurrency}),n)})),nz=eO({}),nK=E.Jr(tg),nV=E.oI(tg,tu),nG=E.zM(tg),nH=(0,f.XY)(e=>(0,$.yw)(e[0]),(e,t)=>(0,$.R6)(r=>(eg.interruptChildren??=eb,eO(nQ(r,e,t?.startImmediately,!1,t?.uninterruptible??!1))))),nQ=(e,t,r=!1,n=!1,i=!1)=>{let a="inherit"===i?e.interruptible:!i,s=new em(e.context,a);return r?s.evaluate(t):e.currentDispatcher.scheduleTask(()=>s.evaluate(t),0),n||s._exit||(e.children().add(s),s.addObserver(()=>e._children.delete(s))),s},nZ=(0,f.XY)(e=>(0,$.yw)(e[0]),(e,t)=>(0,$.R6)(r=>eO(nQ(r,e,t?.startImmediately,!0,t?.uninterruptible)))),n0=e=>(0,$.R6)(t=>{let r=t._children&&s.Ts(t._children);return ns(e,e=>{let n=t._children;return void 0===n||0===n.size?eq:(r&&(n=m.pb(n,e=>!r.includes(e))),ti(ew(n)))})}),n1=(0,f.XY)(e=>(0,$.yw)(e[0]),(e,t,r)=>(0,$.R6)(n=>{let i=nQ(n,e,r?.startImmediately,!0,r?.uninterruptible);if(!i._exit)if("Closed"!==t.state._tag){let e={};r5(t,e,()=>ez(e=>e===i.id?eq:ek(i))),i.addObserver(()=>r3(t,e))}else i.interruptUnsafe(n.id,ey(n));return eO(i)})),n2=(0,f.XY)(e=>(0,$.yw)(e[0]),(e,t)=>tu(r9,r=>n1(e,r,t))),n5=e=>(t,r)=>{let n=new em(r?.scheduler?o.WQ(e,_._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},n3=(0,f.XY)(2,(e,t)=>{if(e._exit)return e;if("Closed"===t.state._tag)return e.interruptUnsafe(e.id),e;let r={};return r5(t,r,()=>ek(e)),e.addObserver(()=>r3(t,r)),e}),n6=n5(o.Ie()),n8=e=>{let t=n5(e);return(e,r)=>{let n=t(e,r);return r?.onExit&&n.addObserver(r.onExit),e=>n.interruptUnsafe(e)}},n4=n8(o.Ie()),n9=e=>{let t=n5(e);return(e,r)=>{let n=t(e,r);return new Promise(e=>{n.addObserver(t=>e(t))})}},n7=n9(o.Ie()),ie=e=>{let t=n9(e);return(e,r)=>t(e,r).then(e=>{if("Failure"===e._tag)throw Z(e.cause);return e.value})},it=ie(o.Ie()),ir=e=>{let t=n5(e);return e=>{if(th(e))return e;let r=t(e,{scheduler:new _.FG("sync")});return r.currentDispatcher?.flush(),r._exit??(0,$.V2)(new i2(r))}},ii=ir(o.Ie()),ia=e=>{let t=ir(e);return e=>{let r=t(e);if("Failure"===r._tag)throw Z(r.cause);return r.value}},is=ia(o.Ie()),io=eO(!0),il=eO(!1);class ic{waiters=[];scheduled=!1;_isOpen;constructor(e){this._isOpen=e}scheduleUnsafe(e){return this.scheduled||0===this.waiters.length||(this.scheduled=!0,e.currentDispatcher.scheduleTask(this.flushWaiters,0)),io}flushWaiters=()=>{this.scheduled=!1;let e=this.waiters;this.waiters=[];for(let t=0;t<e.length;t++)e[t](tM)};open=(0,$.R6)(e=>this._isOpen?il:(this._isOpen=!0,this.scheduleUnsafe(e)));release=(0,$.R6)(e=>this._isOpen?il:this.scheduleUnsafe(e));openUnsafe(){return!this._isOpen&&(this._isOpen=!0,this.flushWaiters(),!0)}await=eQ(e=>this._isOpen?e(eq):(this.waiters.push(e),eC(()=>{let t=this.waiters.indexOf(e);-1!==t&&this.waiters.splice(t,1)})));closeUnsafe(){return!!this._isOpen&&(this._isOpen=!1,!0)}close=eC(()=>this.closeUnsafe());whenOpen=e=>tu(this.await,()=>e);isOpen(){return this._isOpen}}let iu=e=>new ic(e??!1),id=e=>eC(()=>iu(e)),ih=(0,$.R6)(e=>eO(e.getRef(k.sh))),ip=(0,f.XY)(2,(e,t)=>t0(e,k.sh,t)),im=t0(I.rf),ig=t0(I.nU),iy=BigInt(0),ib={_tag:"Span",spanId:"noop",traceId:"noop",sampled:!1,status:{_tag:"Ended",startTime:iy,endTime:iy,exit:tM},attributes:new Map,links:[],kind:"internal",attribute(){},event(){},end(){},addLinks(){}},iv=e=>e?o.Jt(e.annotations,k.DW)?"Span"===e._tag?iv(g.getOrUndefined(e.parent)):g.none():g.some(e):g.none(),iw=(e,t,r)=>{let n,i=!e.getRef(I.rf)||r?.annotations&&o.Jt(r.annotations,k.DW),a=r?.parent!==void 0?g.some(r.parent):r?.root?g.none():iv(e.currentSpan);if(i){let e;e={name:t,parent:a,annotations:o.WQ(r?.annotations??o.Ie(),k.DW,!0)},n=Object.assign(Object.create(ib),e)}else{let i=e.getRef(k.sh),s=e.getRef(iD),l=e.getRef(I.nU),c=e.getRef(I.ce),u=e.getRef(I.ls),d=r?.level??e.getRef(k.pX),f=r?.links!==void 0?[...u,...r.links]:u.slice();for(let[u,h]of(n=i.span({name:t,parent:a,annotations:r?.annotations??o.Ie(),links:f,startTime:l?s.currentTimeNanosUnsafe():BigInt(0),kind:r?.kind??"internal",root:r?.root??g.isNone(a),sampled:r?.sampled??((!g.isSome(a)||!1!==a.value.sampled)&&!i9(e.getRef(k.EW),d))}),Object.entries(c)))n.attribute(u,h);if(r?.attributes!==void 0)for(let[e,t]of Object.entries(r.attributes))n.attribute(e,t)}return n},ix=(e,t)=>(0,$.R6)(r=>eO(iw(r,e,t))),i_=(e,t)=>nw((0,$.R6)(r=>{let n=o.fp(r.context,rV),i=iw(r,e,t??{}),a=r.getRef(iD),s=r.getRef(I.nU);return e7(r1(n,e=>iO(i,e,a,s)),i)})),ik=function(){let e="string"!=typeof arguments[0],t=e?arguments[1]:arguments[0],r=C(e?arguments[2]:arguments[1]);if(e){let e=arguments[0];return tu(i_(t,r),t=>iC(e,t,r))}return e=>tu(i_(t,r),t=>iC(e,t,r))},iS=I.ce,i$=I.ls,iE=(0,f.XY)(e=>(0,$.yw)(e[0]),(e,t,r={})=>{let n=(Array.isArray(t)?t:[t]).map(e=>({span:e,attributes:r}));return tK(e,I.ls,e=>[...e,...n])}),iO=(e,t,r,n)=>eC(()=>{"Ended"!==e.status._tag&&e.end(n?r.currentTimeNanosUnsafe():iy,t)}),iI=(e,...t)=>{let r=1===t.length?void 0:t[0],n=t[t.length-1];return(0,$.R6)(t=>{let i=iw(t,e,r),a=t.getRef(iD);return ns((0,S.s)(()=>n(i)),e=>eC(()=>{"Ended"!==i.status._tag&&i.end(a.currentTimeNanosUnsafe(),e)}))})},iA=t0(k.Tv),iC=function(){let e=(0,$.yw)(arguments[0]),t=e?arguments[1]:arguments[0],r=e?arguments[2]:arguments[1],n=f.D_;if("Span"===t._tag){var i,a;r=C(r),i=t.name,a="function"==typeof(a=r?.captureStackTrace)?a:f.MN,n=tK(I.vA,e=>({name:i,stack:a,parent:e}))}return e?iA(n(arguments[0]),t):e=>iA(n(e),t)},iT=function(){let e="string"!=typeof arguments[0],t=e?arguments[1]:arguments[0],r=C(arguments[2]);if(e){let e=arguments[0];return iI(t,arguments[2],t=>iC(e,t,r))}let n="function"==typeof arguments[1]?arguments[1]:void 0,i=n?void 0:arguments[1];return(e,...a)=>iI(t,n?n(...a):i,t=>iC(e,t,r))},iN=(0,f.XY)(e=>(0,$.yw)(e[0]),(e,...t)=>tK(e,I.ce,e=>{let r={...e};return 1===t.length?Object.assign(r,t[0]):r[t[0]]=t[1],r})),iM=(...e)=>(0,$.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 eq}),iP=(0,$.R6)(e=>{let t=e.currentSpanLocal;return t?eO(t):eA(new $.Xm)}),ij=(n=k.Tv,(0,$.R6)(e=>e.context.mapUnsafe.has(n.key)?eO(o.fp(e.context,n)):eA(new $.Xm))),iD=o.Or("effect/Clock",{defaultValue:()=>new iR}),iU=0x80000000-1;class iR{currentTimeMillisUnsafe(){return Date.now()}currentTimeMillis=eC(()=>this.currentTimeMillisUnsafe());currentTimeNanosUnsafe(){return iL()}currentTimeNanos=eC(()=>this.currentTimeNanosUnsafe());sleep(e){return this.sleepMillis(l.kE(e))}sleepMillis(e){return e<=0?eD:Number.isFinite(e)?eQ(t=>{let r=e>iU?this.sleepMillis(e-iU):eq,n=setTimeout(()=>t(r),Math.min(e,iU));return eC(()=>clearTimeout(n))}):eZ}}let iF=(a=BigInt(1e6),"u"<typeof performance||void 0===performance.now?()=>BigInt(Date.now())*a:()=>(i??=BigInt(Date.now())*a-BigInt(Math.round(1e6*performance.now())))+BigInt(Math.round(1e6*performance.now()))),iL=function(){let e="object"==typeof process&&"hrtime"in process&&"function"==typeof process.hrtime.bigint?process.hrtime:void 0;if(!e)return iF;let t=BigInt(Date.now())*BigInt(1e6)-e.bigint();return()=>t+e.bigint()}(),iB=e=>(0,$.R6)(t=>e(t.getRef(iD))),iY=e=>iB(t=>t.sleep(l.bN(e))),iq=iB(e=>e.currentTimeMillis),iW=iB(e=>e.currentTimeNanos),iX="~effect/Cause/TimeoutError",iJ=e=>(0,v.i5)(e,iX);class iz extends(0,$.rN)("TimeoutError"){[iX]=iX;constructor(e){super({message:e})}}let iK="~effect/Cause/IllegalArgumentError",iV=e=>(0,v.i5)(e,iK);class iG extends(0,$.rN)("IllegalArgumentError"){[iK]=iK;constructor(e){super({message:e})}}let iH="~effect/Cause/ExceededCapacityError",iQ=e=>(0,v.i5)(e,iH);class iZ extends(0,$.rN)("ExceededCapacityError"){[iH]=iH;constructor(e){super({message:e})}}let i0="~effect/Cause/AsyncFiberError",i1=e=>(0,v.i5)(e,i0);class i2 extends(0,$.rN)("AsyncFiberError"){[i0]=i0;constructor(e){super({message:"An asynchronous Effect was executed with Effect.runSync",fiber:e})}}let i5="~effect/Cause/UnknownError",i3=e=>(0,v.i5)(e,i5);class i6 extends(0,$.rN)("UnknownError"){[i5]=i5;constructor(e,t){super({message:t,cause:e})}}let i8=o.Or("effect/Console/CurrentConsole",{defaultValue:()=>globalThis.console}),i4=y.zQ(y.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}}),i9=y.yJ(i4),i7=o.Or("effect/Loggers/CurrentLoggers",{defaultValue:()=>new Set([as,ao])}),ae=o.Or("effect/Logger/LogToStderr",{defaultValue:f.f4}),at=function(){let e="string"==typeof arguments[0]?[[arguments[0],arguments[1]]]:Object.entries(arguments[0]);return nw((0,$.R6)(t=>{let r=t.getRef(I.iL),n={...r};for(let t=0;t<e.length;t++){let[r,i]=e[t];n[r]=i}return t.setContext(o.WQ(t.context,I.iL,n)),r1(o.fp(t.context,rV),n=>{let i=t.getRef(I.iL),a={...i};for(let t=0;t<e.length;t++){let[n,s]=e[t];i[n]===s&&(n in r?a[n]=r[n]:delete a[n])}return t.setContext(o.WQ(t.context,I.iL,a)),eq})}))},ar={"~effect/Logger":{_Message:f.D_,_Output:f.D_},pipe(){return(0,b.tT)(this,arguments)}},an=e=>{let t=Object.create(ar);return t.log=e,t},ai=(e,t)=>{let r=e[0].replace(/[\s="]/g,"_");return`${r}=${t-e[1]}ms`},aa=e=>(...t)=>{let r;for(let e=0,n=t.length;e<n;e++){let n=t[e];(0,$.Aj)(n)&&(r?t.splice(e,1):t=t.slice(0,e).concat(t.slice(e+1)),r=r?(0,$.b5)(r.reasons.concat(n.reasons)):n,e--)}return void 0===r&&(r=$.DH),(0,$.R6)(n=>{let i=e??n.currentLogLevel;if(i9(n.minimumLogLevel,i))return eq;let a=n.getRef(iD),s=n.getRef(i7);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 eq})},as=an(({cause:e,date:t,fiber:r,logLevel:n,message:i})=>{let a=Array.isArray(i)?i.slice():[i];e.reasons.length>0&&a.push(el(e));let s=t.getTime(),o=r.getRef(I.d8),l="";for(let e of o)l+=` ${ai(e,s)}`;let c=r.getRef(I.iL);Object.keys(c).length>0&&a.push(c);let u=r.getRef(i8);(r.getRef(ae)?u.error:u.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)}),ao=an(({cause:e,fiber:t,logLevel:r,message:n})=>{let i=t.getRef(iD),a=t.getRef(I.iL),s=t.currentSpan;if(void 0===s||"ExternalSpan"===s._tag)return;let o={};for(let[e,t]of Object.entries(a))o[e]=t;o["effect.fiberId"]=t.id,o["effect.logLevel"]=r.toUpperCase(),e.reasons.length>0&&(o["effect.cause"]=el(e)),s.event((0,p.ZK)(Array.isArray(n)&&1===n.length?n[0]:n),i.currentTimeNanosUnsafe(),o)}),al=eO(void 0),ac=(0,f.XY)(e=>(0,$.yw)(e[0]),(e,t)=>nu(e,e=>(0,$.R6)(r=>(au(r,e,t?.defectsOnly),eq)))),au=(e,t,r)=>{let n=e.getRef(I.oQ);if(0===n.size||r&&!L(t))return;let i={cause:t,fiber:e,timestamp:e.getRef(iD).currentTimeNanosUnsafe()};n.forEach(e=>e.report(i))}},6516(e,t,r){let n=new WeakSet;r.d(t,{},{J:n,X: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}})},9354(e,t,r){r.d(t,{},{F:"effect/observability/Metric/FiberRuntimeMetricsKey"})},5091(e,t,r){var n=r(8036),i=r(6470),a=r(4450),s=r(6400),o=r(5369),l=r(3537),c=r(8433);let u="~effect/data/Option",d={[u]:{_A:e=>e},...c.fU,[Symbol.iterator](){return new l.B(this)}},f=Object.defineProperty(Object.assign(Object.create(d),{_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}}),h=a.tW("None"),p=Object.assign(Object.create(d),{_tag:"None",_op:"None",valueOrUndefined:void 0,[n.HR]:e=>m(e)&&g(e),[a.HR]:()=>h,toString:()=>"none()",toJSON(){return{_id:"Option",_tag:this._tag}}}),m=e=>(0,o.i5)(e,u),g=e=>"None"===e._tag,y=e=>"Some"===e._tag,b=Object.create(p);r.d(t,{},{$I:g,Ru:y,dv:b,oL:m,zN:e=>{let t=Object.create(f);return t.value=e,t}})},8344(e,t,r){var n=r(8619),i=r(4650);let a=n.Or("effect/References/CurrentConcurrency",{defaultValue:()=>"unbounded"}),s=n.Or("effect/ErrorReporter/CurrentErrorReporters",{defaultValue:()=>new Set}),o=n.Or("effect/References/CurrentStackFrame",{defaultValue:i.MN}),l=n.Or("effect/References/TracerEnabled",{defaultValue:i.ue}),c=n.Or("effect/References/TracerTimingEnabled",{defaultValue:i.ue}),u=n.Or("effect/References/TracerSpanAnnotations",{defaultValue:()=>({})}),d=n.Or("effect/References/TracerSpanLinks",{defaultValue:()=>[]}),f=n.Or("effect/References/CurrentLogAnnotations",{defaultValue:()=>({})}),h=n.Or("effect/References/CurrentLogLevel",{defaultValue:()=>"Info"}),p=n.Or("effect/References/MinimumLogLevel",{defaultValue:()=>"Info"}),m=n.Or("effect/References/UnhandledLogLevel",{defaultValue:()=>"Error"}),g=n.Or("effect/References/CurrentLogSpans",{defaultValue:()=>[]});r.d(t,{},{F8:a,Gl:h,aG:m,ce:u,d8:g,iL:f,ls:d,nU:c,oQ:s,rf:l,vA:o,zQ:p})},4403(e,t,r){var n=r(8036),i=r(6470),a=r(4650),s=r(4450),o=r(6400),l=r(5369),c=r(3537),u=r(8433),d=r(5091);let f="~effect/data/Result",h={[f]:{_A:e=>e,_E:e=>e},...u.fU,[Symbol.iterator](){return new c.B(this)}},p=Object.assign(Object.create(h),{_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(h),{_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=e=>{let t=Object.create(m);return t.failure=e,t},w=e=>{let t=Object.create(p);return t.success=e,t},x=(0,a.XY)(2,(e,t)=>d.$I(e)?v(t()):w(e.value));r.d(t,{},{L8:e=>b(e)?d.dv:d.zN(e.failure),N6:y,Oz:e=>y(e)?d.dv:d.zN(e.success),Py:w,aI:g,fJ:v,oJ:b,sV:x})},4888(e,t,r){var n=r(4650);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=a("identifier"),o=a("title"),l=a("description"),c=(0,n.Bj)(e=>{let t=s(e);return"string"==typeof t?t:e.getExpected(c)});r.d(t,{hd:()=>i,ip:()=>a},{DQ:o,KE:s,Pk:l,bo:c})},8045(e,t,r){var n=r(8543),i=r(6030);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})},3628(e,t,r){let n,i=Object.getOwnPropertyDescriptor,a=Object.prototype.hasOwnProperty,s=Object.isExtensible,o=void 0===(n=i(Error,"stackTraceLimit"))?s(Error):a.call(n,"writable")?!0===n.writable:void 0!==n.set;r.d(t,{},{ft:e=>{o&&(Error.stackTraceLimit=e)},jt:()=>Error.stackTraceLimit})},1580(e,t,r){let n="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function i(e,t,r){let n=r[0];if(null!=t&&e>=t)throw Error(e+" >= "+t);if(e.slice(-1)===n||t&&t.slice(-1)===n)throw Error("trailing zero");if(t){let a=0;for(;(e[a]||n)===t[a];)a++;if(a>0)return t.slice(0,a)+i(e.slice(a),t.slice(a),r)}let a=e?r.indexOf(e[0]):0,s=null!=t?r.indexOf(t[0]):r.length;return s-a>1?r[Math.round(.5*(a+s))]:t&&t.length>1?t.slice(0,1):r[a]+i(e.slice(1),null,r)}function a(e){if(e.length!==s(e[0]))throw Error("invalid integer part of order key: "+e)}function s(e){if(e>="a"&&e<="z")return e.charCodeAt(0)-97+2;if(e>="A"&&e<="Z")return 90-e.charCodeAt(0)+2;throw Error("invalid order key head: "+e)}function o(e){let t=s(e[0]);if(t>e.length)throw Error("invalid order key: "+e);return e.slice(0,t)}function l(e,t){if(e==="A"+t[0].repeat(26))throw Error("invalid order key: "+e);let r=o(e);if(e.slice(r.length).slice(-1)===t[0])throw Error("invalid order key: "+e)}function c(e,t){a(e);let[r,...n]=e.split(""),i=!0;for(let e=n.length-1;i&&e>=0;e--){let r=t.indexOf(n[e])+1;r===t.length?n[e]=t[0]:(n[e]=t[r],i=!1)}if(!i)return r+n.join("");{if("Z"===r)return"a"+t[0];if("z"===r)return null;let e=String.fromCharCode(r.charCodeAt(0)+1);return e>"a"?n.push(t[0]):n.pop(),e+n.join("")}}function u(e,t,r=n){if(null!=e&&l(e,r),null!=t&&l(t,r),null!=e&&null!=t&&e>=t)throw Error(e+" >= "+t);if(null==e){if(null==t)return"a"+r[0];let e=o(t),n=t.slice(e.length);if(e==="A"+r[0].repeat(26))return e+i("",n,r);if(e<t)return e;let s=function(e,t){a(e);let[r,...n]=e.split(""),i=!0;for(let e=n.length-1;i&&e>=0;e--){let r=t.indexOf(n[e])-1;-1===r?n[e]=t.slice(-1):(n[e]=t[r],i=!1)}if(!i)return r+n.join("");{if("a"===r)return"Z"+t.slice(-1);if("A"===r)return null;let e=String.fromCharCode(r.charCodeAt(0)-1);return e<"Z"?n.push(t.slice(-1)):n.pop(),e+n.join("")}}(e,r);if(null==s)throw Error("cannot decrement any more");return s}if(null==t){let t=o(e),n=e.slice(t.length),a=c(t,r);return null==a?t+i(n,null,r):a}let s=o(e),d=e.slice(s.length),f=o(t),h=t.slice(f.length);if(s===f)return s+i(d,h,r);let p=c(s,r);if(null==p)throw Error("cannot increment any more");return p<t?p:s+i(d,null,r)}r.d(t,{TU:()=>u,YT:()=>function e(t,r,i,a=n){if(0===i)return[];if(1===i)return[u(t,r,a)];if(null==r){let e=u(t,r,a),n=[e];for(let t=0;t<i-1;t++)n.push(e=u(e,r,a));return n}if(null==t){let e=u(t,r,a),n=[e];for(let r=0;r<i-1;r++)n.push(e=u(t,e,a));return n.reverse(),n}let s=Math.floor(i/2),o=u(t,r,a);return[...e(t,o,s,a),o,...e(o,r,i-s-1,a)]}})},8689(e,t,r){let n,i,a,s,o;function l(e){let t=e.length;for(;--t>=0;)e[t]=0}let c=573,u=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]),d=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]),h=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),p=Array(576);l(p);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 w(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 _=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)},$=(e,t,r)=>{S(e,r[2*t],r[2*t+1])},E=(e,t)=>{let r=0;do r|=1&e,e>>>=1,r<<=1;while(--t>0)return r>>>1},O=(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]=E(a[t]++,t))}},I=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},A=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},C=(e,t,r,n)=>{let i=2*t,a=2*r;return e[i]<e[a]||e[i]===e[a]&&n[t]<=n[r]},T=(e,t,r)=>{let n=e.heap[r],i=r<<1;for(;i<=e.heap_len&&(i<e.heap_len&&C(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!C(t,n,e.heap[i],e.depth));)e.heap[r]=e.heap[i],r=i,i<<=1;e.heap[r]=n},N=(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?$(e,i,t):($(e,(a=y[i])+256+1,t),0!==(s=u[a])&&S(e,i-=b[a],s),$(e,a=_(--n),r),0!==(s=d[a])&&S(e,n-=v[a],s));while(o<e.last_lit)$(e,256,t)},M=(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,u=-1;for(e.heap_len=0,e.heap_max=c,r=0;r<l;r++)0!==a[2*r]?(e.heap[++e.heap_len]=u=r,e.depth[r]=0):a[2*r+1]=0;for(;e.heap_len<2;)a[2*(i=e.heap[++e.heap_len]=u<2?++u:0)]=1,e.depth[i]=0,e.opt_len--,o&&(e.static_len-=s[2*i+1]);for(t.max_code=u,r=e.heap_len>>1;r>=1;r--)T(e,a,r);i=l;do r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],T(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++,T(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,u=t.max_code,d=t.stat_desc.static_tree,f=t.stat_desc.has_stree,h=t.stat_desc.extra_bits,p=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<c;r++)(a=l[2*l[2*(n=e.heap[r])+1]+1]+1)>m&&(a=m,g++),l[2*n+1]=a,!(n>u)&&(e.bl_count[a]++,s=0,n>=p&&(s=h[n-p]),o=l[2*n],e.opt_len+=o*(a+s),f&&(e.static_len+=o*(d[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])>u)&&(l[2*i+1]!==a&&(e.opt_len+=(a-l[2*i+1])*l[2*i],l[2*i+1]=a),n--)}})(e,t),O(a,u,e.bl_count)},P=(e,t,r)=>{let n,i,a=-1,s=t[1],o=0,l=7,c=4;for(0===s&&(l=138,c=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<c?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,c=3):i===s?(l=6,c=3):(l=7,c=4))},j=(e,t,r)=>{let n,i,a=-1,s=t[1],o=0,l=7,c=4;for(0===s&&(l=138,c=3),n=0;n<=r;n++)if(i=s,s=t[(n+1)*2+1],!(++o<l)||i!==s){if(o<c)do $(e,i,e.bl_tree);while(0!=--o)else 0!==i?(i!==a&&($(e,i,e.bl_tree),o--),$(e,16,e.bl_tree),S(e,o-3,2)):o<=10?($(e,17,e.bl_tree),S(e,o-3,3)):($(e,18,e.bl_tree),S(e,o-11,7));o=0,a=i,0===s?(l=138,c=3):i===s?(l=6,c=3):(l=7,c=4)}},D=!1,U=(e,t,r,n)=>{S(e,0+ +!!n,3),A(e),k(e,r),k(e,~r),e.pending_buf.set(e.window.subarray(t,t+r),e.pending),e.pending+=r};var R={_tr_init:e=>{D||((()=>{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<<u[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<<d[s];e++)g[o++]=s;for(o>>=7;s<30;s++)for(v[s]=o<<7,e=0;e<1<<d[s]-7;e++)g[256+o++]=s;for(t=0;t<=15;t++)l[t]=0;for(e=0;e<=143;)p[2*e+1]=8,e++,l[8]++;for(;e<=255;)p[2*e+1]=9,e++,l[9]++;for(;e<=279;)p[2*e+1]=7,e++,l[7]++;for(;e<=287;)p[2*e+1]=8,e++,l[8]++;for(O(p,287,l),e=0;e<30;e++)m[2*e+1]=5,m[2*e]=E(e,5);n=new w(p,u,257,286,15),i=new w(m,d,0,30,15),a=new w([],f,0,19,7)})(),D=!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,I(e)},_tr_stored_block:U,_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)),M(e,e.l_desc),M(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),M(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*h[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?U(e,t,r,n):4===e.strategy||a===i?(S(e,2+ +!!n,3),N(e,p,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*h[i]+1],3);j(e,e.dyn_ltree,t-1),j(e,e.dyn_dtree,r-1)})(e,e.l_desc.max_code+1,e.d_desc.max_code+1,s+1),N(e,e.dyn_ltree,e.dyn_dtree)),I(e),n&&A(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*_(t)]++),e.last_lit===e.lit_bufsize-1),_tr_align:e=>{S(e,2,3),$(e,256,p),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 L=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 B=(e,t,r,n)=>{let i=n+r;e^=-1;for(let r=n;r<i;r++)e=e>>>8^L[(e^t[r])&255];return -1^e},Y={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"},q={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:W,_tr_stored_block:X,_tr_flush_block:J,_tr_tally:z,_tr_align:K}=R,{Z_NO_FLUSH:V,Z_PARTIAL_FLUSH:G,Z_FULL_FLUSH:H,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:ec,Z_DEFAULT_STRATEGY:eu,Z_UNKNOWN:ed,Z_DEFLATED:ef}=q,eh=573,ep=(e,t)=>(e.msg=Y[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)=>{J(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,eb(e.strm)},ew=(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},e_=(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=B(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,c=e.window,u=e.w_mask,d=e.prev,f=e.strstart+258,h=c[a+s-1],p=c[a+s];e.prev_length>=e.good_match&&(i>>=2),o>e.lookahead&&(o=e.lookahead);do{if(c[(r=t)+s]!==p||c[r+s-1]!==h||c[r]!==c[a]||c[++r]!==c[a+1])continue;a+=2,r++;do;while(c[++a]===c[++r]&&c[++a]===c[++r]&&c[++a]===c[++r]&&c[++a]===c[++r]&&c[++a]===c[++r]&&c[++a]===c[++r]&&c[++a]===c[++r]&&c[++a]===c[++r]&&a<f)if(n=258-(f-a),a=f-258,n>s){if(e.match_start=t,s=n,n>=o)break;h=c[a+s-1],p=c[a+s]}}while((t=d[t&u])>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=e_(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)},e$=(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=z(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=z(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},eE=(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=z(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=z(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=z(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 eO(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 eI=[new eO(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 eO(4,4,8,4,e$),new eO(4,5,16,8,e$),new eO(4,6,32,32,e$),new eO(4,4,16,16,eE),new eO(8,16,32,32,eE),new eO(8,16,128,128,eE),new eO(8,32,128,256,eE),new eO(32,128,258,1024,eE),new eO(32,258,258,4096,eE)];function eA(){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*eh),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 eC=(e,t)=>{let r,n;if(!e||!e.state||t>Z||t<0)return e?ep(e,er):er;let i=e.state;if(!e.output||!e.input&&0!==e.avail_in||666===i.status&&t!==Q)return ep(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,ew(i,31),ew(i,139),ew(i,8),i.gzhead?(ew(i,+!!i.gzhead.text+2*!!i.gzhead.hcrc+4*!!i.gzhead.extra+8*!!i.gzhead.name+16*!!i.gzhead.comment),ew(i,255&i.gzhead.time),ew(i,i.gzhead.time>>8&255),ew(i,i.gzhead.time>>16&255),ew(i,i.gzhead.time>>24&255),ew(i,9===i.level?2:4*(i.strategy>=eo||i.level<2)),ew(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(ew(i,255&i.gzhead.extra.length),ew(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=B(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(ew(i,0),ew(i,0),ew(i,0),ew(i,0),ew(i,0),ew(i,9===i.level?2:4*(i.strategy>=eo||i.level<2)),ew(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=B(e.adler,i.pending_buf,i.pending-r,r)),eb(e),r=i.pending,i.pending!==i.pending_buf_size));)ew(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>r&&(e.adler=B(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=B(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,ew(i,n)}while(0!==n)i.gzhead.hcrc&&i.pending>r&&(e.adler=B(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=B(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,ew(i,n)}while(0!==n)i.gzhead.hcrc&&i.pending>r&&(e.adler=B(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&&(ew(i,255&e.adler),ew(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 ep(e,ei);if(666===i.status&&0!==e.avail_in)return ep(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=z(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=z(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=z(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):eI[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===G?K(i):t!==Z&&(X(i,0,0,!1),t===H&&(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?(ew(i,255&e.adler),ew(i,e.adler>>8&255),ew(i,e.adler>>16&255),ew(i,e.adler>>24&255),ew(i,255&e.total_in),ew(i,e.total_in>>8&255),ew(i,e.total_in>>16&255),ew(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)},eT=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?ep(e,er):(e.state=null,113===t?ep(e,en):ee)};let eN=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var eM=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)eN(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 ej=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){ej=!1}let eD=new Uint8Array(256);for(let e=0;e<256;e++)eD[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;eD[254]=eD[254]=1;var eU=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},eR=(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=eD[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&&ej)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+eD[e[r]]>t?r:t},eL=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 eB=Object.prototype.toString,{Z_NO_FLUSH:eY,Z_SYNC_FLUSH:eq,Z_FULL_FLUSH:eW,Z_FINISH:eX,Z_OK:eJ,Z_STREAM_END:ez,Z_DEFAULT_COMPRESSION:eK,Z_DEFAULT_STRATEGY:eV,Z_DEFLATED:eG}=q;function eH(e){let t,r;this.options=eM({level:eK,method:eG,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 eL,this.strm.avail_out=0;let i=((e,t,r,n,i,a)=>{var s,o;let l;if(!e)return er;let c=1;if(t===ea&&(t=6),n<0?(c=0,n=-n):n>15&&(c=2,n-=16),i<1||i>9||r!==ef||n<8||n>15||t<0||t>9||a<0||a>ec)return ep(e,er);8===n&&(n=9);let u=new eA;return e.state=u,u.strm=e,u.wrap=c,u.gzhead=null,u.w_bits=n,u.w_size=1<<u.w_bits,u.w_mask=u.w_size-1,u.hash_bits=i+7,u.hash_size=1<<u.hash_bits,u.hash_mask=u.hash_size-1,u.hash_shift=~~((u.hash_bits+3-1)/3),u.window=new Uint8Array(2*u.w_size),u.head=new Uint16Array(u.hash_size),u.prev=new Uint16Array(u.w_size),u.lit_bufsize=1<<i+6,u.pending_buf_size=4*u.lit_bufsize,u.pending_buf=new Uint8Array(u.pending_buf_size),u.d_buf=+u.lit_bufsize,u.l_buf=3*u.lit_bufsize,u.level=t,u.strategy=a,u.method=r,(l=(e=>{if(!e||!e.state)return ep(e,er);e.total_in=e.total_out=0,e.data_type=ed;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,W(t),ee})(s=e))===ee&&((o=s.state).window_size=2*o.w_size,eg(o.head),o.max_lazy_match=eI[o.level].max_lazy,o.good_match=eI[o.level].good_length,o.nice_match=eI[o.level].nice_length,o.max_chain_length=eI[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!==eJ)throw Error(Y[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?eU(n.dictionary):"[object ArrayBuffer]"===eB.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))!==eJ)throw Error(Y[i]);this._dict_set=!0}}function eQ(e,t){let r=new eH(t);if(r.push(e,!0),r.err)throw r.msg||Y[r.err];return r.result}eH.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?eX:eY,"string"==typeof e?i.input=eU(e):"[object ArrayBuffer]"===eB.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===eq||n===eW)&&i.avail_out<=6){this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;continue}if((r=eC(i,n))===ez)return i.next_out>0&&this.onData(i.output.subarray(0,i.next_out)),r=eT(this.strm),this.onEnd(r),this.ended=!0,r===eJ;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},eH.prototype.onData=function(e){this.chunks.push(e)},eH.prototype.onEnd=function(e){e===eJ&&(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,c,u,d,f,h,p,m,g,y,b,v,w,x,_,k,S,$,E=e.state;r=e.next_in,S=e.input,n=r+(e.avail_in-5),i=e.next_out,$=e.output,a=i-(t-e.avail_out),s=i+(e.avail_out-257),o=E.dmax,l=E.wsize,c=E.whave,u=E.wnext,d=E.window,f=E.hold,h=E.bits,p=E.lencode,m=E.distcode,g=(1<<E.lenbits)-1,y=(1<<E.distbits)-1;t:do for(h<15&&(f+=S[r++]<<h,h+=8,f+=S[r++]<<h,h+=8),b=p[f&g];;){if(f>>>=v=b>>>24,h-=v,0==(v=b>>>16&255))$[i++]=65535&b;else if(16&v)for(w=65535&b,(v&=15)&&(h<v&&(f+=S[r++]<<h,h+=8),w+=f&(1<<v)-1,f>>>=v,h-=v),h<15&&(f+=S[r++]<<h,h+=8,f+=S[r++]<<h,h+=8),b=m[f&y];;){if(f>>>=v=b>>>24,h-=v,16&(v=b>>>16&255)){if(x=65535&b,h<(v&=15)&&(f+=S[r++]<<h,(h+=8)<v&&(f+=S[r++]<<h,h+=8)),(x+=f&(1<<v)-1)>o){e.msg="invalid distance too far back",E.mode=30;break t}if(f>>>=v,h-=v,x>(v=i-a)){if((v=x-v)>c&&E.sane){e.msg="invalid distance too far back",E.mode=30;break t}if(_=0,k=d,0===u){if(_+=l-v,v<w){w-=v;do $[i++]=d[_++];while(--v)_=i-x,k=$}}else if(u<v){if(_+=l+u-v,(v-=u)<w){w-=v;do $[i++]=d[_++];while(--v)if(_=0,u<w){w-=v=u;do $[i++]=d[_++];while(--v)_=i-x,k=$}}}else if(_+=u-v,v<w){w-=v;do $[i++]=d[_++];while(--v)_=i-x,k=$}for(;w>2;)$[i++]=k[_++],$[i++]=k[_++],$[i++]=k[_++],w-=3;w&&($[i++]=k[_++],w>1&&($[i++]=k[_++]))}else{_=i-x;do $[i++]=$[_++],$[i++]=$[_++],$[i++]=$[_++],w-=3;while(w>2)w&&($[i++]=$[_++],w>1&&($[i++]=$[_++]))}}else if((64&v)==0){b=m[(65535&b)+(f&(1<<v)-1)];continue}else{e.msg="invalid distance code",E.mode=30;break t}break}else if((64&v)==0){b=p[(65535&b)+(f&(1<<v)-1)];continue}else if(32&v){E.mode=12;break t}else{e.msg="invalid literal/length code",E.mode=30;break t}break}while(r<n&&i<s)r-=w=h>>3,h-=w<<3,f&=(1<<h)-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),E.hold=f,E.bits=h};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,c,u,d,f,h,p,m,g,y=o.bits,b=0,v=0,w=0,x=0,_=0,k=0,S=0,$=0,E=0,O=0,I=null,A=0,C=new Uint16Array(16),T=new Uint16Array(16),N=null,M=0;for(b=0;b<=15;b++)C[b]=0;for(v=0;v<n;v++)C[t[r+v]]++;for(_=y,x=15;x>=1&&0===C[x];x--);if(_>x&&(_=x),0===x)return i[a++]=0x1400000,i[a++]=0x1400000,o.bits=1,0;for(w=1;w<x&&0===C[w];w++);for(_<w&&(_=w),$=1,b=1;b<=15;b++)if($<<=1,($-=C[b])<0)return -1;if($>0&&(0===e||1!==x))return -1;for(T[1]=0,b=1;b<15;b++)T[b+1]=T[b]+C[b];for(v=0;v<n;v++)0!==t[r+v]&&(s[T[t[r+v]]++]=v);if(0===e?(I=N=s,h=19):1===e?(I=e0,A-=257,N=e1,M-=257,h=256):(I=e2,N=e5,h=-1),O=0,v=0,b=w,f=a,k=_,S=0,u=-1,d=(E=1<<_)-1,1===e&&E>852||2===e&&E>592)return 1;for(;;){p=b-S,s[v]<h?(m=0,g=s[v]):s[v]>h?(m=N[M+s[v]],g=I[A+s[v]]):(m=96,g=0),l=1<<b-S,w=c=1<<k;do i[f+(O>>S)+(c-=l)]=p<<24|m<<16|g;while(0!==c)for(l=1<<b-1;O&l;)l>>=1;if(0!==l?(O&=l-1,O+=l):O=0,v++,0==--C[b]){if(b===x)break;b=t[r+s[v]]}if(b>_&&(O&d)!==u){for(0===S&&(S=_),f+=w,$=1<<(k=b-S);k+S<x&&!(($-=C[k+S])<=0);)k++,$<<=1;if(E+=1<<k,1===e&&E>852||2===e&&E>592)return 1;i[u=O&d]=_<<24|k<<16|f-a}}return 0!==O&&(i[f+O]=b-S<<24|4194304),o.bits=_,0};let{Z_FINISH:e6,Z_BLOCK:e8,Z_TREES:e4,Z_OK:e9,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}=q,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,e9})(e)},tc=!0,tu=e=>{if(tc){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}),tc=!1}e.lencode=s,e.lenbits=9,e.distcode=o,e.distbits=5},td=(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,c,u,d,f,h,p,m,g,y,b,v,w,x,_,k,S,$,E=0,O=new Uint8Array(4),I=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,c=r.hold,u=r.bits,d=o,f=l,k=e9;r:for(;;)switch(r.mode){case 1:if(0===r.wrap){r.mode=13;break}for(;u<16;){if(0===o)break r;o--,c+=n[a++]<<u,u+=8}if(2&r.wrap&&35615===c){r.check=0,O[0]=255&c,O[1]=c>>>8&255,r.check=B(r.check,O,2,0),c=0,u=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&c)<<8)+(c>>8))%31){e.msg="incorrect header check",r.mode=30;break}if((15&c)!==ta){e.msg="unknown compression method",r.mode=30;break}if(c>>>=4,u-=4,_=(15&c)+8,0===r.wbits)r.wbits=_;else if(_>r.wbits){e.msg="invalid window size",r.mode=30;break}r.dmax=1<<r.wbits,e.adler=r.check=1,r.mode=512&c?10:12,c=0,u=0;break;case 2:for(;u<16;){if(0===o)break r;o--,c+=n[a++]<<u,u+=8}if(r.flags=c,(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=c>>8&1),512&r.flags&&(O[0]=255&c,O[1]=c>>>8&255,r.check=B(r.check,O,2,0)),c=0,u=0,r.mode=3;case 3:for(;u<32;){if(0===o)break r;o--,c+=n[a++]<<u,u+=8}r.head&&(r.head.time=c),512&r.flags&&(O[0]=255&c,O[1]=c>>>8&255,O[2]=c>>>16&255,O[3]=c>>>24&255,r.check=B(r.check,O,4,0)),c=0,u=0,r.mode=4;case 4:for(;u<16;){if(0===o)break r;o--,c+=n[a++]<<u,u+=8}r.head&&(r.head.xflags=255&c,r.head.os=c>>8),512&r.flags&&(O[0]=255&c,O[1]=c>>>8&255,r.check=B(r.check,O,2,0)),c=0,u=0,r.mode=5;case 5:if(1024&r.flags){for(;u<16;){if(0===o)break r;o--,c+=n[a++]<<u,u+=8}r.length=c,r.head&&(r.head.extra_len=c),512&r.flags&&(O[0]=255&c,O[1]=c>>>8&255,r.check=B(r.check,O,2,0)),c=0,u=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&((h=r.length)>o&&(h=o),h&&(r.head&&(_=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+h),_)),512&r.flags&&(r.check=B(r.check,n,h,a)),o-=h,a+=h,r.length-=h),r.length))break r;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(0===o)break r;h=0;do _=n[a+h++],r.head&&_&&r.length<65536&&(r.head.name+=String.fromCharCode(_));while(_&&h<o)if(512&r.flags&&(r.check=B(r.check,n,h,a)),o-=h,a+=h,_)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;h=0;do _=n[a+h++],r.head&&_&&r.length<65536&&(r.head.comment+=String.fromCharCode(_));while(_&&h<o)if(512&r.flags&&(r.check=B(r.check,n,h,a)),o-=h,a+=h,_)break r}else r.head&&(r.head.comment=null);r.mode=9;case 9:if(512&r.flags){for(;u<16;){if(0===o)break r;o--,c+=n[a++]<<u,u+=8}if(c!==(65535&r.check)){e.msg="header crc mismatch",r.mode=30;break}c=0,u=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(;u<32;){if(0===o)break r;o--,c+=n[a++]<<u,u+=8}e.adler=r.check=ts(c),c=0,u=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=c,r.bits=u,te;e.adler=r.check=1,r.mode=12;case 12:if(t===e8||t===e4)break r;case 13:if(r.last){c>>>=7&u,u-=7&u,r.mode=27;break}for(;u<3;){if(0===o)break r;o--,c+=n[a++]<<u,u+=8}switch(r.last=1&c,u-=1,3&(c>>>=1)){case 0:r.mode=14;break;case 1:if(tu(r),r.mode=20,t===e4){c>>>=2,u-=2;break r}break;case 2:r.mode=17;break;case 3:e.msg="invalid block type",r.mode=30}c>>>=2,u-=2;break;case 14:for(c>>>=7&u,u-=7&u;u<32;){if(0===o)break r;o--,c+=n[a++]<<u,u+=8}if((65535&c)!=(c>>>16^65535)){e.msg="invalid stored block lengths",r.mode=30;break}if(r.length=65535&c,c=0,u=0,r.mode=15,t===e4)break r;case 15:r.mode=16;case 16:if(h=r.length){if(h>o&&(h=o),h>l&&(h=l),0===h)break r;i.set(n.subarray(a,a+h),s),o-=h,a+=h,l-=h,s+=h,r.length-=h;break}r.mode=12;break;case 17:for(;u<14;){if(0===o)break r;o--,c+=n[a++]<<u,u+=8}if(r.nlen=(31&c)+257,u-=5,r.ndist=(31&(c>>>=5))+1,u-=5,r.ncode=(15&(c>>>=5))+4,c>>>=4,u-=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(;u<3;){if(0===o)break r;o--,c+=n[a++]<<u,u+=8}r.lens[I[r.have++]]=7&c,c>>>=3,u-=3}for(;r.have<19;)r.lens[I[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=(E=r.lencode[c&(1<<r.lenbits)-1])>>>24,y=E>>>16&255,b=65535&E,!(g<=u);){if(0===o)break r;o--,c+=n[a++]<<u,u+=8}if(b<16)c>>>=g,u-=g,r.lens[r.have++]=b;else{if(16===b){for($=g+2;u<$;){if(0===o)break r;o--,c+=n[a++]<<u,u+=8}if(c>>>=g,u-=g,0===r.have){e.msg="invalid bit length repeat",r.mode=30;break}_=r.lens[r.have-1],h=3+(3&c),c>>>=2,u-=2}else if(17===b){for($=g+3;u<$;){if(0===o)break r;o--,c+=n[a++]<<u,u+=8}c>>>=g,u-=g,_=0,h=3+(7&c),c>>>=3,u-=3}else{for($=g+7;u<$;){if(0===o)break r;o--,c+=n[a++]<<u,u+=8}c>>>=g,u-=g,_=0,h=11+(127&c),c>>>=7,u-=7}if(r.have+h>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=30;break}for(;h--;)r.lens[r.have++]=_}}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===e4)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=c,r.bits=u,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,c=r.hold,u=r.bits,12===r.mode&&(r.back=-1);break}for(r.back=0;g=(E=r.lencode[c&(1<<r.lenbits)-1])>>>24,y=E>>>16&255,b=65535&E,!(g<=u);){if(0===o)break r;o--,c+=n[a++]<<u,u+=8}if(y&&(240&y)==0){for(v=g,w=y,x=b;g=(E=r.lencode[x+((c&(1<<v+w)-1)>>v)])>>>24,y=E>>>16&255,b=65535&E,!(v+g<=u);){if(0===o)break r;o--,c+=n[a++]<<u,u+=8}c>>>=v,u-=v,r.back+=v}if(c>>>=g,u-=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($=r.extra;u<$;){if(0===o)break r;o--,c+=n[a++]<<u,u+=8}r.length+=c&(1<<r.extra)-1,c>>>=r.extra,u-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;g=(E=r.distcode[c&(1<<r.distbits)-1])>>>24,y=E>>>16&255,b=65535&E,!(g<=u);){if(0===o)break r;o--,c+=n[a++]<<u,u+=8}if((240&y)==0){for(v=g,w=y,x=b;g=(E=r.distcode[x+((c&(1<<v+w)-1)>>v)])>>>24,y=E>>>16&255,b=65535&E,!(v+g<=u);){if(0===o)break r;o--,c+=n[a++]<<u,u+=8}c>>>=v,u-=v,r.back+=v}if(c>>>=g,u-=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($=r.extra;u<$;){if(0===o)break r;o--,c+=n[a++]<<u,u+=8}r.offset+=c&(1<<r.extra)-1,c>>>=r.extra,u-=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(h=f-l,r.offset>h){if((h=r.offset-h)>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=30;break}h>r.wnext?(h-=r.wnext,p=r.wsize-h):p=r.wnext-h,h>r.length&&(h=r.length),m=r.window}else m=i,p=s-r.offset,h=r.length;h>l&&(h=l),l-=h,r.length-=h;do i[s++]=m[p++];while(--h)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(;u<32;){if(0===o)break r;o--,c|=n[a++]<<u,u+=8}if(f-=l,e.total_out+=f,r.total+=f,f&&(e.adler=r.check=r.flags?B(r.check,i,f,s-f):F(r.check,i,f,s-f)),f=l,(r.flags?c:ts(c))!==r.check){e.msg="incorrect data check",r.mode=30;break}c=0,u=0}r.mode=28;case 28:if(r.wrap&&r.flags){for(;u<32;){if(0===o)break r;o--,c+=n[a++]<<u,u+=8}if(c!==(0|r.total)){e.msg="incorrect length check",r.mode=30;break}c=0,u=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=c,r.bits=u,(r.wsize||f!==e.avail_out&&r.mode<30&&(r.mode<27||t!==e6))&&td(e,e.output,e.next_out,f-e.avail_out),d-=e.avail_in,f-=e.avail_out,e.total_in+=d,e.total_out+=f,r.total+=f,r.wrap&&f&&(e.adler=r.check=r.flags?B(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===d&&0===f||t===e6)&&k===e9&&(k=ti),k},th=e=>{if(!e||!e.state)return tt;let t=e.state;return t.window&&(t.window=null),e.state=null,e9},tp=(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:td(e,t,n,n)?(r.mode=31,tn):(r.havedict=1,e9):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:tw,Z_NEED_DICT:tx,Z_STREAM_ERROR:t_,Z_DATA_ERROR:tk,Z_MEM_ERROR:tS}=q;function t$(e){this.options=eM({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 eL,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!==e9&&(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=eU(t.dictionary):"[object ArrayBuffer]"===tg.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw)&&(r=tp(this.strm,t.dictionary))!==tv))throw Error(Y[r])}function tE(e,t){let r=new t$(t);if(r.push(e),r.err)throw r.msg||Y[r.err];return r.result}t$.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=tp(a,o))===tv?r=tf(a,n):r===tk&&(r=tx));a.avail_in>0&&r===tw&&a.state.wrap>0&&0!==e[a.next_in];)tl(a),r=tf(a,n);switch(r){case t_: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===tw))if("string"===this.options.to){let e=eF(a.output,a.next_out),t=a.next_out-e,r=eR(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===tw)return r=th(this.strm),this.onEnd(r),this.ended=!0,!0;if(0===a.avail_in)break}}return!0},t$.prototype.onData=function(e){this.chunks.push(e)},t$.prototype.onEnd=function(e){e===tv&&("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:tO,deflate:tI,deflateRaw:tA,gzip:tC}={Deflate:eH,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:q},{Inflate:tT,inflate:tN,inflateRaw:tM,ungzip:tP}={Inflate:t$,inflate:tE,inflateRaw:function(e,t){return(t=t||{}).raw=!0,tE(e,t)},ungzip:tE,constants:q};r.d(t,{Gy:()=>tO,Kc:()=>tI,UD:()=>tN})},5810(e,t,r){let n;r.d(t,{Er:()=>t5,Ov:()=>rm,Tx:()=>r_,UA:()=>nV,yE:()=>tR,Ky:()=>e4,e5:()=>t$,Uh:()=>tP,OF:()=>iY,XV:()=>iL,r8:()=>iB,rR:()=>nG});var i=r(8861),a=r(8619),s=r(7720),o=r(190),l=r(5089),c=r(9177),u=r(6030),d=r(3833),f=r(995),h=r(4858),p=r(6310);let m=i.ukk,g=i.mSG(i.QfV,i.$r1),y=Object.freeze({paper:"#f6f1e7",card:"#fffdf8",ink:"#1a1712",accent:"#8f707f"}),b=Object.freeze({accentColor:y.accent,backgroundColor:y.card});function v(e,t){return e.pipe(i.tiU(s.PyW(t)))}function w(e,t){return i.svK(e,{errors:"all"})(t)}let x=u.ID();function _(e){return Object.assign(e,{parse:t=>w(e,t),safeParse:t=>{let r;return r=i.q$Z(e,{errors:"all"})(t),f.oJ(r)?{data:r.success,success:!0}:{error:{issues:x(r.failure.issue).issues.map(e=>({message:e.message,path:(e.path??[]).map(e=>"object"==typeof e?e.key:e)}))},success:!1}}})}let k=i.xCb(["flowchart","mindmap"]),S=i.xCb(["TB","BT","LR","RL"]),$=i.xCb(["straight","orthogonal","curved"]);class E extends i.Xsx("DiagramNode")({id:m,label:m,group:i.lqM(m),kind:i.lqM(m),metadata:v(g,{})}){}_(E);class O extends i.Xsx("DiagramEdge")({id:m,source:m,target:m,label:i.lqM(m),metadata:v(g,{})}){}_(O);let I=i.QfV.check(i.Pto(/^#[0-9a-fA-F]{6}$/));class A extends i.Xsx("DiagramStyle")({accentColor:v(I,b.accentColor),backgroundColor:v(I,b.backgroundColor)}){}_(A);class C extends i.Xsx("DiagramLayout")({direction:v(S,"LR"),edgeRouting:v($,"orthogonal")}){}_(C);class T extends i.Xsx("IntermediateDiagram")({id:m,title:m,type:v(k,"flowchart"),nodes:i.O31(E).pipe(i.fXn).check(i.tJb(1)),edges:v(i.O31(O).pipe(i.fXn),[]),layout:v(C,{direction:"LR",edgeRouting:"orthogonal"}),style:v(A,b),metadata:v(g,{})}){}_(T);class N 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 N(`Duplicate node id "${t}" is not allowed.`);let r=M(e.edges.map(e=>e.id));if(r)throw new N(`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 N(`Edge "${t.id}" references missing source node "${t.source}".`);if(!n.has(t.target))throw new N(`Edge "${t.id}" references missing target node "${t.target}".`);if(t.source===t.target)throw new N(`Edge "${t.id}" cannot connect node "${t.source}" to itself.`)}return e}function j(e){return P(w(T,e))}let D="flowchart",U=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 R extends i.Xsx("FlowchartValidationIssueRef")({kind:i.xCb(["diagram","node","edge"]),id:i.lqM(i.ukk),path:i.lqM(i.ukk)}){}i.Xsx("FlowchartValidationIssue")({code:U,ref:i.lqM(R),message:i.ukk,hint:i.ukk});let F=i.xCb(["start","process","decision","end"]);class L extends E.extend("FlowchartNode")({kind:F,description:i.lqM(i.ukk)}){}class B extends O.extend("FlowchartEdge")({label:i.lqM(i.ukk)}){}class Y extends T.extend("FlowchartDiagram")({type:i.uSQ(D),nodes:i.O31(L).pipe(i.fXn).check(i.tJb(2)),edges:i.O31(B).pipe(i.fXn).check(i.tJb(1))}){}let q=_(Y);function W(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 X(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."}),W(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 W(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 W(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=X([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=X(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 z extends N{issues;constructor(e){super(e[0]?.message??"Flowchart failed semantic validation."),this.issues=e,this.name="FlowchartValidationError"}}function K(e){let t=J(e);if(t.length>0)throw new z(t);return e}let V=K(w(Y,{id:"onboarding-flow",title:"Sketchi onboarding decision flow",type:D,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"}}));K(w(Y,{id:"pharma-batch-disposition",title:"Pharma batch disposition flow",type:D,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 H extends i.Xsx("MindmapNodeMetadata")({depth:i.Aiz.check(i.OWK(0)),siblingIndex:i.Aiz.check(i.OWK(0))}){}class Q extends E.extend("MindmapNode")({kind:i.xCb(["root","topic"]),metadata:H}){}class Z extends i.Xsx("MindmapEdgeMetadata")({depth:i.Aiz.check(i.yJO(0)),siblingIndex:i.Aiz.check(i.OWK(0))}){}class ee extends O.extend("MindmapEdge")({metadata:Z}){}class et extends T.extend("MindmapDiagram")({type:i.uSQ(G),nodes:i.O31(Q).pipe(i.fXn).check(i.tJb(2)),edges:i.O31(ee).pipe(i.fXn).check(i.tJb(1))}){}function er(e){return function(e){P(e);let t=e.nodes.filter(e=>"root"===e.kind);if(1!==t.length)throw new N(`Mindmap must contain exactly one root topic; found ${t.length}.`);let r=t[0];if(!r||0!==r.metadata.depth)throw new N("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 N(`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 N(`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 N(`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 N(`Mindmap children of "${e}" must use contiguous sibling ordering from 0.`)}return e}(w(et,e))}_(et);let en=er({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"}});j(V),j(en);let ei=/[,;]\s*(?:id|label|kind|group|source|target|title|direction|nodes|edges)\s*:?\s*$/i;function ea(e){let t=e.trim();for(;;){let e=t.replace(ei,"").trim();if(e===t)return t;t=e}}class es extends i.Xsx("ContractSchemaIssue")({code:ex("custom"),message:i.QfV,path:i.O31(i.pHd)},{identifier:void 0}){}class eo extends i.X0d()("ContractSchemaError",{issues:i.O31(i.O3D(es))}){}let el=e=>{var t;if("InvalidType"!==e._tag)return u.vp(e);let r=d.isSome(e.actual)?e.actual.value:void 0;return`Invalid input: expected ${t=e.ast,c.Kg(t)?"string":c.Et(t)?"number":c.Lm(t)?"boolean":c.tF(t)?"array":c.RP(t)?"object":c.c$(t)?JSON.stringify(t.literal):"value"}, received ${null===r?"null":Array.isArray(r)?"array":typeof r}`},ec=u.ID({leafHook:el});function eu(e){return"string"==typeof e||"number"==typeof e||"symbol"==typeof e}function ed(e,t){let r,n=i.q$Z(e,{errors:"all"})(t);return f.oJ(n)?{data:n.success,success:!0}:{error:new eo({issues:(r=ec(n.failure.issue).issues.map(e=>{let t=(e.path??[]).flatMap(e=>{let t=eu(e)?e:null!==e&&"object"==typeof e&&"key"in e&&eu(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 ef(e){return Object.assign(e,{parse:t=>(function(e,t){let r=ed(e,t);if(r.success)return r.data;throw r.error})(e,t),safeParse:t=>ed(e,t)})}let eh=new Set(["const","exclusiveMaximum","exclusiveMinimum","maximum","maxLength","minimum","minItems","minLength","pattern"]);function ep(e){let t=i._oz(i.AxX(e),{includeAnnotationKey:e=>eh.has(e)});return{$schema:"https://json-schema.org/draft/2020-12/schema",...t.schema,...0===Object.keys(t.definitions).length?{}:{$defs:t.definitions}}}function em(e){return i.O31(e).pipe(i.fXn).annotate({minItems:1}).check(i.HNH(e=>e.length>=1,{message:"Too small: expected array to have >=1 items"}))}function eg(e){let t=i.hzj()([e],([e])=>(t,r,n)=>void 0===t?s.PyW(void 0):h._R(e)(t,n),{toCodecJson:([e])=>i.nfo()(e,{decode:p.le({strict:!1}),encode:new p.uB(e=>s.PyW(d.filter(e,e=>void 0!==e)))})});return i.Qrq(t)}function ey(e){return e.pipe(i.usV({messageMissingKey:"Invalid input: expected string, received undefined"}))}function eb(e){return e.pipe(i.usV({messageMissingKey:"Invalid input: expected object, received undefined"}))}function ev(e){return e.pipe(i.usV({messageMissingKey:"Invalid input: expected array, received undefined"}))}function ew(e){return i.xCb(e).annotate({message:`Invalid option: expected one of ${e.map(e=>JSON.stringify(e)).join("|")}`})}function ex(e){return i.uSQ(e).pipe(i.GLL(i.QfV.annotate({const:e}).pipe(i.YPB(t=>t===e,{message:`Invalid literal value, expected ${JSON.stringify(e)}`}))))}function e_(e){return i.uSQ(e).pipe(i.GLL(i.wNn.annotate({const:e}).pipe(i.YPB(t=>t===e,{message:`Invalid literal value, expected ${JSON.stringify(e)}`}))))}function ek(e){return i.uSQ(e).pipe(i.GLL(i.v8c.annotate({const:e}).pipe(i.YPB(t=>t===e,{message:`Invalid literal value, expected ${JSON.stringify(e)}`}))))}let eS=i.QfV.annotate({minLength:1}).check(i.HNH(e=>e.length>=1,{message:"Too small: expected string to have >=1 characters"})),e$=ey(eS),eE=i.wYs,eO=i.wNn.annotate({exclusiveMinimum:0}).check(i.MIs(),i.HNH(e=>e>0,{message:"Too small: expected number to be >0"})),eI=/^#[0-9a-fA-F]{6}$/;function eA(e){return i.QfV.annotate({pattern:eI.source,...void 0===e?{}:{default:e}}).check(i.HNH(e=>eI.test(e),{message:`Invalid string: must match pattern /${eI.source}/`}))}let eC=eA();ef(eC);let eT=["excalidraw","scene","png"],eN=["excalidraw","scene"],eM=Object.assign(ef(ew(eT)),{options:eT}),eP=Object.assign(ef(ew(eN)),{options:eN});class ej extends i.Xsx("ArtifactProvenance")({sourceArtifactId:e$.pipe(i.Wa3)},{identifier:void 0}){}ef(ej);let eD=["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"],eU=Object.assign(ef(ew(eD)),{options:eD}),eR=ew(["request","diagram","node","edge","artifact"]),eF=ew(["input","flowchart","mindmap","quality","render","export","storage"]);class eL extends i.Xsx("CodeModeIssueRef")({kind:eR,id:eg(eS),path:eg(eS)},{identifier:void 0}){}ef(eL);class eB extends i.Xsx("CodeModeIssue")({code:eU,severity:ew(["error","warning"]),stage:eF,ref:eg(eL),message:e$,hint:e$},{identifier:void 0}){}ef(eB);let eY=["start","process","decision","end"],eq=Object.assign(ef(ew(eY)),{options:eY}),eW=["setDefaultStyle","setStyle","setShape","translate","replaceText","rerouteEdges"];Object.assign(ef(ew(eW)),{options:eW});class eX extends i.Xsx("FlowchartSpecNode")({id:e$,label:e$,kind:eq,description:eg(eS)},{identifier:void 0}){}class eJ extends i.Xsx("FlowchartSpecEdge")({id:eg(eS),source:e$,target:e$,label:eg(eS)},{identifier:void 0}){}let ez=ew(["TB","LR"]),eK=ez.annotate({default:"TB"}).pipe(i.tiU(s.PyW("TB")));class eV extends i.Xsx("FlowchartSpecLayout")({direction:eK},{identifier:void 0}){}let eG=b.accentColor,eH=eA(eG).pipe(i.tiU(s.PyW(eG))),eQ=b.backgroundColor,eZ=eA(eQ).pipe(i.tiU(s.PyW(eQ)));class e0 extends i.Xsx("FlowchartSpecStyle")({accentColor:eH,backgroundColor:eZ},{identifier:void 0}){}let e1=[],e2=i.O31(eJ).pipe(i.fXn).annotate({default:e1}).pipe(i.tiU(s.PyW(e1))),e5={direction:"TB"},e3=eV.annotate({default:e5}).pipe(i.tiU(s.PyW(e5))),e6={accentColor:b.accentColor,backgroundColor:b.backgroundColor},e8=e0.annotate({default:e6}).pipe(i.tiU(s.PyW(e6)));class e4 extends i.Xsx("FlowchartSpec")({id:eg(eS),title:e$,nodes:ev(em(eX)),edges:e2,layout:e3,style:e8},{identifier:void 0}){}ef(e4),ef(eX),ef(eJ),ef(eV),ef(e0);class e9 extends i.Xsx("SequenceParticipantSpec")({id:e$,label:e$,kind:eg(eS)},{identifier:void 0}){}class e7 extends i.Xsx("SequenceMessageSpec")({id:eg(eS),source:e$,target:e$,label:e$,type:eg(ew(["message","return"])),style:eg(ew(["solid","dashed"]))},{identifier:void 0}){}let te=[],tt=i.O31(e7).pipe(i.fXn).annotate({default:te}).pipe(i.tiU(s.PyW(te))),tr={accentColor:b.accentColor,backgroundColor:b.backgroundColor},tn=i._kM({accentColor:eA(eG).pipe(i.tiU(s.PyW(eG))),backgroundColor:eA(eQ).pipe(i.tiU(s.PyW(eQ)))}).annotate({default:tr}).pipe(i.tiU(s.PyW(tr)));class ti extends i.Xsx("SequenceDiagramSpec")({id:eg(eS),title:e$,participants:ev(em(e9)),messages:tt,style:tn},{identifier:void 0}){}ef(ti),ef(e9),ef(e7);let ta=eg(em(eM)),ts=eg(i.O31(eP).pipe(i.fXn)),to=eg(i.wNn.annotate({minimum:0,maximum:10}).check(i.MIs(),i.HNH(e=>e>=0,{message:"Too small: expected number to be >=0"}),i.HNH(e=>e<=10,{message:"Too big: expected number to be <=10"})));class tl extends i.Xsx("BuildFlowchartOptions")({artifactFormats:ta,inlineArtifacts:ts,minQualityScore:to},{identifier:void 0}){}ef(eg(tl));class tc extends i.Xsx("BuildFlowchartRequest")({requestId:eg(eS),spec:eb(e4),options:eg(tl)},{identifier:void 0}){}let tu=e4.mapFields(({id:e,title:t,nodes:r,edges:n,layout:i})=>({id:e,title:t,nodes:r,edges:n,layout:i})),td=i._kM({requestId:eg(eS),spec:eb(tu)}),tf=i.rcy(td,{leafHook:el,parseOptions:{errors:"all"}});Object.assign(tf["~standard"],{jsonSchema:{input:()=>ep(td),output:()=>ep(td)}});let th=Object.assign(ef(tc),{omit:e=>tf});class tp extends i.Xsx("BuildSequenceDiagramRequest")({requestId:eg(eS),spec:eb(ti),options:eg(tl)},{identifier:void 0}){}let tm=ef(tp),tg=i.QfV.annotate({minLength:1}).check(i.HNH(e=>e.length>=1,{message:"Too small: expected string to have >=1 characters"}),i.HNH(function(e){let t=ea(e);return t.length>0&&!/^(?:""|''|``)$/.test(t)},{message:"Must contain semantic text after normalization."})),ty=eb(i.DYE(()=>tb).annotate({identifier:"__schema0"})),tb=i._kM({label:ey(tg),children:i.Qrq(i.O31(ty).pipe(i.fXn))});ef(ty);class tv extends i.Xsx("MindmapSpecLayout")({direction:ew(["LR","RL"]).annotate({default:"LR"}).pipe(i.tiU(s.PyW("LR")))},{identifier:void 0}){}let tw={direction:"LR"},tx=tv.annotate({default:tw}).pipe(i.tiU(s.PyW(tw))),t_={accentColor:b.accentColor,backgroundColor:b.backgroundColor},tk=i._kM({accentColor:eA(eG).pipe(i.tiU(s.PyW(t_.accentColor))),backgroundColor:eA(t_.backgroundColor).pipe(i.tiU(s.PyW(t_.backgroundColor)))}).annotate({default:t_}).pipe(i.tiU(s.PyW(t_))),tS=i._kM({id:eg(eS),title:ey(tg),root:ty,layout:tx,style:tk});class t$ extends i.Xsx("MindmapSpec")(tS,{identifier:void 0}){}ef(t$);let tE=i._kM({requestId:eg(eS),spec:eb(tS),options:eg(tl)});i.Xsx("BuildMindmapRequest")(tE,{identifier:void 0});let tO=ef(tE);class tI extends i.Xsx("ScenePoint")({x:eE.pipe(i.Wa3),y:eE.pipe(i.Wa3)},{identifier:void 0}){}ef(tI);class tA extends i.Xsx("NodeSceneElement")({type:ex("node"),id:e$,nodeId:e$,kind:eg(eS),rendererRole:eg(ew(["sequence-lifeline"])),shape:ew(["rectangle","ellipse","diamond","circle"]).pipe(i.Wa3),fillColor:eg(eC).pipe(i.Wa3),strokeColor:eg(eC).pipe(i.Wa3),textColor:eg(eC).pipe(i.Wa3),x:eE.pipe(i.Wa3),y:eE.pipe(i.Wa3),width:eO.pipe(i.Wa3),height:eO.pipe(i.Wa3),label:e$.pipe(i.Wa3)},{identifier:void 0}){}class tC extends i.Xsx("TextSceneElement")({type:ex("text"),id:e$,containerId:eg(eS),textColor:eg(eC).pipe(i.Wa3),x:eE.pipe(i.Wa3),y:eE.pipe(i.Wa3),text:e$.pipe(i.Wa3),fontSize:eO,maxWidth:eg(eO)},{identifier:void 0}){}class tT extends i.Xsx("ArrowSceneElement")({type:ex("arrow"),id:e$,edgeId:e$,sourceNodeId:e$,targetNodeId:e$.pipe(i.Wa3),strokeColor:eg(eC).pipe(i.Wa3),strokeStyle:eg(ew(["dashed","dotted","solid"])).pipe(i.Wa3),textColor:eg(eC).pipe(i.Wa3),points:ev(i.O31(tI).pipe(i.fXn)).annotate({minItems:2}).check(i.HNH(e=>e.length>=2,{message:"Too small: expected array to have >=2 items"})).pipe(i.Wa3),label:eg(eS).pipe(i.Wa3)},{identifier:void 0}){}ef(tA),ef(tC),ef(tT);let tN=i.gPz([tA,tC,tT],{mode:"oneOf"});class tM extends i.Xsx("RenderedDiagramScene")({diagramId:e$,title:e$,width:eO.pipe(i.Wa3),height:eO.pipe(i.Wa3),accentColor:eC.pipe(i.Wa3),backgroundColor:eC.pipe(i.Wa3),elements:ev(i.O31(tN).pipe(i.fXn))},{identifier:void 0}){}let tP=ef(tM),tj=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"}));ef(tj);class tD extends i.Xsx("ExcalidrawScene")({appState:i.mSG(i.QfV,i.$r1),elements:i.O31(tj).pipe(i.fXn)},{identifier:void 0}){}ef(tD);class tU extends tD.extend("ExcalidrawFile")({files:i.mSG(i.QfV,i.$r1),source:e$,type:ex("excalidraw"),version:e_(2)},{identifier:void 0}){}let tR=ef(tU);class tF extends i.Xsx("GetArtifactRequest")({artifactId:e$,format:eg(eM),inline:eg(i.v8c)},{identifier:void 0}){}let tL=ef(tF);class tB extends i.Xsx("DiagramSelector")({ids:eg(i.O31(eS).pipe(i.fXn)),nodeIds:eg(i.O31(eS).pipe(i.fXn)),edgeIds:eg(i.O31(eS).pipe(i.fXn)),kinds:eg(i.O31(eq).pipe(i.fXn)),labels:eg(i.O31(eS).pipe(i.fXn)),scope:eg(ew(["all","nodes","edges"]))},{identifier:void 0}){}ef(tB);class tY extends i.Xsx("DiagramStylePatch")({strokeColor:eg(eC),fillColor:eg(eC),textColor:eg(eC),backgroundColor:eg(eC)},{identifier:void 0}){}ef(tY);let tq=["rectangle","diamond","ellipse","circle"],tW=Object.assign(ef(ew(tq)),{options:tq});class tX extends i.Xsx("SetDefaultStyleOperation")({op:ex("setDefaultStyle"),style:eb(tY)},{identifier:void 0}){}class tJ extends i.Xsx("SetStyleOperation")({op:ex("setStyle"),selector:eb(tB),style:eb(tY)},{identifier:void 0}){}class tz extends i.Xsx("SetShapeOperation")({op:ex("setShape"),selector:eb(tB),shape:tW},{identifier:void 0}){}class tK extends i.Xsx("TranslateOperation")({op:ex("translate"),selector:eb(tB),dx:eE,dy:eE},{identifier:void 0}){}class tV extends i.Xsx("ReplaceTextOperation")({op:ex("replaceText"),selector:eb(tB),text:e$},{identifier:void 0}){}class tG extends i.Xsx("RerouteEdgesOperation")({op:ex("rerouteEdges"),selector:eg(tB)},{identifier:void 0}){}let tH=i.gPz([tX,tJ,tz,tK,tV,tG],{mode:"oneOf"}).annotate({message:`Invalid discriminator value. Expected ${eW.map(e=>`'${e}'`).join(" | ")}`});class tQ extends i.Xsx("ArtifactPatchSource")({artifactId:e$,format:eg(ex("scene"))},{identifier:void 0}){}class tZ extends i.Xsx("InlineScenePatchSource")({scene:eb(tM)},{identifier:void 0}){}let t0=i.gPz([tQ,tZ]).annotate({message:"Invalid input"});class t1 extends i.Xsx("ApplyDiagramPatchOptions")({artifactFormats:ta,inlineArtifacts:ts,preserveConnectivity:eg(i.v8c)},{identifier:void 0}){}ef(eg(t1));class t2 extends i.Xsx("ApplyDiagramPatchRequest")({requestId:eg(eS),source:t0.annotateKey({messageMissingKey:"Invalid input"}),operations:ev(em(tH)).pipe(i.rvE({minItems:1})),options:eg(t1),intent:eg(eS)},{identifier:void 0}){}let t5=ef(t2),t3=i._kM({id:eS,title:eS,nodes:i.O31(eX).pipe(i.fXn),edges:i.O31(eJ.mapFields(e=>({...e,id:eS}))).pipe(i.fXn),layout:i._kM({direction:ez}),style:i._kM({accentColor:eC,backgroundColor:eC})}),t6=i._kM({id:eS,label:eS,children:i.O31(i.DYE(()=>t6)).pipe(i.fXn)}),t8=i._kM({id:eS,title:eS,root:t6,layout:i._kM({direction:ew(["LR","RL"])}),style:i._kM({accentColor:eC,backgroundColor:eC})}),t4=i._kM({id:eS,title:eS,participants:i.O31(e9).pipe(i.fXn),messages:i.O31(e7.mapFields(e=>({...e,id:eS}))).pipe(i.fXn),style:i._kM({accentColor:eC,backgroundColor:eC})}),t9=i._kM({code:i.QfV,passed:i.v8c,severity:ew(["error","warning"]),message:i.QfV,refs:i.O31(eL).pipe(i.fXn)}),t7=i._kM({accepted:i.v8c,score:i.wNn,threshold:i.wNn,summary:i._kM({nodeCount:i.wNn,edgeCount:i.wNn}),checks:i.O31(t9).pipe(i.fXn)}),re=i._kM({format:eM,mimeType:i.QfV,url:eg(i.QfV),expiresAt:eg(i.QfV),inline:eg(i.$r1),sizeBytes:eg(i.wNn)}),rt=i._kM({artifactId:i.QfV,diagramId:i.QfV,formats:i.O31(re).pipe(i.fXn),provenance:eg(ej),preview:eg(re)}),rr=i._kM({artifactId:eg(i.QfV),diagramId:eg(i.QfV),formats:eg(i.O31(re).pipe(i.fXn))});class rn extends i.Xsx("BuildFlowchartAccepted")({ok:ek(!0),status:ex("accepted"),buildId:i.QfV,requestId:eg(i.QfV),normalizedSpec:t3,quality:t7,artifact:rt,issues:i.O31(eB).pipe(i.fXn)},{identifier:void 0}){}class ri extends i.Xsx("BuildFlowchartRejected")({ok:ek(!1),status:ew(["invalid_input","invalid_flowchart","quality_failed","render_failed","export_failed","storage_failed"]),buildId:eg(i.QfV),requestId:eg(i.QfV),normalizedSpec:eg(t3),quality:eg(t7),partial:eg(rr),issues:i.O31(eB).pipe(i.fXn)},{identifier:void 0}){}i.gPz([rn,ri]);class ra extends i.Xsx("BuildMindmapAccepted")({ok:ek(!0),status:ex("accepted"),buildId:i.QfV,requestId:eg(i.QfV),normalizedSpec:t8,quality:t7,artifact:rt,issues:i.O31(eB).pipe(i.fXn)},{identifier:void 0}){}class rs extends i.Xsx("BuildMindmapRejected")({ok:ek(!1),status:ew(["invalid_input","invalid_mindmap","quality_failed","render_failed","export_failed","storage_failed"]),buildId:eg(i.QfV),requestId:eg(i.QfV),normalizedSpec:eg(t8),quality:eg(t7),partial:eg(rr),issues:i.O31(eB).pipe(i.fXn)},{identifier:void 0}){}i.gPz([ra,rs]);class ro extends i.Xsx("BuildSequenceDiagramAccepted")({ok:ek(!0),status:ex("accepted"),buildId:i.QfV,requestId:eg(i.QfV),normalizedSpec:t4,quality:t7,artifact:rt,issues:i.O31(eB).pipe(i.fXn)},{identifier:void 0}){}class rl extends i.Xsx("BuildSequenceDiagramRejected")({ok:ek(!1),status:ew(["invalid_input","invalid_sequence","quality_failed","render_failed","export_failed","storage_failed"]),buildId:eg(i.QfV),requestId:eg(i.QfV),normalizedSpec:eg(t4),quality:eg(t7),partial:eg(rr),issues:i.O31(eB).pipe(i.fXn)},{identifier:void 0}){}i.gPz([ro,rl]);class rc extends i.Xsx("GetArtifactAccepted")({ok:ek(!0),artifactId:i.QfV,diagramId:i.QfV,format:eM,mimeType:i.QfV,url:eg(i.QfV),expiresAt:eg(i.QfV),inline:eg(i.$r1),sizeBytes:eg(i.wNn),provenance:eg(ej)},{identifier:void 0}){}class ru extends i.Xsx("GetArtifactRejected")({ok:ek(!1),status:ew(["invalid_input","not_found","format_unavailable","expired","storage_failed"]),issues:i.O31(eB).pipe(i.fXn)},{identifier:void 0}){}i.gPz([rc,ru]);class rd extends i.Xsx("ApplyDiagramPatchAccepted")({ok:ek(!0),status:ex("accepted"),patchId:i.QfV,requestId:eg(i.QfV),sourceArtifactId:eg(i.QfV),artifact:rt,issues:i.O31(eB).pipe(i.fXn)},{identifier:void 0}){}class rf extends i.Xsx("ApplyDiagramPatchRejected")({ok:ek(!1),status:ew(["invalid_input","source_unavailable","target_not_found","unsupported_operation","connectivity_changed","render_failed","export_failed","storage_failed"]),patchId:eg(i.QfV),requestId:eg(i.QfV),sourceArtifactId:eg(i.QfV),partial:eg(rr),issues:i.O31(eB).pipe(i.fXn)},{identifier:void 0}){}i.gPz([rd,rf]);let rh=i.xCb(["read","readManifest","write"]);class rp extends i.X0d()("CodeModeArtifactStorageError",{cause:i.kld(),message:i.QfV,operation:rh}){}class rm extends a.kl()("@sketchi/diagram-agent/CodeModeArtifactStorage"){}let rg={excalidraw:"application/vnd.excalidraw+json",png:"image/png",scene:"application/vnd.sketchi.scene+json"};function ry(e){return"excalidraw"===e||"scene"===e}function rb(e){return{format:e.format,mimeType:e.mimeType,sizeBytes:e.sizeBytes}}function rv(e){return structuredClone(e)}function rw(e){return new TextEncoder().encode(JSON.stringify(e)).length}function rx(e){return t=>{var r;return rp.make({cause:t,message:(r="write"===e?"Artifact storage failed.":"Artifact read failed.",t instanceof Error?t.message:r),operation:e})}}let r_=l.QZ(rm)(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:rv(n.data)}:null},catch:rx("read")})}),readManifest:s.fn("codeMode.artifacts.memory.readManifest")(function*(t){return yield*s.SvU({try:()=>{let r=e.get(t);return r?rv(r):null},catch:rx("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(rb),o=r.provenance?rv(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:rv(n.data)});let c=r.formats.map(e=>{var t;return t=r.inlineFormats,{format:e.format,mimeType:e.mimeType,...ry(e.format)&&t.includes(e.format)?{inline:e.data}:{},sizeBytes:e.sizeBytes}});return a=(i={artifactId:r.artifactId,diagramId:r.diagramId,formats:c,...r.provenance?{provenance:rv(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:rx("write")})})}}}),e=>e.close).pipe(s.TjK(e=>e.storage)));function rk(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 rS(e){return new Map(e.map((e,t)=>[e.id,t]))}function r$(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 rE(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}function rO(e,t,r){return Math.min(r,Math.max(t,e))}function rI(e,t,r=0){let n,i=(n="top"===t||"bottom"===t?e.width/2-16:e.height/2-16)>0?rO(r,-n,n):0,a=rE(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 rA(e){return`${e.edgeId}:${e.endpoint}`}function rC(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 rT(e,t,r){return e>t+.01&&e<r-.01}function rN(e,t,r,n){return Math.min(t,n)-Math.max(e,r)>.01}function rM(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?rT(a.y,e.y,e.y+e.height)&&rN(Math.min(a.x,s.x),Math.max(a.x,s.x),e.x,e.x+e.width):a.x===s.x&&rT(a.x,e.x,e.x+e.width)&&rN(Math.min(a.y,s.y),Math.max(a.y,s.y),e.y,e.y+e.height))&&(n+=1)}return n}function rP(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 rj(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 rD(e,t){return Math.min(e.max,t.max)-Math.max(e.min,t.min)}function rU(e,t,r){let n=rj({arrowId:`edge:${r.edge.id}`,points:e,sourceNodeId:r.edge.source,targetNodeId:r.edge.target}),i=t.flatMap(e=>rj({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>=rD(e,t)||(a+=1);return a}function rR(e,t){let r=rj({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>=rD(t,e)||(n+=1)}}return n}function rF(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 rL(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 rB(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 rY(e,t){let r=e[0],n=e[1],i=e[e.length-1],a=e[e.length-2],s=0;return n&&rB(r,n,t.sourceEdge)&&(s+=1),a&&i&&rB(i,a,t.targetEdge)&&(s+=1),s}function rq(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 rW(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]),c=Math.min(...n.map(e=>e.x)),u=Math.max(...n.map(e=>e.x+e.width)),d=Math.min(...n.map(e=>e.y)),f=Math.max(...n.map(e=>e.y+e.height)),h="left"===e.sourceEdge||"left"===e.targetEdge||rE(e.target).x<rE(e.source).x,p="top"===e.sourceEdge||"top"===e.targetEdge||rE(e.source).y<=rE(e.target).y,m=18*e.index,g=c-56-m,y=u+56+m,b=d-48-m,v=f+48+m,w=h?g:y,x=h?y:g,_=p?b:v,k=p?v:b,S=[0,36+e.index%4*18],$=(n,i)=>{let a=i>0?rq(t,e.sourceEdge,i):t,s=i>0?rq(r,e.targetEdge,i):r;return rC([t,a,{x:n,y:a.y},{x:n,y:s.y},s,r])},E=(n,i)=>{let a=i>0?rq(t,e.sourceEdge,i):t,s=i>0?rq(r,e.targetEdge,i):r;return rC([t,a,{x:a.x,y:n},{x:s.x,y:n},s,r])},O=[...S.map(e=>E(_,e)),...S.map(e=>E(k,e)),...S.map(e=>$(w,e)),...S.map(e=>$(x,e))],I=[...S.map(e=>$(w,e)),...S.map(e=>$(x,e)),...S.map(e=>E(_,e)),...S.map(e=>E(k,e))];return(s=(a=o?O:I)[0])?a.slice(1).reduce((t,r)=>{let a=rM(t,n,l),s=rM(r,n,l);if(s<a)return r;if(a<s)return t;let o=rR(t,e),c=rR(r,e);if(c<o)return r;if(o<c)return t;let u=rU(t,i,e),d=rU(r,i,e);if(d<u)return r;if(u<d)return t;let f=rY(t,e),h=rY(r,e);if(h>f)return r;if(f>h)return t;let p=rF(t),m=rF(r);if(m<p)return r;if(p<m)return t;let g=rL(t),y=rL(r);return y<g?r:g<y?t:rP(r)<rP(t)?r:t},s):[{x:0,y:0}]}function rX(e){return e.flatMap(e=>"arrow"===e.type?[...e.points]:[{x:e.x,y:e.y},{x:e.x+("node"===e.type?e.width:e.maxWidth??e.text.length),y:e.y+("node"===e.type?e.height:e.fontSize)}])}function rJ(e,t,r){return{x:e.x+t,y:e.y+r}}function rz(e){var t;let r,n,i,a,s,o=j(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=rS(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 c=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,c+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=rS(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,c=[];for(let e of s){let r=48+Math.max(0,o-e.breadth)/2;for(let n of e.shapes)t?(c.push({...n,x:r,y:l+Math.max(0,e.depth-n.height)/2}),r+=n.width+112):(c.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(...c.map(e=>e.y+e.height));return c.map(t=>({...t,y:48+e-t.y-t.height}))}if("RL"===e.layout.direction){let e=Math.max(...c.map(e=>e.x+e.width));return c.map(t=>({...t,x:48+e-t.x-t.width}))}return c}(o),c=new Map(l.map(e=>[e.nodeId,e])),u=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=rE(e),i=rE(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,c,o.layout.direction)),d=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(rA(t),(r-(e.length-1)/2)*18)});return s}(u),f=[];for(let e of u)f.push(function(e,t,r,n,i,a){let{edge:s,source:o,sourceEdge:l,target:c,targetEdge:u}=e,d=rI(o,l,r.get(rA({edgeId:s.id,endpoint:"source"}))??0),f=rI(c,u,r.get(rA({edgeId:s.id,endpoint:"target"}))??0),h=rC([d,f]);if(function(e,t,r){let n=rE(e),i=rE(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,c,a))h=rW(e,d,f,n,i);else if("orthogonal"===t&&d.x!==f.x&&d.y!==f.y){var p,m,g;let t,r,n,i=e.index%4*18,a=(p=d.y,m=f.y,g=f.y<d.y?-i:i,t=p+(m-p)/2,(r=Math.min(p,m)+18)<(n=Math.max(p,m)-18)?rO(t+g,r,n):t),s="left"===l?{x:d.x-36-i,y:d.y}:"right"===l?{x:d.x+36+i,y:d.y}:d,o="left"===u?{x:f.x-36-i,y:f.y}:"right"===u?{x:f.x+36+i,y:f.y}:f;h=rC([d,s,{x:s.x,y:a},{x:o.x,y:a},o,f])}return"orthogonal"===t&&(rM(h,n,new Set([o.nodeId,c.nodeId]))>0||rR(h,e)>0||rU(h,i,e)>0)&&(h=rW(e,d,f,n,i)),{type:"arrow",id:`edge:${s.id}`,edgeId:s.id,sourceNodeId:s.source,targetNodeId:s.target,points:h,...s.label?{label:s.label}:{}}}(e,o.layout.edgeRouting,d,l,f,o.layout.direction));let h=l.map(r$),p=(i=Math.max(0,48-(n={x:Math.min(...(r=rX(t=[...f,...l,...h])).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[rJ(n,t,r),...i.map(e=>rJ(e,t,r))]}(e.points,i,a)}:{...e,x:e.x+i,y:e.y+a})),m={width:Math.max(...(s=rX(p)).map(e=>e.x))+48,height:Math.max(...s.map(e=>e.y))+48};return{diagramId:o.id,title:o.title,width:m.width,height:m.height,accentColor:o.style.accentColor,backgroundColor:o.style.backgroundColor,elements:p}}let rK="sequence-lifeline";function rV(e){return`${e}:lifeline`}var rG=r(1580);let rH=new Set(["rectangle","ellipse","diamond"]),rQ=y.ink;function rZ(e){return"number"==typeof e&&Number.isFinite(e)?e:null}function r0(e){if(!Array.isArray(e)||e.length<2)return null;let t=rZ(e[0]),r=rZ(e[1]);return null===t||null===r?null:[t,r]}function r1(e){let t=rZ(e.x),r=rZ(e.y),n=rZ(e.width),i=rZ(e.height);return null===t||null===r||null===n||null===i?null:{x:t,y:r,width:n,height:i}}function r2(e){return 1e-4>Math.abs(e-.5)?.5001:e}function r5(e,t){let r;return{elementId:e?.id??"",focus:0,gap:0,fixedPoint:e?(r=r1(e))&&0!==r.width&&0!==r.height?[r2((t.x-r.x)/r.width),r2((t.y-r.y)/r.height)]:null:null}}function r3(e,t){let r=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:"solid",frameId:null,groupIds:[],index:t,isDeleted:!1,link:null,locked:!1,opacity:100,roughness:1,seed:r,strokeStyle:"solid",strokeWidth:2,updated:1,version:1,versionNonce:r+1}}function r6(e,t){return Math.ceil(e.split("\n").length*t*1.35)}function r8(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=r6(e.text,e.fontSize);return{...r3(e.id,e.index),type:"text",x:e.x-n/2,y:e.y-i/2,width:n,height:i,backgroundColor:"transparent",boundElements:null,containerId:e.containerId,fontFamily:5,fontSize:e.fontSize,lineHeight:1.35,originalText:e.text,roundness:null,strokeColor:e.textColor??rQ,text:e.text,textAlign:"center",verticalAlign:"middle",autoResize:!0}}function r4(e){return e.points[e.points.length-1]??e.points[0]}function r9(e){return"node"===e.type}function r7(e){return"text"===e.type}function ne(e){return"arrow"===e.type}function nt(e){let t=e.elements.filter(r9),r=new Map(e.elements.filter(r7).map(e=>[e.containerId??"",e])),n=e.elements.filter(ne),i=function(e){let t=new Map;for(let r of e)for(let e of[r.sourceNodeId,r.targetNodeId]){let n=`node:${e}`;t.set(n,[...t.get(n)??[],r.id])}return t}(n),a=new Map,s=[],o=null,l=()=>{let e=(0,rG.TU)(o,null);return o=e,e};for(let n of t){let t=r.get(n.id),o=function(e){let t=e.text?r6(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?[{id:e.text.id,type:"text"}]:[],...e.arrowIds.map(e=>({id:e,type:"arrow"}))];return{...r3(e.shape.id,e.index),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===rK?{customData:{sketchiRendererRole:rK}}:{}}}({scene:e,shape:n,arrowIds:i.get(n.id)??[],index:l(),...t?{text:t}:{}});a.set(n.nodeId,o),s.push(o)}for(let t of e.elements.filter(r7))t.containerId&&s.push(r8({id:t.id,index:l(),containerId:t.containerId,fontSize:t.fontSize,maxWidth:t.maxWidth??160,...t.textColor?{textColor:t.textColor}:{},text:t.text,x:t.x,y:t.y}));for(let t of n){s.push(function(e){let t=e.arrow.points[0],r=r4(e.arrow),n=e.arrow.points.length>2;return{...r3(e.arrow.id,e.index),type:"arrow",x:t.x,y:t.y,width:r.x-t.x,height:r.y-t.y,backgroundColor:"transparent",boundElements:e.arrow.label?[{id:`${e.arrow.id}:label`,type:"text"}]:null,elbowed:n,endArrowhead:"arrow",endBinding:r5(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:null,startBinding:r5(e.sourceShape,t),strokeColor:e.arrow.strokeColor??e.scene.accentColor,strokeStyle:e.arrow.strokeStyle??"solid"}}({arrow:t,scene:e,index:l(),sourceShape:a.get(t.sourceNodeId),targetShape:a.get(t.targetNodeId)}));let r=t.label?function(e){if(!e.arrow.label)return null;let t=e.arrow.points[0],r=r4(e.arrow);return r8({id:`${e.arrow.id}:label`,index:e.index,containerId:e.arrow.id,fontSize:13,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:l()}):null;r&&s.push(r)}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:s}}function nr(e,t){let r=e[t];if(!(r&&"object"==typeof r))return null;let n=r.elementId;return"string"==typeof n?n:null}function nn(e){return r0(e)}function ni(e){let t=rZ(e.x)??0,r=rZ(e.y)??0,n=nr(e,"startBinding"),i=nr(e,"endBinding"),a=Array.isArray(e.points)?e.points.map(nn).filter(e=>!!e):[],s=[];for(let o=0;o<a.length-1;o+=1){let l=a[o],c=a[o+1];if(!l||!c)continue;let[u,d]=l,[f,h]=c,p=t+u,m=r+d,g=t+f,y=r+h;if(.001>=Math.abs(m-y)){s.push({arrowId:e.id,endBindingElementId:i,isLastSegment:o===a.length-2,max:Math.max(p,g),min:Math.min(p,g),orientation:"horizontal",segmentIndex:o,startBindingElementId:n,staticCoordinate:m});continue}.001>=Math.abs(p-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:p})}return s.filter(e=>e.max-e.min>.001)}function na(e,t,r){return e>t+.01&&e<r-.01}function ns(e,t,r,n){return Math.min(t,n)-Math.max(e,r)>.01}function no(e,t,r){return e>=t-.01&&e<=r+.01}function nl(e,t){return .01>=Math.abs(e-t)}function nc(e){let t=[],r=new Map(e.elements.map(e=>[e.id,e])),n=new Set(e.elements.filter(e=>rH.has(e.type)).map(e=>e.id));for(let i of(0===n.size&&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"])){let s=nr(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=rZ(e.x)??0,n=rZ(e.y)??0,i=Array.isArray(e.points)?e.points.map(nn).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=r1(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 nl(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 nl(((e.x-i)/t)**2+((e.y-a)/n)**2,1)}let n=(nl(e.x,r.x)||nl(e.x,r.x+r.width))&&no(e.y,r.y,r.y+r.height),i=(nl(e.y,r.y)||nl(e.y,r.y+r.height))&&no(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?r0(r.fixedPoint):null}(i,a);e&&function(e,t,r){let n=r1(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 nl(n.x+i*n.width,t.x)&&nl(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;rH.has(n.type)&&(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(ni),r=e.filter(e=>rH.has(e.type)),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===rK}(t)||t.id===e.startBindingElementId||t.id===e.endBindingElementId)continue;let r=r1(t);if(!r||("horizontal"===e.orientation?!(na(e.staticCoordinate,r.y,r.y+r.height)&&ns(e.min,e.max,r.x,r.x+r.width)):!(na(e.staticCoordinate,r.x,r.x+r.width)&&ns(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(ni),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 nu=r(8927);r(2302);var nd=r(4650),nf=r(1136),nh=r(9354),np=r(6364),nm=r(9138),ng=r(5369);let ny=a.Or("effect/Metric/CurrentMetricAttributes",{defaultValue:()=>({})}),nb=a.Or("~effect/observability/Metric/MetricRegistryKey",{defaultValue:()=>new Map}),nv="~effect/observability/Metric";class nw{[nv]=nv;#e=new WeakMap;#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){let t=a.Jt(e,ny);if(0===Object.keys(t).length)return ng.EA(this.#t)||(this.#t=this.getOrCreate(e,this.attributes)),this.#t.hooks;let r=nI(this.attributes,t),n=this.#e.get(r);return ng.EA(n)||(n=this.getOrCreate(e,r),this.#e.set(r,n)),n.hooks}getOrCreate(e,t){var r,n,i;let s,o=(r=this,n=t,s=`${r.type}:${r.id}`,ng.EA(r.description)&&(s+=`:${r.description}`),ng.EA(n)&&(s+=`:${(Array.isArray(i=n)?i:Object.entries(i)).map(([e,t])=>`${e}=${t}`).join(",")}`),s),l=a.Jt(e,nb);if(l.has(o))return l.get(o);let c=this.createHooks(),u={id:this.id,type:this.type,description:this.description,attributes:nA(t),hooks:c};return l.set(o,u),u}pipe(){return(0,nm.tT)(this,arguments)}}let nx=BigInt(0);class n_ extends nw{type="Counter";#r;#n;constructor(e,t){super(e,t?.description,nA(t?.attributes)),this.#r=t?.bigint??!1,this.#n=t?.incremental??!1}createHooks(){let e=this.#r?nx:0,t=this.#n?this.#r?e=>e>=nx:e=>e>=0:e=>!0;return nO(()=>({count:e,incremental:this.#n}),r=>{t(r)&&(e+=r)})}}class nk extends nw{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 nS=(e,t)=>new n_(e,t),n$=(0,nd.XY)(2,(e,t)=>nf.sxi(r=>nf.OH5(()=>e.updateUnsafe(t,r)))),nE=(0,nd.XY)(2,(e,t)=>new nk(e,r=>e.valueUnsafe(nC(r,t)),(r,n)=>e.updateUnsafe(r,nC(n,t)),(r,n)=>e.modifyUnsafe(r,nC(n,t))));function nO(e,t,r){return{get:e,update:t,modify:r??t}}function nI(e,t){return{...nA(e),...nA(t)}}function nA(e){return ng.EA(e)&&Array.isArray(e)?e.reduce((e,[t,r])=>(e[t]=r,e),{}):e}function nC(e,t){let r=nI(a.Jt(e,ny),t);return a.WQ(e,ny,r)}nh.F,nh.F,nd.MN,r(7598),r(8543);var nT=r(755);[...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 nN={metric:()=>void 0},nM=a.Or("@sketchi/observability/TelemetryExporter",{defaultValue:()=>nN}),nP=a.Or("@sketchi/observability/TelemetryCorrelation",{defaultValue:()=>({})});function nj(e){let t=e?.trim();if(t&&!(t.length>128)&&/^[A-Za-z0-9][A-Za-z0-9._:-]*$/.test(t))return t}function nD(e){let t=nj(e.artifactId),r=nj(e.attemptId),n=nj(e.projectId),i=nj(e.requestId),a=nj(e.runId),s=nj(e.scenarioId),o=nj(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 nU(e,t){return s.JkU(function*(){let r=nD({...yield*nP,...nD(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(nP,r),s.Muk(n),s.swY(n))})}a.Or("@sketchi/observability/TelemetryResource",{defaultValue:()=>({serviceName:"sketchi"})});let nR=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=nj(n);t&&(r[e]=t)}return r}(r);yield*n$(nE(e,n),t);let i=yield*nM,a=d.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}))});nT.W1;let nF=/^(node|step|item|box|thing|process|task)\s*\d*$/i,nL=/^(diagram|untitled|flowchart|chart|sketch)$/i;function nB(e){return"decision"===e.kind||e.label.endsWith("?")}function nY(e){if(void 0===e)return;let t=ea(e);return t.length>0?t:void 0}let nq=["excalidraw","scene"],nW=["scene"];y.card,y.accent,y.ink;let nX=nS("sketchi_codemode_requests",{description:"Code Mode boundary requests by terminal outcome",incremental:!0}),nJ=nS("sketchi_codemode_failures",{description:"Code Mode boundary failures by typed status",incremental:!0}),nz=nS("sketchi_codemode_artifacts",{description:"Code Mode artifacts accepted at workflow boundaries",incremental:!0}),nK=new class e extends nw{type="Histogram";#i;constructor(e,t){super(e,t?.description,nA(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=5e-324;return nu.Tj(nu.di(e,np.wN),(e,t)=>{n[t]=e}),nO(()=>({buckets:(()=>{let e=nu.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,c=t;for(;l!==c;){let t=Math.floor(l+(c-l)/2);e<=n[t]?c=t:l=t,c===l+1&&(e<=n[l]?c=l:l=c)}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],nu.BC(nu.pb(new Set(n),e=>e>0),1/0))});class nV extends a.kl()("@sketchi/diagram-agent/CodeModeRuntimeEnvironment"){}function nG(e={}){return l.Py(nV,{createId:e.createId??n6,...e.renderer?{renderer:e.renderer}:{},...e.artifactUrl?{artifactUrl:e.artifactUrl}:{}})}function nH(e){return null===e||"object"!=typeof e||Array.isArray(e)?void 0:Object.fromEntries(Object.entries(e))}function nQ(e,t,r){let n,i,a,l;return nU(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*nR(nX,1,{...s?{failureCategory:s}:{},operation:e,outcome:a,surface:"code_mode"}),yield*nR(nK,i-t,{...s?{failureCategory:s}:{},operation:e,outcome:a,surface:"code_mode"}),s&&(yield*nR(nJ,1,{failureCategory:s,operation:e,surface:"code_mode"}));let l="buildFlowchart"===e?"flowchart":"buildMindmap"===e?"mindmap":"buildSequenceDiagram"===e?"sequence":"applyDiagramPatch"===e?"patch":void 0;return n.ok&&l&&(yield*nR(nz,1,{artifactKind:l,operation:e,surface:"code_mode"})),n}),(n=nH(t),i=nH(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(nV,{createId:n6});class nZ extends i.X0d()("CodeModeArtifactExportError",{cause:i.kld(),message:i.QfV,optionPath:i.v8c}){}class n0 extends i.X0d()("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 n1 extends i.X0d()("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 n2 extends i.X0d()("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 n5 extends i.X0d()("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 n3 extends i.X0d()("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 n6(e){return`${e}_${globalThis.crypto.randomUUID()}`}function n8(e){return{code:e.code,severity:e.severity??"error",stage:e.stage,...e.ref?{ref:e.ref}:{},message:e.message,hint:e.hint}}function n4(e){return 0===e.length?"input":e.map(e=>"number"==typeof e?`[${e}]`:String(e)).join(".")}function n9(e){let t=n4(e.path);return n7(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 n7(e){return/^operations\.\[\d+\]\.op$/.test(e)}function ie(e){let t=e.issues.slice(0,20).map(e=>{let t=n4(e.path);return n8({code:n9(e),stage:"input",ref:{kind:"request",path:t},message:e.message,hint:n7(t)?`Use one of: ${eW.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(n8({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 it(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)}function ir(e){if(void 0===e)return;let t=ea(e);return t.length>0?t:void 0}function ii(e){return e.checks.map(e=>{var t;return n8({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 ia(e){return e?.artifactFormats??nq}function is(e){return e?.inlineArtifacts??nW}let io=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=>nZ.make({cause:e,message:e instanceof Error?e.message:"Artifact export failed.",optionPath:!1}))):s.fJG(nZ.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:rg[a],data:o,sizeBytes:(i=o)instanceof ArrayBuffer||i instanceof Uint8Array?i.byteLength:rw(i)})}return t});function il(e){return[n8({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 ic(e){return e.map(e=>n8({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 iu(e){return structuredClone(e)}function id(e){return e.elements.filter(e=>"arrow"===e.type).map(e=>`${e.edgeId}:${e.sourceNodeId}->${e.targetNodeId}`).sort()}function ih(e){return e.elements.filter(e=>"node"===e.type)}function ip(e){return e.elements.filter(e=>"text"===e.type)}function im(e){return e.elements.filter(e=>"arrow"===e.type)}function ig(e,t){if(!e||0===e.length||!t)return!1;let r=t.trim().toLowerCase();return e.some(e=>e.trim().toLowerCase()===r)}function iy(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=ih(e).filter(e=>"edges"!==r&&(!t||!n||i.has(e.id)||a.has(e.nodeId)||!!e.kind&&[...o].some(t=>t===e.kind)||ig(t.labels,e.label))),c=im(e).filter(e=>"nodes"!==r&&(!t||!n||i.has(e.id)||s.has(e.edgeId)||ig(t.labels,e.label))),u=new Set(l.map(e=>e.id)),d=new Set(c.map(e=>e.id));return{arrows:c,nodes:l,texts:ip(e).filter(e=>t&&n?i.has(e.id)||!!e.containerId&&u.has(e.containerId)||!!e.containerId&&d.has(e.containerId)||ig(t.labels,e.text):"nodes"===r?!!e.containerId&&u.has(e.containerId):"edges"!==r||!!e.containerId&&d.has(e.containerId))}}function ib(e){return n8({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 iv(e,t){return ip(e).find(e=>e.containerId===t)}function iw(e,t){let r=new Set(t);for(let t of im(e))(r.has(t.sourceNodeId)||r.has(t.targetNodeId))&&ik(e,t)}function ix(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}function i_(e,t,r){let n=ix(e),i=ix(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 ik(e,t){let r,n,i=new Map(ih(e).map(e=>[e.nodeId,e])),a=i.get(t.sourceNodeId),s=i.get(t.targetNodeId);if(!a||!s)return[n8({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=i_(a,s,!0),l=i_(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=iv(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),[]}let iS=s.fn("codeMode.patch.resolveSource")(function*(e){if("scene"in e.source)return{scene:iu(e.source.scene)};let t=yield*rm,r=yield*t.readManifest(e.source.artifactId).pipe(s.xm_(e=>new n3({status:"storage_failed",context:{issues:[rk(e.message,"storage_read_failed")]}})));if(!r||r.artifactId!==e.source.artifactId||!r.formats.some(e=>"scene"===e.format))return yield*new n3({status:"source_unavailable",context:{issues:[n8({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 n3({status:"storage_failed",context:{issues:[rk(e.message,"storage_read_failed")]}})));if(!n)return yield*new n3({status:"source_unavailable",context:{issues:[n8({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=tP.safeParse(n.data);return i.success?{scene:iu(i.data),sourceArtifactId:e.source.artifactId}:yield*new n3({status:"source_unavailable",context:{issues:[n8({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 i$(e){return e?{requestId:e}:{}}function iE(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 iO(e){return{diagramId:e.diagramId,formats:[{format:"scene",mimeType:rg.scene,inline:e,sizeBytes:rw(e)}]}}function iI(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 iA(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 iC(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 iT(e){return{ok:!1,status:e.status,issues:e.issues}}function iN(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 iM(e,t){return rk(e.message,t)}let iP=s.fn("codeMode.buildMindmap.workflow")(function*(e){let t=yield*s.OH5(()=>(function(e){let t=nH(nH(nH(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[n8({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[n8({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=nH(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 n1({status:"invalid_mindmap",context:{issues:t}});let r=yield*s.OH5(()=>tO.safeParse(e)).pipe(s.fRP("codeMode.buildMindmap.parse"));if(!r.success)return yield*new n1({status:"invalid_input",context:{issues:ie(r.error)}});let n=yield*nV,i=yield*rm,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:ea(e.label),children:(e.children??[]).map((e,n)=>t(e,[...r,n]))}),r=ea(e.title),{id:ir(e.id)??(it(r)||"sketchi-mindmap"),title:r,root:t(e.root,[0]),layout:{direction:e.layout.direction},style:{...b}}}).pipe(s.fRP("codeMode.buildMindmap.normalize")),c={buildId:o,...i$(a.requestId),normalizedSpec:l},u=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(n8({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(n8({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(n8({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(u.length>0)return yield*new n1({status:"invalid_mindmap",context:{...c,issues:u}});let d=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),er({id:l.id,title:l.title,type:"mindmap",nodes:e,edges:t,layout:{direction:l.layout.direction,edgeRouting:"curved"},style:{...b}})},catch:e=>new n1({status:"invalid_mindmap",context:{...c,issues:[n8({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=d.nodes.filter(e=>/^(topic|branch|item|mindmap)$/i.test(e.label.trim()))).length))>=e,score:r,threshold:e,summary:{nodeCount:d.nodes.length,edgeCount:d.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")),h={...c,quality:f};if(!f.accepted)return yield*new n1({status:"quality_failed",context:{...h,issues:ii(f)}});let p=yield*s.SvU({try:()=>rz(d),catch:e=>new n1({status:"render_failed",context:{...h,issues:[n8({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:g}=yield*s.OH5(()=>{let e=nt(p);return{excalidraw:e,exportValidation:nc(e)}}).pipe(s.fRP("codeMode.buildMindmap.exportValidate")),y={...h,partial:iO(p)};if(!g.ok)return yield*new n1({status:"export_failed",context:{...y,issues:ic(g.issues)}});let v=yield*io({formats:ia(a.options),scene:p,excalidraw:m,renderer:n.renderer}).pipe(s.xm_(e=>new n1({status:"export_failed",context:{...y,issues:il(e)}}))),w=yield*s.OH5(()=>n.createId("artifact")),x=yield*nU(i.write({artifactId:w,diagramId:p.diagramId,formats:v,inlineFormats:is(a.options)}),{artifactId:w,...a.requestId?{requestId:a.requestId}:{}}).pipe(s.xm_(e=>new n1({status:"storage_failed",context:{...h,partial:{diagramId:p.diagramId},issues:[iM(e,"storage_write_failed")]}})));return{ok:!0,status:"accepted",buildId:o,...i$(a.requestId),normalizedSpec:l,quality:f,artifact:iE(x,n.artifactUrl),issues:[]}}),ij=s.fn("codeMode.buildSequenceDiagram.workflow")(function*(e){yield*s.rIH.pipe(s.fRP("codeMode.buildSequenceDiagram.preflight"));let t=yield*s.OH5(()=>tm.safeParse(e)).pipe(s.fRP("codeMode.buildSequenceDiagram.parse"));if(!t.success)return yield*new n2({status:"invalid_input",context:{issues:ie(t.error)}});let r=yield*nV,n=yield*rm,i=t.data,a=yield*s.OH5(()=>r.createId("build")),o=yield*s.OH5(()=>{var e;let t;return t=ea((e=i.spec).title),{id:ir(e.id)??(it(t)||"sketchi-sequence"),title:t,participants:e.participants.map(e=>({id:ea(e.id),label:ea(e.label),...e.kind?{kind:ea(e.kind)}:{}})),messages:e.messages.map((e,t)=>({id:ir(e.id)??`message-${t+1}-${it(e.source)}-${it(e.target)}`,source:ea(e.source),target:ea(e.target),label:ea(e.label),...e.type?{type:e.type}:{},...e.style?{style:e.style}:{}})),style:{...b}}}).pipe(s.fRP("codeMode.buildSequenceDiagram.normalize")),l={buildId:a,...i$(i.requestId),normalizedSpec:o},c=yield*s.OH5(()=>{let e,t,r,n;return e=[],t=new Set,o.participants.forEach((r,n)=>{t.has(r.id)&&e.push(n8({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=rV(t.id),i=r.get(n);void 0!==i&&e.push(n8({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(n8({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(n8({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(n8({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(n8({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(c.length>0)return yield*new n2({status:"invalid_sequence",context:{...l,issues:c}});let u=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")),d={...l,quality:u};if(!u.accepted)return yield*new n2({status:"quality_failed",context:{...d,issues:ii(u)}});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=rV(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,c=l+90;n.set(t.id,c),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:c,y:84,text:t.label,fontSize:14,maxWidth:156}),s.push({type:"node",id:`node:${rV(t.id)}`,nodeId:rV(t.id),rendererRole:rK,shape:"rectangle",fillColor:e.style.backgroundColor,strokeColor:e.style.accentColor,x:c-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:rV(e.source),targetNodeId:rV(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}});return{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:[...o,...s,...i,...a]}})(o),catch:e=>new n2({status:"render_failed",context:{...d,issues:[n8({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:h,validation:p}=yield*s.OH5(()=>{let e=nt(f);return{excalidraw:e,validation:nc(e)}}).pipe(s.fRP("codeMode.buildSequenceDiagram.exportValidate")),m={...d,partial:iO(f)};if(!p.ok)return yield*new n2({status:"export_failed",context:{...m,issues:ic(p.issues)}});let g=yield*io({formats:ia(i.options),scene:f,excalidraw:h,renderer:r.renderer}).pipe(s.xm_(e=>new n2({status:"export_failed",context:{...m,issues:il(e)}}))),y=yield*s.OH5(()=>r.createId("artifact")),v=yield*nU(n.write({artifactId:y,diagramId:f.diagramId,formats:g,inlineFormats:is(i.options)}),{artifactId:y,...i.requestId?{requestId:i.requestId}:{}}).pipe(s.xm_(e=>new n2({status:"storage_failed",context:{...d,issues:[iM(e,"storage_write_failed")]}})));return{ok:!0,status:"accepted",buildId:a,...i$(i.requestId),normalizedSpec:o,quality:u,artifact:iE(v,r.artifactUrl),issues:[]}}),iD=s.fn("codeMode.buildFlowchart.workflow")(function*(e){let t=yield*s.OH5(()=>th.safeParse(e)).pipe(s.fRP("codeMode.buildFlowchart.parse"));if(!t.success)return yield*new n0({status:"invalid_input",context:{issues:ie(t.error)}});let r=yield*nV,n=yield*rm,i=t.data,a=ia(i.options),o=yield*s.OH5(()=>r.createId("build")),l=yield*s.OH5(()=>{var e;let t;return t=ea((e=i.spec).title),{id:nY(e.id)??(t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"sketchi-flowchart"),title:t,nodes:e.nodes.map(e=>({id:ea(e.id),label:ea(e.label),kind:e.kind,...e.description?{description:ea(e.description)}:{}})),edges:e.edges.map((e,t)=>({id:nY(e.id)??`edge-${t+1}`,source:ea(e.source),target:ea(e.target),...e.label?{label:ea(e.label)}:{}})),layout:{direction:e.layout.direction},style:{...b}}}).pipe(s.fRP("codeMode.buildFlowchart.normalize")),c={buildId:o,...i$(i.requestId),normalizedSpec:l},u=yield*s.OH5(()=>q.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(!u.success){var d;return yield*new n0({status:"invalid_flowchart",context:{...c,issues:(d=u.error,d.issues.slice(0,20).map(e=>{let t=function(e,t){let r=n4(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 n8({code:n9(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,h=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 n8({code:e.code,stage:"flowchart",...t?{ref:t}:{},message:e.message,hint:e.hint})})).pipe(s.fRP("codeMode.buildFlowchart.validate"));if(h.length>0)return yield*new n0({status:"invalid_flowchart",context:{...c,issues:h}});yield*s.OH5(()=>K(f)).pipe(s.fRP("codeMode.buildFlowchart.assertValid"));let p=yield*s.OH5(()=>(function(e,t){let r=[],n=0,i=(e,t,i=!1)=>{n+=e,r.push({severity:i?"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",!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(", ")}`,!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`,!0)}e.nodes.length<3?i(2,"too sparse — a useful flow needs at least 3 nodes"):e.nodes.length>24&&i(2,"too dense — trim or merge nodes (24 max)");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(", ")}`);let c=0,u=0;for(let t of e.nodes.filter(nB)){let e=s.get(t.id)??[];e.length<2?(c+=1,r.push({severity:"error",message:`decision "${t.id}" needs at least 2 outgoing branches`})):e.some(e=>!e.label)&&(u+=1,r.push({severity:"warning",message:`label every branch out of decision "${t.id}" (yes/no, …)`}))}n+=Math.min(1.5*c,4.5)+Math.min(u,3);let d=e.nodes.filter(e=>e.label.length>42);d.length>0&&i(Math.min(.5*d.length,2),`shorten label(s): ${d.map(e=>e.id).join(", ")}`);let f=e.nodes.filter(e=>nF.test(e.label.trim()));f.length>0&&i(Math.min(f.length,3),`generic label(s) say nothing: ${f.map(e=>`"${e.label}"`).join(", ")}`),(e.title.trim().length<4||nL.test(e.title.trim()))&&i(.5,"give the diagram a specific title");let h=Math.max(0,Math.round((10-n)*10)/10),p=r.map(e=>{var t;return{code:(t=e.message).includes("generic label")?"generic_label":t.includes("shorten label")?"label_too_long":t.includes("disconnected")?"disconnected_graph":"quality_below_threshold",passed:!1,severity:e.severity,message:e.message,refs:[]}});return{accepted:h>=t&&!p.some(e=>"error"===e.severity),score:h,threshold:t,summary:{nodeCount:e.nodes.length,edgeCount:e.edges.length},checks:p}})(f,i.options?.minQualityScore??8)).pipe(s.fRP("codeMode.buildFlowchart.quality")),m={...c,quality:p};if(!p.accepted)return yield*new n0({status:"quality_failed",context:{...m,issues:ii(p)}});let g=yield*s.SvU({try:()=>rz(f),catch:e=>new n0({status:"render_failed",context:{...m,issues:[n8({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:y,validation:v}=yield*s.OH5(()=>{let e=nt(g);return{excalidraw:e,validation:nc(e)}}).pipe(s.fRP("codeMode.buildFlowchart.exportValidate")),w={...m,partial:iO(g)};if(!v.ok)return yield*new n0({status:"export_failed",context:{...w,issues:ic(v.issues)}});let x=yield*io({formats:a,scene:g,excalidraw:y,renderer:r.renderer}).pipe(s.xm_(e=>new n0({status:"export_failed",context:{...w,issues:il(e)}}))),_=yield*s.OH5(()=>r.createId("artifact")),k=yield*nU(n.write({artifactId:_,diagramId:g.diagramId,formats:x,inlineFormats:is(i.options)}),{artifactId:_,...i.requestId?{requestId:i.requestId}:{}}).pipe(s.xm_(e=>new n0({status:"storage_failed",context:{...m,issues:[iM(e,"storage_write_failed")]}})));return{ok:!0,status:"accepted",buildId:o,...i$(i.requestId),normalizedSpec:l,quality:p,artifact:iE(k,r.artifactUrl),issues:[]}}),iU=s.fn("codeMode.getArtifact.workflow")(function*(e){let t=yield*s.OH5(()=>tL.safeParse(e)).pipe(s.fRP("codeMode.getArtifact.parse"));if(!t.success)return yield*new n5({status:"invalid_input",issues:ie(t.error)});let r=yield*nV,n=yield*rm,i=t.data,a=yield*n.readManifest(i.artifactId).pipe(s.xm_(e=>new n5({status:"storage_failed",issues:[iM(e,"storage_read_failed")]})));if(!a)return yield*new n5({status:"not_found",issues:[n8({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 n5({status:"format_unavailable",issues:[n8({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 n5({status:"storage_failed",issues:[iM(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||!ry(o)?{}:{inline:l.data},sizeBytes:l.sizeBytes,...a.provenance?{provenance:a.provenance}:{}}:yield*new n5({status:"format_unavailable",issues:[n8({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."})]})}),iR=s.fn("codeMode.applyDiagramPatch.workflow")(function*(e){let t=yield*s.OH5(()=>t5.safeParse(e)).pipe(s.fRP("codeMode.applyDiagramPatch.parse"));if(!t.success)return yield*new n3({status:"invalid_input",context:{issues:ie(t.error)}});let r=yield*nV,n=yield*rm,i=t.data,a=yield*s.OH5(()=>r.createId("patch")),o={patchId:a,...i$(i.requestId)},l=ia(i.options),c=yield*iS(i).pipe(s.xm_(e=>new n3({status:e.status,context:{...o,...e.context}}))),u={...o,...c.sourceArtifactId?{sourceArtifactId:c.sourceArtifactId}:{}},d=c.scene,f=id(d),h=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),ih(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 im(e))t.style.strokeColor&&(r.strokeColor=t.style.strokeColor),t.style.textColor&&(r.textColor=t.style.textColor);for(let r of ip(e))t.style.textColor&&(r.textColor=t.style.textColor);return[]}let r=iy(e,t.selector);if(0===r.nodes.length&&0===r.arrows.length&&0===r.texts.length)return[ib(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=iv(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=iv(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=iy(e,t.selector);if(0===n.nodes.length)return[ib(t)];let i=[];for(let r of n.nodes){if(r.shape=t.shape,"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=iv(e,t.id);r&&(r.x=t.x+t.width/2,r.y=t.y+t.height/2)}(e,r)}return iw(e,i),[];case"translate":return function(e,t){let r=iy(e,t.selector);if(0===r.nodes.length&&0===r.arrows.length&&0===r.texts.length)return[ib(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=iv(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=iv(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 iw(e,[...n]),function(e){let t=[e.width],r=[e.height];for(let n of ih(e))t.push(n.x+n.width),r.push(n.y+n.height);for(let n of ip(e))t.push(n.x+(n.maxWidth??0)),r.push(n.y+n.fontSize);for(let n of im(e))for(let e of n.points)t.push(e.x),r.push(e.y);e.width=Math.max(...t)+48,e.height=Math.max(...r)+48}(e),[]}(e,t);case"replaceText":let a=iy(e,t.selector);if(0===a.nodes.length&&0===a.arrows.length&&0===a.texts.length)return[ib(t)];for(let r of a.nodes){r.label=t.text;let n=iv(e,r.id);n&&(n.text=t.text)}for(let r of a.arrows){r.label=t.text;let n=iv(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=iy(e,t.selector)).arrows.length?[ib(t)]:s.arrows.flatMap(t=>ik(e,t))}}(d,e);if(t.length>0)return t}return[]}).pipe(s.fRP("codeMode.applyDiagramPatch.operations"));if(h.length>0)return yield*new n3({status:h[0]?.code==="unknown_patch_target"?"target_not_found":"unsupported_operation",context:{...u,issues:h}});if(i.options?.preserveConnectivity!==!1){let e=id(d);if(!(f.length===e.length&&f.every((t,r)=>t===e[r])))return yield*new n3({status:"connectivity_changed",context:{...u,issues:[n8({code:"patch_preserve_connectivity_failed",stage:"flowchart",ref:{kind:"diagram",id:d.diagramId},message:"Patch changed the diagram edge connectivity.",hint:"Use buildFlowchart for process-graph structure or buildMindmap for hierarchy structure."})]}})}let p=yield*s.OH5(()=>(function(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({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){t.push({type:"node",id:r.id,nodeId:r.nodeId,...r.kind?{kind:r.kind}:{},..."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}:{},shape:r.shape,...r.fillColor?{fillColor:r.fillColor}:{},...r.strokeColor?{strokeColor:r.strokeColor}:{},...r.textColor?{textColor:r.textColor}:{},x:r.x,y:r.y,width:r.width,height:r.height,label:r.label});continue}t.push({type:"text",id:r.id,...r.containerId?{containerId:r.containerId}:{},...r.textColor?{textColor:r.textColor}:{},x:r.x,y:r.y,text:r.text,fontSize:r.fontSize,...r.maxWidth?{maxWidth:r.maxWidth}:{}})}return{diagramId:e.diagramId,title:e.title,width:e.width,height:e.height,accentColor:e.accentColor,backgroundColor:e.backgroundColor,elements:t}})(d)).pipe(s.fRP("codeMode.applyDiagramPatch.normalize"));if(!p)return yield*new n3({status:"render_failed",context:{...u,issues:[n8({code:"patch_output_invalid",stage:"render",ref:{kind:"diagram",id:d.diagramId},message:"Patched scene has an invalid arrow point list.",hint:"Reroute edges or rebuild the flowchart artifact."})]}});let{excalidraw:m,validation:g}=yield*s.OH5(()=>{let e=nt(p);return{excalidraw:e,validation:nc(e)}}).pipe(s.fRP("codeMode.applyDiagramPatch.exportValidate")),y={...u,partial:iO(p)};if(!g.ok)return yield*new n3({status:"export_failed",context:{...y,issues:ic(g.issues)}});let b=yield*io({formats:l,scene:p,excalidraw:m,renderer:r.renderer}).pipe(s.xm_(e=>new n3({status:"export_failed",context:{...y,issues:il(e)}}))),v=yield*s.OH5(()=>r.createId("artifact")),w=yield*nU(n.write({artifactId:v,diagramId:p.diagramId,formats:b,inlineFormats:is(i.options),...c.sourceArtifactId?{provenance:{sourceArtifactId:c.sourceArtifactId}}:{}}),{artifactId:v,...i.requestId?{requestId:i.requestId}:{}}).pipe(s.xm_(e=>new n3({status:"storage_failed",context:{...u,issues:[iM(e,"storage_write_failed")]}})));return{ok:!0,status:"accepted",patchId:a,...i$(i.requestId),...c.sourceArtifactId?{sourceArtifactId:c.sourceArtifactId}:{},artifact:iE(w,r.artifactUrl),issues:[]}});function iF(e,t){return e.pipe(s.YWq({onFailure:t,onSuccess:e=>e}))}let iL=s.fn("codeMode.buildFlowchart")(e=>nQ("buildFlowchart",e,iF(iD(e),iI))),iB=s.fn("codeMode.buildMindmap")(e=>nQ("buildMindmap",e,iF(iP(e),iA)));s.fn("codeMode.buildSequenceDiagram")(e=>nQ("buildSequenceDiagram",e,iF(ij(e),iC))),s.fn("codeMode.getArtifact")(e=>nQ("getArtifact",e,iF(iU(e),iT)));let iY=s.fn("codeMode.applyDiagramPatch")(e=>nQ("applyDiagramPatch",e,iF(iR(e),iN)))}},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,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+"."+({831:"bdee8e123d2a353d",869:"cacc093c4bbc5a04"})[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(4144);
|