slack-term 1.21.2 → 1.23.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 G3}from"node:module";var D3=Object.create;var{getPrototypeOf:u3,defineProperty:g0,getOwnPropertyNames:F3}=Object;var E3=Object.prototype.hasOwnProperty;function C3(D){return this[D]}var B3,$3,k0=(D,u,F)=>{var E=D!=null&&typeof D==="object";if(E){var C=u?B3??=new WeakMap:$3??=new WeakMap,B=C.get(D);if(B)return B}F=D!=null?D3(u3(D)):{};let $=u||!D||!D.__esModule?g0(F,"default",{value:D,enumerable:!0}):F;for(let G of F3(D))if(!E3.call($,G))g0($,G,{get:C3.bind(D,G),enumerable:!0});if(E)C.set(D,$);return $};var d0=(D,u)=>()=>(u||D((u={exports:{}}).exports,u),u.exports);var wD=G3(import.meta.url);var z2=d0((J9,G2)=>{G2.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 b2=d0((a9,I2)=>{I2.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 Z7}from"crypto";import{existsSync as t1,readFileSync as J7,mkdirSync as X7,writeFileSync as o1}from"fs";import{homedir as d1}from"os";import{join as tD}from"path";import{notStrictEqual as n3,strictEqual as l3}from"assert";var z3={right:X3,center:Q3};class n0{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(`
3
+ import{createRequire as Q3}from"node:module";var B3=Object.create;var{getPrototypeOf:$3,defineProperty:t0,getOwnPropertyNames:G3}=Object;var z3=Object.prototype.hasOwnProperty;function Z3(D){return this[D]}var J3,X3,o0=(D,u,F)=>{var E=D!=null&&typeof D==="object";if(E){var C=u?J3??=new WeakMap:X3??=new WeakMap,B=C.get(D);if(B)return B}F=D!=null?B3($3(D)):{};let $=u||!D||!D.__esModule?t0(F,"default",{value:D,enumerable:!0}):F;for(let G of G3(D))if(!z3.call($,G))t0($,G,{get:Z3.bind(D,G),enumerable:!0});if(E)C.set(D,$);return $};var s0=(D,u)=>()=>(u||D((u={exports:{}}).exports,u),u.exports);var wD=Q3(import.meta.url);var W2=s0((O9,Y2)=>{Y2.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 m2=s0((EE,y2)=>{y2.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 W7}from"crypto";import{existsSync as e1,readFileSync as O7,mkdirSync as V7,writeFileSync as D3}from"fs";import{homedir as o1}from"os";import{join as oD}from"path";import{notStrictEqual as r3,strictEqual as a3}from"assert";var Y3={right:V3,center:H3};class a0{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
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:G}=D[$],z=this.negatePadding(D[$]),Z=B;if(z>HD.stringWidth(B))Z+=" ".repeat(z-HD.stringWidth(B));if(D[$].align&&D[$].align!=="left"&&this.wrap){let J=z3[D[$].align];if(Z=J(Z,z),HD.stringWidth(Z)<z)Z+=" ".repeat((G||0)-HD.stringWidth(Z)-1)}let Y=D[$].padding||[0,0,0,0];if(Y[3])C+=" ".repeat(Y[3]);if(C+=i0(D[$],Z,"| "),C+=Z,C+=i0(D[$],Z," |"),Y[1])C+=" ".repeat(Y[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(`
5
+ `)}rowToString(D,u){return this.rasterize(D).forEach((F,E)=>{let C="";F.forEach((B,$)=>{let{width:G}=D[$],Z=this.negatePadding(D[$]),z=B;if(Z>HD.stringWidth(B))z+=" ".repeat(Z-HD.stringWidth(B));if(D[$].align&&D[$].align!=="left"&&this.wrap){let J=Y3[D[$].align];if(z=J(z,Z),HD.stringWidth(z)<Z)z+=" ".repeat((G||0)-HD.stringWidth(z)-1)}let Q=D[$].padding||[0,0,0,0];if(Q[3])C+=" ".repeat(Q[3]);if(C+=r0(D[$],z,"| "),C+=z,C+=r0(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(($,G)=>{if(!u[G])u.push([]);let z=u[G];for(let Z=0;Z<B;Z++)if(z[Z]===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||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,Z3(D[$]));return B})}}function i0(D,u,F){if(D.border){if(/[.']-+[.']/.test(u))return"";if(u.trim().length!==0)return F;return" "}return""}function Z3(D){let u=D.padding||[],F=1+(u[3]||0)+(u[1]||0);if(D.border)return F+4;return F}function J3(){if(typeof process==="object"&&process.stdout&&process.stdout.columns)return process.stdout.columns;return 80}function X3(D,u){D=D.trim();let F=HD.stringWidth(D);if(F<u)return" ".repeat(u-F)+D;return D}function Q3(D,u){D=D.trim();let F=HD.stringWidth(D);if(F>=u)return D;return" ".repeat(u-F>>1)+D}var HD;function l0(D,u){return HD=u,new n0({width:(D===null||D===void 0?void 0:D.width)||J3(),wrap:D===null||D===void 0?void 0:D.wrap})}function RF({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 Y3=RF();function sD(D){if(typeof D!=="string")throw TypeError(`Expected a \`string\`, got \`${typeof D}\``);if(!D.includes("\x1B")&&!D.includes("›"))return D;return D.replace(Y3,"")}var t0=161,o0=1114109,s0=[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],r0=12288,a0=65510,e0=[12288,12288,65281,65376,65504,65510];var D2=4352,u2=262141,SF=[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 iu=(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 F2=19968,[W3,O3]=V3(SF);function V3(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(F2>=C&&F2<=B)return[C,B];if(B-C>F-u)u=C,F=B}return[u,F]}var E2=(D)=>{if(D<t0||D>o0)return!1;return iu(s0,D)},C2=(D)=>{if(D<r0||D>a0)return!1;return iu(e0,D)};var B2=(D)=>{if(D>=W3&&D<=O3)return!0;if(D<D2||D>u2)return!1;return iu(SF,D)};function H3(D){if(!Number.isSafeInteger(D))throw TypeError(`Expected a code point, got \`${typeof D}\`.`)}function $2(D,{ambiguousAsWide:u=!1}={}){if(H3(D),C2(D)||B2(D)||u&&E2(D))return 2;return 1}var Z2=k0(z2(),1),q3=new Intl.Segmenter,U3=/^\p{Default_Ignorable_Code_Point}$/u;function TD(D,u={}){if(typeof D!=="string"||D.length===0)return 0;let{ambiguousIsNarrow:F=!0,countAnsiEscapeCodes:E=!1}=u;if(!E)D=sD(D);if(D.length===0)return 0;let C=0,B={ambiguousAsWide:!F};for(let{segment:$}of q3.segment(D)){let G=$.codePointAt(0);if(G<=31||G>=127&&G<=159)continue;if(G>=8203&&G<=8207||G===65279)continue;if(G>=768&&G<=879||G>=6832&&G<=6911||G>=7616&&G<=7679||G>=8400&&G<=8447||G>=65056&&G<=65071)continue;if(G>=55296&&G<=57343)continue;if(G>=65024&&G<=65039)continue;if(U3.test($))continue;if(Z2.default().test($)){C+=2;continue}C+=$2(G,B)}return C}var J2=(D=0)=>(u)=>`\x1B[${u+D}m`,X2=(D=0)=>(u)=>`\x1B[${38+D};5;${u}m`,Q2=(D=0)=>(u,F,E)=>`\x1B[${38+D};2;${u};${F};${E}m`,a={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]}},W9=Object.keys(a.modifier),M3=Object.keys(a.color),K3=Object.keys(a.bgColor),O9=[...M3,...K3];function _3(){let D=new Map;for(let[u,F]of Object.entries(a)){for(let[E,C]of Object.entries(F))a[E]={open:`\x1B[${C[0]}m`,close:`\x1B[${C[1]}m`},F[E]=a[E],D.set(C[0],C[1]);Object.defineProperty(a,u,{value:F,enumerable:!1})}return Object.defineProperty(a,"codes",{value:D,enumerable:!1}),a.color.close="\x1B[39m",a.bgColor.close="\x1B[49m",a.color.ansi=J2(),a.color.ansi256=X2(),a.color.ansi16m=Q2(),a.bgColor.ansi=J2(10),a.bgColor.ansi256=X2(10),a.bgColor.ansi16m=Q2(10),Object.defineProperties(a,{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)=>a.rgbToAnsi256(...a.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 G=u%36;F=Math.floor(u/36)/5,E=Math.floor(G/6)/5,C=G%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)=>a.ansi256ToAnsi(a.rgbToAnsi256(u,F,E)),enumerable:!1},hexToAnsi:{value:(u)=>a.ansi256ToAnsi(a.hexToAnsi256(u)),enumerable:!1}}),a}var j3=_3(),Y2=j3;var lu=new Set(["\x1B","›"]),A3=39,wF="\x07",V2="[",L3="]",H2="m",nu=`${L3}8;;`,W2=(D)=>`${lu.values().next().value}${V2}${D}${H2}`,O2=(D)=>`${lu.values().next().value}${nu}${D}${wF}`,N3=(D)=>D.split(" ").map((u)=>TD(u)),PF=(D,u,F)=>{let E=[...u],C=!1,B=!1,$=TD(sD(D.at(-1)));for(let[G,z]of E.entries()){let Z=TD(z);if($+Z<=F)D[D.length-1]+=z;else D.push(z),$=0;if(lu.has(z))C=!0,B=E.slice(G+1,G+1+nu.length).join("")===nu;if(C){if(B){if(z===wF)C=!1,B=!1}else if(z===H2)C=!1;continue}if($+=Z,$===F&&G<E.length-1)D.push(""),$=0}if(!$&&D.at(-1).length>0&&D.length>1)D[D.length-2]+=D.pop()},T3=(D)=>{let u=D.split(" "),F=u.length;while(F>0){if(TD(u[F-1])>0)break;F--}if(F===u.length)return D;return u.slice(0,F).join(" ")+u.slice(F).join("")},R3=(D,u,F={})=>{if(F.trim!==!1&&D.trim()==="")return"";let E="",C,B,$=N3(D),G=[""];for(let[J,Q]of D.split(" ").entries()){if(F.trim!==!1)G[G.length-1]=G.at(-1).trimStart();let O=TD(G.at(-1));if(J!==0){if(O>=u&&(F.wordWrap===!1||F.trim===!1))G.push(""),O=0;if(O>0||F.trim===!1)G[G.length-1]+=" ",O++}if(F.hard&&$[J]>u){let V=u-O,W=1+Math.floor(($[J]-V-1)/u);if(Math.floor(($[J]-1)/u)<W)G.push("");PF(G,Q,u);continue}if(O+$[J]>u&&O>0&&$[J]>0){if(F.wordWrap===!1&&O<u){PF(G,Q,u);continue}G.push("")}if(O+$[J]>u&&F.wordWrap===!1){PF(G,Q,u);continue}G[G.length-1]+=Q}if(F.trim!==!1)G=G.map((J)=>T3(J));let z=G.join(`
8
- `),Z=[...z],Y=0;for(let[J,Q]of Z.entries()){if(E+=Q,lu.has(Q)){let{groups:V}=new RegExp(`(?:\\${V2}(?<code>\\d+)m|\\${nu}(?<uri>.*)${wF})`).exec(z.slice(Y))||{groups:{}};if(V.code!==void 0){let W=Number.parseFloat(V.code);C=W===A3?void 0:W}else if(V.uri!==void 0)B=V.uri.length===0?void 0:V.uri}let O=Y2.codes.get(Number(C));if(Z[J+1]===`
9
- `){if(B)E+=O2("");if(C&&O)E+=W2(O)}else if(Q===`
10
- `){if(C&&O)E+=W2(C);if(B)E+=O2(B)}Y+=Q.length}return E};function xF(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(($,G)=>{if(!u[G])u.push([]);let Z=u[G];for(let z=0;z<B;z++)if(Z[z]===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||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,W3(D[$]));return B})}}function r0(D,u,F){if(D.border){if(/[.']-+[.']/.test(u))return"";if(u.trim().length!==0)return F;return" "}return""}function W3(D){let u=D.padding||[],F=1+(u[3]||0)+(u[1]||0);if(D.border)return F+4;return F}function O3(){if(typeof process==="object"&&process.stdout&&process.stdout.columns)return process.stdout.columns;return 80}function V3(D,u){D=D.trim();let F=HD.stringWidth(D);if(F<u)return" ".repeat(u-F)+D;return D}function H3(D,u){D=D.trim();let F=HD.stringWidth(D);if(F>=u)return D;return" ".repeat(u-F>>1)+D}var HD;function e0(D,u){return HD=u,new a0({width:(D===null||D===void 0?void 0:D.width)||O3(),wrap:D===null||D===void 0?void 0:D.wrap})}function SF({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 q3=SF();function rD(D){if(typeof D!=="string")throw TypeError(`Expected a \`string\`, got \`${typeof D}\``);if(!D.includes("\x1B")&&!D.includes("›"))return D;return D.replace(q3,"")}var D2=161,u2=1114109,F2=[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],E2=12288,C2=65510,B2=[12288,12288,65281,65376,65504,65510];var $2=4352,G2=262141,PF=[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 lu=(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 z2=19968,[K3,U3]=_3(PF);function _3(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(z2>=C&&z2<=B)return[C,B];if(B-C>F-u)u=C,F=B}return[u,F]}var Z2=(D)=>{if(D<D2||D>u2)return!1;return lu(F2,D)},J2=(D)=>{if(D<E2||D>C2)return!1;return lu(B2,D)};var X2=(D)=>{if(D>=K3&&D<=U3)return!0;if(D<$2||D>G2)return!1;return lu(PF,D)};function j3(D){if(!Number.isSafeInteger(D))throw TypeError(`Expected a code point, got \`${typeof D}\`.`)}function Q2(D,{ambiguousAsWide:u=!1}={}){if(j3(D),J2(D)||X2(D)||u&&Z2(D))return 2;return 1}var O2=o0(W2(),1),M3=new Intl.Segmenter,A3=/^\p{Default_Ignorable_Code_Point}$/u;function TD(D,u={}){if(typeof D!=="string"||D.length===0)return 0;let{ambiguousIsNarrow:F=!0,countAnsiEscapeCodes:E=!1}=u;if(!E)D=rD(D);if(D.length===0)return 0;let C=0,B={ambiguousAsWide:!F};for(let{segment:$}of M3.segment(D)){let G=$.codePointAt(0);if(G<=31||G>=127&&G<=159)continue;if(G>=8203&&G<=8207||G===65279)continue;if(G>=768&&G<=879||G>=6832&&G<=6911||G>=7616&&G<=7679||G>=8400&&G<=8447||G>=65056&&G<=65071)continue;if(G>=55296&&G<=57343)continue;if(G>=65024&&G<=65039)continue;if(A3.test($))continue;if(O2.default().test($)){C+=2;continue}C+=Q2(G,B)}return C}var V2=(D=0)=>(u)=>`\x1B[${u+D}m`,H2=(D=0)=>(u)=>`\x1B[${38+D};5;${u}m`,q2=(D=0)=>(u,F,E)=>`\x1B[${38+D};2;${u};${F};${E}m`,e={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]}},K9=Object.keys(e.modifier),L3=Object.keys(e.color),N3=Object.keys(e.bgColor),U9=[...L3,...N3];function T3(){let D=new Map;for(let[u,F]of Object.entries(e)){for(let[E,C]of Object.entries(F))e[E]={open:`\x1B[${C[0]}m`,close:`\x1B[${C[1]}m`},F[E]=e[E],D.set(C[0],C[1]);Object.defineProperty(e,u,{value:F,enumerable:!1})}return Object.defineProperty(e,"codes",{value:D,enumerable:!1}),e.color.close="\x1B[39m",e.bgColor.close="\x1B[49m",e.color.ansi=V2(),e.color.ansi256=H2(),e.color.ansi16m=q2(),e.bgColor.ansi=V2(10),e.bgColor.ansi256=H2(10),e.bgColor.ansi16m=q2(10),Object.defineProperties(e,{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)=>e.rgbToAnsi256(...e.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 G=u%36;F=Math.floor(u/36)/5,E=Math.floor(G/6)/5,C=G%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)=>e.ansi256ToAnsi(e.rgbToAnsi256(u,F,E)),enumerable:!1},hexToAnsi:{value:(u)=>e.ansi256ToAnsi(e.hexToAnsi256(u)),enumerable:!1}}),e}var R3=T3(),K2=R3;var ou=new Set(["\x1B","›"]),S3=39,xF="\x07",j2="[",P3="]",M2="m",tu=`${P3}8;;`,U2=(D)=>`${ou.values().next().value}${j2}${D}${M2}`,_2=(D)=>`${ou.values().next().value}${tu}${D}${xF}`,w3=(D)=>D.split(" ").map((u)=>TD(u)),wF=(D,u,F)=>{let E=[...u],C=!1,B=!1,$=TD(rD(D.at(-1)));for(let[G,Z]of E.entries()){let z=TD(Z);if($+z<=F)D[D.length-1]+=Z;else D.push(Z),$=0;if(ou.has(Z))C=!0,B=E.slice(G+1,G+1+tu.length).join("")===tu;if(C){if(B){if(Z===xF)C=!1,B=!1}else if(Z===M2)C=!1;continue}if($+=z,$===F&&G<E.length-1)D.push(""),$=0}if(!$&&D.at(-1).length>0&&D.length>1)D[D.length-2]+=D.pop()},x3=(D)=>{let u=D.split(" "),F=u.length;while(F>0){if(TD(u[F-1])>0)break;F--}if(F===u.length)return D;return u.slice(0,F).join(" ")+u.slice(F).join("")},I3=(D,u,F={})=>{if(F.trim!==!1&&D.trim()==="")return"";let E="",C,B,$=w3(D),G=[""];for(let[J,Y]of D.split(" ").entries()){if(F.trim!==!1)G[G.length-1]=G.at(-1).trimStart();let O=TD(G.at(-1));if(J!==0){if(O>=u&&(F.wordWrap===!1||F.trim===!1))G.push(""),O=0;if(O>0||F.trim===!1)G[G.length-1]+=" ",O++}if(F.hard&&$[J]>u){let V=u-O,W=1+Math.floor(($[J]-V-1)/u);if(Math.floor(($[J]-1)/u)<W)G.push("");wF(G,Y,u);continue}if(O+$[J]>u&&O>0&&$[J]>0){if(F.wordWrap===!1&&O<u){wF(G,Y,u);continue}G.push("")}if(O+$[J]>u&&F.wordWrap===!1){wF(G,Y,u);continue}G[G.length-1]+=Y}if(F.trim!==!1)G=G.map((J)=>x3(J));let Z=G.join(`
8
+ `),z=[...Z],Q=0;for(let[J,Y]of z.entries()){if(E+=Y,ou.has(Y)){let{groups:V}=new RegExp(`(?:\\${j2}(?<code>\\d+)m|\\${tu}(?<uri>.*)${xF})`).exec(Z.slice(Q))||{groups:{}};if(V.code!==void 0){let W=Number.parseFloat(V.code);C=W===S3?void 0:W}else if(V.uri!==void 0)B=V.uri.length===0?void 0:V.uri}let O=K2.codes.get(Number(C));if(z[J+1]===`
9
+ `){if(B)E+=_2("");if(C&&O)E+=U2(O)}else if(Y===`
10
+ `){if(C&&O)E+=U2(C);if(B)E+=_2(B)}Q+=Y.length}return E};function IF(D,u,F){return String(D).normalize().replaceAll(`\r
11
11
  `,`
12
12
  `).split(`
13
- `).map((E)=>R3(E,u,F)).join(`
14
- `)}function IF(D){return l0(D,{stringWidth:TD,stripAnsi:sD,wrap:xF})}import{dirname as q2,resolve as U2}from"path";import{readdirSync as S3,statSync as P3}from"fs";function bF(D,u){let F=U2(".",D),E;if(!P3(F).isDirectory())F=q2(F);while(!0){if(E=u(F,S3(F)),E)return U2(F,E);if(F=q2(E=F),E===F)break}}import{inspect as t3}from"util";import{fileURLToPath as h2}from"url";import{format as I3}from"util";import{normalize as b3,resolve as f3}from"path";function rD(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 ou(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 M2(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 jD;(function(D){D.BOOLEAN="boolean",D.STRING="string",D.NUMBER="number",D.ARRAY="array"})(jD||(jD={}));var vD;class hF{constructor(D){vD=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=M2(D),C=typeof D==="string",B=w3(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),G=Object.assign(Object.create(null),F.default),z=F.configObjects||[],Z=F.envPrefix,Y=$["populate--"],J=Y?"--":"_",Q=Object.create(null),O=Object.create(null),V=F.__||vD.format,W={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:[]},M=/^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/,_=new RegExp("^--"+$["negation-prefix"]+"(.+)");if([].concat(F.array||[]).filter(Boolean).forEach(function(H){let U=typeof H==="object"?H.key:H,j=Object.keys(H).map(function(K){return{boolean:"bools",string:"strings",number:"numbers"}[K]}).filter(Boolean).pop();if(j)W[j][U]=!0;W.arrays[U]=!0,W.keys.push(U)}),[].concat(F.boolean||[]).filter(Boolean).forEach(function(H){W.bools[H]=!0,W.keys.push(H)}),[].concat(F.string||[]).filter(Boolean).forEach(function(H){W.strings[H]=!0,W.keys.push(H)}),[].concat(F.number||[]).filter(Boolean).forEach(function(H){W.numbers[H]=!0,W.keys.push(H)}),[].concat(F.count||[]).filter(Boolean).forEach(function(H){W.counts[H]=!0,W.keys.push(H)}),[].concat(F.normalize||[]).filter(Boolean).forEach(function(H){W.normalize[H]=!0,W.keys.push(H)}),typeof F.narg==="object")Object.entries(F.narg).forEach(([H,U])=>{if(typeof U==="number")W.nargs[H]=U,W.keys.push(H)});if(typeof F.coerce==="object")Object.entries(F.coerce).forEach(([H,U])=>{if(typeof U==="function")W.coercions[H]=U,W.keys.push(H)});if(typeof F.config<"u"){if(Array.isArray(F.config)||typeof F.config==="string")[].concat(F.config).filter(Boolean).forEach(function(H){W.configs[H]=!0});else if(typeof F.config==="object")Object.entries(F.config).forEach(([H,U])=>{if(typeof U==="boolean"||typeof U==="function")W.configs[H]=U})}Nu(F.key,B,F.default,W.arrays),Object.keys(G).forEach(function(H){(W.aliases[H]||[]).forEach(function(U){G[U]=G[H]})});let N=null;TF();let k=[],w=Object.assign(Object.create(null),{_:[]}),c={};for(let H=0;H<E.length;H++){let U=E[H],j=U.replace(/^-{3,}/,"---"),K,q,S,L,b,JD;if(U!=="--"&&/^-/.test(U)&&l(U))e(U);else if(j.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],W.arrays))H=_D(H,L[1],E,L[2]);else if(f(L[1],W.nargs)!==!1)H=r(H,L[1],E,L[2]);else i(L[1],L[2],!0)}else if(U.match(_)&&$["boolean-negation"]){if(L=U.match(_),L!==null&&Array.isArray(L)&&L.length>=2)q=L[1],i(q,f(q,W.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(q=L[1],f(q,W.arrays))H=_D(H,q,E);else if(f(q,W.nargs)!==!1)H=r(H,q,E);else if(b=E[H+1],b!==void 0&&(!b.match(/^-/)||b.match(M))&&!f(q,W.bools)&&!f(q,W.counts))i(q,b),H++;else if(/^(true|false)$/.test(b))i(q,b),H++;else i(q,g(q))}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(M)){if(b=E[H+1],L=U.match(/^-(.\..+)/),L!==null&&Array.isArray(L)&&L.length>=2)if(q=L[1],b!==void 0&&!b.match(/^-/)&&!f(q,W.bools)&&!f(q,W.counts))i(q,b),H++;else i(q,g(q))}else if(U.match(/^-[^-]+/)&&!U.match(M)){S=U.slice(1,-1).split(""),K=!1;for(let YD=0;YD<S.length;YD++){if(b=U.slice(YD+2),S[YD+1]&&S[YD+1]==="="){if(JD=U.slice(YD+3),q=S[YD],f(q,W.arrays))H=_D(H,q,E,JD);else if(f(q,W.nargs)!==!1)H=r(H,q,E,JD);else i(q,JD);K=!0;break}if(b==="-"){i(S[YD],b);continue}if(/[A-Za-z]/.test(S[YD])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(b)&&f(b,W.bools)===!1){i(S[YD],b),K=!0;break}if(S[YD+1]&&S[YD+1].match(/\W/)){i(S[YD],b),K=!0;break}else i(S[YD],g(S[YD]))}if(q=U.slice(-1)[0],!K&&q!=="-")if(f(q,W.arrays))H=_D(H,q,E);else if(f(q,W.nargs)!==!1)H=r(H,q,E);else if(b=E[H+1],b!==void 0&&(!/^(-|--)[^-]/.test(b)||b.match(M))&&!f(q,W.bools)&&!f(q,W.counts))i(q,b),H++;else if(/^(true|false)$/.test(b))i(q,b),H++;else i(q,g(q))}else if(U.match(/^-[0-9]$/)&&U.match(M)&&f(U.slice(1),W.bools))q=U.slice(1),i(q,g(q));else if(U==="--"){k=E.slice(H+1);break}else if($["halt-at-non-option"]){k=E.slice(H);break}else e(U)}if(BD(w,!0),BD(w,!1),x(w),n(),mD(w,W.aliases,G,!0),d(w),$["set-placeholder-key"])$D(w);if(Object.keys(W.counts).forEach(function(H){if(!t(w,H.split(".")))i(H,0)}),Y&&k.length)w[J]=[];if(k.forEach(function(H){w[J].push(H)}),$["camel-case-expansion"]&&$["strip-dashed"])Object.keys(w).filter((H)=>H!=="--"&&H.includes("-")).forEach((H)=>{delete w[H]});if($["strip-aliased"])[].concat(...Object.keys(B).map((H)=>B[H])).forEach((H)=>{if($["camel-case-expansion"]&&H.includes("-"))delete w[H.split(".").map((U)=>rD(U)).join(".")];delete w[H]});function e(H){let U=A("_",H);if(typeof U==="string"||typeof U==="number")w._.push(U)}function r(H,U,j,K){let q,S=f(U,W.nargs);if(S=typeof S!=="number"||isNaN(S)?1:S,S===0){if(!zD(K))N=Error(V("Argument unexpected for: %s",U));return i(U,g(U)),H}let L=zD(K)?0:1;if($["nargs-eats-options"]){if(j.length-(H+1)+L<S)N=Error(V("Not enough arguments following: %s",U));L=S}else{for(q=H+1;q<j.length;q++)if(!j[q].match(/^-[^0-9]/)||j[q].match(M)||l(j[q]))L++;else break;if(L<S)N=Error(V("Not enough arguments following: %s",U))}let b=Math.min(L,S);if(!zD(K)&&b>0)i(U,K),b--;for(q=H+1;q<b+H+1;q++)i(U,j[q]);return H+b}function _D(H,U,j,K){let q=[],S=K||j[H+1],L=f(U,W.nargs);if(f(U,W.bools)&&!/^(true|false)$/.test(S))q.push(!0);else if(zD(S)||zD(K)&&/^-/.test(S)&&!M.test(S)&&!l(S)){if(G[U]!==void 0){let b=G[U];q=Array.isArray(b)?b:[b]}}else{if(!zD(K))q.push(P(U,K,!0));for(let b=H+1;b<j.length;b++){if(!$["greedy-arrays"]&&q.length>0||L&&typeof L==="number"&&q.length>=L)break;if(S=j[b],/^-/.test(S)&&!M.test(S)&&!l(S))break;H=b,q.push(P(U,S,C))}}if(typeof L==="number"&&(L&&q.length<L||isNaN(L)&&q.length===0))N=Error(V("Not enough arguments following: %s",U));return i(U,q),H}function i(H,U,j=C){if(/-/.test(H)&&$["camel-case-expansion"]){let S=H.split(".").map(function(L){return rD(L)}).join(".");oD(H,S)}let K=P(H,U,j),q=H.split(".");if(hD(w,q,K),W.aliases[H])W.aliases[H].forEach(function(S){let L=S.split(".");hD(w,L,K)});if(q.length>1&&$["dot-notation"])(W.aliases[q[0]]||[]).forEach(function(S){let L=S.split("."),b=[].concat(q);if(b.shift(),L=L.concat(b),!(W.aliases[H]||[]).includes(L.join(".")))hD(w,L,K)});if(f(H,W.normalize)&&!f(H,W.arrays))[H].concat(W.aliases[H]||[]).forEach(function(L){Object.defineProperty(c,L,{enumerable:!0,get(){return U},set(b){U=typeof b==="string"?vD.normalize(b):b}})})}function oD(H,U){if(!(W.aliases[H]&&W.aliases[H].length))W.aliases[H]=[U],Q[U]=!0;if(!(W.aliases[U]&&W.aliases[U].length))oD(U,H)}function P(H,U,j){if(j)U=x3(U);if(f(H,W.bools)||f(H,W.counts)){if(typeof U==="string")U=U==="true"}let K=Array.isArray(U)?U.map(function(q){return A(H,q)}):A(H,U);if(f(H,W.counts)&&(zD(K)||typeof K==="boolean"))K=fF();if(f(H,W.normalize)&&f(H,W.arrays))if(Array.isArray(U))K=U.map((q)=>{return vD.normalize(q)});else K=vD.normalize(U);return K}function A(H,U){if(!$["parse-positional-numbers"]&&H==="_")return U;if(!f(H,W.strings)&&!f(H,W.bools)&&!Array.isArray(U)){if(ou(U)&&$["parse-numbers"]&&Number.isSafeInteger(Math.floor(parseFloat(`${U}`)))||!zD(U)&&f(H,W.numbers))U=Number(U)}return U}function x(H){let U=Object.create(null);mD(U,W.aliases,G),Object.keys(W.configs).forEach(function(j){let K=H[j]||U[j];if(K)try{let q=null,S=vD.resolve(vD.cwd(),K),L=W.configs[j];if(typeof L==="function"){try{q=L(S)}catch(b){q=b}if(q instanceof Error){N=q;return}}else q=vD.require(S);p(q)}catch(q){if(q.name==="PermissionDenied")N=q;else if(H[j])N=Error(V("Invalid JSON config file: %s",K))}})}function p(H,U){Object.keys(H).forEach(function(j){let K=H[j],q=U?U+"."+j:j;if(typeof K==="object"&&K!==null&&!Array.isArray(K)&&$["dot-notation"])p(K,q);else if(!t(w,q.split("."))||f(q,W.arrays)&&$["combine-arrays"])i(q,K)})}function n(){if(typeof z<"u")z.forEach(function(H){p(H)})}function BD(H,U){if(typeof Z>"u")return;let j=typeof Z==="string"?Z:"",K=vD.env();Object.keys(K).forEach(function(q){if(j===""||q.lastIndexOf(j,0)===0){let S=q.split("__").map(function(L,b){if(b===0)L=L.substring(j.length);return rD(L)});if((U&&W.configs[S.join(".")]||!U)&&!t(H,S))i(S.join("."),K[q])}})}function d(H){let U,j=new Set;Object.keys(H).forEach(function(K){if(!j.has(K)){if(U=f(K,W.coercions),typeof U==="function")try{let q=A(K,U(H[K]));[].concat(W.aliases[K]||[],K).forEach((S)=>{j.add(S),H[S]=q})}catch(q){N=q}}})}function $D(H){return W.keys.forEach((U)=>{if(~U.indexOf("."))return;if(typeof H[U]>"u")H[U]=void 0}),H}function mD(H,U,j,K=!1){Object.keys(j).forEach(function(q){if(!t(H,q.split("."))){if(hD(H,q.split("."),j[q]),K)O[q]=!0;(U[q]||[]).forEach(function(S){if(t(H,S.split(".")))return;hD(H,S.split("."),j[q])})}})}function t(H,U){let j=H;if(!$["dot-notation"])U=[U.join(".")];U.slice(0,-1).forEach(function(q){j=j[q]||{}});let K=U[U.length-1];if(typeof j!=="object")return!1;else return K in j}function hD(H,U,j){let K=H;if(!$["dot-notation"])U=[U.join(".")];U.slice(0,-1).forEach(function(JD){if(JD=K2(JD),typeof K==="object"&&K[JD]===void 0)K[JD]={};if(typeof K[JD]!=="object"||Array.isArray(K[JD])){if(Array.isArray(K[JD]))K[JD].push({});else K[JD]=[K[JD],{}];K=K[JD][K[JD].length-1]}else K=K[JD]});let q=K2(U[U.length-1]),S=f(U.join("."),W.arrays),L=Array.isArray(j),b=$["duplicate-arguments-array"];if(!b&&f(q,W.nargs)){if(b=!0,!zD(K[q])&&W.nargs[q]===1||Array.isArray(K[q])&&K[q].length===W.nargs[q])K[q]=void 0}if(j===fF())K[q]=fF(K[q]);else if(Array.isArray(K[q]))if(b&&S&&L)K[q]=$["flatten-duplicate-arrays"]?K[q].concat(j):(Array.isArray(K[q][0])?K[q]:[K[q]]).concat([j]);else if(!b&&Boolean(S)===Boolean(L))K[q]=j;else K[q]=K[q].concat([j]);else if(K[q]===void 0&&S)K[q]=L?j:[j];else if(b&&!(K[q]===void 0||f(q,W.counts)||f(q,W.bools)))K[q]=[K[q],j];else K[q]=j}function Nu(...H){H.forEach(function(U){Object.keys(U||{}).forEach(function(j){if(W.aliases[j])return;W.aliases[j]=[].concat(B[j]||[]),W.aliases[j].concat(j).forEach(function(K){if(/-/.test(K)&&$["camel-case-expansion"]){let q=rD(K);if(q!==j&&W.aliases[j].indexOf(q)===-1)W.aliases[j].push(q),Q[q]=!0}}),W.aliases[j].concat(j).forEach(function(K){if(K.length>1&&/[A-Z]/.test(K)&&$["camel-case-expansion"]){let q=tu(K,"-");if(q!==j&&W.aliases[j].indexOf(q)===-1)W.aliases[j].push(q),Q[q]=!0}}),W.aliases[j].forEach(function(K){W.aliases[K]=[j].concat(W.aliases[j].filter(function(q){return K!==q}))})})})}function f(H,U){let j=[].concat(W.aliases[H]||[],H),K=Object.keys(U),q=j.find((S)=>K.includes(S));return q?U[q]:!1}function Hu(H){let U=Object.keys(W);return[].concat(U.map((K)=>W[K])).some(function(K){return Array.isArray(K)?K.includes(H):K[H]})}function c0(H,...U){return[].concat(...U).some(function(K){let q=H.match(K);return q&&Hu(q[1])})}function h(H){if(H.match(M)||!H.match(/^-[^-]+/))return!1;let U=!0,j,K=H.slice(1).split("");for(let q=0;q<K.length;q++){if(j=H.slice(q+2),!Hu(K[q])){U=!1;break}if(K[q+1]&&K[q+1]==="="||j==="-"||/[A-Za-z]/.test(K[q])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(j)||K[q+1]&&K[q+1].match(/\W/))break}return U}function l(H){return $["unknown-options-as-args"]&&GD(H)}function GD(H){if(H=H.replace(/^-{3,}/,"--"),H.match(M))return!1;if(h(H))return!1;return!c0(H,/^-+([^=]+?)=[\s\S]*$/,_,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}function g(H){if(!f(H,W.bools)&&!f(H,W.counts)&&`${H}`in G)return G[H];else return QD(uD(H))}function QD(H){return{[jD.BOOLEAN]:!0,[jD.STRING]:"",[jD.NUMBER]:void 0,[jD.ARRAY]:[]}[H]}function uD(H){let U=jD.BOOLEAN;if(f(H,W.strings))U=jD.STRING;else if(f(H,W.numbers))U=jD.NUMBER;else if(f(H,W.bools))U=jD.BOOLEAN;else if(f(H,W.arrays))U=jD.ARRAY;return U}function zD(H){return H===void 0}function TF(){Object.keys(W.counts).find((H)=>{if(f(H,W.arrays))return N=Error(V("Invalid configuration: %s, opts.count excludes opts.array.",H)),!0;else if(f(H,W.nargs))return N=Error(V("Invalid configuration: %s, opts.count excludes opts.narg.",H)),!0;return!1})}return{aliases:Object.assign({},W.aliases),argv:Object.assign(c,w),configuration:$,defaulted:Object.assign({},O),error:N,newAliases:Object.assign({},Q)}}}function w3(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(G){return u[B].indexOf(G)!==-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($,G,z){return z.indexOf($)===G});let B=C.pop();if(B!==void 0&&typeof B==="string")F[B]=C}),F}function fF(D){return D!==void 0?D+1:1}function K2(D){if(D==="__proto__")return"___proto___";return D}function x3(D){return typeof D==="string"&&(D[0]==="'"||D[0]==='"')&&D[D.length-1]===D[0]?D.substring(1,D.length-1):D}import{readFileSync as h3}from"fs";import{createRequire as _2}from"node:module";var vF,pF,yF,j2=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):20,A2=(pF=(vF=process===null||process===void 0?void 0:process.versions)===null||vF===void 0?void 0:vF.node)!==null&&pF!==void 0?pF:(yF=process===null||process===void 0?void 0:process.version)===null||yF===void 0?void 0:yF.slice(1);if(A2){if(Number(A2.match(/^([^.]+)/)[1])<j2)throw Error(`yargs parser supports a minimum Node.js version of ${j2}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`)}var v3=process?process.env:{},L2=_2?_2(import.meta.url):void 0,N2=new hF({cwd:process.cwd,env:()=>{return v3},format:I3,normalize:b3,resolve:f3,require:(D)=>{if(typeof L2<"u")return L2(D);else if(D.match(/\.json$/))return JSON.parse(h3(D,"utf8"));else throw Error("only .json config files are supported in ESM")}}),Tu=function(u,F){return N2.parse(u.slice(),F).argv};Tu.detailed=function(D,u){return N2.parse(D.slice(),u)};Tu.camelCase=rD;Tu.decamelize=tu;Tu.looksLikeNumber=ou;var mF=Tu;import{basename as o3,dirname as s3,extname as r3,relative as a3,resolve as f2,join as e3}from"path";function T2(){if(p3())return 0;return 1}function p3(){return y3()&&!process.defaultApp}function y3(){return!!process.versions.electron}function cF(D){return D.slice(T2()+1)}function R2(){return process.argv[T2()]}import{readFileSync as m3,statSync as c3,writeFile as g3}from"fs";import{format as k3}from"util";import{resolve as d3}from"path";var S2={fs:{readFileSync:m3,writeFile:g3},format:k3,resolve:d3,exists:(D)=>{try{return c3(D).isFile()}catch(u){return!1}}};var RD;class P2{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 RD.format.apply(RD.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 RD.format.apply(RD.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);RD.fs.writeFile(B,$,"utf-8",function(G){if(D.writeQueue.shift(),D.writeQueue.length>0)D._processWriteQueue();C(G)})}_readLocaleFile(){let D={},u=this._resolveLocaleFile(this.directory,this.locale);try{if(RD.fs.readFileSync)D=JSON.parse(RD.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=RD.resolve(D,"./",u+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(F)&&~u.lastIndexOf("_")){let E=RD.resolve(D,"./",u.split("_")[0]+".json");if(this._fileExistsSync(E))F=E}return F}_fileExistsSync(D){return RD.exists(D)}}function w2(D,u){RD=u;let F=new P2(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 i3=(D)=>{return w2(D,S2)},x2=i3;var v2=k0(b2(),1);import{createRequire as D6}from"node:module";import{readFileSync as u6,readdirSync as F6}from"node:fs";var gF=h2(import.meta.url),E6=gF.substring(0,gF.lastIndexOf("node_modules")),C6=D6(import.meta.url),kF={assert:{notStrictEqual:n3,strictEqual:l3},cliui:IF,findUp:bF,getEnv:(D)=>{return process.env[D]},inspect:t3,getProcessArgvBin:R2,mainFilename:E6||process.cwd(),Parser:mF,path:{basename:o3,dirname:s3,extname:r3,relative:a3,resolve:f2,join:e3},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:u6,readdirSync:F6,require:C6,getCallerFile:()=>{let D=v2.default(3);return D.match(/^file:\/\//)?h2(D):D},stringWidth:TD,y18n:x2({directory:f2(gF,"../../../locales"),updateFiles:!1})};function WD(D,u,F,E){F.assert.notStrictEqual(D,u,E)}function dF(D,u){u.assert.strictEqual(typeof D,"string")}function qu(D){return Object.keys(D)}function s(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 cD(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(($,G)=>{let z=!1;if($=$.replace(/\s/g,""),/\.+[\]>]/.test($)&&G===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 B6=["first","second","third","fourth","fifth","sixth"];function T(D,u,F){function E(){return typeof D==="object"?[{demanded:[],optional:[]},D,u]:[cD(`cmd ${D}`),u,F]}try{let C=0,[B,$,G]=E(),z=[].slice.call($);while(z.length&&z[z.length-1]===void 0)z.pop();let Z=G||z.length;if(Z<B.demanded.length)throw new FD(`Not enough arguments provided. Expected ${B.demanded.length} but received ${z.length}.`);let Y=B.demanded.length+B.optional.length;if(Z>Y)throw new FD(`Too many arguments provided. Expected max ${Y} but received ${Z}.`);B.demanded.forEach((J)=>{let Q=z.shift(),O=p2(Q);if(J.cmd.filter((W)=>W===O||W==="*").length===0)y2(O,J.cmd,C);C+=1}),B.optional.forEach((J)=>{if(z.length===0)return;let Q=z.shift(),O=p2(Q);if(J.cmd.filter((W)=>W===O||W==="*").length===0)y2(O,J.cmd,C);C+=1})}catch(C){console.warn(C.stack)}}function p2(D){if(Array.isArray(D))return"array";else if(D===null)return"null";return typeof D}function y2(D,u,F){throw new FD(`Invalid ${B6[F]||"manyith"} argument. Expected ${u.join(" or ")} but received ${D}.`)}class iF{constructor(D){this.globalMiddleware=[],this.frozens=[],this.yargs=D}addMiddleware(D,u,F=!0,E=!1){if(T("<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 m2(D){if(!D)return[];return D.map((u)=>{return u.applyBeforeValidation=!1,u})}function aD(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(s(C))return C.then(($)=>Promise.all([$,B($,u)])).then(([$,G])=>Object.assign($,G));else{let $=B(C,u);return s($)?$.then((G)=>Object.assign(C,G)):Object.assign(C,$)}},D)}function eD(D,u,F=(E)=>{throw E}){try{let E=$6(D)?D():D;return s(E)?E.then((C)=>u(C)):u(E)}catch(E){return F(E)}}function $6(D){return typeof D==="function"}var Uu=/(^\*)|(^\$0)/;class g2{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:(G)=>G;for(let G of B){let z=G.toString();if(E.exclude){let Y=!1;if(typeof E.exclude==="function")Y=E.exclude(z);else Y=E.exclude.test(z);if(Y)continue}if(E.include){let Y=!1;if(typeof E.include==="function")Y=E.include(z);else Y=E.include.test(z);if(!Y)continue}let Z=!1;for(let Y of E.extensions)if(z.endsWith(Y))Z=!0;if(Z){let Y=this.shim.path.join(C,z),J=u(Y),Q=Object.create(null,Object.getOwnPropertyDescriptors({...J}));if($(Q,Y,z)){if(this.requireCache.has(Y))continue;else this.requireCache.add(Y);if(!Q.command)Q.command=this.shim.path.basename(Y,this.shim.path.extname(Y));this.addHandler(Q)}}}}addHandler(D,u,F,E,C,B){let $=[],G=m2(C);if(E=E||(()=>{}),Array.isArray(D))if(G6(D))[D,...$]=D;else for(let z of D)this.addHandler(z);else if(Z6(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(c2(F)){this.addHandler([D].concat($),u,F.builder,F.handler,F.middlewares,F.deprecated);return}if(typeof D==="string"){let z=cD(D);$=$.map((J)=>cD(J).cmd);let Z=!1,Y=[z.cmd].concat($).filter((J)=>{if(Uu.test(J))return Z=!0,!1;return!0});if(Y.length===0&&Z)Y.push("$0");if(Z)z.cmd=Y[0],$=Y.slice(1),D=D.replace(Uu,z.cmd);if($.forEach((J)=>{this.aliasMap[J]=z.cmd}),u!==!1)this.usage.command(D,u,Z,$,B);if(this.handlers[z.cmd]={original:D,description:u,handler:E,builder:F||{},middlewares:G,deprecated:B,demanded:z.demanded,optional:z.optional},Z)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,G=u.getInternalMethods().getContext(),z=G.commands.slice(),Z=!D;if(D)G.commands.push(D),G.fullCommands.push($.original);let Y=this.applyBuilderUpdateUsageAndParse(Z,$,u,F.aliases,z,E,C,B);return s(Y)?Y.then((J)=>this.applyMiddlewareAndGetResult(Z,$,J.innerArgv,G,C,J.aliases,u)):this.applyMiddlewareAndGetResult(Z,$,Y.innerArgv,G,C,Y.aliases,u)}applyBuilderUpdateUsageAndParse(D,u,F,E,C,B,$,G){let z=u.builder,Z=F;if(su(z)){F.getInternalMethods().getUsageInstance().freeze();let Y=z(F.getInternalMethods().reset(E),G);if(s(Y))return Y.then((J)=>{return Z=d2(J)?J:F,this.parseAndUpdateUsage(D,u,Z,C,B,$)})}else if(z6(z))F.getInternalMethods().getUsageInstance().freeze(),Z=F.getInternalMethods().reset(E),Object.keys(u.builder).forEach((Y)=>{Z.option(Y,z[Y])});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 s($)?$.then((G)=>({aliases:F.parsed.aliases,innerArgv:G})):{aliases:F.parsed.aliases,innerArgv:$}}shouldUpdateUsage(D){return!D.getInternalMethods().getUsageInstance().getUsageDisabled()&&D.getInternalMethods().getUsageInstance().getUsage().length===0}usageFromParentCommandsCommandHandler(D,u){let F=Uu.test(u.original)?u.original.replace(Uu,"").trim():u.original,E=D.filter((C)=>{return!Uu.test(C)});return E.push(F),`$0 ${E.join(" ")}`}handleValidationAndGetResult(D,u,F,E,C,B,$,G){if(!B.getInternalMethods().getHasOutput()){let z=B.getInternalMethods().runValidation(C,G,B.parsed.error,D);F=eD(F,(Z)=>{return z(Z),Z})}if(u.handler&&!B.getInternalMethods().getHasOutput()){B.getInternalMethods().setHasOutput();let z=!!B.getOptions().configuration["populate--"];if(B.getInternalMethods().postProcess(F,z,!1,!1),F=aD(F,B,$,!1),F=eD(F,(Z)=>{let Y=u.handler(Z);return s(Y)?Y.then(()=>Z):Z}),!D)B.getInternalMethods().getUsageInstance().cacheHelpMessage();if(s(F)&&!B.getInternalMethods().hasParseCallback())F.catch((Z)=>{try{B.getInternalMethods().getUsageInstance().fail(null,Z)}catch(Y){}})}if(!D)E.commands.pop(),E.fullCommands.pop();return F}applyMiddlewareAndGetResult(D,u,F,E,C,B,$){let G={};if(C)return F;if(!$.getInternalMethods().getHasOutput())G=this.populatePositionals(u,F,E,$);let z=this.globalMiddleware.getMiddleware().slice(0).concat(u.middlewares),Z=aD(F,$,z,!0);return s(Z)?Z.then((Y)=>this.handleValidationAndGetResult(D,u,Y,E,B,$,z,G)):this.handleValidationAndGetResult(D,u,Z,E,B,$,z,G)}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 G=C.shift();this.populatePositional(G,u,$)}while(B.length){let G=B.shift();this.populatePositional(G,u,$)}return u._=F.commands.concat(u._.map((G)=>""+G)),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=cD(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((Z)=>{if(C.configuration["unknown-options-as-args"])C.key[z]=!0;B.push(`--${z}`),B.push(Z)})}),!B.length)return;let $=Object.assign({},C.configuration,{"populate--":!1}),G=this.shim.Parser.detailed(B,Object.assign({},C,{configuration:$}));if(G.error)E.getInternalMethods().getUsageInstance().fail(G.error.message,G.error);else{let z=Object.keys(u);Object.keys(u).forEach((Z)=>{z.push(...G.aliases[Z])}),Object.keys(G.argv).forEach((Z)=>{if(z.includes(Z)){if(!u[Z])u[Z]=G.argv[Z];if(!this.isInConfigs(E,Z)&&!this.isDefaulted(E,Z)&&Object.prototype.hasOwnProperty.call(D,Z)&&Object.prototype.hasOwnProperty.call(G.argv,Z)&&(Array.isArray(D[Z])||Array.isArray(G.argv[Z])))D[Z]=[].concat(D[Z],G.argv[Z]);else D[Z]=G.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=Uu.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(su(u))return u(D,!0);else if(!c2(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;WD(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();WD(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 k2(D,u,F,E){return new g2(D,u,F,E)}function c2(D){return typeof D==="object"&&!!D.builder&&typeof D.handler==="function"}function G6(D){return D.every((u)=>typeof u==="string")}function su(D){return typeof D==="function"}function z6(D){return typeof D==="object"}function Z6(D){return typeof D==="object"&&!Array.isArray(D)}function gD(D={},u=()=>!0){let F={};return qu(D).forEach((E)=>{if(u(E,D[E]))F[E]=D[E]}),F}function kD(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 J6(D){return typeof D==="boolean"}function n2(D,u){let F=u.y18n.__,E={},C=[];E.failFn=function(A){C.push(A)};let B=null,$=null,G=!0;E.showHelpOnFail=function(A=!0,x){let[p,n]=typeof A==="string"?[!0,A]:[A,x];if(D.getInternalMethods().isGlobalContext())$=n;return B=n,G=p,E};let z=!1;E.fail=function(A,x){let p=D.getInternalMethods().getLoggerInstance();if(C.length)for(let n=C.length-1;n>=0;--n){let BD=C[n];if(J6(BD)){if(x)throw x;else if(A)throw Error(A)}else BD(A,x,E)}else{if(D.getExitProcess())kD(!0);if(!z){if(z=!0,G)D.showHelp("error"),p.error();if(A||x)p.error(A||x);let n=B||$;if(n){if(A||x)p.error("");p.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=[],Y=!1;E.usage=(P,A)=>{if(P===null)return Y=!0,Z=[],E;return Y=!1,Z.push([P,A||""]),E},E.getUsage=()=>{return Z},E.getUsageDisabled=()=>{return Y},E.getPositionalGroupName=()=>{return F("Positionals:")};let J=[];E.example=(P,A)=>{J.push([P,A||""])};let Q=[];E.command=function(A,x,p,n,BD=!1){if(p)Q=Q.map((d)=>{return d[2]=!1,d});Q.push([A,x||"",p,n,BD])},E.getCommands=()=>Q;let O={};E.describe=function(A,x){if(Array.isArray(A))A.forEach((p)=>{E.describe(p,x)});else if(typeof A==="object")Object.keys(A).forEach((p)=>{E.describe(p,A[p])});else O[A]=x},E.getDescriptions=()=>O;let V=[];E.epilog=(P)=>{V.push(P)};let W=!1,M;E.wrap=(P)=>{W=!0,M=P},E.getWrap=()=>{if(u.getEnv("YARGS_DISABLE_WRAP"))return null;if(!W)M=_D(),W=!0;return M};let _="__yargsString__:";E.deferY18nLookup=(P)=>_+P,E.help=function(){if(w)return w;k();let A=D.customScriptName?D.$0:u.path.basename(D.$0),x=D.getDemandedOptions(),p=D.getDemandedCommands(),n=D.getDeprecatedOptions(),BD=D.getGroups(),d=D.getOptions(),$D=[];$D=$D.concat(Object.keys(O)),$D=$D.concat(Object.keys(x)),$D=$D.concat(Object.keys(p)),$D=$D.concat(Object.keys(d.default)),$D=$D.filter(e),$D=Object.keys($D.reduce((h,l)=>{if(l!=="_")h[l]=!0;return h},{}));let mD=E.getWrap(),t=u.cliui({width:mD,wrap:!!mD});if(!Y){if(Z.length)Z.forEach((h)=>{if(t.div({text:`${h[0].replace(/\$0/g,A)}`}),h[1])t.div({text:`${h[1]}`,padding:[1,0,0,0]})}),t.div();else if(Q.length){let h=null;if(p._)h=`${A} <${F("command")}>
15
- `;else h=`${A} [${F("command")}]
16
- `;t.div(`${h}`)}}if(Q.length>1||Q.length===1&&!Q[0][2]){t.div(F("Commands:"));let h=D.getInternalMethods().getContext(),l=h.commands.length?`${h.commands.join(" ")} `:"";if(D.getInternalMethods().getParserConfiguration()["sort-commands"]===!0)Q=Q.sort((g,QD)=>g[0].localeCompare(QD[0]));let GD=A?`${A} `:"";Q.forEach((g)=>{let QD=`${GD}${l}${g[0].replace(/^\$0 ?/,"")}`;t.span({text:QD,padding:[0,2,0,2],width:N(Q,mD,`${A}${l}`)+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)t.div({text:uD.join(" "),padding:[0,0,0,2],align:"right"});else t.div()}),t.div()}let hD=(Object.keys(d.alias)||[]).concat(Object.keys(D.parsed.newAliases)||[]);$D=$D.filter((h)=>!D.parsed.newAliases[h]&&hD.every((l)=>(d.alias[l]||[]).indexOf(h)===-1));let Nu=F("Options:");if(!BD[Nu])BD[Nu]=[];c($D,d.alias,BD,Nu);let f=(h)=>/^--/.test(ru(h)),Hu=Object.keys(BD).filter((h)=>BD[h].length>0).map((h)=>{let l=BD[h].filter(e).map((GD)=>{if(hD.includes(GD))return GD;for(let g=0,QD;(QD=hD[g])!==void 0;g++)if((d.alias[QD]||[]).includes(GD))return QD;return GD});return{groupName:h,normalizedKeys:l}}).filter(({normalizedKeys:h})=>h.length>0).map(({groupName:h,normalizedKeys:l})=>{let GD=l.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,zD)=>f(uD)===f(zD)?0:f(uD)?1:-1).join(", "),g},{});return{groupName:h,normalizedKeys:l,switches:GD}});if(Hu.filter(({groupName:h})=>h!==E.getPositionalGroupName()).some(({normalizedKeys:h,switches:l})=>!h.every((GD)=>f(l[GD]))))Hu.filter(({groupName:h})=>h!==E.getPositionalGroupName()).forEach(({normalizedKeys:h,switches:l})=>{h.forEach((GD)=>{if(f(l[GD]))l[GD]=X6(l[GD],4)})});if(Hu.forEach(({groupName:h,normalizedKeys:l,switches:GD})=>{t.div(h),l.forEach((g)=>{let QD=GD[g],uD=O[g]||"",zD=null;if(uD.includes(_))uD=F(uD.substring(_.length));if(d.boolean.includes(g))zD=`[${F("boolean")}]`;if(d.count.includes(g))zD=`[${F("count")}]`;if(d.string.includes(g))zD=`[${F("string")}]`;if(d.normalize.includes(g))zD=`[${F("string")}]`;if(d.array.includes(g))zD=`[${F("array")}]`;if(d.number.includes(g))zD=`[${F("number")}]`;let TF=(j)=>typeof j==="string"?`[${F("deprecated: %s",j)}]`:`[${F("deprecated")}]`,H=[g in n?TF(n[g]):null,zD,g in x?`[${F("required")}]`:null,d.choices&&d.choices[g]?`[${F("choices:")} ${E.stringifiedValues(d.choices[g])}]`:null,r(d.default[g],d.defaultDescription[g])].filter(Boolean).join(" ");t.span({text:ru(QD),padding:[0,2,0,2+i2(QD)],width:N(GD,mD)+4},uD);let U=D.getInternalMethods().getUsageConfiguration()["hide-types"]===!0;if(H&&!U)t.div({text:H,padding:[0,0,0,2],align:"right"});else t.div()}),t.div()}),J.length)t.div(F("Examples:")),J.forEach((h)=>{h[0]=h[0].replace(/\$0/g,A)}),J.forEach((h)=>{if(h[1]==="")t.div({text:h[0],padding:[0,2,0,2]});else t.div({text:h[0],padding:[0,2,0,2],width:N(J,mD)+4},{text:h[1]})}),t.div();if(V.length>0){let h=V.map((l)=>l.replace(/\$0/g,A)).join(`
17
- `);t.div(`${h}
18
- `)}return t.toString().replace(/\s*$/,"")};function N(P,A,x){let p=0;if(!Array.isArray(P))P=Object.values(P).map((n)=>[n]);if(P.forEach((n)=>{p=Math.max(u.stringWidth(x?`${x} ${ru(n[0])}`:ru(n[0]))+i2(n[0]),p)}),A)p=Math.min(p,parseInt((A*0.5).toString(),10));return p}function k(){let P=D.getDemandedOptions(),A=D.getOptions();(Object.keys(A.alias)||[]).forEach((x)=>{A.alias[x].forEach((p)=>{if(O[p])E.describe(x,O[p]);if(p in P)D.demandOption(x,P[p]);if(A.boolean.includes(p))D.boolean(x);if(A.count.includes(p))D.count(x);if(A.string.includes(p))D.string(x);if(A.normalize.includes(p))D.normalize(x);if(A.array.includes(p))D.array(x);if(A.number.includes(p))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,p){let n=[],BD=null;return Object.keys(x).forEach((d)=>{n=n.concat(x[d])}),P.forEach((d)=>{if(BD=[d].concat(A[d]),!BD.some(($D)=>n.indexOf($D)!==-1))x[p].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 p="",n=x||", ",BD=[].concat(A);if(!A||!BD.length)return p;return BD.forEach((d)=>{if(p.length)p+=n;p+=JSON.stringify(d)}),p};function r(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 _D(){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,z=!1,Z=[],Y=!1,V=[],J=[],Q=[],O=gD(O,(x)=>!A[x]),E};let oD=[];return E.freeze=function(){oD.push({failMessage:B,failureOutput:z,usages:Z,usageDisabled:Y,epilogs:V,examples:J,commands:Q,descriptions:O})},E.unfreeze=function(A=!1){let x=oD.pop();if(!x)return;if(A)O={...x.descriptions,...O},Q=[...x.commands,...Q],Z=[...x.usages,...Z],J=[...x.examples,...J],V=[...x.epilogs,...V];else({failMessage:B,failureOutput:z,usages:Z,usageDisabled:Y,epilogs:V,examples:J,commands:Q,descriptions:O}=x)},E}function nF(D){return typeof D==="object"}function X6(D,u){return nF(D)?{text:D.text,indentation:D.indentation+u}:{text:D,indentation:u}}function i2(D){return nF(D)?D.indentation:0}function ru(D){return nF(D)?D.text:D}var l2=`###-begin-{{app_name}}-completions-###
13
+ `).map((E)=>I3(E,u,F)).join(`
14
+ `)}function bF(D){return e0(D,{stringWidth:TD,stripAnsi:rD,wrap:IF})}import{dirname as A2,resolve as L2}from"path";import{readdirSync as b3,statSync as f3}from"fs";function fF(D,u){let F=L2(".",D),E;if(!f3(F).isDirectory())F=A2(F);while(!0){if(E=u(F,b3(F)),E)return L2(F,E);if(F=A2(E=F),E===F)break}}import{inspect as e3}from"util";import{fileURLToPath as g2}from"url";import{format as p3}from"util";import{normalize as y3,resolve as m3}from"path";function aD(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 su(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 ru(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 N2(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 MD;(function(D){D.BOOLEAN="boolean",D.STRING="string",D.NUMBER="number",D.ARRAY="array"})(MD||(MD={}));var vD;class vF{constructor(D){vD=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=N2(D),C=typeof D==="string",B=h3(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),G=Object.assign(Object.create(null),F.default),Z=F.configObjects||[],z=F.envPrefix,Q=$["populate--"],J=Q?"--":"_",Y=Object.create(null),O=Object.create(null),V=F.__||vD.format,W={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:[]},U=/^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/,_=new RegExp("^--"+$["negation-prefix"]+"(.+)");if([].concat(F.array||[]).filter(Boolean).forEach(function(H){let K=typeof H==="object"?H.key:H,L=Object.keys(H).map(function(j){return{boolean:"bools",string:"strings",number:"numbers"}[j]}).filter(Boolean).pop();if(L)W[L][K]=!0;W.arrays[K]=!0,W.keys.push(K)}),[].concat(F.boolean||[]).filter(Boolean).forEach(function(H){W.bools[H]=!0,W.keys.push(H)}),[].concat(F.string||[]).filter(Boolean).forEach(function(H){W.strings[H]=!0,W.keys.push(H)}),[].concat(F.number||[]).filter(Boolean).forEach(function(H){W.numbers[H]=!0,W.keys.push(H)}),[].concat(F.count||[]).filter(Boolean).forEach(function(H){W.counts[H]=!0,W.keys.push(H)}),[].concat(F.normalize||[]).filter(Boolean).forEach(function(H){W.normalize[H]=!0,W.keys.push(H)}),typeof F.narg==="object")Object.entries(F.narg).forEach(([H,K])=>{if(typeof K==="number")W.nargs[H]=K,W.keys.push(H)});if(typeof F.coerce==="object")Object.entries(F.coerce).forEach(([H,K])=>{if(typeof K==="function")W.coercions[H]=K,W.keys.push(H)});if(typeof F.config<"u"){if(Array.isArray(F.config)||typeof F.config==="string")[].concat(F.config).filter(Boolean).forEach(function(H){W.configs[H]=!0});else if(typeof F.config==="object")Object.entries(F.config).forEach(([H,K])=>{if(typeof K==="boolean"||typeof K==="function")W.configs[H]=K})}Su(F.key,B,F.default,W.arrays),Object.keys(G).forEach(function(H){(W.aliases[H]||[]).forEach(function(K){G[K]=G[H]})});let M=null;RF();let N=[],A=Object.assign(Object.create(null),{_:[]}),h={};for(let H=0;H<E.length;H++){let K=E[H],L=K.replace(/^-{3,}/,"---"),j,q,w,R,f,JD;if(K!=="--"&&/^-/.test(K)&&t(K))d(K);else if(L.match(/^---+(=|$)/)){d(K);continue}else if(K.match(/^--.+=/)||!$["short-option-groups"]&&K.match(/^-.+=/)){if(R=K.match(/^--?([^=]+)=([\s\S]*)$/),R!==null&&Array.isArray(R)&&R.length>=3)if(v(R[1],W.arrays))H=jD(H,R[1],E,R[2]);else if(v(R[1],W.nargs)!==!1)H=o(H,R[1],E,R[2]);else n(R[1],R[2],!0)}else if(K.match(_)&&$["boolean-negation"]){if(R=K.match(_),R!==null&&Array.isArray(R)&&R.length>=2)q=R[1],n(q,v(q,W.arrays)?[!1]:!1)}else if(K.match(/^--.+/)||!$["short-option-groups"]&&K.match(/^-[^-]+/)){if(R=K.match(/^--?(.+)/),R!==null&&Array.isArray(R)&&R.length>=2)if(q=R[1],v(q,W.arrays))H=jD(H,q,E);else if(v(q,W.nargs)!==!1)H=o(H,q,E);else if(f=E[H+1],f!==void 0&&(!f.match(/^-/)||f.match(U))&&!v(q,W.bools)&&!v(q,W.counts))n(q,f),H++;else if(/^(true|false)$/.test(f))n(q,f),H++;else n(q,k(q))}else if(K.match(/^-.\..+=/)){if(R=K.match(/^-([^=]+)=([\s\S]*)$/),R!==null&&Array.isArray(R)&&R.length>=3)n(R[1],R[2])}else if(K.match(/^-.\..+/)&&!K.match(U)){if(f=E[H+1],R=K.match(/^-(.\..+)/),R!==null&&Array.isArray(R)&&R.length>=2)if(q=R[1],f!==void 0&&!f.match(/^-/)&&!v(q,W.bools)&&!v(q,W.counts))n(q,f),H++;else n(q,k(q))}else if(K.match(/^-[^-]+/)&&!K.match(U)){w=K.slice(1,-1).split(""),j=!1;for(let YD=0;YD<w.length;YD++){if(f=K.slice(YD+2),w[YD+1]&&w[YD+1]==="="){if(JD=K.slice(YD+3),q=w[YD],v(q,W.arrays))H=jD(H,q,E,JD);else if(v(q,W.nargs)!==!1)H=o(H,q,E,JD);else n(q,JD);j=!0;break}if(f==="-"){n(w[YD],f);continue}if(/[A-Za-z]/.test(w[YD])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(f)&&v(f,W.bools)===!1){n(w[YD],f),j=!0;break}if(w[YD+1]&&w[YD+1].match(/\W/)){n(w[YD],f),j=!0;break}else n(w[YD],k(w[YD]))}if(q=K.slice(-1)[0],!j&&q!=="-")if(v(q,W.arrays))H=jD(H,q,E);else if(v(q,W.nargs)!==!1)H=o(H,q,E);else if(f=E[H+1],f!==void 0&&(!/^(-|--)[^-]/.test(f)||f.match(U))&&!v(q,W.bools)&&!v(q,W.counts))n(q,f),H++;else if(/^(true|false)$/.test(f))n(q,f),H++;else n(q,k(q))}else if(K.match(/^-[0-9]$/)&&K.match(U)&&v(K.slice(1),W.bools))q=K.slice(1),n(q,k(q));else if(K==="--"){N=E.slice(H+1);break}else if($["halt-at-non-option"]){N=E.slice(H);break}else d(K)}if(BD(A,!0),BD(A,!1),I(A),l(),mD(A,W.aliases,G,!0),i(A),$["set-placeholder-key"])$D(A);if(Object.keys(W.counts).forEach(function(H){if(!s(A,H.split(".")))n(H,0)}),Q&&N.length)A[J]=[];if(N.forEach(function(H){A[J].push(H)}),$["camel-case-expansion"]&&$["strip-dashed"])Object.keys(A).filter((H)=>H!=="--"&&H.includes("-")).forEach((H)=>{delete A[H]});if($["strip-aliased"])[].concat(...Object.keys(B).map((H)=>B[H])).forEach((H)=>{if($["camel-case-expansion"]&&H.includes("-"))delete A[H.split(".").map((K)=>aD(K)).join(".")];delete A[H]});function d(H){let K=T("_",H);if(typeof K==="string"||typeof K==="number")A._.push(K)}function o(H,K,L,j){let q,w=v(K,W.nargs);if(w=typeof w!=="number"||isNaN(w)?1:w,w===0){if(!zD(j))M=Error(V("Argument unexpected for: %s",K));return n(K,k(K)),H}let R=zD(j)?0:1;if($["nargs-eats-options"]){if(L.length-(H+1)+R<w)M=Error(V("Not enough arguments following: %s",K));R=w}else{for(q=H+1;q<L.length;q++)if(!L[q].match(/^-[^0-9]/)||L[q].match(U)||t(L[q]))R++;else break;if(R<w)M=Error(V("Not enough arguments following: %s",K))}let f=Math.min(R,w);if(!zD(j)&&f>0)n(K,j),f--;for(q=H+1;q<f+H+1;q++)n(K,L[q]);return H+f}function jD(H,K,L,j){let q=[],w=j||L[H+1],R=v(K,W.nargs);if(v(K,W.bools)&&!/^(true|false)$/.test(w))q.push(!0);else if(zD(w)||zD(j)&&/^-/.test(w)&&!U.test(w)&&!t(w)){if(G[K]!==void 0){let f=G[K];q=Array.isArray(f)?f:[f]}}else{if(!zD(j))q.push(x(K,j,!0));for(let f=H+1;f<L.length;f++){if(!$["greedy-arrays"]&&q.length>0||R&&typeof R==="number"&&q.length>=R)break;if(w=L[f],/^-/.test(w)&&!U.test(w)&&!t(w))break;H=f,q.push(x(K,w,C))}}if(typeof R==="number"&&(R&&q.length<R||isNaN(R)&&q.length===0))M=Error(V("Not enough arguments following: %s",K));return n(K,q),H}function n(H,K,L=C){if(/-/.test(H)&&$["camel-case-expansion"]){let w=H.split(".").map(function(R){return aD(R)}).join(".");sD(H,w)}let j=x(H,K,L),q=H.split(".");if(hD(A,q,j),W.aliases[H])W.aliases[H].forEach(function(w){let R=w.split(".");hD(A,R,j)});if(q.length>1&&$["dot-notation"])(W.aliases[q[0]]||[]).forEach(function(w){let R=w.split("."),f=[].concat(q);if(f.shift(),R=R.concat(f),!(W.aliases[H]||[]).includes(R.join(".")))hD(A,R,j)});if(v(H,W.normalize)&&!v(H,W.arrays))[H].concat(W.aliases[H]||[]).forEach(function(R){Object.defineProperty(h,R,{enumerable:!0,get(){return K},set(f){K=typeof f==="string"?vD.normalize(f):f}})})}function sD(H,K){if(!(W.aliases[H]&&W.aliases[H].length))W.aliases[H]=[K],Y[K]=!0;if(!(W.aliases[K]&&W.aliases[K].length))sD(K,H)}function x(H,K,L){if(L)K=v3(K);if(v(H,W.bools)||v(H,W.counts)){if(typeof K==="string")K=K==="true"}let j=Array.isArray(K)?K.map(function(q){return T(H,q)}):T(H,K);if(v(H,W.counts)&&(zD(j)||typeof j==="boolean"))j=hF();if(v(H,W.normalize)&&v(H,W.arrays))if(Array.isArray(K))j=K.map((q)=>{return vD.normalize(q)});else j=vD.normalize(K);return j}function T(H,K){if(!$["parse-positional-numbers"]&&H==="_")return K;if(!v(H,W.strings)&&!v(H,W.bools)&&!Array.isArray(K)){if(ru(K)&&$["parse-numbers"]&&Number.isSafeInteger(Math.floor(parseFloat(`${K}`)))||!zD(K)&&v(H,W.numbers))K=Number(K)}return K}function I(H){let K=Object.create(null);mD(K,W.aliases,G),Object.keys(W.configs).forEach(function(L){let j=H[L]||K[L];if(j)try{let q=null,w=vD.resolve(vD.cwd(),j),R=W.configs[L];if(typeof R==="function"){try{q=R(w)}catch(f){q=f}if(q instanceof Error){M=q;return}}else q=vD.require(w);m(q)}catch(q){if(q.name==="PermissionDenied")M=q;else if(H[L])M=Error(V("Invalid JSON config file: %s",j))}})}function m(H,K){Object.keys(H).forEach(function(L){let j=H[L],q=K?K+"."+L:L;if(typeof j==="object"&&j!==null&&!Array.isArray(j)&&$["dot-notation"])m(j,q);else if(!s(A,q.split("."))||v(q,W.arrays)&&$["combine-arrays"])n(q,j)})}function l(){if(typeof Z<"u")Z.forEach(function(H){m(H)})}function BD(H,K){if(typeof z>"u")return;let L=typeof z==="string"?z:"",j=vD.env();Object.keys(j).forEach(function(q){if(L===""||q.lastIndexOf(L,0)===0){let w=q.split("__").map(function(R,f){if(f===0)R=R.substring(L.length);return aD(R)});if((K&&W.configs[w.join(".")]||!K)&&!s(H,w))n(w.join("."),j[q])}})}function i(H){let K,L=new Set;Object.keys(H).forEach(function(j){if(!L.has(j)){if(K=v(j,W.coercions),typeof K==="function")try{let q=T(j,K(H[j]));[].concat(W.aliases[j]||[],j).forEach((w)=>{L.add(w),H[w]=q})}catch(q){M=q}}})}function $D(H){return W.keys.forEach((K)=>{if(~K.indexOf("."))return;if(typeof H[K]>"u")H[K]=void 0}),H}function mD(H,K,L,j=!1){Object.keys(L).forEach(function(q){if(!s(H,q.split("."))){if(hD(H,q.split("."),L[q]),j)O[q]=!0;(K[q]||[]).forEach(function(w){if(s(H,w.split(".")))return;hD(H,w.split("."),L[q])})}})}function s(H,K){let L=H;if(!$["dot-notation"])K=[K.join(".")];K.slice(0,-1).forEach(function(q){L=L[q]||{}});let j=K[K.length-1];if(typeof L!=="object")return!1;else return j in L}function hD(H,K,L){let j=H;if(!$["dot-notation"])K=[K.join(".")];K.slice(0,-1).forEach(function(JD){if(JD=T2(JD),typeof j==="object"&&j[JD]===void 0)j[JD]={};if(typeof j[JD]!=="object"||Array.isArray(j[JD])){if(Array.isArray(j[JD]))j[JD].push({});else j[JD]=[j[JD],{}];j=j[JD][j[JD].length-1]}else j=j[JD]});let q=T2(K[K.length-1]),w=v(K.join("."),W.arrays),R=Array.isArray(L),f=$["duplicate-arguments-array"];if(!f&&v(q,W.nargs)){if(f=!0,!zD(j[q])&&W.nargs[q]===1||Array.isArray(j[q])&&j[q].length===W.nargs[q])j[q]=void 0}if(L===hF())j[q]=hF(j[q]);else if(Array.isArray(j[q]))if(f&&w&&R)j[q]=$["flatten-duplicate-arrays"]?j[q].concat(L):(Array.isArray(j[q][0])?j[q]:[j[q]]).concat([L]);else if(!f&&Boolean(w)===Boolean(R))j[q]=L;else j[q]=j[q].concat([L]);else if(j[q]===void 0&&w)j[q]=R?L:[L];else if(f&&!(j[q]===void 0||v(q,W.counts)||v(q,W.bools)))j[q]=[j[q],L];else j[q]=L}function Su(...H){H.forEach(function(K){Object.keys(K||{}).forEach(function(L){if(W.aliases[L])return;W.aliases[L]=[].concat(B[L]||[]),W.aliases[L].concat(L).forEach(function(j){if(/-/.test(j)&&$["camel-case-expansion"]){let q=aD(j);if(q!==L&&W.aliases[L].indexOf(q)===-1)W.aliases[L].push(q),Y[q]=!0}}),W.aliases[L].concat(L).forEach(function(j){if(j.length>1&&/[A-Z]/.test(j)&&$["camel-case-expansion"]){let q=su(j,"-");if(q!==L&&W.aliases[L].indexOf(q)===-1)W.aliases[L].push(q),Y[q]=!0}}),W.aliases[L].forEach(function(j){W.aliases[j]=[L].concat(W.aliases[L].filter(function(q){return j!==q}))})})})}function v(H,K){let L=[].concat(W.aliases[H]||[],H),j=Object.keys(K),q=L.find((w)=>j.includes(w));return q?K[q]:!1}function qu(H){let K=Object.keys(W);return[].concat(K.map((j)=>W[j])).some(function(j){return Array.isArray(j)?j.includes(H):j[H]})}function l0(H,...K){return[].concat(...K).some(function(j){let q=H.match(j);return q&&qu(q[1])})}function p(H){if(H.match(U)||!H.match(/^-[^-]+/))return!1;let K=!0,L,j=H.slice(1).split("");for(let q=0;q<j.length;q++){if(L=H.slice(q+2),!qu(j[q])){K=!1;break}if(j[q+1]&&j[q+1]==="="||L==="-"||/[A-Za-z]/.test(j[q])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(L)||j[q+1]&&j[q+1].match(/\W/))break}return K}function t(H){return $["unknown-options-as-args"]&&GD(H)}function GD(H){if(H=H.replace(/^-{3,}/,"--"),H.match(U))return!1;if(p(H))return!1;return!l0(H,/^-+([^=]+?)=[\s\S]*$/,_,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}function k(H){if(!v(H,W.bools)&&!v(H,W.counts)&&`${H}`in G)return G[H];else return QD(uD(H))}function QD(H){return{[MD.BOOLEAN]:!0,[MD.STRING]:"",[MD.NUMBER]:void 0,[MD.ARRAY]:[]}[H]}function uD(H){let K=MD.BOOLEAN;if(v(H,W.strings))K=MD.STRING;else if(v(H,W.numbers))K=MD.NUMBER;else if(v(H,W.bools))K=MD.BOOLEAN;else if(v(H,W.arrays))K=MD.ARRAY;return K}function zD(H){return H===void 0}function RF(){Object.keys(W.counts).find((H)=>{if(v(H,W.arrays))return M=Error(V("Invalid configuration: %s, opts.count excludes opts.array.",H)),!0;else if(v(H,W.nargs))return M=Error(V("Invalid configuration: %s, opts.count excludes opts.narg.",H)),!0;return!1})}return{aliases:Object.assign({},W.aliases),argv:Object.assign(h,A),configuration:$,defaulted:Object.assign({},O),error:M,newAliases:Object.assign({},Y)}}}function h3(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(G){return u[B].indexOf(G)!==-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($,G,Z){return Z.indexOf($)===G});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 T2(D){if(D==="__proto__")return"___proto___";return D}function v3(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 c3}from"fs";import{createRequire as R2}from"node:module";var pF,yF,mF,S2=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):20,P2=(yF=(pF=process===null||process===void 0?void 0:process.versions)===null||pF===void 0?void 0:pF.node)!==null&&yF!==void 0?yF:(mF=process===null||process===void 0?void 0:process.version)===null||mF===void 0?void 0:mF.slice(1);if(P2){if(Number(P2.match(/^([^.]+)/)[1])<S2)throw Error(`yargs parser supports a minimum Node.js version of ${S2}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`)}var g3=process?process.env:{},w2=R2?R2(import.meta.url):void 0,x2=new vF({cwd:process.cwd,env:()=>{return g3},format:p3,normalize:y3,resolve:m3,require:(D)=>{if(typeof w2<"u")return w2(D);else if(D.match(/\.json$/))return JSON.parse(c3(D,"utf8"));else throw Error("only .json config files are supported in ESM")}}),Pu=function(u,F){return x2.parse(u.slice(),F).argv};Pu.detailed=function(D,u){return x2.parse(D.slice(),u)};Pu.camelCase=aD;Pu.decamelize=su;Pu.looksLikeNumber=ru;var cF=Pu;import{basename as D6,dirname as u6,extname as F6,relative as E6,resolve as c2,join as C6}from"path";function I2(){if(k3())return 0;return 1}function k3(){return d3()&&!process.defaultApp}function d3(){return!!process.versions.electron}function gF(D){return D.slice(I2()+1)}function b2(){return process.argv[I2()]}import{readFileSync as i3,statSync as n3,writeFile as l3}from"fs";import{format as t3}from"util";import{resolve as o3}from"path";var f2={fs:{readFileSync:i3,writeFile:l3},format:t3,resolve:o3,exists:(D)=>{try{return n3(D).isFile()}catch(u){return!1}}};var RD;class h2{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 RD.format.apply(RD.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 RD.format.apply(RD.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);RD.fs.writeFile(B,$,"utf-8",function(G){if(D.writeQueue.shift(),D.writeQueue.length>0)D._processWriteQueue();C(G)})}_readLocaleFile(){let D={},u=this._resolveLocaleFile(this.directory,this.locale);try{if(RD.fs.readFileSync)D=JSON.parse(RD.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=RD.resolve(D,"./",u+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(F)&&~u.lastIndexOf("_")){let E=RD.resolve(D,"./",u.split("_")[0]+".json");if(this._fileExistsSync(E))F=E}return F}_fileExistsSync(D){return RD.exists(D)}}function v2(D,u){RD=u;let F=new h2(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 s3=(D)=>{return v2(D,f2)},p2=s3;var k2=o0(m2(),1);import{createRequire as B6}from"node:module";import{readFileSync as $6,readdirSync as G6}from"node:fs";var kF=g2(import.meta.url),z6=kF.substring(0,kF.lastIndexOf("node_modules")),Z6=B6(import.meta.url),dF={assert:{notStrictEqual:r3,strictEqual:a3},cliui:bF,findUp:fF,getEnv:(D)=>{return process.env[D]},inspect:e3,getProcessArgvBin:b2,mainFilename:z6||process.cwd(),Parser:cF,path:{basename:D6,dirname:u6,extname:F6,relative:E6,resolve:c2,join:C6},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:$6,readdirSync:G6,require:Z6,getCallerFile:()=>{let D=k2.default(3);return D.match(/^file:\/\//)?g2(D):D},stringWidth:TD,y18n:p2({directory:c2(kF,"../../../locales"),updateFiles:!1})};function WD(D,u,F,E){F.assert.notStrictEqual(D,u,E)}function iF(D,u){u.assert.strictEqual(typeof D,"string")}function Ku(D){return Object.keys(D)}function a(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 cD(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(($,G)=>{let Z=!1;if($=$.replace(/\s/g,""),/\.+[\]>]/.test($)&&G===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 J6=["first","second","third","fourth","fifth","sixth"];function S(D,u,F){function E(){return typeof D==="object"?[{demanded:[],optional:[]},D,u]:[cD(`cmd ${D}`),u,F]}try{let C=0,[B,$,G]=E(),Z=[].slice.call($);while(Z.length&&Z[Z.length-1]===void 0)Z.pop();let z=G||Z.length;if(z<B.demanded.length)throw new FD(`Not enough arguments provided. Expected ${B.demanded.length} but received ${Z.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=Z.shift(),O=d2(Y);if(J.cmd.filter((W)=>W===O||W==="*").length===0)i2(O,J.cmd,C);C+=1}),B.optional.forEach((J)=>{if(Z.length===0)return;let Y=Z.shift(),O=d2(Y);if(J.cmd.filter((W)=>W===O||W==="*").length===0)i2(O,J.cmd,C);C+=1})}catch(C){console.warn(C.stack)}}function d2(D){if(Array.isArray(D))return"array";else if(D===null)return"null";return typeof D}function i2(D,u,F){throw new FD(`Invalid ${J6[F]||"manyith"} argument. Expected ${u.join(" or ")} but received ${D}.`)}class nF{constructor(D){this.globalMiddleware=[],this.frozens=[],this.yargs=D}addMiddleware(D,u,F=!0,E=!1){if(S("<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 n2(D){if(!D)return[];return D.map((u)=>{return u.applyBeforeValidation=!1,u})}function eD(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(a(C))return C.then(($)=>Promise.all([$,B($,u)])).then(([$,G])=>Object.assign($,G));else{let $=B(C,u);return a($)?$.then((G)=>Object.assign(C,G)):Object.assign(C,$)}},D)}function Du(D,u,F=(E)=>{throw E}){try{let E=X6(D)?D():D;return a(E)?E.then((C)=>u(C)):u(E)}catch(E){return F(E)}}function X6(D){return typeof D==="function"}var Uu=/(^\*)|(^\$0)/;class t2{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:(G)=>G;for(let G of B){let Z=G.toString();if(E.exclude){let Q=!1;if(typeof E.exclude==="function")Q=E.exclude(Z);else Q=E.exclude.test(Z);if(Q)continue}if(E.include){let Q=!1;if(typeof E.include==="function")Q=E.include(Z);else Q=E.include.test(Z);if(!Q)continue}let z=!1;for(let Q of E.extensions)if(Z.endsWith(Q))z=!0;if(z){let Q=this.shim.path.join(C,Z),J=u(Q),Y=Object.create(null,Object.getOwnPropertyDescriptors({...J}));if($(Y,Q,Z)){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 $=[],G=n2(C);if(E=E||(()=>{}),Array.isArray(D))if(Q6(D))[D,...$]=D;else for(let Z of D)this.addHandler(Z);else if(W6(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(l2(F)){this.addHandler([D].concat($),u,F.builder,F.handler,F.middlewares,F.deprecated);return}if(typeof D==="string"){let Z=cD(D);$=$.map((J)=>cD(J).cmd);let z=!1,Q=[Z.cmd].concat($).filter((J)=>{if(Uu.test(J))return z=!0,!1;return!0});if(Q.length===0&&z)Q.push("$0");if(z)Z.cmd=Q[0],$=Q.slice(1),D=D.replace(Uu,Z.cmd);if($.forEach((J)=>{this.aliasMap[J]=Z.cmd}),u!==!1)this.usage.command(D,u,z,$,B);if(this.handlers[Z.cmd]={original:D,description:u,handler:E,builder:F||{},middlewares:G,deprecated:B,demanded:Z.demanded,optional:Z.optional},z)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,G=u.getInternalMethods().getContext(),Z=G.commands.slice(),z=!D;if(D)G.commands.push(D),G.fullCommands.push($.original);let Q=this.applyBuilderUpdateUsageAndParse(z,$,u,F.aliases,Z,E,C,B);return a(Q)?Q.then((J)=>this.applyMiddlewareAndGetResult(z,$,J.innerArgv,G,C,J.aliases,u)):this.applyMiddlewareAndGetResult(z,$,Q.innerArgv,G,C,Q.aliases,u)}applyBuilderUpdateUsageAndParse(D,u,F,E,C,B,$,G){let Z=u.builder,z=F;if(au(Z)){F.getInternalMethods().getUsageInstance().freeze();let Q=Z(F.getInternalMethods().reset(E),G);if(a(Q))return Q.then((J)=>{return z=s2(J)?J:F,this.parseAndUpdateUsage(D,u,z,C,B,$)})}else if(Y6(Z))F.getInternalMethods().getUsageInstance().freeze(),z=F.getInternalMethods().reset(E),Object.keys(u.builder).forEach((Q)=>{z.option(Q,Z[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 a($)?$.then((G)=>({aliases:F.parsed.aliases,innerArgv:G})):{aliases:F.parsed.aliases,innerArgv:$}}shouldUpdateUsage(D){return!D.getInternalMethods().getUsageInstance().getUsageDisabled()&&D.getInternalMethods().getUsageInstance().getUsage().length===0}usageFromParentCommandsCommandHandler(D,u){let F=Uu.test(u.original)?u.original.replace(Uu,"").trim():u.original,E=D.filter((C)=>{return!Uu.test(C)});return E.push(F),`$0 ${E.join(" ")}`}handleValidationAndGetResult(D,u,F,E,C,B,$,G){if(!B.getInternalMethods().getHasOutput()){let Z=B.getInternalMethods().runValidation(C,G,B.parsed.error,D);F=Du(F,(z)=>{return Z(z),z})}if(u.handler&&!B.getInternalMethods().getHasOutput()){B.getInternalMethods().setHasOutput();let Z=!!B.getOptions().configuration["populate--"];if(B.getInternalMethods().postProcess(F,Z,!1,!1),F=eD(F,B,$,!1),F=Du(F,(z)=>{let Q=u.handler(z);return a(Q)?Q.then(()=>z):z}),!D)B.getInternalMethods().getUsageInstance().cacheHelpMessage();if(a(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 G={};if(C)return F;if(!$.getInternalMethods().getHasOutput())G=this.populatePositionals(u,F,E,$);let Z=this.globalMiddleware.getMiddleware().slice(0).concat(u.middlewares),z=eD(F,$,Z,!0);return a(z)?z.then((Q)=>this.handleValidationAndGetResult(D,u,Q,E,B,$,Z,G)):this.handleValidationAndGetResult(D,u,z,E,B,$,Z,G)}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 G=C.shift();this.populatePositional(G,u,$)}while(B.length){let G=B.shift();this.populatePositional(G,u,$)}return u._=F.commands.concat(u._.map((G)=>""+G)),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=cD(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((z)=>{if(C.configuration["unknown-options-as-args"])C.key[Z]=!0;B.push(`--${Z}`),B.push(z)})}),!B.length)return;let $=Object.assign({},C.configuration,{"populate--":!1}),G=this.shim.Parser.detailed(B,Object.assign({},C,{configuration:$}));if(G.error)E.getInternalMethods().getUsageInstance().fail(G.error.message,G.error);else{let Z=Object.keys(u);Object.keys(u).forEach((z)=>{Z.push(...G.aliases[z])}),Object.keys(G.argv).forEach((z)=>{if(Z.includes(z)){if(!u[z])u[z]=G.argv[z];if(!this.isInConfigs(E,z)&&!this.isDefaulted(E,z)&&Object.prototype.hasOwnProperty.call(D,z)&&Object.prototype.hasOwnProperty.call(G.argv,z)&&(Array.isArray(D[z])||Array.isArray(G.argv[z])))D[z]=[].concat(D[z],G.argv[z]);else D[z]=G.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=Uu.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(au(u))return u(D,!0);else if(!l2(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;WD(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();WD(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 o2(D,u,F,E){return new t2(D,u,F,E)}function l2(D){return typeof D==="object"&&!!D.builder&&typeof D.handler==="function"}function Q6(D){return D.every((u)=>typeof u==="string")}function au(D){return typeof D==="function"}function Y6(D){return typeof D==="object"}function W6(D){return typeof D==="object"&&!Array.isArray(D)}function gD(D={},u=()=>!0){let F={};return Ku(D).forEach((E)=>{if(u(E,D[E]))F[E]=D[E]}),F}function kD(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 O6(D){return typeof D==="boolean"}function a2(D,u){let F=u.y18n.__,E={},C=[];E.failFn=function(T){C.push(T)};let B=null,$=null,G=!0;E.showHelpOnFail=function(T=!0,I){let[m,l]=typeof T==="string"?[!0,T]:[T,I];if(D.getInternalMethods().isGlobalContext())$=l;return B=l,G=m,E};let Z=!1;E.fail=function(T,I){let m=D.getInternalMethods().getLoggerInstance();if(C.length)for(let l=C.length-1;l>=0;--l){let BD=C[l];if(O6(BD)){if(I)throw I;else if(T)throw Error(T)}else BD(T,I,E)}else{if(D.getExitProcess())kD(!0);if(!Z){if(Z=!0,G)D.showHelp("error"),m.error();if(T||I)m.error(T||I);let l=B||$;if(l){if(T||I)m.error("");m.error(l)}}if(I=I||new FD(T),D.getExitProcess())return D.exit(1);else if(D.getInternalMethods().hasParseCallback())return D.exit(1,I);else throw I}};let z=[],Q=!1;E.usage=(x,T)=>{if(x===null)return Q=!0,z=[],E;return Q=!1,z.push([x,T||""]),E},E.getUsage=()=>{return z},E.getUsageDisabled=()=>{return Q},E.getPositionalGroupName=()=>{return F("Positionals:")};let J=[];E.example=(x,T)=>{J.push([x,T||""])};let Y=[];E.command=function(T,I,m,l,BD=!1){if(m)Y=Y.map((i)=>{return i[2]=!1,i});Y.push([T,I||"",m,l,BD])},E.getCommands=()=>Y;let O={};E.describe=function(T,I){if(Array.isArray(T))T.forEach((m)=>{E.describe(m,I)});else if(typeof T==="object")Object.keys(T).forEach((m)=>{E.describe(m,T[m])});else O[T]=I},E.getDescriptions=()=>O;let V=[];E.epilog=(x)=>{V.push(x)};let W=!1,U;E.wrap=(x)=>{W=!0,U=x},E.getWrap=()=>{if(u.getEnv("YARGS_DISABLE_WRAP"))return null;if(!W)U=jD(),W=!0;return U};let _="__yargsString__:";E.deferY18nLookup=(x)=>_+x,E.help=function(){if(A)return A;N();let T=D.customScriptName?D.$0:u.path.basename(D.$0),I=D.getDemandedOptions(),m=D.getDemandedCommands(),l=D.getDeprecatedOptions(),BD=D.getGroups(),i=D.getOptions(),$D=[];$D=$D.concat(Object.keys(O)),$D=$D.concat(Object.keys(I)),$D=$D.concat(Object.keys(m)),$D=$D.concat(Object.keys(i.default)),$D=$D.filter(d),$D=Object.keys($D.reduce((p,t)=>{if(t!=="_")p[t]=!0;return p},{}));let mD=E.getWrap(),s=u.cliui({width:mD,wrap:!!mD});if(!Q){if(z.length)z.forEach((p)=>{if(s.div({text:`${p[0].replace(/\$0/g,T)}`}),p[1])s.div({text:`${p[1]}`,padding:[1,0,0,0]})}),s.div();else if(Y.length){let p=null;if(m._)p=`${T} <${F("command")}>
15
+ `;else p=`${T} [${F("command")}]
16
+ `;s.div(`${p}`)}}if(Y.length>1||Y.length===1&&!Y[0][2]){s.div(F("Commands:"));let p=D.getInternalMethods().getContext(),t=p.commands.length?`${p.commands.join(" ")} `:"";if(D.getInternalMethods().getParserConfiguration()["sort-commands"]===!0)Y=Y.sort((k,QD)=>k[0].localeCompare(QD[0]));let GD=T?`${T} `:"";Y.forEach((k)=>{let QD=`${GD}${t}${k[0].replace(/^\$0 ?/,"")}`;s.span({text:QD,padding:[0,2,0,2],width:M(Y,mD,`${T}${t}`)+4},{text:k[1]});let uD=[];if(k[2])uD.push(`[${F("default")}]`);if(k[3]&&k[3].length)uD.push(`[${F("aliases:")} ${k[3].join(", ")}]`);if(k[4])if(typeof k[4]==="string")uD.push(`[${F("deprecated: %s",k[4])}]`);else uD.push(`[${F("deprecated")}]`);if(uD.length)s.div({text:uD.join(" "),padding:[0,0,0,2],align:"right"});else s.div()}),s.div()}let hD=(Object.keys(i.alias)||[]).concat(Object.keys(D.parsed.newAliases)||[]);$D=$D.filter((p)=>!D.parsed.newAliases[p]&&hD.every((t)=>(i.alias[t]||[]).indexOf(p)===-1));let Su=F("Options:");if(!BD[Su])BD[Su]=[];h($D,i.alias,BD,Su);let v=(p)=>/^--/.test(eu(p)),qu=Object.keys(BD).filter((p)=>BD[p].length>0).map((p)=>{let t=BD[p].filter(d).map((GD)=>{if(hD.includes(GD))return GD;for(let k=0,QD;(QD=hD[k])!==void 0;k++)if((i.alias[QD]||[]).includes(GD))return QD;return GD});return{groupName:p,normalizedKeys:t}}).filter(({normalizedKeys:p})=>p.length>0).map(({groupName:p,normalizedKeys:t})=>{let GD=t.reduce((k,QD)=>{return k[QD]=[QD].concat(i.alias[QD]||[]).map((uD)=>{if(p===E.getPositionalGroupName())return uD;else return(/^[0-9]$/.test(uD)?i.boolean.includes(QD)?"-":"--":uD.length>1?"--":"-")+uD}).sort((uD,zD)=>v(uD)===v(zD)?0:v(uD)?1:-1).join(", "),k},{});return{groupName:p,normalizedKeys:t,switches:GD}});if(qu.filter(({groupName:p})=>p!==E.getPositionalGroupName()).some(({normalizedKeys:p,switches:t})=>!p.every((GD)=>v(t[GD]))))qu.filter(({groupName:p})=>p!==E.getPositionalGroupName()).forEach(({normalizedKeys:p,switches:t})=>{p.forEach((GD)=>{if(v(t[GD]))t[GD]=V6(t[GD],4)})});if(qu.forEach(({groupName:p,normalizedKeys:t,switches:GD})=>{s.div(p),t.forEach((k)=>{let QD=GD[k],uD=O[k]||"",zD=null;if(uD.includes(_))uD=F(uD.substring(_.length));if(i.boolean.includes(k))zD=`[${F("boolean")}]`;if(i.count.includes(k))zD=`[${F("count")}]`;if(i.string.includes(k))zD=`[${F("string")}]`;if(i.normalize.includes(k))zD=`[${F("string")}]`;if(i.array.includes(k))zD=`[${F("array")}]`;if(i.number.includes(k))zD=`[${F("number")}]`;let RF=(L)=>typeof L==="string"?`[${F("deprecated: %s",L)}]`:`[${F("deprecated")}]`,H=[k in l?RF(l[k]):null,zD,k in I?`[${F("required")}]`:null,i.choices&&i.choices[k]?`[${F("choices:")} ${E.stringifiedValues(i.choices[k])}]`:null,o(i.default[k],i.defaultDescription[k])].filter(Boolean).join(" ");s.span({text:eu(QD),padding:[0,2,0,2+r2(QD)],width:M(GD,mD)+4},uD);let K=D.getInternalMethods().getUsageConfiguration()["hide-types"]===!0;if(H&&!K)s.div({text:H,padding:[0,0,0,2],align:"right"});else s.div()}),s.div()}),J.length)s.div(F("Examples:")),J.forEach((p)=>{p[0]=p[0].replace(/\$0/g,T)}),J.forEach((p)=>{if(p[1]==="")s.div({text:p[0],padding:[0,2,0,2]});else s.div({text:p[0],padding:[0,2,0,2],width:M(J,mD)+4},{text:p[1]})}),s.div();if(V.length>0){let p=V.map((t)=>t.replace(/\$0/g,T)).join(`
17
+ `);s.div(`${p}
18
+ `)}return s.toString().replace(/\s*$/,"")};function M(x,T,I){let m=0;if(!Array.isArray(x))x=Object.values(x).map((l)=>[l]);if(x.forEach((l)=>{m=Math.max(u.stringWidth(I?`${I} ${eu(l[0])}`:eu(l[0]))+r2(l[0]),m)}),T)m=Math.min(m,parseInt((T*0.5).toString(),10));return m}function N(){let x=D.getDemandedOptions(),T=D.getOptions();(Object.keys(T.alias)||[]).forEach((I)=>{T.alias[I].forEach((m)=>{if(O[m])E.describe(I,O[m]);if(m in x)D.demandOption(I,x[m]);if(T.boolean.includes(m))D.boolean(I);if(T.count.includes(m))D.count(I);if(T.string.includes(m))D.string(I);if(T.normalize.includes(m))D.normalize(I);if(T.array.includes(m))D.array(I);if(T.number.includes(m))D.number(I)})})}let A;E.cacheHelpMessage=function(){A=this.help()},E.clearCachedHelpMessage=function(){A=void 0},E.hasCachedHelpMessage=function(){return!!A};function h(x,T,I,m){let l=[],BD=null;return Object.keys(I).forEach((i)=>{l=l.concat(I[i])}),x.forEach((i)=>{if(BD=[i].concat(T[i]),!BD.some(($D)=>l.indexOf($D)!==-1))I[m].push(i)}),l}function d(x){return D.getOptions().hiddenOptions.indexOf(x)<0||D.parsed.argv[D.getOptions().showHiddenOpt]}E.showHelp=(x)=>{let T=D.getInternalMethods().getLoggerInstance();if(!x)x="error";(typeof x==="function"?x:T[x])(E.help())},E.functionDescription=(x)=>{return["(",x.name?u.Parser.decamelize(x.name,"-"):F("generated-value"),")"].join("")},E.stringifiedValues=function(T,I){let m="",l=I||", ",BD=[].concat(T);if(!T||!BD.length)return m;return BD.forEach((i)=>{if(m.length)m+=l;m+=JSON.stringify(i)}),m};function o(x,T){let I=`[${F("default:")} `;if(x===void 0&&!T)return null;if(T)I+=T;else switch(typeof x){case"string":I+=`"${x}"`;break;case"object":I+=JSON.stringify(x);break;default:I+=x}return`${I}]`}function jD(){if(u.process.stdColumns)return Math.min(80,u.process.stdColumns);else return 80}let n=null;E.version=(x)=>{n=x},E.showVersion=(x)=>{let T=D.getInternalMethods().getLoggerInstance();if(!x)x="error";(typeof x==="function"?x:T[x])(n)},E.reset=function(T){return B=null,Z=!1,z=[],Q=!1,V=[],J=[],Y=[],O=gD(O,(I)=>!T[I]),E};let sD=[];return E.freeze=function(){sD.push({failMessage:B,failureOutput:Z,usages:z,usageDisabled:Q,epilogs:V,examples:J,commands:Y,descriptions:O})},E.unfreeze=function(T=!1){let I=sD.pop();if(!I)return;if(T)O={...I.descriptions,...O},Y=[...I.commands,...Y],z=[...I.usages,...z],J=[...I.examples,...J],V=[...I.epilogs,...V];else({failMessage:B,failureOutput:Z,usages:z,usageDisabled:Q,epilogs:V,examples:J,commands:Y,descriptions:O}=I)},E}function lF(D){return typeof D==="object"}function V6(D,u){return lF(D)?{text:D.text,indentation:D.indentation+u}:{text:D,indentation:u}}function r2(D){return lF(D)?D.indentation:0}function eu(D){return lF(D)?D.text:D}var e2=`###-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
- `,t2=`#compdef {{app_name}}
47
+ `,D8=`#compdef {{app_name}}
48
48
  ###-begin-{{app_name}}-completions-###
49
49
  #
50
50
  # yargs command completion script
@@ -71,96 +71,96 @@ else
71
71
  compdef _{{app_name}}_yargs_completions {{app_name}}
72
72
  fi
73
73
  ###-end-{{app_name}}-completions-###
74
- `;class o2{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,G=D.length;$<G;++$)if(C[D[$]]&&C[D[$]].builder){let z=C[D[$]].builder;if(su(z)){this.indexAfterLastReset=$+1;let Z=this.yargs.getInternalMethods().reset();return z(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=cD(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 G=!!C.configuration["boolean-negation"]&&C.boolean.includes($);if(!B.includes($)&&!C.hiddenOptions.includes($)&&!this.argsContainKey(u,$,G))this.completeOptionKey($,D,E,G&&!!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 G=this.yargs.getOptions().choices[$]||[];for(let z of G)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 G of B)if(Object.prototype.hasOwnProperty.call(C.key,G)&&Array.isArray(C.choices[G])){$=C.choices[G];break}if($)return $.filter((G)=>!F||G.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,$,G;let z=D;if(this.zshShell){let Q=this.usage.getDescriptions(),O=(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((M)=>{let _=Q[M];return typeof _==="string"&&_.length>0}),V=O?Q[O]:void 0,W=(G=($=Q[D])!==null&&$!==void 0?$:V)!==null&&G!==void 0?G:"";z=`${D.replace(/:/g,"\\:")}:${W.replace("__yargsString__:","").replace(/(\r\n|\n|\r)/gm," ")}`}let Z=(Q)=>/^--/.test(Q),Y=(Q)=>/^[^0-9]$/.test(Q),J=!Z(F)&&Y(D)?"-":"--";if(u.push(J+z),E)u.push(J+"no-"+z)}customCompletion(D,u,F,E){if(WD(this.customCompletionFunction,null,this.shim),Y6(this.customCompletionFunction)){let C=this.customCompletionFunction(F,u);if(s(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(W6(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 s(E)?E.then(C):C(E)}generateCompletionScript(D,u){let F=this.zshShell?t2:l2,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 s2(D,u,F,E){return new o2(D,u,F,E)}function Y6(D){return D.length<3}function W6(D){return D.length>3}function r2(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 a2=["$0","--","_"];function e2(D,u,F){let E=F.y18n.__,C=F.y18n.__n,B={};B.nonOptionCount=function(J){let Q=D.getDemandedCommands(),V=J._.length+(J["--"]?J["--"].length:0)-D.getInternalMethods().getContext().commands.length;if(Q._&&(V<Q._.min||V>Q._.max)){if(V<Q._.min)if(Q._.minMsg!==void 0)u.fail(Q._.minMsg?Q._.minMsg.replace(/\$0/g,V.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",V,V.toString(),Q._.min.toString()));else if(V>Q._.max)if(Q._.maxMsg!==void 0)u.fail(Q._.maxMsg?Q._.maxMsg.replace(/\$0/g,V.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",V,V.toString(),Q._.max.toString()))}},B.positionalCount=function(J,Q){if(Q<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",Q,Q+"",J+""))},B.requiredArguments=function(J,Q){let O=null;for(let V of Object.keys(Q))if(!Object.prototype.hasOwnProperty.call(J,V)||typeof J[V]>"u")O=O||{},O[V]=Q[V];if(O){let V=[];for(let M of Object.keys(O)){let _=O[M];if(_&&V.indexOf(_)<0)V.push(_)}let W=V.length?`
74
+ `;class u8{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,G=D.length;$<G;++$)if(C[D[$]]&&C[D[$]].builder){let Z=C[D[$]].builder;if(au(Z)){this.indexAfterLastReset=$+1;let z=this.yargs.getInternalMethods().reset();return Z(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=cD(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 G=!!C.configuration["boolean-negation"]&&C.boolean.includes($);if(!B.includes($)&&!C.hiddenOptions.includes($)&&!this.argsContainKey(u,$,G))this.completeOptionKey($,D,E,G&&!!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 G=this.yargs.getOptions().choices[$]||[];for(let Z of G)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 G of B)if(Object.prototype.hasOwnProperty.call(C.key,G)&&Array.isArray(C.choices[G])){$=C.choices[G];break}if($)return $.filter((G)=>!F||G.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,$,G;let Z=D;if(this.zshShell){let Y=this.usage.getDescriptions(),O=(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((U)=>{let _=Y[U];return typeof _==="string"&&_.length>0}),V=O?Y[O]:void 0,W=(G=($=Y[D])!==null&&$!==void 0?$:V)!==null&&G!==void 0?G:"";Z=`${D.replace(/:/g,"\\:")}:${W.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+Z),E)u.push(J+"no-"+Z)}customCompletion(D,u,F,E){if(WD(this.customCompletionFunction,null,this.shim),q6(this.customCompletionFunction)){let C=this.customCompletionFunction(F,u);if(a(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(K6(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 a(E)?E.then(C):C(E)}generateCompletionScript(D,u){let F=this.zshShell?D8:e2,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 F8(D,u,F,E){return new u8(D,u,F,E)}function q6(D){return D.length<3}function K6(D){return D.length>3}function E8(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 C8=["$0","--","_"];function B8(D,u,F){let E=F.y18n.__,C=F.y18n.__n,B={};B.nonOptionCount=function(J){let Y=D.getDemandedCommands(),V=J._.length+(J["--"]?J["--"].length:0)-D.getInternalMethods().getContext().commands.length;if(Y._&&(V<Y._.min||V>Y._.max)){if(V<Y._.min)if(Y._.minMsg!==void 0)u.fail(Y._.minMsg?Y._.minMsg.replace(/\$0/g,V.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",V,V.toString(),Y._.min.toString()));else if(V>Y._.max)if(Y._.maxMsg!==void 0)u.fail(Y._.maxMsg?Y._.maxMsg.replace(/\$0/g,V.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",V,V.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 O=null;for(let V of Object.keys(Y))if(!Object.prototype.hasOwnProperty.call(J,V)||typeof J[V]>"u")O=O||{},O[V]=Y[V];if(O){let V=[];for(let U of Object.keys(O)){let _=O[U];if(_&&V.indexOf(_)<0)V.push(_)}let W=V.length?`
75
75
  ${V.join(`
76
- `)}`:"";u.fail(C("Missing required argument: %s","Missing required arguments: %s",Object.keys(O).length,Object.keys(O).join(", ")+W))}},B.unknownArguments=function(J,Q,O,V,W=!0){var M;let _=D.getInternalMethods().getCommandInstance().getCommands(),N=[],k=D.getInternalMethods().getContext();if(Object.keys(J).forEach((w)=>{if(!a2.includes(w)&&!Object.prototype.hasOwnProperty.call(O,w)&&!Object.prototype.hasOwnProperty.call(D.getInternalMethods().getParseContext(),w)&&!B.isValidAndSomeAliasIsNotNew(w,Q))N.push(w)}),W&&(k.commands.length>0||_.length>0||V))J._.slice(k.commands.length).forEach((w)=>{if(!_.includes(""+w))N.push(""+w)});if(W){let c=((M=D.getDemandedCommands()._)===null||M===void 0?void 0:M.max)||0,e=k.commands.length+c;if(e<J._.length)J._.slice(e).forEach((r)=>{if(r=String(r),!k.commands.includes(r)&&!N.includes(r))N.push(r)})}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 Q=D.getInternalMethods().getCommandInstance().getCommands(),O=[],V=D.getInternalMethods().getContext();if(V.commands.length>0||Q.length>0)J._.slice(V.commands.length).forEach((W)=>{if(!Q.includes(""+W))O.push(""+W)});if(O.length>0)return u.fail(C("Unknown command: %s","Unknown commands: %s",O.length,O.join(", "))),!0;else return!1},B.isValidAndSomeAliasIsNotNew=function(J,Q){if(!Object.prototype.hasOwnProperty.call(Q,J))return!1;let O=D.parsed.newAliases;return[J,...Q[J]].some((V)=>!Object.prototype.hasOwnProperty.call(O,V)||!O[J])},B.limitedChoices=function(J){let Q=D.getOptions(),O={};if(!Object.keys(Q.choices).length)return;Object.keys(J).forEach((M)=>{if(a2.indexOf(M)===-1&&Object.prototype.hasOwnProperty.call(Q.choices,M))[].concat(J[M]).forEach((_)=>{if(Q.choices[M].indexOf(_)===-1&&_!==void 0)O[M]=(O[M]||[]).concat(_)})});let V=Object.keys(O);if(!V.length)return;let W=E("Invalid values:");V.forEach((M)=>{W+=`
77
- ${E("Argument: %s, Given: %s, Choices: %s",M,u.stringifiedValues(O[M]),u.stringifiedValues(Q.choices[M]))}`}),u.fail(W)};let $={};B.implies=function(J,Q){if(T("<string|object> [array|number|string]",[J,Q],arguments.length),typeof J==="object")Object.keys(J).forEach((O)=>{B.implies(O,J[O])});else{if(D.global(J),!$[J])$[J]=[];if(Array.isArray(Q))Q.forEach((O)=>B.implies(J,O));else WD(Q,void 0,F),$[J].push(Q)}},B.getImplied=function(){return $};function G(Y,J){let Q=Number(J);if(J=isNaN(Q)?J:Q,typeof J==="number")J=Y._.length>=J;else if(J.match(/^--no-.+/))J=J.match(/^--no-(.+)/)[1],J=!Object.prototype.hasOwnProperty.call(Y,J);else J=Object.prototype.hasOwnProperty.call(Y,J);return J}B.implications=function(J){let Q=[];if(Object.keys($).forEach((O)=>{let V=O;($[O]||[]).forEach((W)=>{let M=V,_=W;if(M=G(J,M),W=G(J,W),M&&!W)Q.push(` ${V} -> ${_}`)})}),Q.length){let O=`${E("Implications failed:")}
78
- `;Q.forEach((V)=>{O+=V}),u.fail(O)}};let z={};B.conflicts=function(J,Q){if(T("<string|object> [array|string]",[J,Q],arguments.length),typeof J==="object")Object.keys(J).forEach((O)=>{B.conflicts(O,J[O])});else{if(D.global(J),!z[J])z[J]=[];if(Array.isArray(Q))Q.forEach((O)=>B.conflicts(J,O));else z[J].push(Q)}},B.getConflicting=()=>z,B.conflicting=function(J){if(Object.keys(J).forEach((Q)=>{if(z[Q])z[Q].forEach((O)=>{if(O&&J[Q]!==void 0&&J[O]!==void 0)u.fail(E("Arguments %s and %s are mutually exclusive",Q,O))})}),D.getInternalMethods().getParserConfiguration()["strip-dashed"])Object.keys(z).forEach((Q)=>{z[Q].forEach((O)=>{if(O&&J[F.Parser.camelCase(Q)]!==void 0&&J[F.Parser.camelCase(O)]!==void 0)u.fail(E("Arguments %s and %s are mutually exclusive",Q,O))})})},B.recommendCommands=function(J,Q){Q=Q.sort((M,_)=>_.length-M.length);let V=null,W=1/0;for(let M=0,_;(_=Q[M])!==void 0;M++){let N=r2(J,_);if(N<=3&&N<W)W=N,V=_}if(V)u.fail(E("Did you mean %s?",V))},B.reset=function(J){return $=gD($,(Q)=>!J[Q]),z=gD(z,(Q)=>!J[Q]),B};let Z=[];return B.freeze=function(){Z.push({implied:$,conflicting:z})},B.unfreeze=function(){let J=Z.pop();WD(J,void 0,F),{implied:$,conflicting:z}=J},B}var lF=[],Ru;function Su(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(G){return D}else $=V6(u,D.extends);O6($),lF.push($),C=B?JSON.parse(Ru.readFileSync($,"utf8")):E.require(D.extends),delete D.extends,C=Su(C,Ru.path.dirname($),F,Ru)}return lF=[],F?D8(C,D):Object.assign({},C,D)}function O6(D){if(lF.indexOf(D)>-1)throw new FD(`Circular extended configurations: '${D}'.`)}function V6(D,u){return Ru.path.resolve(D,u)}function D8(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]=D8(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},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,Du,Pu,VD,qD,au,dD,uu,eu,AD,DF,LD,xD,UD,ND,uF,Fu,XD,I,FF,EF,MD,Eu,Mu,Cu,iD,CF,v,Bu,$u,Gu,y,BF,ID,DD;function M8(D){return(u=[],F=D.process.cwd(),E)=>{let C=new K8(u,F,E,D);return Object.defineProperty(C,"argv",{get:()=>{return C.parse()},enumerable:!0}),C.help(),C.version(),C}}var u8=Symbol("copyDoubleDash"),F8=Symbol("copyDoubleDash"),tF=Symbol("deleteFromParserHintObject"),E8=Symbol("emitWarning"),C8=Symbol("freeze"),B8=Symbol("getDollarZero"),zu=Symbol("getParserConfiguration"),$8=Symbol("getUsageConfiguration"),oF=Symbol("guessLocale"),G8=Symbol("guessVersion"),z8=Symbol("parsePositionalNumbers"),sF=Symbol("pkgUp"),nD=Symbol("populateParserHintArray"),Ku=Symbol("populateParserHintSingleValueDictionary"),rF=Symbol("populateParserHintArrayDictionary"),aF=Symbol("populateParserHintDictionary"),eF=Symbol("sanitizeKey"),D0=Symbol("setKey"),u0=Symbol("unfreeze"),Z8=Symbol("validateAsync"),J8=Symbol("getCommandInstance"),X8=Symbol("getContext"),Q8=Symbol("getHasOutput"),Y8=Symbol("getLoggerInstance"),W8=Symbol("getParseContext"),O8=Symbol("getUsageInstance"),V8=Symbol("getValidationInstance"),$F=Symbol("hasParseCallback"),H8=Symbol("isGlobalContext"),Zu=Symbol("postProcess"),q8=Symbol("rebase"),F0=Symbol("reset"),wu=Symbol("runYargsParserAndExecuteCommands"),E0=Symbol("runValidation"),U8=Symbol("setHasOutput"),Ju=Symbol("kTrackManuallySetKeys"),H6="en_US";class K8{constructor(D=[],u,F,E){this.customScriptName=!1,this.parsed=!1,ED.set(this,void 0),Du.set(this,void 0),Pu.set(this,{commands:[],fullCommands:[]}),VD.set(this,null),qD.set(this,null),au.set(this,"show-hidden"),dD.set(this,null),uu.set(this,!0),eu.set(this,{}),AD.set(this,!0),DF.set(this,[]),LD.set(this,void 0),xD.set(this,{}),UD.set(this,!1),ND.set(this,null),uF.set(this,!0),Fu.set(this,void 0),XD.set(this,""),I.set(this,void 0),FF.set(this,void 0),EF.set(this,{}),MD.set(this,null),Eu.set(this,null),Mu.set(this,{}),Cu.set(this,{}),iD.set(this,void 0),CF.set(this,!1),v.set(this,void 0),Bu.set(this,!1),$u.set(this,!1),Gu.set(this,!1),y.set(this,void 0),BF.set(this,{}),ID.set(this,null),DD.set(this,void 0),R(this,v,E,"f"),R(this,iD,D,"f"),R(this,Du,u,"f"),R(this,FF,F,"f"),R(this,LD,new iF(this),"f"),this.$0=this[B8](),this[F0](),R(this,ED,X(this,ED,"f"),"f"),R(this,y,X(this,y,"f"),"f"),R(this,DD,X(this,DD,"f"),"f"),R(this,I,X(this,I,"f"),"f"),X(this,I,"f").showHiddenOpt=X(this,au,"f"),R(this,Fu,this[F8](),"f"),X(this,v,"f").y18n.setLocale(H6)}addHelpOpt(D,u){if(T("[string|boolean] [string]",[D,u],arguments.length),X(this,ND,"f"))this[tF](X(this,ND,"f")),R(this,ND,null,"f");if(D===!1&&u===void 0)return this;return R(this,ND,typeof D==="string"?D:"help","f"),this.boolean(X(this,ND,"f")),this.describe(X(this,ND,"f"),u||X(this,y,"f").deferY18nLookup("Show help")),this}help(D,u){return this.addHelpOpt(D,u)}addShowHiddenOpt(D,u){if(T("[string|boolean] [string]",[D,u],arguments.length),D===!1&&u===void 0)return this;let F=typeof D==="string"?D:X(this,au,"f");return this.boolean(F),this.describe(F,u||X(this,y,"f").deferY18nLookup("Show hidden options")),X(this,I,"f").showHiddenOpt=F,this}showHidden(D,u){return this.addShowHiddenOpt(D,u)}alias(D,u){return T("<object|string|array> [string|array]",[D,u],arguments.length),this[rF](this.alias.bind(this),"alias",D,u),this}array(D){return T("<array|string>",[D],arguments.length),this[nD]("array",D),this[Ju](D),this}boolean(D){return T("<array|string>",[D],arguments.length),this[nD]("boolean",D),this[Ju](D),this}check(D,u){return T("<function> [boolean]",[D,u],arguments.length),this.middleware((F,E)=>{return eD(()=>{return D(F,E.getOptions())},(C)=>{if(!C)X(this,y,"f").fail(X(this,v,"f").y18n.__("Argument check failed: %s",D.toString()));else if(typeof C==="string"||C instanceof Error)X(this,y,"f").fail(C.toString(),C);return F},(C)=>{return X(this,y,"f").fail(C.message?C.message:C.toString(),C),F})},!1,u),this}choices(D,u){return T("<object|string|array> [string|array]",[D,u],arguments.length),this[rF](this.choices.bind(this),"choices",D,u),this}coerce(D,u){if(T("<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,LD,"f").addCoerceMiddleware((E,C)=>{var B;let $=(B=C.getAliases()[F])!==null&&B!==void 0?B:[],G=[F,...$].filter((z)=>Object.prototype.hasOwnProperty.call(E,z));if(G.length===0)return E;return eD(()=>{return u(E[G[0]])},(z)=>{return G.forEach((Z)=>{E[Z]=z}),E},(z)=>{throw new FD(z.message)})},F),this}conflicts(D,u){return T("<string|object> [string|array]",[D,u],arguments.length),X(this,DD,"f").conflicts(D,u),this}config(D="config",u,F){if(T("[object|string] [string|function] [function]",[D,u,F],arguments.length),typeof D==="object"&&!Array.isArray(D))return D=Su(D,X(this,Du,"f"),this[zu]()["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,y,"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(T("[string] [string|boolean|function] [function]",[D,u,F],arguments.length),typeof u==="function")F=u,u=void 0;if(R(this,qD,D||X(this,qD,"f")||"completion","f"),!u&&u!==!1)u="generate completion script";if(this.command(X(this,qD,"f"),u),F)X(this,VD,"f").registerFunction(F);return this}command(D,u,F,E,C,B){return T("<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){T("<string> [object]",[D,u],arguments.length);let F=X(this,FF,"f")||X(this,v,"f").require;return X(this,ED,"f").addDirectory(D,F,X(this,v,"f").getCallerFile(),u),this}count(D){return T("<array|string>",[D],arguments.length),this[nD]("count",D),this[Ju](D),this}default(D,u,F){if(T("<object|string|array> [*] [string]",[D,u,F],arguments.length),F)dF(D,X(this,v,"f")),X(this,I,"f").defaultDescription[D]=F;if(typeof u==="function"){if(dF(D,X(this,v,"f")),!X(this,I,"f").defaultDescription[D])X(this,I,"f").defaultDescription[D]=X(this,y,"f").functionDescription(u);u=u.call()}return this[Ku](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(T("[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)=>{WD(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")WD(F,!0,X(this,v,"f")),this.demandCommand(D,u,F,F);else if(Array.isArray(D))D.forEach((E)=>{WD(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 T("<object|string|array> [string]",[D,u],arguments.length),this[Ku](this.demandOption.bind(this),"demandedOptions",D,u),this}deprecateOption(D,u){return T("<string> [string|boolean]",[D,u],arguments.length),X(this,I,"f").deprecatedOptions[D]=u,this}describe(D,u){return T("<object|string|array> [string]",[D,u],arguments.length),this[D0](D,!0),X(this,y,"f").describe(D,u),this}detectLocale(D){return T("<boolean>",[D],arguments.length),R(this,uu,D,"f"),this}env(D){if(T("[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 T("<string>",[D],arguments.length),X(this,y,"f").epilog(D),this}epilog(D){return this.epilogue(D)}example(D,u){if(T("<string|array> [string]",[D,u],arguments.length),Array.isArray(D))D.forEach((F)=>this.example(...F));else X(this,y,"f").example(D,u);return this}exit(D,u){if(R(this,UD,!0,"f"),R(this,dD,u,"f"),X(this,AD,"f"))X(this,v,"f").process.exit(D)}exitProcess(D=!0){return T("[boolean]",[D],arguments.length),R(this,AD,D,"f"),this}fail(D){if(T("<function|boolean>",[D],arguments.length),typeof D==="boolean"&&D!==!1)throw new FD("Invalid first argument. Expected function or boolean 'false'");return X(this,y,"f").failFn(D),this}getAliases(){return this.parsed?this.parsed.aliases:{}}async getCompletion(D,u){if(T("<array> [function]",[D,u],arguments.length),!u)return new Promise((F,E)=>{X(this,VD,"f").getCompletion(D,(C,B)=>{if(C)E(C);else F(B)})});else return X(this,VD,"f").getCompletion(D,u)}getDemandedOptions(){return T([],0),X(this,I,"f").demandedOptions}getDemandedCommands(){return T([],0),X(this,I,"f").demandedCommands}getDeprecatedOptions(){return T([],0),X(this,I,"f").deprecatedOptions}getDetectLocale(){return X(this,uu,"f")}getExitProcess(){return X(this,AD,"f")}getGroups(){return Object.assign({},X(this,xD,"f"),X(this,Cu,"f"))}getHelp(){if(R(this,UD,!0,"f"),!X(this,y,"f").hasCachedHelpMessage()){if(!this.parsed){let u=this[wu](X(this,iD,"f"),void 0,void 0,0,!0);if(s(u))return u.then(()=>{return X(this,y,"f").help()})}let D=X(this,ED,"f").runDefaultBuilderOn(this);if(s(D))return D.then(()=>{return X(this,y,"f").help()})}return Promise.resolve(X(this,y,"f").help())}getOptions(){return X(this,I,"f")}getStrict(){return X(this,Bu,"f")}getStrictCommands(){return X(this,$u,"f")}getStrictOptions(){return X(this,Gu,"f")}global(D,u){if(T("<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){T("<string|array> <string>",[D,u],arguments.length);let F=X(this,Cu,"f")[u]||X(this,xD,"f")[u];if(X(this,Cu,"f")[u])delete X(this,Cu,"f")[u];let E={};return X(this,xD,"f")[u]=(F||[]).concat(D).filter((C)=>{if(E[C])return!1;return E[C]=!0}),this}hide(D){return T("<string>",[D],arguments.length),X(this,I,"f").hiddenOptions.push(D),this}implies(D,u){return T("<string|object> [number|string|array]",[D,u],arguments.length),X(this,DD,"f").implies(D,u),this}locale(D){if(T("[string]",[D],arguments.length),D===void 0)return this[oF](),X(this,v,"f").y18n.getLocale();return R(this,uu,!1,"f"),X(this,v,"f").y18n.setLocale(D),this}middleware(D,u,F){return X(this,LD,"f").addMiddleware(D,!!u,F)}nargs(D,u){return T("<string|object|array> [number]",[D,u],arguments.length),this[Ku](this.nargs.bind(this),"narg",D,u),this}normalize(D){return T("<array|string>",[D],arguments.length),this[nD]("normalize",D),this}number(D){return T("<array|string>",[D],arguments.length),this[nD]("number",D),this[Ju](D),this}option(D,u){if(T("<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[Ju](D),X(this,ID,"f")&&(D==="version"||(u===null||u===void 0?void 0:u.alias)==="version"))this[E8](['"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,y,"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(T("[string|array] [function|boolean|object] [function]",[D,u,F],arguments.length),this[C8](),typeof D>"u")D=X(this,iD,"f");if(typeof u==="object")R(this,Eu,u,"f"),u=F;if(typeof u==="function")R(this,MD,u,"f"),u=!1;if(!u)R(this,iD,D,"f");if(X(this,MD,"f"))R(this,AD,!1,"f");let E=this[wu](D,!!u),C=this.parsed;if(X(this,VD,"f").setParsed(this.parsed),s(E))return E.then((B)=>{if(X(this,MD,"f"))X(this,MD,"f").call(this,X(this,dD,"f"),B,X(this,XD,"f"));return B}).catch((B)=>{if(X(this,MD,"f"))X(this,MD,"f")(B,this.parsed.argv,X(this,XD,"f"));throw B}).finally(()=>{this[u0](),this.parsed=C});else{if(X(this,MD,"f"))X(this,MD,"f").call(this,X(this,dD,"f"),E,X(this,XD,"f"));this[u0](),this.parsed=C}return E}parseAsync(D,u,F){let E=this.parse(D,u,F);return!s(E)?Promise.resolve(E):E}parseSync(D,u,F){let E=this.parse(D,u,F);if(s(E))throw new FD(".parseSync() must not be used with asynchronous builders, handlers, or middleware");return E}parserConfiguration(D){return T("<object>",[D],arguments.length),R(this,EF,D,"f"),this}pkgConf(D,u){T("<string> [string]",[D,u],arguments.length);let F=null,E=this[sF](u||X(this,Du,"f"));if(E[D]&&typeof E[D]==="object")F=Su(E[D],u||X(this,Du,"f"),this[zu]()["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){T("<string> <object>",[D,u],arguments.length);let F=["default","defaultDescription","implies","normalize","choices","conflicts","coerce","type","describe","desc","description","alias"];u=gD(u,(B,$)=>{if(B==="type"&&!["string","number","boolean"].includes($))return!1;return F.includes(B)});let E=X(this,Pu,"f").fullCommands[X(this,Pu,"f").fullCommands.length-1],C=E?X(this,ED,"f").cmdToParseOptions(E):{array:[],alias:{},default:{},demand:{}};return qu(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,y,"f").getPositionalGroupName()),this.option(D,u)}recommendCommands(D=!0){return T("[boolean]",[D],arguments.length),R(this,CF,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(T("<array|string|object> [number]",[D],arguments.length),typeof D==="string"&&X(this,I,"f").narg[D])return this;else this[Ku](this.requiresArg.bind(this),"narg",D,NaN);return this}showCompletionScript(D,u){return T("[string] [string]",[D,u],arguments.length),D=D||this.$0,X(this,Fu,"f").log(X(this,VD,"f").generateCompletionScript(D,u||X(this,qD,"f")||"completion")),this}showHelp(D){if(T("[string|function]",[D],arguments.length),R(this,UD,!0,"f"),!X(this,y,"f").hasCachedHelpMessage()){if(!this.parsed){let F=this[wu](X(this,iD,"f"),void 0,void 0,0,!0);if(s(F))return F.then(()=>{X(this,y,"f").showHelp(D)}),this}let u=X(this,ED,"f").runDefaultBuilderOn(this);if(s(u))return u.then(()=>{X(this,y,"f").showHelp(D)}),this}return X(this,y,"f").showHelp(D),this}scriptName(D){return this.customScriptName=!0,this.$0=D,this}showHelpOnFail(D,u){return T("[boolean|string] [string]",[D,u],arguments.length),X(this,y,"f").showHelpOnFail(D,u),this}showVersion(D){return T("[string|function]",[D],arguments.length),X(this,y,"f").showVersion(D),this}skipValidation(D){return T("<array|string>",[D],arguments.length),this[nD]("skipValidation",D),this}strict(D){return T("[boolean]",[D],arguments.length),R(this,Bu,D!==!1,"f"),this}strictCommands(D){return T("[boolean]",[D],arguments.length),R(this,$u,D!==!1,"f"),this}strictOptions(D){return T("[boolean]",[D],arguments.length),R(this,Gu,D!==!1,"f"),this}string(D){return T("<array|string>",[D],arguments.length),this[nD]("string",D),this[Ju](D),this}terminalWidth(){return T([],0),X(this,v,"f").process.stdColumns}updateLocale(D){return this.updateStrings(D)}updateStrings(D){return T("<object>",[D],arguments.length),R(this,uu,!1,"f"),X(this,v,"f").y18n.updateLocale(D),this}usage(D,u,F,E){if(T("<string|null|undefined> [string|boolean] [function|object] [function]",[D,u,F,E],arguments.length),u!==void 0)if(WD(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,y,"f").usage(D),this}usageConfiguration(D){return T("<object>",[D],arguments.length),R(this,BF,D,"f"),this}version(D,u,F){if(T("[boolean|string] [string] [string]",[D,u,F],arguments.length),X(this,ID,"f"))this[tF](X(this,ID,"f")),X(this,y,"f").version(void 0),R(this,ID,null,"f");if(arguments.length===0)F=this[G8](),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,ID,typeof D==="string"?D:"version","f"),u=u||X(this,y,"f").deferY18nLookup("Show version number"),X(this,y,"f").version(F||void 0),this.boolean(X(this,ID,"f")),this.describe(X(this,ID,"f"),u),this}wrap(D){return T("<number|null|undefined>",[D],arguments.length),X(this,y,"f").wrap(D),this}[(ED=new WeakMap,Du=new WeakMap,Pu=new WeakMap,VD=new WeakMap,qD=new WeakMap,au=new WeakMap,dD=new WeakMap,uu=new WeakMap,eu=new WeakMap,AD=new WeakMap,DF=new WeakMap,LD=new WeakMap,xD=new WeakMap,UD=new WeakMap,ND=new WeakMap,uF=new WeakMap,Fu=new WeakMap,XD=new WeakMap,I=new WeakMap,FF=new WeakMap,EF=new WeakMap,MD=new WeakMap,Eu=new WeakMap,Mu=new WeakMap,Cu=new WeakMap,iD=new WeakMap,CF=new WeakMap,v=new WeakMap,Bu=new WeakMap,$u=new WeakMap,Gu=new WeakMap,y=new WeakMap,BF=new WeakMap,ID=new WeakMap,DD=new WeakMap,u8)](D){if(!D._||!D["--"])return D;D._.push.apply(D._,D["--"]);try{delete D["--"]}catch(u){}return D}[F8](){return{log:(...D)=>{if(!this[$F]())console.log(...D);if(R(this,UD,!0,"f"),X(this,XD,"f").length)R(this,XD,X(this,XD,"f")+`
80
- `,"f");R(this,XD,X(this,XD,"f")+D.join(" "),"f")},error:(...D)=>{if(!this[$F]())console.error(...D);if(R(this,UD,!0,"f"),X(this,XD,"f").length)R(this,XD,X(this,XD,"f")+`
81
- `,"f");R(this,XD,X(this,XD,"f")+D.join(" "),"f")}}}[tF](D){qu(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,y,"f").getDescriptions()[D]}[E8](D,u,F){if(!X(this,eu,"f")[F])X(this,v,"f").process.emitWarning(D,u),X(this,eu,"f")[F]=!0}[C8](){X(this,DF,"f").push({options:X(this,I,"f"),configObjects:X(this,I,"f").configObjects.slice(0),exitProcess:X(this,AD,"f"),groups:X(this,xD,"f"),strict:X(this,Bu,"f"),strictCommands:X(this,$u,"f"),strictOptions:X(this,Gu,"f"),completionCommand:X(this,qD,"f"),output:X(this,XD,"f"),exitError:X(this,dD,"f"),hasOutput:X(this,UD,"f"),parsed:this.parsed,parseFn:X(this,MD,"f"),parseContext:X(this,Eu,"f")}),X(this,y,"f").freeze(),X(this,DD,"f").freeze(),X(this,ED,"f").freeze(),X(this,LD,"f").freeze()}[B8](){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[q8](X(this,Du,"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}[zu](){return X(this,EF,"f")}[$8](){return X(this,BF,"f")}[oF](){if(!X(this,uu,"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(/[.:].*/,""))}[G8](){return this[sF]().version||"unknown"}[z8](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}[sF](D){let u=D||"*";if(X(this,Mu,"f")[u])return X(this,Mu,"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});WD(C,void 0,X(this,v,"f")),F=JSON.parse(X(this,v,"f").readFileSync(C,"utf8"))}catch(E){}return X(this,Mu,"f")[u]=F||{},X(this,Mu,"f")[u]}[nD](D,u){u=[].concat(u),u.forEach((F)=>{F=this[eF](F),X(this,I,"f")[D].push(F)})}[Ku](D,u,F,E){this[aF](D,u,F,E,(C,B,$)=>{X(this,I,"f")[C][B]=$})}[rF](D,u,F,E){this[aF](D,u,F,E,(C,B,$)=>{X(this,I,"f")[C][B]=(X(this,I,"f")[C][B]||[]).concat($)})}[aF](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 qu(F))D(B,F[B]);else C(u,this[eF](F),E)}[eF](D){if(D==="__proto__")return"___proto___";return D}[D0](D,u){return this[Ku](this[D0].bind(this),"key",D,u),this}[u0](){var D,u,F,E,C,B,$,G,z,Z,Y,J;let Q=X(this,DF,"f").pop();WD(Q,void 0,X(this,v,"f"));let O;D=this,u=this,F=this,E=this,C=this,B=this,$=this,G=this,z=this,Z=this,Y=this,J=this,{options:{set value(V){R(D,I,V,"f")}}.value,configObjects:O,exitProcess:{set value(V){R(u,AD,V,"f")}}.value,groups:{set value(V){R(F,xD,V,"f")}}.value,output:{set value(V){R(E,XD,V,"f")}}.value,exitError:{set value(V){R(C,dD,V,"f")}}.value,hasOutput:{set value(V){R(B,UD,V,"f")}}.value,parsed:this.parsed,strict:{set value(V){R($,Bu,V,"f")}}.value,strictCommands:{set value(V){R(G,$u,V,"f")}}.value,strictOptions:{set value(V){R(z,Gu,V,"f")}}.value,completionCommand:{set value(V){R(Z,qD,V,"f")}}.value,parseFn:{set value(V){R(Y,MD,V,"f")}}.value,parseContext:{set value(V){R(J,Eu,V,"f")}}.value}=Q,X(this,I,"f").configObjects=O,X(this,y,"f").unfreeze(),X(this,DD,"f").unfreeze(),X(this,ED,"f").unfreeze(),X(this,LD,"f").unfreeze()}[Z8](D,u){return eD(u,(F)=>{return D(F),F})}getInternalMethods(){return{getCommandInstance:this[J8].bind(this),getContext:this[X8].bind(this),getHasOutput:this[Q8].bind(this),getLoggerInstance:this[Y8].bind(this),getParseContext:this[W8].bind(this),getParserConfiguration:this[zu].bind(this),getUsageConfiguration:this[$8].bind(this),getUsageInstance:this[O8].bind(this),getValidationInstance:this[V8].bind(this),hasParseCallback:this[$F].bind(this),isGlobalContext:this[H8].bind(this),postProcess:this[Zu].bind(this),reset:this[F0].bind(this),runValidation:this[E0].bind(this),runYargsParserAndExecuteCommands:this[wu].bind(this),setHasOutput:this[U8].bind(this)}}[J8](){return X(this,ED,"f")}[X8](){return X(this,Pu,"f")}[Q8](){return X(this,UD,"f")}[Y8](){return X(this,Fu,"f")}[W8](){return X(this,Eu,"f")||{}}[O8](){return X(this,y,"f")}[V8](){return X(this,DD,"f")}[$F](){return!!X(this,MD,"f")}[H8](){return X(this,uF,"f")}[Zu](D,u,F,E){if(F)return D;if(s(D))return D;if(!u)D=this[u8](D);if(this[zu]()["parse-positional-numbers"]||this[zu]()["parse-positional-numbers"]===void 0)D=this[z8](D);if(E)D=aD(D,this,X(this,LD,"f").getMiddleware(),!1);return D}[F0](D={}){R(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,Cu,"f"),Object.keys(X(this,xD,"f")).reduce((B,$)=>{let G=X(this,xD,"f")[$].filter((z)=>!(z in F));if(G.length>0)B[$]=G;return B},{})),R(this,xD,{},"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]=gD(X(this,I,"f")[B],($)=>!F[$])}),u.envPrefix=X(this,I,"f").envPrefix,R(this,I,u,"f"),R(this,y,X(this,y,"f")?X(this,y,"f").reset(F):n2(this,X(this,v,"f")),"f"),R(this,DD,X(this,DD,"f")?X(this,DD,"f").reset(F):e2(this,X(this,y,"f"),X(this,v,"f")),"f"),R(this,ED,X(this,ED,"f")?X(this,ED,"f").reset():k2(X(this,y,"f"),X(this,DD,"f"),X(this,LD,"f"),X(this,v,"f")),"f"),!X(this,VD,"f"))R(this,VD,s2(this,X(this,y,"f"),X(this,ED,"f"),X(this,v,"f")),"f");return X(this,LD,"f").reset(),R(this,qD,null,"f"),R(this,XD,"","f"),R(this,dD,null,"f"),R(this,UD,!1,"f"),this.parsed=!1,this}[q8](D,u){return X(this,v,"f").path.relative(D,u)}[wu](D,u,F,E=0,C=!1){var B,$,G,z;let Z=!!F||C;D=D||X(this,iD,"f"),X(this,I,"f").__=X(this,v,"f").y18n.__,X(this,I,"f").configuration=this[zu]();let Y=!!X(this,I,"f").configuration["populate--"],J=Object.assign({},X(this,I,"f").configuration,{"populate--":!0}),Q=X(this,v,"f").Parser.detailed(D,Object.assign({},X(this,I,"f"),{configuration:{"parse-positional-numbers":!1,...J}})),O=Object.assign(Q.argv,X(this,Eu,"f")),V=void 0,W=Q.aliases,M=!1,_=!1;if(Object.keys(O).forEach((N)=>{if(N===X(this,ND,"f")&&O[N])M=!0;else if(N===X(this,ID,"f")&&O[N])_=!0}),O.$0=this.$0,this.parsed=Q,E===0)X(this,y,"f").clearCachedHelpMessage();try{if(this[oF](),u)return this[Zu](O,Y,!!F,!1);if(X(this,ND,"f")){if([X(this,ND,"f")].concat(W[X(this,ND,"f")]||[]).filter((e)=>e.length>1).includes(""+O._[O._.length-1]))O._.pop(),M=!0}R(this,uF,!1,"f");let N=X(this,ED,"f").getCommands(),k=((B=X(this,VD,"f"))===null||B===void 0?void 0:B.completionKey)?[($=X(this,VD,"f"))===null||$===void 0?void 0:$.completionKey,...(z=this.getAliases()[(G=X(this,VD,"f"))===null||G===void 0?void 0:G.completionKey])!==null&&z!==void 0?z:[]].some((c)=>Object.prototype.hasOwnProperty.call(O,c)):!1,w=M||k||C;if(O._.length){if(N.length){let c;for(let e=E||0,r;O._[e]!==void 0;e++)if(r=String(O._[e]),N.includes(r)&&r!==X(this,qD,"f")){let _D=X(this,ED,"f").runCommand(r,this,Q,e+1,C,M||_||C);return this[Zu](_D,Y,!!F,!1)}else if(!c&&r!==X(this,qD,"f")){c=r;break}if(!X(this,ED,"f").hasDefaultCommand()&&X(this,CF,"f")&&c&&!w)X(this,DD,"f").recommendCommands(c,N)}if(X(this,qD,"f")&&O._.includes(X(this,qD,"f"))&&!k){if(X(this,AD,"f"))kD(!0);this.showCompletionScript(),this.exit(0)}}if(X(this,ED,"f").hasDefaultCommand()&&!w){let c=X(this,ED,"f").runCommand(null,this,Q,0,C,M||_||C);return this[Zu](c,Y,!!F,!1)}if(k){if(X(this,AD,"f"))kD(!0);D=[].concat(D);let c=D.slice(D.indexOf(`--${X(this,VD,"f").completionKey}`)+1);return X(this,VD,"f").getCompletion(c,(e,r)=>{if(e)throw new FD(e.message);(r||[]).forEach((_D)=>{X(this,Fu,"f").log(_D)}),this.exit(0)}),this[Zu](O,!Y,!!F,!1)}if(!X(this,UD,"f")){if(M){if(X(this,AD,"f"))kD(!0);Z=!0,this.showHelp((c)=>{X(this,Fu,"f").log(c),this.exit(0)})}else if(_){if(X(this,AD,"f"))kD(!0);Z=!0,X(this,y,"f").showVersion("log"),this.exit(0)}}if(!Z&&X(this,I,"f").skipValidation.length>0)Z=Object.keys(O).some((c)=>X(this,I,"f").skipValidation.indexOf(c)>=0&&O[c]===!0);if(!Z){if(Q.error)throw new FD(Q.error.message);if(!k){let c=this[E0](W,{},Q.error);if(!F)V=aD(O,this,X(this,LD,"f").getMiddleware(),!0);if(V=this[Z8](c,V!==null&&V!==void 0?V:O),s(V)&&!F)V=V.then(()=>{return aD(O,this,X(this,LD,"f").getMiddleware(),!1)})}}}catch(N){if(N instanceof FD)X(this,y,"f").fail(N.message,N);else throw N}return this[Zu](V!==null&&V!==void 0?V:O,Y,!!F,!0)}[E0](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,$u,"f"))$=X(this,DD,"f").unknownCommands(B);if(X(this,Bu,"f")&&!$)X(this,DD,"f").unknownArguments(B,D,u,!!E);else if(X(this,Gu,"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)}}[U8](){R(this,UD,!0,"f")}[Ju](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 d2(D){return!!D&&typeof D.getInternalMethods==="function"}var q6=M8(kF),_8=q6;import{existsSync as GF,readFileSync as $0,writeFileSync as C0,mkdirSync as L8}from"node:fs";import{homedir as U6}from"node:os";import{join as Xu,dirname as G0}from"node:path";function z0(){return process.env.HOME||U6()}function N8(){return Xu(z0(),".config","slack-cli","profiles.json")}function zF(){return Xu(process.cwd(),".slack-cli","workspace")}function ZF(){return Xu(z0(),".slack-cli","workspace")}function xu(){let D=N8();if(!GF(D))return{profiles:{}};return JSON.parse($0(D,"utf8"))}function M6(D){let u=N8();L8(G0(u),{recursive:!0}),C0(u,JSON.stringify(D,null,2)+`
82
- `)}function _u(D){if(!GF(D))return;return $0(D,"utf8").trim()||void 0}function j8(D,u){let F=G0(D);L8(F,{recursive:!0});let E=Xu(F,".gitignore");if(!GF(E))C0(E,`*
83
- `);C0(D,u+`
84
- `)}function K6(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 A8(D){if(!GF(D))return{};try{return K6($0(D,"utf8"))}catch{return{}}}function B0(D,u){let F=z0(),E=D;while(!0){for(let $ of[Xu(E,".slack-term",".env.local"),Xu(E,".env.local")]){let G=A8($);for(let z of u)if(G[z])return G[z]}if(E===F)break;let B=G0(E);if(B===E)break;E=B}let C=A8(Xu(F,".slack-term",".env.local"));for(let B of u)if(C[B])return C[B];return}function T8(){let D=xu(),u=_u(zF()),F=_u(ZF()),E=u??F;return Object.entries(D.profiles).map(([C,B])=>({name:C,profile:B,current:C===E}))}function R8(D){let u=xu();if(!(D in u.profiles))throw Error(`Profile not found: ${D}`);delete u.profiles[D],M6(u)}function S8(D,u=!1){let F=xu();if(!(D in F.profiles))throw Error(`Profile not found: ${D}`);if(u)j8(ZF(),D);else j8(zF(),D)}function Z0(D){let F=xu().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=B0(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=B0(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 G=_u(zF());if(G){let Z=F[G];if(!Z)throw Error(`Workspace "${G}" (from .slack-cli/workspace) not found in profiles.`);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}if(E.length>0)throw Error(`Workspace not selected (${E.join(", ")} available).
76
+ `)}`:"";u.fail(C("Missing required argument: %s","Missing required arguments: %s",Object.keys(O).length,Object.keys(O).join(", ")+W))}},B.unknownArguments=function(J,Y,O,V,W=!0){var U;let _=D.getInternalMethods().getCommandInstance().getCommands(),M=[],N=D.getInternalMethods().getContext();if(Object.keys(J).forEach((A)=>{if(!C8.includes(A)&&!Object.prototype.hasOwnProperty.call(O,A)&&!Object.prototype.hasOwnProperty.call(D.getInternalMethods().getParseContext(),A)&&!B.isValidAndSomeAliasIsNotNew(A,Y))M.push(A)}),W&&(N.commands.length>0||_.length>0||V))J._.slice(N.commands.length).forEach((A)=>{if(!_.includes(""+A))M.push(""+A)});if(W){let h=((U=D.getDemandedCommands()._)===null||U===void 0?void 0:U.max)||0,d=N.commands.length+h;if(d<J._.length)J._.slice(d).forEach((o)=>{if(o=String(o),!N.commands.includes(o)&&!M.includes(o))M.push(o)})}if(M.length)u.fail(C("Unknown argument: %s","Unknown arguments: %s",M.length,M.map((A)=>A.trim()?A:`"${A}"`).join(", ")))},B.unknownCommands=function(J){let Y=D.getInternalMethods().getCommandInstance().getCommands(),O=[],V=D.getInternalMethods().getContext();if(V.commands.length>0||Y.length>0)J._.slice(V.commands.length).forEach((W)=>{if(!Y.includes(""+W))O.push(""+W)});if(O.length>0)return u.fail(C("Unknown command: %s","Unknown commands: %s",O.length,O.join(", "))),!0;else return!1},B.isValidAndSomeAliasIsNotNew=function(J,Y){if(!Object.prototype.hasOwnProperty.call(Y,J))return!1;let O=D.parsed.newAliases;return[J,...Y[J]].some((V)=>!Object.prototype.hasOwnProperty.call(O,V)||!O[J])},B.limitedChoices=function(J){let Y=D.getOptions(),O={};if(!Object.keys(Y.choices).length)return;Object.keys(J).forEach((U)=>{if(C8.indexOf(U)===-1&&Object.prototype.hasOwnProperty.call(Y.choices,U))[].concat(J[U]).forEach((_)=>{if(Y.choices[U].indexOf(_)===-1&&_!==void 0)O[U]=(O[U]||[]).concat(_)})});let V=Object.keys(O);if(!V.length)return;let W=E("Invalid values:");V.forEach((U)=>{W+=`
77
+ ${E("Argument: %s, Given: %s, Choices: %s",U,u.stringifiedValues(O[U]),u.stringifiedValues(Y.choices[U]))}`}),u.fail(W)};let $={};B.implies=function(J,Y){if(S("<string|object> [array|number|string]",[J,Y],arguments.length),typeof J==="object")Object.keys(J).forEach((O)=>{B.implies(O,J[O])});else{if(D.global(J),!$[J])$[J]=[];if(Array.isArray(Y))Y.forEach((O)=>B.implies(J,O));else WD(Y,void 0,F),$[J].push(Y)}},B.getImplied=function(){return $};function G(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((O)=>{let V=O;($[O]||[]).forEach((W)=>{let U=V,_=W;if(U=G(J,U),W=G(J,W),U&&!W)Y.push(` ${V} -> ${_}`)})}),Y.length){let O=`${E("Implications failed:")}
78
+ `;Y.forEach((V)=>{O+=V}),u.fail(O)}};let Z={};B.conflicts=function(J,Y){if(S("<string|object> [array|string]",[J,Y],arguments.length),typeof J==="object")Object.keys(J).forEach((O)=>{B.conflicts(O,J[O])});else{if(D.global(J),!Z[J])Z[J]=[];if(Array.isArray(Y))Y.forEach((O)=>B.conflicts(J,O));else Z[J].push(Y)}},B.getConflicting=()=>Z,B.conflicting=function(J){if(Object.keys(J).forEach((Y)=>{if(Z[Y])Z[Y].forEach((O)=>{if(O&&J[Y]!==void 0&&J[O]!==void 0)u.fail(E("Arguments %s and %s are mutually exclusive",Y,O))})}),D.getInternalMethods().getParserConfiguration()["strip-dashed"])Object.keys(Z).forEach((Y)=>{Z[Y].forEach((O)=>{if(O&&J[F.Parser.camelCase(Y)]!==void 0&&J[F.Parser.camelCase(O)]!==void 0)u.fail(E("Arguments %s and %s are mutually exclusive",Y,O))})})},B.recommendCommands=function(J,Y){Y=Y.sort((U,_)=>_.length-U.length);let V=null,W=1/0;for(let U=0,_;(_=Y[U])!==void 0;U++){let M=E8(J,_);if(M<=3&&M<W)W=M,V=_}if(V)u.fail(E("Did you mean %s?",V))},B.reset=function(J){return $=gD($,(Y)=>!J[Y]),Z=gD(Z,(Y)=>!J[Y]),B};let z=[];return B.freeze=function(){z.push({implied:$,conflicting:Z})},B.unfreeze=function(){let J=z.pop();WD(J,void 0,F),{implied:$,conflicting:Z}=J},B}var tF=[],wu;function xu(D,u,F,E){wu=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(G){return D}else $=_6(u,D.extends);U6($),tF.push($),C=B?JSON.parse(wu.readFileSync($,"utf8")):E.require(D.extends),delete D.extends,C=xu(C,wu.path.dirname($),F,wu)}return tF=[],F?$8(C,D):Object.assign({},C,D)}function U6(D){if(tF.indexOf(D)>-1)throw new FD(`Circular extended configurations: '${D}'.`)}function _6(D,u){return wu.path.resolve(D,u)}function $8(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]=$8(D[C],u[C]);else F[C]=u[C];return F}var P=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,uu,Iu,VD,qD,DF,dD,Fu,uF,AD,FF,LD,xD,KD,ND,EF,Eu,XD,b,CF,BF,UD,Cu,_u,Bu,iD,$F,y,$u,Gu,zu,c,GF,ID,DD;function N8(D){return(u=[],F=D.process.cwd(),E)=>{let C=new T8(u,F,E,D);return Object.defineProperty(C,"argv",{get:()=>{return C.parse()},enumerable:!0}),C.help(),C.version(),C}}var G8=Symbol("copyDoubleDash"),z8=Symbol("copyDoubleDash"),oF=Symbol("deleteFromParserHintObject"),Z8=Symbol("emitWarning"),J8=Symbol("freeze"),X8=Symbol("getDollarZero"),Zu=Symbol("getParserConfiguration"),Q8=Symbol("getUsageConfiguration"),sF=Symbol("guessLocale"),Y8=Symbol("guessVersion"),W8=Symbol("parsePositionalNumbers"),rF=Symbol("pkgUp"),nD=Symbol("populateParserHintArray"),ju=Symbol("populateParserHintSingleValueDictionary"),aF=Symbol("populateParserHintArrayDictionary"),eF=Symbol("populateParserHintDictionary"),D0=Symbol("sanitizeKey"),u0=Symbol("setKey"),F0=Symbol("unfreeze"),O8=Symbol("validateAsync"),V8=Symbol("getCommandInstance"),H8=Symbol("getContext"),q8=Symbol("getHasOutput"),K8=Symbol("getLoggerInstance"),U8=Symbol("getParseContext"),_8=Symbol("getUsageInstance"),j8=Symbol("getValidationInstance"),zF=Symbol("hasParseCallback"),M8=Symbol("isGlobalContext"),Ju=Symbol("postProcess"),A8=Symbol("rebase"),E0=Symbol("reset"),bu=Symbol("runYargsParserAndExecuteCommands"),C0=Symbol("runValidation"),L8=Symbol("setHasOutput"),Xu=Symbol("kTrackManuallySetKeys"),j6="en_US";class T8{constructor(D=[],u,F,E){this.customScriptName=!1,this.parsed=!1,ED.set(this,void 0),uu.set(this,void 0),Iu.set(this,{commands:[],fullCommands:[]}),VD.set(this,null),qD.set(this,null),DF.set(this,"show-hidden"),dD.set(this,null),Fu.set(this,!0),uF.set(this,{}),AD.set(this,!0),FF.set(this,[]),LD.set(this,void 0),xD.set(this,{}),KD.set(this,!1),ND.set(this,null),EF.set(this,!0),Eu.set(this,void 0),XD.set(this,""),b.set(this,void 0),CF.set(this,void 0),BF.set(this,{}),UD.set(this,null),Cu.set(this,null),_u.set(this,{}),Bu.set(this,{}),iD.set(this,void 0),$F.set(this,!1),y.set(this,void 0),$u.set(this,!1),Gu.set(this,!1),zu.set(this,!1),c.set(this,void 0),GF.set(this,{}),ID.set(this,null),DD.set(this,void 0),P(this,y,E,"f"),P(this,iD,D,"f"),P(this,uu,u,"f"),P(this,CF,F,"f"),P(this,LD,new nF(this),"f"),this.$0=this[X8](),this[E0](),P(this,ED,X(this,ED,"f"),"f"),P(this,c,X(this,c,"f"),"f"),P(this,DD,X(this,DD,"f"),"f"),P(this,b,X(this,b,"f"),"f"),X(this,b,"f").showHiddenOpt=X(this,DF,"f"),P(this,Eu,this[z8](),"f"),X(this,y,"f").y18n.setLocale(j6)}addHelpOpt(D,u){if(S("[string|boolean] [string]",[D,u],arguments.length),X(this,ND,"f"))this[oF](X(this,ND,"f")),P(this,ND,null,"f");if(D===!1&&u===void 0)return this;return P(this,ND,typeof D==="string"?D:"help","f"),this.boolean(X(this,ND,"f")),this.describe(X(this,ND,"f"),u||X(this,c,"f").deferY18nLookup("Show help")),this}help(D,u){return this.addHelpOpt(D,u)}addShowHiddenOpt(D,u){if(S("[string|boolean] [string]",[D,u],arguments.length),D===!1&&u===void 0)return this;let F=typeof D==="string"?D:X(this,DF,"f");return this.boolean(F),this.describe(F,u||X(this,c,"f").deferY18nLookup("Show hidden options")),X(this,b,"f").showHiddenOpt=F,this}showHidden(D,u){return this.addShowHiddenOpt(D,u)}alias(D,u){return S("<object|string|array> [string|array]",[D,u],arguments.length),this[aF](this.alias.bind(this),"alias",D,u),this}array(D){return S("<array|string>",[D],arguments.length),this[nD]("array",D),this[Xu](D),this}boolean(D){return S("<array|string>",[D],arguments.length),this[nD]("boolean",D),this[Xu](D),this}check(D,u){return S("<function> [boolean]",[D,u],arguments.length),this.middleware((F,E)=>{return Du(()=>{return D(F,E.getOptions())},(C)=>{if(!C)X(this,c,"f").fail(X(this,y,"f").y18n.__("Argument check failed: %s",D.toString()));else if(typeof C==="string"||C instanceof Error)X(this,c,"f").fail(C.toString(),C);return F},(C)=>{return X(this,c,"f").fail(C.message?C.message:C.toString(),C),F})},!1,u),this}choices(D,u){return S("<object|string|array> [string|array]",[D,u],arguments.length),this[aF](this.choices.bind(this),"choices",D,u),this}coerce(D,u){if(S("<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,b,"f").key[F]=!0,X(this,LD,"f").addCoerceMiddleware((E,C)=>{var B;let $=(B=C.getAliases()[F])!==null&&B!==void 0?B:[],G=[F,...$].filter((Z)=>Object.prototype.hasOwnProperty.call(E,Z));if(G.length===0)return E;return Du(()=>{return u(E[G[0]])},(Z)=>{return G.forEach((z)=>{E[z]=Z}),E},(Z)=>{throw new FD(Z.message)})},F),this}conflicts(D,u){return S("<string|object> [string|array]",[D,u],arguments.length),X(this,DD,"f").conflicts(D,u),this}config(D="config",u,F){if(S("[object|string] [string|function] [function]",[D,u,F],arguments.length),typeof D==="object"&&!Array.isArray(D))return D=xu(D,X(this,uu,"f"),this[Zu]()["deep-merge-config"]||!1,X(this,y,"f")),X(this,b,"f").configObjects=(X(this,b,"f").configObjects||[]).concat(D),this;if(typeof u==="function")F=u,u=void 0;return this.describe(D,u||X(this,c,"f").deferY18nLookup("Path to JSON config file")),(Array.isArray(D)?D:[D]).forEach((E)=>{X(this,b,"f").config[E]=F||!0}),this}completion(D,u,F){if(S("[string] [string|boolean|function] [function]",[D,u,F],arguments.length),typeof u==="function")F=u,u=void 0;if(P(this,qD,D||X(this,qD,"f")||"completion","f"),!u&&u!==!1)u="generate completion script";if(this.command(X(this,qD,"f"),u),F)X(this,VD,"f").registerFunction(F);return this}command(D,u,F,E,C,B){return S("<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){S("<string> [object]",[D,u],arguments.length);let F=X(this,CF,"f")||X(this,y,"f").require;return X(this,ED,"f").addDirectory(D,F,X(this,y,"f").getCallerFile(),u),this}count(D){return S("<array|string>",[D],arguments.length),this[nD]("count",D),this[Xu](D),this}default(D,u,F){if(S("<object|string|array> [*] [string]",[D,u,F],arguments.length),F)iF(D,X(this,y,"f")),X(this,b,"f").defaultDescription[D]=F;if(typeof u==="function"){if(iF(D,X(this,y,"f")),!X(this,b,"f").defaultDescription[D])X(this,b,"f").defaultDescription[D]=X(this,c,"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(S("[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,b,"f").demandedCommands._={min:D,max:u,minMsg:F,maxMsg:E},this}demand(D,u,F){if(Array.isArray(u))u.forEach((E)=>{WD(F,!0,X(this,y,"f")),this.demandOption(E,F)}),u=1/0;else if(typeof u!=="number")F=u,u=1/0;if(typeof D==="number")WD(F,!0,X(this,y,"f")),this.demandCommand(D,u,F,F);else if(Array.isArray(D))D.forEach((E)=>{WD(F,!0,X(this,y,"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 S("<object|string|array> [string]",[D,u],arguments.length),this[ju](this.demandOption.bind(this),"demandedOptions",D,u),this}deprecateOption(D,u){return S("<string> [string|boolean]",[D,u],arguments.length),X(this,b,"f").deprecatedOptions[D]=u,this}describe(D,u){return S("<object|string|array> [string]",[D,u],arguments.length),this[u0](D,!0),X(this,c,"f").describe(D,u),this}detectLocale(D){return S("<boolean>",[D],arguments.length),P(this,Fu,D,"f"),this}env(D){if(S("[string|boolean]",[D],arguments.length),D===!1)delete X(this,b,"f").envPrefix;else X(this,b,"f").envPrefix=D||"";return this}epilogue(D){return S("<string>",[D],arguments.length),X(this,c,"f").epilog(D),this}epilog(D){return this.epilogue(D)}example(D,u){if(S("<string|array> [string]",[D,u],arguments.length),Array.isArray(D))D.forEach((F)=>this.example(...F));else X(this,c,"f").example(D,u);return this}exit(D,u){if(P(this,KD,!0,"f"),P(this,dD,u,"f"),X(this,AD,"f"))X(this,y,"f").process.exit(D)}exitProcess(D=!0){return S("[boolean]",[D],arguments.length),P(this,AD,D,"f"),this}fail(D){if(S("<function|boolean>",[D],arguments.length),typeof D==="boolean"&&D!==!1)throw new FD("Invalid first argument. Expected function or boolean 'false'");return X(this,c,"f").failFn(D),this}getAliases(){return this.parsed?this.parsed.aliases:{}}async getCompletion(D,u){if(S("<array> [function]",[D,u],arguments.length),!u)return new Promise((F,E)=>{X(this,VD,"f").getCompletion(D,(C,B)=>{if(C)E(C);else F(B)})});else return X(this,VD,"f").getCompletion(D,u)}getDemandedOptions(){return S([],0),X(this,b,"f").demandedOptions}getDemandedCommands(){return S([],0),X(this,b,"f").demandedCommands}getDeprecatedOptions(){return S([],0),X(this,b,"f").deprecatedOptions}getDetectLocale(){return X(this,Fu,"f")}getExitProcess(){return X(this,AD,"f")}getGroups(){return Object.assign({},X(this,xD,"f"),X(this,Bu,"f"))}getHelp(){if(P(this,KD,!0,"f"),!X(this,c,"f").hasCachedHelpMessage()){if(!this.parsed){let u=this[bu](X(this,iD,"f"),void 0,void 0,0,!0);if(a(u))return u.then(()=>{return X(this,c,"f").help()})}let D=X(this,ED,"f").runDefaultBuilderOn(this);if(a(D))return D.then(()=>{return X(this,c,"f").help()})}return Promise.resolve(X(this,c,"f").help())}getOptions(){return X(this,b,"f")}getStrict(){return X(this,$u,"f")}getStrictCommands(){return X(this,Gu,"f")}getStrictOptions(){return X(this,zu,"f")}global(D,u){if(S("<string|array> [boolean]",[D,u],arguments.length),D=[].concat(D),u!==!1)X(this,b,"f").local=X(this,b,"f").local.filter((F)=>D.indexOf(F)===-1);else D.forEach((F)=>{if(!X(this,b,"f").local.includes(F))X(this,b,"f").local.push(F)});return this}group(D,u){S("<string|array> <string>",[D,u],arguments.length);let F=X(this,Bu,"f")[u]||X(this,xD,"f")[u];if(X(this,Bu,"f")[u])delete X(this,Bu,"f")[u];let E={};return X(this,xD,"f")[u]=(F||[]).concat(D).filter((C)=>{if(E[C])return!1;return E[C]=!0}),this}hide(D){return S("<string>",[D],arguments.length),X(this,b,"f").hiddenOptions.push(D),this}implies(D,u){return S("<string|object> [number|string|array]",[D,u],arguments.length),X(this,DD,"f").implies(D,u),this}locale(D){if(S("[string]",[D],arguments.length),D===void 0)return this[sF](),X(this,y,"f").y18n.getLocale();return P(this,Fu,!1,"f"),X(this,y,"f").y18n.setLocale(D),this}middleware(D,u,F){return X(this,LD,"f").addMiddleware(D,!!u,F)}nargs(D,u){return S("<string|object|array> [number]",[D,u],arguments.length),this[ju](this.nargs.bind(this),"narg",D,u),this}normalize(D){return S("<array|string>",[D],arguments.length),this[nD]("normalize",D),this}number(D){return S("<array|string>",[D],arguments.length),this[nD]("number",D),this[Xu](D),this}option(D,u){if(S("<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[Xu](D),X(this,ID,"f")&&(D==="version"||(u===null||u===void 0?void 0:u.alias)==="version"))this[Z8](['"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,b,"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,b,"f").defaultDescription[D]=u.defaultDescription;if(u.skipValidation)this.skipValidation(D);let C=u.describe||u.description||u.desc,B=X(this,c,"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(S("[string|array] [function|boolean|object] [function]",[D,u,F],arguments.length),this[J8](),typeof D>"u")D=X(this,iD,"f");if(typeof u==="object")P(this,Cu,u,"f"),u=F;if(typeof u==="function")P(this,UD,u,"f"),u=!1;if(!u)P(this,iD,D,"f");if(X(this,UD,"f"))P(this,AD,!1,"f");let E=this[bu](D,!!u),C=this.parsed;if(X(this,VD,"f").setParsed(this.parsed),a(E))return E.then((B)=>{if(X(this,UD,"f"))X(this,UD,"f").call(this,X(this,dD,"f"),B,X(this,XD,"f"));return B}).catch((B)=>{if(X(this,UD,"f"))X(this,UD,"f")(B,this.parsed.argv,X(this,XD,"f"));throw B}).finally(()=>{this[F0](),this.parsed=C});else{if(X(this,UD,"f"))X(this,UD,"f").call(this,X(this,dD,"f"),E,X(this,XD,"f"));this[F0](),this.parsed=C}return E}parseAsync(D,u,F){let E=this.parse(D,u,F);return!a(E)?Promise.resolve(E):E}parseSync(D,u,F){let E=this.parse(D,u,F);if(a(E))throw new FD(".parseSync() must not be used with asynchronous builders, handlers, or middleware");return E}parserConfiguration(D){return S("<object>",[D],arguments.length),P(this,BF,D,"f"),this}pkgConf(D,u){S("<string> [string]",[D,u],arguments.length);let F=null,E=this[rF](u||X(this,uu,"f"));if(E[D]&&typeof E[D]==="object")F=xu(E[D],u||X(this,uu,"f"),this[Zu]()["deep-merge-config"]||!1,X(this,y,"f")),X(this,b,"f").configObjects=(X(this,b,"f").configObjects||[]).concat(F);return this}positional(D,u){S("<string> <object>",[D,u],arguments.length);let F=["default","defaultDescription","implies","normalize","choices","conflicts","coerce","type","describe","desc","description","alias"];u=gD(u,(B,$)=>{if(B==="type"&&!["string","number","boolean"].includes($))return!1;return F.includes(B)});let E=X(this,Iu,"f").fullCommands[X(this,Iu,"f").fullCommands.length-1],C=E?X(this,ED,"f").cmdToParseOptions(E):{array:[],alias:{},default:{},demand:{}};return Ku(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,c,"f").getPositionalGroupName()),this.option(D,u)}recommendCommands(D=!0){return S("[boolean]",[D],arguments.length),P(this,$F,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(S("<array|string|object> [number]",[D],arguments.length),typeof D==="string"&&X(this,b,"f").narg[D])return this;else this[ju](this.requiresArg.bind(this),"narg",D,NaN);return this}showCompletionScript(D,u){return S("[string] [string]",[D,u],arguments.length),D=D||this.$0,X(this,Eu,"f").log(X(this,VD,"f").generateCompletionScript(D,u||X(this,qD,"f")||"completion")),this}showHelp(D){if(S("[string|function]",[D],arguments.length),P(this,KD,!0,"f"),!X(this,c,"f").hasCachedHelpMessage()){if(!this.parsed){let F=this[bu](X(this,iD,"f"),void 0,void 0,0,!0);if(a(F))return F.then(()=>{X(this,c,"f").showHelp(D)}),this}let u=X(this,ED,"f").runDefaultBuilderOn(this);if(a(u))return u.then(()=>{X(this,c,"f").showHelp(D)}),this}return X(this,c,"f").showHelp(D),this}scriptName(D){return this.customScriptName=!0,this.$0=D,this}showHelpOnFail(D,u){return S("[boolean|string] [string]",[D,u],arguments.length),X(this,c,"f").showHelpOnFail(D,u),this}showVersion(D){return S("[string|function]",[D],arguments.length),X(this,c,"f").showVersion(D),this}skipValidation(D){return S("<array|string>",[D],arguments.length),this[nD]("skipValidation",D),this}strict(D){return S("[boolean]",[D],arguments.length),P(this,$u,D!==!1,"f"),this}strictCommands(D){return S("[boolean]",[D],arguments.length),P(this,Gu,D!==!1,"f"),this}strictOptions(D){return S("[boolean]",[D],arguments.length),P(this,zu,D!==!1,"f"),this}string(D){return S("<array|string>",[D],arguments.length),this[nD]("string",D),this[Xu](D),this}terminalWidth(){return S([],0),X(this,y,"f").process.stdColumns}updateLocale(D){return this.updateStrings(D)}updateStrings(D){return S("<object>",[D],arguments.length),P(this,Fu,!1,"f"),X(this,y,"f").y18n.updateLocale(D),this}usage(D,u,F,E){if(S("<string|null|undefined> [string|boolean] [function|object] [function]",[D,u,F,E],arguments.length),u!==void 0)if(WD(D,null,X(this,y,"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,c,"f").usage(D),this}usageConfiguration(D){return S("<object>",[D],arguments.length),P(this,GF,D,"f"),this}version(D,u,F){if(S("[boolean|string] [string] [string]",[D,u,F],arguments.length),X(this,ID,"f"))this[oF](X(this,ID,"f")),X(this,c,"f").version(void 0),P(this,ID,null,"f");if(arguments.length===0)F=this[Y8](),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 P(this,ID,typeof D==="string"?D:"version","f"),u=u||X(this,c,"f").deferY18nLookup("Show version number"),X(this,c,"f").version(F||void 0),this.boolean(X(this,ID,"f")),this.describe(X(this,ID,"f"),u),this}wrap(D){return S("<number|null|undefined>",[D],arguments.length),X(this,c,"f").wrap(D),this}[(ED=new WeakMap,uu=new WeakMap,Iu=new WeakMap,VD=new WeakMap,qD=new WeakMap,DF=new WeakMap,dD=new WeakMap,Fu=new WeakMap,uF=new WeakMap,AD=new WeakMap,FF=new WeakMap,LD=new WeakMap,xD=new WeakMap,KD=new WeakMap,ND=new WeakMap,EF=new WeakMap,Eu=new WeakMap,XD=new WeakMap,b=new WeakMap,CF=new WeakMap,BF=new WeakMap,UD=new WeakMap,Cu=new WeakMap,_u=new WeakMap,Bu=new WeakMap,iD=new WeakMap,$F=new WeakMap,y=new WeakMap,$u=new WeakMap,Gu=new WeakMap,zu=new WeakMap,c=new WeakMap,GF=new WeakMap,ID=new WeakMap,DD=new WeakMap,G8)](D){if(!D._||!D["--"])return D;D._.push.apply(D._,D["--"]);try{delete D["--"]}catch(u){}return D}[z8](){return{log:(...D)=>{if(!this[zF]())console.log(...D);if(P(this,KD,!0,"f"),X(this,XD,"f").length)P(this,XD,X(this,XD,"f")+`
80
+ `,"f");P(this,XD,X(this,XD,"f")+D.join(" "),"f")},error:(...D)=>{if(!this[zF]())console.error(...D);if(P(this,KD,!0,"f"),X(this,XD,"f").length)P(this,XD,X(this,XD,"f")+`
81
+ `,"f");P(this,XD,X(this,XD,"f")+D.join(" "),"f")}}}[oF](D){Ku(X(this,b,"f")).forEach((u)=>{if(((E)=>E==="configObjects")(u))return;let F=X(this,b,"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,c,"f").getDescriptions()[D]}[Z8](D,u,F){if(!X(this,uF,"f")[F])X(this,y,"f").process.emitWarning(D,u),X(this,uF,"f")[F]=!0}[J8](){X(this,FF,"f").push({options:X(this,b,"f"),configObjects:X(this,b,"f").configObjects.slice(0),exitProcess:X(this,AD,"f"),groups:X(this,xD,"f"),strict:X(this,$u,"f"),strictCommands:X(this,Gu,"f"),strictOptions:X(this,zu,"f"),completionCommand:X(this,qD,"f"),output:X(this,XD,"f"),exitError:X(this,dD,"f"),hasOutput:X(this,KD,"f"),parsed:this.parsed,parseFn:X(this,UD,"f"),parseContext:X(this,Cu,"f")}),X(this,c,"f").freeze(),X(this,DD,"f").freeze(),X(this,ED,"f").freeze(),X(this,LD,"f").freeze()}[X8](){let D="",u;if(/\b(node|iojs|electron)(\.exe)?$/.test(X(this,y,"f").process.argv()[0]))u=X(this,y,"f").process.argv().slice(1,2);else u=X(this,y,"f").process.argv().slice(0,1);if(D=u.map((F)=>{let E=this[A8](X(this,uu,"f"),F);return F.match(/^(\/|([a-zA-Z]:)?\\)/)&&E.length<F.length?E:F}).join(" ").trim(),X(this,y,"f").getEnv("_")&&X(this,y,"f").getProcessArgvBin()===X(this,y,"f").getEnv("_"))D=X(this,y,"f").getEnv("_").replace(`${X(this,y,"f").path.dirname(X(this,y,"f").process.execPath())}/`,"");return D}[Zu](){return X(this,BF,"f")}[Q8](){return X(this,GF,"f")}[sF](){if(!X(this,Fu,"f"))return;let D=X(this,y,"f").getEnv("LC_ALL")||X(this,y,"f").getEnv("LC_MESSAGES")||X(this,y,"f").getEnv("LANG")||X(this,y,"f").getEnv("LANGUAGE")||"en_US";this.locale(D.replace(/[.:].*/,""))}[Y8](){return this[rF]().version||"unknown"}[W8](D){let u=D["--"]?D["--"]:D._;for(let F=0,E;(E=u[F])!==void 0;F++)if(X(this,y,"f").Parser.looksLikeNumber(E)&&Number.isSafeInteger(Math.floor(parseFloat(`${E}`))))u[F]=Number(E);return D}[rF](D){let u=D||"*";if(X(this,_u,"f")[u])return X(this,_u,"f")[u];let F={};try{let E=D||X(this,y,"f").mainFilename;if(X(this,y,"f").path.extname(E))E=X(this,y,"f").path.dirname(E);let C=X(this,y,"f").findUp(E,(B,$)=>{if($.includes("package.json"))return"package.json";else return});WD(C,void 0,X(this,y,"f")),F=JSON.parse(X(this,y,"f").readFileSync(C,"utf8"))}catch(E){}return X(this,_u,"f")[u]=F||{},X(this,_u,"f")[u]}[nD](D,u){u=[].concat(u),u.forEach((F)=>{F=this[D0](F),X(this,b,"f")[D].push(F)})}[ju](D,u,F,E){this[eF](D,u,F,E,(C,B,$)=>{X(this,b,"f")[C][B]=$})}[aF](D,u,F,E){this[eF](D,u,F,E,(C,B,$)=>{X(this,b,"f")[C][B]=(X(this,b,"f")[C][B]||[]).concat($)})}[eF](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 Ku(F))D(B,F[B]);else C(u,this[D0](F),E)}[D0](D){if(D==="__proto__")return"___proto___";return D}[u0](D,u){return this[ju](this[u0].bind(this),"key",D,u),this}[F0](){var D,u,F,E,C,B,$,G,Z,z,Q,J;let Y=X(this,FF,"f").pop();WD(Y,void 0,X(this,y,"f"));let O;D=this,u=this,F=this,E=this,C=this,B=this,$=this,G=this,Z=this,z=this,Q=this,J=this,{options:{set value(V){P(D,b,V,"f")}}.value,configObjects:O,exitProcess:{set value(V){P(u,AD,V,"f")}}.value,groups:{set value(V){P(F,xD,V,"f")}}.value,output:{set value(V){P(E,XD,V,"f")}}.value,exitError:{set value(V){P(C,dD,V,"f")}}.value,hasOutput:{set value(V){P(B,KD,V,"f")}}.value,parsed:this.parsed,strict:{set value(V){P($,$u,V,"f")}}.value,strictCommands:{set value(V){P(G,Gu,V,"f")}}.value,strictOptions:{set value(V){P(Z,zu,V,"f")}}.value,completionCommand:{set value(V){P(z,qD,V,"f")}}.value,parseFn:{set value(V){P(Q,UD,V,"f")}}.value,parseContext:{set value(V){P(J,Cu,V,"f")}}.value}=Y,X(this,b,"f").configObjects=O,X(this,c,"f").unfreeze(),X(this,DD,"f").unfreeze(),X(this,ED,"f").unfreeze(),X(this,LD,"f").unfreeze()}[O8](D,u){return Du(u,(F)=>{return D(F),F})}getInternalMethods(){return{getCommandInstance:this[V8].bind(this),getContext:this[H8].bind(this),getHasOutput:this[q8].bind(this),getLoggerInstance:this[K8].bind(this),getParseContext:this[U8].bind(this),getParserConfiguration:this[Zu].bind(this),getUsageConfiguration:this[Q8].bind(this),getUsageInstance:this[_8].bind(this),getValidationInstance:this[j8].bind(this),hasParseCallback:this[zF].bind(this),isGlobalContext:this[M8].bind(this),postProcess:this[Ju].bind(this),reset:this[E0].bind(this),runValidation:this[C0].bind(this),runYargsParserAndExecuteCommands:this[bu].bind(this),setHasOutput:this[L8].bind(this)}}[V8](){return X(this,ED,"f")}[H8](){return X(this,Iu,"f")}[q8](){return X(this,KD,"f")}[K8](){return X(this,Eu,"f")}[U8](){return X(this,Cu,"f")||{}}[_8](){return X(this,c,"f")}[j8](){return X(this,DD,"f")}[zF](){return!!X(this,UD,"f")}[M8](){return X(this,EF,"f")}[Ju](D,u,F,E){if(F)return D;if(a(D))return D;if(!u)D=this[G8](D);if(this[Zu]()["parse-positional-numbers"]||this[Zu]()["parse-positional-numbers"]===void 0)D=this[W8](D);if(E)D=eD(D,this,X(this,LD,"f").getMiddleware(),!1);return D}[E0](D={}){P(this,b,X(this,b,"f")||{},"f");let u={};u.local=X(this,b,"f").local||[],u.configObjects=X(this,b,"f").configObjects||[];let F={};u.local.forEach((B)=>{F[B]=!0,(D[B]||[]).forEach(($)=>{F[$]=!0})}),Object.assign(X(this,Bu,"f"),Object.keys(X(this,xD,"f")).reduce((B,$)=>{let G=X(this,xD,"f")[$].filter((Z)=>!(Z in F));if(G.length>0)B[$]=G;return B},{})),P(this,xD,{},"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,b,"f")[B]||[]).filter(($)=>!F[$])}),C.forEach((B)=>{u[B]=gD(X(this,b,"f")[B],($)=>!F[$])}),u.envPrefix=X(this,b,"f").envPrefix,P(this,b,u,"f"),P(this,c,X(this,c,"f")?X(this,c,"f").reset(F):a2(this,X(this,y,"f")),"f"),P(this,DD,X(this,DD,"f")?X(this,DD,"f").reset(F):B8(this,X(this,c,"f"),X(this,y,"f")),"f"),P(this,ED,X(this,ED,"f")?X(this,ED,"f").reset():o2(X(this,c,"f"),X(this,DD,"f"),X(this,LD,"f"),X(this,y,"f")),"f"),!X(this,VD,"f"))P(this,VD,F8(this,X(this,c,"f"),X(this,ED,"f"),X(this,y,"f")),"f");return X(this,LD,"f").reset(),P(this,qD,null,"f"),P(this,XD,"","f"),P(this,dD,null,"f"),P(this,KD,!1,"f"),this.parsed=!1,this}[A8](D,u){return X(this,y,"f").path.relative(D,u)}[bu](D,u,F,E=0,C=!1){var B,$,G,Z;let z=!!F||C;D=D||X(this,iD,"f"),X(this,b,"f").__=X(this,y,"f").y18n.__,X(this,b,"f").configuration=this[Zu]();let Q=!!X(this,b,"f").configuration["populate--"],J=Object.assign({},X(this,b,"f").configuration,{"populate--":!0}),Y=X(this,y,"f").Parser.detailed(D,Object.assign({},X(this,b,"f"),{configuration:{"parse-positional-numbers":!1,...J}})),O=Object.assign(Y.argv,X(this,Cu,"f")),V=void 0,W=Y.aliases,U=!1,_=!1;if(Object.keys(O).forEach((M)=>{if(M===X(this,ND,"f")&&O[M])U=!0;else if(M===X(this,ID,"f")&&O[M])_=!0}),O.$0=this.$0,this.parsed=Y,E===0)X(this,c,"f").clearCachedHelpMessage();try{if(this[sF](),u)return this[Ju](O,Q,!!F,!1);if(X(this,ND,"f")){if([X(this,ND,"f")].concat(W[X(this,ND,"f")]||[]).filter((d)=>d.length>1).includes(""+O._[O._.length-1]))O._.pop(),U=!0}P(this,EF,!1,"f");let M=X(this,ED,"f").getCommands(),N=((B=X(this,VD,"f"))===null||B===void 0?void 0:B.completionKey)?[($=X(this,VD,"f"))===null||$===void 0?void 0:$.completionKey,...(Z=this.getAliases()[(G=X(this,VD,"f"))===null||G===void 0?void 0:G.completionKey])!==null&&Z!==void 0?Z:[]].some((h)=>Object.prototype.hasOwnProperty.call(O,h)):!1,A=U||N||C;if(O._.length){if(M.length){let h;for(let d=E||0,o;O._[d]!==void 0;d++)if(o=String(O._[d]),M.includes(o)&&o!==X(this,qD,"f")){let jD=X(this,ED,"f").runCommand(o,this,Y,d+1,C,U||_||C);return this[Ju](jD,Q,!!F,!1)}else if(!h&&o!==X(this,qD,"f")){h=o;break}if(!X(this,ED,"f").hasDefaultCommand()&&X(this,$F,"f")&&h&&!A)X(this,DD,"f").recommendCommands(h,M)}if(X(this,qD,"f")&&O._.includes(X(this,qD,"f"))&&!N){if(X(this,AD,"f"))kD(!0);this.showCompletionScript(),this.exit(0)}}if(X(this,ED,"f").hasDefaultCommand()&&!A){let h=X(this,ED,"f").runCommand(null,this,Y,0,C,U||_||C);return this[Ju](h,Q,!!F,!1)}if(N){if(X(this,AD,"f"))kD(!0);D=[].concat(D);let h=D.slice(D.indexOf(`--${X(this,VD,"f").completionKey}`)+1);return X(this,VD,"f").getCompletion(h,(d,o)=>{if(d)throw new FD(d.message);(o||[]).forEach((jD)=>{X(this,Eu,"f").log(jD)}),this.exit(0)}),this[Ju](O,!Q,!!F,!1)}if(!X(this,KD,"f")){if(U){if(X(this,AD,"f"))kD(!0);z=!0,this.showHelp((h)=>{X(this,Eu,"f").log(h),this.exit(0)})}else if(_){if(X(this,AD,"f"))kD(!0);z=!0,X(this,c,"f").showVersion("log"),this.exit(0)}}if(!z&&X(this,b,"f").skipValidation.length>0)z=Object.keys(O).some((h)=>X(this,b,"f").skipValidation.indexOf(h)>=0&&O[h]===!0);if(!z){if(Y.error)throw new FD(Y.error.message);if(!N){let h=this[C0](W,{},Y.error);if(!F)V=eD(O,this,X(this,LD,"f").getMiddleware(),!0);if(V=this[O8](h,V!==null&&V!==void 0?V:O),a(V)&&!F)V=V.then(()=>{return eD(O,this,X(this,LD,"f").getMiddleware(),!1)})}}}catch(M){if(M instanceof FD)X(this,c,"f").fail(M.message,M);else throw M}return this[Ju](V!==null&&V!==void 0?V:O,Q,!!F,!0)}[C0](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,Gu,"f"))$=X(this,DD,"f").unknownCommands(B);if(X(this,$u,"f")&&!$)X(this,DD,"f").unknownArguments(B,D,u,!!E);else if(X(this,zu,"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)}}[L8](){P(this,KD,!0,"f")}[Xu](D){if(typeof D==="string")X(this,b,"f").key[D]=!0;else for(let u of D)X(this,b,"f").key[u]=!0}}function s2(D){return!!D&&typeof D.getInternalMethods==="function"}var M6=N8(dF),R8=M6;import{existsSync as ZF,readFileSync as G0,writeFileSync as B0,mkdirSync as w8}from"node:fs";import{homedir as A6}from"node:os";import{join as Qu,dirname as z0}from"node:path";function Z0(){return process.env.HOME||A6()}function x8(){return Qu(Z0(),".config","slack-cli","profiles.json")}function JF(){return Qu(process.cwd(),".slack-cli","workspace")}function XF(){return Qu(Z0(),".slack-cli","workspace")}function fu(){let D=x8();if(!ZF(D))return{profiles:{}};return JSON.parse(G0(D,"utf8"))}function L6(D){let u=x8();w8(z0(u),{recursive:!0}),B0(u,JSON.stringify(D,null,2)+`
82
+ `)}function Mu(D){if(!ZF(D))return;return G0(D,"utf8").trim()||void 0}function S8(D,u){let F=z0(D);w8(F,{recursive:!0});let E=Qu(F,".gitignore");if(!ZF(E))B0(E,`*
83
+ `);B0(D,u+`
84
+ `)}function N6(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 P8(D){if(!ZF(D))return{};try{return N6(G0(D,"utf8"))}catch{return{}}}function $0(D,u){let F=Z0(),E=D;while(!0){for(let $ of[Qu(E,".slack-term",".env.local"),Qu(E,".env.local")]){let G=P8($);for(let Z of u)if(G[Z])return G[Z]}if(E===F)break;let B=z0(E);if(B===E)break;E=B}let C=P8(Qu(F,".slack-term",".env.local"));for(let B of u)if(C[B])return C[B];return}function I8(){let D=fu(),u=Mu(JF()),F=Mu(XF()),E=u??F;return Object.entries(D.profiles).map(([C,B])=>({name:C,profile:B,current:C===E}))}function b8(D){let u=fu();if(!(D in u.profiles))throw Error(`Profile not found: ${D}`);delete u.profiles[D],L6(u)}function f8(D,u=!1){let F=fu();if(!(D in F.profiles))throw Error(`Profile not found: ${D}`);if(u)S8(XF(),D);else S8(JF(),D)}function J0(D){let F=fu().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=$0(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=$0(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 G=Mu(JF());if(G){let z=F[G];if(!z)throw Error(`Workspace "${G}" (from .slack-cli/workspace) not found in profiles.`);return z.token}let Z=Mu(XF());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(`Workspace not selected (${E.join(", ")} available).
87
87
  Select locally: slack auth use <name> (writes .slack-cli/workspace)
88
88
  Select globally: slack auth use -g <name> (writes ~/.slack-cli/workspace)`);throw Error(`No Slack token found.
89
89
  Run one of:
90
90
  `+` slack auth token — paste an existing xoxp-/xoxb- token
91
91
  `+` slack auth chrome — import from Chrome browser (macOS)
92
92
  `+` slack auth app — guided Slack app creation
93
- `+" Or set SLACK_TOKEN=xoxp-... in .slack-term/.env.local")}function J0(){let D=process.env.SLACK_BOT_TOKEN;return D&&D.startsWith("xoxb-")?D:void 0}function P8(D){let F=xu().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=B0(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 G=_u(ZF());if(G)return F[G]?.cookie;return}class lD extends Error{retryAfter;constructor(D){super(`Slack rate limited — retry after ${D}s`);this.name="RateLimitError",this.retryAfter=D}}function X0(){return(process.env.SLACK_API_BASE??"https://slack.com/api").replace(/\/$/,"")}async function w8(D,u,F,E){let C={};if(E)C.Cookie=`d=${E}`;let B=await fetch(`${X0()}/${u}`,{...F,headers:{...F.headers??{},Authorization:`Bearer ${D}`,...C}});if(B.status===429){let G=parseInt(B.headers.get("retry-after")??"60",10);throw new lD(isNaN(G)?60:G)}let $=await B.json();if($.ok!==!0){let G=$.error??"unknown";if(G==="ratelimited")throw new lD(60);if(G==="invalid_auth"&&D.startsWith("xoxc-")&&!E)throw Error(`Desktop app token (xoxc-) is not accepted by the public Slack API.
93
+ `+" Or set SLACK_TOKEN=xoxp-... in .slack-term/.env.local")}function X0(){let D=process.env.SLACK_BOT_TOKEN;return D&&D.startsWith("xoxb-")?D:void 0}function h8(D){let F=fu().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=$0(process.cwd(),["SLACK_COOKIE"]);if(C)return C;let B=process.env.SLACK_WORKSPACE;if(B)return F[B]?.cookie;let $=Mu(JF());if($)return F[$]?.cookie;let G=Mu(XF());if(G)return F[G]?.cookie;return}class lD extends Error{retryAfter;constructor(D){super(`Slack rate limited — retry after ${D}s`);this.name="RateLimitError",this.retryAfter=D}}function Q0(){return(process.env.SLACK_API_BASE??"https://slack.com/api").replace(/\/$/,"")}async function v8(D,u,F,E){let C={};if(E)C.Cookie=`d=${E}`;let B=await fetch(`${Q0()}/${u}`,{...F,headers:{...F.headers??{},Authorization:`Bearer ${D}`,...C}});if(B.status===429){let G=parseInt(B.headers.get("retry-after")??"60",10);throw new lD(isNaN(G)?60:G)}let $=await B.json();if($.ok!==!0){let G=$.error??"unknown";if(G==="ratelimited")throw new lD(60);if(G==="invalid_auth"&&D.startsWith("xoxc-")&&!E)throw Error(`Desktop app token (xoxc-) is not accepted by the public Slack API.
94
94
  Replace it with an xoxp- user token:
95
95
  slack auth token`);if((G==="missing_scope"||G==="cannot_dm_bot")&&D.startsWith("xoxb-"))throw Error(`Slack error on ${u}: ${G} — ${G==="cannot_dm_bot"?`you're authenticated as a bot, so "@you" is the bot itself and it can't DM itself`:"this bot token lacks the user scope this action needs"}.
96
96
  Tailing/DMing people and listing users need a user session, not a bot token.
97
97
  Switch workspace: slack auth ls then slack auth use <name>
98
- Or import your Slack desktop session: slack auth login`);throw Error(`Slack error on ${u}: ${G}`)}return $}async function _6(D,u,F,E){let C={};if(E)C.Cookie=`d=${E}`;let B=await fetch(`${X0()}/${u}`,{...F,headers:{...F.headers??{},Authorization:`Bearer ${D}`,...C}});if(B.status===429){let G=parseInt(B.headers.get("retry-after")??"60",10);throw new lD(isNaN(G)?60:G)}let $=await B.json();if($.ok!==!0){let G=$.error??"unknown";if(G==="ratelimited")throw new lD(60);if((G==="invalid_auth"||G==="not_authed")&&!D.startsWith("xoxc-"))throw Error(`The draft API requires a desktop app session token (xoxc-).
98
+ Or import your Slack desktop session: slack auth login`);throw Error(`Slack error on ${u}: ${G}`)}return $}async function T6(D,u,F,E){let C={};if(E)C.Cookie=`d=${E}`;let B=await fetch(`${Q0()}/${u}`,{...F,headers:{...F.headers??{},Authorization:`Bearer ${D}`,...C}});if(B.status===429){let G=parseInt(B.headers.get("retry-after")??"60",10);throw new lD(isNaN(G)?60:G)}let $=await B.json();if($.ok!==!0){let G=$.error??"unknown";if(G==="ratelimited")throw new lD(60);if((G==="invalid_auth"||G==="not_authed")&&!D.startsWith("xoxc-"))throw Error(`The draft API requires a desktop app session token (xoxc-).
99
99
  Import from Slack desktop: slack auth login`);if((G==="invalid_auth"||G==="not_authed")&&!E)throw Error(`drafts.list also requires the xoxd session cookie.
100
- Attach it with: slack auth chrome (macOS) or slack auth firefox`);throw Error(`Slack error on ${u}: ${G}`)}return $}function j6(D,u,F={},E){let C=new URLSearchParams({token:D,...F});return _6(D,u,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:C.toString()},E)}function OD(D,u,F,E){let C=new URLSearchParams(F).toString();return w8(D,`${u}?${C}`,{method:"GET"},E)}function A6(D,u,F){return w8(D,u,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(F)})}async function JF(D){let u=await OD(D,"auth.test",{});return{team:u.team??"",teamId:u.team_id??"",url:u.url??"",user:u.user??"",userId:u.user_id??""}}async function x8(D){let u=await fetch(`${X0()}/auth.test`,{method:"GET",headers:{Authorization:`Bearer ${D}`}});if(u.status===429){let C=parseInt(u.headers.get("retry-after")??"60",10);throw new lD(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 I8(D,u){let F=await OD(D,"bots.info",{bot:u});return{appId:F.bot?.app_id??"",userId:F.bot?.user_id??""}}async function Q0(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 OD(D,"conversations.history",B)}async function b8(D,u,F,E=50){return OD(D,"conversations.replies",{channel:u,ts:F,limit:String(E)})}async function L6(D,u){let E=(await A6(D,"conversations.open",{users:u})).channel?.id;if(!E)throw Error(`Failed to open DM with user ${u}`);return E}function Iu(D){return D.toLowerCase().replace(/[-_\s]/g,"")}function Y0(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 N6(D){return Y0(D)?.channel}async function f8(D,u,F){let E=N6(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),$=Iu(B);if(C){let Z=await OD(D,"auth.test",{},F);if($==="you"||$==="me"||Iu(Z.user??"")===$){let V=Z.user_id;if(!V)throw Error("auth.test did not return user_id");let M=((await OD(D,"conversations.list",{types:"im",limit:"200"},F)).channels??[]).find((_)=>_.user===V);if(M?.id)return String(M.id);return L6(D,V)}let J="",Q="";while(!0){let V={limit:"200"};if(Q)V.cursor=Q;let W=await OD(D,"users.list",V,F);for(let M of W.members??[]){let _=Iu(M.name??""),N=Iu(M.real_name??""),k=Iu(M.profile?.display_name??"");if(_===$||N===$||k&&k===$){J=M.id??"";break}}if(J)break;if(Q=W.response_metadata?.next_cursor??"",!Q)break}if(!J)throw Error(`User not found: ${u}`);let O="";while(!0){let V={types:"im",limit:"200"};if(O)V.cursor=O;let W=await OD(D,"conversations.list",V,F);for(let M of W.channels??[])if(M.user===J)return String(M.id??"");if(O=W.response_metadata?.next_cursor??"",!O)break}throw Error(`No existing DM with ${u} (${J}). Open it once in Slack first.`)}let G=B.toLowerCase(),z="";while(!0){let Z={limit:"200",types:"public_channel,private_channel",exclude_archived:"true"};if(z)Z.cursor=z;let Y=await OD(D,"conversations.list",Z,F);for(let J of Y.channels??[])if(String(J.name??"").toLowerCase()===G)return String(J.id??"");if(z=Y.response_metadata?.next_cursor??"",!z)break}throw Error(`channel not found: ${u}`)}async function XF(D,u){try{let F=await OD(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 QF(D,u){try{let F=await OD(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 YF(D){let u=[],F="";while(!0){let E={limit:"200"};if(F)E.cursor=F;let C=await OD(D,"users.list",E);if(u.push(...C.members??[]),F=C.response_metadata?.next_cursor??"",!F)break}return{members:u}}async function W0(D,u){let F=[],E="";while(!0){let C={channel:u,limit:"200"};if(E)C.cursor=E;let B=await OD(D,"conversations.members",C);if(F.push(...B.members??[]),E=B.response_metadata?.next_cursor??"",!E)break}return F}async function O0(D,u){return OD(D,"users.info",{user:u})}async function h8(D,u){return OD(D,"conversations.info",{channel:u})}async function v8(D,u){let F=await j6(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 T6=["chat:write","im:write"],R6=["im:history","im:read"];async function V0(D){let{userId:u,botId:F,team:E,scopes:C}=await x8(D),B="";if(F)try{B=(await I8(D,F)).appId}catch{B=""}let $=(Z)=>C.includes(Z),G=T6.filter((Z)=>!$(Z)),z=R6.filter((Z)=>!$(Z));return{canSend:G.length===0,canReceiveReplies:z.length===0,ok:G.length===0&&z.length===0,botUserId:u,appId:B,team:E,grantedScopes:C,missingSendScopes:G,missingReplyScopes:z}}function p8(D){return["",` Bot user: ${D.botUserId||"(unknown)"}`,` App ID: ${D.appId||"(unknown — bots.info unavailable)"}`,` Granted scopes: ${D.grantedScopes.join(", ")||"(none reported)"}`]}function H0(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,...p8(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,...p8(D)]}import{createInterface as Yu}from"node:readline/promises";import{join as A0}from"node:path";import{homedir as c6}from"node:os";import{existsSync as q0,readFileSync as U0,writeFileSync as m8,mkdirSync as c8}from"node:fs";import{homedir as S6}from"node:os";import{join as M0,dirname as g8}from"node:path";function k8(){return process.env.HOME||S6()}function d8(){return M0(k8(),".config","slack-cli","profiles.json")}function P6(){return M0(process.cwd(),".slack-cli","workspace")}function w6(){return M0(k8(),".slack-cli","workspace")}function K0(){let D=d8();if(!q0(D))return{profiles:{}};return JSON.parse(U0(D,"utf8"))}function i8(D){let u=d8();c8(g8(u),{recursive:!0}),m8(u,JSON.stringify(D,null,2)+`
101
- `)}function y8(D){if(!q0(D))return;return U0(D,"utf8").trim()||void 0}function n8(D,u){c8(g8(D),{recursive:!0});let F=q0(D)?U0(D,"utf8"):"",E=F?F.split(`
102
- `):[];for(let[C,B]of Object.entries(u)){let $=E.findIndex((z)=>{let Z=z.trim();return Z.startsWith(C+"=")||Z.startsWith(C+" =")}),G=`${C}=${B}`;if($!==-1)E[$]=G;else E.push(G)}m8(D,E.join(`
100
+ Attach it with: slack auth chrome (macOS) or slack auth firefox`);throw Error(`Slack error on ${u}: ${G}`)}return $}function R6(D,u,F={},E){let C=new URLSearchParams({token:D,...F});return T6(D,u,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:C.toString()},E)}function OD(D,u,F,E){let C=new URLSearchParams(F).toString();return v8(D,`${u}?${C}`,{method:"GET"},E)}function S6(D,u,F){return v8(D,u,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(F)})}async function QF(D){let u=await OD(D,"auth.test",{});return{team:u.team??"",teamId:u.team_id??"",url:u.url??"",user:u.user??"",userId:u.user_id??""}}async function p8(D){let u=await fetch(`${Q0()}/auth.test`,{method:"GET",headers:{Authorization:`Bearer ${D}`}});if(u.status===429){let C=parseInt(u.headers.get("retry-after")??"60",10);throw new lD(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 y8(D,u){let F=await OD(D,"bots.info",{bot:u});return{appId:F.bot?.app_id??"",userId:F.bot?.user_id??""}}async function Y0(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 OD(D,"conversations.history",B)}async function m8(D,u,F,E=50){return OD(D,"conversations.replies",{channel:u,ts:F,limit:String(E)})}async function P6(D,u){let E=(await S6(D,"conversations.open",{users:u})).channel?.id;if(!E)throw Error(`Failed to open DM with user ${u}`);return E}function hu(D){return D.toLowerCase().replace(/[-_\s]/g,"")}function W0(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 w6(D){return W0(D)?.channel}async function c8(D,u,F){let E=w6(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),$=hu(B);if(C){let z=await OD(D,"auth.test",{},F);if($==="you"||$==="me"||hu(z.user??"")===$){let V=z.user_id;if(!V)throw Error("auth.test did not return user_id");let U=((await OD(D,"conversations.list",{types:"im",limit:"200"},F)).channels??[]).find((_)=>_.user===V);if(U?.id)return String(U.id);return P6(D,V)}let J="",Y="";while(!0){let V={limit:"200"};if(Y)V.cursor=Y;let W=await OD(D,"users.list",V,F);for(let U of W.members??[]){let _=hu(U.name??""),M=hu(U.real_name??""),N=hu(U.profile?.display_name??"");if(_===$||M===$||N&&N===$){J=U.id??"";break}}if(J)break;if(Y=W.response_metadata?.next_cursor??"",!Y)break}if(!J)throw Error(`User not found: ${u}`);let O="";while(!0){let V={types:"im",limit:"200"};if(O)V.cursor=O;let W=await OD(D,"conversations.list",V,F);for(let U of W.channels??[])if(U.user===J)return String(U.id??"");if(O=W.response_metadata?.next_cursor??"",!O)break}throw Error(`No existing DM with ${u} (${J}). Open it once in Slack first.`)}let G=B.toLowerCase(),Z="";while(!0){let z={limit:"200",types:"public_channel,private_channel",exclude_archived:"true"};if(Z)z.cursor=Z;let Q=await OD(D,"conversations.list",z,F);for(let J of Q.channels??[])if(String(J.name??"").toLowerCase()===G)return String(J.id??"");if(Z=Q.response_metadata?.next_cursor??"",!Z)break}throw Error(`channel not found: ${u}`)}async function YF(D,u){try{let F=await OD(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 WF(D,u){try{let F=await OD(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,u){let F=[],E="";while(!0){let C={limit:"200"};if(E)C.cursor=E;let B=await OD(D,"users.list",C,u);if(F.push(...B.members??[]),E=B.response_metadata?.next_cursor??"",!E)break}return{members:F}}async function O0(D,u,F){let E=[],C="";while(!0){let B={channel:u,limit:"200"};if(C)B.cursor=C;let $=await OD(D,"conversations.members",B,F);if(E.push(...$.members??[]),C=$.response_metadata?.next_cursor??"",!C)break}return E}async function V0(D,u,F){return OD(D,"users.info",{user:u},F)}async function g8(D,u){return OD(D,"conversations.info",{channel:u})}async function k8(D,u){let F=await R6(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 x6=["chat:write","im:write"],I6=["im:history","im:read"];async function H0(D){let{userId:u,botId:F,team:E,scopes:C}=await p8(D),B="";if(F)try{B=(await y8(D,F)).appId}catch{B=""}let $=(z)=>C.includes(z),G=x6.filter((z)=>!$(z)),Z=I6.filter((z)=>!$(z));return{canSend:G.length===0,canReceiveReplies:Z.length===0,ok:G.length===0&&Z.length===0,botUserId:u,appId:B,team:E,grantedScopes:C,missingSendScopes:G,missingReplyScopes:Z}}function d8(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,...d8(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,...d8(D)]}import{createInterface as Wu}from"node:readline/promises";import{join as L0}from"node:path";import{homedir as n6}from"node:os";import{existsSync as K0,readFileSync as U0,writeFileSync as n8,mkdirSync as l8}from"node:fs";import{homedir as b6}from"node:os";import{join as _0,dirname as t8}from"node:path";function o8(){return process.env.HOME||b6()}function s8(){return _0(o8(),".config","slack-cli","profiles.json")}function f6(){return _0(process.cwd(),".slack-cli","workspace")}function h6(){return _0(o8(),".slack-cli","workspace")}function j0(){let D=s8();if(!K0(D))return{profiles:{}};return JSON.parse(U0(D,"utf8"))}function r8(D){let u=s8();l8(t8(u),{recursive:!0}),n8(u,JSON.stringify(D,null,2)+`
101
+ `)}function i8(D){if(!K0(D))return;return U0(D,"utf8").trim()||void 0}function a8(D,u){l8(t8(D),{recursive:!0});let F=K0(D)?U0(D,"utf8"):"",E=F?F.split(`
102
+ `):[];for(let[C,B]of Object.entries(u)){let $=E.findIndex((Z)=>{let z=Z.trim();return z.startsWith(C+"=")||z.startsWith(C+" =")}),G=`${C}=${B}`;if($!==-1)E[$]=G;else E.push(G)}n8(D,E.join(`
103
103
  `).trimEnd()+`
104
- `)}function WF(){let D=K0(),u=y8(P6()),F=y8(w6()),E=u??F;return Object.entries(D.profiles).map(([C,B])=>({name:C,profile:B,current:C===E}))}function _0(D,u){let F=K0();F.profiles[D]=u,i8(F)}function j0(D,u){let F=K0();if(!(D in F.profiles))throw Error(`Profile not found: ${D}`);F.profiles[D].cookie=u,i8(F)}import{readdirSync as OF,readFileSync as bu,existsSync as Qu,copyFileSync as l8,unlinkSync as t8}from"node:fs";import{homedir as VF,tmpdir as o8}from"node:os";import{join as ZD,dirname as x6}from"node:path";import{pbkdf2Sync as s8,createDecipheriv as r8}from"node:crypto";import{execSync as a8}from"node:child_process";function I6(){let D=VF();if(process.platform==="darwin")return ZD(D,"Library","Application Support","Slack","Local Storage","leveldb");if(process.platform==="linux")return ZD(D,".config","Slack","Local Storage","leveldb");if(process.platform==="win32"){let u=process.env.APPDATA??ZD(D,"AppData","Roaming");return ZD(u,"Slack","Local Storage","leveldb")}throw Error(`Unsupported platform: ${process.platform}`)}function b6(){let D=VF();if(process.platform==="darwin")return ZD(D,"Library","Application Support","Slack","Cookies");return""}function f6(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=r8("aes-128-cbc",u,F);return C.setAutoPadding(!0),Buffer.concat([C.update(E),C.final()]).toString("utf8")}function h6(){if(process.platform!=="darwin")return;let D=b6();if(!Qu(D))return;let u;try{u=a8('security find-generic-password -w -s "Slack Safe Storage" -a "Slack Key"',{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trimEnd()}catch{return}let F=s8(u,"saltysalt",1003,16,"sha1");try{let{default:E}=wD("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 f6(Buffer.from(B.encrypted_value),F)}catch{return}}async function e8(){let D=I6();if(!Qu(D))throw Error(`Slack desktop app LevelDB not found at:
104
+ `)}function VF(){let D=j0(),u=i8(f6()),F=i8(h6()),E=u??F;return Object.entries(D.profiles).map(([C,B])=>({name:C,profile:B,current:C===E}))}function M0(D,u){let F=j0();F.profiles[D]=u,r8(F)}function A0(D,u){let F=j0();if(!(D in F.profiles))throw Error(`Profile not found: ${D}`);F.profiles[D].cookie=u,r8(F)}import{readdirSync as HF,readFileSync as vu,existsSync as Yu,copyFileSync as e8,unlinkSync as D1}from"node:fs";import{homedir as qF,tmpdir as u1}from"node:os";import{join as ZD,dirname as v6}from"node:path";import{pbkdf2Sync as F1,createDecipheriv as E1}from"node:crypto";import{execSync as C1}from"node:child_process";function p6(){let D=qF();if(process.platform==="darwin")return ZD(D,"Library","Application Support","Slack","Local Storage","leveldb");if(process.platform==="linux")return ZD(D,".config","Slack","Local Storage","leveldb");if(process.platform==="win32"){let u=process.env.APPDATA??ZD(D,"AppData","Roaming");return ZD(u,"Slack","Local Storage","leveldb")}throw Error(`Unsupported platform: ${process.platform}`)}function y6(){let D=qF();if(process.platform==="darwin")return ZD(D,"Library","Application Support","Slack","Cookies");return""}function m6(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=E1("aes-128-cbc",u,F);return C.setAutoPadding(!0),Buffer.concat([C.update(E),C.final()]).toString("utf8")}function c6(){if(process.platform!=="darwin")return;let D=y6();if(!Yu(D))return;let u;try{u=C1('security find-generic-password -w -s "Slack Safe Storage" -a "Slack Key"',{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trimEnd()}catch{return}let F=F1(u,"saltysalt",1003,16,"sha1");try{let{default:E}=wD("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 m6(Buffer.from(B.encrypted_value),F)}catch{return}}async function B1(){let D=p6();if(!Yu(D))throw Error(`Slack desktop app LevelDB not found at:
105
105
  ${D}
106
- Is Slack installed and opened at least once?`);let u=OF(D).filter((G)=>G.endsWith(".ldb")||G.endsWith(".log"));if(u.length===0)throw Error(`No LevelDB data files found in ${D}`);let F=new Map;for(let G of u){let z;try{z=bu(ZD(D,G),"latin1")}catch{continue}if(G.endsWith(".log"))for(let Z of z.matchAll(/"token":"(xoxc-[^"]+)"/g)){let Y=Z[1],J=Y.split("-")[1]??"";if(!J||Y.length<40)continue;let Q=Math.max(0,Z.index-2000),O=Math.min(z.length,Z.index+2000),V=z.slice(Q,O),W=V.match(/"url":"(https:\/\/[a-z0-9-]+\.slack\.com\/)"/),M=V.match(/"(?:team_name|name)":"([^"]{2,60})"/),_=F.get(J);if(!_||Y.length>_.token.length){let N={token:Y,teamId:J},k=W?.[1]??_?.url,w=M?.[1]??_?.teamName;if(k)N.url=k;if(w)N.teamName=w;F.set(J,N)}}else for(let Z of z.matchAll(/xoxc-(\d+)-(\d+)-(\d+)/g)){let Y=Z[1];if(F.has(Y))continue;let J=Z.index+Z[0].length,Q=Math.min(J+10,z.length);while(J<Q&&(z.charCodeAt(J)<48||z.charCodeAt(J)>57))J++;let O="";while(J<z.length&&z.charCodeAt(J)>=48&&z.charCodeAt(J)<=57)O+=z[J++];if(z[J]!=="-")continue;J++;let V="";while(J<z.length){let M=z.charCodeAt(J);if(M>=48&&M<=57||M>=97&&M<=102)V+=z[J++];else break}if(V.length<20)continue;let W=`${Z[0]}${O}-${V}`;F.set(Y,{token:W,teamId:Y})}}let C=OF(D).filter((G)=>G.endsWith(".ldb")||G.endsWith(".log")).map((G)=>{try{return bu(ZD(D,G),"latin1").replace(/[^\x20-\x7e]/g," ")}catch{return""}}).join(" ");for(let G of F.values()){if(G.teamName)continue;let z=C.indexOf(G.teamId);if(z!==-1){let Z=Math.max(0,z-500),Y=Math.min(C.length,z+500),Q=C.slice(Z,Y).match(/"(?:team_name|name)":"([^"]{2,60})"/);if(Q?.[1]){G.teamName=Q[1];continue}}if(!G.teamName&&G.url){let Z=G.url.match(/https:\/\/([a-z0-9-]+)\.slack\.com\//)?.[1];if(Z){let Y=C.indexOf(Z);if(Y!==-1){let J=Math.max(0,Y-500),Q=Math.min(C.length,Y+500),V=C.slice(J,Q).match(/"(?:team_name|name)":"([^"]{2,60})"/);if(V?.[1]){G.teamName=V[1];continue}}G.teamName=Z.split("-").map((J)=>J.charAt(0).toUpperCase()+J.slice(1)).join(" ")}}}let B=h6(),$=[...F.values()];if(B)for(let G of $)G.cookie=B;return $}function v6(D,u){let F=(E,C)=>{try{let B=r8("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 p6(D,u){let F=(E,C)=>{if(E&&C)return`${E} (${C})`;return E||C||u};try{let C=JSON.parse(bu(ZD(D,"Local State"),"utf8")).profile?.info_cache?.[u];if(C&&(C.name||C.user_name))return F(C.name??"",C.user_name??"")}catch{}try{let C=JSON.parse(bu(ZD(D,u,"Preferences"),"utf8")).profile;return F(C?.name??"",C?.user_name??"")}catch{return u}}function D1(){if(process.platform!=="darwin")return{candidates:[],totalProfiles:0};let D=ZD(VF(),"Library","Application Support","Google","Chrome");if(!Qu(D))return{candidates:[],totalProfiles:0};let u;try{u=a8('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=s8(u,"saltysalt",1003,16,"sha1"),E=["Default",...OF(D).filter((B)=>B.startsWith("Profile "))],C=[];for(let B of E){let $=ZD(D,B,"Cookies");if(!Qu($))continue;let G=ZD(o8(),`slack-chrome-cookies-${Date.now()}-${B}.db`);try{l8($,G);let{default:z}=wD("bun:sqlite"),Z=new z(G,{readonly:!0}),Y=Z.prepare("SELECT encrypted_value FROM cookies WHERE name='d' AND host_key LIKE '%slack%'").get();if(Z.close(),!Y)continue;let J=Buffer.from(Y.encrypted_value),Q=J.slice(0,3).toString();if(Q==="v10"){let O=v6(J,F);if(!O)continue;C.push({profileDir:B,profileName:p6(D,B),cookie:O})}else if(Q==="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(z){if(z instanceof Error&&(z.message.includes("app-bound")||z.message.includes("Unknown cookie")))throw z}finally{try{t8(G)}catch{}}}return{candidates:C,totalProfiles:E.length}}function y6(){let D=VF();if(process.platform==="darwin")return ZD(D,"Library","Application Support","Firefox","Profiles");if(process.platform==="linux")return ZD(D,".mozilla","firefox");if(process.platform==="win32")return ZD(process.env.APPDATA??ZD(D,"AppData","Roaming"),"Mozilla","Firefox","Profiles");return""}function m6(D){let u=ZD(x6(D),"profiles.ini"),F={};if(!Qu(u))return F;try{let E=bu(u,"utf8"),C="",B="";for(let $ of E.split(`
107
- `)){let G=$.trim();if(G.startsWith("[")){C="",B="";continue}let z=G.indexOf("=");if(z===-1)continue;let Z=G.slice(0,z).trim().toLowerCase(),Y=G.slice(z+1).trim();if(Z==="name")C=Y;if(Z==="path")B=Y.split(/[\\/]/).pop()??Y;if(C&&B)F[B]=C,C="",B=""}}catch{}return F}function u1(){let D=y6();if(!D||!Qu(D))return[];let u=m6(D),F=[],E;try{E=OF(D)}catch{return[]}for(let C of E){let B=ZD(D,C,"cookies.sqlite");if(!Qu(B))continue;let $=ZD(o8(),`slack-firefox-cookies-${Date.now()}-${C}.db`);try{l8(B,$);let{default:G}=wD("bun:sqlite"),z=new G($,{readonly:!0}),Z=z.prepare("SELECT value FROM moz_cookies WHERE name='d' AND host LIKE '%slack%' LIMIT 1").get();if(z.close(),!Z?.value||!Z.value.startsWith("xoxd-"))continue;let Y=u[C]??C;F.push({profileDir:C,profileName:Y,cookie:Z.value})}catch{}finally{try{t8($)}catch{}}}return F}var g6=["search:read","channels:history","groups:history","im:history","mpim:history","channels:read","groups:read","im:read","mpim:read","users:read","chat:write","files:write"],k6=["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 d6(){return JSON.stringify({display_information:{name:"slack-term"},oauth_config:{scopes:{user:g6}},settings:{org_deploy_enabled:!1,socket_mode_enabled:!1,token_rotation_enabled:!1}},null,2)}function i6(){return JSON.stringify({display_information:{name:"slack-term"},features:{bot_user:{display_name:"slack-term",always_online:!1}},oauth_config:{scopes:{bot:k6}},settings:{org_deploy_enabled:!1,socket_mode_enabled:!1,token_rotation_enabled:!1}},null,2)}async function Wu(D,u){return(await D.question(u)).trim()}async function Ou(D,u,F,E){console.error("Verifying token...");let C=await JF(u),B=HF(C.team),$;if(F)$=F;else if(D)$=await Wu(D,`Workspace name [${B}]: `)||B;else $=B;let G=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 z=await Wu(D,"Choice [1/2/3/4, Enter=1]: ");if(z==="2")G=A0(process.cwd(),".slack-term",".env.local");else if(z==="3")G=A0(c6(),".slack-term",".env.local");else if(z==="4")G=null;else G=A0(process.cwd(),".env.local")}if(G===null)if(_0($,{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 z={SLACK_TOKEN:u};if(E)z.SLACK_COOKIE=E;n8(G,z),console.log(`Saved token to ${G}`),console.log(" SLACK_TOKEN will be picked up automatically in this directory tree.")}return $}async function n6(D){console.error("Scanning Slack desktop app...");let u=await e8();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);_0(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 F1(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 Wu(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 Wu(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 qF(D,u){let F=u==="user"?d6():i6(),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 Wu(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 E1(D={}){if(process.platform!=="darwin")console.error("Chrome cookie extraction is only supported on macOS."),process.exit(1);let u=WF();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 G=u.find((z)=>z.current);if(G)F=G.name,console.log(`Using active workspace: ${F}`);else{console.log("Multiple workspaces found. Choose one:"),u.forEach((J,Q)=>console.log(` ${Q+1}) ${J.name} (${J.profile.team})`));let z=Yu({input:process.stdin,output:process.stdout}),Z=(await z.question("Choice: ")).trim();z.close();let Y=parseInt(Z,10)-1;if(isNaN(Y)||Y<0||Y>=u.length)console.error("Invalid choice."),process.exit(1);F=u[Y].name}}if(u.find((G)=>G.name===F).profile.token.startsWith("xoxb-")){console.error(`
106
+ Is Slack installed and opened at least once?`);let u=HF(D).filter((G)=>G.endsWith(".ldb")||G.endsWith(".log"));if(u.length===0)throw Error(`No LevelDB data files found in ${D}`);let F=new Map;for(let G of u){let Z;try{Z=vu(ZD(D,G),"latin1")}catch{continue}if(G.endsWith(".log"))for(let z of Z.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),O=Math.min(Z.length,z.index+2000),V=Z.slice(Y,O),W=V.match(/"url":"(https:\/\/[a-z0-9-]+\.slack\.com\/)"/),U=V.match(/"(?:team_name|name)":"([^"]{2,60})"/),_=F.get(J);if(!_||Q.length>_.token.length){let M={token:Q,teamId:J},N=W?.[1]??_?.url,A=U?.[1]??_?.teamName;if(N)M.url=N;if(A)M.teamName=A;F.set(J,M)}}else for(let z of Z.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,Z.length);while(J<Y&&(Z.charCodeAt(J)<48||Z.charCodeAt(J)>57))J++;let O="";while(J<Z.length&&Z.charCodeAt(J)>=48&&Z.charCodeAt(J)<=57)O+=Z[J++];if(Z[J]!=="-")continue;J++;let V="";while(J<Z.length){let U=Z.charCodeAt(J);if(U>=48&&U<=57||U>=97&&U<=102)V+=Z[J++];else break}if(V.length<20)continue;let W=`${z[0]}${O}-${V}`;F.set(Q,{token:W,teamId:Q})}}let C=HF(D).filter((G)=>G.endsWith(".ldb")||G.endsWith(".log")).map((G)=>{try{return vu(ZD(D,G),"latin1").replace(/[^\x20-\x7e]/g," ")}catch{return""}}).join(" ");for(let G of F.values()){if(G.teamName)continue;let Z=C.indexOf(G.teamId);if(Z!==-1){let z=Math.max(0,Z-500),Q=Math.min(C.length,Z+500),Y=C.slice(z,Q).match(/"(?:team_name|name)":"([^"]{2,60})"/);if(Y?.[1]){G.teamName=Y[1];continue}}if(!G.teamName&&G.url){let z=G.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),V=C.slice(J,Y).match(/"(?:team_name|name)":"([^"]{2,60})"/);if(V?.[1]){G.teamName=V[1];continue}}G.teamName=z.split("-").map((J)=>J.charAt(0).toUpperCase()+J.slice(1)).join(" ")}}}let B=c6(),$=[...F.values()];if(B)for(let G of $)G.cookie=B;return $}function g6(D,u){let F=(E,C)=>{try{let B=E1("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 k6(D,u){let F=(E,C)=>{if(E&&C)return`${E} (${C})`;return E||C||u};try{let C=JSON.parse(vu(ZD(D,"Local State"),"utf8")).profile?.info_cache?.[u];if(C&&(C.name||C.user_name))return F(C.name??"",C.user_name??"")}catch{}try{let C=JSON.parse(vu(ZD(D,u,"Preferences"),"utf8")).profile;return F(C?.name??"",C?.user_name??"")}catch{return u}}function $1(){if(process.platform!=="darwin")return{candidates:[],totalProfiles:0};let D=ZD(qF(),"Library","Application Support","Google","Chrome");if(!Yu(D))return{candidates:[],totalProfiles:0};let u;try{u=C1('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=F1(u,"saltysalt",1003,16,"sha1"),E=["Default",...HF(D).filter((B)=>B.startsWith("Profile "))],C=[];for(let B of E){let $=ZD(D,B,"Cookies");if(!Yu($))continue;let G=ZD(u1(),`slack-chrome-cookies-${Date.now()}-${B}.db`);try{e8($,G);let{default:Z}=wD("bun:sqlite"),z=new Z(G,{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 O=g6(J,F);if(!O)continue;C.push({profileDir:B,profileName:k6(D,B),cookie:O})}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(Z){if(Z instanceof Error&&(Z.message.includes("app-bound")||Z.message.includes("Unknown cookie")))throw Z}finally{try{D1(G)}catch{}}}return{candidates:C,totalProfiles:E.length}}function d6(){let D=qF();if(process.platform==="darwin")return ZD(D,"Library","Application Support","Firefox","Profiles");if(process.platform==="linux")return ZD(D,".mozilla","firefox");if(process.platform==="win32")return ZD(process.env.APPDATA??ZD(D,"AppData","Roaming"),"Mozilla","Firefox","Profiles");return""}function i6(D){let u=ZD(v6(D),"profiles.ini"),F={};if(!Yu(u))return F;try{let E=vu(u,"utf8"),C="",B="";for(let $ of E.split(`
107
+ `)){let G=$.trim();if(G.startsWith("[")){C="",B="";continue}let Z=G.indexOf("=");if(Z===-1)continue;let z=G.slice(0,Z).trim().toLowerCase(),Q=G.slice(Z+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 G1(){let D=d6();if(!D||!Yu(D))return[];let u=i6(D),F=[],E;try{E=HF(D)}catch{return[]}for(let C of E){let B=ZD(D,C,"cookies.sqlite");if(!Yu(B))continue;let $=ZD(u1(),`slack-firefox-cookies-${Date.now()}-${C}.db`);try{e8(B,$);let{default:G}=wD("bun:sqlite"),Z=new G($,{readonly:!0}),z=Z.prepare("SELECT value FROM moz_cookies WHERE name='d' AND host LIKE '%slack%' LIMIT 1").get();if(Z.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{D1($)}catch{}}}return F}var l6=["search:read","channels:history","groups:history","im:history","mpim:history","channels:read","groups:read","im:read","mpim:read","users:read","chat:write","files:write"],t6=["channels:history","groups:history","im:history","mpim:history","channels:read","groups:read","im:read","mpim:read","users:read","chat:write","files:write"];function KF(D){return D.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function o6(){return JSON.stringify({display_information:{name:"slack-term"},oauth_config:{scopes:{user:l6}},settings:{org_deploy_enabled:!1,socket_mode_enabled:!1,token_rotation_enabled:!1}},null,2)}function s6(){return JSON.stringify({display_information:{name:"slack-term"},features:{bot_user:{display_name:"slack-term",always_online:!1}},oauth_config:{scopes:{bot:t6}},settings:{org_deploy_enabled:!1,socket_mode_enabled:!1,token_rotation_enabled:!1}},null,2)}async function Ou(D,u){return(await D.question(u)).trim()}async function Vu(D,u,F,E){console.error("Verifying token...");let C=await QF(u),B=KF(C.team),$;if(F)$=F;else if(D)$=await Ou(D,`Workspace name [${B}]: `)||B;else $=B;let G=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 Z=await Ou(D,"Choice [1/2/3/4, Enter=1]: ");if(Z==="2")G=L0(process.cwd(),".slack-term",".env.local");else if(Z==="3")G=L0(n6(),".slack-term",".env.local");else if(Z==="4")G=null;else G=L0(process.cwd(),".env.local")}if(G===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 Z={SLACK_TOKEN:u};if(E)Z.SLACK_COOKIE=E;a8(G,Z),console.log(`Saved token to ${G}`),console.log(" SLACK_TOKEN will be picked up automatically in this directory tree.")}return $}async function r6(D){console.error("Scanning Slack desktop app...");let u=await B1();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 Vu(D,F.token,KF(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=KF(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=KF(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 z1(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 Ou(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 Ou(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 Vu(D,B)}async function UF(D,u){let F=u==="user"?o6():s6(),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 Ou(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 Vu(D,B)}async function Z1(D={}){if(process.platform!=="darwin")console.error("Chrome cookie extraction is only supported on macOS."),process.exit(1);let u=VF();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 G=u.find((Z)=>Z.current);if(G)F=G.name,console.log(`Using active workspace: ${F}`);else{console.log("Multiple workspaces found. Choose one:"),u.forEach((J,Y)=>console.log(` ${Y+1}) ${J.name} (${J.profile.team})`));let Z=Wu({input:process.stdin,output:process.stdout}),z=(await Z.question("Choice: ")).trim();Z.close();let Q=parseInt(z,10)-1;if(isNaN(Q)||Q<0||Q>=u.length)console.error("Invalid choice."),process.exit(1);F=u[Q].name}}if(u.find((G)=>G.name===F).profile.token.startsWith("xoxb-")){console.error(`
108
108
  Workspace "${F}" uses a bot token (xoxb-). A Chrome session cookie only
109
109
  `+`augments a user session token (xoxc-) — it has no effect on a bot token, so user-level
110
- `+"actions (tail @user, DMs, listing users) would still fail.");let G=u.filter((z)=>z.profile.token.startsWith("xoxc-")||z.profile.token.startsWith("xoxp-"));if(G.length>0)console.error(` Target a user-token workspace instead: ${G.map((z)=>z.name).join(", ")}`),console.error(` slack auth chrome -w ${G[0].name}`);else console.error(" Import your Slack desktop user session instead: slack auth login");process.exit(1)}console.log("Scanning Chrome profiles for Slack session..."),console.log("macOS may show a dialog asking for your login password — click Allow.");let C,B;try{({candidates:C,totalProfiles:B}=D1())}catch(G){console.error(`Failed: ${G instanceof Error?G.message:String(G)}`),process.exit(1)}if(C.length===0)console.error(`No Slack session found in Chrome (scanned ${B} profile${B!==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 $;if(C.length===1&&B<=1)$=C[0].cookie,console.log(`Found session in Chrome profile: ${C[0].profileName}`);else{let G=C.length===1?`Found 1 Slack session across ${B} Chrome profiles:`:`Found ${C.length} Slack sessions across ${B} Chrome profiles:`;console.log(G),C.forEach((Q,O)=>console.log(` ${O+1}) ${Q.profileName} [${Q.profileDir}]`)),console.log("");let z=Yu({input:process.stdin,output:process.stdout}),Z=C.length===1?" [Enter=1]":"",Y=(await z.question(`Choice [1-${C.length}]${Z}: `)).trim();z.close();let J=Y===""&&C.length===1?0:parseInt(Y,10)-1;if(isNaN(J)||J<0||J>=C.length)console.error("Invalid choice."),process.exit(1);$=C[J].cookie}j0(F,$),console.log(`Saved xoxd cookie to workspace "${F}".`),console.log("RTM WebSocket mode is now available: slack tail @you")}async function C1(D={}){let u=WF();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,Y)=>console.log(` ${Y+1}) ${Z.name} (${Z.profile.team})`));let $=Yu({input:process.stdin,output:process.stdout}),G=(await $.question("Choice: ")).trim();$.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 Firefox profiles for Slack session...");let E=u1();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((z,Z)=>console.log(` ${Z+1}) ${z.profileName} [${z.profileDir}]`));let B=Yu({input:process.stdin,output:process.stdout}),$=(await B.question("Choice: ")).trim();B.close();let G=parseInt($,10)-1;if(isNaN(G)||G<0||G>=E.length)console.error("Invalid choice."),process.exit(1);C=E[G].cookie}j0(F,C),console.log(`Saved xoxd cookie to workspace "${F}".`),console.log("RTM WebSocket mode is now available: slack tail @you")}async function B1(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=Yu({input:process.stdin,output:process.stdout});try{await F1(u)}finally{u.close()}}async function $1(D={}){let u=Yu({input:process.stdin,output:process.stdout});try{if(D.bot!==void 0){await qF(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 Wu(u,"Choice [1/2, Enter=1]: ");await qF(u,F==="2"?"bot":"user")}finally{u.close()}}async function UF(D={}){let u=WF();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=Yu({input:process.stdin,output:process.stdout});try{let E=await Wu(F,"Choice [1/2/3/4]: ");if(console.log(""),E==="1")await n6(F);else if(E==="2")await F1(F);else if(E==="3")await qF(F,"user");else if(E==="4")await qF(F,"bot");else console.error(`Invalid choice: "${E}". Enter 1, 2, 3, or 4.`),process.exit(1)}finally{F.close()}}async function MF(D,u,F){let E=u,C=[],B=E,$=0;while(!0){let G=B.indexOf("<@U",$);if(G===-1)break;let z=B.slice(G+2),Z=z.search(/[>|]/),Y=Z===-1?z:z.slice(0,Z);if(Y.length>=9)C.push(Y);$=G+1}for(let G of C){if(!F.has(G))F.set(G,await QF(D,G));let z=F.get(G)??G;E=E.replaceAll(`<@${G}>`,`@${z}`),E=E.replace(new RegExp(`<@${G}\\|[^>]*>`,"g"),`@${z}`)}return E}function KF(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"],G=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],z=$[B.getUTCDay()]??"",Z=G[B.getUTCMonth()]??"";return`${z}, ${Z} ${String(B.getUTCDate()).padStart(2,"0")}, ${B.getUTCFullYear()}`})}function z1(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"),G=String(E.getUTCHours()).padStart(2,"0"),z=String(E.getUTCMinutes()).padStart(2,"0"),Z=String(E.getUTCSeconds()).padStart(2,"0"),Y=F.padEnd(6,"0").slice(0,6);return`${C}-${B}-${$}T${G}:${z}:${Z}.${Y}`}async function t6(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,Q="@"+J;if(!F.has(Q)){let[,O]=await XF(D,J);F.set(Q,O)}B=F.get(Q)??J}else if(typeof u.username==="string")B=u.username;let $=typeof u.text==="string"?u.text:"",z=KF(await MF(D,$,F)).split(`
111
- `),Z=z[0]+(z.length>1?`
112
- `+z.slice(1).map((J)=>` ${J}`).join(`
113
- `):""),Y=z1(u)?"↳ ":"";return`${C} ${Y}@${B}: ${Z}`}async function o6(D,u,F,E,C,B,$,G){if(G?.aborted)return;return new Promise((z)=>{let Z=new D(F);G?.addEventListener("abort",()=>{Z.close(),z()},{once:!0}),Z.addEventListener("open",()=>{process.stderr.write(`Connected via RTM (experimental).
114
- `)}),Z.addEventListener("close",()=>z()),Z.addEventListener("error",()=>z()),Z.addEventListener("message",(Y)=>{(async()=>{try{let J;try{J=JSON.parse(String(Y.data))}catch{return}let Q=typeof J.type==="string"?J.type:"";if(Q==="ping"){Z.send(JSON.stringify({type:"pong",reply_to:J.id??0}));return}if(Q!=="message")return;if((typeof J.channel==="string"?J.channel:"")!==E)return;let V=typeof J.ts==="string"?J.ts:"";if(!V||B.has(V))return;let W=typeof J.subtype==="string"?J.subtype:"";if(W==="message_changed"||W==="message_deleted")return;if(C.thread){if((typeof J.thread_ts==="string"?J.thread_ts:V)!==C.thread&&V!==C.thread)return}if(C.watchThread&&z1(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(V),B.size>1000){let _=B.values().next().value;if(_!==void 0)B.delete(_)}let M=await t6(u,J,$);process.stdout.write(M+`
110
+ `+"actions (tail @user, DMs, listing users) would still fail.");let G=u.filter((Z)=>Z.profile.token.startsWith("xoxc-")||Z.profile.token.startsWith("xoxp-"));if(G.length>0)console.error(` Target a user-token workspace instead: ${G.map((Z)=>Z.name).join(", ")}`),console.error(` slack auth chrome -w ${G[0].name}`);else console.error(" Import your Slack desktop user session instead: slack auth login");process.exit(1)}console.log("Scanning Chrome profiles for Slack session..."),console.log("macOS may show a dialog asking for your login password — click Allow.");let C,B;try{({candidates:C,totalProfiles:B}=$1())}catch(G){console.error(`Failed: ${G instanceof Error?G.message:String(G)}`),process.exit(1)}if(C.length===0)console.error(`No Slack session found in Chrome (scanned ${B} profile${B!==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 $;if(C.length===1&&B<=1)$=C[0].cookie,console.log(`Found session in Chrome profile: ${C[0].profileName}`);else{let G=C.length===1?`Found 1 Slack session across ${B} Chrome profiles:`:`Found ${C.length} Slack sessions across ${B} Chrome profiles:`;console.log(G),C.forEach((Y,O)=>console.log(` ${O+1}) ${Y.profileName} [${Y.profileDir}]`)),console.log("");let Z=Wu({input:process.stdin,output:process.stdout}),z=C.length===1?" [Enter=1]":"",Q=(await Z.question(`Choice [1-${C.length}]${z}: `)).trim();Z.close();let J=Q===""&&C.length===1?0:parseInt(Q,10)-1;if(isNaN(J)||J<0||J>=C.length)console.error("Invalid choice."),process.exit(1);$=C[J].cookie}A0(F,$),console.log(`Saved xoxd cookie to workspace "${F}".`),console.log("RTM WebSocket mode is now available: slack tail @you")}async function J1(D={}){let u=VF();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 $=Wu({input:process.stdin,output:process.stdout}),G=(await $.question("Choice: ")).trim();$.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 Firefox profiles for Slack session...");let E=G1();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((Z,z)=>console.log(` ${z+1}) ${Z.profileName} [${Z.profileDir}]`));let B=Wu({input:process.stdin,output:process.stdout}),$=(await B.question("Choice: ")).trim();B.close();let G=parseInt($,10)-1;if(isNaN(G)||G<0||G>=E.length)console.error("Invalid choice."),process.exit(1);C=E[G].cookie}A0(F,C),console.log(`Saved xoxd cookie to workspace "${F}".`),console.log("RTM WebSocket mode is now available: slack tail @you")}async function X1(D={}){if(D.token){await Vu(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 Vu(null,E,D.name);return}let u=Wu({input:process.stdin,output:process.stdout});try{await z1(u)}finally{u.close()}}async function Q1(D={}){let u=Wu({input:process.stdin,output:process.stdout});try{if(D.bot!==void 0){await UF(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 Ou(u,"Choice [1/2, Enter=1]: ");await UF(u,F==="2"?"bot":"user")}finally{u.close()}}async function _F(D={}){let u=VF();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 Vu(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 Vu(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=Wu({input:process.stdin,output:process.stdout});try{let E=await Ou(F,"Choice [1/2/3/4]: ");if(console.log(""),E==="1")await r6(F);else if(E==="2")await z1(F);else if(E==="3")await UF(F,"user");else if(E==="4")await UF(F,"bot");else console.error(`Invalid choice: "${E}". Enter 1, 2, 3, or 4.`),process.exit(1)}finally{F.close()}}async function jF(D,u,F){let E=u,C=[],B=E,$=0;while(!0){let G=B.indexOf("<@U",$);if(G===-1)break;let Z=B.slice(G+2),z=Z.search(/[>|]/),Q=z===-1?Z:Z.slice(0,z);if(Q.length>=9)C.push(Q);$=G+1}for(let G of C){if(!F.has(G))F.set(G,await WF(D,G));let Z=F.get(G)??G;E=E.replaceAll(`<@${G}>`,`@${Z}`),E=E.replace(new RegExp(`<@${G}\\|[^>]*>`,"g"),`@${Z}`)}return E}function MF(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"],G=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Z=$[B.getUTCDay()]??"",z=G[B.getUTCMonth()]??"";return`${Z}, ${z} ${String(B.getUTCDate()).padStart(2,"0")}, ${B.getUTCFullYear()}`})}function W1(D){let u=typeof D.ts==="string"?D.ts:"",F=typeof D.thread_ts==="string"?D.thread_ts:"";return F!==""&&F!==u}function a6(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"),G=String(E.getUTCHours()).padStart(2,"0"),Z=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${G}:${Z}:${z}.${Q}`}async function e6(D,u,F){let E=typeof u.ts==="string"?u.ts:"0.000000",C=a6(E),B="?";if(typeof u.user==="string"){let J=u.user,Y="@"+J;if(!F.has(Y)){let[,O]=await YF(D,J);F.set(Y,O)}B=F.get(Y)??J}else if(typeof u.username==="string")B=u.username;let $=typeof u.text==="string"?u.text:"",Z=MF(await jF(D,$,F)).split(`
111
+ `),z=Z[0]+(Z.length>1?`
112
+ `+Z.slice(1).map((J)=>` ${J}`).join(`
113
+ `):""),Q=W1(u)?"↳ ":"";return`${C} ${Q}@${B}: ${z}`}async function D7(D,u,F,E,C,B,$,G){if(G?.aborted)return;return new Promise((Z)=>{let z=new D(F);G?.addEventListener("abort",()=>{z.close(),Z()},{once:!0}),z.addEventListener("open",()=>{process.stderr.write(`Connected via RTM (experimental).
114
+ `)}),z.addEventListener("close",()=>Z()),z.addEventListener("error",()=>Z()),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 V=typeof J.ts==="string"?J.ts:"";if(!V||B.has(V))return;let W=typeof J.subtype==="string"?J.subtype:"";if(W==="message_changed"||W==="message_deleted")return;if(C.thread){if((typeof J.thread_ts==="string"?J.thread_ts:V)!==C.thread&&V!==C.thread)return}if(C.watchThread&&W1(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(V),B.size>1000){let _=B.values().next().value;if(_!==void 0)B.delete(_)}let U=await e6(u,J,$);process.stdout.write(U+`
115
115
  `)}catch(J){process.stderr.write(`RTM message error: ${J instanceof Error?J.message:String(J)}
116
- `)}})()})})}var G1=3,s6=2000,L0={sleep:(D)=>new Promise((u)=>setTimeout(u,D)),clientBoot:v8,getWebSocket:()=>{let D=globalThis.WebSocket;return typeof D==="function"?D:void 0}};async function Z1(D,u,F,E,C,B,$){let G=L0.getWebSocket();if(!G)return;for(let z=0;z<G1;z++){if($?.aborted)return;try{let{wsUrl:Z}=await L0.clientBoot(D,u);await o6(G,D,Z,F,E,C,B,$)}catch{}if($?.aborted)return;if(z<G1-1)await L0.sleep(s6)}}function J1(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:Z1};function pD(D){return D&&typeof D==="object"&&!Array.isArray(D)?D:{}}function N0(D){return Array.isArray(D)?D:[]}function X1(D){return Number(D)||0}function Q1(D){let u=typeof D.ts==="string"?D.ts:"",F=typeof D.thread_ts==="string"?D.thread_ts:"";return F!==""&&F!==u}function r6(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"),G=String(E.getUTCHours()).padStart(2,"0"),z=String(E.getUTCMinutes()).padStart(2,"0"),Z=String(E.getUTCSeconds()).padStart(2,"0"),Y=F.padEnd(6,"0").slice(0,6);return`${C}-${B}-${$}T${G}:${z}:${Z}.${Y}`}async function a6(D,u,F,E){let C=typeof u.ts==="string"?u.ts:"0.000000",B=r6(C),$="?";if(typeof u.user==="string"){let O=u.user,V="@"+O;if(!F.has(V)){let[,W]=await XF(D,O);F.set(V,W)}$=F.get(V)??O}else if(typeof u.username==="string")$=u.username;let G=typeof u.text==="string"?u.text:"",Z=KF(await MF(D,G,F)).split(`
117
- `),Y=Z[0]+(Z.length>1?`
118
- `+Z.slice(1).map((O)=>` ${O}`).join(`
119
- `):""),J=Q1(u)?"↳ ":"",Q=E?`${E} @${$}`:`@${$}`;return`${B} ${J}${Q}: ${Y}`}async function e6(D,u,F,E,C,B,$){let G=pD(await Q0(D,u,20,$?void 0:F||void 0,$)),z=N0(G.messages).map(pD).reverse(),Z=pD(G.response_metadata),Y=G.has_more===!0&&typeof Z.next_cursor==="string"?Z.next_cursor:void 0,J=[];if(E.watchThread&&!$){let M=pD(await b8(D,u,E.watchThread,50));J=N0(M.messages).map(pD).filter((_)=>(typeof _.ts==="string"?_.ts:"")!==E.watchThread)}let Q=[...z.map((M)=>({m:M,fromHistory:!0})),...J.map((M)=>({m:M,fromHistory:!1}))].sort((M,_)=>X1(typeof M.m.ts==="string"?M.m.ts:"")-X1(typeof _.m.ts==="string"?_.m.ts:"")),O=[],V=F,W=!1;for(let{m:M,fromHistory:_}of Q){let N=typeof M.ts==="string"?M.ts:"";if(!N||C.has(N))continue;let k=typeof M.subtype==="string"?M.subtype:"";if(k==="message_changed"||k==="message_deleted")continue;if(E.thread){if((typeof M.thread_ts==="string"?M.thread_ts:N)!==E.thread&&N!==E.thread)continue}if(E.watchThread&&Q1(M)){if((typeof M.thread_ts==="string"?M.thread_ts:"")!==E.watchThread)continue}if(E.me&&E.myUserId){if(!(typeof M.text==="string"?M.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(O.push(await a6(D,M,B)),_)V=N;let w=typeof M.user==="string"?M.user:"";if(!E.myUserId||w!==E.myUserId)W=!0}return{newCursor:V,lines:O,hasMore:G.has_more===!0,nextPageCursor:Y,emittedOther:W}}function D7(D){if(D.includes("slack.com")){let u=Y0(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 Y1(D,u,F={},E){if(F.me&&!u)console.error(`slack tail --me requires a <target> channel.
116
+ `)}})()})})}var Y1=3,u7=2000,N0={sleep:(D)=>new Promise((u)=>setTimeout(u,D)),clientBoot:k8,getWebSocket:()=>{let D=globalThis.WebSocket;return typeof D==="function"?D:void 0}};async function O1(D,u,F,E,C,B,$){let G=N0.getWebSocket();if(!G)return;for(let Z=0;Z<Y1;Z++){if($?.aborted)return;try{let{wsUrl:z}=await N0.clientBoot(D,u);await D7(G,D,z,F,E,C,B,$)}catch{}if($?.aborted)return;if(Z<Y1-1)await N0.sleep(u7)}}function V1(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:O1};function pD(D){return D&&typeof D==="object"&&!Array.isArray(D)?D:{}}function T0(D){return Array.isArray(D)?D:[]}function H1(D){return Number(D)||0}function q1(D){let u=typeof D.ts==="string"?D.ts:"",F=typeof D.thread_ts==="string"?D.thread_ts:"";return F!==""&&F!==u}function F7(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"),G=String(E.getUTCHours()).padStart(2,"0"),Z=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${G}:${Z}:${z}.${Q}`}async function E7(D,u,F,E){let C=typeof u.ts==="string"?u.ts:"0.000000",B=F7(C),$="?";if(typeof u.user==="string"){let O=u.user,V="@"+O;if(!F.has(V)){let[,W]=await YF(D,O);F.set(V,W)}$=F.get(V)??O}else if(typeof u.username==="string")$=u.username;let G=typeof u.text==="string"?u.text:"",z=MF(await jF(D,G,F)).split(`
117
+ `),Q=z[0]+(z.length>1?`
118
+ `+z.slice(1).map((O)=>` ${O}`).join(`
119
+ `):""),J=q1(u)?"↳ ":"",Y=E?`${E} @${$}`:`@${$}`;return`${B} ${J}${Y}: ${Q}`}async function C7(D,u,F,E,C,B,$){let G=pD(await Y0(D,u,20,$?void 0:F||void 0,$)),Z=T0(G.messages).map(pD).reverse(),z=pD(G.response_metadata),Q=G.has_more===!0&&typeof z.next_cursor==="string"?z.next_cursor:void 0,J=[];if(E.watchThread&&!$){let U=pD(await m8(D,u,E.watchThread,50));J=T0(U.messages).map(pD).filter((_)=>(typeof _.ts==="string"?_.ts:"")!==E.watchThread)}let Y=[...Z.map((U)=>({m:U,fromHistory:!0})),...J.map((U)=>({m:U,fromHistory:!1}))].sort((U,_)=>H1(typeof U.m.ts==="string"?U.m.ts:"")-H1(typeof _.m.ts==="string"?_.m.ts:"")),O=[],V=F,W=!1;for(let{m:U,fromHistory:_}of Y){let M=typeof U.ts==="string"?U.ts:"";if(!M||C.has(M))continue;let N=typeof U.subtype==="string"?U.subtype:"";if(N==="message_changed"||N==="message_deleted")continue;if(E.thread){if((typeof U.thread_ts==="string"?U.thread_ts:M)!==E.thread&&M!==E.thread)continue}if(E.watchThread&&q1(U)){if((typeof U.thread_ts==="string"?U.thread_ts:"")!==E.watchThread)continue}if(E.me&&E.myUserId){if(!(typeof U.text==="string"?U.text:"").includes(`<@${E.myUserId}>`))continue}if(C.add(M),C.size>1000){let h=C.values().next().value;if(h!==void 0)C.delete(h)}if(O.push(await E7(D,U,B)),_)V=M;let A=typeof U.user==="string"?U.user:"";if(!E.myUserId||A!==E.myUserId)W=!0}return{newCursor:V,lines:O,hasMore:G.has_more===!0,nextPageCursor:Q,emittedOther:W}}function B7(D){if(D.includes("slack.com")){let u=W0(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 K1(D,u,F={},E){if(F.me&&!u)console.error(`slack tail --me requires a <target> channel.
120
120
  Cross-channel mention streaming is not yet supported.
121
- 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 f8(D,u),B=F.interval??60000,$=F.timeout?SD.now()+J1(F.timeout)*1000:1/0,G=new Map,z=new Set;try{let W=pD(await h8(D,C));if(pD(W.channel).is_archived===!0)console.error("Warning: this channel is archived — no new messages will arrive.")}catch(W){let M=W instanceof Error?W.message:String(W);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 W=J1(F.since);Z=(SD.now()/1000-W).toFixed(6)}else{let W=pD(await Q0(D,C,1)),M=N0(W.messages).map(pD);if(M.length>0&&typeof M[0]?.ts==="string")Z=M[0].ts,z.add(Z);else Z=(SD.now()/1000).toFixed(6)}let Y;if(F.me||F.exitOnMessage)Y=(await JF(D)).userId||void 0;let J;if(F.watchThread!==void 0)try{J=D7(F.watchThread)}catch(W){console.error(W instanceof Error?W.message:String(W)),process.exit(1)}let Q={...F.thread!==void 0?{thread:F.thread}:{},...J!==void 0?{watchThread:J}:{},...F.me!==void 0?{me:F.me}:{},...Y!==void 0?{myUserId:Y}:{}};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,Q,z,G,E),E?.aborted)return;console.error("RTM unavailable — switching to polling.")}let O=!0,V=SD.now();while(!E?.aborted){if(SD.now()>=$)return;let W=!1;try{let N=SD.now()-V,k=B>0&&N>B*5,w,c=!0;do{let{newCursor:e,lines:r,nextPageCursor:_D,emittedOther:i}=await e6(D,C,Z,Q,z,G,w);if(Z=e,O&&c&&F.since&&r.length===0)process.stdout.write(`(no messages in the last ${F.since} — watching for new)
122
- `);c=!1;for(let oD of r)process.stdout.write(oD+`
123
- `);if(i)W=!0;w=k?_D:void 0}while(w);O=!1}catch(_){if(_ instanceof lD){console.error(`Warning: Slack rate limit hit — backing off for ${_.retryAfter}s`),await SD.sleep(_.retryAfter*1000);continue}throw _}if(F.exitOnMessage&&W)return;V=SD.now();let M=$-SD.now();if(M<=0)return;await SD.sleep(Math.min(B,M))}}class fu extends Error{retryAfter;constructor(D){super(`Slack rate limited — retry after ${D}s`);this.name="RateLimitError",this.retryAfter=D}}function W1(){return(process.env.SLACK_API_BASE??"https://slack.com/api").replace(/\/$/,"")}async function O1(D,u,F,E){let C={};if(E)C.Cookie=`d=${E}`;let B=await fetch(`${W1()}/${u}`,{...F,headers:{...F.headers??{},Authorization:`Bearer ${D}`,...C}});if(B.status===429){let G=parseInt(B.headers.get("retry-after")??"60",10);throw new fu(isNaN(G)?60:G)}let $=await B.json();if($.ok!==!0){let G=$.error??"unknown";if(G==="ratelimited")throw new fu(60);if(G==="invalid_auth"&&D.startsWith("xoxc-")&&!E)throw Error(`Desktop app token (xoxc-) is not accepted by the public Slack API.
121
+ 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 c8(D,u),B=F.interval??60000,$=F.timeout?SD.now()+V1(F.timeout)*1000:1/0,G=new Map,Z=new Set;try{let W=pD(await g8(D,C));if(pD(W.channel).is_archived===!0)console.error("Warning: this channel is archived — no new messages will arrive.")}catch(W){let U=W instanceof Error?W.message:String(W);if(U.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(U.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(U.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: ${U}`)}let z="";if(F.since){let W=V1(F.since);z=(SD.now()/1000-W).toFixed(6)}else{let W=pD(await Y0(D,C,1)),U=T0(W.messages).map(pD);if(U.length>0&&typeof U[0]?.ts==="string")z=U[0].ts,Z.add(z);else z=(SD.now()/1000).toFixed(6)}let Q;if(F.me||F.exitOnMessage)Q=(await QF(D)).userId||void 0;let J;if(F.watchThread!==void 0)try{J=B7(F.watchThread)}catch(W){console.error(W instanceof Error?W.message:String(W)),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,Z,G,E),E?.aborted)return;console.error("RTM unavailable — switching to polling.")}let O=!0,V=SD.now();while(!E?.aborted){if(SD.now()>=$)return;let W=!1;try{let M=SD.now()-V,N=B>0&&M>B*5,A,h=!0;do{let{newCursor:d,lines:o,nextPageCursor:jD,emittedOther:n}=await C7(D,C,z,Y,Z,G,A);if(z=d,O&&h&&F.since&&o.length===0)process.stdout.write(`(no messages in the last ${F.since} — watching for new)
122
+ `);h=!1;for(let sD of o)process.stdout.write(sD+`
123
+ `);if(n)W=!0;A=N?jD:void 0}while(A);O=!1}catch(_){if(_ instanceof lD){console.error(`Warning: Slack rate limit hit — backing off for ${_.retryAfter}s`),await SD.sleep(_.retryAfter*1000);continue}throw _}if(F.exitOnMessage&&W)return;V=SD.now();let U=$-SD.now();if(U<=0)return;await SD.sleep(Math.min(B,U))}}class Au extends Error{retryAfter;constructor(D){super(`Slack rate limited — retry after ${D}s`);this.name="RateLimitError",this.retryAfter=D}}function R0(){return(process.env.SLACK_API_BASE??"https://slack.com/api").replace(/\/$/,"")}async function U1(D,u,F,E){let C={};if(E)C.Cookie=`d=${E}`;let B=await fetch(`${R0()}/${u}`,{...F,headers:{...F.headers??{},Authorization:`Bearer ${D}`,...C}});if(B.status===429){let G=parseInt(B.headers.get("retry-after")??"60",10);throw new Au(isNaN(G)?60:G)}let $=await B.json();if($.ok!==!0){let G=$.error??"unknown";if(G==="ratelimited")throw new Au(60);if(G==="invalid_auth"&&D.startsWith("xoxc-")&&!E)throw Error(`Desktop app token (xoxc-) is not accepted by the public Slack API.
124
124
  Replace it with an xoxp- user token:
125
125
  slack auth token`);if((G==="missing_scope"||G==="cannot_dm_bot")&&D.startsWith("xoxb-"))throw Error(`Slack error on ${u}: ${G} — ${G==="cannot_dm_bot"?`you're authenticated as a bot, so "@you" is the bot itself and it can't DM itself`:"this bot token lacks the user scope this action needs"}.
126
126
  Tailing/DMing people and listing users need a user session, not a bot token.
127
127
  Switch workspace: slack auth ls then slack auth use <name>
128
- Or import your Slack desktop session: slack auth login`);throw Error(`Slack error on ${u}: ${G}`)}return $}async function u7(D,u,F,E){let C={};if(E)C.Cookie=`d=${E}`;let B=await fetch(`${W1()}/${u}`,{...F,headers:{...F.headers??{},Authorization:`Bearer ${D}`,...C}});if(B.status===429){let G=parseInt(B.headers.get("retry-after")??"60",10);throw new fu(isNaN(G)?60:G)}let $=await B.json();if($.ok!==!0){let G=$.error??"unknown";if(G==="ratelimited")throw new fu(60);if((G==="invalid_auth"||G==="not_authed")&&!D.startsWith("xoxc-"))throw Error(`The draft API requires a desktop app session token (xoxc-).
128
+ Or import your Slack desktop session: slack auth login`);throw Error(`Slack error on ${u}: ${G}`)}return $}async function $7(D,u,F,E){let C={};if(E)C.Cookie=`d=${E}`;let B=await fetch(`${R0()}/${u}`,{...F,headers:{...F.headers??{},Authorization:`Bearer ${D}`,...C}});if(B.status===429){let G=parseInt(B.headers.get("retry-after")??"60",10);throw new Au(isNaN(G)?60:G)}let $=await B.json();if($.ok!==!0){let G=$.error??"unknown";if(G==="ratelimited")throw new Au(60);if((G==="invalid_auth"||G==="not_authed")&&!D.startsWith("xoxc-"))throw Error(`The draft API requires a desktop app session token (xoxc-).
129
129
  Import from Slack desktop: slack auth login`);if((G==="invalid_auth"||G==="not_authed")&&!E)throw Error(`drafts.list also requires the xoxd session cookie.
130
- Attach it with: slack auth chrome (macOS) or slack auth firefox`);throw Error(`Slack error on ${u}: ${G}`)}return $}function ju(D,u,F={},E){let C=new URLSearchParams({token:D,...F});return u7(D,u,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:C.toString()},E)}function CD(D,u,F,E){let C=new URLSearchParams(F).toString();return O1(D,`${u}?${C}`,{method:"GET"},E)}function PD(D,u,F){return O1(D,u,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(F)})}async function V1(D){let u=await CD(D,"auth.test",{});return{team:u.team??"",teamId:u.team_id??"",url:u.url??"",user:u.user??"",userId:u.user_id??""}}async function vu(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 CD(D,"conversations.history",B)}async function Au(D,u,F,E=50){return CD(D,"conversations.replies",{channel:u,ts:F,limit:String(E)})}async function H1(D,u,F){return CD(D,"files.info",{file:u},F)}async function q1(D,u,F,E){return CD(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 U1(D,u){return q1(D,u,100,1)}async function M1(D,u,F){let C=1,B=[],$={ok:!0,messages:{}};while(!0){let z=await q1(D,u,100,C),Z=hu(z,["messages","matches"]),Y=Array.isArray(Z)?Z:[];B.push(...Y);let J=Number(hu(z,["messages","paging","pages"])??1);if($=z,Y.length===0||C>=J||B.length>=F)break;C+=1}let G=$;if(!G.messages)G.messages={};return G.messages.matches=B.slice(0,F),G}async function K1(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 PD(D,"chat.postMessage",B)).ts??""}async function _1(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 PD(D,"chat.scheduleMessage",B)).scheduled_message_id??""}async function j1(D,u){let F={};if(u)F.channel=u;return CD(D,"chat.scheduledMessages.list",F)}async function A1(D,u,F){await PD(D,"chat.deleteScheduledMessage",{channel:u,scheduled_message_id:F})}async function L1(D,u,F){return(await CD(D,"chat.getPermalink",{channel:u,message_ts:F})).permalink??""}async function N1(D,u,F,E){return(await PD(D,"chat.update",{channel:u,ts:F,text:E,blocks:[{type:"markdown",text:E}]})).ts??F}async function T1(D,u,F){await PD(D,"chat.delete",{channel:u,ts:F})}async function R1(D,u,F,E){await PD(D,"reactions.add",{channel:u,timestamp:F,name:E})}async function S1(D,u,F,E){await PD(D,"reactions.remove",{channel:u,timestamp:F,name:E})}async function P1(D,u,F=!1){let E=await PD(D,"conversations.create",{name:u,is_private:F});return{id:E.channel?.id??"",name:E.channel?.name??u}}async function w1(D,u,F){await PD(D,"conversations.invite",{channel:u,users:F.join(",")})}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 CD(D,"conversations.list",E);if(u.push(...C.channels??[]),F=C.response_metadata?.next_cursor??"",!F)break}return{channels:u}}async function pu(D,u){let E=(await PD(D,"conversations.open",{users:u})).channel?.id;if(!E)throw Error(`Failed to open DM with user ${u}`);return E}function bD(D){return D.toLowerCase().replace(/[-_\s]/g,"")}async function T0(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=bD(u.slice(1)),C=await CD(D,"auth.test",{},F);if(E==="you"||E==="me"||bD(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 G=await CD(D,"users.list",$,F);for(let z of G.members??[]){let Z=bD(z.name??""),Y=bD(z.real_name??""),J=bD(z.profile?.display_name??"");if(Z===E||Y===E||J&&J===E)return z.id??""}if(B=G.response_metadata?.next_cursor??"",!B)break}throw Error(`User not found: ${u}`)}function yu(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 F7(D){return yu(D)?.channel}async function KD(D,u,F){let E=F7(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),$=bD(B);if(C){let Z=await CD(D,"auth.test",{},F);if($==="you"||$==="me"||bD(Z.user??"")===$){let V=Z.user_id;if(!V)throw Error("auth.test did not return user_id");let M=((await CD(D,"conversations.list",{types:"im",limit:"200"},F)).channels??[]).find((_)=>_.user===V);if(M?.id)return String(M.id);return pu(D,V)}let J="",Q="";while(!0){let V={limit:"200"};if(Q)V.cursor=Q;let W=await CD(D,"users.list",V,F);for(let M of W.members??[]){let _=bD(M.name??""),N=bD(M.real_name??""),k=bD(M.profile?.display_name??"");if(_===$||N===$||k&&k===$){J=M.id??"";break}}if(J)break;if(Q=W.response_metadata?.next_cursor??"",!Q)break}if(!J)throw Error(`User not found: ${u}`);let O="";while(!0){let V={types:"im",limit:"200"};if(O)V.cursor=O;let W=await CD(D,"conversations.list",V,F);for(let M of W.channels??[])if(M.user===J)return String(M.id??"");if(O=W.response_metadata?.next_cursor??"",!O)break}throw Error(`No existing DM with ${u} (${J}). Open it once in Slack first.`)}let G=B.toLowerCase(),z="";while(!0){let Z={limit:"200",types:"public_channel,private_channel",exclude_archived:"true"};if(z)Z.cursor=z;let Y=await CD(D,"conversations.list",Z,F);for(let J of Y.channels??[])if(String(J.name??"").toLowerCase()===G)return String(J.id??"");if(z=Y.response_metadata?.next_cursor??"",!z)break}throw Error(`channel not found: ${u}`)}async function mu(D,u){try{let F=await CD(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 cu(D,u){try{let F=await CD(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 R0(D){let u=[],F="";while(!0){let E={limit:"200"};if(F)E.cursor=F;let C=await CD(D,"users.list",E);if(u.push(...C.members??[]),F=C.response_metadata?.next_cursor??"",!F)break}return{members:u}}async function gu(D,u){return ju(D,"drafts.list",{},u)}async function x1(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 ju(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 I1(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 ju(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 b1(D,u,F){return ju(D,"conversations.info",{channel:u},F)}async function f1(D,u){return CD(D,"users.info",{user:u})}async function S0(D,u){return CD(D,"conversations.info",{channel:u})}async function h1(D,u,F){let E=(Date.now()/1000).toFixed(6);return ju(D,"drafts.delete",{draft_id:u,client_last_updated_ts:E},F)}async function P0(D,u){let F=await ju(D,"auth.test",{},u);return{userId:String(F.user_id??""),teamId:String(F.team_id??"")}}async function v1(D,u,F,E={}){let{statSync:C,readFileSync:B}=await import("node:fs"),{basename:$}=await import("node:path"),G=C(F),z=$(F),Z=await CD(D,"files.getUploadURLExternal",{filename:z,length:String(G.size)}),Y=Z.upload_url,J=Z.file_id;if(!Y||!J)throw Error("files.getUploadURLExternal returned no upload_url/file_id");let Q=B(F),O=await fetch(Y,{method:"POST",headers:{"Content-Type":"application/octet-stream"},body:Q});if(!O.ok)throw Error(`Upload PUT failed: ${O.status} ${O.statusText}`);let V={files:[{id:J,title:E.title??z}],channel_id:u};if(E.threadTs)V.thread_ts=E.threadTs;if(E.initialComment)V.initial_comment=E.initialComment;let W=await PD(D,"files.completeUploadExternal",V),M={fileId:J},_=W.files?.[0]?.permalink;if(_)M.permalink=_;return M}function hu(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}function p1(){return/(?<![A-Za-z0-9._@<-])@([A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)*)/g}function jF(D){return D.toLowerCase().replace(/[-_\s]/g,"")}function Vu(D){return D&&typeof D==="object"&&!Array.isArray(D)?D:{}}function y1(D,u){let F=jF(u),E=Vu(D.profile);for(let B of[D.name,D.real_name,E.display_name,E.real_name])if(typeof B==="string"&&B&&jF(B)===F)return!0;let C=typeof E.email==="string"?E.email.toLowerCase():"";return C!==""&&C===u.toLowerCase()}async function x0(D,u,F,E={}){let C=E.warn??((Y)=>process.stderr.write(`${Y}
131
- `)),B=new Set;for(let Y of u.matchAll(p1()))B.add(Y[1]);if(B.size===0)return u;let $=new Map,z=((await YF(D)).members??[]).map(Vu),Z=[];for(let Y of B){let J=z.find((O)=>y1(O,Y)),Q=J&&typeof J.id==="string"?J.id:"";if(Q)$.set(Y,Q);else Z.push(Y)}if(Z.length>0&&F){let Y=await W0(D,F),J=[];for(let Q of Y){let O=Vu(await O0(D,Q)),V=Vu(O.user);if(typeof V.id!=="string")V.id=Q;J.push(V)}for(let Q of Z){let O=J.find((W)=>y1(W,Q)),V=O&&typeof O.id==="string"?O.id:"";if(V)$.set(Q,V)}}for(let Y of B)if(!$.has(Y))C(`warn: unresolved mention @${Y} (left as text)`);return u.replace(p1(),(Y,J)=>{let Q=$.get(J);return Q?`<@${Q}>`:Y})}var E7=["さん","さま","様","君","くん","ちゃん","氏","先生","先輩","殿","老师","老師","兄","姐","哥","姐妹"],C7="\\p{Script=Han}\\p{Script=Hiragana}\\p{Script=Katakana}A-Za-z0-9";function m1(D){return/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}]/u.test(D)}function B7(D){let u=[],F=new RegExp(`([${C7}]{1,12})(${E7.join("|")})`,"gu");for(let E of D.matchAll(F))u.push({ref:E[1],honorific:E[2]});for(let E of D.matchAll(/\b(?:dear|hi|hello|hey)\b[ \t]+([A-Z][A-Za-z'’-]{1,20})/gi))u.push({ref:E[1],honorific:""});for(let E of D.matchAll(/(?:^|\n)[ \t]*([A-Z][A-Za-z'’-]{1,20}),/g))u.push({ref:E[1],honorific:""});return u}function $7(D){let u=Vu(D.profile),F=new Set;for(let E of[D.name,D.real_name,u.display_name,u.real_name]){if(typeof E!=="string"||!E)continue;for(let C of[E,...E.split(/\s+/)]){let B=jF(C);if(B.length>=2)F.add(B)}}return[...F]}function G7(D,u){let F=jF(D);if(F.length<2)return;for(let E of u)if(F===E)return E;if(m1(D)){for(let E of u)if(F.includes(E)||E.includes(F))return E}return}function z7(D){return[Vu(D.profile).display_name,D.real_name,D.name].filter((E)=>typeof E==="string"&&E!=="")[0]??String(D.id??"?")}async function c1(D,u){let F=B7(u);if(F.length===0)return[];let E=new Set;for(let z of u.matchAll(/<@([A-Z0-9]+)(?:\|[^>]*)?>/g))E.add(z[1]);let B=((await YF(D)).members??[]).map(Vu).filter((z)=>z.deleted!==!0&&z.is_bot!==!0&&z.id!=="USLACKBOT").map((z)=>({id:typeof z.id==="string"?z.id:"",forms:$7(z),display:z7(z)})).filter((z)=>z.id!==""),$=[],G=new Set;for(let{ref:z,honorific:Z}of F)for(let Y of B){let J=G7(z,Y.forms);if(!J)continue;if(E.has(Y.id)||G.has(Y.id))break;G.add(Y.id),$.push({surface:m1(z)?`${J}${Z}`:z,display:Y.display,userId:Y.id});break}return $}async function Lu(D,u,F){let E=u,C=[],B=E,$=0;while(!0){let G=B.indexOf("<@U",$);if(G===-1)break;let z=B.slice(G+2),Z=z.search(/[>|]/),Y=Z===-1?z:z.slice(0,Z);if(Y.length>=9)C.push(Y);$=G+1}for(let G of C){if(!F.has(G))F.set(G,await QF(D,G));let z=F.get(G)??G;E=E.replaceAll(`<@${G}>`,`@${z}`),E=E.replace(new RegExp(`<@${G}\\|[^>]*>`,"g"),`@${z}`)}return E}function ku(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"],G=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],z=$[B.getUTCDay()]??"",Z=G[B.getUTCMonth()]??"";return`${z}, ${Z} ${String(B.getUTCDate()).padStart(2,"0")}, ${B.getUTCFullYear()}`})}function g1(D,u=new Date){let F=new Date(D*1000),E=w0(u),C=w0(new Date(u.getTime()-86400000)),B=w0(F);if(B===E)return"Today";if(B===C)return"Yesterday";let $=F.toLocaleDateString("en-US",{weekday:"long"}),G=F.toLocaleDateString("en-US",{month:"short"});return`${$}, ${G} ${String(F.getDate()).padStart(2,"0")}`}function w0(D){return`${D.getFullYear()}-${D.getMonth()}-${D.getDate()}`}function k1(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 du(D){if(!t1(D))return;let u=J7(D,"utf8");for(let F of u.split(`
132
- `)){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 Q7(D){X7(D,{recursive:!0});let u=tD(D,".gitignore");if(!t1(u))o1(u,`*
133
- `)}function Y7(){du(tD(d1(),".slack-cli",".env.local")),du(tD(d1(),".config/slack-cli",".env")),du(tD(process.cwd(),".slack-cli",".env.local")),du(tD(process.cwd(),".env.local")),du(tD(process.cwd(),".env"))}function W7(D){return Z7("sha256").update(D).digest("hex")}function m(D){return D&&typeof D==="object"&&!Array.isArray(D)?D:{}}function o(D){return Array.isArray(D)?D:[]}function AF(D){return Number(D.ts??0)}async function s1(D,u,F){let E=u.user;if(typeof E==="string"){if(!F.has(E))F.set(E,await cu(D,E));return F.get(E)??E}return typeof u.username==="string"?u.username:"bot"}function I0(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"),G=String(u.getUTCSeconds()).padStart(2,"0");return`${F}-${E}-${C} ${B}:${$}:${G}`}function f0(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"),G=String(C.getUTCDate()).padStart(2,"0"),z=String(C.getUTCHours()).padStart(2,"0"),Z=String(C.getUTCMinutes()).padStart(2,"0"),Y=String(C.getUTCSeconds()).padStart(2,"0"),J=F.padEnd(6,"0").slice(0,6);return`${B}-${$}-${G}T${z}:${Z}:${Y}.${J}`}function h0(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 O7(D){return/^\d{4}-\d{2}-\d{2}T/.test(D)?h0(D):D}async function NF(D,u,F,E){let C=typeof u.ts==="string"?u.ts:`${AF(u)}.000000`,B=f0(C),$="?";if(typeof u.user==="string"){let W=u.user,M="@"+W;if(!F.has(M)){let[,_]=await mu(D,W);F.set(M,_)}$=F.get(M)??W}else if(typeof u.username==="string")$=u.username;let G=typeof u.text==="string"?u.text:"",Z=ku(await Lu(D,G,F)).split(`
134
- `),Y=Z[0]+(Z.length>1?`
135
- `+Z.slice(1).map((W)=>` ${W}`).join(`
136
- `):""),J=E?`${E} @${$}`:`@${$}`,Q=o(u.reactions).map(m).map((W)=>{let M=typeof W.name==="string"?W.name:"",_=Number(W.count??o(W.users).length??0);return M?`:${M}:\xD7${_}`:""}).filter(Boolean).join(" "),O=o(u.files).map(m).map((W)=>{let M=typeof W.name==="string"?W.name:typeof W.title==="string"?W.title:"(file)",_=typeof W.size==="number"?` (${v0(W.size)})`:"",N=typeof W.id==="string"?` [${W.id}]`:"";return`
137
- \uD83D\uDCCE ${M}${_}${N}`}).join(""),V=(Q?`
138
- ${Q}`:"")+O;return`${B} ${J}: ${Y}${V}`}function v0(D){return D<1024?`${D} B`:D<1048576?`${(D/1024).toFixed(1)} KB`:`${(D/1048576).toFixed(1)} MB`}function V7(D){return o(D.files).map(m).map((u)=>({id:u.id??null,name:u.name??u.title??null,mimetype:u.mimetype??null,size:u.size??null,url_private_download:u.url_private_download??u.url_private??null,permalink:u.permalink??null}))}function r1(D){let u=V7(D);return{ts:D.ts??null,user:D.user??null,username:D.username??null,bot_id:D.bot_id??null,thread_ts:D.thread_ts??null,text:typeof D.text==="string"?D.text:"",...u.length>0?{files:u}:{}}}async function H7(D,u,F,E="text"){let C=yu(u),B=await KD(D,u),$=new Map,z=await(async()=>{if(C?.threadTs){let Y=await Au(D,B,C.threadTs,F);return o(Y.messages).map(m)}let Z=await vu(D,B,F);return o(Z.messages).map(m).reverse()})();if(E==="jsonl"){for(let Z of z)console.log(JSON.stringify(r1(Z)));return}for(let Z of z)console.log(await NF(D,Z,$))}async function q7(D,u,F,E,C="text"){let B=await KD(D,u),$=await Au(D,B,O7(F),E),G=o($.messages).map(m);if(C==="jsonl"){for(let Z of G)console.log(JSON.stringify(r1(Z)));return}let z=new Map;for(let Z of G)console.log(await NF(D,Z,z))}async function U7(D){let u=await _F(D),F=o(u.channels).map(m).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,G=await vu(D,B,5),z=o(G.messages).map(m).filter((Z)=>Z.subtype===void 0||Z.subtype===null).filter((Z)=>{let Y=typeof Z.text==="string"?Z.text:"";return Y.length>0&&!Y.startsWith("<@")}).slice(0,3).reverse();if(z.length===0)continue;console.log(`-- #${$} --------------------------------`);for(let Z of z){let Y=await s1(D,Z,E),J=(typeof Z.text==="string"?Z.text:"").split(`
139
- `)[0]??"",Q=await Lu(D,J,E);console.log(` ${Y}: ${Q}`)}}}async function M7(D,u){let F=await U1(D,"to:me"),E=o(hu(F,["messages","matches"])).map(m).slice(0,u),C=new Map,B=[];for(let $ of E){let G=g1(AF($)),z=B[B.length-1];if(z?.label===G)z.msgs.push($);else B.push({label:G,msgs:[$]})}for(let $=0;$<B.length;$++){let{label:G,msgs:z}=B[$];if($>0)console.log("");console.log(` ${G}`),console.log(" ----------------------------");for(let Z of[...z].reverse()){let Y=m(Z.channel),J=Y.is_im===!0,Q=typeof Y.name==="string"?Y.name:"dm",O;if(J&&Q.startsWith("U")){let V="@"+Q;if(!C.has(V)){let[,W]=await mu(D,Q);C.set(V,W)}O=`@${C.get(V)??Q}`}else if(J)O=`@${Q}`;else O=`#${Q}`;console.log(await NF(D,Z,C,O))}}}async function K7(D,u,F,E,C="text"){let B=await _F(D),$=o(B.channels).map(m).filter((G)=>E||G.is_member===!0).filter((G)=>{if(!F)return!0;return(typeof G.name==="string"?G.name:"").toLowerCase().includes(F.toLowerCase())}).sort((G,z)=>Number(z.updated??0)-Number(G.updated??0)).slice(0,u);if(C==="jsonl"){for(let G of $)console.log(JSON.stringify(G));return}for(let G of $){let z=String(G.id??""),Z=typeof G.name==="string"?G.name:typeof G.user==="string"?G.user:z,Y=G.is_im===!0,J=G.is_mpim===!0,Q=Y||J?"@":"#",O=G.is_member===!0?"":" (not joined)",V=typeof m(G.purpose).value==="string"?String(m(G.purpose).value):"",W=V?` ${V.split(`
140
- `)[0]?.slice(0,60)}`:"";console.log(`${Q}${Z} ${z}${O}${W}`)}}async function _7(D,u,F,E){let C=await M1(D,u,F);if(E){console.log(JSON.stringify(C,null,2));return}let B=o(hu(C,["messages","matches"])).map(m),$=new Map;for(let G of B){let z=m(G.channel),Z=z.is_im===!0,Y=typeof z.name==="string"?z.name:"dm",J;if(Z&&Y.startsWith("U")){let Q="@"+Y;if(!$.has(Q)){let[,O]=await mu(D,Y);$.set(Q,O)}J=`@${$.get(Q)??Y}`}else if(Z)J=`@${Y}`;else J=`#${Y}`;console.log(await NF(D,G,$,J))}}async function j7(D,u,F,E){let C=Math.floor(Date.now()/1000)-u*86400,B=await _F(D),$=o(B.channels).map(m).filter((Y)=>Y.is_member===!0&&Y.is_im!==!0&&Y.is_mpim!==!0).filter((Y)=>{if(!E)return!0;return(typeof Y.name==="string"?Y.name:"").toLowerCase().includes(E.toLowerCase())}).sort((Y,J)=>Number(J.updated??0)-Number(Y.updated??0)),G=new Map,z=0,Z=0;for(let Y of $){let J=String(Y.id??""),Q=typeof Y.name==="string"?Y.name:J,O;try{O=await vu(D,J,F)}catch(W){console.error(` SKIP #${Q}: ${W.message}`);continue}let V=o(O.messages).map(m).filter((W)=>(W.subtype===void 0||W.subtype===null)&&AF(W)>=C);if(V.length===0)continue;Z+=1,z+=V.length,console.log(`## #${Q} (${V.length} msgs)
141
- `);for(let W of[...V].reverse()){let M=await s1(D,W,G),_=typeof W.text==="string"?W.text:"",k=ku(await Lu(D,_,G)).split(`
142
- `).join(" \u21B5 ");console.log(`[${k1(AF(W))}] ${M}: ${k}`)}console.log("")}console.error(`Dumped ${z} messages across ${Z} channels (cutoff: ${u}d)`)}function A7(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 a1(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 b1(D,C,u),$=m(B.channel),G;if($.is_im===!0){let z=typeof $.user==="string"?$.user:"";if(!z||z===F)G="@self";else{let[Z]=await mu(D,z);G=`@${Z}`}}else G=`#${typeof $.name==="string"?$.name:C}`;return E.set(C,G),G}catch{return C}}}function p0(D){let u=m(o(D.destinations)[0]);return String(u.channel_id??D.channel_id??D.channel??"")}function LF(D){return A7(o(D.blocks))||(typeof D.text==="string"?D.text:"(no text)")}async function L7(D,u,F=!1){let E=await gu(D,u),C=o(E.drafts??E.messages??[]).map(m).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 P0(D,u))}catch{}let G=await a1(D,u,$),z=new Map;for(let Z of B){let Y=p0(Z),J=LF(Z),Q=Number(Z.date_created??Z.date_create??0),O=Q?I0(Q):"?",V=await G(Y),W=typeof Z.id==="string"?Z.id:"",M=Z.is_sent===!0?" [SENT]":"",_=ku(await Lu(D,J,z));console.log(`-- ${W} ${V} [${O}]${M}`);for(let N of _.split(`
143
- `))console.log(` ${N}`)}}async function N7(D,u,F){let E=await gu(D,u),C=o(E.drafts).map(m).find((V)=>String(V.id)===F);if(!C)console.error(`Draft not found: ${F}`),process.exit(1);let B="";try{({userId:B}=await P0(D,u))}catch{}let $=await a1(D,u,B),G=p0(C),z=LF(C),Z=Number(C.date_created??0),Y=String(C.last_updated_ts??"?"),J=await $(G),O=ku(await Lu(D,z,new Map));console.log(`id: ${C.id}`),console.log(`channel: ${J} (${G})`),console.log(`created: ${Z?I0(Z):"?"}`),console.log(`updated: ${I0(Number(Y.split(".")[0]))}`),console.log(`status: ${C.is_sent===!0?"sent":"pending"}`),console.log("---"),console.log(O)}function yD(...D){return W7(D.join(`
144
- `)).slice(0,4)}var T7={"reactions.add":"reactions:write","reactions.remove":"reactions:write","chat.postMessage":"chat:write","chat.update":"chat:write","chat.delete":"chat:write","conversations.replies":"channels:history (or groups:history)","conversations.history":"channels:history (or groups:history)"};function i1(D){let u=D instanceof Error?D.message:String(D),F=u.match(/Slack error on (\S+): (\w+)/);if(!F)return u;let[,E,C]=F;switch(C){case"missing_scope":return`Error: token lacks the ${T7[E]??"the required"} scope (needed for ${E}). Add it to your Slack App's User Token Scopes (or Bot Token Scopes if you use a bot token / --as-bot) \u2014 it must be on the token type the CLI actually uses \u2014 then reinstall to the workspace.`;case"invalid_name":return"Error: not a valid emoji shortcode \u2014 use the name without colons (e.g. white_check_mark), and make sure it exists in the workspace.";case"already_reacted":return"Error: you've already added that reaction to the message.";case"no_reaction":return"Error: that reaction isn't on the message \u2014 nothing to remove.";case"message_not_found":return"Error: no message found at that timestamp in the channel \u2014 check the target ts/permalink.";case"channel_not_found":return"Error: channel not found \u2014 check the target.";default:return u}}function fD(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 y0(D){let u=yu(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:h0(E)}}}return{ref:D}}function m0(D){let u=yu(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:h0(E)}}return{ref:D}}async function e1(D,u,F){let E=F;if(!F.startsWith("#")&&!F.startsWith("@"))try{let C=m(await S0(D,u)),B=m(C.channel);if(B.is_im===!0){let $=typeof B.user==="string"?B.user:"";E=$?`@${await cu(D,$)}`:u}else E=typeof B.name==="string"?`#${B.name}`:u}catch{E=u}return E===u?u:`${E} (${u})`}async function b0(D,u,F=60){let E=typeof u.user==="string"?await cu(D,u.user):typeof u.username==="string"?u.username:"?",C=(typeof u.text==="string"?u.text:"").split(`
145
- `)[0]??"",B=C.length>F?`${C.slice(0,F)}\u2026`:C,$=typeof u.ts==="string"?u.ts:"";return`${$?f0($).slice(0,16).replace("T"," "):""} @${E}${B?`: ${B}`:""}`}async function R7(D,u,F){let E=F.find((C)=>String(C.ts)===u)??F[0];if(!E)return u;return b0(D,E,40)}function n1(D){return D.toLowerCase().replace(/<[@#!][^>]+>/g," ").replace(/[^\p{L}\p{N}\s]/gu," ").replace(/\s+/g," ").trim()}function S7(D,u){let F=n1(D),E=n1(u);if(!F||!E)return 0;if(F===E)return 1;let C=(Z)=>{let Y=new Map;for(let J=0;J<Z.length-1;J++){let Q=Z.slice(J,J+2);Y.set(Q,(Y.get(Q)??0)+1)}return Y},B=C(F),$=C(E);if(B.size===0||$.size===0)return 0;let G=0;for(let[Z,Y]of B){let J=$.get(Z);if(J)G+=Math.min(Y,J)}let z=l1(B)+l1($);return z===0?0:2*G/z}function l1(D){let u=0;for(let F of D.values())u+=F;return u}async function P7(D,u){let{ref:F,ts:E}=y0(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 KD(D,F);let B=await Au(D,C,E,1),G=o(B.messages).map(m).find((Q)=>String(Q.ts)===E);if(!G)console.error(`Message not found at ts=${E} in channel ${C}`),process.exit(1);let z=typeof G.text==="string"?G.text:"",Z=u.mentions?await x0(D,u.newText,C):u.newText,Y=yD(z,Z);if(u.code!==Y)fD(u.code,Y,["--- Original message -------------------------",...z.split(`
146
- `).map((Q)=>` ${Q}`),"--- Replacing with ---------------------------",...Z.split(`
147
- `).map((Q)=>` ${Q}`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);let J=await N1(D,C,E,Z);console.log(`\u2713 Edited (ts: ${J})`)}async function w7(D,u){let{ref:F,ts:E}=y0(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 KD(D,F);let B=await Au(D,C,E,1),G=o(B.messages).map(m).find((Y)=>String(Y.ts)===E);if(!G)console.error(`Message not found at ts=${E} in channel ${C}`),process.exit(1);let z=typeof G.text==="string"?G.text:"",Z=yD(C,E,z);if(u.code!==Z){let Y=await e1(D,C,F);fD(u.code,Z,["--- Deleting message -------------------------",` \u2192 ${Y} at ${f0(E)}`,...z.split(`
148
- `).map((J)=>` ${J}`),"---------------------------------------------"])}await T1(D,C,E),console.log(`\u2713 Deleted (ts: ${E})`)}async function x7(D,u){let{ref:F,ts:E}=y0(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=u.emoji.replace(/^:|:$/g,""),B;if(u.channelId)B=u.channelId;else B=await KD(D,F);if(u.remove)await S1(D,B,E,C),console.log(`\u2713 Removed :${C}: (ts: ${E})`);else await R1(D,B,E,C),console.log(`\u2713 Reacted :${C}: (ts: ${E})`)}async function I7(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 V1(D)).user??"").toLowerCase().replace(/[^a-z0-9]/g,"");return C!==""&&C===F}catch{return!1}}async function b7(D,u){let{ref:F,threadTs:E}=m0(u.target);if(!u.asBot&&!u.channelId&&!u.userId&&await I7(D,F))console.error(`Warning: "${F}" is a DM to yourself \u2014 Slack will NOT notify you of your own message.
149
- `+` 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 pu(D,u.userId);else C=await KD(D,F);let B=u.mentions?await x0(u.mentionToken??D,u.message,C):u.message;try{for(let Q of await c1(u.mentionToken??D,B))console.error(`\u26A0 possible untagged mention: ${Q.surface} \u2014 @${Q.display} won't be notified (did you mean <@${Q.userId}>?)`)}catch{}let $="",G="?",z=[];if(E)try{let Q=await Au(D,C,E,100);z=o(Q.messages).map(m);let O=z[z.length-1];$=typeof O?.text==="string"?O.text:""}catch{}else try{let Q=await vu(D,C,1),O=o(Q.messages).map(m).filter((V)=>V.subtype===void 0||V.subtype===null)[0];$=typeof O?.text==="string"?O.text:"",G=typeof O?.user==="string"?await cu(D,O.user):typeof O?.username==="string"?O.username:"?"}catch{}if(E&&z.length){let Q={sim:0,msg:null};for(let O of z){let V=typeof O.text==="string"?O.text:"";if(!V)continue;let W=S7(B,V);if(W>Q.sim)Q={sim:W,msg:O}}if(Q.msg&&Q.sim>=0.82){let O=Math.round(Q.sim*100);console.error(`\u26A0 possible duplicate: ${O}% similar to an existing thread message \u2014 ${await b0(D,Q.msg)}`)}}let Z=yD(C,E??"",$,B);if(u.code!==Z){let Q=await e1(D,C,F);if(E){let O=await R7(D,E,z),V=z.slice(-3),W=V.length?await Promise.all(V.map(async(M)=>` ${await b0(D,M)}`)):[" (thread context unavailable)"];fD(u.code,Z,["--- Recent messages in thread ----------------",...W,"--- Sending ----------------------------------",` \u2192 ${Q} thread of ${O} \u2014 THREAD REPLY`,` Message: ${B}`,"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"])}else fD(u.code,Z,["--- Last message in channel ------------------",` ${G}: ${$.split(`
150
- `)[0]?.slice(0,100)??"(empty)"}`,"--- Sending ----------------------------------",` \u2192 ${Q} \u2014 NEW top-level message`,` Message: ${B}`,"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"])}let Y=await K1(D,C,B,E,u.broadcast),J="";try{J=await L1(D,C,Y)}catch{}if(J)console.log(`\u2713 Sent: ${J}`);else console.log(`\u2713 Sent (ts: ${Y})`);if(u.asBot&&C.startsWith("D"))try{let Q=await V0(D);if(!Q.ok)for(let O of H0(Q,!0))console.error(O);else{let O=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: ${O} \u2192 App Home.`)}}catch{}}async function f7(D){let u=await V0(D);for(let F of H0(u,!1))console.log(F);if(!u.ok)process.exit(1)}function h7(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 v7(D,u){let{ref:F,threadTs:E}=m0(u.target),C;if(u.channelId)C=u.channelId;else if(u.userId)C=await pu(D,u.userId);else C=await KD(D,F);let B=h7(u.at),$=new Date(B*1000).toISOString(),G=yD(C,u.message,String(B));if(u.code!==G)fD(u.code,G,["--- Scheduling message -----------------------",` To: ${F}${E?` (thread ${E})`:""}`,` At: ${$} (Unix: ${B})`,` Message: ${u.message}`,"---------------------------------------------"]);let z=await _1(D,C,u.message,B,E);console.log(`\u2713 Scheduled (id: ${z}, at: ${$})`)}async function p7(D,u,F){let E;if(F)E=F;else if(u)E=await KD(D,u);let B=(await j1(D,E)).scheduled_messages??[];if(B.length===0){console.log("(no scheduled messages)");return}for(let $ of B){let G=new Date($.post_at*1000).toISOString();console.log(`${$.id} ${G} [${$.channel_id}] ${$.text.split(`
151
- `)[0]?.slice(0,80)??""}`)}}async function y7(D,u){let F;if(u.channelId)F=u.channelId;else F=await KD(D,u.target);let E=yD(F,u.id);if(u.code!==E)fD(u.code,E,["--- Deleting scheduled message ---------------",` Channel: ${u.target}`,` ID: ${u.id}`,"---------------------------------------------"]);await A1(D,F,u.id),console.log(`\u2713 Deleted scheduled message ${u.id}`)}async function m7(D,u){let{statSync:F,existsSync:E}=await import("fs"),{basename:C}=await import("path");for(let Q of u.filePaths)if(!E(Q))console.error(`Error: file not found: ${Q}`),process.exit(1);let{ref:B,threadTs:$}=m0(u.target),G;if(u.channelId)G=u.channelId;else if(u.userId)G=await pu(D,u.userId);else G=await KD(D,B);let z=u.filePaths.length>1,Z=u.filePaths.map((Q)=>{let O=C(Q),V=z?O:u.title??O;return{fp:Q,filename:O,title:V,sizeFmt:v0(F(Q).size)}}),Y=yD(G,...Z.flatMap((Q)=>[Q.fp,Q.title]));if(u.code!==Y){let Q=` To: ${B}${$?` (thread ${$})`:""}`,O=z?[`--- Uploading ${Z.length} files ------------------------`,Q,...Z.map((V)=>` ${V.filename} (${V.sizeFmt})`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]:["--- Uploading file ---------------------------",Q,` File: ${Z[0].fp}`,` Title: ${Z[0].title}`,` Size: ${Z[0].sizeFmt}`,"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"];fD(u.code,Y,O)}let J=Z.length;for(let Q=0;Q<J;Q++){let O=Z[Q],V={title:O.title};if($!==void 0)V.threadTs=$;if(u.comment!==void 0&&Q===0)V.initialComment=u.comment;let{fileId:W,permalink:M}=await v1(D,G,O.fp,V),_=J>1?`[${Q+1}/${J}] `:"";console.log(`${_}\u2713 Uploaded (file_id: ${W}${M?`, url: ${M}`:""})`)}}function c7(D){if(/^F[A-Z0-9]+$/i.test(D))return D;return D.match(/\/files\/[A-Za-z0-9]+\/(F[A-Za-z0-9]+)/)?.[1]}async function g7(D,u,F,E){let C=c7(F);if(!C)throw Error(`Not a file ID or file permalink: ${F}
152
- `+"Expected F\u2026 or https://<ws>.slack.com/files/<UID>/<FID>/<name>");let B=m(await H1(D,C,u)),$=m(B.file),G=typeof $.name==="string"?$.name:typeof $.title==="string"?$.title:C,z=typeof $.url_private_download==="string"?$.url_private_download:typeof $.url_private==="string"?$.url_private:"";if(!z)throw Error(`files.info returned no download URL for ${C}`);let Z={Authorization:`Bearer ${D}`};if(u)Z.Cookie=`d=${u}`;let Y=await fetch(z,{headers:Z});if(!Y.ok)throw Error(`Download failed: HTTP ${Y.status} ${Y.statusText}`);let J=Buffer.from(await Y.arrayBuffer()),{statSync:Q,existsSync:O}=await import("fs"),{basename:V}=await import("path"),W=E??G;if(E&&O(E)&&Q(E).isDirectory())W=tD(E,V(G));o1(W,J),console.log(`\u2713 Downloaded ${G} (${v0(J.length)}) \u2192 ${W}`)}async function k7(){Y7();let D=(F)=>Z0(F.workspace),u=(F)=>P8(F.workspace);await _8(cF(process.argv)).scriptName("slack").showHelpOnFail(!1).fail((F,E,C)=>{if(E)console.error(E.message),process.exit(1);console.error(F),console.error(""),C.showHelp(),process.exit(1)}).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{Z0(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:
153
- `),await UF(),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"}).option("format",{type:"string",choices:["text","jsonl"],default:"text",describe:"jsonl exposes raw ts/user/text (incl. external-guest user IDs)"}).option("json",{type:"boolean",default:!1,describe:"Alias for --format=jsonl"}),async(F)=>{let E=D(F),C=F.json?"jsonl":F.format;if(F.target)await H7(E,F.target,F.limit,C);else await U7(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}).option("format",{type:"string",choices:["text","jsonl"],default:"text",describe:"jsonl exposes raw ts/user/text (incl. external-guest user IDs)"}).option("json",{type:"boolean",default:!1,describe:"Alias for --format=jsonl"}),async(F)=>{let E=F.json?"jsonl":F.format;await q7(D(F),F.target,F.ts,F.limit,E)}).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 K7(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}`,G=await KD(C,$),z=m(await S0(C,G)),Z=m(z.channel),Y=typeof Z.name==="string"?Z.name:G,Q=Z.is_im===!0?"@":"#",O=String(m(Z.purpose).value??""),V=String(m(Z.topic).value??""),W=Z.num_members??Z.member_count??"";if(console.log(`${Q}${Y} ${G}`),V)console.log(`topic: ${V}`);if(O)console.log(`purpose: ${O}`);if(W)console.log(`members: ${W}`);console.log(`private: ${Z.is_private===!0}`)}).command(["create <name>","new <name>"],"Create a channel (confirm-hash safety gate)",(E)=>E.positional("name",{type:"string",demandOption:!0,describe:"Channel name (Slack lowercases it; no spaces)"}).option("private",{type:"boolean",default:!1,describe:"Create a private channel"}).option("invite",{type:"string",array:!0,default:[],describe:"Users to invite after creating (@handle or Uxxxx, repeatable)"}).option("code",{type:"string",describe:"Safety hash to confirm create"}),async(E)=>{let C=D(E),B=E.name.replace(/^#/,"").toLowerCase(),$=E.private===!0,G=E.invite.filter(Boolean),z=yD(B,String($),G.join(","));if(E.code!==z)fD(E.code,z,["--- Creating channel -------------------------",` name: ${$?"\uD83D\uDD12 ":"#"}${B}`,` private: ${$}`,...G.length?[` invite: ${G.join(", ")}`]:[],"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);let Z;try{Z=await P1(C,B,$)}catch(Y){console.error(Y instanceof Error?Y.message:String(Y)),process.exit(1)}if(console.log(`\u2713 Created ${$?"\uD83D\uDD12 ":"#"}${Z.name} (${Z.id})`),G.length){let Y=[];for(let J of G)try{Y.push(J.startsWith("U")||J.startsWith("W")?J:await T0(C,J))}catch(Q){console.error(` ! could not resolve ${J}: ${Q instanceof Error?Q.message:String(Q)}`)}if(Y.length)try{await w1(C,Z.id,Y),console.log(`\u2713 Invited ${Y.length} member${Y.length===1?"":"s"}`)}catch(J){console.error(` ! invite failed: ${J instanceof Error?J.message:String(J)}`)}}}).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 R0(D(E)),$=E.filter?.toLowerCase(),G=o(B.members).map(m).filter((Z)=>Z.deleted!==!0&&Z.is_bot!==!0&&String(Z.id)!=="USLACKBOT").filter((Z)=>{if(!$)return!0;let Y=String(Z.name??"").toLowerCase(),J=String(m(Z.profile).real_name??"").toLowerCase(),Q=String(m(Z.profile).email??"").toLowerCase();return Y.includes($)||J.includes($)||Q.includes($)}).slice(0,E.limit);if(C==="jsonl"){for(let Z of G)console.log(JSON.stringify(Z));return}if(C==="yaml"){for(let Z of G){let Y=function(J,Q=""){if(J===null)return"null";if(typeof J==="string")return J.includes(`
130
+ Attach it with: slack auth chrome (macOS) or slack auth firefox`);throw Error(`Slack error on ${u}: ${G}`)}return $}function Lu(D,u,F={},E){let C=new URLSearchParams({token:D,...F});return $7(D,u,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:C.toString()},E)}function CD(D,u,F,E){let C=new URLSearchParams(F).toString();return U1(D,`${u}?${C}`,{method:"GET"},E)}function PD(D,u,F){return U1(D,u,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(F)})}async function _1(D){let u=await CD(D,"auth.test",{});return{team:u.team??"",teamId:u.team_id??"",url:u.url??"",user:u.user??"",userId:u.user_id??""}}async function j1(D){let u=await fetch(`${R0()}/auth.test`,{method:"GET",headers:{Authorization:`Bearer ${D}`}});if(u.status===429){let C=parseInt(u.headers.get("retry-after")??"60",10);throw new Au(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 yu(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 CD(D,"conversations.history",B)}async function Nu(D,u,F,E=50){return CD(D,"conversations.replies",{channel:u,ts:F,limit:String(E)})}async function M1(D,u,F){return CD(D,"files.info",{file:u},F)}async function A1(D,u,F,E){return CD(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 L1(D,u){return A1(D,u,100,1)}async function N1(D,u,F){let C=1,B=[],$={ok:!0,messages:{}};while(!0){let Z=await A1(D,u,100,C),z=pu(Z,["messages","matches"]),Q=Array.isArray(z)?z:[];B.push(...Q);let J=Number(pu(Z,["messages","paging","pages"])??1);if($=Z,Q.length===0||C>=J||B.length>=F)break;C+=1}let G=$;if(!G.messages)G.messages={};return G.messages.matches=B.slice(0,F),G}async function T1(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 PD(D,"chat.postMessage",B)).ts??""}async function R1(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 PD(D,"chat.scheduleMessage",B)).scheduled_message_id??""}async function S1(D,u){let F={};if(u)F.channel=u;return CD(D,"chat.scheduledMessages.list",F)}async function P1(D,u,F){await PD(D,"chat.deleteScheduledMessage",{channel:u,scheduled_message_id:F})}async function S0(D,u,F){return(await CD(D,"chat.getPermalink",{channel:u,message_ts:F})).permalink??""}async function w1(D,u,F,E){return(await PD(D,"chat.update",{channel:u,ts:F,text:E,blocks:[{type:"markdown",text:E}]})).ts??F}async function x1(D,u,F){await PD(D,"chat.delete",{channel:u,ts:F})}async function I1(D,u,F,E){await PD(D,"reactions.add",{channel:u,timestamp:F,name:E})}async function b1(D,u,F,E){await PD(D,"reactions.remove",{channel:u,timestamp:F,name:E})}async function f1(D,u,F=!1){let E=await PD(D,"conversations.create",{name:u,is_private:F});return{id:E.channel?.id??"",name:E.channel?.name??u}}async function h1(D,u,F){await PD(D,"conversations.invite",{channel:u,users:F.join(",")})}async function AF(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 CD(D,"conversations.list",E);if(u.push(...C.channels??[]),F=C.response_metadata?.next_cursor??"",!F)break}return{channels:u}}async function mu(D,u){let E=(await PD(D,"conversations.open",{users:u})).channel?.id;if(!E)throw Error(`Failed to open DM with user ${u}`);return E}function bD(D){return D.toLowerCase().replace(/[-_\s]/g,"")}async function P0(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=bD(u.slice(1)),C=await CD(D,"auth.test",{},F);if(E==="you"||E==="me"||bD(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 G=await CD(D,"users.list",$,F);for(let Z of G.members??[]){let z=bD(Z.name??""),Q=bD(Z.real_name??""),J=bD(Z.profile?.display_name??"");if(z===E||Q===E||J&&J===E)return Z.id??""}if(B=G.response_metadata?.next_cursor??"",!B)break}throw Error(`User not found: ${u}`)}function cu(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 G7(D){return cu(D)?.channel}async function _D(D,u,F){let E=G7(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),$=bD(B);if(C){let z=await CD(D,"auth.test",{},F);if($==="you"||$==="me"||bD(z.user??"")===$){let V=z.user_id;if(!V)throw Error("auth.test did not return user_id");let U=((await CD(D,"conversations.list",{types:"im",limit:"200"},F)).channels??[]).find((_)=>_.user===V);if(U?.id)return String(U.id);return mu(D,V)}let J="",Y="";while(!0){let V={limit:"200"};if(Y)V.cursor=Y;let W=await CD(D,"users.list",V,F);for(let U of W.members??[]){let _=bD(U.name??""),M=bD(U.real_name??""),N=bD(U.profile?.display_name??"");if(_===$||M===$||N&&N===$){J=U.id??"";break}}if(J)break;if(Y=W.response_metadata?.next_cursor??"",!Y)break}if(!J)throw Error(`User not found: ${u}`);let O="";while(!0){let V={types:"im",limit:"200"};if(O)V.cursor=O;let W=await CD(D,"conversations.list",V,F);for(let U of W.channels??[])if(U.user===J)return String(U.id??"");if(O=W.response_metadata?.next_cursor??"",!O)break}throw Error(`No existing DM with ${u} (${J}). Open it once in Slack first.`)}let G=B.toLowerCase(),Z="";while(!0){let z={limit:"200",types:"public_channel,private_channel",exclude_archived:"true"};if(Z)z.cursor=Z;let Q=await CD(D,"conversations.list",z,F);for(let J of Q.channels??[])if(String(J.name??"").toLowerCase()===G)return String(J.id??"");if(Z=Q.response_metadata?.next_cursor??"",!Z)break}throw Error(`channel not found: ${u}`)}async function gu(D,u){try{let F=await CD(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 ku(D,u){try{let F=await CD(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 w0(D,u){let F=[],E="";while(!0){let C={limit:"200"};if(E)C.cursor=E;let B=await CD(D,"users.list",C,u);if(F.push(...B.members??[]),E=B.response_metadata?.next_cursor??"",!E)break}return{members:F}}async function du(D,u){return Lu(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 Lu(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 p1(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 Lu(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 y1(D,u,F){return Lu(D,"conversations.info",{channel:u},F)}async function m1(D,u,F){return CD(D,"users.info",{user:u},F)}async function x0(D,u){return CD(D,"conversations.info",{channel:u})}async function c1(D,u,F){let E=(Date.now()/1000).toFixed(6);return Lu(D,"drafts.delete",{draft_id:u,client_last_updated_ts:E},F)}async function I0(D,u){let F=await Lu(D,"auth.test",{},u);return{userId:String(F.user_id??""),teamId:String(F.team_id??"")}}async function g1(D,u,F,E={}){let{statSync:C,readFileSync:B}=await import("node:fs"),{basename:$}=await import("node:path"),G=C(F),Z=$(F),z=await CD(D,"files.getUploadURLExternal",{filename:Z,length:String(G.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),O=await fetch(Q,{method:"POST",headers:{"Content-Type":"application/octet-stream"},body:Y});if(!O.ok)throw Error(`Upload PUT failed: ${O.status} ${O.statusText}`);let V={files:[{id:J,title:E.title??Z}],channel_id:u};if(E.threadTs)V.thread_ts=E.threadTs;if(E.initialComment)V.initial_comment=E.initialComment;let W=await PD(D,"files.completeUploadExternal",V),U={fileId:J},_=W.files?.[0]?.permalink;if(_)U.permalink=_;return U}function pu(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}function Hu(D){return D.toLowerCase().replace(/[-_\s]/g,"")}function tD(D){return D&&typeof D==="object"&&!Array.isArray(D)?D:{}}function z7(D,u){let F=Hu(u),E=tD(D.profile);for(let B of[D.name,D.real_name,E.display_name,E.real_name])if(typeof B==="string"&&B&&Hu(B)===F)return!0;let C=typeof E.email==="string"?E.email.toLowerCase():"";return C!==""&&C===u.toLowerCase()}function Z7(D){let u=tD(D.profile),F=new Set;for(let E of[u.display_name,D.real_name,D.name,u.real_name])if(typeof E==="string"&&E){let C=Hu(E);if(C.length>=2)F.add(C)}return[...F]}function J7(D,u){let F=Hu(D),E,C=!1;for(let B of u){let $=typeof B.id==="string"?B.id:"";if(!$)continue;for(let G of Z7(B)){let Z=-1;if(F===G)Z=D.length;else for(let z of d1)if(D.length>z.length&&D.endsWith(z)&&Hu(D.slice(0,D.length-z.length))===G){Z=D.length-z.length;break}if(Z<0)continue;if(!E||G.length>E.formLen)E={userId:$,matchLen:Z,formLen:G.length,display:p0(B)},C=!1;else if(G.length===E.formLen&&E.userId!==$)C=!0}}if(!E)return;return C?"ambiguous":{userId:E.userId,matchLen:E.matchLen,display:E.display}}async function f0(D,u,F,E){let C=`[${i1}ー]+`,B=`${C}(?:[._-]+${C})*`,$=new RegExp(`(?<![A-Za-z0-9._@<-])@(${B})`,"gu"),G=new Set;for(let M of u.matchAll($))G.add(M[1]);if(G.size===0)return{text:u,resolved:[],unresolved:[]};let Z=new Map;for(let M of G)Z.set(M,{status:"pending"});let z=(M)=>{for(let N of G){if(Z.get(N).status!=="pending")continue;if(v0(N)){let A=J7(N,M);if(A==="ambiguous")Z.set(N,{status:"ambiguous"});else if(A)Z.set(N,{status:"resolved",userId:A.userId,matchLen:A.matchLen,display:A.display})}else{let A=M.filter((d)=>z7(d,N)),h=new Set(A.map((d)=>typeof d.id==="string"?d.id:"").filter(Boolean));if(h.size===1){let d=A.find((o)=>typeof o.id==="string");Z.set(N,{status:"resolved",userId:d.id,matchLen:N.length,display:p0(d)})}else if(h.size>1)Z.set(N,{status:"ambiguous"})}}},Q=!1;try{let M=await OF(D,E);z((M.members??[]).map(tD)),Q=!0}catch{Q=!1}let J=[...G].some((M)=>Z.get(M).status==="pending"),Y=!1,O=!0;if(J&&F){Y=!0;try{let M=await O0(D,F,E),N=[];for(let A of M){let h=tD(await V0(D,A,E)),d=tD(h.user);if(typeof d.id!=="string")d.id=A;N.push(d)}z(N)}catch{O=!1}}let V=Q&&(F?Y&&O:!0),W=[],U=[];for(let M of G){let N=Z.get(M);if(N.status==="resolved")W.push({surface:`@${M.slice(0,N.matchLen)}`,display:N.display,userId:N.userId});else if(N.status==="ambiguous")U.push({surface:`@${M}`,reason:"ambiguous"});else U.push({surface:`@${M}`,reason:V?"no-match":"unavailable"})}return{text:u.replace($,(M,N)=>{let A=Z.get(N);if(A&&A.status==="resolved")return`<@${A.userId}>${N.slice(A.matchLen)}`;return M}),resolved:W,unresolved:U}}function h0(D){let u=[],F=!1;for(let E of D)if(E.reason==="ambiguous")u.push(`${E.surface} matches multiple people — not tagged, sent as plain text (use <@USERID> to tag)`);else if(E.reason==="unavailable"){if(F)continue;u.push("could not fetch the user list (users:read missing or an API/connection error) — @mentions not tagged, sent as plain text"),F=!0}else u.push(`${E.surface} matched no one — not tagged, sent as plain text`);return u}async function k1(D,u,F,E={}){let C=E.warn??(($)=>process.stderr.write(`${$}
131
+ `)),B=await f0(D,u,F,E.cookie);for(let $ of h0(B.unresolved))C(`warn: ${$}`);return B.text}var d1=["さん","さま","様","君","くん","ちゃん","氏","先生","先輩","殿","老师","老師","兄","姐","哥","姐妹"],i1="\\p{Script=Han}\\p{Script=Hiragana}\\p{Script=Katakana}A-Za-z0-9";function v0(D){return/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}]/u.test(D)}function X7(D){let u=[],F=new RegExp(`([${i1}]{1,12})(${d1.join("|")})`,"gu");for(let E of D.matchAll(F))u.push({ref:E[1],honorific:E[2]});for(let E of D.matchAll(/\b(?:dear|hi|hello|hey)\b[ \t]+([A-Z][A-Za-z'’-]{1,20})/gi))u.push({ref:E[1],honorific:""});for(let E of D.matchAll(/(?:^|\n)[ \t]*([A-Z][A-Za-z'’-]{1,20}),/g))u.push({ref:E[1],honorific:""});return u}function Q7(D){let u=tD(D.profile),F=new Set;for(let E of[D.name,D.real_name,u.display_name,u.real_name]){if(typeof E!=="string"||!E)continue;for(let C of[E,...E.split(/\s+/)]){let B=Hu(C);if(B.length>=2)F.add(B)}}return[...F]}function Y7(D,u){let F=Hu(D);if(F.length<2)return;for(let E of u)if(F===E)return E;if(v0(D)){for(let E of u)if(F.includes(E)||E.includes(F))return E}return}function p0(D){return[tD(D.profile).display_name,D.real_name,D.name].filter((E)=>typeof E==="string"&&E!=="")[0]??String(D.id??"?")}async function n1(D,u,F){let E=X7(u);if(E.length===0)return[];let C=new Set;for(let z of u.matchAll(/<@([A-Z0-9]+)(?:\|[^>]*)?>/g))C.add(z[1]);let $=((await OF(D,F)).members??[]).map(tD).filter((z)=>z.deleted!==!0&&z.is_bot!==!0&&z.id!=="USLACKBOT").map((z)=>({id:typeof z.id==="string"?z.id:"",forms:Q7(z),display:p0(z)})).filter((z)=>z.id!==""),G=[],Z=new Set;for(let{ref:z,honorific:Q}of E)for(let J of $){let Y=Y7(z,J.forms);if(!Y)continue;if(C.has(J.id)||Z.has(J.id))break;Z.add(J.id),G.push({surface:v0(z)?`${Y}${Q}`:z,display:J.display,userId:J.id});break}return G}async function Tu(D,u,F){let E=u,C=[],B=E,$=0;while(!0){let G=B.indexOf("<@U",$);if(G===-1)break;let Z=B.slice(G+2),z=Z.search(/[>|]/),Q=z===-1?Z:Z.slice(0,z);if(Q.length>=9)C.push(Q);$=G+1}for(let G of C){if(!F.has(G))F.set(G,await WF(D,G));let Z=F.get(G)??G;E=E.replaceAll(`<@${G}>`,`@${Z}`),E=E.replace(new RegExp(`<@${G}\\|[^>]*>`,"g"),`@${Z}`)}return E}function iu(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"],G=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Z=$[B.getUTCDay()]??"",z=G[B.getUTCMonth()]??"";return`${Z}, ${z} ${String(B.getUTCDate()).padStart(2,"0")}, ${B.getUTCFullYear()}`})}function l1(D,u=new Date){let F=new Date(D*1000),E=b0(u),C=b0(new Date(u.getTime()-86400000)),B=b0(F);if(B===E)return"Today";if(B===C)return"Yesterday";let $=F.toLocaleDateString("en-US",{weekday:"long"}),G=F.toLocaleDateString("en-US",{month:"short"});return`${$}, ${G} ${String(F.getDate()).padStart(2,"0")}`}function b0(D){return`${D.getFullYear()}-${D.getMonth()}-${D.getDate()}`}function t1(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 nu(D){if(!e1(D))return;let u=O7(D,"utf8");for(let F of u.split(`
132
+ `)){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 H7(D){V7(D,{recursive:!0});let u=oD(D,".gitignore");if(!e1(u))D3(u,`*
133
+ `)}function q7(){nu(oD(o1(),".slack-cli",".env.local")),nu(oD(o1(),".config/slack-cli",".env")),nu(oD(process.cwd(),".slack-cli",".env.local")),nu(oD(process.cwd(),".env.local")),nu(oD(process.cwd(),".env"))}function K7(D){return W7("sha256").update(D).digest("hex")}function g(D){return D&&typeof D==="object"&&!Array.isArray(D)?D:{}}function r(D){return Array.isArray(D)?D:[]}function LF(D){return Number(D.ts??0)}async function u3(D,u,F){let E=u.user;if(typeof E==="string"){if(!F.has(E))F.set(E,await ku(D,E));return F.get(E)??E}return typeof u.username==="string"?u.username:"bot"}function y0(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"),G=String(u.getUTCSeconds()).padStart(2,"0");return`${F}-${E}-${C} ${B}:${$}:${G}`}function c0(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"),G=String(C.getUTCDate()).padStart(2,"0"),Z=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}-${$}-${G}T${Z}:${z}:${Q}.${J}`}function g0(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 U7(D){return/^\d{4}-\d{2}-\d{2}T/.test(D)?g0(D):D}async function TF(D,u,F,E){let C=typeof u.ts==="string"?u.ts:`${LF(u)}.000000`,B=c0(C),$="?";if(typeof u.user==="string"){let W=u.user,U="@"+W;if(!F.has(U)){let[,_]=await gu(D,W);F.set(U,_)}$=F.get(U)??W}else if(typeof u.username==="string")$=u.username;let G=typeof u.text==="string"?u.text:"",z=iu(await Tu(D,G,F)).split(`
134
+ `),Q=z[0]+(z.length>1?`
135
+ `+z.slice(1).map((W)=>` ${W}`).join(`
136
+ `):""),J=E?`${E} @${$}`:`@${$}`,Y=r(u.reactions).map(g).map((W)=>{let U=typeof W.name==="string"?W.name:"",_=Number(W.count??r(W.users).length??0);return U?`:${U}:\xD7${_}`:""}).filter(Boolean).join(" "),O=r(u.files).map(g).map((W)=>{let U=typeof W.name==="string"?W.name:typeof W.title==="string"?W.title:"(file)",_=typeof W.size==="number"?` (${k0(W.size)})`:"",M=typeof W.id==="string"?` [${W.id}]`:"";return`
137
+ \uD83D\uDCCE ${U}${_}${M}`}).join(""),V=(Y?`
138
+ ${Y}`:"")+O;return`${B} ${J}: ${Q}${V}`}function k0(D){return D<1024?`${D} B`:D<1048576?`${(D/1024).toFixed(1)} KB`:`${(D/1048576).toFixed(1)} MB`}function _7(D){return r(D.files).map(g).map((u)=>({id:u.id??null,name:u.name??u.title??null,mimetype:u.mimetype??null,size:u.size??null,url_private_download:u.url_private_download??u.url_private??null,permalink:u.permalink??null}))}function F3(D){let u=_7(D);return{ts:D.ts??null,user:D.user??null,username:D.username??null,bot_id:D.bot_id??null,thread_ts:D.thread_ts??null,text:typeof D.text==="string"?D.text:"",...u.length>0?{files:u}:{}}}async function j7(D,u,F,E="text"){let C=cu(u),B=await _D(D,u),$=new Map,Z=await(async()=>{if(C?.threadTs){let Q=await Nu(D,B,C.threadTs,F);return r(Q.messages).map(g)}let z=await yu(D,B,F);return r(z.messages).map(g).reverse()})();if(E==="jsonl"){for(let z of Z)console.log(JSON.stringify(F3(z)));return}for(let z of Z)console.log(await TF(D,z,$))}async function M7(D,u,F,E,C="text"){let B=await _D(D,u),$=await Nu(D,B,U7(F),E),G=r($.messages).map(g);if(C==="jsonl"){for(let z of G)console.log(JSON.stringify(F3(z)));return}let Z=new Map;for(let z of G)console.log(await TF(D,z,Z))}async function A7(D){let u=await AF(D),F=r(u.channels).map(g).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,G=await yu(D,B,5),Z=r(G.messages).map(g).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(Z.length===0)continue;console.log(`-- #${$} --------------------------------`);for(let z of Z){let Q=await u3(D,z,E),J=(typeof z.text==="string"?z.text:"").split(`
139
+ `)[0]??"",Y=await Tu(D,J,E);console.log(` ${Q}: ${Y}`)}}}async function L7(D,u){let F=await L1(D,"to:me"),E=r(pu(F,["messages","matches"])).map(g).slice(0,u),C=new Map,B=[];for(let $ of E){let G=l1(LF($)),Z=B[B.length-1];if(Z?.label===G)Z.msgs.push($);else B.push({label:G,msgs:[$]})}for(let $=0;$<B.length;$++){let{label:G,msgs:Z}=B[$];if($>0)console.log("");console.log(` ${G}`),console.log(" ----------------------------");for(let z of[...Z].reverse()){let Q=g(z.channel),J=Q.is_im===!0,Y=typeof Q.name==="string"?Q.name:"dm",O;if(J&&Y.startsWith("U")){let V="@"+Y;if(!C.has(V)){let[,W]=await gu(D,Y);C.set(V,W)}O=`@${C.get(V)??Y}`}else if(J)O=`@${Y}`;else O=`#${Y}`;console.log(await TF(D,z,C,O))}}}async function N7(D,u,F,E,C="text"){let B=await AF(D),$=r(B.channels).map(g).filter((G)=>E||G.is_member===!0).filter((G)=>{if(!F)return!0;return(typeof G.name==="string"?G.name:"").toLowerCase().includes(F.toLowerCase())}).sort((G,Z)=>Number(Z.updated??0)-Number(G.updated??0)).slice(0,u);if(C==="jsonl"){for(let G of $)console.log(JSON.stringify(G));return}for(let G of $){let Z=String(G.id??""),z=typeof G.name==="string"?G.name:typeof G.user==="string"?G.user:Z,Q=G.is_im===!0,J=G.is_mpim===!0,Y=Q||J?"@":"#",O=G.is_member===!0?"":" (not joined)",V=typeof g(G.purpose).value==="string"?String(g(G.purpose).value):"",W=V?` ${V.split(`
140
+ `)[0]?.slice(0,60)}`:"";console.log(`${Y}${z} ${Z}${O}${W}`)}}async function T7(D,u,F,E){let C=await N1(D,u,F);if(E){console.log(JSON.stringify(C,null,2));return}let B=r(pu(C,["messages","matches"])).map(g),$=new Map;for(let G of B){let Z=g(G.channel),z=Z.is_im===!0,Q=typeof Z.name==="string"?Z.name:"dm",J;if(z&&Q.startsWith("U")){let Y="@"+Q;if(!$.has(Y)){let[,O]=await gu(D,Q);$.set(Y,O)}J=`@${$.get(Y)??Q}`}else if(z)J=`@${Q}`;else J=`#${Q}`;console.log(await TF(D,G,$,J))}}async function R7(D,u,F,E){let C=Math.floor(Date.now()/1000)-u*86400,B=await AF(D),$=r(B.channels).map(g).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)),G=new Map,Z=0,z=0;for(let Q of $){let J=String(Q.id??""),Y=typeof Q.name==="string"?Q.name:J,O;try{O=await yu(D,J,F)}catch(W){console.error(` SKIP #${Y}: ${W.message}`);continue}let V=r(O.messages).map(g).filter((W)=>(W.subtype===void 0||W.subtype===null)&&LF(W)>=C);if(V.length===0)continue;z+=1,Z+=V.length,console.log(`## #${Y} (${V.length} msgs)
141
+ `);for(let W of[...V].reverse()){let U=await u3(D,W,G),_=typeof W.text==="string"?W.text:"",N=iu(await Tu(D,_,G)).split(`
142
+ `).join(" \u21B5 ");console.log(`[${t1(LF(W))}] ${U}: ${N}`)}console.log("")}console.error(`Dumped ${Z} messages across ${z} channels (cutoff: ${u}d)`)}function S7(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 E3(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 y1(D,C,u),$=g(B.channel),G;if($.is_im===!0){let Z=typeof $.user==="string"?$.user:"";if(!Z||Z===F)G="@self";else{let[z]=await gu(D,Z);G=`@${z}`}}else G=`#${typeof $.name==="string"?$.name:C}`;return E.set(C,G),G}catch{return C}}}function d0(D){let u=g(r(D.destinations)[0]);return String(u.channel_id??D.channel_id??D.channel??"")}function NF(D){return S7(r(D.blocks))||(typeof D.text==="string"?D.text:"(no text)")}async function P7(D,u,F=!1){let E=await du(D,u),C=r(E.drafts??E.messages??[]).map(g).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 I0(D,u))}catch{}let G=await E3(D,u,$),Z=new Map;for(let z of B){let Q=d0(z),J=NF(z),Y=Number(z.date_created??z.date_create??0),O=Y?y0(Y):"?",V=await G(Q),W=typeof z.id==="string"?z.id:"",U=z.is_sent===!0?" [SENT]":"",_=iu(await Tu(D,J,Z));console.log(`-- ${W} ${V} [${O}]${U}`);for(let M of _.split(`
143
+ `))console.log(` ${M}`)}}async function w7(D,u,F){let E=await du(D,u),C=r(E.drafts).map(g).find((V)=>String(V.id)===F);if(!C)console.error(`Draft not found: ${F}`),process.exit(1);let B="";try{({userId:B}=await I0(D,u))}catch{}let $=await E3(D,u,B),G=d0(C),Z=NF(C),z=Number(C.date_created??0),Q=String(C.last_updated_ts??"?"),J=await $(G),O=iu(await Tu(D,Z,new Map));console.log(`id: ${C.id}`),console.log(`channel: ${J} (${G})`),console.log(`created: ${z?y0(z):"?"}`),console.log(`updated: ${y0(Number(Q.split(".")[0]))}`),console.log(`status: ${C.is_sent===!0?"sent":"pending"}`),console.log("---"),console.log(O)}function yD(...D){return K7(D.join(`
144
+ `)).slice(0,4)}function Ru(D){return D.replace(/\x1b\[[0-9;:?]*[ -/]*[@-~]/g,"").replace(/[\x00-\x1f\x7f-\x9f]/g,"").replace(/[\u061c\u200e\u200f\u202a-\u202e\u2066-\u2069]/g,"")}var x7={"reactions.add":"reactions:write","reactions.remove":"reactions:write","chat.postMessage":"chat:write","chat.update":"chat:write","chat.delete":"chat:write","conversations.replies":"channels:history (or groups:history)","conversations.history":"channels:history (or groups:history)"};function s1(D){let u=D instanceof Error?D.message:String(D),F=u.match(/Slack error on (\S+): (\w+)/);if(!F)return u;let[,E,C]=F;switch(C){case"missing_scope":return`Error: token lacks the ${x7[E]??"the required"} scope (needed for ${E}). Add it to your Slack App's User Token Scopes (or Bot Token Scopes if you use a bot token / --as-bot) \u2014 it must be on the token type the CLI actually uses \u2014 then reinstall to the workspace.`;case"invalid_name":return"Error: not a valid emoji shortcode \u2014 use the name without colons (e.g. white_check_mark), and make sure it exists in the workspace.";case"already_reacted":return"Error: you've already added that reaction to the message.";case"no_reaction":return"Error: that reaction isn't on the message \u2014 nothing to remove.";case"message_not_found":return"Error: no message found at that timestamp in the channel \u2014 check the target ts/permalink.";case"channel_not_found":return"Error: channel not found \u2014 check the target.";default:return u}}function fD(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 i0(D){let u=cu(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:g0(E)}}}return{ref:D}}function n0(D){let u=cu(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:g0(E)}}return{ref:D}}async function C3(D,u,F){let E=F;if(!F.startsWith("#")&&!F.startsWith("@"))try{let C=g(await x0(D,u)),B=g(C.channel);if(B.is_im===!0){let $=typeof B.user==="string"?B.user:"";E=$?`@${await ku(D,$)}`:u}else E=typeof B.name==="string"?`#${B.name}`:u}catch{E=u}return E===u?u:`${E} (${u})`}async function m0(D,u,F=60){let E=typeof u.user==="string"?await ku(D,u.user):typeof u.username==="string"?u.username:"?",C=(typeof u.text==="string"?u.text:"").split(`
145
+ `)[0]??"",B=C.length>F?`${C.slice(0,F)}\u2026`:C,$=typeof u.ts==="string"?u.ts:"";return`${$?c0($).slice(0,16).replace("T"," "):""} @${E}${B?`: ${B}`:""}`}async function I7(D,u,F){let E=F.find((C)=>String(C.ts)===u)??F[0];if(!E)return u;return m0(D,E,40)}function r1(D){return D.toLowerCase().replace(/<[@#!][^>]+>/g," ").replace(/[^\p{L}\p{N}\s]/gu," ").replace(/\s+/g," ").trim()}function b7(D,u){let F=r1(D),E=r1(u);if(!F||!E)return 0;if(F===E)return 1;let C=(z)=>{let Q=new Map;for(let J=0;J<z.length-1;J++){let Y=z.slice(J,J+2);Q.set(Y,(Q.get(Y)??0)+1)}return Q},B=C(F),$=C(E);if(B.size===0||$.size===0)return 0;let G=0;for(let[z,Q]of B){let J=$.get(z);if(J)G+=Math.min(Q,J)}let Z=a1(B)+a1($);return Z===0?0:2*G/Z}function a1(D){let u=0;for(let F of D.values())u+=F;return u}async function f7(D,u){let{ref:F,ts:E}=i0(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 _D(D,F);let B=await Nu(D,C,E,1),G=r(B.messages).map(g).find((Y)=>String(Y.ts)===E);if(!G)console.error(`Message not found at ts=${E} in channel ${C}`),process.exit(1);let Z=typeof G.text==="string"?G.text:"",z=u.mentions?await k1(D,u.newText,C):u.newText,Q=yD(Z,z);if(u.code!==Q)fD(u.code,Q,["--- Original message -------------------------",...Z.split(`
146
+ `).map((Y)=>` ${Y}`),"--- Replacing with ---------------------------",...z.split(`
147
+ `).map((Y)=>` ${Y}`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);let J=await w1(D,C,E,z);console.log(`\u2713 Edited (ts: ${J})`)}async function h7(D,u){let{ref:F,ts:E}=i0(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 _D(D,F);let B=await Nu(D,C,E,1),G=r(B.messages).map(g).find((Q)=>String(Q.ts)===E);if(!G)console.error(`Message not found at ts=${E} in channel ${C}`),process.exit(1);let Z=typeof G.text==="string"?G.text:"",z=yD(C,E,Z);if(u.code!==z){let Q=await C3(D,C,F);fD(u.code,z,["--- Deleting message -------------------------",` \u2192 ${Q} at ${c0(E)}`,...Z.split(`
148
+ `).map((J)=>` ${J}`),"---------------------------------------------"])}await x1(D,C,E),console.log(`\u2713 Deleted (ts: ${E})`)}async function v7(D,u){let{ref:F,ts:E}=i0(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=u.emoji.replace(/^:|:$/g,""),B;if(u.channelId)B=u.channelId;else B=await _D(D,F);if(u.remove)await b1(D,B,E,C),console.log(`\u2713 Removed :${C}: (ts: ${E})`);else await I1(D,B,E,C),console.log(`\u2713 Reacted :${C}: (ts: ${E})`)}async function p7(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 y7(D,u){let{ref:F,threadTs:E}=n0(u.target);if(!u.asBot&&!u.channelId&&!u.userId&&await p7(D,F))console.error(`Warning: "${F}" is a DM to yourself \u2014 Slack will NOT notify you of your own message.
149
+ `+` 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 mu(D,u.userId);else C=await _D(D,F);let B=u.message,$=null;if(u.mentions){$=await f0(u.mentionToken??D,u.message,C,u.mentionCookie),B=$.text;for(let _ of h0($.unresolved))console.error(`\u26A0 ${Ru(_)}`)}try{for(let _ of await n1(u.mentionToken??D,B,u.mentionCookie))console.error(`\u26A0 possible untagged mention: ${Ru(_.surface)} \u2014 @${Ru(_.display)} won't be notified (did you mean <@${_.userId}>?)`)}catch{}let G=[];if($&&($.resolved.length>0||$.unresolved.length>0)){G.push("--- Mentions ---------------------------------");for(let _ of $.resolved)G.push(` \u2713 ${Ru(_.surface)} \u2192 @${Ru(_.display)} (${_.userId}) \u2014 will notify`);for(let _ of $.unresolved){let M=_.reason==="ambiguous"?"ambiguous":_.reason==="unavailable"?"lookup unavailable":"no match";G.push(` \u26A0 ${Ru(_.surface)} \u2014 plain text, NOT notified (${M})`)}}let Z="",z="?",Q=[],J,Y,O;if(E)try{let _=await Nu(D,C,E,100);Q=r(_.messages).map(g);let M=Q[Q.length-1];Z=typeof M?.text==="string"?M.text:"",J=typeof M?.user==="string"?M.user:void 0,Y=typeof M?.bot_id==="string"?M.bot_id:void 0,O=typeof M?.ts==="string"?M.ts:void 0}catch{}else try{let _=await yu(D,C,1),M=r(_.messages).map(g),N=M.filter((h)=>h.subtype===void 0||h.subtype===null)[0];Z=typeof N?.text==="string"?N.text:"",z=typeof N?.user==="string"?await ku(D,N.user):typeof N?.username==="string"?N.username:"?";let A=M[0];J=typeof A?.user==="string"?A.user:void 0,Y=typeof A?.bot_id==="string"?A.bot_id:void 0,O=typeof A?.ts==="string"?A.ts:void 0}catch{}if(process.env.SLACK_UNREPLIED_WARN!=="0"&&O&&(J||Y))try{let _=await j1(D);if(!!J&&!!_.userId&&_.userId===J||!!Y&&!!_.botId&&_.botId===Y){let N=`slack edit "#${C}:${O}" "<\u65B0\u3057\u3044\u672C\u6587>" --channel-id ${C}`;try{let A=await S0(D,C,O);if(A)N=`slack edit "${A}" "<\u65B0\u3057\u3044\u672C\u6587>"`}catch{}console.error("\u26A0 \u76F8\u624B\u306F\u307E\u3060\u8FD4\u4FE1\u3057\u3066\u3044\u307E\u305B\u3093(\u6700\u5F8C\u306E\u30E1\u30C3\u30BB\u30FC\u30B8\u306F\u3042\u306A\u305F\u306E\u3082\u306E\u3067\u3059)\u3002"),console.error(" \u9023\u6295\u3092\u907F\u3051\u308B\u305F\u3081\u3001\u65B0\u898F\u9001\u4FE1\u3067\u306A\u304F\u76F4\u524D\u306E\u30E1\u30C3\u30BB\u30FC\u30B8\u306E edit \u3092\u691C\u8A0E\u3057\u3066\u304F\u3060\u3055\u3044:"),console.error(` ${N}`),console.error(" \u3053\u306E\u307E\u307E\u9001\u4FE1\u3059\u308B\u5834\u5408\u306F --code=XXXX \u3067\u78BA\u5B9A\u3002")}}catch{}if(E&&Q.length){let _={sim:0,msg:null};for(let M of Q){let N=typeof M.text==="string"?M.text:"";if(!N)continue;let A=b7(B,N);if(A>_.sim)_={sim:A,msg:M}}if(_.msg&&_.sim>=0.82){let M=Math.round(_.sim*100);console.error(`\u26A0 possible duplicate: ${M}% similar to an existing thread message \u2014 ${await m0(D,_.msg)}`)}}let V=yD(C,E??"",Z,B);if(u.code!==V){let _=await C3(D,C,F);if(E){let M=await I7(D,E,Q),N=Q.slice(-3),A=N.length?await Promise.all(N.map(async(h)=>` ${await m0(D,h)}`)):[" (thread context unavailable)"];fD(u.code,V,["--- Recent messages in thread ----------------",...A,...G,"--- Sending ----------------------------------",` \u2192 ${_} thread of ${M} \u2014 THREAD REPLY`,` Message: ${B}`,"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"])}else fD(u.code,V,["--- Last message in channel ------------------",` ${z}: ${Z.split(`
150
+ `)[0]?.slice(0,100)??"(empty)"}`,...G,"--- Sending ----------------------------------",` \u2192 ${_} \u2014 NEW top-level message`,` Message: ${B}`,"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"])}let W=await T1(D,C,B,E,u.broadcast),U="";try{U=await S0(D,C,W)}catch{}if(U)console.log(`\u2713 Sent: ${U}`);else console.log(`\u2713 Sent (ts: ${W})`);if(u.asBot&&C.startsWith("D"))try{let _=await H0(D);if(!_.ok)for(let M of q0(_,!0))console.error(M);else{let M=_.appId?`https://api.slack.com/apps/${_.appId}`:"https://api.slack.com/apps";console.error(`Note: if ${u.target} can't reply (app messaging may be off), enable Messages Tab: ${M} \u2192 App Home.`)}}catch{}}async function m7(D){let u=await H0(D);for(let F of q0(u,!1))console.log(F);if(!u.ok)process.exit(1)}function c7(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 g7(D,u){let{ref:F,threadTs:E}=n0(u.target),C;if(u.channelId)C=u.channelId;else if(u.userId)C=await mu(D,u.userId);else C=await _D(D,F);let B=c7(u.at),$=new Date(B*1000).toISOString(),G=yD(C,u.message,String(B));if(u.code!==G)fD(u.code,G,["--- Scheduling message -----------------------",` To: ${F}${E?` (thread ${E})`:""}`,` At: ${$} (Unix: ${B})`,` Message: ${u.message}`,"---------------------------------------------"]);let Z=await R1(D,C,u.message,B,E);console.log(`\u2713 Scheduled (id: ${Z}, at: ${$})`)}async function k7(D,u,F){let E;if(F)E=F;else if(u)E=await _D(D,u);let B=(await S1(D,E)).scheduled_messages??[];if(B.length===0){console.log("(no scheduled messages)");return}for(let $ of B){let G=new Date($.post_at*1000).toISOString();console.log(`${$.id} ${G} [${$.channel_id}] ${$.text.split(`
151
+ `)[0]?.slice(0,80)??""}`)}}async function d7(D,u){let F;if(u.channelId)F=u.channelId;else F=await _D(D,u.target);let E=yD(F,u.id);if(u.code!==E)fD(u.code,E,["--- Deleting scheduled message ---------------",` Channel: ${u.target}`,` ID: ${u.id}`,"---------------------------------------------"]);await P1(D,F,u.id),console.log(`\u2713 Deleted scheduled message ${u.id}`)}async function i7(D,u){let{statSync:F,existsSync:E}=await import("fs"),{basename:C}=await import("path");for(let Y of u.filePaths)if(!E(Y))console.error(`Error: file not found: ${Y}`),process.exit(1);let{ref:B,threadTs:$}=n0(u.target),G;if(u.channelId)G=u.channelId;else if(u.userId)G=await mu(D,u.userId);else G=await _D(D,B);let Z=u.filePaths.length>1,z=u.filePaths.map((Y)=>{let O=C(Y),V=Z?O:u.title??O;return{fp:Y,filename:O,title:V,sizeFmt:k0(F(Y).size)}}),Q=yD(G,...z.flatMap((Y)=>[Y.fp,Y.title]));if(u.code!==Q){let Y=` To: ${B}${$?` (thread ${$})`:""}`,O=Z?[`--- Uploading ${z.length} files ------------------------`,Y,...z.map((V)=>` ${V.filename} (${V.sizeFmt})`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]:["--- Uploading file ---------------------------",Y,` File: ${z[0].fp}`,` Title: ${z[0].title}`,` Size: ${z[0].sizeFmt}`,"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"];fD(u.code,Q,O)}let J=z.length;for(let Y=0;Y<J;Y++){let O=z[Y],V={title:O.title};if($!==void 0)V.threadTs=$;if(u.comment!==void 0&&Y===0)V.initialComment=u.comment;let{fileId:W,permalink:U}=await g1(D,G,O.fp,V),_=J>1?`[${Y+1}/${J}] `:"";console.log(`${_}\u2713 Uploaded (file_id: ${W}${U?`, url: ${U}`:""})`)}}function n7(D){if(/^F[A-Z0-9]+$/i.test(D))return D;return D.match(/\/files\/[A-Za-z0-9]+\/(F[A-Za-z0-9]+)/)?.[1]}async function l7(D,u,F,E){let C=n7(F);if(!C)throw Error(`Not a file ID or file permalink: ${F}
152
+ `+"Expected F\u2026 or https://<ws>.slack.com/files/<UID>/<FID>/<name>");let B=g(await M1(D,C,u)),$=g(B.file),G=typeof $.name==="string"?$.name:typeof $.title==="string"?$.title:C,Z=typeof $.url_private_download==="string"?$.url_private_download:typeof $.url_private==="string"?$.url_private:"";if(!Z)throw Error(`files.info returned no download URL for ${C}`);let z={Authorization:`Bearer ${D}`};if(u)z.Cookie=`d=${u}`;let Q=await fetch(Z,{headers:z});if(!Q.ok)throw Error(`Download failed: HTTP ${Q.status} ${Q.statusText}`);let J=Buffer.from(await Q.arrayBuffer()),{statSync:Y,existsSync:O}=await import("fs"),{basename:V}=await import("path"),W=E??G;if(E&&O(E)&&Y(E).isDirectory())W=oD(E,V(G));D3(W,J),console.log(`\u2713 Downloaded ${G} (${k0(J.length)}) \u2192 ${W}`)}async function t7(){q7();let D=(F)=>J0(F.workspace),u=(F)=>h8(F.workspace);await R8(gF(process.argv)).scriptName("slack").showHelpOnFail(!1).fail((F,E,C)=>{if(E)console.error(E.message),process.exit(1);console.error(F),console.error(""),C.showHelp(),process.exit(1)}).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{J0(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:
153
+ `),await _F(),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"}).option("format",{type:"string",choices:["text","jsonl"],default:"text",describe:"jsonl exposes raw ts/user/text (incl. external-guest user IDs)"}).option("json",{type:"boolean",default:!1,describe:"Alias for --format=jsonl"}),async(F)=>{let E=D(F),C=F.json?"jsonl":F.format;if(F.target)await j7(E,F.target,F.limit,C);else await A7(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}).option("format",{type:"string",choices:["text","jsonl"],default:"text",describe:"jsonl exposes raw ts/user/text (incl. external-guest user IDs)"}).option("json",{type:"boolean",default:!1,describe:"Alias for --format=jsonl"}),async(F)=>{let E=F.json?"jsonl":F.format;await M7(D(F),F.target,F.ts,F.limit,E)}).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 N7(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}`,G=await _D(C,$),Z=g(await x0(C,G)),z=g(Z.channel),Q=typeof z.name==="string"?z.name:G,Y=z.is_im===!0?"@":"#",O=String(g(z.purpose).value??""),V=String(g(z.topic).value??""),W=z.num_members??z.member_count??"";if(console.log(`${Y}${Q} ${G}`),V)console.log(`topic: ${V}`);if(O)console.log(`purpose: ${O}`);if(W)console.log(`members: ${W}`);console.log(`private: ${z.is_private===!0}`)}).command(["create <name>","new <name>"],"Create a channel (confirm-hash safety gate)",(E)=>E.positional("name",{type:"string",demandOption:!0,describe:"Channel name (Slack lowercases it; no spaces)"}).option("private",{type:"boolean",default:!1,describe:"Create a private channel"}).option("invite",{type:"string",array:!0,default:[],describe:"Users to invite after creating (@handle or Uxxxx, repeatable)"}).option("code",{type:"string",describe:"Safety hash to confirm create"}),async(E)=>{let C=D(E),B=E.name.replace(/^#/,"").toLowerCase(),$=E.private===!0,G=E.invite.filter(Boolean),Z=yD(B,String($),G.join(","));if(E.code!==Z)fD(E.code,Z,["--- Creating channel -------------------------",` name: ${$?"\uD83D\uDD12 ":"#"}${B}`,` private: ${$}`,...G.length?[` invite: ${G.join(", ")}`]:[],"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);let z;try{z=await f1(C,B,$)}catch(Q){console.error(Q instanceof Error?Q.message:String(Q)),process.exit(1)}if(console.log(`\u2713 Created ${$?"\uD83D\uDD12 ":"#"}${z.name} (${z.id})`),G.length){let Q=[];for(let J of G)try{Q.push(J.startsWith("U")||J.startsWith("W")?J:await P0(C,J))}catch(Y){console.error(` ! could not resolve ${J}: ${Y instanceof Error?Y.message:String(Y)}`)}if(Q.length)try{await h1(C,z.id,Q),console.log(`\u2713 Invited ${Q.length} member${Q.length===1?"":"s"}`)}catch(J){console.error(` ! invite failed: ${J instanceof Error?J.message:String(J)}`)}}}).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 w0(D(E)),$=E.filter?.toLowerCase(),G=r(B.members).map(g).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(g(z.profile).real_name??"").toLowerCase(),Y=String(g(z.profile).email??"").toLowerCase();return Q.includes($)||J.includes($)||Y.includes($)}).slice(0,E.limit);if(C==="jsonl"){for(let z of G)console.log(JSON.stringify(z));return}if(C==="yaml"){for(let z of G){let Q=function(J,Y=""){if(J===null)return"null";if(typeof J==="string")return J.includes(`
154
154
  `)?`|
155
155
  ${J.split(`
156
156
  `).join(`
157
157
  `)}`:J;if(typeof J!=="object")return String(J);if(Array.isArray(J))return J.map((O)=>`
158
- ${Q} - ${Y(O,Q+" ")}`).join("");return Object.entries(J).map(([O,V])=>`
159
- ${Q} ${O}: ${Y(V,Q+" ")}`).join("")};console.log("---");for(let[J,Q]of Object.entries(Z))console.log(`${J}: ${Y(Q)}`)}return}let z=Intl.DateTimeFormat().resolvedOptions().timeZone;for(let Z of G){let Y=m(Z.profile),J=String(Z.name??Z.id),Q=String(Z.id??""),O=String(Y.display_name||""),V=String(Y.real_name||""),W=String(Y.email||""),M=String(Z.tz??""),N=[...new Set([O,V].filter((c)=>c&&c!==J))].join(" / "),w=[W,M&&M!==z?M:""].filter(Boolean).join(" ");console.log(`@${J} ${Q} ${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 R0(C),c=o(w.members).map(m).find((e)=>String(e.name??"")===B);if(!c)console.error(`User not found: @${B}`),process.exit(1);$=String(c.id)}let G=m(await f1(C,$)),z=m(G.user),Z=m(z.profile),Y=Intl.DateTimeFormat().resolvedOptions().timeZone,J=String(z.name??$),Q=String(z.id??$),O=String(Z.display_name||""),V=String(Z.real_name||""),W=String(Z.email||""),M=String(z.tz??""),_=String(Z.phone||""),N=String(Z.title||"");console.log(`@${J} ${Q}`);let k=[...new Set([O,V].filter((w)=>w&&w!==J))];if(k.length)console.log(`name: ${k.join(" / ")}`);if(W)console.log(`email: ${W}`);if(_)console.log(`phone: ${_}`);if(N)console.log(`title: ${N}`);if(M&&M!==Y)console.log(`tz: ${M}`)}).demandCommand(1,"").showHelpOnFail(!0)).command("news","Activity feed (mentions to you)",(F)=>F.option("limit",{alias:"l",type:"number",default:20}),async(F)=>{await M7(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 _7(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.`}).option("mentions",{type:"boolean",default:!0,describe:"Convert @handle tokens to real <@USERID> mentions (on by default; resolves via users.list, then channel members for Slack Connect guests). Unresolved handles stay as plain text. The confirm preview shows the converted message before sending. Disable with --no-mentions for literal @text."}),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;if(F.mentions!==!1)E.mentions=!0,E.mentionToken=D(F);let C;if(F["as-bot"]){let B=J0();if(!B)console.error(`Error: --as-bot needs a bot token, but no xoxb- token was found.
160
- 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 T0(D(F),E.target)}catch($){console.error(`Error: could not resolve ${E.target} to a user for the bot DM.
158
+ ${Y} - ${Q(O,Y+" ")}`).join("");return Object.entries(J).map(([O,V])=>`
159
+ ${Y} ${O}: ${Q(V,Y+" ")}`).join("")};console.log("---");for(let[J,Y]of Object.entries(z))console.log(`${J}: ${Q(Y)}`)}return}let Z=Intl.DateTimeFormat().resolvedOptions().timeZone;for(let z of G){let Q=g(z.profile),J=String(z.name??z.id),Y=String(z.id??""),O=String(Q.display_name||""),V=String(Q.real_name||""),W=String(Q.email||""),U=String(z.tz??""),M=[...new Set([O,V].filter((h)=>h&&h!==J))].join(" / "),A=[W,U&&U!==Z?U:""].filter(Boolean).join(" ");console.log(`@${J} ${Y} ${M}${A?" "+A:""}`)}}).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 A=await w0(C),h=r(A.members).map(g).find((d)=>String(d.name??"")===B);if(!h)console.error(`User not found: @${B}`),process.exit(1);$=String(h.id)}let G=g(await m1(C,$)),Z=g(G.user),z=g(Z.profile),Q=Intl.DateTimeFormat().resolvedOptions().timeZone,J=String(Z.name??$),Y=String(Z.id??$),O=String(z.display_name||""),V=String(z.real_name||""),W=String(z.email||""),U=String(Z.tz??""),_=String(z.phone||""),M=String(z.title||"");console.log(`@${J} ${Y}`);let N=[...new Set([O,V].filter((A)=>A&&A!==J))];if(N.length)console.log(`name: ${N.join(" / ")}`);if(W)console.log(`email: ${W}`);if(_)console.log(`phone: ${_}`);if(M)console.log(`title: ${M}`);if(U&&U!==Q)console.log(`tz: ${U}`)}).demandCommand(1,"").showHelpOnFail(!0)).command("news","Activity feed (mentions to you)",(F)=>F.option("limit",{alias:"l",type:"number",default:20}),async(F)=>{await L7(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 T7(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.`}).option("mentions",{type:"boolean",default:!0,describe:"Convert @handle tokens to real <@USERID> mentions (on by default; resolves via users.list, then channel members for Slack Connect guests). Unresolved handles stay as plain text. The confirm preview shows the converted message before sending. Disable with --no-mentions for literal @text."}),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;if(F.mentions!==!1){E.mentions=!0,E.mentionToken=D(F);let B=u(F);if(B)E.mentionCookie=B}let C;if(F["as-bot"]){let B=X0();if(!B)console.error(`Error: --as-bot needs a bot token, but no xoxb- token was found.
160
+ 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 P0(D(F),E.target)}catch($){console.error(`Error: could not resolve ${E.target} to a user for the bot DM.
161
161
  ${$ instanceof Error?$.message:String($)}
162
- Tip: pass --user-id <Uxxxx> to skip the lookup.`),process.exit(1)}C=B,E.asBot=!0}else C=D(F);try{await b7(C,E)}catch(B){console.error(i1(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=J0();if(!F)console.error(`Error: slack doctor checks the bot token, but no xoxb- token was found.
163
- Set SLACK_BOT_TOKEN=xoxb-... in ~/.config/slack-cli/.env (or your shell).`),process.exit(1);await f7(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 v7(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 p7(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 y7(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"}).option("mentions",{type:"boolean",default:!0,describe:"Convert @handle tokens in the new text to real <@USERID> mentions (on by default). Unresolved handles stay as plain text. Disable with --no-mentions for literal @text."}),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"];if(F.mentions!==!1)E.mentions=!0;await P7(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 w7(D(F),E)}).command("react <target> <emoji>","Add (or --remove) an emoji reaction \u2014 a lightweight ack that doesn't grow the thread",(F)=>F.positional("target",{type:"string",demandOption:!0,describe:"#chan:ts, @user:ts, or permalink"}).positional("emoji",{type:"string",demandOption:!0,describe:"Emoji shortcode without colons (e.g. eyes, white_check_mark, hourglass)"}).option("remove",{type:"boolean",default:!1,describe:"Remove the reaction instead of adding it"}).option("channel-id",{type:"string",describe:"Raw channel ID"}),async(F)=>{let E={target:F.target,emoji:F.emoji};if(F.remove)E.remove=!0;if(F["channel-id"])E.channelId=F["channel-id"];try{await x7(D(F),E)}catch(C){console.error(i1(C)),process.exit(1)}}).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 m7(D(F),E)}).command("download <ref> [dest]","Download a file attachment (by file ID or file permalink) to disk",(F)=>F.positional("ref",{type:"string",demandOption:!0,describe:"File ID (F\u2026) or Slack file permalink"}).positional("dest",{type:"string",describe:"Output path or directory (default: ./<filename>)"}),async(F)=>{await g7(D(F),u(F),F.ref,F.dest)}).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 j7(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 L7(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 G=await KD(C,E.channel,B),z=await x1(C,G,$,B);console.log(`\u2713 Draft created (id: ${m(z.draft).id??"?"})`)}).command("get <id>","Show a draft",(E)=>E.positional("id",{type:"string",demandOption:!0}),async(E)=>{await N7(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 G=await gu(C,B),z=o(G.drafts).map(m).find((Q)=>String(Q.id)===E.id);if(!z)console.error(`Draft not found: ${E.id}`),process.exit(1);let Z=LF(z),Y=yD(Z,$);if(E.code!==Y)fD(E.code,Y,["--- Current draft ----------------------------",...Z.split(`
164
- `).map((Q)=>` ${Q}`),"--- Replacing with ---------------------------",...$.split(`
165
- `).map((Q)=>` ${Q}`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);let J=await I1(C,E.id,p0(z),$,B);console.log(`\u2713 Draft updated (id: ${m(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 gu(C,B),G=o($.drafts).map(m).find((Y)=>String(Y.id)===E.id);if(!G)console.error(`Draft not found: ${E.id}`),process.exit(1);let z=LF(G),Z=yD(E.id,z);if(E.code!==Z)fD(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}`,...z.split(`
166
- `).map((Y)=>` ${Y}`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);await h1(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 B1({...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 $1({...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 UF({...E.token!==void 0?{token:E.token}:{},...E.name!==void 0?{name:E.name}:{}})}).command(["ls","status"],"Show auth status",()=>{},()=>{let E=T8();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)Q7(tD(process.cwd(),".slack-cli"));S8(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)=>{R8(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 E1({...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 C1({...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 Y1(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 UF({...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()}k7().catch((D)=>{console.error(D instanceof Error?D.message:String(D)),process.exit(1)});
162
+ Tip: pass --user-id <Uxxxx> to skip the lookup.`),process.exit(1)}C=B,E.asBot=!0}else C=D(F);try{await y7(C,E)}catch(B){console.error(s1(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=X0();if(!F)console.error(`Error: slack doctor checks the bot token, but no xoxb- token was found.
163
+ Set SLACK_BOT_TOKEN=xoxb-... in ~/.config/slack-cli/.env (or your shell).`),process.exit(1);await m7(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 g7(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 k7(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 d7(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"}).option("mentions",{type:"boolean",default:!0,describe:"Convert @handle tokens in the new text to real <@USERID> mentions (on by default). Unresolved handles stay as plain text. Disable with --no-mentions for literal @text."}),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"];if(F.mentions!==!1)E.mentions=!0;await f7(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 h7(D(F),E)}).command("react <target> <emoji>","Add (or --remove) an emoji reaction \u2014 a lightweight ack that doesn't grow the thread",(F)=>F.positional("target",{type:"string",demandOption:!0,describe:"#chan:ts, @user:ts, or permalink"}).positional("emoji",{type:"string",demandOption:!0,describe:"Emoji shortcode without colons (e.g. eyes, white_check_mark, hourglass)"}).option("remove",{type:"boolean",default:!1,describe:"Remove the reaction instead of adding it"}).option("channel-id",{type:"string",describe:"Raw channel ID"}),async(F)=>{let E={target:F.target,emoji:F.emoji};if(F.remove)E.remove=!0;if(F["channel-id"])E.channelId=F["channel-id"];try{await v7(D(F),E)}catch(C){console.error(s1(C)),process.exit(1)}}).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 i7(D(F),E)}).command("download <ref> [dest]","Download a file attachment (by file ID or file permalink) to disk",(F)=>F.positional("ref",{type:"string",demandOption:!0,describe:"File ID (F\u2026) or Slack file permalink"}).positional("dest",{type:"string",describe:"Output path or directory (default: ./<filename>)"}),async(F)=>{await l7(D(F),u(F),F.ref,F.dest)}).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 R7(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 P7(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 G=await _D(C,E.channel,B),Z=await v1(C,G,$,B);console.log(`\u2713 Draft created (id: ${g(Z.draft).id??"?"})`)}).command("get <id>","Show a draft",(E)=>E.positional("id",{type:"string",demandOption:!0}),async(E)=>{await w7(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 G=await du(C,B),Z=r(G.drafts).map(g).find((Y)=>String(Y.id)===E.id);if(!Z)console.error(`Draft not found: ${E.id}`),process.exit(1);let z=NF(Z),Q=yD(z,$);if(E.code!==Q)fD(E.code,Q,["--- Current draft ----------------------------",...z.split(`
164
+ `).map((Y)=>` ${Y}`),"--- Replacing with ---------------------------",...$.split(`
165
+ `).map((Y)=>` ${Y}`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);let J=await p1(C,E.id,d0(Z),$,B);console.log(`\u2713 Draft updated (id: ${g(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 du(C,B),G=r($.drafts).map(g).find((Q)=>String(Q.id)===E.id);if(!G)console.error(`Draft not found: ${E.id}`),process.exit(1);let Z=NF(G),z=yD(E.id,Z);if(E.code!==z)fD(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}`,...Z.split(`
166
+ `).map((Q)=>` ${Q}`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);await c1(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 X1({...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 Q1({...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 _F({...E.token!==void 0?{token:E.token}:{},...E.name!==void 0?{name:E.name}:{}})}).command(["ls","status"],"Show auth status",()=>{},()=>{let E=I8();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)H7(oD(process.cwd(),".slack-cli"));f8(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)=>{b8(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 Z1({...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 J1({...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 K1(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 _F({...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()}t7().catch((D)=>{console.error(D instanceof Error?D.message:String(D)),process.exit(1)});