slack-term 1.13.0 → 1.15.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/cli.js CHANGED
@@ -1,21 +1,21 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
- import{createRequire as k8}from"node:module";var v8=Object.create;var{getPrototypeOf:p8,defineProperty:u0,getOwnPropertyNames:m8}=Object;var c8=Object.prototype.hasOwnProperty;function y8(D){return this[D]}var i8,n8,F0=(D,u,F)=>{var E=D!=null&&typeof D==="object";if(E){var C=u?i8??=new WeakMap:n8??=new WeakMap,B=C.get(D);if(B)return B}F=D!=null?v8(p8(D)):{};let $=u||!D||!D.__esModule?u0(F,"default",{value:D,enumerable:!0}):F;for(let z of m8(D))if(!c8.call($,z))u0($,z,{get:y8.bind(D,z),enumerable:!0});if(E)C.set(D,$);return $};var E0=(D,u)=>()=>(u||D((u={exports:{}}).exports,u),u.exports);var zu=k8(import.meta.url);var _0=E0((S6,U0)=>{U0.exports=()=>{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 t0=E0((H7,g0)=>{g0.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(C,B){return B};var E=Error().stack;if(Error.prepareStackTrace=F,E!==null&&typeof E==="object")return E[u]?E[u].getFileName():void 0}});import{createHash as b3}from"crypto";import{existsSync as f8,readFileSync as h3,mkdirSync as v3,writeFileSync as p3}from"fs";import{homedir as I8}from"os";import{join as Eu}from"path";import{notStrictEqual as S1,strictEqual as P1}from"assert";var d8={right:l8,center:o8};class B0{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((E)=>E.split("\t")),F=0;return u.forEach((E)=>{if(E.length>1&&WD.stringWidth(E[0])>F)F=Math.min(Math.floor(this.width*0.5),WD.stringWidth(E[0]))}),u.forEach((E)=>{this.div(...E.map((C,B)=>{return{text:C.trim(),padding:this.measurePadding(C),width:B===0&&E.length>1?F:void 0}}))}),this.rows[this.rows.length-1]}colFromString(D){return{text:D,padding:this.measurePadding(D)}}measurePadding(D){let u=WD.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,E)=>{let C="";F.forEach((B,$)=>{let{width:z}=D[$],Z=this.negatePadding(D[$]),J=B;if(Z>WD.stringWidth(B))J+=" ".repeat(Z-WD.stringWidth(B));if(D[$].align&&D[$].align!=="left"&&this.wrap){let X=d8[D[$].align];if(J=X(J,Z),WD.stringWidth(J)<Z)J+=" ".repeat((z||0)-WD.stringWidth(J)-1)}let O=D[$].padding||[0,0,0,0];if(O[3])C+=" ".repeat(O[3]);if(C+=C0(D[$],J,"| "),C+=J,C+=C0(D[$],J," |"),O[1])C+=" ".repeat(O[1]);if(E===0&&u.length>0)C=this.renderInline(C,u[u.length-1])}),u.push({text:C.replace(/ +$/,""),span:D.span})}),u}renderInline(D,u){let F=D.match(/^ */),E=F?F[0].length:0,C=u.text,B=WD.stringWidth(C.trimRight());if(!u.span)return D;if(!this.wrap)return u.hidden=!0,C+D;if(E<B)return D;return u.hidden=!0,C.trimRight()+" ".repeat(E-B)+D.trimLeft()}rasterize(D){let u=[],F=this.columnWidths(D),E;return D.forEach((C,B)=>{if(C.width=F[B],this.wrap)E=WD.wrap(C.text,this.negatePadding(C),{hard:!0}).split(`
3
+ import{createRequire as p1}from"node:module";var x1=Object.create;var{getPrototypeOf:I1,defineProperty:x0,getOwnPropertyNames:b1}=Object;var f1=Object.prototype.hasOwnProperty;function h1(D){return this[D]}var v1,m1,I0=(D,u,F)=>{var E=D!=null&&typeof D==="object";if(E){var C=u?v1??=new WeakMap:m1??=new WeakMap,B=C.get(D);if(B)return B}F=D!=null?x1(I1(D)):{};let $=u||!D||!D.__esModule?x0(F,"default",{value:D,enumerable:!0}):F;for(let z of b1(D))if(!f1.call($,z))x0($,z,{get:h1.bind(D,z),enumerable:!0});if(E)C.set(D,$);return $};var b0=(D,u)=>()=>(u||D((u={exports:{}}).exports,u),u.exports);var vD=p1(import.meta.url);var a0=b0((w7,r0)=>{r0.exports=()=>{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 A2=b0((U9,j2)=>{j2.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(C,B){return B};var E=Error().stack;if(Error.prepareStackTrace=F,E!==null&&typeof E==="object")return E[u]?E[u].getFileName():void 0}});import{createHash as f6}from"crypto";import{existsSync as R1,readFileSync as h6,mkdirSync as v6,writeFileSync as m6}from"fs";import{homedir as N1}from"os";import{join as Wu}from"path";import{notStrictEqual as A3,strictEqual as L3}from"assert";var y1={right:k1,center:d1};class h0{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((E)=>E.split("\t")),F=0;return u.forEach((E)=>{if(E.length>1&&HD.stringWidth(E[0])>F)F=Math.min(Math.floor(this.width*0.5),HD.stringWidth(E[0]))}),u.forEach((E)=>{this.div(...E.map((C,B)=>{return{text:C.trim(),padding:this.measurePadding(C),width:B===0&&E.length>1?F:void 0}}))}),this.rows[this.rows.length-1]}colFromString(D){return{text:D,padding:this.measurePadding(D)}}measurePadding(D){let u=HD.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,E)=>{let C="";F.forEach((B,$)=>{let{width:z}=D[$],G=this.negatePadding(D[$]),Z=B;if(G>HD.stringWidth(B))Z+=" ".repeat(G-HD.stringWidth(B));if(D[$].align&&D[$].align!=="left"&&this.wrap){let J=y1[D[$].align];if(Z=J(Z,G),HD.stringWidth(Z)<G)Z+=" ".repeat((z||0)-HD.stringWidth(Z)-1)}let Q=D[$].padding||[0,0,0,0];if(Q[3])C+=" ".repeat(Q[3]);if(C+=f0(D[$],Z,"| "),C+=Z,C+=f0(D[$],Z," |"),Q[1])C+=" ".repeat(Q[1]);if(E===0&&u.length>0)C=this.renderInline(C,u[u.length-1])}),u.push({text:C.replace(/ +$/,""),span:D.span})}),u}renderInline(D,u){let F=D.match(/^ */),E=F?F[0].length:0,C=u.text,B=HD.stringWidth(C.trimRight());if(!u.span)return D;if(!this.wrap)return u.hidden=!0,C+D;if(E<B)return D;return u.hidden=!0,C.trimRight()+" ".repeat(E-B)+D.trimLeft()}rasterize(D){let u=[],F=this.columnWidths(D),E;return D.forEach((C,B)=>{if(C.width=F[B],this.wrap)E=HD.wrap(C.text,this.negatePadding(C),{hard:!0}).split(`
6
6
  `);else E=C.text.split(`
7
- `);if(C.border)E.unshift("."+"-".repeat(this.negatePadding(C)+2)+"."),E.push("'"+"-".repeat(this.negatePadding(C)+2)+"'");if(C.padding)E.unshift(...Array(C.padding[0]||0).fill("")),E.push(...Array(C.padding[2]||0).fill(""));E.forEach(($,z)=>{if(!u[z])u.push([]);let Z=u[z];for(let J=0;J<B;J++)if(Z[J]===void 0)Z.push("");Z.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||WD.stringWidth(B.text)});let u=D.length,F=this.width,E=D.map((B)=>{if(B.width)return u--,F-=B.width,B.width;return}),C=u?Math.floor(F/u):0;return E.map((B,$)=>{if(B===void 0)return Math.max(C,g8(D[$]));return B})}}function C0(D,u,F){if(D.border){if(/[.']-+[.']/.test(u))return"";if(u.trim().length!==0)return F;return" "}return""}function g8(D){let u=D.padding||[],F=1+(u[3]||0)+(u[1]||0);if(D.border)return F+4;return F}function t8(){if(typeof process==="object"&&process.stdout&&process.stdout.columns)return process.stdout.columns;return 80}function l8(D,u){D=D.trim();let F=WD.stringWidth(D);if(F<u)return" ".repeat(u-F)+D;return D}function o8(D,u){D=D.trim();let F=WD.stringWidth(D);if(F>=u)return D;return" ".repeat(u-F>>1)+D}var WD;function $0(D,u){return WD=u,new B0({width:(D===null||D===void 0?void 0:D.width)||t8(),wrap:D===null||D===void 0?void 0:D.wrap})}function XF({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 s8=XF();function mD(D){if(typeof D!=="string")throw TypeError(`Expected a \`string\`, got \`${typeof D}\``);if(!D.includes("\x1B")&&!D.includes("›"))return D;return D.replace(s8,"")}var z0=161,G0=1114109,Z0=[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],X0=12288,J0=65510,Q0=[12288,12288,65281,65376,65504,65510];var O0=4352,Y0=262141,JF=[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 fu=(D,u)=>{let F=0,E=Math.floor(D.length/2)-1;while(F<=E){let C=Math.floor((F+E)/2),B=C*2;if(u<D[B])E=C-1;else if(u>D[B+1])F=C+1;else return!0}return!1};var W0=19968,[r8,a8]=e8(JF);function e8(D){let u=D[0],F=D[1];for(let E=0;E<D.length;E+=2){let C=D[E],B=D[E+1];if(W0>=C&&W0<=B)return[C,B];if(B-C>F-u)u=C,F=B}return[u,F]}var M0=(D)=>{if(D<z0||D>G0)return!1;return fu(Z0,D)},H0=(D)=>{if(D<X0||D>J0)return!1;return fu(Q0,D)};var V0=(D)=>{if(D>=r8&&D<=a8)return!0;if(D<O0||D>Y0)return!1;return fu(JF,D)};function D1(D){if(!Number.isSafeInteger(D))throw TypeError(`Expected a code point, got \`${typeof D}\`.`)}function q0(D,{ambiguousAsWide:u=!1}={}){if(D1(D),H0(D)||V0(D)||u&&M0(D))return 2;return 1}var j0=F0(_0(),1),u1=new Intl.Segmenter,F1=/^\p{Default_Ignorable_Code_Point}$/u;function KD(D,u={}){if(typeof D!=="string"||D.length===0)return 0;let{ambiguousIsNarrow:F=!0,countAnsiEscapeCodes:E=!1}=u;if(!E)D=mD(D);if(D.length===0)return 0;let C=0,B={ambiguousAsWide:!F};for(let{segment:$}of u1.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(F1.test($))continue;if(j0.default().test($)){C+=2;continue}C+=q0(z,B)}return C}var K0=(D=0)=>(u)=>`\x1B[${u+D}m`,T0=(D=0)=>(u)=>`\x1B[${38+D};5;${u}m`,N0=(D=0)=>(u,F,E)=>`\x1B[${38+D};2;${u};${F};${E}m`,s={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]}},f6=Object.keys(s.modifier),E1=Object.keys(s.color),C1=Object.keys(s.bgColor),x6=[...E1,...C1];function B1(){let D=new Map;for(let[u,F]of Object.entries(s)){for(let[E,C]of Object.entries(F))s[E]={open:`\x1B[${C[0]}m`,close:`\x1B[${C[1]}m`},F[E]=s[E],D.set(C[0],C[1]);Object.defineProperty(s,u,{value:F,enumerable:!1})}return Object.defineProperty(s,"codes",{value:D,enumerable:!1}),s.color.close="\x1B[39m",s.bgColor.close="\x1B[49m",s.color.ansi=K0(),s.color.ansi256=T0(),s.color.ansi16m=N0(),s.bgColor.ansi=K0(10),s.bgColor.ansi256=T0(10),s.bgColor.ansi16m=N0(10),Object.defineProperties(s,{rgbToAnsi256:{value(u,F,E){if(u===F&&F===E){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(E/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[E]=F;if(E.length===3)E=[...E].map((B)=>B+B).join("");let C=Number.parseInt(E,16);return[C>>16&255,C>>8&255,C&255]},enumerable:!1},hexToAnsi256:{value:(u)=>s.rgbToAnsi256(...s.hexToRgb(u)),enumerable:!1},ansi256ToAnsi:{value(u){if(u<8)return 30+u;if(u<16)return 90+(u-8);let F,E,C;if(u>=232)F=((u-232)*10+8)/255,E=F,C=F;else{u-=16;let z=u%36;F=Math.floor(u/36)/5,E=Math.floor(z/6)/5,C=z%6/5}let B=Math.max(F,E,C)*2;if(B===0)return 30;let $=30+(Math.round(C)<<2|Math.round(E)<<1|Math.round(F));if(B===2)$+=60;return $},enumerable:!1},rgbToAnsi:{value:(u,F,E)=>s.ansi256ToAnsi(s.rgbToAnsi256(u,F,E)),enumerable:!1},hexToAnsi:{value:(u)=>s.ansi256ToAnsi(s.hexToAnsi256(u)),enumerable:!1}}),s}var $1=B1(),R0=$1;var bu=new Set(["\x1B","›"]),z1=39,OF="\x07",S0="[",G1="]",P0="m",xu=`${G1}8;;`,A0=(D)=>`${bu.values().next().value}${S0}${D}${P0}`,L0=(D)=>`${bu.values().next().value}${xu}${D}${OF}`,Z1=(D)=>D.split(" ").map((u)=>KD(u)),QF=(D,u,F)=>{let E=[...u],C=!1,B=!1,$=KD(mD(D.at(-1)));for(let[z,Z]of E.entries()){let J=KD(Z);if($+J<=F)D[D.length-1]+=Z;else D.push(Z),$=0;if(bu.has(Z))C=!0,B=E.slice(z+1,z+1+xu.length).join("")===xu;if(C){if(B){if(Z===OF)C=!1,B=!1}else if(Z===P0)C=!1;continue}if($+=J,$===F&&z<E.length-1)D.push(""),$=0}if(!$&&D.at(-1).length>0&&D.length>1)D[D.length-2]+=D.pop()},X1=(D)=>{let u=D.split(" "),F=u.length;while(F>0){if(KD(u[F-1])>0)break;F--}if(F===u.length)return D;return u.slice(0,F).join(" ")+u.slice(F).join("")},J1=(D,u,F={})=>{if(F.trim!==!1&&D.trim()==="")return"";let E="",C,B,$=Z1(D),z=[""];for(let[X,Q]of D.split(" ").entries()){if(F.trim!==!1)z[z.length-1]=z.at(-1).trimStart();let Y=KD(z.at(-1));if(X!==0){if(Y>=u&&(F.wordWrap===!1||F.trim===!1))z.push(""),Y=0;if(Y>0||F.trim===!1)z[z.length-1]+=" ",Y++}if(F.hard&&$[X]>u){let M=u-Y,H=1+Math.floor(($[X]-M-1)/u);if(Math.floor(($[X]-1)/u)<H)z.push("");QF(z,Q,u);continue}if(Y+$[X]>u&&Y>0&&$[X]>0){if(F.wordWrap===!1&&Y<u){QF(z,Q,u);continue}z.push("")}if(Y+$[X]>u&&F.wordWrap===!1){QF(z,Q,u);continue}z[z.length-1]+=Q}if(F.trim!==!1)z=z.map((X)=>X1(X));let Z=z.join(`
8
- `),J=[...Z],O=0;for(let[X,Q]of J.entries()){if(E+=Q,bu.has(Q)){let{groups:M}=new RegExp(`(?:\\${S0}(?<code>\\d+)m|\\${xu}(?<uri>.*)${OF})`).exec(Z.slice(O))||{groups:{}};if(M.code!==void 0){let H=Number.parseFloat(M.code);C=H===z1?void 0:H}else if(M.uri!==void 0)B=M.uri.length===0?void 0:M.uri}let Y=R0.codes.get(Number(C));if(J[X+1]===`
9
- `){if(B)E+=L0("");if(C&&Y)E+=A0(Y)}else if(Q===`
10
- `){if(C&&Y)E+=A0(C);if(B)E+=L0(B)}O+=Q.length}return E};function YF(D,u,F){return String(D).normalize().replaceAll(`\r
7
+ `);if(C.border)E.unshift("."+"-".repeat(this.negatePadding(C)+2)+"."),E.push("'"+"-".repeat(this.negatePadding(C)+2)+"'");if(C.padding)E.unshift(...Array(C.padding[0]||0).fill("")),E.push(...Array(C.padding[2]||0).fill(""));E.forEach(($,z)=>{if(!u[z])u.push([]);let G=u[z];for(let Z=0;Z<B;Z++)if(G[Z]===void 0)G.push("");G.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||HD.stringWidth(B.text)});let u=D.length,F=this.width,E=D.map((B)=>{if(B.width)return u--,F-=B.width,B.width;return}),C=u?Math.floor(F/u):0;return E.map((B,$)=>{if(B===void 0)return Math.max(C,c1(D[$]));return B})}}function f0(D,u,F){if(D.border){if(/[.']-+[.']/.test(u))return"";if(u.trim().length!==0)return F;return" "}return""}function c1(D){let u=D.padding||[],F=1+(u[3]||0)+(u[1]||0);if(D.border)return F+4;return F}function g1(){if(typeof process==="object"&&process.stdout&&process.stdout.columns)return process.stdout.columns;return 80}function k1(D,u){D=D.trim();let F=HD.stringWidth(D);if(F<u)return" ".repeat(u-F)+D;return D}function d1(D,u){D=D.trim();let F=HD.stringWidth(D);if(F>=u)return D;return" ".repeat(u-F>>1)+D}var HD;function v0(D,u){return HD=u,new h0({width:(D===null||D===void 0?void 0:D.width)||g1(),wrap:D===null||D===void 0?void 0:D.wrap})}function LF({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 i1=LF();function lD(D){if(typeof D!=="string")throw TypeError(`Expected a \`string\`, got \`${typeof D}\``);if(!D.includes("\x1B")&&!D.includes("›"))return D;return D.replace(i1,"")}var m0=161,p0=1114109,y0=[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],c0=12288,g0=65510,k0=[12288,12288,65281,65376,65504,65510];var d0=4352,i0=262141,NF=[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 du=(D,u)=>{let F=0,E=Math.floor(D.length/2)-1;while(F<=E){let C=Math.floor((F+E)/2),B=C*2;if(u<D[B])E=C-1;else if(u>D[B+1])F=C+1;else return!0}return!1};var n0=19968,[n1,t1]=l1(NF);function l1(D){let u=D[0],F=D[1];for(let E=0;E<D.length;E+=2){let C=D[E],B=D[E+1];if(n0>=C&&n0<=B)return[C,B];if(B-C>F-u)u=C,F=B}return[u,F]}var t0=(D)=>{if(D<m0||D>p0)return!1;return du(y0,D)},l0=(D)=>{if(D<c0||D>g0)return!1;return du(k0,D)};var o0=(D)=>{if(D>=n1&&D<=t1)return!0;if(D<d0||D>i0)return!1;return du(NF,D)};function o1(D){if(!Number.isSafeInteger(D))throw TypeError(`Expected a code point, got \`${typeof D}\`.`)}function s0(D,{ambiguousAsWide:u=!1}={}){if(o1(D),l0(D)||o0(D)||u&&t0(D))return 2;return 1}var e0=I0(a0(),1),s1=new Intl.Segmenter,r1=/^\p{Default_Ignorable_Code_Point}$/u;function RD(D,u={}){if(typeof D!=="string"||D.length===0)return 0;let{ambiguousIsNarrow:F=!0,countAnsiEscapeCodes:E=!1}=u;if(!E)D=lD(D);if(D.length===0)return 0;let C=0,B={ambiguousAsWide:!F};for(let{segment:$}of s1.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(r1.test($))continue;if(e0.default().test($)){C+=2;continue}C+=s0(z,B)}return C}var D2=(D=0)=>(u)=>`\x1B[${u+D}m`,u2=(D=0)=>(u)=>`\x1B[${38+D};5;${u}m`,F2=(D=0)=>(u,F,E)=>`\x1B[${38+D};2;${u};${F};${E}m`,r={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]}},f7=Object.keys(r.modifier),a1=Object.keys(r.color),e1=Object.keys(r.bgColor),h7=[...a1,...e1];function D3(){let D=new Map;for(let[u,F]of Object.entries(r)){for(let[E,C]of Object.entries(F))r[E]={open:`\x1B[${C[0]}m`,close:`\x1B[${C[1]}m`},F[E]=r[E],D.set(C[0],C[1]);Object.defineProperty(r,u,{value:F,enumerable:!1})}return Object.defineProperty(r,"codes",{value:D,enumerable:!1}),r.color.close="\x1B[39m",r.bgColor.close="\x1B[49m",r.color.ansi=D2(),r.color.ansi256=u2(),r.color.ansi16m=F2(),r.bgColor.ansi=D2(10),r.bgColor.ansi256=u2(10),r.bgColor.ansi16m=F2(10),Object.defineProperties(r,{rgbToAnsi256:{value(u,F,E){if(u===F&&F===E){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(E/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[E]=F;if(E.length===3)E=[...E].map((B)=>B+B).join("");let C=Number.parseInt(E,16);return[C>>16&255,C>>8&255,C&255]},enumerable:!1},hexToAnsi256:{value:(u)=>r.rgbToAnsi256(...r.hexToRgb(u)),enumerable:!1},ansi256ToAnsi:{value(u){if(u<8)return 30+u;if(u<16)return 90+(u-8);let F,E,C;if(u>=232)F=((u-232)*10+8)/255,E=F,C=F;else{u-=16;let z=u%36;F=Math.floor(u/36)/5,E=Math.floor(z/6)/5,C=z%6/5}let B=Math.max(F,E,C)*2;if(B===0)return 30;let $=30+(Math.round(C)<<2|Math.round(E)<<1|Math.round(F));if(B===2)$+=60;return $},enumerable:!1},rgbToAnsi:{value:(u,F,E)=>r.ansi256ToAnsi(r.rgbToAnsi256(u,F,E)),enumerable:!1},hexToAnsi:{value:(u)=>r.ansi256ToAnsi(r.hexToAnsi256(u)),enumerable:!1}}),r}var u3=D3(),E2=u3;var nu=new Set(["\x1B","›"]),F3=39,TF="\x07",$2="[",E3="]",z2="m",iu=`${E3}8;;`,C2=(D)=>`${nu.values().next().value}${$2}${D}${z2}`,B2=(D)=>`${nu.values().next().value}${iu}${D}${TF}`,C3=(D)=>D.split(" ").map((u)=>RD(u)),RF=(D,u,F)=>{let E=[...u],C=!1,B=!1,$=RD(lD(D.at(-1)));for(let[z,G]of E.entries()){let Z=RD(G);if($+Z<=F)D[D.length-1]+=G;else D.push(G),$=0;if(nu.has(G))C=!0,B=E.slice(z+1,z+1+iu.length).join("")===iu;if(C){if(B){if(G===TF)C=!1,B=!1}else if(G===z2)C=!1;continue}if($+=Z,$===F&&z<E.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(RD(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 E="",C,B,$=C3(D),z=[""];for(let[J,Y]of D.split(" ").entries()){if(F.trim!==!1)z[z.length-1]=z.at(-1).trimStart();let W=RD(z.at(-1));if(J!==0){if(W>=u&&(F.wordWrap===!1||F.trim===!1))z.push(""),W=0;if(W>0||F.trim===!1)z[z.length-1]+=" ",W++}if(F.hard&&$[J]>u){let H=u-W,O=1+Math.floor(($[J]-H-1)/u);if(Math.floor(($[J]-1)/u)<O)z.push("");RF(z,Y,u);continue}if(W+$[J]>u&&W>0&&$[J]>0){if(F.wordWrap===!1&&W<u){RF(z,Y,u);continue}z.push("")}if(W+$[J]>u&&F.wordWrap===!1){RF(z,Y,u);continue}z[z.length-1]+=Y}if(F.trim!==!1)z=z.map((J)=>B3(J));let G=z.join(`
8
+ `),Z=[...G],Q=0;for(let[J,Y]of Z.entries()){if(E+=Y,nu.has(Y)){let{groups:H}=new RegExp(`(?:\\${$2}(?<code>\\d+)m|\\${iu}(?<uri>.*)${TF})`).exec(G.slice(Q))||{groups:{}};if(H.code!==void 0){let O=Number.parseFloat(H.code);C=O===F3?void 0:O}else if(H.uri!==void 0)B=H.uri.length===0?void 0:H.uri}let W=E2.codes.get(Number(C));if(Z[J+1]===`
9
+ `){if(B)E+=B2("");if(C&&W)E+=C2(W)}else if(Y===`
10
+ `){if(C&&W)E+=C2(C);if(B)E+=B2(B)}Q+=Y.length}return E};function SF(D,u,F){return String(D).normalize().replaceAll(`\r
11
11
  `,`
12
12
  `).split(`
13
- `).map((E)=>J1(E,u,F)).join(`
14
- `)}function WF(D){return $0(D,{stringWidth:KD,stripAnsi:mD,wrap:YF})}import{dirname as w0,resolve as I0}from"path";import{readdirSync as Q1,statSync as O1}from"fs";function MF(D,u){let F=I0(".",D),E;if(!O1(F).isDirectory())F=w0(F);while(!0){if(E=u(F,Q1(F)),E)return I0(F,E);if(F=w0(E=F),E===F)break}}import{inspect as w1}from"util";import{fileURLToPath as o0}from"url";import{format as M1}from"util";import{normalize as H1,resolve as V1}from"path";function cD(D){if(!(D!==D.toLowerCase()&&D!==D.toUpperCase()))D=D.toLowerCase();if(D.indexOf("-")===-1&&D.indexOf("_")===-1)return D;else{let F="",E=!1,C=D.match(/^-+/);for(let B=C?C[0].length:0;B<D.length;B++){let $=D.charAt(B);if(E)E=!1,$=$.toUpperCase();if(B!==0&&($==="-"||$==="_"))E=!0;else if($!=="-"&&$!=="_")F+=$}return F}}function hu(D,u){let F=D.toLowerCase();u=u||"-";let E="";for(let C=0;C<D.length;C++){let B=F.charAt(C),$=D.charAt(C);if(B!==$&&C>0)E+=`${u}${F.charAt(C)}`;else E+=$}return E}function vu(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 f0(D){if(Array.isArray(D))return D.map(($)=>typeof $!=="string"?$+"":$);D=D.trim();let u=0,F=null,E=null,C=null,B=[];for(let $=0;$<D.length;$++){if(F=E,E=D.charAt($),E===" "&&!C){if(F!==" ")u++;continue}if(E===C)C=null;else if((E==="'"||E==='"')&&!C)C=E;if(!B[u])B[u]="";B[u]+=E}return B}var qD;(function(D){D.BOOLEAN="boolean",D.STRING="string",D.NUMBER="number",D.ARRAY="array"})(qD||(qD={}));var PD;class VF{constructor(D){PD=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),E=f0(D),C=typeof D==="string",B=Y1(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),Z=F.configObjects||[],J=F.envPrefix,O=$["populate--"],X=O?"--":"_",Q=Object.create(null),Y=Object.create(null),M=F.__||PD.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:[]},_=/^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/,S=new RegExp("^--"+$["negation-prefix"]+"(.+)");if([].concat(F.array||[]).filter(Boolean).forEach(function(W){let q=typeof W==="object"?W.key:W,j=Object.keys(W).map(function(U){return{boolean:"bools",string:"strings",number:"numbers"}[U]}).filter(Boolean).pop();if(j)H[j][q]=!0;H.arrays[q]=!0,H.keys.push(q)}),[].concat(F.boolean||[]).filter(Boolean).forEach(function(W){H.bools[W]=!0,H.keys.push(W)}),[].concat(F.string||[]).filter(Boolean).forEach(function(W){H.strings[W]=!0,H.keys.push(W)}),[].concat(F.number||[]).filter(Boolean).forEach(function(W){H.numbers[W]=!0,H.keys.push(W)}),[].concat(F.count||[]).filter(Boolean).forEach(function(W){H.counts[W]=!0,H.keys.push(W)}),[].concat(F.normalize||[]).filter(Boolean).forEach(function(W){H.normalize[W]=!0,H.keys.push(W)}),typeof F.narg==="object")Object.entries(F.narg).forEach(([W,q])=>{if(typeof q==="number")H.nargs[W]=q,H.keys.push(W)});if(typeof F.coerce==="object")Object.entries(F.coerce).forEach(([W,q])=>{if(typeof q==="function")H.coercions[W]=q,H.keys.push(W)});if(typeof F.config<"u"){if(Array.isArray(F.config)||typeof F.config==="string")[].concat(F.config).filter(Boolean).forEach(function(W){H.configs[W]=!0});else if(typeof F.config==="object")Object.entries(F.config).forEach(([W,q])=>{if(typeof q==="boolean"||typeof q==="function")H.configs[W]=q})}Hu(F.key,B,F.default,H.arrays),Object.keys(z).forEach(function(W){(H.aliases[W]||[]).forEach(function(q){z[q]=z[W]})});let f=null;ZF();let d=[],x=Object.assign(Object.create(null),{_:[]}),i={};for(let W=0;W<E.length;W++){let q=E[W],j=q.replace(/^-{3,}/,"---"),U,V,A,T,I,GD;if(q!=="--"&&/^-/.test(q)&&t(q))a(q);else if(j.match(/^---+(=|$)/)){a(q);continue}else if(q.match(/^--.+=/)||!$["short-option-groups"]&&q.match(/^-.+=/)){if(T=q.match(/^--?([^=]+)=([\s\S]*)$/),T!==null&&Array.isArray(T)&&T.length>=3)if(b(T[1],H.arrays))W=RD(W,T[1],E,T[2]);else if(b(T[1],H.nargs)!==!1)W=e(W,T[1],E,T[2]);else g(T[1],T[2],!0)}else if(q.match(S)&&$["boolean-negation"]){if(T=q.match(S),T!==null&&Array.isArray(T)&&T.length>=2)V=T[1],g(V,b(V,H.arrays)?[!1]:!1)}else if(q.match(/^--.+/)||!$["short-option-groups"]&&q.match(/^-[^-]+/)){if(T=q.match(/^--?(.+)/),T!==null&&Array.isArray(T)&&T.length>=2)if(V=T[1],b(V,H.arrays))W=RD(W,V,E);else if(b(V,H.nargs)!==!1)W=e(W,V,E);else if(I=E[W+1],I!==void 0&&(!I.match(/^-/)||I.match(_))&&!b(V,H.bools)&&!b(V,H.counts))g(V,I),W++;else if(/^(true|false)$/.test(I))g(V,I),W++;else g(V,c(V))}else if(q.match(/^-.\..+=/)){if(T=q.match(/^-([^=]+)=([\s\S]*)$/),T!==null&&Array.isArray(T)&&T.length>=3)g(T[1],T[2])}else if(q.match(/^-.\..+/)&&!q.match(_)){if(I=E[W+1],T=q.match(/^-(.\..+)/),T!==null&&Array.isArray(T)&&T.length>=2)if(V=T[1],I!==void 0&&!I.match(/^-/)&&!b(V,H.bools)&&!b(V,H.counts))g(V,I),W++;else g(V,c(V))}else if(q.match(/^-[^-]+/)&&!q.match(_)){A=q.slice(1,-1).split(""),U=!1;for(let JD=0;JD<A.length;JD++){if(I=q.slice(JD+2),A[JD+1]&&A[JD+1]==="="){if(GD=q.slice(JD+3),V=A[JD],b(V,H.arrays))W=RD(W,V,E,GD);else if(b(V,H.nargs)!==!1)W=e(W,V,E,GD);else g(V,GD);U=!0;break}if(I==="-"){g(A[JD],I);continue}if(/[A-Za-z]/.test(A[JD])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(I)&&b(I,H.bools)===!1){g(A[JD],I),U=!0;break}if(A[JD+1]&&A[JD+1].match(/\W/)){g(A[JD],I),U=!0;break}else g(A[JD],c(A[JD]))}if(V=q.slice(-1)[0],!U&&V!=="-")if(b(V,H.arrays))W=RD(W,V,E);else if(b(V,H.nargs)!==!1)W=e(W,V,E);else if(I=E[W+1],I!==void 0&&(!/^(-|--)[^-]/.test(I)||I.match(_))&&!b(V,H.bools)&&!b(V,H.counts))g(V,I),W++;else if(/^(true|false)$/.test(I))g(V,I),W++;else g(V,c(V))}else if(q.match(/^-[0-9]$/)&&q.match(_)&&b(q.slice(1),H.bools))V=q.slice(1),g(V,c(V));else if(q==="--"){d=E.slice(W+1);break}else if($["halt-at-non-option"]){d=E.slice(W);break}else a(q)}if(ED(x,!0),ED(x,!1),P(x),k(),wD(x,H.aliases,z,!0),n(x),$["set-placeholder-key"])CD(x);if(Object.keys(H.counts).forEach(function(W){if(!l(x,W.split(".")))g(W,0)}),O&&d.length)x[X]=[];if(d.forEach(function(W){x[X].push(W)}),$["camel-case-expansion"]&&$["strip-dashed"])Object.keys(x).filter((W)=>W!=="--"&&W.includes("-")).forEach((W)=>{delete x[W]});if($["strip-aliased"])[].concat(...Object.keys(B).map((W)=>B[W])).forEach((W)=>{if($["camel-case-expansion"]&&W.includes("-"))delete x[W.split(".").map((q)=>cD(q)).join(".")];delete x[W]});function a(W){let q=K("_",W);if(typeof q==="string"||typeof q==="number")x._.push(q)}function e(W,q,j,U){let V,A=b(q,H.nargs);if(A=typeof A!=="number"||isNaN(A)?1:A,A===0){if(!$D(U))f=Error(M("Argument unexpected for: %s",q));return g(q,c(q)),W}let T=$D(U)?0:1;if($["nargs-eats-options"]){if(j.length-(W+1)+T<A)f=Error(M("Not enough arguments following: %s",q));T=A}else{for(V=W+1;V<j.length;V++)if(!j[V].match(/^-[^0-9]/)||j[V].match(_)||t(j[V]))T++;else break;if(T<A)f=Error(M("Not enough arguments following: %s",q))}let I=Math.min(T,A);if(!$D(U)&&I>0)g(q,U),I--;for(V=W+1;V<I+W+1;V++)g(q,j[V]);return W+I}function RD(W,q,j,U){let V=[],A=U||j[W+1],T=b(q,H.nargs);if(b(q,H.bools)&&!/^(true|false)$/.test(A))V.push(!0);else if($D(A)||$D(U)&&/^-/.test(A)&&!_.test(A)&&!t(A)){if(z[q]!==void 0){let I=z[q];V=Array.isArray(I)?I:[I]}}else{if(!$D(U))V.push(L(q,U,!0));for(let I=W+1;I<j.length;I++){if(!$["greedy-arrays"]&&V.length>0||T&&typeof T==="number"&&V.length>=T)break;if(A=j[I],/^-/.test(A)&&!_.test(A)&&!t(A))break;W=I,V.push(L(q,A,C))}}if(typeof T==="number"&&(T&&V.length<T||isNaN(T)&&V.length===0))f=Error(M("Not enough arguments following: %s",q));return g(q,V),W}function g(W,q,j=C){if(/-/.test(W)&&$["camel-case-expansion"]){let A=W.split(".").map(function(T){return cD(T)}).join(".");Mu(W,A)}let U=L(W,q,j),V=W.split(".");if(SD(x,V,U),H.aliases[W])H.aliases[W].forEach(function(A){let T=A.split(".");SD(x,T,U)});if(V.length>1&&$["dot-notation"])(H.aliases[V[0]]||[]).forEach(function(A){let T=A.split("."),I=[].concat(V);if(I.shift(),T=T.concat(I),!(H.aliases[W]||[]).includes(T.join(".")))SD(x,T,U)});if(b(W,H.normalize)&&!b(W,H.arrays))[W].concat(H.aliases[W]||[]).forEach(function(T){Object.defineProperty(i,T,{enumerable:!0,get(){return q},set(I){q=typeof I==="string"?PD.normalize(I):I}})})}function Mu(W,q){if(!(H.aliases[W]&&H.aliases[W].length))H.aliases[W]=[q],Q[q]=!0;if(!(H.aliases[q]&&H.aliases[q].length))Mu(q,W)}function L(W,q,j){if(j)q=W1(q);if(b(W,H.bools)||b(W,H.counts)){if(typeof q==="string")q=q==="true"}let U=Array.isArray(q)?q.map(function(V){return K(W,V)}):K(W,q);if(b(W,H.counts)&&($D(U)||typeof U==="boolean"))U=HF();if(b(W,H.normalize)&&b(W,H.arrays))if(Array.isArray(q))U=q.map((V)=>{return PD.normalize(V)});else U=PD.normalize(q);return U}function K(W,q){if(!$["parse-positional-numbers"]&&W==="_")return q;if(!b(W,H.strings)&&!b(W,H.bools)&&!Array.isArray(q)){if(vu(q)&&$["parse-numbers"]&&Number.isSafeInteger(Math.floor(parseFloat(`${q}`)))||!$D(q)&&b(W,H.numbers))q=Number(q)}return q}function P(W){let q=Object.create(null);wD(q,H.aliases,z),Object.keys(H.configs).forEach(function(j){let U=W[j]||q[j];if(U)try{let V=null,A=PD.resolve(PD.cwd(),U),T=H.configs[j];if(typeof T==="function"){try{V=T(A)}catch(I){V=I}if(V instanceof Error){f=V;return}}else V=PD.require(A);p(V)}catch(V){if(V.name==="PermissionDenied")f=V;else if(W[j])f=Error(M("Invalid JSON config file: %s",U))}})}function p(W,q){Object.keys(W).forEach(function(j){let U=W[j],V=q?q+"."+j:j;if(typeof U==="object"&&U!==null&&!Array.isArray(U)&&$["dot-notation"])p(U,V);else if(!l(x,V.split("."))||b(V,H.arrays)&&$["combine-arrays"])g(V,U)})}function k(){if(typeof Z<"u")Z.forEach(function(W){p(W)})}function ED(W,q){if(typeof J>"u")return;let j=typeof J==="string"?J:"",U=PD.env();Object.keys(U).forEach(function(V){if(j===""||V.lastIndexOf(j,0)===0){let A=V.split("__").map(function(T,I){if(I===0)T=T.substring(j.length);return cD(T)});if((q&&H.configs[A.join(".")]||!q)&&!l(W,A))g(A.join("."),U[V])}})}function n(W){let q,j=new Set;Object.keys(W).forEach(function(U){if(!j.has(U)){if(q=b(U,H.coercions),typeof q==="function")try{let V=K(U,q(W[U]));[].concat(H.aliases[U]||[],U).forEach((A)=>{j.add(A),W[A]=V})}catch(V){f=V}}})}function CD(W){return H.keys.forEach((q)=>{if(~q.indexOf("."))return;if(typeof W[q]>"u")W[q]=void 0}),W}function wD(W,q,j,U=!1){Object.keys(j).forEach(function(V){if(!l(W,V.split("."))){if(SD(W,V.split("."),j[V]),U)Y[V]=!0;(q[V]||[]).forEach(function(A){if(l(W,A.split(".")))return;SD(W,A.split("."),j[V])})}})}function l(W,q){let j=W;if(!$["dot-notation"])q=[q.join(".")];q.slice(0,-1).forEach(function(V){j=j[V]||{}});let U=q[q.length-1];if(typeof j!=="object")return!1;else return U in j}function SD(W,q,j){let U=W;if(!$["dot-notation"])q=[q.join(".")];q.slice(0,-1).forEach(function(GD){if(GD=x0(GD),typeof U==="object"&&U[GD]===void 0)U[GD]={};if(typeof U[GD]!=="object"||Array.isArray(U[GD])){if(Array.isArray(U[GD]))U[GD].push({});else U[GD]=[U[GD],{}];U=U[GD][U[GD].length-1]}else U=U[GD]});let V=x0(q[q.length-1]),A=b(q.join("."),H.arrays),T=Array.isArray(j),I=$["duplicate-arguments-array"];if(!I&&b(V,H.nargs)){if(I=!0,!$D(U[V])&&H.nargs[V]===1||Array.isArray(U[V])&&U[V].length===H.nargs[V])U[V]=void 0}if(j===HF())U[V]=HF(U[V]);else if(Array.isArray(U[V]))if(I&&A&&T)U[V]=$["flatten-duplicate-arrays"]?U[V].concat(j):(Array.isArray(U[V][0])?U[V]:[U[V]]).concat([j]);else if(!I&&Boolean(A)===Boolean(T))U[V]=j;else U[V]=U[V].concat([j]);else if(U[V]===void 0&&A)U[V]=T?j:[j];else if(I&&!(U[V]===void 0||b(V,H.counts)||b(V,H.bools)))U[V]=[U[V],j];else U[V]=j}function Hu(...W){W.forEach(function(q){Object.keys(q||{}).forEach(function(j){if(H.aliases[j])return;H.aliases[j]=[].concat(B[j]||[]),H.aliases[j].concat(j).forEach(function(U){if(/-/.test(U)&&$["camel-case-expansion"]){let V=cD(U);if(V!==j&&H.aliases[j].indexOf(V)===-1)H.aliases[j].push(V),Q[V]=!0}}),H.aliases[j].concat(j).forEach(function(U){if(U.length>1&&/[A-Z]/.test(U)&&$["camel-case-expansion"]){let V=hu(U,"-");if(V!==j&&H.aliases[j].indexOf(V)===-1)H.aliases[j].push(V),Q[V]=!0}}),H.aliases[j].forEach(function(U){H.aliases[U]=[j].concat(H.aliases[j].filter(function(V){return U!==V}))})})})}function b(W,q){let j=[].concat(H.aliases[W]||[],W),U=Object.keys(q),V=j.find((A)=>U.includes(A));return V?q[V]:!1}function $u(W){let q=Object.keys(H);return[].concat(q.map((U)=>H[U])).some(function(U){return Array.isArray(U)?U.includes(W):U[W]})}function D0(W,...q){return[].concat(...q).some(function(U){let V=W.match(U);return V&&$u(V[1])})}function h(W){if(W.match(_)||!W.match(/^-[^-]+/))return!1;let q=!0,j,U=W.slice(1).split("");for(let V=0;V<U.length;V++){if(j=W.slice(V+2),!$u(U[V])){q=!1;break}if(U[V+1]&&U[V+1]==="="||j==="-"||/[A-Za-z]/.test(U[V])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(j)||U[V+1]&&U[V+1].match(/\W/))break}return q}function t(W){return $["unknown-options-as-args"]&&BD(W)}function BD(W){if(W=W.replace(/^-{3,}/,"--"),W.match(_))return!1;if(h(W))return!1;return!D0(W,/^-+([^=]+?)=[\s\S]*$/,S,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}function c(W){if(!b(W,H.bools)&&!b(W,H.counts)&&`${W}`in z)return z[W];else return XD(DD(W))}function XD(W){return{[qD.BOOLEAN]:!0,[qD.STRING]:"",[qD.NUMBER]:void 0,[qD.ARRAY]:[]}[W]}function DD(W){let q=qD.BOOLEAN;if(b(W,H.strings))q=qD.STRING;else if(b(W,H.numbers))q=qD.NUMBER;else if(b(W,H.bools))q=qD.BOOLEAN;else if(b(W,H.arrays))q=qD.ARRAY;return q}function $D(W){return W===void 0}function ZF(){Object.keys(H.counts).find((W)=>{if(b(W,H.arrays))return f=Error(M("Invalid configuration: %s, opts.count excludes opts.array.",W)),!0;else if(b(W,H.nargs))return f=Error(M("Invalid configuration: %s, opts.count excludes opts.narg.",W)),!0;return!1})}return{aliases:Object.assign({},H.aliases),argv:Object.assign(i,x),configuration:$,defaulted:Object.assign({},Y),error:f,newAliases:Object.assign({},Q)}}}function Y1(D){let u=[],F=Object.create(null),E=!0;Object.keys(D).forEach(function(C){u.push([].concat(D[C],C))});while(E){E=!1;for(let C=0;C<u.length;C++)for(let B=C+1;B<u.length;B++)if(u[C].filter(function(z){return u[B].indexOf(z)!==-1}).length){u[C]=u[C].concat(u[B]),u.splice(B,1),E=!0;break}}return u.forEach(function(C){C=C.filter(function($,z,Z){return Z.indexOf($)===z});let B=C.pop();if(B!==void 0&&typeof B==="string")F[B]=C}),F}function HF(D){return D!==void 0?D+1:1}function x0(D){if(D==="__proto__")return"___proto___";return D}function W1(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 q1}from"fs";import{createRequire as b0}from"node:module";var qF,UF,_F,h0=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):20,v0=(UF=(qF=process===null||process===void 0?void 0:process.versions)===null||qF===void 0?void 0:qF.node)!==null&&UF!==void 0?UF:(_F=process===null||process===void 0?void 0:process.version)===null||_F===void 0?void 0:_F.slice(1);if(v0){if(Number(v0.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 U1=process?process.env:{},p0=b0?b0(import.meta.url):void 0,m0=new VF({cwd:process.cwd,env:()=>{return U1},format:M1,normalize:H1,resolve:V1,require:(D)=>{if(typeof p0<"u")return p0(D);else if(D.match(/\.json$/))return JSON.parse(q1(D,"utf8"));else throw Error("only .json config files are supported in ESM")}}),Vu=function(u,F){return m0.parse(u.slice(),F).argv};Vu.detailed=function(D,u){return m0.parse(D.slice(),u)};Vu.camelCase=cD;Vu.decamelize=hu;Vu.looksLikeNumber=vu;var jF=Vu;import{basename as I1,dirname as f1,extname as x1,relative as b1,resolve as l0,join as h1}from"path";function c0(){if(_1())return 0;return 1}function _1(){return j1()&&!process.defaultApp}function j1(){return!!process.versions.electron}function KF(D){return D.slice(c0()+1)}function y0(){return process.argv[c0()]}import{readFileSync as K1,statSync as T1,writeFile as N1}from"fs";import{format as R1}from"util";import{resolve as A1}from"path";var i0={fs:{readFileSync:K1,writeFile:N1},format:R1,resolve:A1,exists:(D)=>{try{return T1(D).isFile()}catch(u){return!1}}};var TD;class n0{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 TD.format.apply(TD.format,[this.cache[this.locale][u]||u].concat(D))}__n(){let D=Array.prototype.slice.call(arguments),u=D.shift(),F=D.shift(),E=D.shift(),C=function(){};if(typeof D[D.length-1]==="function")C=D.pop();if(!this.cache[this.locale])this._readLocaleFile();let B=E===1?u:F;if(this.cache[this.locale][u])B=this.cache[this.locale][u][E===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:C});else C();let $=[B];if(~B.indexOf("%d"))$.push(E);return TD.format.apply(TD.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(E,C){let B=u[C+1];if(F+=E,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,E=u.locale,C=u.cb,B=this._resolveLocaleFile(F,E),$=JSON.stringify(this.cache[E],null,2);TD.fs.writeFile(B,$,"utf-8",function(z){if(D.writeQueue.shift(),D.writeQueue.length>0)D._processWriteQueue();C(z)})}_readLocaleFile(){let D={},u=this._resolveLocaleFile(this.directory,this.locale);try{if(TD.fs.readFileSync)D=JSON.parse(TD.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=TD.resolve(D,"./",u+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(F)&&~u.lastIndexOf("_")){let E=TD.resolve(D,"./",u.split("_")[0]+".json");if(this._fileExistsSync(E))F=E}return F}_fileExistsSync(D){return TD.exists(D)}}function k0(D,u){TD=u;let F=new n0(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 L1=(D)=>{return k0(D,i0)},d0=L1;var s0=F0(t0(),1);import{createRequire as v1}from"node:module";import{readFileSync as p1,readdirSync as m1}from"node:fs";var TF=o0(import.meta.url),c1=TF.substring(0,TF.lastIndexOf("node_modules")),y1=v1(import.meta.url),NF={assert:{notStrictEqual:S1,strictEqual:P1},cliui:WF,findUp:MF,getEnv:(D)=>{return process.env[D]},inspect:w1,getProcessArgvBin:y0,mainFilename:c1||process.cwd(),Parser:jF,path:{basename:I1,dirname:f1,extname:x1,relative:b1,resolve:l0,join:h1},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:p1,readdirSync:m1,require:y1,getCallerFile:()=>{let D=s0.default(3);return D.match(/^file:\/\//)?o0(D):D},stringWidth:KD,y18n:d0({directory:l0(TF,"../../../locales"),updateFiles:!1})};function QD(D,u,F,E){F.assert.notStrictEqual(D,u,E)}function RF(D,u){u.assert.strictEqual(typeof D,"string")}function Gu(D){return Object.keys(D)}function o(D){return!!D&&!!D.then&&typeof D.then==="function"}class uD extends Error{constructor(D){super(D||"yargs error");if(this.name="YError",Error.captureStackTrace)Error.captureStackTrace(this,uD)}}function ID(D){let F=D.replace(/\s{2,}/g," ").split(/\s+(?![^[]*]|[^<]*>)/),E=/\.*[\][<>]/g,C=F.shift();if(!C)throw Error(`No command found in: ${D}`);let B={cmd:C.replace(E,""),demanded:[],optional:[]};return F.forEach(($,z)=>{let Z=!1;if($=$.replace(/\s/g,""),/\.+[\]>]/.test($)&&z===F.length-1)Z=!0;if(/^\[/.test($))B.optional.push({cmd:$.replace(E,"").split("|"),variadic:Z});else B.demanded.push({cmd:$.replace(E,"").split("|"),variadic:Z})}),B}var i1=["first","second","third","fourth","fifth","sixth"];function N(D,u,F){function E(){return typeof D==="object"?[{demanded:[],optional:[]},D,u]:[ID(`cmd ${D}`),u,F]}try{let C=0,[B,$,z]=E(),Z=[].slice.call($);while(Z.length&&Z[Z.length-1]===void 0)Z.pop();let J=z||Z.length;if(J<B.demanded.length)throw new uD(`Not enough arguments provided. Expected ${B.demanded.length} but received ${Z.length}.`);let O=B.demanded.length+B.optional.length;if(J>O)throw new uD(`Too many arguments provided. Expected max ${O} but received ${J}.`);B.demanded.forEach((X)=>{let Q=Z.shift(),Y=r0(Q);if(X.cmd.filter((H)=>H===Y||H==="*").length===0)a0(Y,X.cmd,C);C+=1}),B.optional.forEach((X)=>{if(Z.length===0)return;let Q=Z.shift(),Y=r0(Q);if(X.cmd.filter((H)=>H===Y||H==="*").length===0)a0(Y,X.cmd,C);C+=1})}catch(C){console.warn(C.stack)}}function r0(D){if(Array.isArray(D))return"array";else if(D===null)return"null";return typeof D}function a0(D,u,F){throw new uD(`Invalid ${i1[F]||"manyith"} argument. Expected ${u.join(" or ")} but received ${D}.`)}class AF{constructor(D){this.globalMiddleware=[],this.frozens=[],this.yargs=D}addMiddleware(D,u,F=!0,E=!1){if(N("<array|function> [boolean] [boolean] [boolean]",[D,u,F],arguments.length),Array.isArray(D)){for(let C=0;C<D.length;C++){if(typeof D[C]!=="function")throw Error("middleware must be a function");let B=D[C];B.applyBeforeValidation=u,B.global=F}Array.prototype.push.apply(this.globalMiddleware,D)}else if(typeof D==="function"){let C=D;C.applyBeforeValidation=u,C.global=F,C.mutates=E,this.globalMiddleware.push(D)}return this.yargs}addCoerceMiddleware(D,u){let F=this.yargs.getAliases();return this.globalMiddleware=this.globalMiddleware.filter((E)=>{let C=[...F[u]||[],u];if(!E.option)return!0;else return!C.includes(E.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 e0(D){if(!D)return[];return D.map((u)=>{return u.applyBeforeValidation=!1,u})}function yD(D,u,F,E){return F.reduce((C,B)=>{if(B.applyBeforeValidation!==E)return C;if(B.mutates){if(B.applied)return C;B.applied=!0}if(o(C))return C.then(($)=>Promise.all([$,B($,u)])).then(([$,z])=>Object.assign($,z));else{let $=B(C,u);return o($)?$.then((z)=>Object.assign(C,z)):Object.assign(C,$)}},D)}function iD(D,u,F=(E)=>{throw E}){try{let E=n1(D)?D():D;return o(E)?E.then((C)=>u(C)):u(E)}catch(E){return F(E)}}function n1(D){return typeof D==="function"}var Zu=/(^\*)|(^\$0)/;class u2{constructor(D,u,F,E){this.requireCache=new Set,this.handlers={},this.aliasMap={},this.frozens=[],this.shim=E,this.usage=D,this.globalMiddleware=F,this.validation=u}addDirectory(D,u,F,E){E=E||{},this.requireCache.add(F);let C=this.shim.path.resolve(this.shim.path.dirname(F),D),B=this.shim.readdirSync(C,{recursive:E.recurse?!0:!1});if(!Array.isArray(E.extensions))E.extensions=["js"];let $=typeof E.visit==="function"?E.visit:(z)=>z;for(let z of B){let Z=z.toString();if(E.exclude){let O=!1;if(typeof E.exclude==="function")O=E.exclude(Z);else O=E.exclude.test(Z);if(O)continue}if(E.include){let O=!1;if(typeof E.include==="function")O=E.include(Z);else O=E.include.test(Z);if(!O)continue}let J=!1;for(let O of E.extensions)if(Z.endsWith(O))J=!0;if(J){let O=this.shim.path.join(C,Z),X=u(O),Q=Object.create(null,Object.getOwnPropertyDescriptors({...X}));if($(Q,O,Z)){if(this.requireCache.has(O))continue;else this.requireCache.add(O);if(!Q.command)Q.command=this.shim.path.basename(O,this.shim.path.extname(O));this.addHandler(Q)}}}}addHandler(D,u,F,E,C,B){let $=[],z=e0(C);if(E=E||(()=>{}),Array.isArray(D))if(k1(D))[D,...$]=D;else for(let Z of D)this.addHandler(Z);else if(g1(D)){let Z=Array.isArray(D.command)||typeof D.command==="string"?D.command:null;if(Z===null)throw Error(`No command name given for module: ${this.shim.inspect(D)}`);if(D.aliases)Z=[].concat(Z).concat(D.aliases);this.addHandler(Z,this.extractDesc(D),D.builder,D.handler,D.middlewares,D.deprecated);return}else if(D2(F)){this.addHandler([D].concat($),u,F.builder,F.handler,F.middlewares,F.deprecated);return}if(typeof D==="string"){let Z=ID(D);$=$.map((X)=>ID(X).cmd);let J=!1,O=[Z.cmd].concat($).filter((X)=>{if(Zu.test(X))return J=!0,!1;return!0});if(O.length===0&&J)O.push("$0");if(J)Z.cmd=O[0],$=O.slice(1),D=D.replace(Zu,Z.cmd);if($.forEach((X)=>{this.aliasMap[X]=Z.cmd}),u!==!1)this.usage.command(D,u,J,$,B);if(this.handlers[Z.cmd]={original:D,description:u,handler:E,builder:F||{},middlewares:z,deprecated:B,demanded:Z.demanded,optional:Z.optional},J)this.defaultCommand=this.handlers[Z.cmd]}}getCommandHandlers(){return this.handlers}getCommands(){return Object.keys(this.handlers).concat(Object.keys(this.aliasMap))}hasDefaultCommand(){return!!this.defaultCommand}runCommand(D,u,F,E,C,B){let $=this.handlers[D]||this.handlers[this.aliasMap[D]]||this.defaultCommand,z=u.getInternalMethods().getContext(),Z=z.commands.slice(),J=!D;if(D)z.commands.push(D),z.fullCommands.push($.original);let O=this.applyBuilderUpdateUsageAndParse(J,$,u,F.aliases,Z,E,C,B);return o(O)?O.then((X)=>this.applyMiddlewareAndGetResult(J,$,X.innerArgv,z,C,X.aliases,u)):this.applyMiddlewareAndGetResult(J,$,O.innerArgv,z,C,O.aliases,u)}applyBuilderUpdateUsageAndParse(D,u,F,E,C,B,$,z){let Z=u.builder,J=F;if(pu(Z)){F.getInternalMethods().getUsageInstance().freeze();let O=Z(F.getInternalMethods().reset(E),z);if(o(O))return O.then((X)=>{return J=E2(X)?X:F,this.parseAndUpdateUsage(D,u,J,C,B,$)})}else if(d1(Z))F.getInternalMethods().getUsageInstance().freeze(),J=F.getInternalMethods().reset(E),Object.keys(u.builder).forEach((O)=>{J.option(O,Z[O])});return this.parseAndUpdateUsage(D,u,J,C,B,$)}parseAndUpdateUsage(D,u,F,E,C,B){if(D)F.getInternalMethods().getUsageInstance().unfreeze(!0);if(this.shouldUpdateUsage(F))F.getInternalMethods().getUsageInstance().usage(this.usageFromParentCommandsCommandHandler(E,u),u.description);let $=F.getInternalMethods().runYargsParserAndExecuteCommands(null,void 0,!0,C,B);return o($)?$.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=Zu.test(u.original)?u.original.replace(Zu,"").trim():u.original,E=D.filter((C)=>{return!Zu.test(C)});return E.push(F),`$0 ${E.join(" ")}`}handleValidationAndGetResult(D,u,F,E,C,B,$,z){if(!B.getInternalMethods().getHasOutput()){let Z=B.getInternalMethods().runValidation(C,z,B.parsed.error,D);F=iD(F,(J)=>{return Z(J),J})}if(u.handler&&!B.getInternalMethods().getHasOutput()){B.getInternalMethods().setHasOutput();let Z=!!B.getOptions().configuration["populate--"];if(B.getInternalMethods().postProcess(F,Z,!1,!1),F=yD(F,B,$,!1),F=iD(F,(J)=>{let O=u.handler(J);return o(O)?O.then(()=>J):J}),!D)B.getInternalMethods().getUsageInstance().cacheHelpMessage();if(o(F)&&!B.getInternalMethods().hasParseCallback())F.catch((J)=>{try{B.getInternalMethods().getUsageInstance().fail(null,J)}catch(O){}})}if(!D)E.commands.pop(),E.fullCommands.pop();return F}applyMiddlewareAndGetResult(D,u,F,E,C,B,$){let z={};if(C)return F;if(!$.getInternalMethods().getHasOutput())z=this.populatePositionals(u,F,E,$);let Z=this.globalMiddleware.getMiddleware().slice(0).concat(u.middlewares),J=yD(F,$,Z,!0);return o(J)?J.then((O)=>this.handleValidationAndGetResult(D,u,O,E,B,$,Z,z)):this.handleValidationAndGetResult(D,u,J,E,B,$,Z,z)}populatePositionals(D,u,F,E){u._=u._.slice(F.commands.length);let C=D.demanded.slice(0),B=D.optional.slice(0),$={};this.validation.positionalCount(C.length,u._.length);while(C.length){let z=C.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),E),$}populatePositional(D,u,F){let E=D.cmd[0];if(D.variadic)F[E]=u._.splice(0).map(String);else if(u._.length)F[E]=[String(u._.shift())]}cmdToParseOptions(D){let u={array:[],default:{},alias:{},demand:{}},F=ID(D);return F.demanded.forEach((E)=>{let[C,...B]=E.cmd;if(E.variadic)u.array.push(C),u.default[C]=[];u.alias[C]=B,u.demand[C]=!0}),F.optional.forEach((E)=>{let[C,...B]=E.cmd;if(E.variadic)u.array.push(C),u.default[C]=[];u.alias[C]=B}),u}postProcessPositionals(D,u,F,E){let C=Object.assign({},E.getOptions());C.default=Object.assign(F.default,C.default);for(let Z of Object.keys(F.alias))C.alias[Z]=(C.alias[Z]||[]).concat(F.alias[Z]);C.array=C.array.concat(F.array),C.config={};let B=[];if(Object.keys(u).forEach((Z)=>{u[Z].map((J)=>{if(C.configuration["unknown-options-as-args"])C.key[Z]=!0;B.push(`--${Z}`),B.push(J)})}),!B.length)return;let $=Object.assign({},C.configuration,{"populate--":!1}),z=this.shim.Parser.detailed(B,Object.assign({},C,{configuration:$}));if(z.error)E.getInternalMethods().getUsageInstance().fail(z.error.message,z.error);else{let Z=Object.keys(u);Object.keys(u).forEach((J)=>{Z.push(...z.aliases[J])}),Object.keys(z.argv).forEach((J)=>{if(Z.includes(J)){if(!u[J])u[J]=z.argv[J];if(!this.isInConfigs(E,J)&&!this.isDefaulted(E,J)&&Object.prototype.hasOwnProperty.call(D,J)&&Object.prototype.hasOwnProperty.call(z.argv,J)&&(Array.isArray(D[J])||Array.isArray(z.argv[J])))D[J]=[].concat(D[J],z.argv[J]);else D[J]=z.argv[J]}})}}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((E)=>Object.prototype.hasOwnProperty.call(E,u))||F.some((E)=>Object.prototype.hasOwnProperty.call(E,this.shim.Parser.camelCase(u)))}runDefaultBuilderOn(D){if(!this.defaultCommand)return;if(this.shouldUpdateUsage(D)){let F=Zu.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(!D2(u))Object.keys(u).forEach((F)=>{D.option(F,u[F])});return}extractDesc({describe:D,description:u,desc:F}){for(let E of[D,u,F]){if(typeof E==="string"||E===!1)return E;QD(E,!0,this.shim)}return!1}freeze(){this.frozens.push({handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand})}unfreeze(){let D=this.frozens.pop();QD(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 F2(D,u,F,E){return new u2(D,u,F,E)}function D2(D){return typeof D==="object"&&!!D.builder&&typeof D.handler==="function"}function k1(D){return D.every((u)=>typeof u==="string")}function pu(D){return typeof D==="function"}function d1(D){return typeof D==="object"}function g1(D){return typeof D==="object"&&!Array.isArray(D)}function fD(D={},u=()=>!0){let F={};return Gu(D).forEach((E)=>{if(u(E,D[E]))F[E]=D[E]}),F}function xD(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 t1(D){return typeof D==="boolean"}function B2(D,u){let F=u.y18n.__,E={},C=[];E.failFn=function(K){C.push(K)};let B=null,$=null,z=!0;E.showHelpOnFail=function(K=!0,P){let[p,k]=typeof K==="string"?[!0,K]:[K,P];if(D.getInternalMethods().isGlobalContext())$=k;return B=k,z=p,E};let Z=!1;E.fail=function(K,P){let p=D.getInternalMethods().getLoggerInstance();if(C.length)for(let k=C.length-1;k>=0;--k){let ED=C[k];if(t1(ED)){if(P)throw P;else if(K)throw Error(K)}else ED(K,P,E)}else{if(D.getExitProcess())xD(!0);if(!Z){if(Z=!0,z)D.showHelp("error"),p.error();if(K||P)p.error(K||P);let k=B||$;if(k){if(K||P)p.error("");p.error(k)}}if(P=P||new uD(K),D.getExitProcess())return D.exit(1);else if(D.getInternalMethods().hasParseCallback())return D.exit(1,P);else throw P}};let J=[],O=!1;E.usage=(L,K)=>{if(L===null)return O=!0,J=[],E;return O=!1,J.push([L,K||""]),E},E.getUsage=()=>{return J},E.getUsageDisabled=()=>{return O},E.getPositionalGroupName=()=>{return F("Positionals:")};let X=[];E.example=(L,K)=>{X.push([L,K||""])};let Q=[];E.command=function(K,P,p,k,ED=!1){if(p)Q=Q.map((n)=>{return n[2]=!1,n});Q.push([K,P||"",p,k,ED])},E.getCommands=()=>Q;let Y={};E.describe=function(K,P){if(Array.isArray(K))K.forEach((p)=>{E.describe(p,P)});else if(typeof K==="object")Object.keys(K).forEach((p)=>{E.describe(p,K[p])});else Y[K]=P},E.getDescriptions=()=>Y;let M=[];E.epilog=(L)=>{M.push(L)};let H=!1,_;E.wrap=(L)=>{H=!0,_=L},E.getWrap=()=>{if(u.getEnv("YARGS_DISABLE_WRAP"))return null;if(!H)_=RD(),H=!0;return _};let S="__yargsString__:";E.deferY18nLookup=(L)=>S+L,E.help=function(){if(x)return x;d();let K=D.customScriptName?D.$0:u.path.basename(D.$0),P=D.getDemandedOptions(),p=D.getDemandedCommands(),k=D.getDeprecatedOptions(),ED=D.getGroups(),n=D.getOptions(),CD=[];CD=CD.concat(Object.keys(Y)),CD=CD.concat(Object.keys(P)),CD=CD.concat(Object.keys(p)),CD=CD.concat(Object.keys(n.default)),CD=CD.filter(a),CD=Object.keys(CD.reduce((h,t)=>{if(t!=="_")h[t]=!0;return h},{}));let wD=E.getWrap(),l=u.cliui({width:wD,wrap:!!wD});if(!O){if(J.length)J.forEach((h)=>{if(l.div({text:`${h[0].replace(/\$0/g,K)}`}),h[1])l.div({text:`${h[1]}`,padding:[1,0,0,0]})}),l.div();else if(Q.length){let h=null;if(p._)h=`${K} <${F("command")}>
15
- `;else h=`${K} [${F("command")}]
16
- `;l.div(`${h}`)}}if(Q.length>1||Q.length===1&&!Q[0][2]){l.div(F("Commands:"));let h=D.getInternalMethods().getContext(),t=h.commands.length?`${h.commands.join(" ")} `:"";if(D.getInternalMethods().getParserConfiguration()["sort-commands"]===!0)Q=Q.sort((c,XD)=>c[0].localeCompare(XD[0]));let BD=K?`${K} `:"";Q.forEach((c)=>{let XD=`${BD}${t}${c[0].replace(/^\$0 ?/,"")}`;l.span({text:XD,padding:[0,2,0,2],width:f(Q,wD,`${K}${t}`)+4},{text:c[1]});let DD=[];if(c[2])DD.push(`[${F("default")}]`);if(c[3]&&c[3].length)DD.push(`[${F("aliases:")} ${c[3].join(", ")}]`);if(c[4])if(typeof c[4]==="string")DD.push(`[${F("deprecated: %s",c[4])}]`);else DD.push(`[${F("deprecated")}]`);if(DD.length)l.div({text:DD.join(" "),padding:[0,0,0,2],align:"right"});else l.div()}),l.div()}let SD=(Object.keys(n.alias)||[]).concat(Object.keys(D.parsed.newAliases)||[]);CD=CD.filter((h)=>!D.parsed.newAliases[h]&&SD.every((t)=>(n.alias[t]||[]).indexOf(h)===-1));let Hu=F("Options:");if(!ED[Hu])ED[Hu]=[];i(CD,n.alias,ED,Hu);let b=(h)=>/^--/.test(mu(h)),$u=Object.keys(ED).filter((h)=>ED[h].length>0).map((h)=>{let t=ED[h].filter(a).map((BD)=>{if(SD.includes(BD))return BD;for(let c=0,XD;(XD=SD[c])!==void 0;c++)if((n.alias[XD]||[]).includes(BD))return XD;return BD});return{groupName:h,normalizedKeys:t}}).filter(({normalizedKeys:h})=>h.length>0).map(({groupName:h,normalizedKeys:t})=>{let BD=t.reduce((c,XD)=>{return c[XD]=[XD].concat(n.alias[XD]||[]).map((DD)=>{if(h===E.getPositionalGroupName())return DD;else return(/^[0-9]$/.test(DD)?n.boolean.includes(XD)?"-":"--":DD.length>1?"--":"-")+DD}).sort((DD,$D)=>b(DD)===b($D)?0:b(DD)?1:-1).join(", "),c},{});return{groupName:h,normalizedKeys:t,switches:BD}});if($u.filter(({groupName:h})=>h!==E.getPositionalGroupName()).some(({normalizedKeys:h,switches:t})=>!h.every((BD)=>b(t[BD]))))$u.filter(({groupName:h})=>h!==E.getPositionalGroupName()).forEach(({normalizedKeys:h,switches:t})=>{h.forEach((BD)=>{if(b(t[BD]))t[BD]=l1(t[BD],4)})});if($u.forEach(({groupName:h,normalizedKeys:t,switches:BD})=>{l.div(h),t.forEach((c)=>{let XD=BD[c],DD=Y[c]||"",$D=null;if(DD.includes(S))DD=F(DD.substring(S.length));if(n.boolean.includes(c))$D=`[${F("boolean")}]`;if(n.count.includes(c))$D=`[${F("count")}]`;if(n.string.includes(c))$D=`[${F("string")}]`;if(n.normalize.includes(c))$D=`[${F("string")}]`;if(n.array.includes(c))$D=`[${F("array")}]`;if(n.number.includes(c))$D=`[${F("number")}]`;let ZF=(j)=>typeof j==="string"?`[${F("deprecated: %s",j)}]`:`[${F("deprecated")}]`,W=[c in k?ZF(k[c]):null,$D,c in P?`[${F("required")}]`:null,n.choices&&n.choices[c]?`[${F("choices:")} ${E.stringifiedValues(n.choices[c])}]`:null,e(n.default[c],n.defaultDescription[c])].filter(Boolean).join(" ");l.span({text:mu(XD),padding:[0,2,0,2+C2(XD)],width:f(BD,wD)+4},DD);let q=D.getInternalMethods().getUsageConfiguration()["hide-types"]===!0;if(W&&!q)l.div({text:W,padding:[0,0,0,2],align:"right"});else l.div()}),l.div()}),X.length)l.div(F("Examples:")),X.forEach((h)=>{h[0]=h[0].replace(/\$0/g,K)}),X.forEach((h)=>{if(h[1]==="")l.div({text:h[0],padding:[0,2,0,2]});else l.div({text:h[0],padding:[0,2,0,2],width:f(X,wD)+4},{text:h[1]})}),l.div();if(M.length>0){let h=M.map((t)=>t.replace(/\$0/g,K)).join(`
13
+ `).map((E)=>$3(E,u,F)).join(`
14
+ `)}function PF(D){return v0(D,{stringWidth:RD,stripAnsi:lD,wrap:SF})}import{dirname as G2,resolve as Z2}from"path";import{readdirSync as z3,statSync as G3}from"fs";function wF(D,u){let F=Z2(".",D),E;if(!G3(F).isDirectory())F=G2(F);while(!0){if(E=u(F,z3(F)),E)return Z2(F,E);if(F=G2(E=F),E===F)break}}import{inspect as N3}from"util";import{fileURLToPath as N2}from"url";import{format as X3}from"util";import{normalize as Q3,resolve as O3}from"path";function oD(D){if(!(D!==D.toLowerCase()&&D!==D.toUpperCase()))D=D.toLowerCase();if(D.indexOf("-")===-1&&D.indexOf("_")===-1)return D;else{let F="",E=!1,C=D.match(/^-+/);for(let B=C?C[0].length:0;B<D.length;B++){let $=D.charAt(B);if(E)E=!1,$=$.toUpperCase();if(B!==0&&($==="-"||$==="_"))E=!0;else if($!=="-"&&$!=="_")F+=$}return F}}function tu(D,u){let F=D.toLowerCase();u=u||"-";let E="";for(let C=0;C<D.length;C++){let B=F.charAt(C),$=D.charAt(C);if(B!==$&&C>0)E+=`${u}${F.charAt(C)}`;else E+=$}return E}function lu(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 J2(D){if(Array.isArray(D))return D.map(($)=>typeof $!=="string"?$+"":$);D=D.trim();let u=0,F=null,E=null,C=null,B=[];for(let $=0;$<D.length;$++){if(F=E,E=D.charAt($),E===" "&&!C){if(F!==" ")u++;continue}if(E===C)C=null;else if((E==="'"||E==='"')&&!C)C=E;if(!B[u])B[u]="";B[u]+=E}return B}var _D;(function(D){D.BOOLEAN="boolean",D.STRING="string",D.NUMBER="number",D.ARRAY="array"})(_D||(_D={}));var bD;class IF{constructor(D){bD=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),E=J2(D),C=typeof D==="string",B=Z3(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),G=F.configObjects||[],Z=F.envPrefix,Q=$["populate--"],J=Q?"--":"_",Y=Object.create(null),W=Object.create(null),H=F.__||bD.format,O={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:[]},q=/^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/,j=new RegExp("^--"+$["negation-prefix"]+"(.+)");if([].concat(F.array||[]).filter(Boolean).forEach(function(M){let U=typeof M==="object"?M.key:M,K=Object.keys(M).map(function(_){return{boolean:"bools",string:"strings",number:"numbers"}[_]}).filter(Boolean).pop();if(K)O[K][U]=!0;O.arrays[U]=!0,O.keys.push(U)}),[].concat(F.boolean||[]).filter(Boolean).forEach(function(M){O.bools[M]=!0,O.keys.push(M)}),[].concat(F.string||[]).filter(Boolean).forEach(function(M){O.strings[M]=!0,O.keys.push(M)}),[].concat(F.number||[]).filter(Boolean).forEach(function(M){O.numbers[M]=!0,O.keys.push(M)}),[].concat(F.count||[]).filter(Boolean).forEach(function(M){O.counts[M]=!0,O.keys.push(M)}),[].concat(F.normalize||[]).filter(Boolean).forEach(function(M){O.normalize[M]=!0,O.keys.push(M)}),typeof F.narg==="object")Object.entries(F.narg).forEach(([M,U])=>{if(typeof U==="number")O.nargs[M]=U,O.keys.push(M)});if(typeof F.coerce==="object")Object.entries(F.coerce).forEach(([M,U])=>{if(typeof U==="function")O.coercions[M]=U,O.keys.push(M)});if(typeof F.config<"u"){if(Array.isArray(F.config)||typeof F.config==="string")[].concat(F.config).filter(Boolean).forEach(function(M){O.configs[M]=!0});else if(typeof F.config==="object")Object.entries(F.config).forEach(([M,U])=>{if(typeof U==="boolean"||typeof U==="function")O.configs[M]=U})}Lu(F.key,B,F.default,O.arrays),Object.keys(z).forEach(function(M){(O.aliases[M]||[]).forEach(function(U){z[U]=z[M]})});let N=null;AF();let k=[],w=Object.assign(Object.create(null),{_:[]}),c={};for(let M=0;M<E.length;M++){let U=E[M],K=U.replace(/^-{3,}/,"---"),_,V,S,L,b,ZD;if(U!=="--"&&/^-/.test(U)&&t(U))e(U);else if(K.match(/^---+(=|$)/)){e(U);continue}else if(U.match(/^--.+=/)||!$["short-option-groups"]&&U.match(/^-.+=/)){if(L=U.match(/^--?([^=]+)=([\s\S]*)$/),L!==null&&Array.isArray(L)&&L.length>=3)if(f(L[1],O.arrays))M=qD(M,L[1],E,L[2]);else if(f(L[1],O.nargs)!==!1)M=s(M,L[1],E,L[2]);else i(L[1],L[2],!0)}else if(U.match(j)&&$["boolean-negation"]){if(L=U.match(j),L!==null&&Array.isArray(L)&&L.length>=2)V=L[1],i(V,f(V,O.arrays)?[!1]:!1)}else if(U.match(/^--.+/)||!$["short-option-groups"]&&U.match(/^-[^-]+/)){if(L=U.match(/^--?(.+)/),L!==null&&Array.isArray(L)&&L.length>=2)if(V=L[1],f(V,O.arrays))M=qD(M,V,E);else if(f(V,O.nargs)!==!1)M=s(M,V,E);else if(b=E[M+1],b!==void 0&&(!b.match(/^-/)||b.match(q))&&!f(V,O.bools)&&!f(V,O.counts))i(V,b),M++;else if(/^(true|false)$/.test(b))i(V,b),M++;else i(V,g(V))}else if(U.match(/^-.\..+=/)){if(L=U.match(/^-([^=]+)=([\s\S]*)$/),L!==null&&Array.isArray(L)&&L.length>=3)i(L[1],L[2])}else if(U.match(/^-.\..+/)&&!U.match(q)){if(b=E[M+1],L=U.match(/^-(.\..+)/),L!==null&&Array.isArray(L)&&L.length>=2)if(V=L[1],b!==void 0&&!b.match(/^-/)&&!f(V,O.bools)&&!f(V,O.counts))i(V,b),M++;else i(V,g(V))}else if(U.match(/^-[^-]+/)&&!U.match(q)){S=U.slice(1,-1).split(""),_=!1;for(let OD=0;OD<S.length;OD++){if(b=U.slice(OD+2),S[OD+1]&&S[OD+1]==="="){if(ZD=U.slice(OD+3),V=S[OD],f(V,O.arrays))M=qD(M,V,E,ZD);else if(f(V,O.nargs)!==!1)M=s(M,V,E,ZD);else i(V,ZD);_=!0;break}if(b==="-"){i(S[OD],b);continue}if(/[A-Za-z]/.test(S[OD])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(b)&&f(b,O.bools)===!1){i(S[OD],b),_=!0;break}if(S[OD+1]&&S[OD+1].match(/\W/)){i(S[OD],b),_=!0;break}else i(S[OD],g(S[OD]))}if(V=U.slice(-1)[0],!_&&V!=="-")if(f(V,O.arrays))M=qD(M,V,E);else if(f(V,O.nargs)!==!1)M=s(M,V,E);else if(b=E[M+1],b!==void 0&&(!/^(-|--)[^-]/.test(b)||b.match(q))&&!f(V,O.bools)&&!f(V,O.counts))i(V,b),M++;else if(/^(true|false)$/.test(b))i(V,b),M++;else i(V,g(V))}else if(U.match(/^-[0-9]$/)&&U.match(q)&&f(U.slice(1),O.bools))V=U.slice(1),i(V,g(V));else if(U==="--"){k=E.slice(M+1);break}else if($["halt-at-non-option"]){k=E.slice(M);break}else e(U)}if(CD(w,!0),CD(w,!1),x(w),n(),hD(w,O.aliases,z,!0),d(w),$["set-placeholder-key"])$D(w);if(Object.keys(O.counts).forEach(function(M){if(!l(w,M.split(".")))i(M,0)}),Q&&k.length)w[J]=[];if(k.forEach(function(M){w[J].push(M)}),$["camel-case-expansion"]&&$["strip-dashed"])Object.keys(w).filter((M)=>M!=="--"&&M.includes("-")).forEach((M)=>{delete w[M]});if($["strip-aliased"])[].concat(...Object.keys(B).map((M)=>B[M])).forEach((M)=>{if($["camel-case-expansion"]&&M.includes("-"))delete w[M.split(".").map((U)=>oD(U)).join(".")];delete w[M]});function e(M){let U=A("_",M);if(typeof U==="string"||typeof U==="number")w._.push(U)}function s(M,U,K,_){let V,S=f(U,O.nargs);if(S=typeof S!=="number"||isNaN(S)?1:S,S===0){if(!GD(_))N=Error(H("Argument unexpected for: %s",U));return i(U,g(U)),M}let L=GD(_)?0:1;if($["nargs-eats-options"]){if(K.length-(M+1)+L<S)N=Error(H("Not enough arguments following: %s",U));L=S}else{for(V=M+1;V<K.length;V++)if(!K[V].match(/^-[^0-9]/)||K[V].match(q)||t(K[V]))L++;else break;if(L<S)N=Error(H("Not enough arguments following: %s",U))}let b=Math.min(L,S);if(!GD(_)&&b>0)i(U,_),b--;for(V=M+1;V<b+M+1;V++)i(U,K[V]);return M+b}function qD(M,U,K,_){let V=[],S=_||K[M+1],L=f(U,O.nargs);if(f(U,O.bools)&&!/^(true|false)$/.test(S))V.push(!0);else if(GD(S)||GD(_)&&/^-/.test(S)&&!q.test(S)&&!t(S)){if(z[U]!==void 0){let b=z[U];V=Array.isArray(b)?b:[b]}}else{if(!GD(_))V.push(P(U,_,!0));for(let b=M+1;b<K.length;b++){if(!$["greedy-arrays"]&&V.length>0||L&&typeof L==="number"&&V.length>=L)break;if(S=K[b],/^-/.test(S)&&!q.test(S)&&!t(S))break;M=b,V.push(P(U,S,C))}}if(typeof L==="number"&&(L&&V.length<L||isNaN(L)&&V.length===0))N=Error(H("Not enough arguments following: %s",U));return i(U,V),M}function i(M,U,K=C){if(/-/.test(M)&&$["camel-case-expansion"]){let S=M.split(".").map(function(L){return oD(L)}).join(".");tD(M,S)}let _=P(M,U,K),V=M.split(".");if(ID(w,V,_),O.aliases[M])O.aliases[M].forEach(function(S){let L=S.split(".");ID(w,L,_)});if(V.length>1&&$["dot-notation"])(O.aliases[V[0]]||[]).forEach(function(S){let L=S.split("."),b=[].concat(V);if(b.shift(),L=L.concat(b),!(O.aliases[M]||[]).includes(L.join(".")))ID(w,L,_)});if(f(M,O.normalize)&&!f(M,O.arrays))[M].concat(O.aliases[M]||[]).forEach(function(L){Object.defineProperty(c,L,{enumerable:!0,get(){return U},set(b){U=typeof b==="string"?bD.normalize(b):b}})})}function tD(M,U){if(!(O.aliases[M]&&O.aliases[M].length))O.aliases[M]=[U],Y[U]=!0;if(!(O.aliases[U]&&O.aliases[U].length))tD(U,M)}function P(M,U,K){if(K)U=J3(U);if(f(M,O.bools)||f(M,O.counts)){if(typeof U==="string")U=U==="true"}let _=Array.isArray(U)?U.map(function(V){return A(M,V)}):A(M,U);if(f(M,O.counts)&&(GD(_)||typeof _==="boolean"))_=xF();if(f(M,O.normalize)&&f(M,O.arrays))if(Array.isArray(U))_=U.map((V)=>{return bD.normalize(V)});else _=bD.normalize(U);return _}function A(M,U){if(!$["parse-positional-numbers"]&&M==="_")return U;if(!f(M,O.strings)&&!f(M,O.bools)&&!Array.isArray(U)){if(lu(U)&&$["parse-numbers"]&&Number.isSafeInteger(Math.floor(parseFloat(`${U}`)))||!GD(U)&&f(M,O.numbers))U=Number(U)}return U}function x(M){let U=Object.create(null);hD(U,O.aliases,z),Object.keys(O.configs).forEach(function(K){let _=M[K]||U[K];if(_)try{let V=null,S=bD.resolve(bD.cwd(),_),L=O.configs[K];if(typeof L==="function"){try{V=L(S)}catch(b){V=b}if(V instanceof Error){N=V;return}}else V=bD.require(S);m(V)}catch(V){if(V.name==="PermissionDenied")N=V;else if(M[K])N=Error(H("Invalid JSON config file: %s",_))}})}function m(M,U){Object.keys(M).forEach(function(K){let _=M[K],V=U?U+"."+K:K;if(typeof _==="object"&&_!==null&&!Array.isArray(_)&&$["dot-notation"])m(_,V);else if(!l(w,V.split("."))||f(V,O.arrays)&&$["combine-arrays"])i(V,_)})}function n(){if(typeof G<"u")G.forEach(function(M){m(M)})}function CD(M,U){if(typeof Z>"u")return;let K=typeof Z==="string"?Z:"",_=bD.env();Object.keys(_).forEach(function(V){if(K===""||V.lastIndexOf(K,0)===0){let S=V.split("__").map(function(L,b){if(b===0)L=L.substring(K.length);return oD(L)});if((U&&O.configs[S.join(".")]||!U)&&!l(M,S))i(S.join("."),_[V])}})}function d(M){let U,K=new Set;Object.keys(M).forEach(function(_){if(!K.has(_)){if(U=f(_,O.coercions),typeof U==="function")try{let V=A(_,U(M[_]));[].concat(O.aliases[_]||[],_).forEach((S)=>{K.add(S),M[S]=V})}catch(V){N=V}}})}function $D(M){return O.keys.forEach((U)=>{if(~U.indexOf("."))return;if(typeof M[U]>"u")M[U]=void 0}),M}function hD(M,U,K,_=!1){Object.keys(K).forEach(function(V){if(!l(M,V.split("."))){if(ID(M,V.split("."),K[V]),_)W[V]=!0;(U[V]||[]).forEach(function(S){if(l(M,S.split(".")))return;ID(M,S.split("."),K[V])})}})}function l(M,U){let K=M;if(!$["dot-notation"])U=[U.join(".")];U.slice(0,-1).forEach(function(V){K=K[V]||{}});let _=U[U.length-1];if(typeof K!=="object")return!1;else return _ in K}function ID(M,U,K){let _=M;if(!$["dot-notation"])U=[U.join(".")];U.slice(0,-1).forEach(function(ZD){if(ZD=X2(ZD),typeof _==="object"&&_[ZD]===void 0)_[ZD]={};if(typeof _[ZD]!=="object"||Array.isArray(_[ZD])){if(Array.isArray(_[ZD]))_[ZD].push({});else _[ZD]=[_[ZD],{}];_=_[ZD][_[ZD].length-1]}else _=_[ZD]});let V=X2(U[U.length-1]),S=f(U.join("."),O.arrays),L=Array.isArray(K),b=$["duplicate-arguments-array"];if(!b&&f(V,O.nargs)){if(b=!0,!GD(_[V])&&O.nargs[V]===1||Array.isArray(_[V])&&_[V].length===O.nargs[V])_[V]=void 0}if(K===xF())_[V]=xF(_[V]);else if(Array.isArray(_[V]))if(b&&S&&L)_[V]=$["flatten-duplicate-arrays"]?_[V].concat(K):(Array.isArray(_[V][0])?_[V]:[_[V]]).concat([K]);else if(!b&&Boolean(S)===Boolean(L))_[V]=K;else _[V]=_[V].concat([K]);else if(_[V]===void 0&&S)_[V]=L?K:[K];else if(b&&!(_[V]===void 0||f(V,O.counts)||f(V,O.bools)))_[V]=[_[V],K];else _[V]=K}function Lu(...M){M.forEach(function(U){Object.keys(U||{}).forEach(function(K){if(O.aliases[K])return;O.aliases[K]=[].concat(B[K]||[]),O.aliases[K].concat(K).forEach(function(_){if(/-/.test(_)&&$["camel-case-expansion"]){let V=oD(_);if(V!==K&&O.aliases[K].indexOf(V)===-1)O.aliases[K].push(V),Y[V]=!0}}),O.aliases[K].concat(K).forEach(function(_){if(_.length>1&&/[A-Z]/.test(_)&&$["camel-case-expansion"]){let V=tu(_,"-");if(V!==K&&O.aliases[K].indexOf(V)===-1)O.aliases[K].push(V),Y[V]=!0}}),O.aliases[K].forEach(function(_){O.aliases[_]=[K].concat(O.aliases[K].filter(function(V){return _!==V}))})})})}function f(M,U){let K=[].concat(O.aliases[M]||[],M),_=Object.keys(U),V=K.find((S)=>_.includes(S));return V?U[V]:!1}function Hu(M){let U=Object.keys(O);return[].concat(U.map((_)=>O[_])).some(function(_){return Array.isArray(_)?_.includes(M):_[M]})}function w0(M,...U){return[].concat(...U).some(function(_){let V=M.match(_);return V&&Hu(V[1])})}function h(M){if(M.match(q)||!M.match(/^-[^-]+/))return!1;let U=!0,K,_=M.slice(1).split("");for(let V=0;V<_.length;V++){if(K=M.slice(V+2),!Hu(_[V])){U=!1;break}if(_[V+1]&&_[V+1]==="="||K==="-"||/[A-Za-z]/.test(_[V])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(K)||_[V+1]&&_[V+1].match(/\W/))break}return U}function t(M){return $["unknown-options-as-args"]&&zD(M)}function zD(M){if(M=M.replace(/^-{3,}/,"--"),M.match(q))return!1;if(h(M))return!1;return!w0(M,/^-+([^=]+?)=[\s\S]*$/,j,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}function g(M){if(!f(M,O.bools)&&!f(M,O.counts)&&`${M}`in z)return z[M];else return QD(uD(M))}function QD(M){return{[_D.BOOLEAN]:!0,[_D.STRING]:"",[_D.NUMBER]:void 0,[_D.ARRAY]:[]}[M]}function uD(M){let U=_D.BOOLEAN;if(f(M,O.strings))U=_D.STRING;else if(f(M,O.numbers))U=_D.NUMBER;else if(f(M,O.bools))U=_D.BOOLEAN;else if(f(M,O.arrays))U=_D.ARRAY;return U}function GD(M){return M===void 0}function AF(){Object.keys(O.counts).find((M)=>{if(f(M,O.arrays))return N=Error(H("Invalid configuration: %s, opts.count excludes opts.array.",M)),!0;else if(f(M,O.nargs))return N=Error(H("Invalid configuration: %s, opts.count excludes opts.narg.",M)),!0;return!1})}return{aliases:Object.assign({},O.aliases),argv:Object.assign(c,w),configuration:$,defaulted:Object.assign({},W),error:N,newAliases:Object.assign({},Y)}}}function Z3(D){let u=[],F=Object.create(null),E=!0;Object.keys(D).forEach(function(C){u.push([].concat(D[C],C))});while(E){E=!1;for(let C=0;C<u.length;C++)for(let B=C+1;B<u.length;B++)if(u[C].filter(function(z){return u[B].indexOf(z)!==-1}).length){u[C]=u[C].concat(u[B]),u.splice(B,1),E=!0;break}}return u.forEach(function(C){C=C.filter(function($,z,G){return G.indexOf($)===z});let B=C.pop();if(B!==void 0&&typeof B==="string")F[B]=C}),F}function xF(D){return D!==void 0?D+1:1}function X2(D){if(D==="__proto__")return"___proto___";return D}function J3(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 Q2}from"node:module";var bF,fF,hF,O2=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):20,Y2=(fF=(bF=process===null||process===void 0?void 0:process.versions)===null||bF===void 0?void 0:bF.node)!==null&&fF!==void 0?fF:(hF=process===null||process===void 0?void 0:process.version)===null||hF===void 0?void 0:hF.slice(1);if(Y2){if(Number(Y2.match(/^([^.]+)/)[1])<O2)throw Error(`yargs parser supports a minimum Node.js version of ${O2}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`)}var W3=process?process.env:{},W2=Q2?Q2(import.meta.url):void 0,H2=new IF({cwd:process.cwd,env:()=>{return W3},format:X3,normalize:Q3,resolve:O3,require:(D)=>{if(typeof W2<"u")return W2(D);else if(D.match(/\.json$/))return JSON.parse(Y3(D,"utf8"));else throw Error("only .json config files are supported in ESM")}}),Nu=function(u,F){return H2.parse(u.slice(),F).argv};Nu.detailed=function(D,u){return H2.parse(D.slice(),u)};Nu.camelCase=oD;Nu.decamelize=tu;Nu.looksLikeNumber=lu;var vF=Nu;import{basename as R3,dirname as T3,extname as S3,relative as P3,resolve as L2,join as w3}from"path";function M2(){if(H3())return 0;return 1}function H3(){return M3()&&!process.defaultApp}function M3(){return!!process.versions.electron}function mF(D){return D.slice(M2()+1)}function V2(){return process.argv[M2()]}import{readFileSync as V3,statSync as U3,writeFile as q3}from"fs";import{format as _3}from"util";import{resolve as K3}from"path";var U2={fs:{readFileSync:V3,writeFile:q3},format:_3,resolve:K3,exists:(D)=>{try{return U3(D).isFile()}catch(u){return!1}}};var TD;class q2{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 TD.format.apply(TD.format,[this.cache[this.locale][u]||u].concat(D))}__n(){let D=Array.prototype.slice.call(arguments),u=D.shift(),F=D.shift(),E=D.shift(),C=function(){};if(typeof D[D.length-1]==="function")C=D.pop();if(!this.cache[this.locale])this._readLocaleFile();let B=E===1?u:F;if(this.cache[this.locale][u])B=this.cache[this.locale][u][E===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:C});else C();let $=[B];if(~B.indexOf("%d"))$.push(E);return TD.format.apply(TD.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(E,C){let B=u[C+1];if(F+=E,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,E=u.locale,C=u.cb,B=this._resolveLocaleFile(F,E),$=JSON.stringify(this.cache[E],null,2);TD.fs.writeFile(B,$,"utf-8",function(z){if(D.writeQueue.shift(),D.writeQueue.length>0)D._processWriteQueue();C(z)})}_readLocaleFile(){let D={},u=this._resolveLocaleFile(this.directory,this.locale);try{if(TD.fs.readFileSync)D=JSON.parse(TD.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=TD.resolve(D,"./",u+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(F)&&~u.lastIndexOf("_")){let E=TD.resolve(D,"./",u.split("_")[0]+".json");if(this._fileExistsSync(E))F=E}return F}_fileExistsSync(D){return TD.exists(D)}}function _2(D,u){TD=u;let F=new q2(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 j3=(D)=>{return _2(D,U2)},K2=j3;var R2=I0(A2(),1);import{createRequire as x3}from"node:module";import{readFileSync as I3,readdirSync as b3}from"node:fs";var pF=N2(import.meta.url),f3=pF.substring(0,pF.lastIndexOf("node_modules")),h3=x3(import.meta.url),yF={assert:{notStrictEqual:A3,strictEqual:L3},cliui:PF,findUp:wF,getEnv:(D)=>{return process.env[D]},inspect:N3,getProcessArgvBin:V2,mainFilename:f3||process.cwd(),Parser:vF,path:{basename:R3,dirname:T3,extname:S3,relative:P3,resolve:L2,join:w3},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:I3,readdirSync:b3,require:h3,getCallerFile:()=>{let D=R2.default(3);return D.match(/^file:\/\//)?N2(D):D},stringWidth:RD,y18n:K2({directory:L2(pF,"../../../locales"),updateFiles:!1})};function YD(D,u,F,E){F.assert.notStrictEqual(D,u,E)}function cF(D,u){u.assert.strictEqual(typeof D,"string")}function Mu(D){return Object.keys(D)}function o(D){return!!D&&!!D.then&&typeof D.then==="function"}class FD extends Error{constructor(D){super(D||"yargs error");if(this.name="YError",Error.captureStackTrace)Error.captureStackTrace(this,FD)}}function mD(D){let F=D.replace(/\s{2,}/g," ").split(/\s+(?![^[]*]|[^<]*>)/),E=/\.*[\][<>]/g,C=F.shift();if(!C)throw Error(`No command found in: ${D}`);let B={cmd:C.replace(E,""),demanded:[],optional:[]};return F.forEach(($,z)=>{let G=!1;if($=$.replace(/\s/g,""),/\.+[\]>]/.test($)&&z===F.length-1)G=!0;if(/^\[/.test($))B.optional.push({cmd:$.replace(E,"").split("|"),variadic:G});else B.demanded.push({cmd:$.replace(E,"").split("|"),variadic:G})}),B}var v3=["first","second","third","fourth","fifth","sixth"];function R(D,u,F){function E(){return typeof D==="object"?[{demanded:[],optional:[]},D,u]:[mD(`cmd ${D}`),u,F]}try{let C=0,[B,$,z]=E(),G=[].slice.call($);while(G.length&&G[G.length-1]===void 0)G.pop();let Z=z||G.length;if(Z<B.demanded.length)throw new FD(`Not enough arguments provided. Expected ${B.demanded.length} but received ${G.length}.`);let Q=B.demanded.length+B.optional.length;if(Z>Q)throw new FD(`Too many arguments provided. Expected max ${Q} but received ${Z}.`);B.demanded.forEach((J)=>{let Y=G.shift(),W=T2(Y);if(J.cmd.filter((O)=>O===W||O==="*").length===0)S2(W,J.cmd,C);C+=1}),B.optional.forEach((J)=>{if(G.length===0)return;let Y=G.shift(),W=T2(Y);if(J.cmd.filter((O)=>O===W||O==="*").length===0)S2(W,J.cmd,C);C+=1})}catch(C){console.warn(C.stack)}}function T2(D){if(Array.isArray(D))return"array";else if(D===null)return"null";return typeof D}function S2(D,u,F){throw new FD(`Invalid ${v3[F]||"manyith"} argument. Expected ${u.join(" or ")} but received ${D}.`)}class gF{constructor(D){this.globalMiddleware=[],this.frozens=[],this.yargs=D}addMiddleware(D,u,F=!0,E=!1){if(R("<array|function> [boolean] [boolean] [boolean]",[D,u,F],arguments.length),Array.isArray(D)){for(let C=0;C<D.length;C++){if(typeof D[C]!=="function")throw Error("middleware must be a function");let B=D[C];B.applyBeforeValidation=u,B.global=F}Array.prototype.push.apply(this.globalMiddleware,D)}else if(typeof D==="function"){let C=D;C.applyBeforeValidation=u,C.global=F,C.mutates=E,this.globalMiddleware.push(D)}return this.yargs}addCoerceMiddleware(D,u){let F=this.yargs.getAliases();return this.globalMiddleware=this.globalMiddleware.filter((E)=>{let C=[...F[u]||[],u];if(!E.option)return!0;else return!C.includes(E.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 P2(D){if(!D)return[];return D.map((u)=>{return u.applyBeforeValidation=!1,u})}function sD(D,u,F,E){return F.reduce((C,B)=>{if(B.applyBeforeValidation!==E)return C;if(B.mutates){if(B.applied)return C;B.applied=!0}if(o(C))return C.then(($)=>Promise.all([$,B($,u)])).then(([$,z])=>Object.assign($,z));else{let $=B(C,u);return o($)?$.then((z)=>Object.assign(C,z)):Object.assign(C,$)}},D)}function rD(D,u,F=(E)=>{throw E}){try{let E=m3(D)?D():D;return o(E)?E.then((C)=>u(C)):u(E)}catch(E){return F(E)}}function m3(D){return typeof D==="function"}var Vu=/(^\*)|(^\$0)/;class x2{constructor(D,u,F,E){this.requireCache=new Set,this.handlers={},this.aliasMap={},this.frozens=[],this.shim=E,this.usage=D,this.globalMiddleware=F,this.validation=u}addDirectory(D,u,F,E){E=E||{},this.requireCache.add(F);let C=this.shim.path.resolve(this.shim.path.dirname(F),D),B=this.shim.readdirSync(C,{recursive:E.recurse?!0:!1});if(!Array.isArray(E.extensions))E.extensions=["js"];let $=typeof E.visit==="function"?E.visit:(z)=>z;for(let z of B){let G=z.toString();if(E.exclude){let Q=!1;if(typeof E.exclude==="function")Q=E.exclude(G);else Q=E.exclude.test(G);if(Q)continue}if(E.include){let Q=!1;if(typeof E.include==="function")Q=E.include(G);else Q=E.include.test(G);if(!Q)continue}let Z=!1;for(let Q of E.extensions)if(G.endsWith(Q))Z=!0;if(Z){let Q=this.shim.path.join(C,G),J=u(Q),Y=Object.create(null,Object.getOwnPropertyDescriptors({...J}));if($(Y,Q,G)){if(this.requireCache.has(Q))continue;else this.requireCache.add(Q);if(!Y.command)Y.command=this.shim.path.basename(Q,this.shim.path.extname(Q));this.addHandler(Y)}}}}addHandler(D,u,F,E,C,B){let $=[],z=P2(C);if(E=E||(()=>{}),Array.isArray(D))if(p3(D))[D,...$]=D;else for(let G of D)this.addHandler(G);else if(c3(D)){let G=Array.isArray(D.command)||typeof D.command==="string"?D.command:null;if(G===null)throw Error(`No command name given for module: ${this.shim.inspect(D)}`);if(D.aliases)G=[].concat(G).concat(D.aliases);this.addHandler(G,this.extractDesc(D),D.builder,D.handler,D.middlewares,D.deprecated);return}else if(w2(F)){this.addHandler([D].concat($),u,F.builder,F.handler,F.middlewares,F.deprecated);return}if(typeof D==="string"){let G=mD(D);$=$.map((J)=>mD(J).cmd);let Z=!1,Q=[G.cmd].concat($).filter((J)=>{if(Vu.test(J))return Z=!0,!1;return!0});if(Q.length===0&&Z)Q.push("$0");if(Z)G.cmd=Q[0],$=Q.slice(1),D=D.replace(Vu,G.cmd);if($.forEach((J)=>{this.aliasMap[J]=G.cmd}),u!==!1)this.usage.command(D,u,Z,$,B);if(this.handlers[G.cmd]={original:D,description:u,handler:E,builder:F||{},middlewares:z,deprecated:B,demanded:G.demanded,optional:G.optional},Z)this.defaultCommand=this.handlers[G.cmd]}}getCommandHandlers(){return this.handlers}getCommands(){return Object.keys(this.handlers).concat(Object.keys(this.aliasMap))}hasDefaultCommand(){return!!this.defaultCommand}runCommand(D,u,F,E,C,B){let $=this.handlers[D]||this.handlers[this.aliasMap[D]]||this.defaultCommand,z=u.getInternalMethods().getContext(),G=z.commands.slice(),Z=!D;if(D)z.commands.push(D),z.fullCommands.push($.original);let Q=this.applyBuilderUpdateUsageAndParse(Z,$,u,F.aliases,G,E,C,B);return o(Q)?Q.then((J)=>this.applyMiddlewareAndGetResult(Z,$,J.innerArgv,z,C,J.aliases,u)):this.applyMiddlewareAndGetResult(Z,$,Q.innerArgv,z,C,Q.aliases,u)}applyBuilderUpdateUsageAndParse(D,u,F,E,C,B,$,z){let G=u.builder,Z=F;if(ou(G)){F.getInternalMethods().getUsageInstance().freeze();let Q=G(F.getInternalMethods().reset(E),z);if(o(Q))return Q.then((J)=>{return Z=b2(J)?J:F,this.parseAndUpdateUsage(D,u,Z,C,B,$)})}else if(y3(G))F.getInternalMethods().getUsageInstance().freeze(),Z=F.getInternalMethods().reset(E),Object.keys(u.builder).forEach((Q)=>{Z.option(Q,G[Q])});return this.parseAndUpdateUsage(D,u,Z,C,B,$)}parseAndUpdateUsage(D,u,F,E,C,B){if(D)F.getInternalMethods().getUsageInstance().unfreeze(!0);if(this.shouldUpdateUsage(F))F.getInternalMethods().getUsageInstance().usage(this.usageFromParentCommandsCommandHandler(E,u),u.description);let $=F.getInternalMethods().runYargsParserAndExecuteCommands(null,void 0,!0,C,B);return o($)?$.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=Vu.test(u.original)?u.original.replace(Vu,"").trim():u.original,E=D.filter((C)=>{return!Vu.test(C)});return E.push(F),`$0 ${E.join(" ")}`}handleValidationAndGetResult(D,u,F,E,C,B,$,z){if(!B.getInternalMethods().getHasOutput()){let G=B.getInternalMethods().runValidation(C,z,B.parsed.error,D);F=rD(F,(Z)=>{return G(Z),Z})}if(u.handler&&!B.getInternalMethods().getHasOutput()){B.getInternalMethods().setHasOutput();let G=!!B.getOptions().configuration["populate--"];if(B.getInternalMethods().postProcess(F,G,!1,!1),F=sD(F,B,$,!1),F=rD(F,(Z)=>{let Q=u.handler(Z);return o(Q)?Q.then(()=>Z):Z}),!D)B.getInternalMethods().getUsageInstance().cacheHelpMessage();if(o(F)&&!B.getInternalMethods().hasParseCallback())F.catch((Z)=>{try{B.getInternalMethods().getUsageInstance().fail(null,Z)}catch(Q){}})}if(!D)E.commands.pop(),E.fullCommands.pop();return F}applyMiddlewareAndGetResult(D,u,F,E,C,B,$){let z={};if(C)return F;if(!$.getInternalMethods().getHasOutput())z=this.populatePositionals(u,F,E,$);let G=this.globalMiddleware.getMiddleware().slice(0).concat(u.middlewares),Z=sD(F,$,G,!0);return o(Z)?Z.then((Q)=>this.handleValidationAndGetResult(D,u,Q,E,B,$,G,z)):this.handleValidationAndGetResult(D,u,Z,E,B,$,G,z)}populatePositionals(D,u,F,E){u._=u._.slice(F.commands.length);let C=D.demanded.slice(0),B=D.optional.slice(0),$={};this.validation.positionalCount(C.length,u._.length);while(C.length){let z=C.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),E),$}populatePositional(D,u,F){let E=D.cmd[0];if(D.variadic)F[E]=u._.splice(0).map(String);else if(u._.length)F[E]=[String(u._.shift())]}cmdToParseOptions(D){let u={array:[],default:{},alias:{},demand:{}},F=mD(D);return F.demanded.forEach((E)=>{let[C,...B]=E.cmd;if(E.variadic)u.array.push(C),u.default[C]=[];u.alias[C]=B,u.demand[C]=!0}),F.optional.forEach((E)=>{let[C,...B]=E.cmd;if(E.variadic)u.array.push(C),u.default[C]=[];u.alias[C]=B}),u}postProcessPositionals(D,u,F,E){let C=Object.assign({},E.getOptions());C.default=Object.assign(F.default,C.default);for(let G of Object.keys(F.alias))C.alias[G]=(C.alias[G]||[]).concat(F.alias[G]);C.array=C.array.concat(F.array),C.config={};let B=[];if(Object.keys(u).forEach((G)=>{u[G].map((Z)=>{if(C.configuration["unknown-options-as-args"])C.key[G]=!0;B.push(`--${G}`),B.push(Z)})}),!B.length)return;let $=Object.assign({},C.configuration,{"populate--":!1}),z=this.shim.Parser.detailed(B,Object.assign({},C,{configuration:$}));if(z.error)E.getInternalMethods().getUsageInstance().fail(z.error.message,z.error);else{let G=Object.keys(u);Object.keys(u).forEach((Z)=>{G.push(...z.aliases[Z])}),Object.keys(z.argv).forEach((Z)=>{if(G.includes(Z)){if(!u[Z])u[Z]=z.argv[Z];if(!this.isInConfigs(E,Z)&&!this.isDefaulted(E,Z)&&Object.prototype.hasOwnProperty.call(D,Z)&&Object.prototype.hasOwnProperty.call(z.argv,Z)&&(Array.isArray(D[Z])||Array.isArray(z.argv[Z])))D[Z]=[].concat(D[Z],z.argv[Z]);else D[Z]=z.argv[Z]}})}}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((E)=>Object.prototype.hasOwnProperty.call(E,u))||F.some((E)=>Object.prototype.hasOwnProperty.call(E,this.shim.Parser.camelCase(u)))}runDefaultBuilderOn(D){if(!this.defaultCommand)return;if(this.shouldUpdateUsage(D)){let F=Vu.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(ou(u))return u(D,!0);else if(!w2(u))Object.keys(u).forEach((F)=>{D.option(F,u[F])});return}extractDesc({describe:D,description:u,desc:F}){for(let E of[D,u,F]){if(typeof E==="string"||E===!1)return E;YD(E,!0,this.shim)}return!1}freeze(){this.frozens.push({handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand})}unfreeze(){let D=this.frozens.pop();YD(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 I2(D,u,F,E){return new x2(D,u,F,E)}function w2(D){return typeof D==="object"&&!!D.builder&&typeof D.handler==="function"}function p3(D){return D.every((u)=>typeof u==="string")}function ou(D){return typeof D==="function"}function y3(D){return typeof D==="object"}function c3(D){return typeof D==="object"&&!Array.isArray(D)}function pD(D={},u=()=>!0){let F={};return Mu(D).forEach((E)=>{if(u(E,D[E]))F[E]=D[E]}),F}function yD(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 g3(D){return typeof D==="boolean"}function h2(D,u){let F=u.y18n.__,E={},C=[];E.failFn=function(A){C.push(A)};let B=null,$=null,z=!0;E.showHelpOnFail=function(A=!0,x){let[m,n]=typeof A==="string"?[!0,A]:[A,x];if(D.getInternalMethods().isGlobalContext())$=n;return B=n,z=m,E};let G=!1;E.fail=function(A,x){let m=D.getInternalMethods().getLoggerInstance();if(C.length)for(let n=C.length-1;n>=0;--n){let CD=C[n];if(g3(CD)){if(x)throw x;else if(A)throw Error(A)}else CD(A,x,E)}else{if(D.getExitProcess())yD(!0);if(!G){if(G=!0,z)D.showHelp("error"),m.error();if(A||x)m.error(A||x);let n=B||$;if(n){if(A||x)m.error("");m.error(n)}}if(x=x||new FD(A),D.getExitProcess())return D.exit(1);else if(D.getInternalMethods().hasParseCallback())return D.exit(1,x);else throw x}};let Z=[],Q=!1;E.usage=(P,A)=>{if(P===null)return Q=!0,Z=[],E;return Q=!1,Z.push([P,A||""]),E},E.getUsage=()=>{return Z},E.getUsageDisabled=()=>{return Q},E.getPositionalGroupName=()=>{return F("Positionals:")};let J=[];E.example=(P,A)=>{J.push([P,A||""])};let Y=[];E.command=function(A,x,m,n,CD=!1){if(m)Y=Y.map((d)=>{return d[2]=!1,d});Y.push([A,x||"",m,n,CD])},E.getCommands=()=>Y;let W={};E.describe=function(A,x){if(Array.isArray(A))A.forEach((m)=>{E.describe(m,x)});else if(typeof A==="object")Object.keys(A).forEach((m)=>{E.describe(m,A[m])});else W[A]=x},E.getDescriptions=()=>W;let H=[];E.epilog=(P)=>{H.push(P)};let O=!1,q;E.wrap=(P)=>{O=!0,q=P},E.getWrap=()=>{if(u.getEnv("YARGS_DISABLE_WRAP"))return null;if(!O)q=qD(),O=!0;return q};let j="__yargsString__:";E.deferY18nLookup=(P)=>j+P,E.help=function(){if(w)return w;k();let A=D.customScriptName?D.$0:u.path.basename(D.$0),x=D.getDemandedOptions(),m=D.getDemandedCommands(),n=D.getDeprecatedOptions(),CD=D.getGroups(),d=D.getOptions(),$D=[];$D=$D.concat(Object.keys(W)),$D=$D.concat(Object.keys(x)),$D=$D.concat(Object.keys(m)),$D=$D.concat(Object.keys(d.default)),$D=$D.filter(e),$D=Object.keys($D.reduce((h,t)=>{if(t!=="_")h[t]=!0;return h},{}));let hD=E.getWrap(),l=u.cliui({width:hD,wrap:!!hD});if(!Q){if(Z.length)Z.forEach((h)=>{if(l.div({text:`${h[0].replace(/\$0/g,A)}`}),h[1])l.div({text:`${h[1]}`,padding:[1,0,0,0]})}),l.div();else if(Y.length){let h=null;if(m._)h=`${A} <${F("command")}>
15
+ `;else h=`${A} [${F("command")}]
16
+ `;l.div(`${h}`)}}if(Y.length>1||Y.length===1&&!Y[0][2]){l.div(F("Commands:"));let h=D.getInternalMethods().getContext(),t=h.commands.length?`${h.commands.join(" ")} `:"";if(D.getInternalMethods().getParserConfiguration()["sort-commands"]===!0)Y=Y.sort((g,QD)=>g[0].localeCompare(QD[0]));let zD=A?`${A} `:"";Y.forEach((g)=>{let QD=`${zD}${t}${g[0].replace(/^\$0 ?/,"")}`;l.span({text:QD,padding:[0,2,0,2],width:N(Y,hD,`${A}${t}`)+4},{text:g[1]});let uD=[];if(g[2])uD.push(`[${F("default")}]`);if(g[3]&&g[3].length)uD.push(`[${F("aliases:")} ${g[3].join(", ")}]`);if(g[4])if(typeof g[4]==="string")uD.push(`[${F("deprecated: %s",g[4])}]`);else uD.push(`[${F("deprecated")}]`);if(uD.length)l.div({text:uD.join(" "),padding:[0,0,0,2],align:"right"});else l.div()}),l.div()}let ID=(Object.keys(d.alias)||[]).concat(Object.keys(D.parsed.newAliases)||[]);$D=$D.filter((h)=>!D.parsed.newAliases[h]&&ID.every((t)=>(d.alias[t]||[]).indexOf(h)===-1));let Lu=F("Options:");if(!CD[Lu])CD[Lu]=[];c($D,d.alias,CD,Lu);let f=(h)=>/^--/.test(su(h)),Hu=Object.keys(CD).filter((h)=>CD[h].length>0).map((h)=>{let t=CD[h].filter(e).map((zD)=>{if(ID.includes(zD))return zD;for(let g=0,QD;(QD=ID[g])!==void 0;g++)if((d.alias[QD]||[]).includes(zD))return QD;return zD});return{groupName:h,normalizedKeys:t}}).filter(({normalizedKeys:h})=>h.length>0).map(({groupName:h,normalizedKeys:t})=>{let zD=t.reduce((g,QD)=>{return g[QD]=[QD].concat(d.alias[QD]||[]).map((uD)=>{if(h===E.getPositionalGroupName())return uD;else return(/^[0-9]$/.test(uD)?d.boolean.includes(QD)?"-":"--":uD.length>1?"--":"-")+uD}).sort((uD,GD)=>f(uD)===f(GD)?0:f(uD)?1:-1).join(", "),g},{});return{groupName:h,normalizedKeys:t,switches:zD}});if(Hu.filter(({groupName:h})=>h!==E.getPositionalGroupName()).some(({normalizedKeys:h,switches:t})=>!h.every((zD)=>f(t[zD]))))Hu.filter(({groupName:h})=>h!==E.getPositionalGroupName()).forEach(({normalizedKeys:h,switches:t})=>{h.forEach((zD)=>{if(f(t[zD]))t[zD]=k3(t[zD],4)})});if(Hu.forEach(({groupName:h,normalizedKeys:t,switches:zD})=>{l.div(h),t.forEach((g)=>{let QD=zD[g],uD=W[g]||"",GD=null;if(uD.includes(j))uD=F(uD.substring(j.length));if(d.boolean.includes(g))GD=`[${F("boolean")}]`;if(d.count.includes(g))GD=`[${F("count")}]`;if(d.string.includes(g))GD=`[${F("string")}]`;if(d.normalize.includes(g))GD=`[${F("string")}]`;if(d.array.includes(g))GD=`[${F("array")}]`;if(d.number.includes(g))GD=`[${F("number")}]`;let AF=(K)=>typeof K==="string"?`[${F("deprecated: %s",K)}]`:`[${F("deprecated")}]`,M=[g in n?AF(n[g]):null,GD,g in x?`[${F("required")}]`:null,d.choices&&d.choices[g]?`[${F("choices:")} ${E.stringifiedValues(d.choices[g])}]`:null,s(d.default[g],d.defaultDescription[g])].filter(Boolean).join(" ");l.span({text:su(QD),padding:[0,2,0,2+f2(QD)],width:N(zD,hD)+4},uD);let U=D.getInternalMethods().getUsageConfiguration()["hide-types"]===!0;if(M&&!U)l.div({text:M,padding:[0,0,0,2],align:"right"});else l.div()}),l.div()}),J.length)l.div(F("Examples:")),J.forEach((h)=>{h[0]=h[0].replace(/\$0/g,A)}),J.forEach((h)=>{if(h[1]==="")l.div({text:h[0],padding:[0,2,0,2]});else l.div({text:h[0],padding:[0,2,0,2],width:N(J,hD)+4},{text:h[1]})}),l.div();if(H.length>0){let h=H.map((t)=>t.replace(/\$0/g,A)).join(`
17
17
  `);l.div(`${h}
18
- `)}return l.toString().replace(/\s*$/,"")};function f(L,K,P){let p=0;if(!Array.isArray(L))L=Object.values(L).map((k)=>[k]);if(L.forEach((k)=>{p=Math.max(u.stringWidth(P?`${P} ${mu(k[0])}`:mu(k[0]))+C2(k[0]),p)}),K)p=Math.min(p,parseInt((K*0.5).toString(),10));return p}function d(){let L=D.getDemandedOptions(),K=D.getOptions();(Object.keys(K.alias)||[]).forEach((P)=>{K.alias[P].forEach((p)=>{if(Y[p])E.describe(P,Y[p]);if(p in L)D.demandOption(P,L[p]);if(K.boolean.includes(p))D.boolean(P);if(K.count.includes(p))D.count(P);if(K.string.includes(p))D.string(P);if(K.normalize.includes(p))D.normalize(P);if(K.array.includes(p))D.array(P);if(K.number.includes(p))D.number(P)})})}let x;E.cacheHelpMessage=function(){x=this.help()},E.clearCachedHelpMessage=function(){x=void 0},E.hasCachedHelpMessage=function(){return!!x};function i(L,K,P,p){let k=[],ED=null;return Object.keys(P).forEach((n)=>{k=k.concat(P[n])}),L.forEach((n)=>{if(ED=[n].concat(K[n]),!ED.some((CD)=>k.indexOf(CD)!==-1))P[p].push(n)}),k}function a(L){return D.getOptions().hiddenOptions.indexOf(L)<0||D.parsed.argv[D.getOptions().showHiddenOpt]}E.showHelp=(L)=>{let K=D.getInternalMethods().getLoggerInstance();if(!L)L="error";(typeof L==="function"?L:K[L])(E.help())},E.functionDescription=(L)=>{return["(",L.name?u.Parser.decamelize(L.name,"-"):F("generated-value"),")"].join("")},E.stringifiedValues=function(K,P){let p="",k=P||", ",ED=[].concat(K);if(!K||!ED.length)return p;return ED.forEach((n)=>{if(p.length)p+=k;p+=JSON.stringify(n)}),p};function e(L,K){let P=`[${F("default:")} `;if(L===void 0&&!K)return null;if(K)P+=K;else switch(typeof L){case"string":P+=`"${L}"`;break;case"object":P+=JSON.stringify(L);break;default:P+=L}return`${P}]`}function RD(){if(u.process.stdColumns)return Math.min(80,u.process.stdColumns);else return 80}let g=null;E.version=(L)=>{g=L},E.showVersion=(L)=>{let K=D.getInternalMethods().getLoggerInstance();if(!L)L="error";(typeof L==="function"?L:K[L])(g)},E.reset=function(K){return B=null,Z=!1,J=[],O=!1,M=[],X=[],Q=[],Y=fD(Y,(P)=>!K[P]),E};let Mu=[];return E.freeze=function(){Mu.push({failMessage:B,failureOutput:Z,usages:J,usageDisabled:O,epilogs:M,examples:X,commands:Q,descriptions:Y})},E.unfreeze=function(K=!1){let P=Mu.pop();if(!P)return;if(K)Y={...P.descriptions,...Y},Q=[...P.commands,...Q],J=[...P.usages,...J],X=[...P.examples,...X],M=[...P.epilogs,...M];else({failMessage:B,failureOutput:Z,usages:J,usageDisabled:O,epilogs:M,examples:X,commands:Q,descriptions:Y}=P)},E}function LF(D){return typeof D==="object"}function l1(D,u){return LF(D)?{text:D.text,indentation:D.indentation+u}:{text:D,indentation:u}}function C2(D){return LF(D)?D.indentation:0}function mu(D){return LF(D)?D.text:D}var $2=`###-begin-{{app_name}}-completions-###
18
+ `)}return l.toString().replace(/\s*$/,"")};function N(P,A,x){let m=0;if(!Array.isArray(P))P=Object.values(P).map((n)=>[n]);if(P.forEach((n)=>{m=Math.max(u.stringWidth(x?`${x} ${su(n[0])}`:su(n[0]))+f2(n[0]),m)}),A)m=Math.min(m,parseInt((A*0.5).toString(),10));return m}function k(){let P=D.getDemandedOptions(),A=D.getOptions();(Object.keys(A.alias)||[]).forEach((x)=>{A.alias[x].forEach((m)=>{if(W[m])E.describe(x,W[m]);if(m in P)D.demandOption(x,P[m]);if(A.boolean.includes(m))D.boolean(x);if(A.count.includes(m))D.count(x);if(A.string.includes(m))D.string(x);if(A.normalize.includes(m))D.normalize(x);if(A.array.includes(m))D.array(x);if(A.number.includes(m))D.number(x)})})}let w;E.cacheHelpMessage=function(){w=this.help()},E.clearCachedHelpMessage=function(){w=void 0},E.hasCachedHelpMessage=function(){return!!w};function c(P,A,x,m){let n=[],CD=null;return Object.keys(x).forEach((d)=>{n=n.concat(x[d])}),P.forEach((d)=>{if(CD=[d].concat(A[d]),!CD.some(($D)=>n.indexOf($D)!==-1))x[m].push(d)}),n}function e(P){return D.getOptions().hiddenOptions.indexOf(P)<0||D.parsed.argv[D.getOptions().showHiddenOpt]}E.showHelp=(P)=>{let A=D.getInternalMethods().getLoggerInstance();if(!P)P="error";(typeof P==="function"?P:A[P])(E.help())},E.functionDescription=(P)=>{return["(",P.name?u.Parser.decamelize(P.name,"-"):F("generated-value"),")"].join("")},E.stringifiedValues=function(A,x){let m="",n=x||", ",CD=[].concat(A);if(!A||!CD.length)return m;return CD.forEach((d)=>{if(m.length)m+=n;m+=JSON.stringify(d)}),m};function s(P,A){let x=`[${F("default:")} `;if(P===void 0&&!A)return null;if(A)x+=A;else switch(typeof P){case"string":x+=`"${P}"`;break;case"object":x+=JSON.stringify(P);break;default:x+=P}return`${x}]`}function qD(){if(u.process.stdColumns)return Math.min(80,u.process.stdColumns);else return 80}let i=null;E.version=(P)=>{i=P},E.showVersion=(P)=>{let A=D.getInternalMethods().getLoggerInstance();if(!P)P="error";(typeof P==="function"?P:A[P])(i)},E.reset=function(A){return B=null,G=!1,Z=[],Q=!1,H=[],J=[],Y=[],W=pD(W,(x)=>!A[x]),E};let tD=[];return E.freeze=function(){tD.push({failMessage:B,failureOutput:G,usages:Z,usageDisabled:Q,epilogs:H,examples:J,commands:Y,descriptions:W})},E.unfreeze=function(A=!1){let x=tD.pop();if(!x)return;if(A)W={...x.descriptions,...W},Y=[...x.commands,...Y],Z=[...x.usages,...Z],J=[...x.examples,...J],H=[...x.epilogs,...H];else({failMessage:B,failureOutput:G,usages:Z,usageDisabled:Q,epilogs:H,examples:J,commands:Y,descriptions:W}=x)},E}function kF(D){return typeof D==="object"}function k3(D,u){return kF(D)?{text:D.text,indentation:D.indentation+u}:{text:D,indentation:u}}function f2(D){return kF(D)?D.indentation:0}function su(D){return kF(D)?D.text:D}var v2=`###-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
- `,z2=`#compdef {{app_name}}
47
+ `,m2=`#compdef {{app_name}}
48
48
  ###-begin-{{app_name}}-completions-###
49
49
  #
50
50
  # yargs command completion script
@@ -71,59 +71,86 @@ else
71
71
  compdef _{{app_name}}_yargs_completions {{app_name}}
72
72
  fi
73
73
  ###-end-{{app_name}}-completions-###
74
- `;class G2{constructor(D,u,F,E){var C,B,$;this.yargs=D,this.usage=u,this.command=F,this.shim=E,this.completionKey="get-yargs-completions",this.aliases=null,this.customCompletionFunction=null,this.indexAfterLastReset=0,this.zshShell=($=((C=this.shim.getEnv("SHELL"))===null||C===void 0?void 0:C.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,E){let C=this.command.getCommandHandlers();for(let $=0,z=D.length;$<z;++$)if(C[D[$]]&&C[D[$]].builder){let Z=C[D[$]].builder;if(pu(Z)){this.indexAfterLastReset=$+1;let J=this.yargs.getInternalMethods().reset();return Z(J,!0),J.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),E(null,B)}commandCompletions(D,u,F){let E=this.yargs.getInternalMethods().getContext().commands;if(!F.match(/^-/)&&E[E.length-1]!==F&&!this.previousArgHasChoices(u))this.usage.getCommands().forEach((C)=>{let B=ID(C[0]).cmd;if(u.indexOf(B)===-1)if(!this.zshShell)D.push(B);else{let $=C[1]||"";D.push(B.replace(/:/g,"\\:")+":"+$)}})}optionCompletions(D,u,F,E){if((E.match(/^-/)||E===""&&D.length===0)&&!this.previousArgHasChoices(u)){let C=this.yargs.getOptions(),B=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[];Object.keys(C.key).forEach(($)=>{let z=!!C.configuration["boolean-negation"]&&C.boolean.includes($);if(!B.includes($)&&!C.hiddenOptions.includes($)&&!this.argsContainKey(u,$,z))this.completeOptionKey($,D,E,z&&!!C.default[$])})}}choicesFromOptionsCompletions(D,u,F,E){if(this.previousArgHasChoices(u)){let C=this.getPreviousArgChoices(u);if(C&&C.length>0)D.push(...C.map((B)=>B.replace(/:/g,"\\:")))}}choicesFromPositionalsCompletions(D,u,F,E){if(E===""&&D.length>0&&this.previousArgHasChoices(u))return;let C=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[],B=Math.max(this.indexAfterLastReset,this.yargs.getInternalMethods().getContext().commands.length+1),$=C[F._.length-B-1];if(!$)return;let z=this.yargs.getOptions().choices[$]||[];for(let Z of z)if(Z.startsWith(E))D.push(Z.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 E=u.replace(/^-+/,""),C=this.yargs.getOptions(),B=[E,...this.yargs.getAliases()[E]||[]],$;for(let z of B)if(Object.prototype.hasOwnProperty.call(C.key,z)&&Array.isArray(C.choices[z])){$=C.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 E=(C)=>D.indexOf((/^[^0-9]$/.test(C)?"-":"--")+C)!==-1;if(E(u))return!0;if(F&&E(`no-${u}`))return!0;if(this.aliases){for(let C of this.aliases[u])if(E(C))return!0}return!1}completeOptionKey(D,u,F,E){var C,B,$,z;let Z=D;if(this.zshShell){let Q=this.usage.getDescriptions(),Y=(B=(C=this===null||this===void 0?void 0:this.aliases)===null||C===void 0?void 0:C[D])===null||B===void 0?void 0:B.find((_)=>{let S=Q[_];return typeof S==="string"&&S.length>0}),M=Y?Q[Y]:void 0,H=(z=($=Q[D])!==null&&$!==void 0?$:M)!==null&&z!==void 0?z:"";Z=`${D.replace(/:/g,"\\:")}:${H.replace("__yargsString__:","").replace(/(\r\n|\n|\r)/gm," ")}`}let J=(Q)=>/^--/.test(Q),O=(Q)=>/^[^0-9]$/.test(Q),X=!J(F)&&O(D)?"-":"--";if(u.push(X+Z),E)u.push(X+"no-"+Z)}customCompletion(D,u,F,E){if(QD(this.customCompletionFunction,null,this.shim),s1(this.customCompletionFunction)){let C=this.customCompletionFunction(F,u);if(o(C))return C.then((B)=>{this.shim.process.nextTick(()=>{E(null,B)})}).catch((B)=>{this.shim.process.nextTick(()=>{E(B,void 0)})});return E(null,C)}else if(r1(this.customCompletionFunction))return this.customCompletionFunction(F,u,(C=E)=>this.defaultCompletion(D,u,F,C),(C)=>{E(null,C)});else return this.customCompletionFunction(F,u,(C)=>{E(null,C)})}getCompletion(D,u){let F=D.length?D[D.length-1]:"",E=this.yargs.parse(D,!0),C=this.customCompletionFunction?(B)=>this.customCompletion(D,B,F,u):(B)=>this.defaultCompletion(D,B,F,u);return o(E)?E.then(C):C(E)}generateCompletionScript(D,u){let F=this.zshShell?z2:$2,E=this.shim.path.basename(D);if(D.match(/\.js$/))D=`./${D}`;return F=F.replace(/{{app_name}}/g,E),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 Z2(D,u,F,E){return new G2(D,u,F,E)}function s1(D){return D.length<3}function r1(D){return D.length>3}function X2(D,u){if(D.length===0)return u.length;if(u.length===0)return D.length;let F=[],E;for(E=0;E<=u.length;E++)F[E]=[E];let C;for(C=0;C<=D.length;C++)F[0][C]=C;for(E=1;E<=u.length;E++)for(C=1;C<=D.length;C++)if(u.charAt(E-1)===D.charAt(C-1))F[E][C]=F[E-1][C-1];else if(E>1&&C>1&&u.charAt(E-2)===D.charAt(C-1)&&u.charAt(E-1)===D.charAt(C-2))F[E][C]=F[E-2][C-2]+1;else F[E][C]=Math.min(F[E-1][C-1]+1,Math.min(F[E][C-1]+1,F[E-1][C]+1));return F[u.length][D.length]}var J2=["$0","--","_"];function Q2(D,u,F){let E=F.y18n.__,C=F.y18n.__n,B={};B.nonOptionCount=function(X){let Q=D.getDemandedCommands(),M=X._.length+(X["--"]?X["--"].length:0)-D.getInternalMethods().getContext().commands.length;if(Q._&&(M<Q._.min||M>Q._.max)){if(M<Q._.min)if(Q._.minMsg!==void 0)u.fail(Q._.minMsg?Q._.minMsg.replace(/\$0/g,M.toString()).replace(/\$1/,Q._.min.toString()):null);else u.fail(C("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",M,M.toString(),Q._.min.toString()));else if(M>Q._.max)if(Q._.maxMsg!==void 0)u.fail(Q._.maxMsg?Q._.maxMsg.replace(/\$0/g,M.toString()).replace(/\$1/,Q._.max.toString()):null);else u.fail(C("Too many non-option arguments: got %s, maximum of %s","Too many non-option arguments: got %s, maximum of %s",M,M.toString(),Q._.max.toString()))}},B.positionalCount=function(X,Q){if(Q<X)u.fail(C("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",Q,Q+"",X+""))},B.requiredArguments=function(X,Q){let Y=null;for(let M of Object.keys(Q))if(!Object.prototype.hasOwnProperty.call(X,M)||typeof X[M]>"u")Y=Y||{},Y[M]=Q[M];if(Y){let M=[];for(let _ of Object.keys(Y)){let S=Y[_];if(S&&M.indexOf(S)<0)M.push(S)}let H=M.length?`
75
- ${M.join(`
76
- `)}`:"";u.fail(C("Missing required argument: %s","Missing required arguments: %s",Object.keys(Y).length,Object.keys(Y).join(", ")+H))}},B.unknownArguments=function(X,Q,Y,M,H=!0){var _;let S=D.getInternalMethods().getCommandInstance().getCommands(),f=[],d=D.getInternalMethods().getContext();if(Object.keys(X).forEach((x)=>{if(!J2.includes(x)&&!Object.prototype.hasOwnProperty.call(Y,x)&&!Object.prototype.hasOwnProperty.call(D.getInternalMethods().getParseContext(),x)&&!B.isValidAndSomeAliasIsNotNew(x,Q))f.push(x)}),H&&(d.commands.length>0||S.length>0||M))X._.slice(d.commands.length).forEach((x)=>{if(!S.includes(""+x))f.push(""+x)});if(H){let i=((_=D.getDemandedCommands()._)===null||_===void 0?void 0:_.max)||0,a=d.commands.length+i;if(a<X._.length)X._.slice(a).forEach((e)=>{if(e=String(e),!d.commands.includes(e)&&!f.includes(e))f.push(e)})}if(f.length)u.fail(C("Unknown argument: %s","Unknown arguments: %s",f.length,f.map((x)=>x.trim()?x:`"${x}"`).join(", ")))},B.unknownCommands=function(X){let Q=D.getInternalMethods().getCommandInstance().getCommands(),Y=[],M=D.getInternalMethods().getContext();if(M.commands.length>0||Q.length>0)X._.slice(M.commands.length).forEach((H)=>{if(!Q.includes(""+H))Y.push(""+H)});if(Y.length>0)return u.fail(C("Unknown command: %s","Unknown commands: %s",Y.length,Y.join(", "))),!0;else return!1},B.isValidAndSomeAliasIsNotNew=function(X,Q){if(!Object.prototype.hasOwnProperty.call(Q,X))return!1;let Y=D.parsed.newAliases;return[X,...Q[X]].some((M)=>!Object.prototype.hasOwnProperty.call(Y,M)||!Y[X])},B.limitedChoices=function(X){let Q=D.getOptions(),Y={};if(!Object.keys(Q.choices).length)return;Object.keys(X).forEach((_)=>{if(J2.indexOf(_)===-1&&Object.prototype.hasOwnProperty.call(Q.choices,_))[].concat(X[_]).forEach((S)=>{if(Q.choices[_].indexOf(S)===-1&&S!==void 0)Y[_]=(Y[_]||[]).concat(S)})});let M=Object.keys(Y);if(!M.length)return;let H=E("Invalid values:");M.forEach((_)=>{H+=`
77
- ${E("Argument: %s, Given: %s, Choices: %s",_,u.stringifiedValues(Y[_]),u.stringifiedValues(Q.choices[_]))}`}),u.fail(H)};let $={};B.implies=function(X,Q){if(N("<string|object> [array|number|string]",[X,Q],arguments.length),typeof X==="object")Object.keys(X).forEach((Y)=>{B.implies(Y,X[Y])});else{if(D.global(X),!$[X])$[X]=[];if(Array.isArray(Q))Q.forEach((Y)=>B.implies(X,Y));else QD(Q,void 0,F),$[X].push(Q)}},B.getImplied=function(){return $};function z(O,X){let Q=Number(X);if(X=isNaN(Q)?X:Q,typeof X==="number")X=O._.length>=X;else if(X.match(/^--no-.+/))X=X.match(/^--no-(.+)/)[1],X=!Object.prototype.hasOwnProperty.call(O,X);else X=Object.prototype.hasOwnProperty.call(O,X);return X}B.implications=function(X){let Q=[];if(Object.keys($).forEach((Y)=>{let M=Y;($[Y]||[]).forEach((H)=>{let _=M,S=H;if(_=z(X,_),H=z(X,H),_&&!H)Q.push(` ${M} -> ${S}`)})}),Q.length){let Y=`${E("Implications failed:")}
78
- `;Q.forEach((M)=>{Y+=M}),u.fail(Y)}};let Z={};B.conflicts=function(X,Q){if(N("<string|object> [array|string]",[X,Q],arguments.length),typeof X==="object")Object.keys(X).forEach((Y)=>{B.conflicts(Y,X[Y])});else{if(D.global(X),!Z[X])Z[X]=[];if(Array.isArray(Q))Q.forEach((Y)=>B.conflicts(X,Y));else Z[X].push(Q)}},B.getConflicting=()=>Z,B.conflicting=function(X){if(Object.keys(X).forEach((Q)=>{if(Z[Q])Z[Q].forEach((Y)=>{if(Y&&X[Q]!==void 0&&X[Y]!==void 0)u.fail(E("Arguments %s and %s are mutually exclusive",Q,Y))})}),D.getInternalMethods().getParserConfiguration()["strip-dashed"])Object.keys(Z).forEach((Q)=>{Z[Q].forEach((Y)=>{if(Y&&X[F.Parser.camelCase(Q)]!==void 0&&X[F.Parser.camelCase(Y)]!==void 0)u.fail(E("Arguments %s and %s are mutually exclusive",Q,Y))})})},B.recommendCommands=function(X,Q){Q=Q.sort((_,S)=>S.length-_.length);let M=null,H=1/0;for(let _=0,S;(S=Q[_])!==void 0;_++){let f=X2(X,S);if(f<=3&&f<H)H=f,M=S}if(M)u.fail(E("Did you mean %s?",M))},B.reset=function(X){return $=fD($,(Q)=>!X[Q]),Z=fD(Z,(Q)=>!X[Q]),B};let J=[];return B.freeze=function(){J.push({implied:$,conflicting:Z})},B.unfreeze=function(){let X=J.pop();QD(X,void 0,F),{implied:$,conflicting:Z}=X},B}var SF=[],qu;function Uu(D,u,F,E){qu=E;let C={};if(Object.prototype.hasOwnProperty.call(D,"extends")){if(typeof D.extends!=="string")return C;let B=/\.json|\..*rc$/.test(D.extends),$=null;if(!B)try{$=import.meta.resolve(D.extends)}catch(z){return D}else $=e1(u,D.extends);a1($),SF.push($),C=B?JSON.parse(qu.readFileSync($,"utf8")):E.require(D.extends),delete D.extends,C=Uu(C,qu.path.dirname($),F,qu)}return SF=[],F?O2(C,D):Object.assign({},C,D)}function a1(D){if(SF.indexOf(D)>-1)throw new uD(`Circular extended configurations: '${D}'.`)}function e1(D,u){return qu.path.resolve(D,u)}function O2(D,u){let F={};function E(C){return C&&typeof C==="object"&&!Array.isArray(C)}Object.assign(F,D);for(let C of Object.keys(u))if(E(u[C])&&E(F[C]))F[C]=O2(D[C],u[C]);else F[C]=u[C];return F}var R=function(D,u,F,E,C){if(E==="m")throw TypeError("Private method is not writable");if(E==="a"&&!C)throw TypeError("Private accessor was defined without a setter");if(typeof u==="function"?D!==u||!C:!u.has(D))throw TypeError("Cannot write private member to an object whose class did not declare it");return E==="a"?C.call(D,F):C?C.value=F:u.set(D,F),F},G=function(D,u,F,E){if(F==="a"&&!E)throw TypeError("Private accessor was defined without a getter");if(typeof u==="function"?D!==u||!E:!u.has(D))throw TypeError("Cannot read private member from an object whose class did not declare it");return F==="m"?E:F==="a"?E.call(D):E?E.value:u.get(D)},FD,nD,_u,OD,MD,cu,bD,kD,yu,UD,iu,_D,AD,HD,jD,nu,dD,ZD,w,ku,du,VD,gD,Xu,tD,hD,gu,v,lD,oD,sD,m,tu,LD,r;function f2(D){return(u=[],F=D.process.cwd(),E)=>{let C=new x2(u,F,E,D);return Object.defineProperty(C,"argv",{get:()=>{return C.parse()},enumerable:!0}),C.help(),C.version(),C}}var Y2=Symbol("copyDoubleDash"),W2=Symbol("copyDoubleDash"),PF=Symbol("deleteFromParserHintObject"),M2=Symbol("emitWarning"),H2=Symbol("freeze"),V2=Symbol("getDollarZero"),rD=Symbol("getParserConfiguration"),q2=Symbol("getUsageConfiguration"),wF=Symbol("guessLocale"),U2=Symbol("guessVersion"),_2=Symbol("parsePositionalNumbers"),IF=Symbol("pkgUp"),vD=Symbol("populateParserHintArray"),Ju=Symbol("populateParserHintSingleValueDictionary"),fF=Symbol("populateParserHintArrayDictionary"),xF=Symbol("populateParserHintDictionary"),bF=Symbol("sanitizeKey"),hF=Symbol("setKey"),vF=Symbol("unfreeze"),j2=Symbol("validateAsync"),K2=Symbol("getCommandInstance"),T2=Symbol("getContext"),N2=Symbol("getHasOutput"),R2=Symbol("getLoggerInstance"),A2=Symbol("getParseContext"),L2=Symbol("getUsageInstance"),S2=Symbol("getValidationInstance"),lu=Symbol("hasParseCallback"),P2=Symbol("isGlobalContext"),aD=Symbol("postProcess"),w2=Symbol("rebase"),pF=Symbol("reset"),ju=Symbol("runYargsParserAndExecuteCommands"),mF=Symbol("runValidation"),I2=Symbol("setHasOutput"),eD=Symbol("kTrackManuallySetKeys"),D3="en_US";class x2{constructor(D=[],u,F,E){this.customScriptName=!1,this.parsed=!1,FD.set(this,void 0),nD.set(this,void 0),_u.set(this,{commands:[],fullCommands:[]}),OD.set(this,null),MD.set(this,null),cu.set(this,"show-hidden"),bD.set(this,null),kD.set(this,!0),yu.set(this,{}),UD.set(this,!0),iu.set(this,[]),_D.set(this,void 0),AD.set(this,{}),HD.set(this,!1),jD.set(this,null),nu.set(this,!0),dD.set(this,void 0),ZD.set(this,""),w.set(this,void 0),ku.set(this,void 0),du.set(this,{}),VD.set(this,null),gD.set(this,null),Xu.set(this,{}),tD.set(this,{}),hD.set(this,void 0),gu.set(this,!1),v.set(this,void 0),lD.set(this,!1),oD.set(this,!1),sD.set(this,!1),m.set(this,void 0),tu.set(this,{}),LD.set(this,null),r.set(this,void 0),R(this,v,E,"f"),R(this,hD,D,"f"),R(this,nD,u,"f"),R(this,ku,F,"f"),R(this,_D,new AF(this),"f"),this.$0=this[V2](),this[pF](),R(this,FD,G(this,FD,"f"),"f"),R(this,m,G(this,m,"f"),"f"),R(this,r,G(this,r,"f"),"f"),R(this,w,G(this,w,"f"),"f"),G(this,w,"f").showHiddenOpt=G(this,cu,"f"),R(this,dD,this[W2](),"f"),G(this,v,"f").y18n.setLocale(D3)}addHelpOpt(D,u){if(N("[string|boolean] [string]",[D,u],arguments.length),G(this,jD,"f"))this[PF](G(this,jD,"f")),R(this,jD,null,"f");if(D===!1&&u===void 0)return this;return R(this,jD,typeof D==="string"?D:"help","f"),this.boolean(G(this,jD,"f")),this.describe(G(this,jD,"f"),u||G(this,m,"f").deferY18nLookup("Show help")),this}help(D,u){return this.addHelpOpt(D,u)}addShowHiddenOpt(D,u){if(N("[string|boolean] [string]",[D,u],arguments.length),D===!1&&u===void 0)return this;let F=typeof D==="string"?D:G(this,cu,"f");return this.boolean(F),this.describe(F,u||G(this,m,"f").deferY18nLookup("Show hidden options")),G(this,w,"f").showHiddenOpt=F,this}showHidden(D,u){return this.addShowHiddenOpt(D,u)}alias(D,u){return N("<object|string|array> [string|array]",[D,u],arguments.length),this[fF](this.alias.bind(this),"alias",D,u),this}array(D){return N("<array|string>",[D],arguments.length),this[vD]("array",D),this[eD](D),this}boolean(D){return N("<array|string>",[D],arguments.length),this[vD]("boolean",D),this[eD](D),this}check(D,u){return N("<function> [boolean]",[D,u],arguments.length),this.middleware((F,E)=>{return iD(()=>{return D(F,E.getOptions())},(C)=>{if(!C)G(this,m,"f").fail(G(this,v,"f").y18n.__("Argument check failed: %s",D.toString()));else if(typeof C==="string"||C instanceof Error)G(this,m,"f").fail(C.toString(),C);return F},(C)=>{return G(this,m,"f").fail(C.message?C.message:C.toString(),C),F})},!1,u),this}choices(D,u){return N("<object|string|array> [string|array]",[D,u],arguments.length),this[fF](this.choices.bind(this),"choices",D,u),this}coerce(D,u){if(N("<object|string|array> [function]",[D,u],arguments.length),Array.isArray(D)){if(!u)throw new uD("coerce callback must be provided");for(let E of D)this.coerce(E,u);return this}else if(typeof D==="object"){for(let E of Object.keys(D))this.coerce(E,D[E]);return this}if(!u)throw new uD("coerce callback must be provided");let F=D;return G(this,w,"f").key[F]=!0,G(this,_D,"f").addCoerceMiddleware((E,C)=>{var B;let $=(B=C.getAliases()[F])!==null&&B!==void 0?B:[],z=[F,...$].filter((Z)=>Object.prototype.hasOwnProperty.call(E,Z));if(z.length===0)return E;return iD(()=>{return u(E[z[0]])},(Z)=>{return z.forEach((J)=>{E[J]=Z}),E},(Z)=>{throw new uD(Z.message)})},F),this}conflicts(D,u){return N("<string|object> [string|array]",[D,u],arguments.length),G(this,r,"f").conflicts(D,u),this}config(D="config",u,F){if(N("[object|string] [string|function] [function]",[D,u,F],arguments.length),typeof D==="object"&&!Array.isArray(D))return D=Uu(D,G(this,nD,"f"),this[rD]()["deep-merge-config"]||!1,G(this,v,"f")),G(this,w,"f").configObjects=(G(this,w,"f").configObjects||[]).concat(D),this;if(typeof u==="function")F=u,u=void 0;return this.describe(D,u||G(this,m,"f").deferY18nLookup("Path to JSON config file")),(Array.isArray(D)?D:[D]).forEach((E)=>{G(this,w,"f").config[E]=F||!0}),this}completion(D,u,F){if(N("[string] [string|boolean|function] [function]",[D,u,F],arguments.length),typeof u==="function")F=u,u=void 0;if(R(this,MD,D||G(this,MD,"f")||"completion","f"),!u&&u!==!1)u="generate completion script";if(this.command(G(this,MD,"f"),u),F)G(this,OD,"f").registerFunction(F);return this}command(D,u,F,E,C,B){return N("<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]",[D,u,F,E,C,B],arguments.length),G(this,FD,"f").addHandler(D,u,F,E,C,B),this}commands(D,u,F,E,C,B){return this.command(D,u,F,E,C,B)}commandDir(D,u){N("<string> [object]",[D,u],arguments.length);let F=G(this,ku,"f")||G(this,v,"f").require;return G(this,FD,"f").addDirectory(D,F,G(this,v,"f").getCallerFile(),u),this}count(D){return N("<array|string>",[D],arguments.length),this[vD]("count",D),this[eD](D),this}default(D,u,F){if(N("<object|string|array> [*] [string]",[D,u,F],arguments.length),F)RF(D,G(this,v,"f")),G(this,w,"f").defaultDescription[D]=F;if(typeof u==="function"){if(RF(D,G(this,v,"f")),!G(this,w,"f").defaultDescription[D])G(this,w,"f").defaultDescription[D]=G(this,m,"f").functionDescription(u);u=u.call()}return this[Ju](this.default.bind(this),"default",D,u),this}defaults(D,u,F){return this.default(D,u,F)}demandCommand(D=1,u,F,E){if(N("[number] [number|string] [string|null|undefined] [string|null|undefined]",[D,u,F,E],arguments.length),typeof u!=="number")F=u,u=1/0;return this.global("_",!1),G(this,w,"f").demandedCommands._={min:D,max:u,minMsg:F,maxMsg:E},this}demand(D,u,F){if(Array.isArray(u))u.forEach((E)=>{QD(F,!0,G(this,v,"f")),this.demandOption(E,F)}),u=1/0;else if(typeof u!=="number")F=u,u=1/0;if(typeof D==="number")QD(F,!0,G(this,v,"f")),this.demandCommand(D,u,F,F);else if(Array.isArray(D))D.forEach((E)=>{QD(F,!0,G(this,v,"f")),this.demandOption(E,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 N("<object|string|array> [string]",[D,u],arguments.length),this[Ju](this.demandOption.bind(this),"demandedOptions",D,u),this}deprecateOption(D,u){return N("<string> [string|boolean]",[D,u],arguments.length),G(this,w,"f").deprecatedOptions[D]=u,this}describe(D,u){return N("<object|string|array> [string]",[D,u],arguments.length),this[hF](D,!0),G(this,m,"f").describe(D,u),this}detectLocale(D){return N("<boolean>",[D],arguments.length),R(this,kD,D,"f"),this}env(D){if(N("[string|boolean]",[D],arguments.length),D===!1)delete G(this,w,"f").envPrefix;else G(this,w,"f").envPrefix=D||"";return this}epilogue(D){return N("<string>",[D],arguments.length),G(this,m,"f").epilog(D),this}epilog(D){return this.epilogue(D)}example(D,u){if(N("<string|array> [string]",[D,u],arguments.length),Array.isArray(D))D.forEach((F)=>this.example(...F));else G(this,m,"f").example(D,u);return this}exit(D,u){if(R(this,HD,!0,"f"),R(this,bD,u,"f"),G(this,UD,"f"))G(this,v,"f").process.exit(D)}exitProcess(D=!0){return N("[boolean]",[D],arguments.length),R(this,UD,D,"f"),this}fail(D){if(N("<function|boolean>",[D],arguments.length),typeof D==="boolean"&&D!==!1)throw new uD("Invalid first argument. Expected function or boolean 'false'");return G(this,m,"f").failFn(D),this}getAliases(){return this.parsed?this.parsed.aliases:{}}async getCompletion(D,u){if(N("<array> [function]",[D,u],arguments.length),!u)return new Promise((F,E)=>{G(this,OD,"f").getCompletion(D,(C,B)=>{if(C)E(C);else F(B)})});else return G(this,OD,"f").getCompletion(D,u)}getDemandedOptions(){return N([],0),G(this,w,"f").demandedOptions}getDemandedCommands(){return N([],0),G(this,w,"f").demandedCommands}getDeprecatedOptions(){return N([],0),G(this,w,"f").deprecatedOptions}getDetectLocale(){return G(this,kD,"f")}getExitProcess(){return G(this,UD,"f")}getGroups(){return Object.assign({},G(this,AD,"f"),G(this,tD,"f"))}getHelp(){if(R(this,HD,!0,"f"),!G(this,m,"f").hasCachedHelpMessage()){if(!this.parsed){let u=this[ju](G(this,hD,"f"),void 0,void 0,0,!0);if(o(u))return u.then(()=>{return G(this,m,"f").help()})}let D=G(this,FD,"f").runDefaultBuilderOn(this);if(o(D))return D.then(()=>{return G(this,m,"f").help()})}return Promise.resolve(G(this,m,"f").help())}getOptions(){return G(this,w,"f")}getStrict(){return G(this,lD,"f")}getStrictCommands(){return G(this,oD,"f")}getStrictOptions(){return G(this,sD,"f")}global(D,u){if(N("<string|array> [boolean]",[D,u],arguments.length),D=[].concat(D),u!==!1)G(this,w,"f").local=G(this,w,"f").local.filter((F)=>D.indexOf(F)===-1);else D.forEach((F)=>{if(!G(this,w,"f").local.includes(F))G(this,w,"f").local.push(F)});return this}group(D,u){N("<string|array> <string>",[D,u],arguments.length);let F=G(this,tD,"f")[u]||G(this,AD,"f")[u];if(G(this,tD,"f")[u])delete G(this,tD,"f")[u];let E={};return G(this,AD,"f")[u]=(F||[]).concat(D).filter((C)=>{if(E[C])return!1;return E[C]=!0}),this}hide(D){return N("<string>",[D],arguments.length),G(this,w,"f").hiddenOptions.push(D),this}implies(D,u){return N("<string|object> [number|string|array]",[D,u],arguments.length),G(this,r,"f").implies(D,u),this}locale(D){if(N("[string]",[D],arguments.length),D===void 0)return this[wF](),G(this,v,"f").y18n.getLocale();return R(this,kD,!1,"f"),G(this,v,"f").y18n.setLocale(D),this}middleware(D,u,F){return G(this,_D,"f").addMiddleware(D,!!u,F)}nargs(D,u){return N("<string|object|array> [number]",[D,u],arguments.length),this[Ju](this.nargs.bind(this),"narg",D,u),this}normalize(D){return N("<array|string>",[D],arguments.length),this[vD]("normalize",D),this}number(D){return N("<array|string>",[D],arguments.length),this[vD]("number",D),this[eD](D),this}option(D,u){if(N("<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[eD](D),G(this,LD,"f")&&(D==="version"||(u===null||u===void 0?void 0:u.alias)==="version"))this[M2](['"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(G(this,w,"f").key[D]=!0,u.alias)this.alias(D,u.alias);let F=u.deprecate||u.deprecated;if(F)this.deprecateOption(D,F);let E=u.demand||u.required||u.require;if(E)this.demand(D,E);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)G(this,w,"f").defaultDescription[D]=u.defaultDescription;if(u.skipValidation)this.skipValidation(D);let C=u.describe||u.description||u.desc,B=G(this,m,"f").getDescriptions();if(!Object.prototype.hasOwnProperty.call(B,D)||typeof C==="string")this.describe(D,C);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(N("[string|array] [function|boolean|object] [function]",[D,u,F],arguments.length),this[H2](),typeof D>"u")D=G(this,hD,"f");if(typeof u==="object")R(this,gD,u,"f"),u=F;if(typeof u==="function")R(this,VD,u,"f"),u=!1;if(!u)R(this,hD,D,"f");if(G(this,VD,"f"))R(this,UD,!1,"f");let E=this[ju](D,!!u),C=this.parsed;if(G(this,OD,"f").setParsed(this.parsed),o(E))return E.then((B)=>{if(G(this,VD,"f"))G(this,VD,"f").call(this,G(this,bD,"f"),B,G(this,ZD,"f"));return B}).catch((B)=>{if(G(this,VD,"f"))G(this,VD,"f")(B,this.parsed.argv,G(this,ZD,"f"));throw B}).finally(()=>{this[vF](),this.parsed=C});else{if(G(this,VD,"f"))G(this,VD,"f").call(this,G(this,bD,"f"),E,G(this,ZD,"f"));this[vF](),this.parsed=C}return E}parseAsync(D,u,F){let E=this.parse(D,u,F);return!o(E)?Promise.resolve(E):E}parseSync(D,u,F){let E=this.parse(D,u,F);if(o(E))throw new uD(".parseSync() must not be used with asynchronous builders, handlers, or middleware");return E}parserConfiguration(D){return N("<object>",[D],arguments.length),R(this,du,D,"f"),this}pkgConf(D,u){N("<string> [string]",[D,u],arguments.length);let F=null,E=this[IF](u||G(this,nD,"f"));if(E[D]&&typeof E[D]==="object")F=Uu(E[D],u||G(this,nD,"f"),this[rD]()["deep-merge-config"]||!1,G(this,v,"f")),G(this,w,"f").configObjects=(G(this,w,"f").configObjects||[]).concat(F);return this}positional(D,u){N("<string> <object>",[D,u],arguments.length);let F=["default","defaultDescription","implies","normalize","choices","conflicts","coerce","type","describe","desc","description","alias"];u=fD(u,(B,$)=>{if(B==="type"&&!["string","number","boolean"].includes($))return!1;return F.includes(B)});let E=G(this,_u,"f").fullCommands[G(this,_u,"f").fullCommands.length-1],C=E?G(this,FD,"f").cmdToParseOptions(E):{array:[],alias:{},default:{},demand:{}};return Gu(C).forEach((B)=>{let $=C[B];if(Array.isArray($)){if($.indexOf(D)!==-1)u[B]=!0}else if($[D]&&!(B in u))u[B]=$[D]}),this.group(D,G(this,m,"f").getPositionalGroupName()),this.option(D,u)}recommendCommands(D=!0){return N("[boolean]",[D],arguments.length),R(this,gu,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(N("<array|string|object> [number]",[D],arguments.length),typeof D==="string"&&G(this,w,"f").narg[D])return this;else this[Ju](this.requiresArg.bind(this),"narg",D,NaN);return this}showCompletionScript(D,u){return N("[string] [string]",[D,u],arguments.length),D=D||this.$0,G(this,dD,"f").log(G(this,OD,"f").generateCompletionScript(D,u||G(this,MD,"f")||"completion")),this}showHelp(D){if(N("[string|function]",[D],arguments.length),R(this,HD,!0,"f"),!G(this,m,"f").hasCachedHelpMessage()){if(!this.parsed){let F=this[ju](G(this,hD,"f"),void 0,void 0,0,!0);if(o(F))return F.then(()=>{G(this,m,"f").showHelp(D)}),this}let u=G(this,FD,"f").runDefaultBuilderOn(this);if(o(u))return u.then(()=>{G(this,m,"f").showHelp(D)}),this}return G(this,m,"f").showHelp(D),this}scriptName(D){return this.customScriptName=!0,this.$0=D,this}showHelpOnFail(D,u){return N("[boolean|string] [string]",[D,u],arguments.length),G(this,m,"f").showHelpOnFail(D,u),this}showVersion(D){return N("[string|function]",[D],arguments.length),G(this,m,"f").showVersion(D),this}skipValidation(D){return N("<array|string>",[D],arguments.length),this[vD]("skipValidation",D),this}strict(D){return N("[boolean]",[D],arguments.length),R(this,lD,D!==!1,"f"),this}strictCommands(D){return N("[boolean]",[D],arguments.length),R(this,oD,D!==!1,"f"),this}strictOptions(D){return N("[boolean]",[D],arguments.length),R(this,sD,D!==!1,"f"),this}string(D){return N("<array|string>",[D],arguments.length),this[vD]("string",D),this[eD](D),this}terminalWidth(){return N([],0),G(this,v,"f").process.stdColumns}updateLocale(D){return this.updateStrings(D)}updateStrings(D){return N("<object>",[D],arguments.length),R(this,kD,!1,"f"),G(this,v,"f").y18n.updateLocale(D),this}usage(D,u,F,E){if(N("<string|null|undefined> [string|boolean] [function|object] [function]",[D,u,F,E],arguments.length),u!==void 0)if(QD(D,null,G(this,v,"f")),(D||"").match(/^\$0( |$)/))return this.command(D,u,F,E);else throw new uD(".usage() description must start with $0 if being used as alias for .command()");else return G(this,m,"f").usage(D),this}usageConfiguration(D){return N("<object>",[D],arguments.length),R(this,tu,D,"f"),this}version(D,u,F){if(N("[boolean|string] [string] [string]",[D,u,F],arguments.length),G(this,LD,"f"))this[PF](G(this,LD,"f")),G(this,m,"f").version(void 0),R(this,LD,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 R(this,LD,typeof D==="string"?D:"version","f"),u=u||G(this,m,"f").deferY18nLookup("Show version number"),G(this,m,"f").version(F||void 0),this.boolean(G(this,LD,"f")),this.describe(G(this,LD,"f"),u),this}wrap(D){return N("<number|null|undefined>",[D],arguments.length),G(this,m,"f").wrap(D),this}[(FD=new WeakMap,nD=new WeakMap,_u=new WeakMap,OD=new WeakMap,MD=new WeakMap,cu=new WeakMap,bD=new WeakMap,kD=new WeakMap,yu=new WeakMap,UD=new WeakMap,iu=new WeakMap,_D=new WeakMap,AD=new WeakMap,HD=new WeakMap,jD=new WeakMap,nu=new WeakMap,dD=new WeakMap,ZD=new WeakMap,w=new WeakMap,ku=new WeakMap,du=new WeakMap,VD=new WeakMap,gD=new WeakMap,Xu=new WeakMap,tD=new WeakMap,hD=new WeakMap,gu=new WeakMap,v=new WeakMap,lD=new WeakMap,oD=new WeakMap,sD=new WeakMap,m=new WeakMap,tu=new WeakMap,LD=new WeakMap,r=new WeakMap,Y2)](D){if(!D._||!D["--"])return D;D._.push.apply(D._,D["--"]);try{delete D["--"]}catch(u){}return D}[W2](){return{log:(...D)=>{if(!this[lu]())console.log(...D);if(R(this,HD,!0,"f"),G(this,ZD,"f").length)R(this,ZD,G(this,ZD,"f")+`
80
- `,"f");R(this,ZD,G(this,ZD,"f")+D.join(" "),"f")},error:(...D)=>{if(!this[lu]())console.error(...D);if(R(this,HD,!0,"f"),G(this,ZD,"f").length)R(this,ZD,G(this,ZD,"f")+`
81
- `,"f");R(this,ZD,G(this,ZD,"f")+D.join(" "),"f")}}}[PF](D){Gu(G(this,w,"f")).forEach((u)=>{if(((E)=>E==="configObjects")(u))return;let F=G(this,w,"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 G(this,m,"f").getDescriptions()[D]}[M2](D,u,F){if(!G(this,yu,"f")[F])G(this,v,"f").process.emitWarning(D,u),G(this,yu,"f")[F]=!0}[H2](){G(this,iu,"f").push({options:G(this,w,"f"),configObjects:G(this,w,"f").configObjects.slice(0),exitProcess:G(this,UD,"f"),groups:G(this,AD,"f"),strict:G(this,lD,"f"),strictCommands:G(this,oD,"f"),strictOptions:G(this,sD,"f"),completionCommand:G(this,MD,"f"),output:G(this,ZD,"f"),exitError:G(this,bD,"f"),hasOutput:G(this,HD,"f"),parsed:this.parsed,parseFn:G(this,VD,"f"),parseContext:G(this,gD,"f")}),G(this,m,"f").freeze(),G(this,r,"f").freeze(),G(this,FD,"f").freeze(),G(this,_D,"f").freeze()}[V2](){let D="",u;if(/\b(node|iojs|electron)(\.exe)?$/.test(G(this,v,"f").process.argv()[0]))u=G(this,v,"f").process.argv().slice(1,2);else u=G(this,v,"f").process.argv().slice(0,1);if(D=u.map((F)=>{let E=this[w2](G(this,nD,"f"),F);return F.match(/^(\/|([a-zA-Z]:)?\\)/)&&E.length<F.length?E:F}).join(" ").trim(),G(this,v,"f").getEnv("_")&&G(this,v,"f").getProcessArgvBin()===G(this,v,"f").getEnv("_"))D=G(this,v,"f").getEnv("_").replace(`${G(this,v,"f").path.dirname(G(this,v,"f").process.execPath())}/`,"");return D}[rD](){return G(this,du,"f")}[q2](){return G(this,tu,"f")}[wF](){if(!G(this,kD,"f"))return;let D=G(this,v,"f").getEnv("LC_ALL")||G(this,v,"f").getEnv("LC_MESSAGES")||G(this,v,"f").getEnv("LANG")||G(this,v,"f").getEnv("LANGUAGE")||"en_US";this.locale(D.replace(/[.:].*/,""))}[U2](){return this[IF]().version||"unknown"}[_2](D){let u=D["--"]?D["--"]:D._;for(let F=0,E;(E=u[F])!==void 0;F++)if(G(this,v,"f").Parser.looksLikeNumber(E)&&Number.isSafeInteger(Math.floor(parseFloat(`${E}`))))u[F]=Number(E);return D}[IF](D){let u=D||"*";if(G(this,Xu,"f")[u])return G(this,Xu,"f")[u];let F={};try{let E=D||G(this,v,"f").mainFilename;if(G(this,v,"f").path.extname(E))E=G(this,v,"f").path.dirname(E);let C=G(this,v,"f").findUp(E,(B,$)=>{if($.includes("package.json"))return"package.json";else return});QD(C,void 0,G(this,v,"f")),F=JSON.parse(G(this,v,"f").readFileSync(C,"utf8"))}catch(E){}return G(this,Xu,"f")[u]=F||{},G(this,Xu,"f")[u]}[vD](D,u){u=[].concat(u),u.forEach((F)=>{F=this[bF](F),G(this,w,"f")[D].push(F)})}[Ju](D,u,F,E){this[xF](D,u,F,E,(C,B,$)=>{G(this,w,"f")[C][B]=$})}[fF](D,u,F,E){this[xF](D,u,F,E,(C,B,$)=>{G(this,w,"f")[C][B]=(G(this,w,"f")[C][B]||[]).concat($)})}[xF](D,u,F,E,C){if(Array.isArray(F))F.forEach((B)=>{D(B,E)});else if(((B)=>typeof B==="object")(F))for(let B of Gu(F))D(B,F[B]);else C(u,this[bF](F),E)}[bF](D){if(D==="__proto__")return"___proto___";return D}[hF](D,u){return this[Ju](this[hF].bind(this),"key",D,u),this}[vF](){var D,u,F,E,C,B,$,z,Z,J,O,X;let Q=G(this,iu,"f").pop();QD(Q,void 0,G(this,v,"f"));let Y;D=this,u=this,F=this,E=this,C=this,B=this,$=this,z=this,Z=this,J=this,O=this,X=this,{options:{set value(M){R(D,w,M,"f")}}.value,configObjects:Y,exitProcess:{set value(M){R(u,UD,M,"f")}}.value,groups:{set value(M){R(F,AD,M,"f")}}.value,output:{set value(M){R(E,ZD,M,"f")}}.value,exitError:{set value(M){R(C,bD,M,"f")}}.value,hasOutput:{set value(M){R(B,HD,M,"f")}}.value,parsed:this.parsed,strict:{set value(M){R($,lD,M,"f")}}.value,strictCommands:{set value(M){R(z,oD,M,"f")}}.value,strictOptions:{set value(M){R(Z,sD,M,"f")}}.value,completionCommand:{set value(M){R(J,MD,M,"f")}}.value,parseFn:{set value(M){R(O,VD,M,"f")}}.value,parseContext:{set value(M){R(X,gD,M,"f")}}.value}=Q,G(this,w,"f").configObjects=Y,G(this,m,"f").unfreeze(),G(this,r,"f").unfreeze(),G(this,FD,"f").unfreeze(),G(this,_D,"f").unfreeze()}[j2](D,u){return iD(u,(F)=>{return D(F),F})}getInternalMethods(){return{getCommandInstance:this[K2].bind(this),getContext:this[T2].bind(this),getHasOutput:this[N2].bind(this),getLoggerInstance:this[R2].bind(this),getParseContext:this[A2].bind(this),getParserConfiguration:this[rD].bind(this),getUsageConfiguration:this[q2].bind(this),getUsageInstance:this[L2].bind(this),getValidationInstance:this[S2].bind(this),hasParseCallback:this[lu].bind(this),isGlobalContext:this[P2].bind(this),postProcess:this[aD].bind(this),reset:this[pF].bind(this),runValidation:this[mF].bind(this),runYargsParserAndExecuteCommands:this[ju].bind(this),setHasOutput:this[I2].bind(this)}}[K2](){return G(this,FD,"f")}[T2](){return G(this,_u,"f")}[N2](){return G(this,HD,"f")}[R2](){return G(this,dD,"f")}[A2](){return G(this,gD,"f")||{}}[L2](){return G(this,m,"f")}[S2](){return G(this,r,"f")}[lu](){return!!G(this,VD,"f")}[P2](){return G(this,nu,"f")}[aD](D,u,F,E){if(F)return D;if(o(D))return D;if(!u)D=this[Y2](D);if(this[rD]()["parse-positional-numbers"]||this[rD]()["parse-positional-numbers"]===void 0)D=this[_2](D);if(E)D=yD(D,this,G(this,_D,"f").getMiddleware(),!1);return D}[pF](D={}){R(this,w,G(this,w,"f")||{},"f");let u={};u.local=G(this,w,"f").local||[],u.configObjects=G(this,w,"f").configObjects||[];let F={};u.local.forEach((B)=>{F[B]=!0,(D[B]||[]).forEach(($)=>{F[$]=!0})}),Object.assign(G(this,tD,"f"),Object.keys(G(this,AD,"f")).reduce((B,$)=>{let z=G(this,AD,"f")[$].filter((Z)=>!(Z in F));if(z.length>0)B[$]=z;return B},{})),R(this,AD,{},"f");let E=["array","boolean","string","skipValidation","count","normalize","number","hiddenOptions"],C=["narg","key","alias","default","defaultDescription","config","choices","demandedOptions","demandedCommands","deprecatedOptions"];if(E.forEach((B)=>{u[B]=(G(this,w,"f")[B]||[]).filter(($)=>!F[$])}),C.forEach((B)=>{u[B]=fD(G(this,w,"f")[B],($)=>!F[$])}),u.envPrefix=G(this,w,"f").envPrefix,R(this,w,u,"f"),R(this,m,G(this,m,"f")?G(this,m,"f").reset(F):B2(this,G(this,v,"f")),"f"),R(this,r,G(this,r,"f")?G(this,r,"f").reset(F):Q2(this,G(this,m,"f"),G(this,v,"f")),"f"),R(this,FD,G(this,FD,"f")?G(this,FD,"f").reset():F2(G(this,m,"f"),G(this,r,"f"),G(this,_D,"f"),G(this,v,"f")),"f"),!G(this,OD,"f"))R(this,OD,Z2(this,G(this,m,"f"),G(this,FD,"f"),G(this,v,"f")),"f");return G(this,_D,"f").reset(),R(this,MD,null,"f"),R(this,ZD,"","f"),R(this,bD,null,"f"),R(this,HD,!1,"f"),this.parsed=!1,this}[w2](D,u){return G(this,v,"f").path.relative(D,u)}[ju](D,u,F,E=0,C=!1){var B,$,z,Z;let J=!!F||C;D=D||G(this,hD,"f"),G(this,w,"f").__=G(this,v,"f").y18n.__,G(this,w,"f").configuration=this[rD]();let O=!!G(this,w,"f").configuration["populate--"],X=Object.assign({},G(this,w,"f").configuration,{"populate--":!0}),Q=G(this,v,"f").Parser.detailed(D,Object.assign({},G(this,w,"f"),{configuration:{"parse-positional-numbers":!1,...X}})),Y=Object.assign(Q.argv,G(this,gD,"f")),M=void 0,H=Q.aliases,_=!1,S=!1;if(Object.keys(Y).forEach((f)=>{if(f===G(this,jD,"f")&&Y[f])_=!0;else if(f===G(this,LD,"f")&&Y[f])S=!0}),Y.$0=this.$0,this.parsed=Q,E===0)G(this,m,"f").clearCachedHelpMessage();try{if(this[wF](),u)return this[aD](Y,O,!!F,!1);if(G(this,jD,"f")){if([G(this,jD,"f")].concat(H[G(this,jD,"f")]||[]).filter((a)=>a.length>1).includes(""+Y._[Y._.length-1]))Y._.pop(),_=!0}R(this,nu,!1,"f");let f=G(this,FD,"f").getCommands(),d=((B=G(this,OD,"f"))===null||B===void 0?void 0:B.completionKey)?[($=G(this,OD,"f"))===null||$===void 0?void 0:$.completionKey,...(Z=this.getAliases()[(z=G(this,OD,"f"))===null||z===void 0?void 0:z.completionKey])!==null&&Z!==void 0?Z:[]].some((i)=>Object.prototype.hasOwnProperty.call(Y,i)):!1,x=_||d||C;if(Y._.length){if(f.length){let i;for(let a=E||0,e;Y._[a]!==void 0;a++)if(e=String(Y._[a]),f.includes(e)&&e!==G(this,MD,"f")){let RD=G(this,FD,"f").runCommand(e,this,Q,a+1,C,_||S||C);return this[aD](RD,O,!!F,!1)}else if(!i&&e!==G(this,MD,"f")){i=e;break}if(!G(this,FD,"f").hasDefaultCommand()&&G(this,gu,"f")&&i&&!x)G(this,r,"f").recommendCommands(i,f)}if(G(this,MD,"f")&&Y._.includes(G(this,MD,"f"))&&!d){if(G(this,UD,"f"))xD(!0);this.showCompletionScript(),this.exit(0)}}if(G(this,FD,"f").hasDefaultCommand()&&!x){let i=G(this,FD,"f").runCommand(null,this,Q,0,C,_||S||C);return this[aD](i,O,!!F,!1)}if(d){if(G(this,UD,"f"))xD(!0);D=[].concat(D);let i=D.slice(D.indexOf(`--${G(this,OD,"f").completionKey}`)+1);return G(this,OD,"f").getCompletion(i,(a,e)=>{if(a)throw new uD(a.message);(e||[]).forEach((RD)=>{G(this,dD,"f").log(RD)}),this.exit(0)}),this[aD](Y,!O,!!F,!1)}if(!G(this,HD,"f")){if(_){if(G(this,UD,"f"))xD(!0);J=!0,this.showHelp((i)=>{G(this,dD,"f").log(i),this.exit(0)})}else if(S){if(G(this,UD,"f"))xD(!0);J=!0,G(this,m,"f").showVersion("log"),this.exit(0)}}if(!J&&G(this,w,"f").skipValidation.length>0)J=Object.keys(Y).some((i)=>G(this,w,"f").skipValidation.indexOf(i)>=0&&Y[i]===!0);if(!J){if(Q.error)throw new uD(Q.error.message);if(!d){let i=this[mF](H,{},Q.error);if(!F)M=yD(Y,this,G(this,_D,"f").getMiddleware(),!0);if(M=this[j2](i,M!==null&&M!==void 0?M:Y),o(M)&&!F)M=M.then(()=>{return yD(Y,this,G(this,_D,"f").getMiddleware(),!1)})}}}catch(f){if(f instanceof uD)G(this,m,"f").fail(f.message,f);else throw f}return this[aD](M!==null&&M!==void 0?M:Y,O,!!F,!0)}[mF](D,u,F,E){let C={...this.getDemandedOptions()};return(B)=>{if(F)throw new uD(F.message);G(this,r,"f").nonOptionCount(B),G(this,r,"f").requiredArguments(B,C);let $=!1;if(G(this,oD,"f"))$=G(this,r,"f").unknownCommands(B);if(G(this,lD,"f")&&!$)G(this,r,"f").unknownArguments(B,D,u,!!E);else if(G(this,sD,"f"))G(this,r,"f").unknownArguments(B,D,{},!1,!1);G(this,r,"f").limitedChoices(B),G(this,r,"f").implications(B),G(this,r,"f").conflicting(B)}}[I2](){R(this,HD,!0,"f")}[eD](D){if(typeof D==="string")G(this,w,"f").key[D]=!0;else for(let u of D)G(this,w,"f").key[u]=!0}}function E2(D){return!!D&&typeof D.getInternalMethods==="function"}var u3=f2(NF),b2=u3;import{existsSync as yF,readFileSync as v2,writeFileSync as cF,mkdirSync as p2}from"node:fs";import{homedir as F3}from"node:os";import{join as ou,dirname as m2}from"node:path";function c2(){return process.env.HOME||F3()}function y2(){return ou(c2(),".config","slack-cli","profiles.json")}function su(){return ou(process.cwd(),".slack-cli","workspace")}function ru(){return ou(c2(),".slack-cli","workspace")}function Ku(){let D=y2();if(!yF(D))return{profiles:{}};return JSON.parse(v2(D,"utf8"))}function E3(D){let u=y2();p2(m2(u),{recursive:!0}),cF(u,JSON.stringify(D,null,2)+`
82
- `)}function Qu(D){if(!yF(D))return;return v2(D,"utf8").trim()||void 0}function h2(D,u){let F=m2(D);p2(F,{recursive:!0});let E=ou(F,".gitignore");if(!yF(E))cF(E,`*
83
- `);cF(D,u+`
84
- `)}function i2(){let D=Ku(),u=Qu(su()),F=Qu(ru()),E=u??F;return Object.entries(D.profiles).map(([C,B])=>({name:C,profile:B,current:C===E}))}function n2(D){let u=Ku();if(!(D in u.profiles))throw Error(`Profile not found: ${D}`);delete u.profiles[D],E3(u)}function k2(D,u=!1){let F=Ku();if(!(D in F.profiles))throw Error(`Profile not found: ${D}`);if(u)h2(ru(),D);else h2(su(),D)}function iF(D){let F=Ku().profiles,E=Object.keys(F),C=process.env.SLACK_MCP_XOXP_TOKEN;if(C&&E.length>0){if(!globalThis.__slackEnvWarnShown)globalThis.__slackEnvWarnShown=!0,console.error(`Warning: SLACK_MCP_XOXP_TOKEN is set but workspace profiles exist - using profiles.
85
- Run: unset SLACK_MCP_XOXP_TOKEN (and remove from ~/.zshrc or ~/.bashrc)`)}else if(C)return C;let B=D??process.env.SLACK_WORKSPACE;if(B){let Z=F[B];if(!Z)throw Error(`Workspace "${B}" not found. Available: ${E.join(", ")||"(none)"}`);return Z.token}let $=Qu(su());if($){let Z=F[$];if(!Z)throw Error(`Workspace "${$}" (from .slack-cli/workspace) not found in profiles.`);return Z.token}let z=Qu(ru());if(z){let Z=F[z];if(!Z)throw Error(`Workspace "${z}" (from ~/.slack-cli/workspace) not found in profiles.`);return Z.token}if(E.length===0)throw Error("No profiles configured. Run: slack auth login");throw Error(`Workspace not selected (${E.join(", ")} available).
74
+ `;class p2{constructor(D,u,F,E){var C,B,$;this.yargs=D,this.usage=u,this.command=F,this.shim=E,this.completionKey="get-yargs-completions",this.aliases=null,this.customCompletionFunction=null,this.indexAfterLastReset=0,this.zshShell=($=((C=this.shim.getEnv("SHELL"))===null||C===void 0?void 0:C.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,E){let C=this.command.getCommandHandlers();for(let $=0,z=D.length;$<z;++$)if(C[D[$]]&&C[D[$]].builder){let G=C[D[$]].builder;if(ou(G)){this.indexAfterLastReset=$+1;let Z=this.yargs.getInternalMethods().reset();return G(Z,!0),Z.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),E(null,B)}commandCompletions(D,u,F){let E=this.yargs.getInternalMethods().getContext().commands;if(!F.match(/^-/)&&E[E.length-1]!==F&&!this.previousArgHasChoices(u))this.usage.getCommands().forEach((C)=>{let B=mD(C[0]).cmd;if(u.indexOf(B)===-1)if(!this.zshShell)D.push(B);else{let $=C[1]||"";D.push(B.replace(/:/g,"\\:")+":"+$)}})}optionCompletions(D,u,F,E){if((E.match(/^-/)||E===""&&D.length===0)&&!this.previousArgHasChoices(u)){let C=this.yargs.getOptions(),B=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[];Object.keys(C.key).forEach(($)=>{let z=!!C.configuration["boolean-negation"]&&C.boolean.includes($);if(!B.includes($)&&!C.hiddenOptions.includes($)&&!this.argsContainKey(u,$,z))this.completeOptionKey($,D,E,z&&!!C.default[$])})}}choicesFromOptionsCompletions(D,u,F,E){if(this.previousArgHasChoices(u)){let C=this.getPreviousArgChoices(u);if(C&&C.length>0)D.push(...C.map((B)=>B.replace(/:/g,"\\:")))}}choicesFromPositionalsCompletions(D,u,F,E){if(E===""&&D.length>0&&this.previousArgHasChoices(u))return;let C=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[],B=Math.max(this.indexAfterLastReset,this.yargs.getInternalMethods().getContext().commands.length+1),$=C[F._.length-B-1];if(!$)return;let z=this.yargs.getOptions().choices[$]||[];for(let G of z)if(G.startsWith(E))D.push(G.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 E=u.replace(/^-+/,""),C=this.yargs.getOptions(),B=[E,...this.yargs.getAliases()[E]||[]],$;for(let z of B)if(Object.prototype.hasOwnProperty.call(C.key,z)&&Array.isArray(C.choices[z])){$=C.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 E=(C)=>D.indexOf((/^[^0-9]$/.test(C)?"-":"--")+C)!==-1;if(E(u))return!0;if(F&&E(`no-${u}`))return!0;if(this.aliases){for(let C of this.aliases[u])if(E(C))return!0}return!1}completeOptionKey(D,u,F,E){var C,B,$,z;let G=D;if(this.zshShell){let Y=this.usage.getDescriptions(),W=(B=(C=this===null||this===void 0?void 0:this.aliases)===null||C===void 0?void 0:C[D])===null||B===void 0?void 0:B.find((q)=>{let j=Y[q];return typeof j==="string"&&j.length>0}),H=W?Y[W]:void 0,O=(z=($=Y[D])!==null&&$!==void 0?$:H)!==null&&z!==void 0?z:"";G=`${D.replace(/:/g,"\\:")}:${O.replace("__yargsString__:","").replace(/(\r\n|\n|\r)/gm," ")}`}let Z=(Y)=>/^--/.test(Y),Q=(Y)=>/^[^0-9]$/.test(Y),J=!Z(F)&&Q(D)?"-":"--";if(u.push(J+G),E)u.push(J+"no-"+G)}customCompletion(D,u,F,E){if(YD(this.customCompletionFunction,null,this.shim),i3(this.customCompletionFunction)){let C=this.customCompletionFunction(F,u);if(o(C))return C.then((B)=>{this.shim.process.nextTick(()=>{E(null,B)})}).catch((B)=>{this.shim.process.nextTick(()=>{E(B,void 0)})});return E(null,C)}else if(n3(this.customCompletionFunction))return this.customCompletionFunction(F,u,(C=E)=>this.defaultCompletion(D,u,F,C),(C)=>{E(null,C)});else return this.customCompletionFunction(F,u,(C)=>{E(null,C)})}getCompletion(D,u){let F=D.length?D[D.length-1]:"",E=this.yargs.parse(D,!0),C=this.customCompletionFunction?(B)=>this.customCompletion(D,B,F,u):(B)=>this.defaultCompletion(D,B,F,u);return o(E)?E.then(C):C(E)}generateCompletionScript(D,u){let F=this.zshShell?m2:v2,E=this.shim.path.basename(D);if(D.match(/\.js$/))D=`./${D}`;return F=F.replace(/{{app_name}}/g,E),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 y2(D,u,F,E){return new p2(D,u,F,E)}function i3(D){return D.length<3}function n3(D){return D.length>3}function c2(D,u){if(D.length===0)return u.length;if(u.length===0)return D.length;let F=[],E;for(E=0;E<=u.length;E++)F[E]=[E];let C;for(C=0;C<=D.length;C++)F[0][C]=C;for(E=1;E<=u.length;E++)for(C=1;C<=D.length;C++)if(u.charAt(E-1)===D.charAt(C-1))F[E][C]=F[E-1][C-1];else if(E>1&&C>1&&u.charAt(E-2)===D.charAt(C-1)&&u.charAt(E-1)===D.charAt(C-2))F[E][C]=F[E-2][C-2]+1;else F[E][C]=Math.min(F[E-1][C-1]+1,Math.min(F[E][C-1]+1,F[E-1][C]+1));return F[u.length][D.length]}var g2=["$0","--","_"];function k2(D,u,F){let E=F.y18n.__,C=F.y18n.__n,B={};B.nonOptionCount=function(J){let Y=D.getDemandedCommands(),H=J._.length+(J["--"]?J["--"].length:0)-D.getInternalMethods().getContext().commands.length;if(Y._&&(H<Y._.min||H>Y._.max)){if(H<Y._.min)if(Y._.minMsg!==void 0)u.fail(Y._.minMsg?Y._.minMsg.replace(/\$0/g,H.toString()).replace(/\$1/,Y._.min.toString()):null);else u.fail(C("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",H,H.toString(),Y._.min.toString()));else if(H>Y._.max)if(Y._.maxMsg!==void 0)u.fail(Y._.maxMsg?Y._.maxMsg.replace(/\$0/g,H.toString()).replace(/\$1/,Y._.max.toString()):null);else u.fail(C("Too many non-option arguments: got %s, maximum of %s","Too many non-option arguments: got %s, maximum of %s",H,H.toString(),Y._.max.toString()))}},B.positionalCount=function(J,Y){if(Y<J)u.fail(C("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",Y,Y+"",J+""))},B.requiredArguments=function(J,Y){let W=null;for(let H of Object.keys(Y))if(!Object.prototype.hasOwnProperty.call(J,H)||typeof J[H]>"u")W=W||{},W[H]=Y[H];if(W){let H=[];for(let q of Object.keys(W)){let j=W[q];if(j&&H.indexOf(j)<0)H.push(j)}let O=H.length?`
75
+ ${H.join(`
76
+ `)}`:"";u.fail(C("Missing required argument: %s","Missing required arguments: %s",Object.keys(W).length,Object.keys(W).join(", ")+O))}},B.unknownArguments=function(J,Y,W,H,O=!0){var q;let j=D.getInternalMethods().getCommandInstance().getCommands(),N=[],k=D.getInternalMethods().getContext();if(Object.keys(J).forEach((w)=>{if(!g2.includes(w)&&!Object.prototype.hasOwnProperty.call(W,w)&&!Object.prototype.hasOwnProperty.call(D.getInternalMethods().getParseContext(),w)&&!B.isValidAndSomeAliasIsNotNew(w,Y))N.push(w)}),O&&(k.commands.length>0||j.length>0||H))J._.slice(k.commands.length).forEach((w)=>{if(!j.includes(""+w))N.push(""+w)});if(O){let c=((q=D.getDemandedCommands()._)===null||q===void 0?void 0:q.max)||0,e=k.commands.length+c;if(e<J._.length)J._.slice(e).forEach((s)=>{if(s=String(s),!k.commands.includes(s)&&!N.includes(s))N.push(s)})}if(N.length)u.fail(C("Unknown argument: %s","Unknown arguments: %s",N.length,N.map((w)=>w.trim()?w:`"${w}"`).join(", ")))},B.unknownCommands=function(J){let Y=D.getInternalMethods().getCommandInstance().getCommands(),W=[],H=D.getInternalMethods().getContext();if(H.commands.length>0||Y.length>0)J._.slice(H.commands.length).forEach((O)=>{if(!Y.includes(""+O))W.push(""+O)});if(W.length>0)return u.fail(C("Unknown command: %s","Unknown commands: %s",W.length,W.join(", "))),!0;else return!1},B.isValidAndSomeAliasIsNotNew=function(J,Y){if(!Object.prototype.hasOwnProperty.call(Y,J))return!1;let W=D.parsed.newAliases;return[J,...Y[J]].some((H)=>!Object.prototype.hasOwnProperty.call(W,H)||!W[J])},B.limitedChoices=function(J){let Y=D.getOptions(),W={};if(!Object.keys(Y.choices).length)return;Object.keys(J).forEach((q)=>{if(g2.indexOf(q)===-1&&Object.prototype.hasOwnProperty.call(Y.choices,q))[].concat(J[q]).forEach((j)=>{if(Y.choices[q].indexOf(j)===-1&&j!==void 0)W[q]=(W[q]||[]).concat(j)})});let H=Object.keys(W);if(!H.length)return;let O=E("Invalid values:");H.forEach((q)=>{O+=`
77
+ ${E("Argument: %s, Given: %s, Choices: %s",q,u.stringifiedValues(W[q]),u.stringifiedValues(Y.choices[q]))}`}),u.fail(O)};let $={};B.implies=function(J,Y){if(R("<string|object> [array|number|string]",[J,Y],arguments.length),typeof J==="object")Object.keys(J).forEach((W)=>{B.implies(W,J[W])});else{if(D.global(J),!$[J])$[J]=[];if(Array.isArray(Y))Y.forEach((W)=>B.implies(J,W));else YD(Y,void 0,F),$[J].push(Y)}},B.getImplied=function(){return $};function z(Q,J){let Y=Number(J);if(J=isNaN(Y)?J:Y,typeof J==="number")J=Q._.length>=J;else if(J.match(/^--no-.+/))J=J.match(/^--no-(.+)/)[1],J=!Object.prototype.hasOwnProperty.call(Q,J);else J=Object.prototype.hasOwnProperty.call(Q,J);return J}B.implications=function(J){let Y=[];if(Object.keys($).forEach((W)=>{let H=W;($[W]||[]).forEach((O)=>{let q=H,j=O;if(q=z(J,q),O=z(J,O),q&&!O)Y.push(` ${H} -> ${j}`)})}),Y.length){let W=`${E("Implications failed:")}
78
+ `;Y.forEach((H)=>{W+=H}),u.fail(W)}};let G={};B.conflicts=function(J,Y){if(R("<string|object> [array|string]",[J,Y],arguments.length),typeof J==="object")Object.keys(J).forEach((W)=>{B.conflicts(W,J[W])});else{if(D.global(J),!G[J])G[J]=[];if(Array.isArray(Y))Y.forEach((W)=>B.conflicts(J,W));else G[J].push(Y)}},B.getConflicting=()=>G,B.conflicting=function(J){if(Object.keys(J).forEach((Y)=>{if(G[Y])G[Y].forEach((W)=>{if(W&&J[Y]!==void 0&&J[W]!==void 0)u.fail(E("Arguments %s and %s are mutually exclusive",Y,W))})}),D.getInternalMethods().getParserConfiguration()["strip-dashed"])Object.keys(G).forEach((Y)=>{G[Y].forEach((W)=>{if(W&&J[F.Parser.camelCase(Y)]!==void 0&&J[F.Parser.camelCase(W)]!==void 0)u.fail(E("Arguments %s and %s are mutually exclusive",Y,W))})})},B.recommendCommands=function(J,Y){Y=Y.sort((q,j)=>j.length-q.length);let H=null,O=1/0;for(let q=0,j;(j=Y[q])!==void 0;q++){let N=c2(J,j);if(N<=3&&N<O)O=N,H=j}if(H)u.fail(E("Did you mean %s?",H))},B.reset=function(J){return $=pD($,(Y)=>!J[Y]),G=pD(G,(Y)=>!J[Y]),B};let Z=[];return B.freeze=function(){Z.push({implied:$,conflicting:G})},B.unfreeze=function(){let J=Z.pop();YD(J,void 0,F),{implied:$,conflicting:G}=J},B}var dF=[],Ru;function Tu(D,u,F,E){Ru=E;let C={};if(Object.prototype.hasOwnProperty.call(D,"extends")){if(typeof D.extends!=="string")return C;let B=/\.json|\..*rc$/.test(D.extends),$=null;if(!B)try{$=import.meta.resolve(D.extends)}catch(z){return D}else $=l3(u,D.extends);t3($),dF.push($),C=B?JSON.parse(Ru.readFileSync($,"utf8")):E.require(D.extends),delete D.extends,C=Tu(C,Ru.path.dirname($),F,Ru)}return dF=[],F?d2(C,D):Object.assign({},C,D)}function t3(D){if(dF.indexOf(D)>-1)throw new FD(`Circular extended configurations: '${D}'.`)}function l3(D,u){return Ru.path.resolve(D,u)}function d2(D,u){let F={};function E(C){return C&&typeof C==="object"&&!Array.isArray(C)}Object.assign(F,D);for(let C of Object.keys(u))if(E(u[C])&&E(F[C]))F[C]=d2(D[C],u[C]);else F[C]=u[C];return F}var T=function(D,u,F,E,C){if(E==="m")throw TypeError("Private method is not writable");if(E==="a"&&!C)throw TypeError("Private accessor was defined without a setter");if(typeof u==="function"?D!==u||!C:!u.has(D))throw TypeError("Cannot write private member to an object whose class did not declare it");return E==="a"?C.call(D,F):C?C.value=F:u.set(D,F),F},X=function(D,u,F,E){if(F==="a"&&!E)throw TypeError("Private accessor was defined without a getter");if(typeof u==="function"?D!==u||!E:!u.has(D))throw TypeError("Cannot read private member from an object whose class did not declare it");return F==="m"?E:F==="a"?E.call(D):E?E.value:u.get(D)},ED,aD,Su,WD,MD,ru,cD,eD,au,KD,eu,jD,PD,VD,AD,DF,Du,JD,I,uF,FF,UD,uu,Uu,Fu,gD,EF,v,Eu,Cu,Bu,p,CF,wD,DD;function J8(D){return(u=[],F=D.process.cwd(),E)=>{let C=new X8(u,F,E,D);return Object.defineProperty(C,"argv",{get:()=>{return C.parse()},enumerable:!0}),C.help(),C.version(),C}}var i2=Symbol("copyDoubleDash"),n2=Symbol("copyDoubleDash"),iF=Symbol("deleteFromParserHintObject"),t2=Symbol("emitWarning"),l2=Symbol("freeze"),o2=Symbol("getDollarZero"),$u=Symbol("getParserConfiguration"),s2=Symbol("getUsageConfiguration"),nF=Symbol("guessLocale"),r2=Symbol("guessVersion"),a2=Symbol("parsePositionalNumbers"),tF=Symbol("pkgUp"),kD=Symbol("populateParserHintArray"),qu=Symbol("populateParserHintSingleValueDictionary"),lF=Symbol("populateParserHintArrayDictionary"),oF=Symbol("populateParserHintDictionary"),sF=Symbol("sanitizeKey"),rF=Symbol("setKey"),aF=Symbol("unfreeze"),e2=Symbol("validateAsync"),D8=Symbol("getCommandInstance"),u8=Symbol("getContext"),F8=Symbol("getHasOutput"),E8=Symbol("getLoggerInstance"),C8=Symbol("getParseContext"),B8=Symbol("getUsageInstance"),$8=Symbol("getValidationInstance"),BF=Symbol("hasParseCallback"),z8=Symbol("isGlobalContext"),zu=Symbol("postProcess"),G8=Symbol("rebase"),eF=Symbol("reset"),Pu=Symbol("runYargsParserAndExecuteCommands"),D0=Symbol("runValidation"),Z8=Symbol("setHasOutput"),Gu=Symbol("kTrackManuallySetKeys"),o3="en_US";class X8{constructor(D=[],u,F,E){this.customScriptName=!1,this.parsed=!1,ED.set(this,void 0),aD.set(this,void 0),Su.set(this,{commands:[],fullCommands:[]}),WD.set(this,null),MD.set(this,null),ru.set(this,"show-hidden"),cD.set(this,null),eD.set(this,!0),au.set(this,{}),KD.set(this,!0),eu.set(this,[]),jD.set(this,void 0),PD.set(this,{}),VD.set(this,!1),AD.set(this,null),DF.set(this,!0),Du.set(this,void 0),JD.set(this,""),I.set(this,void 0),uF.set(this,void 0),FF.set(this,{}),UD.set(this,null),uu.set(this,null),Uu.set(this,{}),Fu.set(this,{}),gD.set(this,void 0),EF.set(this,!1),v.set(this,void 0),Eu.set(this,!1),Cu.set(this,!1),Bu.set(this,!1),p.set(this,void 0),CF.set(this,{}),wD.set(this,null),DD.set(this,void 0),T(this,v,E,"f"),T(this,gD,D,"f"),T(this,aD,u,"f"),T(this,uF,F,"f"),T(this,jD,new gF(this),"f"),this.$0=this[o2](),this[eF](),T(this,ED,X(this,ED,"f"),"f"),T(this,p,X(this,p,"f"),"f"),T(this,DD,X(this,DD,"f"),"f"),T(this,I,X(this,I,"f"),"f"),X(this,I,"f").showHiddenOpt=X(this,ru,"f"),T(this,Du,this[n2](),"f"),X(this,v,"f").y18n.setLocale(o3)}addHelpOpt(D,u){if(R("[string|boolean] [string]",[D,u],arguments.length),X(this,AD,"f"))this[iF](X(this,AD,"f")),T(this,AD,null,"f");if(D===!1&&u===void 0)return this;return T(this,AD,typeof D==="string"?D:"help","f"),this.boolean(X(this,AD,"f")),this.describe(X(this,AD,"f"),u||X(this,p,"f").deferY18nLookup("Show help")),this}help(D,u){return this.addHelpOpt(D,u)}addShowHiddenOpt(D,u){if(R("[string|boolean] [string]",[D,u],arguments.length),D===!1&&u===void 0)return this;let F=typeof D==="string"?D:X(this,ru,"f");return this.boolean(F),this.describe(F,u||X(this,p,"f").deferY18nLookup("Show hidden options")),X(this,I,"f").showHiddenOpt=F,this}showHidden(D,u){return this.addShowHiddenOpt(D,u)}alias(D,u){return R("<object|string|array> [string|array]",[D,u],arguments.length),this[lF](this.alias.bind(this),"alias",D,u),this}array(D){return R("<array|string>",[D],arguments.length),this[kD]("array",D),this[Gu](D),this}boolean(D){return R("<array|string>",[D],arguments.length),this[kD]("boolean",D),this[Gu](D),this}check(D,u){return R("<function> [boolean]",[D,u],arguments.length),this.middleware((F,E)=>{return rD(()=>{return D(F,E.getOptions())},(C)=>{if(!C)X(this,p,"f").fail(X(this,v,"f").y18n.__("Argument check failed: %s",D.toString()));else if(typeof C==="string"||C instanceof Error)X(this,p,"f").fail(C.toString(),C);return F},(C)=>{return X(this,p,"f").fail(C.message?C.message:C.toString(),C),F})},!1,u),this}choices(D,u){return R("<object|string|array> [string|array]",[D,u],arguments.length),this[lF](this.choices.bind(this),"choices",D,u),this}coerce(D,u){if(R("<object|string|array> [function]",[D,u],arguments.length),Array.isArray(D)){if(!u)throw new FD("coerce callback must be provided");for(let E of D)this.coerce(E,u);return this}else if(typeof D==="object"){for(let E of Object.keys(D))this.coerce(E,D[E]);return this}if(!u)throw new FD("coerce callback must be provided");let F=D;return X(this,I,"f").key[F]=!0,X(this,jD,"f").addCoerceMiddleware((E,C)=>{var B;let $=(B=C.getAliases()[F])!==null&&B!==void 0?B:[],z=[F,...$].filter((G)=>Object.prototype.hasOwnProperty.call(E,G));if(z.length===0)return E;return rD(()=>{return u(E[z[0]])},(G)=>{return z.forEach((Z)=>{E[Z]=G}),E},(G)=>{throw new FD(G.message)})},F),this}conflicts(D,u){return R("<string|object> [string|array]",[D,u],arguments.length),X(this,DD,"f").conflicts(D,u),this}config(D="config",u,F){if(R("[object|string] [string|function] [function]",[D,u,F],arguments.length),typeof D==="object"&&!Array.isArray(D))return D=Tu(D,X(this,aD,"f"),this[$u]()["deep-merge-config"]||!1,X(this,v,"f")),X(this,I,"f").configObjects=(X(this,I,"f").configObjects||[]).concat(D),this;if(typeof u==="function")F=u,u=void 0;return this.describe(D,u||X(this,p,"f").deferY18nLookup("Path to JSON config file")),(Array.isArray(D)?D:[D]).forEach((E)=>{X(this,I,"f").config[E]=F||!0}),this}completion(D,u,F){if(R("[string] [string|boolean|function] [function]",[D,u,F],arguments.length),typeof u==="function")F=u,u=void 0;if(T(this,MD,D||X(this,MD,"f")||"completion","f"),!u&&u!==!1)u="generate completion script";if(this.command(X(this,MD,"f"),u),F)X(this,WD,"f").registerFunction(F);return this}command(D,u,F,E,C,B){return R("<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]",[D,u,F,E,C,B],arguments.length),X(this,ED,"f").addHandler(D,u,F,E,C,B),this}commands(D,u,F,E,C,B){return this.command(D,u,F,E,C,B)}commandDir(D,u){R("<string> [object]",[D,u],arguments.length);let F=X(this,uF,"f")||X(this,v,"f").require;return X(this,ED,"f").addDirectory(D,F,X(this,v,"f").getCallerFile(),u),this}count(D){return R("<array|string>",[D],arguments.length),this[kD]("count",D),this[Gu](D),this}default(D,u,F){if(R("<object|string|array> [*] [string]",[D,u,F],arguments.length),F)cF(D,X(this,v,"f")),X(this,I,"f").defaultDescription[D]=F;if(typeof u==="function"){if(cF(D,X(this,v,"f")),!X(this,I,"f").defaultDescription[D])X(this,I,"f").defaultDescription[D]=X(this,p,"f").functionDescription(u);u=u.call()}return this[qu](this.default.bind(this),"default",D,u),this}defaults(D,u,F){return this.default(D,u,F)}demandCommand(D=1,u,F,E){if(R("[number] [number|string] [string|null|undefined] [string|null|undefined]",[D,u,F,E],arguments.length),typeof u!=="number")F=u,u=1/0;return this.global("_",!1),X(this,I,"f").demandedCommands._={min:D,max:u,minMsg:F,maxMsg:E},this}demand(D,u,F){if(Array.isArray(u))u.forEach((E)=>{YD(F,!0,X(this,v,"f")),this.demandOption(E,F)}),u=1/0;else if(typeof u!=="number")F=u,u=1/0;if(typeof D==="number")YD(F,!0,X(this,v,"f")),this.demandCommand(D,u,F,F);else if(Array.isArray(D))D.forEach((E)=>{YD(F,!0,X(this,v,"f")),this.demandOption(E,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 R("<object|string|array> [string]",[D,u],arguments.length),this[qu](this.demandOption.bind(this),"demandedOptions",D,u),this}deprecateOption(D,u){return R("<string> [string|boolean]",[D,u],arguments.length),X(this,I,"f").deprecatedOptions[D]=u,this}describe(D,u){return R("<object|string|array> [string]",[D,u],arguments.length),this[rF](D,!0),X(this,p,"f").describe(D,u),this}detectLocale(D){return R("<boolean>",[D],arguments.length),T(this,eD,D,"f"),this}env(D){if(R("[string|boolean]",[D],arguments.length),D===!1)delete X(this,I,"f").envPrefix;else X(this,I,"f").envPrefix=D||"";return this}epilogue(D){return R("<string>",[D],arguments.length),X(this,p,"f").epilog(D),this}epilog(D){return this.epilogue(D)}example(D,u){if(R("<string|array> [string]",[D,u],arguments.length),Array.isArray(D))D.forEach((F)=>this.example(...F));else X(this,p,"f").example(D,u);return this}exit(D,u){if(T(this,VD,!0,"f"),T(this,cD,u,"f"),X(this,KD,"f"))X(this,v,"f").process.exit(D)}exitProcess(D=!0){return R("[boolean]",[D],arguments.length),T(this,KD,D,"f"),this}fail(D){if(R("<function|boolean>",[D],arguments.length),typeof D==="boolean"&&D!==!1)throw new FD("Invalid first argument. Expected function or boolean 'false'");return X(this,p,"f").failFn(D),this}getAliases(){return this.parsed?this.parsed.aliases:{}}async getCompletion(D,u){if(R("<array> [function]",[D,u],arguments.length),!u)return new Promise((F,E)=>{X(this,WD,"f").getCompletion(D,(C,B)=>{if(C)E(C);else F(B)})});else return X(this,WD,"f").getCompletion(D,u)}getDemandedOptions(){return R([],0),X(this,I,"f").demandedOptions}getDemandedCommands(){return R([],0),X(this,I,"f").demandedCommands}getDeprecatedOptions(){return R([],0),X(this,I,"f").deprecatedOptions}getDetectLocale(){return X(this,eD,"f")}getExitProcess(){return X(this,KD,"f")}getGroups(){return Object.assign({},X(this,PD,"f"),X(this,Fu,"f"))}getHelp(){if(T(this,VD,!0,"f"),!X(this,p,"f").hasCachedHelpMessage()){if(!this.parsed){let u=this[Pu](X(this,gD,"f"),void 0,void 0,0,!0);if(o(u))return u.then(()=>{return X(this,p,"f").help()})}let D=X(this,ED,"f").runDefaultBuilderOn(this);if(o(D))return D.then(()=>{return X(this,p,"f").help()})}return Promise.resolve(X(this,p,"f").help())}getOptions(){return X(this,I,"f")}getStrict(){return X(this,Eu,"f")}getStrictCommands(){return X(this,Cu,"f")}getStrictOptions(){return X(this,Bu,"f")}global(D,u){if(R("<string|array> [boolean]",[D,u],arguments.length),D=[].concat(D),u!==!1)X(this,I,"f").local=X(this,I,"f").local.filter((F)=>D.indexOf(F)===-1);else D.forEach((F)=>{if(!X(this,I,"f").local.includes(F))X(this,I,"f").local.push(F)});return this}group(D,u){R("<string|array> <string>",[D,u],arguments.length);let F=X(this,Fu,"f")[u]||X(this,PD,"f")[u];if(X(this,Fu,"f")[u])delete X(this,Fu,"f")[u];let E={};return X(this,PD,"f")[u]=(F||[]).concat(D).filter((C)=>{if(E[C])return!1;return E[C]=!0}),this}hide(D){return R("<string>",[D],arguments.length),X(this,I,"f").hiddenOptions.push(D),this}implies(D,u){return R("<string|object> [number|string|array]",[D,u],arguments.length),X(this,DD,"f").implies(D,u),this}locale(D){if(R("[string]",[D],arguments.length),D===void 0)return this[nF](),X(this,v,"f").y18n.getLocale();return T(this,eD,!1,"f"),X(this,v,"f").y18n.setLocale(D),this}middleware(D,u,F){return X(this,jD,"f").addMiddleware(D,!!u,F)}nargs(D,u){return R("<string|object|array> [number]",[D,u],arguments.length),this[qu](this.nargs.bind(this),"narg",D,u),this}normalize(D){return R("<array|string>",[D],arguments.length),this[kD]("normalize",D),this}number(D){return R("<array|string>",[D],arguments.length),this[kD]("number",D),this[Gu](D),this}option(D,u){if(R("<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[Gu](D),X(this,wD,"f")&&(D==="version"||(u===null||u===void 0?void 0:u.alias)==="version"))this[t2](['"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(X(this,I,"f").key[D]=!0,u.alias)this.alias(D,u.alias);let F=u.deprecate||u.deprecated;if(F)this.deprecateOption(D,F);let E=u.demand||u.required||u.require;if(E)this.demand(D,E);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)X(this,I,"f").defaultDescription[D]=u.defaultDescription;if(u.skipValidation)this.skipValidation(D);let C=u.describe||u.description||u.desc,B=X(this,p,"f").getDescriptions();if(!Object.prototype.hasOwnProperty.call(B,D)||typeof C==="string")this.describe(D,C);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(R("[string|array] [function|boolean|object] [function]",[D,u,F],arguments.length),this[l2](),typeof D>"u")D=X(this,gD,"f");if(typeof u==="object")T(this,uu,u,"f"),u=F;if(typeof u==="function")T(this,UD,u,"f"),u=!1;if(!u)T(this,gD,D,"f");if(X(this,UD,"f"))T(this,KD,!1,"f");let E=this[Pu](D,!!u),C=this.parsed;if(X(this,WD,"f").setParsed(this.parsed),o(E))return E.then((B)=>{if(X(this,UD,"f"))X(this,UD,"f").call(this,X(this,cD,"f"),B,X(this,JD,"f"));return B}).catch((B)=>{if(X(this,UD,"f"))X(this,UD,"f")(B,this.parsed.argv,X(this,JD,"f"));throw B}).finally(()=>{this[aF](),this.parsed=C});else{if(X(this,UD,"f"))X(this,UD,"f").call(this,X(this,cD,"f"),E,X(this,JD,"f"));this[aF](),this.parsed=C}return E}parseAsync(D,u,F){let E=this.parse(D,u,F);return!o(E)?Promise.resolve(E):E}parseSync(D,u,F){let E=this.parse(D,u,F);if(o(E))throw new FD(".parseSync() must not be used with asynchronous builders, handlers, or middleware");return E}parserConfiguration(D){return R("<object>",[D],arguments.length),T(this,FF,D,"f"),this}pkgConf(D,u){R("<string> [string]",[D,u],arguments.length);let F=null,E=this[tF](u||X(this,aD,"f"));if(E[D]&&typeof E[D]==="object")F=Tu(E[D],u||X(this,aD,"f"),this[$u]()["deep-merge-config"]||!1,X(this,v,"f")),X(this,I,"f").configObjects=(X(this,I,"f").configObjects||[]).concat(F);return this}positional(D,u){R("<string> <object>",[D,u],arguments.length);let F=["default","defaultDescription","implies","normalize","choices","conflicts","coerce","type","describe","desc","description","alias"];u=pD(u,(B,$)=>{if(B==="type"&&!["string","number","boolean"].includes($))return!1;return F.includes(B)});let E=X(this,Su,"f").fullCommands[X(this,Su,"f").fullCommands.length-1],C=E?X(this,ED,"f").cmdToParseOptions(E):{array:[],alias:{},default:{},demand:{}};return Mu(C).forEach((B)=>{let $=C[B];if(Array.isArray($)){if($.indexOf(D)!==-1)u[B]=!0}else if($[D]&&!(B in u))u[B]=$[D]}),this.group(D,X(this,p,"f").getPositionalGroupName()),this.option(D,u)}recommendCommands(D=!0){return R("[boolean]",[D],arguments.length),T(this,EF,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(R("<array|string|object> [number]",[D],arguments.length),typeof D==="string"&&X(this,I,"f").narg[D])return this;else this[qu](this.requiresArg.bind(this),"narg",D,NaN);return this}showCompletionScript(D,u){return R("[string] [string]",[D,u],arguments.length),D=D||this.$0,X(this,Du,"f").log(X(this,WD,"f").generateCompletionScript(D,u||X(this,MD,"f")||"completion")),this}showHelp(D){if(R("[string|function]",[D],arguments.length),T(this,VD,!0,"f"),!X(this,p,"f").hasCachedHelpMessage()){if(!this.parsed){let F=this[Pu](X(this,gD,"f"),void 0,void 0,0,!0);if(o(F))return F.then(()=>{X(this,p,"f").showHelp(D)}),this}let u=X(this,ED,"f").runDefaultBuilderOn(this);if(o(u))return u.then(()=>{X(this,p,"f").showHelp(D)}),this}return X(this,p,"f").showHelp(D),this}scriptName(D){return this.customScriptName=!0,this.$0=D,this}showHelpOnFail(D,u){return R("[boolean|string] [string]",[D,u],arguments.length),X(this,p,"f").showHelpOnFail(D,u),this}showVersion(D){return R("[string|function]",[D],arguments.length),X(this,p,"f").showVersion(D),this}skipValidation(D){return R("<array|string>",[D],arguments.length),this[kD]("skipValidation",D),this}strict(D){return R("[boolean]",[D],arguments.length),T(this,Eu,D!==!1,"f"),this}strictCommands(D){return R("[boolean]",[D],arguments.length),T(this,Cu,D!==!1,"f"),this}strictOptions(D){return R("[boolean]",[D],arguments.length),T(this,Bu,D!==!1,"f"),this}string(D){return R("<array|string>",[D],arguments.length),this[kD]("string",D),this[Gu](D),this}terminalWidth(){return R([],0),X(this,v,"f").process.stdColumns}updateLocale(D){return this.updateStrings(D)}updateStrings(D){return R("<object>",[D],arguments.length),T(this,eD,!1,"f"),X(this,v,"f").y18n.updateLocale(D),this}usage(D,u,F,E){if(R("<string|null|undefined> [string|boolean] [function|object] [function]",[D,u,F,E],arguments.length),u!==void 0)if(YD(D,null,X(this,v,"f")),(D||"").match(/^\$0( |$)/))return this.command(D,u,F,E);else throw new FD(".usage() description must start with $0 if being used as alias for .command()");else return X(this,p,"f").usage(D),this}usageConfiguration(D){return R("<object>",[D],arguments.length),T(this,CF,D,"f"),this}version(D,u,F){if(R("[boolean|string] [string] [string]",[D,u,F],arguments.length),X(this,wD,"f"))this[iF](X(this,wD,"f")),X(this,p,"f").version(void 0),T(this,wD,null,"f");if(arguments.length===0)F=this[r2](),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 T(this,wD,typeof D==="string"?D:"version","f"),u=u||X(this,p,"f").deferY18nLookup("Show version number"),X(this,p,"f").version(F||void 0),this.boolean(X(this,wD,"f")),this.describe(X(this,wD,"f"),u),this}wrap(D){return R("<number|null|undefined>",[D],arguments.length),X(this,p,"f").wrap(D),this}[(ED=new WeakMap,aD=new WeakMap,Su=new WeakMap,WD=new WeakMap,MD=new WeakMap,ru=new WeakMap,cD=new WeakMap,eD=new WeakMap,au=new WeakMap,KD=new WeakMap,eu=new WeakMap,jD=new WeakMap,PD=new WeakMap,VD=new WeakMap,AD=new WeakMap,DF=new WeakMap,Du=new WeakMap,JD=new WeakMap,I=new WeakMap,uF=new WeakMap,FF=new WeakMap,UD=new WeakMap,uu=new WeakMap,Uu=new WeakMap,Fu=new WeakMap,gD=new WeakMap,EF=new WeakMap,v=new WeakMap,Eu=new WeakMap,Cu=new WeakMap,Bu=new WeakMap,p=new WeakMap,CF=new WeakMap,wD=new WeakMap,DD=new WeakMap,i2)](D){if(!D._||!D["--"])return D;D._.push.apply(D._,D["--"]);try{delete D["--"]}catch(u){}return D}[n2](){return{log:(...D)=>{if(!this[BF]())console.log(...D);if(T(this,VD,!0,"f"),X(this,JD,"f").length)T(this,JD,X(this,JD,"f")+`
80
+ `,"f");T(this,JD,X(this,JD,"f")+D.join(" "),"f")},error:(...D)=>{if(!this[BF]())console.error(...D);if(T(this,VD,!0,"f"),X(this,JD,"f").length)T(this,JD,X(this,JD,"f")+`
81
+ `,"f");T(this,JD,X(this,JD,"f")+D.join(" "),"f")}}}[iF](D){Mu(X(this,I,"f")).forEach((u)=>{if(((E)=>E==="configObjects")(u))return;let F=X(this,I,"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 X(this,p,"f").getDescriptions()[D]}[t2](D,u,F){if(!X(this,au,"f")[F])X(this,v,"f").process.emitWarning(D,u),X(this,au,"f")[F]=!0}[l2](){X(this,eu,"f").push({options:X(this,I,"f"),configObjects:X(this,I,"f").configObjects.slice(0),exitProcess:X(this,KD,"f"),groups:X(this,PD,"f"),strict:X(this,Eu,"f"),strictCommands:X(this,Cu,"f"),strictOptions:X(this,Bu,"f"),completionCommand:X(this,MD,"f"),output:X(this,JD,"f"),exitError:X(this,cD,"f"),hasOutput:X(this,VD,"f"),parsed:this.parsed,parseFn:X(this,UD,"f"),parseContext:X(this,uu,"f")}),X(this,p,"f").freeze(),X(this,DD,"f").freeze(),X(this,ED,"f").freeze(),X(this,jD,"f").freeze()}[o2](){let D="",u;if(/\b(node|iojs|electron)(\.exe)?$/.test(X(this,v,"f").process.argv()[0]))u=X(this,v,"f").process.argv().slice(1,2);else u=X(this,v,"f").process.argv().slice(0,1);if(D=u.map((F)=>{let E=this[G8](X(this,aD,"f"),F);return F.match(/^(\/|([a-zA-Z]:)?\\)/)&&E.length<F.length?E:F}).join(" ").trim(),X(this,v,"f").getEnv("_")&&X(this,v,"f").getProcessArgvBin()===X(this,v,"f").getEnv("_"))D=X(this,v,"f").getEnv("_").replace(`${X(this,v,"f").path.dirname(X(this,v,"f").process.execPath())}/`,"");return D}[$u](){return X(this,FF,"f")}[s2](){return X(this,CF,"f")}[nF](){if(!X(this,eD,"f"))return;let D=X(this,v,"f").getEnv("LC_ALL")||X(this,v,"f").getEnv("LC_MESSAGES")||X(this,v,"f").getEnv("LANG")||X(this,v,"f").getEnv("LANGUAGE")||"en_US";this.locale(D.replace(/[.:].*/,""))}[r2](){return this[tF]().version||"unknown"}[a2](D){let u=D["--"]?D["--"]:D._;for(let F=0,E;(E=u[F])!==void 0;F++)if(X(this,v,"f").Parser.looksLikeNumber(E)&&Number.isSafeInteger(Math.floor(parseFloat(`${E}`))))u[F]=Number(E);return D}[tF](D){let u=D||"*";if(X(this,Uu,"f")[u])return X(this,Uu,"f")[u];let F={};try{let E=D||X(this,v,"f").mainFilename;if(X(this,v,"f").path.extname(E))E=X(this,v,"f").path.dirname(E);let C=X(this,v,"f").findUp(E,(B,$)=>{if($.includes("package.json"))return"package.json";else return});YD(C,void 0,X(this,v,"f")),F=JSON.parse(X(this,v,"f").readFileSync(C,"utf8"))}catch(E){}return X(this,Uu,"f")[u]=F||{},X(this,Uu,"f")[u]}[kD](D,u){u=[].concat(u),u.forEach((F)=>{F=this[sF](F),X(this,I,"f")[D].push(F)})}[qu](D,u,F,E){this[oF](D,u,F,E,(C,B,$)=>{X(this,I,"f")[C][B]=$})}[lF](D,u,F,E){this[oF](D,u,F,E,(C,B,$)=>{X(this,I,"f")[C][B]=(X(this,I,"f")[C][B]||[]).concat($)})}[oF](D,u,F,E,C){if(Array.isArray(F))F.forEach((B)=>{D(B,E)});else if(((B)=>typeof B==="object")(F))for(let B of Mu(F))D(B,F[B]);else C(u,this[sF](F),E)}[sF](D){if(D==="__proto__")return"___proto___";return D}[rF](D,u){return this[qu](this[rF].bind(this),"key",D,u),this}[aF](){var D,u,F,E,C,B,$,z,G,Z,Q,J;let Y=X(this,eu,"f").pop();YD(Y,void 0,X(this,v,"f"));let W;D=this,u=this,F=this,E=this,C=this,B=this,$=this,z=this,G=this,Z=this,Q=this,J=this,{options:{set value(H){T(D,I,H,"f")}}.value,configObjects:W,exitProcess:{set value(H){T(u,KD,H,"f")}}.value,groups:{set value(H){T(F,PD,H,"f")}}.value,output:{set value(H){T(E,JD,H,"f")}}.value,exitError:{set value(H){T(C,cD,H,"f")}}.value,hasOutput:{set value(H){T(B,VD,H,"f")}}.value,parsed:this.parsed,strict:{set value(H){T($,Eu,H,"f")}}.value,strictCommands:{set value(H){T(z,Cu,H,"f")}}.value,strictOptions:{set value(H){T(G,Bu,H,"f")}}.value,completionCommand:{set value(H){T(Z,MD,H,"f")}}.value,parseFn:{set value(H){T(Q,UD,H,"f")}}.value,parseContext:{set value(H){T(J,uu,H,"f")}}.value}=Y,X(this,I,"f").configObjects=W,X(this,p,"f").unfreeze(),X(this,DD,"f").unfreeze(),X(this,ED,"f").unfreeze(),X(this,jD,"f").unfreeze()}[e2](D,u){return rD(u,(F)=>{return D(F),F})}getInternalMethods(){return{getCommandInstance:this[D8].bind(this),getContext:this[u8].bind(this),getHasOutput:this[F8].bind(this),getLoggerInstance:this[E8].bind(this),getParseContext:this[C8].bind(this),getParserConfiguration:this[$u].bind(this),getUsageConfiguration:this[s2].bind(this),getUsageInstance:this[B8].bind(this),getValidationInstance:this[$8].bind(this),hasParseCallback:this[BF].bind(this),isGlobalContext:this[z8].bind(this),postProcess:this[zu].bind(this),reset:this[eF].bind(this),runValidation:this[D0].bind(this),runYargsParserAndExecuteCommands:this[Pu].bind(this),setHasOutput:this[Z8].bind(this)}}[D8](){return X(this,ED,"f")}[u8](){return X(this,Su,"f")}[F8](){return X(this,VD,"f")}[E8](){return X(this,Du,"f")}[C8](){return X(this,uu,"f")||{}}[B8](){return X(this,p,"f")}[$8](){return X(this,DD,"f")}[BF](){return!!X(this,UD,"f")}[z8](){return X(this,DF,"f")}[zu](D,u,F,E){if(F)return D;if(o(D))return D;if(!u)D=this[i2](D);if(this[$u]()["parse-positional-numbers"]||this[$u]()["parse-positional-numbers"]===void 0)D=this[a2](D);if(E)D=sD(D,this,X(this,jD,"f").getMiddleware(),!1);return D}[eF](D={}){T(this,I,X(this,I,"f")||{},"f");let u={};u.local=X(this,I,"f").local||[],u.configObjects=X(this,I,"f").configObjects||[];let F={};u.local.forEach((B)=>{F[B]=!0,(D[B]||[]).forEach(($)=>{F[$]=!0})}),Object.assign(X(this,Fu,"f"),Object.keys(X(this,PD,"f")).reduce((B,$)=>{let z=X(this,PD,"f")[$].filter((G)=>!(G in F));if(z.length>0)B[$]=z;return B},{})),T(this,PD,{},"f");let E=["array","boolean","string","skipValidation","count","normalize","number","hiddenOptions"],C=["narg","key","alias","default","defaultDescription","config","choices","demandedOptions","demandedCommands","deprecatedOptions"];if(E.forEach((B)=>{u[B]=(X(this,I,"f")[B]||[]).filter(($)=>!F[$])}),C.forEach((B)=>{u[B]=pD(X(this,I,"f")[B],($)=>!F[$])}),u.envPrefix=X(this,I,"f").envPrefix,T(this,I,u,"f"),T(this,p,X(this,p,"f")?X(this,p,"f").reset(F):h2(this,X(this,v,"f")),"f"),T(this,DD,X(this,DD,"f")?X(this,DD,"f").reset(F):k2(this,X(this,p,"f"),X(this,v,"f")),"f"),T(this,ED,X(this,ED,"f")?X(this,ED,"f").reset():I2(X(this,p,"f"),X(this,DD,"f"),X(this,jD,"f"),X(this,v,"f")),"f"),!X(this,WD,"f"))T(this,WD,y2(this,X(this,p,"f"),X(this,ED,"f"),X(this,v,"f")),"f");return X(this,jD,"f").reset(),T(this,MD,null,"f"),T(this,JD,"","f"),T(this,cD,null,"f"),T(this,VD,!1,"f"),this.parsed=!1,this}[G8](D,u){return X(this,v,"f").path.relative(D,u)}[Pu](D,u,F,E=0,C=!1){var B,$,z,G;let Z=!!F||C;D=D||X(this,gD,"f"),X(this,I,"f").__=X(this,v,"f").y18n.__,X(this,I,"f").configuration=this[$u]();let Q=!!X(this,I,"f").configuration["populate--"],J=Object.assign({},X(this,I,"f").configuration,{"populate--":!0}),Y=X(this,v,"f").Parser.detailed(D,Object.assign({},X(this,I,"f"),{configuration:{"parse-positional-numbers":!1,...J}})),W=Object.assign(Y.argv,X(this,uu,"f")),H=void 0,O=Y.aliases,q=!1,j=!1;if(Object.keys(W).forEach((N)=>{if(N===X(this,AD,"f")&&W[N])q=!0;else if(N===X(this,wD,"f")&&W[N])j=!0}),W.$0=this.$0,this.parsed=Y,E===0)X(this,p,"f").clearCachedHelpMessage();try{if(this[nF](),u)return this[zu](W,Q,!!F,!1);if(X(this,AD,"f")){if([X(this,AD,"f")].concat(O[X(this,AD,"f")]||[]).filter((e)=>e.length>1).includes(""+W._[W._.length-1]))W._.pop(),q=!0}T(this,DF,!1,"f");let N=X(this,ED,"f").getCommands(),k=((B=X(this,WD,"f"))===null||B===void 0?void 0:B.completionKey)?[($=X(this,WD,"f"))===null||$===void 0?void 0:$.completionKey,...(G=this.getAliases()[(z=X(this,WD,"f"))===null||z===void 0?void 0:z.completionKey])!==null&&G!==void 0?G:[]].some((c)=>Object.prototype.hasOwnProperty.call(W,c)):!1,w=q||k||C;if(W._.length){if(N.length){let c;for(let e=E||0,s;W._[e]!==void 0;e++)if(s=String(W._[e]),N.includes(s)&&s!==X(this,MD,"f")){let qD=X(this,ED,"f").runCommand(s,this,Y,e+1,C,q||j||C);return this[zu](qD,Q,!!F,!1)}else if(!c&&s!==X(this,MD,"f")){c=s;break}if(!X(this,ED,"f").hasDefaultCommand()&&X(this,EF,"f")&&c&&!w)X(this,DD,"f").recommendCommands(c,N)}if(X(this,MD,"f")&&W._.includes(X(this,MD,"f"))&&!k){if(X(this,KD,"f"))yD(!0);this.showCompletionScript(),this.exit(0)}}if(X(this,ED,"f").hasDefaultCommand()&&!w){let c=X(this,ED,"f").runCommand(null,this,Y,0,C,q||j||C);return this[zu](c,Q,!!F,!1)}if(k){if(X(this,KD,"f"))yD(!0);D=[].concat(D);let c=D.slice(D.indexOf(`--${X(this,WD,"f").completionKey}`)+1);return X(this,WD,"f").getCompletion(c,(e,s)=>{if(e)throw new FD(e.message);(s||[]).forEach((qD)=>{X(this,Du,"f").log(qD)}),this.exit(0)}),this[zu](W,!Q,!!F,!1)}if(!X(this,VD,"f")){if(q){if(X(this,KD,"f"))yD(!0);Z=!0,this.showHelp((c)=>{X(this,Du,"f").log(c),this.exit(0)})}else if(j){if(X(this,KD,"f"))yD(!0);Z=!0,X(this,p,"f").showVersion("log"),this.exit(0)}}if(!Z&&X(this,I,"f").skipValidation.length>0)Z=Object.keys(W).some((c)=>X(this,I,"f").skipValidation.indexOf(c)>=0&&W[c]===!0);if(!Z){if(Y.error)throw new FD(Y.error.message);if(!k){let c=this[D0](O,{},Y.error);if(!F)H=sD(W,this,X(this,jD,"f").getMiddleware(),!0);if(H=this[e2](c,H!==null&&H!==void 0?H:W),o(H)&&!F)H=H.then(()=>{return sD(W,this,X(this,jD,"f").getMiddleware(),!1)})}}}catch(N){if(N instanceof FD)X(this,p,"f").fail(N.message,N);else throw N}return this[zu](H!==null&&H!==void 0?H:W,Q,!!F,!0)}[D0](D,u,F,E){let C={...this.getDemandedOptions()};return(B)=>{if(F)throw new FD(F.message);X(this,DD,"f").nonOptionCount(B),X(this,DD,"f").requiredArguments(B,C);let $=!1;if(X(this,Cu,"f"))$=X(this,DD,"f").unknownCommands(B);if(X(this,Eu,"f")&&!$)X(this,DD,"f").unknownArguments(B,D,u,!!E);else if(X(this,Bu,"f"))X(this,DD,"f").unknownArguments(B,D,{},!1,!1);X(this,DD,"f").limitedChoices(B),X(this,DD,"f").implications(B),X(this,DD,"f").conflicting(B)}}[Z8](){T(this,VD,!0,"f")}[Gu](D){if(typeof D==="string")X(this,I,"f").key[D]=!0;else for(let u of D)X(this,I,"f").key[u]=!0}}function b2(D){return!!D&&typeof D.getInternalMethods==="function"}var s3=J8(yF),Q8=s3;import{existsSync as $F,readFileSync as E0,writeFileSync as u0,mkdirSync as W8}from"node:fs";import{homedir as r3}from"node:os";import{join as Zu,dirname as C0}from"node:path";function B0(){return process.env.HOME||r3()}function H8(){return Zu(B0(),".config","slack-cli","profiles.json")}function zF(){return Zu(process.cwd(),".slack-cli","workspace")}function GF(){return Zu(B0(),".slack-cli","workspace")}function wu(){let D=H8();if(!$F(D))return{profiles:{}};return JSON.parse(E0(D,"utf8"))}function a3(D){let u=H8();W8(C0(u),{recursive:!0}),u0(u,JSON.stringify(D,null,2)+`
82
+ `)}function _u(D){if(!$F(D))return;return E0(D,"utf8").trim()||void 0}function O8(D,u){let F=C0(D);W8(F,{recursive:!0});let E=Zu(F,".gitignore");if(!$F(E))u0(E,`*
83
+ `);u0(D,u+`
84
+ `)}function e3(D){let u={};for(let F of D.split(`
85
+ `)){let E=F.trim();if(!E||E.startsWith("#"))continue;let C=E.indexOf("=");if(C===-1)continue;let B=E.slice(0,C).trim(),$=E.slice(C+1).trim();if($.startsWith('"')&&$.endsWith('"')||$.startsWith("'")&&$.endsWith("'"))$=$.slice(1,-1);u[B]=$}return u}function Y8(D){if(!$F(D))return{};try{return e3(E0(D,"utf8"))}catch{return{}}}function F0(D,u){let F=B0(),E=D;while(!0){for(let $ of[Zu(E,".slack-term",".env.local"),Zu(E,".env.local")]){let z=Y8($);for(let G of u)if(z[G])return z[G]}if(E===F)break;let B=C0(E);if(B===E)break;E=B}let C=Y8(Zu(F,".slack-term",".env.local"));for(let B of u)if(C[B])return C[B];return}function M8(){let D=wu(),u=_u(zF()),F=_u(GF()),E=u??F;return Object.entries(D.profiles).map(([C,B])=>({name:C,profile:B,current:C===E}))}function V8(D){let u=wu();if(!(D in u.profiles))throw Error(`Profile not found: ${D}`);delete u.profiles[D],a3(u)}function U8(D,u=!1){let F=wu();if(!(D in F.profiles))throw Error(`Profile not found: ${D}`);if(u)O8(GF(),D);else O8(zF(),D)}function $0(D){let F=wu().profiles,E=Object.keys(F);if(D){let Z=F[D];if(!Z)throw Error(`Workspace "${D}" not found. Available: ${E.join(", ")||"(none)"}`);return Z.token}if(process.env.SLACK_TOKEN)return process.env.SLACK_TOKEN;let C=process.env.SLACK_BOT_TOKEN??process.env.SLACK_MCP_XOXP_TOKEN;if(C&&E.length===0)return C;if(C&&E.length>0){let Z=F0(process.cwd(),["SLACK_BOT_TOKEN","SLACK_MCP_XOXP_TOKEN"]);if(C!==Z){if(!globalThis.__slackEnvWarnShown)globalThis.__slackEnvWarnShown=!0,console.error(`Warning: SLACK_MCP_XOXP_TOKEN / SLACK_BOT_TOKEN is set but workspace profiles exist using profiles.
86
+ `+" Migrate to SLACK_TOKEN=... or remove from your shell config.")}}let B=F0(process.cwd(),["SLACK_TOKEN"]);if(B)return B;let $=process.env.SLACK_WORKSPACE;if($){let Z=F[$];if(!Z)throw Error(`Workspace "${$}" not found. Available: ${E.join(", ")||"(none)"}`);return Z.token}let z=_u(zF());if(z){let Z=F[z];if(!Z)throw Error(`Workspace "${z}" (from .slack-cli/workspace) not found in profiles.`);return Z.token}let G=_u(GF());if(G){let Z=F[G];if(!Z)throw Error(`Workspace "${G}" (from ~/.slack-cli/workspace) not found in profiles.`);return Z.token}if(E.length>0)throw Error(`Workspace not selected (${E.join(", ")} available).
86
87
  Select locally: slack workspace use <name> (writes .slack-cli/workspace)
87
- Select globally: slack workspace use -g <name> (writes ~/.slack-cli/workspace)`)}function d2(D){let F=Ku().profiles;if(process.env.SLACK_MCP_XOXP_TOKEN)return process.env.SLACK_MCP_XOXD_COOKIE;let C=D??process.env.SLACK_WORKSPACE;if(C)return F[C]?.cookie;let B=Qu(su());if(B)return F[B]?.cookie;let $=Qu(ru());if($)return F[$]?.cookie;return}import{createInterface as j3}from"node:readline/promises";import{existsSync as t2,readFileSync as l2,writeFileSync as C3,mkdirSync as B3}from"node:fs";import{homedir as $3}from"node:os";import{join as nF,dirname as z3}from"node:path";function o2(){return process.env.HOME||$3()}function s2(){return nF(o2(),".config","slack-cli","profiles.json")}function G3(){return nF(process.cwd(),".slack-cli","workspace")}function Z3(){return nF(o2(),".slack-cli","workspace")}function r2(){let D=s2();if(!t2(D))return{profiles:{}};return JSON.parse(l2(D,"utf8"))}function X3(D){let u=s2();B3(z3(u),{recursive:!0}),C3(u,JSON.stringify(D,null,2)+`
88
- `)}function g2(D){if(!t2(D))return;return l2(D,"utf8").trim()||void 0}function a2(){let D=r2(),u=g2(G3()),F=g2(Z3()),E=u??F;return Object.entries(D.profiles).map(([C,B])=>({name:C,profile:B,current:C===E}))}function kF(D,u){let F=r2();F.profiles[D]=u,X3(F)}class Tu extends Error{retryAfter;constructor(D){super(`Slack rate limited — retry after ${D}s`);this.name="RateLimitError",this.retryAfter=D}}function J3(){return(process.env.SLACK_API_BASE??"https://slack.com/api").replace(/\/$/,"")}async function Q3(D,u,F,E){let C={};if(E)C.Cookie=`d=${E}`;let B=await fetch(`${J3()}/${u}`,{...F,headers:{...F.headers??{},Authorization:`Bearer ${D}`,...C}});if(B.status===429){let z=parseInt(B.headers.get("retry-after")??"60",10);throw new Tu(isNaN(z)?60:z)}let $=await B.json();if($.ok!==!0){let z=$.error??"unknown";if(z==="ratelimited")throw new Tu(60);if(z==="invalid_auth"&&D.startsWith("xoxc-")&&!E)throw Error(`Desktop app token (xoxc-) is not accepted by the public Slack API.
88
+ Select globally: slack workspace use -g <name> (writes ~/.slack-cli/workspace)`);throw Error(`No Slack token found.
89
+ Run one of:
90
+ `+` slack auth token — paste an existing xoxp-/xoxb- token
91
+ `+` slack auth chrome — import from Chrome browser (macOS)
92
+ `+` slack auth app — guided Slack app creation
93
+ `+" Or set SLACK_TOKEN=xoxp-... in .slack-term/.env.local")}function z0(){let D=process.env.SLACK_BOT_TOKEN;return D&&D.startsWith("xoxb-")?D:void 0}function q8(D){let F=wu().profiles;if(D)return F[D]?.cookie;if(process.env.SLACK_COOKIE)return process.env.SLACK_COOKIE;if(process.env.SLACK_MCP_XOXD_COOKIE)return process.env.SLACK_MCP_XOXD_COOKIE;if(process.env.SLACK_MCP_XOXP_TOKEN&&Object.keys(F).length===0)return process.env.SLACK_MCP_XOXD_COOKIE;let C=F0(process.cwd(),["SLACK_COOKIE"]);if(C)return C;let B=process.env.SLACK_WORKSPACE;if(B)return F[B]?.cookie;let $=_u(zF());if($)return F[$]?.cookie;let z=_u(GF());if(z)return F[z]?.cookie;return}class dD extends Error{retryAfter;constructor(D){super(`Slack rate limited — retry after ${D}s`);this.name="RateLimitError",this.retryAfter=D}}function G0(){return(process.env.SLACK_API_BASE??"https://slack.com/api").replace(/\/$/,"")}async function _8(D,u,F,E){let C={};if(E)C.Cookie=`d=${E}`;let B=await fetch(`${G0()}/${u}`,{...F,headers:{...F.headers??{},Authorization:`Bearer ${D}`,...C}});if(B.status===429){let z=parseInt(B.headers.get("retry-after")??"60",10);throw new dD(isNaN(z)?60:z)}let $=await B.json();if($.ok!==!0){let z=$.error??"unknown";if(z==="ratelimited")throw new dD(60);if(z==="invalid_auth"&&D.startsWith("xoxc-")&&!E)throw Error(`Desktop app token (xoxc-) is not accepted by the public Slack API.
89
94
  Replace it with an xoxp- user token:
90
- slack workspace set-token <name> <xoxp-token>`);throw Error(`Slack error on ${u}: ${z}`)}return $}function pD(D,u,F,E){let C=new URLSearchParams(F).toString();return Q3(D,`${u}?${C}`,{method:"GET"},E)}async function eu(D){let u=await pD(D,"auth.test",{});return{team:u.team??"",teamId:u.team_id??"",url:u.url??"",user:u.user??"",userId:u.user_id??""}}async function dF(D,u,F=20,E,C){let B={channel:u,limit:String(F)};if(E!==void 0)B.oldest=E;if(C!==void 0)B.cursor=C;return pD(D,"conversations.history",B)}function au(D){return D.toLowerCase().replace(/[-_\s]/g,"")}function O3(D){let u=D.match(/(?:app\.slack\.com\/client\/T[A-Za-z0-9]+|[A-Za-z0-9-]+\.slack\.com\/archives)\/([A-Za-z0-9]+)(?:\/p(\d{10})(\d{6}))?/);if(!u)return;let F=u[1],E=u[2]&&u[3]?`${u[2]}.${u[3]}`:void 0;return E?{channel:F,ts:E}:{channel:F}}function Y3(D){return O3(D)?.channel}async function e2(D,u,F){let E=Y3(u);if(E)return E;if(!u.startsWith("@")&&!u.startsWith("#")){if(/^[A-Za-z0-9]{9,}$/.test(u))return u;throw Error(`Target must start with # or @ (or be a Slack URL/ID), got: ${u}`)}let C=u.startsWith("@"),B=u.slice(1),$=au(B);if(C){let J="",O="";while(!0){let Q={limit:"200"};if(O)Q.cursor=O;let Y=await pD(D,"users.list",Q,F);for(let M of Y.members??[]){let H=au(M.name??""),_=au(M.real_name??""),S=au(M.profile?.display_name??"");if(H===$||_===$||S&&S===$){J=M.id??"";break}}if(J)break;if(O=Y.response_metadata?.next_cursor??"",!O)break}if(!J)throw Error(`User not found: ${u}`);let X="";while(!0){let Q={types:"im",limit:"200"};if(X)Q.cursor=X;let Y=await pD(D,"conversations.list",Q,F);for(let M of Y.channels??[])if(M.user===J)return String(M.id??"");if(X=Y.response_metadata?.next_cursor??"",!X)break}throw Error(`No existing DM with ${u} (${J}). Open it once in Slack first.`)}let z=B.toLowerCase(),Z="";while(!0){let J={limit:"200",types:"public_channel,private_channel",exclude_archived:"true"};if(Z)J.cursor=Z;let O=await pD(D,"conversations.list",J,F);for(let X of O.channels??[])if(String(X.name??"").toLowerCase()===z)return String(X.id??"");if(Z=O.response_metadata?.next_cursor??"",!Z)break}throw Error(`channel not found: ${u}`)}async function D8(D,u){try{let F=await pD(D,"users.info",{user:u}),E=F.user?.profile?.display_name,C=E&&E.length>0?E:F.user?.real_name??F.user?.name??u,B=F.user?.name??u;return[C,B]}catch{return[u,u]}}async function DF(D,u){try{let F=await pD(D,"users.info",{user:u}),E=F.user?.profile?.display_name;if(E&&E.length>0)return E;return F.user?.real_name??F.user?.name??u}catch{return u}}async function u8(D,u){return pD(D,"conversations.info",{channel:u})}import{readdirSync as F8,readFileSync as E8,existsSync as C8}from"node:fs";import{homedir as B8}from"node:os";import{join as Du}from"node:path";import{pbkdf2Sync as W3,createDecipheriv as M3}from"node:crypto";import{execSync as H3}from"node:child_process";function V3(){let D=B8();if(process.platform==="darwin")return Du(D,"Library","Application Support","Slack","Local Storage","leveldb");if(process.platform==="linux")return Du(D,".config","Slack","Local Storage","leveldb");if(process.platform==="win32"){let u=process.env.APPDATA??Du(D,"AppData","Roaming");return Du(u,"Slack","Local Storage","leveldb")}throw Error(`Unsupported platform: ${process.platform}`)}function q3(){let D=B8();if(process.platform==="darwin")return Du(D,"Library","Application Support","Slack","Cookies");return""}function U3(D,u){if(D.length<35||D.slice(0,3).toString()!=="v10")throw Error("Not a v10 encrypted cookie");let F=D.slice(19,35),E=D.slice(35),C=M3("aes-128-cbc",u,F);return C.setAutoPadding(!0),Buffer.concat([C.update(E),C.final()]).toString("utf8")}function _3(){if(process.platform!=="darwin")return;let D=q3();if(!C8(D))return;let u;try{u=H3('security find-generic-password -w -s "Slack Safe Storage" -a "Slack Key"',{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trimEnd()}catch{return}let F=W3(u,"saltysalt",1003,16,"sha1");try{let{default:E}=zu("bun:sqlite"),C=new E(D,{readonly:!0}),B=C.prepare("SELECT encrypted_value FROM cookies WHERE name='d' AND host_key LIKE '%slack%'").get();if(C.close(),!B)return;return U3(Buffer.from(B.encrypted_value),F)}catch{return}}async function $8(){let D=V3();if(!C8(D))throw Error(`Slack desktop app LevelDB not found at:
95
+ slack workspace set-token <name> <xoxp-token>`);throw Error(`Slack error on ${u}: ${z}`)}return $}async function D6(D,u,F,E){let C={};if(E)C.Cookie=`d=${E}`;let B=await fetch(`${G0()}/${u}`,{...F,headers:{...F.headers??{},Authorization:`Bearer ${D}`,...C}});if(B.status===429){let z=parseInt(B.headers.get("retry-after")??"60",10);throw new dD(isNaN(z)?60:z)}let $=await B.json();if($.ok!==!0){let z=$.error??"unknown";if(z==="ratelimited")throw new dD(60);if((z==="invalid_auth"||z==="not_authed")&&!D.startsWith("xoxc-"))throw Error(`The draft API requires a desktop app session token (xoxc-).
96
+ Import from Slack desktop: slack workspace import`);if((z==="invalid_auth"||z==="not_authed")&&!E)throw Error(`drafts.list also requires the xoxd session cookie.
97
+ Set it with: slack workspace set-cookie <workspace-name> <xoxd-value>
98
+ `+"Get xoxd from browser: DevTools → Application → Cookies → slack.com → d");throw Error(`Slack error on ${u}: ${z}`)}return $}function u6(D,u,F={},E){let C=new URLSearchParams({token:D,...F});return D6(D,u,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:C.toString()},E)}function LD(D,u,F,E){let C=new URLSearchParams(F).toString();return _8(D,`${u}?${C}`,{method:"GET"},E)}function F6(D,u,F){return _8(D,u,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(F)})}async function ZF(D){let u=await LD(D,"auth.test",{});return{team:u.team??"",teamId:u.team_id??"",url:u.url??"",user:u.user??"",userId:u.user_id??""}}async function K8(D){let u=await fetch(`${G0()}/auth.test`,{method:"GET",headers:{Authorization:`Bearer ${D}`}});if(u.status===429){let C=parseInt(u.headers.get("retry-after")??"60",10);throw new dD(isNaN(C)?60:C)}let F=u.headers.get("x-oauth-scopes")??"",E=await u.json();if(E.ok!==!0)throw Error(`Slack error on auth.test: ${E.error??"unknown"}`);return{userId:E.user_id??"",botId:E.bot_id??"",team:E.team??"",url:E.url??"",scopes:F.split(",").map((C)=>C.trim()).filter(Boolean)}}async function j8(D,u){let F=await LD(D,"bots.info",{bot:u});return{appId:F.bot?.app_id??"",userId:F.bot?.user_id??""}}async function Z0(D,u,F=20,E,C){let B={channel:u,limit:String(F)};if(E!==void 0)B.oldest=E;if(C!==void 0)B.cursor=C;return LD(D,"conversations.history",B)}async function A8(D,u,F,E=50){return LD(D,"conversations.replies",{channel:u,ts:F,limit:String(E)})}async function E6(D,u){let E=(await F6(D,"conversations.open",{users:u})).channel?.id;if(!E)throw Error(`Failed to open DM with user ${u}`);return E}function xu(D){return D.toLowerCase().replace(/[-_\s]/g,"")}function J0(D){let u=D.match(/(?:app\.slack\.com\/client\/T[A-Za-z0-9]+|[A-Za-z0-9-]+\.slack\.com\/archives)\/([A-Za-z0-9]+)(?:\/p(\d{10})(\d{6}))?/);if(!u)return;let F=u[1],E=u[2]&&u[3]?`${u[2]}.${u[3]}`:void 0,C=D.indexOf("?"),B=C>=0?new URLSearchParams(D.slice(C)):void 0,$=B?.get("thread_ts")??void 0,Z={channel:B?.get("cid")??void 0??F};if(E)Z.ts=E;if($)Z.threadTs=$;return Z}function C6(D){return J0(D)?.channel}async function L8(D,u,F){let E=C6(u);if(E)return E;if(!u.startsWith("@")&&!u.startsWith("#")){if(/^[A-Za-z0-9]{9,}$/.test(u))return u;throw Error(`Target must start with # or @ (or be a Slack URL/ID), got: ${u}`)}let C=u.startsWith("@"),B=u.slice(1),$=xu(B);if(C){let Z=await LD(D,"auth.test",{},F);if($==="you"||$==="me"||xu(Z.user??"")===$){let H=Z.user_id;if(!H)throw Error("auth.test did not return user_id");let q=((await LD(D,"conversations.list",{types:"im",limit:"200"},F)).channels??[]).find((j)=>j.user===H);if(q?.id)return String(q.id);return E6(D,H)}let J="",Y="";while(!0){let H={limit:"200"};if(Y)H.cursor=Y;let O=await LD(D,"users.list",H,F);for(let q of O.members??[]){let j=xu(q.name??""),N=xu(q.real_name??""),k=xu(q.profile?.display_name??"");if(j===$||N===$||k&&k===$){J=q.id??"";break}}if(J)break;if(Y=O.response_metadata?.next_cursor??"",!Y)break}if(!J)throw Error(`User not found: ${u}`);let W="";while(!0){let H={types:"im",limit:"200"};if(W)H.cursor=W;let O=await LD(D,"conversations.list",H,F);for(let q of O.channels??[])if(q.user===J)return String(q.id??"");if(W=O.response_metadata?.next_cursor??"",!W)break}throw Error(`No existing DM with ${u} (${J}). Open it once in Slack first.`)}let z=B.toLowerCase(),G="";while(!0){let Z={limit:"200",types:"public_channel,private_channel",exclude_archived:"true"};if(G)Z.cursor=G;let Q=await LD(D,"conversations.list",Z,F);for(let J of Q.channels??[])if(String(J.name??"").toLowerCase()===z)return String(J.id??"");if(G=Q.response_metadata?.next_cursor??"",!G)break}throw Error(`channel not found: ${u}`)}async function JF(D,u){try{let F=await LD(D,"users.info",{user:u}),E=F.user?.profile?.display_name,C=E&&E.length>0?E:F.user?.real_name??F.user?.name??u,B=F.user?.name??u;return[C,B]}catch{return[u,u]}}async function XF(D,u){try{let F=await LD(D,"users.info",{user:u}),E=F.user?.profile?.display_name;if(E&&E.length>0)return E;return F.user?.real_name??F.user?.name??u}catch{return u}}async function N8(D,u){return LD(D,"conversations.info",{channel:u})}async function R8(D,u){let F=await u6(D,"client.boot",{},u),E=typeof F.url==="string"?F.url:void 0;if(!E){let B=Object.keys(F).join(", ");throw Error(`client.boot did not return a WebSocket URL. Keys: ${B}`)}let C=F.self&&typeof F.self==="object"&&!Array.isArray(F.self)?F.self:{};return{wsUrl:E,selfId:typeof C.id==="string"?C.id:""}}var B6=["chat:write","im:write"],$6=["im:history","im:read"];async function X0(D){let{userId:u,botId:F,team:E,scopes:C}=await K8(D),B="";if(F)try{B=(await j8(D,F)).appId}catch{B=""}let $=(Z)=>C.includes(Z),z=B6.filter((Z)=>!$(Z)),G=$6.filter((Z)=>!$(Z));return{canSend:z.length===0,canReceiveReplies:G.length===0,ok:z.length===0&&G.length===0,botUserId:u,appId:B,team:E,grantedScopes:C,missingSendScopes:z,missingReplyScopes:G}}function T8(D){return["",` Bot user: ${D.botUserId||"(unknown)"}`,` App ID: ${D.appId||"(unknown — bots.info unavailable)"}`,` Granted scopes: ${D.grantedScopes.join(", ")||"(none reported)"}`]}function Q0(D,u=!1){let F=D.appId?`https://api.slack.com/apps/${D.appId}`:"https://api.slack.com/apps";if(D.ok){let C=["✓ Bot DM scopes are complete (send + read replies)."," Two-way replies also require the Messages Tab, which is not API-detectable.",' If recipients see "Sending messages to this app is turned off", enable it:',` ${F} → App Home → "Messages Tab" ON + "Allow users to send messages".`];return u?C:[...C,...T8(D)]}let E=[];if(!D.canSend)E.push(`⚠ This bot CANNOT send DMs — missing scope(s): ${D.missingSendScopes.join(", ")}.`);else E.push("⚠ This bot can send DMs, but the user's replies will NOT be readable.");return E.push(" Make escalation DMs two-way:"),E.push(` 1. ${F} → App Home → enable "Messages Tab" and check`),E.push(' "Allow users to send Slash commands and messages".'),E.push(` 2. OAuth & Permissions → add Bot Token Scopes: ${[...D.missingSendScopes,...D.missingReplyScopes].join(", ")}`),E.push(" 3. Reinstall the app to apply the new scopes."),u?E:[...E,...T8(D)]}import{createInterface as Xu}from"node:readline/promises";import{join as U0}from"node:path";import{homedir as U6}from"node:os";import{existsSync as O0,readFileSync as Y0,writeFileSync as P8,mkdirSync as w8}from"node:fs";import{homedir as z6}from"node:os";import{join as W0,dirname as x8}from"node:path";function I8(){return process.env.HOME||z6()}function b8(){return W0(I8(),".config","slack-cli","profiles.json")}function G6(){return W0(process.cwd(),".slack-cli","workspace")}function Z6(){return W0(I8(),".slack-cli","workspace")}function H0(){let D=b8();if(!O0(D))return{profiles:{}};return JSON.parse(Y0(D,"utf8"))}function f8(D){let u=b8();w8(x8(u),{recursive:!0}),P8(u,JSON.stringify(D,null,2)+`
99
+ `)}function S8(D){if(!O0(D))return;return Y0(D,"utf8").trim()||void 0}function h8(D,u){w8(x8(D),{recursive:!0});let F=O0(D)?Y0(D,"utf8"):"",E=F?F.split(`
100
+ `):[];for(let[C,B]of Object.entries(u)){let $=E.findIndex((G)=>{let Z=G.trim();return Z.startsWith(C+"=")||Z.startsWith(C+" =")}),z=`${C}=${B}`;if($!==-1)E[$]=z;else E.push(z)}P8(D,E.join(`
101
+ `).trimEnd()+`
102
+ `)}function QF(){let D=H0(),u=S8(G6()),F=S8(Z6()),E=u??F;return Object.entries(D.profiles).map(([C,B])=>({name:C,profile:B,current:C===E}))}function M0(D,u){let F=H0();F.profiles[D]=u,f8(F)}function V0(D,u){let F=H0();if(!(D in F.profiles))throw Error(`Profile not found: ${D}`);F.profiles[D].cookie=u,f8(F)}import{readdirSync as OF,readFileSync as YF,existsSync as Ju,copyFileSync as v8,unlinkSync as m8}from"node:fs";import{homedir as WF,tmpdir as p8}from"node:os";import{join as XD,dirname as J6}from"node:path";import{pbkdf2Sync as y8,createDecipheriv as c8}from"node:crypto";import{execSync as g8}from"node:child_process";function X6(){let D=WF();if(process.platform==="darwin")return XD(D,"Library","Application Support","Slack","Local Storage","leveldb");if(process.platform==="linux")return XD(D,".config","Slack","Local Storage","leveldb");if(process.platform==="win32"){let u=process.env.APPDATA??XD(D,"AppData","Roaming");return XD(u,"Slack","Local Storage","leveldb")}throw Error(`Unsupported platform: ${process.platform}`)}function Q6(){let D=WF();if(process.platform==="darwin")return XD(D,"Library","Application Support","Slack","Cookies");return""}function O6(D,u){if(D.length<35||D.slice(0,3).toString()!=="v10")throw Error("Not a v10 encrypted cookie");let F=D.slice(19,35),E=D.slice(35),C=c8("aes-128-cbc",u,F);return C.setAutoPadding(!0),Buffer.concat([C.update(E),C.final()]).toString("utf8")}function Y6(){if(process.platform!=="darwin")return;let D=Q6();if(!Ju(D))return;let u;try{u=g8('security find-generic-password -w -s "Slack Safe Storage" -a "Slack Key"',{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trimEnd()}catch{return}let F=y8(u,"saltysalt",1003,16,"sha1");try{let{default:E}=vD("bun:sqlite"),C=new E(D,{readonly:!0}),B=C.prepare("SELECT encrypted_value FROM cookies WHERE name='d' AND host_key LIKE '%slack%'").get();if(C.close(),!B)return;return O6(Buffer.from(B.encrypted_value),F)}catch{return}}async function k8(){let D=X6();if(!Ju(D))throw Error(`Slack desktop app LevelDB not found at:
91
103
  ${D}
92
- Is Slack installed and opened at least once?`);let u=F8(D).filter((z)=>z.endsWith(".ldb")||z.endsWith(".log"));if(u.length===0)throw Error(`No LevelDB data files found in ${D}`);let F=new Map;for(let z of u){let Z;try{Z=E8(Du(D,z),"latin1")}catch{continue}if(z.endsWith(".log"))for(let J of Z.matchAll(/"token":"(xoxc-[^"]+)"/g)){let O=J[1],X=O.split("-")[1]??"";if(!X||O.length<40)continue;let Q=Math.max(0,J.index-2000),Y=Math.min(Z.length,J.index+2000),M=Z.slice(Q,Y),H=M.match(/"url":"(https:\/\/[a-z0-9-]+\.slack\.com\/)"/),_=M.match(/"(?:team_name|name)":"([^"]{2,60})"/),S=F.get(X);if(!S||O.length>S.token.length){let f={token:O,teamId:X},d=H?.[1]??S?.url,x=_?.[1]??S?.teamName;if(d)f.url=d;if(x)f.teamName=x;F.set(X,f)}}else for(let J of Z.matchAll(/xoxc-(\d+)-(\d+)-(\d+)/g)){let O=J[1];if(F.has(O))continue;let X=J.index+J[0].length,Q=Math.min(X+10,Z.length);while(X<Q&&(Z.charCodeAt(X)<48||Z.charCodeAt(X)>57))X++;let Y="";while(X<Z.length&&Z.charCodeAt(X)>=48&&Z.charCodeAt(X)<=57)Y+=Z[X++];if(Z[X]!=="-")continue;X++;let M="";while(X<Z.length){let _=Z.charCodeAt(X);if(_>=48&&_<=57||_>=97&&_<=102)M+=Z[X++];else break}if(M.length<20)continue;let H=`${J[0]}${Y}-${M}`;F.set(O,{token:H,teamId:O})}}let C=F8(D).filter((z)=>z.endsWith(".ldb")||z.endsWith(".log")).map((z)=>{try{return E8(Du(D,z),"latin1").replace(/[^\x20-\x7e]/g," ")}catch{return""}}).join(" ");for(let z of F.values()){if(z.teamName)continue;let Z=C.indexOf(z.teamId);if(Z!==-1){let J=Math.max(0,Z-500),O=Math.min(C.length,Z+500),Q=C.slice(J,O).match(/"(?:team_name|name)":"([^"]{2,60})"/);if(Q?.[1]){z.teamName=Q[1];continue}}if(!z.teamName&&z.url){let J=z.url.match(/https:\/\/([a-z0-9-]+)\.slack\.com\//)?.[1];if(J){let O=C.indexOf(J);if(O!==-1){let X=Math.max(0,O-500),Q=Math.min(C.length,O+500),M=C.slice(X,Q).match(/"(?:team_name|name)":"([^"]{2,60})"/);if(M?.[1]){z.teamName=M[1];continue}}z.teamName=J.split("-").map((X)=>X.charAt(0).toUpperCase()+X.slice(1)).join(" ")}}}let B=_3(),$=[...F.values()];if(B)for(let z of $)z.cookie=B;return $}var K3=["search:read","channels:history","groups:history","im:history","mpim:history","channels:read","groups:read","im:read","mpim:read","users:read","chat:write","files:write"],T3=["channels:history","groups:history","im:history","mpim:history","channels:read","groups:read","im:read","mpim:read","users:read","chat:write","files:write"];function gF(D){return D.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function N3(){return JSON.stringify({display_information:{name:"slack-term"},oauth_config:{scopes:{user:K3}},settings:{org_deploy_enabled:!1,socket_mode_enabled:!1,token_rotation_enabled:!1}},null,2)}function R3(){return JSON.stringify({display_information:{name:"slack-term"},features:{bot_user:{display_name:"slack-term",always_online:!1}},oauth_config:{scopes:{bot:T3}},settings:{org_deploy_enabled:!1,socket_mode_enabled:!1,token_rotation_enabled:!1}},null,2)}async function Nu(D,u){return(await D.question(u)).trim()}async function uF(D,u,F){console.error("Verifying token...");let E=await eu(u),C=gF(E.team),B;if(F)B=F;else if(D)B=await Nu(D,`Workspace name [${C}]: `)||C;else B=C;if(kF(B,{token:u,...E}),console.log(`Saved workspace "${B}": ${E.team} (${E.user})`),process.env.SLACK_MCP_XOXP_TOKEN)console.log(""),console.log("Warning: SLACK_MCP_XOXP_TOKEN is set in your environment - it conflicts with profiles."),console.log(" Unset it so your new profile is used:"),console.log(" unset SLACK_MCP_XOXP_TOKEN"),console.log(" Also remove it from your shell config (~/.zshrc, ~/.bashrc, etc.)");else console.log(` Run: slack auth use -g ${B}`);return B}async function A3(){console.error("Scanning Slack desktop app...");let D=await $8();if(D.length===0)console.error("No sessions found. Make sure Slack is installed and you have signed in at least once."),process.exit(1);for(let u of D){let F=u.teamName??u.teamId,E=gF(F);kF(E,{token:u.token,team:F,teamId:u.teamId,url:u.url??"",user:"",...u.cookie?{cookie:u.cookie}:{}}),console.log(`Added workspace "${E}": ${F}${u.cookie?" + xoxd cookie":""}`)}if(console.log(""),D.length===1){let u=gF(D[0].teamName??D[0].teamId);console.log(`Run: slack auth use -g ${u}`)}else console.log("Run: slack auth ls then: slack auth use -g <name>");console.log(""),console.log("Note: desktop app tokens (xoxc-) are internal Slack tokens."),console.log("If API calls fail, replace with an xoxp- user token by re-running: slack auth login")}async function L3(D){console.log("Which token type does your app use?"),console.log(""),console.log(" 1) User token (xoxp-) -full access including search [recommended]"),console.log(" 2) Bot token (xoxb-) -search and news unavailable"),console.log("");let F=await Nu(D,"Choice [1/2]: ")==="2"?"bot":"user",E=F==="user"?"xoxp-":"xoxb-",C=F==="user"?"User OAuth Token":"Bot User OAuth Token";console.log(""),console.log("Find your token here:"),console.log(" https://api.slack.com/apps"),console.log(" -> Select your app -> OAuth & Permissions"),console.log(` -> Copy the "${C}" (starts with ${E})`),console.log("");let B=await Nu(D,"Paste your token: ");if(!B)console.error("No token provided."),process.exit(1);if(!B.startsWith(E))console.error(`Expected a ${E} token, got: ${B.slice(0,10)}...`),process.exit(1);await uF(D,B)}async function z8(D,u){let F=u==="user"?N3():R3(),E=u==="user"?"User OAuth Token (xoxp-...)":"Bot User OAuth Token (xoxb-...)",C=u==="user"?"xoxp-":"xoxb-";if(u==="bot")console.log("Note: bot tokens cannot use search:read (user-only scope)."),console.log(" The news and search commands will not work with a bot token."),console.log("");console.log("Step 1 -Create your Slack app:"),console.log(" Open: https://api.slack.com/apps"),console.log(' Click "Create New App" -> "From a manifest" -> select your workspace'),console.log(" Paste this manifest (JSON tab):"),console.log(""),console.log("-------------------------------------------------------------"),console.log(F),console.log("-------------------------------------------------------------"),console.log(""),console.log('Step 2 -Install: "Install App" -> "Install to Workspace" -> Authorize'),console.log(""),console.log("Step 3 -Copy your token:"),console.log(` OAuth & Permissions -> ${E}`),console.log("");let B=await Nu(D,"Paste your token: ");if(!B)console.error("No token provided."),process.exit(1);if(!B.startsWith(C))console.error(`Expected a ${C} token, got: ${B.slice(0,10)}...`),process.exit(1);await uF(D,B)}async function FF(D={}){let u=a2();if(u.length>0){console.log("Currently logged in:");for(let{name:E,profile:C,current:B}of u)console.log(` ${B?"*":" "} ${E} ${C.team} (${C.user||"unknown"})`);console.log(""),console.log("Adding another workspace:"),console.log("")}if(D.token){await uF(null,D.token,D.name);return}if(!process.stdin.isTTY){let E=[];for await(let B of process.stdin)E.push(B);let C=Buffer.concat(E).toString("utf8").trim();if(!C)console.error("No token provided on stdin."),process.exit(1);await uF(null,C,D.name);return}console.log("How would you like to authenticate with Slack?"),console.log(""),console.log(" 1) Slack desktop app - import session token"),console.log(" Reads the xoxc- token directly from the installed app."),console.log(" Token: all platforms | xoxd cookie: macOS only"),console.log(""),console.log(" 2) Connect existing Slack app [recommended if you have one]"),console.log(" Paste a token from an app you already created."),console.log(""),console.log(" 3) Create new Slack app - user token (xoxp-)"),console.log(" Guided setup with manifest. Full access including search."),console.log(""),console.log(" 4) Create new Slack app - bot token (xoxb-)"),console.log(" Bot is invited to channels. Search and news unavailable."),console.log("");let F=j3({input:process.stdin,output:process.stdout});try{let E=await Nu(F,"Choice [1/2/3/4]: ");if(console.log(""),E==="1")await A3();else if(E==="2")await L3(F);else if(E==="3")await z8(F,"user");else if(E==="4")await z8(F,"bot");else console.error(`Invalid choice: "${E}". Enter 1, 2, 3, or 4.`),process.exit(1)}finally{F.close()}}async function G8(D,u,F){let E=u,C=[],B=E,$=0;while(!0){let z=B.indexOf("<@U",$);if(z===-1)break;let Z=B.slice(z+2),J=Z.search(/[>|]/),O=J===-1?Z:Z.slice(0,J);if(O.length>=9)C.push(O);$=z+1}for(let z of C){if(!F.has(z))F.set(z,await DF(D,z));let Z=F.get(z)??z;E=E.replaceAll(`<@${z}>`,`@${Z}`),E=E.replace(new RegExp(`<@${z}\\|[^>]*>`,"g"),`@${Z}`)}return E}function Z8(D){return D.replace(/<!date\^(\d+)\^[^|>]*(?:\|([^>]*))?>/g,(u,F,E)=>{let C=Number(F);if(!Number.isFinite(C))return E??"date";let B=new Date(C*1000);if(Number.isNaN(B.getTime()))return E??"date";let $=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],z=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Z=$[B.getUTCDay()]??"",J=z[B.getUTCMonth()]??"";return`${Z}, ${J} ${String(B.getUTCDate()).padStart(2,"0")}, ${B.getUTCFullYear()}`})}function S3(D){let u=D.match(/^(\d+(?:\.\d+)?)(s|m|h|d)$/);if(!u)throw Error(`Invalid --since format: "${D}" (expected e.g. 10m, 2h, 1d)`);let F=parseFloat(u[1]);switch(u[2]){case"s":return F;case"m":return F*60;case"h":return F*3600;case"d":return F*86400}}var uu={sleep:(D)=>new Promise((u)=>setTimeout(u,D)),now:()=>Date.now()};function Fu(D){return D&&typeof D==="object"&&!Array.isArray(D)?D:{}}function X8(D){return Array.isArray(D)?D:[]}function P3(D){let[u,F="000000"]=D.split("."),E=new Date(Number(u)*1000),C=E.getUTCFullYear(),B=String(E.getUTCMonth()+1).padStart(2,"0"),$=String(E.getUTCDate()).padStart(2,"0"),z=String(E.getUTCHours()).padStart(2,"0"),Z=String(E.getUTCMinutes()).padStart(2,"0"),J=String(E.getUTCSeconds()).padStart(2,"0"),O=F.padEnd(6,"0").slice(0,6);return`${C}-${B}-${$}T${z}:${Z}:${J}.${O}`}async function w3(D,u,F,E){let C=typeof u.ts==="string"?u.ts:"0.000000",B=P3(C),$="?";if(typeof u.user==="string"){let Q=u.user,Y="@"+Q;if(!F.has(Y)){let[,M]=await D8(D,Q);F.set(Y,M)}$=F.get(Y)??Q}else if(typeof u.username==="string")$=u.username;let z=typeof u.text==="string"?u.text:"",J=Z8(await G8(D,z,F)).split(`
93
- `),O=J[0]+(J.length>1?`
94
- `+J.slice(1).map((Q)=>` ${Q}`).join(`
95
- `):""),X=E?`${E} @${$}`:`@${$}`;return`${B} ${X}: ${O}`}async function I3(D,u,F,E,C,B,$){let z=Fu(await dF(D,u,20,$?void 0:F||void 0,$)),Z=X8(z.messages).map(Fu).reverse(),J=Fu(z.response_metadata),O=z.has_more===!0&&typeof J.next_cursor==="string"?J.next_cursor:void 0,X=[],Q=F;for(let Y of Z){let M=typeof Y.ts==="string"?Y.ts:"";if(!M||C.has(M))continue;let H=typeof Y.subtype==="string"?Y.subtype:"";if(H==="message_changed"||H==="message_deleted")continue;if(E.thread){if((typeof Y.thread_ts==="string"?Y.thread_ts:M)!==E.thread&&M!==E.thread)continue}if(E.me&&E.myUserId){if(!(typeof Y.text==="string"?Y.text:"").includes(`<@${E.myUserId}>`))continue}if(C.add(M),C.size>1000){let _=C.values().next().value;if(_!==void 0)C.delete(_)}X.push(await w3(D,Y,B)),Q=M}return{newCursor:Q,lines:X,hasMore:z.has_more===!0,nextPageCursor:O}}async function J8(D,u,F={},E){if(F.me&&!u)console.error(`slack tail --me requires a <target> channel.
104
+ Is Slack installed and opened at least once?`);let u=OF(D).filter((z)=>z.endsWith(".ldb")||z.endsWith(".log"));if(u.length===0)throw Error(`No LevelDB data files found in ${D}`);let F=new Map;for(let z of u){let G;try{G=YF(XD(D,z),"latin1")}catch{continue}if(z.endsWith(".log"))for(let Z of G.matchAll(/"token":"(xoxc-[^"]+)"/g)){let Q=Z[1],J=Q.split("-")[1]??"";if(!J||Q.length<40)continue;let Y=Math.max(0,Z.index-2000),W=Math.min(G.length,Z.index+2000),H=G.slice(Y,W),O=H.match(/"url":"(https:\/\/[a-z0-9-]+\.slack\.com\/)"/),q=H.match(/"(?:team_name|name)":"([^"]{2,60})"/),j=F.get(J);if(!j||Q.length>j.token.length){let N={token:Q,teamId:J},k=O?.[1]??j?.url,w=q?.[1]??j?.teamName;if(k)N.url=k;if(w)N.teamName=w;F.set(J,N)}}else for(let Z of G.matchAll(/xoxc-(\d+)-(\d+)-(\d+)/g)){let Q=Z[1];if(F.has(Q))continue;let J=Z.index+Z[0].length,Y=Math.min(J+10,G.length);while(J<Y&&(G.charCodeAt(J)<48||G.charCodeAt(J)>57))J++;let W="";while(J<G.length&&G.charCodeAt(J)>=48&&G.charCodeAt(J)<=57)W+=G[J++];if(G[J]!=="-")continue;J++;let H="";while(J<G.length){let q=G.charCodeAt(J);if(q>=48&&q<=57||q>=97&&q<=102)H+=G[J++];else break}if(H.length<20)continue;let O=`${Z[0]}${W}-${H}`;F.set(Q,{token:O,teamId:Q})}}let C=OF(D).filter((z)=>z.endsWith(".ldb")||z.endsWith(".log")).map((z)=>{try{return YF(XD(D,z),"latin1").replace(/[^\x20-\x7e]/g," ")}catch{return""}}).join(" ");for(let z of F.values()){if(z.teamName)continue;let G=C.indexOf(z.teamId);if(G!==-1){let Z=Math.max(0,G-500),Q=Math.min(C.length,G+500),Y=C.slice(Z,Q).match(/"(?:team_name|name)":"([^"]{2,60})"/);if(Y?.[1]){z.teamName=Y[1];continue}}if(!z.teamName&&z.url){let Z=z.url.match(/https:\/\/([a-z0-9-]+)\.slack\.com\//)?.[1];if(Z){let Q=C.indexOf(Z);if(Q!==-1){let J=Math.max(0,Q-500),Y=Math.min(C.length,Q+500),H=C.slice(J,Y).match(/"(?:team_name|name)":"([^"]{2,60})"/);if(H?.[1]){z.teamName=H[1];continue}}z.teamName=Z.split("-").map((J)=>J.charAt(0).toUpperCase()+J.slice(1)).join(" ")}}}let B=Y6(),$=[...F.values()];if(B)for(let z of $)z.cookie=B;return $}function W6(D,u){let F=(E,C)=>{try{let B=c8("aes-128-cbc",u,E);B.setAutoPadding(!0);let $=Buffer.concat([B.update(C),B.final()]).toString("utf8");return $.startsWith("xoxd-")?$:void 0}catch{return}};return F(Buffer.alloc(16,32),D.slice(3))??(D.length>=35?F(D.slice(19,35),D.slice(35)):void 0)}function H6(D,u){try{let E=JSON.parse(YF(XD(D,u,"Preferences"),"utf8")).profile,C=E?.name??"",B=E?.user_name??"";return B?`${C} (${B})`:C||u}catch{return u}}function d8(){if(process.platform!=="darwin")return{candidates:[],totalProfiles:0};let D=XD(WF(),"Library","Application Support","Google","Chrome");if(!Ju(D))return{candidates:[],totalProfiles:0};let u;try{u=g8('security find-generic-password -a Chrome -s "Chrome Safe Storage" -w',{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trimEnd()}catch{return{candidates:[],totalProfiles:0}}if(!u)return{candidates:[],totalProfiles:0};let F=y8(u,"saltysalt",1003,16,"sha1"),E=["Default",...OF(D).filter((B)=>B.startsWith("Profile "))],C=[];for(let B of E){let $=XD(D,B,"Cookies");if(!Ju($))continue;let z=XD(p8(),`slack-chrome-cookies-${Date.now()}-${B}.db`);try{v8($,z);let{default:G}=vD("bun:sqlite"),Z=new G(z,{readonly:!0}),Q=Z.prepare("SELECT encrypted_value FROM cookies WHERE name='d' AND host_key LIKE '%slack%'").get();if(Z.close(),!Q)continue;let J=Buffer.from(Q.encrypted_value),Y=J.slice(0,3).toString();if(Y==="v10"){let W=W6(J,F);if(!W)continue;C.push({profileDir:B,profileName:H6(D,B),cookie:W})}else if(Y==="v20")throw Error(`Chrome cookie uses v20 (app-bound AES-256-GCM) which is not supported yet. Prefix found: ${J.slice(0,4).toString("hex")}`);else throw Error(`Unknown cookie encryption prefix: ${J.slice(0,4).toString("hex")}`)}catch(G){if(G instanceof Error&&(G.message.includes("app-bound")||G.message.includes("Unknown cookie")))throw G}finally{try{m8(z)}catch{}}}return{candidates:C,totalProfiles:E.length}}function M6(){let D=WF();if(process.platform==="darwin")return XD(D,"Library","Application Support","Firefox","Profiles");if(process.platform==="linux")return XD(D,".mozilla","firefox");if(process.platform==="win32")return XD(process.env.APPDATA??XD(D,"AppData","Roaming"),"Mozilla","Firefox","Profiles");return""}function V6(D){let u=XD(J6(D),"profiles.ini"),F={};if(!Ju(u))return F;try{let E=YF(u,"utf8"),C="",B="";for(let $ of E.split(`
105
+ `)){let z=$.trim();if(z.startsWith("[")){C="",B="";continue}let G=z.indexOf("=");if(G===-1)continue;let Z=z.slice(0,G).trim().toLowerCase(),Q=z.slice(G+1).trim();if(Z==="name")C=Q;if(Z==="path")B=Q.split(/[\\/]/).pop()??Q;if(C&&B)F[B]=C,C="",B=""}}catch{}return F}function i8(){let D=M6();if(!D||!Ju(D))return[];let u=V6(D),F=[],E;try{E=OF(D)}catch{return[]}for(let C of E){let B=XD(D,C,"cookies.sqlite");if(!Ju(B))continue;let $=XD(p8(),`slack-firefox-cookies-${Date.now()}-${C}.db`);try{v8(B,$);let{default:z}=vD("bun:sqlite"),G=new z($,{readonly:!0}),Z=G.prepare("SELECT value FROM moz_cookies WHERE name='d' AND host LIKE '%slack%' LIMIT 1").get();if(G.close(),!Z?.value||!Z.value.startsWith("xoxd-"))continue;let Q=u[C]??C;F.push({profileDir:C,profileName:Q,cookie:Z.value})}catch{}finally{try{m8($)}catch{}}}return F}var q6=["search:read","channels:history","groups:history","im:history","mpim:history","channels:read","groups:read","im:read","mpim:read","users:read","chat:write","files:write"],_6=["channels:history","groups:history","im:history","mpim:history","channels:read","groups:read","im:read","mpim:read","users:read","chat:write","files:write"];function HF(D){return D.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function K6(){return JSON.stringify({display_information:{name:"slack-term"},oauth_config:{scopes:{user:q6}},settings:{org_deploy_enabled:!1,socket_mode_enabled:!1,token_rotation_enabled:!1}},null,2)}function j6(){return JSON.stringify({display_information:{name:"slack-term"},features:{bot_user:{display_name:"slack-term",always_online:!1}},oauth_config:{scopes:{bot:_6}},settings:{org_deploy_enabled:!1,socket_mode_enabled:!1,token_rotation_enabled:!1}},null,2)}async function Qu(D,u){return(await D.question(u)).trim()}async function Ou(D,u,F,E){console.error("Verifying token...");let C=await ZF(u),B=HF(C.team),$;if(F)$=F;else if(D)$=await Qu(D,`Workspace name [${B}]: `)||B;else $=B;let z=null;if(D){console.log(""),console.log("Where to save the token?"),console.log(" 1) ./.env.local (current directory) [default]"),console.log(" 2) ./.slack-term/.env.local (current directory, slack-specific)"),console.log(" 3) ~/.slack-term/.env.local (global, available everywhere)"),console.log(" 4) profiles.json (multi-workspace: slack auth use)"),console.log("");let G=await Qu(D,"Choice [1/2/3/4, Enter=1]: ");if(G==="2")z=U0(process.cwd(),".slack-term",".env.local");else if(G==="3")z=U0(U6(),".slack-term",".env.local");else if(G==="4")z=null;else z=U0(process.cwd(),".env.local")}if(z===null)if(M0($,{token:u,...C,...E?{cookie:E}:{}}),console.log(`Saved workspace "${$}" to profiles.json: ${C.team} (${C.user})`),process.env.SLACK_MCP_XOXP_TOKEN)console.log(""),console.log("Warning: SLACK_MCP_XOXP_TOKEN is set — it conflicts with profiles."),console.log(" Unset it: unset SLACK_MCP_XOXP_TOKEN (and remove from ~/.zshrc / ~/.bashrc)");else console.log(` Run: slack auth use -g ${$}`);else{let G={SLACK_TOKEN:u};if(E)G.SLACK_COOKIE=E;h8(z,G),console.log(`Saved token to ${z}`),console.log(" SLACK_TOKEN will be picked up automatically in this directory tree.")}return $}async function A6(D){console.error("Scanning Slack desktop app...");let u=await k8();if(u.length===0)console.error("No sessions found. Make sure Slack is installed and you have signed in at least once."),process.exit(1);if(u.length===1&&D){let F=u[0],E=F.teamName??F.teamId;console.log(`Found workspace: ${E}${F.cookie?" (+ xoxd cookie)":""}`),await Ou(D,F.token,HF(E),F.cookie),console.log(""),console.log("Note: desktop app tokens (xoxc-) are internal Slack tokens."),console.log("If API calls fail, replace with an xoxp- token: slack auth login");return}for(let F of u){let E=F.teamName??F.teamId,C=HF(E);M0(C,{token:F.token,team:E,teamId:F.teamId,url:F.url??"",user:"",...F.cookie?{cookie:F.cookie}:{}}),console.log(`Added workspace "${C}": ${E}${F.cookie?" + xoxd cookie":""}`)}if(console.log(""),u.length===1){let F=HF(u[0].teamName??u[0].teamId);console.log(`Run: slack auth use -g ${F}`)}else console.log("Run: slack auth ls then: slack auth use -g <name>");console.log(""),console.log("Note: desktop app tokens (xoxc-) are internal Slack tokens."),console.log("If API calls fail, replace with an xoxp- user token by re-running: slack auth login")}async function n8(D){console.log("Which token type does your app use?"),console.log(""),console.log(" 1) User token (xoxp-) -full access including search [recommended]"),console.log(" 2) Bot token (xoxb-) -search and news unavailable"),console.log("");let F=await Qu(D,"Choice [1/2]: ")==="2"?"bot":"user",E=F==="user"?"xoxp-":"xoxb-",C=F==="user"?"User OAuth Token":"Bot User OAuth Token";console.log(""),console.log("Find your token here:"),console.log(" https://api.slack.com/apps"),console.log(" -> Select your app -> OAuth & Permissions"),console.log(` -> Copy the "${C}" (starts with ${E})`),console.log("");let B=await Qu(D,"Paste your token: ");if(!B)console.error("No token provided."),process.exit(1);if(!B.startsWith(E))console.error(`Expected a ${E} token, got: ${B.slice(0,10)}...`),process.exit(1);await Ou(D,B)}async function MF(D,u){let F=u==="user"?K6():j6(),E=u==="user"?"User OAuth Token (xoxp-...)":"Bot User OAuth Token (xoxb-...)",C=u==="user"?"xoxp-":"xoxb-";if(u==="bot")console.log("Note: bot tokens cannot use search:read (user-only scope)."),console.log(" The news and search commands will not work with a bot token."),console.log("");console.log("Step 1 -Create your Slack app:"),console.log(" Open: https://api.slack.com/apps"),console.log(' Click "Create New App" -> "From a manifest" -> select your workspace'),console.log(" Paste this manifest (JSON tab):"),console.log(""),console.log("-------------------------------------------------------------"),console.log(F),console.log("-------------------------------------------------------------"),console.log(""),console.log('Step 2 -Install: "Install App" -> "Install to Workspace" -> Authorize'),console.log(""),console.log("Step 3 -Copy your token:"),console.log(` OAuth & Permissions -> ${E}`),console.log("");let B=await Qu(D,"Paste your token: ");if(!B)console.error("No token provided."),process.exit(1);if(!B.startsWith(C))console.error(`Expected a ${C} token, got: ${B.slice(0,10)}...`),process.exit(1);await Ou(D,B)}async function t8(D={}){if(process.platform!=="darwin")console.error("Chrome cookie extraction is only supported on macOS."),process.exit(1);let u=QF();if(u.length===0)console.error("No workspaces configured. Run: slack auth login"),process.exit(1);let F;if(D.workspace){if(!u.find((z)=>z.name===D.workspace))console.error(`Workspace "${D.workspace}" not found. Available: ${u.map((z)=>z.name).join(", ")}`),process.exit(1);F=D.workspace}else if(u.length===1)F=u[0].name;else{let $=u.find((z)=>z.current);if($)F=$.name,console.log(`Using active workspace: ${F}`);else{console.log("Multiple workspaces found. Choose one:"),u.forEach((Q,J)=>console.log(` ${J+1}) ${Q.name} (${Q.profile.team})`));let z=Xu({input:process.stdin,output:process.stdout}),G=(await z.question("Choice: ")).trim();z.close();let Z=parseInt(G,10)-1;if(isNaN(Z)||Z<0||Z>=u.length)console.error("Invalid choice."),process.exit(1);F=u[Z].name}}console.log("Scanning Chrome profiles for Slack session..."),console.log("macOS may show a dialog asking for your login password — click Allow.");let E,C;try{({candidates:E,totalProfiles:C}=d8())}catch($){console.error(`Failed: ${$ instanceof Error?$.message:String($)}`),process.exit(1)}if(E.length===0)console.error(`No Slack session found in Chrome (scanned ${C} profile${C!==1?"s":""}). Possible reasons:`),console.error(" - You denied the keychain dialog (try running again and click Allow)"),console.error(" - Chrome is not installed or has no Slack session"),console.error(" - You're not logged in to Slack in Chrome"),process.exit(1);let B;if(E.length===1&&C<=1)B=E[0].cookie,console.log(`Found session in Chrome profile: ${E[0].profileName}`);else{let $=E.length===1?`Found 1 Slack session across ${C} Chrome profiles:`:`Found ${E.length} Slack sessions across ${C} Chrome profiles:`;console.log($),E.forEach((J,Y)=>console.log(` ${Y+1}) ${J.profileName} [${J.profileDir}]`)),console.log("");let z=Xu({input:process.stdin,output:process.stdout}),G=E.length===1?" [Enter=1]":"",Z=(await z.question(`Choice [1-${E.length}]${G}: `)).trim();z.close();let Q=Z===""&&E.length===1?0:parseInt(Z,10)-1;if(isNaN(Q)||Q<0||Q>=E.length)console.error("Invalid choice."),process.exit(1);B=E[Q].cookie}V0(F,B),console.log(`Saved xoxd cookie to workspace "${F}".`),console.log("RTM WebSocket mode is now available: slack tail @you")}async function l8(D={}){let u=QF();if(u.length===0)console.error("No workspaces configured. Run: slack auth token"),process.exit(1);let F;if(D.workspace){if(!u.find(($)=>$.name===D.workspace))console.error(`Workspace "${D.workspace}" not found. Available: ${u.map(($)=>$.name).join(", ")}`),process.exit(1);F=D.workspace}else if(u.length===1)F=u[0].name;else{let B=u.find(($)=>$.current);if(B)F=B.name,console.log(`Using active workspace: ${F}`);else{console.log("Multiple workspaces found. Choose one:"),u.forEach((Z,Q)=>console.log(` ${Q+1}) ${Z.name} (${Z.profile.team})`));let $=Xu({input:process.stdin,output:process.stdout}),z=(await $.question("Choice: ")).trim();$.close();let G=parseInt(z,10)-1;if(isNaN(G)||G<0||G>=u.length)console.error("Invalid choice."),process.exit(1);F=u[G].name}}console.log("Scanning Firefox profiles for Slack session...");let E=i8();if(E.length===0)console.error("No Slack session found in Firefox. Possible reasons:"),console.error(" - Firefox is not installed"),console.error(" - You are not logged in to Slack in Firefox"),process.exit(1);let C;if(E.length===1)C=E[0].cookie,console.log(`Found session in Firefox profile: ${E[0].profileName}`);else{console.log("Multiple Firefox profiles have a Slack session. Choose one:"),E.forEach((G,Z)=>console.log(` ${Z+1}) ${G.profileName} [${G.profileDir}]`));let B=Xu({input:process.stdin,output:process.stdout}),$=(await B.question("Choice: ")).trim();B.close();let z=parseInt($,10)-1;if(isNaN(z)||z<0||z>=E.length)console.error("Invalid choice."),process.exit(1);C=E[z].cookie}V0(F,C),console.log(`Saved xoxd cookie to workspace "${F}".`),console.log("RTM WebSocket mode is now available: slack tail @you")}async function o8(D={}){if(D.token){await Ou(null,D.token,D.name);return}if(!process.stdin.isTTY){let F=[];for await(let C of process.stdin)F.push(C);let E=Buffer.concat(F).toString("utf8").trim();if(!E)console.error("No token provided on stdin."),process.exit(1);await Ou(null,E,D.name);return}let u=Xu({input:process.stdin,output:process.stdout});try{await n8(u)}finally{u.close()}}async function s8(D={}){let u=Xu({input:process.stdin,output:process.stdout});try{if(D.bot!==void 0){await MF(u,D.bot?"bot":"user");return}console.log("Which token type?"),console.log(" 1) User token (xoxp-) -full access including search [default]"),console.log(" 2) Bot token (xoxb-) -search and news unavailable"),console.log("");let F=await Qu(u,"Choice [1/2, Enter=1]: ");await MF(u,F==="2"?"bot":"user")}finally{u.close()}}async function VF(D={}){let u=QF();if(u.length>0){console.log("Currently logged in:");for(let{name:E,profile:C,current:B}of u)console.log(` ${B?"*":" "} ${E} ${C.team} (${C.user||"unknown"})`);console.log(""),console.log("Adding another workspace:"),console.log("")}if(D.token){await Ou(null,D.token,D.name);return}if(!process.stdin.isTTY){let E=[];for await(let B of process.stdin)E.push(B);let C=Buffer.concat(E).toString("utf8").trim();if(!C)console.error("No token provided on stdin."),process.exit(1);await Ou(null,C,D.name);return}console.log("How would you like to authenticate with Slack?"),console.log(""),console.log(" 1) Slack desktop app - import session token"),console.log(" Reads the xoxc- token directly from the installed app."),console.log(" Token: all platforms | xoxd cookie: macOS only"),console.log(""),console.log(" 2) Connect existing Slack app [recommended if you have one]"),console.log(" Paste a token from an app you already created."),console.log(""),console.log(" 3) Create new Slack app - user token (xoxp-)"),console.log(" Guided setup with manifest. Full access including search."),console.log(""),console.log(" 4) Create new Slack app - bot token (xoxb-)"),console.log(" Bot is invited to channels. Search and news unavailable."),console.log("");let F=Xu({input:process.stdin,output:process.stdout});try{let E=await Qu(F,"Choice [1/2/3/4]: ");if(console.log(""),E==="1")await A6(F);else if(E==="2")await n8(F);else if(E==="3")await MF(F,"user");else if(E==="4")await MF(F,"bot");else console.error(`Invalid choice: "${E}". Enter 1, 2, 3, or 4.`),process.exit(1)}finally{F.close()}}async function UF(D,u,F){let E=u,C=[],B=E,$=0;while(!0){let z=B.indexOf("<@U",$);if(z===-1)break;let G=B.slice(z+2),Z=G.search(/[>|]/),Q=Z===-1?G:G.slice(0,Z);if(Q.length>=9)C.push(Q);$=z+1}for(let z of C){if(!F.has(z))F.set(z,await XF(D,z));let G=F.get(z)??z;E=E.replaceAll(`<@${z}>`,`@${G}`),E=E.replace(new RegExp(`<@${z}\\|[^>]*>`,"g"),`@${G}`)}return E}function qF(D){return D.replace(/<!date\^(\d+)\^[^|>]*(?:\|([^>]*))?>/g,(u,F,E)=>{let C=Number(F);if(!Number.isFinite(C))return E??"date";let B=new Date(C*1000);if(Number.isNaN(B.getTime()))return E??"date";let $=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],z=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],G=$[B.getUTCDay()]??"",Z=z[B.getUTCMonth()]??"";return`${G}, ${Z} ${String(B.getUTCDate()).padStart(2,"0")}, ${B.getUTCFullYear()}`})}function a8(D){let u=typeof D.ts==="string"?D.ts:"",F=typeof D.thread_ts==="string"?D.thread_ts:"";return F!==""&&F!==u}function L6(D){let[u,F="000000"]=D.split("."),E=new Date(Number(u)*1000),C=E.getUTCFullYear(),B=String(E.getUTCMonth()+1).padStart(2,"0"),$=String(E.getUTCDate()).padStart(2,"0"),z=String(E.getUTCHours()).padStart(2,"0"),G=String(E.getUTCMinutes()).padStart(2,"0"),Z=String(E.getUTCSeconds()).padStart(2,"0"),Q=F.padEnd(6,"0").slice(0,6);return`${C}-${B}-${$}T${z}:${G}:${Z}.${Q}`}async function N6(D,u,F){let E=typeof u.ts==="string"?u.ts:"0.000000",C=L6(E),B="?";if(typeof u.user==="string"){let J=u.user,Y="@"+J;if(!F.has(Y)){let[,W]=await JF(D,J);F.set(Y,W)}B=F.get(Y)??J}else if(typeof u.username==="string")B=u.username;let $=typeof u.text==="string"?u.text:"",G=qF(await UF(D,$,F)).split(`
106
+ `),Z=G[0]+(G.length>1?`
107
+ `+G.slice(1).map((J)=>` ${J}`).join(`
108
+ `):""),Q=a8(u)?"↳ ":"";return`${C} ${Q}@${B}: ${Z}`}async function R6(D,u,F,E,C,B,$,z){if(z?.aborted)return;return new Promise((G)=>{let Z=new D(F);z?.addEventListener("abort",()=>{Z.close(),G()},{once:!0}),Z.addEventListener("open",()=>{process.stderr.write(`Connected via RTM (experimental).
109
+ `)}),Z.addEventListener("close",()=>G()),Z.addEventListener("error",()=>G()),Z.addEventListener("message",(Q)=>{(async()=>{try{let J;try{J=JSON.parse(String(Q.data))}catch{return}let Y=typeof J.type==="string"?J.type:"";if(Y==="ping"){Z.send(JSON.stringify({type:"pong",reply_to:J.id??0}));return}if(Y!=="message")return;if((typeof J.channel==="string"?J.channel:"")!==E)return;let H=typeof J.ts==="string"?J.ts:"";if(!H||B.has(H))return;let O=typeof J.subtype==="string"?J.subtype:"";if(O==="message_changed"||O==="message_deleted")return;if(C.thread){if((typeof J.thread_ts==="string"?J.thread_ts:H)!==C.thread&&H!==C.thread)return}if(C.watchThread&&a8(J)){if((typeof J.thread_ts==="string"?J.thread_ts:"")!==C.watchThread)return}if(C.me&&C.myUserId){if(!(typeof J.text==="string"?J.text:"").includes(`<@${C.myUserId}>`))return}if(B.add(H),B.size>1000){let j=B.values().next().value;if(j!==void 0)B.delete(j)}let q=await N6(u,J,$);process.stdout.write(q+`
110
+ `)}catch(J){process.stderr.write(`RTM message error: ${J instanceof Error?J.message:String(J)}
111
+ `)}})()})})}var r8=3,T6=2000,q0={sleep:(D)=>new Promise((u)=>setTimeout(u,D)),clientBoot:R8,getWebSocket:()=>{let D=globalThis.WebSocket;return typeof D==="function"?D:void 0}};async function e8(D,u,F,E,C,B,$){let z=q0.getWebSocket();if(!z)return;for(let G=0;G<r8;G++){if($?.aborted)return;try{let{wsUrl:Z}=await q0.clientBoot(D,u);await R6(z,D,Z,F,E,C,B,$)}catch{}if($?.aborted)return;if(G<r8-1)await q0.sleep(T6)}}function D1(D){let u=D.match(/^(\d+(?:\.\d+)?)(s|m|h|d)$/);if(!u)throw Error(`Invalid --since format: "${D}" (expected e.g. 10m, 2h, 1d)`);let F=parseFloat(u[1]);switch(u[2]){case"s":return F;case"m":return F*60;case"h":return F*3600;case"d":return F*86400}}var SD={sleep:(D)=>new Promise((u)=>setTimeout(u,D)),now:()=>Date.now(),tailRTM:e8};function fD(D){return D&&typeof D==="object"&&!Array.isArray(D)?D:{}}function _0(D){return Array.isArray(D)?D:[]}function u1(D){return Number(D)||0}function F1(D){let u=typeof D.ts==="string"?D.ts:"",F=typeof D.thread_ts==="string"?D.thread_ts:"";return F!==""&&F!==u}function S6(D){let[u,F="000000"]=D.split("."),E=new Date(Number(u)*1000),C=E.getUTCFullYear(),B=String(E.getUTCMonth()+1).padStart(2,"0"),$=String(E.getUTCDate()).padStart(2,"0"),z=String(E.getUTCHours()).padStart(2,"0"),G=String(E.getUTCMinutes()).padStart(2,"0"),Z=String(E.getUTCSeconds()).padStart(2,"0"),Q=F.padEnd(6,"0").slice(0,6);return`${C}-${B}-${$}T${z}:${G}:${Z}.${Q}`}async function P6(D,u,F,E){let C=typeof u.ts==="string"?u.ts:"0.000000",B=S6(C),$="?";if(typeof u.user==="string"){let W=u.user,H="@"+W;if(!F.has(H)){let[,O]=await JF(D,W);F.set(H,O)}$=F.get(H)??W}else if(typeof u.username==="string")$=u.username;let z=typeof u.text==="string"?u.text:"",Z=qF(await UF(D,z,F)).split(`
112
+ `),Q=Z[0]+(Z.length>1?`
113
+ `+Z.slice(1).map((W)=>` ${W}`).join(`
114
+ `):""),J=F1(u)?"↳ ":"",Y=E?`${E} @${$}`:`@${$}`;return`${B} ${J}${Y}: ${Q}`}async function w6(D,u,F,E,C,B,$){let z=fD(await Z0(D,u,20,$?void 0:F||void 0,$)),G=_0(z.messages).map(fD).reverse(),Z=fD(z.response_metadata),Q=z.has_more===!0&&typeof Z.next_cursor==="string"?Z.next_cursor:void 0,J=[];if(E.watchThread&&!$){let q=fD(await A8(D,u,E.watchThread,50));J=_0(q.messages).map(fD).filter((j)=>(typeof j.ts==="string"?j.ts:"")!==E.watchThread)}let Y=[...G.map((q)=>({m:q,fromHistory:!0})),...J.map((q)=>({m:q,fromHistory:!1}))].sort((q,j)=>u1(typeof q.m.ts==="string"?q.m.ts:"")-u1(typeof j.m.ts==="string"?j.m.ts:"")),W=[],H=F,O=!1;for(let{m:q,fromHistory:j}of Y){let N=typeof q.ts==="string"?q.ts:"";if(!N||C.has(N))continue;let k=typeof q.subtype==="string"?q.subtype:"";if(k==="message_changed"||k==="message_deleted")continue;if(E.thread){if((typeof q.thread_ts==="string"?q.thread_ts:N)!==E.thread&&N!==E.thread)continue}if(E.watchThread&&F1(q)){if((typeof q.thread_ts==="string"?q.thread_ts:"")!==E.watchThread)continue}if(E.me&&E.myUserId){if(!(typeof q.text==="string"?q.text:"").includes(`<@${E.myUserId}>`))continue}if(C.add(N),C.size>1000){let c=C.values().next().value;if(c!==void 0)C.delete(c)}if(W.push(await P6(D,q,B)),j)H=N;let w=typeof q.user==="string"?q.user:"";if(!E.myUserId||w!==E.myUserId)O=!0}return{newCursor:H,lines:W,hasMore:z.has_more===!0,nextPageCursor:Q,emittedOther:O}}function x6(D){if(D.includes("slack.com")){let u=J0(D),F=u?.threadTs??u?.ts;if(F)return F;throw Error(`--watch-thread: could not extract a timestamp from "${D}"`)}if(/^\d{10}\.\d{6}$/.test(D))return D;if(/^\d{16}$/.test(D))return`${D.slice(0,10)}.${D.slice(10)}`;throw Error(`--watch-thread: "${D}" is not a valid ts or permalink`)}async function E1(D,u,F={},E){if(F.me&&!u)console.error(`slack tail --me requires a <target> channel.
96
115
  Cross-channel mention streaming is not yet supported.
97
- Use: slack tail "#channel" --me`),process.exit(1);if(!u)console.error("Usage: slack tail <#channel|@user>\n Run `slack tail --help` for details."),process.exit(1);let C=await e2(D,u),B=F.interval??60000,$=new Map,z=new Set;try{let Y=Fu(await u8(D,C));if(Fu(Y.channel).is_archived===!0)console.error("Warning: this channel is archived — no new messages will arrive.")}catch(Y){let M=Y instanceof Error?Y.message:String(Y);if(M.includes("not_in_channel"))console.error("Error: you are not a member of that channel. Join it in Slack first, then retry."),process.exit(1);if(M.includes("missing_scope"))console.error("Error: token lacks the required history scope. Check your token's channels:history (or groups:history) permission."),process.exit(1);if(M.includes("channel_not_found"))console.error("Error: channel not found — it may be a private channel inaccessible with your token."),process.exit(1);console.error(`Warning: preflight check failed: ${M}`)}let Z="";if(F.since){let Y=S3(F.since);Z=(uu.now()/1000-Y).toFixed(6)}else{let Y=Fu(await dF(D,C,1)),M=X8(Y.messages).map(Fu);if(M.length>0&&typeof M[0]?.ts==="string")Z=M[0].ts,z.add(Z);else Z=(uu.now()/1000).toFixed(6)}let J;if(F.me)J=(await eu(D)).userId||void 0;let O={...F.thread!==void 0?{thread:F.thread}:{},...F.me!==void 0?{me:F.me}:{},...J!==void 0?{myUserId:J}:{}},X=!0,Q=uu.now();while(!E?.aborted){try{let M=uu.now()-Q,H=B>0&&M>B*5,_,S=!0;do{let{newCursor:f,lines:d,nextPageCursor:x}=await I3(D,C,Z,O,z,$,_);if(Z=f,X&&S&&F.since&&d.length===0)process.stdout.write(`(no messages in the last ${F.since} — watching for new)
98
- `);S=!1;for(let i of d)process.stdout.write(i+`
99
- `);_=H?x:void 0}while(_);X=!1}catch(Y){if(Y instanceof Tu){console.error(`Warning: Slack rate limit hit — backing off for ${Y.retryAfter}s`),await uu.sleep(Y.retryAfter*1000);continue}throw Y}Q=uu.now(),await uu.sleep(B)}}class Ru extends Error{retryAfter;constructor(D){super(`Slack rate limited — retry after ${D}s`);this.name="RateLimitError",this.retryAfter=D}}function Q8(){return(process.env.SLACK_API_BASE??"https://slack.com/api").replace(/\/$/,"")}async function O8(D,u,F,E){let C={};if(E)C.Cookie=`d=${E}`;let B=await fetch(`${Q8()}/${u}`,{...F,headers:{...F.headers??{},Authorization:`Bearer ${D}`,...C}});if(B.status===429){let z=parseInt(B.headers.get("retry-after")??"60",10);throw new Ru(isNaN(z)?60:z)}let $=await B.json();if($.ok!==!0){let z=$.error??"unknown";if(z==="ratelimited")throw new Ru(60);if(z==="invalid_auth"&&D.startsWith("xoxc-")&&!E)throw Error(`Desktop app token (xoxc-) is not accepted by the public Slack API.
116
+ Use: slack tail "#channel" --me`),process.exit(1);if(!u)console.error("Usage: slack tail <#channel|@user>\n Run `slack tail --help` for details."),process.exit(1);let C=await L8(D,u),B=F.interval??60000,$=F.timeout?SD.now()+D1(F.timeout)*1000:1/0,z=new Map,G=new Set;try{let O=fD(await N8(D,C));if(fD(O.channel).is_archived===!0)console.error("Warning: this channel is archived — no new messages will arrive.")}catch(O){let q=O instanceof Error?O.message:String(O);if(q.includes("not_in_channel"))console.error("Error: you are not a member of that channel. Join it in Slack first, then retry."),process.exit(1);if(q.includes("missing_scope"))console.error("Error: token lacks the required history scope. Check your token's channels:history (or groups:history) permission."),process.exit(1);if(q.includes("channel_not_found"))console.error("Error: channel not found — it may be a private channel inaccessible with your token."),process.exit(1);console.error(`Warning: preflight check failed: ${q}`)}let Z="";if(F.since){let O=D1(F.since);Z=(SD.now()/1000-O).toFixed(6)}else{let O=fD(await Z0(D,C,1)),q=_0(O.messages).map(fD);if(q.length>0&&typeof q[0]?.ts==="string")Z=q[0].ts,G.add(Z);else Z=(SD.now()/1000).toFixed(6)}let Q;if(F.me||F.exitOnMessage)Q=(await ZF(D)).userId||void 0;let J;if(F.watchThread!==void 0)try{J=x6(F.watchThread)}catch(O){console.error(O instanceof Error?O.message:String(O)),process.exit(1)}let Y={...F.thread!==void 0?{thread:F.thread}:{},...J!==void 0?{watchThread:J}:{},...F.me!==void 0?{me:F.me}:{},...Q!==void 0?{myUserId:Q}:{}};if(D.startsWith("xoxc-")&&F.cookie!==void 0&&F.noRtm!==!0&&F.since===void 0&&F.timeout===void 0&&F.exitOnMessage!==!0){if(await SD.tailRTM(D,F.cookie,C,Y,G,z,E),E?.aborted)return;console.error("RTM unavailable — switching to polling.")}let W=!0,H=SD.now();while(!E?.aborted){if(SD.now()>=$)return;let O=!1;try{let N=SD.now()-H,k=B>0&&N>B*5,w,c=!0;do{let{newCursor:e,lines:s,nextPageCursor:qD,emittedOther:i}=await w6(D,C,Z,Y,G,z,w);if(Z=e,W&&c&&F.since&&s.length===0)process.stdout.write(`(no messages in the last ${F.since} — watching for new)
117
+ `);c=!1;for(let tD of s)process.stdout.write(tD+`
118
+ `);if(i)O=!0;w=k?qD:void 0}while(w);W=!1}catch(j){if(j instanceof dD){console.error(`Warning: Slack rate limit hit — backing off for ${j.retryAfter}s`),await SD.sleep(j.retryAfter*1000);continue}throw j}if(F.exitOnMessage&&O)return;H=SD.now();let q=$-SD.now();if(q<=0)return;await SD.sleep(Math.min(B,q))}}class Iu extends Error{retryAfter;constructor(D){super(`Slack rate limited — retry after ${D}s`);this.name="RateLimitError",this.retryAfter=D}}function C1(){return(process.env.SLACK_API_BASE??"https://slack.com/api").replace(/\/$/,"")}async function B1(D,u,F,E){let C={};if(E)C.Cookie=`d=${E}`;let B=await fetch(`${C1()}/${u}`,{...F,headers:{...F.headers??{},Authorization:`Bearer ${D}`,...C}});if(B.status===429){let z=parseInt(B.headers.get("retry-after")??"60",10);throw new Iu(isNaN(z)?60:z)}let $=await B.json();if($.ok!==!0){let z=$.error??"unknown";if(z==="ratelimited")throw new Iu(60);if(z==="invalid_auth"&&D.startsWith("xoxc-")&&!E)throw Error(`Desktop app token (xoxc-) is not accepted by the public Slack API.
100
119
  Replace it with an xoxp- user token:
101
- slack workspace set-token <name> <xoxp-token>`);throw Error(`Slack error on ${u}: ${z}`)}return $}async function f3(D,u,F,E){let C={};if(E)C.Cookie=`d=${E}`;let B=await fetch(`${Q8()}/${u}`,{...F,headers:{...F.headers??{},Authorization:`Bearer ${D}`,...C}});if(B.status===429){let z=parseInt(B.headers.get("retry-after")??"60",10);throw new Ru(isNaN(z)?60:z)}let $=await B.json();if($.ok!==!0){let z=$.error??"unknown";if(z==="ratelimited")throw new Ru(60);if((z==="invalid_auth"||z==="not_authed")&&!D.startsWith("xoxc-"))throw Error(`The draft API requires a desktop app session token (xoxc-).
120
+ slack workspace set-token <name> <xoxp-token>`);throw Error(`Slack error on ${u}: ${z}`)}return $}async function I6(D,u,F,E){let C={};if(E)C.Cookie=`d=${E}`;let B=await fetch(`${C1()}/${u}`,{...F,headers:{...F.headers??{},Authorization:`Bearer ${D}`,...C}});if(B.status===429){let z=parseInt(B.headers.get("retry-after")??"60",10);throw new Iu(isNaN(z)?60:z)}let $=await B.json();if($.ok!==!0){let z=$.error??"unknown";if(z==="ratelimited")throw new Iu(60);if((z==="invalid_auth"||z==="not_authed")&&!D.startsWith("xoxc-"))throw Error(`The draft API requires a desktop app session token (xoxc-).
102
121
  Import from Slack desktop: slack workspace import`);if((z==="invalid_auth"||z==="not_authed")&&!E)throw Error(`drafts.list also requires the xoxd session cookie.
103
122
  Set it with: slack workspace set-cookie <workspace-name> <xoxd-value>
104
- `+"Get xoxd from browser: DevTools → Application → Cookies → slack.com → d");throw Error(`Slack error on ${u}: ${z}`)}return $}function Ou(D,u,F={},E){let C=new URLSearchParams({token:D,...F});return f3(D,u,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:C.toString()},E)}function YD(D,u,F,E){let C=new URLSearchParams(F).toString();return O8(D,`${u}?${C}`,{method:"GET"},E)}function Yu(D,u,F){return O8(D,u,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(F)})}async function Lu(D,u,F=20,E,C){let B={channel:u,limit:String(F)};if(E!==void 0)B.oldest=E;if(C!==void 0)B.cursor=C;return YD(D,"conversations.history",B)}async function tF(D,u,F,E=50){return YD(D,"conversations.replies",{channel:u,ts:F,limit:String(E)})}async function Y8(D,u,F,E){return YD(D,"search.messages",{query:u,sort:"timestamp",sort_dir:"desc",count:String(Math.min(Math.max(F,1),100)),page:String(Math.max(E,1))})}async function W8(D,u){return Y8(D,u,100,1)}async function M8(D,u,F){let C=1,B=[],$={ok:!0,messages:{}};while(!0){let Z=await Y8(D,u,100,C),J=Au(Z,["messages","matches"]),O=Array.isArray(J)?J:[];B.push(...O);let X=Number(Au(Z,["messages","paging","pages"])??1);if($=Z,O.length===0||C>=X||B.length>=F)break;C+=1}let z=$;if(!z.messages)z.messages={};return z.messages.matches=B.slice(0,F),z}async function H8(D,u,F,E){let C={channel:u,text:F,blocks:[{type:"markdown",text:F}]};if(E!==void 0)C.thread_ts=E;return(await Yu(D,"chat.postMessage",C)).ts??""}async function V8(D,u,F,E,C){let B={channel:u,text:F,post_at:E,blocks:[{type:"markdown",text:F}]};if(C!==void 0)B.thread_ts=C;return(await Yu(D,"chat.scheduleMessage",B)).scheduled_message_id??""}async function q8(D,u){let F={};if(u)F.channel=u;return YD(D,"chat.scheduledMessages.list",F)}async function U8(D,u,F){await Yu(D,"chat.deleteScheduledMessage",{channel:u,scheduled_message_id:F})}async function _8(D,u,F,E){return(await Yu(D,"chat.update",{channel:u,ts:F,text:E,blocks:[{type:"markdown",text:E}]})).ts??F}async function CF(D){let u=[],F="";while(!0){let E={limit:"200",types:"public_channel,private_channel,im,mpim"};if(F)E.cursor=F;let C=await YD(D,"conversations.list",E);if(u.push(...C.channels??[]),F=C.response_metadata?.next_cursor??"",!F)break}return{channels:u}}async function BF(D,u){let E=(await Yu(D,"conversations.open",{users:u})).channel?.id;if(!E)throw Error(`Failed to open DM with user ${u}`);return E}function EF(D){return D.toLowerCase().replace(/[-_\s]/g,"")}function lF(D){let u=D.match(/(?:app\.slack\.com\/client\/T[A-Za-z0-9]+|[A-Za-z0-9-]+\.slack\.com\/archives)\/([A-Za-z0-9]+)(?:\/p(\d{10})(\d{6}))?/);if(!u)return;let F=u[1],E=u[2]&&u[3]?`${u[2]}.${u[3]}`:void 0;return E?{channel:F,ts:E}:{channel:F}}function x3(D){return lF(D)?.channel}async function ND(D,u,F){let E=x3(u);if(E)return E;if(!u.startsWith("@")&&!u.startsWith("#")){if(/^[A-Za-z0-9]{9,}$/.test(u))return u;throw Error(`Target must start with # or @ (or be a Slack URL/ID), got: ${u}`)}let C=u.startsWith("@"),B=u.slice(1),$=EF(B);if(C){let J="",O="";while(!0){let Q={limit:"200"};if(O)Q.cursor=O;let Y=await YD(D,"users.list",Q,F);for(let M of Y.members??[]){let H=EF(M.name??""),_=EF(M.real_name??""),S=EF(M.profile?.display_name??"");if(H===$||_===$||S&&S===$){J=M.id??"";break}}if(J)break;if(O=Y.response_metadata?.next_cursor??"",!O)break}if(!J)throw Error(`User not found: ${u}`);let X="";while(!0){let Q={types:"im",limit:"200"};if(X)Q.cursor=X;let Y=await YD(D,"conversations.list",Q,F);for(let M of Y.channels??[])if(M.user===J)return String(M.id??"");if(X=Y.response_metadata?.next_cursor??"",!X)break}throw Error(`No existing DM with ${u} (${J}). Open it once in Slack first.`)}let z=B.toLowerCase(),Z="";while(!0){let J={limit:"200",types:"public_channel,private_channel",exclude_archived:"true"};if(Z)J.cursor=Z;let O=await YD(D,"conversations.list",J,F);for(let X of O.channels??[])if(String(X.name??"").toLowerCase()===z)return String(X.id??"");if(Z=O.response_metadata?.next_cursor??"",!Z)break}throw Error(`channel not found: ${u}`)}async function Su(D,u){try{let F=await YD(D,"users.info",{user:u}),E=F.user?.profile?.display_name,C=E&&E.length>0?E:F.user?.real_name??F.user?.name??u,B=F.user?.name??u;return[C,B]}catch{return[u,u]}}async function j8(D,u){try{let F=await YD(D,"users.info",{user:u}),E=F.user?.profile?.display_name;if(E&&E.length>0)return E;return F.user?.real_name??F.user?.name??u}catch{return u}}async function oF(D){let u=[],F="";while(!0){let E={limit:"200"};if(F)E.cursor=F;let C=await YD(D,"users.list",E);if(u.push(...C.members??[]),F=C.response_metadata?.next_cursor??"",!F)break}return{members:u}}async function Pu(D,u){return Ou(D,"drafts.list",{},u)}async function K8(D,u,F,E){let{randomUUID:C}=await import("node:crypto"),B=JSON.stringify([{type:"rich_text",elements:[{type:"rich_text_section",elements:[{type:"text",text:F}]}]}]);return Ou(D,"drafts.create",{client_msg_id:C(),destinations:JSON.stringify([{channel_id:u}]),blocks:B,file_ids:JSON.stringify([]),is_from_composer:"true"},E)}async function T8(D,u,F,E,C){let B=JSON.stringify([{type:"rich_text",elements:[{type:"rich_text_section",elements:[{type:"text",text:E}]}]}]),$=(Date.now()/1000).toFixed(6);return Ou(D,"drafts.update",{draft_id:u,client_last_updated_ts:$,destinations:JSON.stringify([{channel_id:F}]),blocks:B,file_ids:JSON.stringify([])},C)}async function N8(D,u,F){return Ou(D,"conversations.info",{channel:u},F)}async function R8(D,u){return YD(D,"users.info",{user:u})}async function A8(D,u){return YD(D,"conversations.info",{channel:u})}async function L8(D,u,F){let E=(Date.now()/1000).toFixed(6);return Ou(D,"drafts.delete",{draft_id:u,client_last_updated_ts:E},F)}async function sF(D,u){let F=await Ou(D,"auth.test",{},u);return{userId:String(F.user_id??""),teamId:String(F.team_id??"")}}async function S8(D,u,F,E={}){let{statSync:C,readFileSync:B}=await import("node:fs"),{basename:$}=await import("node:path"),z=C(F),Z=$(F),J=await YD(D,"files.getUploadURLExternal",{filename:Z,length:String(z.size)}),O=J.upload_url,X=J.file_id;if(!O||!X)throw Error("files.getUploadURLExternal returned no upload_url/file_id");let Q=B(F),Y=await fetch(O,{method:"POST",headers:{"Content-Type":"application/octet-stream"},body:Q});if(!Y.ok)throw Error(`Upload PUT failed: ${Y.status} ${Y.statusText}`);let M={files:[{id:X,title:E.title??Z}],channel_id:u};if(E.threadTs)M.thread_ts=E.threadTs;if(E.initialComment)M.initial_comment=E.initialComment;let H=await Yu(D,"files.completeUploadExternal",M),_={fileId:X},S=H.files?.[0]?.permalink;if(S)_.permalink=S;return _}function Au(D,u){let F=D;for(let E of u){if(F===void 0||F===null)return;if(typeof E==="number"){if(!Array.isArray(F))return;F=F[E]??void 0}else{if(typeof F!=="object"||Array.isArray(F))return;F=F[E]}}return F}async function Wu(D,u,F){let E=u,C=[],B=E,$=0;while(!0){let z=B.indexOf("<@U",$);if(z===-1)break;let Z=B.slice(z+2),J=Z.search(/[>|]/),O=J===-1?Z:Z.slice(0,J);if(O.length>=9)C.push(O);$=z+1}for(let z of C){if(!F.has(z))F.set(z,await DF(D,z));let Z=F.get(z)??z;E=E.replaceAll(`<@${z}>`,`@${Z}`),E=E.replace(new RegExp(`<@${z}\\|[^>]*>`,"g"),`@${Z}`)}return E}function wu(D){return D.replace(/<!date\^(\d+)\^[^|>]*(?:\|([^>]*))?>/g,(u,F,E)=>{let C=Number(F);if(!Number.isFinite(C))return E??"date";let B=new Date(C*1000);if(Number.isNaN(B.getTime()))return E??"date";let $=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],z=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Z=$[B.getUTCDay()]??"",J=z[B.getUTCMonth()]??"";return`${Z}, ${J} ${String(B.getUTCDate()).padStart(2,"0")}, ${B.getUTCFullYear()}`})}function P8(D,u=new Date){let F=new Date(D*1000),E=rF(u),C=rF(new Date(u.getTime()-86400000)),B=rF(F);if(B===E)return"Today";if(B===C)return"Yesterday";let $=F.toLocaleDateString("en-US",{weekday:"long"}),z=F.toLocaleDateString("en-US",{month:"short"});return`${$}, ${z} ${String(F.getDate()).padStart(2,"0")}`}function rF(D){return`${D.getFullYear()}-${D.getMonth()}-${D.getDate()}`}function w8(D){let u=new Date(D*1000),F=u.getFullYear(),E=String(u.getMonth()+1).padStart(2,"0"),C=String(u.getDate()).padStart(2,"0"),B=String(u.getHours()).padStart(2,"0"),$=String(u.getMinutes()).padStart(2,"0");return`${F}-${E}-${C} ${B}:${$}`}function Iu(D){if(!f8(D))return;let u=h3(D,"utf8");for(let F of u.split(`
105
- `)){let E=F.trim();if(!E||E.startsWith("#"))continue;let C=E.indexOf("=");if(C===-1)continue;let B=E.slice(0,C).trim(),$=E.slice(C+1).trim();if($.startsWith('"')&&$.endsWith('"')||$.startsWith("'")&&$.endsWith("'"))$=$.slice(1,-1);if(!(B in process.env))process.env[B]=$}}function m3(D){v3(D,{recursive:!0});let u=Eu(D,".gitignore");if(!f8(u))p3(u,`*
106
- `)}function c3(){Iu(Eu(I8(),".slack-cli",".env.local")),Iu(Eu(I8(),".config/slack-cli",".env")),Iu(Eu(process.cwd(),".slack-cli",".env.local")),Iu(Eu(process.cwd(),".env.local")),Iu(Eu(process.cwd(),".env"))}function y3(D){return b3("sha256").update(D).digest("hex")}function y(D){return D&&typeof D==="object"&&!Array.isArray(D)?D:{}}function zD(D){return Array.isArray(D)?D:[]}function $F(D){return Number(D.ts??0)}async function x8(D,u,F){let E=u.user;if(typeof E==="string"){if(!F.has(E))F.set(E,await j8(D,E));return F.get(E)??E}return typeof u.username==="string"?u.username:"bot"}function aF(D){let u=new Date(D*1000),F=u.getUTCFullYear(),E=String(u.getUTCMonth()+1).padStart(2,"0"),C=String(u.getUTCDate()).padStart(2,"0"),B=String(u.getUTCHours()).padStart(2,"0"),$=String(u.getUTCMinutes()).padStart(2,"0"),z=String(u.getUTCSeconds()).padStart(2,"0");return`${F}-${E}-${C} ${B}:${$}:${z}`}function i3(D){let[u,F="000000"]=D.split("."),E=Number(u),C=new Date(E*1000),B=C.getUTCFullYear(),$=String(C.getUTCMonth()+1).padStart(2,"0"),z=String(C.getUTCDate()).padStart(2,"0"),Z=String(C.getUTCHours()).padStart(2,"0"),J=String(C.getUTCMinutes()).padStart(2,"0"),O=String(C.getUTCSeconds()).padStart(2,"0"),X=F.padEnd(6,"0").slice(0,6);return`${B}-${$}-${z}T${Z}:${J}:${O}.${X}`}function b8(D){let u=D.match(/^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})\.(\d{6})$/);if(!u)throw Error(`Invalid message timestamp "${D}" \u2014 expected 2026-05-11T06:01:04.000100`);let F=Date.parse(u[1]+"Z");if(isNaN(F))throw Error(`Cannot parse date in "${D}"`);return`${Math.floor(F/1000)}.${u[2]}`}function n3(D){return/^\d{4}-\d{2}-\d{2}T/.test(D)?b8(D):D}async function GF(D,u,F,E){let C=typeof u.ts==="string"?u.ts:`${$F(u)}.000000`,B=i3(C),$="?";if(typeof u.user==="string"){let Q=u.user,Y="@"+Q;if(!F.has(Y)){let[,M]=await Su(D,Q);F.set(Y,M)}$=F.get(Y)??Q}else if(typeof u.username==="string")$=u.username;let z=typeof u.text==="string"?u.text:"",J=wu(await Wu(D,z,F)).split(`
107
- `),O=J[0]+(J.length>1?`
108
- `+J.slice(1).map((Q)=>` ${Q}`).join(`
109
- `):""),X=E?`${E} @${$}`:`@${$}`;return`${B} ${X}: ${O}`}async function k3(D,u,F){let E=await ND(D,u),C=await Lu(D,E,F),B=zD(C.messages).map(y),$=new Map;for(let z of B.reverse())console.log(await GF(D,z,$))}async function d3(D,u,F,E){let C=await ND(D,u),B=await tF(D,C,n3(F),E),$=zD(B.messages).map(y),z=new Map;for(let Z of $)console.log(await GF(D,Z,z))}async function g3(D){let u=await CF(D),F=zD(u.channels).map(y).filter((C)=>C.is_member===!0).sort((C,B)=>Number(B.updated??0)-Number(C.updated??0)).slice(0,10),E=new Map;for(let C of F){let B=String(C.id??""),$=typeof C.name==="string"?C.name:typeof C.user==="string"?C.user:B,z=await Lu(D,B,5),Z=zD(z.messages).map(y).filter((J)=>J.subtype===void 0||J.subtype===null).filter((J)=>{let O=typeof J.text==="string"?J.text:"";return O.length>0&&!O.startsWith("<@")}).slice(0,3).reverse();if(Z.length===0)continue;console.log(`-- #${$} --------------------------------`);for(let J of Z){let O=await x8(D,J,E),X=(typeof J.text==="string"?J.text:"").split(`
110
- `)[0]??"",Q=await Wu(D,X,E);console.log(` ${O}: ${Q}`)}}}async function t3(D,u){let F=await W8(D,"to:me"),E=zD(Au(F,["messages","matches"])).map(y).slice(0,u),C=new Map,B=[];for(let $ of E){let z=P8($F($)),Z=B[B.length-1];if(Z?.label===z)Z.msgs.push($);else B.push({label:z,msgs:[$]})}for(let $=0;$<B.length;$++){let{label:z,msgs:Z}=B[$];if($>0)console.log("");console.log(` ${z}`),console.log(" ----------------------------");for(let J of[...Z].reverse()){let O=y(J.channel),X=O.is_im===!0,Q=typeof O.name==="string"?O.name:"dm",Y;if(X&&Q.startsWith("U")){let M="@"+Q;if(!C.has(M)){let[,H]=await Su(D,Q);C.set(M,H)}Y=`@${C.get(M)??Q}`}else if(X)Y=`@${Q}`;else Y=`#${Q}`;console.log(await GF(D,J,C,Y))}}}async function l3(D,u,F,E,C="text"){let B=await CF(D),$=zD(B.channels).map(y).filter((z)=>E||z.is_member===!0).filter((z)=>{if(!F)return!0;return(typeof z.name==="string"?z.name:"").toLowerCase().includes(F.toLowerCase())}).sort((z,Z)=>Number(Z.updated??0)-Number(z.updated??0)).slice(0,u);if(C==="jsonl"){for(let z of $)console.log(JSON.stringify(z));return}for(let z of $){let Z=String(z.id??""),J=typeof z.name==="string"?z.name:typeof z.user==="string"?z.user:Z,O=z.is_im===!0,X=z.is_mpim===!0,Q=O||X?"@":"#",Y=z.is_member===!0?"":" (not joined)",M=typeof y(z.purpose).value==="string"?String(y(z.purpose).value):"",H=M?` ${M.split(`
111
- `)[0]?.slice(0,60)}`:"";console.log(`${Q}${J} ${Z}${Y}${H}`)}}async function o3(D,u,F,E){let C=await M8(D,u,F);if(E){console.log(JSON.stringify(C,null,2));return}let B=zD(Au(C,["messages","matches"])).map(y),$=new Map;for(let z of B){let Z=y(z.channel),J=Z.is_im===!0,O=typeof Z.name==="string"?Z.name:"dm",X;if(J&&O.startsWith("U")){let Q="@"+O;if(!$.has(Q)){let[,Y]=await Su(D,O);$.set(Q,Y)}X=`@${$.get(Q)??O}`}else if(J)X=`@${O}`;else X=`#${O}`;console.log(await GF(D,z,$,X))}}async function s3(D,u,F,E){let C=Math.floor(Date.now()/1000)-u*86400,B=await CF(D),$=zD(B.channels).map(y).filter((O)=>O.is_member===!0&&O.is_im!==!0&&O.is_mpim!==!0).filter((O)=>{if(!E)return!0;return(typeof O.name==="string"?O.name:"").toLowerCase().includes(E.toLowerCase())}).sort((O,X)=>Number(X.updated??0)-Number(O.updated??0)),z=new Map,Z=0,J=0;for(let O of $){let X=String(O.id??""),Q=typeof O.name==="string"?O.name:X,Y;try{Y=await Lu(D,X,F)}catch(H){console.error(` SKIP #${Q}: ${H.message}`);continue}let M=zD(Y.messages).map(y).filter((H)=>(H.subtype===void 0||H.subtype===null)&&$F(H)>=C);if(M.length===0)continue;J+=1,Z+=M.length,console.log(`## #${Q} (${M.length} msgs)
112
- `);for(let H of[...M].reverse()){let _=await x8(D,H,z),S=typeof H.text==="string"?H.text:"",d=wu(await Wu(D,S,z)).split(`
113
- `).join(" \u21B5 ");console.log(`[${w8($F(H))}] ${_}: ${d}`)}console.log("")}console.error(`Dumped ${Z} messages across ${J} channels (cutoff: ${u}d)`)}function r3(D){let u=[];function F(E){if(typeof E==="string"){u.push(E);return}if(Array.isArray(E)){for(let C of E)F(C);return}if(E&&typeof E==="object"){let C=E;if(typeof C.text==="string"){u.push(C.text);return}if(Array.isArray(C.elements))F(C.elements);else if(Array.isArray(C.content))F(C.content)}}for(let E of D)F(E);return u.join("").trim()}async function h8(D,u,F){let E=new Map;return async(C)=>{if(!C)return"(unknown)";if(E.has(C))return E.get(C);try{let B=await N8(D,C,u),$=y(B.channel),z;if($.is_im===!0){let Z=typeof $.user==="string"?$.user:"";if(!Z||Z===F)z="@self";else{let[J]=await Su(D,Z);z=`@${J}`}}else z=`#${typeof $.name==="string"?$.name:C}`;return E.set(C,z),z}catch{return C}}}function eF(D){let u=y(zD(D.destinations)[0]);return String(u.channel_id??D.channel_id??D.channel??"")}function zF(D){return r3(zD(D.blocks))||(typeof D.text==="string"?D.text:"(no text)")}async function a3(D,u,F=!1){let E=await Pu(D,u),C=zD(E.drafts??E.messages??[]).map(y).filter((J)=>J.is_deleted!==!0),B=F?C:C.filter((J)=>J.is_sent!==!0);if(B.length===0){console.log(F?"No drafts.":"No pending drafts. Run with --all to include sent.");return}let $="";try{({userId:$}=await sF(D,u))}catch{}let z=await h8(D,u,$),Z=new Map;for(let J of B){let O=eF(J),X=zF(J),Q=Number(J.date_created??J.date_create??0),Y=Q?aF(Q):"?",M=await z(O),H=typeof J.id==="string"?J.id:"",_=J.is_sent===!0?" [SENT]":"",S=wu(await Wu(D,X,Z));console.log(`-- ${H} ${M} [${Y}]${_}`);for(let f of S.split(`
114
- `))console.log(` ${f}`)}}async function e3(D,u,F){let E=await Pu(D,u),C=zD(E.drafts).map(y).find((M)=>String(M.id)===F);if(!C)console.error(`Draft not found: ${F}`),process.exit(1);let B="";try{({userId:B}=await sF(D,u))}catch{}let $=await h8(D,u,B),z=eF(C),Z=zF(C),J=Number(C.date_created??0),O=String(C.last_updated_ts??"?"),X=await $(z),Y=wu(await Wu(D,Z,new Map));console.log(`id: ${C.id}`),console.log(`channel: ${X} (${z})`),console.log(`created: ${J?aF(J):"?"}`),console.log(`updated: ${aF(Number(O.split(".")[0]))}`),console.log(`status: ${C.is_sent===!0?"sent":"pending"}`),console.log("---"),console.log(Y)}function Cu(...D){return y3(D.join(`
115
- `)).slice(0,4)}function Bu(D,u,F){for(let E of F)console.log(E);if(D!==void 0)console.error(`Code mismatch (got ${D}, expected ${u})`);console.error(`Rerun with --code=${u}`),process.exit(1)}function D6(D){let u=lF(D);if(u)return u.ts?{ref:u.channel,ts:u.ts}:{ref:u.channel};if(D.startsWith("#")||D.startsWith("@")){let F=D.indexOf(":");if(F>0){let E=D.slice(F+1);if(/^\d{10}\.\d{6}$/.test(E))return{ref:D.slice(0,F),ts:E};if(/^\d{4}-\d{2}-\d{2}T/.test(E))return{ref:D.slice(0,F),ts:b8(E)}}}return{ref:D}}async function u6(D,u){let{ref:F,ts:E}=D6(u.target);if(!E)console.error("Error: target must embed a message ts (e.g. #chan:2026-05-11T06:01:04.000100 or a Slack permalink URL)"),process.exit(2);let C;if(u.channelId)C=u.channelId;else C=await ND(D,F);let B=await tF(D,C,E,1),z=zD(B.messages).map(y).find((X)=>String(X.ts)===E);if(!z)console.error(`Message not found at ts=${E} in channel ${C}`),process.exit(1);let Z=typeof z.text==="string"?z.text:"",J=Cu(Z,u.newText);if(u.code!==J)Bu(u.code,J,["--- Original message -------------------------",...Z.split(`
116
- `).map((X)=>` ${X}`),"--- Replacing with ---------------------------",...u.newText.split(`
117
- `).map((X)=>` ${X}`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);let O=await _8(D,C,E,u.newText);console.log(`\u2713 Edited (ts: ${O})`)}async function F6(D,u){let F;if(u.channelId)F=u.channelId;else if(u.userId)F=await BF(D,u.userId);else if(u.target.startsWith("#")||u.target.startsWith("@"))F=await ND(D,u.target);else console.error(`Error: target must be #channel-name or @username (got: ${u.target})`),console.error("Use --channel-id=<ID> or --user-id=<ID> to send by raw ID."),process.exit(1);let E=await Lu(D,F,1),C=zD(E.messages).map(y).filter((J)=>J.subtype===void 0||J.subtype===null)[0],B=typeof C?.text==="string"?C.text:"",$=typeof C?.user==="string"?C.user:"?",z=Cu(B,u.message);if(u.code!==z)Bu(u.code,z,["--- Last message in channel ------------------",` ${$}: ${B.split(`
118
- `)[0]?.slice(0,100)??"(empty)"}`,"--- Sending ----------------------------------",` To: ${u.target}${u.thread?` (thread ${u.thread})`:""}`,` Message: ${u.message}`,"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);let Z=await H8(D,F,u.message,u.thread);console.log(`\u2713 Sent (ts: ${Z})`)}function E6(D){if(/^\d{10,}$/.test(D))return parseInt(D,10);let u=new Date(D.replace(" ","T"));if(isNaN(u.getTime()))throw Error(`Cannot parse time: ${D}`);return Math.floor(u.getTime()/1000)}async function C6(D,u){let F;if(u.channelId)F=u.channelId;else if(u.userId)F=await BF(D,u.userId);else if(u.target.startsWith("#")||u.target.startsWith("@"))F=await ND(D,u.target);else console.error(`Error: target must be #channel-name or @username (got: ${u.target})`),process.exit(1);let E=E6(u.at),C=new Date(E*1000).toISOString(),B=Cu(F,u.message,String(E));if(u.code!==B)Bu(u.code,B,["--- Scheduling message -----------------------",` To: ${u.target}${u.thread?` (thread ${u.thread})`:""}`,` At: ${C} (Unix: ${E})`,` Message: ${u.message}`,"---------------------------------------------"]);let $=await V8(D,F,u.message,E,u.thread);console.log(`\u2713 Scheduled (id: ${$}, at: ${C})`)}async function B6(D,u,F){let E;if(F)E=F;else if(u)E=await ND(D,u);let B=(await q8(D,E)).scheduled_messages??[];if(B.length===0){console.log("(no scheduled messages)");return}for(let $ of B){let z=new Date($.post_at*1000).toISOString();console.log(`${$.id} ${z} [${$.channel_id}] ${$.text.split(`
119
- `)[0]?.slice(0,80)??""}`)}}async function $6(D,u){let F;if(u.channelId)F=u.channelId;else F=await ND(D,u.target);let E=Cu(F,u.id);if(u.code!==E)Bu(u.code,E,["--- Deleting scheduled message ---------------",` Channel: ${u.target}`,` ID: ${u.id}`,"---------------------------------------------"]);await U8(D,F,u.id),console.log(`\u2713 Deleted scheduled message ${u.id}`)}async function z6(D,u){let{statSync:F,existsSync:E}=await import("fs"),{basename:C}=await import("path");for(let X of u.filePaths)if(!E(X))console.error(`Error: file not found: ${X}`),process.exit(1);let B;if(u.channelId)B=u.channelId;else if(u.userId)B=await BF(D,u.userId);else if(u.target.startsWith("#")||u.target.startsWith("@"))B=await ND(D,u.target);else console.error(`Error: target must be #channel-name or @username (got: ${u.target})`),process.exit(1);function $(X){return X<1024?`${X} B`:X<1048576?`${(X/1024).toFixed(1)} KB`:`${(X/1048576).toFixed(1)} MB`}let z=u.filePaths.length>1,Z=u.filePaths.map((X)=>{let Q=C(X),Y=z?Q:u.title??Q;return{fp:X,filename:Q,title:Y,sizeFmt:$(F(X).size)}}),J=Cu(B,...Z.flatMap((X)=>[X.fp,X.title]));if(u.code!==J){let X=` To: ${u.target}${u.thread?` (thread ${u.thread})`:""}`,Q=z?[`--- Uploading ${Z.length} files ------------------------`,X,...Z.map((Y)=>` ${Y.filename} (${Y.sizeFmt})`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]:["--- Uploading file ---------------------------",X,` File: ${Z[0].fp}`,` Title: ${Z[0].title}`,` Size: ${Z[0].sizeFmt}`,"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"];Bu(u.code,J,Q)}let O=Z.length;for(let X=0;X<O;X++){let Q=Z[X],Y={title:Q.title};if(u.thread!==void 0)Y.threadTs=u.thread;if(u.comment!==void 0&&X===0)Y.initialComment=u.comment;let{fileId:M,permalink:H}=await S8(D,B,Q.fp,Y),_=O>1?`[${X+1}/${O}] `:"";console.log(`${_}\u2713 Uploaded (file_id: ${M}${H?`, url: ${H}`:""})`)}}async function G6(){c3();let D=(F)=>iF(F.workspace),u=(F)=>d2(F.workspace);await b2(KF(process.argv)).scriptName("slack").option("workspace",{alias:"w",type:"string",describe:"Workspace name"}).middleware(async(F)=>{let E=String((F._??[])[0]??"");if(!E||E==="auth"||E==="login")return;try{iF(F.workspace)}catch(C){if((C instanceof Error?C.message:String(C)).startsWith("No profiles configured"))console.log(`No workspace configured. Let's set that up:
120
- `),await FF(),process.exit(0);throw C}},!0).command(["read [target]","msgs [target]"],"Browse messages",(F)=>F.positional("target",{type:"string",describe:"#channel, @user, or URL"}).option("limit",{alias:"n",type:"number",default:20,describe:"Number of messages"}),async(F)=>{let E=D(F);if(F.target)await k3(E,F.target,F.limit);else await g3(E)}).command("thread <target> <ts>","Show thread messages",(F)=>F.positional("target",{type:"string",demandOption:!0}).positional("ts",{type:"string",demandOption:!0}).option("limit",{alias:"n",type:"number",default:100}),async(F)=>{await d3(D(F),F.target,F.ts,F.limit)}).command(["channel","channels","ch"],"Channel commands",(F)=>F.command(["ls","list"],"List channels",(E)=>E.option("limit",{alias:"n",type:"number",default:200}).option("filter",{alias:"f",type:"string"}).option("all",{type:"boolean",default:!1}).option("format",{type:"string",choices:["text","jsonl"],default:"text"}).option("json",{type:"boolean",default:!1,describe:"Alias for --format=jsonl"}),async(E)=>{await l3(D(E),E.limit,E.filter,E.all,E.json?"jsonl":E.format)}).command("get <channel>","Show channel details",(E)=>E.positional("channel",{type:"string",demandOption:!0,describe:"#name or channel ID"}),async(E)=>{let C=D(E),B=E.channel,$=B.startsWith("#")||B.startsWith("@")||B.startsWith("C")||B.startsWith("G")||B.startsWith("D")?B:`#${B}`,z=await ND(C,$),Z=y(await A8(C,z)),J=y(Z.channel),O=typeof J.name==="string"?J.name:z,Q=J.is_im===!0?"@":"#",Y=String(y(J.purpose).value??""),M=String(y(J.topic).value??""),H=J.num_members??J.member_count??"";if(console.log(`${Q}${O} ${z}`),M)console.log(`topic: ${M}`);if(Y)console.log(`purpose: ${Y}`);if(H)console.log(`members: ${H}`);console.log(`private: ${J.is_private===!0}`)}).demandCommand(1,"").showHelpOnFail(!0)).command(["user","usr"],"User commands",(F)=>F.command(["ls","list"],"List workspace members",(E)=>E.option("limit",{alias:"n",type:"number",default:200}).option("filter",{alias:"f",type:"string"}).option("format",{type:"string",choices:["text","jsonl","yaml"],default:"text"}).option("json",{type:"boolean",default:!1,describe:"Alias for --format=jsonl"}),async(E)=>{let C=E.json?"jsonl":E.format,B=await oF(D(E)),$=E.filter?.toLowerCase(),z=zD(B.members).map(y).filter((J)=>J.deleted!==!0&&J.is_bot!==!0&&String(J.id)!=="USLACKBOT").filter((J)=>{if(!$)return!0;let O=String(J.name??"").toLowerCase(),X=String(y(J.profile).real_name??"").toLowerCase(),Q=String(y(J.profile).email??"").toLowerCase();return O.includes($)||X.includes($)||Q.includes($)}).slice(0,E.limit);if(C==="jsonl"){for(let J of z)console.log(JSON.stringify(J));return}if(C==="yaml"){for(let J of z){let O=function(X,Q=""){if(X===null)return"null";if(typeof X==="string")return X.includes(`
123
+ `+"Get xoxd from browser: DevTools → Application → Cookies → slack.com → d");throw Error(`Slack error on ${u}: ${z}`)}return $}function Ku(D,u,F={},E){let C=new URLSearchParams({token:D,...F});return I6(D,u,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:C.toString()},E)}function BD(D,u,F,E){let C=new URLSearchParams(F).toString();return B1(D,`${u}?${C}`,{method:"GET"},E)}function Yu(D,u,F){return B1(D,u,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(F)})}async function $1(D){let u=await BD(D,"auth.test",{});return{team:u.team??"",teamId:u.team_id??"",url:u.url??"",user:u.user??"",userId:u.user_id??""}}async function fu(D,u,F=20,E,C){let B={channel:u,limit:String(F)};if(E!==void 0)B.oldest=E;if(C!==void 0)B.cursor=C;return BD(D,"conversations.history",B)}async function ju(D,u,F,E=50){return BD(D,"conversations.replies",{channel:u,ts:F,limit:String(E)})}async function z1(D,u,F,E){return BD(D,"search.messages",{query:u,sort:"timestamp",sort_dir:"desc",count:String(Math.min(Math.max(F,1),100)),page:String(Math.max(E,1))})}async function G1(D,u){return z1(D,u,100,1)}async function Z1(D,u,F){let C=1,B=[],$={ok:!0,messages:{}};while(!0){let G=await z1(D,u,100,C),Z=bu(G,["messages","matches"]),Q=Array.isArray(Z)?Z:[];B.push(...Q);let J=Number(bu(G,["messages","paging","pages"])??1);if($=G,Q.length===0||C>=J||B.length>=F)break;C+=1}let z=$;if(!z.messages)z.messages={};return z.messages.matches=B.slice(0,F),z}async function J1(D,u,F,E,C){let B={channel:u,text:F,blocks:[{type:"markdown",text:F}]};if(E!==void 0)B.thread_ts=E;if(C&&E!==void 0)B.reply_broadcast=!0;return(await Yu(D,"chat.postMessage",B)).ts??""}async function X1(D,u,F,E,C){let B={channel:u,text:F,post_at:E,blocks:[{type:"markdown",text:F}]};if(C!==void 0)B.thread_ts=C;return(await Yu(D,"chat.scheduleMessage",B)).scheduled_message_id??""}async function Q1(D,u){let F={};if(u)F.channel=u;return BD(D,"chat.scheduledMessages.list",F)}async function O1(D,u,F){await Yu(D,"chat.deleteScheduledMessage",{channel:u,scheduled_message_id:F})}async function Y1(D,u,F){return(await BD(D,"chat.getPermalink",{channel:u,message_ts:F})).permalink??""}async function W1(D,u,F,E){return(await Yu(D,"chat.update",{channel:u,ts:F,text:E,blocks:[{type:"markdown",text:E}]})).ts??F}async function H1(D,u,F){await Yu(D,"chat.delete",{channel:u,ts:F})}async function _F(D){let u=[],F="";while(!0){let E={limit:"200",types:"public_channel,private_channel,im,mpim"};if(F)E.cursor=F;let C=await BD(D,"conversations.list",E);if(u.push(...C.channels??[]),F=C.response_metadata?.next_cursor??"",!F)break}return{channels:u}}async function hu(D,u){let E=(await Yu(D,"conversations.open",{users:u})).channel?.id;if(!E)throw Error(`Failed to open DM with user ${u}`);return E}function xD(D){return D.toLowerCase().replace(/[-_\s]/g,"")}async function M1(D,u,F){if(!u.startsWith("@")){if(/^[UW][A-Za-z0-9]{6,}$/.test(u))return u;throw Error(`Expected @user or a user ID, got: ${u}`)}let E=xD(u.slice(1)),C=await BD(D,"auth.test",{},F);if(E==="you"||E==="me"||xD(C.user??"")===E){if(!C.user_id)throw Error("auth.test did not return user_id");return C.user_id}let B="";while(!0){let $={limit:"200"};if(B)$.cursor=B;let z=await BD(D,"users.list",$,F);for(let G of z.members??[]){let Z=xD(G.name??""),Q=xD(G.real_name??""),J=xD(G.profile?.display_name??"");if(Z===E||Q===E||J&&J===E)return G.id??""}if(B=z.response_metadata?.next_cursor??"",!B)break}throw Error(`User not found: ${u}`)}function vu(D){let u=D.match(/(?:app\.slack\.com\/client\/T[A-Za-z0-9]+|[A-Za-z0-9-]+\.slack\.com\/archives)\/([A-Za-z0-9]+)(?:\/p(\d{10})(\d{6}))?/);if(!u)return;let F=u[1],E=u[2]&&u[3]?`${u[2]}.${u[3]}`:void 0,C=D.indexOf("?"),B=C>=0?new URLSearchParams(D.slice(C)):void 0,$=B?.get("thread_ts")??void 0,Z={channel:B?.get("cid")??void 0??F};if(E)Z.ts=E;if($)Z.threadTs=$;return Z}function b6(D){return vu(D)?.channel}async function ND(D,u,F){let E=b6(u);if(E)return E;if(!u.startsWith("@")&&!u.startsWith("#")){if(/^[A-Za-z0-9]{9,}$/.test(u))return u;throw Error(`Target must start with # or @ (or be a Slack URL/ID), got: ${u}`)}let C=u.startsWith("@"),B=u.slice(1),$=xD(B);if(C){let Z=await BD(D,"auth.test",{},F);if($==="you"||$==="me"||xD(Z.user??"")===$){let H=Z.user_id;if(!H)throw Error("auth.test did not return user_id");let q=((await BD(D,"conversations.list",{types:"im",limit:"200"},F)).channels??[]).find((j)=>j.user===H);if(q?.id)return String(q.id);return hu(D,H)}let J="",Y="";while(!0){let H={limit:"200"};if(Y)H.cursor=Y;let O=await BD(D,"users.list",H,F);for(let q of O.members??[]){let j=xD(q.name??""),N=xD(q.real_name??""),k=xD(q.profile?.display_name??"");if(j===$||N===$||k&&k===$){J=q.id??"";break}}if(J)break;if(Y=O.response_metadata?.next_cursor??"",!Y)break}if(!J)throw Error(`User not found: ${u}`);let W="";while(!0){let H={types:"im",limit:"200"};if(W)H.cursor=W;let O=await BD(D,"conversations.list",H,F);for(let q of O.channels??[])if(q.user===J)return String(q.id??"");if(W=O.response_metadata?.next_cursor??"",!W)break}throw Error(`No existing DM with ${u} (${J}). Open it once in Slack first.`)}let z=B.toLowerCase(),G="";while(!0){let Z={limit:"200",types:"public_channel,private_channel",exclude_archived:"true"};if(G)Z.cursor=G;let Q=await BD(D,"conversations.list",Z,F);for(let J of Q.channels??[])if(String(J.name??"").toLowerCase()===z)return String(J.id??"");if(G=Q.response_metadata?.next_cursor??"",!G)break}throw Error(`channel not found: ${u}`)}async function mu(D,u){try{let F=await BD(D,"users.info",{user:u}),E=F.user?.profile?.display_name,C=E&&E.length>0?E:F.user?.real_name??F.user?.name??u,B=F.user?.name??u;return[C,B]}catch{return[u,u]}}async function pu(D,u){try{let F=await BD(D,"users.info",{user:u}),E=F.user?.profile?.display_name;if(E&&E.length>0)return E;return F.user?.real_name??F.user?.name??u}catch{return u}}async function K0(D){let u=[],F="";while(!0){let E={limit:"200"};if(F)E.cursor=F;let C=await BD(D,"users.list",E);if(u.push(...C.members??[]),F=C.response_metadata?.next_cursor??"",!F)break}return{members:u}}async function yu(D,u){return Ku(D,"drafts.list",{},u)}async function V1(D,u,F,E){let{randomUUID:C}=await import("node:crypto"),B=JSON.stringify([{type:"rich_text",elements:[{type:"rich_text_section",elements:[{type:"text",text:F}]}]}]);return Ku(D,"drafts.create",{client_msg_id:C(),destinations:JSON.stringify([{channel_id:u}]),blocks:B,file_ids:JSON.stringify([]),is_from_composer:"true"},E)}async function U1(D,u,F,E,C){let B=JSON.stringify([{type:"rich_text",elements:[{type:"rich_text_section",elements:[{type:"text",text:E}]}]}]),$=(Date.now()/1000).toFixed(6);return Ku(D,"drafts.update",{draft_id:u,client_last_updated_ts:$,destinations:JSON.stringify([{channel_id:F}]),blocks:B,file_ids:JSON.stringify([])},C)}async function q1(D,u,F){return Ku(D,"conversations.info",{channel:u},F)}async function _1(D,u){return BD(D,"users.info",{user:u})}async function j0(D,u){return BD(D,"conversations.info",{channel:u})}async function K1(D,u,F){let E=(Date.now()/1000).toFixed(6);return Ku(D,"drafts.delete",{draft_id:u,client_last_updated_ts:E},F)}async function A0(D,u){let F=await Ku(D,"auth.test",{},u);return{userId:String(F.user_id??""),teamId:String(F.team_id??"")}}async function j1(D,u,F,E={}){let{statSync:C,readFileSync:B}=await import("node:fs"),{basename:$}=await import("node:path"),z=C(F),G=$(F),Z=await BD(D,"files.getUploadURLExternal",{filename:G,length:String(z.size)}),Q=Z.upload_url,J=Z.file_id;if(!Q||!J)throw Error("files.getUploadURLExternal returned no upload_url/file_id");let Y=B(F),W=await fetch(Q,{method:"POST",headers:{"Content-Type":"application/octet-stream"},body:Y});if(!W.ok)throw Error(`Upload PUT failed: ${W.status} ${W.statusText}`);let H={files:[{id:J,title:E.title??G}],channel_id:u};if(E.threadTs)H.thread_ts=E.threadTs;if(E.initialComment)H.initial_comment=E.initialComment;let O=await Yu(D,"files.completeUploadExternal",H),q={fileId:J},j=O.files?.[0]?.permalink;if(j)q.permalink=j;return q}function bu(D,u){let F=D;for(let E of u){if(F===void 0||F===null)return;if(typeof E==="number"){if(!Array.isArray(F))return;F=F[E]??void 0}else{if(typeof F!=="object"||Array.isArray(F))return;F=F[E]}}return F}async function Au(D,u,F){let E=u,C=[],B=E,$=0;while(!0){let z=B.indexOf("<@U",$);if(z===-1)break;let G=B.slice(z+2),Z=G.search(/[>|]/),Q=Z===-1?G:G.slice(0,Z);if(Q.length>=9)C.push(Q);$=z+1}for(let z of C){if(!F.has(z))F.set(z,await XF(D,z));let G=F.get(z)??z;E=E.replaceAll(`<@${z}>`,`@${G}`),E=E.replace(new RegExp(`<@${z}\\|[^>]*>`,"g"),`@${G}`)}return E}function cu(D){return D.replace(/<!date\^(\d+)\^[^|>]*(?:\|([^>]*))?>/g,(u,F,E)=>{let C=Number(F);if(!Number.isFinite(C))return E??"date";let B=new Date(C*1000);if(Number.isNaN(B.getTime()))return E??"date";let $=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],z=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],G=$[B.getUTCDay()]??"",Z=z[B.getUTCMonth()]??"";return`${G}, ${Z} ${String(B.getUTCDate()).padStart(2,"0")}, ${B.getUTCFullYear()}`})}function A1(D,u=new Date){let F=new Date(D*1000),E=L0(u),C=L0(new Date(u.getTime()-86400000)),B=L0(F);if(B===E)return"Today";if(B===C)return"Yesterday";let $=F.toLocaleDateString("en-US",{weekday:"long"}),z=F.toLocaleDateString("en-US",{month:"short"});return`${$}, ${z} ${String(F.getDate()).padStart(2,"0")}`}function L0(D){return`${D.getFullYear()}-${D.getMonth()}-${D.getDate()}`}function L1(D){let u=new Date(D*1000),F=u.getFullYear(),E=String(u.getMonth()+1).padStart(2,"0"),C=String(u.getDate()).padStart(2,"0"),B=String(u.getHours()).padStart(2,"0"),$=String(u.getMinutes()).padStart(2,"0");return`${F}-${E}-${C} ${B}:${$}`}function gu(D){if(!R1(D))return;let u=h6(D,"utf8");for(let F of u.split(`
124
+ `)){let E=F.trim();if(!E||E.startsWith("#"))continue;let C=E.indexOf("=");if(C===-1)continue;let B=E.slice(0,C).trim(),$=E.slice(C+1).trim();if($.startsWith('"')&&$.endsWith('"')||$.startsWith("'")&&$.endsWith("'"))$=$.slice(1,-1);if(!(B in process.env))process.env[B]=$}}function p6(D){v6(D,{recursive:!0});let u=Wu(D,".gitignore");if(!R1(u))m6(u,`*
125
+ `)}function y6(){gu(Wu(N1(),".slack-cli",".env.local")),gu(Wu(N1(),".config/slack-cli",".env")),gu(Wu(process.cwd(),".slack-cli",".env.local")),gu(Wu(process.cwd(),".env.local")),gu(Wu(process.cwd(),".env"))}function c6(D){return f6("sha256").update(D).digest("hex")}function y(D){return D&&typeof D==="object"&&!Array.isArray(D)?D:{}}function a(D){return Array.isArray(D)?D:[]}function KF(D){return Number(D.ts??0)}async function T1(D,u,F){let E=u.user;if(typeof E==="string"){if(!F.has(E))F.set(E,await pu(D,E));return F.get(E)??E}return typeof u.username==="string"?u.username:"bot"}function N0(D){let u=new Date(D*1000),F=u.getUTCFullYear(),E=String(u.getUTCMonth()+1).padStart(2,"0"),C=String(u.getUTCDate()).padStart(2,"0"),B=String(u.getUTCHours()).padStart(2,"0"),$=String(u.getUTCMinutes()).padStart(2,"0"),z=String(u.getUTCSeconds()).padStart(2,"0");return`${F}-${E}-${C} ${B}:${$}:${z}`}function R0(D){let[u,F="000000"]=D.split("."),E=Number(u),C=new Date(E*1000),B=C.getUTCFullYear(),$=String(C.getUTCMonth()+1).padStart(2,"0"),z=String(C.getUTCDate()).padStart(2,"0"),G=String(C.getUTCHours()).padStart(2,"0"),Z=String(C.getUTCMinutes()).padStart(2,"0"),Q=String(C.getUTCSeconds()).padStart(2,"0"),J=F.padEnd(6,"0").slice(0,6);return`${B}-${$}-${z}T${G}:${Z}:${Q}.${J}`}function T0(D){let u=D.match(/^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})\.(\d{6})$/);if(!u)throw Error(`Invalid message timestamp "${D}" \u2014 expected 2026-05-11T06:01:04.000100`);let F=Date.parse(u[1]+"Z");if(isNaN(F))throw Error(`Cannot parse date in "${D}"`);return`${Math.floor(F/1000)}.${u[2]}`}function g6(D){return/^\d{4}-\d{2}-\d{2}T/.test(D)?T0(D):D}async function ku(D,u,F,E){let C=typeof u.ts==="string"?u.ts:`${KF(u)}.000000`,B=R0(C),$="?";if(typeof u.user==="string"){let H=u.user,O="@"+H;if(!F.has(O)){let[,q]=await mu(D,H);F.set(O,q)}$=F.get(O)??H}else if(typeof u.username==="string")$=u.username;let z=typeof u.text==="string"?u.text:"",Z=cu(await Au(D,z,F)).split(`
126
+ `),Q=Z[0]+(Z.length>1?`
127
+ `+Z.slice(1).map((H)=>` ${H}`).join(`
128
+ `):""),J=E?`${E} @${$}`:`@${$}`,Y=a(u.reactions).map(y).map((H)=>{let O=typeof H.name==="string"?H.name:"",q=Number(H.count??a(H.users).length??0);return O?`:${O}:\xD7${q}`:""}).filter(Boolean).join(" "),W=Y?`
129
+ ${Y}`:"";return`${B} ${J}: ${Q}${W}`}async function k6(D,u,F){let E=vu(u),C=await ND(D,u),B=new Map;if(E?.threadTs){let $=await ju(D,C,E.threadTs,F),z=a($.messages).map(y);for(let G of z)console.log(await ku(D,G,B))}else{let $=await fu(D,C,F),z=a($.messages).map(y);for(let G of z.reverse())console.log(await ku(D,G,B))}}async function d6(D,u,F,E){let C=await ND(D,u),B=await ju(D,C,g6(F),E),$=a(B.messages).map(y),z=new Map;for(let G of $)console.log(await ku(D,G,z))}async function i6(D){let u=await _F(D),F=a(u.channels).map(y).filter((C)=>C.is_member===!0).sort((C,B)=>Number(B.updated??0)-Number(C.updated??0)).slice(0,10),E=new Map;for(let C of F){let B=String(C.id??""),$=typeof C.name==="string"?C.name:typeof C.user==="string"?C.user:B,z=await fu(D,B,5),G=a(z.messages).map(y).filter((Z)=>Z.subtype===void 0||Z.subtype===null).filter((Z)=>{let Q=typeof Z.text==="string"?Z.text:"";return Q.length>0&&!Q.startsWith("<@")}).slice(0,3).reverse();if(G.length===0)continue;console.log(`-- #${$} --------------------------------`);for(let Z of G){let Q=await T1(D,Z,E),J=(typeof Z.text==="string"?Z.text:"").split(`
130
+ `)[0]??"",Y=await Au(D,J,E);console.log(` ${Q}: ${Y}`)}}}async function n6(D,u){let F=await G1(D,"to:me"),E=a(bu(F,["messages","matches"])).map(y).slice(0,u),C=new Map,B=[];for(let $ of E){let z=A1(KF($)),G=B[B.length-1];if(G?.label===z)G.msgs.push($);else B.push({label:z,msgs:[$]})}for(let $=0;$<B.length;$++){let{label:z,msgs:G}=B[$];if($>0)console.log("");console.log(` ${z}`),console.log(" ----------------------------");for(let Z of[...G].reverse()){let Q=y(Z.channel),J=Q.is_im===!0,Y=typeof Q.name==="string"?Q.name:"dm",W;if(J&&Y.startsWith("U")){let H="@"+Y;if(!C.has(H)){let[,O]=await mu(D,Y);C.set(H,O)}W=`@${C.get(H)??Y}`}else if(J)W=`@${Y}`;else W=`#${Y}`;console.log(await ku(D,Z,C,W))}}}async function t6(D,u,F,E,C="text"){let B=await _F(D),$=a(B.channels).map(y).filter((z)=>E||z.is_member===!0).filter((z)=>{if(!F)return!0;return(typeof z.name==="string"?z.name:"").toLowerCase().includes(F.toLowerCase())}).sort((z,G)=>Number(G.updated??0)-Number(z.updated??0)).slice(0,u);if(C==="jsonl"){for(let z of $)console.log(JSON.stringify(z));return}for(let z of $){let G=String(z.id??""),Z=typeof z.name==="string"?z.name:typeof z.user==="string"?z.user:G,Q=z.is_im===!0,J=z.is_mpim===!0,Y=Q||J?"@":"#",W=z.is_member===!0?"":" (not joined)",H=typeof y(z.purpose).value==="string"?String(y(z.purpose).value):"",O=H?` ${H.split(`
131
+ `)[0]?.slice(0,60)}`:"";console.log(`${Y}${Z} ${G}${W}${O}`)}}async function l6(D,u,F,E){let C=await Z1(D,u,F);if(E){console.log(JSON.stringify(C,null,2));return}let B=a(bu(C,["messages","matches"])).map(y),$=new Map;for(let z of B){let G=y(z.channel),Z=G.is_im===!0,Q=typeof G.name==="string"?G.name:"dm",J;if(Z&&Q.startsWith("U")){let Y="@"+Q;if(!$.has(Y)){let[,W]=await mu(D,Q);$.set(Y,W)}J=`@${$.get(Y)??Q}`}else if(Z)J=`@${Q}`;else J=`#${Q}`;console.log(await ku(D,z,$,J))}}async function o6(D,u,F,E){let C=Math.floor(Date.now()/1000)-u*86400,B=await _F(D),$=a(B.channels).map(y).filter((Q)=>Q.is_member===!0&&Q.is_im!==!0&&Q.is_mpim!==!0).filter((Q)=>{if(!E)return!0;return(typeof Q.name==="string"?Q.name:"").toLowerCase().includes(E.toLowerCase())}).sort((Q,J)=>Number(J.updated??0)-Number(Q.updated??0)),z=new Map,G=0,Z=0;for(let Q of $){let J=String(Q.id??""),Y=typeof Q.name==="string"?Q.name:J,W;try{W=await fu(D,J,F)}catch(O){console.error(` SKIP #${Y}: ${O.message}`);continue}let H=a(W.messages).map(y).filter((O)=>(O.subtype===void 0||O.subtype===null)&&KF(O)>=C);if(H.length===0)continue;Z+=1,G+=H.length,console.log(`## #${Y} (${H.length} msgs)
132
+ `);for(let O of[...H].reverse()){let q=await T1(D,O,z),j=typeof O.text==="string"?O.text:"",k=cu(await Au(D,j,z)).split(`
133
+ `).join(" \u21B5 ");console.log(`[${L1(KF(O))}] ${q}: ${k}`)}console.log("")}console.error(`Dumped ${G} messages across ${Z} channels (cutoff: ${u}d)`)}function s6(D){let u=[];function F(E){if(typeof E==="string"){u.push(E);return}if(Array.isArray(E)){for(let C of E)F(C);return}if(E&&typeof E==="object"){let C=E;if(typeof C.text==="string"){u.push(C.text);return}if(Array.isArray(C.elements))F(C.elements);else if(Array.isArray(C.content))F(C.content)}}for(let E of D)F(E);return u.join("").trim()}async function S1(D,u,F){let E=new Map;return async(C)=>{if(!C)return"(unknown)";if(E.has(C))return E.get(C);try{let B=await q1(D,C,u),$=y(B.channel),z;if($.is_im===!0){let G=typeof $.user==="string"?$.user:"";if(!G||G===F)z="@self";else{let[Z]=await mu(D,G);z=`@${Z}`}}else z=`#${typeof $.name==="string"?$.name:C}`;return E.set(C,z),z}catch{return C}}}function S0(D){let u=y(a(D.destinations)[0]);return String(u.channel_id??D.channel_id??D.channel??"")}function jF(D){return s6(a(D.blocks))||(typeof D.text==="string"?D.text:"(no text)")}async function r6(D,u,F=!1){let E=await yu(D,u),C=a(E.drafts??E.messages??[]).map(y).filter((Z)=>Z.is_deleted!==!0),B=F?C:C.filter((Z)=>Z.is_sent!==!0);if(B.length===0){console.log(F?"No drafts.":"No pending drafts. Run with --all to include sent.");return}let $="";try{({userId:$}=await A0(D,u))}catch{}let z=await S1(D,u,$),G=new Map;for(let Z of B){let Q=S0(Z),J=jF(Z),Y=Number(Z.date_created??Z.date_create??0),W=Y?N0(Y):"?",H=await z(Q),O=typeof Z.id==="string"?Z.id:"",q=Z.is_sent===!0?" [SENT]":"",j=cu(await Au(D,J,G));console.log(`-- ${O} ${H} [${W}]${q}`);for(let N of j.split(`
134
+ `))console.log(` ${N}`)}}async function a6(D,u,F){let E=await yu(D,u),C=a(E.drafts).map(y).find((H)=>String(H.id)===F);if(!C)console.error(`Draft not found: ${F}`),process.exit(1);let B="";try{({userId:B}=await A0(D,u))}catch{}let $=await S1(D,u,B),z=S0(C),G=jF(C),Z=Number(C.date_created??0),Q=String(C.last_updated_ts??"?"),J=await $(z),W=cu(await Au(D,G,new Map));console.log(`id: ${C.id}`),console.log(`channel: ${J} (${z})`),console.log(`created: ${Z?N0(Z):"?"}`),console.log(`updated: ${N0(Number(Q.split(".")[0]))}`),console.log(`status: ${C.is_sent===!0?"sent":"pending"}`),console.log("---"),console.log(W)}function iD(...D){return c6(D.join(`
135
+ `)).slice(0,4)}function nD(D,u,F){for(let E of F)console.log(E);if(D!==void 0)console.error(`Code mismatch (got ${D}, expected ${u})`);console.error(`Rerun with --code=${u}`),process.exit(1)}function P1(D){let u=vu(D);if(u)return u.ts?{ref:u.channel,ts:u.ts}:{ref:u.channel};if(D.startsWith("#")||D.startsWith("@")){let F=D.indexOf(":");if(F>0){let E=D.slice(F+1);if(/^\d{10}\.\d{6}$/.test(E))return{ref:D.slice(0,F),ts:E};if(/^\d{4}-\d{2}-\d{2}T/.test(E))return{ref:D.slice(0,F),ts:T0(E)}}}return{ref:D}}function P0(D){let u=vu(D);if(u){let E=u.threadTs??u.ts;return E?{ref:u.channel,threadTs:E}:{ref:u.channel}}let F=D.indexOf(":");if(F>0){let E=D.slice(F+1);if(/^\d{10}\.\d{6}$/.test(E))return{ref:D.slice(0,F),threadTs:E};if(/^\d{4}-\d{2}-\d{2}T/.test(E))return{ref:D.slice(0,F),threadTs:T0(E)}}return{ref:D}}async function w1(D,u,F){let E=F;if(!F.startsWith("#")&&!F.startsWith("@"))try{let C=y(await j0(D,u)),B=y(C.channel);if(B.is_im===!0){let $=typeof B.user==="string"?B.user:"";E=$?`@${await pu(D,$)}`:u}else E=typeof B.name==="string"?`#${B.name}`:u}catch{E=u}return E===u?u:`${E} (${u})`}async function e6(D,u,F){try{let E=await ju(D,u,F,1),C=a(E.messages).map(y),B=C.find((Q)=>String(Q.ts)===F)??C[0];if(!B)return F;let $=typeof B.user==="string"?await pu(D,B.user):typeof B.username==="string"?B.username:"?",z=(typeof B.text==="string"?B.text:"").split(`
136
+ `)[0]??"",G=z.length>40?`${z.slice(0,40)}\u2026`:z;return`${R0(F).slice(0,16).replace("T"," ")} @${$}${G?`: ${G}`:""}`}catch{return F}}async function D7(D,u){let{ref:F,ts:E}=P1(u.target);if(!E)console.error("Error: target must embed a message ts (e.g. #chan:2026-05-11T06:01:04.000100 or a Slack permalink URL)"),process.exit(2);let C;if(u.channelId)C=u.channelId;else C=await ND(D,F);let B=await ju(D,C,E,1),z=a(B.messages).map(y).find((J)=>String(J.ts)===E);if(!z)console.error(`Message not found at ts=${E} in channel ${C}`),process.exit(1);let G=typeof z.text==="string"?z.text:"",Z=iD(G,u.newText);if(u.code!==Z)nD(u.code,Z,["--- Original message -------------------------",...G.split(`
137
+ `).map((J)=>` ${J}`),"--- Replacing with ---------------------------",...u.newText.split(`
138
+ `).map((J)=>` ${J}`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);let Q=await W1(D,C,E,u.newText);console.log(`\u2713 Edited (ts: ${Q})`)}async function u7(D,u){let{ref:F,ts:E}=P1(u.target);if(!E)console.error("Error: target must embed a message ts (e.g. #chan:2026-05-11T06:01:04.000100 or a Slack permalink URL)"),process.exit(2);let C;if(u.channelId)C=u.channelId;else C=await ND(D,F);let B=await ju(D,C,E,1),z=a(B.messages).map(y).find((Q)=>String(Q.ts)===E);if(!z)console.error(`Message not found at ts=${E} in channel ${C}`),process.exit(1);let G=typeof z.text==="string"?z.text:"",Z=iD(C,E,G);if(u.code!==Z){let Q=await w1(D,C,F);nD(u.code,Z,["--- Deleting message -------------------------",` \u2192 ${Q} at ${R0(E)}`,...G.split(`
139
+ `).map((J)=>` ${J}`),"---------------------------------------------"])}await H1(D,C,E),console.log(`\u2713 Deleted (ts: ${E})`)}async function F7(D,u){if(!u.startsWith("@"))return!1;let F=u.slice(1).toLowerCase().replace(/[^a-z0-9]/g,"");if(F==="me"||F==="you")return!0;try{let C=((await $1(D)).user??"").toLowerCase().replace(/[^a-z0-9]/g,"");return C!==""&&C===F}catch{return!1}}async function E7(D,u){let{ref:F,threadTs:E}=P0(u.target);if(!u.asBot&&!u.channelId&&!u.userId&&await F7(D,F))console.error(`Warning: "${F}" is a DM to yourself \u2014 Slack will NOT notify you of your own message.
140
+ `+` To reach yourself with a notification, send as the bot: slack send '${F}' '...' --as-bot`);let C;if(u.channelId)C=u.channelId;else if(u.userId)C=await hu(D,u.userId);else C=await ND(D,F);let B="",$="?";try{let Q=await fu(D,C,1),J=a(Q.messages).map(y).filter((Y)=>Y.subtype===void 0||Y.subtype===null)[0];B=typeof J?.text==="string"?J.text:"",$=typeof J?.user==="string"?await pu(D,J.user):typeof J?.username==="string"?J.username:"?"}catch{}let z=iD(C,E??"",B,u.message);if(u.code!==z){let Q=await w1(D,C,F),J=E?` \u2192 ${Q} thread of ${await e6(D,C,E)} \u2014 THREAD REPLY`:` \u2192 ${Q} \u2014 NEW top-level message`;nD(u.code,z,["--- Last message in channel ------------------",` ${$}: ${B.split(`
141
+ `)[0]?.slice(0,100)??"(empty)"}`,"--- Sending ----------------------------------",J,` Message: ${u.message}`,"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"])}let G=await J1(D,C,u.message,E,u.broadcast),Z="";try{Z=await Y1(D,C,G)}catch{}if(Z)console.log(`\u2713 Sent: ${Z}`);else console.log(`\u2713 Sent (ts: ${G})`);if(u.asBot&&C.startsWith("D"))try{let Q=await X0(D);if(!Q.ok)for(let J of Q0(Q,!0))console.error(J);else{let J=Q.appId?`https://api.slack.com/apps/${Q.appId}`:"https://api.slack.com/apps";console.error(`Note: if ${u.target} can't reply (app messaging may be off), enable Messages Tab: ${J} \u2192 App Home.`)}}catch{}}async function C7(D){let u=await X0(D);for(let F of Q0(u,!1))console.log(F);if(!u.ok)process.exit(1)}function B7(D){if(/^\d{10,}$/.test(D))return parseInt(D,10);let u=new Date(D.replace(" ","T"));if(isNaN(u.getTime()))throw Error(`Cannot parse time: ${D}`);return Math.floor(u.getTime()/1000)}async function $7(D,u){let{ref:F,threadTs:E}=P0(u.target),C;if(u.channelId)C=u.channelId;else if(u.userId)C=await hu(D,u.userId);else C=await ND(D,F);let B=B7(u.at),$=new Date(B*1000).toISOString(),z=iD(C,u.message,String(B));if(u.code!==z)nD(u.code,z,["--- Scheduling message -----------------------",` To: ${F}${E?` (thread ${E})`:""}`,` At: ${$} (Unix: ${B})`,` Message: ${u.message}`,"---------------------------------------------"]);let G=await X1(D,C,u.message,B,E);console.log(`\u2713 Scheduled (id: ${G}, at: ${$})`)}async function z7(D,u,F){let E;if(F)E=F;else if(u)E=await ND(D,u);let B=(await Q1(D,E)).scheduled_messages??[];if(B.length===0){console.log("(no scheduled messages)");return}for(let $ of B){let z=new Date($.post_at*1000).toISOString();console.log(`${$.id} ${z} [${$.channel_id}] ${$.text.split(`
142
+ `)[0]?.slice(0,80)??""}`)}}async function G7(D,u){let F;if(u.channelId)F=u.channelId;else F=await ND(D,u.target);let E=iD(F,u.id);if(u.code!==E)nD(u.code,E,["--- Deleting scheduled message ---------------",` Channel: ${u.target}`,` ID: ${u.id}`,"---------------------------------------------"]);await O1(D,F,u.id),console.log(`\u2713 Deleted scheduled message ${u.id}`)}async function Z7(D,u){let{statSync:F,existsSync:E}=await import("fs"),{basename:C}=await import("path");for(let W of u.filePaths)if(!E(W))console.error(`Error: file not found: ${W}`),process.exit(1);let{ref:B,threadTs:$}=P0(u.target),z;if(u.channelId)z=u.channelId;else if(u.userId)z=await hu(D,u.userId);else z=await ND(D,B);function G(W){return W<1024?`${W} B`:W<1048576?`${(W/1024).toFixed(1)} KB`:`${(W/1048576).toFixed(1)} MB`}let Z=u.filePaths.length>1,Q=u.filePaths.map((W)=>{let H=C(W),O=Z?H:u.title??H;return{fp:W,filename:H,title:O,sizeFmt:G(F(W).size)}}),J=iD(z,...Q.flatMap((W)=>[W.fp,W.title]));if(u.code!==J){let W=` To: ${B}${$?` (thread ${$})`:""}`,H=Z?[`--- Uploading ${Q.length} files ------------------------`,W,...Q.map((O)=>` ${O.filename} (${O.sizeFmt})`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]:["--- Uploading file ---------------------------",W,` File: ${Q[0].fp}`,` Title: ${Q[0].title}`,` Size: ${Q[0].sizeFmt}`,"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"];nD(u.code,J,H)}let Y=Q.length;for(let W=0;W<Y;W++){let H=Q[W],O={title:H.title};if($!==void 0)O.threadTs=$;if(u.comment!==void 0&&W===0)O.initialComment=u.comment;let{fileId:q,permalink:j}=await j1(D,z,H.fp,O),N=Y>1?`[${W+1}/${Y}] `:"";console.log(`${N}\u2713 Uploaded (file_id: ${q}${j?`, url: ${j}`:""})`)}}async function J7(){y6();let D=(F)=>$0(F.workspace),u=(F)=>q8(F.workspace);await Q8(mF(process.argv)).scriptName("slack").option("workspace",{alias:"w",type:"string",describe:"Workspace name"}).middleware(async(F)=>{let E=String((F._??[])[0]??"");if(!E||E==="auth"||E==="login")return;try{$0(F.workspace)}catch(C){if((C instanceof Error?C.message:String(C)).startsWith("No profiles configured"))console.log(`No workspace configured. Let's set that up:
143
+ `),await VF(),process.exit(0);throw C}},!0).command(["read [target]","msgs [target]"],"Browse messages",(F)=>F.positional("target",{type:"string",describe:"#channel, @user, or URL"}).option("limit",{alias:"n",type:"number",default:20,describe:"Number of messages"}),async(F)=>{let E=D(F);if(F.target)await k6(E,F.target,F.limit);else await i6(E)}).command("thread <target> <ts>","Show thread messages",(F)=>F.positional("target",{type:"string",demandOption:!0}).positional("ts",{type:"string",demandOption:!0}).option("limit",{alias:"n",type:"number",default:100}),async(F)=>{await d6(D(F),F.target,F.ts,F.limit)}).command(["channel","channels","ch"],"Channel commands",(F)=>F.command(["ls","list"],"List channels",(E)=>E.option("limit",{alias:"n",type:"number",default:200}).option("filter",{alias:"f",type:"string"}).option("all",{type:"boolean",default:!1}).option("format",{type:"string",choices:["text","jsonl"],default:"text"}).option("json",{type:"boolean",default:!1,describe:"Alias for --format=jsonl"}),async(E)=>{await t6(D(E),E.limit,E.filter,E.all,E.json?"jsonl":E.format)}).command("get <channel>","Show channel details",(E)=>E.positional("channel",{type:"string",demandOption:!0,describe:"#name or channel ID"}),async(E)=>{let C=D(E),B=E.channel,$=B.startsWith("#")||B.startsWith("@")||B.startsWith("C")||B.startsWith("G")||B.startsWith("D")?B:`#${B}`,z=await ND(C,$),G=y(await j0(C,z)),Z=y(G.channel),Q=typeof Z.name==="string"?Z.name:z,Y=Z.is_im===!0?"@":"#",W=String(y(Z.purpose).value??""),H=String(y(Z.topic).value??""),O=Z.num_members??Z.member_count??"";if(console.log(`${Y}${Q} ${z}`),H)console.log(`topic: ${H}`);if(W)console.log(`purpose: ${W}`);if(O)console.log(`members: ${O}`);console.log(`private: ${Z.is_private===!0}`)}).demandCommand(1,"").showHelpOnFail(!0)).command(["user","usr"],"User commands",(F)=>F.command(["ls","list"],"List workspace members",(E)=>E.option("limit",{alias:"n",type:"number",default:200}).option("filter",{alias:"f",type:"string"}).option("format",{type:"string",choices:["text","jsonl","yaml"],default:"text"}).option("json",{type:"boolean",default:!1,describe:"Alias for --format=jsonl"}),async(E)=>{let C=E.json?"jsonl":E.format,B=await K0(D(E)),$=E.filter?.toLowerCase(),z=a(B.members).map(y).filter((Z)=>Z.deleted!==!0&&Z.is_bot!==!0&&String(Z.id)!=="USLACKBOT").filter((Z)=>{if(!$)return!0;let Q=String(Z.name??"").toLowerCase(),J=String(y(Z.profile).real_name??"").toLowerCase(),Y=String(y(Z.profile).email??"").toLowerCase();return Q.includes($)||J.includes($)||Y.includes($)}).slice(0,E.limit);if(C==="jsonl"){for(let Z of z)console.log(JSON.stringify(Z));return}if(C==="yaml"){for(let Z of z){let Q=function(J,Y=""){if(J===null)return"null";if(typeof J==="string")return J.includes(`
121
144
  `)?`|
122
- ${X.split(`
145
+ ${J.split(`
123
146
  `).join(`
124
- `)}`:X;if(typeof X!=="object")return String(X);if(Array.isArray(X))return X.map((Y)=>`
125
- ${Q} - ${O(Y,Q+" ")}`).join("");return Object.entries(X).map(([Y,M])=>`
126
- ${Q} ${Y}: ${O(M,Q+" ")}`).join("")};console.log("---");for(let[X,Q]of Object.entries(J))console.log(`${X}: ${O(Q)}`)}return}let Z=Intl.DateTimeFormat().resolvedOptions().timeZone;for(let J of z){let O=y(J.profile),X=String(J.name??J.id),Q=String(J.id??""),Y=String(O.display_name||""),M=String(O.real_name||""),H=String(O.email||""),_=String(J.tz??""),f=[...new Set([Y,M].filter((i)=>i&&i!==X))].join(" / "),x=[H,_&&_!==Z?_:""].filter(Boolean).join(" ");console.log(`@${X} ${Q} ${f}${x?" "+x:""}`)}}).command("get <user>","Show user details",(E)=>E.positional("user",{type:"string",demandOption:!0,describe:"@handle or user ID"}),async(E)=>{let C=D(E),B=E.user.startsWith("@")?E.user.slice(1):E.user,$=B;if(!/^U[A-Z0-9]+$/.test(B)){let x=await oF(C),i=zD(x.members).map(y).find((a)=>String(a.name??"")===B);if(!i)console.error(`User not found: @${B}`),process.exit(1);$=String(i.id)}let z=y(await R8(C,$)),Z=y(z.user),J=y(Z.profile),O=Intl.DateTimeFormat().resolvedOptions().timeZone,X=String(Z.name??$),Q=String(Z.id??$),Y=String(J.display_name||""),M=String(J.real_name||""),H=String(J.email||""),_=String(Z.tz??""),S=String(J.phone||""),f=String(J.title||"");console.log(`@${X} ${Q}`);let d=[...new Set([Y,M].filter((x)=>x&&x!==X))];if(d.length)console.log(`name: ${d.join(" / ")}`);if(H)console.log(`email: ${H}`);if(S)console.log(`phone: ${S}`);if(f)console.log(`title: ${f}`);if(_&&_!==O)console.log(`tz: ${_}`)}).demandCommand(1,"").showHelpOnFail(!0)).command("news","Activity feed (mentions to you)",(F)=>F.option("limit",{alias:"l",type:"number",default:20}),async(F)=>{await t3(D(F),F.limit)}).command("search <query>","Full-text search",(F)=>F.positional("query",{type:"string",demandOption:!0}).option("count",{alias:"n",type:"number",default:100}).option("json",{type:"boolean",default:!1,describe:"Output raw JSON"}),async(F)=>{await o3(D(F),F.query,F.count,F.json)}).command("send <target> <message>","Send a message (confirm-hash safety gate)",(F)=>F.positional("target",{type:"string",demandOption:!0}).positional("message",{type:"string",demandOption:!0}).option("thread",{type:"string",describe:"Thread timestamp"}).option("code",{type:"string",describe:"Safety hash to confirm send"}).option("channel-id",{type:"string",describe:"Raw channel ID"}).option("user-id",{type:"string",describe:"Raw user ID (opens DM)"}),async(F)=>{let E={target:F.target,message:F.message};if(F.thread)E.thread=F.thread;if(F.code)E.code=F.code;if(F["channel-id"])E.channelId=F["channel-id"];if(F["user-id"])E.userId=F["user-id"];await F6(D(F),E)}).command("schedule","Manage scheduled messages",(F)=>F.command("send <target> <message>","Schedule a message for later delivery",(E)=>E.positional("target",{type:"string",demandOption:!0}).positional("message",{type:"string",demandOption:!0}).option("at",{type:"string",demandOption:!0,describe:"Delivery time (ISO datetime or Unix ts)"}).option("thread",{type:"string",describe:"Thread timestamp"}).option("code",{type:"string",describe:"Safety hash to confirm"}).option("channel-id",{type:"string",describe:"Raw channel ID"}).option("user-id",{type:"string",describe:"Raw user ID (opens DM)"}),async(E)=>{let C={target:E.target,message:E.message,at:E.at};if(E.thread)C.thread=E.thread;if(E.code)C.code=E.code;if(E["channel-id"])C.channelId=E["channel-id"];if(E["user-id"])C.userId=E["user-id"];await C6(D(E),C)}).command(["ls","list"],"List pending scheduled messages",(E)=>E.positional("target",{type:"string",describe:"#channel to filter by"}).option("channel-id",{type:"string",describe:"Raw channel ID"}),async(E)=>{await B6(D(E),E.target,E["channel-id"])}).command("rm <target> <id>","Delete a scheduled message",(E)=>E.positional("target",{type:"string",demandOption:!0,describe:"#channel or @user"}).positional("id",{type:"string",demandOption:!0,describe:"Scheduled message ID"}).option("code",{type:"string",describe:"Safety hash to confirm"}).option("channel-id",{type:"string",describe:"Raw channel ID"}),async(E)=>{let C={target:E.target,id:E.id};if(E.code)C.code=E.code;if(E["channel-id"])C.channelId=E["channel-id"];await $6(D(E),C)}).demandCommand(1,"").showHelpOnFail(!0),()=>{}).command("edit <target> <newText>","Edit a sent message",(F)=>F.positional("target",{type:"string",demandOption:!0,describe:"#chan:ts, @user:ts, or permalink"}).positional("newText",{type:"string",demandOption:!0}).option("code",{type:"string",describe:"Safety hash to confirm edit"}).option("channel-id",{type:"string",describe:"Raw channel ID"}),async(F)=>{let E={target:F.target,newText:F.newText};if(F.code)E.code=F.code;if(F["channel-id"])E.channelId=F["channel-id"];await u6(D(F),E)}).command("upload <target> <file..>","Upload one or more files to a channel or DM",(F)=>F.positional("target",{type:"string",demandOption:!0}).positional("file",{type:"string",array:!0,demandOption:!0,describe:"Path(s) to file(s)"}).option("title",{type:"string",describe:"Title (single file only)"}).option("thread",{type:"string",describe:"Thread timestamp"}).option("comment",{type:"string",describe:"Initial comment (first file)"}).option("code",{type:"string",describe:"4-hex safety code to confirm upload"}).option("channel-id",{type:"string"}).option("user-id",{type:"string"}),async(F)=>{let E={target:F.target,filePaths:F.file};if(F.title)E.title=F.title;if(F.thread)E.thread=F.thread;if(F.comment)E.comment=F.comment;if(F.code)E.code=F.code;if(F["channel-id"])E.channelId=F["channel-id"];if(F["user-id"])E.userId=F["user-id"];await z6(D(F),E)}).command("dump","Bulk export channel history as markdown",(F)=>F.option("days",{alias:"d",type:"number",default:7,describe:"Days of history"}).option("limit",{alias:"l",type:"number",default:200}).option("filter",{alias:"f",type:"string",describe:"Filter channel names"}),async(F)=>{await s3(D(F),F.days,F.limit,F.filter)}).command("drafts","Manage message drafts (requires xoxc desktop token)",(F)=>F.command(["$0","ls","list"],"List pending drafts",(E)=>E.option("all",{alias:"a",type:"boolean",default:!1,describe:"Include sent drafts"}),async(E)=>{await a3(D(E),u(E),E.all)}).command(["new <channel> [text..]","save <channel> [text..]"],"Create a draft",(E)=>E.positional("channel",{type:"string",demandOption:!0}).positional("text",{type:"string",array:!0,default:[]}),async(E)=>{let C=D(E),B=u(E),$=E.text.join(" ");if(!$)console.error("Usage: slack drafts new <#channel|@user> <text>"),process.exit(2);let z=await ND(C,E.channel,B),Z=await K8(C,z,$,B);console.log(`\u2713 Draft created (id: ${y(Z.draft).id??"?"})`)}).command("get <id>","Show a draft",(E)=>E.positional("id",{type:"string",demandOption:!0}),async(E)=>{await e3(D(E),u(E),E.id)}).command(["edit <id> [text..]","update <id> [text..]"],"Edit a draft",(E)=>E.positional("id",{type:"string",demandOption:!0}).positional("text",{type:"string",array:!0,default:[]}).option("code",{type:"string"}),async(E)=>{let C=D(E),B=u(E),$=E.text.join(" ");if(!$)console.error("Usage: slack drafts edit <id> <new-text>"),process.exit(2);let z=await Pu(C,B),Z=zD(z.drafts).map(y).find((Q)=>String(Q.id)===E.id);if(!Z)console.error(`Draft not found: ${E.id}`),process.exit(1);let J=zF(Z),O=Cu(J,$);if(E.code!==O)Bu(E.code,O,["--- Current draft ----------------------------",...J.split(`
127
- `).map((Q)=>` ${Q}`),"--- Replacing with ---------------------------",...$.split(`
128
- `).map((Q)=>` ${Q}`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);let X=await T8(C,E.id,eF(Z),$,B);console.log(`\u2713 Draft updated (id: ${y(X.draft).id??"?"})`)}).command(["delete <id>","rm <id>"],"Delete a draft",(E)=>E.positional("id",{type:"string",demandOption:!0}).option("code",{type:"string"}),async(E)=>{let C=D(E),B=u(E),$=await Pu(C,B),z=zD($.drafts).map(y).find((O)=>String(O.id)===E.id);if(!z)console.error(`Draft not found: ${E.id}`),process.exit(1);let Z=zF(z),J=Cu(E.id,Z);if(E.code!==J)Bu(E.code,J,["\u2500-- Deleting draft \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500",` id: ${E.id}`,...Z.split(`
129
- `).map((O)=>` ${O}`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);await L8(C,E.id,B),console.log(`\u2713 Draft deleted (id: ${E.id})`)})).command("auth","Authentication and workspace management",(F)=>F.command("login","Add a workspace (interactive or --token for non-interactive)",(E)=>E.option("token",{type:"string",describe:"Token to save directly (non-interactive)"}).option("name",{type:"string",describe:"Workspace name (used with --token)"}),async(E)=>{await FF({...E.token!==void 0?{token:E.token}:{},...E.name!==void 0?{name:E.name}:{}})}).command(["ls","status"],"Show auth status",()=>{},()=>{let E=i2();if(E.length===0){console.log("No workspaces configured. Run: slack auth login");return}for(let{name:C,profile:B,current:$}of E)console.log(`${$?"* ":" "}${C} ${B.team} (${B.user}) ${B.url??""}`)}).command("use <name>","Switch active workspace",(E)=>E.positional("name",{type:"string",demandOption:!0}).option("g",{type:"boolean",default:!1,describe:"Write global lockfile (~/.slack-cli/workspace)"}),(E)=>{if(!E.g)m3(Eu(process.cwd(),".slack-cli"));k2(E.name,E.g),console.log(`Switched to workspace "${E.name}" ${E.g?"globally":"locally"}`)}).command(["rm <name>","remove <name>"],"Remove a workspace",(E)=>E.positional("name",{type:"string",demandOption:!0}),(E)=>{n2(E.name),console.log(`Removed workspace "${E.name}"`)}).command("$0",!1,()=>{},()=>{F.showHelp(),process.exit(0)})).command("tail [target]","Stream new messages in real time (like tail -f)",(F)=>F.positional("target",{type:"string",describe:"#channel or @user to follow"}).option("since",{type:"string",describe:"Backfill from N ago (e.g. 10m, 2h, 1d)"}).option("thread",{type:"string",describe:"Follow a single thread by timestamp"}).option("me",{type:"boolean",default:!1,describe:"Filter to messages that mention you"}).option("interval",{type:"number",default:60000,describe:"Poll interval in ms (default 60s; use --interval=3000 for near-real-time)"}),async(F)=>{let E=D(F),C=new AbortController;process.on("SIGINT",()=>{C.abort(),process.exit(0)}),await J8(E,F.target,{...F.since!==void 0?{since:F.since}:{},...F.thread!==void 0?{thread:F.thread}:{},me:F.me,interval:F.interval},C.signal)}).command("login",!1,(F)=>F.option("token",{type:"string"}).option("name",{type:"string"}),async(F)=>{await FF({...F.token!==void 0?{token:F.token}:{},...F.name!==void 0?{name:F.name}:{}})}).demandCommand(1,"Specify a command. Run with --help for usage.").strict().help().alias("help","h").parseAsync()}G6().catch((D)=>{console.error(D instanceof Error?D.message:String(D)),process.exit(1)});
147
+ `)}`:J;if(typeof J!=="object")return String(J);if(Array.isArray(J))return J.map((W)=>`
148
+ ${Y} - ${Q(W,Y+" ")}`).join("");return Object.entries(J).map(([W,H])=>`
149
+ ${Y} ${W}: ${Q(H,Y+" ")}`).join("")};console.log("---");for(let[J,Y]of Object.entries(Z))console.log(`${J}: ${Q(Y)}`)}return}let G=Intl.DateTimeFormat().resolvedOptions().timeZone;for(let Z of z){let Q=y(Z.profile),J=String(Z.name??Z.id),Y=String(Z.id??""),W=String(Q.display_name||""),H=String(Q.real_name||""),O=String(Q.email||""),q=String(Z.tz??""),N=[...new Set([W,H].filter((c)=>c&&c!==J))].join(" / "),w=[O,q&&q!==G?q:""].filter(Boolean).join(" ");console.log(`@${J} ${Y} ${N}${w?" "+w:""}`)}}).command("get <user>","Show user details",(E)=>E.positional("user",{type:"string",demandOption:!0,describe:"@handle or user ID"}),async(E)=>{let C=D(E),B=E.user.startsWith("@")?E.user.slice(1):E.user,$=B;if(!/^U[A-Z0-9]+$/.test(B)){let w=await K0(C),c=a(w.members).map(y).find((e)=>String(e.name??"")===B);if(!c)console.error(`User not found: @${B}`),process.exit(1);$=String(c.id)}let z=y(await _1(C,$)),G=y(z.user),Z=y(G.profile),Q=Intl.DateTimeFormat().resolvedOptions().timeZone,J=String(G.name??$),Y=String(G.id??$),W=String(Z.display_name||""),H=String(Z.real_name||""),O=String(Z.email||""),q=String(G.tz??""),j=String(Z.phone||""),N=String(Z.title||"");console.log(`@${J} ${Y}`);let k=[...new Set([W,H].filter((w)=>w&&w!==J))];if(k.length)console.log(`name: ${k.join(" / ")}`);if(O)console.log(`email: ${O}`);if(j)console.log(`phone: ${j}`);if(N)console.log(`title: ${N}`);if(q&&q!==Q)console.log(`tz: ${q}`)}).demandCommand(1,"").showHelpOnFail(!0)).command("news","Activity feed (mentions to you)",(F)=>F.option("limit",{alias:"l",type:"number",default:20}),async(F)=>{await n6(D(F),F.limit)}).command("search <query>","Full-text search",(F)=>F.positional("query",{type:"string",demandOption:!0}).option("count",{alias:"n",type:"number",default:100}).option("json",{type:"boolean",default:!1,describe:"Output raw JSON"}),async(F)=>{await l6(D(F),F.query,F.count,F.json)}).command("send <target> <message>","Send a message (confirm-hash safety gate)",(F)=>F.positional("target",{type:"string",demandOption:!0,describe:"#chan, @user, #chan:thread_ts, or permalink (a message permalink replies in its thread)"}).positional("message",{type:"string",demandOption:!0}).option("code",{type:"string",describe:"Safety hash to confirm send"}).option("channel-id",{type:"string",describe:"Raw channel ID"}).option("user-id",{type:"string",describe:"Raw user ID (opens DM)"}).option("as-bot",{type:"boolean",default:!1,describe:"Send via the bot token (xoxb / SLACK_BOT_TOKEN) so a DM notifies the recipient and can be two-way"}).option("broadcast",{type:"boolean",default:!1,describe:`Also send to channel: broadcast a threaded reply back to the channel (Slack's "Also send to #channel" checkbox). Only effective with a thread target.`}),async(F)=>{let E={target:F.target,message:F.message};if(F.code)E.code=F.code;if(F["channel-id"])E.channelId=F["channel-id"];if(F["user-id"])E.userId=F["user-id"];if(F.broadcast)E.broadcast=!0;let C;if(F["as-bot"]){let B=z0();if(!B)console.error(`Error: --as-bot needs a bot token, but no xoxb- token was found.
150
+ Set SLACK_BOT_TOKEN=xoxb-... in ~/.config/slack-cli/.env (or your shell).`),process.exit(1);if(!E.channelId&&!E.userId&&E.target.startsWith("@"))try{E.userId=await M1(D(F),E.target)}catch($){console.error(`Error: could not resolve ${E.target} to a user for the bot DM.
151
+ ${$ instanceof Error?$.message:String($)}
152
+ Tip: pass --user-id <Uxxxx> to skip the lookup.`),process.exit(1)}C=B,E.asBot=!0}else C=D(F);try{await E7(C,E)}catch(B){console.error(B instanceof Error?B.message:String(B)),process.exit(1)}}).command("doctor","Check the bot token (xoxb) can carry a two-way DM (scopes + Messages Tab)",(F)=>F,async()=>{let F=z0();if(!F)console.error(`Error: slack doctor checks the bot token, but no xoxb- token was found.
153
+ Set SLACK_BOT_TOKEN=xoxb-... in ~/.config/slack-cli/.env (or your shell).`),process.exit(1);await C7(F)}).command("schedule","Manage scheduled messages",(F)=>F.command("send <target> <message>","Schedule a message for later delivery",(E)=>E.positional("target",{type:"string",demandOption:!0,describe:"#chan, @user, #chan:thread_ts, or permalink (a message permalink replies in its thread)"}).positional("message",{type:"string",demandOption:!0}).option("at",{type:"string",demandOption:!0,describe:"Delivery time (ISO datetime or Unix ts)"}).option("code",{type:"string",describe:"Safety hash to confirm"}).option("channel-id",{type:"string",describe:"Raw channel ID"}).option("user-id",{type:"string",describe:"Raw user ID (opens DM)"}),async(E)=>{let C={target:E.target,message:E.message,at:E.at};if(E.code)C.code=E.code;if(E["channel-id"])C.channelId=E["channel-id"];if(E["user-id"])C.userId=E["user-id"];await $7(D(E),C)}).command(["ls","list"],"List pending scheduled messages",(E)=>E.positional("target",{type:"string",describe:"#channel to filter by"}).option("channel-id",{type:"string",describe:"Raw channel ID"}),async(E)=>{await z7(D(E),E.target,E["channel-id"])}).command("rm <target> <id>","Delete a scheduled message",(E)=>E.positional("target",{type:"string",demandOption:!0,describe:"#channel or @user"}).positional("id",{type:"string",demandOption:!0,describe:"Scheduled message ID"}).option("code",{type:"string",describe:"Safety hash to confirm"}).option("channel-id",{type:"string",describe:"Raw channel ID"}),async(E)=>{let C={target:E.target,id:E.id};if(E.code)C.code=E.code;if(E["channel-id"])C.channelId=E["channel-id"];await G7(D(E),C)}).demandCommand(1,"").showHelpOnFail(!0),()=>{}).command("edit <target> <newText>","Edit a sent message",(F)=>F.positional("target",{type:"string",demandOption:!0,describe:"#chan:ts, @user:ts, or permalink"}).positional("newText",{type:"string",demandOption:!0}).option("code",{type:"string",describe:"Safety hash to confirm edit"}).option("channel-id",{type:"string",describe:"Raw channel ID"}),async(F)=>{let E={target:F.target,newText:F.newText};if(F.code)E.code=F.code;if(F["channel-id"])E.channelId=F["channel-id"];await D7(D(F),E)}).command("delete <target>","Delete a sent message (confirm-hash safety gate)",(F)=>F.positional("target",{type:"string",demandOption:!0,describe:"#chan:ts, @user:ts, or permalink"}).option("code",{type:"string",describe:"Safety hash to confirm delete"}).option("channel-id",{type:"string",describe:"Raw channel ID"}),async(F)=>{let E={target:F.target};if(F.code)E.code=F.code;if(F["channel-id"])E.channelId=F["channel-id"];await u7(D(F),E)}).command("upload <target> <file..>","Upload one or more files to a channel or DM",(F)=>F.positional("target",{type:"string",demandOption:!0,describe:"#chan, @user, #chan:thread_ts, or permalink (a message permalink replies in its thread)"}).positional("file",{type:"string",array:!0,demandOption:!0,describe:"Path(s) to file(s)"}).option("title",{type:"string",describe:"Title (single file only)"}).option("comment",{type:"string",describe:"Initial comment (first file)"}).option("code",{type:"string",describe:"4-hex safety code to confirm upload"}).option("channel-id",{type:"string"}).option("user-id",{type:"string"}),async(F)=>{let E={target:F.target,filePaths:F.file};if(F.title)E.title=F.title;if(F.comment)E.comment=F.comment;if(F.code)E.code=F.code;if(F["channel-id"])E.channelId=F["channel-id"];if(F["user-id"])E.userId=F["user-id"];await Z7(D(F),E)}).command("dump","Bulk export channel history as markdown",(F)=>F.option("days",{alias:"d",type:"number",default:7,describe:"Days of history"}).option("limit",{alias:"l",type:"number",default:200}).option("filter",{alias:"f",type:"string",describe:"Filter channel names"}),async(F)=>{await o6(D(F),F.days,F.limit,F.filter)}).command("drafts","Manage message drafts (requires xoxc desktop token)",(F)=>F.command(["$0","ls","list"],"List pending drafts",(E)=>E.option("all",{alias:"a",type:"boolean",default:!1,describe:"Include sent drafts"}),async(E)=>{await r6(D(E),u(E),E.all)}).command(["new <channel> [text..]","save <channel> [text..]"],"Create a draft",(E)=>E.positional("channel",{type:"string",demandOption:!0}).positional("text",{type:"string",array:!0,default:[]}),async(E)=>{let C=D(E),B=u(E),$=E.text.join(" ");if(!$)console.error("Usage: slack drafts new <#channel|@user> <text>"),process.exit(2);let z=await ND(C,E.channel,B),G=await V1(C,z,$,B);console.log(`\u2713 Draft created (id: ${y(G.draft).id??"?"})`)}).command("get <id>","Show a draft",(E)=>E.positional("id",{type:"string",demandOption:!0}),async(E)=>{await a6(D(E),u(E),E.id)}).command(["edit <id> [text..]","update <id> [text..]"],"Edit a draft",(E)=>E.positional("id",{type:"string",demandOption:!0}).positional("text",{type:"string",array:!0,default:[]}).option("code",{type:"string"}),async(E)=>{let C=D(E),B=u(E),$=E.text.join(" ");if(!$)console.error("Usage: slack drafts edit <id> <new-text>"),process.exit(2);let z=await yu(C,B),G=a(z.drafts).map(y).find((Y)=>String(Y.id)===E.id);if(!G)console.error(`Draft not found: ${E.id}`),process.exit(1);let Z=jF(G),Q=iD(Z,$);if(E.code!==Q)nD(E.code,Q,["--- Current draft ----------------------------",...Z.split(`
154
+ `).map((Y)=>` ${Y}`),"--- Replacing with ---------------------------",...$.split(`
155
+ `).map((Y)=>` ${Y}`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);let J=await U1(C,E.id,S0(G),$,B);console.log(`\u2713 Draft updated (id: ${y(J.draft).id??"?"})`)}).command(["delete <id>","rm <id>"],"Delete a draft",(E)=>E.positional("id",{type:"string",demandOption:!0}).option("code",{type:"string"}),async(E)=>{let C=D(E),B=u(E),$=await yu(C,B),z=a($.drafts).map(y).find((Q)=>String(Q.id)===E.id);if(!z)console.error(`Draft not found: ${E.id}`),process.exit(1);let G=jF(z),Z=iD(E.id,G);if(E.code!==Z)nD(E.code,Z,["\u2500-- Deleting draft \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500",` id: ${E.id}`,...G.split(`
156
+ `).map((Q)=>` ${Q}`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);await K1(C,E.id,B),console.log(`\u2713 Draft deleted (id: ${E.id})`)})).command("auth","Authentication and workspace management",(F)=>F.command("token","Add a workspace \u2014 paste an existing xoxp-/xoxb- token",(E)=>E.option("token",{type:"string",describe:"Token to save directly (non-interactive)"}).option("name",{type:"string",describe:"Workspace name (used with --token)"}),async(E)=>{await o8({...E.token!==void 0?{token:E.token}:{},...E.name!==void 0?{name:E.name}:{}})}).command("app","Create a new Slack app and obtain a token (guided wizard)",(E)=>E.option("bot",{type:"boolean",describe:"Create a bot token (xoxb-) instead of user (xoxp-)"}),async(E)=>{await s8({...E.bot!==void 0?{bot:E.bot}:{}})}).command("login","Interactive auth wizard (all auth methods: desktop app, token, new app)",(E)=>E.option("token",{type:"string",describe:"Token to save directly (non-interactive)"}).option("name",{type:"string",describe:"Workspace name (used with --token)"}),async(E)=>{await VF({...E.token!==void 0?{token:E.token}:{},...E.name!==void 0?{name:E.name}:{}})}).command(["ls","status"],"Show auth status",()=>{},()=>{let E=M8();if(E.length===0){console.log("No workspaces configured. Run: slack auth login");return}for(let{name:C,profile:B,current:$}of E)console.log(`${$?"* ":" "}${C} ${B.team} (${B.user}) ${B.url??""}`)}).command("use <name>","Switch active workspace",(E)=>E.positional("name",{type:"string",demandOption:!0}).option("g",{type:"boolean",default:!1,describe:"Write global lockfile (~/.slack-cli/workspace)"}),(E)=>{if(!E.g)p6(Wu(process.cwd(),".slack-cli"));U8(E.name,E.g),console.log(`Switched to workspace "${E.name}" ${E.g?"globally":"locally"}`)}).command(["logout <name>","rm <name>","remove <name>"],"Remove a workspace",(E)=>E.positional("name",{type:"string",demandOption:!0}),(E)=>{V8(E.name),console.log(`Removed workspace "${E.name}"`)}).command(["chrome","cookie"],"Attach Chrome browser xoxd cookie to a workspace (macOS, interactive)",(E)=>E.option("workspace",{type:"string",alias:"w",describe:"Workspace name to update (default: active)"}),async(E)=>{await t8({...E.workspace!==void 0?{workspace:E.workspace}:{}})}).command("firefox","Attach Firefox browser xoxd cookie to a workspace (all platforms)",(E)=>E.option("workspace",{type:"string",alias:"w",describe:"Workspace name to update (default: active)"}),async(E)=>{await l8({...E.workspace!==void 0?{workspace:E.workspace}:{}})}).command("$0",!1,()=>{},()=>{F.showHelp(),process.exit(0)})).command("tail [target]","Stream new messages in real time (like tail -f)",(F)=>F.positional("target",{type:"string",describe:"#channel or @user to follow"}).option("since",{type:"string",describe:"Backfill from N ago (e.g. 10m, 2h, 1d)"}).option("thread",{type:"string",describe:"Follow a single thread by timestamp"}).option("watch-thread",{type:"string",describe:"Watch the channel's top-level timeline AND one thread's replies together (ts or permalink)"}).option("me",{type:"boolean",default:!1,describe:"Filter to messages that mention you"}).option("interval",{type:"number",default:60000,describe:"Poll interval in ms (default 60s; use --interval=3000 for near-real-time)"}).option("timeout",{type:"string",describe:"Auto-stop after this long (e.g. 30m, 2h). Exit code 0 even if nothing arrived."}).option("exit-on-message",{type:"boolean",default:!1,describe:"Stop as soon as the first new message from someone else arrives (wait-for-reply)"}).option("rtm",{type:"boolean",default:!0,describe:"Use RTM WebSocket when available (xoxc + cookie); pass --no-rtm to force polling"}),async(F)=>{let E=D(F),C=u(F),B=new AbortController;process.on("SIGINT",()=>{B.abort(),process.exit(0)}),await E1(E,F.target,{...F.since!==void 0?{since:F.since}:{},...F.thread!==void 0?{thread:F.thread}:{},...F["watch-thread"]!==void 0?{watchThread:F["watch-thread"]}:{},me:F.me,interval:F.interval,...F.timeout!==void 0?{timeout:F.timeout}:{},...F["exit-on-message"]===!0?{exitOnMessage:!0}:{},...C!==void 0?{cookie:C}:{},...F.rtm===!1?{noRtm:!0}:{}},B.signal)}).command("login",!1,(F)=>F.option("token",{type:"string"}).option("name",{type:"string"}),async(F)=>{await VF({...F.token!==void 0?{token:F.token}:{},...F.name!==void 0?{name:F.name}:{}})}).demandCommand(1,"Specify a command. Run with --help for usage.").strict().help().alias("help","h").parseAsync()}J7().catch((D)=>{console.error(D instanceof Error?D.message:String(D)),process.exit(1)});