slack-term 1.24.0 → 1.25.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 Y3}from"node:module";var $3=Object.create;var{getPrototypeOf:G3,defineProperty:r0,getOwnPropertyNames:z3}=Object;var Z3=Object.prototype.hasOwnProperty;function J3(D){return this[D]}var X3,Q3,a0=(D,u,F)=>{var E=D!=null&&typeof D==="object";if(E){var C=u?X3??=new WeakMap:Q3??=new WeakMap,B=C.get(D);if(B)return B}F=D!=null?$3(G3(D)):{};let $=u||!D||!D.__esModule?r0(F,"default",{value:D,enumerable:!0}):F;for(let G of z3(D))if(!Z3.call($,G))r0($,G,{get:J3.bind(D,G),enumerable:!0});if(E)C.set(D,$);return $};var e0=(D,u)=>()=>(u||D((u={exports:{}}).exports,u),u.exports);var wD=Y3(import.meta.url);var H2=e0((q9,V2)=>{V2.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 k2=e0(($E,g2)=>{g2.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 O7}from"crypto";import{existsSync as D3,readFileSync as V7,mkdirSync as H7,writeFileSync as u3}from"fs";import{homedir as s1}from"os";import{join as oD}from"path";import{notStrictEqual as a3,strictEqual as e3}from"assert";var W3={right:H3,center:q3};class u2{constructor(D){var u;this.width=D.width,this.wrap=(u=D.wrap)!==null&&u!==void 0?u:!0,this.rows=[]}span(...D){let u=this.div(...D);u.span=!0}resetOutput(){this.rows=[]}div(...D){if(D.length===0)this.div("");if(this.wrap&&this.shouldApplyLayoutDSL(...D)&&typeof D[0]==="string")return this.applyLayoutDSL(D[0]);let u=D.map((F)=>{if(typeof F==="string")return this.colFromString(F);return F});return this.rows.push(u),u}shouldApplyLayoutDSL(...D){return D.length===1&&typeof D[0]==="string"&&/[\t\n]/.test(D[0])}applyLayoutDSL(D){let u=D.split(`
4
- `).map((E)=>E.split("\t")),F=0;return u.forEach((E)=>{if(E.length>1&&qD.stringWidth(E[0])>F)F=Math.min(Math.floor(this.width*0.5),qD.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=qD.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>qD.stringWidth(B))Z+=" ".repeat(z-qD.stringWidth(B));if(D[$].align&&D[$].align!=="left"&&this.wrap){let J=W3[D[$].align];if(Z=J(Z,z),qD.stringWidth(Z)<z)Z+=" ".repeat((G||0)-qD.stringWidth(Z)-1)}let Y=D[$].padding||[0,0,0,0];if(Y[3])C+=" ".repeat(Y[3]);if(C+=D2(D[$],Z,"| "),C+=Z,C+=D2(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=qD.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=qD.wrap(C.text,this.negatePadding(C),{hard:!0}).split(`
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||qD.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,O3(D[$]));return B})}}function D2(D,u,F){if(D.border){if(/[.']-+[.']/.test(u))return"";if(u.trim().length!==0)return F;return" "}return""}function O3(D){let u=D.padding||[],F=1+(u[3]||0)+(u[1]||0);if(D.border)return F+4;return F}function V3(){if(typeof process==="object"&&process.stdout&&process.stdout.columns)return process.stdout.columns;return 80}function H3(D,u){D=D.trim();let F=qD.stringWidth(D);if(F<u)return" ".repeat(u-F)+D;return D}function q3(D,u){D=D.trim();let F=qD.stringWidth(D);if(F>=u)return D;return" ".repeat(u-F>>1)+D}var qD;function F2(D,u){return qD=u,new u2({width:(D===null||D===void 0?void 0:D.width)||V3(),wrap:D===null||D===void 0?void 0:D.wrap})}function PF({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 K3=PF();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(K3,"")}var E2=161,C2=1114109,B2=[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],$2=12288,G2=65510,z2=[12288,12288,65281,65376,65504,65510];var Z2=4352,J2=262141,wF=[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 X2=19968,[U3,_3]=j3(wF);function j3(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(X2>=C&&X2<=B)return[C,B];if(B-C>F-u)u=C,F=B}return[u,F]}var Q2=(D)=>{if(D<E2||D>C2)return!1;return lu(B2,D)},Y2=(D)=>{if(D<$2||D>G2)return!1;return lu(z2,D)};var W2=(D)=>{if(D>=U3&&D<=_3)return!0;if(D<Z2||D>J2)return!1;return lu(wF,D)};function M3(D){if(!Number.isSafeInteger(D))throw TypeError(`Expected a code point, got \`${typeof D}\`.`)}function O2(D,{ambiguousAsWide:u=!1}={}){if(M3(D),Y2(D)||W2(D)||u&&Q2(D))return 2;return 1}var q2=a0(H2(),1),A3=new Intl.Segmenter,L3=/^\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 A3.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(L3.test($))continue;if(q2.default().test($)){C+=2;continue}C+=O2(G,B)}return C}var K2=(D=0)=>(u)=>`\x1B[${u+D}m`,U2=(D=0)=>(u)=>`\x1B[${38+D};5;${u}m`,_2=(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]}},j9=Object.keys(e.modifier),N3=Object.keys(e.color),T3=Object.keys(e.bgColor),M9=[...N3,...T3];function R3(){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=K2(),e.color.ansi256=U2(),e.color.ansi16m=_2(),e.bgColor.ansi=K2(10),e.bgColor.ansi256=U2(10),e.bgColor.ansi16m=_2(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 S3=R3(),j2=S3;var ou=new Set(["\x1B","›"]),P3=39,IF="\x07",L2="[",w3="]",N2="m",tu=`${w3}8;;`,M2=(D)=>`${ou.values().next().value}${L2}${D}${N2}`,A2=(D)=>`${ou.values().next().value}${tu}${D}${IF}`,x3=(D)=>D.split(" ").map((u)=>TD(u)),xF=(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===IF)C=!1,B=!1}else if(z===N2)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()},I3=(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("")},b3=(D,u,F={})=>{if(F.trim!==!1&&D.trim()==="")return"";let E="",C,B,$=x3(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("");xF(G,Q,u);continue}if(O+$[J]>u&&O>0&&$[J]>0){if(F.wordWrap===!1&&O<u){xF(G,Q,u);continue}G.push("")}if(O+$[J]>u&&F.wordWrap===!1){xF(G,Q,u);continue}G[G.length-1]+=Q}if(F.trim!==!1)G=G.map((J)=>I3(J));let z=G.join(`
8
- `),Z=[...z],Y=0;for(let[J,Q]of Z.entries()){if(E+=Q,ou.has(Q)){let{groups:V}=new RegExp(`(?:\\${L2}(?<code>\\d+)m|\\${tu}(?<uri>.*)${IF})`).exec(z.slice(Y))||{groups:{}};if(V.code!==void 0){let W=Number.parseFloat(V.code);C=W===P3?void 0:W}else if(V.uri!==void 0)B=V.uri.length===0?void 0:V.uri}let O=j2.codes.get(Number(C));if(Z[J+1]===`
9
- `){if(B)E+=A2("");if(C&&O)E+=M2(O)}else if(Q===`
10
- `){if(C&&O)E+=M2(C);if(B)E+=A2(B)}Y+=Q.length}return E};function bF(D,u,F){return String(D).normalize().replaceAll(`\r
3
+ import{createRequire as s3}from"node:module";var d3=Object.create;var{getPrototypeOf:k3,defineProperty:K2,getOwnPropertyNames:i3}=Object;var l3=Object.prototype.hasOwnProperty;function n3(D){return this[D]}var t3,o3,O2=(D,u,F)=>{var E=D!=null&&typeof D==="object";if(E){var B=u?t3??=new WeakMap:o3??=new WeakMap,C=B.get(D);if(C)return C}F=D!=null?d3(k3(D)):{};let $=u||!D||!D.__esModule?K2(F,"default",{value:D,enumerable:!0}):F;for(let z of i3(D))if(!l3.call($,z))K2($,z,{get:n3.bind(D,z),enumerable:!0});if(E)B.set(D,$);return $};var U2=(D,u)=>()=>(u||D((u={exports:{}}).exports,u),u.exports);var xD=s3(import.meta.url);var y2=U2((TE,v2)=>{v2.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 G8=U2((V4,J8)=>{J8.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(B,C){return C};var E=Error().stack;if(Error.prepareStackTrace=F,E!==null&&typeof E==="object")return E[u]?E[u].getFileName():void 0}});import{createHash as V9}from"crypto";import{existsSync as f3,readFileSync as H9,mkdirSync as q9,writeFileSync as h3}from"fs";import{homedir as x3}from"os";import{join as eD}from"path";import{notStrictEqual as f6,strictEqual as h6}from"assert";var r3={right:D6,center:u6};class M2{constructor(D){var u;this.width=D.width,this.wrap=(u=D.wrap)!==null&&u!==void 0?u:!0,this.rows=[]}span(...D){let u=this.div(...D);u.span=!0}resetOutput(){this.rows=[]}div(...D){if(D.length===0)this.div("");if(this.wrap&&this.shouldApplyLayoutDSL(...D)&&typeof D[0]==="string")return this.applyLayoutDSL(D[0]);let u=D.map((F)=>{if(typeof F==="string")return this.colFromString(F);return F});return this.rows.push(u),u}shouldApplyLayoutDSL(...D){return D.length===1&&typeof D[0]==="string"&&/[\t\n]/.test(D[0])}applyLayoutDSL(D){let u=D.split(`
4
+ `).map((E)=>E.split("\t")),F=0;return u.forEach((E)=>{if(E.length>1&&OD.stringWidth(E[0])>F)F=Math.min(Math.floor(this.width*0.5),OD.stringWidth(E[0]))}),u.forEach((E)=>{this.div(...E.map((B,C)=>{return{text:B.trim(),padding:this.measurePadding(B),width:C===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=OD.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 B="";F.forEach((C,$)=>{let{width:z}=D[$],Z=this.negatePadding(D[$]),J=C;if(Z>OD.stringWidth(C))J+=" ".repeat(Z-OD.stringWidth(C));if(D[$].align&&D[$].align!=="left"&&this.wrap){let G=r3[D[$].align];if(J=G(J,Z),OD.stringWidth(J)<Z)J+=" ".repeat((z||0)-OD.stringWidth(J)-1)}let X=D[$].padding||[0,0,0,0];if(X[3])B+=" ".repeat(X[3]);if(B+=j2(D[$],J,"| "),B+=J,B+=j2(D[$],J," |"),X[1])B+=" ".repeat(X[1]);if(E===0&&u.length>0)B=this.renderInline(B,u[u.length-1])}),u.push({text:B.replace(/ +$/,""),span:D.span})}),u}renderInline(D,u){let F=D.match(/^ */),E=F?F[0].length:0,B=u.text,C=OD.stringWidth(B.trimRight());if(!u.span)return D;if(!this.wrap)return u.hidden=!0,B+D;if(E<C)return D;return u.hidden=!0,B.trimRight()+" ".repeat(E-C)+D.trimLeft()}rasterize(D){let u=[],F=this.columnWidths(D),E;return D.forEach((B,C)=>{if(B.width=F[C],this.wrap)E=OD.wrap(B.text,this.negatePadding(B),{hard:!0}).split(`
6
+ `);else E=B.text.split(`
7
+ `);if(B.border)E.unshift("."+"-".repeat(this.negatePadding(B)+2)+"."),E.push("'"+"-".repeat(this.negatePadding(B)+2)+"'");if(B.padding)E.unshift(...Array(B.padding[0]||0).fill("")),E.push(...Array(B.padding[2]||0).fill(""));E.forEach(($,z)=>{if(!u[z])u.push([]);let Z=u[z];for(let J=0;J<C;J++)if(Z[J]===void 0)Z.push("");Z.push($)})}),u}negatePadding(D){let u=D.width||0;if(D.padding)u-=(D.padding[3]||0)+(D.padding[1]||0);if(D.border)u-=4;return u}columnWidths(D){if(!this.wrap)return D.map((C)=>{return C.width||OD.stringWidth(C.text)});let u=D.length,F=this.width,E=D.map((C)=>{if(C.width)return u--,F-=C.width,C.width;return}),B=u?Math.floor(F/u):0;return E.map((C,$)=>{if(C===void 0)return Math.max(B,a3(D[$]));return C})}}function j2(D,u,F){if(D.border){if(/[.']-+[.']/.test(u))return"";if(u.trim().length!==0)return F;return" "}return""}function a3(D){let u=D.padding||[],F=1+(u[3]||0)+(u[1]||0);if(D.border)return F+4;return F}function e3(){if(typeof process==="object"&&process.stdout&&process.stdout.columns)return process.stdout.columns;return 80}function D6(D,u){D=D.trim();let F=OD.stringWidth(D);if(F<u)return" ".repeat(u-F)+D;return D}function u6(D,u){D=D.trim();let F=OD.stringWidth(D);if(F>=u)return D;return" ".repeat(u-F>>1)+D}var OD;function _2(D,u){return OD=u,new M2({width:(D===null||D===void 0?void 0:D.width)||e3(),wrap:D===null||D===void 0?void 0:D.wrap})}function iF({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 F6=iF();function uu(D){if(typeof D!=="string")throw TypeError(`Expected a \`string\`, got \`${typeof D}\``);if(!D.includes("\x1B")&&!D.includes("›"))return D;return D.replace(F6,"")}var N2=161,A2=1114109,L2=[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],T2=12288,R2=65510,P2=[12288,12288,65281,65376,65504,65510];var S2=4352,w2=262141,lF=[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 EF=(D,u)=>{let F=0,E=Math.floor(D.length/2)-1;while(F<=E){let B=Math.floor((F+E)/2),C=B*2;if(u<D[C])E=B-1;else if(u>D[C+1])F=B+1;else return!0}return!1};var x2=19968,[E6,B6]=C6(lF);function C6(D){let u=D[0],F=D[1];for(let E=0;E<D.length;E+=2){let B=D[E],C=D[E+1];if(x2>=B&&x2<=C)return[B,C];if(C-B>F-u)u=B,F=C}return[u,F]}var I2=(D)=>{if(D<N2||D>A2)return!1;return EF(L2,D)},b2=(D)=>{if(D<T2||D>R2)return!1;return EF(P2,D)};var f2=(D)=>{if(D>=E6&&D<=B6)return!0;if(D<S2||D>w2)return!1;return EF(lF,D)};function $6(D){if(!Number.isSafeInteger(D))throw TypeError(`Expected a code point, got \`${typeof D}\`.`)}function h2(D,{ambiguousAsWide:u=!1}={}){if($6(D),b2(D)||f2(D)||u&&I2(D))return 2;return 1}var p2=O2(y2(),1),z6=new Intl.Segmenter,Z6=/^\p{Default_Ignorable_Code_Point}$/u;function RD(D,u={}){if(typeof D!=="string"||D.length===0)return 0;let{ambiguousIsNarrow:F=!0,countAnsiEscapeCodes:E=!1}=u;if(!E)D=uu(D);if(D.length===0)return 0;let B=0,C={ambiguousAsWide:!F};for(let{segment:$}of z6.segment(D)){let z=$.codePointAt(0);if(z<=31||z>=127&&z<=159)continue;if(z>=8203&&z<=8207||z===65279)continue;if(z>=768&&z<=879||z>=6832&&z<=6911||z>=7616&&z<=7679||z>=8400&&z<=8447||z>=65056&&z<=65071)continue;if(z>=55296&&z<=57343)continue;if(z>=65024&&z<=65039)continue;if(Z6.test($))continue;if(p2.default().test($)){B+=2;continue}B+=h2(z,C)}return B}var m2=(D=0)=>(u)=>`\x1B[${u+D}m`,g2=(D=0)=>(u)=>`\x1B[${38+D};5;${u}m`,c2=(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]}},wE=Object.keys(e.modifier),J6=Object.keys(e.color),G6=Object.keys(e.bgColor),xE=[...J6,...G6];function X6(){let D=new Map;for(let[u,F]of Object.entries(e)){for(let[E,B]of Object.entries(F))e[E]={open:`\x1B[${B[0]}m`,close:`\x1B[${B[1]}m`},F[E]=e[E],D.set(B[0],B[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=m2(),e.color.ansi256=g2(),e.color.ansi16m=c2(),e.bgColor.ansi=m2(10),e.bgColor.ansi256=g2(10),e.bgColor.ansi16m=c2(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((C)=>C+C).join("");let B=Number.parseInt(E,16);return[B>>16&255,B>>8&255,B&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,B;if(u>=232)F=((u-232)*10+8)/255,E=F,B=F;else{u-=16;let z=u%36;F=Math.floor(u/36)/5,E=Math.floor(z/6)/5,B=z%6/5}let C=Math.max(F,E,B)*2;if(C===0)return 30;let $=30+(Math.round(B)<<2|Math.round(E)<<1|Math.round(F));if(C===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 Q6=X6(),d2=Q6;var CF=new Set(["\x1B","›"]),Y6=39,tF="\x07",l2="[",W6="]",n2="m",BF=`${W6}8;;`,k2=(D)=>`${CF.values().next().value}${l2}${D}${n2}`,i2=(D)=>`${CF.values().next().value}${BF}${D}${tF}`,V6=(D)=>D.split(" ").map((u)=>RD(u)),nF=(D,u,F)=>{let E=[...u],B=!1,C=!1,$=RD(uu(D.at(-1)));for(let[z,Z]of E.entries()){let J=RD(Z);if($+J<=F)D[D.length-1]+=Z;else D.push(Z),$=0;if(CF.has(Z))B=!0,C=E.slice(z+1,z+1+BF.length).join("")===BF;if(B){if(C){if(Z===tF)B=!1,C=!1}else if(Z===n2)B=!1;continue}if($+=J,$===F&&z<E.length-1)D.push(""),$=0}if(!$&&D.at(-1).length>0&&D.length>1)D[D.length-2]+=D.pop()},H6=(D)=>{let u=D.split(" "),F=u.length;while(F>0){if(RD(u[F-1])>0)break;F--}if(F===u.length)return D;return u.slice(0,F).join(" ")+u.slice(F).join("")},q6=(D,u,F={})=>{if(F.trim!==!1&&D.trim()==="")return"";let E="",B,C,$=V6(D),z=[""];for(let[G,Y]of D.split(" ").entries()){if(F.trim!==!1)z[z.length-1]=z.at(-1).trimStart();let V=RD(z.at(-1));if(G!==0){if(V>=u&&(F.wordWrap===!1||F.trim===!1))z.push(""),V=0;if(V>0||F.trim===!1)z[z.length-1]+=" ",V++}if(F.hard&&$[G]>u){let H=u-V,W=1+Math.floor(($[G]-H-1)/u);if(Math.floor(($[G]-1)/u)<W)z.push("");nF(z,Y,u);continue}if(V+$[G]>u&&V>0&&$[G]>0){if(F.wordWrap===!1&&V<u){nF(z,Y,u);continue}z.push("")}if(V+$[G]>u&&F.wordWrap===!1){nF(z,Y,u);continue}z[z.length-1]+=Y}if(F.trim!==!1)z=z.map((G)=>H6(G));let Z=z.join(`
8
+ `),J=[...Z],X=0;for(let[G,Y]of J.entries()){if(E+=Y,CF.has(Y)){let{groups:H}=new RegExp(`(?:\\${l2}(?<code>\\d+)m|\\${BF}(?<uri>.*)${tF})`).exec(Z.slice(X))||{groups:{}};if(H.code!==void 0){let W=Number.parseFloat(H.code);B=W===Y6?void 0:W}else if(H.uri!==void 0)C=H.uri.length===0?void 0:H.uri}let V=d2.codes.get(Number(B));if(J[G+1]===`
9
+ `){if(C)E+=i2("");if(B&&V)E+=k2(V)}else if(Y===`
10
+ `){if(B&&V)E+=k2(B);if(C)E+=i2(C)}X+=Y.length}return E};function oF(D,u,F){return String(D).normalize().replaceAll(`\r
11
11
  `,`
12
12
  `).split(`
13
- `).map((E)=>b3(E,u,F)).join(`
14
- `)}function fF(D){return F2(D,{stringWidth:TD,stripAnsi:rD,wrap:bF})}import{dirname as T2,resolve as R2}from"path";import{readdirSync as f3,statSync as h3}from"fs";function hF(D,u){let F=R2(".",D),E;if(!h3(F).isDirectory())F=T2(F);while(!0){if(E=u(F,f3(F)),E)return R2(F,E);if(F=T2(E=F),E===F)break}}import{inspect as D6}from"util";import{fileURLToPath as i2}from"url";import{format as p3}from"util";import{normalize as m3,resolve as c3}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 S2(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 yF{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=S2(D),C=typeof D==="string",B=v3(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:[]},K=/^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/,A=new RegExp("^--"+$["negation-prefix"]+"(.+)");if([].concat(F.array||[]).filter(Boolean).forEach(function(H){let U=typeof H==="object"?H.key:H,N=Object.keys(H).map(function(j){return{boolean:"bools",string:"strings",number:"numbers"}[j]}).filter(Boolean).pop();if(N)W[N][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})}Su(F.key,B,F.default,W.arrays),Object.keys(G).forEach(function(H){(W.aliases[H]||[]).forEach(function(U){G[U]=G[H]})});let _=null;SF();let L=[],M=Object.assign(Object.create(null),{_:[]}),x={};for(let H=0;H<E.length;H++){let U=E[H],N=U.replace(/^-{3,}/,"---"),j,q,w,R,h,JD;if(U!=="--"&&/^-/.test(U)&&t(U))k(U);else if(N.match(/^---+(=|$)/)){k(U);continue}else if(U.match(/^--.+=/)||!$["short-option-groups"]&&U.match(/^-.+=/)){if(R=U.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=s(H,R[1],E,R[2]);else n(R[1],R[2],!0)}else if(U.match(A)&&$["boolean-negation"]){if(R=U.match(A),R!==null&&Array.isArray(R)&&R.length>=2)q=R[1],n(q,v(q,W.arrays)?[!1]:!1)}else if(U.match(/^--.+/)||!$["short-option-groups"]&&U.match(/^-[^-]+/)){if(R=U.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=s(H,q,E);else if(h=E[H+1],h!==void 0&&(!h.match(/^-/)||h.match(K))&&!v(q,W.bools)&&!v(q,W.counts))n(q,h),H++;else if(/^(true|false)$/.test(h))n(q,h),H++;else n(q,d(q))}else if(U.match(/^-.\..+=/)){if(R=U.match(/^-([^=]+)=([\s\S]*)$/),R!==null&&Array.isArray(R)&&R.length>=3)n(R[1],R[2])}else if(U.match(/^-.\..+/)&&!U.match(K)){if(h=E[H+1],R=U.match(/^-(.\..+)/),R!==null&&Array.isArray(R)&&R.length>=2)if(q=R[1],h!==void 0&&!h.match(/^-/)&&!v(q,W.bools)&&!v(q,W.counts))n(q,h),H++;else n(q,d(q))}else if(U.match(/^-[^-]+/)&&!U.match(K)){w=U.slice(1,-1).split(""),j=!1;for(let YD=0;YD<w.length;YD++){if(h=U.slice(YD+2),w[YD+1]&&w[YD+1]==="="){if(JD=U.slice(YD+3),q=w[YD],v(q,W.arrays))H=jD(H,q,E,JD);else if(v(q,W.nargs)!==!1)H=s(H,q,E,JD);else n(q,JD);j=!0;break}if(h==="-"){n(w[YD],h);continue}if(/[A-Za-z]/.test(w[YD])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(h)&&v(h,W.bools)===!1){n(w[YD],h),j=!0;break}if(w[YD+1]&&w[YD+1].match(/\W/)){n(w[YD],h),j=!0;break}else n(w[YD],d(w[YD]))}if(q=U.slice(-1)[0],!j&&q!=="-")if(v(q,W.arrays))H=jD(H,q,E);else if(v(q,W.nargs)!==!1)H=s(H,q,E);else if(h=E[H+1],h!==void 0&&(!/^(-|--)[^-]/.test(h)||h.match(K))&&!v(q,W.bools)&&!v(q,W.counts))n(q,h),H++;else if(/^(true|false)$/.test(h))n(q,h),H++;else n(q,d(q))}else if(U.match(/^-[0-9]$/)&&U.match(K)&&v(U.slice(1),W.bools))q=U.slice(1),n(q,d(q));else if(U==="--"){L=E.slice(H+1);break}else if($["halt-at-non-option"]){L=E.slice(H);break}else k(U)}if(BD(M,!0),BD(M,!1),b(M),l(),mD(M,W.aliases,G,!0),i(M),$["set-placeholder-key"])$D(M);if(Object.keys(W.counts).forEach(function(H){if(!r(M,H.split(".")))n(H,0)}),Y&&L.length)M[J]=[];if(L.forEach(function(H){M[J].push(H)}),$["camel-case-expansion"]&&$["strip-dashed"])Object.keys(M).filter((H)=>H!=="--"&&H.includes("-")).forEach((H)=>{delete M[H]});if($["strip-aliased"])[].concat(...Object.keys(B).map((H)=>B[H])).forEach((H)=>{if($["camel-case-expansion"]&&H.includes("-"))delete M[H.split(".").map((U)=>aD(U)).join(".")];delete M[H]});function k(H){let U=T("_",H);if(typeof U==="string"||typeof U==="number")M._.push(U)}function s(H,U,N,j){let q,w=v(U,W.nargs);if(w=typeof w!=="number"||isNaN(w)?1:w,w===0){if(!zD(j))_=Error(V("Argument unexpected for: %s",U));return n(U,d(U)),H}let R=zD(j)?0:1;if($["nargs-eats-options"]){if(N.length-(H+1)+R<w)_=Error(V("Not enough arguments following: %s",U));R=w}else{for(q=H+1;q<N.length;q++)if(!N[q].match(/^-[^0-9]/)||N[q].match(K)||t(N[q]))R++;else break;if(R<w)_=Error(V("Not enough arguments following: %s",U))}let h=Math.min(R,w);if(!zD(j)&&h>0)n(U,j),h--;for(q=H+1;q<h+H+1;q++)n(U,N[q]);return H+h}function jD(H,U,N,j){let q=[],w=j||N[H+1],R=v(U,W.nargs);if(v(U,W.bools)&&!/^(true|false)$/.test(w))q.push(!0);else if(zD(w)||zD(j)&&/^-/.test(w)&&!K.test(w)&&!t(w)){if(G[U]!==void 0){let h=G[U];q=Array.isArray(h)?h:[h]}}else{if(!zD(j))q.push(I(U,j,!0));for(let h=H+1;h<N.length;h++){if(!$["greedy-arrays"]&&q.length>0||R&&typeof R==="number"&&q.length>=R)break;if(w=N[h],/^-/.test(w)&&!K.test(w)&&!t(w))break;H=h,q.push(I(U,w,C))}}if(typeof R==="number"&&(R&&q.length<R||isNaN(R)&&q.length===0))_=Error(V("Not enough arguments following: %s",U));return n(U,q),H}function n(H,U,N=C){if(/-/.test(H)&&$["camel-case-expansion"]){let w=H.split(".").map(function(R){return aD(R)}).join(".");sD(H,w)}let j=I(H,U,N),q=H.split(".");if(hD(M,q,j),W.aliases[H])W.aliases[H].forEach(function(w){let R=w.split(".");hD(M,R,j)});if(q.length>1&&$["dot-notation"])(W.aliases[q[0]]||[]).forEach(function(w){let R=w.split("."),h=[].concat(q);if(h.shift(),R=R.concat(h),!(W.aliases[H]||[]).includes(R.join(".")))hD(M,R,j)});if(v(H,W.normalize)&&!v(H,W.arrays))[H].concat(W.aliases[H]||[]).forEach(function(R){Object.defineProperty(x,R,{enumerable:!0,get(){return U},set(h){U=typeof h==="string"?vD.normalize(h):h}})})}function sD(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))sD(U,H)}function I(H,U,N){if(N)U=y3(U);if(v(H,W.bools)||v(H,W.counts)){if(typeof U==="string")U=U==="true"}let j=Array.isArray(U)?U.map(function(q){return T(H,q)}):T(H,U);if(v(H,W.counts)&&(zD(j)||typeof j==="boolean"))j=vF();if(v(H,W.normalize)&&v(H,W.arrays))if(Array.isArray(U))j=U.map((q)=>{return vD.normalize(q)});else j=vD.normalize(U);return j}function T(H,U){if(!$["parse-positional-numbers"]&&H==="_")return U;if(!v(H,W.strings)&&!v(H,W.bools)&&!Array.isArray(U)){if(ru(U)&&$["parse-numbers"]&&Number.isSafeInteger(Math.floor(parseFloat(`${U}`)))||!zD(U)&&v(H,W.numbers))U=Number(U)}return U}function b(H){let U=Object.create(null);mD(U,W.aliases,G),Object.keys(W.configs).forEach(function(N){let j=H[N]||U[N];if(j)try{let q=null,w=vD.resolve(vD.cwd(),j),R=W.configs[N];if(typeof R==="function"){try{q=R(w)}catch(h){q=h}if(q instanceof Error){_=q;return}}else q=vD.require(w);c(q)}catch(q){if(q.name==="PermissionDenied")_=q;else if(H[N])_=Error(V("Invalid JSON config file: %s",j))}})}function c(H,U){Object.keys(H).forEach(function(N){let j=H[N],q=U?U+"."+N:N;if(typeof j==="object"&&j!==null&&!Array.isArray(j)&&$["dot-notation"])c(j,q);else if(!r(M,q.split("."))||v(q,W.arrays)&&$["combine-arrays"])n(q,j)})}function l(){if(typeof z<"u")z.forEach(function(H){c(H)})}function BD(H,U){if(typeof Z>"u")return;let N=typeof Z==="string"?Z:"",j=vD.env();Object.keys(j).forEach(function(q){if(N===""||q.lastIndexOf(N,0)===0){let w=q.split("__").map(function(R,h){if(h===0)R=R.substring(N.length);return aD(R)});if((U&&W.configs[w.join(".")]||!U)&&!r(H,w))n(w.join("."),j[q])}})}function i(H){let U,N=new Set;Object.keys(H).forEach(function(j){if(!N.has(j)){if(U=v(j,W.coercions),typeof U==="function")try{let q=T(j,U(H[j]));[].concat(W.aliases[j]||[],j).forEach((w)=>{N.add(w),H[w]=q})}catch(q){_=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,N,j=!1){Object.keys(N).forEach(function(q){if(!r(H,q.split("."))){if(hD(H,q.split("."),N[q]),j)O[q]=!0;(U[q]||[]).forEach(function(w){if(r(H,w.split(".")))return;hD(H,w.split("."),N[q])})}})}function r(H,U){let N=H;if(!$["dot-notation"])U=[U.join(".")];U.slice(0,-1).forEach(function(q){N=N[q]||{}});let j=U[U.length-1];if(typeof N!=="object")return!1;else return j in N}function hD(H,U,N){let j=H;if(!$["dot-notation"])U=[U.join(".")];U.slice(0,-1).forEach(function(JD){if(JD=P2(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=P2(U[U.length-1]),w=v(U.join("."),W.arrays),R=Array.isArray(N),h=$["duplicate-arguments-array"];if(!h&&v(q,W.nargs)){if(h=!0,!zD(j[q])&&W.nargs[q]===1||Array.isArray(j[q])&&j[q].length===W.nargs[q])j[q]=void 0}if(N===vF())j[q]=vF(j[q]);else if(Array.isArray(j[q]))if(h&&w&&R)j[q]=$["flatten-duplicate-arrays"]?j[q].concat(N):(Array.isArray(j[q][0])?j[q]:[j[q]]).concat([N]);else if(!h&&Boolean(w)===Boolean(R))j[q]=N;else j[q]=j[q].concat([N]);else if(j[q]===void 0&&w)j[q]=R?N:[N];else if(h&&!(j[q]===void 0||v(q,W.counts)||v(q,W.bools)))j[q]=[j[q],N];else j[q]=N}function Su(...H){H.forEach(function(U){Object.keys(U||{}).forEach(function(N){if(W.aliases[N])return;W.aliases[N]=[].concat(B[N]||[]),W.aliases[N].concat(N).forEach(function(j){if(/-/.test(j)&&$["camel-case-expansion"]){let q=aD(j);if(q!==N&&W.aliases[N].indexOf(q)===-1)W.aliases[N].push(q),Q[q]=!0}}),W.aliases[N].concat(N).forEach(function(j){if(j.length>1&&/[A-Z]/.test(j)&&$["camel-case-expansion"]){let q=su(j,"-");if(q!==N&&W.aliases[N].indexOf(q)===-1)W.aliases[N].push(q),Q[q]=!0}}),W.aliases[N].forEach(function(j){W.aliases[j]=[N].concat(W.aliases[N].filter(function(q){return j!==q}))})})})}function v(H,U){let N=[].concat(W.aliases[H]||[],H),j=Object.keys(U),q=N.find((w)=>j.includes(w));return q?U[q]:!1}function qu(H){let U=Object.keys(W);return[].concat(U.map((j)=>W[j])).some(function(j){return Array.isArray(j)?j.includes(H):j[H]})}function s0(H,...U){return[].concat(...U).some(function(j){let q=H.match(j);return q&&qu(q[1])})}function y(H){if(H.match(K)||!H.match(/^-[^-]+/))return!1;let U=!0,N,j=H.slice(1).split("");for(let q=0;q<j.length;q++){if(N=H.slice(q+2),!qu(j[q])){U=!1;break}if(j[q+1]&&j[q+1]==="="||N==="-"||/[A-Za-z]/.test(j[q])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(N)||j[q+1]&&j[q+1].match(/\W/))break}return U}function t(H){return $["unknown-options-as-args"]&&GD(H)}function GD(H){if(H=H.replace(/^-{3,}/,"--"),H.match(K))return!1;if(y(H))return!1;return!s0(H,/^-+([^=]+?)=[\s\S]*$/,A,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}function d(H){if(!v(H,W.bools)&&!v(H,W.counts)&&`${H}`in G)return G[H];else return QD(FD(H))}function QD(H){return{[MD.BOOLEAN]:!0,[MD.STRING]:"",[MD.NUMBER]:void 0,[MD.ARRAY]:[]}[H]}function FD(H){let U=MD.BOOLEAN;if(v(H,W.strings))U=MD.STRING;else if(v(H,W.numbers))U=MD.NUMBER;else if(v(H,W.bools))U=MD.BOOLEAN;else if(v(H,W.arrays))U=MD.ARRAY;return U}function zD(H){return H===void 0}function SF(){Object.keys(W.counts).find((H)=>{if(v(H,W.arrays))return _=Error(V("Invalid configuration: %s, opts.count excludes opts.array.",H)),!0;else if(v(H,W.nargs))return _=Error(V("Invalid configuration: %s, opts.count excludes opts.narg.",H)),!0;return!1})}return{aliases:Object.assign({},W.aliases),argv:Object.assign(x,M),configuration:$,defaulted:Object.assign({},O),error:_,newAliases:Object.assign({},Q)}}}function v3(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 vF(D){return D!==void 0?D+1:1}function P2(D){if(D==="__proto__")return"___proto___";return D}function y3(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 g3}from"fs";import{createRequire as w2}from"node:module";var pF,mF,cF,x2=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):20,I2=(mF=(pF=process===null||process===void 0?void 0:process.versions)===null||pF===void 0?void 0:pF.node)!==null&&mF!==void 0?mF:(cF=process===null||process===void 0?void 0:process.version)===null||cF===void 0?void 0:cF.slice(1);if(I2){if(Number(I2.match(/^([^.]+)/)[1])<x2)throw Error(`yargs parser supports a minimum Node.js version of ${x2}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`)}var k3=process?process.env:{},b2=w2?w2(import.meta.url):void 0,f2=new yF({cwd:process.cwd,env:()=>{return k3},format:p3,normalize:m3,resolve:c3,require:(D)=>{if(typeof b2<"u")return b2(D);else if(D.match(/\.json$/))return JSON.parse(g3(D,"utf8"));else throw Error("only .json config files are supported in ESM")}}),Pu=function(u,F){return f2.parse(u.slice(),F).argv};Pu.detailed=function(D,u){return f2.parse(D.slice(),u)};Pu.camelCase=aD;Pu.decamelize=su;Pu.looksLikeNumber=ru;var gF=Pu;import{basename as u6,dirname as F6,extname as E6,relative as C6,resolve as d2,join as B6}from"path";function h2(){if(d3())return 0;return 1}function d3(){return i3()&&!process.defaultApp}function i3(){return!!process.versions.electron}function kF(D){return D.slice(h2()+1)}function v2(){return process.argv[h2()]}import{readFileSync as n3,statSync as l3,writeFile as t3}from"fs";import{format as o3}from"util";import{resolve as s3}from"path";var y2={fs:{readFileSync:n3,writeFile:t3},format:o3,resolve:s3,exists:(D)=>{try{return l3(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 m2(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 r3=(D)=>{return m2(D,y2)},c2=r3;var n2=a0(k2(),1);import{createRequire as $6}from"node:module";import{readFileSync as G6,readdirSync as z6}from"node:fs";var dF=i2(import.meta.url),Z6=dF.substring(0,dF.lastIndexOf("node_modules")),J6=$6(import.meta.url),iF={assert:{notStrictEqual:a3,strictEqual:e3},cliui:fF,findUp:hF,getEnv:(D)=>{return process.env[D]},inspect:D6,getProcessArgvBin:v2,mainFilename:Z6||process.cwd(),Parser:gF,path:{basename:u6,dirname:F6,extname:E6,relative:C6,resolve:d2,join:B6},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:G6,readdirSync:z6,require:J6,getCallerFile:()=>{let D=n2.default(3);return D.match(/^file:\/\//)?i2(D):D},stringWidth:TD,y18n:c2({directory:d2(dF,"../../../locales"),updateFiles:!1})};function WD(D,u,F,E){F.assert.notStrictEqual(D,u,E)}function nF(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 ED extends Error{constructor(D){super(D||"yargs error");if(this.name="YError",Error.captureStackTrace)Error.captureStackTrace(this,ED)}}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 X6=["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 ED(`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 ED(`Too many arguments provided. Expected max ${Y} but received ${Z}.`);B.demanded.forEach((J)=>{let Q=z.shift(),O=l2(Q);if(J.cmd.filter((W)=>W===O||W==="*").length===0)t2(O,J.cmd,C);C+=1}),B.optional.forEach((J)=>{if(z.length===0)return;let Q=z.shift(),O=l2(Q);if(J.cmd.filter((W)=>W===O||W==="*").length===0)t2(O,J.cmd,C);C+=1})}catch(C){console.warn(C.stack)}}function l2(D){if(Array.isArray(D))return"array";else if(D===null)return"null";return typeof D}function t2(D,u,F){throw new ED(`Invalid ${X6[F]||"manyith"} argument. Expected ${u.join(" or ")} but received ${D}.`)}class lF{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 o2(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=Q6(D)?D():D;return a(E)?E.then((C)=>u(C)):u(E)}catch(E){return F(E)}}function Q6(D){return typeof D==="function"}var Uu=/(^\*)|(^\$0)/;class r2{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=o2(C);if(E=E||(()=>{}),Array.isArray(D))if(Y6(D))[D,...$]=D;else for(let z of D)this.addHandler(z);else if(O6(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(s2(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 a(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(au(z)){F.getInternalMethods().getUsageInstance().freeze();let Y=z(F.getInternalMethods().reset(E),G);if(a(Y))return Y.then((J)=>{return Z=e2(J)?J:F,this.parseAndUpdateUsage(D,u,Z,C,B,$)})}else if(W6(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 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 Y=u.handler(Z);return a(Y)?Y.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(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=eD(F,$,z,!0);return a(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(au(u))return u(D,!0);else if(!s2(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 a2(D,u,F,E){return new r2(D,u,F,E)}function s2(D){return typeof D==="object"&&!!D.builder&&typeof D.handler==="function"}function Y6(D){return D.every((u)=>typeof u==="string")}function au(D){return typeof D==="function"}function W6(D){return typeof D==="object"}function O6(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 V6(D){return typeof D==="boolean"}function u8(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,b){let[c,l]=typeof T==="string"?[!0,T]:[T,b];if(D.getInternalMethods().isGlobalContext())$=l;return B=l,G=c,E};let z=!1;E.fail=function(T,b){let c=D.getInternalMethods().getLoggerInstance();if(C.length)for(let l=C.length-1;l>=0;--l){let BD=C[l];if(V6(BD)){if(b)throw b;else if(T)throw Error(T)}else BD(T,b,E)}else{if(D.getExitProcess())kD(!0);if(!z){if(z=!0,G)D.showHelp("error"),c.error();if(T||b)c.error(T||b);let l=B||$;if(l){if(T||b)c.error("");c.error(l)}}if(b=b||new ED(T),D.getExitProcess())return D.exit(1);else if(D.getInternalMethods().hasParseCallback())return D.exit(1,b);else throw b}};let Z=[],Y=!1;E.usage=(I,T)=>{if(I===null)return Y=!0,Z=[],E;return Y=!1,Z.push([I,T||""]),E},E.getUsage=()=>{return Z},E.getUsageDisabled=()=>{return Y},E.getPositionalGroupName=()=>{return F("Positionals:")};let J=[];E.example=(I,T)=>{J.push([I,T||""])};let Q=[];E.command=function(T,b,c,l,BD=!1){if(c)Q=Q.map((i)=>{return i[2]=!1,i});Q.push([T,b||"",c,l,BD])},E.getCommands=()=>Q;let O={};E.describe=function(T,b){if(Array.isArray(T))T.forEach((c)=>{E.describe(c,b)});else if(typeof T==="object")Object.keys(T).forEach((c)=>{E.describe(c,T[c])});else O[T]=b},E.getDescriptions=()=>O;let V=[];E.epilog=(I)=>{V.push(I)};let W=!1,K;E.wrap=(I)=>{W=!0,K=I},E.getWrap=()=>{if(u.getEnv("YARGS_DISABLE_WRAP"))return null;if(!W)K=jD(),W=!0;return K};let A="__yargsString__:";E.deferY18nLookup=(I)=>A+I,E.help=function(){if(M)return M;L();let T=D.customScriptName?D.$0:u.path.basename(D.$0),b=D.getDemandedOptions(),c=D.getDemandedCommands(),l=D.getDeprecatedOptions(),BD=D.getGroups(),i=D.getOptions(),$D=[];$D=$D.concat(Object.keys(O)),$D=$D.concat(Object.keys(b)),$D=$D.concat(Object.keys(c)),$D=$D.concat(Object.keys(i.default)),$D=$D.filter(k),$D=Object.keys($D.reduce((y,t)=>{if(t!=="_")y[t]=!0;return y},{}));let mD=E.getWrap(),r=u.cliui({width:mD,wrap:!!mD});if(!Y){if(Z.length)Z.forEach((y)=>{if(r.div({text:`${y[0].replace(/\$0/g,T)}`}),y[1])r.div({text:`${y[1]}`,padding:[1,0,0,0]})}),r.div();else if(Q.length){let y=null;if(c._)y=`${T} <${F("command")}>
15
- `;else y=`${T} [${F("command")}]
16
- `;r.div(`${y}`)}}if(Q.length>1||Q.length===1&&!Q[0][2]){r.div(F("Commands:"));let y=D.getInternalMethods().getContext(),t=y.commands.length?`${y.commands.join(" ")} `:"";if(D.getInternalMethods().getParserConfiguration()["sort-commands"]===!0)Q=Q.sort((d,QD)=>d[0].localeCompare(QD[0]));let GD=T?`${T} `:"";Q.forEach((d)=>{let QD=`${GD}${t}${d[0].replace(/^\$0 ?/,"")}`;r.span({text:QD,padding:[0,2,0,2],width:_(Q,mD,`${T}${t}`)+4},{text:d[1]});let FD=[];if(d[2])FD.push(`[${F("default")}]`);if(d[3]&&d[3].length)FD.push(`[${F("aliases:")} ${d[3].join(", ")}]`);if(d[4])if(typeof d[4]==="string")FD.push(`[${F("deprecated: %s",d[4])}]`);else FD.push(`[${F("deprecated")}]`);if(FD.length)r.div({text:FD.join(" "),padding:[0,0,0,2],align:"right"});else r.div()}),r.div()}let hD=(Object.keys(i.alias)||[]).concat(Object.keys(D.parsed.newAliases)||[]);$D=$D.filter((y)=>!D.parsed.newAliases[y]&&hD.every((t)=>(i.alias[t]||[]).indexOf(y)===-1));let Su=F("Options:");if(!BD[Su])BD[Su]=[];x($D,i.alias,BD,Su);let v=(y)=>/^--/.test(eu(y)),qu=Object.keys(BD).filter((y)=>BD[y].length>0).map((y)=>{let t=BD[y].filter(k).map((GD)=>{if(hD.includes(GD))return GD;for(let d=0,QD;(QD=hD[d])!==void 0;d++)if((i.alias[QD]||[]).includes(GD))return QD;return GD});return{groupName:y,normalizedKeys:t}}).filter(({normalizedKeys:y})=>y.length>0).map(({groupName:y,normalizedKeys:t})=>{let GD=t.reduce((d,QD)=>{return d[QD]=[QD].concat(i.alias[QD]||[]).map((FD)=>{if(y===E.getPositionalGroupName())return FD;else return(/^[0-9]$/.test(FD)?i.boolean.includes(QD)?"-":"--":FD.length>1?"--":"-")+FD}).sort((FD,zD)=>v(FD)===v(zD)?0:v(FD)?1:-1).join(", "),d},{});return{groupName:y,normalizedKeys:t,switches:GD}});if(qu.filter(({groupName:y})=>y!==E.getPositionalGroupName()).some(({normalizedKeys:y,switches:t})=>!y.every((GD)=>v(t[GD]))))qu.filter(({groupName:y})=>y!==E.getPositionalGroupName()).forEach(({normalizedKeys:y,switches:t})=>{y.forEach((GD)=>{if(v(t[GD]))t[GD]=H6(t[GD],4)})});if(qu.forEach(({groupName:y,normalizedKeys:t,switches:GD})=>{r.div(y),t.forEach((d)=>{let QD=GD[d],FD=O[d]||"",zD=null;if(FD.includes(A))FD=F(FD.substring(A.length));if(i.boolean.includes(d))zD=`[${F("boolean")}]`;if(i.count.includes(d))zD=`[${F("count")}]`;if(i.string.includes(d))zD=`[${F("string")}]`;if(i.normalize.includes(d))zD=`[${F("string")}]`;if(i.array.includes(d))zD=`[${F("array")}]`;if(i.number.includes(d))zD=`[${F("number")}]`;let SF=(N)=>typeof N==="string"?`[${F("deprecated: %s",N)}]`:`[${F("deprecated")}]`,H=[d in l?SF(l[d]):null,zD,d in b?`[${F("required")}]`:null,i.choices&&i.choices[d]?`[${F("choices:")} ${E.stringifiedValues(i.choices[d])}]`:null,s(i.default[d],i.defaultDescription[d])].filter(Boolean).join(" ");r.span({text:eu(QD),padding:[0,2,0,2+D8(QD)],width:_(GD,mD)+4},FD);let U=D.getInternalMethods().getUsageConfiguration()["hide-types"]===!0;if(H&&!U)r.div({text:H,padding:[0,0,0,2],align:"right"});else r.div()}),r.div()}),J.length)r.div(F("Examples:")),J.forEach((y)=>{y[0]=y[0].replace(/\$0/g,T)}),J.forEach((y)=>{if(y[1]==="")r.div({text:y[0],padding:[0,2,0,2]});else r.div({text:y[0],padding:[0,2,0,2],width:_(J,mD)+4},{text:y[1]})}),r.div();if(V.length>0){let y=V.map((t)=>t.replace(/\$0/g,T)).join(`
17
- `);r.div(`${y}
18
- `)}return r.toString().replace(/\s*$/,"")};function _(I,T,b){let c=0;if(!Array.isArray(I))I=Object.values(I).map((l)=>[l]);if(I.forEach((l)=>{c=Math.max(u.stringWidth(b?`${b} ${eu(l[0])}`:eu(l[0]))+D8(l[0]),c)}),T)c=Math.min(c,parseInt((T*0.5).toString(),10));return c}function L(){let I=D.getDemandedOptions(),T=D.getOptions();(Object.keys(T.alias)||[]).forEach((b)=>{T.alias[b].forEach((c)=>{if(O[c])E.describe(b,O[c]);if(c in I)D.demandOption(b,I[c]);if(T.boolean.includes(c))D.boolean(b);if(T.count.includes(c))D.count(b);if(T.string.includes(c))D.string(b);if(T.normalize.includes(c))D.normalize(b);if(T.array.includes(c))D.array(b);if(T.number.includes(c))D.number(b)})})}let M;E.cacheHelpMessage=function(){M=this.help()},E.clearCachedHelpMessage=function(){M=void 0},E.hasCachedHelpMessage=function(){return!!M};function x(I,T,b,c){let l=[],BD=null;return Object.keys(b).forEach((i)=>{l=l.concat(b[i])}),I.forEach((i)=>{if(BD=[i].concat(T[i]),!BD.some(($D)=>l.indexOf($D)!==-1))b[c].push(i)}),l}function k(I){return D.getOptions().hiddenOptions.indexOf(I)<0||D.parsed.argv[D.getOptions().showHiddenOpt]}E.showHelp=(I)=>{let T=D.getInternalMethods().getLoggerInstance();if(!I)I="error";(typeof I==="function"?I:T[I])(E.help())},E.functionDescription=(I)=>{return["(",I.name?u.Parser.decamelize(I.name,"-"):F("generated-value"),")"].join("")},E.stringifiedValues=function(T,b){let c="",l=b||", ",BD=[].concat(T);if(!T||!BD.length)return c;return BD.forEach((i)=>{if(c.length)c+=l;c+=JSON.stringify(i)}),c};function s(I,T){let b=`[${F("default:")} `;if(I===void 0&&!T)return null;if(T)b+=T;else switch(typeof I){case"string":b+=`"${I}"`;break;case"object":b+=JSON.stringify(I);break;default:b+=I}return`${b}]`}function jD(){if(u.process.stdColumns)return Math.min(80,u.process.stdColumns);else return 80}let n=null;E.version=(I)=>{n=I},E.showVersion=(I)=>{let T=D.getInternalMethods().getLoggerInstance();if(!I)I="error";(typeof I==="function"?I:T[I])(n)},E.reset=function(T){return B=null,z=!1,Z=[],Y=!1,V=[],J=[],Q=[],O=gD(O,(b)=>!T[b]),E};let sD=[];return E.freeze=function(){sD.push({failMessage:B,failureOutput:z,usages:Z,usageDisabled:Y,epilogs:V,examples:J,commands:Q,descriptions:O})},E.unfreeze=function(T=!1){let b=sD.pop();if(!b)return;if(T)O={...b.descriptions,...O},Q=[...b.commands,...Q],Z=[...b.usages,...Z],J=[...b.examples,...J],V=[...b.epilogs,...V];else({failMessage:B,failureOutput:z,usages:Z,usageDisabled:Y,epilogs:V,examples:J,commands:Q,descriptions:O}=b)},E}function tF(D){return typeof D==="object"}function H6(D,u){return tF(D)?{text:D.text,indentation:D.indentation+u}:{text:D,indentation:u}}function D8(D){return tF(D)?D.indentation:0}function eu(D){return tF(D)?D.text:D}var F8=`###-begin-{{app_name}}-completions-###
13
+ `).map((E)=>q6(E,u,F)).join(`
14
+ `)}function sF(D){return _2(D,{stringWidth:RD,stripAnsi:uu,wrap:oF})}import{dirname as t2,resolve as o2}from"path";import{readdirSync as K6,statSync as O6}from"fs";function rF(D,u){let F=o2(".",D),E;if(!O6(F).isDirectory())F=t2(F);while(!0){if(E=u(F,K6(F)),E)return o2(F,E);if(F=t2(E=F),E===F)break}}import{inspect as v6}from"util";import{fileURLToPath as Q8}from"url";import{format as M6}from"util";import{normalize as _6,resolve as N6}from"path";function Fu(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,B=D.match(/^-+/);for(let C=B?B[0].length:0;C<D.length;C++){let $=D.charAt(C);if(E)E=!1,$=$.toUpperCase();if(C!==0&&($==="-"||$==="_"))E=!0;else if($!=="-"&&$!=="_")F+=$}return F}}function $F(D,u){let F=D.toLowerCase();u=u||"-";let E="";for(let B=0;B<D.length;B++){let C=F.charAt(B),$=D.charAt(B);if(C!==$&&B>0)E+=`${u}${F.charAt(B)}`;else E+=$}return E}function zF(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 s2(D){if(Array.isArray(D))return D.map(($)=>typeof $!=="string"?$+"":$);D=D.trim();let u=0,F=null,E=null,B=null,C=[];for(let $=0;$<D.length;$++){if(F=E,E=D.charAt($),E===" "&&!B){if(F!==" ")u++;continue}if(E===B)B=null;else if((E==="'"||E==='"')&&!B)B=E;if(!C[u])C[u]="";C[u]+=E}return C}var ND;(function(D){D.BOOLEAN="boolean",D.STRING="string",D.NUMBER="number",D.ARRAY="array"})(ND||(ND={}));var mD;class eF{constructor(D){mD=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=s2(D),B=typeof D==="string",C=U6(Object.assign(Object.create(null),F.alias)),$=Object.assign({"boolean-negation":!0,"camel-case-expansion":!0,"combine-arrays":!1,"dot-notation":!0,"duplicate-arguments-array":!0,"flatten-duplicate-arrays":!0,"greedy-arrays":!0,"halt-at-non-option":!1,"nargs-eats-options":!1,"negation-prefix":"no-","parse-numbers":!0,"parse-positional-numbers":!0,"populate--":!1,"set-placeholder-key":!1,"short-option-groups":!0,"strip-aliased":!1,"strip-dashed":!1,"unknown-options-as-args":!1},F.configuration),z=Object.assign(Object.create(null),F.default),Z=F.configObjects||[],J=F.envPrefix,X=$["populate--"],G=X?"--":"_",Y=Object.create(null),V=Object.create(null),H=F.__||mD.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:[]},K=/^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/,N=new RegExp("^--"+$["negation-prefix"]+"(.+)");if([].concat(F.array||[]).filter(Boolean).forEach(function(q){let U=typeof q==="object"?q.key:q,A=Object.keys(q).map(function(_){return{boolean:"bools",string:"strings",number:"numbers"}[_]}).filter(Boolean).pop();if(A)W[A][U]=!0;W.arrays[U]=!0,W.keys.push(U)}),[].concat(F.boolean||[]).filter(Boolean).forEach(function(q){W.bools[q]=!0,W.keys.push(q)}),[].concat(F.string||[]).filter(Boolean).forEach(function(q){W.strings[q]=!0,W.keys.push(q)}),[].concat(F.number||[]).filter(Boolean).forEach(function(q){W.numbers[q]=!0,W.keys.push(q)}),[].concat(F.count||[]).filter(Boolean).forEach(function(q){W.counts[q]=!0,W.keys.push(q)}),[].concat(F.normalize||[]).filter(Boolean).forEach(function(q){W.normalize[q]=!0,W.keys.push(q)}),typeof F.narg==="object")Object.entries(F.narg).forEach(([q,U])=>{if(typeof U==="number")W.nargs[q]=U,W.keys.push(q)});if(typeof F.coerce==="object")Object.entries(F.coerce).forEach(([q,U])=>{if(typeof U==="function")W.coercions[q]=U,W.keys.push(q)});if(typeof F.config<"u"){if(Array.isArray(F.config)||typeof F.config==="string")[].concat(F.config).filter(Boolean).forEach(function(q){W.configs[q]=!0});else if(typeof F.config==="object")Object.entries(F.config).forEach(([q,U])=>{if(typeof U==="boolean"||typeof U==="function")W.configs[q]=U})}bu(F.key,C,F.default,W.arrays),Object.keys(z).forEach(function(q){(W.aliases[q]||[]).forEach(function(U){z[U]=z[q]})});let M=null;kF();let L=[],j=Object.assign(Object.create(null),{_:[]}),T={};for(let q=0;q<E.length;q++){let U=E[q],A=U.replace(/^-{3,}/,"---"),_,O,x,P,v,GD;if(U!=="--"&&/^-/.test(U)&&s(U))y(U);else if(A.match(/^---+(=|$)/)){y(U);continue}else if(U.match(/^--.+=/)||!$["short-option-groups"]&&U.match(/^-.+=/)){if(P=U.match(/^--?([^=]+)=([\s\S]*)$/),P!==null&&Array.isArray(P)&&P.length>=3)if(p(P[1],W.arrays))q=QD(q,P[1],E,P[2]);else if(p(P[1],W.nargs)!==!1)q=k(q,P[1],E,P[2]);else l(P[1],P[2],!0)}else if(U.match(N)&&$["boolean-negation"]){if(P=U.match(N),P!==null&&Array.isArray(P)&&P.length>=2)O=P[1],l(O,p(O,W.arrays)?[!1]:!1)}else if(U.match(/^--.+/)||!$["short-option-groups"]&&U.match(/^-[^-]+/)){if(P=U.match(/^--?(.+)/),P!==null&&Array.isArray(P)&&P.length>=2)if(O=P[1],p(O,W.arrays))q=QD(q,O,E);else if(p(O,W.nargs)!==!1)q=k(q,O,E);else if(v=E[q+1],v!==void 0&&(!v.match(/^-/)||v.match(K))&&!p(O,W.bools)&&!p(O,W.counts))l(O,v),q++;else if(/^(true|false)$/.test(v))l(O,v),q++;else l(O,i(O))}else if(U.match(/^-.\..+=/)){if(P=U.match(/^-([^=]+)=([\s\S]*)$/),P!==null&&Array.isArray(P)&&P.length>=3)l(P[1],P[2])}else if(U.match(/^-.\..+/)&&!U.match(K)){if(v=E[q+1],P=U.match(/^-(.\..+)/),P!==null&&Array.isArray(P)&&P.length>=2)if(O=P[1],v!==void 0&&!v.match(/^-/)&&!p(O,W.bools)&&!p(O,W.counts))l(O,v),q++;else l(O,i(O))}else if(U.match(/^-[^-]+/)&&!U.match(K)){x=U.slice(1,-1).split(""),_=!1;for(let HD=0;HD<x.length;HD++){if(v=U.slice(HD+2),x[HD+1]&&x[HD+1]==="="){if(GD=U.slice(HD+3),O=x[HD],p(O,W.arrays))q=QD(q,O,E,GD);else if(p(O,W.nargs)!==!1)q=k(q,O,E,GD);else l(O,GD);_=!0;break}if(v==="-"){l(x[HD],v);continue}if(/[A-Za-z]/.test(x[HD])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(v)&&p(v,W.bools)===!1){l(x[HD],v),_=!0;break}if(x[HD+1]&&x[HD+1].match(/\W/)){l(x[HD],v),_=!0;break}else l(x[HD],i(x[HD]))}if(O=U.slice(-1)[0],!_&&O!=="-")if(p(O,W.arrays))q=QD(q,O,E);else if(p(O,W.nargs)!==!1)q=k(q,O,E);else if(v=E[q+1],v!==void 0&&(!/^(-|--)[^-]/.test(v)||v.match(K))&&!p(O,W.bools)&&!p(O,W.counts))l(O,v),q++;else if(/^(true|false)$/.test(v))l(O,v),q++;else l(O,i(O))}else if(U.match(/^-[0-9]$/)&&U.match(K)&&p(U.slice(1),W.bools))O=U.slice(1),l(O,i(O));else if(U==="--"){L=E.slice(q+1);break}else if($["halt-at-non-option"]){L=E.slice(q);break}else y(U)}if(CD(j,!0),CD(j,!1),b(j),o(),kD(j,W.aliases,z,!0),n(j),$["set-placeholder-key"])$D(j);if(Object.keys(W.counts).forEach(function(q){if(!r(j,q.split(".")))l(q,0)}),X&&L.length)j[G]=[];if(L.forEach(function(q){j[G].push(q)}),$["camel-case-expansion"]&&$["strip-dashed"])Object.keys(j).filter((q)=>q!=="--"&&q.includes("-")).forEach((q)=>{delete j[q]});if($["strip-aliased"])[].concat(...Object.keys(C).map((q)=>C[q])).forEach((q)=>{if($["camel-case-expansion"]&&q.includes("-"))delete j[q.split(".").map((U)=>Fu(U)).join(".")];delete j[q]});function y(q){let U=R("_",q);if(typeof U==="string"||typeof U==="number")j._.push(U)}function k(q,U,A,_){let O,x=p(U,W.nargs);if(x=typeof x!=="number"||isNaN(x)?1:x,x===0){if(!ZD(_))M=Error(H("Argument unexpected for: %s",U));return l(U,i(U)),q}let P=ZD(_)?0:1;if($["nargs-eats-options"]){if(A.length-(q+1)+P<x)M=Error(H("Not enough arguments following: %s",U));P=x}else{for(O=q+1;O<A.length;O++)if(!A[O].match(/^-[^0-9]/)||A[O].match(K)||s(A[O]))P++;else break;if(P<x)M=Error(H("Not enough arguments following: %s",U))}let v=Math.min(P,x);if(!ZD(_)&&v>0)l(U,_),v--;for(O=q+1;O<v+q+1;O++)l(U,A[O]);return q+v}function QD(q,U,A,_){let O=[],x=_||A[q+1],P=p(U,W.nargs);if(p(U,W.bools)&&!/^(true|false)$/.test(x))O.push(!0);else if(ZD(x)||ZD(_)&&/^-/.test(x)&&!K.test(x)&&!s(x)){if(z[U]!==void 0){let v=z[U];O=Array.isArray(v)?v:[v]}}else{if(!ZD(_))O.push(I(U,_,!0));for(let v=q+1;v<A.length;v++){if(!$["greedy-arrays"]&&O.length>0||P&&typeof P==="number"&&O.length>=P)break;if(x=A[v],/^-/.test(x)&&!K.test(x)&&!s(x))break;q=v,O.push(I(U,x,B))}}if(typeof P==="number"&&(P&&O.length<P||isNaN(P)&&O.length===0))M=Error(H("Not enough arguments following: %s",U));return l(U,O),q}function l(q,U,A=B){if(/-/.test(q)&&$["camel-case-expansion"]){let x=q.split(".").map(function(P){return Fu(P)}).join(".");Du(q,x)}let _=I(q,U,A),O=q.split(".");if(pD(j,O,_),W.aliases[q])W.aliases[q].forEach(function(x){let P=x.split(".");pD(j,P,_)});if(O.length>1&&$["dot-notation"])(W.aliases[O[0]]||[]).forEach(function(x){let P=x.split("."),v=[].concat(O);if(v.shift(),P=P.concat(v),!(W.aliases[q]||[]).includes(P.join(".")))pD(j,P,_)});if(p(q,W.normalize)&&!p(q,W.arrays))[q].concat(W.aliases[q]||[]).forEach(function(P){Object.defineProperty(T,P,{enumerable:!0,get(){return U},set(v){U=typeof v==="string"?mD.normalize(v):v}})})}function Du(q,U){if(!(W.aliases[q]&&W.aliases[q].length))W.aliases[q]=[U],Y[U]=!0;if(!(W.aliases[U]&&W.aliases[U].length))Du(U,q)}function I(q,U,A){if(A)U=j6(U);if(p(q,W.bools)||p(q,W.counts)){if(typeof U==="string")U=U==="true"}let _=Array.isArray(U)?U.map(function(O){return R(q,O)}):R(q,U);if(p(q,W.counts)&&(ZD(_)||typeof _==="boolean"))_=aF();if(p(q,W.normalize)&&p(q,W.arrays))if(Array.isArray(U))_=U.map((O)=>{return mD.normalize(O)});else _=mD.normalize(U);return _}function R(q,U){if(!$["parse-positional-numbers"]&&q==="_")return U;if(!p(q,W.strings)&&!p(q,W.bools)&&!Array.isArray(U)){if(zF(U)&&$["parse-numbers"]&&Number.isSafeInteger(Math.floor(parseFloat(`${U}`)))||!ZD(U)&&p(q,W.numbers))U=Number(U)}return U}function b(q){let U=Object.create(null);kD(U,W.aliases,z),Object.keys(W.configs).forEach(function(A){let _=q[A]||U[A];if(_)try{let O=null,x=mD.resolve(mD.cwd(),_),P=W.configs[A];if(typeof P==="function"){try{O=P(x)}catch(v){O=v}if(O instanceof Error){M=O;return}}else O=mD.require(x);c(O)}catch(O){if(O.name==="PermissionDenied")M=O;else if(q[A])M=Error(H("Invalid JSON config file: %s",_))}})}function c(q,U){Object.keys(q).forEach(function(A){let _=q[A],O=U?U+"."+A:A;if(typeof _==="object"&&_!==null&&!Array.isArray(_)&&$["dot-notation"])c(_,O);else if(!r(j,O.split("."))||p(O,W.arrays)&&$["combine-arrays"])l(O,_)})}function o(){if(typeof Z<"u")Z.forEach(function(q){c(q)})}function CD(q,U){if(typeof J>"u")return;let A=typeof J==="string"?J:"",_=mD.env();Object.keys(_).forEach(function(O){if(A===""||O.lastIndexOf(A,0)===0){let x=O.split("__").map(function(P,v){if(v===0)P=P.substring(A.length);return Fu(P)});if((U&&W.configs[x.join(".")]||!U)&&!r(q,x))l(x.join("."),_[O])}})}function n(q){let U,A=new Set;Object.keys(q).forEach(function(_){if(!A.has(_)){if(U=p(_,W.coercions),typeof U==="function")try{let O=R(_,U(q[_]));[].concat(W.aliases[_]||[],_).forEach((x)=>{A.add(x),q[x]=O})}catch(O){M=O}}})}function $D(q){return W.keys.forEach((U)=>{if(~U.indexOf("."))return;if(typeof q[U]>"u")q[U]=void 0}),q}function kD(q,U,A,_=!1){Object.keys(A).forEach(function(O){if(!r(q,O.split("."))){if(pD(q,O.split("."),A[O]),_)V[O]=!0;(U[O]||[]).forEach(function(x){if(r(q,x.split(".")))return;pD(q,x.split("."),A[O])})}})}function r(q,U){let A=q;if(!$["dot-notation"])U=[U.join(".")];U.slice(0,-1).forEach(function(O){A=A[O]||{}});let _=U[U.length-1];if(typeof A!=="object")return!1;else return _ in A}function pD(q,U,A){let _=q;if(!$["dot-notation"])U=[U.join(".")];U.slice(0,-1).forEach(function(GD){if(GD=r2(GD),typeof _==="object"&&_[GD]===void 0)_[GD]={};if(typeof _[GD]!=="object"||Array.isArray(_[GD])){if(Array.isArray(_[GD]))_[GD].push({});else _[GD]=[_[GD],{}];_=_[GD][_[GD].length-1]}else _=_[GD]});let O=r2(U[U.length-1]),x=p(U.join("."),W.arrays),P=Array.isArray(A),v=$["duplicate-arguments-array"];if(!v&&p(O,W.nargs)){if(v=!0,!ZD(_[O])&&W.nargs[O]===1||Array.isArray(_[O])&&_[O].length===W.nargs[O])_[O]=void 0}if(A===aF())_[O]=aF(_[O]);else if(Array.isArray(_[O]))if(v&&x&&P)_[O]=$["flatten-duplicate-arrays"]?_[O].concat(A):(Array.isArray(_[O][0])?_[O]:[_[O]]).concat([A]);else if(!v&&Boolean(x)===Boolean(P))_[O]=A;else _[O]=_[O].concat([A]);else if(_[O]===void 0&&x)_[O]=P?A:[A];else if(v&&!(_[O]===void 0||p(O,W.counts)||p(O,W.bools)))_[O]=[_[O],A];else _[O]=A}function bu(...q){q.forEach(function(U){Object.keys(U||{}).forEach(function(A){if(W.aliases[A])return;W.aliases[A]=[].concat(C[A]||[]),W.aliases[A].concat(A).forEach(function(_){if(/-/.test(_)&&$["camel-case-expansion"]){let O=Fu(_);if(O!==A&&W.aliases[A].indexOf(O)===-1)W.aliases[A].push(O),Y[O]=!0}}),W.aliases[A].concat(A).forEach(function(_){if(_.length>1&&/[A-Z]/.test(_)&&$["camel-case-expansion"]){let O=$F(_,"-");if(O!==A&&W.aliases[A].indexOf(O)===-1)W.aliases[A].push(O),Y[O]=!0}}),W.aliases[A].forEach(function(_){W.aliases[_]=[A].concat(W.aliases[A].filter(function(O){return _!==O}))})})})}function p(q,U){let A=[].concat(W.aliases[q]||[],q),_=Object.keys(U),O=A.find((x)=>_.includes(x));return O?U[O]:!1}function Nu(q){let U=Object.keys(W);return[].concat(U.map((_)=>W[_])).some(function(_){return Array.isArray(_)?_.includes(q):_[q]})}function q2(q,...U){return[].concat(...U).some(function(_){let O=q.match(_);return O&&Nu(O[1])})}function m(q){if(q.match(K)||!q.match(/^-[^-]+/))return!1;let U=!0,A,_=q.slice(1).split("");for(let O=0;O<_.length;O++){if(A=q.slice(O+2),!Nu(_[O])){U=!1;break}if(_[O+1]&&_[O+1]==="="||A==="-"||/[A-Za-z]/.test(_[O])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(A)||_[O+1]&&_[O+1].match(/\W/))break}return U}function s(q){return $["unknown-options-as-args"]&&zD(q)}function zD(q){if(q=q.replace(/^-{3,}/,"--"),q.match(K))return!1;if(m(q))return!1;return!q2(q,/^-+([^=]+?)=[\s\S]*$/,N,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}function i(q){if(!p(q,W.bools)&&!p(q,W.counts)&&`${q}`in z)return z[q];else return YD(FD(q))}function YD(q){return{[ND.BOOLEAN]:!0,[ND.STRING]:"",[ND.NUMBER]:void 0,[ND.ARRAY]:[]}[q]}function FD(q){let U=ND.BOOLEAN;if(p(q,W.strings))U=ND.STRING;else if(p(q,W.numbers))U=ND.NUMBER;else if(p(q,W.bools))U=ND.BOOLEAN;else if(p(q,W.arrays))U=ND.ARRAY;return U}function ZD(q){return q===void 0}function kF(){Object.keys(W.counts).find((q)=>{if(p(q,W.arrays))return M=Error(H("Invalid configuration: %s, opts.count excludes opts.array.",q)),!0;else if(p(q,W.nargs))return M=Error(H("Invalid configuration: %s, opts.count excludes opts.narg.",q)),!0;return!1})}return{aliases:Object.assign({},W.aliases),argv:Object.assign(T,j),configuration:$,defaulted:Object.assign({},V),error:M,newAliases:Object.assign({},Y)}}}function U6(D){let u=[],F=Object.create(null),E=!0;Object.keys(D).forEach(function(B){u.push([].concat(D[B],B))});while(E){E=!1;for(let B=0;B<u.length;B++)for(let C=B+1;C<u.length;C++)if(u[B].filter(function(z){return u[C].indexOf(z)!==-1}).length){u[B]=u[B].concat(u[C]),u.splice(C,1),E=!0;break}}return u.forEach(function(B){B=B.filter(function($,z,Z){return Z.indexOf($)===z});let C=B.pop();if(C!==void 0&&typeof C==="string")F[C]=B}),F}function aF(D){return D!==void 0?D+1:1}function r2(D){if(D==="__proto__")return"___proto___";return D}function j6(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 A6}from"fs";import{createRequire as a2}from"node:module";var D0,u0,F0,e2=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):20,D8=(u0=(D0=process===null||process===void 0?void 0:process.versions)===null||D0===void 0?void 0:D0.node)!==null&&u0!==void 0?u0:(F0=process===null||process===void 0?void 0:process.version)===null||F0===void 0?void 0:F0.slice(1);if(D8){if(Number(D8.match(/^([^.]+)/)[1])<e2)throw Error(`yargs parser supports a minimum Node.js version of ${e2}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`)}var L6=process?process.env:{},u8=a2?a2(import.meta.url):void 0,F8=new eF({cwd:process.cwd,env:()=>{return L6},format:M6,normalize:_6,resolve:N6,require:(D)=>{if(typeof u8<"u")return u8(D);else if(D.match(/\.json$/))return JSON.parse(A6(D,"utf8"));else throw Error("only .json config files are supported in ESM")}}),fu=function(u,F){return F8.parse(u.slice(),F).argv};fu.detailed=function(D,u){return F8.parse(D.slice(),u)};fu.camelCase=Fu;fu.decamelize=$F;fu.looksLikeNumber=zF;var E0=fu;import{basename as y6,dirname as p6,extname as m6,relative as g6,resolve as X8,join as c6}from"path";function E8(){if(T6())return 0;return 1}function T6(){return R6()&&!process.defaultApp}function R6(){return!!process.versions.electron}function B0(D){return D.slice(E8()+1)}function B8(){return process.argv[E8()]}import{readFileSync as P6,statSync as S6,writeFile as w6}from"fs";import{format as x6}from"util";import{resolve as I6}from"path";var C8={fs:{readFileSync:P6,writeFile:w6},format:x6,resolve:I6,exists:(D)=>{try{return S6(D).isFile()}catch(u){return!1}}};var PD;class $8{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 PD.format.apply(PD.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(),B=function(){};if(typeof D[D.length-1]==="function")B=D.pop();if(!this.cache[this.locale])this._readLocaleFile();let C=E===1?u:F;if(this.cache[this.locale][u])C=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:B});else B();let $=[C];if(~C.indexOf("%d"))$.push(E);return PD.format.apply(PD.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,B){let C=u[B+1];if(F+=E,typeof C<"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,B=u.cb,C=this._resolveLocaleFile(F,E),$=JSON.stringify(this.cache[E],null,2);PD.fs.writeFile(C,$,"utf-8",function(z){if(D.writeQueue.shift(),D.writeQueue.length>0)D._processWriteQueue();B(z)})}_readLocaleFile(){let D={},u=this._resolveLocaleFile(this.directory,this.locale);try{if(PD.fs.readFileSync)D=JSON.parse(PD.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=PD.resolve(D,"./",u+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(F)&&~u.lastIndexOf("_")){let E=PD.resolve(D,"./",u.split("_")[0]+".json");if(this._fileExistsSync(E))F=E}return F}_fileExistsSync(D){return PD.exists(D)}}function z8(D,u){PD=u;let F=new $8(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 b6=(D)=>{return z8(D,C8)},Z8=b6;var Y8=O2(G8(),1);import{createRequire as d6}from"node:module";import{readFileSync as k6,readdirSync as i6}from"node:fs";var C0=Q8(import.meta.url),l6=C0.substring(0,C0.lastIndexOf("node_modules")),n6=d6(import.meta.url),$0={assert:{notStrictEqual:f6,strictEqual:h6},cliui:sF,findUp:rF,getEnv:(D)=>{return process.env[D]},inspect:v6,getProcessArgvBin:B8,mainFilename:l6||process.cwd(),Parser:E0,path:{basename:y6,dirname:p6,extname:m6,relative:g6,resolve:X8,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:k6,readdirSync:i6,require:n6,getCallerFile:()=>{let D=Y8.default(3);return D.match(/^file:\/\//)?Q8(D):D},stringWidth:RD,y18n:Z8({directory:X8(C0,"../../../locales"),updateFiles:!1})};function qD(D,u,F,E){F.assert.notStrictEqual(D,u,E)}function z0(D,u){u.assert.strictEqual(typeof D,"string")}function Au(D){return Object.keys(D)}function a(D){return!!D&&!!D.then&&typeof D.then==="function"}class ED extends Error{constructor(D){super(D||"yargs error");if(this.name="YError",Error.captureStackTrace)Error.captureStackTrace(this,ED)}}function iD(D){let F=D.replace(/\s{2,}/g," ").split(/\s+(?![^[]*]|[^<]*>)/),E=/\.*[\][<>]/g,B=F.shift();if(!B)throw Error(`No command found in: ${D}`);let C={cmd:B.replace(E,""),demanded:[],optional:[]};return F.forEach(($,z)=>{let Z=!1;if($=$.replace(/\s/g,""),/\.+[\]>]/.test($)&&z===F.length-1)Z=!0;if(/^\[/.test($))C.optional.push({cmd:$.replace(E,"").split("|"),variadic:Z});else C.demanded.push({cmd:$.replace(E,"").split("|"),variadic:Z})}),C}var t6=["first","second","third","fourth","fifth","sixth"];function S(D,u,F){function E(){return typeof D==="object"?[{demanded:[],optional:[]},D,u]:[iD(`cmd ${D}`),u,F]}try{let B=0,[C,$,z]=E(),Z=[].slice.call($);while(Z.length&&Z[Z.length-1]===void 0)Z.pop();let J=z||Z.length;if(J<C.demanded.length)throw new ED(`Not enough arguments provided. Expected ${C.demanded.length} but received ${Z.length}.`);let X=C.demanded.length+C.optional.length;if(J>X)throw new ED(`Too many arguments provided. Expected max ${X} but received ${J}.`);C.demanded.forEach((G)=>{let Y=Z.shift(),V=W8(Y);if(G.cmd.filter((W)=>W===V||W==="*").length===0)V8(V,G.cmd,B);B+=1}),C.optional.forEach((G)=>{if(Z.length===0)return;let Y=Z.shift(),V=W8(Y);if(G.cmd.filter((W)=>W===V||W==="*").length===0)V8(V,G.cmd,B);B+=1})}catch(B){console.warn(B.stack)}}function W8(D){if(Array.isArray(D))return"array";else if(D===null)return"null";return typeof D}function V8(D,u,F){throw new ED(`Invalid ${t6[F]||"manyith"} argument. Expected ${u.join(" or ")} but received ${D}.`)}class Z0{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 B=0;B<D.length;B++){if(typeof D[B]!=="function")throw Error("middleware must be a function");let C=D[B];C.applyBeforeValidation=u,C.global=F}Array.prototype.push.apply(this.globalMiddleware,D)}else if(typeof D==="function"){let B=D;B.applyBeforeValidation=u,B.global=F,B.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 B=[...F[u]||[],u];if(!E.option)return!0;else return!B.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 H8(D){if(!D)return[];return D.map((u)=>{return u.applyBeforeValidation=!1,u})}function Eu(D,u,F,E){return F.reduce((B,C)=>{if(C.applyBeforeValidation!==E)return B;if(C.mutates){if(C.applied)return B;C.applied=!0}if(a(B))return B.then(($)=>Promise.all([$,C($,u)])).then(([$,z])=>Object.assign($,z));else{let $=C(B,u);return a($)?$.then((z)=>Object.assign(B,z)):Object.assign(B,$)}},D)}function Bu(D,u,F=(E)=>{throw E}){try{let E=o6(D)?D():D;return a(E)?E.then((B)=>u(B)):u(E)}catch(E){return F(E)}}function o6(D){return typeof D==="function"}var Lu=/(^\*)|(^\$0)/;class K8{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 B=this.shim.path.resolve(this.shim.path.dirname(F),D),C=this.shim.readdirSync(B,{recursive:E.recurse?!0:!1});if(!Array.isArray(E.extensions))E.extensions=["js"];let $=typeof E.visit==="function"?E.visit:(z)=>z;for(let z of C){let Z=z.toString();if(E.exclude){let X=!1;if(typeof E.exclude==="function")X=E.exclude(Z);else X=E.exclude.test(Z);if(X)continue}if(E.include){let X=!1;if(typeof E.include==="function")X=E.include(Z);else X=E.include.test(Z);if(!X)continue}let J=!1;for(let X of E.extensions)if(Z.endsWith(X))J=!0;if(J){let X=this.shim.path.join(B,Z),G=u(X),Y=Object.create(null,Object.getOwnPropertyDescriptors({...G}));if($(Y,X,Z)){if(this.requireCache.has(X))continue;else this.requireCache.add(X);if(!Y.command)Y.command=this.shim.path.basename(X,this.shim.path.extname(X));this.addHandler(Y)}}}}addHandler(D,u,F,E,B,C){let $=[],z=H8(B);if(E=E||(()=>{}),Array.isArray(D))if(s6(D))[D,...$]=D;else for(let Z of D)this.addHandler(Z);else if(a6(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(q8(F)){this.addHandler([D].concat($),u,F.builder,F.handler,F.middlewares,F.deprecated);return}if(typeof D==="string"){let Z=iD(D);$=$.map((G)=>iD(G).cmd);let J=!1,X=[Z.cmd].concat($).filter((G)=>{if(Lu.test(G))return J=!0,!1;return!0});if(X.length===0&&J)X.push("$0");if(J)Z.cmd=X[0],$=X.slice(1),D=D.replace(Lu,Z.cmd);if($.forEach((G)=>{this.aliasMap[G]=Z.cmd}),u!==!1)this.usage.command(D,u,J,$,C);if(this.handlers[Z.cmd]={original:D,description:u,handler:E,builder:F||{},middlewares:z,deprecated:C,demanded:Z.demanded,optional:Z.optional},J)this.defaultCommand=this.handlers[Z.cmd]}}getCommandHandlers(){return this.handlers}getCommands(){return Object.keys(this.handlers).concat(Object.keys(this.aliasMap))}hasDefaultCommand(){return!!this.defaultCommand}runCommand(D,u,F,E,B,C){let $=this.handlers[D]||this.handlers[this.aliasMap[D]]||this.defaultCommand,z=u.getInternalMethods().getContext(),Z=z.commands.slice(),J=!D;if(D)z.commands.push(D),z.fullCommands.push($.original);let X=this.applyBuilderUpdateUsageAndParse(J,$,u,F.aliases,Z,E,B,C);return a(X)?X.then((G)=>this.applyMiddlewareAndGetResult(J,$,G.innerArgv,z,B,G.aliases,u)):this.applyMiddlewareAndGetResult(J,$,X.innerArgv,z,B,X.aliases,u)}applyBuilderUpdateUsageAndParse(D,u,F,E,B,C,$,z){let Z=u.builder,J=F;if(ZF(Z)){F.getInternalMethods().getUsageInstance().freeze();let X=Z(F.getInternalMethods().reset(E),z);if(a(X))return X.then((G)=>{return J=U8(G)?G:F,this.parseAndUpdateUsage(D,u,J,B,C,$)})}else if(r6(Z))F.getInternalMethods().getUsageInstance().freeze(),J=F.getInternalMethods().reset(E),Object.keys(u.builder).forEach((X)=>{J.option(X,Z[X])});return this.parseAndUpdateUsage(D,u,J,B,C,$)}parseAndUpdateUsage(D,u,F,E,B,C){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,B,C);return a($)?$.then((z)=>({aliases:F.parsed.aliases,innerArgv:z})):{aliases:F.parsed.aliases,innerArgv:$}}shouldUpdateUsage(D){return!D.getInternalMethods().getUsageInstance().getUsageDisabled()&&D.getInternalMethods().getUsageInstance().getUsage().length===0}usageFromParentCommandsCommandHandler(D,u){let F=Lu.test(u.original)?u.original.replace(Lu,"").trim():u.original,E=D.filter((B)=>{return!Lu.test(B)});return E.push(F),`$0 ${E.join(" ")}`}handleValidationAndGetResult(D,u,F,E,B,C,$,z){if(!C.getInternalMethods().getHasOutput()){let Z=C.getInternalMethods().runValidation(B,z,C.parsed.error,D);F=Bu(F,(J)=>{return Z(J),J})}if(u.handler&&!C.getInternalMethods().getHasOutput()){C.getInternalMethods().setHasOutput();let Z=!!C.getOptions().configuration["populate--"];if(C.getInternalMethods().postProcess(F,Z,!1,!1),F=Eu(F,C,$,!1),F=Bu(F,(J)=>{let X=u.handler(J);return a(X)?X.then(()=>J):J}),!D)C.getInternalMethods().getUsageInstance().cacheHelpMessage();if(a(F)&&!C.getInternalMethods().hasParseCallback())F.catch((J)=>{try{C.getInternalMethods().getUsageInstance().fail(null,J)}catch(X){}})}if(!D)E.commands.pop(),E.fullCommands.pop();return F}applyMiddlewareAndGetResult(D,u,F,E,B,C,$){let z={};if(B)return F;if(!$.getInternalMethods().getHasOutput())z=this.populatePositionals(u,F,E,$);let Z=this.globalMiddleware.getMiddleware().slice(0).concat(u.middlewares),J=Eu(F,$,Z,!0);return a(J)?J.then((X)=>this.handleValidationAndGetResult(D,u,X,E,C,$,Z,z)):this.handleValidationAndGetResult(D,u,J,E,C,$,Z,z)}populatePositionals(D,u,F,E){u._=u._.slice(F.commands.length);let B=D.demanded.slice(0),C=D.optional.slice(0),$={};this.validation.positionalCount(B.length,u._.length);while(B.length){let z=B.shift();this.populatePositional(z,u,$)}while(C.length){let z=C.shift();this.populatePositional(z,u,$)}return u._=F.commands.concat(u._.map((z)=>""+z)),this.postProcessPositionals(u,$,this.cmdToParseOptions(D.original),E),$}populatePositional(D,u,F){let E=D.cmd[0];if(D.variadic)F[E]=u._.splice(0).map(String);else if(u._.length)F[E]=[String(u._.shift())]}cmdToParseOptions(D){let u={array:[],default:{},alias:{},demand:{}},F=iD(D);return F.demanded.forEach((E)=>{let[B,...C]=E.cmd;if(E.variadic)u.array.push(B),u.default[B]=[];u.alias[B]=C,u.demand[B]=!0}),F.optional.forEach((E)=>{let[B,...C]=E.cmd;if(E.variadic)u.array.push(B),u.default[B]=[];u.alias[B]=C}),u}postProcessPositionals(D,u,F,E){let B=Object.assign({},E.getOptions());B.default=Object.assign(F.default,B.default);for(let Z of Object.keys(F.alias))B.alias[Z]=(B.alias[Z]||[]).concat(F.alias[Z]);B.array=B.array.concat(F.array),B.config={};let C=[];if(Object.keys(u).forEach((Z)=>{u[Z].map((J)=>{if(B.configuration["unknown-options-as-args"])B.key[Z]=!0;C.push(`--${Z}`),C.push(J)})}),!C.length)return;let $=Object.assign({},B.configuration,{"populate--":!1}),z=this.shim.Parser.detailed(C,Object.assign({},B,{configuration:$}));if(z.error)E.getInternalMethods().getUsageInstance().fail(z.error.message,z.error);else{let Z=Object.keys(u);Object.keys(u).forEach((J)=>{Z.push(...z.aliases[J])}),Object.keys(z.argv).forEach((J)=>{if(Z.includes(J)){if(!u[J])u[J]=z.argv[J];if(!this.isInConfigs(E,J)&&!this.isDefaulted(E,J)&&Object.prototype.hasOwnProperty.call(D,J)&&Object.prototype.hasOwnProperty.call(z.argv,J)&&(Array.isArray(D[J])||Array.isArray(z.argv[J])))D[J]=[].concat(D[J],z.argv[J]);else D[J]=z.argv[J]}})}}isDefaulted(D,u){let{default:F}=D.getOptions();return Object.prototype.hasOwnProperty.call(F,u)||Object.prototype.hasOwnProperty.call(F,this.shim.Parser.camelCase(u))}isInConfigs(D,u){let{configObjects:F}=D.getOptions();return F.some((E)=>Object.prototype.hasOwnProperty.call(E,u))||F.some((E)=>Object.prototype.hasOwnProperty.call(E,this.shim.Parser.camelCase(u)))}runDefaultBuilderOn(D){if(!this.defaultCommand)return;if(this.shouldUpdateUsage(D)){let F=Lu.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(ZF(u))return u(D,!0);else if(!q8(u))Object.keys(u).forEach((F)=>{D.option(F,u[F])});return}extractDesc({describe:D,description:u,desc:F}){for(let E of[D,u,F]){if(typeof E==="string"||E===!1)return E;qD(E,!0,this.shim)}return!1}freeze(){this.frozens.push({handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand})}unfreeze(){let D=this.frozens.pop();qD(D,void 0,this.shim),{handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand}=D}reset(){return this.handlers={},this.aliasMap={},this.defaultCommand=void 0,this.requireCache=new Set,this}}function O8(D,u,F,E){return new K8(D,u,F,E)}function q8(D){return typeof D==="object"&&!!D.builder&&typeof D.handler==="function"}function s6(D){return D.every((u)=>typeof u==="string")}function ZF(D){return typeof D==="function"}function r6(D){return typeof D==="object"}function a6(D){return typeof D==="object"&&!Array.isArray(D)}function lD(D={},u=()=>!0){let F={};return Au(D).forEach((E)=>{if(u(E,D[E]))F[E]=D[E]}),F}function nD(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 e6(D){return typeof D==="boolean"}function M8(D,u){let F=u.y18n.__,E={},B=[];E.failFn=function(R){B.push(R)};let C=null,$=null,z=!0;E.showHelpOnFail=function(R=!0,b){let[c,o]=typeof R==="string"?[!0,R]:[R,b];if(D.getInternalMethods().isGlobalContext())$=o;return C=o,z=c,E};let Z=!1;E.fail=function(R,b){let c=D.getInternalMethods().getLoggerInstance();if(B.length)for(let o=B.length-1;o>=0;--o){let CD=B[o];if(e6(CD)){if(b)throw b;else if(R)throw Error(R)}else CD(R,b,E)}else{if(D.getExitProcess())nD(!0);if(!Z){if(Z=!0,z)D.showHelp("error"),c.error();if(R||b)c.error(R||b);let o=C||$;if(o){if(R||b)c.error("");c.error(o)}}if(b=b||new ED(R),D.getExitProcess())return D.exit(1);else if(D.getInternalMethods().hasParseCallback())return D.exit(1,b);else throw b}};let J=[],X=!1;E.usage=(I,R)=>{if(I===null)return X=!0,J=[],E;return X=!1,J.push([I,R||""]),E},E.getUsage=()=>{return J},E.getUsageDisabled=()=>{return X},E.getPositionalGroupName=()=>{return F("Positionals:")};let G=[];E.example=(I,R)=>{G.push([I,R||""])};let Y=[];E.command=function(R,b,c,o,CD=!1){if(c)Y=Y.map((n)=>{return n[2]=!1,n});Y.push([R,b||"",c,o,CD])},E.getCommands=()=>Y;let V={};E.describe=function(R,b){if(Array.isArray(R))R.forEach((c)=>{E.describe(c,b)});else if(typeof R==="object")Object.keys(R).forEach((c)=>{E.describe(c,R[c])});else V[R]=b},E.getDescriptions=()=>V;let H=[];E.epilog=(I)=>{H.push(I)};let W=!1,K;E.wrap=(I)=>{W=!0,K=I},E.getWrap=()=>{if(u.getEnv("YARGS_DISABLE_WRAP"))return null;if(!W)K=QD(),W=!0;return K};let N="__yargsString__:";E.deferY18nLookup=(I)=>N+I,E.help=function(){if(j)return j;L();let R=D.customScriptName?D.$0:u.path.basename(D.$0),b=D.getDemandedOptions(),c=D.getDemandedCommands(),o=D.getDeprecatedOptions(),CD=D.getGroups(),n=D.getOptions(),$D=[];$D=$D.concat(Object.keys(V)),$D=$D.concat(Object.keys(b)),$D=$D.concat(Object.keys(c)),$D=$D.concat(Object.keys(n.default)),$D=$D.filter(y),$D=Object.keys($D.reduce((m,s)=>{if(s!=="_")m[s]=!0;return m},{}));let kD=E.getWrap(),r=u.cliui({width:kD,wrap:!!kD});if(!X){if(J.length)J.forEach((m)=>{if(r.div({text:`${m[0].replace(/\$0/g,R)}`}),m[1])r.div({text:`${m[1]}`,padding:[1,0,0,0]})}),r.div();else if(Y.length){let m=null;if(c._)m=`${R} <${F("command")}>
15
+ `;else m=`${R} [${F("command")}]
16
+ `;r.div(`${m}`)}}if(Y.length>1||Y.length===1&&!Y[0][2]){r.div(F("Commands:"));let m=D.getInternalMethods().getContext(),s=m.commands.length?`${m.commands.join(" ")} `:"";if(D.getInternalMethods().getParserConfiguration()["sort-commands"]===!0)Y=Y.sort((i,YD)=>i[0].localeCompare(YD[0]));let zD=R?`${R} `:"";Y.forEach((i)=>{let YD=`${zD}${s}${i[0].replace(/^\$0 ?/,"")}`;r.span({text:YD,padding:[0,2,0,2],width:M(Y,kD,`${R}${s}`)+4},{text:i[1]});let FD=[];if(i[2])FD.push(`[${F("default")}]`);if(i[3]&&i[3].length)FD.push(`[${F("aliases:")} ${i[3].join(", ")}]`);if(i[4])if(typeof i[4]==="string")FD.push(`[${F("deprecated: %s",i[4])}]`);else FD.push(`[${F("deprecated")}]`);if(FD.length)r.div({text:FD.join(" "),padding:[0,0,0,2],align:"right"});else r.div()}),r.div()}let pD=(Object.keys(n.alias)||[]).concat(Object.keys(D.parsed.newAliases)||[]);$D=$D.filter((m)=>!D.parsed.newAliases[m]&&pD.every((s)=>(n.alias[s]||[]).indexOf(m)===-1));let bu=F("Options:");if(!CD[bu])CD[bu]=[];T($D,n.alias,CD,bu);let p=(m)=>/^--/.test(JF(m)),Nu=Object.keys(CD).filter((m)=>CD[m].length>0).map((m)=>{let s=CD[m].filter(y).map((zD)=>{if(pD.includes(zD))return zD;for(let i=0,YD;(YD=pD[i])!==void 0;i++)if((n.alias[YD]||[]).includes(zD))return YD;return zD});return{groupName:m,normalizedKeys:s}}).filter(({normalizedKeys:m})=>m.length>0).map(({groupName:m,normalizedKeys:s})=>{let zD=s.reduce((i,YD)=>{return i[YD]=[YD].concat(n.alias[YD]||[]).map((FD)=>{if(m===E.getPositionalGroupName())return FD;else return(/^[0-9]$/.test(FD)?n.boolean.includes(YD)?"-":"--":FD.length>1?"--":"-")+FD}).sort((FD,ZD)=>p(FD)===p(ZD)?0:p(FD)?1:-1).join(", "),i},{});return{groupName:m,normalizedKeys:s,switches:zD}});if(Nu.filter(({groupName:m})=>m!==E.getPositionalGroupName()).some(({normalizedKeys:m,switches:s})=>!m.every((zD)=>p(s[zD]))))Nu.filter(({groupName:m})=>m!==E.getPositionalGroupName()).forEach(({normalizedKeys:m,switches:s})=>{m.forEach((zD)=>{if(p(s[zD]))s[zD]=D7(s[zD],4)})});if(Nu.forEach(({groupName:m,normalizedKeys:s,switches:zD})=>{r.div(m),s.forEach((i)=>{let YD=zD[i],FD=V[i]||"",ZD=null;if(FD.includes(N))FD=F(FD.substring(N.length));if(n.boolean.includes(i))ZD=`[${F("boolean")}]`;if(n.count.includes(i))ZD=`[${F("count")}]`;if(n.string.includes(i))ZD=`[${F("string")}]`;if(n.normalize.includes(i))ZD=`[${F("string")}]`;if(n.array.includes(i))ZD=`[${F("array")}]`;if(n.number.includes(i))ZD=`[${F("number")}]`;let kF=(A)=>typeof A==="string"?`[${F("deprecated: %s",A)}]`:`[${F("deprecated")}]`,q=[i in o?kF(o[i]):null,ZD,i in b?`[${F("required")}]`:null,n.choices&&n.choices[i]?`[${F("choices:")} ${E.stringifiedValues(n.choices[i])}]`:null,k(n.default[i],n.defaultDescription[i])].filter(Boolean).join(" ");r.span({text:JF(YD),padding:[0,2,0,2+j8(YD)],width:M(zD,kD)+4},FD);let U=D.getInternalMethods().getUsageConfiguration()["hide-types"]===!0;if(q&&!U)r.div({text:q,padding:[0,0,0,2],align:"right"});else r.div()}),r.div()}),G.length)r.div(F("Examples:")),G.forEach((m)=>{m[0]=m[0].replace(/\$0/g,R)}),G.forEach((m)=>{if(m[1]==="")r.div({text:m[0],padding:[0,2,0,2]});else r.div({text:m[0],padding:[0,2,0,2],width:M(G,kD)+4},{text:m[1]})}),r.div();if(H.length>0){let m=H.map((s)=>s.replace(/\$0/g,R)).join(`
17
+ `);r.div(`${m}
18
+ `)}return r.toString().replace(/\s*$/,"")};function M(I,R,b){let c=0;if(!Array.isArray(I))I=Object.values(I).map((o)=>[o]);if(I.forEach((o)=>{c=Math.max(u.stringWidth(b?`${b} ${JF(o[0])}`:JF(o[0]))+j8(o[0]),c)}),R)c=Math.min(c,parseInt((R*0.5).toString(),10));return c}function L(){let I=D.getDemandedOptions(),R=D.getOptions();(Object.keys(R.alias)||[]).forEach((b)=>{R.alias[b].forEach((c)=>{if(V[c])E.describe(b,V[c]);if(c in I)D.demandOption(b,I[c]);if(R.boolean.includes(c))D.boolean(b);if(R.count.includes(c))D.count(b);if(R.string.includes(c))D.string(b);if(R.normalize.includes(c))D.normalize(b);if(R.array.includes(c))D.array(b);if(R.number.includes(c))D.number(b)})})}let j;E.cacheHelpMessage=function(){j=this.help()},E.clearCachedHelpMessage=function(){j=void 0},E.hasCachedHelpMessage=function(){return!!j};function T(I,R,b,c){let o=[],CD=null;return Object.keys(b).forEach((n)=>{o=o.concat(b[n])}),I.forEach((n)=>{if(CD=[n].concat(R[n]),!CD.some(($D)=>o.indexOf($D)!==-1))b[c].push(n)}),o}function y(I){return D.getOptions().hiddenOptions.indexOf(I)<0||D.parsed.argv[D.getOptions().showHiddenOpt]}E.showHelp=(I)=>{let R=D.getInternalMethods().getLoggerInstance();if(!I)I="error";(typeof I==="function"?I:R[I])(E.help())},E.functionDescription=(I)=>{return["(",I.name?u.Parser.decamelize(I.name,"-"):F("generated-value"),")"].join("")},E.stringifiedValues=function(R,b){let c="",o=b||", ",CD=[].concat(R);if(!R||!CD.length)return c;return CD.forEach((n)=>{if(c.length)c+=o;c+=JSON.stringify(n)}),c};function k(I,R){let b=`[${F("default:")} `;if(I===void 0&&!R)return null;if(R)b+=R;else switch(typeof I){case"string":b+=`"${I}"`;break;case"object":b+=JSON.stringify(I);break;default:b+=I}return`${b}]`}function QD(){if(u.process.stdColumns)return Math.min(80,u.process.stdColumns);else return 80}let l=null;E.version=(I)=>{l=I},E.showVersion=(I)=>{let R=D.getInternalMethods().getLoggerInstance();if(!I)I="error";(typeof I==="function"?I:R[I])(l)},E.reset=function(R){return C=null,Z=!1,J=[],X=!1,H=[],G=[],Y=[],V=lD(V,(b)=>!R[b]),E};let Du=[];return E.freeze=function(){Du.push({failMessage:C,failureOutput:Z,usages:J,usageDisabled:X,epilogs:H,examples:G,commands:Y,descriptions:V})},E.unfreeze=function(R=!1){let b=Du.pop();if(!b)return;if(R)V={...b.descriptions,...V},Y=[...b.commands,...Y],J=[...b.usages,...J],G=[...b.examples,...G],H=[...b.epilogs,...H];else({failMessage:C,failureOutput:Z,usages:J,usageDisabled:X,epilogs:H,examples:G,commands:Y,descriptions:V}=b)},E}function J0(D){return typeof D==="object"}function D7(D,u){return J0(D)?{text:D.text,indentation:D.indentation+u}:{text:D,indentation:u}}function j8(D){return J0(D)?D.indentation:0}function JF(D){return J0(D)?D.text:D}var _8=`###-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
- `,E8=`#compdef {{app_name}}
47
+ `,N8=`#compdef {{app_name}}
48
48
  ###-begin-{{app_name}}-completions-###
49
49
  #
50
50
  # yargs command completion script
@@ -71,100 +71,103 @@ else
71
71
  compdef _{{app_name}}_yargs_completions {{app_name}}
72
72
  fi
73
73
  ###-end-{{app_name}}-completions-###
74
- `;class C8{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 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((K)=>{let A=Q[K];return typeof A==="string"&&A.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),K6(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(U6(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?E8:F8,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 B8(D,u,F,E){return new C8(D,u,F,E)}function K6(D){return D.length<3}function U6(D){return D.length>3}function $8(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 G8=["$0","--","_"];function z8(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 K of Object.keys(O)){let A=O[K];if(A&&V.indexOf(A)<0)V.push(A)}let W=V.length?`
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 K;let A=D.getInternalMethods().getCommandInstance().getCommands(),_=[],L=D.getInternalMethods().getContext();if(Object.keys(J).forEach((M)=>{if(!G8.includes(M)&&!Object.prototype.hasOwnProperty.call(O,M)&&!Object.prototype.hasOwnProperty.call(D.getInternalMethods().getParseContext(),M)&&!B.isValidAndSomeAliasIsNotNew(M,Q))_.push(M)}),W&&(L.commands.length>0||A.length>0||V))J._.slice(L.commands.length).forEach((M)=>{if(!A.includes(""+M))_.push(""+M)});if(W){let x=((K=D.getDemandedCommands()._)===null||K===void 0?void 0:K.max)||0,k=L.commands.length+x;if(k<J._.length)J._.slice(k).forEach((s)=>{if(s=String(s),!L.commands.includes(s)&&!_.includes(s))_.push(s)})}if(_.length)u.fail(C("Unknown argument: %s","Unknown arguments: %s",_.length,_.map((M)=>M.trim()?M:`"${M}"`).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((K)=>{if(G8.indexOf(K)===-1&&Object.prototype.hasOwnProperty.call(Q.choices,K))[].concat(J[K]).forEach((A)=>{if(Q.choices[K].indexOf(A)===-1&&A!==void 0)O[K]=(O[K]||[]).concat(A)})});let V=Object.keys(O);if(!V.length)return;let W=E("Invalid values:");V.forEach((K)=>{W+=`
77
- ${E("Argument: %s, Given: %s, Choices: %s",K,u.stringifiedValues(O[K]),u.stringifiedValues(Q.choices[K]))}`}),u.fail(W)};let $={};B.implies=function(J,Q){if(S("<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 K=V,A=W;if(K=G(J,K),W=G(J,W),K&&!W)Q.push(` ${V} -> ${A}`)})}),Q.length){let O=`${E("Implications failed:")}
78
- `;Q.forEach((V)=>{O+=V}),u.fail(O)}};let z={};B.conflicts=function(J,Q){if(S("<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((K,A)=>A.length-K.length);let V=null,W=1/0;for(let K=0,A;(A=Q[K])!==void 0;K++){let _=$8(J,A);if(_<=3&&_<W)W=_,V=A}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 oF=[],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 $=j6(u,D.extends);_6($),oF.push($),C=B?JSON.parse(wu.readFileSync($,"utf8")):E.require(D.extends),delete D.extends,C=xu(C,wu.path.dirname($),F,wu)}return oF=[],F?Z8(C,D):Object.assign({},C,D)}function _6(D){if(oF.indexOf(D)>-1)throw new ED(`Circular extended configurations: '${D}'.`)}function j6(D,u){return wu.path.resolve(D,u)}function Z8(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]=Z8(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)},CD,uu,Iu,VD,KD,DF,dD,Fu,uF,AD,FF,LD,xD,UD,ND,EF,Eu,XD,f,CF,BF,_D,Cu,_u,Bu,iD,$F,m,$u,Gu,zu,g,GF,ID,DD;function S8(D){return(u=[],F=D.process.cwd(),E)=>{let C=new P8(u,F,E,D);return Object.defineProperty(C,"argv",{get:()=>{return C.parse()},enumerable:!0}),C.help(),C.version(),C}}var J8=Symbol("copyDoubleDash"),X8=Symbol("copyDoubleDash"),sF=Symbol("deleteFromParserHintObject"),Q8=Symbol("emitWarning"),Y8=Symbol("freeze"),W8=Symbol("getDollarZero"),Zu=Symbol("getParserConfiguration"),O8=Symbol("getUsageConfiguration"),rF=Symbol("guessLocale"),V8=Symbol("guessVersion"),H8=Symbol("parsePositionalNumbers"),aF=Symbol("pkgUp"),nD=Symbol("populateParserHintArray"),ju=Symbol("populateParserHintSingleValueDictionary"),eF=Symbol("populateParserHintArrayDictionary"),D0=Symbol("populateParserHintDictionary"),u0=Symbol("sanitizeKey"),F0=Symbol("setKey"),E0=Symbol("unfreeze"),q8=Symbol("validateAsync"),K8=Symbol("getCommandInstance"),U8=Symbol("getContext"),_8=Symbol("getHasOutput"),j8=Symbol("getLoggerInstance"),M8=Symbol("getParseContext"),A8=Symbol("getUsageInstance"),L8=Symbol("getValidationInstance"),zF=Symbol("hasParseCallback"),N8=Symbol("isGlobalContext"),Ju=Symbol("postProcess"),T8=Symbol("rebase"),C0=Symbol("reset"),bu=Symbol("runYargsParserAndExecuteCommands"),B0=Symbol("runValidation"),R8=Symbol("setHasOutput"),Xu=Symbol("kTrackManuallySetKeys"),M6="en_US";class P8{constructor(D=[],u,F,E){this.customScriptName=!1,this.parsed=!1,CD.set(this,void 0),uu.set(this,void 0),Iu.set(this,{commands:[],fullCommands:[]}),VD.set(this,null),KD.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,{}),UD.set(this,!1),ND.set(this,null),EF.set(this,!0),Eu.set(this,void 0),XD.set(this,""),f.set(this,void 0),CF.set(this,void 0),BF.set(this,{}),_D.set(this,null),Cu.set(this,null),_u.set(this,{}),Bu.set(this,{}),iD.set(this,void 0),$F.set(this,!1),m.set(this,void 0),$u.set(this,!1),Gu.set(this,!1),zu.set(this,!1),g.set(this,void 0),GF.set(this,{}),ID.set(this,null),DD.set(this,void 0),P(this,m,E,"f"),P(this,iD,D,"f"),P(this,uu,u,"f"),P(this,CF,F,"f"),P(this,LD,new lF(this),"f"),this.$0=this[W8](),this[C0](),P(this,CD,X(this,CD,"f"),"f"),P(this,g,X(this,g,"f"),"f"),P(this,DD,X(this,DD,"f"),"f"),P(this,f,X(this,f,"f"),"f"),X(this,f,"f").showHiddenOpt=X(this,DF,"f"),P(this,Eu,this[X8](),"f"),X(this,m,"f").y18n.setLocale(M6)}addHelpOpt(D,u){if(S("[string|boolean] [string]",[D,u],arguments.length),X(this,ND,"f"))this[sF](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,g,"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,g,"f").deferY18nLookup("Show hidden options")),X(this,f,"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[eF](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,g,"f").fail(X(this,m,"f").y18n.__("Argument check failed: %s",D.toString()));else if(typeof C==="string"||C instanceof Error)X(this,g,"f").fail(C.toString(),C);return F},(C)=>{return X(this,g,"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[eF](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 ED("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 ED("coerce callback must be provided");let F=D;return X(this,f,"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 ED(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,m,"f")),X(this,f,"f").configObjects=(X(this,f,"f").configObjects||[]).concat(D),this;if(typeof u==="function")F=u,u=void 0;return this.describe(D,u||X(this,g,"f").deferY18nLookup("Path to JSON config file")),(Array.isArray(D)?D:[D]).forEach((E)=>{X(this,f,"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,KD,D||X(this,KD,"f")||"completion","f"),!u&&u!==!1)u="generate completion script";if(this.command(X(this,KD,"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,CD,"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,m,"f").require;return X(this,CD,"f").addDirectory(D,F,X(this,m,"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)nF(D,X(this,m,"f")),X(this,f,"f").defaultDescription[D]=F;if(typeof u==="function"){if(nF(D,X(this,m,"f")),!X(this,f,"f").defaultDescription[D])X(this,f,"f").defaultDescription[D]=X(this,g,"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,f,"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,m,"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,m,"f")),this.demandCommand(D,u,F,F);else if(Array.isArray(D))D.forEach((E)=>{WD(F,!0,X(this,m,"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,f,"f").deprecatedOptions[D]=u,this}describe(D,u){return S("<object|string|array> [string]",[D,u],arguments.length),this[F0](D,!0),X(this,g,"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,f,"f").envPrefix;else X(this,f,"f").envPrefix=D||"";return this}epilogue(D){return S("<string>",[D],arguments.length),X(this,g,"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,g,"f").example(D,u);return this}exit(D,u){if(P(this,UD,!0,"f"),P(this,dD,u,"f"),X(this,AD,"f"))X(this,m,"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 ED("Invalid first argument. Expected function or boolean 'false'");return X(this,g,"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,f,"f").demandedOptions}getDemandedCommands(){return S([],0),X(this,f,"f").demandedCommands}getDeprecatedOptions(){return S([],0),X(this,f,"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,UD,!0,"f"),!X(this,g,"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,g,"f").help()})}let D=X(this,CD,"f").runDefaultBuilderOn(this);if(a(D))return D.then(()=>{return X(this,g,"f").help()})}return Promise.resolve(X(this,g,"f").help())}getOptions(){return X(this,f,"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,f,"f").local=X(this,f,"f").local.filter((F)=>D.indexOf(F)===-1);else D.forEach((F)=>{if(!X(this,f,"f").local.includes(F))X(this,f,"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,f,"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[rF](),X(this,m,"f").y18n.getLocale();return P(this,Fu,!1,"f"),X(this,m,"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[Q8](['"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,f,"f").key[D]=!0,u.alias)this.alias(D,u.alias);let F=u.deprecate||u.deprecated;if(F)this.deprecateOption(D,F);let 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,f,"f").defaultDescription[D]=u.defaultDescription;if(u.skipValidation)this.skipValidation(D);let C=u.describe||u.description||u.desc,B=X(this,g,"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[Y8](),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,_D,u,"f"),u=!1;if(!u)P(this,iD,D,"f");if(X(this,_D,"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,_D,"f"))X(this,_D,"f").call(this,X(this,dD,"f"),B,X(this,XD,"f"));return B}).catch((B)=>{if(X(this,_D,"f"))X(this,_D,"f")(B,this.parsed.argv,X(this,XD,"f"));throw B}).finally(()=>{this[E0](),this.parsed=C});else{if(X(this,_D,"f"))X(this,_D,"f").call(this,X(this,dD,"f"),E,X(this,XD,"f"));this[E0](),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 ED(".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[aF](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,m,"f")),X(this,f,"f").configObjects=(X(this,f,"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,CD,"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,g,"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,f,"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,KD,"f")||"completion")),this}showHelp(D){if(S("[string|function]",[D],arguments.length),P(this,UD,!0,"f"),!X(this,g,"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,g,"f").showHelp(D)}),this}let u=X(this,CD,"f").runDefaultBuilderOn(this);if(a(u))return u.then(()=>{X(this,g,"f").showHelp(D)}),this}return X(this,g,"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,g,"f").showHelpOnFail(D,u),this}showVersion(D){return S("[string|function]",[D],arguments.length),X(this,g,"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,m,"f").process.stdColumns}updateLocale(D){return this.updateStrings(D)}updateStrings(D){return S("<object>",[D],arguments.length),P(this,Fu,!1,"f"),X(this,m,"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,m,"f")),(D||"").match(/^\$0( |$)/))return this.command(D,u,F,E);else throw new ED(".usage() description must start with $0 if being used as alias for .command()");else return X(this,g,"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[sF](X(this,ID,"f")),X(this,g,"f").version(void 0),P(this,ID,null,"f");if(arguments.length===0)F=this[V8](),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,g,"f").deferY18nLookup("Show version number"),X(this,g,"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,g,"f").wrap(D),this}[(CD=new WeakMap,uu=new WeakMap,Iu=new WeakMap,VD=new WeakMap,KD=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,UD=new WeakMap,ND=new WeakMap,EF=new WeakMap,Eu=new WeakMap,XD=new WeakMap,f=new WeakMap,CF=new WeakMap,BF=new WeakMap,_D=new WeakMap,Cu=new WeakMap,_u=new WeakMap,Bu=new WeakMap,iD=new WeakMap,$F=new WeakMap,m=new WeakMap,$u=new WeakMap,Gu=new WeakMap,zu=new WeakMap,g=new WeakMap,GF=new WeakMap,ID=new WeakMap,DD=new WeakMap,J8)](D){if(!D._||!D["--"])return D;D._.push.apply(D._,D["--"]);try{delete D["--"]}catch(u){}return D}[X8](){return{log:(...D)=>{if(!this[zF]())console.log(...D);if(P(this,UD,!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,UD,!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")}}}[sF](D){Ku(X(this,f,"f")).forEach((u)=>{if(((E)=>E==="configObjects")(u))return;let F=X(this,f,"f")[u];if(Array.isArray(F)){if(F.includes(D))F.splice(F.indexOf(D),1)}else if(typeof F==="object")delete F[D]}),delete X(this,g,"f").getDescriptions()[D]}[Q8](D,u,F){if(!X(this,uF,"f")[F])X(this,m,"f").process.emitWarning(D,u),X(this,uF,"f")[F]=!0}[Y8](){X(this,FF,"f").push({options:X(this,f,"f"),configObjects:X(this,f,"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,KD,"f"),output:X(this,XD,"f"),exitError:X(this,dD,"f"),hasOutput:X(this,UD,"f"),parsed:this.parsed,parseFn:X(this,_D,"f"),parseContext:X(this,Cu,"f")}),X(this,g,"f").freeze(),X(this,DD,"f").freeze(),X(this,CD,"f").freeze(),X(this,LD,"f").freeze()}[W8](){let D="",u;if(/\b(node|iojs|electron)(\.exe)?$/.test(X(this,m,"f").process.argv()[0]))u=X(this,m,"f").process.argv().slice(1,2);else u=X(this,m,"f").process.argv().slice(0,1);if(D=u.map((F)=>{let E=this[T8](X(this,uu,"f"),F);return F.match(/^(\/|([a-zA-Z]:)?\\)/)&&E.length<F.length?E:F}).join(" ").trim(),X(this,m,"f").getEnv("_")&&X(this,m,"f").getProcessArgvBin()===X(this,m,"f").getEnv("_"))D=X(this,m,"f").getEnv("_").replace(`${X(this,m,"f").path.dirname(X(this,m,"f").process.execPath())}/`,"");return D}[Zu](){return X(this,BF,"f")}[O8](){return X(this,GF,"f")}[rF](){if(!X(this,Fu,"f"))return;let D=X(this,m,"f").getEnv("LC_ALL")||X(this,m,"f").getEnv("LC_MESSAGES")||X(this,m,"f").getEnv("LANG")||X(this,m,"f").getEnv("LANGUAGE")||"en_US";this.locale(D.replace(/[.:].*/,""))}[V8](){return this[aF]().version||"unknown"}[H8](D){let u=D["--"]?D["--"]:D._;for(let F=0,E;(E=u[F])!==void 0;F++)if(X(this,m,"f").Parser.looksLikeNumber(E)&&Number.isSafeInteger(Math.floor(parseFloat(`${E}`))))u[F]=Number(E);return D}[aF](D){let u=D||"*";if(X(this,_u,"f")[u])return X(this,_u,"f")[u];let F={};try{let E=D||X(this,m,"f").mainFilename;if(X(this,m,"f").path.extname(E))E=X(this,m,"f").path.dirname(E);let C=X(this,m,"f").findUp(E,(B,$)=>{if($.includes("package.json"))return"package.json";else return});WD(C,void 0,X(this,m,"f")),F=JSON.parse(X(this,m,"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[u0](F),X(this,f,"f")[D].push(F)})}[ju](D,u,F,E){this[D0](D,u,F,E,(C,B,$)=>{X(this,f,"f")[C][B]=$})}[eF](D,u,F,E){this[D0](D,u,F,E,(C,B,$)=>{X(this,f,"f")[C][B]=(X(this,f,"f")[C][B]||[]).concat($)})}[D0](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[u0](F),E)}[u0](D){if(D==="__proto__")return"___proto___";return D}[F0](D,u){return this[ju](this[F0].bind(this),"key",D,u),this}[E0](){var D,u,F,E,C,B,$,G,z,Z,Y,J;let Q=X(this,FF,"f").pop();WD(Q,void 0,X(this,m,"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){P(D,f,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,UD,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,KD,V,"f")}}.value,parseFn:{set value(V){P(Y,_D,V,"f")}}.value,parseContext:{set value(V){P(J,Cu,V,"f")}}.value}=Q,X(this,f,"f").configObjects=O,X(this,g,"f").unfreeze(),X(this,DD,"f").unfreeze(),X(this,CD,"f").unfreeze(),X(this,LD,"f").unfreeze()}[q8](D,u){return Du(u,(F)=>{return D(F),F})}getInternalMethods(){return{getCommandInstance:this[K8].bind(this),getContext:this[U8].bind(this),getHasOutput:this[_8].bind(this),getLoggerInstance:this[j8].bind(this),getParseContext:this[M8].bind(this),getParserConfiguration:this[Zu].bind(this),getUsageConfiguration:this[O8].bind(this),getUsageInstance:this[A8].bind(this),getValidationInstance:this[L8].bind(this),hasParseCallback:this[zF].bind(this),isGlobalContext:this[N8].bind(this),postProcess:this[Ju].bind(this),reset:this[C0].bind(this),runValidation:this[B0].bind(this),runYargsParserAndExecuteCommands:this[bu].bind(this),setHasOutput:this[R8].bind(this)}}[K8](){return X(this,CD,"f")}[U8](){return X(this,Iu,"f")}[_8](){return X(this,UD,"f")}[j8](){return X(this,Eu,"f")}[M8](){return X(this,Cu,"f")||{}}[A8](){return X(this,g,"f")}[L8](){return X(this,DD,"f")}[zF](){return!!X(this,_D,"f")}[N8](){return X(this,EF,"f")}[Ju](D,u,F,E){if(F)return D;if(a(D))return D;if(!u)D=this[J8](D);if(this[Zu]()["parse-positional-numbers"]||this[Zu]()["parse-positional-numbers"]===void 0)D=this[H8](D);if(E)D=eD(D,this,X(this,LD,"f").getMiddleware(),!1);return D}[C0](D={}){P(this,f,X(this,f,"f")||{},"f");let u={};u.local=X(this,f,"f").local||[],u.configObjects=X(this,f,"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,f,"f")[B]||[]).filter(($)=>!F[$])}),C.forEach((B)=>{u[B]=gD(X(this,f,"f")[B],($)=>!F[$])}),u.envPrefix=X(this,f,"f").envPrefix,P(this,f,u,"f"),P(this,g,X(this,g,"f")?X(this,g,"f").reset(F):u8(this,X(this,m,"f")),"f"),P(this,DD,X(this,DD,"f")?X(this,DD,"f").reset(F):z8(this,X(this,g,"f"),X(this,m,"f")),"f"),P(this,CD,X(this,CD,"f")?X(this,CD,"f").reset():a2(X(this,g,"f"),X(this,DD,"f"),X(this,LD,"f"),X(this,m,"f")),"f"),!X(this,VD,"f"))P(this,VD,B8(this,X(this,g,"f"),X(this,CD,"f"),X(this,m,"f")),"f");return X(this,LD,"f").reset(),P(this,KD,null,"f"),P(this,XD,"","f"),P(this,dD,null,"f"),P(this,UD,!1,"f"),this.parsed=!1,this}[T8](D,u){return X(this,m,"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,f,"f").__=X(this,m,"f").y18n.__,X(this,f,"f").configuration=this[Zu]();let Y=!!X(this,f,"f").configuration["populate--"],J=Object.assign({},X(this,f,"f").configuration,{"populate--":!0}),Q=X(this,m,"f").Parser.detailed(D,Object.assign({},X(this,f,"f"),{configuration:{"parse-positional-numbers":!1,...J}})),O=Object.assign(Q.argv,X(this,Cu,"f")),V=void 0,W=Q.aliases,K=!1,A=!1;if(Object.keys(O).forEach((_)=>{if(_===X(this,ND,"f")&&O[_])K=!0;else if(_===X(this,ID,"f")&&O[_])A=!0}),O.$0=this.$0,this.parsed=Q,E===0)X(this,g,"f").clearCachedHelpMessage();try{if(this[rF](),u)return this[Ju](O,Y,!!F,!1);if(X(this,ND,"f")){if([X(this,ND,"f")].concat(W[X(this,ND,"f")]||[]).filter((k)=>k.length>1).includes(""+O._[O._.length-1]))O._.pop(),K=!0}P(this,EF,!1,"f");let _=X(this,CD,"f").getCommands(),L=((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((x)=>Object.prototype.hasOwnProperty.call(O,x)):!1,M=K||L||C;if(O._.length){if(_.length){let x;for(let k=E||0,s;O._[k]!==void 0;k++)if(s=String(O._[k]),_.includes(s)&&s!==X(this,KD,"f")){let jD=X(this,CD,"f").runCommand(s,this,Q,k+1,C,K||A||C);return this[Ju](jD,Y,!!F,!1)}else if(!x&&s!==X(this,KD,"f")){x=s;break}if(!X(this,CD,"f").hasDefaultCommand()&&X(this,$F,"f")&&x&&!M)X(this,DD,"f").recommendCommands(x,_)}if(X(this,KD,"f")&&O._.includes(X(this,KD,"f"))&&!L){if(X(this,AD,"f"))kD(!0);this.showCompletionScript(),this.exit(0)}}if(X(this,CD,"f").hasDefaultCommand()&&!M){let x=X(this,CD,"f").runCommand(null,this,Q,0,C,K||A||C);return this[Ju](x,Y,!!F,!1)}if(L){if(X(this,AD,"f"))kD(!0);D=[].concat(D);let x=D.slice(D.indexOf(`--${X(this,VD,"f").completionKey}`)+1);return X(this,VD,"f").getCompletion(x,(k,s)=>{if(k)throw new ED(k.message);(s||[]).forEach((jD)=>{X(this,Eu,"f").log(jD)}),this.exit(0)}),this[Ju](O,!Y,!!F,!1)}if(!X(this,UD,"f")){if(K){if(X(this,AD,"f"))kD(!0);Z=!0,this.showHelp((x)=>{X(this,Eu,"f").log(x),this.exit(0)})}else if(A){if(X(this,AD,"f"))kD(!0);Z=!0,X(this,g,"f").showVersion("log"),this.exit(0)}}if(!Z&&X(this,f,"f").skipValidation.length>0)Z=Object.keys(O).some((x)=>X(this,f,"f").skipValidation.indexOf(x)>=0&&O[x]===!0);if(!Z){if(Q.error)throw new ED(Q.error.message);if(!L){let x=this[B0](W,{},Q.error);if(!F)V=eD(O,this,X(this,LD,"f").getMiddleware(),!0);if(V=this[q8](x,V!==null&&V!==void 0?V:O),a(V)&&!F)V=V.then(()=>{return eD(O,this,X(this,LD,"f").getMiddleware(),!1)})}}}catch(_){if(_ instanceof ED)X(this,g,"f").fail(_.message,_);else throw _}return this[Ju](V!==null&&V!==void 0?V:O,Y,!!F,!0)}[B0](D,u,F,E){let C={...this.getDemandedOptions()};return(B)=>{if(F)throw new ED(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)}}[R8](){P(this,UD,!0,"f")}[Xu](D){if(typeof D==="string")X(this,f,"f").key[D]=!0;else for(let u of D)X(this,f,"f").key[u]=!0}}function e2(D){return!!D&&typeof D.getInternalMethods==="function"}var A6=S8(iF),w8=A6;import{existsSync as ZF,readFileSync as z0,writeFileSync as $0,mkdirSync as b8}from"node:fs";import{homedir as L6}from"node:os";import{join as Qu,dirname as Z0}from"node:path";function J0(){return process.env.HOME||L6()}function f8(){return Qu(J0(),".config","slack-cli","profiles.json")}function JF(){return Qu(process.cwd(),".slack-cli","workspace")}function XF(){return Qu(J0(),".slack-cli","workspace")}function fu(){let D=f8();if(!ZF(D))return{profiles:{}};return JSON.parse(z0(D,"utf8"))}function N6(D){let u=f8();b8(Z0(u),{recursive:!0}),$0(u,JSON.stringify(D,null,2)+`
82
- `)}function Mu(D){if(!ZF(D))return;return z0(D,"utf8").trim()||void 0}function x8(D,u){let F=Z0(D);b8(F,{recursive:!0});let E=Qu(F,".gitignore");if(!ZF(E))$0(E,`*
83
- `);$0(D,u+`
84
- `)}function T6(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 I8(D){if(!ZF(D))return{};try{return T6(z0(D,"utf8"))}catch{return{}}}function G0(D,u){let F=J0(),E=D;while(!0){for(let $ of[Qu(E,".slack-term",".env.local"),Qu(E,".env.local")]){let G=I8($);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=I8(Qu(F,".slack-term",".env.local"));for(let B of u)if(C[B])return C[B];return}function X0(){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 h8(D){let u=fu();if(!(D in u.profiles))throw Error(`Profile not found: ${D}`);delete u.profiles[D],N6(u)}function v8(D,u=!1){let F=fu();if(!(D in F.profiles))throw Error(`Profile not found: ${D}`);if(u)x8(XF(),D);else x8(JF(),D)}function Q0(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=G0(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=G0(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).
74
+ `;class A8{constructor(D,u,F,E){var B,C,$;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=($=((B=this.shim.getEnv("SHELL"))===null||B===void 0?void 0:B.includes("zsh"))||((C=this.shim.getEnv("ZSH_NAME"))===null||C===void 0?void 0:C.includes("zsh")))!==null&&$!==void 0?$:!1}defaultCompletion(D,u,F,E){let B=this.command.getCommandHandlers();for(let $=0,z=D.length;$<z;++$)if(B[D[$]]&&B[D[$]].builder){let Z=B[D[$]].builder;if(ZF(Z)){this.indexAfterLastReset=$+1;let J=this.yargs.getInternalMethods().reset();return Z(J,!0),J.argv}}let C=[];this.commandCompletions(C,D,F),this.optionCompletions(C,D,u,F),this.choicesFromOptionsCompletions(C,D,u,F),this.choicesFromPositionalsCompletions(C,D,u,F),E(null,C)}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((B)=>{let C=iD(B[0]).cmd;if(u.indexOf(C)===-1)if(!this.zshShell)D.push(C);else{let $=B[1]||"";D.push(C.replace(/:/g,"\\:")+":"+$)}})}optionCompletions(D,u,F,E){if((E.match(/^-/)||E===""&&D.length===0)&&!this.previousArgHasChoices(u)){let B=this.yargs.getOptions(),C=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[];Object.keys(B.key).forEach(($)=>{let z=!!B.configuration["boolean-negation"]&&B.boolean.includes($);if(!C.includes($)&&!B.hiddenOptions.includes($)&&!this.argsContainKey(u,$,z))this.completeOptionKey($,D,E,z&&!!B.default[$])})}}choicesFromOptionsCompletions(D,u,F,E){if(this.previousArgHasChoices(u)){let B=this.getPreviousArgChoices(u);if(B&&B.length>0)D.push(...B.map((C)=>C.replace(/:/g,"\\:")))}}choicesFromPositionalsCompletions(D,u,F,E){if(E===""&&D.length>0&&this.previousArgHasChoices(u))return;let B=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[],C=Math.max(this.indexAfterLastReset,this.yargs.getInternalMethods().getContext().commands.length+1),$=B[F._.length-C-1];if(!$)return;let z=this.yargs.getOptions().choices[$]||[];for(let Z of z)if(Z.startsWith(E))D.push(Z.replace(/:/g,"\\:"))}getPreviousArgChoices(D){if(D.length<1)return;let u=D[D.length-1],F="";if(!u.startsWith("-")&&D.length>1)F=u,u=D[D.length-2];if(!u.startsWith("-"))return;let E=u.replace(/^-+/,""),B=this.yargs.getOptions(),C=[E,...this.yargs.getAliases()[E]||[]],$;for(let z of C)if(Object.prototype.hasOwnProperty.call(B.key,z)&&Array.isArray(B.choices[z])){$=B.choices[z];break}if($)return $.filter((z)=>!F||z.startsWith(F))}previousArgHasChoices(D){let u=this.getPreviousArgChoices(D);return u!==void 0&&u.length>0}argsContainKey(D,u,F){let E=(B)=>D.indexOf((/^[^0-9]$/.test(B)?"-":"--")+B)!==-1;if(E(u))return!0;if(F&&E(`no-${u}`))return!0;if(this.aliases){for(let B of this.aliases[u])if(E(B))return!0}return!1}completeOptionKey(D,u,F,E){var B,C,$,z;let Z=D;if(this.zshShell){let Y=this.usage.getDescriptions(),V=(C=(B=this===null||this===void 0?void 0:this.aliases)===null||B===void 0?void 0:B[D])===null||C===void 0?void 0:C.find((K)=>{let N=Y[K];return typeof N==="string"&&N.length>0}),H=V?Y[V]:void 0,W=(z=($=Y[D])!==null&&$!==void 0?$:H)!==null&&z!==void 0?z:"";Z=`${D.replace(/:/g,"\\:")}:${W.replace("__yargsString__:","").replace(/(\r\n|\n|\r)/gm," ")}`}let J=(Y)=>/^--/.test(Y),X=(Y)=>/^[^0-9]$/.test(Y),G=!J(F)&&X(D)?"-":"--";if(u.push(G+Z),E)u.push(G+"no-"+Z)}customCompletion(D,u,F,E){if(qD(this.customCompletionFunction,null,this.shim),F7(this.customCompletionFunction)){let B=this.customCompletionFunction(F,u);if(a(B))return B.then((C)=>{this.shim.process.nextTick(()=>{E(null,C)})}).catch((C)=>{this.shim.process.nextTick(()=>{E(C,void 0)})});return E(null,B)}else if(E7(this.customCompletionFunction))return this.customCompletionFunction(F,u,(B=E)=>this.defaultCompletion(D,u,F,B),(B)=>{E(null,B)});else return this.customCompletionFunction(F,u,(B)=>{E(null,B)})}getCompletion(D,u){let F=D.length?D[D.length-1]:"",E=this.yargs.parse(D,!0),B=this.customCompletionFunction?(C)=>this.customCompletion(D,C,F,u):(C)=>this.defaultCompletion(D,C,F,u);return a(E)?E.then(B):B(E)}generateCompletionScript(D,u){let F=this.zshShell?N8:_8,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 L8(D,u,F,E){return new A8(D,u,F,E)}function F7(D){return D.length<3}function E7(D){return D.length>3}function T8(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 B;for(B=0;B<=D.length;B++)F[0][B]=B;for(E=1;E<=u.length;E++)for(B=1;B<=D.length;B++)if(u.charAt(E-1)===D.charAt(B-1))F[E][B]=F[E-1][B-1];else if(E>1&&B>1&&u.charAt(E-2)===D.charAt(B-1)&&u.charAt(E-1)===D.charAt(B-2))F[E][B]=F[E-2][B-2]+1;else F[E][B]=Math.min(F[E-1][B-1]+1,Math.min(F[E][B-1]+1,F[E-1][B]+1));return F[u.length][D.length]}var R8=["$0","--","_"];function P8(D,u,F){let E=F.y18n.__,B=F.y18n.__n,C={};C.nonOptionCount=function(G){let Y=D.getDemandedCommands(),H=G._.length+(G["--"]?G["--"].length:0)-D.getInternalMethods().getContext().commands.length;if(Y._&&(H<Y._.min||H>Y._.max)){if(H<Y._.min)if(Y._.minMsg!==void 0)u.fail(Y._.minMsg?Y._.minMsg.replace(/\$0/g,H.toString()).replace(/\$1/,Y._.min.toString()):null);else u.fail(B("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",H,H.toString(),Y._.min.toString()));else if(H>Y._.max)if(Y._.maxMsg!==void 0)u.fail(Y._.maxMsg?Y._.maxMsg.replace(/\$0/g,H.toString()).replace(/\$1/,Y._.max.toString()):null);else u.fail(B("Too many non-option arguments: got %s, maximum of %s","Too many non-option arguments: got %s, maximum of %s",H,H.toString(),Y._.max.toString()))}},C.positionalCount=function(G,Y){if(Y<G)u.fail(B("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",Y,Y+"",G+""))},C.requiredArguments=function(G,Y){let V=null;for(let H of Object.keys(Y))if(!Object.prototype.hasOwnProperty.call(G,H)||typeof G[H]>"u")V=V||{},V[H]=Y[H];if(V){let H=[];for(let K of Object.keys(V)){let N=V[K];if(N&&H.indexOf(N)<0)H.push(N)}let W=H.length?`
75
+ ${H.join(`
76
+ `)}`:"";u.fail(B("Missing required argument: %s","Missing required arguments: %s",Object.keys(V).length,Object.keys(V).join(", ")+W))}},C.unknownArguments=function(G,Y,V,H,W=!0){var K;let N=D.getInternalMethods().getCommandInstance().getCommands(),M=[],L=D.getInternalMethods().getContext();if(Object.keys(G).forEach((j)=>{if(!R8.includes(j)&&!Object.prototype.hasOwnProperty.call(V,j)&&!Object.prototype.hasOwnProperty.call(D.getInternalMethods().getParseContext(),j)&&!C.isValidAndSomeAliasIsNotNew(j,Y))M.push(j)}),W&&(L.commands.length>0||N.length>0||H))G._.slice(L.commands.length).forEach((j)=>{if(!N.includes(""+j))M.push(""+j)});if(W){let T=((K=D.getDemandedCommands()._)===null||K===void 0?void 0:K.max)||0,y=L.commands.length+T;if(y<G._.length)G._.slice(y).forEach((k)=>{if(k=String(k),!L.commands.includes(k)&&!M.includes(k))M.push(k)})}if(M.length)u.fail(B("Unknown argument: %s","Unknown arguments: %s",M.length,M.map((j)=>j.trim()?j:`"${j}"`).join(", ")))},C.unknownCommands=function(G){let Y=D.getInternalMethods().getCommandInstance().getCommands(),V=[],H=D.getInternalMethods().getContext();if(H.commands.length>0||Y.length>0)G._.slice(H.commands.length).forEach((W)=>{if(!Y.includes(""+W))V.push(""+W)});if(V.length>0)return u.fail(B("Unknown command: %s","Unknown commands: %s",V.length,V.join(", "))),!0;else return!1},C.isValidAndSomeAliasIsNotNew=function(G,Y){if(!Object.prototype.hasOwnProperty.call(Y,G))return!1;let V=D.parsed.newAliases;return[G,...Y[G]].some((H)=>!Object.prototype.hasOwnProperty.call(V,H)||!V[G])},C.limitedChoices=function(G){let Y=D.getOptions(),V={};if(!Object.keys(Y.choices).length)return;Object.keys(G).forEach((K)=>{if(R8.indexOf(K)===-1&&Object.prototype.hasOwnProperty.call(Y.choices,K))[].concat(G[K]).forEach((N)=>{if(Y.choices[K].indexOf(N)===-1&&N!==void 0)V[K]=(V[K]||[]).concat(N)})});let H=Object.keys(V);if(!H.length)return;let W=E("Invalid values:");H.forEach((K)=>{W+=`
77
+ ${E("Argument: %s, Given: %s, Choices: %s",K,u.stringifiedValues(V[K]),u.stringifiedValues(Y.choices[K]))}`}),u.fail(W)};let $={};C.implies=function(G,Y){if(S("<string|object> [array|number|string]",[G,Y],arguments.length),typeof G==="object")Object.keys(G).forEach((V)=>{C.implies(V,G[V])});else{if(D.global(G),!$[G])$[G]=[];if(Array.isArray(Y))Y.forEach((V)=>C.implies(G,V));else qD(Y,void 0,F),$[G].push(Y)}},C.getImplied=function(){return $};function z(X,G){let Y=Number(G);if(G=isNaN(Y)?G:Y,typeof G==="number")G=X._.length>=G;else if(G.match(/^--no-.+/))G=G.match(/^--no-(.+)/)[1],G=!Object.prototype.hasOwnProperty.call(X,G);else G=Object.prototype.hasOwnProperty.call(X,G);return G}C.implications=function(G){let Y=[];if(Object.keys($).forEach((V)=>{let H=V;($[V]||[]).forEach((W)=>{let K=H,N=W;if(K=z(G,K),W=z(G,W),K&&!W)Y.push(` ${H} -> ${N}`)})}),Y.length){let V=`${E("Implications failed:")}
78
+ `;Y.forEach((H)=>{V+=H}),u.fail(V)}};let Z={};C.conflicts=function(G,Y){if(S("<string|object> [array|string]",[G,Y],arguments.length),typeof G==="object")Object.keys(G).forEach((V)=>{C.conflicts(V,G[V])});else{if(D.global(G),!Z[G])Z[G]=[];if(Array.isArray(Y))Y.forEach((V)=>C.conflicts(G,V));else Z[G].push(Y)}},C.getConflicting=()=>Z,C.conflicting=function(G){if(Object.keys(G).forEach((Y)=>{if(Z[Y])Z[Y].forEach((V)=>{if(V&&G[Y]!==void 0&&G[V]!==void 0)u.fail(E("Arguments %s and %s are mutually exclusive",Y,V))})}),D.getInternalMethods().getParserConfiguration()["strip-dashed"])Object.keys(Z).forEach((Y)=>{Z[Y].forEach((V)=>{if(V&&G[F.Parser.camelCase(Y)]!==void 0&&G[F.Parser.camelCase(V)]!==void 0)u.fail(E("Arguments %s and %s are mutually exclusive",Y,V))})})},C.recommendCommands=function(G,Y){Y=Y.sort((K,N)=>N.length-K.length);let H=null,W=1/0;for(let K=0,N;(N=Y[K])!==void 0;K++){let M=T8(G,N);if(M<=3&&M<W)W=M,H=N}if(H)u.fail(E("Did you mean %s?",H))},C.reset=function(G){return $=lD($,(Y)=>!G[Y]),Z=lD(Z,(Y)=>!G[Y]),C};let J=[];return C.freeze=function(){J.push({implied:$,conflicting:Z})},C.unfreeze=function(){let G=J.pop();qD(G,void 0,F),{implied:$,conflicting:Z}=G},C}var G0=[],hu;function vu(D,u,F,E){hu=E;let B={};if(Object.prototype.hasOwnProperty.call(D,"extends")){if(typeof D.extends!=="string")return B;let C=/\.json|\..*rc$/.test(D.extends),$=null;if(!C)try{$=import.meta.resolve(D.extends)}catch(z){return D}else $=C7(u,D.extends);B7($),G0.push($),B=C?JSON.parse(hu.readFileSync($,"utf8")):E.require(D.extends),delete D.extends,B=vu(B,hu.path.dirname($),F,hu)}return G0=[],F?S8(B,D):Object.assign({},B,D)}function B7(D){if(G0.indexOf(D)>-1)throw new ED(`Circular extended configurations: '${D}'.`)}function C7(D,u){return hu.path.resolve(D,u)}function S8(D,u){let F={};function E(B){return B&&typeof B==="object"&&!Array.isArray(B)}Object.assign(F,D);for(let B of Object.keys(u))if(E(u[B])&&E(F[B]))F[B]=S8(D[B],u[B]);else F[B]=u[B];return F}var w=function(D,u,F,E,B){if(E==="m")throw TypeError("Private method is not writable");if(E==="a"&&!B)throw TypeError("Private accessor was defined without a setter");if(typeof u==="function"?D!==u||!B:!u.has(D))throw TypeError("Cannot write private member to an object whose class did not declare it");return E==="a"?B.call(D,F):B?B.value=F:u.set(D,F),F},Q=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)},BD,Cu,yu,KD,UD,GF,tD,$u,XF,AD,QF,LD,ID,jD,TD,YF,zu,XD,f,WF,VF,MD,Zu,Tu,Ju,oD,HF,g,Gu,Xu,Qu,d,qF,bD,DD;function s8(D){return(u=[],F=D.process.cwd(),E)=>{let B=new r8(u,F,E,D);return Object.defineProperty(B,"argv",{get:()=>{return B.parse()},enumerable:!0}),B.help(),B.version(),B}}var w8=Symbol("copyDoubleDash"),x8=Symbol("copyDoubleDash"),X0=Symbol("deleteFromParserHintObject"),I8=Symbol("emitWarning"),b8=Symbol("freeze"),f8=Symbol("getDollarZero"),Yu=Symbol("getParserConfiguration"),h8=Symbol("getUsageConfiguration"),Q0=Symbol("guessLocale"),v8=Symbol("guessVersion"),y8=Symbol("parsePositionalNumbers"),Y0=Symbol("pkgUp"),sD=Symbol("populateParserHintArray"),Ru=Symbol("populateParserHintSingleValueDictionary"),W0=Symbol("populateParserHintArrayDictionary"),V0=Symbol("populateParserHintDictionary"),H0=Symbol("sanitizeKey"),q0=Symbol("setKey"),K0=Symbol("unfreeze"),p8=Symbol("validateAsync"),m8=Symbol("getCommandInstance"),g8=Symbol("getContext"),c8=Symbol("getHasOutput"),d8=Symbol("getLoggerInstance"),k8=Symbol("getParseContext"),i8=Symbol("getUsageInstance"),l8=Symbol("getValidationInstance"),KF=Symbol("hasParseCallback"),n8=Symbol("isGlobalContext"),Wu=Symbol("postProcess"),t8=Symbol("rebase"),O0=Symbol("reset"),pu=Symbol("runYargsParserAndExecuteCommands"),U0=Symbol("runValidation"),o8=Symbol("setHasOutput"),Vu=Symbol("kTrackManuallySetKeys"),$7="en_US";class r8{constructor(D=[],u,F,E){this.customScriptName=!1,this.parsed=!1,BD.set(this,void 0),Cu.set(this,void 0),yu.set(this,{commands:[],fullCommands:[]}),KD.set(this,null),UD.set(this,null),GF.set(this,"show-hidden"),tD.set(this,null),$u.set(this,!0),XF.set(this,{}),AD.set(this,!0),QF.set(this,[]),LD.set(this,void 0),ID.set(this,{}),jD.set(this,!1),TD.set(this,null),YF.set(this,!0),zu.set(this,void 0),XD.set(this,""),f.set(this,void 0),WF.set(this,void 0),VF.set(this,{}),MD.set(this,null),Zu.set(this,null),Tu.set(this,{}),Ju.set(this,{}),oD.set(this,void 0),HF.set(this,!1),g.set(this,void 0),Gu.set(this,!1),Xu.set(this,!1),Qu.set(this,!1),d.set(this,void 0),qF.set(this,{}),bD.set(this,null),DD.set(this,void 0),w(this,g,E,"f"),w(this,oD,D,"f"),w(this,Cu,u,"f"),w(this,WF,F,"f"),w(this,LD,new Z0(this),"f"),this.$0=this[f8](),this[O0](),w(this,BD,Q(this,BD,"f"),"f"),w(this,d,Q(this,d,"f"),"f"),w(this,DD,Q(this,DD,"f"),"f"),w(this,f,Q(this,f,"f"),"f"),Q(this,f,"f").showHiddenOpt=Q(this,GF,"f"),w(this,zu,this[x8](),"f"),Q(this,g,"f").y18n.setLocale($7)}addHelpOpt(D,u){if(S("[string|boolean] [string]",[D,u],arguments.length),Q(this,TD,"f"))this[X0](Q(this,TD,"f")),w(this,TD,null,"f");if(D===!1&&u===void 0)return this;return w(this,TD,typeof D==="string"?D:"help","f"),this.boolean(Q(this,TD,"f")),this.describe(Q(this,TD,"f"),u||Q(this,d,"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:Q(this,GF,"f");return this.boolean(F),this.describe(F,u||Q(this,d,"f").deferY18nLookup("Show hidden options")),Q(this,f,"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[W0](this.alias.bind(this),"alias",D,u),this}array(D){return S("<array|string>",[D],arguments.length),this[sD]("array",D),this[Vu](D),this}boolean(D){return S("<array|string>",[D],arguments.length),this[sD]("boolean",D),this[Vu](D),this}check(D,u){return S("<function> [boolean]",[D,u],arguments.length),this.middleware((F,E)=>{return Bu(()=>{return D(F,E.getOptions())},(B)=>{if(!B)Q(this,d,"f").fail(Q(this,g,"f").y18n.__("Argument check failed: %s",D.toString()));else if(typeof B==="string"||B instanceof Error)Q(this,d,"f").fail(B.toString(),B);return F},(B)=>{return Q(this,d,"f").fail(B.message?B.message:B.toString(),B),F})},!1,u),this}choices(D,u){return S("<object|string|array> [string|array]",[D,u],arguments.length),this[W0](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 ED("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 ED("coerce callback must be provided");let F=D;return Q(this,f,"f").key[F]=!0,Q(this,LD,"f").addCoerceMiddleware((E,B)=>{var C;let $=(C=B.getAliases()[F])!==null&&C!==void 0?C:[],z=[F,...$].filter((Z)=>Object.prototype.hasOwnProperty.call(E,Z));if(z.length===0)return E;return Bu(()=>{return u(E[z[0]])},(Z)=>{return z.forEach((J)=>{E[J]=Z}),E},(Z)=>{throw new ED(Z.message)})},F),this}conflicts(D,u){return S("<string|object> [string|array]",[D,u],arguments.length),Q(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=vu(D,Q(this,Cu,"f"),this[Yu]()["deep-merge-config"]||!1,Q(this,g,"f")),Q(this,f,"f").configObjects=(Q(this,f,"f").configObjects||[]).concat(D),this;if(typeof u==="function")F=u,u=void 0;return this.describe(D,u||Q(this,d,"f").deferY18nLookup("Path to JSON config file")),(Array.isArray(D)?D:[D]).forEach((E)=>{Q(this,f,"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(w(this,UD,D||Q(this,UD,"f")||"completion","f"),!u&&u!==!1)u="generate completion script";if(this.command(Q(this,UD,"f"),u),F)Q(this,KD,"f").registerFunction(F);return this}command(D,u,F,E,B,C){return S("<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]",[D,u,F,E,B,C],arguments.length),Q(this,BD,"f").addHandler(D,u,F,E,B,C),this}commands(D,u,F,E,B,C){return this.command(D,u,F,E,B,C)}commandDir(D,u){S("<string> [object]",[D,u],arguments.length);let F=Q(this,WF,"f")||Q(this,g,"f").require;return Q(this,BD,"f").addDirectory(D,F,Q(this,g,"f").getCallerFile(),u),this}count(D){return S("<array|string>",[D],arguments.length),this[sD]("count",D),this[Vu](D),this}default(D,u,F){if(S("<object|string|array> [*] [string]",[D,u,F],arguments.length),F)z0(D,Q(this,g,"f")),Q(this,f,"f").defaultDescription[D]=F;if(typeof u==="function"){if(z0(D,Q(this,g,"f")),!Q(this,f,"f").defaultDescription[D])Q(this,f,"f").defaultDescription[D]=Q(this,d,"f").functionDescription(u);u=u.call()}return this[Ru](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),Q(this,f,"f").demandedCommands._={min:D,max:u,minMsg:F,maxMsg:E},this}demand(D,u,F){if(Array.isArray(u))u.forEach((E)=>{qD(F,!0,Q(this,g,"f")),this.demandOption(E,F)}),u=1/0;else if(typeof u!=="number")F=u,u=1/0;if(typeof D==="number")qD(F,!0,Q(this,g,"f")),this.demandCommand(D,u,F,F);else if(Array.isArray(D))D.forEach((E)=>{qD(F,!0,Q(this,g,"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[Ru](this.demandOption.bind(this),"demandedOptions",D,u),this}deprecateOption(D,u){return S("<string> [string|boolean]",[D,u],arguments.length),Q(this,f,"f").deprecatedOptions[D]=u,this}describe(D,u){return S("<object|string|array> [string]",[D,u],arguments.length),this[q0](D,!0),Q(this,d,"f").describe(D,u),this}detectLocale(D){return S("<boolean>",[D],arguments.length),w(this,$u,D,"f"),this}env(D){if(S("[string|boolean]",[D],arguments.length),D===!1)delete Q(this,f,"f").envPrefix;else Q(this,f,"f").envPrefix=D||"";return this}epilogue(D){return S("<string>",[D],arguments.length),Q(this,d,"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 Q(this,d,"f").example(D,u);return this}exit(D,u){if(w(this,jD,!0,"f"),w(this,tD,u,"f"),Q(this,AD,"f"))Q(this,g,"f").process.exit(D)}exitProcess(D=!0){return S("[boolean]",[D],arguments.length),w(this,AD,D,"f"),this}fail(D){if(S("<function|boolean>",[D],arguments.length),typeof D==="boolean"&&D!==!1)throw new ED("Invalid first argument. Expected function or boolean 'false'");return Q(this,d,"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)=>{Q(this,KD,"f").getCompletion(D,(B,C)=>{if(B)E(B);else F(C)})});else return Q(this,KD,"f").getCompletion(D,u)}getDemandedOptions(){return S([],0),Q(this,f,"f").demandedOptions}getDemandedCommands(){return S([],0),Q(this,f,"f").demandedCommands}getDeprecatedOptions(){return S([],0),Q(this,f,"f").deprecatedOptions}getDetectLocale(){return Q(this,$u,"f")}getExitProcess(){return Q(this,AD,"f")}getGroups(){return Object.assign({},Q(this,ID,"f"),Q(this,Ju,"f"))}getHelp(){if(w(this,jD,!0,"f"),!Q(this,d,"f").hasCachedHelpMessage()){if(!this.parsed){let u=this[pu](Q(this,oD,"f"),void 0,void 0,0,!0);if(a(u))return u.then(()=>{return Q(this,d,"f").help()})}let D=Q(this,BD,"f").runDefaultBuilderOn(this);if(a(D))return D.then(()=>{return Q(this,d,"f").help()})}return Promise.resolve(Q(this,d,"f").help())}getOptions(){return Q(this,f,"f")}getStrict(){return Q(this,Gu,"f")}getStrictCommands(){return Q(this,Xu,"f")}getStrictOptions(){return Q(this,Qu,"f")}global(D,u){if(S("<string|array> [boolean]",[D,u],arguments.length),D=[].concat(D),u!==!1)Q(this,f,"f").local=Q(this,f,"f").local.filter((F)=>D.indexOf(F)===-1);else D.forEach((F)=>{if(!Q(this,f,"f").local.includes(F))Q(this,f,"f").local.push(F)});return this}group(D,u){S("<string|array> <string>",[D,u],arguments.length);let F=Q(this,Ju,"f")[u]||Q(this,ID,"f")[u];if(Q(this,Ju,"f")[u])delete Q(this,Ju,"f")[u];let E={};return Q(this,ID,"f")[u]=(F||[]).concat(D).filter((B)=>{if(E[B])return!1;return E[B]=!0}),this}hide(D){return S("<string>",[D],arguments.length),Q(this,f,"f").hiddenOptions.push(D),this}implies(D,u){return S("<string|object> [number|string|array]",[D,u],arguments.length),Q(this,DD,"f").implies(D,u),this}locale(D){if(S("[string]",[D],arguments.length),D===void 0)return this[Q0](),Q(this,g,"f").y18n.getLocale();return w(this,$u,!1,"f"),Q(this,g,"f").y18n.setLocale(D),this}middleware(D,u,F){return Q(this,LD,"f").addMiddleware(D,!!u,F)}nargs(D,u){return S("<string|object|array> [number]",[D,u],arguments.length),this[Ru](this.nargs.bind(this),"narg",D,u),this}normalize(D){return S("<array|string>",[D],arguments.length),this[sD]("normalize",D),this}number(D){return S("<array|string>",[D],arguments.length),this[sD]("number",D),this[Vu](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[Vu](D),Q(this,bD,"f")&&(D==="version"||(u===null||u===void 0?void 0:u.alias)==="version"))this[I8](['"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(Q(this,f,"f").key[D]=!0,u.alias)this.alias(D,u.alias);let F=u.deprecate||u.deprecated;if(F)this.deprecateOption(D,F);let 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)Q(this,f,"f").defaultDescription[D]=u.defaultDescription;if(u.skipValidation)this.skipValidation(D);let B=u.describe||u.description||u.desc,C=Q(this,d,"f").getDescriptions();if(!Object.prototype.hasOwnProperty.call(C,D)||typeof B==="string")this.describe(D,B);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[b8](),typeof D>"u")D=Q(this,oD,"f");if(typeof u==="object")w(this,Zu,u,"f"),u=F;if(typeof u==="function")w(this,MD,u,"f"),u=!1;if(!u)w(this,oD,D,"f");if(Q(this,MD,"f"))w(this,AD,!1,"f");let E=this[pu](D,!!u),B=this.parsed;if(Q(this,KD,"f").setParsed(this.parsed),a(E))return E.then((C)=>{if(Q(this,MD,"f"))Q(this,MD,"f").call(this,Q(this,tD,"f"),C,Q(this,XD,"f"));return C}).catch((C)=>{if(Q(this,MD,"f"))Q(this,MD,"f")(C,this.parsed.argv,Q(this,XD,"f"));throw C}).finally(()=>{this[K0](),this.parsed=B});else{if(Q(this,MD,"f"))Q(this,MD,"f").call(this,Q(this,tD,"f"),E,Q(this,XD,"f"));this[K0](),this.parsed=B}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 ED(".parseSync() must not be used with asynchronous builders, handlers, or middleware");return E}parserConfiguration(D){return S("<object>",[D],arguments.length),w(this,VF,D,"f"),this}pkgConf(D,u){S("<string> [string]",[D,u],arguments.length);let F=null,E=this[Y0](u||Q(this,Cu,"f"));if(E[D]&&typeof E[D]==="object")F=vu(E[D],u||Q(this,Cu,"f"),this[Yu]()["deep-merge-config"]||!1,Q(this,g,"f")),Q(this,f,"f").configObjects=(Q(this,f,"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=lD(u,(C,$)=>{if(C==="type"&&!["string","number","boolean"].includes($))return!1;return F.includes(C)});let E=Q(this,yu,"f").fullCommands[Q(this,yu,"f").fullCommands.length-1],B=E?Q(this,BD,"f").cmdToParseOptions(E):{array:[],alias:{},default:{},demand:{}};return Au(B).forEach((C)=>{let $=B[C];if(Array.isArray($)){if($.indexOf(D)!==-1)u[C]=!0}else if($[D]&&!(C in u))u[C]=$[D]}),this.group(D,Q(this,d,"f").getPositionalGroupName()),this.option(D,u)}recommendCommands(D=!0){return S("[boolean]",[D],arguments.length),w(this,HF,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"&&Q(this,f,"f").narg[D])return this;else this[Ru](this.requiresArg.bind(this),"narg",D,NaN);return this}showCompletionScript(D,u){return S("[string] [string]",[D,u],arguments.length),D=D||this.$0,Q(this,zu,"f").log(Q(this,KD,"f").generateCompletionScript(D,u||Q(this,UD,"f")||"completion")),this}showHelp(D){if(S("[string|function]",[D],arguments.length),w(this,jD,!0,"f"),!Q(this,d,"f").hasCachedHelpMessage()){if(!this.parsed){let F=this[pu](Q(this,oD,"f"),void 0,void 0,0,!0);if(a(F))return F.then(()=>{Q(this,d,"f").showHelp(D)}),this}let u=Q(this,BD,"f").runDefaultBuilderOn(this);if(a(u))return u.then(()=>{Q(this,d,"f").showHelp(D)}),this}return Q(this,d,"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),Q(this,d,"f").showHelpOnFail(D,u),this}showVersion(D){return S("[string|function]",[D],arguments.length),Q(this,d,"f").showVersion(D),this}skipValidation(D){return S("<array|string>",[D],arguments.length),this[sD]("skipValidation",D),this}strict(D){return S("[boolean]",[D],arguments.length),w(this,Gu,D!==!1,"f"),this}strictCommands(D){return S("[boolean]",[D],arguments.length),w(this,Xu,D!==!1,"f"),this}strictOptions(D){return S("[boolean]",[D],arguments.length),w(this,Qu,D!==!1,"f"),this}string(D){return S("<array|string>",[D],arguments.length),this[sD]("string",D),this[Vu](D),this}terminalWidth(){return S([],0),Q(this,g,"f").process.stdColumns}updateLocale(D){return this.updateStrings(D)}updateStrings(D){return S("<object>",[D],arguments.length),w(this,$u,!1,"f"),Q(this,g,"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(qD(D,null,Q(this,g,"f")),(D||"").match(/^\$0( |$)/))return this.command(D,u,F,E);else throw new ED(".usage() description must start with $0 if being used as alias for .command()");else return Q(this,d,"f").usage(D),this}usageConfiguration(D){return S("<object>",[D],arguments.length),w(this,qF,D,"f"),this}version(D,u,F){if(S("[boolean|string] [string] [string]",[D,u,F],arguments.length),Q(this,bD,"f"))this[X0](Q(this,bD,"f")),Q(this,d,"f").version(void 0),w(this,bD,null,"f");if(arguments.length===0)F=this[v8](),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 w(this,bD,typeof D==="string"?D:"version","f"),u=u||Q(this,d,"f").deferY18nLookup("Show version number"),Q(this,d,"f").version(F||void 0),this.boolean(Q(this,bD,"f")),this.describe(Q(this,bD,"f"),u),this}wrap(D){return S("<number|null|undefined>",[D],arguments.length),Q(this,d,"f").wrap(D),this}[(BD=new WeakMap,Cu=new WeakMap,yu=new WeakMap,KD=new WeakMap,UD=new WeakMap,GF=new WeakMap,tD=new WeakMap,$u=new WeakMap,XF=new WeakMap,AD=new WeakMap,QF=new WeakMap,LD=new WeakMap,ID=new WeakMap,jD=new WeakMap,TD=new WeakMap,YF=new WeakMap,zu=new WeakMap,XD=new WeakMap,f=new WeakMap,WF=new WeakMap,VF=new WeakMap,MD=new WeakMap,Zu=new WeakMap,Tu=new WeakMap,Ju=new WeakMap,oD=new WeakMap,HF=new WeakMap,g=new WeakMap,Gu=new WeakMap,Xu=new WeakMap,Qu=new WeakMap,d=new WeakMap,qF=new WeakMap,bD=new WeakMap,DD=new WeakMap,w8)](D){if(!D._||!D["--"])return D;D._.push.apply(D._,D["--"]);try{delete D["--"]}catch(u){}return D}[x8](){return{log:(...D)=>{if(!this[KF]())console.log(...D);if(w(this,jD,!0,"f"),Q(this,XD,"f").length)w(this,XD,Q(this,XD,"f")+`
80
+ `,"f");w(this,XD,Q(this,XD,"f")+D.join(" "),"f")},error:(...D)=>{if(!this[KF]())console.error(...D);if(w(this,jD,!0,"f"),Q(this,XD,"f").length)w(this,XD,Q(this,XD,"f")+`
81
+ `,"f");w(this,XD,Q(this,XD,"f")+D.join(" "),"f")}}}[X0](D){Au(Q(this,f,"f")).forEach((u)=>{if(((E)=>E==="configObjects")(u))return;let F=Q(this,f,"f")[u];if(Array.isArray(F)){if(F.includes(D))F.splice(F.indexOf(D),1)}else if(typeof F==="object")delete F[D]}),delete Q(this,d,"f").getDescriptions()[D]}[I8](D,u,F){if(!Q(this,XF,"f")[F])Q(this,g,"f").process.emitWarning(D,u),Q(this,XF,"f")[F]=!0}[b8](){Q(this,QF,"f").push({options:Q(this,f,"f"),configObjects:Q(this,f,"f").configObjects.slice(0),exitProcess:Q(this,AD,"f"),groups:Q(this,ID,"f"),strict:Q(this,Gu,"f"),strictCommands:Q(this,Xu,"f"),strictOptions:Q(this,Qu,"f"),completionCommand:Q(this,UD,"f"),output:Q(this,XD,"f"),exitError:Q(this,tD,"f"),hasOutput:Q(this,jD,"f"),parsed:this.parsed,parseFn:Q(this,MD,"f"),parseContext:Q(this,Zu,"f")}),Q(this,d,"f").freeze(),Q(this,DD,"f").freeze(),Q(this,BD,"f").freeze(),Q(this,LD,"f").freeze()}[f8](){let D="",u;if(/\b(node|iojs|electron)(\.exe)?$/.test(Q(this,g,"f").process.argv()[0]))u=Q(this,g,"f").process.argv().slice(1,2);else u=Q(this,g,"f").process.argv().slice(0,1);if(D=u.map((F)=>{let E=this[t8](Q(this,Cu,"f"),F);return F.match(/^(\/|([a-zA-Z]:)?\\)/)&&E.length<F.length?E:F}).join(" ").trim(),Q(this,g,"f").getEnv("_")&&Q(this,g,"f").getProcessArgvBin()===Q(this,g,"f").getEnv("_"))D=Q(this,g,"f").getEnv("_").replace(`${Q(this,g,"f").path.dirname(Q(this,g,"f").process.execPath())}/`,"");return D}[Yu](){return Q(this,VF,"f")}[h8](){return Q(this,qF,"f")}[Q0](){if(!Q(this,$u,"f"))return;let D=Q(this,g,"f").getEnv("LC_ALL")||Q(this,g,"f").getEnv("LC_MESSAGES")||Q(this,g,"f").getEnv("LANG")||Q(this,g,"f").getEnv("LANGUAGE")||"en_US";this.locale(D.replace(/[.:].*/,""))}[v8](){return this[Y0]().version||"unknown"}[y8](D){let u=D["--"]?D["--"]:D._;for(let F=0,E;(E=u[F])!==void 0;F++)if(Q(this,g,"f").Parser.looksLikeNumber(E)&&Number.isSafeInteger(Math.floor(parseFloat(`${E}`))))u[F]=Number(E);return D}[Y0](D){let u=D||"*";if(Q(this,Tu,"f")[u])return Q(this,Tu,"f")[u];let F={};try{let E=D||Q(this,g,"f").mainFilename;if(Q(this,g,"f").path.extname(E))E=Q(this,g,"f").path.dirname(E);let B=Q(this,g,"f").findUp(E,(C,$)=>{if($.includes("package.json"))return"package.json";else return});qD(B,void 0,Q(this,g,"f")),F=JSON.parse(Q(this,g,"f").readFileSync(B,"utf8"))}catch(E){}return Q(this,Tu,"f")[u]=F||{},Q(this,Tu,"f")[u]}[sD](D,u){u=[].concat(u),u.forEach((F)=>{F=this[H0](F),Q(this,f,"f")[D].push(F)})}[Ru](D,u,F,E){this[V0](D,u,F,E,(B,C,$)=>{Q(this,f,"f")[B][C]=$})}[W0](D,u,F,E){this[V0](D,u,F,E,(B,C,$)=>{Q(this,f,"f")[B][C]=(Q(this,f,"f")[B][C]||[]).concat($)})}[V0](D,u,F,E,B){if(Array.isArray(F))F.forEach((C)=>{D(C,E)});else if(((C)=>typeof C==="object")(F))for(let C of Au(F))D(C,F[C]);else B(u,this[H0](F),E)}[H0](D){if(D==="__proto__")return"___proto___";return D}[q0](D,u){return this[Ru](this[q0].bind(this),"key",D,u),this}[K0](){var D,u,F,E,B,C,$,z,Z,J,X,G;let Y=Q(this,QF,"f").pop();qD(Y,void 0,Q(this,g,"f"));let V;D=this,u=this,F=this,E=this,B=this,C=this,$=this,z=this,Z=this,J=this,X=this,G=this,{options:{set value(H){w(D,f,H,"f")}}.value,configObjects:V,exitProcess:{set value(H){w(u,AD,H,"f")}}.value,groups:{set value(H){w(F,ID,H,"f")}}.value,output:{set value(H){w(E,XD,H,"f")}}.value,exitError:{set value(H){w(B,tD,H,"f")}}.value,hasOutput:{set value(H){w(C,jD,H,"f")}}.value,parsed:this.parsed,strict:{set value(H){w($,Gu,H,"f")}}.value,strictCommands:{set value(H){w(z,Xu,H,"f")}}.value,strictOptions:{set value(H){w(Z,Qu,H,"f")}}.value,completionCommand:{set value(H){w(J,UD,H,"f")}}.value,parseFn:{set value(H){w(X,MD,H,"f")}}.value,parseContext:{set value(H){w(G,Zu,H,"f")}}.value}=Y,Q(this,f,"f").configObjects=V,Q(this,d,"f").unfreeze(),Q(this,DD,"f").unfreeze(),Q(this,BD,"f").unfreeze(),Q(this,LD,"f").unfreeze()}[p8](D,u){return Bu(u,(F)=>{return D(F),F})}getInternalMethods(){return{getCommandInstance:this[m8].bind(this),getContext:this[g8].bind(this),getHasOutput:this[c8].bind(this),getLoggerInstance:this[d8].bind(this),getParseContext:this[k8].bind(this),getParserConfiguration:this[Yu].bind(this),getUsageConfiguration:this[h8].bind(this),getUsageInstance:this[i8].bind(this),getValidationInstance:this[l8].bind(this),hasParseCallback:this[KF].bind(this),isGlobalContext:this[n8].bind(this),postProcess:this[Wu].bind(this),reset:this[O0].bind(this),runValidation:this[U0].bind(this),runYargsParserAndExecuteCommands:this[pu].bind(this),setHasOutput:this[o8].bind(this)}}[m8](){return Q(this,BD,"f")}[g8](){return Q(this,yu,"f")}[c8](){return Q(this,jD,"f")}[d8](){return Q(this,zu,"f")}[k8](){return Q(this,Zu,"f")||{}}[i8](){return Q(this,d,"f")}[l8](){return Q(this,DD,"f")}[KF](){return!!Q(this,MD,"f")}[n8](){return Q(this,YF,"f")}[Wu](D,u,F,E){if(F)return D;if(a(D))return D;if(!u)D=this[w8](D);if(this[Yu]()["parse-positional-numbers"]||this[Yu]()["parse-positional-numbers"]===void 0)D=this[y8](D);if(E)D=Eu(D,this,Q(this,LD,"f").getMiddleware(),!1);return D}[O0](D={}){w(this,f,Q(this,f,"f")||{},"f");let u={};u.local=Q(this,f,"f").local||[],u.configObjects=Q(this,f,"f").configObjects||[];let F={};u.local.forEach((C)=>{F[C]=!0,(D[C]||[]).forEach(($)=>{F[$]=!0})}),Object.assign(Q(this,Ju,"f"),Object.keys(Q(this,ID,"f")).reduce((C,$)=>{let z=Q(this,ID,"f")[$].filter((Z)=>!(Z in F));if(z.length>0)C[$]=z;return C},{})),w(this,ID,{},"f");let E=["array","boolean","string","skipValidation","count","normalize","number","hiddenOptions"],B=["narg","key","alias","default","defaultDescription","config","choices","demandedOptions","demandedCommands","deprecatedOptions"];if(E.forEach((C)=>{u[C]=(Q(this,f,"f")[C]||[]).filter(($)=>!F[$])}),B.forEach((C)=>{u[C]=lD(Q(this,f,"f")[C],($)=>!F[$])}),u.envPrefix=Q(this,f,"f").envPrefix,w(this,f,u,"f"),w(this,d,Q(this,d,"f")?Q(this,d,"f").reset(F):M8(this,Q(this,g,"f")),"f"),w(this,DD,Q(this,DD,"f")?Q(this,DD,"f").reset(F):P8(this,Q(this,d,"f"),Q(this,g,"f")),"f"),w(this,BD,Q(this,BD,"f")?Q(this,BD,"f").reset():O8(Q(this,d,"f"),Q(this,DD,"f"),Q(this,LD,"f"),Q(this,g,"f")),"f"),!Q(this,KD,"f"))w(this,KD,L8(this,Q(this,d,"f"),Q(this,BD,"f"),Q(this,g,"f")),"f");return Q(this,LD,"f").reset(),w(this,UD,null,"f"),w(this,XD,"","f"),w(this,tD,null,"f"),w(this,jD,!1,"f"),this.parsed=!1,this}[t8](D,u){return Q(this,g,"f").path.relative(D,u)}[pu](D,u,F,E=0,B=!1){var C,$,z,Z;let J=!!F||B;D=D||Q(this,oD,"f"),Q(this,f,"f").__=Q(this,g,"f").y18n.__,Q(this,f,"f").configuration=this[Yu]();let X=!!Q(this,f,"f").configuration["populate--"],G=Object.assign({},Q(this,f,"f").configuration,{"populate--":!0}),Y=Q(this,g,"f").Parser.detailed(D,Object.assign({},Q(this,f,"f"),{configuration:{"parse-positional-numbers":!1,...G}})),V=Object.assign(Y.argv,Q(this,Zu,"f")),H=void 0,W=Y.aliases,K=!1,N=!1;if(Object.keys(V).forEach((M)=>{if(M===Q(this,TD,"f")&&V[M])K=!0;else if(M===Q(this,bD,"f")&&V[M])N=!0}),V.$0=this.$0,this.parsed=Y,E===0)Q(this,d,"f").clearCachedHelpMessage();try{if(this[Q0](),u)return this[Wu](V,X,!!F,!1);if(Q(this,TD,"f")){if([Q(this,TD,"f")].concat(W[Q(this,TD,"f")]||[]).filter((y)=>y.length>1).includes(""+V._[V._.length-1]))V._.pop(),K=!0}w(this,YF,!1,"f");let M=Q(this,BD,"f").getCommands(),L=((C=Q(this,KD,"f"))===null||C===void 0?void 0:C.completionKey)?[($=Q(this,KD,"f"))===null||$===void 0?void 0:$.completionKey,...(Z=this.getAliases()[(z=Q(this,KD,"f"))===null||z===void 0?void 0:z.completionKey])!==null&&Z!==void 0?Z:[]].some((T)=>Object.prototype.hasOwnProperty.call(V,T)):!1,j=K||L||B;if(V._.length){if(M.length){let T;for(let y=E||0,k;V._[y]!==void 0;y++)if(k=String(V._[y]),M.includes(k)&&k!==Q(this,UD,"f")){let QD=Q(this,BD,"f").runCommand(k,this,Y,y+1,B,K||N||B);return this[Wu](QD,X,!!F,!1)}else if(!T&&k!==Q(this,UD,"f")){T=k;break}if(!Q(this,BD,"f").hasDefaultCommand()&&Q(this,HF,"f")&&T&&!j)Q(this,DD,"f").recommendCommands(T,M)}if(Q(this,UD,"f")&&V._.includes(Q(this,UD,"f"))&&!L){if(Q(this,AD,"f"))nD(!0);this.showCompletionScript(),this.exit(0)}}if(Q(this,BD,"f").hasDefaultCommand()&&!j){let T=Q(this,BD,"f").runCommand(null,this,Y,0,B,K||N||B);return this[Wu](T,X,!!F,!1)}if(L){if(Q(this,AD,"f"))nD(!0);D=[].concat(D);let T=D.slice(D.indexOf(`--${Q(this,KD,"f").completionKey}`)+1);return Q(this,KD,"f").getCompletion(T,(y,k)=>{if(y)throw new ED(y.message);(k||[]).forEach((QD)=>{Q(this,zu,"f").log(QD)}),this.exit(0)}),this[Wu](V,!X,!!F,!1)}if(!Q(this,jD,"f")){if(K){if(Q(this,AD,"f"))nD(!0);J=!0,this.showHelp((T)=>{Q(this,zu,"f").log(T),this.exit(0)})}else if(N){if(Q(this,AD,"f"))nD(!0);J=!0,Q(this,d,"f").showVersion("log"),this.exit(0)}}if(!J&&Q(this,f,"f").skipValidation.length>0)J=Object.keys(V).some((T)=>Q(this,f,"f").skipValidation.indexOf(T)>=0&&V[T]===!0);if(!J){if(Y.error)throw new ED(Y.error.message);if(!L){let T=this[U0](W,{},Y.error);if(!F)H=Eu(V,this,Q(this,LD,"f").getMiddleware(),!0);if(H=this[p8](T,H!==null&&H!==void 0?H:V),a(H)&&!F)H=H.then(()=>{return Eu(V,this,Q(this,LD,"f").getMiddleware(),!1)})}}}catch(M){if(M instanceof ED)Q(this,d,"f").fail(M.message,M);else throw M}return this[Wu](H!==null&&H!==void 0?H:V,X,!!F,!0)}[U0](D,u,F,E){let B={...this.getDemandedOptions()};return(C)=>{if(F)throw new ED(F.message);Q(this,DD,"f").nonOptionCount(C),Q(this,DD,"f").requiredArguments(C,B);let $=!1;if(Q(this,Xu,"f"))$=Q(this,DD,"f").unknownCommands(C);if(Q(this,Gu,"f")&&!$)Q(this,DD,"f").unknownArguments(C,D,u,!!E);else if(Q(this,Qu,"f"))Q(this,DD,"f").unknownArguments(C,D,{},!1,!1);Q(this,DD,"f").limitedChoices(C),Q(this,DD,"f").implications(C),Q(this,DD,"f").conflicting(C)}}[o8](){w(this,jD,!0,"f")}[Vu](D){if(typeof D==="string")Q(this,f,"f").key[D]=!0;else for(let u of D)Q(this,f,"f").key[u]=!0}}function U8(D){return!!D&&typeof D.getInternalMethods==="function"}var z7=s8($0),a8=z7;import{existsSync as OF,readFileSync as _0,writeFileSync as j0,mkdirSync as u1}from"node:fs";import{homedir as Z7}from"node:os";import{join as Hu,dirname as N0}from"node:path";function A0(){return process.env.HOME||Z7()}function F1(){return Hu(A0(),".config","slack-cli","profiles.json")}function UF(){return Hu(process.cwd(),".slack-cli","workspace")}function jF(){return Hu(A0(),".slack-cli","workspace")}function mu(){let D=F1();if(!OF(D))return{profiles:{}};return JSON.parse(_0(D,"utf8"))}function J7(D){let u=F1();u1(N0(u),{recursive:!0}),j0(u,JSON.stringify(D,null,2)+`
82
+ `)}function Pu(D){if(!OF(D))return;return _0(D,"utf8").trim()||void 0}function e8(D,u){let F=N0(D);u1(F,{recursive:!0});let E=Hu(F,".gitignore");if(!OF(E))j0(E,`*
83
+ `);j0(D,u+`
84
+ `)}function G7(D){let u={};for(let F of D.split(`
85
+ `)){let E=F.trim();if(!E||E.startsWith("#"))continue;let B=E.indexOf("=");if(B===-1)continue;let C=E.slice(0,B).trim(),$=E.slice(B+1).trim();if($.startsWith('"')&&$.endsWith('"')||$.startsWith("'")&&$.endsWith("'"))$=$.slice(1,-1);u[C]=$}return u}function D1(D){if(!OF(D))return{};try{return G7(_0(D,"utf8"))}catch{return{}}}function M0(D,u){let F=A0(),E=D;while(!0){for(let $ of[Hu(E,".slack-term",".env.local"),Hu(E,".env.local")]){let z=D1($);for(let Z of u)if(z[Z])return z[Z]}if(E===F)break;let C=N0(E);if(C===E)break;E=C}let B=D1(Hu(F,".slack-term",".env.local"));for(let C of u)if(B[C])return B[C];return}function L0(){let D=mu(),u=Pu(UF()),F=Pu(jF()),E=u??F;return Object.entries(D.profiles).map(([B,C])=>({name:B,profile:C,current:B===E}))}function E1(D){let u=mu();if(!(D in u.profiles))throw Error(`Profile not found: ${D}`);delete u.profiles[D],J7(u)}function B1(D,u=!1){let F=mu();if(!(D in F.profiles))throw Error(`Profile not found: ${D}`);if(u)e8(jF(),D);else e8(UF(),D)}function T0(D){let F=mu().profiles,E=Object.keys(F);if(D){let J=F[D];if(!J)throw Error(`Workspace "${D}" not found. Available: ${E.join(", ")||"(none)"}`);return J.token}if(process.env.SLACK_TOKEN)return process.env.SLACK_TOKEN;let B=process.env.SLACK_BOT_TOKEN??process.env.SLACK_MCP_XOXP_TOKEN;if(B&&E.length===0)return B;if(B&&E.length>0){let J=M0(process.cwd(),["SLACK_BOT_TOKEN","SLACK_MCP_XOXP_TOKEN"]);if(B!==J){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 C=M0(process.cwd(),["SLACK_TOKEN"]);if(C)return C;let $=process.env.SLACK_WORKSPACE;if($){let J=F[$];if(!J)throw Error(`Workspace "${$}" not found. Available: ${E.join(", ")||"(none)"}`);return J.token}let z=Pu(UF());if(z){let J=F[z];if(!J)throw Error(`Workspace "${z}" (from .slack-cli/workspace) not found in profiles.`);return J.token}let Z=Pu(jF());if(Z){let J=F[Z];if(!J)throw Error(`Workspace "${Z}" (from ~/.slack-cli/workspace) not found in profiles.`);return J.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 Y0(){let D=process.env.SLACK_BOT_TOKEN;return D&&D.startsWith("xoxb-")?D:void 0}function y8(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=G0(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 W0(){return(process.env.SLACK_API_BASE??"https://slack.com/api").replace(/\/$/,"")}async function p8(D,u,F,E){let C={};if(E)C.Cookie=`d=${E}`;let B=await fetch(`${W0()}/${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-) needs its session cookie to be accepted by the public Slack API.
93
+ `+" Or set SLACK_TOKEN=xoxp-... in .slack-term/.env.local")}function R0(){let D=process.env.SLACK_BOT_TOKEN;return D&&D.startsWith("xoxb-")?D:void 0}function C1(D){let F=mu().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 B=M0(process.cwd(),["SLACK_COOKIE"]);if(B)return B;let C=process.env.SLACK_WORKSPACE;if(C)return F[C]?.cookie;let $=Pu(UF());if($)return F[$]?.cookie;let z=Pu(jF());if(z)return F[z]?.cookie;return}class fD extends Error{retryAfter;constructor(D){super(`Slack rate limited — retry after ${D}s`);this.name="RateLimitError",this.retryAfter=D}}function P0(){return(process.env.SLACK_API_BASE??"https://slack.com/api").replace(/\/$/,"")}async function $1(D,u,F,E){let B={};if(E)B.Cookie=`d=${E}`;let C=await fetch(`${P0()}/${u}`,{...F,headers:{...F.headers??{},Authorization:`Bearer ${D}`,...B}});if(C.status===429){let z=parseInt(C.headers.get("retry-after")??"60",10);throw new fD(isNaN(z)?60:z)}let $=await C.json();if($.ok!==!0){let z=$.error??"unknown";if(z==="ratelimited")throw new fD(60);if(z==="invalid_auth"&&D.startsWith("xoxc-")&&!E)throw Error(`Desktop app token (xoxc-) needs its session cookie to be accepted by the public Slack API.
94
94
  Attach it: slack auth chrome (macOS) or slack auth firefox
95
95
  Or replace the token with an xoxp- user token:
96
- 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
+ slack auth token`);if((z==="missing_scope"||z==="cannot_dm_bot")&&D.startsWith("xoxb-"))throw Error(`Slack error on ${u}: ${z} — ${z==="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"}.
97
97
  Tailing/DMing people and listing users need a user session, not a bot token.
98
98
  Switch workspace: slack auth ls then slack auth use <name>
99
- Or import your Slack desktop session: slack auth login`);throw Error(`Slack error on ${u}: ${G}`)}return $}async function R6(D,u,F,E){let C={};if(E)C.Cookie=`d=${E}`;let B=await fetch(`${W0()}/${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-).
100
- 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.
101
- Attach it with: slack auth chrome (macOS) or slack auth firefox`);throw Error(`Slack error on ${u}: ${G}`)}return $}function S6(D,u,F={},E){let C=new URLSearchParams({token:D,...F});return R6(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 p8(D,`${u}?${C}`,{method:"GET"},E)}function P6(D,u,F,E){return p8(D,u,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(F)},E)}async function QF(D,u){let F=await OD(D,"auth.test",{},u);return{team:F.team??"",teamId:F.team_id??"",url:F.url??"",user:F.user??"",userId:F.user_id??""}}async function m8(D,u){let F={Authorization:`Bearer ${D}`};if(u)F.Cookie=`d=${u}`;let E=await fetch(`${W0()}/auth.test`,{method:"GET",headers:F});if(E.status===429){let $=parseInt(E.headers.get("retry-after")??"60",10);throw new lD(isNaN($)?60:$)}let C=E.headers.get("x-oauth-scopes")??"",B=await E.json();if(B.ok!==!0)throw Error(`Slack error on auth.test: ${B.error??"unknown"}`);return{userId:B.user_id??"",botId:B.bot_id??"",team:B.team??"",url:B.url??"",scopes:C.split(",").map(($)=>$.trim()).filter(Boolean)}}async function c8(D,u,F){let E=await OD(D,"bots.info",{bot:u},F);return{appId:E.bot?.app_id??"",userId:E.bot?.user_id??""}}async function O0(D,u,F=20,E,C,B){let $={channel:u,limit:String(F)};if(E!==void 0)$.oldest=E;if(C!==void 0)$.cursor=C;return OD(D,"conversations.history",$,B)}async function g8(D,u,F,E=50,C){return OD(D,"conversations.replies",{channel:u,ts:F,limit:String(E)},C)}async function w6(D,u,F){let C=(await P6(D,"conversations.open",{users:u},F)).channel?.id;if(!C)throw Error(`Failed to open DM with user ${u}`);return C}function hu(D){return D.toLowerCase().replace(/[-_\s]/g,"")}function V0(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 x6(D){return V0(D)?.channel}async function k8(D,u,F){let E=x6(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 K=((await OD(D,"conversations.list",{types:"im",limit:"200"},F)).channels??[]).find((A)=>A.user===V);if(K?.id)return String(K.id);return w6(D,V,F)}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 K of W.members??[]){let A=hu(K.name??""),_=hu(K.real_name??""),L=hu(K.profile?.display_name??"");if(A===$||_===$||L&&L===$){J=K.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 K of W.channels??[])if(K.user===J)return String(K.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 YF(D,u,F){try{let E=await OD(D,"users.info",{user:u},F),C=E.user?.profile?.display_name,B=C&&C.length>0?C:E.user?.real_name??E.user?.name??u,$=E.user?.name??u;return[B,$]}catch{return[u,u]}}async function WF(D,u,F){try{let E=await OD(D,"users.info",{user:u},F),C=E.user?.profile?.display_name;if(C&&C.length>0)return C;return E.user?.real_name??E.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 H0(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 q0(D,u,F){return OD(D,"users.info",{user:u},F)}async function d8(D,u,F){return OD(D,"conversations.info",{channel:u},F)}async function i8(D,u){let F=await S6(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 I6=["chat:write","im:write"],b6=["im:history","im:read"];async function K0(D){let{userId:u,botId:F,team:E,scopes:C}=await m8(D),B="";if(F)try{B=(await c8(D,F)).appId}catch{B=""}let $=(Z)=>C.includes(Z),G=I6.filter((Z)=>!$(Z)),z=b6.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 n8(D){return["",` Bot user: ${D.botUserId||"(unknown)"}`,` App ID: ${D.appId||"(unknown — bots.info unavailable)"}`,` Granted scopes: ${D.grantedScopes.join(", ")||"(none reported)"}`]}function U0(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,...n8(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,...n8(D)]}import{createInterface as Wu}from"node:readline/promises";import{join as T0}from"node:path";import{homedir as l6}from"node:os";import{existsSync as _0,readFileSync as j0,writeFileSync as t8,mkdirSync as o8}from"node:fs";import{homedir as f6}from"node:os";import{join as M0,dirname as s8}from"node:path";function r8(){return process.env.HOME||f6()}function a8(){return M0(r8(),".config","slack-cli","profiles.json")}function h6(){return M0(process.cwd(),".slack-cli","workspace")}function v6(){return M0(r8(),".slack-cli","workspace")}function A0(){let D=a8();if(!_0(D))return{profiles:{}};return JSON.parse(j0(D,"utf8"))}function e8(D){let u=a8();o8(s8(u),{recursive:!0}),t8(u,JSON.stringify(D,null,2)+`
102
- `)}function l8(D){if(!_0(D))return;return j0(D,"utf8").trim()||void 0}function D1(D,u){o8(s8(D),{recursive:!0});let F=_0(D)?j0(D,"utf8"):"",E=F?F.split(`
103
- `):[];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)}t8(D,E.join(`
99
+ Or import your Slack desktop session: slack auth login`);throw Error(`Slack error on ${u}: ${z}`)}return $}async function X7(D,u,F,E){let B={};if(E)B.Cookie=`d=${E}`;let C=await fetch(`${P0()}/${u}`,{...F,headers:{...F.headers??{},Authorization:`Bearer ${D}`,...B}});if(C.status===429){let z=parseInt(C.headers.get("retry-after")??"60",10);throw new fD(isNaN(z)?60:z)}let $=await C.json();if($.ok!==!0){let z=$.error??"unknown";if(z==="ratelimited")throw new fD(60);if((z==="invalid_auth"||z==="not_authed")&&!D.startsWith("xoxc-"))throw Error(`The draft API requires a desktop app session token (xoxc-).
100
+ Import from Slack desktop: slack auth login`);if((z==="invalid_auth"||z==="not_authed")&&!E)throw Error(`drafts.list also requires the xoxd session cookie.
101
+ Attach it with: slack auth chrome (macOS) or slack auth firefox`);throw Error(`Slack error on ${u}: ${z}`)}return $}function Q7(D,u,F={},E){let B=new URLSearchParams({token:D,...F});return X7(D,u,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:B.toString()},E)}function WD(D,u,F,E){let B=new URLSearchParams(F).toString();return $1(D,`${u}?${B}`,{method:"GET"},E)}function S0(D,u,F,E){return $1(D,u,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(F)},E)}async function Su(D,u){let F=await WD(D,"auth.test",{},u);return{team:F.team??"",teamId:F.team_id??"",url:F.url??"",user:F.user??"",userId:F.user_id??""}}async function z1(D,u){let F={Authorization:`Bearer ${D}`};if(u)F.Cookie=`d=${u}`;let E=await fetch(`${P0()}/auth.test`,{method:"GET",headers:F});if(E.status===429){let $=parseInt(E.headers.get("retry-after")??"60",10);throw new fD(isNaN($)?60:$)}let B=E.headers.get("x-oauth-scopes")??"",C=await E.json();if(C.ok!==!0)throw Error(`Slack error on auth.test: ${C.error??"unknown"}`);return{userId:C.user_id??"",user:C.user??"",botId:C.bot_id??"",team:C.team??"",url:C.url??"",scopes:B.split(",").map(($)=>$.trim()).filter(Boolean)}}async function Z1(D,u,F){let E=await WD(D,"bots.info",{bot:u},F);return{appId:E.bot?.app_id??"",userId:E.bot?.user_id??""}}async function cu(D,u,F=20,E,B,C){let $={channel:u,limit:String(F)};if(E!==void 0)$.oldest=E;if(B!==void 0)$.cursor=B;return WD(D,"conversations.history",$,C)}async function J1(D,u,F,E=50,B){return WD(D,"conversations.replies",{channel:u,ts:F,limit:String(E)},B)}async function MF(D,u,F,E,B){await S0(D,"reactions.add",{channel:u,timestamp:F,name:E},B)}async function G1(D,u,F,E){return((await WD(D,"reactions.get",{channel:u,timestamp:F,full:"true"},E)).message?.reactions??[]).map((C)=>({name:String(C.name??""),users:Array.isArray(C.users)?C.users.map(String):[]}))}async function _F(D,u,F,E,B){await S0(D,"reactions.remove",{channel:u,timestamp:F,name:E},B)}async function Y7(D,u,F){let B=(await S0(D,"conversations.open",{users:u},F)).channel?.id;if(!B)throw Error(`Failed to open DM with user ${u}`);return B}function gu(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,B=D.indexOf("?"),C=B>=0?new URLSearchParams(D.slice(B)):void 0,$=C?.get("thread_ts")??void 0,J={channel:C?.get("cid")??void 0??F};if(E)J.ts=E;if($)J.threadTs=$;return J}function W7(D){return w0(D)?.channel}async function X1(D,u,F){let E=W7(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 B=u.startsWith("@"),C=u.slice(1),$=gu(C);if(B){let J=await WD(D,"auth.test",{},F);if($==="you"||$==="me"||gu(J.user??"")===$){let H=J.user_id;if(!H)throw Error("auth.test did not return user_id");let K=((await WD(D,"conversations.list",{types:"im",limit:"200"},F)).channels??[]).find((N)=>N.user===H);if(K?.id)return String(K.id);return Y7(D,H,F)}let G="",Y="";while(!0){let H={limit:"200"};if(Y)H.cursor=Y;let W=await WD(D,"users.list",H,F);for(let K of W.members??[]){let N=gu(K.name??""),M=gu(K.real_name??""),L=gu(K.profile?.display_name??"");if(N===$||M===$||L&&L===$){G=K.id??"";break}}if(G)break;if(Y=W.response_metadata?.next_cursor??"",!Y)break}if(!G)throw Error(`User not found: ${u}`);let V="";while(!0){let H={types:"im",limit:"200"};if(V)H.cursor=V;let W=await WD(D,"conversations.list",H,F);for(let K of W.channels??[])if(K.user===G)return String(K.id??"");if(V=W.response_metadata?.next_cursor??"",!V)break}throw Error(`No existing DM with ${u} (${G}). Open it once in Slack first.`)}let z=C.toLowerCase(),Z="";while(!0){let J={limit:"200",types:"public_channel,private_channel",exclude_archived:"true"};if(Z)J.cursor=Z;let X=await WD(D,"conversations.list",J,F);for(let G of X.channels??[])if(String(G.name??"").toLowerCase()===z)return String(G.id??"");if(Z=X.response_metadata?.next_cursor??"",!Z)break}throw Error(`channel not found: ${u}`)}async function NF(D,u,F){try{let E=await WD(D,"users.info",{user:u},F),B=E.user?.profile?.display_name,C=B&&B.length>0?B:E.user?.real_name??E.user?.name??u,$=E.user?.name??u;return[C,$]}catch{return[u,u]}}async function AF(D,u,F){try{let E=await WD(D,"users.info",{user:u},F),B=E.user?.profile?.display_name;if(B&&B.length>0)return B;return E.user?.real_name??E.user?.name??u}catch{return u}}async function LF(D,u){let F=[],E="";while(!0){let B={limit:"200"};if(E)B.cursor=E;let C=await WD(D,"users.list",B,u);if(F.push(...C.members??[]),E=C.response_metadata?.next_cursor??"",!E)break}return{members:F}}async function x0(D,u,F){let E=[],B="";while(!0){let C={channel:u,limit:"200"};if(B)C.cursor=B;let $=await WD(D,"conversations.members",C,F);if(E.push(...$.members??[]),B=$.response_metadata?.next_cursor??"",!B)break}return E}async function I0(D,u,F){return WD(D,"users.info",{user:u},F)}async function Q1(D,u,F){return WD(D,"conversations.info",{channel:u},F)}async function Y1(D,u){let F=await Q7(D,"client.boot",{},u),E=typeof F.url==="string"?F.url:void 0;if(!E){let C=Object.keys(F).join(", ");throw Error(`client.boot did not return a WebSocket URL. Keys: ${C}`)}let B=F.self&&typeof F.self==="object"&&!Array.isArray(F.self)?F.self:{};return{wsUrl:E,selfId:typeof B.id==="string"?B.id:""}}var V7=["chat:write","im:write"],H7=["im:history","im:read"];async function b0(D){let{userId:u,botId:F,team:E,scopes:B}=await z1(D),C="";if(F)try{C=(await Z1(D,F)).appId}catch{C=""}let $=(J)=>B.includes(J),z=V7.filter((J)=>!$(J)),Z=H7.filter((J)=>!$(J));return{canSend:z.length===0,canReceiveReplies:Z.length===0,ok:z.length===0&&Z.length===0,botUserId:u,appId:C,team:E,grantedScopes:B,missingSendScopes:z,missingReplyScopes:Z}}function W1(D){return["",` Bot user: ${D.botUserId||"(unknown)"}`,` App ID: ${D.appId||"(unknown — bots.info unavailable)"}`,` Granted scopes: ${D.grantedScopes.join(", ")||"(none reported)"}`]}function f0(D,u=!1){let F=D.appId?`https://api.slack.com/apps/${D.appId}`:"https://api.slack.com/apps";if(D.ok){let B=["✓ 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?B:[...B,...W1(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,...W1(D)]}import{createInterface as Ku}from"node:readline/promises";import{join as c0}from"node:path";import{homedir as P7}from"node:os";import{existsSync as h0,readFileSync as v0,writeFileSync as H1,mkdirSync as q1}from"node:fs";import{homedir as q7}from"node:os";import{join as y0,dirname as K1}from"node:path";function O1(){return process.env.HOME||q7()}function U1(){return y0(O1(),".config","slack-cli","profiles.json")}function K7(){return y0(process.cwd(),".slack-cli","workspace")}function O7(){return y0(O1(),".slack-cli","workspace")}function p0(){let D=U1();if(!h0(D))return{profiles:{}};return JSON.parse(v0(D,"utf8"))}function j1(D){let u=U1();q1(K1(u),{recursive:!0}),H1(u,JSON.stringify(D,null,2)+`
102
+ `)}function V1(D){if(!h0(D))return;return v0(D,"utf8").trim()||void 0}function M1(D,u){q1(K1(D),{recursive:!0});let F=h0(D)?v0(D,"utf8"):"",E=F?F.split(`
103
+ `):[];for(let[B,C]of Object.entries(u)){let $=E.findIndex((Z)=>{let J=Z.trim();return J.startsWith(B+"=")||J.startsWith(B+" =")}),z=`${B}=${C}`;if($!==-1)E[$]=z;else E.push(z)}H1(D,E.join(`
104
104
  `).trimEnd()+`
105
- `)}function VF(){let D=A0(),u=l8(h6()),F=l8(v6()),E=u??F;return Object.entries(D.profiles).map(([C,B])=>({name:C,profile:B,current:C===E}))}function L0(D,u){let F=A0();F.profiles[D]=u,e8(F)}function N0(D,u){let F=A0();if(!(D in F.profiles))throw Error(`Profile not found: ${D}`);F.profiles[D].cookie=u,e8(F)}import{readdirSync as HF,readFileSync as vu,existsSync as Yu,copyFileSync as u1,unlinkSync as F1}from"node:fs";import{homedir as qF,tmpdir as E1}from"node:os";import{join as ZD,dirname as y6}from"node:path";import{pbkdf2Sync as C1,createDecipheriv as B1}from"node:crypto";import{execSync as $1}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 m6(){let D=qF();if(process.platform==="darwin")return ZD(D,"Library","Application Support","Slack","Cookies");return""}function c6(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=B1("aes-128-cbc",u,F);return C.setAutoPadding(!0),Buffer.concat([C.update(E),C.final()]).toString("utf8")}function g6(){if(process.platform!=="darwin")return;let D=m6();if(!Yu(D))return;let u;try{u=$1('security find-generic-password -w -s "Slack Safe Storage" -a "Slack Key"',{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trimEnd()}catch{return}let F=C1(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 c6(Buffer.from(B.encrypted_value),F)}catch{return}}async function G1(){let D=p6();if(!Yu(D))throw Error(`Slack desktop app LevelDB not found at:
105
+ `)}function TF(){let D=p0(),u=V1(K7()),F=V1(O7()),E=u??F;return Object.entries(D.profiles).map(([B,C])=>({name:B,profile:C,current:B===E}))}function m0(D,u){let F=p0();F.profiles[D]=u,j1(F)}function g0(D,u){let F=p0();if(!(D in F.profiles))throw Error(`Profile not found: ${D}`);F.profiles[D].cookie=u,j1(F)}import{readdirSync as RF,readFileSync as du,existsSync as qu,copyFileSync as _1,unlinkSync as N1}from"node:fs";import{homedir as PF,tmpdir as A1}from"node:os";import{join as JD,dirname as U7}from"node:path";import{pbkdf2Sync as L1,createDecipheriv as T1}from"node:crypto";import{execSync as R1}from"node:child_process";function j7(){let D=PF();if(process.platform==="darwin")return JD(D,"Library","Application Support","Slack","Local Storage","leveldb");if(process.platform==="linux")return JD(D,".config","Slack","Local Storage","leveldb");if(process.platform==="win32"){let u=process.env.APPDATA??JD(D,"AppData","Roaming");return JD(u,"Slack","Local Storage","leveldb")}throw Error(`Unsupported platform: ${process.platform}`)}function M7(){let D=PF();if(process.platform==="darwin")return JD(D,"Library","Application Support","Slack","Cookies");return""}function _7(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),B=T1("aes-128-cbc",u,F);return B.setAutoPadding(!0),Buffer.concat([B.update(E),B.final()]).toString("utf8")}function N7(){if(process.platform!=="darwin")return;let D=M7();if(!qu(D))return;let u;try{u=R1('security find-generic-password -w -s "Slack Safe Storage" -a "Slack Key"',{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trimEnd()}catch{return}let F=L1(u,"saltysalt",1003,16,"sha1");try{let{default:E}=xD("bun:sqlite"),B=new E(D,{readonly:!0}),C=B.prepare("SELECT encrypted_value FROM cookies WHERE name='d' AND host_key LIKE '%slack%'").get();if(B.close(),!C)return;return _7(Buffer.from(C.encrypted_value),F)}catch{return}}async function P1(){let D=j7();if(!qu(D))throw Error(`Slack desktop app LevelDB not found at:
106
106
  ${D}
107
- 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 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\/)"/),K=V.match(/"(?:team_name|name)":"([^"]{2,60})"/),A=F.get(J);if(!A||Y.length>A.token.length){let _={token:Y,teamId:J},L=W?.[1]??A?.url,M=K?.[1]??A?.teamName;if(L)_.url=L;if(M)_.teamName=M;F.set(J,_)}}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 K=z.charCodeAt(J);if(K>=48&&K<=57||K>=97&&K<=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=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),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=g6(),$=[...F.values()];if(B)for(let G of $)G.cookie=B;return $}function k6(D,u){let F=(E,C)=>{try{let B=B1("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 d6(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 z1(){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=$1('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=C1(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(E1(),`slack-chrome-cookies-${Date.now()}-${B}.db`);try{u1($,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=k6(J,F);if(!O)continue;C.push({profileDir:B,profileName:d6(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{F1(G)}catch{}}}return{candidates:C,totalProfiles:E.length}}function i6(){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 n6(D){let u=ZD(y6(D),"profiles.ini"),F={};if(!Yu(u))return F;try{let E=vu(u,"utf8"),C="",B="";for(let $ of E.split(`
108
- `)){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 Z1(){let D=i6();if(!D||!Yu(D))return[];let u=n6(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(E1(),`slack-firefox-cookies-${Date.now()}-${C}.db`);try{u1(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{F1($)}catch{}}}return F}var t6=["search:read","channels:history","groups:history","im:history","mpim:history","channels:read","groups:read","im:read","mpim:read","users:read","chat:write","files:write"],o6=["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 s6(){return JSON.stringify({display_information:{name:"slack-term"},oauth_config:{scopes:{user:t6}},settings:{org_deploy_enabled:!1,socket_mode_enabled:!1,token_rotation_enabled:!1}},null,2)}function r6(){return JSON.stringify({display_information:{name:"slack-term"},features:{bot_user:{display_name:"slack-term",always_online:!1}},oauth_config:{scopes:{bot:o6}},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=T0(process.cwd(),".slack-term",".env.local");else if(z==="3")G=T0(l6(),".slack-term",".env.local");else if(z==="4")G=null;else G=T0(process.cwd(),".env.local")}if(G===null)if(L0($,{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;D1(G,z),console.log(`Saved token to ${G}`),console.log(" SLACK_TOKEN will be picked up automatically in this directory tree.")}return $}async function a6(D){console.error("Scanning Slack desktop app...");let u=await G1();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);L0(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 J1(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"?s6():r6(),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 X1(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,Q)=>console.log(` ${Q+1}) ${J.name} (${J.profile.team})`));let z=Wu({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(`
107
+ Is Slack installed and opened at least once?`);let u=RF(D).filter((z)=>z.endsWith(".ldb")||z.endsWith(".log"));if(u.length===0)throw Error(`No LevelDB data files found in ${D}`);let F=new Map;for(let z of u){let Z;try{Z=du(JD(D,z),"latin1")}catch{continue}if(z.endsWith(".log"))for(let J of Z.matchAll(/"token":"(xoxc-[^"]+)"/g)){let X=J[1],G=X.split("-")[1]??"";if(!G||X.length<40)continue;let Y=Math.max(0,J.index-2000),V=Math.min(Z.length,J.index+2000),H=Z.slice(Y,V),W=H.match(/"url":"(https:\/\/[a-z0-9-]+\.slack\.com\/)"/),K=H.match(/"(?:team_name|name)":"([^"]{2,60})"/),N=F.get(G);if(!N||X.length>N.token.length){let M={token:X,teamId:G},L=W?.[1]??N?.url,j=K?.[1]??N?.teamName;if(L)M.url=L;if(j)M.teamName=j;F.set(G,M)}}else for(let J of Z.matchAll(/xoxc-(\d+)-(\d+)-(\d+)/g)){let X=J[1];if(F.has(X))continue;let G=J.index+J[0].length,Y=Math.min(G+10,Z.length);while(G<Y&&(Z.charCodeAt(G)<48||Z.charCodeAt(G)>57))G++;let V="";while(G<Z.length&&Z.charCodeAt(G)>=48&&Z.charCodeAt(G)<=57)V+=Z[G++];if(Z[G]!=="-")continue;G++;let H="";while(G<Z.length){let K=Z.charCodeAt(G);if(K>=48&&K<=57||K>=97&&K<=102)H+=Z[G++];else break}if(H.length<20)continue;let W=`${J[0]}${V}-${H}`;F.set(X,{token:W,teamId:X})}}let B=RF(D).filter((z)=>z.endsWith(".ldb")||z.endsWith(".log")).map((z)=>{try{return du(JD(D,z),"latin1").replace(/[^\x20-\x7e]/g," ")}catch{return""}}).join(" ");for(let z of F.values()){if(z.teamName)continue;let Z=B.indexOf(z.teamId);if(Z!==-1){let J=Math.max(0,Z-500),X=Math.min(B.length,Z+500),Y=B.slice(J,X).match(/"(?:team_name|name)":"([^"]{2,60})"/);if(Y?.[1]){z.teamName=Y[1];continue}}if(!z.teamName&&z.url){let J=z.url.match(/https:\/\/([a-z0-9-]+)\.slack\.com\//)?.[1];if(J){let X=B.indexOf(J);if(X!==-1){let G=Math.max(0,X-500),Y=Math.min(B.length,X+500),H=B.slice(G,Y).match(/"(?:team_name|name)":"([^"]{2,60})"/);if(H?.[1]){z.teamName=H[1];continue}}z.teamName=J.split("-").map((G)=>G.charAt(0).toUpperCase()+G.slice(1)).join(" ")}}}let C=N7(),$=[...F.values()];if(C)for(let z of $)z.cookie=C;return $}function A7(D,u){let F=(E,B)=>{try{let C=T1("aes-128-cbc",u,E);C.setAutoPadding(!0);let $=Buffer.concat([C.update(B),C.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 L7(D,u){let F=(E,B)=>{if(E&&B)return`${E} (${B})`;return E||B||u};try{let B=JSON.parse(du(JD(D,"Local State"),"utf8")).profile?.info_cache?.[u];if(B&&(B.name||B.user_name))return F(B.name??"",B.user_name??"")}catch{}try{let B=JSON.parse(du(JD(D,u,"Preferences"),"utf8")).profile;return F(B?.name??"",B?.user_name??"")}catch{return u}}function S1(){if(process.platform!=="darwin")return{candidates:[],totalProfiles:0};let D=JD(PF(),"Library","Application Support","Google","Chrome");if(!qu(D))return{candidates:[],totalProfiles:0};let u;try{u=R1('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=L1(u,"saltysalt",1003,16,"sha1"),E=["Default",...RF(D).filter((C)=>C.startsWith("Profile "))],B=[];for(let C of E){let $=JD(D,C,"Cookies");if(!qu($))continue;let z=JD(A1(),`slack-chrome-cookies-${Date.now()}-${C}.db`);try{_1($,z);let{default:Z}=xD("bun:sqlite"),J=new Z(z,{readonly:!0}),X=J.prepare("SELECT encrypted_value FROM cookies WHERE name='d' AND host_key LIKE '%slack%'").get();if(J.close(),!X)continue;let G=Buffer.from(X.encrypted_value),Y=G.slice(0,3).toString();if(Y==="v10"){let V=A7(G,F);if(!V)continue;B.push({profileDir:C,profileName:L7(D,C),cookie:V})}else if(Y==="v20")throw Error(`Chrome cookie uses v20 (app-bound AES-256-GCM) which is not supported yet. Prefix found: ${G.slice(0,4).toString("hex")}`);else throw Error(`Unknown cookie encryption prefix: ${G.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{N1(z)}catch{}}}return{candidates:B,totalProfiles:E.length}}function T7(){let D=PF();if(process.platform==="darwin")return JD(D,"Library","Application Support","Firefox","Profiles");if(process.platform==="linux")return JD(D,".mozilla","firefox");if(process.platform==="win32")return JD(process.env.APPDATA??JD(D,"AppData","Roaming"),"Mozilla","Firefox","Profiles");return""}function R7(D){let u=JD(U7(D),"profiles.ini"),F={};if(!qu(u))return F;try{let E=du(u,"utf8"),B="",C="";for(let $ of E.split(`
108
+ `)){let z=$.trim();if(z.startsWith("[")){B="",C="";continue}let Z=z.indexOf("=");if(Z===-1)continue;let J=z.slice(0,Z).trim().toLowerCase(),X=z.slice(Z+1).trim();if(J==="name")B=X;if(J==="path")C=X.split(/[\\/]/).pop()??X;if(B&&C)F[C]=B,B="",C=""}}catch{}return F}function w1(){let D=T7();if(!D||!qu(D))return[];let u=R7(D),F=[],E;try{E=RF(D)}catch{return[]}for(let B of E){let C=JD(D,B,"cookies.sqlite");if(!qu(C))continue;let $=JD(A1(),`slack-firefox-cookies-${Date.now()}-${B}.db`);try{_1(C,$);let{default:z}=xD("bun:sqlite"),Z=new z($,{readonly:!0}),J=Z.prepare("SELECT value FROM moz_cookies WHERE name='d' AND host LIKE '%slack%' LIMIT 1").get();if(Z.close(),!J?.value||!J.value.startsWith("xoxd-"))continue;let X=u[B]??B;F.push({profileDir:B,profileName:X,cookie:J.value})}catch{}finally{try{N1($)}catch{}}}return F}var S7=["search:read","channels:history","groups:history","im:history","mpim:history","channels:read","groups:read","im:read","mpim:read","users:read","chat:write","files:write"],w7=["channels:history","groups:history","im:history","mpim:history","channels:read","groups:read","im:read","mpim:read","users:read","chat:write","files:write"];function SF(D){return D.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function x7(){return JSON.stringify({display_information:{name:"slack-term"},oauth_config:{scopes:{user:S7}},settings:{org_deploy_enabled:!1,socket_mode_enabled:!1,token_rotation_enabled:!1}},null,2)}function I7(){return JSON.stringify({display_information:{name:"slack-term"},features:{bot_user:{display_name:"slack-term",always_online:!1}},oauth_config:{scopes:{bot:w7}},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 Uu(D,u,F,E){console.error("Verifying token...");let B=await Su(u),C=SF(B.team),$;if(F)$=F;else if(D)$=await Ou(D,`Workspace name [${C}]: `)||C;else $=C;let z=null;if(D){console.log(""),console.log("Where to save the token?"),console.log(" 1) ./.env.local (current directory) [default]"),console.log(" 2) ./.slack-term/.env.local (current directory, slack-specific)"),console.log(" 3) ~/.slack-term/.env.local (global, available everywhere)"),console.log(" 4) profiles.json (multi-workspace: slack auth use)"),console.log("");let Z=await Ou(D,"Choice [1/2/3/4, Enter=1]: ");if(Z==="2")z=c0(process.cwd(),".slack-term",".env.local");else if(Z==="3")z=c0(P7(),".slack-term",".env.local");else if(Z==="4")z=null;else z=c0(process.cwd(),".env.local")}if(z===null)if(m0($,{token:u,...B,...E?{cookie:E}:{}}),console.log(`Saved workspace "${$}" to profiles.json: ${B.team} (${B.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;M1(z,Z),console.log(`Saved token to ${z}`),console.log(" SLACK_TOKEN will be picked up automatically in this directory tree.")}return $}async function b7(D){console.error("Scanning Slack desktop app...");let u=await P1();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 Uu(D,F.token,SF(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,B=SF(E);m0(B,{token:F.token,team:E,teamId:F.teamId,url:F.url??"",user:"",...F.cookie?{cookie:F.cookie}:{}}),console.log(`Added workspace "${B}": ${E}${F.cookie?" + xoxd cookie":""}`)}if(console.log(""),u.length===1){let F=SF(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 x1(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-",B=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 "${B}" (starts with ${E})`),console.log("");let C=await Ou(D,"Paste your token: ");if(!C)console.error("No token provided."),process.exit(1);if(!C.startsWith(E))console.error(`Expected a ${E} token, got: ${C.slice(0,10)}...`),process.exit(1);await Uu(D,C)}async function wF(D,u){let F=u==="user"?x7():I7(),E=u==="user"?"User OAuth Token (xoxp-...)":"Bot User OAuth Token (xoxb-...)",B=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 C=await Ou(D,"Paste your token: ");if(!C)console.error("No token provided."),process.exit(1);if(!C.startsWith(B))console.error(`Expected a ${B} token, got: ${C.slice(0,10)}...`),process.exit(1);await Uu(D,C)}async function I1(D={}){if(process.platform!=="darwin")console.error("Chrome cookie extraction is only supported on macOS."),process.exit(1);let u=TF();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 z=u.find((Z)=>Z.current);if(z)F=z.name,console.log(`Using active workspace: ${F}`);else{console.log("Multiple workspaces found. Choose one:"),u.forEach((G,Y)=>console.log(` ${Y+1}) ${G.name} (${G.profile.team})`));let Z=Ku({input:process.stdin,output:process.stdout}),J=(await Z.question("Choice: ")).trim();Z.close();let X=parseInt(J,10)-1;if(isNaN(X)||X<0||X>=u.length)console.error("Invalid choice."),process.exit(1);F=u[X].name}}if(u.find((z)=>z.name===F).profile.token.startsWith("xoxb-")){console.error(`
109
109
  Workspace "${F}" uses a bot token (xoxb-). A Chrome session cookie only
110
110
  `+`augments a user session token (xoxc-) — it has no effect on a bot token, so user-level
111
- `+"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}=z1())}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=Wu({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}N0(F,$),console.log(`Saved xoxd cookie to workspace "${F}".`),console.log("RTM WebSocket mode is now available: slack tail @you")}async function Q1(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,Y)=>console.log(` ${Y+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=Z1();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}N0(F,C),console.log(`Saved xoxd cookie to workspace "${F}".`),console.log("RTM WebSocket mode is now available: slack tail @you")}async function Y1(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 J1(u)}finally{u.close()}}async function W1(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 a6(F);else if(E==="2")await J1(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(/[>|]/),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 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 V1(D){let u=typeof D.ts==="string"?D.ts:"",F=typeof D.thread_ts==="string"?D.thread_ts:"";return F!==""&&F!==u}function e6(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 D7(D,u,F){let E=typeof u.ts==="string"?u.ts:"0.000000",C=e6(E),B="?";if(typeof u.user==="string"){let J=u.user,Q="@"+J;if(!F.has(Q)){let[,O]=await YF(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=MF(await jF(D,$,F)).split(`
112
- `),Z=z[0]+(z.length>1?`
113
- `+z.slice(1).map((J)=>` ${J}`).join(`
114
- `):""),Y=V1(u)?"↳ ":"";return`${C} ${Y}@${B}: ${Z}`}async function u7(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).
115
- `)}),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&&V1(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 A=B.values().next().value;if(A!==void 0)B.delete(A)}let K=await D7(u,J,$);process.stdout.write(K+`
116
- `)}catch(J){process.stderr.write(`RTM message error: ${J instanceof Error?J.message:String(J)}
117
- `)}})()})})}var O1=3,F7=2000,R0={sleep:(D)=>new Promise((u)=>setTimeout(u,D)),clientBoot:i8,getWebSocket:()=>{let D=globalThis.WebSocket;return typeof D==="function"?D:void 0}};async function H1(D,u,F,E,C,B,$){let G=R0.getWebSocket();if(!G)return;for(let z=0;z<O1;z++){if($?.aborted)return;try{let{wsUrl:Z}=await R0.clientBoot(D,u);await u7(G,D,Z,F,E,C,B,$)}catch{}if($?.aborted)return;if(z<O1-1)await R0.sleep(F7)}}function q1(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:H1};function yD(D){return D&&typeof D==="object"&&!Array.isArray(D)?D:{}}function S0(D){return Array.isArray(D)?D:[]}function K1(D){return Number(D)||0}function U1(D){let u=typeof D.ts==="string"?D.ts:"",F=typeof D.thread_ts==="string"?D.thread_ts:"";return F!==""&&F!==u}function E7(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 C7(D,u,F,E){let C=typeof u.ts==="string"?u.ts:"0.000000",B=E7(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(`
118
- `),Y=Z[0]+(Z.length>1?`
119
- `+Z.slice(1).map((O)=>` ${O}`).join(`
120
- `):""),J=U1(u)?"↳ ":"",Q=E?`${E} @${$}`:`@${$}`;return`${B} ${J}${Q}: ${Y}`}async function B7(D,u,F,E,C,B,$){let G=yD(await O0(D,u,20,$?void 0:F||void 0,$)),z=S0(G.messages).map(yD).reverse(),Z=yD(G.response_metadata),Y=G.has_more===!0&&typeof Z.next_cursor==="string"?Z.next_cursor:void 0,J=[];if(E.watchThread&&!$){let K=yD(await g8(D,u,E.watchThread,50));J=S0(K.messages).map(yD).filter((A)=>(typeof A.ts==="string"?A.ts:"")!==E.watchThread)}let Q=[...z.map((K)=>({m:K,fromHistory:!0})),...J.map((K)=>({m:K,fromHistory:!1}))].sort((K,A)=>K1(typeof K.m.ts==="string"?K.m.ts:"")-K1(typeof A.m.ts==="string"?A.m.ts:"")),O=[],V=F,W=!1;for(let{m:K,fromHistory:A}of Q){let _=typeof K.ts==="string"?K.ts:"";if(!_||C.has(_))continue;let L=typeof K.subtype==="string"?K.subtype:"";if(L==="message_changed"||L==="message_deleted")continue;if(E.thread){if((typeof K.thread_ts==="string"?K.thread_ts:_)!==E.thread&&_!==E.thread)continue}if(E.watchThread&&U1(K)){if((typeof K.thread_ts==="string"?K.thread_ts:"")!==E.watchThread)continue}if(E.me&&E.myUserId){if(!(typeof K.text==="string"?K.text:"").includes(`<@${E.myUserId}>`))continue}if(C.add(_),C.size>1000){let x=C.values().next().value;if(x!==void 0)C.delete(x)}if(O.push(await C7(D,K,B)),A)V=_;let M=typeof K.user==="string"?K.user:"";if(!E.myUserId||M!==E.myUserId)W=!0}return{newCursor:V,lines:O,hasMore:G.has_more===!0,nextPageCursor:Y,emittedOther:W}}function $7(D){if(D.includes("slack.com")){let u=V0(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 _1(D,u,F={},E){if(F.me&&!u)console.error(`slack tail --me requires a <target> channel.
111
+ `+"actions (tail @user, DMs, listing users) would still fail.");let z=u.filter((Z)=>Z.profile.token.startsWith("xoxc-")||Z.profile.token.startsWith("xoxp-"));if(z.length>0)console.error(` Target a user-token workspace instead: ${z.map((Z)=>Z.name).join(", ")}`),console.error(` slack auth chrome -w ${z[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 B,C;try{({candidates:B,totalProfiles:C}=S1())}catch(z){console.error(`Failed: ${z instanceof Error?z.message:String(z)}`),process.exit(1)}if(B.length===0)console.error(`No Slack session found in Chrome (scanned ${C} profile${C!==1?"s":""}). Possible reasons:`),console.error(" - You denied the keychain dialog (try running again and click Allow)"),console.error(" - Chrome is not installed or has no Slack session"),console.error(" - You're not logged in to Slack in Chrome"),process.exit(1);let $;if(B.length===1&&C<=1)$=B[0].cookie,console.log(`Found session in Chrome profile: ${B[0].profileName}`);else{let z=B.length===1?`Found 1 Slack session across ${C} Chrome profiles:`:`Found ${B.length} Slack sessions across ${C} Chrome profiles:`;console.log(z),B.forEach((Y,V)=>console.log(` ${V+1}) ${Y.profileName} [${Y.profileDir}]`)),console.log("");let Z=Ku({input:process.stdin,output:process.stdout}),J=B.length===1?" [Enter=1]":"",X=(await Z.question(`Choice [1-${B.length}]${J}: `)).trim();Z.close();let G=X===""&&B.length===1?0:parseInt(X,10)-1;if(isNaN(G)||G<0||G>=B.length)console.error("Invalid choice."),process.exit(1);$=B[G].cookie}g0(F,$),console.log(`Saved xoxd cookie to workspace "${F}".`),console.log("RTM WebSocket mode is now available: slack tail @you")}async function b1(D={}){let u=TF();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 C=u.find(($)=>$.current);if(C)F=C.name,console.log(`Using active workspace: ${F}`);else{console.log("Multiple workspaces found. Choose one:"),u.forEach((J,X)=>console.log(` ${X+1}) ${J.name} (${J.profile.team})`));let $=Ku({input:process.stdin,output:process.stdout}),z=(await $.question("Choice: ")).trim();$.close();let Z=parseInt(z,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=w1();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 B;if(E.length===1)B=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,J)=>console.log(` ${J+1}) ${Z.profileName} [${Z.profileDir}]`));let C=Ku({input:process.stdin,output:process.stdout}),$=(await C.question("Choice: ")).trim();C.close();let z=parseInt($,10)-1;if(isNaN(z)||z<0||z>=E.length)console.error("Invalid choice."),process.exit(1);B=E[z].cookie}g0(F,B),console.log(`Saved xoxd cookie to workspace "${F}".`),console.log("RTM WebSocket mode is now available: slack tail @you")}async function f1(D={}){if(D.token){await Uu(null,D.token,D.name);return}if(!process.stdin.isTTY){let F=[];for await(let B of process.stdin)F.push(B);let E=Buffer.concat(F).toString("utf8").trim();if(!E)console.error("No token provided on stdin."),process.exit(1);await Uu(null,E,D.name);return}let u=Ku({input:process.stdin,output:process.stdout});try{await x1(u)}finally{u.close()}}async function h1(D={}){let u=Ku({input:process.stdin,output:process.stdout});try{if(D.bot!==void 0){await wF(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 wF(u,F==="2"?"bot":"user")}finally{u.close()}}async function xF(D={}){let u=TF();if(u.length>0){console.log("Currently logged in:");for(let{name:E,profile:B,current:C}of u)console.log(` ${C?"*":" "} ${E} ${B.team} (${B.user||"unknown"})`);console.log(""),console.log("Adding another workspace:"),console.log("")}if(D.token){await Uu(null,D.token,D.name);return}if(!process.stdin.isTTY){let E=[];for await(let C of process.stdin)E.push(C);let B=Buffer.concat(E).toString("utf8").trim();if(!B)console.error("No token provided on stdin."),process.exit(1);await Uu(null,B,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=Ku({input:process.stdin,output:process.stdout});try{let E=await Ou(F,"Choice [1/2/3/4]: ");if(console.log(""),E==="1")await b7(F);else if(E==="2")await x1(F);else if(E==="3")await wF(F,"user");else if(E==="4")await wF(F,"bot");else console.error(`Invalid choice: "${E}". Enter 1, 2, 3, or 4.`),process.exit(1)}finally{F.close()}}async function IF(D,u,F,E){let B=u,C=[],$=B,z=0;while(!0){let Z=$.indexOf("<@U",z);if(Z===-1)break;let J=$.slice(Z+2),X=J.search(/[>|]/),G=X===-1?J:J.slice(0,X);if(G.length>=9)C.push(G);z=Z+1}for(let Z of C){if(!F.has(Z))F.set(Z,await AF(D,Z,E));let J=F.get(Z)??Z;B=B.replaceAll(`<@${Z}>`,`@${J}`),B=B.replace(new RegExp(`<@${Z}\\|[^>]*>`,"g"),`@${J}`)}return B}function bF(D){return D.replace(/<!date\^(\d+)\^[^|>]*(?:\|([^>]*))?>/g,(u,F,E)=>{let B=Number(F);if(!Number.isFinite(B))return E??"date";let C=new Date(B*1000);if(Number.isNaN(C.getTime()))return E??"date";let $=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],z=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Z=$[C.getUTCDay()]??"",J=z[C.getUTCMonth()]??"";return`${Z}, ${J} ${String(C.getUTCDate()).padStart(2,"0")}, ${C.getUTCFullYear()}`})}function y1(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),B=E.getUTCFullYear(),C=String(E.getUTCMonth()+1).padStart(2,"0"),$=String(E.getUTCDate()).padStart(2,"0"),z=String(E.getUTCHours()).padStart(2,"0"),Z=String(E.getUTCMinutes()).padStart(2,"0"),J=String(E.getUTCSeconds()).padStart(2,"0"),X=F.padEnd(6,"0").slice(0,6);return`${B}-${C}-${$}T${z}:${Z}:${J}.${X}`}async function h7(D,u,F){let E=typeof u.ts==="string"?u.ts:"0.000000",B=f7(E),C="?";if(typeof u.user==="string"){let G=u.user,Y="@"+G;if(!F.has(Y)){let[,V]=await NF(D,G);F.set(Y,V)}C=F.get(Y)??G}else if(typeof u.username==="string")C=u.username;let $=typeof u.text==="string"?u.text:"",Z=bF(await IF(D,$,F)).split(`
112
+ `),J=Z[0]+(Z.length>1?`
113
+ `+Z.slice(1).map((G)=>` ${G}`).join(`
114
+ `):""),X=y1(u)?"↳ ":"";return`${B} ${X}@${C}: ${J}`}async function v7(D,u,F,E,B,C,$,z){if(z?.aborted)return;return new Promise((Z)=>{let J=new D(F);z?.addEventListener("abort",()=>{J.close(),Z()},{once:!0}),J.addEventListener("open",()=>{process.stderr.write(`Connected via RTM (experimental).
115
+ `)}),J.addEventListener("close",()=>Z()),J.addEventListener("error",()=>Z()),J.addEventListener("message",(X)=>{(async()=>{try{let G;try{G=JSON.parse(String(X.data))}catch{return}let Y=typeof G.type==="string"?G.type:"";if(Y==="ping"){J.send(JSON.stringify({type:"pong",reply_to:G.id??0}));return}if(Y!=="message")return;if((typeof G.channel==="string"?G.channel:"")!==E)return;let H=typeof G.ts==="string"?G.ts:"";if(!H||C.has(H))return;let W=typeof G.subtype==="string"?G.subtype:"";if(W==="message_changed"||W==="message_deleted")return;if(B.thread){if((typeof G.thread_ts==="string"?G.thread_ts:H)!==B.thread&&H!==B.thread)return}if(B.watchThread&&y1(G)){if((typeof G.thread_ts==="string"?G.thread_ts:"")!==B.watchThread)return}if(B.me&&B.myUserId){if(!(typeof G.text==="string"?G.text:"").includes(`<@${B.myUserId}>`))return}if(C.add(H),C.size>1000){let N=C.values().next().value;if(N!==void 0)C.delete(N)}let K=await h7(u,G,$);process.stdout.write(K+`
116
+ `)}catch(G){process.stderr.write(`RTM message error: ${G instanceof Error?G.message:String(G)}
117
+ `)}})()})})}var v1=3,y7=2000,d0={sleep:(D)=>new Promise((u)=>setTimeout(u,D)),clientBoot:Y1,getWebSocket:()=>{let D=globalThis.WebSocket;return typeof D==="function"?D:void 0}};async function p1(D,u,F,E,B,C,$){let z=d0.getWebSocket();if(!z)return;for(let Z=0;Z<v1;Z++){if($?.aborted)return;try{let{wsUrl:J}=await d0.clientBoot(D,u);await v7(z,D,J,F,E,B,C,$)}catch{}if($?.aborted)return;if(Z<v1-1)await d0.sleep(y7)}}function m1(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:p1};function gD(D){return D&&typeof D==="object"&&!Array.isArray(D)?D:{}}function k0(D){return Array.isArray(D)?D:[]}function g1(D){return Number(D)||0}function c1(D){let u=typeof D.ts==="string"?D.ts:"",F=typeof D.thread_ts==="string"?D.thread_ts:"";return F!==""&&F!==u}function p7(D){let[u,F="000000"]=D.split("."),E=new Date(Number(u)*1000),B=E.getUTCFullYear(),C=String(E.getUTCMonth()+1).padStart(2,"0"),$=String(E.getUTCDate()).padStart(2,"0"),z=String(E.getUTCHours()).padStart(2,"0"),Z=String(E.getUTCMinutes()).padStart(2,"0"),J=String(E.getUTCSeconds()).padStart(2,"0"),X=F.padEnd(6,"0").slice(0,6);return`${B}-${C}-${$}T${z}:${Z}:${J}.${X}`}async function m7(D,u,F,E,B){let C=typeof u.ts==="string"?u.ts:"0.000000",$=p7(C),z="?";if(typeof u.user==="string"){let H=u.user,W="@"+H;if(!F.has(W)){let[,K]=await NF(D,H,B);F.set(W,K)}z=F.get(W)??H}else if(typeof u.username==="string")z=u.username;let Z=typeof u.text==="string"?u.text:"",X=bF(await IF(D,Z,F,B)).split(`
118
+ `),G=X[0]+(X.length>1?`
119
+ `+X.slice(1).map((H)=>` ${H}`).join(`
120
+ `):""),Y=c1(u)?"↳ ":"",V=E?`${E} @${z}`:`@${z}`;return`${$} ${Y}${V}: ${G}`}async function g7(D,u,F,E,B,C,$){let z=gD(await cu(D,u,20,$?void 0:F||void 0,$,E.cookie)),Z=k0(z.messages).map(gD).reverse(),J=gD(z.response_metadata),X=z.has_more===!0&&typeof J.next_cursor==="string"?J.next_cursor:void 0,G=[];if(E.watchThread&&!$){let K=gD(await J1(D,u,E.watchThread,50,E.cookie));G=k0(K.messages).map(gD).filter((N)=>(typeof N.ts==="string"?N.ts:"")!==E.watchThread)}let Y=[...Z.map((K)=>({m:K,fromHistory:!0})),...G.map((K)=>({m:K,fromHistory:!1}))].sort((K,N)=>g1(typeof K.m.ts==="string"?K.m.ts:"")-g1(typeof N.m.ts==="string"?N.m.ts:"")),V=[],H=F,W=!1;for(let{m:K,fromHistory:N}of Y){let M=typeof K.ts==="string"?K.ts:"";if(!M||B.has(M))continue;let L=typeof K.subtype==="string"?K.subtype:"";if(L==="message_changed"||L==="message_deleted")continue;if(E.thread){if((typeof K.thread_ts==="string"?K.thread_ts:M)!==E.thread&&M!==E.thread)continue}if(E.watchThread&&c1(K)){if((typeof K.thread_ts==="string"?K.thread_ts:"")!==E.watchThread)continue}if(E.me&&E.myUserId){if(!(typeof K.text==="string"?K.text:"").includes(`<@${E.myUserId}>`))continue}if(B.add(M),B.size>1000){let T=B.values().next().value;if(T!==void 0)B.delete(T)}if(V.push(await m7(D,K,C,void 0,E.cookie)),N)H=M;let j=typeof K.user==="string"?K.user:"";if(!E.myUserId||j!==E.myUserId)W=!0}return{newCursor:H,lines:V,hasMore:z.has_more===!0,nextPageCursor:X,emittedOther:W}}function c7(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 d1(D,u,F={},E){if(F.me&&!u)console.error(`slack tail --me requires a <target> channel.
121
121
  Cross-channel mention streaming is not yet supported.
122
- 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 k8(D,u),B=F.interval??60000,$=F.timeout?SD.now()+q1(F.timeout)*1000:1/0,G=new Map,z=new Set;try{let W=yD(await d8(D,C));if(yD(W.channel).is_archived===!0)console.error("Warning: this channel is archived — no new messages will arrive.")}catch(W){let K=W instanceof Error?W.message:String(W);if(K.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(K.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(K.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: ${K}`)}let Z="";if(F.since){let W=q1(F.since);Z=(SD.now()/1000-W).toFixed(6)}else{let W=yD(await O0(D,C,1)),K=S0(W.messages).map(yD);if(K.length>0&&typeof K[0]?.ts==="string")Z=K[0].ts,z.add(Z);else Z=(SD.now()/1000).toFixed(6)}let Y;if(F.me||F.exitOnMessage)Y=(await QF(D)).userId||void 0;let J;if(F.watchThread!==void 0)try{J=$7(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 _=SD.now()-V,L=B>0&&_>B*5,M,x=!0;do{let{newCursor:k,lines:s,nextPageCursor:jD,emittedOther:n}=await B7(D,C,Z,Q,z,G,M);if(Z=k,O&&x&&F.since&&s.length===0)process.stdout.write(`(no messages in the last ${F.since} — watching for new)
123
- `);x=!1;for(let sD of s)process.stdout.write(sD+`
124
- `);if(n)W=!0;M=L?jD:void 0}while(M);O=!1}catch(A){if(A instanceof lD){console.error(`Warning: Slack rate limit hit — backing off for ${A.retryAfter}s`),await SD.sleep(A.retryAfter*1000);continue}throw A}if(F.exitOnMessage&&W)return;V=SD.now();let K=$-SD.now();if(K<=0)return;await SD.sleep(Math.min(B,K))}}class Au extends Error{retryAfter;constructor(D){super(`Slack rate limited — retry after ${D}s`);this.name="RateLimitError",this.retryAfter=D}}function P0(){return(process.env.SLACK_API_BASE??"https://slack.com/api").replace(/\/$/,"")}async function j1(D,u,F,E){let C={};if(E)C.Cookie=`d=${E}`;let B=await fetch(`${P0()}/${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-) needs its session cookie to be accepted by the public Slack API.
122
+ 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 B=await X1(D,u),C=F.interval??60000,$=F.timeout?SD.now()+m1(F.timeout)*1000:1/0,z=new Map,Z=new Set;try{let W=gD(await Q1(D,B,F.cookie));if(gD(W.channel).is_archived===!0)console.error("Warning: this channel is archived — no new messages will arrive.")}catch(W){let K=W instanceof Error?W.message:String(W);if(K.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(K.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(K.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: ${K}`)}let J="";if(F.since){let W=m1(F.since);J=(SD.now()/1000-W).toFixed(6)}else{let W=gD(await cu(D,B,1,void 0,void 0,F.cookie)),K=k0(W.messages).map(gD);if(K.length>0&&typeof K[0]?.ts==="string")J=K[0].ts,Z.add(J);else J=(SD.now()/1000).toFixed(6)}let X;if(F.me||F.exitOnMessage)X=(await Su(D,F.cookie)).userId||void 0;let G;if(F.watchThread!==void 0)try{G=c7(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}:{},...G!==void 0?{watchThread:G}:{},...F.me!==void 0?{me:F.me}:{},...X!==void 0?{myUserId:X}:{},...F.cookie!==void 0?{cookie:F.cookie}:{}};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,B,Y,Z,z,E),E?.aborted)return;console.error("RTM unavailable — switching to polling.")}let V=!0,H=SD.now();while(!E?.aborted){if(SD.now()>=$)return;let W=!1;try{let M=SD.now()-H,L=C>0&&M>C*5,j,T=!0;do{let{newCursor:y,lines:k,nextPageCursor:QD,emittedOther:l}=await g7(D,B,J,Y,Z,z,j);if(J=y,V&&T&&F.since&&k.length===0)process.stdout.write(`(no messages in the last ${F.since} — watching for new)
123
+ `);T=!1;for(let Du of k)process.stdout.write(Du+`
124
+ `);if(l)W=!0;j=L?QD:void 0}while(j);V=!1}catch(N){if(N instanceof fD){console.error(`Warning: Slack rate limit hit — backing off for ${N.retryAfter}s`),await SD.sleep(N.retryAfter*1000);continue}throw N}if(F.exitOnMessage&&W)return;H=SD.now();let K=$-SD.now();if(K<=0)return;await SD.sleep(Math.min(C,K))}}class wu extends Error{retryAfter;constructor(D){super(`Slack rate limited — retry after ${D}s`);this.name="RateLimitError",this.retryAfter=D}}function i0(){return(process.env.SLACK_API_BASE??"https://slack.com/api").replace(/\/$/,"")}async function k1(D,u,F,E){let B={};if(E)B.Cookie=`d=${E}`;let C=await fetch(`${i0()}/${u}`,{...F,headers:{...F.headers??{},Authorization:`Bearer ${D}`,...B}});if(C.status===429){let z=parseInt(C.headers.get("retry-after")??"60",10);throw new wu(isNaN(z)?60:z)}let $=await C.json();if($.ok!==!0){let z=$.error??"unknown";if(z==="ratelimited")throw new wu(60);if(z==="invalid_auth"&&D.startsWith("xoxc-")&&!E)throw Error(`Desktop app token (xoxc-) needs its session cookie to be accepted by the public Slack API.
125
125
  Attach it: slack auth chrome (macOS) or slack auth firefox
126
126
  Or replace the token with an xoxp- user token:
127
- 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"}.
127
+ slack auth token`);if((z==="missing_scope"||z==="cannot_dm_bot")&&D.startsWith("xoxb-"))throw Error(`Slack error on ${u}: ${z} — ${z==="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"}.
128
128
  Tailing/DMing people and listing users need a user session, not a bot token.
129
129
  Switch workspace: slack auth ls then slack auth use <name>
130
- Or import your Slack desktop session: slack auth login`);throw Error(`Slack error on ${u}: ${G}`)}return $}async function G7(D,u,F,E){let C={};if(E)C.Cookie=`d=${E}`;let B=await fetch(`${P0()}/${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-).
131
- 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.
132
- 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 G7(D,u,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:C.toString()},E)}function uD(D,u,F,E){let C=new URLSearchParams(F).toString();return j1(D,`${u}?${C}`,{method:"GET"},E)}function PD(D,u,F,E){return j1(D,u,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(F)},E)}async function M1(D,u){let F=await uD(D,"auth.test",{},u);return{team:F.team??"",teamId:F.team_id??"",url:F.url??"",user:F.user??"",userId:F.user_id??""}}async function A1(D,u){let F={Authorization:`Bearer ${D}`};if(u)F.Cookie=`d=${u}`;let E=await fetch(`${P0()}/auth.test`,{method:"GET",headers:F});if(E.status===429){let $=parseInt(E.headers.get("retry-after")??"60",10);throw new Au(isNaN($)?60:$)}let C=E.headers.get("x-oauth-scopes")??"",B=await E.json();if(B.ok!==!0)throw Error(`Slack error on auth.test: ${B.error??"unknown"}`);return{userId:B.user_id??"",botId:B.bot_id??"",team:B.team??"",url:B.url??"",scopes:C.split(",").map(($)=>$.trim()).filter(Boolean)}}async function pu(D,u,F=20,E,C,B){let $={channel:u,limit:String(F)};if(E!==void 0)$.oldest=E;if(C!==void 0)$.cursor=C;return uD(D,"conversations.history",$,B)}async function Nu(D,u,F,E=50,C){return uD(D,"conversations.replies",{channel:u,ts:F,limit:String(E)},C)}async function L1(D,u,F){return uD(D,"files.info",{file:u},F)}async function N1(D,u={},F){let E={count:String(Math.min(Math.max(u.count??100,1),200)),page:String(Math.max(u.page??1,1))};if(u.types)E.types=u.types;if(u.channel)E.channel=u.channel;if(u.user)E.user=u.user;return uD(D,"files.list",E,F)}async function T1(D,u,F,E,C){return uD(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))},C)}async function R1(D,u,F){return T1(D,u,100,1,F)}async function w0(D,u,F,E){let B=1,$=[],G={ok:!0,messages:{}};while(!0){let Z=await T1(D,u,100,B,E),Y=yu(Z,["messages","matches"]),J=Array.isArray(Y)?Y:[];$.push(...J);let Q=Number(yu(Z,["messages","paging","pages"])??1);if(G=Z,J.length===0||B>=Q||$.length>=F)break;B+=1}let z=G;if(!z.messages)z.messages={};return z.messages.matches=$.slice(0,F),z}async function S1(D,u,F,E,C,B){let $={channel:u,text:F,blocks:[{type:"markdown",text:F}]};if(E!==void 0)$.thread_ts=E;if(C&&E!==void 0)$.reply_broadcast=!0;return(await PD(D,"chat.postMessage",$,B)).ts??""}async function P1(D,u,F,E,C,B){let $={channel:u,text:F,post_at:E,blocks:[{type:"markdown",text:F}]};if(C!==void 0)$.thread_ts=C;return(await PD(D,"chat.scheduleMessage",$,B)).scheduled_message_id??""}async function w1(D,u,F){let E={};if(u)E.channel=u;return uD(D,"chat.scheduledMessages.list",E,F)}async function x1(D,u,F,E){await PD(D,"chat.deleteScheduledMessage",{channel:u,scheduled_message_id:F},E)}async function x0(D,u,F,E){return(await uD(D,"chat.getPermalink",{channel:u,message_ts:F},E)).permalink??""}async function I1(D,u,F,E,C){return(await PD(D,"chat.update",{channel:u,ts:F,text:E,blocks:[{type:"markdown",text:E}]},C)).ts??F}async function b1(D,u,F,E){await PD(D,"chat.delete",{channel:u,ts:F},E)}async function f1(D,u,F,E,C){await PD(D,"reactions.add",{channel:u,timestamp:F,name:E},C)}async function h1(D,u,F,E,C){await PD(D,"reactions.remove",{channel:u,timestamp:F,name:E},C)}async function v1(D,u,F=!1,E){let C=await PD(D,"conversations.create",{name:u,is_private:F},E);return{id:C.channel?.id??"",name:C.channel?.name??u}}async function y1(D,u,F,E){await PD(D,"conversations.invite",{channel:u,users:F.join(",")},E)}async function AF(D,u){let F=[],E="";while(!0){let C={limit:"200",types:"public_channel,private_channel,im,mpim"};if(E)C.cursor=E;let B=await uD(D,"conversations.list",C,u);if(F.push(...B.channels??[]),E=B.response_metadata?.next_cursor??"",!E)break}return{channels:F}}async function mu(D,u,F){let C=(await PD(D,"conversations.open",{users:u},F)).channel?.id;if(!C)throw Error(`Failed to open DM with user ${u}`);return C}function bD(D){return D.toLowerCase().replace(/[-_\s]/g,"")}async function I0(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 uD(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 uD(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 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 z7(D){return cu(D)?.channel}async function HD(D,u,F){let E=z7(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 uD(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 K=((await uD(D,"conversations.list",{types:"im",limit:"200"},F)).channels??[]).find((A)=>A.user===V);if(K?.id)return String(K.id);return mu(D,V,F)}let J="",Q="";while(!0){let V={limit:"200"};if(Q)V.cursor=Q;let W=await uD(D,"users.list",V,F);for(let K of W.members??[]){let A=bD(K.name??""),_=bD(K.real_name??""),L=bD(K.profile?.display_name??"");if(A===$||_===$||L&&L===$){J=K.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 uD(D,"conversations.list",V,F);for(let K of W.channels??[])if(K.user===J)return String(K.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 uD(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 gu(D,u,F){try{let E=await uD(D,"users.info",{user:u},F),C=E.user?.profile?.display_name,B=C&&C.length>0?C:E.user?.real_name??E.user?.name??u,$=E.user?.name??u;return[B,$]}catch{return[u,u]}}async function ku(D,u,F){try{let E=await uD(D,"users.info",{user:u},F),C=E.user?.profile?.display_name;if(C&&C.length>0)return C;return E.user?.real_name??E.user?.name??u}catch{return u}}async function b0(D,u){let F=[],E="";while(!0){let C={limit:"200"};if(E)C.cursor=E;let B=await uD(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 p1(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 m1(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 c1(D,u,F){return Lu(D,"conversations.info",{channel:u},F)}async function f0(D,u,F){return uD(D,"users.info",{user:u},F)}async function h0(D,u,F){return uD(D,"conversations.info",{channel:u},F)}async function g1(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 v0(D,u){let F=await Lu(D,"auth.test",{},u);return{userId:String(F.user_id??""),teamId:String(F.team_id??"")}}async function k1(D,u,F,E={},C){let{statSync:B,readFileSync:$}=await import("node:fs"),{basename:G}=await import("node:path"),z=B(F),Z=G(F),Y=await uD(D,"files.getUploadURLExternal",{filename:Z,length:String(z.size)},C),J=Y.upload_url,Q=Y.file_id;if(!J||!Q)throw Error("files.getUploadURLExternal returned no upload_url/file_id");let O=$(F),V=await fetch(J,{method:"POST",headers:{"Content-Type":"application/octet-stream"},body:O});if(!V.ok)throw Error(`Upload PUT failed: ${V.status} ${V.statusText}`);let W={files:[{id:Q,title:E.title??Z}],channel_id:u};if(E.threadTs)W.thread_ts=E.threadTs;if(E.initialComment)W.initial_comment=E.initialComment;let K=await PD(D,"files.completeUploadExternal",W,C),A={fileId:Q},_=K.files?.[0]?.permalink;if(_)A.permalink=_;return A}function yu(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 J7(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 X7(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 J7(B)){let z=-1;if(F===G)z=D.length;else for(let Z of i1)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:g0(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 p0(D,u,F,E){let C=`[${n1}ー]+`,B=`${C}(?:[._-]+${C})*`,$=new RegExp(`(?<![A-Za-z0-9._@<-])@(${B})`,"gu"),G=new Set;for(let _ of u.matchAll($))G.add(_[1]);if(G.size===0)return{text:u,resolved:[],unresolved:[]};let z=new Map;for(let _ of G)z.set(_,{status:"pending"});let Z=(_)=>{for(let L of G){if(z.get(L).status!=="pending")continue;if(c0(L)){let M=X7(L,_);if(M==="ambiguous")z.set(L,{status:"ambiguous"});else if(M)z.set(L,{status:"resolved",userId:M.userId,matchLen:M.matchLen,display:M.display})}else{let M=_.filter((k)=>Z7(k,L)),x=new Set(M.map((k)=>typeof k.id==="string"?k.id:"").filter(Boolean));if(x.size===1){let k=M.find((s)=>typeof s.id==="string");z.set(L,{status:"resolved",userId:k.id,matchLen:L.length,display:g0(k)})}else if(x.size>1)z.set(L,{status:"ambiguous"})}}},Y=!1;try{let _=await OF(D,E);Z((_.members??[]).map(tD)),Y=!0}catch{Y=!1}let J=[...G].some((_)=>z.get(_).status==="pending"),Q=!1,O=!0;if(J&&F){Q=!0;try{let _=await H0(D,F,E),L=[];for(let M of _){let x=tD(await q0(D,M,E)),k=tD(x.user);if(typeof k.id!=="string")k.id=M;L.push(k)}Z(L)}catch{O=!1}}let V=Y&&(F?Q&&O:!0),W=[],K=[];for(let _ of G){let L=z.get(_);if(L.status==="resolved")W.push({surface:`@${_.slice(0,L.matchLen)}`,display:L.display,userId:L.userId});else if(L.status==="ambiguous")K.push({surface:`@${_}`,reason:"ambiguous"});else K.push({surface:`@${_}`,reason:V?"no-match":"unavailable"})}return{text:u.replace($,(_,L)=>{let M=z.get(L);if(M&&M.status==="resolved")return`<@${M.userId}>${L.slice(M.matchLen)}`;return _}),resolved:W,unresolved:K}}function m0(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 d1(D,u,F,E={}){let C=E.warn??(($)=>process.stderr.write(`${$}
133
- `)),B=await p0(D,u,F,E.cookie);for(let $ of m0(B.unresolved))C(`warn: ${$}`);return B.text}var i1=["さん","さま","様","君","くん","ちゃん","氏","先生","先輩","殿","老师","老師","兄","姐","哥","姐妹"],n1="\\p{Script=Han}\\p{Script=Hiragana}\\p{Script=Katakana}A-Za-z0-9";function c0(D){return/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}]/u.test(D)}function Q7(D){let u=[],F=new RegExp(`([${n1}]{1,12})(${i1.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 Y7(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 W7(D,u){let F=Hu(D);if(F.length<2)return;for(let E of u)if(F===E)return E;if(c0(D)){for(let E of u)if(F.includes(E)||E.includes(F))return E}return}function g0(D){return[tD(D.profile).display_name,D.real_name,D.name].filter((E)=>typeof E==="string"&&E!=="")[0]??String(D.id??"?")}async function l1(D,u,F){let E=Q7(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:Y7(Z),display:g0(Z)})).filter((Z)=>Z.id!==""),G=[],z=new Set;for(let{ref:Z,honorific:Y}of E)for(let J of $){let Q=W7(Z,J.forms);if(!Q)continue;if(C.has(J.id)||z.has(J.id))break;z.add(J.id),G.push({surface:c0(Z)?`${Q}${Y}`: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(/[>|]/),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 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 t1(D,u=new Date){let F=new Date(D*1000),E=y0(u),C=y0(new Date(u.getTime()-86400000)),B=y0(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 y0(D){return`${D.getFullYear()}-${D.getMonth()}-${D.getDate()}`}function o1(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(!D3(D))return;let u=V7(D,"utf8");for(let F of u.split(`
134
- `)){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){H7(D,{recursive:!0});let u=oD(D,".gitignore");if(!D3(u))u3(u,`*
135
- `)}function K7(){nu(oD(s1(),".slack-cli",".env.local")),nu(oD(s1(),".config/slack-cli",".env")),nu(oD(process.cwd(),".slack-cli",".env.local")),nu(oD(process.cwd(),".env.local")),nu(oD(process.cwd(),".env"))}function U7(D){return O7("sha256").update(D).digest("hex")}function p(D){return D&&typeof D==="object"&&!Array.isArray(D)?D:{}}function o(D){return Array.isArray(D)?D:[]}function LF(D){return Number(D.ts??0)}async function F3(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 k0(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 i0(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 n0(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 _7(D){return/^\d{4}-\d{2}-\d{2}T/.test(D)?n0(D):D}async function TF(D,u,F,E){let C=typeof u.ts==="string"?u.ts:`${LF(u)}.000000`,B=i0(C),$="?";if(typeof u.user==="string"){let W=u.user,K="@"+W;if(!F.has(K)){let[,A]=await gu(D,W);F.set(K,A)}$=F.get(K)??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(`
136
- `),Y=Z[0]+(Z.length>1?`
137
- `+Z.slice(1).map((W)=>` ${W}`).join(`
138
- `):""),J=E?`${E} @${$}`:`@${$}`,Q=o(u.reactions).map(p).map((W)=>{let K=typeof W.name==="string"?W.name:"",A=Number(W.count??o(W.users).length??0);return K?`:${K}:\xD7${A}`:""}).filter(Boolean).join(" "),O=o(u.files).map(p).map((W)=>{let K=typeof W.name==="string"?W.name:typeof W.title==="string"?W.title:"(file)",A=typeof W.size==="number"?` (${RF(W.size)})`:"",_=typeof W.id==="string"?` [${W.id}]`:"";return`
139
- \uD83D\uDCCE ${K}${A}${_}`}).join(""),V=(Q?`
140
- ${Q}`:"")+O;return`${B} ${J}: ${Y}${V}`}function RF(D){return D<1024?`${D} B`:D<1048576?`${(D/1024).toFixed(1)} KB`:`${(D/1048576).toFixed(1)} MB`}function j7(D){return o(D.files).map(p).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 E3(D){let u=j7(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 M7(D,u,F,E="text"){let C=cu(u),B=await HD(D,u),$=new Map,z=await(async()=>{if(C?.threadTs){let Y=await Nu(D,B,C.threadTs,F);return o(Y.messages).map(p)}let Z=await pu(D,B,F);return o(Z.messages).map(p).reverse()})();if(E==="jsonl"){for(let Z of z)console.log(JSON.stringify(E3(Z)));return}for(let Z of z)console.log(await TF(D,Z,$))}async function A7(D,u,F,E,C="text"){let B=await HD(D,u),$=await Nu(D,B,_7(F),E),G=o($.messages).map(p);if(C==="jsonl"){for(let Z of G)console.log(JSON.stringify(E3(Z)));return}let z=new Map;for(let Z of G)console.log(await TF(D,Z,z))}async function L7(D){let u=await AF(D),F=o(u.channels).map(p).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 pu(D,B,5),z=o(G.messages).map(p).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 F3(D,Z,E),J=(typeof Z.text==="string"?Z.text:"").split(`
141
- `)[0]??"",Q=await Tu(D,J,E);console.log(` ${Y}: ${Q}`)}}}async function N7(D,u){let F=await R1(D,"to:me"),E=o(yu(F,["messages","matches"])).map(p).slice(0,u),C=new Map,B=[];for(let $ of E){let G=t1(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 Y=p(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 gu(D,Q);C.set(V,W)}O=`@${C.get(V)??Q}`}else if(J)O=`@${Q}`;else O=`#${Q}`;console.log(await TF(D,Z,C,O))}}}async function T7(D,u,F,E,C="text"){let B=await AF(D),$=o(B.channels).map(p).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 p(G.purpose).value==="string"?String(p(G.purpose).value):"",W=V?` ${V.split(`
142
- `)[0]?.slice(0,60)}`:"";console.log(`${Q}${Z} ${z}${O}${W}`)}}function R7(D){let u=(C)=>C.startsWith("xoxp-")||C.startsWith("xoxc-"),F=X0(),E=F.find((C)=>C.profile.token===D);if(!E)return;return F.find((C)=>u(C.profile.token)&&C.profile.teamId===E.profile.teamId)}async function S7(D,u,F,E,C){let B=D,$=C,G;try{G=await w0(B,u,F,$)}catch(Y){let J=Y instanceof Error?Y.message:String(Y);if(D.startsWith("xoxb-")&&J.includes("not_allowed_token_type")){let Q=R7(D);if(Q)console.error(`Note: search.messages needs a user token \u2014 the active profile is a bot token (xoxb-); falling back to profile "${Q.name}".`),B=Q.profile.token,$=Q.profile.cookie,G=await w0(B,u,F,$);else console.error(`Error: search requires a user token (xoxp-/xoxc-) \u2014 the active profile is a bot token (xoxb-), which Slack rejects for search.messages.
130
+ Or import your Slack desktop session: slack auth login`);throw Error(`Slack error on ${u}: ${z}`)}return $}async function d7(D,u,F,E){let B={};if(E)B.Cookie=`d=${E}`;let C=await fetch(`${i0()}/${u}`,{...F,headers:{...F.headers??{},Authorization:`Bearer ${D}`,...B}});if(C.status===429){let z=parseInt(C.headers.get("retry-after")??"60",10);throw new wu(isNaN(z)?60:z)}let $=await C.json();if($.ok!==!0){let z=$.error??"unknown";if(z==="ratelimited")throw new wu(60);if((z==="invalid_auth"||z==="not_authed")&&!D.startsWith("xoxc-"))throw Error(`The draft API requires a desktop app session token (xoxc-).
131
+ Import from Slack desktop: slack auth login`);if((z==="invalid_auth"||z==="not_authed")&&!E)throw Error(`drafts.list also requires the xoxd session cookie.
132
+ Attach it with: slack auth chrome (macOS) or slack auth firefox`);throw Error(`Slack error on ${u}: ${z}`)}return $}function ju(D,u,F={},E){let B=new URLSearchParams({token:D,...F});return d7(D,u,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:B.toString()},E)}function uD(D,u,F,E){let B=new URLSearchParams(F).toString();return k1(D,`${u}?${B}`,{method:"GET"},E)}function wD(D,u,F,E){return k1(D,u,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(F)},E)}async function l0(D,u){let F=await uD(D,"auth.test",{},u);return{team:F.team??"",teamId:F.team_id??"",url:F.url??"",user:F.user??"",userId:F.user_id??""}}async function i1(D,u){let F={Authorization:`Bearer ${D}`};if(u)F.Cookie=`d=${u}`;let E=await fetch(`${i0()}/auth.test`,{method:"GET",headers:F});if(E.status===429){let $=parseInt(E.headers.get("retry-after")??"60",10);throw new wu(isNaN($)?60:$)}let B=E.headers.get("x-oauth-scopes")??"",C=await E.json();if(C.ok!==!0)throw Error(`Slack error on auth.test: ${C.error??"unknown"}`);return{userId:C.user_id??"",user:C.user??"",botId:C.bot_id??"",team:C.team??"",url:C.url??"",scopes:B.split(",").map(($)=>$.trim()).filter(Boolean)}}async function iu(D,u,F=20,E,B,C){let $={channel:u,limit:String(F)};if(E!==void 0)$.oldest=E;if(B!==void 0)$.cursor=B;return uD(D,"conversations.history",$,C)}async function Mu(D,u,F,E=50,B){return uD(D,"conversations.replies",{channel:u,ts:F,limit:String(E)},B)}async function l1(D,u,F){return uD(D,"files.info",{file:u},F)}async function n1(D,u={},F){let E={count:String(Math.min(Math.max(u.count??100,1),200)),page:String(Math.max(u.page??1,1))};if(u.types)E.types=u.types;if(u.channel)E.channel=u.channel;if(u.user)E.user=u.user;return uD(D,"files.list",E,F)}async function t1(D,u,F={},E){let B={list_id:u};if(F.limit)B.limit=String(F.limit);if(F.cursor)B.cursor=F.cursor;return ju(D,"lists.records.list",B,E)}async function o1(D,u,F,E,B){return uD(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))},B)}async function s1(D,u,F){return o1(D,u,100,1,F)}async function n0(D,u,F,E){let C=1,$=[],z={ok:!0,messages:{}};while(!0){let J=await o1(D,u,100,C,E),X=ku(J,["messages","matches"]),G=Array.isArray(X)?X:[];$.push(...G);let Y=Number(ku(J,["messages","paging","pages"])??1);if(z=J,G.length===0||C>=Y||$.length>=F)break;C+=1}let Z=z;if(!Z.messages)Z.messages={};return Z.messages.matches=$.slice(0,F),Z}async function r1(D,u,F,E,B,C){let $={channel:u,text:F,blocks:[{type:"markdown",text:F}]};if(E!==void 0)$.thread_ts=E;if(B&&E!==void 0)$.reply_broadcast=!0;return(await wD(D,"chat.postMessage",$,C)).ts??""}async function a1(D,u,F,E,B,C){let $={channel:u,text:F,post_at:E,blocks:[{type:"markdown",text:F}]};if(B!==void 0)$.thread_ts=B;return(await wD(D,"chat.scheduleMessage",$,C)).scheduled_message_id??""}async function e1(D,u,F){let E={};if(u)E.channel=u;return uD(D,"chat.scheduledMessages.list",E,F)}async function D3(D,u,F,E){await wD(D,"chat.deleteScheduledMessage",{channel:u,scheduled_message_id:F},E)}async function t0(D,u,F,E){return(await uD(D,"chat.getPermalink",{channel:u,message_ts:F},E)).permalink??""}async function u3(D,u,F,E,B){return(await wD(D,"chat.update",{channel:u,ts:F,text:E,blocks:[{type:"markdown",text:E}]},B)).ts??F}async function F3(D,u,F,E){await wD(D,"chat.delete",{channel:u,ts:F},E)}async function E3(D,u,F,E,B){await wD(D,"reactions.add",{channel:u,timestamp:F,name:E},B)}async function B3(D,u,F,E,B){await wD(D,"reactions.remove",{channel:u,timestamp:F,name:E},B)}async function C3(D,u,F=!1,E){let B=await wD(D,"conversations.create",{name:u,is_private:F},E);return{id:B.channel?.id??"",name:B.channel?.name??u}}async function $3(D,u,F,E){await wD(D,"conversations.invite",{channel:u,users:F.join(",")},E)}async function fF(D,u){let F=[],E="";while(!0){let B={limit:"200",types:"public_channel,private_channel,im,mpim"};if(E)B.cursor=E;let C=await uD(D,"conversations.list",B,u);if(F.push(...C.channels??[]),E=C.response_metadata?.next_cursor??"",!E)break}return{channels:F}}async function lu(D,u,F){let B=(await wD(D,"conversations.open",{users:u},F)).channel?.id;if(!B)throw Error(`Failed to open DM with user ${u}`);return B}function hD(D){return D.toLowerCase().replace(/[-_\s]/g,"")}async function o0(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=hD(u.slice(1)),B=await uD(D,"auth.test",{},F);if(E==="you"||E==="me"||hD(B.user??"")===E){if(!B.user_id)throw Error("auth.test did not return user_id");return B.user_id}let C="";while(!0){let $={limit:"200"};if(C)$.cursor=C;let z=await uD(D,"users.list",$,F);for(let Z of z.members??[]){let J=hD(Z.name??""),X=hD(Z.real_name??""),G=hD(Z.profile?.display_name??"");if(J===E||X===E||G&&G===E)return Z.id??""}if(C=z.response_metadata?.next_cursor??"",!C)break}throw Error(`User not found: ${u}`)}function nu(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,B=D.indexOf("?"),C=B>=0?new URLSearchParams(D.slice(B)):void 0,$=C?.get("thread_ts")??void 0,J={channel:C?.get("cid")??void 0??F};if(E)J.ts=E;if($)J.threadTs=$;return J}function k7(D){return nu(D)?.channel}async function VD(D,u,F){let E=k7(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 B=u.startsWith("@"),C=u.slice(1),$=hD(C);if(B){let J=await uD(D,"auth.test",{},F);if($==="you"||$==="me"||hD(J.user??"")===$){let H=J.user_id;if(!H)throw Error("auth.test did not return user_id");let K=((await uD(D,"conversations.list",{types:"im",limit:"200"},F)).channels??[]).find((N)=>N.user===H);if(K?.id)return String(K.id);return lu(D,H,F)}let G="",Y="";while(!0){let H={limit:"200"};if(Y)H.cursor=Y;let W=await uD(D,"users.list",H,F);for(let K of W.members??[]){let N=hD(K.name??""),M=hD(K.real_name??""),L=hD(K.profile?.display_name??"");if(N===$||M===$||L&&L===$){G=K.id??"";break}}if(G)break;if(Y=W.response_metadata?.next_cursor??"",!Y)break}if(!G)throw Error(`User not found: ${u}`);let V="";while(!0){let H={types:"im",limit:"200"};if(V)H.cursor=V;let W=await uD(D,"conversations.list",H,F);for(let K of W.channels??[])if(K.user===G)return String(K.id??"");if(V=W.response_metadata?.next_cursor??"",!V)break}throw Error(`No existing DM with ${u} (${G}). Open it once in Slack first.`)}let z=C.toLowerCase(),Z="";while(!0){let J={limit:"200",types:"public_channel,private_channel",exclude_archived:"true"};if(Z)J.cursor=Z;let X=await uD(D,"conversations.list",J,F);for(let G of X.channels??[])if(String(G.name??"").toLowerCase()===z)return String(G.id??"");if(Z=X.response_metadata?.next_cursor??"",!Z)break}throw Error(`channel not found: ${u}`)}async function tu(D,u,F){try{let E=await uD(D,"users.info",{user:u},F),B=E.user?.profile?.display_name,C=B&&B.length>0?B:E.user?.real_name??E.user?.name??u,$=E.user?.name??u;return[C,$]}catch{return[u,u]}}async function ou(D,u,F){try{let E=await uD(D,"users.info",{user:u},F),B=E.user?.profile?.display_name;if(B&&B.length>0)return B;return E.user?.real_name??E.user?.name??u}catch{return u}}async function s0(D,u){let F=[],E="";while(!0){let B={limit:"200"};if(E)B.cursor=E;let C=await uD(D,"users.list",B,u);if(F.push(...C.members??[]),E=C.response_metadata?.next_cursor??"",!E)break}return{members:F}}async function su(D,u){return ju(D,"drafts.list",{},u)}async function z3(D,u,F,E){let{randomUUID:B}=await import("node:crypto"),C=JSON.stringify([{type:"rich_text",elements:[{type:"rich_text_section",elements:[{type:"text",text:F}]}]}]);return ju(D,"drafts.create",{client_msg_id:B(),destinations:JSON.stringify([{channel_id:u}]),blocks:C,file_ids:JSON.stringify([]),is_from_composer:"true"},E)}async function Z3(D,u,F,E,B){let C=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:C,file_ids:JSON.stringify([])},B)}async function J3(D,u,F){return ju(D,"conversations.info",{channel:u},F)}async function r0(D,u,F){return uD(D,"users.info",{user:u},F)}async function a0(D,u,F){return uD(D,"conversations.info",{channel:u},F)}async function G3(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 e0(D,u){let F=await ju(D,"auth.test",{},u);return{userId:String(F.user_id??""),teamId:String(F.team_id??"")}}async function X3(D,u,F,E={},B){let{statSync:C,readFileSync:$}=await import("node:fs"),{basename:z}=await import("node:path"),Z=C(F),J=z(F),X=await uD(D,"files.getUploadURLExternal",{filename:J,length:String(Z.size)},B),G=X.upload_url,Y=X.file_id;if(!G||!Y)throw Error("files.getUploadURLExternal returned no upload_url/file_id");let V=$(F),H=await fetch(G,{method:"POST",headers:{"Content-Type":"application/octet-stream"},body:V});if(!H.ok)throw Error(`Upload PUT failed: ${H.status} ${H.statusText}`);let W={files:[{id:Y,title:E.title??J}],channel_id:u};if(E.threadTs)W.thread_ts=E.threadTs;if(E.initialComment)W.initial_comment=E.initialComment;let K=await wD(D,"files.completeUploadExternal",W,B),N={fileId:Y},M=K.files?.[0]?.permalink;if(M)N.permalink=M;return N}function ku(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}import{existsSync as D9,readFileSync as u9}from"node:fs";import{homedir as F9}from"node:os";import{join as E9}from"node:path";import{existsSync as i7,mkdirSync as l7,readFileSync as n7,writeFileSync as t7}from"node:fs";import{homedir as o7}from"node:os";import{dirname as s7,join as r7}from"node:path";var a7=3600000,hF={now:()=>Date.now(),path:()=>r7(process.env.HOME||o7(),".config","slack-cli","cache.json")},vF=!0,rD;function Q3(){return{channels:{},users:{}}}function D2(){if(rD)return rD;if(rD=Q3(),!vF)return rD;try{let D=hF.path();if(!i7(D))return rD;let u=JSON.parse(n7(D,"utf8"));for(let F of["channels","users"]){let E=u?.[F];if(!E||typeof E!=="object"||Array.isArray(E))continue;for(let[B,C]of Object.entries(E))if(C&&typeof C==="object"&&typeof C.value==="string"&&typeof C.expires==="number")rD[F][B]={value:C.value,expires:C.expires}}}catch{rD=Q3()}return rD}function e7(D){if(!vF)return;try{let u=hF.path();l7(s7(u),{recursive:!0}),t7(u,JSON.stringify(D,null,2)+`
133
+ `)}catch{}}function Y3(D,u){return D?`${D} ${u}`:void 0}function u2(D,u,F){if(!vF)return;let E=Y3(u,F);if(!E)return;let B=D2()[D][E];if(!B)return;if(B.expires<=hF.now()){delete D2()[D][E];return}return B.value}function F2(D,u,F,E,B=a7){if(!vF)return;let C=Y3(u,F);if(!C)return;let $=D2();$[D][C]={value:E,expires:hF.now()+B},e7($)}var E2={marker:"pushpin",progress:{done:"white_check_mark",dropped:"no_entry_sign",doing:"eyes",pending:"hourglass_flowing_sand"},flags:{alert:"exclamation","needs-discussion":"question",waiting:"speech_balloon",blocked:"lock"}},xu=["done","dropped","doing","pending"],H3=["alert","needs-discussion","waiting","blocked"];function B9(){return E9(process.env.HOME||F9(),".config","slack-cli","todo.json")}function yF(D){return D.replace(/^:+|:+$/g,"")}function ru(D=B9()){let u={marker:E2.marker,progress:{...E2.progress},flags:{...E2.flags}};try{if(!D9(D))return u;let F=JSON.parse(u9(D,"utf8"));if(typeof F.marker==="string"&&F.marker.trim())u.marker=yF(F.marker.trim());for(let E of xu){let B=F.progress?.[E];if(typeof B==="string"&&B.trim())u.progress[E]=yF(B.trim())}for(let E of H3){let B=F.flags?.[E];if(typeof B==="string"&&B.trim())u.flags[E]=yF(B.trim())}}catch{}return u}function W3(D,u,F=!1){return`${F?"-":""}${u?"has":"hasmy"}::${yF(D)}:`}function q3(D,u,F={}){let E=F.shared===!0,B=(z)=>W3(z,E),C=(z)=>W3(z,E,!0),$=[];if(D==="untriaged")$.push(B(u.marker),...xu.map((z)=>C(u.progress[z])));else if(D==="stuck")$.push(B(u.marker),C(u.progress.done),C(u.progress.dropped),`(${H3.map((z)=>B(u.flags[z])).join(" OR ")})`);else if(D==="open")$.push(B(u.marker),C(u.progress.done),C(u.progress.dropped));else{let z=xu.indexOf(D);$.push(B(u.progress[D]));for(let Z of xu.slice(0,z))$.push(C(u.progress[Z]))}if(F.in){let z=F.in.startsWith("#")||F.in.startsWith("@")?F.in:`#${F.in}`;$.push(`in:${z}`)}if(F.from){let z=F.from==="me"||F.from.startsWith("@")?F.from:`@${F.from}`;$.push(`from:${z}`)}return $.join(" ")}var C9=3,$9={sleep:(D)=>new Promise((u)=>setTimeout(u,D))};async function _D(D,u,F=C9){for(let E=0;;E++)try{return await u()}catch(B){if(!(B instanceof fD))throw B;if(E>=F)throw Error(`Slack rate limit hit on ${D} — gave up after ${F} retries. Try again in a minute.`);console.error(`Warning: Slack rate limit hit on ${D} — backing off for ${B.retryAfter}s`),await $9.sleep(B.retryAfter*1000)}}var V3=new Map;async function K3(D,u){let F=V3.get(D);if(F)return F;let E=await _D("auth.test",()=>Su(D,u)),B={userId:E.userId,teamId:E.teamId};return V3.set(D,B),B}async function O3(D,u){return(await K3(D,u)).userId}async function U3(D,u){try{return(await K3(D,u)).teamId}catch{return""}}async function B2(D,u,F,E){if(!u.startsWith("#"))return F(D,u,E);let B=await U3(D,E),C=u2("channels",B,u);if(C)return C;let $=await _D("resolveChannel",()=>F(D,u,E));return F2("channels",B,u,$),$}async function j3(D,u,F,E){let B=await U3(D,E),C=u2("users",B,u);if(C)return C;let $=await _D("users.info",()=>F(D,u,E));if($&&$!==u)F2("users",B,u,$);return $}async function M3(D,u,F,E,B,C){let $=B.progress[E],z=await O3(D,C),Z=await _D("reactions.get",()=>G1(D,u,F,C)),J=new Set(Z.filter((V)=>V.users.includes(z)).map((V)=>V.name)),X=xu.map((V)=>B.progress[V]).filter((V)=>J.has(V));if(X.length===1&&X[0]===$)return{noop:!0,removed:[],leftover:[]};if(!J.has($))await _D("reactions.add",()=>MF(D,u,F,$,C));let G=[],Y=[];for(let V of X){if(V===$)continue;try{await _D("reactions.remove",()=>_F(D,u,F,V,C)),G.push(V)}catch{Y.push(V)}}return{noop:!1,added:E,removed:G,leftover:Y}}async function _3(D,u,F,E,B,C,$){let z=B.flags[E];if(C)await _D("reactions.remove",()=>_F(D,u,F,z,$));else await _D("reactions.add",()=>MF(D,u,F,z,$));return z}var C2=1000;async function N3(D,u,F,E={}){let B=E.limit??C2,C=E.cookie,$=await O3(D,C),z=xu.map((Y)=>F.progress[Y]),Z=[],J=0,X,G=!1;while(J<B){let Y=Math.min(200,B-J),V=await _D("conversations.history",()=>cu(D,u,Y,void 0,X,C)),H=V.messages??[];J+=H.length;for(let W of H){let K=String(W.ts??"");if(!K)continue;let N=new Set((W.reactions??[]).filter((L)=>(L.users??[]).map(String).includes($)).map((L)=>String(L.name??""))),M=z.filter((L)=>N.has(L));if(M.length<2)continue;Z.push({ts:K,text:String(W.text??"").split(`
134
+ `)[0]??"",emoji:M,keep:M[0]})}if(X=V.response_metadata?.next_cursor||void 0,!X||H.length===0)break;if(J>=B){G=!0;break}}if(E.fix)for(let Y of Z)try{try{await _D("reactions.add",()=>MF(D,u,Y.ts,Y.keep,C))}catch(V){if(!(V instanceof Error)||!/already_reacted/.test(V.message))throw V}for(let V of Y.emoji){if(V===Y.keep)continue;await _D("reactions.remove",()=>_F(D,u,Y.ts,V,C))}Y.fixed=!0}catch(V){Y.fixed=!1,Y.error=V instanceof Error?V.message:String(V)}return{scanned:J,findings:Z,truncated:G}}var z9=!0,Z9;function A3(D){if(z9=D,!D)Z9=void 0}function _u(D){return D.toLowerCase().replace(/[-_\s]/g,"")}function aD(D){return D&&typeof D==="object"&&!Array.isArray(D)?D:{}}function J9(D,u){let F=_u(u),E=aD(D.profile);for(let C of[D.name,D.real_name,E.display_name,E.real_name])if(typeof C==="string"&&C&&_u(C)===F)return!0;let B=typeof E.email==="string"?E.email.toLowerCase():"";return B!==""&&B===u.toLowerCase()}function G9(D){let u=aD(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 B=_u(E);if(B.length>=2)F.add(B)}return[...F]}function X9(D,u){let F=_u(D),E,B=!1;for(let C of u){let $=typeof C.id==="string"?C.id:"";if(!$)continue;for(let z of G9(C)){let Z=-1;if(F===z)Z=D.length;else for(let J of T3)if(D.length>J.length&&D.endsWith(J)&&_u(D.slice(0,D.length-J.length))===z){Z=D.length-J.length;break}if(Z<0)continue;if(!E||z.length>E.formLen)E={userId:$,matchLen:Z,formLen:z.length,display:G2(C)},B=!1;else if(z.length===E.formLen&&E.userId!==$)B=!0}}if(!E)return;return B?"ambiguous":{userId:E.userId,matchLen:E.matchLen,display:E.display}}async function z2(D,u,F,E){let B=`[${R3}ー]+`,C=`${B}(?:[._-]+${B})*`,$=new RegExp(`(?<![A-Za-z0-9._@<-])@(${C})`,"gu"),z=new Set;for(let M of u.matchAll($))z.add(M[1]);if(z.size===0)return{text:u,resolved:[],unresolved:[]};let Z=new Map;for(let M of z)Z.set(M,{status:"pending"});let J=(M)=>{for(let L of z){if(Z.get(L).status!=="pending")continue;if(J2(L)){let j=X9(L,M);if(j==="ambiguous")Z.set(L,{status:"ambiguous"});else if(j)Z.set(L,{status:"resolved",userId:j.userId,matchLen:j.matchLen,display:j.display})}else{let j=M.filter((y)=>J9(y,L)),T=new Set(j.map((y)=>typeof y.id==="string"?y.id:"").filter(Boolean));if(T.size===1){let y=j.find((k)=>typeof k.id==="string");Z.set(L,{status:"resolved",userId:y.id,matchLen:L.length,display:G2(y)})}else if(T.size>1)Z.set(L,{status:"ambiguous"})}}},X=!1;try{let M=await LF(D,E);J((M.members??[]).map(aD)),X=!0}catch{X=!1}let G=[...z].some((M)=>Z.get(M).status==="pending"),Y=!1,V=!0;if(G&&F){Y=!0;try{let M=await x0(D,F,E),L=[];for(let j of M){let T=aD(await I0(D,j,E)),y=aD(T.user);if(typeof y.id!=="string")y.id=j;L.push(y)}J(L)}catch{V=!1}}let H=X&&(F?Y&&V:!0),W=[],K=[];for(let M of z){let L=Z.get(M);if(L.status==="resolved")W.push({surface:`@${M.slice(0,L.matchLen)}`,display:L.display,userId:L.userId});else if(L.status==="ambiguous")K.push({surface:`@${M}`,reason:"ambiguous"});else K.push({surface:`@${M}`,reason:H?"no-match":"unavailable"})}return{text:u.replace($,(M,L)=>{let j=Z.get(L);if(j&&j.status==="resolved")return`<@${j.userId}>${L.slice(j.matchLen)}`;return M}),resolved:W,unresolved:K}}function Z2(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 L3(D,u,F,E={}){let B=E.warn??(($)=>process.stderr.write(`${$}
135
+ `)),C=await z2(D,u,F,E.cookie);for(let $ of Z2(C.unresolved))B(`warn: ${$}`);return C.text}var T3=["さん","さま","様","君","くん","ちゃん","氏","先生","先輩","殿","老师","老師","兄","姐","哥","姐妹"],R3="\\p{Script=Han}\\p{Script=Hiragana}\\p{Script=Katakana}A-Za-z0-9";function J2(D){return/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}]/u.test(D)}function Q9(D){let u=[],F=new RegExp(`([${R3}]{1,12})(${T3.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 Y9(D){let u=aD(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 B of[E,...E.split(/\s+/)]){let C=_u(B);if(C.length>=2)F.add(C)}}return[...F]}function W9(D,u){let F=_u(D);if(F.length<2)return;for(let E of u)if(F===E)return E;if(J2(D)){for(let E of u)if(F.includes(E)||E.includes(F))return E}return}function G2(D){return[aD(D.profile).display_name,D.real_name,D.name].filter((E)=>typeof E==="string"&&E!=="")[0]??String(D.id??"?")}async function P3(D,u,F){let E=Q9(u);if(E.length===0)return[];let B=new Set;for(let J of u.matchAll(/<@([A-Z0-9]+)(?:\|[^>]*)?>/g))B.add(J[1]);let $=((await LF(D,F)).members??[]).map(aD).filter((J)=>J.deleted!==!0&&J.is_bot!==!0&&J.id!=="USLACKBOT").map((J)=>({id:typeof J.id==="string"?J.id:"",forms:Y9(J),display:G2(J)})).filter((J)=>J.id!==""),z=[],Z=new Set;for(let{ref:J,honorific:X}of E)for(let G of $){let Y=W9(J,G.forms);if(!Y)continue;if(B.has(G.id)||Z.has(G.id))break;Z.add(G.id),z.push({surface:J2(J)?`${Y}${X}`:J,display:G.display,userId:G.id});break}return z}async function Iu(D,u,F,E){let B=u,C=[],$=B,z=0;while(!0){let Z=$.indexOf("<@U",z);if(Z===-1)break;let J=$.slice(Z+2),X=J.search(/[>|]/),G=X===-1?J:J.slice(0,X);if(G.length>=9)C.push(G);z=Z+1}for(let Z of C){if(!F.has(Z))F.set(Z,await AF(D,Z,E));let J=F.get(Z)??Z;B=B.replaceAll(`<@${Z}>`,`@${J}`),B=B.replace(new RegExp(`<@${Z}\\|[^>]*>`,"g"),`@${J}`)}return B}function au(D){return D.replace(/<!date\^(\d+)\^[^|>]*(?:\|([^>]*))?>/g,(u,F,E)=>{let B=Number(F);if(!Number.isFinite(B))return E??"date";let C=new Date(B*1000);if(Number.isNaN(C.getTime()))return E??"date";let $=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],z=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Z=$[C.getUTCDay()]??"",J=z[C.getUTCMonth()]??"";return`${Z}, ${J} ${String(C.getUTCDate()).padStart(2,"0")}, ${C.getUTCFullYear()}`})}function S3(D,u=new Date){let F=new Date(D*1000),E=$2(u),B=$2(new Date(u.getTime()-86400000)),C=$2(F);if(C===E)return"Today";if(C===B)return"Yesterday";let $=F.toLocaleDateString("en-US",{weekday:"long"}),z=F.toLocaleDateString("en-US",{month:"short"});return`${$}, ${z} ${String(F.getDate()).padStart(2,"0")}`}function $2(D){return`${D.getFullYear()}-${D.getMonth()}-${D.getDate()}`}function w3(D){let u=new Date(D*1000),F=u.getFullYear(),E=String(u.getMonth()+1).padStart(2,"0"),B=String(u.getDate()).padStart(2,"0"),C=String(u.getHours()).padStart(2,"0"),$=String(u.getMinutes()).padStart(2,"0");return`${F}-${E}-${B} ${C}:${$}`}function eu(D){if(!f3(D))return;let u=H9(D,"utf8");for(let F of u.split(`
136
+ `)){let E=F.trim();if(!E||E.startsWith("#"))continue;let B=E.indexOf("=");if(B===-1)continue;let C=E.slice(0,B).trim(),$=E.slice(B+1).trim();if($.startsWith('"')&&$.endsWith('"')||$.startsWith("'")&&$.endsWith("'"))$=$.slice(1,-1);if(!(C in process.env))process.env[C]=$}}function K9(D){q9(D,{recursive:!0});let u=eD(D,".gitignore");if(!f3(u))h3(u,`*
137
+ `)}function O9(){eu(eD(x3(),".slack-cli",".env.local")),eu(eD(x3(),".config/slack-cli",".env")),eu(eD(process.cwd(),".slack-cli",".env.local")),eu(eD(process.cwd(),".env.local")),eu(eD(process.cwd(),".env"))}function U9(D){return V9("sha256").update(D).digest("hex")}function h(D){return D&&typeof D==="object"&&!Array.isArray(D)?D:{}}function t(D){return Array.isArray(D)?D:[]}function pF(D){return Number(D.ts??0)}async function v3(D,u,F){let E=u.user;if(typeof E==="string"){if(!F.has(E))F.set(E,await ou(D,E));return F.get(E)??E}return typeof u.username==="string"?u.username:"bot"}function X2(D){let u=new Date(D*1000),F=u.getUTCFullYear(),E=String(u.getUTCMonth()+1).padStart(2,"0"),B=String(u.getUTCDate()).padStart(2,"0"),C=String(u.getUTCHours()).padStart(2,"0"),$=String(u.getUTCMinutes()).padStart(2,"0"),z=String(u.getUTCSeconds()).padStart(2,"0");return`${F}-${E}-${B} ${C}:${$}:${z}`}function Y2(D){let[u,F="000000"]=D.split("."),E=Number(u),B=new Date(E*1000),C=B.getUTCFullYear(),$=String(B.getUTCMonth()+1).padStart(2,"0"),z=String(B.getUTCDate()).padStart(2,"0"),Z=String(B.getUTCHours()).padStart(2,"0"),J=String(B.getUTCMinutes()).padStart(2,"0"),X=String(B.getUTCSeconds()).padStart(2,"0"),G=F.padEnd(6,"0").slice(0,6);return`${C}-${$}-${z}T${Z}:${J}:${X}.${G}`}function W2(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 j9(D){return/^\d{4}-\d{2}-\d{2}T/.test(D)?W2(D):D}async function gF(D,u,F,E,B){let C=typeof u.ts==="string"?u.ts:`${pF(u)}.000000`,$=Y2(C),z="?";if(typeof u.user==="string"){let M=u.user,L="@"+M;if(!F.has(L)){let j=await j3(D,M,async(T,y,k)=>(await tu(T,y,k))[1],B);F.set(L,j)}z=F.get(L)??M}else if(typeof u.username==="string")z=u.username;let Z=typeof u.text==="string"?u.text:"",X=au(await Iu(D,Z,F,B)).split(`
138
+ `),G=X[0]+(X.length>1?`
139
+ `+X.slice(1).map((M)=>` ${M}`).join(`
140
+ `):""),Y=E?`${E} @${z}`:`@${z}`,V=t(u.reactions).map(h).map((M)=>{let L=typeof M.name==="string"?M.name:"",j=Number(M.count??t(M.users).length??0);return L?`:${L}:\xD7${j}`:""}).filter(Boolean).join(" "),H=t(u.files).map(h).map((M)=>{let L=typeof M.name==="string"?M.name:typeof M.title==="string"?M.title:"(file)",j=typeof M.size==="number"?` (${cF(M.size)})`:"",T=typeof M.id==="string"?` [${M.id}]`:"";return`
141
+ \uD83D\uDCCE ${L}${j}${T}`}).join(""),W=Number(u.reply_count??0),K=W>0?` [+${W} ${W===1?"reply":"replies"}]`:"",N=(V?`
142
+ ${V}`:"")+H;return`${$} ${Y}: ${G}${K}${N}`}function cF(D){return D<1024?`${D} B`:D<1048576?`${(D/1024).toFixed(1)} KB`:`${(D/1048576).toFixed(1)} MB`}function M9(D){return t(D.files).map(h).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 y3(D){let u=M9(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:"",...D.reply_count!==void 0?{reply_count:D.reply_count}:{},...D.reply_users_count!==void 0?{reply_users_count:D.reply_users_count}:{},...D.latest_reply!==void 0?{latest_reply:D.latest_reply}:{},...u.length>0?{files:u}:{}}}async function _9(D,u,F,E,B){let C=[];for(let $ of F){let z=$;if(Number($.reply_count??0)>0&&typeof $.ts==="string"){let Z=await Mu(D,u,$.ts,200,B),J=t(Z.messages).map(h);z=J[J.length-1]??$}if(z.user!==E)C.push($)}return C}async function N9(D,u,F,E="text",B=!1,C){let $=nu(u),z=await VD(D,u,C),Z=new Map,X=await(async()=>{if($?.threadTs){let Y=await Mu(D,z,$.threadTs,F,C);return t(Y.messages).map(h)}let G=await iu(D,z,F,void 0,void 0,C);return t(G.messages).map(h).reverse()})();if(B){let{userId:G}=await l0(D,C);X=await _9(D,z,X,G,C)}if(E==="jsonl"){for(let G of X)console.log(JSON.stringify(y3(G)));return}for(let G of X)console.log(await gF(D,G,Z,void 0,C))}async function A9(D,u,F,E,B="text",C){let $=await VD(D,u,C),z=await Mu(D,$,j9(F),E,C),Z=t(z.messages).map(h);if(B==="jsonl"){for(let X of Z)console.log(JSON.stringify(y3(X)));return}let J=new Map;for(let X of Z)console.log(await gF(D,X,J,void 0,C))}async function L9(D){let u=await fF(D),F=t(u.channels).map(h).filter((B)=>B.is_member===!0).sort((B,C)=>Number(C.updated??0)-Number(B.updated??0)).slice(0,10),E=new Map;for(let B of F){let C=String(B.id??""),$=typeof B.name==="string"?B.name:typeof B.user==="string"?B.user:C,z=await iu(D,C,5),Z=t(z.messages).map(h).filter((J)=>J.subtype===void 0||J.subtype===null).filter((J)=>{let X=typeof J.text==="string"?J.text:"";return X.length>0&&!X.startsWith("<@")}).slice(0,3).reverse();if(Z.length===0)continue;console.log(`-- #${$} --------------------------------`);for(let J of Z){let X=await v3(D,J,E),G=(typeof J.text==="string"?J.text:"").split(`
143
+ `)[0]??"",Y=await Iu(D,G,E);console.log(` ${X}: ${Y}`)}}}async function T9(D,u){let F=await s1(D,"to:me"),E=t(ku(F,["messages","matches"])).map(h).slice(0,u),B=new Map,C=[];for(let $ of E){let z=S3(pF($)),Z=C[C.length-1];if(Z?.label===z)Z.msgs.push($);else C.push({label:z,msgs:[$]})}for(let $=0;$<C.length;$++){let{label:z,msgs:Z}=C[$];if($>0)console.log("");console.log(` ${z}`),console.log(" ----------------------------");for(let J of[...Z].reverse()){let X=h(J.channel),G=X.is_im===!0,Y=typeof X.name==="string"?X.name:"dm",V;if(G&&Y.startsWith("U")){let H="@"+Y;if(!B.has(H)){let[,W]=await tu(D,Y);B.set(H,W)}V=`@${B.get(H)??Y}`}else if(G)V=`@${Y}`;else V=`#${Y}`;console.log(await gF(D,J,B,V))}}}async function R9(D,u,F,E,B="text"){let C=await fF(D),$=t(C.channels).map(h).filter((z)=>E||z.is_member===!0).filter((z)=>{if(!F)return!0;return(typeof z.name==="string"?z.name:"").toLowerCase().includes(F.toLowerCase())}).sort((z,Z)=>Number(Z.updated??0)-Number(z.updated??0)).slice(0,u);if(B==="jsonl"){for(let z of $)console.log(JSON.stringify(z));return}for(let z of $){let Z=String(z.id??""),J=typeof z.name==="string"?z.name:typeof z.user==="string"?z.user:Z,X=z.is_im===!0,G=z.is_mpim===!0,Y=X||G?"@":"#",V=z.is_member===!0?"":" (not joined)",H=typeof h(z.purpose).value==="string"?String(h(z.purpose).value):"",W=H?` ${H.split(`
144
+ `)[0]?.slice(0,60)}`:"";console.log(`${Y}${J} ${Z}${V}${W}`)}}function P9(D){let u=(B)=>B.startsWith("xoxp-")||B.startsWith("xoxc-"),F=L0(),E=F.find((B)=>B.profile.token===D);if(!E)return;return F.find((B)=>u(B.profile.token)&&B.profile.teamId===E.profile.teamId)}async function p3(D,u,F,E,B){let C=D,$=B,z;try{z=await n0(C,u,F,$)}catch(X){let G=X instanceof Error?X.message:String(X);if(D.startsWith("xoxb-")&&G.includes("not_allowed_token_type")){let Y=P9(D);if(Y)console.error(`Note: search.messages needs a user token \u2014 the active profile is a bot token (xoxb-); falling back to profile "${Y.name}".`),C=Y.profile.token,$=Y.profile.cookie,z=await n0(C,u,F,$);else console.error(`Error: search requires a user token (xoxp-/xoxc-) \u2014 the active profile is a bot token (xoxb-), which Slack rejects for search.messages.
143
145
  `+` Add a user-token profile: slack auth login (or slack auth token)
144
- Then select it: slack auth use <name> (or pass --workspace <name>)`),process.exit(1)}else throw Y}if(E){console.log(JSON.stringify(G,null,2));return}let z=o(yu(G,["messages","matches"])).map(p),Z=new Map;for(let Y of z){let J=p(Y.channel),Q=J.is_im===!0,O=typeof J.name==="string"?J.name:"dm",V;if(Q&&O.startsWith("U")){let W="@"+O;if(!Z.has(W)){let[,K]=await gu(B,O,$);Z.set(W,K)}V=`@${Z.get(W)??O}`}else if(Q)V=`@${O}`;else V=`#${O}`;console.log(await TF(B,Y,Z,V))}}async function P7(D,u,F,E){let C=Math.floor(Date.now()/1000)-u*86400,B=await AF(D),$=o(B.channels).map(p).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 pu(D,J,F)}catch(W){console.error(` SKIP #${Q}: ${W.message}`);continue}let V=o(O.messages).map(p).filter((W)=>(W.subtype===void 0||W.subtype===null)&&LF(W)>=C);if(V.length===0)continue;Z+=1,z+=V.length,console.log(`## #${Q} (${V.length} msgs)
145
- `);for(let W of[...V].reverse()){let K=await F3(D,W,G),A=typeof W.text==="string"?W.text:"",L=iu(await Tu(D,A,G)).split(`
146
- `).join(" \u21B5 ");console.log(`[${o1(LF(W))}] ${K}: ${L}`)}console.log("")}console.error(`Dumped ${z} messages across ${Z} channels (cutoff: ${u}d)`)}function w7(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 C3(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 c1(D,C,u),$=p(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 l0(D){let u=p(o(D.destinations)[0]);return String(u.channel_id??D.channel_id??D.channel??"")}function NF(D){return w7(o(D.blocks))||(typeof D.text==="string"?D.text:"(no text)")}async function x7(D,u,F=!1){let E=await du(D,u),C=o(E.drafts??E.messages??[]).map(p).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 v0(D,u))}catch{}let G=await C3(D,u,$),z=new Map;for(let Z of B){let Y=l0(Z),J=NF(Z),Q=Number(Z.date_created??Z.date_create??0),O=Q?k0(Q):"?",V=await G(Y),W=typeof Z.id==="string"?Z.id:"",K=Z.is_sent===!0?" [SENT]":"",A=iu(await Tu(D,J,z));console.log(`-- ${W} ${V} [${O}]${K}`);for(let _ of A.split(`
147
- `))console.log(` ${_}`)}}async function I7(D,u,F){let E=await du(D,u),C=o(E.drafts).map(p).find((V)=>String(V.id)===F);if(!C)console.error(`Draft not found: ${F}`),process.exit(1);let B="";try{({userId:B}=await v0(D,u))}catch{}let $=await C3(D,u,B),G=l0(C),z=NF(C),Z=Number(C.date_created??0),Y=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?k0(Z):"?"}`),console.log(`updated: ${k0(Number(Y.split(".")[0]))}`),console.log(`status: ${C.is_sent===!0?"sent":"pending"}`),console.log("---"),console.log(O)}function pD(...D){return U7(D.join(`
148
- `)).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 b7={"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 r1(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 ${b7[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 t0(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:n0(E)}}}return{ref:D}}function o0(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:n0(E)}}return{ref:D}}async function B3(D,u,F,E){let C=F;if(!F.startsWith("#")&&!F.startsWith("@"))try{let B=p(await h0(D,u,E)),$=p(B.channel);if($.is_im===!0){let G=typeof $.user==="string"?$.user:"";C=G?`@${await ku(D,G,E)}`:u}else C=typeof $.name==="string"?`#${$.name}`:u}catch{C=u}return C===u?u:`${C} (${u})`}async function d0(D,u,F=60,E){let C=typeof u.user==="string"?await ku(D,u.user,E):typeof u.username==="string"?u.username:"?",B=(typeof u.text==="string"?u.text:"").split(`
149
- `)[0]??"",$=B.length>F?`${B.slice(0,F)}\u2026`:B,G=typeof u.ts==="string"?u.ts:"";return`${G?i0(G).slice(0,16).replace("T"," "):""} @${C}${$?`: ${$}`:""}`}async function f7(D,u,F,E){let C=F.find((B)=>String(B.ts)===u)??F[0];if(!C)return u;return d0(D,C,40,E)}function a1(D){return D.toLowerCase().replace(/<[@#!][^>]+>/g," ").replace(/[^\p{L}\p{N}\s]/gu," ").replace(/\s+/g," ").trim()}function h7(D,u){let F=a1(D),E=a1(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=e1(B)+e1($);return z===0?0:2*G/z}function e1(D){let u=0;for(let F of D.values())u+=F;return u}async function v7(D,u){let{ref:F,ts:E}=t0(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 HD(D,F,u.cookie);let B=await Nu(D,C,E,1,u.cookie),G=o(B.messages).map(p).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 d1(D,u.newText,C,u.cookie?{cookie:u.cookie}:{}):u.newText,Y=pD(z,Z);if(u.code!==Y)fD(u.code,Y,["--- Original message -------------------------",...z.split(`
150
- `).map((Q)=>` ${Q}`),"--- Replacing with ---------------------------",...Z.split(`
151
- `).map((Q)=>` ${Q}`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);let J=await I1(D,C,E,Z,u.cookie);console.log(`\u2713 Edited (ts: ${J})`)}async function y7(D,u){let{ref:F,ts:E}=t0(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 HD(D,F,u.cookie);let B=await Nu(D,C,E,1,u.cookie),G=o(B.messages).map(p).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=pD(C,E,z);if(u.code!==Z){let Y=await B3(D,C,F,u.cookie);fD(u.code,Z,["--- Deleting message -------------------------",` \u2192 ${Y} at ${i0(E)}`,...z.split(`
152
- `).map((J)=>` ${J}`),"---------------------------------------------"])}await b1(D,C,E,u.cookie),console.log(`\u2713 Deleted (ts: ${E})`)}async function p7(D,u){let{ref:F,ts:E}=t0(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 HD(D,F,u.cookie);if(u.remove)await h1(D,B,E,C,u.cookie),console.log(`\u2713 Removed :${C}: (ts: ${E})`);else await f1(D,B,E,C,u.cookie),console.log(`\u2713 Reacted :${C}: (ts: ${E})`)}async function m7(D,u,F){if(!u.startsWith("@"))return!1;let E=u.slice(1).toLowerCase().replace(/[^a-z0-9]/g,"");if(E==="me"||E==="you")return!0;try{let B=((await M1(D,F)).user??"").toLowerCase().replace(/[^a-z0-9]/g,"");return B!==""&&B===E}catch{return!1}}async function c7(D,u){let{ref:F,threadTs:E}=o0(u.target),C=u.cookie;if(!u.asBot&&!u.channelId&&!u.userId&&await m7(D,F,C))console.error(`Warning: "${F}" is a DM to yourself \u2014 Slack will NOT notify you of your own message.
153
- `+` To reach yourself with a notification, send as the bot: slack send '${F}' '...' --as-bot`);let B;if(u.channelId)B=u.channelId;else if(u.userId)B=await mu(D,u.userId,C);else B=await HD(D,F,C);let $=u.message,G=null;if(u.mentions){G=await p0(u.mentionToken??D,u.message,B,u.mentionCookie),$=G.text;for(let _ of m0(G.unresolved))console.error(`\u26A0 ${Ru(_)}`)}try{for(let _ of await l1(u.mentionToken??D,$,u.mentionCookie))console.error(`\u26A0 possible untagged mention: ${Ru(_.surface)} \u2014 @${Ru(_.display)} won't be notified (did you mean <@${_.userId}>?)`)}catch{}let z=[];if(G&&(G.resolved.length>0||G.unresolved.length>0)){z.push("--- Mentions ---------------------------------");for(let _ of G.resolved)z.push(` \u2713 ${Ru(_.surface)} \u2192 @${Ru(_.display)} (${_.userId}) \u2014 will notify`);for(let _ of G.unresolved){let L=_.reason==="ambiguous"?"ambiguous":_.reason==="unavailable"?"lookup unavailable":"no match";z.push(` \u26A0 ${Ru(_.surface)} \u2014 plain text, NOT notified (${L})`)}}let Z="",Y="?",J=[],Q,O,V;if(E)try{let _=await Nu(D,B,E,100,C);J=o(_.messages).map(p);let L=J[J.length-1];Z=typeof L?.text==="string"?L.text:"",Q=typeof L?.user==="string"?L.user:void 0,O=typeof L?.bot_id==="string"?L.bot_id:void 0,V=typeof L?.ts==="string"?L.ts:void 0}catch{}else try{let _=await pu(D,B,1,void 0,void 0,C),L=o(_.messages).map(p),M=L.filter((k)=>k.subtype===void 0||k.subtype===null)[0];Z=typeof M?.text==="string"?M.text:"",Y=typeof M?.user==="string"?await ku(D,M.user,C):typeof M?.username==="string"?M.username:"?";let x=L[0];Q=typeof x?.user==="string"?x.user:void 0,O=typeof x?.bot_id==="string"?x.bot_id:void 0,V=typeof x?.ts==="string"?x.ts:void 0}catch{}if(process.env.SLACK_UNREPLIED_WARN!=="0"&&V&&(Q||O))try{let _=await A1(D,C);if(!!Q&&!!_.userId&&_.userId===Q||!!O&&!!_.botId&&_.botId===O){let M=`slack edit "#${B}:${V}" "<\u65B0\u3057\u3044\u672C\u6587>" --channel-id ${B}`;try{let x=await x0(D,B,V,C);if(x)M=`slack edit "${x}" "<\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(` ${M}`),console.error(" \u3053\u306E\u307E\u307E\u9001\u4FE1\u3059\u308B\u5834\u5408\u306F --code=XXXX \u3067\u78BA\u5B9A\u3002")}}catch{}if(E&&J.length){let _={sim:0,msg:null};for(let L of J){let M=typeof L.text==="string"?L.text:"";if(!M)continue;let x=h7($,M);if(x>_.sim)_={sim:x,msg:L}}if(_.msg&&_.sim>=0.82){let L=Math.round(_.sim*100);console.error(`\u26A0 possible duplicate: ${L}% similar to an existing thread message \u2014 ${await d0(D,_.msg,60,C)}`)}}let W=pD(B,E??"",Z,$);if(u.code!==W){let _=await B3(D,B,F,C);if(E){let L=await f7(D,E,J,C),M=J.slice(-3),x=M.length?await Promise.all(M.map(async(k)=>` ${await d0(D,k,60,C)}`)):[" (thread context unavailable)"];fD(u.code,W,["--- Recent messages in thread ----------------",...x,...z,"--- Sending ----------------------------------",` \u2192 ${_} thread of ${L} \u2014 THREAD REPLY`,` Message: ${$}`,"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"])}else fD(u.code,W,["--- Last message in channel ------------------",` ${Y}: ${Z.split(`
154
- `)[0]?.slice(0,100)??"(empty)"}`,...z,"--- Sending ----------------------------------",` \u2192 ${_} \u2014 NEW top-level message`,` Message: ${$}`,"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"])}let K=await S1(D,B,$,E,u.broadcast,C),A="";try{A=await x0(D,B,K,C)}catch{}if(A)console.log(`\u2713 Sent: ${A}`);else console.log(`\u2713 Sent (ts: ${K})`);if(u.asBot&&B.startsWith("D"))try{let _=await K0(D);if(!_.ok)for(let L of U0(_,!0))console.error(L);else{let L=_.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: ${L} \u2192 App Home.`)}}catch{}}async function g7(D){let u=await K0(D);for(let F of U0(u,!1))console.log(F);if(!u.ok)process.exit(1)}function k7(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 d7(D,u){let{ref:F,threadTs:E}=o0(u.target),C;if(u.channelId)C=u.channelId;else if(u.userId)C=await mu(D,u.userId,u.cookie);else C=await HD(D,F,u.cookie);let B=k7(u.at),$=new Date(B*1000).toISOString(),G=pD(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 P1(D,C,u.message,B,E,u.cookie);console.log(`\u2713 Scheduled (id: ${z}, at: ${$})`)}async function i7(D,u,F,E){let C;if(F)C=F;else if(u)C=await HD(D,u,E);let $=(await w1(D,C,E)).scheduled_messages??[];if($.length===0){console.log("(no scheduled messages)");return}for(let G of $){let z=new Date(G.post_at*1000).toISOString();console.log(`${G.id} ${z} [${G.channel_id}] ${G.text.split(`
155
- `)[0]?.slice(0,80)??""}`)}}async function n7(D,u){let F;if(u.channelId)F=u.channelId;else F=await HD(D,u.target,u.cookie);let E=pD(F,u.id);if(u.code!==E)fD(u.code,E,["--- Deleting scheduled message ---------------",` Channel: ${u.target}`,` ID: ${u.id}`,"---------------------------------------------"]);await x1(D,F,u.id,u.cookie),console.log(`\u2713 Deleted scheduled message ${u.id}`)}async function l7(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:$}=o0(u.target),G;if(u.channelId)G=u.channelId;else if(u.userId)G=await mu(D,u.userId,u.cookie);else G=await HD(D,B,u.cookie);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:RF(F(Q).size)}}),Y=pD(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:K}=await k1(D,G,O.fp,V,u.cookie),A=J>1?`[${Q+1}/${J}] `:"";console.log(`${A}\u2713 Uploaded (file_id: ${W}${K?`, url: ${K}`:""})`)}}async function t7(D,u,F){let E=F.channel?await HD(D,F.channel,u):void 0,C=[],B=1,$=1;do{let z={page:B,count:200};if(F.types)z.types=F.types;if(E)z.channel=E;if(F.user)z.user=F.user;let Z=p(await N1(D,z,u));for(let Y of o(Z.files))C.push(p(Y));$=Number(p(Z.paging).pages??1),B++}while(C.length<F.limit&&B<=$);let G=C.slice(0,F.limit);if(F.format==="jsonl"){for(let z of G)console.log(JSON.stringify({id:z.id??null,name:z.name??z.title??null,filetype:z.filetype??null,size:z.size??null,user:z.user??null,created:z.created??null,permalink:z.permalink??null}));return}for(let z of G){let Z=String(z.id??""),Y=typeof z.name==="string"?z.name:typeof z.title==="string"?z.title:Z,J=typeof z.filetype==="string"?z.filetype:"?",Q=typeof z.size==="number"?RF(z.size):"";console.log(`${Z} ${J.padEnd(7)} ${Q.padStart(9)} ${Y}`)}}function o7(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 s7(D,u,F,E){let C=o7(F);if(!C)throw Error(`Not a file ID or file permalink: ${F}
156
- `+"Expected F\u2026 or https://<ws>.slack.com/files/<UID>/<FID>/<name>");let B=p(await L1(D,C,u)),$=p(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=oD(E,V(G));u3(W,J),console.log(`\u2713 Downloaded ${G} (${RF(J.length)}) \u2192 ${W}`)}async function r7(){K7();let D=(F)=>Q0(F.workspace),u=(F)=>y8(F.workspace);await w8(kF(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{Q0(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:
157
- `),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 M7(E,F.target,F.limit,C);else await L7(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 A7(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 T7(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=u(E),$=E.channel,G=$.startsWith("#")||$.startsWith("@")||$.startsWith("C")||$.startsWith("G")||$.startsWith("D")?$:`#${$}`,z=await HD(C,G,B),Z=p(await h0(C,z,B)),Y=p(Z.channel),J=typeof Y.name==="string"?Y.name:z,O=Y.is_im===!0?"@":"#",V=String(p(Y.purpose).value??""),W=String(p(Y.topic).value??""),K=Y.num_members??Y.member_count??"";if(console.log(`${O}${J} ${z}`),W)console.log(`topic: ${W}`);if(V)console.log(`purpose: ${V}`);if(K)console.log(`members: ${K}`);console.log(`private: ${Y.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=u(E),$=E.name.replace(/^#/,"").toLowerCase(),G=E.private===!0,z=E.invite.filter(Boolean),Z=pD($,String(G),z.join(","));if(E.code!==Z)fD(E.code,Z,["--- Creating channel -------------------------",` name: ${G?"\uD83D\uDD12 ":"#"}${$}`,` private: ${G}`,...z.length?[` invite: ${z.join(", ")}`]:[],"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);let Y;try{Y=await v1(C,$,G,B)}catch(J){console.error(J instanceof Error?J.message:String(J)),process.exit(1)}if(console.log(`\u2713 Created ${G?"\uD83D\uDD12 ":"#"}${Y.name} (${Y.id})`),z.length){let J=[];for(let Q of z)try{J.push(Q.startsWith("U")||Q.startsWith("W")?Q:await I0(C,Q,B))}catch(O){console.error(` ! could not resolve ${Q}: ${O instanceof Error?O.message:String(O)}`)}for(let Q of J)try{let O=p(await f0(C,Q,B)),V=p(O.user);if(V.is_ultra_restricted===!0)console.error(`\u26A0 ${Q} is a single-channel guest \u2014 Slack restricts them to their one existing channel; this invite will likely report success but not actually add them.`);else if(V.is_restricted===!0)console.error(`\u26A0 ${Q} is a multi-channel guest \u2014 double-check they were actually added (guest invites can silently no-op depending on workspace restrictions).`)}catch{}if(J.length)try{await y1(C,Y.id,J,B),console.log(`\u2713 Invited ${J.length} member${J.length===1?"":"s"}`)}catch(Q){console.error(` ! invite failed: ${Q instanceof Error?Q.message:String(Q)}`)}}}).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 b0(D(E)),$=E.filter?.toLowerCase(),G=o(B.members).map(p).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(p(Z.profile).real_name??"").toLowerCase(),Q=String(p(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(`
146
+ Then select it: slack auth use <name> (or pass --workspace <name>)`),process.exit(1)}else throw X}if(E){console.log(JSON.stringify(z,null,2));return}let Z=t(ku(z,["messages","matches"])).map(h),J=new Map;for(let X of Z){let G=h(X.channel),Y=G.is_im===!0,V=typeof G.name==="string"?G.name:"dm",H;if(Y&&V.startsWith("U")){let W="@"+V;if(!J.has(W)){let[,K]=await tu(C,V,$);J.set(W,K)}H=`@${J.get(W)??V}`}else if(Y)H=`@${V}`;else H=`#${V}`;console.log(await gF(C,X,J,H,$))}}async function m3(D,u,F,E){let{ref:B,ts:C}=dF(u);if(!C)console.error("Error: target must embed a message ts (e.g. #chan:1700000000.000100 or a Slack permalink URL)"),process.exit(2);return{channelId:F??await B2(D,B,VD,E),ts:C}}async function S9(D,u){let F=ru(),E={};if(u.shared)E.shared=!0;if(u.in)E.in=u.in;if(u.from)E.from=u.from;let B=q3(u.state,F,E);if(!u.json)console.error(`(query: ${B})`);await _D("search.messages",()=>p3(D,B,u.count,u.json,u.cookie))}async function w9(D,u){let F=ru(),{channelId:E,ts:B}=await m3(D,u.target,u.channelId,u.cookie),C=await M3(D,E,B,u.state,F,u.cookie);if(C.noop){console.log(`= Already ${u.state} (ts: ${B})`);return}let $=C.removed.length?`, removed ${C.removed.map((z)=>`:${z}:`).join(" ")}`:"";if(console.log(`\u2713 ${u.state} :${F.progress[u.state]}: (ts: ${B})${$}`),C.leftover.length)console.error(`\u26A0 ${C.leftover.map((z)=>`:${z}:`).join(" ")} could not be removed \u2014 this message now carries more than one `+"progress reaction. Readers collapse by priority so nothing is lost; repair with: slack todo doctor --in <#chan> --fix")}async function x9(D,u){let F=ru(),{channelId:E,ts:B}=await m3(D,u.target,u.channelId,u.cookie),C=await _3(D,E,B,u.flag,F,u.remove===!0,u.cookie);console.log(`\u2713 ${u.remove?"Cleared":"Flagged"} ${u.flag} :${C}: (ts: ${B})`)}async function I9(D,u){let F=ru(),E=u.channelId??await B2(D,u.channel,VD,u.cookie),B={limit:u.limit};if(u.fix)B.fix=!0;if(u.cookie)B.cookie=u.cookie;let C=await N3(D,E,F,B);if(C.findings.length===0)console.log(`\u2713 No multi-state tasks in ${C.scanned} message(s).`);else{for(let $ of C.findings){let z=$.fixed===!0?"fixed":$.fixed===!1?`FAILED: ${$.error??"?"}`:"needs --fix";console.log(`${$.ts} ${$.emoji.map((Z)=>`:${Z}:`).join(" ")} \u2192 keep :${$.keep}: [${z}] ${cD($.text).slice(0,60)}`)}console.log(`${C.findings.length} multi-state task(s) in ${C.scanned} message(s).`)}if(C.truncated)console.error(`\u26A0 Scan limit reached (${u.limit} messages) \u2014 older history was NOT checked. Raise it with --limit N.`)}async function b9(D,u,F,E){let B=Math.floor(Date.now()/1000)-u*86400,C=await fF(D),$=t(C.channels).map(h).filter((X)=>X.is_member===!0&&X.is_im!==!0&&X.is_mpim!==!0).filter((X)=>{if(!E)return!0;return(typeof X.name==="string"?X.name:"").toLowerCase().includes(E.toLowerCase())}).sort((X,G)=>Number(G.updated??0)-Number(X.updated??0)),z=new Map,Z=0,J=0;for(let X of $){let G=String(X.id??""),Y=typeof X.name==="string"?X.name:G,V;try{V=await iu(D,G,F)}catch(W){console.error(` SKIP #${Y}: ${W.message}`);continue}let H=t(V.messages).map(h).filter((W)=>(W.subtype===void 0||W.subtype===null)&&pF(W)>=B);if(H.length===0)continue;J+=1,Z+=H.length,console.log(`## #${Y} (${H.length} msgs)
147
+ `);for(let W of[...H].reverse()){let K=await v3(D,W,z),N=typeof W.text==="string"?W.text:"",L=au(await Iu(D,N,z)).split(`
148
+ `).join(" \u21B5 ");console.log(`[${w3(pF(W))}] ${K}: ${L}`)}console.log("")}console.error(`Dumped ${Z} messages across ${J} channels (cutoff: ${u}d)`)}function f9(D){let u=[];function F(E){if(typeof E==="string"){u.push(E);return}if(Array.isArray(E)){for(let B of E)F(B);return}if(E&&typeof E==="object"){let B=E;if(typeof B.text==="string"){u.push(B.text);return}if(Array.isArray(B.elements))F(B.elements);else if(Array.isArray(B.content))F(B.content)}}for(let E of D)F(E);return u.join("").trim()}async function g3(D,u,F){let E=new Map;return async(B)=>{if(!B)return"(unknown)";if(E.has(B))return E.get(B);try{let C=await J3(D,B,u),$=h(C.channel),z;if($.is_im===!0){let Z=typeof $.user==="string"?$.user:"";if(!Z||Z===F)z="@self";else{let[J]=await tu(D,Z);z=`@${J}`}}else z=`#${typeof $.name==="string"?$.name:B}`;return E.set(B,z),z}catch{return B}}}function V2(D){let u=h(t(D.destinations)[0]);return String(u.channel_id??D.channel_id??D.channel??"")}function mF(D){return f9(t(D.blocks))||(typeof D.text==="string"?D.text:"(no text)")}async function h9(D,u,F=!1){let E=await su(D,u),B=t(E.drafts??E.messages??[]).map(h).filter((J)=>J.is_deleted!==!0),C=F?B:B.filter((J)=>J.is_sent!==!0);if(C.length===0){console.log(F?"No drafts.":"No pending drafts. Run with --all to include sent.");return}let $="";try{({userId:$}=await e0(D,u))}catch{}let z=await g3(D,u,$),Z=new Map;for(let J of C){let X=V2(J),G=mF(J),Y=Number(J.date_created??J.date_create??0),V=Y?X2(Y):"?",H=await z(X),W=typeof J.id==="string"?J.id:"",K=J.is_sent===!0?" [SENT]":"",N=au(await Iu(D,G,Z));console.log(`-- ${W} ${H} [${V}]${K}`);for(let M of N.split(`
149
+ `))console.log(` ${M}`)}}async function v9(D,u,F){let E=await su(D,u),B=t(E.drafts).map(h).find((H)=>String(H.id)===F);if(!B)console.error(`Draft not found: ${F}`),process.exit(1);let C="";try{({userId:C}=await e0(D,u))}catch{}let $=await g3(D,u,C),z=V2(B),Z=mF(B),J=Number(B.date_created??0),X=String(B.last_updated_ts??"?"),G=await $(z),V=au(await Iu(D,Z,new Map));console.log(`id: ${B.id}`),console.log(`channel: ${G} (${z})`),console.log(`created: ${J?X2(J):"?"}`),console.log(`updated: ${X2(Number(X.split(".")[0]))}`),console.log(`status: ${B.is_sent===!0?"sent":"pending"}`),console.log("---"),console.log(V)}function dD(...D){return U9(D.join(`
150
+ `)).slice(0,4)}function cD(D){return D.replace(/\x1b\[[0-9;:?]*[ -/]*[@-~]/g,"").replace(/[\x00-\x1f\x7f-\x9f]/g,"").replace(/[\u061c\u200e\u200f\u202a-\u202e\u2066-\u2069]/g,"")}var y9={"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 DF(D){let u=D instanceof Error?D.message:String(D),F=u.match(/Slack error on (\S+): (\w+)/);if(!F)return u;let[,E,B]=F;switch(B){case"missing_scope":return`Error: token lacks the ${y9[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 vD(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 dF(D){let u=nu(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:W2(E)}}}return{ref:D}}function H2(D){let u=nu(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:W2(E)}}return{ref:D}}async function c3(D,u,F,E){let B=F;if(!F.startsWith("#")&&!F.startsWith("@"))try{let C=h(await a0(D,u,E)),$=h(C.channel);if($.is_im===!0){let z=typeof $.user==="string"?$.user:"";B=z?`@${await ou(D,z,E)}`:u}else B=typeof $.name==="string"?`#${$.name}`:u}catch{B=u}return B===u?u:`${B} (${u})`}async function uF(D,u){try{return await i1(D,u)}catch{return null}}function FF(D,u){let F;return async()=>{if(F===void 0)F=await uF(D,u);return F}}function p9(D,u){let F=u?" [as bot]":"";if(!D)return`(unknown \u2014 auth.test failed)${F}`;let E=cD(D.user||D.userId||"?"),B=D.userId?` (${D.userId})`:"",C=D.team?` \u2014 ${cD(D.team)}`:"";return`@${E}${B}${C}${F}`}function yD(D,u={}){return` ${"From:".padEnd(u.pad??6)}${p9(D,u.asBot)}`}async function Q2(D,u,F=60,E){let B=typeof u.user==="string"?await ou(D,u.user,E):typeof u.username==="string"?u.username:"?",C=(typeof u.text==="string"?u.text:"").split(`
151
+ `)[0]??"",$=C.length>F?`${C.slice(0,F)}\u2026`:C,z=typeof u.ts==="string"?u.ts:"";return`${z?Y2(z).slice(0,16).replace("T"," "):""} @${B}${$?`: ${$}`:""}`}async function m9(D,u,F,E){let B=F.find((C)=>String(C.ts)===u)??F[0];if(!B)return u;return Q2(D,B,40,E)}function I3(D){return D.toLowerCase().replace(/<[@#!][^>]+>/g," ").replace(/[^\p{L}\p{N}\s]/gu," ").replace(/\s+/g," ").trim()}function g9(D,u){let F=I3(D),E=I3(u);if(!F||!E)return 0;if(F===E)return 1;let B=(J)=>{let X=new Map;for(let G=0;G<J.length-1;G++){let Y=J.slice(G,G+2);X.set(Y,(X.get(Y)??0)+1)}return X},C=B(F),$=B(E);if(C.size===0||$.size===0)return 0;let z=0;for(let[J,X]of C){let G=$.get(J);if(G)z+=Math.min(X,G)}let Z=b3(C)+b3($);return Z===0?0:2*z/Z}function b3(D){let u=0;for(let F of D.values())u+=F;return u}async function c9(D,u){let F=FF(D,u.cookie),{ref:E,ts:B}=dF(u.target);if(!B)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 VD(D,E,u.cookie);let $=await Mu(D,C,B,1,u.cookie),Z=t($.messages).map(h).find((H)=>String(H.ts)===B);if(!Z)console.error(`Message not found at ts=${B} in channel ${C}`),process.exit(1);let J=typeof Z.text==="string"?Z.text:"",X=u.mentions?await L3(D,u.newText,C,u.cookie?{cookie:u.cookie}:{}):u.newText,G=await F(),Y=dD(J,X,G?.userId??"");if(u.code!==Y)vD(u.code,Y,["--- Editing as -------------------------------",yD(G),"--- Original message -------------------------",...J.split(`
152
+ `).map((H)=>` ${H}`),"--- Replacing with ---------------------------",...X.split(`
153
+ `).map((H)=>` ${H}`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);let V=await u3(D,C,B,X,u.cookie);console.log(`\u2713 Edited (ts: ${V})`)}async function d9(D,u){let F=FF(D,u.cookie),{ref:E,ts:B}=dF(u.target);if(!B)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 VD(D,E,u.cookie);let $=await Mu(D,C,B,1,u.cookie),Z=t($.messages).map(h).find((Y)=>String(Y.ts)===B);if(!Z)console.error(`Message not found at ts=${B} in channel ${C}`),process.exit(1);let J=typeof Z.text==="string"?Z.text:"",X=await F(),G=dD(C,B,J,X?.userId??"");if(u.code!==G){let Y=await c3(D,C,E,u.cookie);vD(u.code,G,["--- Deleting message -------------------------",yD(X),` \u2192 ${Y} at ${Y2(B)}`,...J.split(`
154
+ `).map((V)=>` ${V}`),"---------------------------------------------"])}await F3(D,C,B,u.cookie),console.log(`\u2713 Deleted (ts: ${B})`)}async function k9(D,u){let{ref:F,ts:E}=dF(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 B=u.emoji.replace(/^:|:$/g,""),C;if(u.channelId)C=u.channelId;else C=await VD(D,F,u.cookie);if(u.remove)await B3(D,C,E,B,u.cookie),console.log(`\u2713 Removed :${B}: (ts: ${E})`);else await E3(D,C,E,B,u.cookie),console.log(`\u2713 Reacted :${B}: (ts: ${E})`)}async function i9(D,u,F){if(!u.startsWith("@"))return!1;let E=u.slice(1).toLowerCase().replace(/[^a-z0-9]/g,"");if(E==="me"||E==="you")return!0;try{let C=((await l0(D,F)).user??"").toLowerCase().replace(/[^a-z0-9]/g,"");return C!==""&&C===E}catch{return!1}}async function l9(D,u){let{ref:F,threadTs:E}=H2(u.target),B=u.cookie,C=FF(D,B);if(!u.asBot&&!u.channelId&&!u.userId&&await i9(D,F,B))console.error(`Warning: "${F}" is a DM to yourself \u2014 Slack will NOT notify you of your own message.
155
+ `+` To reach yourself with a notification, send as the bot: slack send '${F}' '...' --as-bot`);let $;if(u.channelId)$=u.channelId;else if(u.userId)$=await lu(D,u.userId,B);else $=await VD(D,F,B);let z=u.message,Z=null;if(u.mentions){Z=await z2(u.mentionToken??D,u.message,$,u.mentionCookie),z=Z.text;for(let j of Z2(Z.unresolved))console.error(`\u26A0 ${cD(j)}`)}try{for(let j of await P3(u.mentionToken??D,z,u.mentionCookie))console.error(`\u26A0 possible untagged mention: ${cD(j.surface)} \u2014 @${cD(j.display)} won't be notified (did you mean <@${j.userId}>?)`)}catch{}let J=[];if(Z&&(Z.resolved.length>0||Z.unresolved.length>0)){J.push("--- Mentions ---------------------------------");for(let j of Z.resolved)J.push(` \u2713 ${cD(j.surface)} \u2192 @${cD(j.display)} (${j.userId}) \u2014 will notify`);for(let j of Z.unresolved){let T=j.reason==="ambiguous"?"ambiguous":j.reason==="unavailable"?"lookup unavailable":"no match";J.push(` \u26A0 ${cD(j.surface)} \u2014 plain text, NOT notified (${T})`)}}let X="",G="?",Y=[],V,H,W;if(E)try{let j=await Mu(D,$,E,100,B);Y=t(j.messages).map(h);let T=Y[Y.length-1];X=typeof T?.text==="string"?T.text:"",V=typeof T?.user==="string"?T.user:void 0,H=typeof T?.bot_id==="string"?T.bot_id:void 0,W=typeof T?.ts==="string"?T.ts:void 0}catch{}else try{let j=await iu(D,$,1,void 0,void 0,B),T=t(j.messages).map(h),y=T.filter((QD)=>QD.subtype===void 0||QD.subtype===null)[0];X=typeof y?.text==="string"?y.text:"",G=typeof y?.user==="string"?await ou(D,y.user,B):typeof y?.username==="string"?y.username:"?";let k=T[0];V=typeof k?.user==="string"?k.user:void 0,H=typeof k?.bot_id==="string"?k.bot_id:void 0,W=typeof k?.ts==="string"?k.ts:void 0}catch{}if(process.env.SLACK_UNREPLIED_WARN!=="0"&&W&&(V||H))try{let j=await C();if(!!j&&(!!V&&!!j.userId&&j.userId===V||!!H&&!!j.botId&&j.botId===H)){let y=`slack edit "#${$}:${W}" "<\u65B0\u3057\u3044\u672C\u6587>" --channel-id ${$}`;try{let k=await t0(D,$,W,B);if(k)y=`slack edit "${k}" "<\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(` ${y}`),console.error(" \u3053\u306E\u307E\u307E\u9001\u4FE1\u3059\u308B\u5834\u5408\u306F --code=XXXX \u3067\u78BA\u5B9A\u3002")}}catch{}if(E&&Y.length){let j={sim:0,msg:null};for(let T of Y){let y=typeof T.text==="string"?T.text:"";if(!y)continue;let k=g9(z,y);if(k>j.sim)j={sim:k,msg:T}}if(j.msg&&j.sim>=0.82){let T=Math.round(j.sim*100);console.error(`\u26A0 possible duplicate: ${T}% similar to an existing thread message \u2014 ${await Q2(D,j.msg,60,B)}`)}}let K=await C(),N=dD($,E??"",X,z,K?.userId??"");if(u.code!==N){let j=await c3(D,$,F,B),T=yD(K,{asBot:u.asBot});if(E){let y=await m9(D,E,Y,B),k=Y.slice(-3),QD=k.length?await Promise.all(k.map(async(l)=>` ${await Q2(D,l,60,B)}`)):[" (thread context unavailable)"];vD(u.code,N,["--- Recent messages in thread ----------------",...QD,...J,"--- Sending ----------------------------------",T,` \u2192 ${j} thread of ${y} \u2014 THREAD REPLY`,` Message: ${z}`,"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"])}else vD(u.code,N,["--- Last message in channel ------------------",` ${G}: ${X.split(`
156
+ `)[0]?.slice(0,100)??"(empty)"}`,...J,"--- Sending ----------------------------------",T,` \u2192 ${j} \u2014 NEW top-level message`,` Message: ${z}`,"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"])}let M=await r1(D,$,z,E,u.broadcast,B),L="";try{L=await t0(D,$,M,B)}catch{}if(L)console.log(`\u2713 Sent: ${L}`);else console.log(`\u2713 Sent (ts: ${M})`);if(u.asBot&&$.startsWith("D"))try{let j=await b0(D);if(!j.ok)for(let T of f0(j,!0))console.error(T);else{let T=j.appId?`https://api.slack.com/apps/${j.appId}`:"https://api.slack.com/apps";console.error(`Note: if ${u.target} can't reply (app messaging may be off), enable Messages Tab: ${T} \u2192 App Home.`)}}catch{}}async function n9(D){let u=await b0(D);for(let F of f0(u,!1))console.log(F);if(!u.ok)process.exit(1)}function t9(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)}function o9(D){let u=new Date(D*1000);return`${new Intl.DateTimeFormat("sv-SE",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,timeZoneName:"short"}).format(u).replace(/\u2212/g,"-")} (local) / ${u.toISOString()} (Unix: ${D})`}async function s9(D,u){let F=FF(D,u.cookie),{ref:E,threadTs:B}=H2(u.target),C;if(u.channelId)C=u.channelId;else if(u.userId)C=await lu(D,u.userId,u.cookie);else C=await VD(D,E,u.cookie);let $=t9(u.at),z=new Date($*1000).toISOString(),Z=await F(),J=dD(C,u.message,String($),Z?.userId??"");if(u.code!==J)vD(u.code,J,["--- Scheduling message -----------------------",yD(Z,{pad:9}),` To: ${E}${B?` (thread ${B})`:""}`,` At: ${o9($)}`,` Message: ${u.message}`,"---------------------------------------------"]);let X=await a1(D,C,u.message,$,B,u.cookie);console.log(`\u2713 Scheduled (id: ${X}, at: ${z})`)}async function r9(D,u,F,E){let B;if(F)B=F;else if(u)B=await VD(D,u,E);let $=(await e1(D,B,E)).scheduled_messages??[];if($.length===0){console.log("(no scheduled messages)");return}for(let z of $){let Z=new Date(z.post_at*1000).toISOString();console.log(`${z.id} ${Z} [${z.channel_id}] ${z.text.split(`
157
+ `)[0]?.slice(0,80)??""}`)}}async function a9(D,u){let F;if(u.channelId)F=u.channelId;else F=await VD(D,u.target,u.cookie);let E=await uF(D,u.cookie),B=dD(F,u.id,E?.userId??"");if(u.code!==B)vD(u.code,B,["--- Deleting scheduled message ---------------",yD(E,{pad:9}),` Channel: ${u.target}`,` ID: ${u.id}`,"---------------------------------------------"]);await D3(D,F,u.id,u.cookie),console.log(`\u2713 Deleted scheduled message ${u.id}`)}async function e9(D,u){let F=FF(D,u.cookie),{statSync:E,existsSync:B}=await import("fs"),{basename:C}=await import("path");for(let H of u.filePaths)if(!B(H))console.error(`Error: file not found: ${H}`),process.exit(1);let{ref:$,threadTs:z}=H2(u.target),Z;if(u.channelId)Z=u.channelId;else if(u.userId)Z=await lu(D,u.userId,u.cookie);else Z=await VD(D,$,u.cookie);let J=u.filePaths.length>1,X=u.filePaths.map((H)=>{let W=C(H),K=J?W:u.title??W;return{fp:H,filename:W,title:K,sizeFmt:cF(E(H).size)}}),G=await F(),Y=dD(Z,...X.flatMap((H)=>[H.fp,H.title]),G?.userId??"");if(u.code!==Y){let H=` To: ${$}${z?` (thread ${z})`:""}`,W=J?[`--- Uploading ${X.length} files ------------------------`,yD(G,{pad:7}),H,...X.map((K)=>` ${K.filename} (${K.sizeFmt})`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]:["--- Uploading file ---------------------------",yD(G,{pad:7}),H,` File: ${X[0].fp}`,` Title: ${X[0].title}`,` Size: ${X[0].sizeFmt}`,"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"];vD(u.code,Y,W)}let V=X.length;for(let H=0;H<V;H++){let W=X[H],K={title:W.title};if(z!==void 0)K.threadTs=z;if(u.comment!==void 0&&H===0)K.initialComment=u.comment;let{fileId:N,permalink:M}=await X3(D,Z,W.fp,K,u.cookie),L=V>1?`[${H+1}/${V}] `:"";console.log(`${L}\u2713 Uploaded (file_id: ${N}${M?`, url: ${M}`:""})`)}}async function DE(D,u,F){let E=F.channel?await VD(D,F.channel,u):void 0,B=[],C=1,$=1;do{let Z={page:C,count:200};if(F.types)Z.types=F.types;if(E)Z.channel=E;if(F.user)Z.user=F.user;let J=h(await n1(D,Z,u));for(let X of t(J.files))B.push(h(X));$=Number(h(J.paging).pages??1),C++}while(B.length<F.limit&&C<=$);let z=B.slice(0,F.limit);if(F.format==="jsonl"){for(let Z of z)console.log(JSON.stringify({id:Z.id??null,name:Z.name??Z.title??null,filetype:Z.filetype??null,size:Z.size??null,user:Z.user??null,created:Z.created??null,permalink:Z.permalink??null}));return}for(let Z of z){let J=String(Z.id??""),X=typeof Z.name==="string"?Z.name:typeof Z.title==="string"?Z.title:J,G=typeof Z.filetype==="string"?Z.filetype:"?",Y=typeof Z.size==="number"?cF(Z.size):"";console.log(`${J} ${G.padEnd(7)} ${Y.padStart(9)} ${X}`)}}function uE(D){if(/^F[A-Z0-9]+$/i.test(D))return D;return D.match(/\/lists\/[A-Za-z0-9]+\/(F[A-Za-z0-9]+)/i)?.[1]??D.match(/\/lists\/(F[A-Za-z0-9]+)/i)?.[1]}function FE(D){if(typeof D.text==="string"&&D.text)return D.text;let u=D.value;if(typeof u==="string"||typeof u==="number"||typeof u==="boolean")return String(u);if(Array.isArray(u))return u.map((F)=>typeof F==="string"?F:String(h(F).text??h(F).name??h(F).value??"")).filter(Boolean).join(", ");for(let F of["rich_text","select","user","date","number","checkbox","email","phone"]){let E=D[F];if(E!=null)return typeof E==="object"?JSON.stringify(E):String(E)}return""}async function EE(D,u,F,E){let B=uE(F);if(!B)throw Error(`Not a list ID or list URL: ${F}
158
+ `+"Expected F\u2026 or https://<ws>.slack.com/lists/<TEAM>/<F-id>");let C=[],$;do{let Z={limit:200};if($)Z.cursor=$;let J=h(await t1(D,B,Z,u));for(let G of t(J.items??J.records))C.push(h(G));let X=h(J.response_metadata).next_cursor;$=typeof X==="string"&&X?X:void 0}while($&&C.length<E.limit);let z=C.slice(0,E.limit);if(E.format==="jsonl"){for(let Z of z)console.log(JSON.stringify(Z));return}for(let Z of z){let J=String(Z.id??""),X=t(Z.fields).map(h).map((G)=>{let Y=String(G.key??G.column_id??"?"),V=FE(G);return V?`${Y}=${V}`:""}).filter(Boolean);console.log(`${J} ${X.join(" | ")}`)}}function BE(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 CE(D,u,F,E){let B=BE(F);if(!B)throw Error(`Not a file ID or file permalink: ${F}
159
+ `+"Expected F\u2026 or https://<ws>.slack.com/files/<UID>/<FID>/<name>");let C=h(await l1(D,B,u)),$=h(C.file),z=typeof $.name==="string"?$.name:typeof $.title==="string"?$.title:B,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 ${B}`);let J={Authorization:`Bearer ${D}`};if(u)J.Cookie=`d=${u}`;let X=await fetch(Z,{headers:J});if(!X.ok)throw Error(`Download failed: HTTP ${X.status} ${X.statusText}`);let G=Buffer.from(await X.arrayBuffer()),{statSync:Y,existsSync:V}=await import("fs"),{basename:H}=await import("path"),W=E??z;if(E&&V(E)&&Y(E).isDirectory())W=eD(E,H(z));h3(W,G),console.log(`\u2713 Downloaded ${z} (${cF(G.length)}) \u2192 ${W}`)}async function $E(){O9();let D=(F)=>T0(F.workspace),u=(F)=>C1(F.workspace);await a8(B0(process.argv)).scriptName("slack").showHelpOnFail(!1).fail((F,E,B)=>{if(E)console.error(E.message),process.exit(1);console.error(F),console.error(""),B.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{T0(F.workspace)}catch(B){if((B instanceof Error?B.message:String(B)).startsWith("No profiles configured"))console.log(`No workspace configured. Let's set that up:
160
+ `),await xF(),process.exit(0);throw B}},!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"}).option("unreplied",{type:"boolean",default:!1,describe:"Only messages whose last word (incl. thread replies) is not yours \u2014 i.e. awaiting your answer"}),async(F)=>{let E=D(F),B=F.json?"jsonl":F.format;if(F.target)await N9(E,F.target,F.limit,B,F.unreplied,u(F));else await L9(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 A9(D(F),F.target,F.ts,F.limit,E,u(F))}).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 R9(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 B=D(E),C=u(E),$=E.channel,z=$.startsWith("#")||$.startsWith("@")||$.startsWith("C")||$.startsWith("G")||$.startsWith("D")?$:`#${$}`,Z=await VD(B,z,C),J=h(await a0(B,Z,C)),X=h(J.channel),G=typeof X.name==="string"?X.name:Z,V=X.is_im===!0?"@":"#",H=String(h(X.purpose).value??""),W=String(h(X.topic).value??""),K=X.num_members??X.member_count??"";if(console.log(`${V}${G} ${Z}`),W)console.log(`topic: ${W}`);if(H)console.log(`purpose: ${H}`);if(K)console.log(`members: ${K}`);console.log(`private: ${X.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 B=D(E),C=u(E),$=E.name.replace(/^#/,"").toLowerCase(),z=E.private===!0,Z=E.invite.filter(Boolean),J=await uF(B,C),X=dD($,String(z),Z.join(","),J?.userId??"");if(E.code!==X)vD(E.code,X,["--- Creating channel -------------------------",yD(J,{pad:9}),` name: ${z?"\uD83D\uDD12 ":"#"}${$}`,` private: ${z}`,...Z.length?[` invite: ${Z.join(", ")}`]:[],"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);let G;try{G=await C3(B,$,z,C)}catch(Y){console.error(Y instanceof Error?Y.message:String(Y)),process.exit(1)}if(console.log(`\u2713 Created ${z?"\uD83D\uDD12 ":"#"}${G.name} (${G.id})`),Z.length){let Y=[];for(let V of Z)try{Y.push(V.startsWith("U")||V.startsWith("W")?V:await o0(B,V,C))}catch(H){console.error(` ! could not resolve ${V}: ${H instanceof Error?H.message:String(H)}`)}for(let V of Y)try{let H=h(await r0(B,V,C)),W=h(H.user);if(W.is_ultra_restricted===!0)console.error(`\u26A0 ${V} is a single-channel guest \u2014 Slack restricts them to their one existing channel; this invite will likely report success but not actually add them.`);else if(W.is_restricted===!0)console.error(`\u26A0 ${V} is a multi-channel guest \u2014 double-check they were actually added (guest invites can silently no-op depending on workspace restrictions).`)}catch{}if(Y.length)try{await $3(B,G.id,Y,C),console.log(`\u2713 Invited ${Y.length} member${Y.length===1?"":"s"}`)}catch(V){console.error(` ! invite failed: ${V instanceof Error?V.message:String(V)}`)}}}).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 B=E.json?"jsonl":E.format,C=await s0(D(E)),$=E.filter?.toLowerCase(),z=t(C.members).map(h).filter((J)=>J.deleted!==!0&&J.is_bot!==!0&&String(J.id)!=="USLACKBOT").filter((J)=>{if(!$)return!0;let X=String(J.name??"").toLowerCase(),G=String(h(J.profile).real_name??"").toLowerCase(),Y=String(h(J.profile).email??"").toLowerCase();return X.includes($)||G.includes($)||Y.includes($)}).slice(0,E.limit);if(B==="jsonl"){for(let J of z)console.log(JSON.stringify(J));return}if(B==="yaml"){for(let J of z){let X=function(G,Y=""){if(G===null)return"null";if(typeof G==="string")return G.includes(`
158
161
  `)?`|
159
- ${J.split(`
162
+ ${G.split(`
160
163
  `).join(`
161
- `)}`:J;if(typeof J!=="object")return String(J);if(Array.isArray(J))return J.map((O)=>`
162
- ${Q} - ${Y(O,Q+" ")}`).join("");return Object.entries(J).map(([O,V])=>`
163
- ${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=p(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||""),K=String(Z.tz??""),_=[...new Set([O,V].filter((x)=>x&&x!==J))].join(" / "),M=[W,K&&K!==z?K:""].filter(Boolean).join(" ");console.log(`@${J} ${Q} ${_}${M?" "+M:""}`)}}).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 M=await b0(C),x=o(M.members).map(p).find((k)=>String(k.name??"")===B);if(!x)console.error(`User not found: @${B}`),process.exit(1);$=String(x.id)}let G=p(await f0(C,$)),z=p(G.user),Z=p(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||""),K=String(z.tz??""),A=String(Z.phone||""),_=String(Z.title||"");console.log(`@${J} ${Q}`);let L=[...new Set([O,V].filter((M)=>M&&M!==J))];if(L.length)console.log(`name: ${L.join(" / ")}`);if(W)console.log(`email: ${W}`);if(A)console.log(`phone: ${A}`);if(_)console.log(`title: ${_}`);if(K&&K!==Y)console.log(`tz: ${K}`)}).demandCommand(1,"").showHelpOnFail(!0)).command("news","Activity feed (mentions to you)",(F)=>F.option("limit",{alias:"l",type:"number",default:20}),async(F)=>{await N7(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 S7(D(F),F.query,F.count,F.json,u(F))}).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=Y0();if(!B)console.error(`Error: --as-bot needs a bot token, but no xoxb- token was found.
164
- 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 I0(D(F),E.target,u(F))}catch($){console.error(`Error: could not resolve ${E.target} to a user for the bot DM.
164
+ `)}`:G;if(typeof G!=="object")return String(G);if(Array.isArray(G))return G.map((V)=>`
165
+ ${Y} - ${X(V,Y+" ")}`).join("");return Object.entries(G).map(([V,H])=>`
166
+ ${Y} ${V}: ${X(H,Y+" ")}`).join("")};console.log("---");for(let[G,Y]of Object.entries(J))console.log(`${G}: ${X(Y)}`)}return}let Z=Intl.DateTimeFormat().resolvedOptions().timeZone;for(let J of z){let X=h(J.profile),G=String(J.name??J.id),Y=String(J.id??""),V=String(X.display_name||""),H=String(X.real_name||""),W=String(X.email||""),K=String(J.tz??""),M=[...new Set([V,H].filter((T)=>T&&T!==G))].join(" / "),j=[W,K&&K!==Z?K:""].filter(Boolean).join(" ");console.log(`@${G} ${Y} ${M}${j?" "+j:""}`)}}).command("get <user>","Show user details",(E)=>E.positional("user",{type:"string",demandOption:!0,describe:"@handle or user ID"}),async(E)=>{let B=D(E),C=E.user.startsWith("@")?E.user.slice(1):E.user,$=C;if(!/^U[A-Z0-9]+$/.test(C)){let j=await s0(B),T=t(j.members).map(h).find((y)=>String(y.name??"")===C);if(!T)console.error(`User not found: @${C}`),process.exit(1);$=String(T.id)}let z=h(await r0(B,$)),Z=h(z.user),J=h(Z.profile),X=Intl.DateTimeFormat().resolvedOptions().timeZone,G=String(Z.name??$),Y=String(Z.id??$),V=String(J.display_name||""),H=String(J.real_name||""),W=String(J.email||""),K=String(Z.tz??""),N=String(J.phone||""),M=String(J.title||"");console.log(`@${G} ${Y}`);let L=[...new Set([V,H].filter((j)=>j&&j!==G))];if(L.length)console.log(`name: ${L.join(" / ")}`);if(W)console.log(`email: ${W}`);if(N)console.log(`phone: ${N}`);if(M)console.log(`title: ${M}`);if(K&&K!==X)console.log(`tz: ${K}`)}).demandCommand(1,"").showHelpOnFail(!0)).command("news","Activity feed (mentions to you)",(F)=>F.option("limit",{alias:"l",type:"number",default:20}),async(F)=>{await T9(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 p3(D(F),F.query,F.count,F.json,u(F))}).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=u(F);if(C)E.mentionCookie=C}let B;if(F["as-bot"]){let C=R0();if(!C)console.error(`Error: --as-bot needs a bot token, but no xoxb- token was found.
167
+ 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 o0(D(F),E.target,u(F))}catch($){console.error(`Error: could not resolve ${E.target} to a user for the bot DM.
165
168
  ${$ instanceof Error?$.message:String($)}
166
- Tip: pass --user-id <Uxxxx> to skip the lookup.`),process.exit(1)}C=B,E.asBot=!0}else{C=D(F);let B=u(F);if(B)E.cookie=B}try{await c7(C,E)}catch(B){console.error(r1(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=Y0();if(!F)console.error(`Error: slack doctor checks the bot token, but no xoxb- token was found.
167
- Set SLACK_BOT_TOKEN=xoxb-... in ~/.config/slack-cli/.env (or your shell).`),process.exit(1);await g7(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"];let B=u(E);if(B)C.cookie=B;await d7(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 i7(D(E),E.target,E["channel-id"],u(E))}).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;let B=u(E);if(B)C.cookie=B;if(E["channel-id"])C.channelId=E["channel-id"];await n7(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;let C=u(F);if(C)E.cookie=C;await v7(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"];let C=u(F);if(C)E.cookie=C;await y7(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"];let C=u(F);if(C)E.cookie=C;try{await p7(D(F),E)}catch(B){console.error(r1(B)),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"];let C=u(F);if(C)E.cookie=C;await l7(D(F),E)}).command("files","File commands",(F)=>F.command(["ls","list"],"List files visible to you (files.list)",(E)=>E.option("limit",{alias:"l",type:"number",default:100,describe:"Max files to list"}).option("type",{alias:"t",type:"string",describe:"Slack type filter: images, pdfs, gdocs, snippets, zips, spaces, all"}).option("channel",{alias:"c",type:"string",describe:"Only files in this channel (#name, @user, ID, or permalink)"}).option("user",{alias:"u",type:"string",describe:"Only files from this raw user ID"}).option("format",{type:"string",choices:["text","jsonl"],default:"text"}).option("json",{type:"boolean",default:!1,describe:"Alias for --format=jsonl"}),async(E)=>{let C={limit:E.limit,format:E.json?"jsonl":E.format};if(E.type)C.types=E.type;if(E.channel)C.channel=E.channel;if(E.user)C.user=E.user;await t7(D(E),u(E),C)}).demandCommand(1,"").showHelpOnFail(!0),()=>{}).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 s7(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 P7(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 x7(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 HD(C,E.channel,B),z=await p1(C,G,$,B);console.log(`\u2713 Draft created (id: ${p(z.draft).id??"?"})`)}).command("get <id>","Show a draft",(E)=>E.positional("id",{type:"string",demandOption:!0}),async(E)=>{await I7(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=o(G.drafts).map(p).find((Q)=>String(Q.id)===E.id);if(!z)console.error(`Draft not found: ${E.id}`),process.exit(1);let Z=NF(z),Y=pD(Z,$);if(E.code!==Y)fD(E.code,Y,["--- Current draft ----------------------------",...Z.split(`
168
- `).map((Q)=>` ${Q}`),"--- Replacing with ---------------------------",...$.split(`
169
- `).map((Q)=>` ${Q}`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);let J=await m1(C,E.id,l0(z),$,B);console.log(`\u2713 Draft updated (id: ${p(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=o($.drafts).map(p).find((Y)=>String(Y.id)===E.id);if(!G)console.error(`Draft not found: ${E.id}`),process.exit(1);let z=NF(G),Z=pD(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(`
170
- `).map((Y)=>` ${Y}`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);await g1(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 Y1({...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 W1({...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=X0();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(oD(process.cwd(),".slack-cli"));v8(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)=>{h8(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 X1({...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 Q1({...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 _1(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()}r7().catch((D)=>{console.error(D instanceof Error?D.message:String(D)),process.exit(1)});
169
+ Tip: pass --user-id <Uxxxx> to skip the lookup.`),process.exit(1)}B=C,E.asBot=!0}else{B=D(F);let C=u(F);if(C)E.cookie=C}try{await l9(B,E)}catch(C){console.error(DF(C)),process.exit(1)}}).command("doctor","Check the bot token (xoxb) can carry a two-way DM (scopes + Messages Tab)",(F)=>F,async()=>{let F=R0();if(!F)console.error(`Error: slack doctor checks the bot token, but no xoxb- token was found.
170
+ Set SLACK_BOT_TOKEN=xoxb-... in ~/.config/slack-cli/.env (or your shell).`),process.exit(1);await n9(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 B={target:E.target,message:E.message,at:E.at};if(E.code)B.code=E.code;if(E["channel-id"])B.channelId=E["channel-id"];if(E["user-id"])B.userId=E["user-id"];let C=u(E);if(C)B.cookie=C;await s9(D(E),B)}).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 r9(D(E),E.target,E["channel-id"],u(E))}).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 B={target:E.target,id:E.id};if(E.code)B.code=E.code;let C=u(E);if(C)B.cookie=C;if(E["channel-id"])B.channelId=E["channel-id"];await a9(D(E),B)}).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;let B=u(F);if(B)E.cookie=B;await c9(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"];let B=u(F);if(B)E.cookie=B;await d9(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"];let B=u(F);if(B)E.cookie=B;try{await k9(D(F),E)}catch(C){console.error(DF(C)),process.exit(1)}}).command("todo","Reaction-backed task tracking (:pushpin: marks a task, progress lives in a second reaction)",(F)=>F.option("cache",{type:"boolean",default:!0,describe:"Use ~/.config/slack-cli/cache.json for channel/user lookups (--no-cache to bypass)"}).middleware((E)=>{if(E.cache===!1)A3(!1)}).command(["ls","list"],"List tasks (read-only; one search per run)",(E)=>E.option("state",{type:"string",choices:["open","untriaged","pending","doing","done","dropped","stuck"],default:"open",describe:"open (default) = marked and not done/dropped; untriaged = marked with no progress; stuck = unfinished with a reason flag"}).option("in",{type:"string",describe:"Limit to a channel (#chan)"}).option("from",{type:"string",describe:"Limit to a sender (@user, or 'me') \u2014 usually the person a task is waiting on"}).option("shared",{type:"boolean",default:!1,describe:"Match anyone's reactions (has:) instead of only yours (hasmy:)"}).option("n",{alias:"count",type:"number",default:50,describe:"Max results"}).option("json",{type:"boolean",default:!1}),async(E)=>{let B={state:E.state,count:E.n,json:E.json};if(E.in)B.in=E.in;if(E.from)B.from=E.from;if(E.shared)B.shared=!0;let C=u(E);if(C)B.cookie=C;await S9(D(E),B)}).command("set <target> <state>","Move a task to a progress state (adds the new reaction before removing the old one)",(E)=>E.positional("target",{type:"string",demandOption:!0,describe:"#chan:ts or permalink"}).positional("state",{type:"string",demandOption:!0,choices:["pending","doing","done","dropped"]}).option("channel-id",{type:"string",describe:"Raw channel ID"}),async(E)=>{let B={target:E.target,state:E.state};if(E["channel-id"])B.channelId=E["channel-id"];let C=u(E);if(C)B.cookie=C;try{await w9(D(E),B)}catch($){console.error(DF($)),process.exit(1)}}).command("flag <target> <flag>","Add (or --remove) a reason flag (alert | needs-discussion | waiting | blocked) \u2014 flags stack, independent of progress",(E)=>E.positional("target",{type:"string",demandOption:!0,describe:"#chan:ts or permalink"}).positional("flag",{type:"string",demandOption:!0,choices:["alert","needs-discussion","waiting","blocked"],describe:"waiting = the other party in this conversation owes a reply; blocked = stuck on something outside it"}).option("remove",{type:"boolean",default:!1,describe:"Remove the flag instead of adding it"}).option("channel-id",{type:"string",describe:"Raw channel ID"}),async(E)=>{let B={target:E.target,flag:E.flag};if(E.remove)B.remove=!0;if(E["channel-id"])B.channelId=E["channel-id"];let C=u(E);if(C)B.cookie=C;try{await x9(D(E),B)}catch($){console.error(DF($)),process.exit(1)}}).command("doctor","Find messages carrying two or more progress reactions (--fix repairs them)",(E)=>E.option("in",{type:"string",demandOption:!0,describe:"Channel to scan (#chan)"}).option("fix",{type:"boolean",default:!1,describe:"Repair findings (keeps the highest-priority state)"}).option("limit",{type:"number",default:C2,describe:"Max messages to scan"}).option("channel-id",{type:"string",describe:"Raw channel ID"}),async(E)=>{let B={channel:E.in,limit:E.limit};if(E.fix)B.fix=!0;if(E["channel-id"])B.channelId=E["channel-id"];let C=u(E);if(C)B.cookie=C;await I9(D(E),B)}).demandCommand(1,"Specify a todo subcommand (ls, set, flag, doctor)"),()=>{}).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"];let B=u(F);if(B)E.cookie=B;await e9(D(F),E)}).command("files","File commands",(F)=>F.command(["ls","list"],"List files visible to you (files.list)",(E)=>E.option("limit",{alias:"l",type:"number",default:100,describe:"Max files to list"}).option("type",{alias:"t",type:"string",describe:"Slack type filter: images, pdfs, gdocs, snippets, zips, spaces, all"}).option("channel",{alias:"c",type:"string",describe:"Only files in this channel (#name, @user, ID, or permalink)"}).option("user",{alias:"u",type:"string",describe:"Only files from this raw user ID"}).option("format",{type:"string",choices:["text","jsonl"],default:"text"}).option("json",{type:"boolean",default:!1,describe:"Alias for --format=jsonl"}),async(E)=>{let B={limit:E.limit,format:E.json?"jsonl":E.format};if(E.type)B.types=E.type;if(E.channel)B.channel=E.channel;if(E.user)B.user=E.user;await DE(D(E),u(E),B)}).demandCommand(1,"").showHelpOnFail(!0),()=>{}).command("lists <ref>","Read a Slack List's rows (by list URL or F-id) \u2014 read-only",(F)=>F.positional("ref",{type:"string",demandOption:!0,describe:"List URL (\u2026/lists/<TEAM>/<F-id>) or bare F-id"}).option("limit",{alias:"l",type:"number",default:100,describe:"Max rows to show"}).option("format",{type:"string",choices:["text","jsonl"],default:"text"}).option("json",{type:"boolean",default:!1,describe:"Alias for --format=jsonl (raw records)"}),async(F)=>{let E=F.json?"jsonl":F.format;try{await EE(D(F),u(F),F.ref,{limit:F.limit,format:E})}catch(B){console.error(DF(B)),process.exit(1)}}).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 CE(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 b9(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 h9(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 B=D(E),C=u(E),$=E.text.join(" ");if(!$)console.error("Usage: slack drafts new <#channel|@user> <text>"),process.exit(2);let z=await VD(B,E.channel,C),Z=await z3(B,z,$,C);console.log(`\u2713 Draft created (id: ${h(Z.draft).id??"?"})`)}).command("get <id>","Show a draft",(E)=>E.positional("id",{type:"string",demandOption:!0}),async(E)=>{await v9(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 B=D(E),C=u(E),$=E.text.join(" ");if(!$)console.error("Usage: slack drafts edit <id> <new-text>"),process.exit(2);let z=await su(B,C),Z=t(z.drafts).map(h).find((V)=>String(V.id)===E.id);if(!Z)console.error(`Draft not found: ${E.id}`),process.exit(1);let J=mF(Z),X=await uF(B,C),G=dD(J,$,X?.userId??"");if(E.code!==G)vD(E.code,G,["--- Editing draft as -------------------------",yD(X),"--- Current draft ----------------------------",...J.split(`
171
+ `).map((V)=>` ${V}`),"--- Replacing with ---------------------------",...$.split(`
172
+ `).map((V)=>` ${V}`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);let Y=await Z3(B,E.id,V2(Z),$,C);console.log(`\u2713 Draft updated (id: ${h(Y.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 B=D(E),C=u(E),$=await su(B,C),z=t($.drafts).map(h).find((G)=>String(G.id)===E.id);if(!z)console.error(`Draft not found: ${E.id}`),process.exit(1);let Z=mF(z),J=await uF(B,C),X=dD(E.id,Z,J?.userId??"");if(E.code!==X)vD(E.code,X,["\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",yD(J),` id: ${E.id}`,...Z.split(`
173
+ `).map((G)=>` ${G}`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);await G3(B,E.id,C),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 f1({...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 h1({...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 xF({...E.token!==void 0?{token:E.token}:{},...E.name!==void 0?{name:E.name}:{}})}).command(["ls","status"],"Show auth status",()=>{},()=>{let E=L0();if(E.length===0){console.log("No workspaces configured. Run: slack auth login");return}for(let{name:B,profile:C,current:$}of E)console.log(`${$?"* ":" "}${B} ${C.team} (${C.user}) ${C.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)K9(eD(process.cwd(),".slack-cli"));B1(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)=>{E1(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 I1({...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 b1({...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),B=u(F),C=new AbortController;process.on("SIGINT",()=>{C.abort(),process.exit(0)}),await d1(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}:{},...B!==void 0?{cookie:B}:{},...F.rtm===!1?{noRtm:!0}:{}},C.signal)}).command("login",!1,(F)=>F.option("token",{type:"string"}).option("name",{type:"string"}),async(F)=>{await xF({...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()}$E().catch((D)=>{console.error(D instanceof Error?D.message:String(D)),process.exit(1)});