sketchi 0.0.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.
Files changed (2) hide show
  1. package/package.json +37 -0
  2. package/sketchi.js +133 -0
package/sketchi.js ADDED
@@ -0,0 +1,133 @@
1
+ #!/usr/bin/env node
2
+ import{createRequire as e}from"node:module";let t=e(import.meta.url);var r,n,i={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",s=t.whitespace?" = ":"=",o=[],l=t.sort?Object.keys(e).sort():Object.keys(e),c=0;t.align&&(c=a(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)=>a(e).length>=a(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+=a(`${t}${d}`).padEnd(c," ")+s+a(e)+i;else r&&"object"==typeof r?o.push(t):u+=a(t).padEnd(c," ")+s+a(r)+i}for(let s of(t.section&&u.length&&(u="["+a(t.section)+"]"+(t.newline?i+i:i)+u),o)){let a=n(s,".").join("\\."),o=(t.section?t.section+".":"")+a,l=r(e[s],{...t,section:o});u.length&&l.length&&(u+=i),u+=l}return u};function n(e,t){var r=0,n=0,i=0,s=[];do if(-1!==(i=e.indexOf(t,r))){if(r=i+t.length,i>0&&"\\"===e[i-1])continue;s.push(e.slice(n,i)),n=i+t.length}while(-1!==i)return s.push(e.slice(n)),s}let i=(e,r={})=>{r.bracketedArray=!1!==r.bracketedArray;let i=Object.create(null),s=i,a=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__"===(a=o(c[1]))){s=Object.create(null);continue}s=i[a]=i[a]||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(s,f)?Array.isArray(s[f])||(s[f]=[s[f]]):s[f]=[]),Array.isArray(s[f])?s[f].push(p):s[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,".");s=i;let a=r.pop(),o=a.replace(/\\\./g,".");for(let e of r)"__proto__"!==e&&(t.call(s,e)&&"object"==typeof s[e]||(s[e]=Object.create(null)),s=s[e]);(s!==i||o!==a)&&(s[o]=i[e],d.push(e))}for(let e of d)delete i[e];return i},s=e=>e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"),a=e=>"string"!=typeof e||e.match(/[=\r\n]/)||e.match(/^\[/)||e.length>1&&s(e)||e!==e.trim()?JSON.stringify(e):e.split(";").join("\\;").split("#").join("\\#"),o=e=>{if(s(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:a,unsafe:o}},3176(e,t,r){var n=r(3633),i=r(4239);e.exports={parse:function(e,t){var r=e.toString(),s=n.parse(r,t);return i.compile(s,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,s=new Set,a=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 s=t[i];if("InlineTableValue"===s.type){var a=s.key;Array.isArray(a)||(a=[a]),function(e,t,r,n,i){for(var s=0;s<t.length-1;s++){var a=t[s],o=w(t.slice(0,s+1));void 0===e[a]?e[a]=b():"object"!=typeof e[a]||null===e[a]||Array.isArray(e[a])?p("Cannot redefine existing key '"+o+"'.",n):i&&i.has(o)&&p("Cannot extend inline table '"+o+"'.",n),e=e[a]}var l=t[t.length-1];void 0!==e[l]&&p("Cannot redefine existing key '"+w(t)+"'.",n),e[l]=r}(r,a,e(s.value),s.offset,n),n.add(w(a))}}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])||s.has(g)?p("Cannot redefine existing key '"+g+"'.",l):a.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),s.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),a.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(s.has(r)&&p("Cannot append to statically defined array '"+r+"'.",n),i.forEach(function(e){k(e,r)&&i.delete(e)}),s.forEach(function(e){k(e,r)&&s.delete(e)}),i.add(r),u=g(c,t,function(){var e=[];return l.add(e),e}(),n),o=t,u instanceof Array){var a=b();u.push(a),u=a}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,a=0;a<t.length;a++){var o=t[a],l=w(t.slice(0,a+1));void 0===i[o]?a===t.length-1?i[o]=r:i[o]=b():a!==t.length-1&&s.has(l)&&p("Cannot redefine existing key '"+l+"'.",n),i=i[o],a<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 k(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,s=this.location.source&&"function"==typeof this.location.source.offset?this.location.source.offset(i):i,a=this.location.source+":"+s.line+":"+s.column;if(r){let e=this.location.end,n="".padEnd(s.line.toString().length," "),o=r[i.line-1],l=(i.line===e.line?e.column:o.length+1)-i.column||1;t+="\n --\x3e "+a+"\n"+n+" |\n"+s.line+" | "+o+"\n"+n+" | "+"".padEnd(i.column-1," ")+"".padEnd(l,"^")}else t+="\n at "+a}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 s(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 a(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=>'"'+s(e.text)+'"',class(e){let t=e.parts.map(e=>Array.isArray(e)?a(e[0])+"-"+a(e[1]):a(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?'"'+s(t)+'"':"end of input")+" found."}}e.exports={StartRules:["start"],SyntaxError:t,parse:function(e,r){let n,i={},s=(r=void 0!==r?r:{}).grammarSource,a={start:eP},o=eP,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]/,k=/^[0-7]/,S=/^[01]/,_=/^[ \t]/,$=/^[A-Za-z0-9_\-]/,O=/^["\\btnfre]/,I=eM("#",!1),C=eN([" ",[" ","~"],["€","￿"]],!1,!1,!1),E=eM("[",!1),A=eM("]",!1),T=eM(".",!1),M=eM("=",!1),N=eN(["+","-"],!1,!1,!1),j=eM("inf",!1),F=eM("nan",!1),L=eM('"""',!1),P=eM('"',!1),D=eM("'''",!1),R=eM("'",!1),U=eM("\\",!1),B={type:"any"},q=eM("\r\n",!1),K=eN(['"',"\\",["\0","\b"],["\v","\x1f"],"","\r"],!0,!1,!1),z=eM('""',!1),V=eN(["'",["\0","\b"],["\v","\x1f"],"","\r"],!0,!1,!1),J=eM("''",!1),W=eN(['"',"\\",["\0","\b"],["\n","\x1f"],""],!0,!1,!1),Y=eN(["'",["\0","\b"],["\n","\x1f"],""],!0,!1,!1),G=eN(["e","E"],!1,!1,!1),H=eM("0",!1),Q=eM("0x",!1),Z=eM("0o",!1),X=eM("0b",!1),ee=eN([["0","9"],"_"],!1,!1,!1),et=eN([["1","9"]],!1,!1,!1),er=eN(["_"],!1,!1,!1),en=eN([["0","9"]],!1,!1,!1),ei=eN([["0","9"],["a","f"],["A","F"]],!1,!1,!1),es=eN([["0","7"]],!1,!1,!1),ea=eN(["0","1"],!1,!1,!1),eo=eM("true",!1),el=eM("false",!1),ec=eM(",",!1),eu=eM("{",!1),ed=eM("}",!1),ef=eM("-",!1),eh=eM(":",!1),ep=eM("Z",!0),em=eM("T",!0),eg=eM(" ",!1),ey=eN([" "," "],!1,!1,!1),eb=eM("\n",!1),ev=eM("\r",!1),ew=eM("\uFEFF",!1),ex=eN([["A","Z"],["a","z"],["0","9"],"_","-"],!1,!1,!1),ek=eN(['"',"\\","b","t","n","f","r","e"],!1,!1,!1),eS=eM("\\U",!1),e_=eM("\\u",!1),e$=eM("\\x",!1),eO=0|r.peg$currPos,eI=eO,eC=[{line:1,column:1}],eE=eO,eA=r.peg$maxFailExpected||[],eT=0|r.peg$silentFails;if(r.startRule){if(!(r.startRule in a))throw Error("Can't start parsing from rule \""+r.startRule+'".');o=a[r.startRule]}function eM(e,t){return{type:"literal",text:e,ignoreCase:t}}function eN(e,t,r,n){return{type:"class",parts:e,inverted:t,ignoreCase:r,unicode:n}}function ej(t){let r,n=eC[t];if(n)return n;if(t>=eC.length)r=eC.length-1;else for(r=t;!eC[--r];);for(n={line:(n=eC[r]).line,column:n.column};r<t;)10===e.charCodeAt(r)?(n.line++,n.column=1):n.column++,r++;return eC[t]=n,n}function eF(e,t,r){let n=ej(e),i=ej(t),a={source:s,start:{offset:e,line:n.line,column:n.column},end:{offset:t,line:i.line,column:i.column}};return r&&s&&"function"==typeof s.offset&&(a.start=s.offset(a.start),a.end=s.offset(a.end)),a}function eL(e){eO<eE||(eO>eE&&(eE=eO,eA=[]),eA.push(e))}function eP(){let t,r,n,s;for(t=eO,65279===e.charCodeAt(eO)?(s="\uFEFF",eO++):(s=i,0===eT&&eL(ew)),s===i,r=[],n=eD();n!==i;)r.push(n),n=eD();return eI=t,t=tl}function eD(){let t,r,n,s,a,o,l,c;for(t=eO,r=[],n=te();n!==i;)r.push(n),n=te();if((c=eR())===i&&(c=function(){let t,r,n,s,a,o,l,c;if(t=eO,91===e.charCodeAt(eO)?(r="[",eO++):(r=i,0===eT&&eL(E)),r!==i)if(91===e.charCodeAt(eO)?(n="[",eO++):(n=i,0===eT&&eL(E)),n!==i){for(s=[],a=te();a!==i;)s.push(a),a=te();if((a=eU())!==i){for(o=[],l=te();l!==i;)o.push(l),l=te();(93===e.charCodeAt(eO)?(l="]",eO++):(l=i,0===eT&&eL(A)),l!==i&&(93===e.charCodeAt(eO)?(c="]",eO++):(c=i,0===eT&&eL(A)),c!==i))?t=void tf(th("ArrayPath",a,eI=t)):(eO=t,t=i)}else eO=t,t=i}else eO=t,t=i;else eO=t,t=i;if(t===i)if(t=eO,91===e.charCodeAt(eO)?(r="[",eO++):(r=i,0===eT&&eL(E)),r!==i){for(n=[],s=te();s!==i;)n.push(s),s=te();if((s=eU())!==i){for(a=[],o=te();o!==i;)a.push(o),o=te();(93===e.charCodeAt(eO)?(o="]",eO++):(o=i,0===eT&&eL(A)),o!==i)?t=void tf(th("ObjectPath",s,eI=t)):(eO=t,t=i)}else eO=t,t=i}else eO=t,t=i;return t}())===i&&(c=function(){let t,r,n,s,a,o;if(t=eO,(r=e5())!==i){for(n=[],s=te();s!==i;)n.push(s),s=te();if(61===e.charCodeAt(eO)?(s="=",eO++):(s=i,0===eT&&eL(M)),s!==i){for(a=[],o=te();o!==i;)a.push(o),o=te();if((o=eK())!==i)t=void tf(th("Assign",o,eI=t,r));else eO=t,t=i}else eO=t,t=i}else eO=t,t=i;return t}()),(n=c)!==i){for(s=[],a=te();a!==i;)s.push(a),a=te();if((a=eR())===i&&(a=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,s,a,o]:(eO=t,t=i)}else eO=t,t=i;if(t===i){if(t=eO,r=[],(n=te())!==i)for(;n!==i;)r.push(n),n=te();else r=i;if(r!==i){if(n=[],(s=tt())!==i)for(;s!==i;)n.push(s),s=tt();else n=i;n===i&&(n=tn()),n!==i?t=r=[r,n]:(eO=t,t=i)}else eO=t,t=i;t===i&&(t=tt())}return t}function eR(){let t,r,n,s;if(t=eO,35===e.charCodeAt(eO)?(r="#",eO++):(r=i,0===eT&&eL(I)),r!==i){for(n=[],s=e.charAt(eO),u.test(s)?eO++:(s=i,0===eT&&eL(C));s!==i;)n.push(s),s=e.charAt(eO),u.test(s)?eO++:(s=i,0===eT&&eL(C));t=r=[r,n]}else eO=t,t=i;return t}function eU(){let e,t,r;if(e=eO,t=[],(r=eq())!==i)for(;r!==i;)t.push(r),r=eq();else t=i;if(t!==i)if((r=eB())!==i){var n,s;eI=e,n=t,s=r,e=n.concat(s)}else eO=e,e=i;else eO=e,e=i;return e===i&&(e=eO,(t=eB())!==i&&(eI=e,t=[t]),e=t),e}function eB(){let e,t,r,n,s;for(e=eO,t=[],r=te();r!==i;)t.push(r),r=te();if((r=e8())!==i){for(n=[],s=te();s!==i;)n.push(s),s=te();eI=e,e=r}else eO=e,e=i;return e}function eq(){let t,r,n,s,a;for(t=eO,r=[],n=te();n!==i;)r.push(n),n=te();if((n=e8())!==i){for(s=[],a=te();a!==i;)s.push(a),a=te();(46===e.charCodeAt(eO)?(a=".",eO++):(a=i,0===eT&&eL(T)),a!==i)?(eI=t,t=n):(eO=t,t=i)}else eO=t,t=i;return t}function eK(){let t,r;return(t=eO,eI=eO,++tc>tu&&(tc--,td("Maximum nesting depth of "+tu+" exceeded.",eI)),void 0!==i&&(r=function(){let t,r,n,s,a,o,u,f,h,p,m,b,w,_,$,O,I;if(t=eO,(a=eO,'"""'===e.substr(eO,3)?(o='"""',eO+=3):(o=i,0===eT&&eL(L)),o!==i&&(tt()===i,u=function(){let t,r,n,s,a,o,l,c,u,d,f;for(t=eO,r=[],n=eJ();n!==i;)r.push(n),n=eJ();if(n=[],s=eO,(a=eW())!==i){if(o=[],(l=eJ())!==i)for(;l!==i;)o.push(l),l=eJ();else o=i;o!==i?s=a=[a,o]:(eO=s,s=i)}else eO=s,s=i;for(;s!==i;)if(n.push(s),s=eO,(a=eW())!==i){if(o=[],(l=eJ())!==i)for(;l!==i;)o.push(l),l=eJ();else o=i;o!==i?s=a=[a,o]:(eO=s,s=i)}else eO=s,s=i;return c=eO,'""'===e.substr(eO,2)?(u='""',eO+=2):(u=i,0===eT&&eL(z)),u!==i?(d=eO,eT++,'"""'===e.substr(eO,3)?(f='"""',eO+=3):(f=i,0===eT&&eL(L)),eT--,f!==i?(eO=d,d=void 0):d=i,d!==i?(eI=c,c='""'):(eO=c,c=i)):(eO=c,c=i),c===i&&(c=eO,34===e.charCodeAt(eO)?(u='"',eO++):(u=i,0===eT&&eL(P)),u!==i?(d=eO,eT++,'"""'===e.substr(eO,3)?(f='"""',eO+=3):(f=i,0===eT&&eL(L)),eT--,f!==i?(eO=d,d=void 0):d=i,d!==i?(eI=c,c='"'):(eO=c,c=i)):(eO=c,c=i)),(s=c)===i&&(s=null),eI=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,s)}(),'"""'===e.substr(eO,3)?(f='"""',eO+=3):(f=i,0===eT&&eL(L)),f!==i))?a=th("String",u,eI=a):(eO=a,a=i),(s=a)===i&&(s=ez())===i&&((h=eO,"'''"===e.substr(eO,3)?(p="'''",eO+=3):(p=i,0===eT&&eL(D)),p!==i&&(tt()===i,m=function(){let t,r,n,s,a,o,l,c,u,d,f;for(t=eO,r=[],n=eY();n!==i;)r.push(n),n=eY();if(n=[],s=eO,(a=eG())!==i){if(o=[],(l=eY())!==i)for(;l!==i;)o.push(l),l=eY();else o=i;o!==i?s=a=[a,o]:(eO=s,s=i)}else eO=s,s=i;for(;s!==i;)if(n.push(s),s=eO,(a=eG())!==i){if(o=[],(l=eY())!==i)for(;l!==i;)o.push(l),l=eY();else o=i;o!==i?s=a=[a,o]:(eO=s,s=i)}else eO=s,s=i;return c=eO,"''"===e.substr(eO,2)?(u="''",eO+=2):(u=i,0===eT&&eL(J)),u!==i?(d=eO,eT++,"'''"===e.substr(eO,3)?(f="'''",eO+=3):(f=i,0===eT&&eL(D)),eT--,f!==i?(eO=d,d=void 0):d=i,d!==i?(eI=c,c="''"):(eO=c,c=i)):(eO=c,c=i),c===i&&(c=eO,39===e.charCodeAt(eO)?(u="'",eO++):(u=i,0===eT&&eL(R)),u!==i?(d=eO,eT++,"'''"===e.substr(eO,3)?(f="'''",eO+=3):(f=i,0===eT&&eL(D)),eT--,f!==i?(eO=d,d=void 0):d=i,d!==i?(eI=c,c="'"):(eO=c,c=i)):(eO=c,c=i)),(s=c)===i&&(s=null),eI=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,s)}(),"'''"===e.substr(eO,3)?(b="'''",eO+=3):(b=i,0===eT&&eL(D)),b!==i))?h=th("String",m,eI=h):(eO=h,h=i),(s=h)===i)&&(s=eV()),(n=s)===i&&((w=eO,_=e.charAt(eO),d.test(_)?eO++:(_=i,0===eT&&eL(N)),_===i&&(_=null),"inf"===e.substr(eO,3)?($="inf",eO+=3):($=i,0===eT&&eL(j)),$!==i)?w=th("Float","-"===_?-1/0:1/0,eI=w):(eO=w,w=i),w===i&&(w=eO,_=e.charAt(eO),d.test(_)?eO++:(_=i,0===eT&&eL(N)),_===i&&(_=null),"nan"===e.substr(eO,3)?($="nan",eO+=3):($=i,0===eT&&eL(F)),$!==i?w=th("Float",NaN,eI=w):(eO=w,w=i),w===i&&(w=function(){var t,r,n,s,a,o,l,c,u,f,h;let p,m,g,y,b;if(p=eO,(m=e6())!==i)if((g=e7())!==i)if((y=e9())!==i){let a,o,l,c,u,f,h,g;(a=eO,"z"===(o=e.charAt(eO)).toLowerCase()?eO++:(o=i,0===eT&&eL(ep)),o!==i&&(eI=a,o="Z"),(a=o)===i&&(a=eO,o=eO,l=e.charAt(eO),d.test(l)?eO++:(l=i,0===eT&&eL(N)),l!==i&&(c=ti())!==i&&(u=ti())!==i?(58===e.charCodeAt(eO)?(f=":",eO++):(f=i,0===eT&&eL(eh)),f!==i&&(h=ti())!==i&&(g=ti())!==i?o=l=[l,c,u,f,h,g]:(eO=o,o=i)):(eO=o,o=i),a=o!==i?e.substring(a,eO):o),(b=a)!==i)?(eI=p,t=m,r=y,tp(t,n=eI),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),(s=th("Date",new Date(t+"T"+r+b),n)).raw=t+"T"+r,s.tz=b,p=s):(eO=p,p=i)}else eO=p,p=i;else eO=p,p=i;else eO=p,p=i;return p===i&&((p=eO,(m=e6())!==i&&(g=e7())!==i&&(y=e9())!==i)?(eI=p,a=m,o=y,tp(a,l=eI),tm(o,l),p=th("LocalDateTime",a+"T"+o,l)):(eO=p,p=i),p===i&&((p=eO,(m=e6())!==i&&(g=eO,eT++,y=e7(),eT--,y===i?g=void 0:(eO=g,g=i),g!==i))?(eI=p,tp(c=m,u=eI),p=th("LocalDate",c,u)):(eO=p,p=i),p===i&&(p=eO,(m=e9())!==i&&(eI=p,tm(f=m,h=eI),m=th("LocalTime",f,h)),p=m))),p}())===i&&(w=function(){let t,r,n,s,a,o,l,c,u,f;if(t=eO,(a=eO,o=e.charAt(eO),d.test(o)?eO++:(o=i,0===eT&&eL(N)),o===i&&(o=null),(l=eZ())!==i&&(46===e.charCodeAt(eO)?(c=".",eO++):(c=i,0===eT&&eL(T)),c!==i&&(u=eO,(u=(f=e0())!==i?e.substring(u,eO):f)!==i)))?(eI=a,a=("-"===o?"-":"")+l+"."+u):(eO=a,a=i),a===i&&((a=eO,o=e.charAt(eO),d.test(o)?eO++:(o=i,0===eT&&eL(N)),o===i&&(o=null),(l=eZ())!==i)?(eI=a,a=("-"===o?"-":"")+l):(eO=a,a=i)),(r=a)!==i)if(n=e.charAt(eO),g.test(n)?eO++:(n=i,0===eT&&eL(G)),n!==i){let n,a,o,l;if((n=eO,a=e.charAt(eO),d.test(a)?eO++:(a=i,0===eT&&eL(N)),a===i&&(a=null),o=eO,(o=(l=e0())!==i?e.substring(o,eO):l)!==i)?(eI=n,n=(a||"")+o):(eO=n,n=i),(s=n)!==i)eI=t,t=th("Float",parseFloat(tg(r+"e"+s)),eI);else eO=t,t=i}else eO=t,t=i;else eO=t,t=i;if(t===i){let n,s,a,o,l,c;t=eO,(n=eO,s=e.charAt(eO),d.test(s)?eO++:(s=i,0===eT&&eL(N)),s===i&&(s=null),(a=eZ())!==i&&(46===e.charCodeAt(eO)?(o=".",eO++):(o=i,0===eT&&eL(T)),o!==i&&(l=eO,(l=(c=e0())!==i?e.substring(l,eO):c)!==i)))?(eI=n,n=("-"===s?"-":"")+a+"."+l):(eO=n,n=i),(r=n)!==i&&(eI=t,r=th("Float",parseFloat(tg(r)),eI)),t=r}return t}())===i&&(w=function(){let t,r,n,s;if(((t=eO,"0x"===e.substr(eO,2)?(r="0x",eO+=2):(r=i,0===eT&&eL(Q)),r!==i&&(n=eO,(n=(s=function(){let t,r,n,s,a,o;if(t=eO,r=e.charAt(eO),x.test(r)?eO++:(r=i,0===eT&&eL(ei)),r!==i){for(n=[],s=eO,a=e.charAt(eO),v.test(a)?eO++:(a=i,0===eT&&eL(er)),a===i&&(a=null),o=e.charAt(eO),x.test(o)?eO++:(o=i,0===eT&&eL(ei)),o!==i?s=a=[a,o]:(eO=s,s=i);s!==i;)n.push(s),s=eO,a=e.charAt(eO),v.test(a)?eO++:(a=i,0===eT&&eL(er)),a===i&&(a=null),o=e.charAt(eO),x.test(o)?eO++:(o=i,0===eT&&eL(ei)),o!==i?s=a=[a,o]:(eO=s,s=i);t=r=[r,n]}else eO=t,t=i;return t}())!==i?e.substring(n,eO):s)!==i))?(eI=t,t=th("Integer",parseInt(tg(n),16),eI)):(eO=t,t=i),t===i)&&((t=eO,"0o"===e.substr(eO,2)?(r="0o",eO+=2):(r=i,0===eT&&eL(Z)),r!==i&&(n=eO,(n=(s=function(){let t,r,n,s,a,o;if(t=eO,r=e.charAt(eO),k.test(r)?eO++:(r=i,0===eT&&eL(es)),r!==i){for(n=[],s=eO,a=e.charAt(eO),v.test(a)?eO++:(a=i,0===eT&&eL(er)),a===i&&(a=null),o=e.charAt(eO),k.test(o)?eO++:(o=i,0===eT&&eL(es)),o!==i?s=a=[a,o]:(eO=s,s=i);s!==i;)n.push(s),s=eO,a=e.charAt(eO),v.test(a)?eO++:(a=i,0===eT&&eL(er)),a===i&&(a=null),o=e.charAt(eO),k.test(o)?eO++:(o=i,0===eT&&eL(es)),o!==i?s=a=[a,o]:(eO=s,s=i);t=r=[r,n]}else eO=t,t=i;return t}())!==i?e.substring(n,eO):s)!==i))?(eI=t,t=th("Integer",parseInt(tg(n),8),eI)):(eO=t,t=i),t===i)&&((t=eO,"0b"===e.substr(eO,2)?(r="0b",eO+=2):(r=i,0===eT&&eL(X)),r!==i&&(n=eO,(n=(s=function(){let t,r,n,s,a,o;if(t=eO,r=e.charAt(eO),S.test(r)?eO++:(r=i,0===eT&&eL(ea)),r!==i){for(n=[],s=eO,a=e.charAt(eO),v.test(a)?eO++:(a=i,0===eT&&eL(er)),a===i&&(a=null),o=e.charAt(eO),S.test(o)?eO++:(o=i,0===eT&&eL(ea)),o!==i?s=a=[a,o]:(eO=s,s=i);s!==i;)n.push(s),s=eO,a=e.charAt(eO),v.test(a)?eO++:(a=i,0===eT&&eL(er)),a===i&&(a=null),o=e.charAt(eO),S.test(o)?eO++:(o=i,0===eT&&eL(ea)),o!==i?s=a=[a,o]:(eO=s,s=i);t=r=[r,n]}else eO=t,t=i;return t}())!==i?e.substring(n,eO):s)!==i))?(eI=t,t=th("Integer",parseInt(tg(n),2),eI)):(eO=t,t=i),t===i)){let n,s,a,o,l,c;t=eO,(n=eO,s=e.charAt(eO),d.test(s)?eO++:(s=i,0===eT&&eL(N)),s===i&&(s=null),48===e.charCodeAt(eO)?(a="0",eO++):(a=i,0===eT&&eL(H)),a!==i&&(o=eO,eT++,l=e.charAt(eO),y.test(l)?eO++:(l=i,0===eT&&eL(ee)),eT--,l===i?o=void 0:(eO=o,o=i),o!==i&&(l=eO,eT++,46===e.charCodeAt(eO)?(c=".",eO++):(c=i,0===eT&&eL(T)),eT--,c===i?l=void 0:(eO=l,l=i),l!==i)))?(eI=n,n=(s||"")+"0"):(eO=n,n=i),n===i&&((n=eO,s=e.charAt(eO),d.test(s)?eO++:(s=i,0===eT&&eL(N)),s===i&&(s=null),a=eO,(a=(o=eX())!==i?e.substring(a,eO):o)!==i&&(o=eO,eT++,46===e.charCodeAt(eO)?(l=".",eO++):(l=i,0===eT&&eL(T)),eT--,l===i?o=void 0:(eO=o,o=i),o!==i))?(eI=n,n=(s||"")+a):(eO=n,n=i)),(r=n)!==i&&(eI=t,r=th("Integer",parseInt(tg(r),10),eI)),t=r}return t}())),(n=w)===i&&(O=eO,e.substr(eO,4)===l?(I=l,eO+=4):(I=i,0===eT&&eL(eo)),I!==i&&(I=th("Boolean",!0,eI=O)),(O=I)===i&&(O=eO,e.substr(eO,5)===c?(I=c,eO+=5):(I=i,0===eT&&eL(el)),I!==i&&(I=th("Boolean",!1,eI=O)),O=I),(n=O)===i&&(n=function(){let t,r,n,s,a,o,l,c,u,d;if(t=eO,91===e.charCodeAt(eO)?(r="[",eO++):(r=i,0===eT&&eL(E)),r!==i){for(n=[],s=e1();s!==i;)n.push(s),s=e1();93===e.charCodeAt(eO)?(s="]",eO++):(s=i,0===eT&&eL(A)),s!==i?t=th("Array",[],eI=t):(eO=t,t=i)}else eO=t,t=i;if(t===i)if(t=eO,91===e.charCodeAt(eO)?(r="[",eO++):(r=i,0===eT&&eL(E)),r!==i){for(n=[],s=e1();s!==i;)n.push(s),s=e1();if((s=eK())!==i){for(a=[],o=eO,l=[],c=e1();c!==i;)l.push(c),c=e1();if(44===e.charCodeAt(eO)?(c=",",eO++):(c=i,0===eT&&eL(ec)),c!==i){for(u=[],d=e1();d!==i;)u.push(d),d=e1();(d=eK())!==i?(eI=o,o=d):(eO=o,o=i)}else eO=o,o=i;for(;o!==i;){for(a.push(o),o=eO,l=[],c=e1();c!==i;)l.push(c),c=e1();if(44===e.charCodeAt(eO)?(c=",",eO++):(c=i,0===eT&&eL(ec)),c!==i){for(u=[],d=e1();d!==i;)u.push(d),d=e1();(d=eK())!==i?(eI=o,o=d):(eO=o,o=i)}else eO=o,o=i}for(o=[],l=e1();l!==i;)o.push(l),l=e1();for(44===e.charCodeAt(eO)?(l=",",eO++):(l=i,0===eT&&eL(ec)),l===i&&(l=null),c=[],u=e1();u!==i;)c.push(u),u=e1();if(93===e.charCodeAt(eO)?(u="]",eO++):(u=i,0===eT&&eL(A)),u!==i){var f;eI=t,f=s,a.unshift(f),t=th("Array",a,eI)}else eO=t,t=i}else eO=t,t=i}else eO=t,t=i;return t}())===i))&&(n=function(){let t,r,n,s,a,o,l,c,u,d;if(t=eO,123===e.charCodeAt(eO)?(r="{",eO++):(r=i,0===eT&&eL(eu)),r!==i){for(n=[],s=e3();s!==i;)n.push(s),s=e3();125===e.charCodeAt(eO)?(s="}",eO++):(s=i,0===eT&&eL(ed)),s!==i?t=th("InlineTable",[],eI=t):(eO=t,t=i)}else eO=t,t=i;if(t===i)if(t=eO,123===e.charCodeAt(eO)?(r="{",eO++):(r=i,0===eT&&eL(eu)),r!==i){for(n=[],s=e3();s!==i;)n.push(s),s=e3();if((s=e2())!==i){for(a=[],o=eO,l=[],c=e3();c!==i;)l.push(c),c=e3();if(44===e.charCodeAt(eO)?(c=",",eO++):(c=i,0===eT&&eL(ec)),c!==i){for(u=[],d=e3();d!==i;)u.push(d),d=e3();(d=e2())!==i?(eI=o,o=d):(eO=o,o=i)}else eO=o,o=i;for(;o!==i;){for(a.push(o),o=eO,l=[],c=e3();c!==i;)l.push(c),c=e3();if(44===e.charCodeAt(eO)?(c=",",eO++):(c=i,0===eT&&eL(ec)),c!==i){for(u=[],d=e3();d!==i;)u.push(d),d=e3();(d=e2())!==i?(eI=o,o=d):(eO=o,o=i)}else eO=o,o=i}for(o=[],l=e3();l!==i;)o.push(l),l=e3();for(44===e.charCodeAt(eO)?(l=",",eO++):(l=i,0===eT&&eL(ec)),l===i&&(l=null),c=[],u=e3();u!==i;)c.push(u),u=e3();if(125===e.charCodeAt(eO)?(u="}",eO++):(u=i,0===eT&&eL(ed)),u!==i){var f;eI=t,f=s,a.unshift(f),t=th("InlineTable",a,eI)}else eO=t,t=i}else eO=t,t=i}else eO=t,t=i;return t}()),(r=n)!==i){var C;eI=t,C=r,tc--,r=C}return(t=r)===i&&(eI=eO,tc--,t=!1,t=i),t}())!==i)?(eI=t,t=r):(eO=t,t=i),t}function ez(){let t,r,n,s;if(t=eO,34===e.charCodeAt(eO)?(r='"',eO++):(r=i,0===eT&&eL(P)),r!==i){for(n=[],s=eH();s!==i;)n.push(s),s=eH();(34===e.charCodeAt(eO)?(s='"',eO++):(s=i,0===eT&&eL(P)),s!==i)?(eI=t,t=th("String",n.join(""),eI)):(eO=t,t=i)}else eO=t,t=i;return t}function eV(){let t,r,n,s;if(t=eO,39===e.charCodeAt(eO)?(r="'",eO++):(r=i,0===eT&&eL(R)),r!==i){for(n=[],s=eQ();s!==i;)n.push(s),s=eQ();(39===e.charCodeAt(eO)?(s="'",eO++):(s=i,0===eT&&eL(R)),s!==i)?(eI=t,t=th("String",n.join(""),eI)):(eO=t,t=i)}else eO=t,t=i;return t}function eJ(){let t,r,n;if((t=to())===i&&(t=function(){let t,r,n,s,a,o;if(t=eO,92===e.charCodeAt(eO)?(r="\\",eO++):(r=i,0===eT&&eL(U)),r!==i){for(n=[],s=te();s!==i;)n.push(s),s=te();if((s=tt())!==i){for(a=[],o=tr();o!==i;)a.push(o),o=tr();eI=t,t=""}else eO=t,t=i}else eO=t,t=i;return t}())===i&&(t=eO,92===e.charCodeAt(eO)?(r="\\",eO++):(r=i,0===eT&&eL(U)),r!==i?(e.length>eO?(n=e.charAt(eO),eO++):(n=i,0===eT&&eL(B)),n!==i?t=void td("Invalid escape sequence",eI=t):(eO=t,t=i)):(eO=t,t=i),t===i)&&(t=eO,"\r\n"===e.substr(eO,2)?(r="\r\n",eO+=2):(r=i,0===eT&&eL(q)),r!==i&&(eI=t,r="\n"),(t=r)===i)){if(t=eO,r=[],n=e.charAt(eO),f.test(n)?eO++:(n=i,0===eT&&eL(K)),n!==i)for(;n!==i;)r.push(n),n=e.charAt(eO),f.test(n)?eO++:(n=i,0===eT&&eL(K));else r=i;t=r!==i?e.substring(t,eO):r}return t}function eW(){let t,r,n,s;return t=eO,'""'===e.substr(eO,2)?(r='""',eO+=2):(r=i,0===eT&&eL(z)),r!==i?(n=eO,eT++,34===e.charCodeAt(eO)?(s='"',eO++):(s=i,0===eT&&eL(P)),eT--,s===i?n=void 0:(eO=n,n=i),n!==i?(eI=t,t='""'):(eO=t,t=i)):(eO=t,t=i),t===i&&(t=eO,34===e.charCodeAt(eO)?(r='"',eO++):(r=i,0===eT&&eL(P)),r!==i?(n=eO,eT++,34===e.charCodeAt(eO)?(s='"',eO++):(s=i,0===eT&&eL(P)),eT--,s===i?n=void 0:(eO=n,n=i),n!==i?(eI=t,t='"'):(eO=t,t=i)):(eO=t,t=i)),t}function eY(){let t,r,n;if(t=eO,"\r\n"===e.substr(eO,2)?(r="\r\n",eO+=2):(r=i,0===eT&&eL(q)),r!==i&&(eI=t,r="\n"),(t=r)===i){if(t=eO,r=[],n=e.charAt(eO),h.test(n)?eO++:(n=i,0===eT&&eL(V)),n!==i)for(;n!==i;)r.push(n),n=e.charAt(eO),h.test(n)?eO++:(n=i,0===eT&&eL(V));else r=i;t=r!==i?e.substring(t,eO):r}return t}function eG(){let t,r,n,s;return t=eO,"''"===e.substr(eO,2)?(r="''",eO+=2):(r=i,0===eT&&eL(J)),r!==i?(n=eO,eT++,39===e.charCodeAt(eO)?(s="'",eO++):(s=i,0===eT&&eL(R)),eT--,s===i?n=void 0:(eO=n,n=i),n!==i?(eI=t,t="''"):(eO=t,t=i)):(eO=t,t=i),t===i&&(t=eO,39===e.charCodeAt(eO)?(r="'",eO++):(r=i,0===eT&&eL(R)),r!==i?(n=eO,eT++,39===e.charCodeAt(eO)?(s="'",eO++):(s=i,0===eT&&eL(R)),eT--,s===i?n=void 0:(eO=n,n=i),n!==i?(eI=t,t="'"):(eO=t,t=i)):(eO=t,t=i)),t}function eH(){let t,r,n;if((t=to())===i&&(t=eO,92===e.charCodeAt(eO)?(r="\\",eO++):(r=i,0===eT&&eL(U)),r!==i?(e.length>eO?(n=e.charAt(eO),eO++):(n=i,0===eT&&eL(B)),n!==i?t=void td("Invalid escape sequence",eI=t):(eO=t,t=i)):(eO=t,t=i),t===i)){if(t=eO,r=[],n=e.charAt(eO),p.test(n)?eO++:(n=i,0===eT&&eL(W)),n!==i)for(;n!==i;)r.push(n),n=e.charAt(eO),p.test(n)?eO++:(n=i,0===eT&&eL(W));else r=i;t=r!==i?e.substring(t,eO):r}return t}function eQ(){let t,r,n;if(t=eO,r=[],n=e.charAt(eO),m.test(n)?eO++:(n=i,0===eT&&eL(Y)),n!==i)for(;n!==i;)r.push(n),n=e.charAt(eO),m.test(n)?eO++:(n=i,0===eT&&eL(Y));else r=i;return r!==i?e.substring(t,eO):r}function eZ(){let t,r;return t=eO,48===e.charCodeAt(eO)?(r="0",eO++):(r=i,0===eT&&eL(H)),r!==i&&(eI=t,r="0"),(t=r)===i&&(t=eO,t=(r=eX())!==i?e.substring(t,eO):r),t}function eX(){let t,r,n,s,a,o;if(t=eO,r=e.charAt(eO),b.test(r)?eO++:(r=i,0===eT&&eL(et)),r!==i){for(n=[],s=eO,a=e.charAt(eO),v.test(a)?eO++:(a=i,0===eT&&eL(er)),a===i&&(a=null),o=e.charAt(eO),w.test(o)?eO++:(o=i,0===eT&&eL(en)),o!==i?s=a=[a,o]:(eO=s,s=i);s!==i;)n.push(s),s=eO,a=e.charAt(eO),v.test(a)?eO++:(a=i,0===eT&&eL(er)),a===i&&(a=null),o=e.charAt(eO),w.test(o)?eO++:(o=i,0===eT&&eL(en)),o!==i?s=a=[a,o]:(eO=s,s=i);t=r=[r,n]}else eO=t,t=i;return t}function e0(){let t,r,n,s,a,o;if(t=eO,r=e.charAt(eO),w.test(r)?eO++:(r=i,0===eT&&eL(en)),r!==i){for(n=[],s=eO,a=e.charAt(eO),v.test(a)?eO++:(a=i,0===eT&&eL(er)),a===i&&(a=null),o=e.charAt(eO),w.test(o)?eO++:(o=i,0===eT&&eL(en)),o!==i?s=a=[a,o]:(eO=s,s=i);s!==i;)n.push(s),s=eO,a=e.charAt(eO),v.test(a)?eO++:(a=i,0===eT&&eL(er)),a===i&&(a=null),o=e.charAt(eO),w.test(o)?eO++:(o=i,0===eT&&eL(en)),o!==i?s=a=[a,o]:(eO=s,s=i);t=r=[r,n]}else eO=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,s,a,o;if(t=eO,(r=e5())!==i){for(n=[],s=te();s!==i;)n.push(s),s=te();if(61===e.charCodeAt(eO)?(s="=",eO++):(s=i,0===eT&&eL(M)),s!==i){for(a=[],o=te();o!==i;)a.push(o),o=te();if((o=eK())!==i)t=th("InlineTableValue",o,eI=t,r);else eO=t,t=i}else eO=t,t=i}else eO=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=eO,t=[],(r=e4())!==i)for(;r!==i;)t.push(r),r=e4();else t=i;if(t!==i){for(r=[],n=te();n!==i;)r.push(n),n=te();if((n=e8())!==i){var s,a;eI=e,s=t,a=n,e=s.concat(a)}else eO=e,e=i}else eO=e,e=i;return e===i&&(e=eO,(t=e8())!==i&&(eI=e,t=[t]),e=t),e}function e4(){let t,r,n,s,a;for(t=eO,r=[],n=te();n!==i;)r.push(n),n=te();if((n=e8())!==i){for(s=[],a=te();a!==i;)s.push(a),a=te();(46===e.charCodeAt(eO)?(a=".",eO++):(a=i,0===eT&&eL(T)),a!==i)?(eI=t,t=n):(eO=t,t=i)}else eO=t,t=i;return t}function e8(){let t,r,n;return(t=function(){let t,r,n;if(t=eO,r=[],(n=ta())!==i)for(;n!==i;)r.push(n),n=ta();else r=i;return r!==i?e.substring(t,eO):r}())===i&&(r=eO,(n=ez())!==i&&(eI=r,n=n.value),(r=n)===i&&(r=eO,(n=eV())!==i&&(eI=r,n=n.value),r=n),t=r),t}function e6(){let t,r,n,s,a,o,l,c,u,d,f,h;return t=eO,r=eO,(n=ti())!==i&&(s=ti())!==i&&(a=ti())!==i&&(o=ti())!==i?(45===e.charCodeAt(eO)?(l="-",eO++):(l=i,0===eT&&eL(ef)),l!==i&&(c=ti())!==i&&(u=ti())!==i?(45===e.charCodeAt(eO)?(d="-",eO++):(d=i,0===eT&&eL(ef)),d!==i&&(f=ti())!==i&&(h=ti())!==i?r=n=[n,s,a,o,l,c,u,d,f,h]:(eO=r,r=i)):(eO=r,r=i)):(eO=r,r=i),t=r!==i?e.substring(t,eO):r}function e9(){let t,r,n,s,a,o,l,c,u,d,f;if(t=eO,r=eO,n=eO,(s=ti())!==i&&(a=ti())!==i?(58===e.charCodeAt(eO)?(o=":",eO++):(o=i,0===eT&&eL(eh)),o!==i&&(l=ti())!==i&&(c=ti())!==i?(58===e.charCodeAt(eO)?(u=":",eO++):(u=i,0===eT&&eL(eh)),u!==i&&(d=ti())!==i&&(f=ti())!==i?n=s=[s,a,o,l,c,u,d,f]:(eO=n,n=i)):(eO=n,n=i)):(eO=n,n=i),(r=n!==i?e.substring(r,eO):n)!==i){var h,p;(n=function(){let t,r,n,s,a;if(t=eO,r=eO,46===e.charCodeAt(eO)?(n=".",eO++):(n=i,0===eT&&eL(T)),n!==i){if(s=[],(a=ti())!==i)for(;a!==i;)s.push(a),a=ti();else s=i;s!==i?r=n=[n,s]:(eO=r,r=i)}else eO=r,r=i;return r!==i?e.substring(t,eO):r}())===i&&(n=null),eI=t,h=r,t=(p=n)?h+p:h}else eO=t,t=i;return t===i&&((t=eO,r=eO,n=eO,(s=ti())!==i&&(a=ti())!==i?(58===e.charCodeAt(eO)?(o=":",eO++):(o=i,0===eT&&eL(eh)),o!==i&&(l=ti())!==i&&(c=ti())!==i?n=s=[s,a,o,l,c]:(eO=n,n=i)):(eO=n,n=i),(r=n!==i?e.substring(r,eO):n)!==i&&(n=eO,eT++,58===e.charCodeAt(eO)?(s=":",eO++):(s=i,0===eT&&eL(eh)),eT--,s===i?n=void 0:(eO=n,n=i),n!==i))?(eI=t,t=r+":00"):(eO=t,t=i)),t}function e7(){let t,r,n,s;return"t"===(t=e.charAt(eO)).toLowerCase()?eO++:(t=i,0===eT&&eL(em)),t===i&&(t=eO,32===e.charCodeAt(eO)?(r=" ",eO++):(r=i,0===eT&&eL(eg)),r!==i?(n=eO,eT++,s=ti(),eT--,s!==i?(eO=n,n=void 0):n=i,n!==i?t=r=[r,n]:(eO=t,t=i)):(eO=t,t=i)),t}function te(){let t;return t=e.charAt(eO),_.test(t)?eO++:(t=i,0===eT&&eL(ey)),t}function tt(){let t,r,n;return 10===e.charCodeAt(eO)?(t="\n",eO++):(t=i,0===eT&&eL(eb)),t===i&&(t=eO,13===e.charCodeAt(eO)?(r="\r",eO++):(r=i,0===eT&&eL(ev)),r!==i?(10===e.charCodeAt(eO)?(n="\n",eO++):(n=i,0===eT&&eL(eb)),n!==i?t=r=[r,n]:(eO=t,t=i)):(eO=t,t=i)),t}function tr(){let e;return(e=tt())===i&&(e=te()),e}function tn(){let t,r;return t=eO,eT++,e.length>eO?(r=e.charAt(eO),eO++):(r=i,0===eT&&eL(B)),eT--,r===i?t=void 0:(eO=t,t=i),t}function ti(){let t;return t=e.charAt(eO),w.test(t)?eO++:(t=i,0===eT&&eL(en)),t}function ts(){let t;return t=e.charAt(eO),x.test(t)?eO++:(t=i,0===eT&&eL(ei)),t}function ta(){let t;return t=e.charAt(eO),$.test(t)?eO++:(t=i,0===eT&&eL(ex)),t}function to(){let t,r,n,s,a,o,l,c,u,d,f,h,p,m,g;if(t=eO,92===e.charCodeAt(eO)?(r="\\",eO++):(r=i,0===eT&&eL(U)),r!==i)if(n=e.charAt(eO),O.test(n)?eO++:(n=i,0===eT&&eL(ek)),n!==i){var y;eI=t,t="n"===(y=n)?"\n":"t"===y?" ":"r"===y?"\r":"\\"===y?"\\":'"'===y?'"':"b"===y?"\b":"f"===y?"\f":"\x1b"}else eO=t,t=i;else eO=t,t=i;return t===i&&((s=eO,"\\U"===e.substr(eO,2)?(a="\\U",eO+=2):(a=i,0===eT&&eL(eS)),a!==i&&(o=eO,l=eO,(c=ts())!==i&&(u=ts())!==i&&(d=ts())!==i&&(f=ts())!==i&&(h=ts())!==i&&(p=ts())!==i&&(m=ts())!==i&&(g=ts())!==i?l=c=[c,u,d,f,h,p,m,g]:(eO=l,l=i),(o=l!==i?e.substring(o,eO):l)!==i))?(eI=s,s=ty(o)):(eO=s,s=i),s===i&&((s=eO,"\\u"===e.substr(eO,2)?(a="\\u",eO+=2):(a=i,0===eT&&eL(e_)),a!==i&&(o=eO,l=eO,(c=ts())!==i&&(u=ts())!==i&&(d=ts())!==i&&(f=ts())!==i?l=c=[c,u,d,f]:(eO=l,l=i),(o=l!==i?e.substring(o,eO):l)!==i))?(eI=s,s=ty(o)):(eO=s,s=i),s===i&&((s=eO,"\\x"===e.substr(eO,2)?(a="\\x",eO+=2):(a=i,0===eT&&eL(e$)),a!==i&&(o=eO,l=eO,(c=ts())!==i&&(u=ts())!==i?l=c=[c,u]:(eO=l,l=i),(o=l!==i?e.substring(o,eO):l)!==i))?(eI=s,s=ty(o)):(eO=s,s=i))),t=s),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 s=[31,28,31,30,31,30,31,31,30,31,30,31];(r%4==0&&r%100!=0||r%400==0)&&(s[1]=29),(i<1||i>s[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,eI)}let tb=(n=o())!==i&&eO===e.length;function tv(){var r,s,a;throw n!==i&&eO<e.length&&eL({type:"end"}),r=eA,s=eE<e.length?function(t=eO){let r=e.codePointAt(t);return void 0===r?"":String.fromCodePoint(r)}(eE):null,a=eE<e.length?eF(eE,eE+1):eF(eE,eE),new t(t.buildMessage(r,s),r,s,a)}return r.peg$library?{peg$result:n,peg$currPos:eO,peg$FAILED:i,peg$maxFailExpected:eA,peg$maxFailPos:eE,peg$success:tb,peg$throw:tb?void 0:tv}:tb?n:void tv()}}},181(e){e.exports=t("buffer")},932(e){e.exports=t("process")},7876(e,t,r){var n=r(6730),i=r(8376),s=r(73),a=r(7028),o=r(3244),l=r(6225),c=r(9661);function u(e,t,r,n,i,s){let a="block-map"===r.type?o.resolveBlockMap(e,t,r,n,s):"block-seq"===r.type?l.resolveBlockSeq(e,t,r,n,s):c.resolveFlowCollection(e,t,r,n,s),u=a.constructor;return"!"===i||i===u.tagName?a.tag=u.tagName:i&&(a.tag=i),a}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===s.YAMLMap.tagName&&"map"===f||d===a.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),s=r(4915),a=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=a.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=s.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),s=r(7876),a=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},s){let a=new n.Alias(r.substring(1));""===a.source&&s(t,"BAD_ALIAS","Alias cannot be an empty string"),a.source.endsWith(":")&&s(t+r.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let l=t+r.length,c=o.resolveEnd(i,l,e.strict,s);return a.range=[t,l,c.offset],c.comment&&(a.comment=c.comment),a}(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=a.composeScalar(e,t,g,l),m&&(u.anchor=m.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{u=s.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:s,anchor:o,tag:c,end:u},f){let h={type:"scalar",offset:l.emptyScalarPosition(t,r,n),indent:-1,source:""},p=a.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),s&&(p.comment=s,p.range[2]=u),p}t.composeEmptyNode=d,t.composeNode=u},5120(e,t,r){var n=r(6730),i=r(8376),s=r(2992),a=r(3165);t.composeScalar=function(e,t,r,o){let l,c,{value:u,type:d,comment:f,range:h}="block-scalar"===t.type?s.resolveBlockScalar(e,t,o):a.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,s){if("!"===r)return e[n.SCALAR];let a=[];for(let t of e.tags)if(!t.collection&&t.tag===r)if(!t.default||!t.test)return t;else a.push(t);for(let e of a)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):(s(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,s,a){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);a(s,"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 s=l.resolve(u,e=>o(r??t,"TAG_RESOLVE_FAILED",e),e.options);c=n.isScalar(s)?s:new i.Scalar(s)}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),s=r(9960),a=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 s=e[i];switch(s[0]){case"#":t+=(""===t?"":n?"\n\n":"\n")+(s.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 a.YAMLWarning(i,t,r)):this.errors.push(new a.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}
3
+ ${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}
4
+ ${t}`:r}else{let e=i.commentBefore;i.commentBefore=e?`${r}
5
+ ${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 a.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 a.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}
6
+ ${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new a.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 s.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),s=r(7800),a=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=s.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||a.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,k=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,k)&&d(x,"DUPLICATE_KEY","Map keys must be unique");let S=s.resolveProps(y??[],{indicator:"map-value-ind",next:b,offset:k.range[2],onError:d,parentIndent:u.indent,startOnNewline:!g||"block-scalar"===g.type});if(p=S.end,S.found){w&&(b?.type!=="block-map"||S.hasNewline||d(p,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),r.options.strict&&v.start<S.found.offset-1024&&d(k.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let s=b?e(r,b,S,d):t(r,p,y,null,S,d);r.schema.compat&&o.flowIndentCheck(u.indent,b,d),p=s.range[2];let a=new n.Pair(k,s);r.options.keepSourceTokens&&(a.srcToken=i),h.items.push(a)}else{w&&d(k.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),S.comment&&(k.comment?k.comment+="\n"+S.comment:k.comment=S.comment);let e=new n.Pair(k);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,s=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],s=i[0],a=0,o="",l=-1;for(let t=1;t<i.length;++t){let r=i[t];if(o||"-"!==r&&"+"!==r){let n=Number(r);!a&&n?a=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:s,indent:a,chomp:o,comment:u,length:d}}(t,e.options.strict,r);if(!s)return{value:"",type:null,comment:"",range:[i,i,i]};let a=">"===s.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="+"===s.chomp&&o.length>0?"\n".repeat(Math.max(1,o.length-1)):"",r=i+s.length;return t.source&&(r+=t.source.length),{value:e,type:a,comment:s.comment,range:[i,r,r]}}let c=t.indent+s.indent,u=t.offset+s.length,d=0;for(let t=0;t<l;++t){let[n,i]=o[t];if(""===i||"\r"===i)0===s.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===s.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=s.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=""}a===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(s.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+s.length+t.source.length;return{value:f,type:a,comment:s.comment,range:[i,m,m]}}},6225(e,t,r){var n=r(7028),i=r(7800),s=r(7090);t.resolveBlockSeq=function({composeNode:e,composeEmptyNode:t},r,a,o,l){let c=new(l?.nodeClass??n.YAMLSeq)(r.schema);r.atRoot&&(r.atRoot=!1),r.atKey&&(r.atKey=!1);let u=a.offset,d=null;for(let{start:n,value:l}of a.items){let f=i.resolveProps(n,{indicator:"seq-item-ind",next:l,offset:u,onError:o,parentIndent:a.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&&s.flowIndentCheck(a.indent,l,o),u=h.range[2],c.items.push(h)}return c.range=[a.offset,u,d??u],c}},4915(e,t){t.resolveEnd=function(e,t,r,n){let i="";if(e){let s=!1,a="";for(let o of e){let{source:e,type:l}=o;switch(l){case"space":s=!0;break;case"comment":{r&&!s&&n(o,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let t=e.substring(1)||" ";i?i+=a+t:i=t,a="";break}case"newline":i&&(a+=e),s=!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),s=r(73),a=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?s.YAMLMap:a.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 a=0;a<h.items.length;++a){let o=h.items[a],{start:m,key:v,sep:x,value:k}=o,S=l.resolveProps(m,{flow:y,indicator:"explicit-key-ind",next:v??x?.[0],offset:w,onError:p,parentIndent:h.indent,startOnNewline:!1});if(!S.found){if(!S.anchor&&!S.tag&&!x&&!k){0===a&&S.comma?p(S.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${y}`):a<h.items.length-1&&p(S.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${y}`),S.comment&&(b.comment?b.comment+="\n"+S.comment:b.comment=S.comment),w=S.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===a)S.comma&&p(S.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${y}`);else if(S.comma||p(S.start,"MISSING_CHAR",`Missing , between ${y} items`),S.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,S.comment=S.comment.substring(e.length+1)}}if(g||x||S.found){r.atKey=!0;let n=S.end,a=v?e(r,v,S,p):t(r,n,m,null,S,p);f(v)&&p(a.range,"BLOCK_IN_FLOW",d),r.atKey=!1;let c=l.resolveProps(x??[],{flow:y,indicator:"map-value-ind",next:k,offset:a.range[2],onError:p,parentIndent:h.indent,startOnNewline:!1});if(c.found){if(!g&&!S.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}}S.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 k&&("source"in k&&k.source?.[0]===":"?p(k,"MISSING_CHAR",`Missing space after : in ${y}`):p(c.start,"MISSING_CHAR",`Missing , or : between ${y} items`));let _=k?e(r,k,c,p):c.found?t(r,c.end,x,null,c,p):null;_?f(k)&&p(_.range,"BLOCK_IN_FLOW",d):c.comment&&(a.comment?a.comment+="\n"+c.comment:a.comment=c.comment);let $=new i.Pair(a,_);if(r.options.keepSourceTokens&&($.srcToken=o),g)u.mapIncludes(r,b.items,a)&&p(n,"DUPLICATE_KEY","Map keys must be unique"),b.items.push($);else{let e=new s.YAMLMap(r.schema);e.flow=!0,e.items.push($);let t=(_??a).range;e.range=[a.range[0],t[1],t[2]],b.items.push(e)}w=_?_.range[2]:c.end}else{let n=k?e(r,k,S,p):t(r,S.end,x,null,S,p);b.items.push(n),w=n.range[2],f(k)&&p(n.range,"BLOCK_IN_FLOW",d)}}let x=g?"}":"]",[k,...S]=h.end,_=w;if(k?.source===x)_=k.offset+k.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),k&&1!==k.source.length&&S.unshift(k)}if(S.length>0){let e=o.resolveEnd(S,_,r.options.strict,p);e.comment&&(b.comment?b.comment+="\n"+e.comment:b.comment=e.comment),b.range=[h.offset,_,e.offset]}else b.range=[h.offset,_,_];return b}},3165(e,t,r){var n=r(8376),i=r(4915);function s(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],s=" ",a=t.lastIndex;for(r.lastIndex=a;n=r.exec(e);)""===n[1]?"\n"===s?i+=s:s="\n":(i+=s+n[1],s=" "),a=r.lastIndex;let o=/[ \t]*(.*)/sy;return o.lastIndex=a,n=o.exec(e),i+s+(n?.[1]??"")}let a={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}`),s(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=s(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],s=a[i];if(s)r+=s;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 s="x"===i?2:"u"===i?4:8;r+=function(e,t,r,n){let i=e.substr(t,r),s=i.length===r&&/^[0-9a-fA-F]+$/.test(i)?parseInt(i,16):NaN;try{return String.fromCodePoint(s)}catch{let i=e.substr(t-2,r+2);return n(t-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${i}`),i}}(e,n+1,s,t),n+=s}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,s=e[n+1];for(;" "===s||" "===s;)s=e[++n+1];"\n"!==s&&("\r"!==s||"\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:s,parentIndent:a,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&&s(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&&s(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||s(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&&s(i,"MULTIPLE_ANCHORS","A node can have at most one anchor"),i.source.endsWith(":")&&s(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&&s(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)&&s(i,"BAD_PROP_ORDER",`Anchors and tags must be after the ${i.source} indicator`),w&&s(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&&s(i,"UNEXPECTED_TOKEN",`Unexpected , in ${t}`),v=i,c=!1,u=!1;break}default:s(i,"UNEXPECTED_TOKEN",`Unexpected ${i.type} token`),c=!1,u=!1}let k=e[e.length-1],S=k?k.offset+k.source.length:i;return p&&n&&"space"!==n.type&&"newline"!==n.type&&"comma"!==n.type&&("scalar"!==n.type||""!==n.source)&&s(n.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),m&&(c&&m.indent<=a||n?.type==="block-map"||n?.type==="block-seq")&&s(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:S,start:x??S}}},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 s="function"==typeof i?i:(e,t)=>e===t||n.isScalar(e)&&n.isScalar(t)&&e.value===t.value;return t.some(e=>s(e.key,r))}},9960(e,t,r){var n=r(2298),i=r(7580),s=r(6730),a=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(s.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,s.NODE_TYPE,{value:s.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:a}=i;r?._directives?(this.directives=r._directives.atDocument(),this.directives.yaml.explicit&&(a=this.directives.yaml.version)):this.directives=new h.Directives({version:a}),this.setSchema(a,r),this.contents=void 0===e?null:this.createNode(e,n,r)}clone(){let t=Object.create(e.prototype,{[s.NODE_TYPE]:{value:s.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=s.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:a,flow:o,keepUndefined:l,onTagObj:c,tag:d}=r??{},{onAnchor:h,setAnchors:p,sourceObjects:m}=u.createNodeAnchors(this,a||"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&&s.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 a.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 s.isCollection(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return i.isEmptyPath(e)?!t&&s.isScalar(this.contents)?this.contents.value:this.contents:s.isCollection(this.contents)?this.contents.getIn(e,t):void 0}has(e){return!!s.isCollection(this.contents)&&this.contents.has(e)}hasIn(e){return i.isEmptyPath(e)?void 0!==this.contents:!!s.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:s}={}){let a={anchors:new Map,doc:this,keep:!e,mapAsMap:!0===r,mapKeyWarned:!1,maxAliasCount:"number"==typeof n?n:100},l=o.toJS(this.contents,t??"",a);if("function"==typeof i)for(let{count:e,res:t}of a.anchors.values())i(t,e);return"function"==typeof s?d.applyReviver(s,{"":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 s(e){let t=new Set;return i.visit(e,{Value(e,r){r.anchor&&t.add(r.anchor)}}),t}function a(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=s,t.createNodeAnchors=function(e,t){let r=[],i=new Map,o=null;return{onAnchor:n=>{r.push(n),o??(o=s(e));let i=a(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=a},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],s=e(t,i,String(r),n);void 0===s?delete i[r]:s!==n&&(i[r]=s)}else if(i instanceof Map)for(let r of Array.from(i.keys())){let n=i.get(r),s=e(t,i,r,n);void 0===s?i.delete(r):s!==n&&i.set(r,s)}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 s=e(t,i,r,n);void 0===s?delete i[r]:s!==n&&(i[r]=s)}return t.call(r,n,i)}},7377(e,t,r){var n=r(2298),i=r(6730),s=r(8376);t.createNode=function(e,t,r){let a;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(a=d.get(e))return a.anchor??(a.anchor=l(e)),new n.Alias(a.anchor);a={anchor:null,node:null},d.set(e,a)}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 s.Scalar(e);return a&&(a.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 s.Scalar(e);return t?h.tag=t:f.default||(h.tag=f.tag),a&&(a.node=h),h}},7087(e,t,r){var n=r(6730),i=r(7995);let s={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},a=e=>e.replace(/[!,[\]{}]/g,e=>s[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+a(e.substring(r.length));return"!"===e[0]?e:`!<${e}>`}toString(e){let t,r=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],s=Object.entries(this.tags);if(e&&s.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 s)("!!"!==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 s=i-1,a=e.substring(t.lineStarts[n-1],t.lineStarts[n]).replace(/[\n\r]+$/,"");if(s>=60&&a.length>80){let e=Math.min(s-39,a.length-79);a="…"+a.substring(e),s-=e-1}if(a.length>80&&(a=a.substring(0,79)+"…"),n>1&&/^ *$/.test(a.substring(0,s))){let r=e.substring(t.lineStarts[n-2],t.lineStarts[n-1]);r.length>80&&(r=r.substring(0,79)+"…\n"),a=r+a}if(/[^ ]/.test(a)){let e=1,t=r.linePos[1];t?.line===n&&t.col>i&&(e=Math.max(1,Math.min(t.col-i,80-s)));let o=" ".repeat(s)+"^".repeat(e);r.message+=`:
7
+
8
+ ${a}
9
+ ${o}
10
+ `}}},2976(e,t,r){var n=r(2545),i=r(9960),s=r(8227),a=r(3409),o=r(2298),l=r(6730),c=r(7748),u=r(8376),d=r(73),f=r(7028);r(9810);var h=r(7894),p=r(3813),m=r(5849),g=r(1094),y=r(7995);n.Composer,i.Document,s.Schema,a.YAMLError,a.YAMLParseError,a.YAMLWarning,o.Alias,l.isAlias,l.isCollection,l.isDocument,l.isMap,l.isNode,l.isPair,l.isScalar,l.isSeq,c.Pair,u.Scalar,d.YAMLMap,f.YAMLSeq,h.Lexer,p.LineCounter,m.Parser,g.parse,g.parseAllDocuments,g.parseDocument,g.stringify,y.visit,y.visitAsync},2186(e,t,r){var n=r(932);t.debug=function(e,...t){"debug"===e&&console.log(...t)},t.warn=function(e,t){("debug"===e||"warn"===e)&&("function"==typeof n.emitWarning?n.emitWarning(t):console.warn(t))}},2298(e,t,r){var n=r(9531),i=r(7995),s=r(6730),a=r(5476),o=r(2234);class l extends a.NodeBase{constructor(e){super(s.ALIAS),this.source=e,Object.defineProperty(this,"tag",{set(){throw Error("Alias nodes cannot have tags")}})}resolve(e,t){let r,n;if(t?.maxAliasCount===0)throw ReferenceError("Alias resolution is disabled");for(let a of(t?.aliasResolveCache?r=t.aliasResolveCache:(r=[],i.visit(e,{Node:(e,t)=>{(s.isAlias(t)||s.hasAnchor(t))&&r.push(t)}}),t&&(t.aliasResolveCache=r)),r)){if(a===this)break;a.anchor===this.source&&(n=a)}return n}toJSON(e,t){if(!t)return{source:this.source};let{anchors:r,doc:n,maxAliasCount:i}=t,a=this.resolve(n,t);if(!a)throw ReferenceError(`Unresolved alias (the anchor must be set before the alias): ${this.source}`);let l=r.get(a);if(l||(o.toJS(a,null,t),l=r.get(a)),l?.res===void 0)throw ReferenceError("This should not happen: Alias anchor was not resolved?");if(i>=0&&(l.count+=1,0===l.aliasCount&&(l.aliasCount=function e(t,r,n){if(s.isAlias(r)){let e=r.resolve(t),i=n&&e&&n.get(e);return i?i.count*i.aliasCount:0}if(s.isCollection(r)){let i=0;for(let s of r.items){let r=e(t,s,n);r>i&&(i=r)}return i}return s.isPair(r)?Math.max(e(t,r.key,n),e(t,r.value,n)):1}(n,a,r)),l.count*l.aliasCount>i))throw ReferenceError("Excessive alias count indicates a resource exhaustion attack");return l.res}toString(e,t,r){let i=`*${this.source}`;if(e){if(n.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source))throw Error(`Unresolved alias (the anchor must be set before the alias): ${this.source}`);if(e.implicitKey)return`${i} `}return i}}t.Alias=l},7580(e,t,r){var n=r(7377),i=r(6730),s=r(5476);function a(e,t,r){let i=r;for(let e=t.length-1;e>=0;--e){let r=t[e];if("number"==typeof r&&Number.isInteger(r)&&r>=0){let e=[];e[r]=i,i=e}else i=new Map([[r,i]])}return n.createNode(i,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error("This should not happen, please report a bug.")},schema:e,sourceObjects:new Map})}let o=e=>null==e||"object"==typeof e&&!!e[Symbol.iterator]().next().done;class l extends s.NodeBase{constructor(e,t){super(e),Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(t.schema=e),t.items=t.items.map(t=>i.isNode(t)||i.isPair(t)?t.clone(e):t),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(o(e))this.add(t);else{let[r,...n]=e,s=this.get(r,!0);if(i.isCollection(s))s.addIn(n,t);else if(void 0===s&&this.schema)this.set(r,a(this.schema,n,t));else throw Error(`Expected YAML collection at ${r}. Remaining path: ${n}`)}}deleteIn(e){let[t,...r]=e;if(0===r.length)return this.delete(t);let n=this.get(t,!0);if(i.isCollection(n))return n.deleteIn(r);throw Error(`Expected YAML collection at ${t}. Remaining path: ${r}`)}getIn(e,t){let[r,...n]=e,s=this.get(r,!0);return 0===n.length?!t&&i.isScalar(s)?s.value:s:i.isCollection(s)?s.getIn(n,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!i.isPair(t))return!1;let r=t.value;return null==r||e&&i.isScalar(r)&&null==r.value&&!r.commentBefore&&!r.comment&&!r.tag})}hasIn(e){let[t,...r]=e;if(0===r.length)return this.has(t);let n=this.get(t,!0);return!!i.isCollection(n)&&n.hasIn(r)}setIn(e,t){let[r,...n]=e;if(0===n.length)this.set(r,t);else{let e=this.get(r,!0);if(i.isCollection(e))e.setIn(n,t);else if(void 0===e&&this.schema)this.set(r,a(this.schema,n,t));else throw Error(`Expected YAML collection at ${r}. Remaining path: ${n}`)}}}t.Collection=l,t.collectionFromPath=a,t.isEmptyPath=o},5476(e,t,r){var n=r(9768),i=r(6730),s=r(2234);t.NodeBase=class{constructor(e){Object.defineProperty(this,i.NODE_TYPE,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:t,maxAliasCount:r,onAnchor:a,reviver:o}={}){if(!i.isDocument(e))throw TypeError("A document argument is required");let l={anchors:new Map,doc:e,keep:!0,mapAsMap:!0===t,mapKeyWarned:!1,maxAliasCount:"number"==typeof r?r:100},c=s.toJS(this,"",l);if("function"==typeof a)for(let{count:e,res:t}of l.anchors.values())a(t,e);return"function"==typeof o?n.applyReviver(o,{"":c},"",c):c}}},7748(e,t,r){var n=r(7377),i=r(4711),s=r(3757),a=r(6730);class o{constructor(e,t=null){Object.defineProperty(this,a.NODE_TYPE,{value:a.PAIR}),this.key=e,this.value=t}clone(e){let{key:t,value:r}=this;return a.isNode(t)&&(t=t.clone(e)),a.isNode(r)&&(r=r.clone(e)),new o(t,r)}toJSON(e,t){let r=t?.mapAsMap?new Map:{};return s.addPairToJSMap(t,r,this)}toString(e,t,r){return e?.doc?i.stringifyPair(this,e,t,r):JSON.stringify(this)}}t.Pair=o,t.createPair=function(e,t,r){return new o(n.createNode(e,void 0,r),n.createNode(t,void 0,r))}},8376(e,t,r){var n=r(6730),i=r(5476),s=r(2234);class a extends i.NodeBase{constructor(e){super(n.SCALAR),this.value=e}toJSON(e,t){return t?.keep?this.value:s.toJS(this.value,e,t)}toString(){return String(this.value)}}a.BLOCK_FOLDED="BLOCK_FOLDED",a.BLOCK_LITERAL="BLOCK_LITERAL",a.PLAIN="PLAIN",a.QUOTE_DOUBLE="QUOTE_DOUBLE",a.QUOTE_SINGLE="QUOTE_SINGLE",t.Scalar=a,t.isScalarValue=e=>!e||"function"!=typeof e&&"object"!=typeof e},73(e,t,r){var n=r(8143),i=r(3757),s=r(7580),a=r(6730),o=r(7748),l=r(8376);function c(e,t){let r=a.isScalar(t)?t.value:t;for(let n of e)if(a.isPair(n)&&(n.key===t||n.key===r||a.isScalar(n.key)&&n.key.value===r))return n}class u extends s.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(a.MAP,e),this.items=[]}static from(e,t,r){let{keepUndefined:n,replacer:i}=r,s=new this(e),a=(e,a)=>{if("function"==typeof i)a=i.call(t,e,a);else if(Array.isArray(i)&&!i.includes(e))return;(void 0!==a||n)&&s.items.push(o.createPair(e,a,r))};if(t instanceof Map)for(let[e,r]of t)a(e,r);else if(t&&"object"==typeof t)for(let e of Object.keys(t))a(e,t[e]);return"function"==typeof e.sortMapEntries&&s.items.sort(e.sortMapEntries),s}add(e,t){let r;r=a.isPair(e)?e:e&&"object"==typeof e&&"key"in e?new o.Pair(e.key,e.value):new o.Pair(e,e?.value);let n=c(this.items,r.key),i=this.schema?.sortMapEntries;if(n){if(!t)throw Error(`Key ${r.key} already set`);a.isScalar(n.value)&&l.isScalarValue(r.value)?n.value.value=r.value:n.value=r.value}else if(i){let e=this.items.findIndex(e=>0>i(r,e));-1===e?this.items.push(r):this.items.splice(e,0,r)}else this.items.push(r)}delete(e){let t=c(this.items,e);return!!t&&this.items.splice(this.items.indexOf(t),1).length>0}get(e,t){let r=c(this.items,e),n=r?.value;return(!t&&a.isScalar(n)?n.value:n)??void 0}has(e){return!!c(this.items,e)}set(e,t){this.add(new o.Pair(e,t),!0)}toJSON(e,t,r){let n=r?new r:t?.mapAsMap?new Map:{};for(let e of(t?.onCreate&&t.onCreate(n),this.items))i.addPairToJSMap(t,n,e);return n}toString(e,t,r){if(!e)return JSON.stringify(this);for(let e of this.items)if(!a.isPair(e))throw Error(`Map items must all be pairs; found ${JSON.stringify(e)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),n.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:r,onComment:t})}}t.YAMLMap=u,t.findPair=c},7028(e,t,r){var n=r(7377),i=r(8143),s=r(7580),a=r(6730),o=r(8376),l=r(2234);class c extends s.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(a.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=u(e);return"number"==typeof t&&this.items.splice(t,1).length>0}get(e,t){let r=u(e);if("number"!=typeof r)return;let n=this.items[r];return!t&&a.isScalar(n)?n.value:n}has(e){let t=u(e);return"number"==typeof t&&t<this.items.length}set(e,t){let r=u(e);if("number"!=typeof r)throw Error(`Expected a valid index, not ${e}.`);let n=this.items[r];a.isScalar(n)&&o.isScalarValue(t)?n.value=t:this.items[r]=t}toJSON(e,t){let r=[];t?.onCreate&&t.onCreate(r);let n=0;for(let e of this.items)r.push(l.toJS(e,String(n++),t));return r}toString(e,t,r){return e?i.stringifyCollection(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:r,onComment:t}):JSON.stringify(this)}static from(e,t,r){let{replacer:i}=r,s=new this(e);if(t&&Symbol.iterator in Object(t)){let e=0;for(let a of t){if("function"==typeof i){let r=t instanceof Set?a:String(e++);a=i.call(t,r,a)}s.items.push(n.createNode(a,void 0,r))}}return s}}function u(e){let t=a.isScalar(e)?e.value:e;return t&&"string"==typeof t&&(t=Number(t)),"number"==typeof t&&Number.isInteger(t)&&t>=0?t:null}t.YAMLSeq=c},3757(e,t,r){var n=r(2186),i=r(8327),s=r(6203),a=r(6730),o=r(2234);t.addPairToJSMap=function(e,t,{key:r,value:l}){if(a.isNode(r)&&r.addToJSMap)r.addToJSMap(e,t,l);else if(i.isMergeKey(e,r))i.addMergeToJSMap(e,t,l);else{let i=o.toJS(r,"",e);if(t instanceof Map)t.set(i,o.toJS(l,i,e));else if(t instanceof Set)t.add(i);else{let c=function(e,t,r){if(null===t)return"";if("object"!=typeof t)return String(t);if(a.isNode(e)&&r?.doc){let t=s.createStringifyContext(r.doc,{});for(let e of(t.anchors=new Set,r.anchors.keys()))t.anchors.add(e.anchor);t.inFlow=!0,t.inStringifyKey=!0;let i=e.toString(t);if(!r.mapKeyWarned){let e=JSON.stringify(i);e.length>40&&(e=e.substring(0,36)+'..."'),n.warn(r.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${e}. Set mapAsMap: true to use object keys.`),r.mapKeyWarned=!0}return i}return JSON.stringify(t)}(r,i,e),u=o.toJS(l,c,e);c in t?Object.defineProperty(t,c,{value:u,writable:!0,enumerable:!0,configurable:!0}):t[c]=u}}return t}},6730(e,t){let r=Symbol.for("yaml.alias"),n=Symbol.for("yaml.document"),i=Symbol.for("yaml.map"),s=Symbol.for("yaml.pair"),a=Symbol.for("yaml.scalar"),o=Symbol.for("yaml.seq"),l=Symbol.for("yaml.node.type"),c=e=>!!e&&"object"==typeof e&&e[l]===a;function u(e){if(e&&"object"==typeof e)switch(e[l]){case i:case o:return!0}return!1}t.ALIAS=r,t.DOC=n,t.MAP=i,t.NODE_TYPE=l,t.PAIR=s,t.SCALAR=a,t.SEQ=o,t.hasAnchor=e=>(c(e)||u(e))&&!!e.anchor,t.isAlias=e=>!!e&&"object"==typeof e&&e[l]===r,t.isCollection=u,t.isDocument=e=>!!e&&"object"==typeof e&&e[l]===n,t.isMap=e=>!!e&&"object"==typeof e&&e[l]===i,t.isNode=function(e){if(e&&"object"==typeof e)switch(e[l]){case r:case i:case a:case o:return!0}return!1},t.isPair=e=>!!e&&"object"==typeof e&&e[l]===s,t.isScalar=c,t.isSeq=e=>!!e&&"object"==typeof e&&e[l]===o},2234(e,t,r){var n=r(6730);t.toJS=function e(t,r,i){if(Array.isArray(t))return t.map((t,r)=>e(t,String(r),i));if(t&&"function"==typeof t.toJSON){if(!i||!n.hasAnchor(t))return t.toJSON(r,i);let e={aliasCount:0,count:1,res:void 0};i.anchors.set(t,e),i.onCreate=t=>{e.res=t,delete i.onCreate};let s=t.toJSON(r,i);return i.onCreate&&i.onCreate(s),s}return"bigint"!=typeof t||i?.keep?t:Number(t)}},8215(e,t,r){var n=r(2992),i=r(3165),s=r(3409),a=r(4286);function o(e,t){if(t)for(let r of t)switch(r.type){case"space":case"comment":e.push(r);break;case"newline":return e.push(r),!0}return!1}function l(e,t,r){switch(e.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":e.type=r,e.source=t;break;case"block-scalar":{let n=e.props.slice(1),i=t.length;for(let t of("block-scalar-header"===e.props[0].type&&(i-=e.props[0].source.length),n))t.offset+=i;delete e.props,Object.assign(e,{type:r,source:t,end:n});break}case"block-map":case"block-seq":{let n={type:"newline",offset:e.offset+t.length,indent:e.indent,source:"\n"};delete e.items,Object.assign(e,{type:r,source:t,end:[n]});break}default:{let n="indent"in e?e.indent:-1,i="end"in e&&Array.isArray(e.end)?e.end.filter(e=>"space"===e.type||"comment"===e.type||"newline"===e.type):[];for(let t of Object.keys(e))"type"!==t&&"offset"!==t&&delete e[t];Object.assign(e,{type:r,indent:n,source:t,end:i})}}}t.createScalarToken=function(e,t){let{implicitKey:r=!1,indent:n,inFlow:i=!1,offset:s=-1,type:l="PLAIN"}=t,c=a.stringifyString({type:l,value:e},{implicitKey:r,indent:n>0?" ".repeat(n):"",inFlow:i,options:{blockQuote:!0,lineWidth:-1}}),u=t.end??[{type:"newline",offset:-1,indent:n,source:"\n"}];switch(c[0]){case"|":case">":{let e=c.indexOf("\n"),t=c.substring(0,e),r=c.substring(e+1)+"\n",i=[{type:"block-scalar-header",offset:s,indent:n,source:t}];return o(i,u)||i.push({type:"newline",offset:-1,indent:n,source:"\n"}),{type:"block-scalar",offset:s,indent:n,props:i,source:r}}case'"':return{type:"double-quoted-scalar",offset:s,indent:n,source:c,end:u};case"'":return{type:"single-quoted-scalar",offset:s,indent:n,source:c,end:u};default:return{type:"scalar",offset:s,indent:n,source:c,end:u}}},t.resolveAsScalar=function(e,t=!0,r){if(e){let a=(e,t,n)=>{let i="number"==typeof e?e:Array.isArray(e)?e[0]:e.offset;if(r)r(i,t,n);else throw new s.YAMLParseError([i,i+1],t,n)};switch(e.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return i.resolveFlowScalar(e,t,a);case"block-scalar":return n.resolveBlockScalar({options:{strict:t}},e,a)}}return null},t.setScalarValue=function(e,t,r={}){let{afterKey:n=!1,implicitKey:i=!1,inFlow:s=!1,type:c}=r,u="indent"in e?e.indent:null;if(n&&"number"==typeof u&&(u+=2),!c)switch(e.type){case"single-quoted-scalar":c="QUOTE_SINGLE";break;case"double-quoted-scalar":c="QUOTE_DOUBLE";break;case"block-scalar":{let t=e.props[0];if("block-scalar-header"!==t.type)throw Error("Invalid block scalar header");c=">"===t.source[0]?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:c="PLAIN"}let d=a.stringifyString({type:c,value:t},{implicitKey:i||null===u,indent:null!==u&&u>0?" ".repeat(u):"",inFlow:s,options:{blockQuote:!0,lineWidth:-1}});switch(d[0]){case"|":case">":!function(e,t){let r=t.indexOf("\n"),n=t.substring(0,r),i=t.substring(r+1)+"\n";if("block-scalar"===e.type){let t=e.props[0];if("block-scalar-header"!==t.type)throw Error("Invalid block scalar header");t.source=n,e.source=i}else{let{offset:t}=e,r="indent"in e?e.indent:-1,s=[{type:"block-scalar-header",offset:t,indent:r,source:n}];for(let t of(o(s,"end"in e?e.end:void 0)||s.push({type:"newline",offset:-1,indent:r,source:"\n"}),Object.keys(e)))"type"!==t&&"offset"!==t&&delete e[t];Object.assign(e,{type:"block-scalar",indent:r,props:s,source:i})}}(e,d);break;case'"':l(e,d,"double-quoted-scalar");break;case"'":l(e,d,"single-quoted-scalar");break;default:l(e,d,"scalar")}}},2142(e,t){function r(e){switch(e.type){case"block-scalar":{let t="";for(let n of e.props)t+=r(n);return t+e.source}case"block-map":case"block-seq":{let t="";for(let r of e.items)t+=n(r);return t}case"flow-collection":{let t=e.start.source;for(let r of e.items)t+=n(r);for(let r of e.end)t+=r.source;return t}case"document":{let t=n(e);if(e.end)for(let r of e.end)t+=r.source;return t}default:{let t=e.source;if("end"in e&&e.end)for(let r of e.end)t+=r.source;return t}}}function n({start:e,key:t,sep:i,value:s}){let a="";for(let t of e)a+=t.source;if(t&&(a+=r(t)),i)for(let e of i)a+=e.source;return s&&(a+=r(s)),a}t.stringify=e=>"type"in e?r(e):n(e)},1844(e,t){let r=Symbol("break visit"),n=Symbol("skip children"),i=Symbol("remove item");function s(e,t){"type"in e&&"document"===e.type&&(e={start:e.start,value:e.value}),function e(t,n,s){let a=s(n,t);if("symbol"==typeof a)return a;for(let o of["key","value"]){let l=n[o];if(l&&"items"in l){for(let n=0;n<l.items.length;++n){let a=e(Object.freeze(t.concat([[o,n]])),l.items[n],s);if("number"==typeof a)n=a-1;else{if(a===r)return r;a===i&&(l.items.splice(n,1),n-=1)}}"function"==typeof a&&"key"===o&&(a=a(n,t))}}return"function"==typeof a?a(n,t):a}(Object.freeze([]),e,t)}s.BREAK=r,s.SKIP=n,s.REMOVE=i,s.itemAtPath=(e,t)=>{let r=e;for(let[e,n]of t){let t=r?.[e];if(!t||!("items"in t))return;r=t.items[n]}return r},s.parentCollection=(e,t)=>{let r=s.itemAtPath(e,t.slice(0,-1)),n=t[t.length-1][0],i=r?.[n];if(i&&"items"in i)return i;throw Error("Parent collection not found")},t.visit=s},9810(e,t,r){var n=r(8215),i=r(2142),s=r(1844);t.createScalarToken=n.createScalarToken,t.resolveAsScalar=n.resolveAsScalar,t.setScalarValue=n.setScalarValue,t.stringify=i.stringify,t.visit=s.visit,t.BOM="\uFEFF",t.DOCUMENT="\x02",t.FLOW_END="\x18",t.SCALAR="\x1f",t.isCollection=e=>!!e&&"items"in e,t.isScalar=e=>!!e&&("scalar"===e.type||"single-quoted-scalar"===e.type||"double-quoted-scalar"===e.type||"block-scalar"===e.type),t.prettyToken=function(e){switch(e){case"\uFEFF":return"<BOM>";case"\x02":return"<DOC>";case"\x18":return"<FLOW_END>";case"\x1f":return"<SCALAR>";default:return JSON.stringify(e)}},t.tokenType=function(e){switch(e){case"\uFEFF":return"byte-order-mark";case"\x02":return"doc-mode";case"\x18":return"flow-error-end";case"\x1f":return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case"\n":case"\r\n":return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(e[0]){case" ":case" ":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}},7894(e,t,r){var n=r(9810);function i(e){switch(e){case void 0:case" ":case"\n":case"\r":case" ":return!0;default:return!1}}let s=new Set("0123456789ABCDEFabcdef"),a=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),o=new Set(",[]{}"),l=new Set(" ,[]{}\n\r "),c=e=>!e||l.has(e);t.Lexer=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,t=!1){if(e){if("string"!=typeof e)throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!t;let r=this.next??"stream";for(;r&&(t||this.hasChars(1));)r=yield*this.parseNext(r)}atLineEnd(){let e=this.pos,t=this.buffer[e];for(;" "===t||" "===t;)t=this.buffer[++e];return!t||"#"===t||"\n"===t||"\r"===t&&"\n"===this.buffer[e+1]}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let t=this.buffer[e];if(this.indentNext>0){let r=0;for(;" "===t;)t=this.buffer[++r+e];if("\r"===t){let t=this.buffer[r+e+1];if("\n"===t||!t&&!this.atEnd)return e+r+1}return"\n"!==t&&!(r>=this.indentNext)&&(t||this.atEnd)?-1:e+r}if("-"===t||"."===t){let t=this.buffer.substr(e,3);if(("---"===t||"..."===t)&&i(this.buffer[e+3]))return -1}return e}getLine(){let e=this.lineEndPos;return(("number"!=typeof e||-1!==e&&e<this.pos)&&(e=this.buffer.indexOf("\n",this.pos),this.lineEndPos=e),-1===e)?this.atEnd?this.buffer.substring(this.pos):null:("\r"===this.buffer[e-1]&&(e-=1),this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(null===e)return this.setNext("stream");if(e[0]===n.BOM&&(yield*this.pushCount(1),e=e.substring(1)),"%"===e[0]){let t=e.length,r=e.indexOf("#");for(;-1!==r;){let n=e[r-1];if(" "===n||" "===n){t=r-1;break}r=e.indexOf("#",r+1)}for(;;){let r=e[t-1];if(" "===r||" "===r)t-=1;else break}let n=(yield*this.pushCount(t))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-n),this.pushNewline(),"stream"}if(this.atLineEnd()){let t=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-t),yield*this.pushNewline(),"stream"}return yield n.DOCUMENT,yield*this.parseLineStart()}*parseLineStart(){let e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext("line-start");if("-"===e||"."===e){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");let e=this.peek(3);if(("---"===e||"..."===e)&&i(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,"---"===e?"doc":"stream"}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!i(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[e,t]=this.peek(2);if(!t&&!this.atEnd)return this.setNext("block-start");if(("-"===e||"?"===e||":"===e)&&i(t)){let e=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=e,"block-start"}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);let e=this.getLine();if(null===e)return this.setNext("doc");let t=yield*this.pushIndicators();switch(e[t]){case"#":yield*this.pushCount(e.length-t);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,"flow";case"}":case"]":return yield*this.pushCount(1),"doc";case"*":return yield*this.pushUntil(c),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return t+=yield*this.parseBlockScalarHeader(),t+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-t),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,t,r=-1;do(e=yield*this.pushNewline())>0?(t=yield*this.pushSpaces(!1),this.indentValue=r=t):t=0,t+=yield*this.pushSpaces(!0);while(e+t>0)let s=this.getLine();if(null===s)return this.setNext("flow");if((-1!==r&&r<this.indentNext&&"#"!==s[0]||0===r&&(s.startsWith("---")||s.startsWith("..."))&&i(s[3]))&&(r!==this.indentNext-1||1!==this.flowLevel||"]"!==s[0]&&"}"!==s[0]))return this.flowLevel=0,yield n.FLOW_END,yield*this.parseLineStart();let a=0;for(;","===s[a];)a+=yield*this.pushCount(1),a+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(s[a+=yield*this.pushIndicators()]){case void 0:return"flow";case"#":return yield*this.pushCount(s.length-a),"flow";case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,"flow";case"}":case"]":return yield*this.pushCount(1),this.flowKey=!0,this.flowLevel-=1,this.flowLevel?"flow":"doc";case"*":return yield*this.pushUntil(c),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let e=this.charAt(1);if(this.flowKey||i(e)||","===e)return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let e=this.charAt(0),t=this.buffer.indexOf(e,this.pos+1);if("'"===e)for(;-1!==t&&"'"===this.buffer[t+1];)t=this.buffer.indexOf("'",t+2);else for(;-1!==t;){let e=0;for(;"\\"===this.buffer[t-1-e];)e+=1;if(e%2==0)break;t=this.buffer.indexOf('"',t+1)}let r=this.buffer.substring(0,t),n=r.indexOf("\n",this.pos);if(-1!==n){for(;-1!==n;){let e=this.continueScalar(n+1);if(-1===e)break;n=r.indexOf("\n",e)}-1!==n&&(t=n-("\r"===r[n-1]?2:1))}if(-1===t){if(!this.atEnd)return this.setNext("quoted-scalar");t=this.buffer.length}return yield*this.pushToIndex(t+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let t=this.buffer[++e];if("+"===t)this.blockScalarKeep=!0;else if(t>"0"&&t<="9")this.blockScalarIndent=Number(t)-1;else if("-"!==t)break}return yield*this.pushUntil(e=>i(e)||"#"===e)}*parseBlockScalar(){let e,t=this.pos-1,r=0;e:for(let n=this.pos;e=this.buffer[n];++n)switch(e){case" ":r+=1;break;case"\n":t=n,r=0;break;case"\r":{let e=this.buffer[n+1];if(!e&&!this.atEnd)return this.setNext("block-scalar");if("\n"===e)break}default:break e}if(!e&&!this.atEnd)return this.setNext("block-scalar");if(r>=this.indentNext){-1===this.blockScalarIndent?this.indentNext=r:this.indentNext=this.blockScalarIndent+(0===this.indentNext?1:this.indentNext);do{let e=this.continueScalar(t+1);if(-1===e)break;t=this.buffer.indexOf("\n",e)}while(-1!==t)if(-1===t){if(!this.atEnd)return this.setNext("block-scalar");t=this.buffer.length}}let i=t+1;for(e=this.buffer[i];" "===e;)e=this.buffer[++i];if(" "===e){for(;" "===e||" "===e||"\r"===e||"\n"===e;)e=this.buffer[++i];t=i-1}else if(!this.blockScalarKeep)for(;;){let e=t-1,n=this.buffer[e];"\r"===n&&(n=this.buffer[--e]);let i=e;for(;" "===n;)n=this.buffer[--e];if("\n"===n&&e>=this.pos&&e+1+r>i)t=e;else break}return yield n.SCALAR,yield*this.pushToIndex(t+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e,t=this.flowLevel>0,r=this.pos-1,s=this.pos-1;for(;e=this.buffer[++s];)if(":"===e){let e=this.buffer[s+1];if(i(e)||t&&o.has(e))break;r=s}else if(i(e)){let n=this.buffer[s+1];if("\r"===e&&("\n"===n?(s+=1,e="\n",n=this.buffer[s+1]):r=s),"#"===n||t&&o.has(n))break;if("\n"===e){let e=this.continueScalar(s+1);if(-1===e)break;s=Math.max(s,e-2)}}else{if(t&&o.has(e))break;r=s}return e||this.atEnd?(yield n.SCALAR,yield*this.pushToIndex(r+1,!0),t?"flow":"doc"):this.setNext("plain-scalar")}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,t){let r=this.buffer.slice(this.pos,e);return r?(yield r,this.pos+=r.length,r.length):(t&&(yield""),0)}*pushIndicators(){let e=0;for(;;){switch(this.charAt(0)){case"!":e+=yield*this.pushTag(),e+=yield*this.pushSpaces(!0);continue;case"&":e+=yield*this.pushUntil(c),e+=yield*this.pushSpaces(!0);continue;case"-":case"?":case":":{let t=this.flowLevel>0,r=this.charAt(1);if(i(r)||t&&o.has(r)){t?this.flowKey&&(this.flowKey=!1):this.indentNext=this.indentValue+1,e+=yield*this.pushCount(1),e+=yield*this.pushSpaces(!0);continue}}}break}return e}*pushTag(){if("<"===this.charAt(1)){let e=this.pos+2,t=this.buffer[e];for(;!i(t)&&">"!==t;)t=this.buffer[++e];return yield*this.pushToIndex(">"===t?e+1:e,!1)}{let e=this.pos+1,t=this.buffer[e];for(;t;)if(a.has(t))t=this.buffer[++e];else if("%"===t&&s.has(this.buffer[e+1])&&s.has(this.buffer[e+2]))t=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return"\n"===e?yield*this.pushCount(1):"\r"===e&&"\n"===this.charAt(1)?yield*this.pushCount(2):0}*pushSpaces(e){let t,r=this.pos-1;do t=this.buffer[++r];while(" "===t||e&&" "===t)let n=r-this.pos;return n>0&&(yield this.buffer.substr(this.pos,n),this.pos=r),n}*pushUntil(e){let t=this.pos,r=this.buffer[t];for(;!e(r);)r=this.buffer[++t];return yield*this.pushToIndex(t,!1)}}},3813(e,t){t.LineCounter=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let t=0,r=this.lineStarts.length;for(;t<r;){let n=t+r>>1;this.lineStarts[n]<e?t=n+1:r=n}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(0===t)return{line:0,col:e};let n=this.lineStarts[t-1];return{line:t,col:e-n+1}}}}},5849(e,t,r){var n=r(932),i=r(9810),s=r(7894);function a(e,t){for(let r=0;r<e.length;++r)if(e[r].type===t)return!0;return!1}function o(e){for(let t=0;t<e.length;++t)switch(e[t].type){case"space":case"comment":case"newline":break;default:return t}return -1}function l(e){switch(e?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function c(e){switch(e.type){case"document":return e.start;case"block-map":{let t=e.items[e.items.length-1];return t.sep??t.start}case"block-seq":return e.items[e.items.length-1].start;default:return[]}}function u(e){if(0===e.length)return[];let t=e.length;e:for(;--t>=0;)switch(e[t].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;e[++t]?.type==="space";);return e.splice(t,e.length)}function d(e,t){if(t.length<1e5)Array.prototype.push.apply(e,t);else for(let r=0;r<t.length;++r)e.push(t[r])}function f(e){if("flow-seq-start"===e.start.type)for(let t of e.items)!t.sep||t.value||a(t.start,"explicit-key-ind")||a(t.sep,"map-value-ind")||(t.key&&(t.value=t.key),delete t.key,l(t.value)?t.value.end?d(t.value.end,t.sep):t.value.end=t.sep:d(t.start,t.sep),delete t.sep)}t.Parser=class{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new s.Lexer,this.onNewLine=e}*parse(e,t=!1){for(let r of(this.onNewLine&&0===this.offset&&this.onNewLine(0),this.lexer.lex(e,t)))yield*this.next(r);t||(yield*this.end())}*next(e){if(this.source=e,n.env.LOG_TOKENS&&console.log("|",i.prettyToken(e)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let t=i.tokenType(e);if(t)if("scalar"===t)this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=t,yield*this.step(),t){case"newline":this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case"space":this.atNewLine&&" "===e[0]&&(this.indent+=e.length);break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":this.atNewLine&&(this.indent+=e.length);break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=e.length}else{let t=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:t,source:e}),this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if("doc-end"===this.type&&e?.type!=="doc-end"){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!e)return yield*this.stream();switch(e.type){case"document":return yield*this.document(e);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(e);case"block-scalar":return yield*this.blockScalar(e);case"block-map":return yield*this.blockMap(e);case"block-seq":return yield*this.blockSequence(e);case"flow-collection":return yield*this.flowCollection(e);case"doc-end":return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){let t=e??this.stack.pop();if(t)if(0===this.stack.length)yield t;else{let e=this.peek(1);switch("block-scalar"===t.type?t.indent="indent"in e?e.indent:0:"flow-collection"===t.type&&"document"===e.type&&(t.indent=0),"flow-collection"===t.type&&f(t),e.type){case"document":e.value=t;break;case"block-scalar":e.props.push(t);break;case"block-map":{let r=e.items[e.items.length-1];if(r.value){e.items.push({start:[],key:t,sep:[]}),this.onKeyLine=!0;return}if(r.sep)r.value=t;else{Object.assign(r,{key:t,sep:[]}),this.onKeyLine=!r.explicitKey;return}break}case"block-seq":{let r=e.items[e.items.length-1];r.value?e.items.push({start:[],value:t}):r.value=t;break}case"flow-collection":{let r=e.items[e.items.length-1];!r||r.value?e.items.push({start:[],key:t,sep:[]}):r.sep?r.value=t:Object.assign(r,{key:t,sep:[]});return}default:yield*this.pop(),yield*this.pop(t)}if(("document"===e.type||"block-map"===e.type||"block-seq"===e.type)&&("block-map"===t.type||"block-seq"===t.type)){let r=t.items[t.items.length-1];r&&!r.sep&&!r.value&&r.start.length>0&&-1===o(r.start)&&(0===t.indent||r.start.every(e=>"comment"!==e.type||e.indent<t.indent))&&("document"===e.type?e.end=r.start:e.items.push({start:r.start}),t.items.splice(-1,1))}}else yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"}}*stream(){switch(this.type){case"directive-line":yield{type:"directive",offset:this.offset,source:this.source};return;case"byte-order-mark":case"space":case"comment":case"newline":yield this.sourceToken;return;case"doc-mode":case"doc-start":{let e={type:"document",offset:this.offset,start:[]};"doc-start"===this.type&&e.start.push(this.sourceToken),this.stack.push(e);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case"doc-start":-1!==o(e.start)?(yield*this.pop(),yield*this.step()):e.start.push(this.sourceToken);return;case"anchor":case"tag":case"space":case"comment":case"newline":e.start.push(this.sourceToken);return}let t=this.startBlockValue(e);t?this.stack.push(t):yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if("map-value-ind"===this.type){let t,r=u(c(this.peek(2)));e.end?((t=e.end).push(this.sourceToken),delete e.end):t=[this.sourceToken];let n={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:r,key:e,sep:t}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=n}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case"space":case"comment":case"newline":e.props.push(this.sourceToken);return;case"scalar":if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let e=this.source.indexOf("\n")+1;for(;0!==e;)this.onNewLine(this.offset+e),e=this.source.indexOf("\n",e)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,t.value){let r="end"in t.value?t.value.end:void 0,n=Array.isArray(r)?r[r.length-1]:void 0;n?.type==="comment"?r?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){let r=e.items[e.items.length-2],n=r?.value?.end;if(Array.isArray(n)){d(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let r=!this.onKeyLine&&this.indent===e.indent,n=r&&(t.sep||t.explicitKey)&&"seq-item-ind"!==this.type,i=[];if(n&&t.sep&&!t.value){let r=[];for(let n=0;n<t.sep.length;++n){let i=t.sep[n];switch(i.type){case"newline":r.push(n);break;case"space":break;case"comment":i.indent>e.indent&&(r.length=0);break;default:r.length=0}}r.length>=2&&(i=t.sep.splice(r[1]))}switch(this.type){case"anchor":case"tag":n||t.value?(i.push(this.sourceToken),e.items.push({start:i}),this.onKeyLine=!0):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"explicit-key-ind":t.sep||t.explicitKey?n||t.value?(i.push(this.sourceToken),e.items.push({start:i,explicitKey:!0})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}):(t.start.push(this.sourceToken),t.explicitKey=!0),this.onKeyLine=!0;return;case"map-value-ind":if(t.explicitKey)if(t.sep)if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(a(t.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]});else if(l(t.key)&&!a(t.sep,"newline")){let e=u(t.start),r=t.key,n=t.sep;n.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:e,key:r,sep:n}]})}else i.length>0?t.sep=t.sep.concat(i,this.sourceToken):t.sep.push(this.sourceToken);else if(a(t.start,"newline"))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let e=u(t.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:e,key:null,sep:[this.sourceToken]}]})}else t.sep?t.value||n?e.items.push({start:i,key:null,sep:[this.sourceToken]}):a(t.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let r=this.flowScalar(this.type);n||t.value?(e.items.push({start:i,key:r,sep:[]}),this.onKeyLine=!0):t.sep?this.stack.push(r):(Object.assign(t,{key:r,sep:[]}),this.onKeyLine=!0);return}default:{let n=this.startBlockValue(e);if(n){if("block-seq"===n.type){if(!t.explicitKey&&t.sep&&!a(t.sep,"newline"))return void(yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source}))}else r&&e.items.push({start:i});this.stack.push(n);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let t=e.items[e.items.length-1];switch(this.type){case"newline":if(t.value){let r="end"in t.value?t.value.end:void 0,n=Array.isArray(r)?r[r.length-1]:void 0;n?.type==="comment"?r?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){let r=e.items[e.items.length-2],n=r?.value?.end;if(Array.isArray(n)){d(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return;case"anchor":case"tag":if(t.value||this.indent<=e.indent)break;t.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==e.indent)break;t.value||a(t.start,"seq-item-ind")?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return}if(this.indent>e.indent){let t=this.startBlockValue(e);if(t)return void this.stack.push(t)}yield*this.pop(),yield*this.step()}*flowCollection(e){let t=e.items[e.items.length-1];if("flow-error-end"===this.type){let e;do yield*this.pop(),e=this.peek(1);while(e?.type==="flow-collection")}else if(0===e.end.length){switch(this.type){case"comma":case"explicit-key-ind":!t||t.sep?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return;case"map-value-ind":!t||t.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!t||t.value?e.items.push({start:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let r=this.flowScalar(this.type);!t||t.value?e.items.push({start:[],key:r,sep:[]}):t.sep?this.stack.push(r):Object.assign(t,{key:r,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}let r=this.startBlockValue(e);r?this.stack.push(r):(yield*this.pop(),yield*this.step())}else{let t=this.peek(2);if("block-map"!==t.type||("map-value-ind"!==this.type||t.indent!==e.indent)&&("newline"!==this.type||t.items[t.items.length-1].sep))if("map-value-ind"===this.type&&"flow-collection"!==t.type){let r=u(c(t));f(e);let n=e.end.splice(1,e.end.length);n.push(this.sourceToken);let i={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:r,key:e,sep:n}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=i}else yield*this.lineEnd(e);else yield*this.pop(),yield*this.step()}}flowScalar(e){if(this.onNewLine){let e=this.source.indexOf("\n")+1;for(;0!==e;)this.onNewLine(this.offset+e),e=this.source.indexOf("\n",e)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let t=u(c(e));return t.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:t,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let t=u(c(e));return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:t,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return"comment"===this.type&&!(this.indent<=t)&&e.every(e=>"newline"===e.type||"space"===e.type)}*documentEnd(e){"doc-mode"!==this.type&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],"newline"===this.type&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],"newline"===this.type&&(yield*this.pop())}}}},1094(e,t,r){var n=r(2545),i=r(9960),s=r(3409),a=r(2186),o=r(6730),l=r(3813),c=r(5849);function u(e){let t=!1!==e.prettyErrors;return{lineCounter:e.lineCounter||t&&new l.LineCounter||null,prettyErrors:t}}function d(e,t={}){let{lineCounter:r,prettyErrors:i}=u(t),a=new c.Parser(r?.addNewLine),o=new n.Composer(t),l=null;for(let t of o.compose(a.parse(e),!0,e.length))if(l){if("silent"!==l.options.logLevel){l.errors.push(new s.YAMLParseError(t.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}}else l=t;return i&&r&&(l.errors.forEach(s.prettifyError(e,r)),l.warnings.forEach(s.prettifyError(e,r))),l}t.parse=function(e,t,r){let n;"function"==typeof t?n=t:void 0===r&&t&&"object"==typeof t&&(r=t);let i=d(e,r);if(!i)return null;if(i.warnings.forEach(e=>a.warn(i.options.logLevel,e)),i.errors.length>0)if("silent"!==i.options.logLevel)throw i.errors[0];else i.errors=[];return i.toJS(Object.assign({reviver:n},r))},t.parseAllDocuments=function(e,t={}){let{lineCounter:r,prettyErrors:i}=u(t),a=new c.Parser(r?.addNewLine),o=new n.Composer(t),l=Array.from(o.compose(a.parse(e)));if(i&&r)for(let t of l)t.errors.forEach(s.prettifyError(e,r)),t.warnings.forEach(s.prettifyError(e,r));return l.length>0?l:Object.assign([],{empty:!0},o.streamInfo())},t.parseDocument=d,t.stringify=function(e,t,r){let n=null;if("function"==typeof t||Array.isArray(t)?n=t:void 0===r&&t&&(r=t),"string"==typeof r&&(r=r.length),"number"==typeof r){let e=Math.round(r);r=e<1?void 0:e>8?{indent:8}:{indent:e}}if(void 0===e){let{keepUndefined:e}=r??t??{};if(!e)return}return o.isDocument(e)&&!n?e.toString(r):new i.Document(e,n,r).toString(r)}},8227(e,t,r){var n=r(6730),i=r(9988),s=r(505),a=r(5613),o=r(7545);let l=(e,t)=>e.key<t.key?-1:+(e.key>t.key);t.Schema=class e{constructor({compat:e,customTags:t,merge:r,resolveKnownTags:c,schema:u,sortMapEntries:d,toStringDefaults:f}){this.compat=Array.isArray(e)?o.getTags(e,"compat"):e?o.getTags(null,e):null,this.name="string"==typeof u&&u||"core",this.knownTags=c?o.coreKnownTags:{},this.tags=o.getTags(t,this.name,r),this.toStringOptions=f??null,Object.defineProperty(this,n.MAP,{value:i.map}),Object.defineProperty(this,n.SCALAR,{value:a.string}),Object.defineProperty(this,n.SEQ,{value:s.seq}),this.sortMapEntries="function"==typeof d?d:!0===d?l:null}clone(){let t=Object.create(e.prototype,Object.getOwnPropertyDescriptors(this));return t.tags=this.tags.slice(),t}}},9988(e,t,r){var n=r(6730),i=r(73);t.map={collection:"map",default:!0,nodeClass:i.YAMLMap,tag:"tag:yaml.org,2002:map",resolve:(e,t)=>(n.isMap(e)||t("Expected a mapping for this tag"),e),createNode:(e,t,r)=>i.YAMLMap.from(e,t,r)}},5725(e,t,r){var n=r(8376);let i={identify:e=>null==e,createNode:()=>new n.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new n.Scalar(null),stringify:({source:e},t)=>"string"==typeof e&&i.test.test(e)?e:t.options.nullStr};t.nullTag=i},505(e,t,r){var n=r(6730),i=r(7028);t.seq={collection:"seq",default:!0,nodeClass:i.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve:(e,t)=>(n.isSeq(e)||t("Expected a sequence for this tag"),e),createNode:(e,t,r)=>i.YAMLSeq.from(e,t,r)}},5613(e,t,r){var n=r(4286);t.string={identify:e=>"string"==typeof e,default:!0,tag:"tag:yaml.org,2002:str",resolve:e=>e,stringify:(e,t,r,i)=>(t=Object.assign({actualString:!0},t),n.stringifyString(e,t,r,i))}},4302(e,t,r){var n=r(8376);let i={identify:e=>"boolean"==typeof e,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new n.Scalar("t"===e[0]||"T"===e[0]),stringify:({source:e,value:t},r)=>e&&i.test.test(e)&&t===("t"===e[0]||"T"===e[0])?e:t?r.options.trueStr:r.options.falseStr};t.boolTag=i},7878(e,t,r){var n=r(8376),i=r(4374);let s={identify:e=>"number"==typeof e,default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>"nan"===e.slice(-3).toLowerCase()?NaN:"-"===e[0]?-1/0:1/0,stringify:i.stringifyNumber};t.float={identify:e=>"number"==typeof e,default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){let t=new n.Scalar(parseFloat(e)),r=e.indexOf(".");return -1!==r&&"0"===e[e.length-1]&&(t.minFractionDigits=e.length-r-1),t},stringify:i.stringifyNumber},t.floatExp={identify:e=>"number"==typeof e,default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():i.stringifyNumber(e)}},t.floatNaN=s},9305(e,t,r){var n=r(4374);let i=e=>"bigint"==typeof e||Number.isInteger(e),s=(e,t,r,{intAsBigInt:n})=>n?BigInt(e):parseInt(e.substring(t),r);function a(e,t,r){let{value:s}=e;return i(s)&&s>=0?r+s.toString(t):n.stringifyNumber(e)}t.int={identify:i,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(e,t,r)=>s(e,0,10,r),stringify:n.stringifyNumber},t.intHex={identify:e=>i(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,r)=>s(e,2,16,r),stringify:e=>a(e,16,"0x")},t.intOct={identify:e=>i(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(e,t,r)=>s(e,2,8,r),stringify:e=>a(e,8,"0o")}},8537(e,t,r){var n=r(9988),i=r(5725),s=r(505),a=r(5613),o=r(4302),l=r(7878),c=r(9305);t.schema=[n.map,s.seq,a.string,i.nullTag,o.boolTag,c.intOct,c.int,c.intHex,l.floatNaN,l.floatExp,l.float]},7150(e,t,r){var n=r(8376),i=r(9988),s=r(505);function a(e){return"bigint"==typeof e||Number.isInteger(e)}let o=({value:e})=>JSON.stringify(e),l=[{identify:e=>"string"==typeof e,default:!0,tag:"tag:yaml.org,2002:str",resolve:e=>e,stringify:o},{identify:e=>null==e,createNode:()=>new n.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:o},{identify:e=>"boolean"==typeof e,default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:e=>"true"===e,stringify:o},{identify:a,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:r})=>r?BigInt(e):parseInt(e,10),stringify:({value:e})=>a(e)?e.toString():JSON.stringify(e)},{identify:e=>"number"==typeof e,default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:e=>parseFloat(e),stringify:o}];t.schema=[i.map,s.seq].concat(l,{default:!0,tag:"",test:/^/,resolve:(e,t)=>(t(`Unresolved plain scalar ${JSON.stringify(e)}`),e)})},7545(e,t,r){var n=r(9988),i=r(5725),s=r(505),a=r(5613),o=r(4302),l=r(7878),c=r(9305),u=r(8537),d=r(7150),f=r(298),h=r(8327),p=r(8822),m=r(9946),g=r(3908),y=r(6675),b=r(9859);let v=new Map([["core",u.schema],["failsafe",[n.map,s.seq,a.string]],["json",d.schema],["yaml11",g.schema],["yaml-1.1",g.schema]]),w={binary:f.binary,bool:o.boolTag,float:l.float,floatExp:l.floatExp,floatNaN:l.floatNaN,floatTime:b.floatTime,int:c.int,intHex:c.intHex,intOct:c.intOct,intTime:b.intTime,map:n.map,merge:h.merge,null:i.nullTag,omap:p.omap,pairs:m.pairs,seq:s.seq,set:y.set,timestamp:b.timestamp};t.coreKnownTags={"tag:yaml.org,2002:binary":f.binary,"tag:yaml.org,2002:merge":h.merge,"tag:yaml.org,2002:omap":p.omap,"tag:yaml.org,2002:pairs":m.pairs,"tag:yaml.org,2002:set":y.set,"tag:yaml.org,2002:timestamp":b.timestamp},t.getTags=function(e,t,r){let n=v.get(t);if(n&&!e)return r&&!n.includes(h.merge)?n.concat(h.merge):n.slice();let i=n;if(!i)if(Array.isArray(e))i=[];else{let e=Array.from(v.keys()).filter(e=>"yaml11"!==e).map(e=>JSON.stringify(e)).join(", ");throw Error(`Unknown schema "${t}"; use one of ${e} or define customTags array`)}if(Array.isArray(e))for(let t of e)i=i.concat(t);else"function"==typeof e&&(i=e(i.slice()));return r&&(i=i.concat(h.merge)),i.reduce((e,t)=>{let r="string"==typeof t?w[t]:t;if(!r){let e=JSON.stringify(t),r=Object.keys(w).map(e=>JSON.stringify(e)).join(", ");throw Error(`Unknown custom tag ${e}; use one of ${r}`)}return e.includes(r)||e.push(r),e},[])}},298(e,t,r){var n=r(181),i=r(8376),s=r(4286);t.binary={identify:e=>e instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(e,t){if("function"==typeof n.Buffer)return n.Buffer.from(e,"base64");if("function"!=typeof atob)return t("This environment does not support reading binary tags; either Buffer or atob is required"),e;{let t=atob(e.replace(/[\n\r]/g,"")),r=new Uint8Array(t.length);for(let e=0;e<t.length;++e)r[e]=t.charCodeAt(e);return r}},stringify({comment:e,type:t,value:r},a,o,l){let c;if(!r)return"";if("function"==typeof n.Buffer)c=r instanceof n.Buffer?r.toString("base64"):n.Buffer.from(r.buffer).toString("base64");else if("function"==typeof btoa){let e="";for(let t=0;t<r.length;++t)e+=String.fromCharCode(r[t]);c=btoa(e)}else throw Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(t??(t=i.Scalar.BLOCK_LITERAL),t!==i.Scalar.QUOTE_DOUBLE){let e=Math.max(a.options.lineWidth-a.indent.length,a.options.minContentWidth),r=Math.ceil(c.length/e),n=Array(r);for(let t=0,i=0;t<r;++t,i+=e)n[t]=c.substr(i,e);c=n.join(t===i.Scalar.BLOCK_LITERAL?"\n":" ")}return s.stringifyString({comment:e,type:t,value:c},a,o,l)}}},4211(e,t,r){var n=r(8376);function i({value:e,source:t},r){let n=e?s:a;return t&&n.test.test(t)?t:e?r.options.trueStr:r.options.falseStr}let s={identify:e=>!0===e,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new n.Scalar(!0),stringify:i},a={identify:e=>!1===e,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new n.Scalar(!1),stringify:i};t.falseTag=a,t.trueTag=s},1489(e,t,r){var n=r(8376),i=r(4374);let s={identify:e=>"number"==typeof e,default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>"nan"===e.slice(-3).toLowerCase()?NaN:"-"===e[0]?-1/0:1/0,stringify:i.stringifyNumber};t.float={identify:e=>"number"==typeof e,default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let t=new n.Scalar(parseFloat(e.replace(/_/g,""))),r=e.indexOf(".");if(-1!==r){let n=e.substring(r+1).replace(/_/g,"");"0"===n[n.length-1]&&(t.minFractionDigits=n.length)}return t},stringify:i.stringifyNumber},t.floatExp={identify:e=>"number"==typeof e,default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,"")),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():i.stringifyNumber(e)}},t.floatNaN=s},5566(e,t,r){var n=r(4374);let i=e=>"bigint"==typeof e||Number.isInteger(e);function s(e,t,r,{intAsBigInt:n}){let i=e[0];if(("-"===i||"+"===i)&&(t+=1),e=e.substring(t).replace(/_/g,""),n){switch(r){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`}let t=BigInt(e);return"-"===i?BigInt(-1)*t:t}let a=parseInt(e,r);return"-"===i?-1*a:a}function a(e,t,r){let{value:s}=e;if(i(s)){let e=s.toString(t);return s<0?"-"+r+e.substr(1):r+e}return n.stringifyNumber(e)}t.int={identify:i,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,r)=>s(e,0,10,r),stringify:n.stringifyNumber},t.intBin={identify:i,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,r)=>s(e,2,2,r),stringify:e=>a(e,2,"0b")},t.intHex={identify:i,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,r)=>s(e,2,16,r),stringify:e=>a(e,16,"0x")},t.intOct={identify:i,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,r)=>s(e,1,8,r),stringify:e=>a(e,8,"0")}},8327(e,t,r){var n=r(6730),i=r(8376);let s={identify:e=>"<<"===e||"symbol"==typeof e&&"<<"===e.description,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new i.Scalar(Symbol("<<")),{addToJSMap:a}),stringify:()=>"<<"};function a(e,t,r){let i=l(e,r);if(n.isSeq(i))for(let r of i.items)o(e,t,r);else if(Array.isArray(i))for(let r of i)o(e,t,r);else o(e,t,i)}function o(e,t,r){let i=l(e,r);if(!n.isMap(i))throw Error("Merge sources must be maps or map aliases");for(let[r,n]of i.toJSON(null,e,Map))t instanceof Map?t.has(r)||t.set(r,n):t instanceof Set?t.add(r):Object.prototype.hasOwnProperty.call(t,r)||Object.defineProperty(t,r,{value:n,writable:!0,enumerable:!0,configurable:!0});return t}function l(e,t){return e&&n.isAlias(t)?t.resolve(e.doc,e):t}t.addMergeToJSMap=a,t.isMergeKey=(e,t)=>(s.identify(t)||n.isScalar(t)&&(!t.type||t.type===i.Scalar.PLAIN)&&s.identify(t.value))&&e?.doc.schema.tags.some(e=>e.tag===s.tag&&e.default),t.merge=s},8822(e,t,r){var n=r(6730),i=r(2234),s=r(73),a=r(7028),o=r(9946);class l extends a.YAMLSeq{constructor(){super(),this.add=s.YAMLMap.prototype.add.bind(this),this.delete=s.YAMLMap.prototype.delete.bind(this),this.get=s.YAMLMap.prototype.get.bind(this),this.has=s.YAMLMap.prototype.has.bind(this),this.set=s.YAMLMap.prototype.set.bind(this),this.tag=l.tag}toJSON(e,t){if(!t)return super.toJSON(e);let r=new Map;for(let e of(t?.onCreate&&t.onCreate(r),this.items)){let s,a;if(n.isPair(e)?(s=i.toJS(e.key,"",t),a=i.toJS(e.value,s,t)):s=i.toJS(e,"",t),r.has(s))throw Error("Ordered maps must not include duplicate keys");r.set(s,a)}return r}static from(e,t,r){let n=o.createPairs(e,t,r),i=new this;return i.items=n.items,i}}l.tag="tag:yaml.org,2002:omap",t.YAMLOMap=l,t.omap={collection:"seq",identify:e=>e instanceof Map,nodeClass:l,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){let r=o.resolvePairs(e,t),i=[];for(let{key:e}of r.items)n.isScalar(e)&&(i.includes(e.value)?t(`Ordered maps must not include duplicate keys: ${e.value}`):i.push(e.value));return Object.assign(new l,r)},createNode:(e,t,r)=>l.from(e,t,r)}},9946(e,t,r){var n=r(6730),i=r(7748),s=r(8376),a=r(7028);function o(e,t){if(n.isSeq(e))for(let r=0;r<e.items.length;++r){let a=e.items[r];if(!n.isPair(a)){if(n.isMap(a)){a.items.length>1&&t("Each pair must have its own sequence indicator");let e=a.items[0]||new i.Pair(new s.Scalar(null));if(a.commentBefore&&(e.key.commentBefore=e.key.commentBefore?`${a.commentBefore}
11
+ ${e.key.commentBefore}`:a.commentBefore),a.comment){let t=e.value??e.key;t.comment=t.comment?`${a.comment}
12
+ ${t.comment}`:a.comment}a=e}e.items[r]=n.isPair(a)?a:new i.Pair(a)}}else t("Expected a sequence for this tag");return e}function l(e,t,r){let{replacer:n}=r,s=new a.YAMLSeq(e);s.tag="tag:yaml.org,2002:pairs";let o=0;if(t&&Symbol.iterator in Object(t))for(let e of t){let a,l;if("function"==typeof n&&(e=n.call(t,String(o++),e)),Array.isArray(e))if(2===e.length)a=e[0],l=e[1];else throw TypeError(`Expected [key, value] tuple: ${e}`);else if(e&&e instanceof Object){let t=Object.keys(e);if(1===t.length)l=e[a=t[0]];else throw TypeError(`Expected tuple with one key, not ${t.length} keys`)}else a=e;s.items.push(i.createPair(a,l,r))}return s}t.createPairs=l,t.pairs={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:o,createNode:l},t.resolvePairs=o},3908(e,t,r){var n=r(9988),i=r(5725),s=r(505),a=r(5613),o=r(298),l=r(4211),c=r(1489),u=r(5566),d=r(8327),f=r(8822),h=r(9946),p=r(6675),m=r(9859);t.schema=[n.map,s.seq,a.string,i.nullTag,l.trueTag,l.falseTag,u.intBin,u.intOct,u.int,u.intHex,c.floatNaN,c.floatExp,c.float,o.binary,d.merge,f.omap,h.pairs,p.set,m.intTime,m.floatTime,m.timestamp]},6675(e,t,r){var n=r(6730),i=r(7748),s=r(73);class a extends s.YAMLMap{constructor(e){super(e),this.tag=a.tag}add(e){let t;t=n.isPair(e)?e:e&&"object"==typeof e&&"key"in e&&"value"in e&&null===e.value?new i.Pair(e.key,null):new i.Pair(e,null),s.findPair(this.items,t.key)||this.items.push(t)}get(e,t){let r=s.findPair(this.items,e);return!t&&n.isPair(r)?n.isScalar(r.key)?r.key.value:r.key:r}set(e,t){if("boolean"!=typeof t)throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let r=s.findPair(this.items,e);r&&!t?this.items.splice(this.items.indexOf(r),1):!r&&t&&this.items.push(new i.Pair(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,r){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,r);throw Error("Set items must all have null values")}static from(e,t,r){let{replacer:n}=r,s=new this(e);if(t&&Symbol.iterator in Object(t))for(let e of t)"function"==typeof n&&(e=n.call(t,e,e)),s.items.push(i.createPair(e,null,r));return s}}a.tag="tag:yaml.org,2002:set",t.YAMLSet=a,t.set={collection:"map",identify:e=>e instanceof Set,nodeClass:a,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,t,r)=>a.from(e,t,r),resolve(e,t){if(n.isMap(e))if(e.hasAllNullValues(!0))return Object.assign(new a,e);else t("Set items must all have null values");else t("Expected a mapping for this tag");return e}}},9859(e,t,r){var n=r(4374);function i(e,t){let r=e[0],n="-"===r||"+"===r?e.substring(1):e,i=e=>t?BigInt(e):Number(e),s=n.replace(/_/g,"").split(":").reduce((e,t)=>e*i(60)+i(t),i(0));return"-"===r?i(-1)*s:s}function s(e){let{value:t}=e,r=e=>e;if("bigint"==typeof t)r=e=>BigInt(e);else if(isNaN(t)||!isFinite(t))return n.stringifyNumber(e);let i="";t<0&&(i="-",t*=r(-1));let s=r(60),a=[t%s];return t<60?a.unshift(0):(t=(t-a[0])/s,a.unshift(t%s),t>=60&&(t=(t-a[0])/s,a.unshift(t))),i+a.map(e=>String(e).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}let a={identify:e=>e instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(e){let t=e.match(a.test);if(!t)throw Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,r,n,s,o,l,c]=t.map(Number),u=Date.UTC(r,n-1,s,o||0,l||0,c||0,t[7]?Number((t[7]+"00").substr(1,3)):0),d=t[8];if(d&&"Z"!==d){let e=i(d,!1);30>Math.abs(e)&&(e*=60),u-=6e4*e}return new Date(u)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};t.floatTime={identify:e=>"number"==typeof e,default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:e=>i(e,!1),stringify:s},t.intTime={identify:e=>"bigint"==typeof e||Number.isInteger(e),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:r})=>i(e,r),stringify:s},t.timestamp=a},3980(e,t){let r="block",n="quoted";function i(e,t,r){let n=t,i=t+1,s=e[i];for(;" "===s||" "===s;)if(t<i+r)s=e[++t];else{do s=e[++t];while(s&&"\n"!==s)n=t,s=e[i=t+1]}return n}t.FOLD_BLOCK=r,t.FOLD_FLOW="flow",t.FOLD_QUOTED=n,t.foldFlowLines=function(e,t,s="flow",{indentAtStart:a,lineWidth:o=80,minContentWidth:l=20,onFold:c,onOverflow:u}={}){let d,f,h;if(!o||o<0)return e;o<l&&(l=0);let p=Math.max(1+l,1+o-t.length);if(e.length<=p)return e;let m=[],g={},y=o-t.length;"number"==typeof a&&(a>o-Math.max(2,l)?m.push(0):y=o-a);let b=!1,v=-1,w=-1,x=-1;for(s===r&&-1!==(v=i(e,v,t.length))&&(y=v+p);h=e[v+=1];){if(s===n&&"\\"===h){switch(w=v,e[v+1]){case"x":v+=3;break;case"u":v+=5;break;case"U":v+=9;break;default:v+=1}x=v}if("\n"===h)s===r&&(v=i(e,v,t.length)),y=v+t.length+p,d=void 0;else{if(" "===h&&f&&" "!==f&&"\n"!==f&&" "!==f){let t=e[v+1];t&&" "!==t&&"\n"!==t&&" "!==t&&(d=v)}if(v>=y)if(d)m.push(d),y=d+p,d=void 0;else if(s===n){for(;" "===f||" "===f;)f=h,h=e[v+=1],b=!0;let t=v>x+1?v-2:w-1;if(g[t])return e;m.push(t),g[t]=!0,y=t+p,d=void 0}else b=!0}f=h}if(b&&u&&u(),0===m.length)return e;c&&c();let k=e.slice(0,m[0]);for(let r=0;r<m.length;++r){let i=m[r],a=m[r+1]||e.length;0===i?k=`
13
+ ${t}${e.slice(0,a)}`:(s===n&&g[i]&&(k+=`${e[i]}\\`),k+=`
14
+ ${t}${e.slice(i+1,a)}`)}return k}},6203(e,t,r){var n=r(9531),i=r(6730),s=r(3202),a=r(4286);t.createStringifyContext=function(e,t){let r,n=Object.assign({blockQuote:!0,commentString:s.stringifyComment,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:"true",verifyAliasOrder:!0},e.schema.toStringOptions,t);switch(n.collectionStyle){case"block":r=!1;break;case"flow":r=!0;break;default:r=null}return{anchors:new Set,doc:e,flowCollectionPadding:n.flowCollectionPadding?" ":"",indent:"",indentStep:"number"==typeof n.indent?" ".repeat(n.indent):" ",inFlow:r,options:n}},t.stringify=function(e,t,r,s){let o;if(i.isPair(e))return e.toString(t,r,s);if(i.isAlias(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw TypeError("Cannot stringify circular structure without alias nodes");t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=new Set([e]),e=e.resolve(t.doc)}let l=i.isNode(e)?e:t.doc.createNode(e,{onTagObj:e=>o=e});o??(o=function(e,t){let r,n;if(t.tag){let r=e.filter(e=>e.tag===t.tag);if(r.length>0)return r.find(e=>e.format===t.format)??r[0]}if(i.isScalar(t)){r=t.value;let i=e.filter(e=>e.identify?.(r));if(i.length>1){let e=i.filter(e=>e.test);e.length>0&&(i=e)}n=i.find(e=>e.format===t.format)??i.find(e=>!e.format)}else r=t,n=e.find(e=>e.nodeClass&&r instanceof e.nodeClass);if(!n){let e=r?.constructor?.name??(null===r?"null":typeof r);throw Error(`Tag not resolved for ${e} value`)}return n}(t.doc.schema.tags,l));let c=function(e,t,{anchors:r,doc:s}){if(!s.directives)return"";let a=[],o=(i.isScalar(e)||i.isCollection(e))&&e.anchor;o&&n.anchorIsValid(o)&&(r.add(o),a.push(`&${o}`));let l=e.tag??(t.default?null:t.tag);return l&&a.push(s.directives.tagString(l)),a.join(" ")}(l,o,t);c.length>0&&(t.indentAtStart=(t.indentAtStart??0)+c.length+1);let u="function"==typeof o.stringify?o.stringify(l,t,r,s):i.isScalar(l)?a.stringifyString(l,t,r,s):l.toString(t,r,s);return c?i.isScalar(l)||"{"===u[0]||"["===u[0]?`${c} ${u}`:`${c}
15
+ ${t.indent}${u}`:u}},8143(e,t,r){var n=r(6730),i=r(6203),s=r(3202);function a({indent:e,options:{commentString:t}},r,n,i){if(n&&i&&(n=n.replace(/^\n+/,"")),n){let i=s.indentComment(t(n),e);r.push(i.trimStart())}}t.stringifyCollection=function(e,t,r){return(t.inFlow??e.flow?function({items:e},t,{flowChars:r,itemIndent:o}){let{indent:l,indentStep:c,flowCollectionPadding:u,options:{commentString:d}}=t,f=Object.assign({},t,{indent:o+=c,inFlow:!0,type:null}),h=!1,p=0,m=[];for(let r=0;r<e.length;++r){let l=e[r],c=null;if(n.isNode(l))l.spaceBefore&&m.push(""),a(t,m,l.commentBefore,!1),l.comment&&(c=l.comment);else if(n.isPair(l)){let e=n.isNode(l.key)?l.key:null;e&&(e.spaceBefore&&m.push(""),a(t,m,e.commentBefore,!1),e.comment&&(h=!0));let r=n.isNode(l.value)?l.value:null;r?(r.comment&&(c=r.comment),r.commentBefore&&(h=!0)):null==l.value&&e?.comment&&(c=e.comment)}c&&(h=!0);let u=i.stringify(l,f,()=>c=null);h||(h=m.length>p||u.includes("\n")),r<e.length-1?u+=",":t.options.trailingComma&&(t.options.lineWidth>0&&(h||(h=m.reduce((e,t)=>e+t.length+2,2)+(u.length+2)>t.options.lineWidth)),h&&(u+=",")),c&&(u+=s.lineComment(u,o,d(c))),m.push(u),p=m.length}let{start:g,end:y}=r;if(0===m.length)return g+y;if(!h){let e=m.reduce((e,t)=>e+t.length+2,2);h=t.options.lineWidth>0&&e>t.options.lineWidth}if(!h)return`${g}${u}${m.join(" ")}${u}${y}`;{let e=g;for(let t of m)e+=t?`
16
+ ${c}${l}${t}`:"\n";return`${e}
17
+ ${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(""),a(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(""),a(r,y,e.commentBefore,g))}g=!1;let d=i.stringify(l,m,()=>u=null,()=>g=!0);u&&(d+=s.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?`
18
+ ${h}${t}`:"\n"}}return e?(f+="\n"+s.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),s=r(3202);t.stringifyDocument=function(e,t){let r=[],a=!0===t.directives;if(!1!==t.directives&&e.directives){let t=e.directives.toString(e);t?(r.push(t),a=!0):e.directives.docStart&&(a=!0)}a&&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(s.indentComment(t,""))}let c=!1,u=null;if(e.contents){if(n.isNode(e.contents)){if(e.contents.spaceBefore&&a&&r.push(""),e.contents.commentBefore){let t=l(e.contents.commentBefore);r.push(s.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+=s.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(s.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(s.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 s=Object.is(n,-0)?"-0":JSON.stringify(n);if(!e&&t&&(!r||"tag:yaml.org,2002:float"===r)&&/^-?\d/.test(s)&&!s.includes("e")){let e=s.indexOf(".");e<0&&(e=s.length,s+=".");let r=t-(s.length-e-1);for(;r-- >0;)s+="0"}return s}},4711(e,t,r){var n=r(6730),i=r(8376),s=r(6203),a=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,k=!1,S=s.stringify(e,r,()=>x=!0,()=>k=!0);if(!w&&!r.inFlow&&S.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(),""===S?"?":w?`? ${S}`:S}else if(f&&!b||null==t&&w)return S=`? ${S}`,v&&!x?S+=a.lineComment(S,r.indent,g(v)):k&&l&&l(),S;x&&(v=null),w?(v&&(S+=a.lineComment(S,r.indent,g(v))),S=`? ${S}
19
+ ${p}:`):(S=`${S}:`,v&&(S+=a.lineComment(S,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=S.length+1),k=!1,!(!y&&m.length>=2&&!r.inFlow&&!w&&n.isSeq(t))||t.flow||t.tag||t.anchor||(r.indent=r.indent.substring(2));let _=!1,$=s.stringify(t,r,()=>_=!0,()=>k=!0),O=" ";if(v||c||u){if(O=c?"\n":"",u){let e=g(u);O+=`
20
+ ${a.indentComment(e,r.indent)}`}""!==$||r.inFlow?O+=`
21
+ ${r.indent}`:"\n"===O&&d&&(O="\n\n")}else if(!w&&n.isCollection(t)){let e=$[0],n=$.indexOf("\n"),i=-1!==n,s=r.inFlow??t.flow??0===t.items.length;if(i||!s){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||(O=`
22
+ ${r.indent}`)}}else(""===$||"\n"===$[0])&&(O="");return S+=O+$,r.inFlow?_&&o&&o():d&&!_?S+=a.lineComment(S,r.indent,g(d)):k&&l&&l(),S}},4286(e,t,r){let n;var i=r(8376),s=r(3980);let a=(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:s.foldFlowLines(l,o,s.FOLD_QUOTED,a(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,`$&
23
+ ${r}`)+"'";return t.implicitKey?n:s.foldFlowLines(n,r,s.FOLD_FLOW,a(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),k=x.indexOf("\n");-1===k?f="-":r===x||k!==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 S=!1,_=-1;for(p=0;p<r.length;++p){let e=r[p];if(" "===e)S=!0;else if("\n"===e)_=p;else break}let $=r.substring(0,_<p?_+1:p);$&&(r=r.substring($.length),$=$.replace(/\n+/g,`$&${v}`));let O=v?"2":"1",I=(S?O:"")+f;if(e&&(I+=" "+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=a(o,!0);"folded"!==g&&t!==i.Scalar.BLOCK_FOLDED&&(l.onOverflow=()=>{n=!0});let c=s.foldFlowLines(`${$}${e}${x}`,v,s.FOLD_BLOCK,l);if(!n)return`>${I}
24
+ ${v}${c}`}return r=r.replace(/\n+/g,`$&${v}`),`|${I}
25
+ ${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,`$&
26
+ ${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:s.foldFlowLines(g,h,s.FOLD_FLOW,a(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"),s=Symbol("skip children"),a=Symbol("remove node");function o(e,t){let r=d(t);n.isDocument(e)?l(null,e.contents,r,Object.freeze([e]))===a&&(e.contents=null):l(null,e,r,Object.freeze([]))}function l(e,t,r,s){let o=f(e,t,r,s);if(n.isNode(o)||n.isPair(o))return h(e,s,o),l(e,o,r,s);if("symbol"!=typeof o){if(n.isCollection(t)){s=Object.freeze(s.concat(t));for(let e=0;e<t.items.length;++e){let n=l(e,t.items[e],r,s);if("number"==typeof n)e=n-1;else{if(n===i)return i;n===a&&(t.items.splice(e,1),e-=1)}}}else if(n.isPair(t)){s=Object.freeze(s.concat(t));let e=l("key",t.key,r,s);if(e===i)return i;e===a&&(t.key=null);let n=l("value",t.value,r,s);if(n===i)return i;n===a&&(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]))===a&&(e.contents=null):await u(null,e,r,Object.freeze([]))}async function u(e,t,r,s){let o=await f(e,t,r,s);if(n.isNode(o)||n.isPair(o))return h(e,s,o),u(e,o,r,s);if("symbol"!=typeof o){if(n.isCollection(t)){s=Object.freeze(s.concat(t));for(let e=0;e<t.items.length;++e){let n=await u(e,t.items[e],r,s);if("number"==typeof n)e=n-1;else{if(n===i)return i;n===a&&(t.items.splice(e,1),e-=1)}}}else if(n.isPair(t)){s=Object.freeze(s.concat(t));let e=await u("key",t.key,r,s);if(e===i)return i;e===a&&(t.key=null);let n=await u("value",t.value,r,s);if(n===i)return i;n===a&&(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=s,o.REMOVE=a,c.BREAK=i,c.SKIP=s,c.REMOVE=a,t.visit=o,t.visitAsync=c}},s={};function a(e){var t=s[e];if(void 0!==t)return t.exports;var r=s[e]={exports:{}};return i[e](r,r.exports,a),r.exports}n=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,a.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);a.r(i);var s={};r=r||[null,n({}),n([]),n(n)];for(var o=2&t&&e;("object"==typeof o||"function"==typeof o)&&!~r.indexOf(o);o=n(o))Object.getOwnPropertyNames(o).forEach(t=>{s[t]=()=>e[t]});return s.default=()=>e,a.d(i,s),i},a.d=(e,t,r)=>{var n=(t,r)=>{for(var n in t)a.o(t,n)&&!a.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,[r]:t[n]})};n(t,"get"),n(r,"value")},a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),a.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{let e,r,n,i,s,o,l,c,u,d,f,h,p,m,g,y,b,v,w,x,k,S,_,$,O,I,C,E,A,T,M,N,j,F,L,P,D,R,U,B,q,K,z,V,J,W,Y;var G,H,Q,Z,X,ee,et,er,en,ei={};a.r(ei),a.d(ei,{Do:()=>nf,all:()=>r4,andThen:()=>rH,as:()=>rJ,asVoid:()=>rW,bind:()=>nd,bindTo:()=>nc,composeK:()=>r1,contains:()=>no,containsWith:()=>na,exists:()=>nl,filter:()=>nt,filterMap:()=>ne,firstSomeOf:()=>rF,flatMap:()=>rG,flatMapNullishOr:()=>rQ,flatten:()=>rZ,fromIterable:()=>rC,fromNullOr:()=>rD,fromNullishOr:()=>rL,fromUndefinedOr:()=>rP,gen:()=>nh,getFailure:()=>rA,getOrElse:()=>rT,getOrNull:()=>rU,getOrThrow:()=>rz,getOrThrowWith:()=>rK,getOrUndefined:()=>rB,getSuccess:()=>rE,isNone:()=>r_,isOption:()=>rS,isSome:()=>r$,let:()=>nu,lift2:()=>ni,liftNullishOr:()=>rR,liftPredicate:()=>ns,liftThrowable:()=>rq,makeCombinerFailFast:()=>nm,makeEquivalence:()=>nr,makeOrder:()=>nn,makeReducer:()=>np,makeReducerFailFast:()=>ng,map:()=>rV,match:()=>rO,none:()=>rx,orElse:()=>rM,orElseResult:()=>rj,orElseSome:()=>rN,partitionMap:()=>r7,product:()=>r3,productMany:()=>r5,reduceCompact:()=>r6,some:()=>rk,tap:()=>r2,toArray:()=>r9,toRefinement:()=>rI,void:()=>rY,zipLeft:()=>r0,zipRight:()=>rX,zipWith:()=>r8});let es=(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}}},ea={pipe(){return es(this,arguments)}},eo=function(){function e(){}return e.prototype=ea,e}(),el=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)}}}},ec=e=>e,eu=e=>()=>e,ed=eu(!0),ef=eu(!1),eh=eu(null),ep=eu(void 0);function em(e,...t){return es(e,t)}function eg(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}}let ey=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},eb=new WeakSet;function ev(e){return"string"==typeof e}function ew(e){return"number"==typeof e}function ex(e){return"boolean"==typeof e}function ek(e){return"bigint"==typeof e}function eS(e){return"symbol"==typeof e}function e_(e){return"function"==typeof e}function e$(e){return void 0===e}function eO(e){return void 0!==e}function eI(e){return null!==e}function eC(e){return null!=e}function eE(e){return!0}function eA(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}let eT=el(2,(e,t)=>{var r;return("object"==typeof(r=e)&&null!==r||e_(r))&&t in e}),eM=el(2,(e,t)=>eT(e,"_tag")&&e._tag===t);function eN(e){return eT(e,Symbol.iterator)||ev(e)}let ej="~effect/interfaces/Hash",eF=e=>{switch(typeof e){case"number":return eU(e);case"bigint":return eB(e.toString(10));case"boolean":case"symbol":return eB(String(e));case"string":return eB(e);case"undefined":return eB("undefined");case"function":case"object":if(null===e)return eB("null");{if(e instanceof Date)return eB(e.toISOString());if(e instanceof RegExp)return eB(e.toString());if(eb.has(e))return eL(e);if(eG.has(e))return eG.get(e);let t=function(e,t){if(eH.has(e))return eB("[Circular]");eH.add(e);let r=t();return eH.delete(e),r}(e,()=>{if(eR(e))return e[ej]();if("function"==typeof e)return eL(e);if(Array.isArray(e)||ArrayBuffer.isView(e))return eV(e);if(e instanceof Map)return eJ(e);if(e instanceof Set)return eW(e);return eK(e)});return eG.set(e,t),t}default:throw Error(`BUG: unhandled typeof ${typeof e} - please report an issue at https://github.com/Effect-TS/effect/issues`)}},eL=e=>(eY.has(e)||eY.set(e,eU(Math.floor(Math.random()*Number.MAX_SAFE_INTEGER))),eY.get(e)),eP=el(2,(e,t)=>53*e^t),eD=e=>0xbfffffff&e|e>>>1&0x40000000,eR=e=>eT(e,ej),eU=e=>{if(e!=e)return eB("NaN");if(e===1/0)return eB("Infinity");if(e===-1/0)return eB("-Infinity");let t=0|e;for(t!==e&&(t^=0xffffffff*e);e>0xffffffff;)t^=e/=0xffffffff;return eD(t)},eB=e=>{let t=5381,r=e.length;for(;r;)t=33*t^e.charCodeAt(--r);return eD(t)},eq=(e,t)=>{let r=12289;for(let n of t)r^=eP(eF(n),eF(e[n]));return eD(r)},eK=e=>eq(e,ey(e)),ez=(e,t)=>r=>{let n=e;for(let e of r)n^=t(e);return eD(n)},eV=ez(6151,eF),eJ=ez(eB("Map"),([e,t])=>eP(eF(e),eF(t))),eW=ez(eB("Set"),eF),eY=new WeakMap,eG=new WeakMap,eH=new WeakSet,eQ="~effect/interfaces/Equal";function eZ(){return 1==arguments.length?e=>eX(e,arguments[0]):eX(arguments[0],arguments[1])}function eX(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||eb.has(e)||eb.has(t))&&function(e,t,r){let n=e3.get(e);if(n){if(n.has(t))return n.get(t)}else n=new WeakMap,e3.set(e,n);let i=r(e,t);n.set(t,i);let s=e3.get(t);return s||(s=new WeakMap,e3.set(t,s)),s.set(e,i),i}(e,t,e2))}let e0=new WeakSet,e1=new WeakSet;function e2(e,t){if(eF(e)!==eF(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=e8(e),n=e8(t);if(r!==n)return!1;let i=r&&n;return("function"!=typeof e||!!i)&&function(e,t,r){let n=e0.has(e),i=e1.has(t);if(n&&i)return!0;if(n||i)return!1;e0.add(e),e1.add(t);let s=r();return e0.delete(e),e1.delete(t),s}(e,t,()=>{if(i)return e[eQ](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(!eX(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&&e5(e,t);if(e instanceof Set)return t instanceof Set&&e.size===t.size&&e4(e,t);var r=e,n=t;let s=ey(r),a=ey(n);if(s.size!==a.size)return!1;for(let e of s)if(!a.has(e)||!eX(r[e],n[e]))return!1;return!0})}let e3=new WeakMap,e5=(H=eX,Q=eX,function(e,t){for(let[r,n]of e){let e=!1;for(let[i,s]of t)if(H(r,i)&&Q(n,s)){e=!0;break}if(!e)return!1}return!0}),e4=(Z=eX,function(e,t){for(let r of e){let e=!1;for(let n of t)if(Z(r,n)){e=!0;break}if(!e)return!1}return!0}),e8=e=>eT(e,eQ),e6=Symbol.for("~effect/Redactable");function e9(e){return eT(e,e6)?e7(e):e}function e7(e){return e[e6](globalThis[te]?.context??tt)}let te="~effect/Fiber/currentFiber",tt={"~effect/Context":{},mapUnsafe:new Map,pipe(){return es(this,arguments)}};function tr(e,t){let r=t?.space??0,n=new WeakSet,i=r?"number"==typeof r?" ".repeat(r):r:"",s=(e,t)=>{let r=e?.constructor;return r&&r!==Object.prototype.constructor&&r.name?`${r.name}(${t})`:t};return function e(r,a=0){if(Array.isArray(r)){let t,s;if(n.has(r))return tn;if(n.add(r),!i||r.length<=1)return`[${r.map(t=>e(t,a)).join(",")}]`;let o=r.map(t=>e(t,a+1)).join(",\n"+(t=a+1,i.repeat(t)));return`[
27
+ ${s=a+1,i.repeat(s)}${o}
28
+ ${i.repeat(a)}]`}if(r instanceof Date)return ts(r);if(!t?.ignoreToString&&eT(r,"toString")&&"function"==typeof r.toString&&r.toString!==Object.prototype.toString&&r.toString!==Array.prototype.toString){let t=function(e){try{let t=e.toString();return"string"==typeof t?t:String(t)}catch{return"[toString threw]"}}(r);return r instanceof Error&&r.cause?`${t} (cause: ${e(r.cause,a)})`:t}if("string"==typeof r)return JSON.stringify(r);if("number"==typeof r||null==r||"boolean"==typeof r||"symbol"==typeof r)return String(r);if("bigint"==typeof r)return String(r)+"n";if("object"==typeof r||"function"==typeof r){if(n.has(r))return tn;if(n.add(r),e6 in r)return tr(e7(r));if(Symbol.iterator in r)return`${r.constructor.name}(${e(Array.from(r),a)})`;let t=(e=>{try{return Reflect.ownKeys(e)}catch{return["[ownKeys threw]"]}})(r);if(!i||t.length<=1){let n=`{${t.map(t=>`${ti(t)}:${e(r[t],a)}`).join(",")}}`;return s(r,n)}let o=`{
29
+ ${t.map(t=>{let n;return`${n=a+1,i.repeat(n)}${ti(t)}: ${e(r[t],a+1)}`}).join(",\n")}
30
+ ${i.repeat(a)}}`;return s(r,o)}return String(r)}(e,0)}let tn="[Circular]";function ti(e){return"string"==typeof e?JSON.stringify(e):String(e)}function ts(e){try{return e.toISOString()}catch{return"Invalid Date"}}function ta(e,t){let r=[];return JSON.stringify(e,function(e,t){let n=e9(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)}let to=Symbol.for("nodejs.util.inspect.custom"),tl=e=>{try{if(eT(e,"toJSON")&&e_(e.toJSON)&&0===e.toJSON.length)return e.toJSON();if(Array.isArray(e))return e.map(tl)}catch{return"[toJSON threw]"}return e9(e)};class tc{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 tc(this.self)}}let tu=(r={[e="~effect/Utils/internal"]:e=>e()},r[e](()=>Error().stack)?.includes(e)===!0?r[e]:({[e]:e=>e()})[e]),td="~effect/Effect",tf="~effect/Exit",th=`${td}/identifier`,tp=`${td}/args`,tm=`${td}/evaluate`,tg=`${td}/successCont`,ty=`${td}/failureCont`,tb=`${td}/ensureCont`,tv=Symbol.for("effect/Effect/Yield"),tw={pipe(){return es(this,arguments)},toJSON(){return{...this}},toString(){return tr(this.toJSON(),{ignoreToString:!0,space:2})},[to](){return this.toJSON()}},tx={[td]:{_A:ec,_E:ec,_R:ec},...tw,[Symbol.iterator](){return new tc(this)},toJSON(){return{_id:"Effect",op:this[th],...tp in this?{args:this[tp]}:void 0}}},tk=e=>eT(e,td),tS="~effect/Cause",t_="~effect/Cause/Reason",t$=e=>eT(e,tS);class tO{[tS];reasons;constructor(e){this[tS]=tS,this.reasons=e}pipe(){return es(this,arguments)}toJSON(){return{_id:"Cause",failures:this.reasons.map(e=>e.toJSON())}}toString(){return`Cause(${tr(this.reasons)})`}[to](){return this.toJSON()}[eQ](e){return t$(e)&&this.reasons.length===e.reasons.length&&this.reasons.every((t,r)=>eZ(t,e.reasons[r]))}[ej](){return eV(this.reasons)}}let tI=new WeakMap;class tC{[t_];annotations;_tag;constructor(e,t,r){if(this[t_]=t_,this._tag=e,t!==tE&&"object"==typeof r&&null!==r&&t.size>0){let e=tI.get(r);e&&(t=new Map([...e,...t])),tI.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 es(this,arguments)}toString(){return tr(this)}[to](){return this.toString()}}let tE=new Map;class tA extends tC{error;constructor(e,t=tE){super("Fail",t,e),this.error=e}toString(){return`Fail(${tr(this.error)})`}toJSON(){return{_tag:"Fail",error:this.error}}[eQ](e){return tL(e)&&eZ(this.error,e.error)&&eZ(this.annotations,e.annotations)}[ej](){return eP(eB(this._tag))(eP(eF(this.error))(eF(this.annotations)))}}let tT=e=>new tO(e),tM=new tO([]),tN=e=>new tO([new tA(e)]);class tj extends tC{defect;constructor(e,t=tE){super("Die",t,e),this.defect=e}toString(){return`Die(${tr(this.defect)})`}toJSON(){return{_tag:"Die",defect:this.defect}}[eQ](e){return tP(e)&&eZ(this.defect,e.defect)&&eZ(this.annotations,e.annotations)}[ej](){return eP(eB(this._tag))(eP(eF(this.defect))(eF(this.annotations)))}}let tF=el(e=>t$(e[0]),(e,t,r)=>0===t.mapUnsafe.size?e:new tO(e.reasons.map(e=>e.annotate(t,r)))),tL=e=>"Fail"===e._tag,tP=e=>"Die"===e._tag,tD=e=>"Interrupt"===e._tag;function tR(e){return tW("Effect.evaluate: Not implemented")}let tU=e=>({...tx,[th]:e.op,[tm]:e[tm]??tR,[tg]:e[tg],[ty]:e[ty],[tb]:e[tb]}),tB=e=>{let t=tU(e);return function(){let r=Object.create(t);return r[tp]=!1===e.single?arguments:arguments[0],r}},tq=e=>{let t={...tU(e),[tf]:tf,_tag:e.op,get[e.prop](){return this[tp]},toString(){return`${e.op}(${tr(this[tp])})`},toJSON(){return{_id:"Exit",_tag:e.op,[e.prop]:this[tp]}},[eQ](e){return eT(e,tf)&&e._tag===this._tag&&eZ(this[tp],e[tp])},[ej](){return eP(eB(e.op),eF(this[tp]))}};return function(e){let r=Object.create(t);return r[tp]=e,r}},tK=tq({op:"Success",prop:"value",[tm](e){let t=e.getCont(tg);return t?t[tg](this[tp],e,this):e.yieldWith(this)}}),tz={key:"effect/Cause/StackTrace"},tV=tq({op:"Failure",prop:"cause",[tm](e){let t=this[tp],r=!1;e.currentStackFrame&&(t=tF(t,{mapUnsafe:new Map([[tz.key,e.currentStackFrame]])}),r=!0);let n=e.getCont(ty);for(;e.interruptible&&e._interruptedCause&&n;)n=e.getCont(ty);return n?n[ty](t,e,r?void 0:this):e.yieldWith(r?this:tV(t))}}),tJ=e=>tV(tN(e)),tW=e=>tV(new tO([new tj(e)])),tY=tB({op:"WithFiber",[tm](e){return this[tp](e)}}),tG=function(){class e extends globalThis.Error{}let t=tU({op:"YieldableError",[tm](){return tJ(this)}});return delete t.toString,Object.assign(e.prototype,t),e}(),tH=(n=Symbol.for("effect/Data/Error/plainArgs"),class extends tG{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}}}),tQ=e=>{class t extends tH{_tag=e}return t.prototype.name=e,t},tZ="~effect/Cause/NoSuchElementError";class tX extends tQ("NoSuchElementError"){[tZ]=tZ;constructor(e){super({message:e})}}let t0="~effect/Cause/Done",t1={[t0]:t0,_tag:"Done",value:void 0},t2=e=>void 0===e?t1:{[t0]:t0,_tag:"Done",value:e},t3=tJ(t1),t5=e=>(t,r)=>t===r||e(t,r),t4=e=>e.length>0,t8="~effect/data/Option",t6={[t8]:{_A:e=>e},...tw,[Symbol.iterator](){return new tc(this)}},t9=Object.defineProperty(Object.assign(Object.create(t6),{_tag:"Some",_op:"Some",[eQ](e){return rt(e)&&rn(e)&&eZ(this.value,e.value)},[ej](){return eP(eF(this._tag))(eF(this.value))},toString(){return`some(${tr(this.value)})`},toJSON(){return{_id:"Option",_tag:this._tag,value:tl(this.value)}}}),"valueOrUndefined",{get(){return this.value}}),t7=eF("None"),re=Object.assign(Object.create(t6),{_tag:"None",_op:"None",valueOrUndefined:void 0,[eQ]:e=>rt(e)&&rr(e),[ej]:()=>t7,toString:()=>"none()",toJSON(){return{_id:"Option",_tag:this._tag}}}),rt=e=>eT(e,t8),rr=e=>"None"===e._tag,rn=e=>"Some"===e._tag,ri=Object.create(re),rs=e=>{let t=Object.create(t9);return t.value=e,t},ra="~effect/data/Result",ro={[ra]:{_A:e=>e,_E:e=>e},...tw,[Symbol.iterator](){return new tc(this)}},rl=Object.assign(Object.create(ro),{_tag:"Success",_op:"Success",[eQ](e){return ru(e)&&rf(e)&&eZ(this.success,e.success)},[ej](){return eP(eF(this._tag))(eF(this.success))},toString(){return`success(${tr(this.success)})`},toJSON(){return{_id:"Result",_tag:this._tag,value:tl(this.success)}}}),rc=Object.assign(Object.create(ro),{_tag:"Failure",_op:"Failure",[eQ](e){return ru(e)&&rd(e)&&eZ(this.failure,e.failure)},[ej](){return eP(eF(this._tag))(eF(this.failure))},toString(){return`failure(${tr(this.failure)})`},toJSON(){return{_id:"Result",_tag:this._tag,failure:tl(this.failure)}}}),ru=e=>eT(e,ra),rd=e=>"Failure"===e._tag,rf=e=>"Success"===e._tag,rh=e=>{let t=Object.create(rc);return t.failure=e,t},rp=e=>{let t=Object.create(rl);return t.success=e,t};function rm(e){return(t,r)=>t===r?0:e(t,r)}let rg=rm((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),ry=rm((e,t)=>e<t?-1:1),rb=el(2,(e,t)=>rm((r,n)=>e(t(r),t(n)))),rv=(e=>e.getTime(),e=>el(2,(t,r)=>1===e(t,r)));function rw(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 rx=()=>ri,rk=rs,rS=rt,r_=rr,r$=rn,rO=el(2,(e,{onNone:t,onSome:r})=>r_(e)?t():r(e.value)),rI=e=>t=>r$(e(t)),rC=e=>{for(let t of e)return rk(t);return rx()},rE=e=>rd(e)?ri:rs(e.success),rA=e=>rf(e)?ri:rs(e.failure),rT=el(2,(e,t)=>r_(e)?t():e.value),rM=el(2,(e,t)=>r_(e)?t():e),rN=el(2,(e,t)=>r_(e)?rk(t()):e),rj=el(2,(e,t)=>r_(e)?rV(t(),rp):rV(e,rh)),rF=e=>{let t=rx();for(t of e)if(r$(t))break;return t},rL=e=>null==e?rx():rk(e),rP=e=>void 0===e?rx():rk(e),rD=e=>null===e?rx():rk(e),rR=e=>(...t)=>rL(e(...t)),rU=rT(eh),rB=rT(ep),rq=e=>(...t)=>{try{return rk(e(...t))}catch{return rx()}},rK=el(2,(e,t)=>{if(r$(e))return e.value;throw t()}),rz=rK(()=>Error("getOrThrow called on a None")),rV=el(2,(e,t)=>r_(e)?rx():rk(t(e.value))),rJ=el(2,(e,t)=>rV(e,()=>t)),rW=rJ(void 0),rY=rk(void 0),rG=el(2,(e,t)=>r_(e)?rx():t(e.value)),rH=el(2,(e,t)=>rG(e,e=>{let r=e_(t)?t(e):t;return rS(r)?r:rk(r)})),rQ=el(2,(e,t)=>r_(e)?rx():rL(t(e.value))),rZ=rG(ec),rX=el(2,(e,t)=>rG(e,()=>t)),r0=el(2,(e,t)=>r2(e,()=>t)),r1=el(2,(e,t)=>r=>rG(e(r),t)),r2=el(2,(e,t)=>rG(e,e=>rV(t(e),()=>e))),r3=(e,t)=>r$(e)&&r$(t)?rk([e.value,t.value]):rx(),r5=(e,t)=>{if(r_(e))return rx();let r=[e.value];for(let e of t){if(r_(e))return rx();r.push(e.value)}return rk(r)},r4=e=>{if(Symbol.iterator in e){let t=[];for(let r of e){if(r_(r))return rx();t.push(r.value)}return rk(t)}let t={};for(let r of Object.keys(e)){let n=e[r];if(r_(n))return rx();t[r]=n.value}return rk(t)},r8=el(3,(e,t,r)=>rV(r3(e,t),([e,t])=>r(e,t))),r6=el(3,(e,t,r)=>{let n=t;for(let t of e)r$(t)&&(n=r(n,t.value));return n}),r9=e=>r_(e)?[]:[e.value],r7=el(2,(e,t)=>{if(r_(e))return[rx(),rx()];let r=t(e.value);return rd(r)?[rk(r.failure),rx()]:[rx(),rk(r.success)]}),ne=el(2,(e,t)=>{if(r_(e))return rx();let r=t(e.value);return rf(r)?rk(r.success):rx()}),nt=el(2,(e,t)=>r_(e)?rx():t(e.value)?rk(e.value):rx()),nr=e=>t5((t,r)=>r_(t)?r_(r):!r_(r)&&e(t.value,r.value)),nn=e=>rm((t,r)=>r$(t)?r$(r)?e(t.value,r.value):1:-1),ni=e=>el(2,(t,r)=>r8(t,r,e)),ns=el(2,(e,t)=>t(e)?rk(e):rx()),na=e=>el(2,(t,r)=>!r_(t)&&e(t.value,r)),no=na(eZ),nl=el(2,(e,t)=>!r_(e)&&t(e.value)),nc=el(2,(e,t)=>rV(e,e=>({[t]:e}))),nu=el(3,(e,t,r)=>rV(e,e=>({...e,[t]:r(e)}))),nd=el(3,(e,t,r)=>rG(e,e=>rV(r(e),r=>({...e,[t]:r})))),nf=rk({}),nh=(...e)=>{let t=(1===e.length?e[0]:e[1].bind(e[0]))(),r=t.next();for(;!r.done;){let e=r.value;if(r_(e))return e;r=t.next(e.value)}return rk(r.value)};function np(e){return rw((t,r)=>r_(t)?r:r_(r)?t:rk(e.combine(t.value,r.value)),rx())}function nm(e){return{combine:(t,r)=>r_(t)||r_(r)?rx():rk(e.combine(t.value,r.value))}}function ng(e){let t=nm(e).combine,r=rk(e.initialValue);return rw(t,r,e=>{let n=r;for(let r of e)if(r_(n=t(n,r)))break;return n})}let ny=el(2,(e,t)=>{let r=0;for(let n of e){let e=t(n,r);if(ex(e)){if(e)return rk(n)}else if(r$(e))return e;r++}return rx()}),nb=e=>0===Object.keys(e).length,nv=el(2,(e,t)=>{let r={...e};for(let n of nx(e))r[n]=t(e[n],n);return r}),nw=el(2,(e,t)=>{let r={};for(let n of nx(e))t(e[n],n)&&(r[n]=e[n]);return r}),nx=e=>Object.keys(e),nk=el(2,(e,t)=>rd(e)?rh(t(e.failure)):rp(e.success)),nS=el(2,(e,t)=>rf(e)?rp(t(e.success)):rh(e.failure)),n_=el(2,(e,{onFailure:t,onSuccess:r})=>rd(e)?t(e.failure):r(e.success)),n$=globalThis.Array,nO=e=>n$.isArray(e)?e:n$.from(e),nI=el(2,(e,{onEmpty:t,onNonEmpty:r})=>nA(e)?r(e):t()),nC=el(2,(e,t)=>[...e,t]),nE=el(2,(e,t)=>nO(e).concat(nO(t)));n$.isArray;let nA=t4,nT=el(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),nM=el(2,(e,t)=>{let r=0;for(let n of e){if(t(n,r))return rk(r);r++}return rx()}),nN=el(2,(e,t)=>{let r=nO(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 rk(n)}else if(r$(i))return i}return rx()}),nj=el(2,(e,t)=>{let r=n$.from(e);return r.sort(t),r}),nF=el(3,(e,t,r)=>{let n=nO(e),i=nO(t);return nA(n)?nA(i)?nK(r)(nE(n,i)):n:i}),nL=el(2,(e,t)=>nF(e,t,eZ)),nP=()=>[],nD=e=>[e],nR=el(2,(e,t)=>e.map(t)),nU=el(2,(e,t)=>{let r=nO(e),n=[];for(let e=0;e<r.length;e++)t(r[e],e)&&n.push(r[e]);return n}),nB=el(2,(e,t)=>{let r=[],n=[],i=0;for(let s of e){let e=t(s,i++);rf(e)?n.push(e.success):r.push(e.failure)}return[r,n]}),nq=el(3,(e,t,r)=>nO(e).reduce((e,t,n)=>r(e,t,n),t)),nK=el(2,(e,t)=>{let r=nO(e);if(nA(r)){let e=[nT(r)];for(let n of r.slice(1))e.every(e=>!t(n,e))&&e.push(n);return e}return[]}),nz=e=>tU({op:e.label,[tm]:e.evaluate}),nV=Object.getOwnPropertyDescriptor,nJ=Object.prototype.hasOwnProperty,nW=Object.isExtensible,nY=void 0===(i=nV(Error,"stackTraceLimit"))?nW(Error):nJ.call(i,"writable")?!0===i.writable:void 0!==i.set,nG=e=>{nY&&(Error.stackTraceLimit=e)},nH="~effect/Context/Service",nQ=function(){let e=Error.stackTraceLimit;nG(2);let t=Error();nG(e);let r=function(){};return(Object.setPrototypeOf(r,nZ),Object.defineProperty(r,"stack",{get:()=>t.stack}),arguments.length>0)?(r.key=arguments[0],arguments[1]?.defaultValue&&(r[nX]=nX,r.defaultValue=arguments[1].defaultValue),r):function(e,t){return r.key=e,t?.make&&(r.make=t.make),r}},nZ={[nH]:nH,...nz({label:"Service",evaluate(e){return tK(n7(e.context,this))}}),toJSON(){return{_id:"Service",key:this.key,stack:this.stack}},of:e=>e,context(e){return n4(this,e)},use(e){return tY(t=>e(n7(t.context,this)))},useSync(e){return tY(t=>tK(e(n7(t.context,this))))}},nX="~effect/Context/Reference",n0="~effect/Context",n1=e=>{let t=Object.create(n2);return t.mapUnsafe=e,t.mutable=!1,t},n2={...tw,[n0]:{_Services:e=>e},toJSON(){return{_id:"Context",services:Array.from(this.mapUnsafe).map(([e,t])=>({key:e,value:t}))}},[eQ](e){if(!n3(e)||this.mapUnsafe.size!==e.mapUnsafe.size)return!1;for(let t of this.mapUnsafe.keys())if(!e.mapUnsafe.has(t)||!eZ(this.mapUnsafe.get(t),e.mapUnsafe.get(t)))return!1;return!0},[ej](){return eU(this.mapUnsafe.size)}},n3=e=>eT(e,n0),n5=n1(new Map),n4=(e,t)=>n1(new Map([[e.key,t]])),n8=el(3,(e,t,r)=>ia(e,e=>{e.set(t.key,r)})),n6=el(2,(e,t)=>e.mapUnsafe.get(t.key)),n9=el(2,(e,t)=>{if(!e.mapUnsafe.has(t.key)){if(nX in t)return it(t);throw ir(t)}return e.mapUnsafe.get(t.key)}),n7=n9,ie="~effect/Context/defaultValue",it=e=>ie in e?e[ie]:e[ie]=e.defaultValue(),ir=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},ii=el(2,(e,t)=>e.mapUnsafe.has(t.key)?rk(e.mapUnsafe.get(t.key)):eT(t,nX)?rk(it(t)):rx()),is=el(2,(e,t)=>0===e.mapUnsafe.size?t:0===t.mapUnsafe.size?e:ia(e,e=>{t.mapUnsafe.forEach((t,r)=>e.set(r,t))})),ia=(e,t)=>{if(e.mutable)return t(e.mapUnsafe),e;let r=new Map(e.mapUnsafe);return t(r),n1(r)},io=nQ,il="~effect/time/Duration",ic=BigInt(0),iu=BigInt(1),id=BigInt(1e3),ih=e=>BigInt(e<0?Math.ceil(e-.5):Math.floor(e+.5)),ip=(e,t)=>e.includes(".")?ih(Number(e)*Number(t)):BigInt(e)*t,im=/^(-?\d+(?:\.\d+)?)\s+(nanos?|micros?|millis?|seconds?|minutes?|hours?|days?|weeks?)$/,ig=e=>{switch(typeof e){case"number":return iC(e);case"bigint":return iI(e);case"string":{if("Infinity"===e)return i$;if("-Infinity"===e)return iO;let t=im.exec(e);if(!t)break;let[r,n,i]=t;if("nano"===i||"nanos"===i)return iI(ip(n,iu));if("micro"===i||"micros"===i)return iI(ip(n,id));let s=Number(n);switch(i){case"milli":case"millis":return iC(s);case"second":case"seconds":return iE(s);case"minute":case"minutes":return iA(s);case"hour":case"hours":return iT(s);case"day":case"days":return iM(s);case"week":case"weeks":return iN(s)}break}case"object":{if(null===e)break;if(il in e)return e;if(Array.isArray(e)){if(2!==e.length||!e.every(ew))return iy(e);if(Number.isNaN(e[0])||Number.isNaN(e[1]))return i_;if(e[0]===-1/0||e[1]===-1/0)return iO;if(e[0]===1/0||e[1]===1/0)return i$;return ik(ih(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 ik(t);return ik(ih(1e6*t+(e.microseconds??0)*1e3+(e.nanoseconds??0)))}}return iy(e)},iy=e=>{throw Error(`Invalid Input: ${e}`)},ib={_tag:"Millis",millis:0},iv={_tag:"Infinity"},iw={_tag:"NegativeInfinity"},ix={[il]:il,[ej](){return eK(this.value)},[eQ](e){return iS(e)&&iR(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"}}},[to](){return this.toJSON()},pipe(){return es(this,arguments)}},ik=e=>{let t=Object.create(ix);return"number"==typeof e?isNaN(e)||0===e||Object.is(e,-0)?t.value=ib:Number.isFinite(e)?Number.isInteger(e)?t.value={_tag:"Millis",millis:e}:t.value={_tag:"Nanos",nanos:ih(1e6*e)}:t.value=e>0?iv:iw:e===ic?t.value=ib:t.value={_tag:"Nanos",nanos:e},t},iS=e=>eT(e,il),i_=ik(0),i$=ik(1/0),iO=ik(-1/0),iI=e=>ik(e),iC=e=>ik(e),iE=e=>ik(1e3*e),iA=e=>ik(6e4*e),iT=e=>ik(36e5*e),iM=e=>ik(864e5*e),iN=e=>ik(6048e5*e),ij=e=>iL(ig(e),{onMillis:ec,onNanos:e=>Number(e)/1e6,onInfinity:()=>1/0,onNegativeInfinity:()=>-1/0}),iF=e=>{let t=ig(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 ih(1e6*t.value.millis)}},iL=el(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)()}}),iP=el(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(iF(e),t.value.nanos):r.onNanos(e.value.nanos,iF(t))),iD=(K=rm((e,t)=>iP(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})),el(2,(e,t)=>1!==K(e,t))),iR=el(2,(e,t)=>iP(e,t,{onMillis:(e,t)=>e===t,onNanos:(e,t)=>e===t,onInfinity:(e,t)=>e.value._tag===t.value._tag})),iU=el(2,(e,t)=>r=>{let n=e(r);if(rd(n))return rh(r);let i=t(n.success);return rd(i)?rh(r):i}),iB=io("effect/Scheduler",{defaultValue:()=>new iz}),iq="setImmediate"in globalThis?e=>{let t=globalThis.setImmediate(e);return()=>globalThis.clearImmediate(t)}:e=>{let t=setTimeout(e,0);return()=>clearTimeout(t)};class iK{buckets=[];scheduleTask(e,t){let r,n=this.buckets,i=n.length,s=0;for(;s<i&&!(n[s][0]>t);s++)r=n[s];r&&r[0]===t?r[1].push(e):s===i?n.push([t,[e]]):n.splice(s,0,[t,[e]])}drain(){let e=this.buckets;return this.buckets=[],e}}class iz{executionMode;setImmediate;constructor(e="async",t=iq){this.executionMode=e,this.setImmediate=t}shouldYield(e){return e.currentOpCount>=e.maxOpsBeforeYield}makeDispatcher(){return new iV(this.setImmediate)}}class iV{tasks=new iK;running=void 0;setImmediate;constructor(e=iq){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 iJ=io("effect/Scheduler/MaxOpsBeforeYield",{defaultValue:()=>2048}),iW=io("effect/Scheduler/PreventSchedulerYield",{defaultValue:()=>!1}),iY="effect/Tracer/ParentSpan";class iG extends nQ()(iY){}let iH=io("effect/Tracer/DisablePropagation",{defaultValue:ef}),iQ=io("effect/Tracer/CurrentTraceLevel",{defaultValue:()=>"Info"}),iZ=io("effect/Tracer/MinimumTraceLevel",{defaultValue:()=>"All"}),iX="effect/Tracer",i0=io(iX,{defaultValue:()=>({span:e=>new i1(e)})});class i1{_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=ei.getOrUndefined(e.parent)?.traceId??i2(32),this.spanId=i2(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 i2=(o=(s="abcdef0123456789").length,function(e){let t="";for(let r=0;r<e;r++)t+=s.charAt(Math.floor(Math.random()*o));return t}),i3=io("effect/References/CurrentConcurrency",{defaultValue:()=>"unbounded"}),i5=io("effect/ErrorReporter/CurrentErrorReporters",{defaultValue:()=>new Set}),i4=io("effect/References/CurrentStackFrame",{defaultValue:ep}),i8=io("effect/References/TracerEnabled",{defaultValue:ed}),i6=io("effect/References/TracerTimingEnabled",{defaultValue:ed}),i9=io("effect/References/TracerSpanAnnotations",{defaultValue:()=>({})}),i7=io("effect/References/TracerSpanLinks",{defaultValue:()=>[]}),se=io("effect/References/CurrentLogAnnotations",{defaultValue:()=>({})}),st=io("effect/References/CurrentLogLevel",{defaultValue:()=>"Info"}),sr=io("effect/References/MinimumLogLevel",{defaultValue:()=>"Info"}),sn=io("effect/References/CurrentLogSpans",{defaultValue:()=>[]}),si=e=>{if(e?.captureStackTrace===!1||e?.captureStackTrace!==void 0&&"boolean"!=typeof e.captureStackTrace)return e;let t=Error.stackTraceLimit;nG(3);let r=Error();return nG(t),{...e,captureStackTrace:sa(()=>r.stack)}},ss=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()}},sa=ss(3);class so extends tC{fiberId;constructor(e,t=tE){super("Interrupt",t,"Interrupted"),this.fiberId=e}toString(){return`Interrupt(${this.fiberId})`}toJSON(){return{_tag:"Interrupt",fiberId:this.fiberId}}[eQ](e){return tD(e)&&this.fiberId===e.fiberId&&this.annotations===e.annotations}[ej](){return eP(eB(`${this._tag}:${this.fiberId}`))(eL(this.annotations))}}let sl=e=>new tO([new so(e)]),sc=e=>{for(let t=0;t<e.reasons.length;t++){let r=e.reasons[t];if("Fail"===r._tag)return rp(r.error)}return rh(e)},su=e=>{let t=sc(e);return rd(t)?rx():rk(t.success)},sd=el(2,(e,t)=>{if(0===e.reasons.length)return t;if(0===t.reasons.length)return e;let r=new tO(nL(e.reasons,t.reasons));return eZ(e,r)?e:r}),sf=el(2,(e,t)=>{let r=!1,n=e.reasons.map(e=>tL(e)?(r=!0,new tA(t(e.error))):e);return r?tT(n):e}),sh=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")},sp=(e,t,r)=>{let n,i=typeof e;if(e&&"object"===i){if(n=new globalThis.Error(sm(e),{cause:e.cause?sp(e.cause):void 0}),"string"==typeof e.name&&(n.name=e.name),"string"==typeof e.stack)n.stack=sy(e.stack,n,t);else{let e=`${n.name}: ${n.message}`;n.stack=t?sb(e,t):e}for(let t of(r?.includeCauseInStack&&(n.stack=sx(n)),Object.keys(e)))t in n||(n[t]=e[t])}else n=new globalThis.Error(!e?`Unknown error: ${e}`:"string"===i?e:ta(e));return n},sm=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 ta(e)},sg=/\((.*)\)/g,sy=(e,t,r)=>{let n=`${t.name}: ${t.message}`,i=(e.startsWith(n)?e.slice(n.length):e).split("\n"),s=[n];for(let e=1;e<i.length&&!/(?:Generator\.next|~effect\/Effect)/.test(i[e]);e++)s.push(i[e]);return r?sb(s.join("\n"),r):s.join("\n")},sb=(e,t)=>{let r=t?.get(tz.key);return r&&(e=`${e}
31
+ ${sv(r)}`),e},sv=e=>{let t=[],r=e,n=0;for(;r&&n<10;){let e=r.stack();if(e){let n=e.matchAll(sg),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")},sw=e=>((e,t)=>{let r=[],n=[];if(0===e.reasons.length)return r;let i=Error.stackTraceLimit;for(let i of(nG(1),e.reasons)){if("Interrupt"===i._tag){n.push(i);continue}r.push(sp("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=((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("effect/Cause/InterruptorStackTrace");r.push(` at fiber (${t})`),n&&r.push(sv(n))}return r.join("\n")})(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(sp(i,n[0].annotations,t))}return nG(i),r})(e).map(sx).join("\n"),sx=e=>e.cause?`${e.stack} {
32
+ ${sk(e.cause," ")}
33
+ }`:e.stack,sk=(e,t)=>{let r=e.stack.split("\n"),n=`${t}[cause]: ${r[0]}`;for(let e=1,i=r.length;e<i;e++)n+=`
34
+ ${t}${r[e]}`;return e.cause&&(n+=` {
35
+ ${sk(e.cause,`${t} `)}
36
+ ${t}}`),n},sS="~effect/Fiber/dev",s_={_A:ec,_E:ec},s$={id:0},sO=()=>globalThis[te];class sI{constructor(e,t=!0){this[sS]=s_,this.setContext(e),this.id=++s$.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)}[sS];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){var t;return t=this.context,t.mapUnsafe.has(e.key)?t.mapUnsafe.get(e.key):it(e)}addObserver(e){return this._exit?(e(this._exit),ep):(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=sl(e);this.currentStackFrame&&(r=tF(r,n4(tz,this.currentStackFrame))),t&&(r=tF(r,t)),this._interruptedCause=this._interruptedCause?sd(this._interruptedCause,r):r,this.interruptible&&this.evaluate(sF(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===tv)return;let r=sC.interruptChildren&&sC.interruptChildren(this);if(void 0!==r)return this.evaluate(s8(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[te];globalThis[te]=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=s8(sR,()=>e)}if(n=this.currentTracerContext?this.currentTracerContext(n,this):n[tm](this),i!==this.currentLoopCount)return tv;if(n===tv){let e=this._yielded;if(tf in e)return this._yielded=void 0,e;return tv}}}catch(e){if(!eT(n,tm))return tW(`Fiber.runLoop: Not a valid effect: ${String(n)}`);return this.runLoop(tW(e))}finally{globalThis[te]=t}}getCont(e){for(;;){let t=this._stack.pop();if(!t)return;let r=t[tb]&&t[tb](this);if(r)return r[e]=r,r;if(t[e])return t}}yieldWith(e){return this._yielded=e,tv}children(){return this._children??=new Set}pipe(){return es(this,arguments)}setContext(e){this.context=e;let t=this.getRef(iB);t!==this.currentScheduler&&(this.currentScheduler=t,this._dispatcher=void 0),this.currentSpan=e.mapUnsafe.get(iY),this.currentLogLevel=this.getRef(st),this.minimumLogLevel=this.getRef(sr),this.currentStackFrame=e.mapUnsafe.get(i4.key),this.maxOpsBeforeYield=this.getRef(iJ),this.currentPreventYield=this.getRef(iW),this.runtimeMetrics=e.mapUnsafe.get("effect/observability/Metric/FiberRuntimeMetricsKey");let r=e.mapUnsafe.get(iX);this.currentTracerContext=r?r.context:void 0}get currentSpanLocal(){return this.currentSpan?._tag==="Span"?this.currentSpan:void 0}}let sC={interruptChildren:void 0},sE=e=>{if(!e.currentStackFrame)return;let t=new Map;return t.set(tz.key,e.currentStackFrame),n1(t)},sA=e=>sW(t=>{let r,n=e[Symbol.iterator](),i=[];return!function e(){let s=n.next();for(;!s.done;){if(s.value._exit){i.push(s.value._exit),s=n.next();continue}r=s.value.addObserver(t=>{i.push(t),e()});return}t(sj(i))}(),sL(()=>r?.())}),sT=e=>tY(t=>sM(e,t.id)),sM=el(e=>eT(e[0],sS),(e,t,r)=>tY(n=>{let i=sE(n);return i=i&&r?is(i,r):i??r,e.interruptUnsafe(t,i),s5(e._exit?sj(e._exit):sW(t=>e._exit?t(sj(e._exit)):sL(e.addObserver(e=>t(sj(e))))))})),sN=e=>tY(t=>{let r=sE(t),n=nP();for(let i of e)i.interruptUnsafe(t.id,r),n.push(i);return s5(sA(n))}),sj=tK,sF=tV,sL=tB({op:"Sync",[tm](e){let t=this[tp](),r=e.getCont(tg);return r?r[tg](t,e):e.yieldWith(tK(t))}}),sP=tB({op:"Suspend",[tm](e){return this[tp]()}}),sD=n_({onFailure:tJ,onSuccess:sj}),sR=tB({op:"Yield",[tm](e){let t=!1;return e.currentDispatcher.scheduleTask(()=>{t||e.evaluate(ai)},this[tp]??0),e.yieldWith(()=>{t=!0})}})(0),sU=sj(rx()),sB=e=>tW(e),sq=e=>sP(()=>tJ(tu(e))),sK=sj(void 0),sz=e=>{let t="function"==typeof e?e:e.try,r="function"==typeof e?e=>new oF(e,"An error occurred in Effect.try"):e.catch;return sP(()=>{try{return sj(tu(t))}catch(e){return tJ(tu(()=>r(e)))}})},sV=tB({op:"Async",single:!1,[tm](e){let t=tu(()=>this[tp][0].bind(e.currentScheduler)),r=!1,n=!1,i=this[tp][1]?new AbortController:void 0,s=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===s||e._stack.push(sJ(()=>(r=!0,i?.abort(),s??ai))),tv)}}),sJ=tB({op:"AsyncFinalizer",[tb](e){e.interruptible&&(e.interruptible=!1,e._stack.push(a3))},[ty](e,t){return e.reasons.some(tD)?s8(this[tp](),()=>sF(e)):sF(e)}}),sW=e=>sV(e,e.length>=2),sY=sW(ep),sG=(e,...t)=>{let r=0===t.length?function(){return sP(()=>s0(e.apply(this,arguments)))}:function(){let r=sP(()=>s0(e.apply(this,arguments)));for(let e=0;e<t.length;e++)r=t[e](r,...arguments);return r};return sH(e.length,r)},sH=(e,t)=>Object.defineProperty(t,"length",{value:e,configurable:!0}),sQ=ss(2),sZ=(e,t,r,n,i,s)=>{let a="function"==typeof t?t:n.pop().bind(t.self);return sH(a.length,function(...t){let o=sP(()=>{let e=a.apply(this,arguments);return tk(e)?e:s0(e)});for(let e=0;e<n.length;e++)o=n[e](o,...t);if(!tk(o))return o;let l=Error.stackTraceLimit;nG(2);let c=new globalThis.Error;return nG(l),ac(i?oy(e,s,e=>ob(o,e)):o,i4,t=>({name:e,stack:sQ(()=>c.stack),parent:{name:`${e} (definition)`,stack:sQ(()=>r.stack),parent:t}}))})},sX=e=>{try{let t,r=e();for(;;){let n=r.next(t);if(n.done)return sj(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 sP(()=>t?(t=!1,s8(n.value,e=>s0(r,e))):sP(()=>s0(e())))}}}catch(e){return sB(e)}},s0=tB({op:"Iterator",single:!1,[tg](e,t){let r=this[tp][0];for(;;){let n=r.next(e);if(n.done)return sj(n.value);if(!s9(n.value))return t._stack.push(this),n.value;if("Failure"===n.value._tag)return n.value;e=n.value.value}},[tm](e){return this[tg](this[tp][1],e)}}),s1=el(2,(e,t)=>{let r=sj(t);return s8(e,e=>r)}),s2=el(2,(e,t)=>s8(e,e=>tk(t)?t:tu(()=>t(e)))),s3=el(2,(e,t)=>s8(e,e=>s1(tk(t)?t:tu(()=>t(e)),e))),s5=e=>s8(e,e=>ai),s4=el(e=>tk(e[1]),(e,t,r)=>{let n;return n=[e,t],tY(e=>sW(t=>{let i=!1,s=new Set,a=e=>{i=!0,t(0===s.size?e:s8(a1(sN(s)),()=>e))},o=0;for(let t of n){if(i)break;let n=o++,l=on(e,t,!0,!0,!1);s.add(l),l.addObserver(t=>{s.delete(l);let o=!i;a(t),o&&r?.onWinner&&r.onWinner({fiber:l,index:n,parentFiber:e})})}return sN(s)}))}),s8=el(2,(e,t)=>{let r=Object.create(s6);return r[tp]=e,r[tg]=1!==t.length?e=>t(e):t,r}),s6=tU({op:"OnSuccess",[tm](e){return e._stack.push(this),this[tp]}}),s9=e=>tf in e,s7=el(2,(e,t)=>s9(e)?"Success"===e._tag?t(e.value):e:s8(e,t)),ae=el(2,(e,t)=>s8(e,e=>sj(tu(()=>t(e))))),at=el(2,(e,t)=>s9(e)?as(e,t):ae(e,t)),ar=el(2,(e,t)=>s9(e)?aa(e,t):a$(e,t)),an=e=>"Failure"===e._tag?rp(e.cause):rh(e),ai=tK(void 0),as=el(2,(e,t)=>"Success"===e._tag?tK(t(e.value)):e),aa=el(2,(e,t)=>{if("Success"===e._tag)return e;let r=sc(e.cause);return rd(r)?e:tJ(t(r.success))});(e,t)=>{if("Success"===e._tag)return tK(t.onSuccess(e.value));let r=sc(e.cause);return rd(r)?e:tJ(t.onFailure(r.success))};let ao=el(2,(e,t)=>"Success"===e._tag?t:e),al=el(2,(e,t)=>tY(r=>{let n=r.context,i=t(n);return n===i?e:(r.setContext(i),aG(e,()=>{r.setContext(n)}))})),ac=el(3,(e,t,r)=>al(e,e=>{let n=n9(e,t),i=r(n);return n===i?e:n8(e,t,i)})),au=e=>tY(t=>e(t.context)),ad=el(2,(e,t)=>s9(e)?e:al(e,is(t))),af=function(){return 1==arguments.length?el(2,(e,t)=>ah(e,arguments[0],t)):el(3,(e,t,r)=>ah(e,t,r)).apply(this,arguments)},ah=(e,t,r)=>al(e,e=>e.mapUnsafe.get(t.key)===r?e:n8(e,t,r)),ap=((e,t,r)=>s8(r,r=>af(e,t,r)),el(e=>tk(e[0]),(e,t)=>a9({while:ed,body:eu(t?.disableYield?e:s8(e,e=>sR)),step:ep}))),am=el(2,(e,t)=>{let r=Object.create(ag);return r[tp]=e,r[ty]=1!==t.length?e=>t(e):t,r}),ag=tU({op:"OnFailure",[tm](e){return e._stack.push(this),this[tp]}}),ay=((e,t,r)=>am(e,e=>t(e)?tu(()=>r(e)):sF(e)),el(3,(e,t,r)=>am(e,e=>{let n=t(e);return rd(n)?sF(n.failure):tu(()=>r(n.success,e))}))),ab=el(2,(e,t)=>ay(e,sc,e=>t(e))),av=el(2,(e,t)=>am(e,e=>s2(tu(()=>t(e)),sF(e)))),aw=el(3,(e,t,r)=>am(e,e=>{let n=t(e);return rd(n)?sF(e):s2(tu(()=>r(n.success,e)),sF(e))})),ax=((e,t)=>aw(e,sc,e=>t(e)),el(e=>tk(e[0]),(e,t,r,n)=>am(e,e=>{let i=sc(e);return rd(i)?sF(i.failure):t(i.success)?tu(()=>r(i.success)):n?tu(()=>n(i.success)):sF(e)}))),ak=el(e=>tk(e[0]),(e,t,r,n)=>am(e,e=>{let i=sc(e);if(rd(i))return sF(i.failure);let s=t(i.success);return rd(s)?n?tu(()=>n(s.failure)):sF(e):tu(()=>r(s.success))})),aS=el(e=>tk(e[0]),(e,t,r,n)=>ax(e,Array.isArray(t)?e=>eT(e,"_tag")&&t.includes(e._tag):eM(t),r,n)),a_=el(e=>tk(e[0]),(e,t,r)=>{let n;return ak(e,e=>(n??=Object.keys(t),eT(e,"_tag")&&ev(e._tag)&&n.includes(e._tag)?rp(e):rh(e)),e=>tu(()=>t[e._tag](e)),r)}),a$=el(2,(e,t)=>ab(e,e=>sq(()=>t(e)))),aO=((e,t)=>aA(e,{onFailure:e=>sq(()=>t.onFailure(e)),onSuccess:e=>sL(()=>t.onSuccess(e))}),el(e=>tk(e[0]),(e,t)=>{if(!t?.log)return aA(e,{onFailure:e=>sK,onSuccess:e=>sK});let r=oK(!0===t.log?void 0:t.log);return aC(e,{onFailure(e){let n,i=(n=e.reasons.find(tL))?rp(n):rh(e);return rd(i)?sF(i.failure):void 0===t.message?r(e):r(t.message,e)},onSuccess:e=>sK})})),aI=e=>aM(e,{onFailure:rh,onSuccess:rp}),aC=el(2,(e,t)=>{let r=Object.create(aE);return r[tp]=e,r[tg]=1!==t.onSuccess.length?e=>t.onSuccess(e):t.onSuccess,r[ty]=1!==t.onFailure.length?e=>t.onFailure(e):t.onFailure,r}),aE=tU({op:"OnSuccessAndFailure",[tm](e){return e._stack.push(this),this[tp]}}),aA=((e,t)=>aC(e,{onFailure:e=>sL(()=>t.onFailure(e)),onSuccess:e=>sL(()=>t.onSuccess(e))}),el(2,(e,t)=>aC(e,{onFailure:e=>{let r=e.reasons.find(tL);return r?tu(()=>t.onFailure(r.error)):sF(e)},onSuccess:t.onSuccess}))),aT=el(2,(e,t)=>aA(e,{onFailure:e=>sL(()=>t.onFailure(e)),onSuccess:e=>sL(()=>t.onSuccess(e))})),aM=el(2,(e,t)=>{if(s9(e)){if("Success"===e._tag)return tK(t.onSuccess(e.value));let r=sc(e.cause);return rd(r)?e:tK(t.onFailure(r.success))}return aT(e,t)}),aN=e=>s9(e)?tK(e):aj(e),aj=tB({op:"Exit",[tm](e){return e._stack.push(this),this[tp]},[tg]:(e,t,r)=>sj(r??tK(e)),[ty]:(e,t,r)=>sj(r??tV(e))}),aF=el(2,(e,t)=>s4(e,s8(oC(t.duration),t.orElse))),aL="~effect/Scope",aP="~effect/Scope/Closeable",aD=nQ("effect/Scope"),aR=(e,t)=>sP(()=>aU(e,t)??sK),aU=(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):aB(e,n,t)},aB=sG(function*(e,t,r){let n=[],i=[],s=Array.from(t.values()),a=sO();for(let t=s.length-1;t>=0;t--){let o=s[t];"sequential"===e.strategy?n.push((yield*aN(o(r)))):i.push(on(a,o(r),!0,!0,"inherit"))}return i.length>0&&(n=yield*sA(i)),yield*(e=>{let t=[];for(let r of e)"Failure"===r._tag&&t.push(...r.cause.reasons);return 0===t.length?ai:tV(tT(t))})(n)}),aq=(e,t)=>sP(()=>"Closed"===e.state._tag?t(e.state.exit):(aK(e,{},t),sK)),aK=(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)},az=(e,t)=>{"Open"===e.state._tag&&e.state.finalizers.delete(t)},aV=(e="sequential")=>({[aP]:aP,[aL]:aL,strategy:e,state:aJ}),aJ={_tag:"Empty"},aW=af(aD),aY=e=>sP(()=>{let t=aV();return aH(e(t),e=>sP(()=>aU(t,e)??sK))}),aG=tB({op:"OnExit",single:!1,[tm](e){return e._stack.push(this),this[tp][0]},[tb](e){e.interruptible&&!0!==this[tp][2]&&(e._stack.push(a3),e.interruptible=!1)},[tg](e,t,r){r??=tK(e);let n=this[tp][1](r);return n?s8(n,e=>r):r},[ty](e,t,r){r??=tV(e);let n=this[tp][1](r);return n?s8(n,e=>r):r}}),aH=el(2,aG),aQ=el(2,(e,t)=>aH(e,e=>t)),aZ=((e,t,r)=>aH(e,e=>t(e)?r(e):sK),el(3,(e,t,r)=>aH(e,e=>{let n=t(e);return rd(n)?sK:r(n.success,e)}))),aX=el(2,(e,t)=>aZ(e,an,t)),a0=((e,t,r)=>aH(e,e=>{if("Failure"!==e._tag)return sK;let n=t(e.cause);return rd(n)?sK:r(n.success,e.cause)}),tY(e=>sF(sl(e.id)))),a1=e=>tY(t=>(t.interruptible&&(t.interruptible=!1,t._stack.push(a3)),e)),a2=tB({op:"SetInterruptible",[tb](e){if(e.interruptible=this[tp],e._interruptedCause&&e.interruptible)return()=>sF(e._interruptedCause)}}),a3=a2(!0),a5=a2(!1),a4=e=>tY(t=>t.interruptible?e:(t.interruptible=!0,t._stack.push(a5),t._interruptedCause)?sF(t._interruptedCause):e),a8=e=>tY(t=>t.interruptible?(t.interruptible=!1,t._stack.push(a3),e(a4)):e(ec)),a6=(e,t)=>eN(e)?t?.mode==="result"?a7(e,aI,t):a7(e,ec,t):t?.discard?"result"===t.mode?a7(Object.values(e),aI,t):a7(Object.values(e),ec,t):sP(()=>{let r={};return s1(a7(Object.entries(e),([e,n])=>ae(t?.mode==="result"?aI(n):n,t=>{r[e]=t}),{discard:!0,concurrency:t?.concurrency}),r)}),a9=((e=>eN(e[0])&&!tk(e[0]),(e,t,r)=>ae(a7(e,(e,r)=>aI(t(e,r)),r),e=>nB(e,ec))),tB({op:"While",[tg](e,t){return(this[tp].step(e),this[tp].while())?(t._stack.push(this),this[tp].body()):ai},[tm](e){return this[tp].while()?(e._stack.push(this),this[tp].body()):ai}})),a7=el(e=>"function"==typeof e[1],(e,t,r)=>tY(n=>{let i=r?.concurrency==="inherit"?n.getRef(i3):r?.concurrency??1,s="unbounded"===i?1/0:Math.max(1,i);if(1===s)return oe(e,t,r);let a=nO(e),o=a.length;if(0===o)return r?.discard?sK:sj([]);let l=r?.discard?void 0:Array(o),c=or({f:t,out:l},a,{concurrency:s});return c?s1(c,l):sj(l)})),oe=(e,t,r)=>sP(()=>{let n=r?.discard?void 0:[],i=e[Symbol.iterator](),s=i.next(),a=0;return s1(a9({while:()=>!s.done,body:()=>t(s.value,a++),step:e=>{n&&n.push(e),s=i.next()}}),n)}),ot=e=>{let t=e.onItem,r=e.step;return(e,n,i)=>{let s,a,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,s)=>{if(!h)return r(e,t,i,s);if(l)return l;for(y[s]=i;g<d;){let t=y[g];if(void 0===t)return;y[g]=void 0;let i=g++,s=r(e,n[i],t,i);if(s)return s}},v=()=>{let r=!1;for(;!l&&u<d;u++){let i=n[u],d=c??t(e,i,u);if(s9(d)){if(l=b(i,d,u))break}else{if(1===f)return s8(aN(d),e=>(l=b(i,e,u),u++,l??v()??sK));if(!s)return sW(e=>{s=sO(),c=d,o=e;let t=v();return t?e(t):sP(()=>(l=ai,m=!0,a?sN(a):sK))});c=void 0;let e=on(s,d,!0,!0,"inherit");if(e._exit){if(l=b(i,e._exit,u))break;continue}a?a.add(e):a=new Set([e]);let t=u;if(e.addObserver(n=>{if(a.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=tV(tT([e]))}else{let e=b(i,n,t);e&&(l="Failure"===e._tag?tV(tT(e.cause.reasons.slice())):e,v())}if(r){let e=v();e&&o(e)}else p&&0===a.size&&o(l??sK)}),a.size<f)continue;r=!0,u++;return}}if(p=!0,l){if(a&&a.size>0){let e=sE(s);a.forEach(t=>t.interruptUnsafe(s.id,e));return}if(o||"Failure"===l._tag)return l}else if(o)if(!a)return ai;else 0===a.size&&o(sK)};return v()}},or=ot({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)}}),on=((e,t,r)=>s8(e,e=>t(e)?sj(e):r(e)),(e,t,r=!1,n=!1,i=!1)=>{let s="inherit"===i?e.interruptible:!i,a=new sI(e.context,s);return r?a.evaluate(t):e.currentDispatcher.scheduleTask(()=>a.evaluate(t),0),n||a._exit||(e.children().add(a),a.addObserver(()=>e._children.delete(a))),a}),oi=el(e=>tk(e[0]),(e,t,r)=>tY(n=>{let i=on(n,e,r?.startImmediately,!0,r?.uninterruptible);if(!i._exit)if("Closed"!==t.state._tag){let e={};aK(t,e,()=>{let e;return e=e=>e===i.id?sK:sT(i),tY(t=>e(t.id))}),i.addObserver(()=>az(t,e))}else i.interruptUnsafe(n.id,sE(n));return sj(i)})),os=el(e=>tk(e[0]),(e,t)=>s8(aD,r=>oi(e,r,t))),oa=e=>(t,r)=>{let n=new sI(r?.scheduler?n8(e,iB,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},oo=el(2,(e,t)=>{if(e._exit)return e;if("Closed"===t.state._tag)return e.interruptUnsafe(e.id),e;let r={};return aK(t,r,()=>sT(e)),e.addObserver(()=>az(t,r)),e}),ol=oa(n5),oc=(z=oa(n5),e=>{if(s9(e))return e;let t=z(e,{scheduler:new iz("sync")});return t.currentDispatcher?.flush(),t._exit??tW(new oN(t))}),ou=sj(!0),od=sj(!1);class of{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)),ou}flushWaiters=()=>{this.scheduled=!1;let e=this.waiters;this.waiters=[];for(let t=0;t<e.length;t++)e[t](ai)};open=tY(e=>this._isOpen?od:(this._isOpen=!0,this.scheduleUnsafe(e)));release=tY(e=>this._isOpen?od:this.scheduleUnsafe(e));openUnsafe(){return!this._isOpen&&(this._isOpen=!0,this.flushWaiters(),!0)}await=sW(e=>this._isOpen?e(sK):(this.waiters.push(e),sL(()=>{let t=this.waiters.indexOf(e);-1!==t&&this.waiters.splice(t,1)})));closeUnsafe(){return!!this._isOpen&&(this._isOpen=!1,!0)}close=sL(()=>this.closeUnsafe());whenOpen=e=>s8(this.await,()=>e);isOpen(){return this._isOpen}}let oh=e=>new of(e??!1),op=BigInt(0),om={_tag:"Span",spanId:"noop",traceId:"noop",sampled:!1,status:{_tag:"Ended",startTime:op,endTime:op,exit:ai},attributes:new Map,links:[],kind:"internal",attribute(){},event(){},end(){},addLinks(){}},og=e=>e?n7(e.annotations,iH)?"Span"===e._tag?og(rB(e.parent)):rx():rk(e):rx(),oy=(e,...t)=>{let r=1===t.length?void 0:t[0],n=t[t.length-1];return tY(t=>{let i=((e,t,r)=>{let n,i=!e.getRef(i8)||r?.annotations&&n7(r.annotations,iH),s=r?.parent!==void 0?rk(r.parent):r?.root?rx():og(e.currentSpan);if(i){let e;e={name:t,parent:s,annotations:n8(r?.annotations??n5,iH,!0)},n=Object.assign(Object.create(om),e)}else{let i=e.getRef(i0),a=e.getRef(ok),o=e.getRef(i6),l=e.getRef(i9),c=e.getRef(i7),u=r?.level??e.getRef(iQ),d=r?.links!==void 0?[...c,...r.links]:c.slice();for(let[c,f]of(n=i.span({name:t,parent:s,annotations:r?.annotations??n5,links:d,startTime:o?a.currentTimeNanosUnsafe():BigInt(0),kind:r?.kind??"internal",root:r?.root??r_(s),sampled:r?.sampled??((!r$(s)||!1!==s.value.sampled)&&!oP(e.getRef(iZ),u))}),Object.entries(l)))n.attribute(c,f);if(r?.attributes!==void 0)for(let[e,t]of Object.entries(r.attributes))n.attribute(e,t)}return n})(t,e,r),s=t.getRef(ok);return aH(tu(()=>n(i)),e=>sL(()=>{"Ended"!==i.status._tag&&i.end(s.currentTimeNanosUnsafe(),e)}))})},ob=af(iG),ov=function(){let e=tk(arguments[0]),t=e?arguments[1]:arguments[0],r=e?arguments[2]:arguments[1],n=ec;if("Span"===t._tag){var i,s;r=si(r),i=t.name,s="function"==typeof(s=r?.captureStackTrace)?s:ep,n=ac(i4,e=>({name:i,stack:s,parent:e}))}return e?ob(n(arguments[0]),t):e=>ob(n(e),t)},ow=el(e=>tk(e[0]),(e,...t)=>ac(e,i9,e=>{let r={...e};return 1===t.length?Object.assign(r,t[0]):r[t[0]]=t[1],r})),ox=tY(e=>{let t=e.currentSpanLocal;return t?sj(t):tJ(new tX)}),ok=io("effect/Clock",{defaultValue:()=>new o_}),oS=0x80000000-1;class o_{currentTimeMillisUnsafe(){return Date.now()}currentTimeMillis=sL(()=>this.currentTimeMillisUnsafe());currentTimeNanosUnsafe(){return oO()}currentTimeNanos=sL(()=>this.currentTimeNanosUnsafe());sleep(e){return this.sleepMillis(ij(e))}sleepMillis(e){return e<=0?sR:Number.isFinite(e)?sW(t=>{let r=e>oS?this.sleepMillis(e-oS):sK,n=setTimeout(()=>t(r),Math.min(e,oS));return sL(()=>clearTimeout(n))}):sY}}let o$=(c=BigInt(1e6),"u"<typeof performance||void 0===performance.now?()=>BigInt(Date.now())*c:()=>(l??=BigInt(Date.now())*c-BigInt(Math.round(1e6*performance.now())))+BigInt(Math.round(1e6*performance.now()))),oO=function(){let e="object"==typeof process&&"hrtime"in process&&"function"==typeof process.hrtime.bigint?process.hrtime:void 0;if(!e)return o$;let t=BigInt(Date.now())*BigInt(1e6)-e.bigint();return()=>t+e.bigint()}(),oI=e=>tY(t=>e(t.getRef(ok))),oC=e=>oI(t=>t.sleep(ig(e))),oE=oI(e=>e.currentTimeMillis),oA="~effect/Cause/IllegalArgumentError";class oT extends tQ("IllegalArgumentError"){[oA]=oA;constructor(e){super({message:e})}}let oM="~effect/Cause/AsyncFiberError";class oN extends tQ("AsyncFiberError"){[oM]=oM;constructor(e){super({message:"An asynchronous Effect was executed with Effect.runSync",fiber:e})}}let oj="~effect/Cause/UnknownError";class oF extends tQ("UnknownError"){[oj]=oj;constructor(e,t){super({message:t,cause:e})}}let oL=io("effect/Console/CurrentConsole",{defaultValue:()=>globalThis.console}),oP=rv(rb(rg,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}})),oD=io("effect/Loggers/CurrentLoggers",{defaultValue:()=>new Set([oz,oV])}),oR=io("effect/Logger/LogToStderr",{defaultValue:ef}),oU={"~effect/Logger":{_Message:ec,_Output:ec},pipe(){return es(this,arguments)}},oB=e=>{let t=Object.create(oU);return t.log=e,t},oq=(e,t)=>{let r=e[0].replace(/[\s="]/g,"_");return`${r}=${t-e[1]}ms`},oK=e=>(...t)=>{let r;for(let e=0,n=t.length;e<n;e++){let n=t[e];t$(n)&&(r?t.splice(e,1):t=t.slice(0,e).concat(t.slice(e+1)),r=r?tT(r.reasons.concat(n.reasons)):n,e--)}return void 0===r&&(r=tM),tY(n=>{let i=e??n.currentLogLevel;if(oP(n.minimumLogLevel,i))return sK;let s=n.getRef(ok),a=n.getRef(oD);if(a.size>0){let e=new Date(s.currentTimeMillisUnsafe());for(let s of a)s.log({cause:r,fiber:n,date:e,logLevel:i,message:t})}return sK})},oz=oB(({cause:e,date:t,fiber:r,logLevel:n,message:i})=>{let s=Array.isArray(i)?i.slice():[i];e.reasons.length>0&&s.push(sw(e));let a=t.getTime(),o=r.getRef(sn),l="";for(let e of o)l+=` ${oq(e,a)}`;let c=r.getRef(se);Object.keys(c).length>0&&s.push(c);let u=r.getRef(oL);(r.getRef(oR)?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}:`,...s)}),oV=oB(({cause:e,fiber:t,logLevel:r,message:n})=>{let i=t.getRef(ok),s=t.getRef(se),a=t.currentSpan;if(void 0===a||"ExternalSpan"===a._tag)return;let o={};for(let[e,t]of Object.entries(s))o[e]=t;o["effect.fiberId"]=t.id,o["effect.logLevel"]=r.toUpperCase(),e.reasons.length>0&&(o["effect.cause"]=sw(e)),a.event(((e,t=2)=>{if("string"==typeof e)return e;try{return"object"==typeof e?ta(e,{space:t}):String(e)}catch{return String(e)}})(Array.isArray(n)&&1===n.length?n[0]:n),i.currentTimeNanosUnsafe(),o)}),oJ=e=>e.reasons.length>0&&e.reasons.every(tD),oW=e=>void 0===e?t3:tJ(t2(e)),oY=el(2,(e,t)=>ay(e,oQ,e=>t(e))),oG=e=>"Fail"===e._tag&&eT(e.error,t0),oH=iU(sc,e=>eT(e,t0)?rp(e):rh(e)),oQ=iU(sc,e=>eT(e,t0)?rp(e.value):rh(e)),oZ=e=>{let t=oH(e);return rd(t)?tV(t.failure):tK(t.success.value)},oX=el(2,(e,t)=>aC(e,{onSuccess:t.onSuccess,onFailure:e=>{let r=oH(e);return rd(r)?t.onFailure(r.failure):t.onDone(r.success.value)}})),o0="~effect/Schedule",o1=io("effect/Schedule/CurrentMetadata",{defaultValue:eu({input:void 0,output:void 0,duration:i_,attempt:0,start:0,now:0,elapsed:0,elapsedSincePrevious:0})}),o2={[o0]:{_Out:ec,_In:ec,_Env:ec},pipe(){return es(this,arguments)}},o3=e=>{let t=Object.create(o2);return t.step=e,t},o5=()=>{let e,t,r=0;return(n,i)=>{void 0===t&&(t=n);let s=n-t,a=void 0===e?0:n-e;return e=n,{input:i,attempt:++r,start:t,now:n,elapsed:s,elapsedSincePrevious:a}}},o4=e=>am(e.step,e=>sj(()=>sF(e))),o8=e=>oI(t=>ae(o4(e),e=>{let r=o5();return n=>sP(()=>{let i=t.currentTimeMillisUnsafe();return s8(e(i,n),([e,t])=>{let s=r(i,n);return s.output=e,s.duration=t,s1(oC(t),s)})})})),o6=e=>o3(ae(o4(e),e=>(t,r)=>oX(e(t,r),{onSuccess:e=>sj([r,e[1]]),onFailure:sF,onDone:()=>oW(r)}))),o9=e=>{let t=ig(e);return o3(ae(sj(e=>sj([e.attempt-1,t])),e=>{let t=o5();return(r,n)=>e(t(r,n))}))},o7=el(2,(e,t)=>{let r=void 0===t.duration?void 0:ig(t.duration);return le(e,({attempt:e,elapsed:n})=>sj((void 0===t.times||e<=t.times)&&(void 0===r||iD(iC(n),r))))}),le=el(2,(e,t)=>o3(ae(o4(e),e=>{let r=o5();return(n,i)=>s8(e(n,i),e=>{let[s,a]=e,o=t({...r(n,i),output:s,duration:a});return s8(tk(o)?o:sj(o),t=>t?sj(e):oW(s))})}))),lt=o9(i_),lr={"~effect/Deferred":{_A:ec,_E:ec},pipe(){return es(this,arguments)}},ln=()=>{let e=Object.create(lr);return e.resumes=void 0,e.effect=void 0,e},li=e=>sW(t=>e.effect?t(e.effect):(e.resumes??=[],e.resumes.push(t),sL(()=>{let r=e.resumes.indexOf(t);e.resumes.splice(r,1)}))),ls=el(2,(e,t)=>sL(()=>ll(e,t))),la=e=>sL(()=>lo(e)),lo=e=>void 0!==e.effect,ll=(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},lc=(e,t)=>{let r=aV(t);if("Closed"===e.state._tag)return r.state=e.state,r;let n={};return aK(e,n,e=>aR(r,e)),aK(r,n,t=>sL(()=>az(e,n))),r},lu="~effect/Layer/MemoMap",ld={"~effect/Layer":{_ROut:ec,_E:ec,_RIn:ec},pipe(){return es(this,arguments)}},lf=e=>{let t=Object.create(ld);return t.build=e,t},lh=e=>lf((t,r)=>{let n=lc(r);return aH(e(t,n),e=>"Failure"===e._tag?aR(n,e):sK)});class lp{get[lu](){return lu}parent;constructor(e){this.parent=e}map=new Map;get(e,t){let r=this.map.get(e);if(r)return r.observers++,s2(aq(t,e=>r.finalizer(e)),r.effect);return this.parent?.get(e,t)}getOrElseMemoize(e,t,r){var n;let i,s,a,o=this.get(e,t);return o?o:(n=this,i=aV(),a={observers:1,effect:li(s=ln()),finalizer:t=>sP(()=>(a.observers--,0===a.observers)?(n.map.delete(e),aR(i,t)):sK)},n.map.set(e,a),aq(t,a.finalizer).pipe(s8(()=>r(n,i)),aH(e=>(a.effect=e,ls(s,e)))))}}let lm=()=>new lp;class lg extends nQ()("effect/Layer/CurrentMemoMap"){static forkOrCreate(e){let t=n6(e,lg);return t?new lp(t):lm()}}let ly=el(3,(e,t,r)=>af(ae(e.build(t,r),n8(lg,t)),lg,t)),lb=el(2,(e,t)=>tY(r=>ly(e,lg.forkOrCreate(r.context),t))),lv=function(){return 1==arguments.length?e=>lw(n4(arguments[0],e)):lw(n4(arguments[0],arguments[1]))},lw=e=>lf(eu(sj(e))),lx=function(){return 1==arguments.length?e=>lk(arguments[0],e):lk(arguments[0],arguments[1])},lk=(e,t)=>lS(ae(t,t=>n4(e,t))),lS=e=>{var t;let r;return t=(t,r)=>aW(e,r),r=lh((e,n)=>e.getOrElseMemoize(r,n,t))},l_=(e,t,r)=>{let n=lc(r,"parallel");return a7(e,e=>e.build(t,lc(n,"sequential")),{concurrency:e.length}).pipe(ae(e=>((...e)=>{let t=new Map;for(let r=0;r<e.length;r++)e[r].mapUnsafe.forEach((e,r)=>{t.set(r,e)});return n1(t)})(...e)))},l$=(...e)=>lh((t,r)=>l_(e,t,r)),lO=(e,t,r)=>lh((n,i)=>s8(Array.isArray(t)?l_(t,n,i):t.build(n,i),t=>e.build(n,i).pipe(ad(t),ae(e=>r(e,t))))),lI=el(2,(e,t)=>lO(e,t,ec)),lC=el(2,(e,t)=>lO(e,t,(e,t)=>is(t,e))),lE=el(e=>tk(e[0]),(e,t,r)=>{let n;return n3(t)?ad(e,t):(n=Array.isArray(t)?l$(...t):t,aY(t=>s8(r?.local?ly(n,lm(),t):lb(n,t),t=>ad(e,t))))}),lA=((e,t,r)=>s8(o8(t),t=>{let n=o1.defaultValue();return ab(ap(s3(s8(sP(()=>af(e,o1,n)),t),e=>sL(()=>{n=e})),{disableYield:!0}),e=>eT(e,t0)?sj(e.value):r(e,0===n.attempt?rx():rk(n)))}),el(3,(e,t,r)=>s8(o8(t),t=>{let n,i=o1.defaultValue(),s=ab(sP(()=>af(e,o1,i)),e=>(n=e,s8(t(e),e=>(i=e,s))));return oY(s,e=>tu(()=>r(n,e)))}))),lT=el(2,(e,t)=>lA(e,"function"==typeof t?t(ec):eT(t,o0)?t:lN(t),tJ)),lM=o6(lt),lN=e=>{let t=e.schedule?o6(e.schedule):lM;return e.while&&(t=le(t,({input:t})=>{let r=e.while(t);return tk(r)?r:sj(r)})),e.until&&(t=le(t,({input:t})=>{let r=e.until(t);return tk(r)?ae(r,e=>!e):sj(!r)})),void 0!==e.times&&(t=le(t,({attempt:t})=>sj(t<=e.times))),t},lj=le(lt,({attempt:e})=>sj(e<=1)),lF=(X={_E:e=>e,_A:e=>e,_R:e=>e},eb.add(X),X);({...{[ej](){return eq(this,Object.keys(this))},[eQ](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]||!eZ(this[t[n]],e[t[n]]))return!1;return!0}},"~effect/Request":lF});let lL=e=>{let t="function"==typeof e?e:e.try,r="function"==typeof e?e=>new oF(e,"An error occurred in Effect.tryPromise"):e.catch;return sV(function(e,n){let i=t=>{try{e(tJ(tu(()=>r(t))))}catch(t){e(sB(t))}};try{tu(()=>t(n)).then(t=>e(sj(t)),i)}catch(e){i(e)}},0!==t.length)},lP=sj,lD=(...e)=>sP(()=>s0(1===e.length?e[0]():e[1].call(e[0].self))),lR=e=>sP(()=>sF(tu(e))),lU=e=>aT(e,{onFailure:rx,onSuccess:rk}),lB=e=>ab(e,sB),lq=e=>tY(t=>{let r=t.context,n=aV();return t.setContext(n8(t.context,aD,n)),aG(e,e=>(t.setContext(r),aU(n,e)))}),lK=(e,t,r)=>au(n=>a8(i=>s8(aD,s=>s3(r?.interruptible?i(e):e,e=>aq(s,r=>ad(t(e,r),n)))))),lz=(e,t,r)=>a8(n=>s8(e,e=>aG(n(t(e)),t=>r(e,t),!0))),lV=function(){let e="string"!=typeof arguments[0],t=e?arguments[1]:arguments[0],r=si(arguments[2]);if(e){let e=arguments[0];return oy(t,arguments[2],t=>ov(e,t,r))}let n="function"==typeof arguments[1]?arguments[1]:void 0,i=n?void 0:arguments[1];return(e,...s)=>oy(t,n?n(...s):i,t=>ov(e,t,r))},lJ=function(){let e="string"==typeof arguments[0],t=e?arguments[0]:"Effect.fn",r=e?arguments[1]:void 0,n=Error.stackTraceLimit;nG(2);let i=new globalThis.Error;return(nG(n),e)?(n,...s)=>sZ(t,n,i,s,e,r):sZ(t,arguments[0],i,Array.prototype.slice.call(arguments,1),e,r)},lW=oK("Error"),lY=el(e=>tk(e[0]),(e,...t)=>ac(e,se,e=>{let r={...e};return 1===t.length?Object.assign(r,t[0]):r[t[0]]=t[1],r})),lG=(e,t,r)=>(...n)=>sW(i=>{try{e(...n,(e,r)=>{e?i(tJ(t?t(e,n):e)):i(lP(r))})}catch(e){i(r?tJ(r(e,n)):sB(e))}}),lH=(e,...t)=>sH(e.length,0===t.length?function(){return sX(()=>e.apply(this,arguments))}:function(){let r=sX(()=>e.apply(this,arguments));for(let e of t)r=e(r);return r}),lQ=(e,t)=>t("Success"===e._tag?0:oJ(e.cause)?130:lX(sh(e.cause))),lZ="~effect/Runtime/errorExitCode",lX=e=>{if("object"==typeof e&&null!==e&&lZ in e){let t=e[lZ];if("number"==typeof t)return t}return 1},l0="~effect/Runtime/errorReported",l1=(u=({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)},el(e=>tk(e[0]),(e,t)=>{let r=ol(t?.disableErrorReporting===!0?e:av(e,e=>oJ(e)?sK:(e=>{if("object"==typeof e&&null!==e&&l0 in e){let t=e[l0];if("boolean"==typeof t)return t}return!0})(sh(e))?lW(e):sK));try{let e=globalThis.setInterval(ep,0x7fffffff);r.addObserver(()=>{clearInterval(e)})}catch{}return u({fiber:r,teardown:t?.teardown??lQ})}));function l2(){return Object.assign(e=>e,{option:e=>rk(e),result:e=>rp(e),is:e=>!0})}let l3=class extends eo{constructor(e){super(),e&&Object.assign(this,e)}};function l5(){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 l4=tH,l8=tQ,l6="~effect/platform/PlatformError";class l9 extends l8("BadArgument"){get message(){return`${this.module}.${this.method}${this.description?`: ${this.description}`:""}`}}class l7 extends l4{get message(){return`${this._tag}: ${this.module}.${this.method}${void 0!==this.pathOrDescriptor?` (${this.pathOrDescriptor})`:""}${this.description?`: ${this.description}`:""}`}}class ce extends l8("PlatformError"){constructor(e){"cause"in e?super({reason:e,cause:e.cause}):super({reason:e})}[l6]=l6;get message(){return this.reason.message}}let ct=e=>new ce(new l7(e)),cr=e=>new ce(new l9(e)),cn=Symbol.for("effect/MutableList/Empty"),ci=()=>({array:[],mutable:!0,offset:0,next:void 0}),cs=(e,t)=>{e.tail?e.tail.mutable||(e.tail.next=ci(),e.tail=e.tail.next):e.head=e.tail=ci(),e.tail.array.push(t),e.length++},ca=e=>{e.head=e.tail=void 0,e.length=0},co=e=>{if(!e.head)return cn;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:ca(e)),t},cl={_A:ec,_E:ec},cc={"~effect/Queue":cl,"~effect/Queue/Enqueue":cl,"~effect/Queue/Dequeue":cl,...tw,toJSON(){return{_id:"effect/Queue",state:this.state._tag,size:cx(this)}}},cu=e=>tY(t=>{let r=Object.create(cc);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},sj(r)}),cd=(e,t)=>sP(()=>{if("Open"!==e.state._tag)return ck;if(e.messages.length>=e.capacity)switch(e.strategy){case"dropping":return ck;case"suspend":if(e.capacity<=0&&e.state.takers.size>0)return cs(e.messages,t),cO(e),cS;return cE(e,t);case"sliding":return co(e.messages),cs(e.messages,t),cS}return cs(e.messages,t),cI(e),cS}),cf=(e,t)=>"Open"===e.state._tag&&(e.messages.length>=e.capacity?"sliding"===e.strategy?(co(e.messages),cs(e.messages,t),!0):e.capacity<=0&&e.state.takers.size>0&&(cs(e.messages,t),cO(e),!0):(cs(e.messages,t),cI(e),!0)),ch=el(2,(e,t)=>sL(()=>cp(e,t))),cp=(e,t)=>{if("Open"!==e.state._tag)return!1;let r=ao(tV(t),c_);return 0===e.state.offers.size&&0===e.messages.length?cM(e,r):e.state={...e.state,_tag:"Closing",exit:r},!0},cm=e=>cp(e,tN(t2())),cg=e=>sL(()=>{if("Done"===e.state._tag)return!0;ca(e.messages);let t=e.state.offers;if(cM(e,"Open"===e.state._tag?c$:e.state.exit),t.size>0){for(let e of t)"Single"===e._tag?e.resume(ck):e.resume(tK(e.remaining.slice(e.offset)));t.clear()}return!0}),cy=e=>cb(e,1,1/0),cb=(e,t,r)=>sP(()=>cC(e,t,r)??s2(cT(e),cb(e,1,r))),cv=e=>sP(()=>cw(e)??s2(cT(e),cv(e))),cw=e=>{if("Done"===e.state._tag)return e.state.exit;if(e.messages.length>0){let t=co(e.messages);return cA(e),tK(t)}if(e.capacity<=0&&e.state.offers.size>0){e.capacity=1,cA(e),e.capacity=0;let t=co(e.messages);return cA(e),tK(t)}},cx=e=>"Done"===e.state._tag?0:e.messages.length,ck=tK(!1),cS=tK(!0),c_=tJ(t2()),c$=tV(sl(void 0)),cO=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(ai),0===e.messages.length)break}},cI=e=>{e.scheduleRunning||"Done"===e.state._tag||0===e.state.takers.size||(e.scheduleRunning=!0,e.dispatcher.scheduleTask(()=>cO(e),0))},cC=(e,t,r)=>{if("Done"===e.state._tag)return e.state.exit;if(r<=0||t<=0)return tK([]);if(e.capacity<=0&&e.state.offers.size>0){e.capacity=1,cA(e),e.capacity=0;let t=[co(e.messages)];return cA(e),tK(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 ca(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&&ca(e),r;i=i.next}return ca(e),r})(e.messages,r);return cA(e),tK(t)}},cE=(e,t)=>sW(r=>{if("Open"!==e.state._tag)return r(ck);let n={_tag:"Single",message:t,resume:r};return e.state.offers.add(n),sL(()=>{"Open"===e.state._tag&&e.state.offers.delete(n)})}),cA=e=>{if("Done"===e.state._tag)return e.state.exit.cause.reasons.some(oG);if(0===e.state.offers.size)return"Closing"===e.state._tag&&0===e.messages.length&&(cM(e,e.state.exit),e.state.exit.cause.reasons.some(oG));let t=e.capacity-e.messages.length;for(let r of e.state.offers)if(0===t)break;else if("Single"===r._tag)cs(e.messages,r.message),t--,r.resume(cS),e.state.offers.delete(r);else{for(;r.offset<r.remaining.length;r.offset++){if(0===t)return!1;cs(e.messages,r.remaining[r.offset]),t--}r.resume(tK([])),e.state.offers.delete(r)}return!1},cT=e=>sW(t=>"Done"===e.state._tag?t(e.state.exit):(e.state.takers.add(t),sL(()=>{"Done"!==e.state._tag&&e.state.takers.delete(t)}))),cM=(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()},cN="~effect/Channel",cj={[cN]:{_Env:ec,_InErr:ec,_InElem:ec,_OutErr:ec,_OutElem:ec},pipe(){return es(this,arguments)}},cF=e=>{let t=Object.create(cj);return t.transform=(t,r)=>am(e(t,r),e=>lP(sF(e))),t},cL=(e,t)=>cF((r,n)=>s8(cD(e)(r,n),e=>t(e,n))),cP=e=>cF((t,r)=>e),cD=e=>e.transform,cR=cP(lP(oW())),cU=el(2,(e,t)=>cL(e,e=>sL(()=>{let r=0;return ae(e,e=>t(e,r++))}))),cB=el(2,(e,t)=>cq(e,e=>lP(t(e)))),cq=el(2,(e,t)=>cL(e,e=>lP(oY(e,e=>s8(t(e),oW))))),cK=el(e=>eT(e[0],cN)&&eT(e[1],cN),(e,t,r)=>{let n;return n=sG(function*(n,i,s){let a=r?.haltStrategy??"both",o=yield*cu({capacity:0});yield*aq(s,eu(cg(o)));let l=0,c=(e,t,r)=>cD(t)(n,r).pipe(s8(e=>e.pipe(s8(e=>cd(o,e)),ap)),aX(t=>s2(aR(r,oZ(t)),function(e,t){if(l++,!t.reasons.some(oG))return ch(o,t);switch(a){case"both":return 2===l?ch(o,t):sK;case"left":case"right":return e===a?ch(o,t):sK;case"either":return ch(o,t)}}(e,t))),oi(s));return yield*c("left",e,lc(s)),yield*c("right",t,lc(s)),cv(o)}),cF(sG(function*(e,t){let r=lc(t),i=e=>aR(r,oZ(e)),s=yield*aX(n(e,t,r),i);return aX(s,i)}))}),cz=el(2,(e,t)=>cF((r,n)=>s8(cD(e)(r,n),e=>cD(t)(e,n)))),cV=e=>cF((t,r)=>{let n;return lP(sP(()=>n||e.pipe(aW(r),s8(e=>cD(e)(t,r)),s8(e=>n=e))))}),cJ=(e,t,r)=>sP(()=>{let n=aV();return oY(s8(cD(e)(oW(),n),t),r||lP).pipe(aH(e=>aR(n,e)))}),cW=el(2,(e,t)=>cJ(e,e=>ap(s8(e,t),{disableYield:!0}))),cY=el(3,(e,t,r)=>sP(()=>{let n=t();return cJ(e,e=>a9({while:ed,body:()=>e,step:e=>{n=r(n,e)}}),()=>lP(n))})),cG=(e,t)=>cD(e)(oW(),t),cH="~effect/Sink",cQ=lP([void 0]),cZ={[cH]:{_A:ec,_In:ec,_L:ec,_E:ec,_R:ec},pipe(){return es(this,arguments)}},cX=e=>c0((t,r)=>cD(e)(t,r).pipe(s8(ap({disableYield:!0})),oY(lP))),c0=e=>{let t=Object.create(cZ);return t.transform=e,t},c1=e=>cF((t,r)=>lP(s8(e.transform(t,r),oW))),c2=c0(e=>oY(ap(e,{disableYield:!0}),()=>cQ)),c3=e=>cX(cV(ae(e,c1))),c5={"~effect/Stream":{_R:ec,_E:ec,_A:ec},pipe(){return es(this,arguments)}},c4=e=>{let t=Object.create(c5);return t.channel=e,t},c8=e=>e.channel,c6=c4(cR),c9=e=>{let t;return c4((t=()=>e().channel,cF((e,r)=>sP(()=>cD(t())(e,r)))))},c7=e=>{let t;return nA(e)?c4((t=lP(e),cP(sL(()=>{let e=!1;return sP(()=>e?oW():(e=!0,t))})))):c6},ue=e=>c4(cV(ae(e,c8))),ut=el(2,(e,t)=>c9(()=>{let r=0;return c4(cU(e.channel,nR(e=>t(e,r++))))})),ur=el(e=>eT(e[0],"~effect/Stream")&&eT(e[1],"~effect/Stream"),(e,t,r)=>c4(cK(c8(e),c8(t),r))),un=el(2,(e,t)=>{let r;return r=(e,r)=>sL(()=>{let n,i,s=sP(()=>{if(void 0!==i){let e=i;return i=void 0,lP(e)}return e}).pipe(ab(e=>(n=tJ(e),oW()))),a=ae(sP(()=>t.transform(s,r)),([e,t])=>(i=t,nD(e)));return sP(()=>n||a)}),c4(cF((t,n)=>s8(cG(e.channel,n),e=>r(e,n))))}),ui=el(e=>eT(e[0],"~effect/Stream"),(e,t)=>c9(()=>{let r=new TextDecoder(t?.encoding);return ut(e,e=>r.decode(e,{stream:!0}))})),us=el(2,(e,t)=>aY(r=>cG(e.channel,r).pipe(s8(e=>t.transform(e,r)),ae(([e])=>e)))),ua=e=>cY(e.channel,()=>[],(e,t)=>{for(let r=0;r<t.length;r++)e.push(t[r]);return e}),uo=((e,t)=>cW(e.channel,t),"~effect/platform/FileSystem"),ul=e=>"bigint"==typeof e?e:BigInt(e),uc=nQ("effect/platform/FileSystem"),uu="~effect/platform/FileSystem/File",ud=l2();class uf extends nQ()("effect/platform/FileSystem/WatchBackend"){}let uh="~effect/platform/Path",up=nQ("effect/Path"),um=l2(),ug=l2(),uy="~effect/ChildProcessSpawner/ChildProcessHandle",ub={[uy]:uy,...{toJSON(){return tl(this)},[to](){return this.toJSON()},toString(){return tr(this.toJSON())}},toJSON(){return{_id:"ChildProcessHandle",pid:this.pid}}},uv=e=>Object.assign(Object.create(ub),e);class uw extends nQ()("effect/process/ChildProcessSpawner"){}let ux="~effect/unstable/process/ChildProcess",uk={...nz({label:"Command",evaluate(e){return n9(e.context,uw).spawn(this)}}),[ux]:ux},uS=(e,t,r)=>Object.assign(Object.create(uk),{_tag:"StandardCommand",command:e,args:t,options:r}),u_=function(...e){if(u$(e[0])){let[t,...r]=e,n=uC(t,r);return uS(n[0]??"",n.slice(1),{})}if("object"==typeof e[0]&&!Array.isArray(e[0])&&!u$(e[0])){let t=e[0];return function(e,...r){let n=uC(e,r);return uS(n[0]??"",n.slice(1),t)}}if("string"==typeof e[0]&&!Array.isArray(e[1])){let[t,r={}]=e;return uS(t,[],r)}let[t,r=[],n={}]=e;return uS(t,r,n)},u$=e=>Array.isArray(e)&&"raw"in e&&Array.isArray(e.raw),uO=e=>{let t=/^fd(\d+)$/.exec(e);if(null===t)return;let r=parseInt(t[1],10);return r>=3?r:void 0},uI=e=>`fd${e}`,uC=(e,t)=>{let r=[];for(let[n,i]of e.entries())r=uE(e,t,r,i,n);return r},uE=(e,t,r,n,i)=>{let s=e.raw[i];if(void 0===s)throw Error(`Invalid backslash sequence: ${e.raw[i]}`);let{hasLeadingWhitespace:a,hasTrailingWhitespace:o,tokens:l}=uN(n,s),c=uj(r,l,a);if(i===t.length)return c;let u=t[i];return uj(c,Array.isArray(u)?u.map(e=>uA(e)):[uA(u)],o)},uA=e=>"string"==typeof e?e:String(e),uT=new Set([" "," ","\r","\n"]),uM={x:3,u:5},uN=(e,t)=>{if(0===t.length)return{tokens:[],hasLeadingWhitespace:!1,hasTrailingWhitespace:!1};let r=uT.has(t[0]),n=[],i=0;for(let r=0,s=0;r<e.length;r+=1,s+=1){let a=t[s];if(uT.has(a))i!==r&&n.push(e.slice(i,r)),i=r+1;else if("\\"===a){let e=t[s+1];"\n"===e?(r-=1,s+=1):"u"===e&&"{"===t[s+2]?s=t.indexOf("}",s+3):s+=uM[e]??1}}let s=i===e.length;return s||n.push(e.slice(i)),{tokens:n,hasLeadingWhitespace:r,hasTrailingWhitespace:s}},uj=(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)],uF=t("node:child_process"),uL=t("node:stream"),uP=(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 ct({_tag:i,module:e,method:t,pathOrDescriptor:n,syscall:r.syscall,cause:r})},uD=e=>cX(cB(uR(e),e=>[e])),uR=e=>cF(t=>{let r=e.evaluate();return lP(uU({...e,writable:r,pull:t}))}),uU=e=>e.pull.pipe(s8(t=>{let r=0;return sW(function n(i){for(;r<t.length;)if(!e.writable.write(t[r++],e.encoding))return void e.writable.once("drain",()=>n(i));i(sK)})}),ap({disableYield:!0}),s4(sW(t=>{let r=r=>t(tJ(e.onError(r)));return e.writable.once("error",r),sL(()=>{e.writable.off("error",r)})})),!1!==e.endOnDone?oY(t=>"closed"in e.writable&&e.writable.closed?oW(t):sW(r=>{e.writable.once("finish",()=>r(oW(t))),e.writable.end()})):ec),uB="~effect/MutableRef",uq={[uB]:uB,...tw,toJSON(){return{_id:"MutableRef",current:tl(this.current)}}},uK=e=>c4(uz(e)),uz=e=>cF((t,r)=>uV({scope:r,readable:e.evaluate(),onError:e.onError??uJ,chunkSize:e.chunkSize,closeOnDone:e.closeOnDone})),uV=e=>{var t;let r,n=e.readable,i=e.closeOnDone??!0,s=e.exit??(t=void 0,(r=Object.create(uq)).current=t,r),a=oh(!1);function o(){a.openUnsafe()}function l(t){s.current=tJ(e.onError(t)),a.openUnsafe()}function c(){s.current=tJ(t2()),a.openUnsafe()}n.on("readable",o),n.once("error",l),n.once("end",c);let u=sP(function t(){let r=e.readable.read(e.chunkSize);if(null===r)return s.current?s.current:n.readableEnded?tJ(t2()):(a.closeUnsafe(),s8(a.await,t));let i=nD(r);for(;null!==(r=e.readable.read(e.chunkSize));)i.push(r);return lP(i)});return s1(aq(e.scope,eu(sL(()=>{n.off("readable",o),n.off("error",l),n.off("end",c),i&&"closed"in e.readable&&!e.readable.closed&&e.readable.destroy()}))),u)};uL.Readable;let uJ=e=>new oF(e),uW=e=>e instanceof globalThis.Error?e:new globalThis.Error(String(e)),uY=(e,t,r)=>{let{commands:n}=uQ(r),i=n.reduce((e,t)=>{let r=`${t.command} ${t.args.join(" ")}`;return 0===e.length?r:`${e} | ${r}`},"");return uP("ChildProcess",e)(t,[i])},uG=lD(function*(){let e,t,r=yield*uc,n=yield*up,i=sG(function*(e){if(!e$(e.cwd))return yield*r.access(e.cwd),n.resolve(e.cwd)}),s=e=>eT(e,cH)?"pipe":e,a=e=>{let t={stream:"pipe",encoding:"utf-8",endOnDone:!0};return e$(e.stdin)?t:"string"==typeof e.stdin?{...t,stream:e.stdin}:eT(e.stdin,"~effect/Stream")?{...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 e$(r)?{stream:"pipe"}:"string"==typeof r?{stream:r}:eT(r,cH)?{stream:r}:{stream:r.stream}},l=sG(function*(e,t,r){if(0===r.length)return{getInputFd:()=>c2,getOutputFd:()=>c6};let n=new Map,i=new Map;for(let{config:s,fd:a}of r){let r=t.stdio[a];switch(s.type){case"input":{let t=c2;r&&"write"in r&&(t=uD({evaluate:()=>r,onError:t=>uY(`fromWritable(fd${a})`,uW(t),e)})),s.stream&&(yield*os(us(s.stream,t))),n.set(a,t);break}case"output":{let t=c6;if(r&&"read"in r){let n=new uL.PassThrough;r.on("error",e=>n.destroy(e)),r.pipe(n),t=uK({evaluate:()=>n,onError:t=>uY(`fromReadable(fd${a})`,uW(t),e)})}s.sink&&(t=un(t,s.sink)),i.set(a,t)}}}return{getInputFd:e=>n.get(e)??c2,getOutputFd:e=>i.get(e)??c6}}),c=(e,t,r)=>"win32"===globalThis.process.platform?sW(r=>{uF.exec(`taskkill /pid ${t.pid} /T /F`,t=>{t?r(tJ(uY("kill",uW(t),e))):r(sK)})}):sz({try:()=>{globalThis.process.kill(-t.pid,r)},catch:t=>uY("kill",uW(t),e)}),u=(e,t,r)=>sP(()=>t.kill(r)?sK:tJ(uY("kill",new globalThis.Error("Failed to kill child process"),e))),d=(e,t,r)=>n=>{let i=r?.killSignal??"SIGTERM";return e$(r?.forceKillAfter)?n(t,e,i):aF(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=uO(r);if(eO(t))return e.getOutputFd(t);return e.stdout}}},h=sG(function*(e){switch(e._tag){case"StandardCommand":{var t,r,n,p;let f,h,m,g,y,b,v,w=a(e.options),x=o(e.options,"stdout"),k=o(e.options,"stderr"),S=(e=>{if(e$(e.additionalFds))return[];let t=[];for(let[r,n]of Object.entries(e.additionalFds)){let e=uO(r);eO(e)&&t.push({fd:e,config:n})}return t.sort((e,t)=>e.fd-t.fd)})(e.options),_=!0,$=yield*i(e.options),O=(b=e.options).extendEnv?{...globalThis.process.env,...b.env}:b.env,I=((e,t,r,n)=>{let i,a=[eT(i=e.stream,"~effect/Stream")?"pipe":i,s(t.stream),s(r.stream)];if(0===n.length)return a;let o=n.reduce((e,{fd:t})=>Math.max(e,t),2);for(let e=3;e<=o;e++)a[e]="ignore";for(let{fd:e}of n)a[e]="pipe";return a})(w,x,k,S),[C,E]=yield*lK((v={cwd:$,env:O,stdio:I,detached:e.options.detached??"win32"!==process.platform,shell:e.options.shell},sW(t=>{let r=ln(),n=uF.spawn(e.command,e.args,v);return n.on("error",r=>{t(tJ(uY("spawn",r,e)))}),n.on("exit",(...e)=>{ll(r,tK(e))}),n.on("spawn",()=>{t(lP([n,r]))}),sL(()=>{n.kill("SIGTERM")})})),sG(function*([t,r]){let n=yield*la(r),i=d(t,e,e.options);if(n){let[e]=yield*li(r);return 0!==e&&eI(e)?yield*aO(i(c)):yield*sK}return _?yield*i((e,t,n)=>c(e,t,n).pipe(ab(()=>u(e,t,n)),s2(li(r)))).pipe(aO):yield*sK})),A=ug(C.pid);C.on("exit",t=>{0!==t&&eI(t)&&((e,t)=>{if("win32"===globalThis.process.platform)return uF.exec(`taskkill /pid ${e.pid} /T /F`,()=>{});try{globalThis.process.kill(-e.pid,t)}catch{}})(C,e.options.killSignal??"SIGTERM")});let T=sL(()=>{_||(C.ref(),_=!0)}),M=sL(()=>(_&&(C.unref(),_=!1),T)),N=yield*sP(()=>{let t=c2;return eI(C.stdin)&&(t=uD({evaluate:()=>C.stdin,onError:t=>uY("fromWritable(stdin)",uW(t),e),endOnDone:w.endOnDone,encoding:w.encoding})),eT(w.stream,"~effect/Stream")?s1(os(us(w.stream,t)),t):lP(t)}),{all:j,stderr:F,stdout:L}=(t=e,r=C,n=x,p=k,m=r.stdout?(f=new uL.PassThrough,r.stdout.on("error",e=>f.destroy(e)),r.stdout.pipe(f),uK({evaluate:()=>f,onError:e=>uY("fromReadable(stdout)",uW(e),t)})):c6,g=r.stderr?(h=new uL.PassThrough,r.stderr.on("error",e=>h.destroy(e)),r.stderr.pipe(h),uK({evaluate:()=>h,onError:e=>uY("fromReadable(stderr)",uW(e),t)})):c6,eT(n.stream,cH)&&(m=un(m,n.stream)),eT(p.stream,cH)&&(g=un(g,p.stream)),y=ur(m,g),{stdout:m,stderr:g,all:y}),{getInputFd:P,getOutputFd:D}=yield*l(e,C,S),R=ae(la(E),e=>!e);return uv({pid:A,exitCode:s8(li(E),([t,r])=>eI(t)?lP(um(t)):tJ(uY("exitCode",new globalThis.Error(`Process interrupted due to receipt of signal: '${r}'`),e))),isRunning:R,kill:t=>d(C,e,t)((e,t,r)=>c(e,t,r).pipe(ab(()=>u(e,t,r)),s2(li(E)))).pipe(s5),stdin:N,stdout:L,stderr:F,all:j,getInputFd:P,getOutputFd:D,unref:M})}case"PipedCommand":{let{commands:t,pipeOptions:r}=uQ(e),[n,...i]=t,s=[(yield*h(n))];for(let e=0;e<i.length;e++){let t=i[e],n=r[e]??{},o=a(t.options),l=ue(lP(f(s[s.length-1],n.from))),c=n.to??"stdin";if("stdin"===c)s.push((yield*h(u_(t.command,t.args,{...t.options,stdin:{...o,stream:l}}))));else{let e=uO(c);if(eO(e)){let r=uI(e),n=t.options.additionalFds??{};s.push((yield*h(u_(t.command,t.args,{...t.options,additionalFds:{...n,[r]:{type:"input",stream:l}}}))))}else s.push((yield*h(u_(t.command,t.args,{...t.options,stdin:{...o,stream:l}}))))}}let o=s[s.length-1],l=lD(function*(){let e=[];for(let t of s)e.push((yield*t.unref));return a7([...e].reverse(),e=>e,{discard:!0})});return uv({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(ae(e=>ui(t?.includeStderr===!0?e.all:e.stdout)),ue),t=(t,r)=>e(t,r).channel.pipe(cz(cF((e,t)=>sL(()=>{let t="",r=!1,n=rx(),i=sP(()=>"Some"===n._tag?oW(n.value):oX(e,{onSuccess:s,onFailure:sF,onDone:e=>{if(n=rk(e),t.length>0||r){let e=t;return t="",r=!1,lP([e])}return oW(e)}}));function s(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 s=e[n];if(0!==s.length){let e=0,n=s.indexOf("\r"),a=s.indexOf("\n");for(r&&(0===a?(i(""),e=1,a=s.indexOf("\n",e)):i(""),r=!1);-1!==n||-1!==a;)-1===n||-1!==a&&a<n?(i(s.substring(e,a)),e=a+1,a=s.indexOf("\n",e)):s.length===n+1?(r=!0,n=-1):(i(s.substring(e,n)),e=n+(a===n+1?2:1),n=s.indexOf("\r",e),a=s.indexOf("\n",e));t+=s.substring(e,s.length-!!r)}}return nA(n)?n:null}(e);return null!==n?lP(n):i}return i}))),c4),uw.of({spawn:h,exitCode:e=>lq(s8(h(e),e=>e.exitCode)),streamString:e,streamLines:t,lines:(e,r)=>ua(t(e,r)),string:(t,r)=>cY(e(t,r).channel,()=>"",(e,t)=>e+t.join(""))})}),uH=lx(uw,uG),uQ=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,...s]=t;return{commands:[i,...s],pipeOptions:r}},uZ="~effect/platform/Crypto",uX=nQ("effect/Crypto"),u0=e=>e.toString(16).padStart(2,"0"),u1=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,u0).join("")).join("-"),u2=0x1000000000000-1,u3=t("node:crypto"),u5=(d=(ee={randomBytes:u3.randomBytes,digest:(e,t)=>sz({try:()=>Uint8Array.from(u3.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=>ct({module:"Crypto",method:"digest",_tag:"Unknown",description:"Could not compute digest",cause:e})})}).randomBytes,f=()=>{let e=d(7);return((31&e[0])*0x1000000000000+0x10000000000*e[1]+0x100000000*e[2]+0x1000000*e[3]+65536*e[4]+256*e[5]+e[6])/0x20000000000000},h=()=>Math.floor(f()*(Number.MAX_SAFE_INTEGER-Number.MIN_SAFE_INTEGER+1))+Number.MIN_SAFE_INTEGER,uX.of({[uZ]:uZ,randomBytes:e=>{let t,r;return ae((t="randomBytes",Number.isSafeInteger(r=e)&&r>=0?lP(r):tJ(cr({module:"Crypto",method:t,description:"size must be a non-negative safe integer"}))),d)},nextDoubleUnsafe:f,nextIntUnsafe:h,digest:ee.digest,random:sL(()=>f()),randomBoolean:sL(()=>f()>.5),randomInt:sL(()=>h()),randomBetween:(e,t)=>sL(()=>f()*(t-e)+e),randomIntBetween(e,t,r){let n=+(r?.halfOpen!==!0);return sL(()=>{let r=Math.ceil(e),i=Math.floor(t);return Math.floor(f()*(i-r+n))+r})},randomShuffle:e=>sL(()=>{let t=Array.from(e);for(let e=t.length-1;e>=1;e-=1){let r=Math.min(e,Math.floor(f()*(e+1))),n=t[e];t[e]=t[r],t[r]=n}return t}),randomUUIDv4:sL(()=>{let e;return(e=d(16))[6]=15&e[6]|64,e[8]=63&e[8]|128,u1(e)}),randomUUIDv7:oI(e=>{var t,r;let n;return lP((t=e.currentTimeMillisUnsafe(),r=d(16),n=Math.min(Math.max(0,Math.trunc(t)),u2),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,u1(r)))})})),u4=lv(uX,u5),u8=t("node:fs"),u6=t("node:os"),u9=t("node:path");var u7=a.t(u9,2);let de=e=>t=>cr({module:"FileSystem",method:e,description:t.message??String(t)}),dt=(p=lG(u8.access,uP("FileSystem","access"),de("access")),(e,t)=>{let r=u8.constants.F_OK;return t?.readable&&(r|=u8.constants.R_OK),t?.writable&&(r|=u8.constants.W_OK),p(e,r)}),dr=(m=lG(u8.cp,uP("FileSystem","copy"),de("copy")),(e,t,r)=>m(e,t,{force:r?.overwrite??!1,preserveTimestamps:r?.preserveTimestamps??!1,recursive:!0})),dn=(g=lG(u8.copyFile,uP("FileSystem","copyFile"),de("copyFile")),(e,t)=>g(e,t)),di=(y=lG(u8.chmod,uP("FileSystem","chmod"),de("chmod")),(e,t)=>y(e,t)),ds=(b=lG(u8.chown,uP("FileSystem","chown"),de("chown")),(e,t,r)=>b(e,t,r)),da=(v=lG(u8.glob,uP("FileSystem","glob"),de("glob")),(e,t)=>v(e,{cwd:t?.root,exclude:t?.exclude})),dl=(w=lG(u8.link,uP("FileSystem","link"),de("link")),(e,t)=>w(e,t)),dc=(x=lG(u8.mkdir,uP("FileSystem","makeDirectory"),de("makeDirectory")),(e,t)=>x(e,{recursive:t?.recursive??!1,mode:t?.mode})),du=e=>{let t=lG(u8.mkdtemp,uP("FileSystem",e),de(e));return e=>sP(()=>{let r=e?.prefix??"",n="string"==typeof e?.directory?u9.join(e.directory,"."):u6.tmpdir();return t(r?u9.join(n,r):n+"/")})},dd=du("makeTempDirectory"),df=e=>{let t=lG(u8.rm,uP("FileSystem",e),de(e));return(e,r)=>t(e,{recursive:r?.recursive??!1,force:r?.force??!1})},dh=df("remove"),dp=(k=du("makeTempDirectoryScoped"),S=df("makeTempDirectoryScoped"),e=>lK(k(e),e=>lB(S(e,{recursive:!0})))),dm=(et="open",_=lG(u8.open,uP("FileSystem",et),de(et)),$=lG(u8.close,uP("FileSystem",et),de(et)),(e,t)=>em(lK(_(e,t?.flag??"r",t?.mode),e=>lB($(e))),ae(e=>dg(ud(e),t?.flag?.startsWith("a")??!1)))),dg=(()=>{let e=e=>lG(u8.read,uP("FileSystem",e),de(e)),t=e("read"),r=e("readAlloc"),n=lG(u8.fstat,uP("FileSystem","stat"),de("stat")),i=lG(u8.ftruncate,uP("FileSystem","truncate"),de("truncate")),s=lG(u8.fsync,uP("FileSystem","sync"),de("sync")),a=e=>lG(u8.write,uP("FileSystem",e),de(e)),o=a("write"),l=a("writeAll");class c{[uu];fd;append;position=BigInt(0);constructor(e,t){this[uu]=uu,this.fd=e,this.append=t}get stat(){return ae(n(this.fd),d$)}get sync(){return s(this.fd)}seek(e,t){let r=ul(e);return sL(()=>("start"===t?this.position=r:"current"===t&&(this.position=this.position+r),this.position))}read(e){return sP(()=>{let r=this.position;return ae(t(this.fd,{buffer:e,position:r}),e=>{let t=ul(e);return this.position=r+t,t})})}readAlloc(e){let t=Number(e);return sP(()=>{let e=Buffer.allocUnsafeSlow(t),n=this.position;return ae(r(this.fd,{buffer:e,position:n}),r=>{if(0===r)return rx();if(this.position=n+BigInt(r),r===t)return rk(e);let i=Buffer.allocUnsafeSlow(r);return e.copy(i,0,0,r),rk(i)})})}truncate(e){return ae(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 sP(()=>{let t=this.position;return ae(o(this.fd,e,void 0,void 0,this.append?void 0:Number(t)),e=>{let r=ul(e);return this.append||(this.position=t+r),r})})}writeAllChunk(e){return sP(()=>{let t=this.position;return s8(l(this.fd,e,void 0,void 0,this.append?void 0:Number(t)),r=>0===r?tJ(ct({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)):sK))})}writeAll(e){return this.writeAllChunk(e)}}return(e,t)=>new c(e,t)})(),dy=e=>{let t=du(e);return sG(function*(e){let r=yield*t(e),n=u3.randomBytes(6).toString("hex"),i=u9.join(r,e?.suffix?`${n}${e.suffix}`:n);return yield*dA(i,new Uint8Array(0)),i})},db=dy("makeTempFile"),dv=(O=dy("makeTempFileScoped"),I=df("makeTempFileScoped"),e=>lK(O(e),e=>lB(I(u9.dirname(e),{recursive:!0})))),dw=(e,t)=>lL({try:()=>u8.promises.readdir(e,t),catch:t=>uP("FileSystem","readDirectory")(t,[e])}),dx=e=>sW((t,r)=>{try{u8.readFile(e,{signal:r},(r,n)=>{r?t(tJ(uP("FileSystem","readFile")(r,[e]))):t(lP(n))})}catch(e){t(tJ(de("readFile")(e)))}}),dk=(C=lG(u8.readlink,uP("FileSystem","readLink"),de("readLink")),e=>C(e)),dS=(E=lG(u8.realpath,uP("FileSystem","realPath"),de("realPath")),e=>E(e)),d_=(A=lG(u8.rename,uP("FileSystem","rename"),de("rename")),(e,t)=>A(e,t)),d$=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:rL(e.mtime),atime:rL(e.atime),birthtime:rL(e.birthtime),dev:e.dev,rdev:rL(e.rdev),ino:rL(e.ino),mode:e.mode,nlink:rL(e.nlink),uid:rL(e.uid),gid:rL(e.gid),size:ul(e.size),blksize:void 0!==e.blksize?rk(ul(e.blksize)):rx(),blocks:rL(e.blocks)}),dO=(T=lG(u8.stat,uP("FileSystem","stat"),de("stat")),e=>ae(T(e),d$)),dI=(M=lG(u8.symlink,uP("FileSystem","symlink"),de("symlink")),(e,t)=>M(e,t)),dC=(N=lG(u8.truncate,uP("FileSystem","truncate"),de("truncate")),(e,t)=>N(e,void 0!==t?Number(t):void 0)),dE=(j=lG(u8.utimes,uP("FileSystem","utime"),de("utime")),(e,t,r)=>j(e,t,r)),dA=(e,t,r)=>sW((n,i)=>{try{u8.writeFile(e,t,{signal:i,flag:r?.flag,mode:r?.mode},t=>{t?n(tJ(uP("FileSystem","writeFile")(t,[e]))):n(sK)})}catch(e){n(tJ(de("writeFile")(e)))}}),dT=ae(tY(e=>sj(ii(e.context,uf))),e=>{let t;return t={access:dt,chmod:di,chown:ds,copy:dr,copyFile:dn,glob:da,link:dl,makeDirectory:dc,makeTempDirectory:dd,makeTempDirectoryScoped:dp,makeTempFile:db,makeTempFileScoped:dv,open:dm,readDirectory:dw,readFile:dx,readLink:dk,realPath:dS,remove:dh,rename:d_,stat:dO,symlink:dI,truncate:dC,utimes:dE,watch:t=>dO(t).pipe(ae(r=>e.pipe(rG(e=>e.register(t,r)),rT(()=>{var e;let r;return c4((r=e=>lK(sL(()=>{let r=u8.watch(t,{recursive:!0},(t,r)=>{if(r)switch(t){case"rename":return void ol(aA(dO(r),{onSuccess:t=>cd(e,{_tag:"Create",path:r}),onFailure:t=>cd(e,{_tag:"Remove",path:r})}));case"change":return void cf(e,{_tag:"Update",path:r})}});return r.on("error",r=>{cp(e,tN(ct({module:"FileSystem",_tag:"Unknown",method:"watch",pathOrDescriptor:t,cause:r})))}),r.on("close",()=>{cm(e)}),r}),e=>sL(()=>e.close())),cF((t,n)=>ae(cu({capacity:e?.bufferSize,strategy:e?.strategy}).pipe(s3(e=>aq(n,eu(cg(e)))),s3(e=>oi(aW(r(e),n),n))),cy))))}))),ue),writeFile:dA},uc.of({...t,[uo]:uo,exists:e=>em(t.access(e),s1(!0),aS("PlatformError",e=>"NotFound"===e.reason._tag?lP(!1):tJ(e))),readFileString:(e,r)=>s8(t.readFile(e),e=>sz({try:()=>new TextDecoder(r).decode(e),catch:e=>cr({module:"FileSystem",method:"readFileString",description:"invalid encoding",cause:e})})),stream:sG(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?ul(r.bytesToRead):void 0,s=BigInt(0),a=ul(r?.chunkSize??65536),o=n.readAlloc(a);return c4(cP(lP(s8(sP(()=>void 0!==i&&i<=s?oW():void 0!==i&&i-s<a?n.readAlloc(i-s):o),rO({onNone:()=>oW(),onSome:e=>(s+=BigInt(e.length),lP(nD(e)))})))))},ue),sink:(e,r)=>em(t.open(e,{flag:"w",...r}),ae(e=>{let t,r;return t=t=>e.writeAll(t),r=a7(e=>t(e),{discard:!0}),c0(e=>e.pipe(s8(r),ap({disableYield:!0}),oY(()=>cQ)))}),c3),writeFileString:(e,r,n)=>s8(sz({try:()=>new TextEncoder().encode(r),catch:e=>cr({module:"FileSystem",method:"writeFileString",description:"could not encode string",cause:e})}),r=>t.writeFile(e,r,n))})}),dM=lx(uc)(dT),dN=t("node:url"),dj=e=>sz({try:()=>dN.fileURLToPath(e),catch:e=>new l9({module:"Path",method:"fromFileUrl",cause:e})}),dF=e=>sz({try:()=>dN.pathToFileURL(e),catch:e=>new l9({module:"Path",method:"toFileUrl",cause:e})});u9.posix,u9.win32;let dL=lv(up)({[uh]:uh,...u7,fromFileUrl:dj,toFileUrl:dF}),dP="~effect/Stdio",dD=nQ(dP),dR=lv(dD,{[dP]:dP,...{args:sL(()=>process.argv.slice(2)),stdout:e=>uD({evaluate:()=>process.stdout,onError:e=>ct({module:"Stdio",method:"stdout",_tag:"Unknown",cause:e}),endOnDone:e?.endOnDone??!1}),stderr:e=>uD({evaluate:()=>process.stderr,onError:e=>ct({module:"Stdio",method:"stderr",_tag:"Unknown",cause:e}),endOnDone:e?.endOnDone??!1}),stdin:uK({evaluate:()=>process.stdin,onError:e=>ct({module:"Stdio",method:"stdin",_tag:"Unknown",cause:e}),closeOnDone:!1})}});class dU{waiters=new Set;taken=0;permits;constructor(e){this.permits=e}get free(){return this.permits-this.taken}take(e){let t=sP(()=>this.free<e?sW(r=>{if(this.free>=e)return r(t);let n=()=>{this.free<e||(this.waiters.delete(n),r(t))};return this.waiters.add(n),sL(()=>{this.waiters.delete(n)})}):(this.taken+=e,sj(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 tY(t=>sj(this.updateTakenUnsafe(t,e)))}resize(e){return tY(t=>(this.permits=e,this.free<0||this.updateTakenUnsafe(t,e=>e),sK))}release(e){return this.updateTaken(t=>t-e)}get releaseAll(){return this.updateTaken(e=>0)}withPermits(e){return t=>a8(r=>s8(r(this.take(e)),e=>aG(r(t),()=>{this.updateTakenUnsafe(sO(),t=>t-e)},!0)))}withPermit=this.withPermits(1);withPermitsIfAvailable(e){return t=>a8(r=>this.free<e?sU:(this.taken+=e,aG(r(ae(t,rk)),()=>{this.updateTakenUnsafe(sO(),t=>t-e)},!0)))}}let dB={_tag:"Empty"},dq={_tag:"Closed"},dK={_A:ec,_E:ec};class dz{"~effect/RcRef"=dK;pipe(){return es(this,arguments)}state=dB;semaphore=new dU(1);acquire;context;scope;idleTimeToLive;constructor(e,t,r,n){this.acquire=e,this.context=t,this.scope=r,this.idleTimeToLive=n}}let dV=sG(function*(e){let t,r=yield*a8(t=>{switch(e.state._tag){case"Closed":return a0;case"Acquired":return e.state.refCount++,e.state.fiber?s1(sT(e.state.fiber),e.state):lP(e.state);case"Empty":{let r=aV();return e.semaphore.withPermits(1)(t(ad(e.acquire,n8(e.context,aD,r))).pipe(ae(t=>{let n={_tag:"Acquired",value:t,scope:r,fiber:void 0,refCount:1,invalidated:!1};return e.state=n,n})))}}}),n=yield*aD,i=void 0!==e.idleTimeToLive&&"Infinity"!==(t=e.idleTimeToLive).value._tag&&"NegativeInfinity"!==t.value._tag;return yield*aq(n,()=>(r.refCount--,r.refCount>0)?sK:void 0===e.idleTimeToLive?(e.state=dB,aR(r.scope,ai)):r.invalidated?aR(r.scope,ai):i?(r.fiber=oC(e.idleTimeToLive).pipe(s8(()=>"Acquired"===e.state._tag&&0===e.state.refCount?(e.state=dB,aR(r.scope,ai)):sK),aQ(sL(()=>{r.fiber=void 0})),oa(e.context),oo(e.scope)),sK):sK),r.value}),dJ=/^[+-]?\d+$/,dW="~effect/BigDecimal",dY={[dW]:dW,[ej](){let e=d3(this);return eP(eF(e.value),eU(e.scale))},[eQ](e){return dG(e)&&ft(this,e)},toString(){return`BigDecimal(${fr(this)})`},toJSON(){return{_id:"BigDecimal",value:String(this.value),scale:this.scale}},[to](){return this.toJSON()},pipe(){return es(this,arguments)}},dG=e=>eT(e,dW),dH=(e,t)=>{let r=Object.create(dY);return r.value=e,r.scale=t,r},dQ=(e,t)=>{if(e!==dZ&&e%d1===dZ)throw RangeError("Value must be normalized");let r=dH(e,t);return r.normalized=r,r},dZ=BigInt(0),dX=BigInt(1),d0=BigInt(-1),d1=BigInt(10),d2=dQ(dZ,0),d3=e=>{if(void 0===e.normalized)if(e.value===dZ)e.normalized=d2;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=dQ(n,i)}return e.normalized},d5=el(2,(e,t)=>t>e.scale?dH(e.value*d1**BigInt(t-e.scale),t):t<e.scale?dH(e.value/d1**BigInt(e.scale-t),t):e),d4=el(2,(e,t)=>t.value===dZ?e:e.value===dZ?t:e.scale>t.scale?dH(d5(t,e.scale).value+e.value,e.scale):e.scale<t.scale?dH(d5(e,t.scale).value+t.value,t.scale):dH(e.value+t.value,e.scale)),d8=rm((e,t)=>{let r=rg(d7(e),d7(t));return 0!==r?r:e.scale>t.scale?ry(e.value,d5(t,e.scale).value):e.scale<t.scale?ry(d5(e,t.scale).value,t.value):ry(e.value,t.value)}),d6=(V=d8,el(2,(e,t)=>-1===V(e,t))),d9=rv(d8),d7=e=>e.value===dZ?0:e.value<dZ?-1:1,fe=t5((e,t)=>e.scale>t.scale?d5(t,e.scale).value===e.value:e.scale<t.scale?d5(e,t.scale).value===t.value:e.value===t.value),ft=el(2,(e,t)=>fe(e,t)),fr=e=>{let t,r,n=d3(e);if(Math.abs(n.scale)>=16)return fn(n);let i=n.value<dZ,s=i?`${n.value}`.substring(1):`${n.value}`;if(n.scale>=s.length)t="0",r="0".repeat(n.scale-s.length)+s;else{let e=s.length-n.scale;if(e>s.length){let n=e-s.length;t=`${s}${"0".repeat(n)}`,r=""}else r=s.slice(e),t=s.slice(0,e)}let a=""===r?t:`${t}.${r}`;return i?`-${a}`:a},fn=e=>{if(fi(e))return"0e+0";let t=d3(e),r=`${(t.value<dZ?dH(-t.value,t.scale):t).value}`,n=r.slice(0,1),i=r.slice(1),s=`${fs(t)?"-":""}${n}`;""!==i&&(s+=`.${i}`);let a=i.length-t.scale;return`${s}e${a>=0?"+":""}${a}`},fi=e=>e.value===dZ,fs=e=>e.value<dZ,fa=e=>dG(e[0]),fo=el(fa,(e,t=0)=>e.scale<=t?e:dH(e.value/d1**BigInt(e.scale-t),t)),fl=el(fa,(e,t=0)=>{let r=fo(e,t);return e.value>dZ&&d6(r,e)?d4(r,dH(dX,t)):r}),fc=el(fa,(e,t=0)=>{let r=fo(e,t);return fs(e)&&d9(r,e)?d4(r,dH(d0,t)):r}),fu="~effect/time/DateTime",fd="~effect/time/DateTime/TimeZone",ff={[fu]:fu,pipe(){return es(this,arguments)},[to](){return this.toString()},toJSON(){return fF(this).toJSON()}},fh={...ff,_tag:"Utc",[ej](){return eU(this.epochMilliseconds)},[eQ](e){return fv(e)&&"Utc"===e._tag&&this.epochMilliseconds===e.epochMilliseconds},toString(){return`DateTime.Utc(${fF(this).toJSON()})`}},fp={...ff,_tag:"Zoned",[ej](){return eP(eU(this.epochMilliseconds))(eF(this.zone))},[eQ](e){return fv(e)&&"Zoned"===e._tag&&this.epochMilliseconds===e.epochMilliseconds&&eZ(this.zone,e.zone)},toString(){return`DateTime.Zoned(${fH(this)})`}},fm={[fd]:fd,[to](){return this.toString()}},fg={...fm,_tag:"Named",[ej](){return eB(`Named:${this.id}`)},[eQ](e){return fx(e)&&"Named"===e._tag&&this.id===e.id},toString(){return`TimeZone.Named(${this.id})`},toJSON(){return{_id:"TimeZone",_tag:"Named",id:this.id}}},fy={...fm,_tag:"Offset",[ej](){return eB(`Offset:${this.offset}`)},[eQ](e){return fx(e)&&"Offset"===e._tag&&this.offset===e.offset},toString(){return`TimeZone.Offset(${fD(this.offset)})`},toJSON(){return{_id:"TimeZone",_tag:"Offset",offset:this.offset}}},fb=(e,t,r)=>{let n=Object.create(fp);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},fv=e=>eT(e,fu),fw=e=>fv(e[0]),fx=e=>eT(e,fd),fk=((e,t)=>e.epochMilliseconds===t.epochMilliseconds,e=>{let t=Object.create(fh);return t.epochMilliseconds=e,Object.defineProperty(t,"partsUtc",{value:void 0,enumerable:!1,writable:!0}),t}),fS=e=>{let t=e.getTime();if(Number.isNaN(t))throw new oT("Invalid date");return fk(t)},f_=e=>{if(fv(e))return e;if(e instanceof Date)return fS(e);if("object"==typeof e){if("epochMilliseconds"in e)return fk(e.epochMilliseconds);let t=new Date(0);return fU(t,e),fS(t)}return"string"!=typeof e||f$(e)?fS(new Date(e)):fS(new Date(e+"Z"))},f$=e=>/Z|GMT|[+-]\d{2}$|[+-]\d{2}:?\d{2}$|\]$/.test(e),fO=rq((e,t)=>{let r,n=t?.timeZone;if(void 0===n&&fv(e)&&"Zoned"===e._tag)return e;let i=f_(e);if(i.epochMilliseconds<-86399999568e5||i.epochMilliseconds>86399999496e5)throw RangeError(`Epoch millis out of range: ${i.epochMilliseconds}`);if(void 0===n&&"object"==typeof e&&"timeZoneId"in e&&(n=e.timeZoneId),void 0===n)r=fT(-60*new Date(i.epochMilliseconds).getTimezoneOffset()*1e3);else if(fx(n))r=n;else if("number"==typeof n)r=fT(n);else{let e=fj(n);if(r_(e))throw new oT(`Invalid time zone: ${n}`);r=e.value}return t?.adjustForTimeZone!==!0?fb(i.epochMilliseconds,r,i.partsUtc):fB(i.epochMilliseconds,r,t?.disambiguation??"compatible")}),fI=rq(f_),fC=/^(.{17,35})\[(.+)\]$/,fE=((e,t,r)=>r?.adjustForTimeZone===!0?fB(e.epochMilliseconds,t,r?.disambiguation??"compatible"):fb(e.epochMilliseconds,t,e.partsUtc),new Map),fA={day:"numeric",month:"numeric",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"longOffset",fractionalSecondDigits:3,hourCycle:"h23"},fT=e=>{let t=Object.create(fy);return t.offset=e,t},fM=rq(e=>{if(fE.has(e))return fE.get(e);try{var t=new Intl.DateTimeFormat("en-US",{...fA,timeZone:e});let r=t.resolvedOptions().timeZone;if(fE.has(r))return fE.get(r);let n=Object.create(fg);return n.id=r,n.format=t,fE.set(r,n),n}catch{throw new oT(`Invalid time zone: ${e}`)}}),fN=/^(?:GMT|[+-])/,fj=e=>{if(fN.test(e)){let t=fK(e);return null===t?rx():rk(fT(t))}return fM(e)},fF=e=>new Date(e.epochMilliseconds),fL=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},fP=e=>fL(e).getTime()-fR(e),fD=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")}`},fR=e=>e.epochMilliseconds,fU=(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)},fB=(e,t,r)=>{if("Offset"===t._tag)return fb(e-t.offset,t);let n=fz(e-864e5,e,t),i=fz(e+864e5,e,t);if(n===i)return fb(e-n,t);let s=n-i;if(n<i){if(fz(e-i,e,t)===i)return fb(e-i,t);let s=fb(e-n,t);if(e!==fL(s).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 fb(e-i,t)}return s}if(fz(e-n,e,t)===n){if("earlier"===r||"compatible"===r||fz(e-n+s,e+s,t)===n)return fb(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 fb(e-i,t)},fq=/([+-])(\d{2}):(\d{2})$/,fK=e=>{let t=fq.exec(e);if(null===t)return null;let[,r,n,i]=t;return("+"===r?1:-1)*(60*Number(n)+Number(i))*6e4},fz=(e,t,r)=>{let n=r.format.formatToParts(e).find(e=>"timeZoneName"===e.type)?.value??"";if("GMT"===n)return 0;let i=fK(n);return null===i?fP(fb(t,r)):i},fV=el(fw,(e,t,r)=>{if("Utc"===e._tag){let r=fF(e);return t(r),fk(r.getTime())}let n=new Date(fL(e).getTime());return t(n),fB(n.getTime(),e.zone,r?.disambiguation??"compatible")}),fJ=((e,t)=>fJ(e,e=>{let r=new Date(e);return t(r),r.getTime()}),el(2,(e,t)=>{let r=t(fR(e));return"Utc"===e._tag?fk(r):fb(r,e.zone)})),fW=((e,t)=>t(fL(e)),el(2,(e,t)=>t(fF(e)))),fY=(e,t)=>{e.setTime(e.getTime()+t)},fG=((e,t)=>fV(e,e=>{if(t.milliseconds&&fY(e,t.milliseconds),t.seconds&&fY(e,1e3*t.seconds),t.minutes&&fY(e,60*t.minutes*1e3),t.hours&&fY(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=fL(e);return"Utc"===e._tag?t.toISOString():`${t.toISOString().slice(0,-1)}${fD(fP(e))}`}),fH=e=>"Offset"===e.zone._tag?fG(e):`${fG(e)}[${e.zone.id}]`,fQ="~effect/encoding/EncodingError";class fZ extends l8("EncodingError"){[fQ]=fQ}let fX=e=>"string"==typeof e?f5(f1.encode(e)):f5(e),f0=e=>{let t=f3(e),r=t.length;if(r%4!=0)return rh(new fZ({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 rh(new fZ({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=f4(t.charCodeAt(e))<<18|f4(t.charCodeAt(e+1))<<12|f4(t.charCodeAt(e+2))<<6|f4(t.charCodeAt(e+3));n[i]=r>>16,n[i+1]=r>>8&255,n[i+2]=255&r}return rp(n)}catch(e){return rh(new fZ({kind:"Decode",module:"Base64",input:t,message:e instanceof Error?e.message:"Invalid input"}))}},f1=new TextEncoder,f2=new TextDecoder,f3=e=>e.replace(/[\n\r]/g,""),f5=e=>{let t,r=e.length,n="";for(t=2;t<r;t+=3)n+=f8[e[t-2]>>2],n+=f8[(3&e[t-2])<<4|e[t-1]>>4],n+=f8[(15&e[t-1])<<2|e[t]>>6],n+=f8[63&e[t]];return t===r+1&&(n+=f8[e[t-2]>>2],n+=f8[(3&e[t-2])<<4],n+="=="),t===r&&(n+=f8[e[t-2]>>2],n+=f8[(3&e[t-2])<<4|e[t-1]>>4],n+=f8[(15&e[t-1])<<2],n+="="),n};function f4(e){if(e>=f6.length)throw TypeError(`Invalid character ${String.fromCharCode(e)}`);let t=f6[e];if(255===t)throw TypeError(`Invalid character ${String.fromCharCode(e)}`);return t}let f8=["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","+","/"],f6=[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],f9=e=>f5(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_"),f7=e=>{let t="";for(let r=0;r<e.length;++r)t+=ht[e[r]];return t},he=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")},ht=["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"];function hr(e,t,r){return"__proto__"===t?Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0}):e[t]=r,e}let hn=e=>(e.checks?e.checks[e.checks.length-1].annotations:e.annotations)?.identifier,hi=eg(e=>{let t=hn(e);return"string"==typeof t?t:e.getExpected(hi)}),hs="~effect/SchemaIssue/Issue";class ha{[hs]=hs;toString(){return h_(this)}}class ho extends ha{_tag="Filter";actual;filter;issue;constructor(e,t,r){super(),this.actual=e,this.filter=t,this.issue=r}}class hl extends ha{_tag="Encoding";ast;actual;issue;constructor(e,t,r){super(),this.ast=e,this.actual=t,this.issue=r}}class hc extends ha{_tag="Pointer";path;issue;constructor(e,t){super(),this.path=e,this.issue=t}}class hu extends ha{_tag="MissingKey";annotations;constructor(e){super(),this.annotations=e}}class hd extends ha{_tag="UnexpectedKey";ast;actual;constructor(e,t){super(),this.ast=e,this.actual=t}}class hf extends ha{_tag="Composite";ast;actual;issues;constructor(e,t,r){super(),this.ast=e,this.actual=t,this.issues=r}}class hh extends ha{_tag="InvalidType";ast;actual;constructor(e,t){super(),this.ast=e,this.actual=t}}class hp extends ha{_tag="InvalidValue";actual;annotations;constructor(e,t){super(),this.actual=e,this.annotations=t}}class hm extends ha{_tag="Forbidden";actual;annotations;constructor(e,t){super(),this.actual=e,this.annotations=t}}class hg extends ha{_tag="AnyOf";ast;actual;issues;constructor(e,t,r){super(),this.ast=e,this.actual=t,this.issues=r}}class hy extends ha{_tag="OneOf";ast;actual;successes;constructor(e,t,r){super(),this.ast=e,this.actual=t,this.successes=r}}function hb(e,t){if(eT(t,hs))return t;if("string"==typeof t)return new hp(rk(e),{message:t});let r="string"==typeof t.issue?new hp(rk(e),{message:t.issue}):t.issue;return new hc(t.path,r)}let hv=e=>{let t=hO(e);if(void 0!==t)return t;switch(e._tag){case"InvalidType":return hk(hi(e.ast),hC(e.actual));case"InvalidValue":return`Invalid data ${hC(e.actual)}`;case"MissingKey":return"Missing key";case"UnexpectedKey":return`Unexpected key with value ${tr(e.actual)}`;case"Forbidden":return"Forbidden operation";case"OneOf":return`Expected exactly one member to match the input ${tr(e.actual)}`}},hw=e=>hO(e.issue)??hO(e);function hx(e){return t=>({issues:hS(t,[],e?.leafHook??hv,e?.checkHook??hw)})}function hk(e,t){return`Expected ${e}, got ${t}`}function hS(e,t,r,n){switch(e._tag){case"Filter":{let i=n(e);if(void 0!==i)return[{path:t,message:i}];if("InvalidValue"===e.issue._tag)return[{path:t,message:hk(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),tr(e.actual))}];return hS(e.issue,t,r,n)}case"Encoding":return hS(e.issue,t,r,n);case"Pointer":return hS(e.issue,[...t,...e.path],r,n);case"Composite":return e.issues.flatMap(e=>hS(e,t,r,n));case"AnyOf":{let i=hO(e);if(0===e.issues.length){if(void 0!==i)return[{path:t,message:i}];return[{path:t,message:hk(hi(e.ast),tr(e.actual))}]}return e.issues.flatMap(e=>hS(e,t,r,n))}default:return[{path:t,message:r(e)}]}}let h_=e=>hS(e,[],hv,hw).map(h$).join("\n");function h$(e){let t=e.message;if(e.path&&e.path.length>0){let r=e.path.map(e=>`[${ti(e)}]`).join("");t+=`
37
+ at ${r}`}return t}function hO(e){switch(e._tag){case"InvalidType":case"OneOf":case"Composite":case"AnyOf":return hI(e.ast.annotations);case"InvalidValue":case"Forbidden":return hI(e.annotations);case"MissingKey":return hI(e.annotations,"messageMissingKey");case"UnexpectedKey":return hI(e.ast.annotations,"messageUnexpectedKey");case"Filter":return hI(e.filter.annotations);case"Encoding":return hO(e.issue)}}function hI(e,t="message"){let r=e?.[t];if("string"==typeof r)return r}function hC(e){return r_(e)?"no value provided":tr(e.value)}function hE(e){let t;for(let r of e.reasons){if(!tL(r)||!eT(r.error,hs))return;t??=r.error}return t}function hA(e,t){let r=hE(e);if(void 0===r)throw Error(t,{cause:e});return r}class hT extends eo{run;constructor(e){super(),this.run=e}map(e){return new hT((t,r)=>this.run(t,r).pipe(at(rV(e))))}compose(e){return hN(this)?e:hN(e)?this:new hT((t,r)=>this.run(t,r).pipe(s7(t=>e.run(t,r))))}}let hM=new hT(lP);function hN(e){return e.run===hM.run}function hj(e){var t;return t=rV(e),new hT(e=>lP(t(e)))}function hF(e){var t;return t=(t,r)=>e(t,r).pipe(at(rk)),new hT((e,r)=>r_(e)?sU:t(e.value,r))}function hL(e){return new hT(t=>{let r=nt(t,eO);return r$(r)?lP(r):at(e,rk)})}function hP(){return hj(globalThis.String)}function hD(){return hj(globalThis.Number)}let hR="~effect/SchemaTransformation/Transformation";class hU{[hR]=hR;_tag="Transformation";decode;encode;constructor(e,t){this.decode=e,this.encode=t}flip(){return new hU(this.encode,this.decode)}compose(e){return new hU(this.decode.compose(e.decode),e.encode.compose(this.encode))}}let hB=e=>eT(e,hR)?e:new hU(e.decode,e.encode);function hq(e){return new hU(hF(e.decode),hF(e.encode))}function hK(e){return new hU(hj(e.decode),hj(e.encode))}let hz=new hU(hM,hM),hV=new hU(hD(),hP()),hJ=new hU(hj(globalThis.BigInt),hP());hj(e=>new globalThis.Date(e));let hW=e=>{let t;return eA(e)&&"string"==typeof e.message?(t=Object.hasOwn(e,"cause")?Error(e.message,{cause:hW(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};function hY(e){return t=>t._tag===e}hF(e=>ar(sD(f0(e)),t=>new hp(rk(e),{message:t.message}))),hj(fX),hF(e=>n_(nS(f0(e),e=>f2.decode(e)),{onFailure:t=>tJ(new hp(rk(e),{message:t.message})),onSuccess:lP})),hj(fX),hF(e=>n_(nS((e=>{let t=f3(e),r=t.length;if(r%4==1)return rh(new fZ({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 rh(new fZ({module:"Base64Url",kind:"Decode",input:t,message:"Invalid input"}));let n=r%4==2?`${t}==`:r%4==3?`${t}=`:t;return f0(n=n.replace(/-/g,"+").replace(/_/g,"/"))})(e),e=>f2.decode(e)),{onFailure:t=>tJ(new hp(rk(e),{message:t.message})),onSuccess:lP})),hj(e=>"string"==typeof e?f9(f1.encode(e)):f9(e)),hF(e=>n_(nS((e=>{let t=new TextEncoder().encode(e);if(t.length%2!=0)return rh(new fZ({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=he(t[2*n]),i=he(t[2*n+1]);r[n]=e<<4|i}return rp(r)}catch(t){return rh(new fZ({module:"Hex",kind:"Decode",input:e,message:t instanceof Error?t.message:"Invalid input"}))}})(e),e=>f2.decode(e)),{onFailure:t=>tJ(new hp(rk(e),{message:t.message})),onSuccess:lP})),hj(e=>"string"==typeof e?f7(f1.encode(e)):f7(e)),hF(e=>{try{return lP(globalThis.decodeURIComponent(e))}catch(t){return tJ(new hp(rk(e),{message:t instanceof URIError?t.message:"Invalid URI component"}))}}),hj(encodeURIComponent);let hG=hY("Declaration"),hH=hY("Never"),hQ=hY("String"),hZ=hY("Number"),hX=hY("Boolean"),h0=hY("Literal"),h1=hY("UniqueSymbol"),h2=hY("Arrays"),h3=hY("Objects"),h5=hY("Union");class h4{to;transformation;constructor(e,t){this.to=e,this.transformation=t}}let h8={};class h6{isOptional;isMutable;defaultValue;annotations;constructor(e,t,r,n){this.isOptional=e,this.isMutable=t,this.defaultValue=r,this.annotations=n}}let h9="~effect/Schema";class h7{[h9]=h9;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 pe extends h7{_tag="Declaration";typeParameters;run;encodingChecks;constructor(e,t,r,n,i,s,a){super(r,n,i,s),this.typeParameters=e,this.run=t,this.encodingChecks=a}getParser(){let e=this.run(this.typeParameters);return(t,r)=>r_(t)?sU:at(e(t.value,this,r),rk)}_rebuild(e,t,r){let n=pQ(this.typeParameters,e);return n===this.typeParameters&&t===this.checks&&r===this.encodingChecks?this:new pe(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 pt=new class extends h7{_tag="Null";getParser(){return p6(this,null)}getExpected(){return"null"}},pr=new h4(pt,new hU(hj(()=>void 0),hj(()=>null))),pn=new class extends h7{_tag="Undefined";getParser(){return p6(this,void 0)}toCodecJson(){return pq(this,[pr])}getExpected(){return"undefined"}},pi=new class extends h7{_tag="Unknown";getParser(){return p9(this,eE)}getExpected(){return"unknown"}};class ps extends h7{_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 ${tr(e)}`);this.literal=e}getParser(){return p6(this,this.literal)}matchPart(e,t){return e===globalThis.String(this.literal)?this.literal:void 0}toCodecJson(){return"bigint"==typeof this.literal?pa(this):this}toCodecStringTree(){return"string"==typeof this.literal?this:pa(this)}getExpected(){return"string"==typeof this.literal?JSON.stringify(this.literal):globalThis.String(this.literal)}}function pa(e){let t=globalThis.String(e.literal);return pq(e,[new h4(new ps(t),new hU(hj(()=>e.literal),hj(()=>t)))])}let po=new class extends h7{_tag="String";getParser(){return p9(this,ev)}matchPart(e,t){return p7(this,e,t)}getExpected(){return"string"}};function pl(e,t){return e.some(e=>{switch(e._tag){case"Filter":return e.annotations?.meta?._tag===t;case"FilterGroup":return pl(e.checks,t)}})}let pc=new class extends h7{_tag="Number";getParser(){return p9(this,ew)}matchKey(e,t){return this._match(mi,e,t)}matchPart(e,t){return this._match(mn,e,t)}_match(e,t,r){return e.test(t)?p7(this,globalThis.Number(t),r):void 0}toCodecJson(){return this.checks&&(pl(this.checks,"isFinite")||pl(this.checks,"isInt"))?this:pq(this,[pj])}toCodecStringTree(){return this.checks&&(pl(this.checks,"isFinite")||pl(this.checks,"isInt"))?pq(this,[ma]):pq(this,[mo])}getExpected(){return"number"}},pu=new class extends h7{_tag="Boolean";getParser(){return p9(this,ex)}getExpected(){return"boolean"}},pd=new class extends h7{_tag="Symbol";getParser(){return p9(this,eS)}matchKey(e,t){return p7(this,e,t)}toCodecStringTree(){return pq(this,[md])}getExpected(){return"symbol"}},pf=new class extends h7{_tag="BigInt";getParser(){return p9(this,ek)}matchPart(e,t){return ml.test(e)?p7(this,globalThis.BigInt(e),t):void 0}toCodecStringTree(){return pq(this,[mc])}getExpected(){return"bigint"}};class ph extends h7{_tag="Arrays";isMutable;elements;rest;encodingChecks;constructor(e,t,r,n,i,s,a,o){super(n,i,s,a),this.isMutable=e,this.elements=t,this.rest=r,this.encodingChecks=o;let l=t.findIndex(p3);if(-1!==l&&(t.slice(l+1).some(e=>!p3(e))||r.length>1))throw Error("A required element cannot follow an optional element. ts(1257)");if(r.length>1&&r.slice(1).some(p3))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,...a]=n,o=a.length;function l(e,t){return t<i?r[t]:t>=e?a[t-e]:s}return lH(function*(e,r){if("None"===e._tag)return e;let n=e.value;if(!Array.isArray(n))return yield*tJ(new hh(t,e));let s=n.length,a={ast:t,getParser:l,oinput:e,len:s,tailThreshold:Math.max(i,s-o),output:new globalThis.Array(s),issues:void 0,options:r},c=pm(r?.concurrency),u=pp(a,n,{concurrency:c?.concurrency,end:0===t.rest.length?i:Math.max(s,i+o)});if(u&&(yield*u),0===t.rest.length&&s>i)for(let o=i;o<=s-1;o++){let i=new hc([o],new hd(t,n[o]));if("all"!==r.errors)return yield*tJ(new hf(t,e,[i]));a.issues?a.issues.push(i):a.issues=[i]}return a.issues?yield*tJ(new hf(t,e,a.issues)):rk(a.output)})}_rebuild(e,t,r){let n=pQ(this.elements,e),i=pQ(this.rest,e);return n===this.elements&&i===this.rest&&t===this.checks&&r===this.encodingChecks?this:new ph(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 pp=ot({onItem(e,t,r){let n=r<e.len?rk(t):rx();return e.getParser(e.tailThreshold,r).parser(n,e.options)},step(e,t,r,n){if("Failure"===r._tag)return pg(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(p3(t.ast))return;let r=new hc([n],new hu(t.ast.context?.annotations));if("all"!==e.options.errors)return tJ(new hf(e.ast,e.oinput,[r]));e.issues?e.issues.push(r):e.issues=[r]}}}),pm=e=>(e="unbounded"===e?1/0:e??1)>1?{concurrency:e}:void 0,pg=(e,t,r,n)=>{if(0===n.cause.reasons.length)return n;let i=hE(n.cause);if(void 0===i)return tV(sf(n.cause,n=>new hf(t,e.oinput,[new hc([r],n)])));let s=new hc([r],i);if("all"!==e.options.errors)return tJ(new hf(t,e.oinput,[s]));e.issues?e.issues.push(s):e.issues=[s]},py="[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?";class pb{name;type;constructor(e,t){this.name=e,this.type=t}}class pv{decode;encode;constructor(e,t){this.decode=e,this.encode=t}flip(){return new pv(this.encode,this.decode)}}function pw(e){switch(e._tag){case"String":case"Number":case"Symbol":case"TemplateLiteral":return!0;case"Union":return e.types.every(pw);default:return!1}}class px{parameter;type;merge;constructor(e,t,r){if(!(pw(e)&&pw(p4(e))))throw Error(`Invalid index signature parameter ${e._tag}`);if(this.parameter=e,this.type=t,this.merge=r,p3(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 pk extends h7{_tag="Objects";propertySignatures;indexSignatures;encodingChecks;constructor(e,t,r,n,i,s,a){super(r,n,i,s),this.propertySignatures=e,this.indexSignatures=t,this.encodingChecks=a;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=[],n=new Set,i=[];for(let s of t.propertySignatures)r.push(s.name),n.add(s.name),i.push({ps:s,parser:e(s.type),name:s.name,type:s.type});let s=t.indexSignatures.length;if(0===t.propertySignatures.length&&0===t.indexSignatures.length)return p9(t,eC);let a=s>0?ot({onItem:lH(function*(r,[i,s]){let a=e(me(s.parameter))(rk(i),r.options),o=s9(a)?a:yield*aN(a);if("Failure"===o._tag){let e=pg(r,t,i,o);e&&(yield*e);return}let l=rk(r.input[i]),c=e(s.type)(l,r.options),u=s9(c)?c:yield*aN(c);if("Failure"===u._tag){let e=pg(r,t,i,u);e&&(yield*e);return}if("Some"===o.value._tag&&"Some"===u.value._tag){let e=o.value.value;if(n.has(i)||n.has(e))return;let t=u.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]);hr(r.out,n,i)}else hr(r.out,e,t)}}),step:(e,t,r)=>"Failure"===r._tag?r:void 0}):void 0;return lH(function*(e,o){let l;if("None"===e._tag)return e;let c=e.value;if(!("object"==typeof c&&null!==c&&!Array.isArray(c)))return yield*tJ(new hh(t,e));let u={},d={ast:t,oinput:e,input:c,out:u,issues:void 0,options:o},f="all"===o.errors,h="error"===o.onExcessProperty,p="preserve"===o.onExcessProperty;if(0===t.indexSignatures.length&&(h||p)){l=Reflect.ownKeys(c);for(let r=0;r<l.length;r++){let i=l[r];if(!n.has(i))if(h){let r=new hc([i],new hd(t,c[i]));if(!f)return yield*tJ(new hf(t,e,[r]));d.issues?d.issues.push(r):d.issues=[r];continue}else hr(u,i,c[i])}}let m=pm(o?.concurrency),g=pS(d,i,m);if(g&&(yield*g),a){let e=nP();for(let r=0;r<s;r++){let n=t.indexSignatures[r],i=function(e,t,r=h8){let n,i;return function t(s){switch(s._tag){case"String":case"TemplateLiteral":return(n??=Object.keys(e)).filter(e=>void 0!==s.matchPart(e,r));case"Number":return(n??=Object.keys(e)).filter(e=>void 0!==s.matchKey(e,r));case"Symbol":return(i??=Object.getOwnPropertySymbols(e)).filter(e=>void 0!==s.matchKey(e,r));case"Union":return[...new Set(s.types.flatMap(t))];default:return[]}}(me(p4(t)))}(c,n.parameter,o);for(let t=0;t<i.length;t++){let r=i[t];e.push([r,n])}}let r=a(d,e,m);r&&(yield*r)}if(d.issues)return yield*tJ(new hf(t,e,d.issues));if("original"===o.propertyOrder){let e=(l??Reflect.ownKeys(c)).concat(r),t={};for(let r of e)Object.hasOwn(u,r)&&hr(t,r,u[r]);return rk(t)}return rk(u)})}_rebuild(e,t,r,n,i){let s=pQ(this.propertySignatures,t=>{let r=e(t.type);return r===t.type?t:new pb(t.name,r)}),a=pQ(this.indexSignatures,n=>{let i=t(n.parameter),s=e(n.type),a=r?n.merge?.flip():n.merge;return i===n.parameter&&s===n.type&&a===n.merge?n:new px(i,s,a)});return s===this.propertySignatures&&a===this.indexSignatures&&n===this.checks&&i===this.encodingChecks?this:new pk(s,a,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 pS=ot({onItem(e,t){let r=Object.hasOwn(e.input,t.name)?rk(e.input[t.name]):rx();return t.parser(r,e.options)},step(e,t,r){if("Failure"===r._tag)return pg(e,e.ast,t.name,r);if("Some"===r.value._tag)hr(e.out,t.name,r.value.value);else if(!p3(t.type)){let r=new hc([t.name],new hu(t.type.context?.annotations));return"all"!==e.options.errors?tJ(new hf(e.ast,e.oinput,[r])):void(e.issues?e.issues.push(r):e.issues=[r])}}});function p_(e,t){return e?t?[...e,...t]:e:t}function p$(e,t,r){return new pk(Reflect.ownKeys(e).map(t=>new pb(t,e[t].ast)),[],r,t)}function pO(e){return e.ast}function pI(e,t,r){return new pT(e.map(pO),t,void 0,r)}function pC(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(!p3(t)){if(h0(t))return[{key:e.name,literal:t.literal}];if(h1(t))return[{key:e.name,literal:t.symbol}]}return[]});case"Arrays":return e.elements.flatMap((e,t)=>h0(e)&&!p3(e)?[{key:t,literal:e.literal}]:[]);case"Suspend":return pC(e.thunk())}}let pE=new WeakMap;function pA(e){return t=>{let r=p4(t);return"Literal"===r._tag?r.literal===e:"UniqueSymbol"!==r._tag||r.symbol===e}}class pT extends h7{_tag="Union";types;mode;encodingChecks;constructor(e,t,r,n,i,s,a){super(r,n,i,s),this.types=e,this.mode=t,this.encodingChecks=a}getParser(e){let t=this;return(r,n)=>{if("None"===r._tag)return lP(r);let i=r.value,s=function(e,t){let r=function(e){let t=pE.get(e);if(t)return t;t={};for(let r=0;r<e.length;r++){let n=p4(e[r]);if(hH(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),s=pC(n);for(let e of(t.byType??={},i))(t.byType[e]??=[]).push(r);if(s.length>0)for(let{key:e,literal:n}of(t.bySentinel??=new Map,s)){let i=t.bySentinel.get(e);i||t.bySentinel.set(e,i=new Map);let s=i.get(n);s||i.set(n,s=[]),s.push(r)}else for(let e of(t.otherwise??={},i))(t.otherwise[e]??=[]).push(r)}return pE.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(pA(e))}return i.map(e=>t[e])}return(r.byType?.[n]??[]).map(e=>t[e]).filter(pA(e))}(i,t.types),a={ast:t,recur:e,oinput:r,input:i,out:void 0,successes:[],issues:void 0,options:n},o=pm(n?.concurrency),l=pM(a,s,o?{...o,orderedStep:!0}:void 0);return l?s8(l,e=>a.out?lP(a.out):tJ(new hg(t,i,a.issues??[]))):a.out?lP(a.out):tJ(new hg(t,i,a.issues??[]))}}_rebuild(e,t,r){let n=pQ(this.types,e);return n===this.types&&t===this.checks&&r===this.encodingChecks?this:new pT(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=p4(t);switch(r._tag){case"Arrays":{let t=r.elements.filter(h0);if(t.length>0)return`${pF(r.isMutable)}[ ${t.map(t=>e(t)+(t.context?.isOptional?"?":"")).join(", ")}, ... ]`;break}case"Objects":{let t=r.propertySignatures.filter(e=>h0(e.type));if(t.length>0)return`{ ${t.map(t=>`${pF(t.type.context?.isMutable)}${ti(t.name)}${t.type.context?.isOptional?"?":""}: ${e(t.type)}`).join(", ")}, ... }`}}return e(r)}))).join(" | ")}}let pM=ot({onItem:(e,t)=>e.recur(t)(e.oinput,e.options),step(e,t,r){if("Failure"===r._tag){let t=hE(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),tJ(new hy(e.ast,e.input,e.successes));if(e.out=r.value,e.successes.push(t),"anyOf"===e.ast.mode)return ai}}}),pN=new pT([new ps("Infinity"),new ps("-Infinity"),new ps("NaN")],"anyOf"),pj=new h4(new pT([pc,pN],"anyOf"),new hU(hD(),hj(e=>globalThis.Number.isFinite(e)?e:globalThis.String(e))));function pF(e){return e?"":"readonly "}class pL extends h7{_tag="Suspend";thunk;constructor(e,t,r,n,i){let s,a;if(void 0!==r)throw Error("Cannot add checks to Suspend");super(t,void 0,n,i),this.thunk=(a=!1,()=>(a||(s=e(),a=!0),s))}getParser(e){return e(this.thunk())}recur(e){return new pL(()=>e(this.thunk()),this.annotations,void 0,void 0,this.context)}getExpected(e){return e(this.thunk())}}class pP extends eo{_tag="Filter";run;annotations;aborted;constructor(e,t,r=!1){super(),this.run=e,this.annotations=t,this.aborted=r}annotate(e){return new pP(this.run,{...this.annotations,...e},this.aborted)}abort(){return new pP(this.run,this.annotations,!0)}and(e,t){return new pD([this,e],t)}}class pD extends eo{_tag="FilterGroup";checks;annotations;constructor(e,t){super(),this.checks=e,this.annotations=t}annotate(e){return new pD(this.checks,{...this.annotations,...e})}and(e,t){return new pD([this,e],t)}}function pR(e,t,r=!1){return new pP((t,r,n)=>(function(e,t,r){if(Array.isArray(r))return nA(r)?1===r.length?hb(e,r[0]):new hf(t,rk(e),nR(r,t=>hb(e,t))):void 0;if(void 0!==r)return"boolean"==typeof r?r?void 0:new hp(rk(e)):hb(e,r)})(t,r,e(t,r,n)),t,r)}function pU(e,t){let r=e.source;return pR(t=>e.test(t),{expected:`a string matching the RegExp ${r}`,meta:{_tag:"isPattern",regExp:e},arbitrary:{constraint:{patterns:[e.source]}},...t})}function pB(e,t){let r=Object.getOwnPropertyDescriptors(e);return t(r),Object.create(Object.getPrototypeOf(e),r)}function pq(e,t){return e.encoding===t?e:pB(e,e=>{e.encoding.value=t})}function pK(e,t){return e.context===t?e:pB(e,e=>{e.context.value=t})}function pz(e){return e.encoding?pz(e.encoding[e.encoding.length-1].to):e}function pV(e,t){if(e.checks){let r=e.checks[e.checks.length-1];return pJ(e,nC(e.checks.slice(0,-1),r.annotate(t)))}return pB(e,e=>{e.annotations.value={...e.annotations.value,...t}})}function pJ(e,t){if("Suspend"===e._tag&&void 0!==t)throw Error("Cannot add checks to Suspend");return e.checks===t?e:pB(e,e=>{e.checks.value=t})}function pW(e,t){return pJ(e,p_(e.checks,t))}function pY(e,t){let r=e[e.length-1],n=t(r.to);return n!==r.to?nC(e.slice(0,e.length-1),new h4(n,r.transformation)):e}function pG(e){return t=>t.encoding?pq(t,pY(t.encoding,e)):t}function pH(e){return eg(function t(r){return r.encoding?pq(r,pY(r.encoding,t)):e(r)})}function pQ(e,t){let r=!1,n=Array(e.length);for(let i=0;i<e.length;i++){let s=e[i],a=t(s);a!==s&&(r=!0),n[i]=a}return r?n:e}function pZ(e,t){let r=e.context?new h6(e.context.isOptional,e.context.isMutable,e.context.defaultValue,{...e.context.annotations,...t}):new h6(!1,!1,void 0,t);return pK(e,r)}let pX=pG(p0);function p0(e){let t=e.context?!1===e.context.isOptional?new h6(!0,e.context.isMutable,e.context.defaultValue,e.context.annotations):e.context:new h6(!0,!1);return pX(pK(e,t))}let p1=pG(p2);function p2(e){let t=e.context?!1===e.context.isMutable?new h6(e.context.isOptional,!0,e.context.defaultValue,e.context.annotations):e.context:new h6(!1,!0);return p1(pK(e,t))}function p3(e){return e.context?.isOptional??!1}let p5=eg(e=>{if(e.encoding)return p5(pq(e,void 0));let t=e.recur?.(p5)??e,r=t.encodingChecks;return r?pB(t,n=>{n.encodingChecks.value=void 0,t===e&&(n.checks.value=p_(t.checks,r))}):t}),p4=eg(e=>p5(p8(e))),p8=eg(e=>e.encoding?function(e,t){let r=t.length,n=t[r-1],i=[new h4(p8(pq(e,void 0)),t[0].transformation.flip())];for(let e=1;e<r;e++)i.unshift(new h4(p8(t[e-1].to),t[e].transformation.flip()));let s=p8(n.to);return s.encoding?pq(s,[...s.encoding,...i]):pq(s,i)}(e,e.encoding):e.flip?.(p8)??e.recur?.(p8)??e);function p6(e,t){let r=sj(rk(t));return n=>"None"===n._tag?sU:n.value===t?r:tJ(new hh(e,n))}function p9(e,t){return r=>"None"===r._tag?sU:t(r.value)?lP(r):tJ(new hh(e,r))}function p7(e,t,r){if(r?.disableChecks||void 0===e.checks)return t;let n=[];return mf(e.checks,t,n,e,r),0===n.length?t:void 0}let me=pH(e=>{switch(e._tag){default:return e;case"Number":return e.toCodecStringTree();case"Union":return e.recur(me)}}),mt=pH(e=>{switch(e._tag){default:return e;case"Symbol":case"UniqueSymbol":return e.toCodecStringTree();case"Union":return e.recur(mt)}}),mr=pH(e=>{switch(e._tag){default:return e;case"Number":case"Literal":case"BigInt":return e.toCodecStringTree();case"Union":return e.recur(mr)}}),mn=new globalThis.RegExp(`^${py}$`),mi=new globalThis.RegExp(`(?:${py}|Infinity|-Infinity|NaN)`),ms=pW(po,[pU(mn,{expected:"a string representing a finite number",meta:{_tag:"isStringFinite",regExp:mn},...void 0})]),ma=new h4(ms,hV),mo=new h4(new pT([ms,pN],"anyOf"),hV),ml=new globalThis.RegExp("^-?\\d+$"),mc=new h4(pW(po,[pU(ml,{expected:"a string representing a bigint",meta:{_tag:"isStringBigInt",regExp:ml},expected:"a string representing a bigint"})]),hJ),mu=new globalThis.RegExp("^Symbol\\((.*)\\)$"),md=new h4(pW(po,[pU(mu,{expected:"a string representing a symbol",meta:{_tag:"isStringSymbol",regExp:mu},...void 0})]),new hU(hj(e=>globalThis.Symbol.for(mu.exec(e)[1])),hF(e=>void 0!==globalThis.Symbol.keyFor(e)?lP(globalThis.String(e)):tJ(new hm(rk(e),{message:"cannot serialize to string, Symbol is not registered"})))));function mf(e,t,r,n,i){for(let s=0;s<e.length;s++){let a=e[s];if("FilterGroup"===a._tag)mf(a.checks,t,r,n,i);else{let e=a.run(t,n,i);if(e&&(r.push(new ho(t,a,e)),a.aborted||i?.errors!=="all"))return}}}let mh="~effect/Schema/Class",mp="~structural",mm=new pe([],()=>(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 s=i?t.every(e):Object.keys(t).every(r=>e(t[r]));return r.delete(t),s&&n.add(t),s}(e))?lP(e):tJ(new hh(t,rk(e)))},{typeConstructor:{_tag:"effect/Json"},generation:{runtime:"Schema.Json",Type:"Schema.Json"},expected:"JSON value",toCodecJson:()=>new h4(pi,hz),toArbitrary:()=>e=>e.jsonValue()}),mg=new h4(new pe([],()=>(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))?lP(e):tJ(new hh(t,rk(e)))},{expected:"StringTree"}),hz),my="~effect/SchemaError/SchemaError";class mb extends l8("SchemaError"){[my]=my;constructor(e){super({issue:e})}get message(){return this.issue.toString()}toString(){return`SchemaError(${this.message})`}}let mv=eg(e=>{switch(e._tag){case"Declaration":{let t=e.annotations?.[mh];if(e_(t)){let r=t(e.typeParameters),n=mv(r.to);return pq(e,n===r.to?[r]:[new h4(n,r.transformation)])}return e}case"Objects":case"Arrays":return e.recur(e=>{let t=e.context?.defaultValue;return t?pq(mv(e),t):mv(e)});case"Suspend":return e.recur(mv);default:return e}});function mw(e){let t=m_(mv(p5(e.ast)));return(e,r)=>t(e,r?.disableChecks?r?.parseOptions?{...r.parseOptions,disableChecks:!0}:{disableChecks:!0}:r?.parseOptions)}function mx(e){let t=mw(e);return(e,r)=>{let n=oc(t(e,r));return"Success"===n._tag?rk(n.value):(hA(n.cause,"Option adapter can only return none for schema issues"),rx())}}function mk(e,t){let r=m_(e.ast);return void 0===t?r:(e,n)=>r(e,mS(t,n))}let mS=(e,t)=>void 0===t?e:{...e,...t};function m_(e){let t=mI(e);return(e,r)=>s7(t(rk(e),r??h8),e=>"None"===e._tag?tJ(new hp(e)):lP(e.value))}function m$(e){return(t,r)=>oc(e(t,r))}function mO(e,t){return am(e,e=>lR(()=>sf(e,t)))}let mI=eg(e=>{let t,r=e.checks,n=e.encoding,i=n?.length??0,s=e.encodingChecks,a=(r?r[r.length-1].annotations:e.annotations)?.parseOptions;if(!e.context&&!n&&!r&&!s)return(r,n)=>(t??=e.getParser(mI),a&&(n={...n,...a}),t(r,n));let o=h2(e)||h3(e)||hG(e)&&e.typeParameters.length>0,l=r&&o?r.filter(e=>e.annotations?.[mp]):void 0;return(o,c)=>{let u;if(a&&(c={...c,...a}),n){for(let e=i-1;e>=0;e--){let t=n[e],r=mI(t.to);if(u=u?s7(u,e=>r(e,c)):r(o,c),"Transformation"===t.transformation._tag){let e=t.transformation.decode;u=s7(u,t=>e.run(t,c))}else u=t.transformation.decode(u,c)}u=mO(u,t=>new hl(e,o,t))}t??=e.getParser(mI);let d=n=>{let i=t(n,c);return s&&!c?.disableChecks&&(i=s7(i,t=>{if(r$(n)&&r$(t)){let t=[];if(mf(s,n.value,t,e,c),t4(t))return tJ(new hf(e,n,t))}return lP(t)})),r&&!c?.disableChecks&&(c?.errors==="all"&&l&&l.length>0&&r$(n)&&(i=mO(i,t=>{let r=[];return mf(l,n.value,r,e,c),t4(r)?"Composite"===t._tag&&t.ast===e?new hf(e,t.actual,[...t.issues,...r]):new hf(e,n,[t,...r]):t})),i=s7(i,t=>{if(r$(t)){let n=t.value,i=[];if(mf(r,n,i,e,c),t4(i))return tJ(new hf(e,t,i))}return lP(t)})),i};return u?s7(u,d):d(o)}}),mC="~effect/Schema/Schema",mE={[mC]:mC,pipe(){return es(this,arguments)},annotate(e){return this.rebuild(pV(this.ast,e))},annotateKey(e){return this.rebuild(pZ(this.ast,e))},check(...e){return this.rebuild(pW(this.ast,e))}};function mA(e,t){let r,n=Object.create(mE);t&&Object.assign(n,t),n.ast=e,n.rebuild=e=>mA(e,t);let i=mw(n);return n.makeEffect=(e,t)=>mT(i(e,t)),r=mw(n),n.make=(e,t)=>{let n=oc(r(e,t));if("Success"===n._tag)return n.value;let i=hA(n.cause,"Constructor adapter can only throw schema issues");throw Error(i.toString(),{cause:i})},n.makeOption=mx(n),n}function mT(e){return am(e,e=>lR(()=>sf(e,e=>new mb(e))))}let mM=mN(function(e){switch(e._tag){case"BigInt":case"Symbol":case"UniqueSymbol":return 0;default:return 1}});function mN(e){return t=>{let r=new Map;for(let e=0;e<t.length;e++)r.set(p4(t[e]),e);let n=[...t].sort((t,n)=>{t=p4(t),n=p4(n);let i=e(t),s=e(n);return i!==s?i-s:r.get(t)-r.get(n)});return n.some((e,r)=>e!==t[r])?n:t}}let mj=new Set(["~structural","~sentinels","meta","arbitrary","toArbitrary","toEquivalence","toFormatter","toCodec","toCodecJson","toCodecIso",mh]),mF=new Set(["title","description","default","examples","readOnly","writeOnly","format","contentEncoding","contentMediaType","contentSchema"]);function mL(e){if(void 0!==e){let t=nw(e,(e,t)=>!mj.has(t));if(!nb(t))return{annotations:t}}}function mP(e,t){return e.some(e=>{switch(e._tag){case"Filter":return e.meta._tag===t;case"FilterGroup":return mP(e.checks,t)}})}function mD(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 mR(e){switch(e._tag){case"Literal":return globalThis.String(e.literal).replace(/[/\\^$*+?.()|[\]{}]/g,"\\$&");case"String":return"[\\s\\S]*?";case"Number":return py;case"TemplateLiteral":return e.parts.map(mR).join("");case"Union":return e.types.map(mR).join("|");default:throw new globalThis.Error("Unsupported part",{cause:e})}}function mU(){return(e,t,r)=>mW(new pe(e.map(pO),e=>t(e.map(e=>mW(e))),r))}function mB(e){return t=>mX(mX(t).annotate(e))}function mq(e){return t=>t.rebuild(pZ(t.ast,e))}function mK(e){return"Success"===e._tag?e.value:{issues:[{message:sw(e.cause)}]}}let mz=function(e){let t;return t=m$(m_(p5(e.ast))),e=>{let r=t(e,h8);return"Success"===r._tag||(hA(r.cause,"Type guard adapter can only return false for schema issues"),!1)}};function mV(e,t){let r=mk(e,t);return(e,t)=>mT(r(e,t))}function mJ(e,t){let r,n=(r=m$(mk(e,t)),(e,t)=>{let n=r(e,t);return"Success"===n._tag?rp(n.value):rh(hA(n.cause,"Result adapter can only return schema issues"))});return(e,t)=>nk(n(e,t),e=>new mb(e))}let mW=mA,mY=e=>mW(p0(e.ast),{schema:e}),mG=e=>mY(gi(e)),mH=e=>mW(p2(e.ast),{schema:e}),mQ=e=>mW(p4(e.ast),{schema:e}),mZ="~effect/Schema/flip";function mX(e){return eT(e,mZ)&&e[mZ]===mZ?e.schema.rebuild(p8(e.ast)):mW(p8(e.ast),{[mZ]:mZ,schema:e})}function m0(e){let t=mW(new ps(e),{literal:e,transform:r=>t.pipe(go(m0(r),{decode:hj(()=>r),encode:hj(()=>e)}))});return t}let m1=mW(pi),m2=mW(pn),m3=mW(po),m5=mW(pc),m4=mW(pu),m8=mW(pd);function m6(e,t){return mW(e,{fields:t,mapFields(e,t){let r=e(this.fields);return m6(p$(r,t?.unsafePreserveChecks?this.ast.checks:void 0),r)}})}function m9(e){return m6(p$(e,void 0),e)}function m7(e,t,r){let n=r?.keyValueCombiner?.decode||r?.keyValueCombiner?.encode?new pv(r.keyValueCombiner.decode,r.keyValueCombiner.encode):void 0;return mW(function(e,t,r){let n,i,{literals:s,parameters:a}=(n=[],i=[],!function e(t){switch(t._tag){case"Literal":var r;(ev(r=t.literal)||ew(r)||eS(r))&&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 pk(s.map(e=>new pb(e,t)),a.map(e=>new px(e,t,r)))}(e.ast,t.ast,n),{key:e,value:t})}let ge=e=>mW(new ph(!1,[],[e.ast]),{value:e}),gt=e=>mW(new ph(!0,e.ast.elements,e.ast.rest),{schema:e});function gr(e,t){return function e(t,r){return mW(t,{members:r,mapMembers(t,r){let n=t(this.members);return e(pI(n,this.ast.mode,r?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}(pI(e,t?.mode??"anyOf",void 0),e)}function gn(e){let t=e.map(m0);return mW(pI(t,"anyOf",void 0),{literals:e,members:t,mapMembers(e){return gr(e(this.members))},pick:e=>gn(e),transform:e=>gr(t.map((t,r)=>t.transform(e[r])))})}let gi=e=>gr([e,m2]);function gs(e){return mW(new pL(()=>e().ast))}function ga(e,t){return r=>mW(pW(r.ast,[new pP(t=>e(t)?void 0:new hp(rk(t)),t,!0)]),{schema:r})}function go(e,t){return r=>{var n,i,s;let a;return mW((n=r.ast,i=e.ast,s=t?hB(t):hz,a=new h4(n,s),pq(i,i.encoding?[...i.encoding,a]:[a])),{from:r,to:e})}}function gl(e){return am(e,e=>lR(()=>sf(e,e=>e.issue)))}function gc(e,t){let r=t?.encodingStrategy==="omit"?new hT(()=>sU):hM;return t=>mG(mQ(t)).pipe(go(t,{decode:hL(gl(e)),encode:r}))}function gu(e){var t;return m0(e).pipe((t=lP(e),e=>{var r;let n,i;return mW((r=e.ast,n=[new h4(pi,new hU(hL(gl(t)),hM))],i=r.context?new h6(r.context.isOptional,r.context.isMutable,n,r.context.annotations):new h6(!1,!1,n),pK(r,i)),{schema:e})}))}let gd=pR;function gf(e){return gd(e=>globalThis.Number.isFinite(e),{expected:"a finite number",meta:{_tag:"isFinite"},arbitrary:{constraint:{noInfinity:!0,noNaN:!0}},...e})}let gh=(F=rv((er={order:rg,annotate:e=>({meta:{_tag:"isGreaterThan",exclusiveMinimum:e}})}).order),L=er.formatter??tr,(e,t)=>gd(t=>F(t,e),{expected:`a value greater than ${L(e)}`,arbitrary:{constraint:{ordered:{order:er.order,minimum:e,exclusiveMinimum:!0}}},...er.annotate?.(e),...t})),gp=(W=(J=(G={order:rg,annotate:e=>({meta:{_tag:"isGreaterThanOrEqualTo",minimum:e}})}).order,el(2,(e,t)=>-1!==J(e,t))),Y=G.formatter??tr,(e,t)=>gd(t=>W(t,e),{expected:`a value greater than or equal to ${Y(e)}`,arbitrary:{constraint:{ordered:{order:G.order,minimum:e}}},...G.annotate?.(e),...t}));function gm(e,t){return e=Math.max(0,Math.floor(e)),gd(t=>t.length>=e,{expected:`a value with a length of at least ${e}`,meta:{_tag:"isMinLength",minLength:e},[mp]:!0,arbitrary:{constraint:{minLength:e}},...t})}let gg=m3.check(gm(1,void 0)),gy=[];function gb(e){var t;let r,n,i=e?.includeStack===!0|2*(e?.excludeCause===!0),s=gy[i];if(void 0!==s)return s;let a=gF.pipe(go(m1,hK({decode:hW,encode:(t=(e=>{switch(e){case 0:return;case 1:return{includeStack:!0};case 2:return{excludeCause:!0};case 3:return{includeStack:!0,excludeCause:!0}}})(i),r=new WeakSet,n=e=>{if(e instanceof Error){var i;let s;if(r.has(e))return"[Circular]";r.add(e);let a=(i=n,s={name:e.name,message:"string"==typeof e.message?e.message:""},t?.includeStack&&"string"==typeof e.stack&&(s.stack=e.stack),t?.excludeCause||void 0===e.cause||(s.cause=i(e.cause)),s);return r.delete(e),a}try{let t=ta(e);return void 0===t?tr(e):JSON.parse(t)}catch{return tr(e)}})})));return gy[i]=a,a}gd(e=>!isNaN(e.getTime()),{expected:"a valid date",meta:{_tag:"isDateValid"},arbitrary:{constraint:{valid:!0}},...void 0});let gv=m5.check(gf()),gw=m5.check(gd(e=>globalThis.Number.isSafeInteger(e),{expected:"an integer",meta:{_tag:"isInt"},arbitrary:{constraint:{integer:!0}},...void 0})),gx=gr([gv,m8,m3]),gk=globalThis.Symbol.for("immer-draftable"),gS={};function g_(e,t,r,n,i){var s,a,o;let l,c=(s=r,a=t,o=n,e=>{if(void 0!==l)return l;let t=new hU(hj(t=>new e(t)),hM);return l=go(mW(new pe([s.ast],()=>(t,r)=>t instanceof e||eT(t,g$(a))?lP(t):tJ(new hh(r,rk(t))),{identifier:a,[mh]:([e])=>new h4(e,t),toCodec:([e])=>new h4(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":pC(s.ast),...o})),t)(s)}),u=g$(t),d=class extends e{constructor(...[e,t]){let n=t?.["~payload"],i=n?.token===gS?n.value:r.make(e??{},t);super(i,{...t,disableChecks:!0,"~payload":{token:gS,value:i}})}static [mC]=mC;get[u](){return u}static [gk]=!0;static identifier=t;static fields=r.fields;static get ast(){return c(this).ast}static pipe(){return es(this,arguments)}static rebuild(e){return c(this).rebuild(e)}static make(e,t){return new this(e,t)}static makeOption(e,t){return mx(c(this))(e??{},t)}static makeEffect(e,t){return c(this).makeEffect(e??{},t)}static annotate(e){return this.rebuild(pV(this.ast,e))}static annotateKey(e){return this.rebuild(pZ(this.ast,e))}static check(...e){return this.rebuild(pW(this.ast,e))}static extend(e){return(t,n)=>{let s=gO(t)?t:m9(t),a={...r.fields,...s.fields},o=p$(a,r.ast.checks,{identifier:e});return g_(this,e,m6(pW(o,s.ast.checks),a),n,i)}}static mapFields(e,t){return r.mapFields(e,t)}};return void 0!==i&&Object.assign(d.prototype,i(t)),d}function g$(e){return`~effect/Schema/Class/${e}`}function gO(e){return eT(e,mC)&&e[mC]===mC}let gI=e=>(t,r)=>g_(l3,e,gO(t)?t:m9(t),r,e=>({toString(){return`${e}(${tr({...this})})`}})),gC=e=>(t,r)=>g_(tH,e,gO(t)?t:m9(t),r,e=>({name:e})),gE=e=>(t,r,n)=>{let i=gO(r)?r.mapFields(e=>({_tag:gu(t),...e}),{unsafePreserveChecks:!0}):m9({_tag:gu(t),...r});return gC(e??t)(i,n)},gA=mN(function(e){switch(e._tag){case"Null":case"Boolean":case"Number":case"BigInt":case"Symbol":case"UniqueSymbol":return 0;default:return 1}}),gT=new h4(new ps("null"),new hU(hj(()=>null),hj(()=>"null"))),gM=new h4(new pT([new ps("true"),new ps("false")],"anyOf"),new hU(hj(e=>"true"===e),hP())),gN=pH(e=>{if(h5(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(e_(n)){let r=n(hG(e)?e.typeParameters.map(e=>mW(t(p4(e)))):[]),i=t(r.to);return pq(e,i===r.to?[r]:[new h4(i,r.transformation)])}return r(e)}case"Null":return pq(e,[gT]);case"Boolean":return pq(e,[gM]);case"Unknown":case"ObjectKeyword":return pq(e,[mg]);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,mt);case"Union":{let r=gA(e.types);if(r!==e.types)return new pT(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,gN,e=>pq(e,[gj]));return t!==e&&p3(e)?pX(t):t}),gj=new h4(pn,new hU(hM,hj(()=>void 0))),gF=mW(mm),gL="~effect/platform/Terminal",gP="effect/platform/Terminal/QuitError";class gD extends gC("QuitError")({_tag:gu("QuitError")}){[gP]=gP}let gR=nQ("effect/platform/Terminal"),gU=t("node:readline"),gB=sG(function*(e=gq){let t,r,n=process.stdin,i=process.stdout,s=yield*(t={acquire:lK(sL(()=>{let e=gU.createInterface({input:n,escapeCodeTimeout:50});return gU.emitKeypressEvents(n,e),n.isTTY&&n.setRawMode(!0),e}),e=>sL(()=>{n.isTTY&&n.setRawMode(!1),e.close()}))},tY(e=>{let r=e.context,n=n7(r,aD),i=new dz(t.acquire,r,n,t.idleTimeToLive?ig(t.idleTimeToLive):void 0);return s1(aq(n,()=>{let e="Acquired"===i.state._tag?aR(i.state.scope,ai):sK;return i.state=dq,e}),i)})),a=sL(()=>i.columns??0),o=sL(()=>i.rows??0),l=lD(function*(){let t;yield*dV(s);let r=yield*cu(),i=(t,n)=>{let i={input:rP(t),key:{name:n.name??"",ctrl:!!n.ctrl,meta:!!n.meta,shift:!!n.shift}};cf(r,i),e(i)&&cm(r)};return yield*(t=()=>sL(()=>n.off("keypress",i)),s8(aD,e=>au(r=>aq(e,e=>ad(t(),r))))),n.on("keypress",i),r});return r={columns:a,rows:o,readInput:l,readLine:lq(s8(dV(s),e=>sW(t=>{let r=e=>t(lP(e));return e.once("line",r),sL(()=>e.off("line",r))}))),display:e=>a1(sW(t=>{i.write(e,e=>null==e?t(sK):t(tJ(cr({module:"Terminal",method:"display",description:"Failed to write prompt to stdout",cause:e}))))}))},gR.of({...r,[gL]:gL})});function gq(e){return e.key.ctrl&&("c"===e.key.name||"d"===e.key.name)}let gK=lC(uH,l$(dM,u4,dL,dR,lx(gR,gB(gq)))),gz=/[,;]\s*(?:id|label|kind|group|source|target|title|direction|nodes|edges)\s*:?\s*$/i;function gV(e){let t=e.trim();for(;;){let e=t.replace(gz,"").trim();if(e===t)return t;t=e}}class gJ extends gI("ContractSchemaIssue")({code:g6("custom"),message:m3,path:ge(gx)},{identifier:void 0}){}class gW extends gE()("ContractSchemaError",{issues:ge(mQ(gJ))}){}let gY=e=>{var t;if("InvalidType"!==e._tag)return hv(e);let r=r$(e.actual)?e.actual.value:void 0;return`Invalid input: expected ${hQ(t=e.ast)?"string":hZ(t)?"number":hX(t)?"boolean":h2(t)?"array":h3(t)?"object":h0(t)?JSON.stringify(t.literal):"value"}, received ${null===r?"null":Array.isArray(r)?"array":typeof r}`},gG=hx({leafHook:gY});function gH(e){return"string"==typeof e||"number"==typeof e||"symbol"==typeof e}function gQ(e,t){let r,n=mJ(e,{errors:"all"})(t);return rf(n)?{data:n.success,success:!0}:{error:new gW({issues:(r=gG(n.failure.issue).issues.map(e=>{let t=(e.path??[]).flatMap(e=>{let t=gH(e)?e:null!==e&&"object"==typeof e&&"key"in e&&gH(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 gZ(e){return Object.assign(e,{parse:t=>(function(e,t){let r=gQ(e,t);if(r.success)return r.data;throw r.error})(e,t),safeParse:t=>gQ(e,t)})}let gX=new Set(["const","exclusiveMaximum","exclusiveMinimum","maximum","maxLength","minimum","minItems","minLength","pattern"]);function g0(e){var t,r;let n,i,s=(t=mW(p5((n=e).ast),{schema:n}),r={includeAnnotationKey:e=>gX.has(e)},{dialect:"draft-2020-12",schema:(i=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,s=nv(e.references,e=>a(e));return{dialect:"draft-2020-12",schemas:nR(e.representations,e=>a(e)),definitions:s};function a(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 a(t.encodedSchema);case"Suspend":return a(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=a(t.contentSchema)),e}case"Number":return mP(t.checks,"isInt")?{type:"integer"}:mP(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 a({_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(mR).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=a(e.type),n=o(e.annotations);return n?mD(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=a(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={},s=[];for(let e of t.propertySignatures){let t=e.name;if("string"!=typeof t)throw new globalThis.Error(`Unsupported property signature name: ${tr(t)}`);let r=a(e.type),n=o(e.annotations);i[t]=n?mD(r,n):r,e.isOptional||s.push(t)}Object.keys(i).length>0&&(r.properties=i),s.length>0&&(r.required=s),r.additionalProperties=n;let l={};for(let n of t.indexSignatures){let t=a(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(mR).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),eA(r.additionalProperties)&&nb(r.additionalProperties)&&delete r.additionalProperties,r}case"Union":{let e=t.types.map(a);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,s;for(let e of(i=t.checks,s=r.type,i.map(function e(t){switch(t._tag){case"Filter":var r=t,n=s;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:a(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=mD(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||mF.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:nR(e,e=>a(e)),references:t};function s(e){let t=e,r=0;for(;n.has(t);)t=`${e}${++r}`;return n.add(t),t}function a(e,n){let l=r.get(e);if(void 0!==l)return{_tag:"Reference",$ref:l};let c=pz(e),u=hn(e)??n;if(e!==c)return a(c,u);if(void 0!==u){let n=s(u);r.set(e,n);let i=o(e),a=t[u];return void 0!==a&&eZ(i,a)?(r.set(e,u),{_tag:"Reference",$ref:u}):(t[n]=i,{_tag:"Reference",$ref:n})}if(i.has(e)){let t=s(`${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){var t;let r=mL(e.annotations);switch(e._tag){case"Declaration":{let t,n=a(e_(t=e.annotations?.toCodecJson??e.annotations?.toCodec)?pq(e,[t(e.typeParameters.map(e=>mA(p4(e))))]):pt);return{_tag:"Declaration",typeParameters:e.typeParameters.map(e=>a(e)),encodedSchema:n,checks:l(e.checks),...r}}case"Null":case"Undefined":case"Void":case"Never":case"Unknown":case"Any":case"Boolean":case"Symbol":case"ObjectKeyword":return{_tag:e._tag,...r};case"String":{let n=e.annotations?.contentMediaType,i=e.annotations?.contentSchema;return{_tag:e._tag,checks:l(e.checks),...r,..."string"==typeof n&&eT(t=i,h9)&&t[h9]===h9?{contentSchema:a(i)}:void 0}}case"Number":case"BigInt":return{_tag:e._tag,checks:l(e.checks),...r};case"Literal":return{_tag:e._tag,literal:e.literal,...r};case"UniqueSymbol":return{_tag:e._tag,symbol:e.symbol,...r};case"Enum":return{_tag:e._tag,enums:e.enums,...r};case"TemplateLiteral":return{_tag:e._tag,parts:e.parts.map(e=>a(e)),...r};case"Arrays":return{_tag:e._tag,elements:e.elements.map(e=>{let t=pz(e);return{isOptional:p3(t),type:a(e),...mL(t.context?.annotations)}}),rest:e.rest.map(e=>a(e)),checks:l(e.checks),...r};case"Objects":return{_tag:e._tag,propertySignatures:e.propertySignatures.map(e=>{let t=pz(e.type);return{name:e.name,type:a(e.type),isOptional:p3(t),isMutable:t.context?.isMutable??!1,...mL(t.context?.annotations)}}),indexSignatures:e.indexSignatures.map(e=>({parameter:a(e.parameter),type:a(e.type)})),checks:l(e.checks),...r};case"Union":{let t=mM(e.types);return{_tag:e._tag,types:t.map(e=>a(e)),mode:e.mode,...r}}case"Suspend":return{_tag:"Suspend",checks:[],thunk:a(e.thunk()),...r}}}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:a(t.propertyNames)}:t,...mL(e.annotations)};return}case"FilterGroup":{let t=l(e.checks);if(t4(t))return{_tag:"FilterGroup",checks:t,...mL(e.annotations)}}}}).filter(e=>void 0!==e):[]}}([e]);return{representation:r[0],references:t}}(t.ast),r)).schema,definitions:i.definitions});return{$schema:"https://json-schema.org/draft/2020-12/schema",...s.schema,...0===Object.keys(s.definitions).length?{}:{$defs:s.definitions}}}function g1(e){return ge(e).pipe(gt).annotate({minItems:1}).check(gd(e=>e.length>=1,{message:"Too small: expected array to have >=1 items"}))}function g2(e){return mY(mU()([e],([e])=>(t,r,n)=>void 0===t?lP(void 0):mk(e)(t,n),{toCodecJson:([e])=>{let t,r;return t=e,r={decode:hM,encode:new hT(e=>lP(nt(e,e=>void 0!==e)))},new h4(t.ast,hB(r))}}))}function g3(e){return e.pipe(mq({messageMissingKey:"Invalid input: expected string, received undefined"}))}function g5(e){return e.pipe(mq({messageMissingKey:"Invalid input: expected object, received undefined"}))}function g4(e){return e.pipe(mq({messageMissingKey:"Invalid input: expected array, received undefined"}))}function g8(e){return gn(e).annotate({message:`Invalid option: expected one of ${e.map(e=>JSON.stringify(e)).join("|")}`})}function g6(e){return m0(e).pipe(go(m3.annotate({const:e}).pipe(ga(t=>t===e,{message:`Invalid literal value, expected ${JSON.stringify(e)}`}))))}function g9(e){return m0(e).pipe(go(m5.annotate({const:e}).pipe(ga(t=>t===e,{message:`Invalid literal value, expected ${JSON.stringify(e)}`}))))}function g7(e){return m0(e).pipe(go(m4.annotate({const:e}).pipe(ga(t=>t===e,{message:`Invalid literal value, expected ${JSON.stringify(e)}`}))))}let ye=m3.annotate({minLength:1}).check(gd(e=>e.length>=1,{message:"Too small: expected string to have >=1 characters"})),yt=g3(ye),yr=gv,yn=m5.annotate({exclusiveMinimum:0}).check(gf(),gd(e=>e>0,{message:"Too small: expected number to be >0"})),yi=/^#[0-9a-fA-F]{6}$/;function ys(e){return m3.annotate({pattern:yi.source,...void 0===e?{}:{default:e}}).check(gd(e=>yi.test(e),{message:`Invalid string: must match pattern /${yi.source}/`}))}let ya=ys();gZ(ya);let yo=["excalidraw","scene","png"],yl=["excalidraw","scene"],yc=Object.assign(gZ(g8(yo)),{options:yo}),yu=Object.assign(gZ(g8(yl)),{options:yl});class yd extends gI("ArtifactProvenance")({sourceArtifactId:yt.pipe(mH)},{identifier:void 0}){}gZ(yd);let yf=["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"],yh=Object.assign(gZ(g8(yf)),{options:yf}),yp=g8(["request","diagram","node","edge","artifact"]),ym=g8(["input","flowchart","mindmap","quality","render","export","storage"]);class yg extends gI("CodeModeIssueRef")({kind:yp,id:g2(ye),path:g2(ye)},{identifier:void 0}){}gZ(yg);class yy extends gI("CodeModeIssue")({code:yh,severity:g8(["error","warning"]),stage:ym,ref:g2(yg),message:yt,hint:yt},{identifier:void 0}){}gZ(yy);let yb=["start","process","decision","end"],yv=Object.assign(gZ(g8(yb)),{options:yb}),yw=["setDefaultStyle","setStyle","setShape","translate","replaceText","rerouteEdges"];Object.assign(gZ(g8(yw)),{options:yw});class yx extends gI("FlowchartSpecNode")({id:yt,label:yt,kind:yv,description:g2(ye)},{identifier:void 0}){}class yk extends gI("FlowchartSpecEdge")({id:g2(ye),source:yt,target:yt,label:g2(ye)},{identifier:void 0}){}let yS=g8(["TB","LR"]),y_=yS.annotate({default:"TB"}).pipe(gc(lP("TB")));class y$ extends gI("FlowchartSpecLayout")({direction:y_},{identifier:void 0}){}let yO="#000000",yI=ys(yO).pipe(gc(lP(yO))),yC="#ffffff",yE=ys(yC).pipe(gc(lP(yC)));class yA extends gI("FlowchartSpecStyle")({accentColor:yI,backgroundColor:yE},{identifier:void 0}){}let yT=[],yM=ge(yk).pipe(gt).annotate({default:yT}).pipe(gc(lP(yT))),yN={direction:"TB"},yj=y$.annotate({default:yN}).pipe(gc(lP(yN))),yF={accentColor:"#000000",backgroundColor:"#ffffff"},yL=yA.annotate({default:yF}).pipe(gc(lP(yF)));class yP extends gI("FlowchartSpec")({id:g2(ye),title:yt,nodes:g4(g1(yx)),edges:yM,layout:yj,style:yL},{identifier:void 0}){}gZ(yP),gZ(yx),gZ(yk),gZ(y$),gZ(yA);let yD=g2(g1(yc)),yR=g2(ge(yu).pipe(gt)),yU=g2(m5.annotate({minimum:0,maximum:10}).check(gf(),gd(e=>e>=0,{message:"Too small: expected number to be >=0"}),gd(e=>e<=10,{message:"Too big: expected number to be <=10"})));class yB extends gI("BuildFlowchartOptions")({artifactFormats:yD,inlineArtifacts:yR,minQualityScore:yU},{identifier:void 0}){}gZ(g2(yB));class yq extends gI("BuildFlowchartRequest")({requestId:g2(ye),spec:g5(yP),options:g2(yB)},{identifier:void 0}){}let yK=yq.mapFields(({requestId:e,spec:t})=>({requestId:e,spec:t})),yz=(en={leafHook:gY,parseOptions:{errors:"all"}},P=mk(yK),D={errors:"all",...en?.parseOptions},R=hx(en),U=e=>{let t=new iz,r=ol(aT(P(e,D),{onFailure:R,onSuccess:e=>({value:e})}),{scheduler:t});r.currentDispatcher?.flush();let n=r.pollUnsafe();return n?mK(n):new Promise(e=>{r.addObserver(t=>{e(mK(t))})})},"~standard"in yK?("validate"in yK["~standard"]||Object.assign(yK["~standard"],{validate:U}),yK):Object.assign(yK,{"~standard":{version:1,vendor:"effect",validate:U}}));Object.assign(yz["~standard"],{jsonSchema:{input:()=>g0(yK),output:()=>g0(yK)}});let yV=Object.assign(gZ(yq),{omit:e=>yz}),yJ=m3.annotate({minLength:1}).check(gd(e=>e.length>=1,{message:"Too small: expected string to have >=1 characters"}),gd(function(e){let t=gV(e);return t.length>0&&!/^(?:""|''|``)$/.test(t)},{message:"Must contain semantic text after normalization."})),yW=g5(gs(()=>yY).annotate({identifier:"__schema0"})),yY=m9({label:g3(yJ),children:mY(ge(yW).pipe(gt))});gZ(yW);class yG extends gI("MindmapSpecLayout")({direction:g8(["LR","RL"]).annotate({default:"LR"}).pipe(gc(lP("LR")))},{identifier:void 0}){}let yH={direction:"LR"},yQ=yG.annotate({default:yH}).pipe(gc(lP(yH))),yZ={accentColor:"#7c3aed",backgroundColor:"#ffffff"},yX=yA.annotate({default:yZ}).pipe(gc(lP(yZ))),y0=m9({id:g2(ye),title:g3(yJ),root:yW,layout:yQ,style:yX});class y1 extends gI("MindmapSpec")(y0,{identifier:void 0}){}gZ(y1);let y2=m9({requestId:g2(ye),spec:g5(y0),options:g2(yB)});gI("BuildMindmapRequest")(y2,{identifier:void 0});let y3=gZ(y2);class y5 extends gI("ScenePoint")({x:yr.pipe(mH),y:yr.pipe(mH)},{identifier:void 0}){}gZ(y5);class y4 extends gI("NodeSceneElement")({type:g6("node"),id:yt,nodeId:yt,kind:g2(ye),shape:g8(["rectangle","ellipse","diamond","circle"]).pipe(mH),fillColor:g2(ya).pipe(mH),strokeColor:g2(ya).pipe(mH),textColor:g2(ya).pipe(mH),x:yr.pipe(mH),y:yr.pipe(mH),width:yn.pipe(mH),height:yn.pipe(mH),label:yt.pipe(mH)},{identifier:void 0}){}class y8 extends gI("TextSceneElement")({type:g6("text"),id:yt,containerId:g2(ye),textColor:g2(ya).pipe(mH),x:yr.pipe(mH),y:yr.pipe(mH),text:yt.pipe(mH),fontSize:yn,maxWidth:g2(yn)},{identifier:void 0}){}class y6 extends gI("ArrowSceneElement")({type:g6("arrow"),id:yt,edgeId:yt,sourceNodeId:yt,targetNodeId:yt.pipe(mH),strokeColor:g2(ya).pipe(mH),textColor:g2(ya).pipe(mH),points:g4(ge(y5).pipe(gt)).annotate({minItems:2}).check(gd(e=>e.length>=2,{message:"Too small: expected array to have >=2 items"})).pipe(mH),label:g2(ye).pipe(mH)},{identifier:void 0}){}gZ(y4),gZ(y8),gZ(y6);let y9=gr([y4,y8,y6],{mode:"oneOf"});class y7 extends gI("RenderedDiagramScene")({diagramId:yt,title:yt,width:yn.pipe(mH),height:yn.pipe(mH),accentColor:ya.pipe(mH),backgroundColor:ya.pipe(mH),elements:g4(ge(y9).pipe(gt))},{identifier:void 0}){}let be=gZ(y7),bt=m7(m3,m1).check(gd(e=>"string"==typeof e.id&&e.id.length>0&&"string"==typeof e.type&&e.type.length>0,{message:"Invalid input"}));gZ(bt);class br extends gI("ExcalidrawScene")({appState:m7(m3,m1),elements:ge(bt).pipe(gt)},{identifier:void 0}){}gZ(br);class bn extends br.extend("ExcalidrawFile")({files:m7(m3,m1),source:yt,type:g6("excalidraw"),version:g9(2)},{identifier:void 0}){}let bi=gZ(bn);class bs extends gI("GetArtifactRequest")({artifactId:yt,format:g2(yc),inline:g2(m4)},{identifier:void 0}){}let ba=gZ(bs);class bo extends gI("DiagramSelector")({ids:g2(ge(ye).pipe(gt)),nodeIds:g2(ge(ye).pipe(gt)),edgeIds:g2(ge(ye).pipe(gt)),kinds:g2(ge(yv).pipe(gt)),labels:g2(ge(ye).pipe(gt)),scope:g2(g8(["all","nodes","edges"]))},{identifier:void 0}){}gZ(bo);class bl extends gI("DiagramStylePatch")({strokeColor:g2(ya),fillColor:g2(ya),textColor:g2(ya),backgroundColor:g2(ya)},{identifier:void 0}){}gZ(bl);let bc=["rectangle","diamond","ellipse","circle"],bu=Object.assign(gZ(g8(bc)),{options:bc});class bd extends gI("SetDefaultStyleOperation")({op:g6("setDefaultStyle"),style:g5(bl)},{identifier:void 0}){}class bf extends gI("SetStyleOperation")({op:g6("setStyle"),selector:g5(bo),style:g5(bl)},{identifier:void 0}){}class bh extends gI("SetShapeOperation")({op:g6("setShape"),selector:g5(bo),shape:bu},{identifier:void 0}){}class bp extends gI("TranslateOperation")({op:g6("translate"),selector:g5(bo),dx:yr,dy:yr},{identifier:void 0}){}class bm extends gI("ReplaceTextOperation")({op:g6("replaceText"),selector:g5(bo),text:yt},{identifier:void 0}){}class bg extends gI("RerouteEdgesOperation")({op:g6("rerouteEdges"),selector:g2(bo)},{identifier:void 0}){}let by=gr([bd,bf,bh,bp,bm,bg],{mode:"oneOf"}).annotate({message:`Invalid discriminator value. Expected ${yw.map(e=>`'${e}'`).join(" | ")}`});class bb extends gI("ArtifactPatchSource")({artifactId:yt,format:g2(g6("scene"))},{identifier:void 0}){}class bv extends gI("InlineScenePatchSource")({scene:g5(y7)},{identifier:void 0}){}let bw=gr([bb,bv]).annotate({message:"Invalid input"});class bx extends gI("ApplyDiagramPatchOptions")({artifactFormats:yD,inlineArtifacts:yR,preserveConnectivity:g2(m4)},{identifier:void 0}){}gZ(g2(bx));class bk extends gI("ApplyDiagramPatchRequest")({requestId:g2(ye),source:bw.annotateKey({messageMissingKey:"Invalid input"}),operations:g4(g1(by)).pipe(mB({minItems:1})),options:g2(bx),intent:g2(ye)},{identifier:void 0}){}let bS=gZ(bk),b_=m9({id:ye,title:ye,nodes:ge(yx).pipe(gt),edges:ge(yk.mapFields(e=>({...e,id:ye}))).pipe(gt),layout:m9({direction:yS}),style:m9({accentColor:ya,backgroundColor:ya})}),b$=m9({id:ye,label:ye,children:ge(gs(()=>b$)).pipe(gt)}),bO=m9({id:ye,title:ye,root:b$,layout:m9({direction:g8(["LR","RL"])}),style:m9({accentColor:ya,backgroundColor:ya})}),bI=m9({code:m3,passed:m4,severity:g8(["error","warning"]),message:m3,refs:ge(yg).pipe(gt)}),bC=m9({accepted:m4,score:m5,threshold:m5,summary:m9({nodeCount:m5,edgeCount:m5}),checks:ge(bI).pipe(gt)}),bE=m9({format:yc,mimeType:m3,url:g2(m3),expiresAt:g2(m3),inline:g2(m1),sizeBytes:g2(m5)}),bA=m9({artifactId:m3,diagramId:m3,formats:ge(bE).pipe(gt),provenance:g2(yd),preview:g2(bE)}),bT=m9({artifactId:g2(m3),diagramId:g2(m3),formats:g2(ge(bE).pipe(gt))});class bM extends gI("BuildFlowchartAccepted")({ok:g7(!0),status:g6("accepted"),buildId:m3,requestId:g2(m3),normalizedSpec:b_,quality:bC,artifact:bA,issues:ge(yy).pipe(gt)},{identifier:void 0}){}class bN extends gI("BuildFlowchartRejected")({ok:g7(!1),status:g8(["invalid_input","invalid_flowchart","quality_failed","render_failed","export_failed","storage_failed"]),buildId:g2(m3),requestId:g2(m3),normalizedSpec:g2(b_),quality:g2(bC),partial:g2(bT),issues:ge(yy).pipe(gt)},{identifier:void 0}){}gr([bM,bN]);class bj extends gI("BuildMindmapAccepted")({ok:g7(!0),status:g6("accepted"),buildId:m3,requestId:g2(m3),normalizedSpec:bO,quality:bC,artifact:bA,issues:ge(yy).pipe(gt)},{identifier:void 0}){}class bF extends gI("BuildMindmapRejected")({ok:g7(!1),status:g8(["invalid_input","invalid_mindmap","quality_failed","render_failed","export_failed","storage_failed"]),buildId:g2(m3),requestId:g2(m3),normalizedSpec:g2(bO),quality:g2(bC),partial:g2(bT),issues:ge(yy).pipe(gt)},{identifier:void 0}){}gr([bj,bF]);class bL extends gI("GetArtifactAccepted")({ok:g7(!0),artifactId:m3,diagramId:m3,format:yc,mimeType:m3,url:g2(m3),expiresAt:g2(m3),inline:g2(m1),sizeBytes:g2(m5),provenance:g2(yd)},{identifier:void 0}){}class bP extends gI("GetArtifactRejected")({ok:g7(!1),status:g8(["invalid_input","not_found","format_unavailable","expired","storage_failed"]),issues:ge(yy).pipe(gt)},{identifier:void 0}){}gr([bL,bP]);class bD extends gI("ApplyDiagramPatchAccepted")({ok:g7(!0),status:g6("accepted"),patchId:m3,requestId:g2(m3),sourceArtifactId:g2(m3),artifact:bA,issues:ge(yy).pipe(gt)},{identifier:void 0}){}class bR extends gI("ApplyDiagramPatchRejected")({ok:g7(!1),status:g8(["invalid_input","source_unavailable","target_not_found","unsupported_operation","connectivity_changed","render_failed","export_failed","storage_failed"]),patchId:g2(m3),requestId:g2(m3),sourceArtifactId:g2(m3),partial:g2(bT),issues:ge(yy).pipe(gt)},{identifier:void 0}){}gr([bD,bR]);let bU=gn(["read","readManifest","write"]);class bB extends gE()("CodeModeArtifactStorageError",{cause:gb(),message:m3,operation:bU}){}class bq extends nQ()("@sketchi/diagram-agent/CodeModeArtifactStorage"){}let bK={excalidraw:"application/vnd.excalidraw+json",png:"image/png",scene:"application/vnd.sketchi.scene+json"};function bz(e){return"excalidraw"===e||"scene"===e}function bV(e){return{format:e.format,mimeType:e.mimeType,sizeBytes:e.sizeBytes}}function bJ(e){return structuredClone(e)}function bW(e){return new TextEncoder().encode(JSON.stringify(e)).length}function bY(e){return t=>{var r;return bB.make({cause:t,message:(r="write"===e?"Artifact storage failed.":"Artifact read failed.",t instanceof Error?t.message:r),operation:e})}}let bG=lx(bq)(lK(sL(function(){let e=new Map,t=new Map;return{close:sL(()=>{t.clear(),e.clear()}),storage:{read:lJ("codeMode.artifacts.memory.read")(function*(e,r){return yield*sz({try:()=>{let n=t.get(`${e}:${r}`);return n?{...n,data:bJ(n.data)}:null},catch:bY("read")})}),readManifest:lJ("codeMode.artifacts.memory.readManifest")(function*(t){return yield*sz({try:()=>{let r=e.get(t);return r?bJ(r):null},catch:bY("readManifest")})}),write:lJ("codeMode.artifacts.memory.write")(function*(r){let n=yield*oE;return yield*sz({try:()=>{var i;let s,a=r.formats.map(bV),o=r.provenance?bJ(r.provenance):void 0,l={artifactId:r.artifactId,diagramId:r.diagramId,formats:a,...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:bJ(n.data)});let c=r.formats.map(e=>{var t;return t=r.inlineFormats,{format:e.format,mimeType:e.mimeType,...bz(e.format)&&t.includes(e.format)?{inline:e.data}:{},sizeBytes:e.sizeBytes}});return s=(i={artifactId:r.artifactId,diagramId:r.diagramId,formats:c,...r.provenance?{provenance:bJ(r.provenance)}:{}}).formats.find(e=>"scene"===e.format),{artifactId:i.artifactId,diagramId:i.diagramId,formats:i.formats,...i.provenance?{provenance:i.provenance}:{},...s?{preview:s}:{}}},catch:bY("write")})})}}}),e=>e.close).pipe(ae(e=>e.storage)));function bH(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 bQ=gg,bZ=m7(m3,m1);function bX(e,t){return e.pipe(gc(lP(t)))}function b0(e,t){let r;return(r=mV(e,{errors:"all"}),(e,t)=>(function(e){let t=oc(e);if("Success"===t._tag)return t.value;throw function(e,t){let r;for(let n of e.reasons){if(!tL(n)||!eT(n.error,my))throw new globalThis.Error(t,{cause:e});r??=n.error}if(void 0===r)throw new globalThis.Error(t,{cause:e});return r}(t.cause,"Sync adapter can only throw schema errors")})(r(e,t)))(t)}let b1=hx();function b2(e){return Object.assign(e,{parse:t=>b0(e,t),safeParse:t=>{let r;return rf(r=mJ(e,{errors:"all"})(t))?{data:r.success,success:!0}:{error:{issues:b1(r.failure.issue).issues.map(e=>({message:e.message,path:(e.path??[]).map(e=>"object"==typeof e?e.key:e)}))},success:!1}}})}let b3=gn(["flowchart","mindmap"]),b5=gn(["TB","BT","LR","RL"]),b4=gn(["straight","orthogonal","curved"]);class b8 extends gI("DiagramNode")({id:bQ,label:bQ,group:mG(bQ),kind:mG(bQ),metadata:bX(bZ,{})}){}b2(b8);class b6 extends gI("DiagramEdge")({id:bQ,source:bQ,target:bQ,label:mG(bQ),metadata:bX(bZ,{})}){}b2(b6);let b9=m3.check(pU(/^#[0-9a-fA-F]{6}$/));class b7 extends gI("DiagramStyle")({accentColor:bX(b9,"#0f766e"),backgroundColor:bX(b9,"#ffffff")}){}b2(b7);class ve extends gI("DiagramLayout")({direction:bX(b5,"LR"),edgeRouting:bX(b4,"orthogonal")}){}b2(ve);class vt extends gI("IntermediateDiagram")({id:bQ,title:bQ,type:bX(b3,"flowchart"),nodes:ge(b8).pipe(gt).check(gm(1)),edges:bX(ge(b6).pipe(gt),[]),layout:bX(ve,{direction:"LR",edgeRouting:"orthogonal"}),style:bX(b7,{accentColor:"#0f766e",backgroundColor:"#ffffff"}),metadata:bX(bZ,{})}){}b2(vt);class vr extends Error{constructor(e){super(e),this.name="DiagramValidationError"}}let vn=e=>{let t=new Set;for(let r of e){if(t.has(r))return r;t.add(r)}};function vi(e){let t=vn(e.nodes.map(e=>e.id));if(t)throw new vr(`Duplicate node id "${t}" is not allowed.`);let r=vn(e.edges.map(e=>e.id));if(r)throw new vr(`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 vr(`Edge "${t.id}" references missing source node "${t.source}".`);if(!n.has(t.target))throw new vr(`Edge "${t.id}" references missing target node "${t.target}".`);if(t.source===t.target)throw new vr(`Edge "${t.id}" cannot connect node "${t.source}" to itself.`)}return e}function vs(e){return vi(b0(vt,e))}let va="flowchart",vo=gn(["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 vl extends gI("FlowchartValidationIssueRef")({kind:gn(["diagram","node","edge"]),id:mG(gg),path:mG(gg)}){}gI("FlowchartValidationIssue")({code:vo,ref:mG(vl),message:gg,hint:gg});let vc=gn(["start","process","decision","end"]);class vu extends b8.extend("FlowchartNode")({kind:vc,description:mG(gg)}){}class vd extends b6.extend("FlowchartEdge")({label:mG(gg)}){}class vf extends vt.extend("FlowchartDiagram")({type:m0(va),nodes:ge(vu).pipe(gt).check(gm(2)),edges:ge(vd).pipe(gt).check(gm(1))}){}let vh=b2(vf);function vp(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 vm(e,t,r){let n=new Set,i=[...e];for(let e=0;e<i.length;e+=1){let s=i[e];if(!(void 0===s||n.has(s)))for(let e of(n.add(s),t.get(s)??[]))i.push(r(e))}return n}function vg(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."}),vp(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 vp(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 s=e.nodes.filter(e=>"start"===e.kind),a=e.nodes.filter(e=>"end"===e.kind);for(let r of(0===s.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".'}):s.length>1&&t.push({code:"multiple_starts",ref:{kind:"diagram",id:e.id,path:"nodes"},message:`Flowchart has ${s.length} start nodes.`,hint:"Keep one start node and change the others to process, decision, or end."}),0===a.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)??[],s=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&&s.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===s.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 vp(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,s))}let o=1===s.length?s[0]:void 0;if(o){let r=vm([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(a.length>0){let s=vm(a.map(e=>e.id),n,e=>e.source);for(let n of e.nodes)r.has(n.id)&&!s.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 vy extends vr{issues;constructor(e){super(e[0]?.message??"Flowchart failed semantic validation."),this.issues=e,this.name="FlowchartValidationError"}}function vb(e){let t=vg(e);if(t.length>0)throw new vy(t);return e}let vv=vb(b0(vf,{id:"onboarding-flow",title:"Sketchi onboarding decision flow",type:va,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"}}));vb(b0(vf,{id:"pharma-batch-disposition",title:"Pharma batch disposition flow",type:va,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 vw="mindmap";class vx extends gI("MindmapNodeMetadata")({depth:gw.check(gp(0)),siblingIndex:gw.check(gp(0))}){}class vk extends b8.extend("MindmapNode")({kind:gn(["root","topic"]),metadata:vx}){}class vS extends gI("MindmapEdgeMetadata")({depth:gw.check(gh(0)),siblingIndex:gw.check(gp(0))}){}class v_ extends b6.extend("MindmapEdge")({metadata:vS}){}class v$ extends vt.extend("MindmapDiagram")({type:m0(vw),nodes:ge(vk).pipe(gt).check(gm(2)),edges:ge(v_).pipe(gt).check(gm(1))}){}function vO(e){return function(e){vi(e);let t=e.nodes.filter(e=>"root"===e.kind);if(1!==t.length)throw new vr(`Mindmap must contain exactly one root topic; found ${t.length}.`);let r=t[0];if(!r||0!==r.metadata.depth)throw new vr("Mindmap root topic must have depth 0.");let n=new Map,i=new Map(e.nodes.map(e=>[e.id,e])),s=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),a=r?.metadata.depth;if(void 0===e||a!==e+1)throw new vr(`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 vr(`Mindmap edge "${t.id}" metadata must match its child topic.`);s.set(t.source,[...s.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 vr(`Mindmap topic "${t.id}" must have ${t.id===r.id?"no parent":"exactly one parent"}.`)}for(let[e,t]of s){let r=t.map((e,t)=>t);if([...t].sort((e,t)=>e-t).some((e,t)=>e!==r[t]))throw new vr(`Mindmap children of "${e}" must use contiguous sibling ordering from 0.`)}return e}(b0(v$,e))}b2(v$);let vI=vO({id:"public-mindmap-capability",title:"Public mindmap generation",type:vw,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"}});vs(vv),vs(vI);function vC(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 vE(e){let t=vC(e[0]);if(t>e.length)throw Error("invalid order key: "+e);return e.slice(0,t)}let vA=new Set(["rectangle","ellipse","diamond"]);function vT(e){return"number"==typeof e&&Number.isFinite(e)?e:null}function vM(e){if(!Array.isArray(e)||e.length<2)return null;let t=vT(e[0]),r=vT(e[1]);return null===t||null===r?null:[t,r]}function vN(e){let t=vT(e.x),r=vT(e.y),n=vT(e.width),i=vT(e.height);return null===t||null===r||null===n||null===i?null:{x:t,y:r,width:n,height:i}}function vj(e){return 1e-4>Math.abs(e-.5)?.5001:e}function vF(e,t){let r;return{elementId:e?.id??"",focus:0,gap:0,fixedPoint:e?(r=vN(e))&&0!==r.width&&0!==r.height?[vj((t.x-r.x)/r.width),vj((t.y-r.y)/r.height)]:null:null}}function vL(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 vP(e,t){return Math.ceil(e.split("\n").length*t*1.35)}function vD(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=vP(e.text,e.fontSize);return{...vL(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 vR(e){return e.points[e.points.length-1]??e.points[0]}function vU(e){return"node"===e.type}function vB(e){return"text"===e.type}function vq(e){return"arrow"===e.type}function vK(e){let t=e.elements.filter(vU),r=new Map(e.elements.filter(vB).map(e=>[e.containerId??"",e])),n=e.elements.filter(vq),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),s=new Map,a=[],o=null,l=()=>{let e=function(e,t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"){if(null!=e&&function(e,t){if(e==="A"+t[0].repeat(26))throw Error("invalid order key: "+e);let r=vE(e);if(e.slice(r.length).slice(-1)===t[0])throw Error("invalid order key: "+e)}(e,t),null==e)return"a"+t[0];{let r=vE(e),n=e.slice(r.length),i=function(e,t){var r=e;if(r.length!==vC(r[0]))throw Error("invalid integer part of order key: "+r);let[n,...i]=e.split(""),s=!0;for(let e=i.length-1;s&&e>=0;e--){let r=t.indexOf(i[e])+1;r===t.length?i[e]=t[0]:(i[e]=t[r],s=!1)}if(!s)return n+i.join("");{if("Z"===n)return"a"+t[0];if("z"===n)return null;let e=String.fromCharCode(n.charCodeAt(0)+1);return e>"a"?i.push(t[0]):i.pop(),e+i.join("")}}(r,t);return null==i?r+function e(t,r,n){let i=n[0];if(null!=r&&t>=r)throw Error(t+" >= "+r);if(t.slice(-1)===i||r&&r.slice(-1)===i)throw Error("trailing zero");if(r){let s=0;for(;(t[s]||i)===r[s];)s++;if(s>0)return r.slice(0,s)+e(t.slice(s),r.slice(s),n)}let s=t?n.indexOf(t[0]):0,a=null!=r?n.indexOf(r[0]):n.length;return a-s>1?n[Math.round(.5*(s+a))]:r&&r.length>1?r.slice(0,1):n[s]+e(t.slice(1),null,n)}(n,null,t):i}}(o);return o=e,e};for(let n of t){let t=r.get(n.id),o=function(e){let t=e.text?vP(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{...vL(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}}({scene:e,shape:n,arrowIds:i.get(n.id)??[],index:l(),...t?{text:t}:{}});s.set(n.nodeId,o),a.push(o)}for(let t of e.elements.filter(vB))t.containerId&&a.push(vD({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){a.push(function(e){let t=e.arrow.points[0],r=vR(e.arrow),n=e.arrow.points.length>2;return{...vL(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:vF(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:vF(e.sourceShape,t),strokeColor:e.arrow.strokeColor??e.scene.accentColor}}({arrow:t,scene:e,index:l(),sourceShape:s.get(t.sourceNodeId),targetShape:s.get(t.targetNodeId)}));let r=t.label?function(e){if(!e.arrow.label)return null;let t=e.arrow.points[0],r=vR(e.arrow);return vD({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&&a.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:a}}function vz(e,t){let r=e[t];if(!(r&&"object"==typeof r))return null;let n=r.elementId;return"string"==typeof n?n:null}function vV(e){return vM(e)}function vJ(e){let t=vT(e.x)??0,r=vT(e.y)??0,n=vz(e,"startBinding"),i=vz(e,"endBinding"),s=Array.isArray(e.points)?e.points.map(vV).filter(e=>!!e):[],a=[];for(let o=0;o<s.length-1;o+=1){let l=s[o],c=s[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)){a.push({arrowId:e.id,endBindingElementId:i,isLastSegment:o===s.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)&&a.push({arrowId:e.id,endBindingElementId:i,isLastSegment:o===s.length-2,max:Math.max(m,y),min:Math.min(m,y),orientation:"vertical",segmentIndex:o,startBindingElementId:n,staticCoordinate:p})}return a.filter(e=>e.max-e.min>.001)}function vW(e,t,r){return e>t+.01&&e<r-.01}function vY(e,t,r,n){return Math.min(t,n)-Math.max(e,r)>.01}function vG(e,t,r){return e>=t-.01&&e<=r+.01}function vH(e,t){return .01>=Math.abs(e-t)}function vQ(e){let t=[],r=new Map(e.elements.map(e=>[e.id,e])),n=new Set(e.elements.filter(e=>vA.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 s 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 a=vz(i,s);if(!(a&&n.has(a))){t.push({code:"missing-arrow-binding",elementId:i.id,message:`Arrow "${i.id}" has invalid ${s}.`});continue}let o=r.get(a);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=vT(e.x)??0,n=vT(e.y)??0,i=Array.isArray(e.points)?e.points.map(vV).filter(e=>!!e):[],s="startBinding"===t?i[0]:i[i.length-1];return s?{x:r+s[0],y:n+s[1]}:null}(i,s);if(o&&l&&!function(e,t){let r=vN(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,s=r.y+n;return vH(Math.abs(e.x-i)/t+Math.abs(e.y-s)/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,s=r.y+n;return vH(((e.x-i)/t)**2+((e.y-s)/n)**2,1)}let n=(vH(e.x,r.x)||vH(e.x,r.x+r.width))&&vG(e.y,r.y,r.y+r.height),i=(vH(e.y,r.y)||vH(e.y,r.y+r.height))&&vG(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}" ${s} endpoint does not land on "${o.id}".`}),o&&l&&e){let e=function(e,t){let r=e[t];return r&&"object"==typeof r?vM(r.fixedPoint):null}(i,s);e&&function(e,t,r){let n=vN(r);if(!n)return!1;let i=1e-4>Math.abs(e[0]-.5001)?.5:e[0],s=1e-4>Math.abs(e[1]-.5001)?.5:e[1];return vH(n.x+i*n.width,t.x)&&vH(n.y+s*n.height,t.y)}(e,l,o)||t.push({code:"invalid-elbow-binding",elementId:i.id,message:`Elbow arrow "${i.id}" has invalid ${s} 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 s="number"==typeof i.width?i.width:0,a="number"==typeof i.height?i.height:0,o="number"==typeof n.width?n.width:0,l="number"==typeof n.height?n.height:0;vA.has(n.type)&&(s+24>o||a+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(vJ),r=e.filter(e=>vA.has(e.type)),n=[],i=new Set;for(let e of t)for(let t of r){if(t.id===e.startBindingElementId||t.id===e.endBindingElementId)continue;let r=vN(t);if(!r||("horizontal"===e.orientation?!(vW(e.staticCoordinate,r.y,r.y+r.height)&&vY(e.min,e.max,r.x,r.x+r.width)):!(vW(e.staticCoordinate,r.x,r.x+r.width)&&vY(e.min,e.max,r.y,r.y+r.height))))continue;let s=`${e.arrowId}:${e.segmentIndex}:${t.id}`;i.has(s)||(i.add(s),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(vJ),r=[],n=new Set;for(let e=0;e<t.length;e+=1){let i=t[e];if(i)for(let s=e+1;s<t.length;s+=1){let e=t[s];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 a=[i.arrowId,i.segmentIndex,e.arrowId,e.segmentIndex].sort().join(":");n.has(a)||(n.add(a),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}}function vZ(e){return new Map(e.map((e,t)=>[e.id,t]))}function vX(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 v0(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}function v1(e,t,r){return Math.min(r,Math.max(t,e))}function v2(e,t,r=0){let n,i=(n="top"===t||"bottom"===t?e.width/2-16:e.height/2-16)>0?v1(r,-n,n):0,s=v0(e),a=e.width/2,o=e.height/2;if("diamond"===e.shape&&a>0&&o>0){if("top"===t||"bottom"===t){let e=s.x+i,r=o*(1-Math.abs(i)/a);return{x:e,y:"top"===t?s.y-r:s.y+r}}let e=s.y+i,r=a*(1-Math.abs(i)/o);return{x:"left"===t?s.x-r:s.x+r,y:e}}if(("ellipse"===e.shape||"circle"===e.shape)&&a>0&&o>0){if("top"===t||"bottom"===t){let e=s.x+i,r=o*Math.sqrt(Math.max(0,1-(i/a)**2));return{x:e,y:"top"===t?s.y-r:s.y+r}}let e=s.y+i,r=a*Math.sqrt(Math.max(0,1-(i/o)**2));return{x:"left"===t?s.x-r:s.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 v3(e){return`${e.edgeId}:${e.endpoint}`}function v5(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 v4(e,t,r){return e>t+.01&&e<r-.01}function v8(e,t,r,n){return Math.min(t,n)-Math.max(e,r)>.01}function v6(e,t,r){let n=0;for(let i=0;i<e.length-1;i+=1){let s=e[i],a=e[i+1];if(s&&a)for(let e of t)!r.has(e.nodeId)&&(s.y===a.y?v4(s.y,e.y,e.y+e.height)&&v8(Math.min(s.x,a.x),Math.max(s.x,a.x),e.x,e.x+e.width):s.x===a.x&&v4(s.x,e.x,e.x+e.width)&&v8(Math.min(s.y,a.y),Math.max(s.y,a.y),e.y,e.y+e.height))&&(n+=1)}return n}function v9(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 v7(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 we(e,t){return Math.min(e.max,t.max)-Math.max(e.min,t.min)}function wt(e,t,r){let n=v7({arrowId:`edge:${r.edge.id}`,points:e,sourceNodeId:r.edge.source,targetNodeId:r.edge.target}),i=t.flatMap(e=>v7({arrowId:e.id,points:e.points,sourceNodeId:e.sourceNodeId,targetNodeId:e.targetNodeId})),s=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>=we(e,t)||(s+=1);return s}function wr(e,t){let r=v7({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>=we(t,e)||(n+=1)}}return n}function wn(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),s=0;return r.x<t.x?s+=Math.max(0,Math.max(...n)-t.x):r.x>t.x&&(s+=Math.max(0,t.x-Math.min(...n))),r.y<t.y?s+=Math.max(0,Math.max(...i)-t.y):r.y>t.y&&(s+=Math.max(0,t.y-Math.min(...i))),s}function wi(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),s=0;return r.x<t.x?s+=Math.max(0,r.x-Math.min(...n)):r.x>t.x&&(s+=Math.max(0,Math.max(...n)-r.x)),r.y<t.y?s+=Math.max(0,r.y-Math.min(...i)):r.y>t.y&&(s+=Math.max(0,Math.max(...i)-r.y)),s}function ws(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 wa(e,t){let r=e[0],n=e[1],i=e[e.length-1],s=e[e.length-2],a=0;return n&&ws(r,n,t.sourceEdge)&&(a+=1),s&&i&&ws(i,s,t.targetEdge)&&(a+=1),a}function wo(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 wl(e,t,r,n,i){var s;let a,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||v0(e.target).x<v0(e.source).x,p="top"===e.sourceEdge||"top"===e.targetEdge||v0(e.source).y<=v0(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,k=p?b:v,S=p?v:b,_=[0,36+e.index%4*18],$=(n,i)=>{let s=i>0?wo(t,e.sourceEdge,i):t,a=i>0?wo(r,e.targetEdge,i):r;return v5([t,s,{x:n,y:s.y},{x:n,y:a.y},a,r])},O=(n,i)=>{let s=i>0?wo(t,e.sourceEdge,i):t,a=i>0?wo(r,e.targetEdge,i):r;return v5([t,s,{x:s.x,y:n},{x:a.x,y:n},a,r])},I=[..._.map(e=>O(k,e)),..._.map(e=>O(S,e)),..._.map(e=>$(w,e)),..._.map(e=>$(x,e))],C=[..._.map(e=>$(w,e)),..._.map(e=>$(x,e)),..._.map(e=>O(k,e)),..._.map(e=>O(S,e))];return(a=(s=o?I:C)[0])?s.slice(1).reduce((t,r)=>{let s=v6(t,n,l),a=v6(r,n,l);if(a<s)return r;if(s<a)return t;let o=wr(t,e),c=wr(r,e);if(c<o)return r;if(o<c)return t;let u=wt(t,i,e),d=wt(r,i,e);if(d<u)return r;if(u<d)return t;let f=wa(t,e),h=wa(r,e);if(h>f)return r;if(f>h)return t;let p=wn(t),m=wn(r);if(m<p)return r;if(p<m)return t;let g=wi(t),y=wi(r);return y<g?r:g<y?t:v9(r)<v9(t)?r:t},a):[{x:0,y:0}]}function wc(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 wu(e,t,r){return{x:e.x+t,y:e.y+r}}function wd(e){var t;let r,n,i,s,a,o=vs(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,s;return[e.id,(s=(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(...s.map(e=>e.length))*.62+36),height:Math.ceil(14*s.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 s(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||s(t.target)}n.set(e,"visited")}let a=e.nodes.find(e=>0===(t.get(e.id)??[]).length)??e.nodes[0];for(let t of(a&&s(a.id),e.nodes))n.has(t.id)||s(t.id);return i}(e,n.incoming,n.outgoing),s=function(e,t,r){let n=vZ(e.nodes),i=new Map(e.nodes.map(e=>[e.id,0])),s=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 a=[];for(let t of e.nodes)(i.get(t.id)??0)===0&&a.push(t.id);let o=new Set;for(let e=0;e<a.length;e+=1){let l=a[e];if(!l||o.has(l))continue;o.add(l);let c=s.get(l)??0;for(let e of t.outgoing.get(l)??[]){if(r.has(e.id))continue;s.set(e.target,Math.max(s.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)}(a,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=>s.get(e.source)??0);s.set(n.id,e.length>0?Math.max(...e)+1:0)}return s}(e,n,i),a=Array.from((function(e,t,r,n,i){let s=vZ(e.nodes),a=new Map;for(let n of e.nodes){let e=r.get(n.id)??0,i=t.get(n.id);i&&a.set(e,[...a.get(e)??[],i])}for(let e=0;e<4;e+=1)for(let e of Array.from(a.keys()).sort((e,t)=>e-t)){let t=a.get(e);if(!t||t.length<2)continue;let r=new Map;(a.get(e-1)??[]).forEach((e,t)=>{r.set(e.nodeId,t)});let o=new Map;(a.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?s.get(e.nodeId)??Number.MAX_SAFE_INTEGER:t.reduce((e,t)=>e+t,0)/t.length};a.set(e,[...t].sort((e,t)=>{let r=l(e)-l(t);return Math.abs(r)>.001?r:(s.get(e.nodeId)??Number.MAX_SAFE_INTEGER)-(s.get(t.nodeId)??Number.MAX_SAFE_INTEGER)}))}return a})(e,r,s,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(...a.map(e=>e.breadth)),l=48,c=[];for(let e of a){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),s=r.get(e.target);if(!i||!s)throw Error(`Cannot render edge "${e.id}" with unresolved nodes.`);let{sourceEdge:a,targetEdge:o}=function(e,t,r){let n=v0(e),i=v0(t),s=i.x-n.x,a=i.y-n.y,o=e.kind?.toLowerCase();if("LR"===r||"RL"===r)return s>=0?{sourceEdge:"right",targetEdge:"left"}:{sourceEdge:"left",targetEdge:"right"};if(a<0)return!(Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)>.01)&&Math.abs(s)>Math.abs(a)?{sourceEdge:s>0?"right":"left",targetEdge:"bottom"}:{sourceEdge:"top",targetEdge:"bottom"};let l="decision"===o&&a>e.height+96;return"decision"===o&&a>0&&(0!==s||l)?{sourceEdge:s<0?"left":"right",targetEdge:"top"}:a>0?{sourceEdge:"bottom",targetEdge:"top"}:Math.abs(s)>Math.abs(a)?s>0?{sourceEdge:"right",targetEdge:"left"}:{sourceEdge:"left",targetEdge:"right"}:a>0?{sourceEdge:"bottom",targetEdge:"top"}:{sourceEdge:"top",targetEdge:"bottom"}}(i,s,n);return{edge:e,index:t,source:i,sourceEdge:a,target:s,targetEdge:o}})(e,t,c,o.layout.direction)),d=function(e){let t=new Map;for(let a of e){var r,n,i,s;let e=(r=a.source.nodeId,n=a.sourceEdge,`${r}:${n}`),o=(i=a.target.nodeId,s=a.targetEdge,`${i}:${s}`);t.set(e,[...t.get(e)??[],{edgeId:a.edge.id,endpoint:"source"}]),t.set(o,[...t.get(o)??[],{edgeId:a.edge.id,endpoint:"target"}])}let a=new Map;for(let e of t.values())e.forEach((t,r)=>{a.set(v3(t),(r-(e.length-1)/2)*18)});return a}(u),f=[];for(let e of u)f.push(function(e,t,r,n,i,s){let{edge:a,source:o,sourceEdge:l,target:c,targetEdge:u}=e,d=v2(o,l,r.get(v3({edgeId:a.id,endpoint:"source"}))??0),f=v2(c,u,r.get(v3({edgeId:a.id,endpoint:"target"}))??0),h=v5([d,f]);if(function(e,t,r){let n=v0(e),i=v0(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,s))h=wl(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,s=(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)?v1(t+g,r,n):t),a="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=v5([d,a,{x:a.x,y:s},{x:o.x,y:s},o,f])}return"orthogonal"===t&&(v6(h,n,new Set([o.nodeId,c.nodeId]))>0||wr(h,e)>0||wt(h,i,e)>0)&&(h=wl(e,d,f,n,i)),{type:"arrow",id:`edge:${a.id}`,edgeId:a.id,sourceNodeId:a.source,targetNodeId:a.target,points:h,...a.label?{label:a.label}:{}}}(e,o.layout.edgeRouting,d,l,f,o.layout.direction));let h=l.map(vX),p=(i=Math.max(0,48-(n={x:Math.min(...(r=wc(t=[...f,...l,...h])).map(e=>e.x)),y:Math.min(...r.map(e=>e.y))}).x),s=Math.max(0,48-n.y),0===i&&0===s?[...t]:t.map(e=>"arrow"===e.type?{...e,points:function(e,t,r){let[n,...i]=e;return[wu(n,t,r),...i.map(e=>wu(e,t,r))]}(e.points,i,s)}:{...e,x:e.x+i,y:e.y+s})),m={width:Math.max(...(a=wc(p)).map(e=>e.x))+48,height:Math.max(...a.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 wf=io("effect/Metric/CurrentMetricAttributes",{defaultValue:()=>({})}),wh=io("~effect/observability/Metric/MetricRegistryKey",{defaultValue:()=>new Map}),wp="~effect/observability/Metric";class wm{[wp]=wp;#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=n7(e,wf);if(0===Object.keys(t).length)return eO(this.#t)||(this.#t=this.getOrCreate(e,this.attributes)),this.#t.hooks;let r=wS(this.attributes,t),n=this.#e.get(r);return eO(n)||(n=this.getOrCreate(e,r),this.#e.set(r,n)),n.hooks}getOrCreate(e,t){var r,n,i;let s,a=(r=this,n=t,s=`${r.type}:${r.id}`,eO(r.description)&&(s+=`:${r.description}`),eO(n)&&(s+=`:${(Array.isArray(i=n)?i:Object.entries(i)).map(([e,t])=>`${e}=${t}`).join(",")}`),s),o=n7(e,wh);if(o.has(a))return o.get(a);let l=this.createHooks(),c={id:this.id,type:this.type,description:this.description,attributes:w_(t),hooks:l};return o.set(a,c),c}pipe(){return es(this,arguments)}}let wg=BigInt(0);class wy extends wm{type="Counter";#r;#n;constructor(e,t){super(e,t?.description,w_(t?.attributes)),this.#r=t?.bigint??!1,this.#n=t?.incremental??!1}createHooks(){let e=this.#r?wg:0,t=this.#n?this.#r?e=>e>=wg:e=>e>=0:e=>!0;return wk(()=>({count:e,incremental:this.#n}),r=>{t(r)&&(e+=r)})}}class wb extends wm{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 wv=(e,t)=>new wy(e,t),ww=el(2,(e,t)=>au(r=>sL(()=>e.updateUnsafe(t,r)))),wx=el(2,(e,t)=>new wb(e,r=>e.valueUnsafe(w$(r,t)),(r,n)=>e.updateUnsafe(r,w$(n,t)),(r,n)=>e.modifyUnsafe(r,w$(n,t))));function wk(e,t,r){return{get:e,update:t,modify:r??t}}function wS(e,t){return{...w_(e),...w_(t)}}function w_(e){return eO(e)&&Array.isArray(e)?e.reduce((e,[t,r])=>(e[t]=r,e),{}):e}function w$(e,t){let r=wS(n7(e,wf),t);return n8(e,wf,r)}[...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 wO={metric:()=>void 0},wI=io("@sketchi/observability/TelemetryExporter",{defaultValue:()=>wO}),wC=io("@sketchi/observability/TelemetryCorrelation",{defaultValue:()=>({})});function wE(e){let t=e?.trim();if(t&&!(t.length>128)&&/^[A-Za-z0-9][A-Za-z0-9._:-]*$/.test(t))return t}function wA(e){let t=wE(e.artifactId),r=wE(e.attemptId),n=wE(e.projectId),i=wE(e.requestId),s=wE(e.runId),a=wE(e.scenarioId),o=wE(e.traceId);return{...t?{artifactId:t}:{},...r?{attemptId:r}:{},...n?{projectId:n}:{},...i?{requestId:i}:{},...s?{runId:s}:{},...a?{scenarioId:a}:{},...o?{traceId:o}:{}}}function wT(e,t){return lD(function*(){let r=wA({...yield*wC,...wA(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(af(wC,r),ow(n),lY(n))})}io("@sketchi/observability/TelemetryResource",{defaultValue:()=>({serviceName:"sketchi"})});let wM=lJ(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=wE(n);t&&(r[e]=t)}return r}(r);yield*ww(wx(e,n),t);let i=yield*wI,s=rB((yield*ox.pipe(lU)));yield*sL(()=>i.metric({attributes:n,metric:e.id,metricType:e.type,...s?{spanId:s.spanId,traceId:s.traceId}:{},value:t}))}),wN=/^(node|step|item|box|thing|process|task)\s*\d*$/i,wj=/^(diagram|untitled|flowchart|chart|sketch)$/i;function wF(e){return"decision"===e.kind||e.label.endsWith("?")}function wL(e){if(void 0===e)return;let t=gV(e);return t.length>0?t:void 0}let wP=["excalidraw","scene"],wD=["scene"],wR=wv("sketchi_codemode_requests",{description:"Code Mode boundary requests by terminal outcome",incremental:!0}),wU=wv("sketchi_codemode_failures",{description:"Code Mode boundary failures by typed status",incremental:!0}),wB=wv("sketchi_codemode_artifacts",{description:"Code Mode artifacts accepted at workflow boundaries",incremental:!0}),wq=new class e extends wm{type="Histogram";#i;constructor(e,t){super(e,t?.description,w_(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,s=0,a=Number.MAX_VALUE,o=5e-324;return nR(nj(e,rg),(e,t)=>{n[t]=e}),wk(()=>({buckets:(()=>{let e=new n$(t),i=0;for(let s=0;s<t;s++){let t=n[s];i+=r[s],e[s]=[t,i]}return e})(),count:i,min:a,max:o,sum:s}),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,s+=e,e<a&&(a=e),e>o&&(o=e)})}}("sketchi_codemode_duration_ms",{description:"Code Mode boundary duration in milliseconds",boundaries:nC(nU(new Set([1,5,10,25,50,100,250,500,1e3,2500,5e3,1e4]),e=>e>0),1/0)});class wK extends nQ()("@sketchi/diagram-agent/CodeModeRuntimeEnvironment"){}function wz(e){return null===e||"object"!=typeof e||Array.isArray(e)?void 0:Object.fromEntries(Object.entries(e))}function wV(e,t,r){let n,i,s,a;return wT(lD(function*(){let t=yield*oE,n=yield*r,i=yield*oE,s=n.ok?"success":"failure",a=n.ok?void 0:n.status??"unknown_failure";yield*wM(wR,1,{...a?{failureCategory:a}:{},operation:e,outcome:s,surface:"code_mode"}),yield*wM(wq,i-t,{...a?{failureCategory:a}:{},operation:e,outcome:s,surface:"code_mode"}),a&&(yield*wM(wU,1,{failureCategory:a,operation:e,surface:"code_mode"}));let o="buildFlowchart"===e?"flowchart":"buildMindmap"===e?"mindmap":"applyDiagramPatch"===e?"patch":void 0;return n.ok&&o&&(yield*wM(wB,1,{artifactKind:o,operation:e,surface:"code_mode"})),n}),(n=wz(t),i=wz(n?.source),s="string"==typeof n?.artifactId?n.artifactId:"string"==typeof i?.artifactId?i.artifactId:void 0,a="string"==typeof n?.requestId?n.requestId:void 0,{...s?{artifactId:s}:{},...a?{requestId:a}:{}}))}lv(wK,{createId:wQ});class wJ extends gE()("CodeModeArtifactExportError",{cause:gb(),message:m3,optionPath:m4}){}class wW extends gE()("BuildFlowchartFailure",{message:m3,status:gn(["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 wY extends gE()("BuildMindmapFailure",{message:m3,status:gn(["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 wG extends gE()("GetArtifactFailure",{message:m3,status:gn(["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 wH extends gE()("ApplyDiagramPatchFailure",{message:m3,status:gn(["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 wQ(e){return`${e}_${globalThis.crypto.randomUUID()}`}function wZ(e){return{code:e.code,severity:e.severity??"error",stage:e.stage,...e.ref?{ref:e.ref}:{},message:e.message,hint:e.hint}}function wX(e){return 0===e.length?"input":e.map(e=>"number"==typeof e?`[${e}]`:String(e)).join(".")}function w0(e){let t=wX(e.path);return w1(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 w1(e){return/^operations\.\[\d+\]\.op$/.test(e)}function w2(e){let t=e.issues.slice(0,20).map(e=>{let t=wX(e.path);return wZ({code:w0(e),stage:"input",ref:{kind:"request",path:t},message:e.message,hint:w1(t)?`Use one of: ${yw.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(wZ({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 w3(e){return e.checks.map(e=>{var t;return wZ({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 w5(e){return e?.artifactFormats??wP}function w4(e){return e?.inlineArtifacts??wD}let w8=lJ("codeMode.artifacts.exportFormats")(function*(e){let t=[];for(let s of e.formats){var r,n,i;let a=yield*(r=e,"scene"===(n=s)?lP(r.scene):"excalidraw"===n?lP(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(a$(e=>wJ.make({cause:e,message:e instanceof Error?e.message:"Artifact export failed.",optionPath:!1}))):tJ(wJ.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:s,mimeType:bK[s],data:a,sizeBytes:(i=a)instanceof ArrayBuffer||i instanceof Uint8Array?i.byteLength:bW(i)})}return t});function w6(e){return[wZ({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 w9(e){return e.map(e=>wZ({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 w7(e){return structuredClone(e)}function xe(e){return e.elements.filter(e=>"arrow"===e.type).map(e=>`${e.edgeId}:${e.sourceNodeId}->${e.targetNodeId}`).sort()}function xt(e){return e.elements.filter(e=>"node"===e.type)}function xr(e){return e.elements.filter(e=>"text"===e.type)}function xn(e){return e.elements.filter(e=>"arrow"===e.type)}function xi(e,t){if(!e||0===e.length||!t)return!1;let r=t.trim().toLowerCase();return e.some(e=>e.trim().toLowerCase()===r)}function xs(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??[]),s=new Set(t?.nodeIds??[]),a=new Set(t?.edgeIds??[]),o=new Set(t?.kinds??[]),l=xt(e).filter(e=>"edges"!==r&&(!t||!n||i.has(e.id)||s.has(e.nodeId)||!!e.kind&&[...o].some(t=>t===e.kind)||xi(t.labels,e.label))),c=xn(e).filter(e=>"nodes"!==r&&(!t||!n||i.has(e.id)||a.has(e.edgeId)||xi(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:xr(e).filter(e=>t&&n?i.has(e.id)||!!e.containerId&&u.has(e.containerId)||!!e.containerId&&d.has(e.containerId)||xi(t.labels,e.text):"nodes"===r?!!e.containerId&&u.has(e.containerId):"edges"!==r||!!e.containerId&&d.has(e.containerId))}}function xa(e){return wZ({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 xo(e,t){return xr(e).find(e=>e.containerId===t)}function xl(e,t){let r=new Set(t);for(let t of xn(e))(r.has(t.sourceNodeId)||r.has(t.targetNodeId))&&xd(e,t)}function xc(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}function xu(e,t,r){let n=xc(e),i=xc(t),s=i.x-n.x,a=i.y-n.y;return Math.abs(s)>Math.abs(a)?s>=0&&r||s<0&&!r?{x:e.x+e.width,y:n.y}:{x:e.x,y:n.y}:a>=0&&r||a<0&&!r?{x:n.x,y:e.y+e.height}:{x:n.x,y:e.y}}function xd(e,t){let r,n,i=new Map(xt(e).map(e=>[e.nodeId,e])),s=i.get(t.sourceNodeId),a=i.get(t.targetNodeId);if(!s||!a)return[wZ({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=xu(s,a,!0),l=xu(a,s,!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=xo(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 xf=lJ("codeMode.patch.resolveSource")(function*(e){if("scene"in e.source)return{scene:w7(e.source.scene)};let t=yield*bq,r=yield*t.readManifest(e.source.artifactId).pipe(a$(e=>new wH({status:"storage_failed",context:{issues:[bH(e.message,"storage_read_failed")]}})));if(!r||r.artifactId!==e.source.artifactId||!r.formats.some(e=>"scene"===e.format))return yield*new wH({status:"source_unavailable",context:{issues:[wZ({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(a$(e=>new wH({status:"storage_failed",context:{issues:[bH(e.message,"storage_read_failed")]}})));if(!n)return yield*new wH({status:"source_unavailable",context:{issues:[wZ({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=be.safeParse(n.data);return i.success?{scene:w7(i.data),sourceArtifactId:e.source.artifactId}:yield*new wH({status:"source_unavailable",context:{issues:[wZ({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 xh(e){return e?{requestId:e}:{}}function xp(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 xm(e){return{diagramId:e.diagramId,formats:[{format:"scene",mimeType:bK.scene,inline:e,sizeBytes:bW(e)}]}}function xg(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 xy(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 xb(e){return{ok:!1,status:e.status,issues:e.issues}}function xv(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 xw(e,t){return bH(e.message,t)}let xx=lJ("codeMode.buildMindmap.workflow")(function*(e){let t=yield*sL(()=>(function(e){let t=wz(wz(wz(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[wZ({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[wZ({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=wz(t[n]);i&&r.push({depth:e.depth+1,topic:i})}}}return[]})(e)).pipe(lV("codeMode.buildMindmap.preflight"));if(t.length>0)return yield*new wY({status:"invalid_mindmap",context:{issues:t}});let r=yield*sL(()=>y3.safeParse(e)).pipe(lV("codeMode.buildMindmap.parse"));if(!r.success)return yield*new wY({status:"invalid_input",context:{issues:w2(r.error)}});let n=yield*wK,i=yield*bq,s=r.data,a=yield*sL(()=>n.createId("build")),o=yield*sL(()=>{var e;let t,r;return e=s.spec,t=(e,r)=>({id:`topic-${r.join("-")}`,label:gV(e.label),children:(e.children??[]).map((e,n)=>t(e,[...r,n]))}),r=gV(e.title),{id:function(e){if(void 0===e)return;let t=gV(e);return t.length>0?t:void 0}(e.id)??(r.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"sketchi-mindmap"),title:r,root:t(e.root,[0]),layout:{direction:e.layout.direction},style:e.style}}).pipe(lV("codeMode.buildMindmap.normalize")),l={buildId:a,...xh(s.requestId),normalizedSpec:o},c=yield*sL(()=>{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))})(o.root,0),i=[],(n={count:e,depth:t}).count<2&&i.push(wZ({code:"disconnected_graph",stage:"mindmap",ref:{kind:"diagram",id:o.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(wZ({code:"mindmap_too_deep",stage:"mindmap",ref:{kind:"diagram",id:o.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(wZ({code:"mindmap_too_large",stage:"mindmap",ref:{kind:"diagram",id:o.id},message:`Mindmap has ${n.count} topics; the supported maximum is 100.`,hint:"Split this hierarchy into smaller focused mindmaps."})),i}).pipe(lV("codeMode.buildMindmap.validate"));if(c.length>0)return yield*new wY({status:"invalid_mindmap",context:{...l,issues:c}});let u=yield*sz({try:()=>{let e,t,r;return e=[],t=[],(r=(n,i,s,a)=>{e.push({id:n.id,label:n.label,kind:0===i?"root":"topic",metadata:{depth:i,siblingIndex:s}}),a&&t.push({id:`branch-${n.id.slice(6)}`,source:a,target:n.id,metadata:{depth:i,siblingIndex:s}}),n.children.forEach((e,t)=>r(e,i+1,t,n.id))})(o.root,0,0),vO({id:o.id,title:o.title,type:"mindmap",nodes:e,edges:t,layout:{direction:o.layout.direction,edgeRouting:"curved"},style:o.style})},catch:e=>new wY({status:"invalid_mindmap",context:{...l,issues:[wZ({code:"disconnected_graph",stage:"mindmap",ref:{kind:"diagram",id:o.id},message:e instanceof Error?e.message:"Mindmap failed core validation.",hint:"Repair the nested topic hierarchy and call buildMindmap again."})]}})}).pipe(lV("codeMode.buildMindmap.canonicalize")),d=yield*sL(()=>{var e;let t,r;return e=s.options?.minQualityScore??8,{accepted:(r=Math.max(0,10-2*(t=u.nodes.filter(e=>/^(topic|branch|item|mindmap)$/i.test(e.label.trim()))).length))>=e,score:r,threshold:e,summary:{nodeCount:u.nodes.length,edgeCount:u.edges.length},checks:t.map(e=>({code:"generic_label",passed:!1,severity:"warning",message:`Topic "${e.label}" is too generic.`,refs:[{kind:"node",id:e.id}]}))}}).pipe(lV("codeMode.buildMindmap.quality")),f={...l,quality:d};if(!d.accepted)return yield*new wY({status:"quality_failed",context:{...f,issues:w3(d)}});let h=yield*sz({try:()=>wd(u),catch:e=>new wY({status:"render_failed",context:{...f,issues:[wZ({code:"render_failed",stage:"render",ref:{kind:"diagram",id:o.id},message:e instanceof Error?e.message:"Unable to render mindmap scene.",hint:"Simplify the hierarchy or retry with a smaller mindmap."})]}})}).pipe(lV("codeMode.buildMindmap.render")),{excalidraw:p,exportValidation:m}=yield*sL(()=>{let e=vK(h);return{excalidraw:e,exportValidation:vQ(e)}}).pipe(lV("codeMode.buildMindmap.exportValidate")),g={...f,partial:xm(h)};if(!m.ok)return yield*new wY({status:"export_failed",context:{...g,issues:w9(m.issues)}});let y=yield*w8({formats:w5(s.options),scene:h,excalidraw:p,renderer:n.renderer}).pipe(a$(e=>new wY({status:"export_failed",context:{...g,issues:w6(e)}}))),b=yield*sL(()=>n.createId("artifact")),v=yield*wT(i.write({artifactId:b,diagramId:h.diagramId,formats:y,inlineFormats:w4(s.options)}),{artifactId:b,...s.requestId?{requestId:s.requestId}:{}}).pipe(a$(e=>new wY({status:"storage_failed",context:{...f,partial:{diagramId:h.diagramId},issues:[xw(e,"storage_write_failed")]}})));return{ok:!0,status:"accepted",buildId:a,...xh(s.requestId),normalizedSpec:o,quality:d,artifact:xp(v,n.artifactUrl),issues:[]}}),xk=lJ("codeMode.buildFlowchart.workflow")(function*(e){let t=yield*sL(()=>yV.safeParse(e)).pipe(lV("codeMode.buildFlowchart.parse"));if(!t.success)return yield*new wW({status:"invalid_input",context:{issues:w2(t.error)}});let r=yield*wK,n=yield*bq,i=t.data,s=w5(i.options),a=yield*sL(()=>r.createId("build")),o=yield*sL(()=>{var e;let t;return t=gV((e=i.spec).title),{id:wL(e.id)??(t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"sketchi-flowchart"),title:t,nodes:e.nodes.map(e=>({id:gV(e.id),label:gV(e.label),kind:e.kind,...e.description?{description:gV(e.description)}:{}})),edges:e.edges.map((e,t)=>({id:wL(e.id)??`edge-${t+1}`,source:gV(e.source),target:gV(e.target),...e.label?{label:gV(e.label)}:{}})),layout:{direction:e.layout.direction},style:{accentColor:e.style.accentColor,backgroundColor:e.style.backgroundColor}}}).pipe(lV("codeMode.buildFlowchart.normalize")),l={buildId:a,...xh(i.requestId),normalizedSpec:o},c=yield*sL(()=>vh.safeParse({id:o.id,title:o.title,type:"flowchart",nodes:o.nodes.map(e=>({...e,metadata:{}})),edges:o.edges.map(e=>({...e,metadata:{}})),layout:{direction:o.layout.direction,edgeRouting:"orthogonal"},style:o.style,metadata:{}})).pipe(lV("codeMode.buildFlowchart.parseCanonical"));if(!c.success){var u;return yield*new wW({status:"invalid_flowchart",context:{...l,issues:(u=c.error,u.issues.slice(0,20).map(e=>{let t=function(e,t){let r=wX(e.path),n="input"===r?"spec":`spec.${r}`,[i,s]=e.path;if("nodes"===i&&"number"==typeof s){let e=t.nodes[s]?.id;return{kind:"node",...e?{id:e}:{},path:n}}if("edges"===i&&"number"==typeof s){let e=t.edges[s]?.id;return{kind:"edge",...e?{id:e}:{},path:n}}return{kind:"diagram",id:t.id,path:n}}(e,o);return wZ({code:w0(e),stage:"flowchart",ref:t,message:e.message,hint:`Fix ${t.path??"spec"} so normalization produces a valid canonical flowchart value.`})}))}})}let d=c.data,f=yield*sL(()=>vg(d).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 wZ({code:e.code,stage:"flowchart",...t?{ref:t}:{},message:e.message,hint:e.hint})})).pipe(lV("codeMode.buildFlowchart.validate"));if(f.length>0)return yield*new wW({status:"invalid_flowchart",context:{...l,issues:f}});yield*sL(()=>vb(d)).pipe(lV("codeMode.buildFlowchart.assertValid"));let h=yield*sL(()=>(function(e,t){let r=[],n=0,i=(e,t,i=!1)=>{n+=e,r.push({severity:i?"error":"warning",message:t})},s=new Map,a=new Map;for(let t of e.edges)s.set(t.source,(s.get(t.source)??0)+1),s.set(t.target,(s.get(t.target)??0)+1),a.set(t.source,[...a.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=>(s.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(wF)){let e=a.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=>wN.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||wj.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}})(d,i.options?.minQualityScore??8)).pipe(lV("codeMode.buildFlowchart.quality")),p={...l,quality:h};if(!h.accepted)return yield*new wW({status:"quality_failed",context:{...p,issues:w3(h)}});let m=yield*sz({try:()=>wd(d),catch:e=>new wW({status:"render_failed",context:{...p,issues:[wZ({code:"render_failed",stage:"render",ref:{kind:"diagram",id:o.id},message:e instanceof Error?e.message:"Unable to render flowchart scene.",hint:"Simplify the graph or retry with a smaller flowchart."})]}})}).pipe(lV("codeMode.buildFlowchart.render")),{excalidraw:g,validation:y}=yield*sL(()=>{let e=vK(m);return{excalidraw:e,validation:vQ(e)}}).pipe(lV("codeMode.buildFlowchart.exportValidate")),b={...p,partial:xm(m)};if(!y.ok)return yield*new wW({status:"export_failed",context:{...b,issues:w9(y.issues)}});let v=yield*w8({formats:s,scene:m,excalidraw:g,renderer:r.renderer}).pipe(a$(e=>new wW({status:"export_failed",context:{...b,issues:w6(e)}}))),w=yield*sL(()=>r.createId("artifact")),x=yield*wT(n.write({artifactId:w,diagramId:m.diagramId,formats:v,inlineFormats:w4(i.options)}),{artifactId:w,...i.requestId?{requestId:i.requestId}:{}}).pipe(a$(e=>new wW({status:"storage_failed",context:{...p,issues:[xw(e,"storage_write_failed")]}})));return{ok:!0,status:"accepted",buildId:a,...xh(i.requestId),normalizedSpec:o,quality:h,artifact:xp(x,r.artifactUrl),issues:[]}}),xS=lJ("codeMode.getArtifact.workflow")(function*(e){let t=yield*sL(()=>ba.safeParse(e)).pipe(lV("codeMode.getArtifact.parse"));if(!t.success)return yield*new wG({status:"invalid_input",issues:w2(t.error)});let r=yield*wK,n=yield*bq,i=t.data,s=yield*n.readManifest(i.artifactId).pipe(a$(e=>new wG({status:"storage_failed",issues:[xw(e,"storage_read_failed")]})));if(!s)return yield*new wG({status:"not_found",issues:[wZ({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 a=i.format??"scene";if(!s.formats.some(e=>e.format===a))return yield*new wG({status:"format_unavailable",issues:[wZ({code:"unsupported_artifact_format",stage:"storage",ref:{kind:"artifact",id:i.artifactId},message:`Artifact "${i.artifactId}" does not include format "${a}".`,hint:"Request a format listed in the artifact bundle."})]});let o=yield*n.read(i.artifactId,a).pipe(a$(e=>new wG({status:"storage_failed",issues:[xw(e,"storage_read_failed")]})));return o?{ok:!0,artifactId:i.artifactId,diagramId:s.diagramId,format:a,mimeType:o.mimeType,...r.artifactUrl?{url:r.artifactUrl({artifactId:i.artifactId,format:a})}:{},...!0!==i.inline||!bz(a)?{}:{inline:o.data},sizeBytes:o.sizeBytes,...s.provenance?{provenance:s.provenance}:{}}:yield*new wG({status:"format_unavailable",issues:[wZ({code:"patch_source_unavailable",stage:"storage",ref:{kind:"artifact",id:i.artifactId},message:`Artifact "${i.artifactId}" format "${a}" could not be read.`,hint:"Retry retrieval or rebuild the artifact."})]})}),x_=lJ("codeMode.applyDiagramPatch.workflow")(function*(e){let t=yield*sL(()=>bS.safeParse(e)).pipe(lV("codeMode.applyDiagramPatch.parse"));if(!t.success)return yield*new wH({status:"invalid_input",context:{issues:w2(t.error)}});let r=yield*wK,n=yield*bq,i=t.data,s=yield*sL(()=>r.createId("patch")),a={patchId:s,...xh(i.requestId)},o=w5(i.options),l=yield*xf(i).pipe(a$(e=>new wH({status:e.status,context:{...a,...e.context}}))),c={...a,...l.sourceArtifactId?{sourceArtifactId:l.sourceArtifactId}:{}},u=l.scene,d=xe(u),f=yield*sL(()=>{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),xt(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 xn(e))t.style.strokeColor&&(r.strokeColor=t.style.strokeColor),t.style.textColor&&(r.textColor=t.style.textColor);for(let r of xr(e))t.style.textColor&&(r.textColor=t.style.textColor);return[]}let r=xs(e,t.selector);if(0===r.nodes.length&&0===r.arrows.length&&0===r.texts.length)return[xa(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=xo(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=xo(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=xs(e,t.selector);if(0===n.nodes.length)return[xa(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=xo(e,t.id);r&&(r.x=t.x+t.width/2,r.y=t.y+t.height/2)}(e,r)}return xl(e,i),[];case"translate":return function(e,t){let r=xs(e,t.selector);if(0===r.nodes.length&&0===r.arrows.length&&0===r.texts.length)return[xa(t)];let n=new Set,i=new Set;for(let s of r.nodes){s.x+=t.dx,s.y+=t.dy,n.add(s.nodeId);let r=xo(e,s.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=xo(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 xl(e,[...n]),function(e){let t=[e.width],r=[e.height];for(let n of xt(e))t.push(n.x+n.width),r.push(n.y+n.height);for(let n of xr(e))t.push(n.x+(n.maxWidth??0)),r.push(n.y+n.fontSize);for(let n of xn(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 s=xs(e,t.selector);if(0===s.nodes.length&&0===s.arrows.length&&0===s.texts.length)return[xa(t)];for(let r of s.nodes){r.label=t.text;let n=xo(e,r.id);n&&(n.text=t.text)}for(let r of s.arrows){r.label=t.text;let n=xo(e,r.id);n&&(n.text=t.text)}for(let e of s.texts)e.text=t.text;return[];case"rerouteEdges":let a;return 0===(a=xs(e,t.selector)).arrows.length?[xa(t)]:a.arrows.flatMap(t=>xd(e,t))}}(u,e);if(t.length>0)return t}return[]}).pipe(lV("codeMode.applyDiagramPatch.operations"));if(f.length>0)return yield*new wH({status:f[0]?.code==="unknown_patch_target"?"target_not_found":"unsupported_operation",context:{...c,issues:f}});if(i.options?.preserveConnectivity!==!1){let e=xe(u);if(!(d.length===e.length&&d.every((t,r)=>t===e[r])))return yield*new wH({status:"connectivity_changed",context:{...c,issues:[wZ({code:"patch_preserve_connectivity_failed",stage:"flowchart",ref:{kind:"diagram",id:u.diagramId},message:"Patch changed the diagram edge connectivity.",hint:"Use buildFlowchart for process-graph structure or buildMindmap for hierarchy structure."})]}})}let h=yield*sL(()=>(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 s=[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.textColor?{textColor:r.textColor}:{},points:s,...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}:{},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}})(u)).pipe(lV("codeMode.applyDiagramPatch.normalize"));if(!h)return yield*new wH({status:"render_failed",context:{...c,issues:[wZ({code:"patch_output_invalid",stage:"render",ref:{kind:"diagram",id:u.diagramId},message:"Patched scene has an invalid arrow point list.",hint:"Reroute edges or rebuild the flowchart artifact."})]}});let{excalidraw:p,validation:m}=yield*sL(()=>{let e=vK(h);return{excalidraw:e,validation:vQ(e)}}).pipe(lV("codeMode.applyDiagramPatch.exportValidate")),g={...c,partial:xm(h)};if(!m.ok)return yield*new wH({status:"export_failed",context:{...g,issues:w9(m.issues)}});let y=yield*w8({formats:o,scene:h,excalidraw:p,renderer:r.renderer}).pipe(a$(e=>new wH({status:"export_failed",context:{...g,issues:w6(e)}}))),b=yield*sL(()=>r.createId("artifact")),v=yield*wT(n.write({artifactId:b,diagramId:h.diagramId,formats:y,inlineFormats:w4(i.options),...l.sourceArtifactId?{provenance:{sourceArtifactId:l.sourceArtifactId}}:{}}),{artifactId:b,...i.requestId?{requestId:i.requestId}:{}}).pipe(a$(e=>new wH({status:"storage_failed",context:{...c,issues:[xw(e,"storage_write_failed")]}})));return{ok:!0,status:"accepted",patchId:s,...xh(i.requestId),...l.sourceArtifactId?{sourceArtifactId:l.sourceArtifactId}:{},artifact:xp(v,r.artifactUrl),issues:[]}});function x$(e,t){return e.pipe(aT({onFailure:t,onSuccess:e=>e}))}let xO=lJ("codeMode.buildFlowchart")(e=>wV("buildFlowchart",e,x$(xk(e),xg))),xI=lJ("codeMode.buildMindmap")(e=>wV("buildMindmap",e,x$(xx(e),xy)));lJ("codeMode.getArtifact")(e=>wV("getArtifact",e,x$(xS(e),xb))),lJ("codeMode.applyDiagramPatch")(e=>wV("applyDiagramPatch",e,x$(x_(e),xv)));class xC extends gE()("CliFilesystemError",{cause:gb(),operation:m3,path:m3,message:m3}){}class xE extends gE()("CliInputError",{code:gn(["input_read_failed","invalid_json","interactive_stdin"]),message:m3,hint:m3}){}class xA extends gE()("CliValidationError",{message:m3,hint:m3,details:ge(m3)}){}class xT extends gE()("CliBuildError",{status:m3,message:m3,hint:m3,details:ge(m3)}){}class xM extends gE()("CliGenerationError",{code:gn(["provider_failure","generation_timeout","malformed_output","invalid_generated_document"]),message:m3,hint:m3,details:ge(m3)}){}class xN extends gE()("CliStorageError",{code:gn(["diagram_not_found","diagram_already_exists","diagram_busy","corrupt_record","unsafe_storage_entry","storage_commit_failed"]),diagramId:mY(m3),message:m3,hint:m3}){}class xj extends gE()("CliExportError",{code:gn(["format_unavailable","export_write_failed"]),format:m3,message:m3,hint:m3}){}function xF(e){return"string"==typeof e||"number"==typeof e||"symbol"==typeof e}let xL=hx(),xP=mV(yP,{errors:"all"}),xD=mV(y1,{errors:"all"});function xR(e){return xA.make({message:"The canonical diagram document is invalid.",hint:'Use {"type":"flowchart","spec":...} or {"type":"mindmap","spec":...}.',details:e})}function xU(e){return xL(e).issues.map(e=>{var t;let r=(e.path??[]).flatMap(e=>{let t=xF(e)?e:null!==e&&"object"==typeof e&&"key"in e&&xF(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 xB=lJ("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*xP(t.spec).pipe(a$(e=>xR(xU(e.issue))))}:"mindmap"===t.type?{type:"mindmap",spec:yield*xD(t.spec).pipe(a$(e=>xR(xU(e.issue))))}:yield*xR(['document.type: Expected "flowchart" or "mindmap".']):yield*xR(["document: Expected an object with type and spec."])}),xq=lJ("sketchi.cli.document.parseJson")(function*(e){let t=yield*sz({try:()=>JSON.parse(e),catch:()=>xE.make({code:"invalid_json",message:"The input is not valid JSON.",hint:"Pass one complete canonical document object."})});return yield*xB(t)});function xK(e){return`${JSON.stringify(e,null,2)}
38
+ `}function xz(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 xV(e){return/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}$/.test(e)?lP(e):tJ(xA.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 xJ extends nQ()("@sketchi/cli/DiagramBuilder"){}function xW(e){let t=e.ref?.path?` (${e.ref.path})`:"";return`${e.code}${t}: ${e.message}`}function xY(e,t){let r=e.formats.find(e=>e.format===t);return r?.inline!==void 0?lP(r.inline):tJ(xT.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 xG(e){let t=be.safeParse(e);return t.success?lP(t.data):tJ(xT.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 xH(e){let t=bi.safeParse(e);return t.success?lP(t.data):tJ(xT.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 xQ=lx(xJ,lD(function*(){let e=yield*bq,t=yield*wK;return{build:lJ("sketchi.cli.diagram.build")(function*(r){let n;if(!(n="flowchart"===r.type?yield*xO({spec:r.spec,options:{artifactFormats:["scene","excalidraw"],inlineArtifacts:["scene","excalidraw"]}}).pipe(af(bq,e),af(wK,t)):yield*xI({spec:r.spec,options:{artifactFormats:["scene","excalidraw"],inlineArtifacts:["scene","excalidraw"]}}).pipe(af(bq,e),af(wK,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(xW),"invalid_input"===n.status||"invalid_flowchart"===n.status||"invalid_mindmap"===n.status||"quality_failed"===n.status?xA.make({message:t,hint:r,details:i}):"storage_failed"===n.status?xN.make({code:"storage_commit_failed",message:t,hint:r}):xT.make({status:n.status,message:t,hint:r,details:i}))}let i=yield*xV(xz(r)),s=yield*xY(n.artifact,"scene").pipe(s8(xG)),a=yield*xY(n.artifact,"excalidraw").pipe(s8(xH));return{id:i,type:r.type,title:r.spec.title,document:r,scene:s,excalidraw:a}})}})),xZ=1,xX="manifest.json",x0="document.json",x1="scene.json",x2="diagram.excalidraw",x3="diagram.png",x5="revisions";class x4 extends gI("DiagramRecordManifest")({schemaVersion:m0(xZ),id:m3,type:gn(["flowchart","mindmap"]),title:m3,revision:gw.check(gh(0)),formats:ge(gn(["scene","excalidraw","png"]))}){}function x8(e){return{id:e.manifest.id,type:e.manifest.type,title:e.manifest.title,revision:e.manifest.revision,formats:e.manifest.formats}}function x6(e){return`${String(e).padStart(6,"0")}.json`}let x9=t("node:fs/promises");class x7 extends nQ()("@sketchi/cli/LocalFileSystem"){}function ke(e,t,r){return xC.make({cause:r,operation:e,path:t,message:`Filesystem ${e} failed for ${t}.`})}function kt(e,t){return"object"==typeof e&&null!==e&&"code"in e&&e.code===t}let kr=lv(x7,{makeDirectory:(e,t=!1)=>lL({try:()=>(0,x9.mkdir)(e,{recursive:t}).then(()=>void 0),catch:t=>ke("make-directory",e,t)}),tryWriteText:(e,t)=>lL({try:async()=>{try{let r=await (0,x9.open)(e,u8.constants.O_WRONLY|u8.constants.O_CREAT|u8.constants.O_EXCL|u8.constants.O_NOFOLLOW,384);try{await r.writeFile(t,{encoding:"utf8"}),await r.sync()}finally{await r.close()}return!0}catch(e){if(kt(e,"EEXIST"))return!1;throw e}},catch:t=>ke("write-exclusive",e,t)}),tryLinkFile:(e,t)=>lL({try:async()=>{try{return await (0,x9.link)(e,t),!0}catch(e){if(kt(e,"EEXIST")||kt(e,"ENOENT"))return!1;throw e}},catch:r=>ke("link-exclusive",`${e} -> ${t}`,r)}),makeTempDirectory:(e,t)=>lL({try:()=>(0,x9.mkdtemp)((0,u9.join)(e,t)),catch:t=>ke("make-temp-directory",e,t)}),list:e=>lL({try:async()=>(await (0,x9.readdir)(e,{withFileTypes:!0})).map(e=>({name:e.name,kind:e.isFile()?"file":e.isDirectory()?"directory":e.isSymbolicLink()?"symbolic-link":"other"})),catch:t=>ke("read-directory",e,t)}),kind:e=>lL({try:async()=>{try{let t=await (0,x9.lstat)(e);if(t.isFile())return"file";if(t.isDirectory())return"directory";if(t.isSymbolicLink())return"symbolic-link";return"other"}catch(e){if(kt(e,"ENOENT"))return"missing";if(kt(e,"ELOOP"))return"symbolic-link";throw e}},catch:t=>ke("stat",e,t)}),readText:e=>lL({try:async()=>{let t=await (0,x9.open)(e,u8.constants.O_RDONLY|u8.constants.O_NOFOLLOW);try{return await t.readFile({encoding:"utf8"})}finally{await t.close()}},catch:t=>ke("read",e,t)}),readBytes:e=>lL({try:async()=>{let t=await (0,x9.open)(e,u8.constants.O_RDONLY|u8.constants.O_NOFOLLOW);try{return new Uint8Array(await t.readFile())}finally{await t.close()}},catch:t=>ke("read",e,t)}),writeText:(e,t,r=!1)=>lL({try:async()=>{let n=u8.constants.O_WRONLY|u8.constants.O_CREAT|u8.constants.O_NOFOLLOW|(r?u8.constants.O_TRUNC:u8.constants.O_EXCL),i=await (0,x9.open)(e,n,384);try{await i.writeFile(t,{encoding:"utf8"}),await i.sync()}finally{await i.close()}},catch:t=>ke("write",e,t)}),writeBytes:(e,t,r=!1)=>lL({try:async()=>{let n=u8.constants.O_WRONLY|u8.constants.O_CREAT|u8.constants.O_NOFOLLOW|(r?u8.constants.O_TRUNC:u8.constants.O_EXCL),i=await (0,x9.open)(e,n,384);try{await i.writeFile(t),await i.sync()}finally{await i.close()}},catch:t=>ke("write",e,t)}),rename:(e,t)=>lL({try:()=>(0,x9.rename)(e,t),catch:r=>ke("rename",`${e} -> ${t}`,r)}),tryRenameDirectory:(e,t)=>lL({try:async()=>{try{return await (0,x9.rename)(e,t),!0}catch(e){if(kt(e,"EEXIST")||kt(e,"ENOTEMPTY"))return!1;if(kt(e,"EPERM"))try{if((await (0,x9.lstat)(t)).isDirectory())return!1}catch{}throw e}},catch:r=>ke("rename-exclusive-directory",`${e} -> ${t}`,r)}),removeFile:e=>lL({try:async()=>{try{return await (0,x9.unlink)(e),!0}catch(e){if(kt(e,"ENOENT"))return!1;throw e}},catch:t=>ke("remove-file",e,t)}),remove:e=>lL({try:()=>(0,x9.rm)(e,{recursive:!0,force:!0}),catch:t=>ke("remove",e,t)})});class kn extends nQ()("@sketchi/cli/StorageRoot"){}class ki extends nQ()("@sketchi/cli/DiagramStore"){}let ks=".locks",ka="free.",ko="owner.",kl=".owner-candidate.",kc=".json",ku="recovery",kd=".backup.",kf=`.stage.${String(process.pid)}.`,kh=o9("10 millis").pipe(o7({times:50})),kp=lv(kn,{path:(0,u9.join)((0,u6.homedir)(),".sketchi","diagrams")});function km(e,t,r,n){return xN.make({code:e,message:t,hint:r,...n?{diagramId:n}:{}})}function kg(e){return Buffer.from(e,"utf8").toString("base64url")}function ky(e,t){return e<t?-1:+(e>t)}function kb(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 kv(e,t){return"object"==typeof e.cause&&null!==e.cause&&"code"in e.cause&&e.cause.code===t}function kw(e,t){return(0,u9.join)(e,t)}function kx(e,t){return km("unsafe_storage_entry",`Unsafe local storage entry at ${e}.`,"Replace symbolic links or special files with ordinary Sketchi record files.",t)}let kk=lx(ki,lD(function*(){let e=yield*x7,t=yield*kn,r=lJ("sketchi.cli.storage.ensureOwnedDirectory")(function*(t){let r=yield*e.kind(t);if("missing"===r&&(yield*e.makeDirectory(t).pipe(ab(e=>kv(e,"EEXIST")?sK:tJ(e))),r=yield*e.kind(t)),"directory"!==r)return yield*kx(t)}),n=lJ("sketchi.cli.storage.ensureRoot")(function*(){yield*r((0,u9.dirname)(t.path)),yield*r(t.path),yield*r((0,u9.join)(t.path,ks))}),i=lJ("sketchi.cli.storage.assertSafeTree")(function*(t,r){for(let n of yield*e.list(t)){let e=(0,u9.join)(t,n.name);if("symbolic-link"===n.kind||"other"===n.kind)return yield*kx(e,r);"directory"===n.kind&&(yield*i(e,r))}}),s=lJ("sketchi.cli.storage.recoverStages")(function*(){for(let r of(yield*n(),[...yield*e.list(t.path)].sort((e,t)=>ky(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&&kb(n)||(yield*e.remove((0,u9.join)(t.path,r.name)))}}),a=lJ("sketchi.cli.storage.recoverRecordTransactions")(function*(r){yield*n(),yield*s();let i=`${kd}${kg(r)}.`;for(let n of[...yield*e.list(t.path)].filter(e=>e.name.startsWith(i)).sort((e,t)=>ky(e.name,t.name))){let i=(0,u9.join)(t.path,n.name),s=kw(t.path,r);"missing"===(yield*e.kind(s))?yield*e.rename(i,s):yield*e.remove(i)}}),o=lJ("sketchi.cli.storage.initializeLockDirectory")(function*(r){let n=(0,u9.join)(t.path,ks,`${kg(r)}.lock`),i=yield*e.kind(n);if("directory"===i)return n;if("missing"!==i)return yield*kx(n,r);let s=(0,u9.join)(t.path,ks);return yield*lz(e.makeTempDirectory(s,`.init.${kg(r)}.`),t=>lD(function*(){let i=crypto.randomUUID();return(yield*e.writeText((0,u9.join)(t,`${ka}${i}${kc}`),xK({token:i})),(yield*e.tryRenameDirectory(t,n))||"directory"===(yield*e.kind(n)))?n:yield*kx(n,r)}),t=>e.remove(t))}),l=e=>km("diagram_busy",`Diagram "${e}" is being changed by another Sketchi process.`,"Wait for that command to finish, then retry.",e),c=lJ("sketchi.cli.storage.readLockEntries")(function*(t,r){let n=[...yield*e.list(t)].sort((e,t)=>ky(e.name,t.name)),i=[];for(let s of n){let n=(0,u9.join)(t,s.name);if("file"!==s.kind)return yield*kx(n,r);let a=function(e){if(!e.startsWith(ka)||!e.endsWith(kc))return;let t=e.slice(ka.length,-kc.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}:{}}}(s.name);if(a){i.push({name:s.name,path:n,state:"free",token:a.token,...a.releasedOwnerToken?{releasedOwnerToken:a.releasedOwnerToken}:{}});continue}if(s.name.startsWith(ka))return yield*kx(n,r);let o=function(e){if(!e.startsWith(kl)||!e.endsWith(kc))return;let t=e.slice(kl.length,-kc.length);return/^[a-zA-Z0-9_-]+$/.test(t)?t:void 0}(s.name);if(o){i.push({name:s.name,path:n,state:"unpublished-owner",token:o});continue}if(s.name.startsWith(kl)||!s.name.startsWith(ko)||!s.name.endsWith(kc))return yield*kx(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(a$(e=>kv(e,"ENOENT")?l(r):e))));if(!c)return yield*l(r);if(s.name!==`${ko}${c.token}${kc}`)return yield*kx(n,r);i.push({name:s.name,path:n,token:c.token,state:kb(c.pid)?"live-owner":"stale-owner"})}return i}),u=lJ("sketchi.cli.storage.acquireLockOnce")(function*(t){yield*n();let r=yield*o(t),i=yield*c(r,t),s=new Set(i.flatMap(e=>e.releasedOwnerToken?[e.releasedOwnerToken]:[]));if(i.some(e=>"live-owner"===e.state&&!s.has(e.token)))return yield*l(t);let a=i.find(e=>"free"===e.state)??i.find(e=>"stale-owner"===e.state);if(!a){let n=(0,u9.join)(r,`${ka}${ku}${kc}`);if(!(yield*e.tryWriteText(n,xK({token:ku}))))return yield*l(t);a={name:`${ka}${ku}${kc}`,path:n,state:"free",token:ku}}let u=crypto.randomUUID(),d=(0,u9.join)(r,`${ko}${u}${kc}`),f=(0,u9.join)(r,`${kl}${u}${kc}`);return yield*a1(lz(lP(f),()=>lD(function*(){if(yield*e.writeText(f,xK({pid:process.pid,token:u})),!(yield*e.tryLinkFile(f,d)))return yield*l(t);if(!(yield*e.removeFile(a.path).pipe(ab(t=>e.removeFile(d).pipe(s2(tJ(t)))))))return yield*e.removeFile(d),yield*l(t);for(let t of i)t.path!==a.path&&(yield*e.removeFile(t.path).pipe(ab(()=>sK)));return{directory:r,ownerPath:d,token:u}}),t=>e.removeFile(t).pipe(ab(()=>sK))))}),d=lJ("sketchi.cli.storage.releaseLock")(function*(t,r){let n=crypto.randomUUID(),i=(0,u9.join)(r.directory,`${ka}${n}.${r.token}${kc}`),s=xK({token:n,releasedOwnerToken:r.token});if(!(yield*e.writeText(i,s).pipe(s1(!0),ab(()=>e.tryWriteText(i,s).pipe(s8(t=>t?lP(!0):e.kind(i).pipe(ae(e=>"file"===e))),ab(()=>lP(!1))))))){if(yield*e.removeFile(r.ownerPath))return;return yield*km("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(aT({onFailure:()=>!0,onSuccess:e=>e}))))return yield*e.removeFile(i).pipe(ab(()=>sK)),yield*km("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 lz((n=u(e),r?n.pipe(lT({schedule:kh,while:e=>"CliStorageError"===e._tag&&"diagram_busy"===e.code})):n),()=>a(e).pipe(s2(t)),t=>d(e,t).pipe(ab(()=>sK)))},h=lJ("sketchi.cli.storage.decodeManifest")(function*(t,r){let n=yield*e.readText(t),i=yield*sz({try:()=>JSON.parse(n),catch:()=>km("corrupt_record",`Diagram "${r}" has an invalid manifest.`,"Inspect manifest.json and restore it from a known-good backup.",r)});return yield*mV(x4)(i).pipe(a$(()=>km("corrupt_record",`Diagram "${r}" has an incompatible manifest.`,`Expected manifest schema version ${String(1)}.`,r)))}),p=lJ("sketchi.cli.storage.decodeDocument")(function*(t,r){let n=yield*e.readText(t),i=yield*sz({try:()=>JSON.parse(n),catch:()=>km("corrupt_record",`Diagram "${r}" has invalid document JSON.`,"Recover a prior canonical document from the revisions directory.",r)});return yield*xB(i).pipe(a$(()=>km("corrupt_record",`Diagram "${r}" has an invalid canonical document.`,"Recover a prior canonical document from the revisions directory.",r)))}),m=lJ("sketchi.cli.storage.loadUnlocked")(function*(r){let n=kw(t.path,r),s=yield*e.kind(n);if("missing"===s)return yield*km("diagram_not_found",`Diagram "${r}" does not exist.`,"Run sketchi list to discover stored diagram ids.",r);if("directory"!==s)return yield*kx(n,r);yield*i(n,r);let a=yield*h((0,u9.join)(n,xX),r);if(a.id!==r)return yield*km("corrupt_record",`Diagram directory "${r}" contains manifest id "${a.id}".`,"Make the directory name and manifest id agree before retrying.",r);let o=yield*p((0,u9.join)(n,x0),r);if(a.type!==o.type||a.title!==o.spec.title)return yield*km("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[x1,x2])if((yield*e.kind((0,u9.join)(n,t)))!=="file")return yield*km("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,u9.join)(n,x3));if("file"!==l&&"missing"!==l)return yield*kx((0,u9.join)(n,x3),r);let c="file"===l?["scene","excalidraw","png"]:["scene","excalidraw"];if(a.formats.length!==c.length||a.formats.some((e,t)=>e!==c[t]))return yield*km("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,u9.join)(n,x5);return{manifest:a,document:o,revisions:[...yield*e.list(u)].filter(e=>"file"===e.kind&&e.name.endsWith(".json")).map(e=>e.name).sort(ky)}}),g=lJ("sketchi.cli.storage.copySafeTree")(function*(t,r,n){for(let i of yield*e.list(t)){let s=(0,u9.join)(t,i.name),a=(0,u9.join)(r,i.name);if("directory"===i.kind)yield*e.makeDirectory(a),yield*g(s,a,n);else{if("file"!==i.kind)return yield*kx(s,n);let t=yield*e.readBytes(s);yield*e.writeBytes(a,t)}}}),y=lJ("sketchi.cli.storage.writeBuilt")(function*(t,r,n){yield*e.makeDirectory((0,u9.join)(t,x5),!0),yield*e.writeText((0,u9.join)(t,x0),xK(r.document),!0),yield*e.writeText((0,u9.join)(t,x1),xK(r.scene),!0),yield*e.writeText((0,u9.join)(t,x2),xK(r.excalidraw),!0);let i=(0,u9.join)(t,x3);yield*e.remove(i),r.png&&(yield*e.writeBytes(i,r.png)),yield*e.writeText((0,u9.join)(t,xX),xK(n),!0)}),b=lJ("sketchi.cli.storage.create")(function*(r){return yield*f(r.id,lD(function*(){let n=kw(t.path,r.id);if((yield*e.kind(n))!=="missing")return yield*km("diagram_already_exists",`Diagram "${r.id}" already exists.`,"Use sketchi edit for full-document replacement.",r.id);let i=x4.make({schemaVersion:1,id:r.id,type:r.type,title:r.title,revision:1,formats:r.png?["scene","excalidraw","png"]:["scene","excalidraw"]});return yield*lz(e.makeTempDirectory(t.path,kf),t=>lD(function*(){return yield*y(t,r,i),yield*e.rename(t,n),{manifest:i,document:r.document,revisions:[]}}),t=>e.remove(t))}))}),v=lJ("sketchi.cli.storage.edit")(function*(r,n){return yield*f(r,lD(function*(){let i=yield*m(r);if(n.id!==r)return yield*km("storage_commit_failed",`Edited document id "${n.id}" does not match "${r}".`,"Keep spec.id equal to the diagram id being edited.",r);let s=kw(t.path,r),a=x4.make({schemaVersion:1,id:r,type:n.type,title:n.title,revision:i.manifest.revision+1,formats:n.png?["scene","excalidraw","png"]:["scene","excalidraw"]});return yield*lz(e.makeTempDirectory(t.path,kf),o=>lD(function*(){yield*g(s,o,r),yield*e.writeText((0,u9.join)(o,x5,x6(i.manifest.revision)),xK(i.document)),yield*y(o,n,a);let l=(0,u9.join)(t.path,`${kd}${kg(r)}.${String(process.pid)}.${crypto.randomUUID()}`);return yield*e.rename(s,l),(yield*e.rename(o,s).pipe(aA({onFailure:t=>e.rename(l,s).pipe(aA({onFailure:()=>tJ(km("storage_commit_failed",`Atomic edit commit and rollback both failed for "${r}".`,"Retry; Sketchi will recover the backup transaction before the next operation.",r)),onSuccess:()=>tJ(t)})),onSuccess:()=>lP(!0)})))&&(yield*e.remove(l).pipe(ab(()=>sK))),{manifest:a,document:n.document,revisions:[...i.revisions,x6(i.manifest.revision)].sort(ky)}}),t=>e.remove(t))}))}),w=lJ("sketchi.cli.storage.show")(e=>f(e,m(e),!0)),x=lJ("sketchi.cli.storage.list")(function*(){yield*n(),yield*s();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(kd))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(ky)){let t=yield*w(e);i.push(x8(t))}return i});return{create:b,edit:v,show:w,list:x,readArtifact:lJ("sketchi.cli.storage.readArtifact")(function*(r,n){return yield*f(r,lD(function*(){return(yield*m(r)).manifest.formats.includes(n)?yield*e.readBytes((0,u9.join)(kw(t.path,r),function(e){switch(e){case"scene":return x1;case"excalidraw":return x2;case"png":return x3}}(n))):yield*xj.make({code:"format_unavailable",format:n,message:`Diagram "${r}" has no stored ${n} artifact.`,hint:"png"===n?"PNG export is offline-only and requires an already-stored PNG artifact.":"Edit the diagram to rebuild its local artifacts."})}),!0)})}})),kS=lJ("sketchi.cli.export.writeFile")(function*(e,t){let r=yield*x7,n=(0,u9.dirname)(e);if((yield*r.kind(n))!=="directory")return yield*xj.make({code:"export_write_failed",format:(0,u9.basename)(e),message:`Export destination directory does not exist: ${n}.`,hint:"Create the destination directory and retry."});let i=(0,u9.join)(n,`.${(0,u9.basename)(e)}.sketchi.${String(process.pid)}.${crypto.randomUUID()}`);return yield*lz(lP(i),n=>r.writeBytes(n,t).pipe(s2(r.rename(n,e)),a$(()=>xj.make({code:"export_write_failed",format:(0,u9.basename)(e),message:`Unable to write export destination ${e}.`,hint:"Check the destination path and permissions, then retry."}))),e=>r.remove(e))}),k_="gemini-3.1-flash-lite",k$="https://playground.sketchi.app/api/v1/generate",kO="SKETCHI_GENERATE_ENDPOINT";function kI(){return xM.make({code:"provider_failure",message:"The Sketchi generate API could not be reached.",hint:"Check your network connection and retry; generate is the only command that uses the network.",details:["transport"]})}function kC(){return xM.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 kE(){return xM.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 kA=lJ("sketchi.cli.generate.request")(function*(e){let t=yield*lL({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:()=>kI()}),r=yield*lL({try:()=>t.text(),catch:()=>kI()});if(!t.ok)return yield*tJ(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 xM.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 xM.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 xM.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 xM.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*tJ(kC()))}),kT=lJ("sketchi.cli.generate")(function*(e){var t,r;let n,i,s=yield*ki,a=yield*kA(e),o=yield*xB(a.document).pipe(a$(()=>kE())),l=yield*xV(xz(o)).pipe(a$(()=>kE())),c=yield*(t=a.scene,(n=be.safeParse(t)).success?lP(n.data):tJ(kC())),u=yield*(r=a.excalidraw,(i=bi.safeParse(r)).success?lP(i.data):tJ(kC())),d={id:l,type:o.type,title:o.spec.title,document:o,scene:c,excalidraw:u};return{diagram:yield*s.create(d),model:a.model||e.model,provider:a.provider}}),kM=e=>tY(t=>e(t.getRef(oL))),kN=(...e)=>kM(t=>sL(()=>{t.log(...e)})),kj="~effect/cli/CliError";class kF extends gE(`${kj}/UnrecognizedOption`)("UnrecognizedOption",{option:m3,command:mG(ge(m3)),suggestions:ge(m3)}){[kj]=kj;get message(){let e=this.suggestions.length>0?`
39
+
40
+ Did you mean this?
41
+ ${this.suggestions.join("\n ")}`:"";return(this.command?`Unrecognized flag: ${this.option} in command ${this.command.join(" ")}`:`Unrecognized flag: ${this.option}`)+e}}class kL extends gE(`${kj}/DuplicateOption`)("DuplicateOption",{option:m3,parentCommand:m3,childCommand:m3}){[kj]=kj;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 kP extends gE(`${kj}/MissingOption`)("MissingOption",{option:m3}){[kj]=kj;get message(){return`Missing required flag: --${this.option}`}}class kD extends gE(`${kj}/MissingArgument`)("MissingArgument",{argument:m3}){[kj]=kj;get message(){return`Missing required argument: ${this.argument}`}}class kR extends gE(`${kj}/InvalidValue`)("InvalidValue",{option:m3,value:m3,expected:m3,kind:gr([m0("flag"),m0("argument")])}){[kj]=kj;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 kU extends gE(`${kj}/UnknownSubcommand`)("UnknownSubcomand",{subcommand:m3,parent:mG(ge(m3)),suggestions:ge(m3)}){[kj]=kj;get message(){let e=this.suggestions.length>0?`
42
+
43
+ Did you mean this?
44
+ ${this.suggestions.join("\n ")}`:"";return this.parent?`Unknown subcommand "${this.subcommand}" for "${this.parent.join(" ")}"${e}`:`Unknown subcommand "${this.subcommand}"${e}`}}class kB extends gE(`${kj}/UserError`)("UserError",{cause:gb()}){[kj]=kj}let kq=gr([kF,kL,kP,kD,kR,kU,kB]);class kK extends gE(`${kj}/ShowHelp`)("ShowHelp",{commandPath:ge(m3),errors:ge(kq)}){[kj]=kj;[lZ]=+!!this.errors.length;[l0]=!1;get message(){return"Help requested"}}a(2532),a(3176),a(2976);let kz=io("effect/ConfigProvider",{defaultValue:()=>(function(){var e;let t,r,n=(void 0)??{...globalThis?.process?.env,...import.meta?.env},i=false,s=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=>lP(function(e,t,r,n){var i;let s=(i=t[r.map(String).join("_")],""!==i||n?i:void 0),a=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=a?.children?Object.keys(a.children):[];return 0===o.length?void 0===s?void 0:{_tag:"Value",value:s}:o.every(e=>kW.test(e))?{_tag:"Array",length:Math.max(...o.map(e=>parseInt(e,10)))+1,value:s}:{_tag:"Record",keys:new Set(o),value:s}}(s,n,e,i)),transform:kJ},e=e=>t.get(t.transform(e)),(r=Object.create(kV)).state=t,r.load=e,r})()}),kV={...tw,toJSON:()=>({_id:"ConfigProvider"})},kJ=e=>e,kW=/^(0|[1-9][0-9]*)$/,kY=gn(["true","yes","on","1","y"]),kG=gn(["false","no","off","0","n"]),kH=gn([...kY.literals,...kG.literals]).pipe(go(m4,hK({decode:e=>"true"===e||"yes"===e||"on"===e||"1"===e||"y"===e,encode:e=>e?"true":"false"}))),kQ={"~effect/cli/Primitive":{_A:ec}},kZ=mz(kY),kX=mz(kG),k0=e=>"Boolean"===e._tag,k1=(e,t)=>Object.assign(Object.create(kQ),{_tag:e,parse:t}),k2=(B=mV(mW(gN(kH.ast),{schema:kH})),k1("Boolean",e=>a$(B(e),e=>e.message))),k3=k1("String",e=>lP(e)),k5=(()=>tJ("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"}}),k4=e=>"Choice"===e._tag?e.choiceKeys:void 0,k8="~effect/cli/Param",k6="argument",k9={[k8]:{_A:ec},pipe(){return es(this,arguments)}},k7=e=>"flag"===e.kind,Se=e=>Object.assign(Object.create(k9),{_tag:"Single",...e,description:e.description??rx(),aliases:e.aliases??[],hidden:e.hidden??!1,parse:t=>e.kind===k6?Sf(e.name,e.primitiveType,t):Sh(e.name,e.primitiveType,t)}),St=(e,t)=>Se({name:t,primitiveType:k3,kind:e}),Sr=(e,t,r)=>{let n,i;return Se({name:t,primitiveType:(n=new Map(r),i=r.map(([e])=>tr(e)).join(" | "),Object.assign(k1("Choice",e=>n.has(e)?lP(n.get(e)):tJ(`Expected ${i}, got ${tr(e)}`)),{choiceKeys:r.map(([e])=>e)})),kind:e})},Sn=/^-+/,Si=el(2,(e,t)=>Sy(e,e=>Se({...e,aliases:[...e.aliases,t.replace(Sn,"")]}))),Ss=el(2,(e,t)=>Sy(e,e=>Se({...e,description:rk(t)}))),Sa=el(2,(e,t)=>Object.assign(Object.create(k9),{_tag:"Map",kind:e.kind,param:e,f:t,parse:r=>ae(e.parse(r),([e,r])=>[e,t(r)])})),So=(e,t)=>Object.assign(Object.create(k9),{_tag:"Transform",kind:e.kind,param:e,f:t,parse:t(e.parse)}),Sl=el(2,(e,t)=>So(e,e=>r=>s8(e(r),([e,r])=>t(r).pipe(ae(t=>[e,t]))))),Sc=e=>{let t=sG(function*(t){let r=Sv(e);return k7(r)&&k0(r.primitiveType)&&![r.name,...r.aliases].some(e=>(t.flags[e]??[]).length>0)?[t.arguments,rx()]:yield*e.parse(t).pipe(ae(([e,t])=>[e,rk(t)]),a_({MissingOption:()=>lP([t.arguments,rx()]),MissingArgument:()=>lP([t.arguments,rx()])}))});return Object.assign(Object.create(k9),{_tag:"Optional",kind:e.kind,param:e,parse:t})},Su=el(2,(e,t)=>tk(t)?Sl(Sc(e),rO({onNone:()=>t,onSome:lP})):Sa(Sc(e),rT(()=>t))),Sd=el(2,(e,t)=>Sy(e,e=>Se({...e,typeName:t}))),Sf=sG(function*(e,t,r){if(0===r.arguments.length)return yield*new kD({argument:e});let n=r.arguments[0],i=yield*a$(t.parse(n),t=>new kR({option:e,value:n,expected:t,kind:"argument"}));return[r.arguments.slice(1),i]}),Sh=sG(function*(e,t,r){let n=r.flags[e];if(void 0===n||0===n.length)if(k0(t))return[r.arguments,!1];else return yield*new kP({option:e});let i=n[0],s=yield*a$(t.parse(i),t=>new kR({option:e,value:i,expected:t,kind:"flag"}));return[r.arguments,s]}),Sp=sG(function*(e,t,r,n){let i=[],s=n?.min??0,a=n?.max??1/0,o=0,l=r.arguments;for(;l.length>0&&o<a;){let[t,n]=yield*e.parse({flags:r.flags,arguments:l});i.push(n),l=t,o++}return o<s?yield*new kR({option:t.name,value:`${o} values`,expected:`at least ${s} value${1===s?"":"s"}`,kind:t.kind}):[l,i]}),Sm=sG(function*(e,t,r,n){let i=[],s=[t.name,...t.aliases].flatMap(e=>r.flags[e]??[]),a=s.length;if(eO(n?.min)&&a<n.min)return yield*0===a?new kP({option:t.name}):new kR({option:t.name,value:`${a} occurrences`,expected:`at least ${n.min} value${1===n.min?"":"s"}`,kind:t.kind});if(eO(n?.max)&&a>n.max)return yield*new kR({option:t.name,value:`${a} occurrences`,expected:`at most ${n.max} value${1===n.max?"":"s"}`,kind:t.kind});for(let r of s){let[,n]=yield*e.parse({flags:{[t.name]:[r]},arguments:[]});i.push(n)}return[r.arguments,i]}),Sg=(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)}},Sy=(e,t)=>Sg(e,{Single:e=>t(e),Map:e=>Sa(Sy(e.param,t),e.f),Transform:e=>So(Sy(e.param,t),e.f),Optional:e=>Sc(Sy(e.param,t)),Variadic:e=>{var r,n;let i;return r=Sy(e.param,t),n={min:rB(e.min),max:rB(e.max)},i=Sv(r),Object.assign(Object.create(k9),{_tag:"Variadic",kind:r.kind,param:r,min:rP(n?.min),max:rP(n?.max),parse:e=>"argument"===i.kind?Sp(r,i,e,n):Sm(r,i,e,n)})}}),Sb=e=>Sg(e,{Single:e=>[e],Map:e=>Sb(e.param),Transform:e=>Sb(e.param),Optional:e=>Sb(e.param),Variadic:e=>Sb(e.param)}),Sv=e=>{let t=Sb(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]},Sw=e=>Sg(e,{Single:()=>({isOptional:!1,isVariadic:!1,variadicMin:rx(),variadicMax:rx()}),Map:e=>Sw(e.param),Transform:e=>Sw(e.param),Optional:e=>({...Sw(e.param),isOptional:!0}),Variadic:e=>({...Sw(e.param),isVariadic:!0,variadicMin:e.min,variadicMax:e.max})}),Sx=io("effect/cli/CliOutput",{defaultValue:()=>Sk()}),Sk=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},s=n?"\x1b[0m":"",a=n?"\x1b[31m":"",o=n?"\x1b[1m":"";return{formatHelpDoc:e=>SO(e,i),formatCliError:e=>e.message,formatError:e=>`
45
+ ${o}${a}ERROR${s}
46
+ ${e.message}${s}`,formatErrors:e=>{if(0===e.length)return"";if(1===e.length)return`
47
+ ${o}${a}ERROR${s}
48
+ ${e[0].message}${s}`;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(`
49
+ ${o}${a}ERRORS${s}`),t))for(let t of e)r.push(` ${t.message}${s}`);return r.join("\n")},formatVersion:(e,t)=>`${i.bold(e)} ${i.dim("v")}${i.bold(t)}`}},SS=e=>e.replace(/\u001B\[[0-9;]*m/g,"").length,S_=(e,t)=>{let r=Math.max(...e.map(e=>SS(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-SS(e)),e+" ".repeat(r)}${t}`}).join("\n")},S$=(e,t)=>t?`${e}, ${t}`:e,SO=(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),s=`${n} ${i}`,a=e.required?"":t.dim(" (optional)");return{left:s,right:rT(e.description,()=>"")+a}});r.push(S_(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:rT(e.description,()=>"")}});r.push(S_(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:rT(e.description,()=>"")}});r.push(S_(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(S_(n.commands.map(e=>({left:t.cyan(S$(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(S_(i.commands.map(e=>({left:t.cyan(S$(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 s of e.examples)s.description?(n||r.push(""),r.push(` ${t.dim(`# ${s.description}`)}`)):i&&r.push(""),r.push(` ${t.cyan(s.command)}`),n=!1,i=!!s.description;r.push("")}return""===r[r.length-1]&&r.pop(),r.join("\n")},SI=e=>e.replace(/[^a-zA-Z0-9_]/g,"_"),SC=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},SE=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") )'}},SA=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}},ST=(e,t,r)=>{let n=[...t,e.name],i=`_${n.map(SI).join("_")}`;r.push(`${i}()`),r.push("{"),r.push(" local cur prev words cword"),r.push(" _init_completion || return"),r.push("");let s=e.flags.filter(e=>"Boolean"!==e.type._tag);if(s.length>0){for(let e of(r.push(" # Flag value completions"),r.push(' case "$prev" in'),s)){let t=[`--${e.name}`];for(let r of e.aliases)t.push(1===r.length?`-${r}`:`--${r}`);let n=SE(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(SI).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 SC(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(SC).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 a=e.arguments.filter(e=>void 0!==SA(e.type));if(a.length>0)for(let e of(r.push(" # Positional argument completions"),a)){let t=SA(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))ST(t,n,r)},SM=e=>e.replace(/'/g,"\\'"),SN=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(" ")}`},Sj=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 '${SM(e.description)}'`);let r=SF(e.type);return r&&t.push(r),t},SF=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"}},SL=e=>{switch(e._tag){case"Choice":return`-r -f -a '${e.values.join(" ")}'`;case"Path":return"-r -F";default:return}},SP=(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)),s=i?`-n '${i}'`:"";if(!t.arguments.some(e=>"Path"===e.type._tag)){let t=[`complete -c ${e}`];s&&t.push(s),t.push("-f"),n.push(t.join(" "))}for(let r of t.subcommands){let t=[`complete -c ${e}`];s&&t.push(s),t.push(`-f -a '${SM(r.name)}'`),r.description&&t.push(`-d '${SM(r.description)}'`),n.push(t.join(" "))}for(let r of t.flags){let t="Boolean"===r.type._tag,s=t?i?`${i}; and ${SN(r)}`:SN(r):i,a=s?`-n '${s}'`:"",o=[`complete -c ${e}`];if(a&&o.push(a),o.push(...Sj(r)),n.push(o.join(" ")),t){let t=[`complete -c ${e}`];a&&t.push(a),t.push(`-l no-${r.name}`),r.description&&t.push(`-d '${SM(`Disable ${r.name}`)}'`),n.push(t.join(" "))}}if(t.flags.length>0){let r='not string match -q -- "-*" (commandline -ct)',s=i?`${i}; and ${r}`:r;for(let r of t.flags){let t=`${s}; and ${SN(r)}`,i="Boolean"===r.type._tag,a=[`complete -c ${e}`];if(a.push(`-n '${t}'`),a.push(`-f -a '--${r.name}'`),r.description&&a.push(`-d '${SM(r.description)}'`),n.push(a.join(" ")),i){let i=[`complete -c ${e}`];i.push(`-n '${t}'`),i.push(`-f -a '--no-${r.name}'`),r.description&&i.push(`-d '${SM(`Disable ${r.name}`)}'`),n.push(i.join(" "))}}}for(let r of t.arguments){let t=SL(r.type);if(t){let i=[`complete -c ${e}`];s&&i.push(s),i.push(t),r.description&&i.push(`-d '${SM(r.description)}'`),n.push(i.join(" "))}}for(let i of t.subcommands)SP(e,i,[...r,i.name],n)},SD=e=>e.replace(/\\/g,"\\\\").replace(/'/g,"'\\''").replace(/:/g,"\\:"),SR=e=>e.replace(/[^a-zA-Z0-9_]/g,"_"),SU=e=>{let t=[],r=e.description?`[${SD(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 s of(t.push(`'${i}--${e.name}${r}${n}'`),e.aliases)){let e=1===s.length?"-":"--";t.push(`'${i}${e}${s}${r}${n}'`)}if("Boolean"===e.type._tag){let r=e.description?`[${SD(`Disable ${e.name}`)}]`:"";t.push(`'${i}--no-${e.name}${r}'`)}return t},SB=e=>{let t=e.description?SD(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}'`},Sq=(e,t,r)=>{let n=[...t,e.name],i=`_${n.map(SR).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?SD(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 SU(t))r.push(` ${e}`);for(let t of e.arguments)r.push(` ${SB(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(SR).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(...SU(r));for(let r of e.arguments)t.push(SB(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))Sq(t,n,r)},SK=e=>Se({name:e,primitiveType:k2,kind:"flag"}),Sz=(e,t)=>Sr("flag",e,t.map(e=>[e,e])),SV=el(2,(e,t)=>Si(e,t)),SJ=el(2,(e,t)=>Ss(e,t)),SW=el(2,(e,t)=>Sd(e,t)),SY=e=>Sc(e),SG=el(2,(e,t)=>Sa(e,t)),SH="~effect/cli/Command/Config/Internal",SQ=e=>{let t=[],r=[],n=[];return{[SH]:SH,flags:r,arguments:n,orderedParams:t,tree:function e(i){let s={};for(let a in i)s[a]=function i(s){if(Array.isArray(s))return{_tag:"Array",children:s.map(e=>i(e))};if(!eT(s,k8))return{_tag:"Nested",tree:e(s)};{let e=t.length;return t.push(s),"argument"===s.kind?n.push(s):r.push(s),{_tag:"Param",index:e}}}(i[a]);return s}(e)}},SZ=SQ({}),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:S0(e.tree,t)}}},S0=(e,t)=>{let r={};for(let n in e)r[n]=SX(e[n],t);return r},S1=(e,t)=>{let r=e.orderedParams.length;return{[SH]:SH,flags:[...e.flags,...t.flags],arguments:[...e.arguments,...t.arguments],orderedParams:[...e.orderedParams,...t.orderedParams],tree:{...e.tree,...S0(t.tree,r)}}},S2=(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 S2(r.tree,t)}}(e[n]);return r},S3="~effect/cli/Command",S5=e=>e,S4={...nz({label:"Command",evaluate(){return S5(this).service}})},S8=e=>{let t=e.config,r=e.contextConfig??SZ,n=e.service??nQ(`${S3}/${e.name}`),i=e.annotations??n5,s=e.globalFlags??[],a=e.subcommands??[],o=e.parse??S7(t),l=e.parseContext??S7(r);return Object.assign(Object.create(S4),{[S3]:S3,name:e.name,examples:e.examples??[],annotations:i,globalFlags:s,subcommands:a,hidden:e.hidden??!1,config:t,contextConfig:r,service:n,parse:o,parseContext:l,handle:(t,r)=>eO(e.handle)?e.handle(t,r):tJ(new kK({commandPath:r,errors:[]})),buildHelpDoc:r=>{let n=[],s=[];for(let e of t.arguments){let t=Sb(e),r=Sw(e);for(let e of t)n.push({name:e.name,type:e.typeName??k5(e.primitiveType),description:e.description,required:!r.isOptional,variadic:r.isVariadic})}let o=r.length>0?r.join(" "):e.name;for(let e of(a.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 Sb(e))t.hidden||s.push(S6(t));let l=[];for(let e of a){let t=e.commands.filter(e=>!e.hidden);0!==t.length&&l.push({group:e.group,commands:nR(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:s,annotations:i,...n.length>0&&{args:n},...l.length>0&&{subcommands:l},...c.length>0&&{examples:c}}},...eO(e.description)?{description:e.description}:{},...eO(e.shortDescription)?{shortDescription:e.shortDescription}:{},...eO(e.alias)?{alias:e.alias}:{}})},S6=e=>{let t=e.aliases.map(e=>1===e.length?`-${e}`:`--${e}`);return{name:e.name,aliases:t,type:e.typeName??k5(e.primitiveType),description:S9(e.description,k4(e.primitiveType)),required:"Boolean"!==e.primitiveType._tag}},S9=(e,t)=>{if(void 0===t||0===t.length)return e;let r=`(choices: ${t.join(", ")})`;return rO(e,{onNone:()=>rk(r),onSome:e=>rk(`${e} ${r}`)})},S7=e=>sG(function*(t){let r={flags:t.flags,arguments:t.arguments},n=yield*_e(r,e.orderedParams);return S2(e.tree,n)}),_e=sG(function*(e,t){let r=[],n=e.arguments;for(let i of t){let[t,s]=yield*i.parse({flags:e.flags,arguments:n});r.push(s),n=t}return r}),_t=(e,t,r)=>{let n=S5(e),i=new Set;for(let e of(r?.contextConfig??n.contextConfig).flags)for(let t of Sb(e))i.add(t.name);for(let r of t)for(let t of S5(r).config.flags)for(let n of Sb(t))if(i.has(n.name))throw new kL({option:n.name,parentCommand:e.name,childCommand:r.name})},_r=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:k4(e.primitiveType)??[]};case"Path":{let t=e.typeName;return{_tag:"Path",pathType:"file"===t?"file":"directory"===t?"directory":"either"}}default:return{_tag:"String"}}},_n=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:k4(e.primitiveType)??[]};case"Path":{let t=e.typeName;return{_tag:"Path",pathType:"file"===t?"file":"directory"===t?"directory":"either"}}default:return{_tag:"String"}}},_i=e=>{let t=S5(e).config,r=[];for(let e of t.flags)for(let t of Sb(e))"flag"===t.kind&&(t.hidden||r.push({name:t.name,aliases:t.aliases,description:rB(t.description),type:_r(t)}));let n=[];for(let e of t.arguments){let t=Sb(e),r=Sw(e);for(let e of t)"argument"===e.kind&&n.push({name:e.name,description:rB(e.description),required:!r.isOptional,variadic:r.isVariadic,type:_n(e)})}let i=[];for(let t of e.subcommands)for(let e of t.commands)e.hidden||i.push(_i(e));return{name:e.name,description:e.shortDescription??e.description,flags:r,arguments:n,subcommands:i}},_s=e=>{let t=new Set,r=[];for(let n of e)t.has(n)||(t.add(n),r.push(n));return r},_a=(e,t)=>{let r=[e],n=e;for(let e=1;e<t.length;e++){let i,s=t[e];for(let e of n.subcommands)if(i=e.commands.find(e=>e.name===s))break;if(!i)break;r.push(i),n=i}return r},_o=(e,t,r)=>_s([...r,..._a(e,t).flatMap(e=>S5(e).globalFlags)]),_l=(e,t,r)=>lD(function*(){let n=_a(e,t),i=S5(n.length>0?n[n.length-1]:e).buildHelpDoc(t),s=((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 S5(t).contextConfig.flags)for(let t of Sb(e))!r.has(t.name)&&(t.hidden||(r.add(t.name),n.push(S6(t))));return n})(n,i.flags),a=_o(e,t,r),o=[];for(let e of a)for(let t of Sb(e.flag))t.hidden||o.push({...S6(t),required:!1});return{...i,flags:[...s,...i.flags],globalFlags:o}}),_c=e=>({_tag:"Action",flag:e.flag,run:e.run}),_u=0,_d=_c({flag:SK("help").pipe(SV("h"),SJ("Show help information")),run:sG(function*(e,{builtIns:t,command:r,commandPath:n}){let i=yield*Sx,s=yield*_l(r,n,t);yield*kN(i.formatHelpDoc(s))})}),_f=_c({flag:SK("version").pipe(SV("v"),SJ("Show version information")),run:sG(function*(e,{command:t,version:r}){let n=yield*Sx;yield*kN(n.formatVersion(t.name,r))})}),_h=_c({flag:SK("wizard").pipe(SJ("Start wizard mode for a command")),run:()=>sK}),_p=_c({flag:Sz("completions",["bash","zsh","fish","sh"]).pipe(SY,SG(e=>rV(e,e=>"sh"===e?"bash":e)),SW("<bash|zsh|fish|sh>"),SJ("Print shell completion script")),run:sG(function*(e,{command:t}){if(r_(e))return;let r=_i(t);yield*kN(((e,t,r)=>{switch(t){case"bash":let n=[],i=SI(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(""),ST(r,[],n),n.push(`complete -F _${i} ${e.replace(/'/g,"'\\''")}`),n.push(`###-end-${e.replace(/'/g,"'\\''")}-completions-###`),n.join("\n");case"zsh":let s,a;return s=[],a=SR(e),s.push(`#compdef ${e}`),s.push(`###-begin-${e}-completions-###`),s.push("#"),s.push("# Static completion script for Zsh"),s.push("#"),s.push("# Installation:"),s.push(`# ${e} --completions zsh > ~/.zsh/completions/_${e}`),s.push("# then add ~/.zsh/completions to your fpath"),s.push("#"),s.push(""),Sq(r,[],s),s.push("# Handle both direct invocation and autoload"),s.push('if [[ "${zsh_eval_context[-1]}" == "loadautofunc" ]]; then'),s.push(` _${a} "$@"`),s.push("else"),s.push(` compdef _${a} ${e}`),s.push("fi"),s.push(`###-end-${e}-completions-###`),s.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(""),SP(e,r,[],o),o.push(""),o.push(`###-end-${e}-completions-###`),o.join("\n")}})(t.name,e.value,r))})}),_m=(q="log-level",e=>(_u+=1,Object.assign(nQ(`effect/unstable/cli/GlobalFlag/${q}/${_u}`),{_tag:"Setting",id:q,flag:e.flag})))({flag:Sr("flag","log-level",[["all","All"],["trace","Trace"],["debug","Debug"],["info","Info"],["warn","Warn"],["warning","Warn"],["error","Error"],["fatal","Fatal"],["none","None"]]).pipe(SY,SJ("Sets the minimum log level"),SW("<all|trace|debug|info|warn|warning|error|fatal|none>"))}),_g=[_d,_f,_h,_p,_m];class _y extends io("effect/unstable/cli/CliConfig",{defaultValue:()=>_b}){}let _b={builtIns:_g},_v=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},_w=(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 s=1;s<=r;s++)for(let r=1;r<=n;r++){let n=+(e[s-1]!==t[r-1]);i[s][r]=Math.min(i[s-1][r]+1,i[s][r-1]+1,i[s-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)},_x=e=>rO(e.subcommand,{onNone:()=>[],onSome:e=>[e.name,..._x(e.parsedInput)]}),_k=(e,t,r=[])=>lD(function*(){let{tokens:n,trailingOperands:i}=e,s=[...r,t.name],a=S5(t),o=a.config.flags.flatMap(Sb).filter(k7),l=__(o),c=a.contextConfig.flags.flatMap(Sb).filter(k7),u=__(c),d=new Set(c.map(e=>e.name)),f=_R(n,{command:t,commandPath:s,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:rx(),...f.errors.length>0&&{errors:f.errors}};let h={tokens:f.childTokens,trailingOperands:[]},p=yield*_k(h,f.sub,s),m=[...f.errors,...p.errors??[]];return{flags:f.flags,arguments:i,subcommand:rk({name:f.sub.name,parsedInput:p}),...m.length>0&&{errors:m}}}),_S=e=>{let t=0;return{peek:()=>e[t],take:()=>e[t++],rest:()=>e.slice(t)}},__=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}},_$=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},_O=e=>Object.fromEntries(e.map(e=>[e.name,[]])),_I=e=>"LongOption"===e._tag||"ShortOption"===e._tag,_C=e=>"LongOption"===e._tag?e.name:e.flag,_E=(e,t)=>{let r=_C(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&&k0(n.primitiveType))return{param:n,negated:!0}}if(n)return{param:n,negated:!1}},_A=(e,t,r)=>new kR({option:t.name,value:r,expected:`omit the value and use ${e.raw} by itself to set --${t.name} to false`,kind:"flag"}),_T=e=>e?._tag==="Value"&&(kZ(e.value)||kX(e.value))?e.value:void 0,_M=(e,t,r,n=!1)=>{let i=_N(e,t,r,n);switch(i._tag){case"Value":return{_tag:"Value",value:i.value};case"Error":return{_tag:"Error",error:i.error}}},_N=(e,t,r,n=!1)=>{let i;if(n){if(void 0!==t.value)return{_tag:"Error",error:_A(t,r,t.value),tokens:[]};let n=_T(e.peek());if(void 0!==n){let i=e.take();return{_tag:"Error",error:_A(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(k0(r.primitiveType)){let t=_T(e.peek()),r=void 0!==t?e.take():void 0;return{_tag:"Value",value:t??"true",tokens:void 0===r?[]:[r]}}let s=e.peek();if(s?._tag==="Value"){let t=e.take();return{_tag:"Value",value:s.value,tokens:void 0===t?[]:[t]}}return{_tag:"Error",error:(i=k4(r.primitiveType),new kR({option:r.name,value:"",expected:void 0===i?r.typeName??k5(r.primitiveType):i.join(" | "),kind:"flag"})),tokens:[]}},_j=(e,t)=>{for(let r of t){let t=_E(e,r);if(void 0!==t)return t}},_F=(e,t,r,n)=>{e.push(r);let i=_N(t,r,n.param,n.negated);e.push(...i.tokens)},_L=(e,t,r,n,i)=>{let s=_S(t);_N(s,e,r.param,r.negated);for(let e=s.take();e;e=s.take()){if(_I(e)){let t=_j(e,i);void 0!==t&&_N(s,e,t.param,t.negated);continue}if("Value"===e._tag)return n.has(e.value)}return!1},_P=(e,t,r,n)=>{let{commandPath:i,flagRegistry:s}=r,a=_E(e,s);if(!a)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),k0(e.primitiveType)&&i.push(`no-${e.name}`),e.aliases))i.push(t);return new kF({option:n,suggestions:_w(_C(e),i).map(e=>1===e.length?`-${e}`:`--${e}`),command:r})})(e,s.params,i));let o=_M(t,e,a.param,a.negated);"Error"===o._tag?n.errors.push(o.error):n.flags.add(a.param.name,o.value)},_D=(e,t,r,n)=>{if("AwaitingFirstValue"===n.mode._tag){let i=((e,t,r,n)=>{let{command:i,commandPath:s,inheritedFlagRegistry:a,localFlagNames:o}=r,l=_$(i.subcommands),c=l.get(e);if(c){let e=[...s,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 kF({option:`--${t}`,suggestions:[],command:e}))}let i=((e,t)=>{let r=_O(t.params),n=[],i=[],s=_S(e);for(let e=s.take();e;e=s.take()){if(!_I(e)){n.push(e);continue}let a=_E(e,t);if(!a){n.push(e);continue}let o=_M(s,e,a.param,a.negated);if("Error"===o._tag){i.push(o.error);continue}void 0!==o.value&&r[a.param.name].push(o.value)}return{flagMap:r,remainder:n,errors:i}})(t.rest(),a);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(!(S5(i).config.arguments.length>0)&&l.size>0){let t=[];for(let[e,r]of l)r.hidden||t.push(e);let r=_w(e,t);n.errors.push(new kU({subcommand:e,parent:s,suggestions:r}))}return{_tag:"Argument"}})(e,t,r,n);if("Subcommand"===i._tag)return i.result;n.mode={_tag:"CollectingArguments"}}n.arguments.push(e)},_R=(e,t)=>{let r,n=_S(e),i={flags:(r=_O(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(_I(e)){_P(e,n,t,i);continue}if("Value"===e._tag){let r=_D(e.value,n,t,i);if(r)return r}}return{_tag:"Leaf",flags:i.flags.snapshot(),arguments:i.arguments,errors:i.errors}},_U=new WeakMap,_B="~effect/data/Redacted",_q=(e,t)=>{let r=Object.create(_K);return t?.label&&(r.label=t.label),_U.set(r,e),r},_K={[_B]:{_A:e=>e},label:void 0,...tw,toJSON(){return this.toString()},toString(){return`<redacted${ev(this.label)?":"+this.label:""}>`},[ej](){return eF(_U.get(this))},[eQ](e){return eT(e,_B)&&eZ(_U.get(this),_U.get(e))}},_z=e=>{if(_U.has(e))return _U.get(e);throw Error("Unable to get redacted value"+(e.label?` with label: "${e.label}"`:""))},_V=el(2,(e,t)=>{let r=Math.pow(10,t);return Math.round(e*r)/r}),_J=(e,...t)=>{let r=t.flat();return`${r.join("")}${e}`},_W={arrowUp:"↑",arrowDown:"↓",arrowLeft:"←",arrowRight:"→",radioOn:"◉",radioOff:"◯",checkboxOn:"☒",checkboxOff:"☐",tick:"✔",cross:"✖",ellipsis:"…",pointerSmall:"›",line:"─",pointer:"❯"},_Y={arrowUp:_W.arrowUp,arrowDown:_W.arrowDown,arrowLeft:_W.arrowLeft,arrowRight:_W.arrowRight,radioOn:"(*)",radioOff:"( )",checkboxOn:"[*]",checkboxOff:"[ ]",tick:"√",cross:"×",ellipsis:"...",pointerSmall:"»",line:"─",pointer:">"},_G=ae(sL(()=>"win32"===process.platform),e=>e?_Y:_W),_H=e=>_J(e,"\x1b[1m"),_Q=e=>_J(e,((...e)=>e)("\x1b[3m","\x1b[31m")),_Z=e=>{let t={initial:!1,...e,label:{confirm:"yes",deny:"no",...e.label},placeholder:{defaultConfirm:"(Y/n)",defaultDeny:"(y/N)",...e.placeholder}};return _X({value:t.initial},{render:$l(t),process:e=>$d(e,t.initial),clear:$i(t)})},_X=(e,...t)=>{let[r,n]=1===t.length?[void 0,t[0]]:[t[0],t[1]],i=Object.create(_6);return i._tag="Loop",i.initialState=e,i.render=n.render,i.process=n.process,i.clear=n.clear,i.events=r,i},_0=el(2,(e,t)=>{let r=Object.create(_6);return r._tag="OnSuccess",r.prompt=e,r.onSuccess=t,r}),_1=e=>{let t={default:0,min:-1/0,max:1/0,incrementBy:1,decrementBy:1,validate:e=>e<t.min?tJ(`${e} must be greater than or equal to ${t.min}`):e>t.max?tJ(`${e} must be less than or equal to ${t.max}`):lP(e),...e},r=void 0===e.default?"":`${t.default}`;return _X({cursor:r.length,value:r,error:rx()},{render:$D(t),process:$R(t),clear:$T(t)})},_2=el(2,(e,t)=>_0(e,e=>_4(t(e)))),_3=sG(function*(e){let t=yield*gR,r=yield*t.readInput;return yield*_9(e,t,r)},a$(()=>new gD({})),lq),_5=e=>{let t={maxPerPage:10,...e};return _X((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:$J(t),process:$Y(t),clear:$W(t)})},_4=e=>{let t=Object.create(_6);return t._tag="Succeed",t.value=e,t},_8=e=>{let t={initial:!1,active:"on",inactive:"off",...e};return _X(t.initial,{render:Oe(t),process:Ot,clear:()=>$3(t)})},_6={...nz({label:"Prompt",evaluate(){return _3(this)}}),"~effect/cli/Prompt":{_Output:e=>e}},_9=(e,t,r)=>sP(()=>{switch(e._tag){case"Loop":return _7(e,t,r);case"OnSuccess":return s8(_9(e.prompt,t,r),n=>_9(e.onSuccess(n),t,r));case"Succeed":return lP(e.value)}}),_7=sG(function*(e,t,r){let n=tk(e.initialState)?yield*e.initialState:e.initialState,i=$e.NextFrame({state:n});for(;;){let s=yield*e.render(n,i);if(yield*lB(t.display(s)),e.events){let t=cv(r).pipe(ae(e=>({_tag:"Input",input:e}))),s=yield*s4(t,cv(e.events).pipe(ae(e=>({_tag:"Event",value:e}))));i=yield*e.process(s,n)}else{let t=yield*cv(r);i=yield*e.process(t,n)}switch(i._tag){case"Beep":continue;case"NextFrame":yield*lB(t.display((yield*e.clear(n,i)))),n=i.state;continue;case"Submit":{yield*lB(t.display((yield*e.clear(n,i))));let r=yield*e.render(n,i);return yield*lB(t.display(r)),i.value}}}},(e,t,r)=>aQ(e,lB(r.display("\x1b[?25h")))),$e=new Proxy({},{get:(e,t,r)=>"$is"===t?eM:"$match"===t?l5:e=>({...e,_tag:t})}),$t=(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($n))n+=1+Math.floor(Math.max(r.length-1,0)/t);var i=n;let s="";for(let e=0;e<i;e++)s+="\x1b[2K"+(e<i-1?"\x1b[1A":"");return i>0&&(s+="\x1b[G"),s},$r=(e,t,r)=>{if(void 0!==r&&r.length>0){let n;return((e=1)=>`\x1b[${e}B`)((n=r.split($n),0===t?n.length:em(nR(n,e=>Math.ceil(e.length/t)),nq(0,(e,t)=>e+t))))+$t(`
50
+ ${r}`,t)+$t(e,t)}return $t(e,t)},$n=/\r?\n/,$i=e=>sG(function*(t,r){let n=yield*gR,i=yield*n.columns,s=yield*_G;return $t($s(t.value?e.placeholder.defaultConfirm:e.placeholder.defaultDeny,"?",s.pointerSmall,e,{plain:!0}),i)+"\x1b[2K\x1b[G"}),$s=(e,t,r,n,i)=>$E(e,n.message,t,r,i),$a=sG(function*(e,t){let r=yield*_G,n=_J("?","\x1b[96m"),i=_J(r.pointerSmall,"\x1b[90m");return"\x1b[?25l"+$s(_J(e.value?t.placeholder.defaultConfirm:t.placeholder.defaultDeny,"\x1b[90m"),n,i,t)}),$o=sG(function*(e,t){let r=yield*_G,n=_J(r.tick,"\x1b[32m"),i=_J(r.ellipsis,"\x1b[90m");return $s(e?t.label.confirm:t.label.deny,n,i,t)+"\n"}),$l=e=>(t,r)=>$e.$match(r,{Beep:()=>lP("\x07"),NextFrame:({state:t})=>$a(t,e),Submit:({value:t})=>$o(t,e)}),$c=/^y|t$/,$u=/^n|f$/,$d=(e,t)=>{let r=rT(e.input,()=>"");return"enter"===e.key.name||"return"===e.key.name?lP($e.Submit({value:t})):$c.test(r.toLowerCase())?lP($e.Submit({value:!0})):$u.test(r.toLowerCase())?lP($e.Submit({value:!1})):lP($e.Beep())},$f=(e,t=!1)=>nq(e.dateParts,"",(r,n,i)=>{let s=n.toString();return i!==e.cursor||t?r+s:r+_J(s,((...e)=>e)("\x1b[4m","\x1b[96m"))}),$h=(e,t,r,n,i)=>$E(r,n.message,e,t,i),$p=sG(function*(e,t){let r=yield*_G;return"\x1b[?25l"+$h(_J("?","\x1b[96m"),_J(r.pointerSmall,"\x1b[90m"),$f(e),t)+((e,t)=>{if(r$(e.error)){let r=e.error.value.split($n);if(nA(r))return"\x1b[s\n"+(_J(t,"\x1b[31m")+" ")+nR(r,e=>_Q(e)).join("\n")+"\x1b[u"}return""})(e,r.pointerSmall)}),$m=sG(function*(e,t){let r=yield*_G;return $h(_J(r.tick,"\x1b[32m"),_J(r.ellipsis,"\x1b[90m"),$f(e,!0),t)+"\n"}),$g={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"]},$y=/\\(.)|"((?:\\["\\]|[^"])+)"|(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,$b={1:({token:e,...t})=>new $w({token:e.replace(/\\(.)/g,"$1"),...t}),2:e=>new $$(e),3:e=>new $O(e),4:e=>new $I(e),5:e=>new $C(e),6:e=>new $_(e),7:e=>new $S(e),8:e=>new $k(e),9:e=>new $x(e)};class $v{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=rT(nM(this.parts,e=>e===this),()=>0);return ny(this.parts.slice(e+1),e=>!e.isToken())}previousPart(){let e=nM(this.parts,e=>e===this);return r$(e)?nN(this.parts.slice(0,e.value),e=>!e.isToken()):rx()}toString(){return String(this.date)}}class $w extends $v{increment(){}decrement(){}setValue(e){this.token=this.token+e}isToken(){return!0}toString(){return this.token}}class $x extends $v{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 $k extends $v{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 $S extends $v{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 $_ extends $v{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 $$ extends $v{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 $O extends $v{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 $I extends $v{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 $C extends $v{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 $E=(e,t,r,n,i)=>{let s=r+" ",a=i?.plain===!0?e=>e:_H;return nI(t.split($n),{onEmpty:()=>s+" "+n+" "+e,onNonEmpty:t=>s+nR(t,e=>a(e)).join("\n")+" "+n+" "+e})},$A=(e,t,r)=>!e.disabled&&e.description&&t?r?.plain===!0?"- "+e.description:_J("- "+e.description,"\x1b[90m"):"",$T=e=>sG(function*(t,r){let n=yield*gR,i=yield*n.columns,s=yield*_G,a=$M(t,s.pointerSmall,{plain:!0});return $r($N(t,"?",s.pointerSmall,e,{plain:!0}),i,a)+"\x1b[2K\x1b[G"}),$M=(e,t,r)=>r$(e.error)?nI(e.error.value.split($n),{onEmpty:()=>"",onNonEmpty:e=>r?.plain===!0?`${t} ${e.join("\n")}`:"\x1b[s\n"+(_J(t,"\x1b[31m")+" ")+nR(e,e=>_Q(e)).join("\n")+"\x1b[u"}):"",$N=(e,t,r,n,i,s=!1)=>{let a;return $E((a=""===e.value?"":`${e.value}`,s||i?.plain===!0?a:_J(a,r$(e.error)?"\x1b[31m":((...e)=>e)("\x1b[4m","\x1b[96m"))),n.message,t,r,i)},$j=sG(function*(e,t){let r=yield*_G,n=_J("?","\x1b[96m"),i=_J(r.pointerSmall,"\x1b[90m"),s=$M(e,r.pointerSmall);return $N(e,n,i,t)+s}),$F=sG(function*(e,t){let r=yield*_G;return $N(e,_J(r.tick,"\x1b[32m"),_J(r.ellipsis,"\x1b[90m"),t,void 0,!0)+"\n"}),$L=e=>{if(e.value.length<=0)return lP($e.Beep());let t=e.value.slice(0,e.value.length-1);return lP($e.NextFrame({state:{...e,value:t,error:rx()}}))},$P=e=>lP($e.NextFrame({state:{...e,cursor:0,value:"",error:rx()}})),$D=e=>(t,r)=>$e.$match(r,{Beep:()=>lP("\x07"),NextFrame:({state:t})=>$j(t,e),Submit:()=>$F(t,e)}),$R=e=>(t,r)=>{if(t.key.ctrl&&"u"===t.key.name)return $P(r);switch(t.key.name){case"backspace":return $L(r);case"k":case"up":return lP($e.NextFrame({state:{...r,value:""===r.value||"-"===r.value?`${e.incrementBy}`:`${Number.parseInt(r.value)+e.incrementBy}`,error:rx()}}));case"j":case"down":return lP($e.NextFrame({state:{...r,value:""===r.value||"-"===r.value?`-${e.decrementBy}`:`${Number.parseInt(r.value)-e.decrementBy}`,error:rx()}}));case"enter":case"return":{let t=Number.parseInt(r.value);if(Number.isNaN(t))return lP($e.NextFrame({state:{...r,error:rk("Must provide an integer value")}}));return aT(e.validate(t),{onFailure:e=>$e.NextFrame({state:{...r,error:rk(e)}}),onSuccess:e=>$e.Submit({value:e})})}default:var n=rT(t.input,()=>"");if(0===r.value.length&&"-"===n)return lP($e.NextFrame({state:{...r,value:"-",error:rx()}}));let i=Number.parseInt(r.value+n);return Number.isNaN(i)?lP($e.Beep()):lP($e.NextFrame({state:{...r,value:`${i}`,error:rx()}}))}},$U=(e,t,r,n)=>$E("",r.message,e,t,n),$B=(e,t,r,n,i,s)=>{let a=" ";if(n===r.startIndex&&r.startIndex>0?a=i.arrowUp:n===r.endIndex-1&&r.endIndex<t.length&&(a=i.arrowDown),s?.plain===!0)return e===n?i.pointer+a:a+" ";if(t[n].disabled){let t=((...e)=>e)("\x1b[1m","\x1b[90m");return e===n?_J(i.pointer,t)+a:a+" "}return e===n?_J(i.pointer,"\x1b[96m")+a:a+" "},$q=(e,t,r)=>{if(r?.plain===!0)return e.title;let n=e.title;return t?e.disabled?_J(n,((...e)=>e)("\x1b[4m","\x1b[90m")):_J(n,((...e)=>e)("\x1b[4m","\x1b[96m")):e.disabled?_J(n,((...e)=>e)("\x1b[9m","\x1b[90m")):n},$K=(e,t,r,n)=>{let i=t.choices,s=Or(e,i.length,t.maxPerPage),a=[];for(let t=s.startIndex;t<s.endIndex;t++){let o=i[t],l=e===t,c=$B(e,i,s,t,r,n),u=$q(o,l,n),d=$A(o,l,n);a.push(c+u+" "+d)}return a.join("\n")},$z=sG(function*(e,t){let r=yield*_G,n=$K(e,t,r);return"\x1b[?25l"+$U(_J("?","\x1b[96m"),_J(r.pointerSmall,"\x1b[90m"),t)+"\n"+n}),$V=sG(function*(e,t){let r=yield*_G,n=t.choices[e].title;return $U(_J(r.tick,"\x1b[32m"),_J(r.ellipsis,"\x1b[90m"),t)+" "+_J(n,"\x1b[37m")+"\n"}),$J=e=>(t,r)=>$e.$match(r,{Beep:()=>lP("\x07"),NextFrame:({state:t})=>$z(t,e),Submit:()=>$V(t,e)}),$W=e=>sG(function*(t,r){let n=yield*gR,i=yield*n.columns,s=yield*_G,a=$U("?",s.pointerSmall,e,{plain:!0}),o=$K(t,e,s,{plain:!0});return $t(`${a}
51
+ ${o}`,i)+"\x1b[2K\x1b[G"}),$Y=e=>(t,r)=>{var n;switch(t.key.name){case"k":case"up":return n=e.choices,0===r?lP($e.NextFrame({state:n.length-1})):lP($e.NextFrame({state:r-1}));case"j":case"down":return r===e.choices.length-1?lP($e.NextFrame({state:0})):lP($e.NextFrame({state:r+1}));case"tab":let i;return i=e.choices,lP($e.NextFrame({state:(r+1)%i.length}));case"enter":case"return":{let t=e.choices[r];if(t.disabled)return lP($e.Beep());return lP($e.Submit({value:t.value}))}default:return lP($e.Beep())}},$G=sG(function*(e,t){let r=yield*gR,n=yield*r.columns,i=yield*_G,s=$H(e,i.pointerSmall,{plain:!0});return $r($Q(e,"?",i.pointerSmall,t,{plain:!0}),n,s)+"\x1b[2K\x1b[G"}),$H=(e,t,r)=>r$(e.error)?nI(e.error.value.split($n),{onEmpty:()=>"",onNonEmpty:e=>r?.plain===!0?`${t} ${e.join("\n")}`:"\x1b[s\n"+(_J(t,"\x1b[31m")+" ")+nR(e,e=>_Q(e)).join("\n")+"\x1b[u"}):"",$Q=(e,t,r,n,i,s=!1)=>$E(((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 s=r$(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 _J("*".repeat(i.length),s);case"text":return _J(i,s)}})(e,n,s,i),n.message,t,r,i),$Z=sG(function*(e,t){let r=yield*_G;return $Q(e,_J("?","\x1b[96m"),_J(r.pointerSmall,"\x1b[90m"),t)+$H(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)}),$X=sG(function*(e,t){let r=yield*_G;return $Q(e,_J(r.tick,"\x1b[32m"),_J(r.ellipsis,"\x1b[90m"),t,void 0,!0)+"\n"}),$0=e=>lP($e.NextFrame({state:{...e,cursor:0,error:rx()}})),$1=e=>lP($e.NextFrame({state:{...e,cursor:e.value.length,error:rx()}})),$2=(e,t)=>{let r={default:"",type:t,validate:lP,...e};return _X({cursor:r.default.length,value:r.default,error:rx()},{render:(e,t)=>$e.$match(t,{Beep:()=>lP("\x07"),NextFrame:({state:e})=>$Z(e,r),Submit:()=>$X(e,r)}),process:(e,t)=>{if(e.key.ctrl)switch(e.key.name){case"u":return lP($e.NextFrame({state:{...t,cursor:0,value:"",error:rx()}}));case"a":return $0(t);case"e":return $1(t);default:return lP($e.Beep())}switch(e.key.name){case"backspace":var n;if(t.cursor<=0)return lP($e.Beep());let i=t.value.slice(0,t.cursor-1),s=t.value.slice(t.cursor),a=t.cursor-1,o=`${i}${s}`;return lP($e.NextFrame({state:{...t,cursor:a,value:o,error:rx()}}));case"left":if(t.cursor<=0)return lP($e.Beep());let l=t.cursor-1;return lP($e.NextFrame({state:{...t,cursor:l,error:rx()}}));case"right":if(t.cursor>=t.value.length)return lP($e.Beep());let c=Math.min(t.cursor+1,t.value.length);return lP($e.NextFrame({state:{...t,cursor:c,error:rx()}}));case"home":return $0(t);case"end":return $1(t);case"enter":case"return":{let e=t.value;return aT(r.validate(e),{onFailure:r=>$e.NextFrame({state:{...t,value:e,error:rk(r)}}),onSuccess:e=>$e.Submit({value:e})})}case"tab":if(t.value===r.default)return lP($e.Beep());let u=0===t.value.length?r.default:t.value;return lP($e.NextFrame({state:{...t,value:u,cursor:u.length,error:rx()}}));default:let d,f,h,p;return n=rT(e.input,()=>""),d=t.value.slice(0,t.cursor),f=t.value.slice(t.cursor),h=`${d}${n}${f}`,p=t.cursor+n.length,lP($e.NextFrame({state:{...t,cursor:p,value:h,error:rx()}}))}},clear:(e,t)=>$G(e,r)})},$3=sG(function*(e){let t=yield*gR,r=yield*t.columns,n=yield*_G;return $t($E(`${e.active} / ${e.inactive}`,e.message,"?",n.pointerSmall,{plain:!0}),r)+"\x1b[2K\x1b[G"}),$5=(e,t,r=!1)=>{let n=_J("/","\x1b[90m"),i=((...e)=>e)("\x1b[4m",r?"\x1b[37m":"\x1b[96m"),s=e?t.inactive:_J(t.inactive,i);return(e?_J(t.active,i):t.active)+" "+n+" "+s},$4=(e,t,r,n)=>{let i=n.message.split($n),s=t+" ";return nA(i)?s+nR(i,e=>_H(e)).join("\n")+" "+r+" "+e:s+" "+r+" "+e},$8=sG(function*(e,t){let r=yield*_G,n=_J("?","\x1b[96m"),i=_J(r.pointerSmall,"\x1b[90m");return"\x1b[?25l"+$4($5(e,t),n,i,t)}),$6=sG(function*(e,t){let r=yield*_G,n=_J(r.tick,"\x1b[32m"),i=_J(r.ellipsis,"\x1b[90m");return $4($5(e,t,!0),n,i,t)+"\n"}),$9=lP($e.NextFrame({state:!0})),$7=lP($e.NextFrame({state:!1})),Oe=e=>(t,r)=>{switch(r._tag){case"Beep":return lP("\x07");case"NextFrame":return $8(t,e);case"Submit":return $6(t,e)}},Ot=(e,t)=>{switch(e.key.name){case"0":case"j":case"delete":case"right":case"down":return $7;case"1":case"k":case"left":case"up":return $9;case" ":case"tab":return t?$7:$9;case"enter":case"return":return lP($e.Submit({value:t}));default:return lP($e.Beep())}},Or=(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 s=Math.min(i+n,t);return{startIndex:i,endIndex:s}},On=sG(function*(e,t){let r=t?.commandPath??[e.name],n=Oi(e,r),i=[...t?.prefix??r];return yield*Of(i),yield*Os(n,i,n===e?"ROOT":n.name),i}),Oi=(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},Os=sG(function*(e,t,r){let n=S5(e),i=e.subcommands.flatMap(e=>e.commands.filter(e=>!e.hidden)),s=0===i.length?n.config:n.contextConfig;if(s.flags.length>0){for(let e of(yield*kN(Oh(r,"FLAGS")),s.flags))t.push(...yield*Oo(e));(s.arguments.length>0||i.length>0)&&(yield*Of(t))}if(s.arguments.length>0){for(let e of(yield*kN(Oh(r,"ARGUMENTS")),s.arguments))t.push(...yield*Oo(e));i.length>0&&(yield*Of(t))}if(0===i.length)return;let a=yield*_3(_5({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*kN(),t.push(a.name),Oa(a)&&(yield*Of(t)),yield*Os(a,t,a.name)}),Oa=e=>e.subcommands.some(e=>e.commands.some(e=>!e.hidden))||S5(e).config.orderedParams.length>0,Oo=sG(function*(e){let t=Sv(e),r=Sw(e);if(r.isOptional&&!(yield*_3(_Z({message:`Set ${Ou(t)}?`,initial:!1}))))return yield*kN(),[];let n=r.isVariadic?yield*_3(_1({message:`${Ou(t)} count`,default:rT(r.variadicMin,()=>0),min:rT(r.variadicMin,()=>0),...r$(r.variadicMax)?{max:r.variadicMax.value}:{}})):1,i=[];for(let e=0;e<n;e++)i.push((yield*Ol(t)));let s="flag"===t.kind?{flags:{[t.name]:i},arguments:[]}:{flags:{},arguments:i};return(yield*e.parse(s),yield*kN(),t.kind===k6)?i:i.flatMap(e=>[`--${t.name}`,e])}),Ol=e=>{var t,r;let n=Oc(e);switch(e.primitiveType._tag){case"Boolean":return ae(_3(_Z({message:n,label:{confirm:"true",deny:"false"},placeholder:{defaultConfirm:"(T/f)",defaultDeny:"(t/F)"}})),String);case"Choice":return _3(_5({message:n,choices:(k4(e.primitiveType)??[]).map(e=>({title:e,value:e}))}));case"Date":let i,s,a,o,l,c;return ae(_3((t={message:n},a=(s=((e,t,r)=>{let n=[],i=null;for(;i=$y.exec(e);){let e=i.shift(),s=i.findIndex(e=>void 0!==e);if(s in $b){let a=i[s]||e;n.push($b[s]({token:a,date:t,parts:n,locales:r}))}else n.push(new $w({token:i[s]||e,date:t,parts:n,locales:r}))}let s=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},nP());return n.splice(0,n.length,...s),n})((i={initial:new Date,dateMask:"YYYY-MM-DD HH:mm:ss",validate:lP,...t,locales:{...$g,...t.locales}}).dateMask,i.initial,i.locales)).findIndex(e=>!e.isToken()),_X({dateParts:s,typed:"",cursor:a,value:i.initial,error:rx()},{render:(o=i,(e,t)=>$e.$match(t,{Beep:()=>lP("\x07"),NextFrame:({state:e})=>$p(e,o),Submit:()=>$m(e,o)})),process:(l=i,(e,t)=>{switch(e.key.name){case"left":let r;return lP(r$(r=t.dateParts[t.cursor].previousPart())?$e.NextFrame({state:{...t,typed:"",cursor:t.dateParts.indexOf(r.value)}}):$e.Beep());case"right":let n;return lP(r$(n=t.dateParts[t.cursor].nextPart())?$e.NextFrame({state:{...t,typed:"",cursor:t.dateParts.indexOf(n.value)}}):$e.Beep());case"k":case"up":return lP((t.dateParts[t.cursor].increment(),$e.NextFrame({state:{...t,typed:""}})));case"j":case"down":return lP((t.dateParts[t.cursor].decrement(),$e.NextFrame({state:{...t,typed:""}})));case"tab":let i;return lP((i=rO(t.dateParts[t.cursor].nextPart(),{onNone:()=>t.dateParts.findIndex(e=>!e.isToken()),onSome:e=>t.dateParts.indexOf(e)}),$e.NextFrame({state:{...t,cursor:i}})));case"enter":case"return":return aT(l.validate(t.value),{onFailure:e=>$e.NextFrame({state:{...t,error:rk(e)}}),onSuccess:e=>$e.Submit({value:e})});default:return lP(((e,t)=>{if(/\d/.test(e)){let r=t.typed+e;return t.dateParts[t.cursor].setValue(r),$e.NextFrame({state:{...t,typed:r}})}return $e.Beep()})(rT(e.input,()=>""),t))}}),clear:(c=i,sG(function*(e,t){let r=yield*gR,n=yield*r.columns,i=yield*_G,s=nq(e.dateParts,"",(e,t)=>e+t.toString());return $r($h("?",i.pointerSmall,s,c,{plain:!0}),n,r$(e.error)?nI(e.error.value.split($n),{onEmpty:()=>"",onNonEmpty:e=>`${i.pointerSmall} ${e.join("\n")}`}):"")+"\x1b[2K\x1b[G"}))}))),e=>e.toISOString());case"Float":let u,d,f,h;return ae(_3((u={default:0,min:-1/0,max:1/0,incrementBy:1,decrementBy:1,precision:2,validate:e=>e<u.min?tJ(`${e} must be greater than or equal to ${u.min}`):e>u.max?tJ(`${e} must be less than or equal to ${u.max}`):lP(e),...r={message:n}},_X({cursor:(d=void 0===r.default?"":`${u.default}`).length,value:d,error:rx()},{render:(f=u,(e,t)=>$e.$match(t,{Beep:()=>lP("\x07"),NextFrame:({state:e})=>$j(e,f),Submit:()=>$F(e,f)})),process:(h=u,(e,t)=>{if(e.key.ctrl&&"u"===e.key.name)return $P(t);switch(e.key.name){case"backspace":return $L(t);case"k":case"up":return lP($e.NextFrame({state:{...t,value:""===t.value||"-"===t.value?`${h.incrementBy}`:`${Number.parseFloat(t.value)+h.incrementBy}`,error:rx()}}));case"j":case"down":return lP($e.NextFrame({state:{...t,value:""===t.value||"-"===t.value?`-${h.decrementBy}`:`${Number.parseFloat(t.value)-h.decrementBy}`,error:rx()}}));case"enter":case"return":{let e=Number.parseFloat(t.value);if(Number.isNaN(e))return lP($e.NextFrame({state:{...t,error:rk("Must provide a floating point value")}}));return s8(sL(()=>_V(e,h.precision)),e=>aT(h.validate(e),{onFailure:e=>$e.NextFrame({state:{...t,error:rk(e)}}),onSuccess:e=>$e.Submit({value:e})}))}default:var r=rT(e.input,()=>"");if("."===r&&t.value.includes("."))return lP($e.Beep());if(0===t.value.length&&"-"===r)return lP($e.NextFrame({state:{...t,value:"-",error:rx()}}));let n=Number.parseFloat(t.value+r);return Number.isNaN(n)?lP($e.Beep()):lP($e.NextFrame({state:{...t,value:"."===r?`${n}.`:`${n}`,error:rx()}}))}}),clear:$T(u)}))),String);case"Integer":return ae(_3(_1({message:n})),String);case"Redacted":return ae(_3($2({message:n},"password").pipe(_2(_q))),_z);default:return _3($2({message:n},"text"))}},Oc=e=>Ou(e),Ou=e=>{let t=ei.getOrUndefined(e.description)?.trim(),r="flag"===e.kind&&void 0!==t&&t.length<=32?t:Od(e.name);return"flag"===e.kind?`${r} (${"flag"===e.kind?`--${e.name}`:e.name})`:r},Od=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(" ")},Of=e=>kN(Oy("Current command",e,"\x1b[35m")),Oh=(e,t)=>`${_J(e.toUpperCase(),"\x1b[1m","\x1b[96m")} ${_J("·","\x1b[90m")} ${_J(t,"\x1b[1m","\x1b[37m")}`,Op=(e,t,r)=>[`${_J(e,"\x1b[1m","\x1b[96m")} ${_J(`v${t}`,"\x1b[37m")} ${_J("· Command wizard","\x1b[1m","\x1b[37m")}`,...void 0===r||0===r.length?[]:[r],_J("Build a command interactively. Press Ctrl+C to cancel.","\x1b[90m"),""].join("\n"),Om=e=>Oy("Command ready",e,"\x1b[96m","\x1b[32m"),Og=()=>`
52
+ ${_J("Wizard cancelled.","\x1b[31m")}`,Oy=(e,t,r,n="\x1b[37m")=>{let i=Ob(t);return[_J(e,"\x1b[1m",n),...i.map(e=>_J(e,r)),""].join("\n")},Ob=e=>{let t=" $ ",r=" ",n=e.map(Ov),i=[],s=t;for(let e of n){let n=s===t||s===r?"":" ";s.length+n.length+e.length>88&&s!==t?(i.push(`${s} \\`),s=`${r}${e}`):s+=`${n}${e}`}return s!==t&&i.push(s),i},Ov=e=>/^[A-Za-z0-9_./:@%+=,-]+$/.test(e)?e:`'${e.replaceAll("'","'\"'\"'")}'`,Ow=e=>eT(e,S3),Ox=(e,t,r)=>S8({name:e,config:SQ(t??{}),...eO(r)?{handle:r}:{}}),Ok=el(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(Ow(t)){n(void 0,t);continue}for(let e of t.commands)n(t.group,e)}let i=[],s=r.get(void 0);for(let[e,t]of(s&&s.length>0&&i.push({group:void 0,commands:s}),r))void 0!==e&&i.push({group:e,commands:t});return{flat:t,groups:i}})(t);_t(e,r.flat);let n=S5(e),i=new Map(r.flat.map(e=>[e.name,S5(e)])),s=Symbol("effect/cli/SubcommandState"),a=sG(function*(e){if(r_(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),a=yield*t.parse(e.subcommand.value.parsedInput);return Object.assign({},r,{[s]:{name:t.name,result:a}})}),o=sG(function*(e,t){let r=e[s];if(r){let s=i.get(r.name);return s?yield*s.handle(r.result,[...t,s.name]).pipe(af(n.service,e)):yield*new kK({commandPath:t,errors:[]})}return yield*n.handle(e,t)});return S8({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:a,parseContext:n.parseContext,handle:o})}),OS=el(2,(e,t)=>{let r=S5(e),n=SQ(t),i=S1(r.config,n),s=S1(r.contextConfig,n);r.subcommands.length>0&&_t(e,r.subcommands.flatMap(e=>e.commands),{contextConfig:s});let a=S7(n),o=sG(function*(e){return Object.assign({},(yield*r.parse(e)),(yield*a(e)))}),l=sG(function*(e){return Object.assign({},(yield*r.parseContext(e)),(yield*a(e)))});return S8({name:r.name,config:i,contextConfig:s,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)})}),O_=el(2,(e,t)=>S8({...S5(e),description:t})),O$=el(2,(e,t)=>S8({...S5(e),shortDescription:t})),OO=el(2,(e,t)=>S8({...S5(e),examples:t})),OI=(e,t)=>{let r=S5(e);return sG(function*(n){let i,s,a,o,l,c,{builtIns:u}=yield*_y,{tokens:d,trailingOperands:f}=-1===(i=n.indexOf("--"))?{tokens:_v(n),trailingOperands:[]}:{tokens:_v(n.slice(0,i)),trailingOperands:n.slice(i+1)},h=_s([...u,...(s=[],(a=e=>{for(let t of S5(e).globalFlags)s.push(t);for(let t of e.subcommands)for(let e of t.commands)a(e)})(e),_s(s))]),p=__(h.flatMap(e=>Sb(e.flag)).filter(k7)),{flagMap:m,remainder:g,errors:y}=(o=_O(p.params),l=[],c=(e,t,r)=>{let n=__(S5(t).config.flags.flatMap(Sb).filter(k7)),i=__(S5(t).contextConfig.flags.flatMap(Sb).filter(k7)),s=_$(t.subcommands),a=_S(e),u=[],d=!0;for(let e=a.take();e;e=a.take()){if(_I(e)){let t=_j(e,r);if(void 0!==t){_F(u,a,e,t);continue}let c=_E(e,i);if(void 0!==c){_F(u,a,e,c);continue}let f=_E(e,n),h=_E(e,p);if(void 0!==f&&(void 0===h||!d||!_L(e,a.rest(),f,s,[n,i,p]))){_F(u,a,e,f);continue}if(void 0!==h){let t=_N(a,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=s.get(e.value);if(void 0!==t)return u.push(e),u.push(...c(a.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*_k({tokens:g,trailingOperands:f},e),w=[e.name,..._x(v)],x={builtIns:u,command:e,commandPath:w,version:t.version},k=_o(e,w,u),S=((e,t,r,n)=>{let i=new Set(t),s=[],a=new Set;for(let t of e)if(!i.has(t))for(let e of Sb(t.flag)){let t=r[e.name];if(!t||0===t.length)continue;let i=`--${e.name}`;a.has(i)||(a.add(i),s.push(new kF({option:i,suggestions:[],command:n})))}return s})(h,k,m,w);if(S.length>0||y.length>0){let e=v.errors??[];return yield*new kK({commandPath:w,errors:[...y,...S,...e]})}for(let r of k){if("Action"!==r._tag||!Sb(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===_h)return yield*lD(function*(){yield*kN(Op(e.name,t.version,e.description));let r=[e.name,...n.filter(e=>"--wizard"!==e&&!e.startsWith("--wizard="))],i=yield*On(e,{commandPath:w,prefix:r});yield*kN(Om(i)),(yield*_3(_8({message:"Run this command?",initial:!0,active:"yes",inactive:"no"})))&&(yield*kN(),yield*OI(e,t)(i.slice(1)))}).pipe(aS("QuitError",()=>kN(Og())));yield*r.run(i,x);return}if(v.errors&&v.errors.length>0)return yield*new kK({commandPath:w,errors:v.errors});let _=yield*aI(r.parse(v));if("Failure"===_._tag)return yield*new kK({commandPath:w,errors:[_.failure]});let $=r.handle(_.success,[e.name]),O=k.includes(_m)?(yield*_m.flag.parse(b))[1]:rx();for(let e of($=af($,_m,O),k)){if("Setting"!==e._tag||e===_m)continue;let[,t]=yield*e.flag.parse(b);$=af($,e,t)}let I=rO(O,{onNone:()=>n5,onSome:e=>n4(sr,e)});yield*ad($,I)},ak(e=>eT(e,kj)&&"ShowHelp"===e._tag?rp(e):rh(e),t=>s2(lD(function*(){let{builtIns:r}=yield*_y,n=yield*Sx,i=yield*_l(e,t.commandPath,r);yield*kN(n.formatHelpDoc(i)),t.errors.length>0&&(yield*((...e)=>kM(t=>sL(()=>{t.error(...e)})))(n.formatErrors(t.errors)))}),tJ(t))),ak(e=>eT(e,gP)?rp(e):rh(e),e=>a0))},OC=new Set(["create","show","edit","list","export"]);function OE(e){return{_tag:"File",path:e}}function OA(e){return{_tag:"InlineJson",value:e}}function OT(){let e=St("flag","file").pipe(SW("PATH|-"),SJ("Read one canonical document from PATH, or stdin with -."),SG(OE)),t=St("flag","json").pipe(SW("VALUE"),SJ("Read one canonical document from inline JSON."),SG(OA));return{source:Object.assign(Object.create(Object.getPrototypeOf(e)),e,{parse:r=>{let n=r.flags.file?.length??0,i=r.flags.json?.length??0;return 1===n&&0===i?e.parse(r):0===n&&1===i?t.parse(r):tJ(new kR({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:SY(t)}}class OM extends nQ()("@sketchi/cli/InputReader"){}function ON(e,t){return sz({try:()=>new TextDecoder("utf-8",{fatal:!0}).decode(e),catch:()=>xE.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 Oj=function(e=()=>!0===process.stdin.isTTY){return lx(OM,lD(function*(){let t=yield*x7,r=yield*dD;return{read:lJ("sketchi.cli.input.read")(function*(n){if("InlineJson"===n._tag)return n.value;if("-"!==n.path){let e=yield*t.readBytes(n.path).pipe(a$(()=>xE.make({code:"input_read_failed",message:`Unable to read input file ${n.path}.`,hint:"Check the path and file permissions, then retry."})));return yield*ON(e,"file")}if(e())return yield*xE.make({code:"interactive_stdin",message:"--file - requires piped or redirected stdin.",hint:"Pipe one JSON document, or use --file PATH / --json VALUE."});let i=yield*ua(r.stdin).pipe(a$(()=>xE.make({code:"input_read_failed",message:"Unable to read JSON from stdin.",hint:"Pipe one complete UTF-8 JSON document and retry."})));return yield*ON(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}(i),"stdin")})}}))}(),OF=lJ("sketchi.cli.input.readDocument")(function*(e){let t=yield*OM,r=yield*t.read(e);return yield*xq(r)});class OL extends nQ()("@sketchi/cli/OutputWriter"){}class OP extends gE()("CliCommandExit",{exitCode:m5}){}function OD(e){return xC.make({cause:e,operation:"write-output",path:"standard stream",message:"Unable to write command output."})}let OR=lx(OL,lD(function*(){let e=yield*dD;return{stdout:t=>((...e)=>c7(e))(t).pipe(us(e.stdout()),a$(OD)),stderr:t=>((...e)=>c7(e))(t).pipe(us(e.stderr()),a$(OD))}}));function OU(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 OB=lJ("sketchi.cli.output.failure")(function*(e,t,r){let n=yield*OL,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":return{code:e.code,message:e.message,hint:e.hint,details:e.details}}}(r),s="json"===t?xK({ok:!1,command:e,error:i}):OU(i);return yield*n.stderr(s),yield*OP.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)return 5;if("diagram_already_exists"===e.code||"diagram_busy"===e.code)return 6;return 7;case"CliFilesystemError":return 7;case"CliExportError":return 8}}(r)})}),Oq=lJ("sketchi.cli.output.success")(function*(e,t,r,n,i="stdout"){let s=yield*OL,a="json"===t?xK({ok:!0,command:e,data:r}):n;yield*s[i](a.endsWith("\n")?a:`${a}
53
+ `)});function OK(e,t,r,n,i=e=>e){return r.pipe(aA({onFailure:r=>OB(e,t,r),onSuccess:r=>Oq(e,t,i(r),n(r))}))}let Oz=`Local Sketchi authoring for canonical flowcharts and mindmaps, with one prompt-assisted path.
54
+
55
+ Manual JSON workflow (strictly offline):
56
+ create a canonical document, inspect or replace it, list local records, and export stored artifacts.
57
+ Accepted input is exactly one complete JSON object shaped like an example below.
58
+
59
+ Canonical flowchart example:
60
+ {"type":"flowchart","spec":{"id":"release-flow","title":"Release approval","nodes":[{"id":"start","label":"Change proposed","kind":"start"},{"id":"review","label":"Review evidence","kind":"process"},{"id":"end","label":"Release approved","kind":"end"}],"edges":[{"source":"start","target":"review"},{"source":"review","target":"end"}]}}
61
+
62
+ Canonical mindmap example:
63
+ {"type":"mindmap","spec":{"id":"launch-map","title":"Launch plan","root":{"label":"Launch","children":[{"label":"Product"},{"label":"Operations"}]}}}
64
+
65
+ Prompt-assisted workflow (sole network boundary):
66
+ sketchi generate --prompt TEXT [--type flowchart|mindmap] [--model MODEL]
67
+ Only generate uses the network. It makes one unauthenticated HTTPS POST to the public
68
+ Sketchi generate API at ${k$}
69
+ and needs no token, key, account, or login. The model call, validation, and quality gate
70
+ run server-side; the finished diagram and Excalidraw artifact come back and are committed
71
+ through the same local store as create. The default type is flowchart and default model is
72
+ ${k_}. Override the endpoint for preview or local testing with
73
+ ${kO} or --endpoint URL.
74
+
75
+ Input and output contracts:
76
+ create/edit require exactly one of --file PATH|- or --json VALUE. --file - reads one
77
+ noninteractive UTF-8 JSON document from stdin and exits with usage code 2 on a TTY.
78
+ --json is inline input only. --prompt is noninteractive text. Use --output text|json for
79
+ result presentation on every command.
80
+ export writes bytes with --dest PATH|-. With --dest -, bytes use stdout and status uses stderr.
81
+
82
+ Offline boundary and storage:
83
+ create, show, edit, list, and export use no model, remote agent, MCP server, login,
84
+ account, browser, credential, or network. No command sends stored records to a provider.
85
+ Records live at ~/.sketchi/diagrams/<id>/ with manifest.json, document.json, scene.json,
86
+ diagram.excalidraw, optional diagram.png, and revisions/<revision>.json.
87
+ Formats are scene, excalidraw, and png. PNG export only returns an already-stored PNG.
88
+
89
+ Exit codes and errors:
90
+ 0 success; 1 internal failure; 2 usage or interactive stdin; 3 invalid input/document;
91
+ 4 build/export construction failure; 5 diagram not found; 6 conflict/busy;
92
+ 7 filesystem/storage failure; 8 unavailable format or export write failure;
93
+ 10 generate network/endpoint failure; 11 generate timeout; 12 malformed generate output.
94
+ Text errors start with "error: CODE". JSON errors use {"ok":false,"command":...,"error":...}.
95
+ Errors never include stacks.
96
+
97
+ Revision recovery and next steps:
98
+ edit validates and builds before an atomic commit, then saves the prior document under revisions/.
99
+ To recover, inspect the prior revision JSON and pass that complete document back to edit.
100
+ Start with create for accepted JSON or generate for a prompt. Use the returned id with show/list,
101
+ edit with a complete replacement document, then export a stored scene or Excalidraw artifact.`,OV=Sz("output",["text","json"]).pipe(Su("text"),SJ("Result presentation format."),SW("text|json")),OJ=Ox("sketchi").pipe(OS({output:OV}),O_(Oz),O$("Local Sketchi authoring with one credential-free prompt-assisted command."));function OW(e){return`~/.sketchi/diagrams/${e}`}function OY(e){return e.revisions.map(t=>`${OW(e.manifest.id)}/revisions/${t}`)}function OG(e){return{...x8(e),storagePath:OW(e.manifest.id),revisions:OY(e),document:e.document}}function OH(e,t){return`${e}: ${t.manifest.id}
102
+ type: ${t.manifest.type}
103
+ title: ${t.manifest.title}
104
+ revision: ${String(t.manifest.revision)}
105
+ formats: ${t.manifest.formats.join(",")}
106
+ storage: ${OW(t.manifest.id)}`}function OQ(e){return{...OG(e.diagram),generation:{model:e.model,provider:e.provider}}}function OZ(e){return[OH("created",e.diagram).replace(/^created:/u,"generated:"),`provider: ${e.provider}`,`model: ${e.model}`].join("\n")}function OX(e){let t=OY(e);return[`id: ${e.manifest.id}`,`type: ${e.manifest.type}`,`title: ${e.manifest.title}`,`revision: ${String(e.manifest.revision)}`,`formats: ${e.manifest.formats.join(",")}`,`revisions: ${0===t.length?"none":t.join(",")}`,"document:",xK(e.document).trimEnd()].join("\n")}function O0(e){return 0===e.length?"no diagrams":["id type revision formats title",...e.map(e=>[e.id,e.type,String(e.revision),e.formats.join(","),e.title].join(" "))].join("\n")}let O1=`Create one persisted diagram from --prompt TEXT. This is Sketchi's only command that uses the network. It makes one unauthenticated HTTPS POST to the public Sketchi generate API and needs no token, key, account, or login.
107
+
108
+ Network and options:
109
+ Endpoint: ${k$}
110
+ The model call, schema validation, and quality gate run server-side; the finished diagram
111
+ and Excalidraw artifact are returned over plain HTTPS. Sketchi sends no credentials.
112
+ --type defaults to flowchart; --model defaults to ${k_}.
113
+ Override the endpoint for preview or local testing with ${kO}
114
+ or --endpoint URL. --output text|json controls only the local result envelope.
115
+
116
+ Validation and storage:
117
+ The returned diagram is decoded against Sketchi's canonical package schemas and atomically
118
+ committed through the create store at ~/.sketchi/diagrams/<id>/. The record contains
119
+ manifest.json, document.json, scene.json, and diagram.excalidraw.
120
+ Any network/endpoint/timeout/output/validation/storage failure leaves no visible record.
121
+
122
+ Errors and next steps:
123
+ Exit 10 means a network or endpoint failure, 11 a timeout, and 12 malformed output;
124
+ a rejected or invalid generated document uses 3, conflict uses 6, and storage uses 7.
125
+ On success, pass the returned id to show, edit, list, or export. For strictly offline manual
126
+ authoring and accepted canonical JSON examples, run sketchi --help.`,O2=Ox("generate",{prompt:St("flag","prompt").pipe(SJ("Diagram request text sent to the public Sketchi generate API."),SW("TEXT")),type:Sz("type",["flowchart","mindmap"]).pipe(Su("flowchart"),SJ("Requested canonical diagram type; default flowchart."),SW("flowchart|mindmap")),model:St("flag","model").pipe(Su(k_),SJ(`Server-routed generation model id; default ${k_}.`),SW("MODEL")),endpoint:St("flag","endpoint").pipe(Su(process.env[kO]?.trim()||k$),SJ("Unauthenticated generate API URL; defaults to the production Sketchi endpoint."),SW("URL"))},e=>lD(function*(){let{output:t}=yield*OJ;yield*OK("generate",t,kT(e),OZ,OQ)})).pipe(O_(O1),O$("Generate and persist one diagram through the public unauthenticated Sketchi generate API."),OO([{command:'sketchi generate --prompt "Map release approval with pass and revise branches"',description:`Generate a flowchart with ${k_}.`},{command:'sketchi generate --prompt "Organize launch readiness" --type mindmap --model gemini-3.1-flash-lite --output json',description:"Generate and persist a mindmap with structured output."}])),O3=Ox("create",OT(),({source:e})=>lD(function*(){let{output:t}=yield*OJ,r=yield*xJ,n=yield*ki,i=lD(function*(){let t=yield*OF(e),i=yield*r.build(t);return yield*n.create(i)});yield*OK("create",t,i,e=>OH("created",e),OG)})).pipe(O_("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."),OO([{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."}])),O5=Ox("show",{diagramId:St(k6,"diagram-id")},({diagramId:e})=>lD(function*(){let{output:t}=yield*OJ,r=yield*ki,n=xV(e).pipe(s8(e=>r.show(e)));yield*OK("show",t,n,OX,OG)})).pipe(O_("Show the current canonical document, manifest summary, formats, and recoverable revision paths for DIAGRAM_ID. This does not rebuild or mutate the record."),OO([{command:"sketchi show release-flow --output json",description:"Read a record as a stable JSON envelope."}])),O4=Ox("edit",{diagramId:St(k6,"diagram-id"),...OT()},({diagramId:e,source:t})=>lD(function*(){let{output:r}=yield*OJ,n=yield*xJ,i=yield*ki,s=lD(function*(){let r=yield*xV(e),s=yield*OF(t),a=yield*n.build(s);return a.id!==r?yield*xA.make({message:`Edited document id "${a.id}" does not match "${r}".`,hint:"Keep spec.id equal to the diagram id being edited.",details:["spec.id"]}):yield*i.edit(r,a)});yield*OK("edit",r,s,e=>OH("edited",e),OG)})).pipe(O_("Replace the complete canonical document for DIAGRAM_ID. Sketchi validates and builds first, preserves the prior document under revisions/, and atomically swaps the record. The new spec.id must match DIAGRAM_ID."),OO([{command:"sketchi edit release-flow --file revised.json",description:"Replace a document and retain the prior revision."}])),O8=Ox("list",{},()=>lD(function*(){let{output:e}=yield*OJ,t=yield*ki;yield*OK("list",e,t.list(),O0)})).pipe(O_("List local diagrams in ascending id order with type, revision, stored formats, and title. The command is deterministic and read-only."),OO([{command:"sketchi list --output json",description:"List records as a stable JSON envelope."}])),O6=Ox("export",{diagramId:St(k6,"diagram-id"),format:Sz("format",["scene","excalidraw","png"]).pipe(SJ("Stored artifact format to export."),SW("scene|excalidraw|png")),destination:St("flag","dest").pipe(SJ("Artifact byte destination path, or - for stdout."),SW("PATH|-"))},({destination:e,diagramId:t,format:r})=>lD(function*(){let{output:n}=yield*OJ,i=yield*ki,s=lD(function*(){let n=yield*xV(t),s=yield*i.readArtifact(n,r);return"-"!==e&&(yield*kS(e,s)),{id:n,format:r,destination:e,sizeBytes:s.byteLength,..."-"===e?{stdoutBytes:s}:{}}});yield*s.pipe(aA({onFailure:e=>OB("export",n,e),onSuccess:e=>lD(function*(){let t=yield*OL;e.stdoutBytes&&(yield*t.stdout(e.stdoutBytes));let r={id:e.id,format:e.format,destination:e.destination,sizeBytes:e.sizeBytes},i=`exported: ${e.id}
127
+ format: ${e.format}
128
+ destination: ${e.destination}
129
+ bytes: ${String(e.sizeBytes)}`;yield*Oq("export",n,r,i,e.stdoutBytes?"stderr":"stdout")})}))})).pipe(O_("Export one already-stored scene, Excalidraw, or PNG artifact. --dest - writes only artifact bytes to stdout and writes the text/JSON success envelope to stderr. PNG never starts a browser or network request; unavailable PNG exits 8."),OO([{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."}])),O9=OJ.pipe(Ok([O2,O3,O5,O4,O8,O6])),O7=lJ("sketchi.cli.run")(function*(e){let t,r,n,i,s,a,o,l,c=(t=e.lastIndexOf("--output"))>=0&&"json"===e[t+1]||e.some(e=>"--output=json"===e)?"json":"text";return yield*(r=Sk({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=(s=e.find(e=>OC.has(e)))??"sketchi",o={...r,formatHelpDoc:e=>i&&!n?"":r.formatHelpDoc(e).replace(/[ \t]+$/gmu,""),formatErrors:e=>{let t=e.map(e=>r.formatCliError(e)).join("; "),n=`Run sketchi${s?` ${s}`:""} --help for usage.`;return i?`${JSON.stringify({ok:!1,command:a,error:{code:"usage_error",message:t,hint:n}},null,2)}
130
+ `:`error: usage_error
131
+ ${t}
132
+ next: ${n}
133
+ `}},l=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}}),OI(O9,{version:"0.0.1"})(e).pipe(af(_y,{builtIns:[_d,_f]}),af(Sx,o),af(oL,l))).pipe(aC({onFailure:e=>lD(function*(){let t,r=rB(su(e));if(r instanceof OP)return r.exitCode;if(r instanceof xC)return 7;let n=function(e){if(eT(e,kj))return"ShowHelp"===e._tag?2*(e.errors.length>0):2}(r);if(void 0!==n)return n;let i=yield*OL;return yield*i.stderr((t={code:"internal_error",message:"Sketchi could not complete the command.",hint:"Retry once; if it persists, report the command and inputs without secrets."},"json"===c?xK({ok:!1,command:"sketchi",error:t}):OU(t))).pipe(ab(()=>sK)),1}),onSuccess:()=>lP(0)}))}),Ie=lI(xQ,l$(bG,function(e={}){return lv(wK,{createId:e.createId??wQ,...e.renderer?{renderer:e.renderer}:{},...e.artifactUrl?{artifactUrl:e.artifactUrl}:{}})}({createId:e=>`${e}_offline_cli`}))),It=lI(kk,l$(kr,kp)),Ir=lC(l$(kr,kp,Ie,It,Oj.pipe(lI(kr)),OR),gK);l1(O7(process.argv.slice(2)).pipe(s3(e=>sL(()=>{process.exitCode=e})),lE(Ir)),{disableErrorReporting:!0})})();