@coryrylan/cradle 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,21 +1,21 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
- var S8=Object.create;var{getPrototypeOf:P8,defineProperty:cF,getOwnPropertyNames:x8}=Object;var b8=Object.prototype.hasOwnProperty;function h8(D){return this[D]}var w8,m8,v8=(D,u,F)=>{var C=D!=null&&typeof D==="object";if(C){var E=u?w8??=new WeakMap:m8??=new WeakMap,B=E.get(D);if(B)return B}F=D!=null?S8(P8(D)):{};let $=u||!D||!D.__esModule?cF(F,"default",{value:D,enumerable:!0}):F;for(let Z of x8(D))if(!b8.call($,Z))cF($,Z,{get:h8.bind(D,Z),enumerable:!0});if(C)E.set(D,$);return $};var c8=(D,u)=>()=>(u||D((u={exports:{}}).exports,u),u.exports);var N0=c8((m9,_0)=>{_0.exports=function(u){if(u===void 0)u=2;if(u>=Error.stackTraceLimit)throw TypeError("getCallerFile(position) requires position be less then Error.stackTraceLimit but position was: `"+u+"` and Error.stackTraceLimit was: `"+Error.stackTraceLimit+"`");var F=Error.prepareStackTrace;Error.prepareStackTrace=function(E,B){return B};var C=Error().stack;if(Error.prepareStackTrace=F,C!==null&&typeof C==="object")return C[u]?C[u].getFileName():void 0}});import{join as f8}from"path";import{notStrictEqual as j3,strictEqual as _3}from"assert";var d8={right:y8,center:g8};class kF{constructor(D){var u;this.width=D.width,this.wrap=(u=D.wrap)!==null&&u!==void 0?u:!0,this.rows=[]}span(...D){let u=this.div(...D);u.span=!0}resetOutput(){this.rows=[]}div(...D){if(D.length===0)this.div("");if(this.wrap&&this.shouldApplyLayoutDSL(...D)&&typeof D[0]==="string")return this.applyLayoutDSL(D[0]);let u=D.map((F)=>{if(typeof F==="string")return this.colFromString(F);return F});return this.rows.push(u),u}shouldApplyLayoutDSL(...D){return D.length===1&&typeof D[0]==="string"&&/[\t\n]/.test(D[0])}applyLayoutDSL(D){let u=D.split(`
4
- `).map((C)=>C.split("\t")),F=0;return u.forEach((C)=>{if(C.length>1&&YD.stringWidth(C[0])>F)F=Math.min(Math.floor(this.width*0.5),YD.stringWidth(C[0]))}),u.forEach((C)=>{this.div(...C.map((E,B)=>{return{text:E.trim(),padding:this.measurePadding(E),width:B===0&&C.length>1?F:void 0}}))}),this.rows[this.rows.length-1]}colFromString(D){return{text:D,padding:this.measurePadding(D)}}measurePadding(D){let u=YD.stripAnsi(D);return[0,u.match(/\s*$/)[0].length,0,u.match(/^\s*/)[0].length]}toString(){let D=[];return this.rows.forEach((u)=>{this.rowToString(u,D)}),D.filter((u)=>!u.hidden).map((u)=>u.text).join(`
5
- `)}rowToString(D,u){return this.rasterize(D).forEach((F,C)=>{let E="";F.forEach((B,$)=>{let{width:Z}=D[$],M=this.negatePadding(D[$]),H=B;if(M>YD.stringWidth(B))H+=" ".repeat(M-YD.stringWidth(B));if(D[$].align&&D[$].align!=="left"&&this.wrap){let Y=d8[D[$].align];if(H=Y(H,M),YD.stringWidth(H)<M)H+=" ".repeat((Z||0)-YD.stringWidth(H)-1)}let V=D[$].padding||[0,0,0,0];if(V[3])E+=" ".repeat(V[3]);if(E+=dF(D[$],H,"| "),E+=H,E+=dF(D[$],H," |"),V[1])E+=" ".repeat(V[1]);if(C===0&&u.length>0)E=this.renderInline(E,u[u.length-1])}),u.push({text:E.replace(/ +$/,""),span:D.span})}),u}renderInline(D,u){let F=D.match(/^ */),C=F?F[0].length:0,E=u.text,B=YD.stringWidth(E.trimRight());if(!u.span)return D;if(!this.wrap)return u.hidden=!0,E+D;if(C<B)return D;return u.hidden=!0,E.trimRight()+" ".repeat(C-B)+D.trimLeft()}rasterize(D){let u=[],F=this.columnWidths(D),C;return D.forEach((E,B)=>{if(E.width=F[B],this.wrap)C=YD.wrap(E.text,this.negatePadding(E),{hard:!0}).split(`
6
- `);else C=E.text.split(`
7
- `);if(E.border)C.unshift("."+"-".repeat(this.negatePadding(E)+2)+"."),C.push("'"+"-".repeat(this.negatePadding(E)+2)+"'");if(E.padding)C.unshift(...Array(E.padding[0]||0).fill("")),C.push(...Array(E.padding[2]||0).fill(""));C.forEach(($,Z)=>{if(!u[Z])u.push([]);let M=u[Z];for(let H=0;H<B;H++)if(M[H]===void 0)M.push("");M.push($)})}),u}negatePadding(D){let u=D.width||0;if(D.padding)u-=(D.padding[3]||0)+(D.padding[1]||0);if(D.border)u-=4;return u}columnWidths(D){if(!this.wrap)return D.map((B)=>{return B.width||YD.stringWidth(B.text)});let u=D.length,F=this.width,C=D.map((B)=>{if(B.width)return u--,F-=B.width,B.width;return}),E=u?Math.floor(F/u):0;return C.map((B,$)=>{if(B===void 0)return Math.max(E,k8(D[$]));return B})}}function dF(D,u,F){if(D.border){if(/[.']-+[.']/.test(u))return"";if(u.trim().length!==0)return F;return" "}return""}function k8(D){let u=D.padding||[],F=1+(u[3]||0)+(u[1]||0);if(D.border)return F+4;return F}function p8(){if(typeof process==="object"&&process.stdout&&process.stdout.columns)return process.stdout.columns;return 80}function y8(D,u){D=D.trim();let F=YD.stringWidth(D);if(F<u)return" ".repeat(u-F)+D;return D}function g8(D,u){D=D.trim();let F=YD.stringWidth(D);if(F>=u)return D;return" ".repeat(u-F>>1)+D}var YD;function pF(D,u){return YD=u,new kF({width:(D===null||D===void 0?void 0:D.width)||p8(),wrap:D===null||D===void 0?void 0:D.wrap})}function eu({onlyFirst:D=!1}={}){return new RegExp("(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]",D?void 0:"g")}var t8=eu();function kD(D){if(typeof D!=="string")throw TypeError(`Expected a \`string\`, got \`${typeof D}\``);if(!D.includes("\x1B")&&!D.includes("\x9B"))return D;return D.replace(t8,"")}var yF=161,gF=1114109,tF=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],lF=12288,iF=65510,oF=[12288,12288,65281,65376,65504,65510];var nF=4352,sF=262141,DF=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141];var Nu=(D,u)=>{let F=0,C=Math.floor(D.length/2)-1;while(F<=C){let E=Math.floor((F+C)/2),B=E*2;if(u<D[B])C=E-1;else if(u>D[B+1])F=E+1;else return!0}return!1};var rF=19968,[l8,i8]=o8(DF);function o8(D){let u=D[0],F=D[1];for(let C=0;C<D.length;C+=2){let E=D[C],B=D[C+1];if(rF>=E&&rF<=B)return[E,B];if(B-E>F-u)u=E,F=B}return[u,F]}var aF=(D)=>{if(D<yF||D>gF)return!1;return Nu(tF,D)},eF=(D)=>{if(D<lF||D>iF)return!1;return Nu(oF,D)};var D0=(D)=>{if(D>=l8&&D<=i8)return!0;if(D<nF||D>sF)return!1;return Nu(DF,D)};function n8(D){if(!Number.isSafeInteger(D))throw TypeError(`Expected a code point, got \`${typeof D}\`.`)}function u0(D,{ambiguousAsWide:u=!1}={}){if(n8(D),eF(D)||D0(D)||u&&aF(D))return 2;return 1}var F0=()=>{return/[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E-\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED8\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])))?))?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3C-\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE8A\uDE8E-\uDEC2\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF]|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g};var s8=new Intl.Segmenter,r8=/^\p{Default_Ignorable_Code_Point}$/u;function LD(D,u={}){if(typeof D!=="string"||D.length===0)return 0;let{ambiguousIsNarrow:F=!0,countAnsiEscapeCodes:C=!1}=u;if(!C)D=kD(D);if(D.length===0)return 0;let E=0,B={ambiguousAsWide:!F};for(let{segment:$}of s8.segment(D)){let Z=$.codePointAt(0);if(Z<=31||Z>=127&&Z<=159)continue;if(Z>=8203&&Z<=8207||Z===65279)continue;if(Z>=768&&Z<=879||Z>=6832&&Z<=6911||Z>=7616&&Z<=7679||Z>=8400&&Z<=8447||Z>=65056&&Z<=65071)continue;if(Z>=55296&&Z<=57343)continue;if(Z>=65024&&Z<=65039)continue;if(r8.test($))continue;if(F0().test($)){E+=2;continue}E+=u0(Z,B)}return E}var C0=(D=0)=>(u)=>`\x1B[${u+D}m`,E0=(D=0)=>(u)=>`\x1B[${38+D};5;${u}m`,B0=(D=0)=>(u,F,C)=>`\x1B[${38+D};2;${u};${F};${C}m`,o={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},e7=Object.keys(o.modifier),a8=Object.keys(o.color),e8=Object.keys(o.bgColor),D9=[...a8,...e8];function D3(){let D=new Map;for(let[u,F]of Object.entries(o)){for(let[C,E]of Object.entries(F))o[C]={open:`\x1B[${E[0]}m`,close:`\x1B[${E[1]}m`},F[C]=o[C],D.set(E[0],E[1]);Object.defineProperty(o,u,{value:F,enumerable:!1})}return Object.defineProperty(o,"codes",{value:D,enumerable:!1}),o.color.close="\x1B[39m",o.bgColor.close="\x1B[49m",o.color.ansi=C0(),o.color.ansi256=E0(),o.color.ansi16m=B0(),o.bgColor.ansi=C0(10),o.bgColor.ansi256=E0(10),o.bgColor.ansi16m=B0(10),Object.defineProperties(o,{rgbToAnsi256:{value(u,F,C){if(u===F&&F===C){if(u<8)return 16;if(u>248)return 231;return Math.round((u-8)/247*24)+232}return 16+36*Math.round(u/255*5)+6*Math.round(F/255*5)+Math.round(C/255*5)},enumerable:!1},hexToRgb:{value(u){let F=/[a-f\d]{6}|[a-f\d]{3}/i.exec(u.toString(16));if(!F)return[0,0,0];let[C]=F;if(C.length===3)C=[...C].map((B)=>B+B).join("");let E=Number.parseInt(C,16);return[E>>16&255,E>>8&255,E&255]},enumerable:!1},hexToAnsi256:{value:(u)=>o.rgbToAnsi256(...o.hexToRgb(u)),enumerable:!1},ansi256ToAnsi:{value(u){if(u<8)return 30+u;if(u<16)return 90+(u-8);let F,C,E;if(u>=232)F=((u-232)*10+8)/255,C=F,E=F;else{u-=16;let Z=u%36;F=Math.floor(u/36)/5,C=Math.floor(Z/6)/5,E=Z%6/5}let B=Math.max(F,C,E)*2;if(B===0)return 30;let $=30+(Math.round(E)<<2|Math.round(C)<<1|Math.round(F));if(B===2)$+=60;return $},enumerable:!1},rgbToAnsi:{value:(u,F,C)=>o.ansi256ToAnsi(o.rgbToAnsi256(u,F,C)),enumerable:!1},hexToAnsi:{value:(u)=>o.ansi256ToAnsi(o.hexToAnsi256(u)),enumerable:!1}}),o}var u3=D3(),$0=u3;var fu=new Set(["\x1B","\x9B"]),F3=39,FF="\x07",Q0="[",C3="]",X0="m",Ru=`${C3}8;;`,z0=(D)=>`${fu.values().next().value}${Q0}${D}${X0}`,Z0=(D)=>`${fu.values().next().value}${Ru}${D}${FF}`,E3=(D)=>D.split(" ").map((u)=>LD(u)),uF=(D,u,F)=>{let C=[...u],E=!1,B=!1,$=LD(kD(D.at(-1)));for(let[Z,M]of C.entries()){let H=LD(M);if($+H<=F)D[D.length-1]+=M;else D.push(M),$=0;if(fu.has(M))E=!0,B=C.slice(Z+1,Z+1+Ru.length).join("")===Ru;if(E){if(B){if(M===FF)E=!1,B=!1}else if(M===X0)E=!1;continue}if($+=H,$===F&&Z<C.length-1)D.push(""),$=0}if(!$&&D.at(-1).length>0&&D.length>1)D[D.length-2]+=D.pop()},B3=(D)=>{let u=D.split(" "),F=u.length;while(F>0){if(LD(u[F-1])>0)break;F--}if(F===u.length)return D;return u.slice(0,F).join(" ")+u.slice(F).join("")},$3=(D,u,F={})=>{if(F.trim!==!1&&D.trim()==="")return"";let C="",E,B,$=E3(D),Z=[""];for(let[Y,q]of D.split(" ").entries()){if(F.trim!==!1)Z[Z.length-1]=Z.at(-1).trimStart();let O=LD(Z.at(-1));if(Y!==0){if(O>=u&&(F.wordWrap===!1||F.trim===!1))Z.push(""),O=0;if(O>0||F.trim===!1)Z[Z.length-1]+=" ",O++}if(F.hard&&$[Y]>u){let W=u-O,J=1+Math.floor(($[Y]-W-1)/u);if(Math.floor(($[Y]-1)/u)<J)Z.push("");uF(Z,q,u);continue}if(O+$[Y]>u&&O>0&&$[Y]>0){if(F.wordWrap===!1&&O<u){uF(Z,q,u);continue}Z.push("")}if(O+$[Y]>u&&F.wordWrap===!1){uF(Z,q,u);continue}Z[Z.length-1]+=q}if(F.trim!==!1)Z=Z.map((Y)=>B3(Y));let M=Z.join(`
8
- `),H=[...M],V=0;for(let[Y,q]of H.entries()){if(C+=q,fu.has(q)){let{groups:W}=new RegExp(`(?:\\${Q0}(?<code>\\d+)m|\\${Ru}(?<uri>.*)${FF})`).exec(M.slice(V))||{groups:{}};if(W.code!==void 0){let J=Number.parseFloat(W.code);E=J===F3?void 0:J}else if(W.uri!==void 0)B=W.uri.length===0?void 0:W.uri}let O=$0.codes.get(Number(E));if(H[Y+1]===`
9
- `){if(B)C+=Z0("");if(E&&O)C+=z0(O)}else if(q===`
10
- `){if(E&&O)C+=z0(E);if(B)C+=Z0(B)}V+=q.length}return C};function CF(D,u,F){return String(D).normalize().replaceAll(`\r
3
+ var _o=Object.create;var{getPrototypeOf:Bo,defineProperty:ur,getOwnPropertyNames:Oo}=Object;var $o=Object.prototype.hasOwnProperty;function vo(e){return this[e]}var jo,ko,Mo=(e,n,t)=>{var r=e!=null&&typeof e==="object";if(r){var i=n?jo??=new WeakMap:ko??=new WeakMap,s=i.get(e);if(s)return s}t=e!=null?_o(Bo(e)):{};let o=n||!e||!e.__esModule?ur(t,"default",{value:e,enumerable:!0}):t;if(e&&typeof e==="object"||typeof e==="function"){for(let u of Oo(e))if(!$o.call(o,u))ur(o,u,{get:vo.bind(e,u),enumerable:!0})}if(r)i.set(e,o);return o};var No=(e,n)=>()=>(n||e((n={exports:{}}).exports,n),n.exports);var Qr=No(function(Ph,Zr){Zr.exports=function(n){if(n===void 0)n=2;if(n>=Error.stackTraceLimit)throw TypeError("getCallerFile(position) requires position be less then Error.stackTraceLimit but position was: `"+n+"` and Error.stackTraceLimit was: `"+Error.stackTraceLimit+"`");var t=Error.prepareStackTrace;Error.prepareStackTrace=function(i,s){return s};var r=Error().stack;if(Error.prepareStackTrace=t,r!==null&&typeof r==="object")return r[n]?r[n].getFileName():void 0}});import{join as So}from"path";import{notStrictEqual as ka,strictEqual as Ma}from"assert";var Ro={right:Lo,center:Wo};class cr{constructor(e){var n;this.width=e.width,this.wrap=(n=e.wrap)!==null&&n!==void 0?n:!0,this.rows=[]}span(...e){let n=this.div(...e);n.span=!0}resetOutput(){this.rows=[]}div(...e){if(e.length===0)this.div("");if(this.wrap&&this.shouldApplyLayoutDSL(...e)&&typeof e[0]==="string")return this.applyLayoutDSL(e[0]);let n=e.map((t)=>{if(typeof t==="string")return this.colFromString(t);return t});return this.rows.push(n),n}shouldApplyLayoutDSL(...e){return e.length===1&&typeof e[0]==="string"&&/[\t\n]/.test(e[0])}applyLayoutDSL(e){let n=e.split(`
4
+ `).map((r)=>r.split("\t")),t=0;return n.forEach((r)=>{if(r.length>1&&ge.stringWidth(r[0])>t)t=Math.min(Math.floor(this.width*0.5),ge.stringWidth(r[0]))}),n.forEach((r)=>{this.div(...r.map((i,s)=>({text:i.trim(),padding:this.measurePadding(i),width:s===0&&r.length>1?t:void 0})))}),this.rows[this.rows.length-1]}colFromString(e){return{text:e,padding:this.measurePadding(e)}}measurePadding(e){let n=ge.stripAnsi(e);return[0,n.match(/\s*$/)[0].length,0,n.match(/^\s*/)[0].length]}toString(){let e=[];return this.rows.forEach((n)=>{this.rowToString(n,e)}),e.filter((n)=>!n.hidden).map((n)=>n.text).join(`
5
+ `)}rowToString(e,n){return this.rasterize(e).forEach((t,r)=>{let i="";t.forEach((s,o)=>{let{width:u}=e[o],c=this.negatePadding(e[o]),p=s;if(c>ge.stringWidth(s))p+=" ".repeat(c-ge.stringWidth(s));if(e[o].align&&e[o].align!=="left"&&this.wrap){let g=Ro[e[o].align];if(p=g(p,c),ge.stringWidth(p)<c)p+=" ".repeat((u||0)-ge.stringWidth(p)-1)}let b=e[o].padding||[0,0,0,0];if(b[3])i+=" ".repeat(b[3]);if(i+=lr(e[o],p,"| "),i+=p,i+=lr(e[o],p," |"),b[1])i+=" ".repeat(b[1]);if(r===0&&n.length>0)i=this.renderInline(i,n[n.length-1])}),n.push({text:i.replace(/ +$/,""),span:e.span})}),n}renderInline(e,n){let t=e.match(/^ */),r=t?t[0].length:0,i=n.text,s=ge.stringWidth(i.trimRight());if(!n.span)return e;if(!this.wrap)return n.hidden=!0,i+e;if(r<s)return e;return n.hidden=!0,i.trimRight()+" ".repeat(r-s)+e.trimLeft()}rasterize(e){let n=[],t=this.columnWidths(e),r;return e.forEach((i,s)=>{if(i.width=t[s],this.wrap)r=ge.wrap(i.text,this.negatePadding(i),{hard:!0}).split(`
6
+ `);else r=i.text.split(`
7
+ `);if(i.border)r.unshift("."+"-".repeat(this.negatePadding(i)+2)+"."),r.push("'"+"-".repeat(this.negatePadding(i)+2)+"'");if(i.padding)r.unshift(...Array(i.padding[0]||0).fill("")),r.push(...Array(i.padding[2]||0).fill(""));r.forEach((o,u)=>{if(!n[u])n.push([]);let c=n[u];for(let p=0;p<s;p++)if(c[p]===void 0)c.push("");c.push(o)})}),n}negatePadding(e){let n=e.width||0;if(e.padding)n-=(e.padding[3]||0)+(e.padding[1]||0);if(e.border)n-=4;return n}columnWidths(e){if(!this.wrap)return e.map((s)=>s.width||ge.stringWidth(s.text));let n=e.length,t=this.width,r=e.map((s)=>{if(s.width)return n--,t-=s.width,s.width;return}),i=n?Math.floor(t/n):0;return r.map((s,o)=>{if(s===void 0)return Math.max(i,Io(e[o]));return s})}}function lr(e,n,t){if(e.border){if(/[.']-+[.']/.test(n))return"";if(n.trim().length!==0)return t;return" "}return""}function Io(e){let n=e.padding||[],t=1+(n[3]||0)+(n[1]||0);if(e.border)return t+4;return t}function To(){if(typeof process==="object"&&process.stdout&&process.stdout.columns)return process.stdout.columns;return 80}function Lo(e,n){e=e.trim();let t=ge.stringWidth(e);if(t<n)return" ".repeat(n-t)+e;return e}function Wo(e,n){e=e.trim();let t=ge.stringWidth(e);if(t>=n)return e;return" ".repeat(n-t>>1)+e}var ge;function dr(e,n){return ge=n,new cr({width:(e===null||e===void 0?void 0:e.width)||To(),wrap:e===null||e===void 0?void 0:e.wrap})}function pt({onlyFirst:e=!1}={}){return new RegExp("(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]",e?void 0:"g")}var Ho=pt();function je(e){if(typeof e!=="string")throw TypeError(`Expected a \`string\`, got \`${typeof e}\``);if(!e.includes("\x1B")&&!e.includes("\x9B"))return e;return e.replace(Ho,"")}var fr=161,hr=1114109,Dr=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],gr=12288,pr=65510,mr=[12288,12288,65281,65376,65504,65510];var Fr=4352,yr=262141,mt=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141];var Nn=(e,n)=>{let t=0,r=Math.floor(e.length/2)-1;while(t<=r){let i=Math.floor((t+r)/2),s=i*2;if(n<e[s])r=i-1;else if(n>e[s+1])t=i+1;else return!0}return!1};var br=19968,[Vo,zo]=Go(mt);function Go(e){let n=e[0],t=e[1];for(let r=0;r<e.length;r+=2){let i=e[r],s=e[r+1];if(br>=i&&br<=s)return[i,s];if(s-i>t-n)n=i,t=s}return[n,t]}var Er=(e)=>{if(e<fr||e>hr)return!1;return Nn(Dr,e)},Cr=(e)=>{if(e<gr||e>pr)return!1;return Nn(mr,e)};var wr=(e)=>{if(e>=Vo&&e<=zo)return!0;if(e<Fr||e>yr)return!1;return Nn(mt,e)};function Uo(e){if(!Number.isSafeInteger(e))throw TypeError(`Expected a code point, got \`${typeof e}\`.`)}function Ye(e,{ambiguousAsWide:n=!1}={}){if(Uo(e),Cr(e)||wr(e)||n&&Er(e))return 2;return 1}var xr=()=>/[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E-\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED8\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])))?))?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3C-\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE8A\uDE8E-\uDEC2\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF]|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g;var Yo=new Intl.Segmenter,Jo=/^\p{Default_Ignorable_Code_Point}$/u;function ke(e,n={}){if(typeof e!=="string"||e.length===0)return 0;let{ambiguousIsNarrow:t=!0,countAnsiEscapeCodes:r=!1}=n;if(!r)e=je(e);if(e.length===0)return 0;let i=0,s={ambiguousAsWide:!t};for(let{segment:o}of Yo.segment(e)){let u=o.codePointAt(0);if(u<=31||u>=127&&u<=159)continue;if(u>=8203&&u<=8207||u===65279)continue;if(u>=768&&u<=879||u>=6832&&u<=6911||u>=7616&&u<=7679||u>=8400&&u<=8447||u>=65056&&u<=65071)continue;if(u>=55296&&u<=57343)continue;if(u>=65024&&u<=65039)continue;if(Jo.test(o))continue;if(xr().test(o)){i+=2;continue}i+=Ye(u,s)}return i}var Sr=(e=0)=>(n)=>`\x1B[${n+e}m`,Ar=(e=0)=>(n)=>`\x1B[${38+e};5;${n}m`,Pr=(e=0)=>(n,t,r)=>`\x1B[${38+e};2;${n};${t};${r}m`,K={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},Lf=Object.keys(K.modifier),Ko=Object.keys(K.color),qo=Object.keys(K.bgColor),Wf=[...Ko,...qo];function Xo(){let e=new Map;for(let[n,t]of Object.entries(K)){for(let[r,i]of Object.entries(t))K[r]={open:`\x1B[${i[0]}m`,close:`\x1B[${i[1]}m`},t[r]=K[r],e.set(i[0],i[1]);Object.defineProperty(K,n,{value:t,enumerable:!1})}return Object.defineProperty(K,"codes",{value:e,enumerable:!1}),K.color.close="\x1B[39m",K.bgColor.close="\x1B[49m",K.color.ansi=Sr(),K.color.ansi256=Ar(),K.color.ansi16m=Pr(),K.bgColor.ansi=Sr(10),K.bgColor.ansi256=Ar(10),K.bgColor.ansi16m=Pr(10),Object.defineProperties(K,{rgbToAnsi256:{value(n,t,r){if(n===t&&t===r){if(n<8)return 16;if(n>248)return 231;return Math.round((n-8)/247*24)+232}return 16+36*Math.round(n/255*5)+6*Math.round(t/255*5)+Math.round(r/255*5)},enumerable:!1},hexToRgb:{value(n){let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(n.toString(16));if(!t)return[0,0,0];let[r]=t;if(r.length===3)r=[...r].map((s)=>s+s).join("");let i=Number.parseInt(r,16);return[i>>16&255,i>>8&255,i&255]},enumerable:!1},hexToAnsi256:{value:(n)=>K.rgbToAnsi256(...K.hexToRgb(n)),enumerable:!1},ansi256ToAnsi:{value(n){if(n<8)return 30+n;if(n<16)return 90+(n-8);let t,r,i;if(n>=232)t=((n-232)*10+8)/255,r=t,i=t;else{n-=16;let u=n%36;t=Math.floor(n/36)/5,r=Math.floor(u/6)/5,i=u%6/5}let s=Math.max(t,r,i)*2;if(s===0)return 30;let o=30+(Math.round(i)<<2|Math.round(r)<<1|Math.round(t));if(s===2)o+=60;return o},enumerable:!1},rgbToAnsi:{value:(n,t,r)=>K.ansi256ToAnsi(K.rgbToAnsi256(n,t,r)),enumerable:!1},hexToAnsi:{value:(n)=>K.ansi256ToAnsi(K.hexToAnsi256(n)),enumerable:!1}}),K}var Zo=Xo(),_r=Zo;var In=new Set(["\x1B","\x9B"]),Qo=39,yt="\x07",$r="[",ea="]",vr="m",Rn=`${ea}8;;`,Br=(e)=>`${In.values().next().value}${$r}${e}${vr}`,Or=(e)=>`${In.values().next().value}${Rn}${e}${yt}`,na=(e)=>e.split(" ").map((n)=>ke(n)),Ft=(e,n,t)=>{let r=[...n],i=!1,s=!1,o=ke(je(e.at(-1)));for(let[u,c]of r.entries()){let p=ke(c);if(o+p<=t)e[e.length-1]+=c;else e.push(c),o=0;if(In.has(c))i=!0,s=r.slice(u+1,u+1+Rn.length).join("")===Rn;if(i){if(s){if(c===yt)i=!1,s=!1}else if(c===vr)i=!1;continue}if(o+=p,o===t&&u<r.length-1)e.push(""),o=0}if(!o&&e.at(-1).length>0&&e.length>1)e[e.length-2]+=e.pop()},ta=(e)=>{let n=e.split(" "),t=n.length;while(t>0){if(ke(n[t-1])>0)break;t--}if(t===n.length)return e;return n.slice(0,t).join(" ")+n.slice(t).join("")},ra=(e,n,t={})=>{if(t.trim!==!1&&e.trim()==="")return"";let r="",i,s,o=na(e),u=[""];for(let[g,D]of e.split(" ").entries()){if(t.trim!==!1)u[u.length-1]=u.at(-1).trimStart();let F=ke(u.at(-1));if(g!==0){if(F>=n&&(t.wordWrap===!1||t.trim===!1))u.push(""),F=0;if(F>0||t.trim===!1)u[u.length-1]+=" ",F++}if(t.hard&&o[g]>n){let y=n-F,h=1+Math.floor((o[g]-y-1)/n);if(Math.floor((o[g]-1)/n)<h)u.push("");Ft(u,D,n);continue}if(F+o[g]>n&&F>0&&o[g]>0){if(t.wordWrap===!1&&F<n){Ft(u,D,n);continue}u.push("")}if(F+o[g]>n&&t.wordWrap===!1){Ft(u,D,n);continue}u[u.length-1]+=D}if(t.trim!==!1)u=u.map((g)=>ta(g));let c=u.join(`
8
+ `),p=[...c],b=0;for(let[g,D]of p.entries()){if(r+=D,In.has(D)){let{groups:y}=new RegExp(`(?:\\${$r}(?<code>\\d+)m|\\${Rn}(?<uri>.*)${yt})`).exec(c.slice(b))||{groups:{}};if(y.code!==void 0){let h=Number.parseFloat(y.code);i=h===Qo?void 0:h}else if(y.uri!==void 0)s=y.uri.length===0?void 0:y.uri}let F=_r.codes.get(Number(i));if(p[g+1]===`
9
+ `){if(s)r+=Or("");if(i&&F)r+=Br(F)}else if(D===`
10
+ `){if(i&&F)r+=Br(i);if(s)r+=Or(s)}b+=D.length}return r};function bt(e,n,t){return String(e).normalize().replaceAll(`\r
11
11
  `,`
12
12
  `).split(`
13
- `).map((C)=>$3(C,u,F)).join(`
14
- `)}function EF(D){return pF(D,{stringWidth:LD,stripAnsi:kD,wrap:CF})}import{dirname as M0,resolve as G0}from"path";import{readdirSync as z3,statSync as Z3}from"fs";function BF(D,u){let F=G0(".",D),C;if(!Z3(F).isDirectory())F=M0(F);while(!0){if(C=u(F,z3(F)),C)return G0(F,C);if(F=M0(C=F),C===F)break}}import{inspect as N3}from"util";import{fileURLToPath as f0}from"url";import{format as M3}from"util";import{normalize as G3,resolve as J3}from"path";function pD(D){if(!(D!==D.toLowerCase()&&D!==D.toUpperCase()))D=D.toLowerCase();if(D.indexOf("-")===-1&&D.indexOf("_")===-1)return D;else{let F="",C=!1,E=D.match(/^-+/);for(let B=E?E[0].length:0;B<D.length;B++){let $=D.charAt(B);if(C)C=!1,$=$.toUpperCase();if(B!==0&&($==="-"||$==="_"))C=!0;else if($!=="-"&&$!=="_")F+=$}return F}}function Au(D,u){let F=D.toLowerCase();u=u||"-";let C="";for(let E=0;E<D.length;E++){let B=F.charAt(E),$=D.charAt(E);if(B!==$&&E>0)C+=`${u}${F.charAt(E)}`;else C+=$}return C}function Su(D){if(D===null||D===void 0)return!1;if(typeof D==="number")return!0;if(/^0x[0-9a-f]+$/i.test(D))return!0;if(/^0[^.]/.test(D))return!1;return/^[-]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(D)}function J0(D){if(Array.isArray(D))return D.map(($)=>typeof $!=="string"?$+"":$);D=D.trim();let u=0,F=null,C=null,E=null,B=[];for(let $=0;$<D.length;$++){if(F=C,C=D.charAt($),C===" "&&!E){if(F!==" ")u++;continue}if(C===E)E=null;else if((C==="'"||C==='"')&&!E)E=C;if(!B[u])B[u]="";B[u]+=C}return B}var UD;(function(D){D.BOOLEAN="boolean",D.STRING="string",D.NUMBER="number",D.ARRAY="array"})(UD||(UD={}));var AD;class zF{constructor(D){AD=D}parse(D,u){let F=Object.assign({alias:void 0,array:void 0,boolean:void 0,config:void 0,configObjects:void 0,configuration:void 0,coerce:void 0,count:void 0,default:void 0,envPrefix:void 0,narg:void 0,normalize:void 0,string:void 0,number:void 0,__:void 0,key:void 0},u),C=J0(D),E=typeof D==="string",B=Q3(Object.assign(Object.create(null),F.alias)),$=Object.assign({"boolean-negation":!0,"camel-case-expansion":!0,"combine-arrays":!1,"dot-notation":!0,"duplicate-arguments-array":!0,"flatten-duplicate-arrays":!0,"greedy-arrays":!0,"halt-at-non-option":!1,"nargs-eats-options":!1,"negation-prefix":"no-","parse-numbers":!0,"parse-positional-numbers":!0,"populate--":!1,"set-placeholder-key":!1,"short-option-groups":!0,"strip-aliased":!1,"strip-dashed":!1,"unknown-options-as-args":!1},F.configuration),Z=Object.assign(Object.create(null),F.default),M=F.configObjects||[],H=F.envPrefix,V=$["populate--"],Y=V?"--":"_",q=Object.create(null),O=Object.create(null),W=F.__||AD.format,J={aliases:Object.create(null),arrays:Object.create(null),bools:Object.create(null),strings:Object.create(null),numbers:Object.create(null),counts:Object.create(null),normalize:Object.create(null),configs:Object.create(null),nargs:Object.create(null),coercions:Object.create(null),keys:[]},S=/^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/,d=new RegExp("^--"+$["negation-prefix"]+"(.+)");if([].concat(F.array||[]).filter(Boolean).forEach(function(Q){let G=typeof Q==="object"?Q.key:Q,T=Object.keys(Q).map(function(U){return{boolean:"bools",string:"strings",number:"numbers"}[U]}).filter(Boolean).pop();if(T)J[T][G]=!0;J.arrays[G]=!0,J.keys.push(G)}),[].concat(F.boolean||[]).filter(Boolean).forEach(function(Q){J.bools[Q]=!0,J.keys.push(Q)}),[].concat(F.string||[]).filter(Boolean).forEach(function(Q){J.strings[Q]=!0,J.keys.push(Q)}),[].concat(F.number||[]).filter(Boolean).forEach(function(Q){J.numbers[Q]=!0,J.keys.push(Q)}),[].concat(F.count||[]).filter(Boolean).forEach(function(Q){J.counts[Q]=!0,J.keys.push(Q)}),[].concat(F.normalize||[]).filter(Boolean).forEach(function(Q){J.normalize[Q]=!0,J.keys.push(Q)}),typeof F.narg==="object")Object.entries(F.narg).forEach(([Q,G])=>{if(typeof G==="number")J.nargs[Q]=G,J.keys.push(Q)});if(typeof F.coerce==="object")Object.entries(F.coerce).forEach(([Q,G])=>{if(typeof G==="function")J.coercions[Q]=G,J.keys.push(Q)});if(typeof F.config<"u"){if(Array.isArray(F.config)||typeof F.config==="string")[].concat(F.config).filter(Boolean).forEach(function(Q){J.configs[Q]=!0});else if(typeof F.config==="object")Object.entries(F.config).forEach(([Q,G])=>{if(typeof G==="boolean"||typeof G==="function")J.configs[Q]=G})}Yu(F.key,B,F.default,J.arrays),Object.keys(Z).forEach(function(Q){(J.aliases[Q]||[]).forEach(function(G){Z[G]=Z[Q]})});let v=null;au();let QD=[],m=Object.assign(Object.create(null),{_:[]}),l={};for(let Q=0;Q<C.length;Q++){let G=C[Q],T=G.replace(/^-{3,}/,"---"),U,X,_,I,A,BD;if(G!=="--"&&/^-/.test(G)&&g(G))uD(G);else if(T.match(/^---+(=|$)/)){uD(G);continue}else if(G.match(/^--.+=/)||!$["short-option-groups"]&&G.match(/^-.+=/)){if(I=G.match(/^--?([^=]+)=([\s\S]*)$/),I!==null&&Array.isArray(I)&&I.length>=3)if(P(I[1],J.arrays))Q=jD(Q,I[1],C,I[2]);else if(P(I[1],J.nargs)!==!1)Q=s(Q,I[1],C,I[2]);else y(I[1],I[2],!0)}else if(G.match(d)&&$["boolean-negation"]){if(I=G.match(d),I!==null&&Array.isArray(I)&&I.length>=2)X=I[1],y(X,P(X,J.arrays)?[!1]:!1)}else if(G.match(/^--.+/)||!$["short-option-groups"]&&G.match(/^-[^-]+/)){if(I=G.match(/^--?(.+)/),I!==null&&Array.isArray(I)&&I.length>=2)if(X=I[1],P(X,J.arrays))Q=jD(Q,X,C);else if(P(X,J.nargs)!==!1)Q=s(Q,X,C);else if(A=C[Q+1],A!==void 0&&(!A.match(/^-/)||A.match(S))&&!P(X,J.bools)&&!P(X,J.counts))y(X,A),Q++;else if(/^(true|false)$/.test(A))y(X,A),Q++;else y(X,c(X))}else if(G.match(/^-.\..+=/)){if(I=G.match(/^-([^=]+)=([\s\S]*)$/),I!==null&&Array.isArray(I)&&I.length>=3)y(I[1],I[2])}else if(G.match(/^-.\..+/)&&!G.match(S)){if(A=C[Q+1],I=G.match(/^-(.\..+)/),I!==null&&Array.isArray(I)&&I.length>=2)if(X=I[1],A!==void 0&&!A.match(/^-/)&&!P(X,J.bools)&&!P(X,J.counts))y(X,A),Q++;else y(X,c(X))}else if(G.match(/^-[^-]+/)&&!G.match(S)){_=G.slice(1,-1).split(""),U=!1;for(let MD=0;MD<_.length;MD++){if(A=G.slice(MD+2),_[MD+1]&&_[MD+1]==="="){if(BD=G.slice(MD+3),X=_[MD],P(X,J.arrays))Q=jD(Q,X,C,BD);else if(P(X,J.nargs)!==!1)Q=s(Q,X,C,BD);else y(X,BD);U=!0;break}if(A==="-"){y(_[MD],A);continue}if(/[A-Za-z]/.test(_[MD])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(A)&&P(A,J.bools)===!1){y(_[MD],A),U=!0;break}if(_[MD+1]&&_[MD+1].match(/\W/)){y(_[MD],A),U=!0;break}else y(_[MD],c(_[MD]))}if(X=G.slice(-1)[0],!U&&X!=="-")if(P(X,J.arrays))Q=jD(Q,X,C);else if(P(X,J.nargs)!==!1)Q=s(Q,X,C);else if(A=C[Q+1],A!==void 0&&(!/^(-|--)[^-]/.test(A)||A.match(S))&&!P(X,J.bools)&&!P(X,J.counts))y(X,A),Q++;else if(/^(true|false)$/.test(A))y(X,A),Q++;else y(X,c(X))}else if(G.match(/^-[0-9]$/)&&G.match(S)&&P(G.slice(1),J.bools))X=G.slice(1),y(X,c(X));else if(G==="--"){QD=C.slice(Q+1);break}else if($["halt-at-non-option"]){QD=C.slice(Q);break}else uD(G)}if(DD(m,!0),DD(m,!1),R(m),p(),PD(m,J.aliases,Z,!0),k(m),$["set-placeholder-key"])FD(m);if(Object.keys(J.counts).forEach(function(Q){if(!t(m,Q.split(".")))y(Q,0)}),V&&QD.length)m[Y]=[];if(QD.forEach(function(Q){m[Y].push(Q)}),$["camel-case-expansion"]&&$["strip-dashed"])Object.keys(m).filter((Q)=>Q!=="--"&&Q.includes("-")).forEach((Q)=>{delete m[Q]});if($["strip-aliased"])[].concat(...Object.keys(B).map((Q)=>B[Q])).forEach((Q)=>{if($["camel-case-expansion"]&&Q.includes("-"))delete m[Q.split(".").map((G)=>pD(G)).join(".")];delete m[Q]});function uD(Q){let G=L("_",Q);if(typeof G==="string"||typeof G==="number")m._.push(G)}function s(Q,G,T,U){let X,_=P(G,J.nargs);if(_=typeof _!=="number"||isNaN(_)?1:_,_===0){if(!ED(U))v=Error(W("Argument unexpected for: %s",G));return y(G,c(G)),Q}let I=ED(U)?0:1;if($["nargs-eats-options"]){if(T.length-(Q+1)+I<_)v=Error(W("Not enough arguments following: %s",G));I=_}else{for(X=Q+1;X<T.length;X++)if(!T[X].match(/^-[^0-9]/)||T[X].match(S)||g(T[X]))I++;else break;if(I<_)v=Error(W("Not enough arguments following: %s",G))}let A=Math.min(I,_);if(!ED(U)&&A>0)y(G,U),A--;for(X=Q+1;X<A+Q+1;X++)y(G,T[X]);return Q+A}function jD(Q,G,T,U){let X=[],_=U||T[Q+1],I=P(G,J.nargs);if(P(G,J.bools)&&!/^(true|false)$/.test(_))X.push(!0);else if(ED(_)||ED(U)&&/^-/.test(_)&&!S.test(_)&&!g(_)){if(Z[G]!==void 0){let A=Z[G];X=Array.isArray(A)?A:[A]}}else{if(!ED(U))X.push(N(G,U,!0));for(let A=Q+1;A<T.length;A++){if(!$["greedy-arrays"]&&X.length>0||I&&typeof I==="number"&&X.length>=I)break;if(_=T[A],/^-/.test(_)&&!S.test(_)&&!g(_))break;Q=A,X.push(N(G,_,E))}}if(typeof I==="number"&&(I&&X.length<I||isNaN(I)&&X.length===0))v=Error(W("Not enough arguments following: %s",G));return y(G,X),Q}function y(Q,G,T=E){if(/-/.test(Q)&&$["camel-case-expansion"]){let _=Q.split(".").map(function(I){return pD(I)}).join(".");Ju(Q,_)}let U=N(Q,G,T),X=Q.split(".");if(fD(m,X,U),J.aliases[Q])J.aliases[Q].forEach(function(_){let I=_.split(".");fD(m,I,U)});if(X.length>1&&$["dot-notation"])(J.aliases[X[0]]||[]).forEach(function(_){let I=_.split("."),A=[].concat(X);if(A.shift(),I=I.concat(A),!(J.aliases[Q]||[]).includes(I.join(".")))fD(m,I,U)});if(P(Q,J.normalize)&&!P(Q,J.arrays))[Q].concat(J.aliases[Q]||[]).forEach(function(I){Object.defineProperty(l,I,{enumerable:!0,get(){return G},set(A){G=typeof A==="string"?AD.normalize(A):A}})})}function Ju(Q,G){if(!(J.aliases[Q]&&J.aliases[Q].length))J.aliases[Q]=[G],q[G]=!0;if(!(J.aliases[G]&&J.aliases[G].length))Ju(G,Q)}function N(Q,G,T){if(T)G=X3(G);if(P(Q,J.bools)||P(Q,J.counts)){if(typeof G==="string")G=G==="true"}let U=Array.isArray(G)?G.map(function(X){return L(Q,X)}):L(Q,G);if(P(Q,J.counts)&&(ED(U)||typeof U==="boolean"))U=$F();if(P(Q,J.normalize)&&P(Q,J.arrays))if(Array.isArray(G))U=G.map((X)=>{return AD.normalize(X)});else U=AD.normalize(G);return U}function L(Q,G){if(!$["parse-positional-numbers"]&&Q==="_")return G;if(!P(Q,J.strings)&&!P(Q,J.bools)&&!Array.isArray(G)){if(Su(G)&&$["parse-numbers"]&&Number.isSafeInteger(Math.floor(parseFloat(`${G}`)))||!ED(G)&&P(Q,J.numbers))G=Number(G)}return G}function R(Q){let G=Object.create(null);PD(G,J.aliases,Z),Object.keys(J.configs).forEach(function(T){let U=Q[T]||G[T];if(U)try{let X=null,_=AD.resolve(AD.cwd(),U),I=J.configs[T];if(typeof I==="function"){try{X=I(_)}catch(A){X=A}if(X instanceof Error){v=X;return}}else X=AD.require(_);h(X)}catch(X){if(X.name==="PermissionDenied")v=X;else if(Q[T])v=Error(W("Invalid JSON config file: %s",U))}})}function h(Q,G){Object.keys(Q).forEach(function(T){let U=Q[T],X=G?G+"."+T:T;if(typeof U==="object"&&U!==null&&!Array.isArray(U)&&$["dot-notation"])h(U,X);else if(!t(m,X.split("."))||P(X,J.arrays)&&$["combine-arrays"])y(X,U)})}function p(){if(typeof M<"u")M.forEach(function(Q){h(Q)})}function DD(Q,G){if(typeof H>"u")return;let T=typeof H==="string"?H:"",U=AD.env();Object.keys(U).forEach(function(X){if(T===""||X.lastIndexOf(T,0)===0){let _=X.split("__").map(function(I,A){if(A===0)I=I.substring(T.length);return pD(I)});if((G&&J.configs[_.join(".")]||!G)&&!t(Q,_))y(_.join("."),U[X])}})}function k(Q){let G,T=new Set;Object.keys(Q).forEach(function(U){if(!T.has(U)){if(G=P(U,J.coercions),typeof G==="function")try{let X=L(U,G(Q[U]));[].concat(J.aliases[U]||[],U).forEach((_)=>{T.add(_),Q[_]=X})}catch(X){v=X}}})}function FD(Q){return J.keys.forEach((G)=>{if(~G.indexOf("."))return;if(typeof Q[G]>"u")Q[G]=void 0}),Q}function PD(Q,G,T,U=!1){Object.keys(T).forEach(function(X){if(!t(Q,X.split("."))){if(fD(Q,X.split("."),T[X]),U)O[X]=!0;(G[X]||[]).forEach(function(_){if(t(Q,_.split(".")))return;fD(Q,_.split("."),T[X])})}})}function t(Q,G){let T=Q;if(!$["dot-notation"])G=[G.join(".")];G.slice(0,-1).forEach(function(X){T=T[X]||{}});let U=G[G.length-1];if(typeof T!=="object")return!1;else return U in T}function fD(Q,G,T){let U=Q;if(!$["dot-notation"])G=[G.join(".")];G.slice(0,-1).forEach(function(BD){if(BD=Y0(BD),typeof U==="object"&&U[BD]===void 0)U[BD]={};if(typeof U[BD]!=="object"||Array.isArray(U[BD])){if(Array.isArray(U[BD]))U[BD].push({});else U[BD]=[U[BD],{}];U=U[BD][U[BD].length-1]}else U=U[BD]});let X=Y0(G[G.length-1]),_=P(G.join("."),J.arrays),I=Array.isArray(T),A=$["duplicate-arguments-array"];if(!A&&P(X,J.nargs)){if(A=!0,!ED(U[X])&&J.nargs[X]===1||Array.isArray(U[X])&&U[X].length===J.nargs[X])U[X]=void 0}if(T===$F())U[X]=$F(U[X]);else if(Array.isArray(U[X]))if(A&&_&&I)U[X]=$["flatten-duplicate-arrays"]?U[X].concat(T):(Array.isArray(U[X][0])?U[X]:[U[X]]).concat([T]);else if(!A&&Boolean(_)===Boolean(I))U[X]=T;else U[X]=U[X].concat([T]);else if(U[X]===void 0&&_)U[X]=I?T:[T];else if(A&&!(U[X]===void 0||P(X,J.counts)||P(X,J.bools)))U[X]=[U[X],T];else U[X]=T}function Yu(...Q){Q.forEach(function(G){Object.keys(G||{}).forEach(function(T){if(J.aliases[T])return;J.aliases[T]=[].concat(B[T]||[]),J.aliases[T].concat(T).forEach(function(U){if(/-/.test(U)&&$["camel-case-expansion"]){let X=pD(U);if(X!==T&&J.aliases[T].indexOf(X)===-1)J.aliases[T].push(X),q[X]=!0}}),J.aliases[T].concat(T).forEach(function(U){if(U.length>1&&/[A-Z]/.test(U)&&$["camel-case-expansion"]){let X=Au(U,"-");if(X!==T&&J.aliases[T].indexOf(X)===-1)J.aliases[T].push(X),q[X]=!0}}),J.aliases[T].forEach(function(U){J.aliases[U]=[T].concat(J.aliases[T].filter(function(X){return U!==X}))})})})}function P(Q,G){let T=[].concat(J.aliases[Q]||[],Q),U=Object.keys(G),X=T.find((_)=>U.includes(_));return X?G[X]:!1}function Eu(Q){let G=Object.keys(J);return[].concat(G.map((U)=>J[U])).some(function(U){return Array.isArray(U)?U.includes(Q):U[Q]})}function vF(Q,...G){return[].concat(...G).some(function(U){let X=Q.match(U);return X&&Eu(X[1])})}function x(Q){if(Q.match(S)||!Q.match(/^-[^-]+/))return!1;let G=!0,T,U=Q.slice(1).split("");for(let X=0;X<U.length;X++){if(T=Q.slice(X+2),!Eu(U[X])){G=!1;break}if(U[X+1]&&U[X+1]==="="||T==="-"||/[A-Za-z]/.test(U[X])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(T)||U[X+1]&&U[X+1].match(/\W/))break}return G}function g(Q){return $["unknown-options-as-args"]&&CD(Q)}function CD(Q){if(Q=Q.replace(/^-{3,}/,"--"),Q.match(S))return!1;if(x(Q))return!1;return!vF(Q,/^-+([^=]+?)=[\s\S]*$/,d,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}function c(Q){if(!P(Q,J.bools)&&!P(Q,J.counts)&&`${Q}`in Z)return Z[Q];else return zD(r(Q))}function zD(Q){return{[UD.BOOLEAN]:!0,[UD.STRING]:"",[UD.NUMBER]:void 0,[UD.ARRAY]:[]}[Q]}function r(Q){let G=UD.BOOLEAN;if(P(Q,J.strings))G=UD.STRING;else if(P(Q,J.numbers))G=UD.NUMBER;else if(P(Q,J.bools))G=UD.BOOLEAN;else if(P(Q,J.arrays))G=UD.ARRAY;return G}function ED(Q){return Q===void 0}function au(){Object.keys(J.counts).find((Q)=>{if(P(Q,J.arrays))return v=Error(W("Invalid configuration: %s, opts.count excludes opts.array.",Q)),!0;else if(P(Q,J.nargs))return v=Error(W("Invalid configuration: %s, opts.count excludes opts.narg.",Q)),!0;return!1})}return{aliases:Object.assign({},J.aliases),argv:Object.assign(l,m),configuration:$,defaulted:Object.assign({},O),error:v,newAliases:Object.assign({},q)}}}function Q3(D){let u=[],F=Object.create(null),C=!0;Object.keys(D).forEach(function(E){u.push([].concat(D[E],E))});while(C){C=!1;for(let E=0;E<u.length;E++)for(let B=E+1;B<u.length;B++)if(u[E].filter(function(Z){return u[B].indexOf(Z)!==-1}).length){u[E]=u[E].concat(u[B]),u.splice(B,1),C=!0;break}}return u.forEach(function(E){E=E.filter(function($,Z,M){return M.indexOf($)===Z});let B=E.pop();if(B!==void 0&&typeof B==="string")F[B]=E}),F}function $F(D){return D!==void 0?D+1:1}function Y0(D){if(D==="__proto__")return"___proto___";return D}function X3(D){return typeof D==="string"&&(D[0]==="'"||D[0]==='"')&&D[D.length-1]===D[0]?D.substring(1,D.length-1):D}import{readFileSync as Y3}from"fs";import{createRequire as q0}from"module";var ZF,QF,XF,H0=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):20,O0=(QF=(ZF=process===null||process===void 0?void 0:process.versions)===null||ZF===void 0?void 0:ZF.node)!==null&&QF!==void 0?QF:(XF=process===null||process===void 0?void 0:process.version)===null||XF===void 0?void 0:XF.slice(1);if(O0){if(Number(O0.match(/^([^.]+)/)[1])<H0)throw Error(`yargs parser supports a minimum Node.js version of ${H0}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`)}var q3=process?process.env:{},U0=q0?q0(import.meta.url):void 0,W0=new zF({cwd:process.cwd,env:()=>{return q3},format:M3,normalize:G3,resolve:J3,require:(D)=>{if(typeof U0<"u")return U0(D);else if(D.match(/\.json$/))return JSON.parse(Y3(D,"utf8"));else throw Error("only .json config files are supported in ESM")}}),qu=function(u,F){return W0.parse(u.slice(),F).argv};qu.detailed=function(D,u){return W0.parse(D.slice(),u)};qu.camelCase=pD;qu.decamelize=Au;qu.looksLikeNumber=Su;var V0=qu;import{basename as R3,dirname as f3,extname as A3,relative as S3,resolve as R0,join as P3}from"path";function H3(){if(O3())return 0;return 1}function O3(){return U3()&&!process.defaultApp}function U3(){return!!process.versions.electron}function T0(){return process.argv[H3()]}import{readFileSync as W3,statSync as V3,writeFile as T3}from"fs";import{format as L3}from"util";import{resolve as I3}from"path";var L0={fs:{readFileSync:W3,writeFile:T3},format:L3,resolve:I3,exists:(D)=>{try{return V3(D).isFile()}catch(u){return!1}}};var ID;class I0{constructor(D){D=D||{},this.directory=D.directory||"./locales",this.updateFiles=typeof D.updateFiles==="boolean"?D.updateFiles:!0,this.locale=D.locale||"en",this.fallbackToLanguage=typeof D.fallbackToLanguage==="boolean"?D.fallbackToLanguage:!0,this.cache=Object.create(null),this.writeQueue=[]}__(...D){if(typeof arguments[0]!=="string")return this._taggedLiteral(arguments[0],...arguments);let u=D.shift(),F=function(){};if(typeof D[D.length-1]==="function")F=D.pop();if(F=F||function(){},!this.cache[this.locale])this._readLocaleFile();if(!this.cache[this.locale][u]&&this.updateFiles)this.cache[this.locale][u]=u,this._enqueueWrite({directory:this.directory,locale:this.locale,cb:F});else F();return ID.format.apply(ID.format,[this.cache[this.locale][u]||u].concat(D))}__n(){let D=Array.prototype.slice.call(arguments),u=D.shift(),F=D.shift(),C=D.shift(),E=function(){};if(typeof D[D.length-1]==="function")E=D.pop();if(!this.cache[this.locale])this._readLocaleFile();let B=C===1?u:F;if(this.cache[this.locale][u])B=this.cache[this.locale][u][C===1?"one":"other"];if(!this.cache[this.locale][u]&&this.updateFiles)this.cache[this.locale][u]={one:u,other:F},this._enqueueWrite({directory:this.directory,locale:this.locale,cb:E});else E();let $=[B];if(~B.indexOf("%d"))$.push(C);return ID.format.apply(ID.format,$.concat(D))}setLocale(D){this.locale=D}getLocale(){return this.locale}updateLocale(D){if(!this.cache[this.locale])this._readLocaleFile();for(let u in D)if(Object.prototype.hasOwnProperty.call(D,u))this.cache[this.locale][u]=D[u]}_taggedLiteral(D,...u){let F="";return D.forEach(function(C,E){let B=u[E+1];if(F+=C,typeof B<"u")F+="%s"}),this.__.apply(this,[F].concat([].slice.call(u,1)))}_enqueueWrite(D){if(this.writeQueue.push(D),this.writeQueue.length===1)this._processWriteQueue()}_processWriteQueue(){let D=this,u=this.writeQueue[0],F=u.directory,C=u.locale,E=u.cb,B=this._resolveLocaleFile(F,C),$=JSON.stringify(this.cache[C],null,2);ID.fs.writeFile(B,$,"utf-8",function(Z){if(D.writeQueue.shift(),D.writeQueue.length>0)D._processWriteQueue();E(Z)})}_readLocaleFile(){let D={},u=this._resolveLocaleFile(this.directory,this.locale);try{if(ID.fs.readFileSync)D=JSON.parse(ID.fs.readFileSync(u,"utf-8"))}catch(F){if(F instanceof SyntaxError)F.message="syntax error in "+u;if(F.code==="ENOENT")D={};else throw F}this.cache[this.locale]=D}_resolveLocaleFile(D,u){let F=ID.resolve(D,"./",u+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(F)&&~u.lastIndexOf("_")){let C=ID.resolve(D,"./",u.split("_")[0]+".json");if(this._fileExistsSync(C))F=C}return F}_fileExistsSync(D){return ID.exists(D)}}function K0(D,u){ID=u;let F=new I0(D);return{__:F.__.bind(F),__n:F.__n.bind(F),setLocale:F.setLocale.bind(F),getLocale:F.getLocale.bind(F),updateLocale:F.updateLocale.bind(F),locale:F.locale}}var K3=(D)=>{return K0(D,L0)},j0=K3;var A0=v8(N0(),1);import{createRequire as x3}from"module";import{readFileSync as b3,readdirSync as h3}from"fs";var MF=f0(import.meta.url),w3=MF.substring(0,MF.lastIndexOf("node_modules")),m3=x3(import.meta.url),S0={assert:{notStrictEqual:j3,strictEqual:_3},cliui:EF,findUp:BF,getEnv:(D)=>{return process.env[D]},inspect:N3,getProcessArgvBin:T0,mainFilename:w3||process.cwd(),Parser:V0,path:{basename:R3,dirname:f3,extname:A3,relative:S3,resolve:R0,join:P3},process:{argv:()=>process.argv,cwd:process.cwd,emitWarning:(D,u)=>process.emitWarning(D,u),execPath:()=>process.execPath,exit:(D)=>{process.exit(D)},nextTick:process.nextTick,stdColumns:typeof process.stdout.columns<"u"?process.stdout.columns:null},readFileSync:b3,readdirSync:h3,require:m3,getCallerFile:()=>{let D=A0.default(3);return D.match(/^file:\/\//)?f0(D):D},stringWidth:LD,y18n:j0({directory:R0(MF,"../../../locales"),updateFiles:!1})};function GD(D,u,F,C){F.assert.notStrictEqual(D,u,C)}function GF(D,u){u.assert.strictEqual(typeof D,"string")}function Bu(D){return Object.keys(D)}function i(D){return!!D&&!!D.then&&typeof D.then==="function"}class a extends Error{constructor(D){super(D||"yargs error");if(this.name="YError",Error.captureStackTrace)Error.captureStackTrace(this,a)}}function xD(D){let F=D.replace(/\s{2,}/g," ").split(/\s+(?![^[]*]|[^<]*>)/),C=/\.*[\][<>]/g,E=F.shift();if(!E)throw Error(`No command found in: ${D}`);let B={cmd:E.replace(C,""),demanded:[],optional:[]};return F.forEach(($,Z)=>{let M=!1;if($=$.replace(/\s/g,""),/\.+[\]>]/.test($)&&Z===F.length-1)M=!0;if(/^\[/.test($))B.optional.push({cmd:$.replace(C,"").split("|"),variadic:M});else B.demanded.push({cmd:$.replace(C,"").split("|"),variadic:M})}),B}var v3=["first","second","third","fourth","fifth","sixth"];function K(D,u,F){function C(){return typeof D==="object"?[{demanded:[],optional:[]},D,u]:[xD(`cmd ${D}`),u,F]}try{let E=0,[B,$,Z]=C(),M=[].slice.call($);while(M.length&&M[M.length-1]===void 0)M.pop();let H=Z||M.length;if(H<B.demanded.length)throw new a(`Not enough arguments provided. Expected ${B.demanded.length} but received ${M.length}.`);let V=B.demanded.length+B.optional.length;if(H>V)throw new a(`Too many arguments provided. Expected max ${V} but received ${H}.`);B.demanded.forEach((Y)=>{let q=M.shift(),O=P0(q);if(Y.cmd.filter((J)=>J===O||J==="*").length===0)x0(O,Y.cmd,E);E+=1}),B.optional.forEach((Y)=>{if(M.length===0)return;let q=M.shift(),O=P0(q);if(Y.cmd.filter((J)=>J===O||J==="*").length===0)x0(O,Y.cmd,E);E+=1})}catch(E){console.warn(E.stack)}}function P0(D){if(Array.isArray(D))return"array";else if(D===null)return"null";return typeof D}function x0(D,u,F){throw new a(`Invalid ${v3[F]||"manyith"} argument. Expected ${u.join(" or ")} but received ${D}.`)}class JF{constructor(D){this.globalMiddleware=[],this.frozens=[],this.yargs=D}addMiddleware(D,u,F=!0,C=!1){if(K("<array|function> [boolean] [boolean] [boolean]",[D,u,F],arguments.length),Array.isArray(D)){for(let E=0;E<D.length;E++){if(typeof D[E]!=="function")throw Error("middleware must be a function");let B=D[E];B.applyBeforeValidation=u,B.global=F}Array.prototype.push.apply(this.globalMiddleware,D)}else if(typeof D==="function"){let E=D;E.applyBeforeValidation=u,E.global=F,E.mutates=C,this.globalMiddleware.push(D)}return this.yargs}addCoerceMiddleware(D,u){let F=this.yargs.getAliases();return this.globalMiddleware=this.globalMiddleware.filter((C)=>{let E=[...F[u]||[],u];if(!C.option)return!0;else return!E.includes(C.option)}),D.option=u,this.addMiddleware(D,!0,!0,!0)}getMiddleware(){return this.globalMiddleware}freeze(){this.frozens.push([...this.globalMiddleware])}unfreeze(){let D=this.frozens.pop();if(D!==void 0)this.globalMiddleware=D}reset(){this.globalMiddleware=this.globalMiddleware.filter((D)=>D.global)}}function b0(D){if(!D)return[];return D.map((u)=>{return u.applyBeforeValidation=!1,u})}function yD(D,u,F,C){return F.reduce((E,B)=>{if(B.applyBeforeValidation!==C)return E;if(B.mutates){if(B.applied)return E;B.applied=!0}if(i(E))return E.then(($)=>Promise.all([$,B($,u)])).then(([$,Z])=>Object.assign($,Z));else{let $=B(E,u);return i($)?$.then((Z)=>Object.assign(E,Z)):Object.assign(E,$)}},D)}function gD(D,u,F=(C)=>{throw C}){try{let C=c3(D)?D():D;return i(C)?C.then((E)=>u(E)):u(C)}catch(C){return F(C)}}function c3(D){return typeof D==="function"}var $u=/(^\*)|(^\$0)/;class w0{constructor(D,u,F,C){this.requireCache=new Set,this.handlers={},this.aliasMap={},this.frozens=[],this.shim=C,this.usage=D,this.globalMiddleware=F,this.validation=u}addDirectory(D,u,F,C){C=C||{},this.requireCache.add(F);let E=this.shim.path.resolve(this.shim.path.dirname(F),D),B=this.shim.readdirSync(E,{recursive:C.recurse?!0:!1});if(!Array.isArray(C.extensions))C.extensions=["js"];let $=typeof C.visit==="function"?C.visit:(Z)=>Z;for(let Z of B){let M=Z.toString();if(C.exclude){let V=!1;if(typeof C.exclude==="function")V=C.exclude(M);else V=C.exclude.test(M);if(V)continue}if(C.include){let V=!1;if(typeof C.include==="function")V=C.include(M);else V=C.include.test(M);if(!V)continue}let H=!1;for(let V of C.extensions)if(M.endsWith(V))H=!0;if(H){let V=this.shim.path.join(E,M),Y=u(V),q=Object.create(null,Object.getOwnPropertyDescriptors({...Y}));if($(q,V,M)){if(this.requireCache.has(V))continue;else this.requireCache.add(V);if(!q.command)q.command=this.shim.path.basename(V,this.shim.path.extname(V));this.addHandler(q)}}}}addHandler(D,u,F,C,E,B){let $=[],Z=b0(E);if(C=C||(()=>{}),Array.isArray(D))if(d3(D))[D,...$]=D;else for(let M of D)this.addHandler(M);else if(p3(D)){let M=Array.isArray(D.command)||typeof D.command==="string"?D.command:null;if(M===null)throw Error(`No command name given for module: ${this.shim.inspect(D)}`);if(D.aliases)M=[].concat(M).concat(D.aliases);this.addHandler(M,this.extractDesc(D),D.builder,D.handler,D.middlewares,D.deprecated);return}else if(h0(F)){this.addHandler([D].concat($),u,F.builder,F.handler,F.middlewares,F.deprecated);return}if(typeof D==="string"){let M=xD(D);$=$.map((Y)=>xD(Y).cmd);let H=!1,V=[M.cmd].concat($).filter((Y)=>{if($u.test(Y))return H=!0,!1;return!0});if(V.length===0&&H)V.push("$0");if(H)M.cmd=V[0],$=V.slice(1),D=D.replace($u,M.cmd);if($.forEach((Y)=>{this.aliasMap[Y]=M.cmd}),u!==!1)this.usage.command(D,u,H,$,B);if(this.handlers[M.cmd]={original:D,description:u,handler:C,builder:F||{},middlewares:Z,deprecated:B,demanded:M.demanded,optional:M.optional},H)this.defaultCommand=this.handlers[M.cmd]}}getCommandHandlers(){return this.handlers}getCommands(){return Object.keys(this.handlers).concat(Object.keys(this.aliasMap))}hasDefaultCommand(){return!!this.defaultCommand}runCommand(D,u,F,C,E,B){let $=this.handlers[D]||this.handlers[this.aliasMap[D]]||this.defaultCommand,Z=u.getInternalMethods().getContext(),M=Z.commands.slice(),H=!D;if(D)Z.commands.push(D),Z.fullCommands.push($.original);let V=this.applyBuilderUpdateUsageAndParse(H,$,u,F.aliases,M,C,E,B);return i(V)?V.then((Y)=>this.applyMiddlewareAndGetResult(H,$,Y.innerArgv,Z,E,Y.aliases,u)):this.applyMiddlewareAndGetResult(H,$,V.innerArgv,Z,E,V.aliases,u)}applyBuilderUpdateUsageAndParse(D,u,F,C,E,B,$,Z){let M=u.builder,H=F;if(Pu(M)){F.getInternalMethods().getUsageInstance().freeze();let V=M(F.getInternalMethods().reset(C),Z);if(i(V))return V.then((Y)=>{return H=v0(Y)?Y:F,this.parseAndUpdateUsage(D,u,H,E,B,$)})}else if(k3(M))F.getInternalMethods().getUsageInstance().freeze(),H=F.getInternalMethods().reset(C),Object.keys(u.builder).forEach((V)=>{H.option(V,M[V])});return this.parseAndUpdateUsage(D,u,H,E,B,$)}parseAndUpdateUsage(D,u,F,C,E,B){if(D)F.getInternalMethods().getUsageInstance().unfreeze(!0);if(this.shouldUpdateUsage(F))F.getInternalMethods().getUsageInstance().usage(this.usageFromParentCommandsCommandHandler(C,u),u.description);let $=F.getInternalMethods().runYargsParserAndExecuteCommands(null,void 0,!0,E,B);return i($)?$.then((Z)=>({aliases:F.parsed.aliases,innerArgv:Z})):{aliases:F.parsed.aliases,innerArgv:$}}shouldUpdateUsage(D){return!D.getInternalMethods().getUsageInstance().getUsageDisabled()&&D.getInternalMethods().getUsageInstance().getUsage().length===0}usageFromParentCommandsCommandHandler(D,u){let F=$u.test(u.original)?u.original.replace($u,"").trim():u.original,C=D.filter((E)=>{return!$u.test(E)});return C.push(F),`$0 ${C.join(" ")}`}handleValidationAndGetResult(D,u,F,C,E,B,$,Z){if(!B.getInternalMethods().getHasOutput()){let M=B.getInternalMethods().runValidation(E,Z,B.parsed.error,D);F=gD(F,(H)=>{return M(H),H})}if(u.handler&&!B.getInternalMethods().getHasOutput()){B.getInternalMethods().setHasOutput();let M=!!B.getOptions().configuration["populate--"];if(B.getInternalMethods().postProcess(F,M,!1,!1),F=yD(F,B,$,!1),F=gD(F,(H)=>{let V=u.handler(H);return i(V)?V.then(()=>H):H}),!D)B.getInternalMethods().getUsageInstance().cacheHelpMessage();if(i(F)&&!B.getInternalMethods().hasParseCallback())F.catch((H)=>{try{B.getInternalMethods().getUsageInstance().fail(null,H)}catch(V){}})}if(!D)C.commands.pop(),C.fullCommands.pop();return F}applyMiddlewareAndGetResult(D,u,F,C,E,B,$){let Z={};if(E)return F;if(!$.getInternalMethods().getHasOutput())Z=this.populatePositionals(u,F,C,$);let M=this.globalMiddleware.getMiddleware().slice(0).concat(u.middlewares),H=yD(F,$,M,!0);return i(H)?H.then((V)=>this.handleValidationAndGetResult(D,u,V,C,B,$,M,Z)):this.handleValidationAndGetResult(D,u,H,C,B,$,M,Z)}populatePositionals(D,u,F,C){u._=u._.slice(F.commands.length);let E=D.demanded.slice(0),B=D.optional.slice(0),$={};this.validation.positionalCount(E.length,u._.length);while(E.length){let Z=E.shift();this.populatePositional(Z,u,$)}while(B.length){let Z=B.shift();this.populatePositional(Z,u,$)}return u._=F.commands.concat(u._.map((Z)=>""+Z)),this.postProcessPositionals(u,$,this.cmdToParseOptions(D.original),C),$}populatePositional(D,u,F){let C=D.cmd[0];if(D.variadic)F[C]=u._.splice(0).map(String);else if(u._.length)F[C]=[String(u._.shift())]}cmdToParseOptions(D){let u={array:[],default:{},alias:{},demand:{}},F=xD(D);return F.demanded.forEach((C)=>{let[E,...B]=C.cmd;if(C.variadic)u.array.push(E),u.default[E]=[];u.alias[E]=B,u.demand[E]=!0}),F.optional.forEach((C)=>{let[E,...B]=C.cmd;if(C.variadic)u.array.push(E),u.default[E]=[];u.alias[E]=B}),u}postProcessPositionals(D,u,F,C){let E=Object.assign({},C.getOptions());E.default=Object.assign(F.default,E.default);for(let M of Object.keys(F.alias))E.alias[M]=(E.alias[M]||[]).concat(F.alias[M]);E.array=E.array.concat(F.array),E.config={};let B=[];if(Object.keys(u).forEach((M)=>{u[M].map((H)=>{if(E.configuration["unknown-options-as-args"])E.key[M]=!0;B.push(`--${M}`),B.push(H)})}),!B.length)return;let $=Object.assign({},E.configuration,{"populate--":!1}),Z=this.shim.Parser.detailed(B,Object.assign({},E,{configuration:$}));if(Z.error)C.getInternalMethods().getUsageInstance().fail(Z.error.message,Z.error);else{let M=Object.keys(u);Object.keys(u).forEach((H)=>{M.push(...Z.aliases[H])}),Object.keys(Z.argv).forEach((H)=>{if(M.includes(H)){if(!u[H])u[H]=Z.argv[H];if(!this.isInConfigs(C,H)&&!this.isDefaulted(C,H)&&Object.prototype.hasOwnProperty.call(D,H)&&Object.prototype.hasOwnProperty.call(Z.argv,H)&&(Array.isArray(D[H])||Array.isArray(Z.argv[H])))D[H]=[].concat(D[H],Z.argv[H]);else D[H]=Z.argv[H]}})}}isDefaulted(D,u){let{default:F}=D.getOptions();return Object.prototype.hasOwnProperty.call(F,u)||Object.prototype.hasOwnProperty.call(F,this.shim.Parser.camelCase(u))}isInConfigs(D,u){let{configObjects:F}=D.getOptions();return F.some((C)=>Object.prototype.hasOwnProperty.call(C,u))||F.some((C)=>Object.prototype.hasOwnProperty.call(C,this.shim.Parser.camelCase(u)))}runDefaultBuilderOn(D){if(!this.defaultCommand)return;if(this.shouldUpdateUsage(D)){let F=$u.test(this.defaultCommand.original)?this.defaultCommand.original:this.defaultCommand.original.replace(/^[^[\]<>]*/,"$0 ");D.getInternalMethods().getUsageInstance().usage(F,this.defaultCommand.description)}let u=this.defaultCommand.builder;if(Pu(u))return u(D,!0);else if(!h0(u))Object.keys(u).forEach((F)=>{D.option(F,u[F])});return}extractDesc({describe:D,description:u,desc:F}){for(let C of[D,u,F]){if(typeof C==="string"||C===!1)return C;GD(C,!0,this.shim)}return!1}freeze(){this.frozens.push({handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand})}unfreeze(){let D=this.frozens.pop();GD(D,void 0,this.shim),{handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand}=D}reset(){return this.handlers={},this.aliasMap={},this.defaultCommand=void 0,this.requireCache=new Set,this}}function m0(D,u,F,C){return new w0(D,u,F,C)}function h0(D){return typeof D==="object"&&!!D.builder&&typeof D.handler==="function"}function d3(D){return D.every((u)=>typeof u==="string")}function Pu(D){return typeof D==="function"}function k3(D){return typeof D==="object"}function p3(D){return typeof D==="object"&&!Array.isArray(D)}function bD(D={},u=()=>!0){let F={};return Bu(D).forEach((C)=>{if(u(C,D[C]))F[C]=D[C]}),F}function hD(D){if(typeof process>"u")return;[process.stdout,process.stderr].forEach((u)=>{let F=u;if(F._handle&&F.isTTY&&typeof F._handle.setBlocking==="function")F._handle.setBlocking(D)})}function y3(D){return typeof D==="boolean"}function d0(D,u){let F=u.y18n.__,C={},E=[];C.failFn=function(L){E.push(L)};let B=null,$=null,Z=!0;C.showHelpOnFail=function(L=!0,R){let[h,p]=typeof L==="string"?[!0,L]:[L,R];if(D.getInternalMethods().isGlobalContext())$=p;return B=p,Z=h,C};let M=!1;C.fail=function(L,R){let h=D.getInternalMethods().getLoggerInstance();if(E.length)for(let p=E.length-1;p>=0;--p){let DD=E[p];if(y3(DD)){if(R)throw R;else if(L)throw Error(L)}else DD(L,R,C)}else{if(D.getExitProcess())hD(!0);if(!M){if(M=!0,Z)D.showHelp("error"),h.error();if(L||R)h.error(L||R);let p=B||$;if(p){if(L||R)h.error("");h.error(p)}}if(R=R||new a(L),D.getExitProcess())return D.exit(1);else if(D.getInternalMethods().hasParseCallback())return D.exit(1,R);else throw R}};let H=[],V=!1;C.usage=(N,L)=>{if(N===null)return V=!0,H=[],C;return V=!1,H.push([N,L||""]),C},C.getUsage=()=>{return H},C.getUsageDisabled=()=>{return V},C.getPositionalGroupName=()=>{return F("Positionals:")};let Y=[];C.example=(N,L)=>{Y.push([N,L||""])};let q=[];C.command=function(L,R,h,p,DD=!1){if(h)q=q.map((k)=>{return k[2]=!1,k});q.push([L,R||"",h,p,DD])},C.getCommands=()=>q;let O={};C.describe=function(L,R){if(Array.isArray(L))L.forEach((h)=>{C.describe(h,R)});else if(typeof L==="object")Object.keys(L).forEach((h)=>{C.describe(h,L[h])});else O[L]=R},C.getDescriptions=()=>O;let W=[];C.epilog=(N)=>{W.push(N)};let J=!1,S;C.wrap=(N)=>{J=!0,S=N},C.getWrap=()=>{if(u.getEnv("YARGS_DISABLE_WRAP"))return null;if(!J)S=jD(),J=!0;return S};let d="__yargsString__:";C.deferY18nLookup=(N)=>d+N,C.help=function(){if(m)return m;QD();let L=D.customScriptName?D.$0:u.path.basename(D.$0),R=D.getDemandedOptions(),h=D.getDemandedCommands(),p=D.getDeprecatedOptions(),DD=D.getGroups(),k=D.getOptions(),FD=[];FD=FD.concat(Object.keys(O)),FD=FD.concat(Object.keys(R)),FD=FD.concat(Object.keys(h)),FD=FD.concat(Object.keys(k.default)),FD=FD.filter(uD),FD=Object.keys(FD.reduce((x,g)=>{if(g!=="_")x[g]=!0;return x},{}));let PD=C.getWrap(),t=u.cliui({width:PD,wrap:!!PD});if(!V){if(H.length)H.forEach((x)=>{if(t.div({text:`${x[0].replace(/\$0/g,L)}`}),x[1])t.div({text:`${x[1]}`,padding:[1,0,0,0]})}),t.div();else if(q.length){let x=null;if(h._)x=`${L} <${F("command")}>
15
- `;else x=`${L} [${F("command")}]
16
- `;t.div(`${x}`)}}if(q.length>1||q.length===1&&!q[0][2]){t.div(F("Commands:"));let x=D.getInternalMethods().getContext(),g=x.commands.length?`${x.commands.join(" ")} `:"";if(D.getInternalMethods().getParserConfiguration()["sort-commands"]===!0)q=q.sort((c,zD)=>c[0].localeCompare(zD[0]));let CD=L?`${L} `:"";q.forEach((c)=>{let zD=`${CD}${g}${c[0].replace(/^\$0 ?/,"")}`;t.span({text:zD,padding:[0,2,0,2],width:v(q,PD,`${L}${g}`)+4},{text:c[1]});let r=[];if(c[2])r.push(`[${F("default")}]`);if(c[3]&&c[3].length)r.push(`[${F("aliases:")} ${c[3].join(", ")}]`);if(c[4])if(typeof c[4]==="string")r.push(`[${F("deprecated: %s",c[4])}]`);else r.push(`[${F("deprecated")}]`);if(r.length)t.div({text:r.join(" "),padding:[0,0,0,2],align:"right"});else t.div()}),t.div()}let fD=(Object.keys(k.alias)||[]).concat(Object.keys(D.parsed.newAliases)||[]);FD=FD.filter((x)=>!D.parsed.newAliases[x]&&fD.every((g)=>(k.alias[g]||[]).indexOf(x)===-1));let Yu=F("Options:");if(!DD[Yu])DD[Yu]=[];l(FD,k.alias,DD,Yu);let P=(x)=>/^--/.test(xu(x)),Eu=Object.keys(DD).filter((x)=>DD[x].length>0).map((x)=>{let g=DD[x].filter(uD).map((CD)=>{if(fD.includes(CD))return CD;for(let c=0,zD;(zD=fD[c])!==void 0;c++)if((k.alias[zD]||[]).includes(CD))return zD;return CD});return{groupName:x,normalizedKeys:g}}).filter(({normalizedKeys:x})=>x.length>0).map(({groupName:x,normalizedKeys:g})=>{let CD=g.reduce((c,zD)=>{return c[zD]=[zD].concat(k.alias[zD]||[]).map((r)=>{if(x===C.getPositionalGroupName())return r;else return(/^[0-9]$/.test(r)?k.boolean.includes(zD)?"-":"--":r.length>1?"--":"-")+r}).sort((r,ED)=>P(r)===P(ED)?0:P(r)?1:-1).join(", "),c},{});return{groupName:x,normalizedKeys:g,switches:CD}});if(Eu.filter(({groupName:x})=>x!==C.getPositionalGroupName()).some(({normalizedKeys:x,switches:g})=>!x.every((CD)=>P(g[CD]))))Eu.filter(({groupName:x})=>x!==C.getPositionalGroupName()).forEach(({normalizedKeys:x,switches:g})=>{x.forEach((CD)=>{if(P(g[CD]))g[CD]=g3(g[CD],4)})});if(Eu.forEach(({groupName:x,normalizedKeys:g,switches:CD})=>{t.div(x),g.forEach((c)=>{let zD=CD[c],r=O[c]||"",ED=null;if(r.includes(d))r=F(r.substring(d.length));if(k.boolean.includes(c))ED=`[${F("boolean")}]`;if(k.count.includes(c))ED=`[${F("count")}]`;if(k.string.includes(c))ED=`[${F("string")}]`;if(k.normalize.includes(c))ED=`[${F("string")}]`;if(k.array.includes(c))ED=`[${F("array")}]`;if(k.number.includes(c))ED=`[${F("number")}]`;let au=(T)=>typeof T==="string"?`[${F("deprecated: %s",T)}]`:`[${F("deprecated")}]`,Q=[c in p?au(p[c]):null,ED,c in R?`[${F("required")}]`:null,k.choices&&k.choices[c]?`[${F("choices:")} ${C.stringifiedValues(k.choices[c])}]`:null,s(k.default[c],k.defaultDescription[c])].filter(Boolean).join(" ");t.span({text:xu(zD),padding:[0,2,0,2+c0(zD)],width:v(CD,PD)+4},r);let G=D.getInternalMethods().getUsageConfiguration()["hide-types"]===!0;if(Q&&!G)t.div({text:Q,padding:[0,0,0,2],align:"right"});else t.div()}),t.div()}),Y.length)t.div(F("Examples:")),Y.forEach((x)=>{x[0]=x[0].replace(/\$0/g,L)}),Y.forEach((x)=>{if(x[1]==="")t.div({text:x[0],padding:[0,2,0,2]});else t.div({text:x[0],padding:[0,2,0,2],width:v(Y,PD)+4},{text:x[1]})}),t.div();if(W.length>0){let x=W.map((g)=>g.replace(/\$0/g,L)).join(`
17
- `);t.div(`${x}
18
- `)}return t.toString().replace(/\s*$/,"")};function v(N,L,R){let h=0;if(!Array.isArray(N))N=Object.values(N).map((p)=>[p]);if(N.forEach((p)=>{h=Math.max(u.stringWidth(R?`${R} ${xu(p[0])}`:xu(p[0]))+c0(p[0]),h)}),L)h=Math.min(h,parseInt((L*0.5).toString(),10));return h}function QD(){let N=D.getDemandedOptions(),L=D.getOptions();(Object.keys(L.alias)||[]).forEach((R)=>{L.alias[R].forEach((h)=>{if(O[h])C.describe(R,O[h]);if(h in N)D.demandOption(R,N[h]);if(L.boolean.includes(h))D.boolean(R);if(L.count.includes(h))D.count(R);if(L.string.includes(h))D.string(R);if(L.normalize.includes(h))D.normalize(R);if(L.array.includes(h))D.array(R);if(L.number.includes(h))D.number(R)})})}let m;C.cacheHelpMessage=function(){m=this.help()},C.clearCachedHelpMessage=function(){m=void 0},C.hasCachedHelpMessage=function(){return!!m};function l(N,L,R,h){let p=[],DD=null;return Object.keys(R).forEach((k)=>{p=p.concat(R[k])}),N.forEach((k)=>{if(DD=[k].concat(L[k]),!DD.some((FD)=>p.indexOf(FD)!==-1))R[h].push(k)}),p}function uD(N){return D.getOptions().hiddenOptions.indexOf(N)<0||D.parsed.argv[D.getOptions().showHiddenOpt]}C.showHelp=(N)=>{let L=D.getInternalMethods().getLoggerInstance();if(!N)N="error";(typeof N==="function"?N:L[N])(C.help())},C.functionDescription=(N)=>{return["(",N.name?u.Parser.decamelize(N.name,"-"):F("generated-value"),")"].join("")},C.stringifiedValues=function(L,R){let h="",p=R||", ",DD=[].concat(L);if(!L||!DD.length)return h;return DD.forEach((k)=>{if(h.length)h+=p;h+=JSON.stringify(k)}),h};function s(N,L){let R=`[${F("default:")} `;if(N===void 0&&!L)return null;if(L)R+=L;else switch(typeof N){case"string":R+=`"${N}"`;break;case"object":R+=JSON.stringify(N);break;default:R+=N}return`${R}]`}function jD(){if(u.process.stdColumns)return Math.min(80,u.process.stdColumns);else return 80}let y=null;C.version=(N)=>{y=N},C.showVersion=(N)=>{let L=D.getInternalMethods().getLoggerInstance();if(!N)N="error";(typeof N==="function"?N:L[N])(y)},C.reset=function(L){return B=null,M=!1,H=[],V=!1,W=[],Y=[],q=[],O=bD(O,(R)=>!L[R]),C};let Ju=[];return C.freeze=function(){Ju.push({failMessage:B,failureOutput:M,usages:H,usageDisabled:V,epilogs:W,examples:Y,commands:q,descriptions:O})},C.unfreeze=function(L=!1){let R=Ju.pop();if(!R)return;if(L)O={...R.descriptions,...O},q=[...R.commands,...q],H=[...R.usages,...H],Y=[...R.examples,...Y],W=[...R.epilogs,...W];else({failMessage:B,failureOutput:M,usages:H,usageDisabled:V,epilogs:W,examples:Y,commands:q,descriptions:O}=R)},C}function YF(D){return typeof D==="object"}function g3(D,u){return YF(D)?{text:D.text,indentation:D.indentation+u}:{text:D,indentation:u}}function c0(D){return YF(D)?D.indentation:0}function xu(D){return YF(D)?D.text:D}var k0=`###-begin-{{app_name}}-completions-###
13
+ `).map((r)=>ra(r,n,t)).join(`
14
+ `)}function Et(e){return dr(e,{stringWidth:ke,stripAnsi:je,wrap:bt})}import{dirname as jr,resolve as kr}from"path";import{readdirSync as ia,statSync as sa}from"fs";function Ct(e,n){let t=kr(".",e),r;if(!sa(t).isDirectory())t=jr(t);while(!0){if(r=n(t,ia(t)),r)return kr(t,r);if(t=jr(r=t),r===t)break}}import{inspect as Na}from"util";import{fileURLToPath as ni}from"url";import{format as ua}from"util";import{normalize as la,resolve as ca}from"path";function Je(e){if(!(e!==e.toLowerCase()&&e!==e.toUpperCase()))e=e.toLowerCase();if(e.indexOf("-")===-1&&e.indexOf("_")===-1)return e;else{let t="",r=!1,i=e.match(/^-+/);for(let s=i?i[0].length:0;s<e.length;s++){let o=e.charAt(s);if(r)r=!1,o=o.toUpperCase();if(s!==0&&(o==="-"||o==="_"))r=!0;else if(o!=="-"&&o!=="_")t+=o}return t}}function Tn(e,n){let t=e.toLowerCase();n=n||"-";let r="";for(let i=0;i<e.length;i++){let s=t.charAt(i),o=e.charAt(i);if(s!==o&&i>0)r+=`${n}${t.charAt(i)}`;else r+=o}return r}function Ln(e){if(e===null||e===void 0)return!1;if(typeof e==="number")return!0;if(/^0x[0-9a-f]+$/i.test(e))return!0;if(/^0[^.]/.test(e))return!1;return/^[-]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(e)}function Mr(e){if(Array.isArray(e))return e.map((o)=>typeof o!=="string"?o+"":o);e=e.trim();let n=0,t=null,r=null,i=null,s=[];for(let o=0;o<e.length;o++){if(t=r,r=e.charAt(o),r===" "&&!i){if(t!==" ")n++;continue}if(r===i)i=null;else if((r==="'"||r==='"')&&!i)i=r;if(!s[n])s[n]="";s[n]+=r}return s}var ye;(function(e){e.BOOLEAN="boolean",e.STRING="string",e.NUMBER="number",e.ARRAY="array"})(ye||(ye={}));var Me;class xt{constructor(e){Me=e}parse(e,n){let t=Object.assign({alias:void 0,array:void 0,boolean:void 0,config:void 0,configObjects:void 0,configuration:void 0,coerce:void 0,count:void 0,default:void 0,envPrefix:void 0,narg:void 0,normalize:void 0,string:void 0,number:void 0,__:void 0,key:void 0},n),r=Mr(e),i=typeof e==="string",s=oa(Object.assign(Object.create(null),t.alias)),o=Object.assign({"boolean-negation":!0,"camel-case-expansion":!0,"combine-arrays":!1,"dot-notation":!0,"duplicate-arguments-array":!0,"flatten-duplicate-arrays":!0,"greedy-arrays":!0,"halt-at-non-option":!1,"nargs-eats-options":!1,"negation-prefix":"no-","parse-numbers":!0,"parse-positional-numbers":!0,"populate--":!1,"set-placeholder-key":!1,"short-option-groups":!0,"strip-aliased":!1,"strip-dashed":!1,"unknown-options-as-args":!1},t.configuration),u=Object.assign(Object.create(null),t.default),c=t.configObjects||[],p=t.envPrefix,b=o["populate--"],g=b?"--":"_",D=Object.create(null),F=Object.create(null),y=t.__||Me.format,h={aliases:Object.create(null),arrays:Object.create(null),bools:Object.create(null),strings:Object.create(null),numbers:Object.create(null),counts:Object.create(null),normalize:Object.create(null),configs:Object.create(null),nargs:Object.create(null),coercions:Object.create(null),keys:[]},v=/^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/,W=new RegExp("^--"+o["negation-prefix"]+"(.+)");if([].concat(t.array||[]).filter(Boolean).forEach(function(l){let f=typeof l==="object"?l.key:l,E=Object.keys(l).map(function(m){return{boolean:"bools",string:"strings",number:"numbers"}[m]}).filter(Boolean).pop();if(E)h[E][f]=!0;h.arrays[f]=!0,h.keys.push(f)}),[].concat(t.boolean||[]).filter(Boolean).forEach(function(l){h.bools[l]=!0,h.keys.push(l)}),[].concat(t.string||[]).filter(Boolean).forEach(function(l){h.strings[l]=!0,h.keys.push(l)}),[].concat(t.number||[]).filter(Boolean).forEach(function(l){h.numbers[l]=!0,h.keys.push(l)}),[].concat(t.count||[]).filter(Boolean).forEach(function(l){h.counts[l]=!0,h.keys.push(l)}),[].concat(t.normalize||[]).filter(Boolean).forEach(function(l){h.normalize[l]=!0,h.keys.push(l)}),typeof t.narg==="object")Object.entries(t.narg).forEach(([l,f])=>{if(typeof f==="number")h.nargs[l]=f,h.keys.push(l)});if(typeof t.coerce==="object")Object.entries(t.coerce).forEach(([l,f])=>{if(typeof f==="function")h.coercions[l]=f,h.keys.push(l)});if(typeof t.config<"u"){if(Array.isArray(t.config)||typeof t.config==="string")[].concat(t.config).filter(Boolean).forEach(function(l){h.configs[l]=!0});else if(typeof t.config==="object")Object.entries(t.config).forEach(([l,f])=>{if(typeof f==="boolean"||typeof f==="function")h.configs[l]=f})}xn(t.key,s,t.default,h.arrays),Object.keys(u).forEach(function(l){(h.aliases[l]||[]).forEach(function(f){u[f]=u[l]})});let T=null;gt();let ce=[],I=Object.assign(Object.create(null),{_:[]}),Y={};for(let l=0;l<r.length;l++){let f=r[l],E=f.replace(/^-{3,}/,"---"),m,d,A,w,O,oe;if(f!=="--"&&/^-/.test(f)&&G(f))te(f);else if(E.match(/^---+(=|$)/)){te(f);continue}else if(f.match(/^--.+=/)||!o["short-option-groups"]&&f.match(/^-.+=/)){if(w=f.match(/^--?([^=]+)=([\s\S]*)$/),w!==null&&Array.isArray(w)&&w.length>=3)if(j(w[1],h.arrays))l=Pe(l,w[1],r,w[2]);else if(j(w[1],h.nargs)!==!1)l=X(l,w[1],r,w[2]);else z(w[1],w[2],!0)}else if(f.match(W)&&o["boolean-negation"]){if(w=f.match(W),w!==null&&Array.isArray(w)&&w.length>=2)d=w[1],z(d,j(d,h.arrays)?[!1]:!1)}else if(f.match(/^--.+/)||!o["short-option-groups"]&&f.match(/^-[^-]+/)){if(w=f.match(/^--?(.+)/),w!==null&&Array.isArray(w)&&w.length>=2)if(d=w[1],j(d,h.arrays))l=Pe(l,d,r);else if(j(d,h.nargs)!==!1)l=X(l,d,r);else if(O=r[l+1],O!==void 0&&(!O.match(/^-/)||O.match(v))&&!j(d,h.bools)&&!j(d,h.counts))z(d,O),l++;else if(/^(true|false)$/.test(O))z(d,O),l++;else z(d,L(d))}else if(f.match(/^-.\..+=/)){if(w=f.match(/^-([^=]+)=([\s\S]*)$/),w!==null&&Array.isArray(w)&&w.length>=3)z(w[1],w[2])}else if(f.match(/^-.\..+/)&&!f.match(v)){if(O=r[l+1],w=f.match(/^-(.\..+)/),w!==null&&Array.isArray(w)&&w.length>=2)if(d=w[1],O!==void 0&&!O.match(/^-/)&&!j(d,h.bools)&&!j(d,h.counts))z(d,O),l++;else z(d,L(d))}else if(f.match(/^-[^-]+/)&&!f.match(v)){A=f.slice(1,-1).split(""),m=!1;for(let fe=0;fe<A.length;fe++){if(O=f.slice(fe+2),A[fe+1]&&A[fe+1]==="="){if(oe=f.slice(fe+3),d=A[fe],j(d,h.arrays))l=Pe(l,d,r,oe);else if(j(d,h.nargs)!==!1)l=X(l,d,r,oe);else z(d,oe);m=!0;break}if(O==="-"){z(A[fe],O);continue}if(/[A-Za-z]/.test(A[fe])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(O)&&j(O,h.bools)===!1){z(A[fe],O),m=!0;break}if(A[fe+1]&&A[fe+1].match(/\W/)){z(A[fe],O),m=!0;break}else z(A[fe],L(A[fe]))}if(d=f.slice(-1)[0],!m&&d!=="-")if(j(d,h.arrays))l=Pe(l,d,r);else if(j(d,h.nargs)!==!1)l=X(l,d,r);else if(O=r[l+1],O!==void 0&&(!/^(-|--)[^-]/.test(O)||O.match(v))&&!j(d,h.bools)&&!j(d,h.counts))z(d,O),l++;else if(/^(true|false)$/.test(O))z(d,O),l++;else z(d,L(d))}else if(f.match(/^-[0-9]$/)&&f.match(v)&&j(f.slice(1),h.bools))d=f.slice(1),z(d,L(d));else if(f==="--"){ce=r.slice(l+1);break}else if(o["halt-at-non-option"]){ce=r.slice(l);break}else te(f)}if(ne(I,!0),ne(I,!1),_(I),V(),Ne(I,h.aliases,u,!0),H(I),o["set-placeholder-key"])re(I);if(Object.keys(h.counts).forEach(function(l){if(!U(I,l.split(".")))z(l,0)}),b&&ce.length)I[g]=[];if(ce.forEach(function(l){I[g].push(l)}),o["camel-case-expansion"]&&o["strip-dashed"])Object.keys(I).filter((l)=>l!=="--"&&l.includes("-")).forEach((l)=>{delete I[l]});if(o["strip-aliased"])[].concat(...Object.keys(s).map((l)=>s[l])).forEach((l)=>{if(o["camel-case-expansion"]&&l.includes("-"))delete I[l.split(".").map((f)=>Je(f)).join(".")];delete I[l]});function te(l){let f=C("_",l);if(typeof f==="string"||typeof f==="number")I._.push(f)}function X(l,f,E,m){let d,A=j(f,h.nargs);if(A=typeof A!=="number"||isNaN(A)?1:A,A===0){if(!se(m))T=Error(y("Argument unexpected for: %s",f));return z(f,L(f)),l}let w=se(m)?0:1;if(o["nargs-eats-options"]){if(E.length-(l+1)+w<A)T=Error(y("Not enough arguments following: %s",f));w=A}else{for(d=l+1;d<E.length;d++)if(!E[d].match(/^-[^0-9]/)||E[d].match(v)||G(E[d]))w++;else break;if(w<A)T=Error(y("Not enough arguments following: %s",f))}let O=Math.min(w,A);if(!se(m)&&O>0)z(f,m),O--;for(d=l+1;d<O+l+1;d++)z(f,E[d]);return l+O}function Pe(l,f,E,m){let d=[],A=m||E[l+1],w=j(f,h.nargs);if(j(f,h.bools)&&!/^(true|false)$/.test(A))d.push(!0);else if(se(A)||se(m)&&/^-/.test(A)&&!v.test(A)&&!G(A)){if(u[f]!==void 0){let O=u[f];d=Array.isArray(O)?O:[O]}}else{if(!se(m))d.push(P(f,m,!0));for(let O=l+1;O<E.length;O++){if(!o["greedy-arrays"]&&d.length>0||w&&typeof w==="number"&&d.length>=w)break;if(A=E[O],/^-/.test(A)&&!v.test(A)&&!G(A))break;l=O,d.push(P(f,A,i))}}if(typeof w==="number"&&(w&&d.length<w||isNaN(w)&&d.length===0))T=Error(y("Not enough arguments following: %s",f));return z(f,d),l}function z(l,f,E=i){if(/-/.test(l)&&o["camel-case-expansion"]){let A=l.split(".").map(function(w){return Je(w)}).join(".");wn(l,A)}let m=P(l,f,E),d=l.split(".");if(ve(I,d,m),h.aliases[l])h.aliases[l].forEach(function(A){let w=A.split(".");ve(I,w,m)});if(d.length>1&&o["dot-notation"])(h.aliases[d[0]]||[]).forEach(function(A){let w=A.split("."),O=[].concat(d);if(O.shift(),w=w.concat(O),!(h.aliases[l]||[]).includes(w.join(".")))ve(I,w,m)});if(j(l,h.normalize)&&!j(l,h.arrays))[l].concat(h.aliases[l]||[]).forEach(function(w){Object.defineProperty(Y,w,{enumerable:!0,get(){return f},set(O){f=typeof O==="string"?Me.normalize(O):O}})})}function wn(l,f){if(!(h.aliases[l]&&h.aliases[l].length))h.aliases[l]=[f],D[f]=!0;if(!(h.aliases[f]&&h.aliases[f].length))wn(f,l)}function P(l,f,E){if(E)f=aa(f);if(j(l,h.bools)||j(l,h.counts)){if(typeof f==="string")f=f==="true"}let m=Array.isArray(f)?f.map(function(d){return C(l,d)}):C(l,f);if(j(l,h.counts)&&(se(m)||typeof m==="boolean"))m=wt();if(j(l,h.normalize)&&j(l,h.arrays))if(Array.isArray(f))m=f.map((d)=>Me.normalize(d));else m=Me.normalize(f);return m}function C(l,f){if(!o["parse-positional-numbers"]&&l==="_")return f;if(!j(l,h.strings)&&!j(l,h.bools)&&!Array.isArray(f)){if(Ln(f)&&o["parse-numbers"]&&Number.isSafeInteger(Math.floor(parseFloat(`${f}`)))||!se(f)&&j(l,h.numbers))f=Number(f)}return f}function _(l){let f=Object.create(null);Ne(f,h.aliases,u),Object.keys(h.configs).forEach(function(E){let m=l[E]||f[E];if(m)try{let d=null,A=Me.resolve(Me.cwd(),m),w=h.configs[E];if(typeof w==="function"){try{d=w(A)}catch(O){d=O}if(d instanceof Error){T=d;return}}else d=Me.require(A);N(d)}catch(d){if(d.name==="PermissionDenied")T=d;else if(l[E])T=Error(y("Invalid JSON config file: %s",m))}})}function N(l,f){Object.keys(l).forEach(function(E){let m=l[E],d=f?f+"."+E:E;if(typeof m==="object"&&m!==null&&!Array.isArray(m)&&o["dot-notation"])N(m,d);else if(!U(I,d.split("."))||j(d,h.arrays)&&o["combine-arrays"])z(d,m)})}function V(){if(typeof c<"u")c.forEach(function(l){N(l)})}function ne(l,f){if(typeof p>"u")return;let E=typeof p==="string"?p:"",m=Me.env();Object.keys(m).forEach(function(d){if(E===""||d.lastIndexOf(E,0)===0){let A=d.split("__").map(function(w,O){if(O===0)w=w.substring(E.length);return Je(w)});if((f&&h.configs[A.join(".")]||!f)&&!U(l,A))z(A.join("."),m[d])}})}function H(l){let f,E=new Set;Object.keys(l).forEach(function(m){if(!E.has(m)){if(f=j(m,h.coercions),typeof f==="function")try{let d=C(m,f(l[m]));[].concat(h.aliases[m]||[],m).forEach((A)=>{E.add(A),l[A]=d})}catch(d){T=d}}})}function re(l){return h.keys.forEach((f)=>{if(~f.indexOf("."))return;if(typeof l[f]>"u")l[f]=void 0}),l}function Ne(l,f,E,m=!1){Object.keys(E).forEach(function(d){if(!U(l,d.split("."))){if(ve(l,d.split("."),E[d]),m)F[d]=!0;(f[d]||[]).forEach(function(A){if(U(l,A.split(".")))return;ve(l,A.split("."),E[d])})}})}function U(l,f){let E=l;if(!o["dot-notation"])f=[f.join(".")];f.slice(0,-1).forEach(function(d){E=E[d]||{}});let m=f[f.length-1];if(typeof E!=="object")return!1;else return m in E}function ve(l,f,E){let m=l;if(!o["dot-notation"])f=[f.join(".")];f.slice(0,-1).forEach(function(oe){if(oe=Nr(oe),typeof m==="object"&&m[oe]===void 0)m[oe]={};if(typeof m[oe]!=="object"||Array.isArray(m[oe])){if(Array.isArray(m[oe]))m[oe].push({});else m[oe]=[m[oe],{}];m=m[oe][m[oe].length-1]}else m=m[oe]});let d=Nr(f[f.length-1]),A=j(f.join("."),h.arrays),w=Array.isArray(E),O=o["duplicate-arguments-array"];if(!O&&j(d,h.nargs)){if(O=!0,!se(m[d])&&h.nargs[d]===1||Array.isArray(m[d])&&m[d].length===h.nargs[d])m[d]=void 0}if(E===wt())m[d]=wt(m[d]);else if(Array.isArray(m[d]))if(O&&A&&w)m[d]=o["flatten-duplicate-arrays"]?m[d].concat(E):(Array.isArray(m[d][0])?m[d]:[m[d]]).concat([E]);else if(!O&&Boolean(A)===Boolean(w))m[d]=E;else m[d]=m[d].concat([E]);else if(m[d]===void 0&&A)m[d]=w?E:[E];else if(O&&!(m[d]===void 0||j(d,h.counts)||j(d,h.bools)))m[d]=[m[d],E];else m[d]=E}function xn(...l){l.forEach(function(f){Object.keys(f||{}).forEach(function(E){if(h.aliases[E])return;h.aliases[E]=[].concat(s[E]||[]),h.aliases[E].concat(E).forEach(function(m){if(/-/.test(m)&&o["camel-case-expansion"]){let d=Je(m);if(d!==E&&h.aliases[E].indexOf(d)===-1)h.aliases[E].push(d),D[d]=!0}}),h.aliases[E].concat(E).forEach(function(m){if(m.length>1&&/[A-Z]/.test(m)&&o["camel-case-expansion"]){let d=Tn(m,"-");if(d!==E&&h.aliases[E].indexOf(d)===-1)h.aliases[E].push(d),D[d]=!0}}),h.aliases[E].forEach(function(m){h.aliases[m]=[E].concat(h.aliases[E].filter(function(d){return m!==d}))})})})}function j(l,f){let E=[].concat(h.aliases[l]||[],l),m=Object.keys(f),d=E.find((A)=>m.includes(A));return d?f[d]:!1}function fn(l){let f=Object.keys(h);return[].concat(f.map((m)=>h[m])).some(function(m){return Array.isArray(m)?m.includes(l):m[l]})}function ar(l,...f){return[].concat(...f).some(function(m){let d=l.match(m);return d&&fn(d[1])})}function k(l){if(l.match(v)||!l.match(/^-[^-]+/))return!1;let f=!0,E,m=l.slice(1).split("");for(let d=0;d<m.length;d++){if(E=l.slice(d+2),!fn(m[d])){f=!1;break}if(m[d+1]&&m[d+1]==="="||E==="-"||/[A-Za-z]/.test(m[d])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(E)||m[d+1]&&m[d+1].match(/\W/))break}return f}function G(l){return o["unknown-options-as-args"]&&ie(l)}function ie(l){if(l=l.replace(/^-{3,}/,"--"),l.match(v))return!1;if(k(l))return!1;return!ar(l,/^-+([^=]+?)=[\s\S]*$/,W,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}function L(l){if(!j(l,h.bools)&&!j(l,h.counts)&&`${l}`in u)return u[l];else return ue(Z(l))}function ue(l){return{[ye.BOOLEAN]:!0,[ye.STRING]:"",[ye.NUMBER]:void 0,[ye.ARRAY]:[]}[l]}function Z(l){let f=ye.BOOLEAN;if(j(l,h.strings))f=ye.STRING;else if(j(l,h.numbers))f=ye.NUMBER;else if(j(l,h.bools))f=ye.BOOLEAN;else if(j(l,h.arrays))f=ye.ARRAY;return f}function se(l){return l===void 0}function gt(){Object.keys(h.counts).find((l)=>{if(j(l,h.arrays))return T=Error(y("Invalid configuration: %s, opts.count excludes opts.array.",l)),!0;else if(j(l,h.nargs))return T=Error(y("Invalid configuration: %s, opts.count excludes opts.narg.",l)),!0;return!1})}return{aliases:Object.assign({},h.aliases),argv:Object.assign(Y,I),configuration:o,defaulted:Object.assign({},F),error:T,newAliases:Object.assign({},D)}}}function oa(e){let n=[],t=Object.create(null),r=!0;Object.keys(e).forEach(function(i){n.push([].concat(e[i],i))});while(r){r=!1;for(let i=0;i<n.length;i++)for(let s=i+1;s<n.length;s++)if(n[i].filter(function(u){return n[s].indexOf(u)!==-1}).length){n[i]=n[i].concat(n[s]),n.splice(s,1),r=!0;break}}return n.forEach(function(i){i=i.filter(function(o,u,c){return c.indexOf(o)===u});let s=i.pop();if(s!==void 0&&typeof s==="string")t[s]=i}),t}function wt(e){return e!==void 0?e+1:1}function Nr(e){if(e==="__proto__")return"___proto___";return e}function aa(e){return typeof e==="string"&&(e[0]==="'"||e[0]==='"')&&e[e.length-1]===e[0]?e.substring(1,e.length-1):e}import{readFileSync as da}from"fs";import{createRequire as Rr}from"module";var St,At,Pt,Ir=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):20,Tr=(At=(St=process===null||process===void 0?void 0:process.versions)===null||St===void 0?void 0:St.node)!==null&&At!==void 0?At:(Pt=process===null||process===void 0?void 0:process.version)===null||Pt===void 0?void 0:Pt.slice(1);if(Tr){if(Number(Tr.match(/^([^.]+)/)[1])<Ir)throw Error(`yargs parser supports a minimum Node.js version of ${Ir}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`)}var fa=process?process.env:{},Lr=Rr?Rr(import.meta.url):void 0,Wr=new xt({cwd:process.cwd,env:()=>fa,format:ua,normalize:la,resolve:ca,require:(e)=>{if(typeof Lr<"u")return Lr(e);else if(e.match(/\.json$/))return JSON.parse(da(e,"utf8"));else throw Error("only .json config files are supported in ESM")}}),Sn=function(n,t){return Wr.parse(n.slice(),t).argv};Sn.detailed=function(e,n){return Wr.parse(e.slice(),n)};Sn.camelCase=Je;Sn.decamelize=Tn;Sn.looksLikeNumber=Ln;var Hr=Sn;import{basename as Ra,dirname as Ia,extname as Ta,relative as La,resolve as ei,join as Wa}from"path";function ha(){if(Da())return 0;return 1}function Da(){return ga()&&!process.defaultApp}function ga(){return!!process.versions.electron}function Vr(){return process.argv[ha()]}var pa=new Intl.Segmenter,zr=/^(?:\p{Default_Ignorable_Code_Point}|\p{Control}|\p{Format}|\p{Nonspacing_Mark}|\p{Enclosing_Mark}|\p{Surrogate})+$/v,ma=/^[\p{Default_Ignorable_Code_Point}\p{Control}\p{Format}\p{Nonspacing_Mark}\p{Enclosing_Mark}\p{Surrogate}]+/v,Fa=/\p{Spacing_Mark}/v,ya=/^\p{RGI_Emoji}$/v,ba=/^[\d#*]\u20E3$/,Ea=/\p{Extended_Pictographic}/gu;function Ca(e){if(e.length>50)return!1;if(ba.test(e))return!0;if(e.includes("\u200D")){let n=e.match(Ea);return n!==null&&n.length>=2}return!1}function wa(e){return e.replace(ma,"")}function xa(e){return zr.test(e)}function Gr(e){return e>=4352&&e<=4447||e>=43360&&e<=43388}function Ur(e){return e>=4448&&e<=4519||e>=55216&&e<=55238}function Yr(e){return e>=4520&&e<=4607||e>=55243&&e<=55291}function Sa(e){return Gr(e)||Ur(e)||Yr(e)}function Aa(e,n){let t=[];for(let i of e){if(zr.test(i))continue;t.push(i.codePointAt(0))}if(t.length===0)return;let r=0;for(let i=0;i<t.length;i++){let s=t[i];if(!Sa(s)){if(r===0)return;for(let o=i;o<t.length;o++)r+=Ye(t[o],n);return r}if(Gr(s)&&Ur(t[i+1])){r+=2,i+=Yr(t[i+2])?2:1;continue}r+=Ye(s,n)}return r}function Pa(e,n){let t=0,r=!0;for(let i of e){if(r){r=!1;continue}if(Fa.test(i)||i>="\uFF00"&&i<="\uFFEF")t+=Ye(i.codePointAt(0),n)}return t}function _t(e,n={}){if(typeof e!=="string"||e.length===0)return 0;let{ambiguousIsNarrow:t=!0,countAnsiEscapeCodes:r=!1}=n,i=e;if(!r&&(i.includes("\x1B")||i.includes("\x9B")))i=je(i);if(i.length===0)return 0;if(/^[\u0020-\u007E]*$/.test(i))return i.length;let s=0,o={ambiguousAsWide:!t};for(let{segment:u}of pa.segment(i)){if(xa(u))continue;if(ya.test(u)||Ca(u)){s+=2;continue}let c=wa(u),p=Aa(c,o);if(p!==void 0){s+=p;continue}let b=c.codePointAt(0);s+=Ye(b,o),s+=Pa(c,o)}return s}import{readFileSync as _a,statSync as Ba,writeFile as Oa}from"fs";import{format as $a}from"util";import{resolve as va}from"path";var Jr={fs:{readFileSync:_a,writeFile:Oa},format:$a,resolve:va,exists:(e)=>{try{return Ba(e).isFile()}catch(n){return!1}}};var xe;class Kr{constructor(e){e=e||{},this.directory=e.directory||"./locales",this.updateFiles=typeof e.updateFiles==="boolean"?e.updateFiles:!0,this.locale=e.locale||"en",this.fallbackToLanguage=typeof e.fallbackToLanguage==="boolean"?e.fallbackToLanguage:!0,this.cache=Object.create(null),this.writeQueue=[]}__(...e){if(typeof arguments[0]!=="string")return this._taggedLiteral(arguments[0],...arguments);let n=e.shift(),t=function(){};if(typeof e[e.length-1]==="function")t=e.pop();if(t=t||function(){},!this.cache[this.locale])this._readLocaleFile();if(!this.cache[this.locale][n]&&this.updateFiles)this.cache[this.locale][n]=n,this._enqueueWrite({directory:this.directory,locale:this.locale,cb:t});else t();return xe.format.apply(xe.format,[this.cache[this.locale][n]||n].concat(e))}__n(){let e=Array.prototype.slice.call(arguments),n=e.shift(),t=e.shift(),r=e.shift(),i=function(){};if(typeof e[e.length-1]==="function")i=e.pop();if(!this.cache[this.locale])this._readLocaleFile();let s=r===1?n:t;if(this.cache[this.locale][n])s=this.cache[this.locale][n][r===1?"one":"other"];if(!this.cache[this.locale][n]&&this.updateFiles)this.cache[this.locale][n]={one:n,other:t},this._enqueueWrite({directory:this.directory,locale:this.locale,cb:i});else i();let o=[s];if(~s.indexOf("%d"))o.push(r);return xe.format.apply(xe.format,o.concat(e))}setLocale(e){this.locale=e}getLocale(){return this.locale}updateLocale(e){if(!this.cache[this.locale])this._readLocaleFile();for(let n in e)if(Object.prototype.hasOwnProperty.call(e,n))this.cache[this.locale][n]=e[n]}_taggedLiteral(e,...n){let t="";return e.forEach(function(r,i){let s=n[i+1];if(t+=r,typeof s<"u")t+="%s"}),this.__.apply(this,[t].concat([].slice.call(n,1)))}_enqueueWrite(e){if(this.writeQueue.push(e),this.writeQueue.length===1)this._processWriteQueue()}_processWriteQueue(){let e=this,n=this.writeQueue[0],t=n.directory,r=n.locale,i=n.cb,s=this._resolveLocaleFile(t,r),o=JSON.stringify(this.cache[r],null,2);xe.fs.writeFile(s,o,"utf-8",function(u){if(e.writeQueue.shift(),e.writeQueue.length>0)e._processWriteQueue();i(u)})}_readLocaleFile(){let e={},n=this._resolveLocaleFile(this.directory,this.locale);try{if(xe.fs.readFileSync)e=JSON.parse(xe.fs.readFileSync(n,"utf-8"))}catch(t){if(t instanceof SyntaxError)t.message="syntax error in "+n;if(t.code==="ENOENT")e={};else throw t}this.cache[this.locale]=e}_resolveLocaleFile(e,n){let t=xe.resolve(e,"./",n+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(t)&&~n.lastIndexOf("_")){let r=xe.resolve(e,"./",n.split("_")[0]+".json");if(this._fileExistsSync(r))t=r}return t}_fileExistsSync(e){return xe.exists(e)}}function qr(e,n){xe=n;let t=new Kr(e);return{__:t.__.bind(t),__n:t.__n.bind(t),setLocale:t.setLocale.bind(t),getLocale:t.getLocale.bind(t),updateLocale:t.updateLocale.bind(t),locale:t.locale}}var ja=(e)=>qr(e,Jr),Xr=ja;var ti=Mo(Qr(),1);import{createRequire as Ha}from"module";import{readFileSync as Va,readdirSync as za}from"fs";var Bt=ni(import.meta.url),Ga=Bt.substring(0,Bt.lastIndexOf("node_modules")),Ua=Ha(import.meta.url),ri={assert:{notStrictEqual:ka,strictEqual:Ma},cliui:Et,findUp:Ct,getEnv:(e)=>process.env[e],inspect:Na,getProcessArgvBin:Vr,mainFilename:Ga||process.cwd(),Parser:Hr,path:{basename:Ra,dirname:Ia,extname:Ta,relative:La,resolve:ei,join:Wa},process:{argv:()=>process.argv,cwd:process.cwd,emitWarning:(e,n)=>process.emitWarning(e,n),execPath:()=>process.execPath,exit:(e)=>{process.exit(e)},nextTick:process.nextTick,stdColumns:typeof process.stdout.columns<"u"?process.stdout.columns:null},readFileSync:Va,readdirSync:za,require:Ua,getCallerFile:()=>{let e=ti.default(3);return e.match(/^file:\/\//)?ni(e):e},stringWidth:_t,y18n:Xr({directory:ei(Bt,"../../../locales"),updateFiles:!1})};function he(e,n,t,r){t.assert.notStrictEqual(e,n,r)}function Ot(e,n){n.assert.strictEqual(typeof e,"string")}function hn(e){return Object.keys(e)}function J(e){return!!e&&!!e.then&&typeof e.then==="function"}class Q extends Error{constructor(e){super(e||"yargs error");if(this.name="YError",Error.captureStackTrace)Error.captureStackTrace(this,Q)}}function Re(e){let t=e.replace(/\s{2,}/g," ").split(/\s+(?![^[]*]|[^<]*>)/),r=/\.*[\][<>]/g,i=t.shift();if(!i)throw Error(`No command found in: ${e}`);let s={cmd:i.replace(r,""),demanded:[],optional:[]};return t.forEach((o,u)=>{let c=!1;if(o=o.replace(/\s/g,""),/\.+[\]>]/.test(o)&&u===t.length-1)c=!0;if(/^\[/.test(o))s.optional.push({cmd:o.replace(r,"").split("|"),variadic:c});else s.demanded.push({cmd:o.replace(r,"").split("|"),variadic:c})}),s}var Ya=["first","second","third","fourth","fifth","sixth"];function x(e,n,t){function r(){return typeof e==="object"?[{demanded:[],optional:[]},e,n]:[Re(`cmd ${e}`),n,t]}try{let i=0,[s,o,u]=r(),c=[].slice.call(o);while(c.length&&c[c.length-1]===void 0)c.pop();let p=u||c.length;if(p<s.demanded.length)throw new Q(`Not enough arguments provided. Expected ${s.demanded.length} but received ${c.length}.`);let b=s.demanded.length+s.optional.length;if(p>b)throw new Q(`Too many arguments provided. Expected max ${b} but received ${p}.`);s.demanded.forEach((g)=>{let D=c.shift(),F=ii(D);if(g.cmd.filter((h)=>h===F||h==="*").length===0)si(F,g.cmd,i);i+=1}),s.optional.forEach((g)=>{if(c.length===0)return;let D=c.shift(),F=ii(D);if(g.cmd.filter((h)=>h===F||h==="*").length===0)si(F,g.cmd,i);i+=1})}catch(i){console.warn(i.stack)}}function ii(e){if(Array.isArray(e))return"array";else if(e===null)return"null";return typeof e}function si(e,n,t){throw new Q(`Invalid ${Ya[t]||"manyith"} argument. Expected ${n.join(" or ")} but received ${e}.`)}class $t{constructor(e){this.globalMiddleware=[],this.frozens=[],this.yargs=e}addMiddleware(e,n,t=!0,r=!1){if(x("<array|function> [boolean] [boolean] [boolean]",[e,n,t],arguments.length),Array.isArray(e)){for(let i=0;i<e.length;i++){if(typeof e[i]!=="function")throw Error("middleware must be a function");let s=e[i];s.applyBeforeValidation=n,s.global=t}Array.prototype.push.apply(this.globalMiddleware,e)}else if(typeof e==="function"){let i=e;i.applyBeforeValidation=n,i.global=t,i.mutates=r,this.globalMiddleware.push(e)}return this.yargs}addCoerceMiddleware(e,n){let t=this.yargs.getAliases();return this.globalMiddleware=this.globalMiddleware.filter((r)=>{let i=[...t[n]||[],n];if(!r.option)return!0;else return!i.includes(r.option)}),e.option=n,this.addMiddleware(e,!0,!0,!0)}getMiddleware(){return this.globalMiddleware}freeze(){this.frozens.push([...this.globalMiddleware])}unfreeze(){let e=this.frozens.pop();if(e!==void 0)this.globalMiddleware=e}reset(){this.globalMiddleware=this.globalMiddleware.filter((e)=>e.global)}}function oi(e){if(!e)return[];return e.map((n)=>(n.applyBeforeValidation=!1,n))}function Ke(e,n,t,r){return t.reduce((i,s)=>{if(s.applyBeforeValidation!==r)return i;if(s.mutates){if(s.applied)return i;s.applied=!0}if(J(i))return i.then((o)=>Promise.all([o,s(o,n)])).then(([o,u])=>Object.assign(o,u));else{let o=s(i,n);return J(o)?o.then((u)=>Object.assign(i,u)):Object.assign(i,o)}},e)}function qe(e,n,t=(r)=>{throw r}){try{let r=Ja(e)?e():e;return J(r)?r.then((i)=>n(i)):n(r)}catch(r){return t(r)}}function Ja(e){return typeof e==="function"}var Dn=/(^\*)|(^\$0)/;class ui{constructor(e,n,t,r){this.requireCache=new Set,this.handlers={},this.aliasMap={},this.frozens=[],this.shim=r,this.usage=e,this.globalMiddleware=t,this.validation=n}addDirectory(e,n,t,r){r=r||{},this.requireCache.add(t);let i=this.shim.path.resolve(this.shim.path.dirname(t),e),s=this.shim.readdirSync(i,{recursive:r.recurse?!0:!1});if(!Array.isArray(r.extensions))r.extensions=["js"];let o=typeof r.visit==="function"?r.visit:(u)=>u;for(let u of s){let c=u.toString();if(r.exclude){let b=!1;if(typeof r.exclude==="function")b=r.exclude(c);else b=r.exclude.test(c);if(b)continue}if(r.include){let b=!1;if(typeof r.include==="function")b=r.include(c);else b=r.include.test(c);if(!b)continue}let p=!1;for(let b of r.extensions)if(c.endsWith(b))p=!0;if(p){let b=this.shim.path.join(i,c),g=n(b),D=Object.create(null,Object.getOwnPropertyDescriptors({...g}));if(o(D,b,c)){if(this.requireCache.has(b))continue;else this.requireCache.add(b);if(!D.command)D.command=this.shim.path.basename(b,this.shim.path.extname(b));this.addHandler(D)}}}}addHandler(e,n,t,r,i,s){let o=[],u=oi(i);if(r=r||(()=>{}),Array.isArray(e))if(Ka(e))[e,...o]=e;else for(let c of e)this.addHandler(c);else if(Xa(e)){let c=Array.isArray(e.command)||typeof e.command==="string"?e.command:null;if(c===null)throw Error(`No command name given for module: ${this.shim.inspect(e)}`);if(e.aliases)c=[].concat(c).concat(e.aliases);this.addHandler(c,this.extractDesc(e),e.builder,e.handler,e.middlewares,e.deprecated);return}else if(ai(t)){this.addHandler([e].concat(o),n,t.builder,t.handler,t.middlewares,t.deprecated);return}if(typeof e==="string"){let c=Re(e);o=o.map((g)=>Re(g).cmd);let p=!1,b=[c.cmd].concat(o).filter((g)=>{if(Dn.test(g))return p=!0,!1;return!0});if(b.length===0&&p)b.push("$0");if(p)c.cmd=b[0],o=b.slice(1),e=e.replace(Dn,c.cmd);if(o.forEach((g)=>{this.aliasMap[g]=c.cmd}),n!==!1)this.usage.command(e,n,p,o,s);if(this.handlers[c.cmd]={original:e,description:n,handler:r,builder:t||{},middlewares:u,deprecated:s,demanded:c.demanded,optional:c.optional},p)this.defaultCommand=this.handlers[c.cmd]}}getCommandHandlers(){return this.handlers}getCommands(){return Object.keys(this.handlers).concat(Object.keys(this.aliasMap))}hasDefaultCommand(){return!!this.defaultCommand}runCommand(e,n,t,r,i,s){let o=this.handlers[e]||this.handlers[this.aliasMap[e]]||this.defaultCommand,u=n.getInternalMethods().getContext(),c=u.commands.slice(),p=!e;if(e)u.commands.push(e),u.fullCommands.push(o.original);let b=this.applyBuilderUpdateUsageAndParse(p,o,n,t.aliases,c,r,i,s);return J(b)?b.then((g)=>this.applyMiddlewareAndGetResult(p,o,g.innerArgv,u,i,g.aliases,n)):this.applyMiddlewareAndGetResult(p,o,b.innerArgv,u,i,b.aliases,n)}applyBuilderUpdateUsageAndParse(e,n,t,r,i,s,o,u){let c=n.builder,p=t;if(Wn(c)){t.getInternalMethods().getUsageInstance().freeze();let b=c(t.getInternalMethods().reset(r),u);if(J(b))return b.then((g)=>(p=ci(g)?g:t,this.parseAndUpdateUsage(e,n,p,i,s,o)))}else if(qa(c))t.getInternalMethods().getUsageInstance().freeze(),p=t.getInternalMethods().reset(r),Object.keys(n.builder).forEach((b)=>{p.option(b,c[b])});return this.parseAndUpdateUsage(e,n,p,i,s,o)}parseAndUpdateUsage(e,n,t,r,i,s){if(e)t.getInternalMethods().getUsageInstance().unfreeze(!0);if(this.shouldUpdateUsage(t))t.getInternalMethods().getUsageInstance().usage(this.usageFromParentCommandsCommandHandler(r,n),n.description);let o=t.getInternalMethods().runYargsParserAndExecuteCommands(null,void 0,!0,i,s);return J(o)?o.then((u)=>({aliases:t.parsed.aliases,innerArgv:u})):{aliases:t.parsed.aliases,innerArgv:o}}shouldUpdateUsage(e){return!e.getInternalMethods().getUsageInstance().getUsageDisabled()&&e.getInternalMethods().getUsageInstance().getUsage().length===0}usageFromParentCommandsCommandHandler(e,n){let t=Dn.test(n.original)?n.original.replace(Dn,"").trim():n.original,r=e.filter((i)=>!Dn.test(i));return r.push(t),`$0 ${r.join(" ")}`}handleValidationAndGetResult(e,n,t,r,i,s,o,u){if(!s.getInternalMethods().getHasOutput()){let c=s.getInternalMethods().runValidation(i,u,s.parsed.error,e);t=qe(t,(p)=>(c(p),p))}if(n.handler&&!s.getInternalMethods().getHasOutput()){s.getInternalMethods().setHasOutput();let c=!!s.getOptions().configuration["populate--"];if(s.getInternalMethods().postProcess(t,c,!1,!1),t=Ke(t,s,o,!1),t=qe(t,(p)=>{let b=n.handler(p);return J(b)?b.then(()=>p):p}),!e)s.getInternalMethods().getUsageInstance().cacheHelpMessage();if(J(t)&&!s.getInternalMethods().hasParseCallback())t.catch((p)=>{try{s.getInternalMethods().getUsageInstance().fail(null,p)}catch(b){}})}if(!e)r.commands.pop(),r.fullCommands.pop();return t}applyMiddlewareAndGetResult(e,n,t,r,i,s,o){let u={};if(i)return t;if(!o.getInternalMethods().getHasOutput())u=this.populatePositionals(n,t,r,o);let c=this.globalMiddleware.getMiddleware().slice(0).concat(n.middlewares),p=Ke(t,o,c,!0);return J(p)?p.then((b)=>this.handleValidationAndGetResult(e,n,b,r,s,o,c,u)):this.handleValidationAndGetResult(e,n,p,r,s,o,c,u)}populatePositionals(e,n,t,r){n._=n._.slice(t.commands.length);let i=e.demanded.slice(0),s=e.optional.slice(0),o={};this.validation.positionalCount(i.length,n._.length);while(i.length){let u=i.shift();this.populatePositional(u,n,o)}while(s.length){let u=s.shift();this.populatePositional(u,n,o)}return n._=t.commands.concat(n._.map((u)=>""+u)),this.postProcessPositionals(n,o,this.cmdToParseOptions(e.original),r),o}populatePositional(e,n,t){let r=e.cmd[0];if(e.variadic)t[r]=n._.splice(0).map(String);else if(n._.length)t[r]=[String(n._.shift())]}cmdToParseOptions(e){let n={array:[],default:{},alias:{},demand:{}},t=Re(e);return t.demanded.forEach((r)=>{let[i,...s]=r.cmd;if(r.variadic)n.array.push(i),n.default[i]=[];n.alias[i]=s,n.demand[i]=!0}),t.optional.forEach((r)=>{let[i,...s]=r.cmd;if(r.variadic)n.array.push(i),n.default[i]=[];n.alias[i]=s}),n}postProcessPositionals(e,n,t,r){let i=Object.assign({},r.getOptions());i.default=Object.assign(t.default,i.default);for(let c of Object.keys(t.alias))i.alias[c]=(i.alias[c]||[]).concat(t.alias[c]);i.array=i.array.concat(t.array),i.config={};let s=[];if(Object.keys(n).forEach((c)=>{n[c].map((p)=>{if(i.configuration["unknown-options-as-args"])i.key[c]=!0;s.push(`--${c}`),s.push(p)})}),!s.length)return;let o=Object.assign({},i.configuration,{"populate--":!1}),u=this.shim.Parser.detailed(s,Object.assign({},i,{configuration:o}));if(u.error)r.getInternalMethods().getUsageInstance().fail(u.error.message,u.error);else{let c=Object.keys(n);Object.keys(n).forEach((p)=>{c.push(...u.aliases[p])}),Object.keys(u.argv).forEach((p)=>{if(c.includes(p)){if(!n[p])n[p]=u.argv[p];if(!this.isInConfigs(r,p)&&!this.isDefaulted(r,p)&&Object.prototype.hasOwnProperty.call(e,p)&&Object.prototype.hasOwnProperty.call(u.argv,p)&&(Array.isArray(e[p])||Array.isArray(u.argv[p])))e[p]=[].concat(e[p],u.argv[p]);else e[p]=u.argv[p]}})}}isDefaulted(e,n){let{default:t}=e.getOptions();return Object.prototype.hasOwnProperty.call(t,n)||Object.prototype.hasOwnProperty.call(t,this.shim.Parser.camelCase(n))}isInConfigs(e,n){let{configObjects:t}=e.getOptions();return t.some((r)=>Object.prototype.hasOwnProperty.call(r,n))||t.some((r)=>Object.prototype.hasOwnProperty.call(r,this.shim.Parser.camelCase(n)))}runDefaultBuilderOn(e){if(!this.defaultCommand)return;if(this.shouldUpdateUsage(e)){let t=Dn.test(this.defaultCommand.original)?this.defaultCommand.original:this.defaultCommand.original.replace(/^[^[\]<>]*/,"$0 ");e.getInternalMethods().getUsageInstance().usage(t,this.defaultCommand.description)}let n=this.defaultCommand.builder;if(Wn(n))return n(e,!0);else if(!ai(n))Object.keys(n).forEach((t)=>{e.option(t,n[t])});return}extractDesc({describe:e,description:n,desc:t}){for(let r of[e,n,t]){if(typeof r==="string"||r===!1)return r;he(r,!0,this.shim)}return!1}freeze(){this.frozens.push({handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand})}unfreeze(){let e=this.frozens.pop();he(e,void 0,this.shim),{handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand}=e}reset(){return this.handlers={},this.aliasMap={},this.defaultCommand=void 0,this.requireCache=new Set,this}}function li(e,n,t,r){return new ui(e,n,t,r)}function ai(e){return typeof e==="object"&&!!e.builder&&typeof e.handler==="function"}function Ka(e){return e.every((n)=>typeof n==="string")}function Wn(e){return typeof e==="function"}function qa(e){return typeof e==="object"}function Xa(e){return typeof e==="object"&&!Array.isArray(e)}function Ie(e={},n=()=>!0){let t={};return hn(e).forEach((r)=>{if(n(r,e[r]))t[r]=e[r]}),t}function Te(e){if(typeof process>"u")return;[process.stdout,process.stderr].forEach((n)=>{let t=n;if(t._handle&&t.isTTY&&typeof t._handle.setBlocking==="function")t._handle.setBlocking(e)})}function Za(e){return typeof e==="boolean"}function fi(e,n){let t=n.y18n.__,r={},i=[];r.failFn=function(C){i.push(C)};let s=null,o=null,u=!0;r.showHelpOnFail=function(C=!0,_){let[N,V]=typeof C==="string"?[!0,C]:[C,_];if(e.getInternalMethods().isGlobalContext())o=V;return s=V,u=N,r};let c=!1;r.fail=function(C,_){let N=e.getInternalMethods().getLoggerInstance();if(i.length)for(let V=i.length-1;V>=0;--V){let ne=i[V];if(Za(ne)){if(_)throw _;else if(C)throw Error(C)}else ne(C,_,r)}else{if(e.getExitProcess())Te(!0);if(!c){if(c=!0,u)e.showHelp("error"),N.error();if(C||_)N.error(C||_);let V=s||o;if(V){if(C||_)N.error("");N.error(V)}}if(_=_||new Q(C),e.getExitProcess())return e.exit(1);else if(e.getInternalMethods().hasParseCallback())return e.exit(1,_);else throw _}};let p=[],b=!1;r.usage=(P,C)=>{if(P===null)return b=!0,p=[],r;return b=!1,p.push([P,C||""]),r},r.getUsage=()=>p,r.getUsageDisabled=()=>b,r.getPositionalGroupName=()=>t("Positionals:");let g=[];r.example=(P,C)=>{g.push([P,C||""])};let D=[];r.command=function(C,_,N,V,ne=!1){if(N)D=D.map((H)=>(H[2]=!1,H));D.push([C,_||"",N,V,ne])},r.getCommands=()=>D;let F={};r.describe=function(C,_){if(Array.isArray(C))C.forEach((N)=>{r.describe(N,_)});else if(typeof C==="object")Object.keys(C).forEach((N)=>{r.describe(N,C[N])});else F[C]=_},r.getDescriptions=()=>F;let y=[];r.epilog=(P)=>{y.push(P)};let h=!1,v;r.wrap=(P)=>{h=!0,v=P},r.getWrap=()=>{if(n.getEnv("YARGS_DISABLE_WRAP"))return null;if(!h)v=Pe(),h=!0;return v};let W="__yargsString__:";r.deferY18nLookup=(P)=>W+P,r.help=function(){if(I)return I;ce();let C=e.customScriptName?e.$0:n.path.basename(e.$0),_=e.getDemandedOptions(),N=e.getDemandedCommands(),V=e.getDeprecatedOptions(),ne=e.getGroups(),H=e.getOptions(),re=[];re=re.concat(Object.keys(F)),re=re.concat(Object.keys(_)),re=re.concat(Object.keys(N)),re=re.concat(Object.keys(H.default)),re=re.filter(te),re=Object.keys(re.reduce((k,G)=>{if(G!=="_")k[G]=!0;return k},{}));let Ne=r.getWrap(),U=n.cliui({width:Ne,wrap:!!Ne});if(!b){if(p.length)p.forEach((k)=>{if(U.div({text:`${k[0].replace(/\$0/g,C)}`}),k[1])U.div({text:`${k[1]}`,padding:[1,0,0,0]})}),U.div();else if(D.length){let k=null;if(N._)k=`${C} <${t("command")}>
15
+ `;else k=`${C} [${t("command")}]
16
+ `;U.div(`${k}`)}}if(D.length>1||D.length===1&&!D[0][2]){U.div(t("Commands:"));let k=e.getInternalMethods().getContext(),G=k.commands.length?`${k.commands.join(" ")} `:"";if(e.getInternalMethods().getParserConfiguration()["sort-commands"]===!0)D=D.sort((L,ue)=>L[0].localeCompare(ue[0]));let ie=C?`${C} `:"";D.forEach((L)=>{let ue=`${ie}${G}${L[0].replace(/^\$0 ?/,"")}`;U.span({text:ue,padding:[0,2,0,2],width:T(D,Ne,`${C}${G}`)+4},{text:L[1]});let Z=[];if(L[2])Z.push(`[${t("default")}]`);if(L[3]&&L[3].length)Z.push(`[${t("aliases:")} ${L[3].join(", ")}]`);if(L[4])if(typeof L[4]==="string")Z.push(`[${t("deprecated: %s",L[4])}]`);else Z.push(`[${t("deprecated")}]`);if(Z.length)U.div({text:Z.join(" "),padding:[0,0,0,2],align:"right"});else U.div()}),U.div()}let ve=(Object.keys(H.alias)||[]).concat(Object.keys(e.parsed.newAliases)||[]);re=re.filter((k)=>!e.parsed.newAliases[k]&&ve.every((G)=>(H.alias[G]||[]).indexOf(k)===-1));let xn=t("Options:");if(!ne[xn])ne[xn]=[];Y(re,H.alias,ne,xn);let j=(k)=>/^--/.test(Hn(k)),fn=Object.keys(ne).filter((k)=>ne[k].length>0).map((k)=>{let G=ne[k].filter(te).map((ie)=>{if(ve.includes(ie))return ie;for(let L=0,ue;(ue=ve[L])!==void 0;L++)if((H.alias[ue]||[]).includes(ie))return ue;return ie});return{groupName:k,normalizedKeys:G}}).filter(({normalizedKeys:k})=>k.length>0).map(({groupName:k,normalizedKeys:G})=>{let ie=G.reduce((L,ue)=>(L[ue]=[ue].concat(H.alias[ue]||[]).map((Z)=>{if(k===r.getPositionalGroupName())return Z;else return(/^[0-9]$/.test(Z)?H.boolean.includes(ue)?"-":"--":Z.length>1?"--":"-")+Z}).sort((Z,se)=>j(Z)===j(se)?0:j(Z)?1:-1).join(", "),L),{});return{groupName:k,normalizedKeys:G,switches:ie}});if(fn.filter(({groupName:k})=>k!==r.getPositionalGroupName()).some(({normalizedKeys:k,switches:G})=>!k.every((ie)=>j(G[ie]))))fn.filter(({groupName:k})=>k!==r.getPositionalGroupName()).forEach(({normalizedKeys:k,switches:G})=>{k.forEach((ie)=>{if(j(G[ie]))G[ie]=Qa(G[ie],4)})});if(fn.forEach(({groupName:k,normalizedKeys:G,switches:ie})=>{U.div(k),G.forEach((L)=>{let ue=ie[L],Z=F[L]||"",se=null;if(Z.includes(W))Z=t(Z.substring(W.length));if(H.boolean.includes(L))se=`[${t("boolean")}]`;if(H.count.includes(L))se=`[${t("count")}]`;if(H.string.includes(L))se=`[${t("string")}]`;if(H.normalize.includes(L))se=`[${t("string")}]`;if(H.array.includes(L))se=`[${t("array")}]`;if(H.number.includes(L))se=`[${t("number")}]`;let gt=(E)=>typeof E==="string"?`[${t("deprecated: %s",E)}]`:`[${t("deprecated")}]`,l=[L in V?gt(V[L]):null,se,L in _?`[${t("required")}]`:null,H.choices&&H.choices[L]?`[${t("choices:")} ${r.stringifiedValues(H.choices[L])}]`:null,X(H.default[L],H.defaultDescription[L])].filter(Boolean).join(" ");U.span({text:Hn(ue),padding:[0,2,0,2+di(ue)],width:T(ie,Ne)+4},Z);let f=e.getInternalMethods().getUsageConfiguration()["hide-types"]===!0;if(l&&!f)U.div({text:l,padding:[0,0,0,2],align:"right"});else U.div()}),U.div()}),g.length)U.div(t("Examples:")),g.forEach((k)=>{k[0]=k[0].replace(/\$0/g,C)}),g.forEach((k)=>{if(k[1]==="")U.div({text:k[0],padding:[0,2,0,2]});else U.div({text:k[0],padding:[0,2,0,2],width:T(g,Ne)+4},{text:k[1]})}),U.div();if(y.length>0){let k=y.map((G)=>G.replace(/\$0/g,C)).join(`
17
+ `);U.div(`${k}
18
+ `)}return U.toString().replace(/\s*$/,"")};function T(P,C,_){let N=0;if(!Array.isArray(P))P=Object.values(P).map((V)=>[V]);if(P.forEach((V)=>{N=Math.max(n.stringWidth(_?`${_} ${Hn(V[0])}`:Hn(V[0]))+di(V[0]),N)}),C)N=Math.min(N,parseInt((C*0.5).toString(),10));return N}function ce(){let P=e.getDemandedOptions(),C=e.getOptions();(Object.keys(C.alias)||[]).forEach((_)=>{C.alias[_].forEach((N)=>{if(F[N])r.describe(_,F[N]);if(N in P)e.demandOption(_,P[N]);if(C.boolean.includes(N))e.boolean(_);if(C.count.includes(N))e.count(_);if(C.string.includes(N))e.string(_);if(C.normalize.includes(N))e.normalize(_);if(C.array.includes(N))e.array(_);if(C.number.includes(N))e.number(_)})})}let I;r.cacheHelpMessage=function(){I=this.help()},r.clearCachedHelpMessage=function(){I=void 0},r.hasCachedHelpMessage=function(){return!!I};function Y(P,C,_,N){let V=[],ne=null;return Object.keys(_).forEach((H)=>{V=V.concat(_[H])}),P.forEach((H)=>{if(ne=[H].concat(C[H]),!ne.some((re)=>V.indexOf(re)!==-1))_[N].push(H)}),V}function te(P){return e.getOptions().hiddenOptions.indexOf(P)<0||e.parsed.argv[e.getOptions().showHiddenOpt]}r.showHelp=(P)=>{let C=e.getInternalMethods().getLoggerInstance();if(!P)P="error";(typeof P==="function"?P:C[P])(r.help())},r.functionDescription=(P)=>["(",P.name?n.Parser.decamelize(P.name,"-"):t("generated-value"),")"].join(""),r.stringifiedValues=function(C,_){let N="",V=_||", ",ne=[].concat(C);if(!C||!ne.length)return N;return ne.forEach((H)=>{if(N.length)N+=V;N+=JSON.stringify(H)}),N};function X(P,C){let _=`[${t("default:")} `;if(P===void 0&&!C)return null;if(C)_+=C;else switch(typeof P){case"string":_+=`"${P}"`;break;case"object":_+=JSON.stringify(P);break;default:_+=P}return`${_}]`}function Pe(){if(n.process.stdColumns)return Math.min(80,n.process.stdColumns);else return 80}let z=null;r.version=(P)=>{z=P},r.showVersion=(P)=>{let C=e.getInternalMethods().getLoggerInstance();if(!P)P="error";(typeof P==="function"?P:C[P])(z)},r.reset=function(C){return s=null,c=!1,p=[],b=!1,y=[],g=[],D=[],F=Ie(F,(_)=>!C[_]),r};let wn=[];return r.freeze=function(){wn.push({failMessage:s,failureOutput:c,usages:p,usageDisabled:b,epilogs:y,examples:g,commands:D,descriptions:F})},r.unfreeze=function(C=!1){let _=wn.pop();if(!_)return;if(C)F={..._.descriptions,...F},D=[..._.commands,...D],p=[..._.usages,...p],g=[..._.examples,...g],y=[..._.epilogs,...y];else({failMessage:s,failureOutput:c,usages:p,usageDisabled:b,epilogs:y,examples:g,commands:D,descriptions:F}=_)},r}function vt(e){return typeof e==="object"}function Qa(e,n){return vt(e)?{text:e.text,indentation:e.indentation+n}:{text:e,indentation:n}}function di(e){return vt(e)?e.indentation:0}function Hn(e){return vt(e)?e.text:e}var hi=`###-begin-{{app_name}}-completions-###
19
19
  #
20
20
  # yargs command completion script
21
21
  #
@@ -44,7 +44,7 @@ _{{app_name}}_yargs_completions()
44
44
  }
45
45
  complete -o bashdefault -o default -F _{{app_name}}_yargs_completions {{app_name}}
46
46
  ###-end-{{app_name}}-completions-###
47
- `,p0=`#compdef {{app_name}}
47
+ `,Di=`#compdef {{app_name}}
48
48
  ###-begin-{{app_name}}-completions-###
49
49
  #
50
50
  # yargs command completion script
@@ -71,14 +71,14 @@ else
71
71
  compdef _{{app_name}}_yargs_completions {{app_name}}
72
72
  fi
73
73
  ###-end-{{app_name}}-completions-###
74
- `;class y0{constructor(D,u,F,C){var E,B,$;this.yargs=D,this.usage=u,this.command=F,this.shim=C,this.completionKey="get-yargs-completions",this.aliases=null,this.customCompletionFunction=null,this.indexAfterLastReset=0,this.zshShell=($=((E=this.shim.getEnv("SHELL"))===null||E===void 0?void 0:E.includes("zsh"))||((B=this.shim.getEnv("ZSH_NAME"))===null||B===void 0?void 0:B.includes("zsh")))!==null&&$!==void 0?$:!1}defaultCompletion(D,u,F,C){let E=this.command.getCommandHandlers();for(let $=0,Z=D.length;$<Z;++$)if(E[D[$]]&&E[D[$]].builder){let M=E[D[$]].builder;if(Pu(M)){this.indexAfterLastReset=$+1;let H=this.yargs.getInternalMethods().reset();return M(H,!0),H.argv}}let B=[];this.commandCompletions(B,D,F),this.optionCompletions(B,D,u,F),this.choicesFromOptionsCompletions(B,D,u,F),this.choicesFromPositionalsCompletions(B,D,u,F),C(null,B)}commandCompletions(D,u,F){let C=this.yargs.getInternalMethods().getContext().commands;if(!F.match(/^-/)&&C[C.length-1]!==F&&!this.previousArgHasChoices(u))this.usage.getCommands().forEach((E)=>{let B=xD(E[0]).cmd;if(u.indexOf(B)===-1)if(!this.zshShell)D.push(B);else{let $=E[1]||"";D.push(B.replace(/:/g,"\\:")+":"+$)}})}optionCompletions(D,u,F,C){if((C.match(/^-/)||C===""&&D.length===0)&&!this.previousArgHasChoices(u)){let E=this.yargs.getOptions(),B=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[];Object.keys(E.key).forEach(($)=>{let Z=!!E.configuration["boolean-negation"]&&E.boolean.includes($);if(!B.includes($)&&!E.hiddenOptions.includes($)&&!this.argsContainKey(u,$,Z))this.completeOptionKey($,D,C,Z&&!!E.default[$])})}}choicesFromOptionsCompletions(D,u,F,C){if(this.previousArgHasChoices(u)){let E=this.getPreviousArgChoices(u);if(E&&E.length>0)D.push(...E.map((B)=>B.replace(/:/g,"\\:")))}}choicesFromPositionalsCompletions(D,u,F,C){if(C===""&&D.length>0&&this.previousArgHasChoices(u))return;let E=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[],B=Math.max(this.indexAfterLastReset,this.yargs.getInternalMethods().getContext().commands.length+1),$=E[F._.length-B-1];if(!$)return;let Z=this.yargs.getOptions().choices[$]||[];for(let M of Z)if(M.startsWith(C))D.push(M.replace(/:/g,"\\:"))}getPreviousArgChoices(D){if(D.length<1)return;let u=D[D.length-1],F="";if(!u.startsWith("-")&&D.length>1)F=u,u=D[D.length-2];if(!u.startsWith("-"))return;let C=u.replace(/^-+/,""),E=this.yargs.getOptions(),B=[C,...this.yargs.getAliases()[C]||[]],$;for(let Z of B)if(Object.prototype.hasOwnProperty.call(E.key,Z)&&Array.isArray(E.choices[Z])){$=E.choices[Z];break}if($)return $.filter((Z)=>!F||Z.startsWith(F))}previousArgHasChoices(D){let u=this.getPreviousArgChoices(D);return u!==void 0&&u.length>0}argsContainKey(D,u,F){let C=(E)=>D.indexOf((/^[^0-9]$/.test(E)?"-":"--")+E)!==-1;if(C(u))return!0;if(F&&C(`no-${u}`))return!0;if(this.aliases){for(let E of this.aliases[u])if(C(E))return!0}return!1}completeOptionKey(D,u,F,C){var E,B,$,Z;let M=D;if(this.zshShell){let q=this.usage.getDescriptions(),O=(B=(E=this===null||this===void 0?void 0:this.aliases)===null||E===void 0?void 0:E[D])===null||B===void 0?void 0:B.find((S)=>{let d=q[S];return typeof d==="string"&&d.length>0}),W=O?q[O]:void 0,J=(Z=($=q[D])!==null&&$!==void 0?$:W)!==null&&Z!==void 0?Z:"";M=`${D.replace(/:/g,"\\:")}:${J.replace("__yargsString__:","").replace(/(\r\n|\n|\r)/gm," ")}`}let H=(q)=>/^--/.test(q),V=(q)=>/^[^0-9]$/.test(q),Y=!H(F)&&V(D)?"-":"--";if(u.push(Y+M),C)u.push(Y+"no-"+M)}customCompletion(D,u,F,C){if(GD(this.customCompletionFunction,null,this.shim),l3(this.customCompletionFunction)){let E=this.customCompletionFunction(F,u);if(i(E))return E.then((B)=>{this.shim.process.nextTick(()=>{C(null,B)})}).catch((B)=>{this.shim.process.nextTick(()=>{C(B,void 0)})});return C(null,E)}else if(i3(this.customCompletionFunction))return this.customCompletionFunction(F,u,(E=C)=>this.defaultCompletion(D,u,F,E),(E)=>{C(null,E)});else return this.customCompletionFunction(F,u,(E)=>{C(null,E)})}getCompletion(D,u){let F=D.length?D[D.length-1]:"",C=this.yargs.parse(D,!0),E=this.customCompletionFunction?(B)=>this.customCompletion(D,B,F,u):(B)=>this.defaultCompletion(D,B,F,u);return i(C)?C.then(E):E(C)}generateCompletionScript(D,u){let F=this.zshShell?p0:k0,C=this.shim.path.basename(D);if(D.match(/\.js$/))D=`./${D}`;return F=F.replace(/{{app_name}}/g,C),F=F.replace(/{{completion_command}}/g,u),F.replace(/{{app_path}}/g,D)}registerFunction(D){this.customCompletionFunction=D}setParsed(D){this.aliases=D.aliases}}function g0(D,u,F,C){return new y0(D,u,F,C)}function l3(D){return D.length<3}function i3(D){return D.length>3}function t0(D,u){if(D.length===0)return u.length;if(u.length===0)return D.length;let F=[],C;for(C=0;C<=u.length;C++)F[C]=[C];let E;for(E=0;E<=D.length;E++)F[0][E]=E;for(C=1;C<=u.length;C++)for(E=1;E<=D.length;E++)if(u.charAt(C-1)===D.charAt(E-1))F[C][E]=F[C-1][E-1];else if(C>1&&E>1&&u.charAt(C-2)===D.charAt(E-1)&&u.charAt(C-1)===D.charAt(E-2))F[C][E]=F[C-2][E-2]+1;else F[C][E]=Math.min(F[C-1][E-1]+1,Math.min(F[C][E-1]+1,F[C-1][E]+1));return F[u.length][D.length]}var l0=["$0","--","_"];function i0(D,u,F){let C=F.y18n.__,E=F.y18n.__n,B={};B.nonOptionCount=function(Y){let q=D.getDemandedCommands(),W=Y._.length+(Y["--"]?Y["--"].length:0)-D.getInternalMethods().getContext().commands.length;if(q._&&(W<q._.min||W>q._.max)){if(W<q._.min)if(q._.minMsg!==void 0)u.fail(q._.minMsg?q._.minMsg.replace(/\$0/g,W.toString()).replace(/\$1/,q._.min.toString()):null);else u.fail(E("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",W,W.toString(),q._.min.toString()));else if(W>q._.max)if(q._.maxMsg!==void 0)u.fail(q._.maxMsg?q._.maxMsg.replace(/\$0/g,W.toString()).replace(/\$1/,q._.max.toString()):null);else u.fail(E("Too many non-option arguments: got %s, maximum of %s","Too many non-option arguments: got %s, maximum of %s",W,W.toString(),q._.max.toString()))}},B.positionalCount=function(Y,q){if(q<Y)u.fail(E("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",q,q+"",Y+""))},B.requiredArguments=function(Y,q){let O=null;for(let W of Object.keys(q))if(!Object.prototype.hasOwnProperty.call(Y,W)||typeof Y[W]>"u")O=O||{},O[W]=q[W];if(O){let W=[];for(let S of Object.keys(O)){let d=O[S];if(d&&W.indexOf(d)<0)W.push(d)}let J=W.length?`
75
- ${W.join(`
76
- `)}`:"";u.fail(E("Missing required argument: %s","Missing required arguments: %s",Object.keys(O).length,Object.keys(O).join(", ")+J))}},B.unknownArguments=function(Y,q,O,W,J=!0){var S;let d=D.getInternalMethods().getCommandInstance().getCommands(),v=[],QD=D.getInternalMethods().getContext();if(Object.keys(Y).forEach((m)=>{if(!l0.includes(m)&&!Object.prototype.hasOwnProperty.call(O,m)&&!Object.prototype.hasOwnProperty.call(D.getInternalMethods().getParseContext(),m)&&!B.isValidAndSomeAliasIsNotNew(m,q))v.push(m)}),J&&(QD.commands.length>0||d.length>0||W))Y._.slice(QD.commands.length).forEach((m)=>{if(!d.includes(""+m))v.push(""+m)});if(J){let l=((S=D.getDemandedCommands()._)===null||S===void 0?void 0:S.max)||0,uD=QD.commands.length+l;if(uD<Y._.length)Y._.slice(uD).forEach((s)=>{if(s=String(s),!QD.commands.includes(s)&&!v.includes(s))v.push(s)})}if(v.length)u.fail(E("Unknown argument: %s","Unknown arguments: %s",v.length,v.map((m)=>m.trim()?m:`"${m}"`).join(", ")))},B.unknownCommands=function(Y){let q=D.getInternalMethods().getCommandInstance().getCommands(),O=[],W=D.getInternalMethods().getContext();if(W.commands.length>0||q.length>0)Y._.slice(W.commands.length).forEach((J)=>{if(!q.includes(""+J))O.push(""+J)});if(O.length>0)return u.fail(E("Unknown command: %s","Unknown commands: %s",O.length,O.join(", "))),!0;else return!1},B.isValidAndSomeAliasIsNotNew=function(Y,q){if(!Object.prototype.hasOwnProperty.call(q,Y))return!1;let O=D.parsed.newAliases;return[Y,...q[Y]].some((W)=>!Object.prototype.hasOwnProperty.call(O,W)||!O[Y])},B.limitedChoices=function(Y){let q=D.getOptions(),O={};if(!Object.keys(q.choices).length)return;Object.keys(Y).forEach((S)=>{if(l0.indexOf(S)===-1&&Object.prototype.hasOwnProperty.call(q.choices,S))[].concat(Y[S]).forEach((d)=>{if(q.choices[S].indexOf(d)===-1&&d!==void 0)O[S]=(O[S]||[]).concat(d)})});let W=Object.keys(O);if(!W.length)return;let J=C("Invalid values:");W.forEach((S)=>{J+=`
77
- ${C("Argument: %s, Given: %s, Choices: %s",S,u.stringifiedValues(O[S]),u.stringifiedValues(q.choices[S]))}`}),u.fail(J)};let $={};B.implies=function(Y,q){if(K("<string|object> [array|number|string]",[Y,q],arguments.length),typeof Y==="object")Object.keys(Y).forEach((O)=>{B.implies(O,Y[O])});else{if(D.global(Y),!$[Y])$[Y]=[];if(Array.isArray(q))q.forEach((O)=>B.implies(Y,O));else GD(q,void 0,F),$[Y].push(q)}},B.getImplied=function(){return $};function Z(V,Y){let q=Number(Y);if(Y=isNaN(q)?Y:q,typeof Y==="number")Y=V._.length>=Y;else if(Y.match(/^--no-.+/))Y=Y.match(/^--no-(.+)/)[1],Y=!Object.prototype.hasOwnProperty.call(V,Y);else Y=Object.prototype.hasOwnProperty.call(V,Y);return Y}B.implications=function(Y){let q=[];if(Object.keys($).forEach((O)=>{let W=O;($[O]||[]).forEach((J)=>{let S=W,d=J;if(S=Z(Y,S),J=Z(Y,J),S&&!J)q.push(` ${W} -> ${d}`)})}),q.length){let O=`${C("Implications failed:")}
78
- `;q.forEach((W)=>{O+=W}),u.fail(O)}};let M={};B.conflicts=function(Y,q){if(K("<string|object> [array|string]",[Y,q],arguments.length),typeof Y==="object")Object.keys(Y).forEach((O)=>{B.conflicts(O,Y[O])});else{if(D.global(Y),!M[Y])M[Y]=[];if(Array.isArray(q))q.forEach((O)=>B.conflicts(Y,O));else M[Y].push(q)}},B.getConflicting=()=>M,B.conflicting=function(Y){if(Object.keys(Y).forEach((q)=>{if(M[q])M[q].forEach((O)=>{if(O&&Y[q]!==void 0&&Y[O]!==void 0)u.fail(C("Arguments %s and %s are mutually exclusive",q,O))})}),D.getInternalMethods().getParserConfiguration()["strip-dashed"])Object.keys(M).forEach((q)=>{M[q].forEach((O)=>{if(O&&Y[F.Parser.camelCase(q)]!==void 0&&Y[F.Parser.camelCase(O)]!==void 0)u.fail(C("Arguments %s and %s are mutually exclusive",q,O))})})},B.recommendCommands=function(Y,q){q=q.sort((S,d)=>d.length-S.length);let W=null,J=1/0;for(let S=0,d;(d=q[S])!==void 0;S++){let v=t0(Y,d);if(v<=3&&v<J)J=v,W=d}if(W)u.fail(C("Did you mean %s?",W))},B.reset=function(Y){return $=bD($,(q)=>!Y[q]),M=bD(M,(q)=>!Y[q]),B};let H=[];return B.freeze=function(){H.push({implied:$,conflicting:M})},B.unfreeze=function(){let Y=H.pop();GD(Y,void 0,F),{implied:$,conflicting:M}=Y},B}var qF=[],Hu;function bu(D,u,F,C){Hu=C;let E={};if(Object.prototype.hasOwnProperty.call(D,"extends")){if(typeof D.extends!=="string")return E;let B=/\.json|\..*rc$/.test(D.extends),$=null;if(!B)try{$=import.meta.resolve(D.extends)}catch(Z){return D}else $=n3(u,D.extends);o3($),qF.push($),E=B?JSON.parse(Hu.readFileSync($,"utf8")):C.require(D.extends),delete D.extends,E=bu(E,Hu.path.dirname($),F,Hu)}return qF=[],F?o0(E,D):Object.assign({},E,D)}function o3(D){if(qF.indexOf(D)>-1)throw new a(`Circular extended configurations: '${D}'.`)}function n3(D,u){return Hu.path.resolve(D,u)}function o0(D,u){let F={};function C(E){return E&&typeof E==="object"&&!Array.isArray(E)}Object.assign(F,D);for(let E of Object.keys(u))if(C(u[E])&&C(F[E]))F[E]=o0(D[E],u[E]);else F[E]=u[E];return F}var j=function(D,u,F,C,E){if(C==="m")throw TypeError("Private method is not writable");if(C==="a"&&!E)throw TypeError("Private accessor was defined without a setter");if(typeof u==="function"?D!==u||!E:!u.has(D))throw TypeError("Cannot write private member to an object whose class did not declare it");return C==="a"?E.call(D,F):E?E.value=F:u.set(D,F),F},z=function(D,u,F,C){if(F==="a"&&!C)throw TypeError("Private accessor was defined without a getter");if(typeof u==="function"?D!==u||!C:!u.has(D))throw TypeError("Cannot read private member from an object whose class did not declare it");return F==="m"?C:F==="a"?C.call(D):C?C.value:u.get(D)},e,tD,Ou,JD,qD,hu,wD,lD,wu,WD,mu,VD,_D,HD,TD,vu,iD,$D,f,cu,du,OD,oD,zu,nD,mD,ku,b,sD,rD,aD,w,pu,ND,n;function Y2(D){return(u=[],F=D.process.cwd(),C)=>{let E=new q2(u,F,C,D);return Object.defineProperty(E,"argv",{get:()=>{return E.parse()},enumerable:!0}),E.help(),E.version(),E}}var n0=Symbol("copyDoubleDash"),s0=Symbol("copyDoubleDash"),HF=Symbol("deleteFromParserHintObject"),r0=Symbol("emitWarning"),a0=Symbol("freeze"),e0=Symbol("getDollarZero"),eD=Symbol("getParserConfiguration"),D2=Symbol("getUsageConfiguration"),OF=Symbol("guessLocale"),u2=Symbol("guessVersion"),F2=Symbol("parsePositionalNumbers"),UF=Symbol("pkgUp"),vD=Symbol("populateParserHintArray"),Zu=Symbol("populateParserHintSingleValueDictionary"),WF=Symbol("populateParserHintArrayDictionary"),VF=Symbol("populateParserHintDictionary"),TF=Symbol("sanitizeKey"),LF=Symbol("setKey"),IF=Symbol("unfreeze"),C2=Symbol("validateAsync"),E2=Symbol("getCommandInstance"),B2=Symbol("getContext"),$2=Symbol("getHasOutput"),z2=Symbol("getLoggerInstance"),Z2=Symbol("getParseContext"),Q2=Symbol("getUsageInstance"),X2=Symbol("getValidationInstance"),yu=Symbol("hasParseCallback"),M2=Symbol("isGlobalContext"),Du=Symbol("postProcess"),G2=Symbol("rebase"),KF=Symbol("reset"),Uu=Symbol("runYargsParserAndExecuteCommands"),jF=Symbol("runValidation"),J2=Symbol("setHasOutput"),uu=Symbol("kTrackManuallySetKeys"),s3="en_US";class q2{constructor(D=[],u,F,C){this.customScriptName=!1,this.parsed=!1,e.set(this,void 0),tD.set(this,void 0),Ou.set(this,{commands:[],fullCommands:[]}),JD.set(this,null),qD.set(this,null),hu.set(this,"show-hidden"),wD.set(this,null),lD.set(this,!0),wu.set(this,{}),WD.set(this,!0),mu.set(this,[]),VD.set(this,void 0),_D.set(this,{}),HD.set(this,!1),TD.set(this,null),vu.set(this,!0),iD.set(this,void 0),$D.set(this,""),f.set(this,void 0),cu.set(this,void 0),du.set(this,{}),OD.set(this,null),oD.set(this,null),zu.set(this,{}),nD.set(this,{}),mD.set(this,void 0),ku.set(this,!1),b.set(this,void 0),sD.set(this,!1),rD.set(this,!1),aD.set(this,!1),w.set(this,void 0),pu.set(this,{}),ND.set(this,null),n.set(this,void 0),j(this,b,C,"f"),j(this,mD,D,"f"),j(this,tD,u,"f"),j(this,cu,F,"f"),j(this,VD,new JF(this),"f"),this.$0=this[e0](),this[KF](),j(this,e,z(this,e,"f"),"f"),j(this,w,z(this,w,"f"),"f"),j(this,n,z(this,n,"f"),"f"),j(this,f,z(this,f,"f"),"f"),z(this,f,"f").showHiddenOpt=z(this,hu,"f"),j(this,iD,this[s0](),"f"),z(this,b,"f").y18n.setLocale(s3)}addHelpOpt(D,u){if(K("[string|boolean] [string]",[D,u],arguments.length),z(this,TD,"f"))this[HF](z(this,TD,"f")),j(this,TD,null,"f");if(D===!1&&u===void 0)return this;return j(this,TD,typeof D==="string"?D:"help","f"),this.boolean(z(this,TD,"f")),this.describe(z(this,TD,"f"),u||z(this,w,"f").deferY18nLookup("Show help")),this}help(D,u){return this.addHelpOpt(D,u)}addShowHiddenOpt(D,u){if(K("[string|boolean] [string]",[D,u],arguments.length),D===!1&&u===void 0)return this;let F=typeof D==="string"?D:z(this,hu,"f");return this.boolean(F),this.describe(F,u||z(this,w,"f").deferY18nLookup("Show hidden options")),z(this,f,"f").showHiddenOpt=F,this}showHidden(D,u){return this.addShowHiddenOpt(D,u)}alias(D,u){return K("<object|string|array> [string|array]",[D,u],arguments.length),this[WF](this.alias.bind(this),"alias",D,u),this}array(D){return K("<array|string>",[D],arguments.length),this[vD]("array",D),this[uu](D),this}boolean(D){return K("<array|string>",[D],arguments.length),this[vD]("boolean",D),this[uu](D),this}check(D,u){return K("<function> [boolean]",[D,u],arguments.length),this.middleware((F,C)=>{return gD(()=>{return D(F,C.getOptions())},(E)=>{if(!E)z(this,w,"f").fail(z(this,b,"f").y18n.__("Argument check failed: %s",D.toString()));else if(typeof E==="string"||E instanceof Error)z(this,w,"f").fail(E.toString(),E);return F},(E)=>{return z(this,w,"f").fail(E.message?E.message:E.toString(),E),F})},!1,u),this}choices(D,u){return K("<object|string|array> [string|array]",[D,u],arguments.length),this[WF](this.choices.bind(this),"choices",D,u),this}coerce(D,u){if(K("<object|string|array> [function]",[D,u],arguments.length),Array.isArray(D)){if(!u)throw new a("coerce callback must be provided");for(let C of D)this.coerce(C,u);return this}else if(typeof D==="object"){for(let C of Object.keys(D))this.coerce(C,D[C]);return this}if(!u)throw new a("coerce callback must be provided");let F=D;return z(this,f,"f").key[F]=!0,z(this,VD,"f").addCoerceMiddleware((C,E)=>{var B;let $=(B=E.getAliases()[F])!==null&&B!==void 0?B:[],Z=[F,...$].filter((M)=>Object.prototype.hasOwnProperty.call(C,M));if(Z.length===0)return C;return gD(()=>{return u(C[Z[0]])},(M)=>{return Z.forEach((H)=>{C[H]=M}),C},(M)=>{throw new a(M.message)})},F),this}conflicts(D,u){return K("<string|object> [string|array]",[D,u],arguments.length),z(this,n,"f").conflicts(D,u),this}config(D="config",u,F){if(K("[object|string] [string|function] [function]",[D,u,F],arguments.length),typeof D==="object"&&!Array.isArray(D))return D=bu(D,z(this,tD,"f"),this[eD]()["deep-merge-config"]||!1,z(this,b,"f")),z(this,f,"f").configObjects=(z(this,f,"f").configObjects||[]).concat(D),this;if(typeof u==="function")F=u,u=void 0;return this.describe(D,u||z(this,w,"f").deferY18nLookup("Path to JSON config file")),(Array.isArray(D)?D:[D]).forEach((C)=>{z(this,f,"f").config[C]=F||!0}),this}completion(D,u,F){if(K("[string] [string|boolean|function] [function]",[D,u,F],arguments.length),typeof u==="function")F=u,u=void 0;if(j(this,qD,D||z(this,qD,"f")||"completion","f"),!u&&u!==!1)u="generate completion script";if(this.command(z(this,qD,"f"),u),F)z(this,JD,"f").registerFunction(F);return this}command(D,u,F,C,E,B){return K("<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]",[D,u,F,C,E,B],arguments.length),z(this,e,"f").addHandler(D,u,F,C,E,B),this}commands(D,u,F,C,E,B){return this.command(D,u,F,C,E,B)}commandDir(D,u){K("<string> [object]",[D,u],arguments.length);let F=z(this,cu,"f")||z(this,b,"f").require;return z(this,e,"f").addDirectory(D,F,z(this,b,"f").getCallerFile(),u),this}count(D){return K("<array|string>",[D],arguments.length),this[vD]("count",D),this[uu](D),this}default(D,u,F){if(K("<object|string|array> [*] [string]",[D,u,F],arguments.length),F)GF(D,z(this,b,"f")),z(this,f,"f").defaultDescription[D]=F;if(typeof u==="function"){if(GF(D,z(this,b,"f")),!z(this,f,"f").defaultDescription[D])z(this,f,"f").defaultDescription[D]=z(this,w,"f").functionDescription(u);u=u.call()}return this[Zu](this.default.bind(this),"default",D,u),this}defaults(D,u,F){return this.default(D,u,F)}demandCommand(D=1,u,F,C){if(K("[number] [number|string] [string|null|undefined] [string|null|undefined]",[D,u,F,C],arguments.length),typeof u!=="number")F=u,u=1/0;return this.global("_",!1),z(this,f,"f").demandedCommands._={min:D,max:u,minMsg:F,maxMsg:C},this}demand(D,u,F){if(Array.isArray(u))u.forEach((C)=>{GD(F,!0,z(this,b,"f")),this.demandOption(C,F)}),u=1/0;else if(typeof u!=="number")F=u,u=1/0;if(typeof D==="number")GD(F,!0,z(this,b,"f")),this.demandCommand(D,u,F,F);else if(Array.isArray(D))D.forEach((C)=>{GD(F,!0,z(this,b,"f")),this.demandOption(C,F)});else if(typeof F==="string")this.demandOption(D,F);else if(F===!0||typeof F>"u")this.demandOption(D);return this}demandOption(D,u){return K("<object|string|array> [string]",[D,u],arguments.length),this[Zu](this.demandOption.bind(this),"demandedOptions",D,u),this}deprecateOption(D,u){return K("<string> [string|boolean]",[D,u],arguments.length),z(this,f,"f").deprecatedOptions[D]=u,this}describe(D,u){return K("<object|string|array> [string]",[D,u],arguments.length),this[LF](D,!0),z(this,w,"f").describe(D,u),this}detectLocale(D){return K("<boolean>",[D],arguments.length),j(this,lD,D,"f"),this}env(D){if(K("[string|boolean]",[D],arguments.length),D===!1)delete z(this,f,"f").envPrefix;else z(this,f,"f").envPrefix=D||"";return this}epilogue(D){return K("<string>",[D],arguments.length),z(this,w,"f").epilog(D),this}epilog(D){return this.epilogue(D)}example(D,u){if(K("<string|array> [string]",[D,u],arguments.length),Array.isArray(D))D.forEach((F)=>this.example(...F));else z(this,w,"f").example(D,u);return this}exit(D,u){if(j(this,HD,!0,"f"),j(this,wD,u,"f"),z(this,WD,"f"))z(this,b,"f").process.exit(D)}exitProcess(D=!0){return K("[boolean]",[D],arguments.length),j(this,WD,D,"f"),this}fail(D){if(K("<function|boolean>",[D],arguments.length),typeof D==="boolean"&&D!==!1)throw new a("Invalid first argument. Expected function or boolean 'false'");return z(this,w,"f").failFn(D),this}getAliases(){return this.parsed?this.parsed.aliases:{}}async getCompletion(D,u){if(K("<array> [function]",[D,u],arguments.length),!u)return new Promise((F,C)=>{z(this,JD,"f").getCompletion(D,(E,B)=>{if(E)C(E);else F(B)})});else return z(this,JD,"f").getCompletion(D,u)}getDemandedOptions(){return K([],0),z(this,f,"f").demandedOptions}getDemandedCommands(){return K([],0),z(this,f,"f").demandedCommands}getDeprecatedOptions(){return K([],0),z(this,f,"f").deprecatedOptions}getDetectLocale(){return z(this,lD,"f")}getExitProcess(){return z(this,WD,"f")}getGroups(){return Object.assign({},z(this,_D,"f"),z(this,nD,"f"))}getHelp(){if(j(this,HD,!0,"f"),!z(this,w,"f").hasCachedHelpMessage()){if(!this.parsed){let u=this[Uu](z(this,mD,"f"),void 0,void 0,0,!0);if(i(u))return u.then(()=>{return z(this,w,"f").help()})}let D=z(this,e,"f").runDefaultBuilderOn(this);if(i(D))return D.then(()=>{return z(this,w,"f").help()})}return Promise.resolve(z(this,w,"f").help())}getOptions(){return z(this,f,"f")}getStrict(){return z(this,sD,"f")}getStrictCommands(){return z(this,rD,"f")}getStrictOptions(){return z(this,aD,"f")}global(D,u){if(K("<string|array> [boolean]",[D,u],arguments.length),D=[].concat(D),u!==!1)z(this,f,"f").local=z(this,f,"f").local.filter((F)=>D.indexOf(F)===-1);else D.forEach((F)=>{if(!z(this,f,"f").local.includes(F))z(this,f,"f").local.push(F)});return this}group(D,u){K("<string|array> <string>",[D,u],arguments.length);let F=z(this,nD,"f")[u]||z(this,_D,"f")[u];if(z(this,nD,"f")[u])delete z(this,nD,"f")[u];let C={};return z(this,_D,"f")[u]=(F||[]).concat(D).filter((E)=>{if(C[E])return!1;return C[E]=!0}),this}hide(D){return K("<string>",[D],arguments.length),z(this,f,"f").hiddenOptions.push(D),this}implies(D,u){return K("<string|object> [number|string|array]",[D,u],arguments.length),z(this,n,"f").implies(D,u),this}locale(D){if(K("[string]",[D],arguments.length),D===void 0)return this[OF](),z(this,b,"f").y18n.getLocale();return j(this,lD,!1,"f"),z(this,b,"f").y18n.setLocale(D),this}middleware(D,u,F){return z(this,VD,"f").addMiddleware(D,!!u,F)}nargs(D,u){return K("<string|object|array> [number]",[D,u],arguments.length),this[Zu](this.nargs.bind(this),"narg",D,u),this}normalize(D){return K("<array|string>",[D],arguments.length),this[vD]("normalize",D),this}number(D){return K("<array|string>",[D],arguments.length),this[vD]("number",D),this[uu](D),this}option(D,u){if(K("<string|object> [object]",[D,u],arguments.length),typeof D==="object")Object.keys(D).forEach((F)=>{this.options(F,D[F])});else{if(typeof u!=="object")u={};if(this[uu](D),z(this,ND,"f")&&(D==="version"||(u===null||u===void 0?void 0:u.alias)==="version"))this[r0](['"version" is a reserved word.',"Please do one of the following:",'- Disable version with `yargs.version(false)` if using "version" as an option',"- Use the built-in `yargs.version` method instead (if applicable)","- Use a different option key","https://yargs.js.org/docs/#api-reference-version"].join(`
79
- `),void 0,"versionWarning");if(z(this,f,"f").key[D]=!0,u.alias)this.alias(D,u.alias);let F=u.deprecate||u.deprecated;if(F)this.deprecateOption(D,F);let C=u.demand||u.required||u.require;if(C)this.demand(D,C);if(u.demandOption)this.demandOption(D,typeof u.demandOption==="string"?u.demandOption:void 0);if(u.conflicts)this.conflicts(D,u.conflicts);if("default"in u)this.default(D,u.default);if(u.implies!==void 0)this.implies(D,u.implies);if(u.nargs!==void 0)this.nargs(D,u.nargs);if(u.config)this.config(D,u.configParser);if(u.normalize)this.normalize(D);if(u.choices)this.choices(D,u.choices);if(u.coerce)this.coerce(D,u.coerce);if(u.group)this.group(D,u.group);if(u.boolean||u.type==="boolean"){if(this.boolean(D),u.alias)this.boolean(u.alias)}if(u.array||u.type==="array"){if(this.array(D),u.alias)this.array(u.alias)}if(u.number||u.type==="number"){if(this.number(D),u.alias)this.number(u.alias)}if(u.string||u.type==="string"){if(this.string(D),u.alias)this.string(u.alias)}if(u.count||u.type==="count")this.count(D);if(typeof u.global==="boolean")this.global(D,u.global);if(u.defaultDescription)z(this,f,"f").defaultDescription[D]=u.defaultDescription;if(u.skipValidation)this.skipValidation(D);let E=u.describe||u.description||u.desc,B=z(this,w,"f").getDescriptions();if(!Object.prototype.hasOwnProperty.call(B,D)||typeof E==="string")this.describe(D,E);if(u.hidden)this.hide(D);if(u.requiresArg)this.requiresArg(D)}return this}options(D,u){return this.option(D,u)}parse(D,u,F){if(K("[string|array] [function|boolean|object] [function]",[D,u,F],arguments.length),this[a0](),typeof D>"u")D=z(this,mD,"f");if(typeof u==="object")j(this,oD,u,"f"),u=F;if(typeof u==="function")j(this,OD,u,"f"),u=!1;if(!u)j(this,mD,D,"f");if(z(this,OD,"f"))j(this,WD,!1,"f");let C=this[Uu](D,!!u),E=this.parsed;if(z(this,JD,"f").setParsed(this.parsed),i(C))return C.then((B)=>{if(z(this,OD,"f"))z(this,OD,"f").call(this,z(this,wD,"f"),B,z(this,$D,"f"));return B}).catch((B)=>{if(z(this,OD,"f"))z(this,OD,"f")(B,this.parsed.argv,z(this,$D,"f"));throw B}).finally(()=>{this[IF](),this.parsed=E});else{if(z(this,OD,"f"))z(this,OD,"f").call(this,z(this,wD,"f"),C,z(this,$D,"f"));this[IF](),this.parsed=E}return C}parseAsync(D,u,F){let C=this.parse(D,u,F);return!i(C)?Promise.resolve(C):C}parseSync(D,u,F){let C=this.parse(D,u,F);if(i(C))throw new a(".parseSync() must not be used with asynchronous builders, handlers, or middleware");return C}parserConfiguration(D){return K("<object>",[D],arguments.length),j(this,du,D,"f"),this}pkgConf(D,u){K("<string> [string]",[D,u],arguments.length);let F=null,C=this[UF](u||z(this,tD,"f"));if(C[D]&&typeof C[D]==="object")F=bu(C[D],u||z(this,tD,"f"),this[eD]()["deep-merge-config"]||!1,z(this,b,"f")),z(this,f,"f").configObjects=(z(this,f,"f").configObjects||[]).concat(F);return this}positional(D,u){K("<string> <object>",[D,u],arguments.length);let F=["default","defaultDescription","implies","normalize","choices","conflicts","coerce","type","describe","desc","description","alias"];u=bD(u,(B,$)=>{if(B==="type"&&!["string","number","boolean"].includes($))return!1;return F.includes(B)});let C=z(this,Ou,"f").fullCommands[z(this,Ou,"f").fullCommands.length-1],E=C?z(this,e,"f").cmdToParseOptions(C):{array:[],alias:{},default:{},demand:{}};return Bu(E).forEach((B)=>{let $=E[B];if(Array.isArray($)){if($.indexOf(D)!==-1)u[B]=!0}else if($[D]&&!(B in u))u[B]=$[D]}),this.group(D,z(this,w,"f").getPositionalGroupName()),this.option(D,u)}recommendCommands(D=!0){return K("[boolean]",[D],arguments.length),j(this,ku,D,"f"),this}required(D,u,F){return this.demand(D,u,F)}require(D,u,F){return this.demand(D,u,F)}requiresArg(D){if(K("<array|string|object> [number]",[D],arguments.length),typeof D==="string"&&z(this,f,"f").narg[D])return this;else this[Zu](this.requiresArg.bind(this),"narg",D,NaN);return this}showCompletionScript(D,u){return K("[string] [string]",[D,u],arguments.length),D=D||this.$0,z(this,iD,"f").log(z(this,JD,"f").generateCompletionScript(D,u||z(this,qD,"f")||"completion")),this}showHelp(D){if(K("[string|function]",[D],arguments.length),j(this,HD,!0,"f"),!z(this,w,"f").hasCachedHelpMessage()){if(!this.parsed){let F=this[Uu](z(this,mD,"f"),void 0,void 0,0,!0);if(i(F))return F.then(()=>{z(this,w,"f").showHelp(D)}),this}let u=z(this,e,"f").runDefaultBuilderOn(this);if(i(u))return u.then(()=>{z(this,w,"f").showHelp(D)}),this}return z(this,w,"f").showHelp(D),this}scriptName(D){return this.customScriptName=!0,this.$0=D,this}showHelpOnFail(D,u){return K("[boolean|string] [string]",[D,u],arguments.length),z(this,w,"f").showHelpOnFail(D,u),this}showVersion(D){return K("[string|function]",[D],arguments.length),z(this,w,"f").showVersion(D),this}skipValidation(D){return K("<array|string>",[D],arguments.length),this[vD]("skipValidation",D),this}strict(D){return K("[boolean]",[D],arguments.length),j(this,sD,D!==!1,"f"),this}strictCommands(D){return K("[boolean]",[D],arguments.length),j(this,rD,D!==!1,"f"),this}strictOptions(D){return K("[boolean]",[D],arguments.length),j(this,aD,D!==!1,"f"),this}string(D){return K("<array|string>",[D],arguments.length),this[vD]("string",D),this[uu](D),this}terminalWidth(){return K([],0),z(this,b,"f").process.stdColumns}updateLocale(D){return this.updateStrings(D)}updateStrings(D){return K("<object>",[D],arguments.length),j(this,lD,!1,"f"),z(this,b,"f").y18n.updateLocale(D),this}usage(D,u,F,C){if(K("<string|null|undefined> [string|boolean] [function|object] [function]",[D,u,F,C],arguments.length),u!==void 0)if(GD(D,null,z(this,b,"f")),(D||"").match(/^\$0( |$)/))return this.command(D,u,F,C);else throw new a(".usage() description must start with $0 if being used as alias for .command()");else return z(this,w,"f").usage(D),this}usageConfiguration(D){return K("<object>",[D],arguments.length),j(this,pu,D,"f"),this}version(D,u,F){if(K("[boolean|string] [string] [string]",[D,u,F],arguments.length),z(this,ND,"f"))this[HF](z(this,ND,"f")),z(this,w,"f").version(void 0),j(this,ND,null,"f");if(arguments.length===0)F=this[u2](),D="version";else if(arguments.length===1){if(D===!1)return this;F=D,D="version"}else if(arguments.length===2)F=u,u=void 0;return j(this,ND,typeof D==="string"?D:"version","f"),u=u||z(this,w,"f").deferY18nLookup("Show version number"),z(this,w,"f").version(F||void 0),this.boolean(z(this,ND,"f")),this.describe(z(this,ND,"f"),u),this}wrap(D){return K("<number|null|undefined>",[D],arguments.length),z(this,w,"f").wrap(D),this}[(e=new WeakMap,tD=new WeakMap,Ou=new WeakMap,JD=new WeakMap,qD=new WeakMap,hu=new WeakMap,wD=new WeakMap,lD=new WeakMap,wu=new WeakMap,WD=new WeakMap,mu=new WeakMap,VD=new WeakMap,_D=new WeakMap,HD=new WeakMap,TD=new WeakMap,vu=new WeakMap,iD=new WeakMap,$D=new WeakMap,f=new WeakMap,cu=new WeakMap,du=new WeakMap,OD=new WeakMap,oD=new WeakMap,zu=new WeakMap,nD=new WeakMap,mD=new WeakMap,ku=new WeakMap,b=new WeakMap,sD=new WeakMap,rD=new WeakMap,aD=new WeakMap,w=new WeakMap,pu=new WeakMap,ND=new WeakMap,n=new WeakMap,n0)](D){if(!D._||!D["--"])return D;D._.push.apply(D._,D["--"]);try{delete D["--"]}catch(u){}return D}[s0](){return{log:(...D)=>{if(!this[yu]())console.log(...D);if(j(this,HD,!0,"f"),z(this,$D,"f").length)j(this,$D,z(this,$D,"f")+`
80
- `,"f");j(this,$D,z(this,$D,"f")+D.join(" "),"f")},error:(...D)=>{if(!this[yu]())console.error(...D);if(j(this,HD,!0,"f"),z(this,$D,"f").length)j(this,$D,z(this,$D,"f")+`
81
- `,"f");j(this,$D,z(this,$D,"f")+D.join(" "),"f")}}}[HF](D){Bu(z(this,f,"f")).forEach((u)=>{if(((C)=>C==="configObjects")(u))return;let F=z(this,f,"f")[u];if(Array.isArray(F)){if(F.includes(D))F.splice(F.indexOf(D),1)}else if(typeof F==="object")delete F[D]}),delete z(this,w,"f").getDescriptions()[D]}[r0](D,u,F){if(!z(this,wu,"f")[F])z(this,b,"f").process.emitWarning(D,u),z(this,wu,"f")[F]=!0}[a0](){z(this,mu,"f").push({options:z(this,f,"f"),configObjects:z(this,f,"f").configObjects.slice(0),exitProcess:z(this,WD,"f"),groups:z(this,_D,"f"),strict:z(this,sD,"f"),strictCommands:z(this,rD,"f"),strictOptions:z(this,aD,"f"),completionCommand:z(this,qD,"f"),output:z(this,$D,"f"),exitError:z(this,wD,"f"),hasOutput:z(this,HD,"f"),parsed:this.parsed,parseFn:z(this,OD,"f"),parseContext:z(this,oD,"f")}),z(this,w,"f").freeze(),z(this,n,"f").freeze(),z(this,e,"f").freeze(),z(this,VD,"f").freeze()}[e0](){let D="",u;if(/\b(node|iojs|electron)(\.exe)?$/.test(z(this,b,"f").process.argv()[0]))u=z(this,b,"f").process.argv().slice(1,2);else u=z(this,b,"f").process.argv().slice(0,1);if(D=u.map((F)=>{let C=this[G2](z(this,tD,"f"),F);return F.match(/^(\/|([a-zA-Z]:)?\\)/)&&C.length<F.length?C:F}).join(" ").trim(),z(this,b,"f").getEnv("_")&&z(this,b,"f").getProcessArgvBin()===z(this,b,"f").getEnv("_"))D=z(this,b,"f").getEnv("_").replace(`${z(this,b,"f").path.dirname(z(this,b,"f").process.execPath())}/`,"");return D}[eD](){return z(this,du,"f")}[D2](){return z(this,pu,"f")}[OF](){if(!z(this,lD,"f"))return;let D=z(this,b,"f").getEnv("LC_ALL")||z(this,b,"f").getEnv("LC_MESSAGES")||z(this,b,"f").getEnv("LANG")||z(this,b,"f").getEnv("LANGUAGE")||"en_US";this.locale(D.replace(/[.:].*/,""))}[u2](){return this[UF]().version||"unknown"}[F2](D){let u=D["--"]?D["--"]:D._;for(let F=0,C;(C=u[F])!==void 0;F++)if(z(this,b,"f").Parser.looksLikeNumber(C)&&Number.isSafeInteger(Math.floor(parseFloat(`${C}`))))u[F]=Number(C);return D}[UF](D){let u=D||"*";if(z(this,zu,"f")[u])return z(this,zu,"f")[u];let F={};try{let C=D||z(this,b,"f").mainFilename;if(z(this,b,"f").path.extname(C))C=z(this,b,"f").path.dirname(C);let E=z(this,b,"f").findUp(C,(B,$)=>{if($.includes("package.json"))return"package.json";else return});GD(E,void 0,z(this,b,"f")),F=JSON.parse(z(this,b,"f").readFileSync(E,"utf8"))}catch(C){}return z(this,zu,"f")[u]=F||{},z(this,zu,"f")[u]}[vD](D,u){u=[].concat(u),u.forEach((F)=>{F=this[TF](F),z(this,f,"f")[D].push(F)})}[Zu](D,u,F,C){this[VF](D,u,F,C,(E,B,$)=>{z(this,f,"f")[E][B]=$})}[WF](D,u,F,C){this[VF](D,u,F,C,(E,B,$)=>{z(this,f,"f")[E][B]=(z(this,f,"f")[E][B]||[]).concat($)})}[VF](D,u,F,C,E){if(Array.isArray(F))F.forEach((B)=>{D(B,C)});else if(((B)=>typeof B==="object")(F))for(let B of Bu(F))D(B,F[B]);else E(u,this[TF](F),C)}[TF](D){if(D==="__proto__")return"___proto___";return D}[LF](D,u){return this[Zu](this[LF].bind(this),"key",D,u),this}[IF](){var D,u,F,C,E,B,$,Z,M,H,V,Y;let q=z(this,mu,"f").pop();GD(q,void 0,z(this,b,"f"));let O;D=this,u=this,F=this,C=this,E=this,B=this,$=this,Z=this,M=this,H=this,V=this,Y=this,{options:{set value(W){j(D,f,W,"f")}}.value,configObjects:O,exitProcess:{set value(W){j(u,WD,W,"f")}}.value,groups:{set value(W){j(F,_D,W,"f")}}.value,output:{set value(W){j(C,$D,W,"f")}}.value,exitError:{set value(W){j(E,wD,W,"f")}}.value,hasOutput:{set value(W){j(B,HD,W,"f")}}.value,parsed:this.parsed,strict:{set value(W){j($,sD,W,"f")}}.value,strictCommands:{set value(W){j(Z,rD,W,"f")}}.value,strictOptions:{set value(W){j(M,aD,W,"f")}}.value,completionCommand:{set value(W){j(H,qD,W,"f")}}.value,parseFn:{set value(W){j(V,OD,W,"f")}}.value,parseContext:{set value(W){j(Y,oD,W,"f")}}.value}=q,z(this,f,"f").configObjects=O,z(this,w,"f").unfreeze(),z(this,n,"f").unfreeze(),z(this,e,"f").unfreeze(),z(this,VD,"f").unfreeze()}[C2](D,u){return gD(u,(F)=>{return D(F),F})}getInternalMethods(){return{getCommandInstance:this[E2].bind(this),getContext:this[B2].bind(this),getHasOutput:this[$2].bind(this),getLoggerInstance:this[z2].bind(this),getParseContext:this[Z2].bind(this),getParserConfiguration:this[eD].bind(this),getUsageConfiguration:this[D2].bind(this),getUsageInstance:this[Q2].bind(this),getValidationInstance:this[X2].bind(this),hasParseCallback:this[yu].bind(this),isGlobalContext:this[M2].bind(this),postProcess:this[Du].bind(this),reset:this[KF].bind(this),runValidation:this[jF].bind(this),runYargsParserAndExecuteCommands:this[Uu].bind(this),setHasOutput:this[J2].bind(this)}}[E2](){return z(this,e,"f")}[B2](){return z(this,Ou,"f")}[$2](){return z(this,HD,"f")}[z2](){return z(this,iD,"f")}[Z2](){return z(this,oD,"f")||{}}[Q2](){return z(this,w,"f")}[X2](){return z(this,n,"f")}[yu](){return!!z(this,OD,"f")}[M2](){return z(this,vu,"f")}[Du](D,u,F,C){if(F)return D;if(i(D))return D;if(!u)D=this[n0](D);if(this[eD]()["parse-positional-numbers"]||this[eD]()["parse-positional-numbers"]===void 0)D=this[F2](D);if(C)D=yD(D,this,z(this,VD,"f").getMiddleware(),!1);return D}[KF](D={}){j(this,f,z(this,f,"f")||{},"f");let u={};u.local=z(this,f,"f").local||[],u.configObjects=z(this,f,"f").configObjects||[];let F={};u.local.forEach((B)=>{F[B]=!0,(D[B]||[]).forEach(($)=>{F[$]=!0})}),Object.assign(z(this,nD,"f"),Object.keys(z(this,_D,"f")).reduce((B,$)=>{let Z=z(this,_D,"f")[$].filter((M)=>!(M in F));if(Z.length>0)B[$]=Z;return B},{})),j(this,_D,{},"f");let C=["array","boolean","string","skipValidation","count","normalize","number","hiddenOptions"],E=["narg","key","alias","default","defaultDescription","config","choices","demandedOptions","demandedCommands","deprecatedOptions"];if(C.forEach((B)=>{u[B]=(z(this,f,"f")[B]||[]).filter(($)=>!F[$])}),E.forEach((B)=>{u[B]=bD(z(this,f,"f")[B],($)=>!F[$])}),u.envPrefix=z(this,f,"f").envPrefix,j(this,f,u,"f"),j(this,w,z(this,w,"f")?z(this,w,"f").reset(F):d0(this,z(this,b,"f")),"f"),j(this,n,z(this,n,"f")?z(this,n,"f").reset(F):i0(this,z(this,w,"f"),z(this,b,"f")),"f"),j(this,e,z(this,e,"f")?z(this,e,"f").reset():m0(z(this,w,"f"),z(this,n,"f"),z(this,VD,"f"),z(this,b,"f")),"f"),!z(this,JD,"f"))j(this,JD,g0(this,z(this,w,"f"),z(this,e,"f"),z(this,b,"f")),"f");return z(this,VD,"f").reset(),j(this,qD,null,"f"),j(this,$D,"","f"),j(this,wD,null,"f"),j(this,HD,!1,"f"),this.parsed=!1,this}[G2](D,u){return z(this,b,"f").path.relative(D,u)}[Uu](D,u,F,C=0,E=!1){var B,$,Z,M;let H=!!F||E;D=D||z(this,mD,"f"),z(this,f,"f").__=z(this,b,"f").y18n.__,z(this,f,"f").configuration=this[eD]();let V=!!z(this,f,"f").configuration["populate--"],Y=Object.assign({},z(this,f,"f").configuration,{"populate--":!0}),q=z(this,b,"f").Parser.detailed(D,Object.assign({},z(this,f,"f"),{configuration:{"parse-positional-numbers":!1,...Y}})),O=Object.assign(q.argv,z(this,oD,"f")),W=void 0,J=q.aliases,S=!1,d=!1;if(Object.keys(O).forEach((v)=>{if(v===z(this,TD,"f")&&O[v])S=!0;else if(v===z(this,ND,"f")&&O[v])d=!0}),O.$0=this.$0,this.parsed=q,C===0)z(this,w,"f").clearCachedHelpMessage();try{if(this[OF](),u)return this[Du](O,V,!!F,!1);if(z(this,TD,"f")){if([z(this,TD,"f")].concat(J[z(this,TD,"f")]||[]).filter((uD)=>uD.length>1).includes(""+O._[O._.length-1]))O._.pop(),S=!0}j(this,vu,!1,"f");let v=z(this,e,"f").getCommands(),QD=((B=z(this,JD,"f"))===null||B===void 0?void 0:B.completionKey)?[($=z(this,JD,"f"))===null||$===void 0?void 0:$.completionKey,...(M=this.getAliases()[(Z=z(this,JD,"f"))===null||Z===void 0?void 0:Z.completionKey])!==null&&M!==void 0?M:[]].some((l)=>Object.prototype.hasOwnProperty.call(O,l)):!1,m=S||QD||E;if(O._.length){if(v.length){let l;for(let uD=C||0,s;O._[uD]!==void 0;uD++)if(s=String(O._[uD]),v.includes(s)&&s!==z(this,qD,"f")){let jD=z(this,e,"f").runCommand(s,this,q,uD+1,E,S||d||E);return this[Du](jD,V,!!F,!1)}else if(!l&&s!==z(this,qD,"f")){l=s;break}if(!z(this,e,"f").hasDefaultCommand()&&z(this,ku,"f")&&l&&!m)z(this,n,"f").recommendCommands(l,v)}if(z(this,qD,"f")&&O._.includes(z(this,qD,"f"))&&!QD){if(z(this,WD,"f"))hD(!0);this.showCompletionScript(),this.exit(0)}}if(z(this,e,"f").hasDefaultCommand()&&!m){let l=z(this,e,"f").runCommand(null,this,q,0,E,S||d||E);return this[Du](l,V,!!F,!1)}if(QD){if(z(this,WD,"f"))hD(!0);D=[].concat(D);let l=D.slice(D.indexOf(`--${z(this,JD,"f").completionKey}`)+1);return z(this,JD,"f").getCompletion(l,(uD,s)=>{if(uD)throw new a(uD.message);(s||[]).forEach((jD)=>{z(this,iD,"f").log(jD)}),this.exit(0)}),this[Du](O,!V,!!F,!1)}if(!z(this,HD,"f")){if(S){if(z(this,WD,"f"))hD(!0);H=!0,this.showHelp((l)=>{z(this,iD,"f").log(l),this.exit(0)})}else if(d){if(z(this,WD,"f"))hD(!0);H=!0,z(this,w,"f").showVersion("log"),this.exit(0)}}if(!H&&z(this,f,"f").skipValidation.length>0)H=Object.keys(O).some((l)=>z(this,f,"f").skipValidation.indexOf(l)>=0&&O[l]===!0);if(!H){if(q.error)throw new a(q.error.message);if(!QD){let l=this[jF](J,{},q.error);if(!F)W=yD(O,this,z(this,VD,"f").getMiddleware(),!0);if(W=this[C2](l,W!==null&&W!==void 0?W:O),i(W)&&!F)W=W.then(()=>{return yD(O,this,z(this,VD,"f").getMiddleware(),!1)})}}}catch(v){if(v instanceof a)z(this,w,"f").fail(v.message,v);else throw v}return this[Du](W!==null&&W!==void 0?W:O,V,!!F,!0)}[jF](D,u,F,C){let E={...this.getDemandedOptions()};return(B)=>{if(F)throw new a(F.message);z(this,n,"f").nonOptionCount(B),z(this,n,"f").requiredArguments(B,E);let $=!1;if(z(this,rD,"f"))$=z(this,n,"f").unknownCommands(B);if(z(this,sD,"f")&&!$)z(this,n,"f").unknownArguments(B,D,u,!!C);else if(z(this,aD,"f"))z(this,n,"f").unknownArguments(B,D,{},!1,!1);z(this,n,"f").limitedChoices(B),z(this,n,"f").implications(B),z(this,n,"f").conflicting(B)}}[J2](){j(this,HD,!0,"f")}[uu](D){if(typeof D==="string")z(this,f,"f").key[D]=!0;else for(let u of D)z(this,f,"f").key[u]=!0}}function v0(D){return!!D&&typeof D.getInternalMethods==="function"}var r3=Y2(S0),H2=r3;var O2={name:"@coryrylan/cradle",version:"1.2.0",description:"A runtime for portable agents defined as folders \u2014 launches the pi coding agent configured from an agent folder, sandboxed with nono",main:"./dist/index.js",module:"./dist/index.js",types:"./dist/index.d.ts",type:"module",exports:{".":{types:"./dist/index.d.ts",default:"./dist/index.js"}},bin:{cradle:"dist/index.js"},files:["README.md","CHANGELOG.md","LICENSE","package.json","dist/index.js","dist/**/*.d.ts","!dist/**/*.test.d.ts"],repository:{type:"git",url:"git+https://github.com/coryrylan/cradle.git",directory:"projects/cli"},keywords:["pi","agents","agent-folders","sandbox","nono","cli","bun"],author:"Cory Rylan (https://coryrylan.com)",license:"MIT",bugs:{url:"https://github.com/coryrylan/cradle/issues"},homepage:"https://github.com/coryrylan/cradle/tree/main/projects/cli#readme",engines:{bun:">=1.3.0"},publishConfig:{access:"public"},scripts:{start:"wireit",ci:"wireit","ci:nocache":"bun run clean && bun run ci",clean:"rm -rf dist",test:"wireit","test:coverage":"wireit",lint:"wireit",build:"wireit","install:local":"wireit","uninstall:local":"wireit",release:"wireit"},wireit:{start:{command:"bun src/index.ts",cache:!1},ci:{dependencies:["lint","build","test:coverage"]},test:{command:"bun test",files:["src/**/*.ts","src/**/*.json","src/**/*.txt","tsconfig.json","bunfig.toml"],output:[]},"test:coverage":{command:"bun test --coverage",files:["src/**/*.ts","src/**/*.json","src/**/*.txt","tsconfig.json","bunfig.toml"],output:[]},lint:{command:"eslint .",files:["src/**/*.ts","eslint.config.js","package.json"],output:[]},build:{dependencies:["build:js","build:tsc","build:darwin-arm64","build:darwin-x64","build:linux-x64","build:linux-arm64","build:windows-x64"]},"build:js":{command:"bun build ./src/index.ts --outdir=./dist --target=bun --format=esm --minify",files:["src/**/*.ts","src/**/*.json","src/**/*.txt","tsconfig.json"],output:["dist/index.js"]},"build:tsc":{command:"tsc --emitDeclarationOnly --project tsconfig.types.json",files:["src/**/*.ts","src/**/*.json","tsconfig.json","tsconfig.types.json"],output:["dist/**/*.d.ts"]},"build:darwin-arm64":{command:"bun build --compile --minify src/index.ts --target=bun-darwin-arm64 --outfile dist/cradle-macos-arm64",files:["src/**/*.ts","src/**/*.json","src/**/*.txt","tsconfig.json"],output:["dist/cradle-macos-arm64"]},"build:darwin-x64":{command:"bun build --compile --minify src/index.ts --target=bun-darwin-x64 --outfile dist/cradle-macos-x64",files:["src/**/*.ts","src/**/*.json","src/**/*.txt","tsconfig.json"],output:["dist/cradle-macos-x64"]},"build:linux-x64":{command:"bun build --compile --minify src/index.ts --target=bun-linux-x64 --outfile dist/cradle-linux-x64",files:["src/**/*.ts","src/**/*.json","src/**/*.txt","tsconfig.json"],output:["dist/cradle-linux-x64"]},"build:linux-arm64":{command:"bun build --compile --minify src/index.ts --target=bun-linux-arm64 --outfile dist/cradle-linux-arm64",files:["src/**/*.ts","src/**/*.json","src/**/*.txt","tsconfig.json"],output:["dist/cradle-linux-arm64"]},"build:windows-x64":{command:"bun build --compile --minify src/index.ts --target=bun-windows-x64 --outfile dist/cradle-windows-x64.exe",files:["src/**/*.ts","src/**/*.json","src/**/*.txt","tsconfig.json"],output:["dist/cradle-windows-x64.exe"]},"install:local":{dependencies:["build"],command:"bash install.sh",cache:!1},"uninstall:local":{command:'rm -f "$HOME/.local/bin/cradle"',cache:!1},release:{command:"HUSKY=0 bun x semantic-release",dependencies:["ci"]}},dependencies:{yargs:"^18.0.0"},devDependencies:{"@coryrylan/tools":"1.1.0","@eslint/js":"catalog:","@eslint/json":"1.2.0","@types/bun":"catalog:","@types/yargs":"17.0.35",eslint:"catalog:","eslint-plugin-jsdoc":"63.2.0",typescript:"catalog:","typescript-eslint":"catalog:"}};import{join as W2}from"path";var gu="agent-browser-nono-fallback.ts";function U2(){return`// generated by cradle for sandboxed agent-browser processes \u2014 do not edit
74
+ `;class gi{constructor(e,n,t,r){var i,s,o;this.yargs=e,this.usage=n,this.command=t,this.shim=r,this.completionKey="get-yargs-completions",this.aliases=null,this.customCompletionFunction=null,this.indexAfterLastReset=0,this.zshShell=(o=((i=this.shim.getEnv("SHELL"))===null||i===void 0?void 0:i.includes("zsh"))||((s=this.shim.getEnv("ZSH_NAME"))===null||s===void 0?void 0:s.includes("zsh")))!==null&&o!==void 0?o:!1}defaultCompletion(e,n,t,r){let i=this.command.getCommandHandlers();for(let o=0,u=e.length;o<u;++o)if(i[e[o]]&&i[e[o]].builder){let c=i[e[o]].builder;if(Wn(c)){this.indexAfterLastReset=o+1;let p=this.yargs.getInternalMethods().reset();return c(p,!0),p.argv}}let s=[];this.commandCompletions(s,e,t),this.optionCompletions(s,e,n,t),this.choicesFromOptionsCompletions(s,e,n,t),this.choicesFromPositionalsCompletions(s,e,n,t),r(null,s)}commandCompletions(e,n,t){let r=this.yargs.getInternalMethods().getContext().commands;if(!t.match(/^-/)&&r[r.length-1]!==t&&!this.previousArgHasChoices(n))this.usage.getCommands().forEach((i)=>{let s=Re(i[0]).cmd;if(n.indexOf(s)===-1)if(!this.zshShell)e.push(s);else{let o=i[1]||"";e.push(s.replace(/:/g,"\\:")+":"+o)}})}optionCompletions(e,n,t,r){if((r.match(/^-/)||r===""&&e.length===0)&&!this.previousArgHasChoices(n)){let i=this.yargs.getOptions(),s=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[];Object.keys(i.key).forEach((o)=>{let u=!!i.configuration["boolean-negation"]&&i.boolean.includes(o);if(!s.includes(o)&&!i.hiddenOptions.includes(o)&&!this.argsContainKey(n,o,u))this.completeOptionKey(o,e,r,u&&!!i.default[o])})}}choicesFromOptionsCompletions(e,n,t,r){if(this.previousArgHasChoices(n)){let i=this.getPreviousArgChoices(n);if(i&&i.length>0)e.push(...i.map((s)=>s.replace(/:/g,"\\:")))}}choicesFromPositionalsCompletions(e,n,t,r){if(r===""&&e.length>0&&this.previousArgHasChoices(n))return;let i=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[],s=Math.max(this.indexAfterLastReset,this.yargs.getInternalMethods().getContext().commands.length+1),o=i[t._.length-s-1];if(!o)return;let u=this.yargs.getOptions().choices[o]||[];for(let c of u)if(c.startsWith(r))e.push(c.replace(/:/g,"\\:"))}getPreviousArgChoices(e){if(e.length<1)return;let n=e[e.length-1],t="";if(!n.startsWith("-")&&e.length>1)t=n,n=e[e.length-2];if(!n.startsWith("-"))return;let r=n.replace(/^-+/,""),i=this.yargs.getOptions(),s=[r,...this.yargs.getAliases()[r]||[]],o;for(let u of s)if(Object.prototype.hasOwnProperty.call(i.key,u)&&Array.isArray(i.choices[u])){o=i.choices[u];break}if(o)return o.filter((u)=>!t||u.startsWith(t))}previousArgHasChoices(e){let n=this.getPreviousArgChoices(e);return n!==void 0&&n.length>0}argsContainKey(e,n,t){let r=(i)=>e.indexOf((/^[^0-9]$/.test(i)?"-":"--")+i)!==-1;if(r(n))return!0;if(t&&r(`no-${n}`))return!0;if(this.aliases){for(let i of this.aliases[n])if(r(i))return!0}return!1}completeOptionKey(e,n,t,r){var i,s,o,u;let c=e;if(this.zshShell){let D=this.usage.getDescriptions(),F=(s=(i=this===null||this===void 0?void 0:this.aliases)===null||i===void 0?void 0:i[e])===null||s===void 0?void 0:s.find((v)=>{let W=D[v];return typeof W==="string"&&W.length>0}),y=F?D[F]:void 0,h=(u=(o=D[e])!==null&&o!==void 0?o:y)!==null&&u!==void 0?u:"";c=`${e.replace(/:/g,"\\:")}:${h.replace("__yargsString__:","").replace(/(\r\n|\n|\r)/gm," ")}`}let p=(D)=>/^--/.test(D),b=(D)=>/^[^0-9]$/.test(D),g=!p(t)&&b(e)?"-":"--";if(n.push(g+c),r)n.push(g+"no-"+c)}customCompletion(e,n,t,r){if(he(this.customCompletionFunction,null,this.shim),nu(this.customCompletionFunction)){let i=this.customCompletionFunction(t,n);if(J(i))return i.then((s)=>{this.shim.process.nextTick(()=>{r(null,s)})}).catch((s)=>{this.shim.process.nextTick(()=>{r(s,void 0)})});return r(null,i)}else if(tu(this.customCompletionFunction))return this.customCompletionFunction(t,n,(i=r)=>this.defaultCompletion(e,n,t,i),(i)=>{r(null,i)});else return this.customCompletionFunction(t,n,(i)=>{r(null,i)})}getCompletion(e,n){let t=e.length?e[e.length-1]:"",r=this.yargs.parse(e,!0),i=this.customCompletionFunction?(s)=>this.customCompletion(e,s,t,n):(s)=>this.defaultCompletion(e,s,t,n);return J(r)?r.then(i):i(r)}generateCompletionScript(e,n){let t=this.zshShell?Di:hi,r=this.shim.path.basename(e);if(e.match(/\.js$/))e=`./${e}`;return t=t.replace(/{{app_name}}/g,r),t=t.replace(/{{completion_command}}/g,n),t.replace(/{{app_path}}/g,e)}registerFunction(e){this.customCompletionFunction=e}setParsed(e){this.aliases=e.aliases}}function pi(e,n,t,r){return new gi(e,n,t,r)}function nu(e){return e.length<3}function tu(e){return e.length>3}function mi(e,n){if(e.length===0)return n.length;if(n.length===0)return e.length;let t=[],r;for(r=0;r<=n.length;r++)t[r]=[r];let i;for(i=0;i<=e.length;i++)t[0][i]=i;for(r=1;r<=n.length;r++)for(i=1;i<=e.length;i++)if(n.charAt(r-1)===e.charAt(i-1))t[r][i]=t[r-1][i-1];else if(r>1&&i>1&&n.charAt(r-2)===e.charAt(i-1)&&n.charAt(r-1)===e.charAt(i-2))t[r][i]=t[r-2][i-2]+1;else t[r][i]=Math.min(t[r-1][i-1]+1,Math.min(t[r][i-1]+1,t[r-1][i]+1));return t[n.length][e.length]}var Fi=["$0","--","_"];function yi(e,n,t){let r=t.y18n.__,i=t.y18n.__n,s={};s.nonOptionCount=function(g){let D=e.getDemandedCommands(),y=g._.length+(g["--"]?g["--"].length:0)-e.getInternalMethods().getContext().commands.length;if(D._&&(y<D._.min||y>D._.max)){if(y<D._.min)if(D._.minMsg!==void 0)n.fail(D._.minMsg?D._.minMsg.replace(/\$0/g,y.toString()).replace(/\$1/,D._.min.toString()):null);else n.fail(i("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",y,y.toString(),D._.min.toString()));else if(y>D._.max)if(D._.maxMsg!==void 0)n.fail(D._.maxMsg?D._.maxMsg.replace(/\$0/g,y.toString()).replace(/\$1/,D._.max.toString()):null);else n.fail(i("Too many non-option arguments: got %s, maximum of %s","Too many non-option arguments: got %s, maximum of %s",y,y.toString(),D._.max.toString()))}},s.positionalCount=function(g,D){if(D<g)n.fail(i("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",D,D+"",g+""))},s.requiredArguments=function(g,D){let F=null;for(let y of Object.keys(D))if(!Object.prototype.hasOwnProperty.call(g,y)||typeof g[y]>"u")F=F||{},F[y]=D[y];if(F){let y=[];for(let v of Object.keys(F)){let W=F[v];if(W&&y.indexOf(W)<0)y.push(W)}let h=y.length?`
75
+ ${y.join(`
76
+ `)}`:"";n.fail(i("Missing required argument: %s","Missing required arguments: %s",Object.keys(F).length,Object.keys(F).join(", ")+h))}},s.unknownArguments=function(g,D,F,y,h=!0){var v;let W=e.getInternalMethods().getCommandInstance().getCommands(),T=[],ce=e.getInternalMethods().getContext();if(Object.keys(g).forEach((I)=>{if(!Fi.includes(I)&&!Object.prototype.hasOwnProperty.call(F,I)&&!Object.prototype.hasOwnProperty.call(e.getInternalMethods().getParseContext(),I)&&!s.isValidAndSomeAliasIsNotNew(I,D))T.push(I)}),h&&(ce.commands.length>0||W.length>0||y))g._.slice(ce.commands.length).forEach((I)=>{if(!W.includes(""+I))T.push(""+I)});if(h){let Y=((v=e.getDemandedCommands()._)===null||v===void 0?void 0:v.max)||0,te=ce.commands.length+Y;if(te<g._.length)g._.slice(te).forEach((X)=>{if(X=String(X),!ce.commands.includes(X)&&!T.includes(X))T.push(X)})}if(T.length)n.fail(i("Unknown argument: %s","Unknown arguments: %s",T.length,T.map((I)=>I.trim()?I:`"${I}"`).join(", ")))},s.unknownCommands=function(g){let D=e.getInternalMethods().getCommandInstance().getCommands(),F=[],y=e.getInternalMethods().getContext();if(y.commands.length>0||D.length>0)g._.slice(y.commands.length).forEach((h)=>{if(!D.includes(""+h))F.push(""+h)});if(F.length>0)return n.fail(i("Unknown command: %s","Unknown commands: %s",F.length,F.join(", "))),!0;else return!1},s.isValidAndSomeAliasIsNotNew=function(g,D){if(!Object.prototype.hasOwnProperty.call(D,g))return!1;let F=e.parsed.newAliases;return[g,...D[g]].some((y)=>!Object.prototype.hasOwnProperty.call(F,y)||!F[g])},s.limitedChoices=function(g){let D=e.getOptions(),F={};if(!Object.keys(D.choices).length)return;Object.keys(g).forEach((v)=>{if(Fi.indexOf(v)===-1&&Object.prototype.hasOwnProperty.call(D.choices,v))[].concat(g[v]).forEach((W)=>{if(D.choices[v].indexOf(W)===-1&&W!==void 0)F[v]=(F[v]||[]).concat(W)})});let y=Object.keys(F);if(!y.length)return;let h=r("Invalid values:");y.forEach((v)=>{h+=`
77
+ ${r("Argument: %s, Given: %s, Choices: %s",v,n.stringifiedValues(F[v]),n.stringifiedValues(D.choices[v]))}`}),n.fail(h)};let o={};s.implies=function(g,D){if(x("<string|object> [array|number|string]",[g,D],arguments.length),typeof g==="object")Object.keys(g).forEach((F)=>{s.implies(F,g[F])});else{if(e.global(g),!o[g])o[g]=[];if(Array.isArray(D))D.forEach((F)=>s.implies(g,F));else he(D,void 0,t),o[g].push(D)}},s.getImplied=function(){return o};function u(b,g){let D=Number(g);if(g=isNaN(D)?g:D,typeof g==="number")g=b._.length>=g;else if(g.match(/^--no-.+/))g=g.match(/^--no-(.+)/)[1],g=!Object.prototype.hasOwnProperty.call(b,g);else g=Object.prototype.hasOwnProperty.call(b,g);return g}s.implications=function(g){let D=[];if(Object.keys(o).forEach((F)=>{let y=F;(o[F]||[]).forEach((h)=>{let v=y,W=h;if(v=u(g,v),h=u(g,h),v&&!h)D.push(` ${y} -> ${W}`)})}),D.length){let F=`${r("Implications failed:")}
78
+ `;D.forEach((y)=>{F+=y}),n.fail(F)}};let c={};s.conflicts=function(g,D){if(x("<string|object> [array|string]",[g,D],arguments.length),typeof g==="object")Object.keys(g).forEach((F)=>{s.conflicts(F,g[F])});else{if(e.global(g),!c[g])c[g]=[];if(Array.isArray(D))D.forEach((F)=>s.conflicts(g,F));else c[g].push(D)}},s.getConflicting=()=>c,s.conflicting=function(g){if(Object.keys(g).forEach((D)=>{if(c[D])c[D].forEach((F)=>{if(F&&g[D]!==void 0&&g[F]!==void 0)n.fail(r("Arguments %s and %s are mutually exclusive",D,F))})}),e.getInternalMethods().getParserConfiguration()["strip-dashed"])Object.keys(c).forEach((D)=>{c[D].forEach((F)=>{if(F&&g[t.Parser.camelCase(D)]!==void 0&&g[t.Parser.camelCase(F)]!==void 0)n.fail(r("Arguments %s and %s are mutually exclusive",D,F))})})},s.recommendCommands=function(g,D){D=D.sort((v,W)=>W.length-v.length);let y=null,h=1/0;for(let v=0,W;(W=D[v])!==void 0;v++){let T=mi(g,W);if(T<=3&&T<h)h=T,y=W}if(y)n.fail(r("Did you mean %s?",y))},s.reset=function(g){return o=Ie(o,(D)=>!g[D]),c=Ie(c,(D)=>!g[D]),s};let p=[];return s.freeze=function(){p.push({implied:o,conflicting:c})},s.unfreeze=function(){let g=p.pop();he(g,void 0,t),{implied:o,conflicting:c}=g},s}var jt=[],An;function Vn(e,n,t,r){An=r;let i={};if(Object.prototype.hasOwnProperty.call(e,"extends")){if(typeof e.extends!=="string")return i;let s=/\.json|\..*rc$/.test(e.extends),o=null;if(!s)try{o=import.meta.resolve(e.extends)}catch(u){return e}else o=iu(n,e.extends);ru(o),jt.push(o),i=s?JSON.parse(An.readFileSync(o,"utf8")):r.require(e.extends),delete e.extends,i=Vn(i,An.path.dirname(o),t,An)}return jt=[],t?bi(i,e):Object.assign({},i,e)}function ru(e){if(jt.indexOf(e)>-1)throw new Q(`Circular extended configurations: '${e}'.`)}function iu(e,n){return An.path.resolve(e,n)}function bi(e,n){let t={};function r(i){return i&&typeof i==="object"&&!Array.isArray(i)}Object.assign(t,e);for(let i of Object.keys(n)){if(i==="__proto__")continue;if(r(n[i])&&r(t[i]))t[i]=bi(e[i],n[i]);else t[i]=n[i]}return t}var S=function(e,n,t,r,i){if(r==="m")throw TypeError("Private method is not writable");if(r==="a"&&!i)throw TypeError("Private accessor was defined without a setter");if(typeof n==="function"?e!==n||!i:!n.has(e))throw TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?i.call(e,t):i?i.value=t:n.set(e,t),t},a=function(e,n,t,r){if(t==="a"&&!r)throw TypeError("Private accessor was defined without a getter");if(typeof n==="function"?e!==n||!r:!n.has(e))throw TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?r:t==="a"?r.call(e):r?r.value:n.get(e)},ee,Xe,Pn,De,pe,zn,Le,Ze,Gn,be,Un,Ee,_e,me,Ce,Yn,Qe,ae,B,Jn,Kn,Fe,en,gn,nn,We,qn,M,tn,rn,sn,R,Xn,Be,q;function Li(e){return(n=[],t=e.process.cwd(),r)=>{let i=new Wi(n,t,r,e);return Object.defineProperty(i,"argv",{get:()=>i.parse(),enumerable:!0}),i.help(),i.version(),i}}var Ei=Symbol("copyDoubleDash"),Ci=Symbol("copyDoubleDash"),kt=Symbol("deleteFromParserHintObject"),wi=Symbol("emitWarning"),xi=Symbol("freeze"),Si=Symbol("getDollarZero"),on=Symbol("getParserConfiguration"),Ai=Symbol("getUsageConfiguration"),Mt=Symbol("guessLocale"),Pi=Symbol("guessVersion"),_i=Symbol("parsePositionalNumbers"),Nt=Symbol("pkgUp"),He=Symbol("populateParserHintArray"),pn=Symbol("populateParserHintSingleValueDictionary"),Rt=Symbol("populateParserHintArrayDictionary"),It=Symbol("populateParserHintDictionary"),Tt=Symbol("sanitizeKey"),Lt=Symbol("setKey"),Wt=Symbol("unfreeze"),Bi=Symbol("validateAsync"),Oi=Symbol("getCommandInstance"),$i=Symbol("getContext"),vi=Symbol("getHasOutput"),ji=Symbol("getLoggerInstance"),ki=Symbol("getParseContext"),Mi=Symbol("getUsageInstance"),Ni=Symbol("getValidationInstance"),Zn=Symbol("hasParseCallback"),Ri=Symbol("isGlobalContext"),an=Symbol("postProcess"),Ii=Symbol("rebase"),Ht=Symbol("reset"),_n=Symbol("runYargsParserAndExecuteCommands"),Vt=Symbol("runValidation"),Ti=Symbol("setHasOutput"),un=Symbol("kTrackManuallySetKeys"),su="en_US";class Wi{constructor(e=[],n,t,r){this.customScriptName=!1,this.parsed=!1,ee.set(this,void 0),Xe.set(this,void 0),Pn.set(this,{commands:[],fullCommands:[]}),De.set(this,null),pe.set(this,null),zn.set(this,"show-hidden"),Le.set(this,null),Ze.set(this,!0),Gn.set(this,{}),be.set(this,!0),Un.set(this,[]),Ee.set(this,void 0),_e.set(this,{}),me.set(this,!1),Ce.set(this,null),Yn.set(this,!0),Qe.set(this,void 0),ae.set(this,""),B.set(this,void 0),Jn.set(this,void 0),Kn.set(this,{}),Fe.set(this,null),en.set(this,null),gn.set(this,{}),nn.set(this,{}),We.set(this,void 0),qn.set(this,!1),M.set(this,void 0),tn.set(this,!1),rn.set(this,!1),sn.set(this,!1),R.set(this,void 0),Xn.set(this,{}),Be.set(this,null),q.set(this,void 0),S(this,M,r,"f"),S(this,We,e,"f"),S(this,Xe,n,"f"),S(this,Jn,t,"f"),S(this,Ee,new $t(this),"f"),this.$0=this[Si](),this[Ht](),S(this,ee,a(this,ee,"f"),"f"),S(this,R,a(this,R,"f"),"f"),S(this,q,a(this,q,"f"),"f"),S(this,B,a(this,B,"f"),"f"),a(this,B,"f").showHiddenOpt=a(this,zn,"f"),S(this,Qe,this[Ci](),"f"),a(this,M,"f").y18n.setLocale(su)}addHelpOpt(e,n){if(x("[string|boolean] [string]",[e,n],arguments.length),a(this,Ce,"f"))this[kt](a(this,Ce,"f")),S(this,Ce,null,"f");if(e===!1&&n===void 0)return this;return S(this,Ce,typeof e==="string"?e:"help","f"),this.boolean(a(this,Ce,"f")),this.describe(a(this,Ce,"f"),n||a(this,R,"f").deferY18nLookup("Show help")),this}help(e,n){return this.addHelpOpt(e,n)}addShowHiddenOpt(e,n){if(x("[string|boolean] [string]",[e,n],arguments.length),e===!1&&n===void 0)return this;let t=typeof e==="string"?e:a(this,zn,"f");return this.boolean(t),this.describe(t,n||a(this,R,"f").deferY18nLookup("Show hidden options")),a(this,B,"f").showHiddenOpt=t,this}showHidden(e,n){return this.addShowHiddenOpt(e,n)}alias(e,n){return x("<object|string|array> [string|array]",[e,n],arguments.length),this[Rt](this.alias.bind(this),"alias",e,n),this}array(e){return x("<array|string>",[e],arguments.length),this[He]("array",e),this[un](e),this}boolean(e){return x("<array|string>",[e],arguments.length),this[He]("boolean",e),this[un](e),this}check(e,n){return x("<function> [boolean]",[e,n],arguments.length),this.middleware((t,r)=>qe(()=>e(t,r.getOptions()),(i)=>{if(!i)a(this,R,"f").fail(a(this,M,"f").y18n.__("Argument check failed: %s",e.toString()));else if(typeof i==="string"||i instanceof Error)a(this,R,"f").fail(i.toString(),i);return t},(i)=>(a(this,R,"f").fail(i.message?i.message:i.toString(),i),t)),!1,n),this}choices(e,n){return x("<object|string|array> [string|array]",[e,n],arguments.length),this[Rt](this.choices.bind(this),"choices",e,n),this}coerce(e,n){if(x("<object|string|array> [function]",[e,n],arguments.length),Array.isArray(e)){if(!n)throw new Q("coerce callback must be provided");for(let r of e)this.coerce(r,n);return this}else if(typeof e==="object"){for(let r of Object.keys(e))this.coerce(r,e[r]);return this}if(!n)throw new Q("coerce callback must be provided");let t=e;return a(this,B,"f").key[t]=!0,a(this,Ee,"f").addCoerceMiddleware((r,i)=>{var s;let o=(s=i.getAliases()[t])!==null&&s!==void 0?s:[],u=[t,...o].filter((c)=>Object.prototype.hasOwnProperty.call(r,c));if(u.length===0)return r;return qe(()=>n(r[u[0]]),(c)=>(u.forEach((p)=>{r[p]=c}),r),(c)=>{throw new Q(c.message)})},t),this}conflicts(e,n){return x("<string|object> [string|array]",[e,n],arguments.length),a(this,q,"f").conflicts(e,n),this}config(e="config",n,t){if(x("[object|string] [string|function] [function]",[e,n,t],arguments.length),typeof e==="object"&&!Array.isArray(e))return e=Vn(e,a(this,Xe,"f"),this[on]()["deep-merge-config"]||!1,a(this,M,"f")),a(this,B,"f").configObjects=(a(this,B,"f").configObjects||[]).concat(e),this;if(typeof n==="function")t=n,n=void 0;return this.describe(e,n||a(this,R,"f").deferY18nLookup("Path to JSON config file")),(Array.isArray(e)?e:[e]).forEach((r)=>{a(this,B,"f").config[r]=t||!0}),this}completion(e,n,t){if(x("[string] [string|boolean|function] [function]",[e,n,t],arguments.length),typeof n==="function")t=n,n=void 0;if(S(this,pe,e||a(this,pe,"f")||"completion","f"),!n&&n!==!1)n="generate completion script";if(this.command(a(this,pe,"f"),n),t)a(this,De,"f").registerFunction(t);return this}command(e,n,t,r,i,s){return x("<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]",[e,n,t,r,i,s],arguments.length),a(this,ee,"f").addHandler(e,n,t,r,i,s),this}commands(e,n,t,r,i,s){return this.command(e,n,t,r,i,s)}commandDir(e,n){x("<string> [object]",[e,n],arguments.length);let t=a(this,Jn,"f")||a(this,M,"f").require;return a(this,ee,"f").addDirectory(e,t,a(this,M,"f").getCallerFile(),n),this}count(e){return x("<array|string>",[e],arguments.length),this[He]("count",e),this[un](e),this}default(e,n,t){if(x("<object|string|array> [*] [string]",[e,n,t],arguments.length),t)Ot(e,a(this,M,"f")),a(this,B,"f").defaultDescription[e]=t;if(typeof n==="function"){if(Ot(e,a(this,M,"f")),!a(this,B,"f").defaultDescription[e])a(this,B,"f").defaultDescription[e]=a(this,R,"f").functionDescription(n);n=n.call()}return this[pn](this.default.bind(this),"default",e,n),this}defaults(e,n,t){return this.default(e,n,t)}demandCommand(e=1,n,t,r){if(x("[number] [number|string] [string|null|undefined] [string|null|undefined]",[e,n,t,r],arguments.length),typeof n!=="number")t=n,n=1/0;return this.global("_",!1),a(this,B,"f").demandedCommands._={min:e,max:n,minMsg:t,maxMsg:r},this}demand(e,n,t){if(Array.isArray(n))n.forEach((r)=>{he(t,!0,a(this,M,"f")),this.demandOption(r,t)}),n=1/0;else if(typeof n!=="number")t=n,n=1/0;if(typeof e==="number")he(t,!0,a(this,M,"f")),this.demandCommand(e,n,t,t);else if(Array.isArray(e))e.forEach((r)=>{he(t,!0,a(this,M,"f")),this.demandOption(r,t)});else if(typeof t==="string")this.demandOption(e,t);else if(t===!0||typeof t>"u")this.demandOption(e);return this}demandOption(e,n){return x("<object|string|array> [string]",[e,n],arguments.length),this[pn](this.demandOption.bind(this),"demandedOptions",e,n),this}deprecateOption(e,n){return x("<string> [string|boolean]",[e,n],arguments.length),a(this,B,"f").deprecatedOptions[e]=n,this}describe(e,n){return x("<object|string|array> [string]",[e,n],arguments.length),this[Lt](e,!0),a(this,R,"f").describe(e,n),this}detectLocale(e){return x("<boolean>",[e],arguments.length),S(this,Ze,e,"f"),this}env(e){if(x("[string|boolean]",[e],arguments.length),e===!1)delete a(this,B,"f").envPrefix;else a(this,B,"f").envPrefix=e||"";return this}epilogue(e){return x("<string>",[e],arguments.length),a(this,R,"f").epilog(e),this}epilog(e){return this.epilogue(e)}example(e,n){if(x("<string|array> [string]",[e,n],arguments.length),Array.isArray(e))e.forEach((t)=>this.example(...t));else a(this,R,"f").example(e,n);return this}exit(e,n){if(S(this,me,!0,"f"),S(this,Le,n,"f"),a(this,be,"f"))a(this,M,"f").process.exit(e)}exitProcess(e=!0){return x("[boolean]",[e],arguments.length),S(this,be,e,"f"),this}fail(e){if(x("<function|boolean>",[e],arguments.length),typeof e==="boolean"&&e!==!1)throw new Q("Invalid first argument. Expected function or boolean 'false'");return a(this,R,"f").failFn(e),this}getAliases(){return this.parsed?this.parsed.aliases:{}}async getCompletion(e,n){if(x("<array> [function]",[e,n],arguments.length),!n)return new Promise((t,r)=>{a(this,De,"f").getCompletion(e,(i,s)=>{if(i)r(i);else t(s)})});else return a(this,De,"f").getCompletion(e,n)}getDemandedOptions(){return x([],0),a(this,B,"f").demandedOptions}getDemandedCommands(){return x([],0),a(this,B,"f").demandedCommands}getDeprecatedOptions(){return x([],0),a(this,B,"f").deprecatedOptions}getDetectLocale(){return a(this,Ze,"f")}getExitProcess(){return a(this,be,"f")}getGroups(){return Object.assign({},a(this,_e,"f"),a(this,nn,"f"))}getHelp(){if(S(this,me,!0,"f"),!a(this,R,"f").hasCachedHelpMessage()){if(!this.parsed){let n=this[_n](a(this,We,"f"),void 0,void 0,0,!0);if(J(n))return n.then(()=>a(this,R,"f").help())}let e=a(this,ee,"f").runDefaultBuilderOn(this);if(J(e))return e.then(()=>a(this,R,"f").help())}return Promise.resolve(a(this,R,"f").help())}getOptions(){return a(this,B,"f")}getStrict(){return a(this,tn,"f")}getStrictCommands(){return a(this,rn,"f")}getStrictOptions(){return a(this,sn,"f")}global(e,n){if(x("<string|array> [boolean]",[e,n],arguments.length),e=[].concat(e),n!==!1)a(this,B,"f").local=a(this,B,"f").local.filter((t)=>e.indexOf(t)===-1);else e.forEach((t)=>{if(!a(this,B,"f").local.includes(t))a(this,B,"f").local.push(t)});return this}group(e,n){x("<string|array> <string>",[e,n],arguments.length);let t=a(this,nn,"f")[n]||a(this,_e,"f")[n];if(a(this,nn,"f")[n])delete a(this,nn,"f")[n];let r={};return a(this,_e,"f")[n]=(t||[]).concat(e).filter((i)=>{if(r[i])return!1;return r[i]=!0}),this}hide(e){return x("<string>",[e],arguments.length),a(this,B,"f").hiddenOptions.push(e),this}implies(e,n){return x("<string|object> [number|string|array]",[e,n],arguments.length),a(this,q,"f").implies(e,n),this}locale(e){if(x("[string]",[e],arguments.length),e===void 0)return this[Mt](),a(this,M,"f").y18n.getLocale();return S(this,Ze,!1,"f"),a(this,M,"f").y18n.setLocale(e),this}middleware(e,n,t){return a(this,Ee,"f").addMiddleware(e,!!n,t)}nargs(e,n){return x("<string|object|array> [number]",[e,n],arguments.length),this[pn](this.nargs.bind(this),"narg",e,n),this}normalize(e){return x("<array|string>",[e],arguments.length),this[He]("normalize",e),this}number(e){return x("<array|string>",[e],arguments.length),this[He]("number",e),this[un](e),this}option(e,n){if(x("<string|object> [object]",[e,n],arguments.length),typeof e==="object")Object.keys(e).forEach((t)=>{this.options(t,e[t])});else{if(typeof n!=="object")n={};if(this[un](e),a(this,Be,"f")&&(e==="version"||(n===null||n===void 0?void 0:n.alias)==="version"))this[wi](['"version" is a reserved word.',"Please do one of the following:",'- Disable version with `yargs.version(false)` if using "version" as an option',"- Use the built-in `yargs.version` method instead (if applicable)","- Use a different option key","https://yargs.js.org/docs/#api-reference-version"].join(`
79
+ `),void 0,"versionWarning");if(a(this,B,"f").key[e]=!0,n.alias)this.alias(e,n.alias);let t=n.deprecate||n.deprecated;if(t)this.deprecateOption(e,t);let r=n.demand||n.required||n.require;if(r)this.demand(e,r);if(n.demandOption)this.demandOption(e,typeof n.demandOption==="string"?n.demandOption:void 0);if(n.conflicts)this.conflicts(e,n.conflicts);if("default"in n)this.default(e,n.default);if(n.implies!==void 0)this.implies(e,n.implies);if(n.nargs!==void 0)this.nargs(e,n.nargs);if(n.config)this.config(e,n.configParser);if(n.normalize)this.normalize(e);if(n.choices)this.choices(e,n.choices);if(n.coerce)this.coerce(e,n.coerce);if(n.group)this.group(e,n.group);if(n.boolean||n.type==="boolean"){if(this.boolean(e),n.alias)this.boolean(n.alias)}if(n.array||n.type==="array"){if(this.array(e),n.alias)this.array(n.alias)}if(n.number||n.type==="number"){if(this.number(e),n.alias)this.number(n.alias)}if(n.string||n.type==="string"){if(this.string(e),n.alias)this.string(n.alias)}if(n.count||n.type==="count")this.count(e);if(typeof n.global==="boolean")this.global(e,n.global);if(n.defaultDescription)a(this,B,"f").defaultDescription[e]=n.defaultDescription;if(n.skipValidation)this.skipValidation(e);let i=n.describe||n.description||n.desc,s=a(this,R,"f").getDescriptions();if(!Object.prototype.hasOwnProperty.call(s,e)||typeof i==="string")this.describe(e,i);if(n.hidden)this.hide(e);if(n.requiresArg)this.requiresArg(e)}return this}options(e,n){return this.option(e,n)}parse(e,n,t){if(x("[string|array] [function|boolean|object] [function]",[e,n,t],arguments.length),this[xi](),typeof e>"u")e=a(this,We,"f");if(typeof n==="object")S(this,en,n,"f"),n=t;if(typeof n==="function")S(this,Fe,n,"f"),n=!1;if(!n)S(this,We,e,"f");if(a(this,Fe,"f"))S(this,be,!1,"f");let r=this[_n](e,!!n),i=this.parsed;if(a(this,De,"f").setParsed(this.parsed),J(r))return r.then((s)=>{if(a(this,Fe,"f"))a(this,Fe,"f").call(this,a(this,Le,"f"),s,a(this,ae,"f"));return s}).catch((s)=>{if(a(this,Fe,"f"))a(this,Fe,"f")(s,this.parsed.argv,a(this,ae,"f"));throw s}).finally(()=>{this[Wt](),this.parsed=i});else{if(a(this,Fe,"f"))a(this,Fe,"f").call(this,a(this,Le,"f"),r,a(this,ae,"f"));this[Wt](),this.parsed=i}return r}parseAsync(e,n,t){let r=this.parse(e,n,t);return!J(r)?Promise.resolve(r):r}parseSync(e,n,t){let r=this.parse(e,n,t);if(J(r))throw new Q(".parseSync() must not be used with asynchronous builders, handlers, or middleware");return r}parserConfiguration(e){return x("<object>",[e],arguments.length),S(this,Kn,e,"f"),this}pkgConf(e,n){x("<string> [string]",[e,n],arguments.length);let t=null,r=this[Nt](n||a(this,Xe,"f"));if(r[e]&&typeof r[e]==="object")t=Vn(r[e],n||a(this,Xe,"f"),this[on]()["deep-merge-config"]||!1,a(this,M,"f")),a(this,B,"f").configObjects=(a(this,B,"f").configObjects||[]).concat(t);return this}positional(e,n){x("<string> <object>",[e,n],arguments.length);let t=["default","defaultDescription","implies","normalize","choices","conflicts","coerce","type","describe","desc","description","alias"];n=Ie(n,(s,o)=>{if(s==="type"&&!["string","number","boolean"].includes(o))return!1;return t.includes(s)});let r=a(this,Pn,"f").fullCommands[a(this,Pn,"f").fullCommands.length-1],i=r?a(this,ee,"f").cmdToParseOptions(r):{array:[],alias:{},default:{},demand:{}};return hn(i).forEach((s)=>{let o=i[s];if(Array.isArray(o)){if(o.indexOf(e)!==-1)n[s]=!0}else if(o[e]&&!(s in n))n[s]=o[e]}),this.group(e,a(this,R,"f").getPositionalGroupName()),this.option(e,n)}recommendCommands(e=!0){return x("[boolean]",[e],arguments.length),S(this,qn,e,"f"),this}required(e,n,t){return this.demand(e,n,t)}require(e,n,t){return this.demand(e,n,t)}requiresArg(e){if(x("<array|string|object> [number]",[e],arguments.length),typeof e==="string"&&a(this,B,"f").narg[e])return this;else this[pn](this.requiresArg.bind(this),"narg",e,NaN);return this}showCompletionScript(e,n){return x("[string] [string]",[e,n],arguments.length),e=e||this.$0,a(this,Qe,"f").log(a(this,De,"f").generateCompletionScript(e,n||a(this,pe,"f")||"completion")),this}showHelp(e){if(x("[string|function]",[e],arguments.length),S(this,me,!0,"f"),!a(this,R,"f").hasCachedHelpMessage()){if(!this.parsed){let t=this[_n](a(this,We,"f"),void 0,void 0,0,!0);if(J(t))return t.then(()=>{a(this,R,"f").showHelp(e)}),this}let n=a(this,ee,"f").runDefaultBuilderOn(this);if(J(n))return n.then(()=>{a(this,R,"f").showHelp(e)}),this}return a(this,R,"f").showHelp(e),this}scriptName(e){return this.customScriptName=!0,this.$0=e,this}showHelpOnFail(e,n){return x("[boolean|string] [string]",[e,n],arguments.length),a(this,R,"f").showHelpOnFail(e,n),this}showVersion(e){return x("[string|function]",[e],arguments.length),a(this,R,"f").showVersion(e),this}skipValidation(e){return x("<array|string>",[e],arguments.length),this[He]("skipValidation",e),this}strict(e){return x("[boolean]",[e],arguments.length),S(this,tn,e!==!1,"f"),this}strictCommands(e){return x("[boolean]",[e],arguments.length),S(this,rn,e!==!1,"f"),this}strictOptions(e){return x("[boolean]",[e],arguments.length),S(this,sn,e!==!1,"f"),this}string(e){return x("<array|string>",[e],arguments.length),this[He]("string",e),this[un](e),this}terminalWidth(){return x([],0),a(this,M,"f").process.stdColumns}updateLocale(e){return this.updateStrings(e)}updateStrings(e){return x("<object>",[e],arguments.length),S(this,Ze,!1,"f"),a(this,M,"f").y18n.updateLocale(e),this}usage(e,n,t,r){if(x("<string|null|undefined> [string|boolean] [function|object] [function]",[e,n,t,r],arguments.length),n!==void 0)if(he(e,null,a(this,M,"f")),(e||"").match(/^\$0( |$)/))return this.command(e,n,t,r);else throw new Q(".usage() description must start with $0 if being used as alias for .command()");else return a(this,R,"f").usage(e),this}usageConfiguration(e){return x("<object>",[e],arguments.length),S(this,Xn,e,"f"),this}version(e,n,t){if(x("[boolean|string] [string] [string]",[e,n,t],arguments.length),a(this,Be,"f"))this[kt](a(this,Be,"f")),a(this,R,"f").version(void 0),S(this,Be,null,"f");if(arguments.length===0)t=this[Pi](),e="version";else if(arguments.length===1){if(e===!1)return this;t=e,e="version"}else if(arguments.length===2)t=n,n=void 0;return S(this,Be,typeof e==="string"?e:"version","f"),n=n||a(this,R,"f").deferY18nLookup("Show version number"),a(this,R,"f").version(t||void 0),this.boolean(a(this,Be,"f")),this.describe(a(this,Be,"f"),n),this}wrap(e){return x("<number|null|undefined>",[e],arguments.length),a(this,R,"f").wrap(e),this}[(ee=new WeakMap,Xe=new WeakMap,Pn=new WeakMap,De=new WeakMap,pe=new WeakMap,zn=new WeakMap,Le=new WeakMap,Ze=new WeakMap,Gn=new WeakMap,be=new WeakMap,Un=new WeakMap,Ee=new WeakMap,_e=new WeakMap,me=new WeakMap,Ce=new WeakMap,Yn=new WeakMap,Qe=new WeakMap,ae=new WeakMap,B=new WeakMap,Jn=new WeakMap,Kn=new WeakMap,Fe=new WeakMap,en=new WeakMap,gn=new WeakMap,nn=new WeakMap,We=new WeakMap,qn=new WeakMap,M=new WeakMap,tn=new WeakMap,rn=new WeakMap,sn=new WeakMap,R=new WeakMap,Xn=new WeakMap,Be=new WeakMap,q=new WeakMap,Ei)](e){if(!e._||!e["--"])return e;e._.push.apply(e._,e["--"]);try{delete e["--"]}catch(n){}return e}[Ci](){return{log:(...e)=>{if(!this[Zn]())console.log(...e);if(S(this,me,!0,"f"),a(this,ae,"f").length)S(this,ae,a(this,ae,"f")+`
80
+ `,"f");S(this,ae,a(this,ae,"f")+e.join(" "),"f")},error:(...e)=>{if(!this[Zn]())console.error(...e);if(S(this,me,!0,"f"),a(this,ae,"f").length)S(this,ae,a(this,ae,"f")+`
81
+ `,"f");S(this,ae,a(this,ae,"f")+e.join(" "),"f")}}}[kt](e){hn(a(this,B,"f")).forEach((n)=>{if(((r)=>r==="configObjects")(n))return;let t=a(this,B,"f")[n];if(Array.isArray(t)){if(t.includes(e))t.splice(t.indexOf(e),1)}else if(typeof t==="object")delete t[e]}),delete a(this,R,"f").getDescriptions()[e]}[wi](e,n,t){if(!a(this,Gn,"f")[t])a(this,M,"f").process.emitWarning(e,n),a(this,Gn,"f")[t]=!0}[xi](){a(this,Un,"f").push({options:a(this,B,"f"),configObjects:a(this,B,"f").configObjects.slice(0),exitProcess:a(this,be,"f"),groups:a(this,_e,"f"),strict:a(this,tn,"f"),strictCommands:a(this,rn,"f"),strictOptions:a(this,sn,"f"),completionCommand:a(this,pe,"f"),output:a(this,ae,"f"),exitError:a(this,Le,"f"),hasOutput:a(this,me,"f"),parsed:this.parsed,parseFn:a(this,Fe,"f"),parseContext:a(this,en,"f")}),a(this,R,"f").freeze(),a(this,q,"f").freeze(),a(this,ee,"f").freeze(),a(this,Ee,"f").freeze()}[Si](){let e="",n;if(/\b(node|iojs|electron|bun)(\.exe)?$/.test(a(this,M,"f").process.argv()[0]))n=a(this,M,"f").process.argv().slice(1,2);else n=a(this,M,"f").process.argv().slice(0,1);if(e=n.map((t)=>{let r=this[Ii](a(this,Xe,"f"),t);return t.match(/^(\/|([a-zA-Z]:)?\\)/)&&r.length<t.length?r:t}).join(" ").trim(),a(this,M,"f").getEnv("_")&&a(this,M,"f").getProcessArgvBin()===a(this,M,"f").getEnv("_"))e=a(this,M,"f").getEnv("_").replace(`${a(this,M,"f").path.dirname(a(this,M,"f").process.execPath())}/`,"");return e}[on](){return a(this,Kn,"f")}[Ai](){return a(this,Xn,"f")}[Mt](){if(!a(this,Ze,"f"))return;let e=a(this,M,"f").getEnv("LC_ALL")||a(this,M,"f").getEnv("LC_MESSAGES")||a(this,M,"f").getEnv("LANG")||a(this,M,"f").getEnv("LANGUAGE")||"en_US";this.locale(e.replace(/[.:].*/,""))}[Pi](){return this[Nt]().version||"unknown"}[_i](e){let n=e["--"]?e["--"]:e._;for(let t=0,r;(r=n[t])!==void 0;t++)if(a(this,M,"f").Parser.looksLikeNumber(r)&&Number.isSafeInteger(Math.floor(parseFloat(`${r}`))))n[t]=Number(r);return e}[Nt](e){let n=e||"*";if(a(this,gn,"f")[n])return a(this,gn,"f")[n];let t={};try{let r=e||a(this,M,"f").mainFilename;if(a(this,M,"f").path.extname(r))r=a(this,M,"f").path.dirname(r);let i=a(this,M,"f").findUp(r,(s,o)=>{if(o.includes("package.json"))return"package.json";else return});he(i,void 0,a(this,M,"f")),t=JSON.parse(a(this,M,"f").readFileSync(i,"utf8"))}catch(r){}return a(this,gn,"f")[n]=t||{},a(this,gn,"f")[n]}[He](e,n){n=[].concat(n),n.forEach((t)=>{t=this[Tt](t),a(this,B,"f")[e].push(t)})}[pn](e,n,t,r){this[It](e,n,t,r,(i,s,o)=>{a(this,B,"f")[i][s]=o})}[Rt](e,n,t,r){this[It](e,n,t,r,(i,s,o)=>{a(this,B,"f")[i][s]=(a(this,B,"f")[i][s]||[]).concat(o)})}[It](e,n,t,r,i){if(Array.isArray(t))t.forEach((s)=>{e(s,r)});else if(((s)=>typeof s==="object")(t))for(let s of hn(t))e(s,t[s]);else i(n,this[Tt](t),r)}[Tt](e){if(e==="__proto__")return"___proto___";return e}[Lt](e,n){return this[pn](this[Lt].bind(this),"key",e,n),this}[Wt](){var e,n,t,r,i,s,o,u,c,p,b,g;let D=a(this,Un,"f").pop();he(D,void 0,a(this,M,"f"));let F;e=this,n=this,t=this,r=this,i=this,s=this,o=this,u=this,c=this,p=this,b=this,g=this,{options:{set value(y){S(e,B,y,"f")}}.value,configObjects:F,exitProcess:{set value(y){S(n,be,y,"f")}}.value,groups:{set value(y){S(t,_e,y,"f")}}.value,output:{set value(y){S(r,ae,y,"f")}}.value,exitError:{set value(y){S(i,Le,y,"f")}}.value,hasOutput:{set value(y){S(s,me,y,"f")}}.value,parsed:this.parsed,strict:{set value(y){S(o,tn,y,"f")}}.value,strictCommands:{set value(y){S(u,rn,y,"f")}}.value,strictOptions:{set value(y){S(c,sn,y,"f")}}.value,completionCommand:{set value(y){S(p,pe,y,"f")}}.value,parseFn:{set value(y){S(b,Fe,y,"f")}}.value,parseContext:{set value(y){S(g,en,y,"f")}}.value}=D,a(this,B,"f").configObjects=F,a(this,R,"f").unfreeze(),a(this,q,"f").unfreeze(),a(this,ee,"f").unfreeze(),a(this,Ee,"f").unfreeze()}[Bi](e,n){return qe(n,(t)=>(e(t),t))}getInternalMethods(){return{getCommandInstance:this[Oi].bind(this),getContext:this[$i].bind(this),getHasOutput:this[vi].bind(this),getLoggerInstance:this[ji].bind(this),getParseContext:this[ki].bind(this),getParserConfiguration:this[on].bind(this),getUsageConfiguration:this[Ai].bind(this),getUsageInstance:this[Mi].bind(this),getValidationInstance:this[Ni].bind(this),hasParseCallback:this[Zn].bind(this),isGlobalContext:this[Ri].bind(this),postProcess:this[an].bind(this),reset:this[Ht].bind(this),runValidation:this[Vt].bind(this),runYargsParserAndExecuteCommands:this[_n].bind(this),setHasOutput:this[Ti].bind(this)}}[Oi](){return a(this,ee,"f")}[$i](){return a(this,Pn,"f")}[vi](){return a(this,me,"f")}[ji](){return a(this,Qe,"f")}[ki](){return a(this,en,"f")||{}}[Mi](){return a(this,R,"f")}[Ni](){return a(this,q,"f")}[Zn](){return!!a(this,Fe,"f")}[Ri](){return a(this,Yn,"f")}[an](e,n,t,r){if(t)return e;if(J(e))return e;if(!n)e=this[Ei](e);if(this[on]()["parse-positional-numbers"]||this[on]()["parse-positional-numbers"]===void 0)e=this[_i](e);if(r)e=Ke(e,this,a(this,Ee,"f").getMiddleware(),!1);return e}[Ht](e={}){S(this,B,a(this,B,"f")||{},"f");let n={};n.local=a(this,B,"f").local||[],n.configObjects=a(this,B,"f").configObjects||[];let t={};n.local.forEach((s)=>{t[s]=!0,(e[s]||[]).forEach((o)=>{t[o]=!0})}),Object.assign(a(this,nn,"f"),Object.keys(a(this,_e,"f")).reduce((s,o)=>{let u=a(this,_e,"f")[o].filter((c)=>!(c in t));if(u.length>0)s[o]=u;return s},{})),S(this,_e,{},"f");let r=["array","boolean","string","skipValidation","count","normalize","number","hiddenOptions"],i=["narg","key","alias","default","defaultDescription","config","choices","demandedOptions","demandedCommands","deprecatedOptions"];if(r.forEach((s)=>{n[s]=(a(this,B,"f")[s]||[]).filter((o)=>!t[o])}),i.forEach((s)=>{n[s]=Ie(a(this,B,"f")[s],(o)=>!t[o])}),n.envPrefix=a(this,B,"f").envPrefix,S(this,B,n,"f"),S(this,R,a(this,R,"f")?a(this,R,"f").reset(t):fi(this,a(this,M,"f")),"f"),S(this,q,a(this,q,"f")?a(this,q,"f").reset(t):yi(this,a(this,R,"f"),a(this,M,"f")),"f"),S(this,ee,a(this,ee,"f")?a(this,ee,"f").reset():li(a(this,R,"f"),a(this,q,"f"),a(this,Ee,"f"),a(this,M,"f")),"f"),!a(this,De,"f"))S(this,De,pi(this,a(this,R,"f"),a(this,ee,"f"),a(this,M,"f")),"f");return a(this,Ee,"f").reset(),S(this,pe,null,"f"),S(this,ae,"","f"),S(this,Le,null,"f"),S(this,me,!1,"f"),this.parsed=!1,this}[Ii](e,n){return a(this,M,"f").path.relative(e,n)}[_n](e,n,t,r=0,i=!1){var s,o,u,c;let p=!!t||i;e=e||a(this,We,"f"),a(this,B,"f").__=a(this,M,"f").y18n.__,a(this,B,"f").configuration=this[on]();let b=!!a(this,B,"f").configuration["populate--"],g=Object.assign({},a(this,B,"f").configuration,{"populate--":!0}),D=a(this,M,"f").Parser.detailed(e,Object.assign({},a(this,B,"f"),{configuration:{"parse-positional-numbers":!1,...g}})),F=Object.assign(D.argv,a(this,en,"f")),y=void 0,h=D.aliases,v=!1,W=!1;if(Object.keys(F).forEach((T)=>{if(T===a(this,Ce,"f")&&F[T])v=!0;else if(T===a(this,Be,"f")&&F[T])W=!0}),F.$0=this.$0,this.parsed=D,r===0)a(this,R,"f").clearCachedHelpMessage();try{if(this[Mt](),n)return this[an](F,b,!!t,!1);if(a(this,Ce,"f")){if([a(this,Ce,"f")].concat(h[a(this,Ce,"f")]||[]).filter((te)=>te.length>1).includes(""+F._[F._.length-1]))F._.pop(),v=!0}S(this,Yn,!1,"f");let T=a(this,ee,"f").getCommands(),ce=((s=a(this,De,"f"))===null||s===void 0?void 0:s.completionKey)?[(o=a(this,De,"f"))===null||o===void 0?void 0:o.completionKey,...(c=this.getAliases()[(u=a(this,De,"f"))===null||u===void 0?void 0:u.completionKey])!==null&&c!==void 0?c:[]].some((Y)=>Object.prototype.hasOwnProperty.call(F,Y)):!1,I=v||ce||i;if(F._.length){if(T.length){let Y;for(let te=r||0,X;F._[te]!==void 0;te++)if(X=String(F._[te]),T.includes(X)&&X!==a(this,pe,"f")){let Pe=a(this,ee,"f").runCommand(X,this,D,te+1,i,v||W||i);return this[an](Pe,b,!!t,!1)}else if(!Y&&X!==a(this,pe,"f")){Y=X;break}if(!a(this,ee,"f").hasDefaultCommand()&&a(this,qn,"f")&&Y&&!I)a(this,q,"f").recommendCommands(Y,T)}if(a(this,pe,"f")&&F._.includes(a(this,pe,"f"))&&!ce){if(a(this,be,"f"))Te(!0);this.showCompletionScript(),this.exit(0)}}if(a(this,ee,"f").hasDefaultCommand()&&!I){let Y=a(this,ee,"f").runCommand(null,this,D,0,i,v||W||i);return this[an](Y,b,!!t,!1)}if(ce){if(a(this,be,"f"))Te(!0);e=[].concat(e);let Y=e.slice(e.indexOf(`--${a(this,De,"f").completionKey}`)+1);return a(this,De,"f").getCompletion(Y,(te,X)=>{if(te)throw new Q(te.message);(X||[]).forEach((Pe)=>{a(this,Qe,"f").log(Pe)}),this.exit(0)}),this[an](F,!b,!!t,!1)}if(!a(this,me,"f")){if(v){if(a(this,be,"f"))Te(!0);p=!0,this.showHelp((Y)=>{a(this,Qe,"f").log(Y),this.exit(0)})}else if(W){if(a(this,be,"f"))Te(!0);p=!0,a(this,R,"f").showVersion("log"),this.exit(0)}}if(!p&&a(this,B,"f").skipValidation.length>0)p=Object.keys(F).some((Y)=>a(this,B,"f").skipValidation.indexOf(Y)>=0&&F[Y]===!0);if(!p){if(D.error)throw new Q(D.error.message);if(!ce){let Y=this[Vt](h,{},D.error);if(!t)y=Ke(F,this,a(this,Ee,"f").getMiddleware(),!0);if(y=this[Bi](Y,y!==null&&y!==void 0?y:F),J(y)&&!t)y=y.then(()=>Ke(F,this,a(this,Ee,"f").getMiddleware(),!1))}}}catch(T){if(T instanceof Q)a(this,R,"f").fail(T.message,T);else throw T}return this[an](y!==null&&y!==void 0?y:F,b,!!t,!0)}[Vt](e,n,t,r){let i={...this.getDemandedOptions()};return(s)=>{if(t)throw new Q(t.message);a(this,q,"f").nonOptionCount(s),a(this,q,"f").requiredArguments(s,i);let o=!1;if(a(this,rn,"f"))o=a(this,q,"f").unknownCommands(s);if(a(this,tn,"f")&&!o)a(this,q,"f").unknownArguments(s,e,n,!!r);else if(a(this,sn,"f"))a(this,q,"f").unknownArguments(s,e,{},!1,!1);a(this,q,"f").limitedChoices(s),a(this,q,"f").implications(s),a(this,q,"f").conflicting(s)}}[Ti](){S(this,me,!0,"f")}[un](e){if(typeof e==="string")a(this,B,"f").key[e]=!0;else for(let n of e)a(this,B,"f").key[n]=!0}}function ci(e){return!!e&&typeof e.getInternalMethods==="function"}var ou=Li(ri),Hi=ou;var Vi={name:"@coryrylan/cradle",version:"1.3.1",description:"A runtime for portable agents defined as folders \u2014 launches the pi coding agent configured from an agent folder, sandboxed with nono",main:"./dist/index.js",module:"./dist/index.js",types:"./dist/index.d.ts",type:"module",exports:{".":{types:"./dist/index.d.ts",default:"./dist/index.js"}},bin:{cradle:"dist/index.js"},files:["README.md","CHANGELOG.md","LICENSE","package.json","dist/index.js","dist/**/*.d.ts","!dist/**/*.test.d.ts"],repository:{type:"git",url:"git+https://github.com/coryrylan/cradle.git",directory:"projects/cli"},keywords:["pi","agents","agent-folders","sandbox","nono","cli","bun"],author:"Cory Rylan (https://coryrylan.com)",license:"MIT",bugs:{url:"https://github.com/coryrylan/cradle/issues"},homepage:"https://github.com/coryrylan/cradle/tree/main/projects/cli#readme",engines:{bun:">=1.4.0"},publishConfig:{access:"public"},scripts:{start:"wireit",ci:"wireit","ci:nocache":"bun run clean && bun run ci",clean:"rm -rf dist",test:"wireit","test:coverage":"wireit",lint:"wireit",build:"wireit","install:local":"wireit","uninstall:local":"wireit",release:"wireit"},wireit:{start:{command:"bun src/index.ts",cache:!1},ci:{dependencies:["lint","build","test:coverage"]},test:{command:"bun test",files:["src/**/*.ts","src/**/*.json","src/**/*.txt","tsconfig.json","bunfig.toml"],output:[]},"test:coverage":{command:"bun test --coverage",files:["src/**/*.ts","src/**/*.json","src/**/*.txt","tsconfig.json","bunfig.toml"],output:[]},lint:{command:"eslint .",files:["src/**/*.ts","eslint.config.js","package.json"],output:[]},build:{dependencies:["build:js","build:tsc","build:darwin-arm64","build:darwin-x64","build:linux-x64","build:linux-arm64","build:windows-x64"]},"build:js":{command:"bun build ./src/index.ts --outdir=./dist --target=bun --format=esm --minify",files:["src/**/*.ts","src/**/*.json","src/**/*.txt","tsconfig.json"],output:["dist/index.js"]},"build:tsc":{command:"tsc --emitDeclarationOnly --project tsconfig.types.json",files:["src/**/*.ts","src/**/*.json","tsconfig.json","tsconfig.types.json"],output:["dist/**/*.d.ts"]},"build:darwin-arm64":{command:"bun build --compile --minify src/index.ts --target=bun-darwin-arm64 --outfile dist/cradle-macos-arm64",files:["src/**/*.ts","src/**/*.json","src/**/*.txt","tsconfig.json"],output:["dist/cradle-macos-arm64"]},"build:darwin-x64":{command:"bun build --compile --minify src/index.ts --target=bun-darwin-x64 --outfile dist/cradle-macos-x64",files:["src/**/*.ts","src/**/*.json","src/**/*.txt","tsconfig.json"],output:["dist/cradle-macos-x64"]},"build:linux-x64":{command:"bun build --compile --minify src/index.ts --target=bun-linux-x64 --outfile dist/cradle-linux-x64",files:["src/**/*.ts","src/**/*.json","src/**/*.txt","tsconfig.json"],output:["dist/cradle-linux-x64"]},"build:linux-arm64":{command:"bun build --compile --minify src/index.ts --target=bun-linux-arm64 --outfile dist/cradle-linux-arm64",files:["src/**/*.ts","src/**/*.json","src/**/*.txt","tsconfig.json"],output:["dist/cradle-linux-arm64"]},"build:windows-x64":{command:"bun build --compile --minify src/index.ts --target=bun-windows-x64 --outfile dist/cradle-windows-x64.exe",files:["src/**/*.ts","src/**/*.json","src/**/*.txt","tsconfig.json"],output:["dist/cradle-windows-x64.exe"]},"install:local":{dependencies:["build"],command:"bash install.sh",cache:!1},"uninstall:local":{command:'rm -f "$HOME/.local/bin/cradle"',cache:!1},release:{command:"HUSKY=0 bun x semantic-release",dependencies:["ci"]}},dependencies:{yargs:"^18.1.0"},devDependencies:{"@coryrylan/tools":"1.1.1","@eslint/js":"catalog:","@eslint/json":"2.0.1","@types/bun":"catalog:","@types/yargs":"17.0.35",eslint:"catalog:","eslint-plugin-jsdoc":"64.2.1",typescript:"catalog:","typescript-eslint":"catalog:"}};import{join as Gi}from"path";var Qn="agent-browser-nono-fallback.ts";function zi(){return`// generated by cradle for sandboxed agent-browser processes \u2014 do not edit
82
82
  import type { ExtensionAPI } from '@earendil-works/pi-coding-agent';
83
83
 
84
84
  export default function configureAgentBrowserNonoEnvironment(_pi: ExtensionAPI): void {
@@ -95,18 +95,38 @@ export default function configureAgentBrowserNonoEnvironment(_pi: ExtensionAPI):
95
95
  process.env.AGENT_BROWSER_PROXY = nonoProxy;
96
96
  }
97
97
  }
98
- `}function e3(D){let u=[];if(D.systemFilePath!==null)u.push("--system-prompt",D.systemFilePath);if(D.appendSystemFilePath!==null)u.push("--append-system-prompt",D.appendSystemFilePath);return u}function D1(D){let{folder:u}=D,{settings:F}=u,C=[D.piBin,...e3(u),"--no-extensions","--no-skills","--no-prompt-templates"];if(u.providersJson!==null)C.push("-e",W2(D.extensionsDir,"providers.ts"));if(D.backend==="nono")C.push("-e",W2(D.extensionsDir,gu));for(let E of D.packageEntries??[])C.push("-e",E);for(let E of u.extensionFiles)C.push("-e",E);if(u.skillsDir!==null)C.push("--skill",u.skillsDir);if(F.defaultProvider!==void 0)C.push("--provider",F.defaultProvider);if(F.defaultModel!==void 0)C.push("--model",F.defaultModel);if(F.defaultThinkingLevel!==void 0)C.push("--thinking",F.defaultThinkingLevel);return C.push("--session-dir",D.sessionsDir),C.push(...D.passthrough),C}function _F(D){return D.backend==="nono"?{MISE_CACHE_DIR:D.miseCacheDir}:{}}function Qu(D){let u=D1(D);if(D.backend!=="nono")return u;return[D.nonoBin,"run",...D.verbose===!0?[]:["--silent"],"--profile",D.profilePath,"--",...u]}import{existsSync as u1}from"fs";import{homedir as F1}from"os";import{join as C1}from"path";function E1(D,u=F1()){let F=C1(u,".local","share","mise","shims",D);return u1(F)?F:null}var V2=(D)=>Bun.which(D)??E1(D);function NF(D,u=V2){return u(D)}function tu(D,u=V2){let F=NF(D,u);if(!F)throw Error(`Required executable "${D}" not found on PATH \u2014 install it, then run \`cradle doctor\` to verify`);return F}var B1="recommended: the supported way to install pi/nono \u2014 cradle resolves them from mise shims and the sandbox profile assumes a mise-managed install",$1="required for sandboxed runs (a folder declaring sandbox/nono.json, or --sandbox/--offline/--allow-host); not needed otherwise",z1="required for sbx-backend runs (a folder declaring sandbox/sbx.json, or --sandbox-backend sbx); not needed otherwise";async function T2(D={}){let u=(Y)=>NF(Y,D.which),F=async(Y,q)=>Y!==null&&D.readVersion?D.readVersion(Y,q):null,C=u("pi"),E=u("nono"),B=u("sbx"),$=u("mise"),[Z,M,H,V]=await Promise.all([F(C),F(E),F(B,["version"]),F($)]);return[{name:"pi",bin:"pi",required:!0,found:C,version:Z},{name:"nono",bin:"nono",required:!1,found:E,version:M,...E?{}:{note:$1}},{name:"sbx",bin:"sbx",required:!1,found:B,version:H,...B?{}:{note:z1}},{name:"mise",bin:"mise",required:!1,found:$,version:V,...$?{}:{note:B1}}]}function Z1(D){let u=D.found?`\u2713 ${D.name.padEnd(8)} ${D.version??"?"} ${D.found}`:D.required?`\u2717 ${D.name.padEnd(8)} MISSING (required)`:`\u25CB ${D.name.padEnd(8)} not found (recommended)`;return D.note?`${u}
99
- \u26A0 ${D.note}`:u}function L2(D){return D.map(Z1).join(`
100
- `)}function I2(D){return D.some((u)=>u.required&&!u.found)?1:0}import{exists as a6,mkdir as mF,rm as e6,writeFile as V8}from"fs/promises";import{homedir as D7}from"os";import{basename as u7,dirname as F7,join as ju}from"path";import{stat as j1}from"fs/promises";import{join as x2,resolve as _1}from"path";import{basename as X1,isAbsolute as M1,join as G1,relative as J1}from"path";var Wu={extends:"default",meta:{name:"cradle-pi"},groups:{include:["node_runtime","git_config","unlink_protection"]},filesystem:{read:["$HOME/.agents","$HOME/.local/share/mise","$HOME/.config/mise","$HOME/.local/state/mise","$HOME/.config/gh","/System/iOSSupport/System/Library/ExtensionKit/Extensions","/System/Library/AssetsV2/com_apple_MobileAsset_TTSAXResourceModelAssets","/System/Library/AssetsV2/com_apple_MobileAsset_UAF_Siri_TextToSpeech"],allow:["$HOME/.pi/agent"]},unsafe_macos_seatbelt_rules:['(allow user-preference-read (preference-domain "kCFPreferencesAnyApplication") (preference-domain "com.apple.speech.voice.prefs") (preference-domain "com.apple.speakselection") (preference-domain "com.apple.assistant.backedup") (preference-domain "com.apple.assistant.support") (preference-domain "com.apple.accessibility"))']};var K2="nono-profile.json";function lu(D,u){let F=J1(D,u);return F===""||!F.startsWith("..")&&!M1(F)}function j2(D,u){let F=G1(u,".local","state","nono");return lu(D,F)||lu(F,D)?D:void 0}function Vu(D,u){if(D==="~"||D==="$HOME")return u;if(D.startsWith("~/"))return`${u}${D.slice(1)}`;if(D.startsWith("$HOME/"))return`${u}${D.slice(5)}`;return D}function _2(D){let u=($)=>Vu($,D.home),F=Wu.filesystem,C=D.network!==void 0?Y1(D.network):void 0,E=[...F.unix_socket_dir_bind??[],...D.grants.unixSocketDirBind.map(u)],B={...Wu,meta:{...Wu.meta,name:`cradle-${X1(D.stateDir)}`},filesystem:{...F,read:[...F.read??[],D.agentDir,...D.grants.read.map(u)],write:[...F.write??[],...D.grants.write.map(u)],allow:[...F.allow??[],D.cwd,D.stateDir,...D.linkedGitDir!==void 0?[D.linkedGitDir]:[],...D.grants.allow.map(u)],...E.length>0?{unix_socket_dir_bind:E}:{}},unsafe_macos_seatbelt_rules:[...Wu.unsafe_macos_seatbelt_rules,...D.rules],...C!==void 0?{network:C}:{}};return JSON.stringify(B,null,2)}function Y1(D){return{...D.block!==void 0?{block:D.block}:{},...D.networkProfile!==void 0?{network_profile:D.networkProfile}:{},...D.allowDomain!==void 0?{allow_domain:D.allowDomain}:{},...D.openPort!==void 0?{open_port:D.openPort}:{},...D.listenPort!==void 0?{listen_port:D.listenPort}:{}}}import{chmod as N2,lstat as q1,mkdir as H1,readdir as R2,readFile as O1,rm as U1,writeFile as W1}from"fs/promises";import{dirname as V1,join as ou,relative as T1}from"path";function ZD(D){return typeof D==="object"&&D!==null&&!Array.isArray(D)}function Xu(D,u){try{return JSON.parse(D)}catch(F){throw Error(`${u} is not valid JSON: ${Fu(F)}`,{cause:F})}}function Fu(D){return D instanceof Error?D.message:String(D)}function XD(D,u){return typeof D==="object"&&D!==null&&"code"in D&&D.code===u}function Mu(D){if(/^[A-Za-z0-9_./:@%+=,-]+$/u.test(D))return D;return`'${D.replaceAll("'","'\\''")}'`}function cD(D){return Array.isArray(D)&&D.every((u)=>typeof u==="string")}function Tu(D){return/^(?:\/|~(?:\/|$)|\$HOME(?:\/|$)|[A-Za-z]:[\\/]|\\\\)/.test(D)}function RD(D,u,F,C){let E=Object.keys(D).filter((B)=>!F.includes(B));if(E.length>0)C.push(`${u}: unsupported keys ignored: ${E.join(", ")}`)}function iu(D,u,F,C){D.results.push({name:u,detail:F,status:C})}function L1(D,u,F){D.failures.push(`${u}: ${F}`),iu(D,u,F,"failed")}async function f2(D,u,F,C){try{if(await K1(F,C)){iu(D,u,F,"unchanged");return}if(D.dryRun){iu(D,u,`would replace ${F}`,"changed");return}await S2(F),await U1(F,{force:!0,recursive:!0});for(let E of C)await I1(F,E);iu(D,u,F,"changed")}catch(E){L1(D,u,Fu(E))}}async function I1(D,u){let F=ou(D,u.rel);if(await H1(V1(F),{recursive:!0}),await W1(F,u.content,"utf8"),u.mode!==void 0)await N2(F,u.mode)}async function K1(D,u){let F=await A2(D);if(F.length!==u.length)return!1;let C=new Set(F);for(let E of u){if(!C.has(E.rel))return!1;if(await SD(ou(D,E.rel))!==E.content)return!1}return!0}async function A2(D,u=D){let F=await P2(D);if(!F||!F.isDirectory())return[];let C=[];for(let E of await R2(D,{withFileTypes:!0})){let B=ou(D,E.name);if(E.isDirectory())C.push(...await A2(B,u));else C.push(T1(u,B))}return C}async function S2(D){let u=await P2(D);if(!u||u.isSymbolicLink())return;if(await N2(D,u.isDirectory()?493:420),!u.isDirectory())return;let F=await R2(D);await Promise.all(F.map((C)=>S2(ou(D,C))))}async function SD(D){try{return await O1(D,"utf8")}catch(u){if(XD(u,"ENOENT"))return;throw u}}async function P2(D){try{return await q1(D)}catch(u){if(XD(u,"ENOENT"))return;throw u}}var N1=/^[A-Za-z0-9][A-Za-z0-9._-]*$/;async function h2(D,u){if(!R1(D))return{dir:D,warnings:[]};let F=x2(u.home,".cradle","settings.json"),C=[],E=await f1(F,C),B=x2(u.cwd,D),$=E.get(D);if($!==void 0){let Z=_1(Vu($,u.home));if(await b2(B))C.push(P1(D,Z));return{dir:Z,warnings:C}}if(await b2(B))return{dir:B,warnings:C};throw Error(x1(D,B,F,E))}function R1(D){return N1.test(D)}async function b2(D){try{return(await j1(D)).isDirectory()}catch(u){if(XD(u,"ENOENT")||XD(u,"ENOTDIR"))return!1;throw u}}async function f1(D,u){let F=await SD(D);if(F===void 0)return new Map;let C=Xu(F,D);if(!ZD(C))return u.push(`${D}: settings must be a JSON object \u2014 ignored`),new Map;return RD(C,D,["agents"],u),A1(C,D,u)}function A1(D,u,F){let C=D.agents;if(C===void 0)return new Map;if(!ZD(C))return F.push(`${u}: agents must be an object \u2014 ignored`),new Map;let E=Object.entries(C).map((B)=>{let[$,Z]=B,M=S1(Z,$,u,F);return M===void 0?void 0:[$,M]}).filter((B)=>B!==void 0);return new Map(E)}function S1(D,u,F,C){if(!ZD(D)){C.push(`${F}: agents.${u} must be an object with a "path" \u2014 ignored`);return}let E=D.path;if(typeof E!=="string"||E.trim()===""){C.push(`${F}: agents.${u}.path must be a non-empty string \u2014 ignored`);return}if(!Tu(E)){C.push(`${F}: agents.${u}.path must be an absolute, ~/, or $HOME/ path \u2014 ignored: ${E}`);return}return E}function P1(D,u){return`started alias "${D}" (${u}) \u2014 a directory named ${D} exists in the current directory; use ./${D} to run it instead`}function x1(D,u,F,C){let E=C.size>0?` (known agents: ${[...C.keys()].join(", ")})`:"";return`Agent folder not found: ${u} \u2014 and no "agents.${D}" entry in ${F}${E}`}import{createHash as b1}from"crypto";import{join as h1}from"path";var m2="host.docker.internal",w2="@earendil-works/pi-coding-agent",w1=/^\d+\.\d+\.\d+\.\d+$/,m1=new Set(["localhost","127.0.0.1"]);function v2(D){let u=(C)=>Vu(C,D.home),F=[{path:D.cwd,readonly:!1},{path:D.agentDir,readonly:!0},{path:D.stateDir,readonly:!1},{path:h1(D.home,".pi","agent"),readonly:!1},...D.linkedGitDir!==void 0?[{path:D.linkedGitDir,readonly:!1}]:[],...D.grants.read.map((C)=>({path:u(C),readonly:!0})),...D.grants.write.map((C)=>({path:u(C),readonly:!1})),...D.grants.allow.map((C)=>({path:u(C),readonly:!1}))];return v1(F)}function v1(D){let u=[],F=new Map;for(let C of D){if(!F.has(C.path))u.push(C.path);if(F.get(C.path)!==!1)F.set(C.path,C.readonly)}return u.map((C)=>({path:C,readonly:F.get(C)===!0}))}function c2(D,u){let F=u.map((E)=>`${E.path}:${E.readonly?"ro":"rw"}`).sort().join("|"),C=b1("sha256").update(F).digest("hex").slice(0,8);return`cradle-${D}-${C}`}function d2(D){let u=D.mounts.map((F)=>F.readonly?`${F.path}:ro`:F.path);return[D.sbxBin,"create","shell",...u,"--name",D.name,"-q"]}function c1(D){let u=[],F=!1;for(let C of D)if(m1.has(C))F=!0;else if(w1.test(C))u.push(C);else u.push(C,`*.${C}`);if(F)u.push(m2);return u}function k2(D){let{network:u,sbxBin:F,name:C}=D;if(u===void 0)return[];if(u.block===!0)return[[F,"policy","deny","network","--sandbox",C,"**"]];let E=c1(u.allowDomain??[]);return E.length>0?[[F,"policy","allow","network","--sandbox",C,E.join(",")]]:[]}function d1(D){return D.networkProfile!==void 0?"network_profile is nono-only \u2014 ignored under the sbx backend":void 0}function k1(D){return(D.openPort?.length??0)>0||(D.listenPort?.length??0)>0?"open_port/listen_port are nono-only \u2014 guest-local ports are unrestricted and host services are reachable via host.docker.internal under sbx":void 0}function p1(D){return D.block!==!0&&(D.allowDomain?.length??0)>0?"sbx allow rules add to your global sbx policy but cannot subtract from it \u2014 run `sbx policy init deny-all` for strict allowlist semantics (nono enforces the allowlist exactly)":void 0}function p2(D){if(D===void 0)return[];return[d1(D),k1(D),p1(D)].filter((u)=>u!==void 0)}function y2(D){return D.unixSocketDirBind.length>0?["unix_socket_dir_bind is nono-only \u2014 Unix sockets cannot cross the sbx VM boundary; grant ignored"]:[]}function RF(D){let u=D.piVersion===null?`command -v pi >/dev/null 2>&1 || npm i -g ${w2}`:`command -v pi >/dev/null 2>&1 && [ "$(pi --version 2>/dev/null)" = "${D.piVersion}" ] || npm i -g ${w2}@${D.piVersion}`;return[D.sbxBin,"exec",D.name,"bash","-lc",u]}function nu(D,u){return[D.sbxBin,"exec","-i",...D.tty?["-t"]:[],"-e",`HOME=${D.home}`,"-w",D.cwd,D.name,...u]}function g2(D){return D.toLowerCase().includes("already exists")}function t2(D){let u;try{u=new URL(D)}catch{return D}if(u.hostname!=="localhost"&&u.hostname!=="127.0.0.1")return D;return u.hostname=m2,u.toString()}function l2(D,u={}){return`// generated by cradle from the agent folder's models.json \u2014 do not edit
98
+ `}function uu(e){let n=[];if(e.systemFilePath!==null)n.push("--system-prompt",e.systemFilePath);if(e.appendSystemFilePath!==null)n.push("--append-system-prompt",e.appendSystemFilePath);return n}function lu(e){let{folder:n}=e,{settings:t}=n,r=[e.piBin,...uu(n),"--no-extensions","--no-skills","--no-prompt-templates"];if(n.providersJson!==null)r.push("-e",Gi(e.extensionsDir,"providers.ts"));if(e.backend==="nono")r.push("-e",Gi(e.extensionsDir,Qn));for(let i of e.packageEntries??[])r.push("-e",i);for(let i of n.extensionFiles)r.push("-e",i);if(n.skillsDir!==null)r.push("--skill",n.skillsDir);if(t.defaultProvider!==void 0)r.push("--provider",t.defaultProvider);if(t.defaultModel!==void 0)r.push("--model",t.defaultModel);if(t.defaultThinkingLevel!==void 0)r.push("--thinking",t.defaultThinkingLevel);return r.push("--session-dir",e.sessionsDir),r.push(...e.passthrough),r}function zt(e){return e.backend==="nono"?{MISE_CACHE_DIR:e.miseCacheDir}:{}}function mn(e){let n=lu(e);if(e.backend!=="nono")return n;return[e.nonoBin,"run",...e.verbose===!0?[]:["--silent"],"--profile",e.profilePath,"--",...n]}import{existsSync as cu}from"fs";import{homedir as du}from"os";import{join as fu}from"path";function hu(e,n=du()){let t=fu(n,".local","share","mise","shims",e);return cu(t)?t:null}var Ui=(e)=>Bun.which(e)??hu(e);function Gt(e,n=Ui){return n(e)}function Fn(e,n=Ui){let t=Gt(e,n);if(!t)throw Error(`Required executable "${e}" not found on PATH \u2014 install it, then run \`cradle doctor\` to verify`);return t}var Du="recommended: the supported way to install pi/nono \u2014 cradle resolves them from mise shims and the sandbox profile assumes a mise-managed install",gu="required for sandboxed runs (a folder declaring sandbox/nono.json, or --sandbox/--offline/--allow-host); not needed otherwise",pu="required for sbx-backend runs (a folder declaring sandbox/sbx.json, or --sandbox-backend sbx); not needed otherwise",mu="recommended for `cradle schedule`: installs schedule/*.md tasks as launchd LaunchAgents; not needed otherwise",Fu="recommended for `cradle schedule`: installs schedule/*.md tasks as systemd --user timers; not needed otherwise";function yu(e){if(e==="darwin")return"launchctl";if(e==="linux")return"systemctl";return null}function bu(e){return e==="launchctl"?mu:Fu}function et(e,n,t,r){return{name:e,bin:e,required:!1,found:n,version:t,...n?{}:{note:r}}}function Eu(e){let n=(r)=>Gt(r,e.which),t=yu(e.platform??process.platform);return{piPath:n("pi"),nonoPath:n("nono"),sbxPath:n("sbx"),misePath:n("mise"),scheduleBin:t,schedulePath:t!==null?n(t):null}}async function Yi(e={}){let n=async(c,p)=>c!==null&&e.readVersion?e.readVersion(c,p):null,t=Eu(e),[r,i,s,o,u]=await Promise.all([n(t.piPath),n(t.nonoPath),n(t.sbxPath,["version"]),n(t.misePath),n(t.schedulePath)]);return[{name:"pi",bin:"pi",required:!0,found:t.piPath,version:r},et("nono",t.nonoPath,i,gu),et("sbx",t.sbxPath,s,pu),et("mise",t.misePath,o,Du),...t.scheduleBin!==null?[et(t.scheduleBin,t.schedulePath,u,bu(t.scheduleBin))]:[]]}var Cu=8;function wu(e,n){let t=e.name.padEnd(n),r=e.version!==null?`${e.version} `:"",i=e.found?`\u2713 ${t} ${r}${e.found}`:e.required?`\u2717 ${t} MISSING (required)`:`\u25CB ${t} not found (recommended)`;return e.note?`${i}
99
+ \u26A0 ${e.note}`:i}function Ji(e){let n=Math.max(Cu,...e.map((t)=>t.name.length));return e.map((t)=>wu(t,n)).join(`
100
+ `)}function Ki(e){return e.some((n)=>n.required&&!n.found)?1:0}import{exists as Us,mkdir as nr,rm as Bc,writeFile as Ys}from"fs/promises";import{homedir as Oc}from"os";import{basename as $c,dirname as vc,join as jn}from"path";import{stat as Lu}from"fs/promises";import{join as ss,resolve as Wu}from"path";import{basename as Su,isAbsolute as Au,join as Pu,relative as _u}from"path";var Bn={extends:"default",meta:{name:"cradle-pi"},groups:{include:["node_runtime","git_config","unlink_protection"]},filesystem:{read:["$HOME/.agents","$HOME/.local/share/mise","$HOME/.config/mise","$HOME/.local/state/mise","$HOME/.config/gh","/System/iOSSupport/System/Library/ExtensionKit/Extensions","/System/Library/AssetsV2/com_apple_MobileAsset_TTSAXResourceModelAssets","/System/Library/AssetsV2/com_apple_MobileAsset_UAF_Siri_TextToSpeech"],allow:["$HOME/.pi/agent"]},unsafe_macos_seatbelt_rules:['(allow user-preference-read (preference-domain "kCFPreferencesAnyApplication") (preference-domain "com.apple.speech.voice.prefs") (preference-domain "com.apple.speakselection") (preference-domain "com.apple.assistant.backedup") (preference-domain "com.apple.assistant.support") (preference-domain "com.apple.accessibility"))']};var qi="nono-profile.json";function nt(e,n){let t=_u(e,n);return t===""||!t.startsWith("..")&&!Au(t)}function Xi(e,n){let t=Pu(n,".local","state","nono");return nt(e,t)||nt(t,e)?e:void 0}function ln(e,n){if(e==="~"||e==="$HOME")return n;if(e.startsWith("~/"))return`${n}${e.slice(1)}`;if(e.startsWith("$HOME/"))return`${n}${e.slice(5)}`;return e}function Zi(e){let n=(o)=>ln(o,e.home),t=Bn.filesystem,r=e.network!==void 0?Bu(e.network):void 0,i=[...t.unix_socket_dir_bind??[],...e.grants.unixSocketDirBind.map(n)],s={...Bn,meta:{...Bn.meta,name:`cradle-${Su(e.stateDir)}`},filesystem:{...t,read:[...t.read??[],e.agentDir,...e.grants.read.map(n)],write:[...t.write??[],...e.grants.write.map(n)],allow:[...t.allow??[],e.cwd,e.stateDir,...e.linkedGitDir!==void 0?[e.linkedGitDir]:[],...e.grants.allow.map(n)],...i.length>0?{unix_socket_dir_bind:i}:{}},unsafe_macos_seatbelt_rules:[...Bn.unsafe_macos_seatbelt_rules,...e.rules],...r!==void 0?{network:r}:{}};return JSON.stringify(s,null,2)}function Bu(e){return{...e.block!==void 0?{block:e.block}:{},...e.networkProfile!==void 0?{network_profile:e.networkProfile}:{},...e.allowDomain!==void 0?{allow_domain:e.allowDomain}:{},...e.openPort!==void 0?{open_port:e.openPort}:{},...e.listenPort!==void 0?{listen_port:e.listenPort}:{}}}import{chmod as Qi,lstat as Ou,mkdir as $u,readdir as es,readFile as vu,rm as ju,writeFile as ku}from"fs/promises";import{dirname as Mu,join as rt,relative as Nu}from"path";function le(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function yn(e,n){try{return JSON.parse(e)}catch(t){throw Error(`${n} is not valid JSON: ${Se(t)}`,{cause:t})}}function Se(e){return e instanceof Error?e.message:String(e)}function de(e,n){return typeof e==="object"&&e!==null&&"code"in e&&e.code===n}function Ve(e){if(/^[A-Za-z0-9_./:@%+=,-]+$/u.test(e))return e;return`'${e.replaceAll("'","'\\''")}'`}function ze(e){return Array.isArray(e)&&e.every((n)=>typeof n==="string")}function cn(e){return/^(?:\/|~(?:\/|$)|\$HOME(?:\/|$)|[A-Za-z]:[\\/]|\\\\)/.test(e)}function Oe(e,n,t,r){let i=Object.keys(e).filter((s)=>!t.includes(s));if(i.length>0)r.push(`${n}: unsupported keys ignored: ${i.join(", ")}`)}function tt(e,n,t,r){e.results.push({name:n,detail:t,status:r})}function Ru(e,n,t){e.failures.push(`${n}: ${t}`),tt(e,n,t,"failed")}async function ns(e,n,t,r){try{if(await Tu(t,r)){tt(e,n,t,"unchanged");return}if(e.dryRun){tt(e,n,`would replace ${t}`,"changed");return}await rs(t),await ju(t,{force:!0,recursive:!0});for(let i of r)await Iu(t,i);tt(e,n,t,"changed")}catch(i){Ru(e,n,Se(i))}}async function Iu(e,n){let t=rt(e,n.rel);if(await $u(Mu(t),{recursive:!0}),await ku(t,n.content,"utf8"),n.mode!==void 0)await Qi(t,n.mode)}async function Tu(e,n){let t=await ts(e);if(t.length!==n.length)return!1;let r=new Set(t);for(let i of n){if(!r.has(i.rel))return!1;if(await Ae(rt(e,i.rel))!==i.content)return!1}return!0}async function ts(e,n=e){let t=await is(e);if(!t||!t.isDirectory())return[];let r=[];for(let i of await es(e,{withFileTypes:!0})){let s=rt(e,i.name);if(i.isDirectory())r.push(...await ts(s,n));else r.push(Nu(n,s))}return r}async function rs(e){let n=await is(e);if(!n||n.isSymbolicLink())return;if(await Qi(e,n.isDirectory()?493:420),!n.isDirectory())return;let t=await es(e);await Promise.all(t.map((r)=>rs(rt(e,r))))}async function Ae(e){try{return await vu(e,"utf8")}catch(n){if(de(n,"ENOENT"))return;throw n}}async function is(e){try{return await Ou(e)}catch(n){if(de(n,"ENOENT"))return;throw n}}var Hu=/^[A-Za-z0-9][A-Za-z0-9._-]*$/;async function it(e,n){if(!Vu(e))return{dir:e,warnings:[]};let t=ss(n.home,".cradle","settings.json"),r=[],i=await zu(t,r),s=ss(n.cwd,e),o=i.get(e);if(o!==void 0){let u=Wu(ln(o,n.home));if(await os(s))r.push(Yu(e,u));return{dir:u,warnings:r}}if(await os(s))return{dir:s,warnings:r};throw Error(Ju(e,s,t,i))}function Vu(e){return Hu.test(e)}async function os(e){try{return(await Lu(e)).isDirectory()}catch(n){if(de(n,"ENOENT")||de(n,"ENOTDIR"))return!1;throw n}}async function zu(e,n){let t=await Ae(e);if(t===void 0)return new Map;let r=yn(t,e);if(!le(r))return n.push(`${e}: settings must be a JSON object \u2014 ignored`),new Map;return Oe(r,e,["agents"],n),Gu(r,e,n)}function Gu(e,n,t){let r=e.agents;if(r===void 0)return new Map;if(!le(r))return t.push(`${n}: agents must be an object \u2014 ignored`),new Map;let i=Object.entries(r).map((s)=>{let[o,u]=s,c=Uu(u,o,n,t);return c===void 0?void 0:[o,c]}).filter((s)=>s!==void 0);return new Map(i)}function Uu(e,n,t,r){if(!le(e)){r.push(`${t}: agents.${n} must be an object with a "path" \u2014 ignored`);return}let i=e.path;if(typeof i!=="string"||i.trim()===""){r.push(`${t}: agents.${n}.path must be a non-empty string \u2014 ignored`);return}if(!cn(i)){r.push(`${t}: agents.${n}.path must be an absolute, ~/, or $HOME/ path \u2014 ignored: ${i}`);return}return i}function Yu(e,n){return`started alias "${e}" (${n}) \u2014 a directory named ${e} exists in the current directory; use ./${e} to run it instead`}function Ju(e,n,t,r){let i=r.size>0?` (known agents: ${[...r.keys()].join(", ")})`:"";return`Agent folder not found: ${n} \u2014 and no "agents.${e}" entry in ${t}${i}`}import{createHash as Ku}from"crypto";import{join as qu}from"path";var us="host.docker.internal",as="@earendil-works/pi-coding-agent",Xu=/^\d+\.\d+\.\d+\.\d+$/,Zu=new Set(["localhost","127.0.0.1"]);function ls(e){let n=(r)=>ln(r,e.home),t=[{path:e.cwd,readonly:!1},{path:e.agentDir,readonly:!0},{path:e.stateDir,readonly:!1},{path:qu(e.home,".pi","agent"),readonly:!1},...e.linkedGitDir!==void 0?[{path:e.linkedGitDir,readonly:!1}]:[],...e.grants.read.map((r)=>({path:n(r),readonly:!0})),...e.grants.write.map((r)=>({path:n(r),readonly:!1})),...e.grants.allow.map((r)=>({path:n(r),readonly:!1}))];return Qu(t)}function Qu(e){let n=[],t=new Map;for(let r of e){if(!t.has(r.path))n.push(r.path);if(t.get(r.path)!==!1)t.set(r.path,r.readonly)}return n.map((r)=>({path:r,readonly:t.get(r)===!0}))}function cs(e,n){let t=n.map((i)=>`${i.path}:${i.readonly?"ro":"rw"}`).sort().join("|"),r=Ku("sha256").update(t).digest("hex").slice(0,8);return`cradle-${e}-${r}`}function ds(e){let n=e.mounts.map((t)=>t.readonly?`${t.path}:ro`:t.path);return[e.sbxBin,"create","shell",...n,"--name",e.name,"-q"]}function el(e){let n=[],t=!1;for(let r of e)if(Zu.has(r))t=!0;else if(Xu.test(r))n.push(r);else n.push(r,`*.${r}`);if(t)n.push(us);return n}function fs(e){let{network:n,sbxBin:t,name:r}=e;if(n===void 0)return[];if(n.block===!0)return[[t,"policy","deny","network","--sandbox",r,"**"]];let i=el(n.allowDomain??[]);return i.length>0?[[t,"policy","allow","network","--sandbox",r,i.join(",")]]:[]}function nl(e){return e.networkProfile!==void 0?"network_profile is nono-only \u2014 ignored under the sbx backend":void 0}function tl(e){return(e.openPort?.length??0)>0||(e.listenPort?.length??0)>0?"open_port/listen_port are nono-only \u2014 guest-local ports are unrestricted and host services are reachable via host.docker.internal under sbx":void 0}function rl(e){return e.block!==!0&&(e.allowDomain?.length??0)>0?"sbx allow rules add to your global sbx policy but cannot subtract from it \u2014 run `sbx policy init deny-all` for strict allowlist semantics (nono enforces the allowlist exactly)":void 0}function hs(e){if(e===void 0)return[];return[nl(e),tl(e),rl(e)].filter((n)=>n!==void 0)}function Ds(e){return e.unixSocketDirBind.length>0?["unix_socket_dir_bind is nono-only \u2014 Unix sockets cannot cross the sbx VM boundary; grant ignored"]:[]}function Ut(e){let n=e.piVersion===null?`command -v pi >/dev/null 2>&1 || npm i -g ${as}`:`command -v pi >/dev/null 2>&1 && [ "$(pi --version 2>/dev/null)" = "${e.piVersion}" ] || npm i -g ${as}@${e.piVersion}`;return[e.sbxBin,"exec",e.name,"bash","-lc",n]}function st(e,n){return[e.sbxBin,"exec","-i",...e.tty?["-t"]:[],"-e",`HOME=${e.home}`,"-w",e.cwd,e.name,...n]}function gs(e){return e.toLowerCase().includes("already exists")}function ps(e){let n;try{n=new URL(e)}catch{return e}if(n.hostname!=="localhost"&&n.hostname!=="127.0.0.1")return e;return n.hostname=us,n.toString()}function ms(e,n={}){return`// generated by cradle from the agent folder's models.json \u2014 do not edit
101
101
  import type { ExtensionAPI } from '@earendil-works/pi-coding-agent';
102
102
 
103
- const providers = ${u.rewriteLocalhostBaseUrls===!0?y1(D):D} as const;
103
+ const providers = ${n.rewriteLocalhostBaseUrls===!0?il(e):e} as const;
104
104
 
105
105
  export default function (pi: ExtensionAPI): void {
106
106
  for (const [name, config] of Object.entries(providers)) {
107
107
  pi.registerProvider(name, config as never);
108
108
  }
109
109
  }
110
- `}function y1(D){let u=JSON.parse(D);for(let F of Object.values(u)){if(F===null||typeof F!=="object")continue;let C=F;if(typeof C.baseUrl==="string")C.baseUrl=t2(C.baseUrl)}return JSON.stringify(u,null,2)}import{lstat as V6,readdir as Q8,stat as T6}from"fs/promises";import{join as KD,resolve as L6}from"path";import{readdir as l1,stat as i1}from"fs/promises";import{join as dD,resolve as s2,sep as r2}from"path";import{basename as g1,relative as o2,sep as i2}from"path";function Lu(D){return D.startsWith("!")||D.startsWith("+")||D.startsWith("-")}function PF(D,u,F){let C=u.filter((Z)=>!Lu(Z)),E=fF(u,"!"),B=fF(u,"+"),$=fF(u,"-");return D.filter((Z)=>{if(SF(Z,$,F))return!1;if(SF(Z,B,F))return!0;if(AF(Z,E,F))return!1;return C.length===0||AF(Z,C,F)})}function n2(D,u,F){return D.filter((C)=>{let E=u.filter((B)=>t1(C,B,F)).at(-1);return E!==void 0&&!E.startsWith("-")&&!E.startsWith("!")})}function t1(D,u,F){let C=Lu(u)?u.slice(1):u;return u.startsWith("+")||u.startsWith("-")?SF(D,[C],F):AF(D,[C],F)}function fF(D,u){return D.filter((F)=>F.startsWith(u)).map((F)=>F.slice(1))}function AF(D,u,F){let C=[Gu(o2(F,D)),g1(D),Gu(D)];return u.some((E)=>{let B=new Bun.Glob(Gu(E));return C.some(($)=>B.match($))})}function SF(D,u,F){let C=Gu(o2(F,D)),E=Gu(D);return u.some((B)=>{let $=Gu(B.startsWith("./")?B.slice(2):B);return $===C||$===E})}function Gu(D){return i2==="/"?D:D.split(i2).join("/")}var o1=/^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/,n1=/^[0-9A-Za-z.^~><=* +-]+$/,s1=/\.[tj]s$/,r1=/[*?]/;function e2(D,u,F){let C=D.packages;if(C===void 0)return[];if(!Array.isArray(C))return F.push(`${u}: packages must be an array \u2014 ignored`),[];let E=a1(C,u,F),B=C6(E,u,F);return E6(B,u,F)}function a1(D,u,F){let C=[],E=[];for(let B of D){let $=typeof B==="string"?{source:B}:e1(B,u,F);if($===null)E.push(JSON.stringify(B));else C.push($)}if(E.length>0)F.push(`${u}: packages entries must be a source string or a { "source": \u2026 } object \u2014 ignored: ${E.join(", ")}`);return C}function e1(D,u,F){if(!ZD(D))return null;let C=D.source;if(typeof C!=="string")return null;F6(D,C,u,F);let E=D.autoload;if(E!==void 0&&typeof E!=="boolean")F.push(`${u}: packages entry ${C}: autoload must be a boolean \u2014 ignored`);let B=D6(D,C,u,F);return{source:C,...B!==void 0?{extensions:B}:{},...E===!1?{autoloadDisabled:!0}:{}}}function D6(D,u,F,C){let E=D.extensions;if(E===void 0)return;if(!cD(E)){C.push(`${F}: packages entry ${u}: extensions must be an array of strings \u2014 ignored`);return}return E}var u6=new Set(["source","extensions","autoload"]),a2=new Set(["skills","prompts","themes"]);function F6(D,u,F,C){let E=Object.keys(D).filter((Z)=>!u6.has(Z)),B=E.filter((Z)=>a2.has(Z)),$=E.filter((Z)=>!a2.has(Z));if(B.length>0)C.push(`${F}: packages entry ${u}: cradle loads a package's extensions and nothing else \u2014 ignored: ${B.join(", ")}`);if($.length>0)C.push(`${F}: packages entry ${u}: unknown filter keys \u2014 ignored: ${$.join(", ")}`)}function C6(D,u,F){let C=D.filter((B)=>B.source.startsWith("npm:")),E=D.filter((B)=>!B.source.startsWith("npm:"));if(E.length>0){let B=E.map(($)=>$.source).join(", ");F.push(`${u}: only npm: package sources are supported \u2014 ignored: ${B}`)}return C}function E6(D,u,F){let C=[],E=[];for(let{source:B,...$}of D){let Z=B6(B.slice(4));if(Z===null)E.push(B);else C.push({...Z,...$})}if(E.length>0)F.push(`${u}: packages entries must be npm:<name>[@<version>] \u2014 ignored: ${E.join(", ")}`);return C}function B6(D){let u=D.lastIndexOf("@"),F=u>0,C=F?D.slice(0,u):D,E=F?D.slice(u+1):"latest";if(!o1.test(C)||!n1.test(E))return null;return{name:C,version:E}}function D8(D){let u=Object.fromEntries([...D].sort((F,C)=>F.name.localeCompare(C.name)).map((F)=>[F.name,F.version]));return`${JSON.stringify({name:"cradle-agent-packages",private:!0,dependencies:u},null,2)}
111
- `}async function u8(D,u){let F=await Promise.all(u.map(async(C)=>{let E=[];return{entries:await $6(D,C,E),warnings:E}}));return{entries:F.flatMap((C)=>C.entries),warnings:F.flatMap((C)=>C.warnings)}}async function $6(D,u,F){let C=dD(D,"node_modules",u.name),E=await z6(u.name,C,F);if(E===null)return[];let B=await Z6(C,E,u.name,F);return H6(B,u,C)}async function z6(D,u,F){let C=dD(u,"package.json"),E=await SD(C);if(E===void 0)return F.push(`package ${D} is not installed \u2014 skipped`),null;try{let B=Xu(E,C);if(!ZD(B))return F.push(`package ${D}: ${C} must be a JSON object \u2014 skipped`),null;return B}catch(B){return F.push(`package ${D}: ${Fu(B)} \u2014 skipped`),null}}async function Z6(D,u,F,C){let E=Q6(u);if(E!==void 0)return X6(D,E,F,C);let B=await F8(dD(D,"extensions"));if(B.length>0)return B;return q6(F,D,C)}function Q6(D){let u=D.pi;if(u===void 0||!ZD(u))return;let F=u.extensions;if(F===void 0||!cD(F)||F.length===0)return;return F}async function X6(D,u,F,C){let E=u.filter((M)=>!Lu(M)),$=(await Promise.all(E.map((M)=>M6(D,M,F,C)))).flat(),Z=u.filter(Lu);return Z.length>0?PF($,Z,D):$}async function M6(D,u,F,C){let E=await G6(D,u),B=E.filter((Z)=>O6(D,Z));if(B.length<E.length)C.push(`package ${F}: extension entry "${u}" escapes the package directory \u2014 skipped`);let $=await Promise.all(B.map(async(Z)=>({files:await J6(Z)})));if($.some((Z)=>Z.files===null))C.push(`package ${F}: extension entry "${u}" not found \u2014 skipped`);return $.flatMap((Z)=>Z.files??[])}async function G6(D,u){if(!r1.test(u))return[s2(D,u)];let F=new Bun.Glob(u).scan({cwd:D,absolute:!0,onlyFiles:!1});return(await Array.fromAsync(F)).map((C)=>s2(C)).sort()}async function J6(D){let u=await U6(D);if(u===void 0)return null;return u.isDirectory()?F8(D):[D]}async function F8(D){let F=[...await W6(D)].sort((E,B)=>E.name.localeCompare(B.name));return(await Promise.all(F.map((E)=>Y6(D,E)))).flat()}async function Y6(D,u){if(u.name.startsWith(".")||u.name==="node_modules")return[];if(u.isFile())return s1.test(u.name)?[dD(D,u.name)]:[];if(!u.isDirectory())return[];let F=await C8([dD(D,u.name,"index.ts"),dD(D,u.name,"index.js")]);return F===null?[]:[F]}async function q6(D,u,F){let C=await C8([dD(u,"index.ts"),dD(u,"index.js")]);if(C===null)return F.push(`package ${D} declares no pi extensions \u2014 skipped`),[];return[C]}function H6(D,u,F){if(u.autoloadDisabled===!0)return n2(D,u.extensions??[],F);if(u.extensions===void 0)return[...D];if(u.extensions.length===0)return[];return PF(D,u.extensions,F)}function O6(D,u){let F=D.endsWith(r2)?D:`${D}${r2}`;return u===D||u.startsWith(F)}async function C8(D){return(await Promise.all(D.map(async(F)=>await Bun.file(F).exists()?F:null))).find((F)=>F!==null)??null}async function U6(D){try{return await i1(D)}catch(u){if(XD(u,"ENOENT")||XD(u,"ENOTDIR"))return;throw u}}async function W6(D){try{return await l1(D,{withFileTypes:!0})}catch(u){if(XD(u,"ENOENT")||XD(u,"ENOTDIR"))return[];throw u}}var E8=["off","minimal","low","medium","high","xhigh"],B8=new Set(["schedules","subagents","channels","connections"]),I6=new Set(["SYSTEM.md","APPEND_SYSTEM.md","settings.json","models.json","skills","extensions","sandbox"]),K6=new Set([".git",".gitignore",".DS_Store","README.md","LICENSE"]),Iu={read:[],write:[],allow:[],unixSocketDirBind:[]},su={posture:"unconfigured",filesystem:Iu,unsafeMacosSeatbeltRules:[]};async function X8(D){let u=L6(D),F=await j6(u),C=new Map(F.map((M)=>[M.name,M])),E=C.has("SYSTEM.md"),B=C.has("APPEND_SYSTEM.md");if(!E&&!B){let M=C.has("AGENTS.md")?" \u2014 found AGENTS.md, rename it to APPEND_SYSTEM.md":"";throw Error(`Not an agent folder: ${u} (needs SYSTEM.md or APPEND_SYSTEM.md${M} \u2014 see ARCHITECTURE.md)`)}let $=[];_6(F,$);let Z=await h6(u,C.get("sandbox"),$);return{dir:u,systemFilePath:E?KD(u,"SYSTEM.md"):null,appendSystemFilePath:B?KD(u,"APPEND_SYSTEM.md"):null,settings:await N6(u,C.has("settings.json"),$),providersJson:await S6(u,C.has("models.json"),$),skillsDir:await x6(u,C.get("skills"),$),extensionFiles:await b6(u,C.get("extensions"),$),sandbox:Z.nono,sbx:Z.sbx,warnings:$}}async function j6(D){try{return await Q8(D,{withFileTypes:!0})}catch(u){if(XD(u,"ENOENT")||XD(u,"ENOTDIR"))throw Error(`Agent folder not found: ${D}`,{cause:u});throw u}}async function bF(D,u){if(u.isDirectory())return!0;if(!u.isSymbolicLink())return!1;try{return(await T6(KD(D,u.name))).isDirectory()}catch(F){if(XD(F,"ENOENT"))return!1;throw F}}function _6(D,u){let F=D.filter((E)=>B8.has(E.name)).map((E)=>E.name),C=D.map((E)=>E.name).filter((E)=>!I6.has(E)&&!B8.has(E)&&!K6.has(E));if(F.length>0)u.push(`reserved for a future cradle release, ignored: ${F.join(", ")}`);if(C.length>0)u.push(`not part of the agent folder format, ignored: ${C.join(", ")}`)}async function N6(D,u,F){if(!u)return{};let C=KD(D,"settings.json"),E=await wF(C);f6(E,C,F);let B=xF(E,"defaultProvider",C,F),$=xF(E,"defaultModel",C,F),Z=l6(E,C,F),M=e2(E,C,F),H=A6(E,C,F);return{...B!==void 0?{defaultProvider:B}:{},...$!==void 0?{defaultModel:$}:{},...Z!==void 0?{defaultThinkingLevel:Z}:{},...M.length>0?{packages:M}:{},...H!==void 0?{npmCommand:H}:{}}}var R6=new Set(["defaultProvider","defaultModel","defaultThinkingLevel","packages","npmCommand"]);function f6(D,u,F){let C=Object.keys(D).filter((E)=>!R6.has(E));if(C.length>0)F.push(`${u}: keys cradle does not map are ignored \u2014 pi reads them from ~/.pi/agent/settings.json or `+`the project's .pi/settings.json, not the agent folder: ${C.join(", ")}`)}var $8=new Set(["npm","pnpm","yarn","bun"]);function A6(D,u,F){let C=D.npmCommand;if(C===void 0)return;let[E,...B]=cD(C)?C:[];if(E===void 0||B.length>0||!$8.has(E)){let $=[...$8].join(", ");F.push(`${u}: npmCommand must be a single-element array naming one of ${$} \u2014 ignored`);return}return[E]}async function S6(D,u,F){if(!u)return null;let C=KD(D,"models.json"),E=await wF(C),B=E.providers;if(B===void 0||!ZD(B))throw Error(`${C} must contain a "providers" object`);return RD(E,C,["providers"],F),JSON.stringify(P6(B),null,2)}function P6(D){let u={input:0,output:0,cacheRead:0,cacheWrite:0};return Object.fromEntries(Object.entries(D).map(([F,C])=>{if(!ZD(C)||!Array.isArray(C.models))return[F,C];let E=C.models.map((B)=>ZD(B)&&B.cost===void 0?{cost:u,...B}:B);return[F,{...C,models:E}]}))}async function x6(D,u,F){if(!u)return null;if(!await bF(D,u))return F.push("skills must be a directory \u2014 ignored"),null;return KD(D,"skills")}async function b6(D,u,F){if(!u)return[];if(!await bF(D,u))return F.push("extensions must be a directory \u2014 ignored"),[];let C=KD(D,"extensions"),E=await Q8(C,{withFileTypes:!0});return(await Promise.all(E.sort(($,Z)=>$.name.localeCompare(Z.name)).map(async($)=>{if($.isFile()&&$.name.endsWith(".ts")&&!$.name.startsWith("."))return KD(C,$.name);if($.isDirectory()){let Z=KD(C,$.name,"index.ts");return await Bun.file(Z).exists()?Z:null}return null}))).filter(($)=>$!==null)}async function h6(D,u,F){let C={nono:su,sbx:su};if(!u)return C;if(!await bF(D,u))return F.push("sandbox must be a directory \u2014 ignored"),C;let E=KD(D,"sandbox","nono.json"),B=KD(D,"sandbox","sbx.json"),$=await z8(E),Z=await z8(B);if($===void 0&&Z===void 0)return F.push("sandbox/ has no nono.json or sbx.json \u2014 sandboxing stays off unless --sandbox is passed"),C;return{nono:$===void 0?su:w6($,E,F),sbx:Z===void 0?su:m6(Z,B,F)}}function w6(D,u,F){let C=ru(D,"sandbox",u,F),E=p6(D,u,F);return k6(D,u,F),RD(D,u,["sandbox","network","filesystem","unsafe_macos_seatbelt_rules","net"],F),{posture:C===!1?"disabled":"enabled",...E!==void 0?{network:E}:{},filesystem:g6(D.filesystem,u,F),unsafeMacosSeatbeltRules:y6(D.unsafe_macos_seatbelt_rules,u,F)}}function m6(D,u,F){let C=ru(D,"sandbox",u,F),E=v6(D,u,F);return hF({record:D,key:"unsafe_macos_seatbelt_rules",path:u,explanation:"the sbx VM boundary replaces Seatbelt"},F),RD(D,u,["sandbox","network","filesystem","unsafe_macos_seatbelt_rules"],F),{posture:C===!1?"disabled":"enabled",...E!==void 0?{network:E}:{},filesystem:c6(D.filesystem,u,F),unsafeMacosSeatbeltRules:[]}}function v6(D,u,F){let C=D.network;if(C===void 0)return;if(!ZD(C)){F.push(`${u}: network must be an object \u2014 ignored`);return}for(let M of["network_profile","open_port","listen_port"])hF({record:C,key:M,path:u},F);let E=`${u} network`;RD(C,E,["block","allow_domain","network_profile","open_port","listen_port"],F);let B=ru(C,"block",E,F),$=M8(C,"allow_domain",E,F),Z={...B!==void 0?{block:B}:{},...$.length>0?{allowDomain:$}:{}};return Object.keys(Z).length>0?Z:void 0}function c6(D,u,F){if(D===void 0)return Iu;if(!ZD(D))return F.push(`${u}: filesystem must be an object \u2014 ignored`),Iu;return hF({record:D,key:"unix_socket_dir_bind",path:u,explanation:"Unix sockets cannot cross the sbx VM boundary"},F),RD(D,`${u} filesystem`,["read","write","allow","unix_socket_dir_bind"],F),{read:Cu(D,"read",u,F),write:Cu(D,"write",u,F),allow:Cu(D,"allow",u,F),unixSocketDirBind:[]}}function hF({record:D,key:u,path:F,explanation:C},E){if(D[u]===void 0)return;E.push(`${F}: ${u} is nono-only \u2014 ${C!==void 0?`${C}; `:""}ignored`)}async function z8(D){return await d6(D)?wF(D):void 0}async function d6(D){try{return await V6(D),!0}catch(u){if(XD(u,"ENOENT"))return!1;throw u}}function k6(D,u,F){if(D.net!==void 0)F.push(`${u}: "net" was removed \u2014 use "network" instead (see ARCHITECTURE.md) \u2014 ignored`)}function p6(D,u,F){let C=D.network;if(C===void 0)return;if(!ZD(C)){F.push(`${u}: network must be an object \u2014 ignored`);return}let E=`${u} network`;RD(C,E,["block","network_profile","allow_domain","open_port","listen_port"],F);let B=ru(C,"block",E,F),$=xF(C,"network_profile",E,F),Z=M8(C,"allow_domain",E,F),M=Z8(C,"open_port",E,F),H=Z8(C,"listen_port",E,F),V={...B!==void 0?{block:B}:{},...$!==void 0?{networkProfile:$}:{},...Z.length>0?{allowDomain:Z}:{},...M.length>0?{openPort:M}:{},...H.length>0?{listenPort:H}:{}};return Object.keys(V).length>0?V:void 0}function M8(D,u,F,C){let E=D[u];if(E===void 0)return[];if(!cD(E))return C.push(`${F}: ${u} must be an array of strings \u2014 ignored`),[];let B=E.map(($)=>$.trim()).filter(($)=>$!=="");if(B.length!==E.length)C.push(`${F}: ${u} entries must be non-empty \u2014 blanks ignored`);return B}function Z8(D,u,F,C){let E=D[u];if(E===void 0)return[];if(!Array.isArray(E))return C.push(`${F}: ${u} must be an array of port numbers \u2014 ignored`),[];let B=(Z)=>typeof Z==="number"&&Number.isInteger(Z)&&Z>=0&&Z<=65535,$=E.filter((Z)=>!B(Z)).map((Z)=>typeof Z==="object"&&Z!==null?JSON.stringify(Z):String(Z));if($.length>0)C.push(`${F}: ${u} entries must be integers 0\u201365535 \u2014 ignored: ${$.join(", ")}`);return E.filter(B)}function y6(D,u,F){if(D===void 0)return[];if(!cD(D))return F.push(`${u}: unsafe_macos_seatbelt_rules must be an array of strings \u2014 ignored`),[];let C=(B)=>{let $=B.trim();return $.startsWith("(")&&$.endsWith(")")},E=D.filter((B)=>!C(B));if(E.length>0)F.push(`${u}: unsafe_macos_seatbelt_rules entries must be parenthesized s-expressions \u2014 ignored: ${E.join(", ")}`);return D.filter(C).map((B)=>B.trim())}function ru(D,u,F,C){let E=D[u];if(E===void 0)return;if(typeof E!=="boolean"){C.push(`${F}: ${u} must be true or false \u2014 ignored`);return}return E}function g6(D,u,F){if(D===void 0)return Iu;if(!ZD(D))return F.push(`${u}: filesystem must be an object \u2014 ignored`),Iu;return RD(D,`${u} filesystem`,["read","write","allow","unix_socket_dir_bind"],F),{read:Cu(D,"read",u,F),write:Cu(D,"write",u,F),allow:Cu(D,"allow",u,F),unixSocketDirBind:Cu(D,"unix_socket_dir_bind",u,F)}}function Cu(D,u,F,C){let E=D[u];if(E===void 0)return[];if(!cD(E))return C.push(`${F}: ${u} must be an array of strings \u2014 ignored`),[];let B=E.filter(($)=>!Tu($));if(B.length>0)C.push(`${F}: ${u} entries must be absolute, ~/, or $HOME/ paths \u2014 ignored: ${B.join(", ")}`);return E.filter(Tu)}async function wF(D){let u=Xu(await t6(D),D);if(!ZD(u))throw Error(`${D} must be a JSON object`);return u}async function t6(D){let u;try{u=await SD(D)}catch(F){throw Error(`${D} could not be read: ${Fu(F)}`,{cause:F})}if(u===void 0)throw Error(`${D} could not be read \u2014 broken symlink?`);return u}function xF(D,u,F,C){let E=D[u];if(E===void 0)return;if(typeof E!=="string"){C.push(`${F}: ${u} must be a string \u2014 ignored`);return}return E}function l6(D,u,F){let C=D.defaultThinkingLevel;if(C===void 0)return;if(typeof C!=="string"||!E8.includes(C)){F.push(`${u}: defaultThinkingLevel must be one of ${E8.join(", ")} \u2014 ignored`);return}return C}import{createHash as i6}from"crypto";import{homedir as o6}from"os";import{basename as n6,join as Ku}from"path";function s6(D){let u=n6(D).toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""),F=i6("sha256").update(D).digest("hex").slice(0,8);return`${u===""?"agent":u}-${F}`}function G8(D,u=o6(),F=process.env.CRADLE_STATE_DIR){let C=F||Ku(u,".cradle");return Ku(C,"agents",s6(D))}function J8(D){return{extensionsDir:Ku(D,"extensions"),sessionsDir:Ku(D,"sessions"),miseCacheDir:Ku(D,"mise-cache")}}import{readFile as r6}from"fs/promises";import{join as Y8,resolve as q8}from"path";var H8="gitdir:";async function O8(D){try{return await r6(D,"utf8")}catch{return}}async function U8(D){let u=await O8(Y8(D,".git"));if(u===void 0||!u.startsWith(H8))return;let F=q8(D,u.slice(H8.length).trim()),C=await O8(Y8(F,"commondir")),E=C!==void 0?q8(F,C.trim()):F;return lu(D,E)?void 0:E}async function T8(D,u={}){let F=u.home??D7(),C=u.cwd??process.cwd(),{dir:E,warnings:B}=await h2(D.dir,{home:F,cwd:C}),$=await X8(E),Z=G8($.dir,F),{extensionsDir:M,sessionsDir:H,miseCacheDir:V}=J8(Z),Y=B7(D,$),q=D.dryRun??!1,O=W7(Y.backend,q,u.which),W=C7({folder:$,flags:D,backend:Y.backend,bins:O,stateDir:Z,extensionsDir:M,sessionsDir:H,miseCacheDir:V}),J=await V7(Y,$,{home:F,cwd:C,stateDir:Z,profilePath:W.profilePath,sbxBin:O.sbxBin,hostPiBin:O.piBin,tty:u.tty??!1}),S=E7($,Z);return{files:I7($,Y.backend),extensionsDir:M,sessionsDir:H,warnings:[...B,...Y.warnings,...J.warnings],profile:J.profile,sbx:J.sbx,packages:S,launch:W,dryRun:q}}function C7(D){let{folder:u,flags:F,backend:C,bins:E,stateDir:B,extensionsDir:$,sessionsDir:Z,miseCacheDir:M}=D;return{folder:u,stateDir:B,extensionsDir:$,sessionsDir:Z,miseCacheDir:M,backend:C,passthrough:F.passthrough??[],nonoBin:E.nonoBin,piBin:C==="sbx"?"pi":E.piBin,profilePath:ju(B,K2),...F.verbose?{verbose:!0}:{}}}function E7(D,u){let F=D.settings.packages;if(F===void 0||F.length===0)return null;return{npmDir:ju(u,"npm"),manifest:D8(F),specs:F,installCommand:[...D.settings.npmCommand??["npm"],"install","--ignore-scripts"]}}function B7(D,u){let{backend:F,warnings:C}=M7(D,u),E=[],B=$7(D,u,F,E);return{backend:F,network:B,warnings:Q7(F!==null,B,[...C,...E])}}function $7(D,u,F,C){if(D.offline)return{block:!0};let E=z7(D.allowHost??[],C);if(E.length>0)return{allowDomain:E};return F==="sbx"?u.sbx.network:u.sandbox.network}function z7(D,u){let F=D.map((C)=>C.trim()).filter((C)=>C!=="");if(F.length!==D.length)u.push("--allow-host entries must be non-empty \u2014 blanks ignored");return F}function Z7(D){return D!==void 0&&(D.block===!0||(D.allowDomain?.length??0)>0)}function Q7(D,u,F){if(D||!Z7(u))return F;return[...F,"network policy has no effect without the sandbox \u2014 pi runs with no network isolation (--sandbox to enforce it)"]}function X7(D){return D.offline===!0||(D.allowHost?.length??0)>0}function M7(D,u){if(D.noSandbox===!0)return{backend:null,warnings:u.warnings};if(D.sandboxBackend!==void 0)return{backend:D.sandboxBackend,warnings:u.warnings};let F=G7(u);if(D.noSandbox===!1||F.backend!==null)return{...F,backend:F.backend??"nono"};return J7(D,u,F.warnings)}function G7(D){let u=D.sandbox.posture==="enabled",F=D.sbx.posture==="enabled";if(u&&F)return{backend:"nono",warnings:[...D.warnings,"both sandbox/nono.json and sandbox/sbx.json declare a sandbox \u2014 using nono (pass --sandbox-backend sbx to override)"]};return{backend:u?"nono":F?"sbx":null,warnings:D.warnings}}function J7(D,u,F){let C=Y7(u);if(X7(D))return{backend:"nono",warnings:[...F,`${C} \u2014 sandbox forced on to enforce the requested network policy (--no-sandbox to override)`]};return{backend:null,warnings:[...F,`${C} \u2014 agent is running without OS isolation (--sandbox to force enable)`]}}function Y7(D){if(D.sandbox.posture==="disabled")return"sandbox disabled by sandbox/nono.json";if(D.sbx.posture==="disabled")return"sandbox disabled by sandbox/sbx.json";return"sandbox/nono.json or sbx.json not found"}async function L8(D,u={}){let F={dryRun:!1,results:[],failures:[]};if(await f2(F,"extensions",D.extensionsDir,D.files),F.failures.length>0)throw Error(`Failed to write agent extensions: ${F.failures.join("; ")}`);if(await mF(D.sessionsDir,{recursive:!0}),D.profile!==null)await mF(F7(D.profile.path),{recursive:!0}),await V8(D.profile.path,D.profile.content,"utf8");if(D.sbx!==null)await q7(D.sbx,u);let C={...D.launch,extensionsDir:D.extensionsDir,sessionsDir:D.sessionsDir},E=D.packages===null?{argv:Qu(C),warnings:[]}:await U7(D.packages,C,u);if(D.sbx===null)return E;return{argv:nu(D.sbx.spec,E.argv),warnings:E.warnings}}async function q7(D,u){let F=u.run;if(F===void 0)throw Error("An sbx-backend run needs a command runner but none was provided");let C=await F(D.createArgv);if(C.exitCode!==0&&!g2(C.stderr))throw Error(`Failed to create sbx sandbox ${D.spec.name}: ${C.stderr.trim()}`);for(let E of D.policyArgvs)await W8(F,E,`apply sbx network policy (${D.spec.name})`);await W8(F,await H7(D,u),`provision pi in sbx sandbox ${D.spec.name}`)}async function W8(D,u,F){let C=await D(u);if(C.exitCode!==0)throw Error(`Failed to ${F}: ${C.stderr.trim()}`)}async function H7(D,u){if(u.readPiVersion===void 0)return D.provisionArgv;let F=await u.readPiVersion(D.hostPiBin);return RF({...D.spec,piVersion:F})}async function O7(D,u){if(await SD(ju(D,"package.json"))!==u)return!1;return a6(ju(D,"node_modules"))}async function U7(D,u,F){if(await mF(D.npmDir,{recursive:!0}),!await O7(D.npmDir,D.manifest)){if(F.install===void 0)throw Error("Packages declared but no installer provided");let B=ju(D.npmDir,"package.json");await V8(B,D.manifest,"utf8");try{await F.install(D.installCommand,D.npmDir)}catch($){throw await e6(B,{force:!0}),$}}let{entries:C,warnings:E}=await u8(D.npmDir,D.specs);return{argv:Qu({...u,packageEntries:C}),warnings:E}}function W7(D,u,F){if(u)return{nonoBin:"nono",piBin:"pi",sbxBin:"sbx"};return{nonoBin:D==="nono"?tu("nono",F):"nono",sbxBin:D==="sbx"?tu("sbx",F):"sbx",piBin:tu("pi",F)}}async function V7(D,u,F){let C=D.backend!==null?await U8(F.cwd):void 0,E=L7(D.backend==="nono",u,D.network,{home:F.home,cwd:F.cwd,stateDir:F.stateDir,profilePath:F.profilePath,...C!==void 0?{linkedGitDir:C}:{}});if(D.backend!=="sbx")return{profile:E,sbx:null,warnings:[]};let B=T7(D.network,u,{...F,...C!==void 0?{linkedGitDir:C}:{}});return{profile:E,sbx:B,warnings:[...p2(D.network),...y2(u.sbx.filesystem)]}}function T7(D,u,F){let C=v2({cwd:F.cwd,agentDir:u.dir,stateDir:F.stateDir,home:F.home,grants:u.sbx.filesystem,...F.linkedGitDir!==void 0?{linkedGitDir:F.linkedGitDir}:{}}),E={sbxBin:F.sbxBin,name:c2(u7(F.stateDir),C),cwd:F.cwd,home:F.home,mounts:C,...D!==void 0?{network:D}:{},piVersion:null,tty:F.tty};return{spec:E,hostPiBin:F.hostPiBin,createArgv:d2(E),policyArgvs:k2(E),provisionArgv:RF(E)}}function L7(D,u,F,C){if(!D)return null;let E=j2(C.cwd,C.home);if(E!==void 0)throw Error(`cannot sandbox from ${E} \u2014 this directory is (or contains) nono's protected state root `+"(~/.local/state/nono) and nono refuses to start with an overlapping grant; run `cradle run` from a project directory instead");let B=_2({home:C.home,cwd:C.cwd,agentDir:u.dir,stateDir:C.stateDir,grants:u.sandbox.filesystem,rules:u.sandbox.unsafeMacosSeatbeltRules,...F!==void 0?{network:F}:{},...C.linkedGitDir!==void 0?{linkedGitDir:C.linkedGitDir}:{}});return{path:C.profilePath,content:B}}function I7(D,u){return[...D.providersJson!==null?[{rel:"providers.ts",content:l2(D.providersJson,{rewriteLocalhostBaseUrls:u==="sbx"})}]:[],...u==="nono"?[{rel:gu,content:U2()}]:[]]}function I8(D,u){return u?`\x1B[33m${D}\x1B[0m`:D}function K8(D,u){return()=>{D.kill(u)}}async function j8(D,u={}){let[F,...C]=D;if(!F)throw Error("Command requires at least one argument");let E=Bun.spawn([F,...C],{stdin:"inherit",stdout:"inherit",stderr:"inherit",env:{...process.env,...u}}),B=K8(E,"SIGINT"),$=K8(E,"SIGTERM");process.on("SIGINT",B),process.on("SIGTERM",$);try{return await E.exited}finally{process.off("SIGINT",B),process.off("SIGTERM",$)}}async function _8(D){let[u,...F]=D;if(!u)throw Error("Command requires at least one argument");let C=Bun.spawn([u,...F],{stdin:"ignore",stdout:"ignore",stderr:"pipe",env:process.env}),[E,B]=await Promise.all([new Response(C.stderr).text(),C.exited]);return{exitCode:B,stderr:E}}async function N8(D,u){let[F,...C]=D;if(!F)throw Error("Command requires at least one argument");let B=await Bun.spawn([F,...C],{cwd:u,stdin:"ignore",stdout:"inherit",stderr:"inherit",env:process.env}).exited;if(B!==0)throw Error(`Package install failed (${D.join(" ")} exited ${String(B)})`)}var _u=H2(process.argv.slice(2)).scriptName("cradle").version(O2.version).usage("$0 <cmd> [args]").parserConfiguration({"populate--":!0,"parse-numbers":!1,"parse-positional-numbers":!1}).strict();_u.command("$0","show help",()=>{},async()=>{console.log(await _u.getHelp())});_u.command("run [dir]","run an agent folder with pi, sandboxed when sandbox/nono.json or sandbox/sbx.json is present",(D)=>D.positional("dir",{type:"string",default:".",describe:"agent folder, or a name from ~/.cradle/settings.json (default: .)"}).option("offline",{type:"boolean",description:"block all outbound network (overrides the folder network policy; implies --sandbox)"}).option("allow-host",{type:"array",string:!0,description:"restrict network to these hosts (repeatable; overrides the folder allowlist; implies --sandbox)"}).option("sandbox",{type:"boolean",description:"run sandboxed (--sandbox forces it when no sandbox/ file enables one or the folder opts out; --no-sandbox disables)"}).option("sandbox-backend",{type:"string",choices:["nono","sbx"],description:"sandbox implementation (implies --sandbox): nono (host OS policy) or sbx (Docker Sandboxes microVM)"}).option("verbose",{type:"boolean",default:!1,description:"show nono's full sandbox capabilities banner instead of the one-line status"}).option("dry-run",{type:"boolean",default:!1,description:"print the write plan + command, do not spawn"}).epilogue("Everything after `--` is forwarded to pi."),async(D)=>{let u=(D["--"]??[]).map(String),F=(D.allowHost??[]).map(String),C={dir:D.dir,dryRun:D.dryRun,...D.sandbox!==void 0?{noSandbox:!D.sandbox}:{},...D.sandboxBackend!==void 0?{sandboxBackend:D.sandboxBackend}:{},...D.offline?{offline:!0}:{},...F.length?{allowHost:F}:{},...D.verbose?{verbose:!0}:{},...u.length?{passthrough:u}:{}};await K7(C)});_u.command("doctor","check pi / nono / mise on PATH",()=>{},async()=>{let D=await T2({readVersion:A8});console.log(L2(D)),process.exitCode=I2(D)});async function K7(D){try{let u=await T8(D,{tty:process.stdout.isTTY});if(R8(u.warnings),u.dryRun){j7(u);return}let F=await L8(u,{install:N8,run:_8,readPiVersion:A8});if(R8(F.warnings),u.profile!==null&&!D.verbose)console.log("\uD83D\uDD12 Sandbox Active");if(u.sbx!==null&&!D.verbose)console.log("\uD83D\uDD12 Sandbox Active (sbx)");process.exit(await j8(F.argv,_F(u.launch)))}catch(u){R7(u)}}function j7(D){for(let C of D.files)console.log(`write: ${f8(D.extensionsDir,C.rel)}`);if(D.profile!==null)console.log(`write: ${D.profile.path}`);if(D.sbx!==null)_7(D.sbx);if(D.packages!==null)N7(D.packages);let u=Object.entries(_F(D.launch)).map(([C,E])=>`${C}=${Mu(E)}`),F=D.sbx!==null?nu(D.sbx.spec,Qu(D.launch)):Qu(D.launch);console.log([...u,...F.map(Mu)].join(" "))}function _7(D){console.log(`create: ${D.createArgv.map(Mu).join(" ")}`);for(let u of D.policyArgvs)console.log(`policy: ${u.map(Mu).join(" ")}`);console.log(`provision: ${D.provisionArgv.map(Mu).join(" ")}`)}function N7(D){console.log(`write: ${f8(D.npmDir,"package.json")}`);let u=D.specs.map((F)=>`${F.name}@${F.version}`).join(", ");console.log(`install: ${D.installCommand.join(" ")} (${D.npmDir}): ${u}`)}function R8(D){let u=process.stderr.isTTY;for(let F of D)console.error(I8(`warning: ${F}`,u))}async function A8(D,u=["--version"]){try{let F=Bun.spawn([D,...u],{stdout:"pipe",stderr:"ignore"}),[C,E]=await Promise.all([new Response(F.stdout).text(),F.exited]);if(E!==0)return null;return C.split(`
112
- `)[0]?.match(/v?\d+\.\d+\S*/)?.[0]??null}catch{return null}}function R7(D){console.error(D instanceof Error?D.message:String(D)),process.exitCode=1}_u.parse();
110
+ `}function il(e){let n=JSON.parse(e);for(let t of Object.values(n)){if(t===null||typeof t!=="object")continue;let r=t;if(typeof r.baseUrl==="string")r.baseUrl=ps(r.baseUrl)}return JSON.stringify(n,null,2)}import{lstat as Ml,readdir as ks,stat as Nl}from"fs/promises";import{join as we,resolve as Rl}from"path";import{readdir as al,stat as ul}from"fs/promises";import{join as Ge,resolve as Es,sep as Cs}from"path";import{basename as sl,relative as ys,sep as Fs}from"path";function On(e){return e.startsWith("!")||e.startsWith("+")||e.startsWith("-")}function qt(e,n,t){let r=n.filter((u)=>!On(u)),i=Yt(n,"!"),s=Yt(n,"+"),o=Yt(n,"-");return e.filter((u)=>{if(Kt(u,o,t))return!1;if(Kt(u,s,t))return!0;if(Jt(u,i,t))return!1;return r.length===0||Jt(u,r,t)})}function bs(e,n,t){return e.filter((r)=>{let i=n.filter((s)=>ol(r,s,t)).at(-1);return i!==void 0&&!i.startsWith("-")&&!i.startsWith("!")})}function ol(e,n,t){let r=On(n)?n.slice(1):n;return n.startsWith("+")||n.startsWith("-")?Kt(e,[r],t):Jt(e,[r],t)}function Yt(e,n){return e.filter((t)=>t.startsWith(n)).map((t)=>t.slice(1))}function Jt(e,n,t){let r=[bn(ys(t,e)),sl(e),bn(e)];return n.some((i)=>{let s=new Bun.Glob(bn(i));return r.some((o)=>s.match(o))})}function Kt(e,n,t){let r=bn(ys(t,e)),i=bn(e);return n.some((s)=>{let o=bn(s.startsWith("./")?s.slice(2):s);return o===r||o===i})}function bn(e){return Fs==="/"?e:e.split(Fs).join("/")}var ll=/^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/,cl=/^[0-9A-Za-z.^~><=* +-]+$/,dl=/\.[tj]s$/,fl=/[*?]/;function xs(e,n,t){let r=e.packages;if(r===void 0)return[];if(!Array.isArray(r))return t.push(`${n}: packages must be an array \u2014 ignored`),[];let i=hl(r,n,t),s=Fl(i,n,t);return yl(s,n,t)}function hl(e,n,t){let r=[],i=[];for(let s of e){let o=typeof s==="string"?{source:s}:Dl(s,n,t);if(o===null)i.push(JSON.stringify(s));else r.push(o)}if(i.length>0)t.push(`${n}: packages entries must be a source string or a { "source": \u2026 } object \u2014 ignored: ${i.join(", ")}`);return r}function Dl(e,n,t){if(!le(e))return null;let r=e.source;if(typeof r!=="string")return null;ml(e,r,n,t);let i=e.autoload;if(i!==void 0&&typeof i!=="boolean")t.push(`${n}: packages entry ${r}: autoload must be a boolean \u2014 ignored`);let s=gl(e,r,n,t);return{source:r,...s!==void 0?{extensions:s}:{},...i===!1?{autoloadDisabled:!0}:{}}}function gl(e,n,t,r){let i=e.extensions;if(i===void 0)return;if(!ze(i)){r.push(`${t}: packages entry ${n}: extensions must be an array of strings \u2014 ignored`);return}return i}var pl=new Set(["source","extensions","autoload"]),ws=new Set(["skills","prompts","themes"]);function ml(e,n,t,r){let i=Object.keys(e).filter((u)=>!pl.has(u)),s=i.filter((u)=>ws.has(u)),o=i.filter((u)=>!ws.has(u));if(s.length>0)r.push(`${t}: packages entry ${n}: cradle loads a package's extensions and nothing else \u2014 ignored: ${s.join(", ")}`);if(o.length>0)r.push(`${t}: packages entry ${n}: unknown filter keys \u2014 ignored: ${o.join(", ")}`)}function Fl(e,n,t){let r=e.filter((s)=>s.source.startsWith("npm:")),i=e.filter((s)=>!s.source.startsWith("npm:"));if(i.length>0){let s=i.map((o)=>o.source).join(", ");t.push(`${n}: only npm: package sources are supported \u2014 ignored: ${s}`)}return r}function yl(e,n,t){let r=[],i=[];for(let{source:s,...o}of e){let u=bl(s.slice(4));if(u===null)i.push(s);else r.push({...u,...o})}if(i.length>0)t.push(`${n}: packages entries must be npm:<name>[@<version>] \u2014 ignored: ${i.join(", ")}`);return r}function bl(e){let n=e.lastIndexOf("@"),t=n>0,r=t?e.slice(0,n):e,i=t?e.slice(n+1):"latest";if(!ll.test(r)||!cl.test(i))return null;return{name:r,version:i}}function Ss(e){let n=Object.fromEntries([...e].sort((t,r)=>t.name.localeCompare(r.name)).map((t)=>[t.name,t.version]));return`${JSON.stringify({name:"cradle-agent-packages",private:!0,dependencies:n},null,2)}
111
+ `}async function As(e,n){let t=await Promise.all(n.map(async(r)=>{let i=[];return{entries:await El(e,r,i),warnings:i}}));return{entries:t.flatMap((r)=>r.entries),warnings:t.flatMap((r)=>r.warnings)}}async function El(e,n,t){let r=Ge(e,"node_modules",n.name),i=await Cl(n.name,r,t);if(i===null)return[];let s=await wl(r,i,n.name,t);return $l(s,n,r)}async function Cl(e,n,t){let r=Ge(n,"package.json"),i=await Ae(r);if(i===void 0)return t.push(`package ${e} is not installed \u2014 skipped`),null;try{let s=yn(i,r);if(!le(s))return t.push(`package ${e}: ${r} must be a JSON object \u2014 skipped`),null;return s}catch(s){return t.push(`package ${e}: ${Se(s)} \u2014 skipped`),null}}async function wl(e,n,t,r){let i=xl(n);if(i!==void 0)return Sl(e,i,t,r);let s=await Ps(Ge(e,"extensions"));if(s.length>0)return s;return Ol(t,e,r)}function xl(e){let n=e.pi;if(n===void 0||!le(n))return;let t=n.extensions;if(t===void 0||!ze(t)||t.length===0)return;return t}async function Sl(e,n,t,r){let i=n.filter((c)=>!On(c)),o=(await Promise.all(i.map((c)=>Al(e,c,t,r)))).flat(),u=n.filter(On);return u.length>0?qt(o,u,e):o}async function Al(e,n,t,r){let i=await Pl(e,n),s=i.filter((u)=>vl(e,u));if(s.length<i.length)r.push(`package ${t}: extension entry "${n}" escapes the package directory \u2014 skipped`);let o=await Promise.all(s.map(async(u)=>({files:await _l(u)})));if(o.some((u)=>u.files===null))r.push(`package ${t}: extension entry "${n}" not found \u2014 skipped`);return o.flatMap((u)=>u.files??[])}async function Pl(e,n){if(!fl.test(n))return[Es(e,n)];let t=new Bun.Glob(n).scan({cwd:e,absolute:!0,onlyFiles:!1});return(await Array.fromAsync(t)).map((r)=>Es(r)).sort()}async function _l(e){let n=await jl(e);if(n===void 0)return null;return n.isDirectory()?Ps(e):[e]}async function Ps(e){let t=[...await kl(e)].sort((i,s)=>i.name.localeCompare(s.name));return(await Promise.all(t.map((i)=>Bl(e,i)))).flat()}async function Bl(e,n){if(n.name.startsWith(".")||n.name==="node_modules")return[];if(n.isFile())return dl.test(n.name)?[Ge(e,n.name)]:[];if(!n.isDirectory())return[];let t=await _s([Ge(e,n.name,"index.ts"),Ge(e,n.name,"index.js")]);return t===null?[]:[t]}async function Ol(e,n,t){let r=await _s([Ge(n,"index.ts"),Ge(n,"index.js")]);if(r===null)return t.push(`package ${e} declares no pi extensions \u2014 skipped`),[];return[r]}function $l(e,n,t){if(n.autoloadDisabled===!0)return bs(e,n.extensions??[],t);if(n.extensions===void 0)return[...e];if(n.extensions.length===0)return[];return qt(e,n.extensions,t)}function vl(e,n){let t=e.endsWith(Cs)?e:`${e}${Cs}`;return n===e||n.startsWith(t)}async function _s(e){return(await Promise.all(e.map(async(t)=>await Bun.file(t).exists()?t:null))).find((t)=>t!==null)??null}async function jl(e){try{return await ul(e)}catch(n){if(de(n,"ENOENT")||de(n,"ENOTDIR"))return;throw n}}async function kl(e){try{return await al(e,{withFileTypes:!0})}catch(n){if(de(n,"ENOENT")||de(n,"ENOTDIR"))return[];throw n}}var Bs=["off","minimal","low","medium","high","xhigh","max"],Os=new Set(["subagents","channels","connections"]),Il=new Set(["SYSTEM.md","APPEND_SYSTEM.md","settings.json","models.json","skills","schedule","extensions","sandbox"]),Tl=new Set([".git",".gitignore",".DS_Store","README.md","LICENSE"]),$n={read:[],write:[],allow:[],unixSocketDirBind:[]},ot={posture:"unconfigured",filesystem:$n,unsafeMacosSeatbeltRules:[]};async function at(e){let n=Rl(e),t=await Ll(n),r=new Map(t.map((c)=>[c.name,c])),i=r.has("SYSTEM.md"),s=r.has("APPEND_SYSTEM.md");if(!i&&!s){let c=r.has("AGENTS.md")?" \u2014 found AGENTS.md, rename it to APPEND_SYSTEM.md":"";throw Error(`Not an agent folder: ${n} (needs SYSTEM.md or APPEND_SYSTEM.md${c} \u2014 see ARCHITECTURE.md)`)}let o=[];Wl(t,o);let u=await Zl(n,r.get("sandbox"),o);return{dir:n,systemFilePath:i?we(n,"SYSTEM.md"):null,appendSystemFilePath:s?we(n,"APPEND_SYSTEM.md"):null,settings:await Vl(n,r.has("settings.json"),o),providersJson:await Yl(n,r.has("models.json"),o),skillsDir:await Kl(n,r.get("skills"),o),scheduleDir:await ql(n,r.get("schedule"),o),extensionFiles:await Xl(n,r.get("extensions"),o),sandbox:u.nono,sbx:u.sbx,warnings:o}}async function Ll(e){try{return await ks(e,{withFileTypes:!0})}catch(n){if(de(n,"ENOENT")||de(n,"ENOTDIR"))throw Error(`Agent folder not found: ${e}`,{cause:n});throw n}}async function ut(e,n){if(n.isDirectory())return!0;if(!n.isSymbolicLink())return!1;try{return(await Nl(we(e,n.name))).isDirectory()}catch(t){if(de(t,"ENOENT"))return!1;throw t}}function Wl(e,n){let t=e.filter((i)=>Os.has(i.name)).map((i)=>i.name),r=e.map((i)=>i.name).filter((i)=>!Il.has(i)&&!Os.has(i)&&!Tl.has(i));if(t.length>0)n.push(`reserved for a future cradle release, ignored: ${t.join(", ")}`);if(r.length>0)n.push(`not part of the agent folder format, ignored: ${r.join(", ")}${Hl(r)}`)}function Hl(e){return e.includes("schedules")?" \u2014 did you mean schedule/ (singular)?":""}async function Vl(e,n,t){if(!n)return{};let r=we(e,"settings.json"),i=await Qt(r);Gl(i,r,t);let s=Xt(i,"defaultProvider",r,t),o=Xt(i,"defaultModel",r,t),u=lc(i,r,t),c=xs(i,r,t),p=Ul(i,r,t);return{...s!==void 0?{defaultProvider:s}:{},...o!==void 0?{defaultModel:o}:{},...u!==void 0?{defaultThinkingLevel:u}:{},...c.length>0?{packages:c}:{},...p!==void 0?{npmCommand:p}:{}}}var zl=new Set(["defaultProvider","defaultModel","defaultThinkingLevel","packages","npmCommand"]);function Gl(e,n,t){let r=Object.keys(e).filter((i)=>!zl.has(i));if(r.length>0)t.push(`${n}: keys cradle does not map are ignored \u2014 pi reads them from ~/.pi/agent/settings.json or `+`the project's .pi/settings.json, not the agent folder: ${r.join(", ")}`)}var $s=new Set(["npm","pnpm","yarn","bun"]);function Ul(e,n,t){let r=e.npmCommand;if(r===void 0)return;let[i,...s]=ze(r)?r:[];if(i===void 0||s.length>0||!$s.has(i)){let o=[...$s].join(", ");t.push(`${n}: npmCommand must be a single-element array naming one of ${o} \u2014 ignored`);return}return[i]}async function Yl(e,n,t){if(!n)return null;let r=we(e,"models.json"),i=await Qt(r),s=i.providers;if(s===void 0||!le(s))throw Error(`${r} must contain a "providers" object`);return Oe(i,r,["providers"],t),JSON.stringify(Jl(s),null,2)}function Jl(e){let n={input:0,output:0,cacheRead:0,cacheWrite:0};return Object.fromEntries(Object.entries(e).map(([t,r])=>{if(!le(r)||!Array.isArray(r.models))return[t,r];let i=r.models.map((s)=>le(s)&&s.cost===void 0?{cost:n,...s}:s);return[t,{...r,models:i}]}))}async function Kl(e,n,t){if(!n)return null;if(!await ut(e,n))return t.push("skills must be a directory \u2014 ignored"),null;return we(e,"skills")}async function ql(e,n,t){if(!n)return null;if(!await ut(e,n))return t.push("schedule must be a directory \u2014 ignored"),null;return we(e,"schedule")}async function Xl(e,n,t){if(!n)return[];if(!await ut(e,n))return t.push("extensions must be a directory \u2014 ignored"),[];let r=we(e,"extensions"),i=await ks(r,{withFileTypes:!0});return(await Promise.all(i.sort((o,u)=>o.name.localeCompare(u.name)).map(async(o)=>{if(o.isFile()&&o.name.endsWith(".ts")&&!o.name.startsWith("."))return we(r,o.name);if(o.isDirectory()){let u=we(r,o.name,"index.ts");return await Bun.file(u).exists()?u:null}return null}))).filter((o)=>o!==null)}async function Zl(e,n,t){let r={nono:ot,sbx:ot};if(!n)return r;if(!await ut(e,n))return t.push("sandbox must be a directory \u2014 ignored"),r;let i=we(e,"sandbox","nono.json"),s=we(e,"sandbox","sbx.json"),o=await vs(i),u=await vs(s);if(o===void 0&&u===void 0)return t.push("sandbox/ has no nono.json or sbx.json \u2014 sandboxing stays off unless --sandbox is passed"),r;return{nono:o===void 0?ot:Ql(o,i,t),sbx:u===void 0?ot:ec(u,s,t)}}function Ql(e,n,t){let r=lt(e,"sandbox",n,t),i=sc(e,n,t);return ic(e,n,t),Oe(e,n,["sandbox","network","filesystem","unsafe_macos_seatbelt_rules","net"],t),{posture:r===!1?"disabled":"enabled",...i!==void 0?{network:i}:{},filesystem:ac(e.filesystem,n,t),unsafeMacosSeatbeltRules:oc(e.unsafe_macos_seatbelt_rules,n,t)}}function ec(e,n,t){let r=lt(e,"sandbox",n,t),i=nc(e,n,t);return Zt({record:e,key:"unsafe_macos_seatbelt_rules",path:n,explanation:"the sbx VM boundary replaces Seatbelt"},t),Oe(e,n,["sandbox","network","filesystem","unsafe_macos_seatbelt_rules"],t),{posture:r===!1?"disabled":"enabled",...i!==void 0?{network:i}:{},filesystem:tc(e.filesystem,n,t),unsafeMacosSeatbeltRules:[]}}function nc(e,n,t){let r=e.network;if(r===void 0)return;if(!le(r)){t.push(`${n}: network must be an object \u2014 ignored`);return}for(let c of["network_profile","open_port","listen_port"])Zt({record:r,key:c,path:n},t);let i=`${n} network`;Oe(r,i,["block","allow_domain","network_profile","open_port","listen_port"],t);let s=lt(r,"block",i,t),o=Ms(r,"allow_domain",i,t),u={...s!==void 0?{block:s}:{},...o.length>0?{allowDomain:o}:{}};return Object.keys(u).length>0?u:void 0}function tc(e,n,t){if(e===void 0)return $n;if(!le(e))return t.push(`${n}: filesystem must be an object \u2014 ignored`),$n;return Zt({record:e,key:"unix_socket_dir_bind",path:n,explanation:"Unix sockets cannot cross the sbx VM boundary"},t),Oe(e,`${n} filesystem`,["read","write","allow","unix_socket_dir_bind"],t),{read:dn(e,"read",n,t),write:dn(e,"write",n,t),allow:dn(e,"allow",n,t),unixSocketDirBind:[]}}function Zt({record:e,key:n,path:t,explanation:r},i){if(e[n]===void 0)return;i.push(`${t}: ${n} is nono-only \u2014 ${r!==void 0?`${r}; `:""}ignored`)}async function vs(e){return await rc(e)?Qt(e):void 0}async function rc(e){try{return await Ml(e),!0}catch(n){if(de(n,"ENOENT"))return!1;throw n}}function ic(e,n,t){if(e.net!==void 0)t.push(`${n}: "net" was removed \u2014 use "network" instead (see ARCHITECTURE.md) \u2014 ignored`)}function sc(e,n,t){let r=e.network;if(r===void 0)return;if(!le(r)){t.push(`${n}: network must be an object \u2014 ignored`);return}let i=`${n} network`;Oe(r,i,["block","network_profile","allow_domain","open_port","listen_port"],t);let s=lt(r,"block",i,t),o=Xt(r,"network_profile",i,t),u=Ms(r,"allow_domain",i,t),c=js(r,"open_port",i,t),p=js(r,"listen_port",i,t),b={...s!==void 0?{block:s}:{},...o!==void 0?{networkProfile:o}:{},...u.length>0?{allowDomain:u}:{},...c.length>0?{openPort:c}:{},...p.length>0?{listenPort:p}:{}};return Object.keys(b).length>0?b:void 0}function Ms(e,n,t,r){let i=e[n];if(i===void 0)return[];if(!ze(i))return r.push(`${t}: ${n} must be an array of strings \u2014 ignored`),[];let s=i.map((o)=>o.trim()).filter((o)=>o!=="");if(s.length!==i.length)r.push(`${t}: ${n} entries must be non-empty \u2014 blanks ignored`);return s}function js(e,n,t,r){let i=e[n];if(i===void 0)return[];if(!Array.isArray(i))return r.push(`${t}: ${n} must be an array of port numbers \u2014 ignored`),[];let s=(u)=>typeof u==="number"&&Number.isInteger(u)&&u>=0&&u<=65535,o=i.filter((u)=>!s(u)).map((u)=>typeof u==="object"&&u!==null?JSON.stringify(u):String(u));if(o.length>0)r.push(`${t}: ${n} entries must be integers 0\u201365535 \u2014 ignored: ${o.join(", ")}`);return i.filter(s)}function oc(e,n,t){if(e===void 0)return[];if(!ze(e))return t.push(`${n}: unsafe_macos_seatbelt_rules must be an array of strings \u2014 ignored`),[];let r=(s)=>{let o=s.trim();return o.startsWith("(")&&o.endsWith(")")},i=e.filter((s)=>!r(s));if(i.length>0)t.push(`${n}: unsafe_macos_seatbelt_rules entries must be parenthesized s-expressions \u2014 ignored: ${i.join(", ")}`);return e.filter(r).map((s)=>s.trim())}function lt(e,n,t,r){let i=e[n];if(i===void 0)return;if(typeof i!=="boolean"){r.push(`${t}: ${n} must be true or false \u2014 ignored`);return}return i}function ac(e,n,t){if(e===void 0)return $n;if(!le(e))return t.push(`${n}: filesystem must be an object \u2014 ignored`),$n;return Oe(e,`${n} filesystem`,["read","write","allow","unix_socket_dir_bind"],t),{read:dn(e,"read",n,t),write:dn(e,"write",n,t),allow:dn(e,"allow",n,t),unixSocketDirBind:dn(e,"unix_socket_dir_bind",n,t)}}function dn(e,n,t,r){let i=e[n];if(i===void 0)return[];if(!ze(i))return r.push(`${t}: ${n} must be an array of strings \u2014 ignored`),[];let s=i.filter((o)=>!cn(o));if(s.length>0)r.push(`${t}: ${n} entries must be absolute, ~/, or $HOME/ paths \u2014 ignored: ${s.join(", ")}`);return i.filter(cn)}async function Qt(e){let n=yn(await uc(e),e);if(!le(n))throw Error(`${e} must be a JSON object`);return n}async function uc(e){let n;try{n=await Ae(e)}catch(t){throw Error(`${e} could not be read: ${Se(t)}`,{cause:t})}if(n===void 0)throw Error(`${e} could not be read \u2014 broken symlink?`);return n}function Xt(e,n,t,r){let i=e[n];if(i===void 0)return;if(typeof i!=="string"){r.push(`${t}: ${n} must be a string \u2014 ignored`);return}return i}function lc(e,n,t){let r=e.defaultThinkingLevel;if(r===void 0)return;if(typeof r!=="string"||!Bs.includes(r)){t.push(`${n}: defaultThinkingLevel must be one of ${Bs.join(", ")} \u2014 ignored`);return}return r}import{exists as cc,readdir as dc}from"fs/promises";import{basename as fc,extname as hc,join as Is,resolve as Dc}from"path";var gc=["name","description","cron","cwd"],Ns=/^[A-Za-z0-9][A-Za-z0-9._-]*$/;async function ct(e){let n=await cc(Is(e,"schedules"))?" \u2014 found schedules/, rename it to schedule/ (singular)":"";return Error(`No schedule/ directory in ${e}${n}`)}async function dt(e,n){let t=await dc(e,{withFileTypes:!0}),r=[];return{schedules:[...(await Promise.all(t.map((o)=>pc(e,o,n,r)))).filter((o)=>o!==null)].sort((o,u)=>o.slug.localeCompare(u.slug)),warnings:r}}async function pc(e,n,t,r){let i=Is(e,n.name);if(n.isDirectory())return r.push(`${i}: subdirectories are not supported in schedule/ \u2014 ignored`),null;if(!n.isFile()&&!n.isSymbolicLink())return r.push(`${i}: only files are read from schedule/ \u2014 ignored`),null;if(hc(n.name)!==".md")return r.push(`${i}: only .md files are read from schedule/ \u2014 ignored`),null;return mc(i,t,r)}async function mc(e,n,t){let r=fc(e,".md");if(!Ns.test(r))return t.push(`${e}: filename must match ${Ns.source} \u2014 a schedule slug becomes a launchd label and a `+"systemd unit name \u2014 ignored"),null;let i=await Ae(e);if(i===void 0)return t.push(`${e}: could not be read \u2014 broken symlink? \u2014 ignored`),null;let s=Fc(i);if(s===null)return t.push(`${e}: missing YAML frontmatter block (a file starting with "---" and a closing "---") \u2014 ignored`),null;let o=yc(s.frontmatter,e,t);if(o===null)return null;return bc({slug:r,path:e,frontmatter:o,body:s.body,home:n,warnings:t})}function Fc(e){let n=e.split(`
112
+ `).map((r)=>r.replace(/\r$/,""));if(n[0]!=="---")return null;let t=n.indexOf("---",1);if(t===-1)return null;return{frontmatter:n.slice(1,t).join(`
113
+ `),body:n.slice(t+1).join(`
114
+ `)}}function yc(e,n,t){let r;try{r=Bun.YAML.parse(e)}catch(i){return t.push(`${n}: frontmatter is not valid YAML: ${Se(i)} \u2014 ignored`),null}if(typeof r!=="object"||r===null||Array.isArray(r))return t.push(`${n}: frontmatter must be a YAML mapping \u2014 ignored`),null;return r}function bc(e){let{slug:n,path:t,frontmatter:r,body:i,home:s,warnings:o}=e;Ec(r,t,o);let u=Cc(r,t,o),c=wc(r,t,s,o),p=Rs(r,"name",t,o),b=Rs(r,"description",t,o),g=i.trim();if(u===null||c===null)return null;if(g==="")return o.push(`${t}: body is empty \u2014 a schedule with no prompt does nothing \u2014 ignored`),null;return{slug:n,name:p??n,path:t,cron:u,cwd:c,...b!==void 0?{description:b}:{},prompt:g}}function Ec(e,n,t){let r=Object.keys(e).filter((i)=>!gc.includes(i));if(r.length>0)t.push(`${n}: unsupported keys ignored: ${r.join(", ")}`)}function Cc(e,n,t){let r=e.cron;if(typeof r!=="string"||r.trim()==="")return t.push(`${n}: cron must be a non-empty string \u2014 ignored`),null;return r}function wc(e,n,t,r){let i=e.cwd;if(typeof i!=="string"||!cn(i))return r.push(`${n}: cwd must be an absolute, ~/, or $HOME/ path${xc(i)} \u2014 ignored`),null;return Dc(ln(i,t))}function xc(e){return e===null?' (a bare "~" is YAML null \u2014 quote it as "~" or write ~/some/dir)':""}function Rs(e,n,t,r){let i=e[n];if(i===void 0)return;if(typeof i!=="string"){r.push(`${t}: ${n} must be a string \u2014 ignored`);return}return i}import{createHash as Sc}from"crypto";import{homedir as Ac}from"os";import{basename as Pc,join as vn}from"path";function er(e){let n=Pc(e).toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""),t=Sc("sha256").update(e).digest("hex").slice(0,8);return`${n===""?"agent":n}-${t}`}function ft(e,n=Ac(),t=process.env.CRADLE_STATE_DIR){let r=t||vn(n,".cradle");return vn(r,"agents",er(e))}function Ts(e){return{extensionsDir:vn(e,"extensions"),sessionsDir:vn(e,"sessions"),miseCacheDir:vn(e,"mise-cache")}}import{readFile as _c}from"fs/promises";import{join as Ls,resolve as Ws}from"path";var Hs="gitdir:";async function Vs(e){try{return await _c(e,"utf8")}catch{return}}async function zs(e){let n=await Vs(Ls(e,".git"));if(n===void 0||!n.startsWith(Hs))return;let t=Ws(e,n.slice(Hs.length).trim()),r=await Vs(Ls(t,"commondir")),i=r!==void 0?Ws(t,r.trim()):t;return nt(e,i)?void 0:i}async function Js(e,n={}){let t=n.home??Oc(),r=n.cwd??process.cwd(),{dir:i,warnings:s}=await it(e.dir,{home:t,cwd:r}),o=await at(i),u=await jc(e,o,t,r),c=ft(o.dir,t),{extensionsDir:p,sessionsDir:b,miseCacheDir:g}=Ts(c),D=Ic(e,o),F=e.dryRun??!1,y=Zc(D.backend,F,n.which),h=Nc({folder:o,flags:e,passthrough:u.passthrough,backend:D.backend,bins:y,stateDir:c,extensionsDir:p,sessionsDir:b,miseCacheDir:g}),v=await Qc(D,o,{home:t,cwd:u.cwd,stateDir:c,profilePath:h.profilePath,sbxBin:y.sbxBin,hostPiBin:y.piBin,tty:n.tty??!1}),W=Rc(o,c);return{files:td(o,D.backend),extensionsDir:p,sessionsDir:b,warnings:[...s,...u.warnings,...D.warnings,...v.warnings],profile:v.profile,sbx:v.sbx,packages:W,launch:h,cwd:u.cwd,dryRun:F}}async function jc(e,n,t,r){let i={cwd:r,passthrough:e.passthrough??[],warnings:[]};if(e.schedule===void 0)return i;if(n.scheduleDir===null)throw await ct(n.dir);let{schedules:s,warnings:o}=await dt(n.scheduleDir,t),u=s.find((c)=>c.slug===e.schedule);if(u===void 0)throw Error(Mc(e.schedule,s));return{cwd:u.cwd,passthrough:[...i.passthrough,"--print","--name",u.name,"--no-approve","--",u.prompt],warnings:[...o,...await kc(u)]}}async function kc(e){if(await Us(e.cwd))return[];return[`schedule "${e.slug}" cwd does not exist: ${e.cwd}`]}function Mc(e,n){let t=n.length>0?` (available: ${n.map((r)=>r.slug).join(", ")})`:" (schedule/ is empty)";return`Unknown schedule "${e}"${t}`}function Nc(e){let{folder:n,flags:t,passthrough:r,backend:i,bins:s,stateDir:o,extensionsDir:u,sessionsDir:c,miseCacheDir:p}=e;return{folder:n,stateDir:o,extensionsDir:u,sessionsDir:c,miseCacheDir:p,backend:i,passthrough:r,nonoBin:s.nonoBin,piBin:i==="sbx"?"pi":s.piBin,profilePath:jn(o,qi),...t.verbose?{verbose:!0}:{}}}function Rc(e,n){let t=e.settings.packages;if(t===void 0||t.length===0)return null;return{npmDir:jn(n,"npm"),manifest:Ss(t),specs:t,installCommand:[...e.settings.npmCommand??["npm"],"install","--ignore-scripts"]}}function Ic(e,n){let{backend:t,warnings:r}=zc(e,n),i=[],s=Tc(e,n,t,i);return{backend:t,network:s,warnings:Hc(t!==null,s,[...r,...i])}}function Tc(e,n,t,r){if(e.offline)return{block:!0};let i=Lc(e.allowHost??[],r);if(i.length>0)return{allowDomain:i};return t==="sbx"?n.sbx.network:n.sandbox.network}function Lc(e,n){let t=e.map((r)=>r.trim()).filter((r)=>r!=="");if(t.length!==e.length)n.push("--allow-host entries must be non-empty \u2014 blanks ignored");return t}function Wc(e){return e!==void 0&&(e.block===!0||(e.allowDomain?.length??0)>0)}function Hc(e,n,t){if(e||!Wc(n))return t;return[...t,"network policy has no effect without the sandbox \u2014 pi runs with no network isolation (--sandbox to enforce it)"]}function Vc(e){return e.offline===!0||(e.allowHost?.length??0)>0}function zc(e,n){if(e.noSandbox===!0)return{backend:null,warnings:n.warnings};if(e.sandboxBackend!==void 0)return{backend:e.sandboxBackend,warnings:n.warnings};let t=Gc(n);if(e.noSandbox===!1||t.backend!==null)return{...t,backend:t.backend??"nono"};return Uc(e,n,t.warnings)}function Gc(e){let n=e.sandbox.posture==="enabled",t=e.sbx.posture==="enabled";if(n&&t)return{backend:"nono",warnings:[...e.warnings,"both sandbox/nono.json and sandbox/sbx.json declare a sandbox \u2014 using nono (pass --sandbox-backend sbx to override)"]};return{backend:n?"nono":t?"sbx":null,warnings:e.warnings}}function Uc(e,n,t){let r=Yc(n);if(Vc(e))return{backend:"nono",warnings:[...t,`${r} \u2014 sandbox forced on to enforce the requested network policy (--no-sandbox to override)`]};return{backend:null,warnings:[...t,`${r} \u2014 agent is running without OS isolation (--sandbox to force enable)`]}}function Yc(e){if(e.sandbox.posture==="disabled")return"sandbox disabled by sandbox/nono.json";if(e.sbx.posture==="disabled")return"sandbox disabled by sandbox/sbx.json";return"sandbox/nono.json or sbx.json not found"}async function Ks(e,n={}){let t={dryRun:!1,results:[],failures:[]};if(await ns(t,"extensions",e.extensionsDir,e.files),t.failures.length>0)throw Error(`Failed to write agent extensions: ${t.failures.join("; ")}`);if(await nr(e.sessionsDir,{recursive:!0}),e.profile!==null)await nr(vc(e.profile.path),{recursive:!0}),await Ys(e.profile.path,e.profile.content,"utf8");if(e.sbx!==null)await Jc(e.sbx,n);let r={...e.launch,extensionsDir:e.extensionsDir,sessionsDir:e.sessionsDir},i=e.packages===null?{argv:mn(r),warnings:[]}:await Xc(e.packages,r,n);if(e.sbx===null)return i;return{argv:st(e.sbx.spec,i.argv),warnings:i.warnings}}async function Jc(e,n){let t=n.run;if(t===void 0)throw Error("An sbx-backend run needs a command runner but none was provided");let r=await t(e.createArgv);if(r.exitCode!==0&&!gs(r.stderr))throw Error(`Failed to create sbx sandbox ${e.spec.name}: ${r.stderr.trim()}`);for(let i of e.policyArgvs)await Gs(t,i,`apply sbx network policy (${e.spec.name})`);await Gs(t,await Kc(e,n),`provision pi in sbx sandbox ${e.spec.name}`)}async function Gs(e,n,t){let r=await e(n);if(r.exitCode!==0)throw Error(`Failed to ${t}: ${r.stderr.trim()}`)}async function Kc(e,n){if(n.readPiVersion===void 0)return e.provisionArgv;let t=await n.readPiVersion(e.hostPiBin);return Ut({...e.spec,piVersion:t})}async function qc(e,n){if(await Ae(jn(e,"package.json"))!==n)return!1;return Us(jn(e,"node_modules"))}async function Xc(e,n,t){if(await nr(e.npmDir,{recursive:!0}),!await qc(e.npmDir,e.manifest)){if(t.install===void 0)throw Error("Packages declared but no installer provided");let s=jn(e.npmDir,"package.json");await Ys(s,e.manifest,"utf8");try{await t.install(e.installCommand,e.npmDir)}catch(o){throw await Bc(s,{force:!0}),o}}let{entries:r,warnings:i}=await As(e.npmDir,e.specs);return{argv:mn({...n,packageEntries:r}),warnings:i}}function Zc(e,n,t){if(n)return{nonoBin:"nono",piBin:"pi",sbxBin:"sbx"};return{nonoBin:e==="nono"?Fn("nono",t):"nono",sbxBin:e==="sbx"?Fn("sbx",t):"sbx",piBin:Fn("pi",t)}}async function Qc(e,n,t){let r=e.backend!==null?await zs(t.cwd):void 0,i=nd(e.backend==="nono",n,e.network,{home:t.home,cwd:t.cwd,stateDir:t.stateDir,profilePath:t.profilePath,...r!==void 0?{linkedGitDir:r}:{}});if(e.backend!=="sbx")return{profile:i,sbx:null,warnings:[]};let s=ed(e.network,n,{...t,...r!==void 0?{linkedGitDir:r}:{}});return{profile:i,sbx:s,warnings:[...hs(e.network),...Ds(n.sbx.filesystem)]}}function ed(e,n,t){let r=ls({cwd:t.cwd,agentDir:n.dir,stateDir:t.stateDir,home:t.home,grants:n.sbx.filesystem,...t.linkedGitDir!==void 0?{linkedGitDir:t.linkedGitDir}:{}}),i={sbxBin:t.sbxBin,name:cs($c(t.stateDir),r),cwd:t.cwd,home:t.home,mounts:r,...e!==void 0?{network:e}:{},piVersion:null,tty:t.tty};return{spec:i,hostPiBin:t.hostPiBin,createArgv:ds(i),policyArgvs:fs(i),provisionArgv:Ut(i)}}function nd(e,n,t,r){if(!e)return null;let i=Xi(r.cwd,r.home);if(i!==void 0)throw Error(`cannot sandbox from ${i} \u2014 this directory is (or contains) nono's protected state root `+"(~/.local/state/nono) and nono refuses to start with an overlapping grant; run `cradle run` from a project directory instead");let s=Zi({home:r.home,cwd:r.cwd,agentDir:n.dir,stateDir:r.stateDir,grants:n.sandbox.filesystem,rules:n.sandbox.unsafeMacosSeatbeltRules,...t!==void 0?{network:t}:{},...r.linkedGitDir!==void 0?{linkedGitDir:r.linkedGitDir}:{}});return{path:r.profilePath,content:s}}function td(e,n){return[...e.providersJson!==null?[{rel:"providers.ts",content:ms(e.providersJson,{rewriteLocalhostBaseUrls:n==="sbx"})}]:[],...n==="nono"?[{rel:Qn,content:zi()}]:[]]}import{exists as Td,mkdir as co,rm as Ld,writeFile as Wd}from"fs/promises";import{homedir as Hd,userInfo as Vd}from"os";import{dirname as fo,join as zd}from"path";var rd={jan:1,feb:2,mar:3,apr:4,may:5,jun:6,jul:7,aug:8,sep:9,oct:10,nov:11,dec:12},id={sun:0,mon:1,tue:2,wed:3,thu:4,fri:5,sat:6};function sd(e){return e===7?0:e}var Zs={name:"minute",min:0,max:59,canonicalMax:59},Qs={name:"hour",min:0,max:23,canonicalMax:23},eo={name:"day-of-month",min:1,max:31,canonicalMax:31},no={name:"month",min:1,max:12,canonicalMax:12,names:rd},to={name:"day-of-week",min:0,max:7,canonicalMax:6,names:id,normalize:sd},od={"@hourly":"0 * * * *","@daily":"0 0 * * *","@midnight":"0 0 * * *","@weekly":"0 0 * * 0","@monthly":"0 0 1 * *","@yearly":"0 0 1 1 *","@annually":"0 0 1 1 *"};function $e(e,n){return Error(`Invalid cron expression "${e}": ${n}`)}function ad(e){let n=e.trim();if(!n.startsWith("@"))return n;let t=od[n.toLowerCase()];if(t===void 0)throw $e(e,`unknown macro "${n}"`);return t}var qs=[Zs,Qs,eo,no,to];function ud(e,n){let t=e.split(/\s+/).filter((r)=>r.length>0);if(t.length!==qs.length)throw $e(n,`expected ${String(qs.length)} space-separated fields, got ${String(t.length)}`);return t}function Xs(e,n){return Array.from({length:n-e+1},(t,r)=>e+r)}function tr(e,n,t){let i=n.names?.[e.toLowerCase()]??(/^\d+$/.test(e)?Number(e):Number.NaN);if(!Number.isInteger(i)||i<n.min||i>n.max)throw $e(t,`${n.name} field: token "${e}" is out of range (${String(n.min)}-${String(n.max)})`);return i}function ld(e,n,t){if(e==="*")return Xs(n.min,n.max);let r=e.split("-");if(r.length===1)return[tr(e,n,t)];if(r.length!==2)throw $e(t,`${n.name} field: could not parse token "${e}"`);let[i,s]=r,o=tr(i??"",n,t),u=tr(s??"",n,t);if(o>u)throw $e(t,`${n.name} field: reversed range "${e}" (start greater than end)`);return Xs(o,u)}function cd(e,n,t){if(e===void 0)return 1;let r=/^\d+$/.test(e)?Number(e):Number.NaN;if(!Number.isInteger(r)||r<1)throw $e(t,`${n.name} field: step must be a positive integer, got "${e}"`);return r}function dd(e,n,t){let r=e.split("/");if(r.length>2)throw $e(t,`${n.name} field: could not parse token "${e}"`);let[i,s]=r;if(s!==void 0&&i!=="*"&&!i?.includes("-"))throw $e(t,`${n.name} field: a step is only valid with "*" or a range, not "${e}"`);let o=ld(i??"",n,t),u=cd(s,n,t);return o.filter((c,p)=>p%u===0)}function fd(e,n){let t=n.normalize?e.map(n.normalize):e,r=Array.from(new Set(t)).sort((s,o)=>s-o),i=n.canonicalMax-n.min+1;return r.length===i?null:r}function hd(e,n,t){if(e.length===0)throw $e(t,`${n.name} field: empty token`);let r=e.split(",").flatMap((i)=>dd(i,n,t));return fd(r,n)}function rr(e){let n=ud(ad(e),e),t=(s,o)=>hd(n[s]??"",o,e),r=t(2,eo),i=t(4,to);if(r!==null&&i!==null)throw $e(e,"day-of-month and day-of-week cannot both be restricted (cron ORs them; launchd/systemd AND them, so there is no faithful encoding)");return{minute:t(0,Zs),hour:t(1,Qs),dayOfMonth:r,month:t(3,no),dayOfWeek:i}}function kn(e,n){return e===null||e.includes(n)}function Dd(e,n){return kn(e.month,n.getMonth()+1)&&kn(e.dayOfMonth,n.getDate())&&kn(e.dayOfWeek,n.getDay())}function gd(e,n){return kn(e.hour,n.getHours())}function pd(e,n){return kn(e.minute,n.getMinutes())}function md(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes()+1)}function Fd(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate()+1)}function yd(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours()+1)}function bd(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes()+1)}function ro(e,n){let t=new Date(n.getFullYear(),n.getMonth(),n.getDate()+366,n.getHours(),n.getMinutes()),r=md(n);while(r.getTime()<=t.getTime()){if(!Dd(e,r)){r=Fd(r);continue}if(!gd(e,r)){r=yd(r);continue}if(pd(e,r))return r;r=bd(r)}return null}import{join as ir}from"path";var io=500;class so extends Error{constructor(e){super(`cron expression expands to ${String(e)} StartCalendarInterval dicts, over the ${String(io)}-dict cap`);this.name="LaunchdIntervalOverflowError"}}function Ed(e){return[ir(e,".local","bin"),ir(e,".local","share","mise","shims"),"/opt/homebrew/bin","/usr/local/bin","/usr/bin","/bin","/usr/sbin","/sbin"].join(":")}function Cd(e){return[{key:"Minute",field:e.minute},{key:"Hour",field:e.hour},{key:"Day",field:e.dayOfMonth},{key:"Month",field:e.month},{key:"Weekday",field:e.dayOfWeek}].filter((t)=>t.field!==null).map((t)=>({key:t.key,values:t.field}))}function wd(e){let n=Cd(e);if(n.length===0)return Array.from({length:60},(r,i)=>({Minute:i}));let t=n.reduce((r,i)=>r.flatMap((s)=>i.values.map((o)=>({...s,[i.key]:o}))),[{}]);if(t.length>io)throw new so(t.length);return t}function xd(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function En(e){return`<string>${xd(e)}</string>`}function Sd(e,n){let t=e.map((r)=>`${n} ${En(r)}`).join(`
115
+ `);return`${n}<array>
116
+ ${t}
117
+ ${n}</array>`}function Ad(e,n){let t=Object.entries(e).map(([r,i])=>`${n} <key>${r}</key>
118
+ ${n} <integer>${String(i)}</integer>`).join(`
119
+ `);return`${n}<dict>
120
+ ${t}
121
+ ${n}</dict>`}function Pd(e,n){let t=e.map((r)=>Ad(r,`${n} `)).join(`
122
+ `);return`${n}<array>
123
+ ${t}
124
+ ${n}</array>`}function _d(e,n,t){let{schedule:r,cradleBin:i,agentDir:s,logPath:o,home:u}=e,c=[i,"schedule","run",s,r.slug];return['<?xml version="1.0" encoding="UTF-8"?>','<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">','<plist version="1.0">',"<dict>"," <key>ProgramArguments</key>",Sd(c," ")," <key>WorkingDirectory</key>",` ${En(r.cwd)}`," <key>StartCalendarInterval</key>",Pd(t," ")," <key>StandardOutPath</key>",` ${En(o)}`," <key>StandardErrorPath</key>",` ${En(o)}`," <key>EnvironmentVariables</key>"," <dict>"," <key>PATH</key>",` ${En(Ed(u))}`," </dict>"," <key>RunAtLoad</key>"," <false/>"," <key>ProcessType</key>"," <string>Background</string>"," <key>Label</key>",` ${En(n)}`,"</dict>","</plist>",""].join(`
125
+ `)}function Bd(e){return`gui/${String(e)}`}function oo(e,n){let t=`com.cradle.${e.agentId}.${e.schedule.slug}`,r=ir(e.home,"Library","LaunchAgents",`${t}.plist`),i=wd(n),s=_d(e,t,i),o=Bd(e.uid),u=`${o}/${t}`;return{id:t,files:[{path:r,content:s}],installSteps:[{argv:["launchctl","bootout",u],ignoreFailure:!0},{argv:["launchctl","bootstrap",o,r]},{argv:["launchctl","enable",u]}],removeSteps:[{argv:["launchctl","bootout",u],ignoreFailure:!0}]}}import{join as Mn}from"path";class ao extends Error{constructor(e){super(`systemd unit values cannot contain a newline, got ${JSON.stringify(e)}`);this.name="SystemdUnitValueError"}}function Ue(e){if(e.includes(`
126
+ `))throw new ao(e);return e.replaceAll("%","%%")}function Od(e){return`"${e.replaceAll("\\","\\\\").replaceAll('"',"\\\"")}"`}function $d(e){return String(e).padStart(2,"0")}function ht(e){return e===null?"*":e.map($d).join(",")}var vd=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function jd(e){let n=vd[e];if(n===void 0)throw Error(`Day-of-week value out of range: ${String(e)}`);return n}function kd(e){return e===null?void 0:e.map(jd).join(",")}function Md(e){let n=kd(e.dayOfWeek),t=`*-${ht(e.month)}-${ht(e.dayOfMonth)}`,r=`${ht(e.hour)}:${ht(e.minute)}:00`;return n===void 0?`${t} ${r}`:`${n} ${t} ${r}`}function Nd(e){return[Mn(e,".local","bin"),Mn(e,".local","share","mise","shims"),"/usr/local/bin","/usr/bin","/bin","/usr/sbin","/sbin"].join(":")}function Rd(e){let n=Ue(e.schedule.name),t=Ue(e.schedule.cwd),r=Ue(e.cradleBin),i=Ue(e.agentDir),s=Ue(e.schedule.slug),o=Ue(e.logPath);return["[Unit]",`Description=${n}`,"","[Service]","Type=oneshot",`WorkingDirectory=${t}`,`Environment=PATH=${Ue(Nd(e.home))}`,`ExecStart=${[r,"schedule","run",i,s].map(Od).join(" ")}`,`StandardOutput=append:${o}`,`StandardError=append:${o}`,""].join(`
127
+ `)}function Id(e,n){let t=Ue(e.schedule.name),r=Md(n);return["[Unit]",`Description=${t}`,"","[Timer]",`OnCalendar=${r}`,"Persistent=true","","[Install]","WantedBy=timers.target",""].join(`
128
+ `)}function uo(e,n){let t=`cradle-${e.agentId}-${e.schedule.slug}`,r=Mn(e.home,".config","systemd","user"),i=Mn(r,`${t}.service`),s=Mn(r,`${t}.timer`),o=`${t}.timer`;return{id:t,files:[{path:i,content:Rd(e)},{path:s,content:Id(e,n)}],installSteps:[{argv:["systemctl","--user","daemon-reload"]},{argv:["systemctl","--user","enable","--now",o]}],removeSteps:[{argv:["systemctl","--user","disable","--now",o],ignoreFailure:!0},{argv:["systemctl","--user","daemon-reload"]}]}}function lo(e){return["loginctl","show-user",e,"--property=Linger"]}var sr="systemd user timers stop firing once you log out unless lingering is enabled \u2014 run `loginctl enable-linger <user>` to keep them running";function Gd(e){if(e!=="darwin"&&e!=="linux")throw Error(`Scheduled tasks are not supported on ${e} \u2014 launchd (macOS) and systemd (Linux) are the supported timer backends`)}async function Ud(e,n,t){let{dir:r,warnings:i}=await it(e.dir,{home:n,cwd:t}),s=await at(r);if(s.scheduleDir===null)throw await ct(s.dir);let{schedules:o,warnings:u}=await dt(s.scheduleDir,n);return{folder:s,schedules:o,warnings:[...i,...u],stateDir:ft(s.dir,n)}}function Yd(e,n){return(t)=>({schedule:t,agentId:er(e.folder.dir),agentDir:e.folder.dir,cradleBin:n.cradleBin,logPath:zd(e.stateDir,"schedule",`${t.slug}.log`),home:n.home,uid:n.uid})}async function ho(e,n={}){let t=Jd(e,n),r=await Ud(e,t.home,t.cwd),i=qd(e,t.dryRun)?Fn("cradle",n.which):"cradle",s=Yd(r,{cradleBin:i,home:t.home,uid:t.uid}),o={flags:e,base:r,contextFor:s,platform:t.platform,deps:n,dryRun:t.dryRun};return e.action==="list"?Xd(o):Zd(o)}function Jd(e,n){let t=n.platform??process.platform;return Gd(t),{home:n.home??Hd(),cwd:n.cwd??process.cwd(),platform:t,uid:n.uid??Kd(),dryRun:e.dryRun??!1}}function Kd(){return process.getuid?.()??0}function qd(e,n){return e.action==="install"&&!n}async function Xd(e){let n=e.deps.now??(()=>new Date),t=await Promise.all(e.base.schedules.map((r)=>tf(r,e.contextFor(r),e.platform,n)));return{action:"list",folder:e.base.folder,platform:e.platform,rows:t,targets:[],warnings:e.base.warnings,dryRun:e.dryRun,lingerCheckArgv:null}}function Zd(e){let n=Qd(e.base.schedules,e.flags).map((r)=>nf(r,e.contextFor(r),e.platform)),t=e.flags.action==="install"&&e.platform==="linux"?lo(e.deps.user??Vd().username):null;return{action:e.flags.action,folder:e.base.folder,platform:e.platform,rows:[],targets:n,warnings:e.base.warnings,dryRun:e.dryRun,lingerCheckArgv:t}}function Qd(e,n){if(n.slug===void 0)return e;let t=e.find((r)=>r.slug===n.slug);if(t===void 0)throw Error(ef(n.slug,e));return[t]}function ef(e,n){let t=n.length>0?` (available: ${n.map((r)=>r.slug).join(", ")})`:" (schedule/ is empty)";return`Unknown schedule "${e}"${t}`}function nf(e,n,t){return{schedule:e,timerPlan:Do(n,t,rr(e.cron)),logPath:n.logPath}}function Do(e,n,t){return n==="darwin"?oo(e,t):uo(e,t)}async function tf(e,n,t,r){let i={slug:e.slug,name:e.name,cron:e.cron,cwd:e.cwd};try{let s=rr(e.cron),o=Do(n,t,s);return{...i,nextFire:ro(s,r()),installed:await rf(o.files)}}catch(s){return{...i,cronError:Se(s),nextFire:null,installed:!1}}}async function rf(e){return(await Promise.all(e.map((t)=>Td(t.path)))).every(Boolean)}function go(e){if(e.length===0)return"No schedules found.";return e.map(sf).join(`
129
+
130
+ `)}function sf(e){let n=e.installed?"installed":"not installed",t=e.cronError!==void 0?`INVALID: ${e.cronError}`:`next: ${of(e.nextFire)}`;return[`${e.slug} \u2014 ${e.name}`,` cron: ${e.cron} (${t})`,` cwd: ${e.cwd}`,` timer: ${n}`].join(`
131
+ `)}function of(e){return e===null?"never (cannot fire within the next year)":e.toLocaleString()}async function po(e,n={}){if(e.dryRun)throw Error("Cannot materialize a --dry-run schedule plan; it is a preview only");if(e.action==="remove")return{warnings:await lf(e,n)};if(e.action==="install")return{warnings:await af(e,n)};return{warnings:[]}}async function af(e,n){let t=mo(n),r=await uf(e.lingerCheckArgv,t);for(let i of e.targets)await cf(i.timerPlan.files),await co(fo(i.logPath),{recursive:!0}),await Fo(t,i.timerPlan.installSteps,`install schedule "${i.schedule.slug}"`);return r}async function uf(e,n){if(e===null)return[];try{return(await n(e)).stdout.includes("Linger=yes")?[]:[sr]}catch{return[sr]}}async function lf(e,n){let t=mo(n);for(let r of e.targets)await Fo(t,r.timerPlan.removeSteps,`remove schedule "${r.schedule.slug}"`),await Promise.all(r.timerPlan.files.map((i)=>Ld(i.path,{force:!0})));return[]}async function cf(e){for(let n of e)await co(fo(n.path),{recursive:!0}),await Wd(n.path,n.content,"utf8")}function mo(e){if(e.run===void 0)throw Error("A schedule install/remove needs a command runner but none was provided");return e.run}async function Fo(e,n,t){for(let r of n){let i=await e(r.argv);if(i.exitCode!==0&&r.ignoreFailure!==!0)throw Error(`Failed to ${t} (${r.argv.join(" ")}): ${i.stderr.trim()}`)}}function yo(e,n){return n?`\x1B[33m${e}\x1B[0m`:e}function bo(e,n){return()=>{e.kill(n)}}async function Eo(e,n={},t){let[r,...i]=e;if(!r)throw Error("Command requires at least one argument");let s=Bun.spawn([r,...i],{stdin:"inherit",stdout:"inherit",stderr:"inherit",env:{...process.env,...n},...t!==void 0?{cwd:t}:{}}),o=bo(s,"SIGINT"),u=bo(s,"SIGTERM");process.on("SIGINT",o),process.on("SIGTERM",u);try{return await s.exited}finally{process.off("SIGINT",o),process.off("SIGTERM",u)}}async function Co(e){let[n,...t]=e;if(!n)throw Error("Command requires at least one argument");let r=Bun.spawn([n,...t],{stdin:"ignore",stdout:"ignore",stderr:"pipe",env:process.env}),[i,s]=await Promise.all([new Response(r.stderr).text(),r.exited]);return{exitCode:s,stderr:i}}async function wo(e){let[n,...t]=e;if(!n)throw Error("Command requires at least one argument");let r=Bun.spawn([n,...t],{stdin:"ignore",stdout:"pipe",stderr:"pipe",env:process.env}),[i,s,o]=await Promise.all([new Response(r.stdout).text(),new Response(r.stderr).text(),r.exited]);return{exitCode:o,stdout:i,stderr:s}}async function xo(e,n){let[t,...r]=e;if(!t)throw Error("Command requires at least one argument");let s=await Bun.spawn([t,...r],{cwd:n,stdin:"ignore",stdout:"inherit",stderr:"inherit",env:process.env}).exited;if(s!==0)throw Error(`Package install failed (${e.join(" ")} exited ${String(s)})`)}var Cn=Hi(process.argv.slice(2)).scriptName("cradle").version(Vi.version).usage("$0 <cmd> [args]").parserConfiguration({"populate--":!0,"parse-numbers":!1,"parse-positional-numbers":!1}).strict();Cn.command("$0","show help",()=>{},async()=>{console.log(await Cn.getHelp())});Cn.command("run [dir]","run an agent folder with pi, sandboxed when sandbox/nono.json or sandbox/sbx.json is present",(e)=>e.positional("dir",{type:"string",default:".",describe:"agent folder, or a name from ~/.cradle/settings.json (default: .)"}).option("offline",{type:"boolean",description:"block all outbound network (overrides the folder network policy; implies --sandbox)"}).option("allow-host",{type:"array",string:!0,description:"restrict network to these hosts (repeatable; overrides the folder allowlist; implies --sandbox)"}).option("sandbox",{type:"boolean",description:"run sandboxed (--sandbox forces it when no sandbox/ file enables one or the folder opts out; --no-sandbox disables)"}).option("sandbox-backend",{type:"string",choices:["nono","sbx"],description:"sandbox implementation (implies --sandbox): nono (host OS policy) or sbx (Docker Sandboxes microVM)"}).option("verbose",{type:"boolean",default:!1,description:"show nono's full sandbox capabilities banner instead of the one-line status"}).option("dry-run",{type:"boolean",default:!1,description:"print the write plan + command, do not spawn"}).epilogue("Everything after `--` is forwarded to pi."),async(e)=>{let n=(e["--"]??[]).map(String),t=(e.allowHost??[]).map(String),r={dir:e.dir,dryRun:e.dryRun,...e.sandbox!==void 0?{noSandbox:!e.sandbox}:{},...e.sandboxBackend!==void 0?{sandboxBackend:e.sandboxBackend}:{},...e.offline?{offline:!0}:{},...t.length?{allowHost:t}:{},...e.verbose?{verbose:!0}:{},...n.length?{passthrough:n}:{}};await Ao(r)});Cn.command("schedule <action> [dir] [task]","manage schedule/*.md tasks as launchd (macOS) / systemd --user (Linux) timers",(e)=>e.positional("action",{type:"string",choices:["list","install","remove","run"],demandOption:!0,describe:"list every schedule, install/remove their timers, or run one now"}).positional("dir",{type:"string",default:".",describe:"agent folder, or a name from ~/.cradle/settings.json (default: .)"}).positional("task",{type:"string",describe:"schedule slug \u2014 required for `run`; an optional filter for `install`/`remove` (default: every schedule)"}).option("dry-run",{type:"boolean",default:!1,description:"install/remove: print what would change, touch nothing"}),async(e)=>{if(e.action==="run"){if(e.task===void 0){or(Error("A task slug is required: cradle schedule run <dir> <task>"));return}await Ao({dir:e.dir,schedule:e.task});return}await df({dir:e.dir,action:e.action,...e.task!==void 0?{slug:e.task}:{},...e.dryRun?{dryRun:!0}:{}})});Cn.command("doctor","check pi / nono / mise on PATH",()=>{},async()=>{let e=await Yi({readVersion:Po});console.log(Ji(e)),process.exitCode=Ki(e)});async function Ao(e){try{let n=await Js(e,{tty:process.stdout.isTTY});if(Dt(n.warnings),n.dryRun){hf(n);return}let t=await Ks(n,{install:xo,run:Co,readPiVersion:Po});if(Dt(t.warnings),n.profile!==null&&!e.verbose)console.log("\uD83D\uDD12 Sandbox Active");if(n.sbx!==null&&!e.verbose)console.log("\uD83D\uDD12 Sandbox Active (sbx)");process.exit(await Eo(t.argv,zt(n.launch),n.cwd))}catch(n){or(n)}}async function df(e){try{let n=await ho(e);if(Dt(n.warnings),n.action==="list"){console.log(go(n.rows));return}if(n.dryRun){ff(n);return}let t=await po(n,{run:wo});Dt(t.warnings)}catch(n){or(n)}}function ff(e){for(let n of e.targets){if(e.action==="install"){for(let t of n.timerPlan.files)console.log(`write: ${t.path}`);for(let t of n.timerPlan.installSteps)console.log(`install: ${t.argv.map(Ve).join(" ")}`);continue}for(let t of n.timerPlan.removeSteps)console.log(`remove: ${t.argv.map(Ve).join(" ")}`);for(let t of n.timerPlan.files)console.log(`delete: ${t.path}`)}}function hf(e){for(let r of e.files)console.log(`write: ${So(e.extensionsDir,r.rel)}`);if(e.profile!==null)console.log(`write: ${e.profile.path}`);if(e.sbx!==null)Df(e.sbx);if(e.packages!==null)gf(e.packages);let n=Object.entries(zt(e.launch)).map(([r,i])=>`${r}=${Ve(i)}`),t=e.sbx!==null?st(e.sbx.spec,mn(e.launch)):mn(e.launch);console.log([...n,...t.map(Ve)].join(" "))}function Df(e){console.log(`create: ${e.createArgv.map(Ve).join(" ")}`);for(let n of e.policyArgvs)console.log(`policy: ${n.map(Ve).join(" ")}`);console.log(`provision: ${e.provisionArgv.map(Ve).join(" ")}`)}function gf(e){console.log(`write: ${So(e.npmDir,"package.json")}`);let n=e.specs.map((t)=>`${t.name}@${t.version}`).join(", ");console.log(`install: ${e.installCommand.join(" ")} (${e.npmDir}): ${n}`)}function Dt(e){let n=process.stderr.isTTY;for(let t of e)console.error(yo(`warning: ${t}`,n))}async function Po(e,n=["--version"]){try{let t=Bun.spawn([e,...n],{stdout:"pipe",stderr:"ignore"}),[r,i]=await Promise.all([new Response(t.stdout).text(),t.exited]);if(i!==0)return null;return r.split(`
132
+ `)[0]?.match(/v?\d+\.\d+\S*/)?.[0]??null}catch{return null}}function or(e){console.error(e instanceof Error?e.message:String(e)),process.exitCode=1}Cn.parse();