slack-term 1.29.0 → 1.30.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -1,21 +1,21 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
- import{createRequire as Hc}from"node:module";var jc=Object.create;var{getPrototypeOf:Lc,defineProperty:Xi,getOwnPropertyNames:Wc}=Object;var Uc=Object.prototype.hasOwnProperty;function Jc(e){return this[e]}var Kc,zc,Gi=(e,t,n)=>{var i=e!=null&&typeof e==="object";if(i){var s=t?Kc??=new WeakMap:zc??=new WeakMap,r=s.get(e);if(r)return r}n=e!=null?jc(Lc(e)):{};let o=t||!e||!e.__esModule?Xi(n,"default",{value:e,enumerable:!0}):n;if(e&&typeof e==="object"||typeof e==="function"){for(let a of Wc(e))if(!Uc.call(o,a))Xi(o,a,{get:Jc.bind(e,a),enumerable:!0})}if(i)s.set(e,o);return o};var Vi=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var qe=Hc(import.meta.url);var gr=Vi(function(vd,hr){hr.exports=()=>/[#*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 Wr=Vi(function(Sp,Lr){Lr.exports=function(t){if(t===void 0)t=2;if(t>=Error.stackTraceLimit)throw TypeError("getCallerFile(position) requires position be less then Error.stackTraceLimit but position was: `"+t+"` and Error.stackTraceLimit was: `"+Error.stackTraceLimit+"`");var n=Error.prepareStackTrace;Error.prepareStackTrace=function(s,r){return r};var i=Error().stack;if(Error.prepareStackTrace=n,i!==null&&typeof i==="object")return i[t]?i[t].getFileName():void 0}});import{createHash as gf}from"crypto";import{existsSync as $c,readFileSync as mf,mkdirSync as Df,writeFileSync as Oc}from"fs";import{homedir as xc}from"os";import{join as ft}from"path";import{notStrictEqual as Iu,strictEqual as Tu}from"assert";var qc={right:Gc,center:Vc};class Qi{constructor(e){var t;this.width=e.width,this.wrap=(t=e.wrap)!==null&&t!==void 0?t:!0,this.rows=[]}span(...e){let t=this.div(...e);t.span=!0}resetOutput(){this.rows=[]}div(...e){if(e.length===0)this.div("");if(this.wrap&&this.shouldApplyLayoutDSL(...e)&&typeof e[0]==="string")return this.applyLayoutDSL(e[0]);let t=e.map((n)=>{if(typeof n==="string")return this.colFromString(n);return n});return this.rows.push(t),t}shouldApplyLayoutDSL(...e){return e.length===1&&typeof e[0]==="string"&&/[\t\n]/.test(e[0])}applyLayoutDSL(e){let t=e.split(`
4
- `).map((i)=>i.split("\t")),n=0;return t.forEach((i)=>{if(i.length>1&&xe.stringWidth(i[0])>n)n=Math.min(Math.floor(this.width*0.5),xe.stringWidth(i[0]))}),t.forEach((i)=>{this.div(...i.map((s,r)=>({text:s.trim(),padding:this.measurePadding(s),width:r===0&&i.length>1?n:void 0})))}),this.rows[this.rows.length-1]}colFromString(e){return{text:e,padding:this.measurePadding(e)}}measurePadding(e){let t=xe.stripAnsi(e);return[0,t.match(/\s*$/)[0].length,0,t.match(/^\s*/)[0].length]}toString(){let e=[];return this.rows.forEach((t)=>{this.rowToString(t,e)}),e.filter((t)=>!t.hidden).map((t)=>t.text).join(`
5
- `)}rowToString(e,t){return this.rasterize(e).forEach((n,i)=>{let s="";n.forEach((r,o)=>{let{width:a}=e[o],c=this.negatePadding(e[o]),u=r;if(c>xe.stringWidth(r))u+=" ".repeat(c-xe.stringWidth(r));if(e[o].align&&e[o].align!=="left"&&this.wrap){let l=qc[e[o].align];if(u=l(u,c),xe.stringWidth(u)<c)u+=" ".repeat((a||0)-xe.stringWidth(u)-1)}let f=e[o].padding||[0,0,0,0];if(f[3])s+=" ".repeat(f[3]);if(s+=Zi(e[o],u,"| "),s+=u,s+=Zi(e[o],u," |"),f[1])s+=" ".repeat(f[1]);if(i===0&&t.length>0)s=this.renderInline(s,t[t.length-1])}),t.push({text:s.replace(/ +$/,""),span:e.span})}),t}renderInline(e,t){let n=e.match(/^ */),i=n?n[0].length:0,s=t.text,r=xe.stringWidth(s.trimRight());if(!t.span)return e;if(!this.wrap)return t.hidden=!0,s+e;if(i<r)return e;return t.hidden=!0,s.trimRight()+" ".repeat(i-r)+e.trimLeft()}rasterize(e){let t=[],n=this.columnWidths(e),i;return e.forEach((s,r)=>{if(s.width=n[r],this.wrap)i=xe.wrap(s.text,this.negatePadding(s),{hard:!0}).split(`
3
+ import{createRequire as Xc}from"node:module";var Uc=Object.create;var{getPrototypeOf:Jc,defineProperty:Vi,getOwnPropertyNames:Kc}=Object;var zc=Object.prototype.hasOwnProperty;function Hc(e){return this[e]}var qc,Yc,Zi=(e,t,n)=>{var i=e!=null&&typeof e==="object";if(i){var s=t?qc??=new WeakMap:Yc??=new WeakMap,r=s.get(e);if(r)return r}n=e!=null?Uc(Jc(e)):{};let o=t||!e||!e.__esModule?Vi(n,"default",{value:e,enumerable:!0}):n;if(e&&typeof e==="object"||typeof e==="function"){for(let a of Kc(e))if(!zc.call(o,a))Vi(o,a,{get:Hc.bind(e,a),enumerable:!0})}if(i)s.set(e,o);return o};var Qi=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Ye=Xc(import.meta.url);var Dr=Qi(function(Ud,mr){mr.exports=()=>/[#*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 Jr=Qi(function(Op,Ur){Ur.exports=function(t){if(t===void 0)t=2;if(t>=Error.stackTraceLimit)throw TypeError("getCallerFile(position) requires position be less then Error.stackTraceLimit but position was: `"+t+"` and Error.stackTraceLimit was: `"+Error.stackTraceLimit+"`");var n=Error.prepareStackTrace;Error.prepareStackTrace=function(s,r){return r};var i=Error().stack;if(Error.prepareStackTrace=n,i!==null&&typeof i==="object")return i[t]?i[t].getFileName():void 0}});import{createHash as wf}from"crypto";import{existsSync as Tc,readFileSync as bf,mkdirSync as Ff,writeFileSync as Pc}from"fs";import{homedir as kc}from"os";import{join as dt}from"path";import{notStrictEqual as Ru,strictEqual as Mu}from"assert";var Gc={right:Qc,center:eu};class tr{constructor(e){var t;this.width=e.width,this.wrap=(t=e.wrap)!==null&&t!==void 0?t:!0,this.rows=[]}span(...e){let t=this.div(...e);t.span=!0}resetOutput(){this.rows=[]}div(...e){if(e.length===0)this.div("");if(this.wrap&&this.shouldApplyLayoutDSL(...e)&&typeof e[0]==="string")return this.applyLayoutDSL(e[0]);let t=e.map((n)=>{if(typeof n==="string")return this.colFromString(n);return n});return this.rows.push(t),t}shouldApplyLayoutDSL(...e){return e.length===1&&typeof e[0]==="string"&&/[\t\n]/.test(e[0])}applyLayoutDSL(e){let t=e.split(`
4
+ `).map((i)=>i.split("\t")),n=0;return t.forEach((i)=>{if(i.length>1&&Se.stringWidth(i[0])>n)n=Math.min(Math.floor(this.width*0.5),Se.stringWidth(i[0]))}),t.forEach((i)=>{this.div(...i.map((s,r)=>({text:s.trim(),padding:this.measurePadding(s),width:r===0&&i.length>1?n:void 0})))}),this.rows[this.rows.length-1]}colFromString(e){return{text:e,padding:this.measurePadding(e)}}measurePadding(e){let t=Se.stripAnsi(e);return[0,t.match(/\s*$/)[0].length,0,t.match(/^\s*/)[0].length]}toString(){let e=[];return this.rows.forEach((t)=>{this.rowToString(t,e)}),e.filter((t)=>!t.hidden).map((t)=>t.text).join(`
5
+ `)}rowToString(e,t){return this.rasterize(e).forEach((n,i)=>{let s="";n.forEach((r,o)=>{let{width:a}=e[o],c=this.negatePadding(e[o]),u=r;if(c>Se.stringWidth(r))u+=" ".repeat(c-Se.stringWidth(r));if(e[o].align&&e[o].align!=="left"&&this.wrap){let l=Gc[e[o].align];if(u=l(u,c),Se.stringWidth(u)<c)u+=" ".repeat((a||0)-Se.stringWidth(u)-1)}let f=e[o].padding||[0,0,0,0];if(f[3])s+=" ".repeat(f[3]);if(s+=er(e[o],u,"| "),s+=u,s+=er(e[o],u," |"),f[1])s+=" ".repeat(f[1]);if(i===0&&t.length>0)s=this.renderInline(s,t[t.length-1])}),t.push({text:s.replace(/ +$/,""),span:e.span})}),t}renderInline(e,t){let n=e.match(/^ */),i=n?n[0].length:0,s=t.text,r=Se.stringWidth(s.trimRight());if(!t.span)return e;if(!this.wrap)return t.hidden=!0,s+e;if(i<r)return e;return t.hidden=!0,s.trimRight()+" ".repeat(i-r)+e.trimLeft()}rasterize(e){let t=[],n=this.columnWidths(e),i;return e.forEach((s,r)=>{if(s.width=n[r],this.wrap)i=Se.wrap(s.text,this.negatePadding(s),{hard:!0}).split(`
6
6
  `);else i=s.text.split(`
7
- `);if(s.border)i.unshift("."+"-".repeat(this.negatePadding(s)+2)+"."),i.push("'"+"-".repeat(this.negatePadding(s)+2)+"'");if(s.padding)i.unshift(...Array(s.padding[0]||0).fill("")),i.push(...Array(s.padding[2]||0).fill(""));i.forEach((o,a)=>{if(!t[a])t.push([]);let c=t[a];for(let u=0;u<r;u++)if(c[u]===void 0)c.push("");c.push(o)})}),t}negatePadding(e){let t=e.width||0;if(e.padding)t-=(e.padding[3]||0)+(e.padding[1]||0);if(e.border)t-=4;return t}columnWidths(e){if(!this.wrap)return e.map((r)=>r.width||xe.stringWidth(r.text));let t=e.length,n=this.width,i=e.map((r)=>{if(r.width)return t--,n-=r.width,r.width;return}),s=t?Math.floor(n/t):0;return i.map((r,o)=>{if(r===void 0)return Math.max(s,Yc(e[o]));return r})}}function Zi(e,t,n){if(e.border){if(/[.']-+[.']/.test(t))return"";if(t.trim().length!==0)return n;return" "}return""}function Yc(e){let t=e.padding||[],n=1+(t[3]||0)+(t[1]||0);if(e.border)return n+4;return n}function Xc(){if(typeof process==="object"&&process.stdout&&process.stdout.columns)return process.stdout.columns;return 80}function Gc(e,t){e=e.trim();let n=xe.stringWidth(e);if(n<t)return" ".repeat(t-n)+e;return e}function Vc(e,t){e=e.trim();let n=xe.stringWidth(e);if(n>=t)return e;return" ".repeat(t-n>>1)+e}var xe;function er(e,t){return xe=t,new Qi({width:(e===null||e===void 0?void 0:e.width)||Xc(),wrap:e===null||e===void 0?void 0:e.wrap})}function ys({onlyFirst:e=!1}={}){return new RegExp("(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]",e?void 0:"g")}var Zc=ys();function dt(e){if(typeof e!=="string")throw TypeError(`Expected a \`string\`, got \`${typeof e}\``);if(!e.includes("\x1B")&&!e.includes("›"))return e;return e.replace(Zc,"")}var tr=161,nr=1114109,sr=[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],ir=12288,rr=65510,or=[12288,12288,65281,65376,65504,65510];var ar=4352,cr=262141,ws=[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 Cn=(e,t)=>{let n=0,i=Math.floor(e.length/2)-1;while(n<=i){let s=Math.floor((n+i)/2),r=s*2;if(t<e[r])i=s-1;else if(t>e[r+1])n=s+1;else return!0}return!1};var ur=19968,[Qc,eu]=tu(ws);function tu(e){let t=e[0],n=e[1];for(let i=0;i<e.length;i+=2){let s=e[i],r=e[i+1];if(ur>=s&&ur<=r)return[s,r];if(r-s>n-t)t=s,n=r}return[t,n]}var lr=(e)=>{if(e<tr||e>nr)return!1;return Cn(sr,e)},fr=(e)=>{if(e<ir||e>rr)return!1;return Cn(or,e)};var dr=(e)=>{if(e>=Qc&&e<=eu)return!0;if(e<ar||e>cr)return!1;return Cn(ws,e)};function nu(e){if(!Number.isSafeInteger(e))throw TypeError(`Expected a code point, got \`${typeof e}\`.`)}function pr(e,{ambiguousAsWide:t=!1}={}){if(nu(e),fr(e)||dr(e)||t&&lr(e))return 2;return 1}var mr=Gi(gr(),1),su=new Intl.Segmenter,iu=/^\p{Default_Ignorable_Code_Point}$/u;function Le(e,t={}){if(typeof e!=="string"||e.length===0)return 0;let{ambiguousIsNarrow:n=!0,countAnsiEscapeCodes:i=!1}=t;if(!i)e=dt(e);if(e.length===0)return 0;let s=0,r={ambiguousAsWide:!n};for(let{segment:o}of su.segment(e)){let a=o.codePointAt(0);if(a<=31||a>=127&&a<=159)continue;if(a>=8203&&a<=8207||a===65279)continue;if(a>=768&&a<=879||a>=6832&&a<=6911||a>=7616&&a<=7679||a>=8400&&a<=8447||a>=65056&&a<=65071)continue;if(a>=55296&&a<=57343)continue;if(a>=65024&&a<=65039)continue;if(iu.test(o))continue;if(mr.default().test(o)){s+=2;continue}s+=pr(a,r)}return s}var Dr=(e=0)=>(t)=>`\x1B[${t+e}m`,yr=(e=0)=>(t)=>`\x1B[${38+e};5;${t}m`,wr=(e=0)=>(t,n,i)=>`\x1B[${38+e};2;${t};${n};${i}m`,se={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]}},Ud=Object.keys(se.modifier),ru=Object.keys(se.color),ou=Object.keys(se.bgColor),Jd=[...ru,...ou];function au(){let e=new Map;for(let[t,n]of Object.entries(se)){for(let[i,s]of Object.entries(n))se[i]={open:`\x1B[${s[0]}m`,close:`\x1B[${s[1]}m`},n[i]=se[i],e.set(s[0],s[1]);Object.defineProperty(se,t,{value:n,enumerable:!1})}return Object.defineProperty(se,"codes",{value:e,enumerable:!1}),se.color.close="\x1B[39m",se.bgColor.close="\x1B[49m",se.color.ansi=Dr(),se.color.ansi256=yr(),se.color.ansi16m=wr(),se.bgColor.ansi=Dr(10),se.bgColor.ansi256=yr(10),se.bgColor.ansi16m=wr(10),Object.defineProperties(se,{rgbToAnsi256:{value(t,n,i){if(t===n&&n===i){if(t<8)return 16;if(t>248)return 231;return Math.round((t-8)/247*24)+232}return 16+36*Math.round(t/255*5)+6*Math.round(n/255*5)+Math.round(i/255*5)},enumerable:!1},hexToRgb:{value(t){let n=/[a-f\d]{6}|[a-f\d]{3}/i.exec(t.toString(16));if(!n)return[0,0,0];let[i]=n;if(i.length===3)i=[...i].map((r)=>r+r).join("");let s=Number.parseInt(i,16);return[s>>16&255,s>>8&255,s&255]},enumerable:!1},hexToAnsi256:{value:(t)=>se.rgbToAnsi256(...se.hexToRgb(t)),enumerable:!1},ansi256ToAnsi:{value(t){if(t<8)return 30+t;if(t<16)return 90+(t-8);let n,i,s;if(t>=232)n=((t-232)*10+8)/255,i=n,s=n;else{t-=16;let a=t%36;n=Math.floor(t/36)/5,i=Math.floor(a/6)/5,s=a%6/5}let r=Math.max(n,i,s)*2;if(r===0)return 30;let o=30+(Math.round(s)<<2|Math.round(i)<<1|Math.round(n));if(r===2)o+=60;return o},enumerable:!1},rgbToAnsi:{value:(t,n,i)=>se.ansi256ToAnsi(se.rgbToAnsi256(t,n,i)),enumerable:!1},hexToAnsi:{value:(t)=>se.ansi256ToAnsi(se.hexToAnsi256(t)),enumerable:!1}}),se}var cu=au(),br=cu;var xn=new Set(["\x1B","›"]),uu=39,Fs="\x07",Er="[",lu="]",xr="m",En=`${lu}8;;`,Fr=(e)=>`${xn.values().next().value}${Er}${e}${xr}`,Cr=(e)=>`${xn.values().next().value}${En}${e}${Fs}`,fu=(e)=>e.split(" ").map((t)=>Le(t)),bs=(e,t,n)=>{let i=[...t],s=!1,r=!1,o=Le(dt(e.at(-1)));for(let[a,c]of i.entries()){let u=Le(c);if(o+u<=n)e[e.length-1]+=c;else e.push(c),o=0;if(xn.has(c))s=!0,r=i.slice(a+1,a+1+En.length).join("")===En;if(s){if(r){if(c===Fs)s=!1,r=!1}else if(c===xr)s=!1;continue}if(o+=u,o===n&&a<i.length-1)e.push(""),o=0}if(!o&&e.at(-1).length>0&&e.length>1)e[e.length-2]+=e.pop()},du=(e)=>{let t=e.split(" "),n=t.length;while(n>0){if(Le(t[n-1])>0)break;n--}if(n===t.length)return e;return t.slice(0,n).join(" ")+t.slice(n).join("")},pu=(e,t,n={})=>{if(n.trim!==!1&&e.trim()==="")return"";let i="",s,r,o=fu(e),a=[""];for(let[l,d]of e.split(" ").entries()){if(n.trim!==!1)a[a.length-1]=a.at(-1).trimStart();let h=Le(a.at(-1));if(l!==0){if(h>=t&&(n.wordWrap===!1||n.trim===!1))a.push(""),h=0;if(h>0||n.trim===!1)a[a.length-1]+=" ",h++}if(n.hard&&o[l]>t){let m=t-h,p=1+Math.floor((o[l]-m-1)/t);if(Math.floor((o[l]-1)/t)<p)a.push("");bs(a,d,t);continue}if(h+o[l]>t&&h>0&&o[l]>0){if(n.wordWrap===!1&&h<t){bs(a,d,t);continue}a.push("")}if(h+o[l]>t&&n.wordWrap===!1){bs(a,d,t);continue}a[a.length-1]+=d}if(n.trim!==!1)a=a.map((l)=>du(l));let c=a.join(`
8
- `),u=[...c],f=0;for(let[l,d]of u.entries()){if(i+=d,xn.has(d)){let{groups:m}=new RegExp(`(?:\\${Er}(?<code>\\d+)m|\\${En}(?<uri>.*)${Fs})`).exec(c.slice(f))||{groups:{}};if(m.code!==void 0){let p=Number.parseFloat(m.code);s=p===uu?void 0:p}else if(m.uri!==void 0)r=m.uri.length===0?void 0:m.uri}let h=br.codes.get(Number(s));if(u[l+1]===`
9
- `){if(r)i+=Cr("");if(s&&h)i+=Fr(h)}else if(d===`
10
- `){if(s&&h)i+=Fr(s);if(r)i+=Cr(r)}f+=d.length}return i};function Cs(e,t,n){return String(e).normalize().replaceAll(`\r
7
+ `);if(s.border)i.unshift("."+"-".repeat(this.negatePadding(s)+2)+"."),i.push("'"+"-".repeat(this.negatePadding(s)+2)+"'");if(s.padding)i.unshift(...Array(s.padding[0]||0).fill("")),i.push(...Array(s.padding[2]||0).fill(""));i.forEach((o,a)=>{if(!t[a])t.push([]);let c=t[a];for(let u=0;u<r;u++)if(c[u]===void 0)c.push("");c.push(o)})}),t}negatePadding(e){let t=e.width||0;if(e.padding)t-=(e.padding[3]||0)+(e.padding[1]||0);if(e.border)t-=4;return t}columnWidths(e){if(!this.wrap)return e.map((r)=>r.width||Se.stringWidth(r.text));let t=e.length,n=this.width,i=e.map((r)=>{if(r.width)return t--,n-=r.width,r.width;return}),s=t?Math.floor(n/t):0;return i.map((r,o)=>{if(r===void 0)return Math.max(s,Vc(e[o]));return r})}}function er(e,t,n){if(e.border){if(/[.']-+[.']/.test(t))return"";if(t.trim().length!==0)return n;return" "}return""}function Vc(e){let t=e.padding||[],n=1+(t[3]||0)+(t[1]||0);if(e.border)return n+4;return n}function Zc(){if(typeof process==="object"&&process.stdout&&process.stdout.columns)return process.stdout.columns;return 80}function Qc(e,t){e=e.trim();let n=Se.stringWidth(e);if(n<t)return" ".repeat(t-n)+e;return e}function eu(e,t){e=e.trim();let n=Se.stringWidth(e);if(n>=t)return e;return" ".repeat(t-n>>1)+e}var Se;function nr(e,t){return Se=t,new tr({width:(e===null||e===void 0?void 0:e.width)||Zc(),wrap:e===null||e===void 0?void 0:e.wrap})}function Fs({onlyFirst:e=!1}={}){return new RegExp("(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]",e?void 0:"g")}var tu=Fs();function pt(e){if(typeof e!=="string")throw TypeError(`Expected a \`string\`, got \`${typeof e}\``);if(!e.includes("\x1B")&&!e.includes("›"))return e;return e.replace(tu,"")}var sr=161,ir=1114109,rr=[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],or=12288,ar=65510,cr=[12288,12288,65281,65376,65504,65510];var ur=4352,lr=262141,Cs=[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 En=(e,t)=>{let n=0,i=Math.floor(e.length/2)-1;while(n<=i){let s=Math.floor((n+i)/2),r=s*2;if(t<e[r])i=s-1;else if(t>e[r+1])n=s+1;else return!0}return!1};var fr=19968,[nu,su]=iu(Cs);function iu(e){let t=e[0],n=e[1];for(let i=0;i<e.length;i+=2){let s=e[i],r=e[i+1];if(fr>=s&&fr<=r)return[s,r];if(r-s>n-t)t=s,n=r}return[t,n]}var dr=(e)=>{if(e<sr||e>ir)return!1;return En(rr,e)},pr=(e)=>{if(e<or||e>ar)return!1;return En(cr,e)};var hr=(e)=>{if(e>=nu&&e<=su)return!0;if(e<ur||e>lr)return!1;return En(Cs,e)};function ru(e){if(!Number.isSafeInteger(e))throw TypeError(`Expected a code point, got \`${typeof e}\`.`)}function gr(e,{ambiguousAsWide:t=!1}={}){if(ru(e),pr(e)||hr(e)||t&&dr(e))return 2;return 1}var yr=Zi(Dr(),1),ou=new Intl.Segmenter,au=/^\p{Default_Ignorable_Code_Point}$/u;function Le(e,t={}){if(typeof e!=="string"||e.length===0)return 0;let{ambiguousIsNarrow:n=!0,countAnsiEscapeCodes:i=!1}=t;if(!i)e=pt(e);if(e.length===0)return 0;let s=0,r={ambiguousAsWide:!n};for(let{segment:o}of ou.segment(e)){let a=o.codePointAt(0);if(a<=31||a>=127&&a<=159)continue;if(a>=8203&&a<=8207||a===65279)continue;if(a>=768&&a<=879||a>=6832&&a<=6911||a>=7616&&a<=7679||a>=8400&&a<=8447||a>=65056&&a<=65071)continue;if(a>=55296&&a<=57343)continue;if(a>=65024&&a<=65039)continue;if(au.test(o))continue;if(yr.default().test(o)){s+=2;continue}s+=gr(a,r)}return s}var wr=(e=0)=>(t)=>`\x1B[${t+e}m`,br=(e=0)=>(t)=>`\x1B[${38+e};5;${t}m`,Fr=(e=0)=>(t,n,i)=>`\x1B[${38+e};2;${t};${n};${i}m`,re={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]}},Hd=Object.keys(re.modifier),cu=Object.keys(re.color),uu=Object.keys(re.bgColor),qd=[...cu,...uu];function lu(){let e=new Map;for(let[t,n]of Object.entries(re)){for(let[i,s]of Object.entries(n))re[i]={open:`\x1B[${s[0]}m`,close:`\x1B[${s[1]}m`},n[i]=re[i],e.set(s[0],s[1]);Object.defineProperty(re,t,{value:n,enumerable:!1})}return Object.defineProperty(re,"codes",{value:e,enumerable:!1}),re.color.close="\x1B[39m",re.bgColor.close="\x1B[49m",re.color.ansi=wr(),re.color.ansi256=br(),re.color.ansi16m=Fr(),re.bgColor.ansi=wr(10),re.bgColor.ansi256=br(10),re.bgColor.ansi16m=Fr(10),Object.defineProperties(re,{rgbToAnsi256:{value(t,n,i){if(t===n&&n===i){if(t<8)return 16;if(t>248)return 231;return Math.round((t-8)/247*24)+232}return 16+36*Math.round(t/255*5)+6*Math.round(n/255*5)+Math.round(i/255*5)},enumerable:!1},hexToRgb:{value(t){let n=/[a-f\d]{6}|[a-f\d]{3}/i.exec(t.toString(16));if(!n)return[0,0,0];let[i]=n;if(i.length===3)i=[...i].map((r)=>r+r).join("");let s=Number.parseInt(i,16);return[s>>16&255,s>>8&255,s&255]},enumerable:!1},hexToAnsi256:{value:(t)=>re.rgbToAnsi256(...re.hexToRgb(t)),enumerable:!1},ansi256ToAnsi:{value(t){if(t<8)return 30+t;if(t<16)return 90+(t-8);let n,i,s;if(t>=232)n=((t-232)*10+8)/255,i=n,s=n;else{t-=16;let a=t%36;n=Math.floor(t/36)/5,i=Math.floor(a/6)/5,s=a%6/5}let r=Math.max(n,i,s)*2;if(r===0)return 30;let o=30+(Math.round(s)<<2|Math.round(i)<<1|Math.round(n));if(r===2)o+=60;return o},enumerable:!1},rgbToAnsi:{value:(t,n,i)=>re.ansi256ToAnsi(re.rgbToAnsi256(t,n,i)),enumerable:!1},hexToAnsi:{value:(t)=>re.ansi256ToAnsi(re.hexToAnsi256(t)),enumerable:!1}}),re}var fu=lu(),Cr=fu;var _n=new Set(["\x1B","›"]),du=39,xs="\x07",_r="[",pu="]",Sr="m",xn=`${pu}8;;`,Er=(e)=>`${_n.values().next().value}${_r}${e}${Sr}`,xr=(e)=>`${_n.values().next().value}${xn}${e}${xs}`,hu=(e)=>e.split(" ").map((t)=>Le(t)),Es=(e,t,n)=>{let i=[...t],s=!1,r=!1,o=Le(pt(e.at(-1)));for(let[a,c]of i.entries()){let u=Le(c);if(o+u<=n)e[e.length-1]+=c;else e.push(c),o=0;if(_n.has(c))s=!0,r=i.slice(a+1,a+1+xn.length).join("")===xn;if(s){if(r){if(c===xs)s=!1,r=!1}else if(c===Sr)s=!1;continue}if(o+=u,o===n&&a<i.length-1)e.push(""),o=0}if(!o&&e.at(-1).length>0&&e.length>1)e[e.length-2]+=e.pop()},gu=(e)=>{let t=e.split(" "),n=t.length;while(n>0){if(Le(t[n-1])>0)break;n--}if(n===t.length)return e;return t.slice(0,n).join(" ")+t.slice(n).join("")},mu=(e,t,n={})=>{if(n.trim!==!1&&e.trim()==="")return"";let i="",s,r,o=hu(e),a=[""];for(let[l,d]of e.split(" ").entries()){if(n.trim!==!1)a[a.length-1]=a.at(-1).trimStart();let h=Le(a.at(-1));if(l!==0){if(h>=t&&(n.wordWrap===!1||n.trim===!1))a.push(""),h=0;if(h>0||n.trim===!1)a[a.length-1]+=" ",h++}if(n.hard&&o[l]>t){let m=t-h,p=1+Math.floor((o[l]-m-1)/t);if(Math.floor((o[l]-1)/t)<p)a.push("");Es(a,d,t);continue}if(h+o[l]>t&&h>0&&o[l]>0){if(n.wordWrap===!1&&h<t){Es(a,d,t);continue}a.push("")}if(h+o[l]>t&&n.wordWrap===!1){Es(a,d,t);continue}a[a.length-1]+=d}if(n.trim!==!1)a=a.map((l)=>gu(l));let c=a.join(`
8
+ `),u=[...c],f=0;for(let[l,d]of u.entries()){if(i+=d,_n.has(d)){let{groups:m}=new RegExp(`(?:\\${_r}(?<code>\\d+)m|\\${xn}(?<uri>.*)${xs})`).exec(c.slice(f))||{groups:{}};if(m.code!==void 0){let p=Number.parseFloat(m.code);s=p===du?void 0:p}else if(m.uri!==void 0)r=m.uri.length===0?void 0:m.uri}let h=Cr.codes.get(Number(s));if(u[l+1]===`
9
+ `){if(r)i+=xr("");if(s&&h)i+=Er(h)}else if(d===`
10
+ `){if(s&&h)i+=Er(s);if(r)i+=xr(r)}f+=d.length}return i};function _s(e,t,n){return String(e).normalize().replaceAll(`\r
11
11
  `,`
12
12
  `).split(`
13
- `).map((i)=>pu(i,t,n)).join(`
14
- `)}function Es(e){return er(e,{stringWidth:Le,stripAnsi:dt,wrap:Cs})}import{dirname as _r,resolve as Sr}from"path";import{readdirSync as hu,statSync as gu}from"fs";function xs(e,t){let n=Sr(".",e),i;if(!gu(n).isDirectory())n=_r(n);while(!0){if(i=t(n,hu(n)),i)return Sr(n,i);if(n=_r(i=n),i===n)break}}import{inspect as Pu}from"util";import{fileURLToPath as Jr}from"url";import{format as yu}from"util";import{normalize as wu,resolve as bu}from"path";function pt(e){if(!(e!==e.toLowerCase()&&e!==e.toUpperCase()))e=e.toLowerCase();if(e.indexOf("-")===-1&&e.indexOf("_")===-1)return e;else{let n="",i=!1,s=e.match(/^-+/);for(let r=s?s[0].length:0;r<e.length;r++){let o=e.charAt(r);if(i)i=!1,o=o.toUpperCase();if(r!==0&&(o==="-"||o==="_"))i=!0;else if(o!=="-"&&o!=="_")n+=o}return n}}function _n(e,t){let n=e.toLowerCase();t=t||"-";let i="";for(let s=0;s<e.length;s++){let r=n.charAt(s),o=e.charAt(s);if(r!==o&&s>0)i+=`${t}${n.charAt(s)}`;else i+=o}return i}function Sn(e){if(e===null||e===void 0)return!1;if(typeof e==="number")return!0;if(/^0x[0-9a-f]+$/i.test(e))return!0;if(/^0[^.]/.test(e))return!1;return/^[-]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(e)}function kr(e){if(Array.isArray(e))return e.map((o)=>typeof o!=="string"?o+"":o);e=e.trim();let t=0,n=null,i=null,s=null,r=[];for(let o=0;o<e.length;o++){if(n=i,i=e.charAt(o),i===" "&&!s){if(n!==" ")t++;continue}if(i===s)s=null;else if((i==="'"||i==='"')&&!s)s=i;if(!r[t])r[t]="";r[t]+=i}return r}var Ie;(function(e){e.BOOLEAN="boolean",e.STRING="string",e.NUMBER="number",e.ARRAY="array"})(Ie||(Ie={}));var Qe;class Ss{constructor(e){Qe=e}parse(e,t){let n=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},t),i=kr(e),s=typeof e==="string",r=mu(Object.assign(Object.create(null),n.alias)),o=Object.assign({"boolean-negation":!0,"camel-case-expansion":!0,"combine-arrays":!1,"dot-notation":!0,"duplicate-arguments-array":!0,"flatten-duplicate-arrays":!0,"greedy-arrays":!0,"halt-at-non-option":!1,"nargs-eats-options":!1,"negation-prefix":"no-","parse-numbers":!0,"parse-positional-numbers":!0,"populate--":!1,"set-placeholder-key":!1,"short-option-groups":!0,"strip-aliased":!1,"strip-dashed":!1,"unknown-options-as-args":!1},n.configuration),a=Object.assign(Object.create(null),n.default),c=n.configObjects||[],u=n.envPrefix,f=o["populate--"],l=f?"--":"_",d=Object.create(null),h=Object.create(null),m=n.__||Qe.format,p={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:[]},y=/^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/,E=new RegExp("^--"+o["negation-prefix"]+"(.+)");if([].concat(n.array||[]).filter(Boolean).forEach(function(D){let b=typeof D==="object"?D.key:D,I=Object.keys(D).map(function(_){return{boolean:"bools",string:"strings",number:"numbers"}[_]}).filter(Boolean).pop();if(I)p[I][b]=!0;p.arrays[b]=!0,p.keys.push(b)}),[].concat(n.boolean||[]).filter(Boolean).forEach(function(D){p.bools[D]=!0,p.keys.push(D)}),[].concat(n.string||[]).filter(Boolean).forEach(function(D){p.strings[D]=!0,p.keys.push(D)}),[].concat(n.number||[]).filter(Boolean).forEach(function(D){p.numbers[D]=!0,p.keys.push(D)}),[].concat(n.count||[]).filter(Boolean).forEach(function(D){p.counts[D]=!0,p.keys.push(D)}),[].concat(n.normalize||[]).filter(Boolean).forEach(function(D){p.normalize[D]=!0,p.keys.push(D)}),typeof n.narg==="object")Object.entries(n.narg).forEach(([D,b])=>{if(typeof b==="number")p.nargs[D]=b,p.keys.push(D)});if(typeof n.coerce==="object")Object.entries(n.coerce).forEach(([D,b])=>{if(typeof b==="function")p.coercions[D]=b,p.keys.push(D)});if(typeof n.config<"u"){if(Array.isArray(n.config)||typeof n.config==="string")[].concat(n.config).filter(Boolean).forEach(function(D){p.configs[D]=!0});else if(typeof n.config==="object")Object.entries(n.config).forEach(([D,b])=>{if(typeof b==="boolean"||typeof b==="function")p.configs[D]=b})}Oe(n.key,r,n.default,p.arrays),Object.keys(a).forEach(function(D){(p.aliases[D]||[]).forEach(function(b){a[b]=a[D]})});let F=null;Ds();let k=[],C=Object.assign(Object.create(null),{_:[]}),A={};for(let D=0;D<i.length;D++){let b=i[D],I=b.replace(/^-{3,}/,"---"),_,w,j,M,K,ge;if(b!=="--"&&/^-/.test(b)&&ee(b))P(b);else if(I.match(/^---+(=|$)/)){P(b);continue}else if(b.match(/^--.+=/)||!o["short-option-groups"]&&b.match(/^-.+=/)){if(M=b.match(/^--?([^=]+)=([\s\S]*)$/),M!==null&&Array.isArray(M)&&M.length>=3)if(z(M[1],p.arrays))D=L(D,M[1],i,M[2]);else if(z(M[1],p.nargs)!==!1)D=v(D,M[1],i,M[2]);else R(M[1],M[2],!0)}else if(b.match(E)&&o["boolean-negation"]){if(M=b.match(E),M!==null&&Array.isArray(M)&&M.length>=2)w=M[1],R(w,z(w,p.arrays)?[!1]:!1)}else if(b.match(/^--.+/)||!o["short-option-groups"]&&b.match(/^-[^-]+/)){if(M=b.match(/^--?(.+)/),M!==null&&Array.isArray(M)&&M.length>=2)if(w=M[1],z(w,p.arrays))D=L(D,w,i);else if(z(w,p.nargs)!==!1)D=v(D,w,i);else if(K=i[D+1],K!==void 0&&(!K.match(/^-/)||K.match(y))&&!z(w,p.bools)&&!z(w,p.counts))R(w,K),D++;else if(/^(true|false)$/.test(K))R(w,K),D++;else R(w,V(w))}else if(b.match(/^-.\..+=/)){if(M=b.match(/^-([^=]+)=([\s\S]*)$/),M!==null&&Array.isArray(M)&&M.length>=3)R(M[1],M[2])}else if(b.match(/^-.\..+/)&&!b.match(y)){if(K=i[D+1],M=b.match(/^-(.\..+)/),M!==null&&Array.isArray(M)&&M.length>=2)if(w=M[1],K!==void 0&&!K.match(/^-/)&&!z(w,p.bools)&&!z(w,p.counts))R(w,K),D++;else R(w,V(w))}else if(b.match(/^-[^-]+/)&&!b.match(y)){j=b.slice(1,-1).split(""),_=!1;for(let be=0;be<j.length;be++){if(K=b.slice(be+2),j[be+1]&&j[be+1]==="="){if(ge=b.slice(be+3),w=j[be],z(w,p.arrays))D=L(D,w,i,ge);else if(z(w,p.nargs)!==!1)D=v(D,w,i,ge);else R(w,ge);_=!0;break}if(K==="-"){R(j[be],K);continue}if(/[A-Za-z]/.test(j[be])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(K)&&z(K,p.bools)===!1){R(j[be],K),_=!0;break}if(j[be+1]&&j[be+1].match(/\W/)){R(j[be],K),_=!0;break}else R(j[be],V(j[be]))}if(w=b.slice(-1)[0],!_&&w!=="-")if(z(w,p.arrays))D=L(D,w,i);else if(z(w,p.nargs)!==!1)D=v(D,w,i);else if(K=i[D+1],K!==void 0&&(!/^(-|--)[^-]/.test(K)||K.match(y))&&!z(w,p.bools)&&!z(w,p.counts))R(w,K),D++;else if(/^(true|false)$/.test(K))R(w,K),D++;else R(w,V(w))}else if(b.match(/^-[0-9]$/)&&b.match(y)&&z(b.slice(1),p.bools))w=b.slice(1),R(w,V(w));else if(b==="--"){k=i.slice(D+1);break}else if(o["halt-at-non-option"]){k=i.slice(D);break}else P(b)}if(re(C,!0),re(C,!1),O(C),Z(),$e(C,p.aliases,a,!0),Q(C),o["set-placeholder-key"])oe(C);if(Object.keys(p.counts).forEach(function(D){if(!J(C,D.split(".")))R(D,0)}),f&&k.length)C[l]=[];if(k.forEach(function(D){C[l].push(D)}),o["camel-case-expansion"]&&o["strip-dashed"])Object.keys(C).filter((D)=>D!=="--"&&D.includes("-")).forEach((D)=>{delete C[D]});if(o["strip-aliased"])[].concat(...Object.keys(r).map((D)=>r[D])).forEach((D)=>{if(o["camel-case-expansion"]&&D.includes("-"))delete C[D.split(".").map((b)=>pt(b)).join(".")];delete C[D]});function P(D){let b=x("_",D);if(typeof b==="string"||typeof b==="number")C._.push(b)}function v(D,b,I,_){let w,j=z(b,p.nargs);if(j=typeof j!=="number"||isNaN(j)?1:j,j===0){if(!pe(_))F=Error(m("Argument unexpected for: %s",b));return R(b,V(b)),D}let M=pe(_)?0:1;if(o["nargs-eats-options"]){if(I.length-(D+1)+M<j)F=Error(m("Not enough arguments following: %s",b));M=j}else{for(w=D+1;w<I.length;w++)if(!I[w].match(/^-[^0-9]/)||I[w].match(y)||ee(I[w]))M++;else break;if(M<j)F=Error(m("Not enough arguments following: %s",b))}let K=Math.min(M,j);if(!pe(_)&&K>0)R(b,_),K--;for(w=D+1;w<K+D+1;w++)R(b,I[w]);return D+K}function L(D,b,I,_){let w=[],j=_||I[D+1],M=z(b,p.nargs);if(z(b,p.bools)&&!/^(true|false)$/.test(j))w.push(!0);else if(pe(j)||pe(_)&&/^-/.test(j)&&!y.test(j)&&!ee(j)){if(a[b]!==void 0){let K=a[b];w=Array.isArray(K)?K:[K]}}else{if(!pe(_))w.push(S(b,_,!0));for(let K=D+1;K<I.length;K++){if(!o["greedy-arrays"]&&w.length>0||M&&typeof M==="number"&&w.length>=M)break;if(j=I[K],/^-/.test(j)&&!y.test(j)&&!ee(j))break;D=K,w.push(S(b,j,s))}}if(typeof M==="number"&&(M&&w.length<M||isNaN(M)&&w.length===0))F=Error(m("Not enough arguments following: %s",b));return R(b,w),D}function R(D,b,I=s){if(/-/.test(D)&&o["camel-case-expansion"]){let j=D.split(".").map(function(M){return pt(M)}).join(".");G(D,j)}let _=S(D,b,I),w=D.split(".");if(ae(C,w,_),p.aliases[D])p.aliases[D].forEach(function(j){let M=j.split(".");ae(C,M,_)});if(w.length>1&&o["dot-notation"])(p.aliases[w[0]]||[]).forEach(function(j){let M=j.split("."),K=[].concat(w);if(K.shift(),M=M.concat(K),!(p.aliases[D]||[]).includes(M.join(".")))ae(C,M,_)});if(z(D,p.normalize)&&!z(D,p.arrays))[D].concat(p.aliases[D]||[]).forEach(function(M){Object.defineProperty(A,M,{enumerable:!0,get(){return b},set(K){b=typeof K==="string"?Qe.normalize(K):K}})})}function G(D,b){if(!(p.aliases[D]&&p.aliases[D].length))p.aliases[D]=[b],d[b]=!0;if(!(p.aliases[b]&&p.aliases[b].length))G(b,D)}function S(D,b,I){if(I)b=Du(b);if(z(D,p.bools)||z(D,p.counts)){if(typeof b==="string")b=b==="true"}let _=Array.isArray(b)?b.map(function(w){return x(D,w)}):x(D,b);if(z(D,p.counts)&&(pe(_)||typeof _==="boolean"))_=_s();if(z(D,p.normalize)&&z(D,p.arrays))if(Array.isArray(b))_=b.map((w)=>Qe.normalize(w));else _=Qe.normalize(b);return _}function x(D,b){if(!o["parse-positional-numbers"]&&D==="_")return b;if(!z(D,p.strings)&&!z(D,p.bools)&&!Array.isArray(b)){if(Sn(b)&&o["parse-numbers"]&&Number.isSafeInteger(Math.floor(parseFloat(`${b}`)))||!pe(b)&&z(D,p.numbers))b=Number(b)}return b}function O(D){let b=Object.create(null);$e(b,p.aliases,a),Object.keys(p.configs).forEach(function(I){let _=D[I]||b[I];if(_)try{let w=null,j=Qe.resolve(Qe.cwd(),_),M=p.configs[I];if(typeof M==="function"){try{w=M(j)}catch(K){w=K}if(w instanceof Error){F=w;return}}else w=Qe.require(j);W(w)}catch(w){if(w.name==="PermissionDenied")F=w;else if(D[I])F=Error(m("Invalid JSON config file: %s",_))}})}function W(D,b){Object.keys(D).forEach(function(I){let _=D[I],w=b?b+"."+I:I;if(typeof _==="object"&&_!==null&&!Array.isArray(_)&&o["dot-notation"])W(_,w);else if(!J(C,w.split("."))||z(w,p.arrays)&&o["combine-arrays"])R(w,_)})}function Z(){if(typeof c<"u")c.forEach(function(D){W(D)})}function re(D,b){if(typeof u>"u")return;let I=typeof u==="string"?u:"",_=Qe.env();Object.keys(_).forEach(function(w){if(I===""||w.lastIndexOf(I,0)===0){let j=w.split("__").map(function(M,K){if(K===0)M=M.substring(I.length);return pt(M)});if((b&&p.configs[j.join(".")]||!b)&&!J(D,j))R(j.join("."),_[w])}})}function Q(D){let b,I=new Set;Object.keys(D).forEach(function(_){if(!I.has(_)){if(b=z(_,p.coercions),typeof b==="function")try{let w=x(_,b(D[_]));[].concat(p.aliases[_]||[],_).forEach((j)=>{I.add(j),D[j]=w})}catch(w){F=w}}})}function oe(D){return p.keys.forEach((b)=>{if(~b.indexOf("."))return;if(typeof D[b]>"u")D[b]=void 0}),D}function $e(D,b,I,_=!1){Object.keys(I).forEach(function(w){if(!J(D,w.split("."))){if(ae(D,w.split("."),I[w]),_)h[w]=!0;(b[w]||[]).forEach(function(j){if(J(D,j.split(".")))return;ae(D,j.split("."),I[w])})}})}function J(D,b){let I=D;if(!o["dot-notation"])b=[b.join(".")];b.slice(0,-1).forEach(function(w){I=I[w]||{}});let _=b[b.length-1];if(typeof I!=="object")return!1;else return _ in I}function ae(D,b,I){let _=D;if(!o["dot-notation"])b=[b.join(".")];b.slice(0,-1).forEach(function(ge){if(ge=Ar(ge),typeof _==="object"&&_[ge]===void 0)_[ge]={};if(typeof _[ge]!=="object"||Array.isArray(_[ge])){if(Array.isArray(_[ge]))_[ge].push({});else _[ge]=[_[ge],{}];_=_[ge][_[ge].length-1]}else _=_[ge]});let w=Ar(b[b.length-1]),j=z(b.join("."),p.arrays),M=Array.isArray(I),K=o["duplicate-arguments-array"];if(!K&&z(w,p.nargs)){if(K=!0,!pe(_[w])&&p.nargs[w]===1||Array.isArray(_[w])&&_[w].length===p.nargs[w])_[w]=void 0}if(I===_s())_[w]=_s(_[w]);else if(Array.isArray(_[w]))if(K&&j&&M)_[w]=o["flatten-duplicate-arrays"]?_[w].concat(I):(Array.isArray(_[w][0])?_[w]:[_[w]]).concat([I]);else if(!K&&Boolean(j)===Boolean(M))_[w]=I;else _[w]=_[w].concat([I]);else if(_[w]===void 0&&j)_[w]=M?I:[I];else if(K&&!(_[w]===void 0||z(w,p.counts)||z(w,p.bools)))_[w]=[_[w],I];else _[w]=I}function Oe(...D){D.forEach(function(b){Object.keys(b||{}).forEach(function(I){if(p.aliases[I])return;p.aliases[I]=[].concat(r[I]||[]),p.aliases[I].concat(I).forEach(function(_){if(/-/.test(_)&&o["camel-case-expansion"]){let w=pt(_);if(w!==I&&p.aliases[I].indexOf(w)===-1)p.aliases[I].push(w),d[w]=!0}}),p.aliases[I].concat(I).forEach(function(_){if(_.length>1&&/[A-Z]/.test(_)&&o["camel-case-expansion"]){let w=_n(_,"-");if(w!==I&&p.aliases[I].indexOf(w)===-1)p.aliases[I].push(w),d[w]=!0}}),p.aliases[I].forEach(function(_){p.aliases[_]=[I].concat(p.aliases[I].filter(function(w){return _!==w}))})})})}function z(D,b){let I=[].concat(p.aliases[D]||[],D),_=Object.keys(b),w=I.find((j)=>_.includes(j));return w?b[w]:!1}function vt(D){let b=Object.keys(p);return[].concat(b.map((_)=>p[_])).some(function(_){return Array.isArray(_)?_.includes(D):_[D]})}function Yi(D,...b){return[].concat(...b).some(function(_){let w=D.match(_);return w&&vt(w[1])})}function H(D){if(D.match(y)||!D.match(/^-[^-]+/))return!1;let b=!0,I,_=D.slice(1).split("");for(let w=0;w<_.length;w++){if(I=D.slice(w+2),!vt(_[w])){b=!1;break}if(_[w+1]&&_[w+1]==="="||I==="-"||/[A-Za-z]/.test(_[w])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(I)||_[w+1]&&_[w+1].match(/\W/))break}return b}function ee(D){return o["unknown-options-as-args"]&&de(D)}function de(D){if(D=D.replace(/^-{3,}/,"--"),D.match(y))return!1;if(H(D))return!1;return!Yi(D,/^-+([^=]+?)=[\s\S]*$/,E,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}function V(D){if(!z(D,p.bools)&&!z(D,p.counts)&&`${D}`in a)return a[D];else return ye(ue(D))}function ye(D){return{[Ie.BOOLEAN]:!0,[Ie.STRING]:"",[Ie.NUMBER]:void 0,[Ie.ARRAY]:[]}[D]}function ue(D){let b=Ie.BOOLEAN;if(z(D,p.strings))b=Ie.STRING;else if(z(D,p.numbers))b=Ie.NUMBER;else if(z(D,p.bools))b=Ie.BOOLEAN;else if(z(D,p.arrays))b=Ie.ARRAY;return b}function pe(D){return D===void 0}function Ds(){Object.keys(p.counts).find((D)=>{if(z(D,p.arrays))return F=Error(m("Invalid configuration: %s, opts.count excludes opts.array.",D)),!0;else if(z(D,p.nargs))return F=Error(m("Invalid configuration: %s, opts.count excludes opts.narg.",D)),!0;return!1})}return{aliases:Object.assign({},p.aliases),argv:Object.assign(A,C),configuration:o,defaulted:Object.assign({},h),error:F,newAliases:Object.assign({},d)}}}function mu(e){let t=[],n=Object.create(null),i=!0;Object.keys(e).forEach(function(s){t.push([].concat(e[s],s))});while(i){i=!1;for(let s=0;s<t.length;s++)for(let r=s+1;r<t.length;r++)if(t[s].filter(function(a){return t[r].indexOf(a)!==-1}).length){t[s]=t[s].concat(t[r]),t.splice(r,1),i=!0;break}}return t.forEach(function(s){s=s.filter(function(o,a,c){return c.indexOf(o)===a});let r=s.pop();if(r!==void 0&&typeof r==="string")n[r]=s}),n}function _s(e){return e!==void 0?e+1:1}function Ar(e){if(e==="__proto__")return"___proto___";return e}function Du(e){return typeof e==="string"&&(e[0]==="'"||e[0]==='"')&&e[e.length-1]===e[0]?e.substring(1,e.length-1):e}import{readFileSync as Fu}from"fs";import{createRequire as $r}from"node:module";var ks,As,$s,Or=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):20,Ir=(As=(ks=process===null||process===void 0?void 0:process.versions)===null||ks===void 0?void 0:ks.node)!==null&&As!==void 0?As:($s=process===null||process===void 0?void 0:process.version)===null||$s===void 0?void 0:$s.slice(1);if(Ir){if(Number(Ir.match(/^([^.]+)/)[1])<Or)throw Error(`yargs parser supports a minimum Node.js version of ${Or}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`)}var Cu=process?process.env:{},Tr=$r?$r(import.meta.url):void 0,Pr=new Ss({cwd:process.cwd,env:()=>Cu,format:yu,normalize:wu,resolve:bu,require:(e)=>{if(typeof Tr<"u")return Tr(e);else if(e.match(/\.json$/))return JSON.parse(Fu(e,"utf8"));else throw Error("only .json config files are supported in ESM")}}),Zt=function(t,n){return Pr.parse(t.slice(),n).argv};Zt.detailed=function(e,t){return Pr.parse(e.slice(),t)};Zt.camelCase=pt;Zt.decamelize=_n;Zt.looksLikeNumber=Sn;var Os=Zt;import{basename as Ru,dirname as Mu,extname as Bu,relative as Nu,resolve as Ur,join as vu}from"path";function Rr(){if(Eu())return 0;return 1}function Eu(){return xu()&&!process.defaultApp}function xu(){return!!process.versions.electron}function Is(e){return e.slice(Rr()+1)}function Mr(){return process.argv[Rr()]}import{readFileSync as _u,statSync as Su,writeFile as ku}from"fs";import{format as Au}from"util";import{resolve as $u}from"path";var Br={fs:{readFileSync:_u,writeFile:ku},format:Au,resolve:$u,exists:(e)=>{try{return Su(e).isFile()}catch(t){return!1}}};var We;class Nr{constructor(e){e=e||{},this.directory=e.directory||"./locales",this.updateFiles=typeof e.updateFiles==="boolean"?e.updateFiles:!0,this.locale=e.locale||"en",this.fallbackToLanguage=typeof e.fallbackToLanguage==="boolean"?e.fallbackToLanguage:!0,this.cache=Object.create(null),this.writeQueue=[]}__(...e){if(typeof arguments[0]!=="string")return this._taggedLiteral(arguments[0],...arguments);let t=e.shift(),n=function(){};if(typeof e[e.length-1]==="function")n=e.pop();if(n=n||function(){},!this.cache[this.locale])this._readLocaleFile();if(!this.cache[this.locale][t]&&this.updateFiles)this.cache[this.locale][t]=t,this._enqueueWrite({directory:this.directory,locale:this.locale,cb:n});else n();return We.format.apply(We.format,[this.cache[this.locale][t]||t].concat(e))}__n(){let e=Array.prototype.slice.call(arguments),t=e.shift(),n=e.shift(),i=e.shift(),s=function(){};if(typeof e[e.length-1]==="function")s=e.pop();if(!this.cache[this.locale])this._readLocaleFile();let r=i===1?t:n;if(this.cache[this.locale][t])r=this.cache[this.locale][t][i===1?"one":"other"];if(!this.cache[this.locale][t]&&this.updateFiles)this.cache[this.locale][t]={one:t,other:n},this._enqueueWrite({directory:this.directory,locale:this.locale,cb:s});else s();let o=[r];if(~r.indexOf("%d"))o.push(i);return We.format.apply(We.format,o.concat(e))}setLocale(e){this.locale=e}getLocale(){return this.locale}updateLocale(e){if(!this.cache[this.locale])this._readLocaleFile();for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t))this.cache[this.locale][t]=e[t]}_taggedLiteral(e,...t){let n="";return e.forEach(function(i,s){let r=t[s+1];if(n+=i,typeof r<"u")n+="%s"}),this.__.apply(this,[n].concat([].slice.call(t,1)))}_enqueueWrite(e){if(this.writeQueue.push(e),this.writeQueue.length===1)this._processWriteQueue()}_processWriteQueue(){let e=this,t=this.writeQueue[0],n=t.directory,i=t.locale,s=t.cb,r=this._resolveLocaleFile(n,i),o=JSON.stringify(this.cache[i],null,2);We.fs.writeFile(r,o,"utf-8",function(a){if(e.writeQueue.shift(),e.writeQueue.length>0)e._processWriteQueue();s(a)})}_readLocaleFile(){let e={},t=this._resolveLocaleFile(this.directory,this.locale);try{if(We.fs.readFileSync)e=JSON.parse(We.fs.readFileSync(t,"utf-8"))}catch(n){if(n instanceof SyntaxError)n.message="syntax error in "+t;if(n.code==="ENOENT")e={};else throw n}this.cache[this.locale]=e}_resolveLocaleFile(e,t){let n=We.resolve(e,"./",t+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(n)&&~t.lastIndexOf("_")){let i=We.resolve(e,"./",t.split("_")[0]+".json");if(this._fileExistsSync(i))n=i}return n}_fileExistsSync(e){return We.exists(e)}}function vr(e,t){We=t;let n=new Nr(e);return{__:n.__.bind(n),__n:n.__n.bind(n),setLocale:n.setLocale.bind(n),getLocale:n.getLocale.bind(n),updateLocale:n.updateLocale.bind(n),locale:n.locale}}var Ou=(e)=>vr(e,Br),jr=Ou;var Kr=Gi(Wr(),1);import{createRequire as ju}from"node:module";import{readFileSync as Lu,readdirSync as Wu}from"node:fs";var Ts=Jr(import.meta.url),Uu=Ts.substring(0,Ts.lastIndexOf("node_modules")),Ju=ju(import.meta.url),Ps={assert:{notStrictEqual:Iu,strictEqual:Tu},cliui:Es,findUp:xs,getEnv:(e)=>process.env[e],inspect:Pu,getProcessArgvBin:Mr,mainFilename:Uu||process.cwd(),Parser:Os,path:{basename:Ru,dirname:Mu,extname:Bu,relative:Nu,resolve:Ur,join:vu},process:{argv:()=>process.argv,cwd:process.cwd,emitWarning:(e,t)=>process.emitWarning(e,t),execPath:()=>process.execPath,exit:(e)=>{process.exit(e)},nextTick:process.nextTick,stdColumns:typeof process.stdout.columns<"u"?process.stdout.columns:null},readFileSync:Lu,readdirSync:Wu,require:Ju,getCallerFile:()=>{let e=Kr.default(3);return e.match(/^file:\/\//)?Jr(e):e},stringWidth:Le,y18n:jr({directory:Ur(Ts,"../../../locales"),updateFiles:!1})};function Fe(e,t,n,i){n.assert.notStrictEqual(e,t,i)}function Rs(e,t){t.assert.strictEqual(typeof e,"string")}function jt(e){return Object.keys(e)}function ne(e){return!!e&&!!e.then&&typeof e.then==="function"}class le extends Error{constructor(e){super(e||"yargs error");if(this.name="YError",Error.captureStackTrace)Error.captureStackTrace(this,le)}}function nt(e){let n=e.replace(/\s{2,}/g," ").split(/\s+(?![^[]*]|[^<]*>)/),i=/\.*[\][<>]/g,s=n.shift();if(!s)throw Error(`No command found in: ${e}`);let r={cmd:s.replace(i,""),demanded:[],optional:[]};return n.forEach((o,a)=>{let c=!1;if(o=o.replace(/\s/g,""),/\.+[\]>]/.test(o)&&a===n.length-1)c=!0;if(/^\[/.test(o))r.optional.push({cmd:o.replace(i,"").split("|"),variadic:c});else r.demanded.push({cmd:o.replace(i,"").split("|"),variadic:c})}),r}var Ku=["first","second","third","fourth","fifth","sixth"];function B(e,t,n){function i(){return typeof e==="object"?[{demanded:[],optional:[]},e,t]:[nt(`cmd ${e}`),t,n]}try{let s=0,[r,o,a]=i(),c=[].slice.call(o);while(c.length&&c[c.length-1]===void 0)c.pop();let u=a||c.length;if(u<r.demanded.length)throw new le(`Not enough arguments provided. Expected ${r.demanded.length} but received ${c.length}.`);let f=r.demanded.length+r.optional.length;if(u>f)throw new le(`Too many arguments provided. Expected max ${f} but received ${u}.`);r.demanded.forEach((l)=>{let d=c.shift(),h=zr(d);if(l.cmd.filter((p)=>p===h||p==="*").length===0)Hr(h,l.cmd,s);s+=1}),r.optional.forEach((l)=>{if(c.length===0)return;let d=c.shift(),h=zr(d);if(l.cmd.filter((p)=>p===h||p==="*").length===0)Hr(h,l.cmd,s);s+=1})}catch(s){console.warn(s.stack)}}function zr(e){if(Array.isArray(e))return"array";else if(e===null)return"null";return typeof e}function Hr(e,t,n){throw new le(`Invalid ${Ku[n]||"manyith"} argument. Expected ${t.join(" or ")} but received ${e}.`)}class Ms{constructor(e){this.globalMiddleware=[],this.frozens=[],this.yargs=e}addMiddleware(e,t,n=!0,i=!1){if(B("<array|function> [boolean] [boolean] [boolean]",[e,t,n],arguments.length),Array.isArray(e)){for(let s=0;s<e.length;s++){if(typeof e[s]!=="function")throw Error("middleware must be a function");let r=e[s];r.applyBeforeValidation=t,r.global=n}Array.prototype.push.apply(this.globalMiddleware,e)}else if(typeof e==="function"){let s=e;s.applyBeforeValidation=t,s.global=n,s.mutates=i,this.globalMiddleware.push(e)}return this.yargs}addCoerceMiddleware(e,t){let n=this.yargs.getAliases();return this.globalMiddleware=this.globalMiddleware.filter((i)=>{let s=[...n[t]||[],t];if(!i.option)return!0;else return!s.includes(i.option)}),e.option=t,this.addMiddleware(e,!0,!0,!0)}getMiddleware(){return this.globalMiddleware}freeze(){this.frozens.push([...this.globalMiddleware])}unfreeze(){let e=this.frozens.pop();if(e!==void 0)this.globalMiddleware=e}reset(){this.globalMiddleware=this.globalMiddleware.filter((e)=>e.global)}}function qr(e){if(!e)return[];return e.map((t)=>(t.applyBeforeValidation=!1,t))}function ht(e,t,n,i){return n.reduce((s,r)=>{if(r.applyBeforeValidation!==i)return s;if(r.mutates){if(r.applied)return s;r.applied=!0}if(ne(s))return s.then((o)=>Promise.all([o,r(o,t)])).then(([o,a])=>Object.assign(o,a));else{let o=r(s,t);return ne(o)?o.then((a)=>Object.assign(s,a)):Object.assign(s,o)}},e)}function gt(e,t,n=(i)=>{throw i}){try{let i=zu(e)?e():e;return ne(i)?i.then((s)=>t(s)):t(i)}catch(i){return n(i)}}function zu(e){return typeof e==="function"}var Lt=/(^\*)|(^\$0)/;class Xr{constructor(e,t,n,i){this.requireCache=new Set,this.handlers={},this.aliasMap={},this.frozens=[],this.shim=i,this.usage=e,this.globalMiddleware=n,this.validation=t}addDirectory(e,t,n,i){i=i||{},this.requireCache.add(n);let s=this.shim.path.resolve(this.shim.path.dirname(n),e),r=this.shim.readdirSync(s,{recursive:i.recurse?!0:!1});if(!Array.isArray(i.extensions))i.extensions=["js"];let o=typeof i.visit==="function"?i.visit:(a)=>a;for(let a of r){let c=a.toString();if(i.exclude){let f=!1;if(typeof i.exclude==="function")f=i.exclude(c);else f=i.exclude.test(c);if(f)continue}if(i.include){let f=!1;if(typeof i.include==="function")f=i.include(c);else f=i.include.test(c);if(!f)continue}let u=!1;for(let f of i.extensions)if(c.endsWith(f))u=!0;if(u){let f=this.shim.path.join(s,c),l=t(f),d=Object.create(null,Object.getOwnPropertyDescriptors({...l}));if(o(d,f,c)){if(this.requireCache.has(f))continue;else this.requireCache.add(f);if(!d.command)d.command=this.shim.path.basename(f,this.shim.path.extname(f));this.addHandler(d)}}}}addHandler(e,t,n,i,s,r){let o=[],a=qr(s);if(i=i||(()=>{}),Array.isArray(e))if(Hu(e))[e,...o]=e;else for(let c of e)this.addHandler(c);else if(Yu(e)){let c=Array.isArray(e.command)||typeof e.command==="string"?e.command:null;if(c===null)throw Error(`No command name given for module: ${this.shim.inspect(e)}`);if(e.aliases)c=[].concat(c).concat(e.aliases);this.addHandler(c,this.extractDesc(e),e.builder,e.handler,e.middlewares,e.deprecated);return}else if(Yr(n)){this.addHandler([e].concat(o),t,n.builder,n.handler,n.middlewares,n.deprecated);return}if(typeof e==="string"){let c=nt(e);o=o.map((l)=>nt(l).cmd);let u=!1,f=[c.cmd].concat(o).filter((l)=>{if(Lt.test(l))return u=!0,!1;return!0});if(f.length===0&&u)f.push("$0");if(u)c.cmd=f[0],o=f.slice(1),e=e.replace(Lt,c.cmd);if(o.forEach((l)=>{this.aliasMap[l]=c.cmd}),t!==!1)this.usage.command(e,t,u,o,r);if(this.handlers[c.cmd]={original:e,description:t,handler:i,builder:n||{},middlewares:a,deprecated:r,demanded:c.demanded,optional:c.optional},u)this.defaultCommand=this.handlers[c.cmd]}}getCommandHandlers(){return this.handlers}getCommands(){return Object.keys(this.handlers).concat(Object.keys(this.aliasMap))}hasDefaultCommand(){return!!this.defaultCommand}runCommand(e,t,n,i,s,r){let o=this.handlers[e]||this.handlers[this.aliasMap[e]]||this.defaultCommand,a=t.getInternalMethods().getContext(),c=a.commands.slice(),u=!e;if(e)a.commands.push(e),a.fullCommands.push(o.original);let f=this.applyBuilderUpdateUsageAndParse(u,o,t,n.aliases,c,i,s,r);return ne(f)?f.then((l)=>this.applyMiddlewareAndGetResult(u,o,l.innerArgv,a,s,l.aliases,t)):this.applyMiddlewareAndGetResult(u,o,f.innerArgv,a,s,f.aliases,t)}applyBuilderUpdateUsageAndParse(e,t,n,i,s,r,o,a){let c=t.builder,u=n;if(kn(c)){n.getInternalMethods().getUsageInstance().freeze();let f=c(n.getInternalMethods().reset(i),a);if(ne(f))return f.then((l)=>(u=Vr(l)?l:n,this.parseAndUpdateUsage(e,t,u,s,r,o)))}else if(qu(c))n.getInternalMethods().getUsageInstance().freeze(),u=n.getInternalMethods().reset(i),Object.keys(t.builder).forEach((f)=>{u.option(f,c[f])});return this.parseAndUpdateUsage(e,t,u,s,r,o)}parseAndUpdateUsage(e,t,n,i,s,r){if(e)n.getInternalMethods().getUsageInstance().unfreeze(!0);if(this.shouldUpdateUsage(n))n.getInternalMethods().getUsageInstance().usage(this.usageFromParentCommandsCommandHandler(i,t),t.description);let o=n.getInternalMethods().runYargsParserAndExecuteCommands(null,void 0,!0,s,r);return ne(o)?o.then((a)=>({aliases:n.parsed.aliases,innerArgv:a})):{aliases:n.parsed.aliases,innerArgv:o}}shouldUpdateUsage(e){return!e.getInternalMethods().getUsageInstance().getUsageDisabled()&&e.getInternalMethods().getUsageInstance().getUsage().length===0}usageFromParentCommandsCommandHandler(e,t){let n=Lt.test(t.original)?t.original.replace(Lt,"").trim():t.original,i=e.filter((s)=>!Lt.test(s));return i.push(n),`$0 ${i.join(" ")}`}handleValidationAndGetResult(e,t,n,i,s,r,o,a){if(!r.getInternalMethods().getHasOutput()){let c=r.getInternalMethods().runValidation(s,a,r.parsed.error,e);n=gt(n,(u)=>(c(u),u))}if(t.handler&&!r.getInternalMethods().getHasOutput()){r.getInternalMethods().setHasOutput();let c=!!r.getOptions().configuration["populate--"];if(r.getInternalMethods().postProcess(n,c,!1,!1),n=ht(n,r,o,!1),n=gt(n,(u)=>{let f=t.handler(u);return ne(f)?f.then(()=>u):u}),!e)r.getInternalMethods().getUsageInstance().cacheHelpMessage();if(ne(n)&&!r.getInternalMethods().hasParseCallback())n.catch((u)=>{try{r.getInternalMethods().getUsageInstance().fail(null,u)}catch(f){}})}if(!e)i.commands.pop(),i.fullCommands.pop();return n}applyMiddlewareAndGetResult(e,t,n,i,s,r,o){let a={};if(s)return n;if(!o.getInternalMethods().getHasOutput())a=this.populatePositionals(t,n,i,o);let c=this.globalMiddleware.getMiddleware().slice(0).concat(t.middlewares),u=ht(n,o,c,!0);return ne(u)?u.then((f)=>this.handleValidationAndGetResult(e,t,f,i,r,o,c,a)):this.handleValidationAndGetResult(e,t,u,i,r,o,c,a)}populatePositionals(e,t,n,i){t._=t._.slice(n.commands.length);let s=e.demanded.slice(0),r=e.optional.slice(0),o={};this.validation.positionalCount(s.length,t._.length);while(s.length){let a=s.shift();this.populatePositional(a,t,o)}while(r.length){let a=r.shift();this.populatePositional(a,t,o)}return t._=n.commands.concat(t._.map((a)=>""+a)),this.postProcessPositionals(t,o,this.cmdToParseOptions(e.original),i),o}populatePositional(e,t,n){let i=e.cmd[0];if(e.variadic)n[i]=t._.splice(0).map(String);else if(t._.length)n[i]=[String(t._.shift())]}cmdToParseOptions(e){let t={array:[],default:{},alias:{},demand:{}},n=nt(e);return n.demanded.forEach((i)=>{let[s,...r]=i.cmd;if(i.variadic)t.array.push(s),t.default[s]=[];t.alias[s]=r,t.demand[s]=!0}),n.optional.forEach((i)=>{let[s,...r]=i.cmd;if(i.variadic)t.array.push(s),t.default[s]=[];t.alias[s]=r}),t}postProcessPositionals(e,t,n,i){let s=Object.assign({},i.getOptions());s.default=Object.assign(n.default,s.default);for(let c of Object.keys(n.alias))s.alias[c]=(s.alias[c]||[]).concat(n.alias[c]);s.array=s.array.concat(n.array),s.config={};let r=[];if(Object.keys(t).forEach((c)=>{t[c].map((u)=>{if(s.configuration["unknown-options-as-args"])s.key[c]=!0;r.push(`--${c}`),r.push(u)})}),!r.length)return;let o=Object.assign({},s.configuration,{"populate--":!1}),a=this.shim.Parser.detailed(r,Object.assign({},s,{configuration:o}));if(a.error)i.getInternalMethods().getUsageInstance().fail(a.error.message,a.error);else{let c=Object.keys(t);Object.keys(t).forEach((u)=>{c.push(...a.aliases[u])}),Object.keys(a.argv).forEach((u)=>{if(c.includes(u)){if(!t[u])t[u]=a.argv[u];if(!this.isInConfigs(i,u)&&!this.isDefaulted(i,u)&&Object.prototype.hasOwnProperty.call(e,u)&&Object.prototype.hasOwnProperty.call(a.argv,u)&&(Array.isArray(e[u])||Array.isArray(a.argv[u])))e[u]=[].concat(e[u],a.argv[u]);else e[u]=a.argv[u]}})}}isDefaulted(e,t){let{default:n}=e.getOptions();return Object.prototype.hasOwnProperty.call(n,t)||Object.prototype.hasOwnProperty.call(n,this.shim.Parser.camelCase(t))}isInConfigs(e,t){let{configObjects:n}=e.getOptions();return n.some((i)=>Object.prototype.hasOwnProperty.call(i,t))||n.some((i)=>Object.prototype.hasOwnProperty.call(i,this.shim.Parser.camelCase(t)))}runDefaultBuilderOn(e){if(!this.defaultCommand)return;if(this.shouldUpdateUsage(e)){let n=Lt.test(this.defaultCommand.original)?this.defaultCommand.original:this.defaultCommand.original.replace(/^[^[\]<>]*/,"$0 ");e.getInternalMethods().getUsageInstance().usage(n,this.defaultCommand.description)}let t=this.defaultCommand.builder;if(kn(t))return t(e,!0);else if(!Yr(t))Object.keys(t).forEach((n)=>{e.option(n,t[n])});return}extractDesc({describe:e,description:t,desc:n}){for(let i of[e,t,n]){if(typeof i==="string"||i===!1)return i;Fe(i,!0,this.shim)}return!1}freeze(){this.frozens.push({handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand})}unfreeze(){let e=this.frozens.pop();Fe(e,void 0,this.shim),{handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand}=e}reset(){return this.handlers={},this.aliasMap={},this.defaultCommand=void 0,this.requireCache=new Set,this}}function Gr(e,t,n,i){return new Xr(e,t,n,i)}function Yr(e){return typeof e==="object"&&!!e.builder&&typeof e.handler==="function"}function Hu(e){return e.every((t)=>typeof t==="string")}function kn(e){return typeof e==="function"}function qu(e){return typeof e==="object"}function Yu(e){return typeof e==="object"&&!Array.isArray(e)}function st(e={},t=()=>!0){let n={};return jt(e).forEach((i)=>{if(t(i,e[i]))n[i]=e[i]}),n}function it(e){if(typeof process>"u")return;[process.stdout,process.stderr].forEach((t)=>{let n=t;if(n._handle&&n.isTTY&&typeof n._handle.setBlocking==="function")n._handle.setBlocking(e)})}function Xu(e){return typeof e==="boolean"}function Qr(e,t){let n=t.y18n.__,i={},s=[];i.failFn=function(x){s.push(x)};let r=null,o=null,a=!0;i.showHelpOnFail=function(x=!0,O){let[W,Z]=typeof x==="string"?[!0,x]:[x,O];if(e.getInternalMethods().isGlobalContext())o=Z;return r=Z,a=W,i};let c=!1;i.fail=function(x,O){let W=e.getInternalMethods().getLoggerInstance();if(s.length)for(let Z=s.length-1;Z>=0;--Z){let re=s[Z];if(Xu(re)){if(O)throw O;else if(x)throw Error(x)}else re(x,O,i)}else{if(e.getExitProcess())it(!0);if(!c){if(c=!0,a)e.showHelp("error"),W.error();if(x||O)W.error(x||O);let Z=r||o;if(Z){if(x||O)W.error("");W.error(Z)}}if(O=O||new le(x),e.getExitProcess())return e.exit(1);else if(e.getInternalMethods().hasParseCallback())return e.exit(1,O);else throw O}};let u=[],f=!1;i.usage=(S,x)=>{if(S===null)return f=!0,u=[],i;return f=!1,u.push([S,x||""]),i},i.getUsage=()=>u,i.getUsageDisabled=()=>f,i.getPositionalGroupName=()=>n("Positionals:");let l=[];i.example=(S,x)=>{l.push([S,x||""])};let d=[];i.command=function(x,O,W,Z,re=!1){if(W)d=d.map((Q)=>(Q[2]=!1,Q));d.push([x,O||"",W,Z,re])},i.getCommands=()=>d;let h={};i.describe=function(x,O){if(Array.isArray(x))x.forEach((W)=>{i.describe(W,O)});else if(typeof x==="object")Object.keys(x).forEach((W)=>{i.describe(W,x[W])});else h[x]=O},i.getDescriptions=()=>h;let m=[];i.epilog=(S)=>{m.push(S)};let p=!1,y;i.wrap=(S)=>{p=!0,y=S},i.getWrap=()=>{if(t.getEnv("YARGS_DISABLE_WRAP"))return null;if(!p)y=L(),p=!0;return y};let E="__yargsString__:";i.deferY18nLookup=(S)=>E+S,i.help=function(){if(C)return C;k();let x=e.customScriptName?e.$0:t.path.basename(e.$0),O=e.getDemandedOptions(),W=e.getDemandedCommands(),Z=e.getDeprecatedOptions(),re=e.getGroups(),Q=e.getOptions(),oe=[];oe=oe.concat(Object.keys(h)),oe=oe.concat(Object.keys(O)),oe=oe.concat(Object.keys(W)),oe=oe.concat(Object.keys(Q.default)),oe=oe.filter(P),oe=Object.keys(oe.reduce((H,ee)=>{if(ee!=="_")H[ee]=!0;return H},{}));let $e=i.getWrap(),J=t.cliui({width:$e,wrap:!!$e});if(!f){if(u.length)u.forEach((H)=>{if(J.div({text:`${H[0].replace(/\$0/g,x)}`}),H[1])J.div({text:`${H[1]}`,padding:[1,0,0,0]})}),J.div();else if(d.length){let H=null;if(W._)H=`${x} <${n("command")}>
15
- `;else H=`${x} [${n("command")}]
16
- `;J.div(`${H}`)}}if(d.length>1||d.length===1&&!d[0][2]){J.div(n("Commands:"));let H=e.getInternalMethods().getContext(),ee=H.commands.length?`${H.commands.join(" ")} `:"";if(e.getInternalMethods().getParserConfiguration()["sort-commands"]===!0)d=d.sort((V,ye)=>V[0].localeCompare(ye[0]));let de=x?`${x} `:"";d.forEach((V)=>{let ye=`${de}${ee}${V[0].replace(/^\$0 ?/,"")}`;J.span({text:ye,padding:[0,2,0,2],width:F(d,$e,`${x}${ee}`)+4},{text:V[1]});let ue=[];if(V[2])ue.push(`[${n("default")}]`);if(V[3]&&V[3].length)ue.push(`[${n("aliases:")} ${V[3].join(", ")}]`);if(V[4])if(typeof V[4]==="string")ue.push(`[${n("deprecated: %s",V[4])}]`);else ue.push(`[${n("deprecated")}]`);if(ue.length)J.div({text:ue.join(" "),padding:[0,0,0,2],align:"right"});else J.div()}),J.div()}let ae=(Object.keys(Q.alias)||[]).concat(Object.keys(e.parsed.newAliases)||[]);oe=oe.filter((H)=>!e.parsed.newAliases[H]&&ae.every((ee)=>(Q.alias[ee]||[]).indexOf(H)===-1));let Oe=n("Options:");if(!re[Oe])re[Oe]=[];A(oe,Q.alias,re,Oe);let z=(H)=>/^--/.test(An(H)),vt=Object.keys(re).filter((H)=>re[H].length>0).map((H)=>{let ee=re[H].filter(P).map((de)=>{if(ae.includes(de))return de;for(let V=0,ye;(ye=ae[V])!==void 0;V++)if((Q.alias[ye]||[]).includes(de))return ye;return de});return{groupName:H,normalizedKeys:ee}}).filter(({normalizedKeys:H})=>H.length>0).map(({groupName:H,normalizedKeys:ee})=>{let de=ee.reduce((V,ye)=>(V[ye]=[ye].concat(Q.alias[ye]||[]).map((ue)=>{if(H===i.getPositionalGroupName())return ue;else return(/^[0-9]$/.test(ue)?Q.boolean.includes(ye)?"-":"--":ue.length>1?"--":"-")+ue}).sort((ue,pe)=>z(ue)===z(pe)?0:z(ue)?1:-1).join(", "),V),{});return{groupName:H,normalizedKeys:ee,switches:de}});if(vt.filter(({groupName:H})=>H!==i.getPositionalGroupName()).some(({normalizedKeys:H,switches:ee})=>!H.every((de)=>z(ee[de]))))vt.filter(({groupName:H})=>H!==i.getPositionalGroupName()).forEach(({normalizedKeys:H,switches:ee})=>{H.forEach((de)=>{if(z(ee[de]))ee[de]=Gu(ee[de],4)})});if(vt.forEach(({groupName:H,normalizedKeys:ee,switches:de})=>{J.div(H),ee.forEach((V)=>{let ye=de[V],ue=h[V]||"",pe=null;if(ue.includes(E))ue=n(ue.substring(E.length));if(Q.boolean.includes(V))pe=`[${n("boolean")}]`;if(Q.count.includes(V))pe=`[${n("count")}]`;if(Q.string.includes(V))pe=`[${n("string")}]`;if(Q.normalize.includes(V))pe=`[${n("string")}]`;if(Q.array.includes(V))pe=`[${n("array")}]`;if(Q.number.includes(V))pe=`[${n("number")}]`;let Ds=(I)=>typeof I==="string"?`[${n("deprecated: %s",I)}]`:`[${n("deprecated")}]`,D=[V in Z?Ds(Z[V]):null,pe,V in O?`[${n("required")}]`:null,Q.choices&&Q.choices[V]?`[${n("choices:")} ${i.stringifiedValues(Q.choices[V])}]`:null,v(Q.default[V],Q.defaultDescription[V])].filter(Boolean).join(" ");J.span({text:An(ye),padding:[0,2,0,2+Zr(ye)],width:F(de,$e)+4},ue);let b=e.getInternalMethods().getUsageConfiguration()["hide-types"]===!0;if(D&&!b)J.div({text:D,padding:[0,0,0,2],align:"right"});else J.div()}),J.div()}),l.length)J.div(n("Examples:")),l.forEach((H)=>{H[0]=H[0].replace(/\$0/g,x)}),l.forEach((H)=>{if(H[1]==="")J.div({text:H[0],padding:[0,2,0,2]});else J.div({text:H[0],padding:[0,2,0,2],width:F(l,$e)+4},{text:H[1]})}),J.div();if(m.length>0){let H=m.map((ee)=>ee.replace(/\$0/g,x)).join(`
17
- `);J.div(`${H}
18
- `)}return J.toString().replace(/\s*$/,"")};function F(S,x,O){let W=0;if(!Array.isArray(S))S=Object.values(S).map((Z)=>[Z]);if(S.forEach((Z)=>{W=Math.max(t.stringWidth(O?`${O} ${An(Z[0])}`:An(Z[0]))+Zr(Z[0]),W)}),x)W=Math.min(W,parseInt((x*0.5).toString(),10));return W}function k(){let S=e.getDemandedOptions(),x=e.getOptions();(Object.keys(x.alias)||[]).forEach((O)=>{x.alias[O].forEach((W)=>{if(h[W])i.describe(O,h[W]);if(W in S)e.demandOption(O,S[W]);if(x.boolean.includes(W))e.boolean(O);if(x.count.includes(W))e.count(O);if(x.string.includes(W))e.string(O);if(x.normalize.includes(W))e.normalize(O);if(x.array.includes(W))e.array(O);if(x.number.includes(W))e.number(O)})})}let C;i.cacheHelpMessage=function(){C=this.help()},i.clearCachedHelpMessage=function(){C=void 0},i.hasCachedHelpMessage=function(){return!!C};function A(S,x,O,W){let Z=[],re=null;return Object.keys(O).forEach((Q)=>{Z=Z.concat(O[Q])}),S.forEach((Q)=>{if(re=[Q].concat(x[Q]),!re.some((oe)=>Z.indexOf(oe)!==-1))O[W].push(Q)}),Z}function P(S){return e.getOptions().hiddenOptions.indexOf(S)<0||e.parsed.argv[e.getOptions().showHiddenOpt]}i.showHelp=(S)=>{let x=e.getInternalMethods().getLoggerInstance();if(!S)S="error";(typeof S==="function"?S:x[S])(i.help())},i.functionDescription=(S)=>["(",S.name?t.Parser.decamelize(S.name,"-"):n("generated-value"),")"].join(""),i.stringifiedValues=function(x,O){let W="",Z=O||", ",re=[].concat(x);if(!x||!re.length)return W;return re.forEach((Q)=>{if(W.length)W+=Z;W+=JSON.stringify(Q)}),W};function v(S,x){let O=`[${n("default:")} `;if(S===void 0&&!x)return null;if(x)O+=x;else switch(typeof S){case"string":O+=`"${S}"`;break;case"object":O+=JSON.stringify(S);break;default:O+=S}return`${O}]`}function L(){if(t.process.stdColumns)return Math.min(80,t.process.stdColumns);else return 80}let R=null;i.version=(S)=>{R=S},i.showVersion=(S)=>{let x=e.getInternalMethods().getLoggerInstance();if(!S)S="error";(typeof S==="function"?S:x[S])(R)},i.reset=function(x){return r=null,c=!1,u=[],f=!1,m=[],l=[],d=[],h=st(h,(O)=>!x[O]),i};let G=[];return i.freeze=function(){G.push({failMessage:r,failureOutput:c,usages:u,usageDisabled:f,epilogs:m,examples:l,commands:d,descriptions:h})},i.unfreeze=function(x=!1){let O=G.pop();if(!O)return;if(x)h={...O.descriptions,...h},d=[...O.commands,...d],u=[...O.usages,...u],l=[...O.examples,...l],m=[...O.epilogs,...m];else({failMessage:r,failureOutput:c,usages:u,usageDisabled:f,epilogs:m,examples:l,commands:d,descriptions:h}=O)},i}function Bs(e){return typeof e==="object"}function Gu(e,t){return Bs(e)?{text:e.text,indentation:e.indentation+t}:{text:e,indentation:t}}function Zr(e){return Bs(e)?e.indentation:0}function An(e){return Bs(e)?e.text:e}var eo=`###-begin-{{app_name}}-completions-###
13
+ `).map((i)=>mu(i,t,n)).join(`
14
+ `)}function Ss(e){return nr(e,{stringWidth:Le,stripAnsi:pt,wrap:_s})}import{dirname as kr,resolve as Ar}from"path";import{readdirSync as Du,statSync as yu}from"fs";function ks(e,t){let n=Ar(".",e),i;if(!yu(n).isDirectory())n=kr(n);while(!0){if(i=t(n,Du(n)),i)return Ar(n,i);if(n=kr(i=n),i===n)break}}import{inspect as Bu}from"util";import{fileURLToPath as zr}from"url";import{format as Fu}from"util";import{normalize as Cu,resolve as Eu}from"path";function ht(e){if(!(e!==e.toLowerCase()&&e!==e.toUpperCase()))e=e.toLowerCase();if(e.indexOf("-")===-1&&e.indexOf("_")===-1)return e;else{let n="",i=!1,s=e.match(/^-+/);for(let r=s?s[0].length:0;r<e.length;r++){let o=e.charAt(r);if(i)i=!1,o=o.toUpperCase();if(r!==0&&(o==="-"||o==="_"))i=!0;else if(o!=="-"&&o!=="_")n+=o}return n}}function Sn(e,t){let n=e.toLowerCase();t=t||"-";let i="";for(let s=0;s<e.length;s++){let r=n.charAt(s),o=e.charAt(s);if(r!==o&&s>0)i+=`${t}${n.charAt(s)}`;else i+=o}return i}function kn(e){if(e===null||e===void 0)return!1;if(typeof e==="number")return!0;if(/^0x[0-9a-f]+$/i.test(e))return!0;if(/^0[^.]/.test(e))return!1;return/^[-]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(e)}function $r(e){if(Array.isArray(e))return e.map((o)=>typeof o!=="string"?o+"":o);e=e.trim();let t=0,n=null,i=null,s=null,r=[];for(let o=0;o<e.length;o++){if(n=i,i=e.charAt(o),i===" "&&!s){if(n!==" ")t++;continue}if(i===s)s=null;else if((i==="'"||i==='"')&&!s)s=i;if(!r[t])r[t]="";r[t]+=i}return r}var Oe;(function(e){e.BOOLEAN="boolean",e.STRING="string",e.NUMBER="number",e.ARRAY="array"})(Oe||(Oe={}));var et;class $s{constructor(e){et=e}parse(e,t){let n=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},t),i=$r(e),s=typeof e==="string",r=wu(Object.assign(Object.create(null),n.alias)),o=Object.assign({"boolean-negation":!0,"camel-case-expansion":!0,"combine-arrays":!1,"dot-notation":!0,"duplicate-arguments-array":!0,"flatten-duplicate-arrays":!0,"greedy-arrays":!0,"halt-at-non-option":!1,"nargs-eats-options":!1,"negation-prefix":"no-","parse-numbers":!0,"parse-positional-numbers":!0,"populate--":!1,"set-placeholder-key":!1,"short-option-groups":!0,"strip-aliased":!1,"strip-dashed":!1,"unknown-options-as-args":!1},n.configuration),a=Object.assign(Object.create(null),n.default),c=n.configObjects||[],u=n.envPrefix,f=o["populate--"],l=f?"--":"_",d=Object.create(null),h=Object.create(null),m=n.__||et.format,p={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:[]},y=/^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/,C=new RegExp("^--"+o["negation-prefix"]+"(.+)");if([].concat(n.array||[]).filter(Boolean).forEach(function(D){let b=typeof D==="object"?D.key:D,T=Object.keys(D).map(function(x){return{boolean:"bools",string:"strings",number:"numbers"}[x]}).filter(Boolean).pop();if(T)p[T][b]=!0;p.arrays[b]=!0,p.keys.push(b)}),[].concat(n.boolean||[]).filter(Boolean).forEach(function(D){p.bools[D]=!0,p.keys.push(D)}),[].concat(n.string||[]).filter(Boolean).forEach(function(D){p.strings[D]=!0,p.keys.push(D)}),[].concat(n.number||[]).filter(Boolean).forEach(function(D){p.numbers[D]=!0,p.keys.push(D)}),[].concat(n.count||[]).filter(Boolean).forEach(function(D){p.counts[D]=!0,p.keys.push(D)}),[].concat(n.normalize||[]).filter(Boolean).forEach(function(D){p.normalize[D]=!0,p.keys.push(D)}),typeof n.narg==="object")Object.entries(n.narg).forEach(([D,b])=>{if(typeof b==="number")p.nargs[D]=b,p.keys.push(D)});if(typeof n.coerce==="object")Object.entries(n.coerce).forEach(([D,b])=>{if(typeof b==="function")p.coercions[D]=b,p.keys.push(D)});if(typeof n.config<"u"){if(Array.isArray(n.config)||typeof n.config==="string")[].concat(n.config).filter(Boolean).forEach(function(D){p.configs[D]=!0});else if(typeof n.config==="object")Object.entries(n.config).forEach(([D,b])=>{if(typeof b==="boolean"||typeof b==="function")p.configs[D]=b})}ge(n.key,r,n.default,p.arrays),Object.keys(a).forEach(function(D){(p.aliases[D]||[]).forEach(function(b){a[b]=a[D]})});let F=null;bs();let k=[],S=Object.assign(Object.create(null),{_:[]}),A={};for(let D=0;D<i.length;D++){let b=i[D],T=b.replace(/^-{3,}/,"---"),x,w,L,M,K,me;if(b!=="--"&&/^-/.test(b)&&te(b))I(b);else if(T.match(/^---+(=|$)/)){I(b);continue}else if(b.match(/^--.+=/)||!o["short-option-groups"]&&b.match(/^-.+=/)){if(M=b.match(/^--?([^=]+)=([\s\S]*)$/),M!==null&&Array.isArray(M)&&M.length>=3)if(J(M[1],p.arrays))D=B(D,M[1],i,M[2]);else if(J(M[1],p.nargs)!==!1)D=W(D,M[1],i,M[2]);else R(M[1],M[2],!0)}else if(b.match(C)&&o["boolean-negation"]){if(M=b.match(C),M!==null&&Array.isArray(M)&&M.length>=2)w=M[1],R(w,J(w,p.arrays)?[!1]:!1)}else if(b.match(/^--.+/)||!o["short-option-groups"]&&b.match(/^-[^-]+/)){if(M=b.match(/^--?(.+)/),M!==null&&Array.isArray(M)&&M.length>=2)if(w=M[1],J(w,p.arrays))D=B(D,w,i);else if(J(w,p.nargs)!==!1)D=W(D,w,i);else if(K=i[D+1],K!==void 0&&(!K.match(/^-/)||K.match(y))&&!J(w,p.bools)&&!J(w,p.counts))R(w,K),D++;else if(/^(true|false)$/.test(K))R(w,K),D++;else R(w,G(w))}else if(b.match(/^-.\..+=/)){if(M=b.match(/^-([^=]+)=([\s\S]*)$/),M!==null&&Array.isArray(M)&&M.length>=3)R(M[1],M[2])}else if(b.match(/^-.\..+/)&&!b.match(y)){if(K=i[D+1],M=b.match(/^-(.\..+)/),M!==null&&Array.isArray(M)&&M.length>=2)if(w=M[1],K!==void 0&&!K.match(/^-/)&&!J(w,p.bools)&&!J(w,p.counts))R(w,K),D++;else R(w,G(w))}else if(b.match(/^-[^-]+/)&&!b.match(y)){L=b.slice(1,-1).split(""),x=!1;for(let Fe=0;Fe<L.length;Fe++){if(K=b.slice(Fe+2),L[Fe+1]&&L[Fe+1]==="="){if(me=b.slice(Fe+3),w=L[Fe],J(w,p.arrays))D=B(D,w,i,me);else if(J(w,p.nargs)!==!1)D=W(D,w,i,me);else R(w,me);x=!0;break}if(K==="-"){R(L[Fe],K);continue}if(/[A-Za-z]/.test(L[Fe])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(K)&&J(K,p.bools)===!1){R(L[Fe],K),x=!0;break}if(L[Fe+1]&&L[Fe+1].match(/\W/)){R(L[Fe],K),x=!0;break}else R(L[Fe],G(L[Fe]))}if(w=b.slice(-1)[0],!x&&w!=="-")if(J(w,p.arrays))D=B(D,w,i);else if(J(w,p.nargs)!==!1)D=W(D,w,i);else if(K=i[D+1],K!==void 0&&(!/^(-|--)[^-]/.test(K)||K.match(y))&&!J(w,p.bools)&&!J(w,p.counts))R(w,K),D++;else if(/^(true|false)$/.test(K))R(w,K),D++;else R(w,G(w))}else if(b.match(/^-[0-9]$/)&&b.match(y)&&J(b.slice(1),p.bools))w=b.slice(1),R(w,G(w));else if(b==="--"){k=i.slice(D+1);break}else if(o["halt-at-non-option"]){k=i.slice(D);break}else I(b)}if(se(S,!0),se(S,!1),O(S),Q(),je(S,p.aliases,a,!0),Z(S),o["set-placeholder-key"])ae(S);if(Object.keys(p.counts).forEach(function(D){if(!ee(S,D.split(".")))R(D,0)}),f&&k.length)S[l]=[];if(k.forEach(function(D){S[l].push(D)}),o["camel-case-expansion"]&&o["strip-dashed"])Object.keys(S).filter((D)=>D!=="--"&&D.includes("-")).forEach((D)=>{delete S[D]});if(o["strip-aliased"])[].concat(...Object.keys(r).map((D)=>r[D])).forEach((D)=>{if(o["camel-case-expansion"]&&D.includes("-"))delete S[D.split(".").map((b)=>ht(b)).join(".")];delete S[D]});function I(D){let b=E("_",D);if(typeof b==="string"||typeof b==="number")S._.push(b)}function W(D,b,T,x){let w,L=J(b,p.nargs);if(L=typeof L!=="number"||isNaN(L)?1:L,L===0){if(!pe(x))F=Error(m("Argument unexpected for: %s",b));return R(b,G(b)),D}let M=pe(x)?0:1;if(o["nargs-eats-options"]){if(T.length-(D+1)+M<L)F=Error(m("Not enough arguments following: %s",b));M=L}else{for(w=D+1;w<T.length;w++)if(!T[w].match(/^-[^0-9]/)||T[w].match(y)||te(T[w]))M++;else break;if(M<L)F=Error(m("Not enough arguments following: %s",b))}let K=Math.min(M,L);if(!pe(x)&&K>0)R(b,x),K--;for(w=D+1;w<K+D+1;w++)R(b,T[w]);return D+K}function B(D,b,T,x){let w=[],L=x||T[D+1],M=J(b,p.nargs);if(J(b,p.bools)&&!/^(true|false)$/.test(L))w.push(!0);else if(pe(L)||pe(x)&&/^-/.test(L)&&!y.test(L)&&!te(L)){if(a[b]!==void 0){let K=a[b];w=Array.isArray(K)?K:[K]}}else{if(!pe(x))w.push(_(b,x,!0));for(let K=D+1;K<T.length;K++){if(!o["greedy-arrays"]&&w.length>0||M&&typeof M==="number"&&w.length>=M)break;if(L=T[K],/^-/.test(L)&&!y.test(L)&&!te(L))break;D=K,w.push(_(b,L,s))}}if(typeof M==="number"&&(M&&w.length<M||isNaN(M)&&w.length===0))F=Error(m("Not enough arguments following: %s",b));return R(b,w),D}function R(D,b,T=s){if(/-/.test(D)&&o["camel-case-expansion"]){let L=D.split(".").map(function(M){return ht(M)}).join(".");Y(D,L)}let x=_(D,b,T),w=D.split(".");if(V(S,w,x),p.aliases[D])p.aliases[D].forEach(function(L){let M=L.split(".");V(S,M,x)});if(w.length>1&&o["dot-notation"])(p.aliases[w[0]]||[]).forEach(function(L){let M=L.split("."),K=[].concat(w);if(K.shift(),M=M.concat(K),!(p.aliases[D]||[]).includes(M.join(".")))V(S,M,x)});if(J(D,p.normalize)&&!J(D,p.arrays))[D].concat(p.aliases[D]||[]).forEach(function(M){Object.defineProperty(A,M,{enumerable:!0,get(){return b},set(K){b=typeof K==="string"?et.normalize(K):K}})})}function Y(D,b){if(!(p.aliases[D]&&p.aliases[D].length))p.aliases[D]=[b],d[b]=!0;if(!(p.aliases[b]&&p.aliases[b].length))Y(b,D)}function _(D,b,T){if(T)b=bu(b);if(J(D,p.bools)||J(D,p.counts)){if(typeof b==="string")b=b==="true"}let x=Array.isArray(b)?b.map(function(w){return E(D,w)}):E(D,b);if(J(D,p.counts)&&(pe(x)||typeof x==="boolean"))x=As();if(J(D,p.normalize)&&J(D,p.arrays))if(Array.isArray(b))x=b.map((w)=>et.normalize(w));else x=et.normalize(b);return x}function E(D,b){if(!o["parse-positional-numbers"]&&D==="_")return b;if(!J(D,p.strings)&&!J(D,p.bools)&&!Array.isArray(b)){if(kn(b)&&o["parse-numbers"]&&Number.isSafeInteger(Math.floor(parseFloat(`${b}`)))||!pe(b)&&J(D,p.numbers))b=Number(b)}return b}function O(D){let b=Object.create(null);je(b,p.aliases,a),Object.keys(p.configs).forEach(function(T){let x=D[T]||b[T];if(x)try{let w=null,L=et.resolve(et.cwd(),x),M=p.configs[T];if(typeof M==="function"){try{w=M(L)}catch(K){w=K}if(w instanceof Error){F=w;return}}else w=et.require(L);j(w)}catch(w){if(w.name==="PermissionDenied")F=w;else if(D[T])F=Error(m("Invalid JSON config file: %s",x))}})}function j(D,b){Object.keys(D).forEach(function(T){let x=D[T],w=b?b+"."+T:T;if(typeof x==="object"&&x!==null&&!Array.isArray(x)&&o["dot-notation"])j(x,w);else if(!ee(S,w.split("."))||J(w,p.arrays)&&o["combine-arrays"])R(w,x)})}function Q(){if(typeof c<"u")c.forEach(function(D){j(D)})}function se(D,b){if(typeof u>"u")return;let T=typeof u==="string"?u:"",x=et.env();Object.keys(x).forEach(function(w){if(T===""||w.lastIndexOf(T,0)===0){let L=w.split("__").map(function(M,K){if(K===0)M=M.substring(T.length);return ht(M)});if((b&&p.configs[L.join(".")]||!b)&&!ee(D,L))R(L.join("."),x[w])}})}function Z(D){let b,T=new Set;Object.keys(D).forEach(function(x){if(!T.has(x)){if(b=J(x,p.coercions),typeof b==="function")try{let w=E(x,b(D[x]));[].concat(p.aliases[x]||[],x).forEach((L)=>{T.add(L),D[L]=w})}catch(w){F=w}}})}function ae(D){return p.keys.forEach((b)=>{if(~b.indexOf("."))return;if(typeof D[b]>"u")D[b]=void 0}),D}function je(D,b,T,x=!1){Object.keys(T).forEach(function(w){if(!ee(D,w.split("."))){if(V(D,w.split("."),T[w]),x)h[w]=!0;(b[w]||[]).forEach(function(L){if(ee(D,L.split(".")))return;V(D,L.split("."),T[w])})}})}function ee(D,b){let T=D;if(!o["dot-notation"])b=[b.join(".")];b.slice(0,-1).forEach(function(w){T=T[w]||{}});let x=b[b.length-1];if(typeof T!=="object")return!1;else return x in T}function V(D,b,T){let x=D;if(!o["dot-notation"])b=[b.join(".")];b.slice(0,-1).forEach(function(me){if(me=Or(me),typeof x==="object"&&x[me]===void 0)x[me]={};if(typeof x[me]!=="object"||Array.isArray(x[me])){if(Array.isArray(x[me]))x[me].push({});else x[me]=[x[me],{}];x=x[me][x[me].length-1]}else x=x[me]});let w=Or(b[b.length-1]),L=J(b.join("."),p.arrays),M=Array.isArray(T),K=o["duplicate-arguments-array"];if(!K&&J(w,p.nargs)){if(K=!0,!pe(x[w])&&p.nargs[w]===1||Array.isArray(x[w])&&x[w].length===p.nargs[w])x[w]=void 0}if(T===As())x[w]=As(x[w]);else if(Array.isArray(x[w]))if(K&&L&&M)x[w]=o["flatten-duplicate-arrays"]?x[w].concat(T):(Array.isArray(x[w][0])?x[w]:[x[w]]).concat([T]);else if(!K&&Boolean(L)===Boolean(M))x[w]=T;else x[w]=x[w].concat([T]);else if(x[w]===void 0&&L)x[w]=M?T:[T];else if(K&&!(x[w]===void 0||J(w,p.counts)||J(w,p.bools)))x[w]=[x[w],T];else x[w]=T}function ge(...D){D.forEach(function(b){Object.keys(b||{}).forEach(function(T){if(p.aliases[T])return;p.aliases[T]=[].concat(r[T]||[]),p.aliases[T].concat(T).forEach(function(x){if(/-/.test(x)&&o["camel-case-expansion"]){let w=ht(x);if(w!==T&&p.aliases[T].indexOf(w)===-1)p.aliases[T].push(w),d[w]=!0}}),p.aliases[T].concat(T).forEach(function(x){if(x.length>1&&/[A-Z]/.test(x)&&o["camel-case-expansion"]){let w=Sn(x,"-");if(w!==T&&p.aliases[T].indexOf(w)===-1)p.aliases[T].push(w),d[w]=!0}}),p.aliases[T].forEach(function(x){p.aliases[x]=[T].concat(p.aliases[T].filter(function(w){return x!==w}))})})})}function J(D,b){let T=[].concat(p.aliases[D]||[],D),x=Object.keys(b),w=T.find((L)=>x.includes(L));return w?b[w]:!1}function qe(D){let b=Object.keys(p);return[].concat(b.map((x)=>p[x])).some(function(x){return Array.isArray(x)?x.includes(D):x[D]})}function Gi(D,...b){return[].concat(...b).some(function(x){let w=D.match(x);return w&&qe(w[1])})}function z(D){if(D.match(y)||!D.match(/^-[^-]+/))return!1;let b=!0,T,x=D.slice(1).split("");for(let w=0;w<x.length;w++){if(T=D.slice(w+2),!qe(x[w])){b=!1;break}if(x[w+1]&&x[w+1]==="="||T==="-"||/[A-Za-z]/.test(x[w])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(T)||x[w+1]&&x[w+1].match(/\W/))break}return b}function te(D){return o["unknown-options-as-args"]&&de(D)}function de(D){if(D=D.replace(/^-{3,}/,"--"),D.match(y))return!1;if(z(D))return!1;return!Gi(D,/^-+([^=]+?)=[\s\S]*$/,C,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}function G(D){if(!J(D,p.bools)&&!J(D,p.counts)&&`${D}`in a)return a[D];else return we(ue(D))}function we(D){return{[Oe.BOOLEAN]:!0,[Oe.STRING]:"",[Oe.NUMBER]:void 0,[Oe.ARRAY]:[]}[D]}function ue(D){let b=Oe.BOOLEAN;if(J(D,p.strings))b=Oe.STRING;else if(J(D,p.numbers))b=Oe.NUMBER;else if(J(D,p.bools))b=Oe.BOOLEAN;else if(J(D,p.arrays))b=Oe.ARRAY;return b}function pe(D){return D===void 0}function bs(){Object.keys(p.counts).find((D)=>{if(J(D,p.arrays))return F=Error(m("Invalid configuration: %s, opts.count excludes opts.array.",D)),!0;else if(J(D,p.nargs))return F=Error(m("Invalid configuration: %s, opts.count excludes opts.narg.",D)),!0;return!1})}return{aliases:Object.assign({},p.aliases),argv:Object.assign(A,S),configuration:o,defaulted:Object.assign({},h),error:F,newAliases:Object.assign({},d)}}}function wu(e){let t=[],n=Object.create(null),i=!0;Object.keys(e).forEach(function(s){t.push([].concat(e[s],s))});while(i){i=!1;for(let s=0;s<t.length;s++)for(let r=s+1;r<t.length;r++)if(t[s].filter(function(a){return t[r].indexOf(a)!==-1}).length){t[s]=t[s].concat(t[r]),t.splice(r,1),i=!0;break}}return t.forEach(function(s){s=s.filter(function(o,a,c){return c.indexOf(o)===a});let r=s.pop();if(r!==void 0&&typeof r==="string")n[r]=s}),n}function As(e){return e!==void 0?e+1:1}function Or(e){if(e==="__proto__")return"___proto___";return e}function bu(e){return typeof e==="string"&&(e[0]==="'"||e[0]==='"')&&e[e.length-1]===e[0]?e.substring(1,e.length-1):e}import{readFileSync as xu}from"fs";import{createRequire as Ir}from"node:module";var Os,Is,Ts,Tr=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):20,Pr=(Is=(Os=process===null||process===void 0?void 0:process.versions)===null||Os===void 0?void 0:Os.node)!==null&&Is!==void 0?Is:(Ts=process===null||process===void 0?void 0:process.version)===null||Ts===void 0?void 0:Ts.slice(1);if(Pr){if(Number(Pr.match(/^([^.]+)/)[1])<Tr)throw Error(`yargs parser supports a minimum Node.js version of ${Tr}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`)}var _u=process?process.env:{},Rr=Ir?Ir(import.meta.url):void 0,Mr=new $s({cwd:process.cwd,env:()=>_u,format:Fu,normalize:Cu,resolve:Eu,require:(e)=>{if(typeof Rr<"u")return Rr(e);else if(e.match(/\.json$/))return JSON.parse(xu(e,"utf8"));else throw Error("only .json config files are supported in ESM")}}),Zt=function(t,n){return Mr.parse(t.slice(),n).argv};Zt.detailed=function(e,t){return Mr.parse(e.slice(),t)};Zt.camelCase=ht;Zt.decamelize=Sn;Zt.looksLikeNumber=kn;var Ps=Zt;import{basename as Nu,dirname as vu,extname as ju,relative as Lu,resolve as Kr,join as Wu}from"path";function Br(){if(Su())return 0;return 1}function Su(){return ku()&&!process.defaultApp}function ku(){return!!process.versions.electron}function Rs(e){return e.slice(Br()+1)}function Nr(){return process.argv[Br()]}import{readFileSync as Au,statSync as $u,writeFile as Ou}from"fs";import{format as Iu}from"util";import{resolve as Tu}from"path";var vr={fs:{readFileSync:Au,writeFile:Ou},format:Iu,resolve:Tu,exists:(e)=>{try{return $u(e).isFile()}catch(t){return!1}}};var We;class jr{constructor(e){e=e||{},this.directory=e.directory||"./locales",this.updateFiles=typeof e.updateFiles==="boolean"?e.updateFiles:!0,this.locale=e.locale||"en",this.fallbackToLanguage=typeof e.fallbackToLanguage==="boolean"?e.fallbackToLanguage:!0,this.cache=Object.create(null),this.writeQueue=[]}__(...e){if(typeof arguments[0]!=="string")return this._taggedLiteral(arguments[0],...arguments);let t=e.shift(),n=function(){};if(typeof e[e.length-1]==="function")n=e.pop();if(n=n||function(){},!this.cache[this.locale])this._readLocaleFile();if(!this.cache[this.locale][t]&&this.updateFiles)this.cache[this.locale][t]=t,this._enqueueWrite({directory:this.directory,locale:this.locale,cb:n});else n();return We.format.apply(We.format,[this.cache[this.locale][t]||t].concat(e))}__n(){let e=Array.prototype.slice.call(arguments),t=e.shift(),n=e.shift(),i=e.shift(),s=function(){};if(typeof e[e.length-1]==="function")s=e.pop();if(!this.cache[this.locale])this._readLocaleFile();let r=i===1?t:n;if(this.cache[this.locale][t])r=this.cache[this.locale][t][i===1?"one":"other"];if(!this.cache[this.locale][t]&&this.updateFiles)this.cache[this.locale][t]={one:t,other:n},this._enqueueWrite({directory:this.directory,locale:this.locale,cb:s});else s();let o=[r];if(~r.indexOf("%d"))o.push(i);return We.format.apply(We.format,o.concat(e))}setLocale(e){this.locale=e}getLocale(){return this.locale}updateLocale(e){if(!this.cache[this.locale])this._readLocaleFile();for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t))this.cache[this.locale][t]=e[t]}_taggedLiteral(e,...t){let n="";return e.forEach(function(i,s){let r=t[s+1];if(n+=i,typeof r<"u")n+="%s"}),this.__.apply(this,[n].concat([].slice.call(t,1)))}_enqueueWrite(e){if(this.writeQueue.push(e),this.writeQueue.length===1)this._processWriteQueue()}_processWriteQueue(){let e=this,t=this.writeQueue[0],n=t.directory,i=t.locale,s=t.cb,r=this._resolveLocaleFile(n,i),o=JSON.stringify(this.cache[i],null,2);We.fs.writeFile(r,o,"utf-8",function(a){if(e.writeQueue.shift(),e.writeQueue.length>0)e._processWriteQueue();s(a)})}_readLocaleFile(){let e={},t=this._resolveLocaleFile(this.directory,this.locale);try{if(We.fs.readFileSync)e=JSON.parse(We.fs.readFileSync(t,"utf-8"))}catch(n){if(n instanceof SyntaxError)n.message="syntax error in "+t;if(n.code==="ENOENT")e={};else throw n}this.cache[this.locale]=e}_resolveLocaleFile(e,t){let n=We.resolve(e,"./",t+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(n)&&~t.lastIndexOf("_")){let i=We.resolve(e,"./",t.split("_")[0]+".json");if(this._fileExistsSync(i))n=i}return n}_fileExistsSync(e){return We.exists(e)}}function Lr(e,t){We=t;let n=new jr(e);return{__:n.__.bind(n),__n:n.__n.bind(n),setLocale:n.setLocale.bind(n),getLocale:n.getLocale.bind(n),updateLocale:n.updateLocale.bind(n),locale:n.locale}}var Pu=(e)=>Lr(e,vr),Wr=Pu;var Hr=Zi(Jr(),1);import{createRequire as Uu}from"node:module";import{readFileSync as Ju,readdirSync as Ku}from"node:fs";var Ms=zr(import.meta.url),zu=Ms.substring(0,Ms.lastIndexOf("node_modules")),Hu=Uu(import.meta.url),Bs={assert:{notStrictEqual:Ru,strictEqual:Mu},cliui:Ss,findUp:ks,getEnv:(e)=>process.env[e],inspect:Bu,getProcessArgvBin:Nr,mainFilename:zu||process.cwd(),Parser:Ps,path:{basename:Nu,dirname:vu,extname:ju,relative:Lu,resolve:Kr,join:Wu},process:{argv:()=>process.argv,cwd:process.cwd,emitWarning:(e,t)=>process.emitWarning(e,t),execPath:()=>process.execPath,exit:(e)=>{process.exit(e)},nextTick:process.nextTick,stdColumns:typeof process.stdout.columns<"u"?process.stdout.columns:null},readFileSync:Ju,readdirSync:Ku,require:Hu,getCallerFile:()=>{let e=Hr.default(3);return e.match(/^file:\/\//)?zr(e):e},stringWidth:Le,y18n:Wr({directory:Kr(Ms,"../../../locales"),updateFiles:!1})};function Ce(e,t,n,i){n.assert.notStrictEqual(e,t,i)}function Ns(e,t){t.assert.strictEqual(typeof e,"string")}function jt(e){return Object.keys(e)}function ie(e){return!!e&&!!e.then&&typeof e.then==="function"}class le extends Error{constructor(e){super(e||"yargs error");if(this.name="YError",Error.captureStackTrace)Error.captureStackTrace(this,le)}}function st(e){let n=e.replace(/\s{2,}/g," ").split(/\s+(?![^[]*]|[^<]*>)/),i=/\.*[\][<>]/g,s=n.shift();if(!s)throw Error(`No command found in: ${e}`);let r={cmd:s.replace(i,""),demanded:[],optional:[]};return n.forEach((o,a)=>{let c=!1;if(o=o.replace(/\s/g,""),/\.+[\]>]/.test(o)&&a===n.length-1)c=!0;if(/^\[/.test(o))r.optional.push({cmd:o.replace(i,"").split("|"),variadic:c});else r.demanded.push({cmd:o.replace(i,"").split("|"),variadic:c})}),r}var qu=["first","second","third","fourth","fifth","sixth"];function N(e,t,n){function i(){return typeof e==="object"?[{demanded:[],optional:[]},e,t]:[st(`cmd ${e}`),t,n]}try{let s=0,[r,o,a]=i(),c=[].slice.call(o);while(c.length&&c[c.length-1]===void 0)c.pop();let u=a||c.length;if(u<r.demanded.length)throw new le(`Not enough arguments provided. Expected ${r.demanded.length} but received ${c.length}.`);let f=r.demanded.length+r.optional.length;if(u>f)throw new le(`Too many arguments provided. Expected max ${f} but received ${u}.`);r.demanded.forEach((l)=>{let d=c.shift(),h=qr(d);if(l.cmd.filter((p)=>p===h||p==="*").length===0)Yr(h,l.cmd,s);s+=1}),r.optional.forEach((l)=>{if(c.length===0)return;let d=c.shift(),h=qr(d);if(l.cmd.filter((p)=>p===h||p==="*").length===0)Yr(h,l.cmd,s);s+=1})}catch(s){console.warn(s.stack)}}function qr(e){if(Array.isArray(e))return"array";else if(e===null)return"null";return typeof e}function Yr(e,t,n){throw new le(`Invalid ${qu[n]||"manyith"} argument. Expected ${t.join(" or ")} but received ${e}.`)}class vs{constructor(e){this.globalMiddleware=[],this.frozens=[],this.yargs=e}addMiddleware(e,t,n=!0,i=!1){if(N("<array|function> [boolean] [boolean] [boolean]",[e,t,n],arguments.length),Array.isArray(e)){for(let s=0;s<e.length;s++){if(typeof e[s]!=="function")throw Error("middleware must be a function");let r=e[s];r.applyBeforeValidation=t,r.global=n}Array.prototype.push.apply(this.globalMiddleware,e)}else if(typeof e==="function"){let s=e;s.applyBeforeValidation=t,s.global=n,s.mutates=i,this.globalMiddleware.push(e)}return this.yargs}addCoerceMiddleware(e,t){let n=this.yargs.getAliases();return this.globalMiddleware=this.globalMiddleware.filter((i)=>{let s=[...n[t]||[],t];if(!i.option)return!0;else return!s.includes(i.option)}),e.option=t,this.addMiddleware(e,!0,!0,!0)}getMiddleware(){return this.globalMiddleware}freeze(){this.frozens.push([...this.globalMiddleware])}unfreeze(){let e=this.frozens.pop();if(e!==void 0)this.globalMiddleware=e}reset(){this.globalMiddleware=this.globalMiddleware.filter((e)=>e.global)}}function Xr(e){if(!e)return[];return e.map((t)=>(t.applyBeforeValidation=!1,t))}function gt(e,t,n,i){return n.reduce((s,r)=>{if(r.applyBeforeValidation!==i)return s;if(r.mutates){if(r.applied)return s;r.applied=!0}if(ie(s))return s.then((o)=>Promise.all([o,r(o,t)])).then(([o,a])=>Object.assign(o,a));else{let o=r(s,t);return ie(o)?o.then((a)=>Object.assign(s,a)):Object.assign(s,o)}},e)}function mt(e,t,n=(i)=>{throw i}){try{let i=Yu(e)?e():e;return ie(i)?i.then((s)=>t(s)):t(i)}catch(i){return n(i)}}function Yu(e){return typeof e==="function"}var Lt=/(^\*)|(^\$0)/;class Vr{constructor(e,t,n,i){this.requireCache=new Set,this.handlers={},this.aliasMap={},this.frozens=[],this.shim=i,this.usage=e,this.globalMiddleware=n,this.validation=t}addDirectory(e,t,n,i){i=i||{},this.requireCache.add(n);let s=this.shim.path.resolve(this.shim.path.dirname(n),e),r=this.shim.readdirSync(s,{recursive:i.recurse?!0:!1});if(!Array.isArray(i.extensions))i.extensions=["js"];let o=typeof i.visit==="function"?i.visit:(a)=>a;for(let a of r){let c=a.toString();if(i.exclude){let f=!1;if(typeof i.exclude==="function")f=i.exclude(c);else f=i.exclude.test(c);if(f)continue}if(i.include){let f=!1;if(typeof i.include==="function")f=i.include(c);else f=i.include.test(c);if(!f)continue}let u=!1;for(let f of i.extensions)if(c.endsWith(f))u=!0;if(u){let f=this.shim.path.join(s,c),l=t(f),d=Object.create(null,Object.getOwnPropertyDescriptors({...l}));if(o(d,f,c)){if(this.requireCache.has(f))continue;else this.requireCache.add(f);if(!d.command)d.command=this.shim.path.basename(f,this.shim.path.extname(f));this.addHandler(d)}}}}addHandler(e,t,n,i,s,r){let o=[],a=Xr(s);if(i=i||(()=>{}),Array.isArray(e))if(Xu(e))[e,...o]=e;else for(let c of e)this.addHandler(c);else if(Vu(e)){let c=Array.isArray(e.command)||typeof e.command==="string"?e.command:null;if(c===null)throw Error(`No command name given for module: ${this.shim.inspect(e)}`);if(e.aliases)c=[].concat(c).concat(e.aliases);this.addHandler(c,this.extractDesc(e),e.builder,e.handler,e.middlewares,e.deprecated);return}else if(Gr(n)){this.addHandler([e].concat(o),t,n.builder,n.handler,n.middlewares,n.deprecated);return}if(typeof e==="string"){let c=st(e);o=o.map((l)=>st(l).cmd);let u=!1,f=[c.cmd].concat(o).filter((l)=>{if(Lt.test(l))return u=!0,!1;return!0});if(f.length===0&&u)f.push("$0");if(u)c.cmd=f[0],o=f.slice(1),e=e.replace(Lt,c.cmd);if(o.forEach((l)=>{this.aliasMap[l]=c.cmd}),t!==!1)this.usage.command(e,t,u,o,r);if(this.handlers[c.cmd]={original:e,description:t,handler:i,builder:n||{},middlewares:a,deprecated:r,demanded:c.demanded,optional:c.optional},u)this.defaultCommand=this.handlers[c.cmd]}}getCommandHandlers(){return this.handlers}getCommands(){return Object.keys(this.handlers).concat(Object.keys(this.aliasMap))}hasDefaultCommand(){return!!this.defaultCommand}runCommand(e,t,n,i,s,r){let o=this.handlers[e]||this.handlers[this.aliasMap[e]]||this.defaultCommand,a=t.getInternalMethods().getContext(),c=a.commands.slice(),u=!e;if(e)a.commands.push(e),a.fullCommands.push(o.original);let f=this.applyBuilderUpdateUsageAndParse(u,o,t,n.aliases,c,i,s,r);return ie(f)?f.then((l)=>this.applyMiddlewareAndGetResult(u,o,l.innerArgv,a,s,l.aliases,t)):this.applyMiddlewareAndGetResult(u,o,f.innerArgv,a,s,f.aliases,t)}applyBuilderUpdateUsageAndParse(e,t,n,i,s,r,o,a){let c=t.builder,u=n;if(An(c)){n.getInternalMethods().getUsageInstance().freeze();let f=c(n.getInternalMethods().reset(i),a);if(ie(f))return f.then((l)=>(u=Qr(l)?l:n,this.parseAndUpdateUsage(e,t,u,s,r,o)))}else if(Gu(c))n.getInternalMethods().getUsageInstance().freeze(),u=n.getInternalMethods().reset(i),Object.keys(t.builder).forEach((f)=>{u.option(f,c[f])});return this.parseAndUpdateUsage(e,t,u,s,r,o)}parseAndUpdateUsage(e,t,n,i,s,r){if(e)n.getInternalMethods().getUsageInstance().unfreeze(!0);if(this.shouldUpdateUsage(n))n.getInternalMethods().getUsageInstance().usage(this.usageFromParentCommandsCommandHandler(i,t),t.description);let o=n.getInternalMethods().runYargsParserAndExecuteCommands(null,void 0,!0,s,r);return ie(o)?o.then((a)=>({aliases:n.parsed.aliases,innerArgv:a})):{aliases:n.parsed.aliases,innerArgv:o}}shouldUpdateUsage(e){return!e.getInternalMethods().getUsageInstance().getUsageDisabled()&&e.getInternalMethods().getUsageInstance().getUsage().length===0}usageFromParentCommandsCommandHandler(e,t){let n=Lt.test(t.original)?t.original.replace(Lt,"").trim():t.original,i=e.filter((s)=>!Lt.test(s));return i.push(n),`$0 ${i.join(" ")}`}handleValidationAndGetResult(e,t,n,i,s,r,o,a){if(!r.getInternalMethods().getHasOutput()){let c=r.getInternalMethods().runValidation(s,a,r.parsed.error,e);n=mt(n,(u)=>(c(u),u))}if(t.handler&&!r.getInternalMethods().getHasOutput()){r.getInternalMethods().setHasOutput();let c=!!r.getOptions().configuration["populate--"];if(r.getInternalMethods().postProcess(n,c,!1,!1),n=gt(n,r,o,!1),n=mt(n,(u)=>{let f=t.handler(u);return ie(f)?f.then(()=>u):u}),!e)r.getInternalMethods().getUsageInstance().cacheHelpMessage();if(ie(n)&&!r.getInternalMethods().hasParseCallback())n.catch((u)=>{try{r.getInternalMethods().getUsageInstance().fail(null,u)}catch(f){}})}if(!e)i.commands.pop(),i.fullCommands.pop();return n}applyMiddlewareAndGetResult(e,t,n,i,s,r,o){let a={};if(s)return n;if(!o.getInternalMethods().getHasOutput())a=this.populatePositionals(t,n,i,o);let c=this.globalMiddleware.getMiddleware().slice(0).concat(t.middlewares),u=gt(n,o,c,!0);return ie(u)?u.then((f)=>this.handleValidationAndGetResult(e,t,f,i,r,o,c,a)):this.handleValidationAndGetResult(e,t,u,i,r,o,c,a)}populatePositionals(e,t,n,i){t._=t._.slice(n.commands.length);let s=e.demanded.slice(0),r=e.optional.slice(0),o={};this.validation.positionalCount(s.length,t._.length);while(s.length){let a=s.shift();this.populatePositional(a,t,o)}while(r.length){let a=r.shift();this.populatePositional(a,t,o)}return t._=n.commands.concat(t._.map((a)=>""+a)),this.postProcessPositionals(t,o,this.cmdToParseOptions(e.original),i),o}populatePositional(e,t,n){let i=e.cmd[0];if(e.variadic)n[i]=t._.splice(0).map(String);else if(t._.length)n[i]=[String(t._.shift())]}cmdToParseOptions(e){let t={array:[],default:{},alias:{},demand:{}},n=st(e);return n.demanded.forEach((i)=>{let[s,...r]=i.cmd;if(i.variadic)t.array.push(s),t.default[s]=[];t.alias[s]=r,t.demand[s]=!0}),n.optional.forEach((i)=>{let[s,...r]=i.cmd;if(i.variadic)t.array.push(s),t.default[s]=[];t.alias[s]=r}),t}postProcessPositionals(e,t,n,i){let s=Object.assign({},i.getOptions());s.default=Object.assign(n.default,s.default);for(let c of Object.keys(n.alias))s.alias[c]=(s.alias[c]||[]).concat(n.alias[c]);s.array=s.array.concat(n.array),s.config={};let r=[];if(Object.keys(t).forEach((c)=>{t[c].map((u)=>{if(s.configuration["unknown-options-as-args"])s.key[c]=!0;r.push(`--${c}`),r.push(u)})}),!r.length)return;let o=Object.assign({},s.configuration,{"populate--":!1}),a=this.shim.Parser.detailed(r,Object.assign({},s,{configuration:o}));if(a.error)i.getInternalMethods().getUsageInstance().fail(a.error.message,a.error);else{let c=Object.keys(t);Object.keys(t).forEach((u)=>{c.push(...a.aliases[u])}),Object.keys(a.argv).forEach((u)=>{if(c.includes(u)){if(!t[u])t[u]=a.argv[u];if(!this.isInConfigs(i,u)&&!this.isDefaulted(i,u)&&Object.prototype.hasOwnProperty.call(e,u)&&Object.prototype.hasOwnProperty.call(a.argv,u)&&(Array.isArray(e[u])||Array.isArray(a.argv[u])))e[u]=[].concat(e[u],a.argv[u]);else e[u]=a.argv[u]}})}}isDefaulted(e,t){let{default:n}=e.getOptions();return Object.prototype.hasOwnProperty.call(n,t)||Object.prototype.hasOwnProperty.call(n,this.shim.Parser.camelCase(t))}isInConfigs(e,t){let{configObjects:n}=e.getOptions();return n.some((i)=>Object.prototype.hasOwnProperty.call(i,t))||n.some((i)=>Object.prototype.hasOwnProperty.call(i,this.shim.Parser.camelCase(t)))}runDefaultBuilderOn(e){if(!this.defaultCommand)return;if(this.shouldUpdateUsage(e)){let n=Lt.test(this.defaultCommand.original)?this.defaultCommand.original:this.defaultCommand.original.replace(/^[^[\]<>]*/,"$0 ");e.getInternalMethods().getUsageInstance().usage(n,this.defaultCommand.description)}let t=this.defaultCommand.builder;if(An(t))return t(e,!0);else if(!Gr(t))Object.keys(t).forEach((n)=>{e.option(n,t[n])});return}extractDesc({describe:e,description:t,desc:n}){for(let i of[e,t,n]){if(typeof i==="string"||i===!1)return i;Ce(i,!0,this.shim)}return!1}freeze(){this.frozens.push({handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand})}unfreeze(){let e=this.frozens.pop();Ce(e,void 0,this.shim),{handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand}=e}reset(){return this.handlers={},this.aliasMap={},this.defaultCommand=void 0,this.requireCache=new Set,this}}function Zr(e,t,n,i){return new Vr(e,t,n,i)}function Gr(e){return typeof e==="object"&&!!e.builder&&typeof e.handler==="function"}function Xu(e){return e.every((t)=>typeof t==="string")}function An(e){return typeof e==="function"}function Gu(e){return typeof e==="object"}function Vu(e){return typeof e==="object"&&!Array.isArray(e)}function it(e={},t=()=>!0){let n={};return jt(e).forEach((i)=>{if(t(i,e[i]))n[i]=e[i]}),n}function rt(e){if(typeof process>"u")return;[process.stdout,process.stderr].forEach((t)=>{let n=t;if(n._handle&&n.isTTY&&typeof n._handle.setBlocking==="function")n._handle.setBlocking(e)})}function Zu(e){return typeof e==="boolean"}function to(e,t){let n=t.y18n.__,i={},s=[];i.failFn=function(E){s.push(E)};let r=null,o=null,a=!0;i.showHelpOnFail=function(E=!0,O){let[j,Q]=typeof E==="string"?[!0,E]:[E,O];if(e.getInternalMethods().isGlobalContext())o=Q;return r=Q,a=j,i};let c=!1;i.fail=function(E,O){let j=e.getInternalMethods().getLoggerInstance();if(s.length)for(let Q=s.length-1;Q>=0;--Q){let se=s[Q];if(Zu(se)){if(O)throw O;else if(E)throw Error(E)}else se(E,O,i)}else{if(e.getExitProcess())rt(!0);if(!c){if(c=!0,a)e.showHelp("error"),j.error();if(E||O)j.error(E||O);let Q=r||o;if(Q){if(E||O)j.error("");j.error(Q)}}if(O=O||new le(E),e.getExitProcess())return e.exit(1);else if(e.getInternalMethods().hasParseCallback())return e.exit(1,O);else throw O}};let u=[],f=!1;i.usage=(_,E)=>{if(_===null)return f=!0,u=[],i;return f=!1,u.push([_,E||""]),i},i.getUsage=()=>u,i.getUsageDisabled=()=>f,i.getPositionalGroupName=()=>n("Positionals:");let l=[];i.example=(_,E)=>{l.push([_,E||""])};let d=[];i.command=function(E,O,j,Q,se=!1){if(j)d=d.map((Z)=>(Z[2]=!1,Z));d.push([E,O||"",j,Q,se])},i.getCommands=()=>d;let h={};i.describe=function(E,O){if(Array.isArray(E))E.forEach((j)=>{i.describe(j,O)});else if(typeof E==="object")Object.keys(E).forEach((j)=>{i.describe(j,E[j])});else h[E]=O},i.getDescriptions=()=>h;let m=[];i.epilog=(_)=>{m.push(_)};let p=!1,y;i.wrap=(_)=>{p=!0,y=_},i.getWrap=()=>{if(t.getEnv("YARGS_DISABLE_WRAP"))return null;if(!p)y=B(),p=!0;return y};let C="__yargsString__:";i.deferY18nLookup=(_)=>C+_,i.help=function(){if(S)return S;k();let E=e.customScriptName?e.$0:t.path.basename(e.$0),O=e.getDemandedOptions(),j=e.getDemandedCommands(),Q=e.getDeprecatedOptions(),se=e.getGroups(),Z=e.getOptions(),ae=[];ae=ae.concat(Object.keys(h)),ae=ae.concat(Object.keys(O)),ae=ae.concat(Object.keys(j)),ae=ae.concat(Object.keys(Z.default)),ae=ae.filter(I),ae=Object.keys(ae.reduce((z,te)=>{if(te!=="_")z[te]=!0;return z},{}));let je=i.getWrap(),ee=t.cliui({width:je,wrap:!!je});if(!f){if(u.length)u.forEach((z)=>{if(ee.div({text:`${z[0].replace(/\$0/g,E)}`}),z[1])ee.div({text:`${z[1]}`,padding:[1,0,0,0]})}),ee.div();else if(d.length){let z=null;if(j._)z=`${E} <${n("command")}>
15
+ `;else z=`${E} [${n("command")}]
16
+ `;ee.div(`${z}`)}}if(d.length>1||d.length===1&&!d[0][2]){ee.div(n("Commands:"));let z=e.getInternalMethods().getContext(),te=z.commands.length?`${z.commands.join(" ")} `:"";if(e.getInternalMethods().getParserConfiguration()["sort-commands"]===!0)d=d.sort((G,we)=>G[0].localeCompare(we[0]));let de=E?`${E} `:"";d.forEach((G)=>{let we=`${de}${te}${G[0].replace(/^\$0 ?/,"")}`;ee.span({text:we,padding:[0,2,0,2],width:F(d,je,`${E}${te}`)+4},{text:G[1]});let ue=[];if(G[2])ue.push(`[${n("default")}]`);if(G[3]&&G[3].length)ue.push(`[${n("aliases:")} ${G[3].join(", ")}]`);if(G[4])if(typeof G[4]==="string")ue.push(`[${n("deprecated: %s",G[4])}]`);else ue.push(`[${n("deprecated")}]`);if(ue.length)ee.div({text:ue.join(" "),padding:[0,0,0,2],align:"right"});else ee.div()}),ee.div()}let V=(Object.keys(Z.alias)||[]).concat(Object.keys(e.parsed.newAliases)||[]);ae=ae.filter((z)=>!e.parsed.newAliases[z]&&V.every((te)=>(Z.alias[te]||[]).indexOf(z)===-1));let ge=n("Options:");if(!se[ge])se[ge]=[];A(ae,Z.alias,se,ge);let J=(z)=>/^--/.test($n(z)),qe=Object.keys(se).filter((z)=>se[z].length>0).map((z)=>{let te=se[z].filter(I).map((de)=>{if(V.includes(de))return de;for(let G=0,we;(we=V[G])!==void 0;G++)if((Z.alias[we]||[]).includes(de))return we;return de});return{groupName:z,normalizedKeys:te}}).filter(({normalizedKeys:z})=>z.length>0).map(({groupName:z,normalizedKeys:te})=>{let de=te.reduce((G,we)=>(G[we]=[we].concat(Z.alias[we]||[]).map((ue)=>{if(z===i.getPositionalGroupName())return ue;else return(/^[0-9]$/.test(ue)?Z.boolean.includes(we)?"-":"--":ue.length>1?"--":"-")+ue}).sort((ue,pe)=>J(ue)===J(pe)?0:J(ue)?1:-1).join(", "),G),{});return{groupName:z,normalizedKeys:te,switches:de}});if(qe.filter(({groupName:z})=>z!==i.getPositionalGroupName()).some(({normalizedKeys:z,switches:te})=>!z.every((de)=>J(te[de]))))qe.filter(({groupName:z})=>z!==i.getPositionalGroupName()).forEach(({normalizedKeys:z,switches:te})=>{z.forEach((de)=>{if(J(te[de]))te[de]=Qu(te[de],4)})});if(qe.forEach(({groupName:z,normalizedKeys:te,switches:de})=>{ee.div(z),te.forEach((G)=>{let we=de[G],ue=h[G]||"",pe=null;if(ue.includes(C))ue=n(ue.substring(C.length));if(Z.boolean.includes(G))pe=`[${n("boolean")}]`;if(Z.count.includes(G))pe=`[${n("count")}]`;if(Z.string.includes(G))pe=`[${n("string")}]`;if(Z.normalize.includes(G))pe=`[${n("string")}]`;if(Z.array.includes(G))pe=`[${n("array")}]`;if(Z.number.includes(G))pe=`[${n("number")}]`;let bs=(T)=>typeof T==="string"?`[${n("deprecated: %s",T)}]`:`[${n("deprecated")}]`,D=[G in Q?bs(Q[G]):null,pe,G in O?`[${n("required")}]`:null,Z.choices&&Z.choices[G]?`[${n("choices:")} ${i.stringifiedValues(Z.choices[G])}]`:null,W(Z.default[G],Z.defaultDescription[G])].filter(Boolean).join(" ");ee.span({text:$n(we),padding:[0,2,0,2+eo(we)],width:F(de,je)+4},ue);let b=e.getInternalMethods().getUsageConfiguration()["hide-types"]===!0;if(D&&!b)ee.div({text:D,padding:[0,0,0,2],align:"right"});else ee.div()}),ee.div()}),l.length)ee.div(n("Examples:")),l.forEach((z)=>{z[0]=z[0].replace(/\$0/g,E)}),l.forEach((z)=>{if(z[1]==="")ee.div({text:z[0],padding:[0,2,0,2]});else ee.div({text:z[0],padding:[0,2,0,2],width:F(l,je)+4},{text:z[1]})}),ee.div();if(m.length>0){let z=m.map((te)=>te.replace(/\$0/g,E)).join(`
17
+ `);ee.div(`${z}
18
+ `)}return ee.toString().replace(/\s*$/,"")};function F(_,E,O){let j=0;if(!Array.isArray(_))_=Object.values(_).map((Q)=>[Q]);if(_.forEach((Q)=>{j=Math.max(t.stringWidth(O?`${O} ${$n(Q[0])}`:$n(Q[0]))+eo(Q[0]),j)}),E)j=Math.min(j,parseInt((E*0.5).toString(),10));return j}function k(){let _=e.getDemandedOptions(),E=e.getOptions();(Object.keys(E.alias)||[]).forEach((O)=>{E.alias[O].forEach((j)=>{if(h[j])i.describe(O,h[j]);if(j in _)e.demandOption(O,_[j]);if(E.boolean.includes(j))e.boolean(O);if(E.count.includes(j))e.count(O);if(E.string.includes(j))e.string(O);if(E.normalize.includes(j))e.normalize(O);if(E.array.includes(j))e.array(O);if(E.number.includes(j))e.number(O)})})}let S;i.cacheHelpMessage=function(){S=this.help()},i.clearCachedHelpMessage=function(){S=void 0},i.hasCachedHelpMessage=function(){return!!S};function A(_,E,O,j){let Q=[],se=null;return Object.keys(O).forEach((Z)=>{Q=Q.concat(O[Z])}),_.forEach((Z)=>{if(se=[Z].concat(E[Z]),!se.some((ae)=>Q.indexOf(ae)!==-1))O[j].push(Z)}),Q}function I(_){return e.getOptions().hiddenOptions.indexOf(_)<0||e.parsed.argv[e.getOptions().showHiddenOpt]}i.showHelp=(_)=>{let E=e.getInternalMethods().getLoggerInstance();if(!_)_="error";(typeof _==="function"?_:E[_])(i.help())},i.functionDescription=(_)=>["(",_.name?t.Parser.decamelize(_.name,"-"):n("generated-value"),")"].join(""),i.stringifiedValues=function(E,O){let j="",Q=O||", ",se=[].concat(E);if(!E||!se.length)return j;return se.forEach((Z)=>{if(j.length)j+=Q;j+=JSON.stringify(Z)}),j};function W(_,E){let O=`[${n("default:")} `;if(_===void 0&&!E)return null;if(E)O+=E;else switch(typeof _){case"string":O+=`"${_}"`;break;case"object":O+=JSON.stringify(_);break;default:O+=_}return`${O}]`}function B(){if(t.process.stdColumns)return Math.min(80,t.process.stdColumns);else return 80}let R=null;i.version=(_)=>{R=_},i.showVersion=(_)=>{let E=e.getInternalMethods().getLoggerInstance();if(!_)_="error";(typeof _==="function"?_:E[_])(R)},i.reset=function(E){return r=null,c=!1,u=[],f=!1,m=[],l=[],d=[],h=it(h,(O)=>!E[O]),i};let Y=[];return i.freeze=function(){Y.push({failMessage:r,failureOutput:c,usages:u,usageDisabled:f,epilogs:m,examples:l,commands:d,descriptions:h})},i.unfreeze=function(E=!1){let O=Y.pop();if(!O)return;if(E)h={...O.descriptions,...h},d=[...O.commands,...d],u=[...O.usages,...u],l=[...O.examples,...l],m=[...O.epilogs,...m];else({failMessage:r,failureOutput:c,usages:u,usageDisabled:f,epilogs:m,examples:l,commands:d,descriptions:h}=O)},i}function js(e){return typeof e==="object"}function Qu(e,t){return js(e)?{text:e.text,indentation:e.indentation+t}:{text:e,indentation:t}}function eo(e){return js(e)?e.indentation:0}function $n(e){return js(e)?e.text:e}var no=`###-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
- `,to=`#compdef {{app_name}}
47
+ `,so=`#compdef {{app_name}}
48
48
  ###-begin-{{app_name}}-completions-###
49
49
  #
50
50
  # yargs command completion script
@@ -71,140 +71,140 @@ else
71
71
  compdef _{{app_name}}_yargs_completions {{app_name}}
72
72
  fi
73
73
  ###-end-{{app_name}}-completions-###
74
- `;class no{constructor(e,t,n,i){var s,r,o;this.yargs=e,this.usage=t,this.command=n,this.shim=i,this.completionKey="get-yargs-completions",this.aliases=null,this.customCompletionFunction=null,this.indexAfterLastReset=0,this.zshShell=(o=((s=this.shim.getEnv("SHELL"))===null||s===void 0?void 0:s.includes("zsh"))||((r=this.shim.getEnv("ZSH_NAME"))===null||r===void 0?void 0:r.includes("zsh")))!==null&&o!==void 0?o:!1}defaultCompletion(e,t,n,i){let s=this.command.getCommandHandlers();for(let o=0,a=e.length;o<a;++o)if(s[e[o]]&&s[e[o]].builder){let c=s[e[o]].builder;if(kn(c)){this.indexAfterLastReset=o+1;let u=this.yargs.getInternalMethods().reset();return c(u,!0),u.argv}}let r=[];this.commandCompletions(r,e,n),this.optionCompletions(r,e,t,n),this.choicesFromOptionsCompletions(r,e,t,n),this.choicesFromPositionalsCompletions(r,e,t,n),i(null,r)}commandCompletions(e,t,n){let i=this.yargs.getInternalMethods().getContext().commands;if(!n.match(/^-/)&&i[i.length-1]!==n&&!this.previousArgHasChoices(t))this.usage.getCommands().forEach((s)=>{let r=nt(s[0]).cmd;if(t.indexOf(r)===-1)if(!this.zshShell)e.push(r);else{let o=s[1]||"";e.push(r.replace(/:/g,"\\:")+":"+o)}})}optionCompletions(e,t,n,i){if((i.match(/^-/)||i===""&&e.length===0)&&!this.previousArgHasChoices(t)){let s=this.yargs.getOptions(),r=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[];Object.keys(s.key).forEach((o)=>{let a=!!s.configuration["boolean-negation"]&&s.boolean.includes(o);if(!r.includes(o)&&!s.hiddenOptions.includes(o)&&!this.argsContainKey(t,o,a))this.completeOptionKey(o,e,i,a&&!!s.default[o])})}}choicesFromOptionsCompletions(e,t,n,i){if(this.previousArgHasChoices(t)){let s=this.getPreviousArgChoices(t);if(s&&s.length>0)e.push(...s.map((r)=>r.replace(/:/g,"\\:")))}}choicesFromPositionalsCompletions(e,t,n,i){if(i===""&&e.length>0&&this.previousArgHasChoices(t))return;let s=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[],r=Math.max(this.indexAfterLastReset,this.yargs.getInternalMethods().getContext().commands.length+1),o=s[n._.length-r-1];if(!o)return;let a=this.yargs.getOptions().choices[o]||[];for(let c of a)if(c.startsWith(i))e.push(c.replace(/:/g,"\\:"))}getPreviousArgChoices(e){if(e.length<1)return;let t=e[e.length-1],n="";if(!t.startsWith("-")&&e.length>1)n=t,t=e[e.length-2];if(!t.startsWith("-"))return;let i=t.replace(/^-+/,""),s=this.yargs.getOptions(),r=[i,...this.yargs.getAliases()[i]||[]],o;for(let a of r)if(Object.prototype.hasOwnProperty.call(s.key,a)&&Array.isArray(s.choices[a])){o=s.choices[a];break}if(o)return o.filter((a)=>!n||a.startsWith(n))}previousArgHasChoices(e){let t=this.getPreviousArgChoices(e);return t!==void 0&&t.length>0}argsContainKey(e,t,n){let i=(s)=>e.indexOf((/^[^0-9]$/.test(s)?"-":"--")+s)!==-1;if(i(t))return!0;if(n&&i(`no-${t}`))return!0;if(this.aliases){for(let s of this.aliases[t])if(i(s))return!0}return!1}completeOptionKey(e,t,n,i){var s,r,o,a;let c=e;if(this.zshShell){let d=this.usage.getDescriptions(),h=(r=(s=this===null||this===void 0?void 0:this.aliases)===null||s===void 0?void 0:s[e])===null||r===void 0?void 0:r.find((y)=>{let E=d[y];return typeof E==="string"&&E.length>0}),m=h?d[h]:void 0,p=(a=(o=d[e])!==null&&o!==void 0?o:m)!==null&&a!==void 0?a:"";c=`${e.replace(/:/g,"\\:")}:${p.replace("__yargsString__:","").replace(/(\r\n|\n|\r)/gm," ")}`}let u=(d)=>/^--/.test(d),f=(d)=>/^[^0-9]$/.test(d),l=!u(n)&&f(e)?"-":"--";if(t.push(l+c),i)t.push(l+"no-"+c)}customCompletion(e,t,n,i){if(Fe(this.customCompletionFunction,null,this.shim),Zu(this.customCompletionFunction)){let s=this.customCompletionFunction(n,t);if(ne(s))return s.then((r)=>{this.shim.process.nextTick(()=>{i(null,r)})}).catch((r)=>{this.shim.process.nextTick(()=>{i(r,void 0)})});return i(null,s)}else if(Qu(this.customCompletionFunction))return this.customCompletionFunction(n,t,(s=i)=>this.defaultCompletion(e,t,n,s),(s)=>{i(null,s)});else return this.customCompletionFunction(n,t,(s)=>{i(null,s)})}getCompletion(e,t){let n=e.length?e[e.length-1]:"",i=this.yargs.parse(e,!0),s=this.customCompletionFunction?(r)=>this.customCompletion(e,r,n,t):(r)=>this.defaultCompletion(e,r,n,t);return ne(i)?i.then(s):s(i)}generateCompletionScript(e,t){let n=this.zshShell?to:eo,i=this.shim.path.basename(e);if(e.match(/\.js$/))e=`./${e}`;return n=n.replace(/{{app_name}}/g,i),n=n.replace(/{{completion_command}}/g,t),n.replace(/{{app_path}}/g,e)}registerFunction(e){this.customCompletionFunction=e}setParsed(e){this.aliases=e.aliases}}function so(e,t,n,i){return new no(e,t,n,i)}function Zu(e){return e.length<3}function Qu(e){return e.length>3}function io(e,t){if(e.length===0)return t.length;if(t.length===0)return e.length;let n=[],i;for(i=0;i<=t.length;i++)n[i]=[i];let s;for(s=0;s<=e.length;s++)n[0][s]=s;for(i=1;i<=t.length;i++)for(s=1;s<=e.length;s++)if(t.charAt(i-1)===e.charAt(s-1))n[i][s]=n[i-1][s-1];else if(i>1&&s>1&&t.charAt(i-2)===e.charAt(s-1)&&t.charAt(i-1)===e.charAt(s-2))n[i][s]=n[i-2][s-2]+1;else n[i][s]=Math.min(n[i-1][s-1]+1,Math.min(n[i][s-1]+1,n[i-1][s]+1));return n[t.length][e.length]}var ro=["$0","--","_"];function oo(e,t,n){let i=n.y18n.__,s=n.y18n.__n,r={};r.nonOptionCount=function(l){let d=e.getDemandedCommands(),m=l._.length+(l["--"]?l["--"].length:0)-e.getInternalMethods().getContext().commands.length;if(d._&&(m<d._.min||m>d._.max)){if(m<d._.min)if(d._.minMsg!==void 0)t.fail(d._.minMsg?d._.minMsg.replace(/\$0/g,m.toString()).replace(/\$1/,d._.min.toString()):null);else t.fail(s("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",m,m.toString(),d._.min.toString()));else if(m>d._.max)if(d._.maxMsg!==void 0)t.fail(d._.maxMsg?d._.maxMsg.replace(/\$0/g,m.toString()).replace(/\$1/,d._.max.toString()):null);else t.fail(s("Too many non-option arguments: got %s, maximum of %s","Too many non-option arguments: got %s, maximum of %s",m,m.toString(),d._.max.toString()))}},r.positionalCount=function(l,d){if(d<l)t.fail(s("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",d,d+"",l+""))},r.requiredArguments=function(l,d){let h=null;for(let m of Object.keys(d))if(!Object.prototype.hasOwnProperty.call(l,m)||typeof l[m]>"u")h=h||{},h[m]=d[m];if(h){let m=[];for(let y of Object.keys(h)){let E=h[y];if(E&&m.indexOf(E)<0)m.push(E)}let p=m.length?`
74
+ `;class io{constructor(e,t,n,i){var s,r,o;this.yargs=e,this.usage=t,this.command=n,this.shim=i,this.completionKey="get-yargs-completions",this.aliases=null,this.customCompletionFunction=null,this.indexAfterLastReset=0,this.zshShell=(o=((s=this.shim.getEnv("SHELL"))===null||s===void 0?void 0:s.includes("zsh"))||((r=this.shim.getEnv("ZSH_NAME"))===null||r===void 0?void 0:r.includes("zsh")))!==null&&o!==void 0?o:!1}defaultCompletion(e,t,n,i){let s=this.command.getCommandHandlers();for(let o=0,a=e.length;o<a;++o)if(s[e[o]]&&s[e[o]].builder){let c=s[e[o]].builder;if(An(c)){this.indexAfterLastReset=o+1;let u=this.yargs.getInternalMethods().reset();return c(u,!0),u.argv}}let r=[];this.commandCompletions(r,e,n),this.optionCompletions(r,e,t,n),this.choicesFromOptionsCompletions(r,e,t,n),this.choicesFromPositionalsCompletions(r,e,t,n),i(null,r)}commandCompletions(e,t,n){let i=this.yargs.getInternalMethods().getContext().commands;if(!n.match(/^-/)&&i[i.length-1]!==n&&!this.previousArgHasChoices(t))this.usage.getCommands().forEach((s)=>{let r=st(s[0]).cmd;if(t.indexOf(r)===-1)if(!this.zshShell)e.push(r);else{let o=s[1]||"";e.push(r.replace(/:/g,"\\:")+":"+o)}})}optionCompletions(e,t,n,i){if((i.match(/^-/)||i===""&&e.length===0)&&!this.previousArgHasChoices(t)){let s=this.yargs.getOptions(),r=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[];Object.keys(s.key).forEach((o)=>{let a=!!s.configuration["boolean-negation"]&&s.boolean.includes(o);if(!r.includes(o)&&!s.hiddenOptions.includes(o)&&!this.argsContainKey(t,o,a))this.completeOptionKey(o,e,i,a&&!!s.default[o])})}}choicesFromOptionsCompletions(e,t,n,i){if(this.previousArgHasChoices(t)){let s=this.getPreviousArgChoices(t);if(s&&s.length>0)e.push(...s.map((r)=>r.replace(/:/g,"\\:")))}}choicesFromPositionalsCompletions(e,t,n,i){if(i===""&&e.length>0&&this.previousArgHasChoices(t))return;let s=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[],r=Math.max(this.indexAfterLastReset,this.yargs.getInternalMethods().getContext().commands.length+1),o=s[n._.length-r-1];if(!o)return;let a=this.yargs.getOptions().choices[o]||[];for(let c of a)if(c.startsWith(i))e.push(c.replace(/:/g,"\\:"))}getPreviousArgChoices(e){if(e.length<1)return;let t=e[e.length-1],n="";if(!t.startsWith("-")&&e.length>1)n=t,t=e[e.length-2];if(!t.startsWith("-"))return;let i=t.replace(/^-+/,""),s=this.yargs.getOptions(),r=[i,...this.yargs.getAliases()[i]||[]],o;for(let a of r)if(Object.prototype.hasOwnProperty.call(s.key,a)&&Array.isArray(s.choices[a])){o=s.choices[a];break}if(o)return o.filter((a)=>!n||a.startsWith(n))}previousArgHasChoices(e){let t=this.getPreviousArgChoices(e);return t!==void 0&&t.length>0}argsContainKey(e,t,n){let i=(s)=>e.indexOf((/^[^0-9]$/.test(s)?"-":"--")+s)!==-1;if(i(t))return!0;if(n&&i(`no-${t}`))return!0;if(this.aliases){for(let s of this.aliases[t])if(i(s))return!0}return!1}completeOptionKey(e,t,n,i){var s,r,o,a;let c=e;if(this.zshShell){let d=this.usage.getDescriptions(),h=(r=(s=this===null||this===void 0?void 0:this.aliases)===null||s===void 0?void 0:s[e])===null||r===void 0?void 0:r.find((y)=>{let C=d[y];return typeof C==="string"&&C.length>0}),m=h?d[h]:void 0,p=(a=(o=d[e])!==null&&o!==void 0?o:m)!==null&&a!==void 0?a:"";c=`${e.replace(/:/g,"\\:")}:${p.replace("__yargsString__:","").replace(/(\r\n|\n|\r)/gm," ")}`}let u=(d)=>/^--/.test(d),f=(d)=>/^[^0-9]$/.test(d),l=!u(n)&&f(e)?"-":"--";if(t.push(l+c),i)t.push(l+"no-"+c)}customCompletion(e,t,n,i){if(Ce(this.customCompletionFunction,null,this.shim),tl(this.customCompletionFunction)){let s=this.customCompletionFunction(n,t);if(ie(s))return s.then((r)=>{this.shim.process.nextTick(()=>{i(null,r)})}).catch((r)=>{this.shim.process.nextTick(()=>{i(r,void 0)})});return i(null,s)}else if(nl(this.customCompletionFunction))return this.customCompletionFunction(n,t,(s=i)=>this.defaultCompletion(e,t,n,s),(s)=>{i(null,s)});else return this.customCompletionFunction(n,t,(s)=>{i(null,s)})}getCompletion(e,t){let n=e.length?e[e.length-1]:"",i=this.yargs.parse(e,!0),s=this.customCompletionFunction?(r)=>this.customCompletion(e,r,n,t):(r)=>this.defaultCompletion(e,r,n,t);return ie(i)?i.then(s):s(i)}generateCompletionScript(e,t){let n=this.zshShell?so:no,i=this.shim.path.basename(e);if(e.match(/\.js$/))e=`./${e}`;return n=n.replace(/{{app_name}}/g,i),n=n.replace(/{{completion_command}}/g,t),n.replace(/{{app_path}}/g,e)}registerFunction(e){this.customCompletionFunction=e}setParsed(e){this.aliases=e.aliases}}function ro(e,t,n,i){return new io(e,t,n,i)}function tl(e){return e.length<3}function nl(e){return e.length>3}function oo(e,t){if(e.length===0)return t.length;if(t.length===0)return e.length;let n=[],i;for(i=0;i<=t.length;i++)n[i]=[i];let s;for(s=0;s<=e.length;s++)n[0][s]=s;for(i=1;i<=t.length;i++)for(s=1;s<=e.length;s++)if(t.charAt(i-1)===e.charAt(s-1))n[i][s]=n[i-1][s-1];else if(i>1&&s>1&&t.charAt(i-2)===e.charAt(s-1)&&t.charAt(i-1)===e.charAt(s-2))n[i][s]=n[i-2][s-2]+1;else n[i][s]=Math.min(n[i-1][s-1]+1,Math.min(n[i][s-1]+1,n[i-1][s]+1));return n[t.length][e.length]}var ao=["$0","--","_"];function co(e,t,n){let i=n.y18n.__,s=n.y18n.__n,r={};r.nonOptionCount=function(l){let d=e.getDemandedCommands(),m=l._.length+(l["--"]?l["--"].length:0)-e.getInternalMethods().getContext().commands.length;if(d._&&(m<d._.min||m>d._.max)){if(m<d._.min)if(d._.minMsg!==void 0)t.fail(d._.minMsg?d._.minMsg.replace(/\$0/g,m.toString()).replace(/\$1/,d._.min.toString()):null);else t.fail(s("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",m,m.toString(),d._.min.toString()));else if(m>d._.max)if(d._.maxMsg!==void 0)t.fail(d._.maxMsg?d._.maxMsg.replace(/\$0/g,m.toString()).replace(/\$1/,d._.max.toString()):null);else t.fail(s("Too many non-option arguments: got %s, maximum of %s","Too many non-option arguments: got %s, maximum of %s",m,m.toString(),d._.max.toString()))}},r.positionalCount=function(l,d){if(d<l)t.fail(s("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",d,d+"",l+""))},r.requiredArguments=function(l,d){let h=null;for(let m of Object.keys(d))if(!Object.prototype.hasOwnProperty.call(l,m)||typeof l[m]>"u")h=h||{},h[m]=d[m];if(h){let m=[];for(let y of Object.keys(h)){let C=h[y];if(C&&m.indexOf(C)<0)m.push(C)}let p=m.length?`
75
75
  ${m.join(`
76
- `)}`:"";t.fail(s("Missing required argument: %s","Missing required arguments: %s",Object.keys(h).length,Object.keys(h).join(", ")+p))}},r.unknownArguments=function(l,d,h,m,p=!0){var y;let E=e.getInternalMethods().getCommandInstance().getCommands(),F=[],k=e.getInternalMethods().getContext();if(Object.keys(l).forEach((C)=>{if(!ro.includes(C)&&!Object.prototype.hasOwnProperty.call(h,C)&&!Object.prototype.hasOwnProperty.call(e.getInternalMethods().getParseContext(),C)&&!r.isValidAndSomeAliasIsNotNew(C,d))F.push(C)}),p&&(k.commands.length>0||E.length>0||m))l._.slice(k.commands.length).forEach((C)=>{if(!E.includes(""+C))F.push(""+C)});if(p){let A=((y=e.getDemandedCommands()._)===null||y===void 0?void 0:y.max)||0,P=k.commands.length+A;if(P<l._.length)l._.slice(P).forEach((v)=>{if(v=String(v),!k.commands.includes(v)&&!F.includes(v))F.push(v)})}if(F.length)t.fail(s("Unknown argument: %s","Unknown arguments: %s",F.length,F.map((C)=>C.trim()?C:`"${C}"`).join(", ")))},r.unknownCommands=function(l){let d=e.getInternalMethods().getCommandInstance().getCommands(),h=[],m=e.getInternalMethods().getContext();if(m.commands.length>0||d.length>0)l._.slice(m.commands.length).forEach((p)=>{if(!d.includes(""+p))h.push(""+p)});if(h.length>0)return t.fail(s("Unknown command: %s","Unknown commands: %s",h.length,h.join(", "))),!0;else return!1},r.isValidAndSomeAliasIsNotNew=function(l,d){if(!Object.prototype.hasOwnProperty.call(d,l))return!1;let h=e.parsed.newAliases;return[l,...d[l]].some((m)=>!Object.prototype.hasOwnProperty.call(h,m)||!h[l])},r.limitedChoices=function(l){let d=e.getOptions(),h={};if(!Object.keys(d.choices).length)return;Object.keys(l).forEach((y)=>{if(ro.indexOf(y)===-1&&Object.prototype.hasOwnProperty.call(d.choices,y))[].concat(l[y]).forEach((E)=>{if(d.choices[y].indexOf(E)===-1&&E!==void 0)h[y]=(h[y]||[]).concat(E)})});let m=Object.keys(h);if(!m.length)return;let p=i("Invalid values:");m.forEach((y)=>{p+=`
77
- ${i("Argument: %s, Given: %s, Choices: %s",y,t.stringifiedValues(h[y]),t.stringifiedValues(d.choices[y]))}`}),t.fail(p)};let o={};r.implies=function(l,d){if(B("<string|object> [array|number|string]",[l,d],arguments.length),typeof l==="object")Object.keys(l).forEach((h)=>{r.implies(h,l[h])});else{if(e.global(l),!o[l])o[l]=[];if(Array.isArray(d))d.forEach((h)=>r.implies(l,h));else Fe(d,void 0,n),o[l].push(d)}},r.getImplied=function(){return o};function a(f,l){let d=Number(l);if(l=isNaN(d)?l:d,typeof l==="number")l=f._.length>=l;else if(l.match(/^--no-.+/))l=l.match(/^--no-(.+)/)[1],l=!Object.prototype.hasOwnProperty.call(f,l);else l=Object.prototype.hasOwnProperty.call(f,l);return l}r.implications=function(l){let d=[];if(Object.keys(o).forEach((h)=>{let m=h;(o[h]||[]).forEach((p)=>{let y=m,E=p;if(y=a(l,y),p=a(l,p),y&&!p)d.push(` ${m} -> ${E}`)})}),d.length){let h=`${i("Implications failed:")}
78
- `;d.forEach((m)=>{h+=m}),t.fail(h)}};let c={};r.conflicts=function(l,d){if(B("<string|object> [array|string]",[l,d],arguments.length),typeof l==="object")Object.keys(l).forEach((h)=>{r.conflicts(h,l[h])});else{if(e.global(l),!c[l])c[l]=[];if(Array.isArray(d))d.forEach((h)=>r.conflicts(l,h));else c[l].push(d)}},r.getConflicting=()=>c,r.conflicting=function(l){if(Object.keys(l).forEach((d)=>{if(c[d])c[d].forEach((h)=>{if(h&&l[d]!==void 0&&l[h]!==void 0)t.fail(i("Arguments %s and %s are mutually exclusive",d,h))})}),e.getInternalMethods().getParserConfiguration()["strip-dashed"])Object.keys(c).forEach((d)=>{c[d].forEach((h)=>{if(h&&l[n.Parser.camelCase(d)]!==void 0&&l[n.Parser.camelCase(h)]!==void 0)t.fail(i("Arguments %s and %s are mutually exclusive",d,h))})})},r.recommendCommands=function(l,d){d=d.sort((y,E)=>E.length-y.length);let m=null,p=1/0;for(let y=0,E;(E=d[y])!==void 0;y++){let F=io(l,E);if(F<=3&&F<p)p=F,m=E}if(m)t.fail(i("Did you mean %s?",m))},r.reset=function(l){return o=st(o,(d)=>!l[d]),c=st(c,(d)=>!l[d]),r};let u=[];return r.freeze=function(){u.push({implied:o,conflicting:c})},r.unfreeze=function(){let l=u.pop();Fe(l,void 0,n),{implied:o,conflicting:c}=l},r}var Ns=[],Qt;function en(e,t,n,i){Qt=i;let s={};if(Object.prototype.hasOwnProperty.call(e,"extends")){if(typeof e.extends!=="string")return s;let r=/\.json|\..*rc$/.test(e.extends),o=null;if(!r)try{o=import.meta.resolve(e.extends)}catch(a){return e}else o=tl(t,e.extends);el(o),Ns.push(o),s=r?JSON.parse(Qt.readFileSync(o,"utf8")):i.require(e.extends),delete e.extends,s=en(s,Qt.path.dirname(o),n,Qt)}return Ns=[],n?ao(s,e):Object.assign({},s,e)}function el(e){if(Ns.indexOf(e)>-1)throw new le(`Circular extended configurations: '${e}'.`)}function tl(e,t){return Qt.path.resolve(e,t)}function ao(e,t){let n={};function i(s){return s&&typeof s==="object"&&!Array.isArray(s)}Object.assign(n,e);for(let s of Object.keys(t))if(i(t[s])&&i(n[s]))n[s]=ao(e[s],t[s]);else n[s]=t[s];return n}var N=function(e,t,n,i,s){if(i==="m")throw TypeError("Private method is not writable");if(i==="a"&&!s)throw TypeError("Private accessor was defined without a setter");if(typeof t==="function"?e!==t||!s:!t.has(e))throw TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(e,n):s?s.value=n:t.set(e,n),n},g=function(e,t,n,i){if(n==="a"&&!i)throw TypeError("Private accessor was defined without a getter");if(typeof t==="function"?e!==t||!i:!t.has(e))throw TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?i:n==="a"?i.call(e):i?i.value:t.get(e)},fe,mt,tn,Ee,_e,$n,rt,Dt,On,Te,In,Pe,Ye,Se,Re,Tn,yt,me,U,Pn,Rn,ke,wt,Wt,bt,ot,Mn,q,Ft,Ct,Et,Y,Bn,Xe,ce;function Ao(e){return(t=[],n=e.process.cwd(),i)=>{let s=new $o(t,n,i,e);return Object.defineProperty(s,"argv",{get:()=>s.parse(),enumerable:!0}),s.help(),s.version(),s}}var co=Symbol("copyDoubleDash"),uo=Symbol("copyDoubleDash"),vs=Symbol("deleteFromParserHintObject"),lo=Symbol("emitWarning"),fo=Symbol("freeze"),po=Symbol("getDollarZero"),xt=Symbol("getParserConfiguration"),ho=Symbol("getUsageConfiguration"),js=Symbol("guessLocale"),go=Symbol("guessVersion"),mo=Symbol("parsePositionalNumbers"),Ls=Symbol("pkgUp"),at=Symbol("populateParserHintArray"),Ut=Symbol("populateParserHintSingleValueDictionary"),Ws=Symbol("populateParserHintArrayDictionary"),Us=Symbol("populateParserHintDictionary"),Js=Symbol("sanitizeKey"),Ks=Symbol("setKey"),zs=Symbol("unfreeze"),Do=Symbol("validateAsync"),yo=Symbol("getCommandInstance"),wo=Symbol("getContext"),bo=Symbol("getHasOutput"),Fo=Symbol("getLoggerInstance"),Co=Symbol("getParseContext"),Eo=Symbol("getUsageInstance"),xo=Symbol("getValidationInstance"),Nn=Symbol("hasParseCallback"),_o=Symbol("isGlobalContext"),_t=Symbol("postProcess"),So=Symbol("rebase"),Hs=Symbol("reset"),nn=Symbol("runYargsParserAndExecuteCommands"),qs=Symbol("runValidation"),ko=Symbol("setHasOutput"),St=Symbol("kTrackManuallySetKeys"),nl="en_US";class $o{constructor(e=[],t,n,i){this.customScriptName=!1,this.parsed=!1,fe.set(this,void 0),mt.set(this,void 0),tn.set(this,{commands:[],fullCommands:[]}),Ee.set(this,null),_e.set(this,null),$n.set(this,"show-hidden"),rt.set(this,null),Dt.set(this,!0),On.set(this,{}),Te.set(this,!0),In.set(this,[]),Pe.set(this,void 0),Ye.set(this,{}),Se.set(this,!1),Re.set(this,null),Tn.set(this,!0),yt.set(this,void 0),me.set(this,""),U.set(this,void 0),Pn.set(this,void 0),Rn.set(this,{}),ke.set(this,null),wt.set(this,null),Wt.set(this,{}),bt.set(this,{}),ot.set(this,void 0),Mn.set(this,!1),q.set(this,void 0),Ft.set(this,!1),Ct.set(this,!1),Et.set(this,!1),Y.set(this,void 0),Bn.set(this,{}),Xe.set(this,null),ce.set(this,void 0),N(this,q,i,"f"),N(this,ot,e,"f"),N(this,mt,t,"f"),N(this,Pn,n,"f"),N(this,Pe,new Ms(this),"f"),this.$0=this[po](),this[Hs](),N(this,fe,g(this,fe,"f"),"f"),N(this,Y,g(this,Y,"f"),"f"),N(this,ce,g(this,ce,"f"),"f"),N(this,U,g(this,U,"f"),"f"),g(this,U,"f").showHiddenOpt=g(this,$n,"f"),N(this,yt,this[uo](),"f"),g(this,q,"f").y18n.setLocale(nl)}addHelpOpt(e,t){if(B("[string|boolean] [string]",[e,t],arguments.length),g(this,Re,"f"))this[vs](g(this,Re,"f")),N(this,Re,null,"f");if(e===!1&&t===void 0)return this;return N(this,Re,typeof e==="string"?e:"help","f"),this.boolean(g(this,Re,"f")),this.describe(g(this,Re,"f"),t||g(this,Y,"f").deferY18nLookup("Show help")),this}help(e,t){return this.addHelpOpt(e,t)}addShowHiddenOpt(e,t){if(B("[string|boolean] [string]",[e,t],arguments.length),e===!1&&t===void 0)return this;let n=typeof e==="string"?e:g(this,$n,"f");return this.boolean(n),this.describe(n,t||g(this,Y,"f").deferY18nLookup("Show hidden options")),g(this,U,"f").showHiddenOpt=n,this}showHidden(e,t){return this.addShowHiddenOpt(e,t)}alias(e,t){return B("<object|string|array> [string|array]",[e,t],arguments.length),this[Ws](this.alias.bind(this),"alias",e,t),this}array(e){return B("<array|string>",[e],arguments.length),this[at]("array",e),this[St](e),this}boolean(e){return B("<array|string>",[e],arguments.length),this[at]("boolean",e),this[St](e),this}check(e,t){return B("<function> [boolean]",[e,t],arguments.length),this.middleware((n,i)=>gt(()=>e(n,i.getOptions()),(s)=>{if(!s)g(this,Y,"f").fail(g(this,q,"f").y18n.__("Argument check failed: %s",e.toString()));else if(typeof s==="string"||s instanceof Error)g(this,Y,"f").fail(s.toString(),s);return n},(s)=>(g(this,Y,"f").fail(s.message?s.message:s.toString(),s),n)),!1,t),this}choices(e,t){return B("<object|string|array> [string|array]",[e,t],arguments.length),this[Ws](this.choices.bind(this),"choices",e,t),this}coerce(e,t){if(B("<object|string|array> [function]",[e,t],arguments.length),Array.isArray(e)){if(!t)throw new le("coerce callback must be provided");for(let i of e)this.coerce(i,t);return this}else if(typeof e==="object"){for(let i of Object.keys(e))this.coerce(i,e[i]);return this}if(!t)throw new le("coerce callback must be provided");let n=e;return g(this,U,"f").key[n]=!0,g(this,Pe,"f").addCoerceMiddleware((i,s)=>{var r;let o=(r=s.getAliases()[n])!==null&&r!==void 0?r:[],a=[n,...o].filter((c)=>Object.prototype.hasOwnProperty.call(i,c));if(a.length===0)return i;return gt(()=>t(i[a[0]]),(c)=>(a.forEach((u)=>{i[u]=c}),i),(c)=>{throw new le(c.message)})},n),this}conflicts(e,t){return B("<string|object> [string|array]",[e,t],arguments.length),g(this,ce,"f").conflicts(e,t),this}config(e="config",t,n){if(B("[object|string] [string|function] [function]",[e,t,n],arguments.length),typeof e==="object"&&!Array.isArray(e))return e=en(e,g(this,mt,"f"),this[xt]()["deep-merge-config"]||!1,g(this,q,"f")),g(this,U,"f").configObjects=(g(this,U,"f").configObjects||[]).concat(e),this;if(typeof t==="function")n=t,t=void 0;return this.describe(e,t||g(this,Y,"f").deferY18nLookup("Path to JSON config file")),(Array.isArray(e)?e:[e]).forEach((i)=>{g(this,U,"f").config[i]=n||!0}),this}completion(e,t,n){if(B("[string] [string|boolean|function] [function]",[e,t,n],arguments.length),typeof t==="function")n=t,t=void 0;if(N(this,_e,e||g(this,_e,"f")||"completion","f"),!t&&t!==!1)t="generate completion script";if(this.command(g(this,_e,"f"),t),n)g(this,Ee,"f").registerFunction(n);return this}command(e,t,n,i,s,r){return B("<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]",[e,t,n,i,s,r],arguments.length),g(this,fe,"f").addHandler(e,t,n,i,s,r),this}commands(e,t,n,i,s,r){return this.command(e,t,n,i,s,r)}commandDir(e,t){B("<string> [object]",[e,t],arguments.length);let n=g(this,Pn,"f")||g(this,q,"f").require;return g(this,fe,"f").addDirectory(e,n,g(this,q,"f").getCallerFile(),t),this}count(e){return B("<array|string>",[e],arguments.length),this[at]("count",e),this[St](e),this}default(e,t,n){if(B("<object|string|array> [*] [string]",[e,t,n],arguments.length),n)Rs(e,g(this,q,"f")),g(this,U,"f").defaultDescription[e]=n;if(typeof t==="function"){if(Rs(e,g(this,q,"f")),!g(this,U,"f").defaultDescription[e])g(this,U,"f").defaultDescription[e]=g(this,Y,"f").functionDescription(t);t=t.call()}return this[Ut](this.default.bind(this),"default",e,t),this}defaults(e,t,n){return this.default(e,t,n)}demandCommand(e=1,t,n,i){if(B("[number] [number|string] [string|null|undefined] [string|null|undefined]",[e,t,n,i],arguments.length),typeof t!=="number")n=t,t=1/0;return this.global("_",!1),g(this,U,"f").demandedCommands._={min:e,max:t,minMsg:n,maxMsg:i},this}demand(e,t,n){if(Array.isArray(t))t.forEach((i)=>{Fe(n,!0,g(this,q,"f")),this.demandOption(i,n)}),t=1/0;else if(typeof t!=="number")n=t,t=1/0;if(typeof e==="number")Fe(n,!0,g(this,q,"f")),this.demandCommand(e,t,n,n);else if(Array.isArray(e))e.forEach((i)=>{Fe(n,!0,g(this,q,"f")),this.demandOption(i,n)});else if(typeof n==="string")this.demandOption(e,n);else if(n===!0||typeof n>"u")this.demandOption(e);return this}demandOption(e,t){return B("<object|string|array> [string]",[e,t],arguments.length),this[Ut](this.demandOption.bind(this),"demandedOptions",e,t),this}deprecateOption(e,t){return B("<string> [string|boolean]",[e,t],arguments.length),g(this,U,"f").deprecatedOptions[e]=t,this}describe(e,t){return B("<object|string|array> [string]",[e,t],arguments.length),this[Ks](e,!0),g(this,Y,"f").describe(e,t),this}detectLocale(e){return B("<boolean>",[e],arguments.length),N(this,Dt,e,"f"),this}env(e){if(B("[string|boolean]",[e],arguments.length),e===!1)delete g(this,U,"f").envPrefix;else g(this,U,"f").envPrefix=e||"";return this}epilogue(e){return B("<string>",[e],arguments.length),g(this,Y,"f").epilog(e),this}epilog(e){return this.epilogue(e)}example(e,t){if(B("<string|array> [string]",[e,t],arguments.length),Array.isArray(e))e.forEach((n)=>this.example(...n));else g(this,Y,"f").example(e,t);return this}exit(e,t){if(N(this,Se,!0,"f"),N(this,rt,t,"f"),g(this,Te,"f"))g(this,q,"f").process.exit(e)}exitProcess(e=!0){return B("[boolean]",[e],arguments.length),N(this,Te,e,"f"),this}fail(e){if(B("<function|boolean>",[e],arguments.length),typeof e==="boolean"&&e!==!1)throw new le("Invalid first argument. Expected function or boolean 'false'");return g(this,Y,"f").failFn(e),this}getAliases(){return this.parsed?this.parsed.aliases:{}}async getCompletion(e,t){if(B("<array> [function]",[e,t],arguments.length),!t)return new Promise((n,i)=>{g(this,Ee,"f").getCompletion(e,(s,r)=>{if(s)i(s);else n(r)})});else return g(this,Ee,"f").getCompletion(e,t)}getDemandedOptions(){return B([],0),g(this,U,"f").demandedOptions}getDemandedCommands(){return B([],0),g(this,U,"f").demandedCommands}getDeprecatedOptions(){return B([],0),g(this,U,"f").deprecatedOptions}getDetectLocale(){return g(this,Dt,"f")}getExitProcess(){return g(this,Te,"f")}getGroups(){return Object.assign({},g(this,Ye,"f"),g(this,bt,"f"))}getHelp(){if(N(this,Se,!0,"f"),!g(this,Y,"f").hasCachedHelpMessage()){if(!this.parsed){let t=this[nn](g(this,ot,"f"),void 0,void 0,0,!0);if(ne(t))return t.then(()=>g(this,Y,"f").help())}let e=g(this,fe,"f").runDefaultBuilderOn(this);if(ne(e))return e.then(()=>g(this,Y,"f").help())}return Promise.resolve(g(this,Y,"f").help())}getOptions(){return g(this,U,"f")}getStrict(){return g(this,Ft,"f")}getStrictCommands(){return g(this,Ct,"f")}getStrictOptions(){return g(this,Et,"f")}global(e,t){if(B("<string|array> [boolean]",[e,t],arguments.length),e=[].concat(e),t!==!1)g(this,U,"f").local=g(this,U,"f").local.filter((n)=>e.indexOf(n)===-1);else e.forEach((n)=>{if(!g(this,U,"f").local.includes(n))g(this,U,"f").local.push(n)});return this}group(e,t){B("<string|array> <string>",[e,t],arguments.length);let n=g(this,bt,"f")[t]||g(this,Ye,"f")[t];if(g(this,bt,"f")[t])delete g(this,bt,"f")[t];let i={};return g(this,Ye,"f")[t]=(n||[]).concat(e).filter((s)=>{if(i[s])return!1;return i[s]=!0}),this}hide(e){return B("<string>",[e],arguments.length),g(this,U,"f").hiddenOptions.push(e),this}implies(e,t){return B("<string|object> [number|string|array]",[e,t],arguments.length),g(this,ce,"f").implies(e,t),this}locale(e){if(B("[string]",[e],arguments.length),e===void 0)return this[js](),g(this,q,"f").y18n.getLocale();return N(this,Dt,!1,"f"),g(this,q,"f").y18n.setLocale(e),this}middleware(e,t,n){return g(this,Pe,"f").addMiddleware(e,!!t,n)}nargs(e,t){return B("<string|object|array> [number]",[e,t],arguments.length),this[Ut](this.nargs.bind(this),"narg",e,t),this}normalize(e){return B("<array|string>",[e],arguments.length),this[at]("normalize",e),this}number(e){return B("<array|string>",[e],arguments.length),this[at]("number",e),this[St](e),this}option(e,t){if(B("<string|object> [object]",[e,t],arguments.length),typeof e==="object")Object.keys(e).forEach((n)=>{this.options(n,e[n])});else{if(typeof t!=="object")t={};if(this[St](e),g(this,Xe,"f")&&(e==="version"||(t===null||t===void 0?void 0:t.alias)==="version"))this[lo](['"version" is a reserved word.',"Please do one of the following:",'- Disable version with `yargs.version(false)` if using "version" as an option',"- Use the built-in `yargs.version` method instead (if applicable)","- Use a different option key","https://yargs.js.org/docs/#api-reference-version"].join(`
79
- `),void 0,"versionWarning");if(g(this,U,"f").key[e]=!0,t.alias)this.alias(e,t.alias);let n=t.deprecate||t.deprecated;if(n)this.deprecateOption(e,n);let i=t.demand||t.required||t.require;if(i)this.demand(e,i);if(t.demandOption)this.demandOption(e,typeof t.demandOption==="string"?t.demandOption:void 0);if(t.conflicts)this.conflicts(e,t.conflicts);if("default"in t)this.default(e,t.default);if(t.implies!==void 0)this.implies(e,t.implies);if(t.nargs!==void 0)this.nargs(e,t.nargs);if(t.config)this.config(e,t.configParser);if(t.normalize)this.normalize(e);if(t.choices)this.choices(e,t.choices);if(t.coerce)this.coerce(e,t.coerce);if(t.group)this.group(e,t.group);if(t.boolean||t.type==="boolean"){if(this.boolean(e),t.alias)this.boolean(t.alias)}if(t.array||t.type==="array"){if(this.array(e),t.alias)this.array(t.alias)}if(t.number||t.type==="number"){if(this.number(e),t.alias)this.number(t.alias)}if(t.string||t.type==="string"){if(this.string(e),t.alias)this.string(t.alias)}if(t.count||t.type==="count")this.count(e);if(typeof t.global==="boolean")this.global(e,t.global);if(t.defaultDescription)g(this,U,"f").defaultDescription[e]=t.defaultDescription;if(t.skipValidation)this.skipValidation(e);let s=t.describe||t.description||t.desc,r=g(this,Y,"f").getDescriptions();if(!Object.prototype.hasOwnProperty.call(r,e)||typeof s==="string")this.describe(e,s);if(t.hidden)this.hide(e);if(t.requiresArg)this.requiresArg(e)}return this}options(e,t){return this.option(e,t)}parse(e,t,n){if(B("[string|array] [function|boolean|object] [function]",[e,t,n],arguments.length),this[fo](),typeof e>"u")e=g(this,ot,"f");if(typeof t==="object")N(this,wt,t,"f"),t=n;if(typeof t==="function")N(this,ke,t,"f"),t=!1;if(!t)N(this,ot,e,"f");if(g(this,ke,"f"))N(this,Te,!1,"f");let i=this[nn](e,!!t),s=this.parsed;if(g(this,Ee,"f").setParsed(this.parsed),ne(i))return i.then((r)=>{if(g(this,ke,"f"))g(this,ke,"f").call(this,g(this,rt,"f"),r,g(this,me,"f"));return r}).catch((r)=>{if(g(this,ke,"f"))g(this,ke,"f")(r,this.parsed.argv,g(this,me,"f"));throw r}).finally(()=>{this[zs](),this.parsed=s});else{if(g(this,ke,"f"))g(this,ke,"f").call(this,g(this,rt,"f"),i,g(this,me,"f"));this[zs](),this.parsed=s}return i}parseAsync(e,t,n){let i=this.parse(e,t,n);return!ne(i)?Promise.resolve(i):i}parseSync(e,t,n){let i=this.parse(e,t,n);if(ne(i))throw new le(".parseSync() must not be used with asynchronous builders, handlers, or middleware");return i}parserConfiguration(e){return B("<object>",[e],arguments.length),N(this,Rn,e,"f"),this}pkgConf(e,t){B("<string> [string]",[e,t],arguments.length);let n=null,i=this[Ls](t||g(this,mt,"f"));if(i[e]&&typeof i[e]==="object")n=en(i[e],t||g(this,mt,"f"),this[xt]()["deep-merge-config"]||!1,g(this,q,"f")),g(this,U,"f").configObjects=(g(this,U,"f").configObjects||[]).concat(n);return this}positional(e,t){B("<string> <object>",[e,t],arguments.length);let n=["default","defaultDescription","implies","normalize","choices","conflicts","coerce","type","describe","desc","description","alias"];t=st(t,(r,o)=>{if(r==="type"&&!["string","number","boolean"].includes(o))return!1;return n.includes(r)});let i=g(this,tn,"f").fullCommands[g(this,tn,"f").fullCommands.length-1],s=i?g(this,fe,"f").cmdToParseOptions(i):{array:[],alias:{},default:{},demand:{}};return jt(s).forEach((r)=>{let o=s[r];if(Array.isArray(o)){if(o.indexOf(e)!==-1)t[r]=!0}else if(o[e]&&!(r in t))t[r]=o[e]}),this.group(e,g(this,Y,"f").getPositionalGroupName()),this.option(e,t)}recommendCommands(e=!0){return B("[boolean]",[e],arguments.length),N(this,Mn,e,"f"),this}required(e,t,n){return this.demand(e,t,n)}require(e,t,n){return this.demand(e,t,n)}requiresArg(e){if(B("<array|string|object> [number]",[e],arguments.length),typeof e==="string"&&g(this,U,"f").narg[e])return this;else this[Ut](this.requiresArg.bind(this),"narg",e,NaN);return this}showCompletionScript(e,t){return B("[string] [string]",[e,t],arguments.length),e=e||this.$0,g(this,yt,"f").log(g(this,Ee,"f").generateCompletionScript(e,t||g(this,_e,"f")||"completion")),this}showHelp(e){if(B("[string|function]",[e],arguments.length),N(this,Se,!0,"f"),!g(this,Y,"f").hasCachedHelpMessage()){if(!this.parsed){let n=this[nn](g(this,ot,"f"),void 0,void 0,0,!0);if(ne(n))return n.then(()=>{g(this,Y,"f").showHelp(e)}),this}let t=g(this,fe,"f").runDefaultBuilderOn(this);if(ne(t))return t.then(()=>{g(this,Y,"f").showHelp(e)}),this}return g(this,Y,"f").showHelp(e),this}scriptName(e){return this.customScriptName=!0,this.$0=e,this}showHelpOnFail(e,t){return B("[boolean|string] [string]",[e,t],arguments.length),g(this,Y,"f").showHelpOnFail(e,t),this}showVersion(e){return B("[string|function]",[e],arguments.length),g(this,Y,"f").showVersion(e),this}skipValidation(e){return B("<array|string>",[e],arguments.length),this[at]("skipValidation",e),this}strict(e){return B("[boolean]",[e],arguments.length),N(this,Ft,e!==!1,"f"),this}strictCommands(e){return B("[boolean]",[e],arguments.length),N(this,Ct,e!==!1,"f"),this}strictOptions(e){return B("[boolean]",[e],arguments.length),N(this,Et,e!==!1,"f"),this}string(e){return B("<array|string>",[e],arguments.length),this[at]("string",e),this[St](e),this}terminalWidth(){return B([],0),g(this,q,"f").process.stdColumns}updateLocale(e){return this.updateStrings(e)}updateStrings(e){return B("<object>",[e],arguments.length),N(this,Dt,!1,"f"),g(this,q,"f").y18n.updateLocale(e),this}usage(e,t,n,i){if(B("<string|null|undefined> [string|boolean] [function|object] [function]",[e,t,n,i],arguments.length),t!==void 0)if(Fe(e,null,g(this,q,"f")),(e||"").match(/^\$0( |$)/))return this.command(e,t,n,i);else throw new le(".usage() description must start with $0 if being used as alias for .command()");else return g(this,Y,"f").usage(e),this}usageConfiguration(e){return B("<object>",[e],arguments.length),N(this,Bn,e,"f"),this}version(e,t,n){if(B("[boolean|string] [string] [string]",[e,t,n],arguments.length),g(this,Xe,"f"))this[vs](g(this,Xe,"f")),g(this,Y,"f").version(void 0),N(this,Xe,null,"f");if(arguments.length===0)n=this[go](),e="version";else if(arguments.length===1){if(e===!1)return this;n=e,e="version"}else if(arguments.length===2)n=t,t=void 0;return N(this,Xe,typeof e==="string"?e:"version","f"),t=t||g(this,Y,"f").deferY18nLookup("Show version number"),g(this,Y,"f").version(n||void 0),this.boolean(g(this,Xe,"f")),this.describe(g(this,Xe,"f"),t),this}wrap(e){return B("<number|null|undefined>",[e],arguments.length),g(this,Y,"f").wrap(e),this}[(fe=new WeakMap,mt=new WeakMap,tn=new WeakMap,Ee=new WeakMap,_e=new WeakMap,$n=new WeakMap,rt=new WeakMap,Dt=new WeakMap,On=new WeakMap,Te=new WeakMap,In=new WeakMap,Pe=new WeakMap,Ye=new WeakMap,Se=new WeakMap,Re=new WeakMap,Tn=new WeakMap,yt=new WeakMap,me=new WeakMap,U=new WeakMap,Pn=new WeakMap,Rn=new WeakMap,ke=new WeakMap,wt=new WeakMap,Wt=new WeakMap,bt=new WeakMap,ot=new WeakMap,Mn=new WeakMap,q=new WeakMap,Ft=new WeakMap,Ct=new WeakMap,Et=new WeakMap,Y=new WeakMap,Bn=new WeakMap,Xe=new WeakMap,ce=new WeakMap,co)](e){if(!e._||!e["--"])return e;e._.push.apply(e._,e["--"]);try{delete e["--"]}catch(t){}return e}[uo](){return{log:(...e)=>{if(!this[Nn]())console.log(...e);if(N(this,Se,!0,"f"),g(this,me,"f").length)N(this,me,g(this,me,"f")+`
80
- `,"f");N(this,me,g(this,me,"f")+e.join(" "),"f")},error:(...e)=>{if(!this[Nn]())console.error(...e);if(N(this,Se,!0,"f"),g(this,me,"f").length)N(this,me,g(this,me,"f")+`
81
- `,"f");N(this,me,g(this,me,"f")+e.join(" "),"f")}}}[vs](e){jt(g(this,U,"f")).forEach((t)=>{if(((i)=>i==="configObjects")(t))return;let n=g(this,U,"f")[t];if(Array.isArray(n)){if(n.includes(e))n.splice(n.indexOf(e),1)}else if(typeof n==="object")delete n[e]}),delete g(this,Y,"f").getDescriptions()[e]}[lo](e,t,n){if(!g(this,On,"f")[n])g(this,q,"f").process.emitWarning(e,t),g(this,On,"f")[n]=!0}[fo](){g(this,In,"f").push({options:g(this,U,"f"),configObjects:g(this,U,"f").configObjects.slice(0),exitProcess:g(this,Te,"f"),groups:g(this,Ye,"f"),strict:g(this,Ft,"f"),strictCommands:g(this,Ct,"f"),strictOptions:g(this,Et,"f"),completionCommand:g(this,_e,"f"),output:g(this,me,"f"),exitError:g(this,rt,"f"),hasOutput:g(this,Se,"f"),parsed:this.parsed,parseFn:g(this,ke,"f"),parseContext:g(this,wt,"f")}),g(this,Y,"f").freeze(),g(this,ce,"f").freeze(),g(this,fe,"f").freeze(),g(this,Pe,"f").freeze()}[po](){let e="",t;if(/\b(node|iojs|electron)(\.exe)?$/.test(g(this,q,"f").process.argv()[0]))t=g(this,q,"f").process.argv().slice(1,2);else t=g(this,q,"f").process.argv().slice(0,1);if(e=t.map((n)=>{let i=this[So](g(this,mt,"f"),n);return n.match(/^(\/|([a-zA-Z]:)?\\)/)&&i.length<n.length?i:n}).join(" ").trim(),g(this,q,"f").getEnv("_")&&g(this,q,"f").getProcessArgvBin()===g(this,q,"f").getEnv("_"))e=g(this,q,"f").getEnv("_").replace(`${g(this,q,"f").path.dirname(g(this,q,"f").process.execPath())}/`,"");return e}[xt](){return g(this,Rn,"f")}[ho](){return g(this,Bn,"f")}[js](){if(!g(this,Dt,"f"))return;let e=g(this,q,"f").getEnv("LC_ALL")||g(this,q,"f").getEnv("LC_MESSAGES")||g(this,q,"f").getEnv("LANG")||g(this,q,"f").getEnv("LANGUAGE")||"en_US";this.locale(e.replace(/[.:].*/,""))}[go](){return this[Ls]().version||"unknown"}[mo](e){let t=e["--"]?e["--"]:e._;for(let n=0,i;(i=t[n])!==void 0;n++)if(g(this,q,"f").Parser.looksLikeNumber(i)&&Number.isSafeInteger(Math.floor(parseFloat(`${i}`))))t[n]=Number(i);return e}[Ls](e){let t=e||"*";if(g(this,Wt,"f")[t])return g(this,Wt,"f")[t];let n={};try{let i=e||g(this,q,"f").mainFilename;if(g(this,q,"f").path.extname(i))i=g(this,q,"f").path.dirname(i);let s=g(this,q,"f").findUp(i,(r,o)=>{if(o.includes("package.json"))return"package.json";else return});Fe(s,void 0,g(this,q,"f")),n=JSON.parse(g(this,q,"f").readFileSync(s,"utf8"))}catch(i){}return g(this,Wt,"f")[t]=n||{},g(this,Wt,"f")[t]}[at](e,t){t=[].concat(t),t.forEach((n)=>{n=this[Js](n),g(this,U,"f")[e].push(n)})}[Ut](e,t,n,i){this[Us](e,t,n,i,(s,r,o)=>{g(this,U,"f")[s][r]=o})}[Ws](e,t,n,i){this[Us](e,t,n,i,(s,r,o)=>{g(this,U,"f")[s][r]=(g(this,U,"f")[s][r]||[]).concat(o)})}[Us](e,t,n,i,s){if(Array.isArray(n))n.forEach((r)=>{e(r,i)});else if(((r)=>typeof r==="object")(n))for(let r of jt(n))e(r,n[r]);else s(t,this[Js](n),i)}[Js](e){if(e==="__proto__")return"___proto___";return e}[Ks](e,t){return this[Ut](this[Ks].bind(this),"key",e,t),this}[zs](){var e,t,n,i,s,r,o,a,c,u,f,l;let d=g(this,In,"f").pop();Fe(d,void 0,g(this,q,"f"));let h;e=this,t=this,n=this,i=this,s=this,r=this,o=this,a=this,c=this,u=this,f=this,l=this,{options:{set value(m){N(e,U,m,"f")}}.value,configObjects:h,exitProcess:{set value(m){N(t,Te,m,"f")}}.value,groups:{set value(m){N(n,Ye,m,"f")}}.value,output:{set value(m){N(i,me,m,"f")}}.value,exitError:{set value(m){N(s,rt,m,"f")}}.value,hasOutput:{set value(m){N(r,Se,m,"f")}}.value,parsed:this.parsed,strict:{set value(m){N(o,Ft,m,"f")}}.value,strictCommands:{set value(m){N(a,Ct,m,"f")}}.value,strictOptions:{set value(m){N(c,Et,m,"f")}}.value,completionCommand:{set value(m){N(u,_e,m,"f")}}.value,parseFn:{set value(m){N(f,ke,m,"f")}}.value,parseContext:{set value(m){N(l,wt,m,"f")}}.value}=d,g(this,U,"f").configObjects=h,g(this,Y,"f").unfreeze(),g(this,ce,"f").unfreeze(),g(this,fe,"f").unfreeze(),g(this,Pe,"f").unfreeze()}[Do](e,t){return gt(t,(n)=>(e(n),n))}getInternalMethods(){return{getCommandInstance:this[yo].bind(this),getContext:this[wo].bind(this),getHasOutput:this[bo].bind(this),getLoggerInstance:this[Fo].bind(this),getParseContext:this[Co].bind(this),getParserConfiguration:this[xt].bind(this),getUsageConfiguration:this[ho].bind(this),getUsageInstance:this[Eo].bind(this),getValidationInstance:this[xo].bind(this),hasParseCallback:this[Nn].bind(this),isGlobalContext:this[_o].bind(this),postProcess:this[_t].bind(this),reset:this[Hs].bind(this),runValidation:this[qs].bind(this),runYargsParserAndExecuteCommands:this[nn].bind(this),setHasOutput:this[ko].bind(this)}}[yo](){return g(this,fe,"f")}[wo](){return g(this,tn,"f")}[bo](){return g(this,Se,"f")}[Fo](){return g(this,yt,"f")}[Co](){return g(this,wt,"f")||{}}[Eo](){return g(this,Y,"f")}[xo](){return g(this,ce,"f")}[Nn](){return!!g(this,ke,"f")}[_o](){return g(this,Tn,"f")}[_t](e,t,n,i){if(n)return e;if(ne(e))return e;if(!t)e=this[co](e);if(this[xt]()["parse-positional-numbers"]||this[xt]()["parse-positional-numbers"]===void 0)e=this[mo](e);if(i)e=ht(e,this,g(this,Pe,"f").getMiddleware(),!1);return e}[Hs](e={}){N(this,U,g(this,U,"f")||{},"f");let t={};t.local=g(this,U,"f").local||[],t.configObjects=g(this,U,"f").configObjects||[];let n={};t.local.forEach((r)=>{n[r]=!0,(e[r]||[]).forEach((o)=>{n[o]=!0})}),Object.assign(g(this,bt,"f"),Object.keys(g(this,Ye,"f")).reduce((r,o)=>{let a=g(this,Ye,"f")[o].filter((c)=>!(c in n));if(a.length>0)r[o]=a;return r},{})),N(this,Ye,{},"f");let i=["array","boolean","string","skipValidation","count","normalize","number","hiddenOptions"],s=["narg","key","alias","default","defaultDescription","config","choices","demandedOptions","demandedCommands","deprecatedOptions"];if(i.forEach((r)=>{t[r]=(g(this,U,"f")[r]||[]).filter((o)=>!n[o])}),s.forEach((r)=>{t[r]=st(g(this,U,"f")[r],(o)=>!n[o])}),t.envPrefix=g(this,U,"f").envPrefix,N(this,U,t,"f"),N(this,Y,g(this,Y,"f")?g(this,Y,"f").reset(n):Qr(this,g(this,q,"f")),"f"),N(this,ce,g(this,ce,"f")?g(this,ce,"f").reset(n):oo(this,g(this,Y,"f"),g(this,q,"f")),"f"),N(this,fe,g(this,fe,"f")?g(this,fe,"f").reset():Gr(g(this,Y,"f"),g(this,ce,"f"),g(this,Pe,"f"),g(this,q,"f")),"f"),!g(this,Ee,"f"))N(this,Ee,so(this,g(this,Y,"f"),g(this,fe,"f"),g(this,q,"f")),"f");return g(this,Pe,"f").reset(),N(this,_e,null,"f"),N(this,me,"","f"),N(this,rt,null,"f"),N(this,Se,!1,"f"),this.parsed=!1,this}[So](e,t){return g(this,q,"f").path.relative(e,t)}[nn](e,t,n,i=0,s=!1){var r,o,a,c;let u=!!n||s;e=e||g(this,ot,"f"),g(this,U,"f").__=g(this,q,"f").y18n.__,g(this,U,"f").configuration=this[xt]();let f=!!g(this,U,"f").configuration["populate--"],l=Object.assign({},g(this,U,"f").configuration,{"populate--":!0}),d=g(this,q,"f").Parser.detailed(e,Object.assign({},g(this,U,"f"),{configuration:{"parse-positional-numbers":!1,...l}})),h=Object.assign(d.argv,g(this,wt,"f")),m=void 0,p=d.aliases,y=!1,E=!1;if(Object.keys(h).forEach((F)=>{if(F===g(this,Re,"f")&&h[F])y=!0;else if(F===g(this,Xe,"f")&&h[F])E=!0}),h.$0=this.$0,this.parsed=d,i===0)g(this,Y,"f").clearCachedHelpMessage();try{if(this[js](),t)return this[_t](h,f,!!n,!1);if(g(this,Re,"f")){if([g(this,Re,"f")].concat(p[g(this,Re,"f")]||[]).filter((P)=>P.length>1).includes(""+h._[h._.length-1]))h._.pop(),y=!0}N(this,Tn,!1,"f");let F=g(this,fe,"f").getCommands(),k=((r=g(this,Ee,"f"))===null||r===void 0?void 0:r.completionKey)?[(o=g(this,Ee,"f"))===null||o===void 0?void 0:o.completionKey,...(c=this.getAliases()[(a=g(this,Ee,"f"))===null||a===void 0?void 0:a.completionKey])!==null&&c!==void 0?c:[]].some((A)=>Object.prototype.hasOwnProperty.call(h,A)):!1,C=y||k||s;if(h._.length){if(F.length){let A;for(let P=i||0,v;h._[P]!==void 0;P++)if(v=String(h._[P]),F.includes(v)&&v!==g(this,_e,"f")){let L=g(this,fe,"f").runCommand(v,this,d,P+1,s,y||E||s);return this[_t](L,f,!!n,!1)}else if(!A&&v!==g(this,_e,"f")){A=v;break}if(!g(this,fe,"f").hasDefaultCommand()&&g(this,Mn,"f")&&A&&!C)g(this,ce,"f").recommendCommands(A,F)}if(g(this,_e,"f")&&h._.includes(g(this,_e,"f"))&&!k){if(g(this,Te,"f"))it(!0);this.showCompletionScript(),this.exit(0)}}if(g(this,fe,"f").hasDefaultCommand()&&!C){let A=g(this,fe,"f").runCommand(null,this,d,0,s,y||E||s);return this[_t](A,f,!!n,!1)}if(k){if(g(this,Te,"f"))it(!0);e=[].concat(e);let A=e.slice(e.indexOf(`--${g(this,Ee,"f").completionKey}`)+1);return g(this,Ee,"f").getCompletion(A,(P,v)=>{if(P)throw new le(P.message);(v||[]).forEach((L)=>{g(this,yt,"f").log(L)}),this.exit(0)}),this[_t](h,!f,!!n,!1)}if(!g(this,Se,"f")){if(y){if(g(this,Te,"f"))it(!0);u=!0,this.showHelp((A)=>{g(this,yt,"f").log(A),this.exit(0)})}else if(E){if(g(this,Te,"f"))it(!0);u=!0,g(this,Y,"f").showVersion("log"),this.exit(0)}}if(!u&&g(this,U,"f").skipValidation.length>0)u=Object.keys(h).some((A)=>g(this,U,"f").skipValidation.indexOf(A)>=0&&h[A]===!0);if(!u){if(d.error)throw new le(d.error.message);if(!k){let A=this[qs](p,{},d.error);if(!n)m=ht(h,this,g(this,Pe,"f").getMiddleware(),!0);if(m=this[Do](A,m!==null&&m!==void 0?m:h),ne(m)&&!n)m=m.then(()=>ht(h,this,g(this,Pe,"f").getMiddleware(),!1))}}}catch(F){if(F instanceof le)g(this,Y,"f").fail(F.message,F);else throw F}return this[_t](m!==null&&m!==void 0?m:h,f,!!n,!0)}[qs](e,t,n,i){let s={...this.getDemandedOptions()};return(r)=>{if(n)throw new le(n.message);g(this,ce,"f").nonOptionCount(r),g(this,ce,"f").requiredArguments(r,s);let o=!1;if(g(this,Ct,"f"))o=g(this,ce,"f").unknownCommands(r);if(g(this,Ft,"f")&&!o)g(this,ce,"f").unknownArguments(r,e,t,!!i);else if(g(this,Et,"f"))g(this,ce,"f").unknownArguments(r,e,{},!1,!1);g(this,ce,"f").limitedChoices(r),g(this,ce,"f").implications(r),g(this,ce,"f").conflicting(r)}}[ko](){N(this,Se,!0,"f")}[St](e){if(typeof e==="string")g(this,U,"f").key[e]=!0;else for(let t of e)g(this,U,"f").key[t]=!0}}function Vr(e){return!!e&&typeof e.getInternalMethods==="function"}var sl=Ao(Ps),Oo=sl;import{existsSync as vn,readFileSync as Gs,writeFileSync as Ys,mkdirSync as Po}from"node:fs";import{homedir as il}from"node:os";import{join as kt,dirname as Vs}from"node:path";function Zs(){return process.env.HOME||il()}function Ro(){return kt(Zs(),".config","slack-cli","profiles.json")}function jn(){return kt(process.cwd(),".slack-cli","workspace")}function Ln(){return kt(Zs(),".slack-cli","workspace")}function sn(){let e=Ro();if(!vn(e))return{profiles:{}};return JSON.parse(Gs(e,"utf8"))}function rl(e){let t=Ro();Po(Vs(t),{recursive:!0}),Ys(t,JSON.stringify(e,null,2)+`
82
- `)}function Jt(e){if(!vn(e))return;return Gs(e,"utf8").trim()||void 0}function Io(e,t){let n=Vs(e);Po(n,{recursive:!0});let i=kt(n,".gitignore");if(!vn(i))Ys(i,`*
83
- `);Ys(e,t+`
84
- `)}function ol(e){let t={};for(let n of e.split(`
85
- `)){let i=n.trim();if(!i||i.startsWith("#"))continue;let s=i.indexOf("=");if(s===-1)continue;let r=i.slice(0,s).trim(),o=i.slice(s+1).trim();if(o.startsWith('"')&&o.endsWith('"')||o.startsWith("'")&&o.endsWith("'"))o=o.slice(1,-1);t[r]=o}return t}function To(e){if(!vn(e))return{};try{return ol(Gs(e,"utf8"))}catch{return{}}}function Xs(e,t){let n=Zs(),i=e;while(!0){for(let o of[kt(i,".slack-term",".env.local"),kt(i,".env.local")]){let a=To(o);for(let c of t)if(a[c])return a[c]}if(i===n)break;let r=Vs(i);if(r===i)break;i=r}let s=To(kt(n,".slack-term",".env.local"));for(let r of t)if(s[r])return s[r];return}function Qs(){let e=sn(),t=Jt(jn()),n=Jt(Ln()),i=t??n;return Object.entries(e.profiles).map(([s,r])=>({name:s,profile:r,current:s===i}))}function Mo(e){let t=sn();if(!(e in t.profiles))throw Error(`Profile not found: ${e}`);delete t.profiles[e],rl(t)}function Bo(e,t=!1){let n=sn();if(!(e in n.profiles))throw Error(`Profile not found: ${e}`);if(t)Io(Ln(),e);else Io(jn(),e)}function ei(e){let n=sn().profiles,i=Object.keys(n);if(e){let u=n[e];if(!u)throw Error(`Workspace "${e}" not found. Available: ${i.join(", ")||"(none)"}`);return u.token}if(process.env.SLACK_TOKEN)return process.env.SLACK_TOKEN;let s=process.env.SLACK_BOT_TOKEN??process.env.SLACK_MCP_XOXP_TOKEN;if(s&&i.length===0)return s;if(s&&i.length>0){let u=Xs(process.cwd(),["SLACK_BOT_TOKEN","SLACK_MCP_XOXP_TOKEN"]);if(s!==u){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 r=Xs(process.cwd(),["SLACK_TOKEN"]);if(r)return r;let o=process.env.SLACK_WORKSPACE;if(o){let u=n[o];if(!u)throw Error(`Workspace "${o}" not found. Available: ${i.join(", ")||"(none)"}`);return u.token}let a=Jt(jn());if(a){let u=n[a];if(!u)throw Error(`Workspace "${a}" (from .slack-cli/workspace) not found in profiles.`);return u.token}let c=Jt(Ln());if(c){let u=n[c];if(!u)throw Error(`Workspace "${c}" (from ~/.slack-cli/workspace) not found in profiles.`);return u.token}if(i.length>0)throw Error(`Workspace not selected (${i.join(", ")} available).
76
+ `)}`:"";t.fail(s("Missing required argument: %s","Missing required arguments: %s",Object.keys(h).length,Object.keys(h).join(", ")+p))}},r.unknownArguments=function(l,d,h,m,p=!0){var y;let C=e.getInternalMethods().getCommandInstance().getCommands(),F=[],k=e.getInternalMethods().getContext();if(Object.keys(l).forEach((S)=>{if(!ao.includes(S)&&!Object.prototype.hasOwnProperty.call(h,S)&&!Object.prototype.hasOwnProperty.call(e.getInternalMethods().getParseContext(),S)&&!r.isValidAndSomeAliasIsNotNew(S,d))F.push(S)}),p&&(k.commands.length>0||C.length>0||m))l._.slice(k.commands.length).forEach((S)=>{if(!C.includes(""+S))F.push(""+S)});if(p){let A=((y=e.getDemandedCommands()._)===null||y===void 0?void 0:y.max)||0,I=k.commands.length+A;if(I<l._.length)l._.slice(I).forEach((W)=>{if(W=String(W),!k.commands.includes(W)&&!F.includes(W))F.push(W)})}if(F.length)t.fail(s("Unknown argument: %s","Unknown arguments: %s",F.length,F.map((S)=>S.trim()?S:`"${S}"`).join(", ")))},r.unknownCommands=function(l){let d=e.getInternalMethods().getCommandInstance().getCommands(),h=[],m=e.getInternalMethods().getContext();if(m.commands.length>0||d.length>0)l._.slice(m.commands.length).forEach((p)=>{if(!d.includes(""+p))h.push(""+p)});if(h.length>0)return t.fail(s("Unknown command: %s","Unknown commands: %s",h.length,h.join(", "))),!0;else return!1},r.isValidAndSomeAliasIsNotNew=function(l,d){if(!Object.prototype.hasOwnProperty.call(d,l))return!1;let h=e.parsed.newAliases;return[l,...d[l]].some((m)=>!Object.prototype.hasOwnProperty.call(h,m)||!h[l])},r.limitedChoices=function(l){let d=e.getOptions(),h={};if(!Object.keys(d.choices).length)return;Object.keys(l).forEach((y)=>{if(ao.indexOf(y)===-1&&Object.prototype.hasOwnProperty.call(d.choices,y))[].concat(l[y]).forEach((C)=>{if(d.choices[y].indexOf(C)===-1&&C!==void 0)h[y]=(h[y]||[]).concat(C)})});let m=Object.keys(h);if(!m.length)return;let p=i("Invalid values:");m.forEach((y)=>{p+=`
77
+ ${i("Argument: %s, Given: %s, Choices: %s",y,t.stringifiedValues(h[y]),t.stringifiedValues(d.choices[y]))}`}),t.fail(p)};let o={};r.implies=function(l,d){if(N("<string|object> [array|number|string]",[l,d],arguments.length),typeof l==="object")Object.keys(l).forEach((h)=>{r.implies(h,l[h])});else{if(e.global(l),!o[l])o[l]=[];if(Array.isArray(d))d.forEach((h)=>r.implies(l,h));else Ce(d,void 0,n),o[l].push(d)}},r.getImplied=function(){return o};function a(f,l){let d=Number(l);if(l=isNaN(d)?l:d,typeof l==="number")l=f._.length>=l;else if(l.match(/^--no-.+/))l=l.match(/^--no-(.+)/)[1],l=!Object.prototype.hasOwnProperty.call(f,l);else l=Object.prototype.hasOwnProperty.call(f,l);return l}r.implications=function(l){let d=[];if(Object.keys(o).forEach((h)=>{let m=h;(o[h]||[]).forEach((p)=>{let y=m,C=p;if(y=a(l,y),p=a(l,p),y&&!p)d.push(` ${m} -> ${C}`)})}),d.length){let h=`${i("Implications failed:")}
78
+ `;d.forEach((m)=>{h+=m}),t.fail(h)}};let c={};r.conflicts=function(l,d){if(N("<string|object> [array|string]",[l,d],arguments.length),typeof l==="object")Object.keys(l).forEach((h)=>{r.conflicts(h,l[h])});else{if(e.global(l),!c[l])c[l]=[];if(Array.isArray(d))d.forEach((h)=>r.conflicts(l,h));else c[l].push(d)}},r.getConflicting=()=>c,r.conflicting=function(l){if(Object.keys(l).forEach((d)=>{if(c[d])c[d].forEach((h)=>{if(h&&l[d]!==void 0&&l[h]!==void 0)t.fail(i("Arguments %s and %s are mutually exclusive",d,h))})}),e.getInternalMethods().getParserConfiguration()["strip-dashed"])Object.keys(c).forEach((d)=>{c[d].forEach((h)=>{if(h&&l[n.Parser.camelCase(d)]!==void 0&&l[n.Parser.camelCase(h)]!==void 0)t.fail(i("Arguments %s and %s are mutually exclusive",d,h))})})},r.recommendCommands=function(l,d){d=d.sort((y,C)=>C.length-y.length);let m=null,p=1/0;for(let y=0,C;(C=d[y])!==void 0;y++){let F=oo(l,C);if(F<=3&&F<p)p=F,m=C}if(m)t.fail(i("Did you mean %s?",m))},r.reset=function(l){return o=it(o,(d)=>!l[d]),c=it(c,(d)=>!l[d]),r};let u=[];return r.freeze=function(){u.push({implied:o,conflicting:c})},r.unfreeze=function(){let l=u.pop();Ce(l,void 0,n),{implied:o,conflicting:c}=l},r}var Ls=[],Qt;function en(e,t,n,i){Qt=i;let s={};if(Object.prototype.hasOwnProperty.call(e,"extends")){if(typeof e.extends!=="string")return s;let r=/\.json|\..*rc$/.test(e.extends),o=null;if(!r)try{o=import.meta.resolve(e.extends)}catch(a){return e}else o=il(t,e.extends);sl(o),Ls.push(o),s=r?JSON.parse(Qt.readFileSync(o,"utf8")):i.require(e.extends),delete e.extends,s=en(s,Qt.path.dirname(o),n,Qt)}return Ls=[],n?uo(s,e):Object.assign({},s,e)}function sl(e){if(Ls.indexOf(e)>-1)throw new le(`Circular extended configurations: '${e}'.`)}function il(e,t){return Qt.path.resolve(e,t)}function uo(e,t){let n={};function i(s){return s&&typeof s==="object"&&!Array.isArray(s)}Object.assign(n,e);for(let s of Object.keys(t))if(i(t[s])&&i(n[s]))n[s]=uo(e[s],t[s]);else n[s]=t[s];return n}var v=function(e,t,n,i,s){if(i==="m")throw TypeError("Private method is not writable");if(i==="a"&&!s)throw TypeError("Private accessor was defined without a setter");if(typeof t==="function"?e!==t||!s:!t.has(e))throw TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(e,n):s?s.value=n:t.set(e,n),n},g=function(e,t,n,i){if(n==="a"&&!i)throw TypeError("Private accessor was defined without a getter");if(typeof t==="function"?e!==t||!i:!t.has(e))throw TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?i:n==="a"?i.call(e):i?i.value:t.get(e)},fe,Dt,tn,xe,ke,On,ot,yt,In,Ie,Tn,Te,Xe,Ae,Pe,Pn,wt,De,U,Rn,Mn,$e,bt,Wt,Ft,at,Bn,H,Ct,Et,xt,q,Nn,Ge,ce;function Oo(e){return(t=[],n=e.process.cwd(),i)=>{let s=new Io(t,n,i,e);return Object.defineProperty(s,"argv",{get:()=>s.parse(),enumerable:!0}),s.help(),s.version(),s}}var lo=Symbol("copyDoubleDash"),fo=Symbol("copyDoubleDash"),Ws=Symbol("deleteFromParserHintObject"),po=Symbol("emitWarning"),ho=Symbol("freeze"),go=Symbol("getDollarZero"),_t=Symbol("getParserConfiguration"),mo=Symbol("getUsageConfiguration"),Us=Symbol("guessLocale"),Do=Symbol("guessVersion"),yo=Symbol("parsePositionalNumbers"),Js=Symbol("pkgUp"),ct=Symbol("populateParserHintArray"),Ut=Symbol("populateParserHintSingleValueDictionary"),Ks=Symbol("populateParserHintArrayDictionary"),zs=Symbol("populateParserHintDictionary"),Hs=Symbol("sanitizeKey"),qs=Symbol("setKey"),Ys=Symbol("unfreeze"),wo=Symbol("validateAsync"),bo=Symbol("getCommandInstance"),Fo=Symbol("getContext"),Co=Symbol("getHasOutput"),Eo=Symbol("getLoggerInstance"),xo=Symbol("getParseContext"),_o=Symbol("getUsageInstance"),So=Symbol("getValidationInstance"),vn=Symbol("hasParseCallback"),ko=Symbol("isGlobalContext"),St=Symbol("postProcess"),Ao=Symbol("rebase"),Xs=Symbol("reset"),nn=Symbol("runYargsParserAndExecuteCommands"),Gs=Symbol("runValidation"),$o=Symbol("setHasOutput"),kt=Symbol("kTrackManuallySetKeys"),rl="en_US";class Io{constructor(e=[],t,n,i){this.customScriptName=!1,this.parsed=!1,fe.set(this,void 0),Dt.set(this,void 0),tn.set(this,{commands:[],fullCommands:[]}),xe.set(this,null),ke.set(this,null),On.set(this,"show-hidden"),ot.set(this,null),yt.set(this,!0),In.set(this,{}),Ie.set(this,!0),Tn.set(this,[]),Te.set(this,void 0),Xe.set(this,{}),Ae.set(this,!1),Pe.set(this,null),Pn.set(this,!0),wt.set(this,void 0),De.set(this,""),U.set(this,void 0),Rn.set(this,void 0),Mn.set(this,{}),$e.set(this,null),bt.set(this,null),Wt.set(this,{}),Ft.set(this,{}),at.set(this,void 0),Bn.set(this,!1),H.set(this,void 0),Ct.set(this,!1),Et.set(this,!1),xt.set(this,!1),q.set(this,void 0),Nn.set(this,{}),Ge.set(this,null),ce.set(this,void 0),v(this,H,i,"f"),v(this,at,e,"f"),v(this,Dt,t,"f"),v(this,Rn,n,"f"),v(this,Te,new vs(this),"f"),this.$0=this[go](),this[Xs](),v(this,fe,g(this,fe,"f"),"f"),v(this,q,g(this,q,"f"),"f"),v(this,ce,g(this,ce,"f"),"f"),v(this,U,g(this,U,"f"),"f"),g(this,U,"f").showHiddenOpt=g(this,On,"f"),v(this,wt,this[fo](),"f"),g(this,H,"f").y18n.setLocale(rl)}addHelpOpt(e,t){if(N("[string|boolean] [string]",[e,t],arguments.length),g(this,Pe,"f"))this[Ws](g(this,Pe,"f")),v(this,Pe,null,"f");if(e===!1&&t===void 0)return this;return v(this,Pe,typeof e==="string"?e:"help","f"),this.boolean(g(this,Pe,"f")),this.describe(g(this,Pe,"f"),t||g(this,q,"f").deferY18nLookup("Show help")),this}help(e,t){return this.addHelpOpt(e,t)}addShowHiddenOpt(e,t){if(N("[string|boolean] [string]",[e,t],arguments.length),e===!1&&t===void 0)return this;let n=typeof e==="string"?e:g(this,On,"f");return this.boolean(n),this.describe(n,t||g(this,q,"f").deferY18nLookup("Show hidden options")),g(this,U,"f").showHiddenOpt=n,this}showHidden(e,t){return this.addShowHiddenOpt(e,t)}alias(e,t){return N("<object|string|array> [string|array]",[e,t],arguments.length),this[Ks](this.alias.bind(this),"alias",e,t),this}array(e){return N("<array|string>",[e],arguments.length),this[ct]("array",e),this[kt](e),this}boolean(e){return N("<array|string>",[e],arguments.length),this[ct]("boolean",e),this[kt](e),this}check(e,t){return N("<function> [boolean]",[e,t],arguments.length),this.middleware((n,i)=>mt(()=>e(n,i.getOptions()),(s)=>{if(!s)g(this,q,"f").fail(g(this,H,"f").y18n.__("Argument check failed: %s",e.toString()));else if(typeof s==="string"||s instanceof Error)g(this,q,"f").fail(s.toString(),s);return n},(s)=>(g(this,q,"f").fail(s.message?s.message:s.toString(),s),n)),!1,t),this}choices(e,t){return N("<object|string|array> [string|array]",[e,t],arguments.length),this[Ks](this.choices.bind(this),"choices",e,t),this}coerce(e,t){if(N("<object|string|array> [function]",[e,t],arguments.length),Array.isArray(e)){if(!t)throw new le("coerce callback must be provided");for(let i of e)this.coerce(i,t);return this}else if(typeof e==="object"){for(let i of Object.keys(e))this.coerce(i,e[i]);return this}if(!t)throw new le("coerce callback must be provided");let n=e;return g(this,U,"f").key[n]=!0,g(this,Te,"f").addCoerceMiddleware((i,s)=>{var r;let o=(r=s.getAliases()[n])!==null&&r!==void 0?r:[],a=[n,...o].filter((c)=>Object.prototype.hasOwnProperty.call(i,c));if(a.length===0)return i;return mt(()=>t(i[a[0]]),(c)=>(a.forEach((u)=>{i[u]=c}),i),(c)=>{throw new le(c.message)})},n),this}conflicts(e,t){return N("<string|object> [string|array]",[e,t],arguments.length),g(this,ce,"f").conflicts(e,t),this}config(e="config",t,n){if(N("[object|string] [string|function] [function]",[e,t,n],arguments.length),typeof e==="object"&&!Array.isArray(e))return e=en(e,g(this,Dt,"f"),this[_t]()["deep-merge-config"]||!1,g(this,H,"f")),g(this,U,"f").configObjects=(g(this,U,"f").configObjects||[]).concat(e),this;if(typeof t==="function")n=t,t=void 0;return this.describe(e,t||g(this,q,"f").deferY18nLookup("Path to JSON config file")),(Array.isArray(e)?e:[e]).forEach((i)=>{g(this,U,"f").config[i]=n||!0}),this}completion(e,t,n){if(N("[string] [string|boolean|function] [function]",[e,t,n],arguments.length),typeof t==="function")n=t,t=void 0;if(v(this,ke,e||g(this,ke,"f")||"completion","f"),!t&&t!==!1)t="generate completion script";if(this.command(g(this,ke,"f"),t),n)g(this,xe,"f").registerFunction(n);return this}command(e,t,n,i,s,r){return N("<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]",[e,t,n,i,s,r],arguments.length),g(this,fe,"f").addHandler(e,t,n,i,s,r),this}commands(e,t,n,i,s,r){return this.command(e,t,n,i,s,r)}commandDir(e,t){N("<string> [object]",[e,t],arguments.length);let n=g(this,Rn,"f")||g(this,H,"f").require;return g(this,fe,"f").addDirectory(e,n,g(this,H,"f").getCallerFile(),t),this}count(e){return N("<array|string>",[e],arguments.length),this[ct]("count",e),this[kt](e),this}default(e,t,n){if(N("<object|string|array> [*] [string]",[e,t,n],arguments.length),n)Ns(e,g(this,H,"f")),g(this,U,"f").defaultDescription[e]=n;if(typeof t==="function"){if(Ns(e,g(this,H,"f")),!g(this,U,"f").defaultDescription[e])g(this,U,"f").defaultDescription[e]=g(this,q,"f").functionDescription(t);t=t.call()}return this[Ut](this.default.bind(this),"default",e,t),this}defaults(e,t,n){return this.default(e,t,n)}demandCommand(e=1,t,n,i){if(N("[number] [number|string] [string|null|undefined] [string|null|undefined]",[e,t,n,i],arguments.length),typeof t!=="number")n=t,t=1/0;return this.global("_",!1),g(this,U,"f").demandedCommands._={min:e,max:t,minMsg:n,maxMsg:i},this}demand(e,t,n){if(Array.isArray(t))t.forEach((i)=>{Ce(n,!0,g(this,H,"f")),this.demandOption(i,n)}),t=1/0;else if(typeof t!=="number")n=t,t=1/0;if(typeof e==="number")Ce(n,!0,g(this,H,"f")),this.demandCommand(e,t,n,n);else if(Array.isArray(e))e.forEach((i)=>{Ce(n,!0,g(this,H,"f")),this.demandOption(i,n)});else if(typeof n==="string")this.demandOption(e,n);else if(n===!0||typeof n>"u")this.demandOption(e);return this}demandOption(e,t){return N("<object|string|array> [string]",[e,t],arguments.length),this[Ut](this.demandOption.bind(this),"demandedOptions",e,t),this}deprecateOption(e,t){return N("<string> [string|boolean]",[e,t],arguments.length),g(this,U,"f").deprecatedOptions[e]=t,this}describe(e,t){return N("<object|string|array> [string]",[e,t],arguments.length),this[qs](e,!0),g(this,q,"f").describe(e,t),this}detectLocale(e){return N("<boolean>",[e],arguments.length),v(this,yt,e,"f"),this}env(e){if(N("[string|boolean]",[e],arguments.length),e===!1)delete g(this,U,"f").envPrefix;else g(this,U,"f").envPrefix=e||"";return this}epilogue(e){return N("<string>",[e],arguments.length),g(this,q,"f").epilog(e),this}epilog(e){return this.epilogue(e)}example(e,t){if(N("<string|array> [string]",[e,t],arguments.length),Array.isArray(e))e.forEach((n)=>this.example(...n));else g(this,q,"f").example(e,t);return this}exit(e,t){if(v(this,Ae,!0,"f"),v(this,ot,t,"f"),g(this,Ie,"f"))g(this,H,"f").process.exit(e)}exitProcess(e=!0){return N("[boolean]",[e],arguments.length),v(this,Ie,e,"f"),this}fail(e){if(N("<function|boolean>",[e],arguments.length),typeof e==="boolean"&&e!==!1)throw new le("Invalid first argument. Expected function or boolean 'false'");return g(this,q,"f").failFn(e),this}getAliases(){return this.parsed?this.parsed.aliases:{}}async getCompletion(e,t){if(N("<array> [function]",[e,t],arguments.length),!t)return new Promise((n,i)=>{g(this,xe,"f").getCompletion(e,(s,r)=>{if(s)i(s);else n(r)})});else return g(this,xe,"f").getCompletion(e,t)}getDemandedOptions(){return N([],0),g(this,U,"f").demandedOptions}getDemandedCommands(){return N([],0),g(this,U,"f").demandedCommands}getDeprecatedOptions(){return N([],0),g(this,U,"f").deprecatedOptions}getDetectLocale(){return g(this,yt,"f")}getExitProcess(){return g(this,Ie,"f")}getGroups(){return Object.assign({},g(this,Xe,"f"),g(this,Ft,"f"))}getHelp(){if(v(this,Ae,!0,"f"),!g(this,q,"f").hasCachedHelpMessage()){if(!this.parsed){let t=this[nn](g(this,at,"f"),void 0,void 0,0,!0);if(ie(t))return t.then(()=>g(this,q,"f").help())}let e=g(this,fe,"f").runDefaultBuilderOn(this);if(ie(e))return e.then(()=>g(this,q,"f").help())}return Promise.resolve(g(this,q,"f").help())}getOptions(){return g(this,U,"f")}getStrict(){return g(this,Ct,"f")}getStrictCommands(){return g(this,Et,"f")}getStrictOptions(){return g(this,xt,"f")}global(e,t){if(N("<string|array> [boolean]",[e,t],arguments.length),e=[].concat(e),t!==!1)g(this,U,"f").local=g(this,U,"f").local.filter((n)=>e.indexOf(n)===-1);else e.forEach((n)=>{if(!g(this,U,"f").local.includes(n))g(this,U,"f").local.push(n)});return this}group(e,t){N("<string|array> <string>",[e,t],arguments.length);let n=g(this,Ft,"f")[t]||g(this,Xe,"f")[t];if(g(this,Ft,"f")[t])delete g(this,Ft,"f")[t];let i={};return g(this,Xe,"f")[t]=(n||[]).concat(e).filter((s)=>{if(i[s])return!1;return i[s]=!0}),this}hide(e){return N("<string>",[e],arguments.length),g(this,U,"f").hiddenOptions.push(e),this}implies(e,t){return N("<string|object> [number|string|array]",[e,t],arguments.length),g(this,ce,"f").implies(e,t),this}locale(e){if(N("[string]",[e],arguments.length),e===void 0)return this[Us](),g(this,H,"f").y18n.getLocale();return v(this,yt,!1,"f"),g(this,H,"f").y18n.setLocale(e),this}middleware(e,t,n){return g(this,Te,"f").addMiddleware(e,!!t,n)}nargs(e,t){return N("<string|object|array> [number]",[e,t],arguments.length),this[Ut](this.nargs.bind(this),"narg",e,t),this}normalize(e){return N("<array|string>",[e],arguments.length),this[ct]("normalize",e),this}number(e){return N("<array|string>",[e],arguments.length),this[ct]("number",e),this[kt](e),this}option(e,t){if(N("<string|object> [object]",[e,t],arguments.length),typeof e==="object")Object.keys(e).forEach((n)=>{this.options(n,e[n])});else{if(typeof t!=="object")t={};if(this[kt](e),g(this,Ge,"f")&&(e==="version"||(t===null||t===void 0?void 0:t.alias)==="version"))this[po](['"version" is a reserved word.',"Please do one of the following:",'- Disable version with `yargs.version(false)` if using "version" as an option',"- Use the built-in `yargs.version` method instead (if applicable)","- Use a different option key","https://yargs.js.org/docs/#api-reference-version"].join(`
79
+ `),void 0,"versionWarning");if(g(this,U,"f").key[e]=!0,t.alias)this.alias(e,t.alias);let n=t.deprecate||t.deprecated;if(n)this.deprecateOption(e,n);let i=t.demand||t.required||t.require;if(i)this.demand(e,i);if(t.demandOption)this.demandOption(e,typeof t.demandOption==="string"?t.demandOption:void 0);if(t.conflicts)this.conflicts(e,t.conflicts);if("default"in t)this.default(e,t.default);if(t.implies!==void 0)this.implies(e,t.implies);if(t.nargs!==void 0)this.nargs(e,t.nargs);if(t.config)this.config(e,t.configParser);if(t.normalize)this.normalize(e);if(t.choices)this.choices(e,t.choices);if(t.coerce)this.coerce(e,t.coerce);if(t.group)this.group(e,t.group);if(t.boolean||t.type==="boolean"){if(this.boolean(e),t.alias)this.boolean(t.alias)}if(t.array||t.type==="array"){if(this.array(e),t.alias)this.array(t.alias)}if(t.number||t.type==="number"){if(this.number(e),t.alias)this.number(t.alias)}if(t.string||t.type==="string"){if(this.string(e),t.alias)this.string(t.alias)}if(t.count||t.type==="count")this.count(e);if(typeof t.global==="boolean")this.global(e,t.global);if(t.defaultDescription)g(this,U,"f").defaultDescription[e]=t.defaultDescription;if(t.skipValidation)this.skipValidation(e);let s=t.describe||t.description||t.desc,r=g(this,q,"f").getDescriptions();if(!Object.prototype.hasOwnProperty.call(r,e)||typeof s==="string")this.describe(e,s);if(t.hidden)this.hide(e);if(t.requiresArg)this.requiresArg(e)}return this}options(e,t){return this.option(e,t)}parse(e,t,n){if(N("[string|array] [function|boolean|object] [function]",[e,t,n],arguments.length),this[ho](),typeof e>"u")e=g(this,at,"f");if(typeof t==="object")v(this,bt,t,"f"),t=n;if(typeof t==="function")v(this,$e,t,"f"),t=!1;if(!t)v(this,at,e,"f");if(g(this,$e,"f"))v(this,Ie,!1,"f");let i=this[nn](e,!!t),s=this.parsed;if(g(this,xe,"f").setParsed(this.parsed),ie(i))return i.then((r)=>{if(g(this,$e,"f"))g(this,$e,"f").call(this,g(this,ot,"f"),r,g(this,De,"f"));return r}).catch((r)=>{if(g(this,$e,"f"))g(this,$e,"f")(r,this.parsed.argv,g(this,De,"f"));throw r}).finally(()=>{this[Ys](),this.parsed=s});else{if(g(this,$e,"f"))g(this,$e,"f").call(this,g(this,ot,"f"),i,g(this,De,"f"));this[Ys](),this.parsed=s}return i}parseAsync(e,t,n){let i=this.parse(e,t,n);return!ie(i)?Promise.resolve(i):i}parseSync(e,t,n){let i=this.parse(e,t,n);if(ie(i))throw new le(".parseSync() must not be used with asynchronous builders, handlers, or middleware");return i}parserConfiguration(e){return N("<object>",[e],arguments.length),v(this,Mn,e,"f"),this}pkgConf(e,t){N("<string> [string]",[e,t],arguments.length);let n=null,i=this[Js](t||g(this,Dt,"f"));if(i[e]&&typeof i[e]==="object")n=en(i[e],t||g(this,Dt,"f"),this[_t]()["deep-merge-config"]||!1,g(this,H,"f")),g(this,U,"f").configObjects=(g(this,U,"f").configObjects||[]).concat(n);return this}positional(e,t){N("<string> <object>",[e,t],arguments.length);let n=["default","defaultDescription","implies","normalize","choices","conflicts","coerce","type","describe","desc","description","alias"];t=it(t,(r,o)=>{if(r==="type"&&!["string","number","boolean"].includes(o))return!1;return n.includes(r)});let i=g(this,tn,"f").fullCommands[g(this,tn,"f").fullCommands.length-1],s=i?g(this,fe,"f").cmdToParseOptions(i):{array:[],alias:{},default:{},demand:{}};return jt(s).forEach((r)=>{let o=s[r];if(Array.isArray(o)){if(o.indexOf(e)!==-1)t[r]=!0}else if(o[e]&&!(r in t))t[r]=o[e]}),this.group(e,g(this,q,"f").getPositionalGroupName()),this.option(e,t)}recommendCommands(e=!0){return N("[boolean]",[e],arguments.length),v(this,Bn,e,"f"),this}required(e,t,n){return this.demand(e,t,n)}require(e,t,n){return this.demand(e,t,n)}requiresArg(e){if(N("<array|string|object> [number]",[e],arguments.length),typeof e==="string"&&g(this,U,"f").narg[e])return this;else this[Ut](this.requiresArg.bind(this),"narg",e,NaN);return this}showCompletionScript(e,t){return N("[string] [string]",[e,t],arguments.length),e=e||this.$0,g(this,wt,"f").log(g(this,xe,"f").generateCompletionScript(e,t||g(this,ke,"f")||"completion")),this}showHelp(e){if(N("[string|function]",[e],arguments.length),v(this,Ae,!0,"f"),!g(this,q,"f").hasCachedHelpMessage()){if(!this.parsed){let n=this[nn](g(this,at,"f"),void 0,void 0,0,!0);if(ie(n))return n.then(()=>{g(this,q,"f").showHelp(e)}),this}let t=g(this,fe,"f").runDefaultBuilderOn(this);if(ie(t))return t.then(()=>{g(this,q,"f").showHelp(e)}),this}return g(this,q,"f").showHelp(e),this}scriptName(e){return this.customScriptName=!0,this.$0=e,this}showHelpOnFail(e,t){return N("[boolean|string] [string]",[e,t],arguments.length),g(this,q,"f").showHelpOnFail(e,t),this}showVersion(e){return N("[string|function]",[e],arguments.length),g(this,q,"f").showVersion(e),this}skipValidation(e){return N("<array|string>",[e],arguments.length),this[ct]("skipValidation",e),this}strict(e){return N("[boolean]",[e],arguments.length),v(this,Ct,e!==!1,"f"),this}strictCommands(e){return N("[boolean]",[e],arguments.length),v(this,Et,e!==!1,"f"),this}strictOptions(e){return N("[boolean]",[e],arguments.length),v(this,xt,e!==!1,"f"),this}string(e){return N("<array|string>",[e],arguments.length),this[ct]("string",e),this[kt](e),this}terminalWidth(){return N([],0),g(this,H,"f").process.stdColumns}updateLocale(e){return this.updateStrings(e)}updateStrings(e){return N("<object>",[e],arguments.length),v(this,yt,!1,"f"),g(this,H,"f").y18n.updateLocale(e),this}usage(e,t,n,i){if(N("<string|null|undefined> [string|boolean] [function|object] [function]",[e,t,n,i],arguments.length),t!==void 0)if(Ce(e,null,g(this,H,"f")),(e||"").match(/^\$0( |$)/))return this.command(e,t,n,i);else throw new le(".usage() description must start with $0 if being used as alias for .command()");else return g(this,q,"f").usage(e),this}usageConfiguration(e){return N("<object>",[e],arguments.length),v(this,Nn,e,"f"),this}version(e,t,n){if(N("[boolean|string] [string] [string]",[e,t,n],arguments.length),g(this,Ge,"f"))this[Ws](g(this,Ge,"f")),g(this,q,"f").version(void 0),v(this,Ge,null,"f");if(arguments.length===0)n=this[Do](),e="version";else if(arguments.length===1){if(e===!1)return this;n=e,e="version"}else if(arguments.length===2)n=t,t=void 0;return v(this,Ge,typeof e==="string"?e:"version","f"),t=t||g(this,q,"f").deferY18nLookup("Show version number"),g(this,q,"f").version(n||void 0),this.boolean(g(this,Ge,"f")),this.describe(g(this,Ge,"f"),t),this}wrap(e){return N("<number|null|undefined>",[e],arguments.length),g(this,q,"f").wrap(e),this}[(fe=new WeakMap,Dt=new WeakMap,tn=new WeakMap,xe=new WeakMap,ke=new WeakMap,On=new WeakMap,ot=new WeakMap,yt=new WeakMap,In=new WeakMap,Ie=new WeakMap,Tn=new WeakMap,Te=new WeakMap,Xe=new WeakMap,Ae=new WeakMap,Pe=new WeakMap,Pn=new WeakMap,wt=new WeakMap,De=new WeakMap,U=new WeakMap,Rn=new WeakMap,Mn=new WeakMap,$e=new WeakMap,bt=new WeakMap,Wt=new WeakMap,Ft=new WeakMap,at=new WeakMap,Bn=new WeakMap,H=new WeakMap,Ct=new WeakMap,Et=new WeakMap,xt=new WeakMap,q=new WeakMap,Nn=new WeakMap,Ge=new WeakMap,ce=new WeakMap,lo)](e){if(!e._||!e["--"])return e;e._.push.apply(e._,e["--"]);try{delete e["--"]}catch(t){}return e}[fo](){return{log:(...e)=>{if(!this[vn]())console.log(...e);if(v(this,Ae,!0,"f"),g(this,De,"f").length)v(this,De,g(this,De,"f")+`
80
+ `,"f");v(this,De,g(this,De,"f")+e.join(" "),"f")},error:(...e)=>{if(!this[vn]())console.error(...e);if(v(this,Ae,!0,"f"),g(this,De,"f").length)v(this,De,g(this,De,"f")+`
81
+ `,"f");v(this,De,g(this,De,"f")+e.join(" "),"f")}}}[Ws](e){jt(g(this,U,"f")).forEach((t)=>{if(((i)=>i==="configObjects")(t))return;let n=g(this,U,"f")[t];if(Array.isArray(n)){if(n.includes(e))n.splice(n.indexOf(e),1)}else if(typeof n==="object")delete n[e]}),delete g(this,q,"f").getDescriptions()[e]}[po](e,t,n){if(!g(this,In,"f")[n])g(this,H,"f").process.emitWarning(e,t),g(this,In,"f")[n]=!0}[ho](){g(this,Tn,"f").push({options:g(this,U,"f"),configObjects:g(this,U,"f").configObjects.slice(0),exitProcess:g(this,Ie,"f"),groups:g(this,Xe,"f"),strict:g(this,Ct,"f"),strictCommands:g(this,Et,"f"),strictOptions:g(this,xt,"f"),completionCommand:g(this,ke,"f"),output:g(this,De,"f"),exitError:g(this,ot,"f"),hasOutput:g(this,Ae,"f"),parsed:this.parsed,parseFn:g(this,$e,"f"),parseContext:g(this,bt,"f")}),g(this,q,"f").freeze(),g(this,ce,"f").freeze(),g(this,fe,"f").freeze(),g(this,Te,"f").freeze()}[go](){let e="",t;if(/\b(node|iojs|electron)(\.exe)?$/.test(g(this,H,"f").process.argv()[0]))t=g(this,H,"f").process.argv().slice(1,2);else t=g(this,H,"f").process.argv().slice(0,1);if(e=t.map((n)=>{let i=this[Ao](g(this,Dt,"f"),n);return n.match(/^(\/|([a-zA-Z]:)?\\)/)&&i.length<n.length?i:n}).join(" ").trim(),g(this,H,"f").getEnv("_")&&g(this,H,"f").getProcessArgvBin()===g(this,H,"f").getEnv("_"))e=g(this,H,"f").getEnv("_").replace(`${g(this,H,"f").path.dirname(g(this,H,"f").process.execPath())}/`,"");return e}[_t](){return g(this,Mn,"f")}[mo](){return g(this,Nn,"f")}[Us](){if(!g(this,yt,"f"))return;let e=g(this,H,"f").getEnv("LC_ALL")||g(this,H,"f").getEnv("LC_MESSAGES")||g(this,H,"f").getEnv("LANG")||g(this,H,"f").getEnv("LANGUAGE")||"en_US";this.locale(e.replace(/[.:].*/,""))}[Do](){return this[Js]().version||"unknown"}[yo](e){let t=e["--"]?e["--"]:e._;for(let n=0,i;(i=t[n])!==void 0;n++)if(g(this,H,"f").Parser.looksLikeNumber(i)&&Number.isSafeInteger(Math.floor(parseFloat(`${i}`))))t[n]=Number(i);return e}[Js](e){let t=e||"*";if(g(this,Wt,"f")[t])return g(this,Wt,"f")[t];let n={};try{let i=e||g(this,H,"f").mainFilename;if(g(this,H,"f").path.extname(i))i=g(this,H,"f").path.dirname(i);let s=g(this,H,"f").findUp(i,(r,o)=>{if(o.includes("package.json"))return"package.json";else return});Ce(s,void 0,g(this,H,"f")),n=JSON.parse(g(this,H,"f").readFileSync(s,"utf8"))}catch(i){}return g(this,Wt,"f")[t]=n||{},g(this,Wt,"f")[t]}[ct](e,t){t=[].concat(t),t.forEach((n)=>{n=this[Hs](n),g(this,U,"f")[e].push(n)})}[Ut](e,t,n,i){this[zs](e,t,n,i,(s,r,o)=>{g(this,U,"f")[s][r]=o})}[Ks](e,t,n,i){this[zs](e,t,n,i,(s,r,o)=>{g(this,U,"f")[s][r]=(g(this,U,"f")[s][r]||[]).concat(o)})}[zs](e,t,n,i,s){if(Array.isArray(n))n.forEach((r)=>{e(r,i)});else if(((r)=>typeof r==="object")(n))for(let r of jt(n))e(r,n[r]);else s(t,this[Hs](n),i)}[Hs](e){if(e==="__proto__")return"___proto___";return e}[qs](e,t){return this[Ut](this[qs].bind(this),"key",e,t),this}[Ys](){var e,t,n,i,s,r,o,a,c,u,f,l;let d=g(this,Tn,"f").pop();Ce(d,void 0,g(this,H,"f"));let h;e=this,t=this,n=this,i=this,s=this,r=this,o=this,a=this,c=this,u=this,f=this,l=this,{options:{set value(m){v(e,U,m,"f")}}.value,configObjects:h,exitProcess:{set value(m){v(t,Ie,m,"f")}}.value,groups:{set value(m){v(n,Xe,m,"f")}}.value,output:{set value(m){v(i,De,m,"f")}}.value,exitError:{set value(m){v(s,ot,m,"f")}}.value,hasOutput:{set value(m){v(r,Ae,m,"f")}}.value,parsed:this.parsed,strict:{set value(m){v(o,Ct,m,"f")}}.value,strictCommands:{set value(m){v(a,Et,m,"f")}}.value,strictOptions:{set value(m){v(c,xt,m,"f")}}.value,completionCommand:{set value(m){v(u,ke,m,"f")}}.value,parseFn:{set value(m){v(f,$e,m,"f")}}.value,parseContext:{set value(m){v(l,bt,m,"f")}}.value}=d,g(this,U,"f").configObjects=h,g(this,q,"f").unfreeze(),g(this,ce,"f").unfreeze(),g(this,fe,"f").unfreeze(),g(this,Te,"f").unfreeze()}[wo](e,t){return mt(t,(n)=>(e(n),n))}getInternalMethods(){return{getCommandInstance:this[bo].bind(this),getContext:this[Fo].bind(this),getHasOutput:this[Co].bind(this),getLoggerInstance:this[Eo].bind(this),getParseContext:this[xo].bind(this),getParserConfiguration:this[_t].bind(this),getUsageConfiguration:this[mo].bind(this),getUsageInstance:this[_o].bind(this),getValidationInstance:this[So].bind(this),hasParseCallback:this[vn].bind(this),isGlobalContext:this[ko].bind(this),postProcess:this[St].bind(this),reset:this[Xs].bind(this),runValidation:this[Gs].bind(this),runYargsParserAndExecuteCommands:this[nn].bind(this),setHasOutput:this[$o].bind(this)}}[bo](){return g(this,fe,"f")}[Fo](){return g(this,tn,"f")}[Co](){return g(this,Ae,"f")}[Eo](){return g(this,wt,"f")}[xo](){return g(this,bt,"f")||{}}[_o](){return g(this,q,"f")}[So](){return g(this,ce,"f")}[vn](){return!!g(this,$e,"f")}[ko](){return g(this,Pn,"f")}[St](e,t,n,i){if(n)return e;if(ie(e))return e;if(!t)e=this[lo](e);if(this[_t]()["parse-positional-numbers"]||this[_t]()["parse-positional-numbers"]===void 0)e=this[yo](e);if(i)e=gt(e,this,g(this,Te,"f").getMiddleware(),!1);return e}[Xs](e={}){v(this,U,g(this,U,"f")||{},"f");let t={};t.local=g(this,U,"f").local||[],t.configObjects=g(this,U,"f").configObjects||[];let n={};t.local.forEach((r)=>{n[r]=!0,(e[r]||[]).forEach((o)=>{n[o]=!0})}),Object.assign(g(this,Ft,"f"),Object.keys(g(this,Xe,"f")).reduce((r,o)=>{let a=g(this,Xe,"f")[o].filter((c)=>!(c in n));if(a.length>0)r[o]=a;return r},{})),v(this,Xe,{},"f");let i=["array","boolean","string","skipValidation","count","normalize","number","hiddenOptions"],s=["narg","key","alias","default","defaultDescription","config","choices","demandedOptions","demandedCommands","deprecatedOptions"];if(i.forEach((r)=>{t[r]=(g(this,U,"f")[r]||[]).filter((o)=>!n[o])}),s.forEach((r)=>{t[r]=it(g(this,U,"f")[r],(o)=>!n[o])}),t.envPrefix=g(this,U,"f").envPrefix,v(this,U,t,"f"),v(this,q,g(this,q,"f")?g(this,q,"f").reset(n):to(this,g(this,H,"f")),"f"),v(this,ce,g(this,ce,"f")?g(this,ce,"f").reset(n):co(this,g(this,q,"f"),g(this,H,"f")),"f"),v(this,fe,g(this,fe,"f")?g(this,fe,"f").reset():Zr(g(this,q,"f"),g(this,ce,"f"),g(this,Te,"f"),g(this,H,"f")),"f"),!g(this,xe,"f"))v(this,xe,ro(this,g(this,q,"f"),g(this,fe,"f"),g(this,H,"f")),"f");return g(this,Te,"f").reset(),v(this,ke,null,"f"),v(this,De,"","f"),v(this,ot,null,"f"),v(this,Ae,!1,"f"),this.parsed=!1,this}[Ao](e,t){return g(this,H,"f").path.relative(e,t)}[nn](e,t,n,i=0,s=!1){var r,o,a,c;let u=!!n||s;e=e||g(this,at,"f"),g(this,U,"f").__=g(this,H,"f").y18n.__,g(this,U,"f").configuration=this[_t]();let f=!!g(this,U,"f").configuration["populate--"],l=Object.assign({},g(this,U,"f").configuration,{"populate--":!0}),d=g(this,H,"f").Parser.detailed(e,Object.assign({},g(this,U,"f"),{configuration:{"parse-positional-numbers":!1,...l}})),h=Object.assign(d.argv,g(this,bt,"f")),m=void 0,p=d.aliases,y=!1,C=!1;if(Object.keys(h).forEach((F)=>{if(F===g(this,Pe,"f")&&h[F])y=!0;else if(F===g(this,Ge,"f")&&h[F])C=!0}),h.$0=this.$0,this.parsed=d,i===0)g(this,q,"f").clearCachedHelpMessage();try{if(this[Us](),t)return this[St](h,f,!!n,!1);if(g(this,Pe,"f")){if([g(this,Pe,"f")].concat(p[g(this,Pe,"f")]||[]).filter((I)=>I.length>1).includes(""+h._[h._.length-1]))h._.pop(),y=!0}v(this,Pn,!1,"f");let F=g(this,fe,"f").getCommands(),k=((r=g(this,xe,"f"))===null||r===void 0?void 0:r.completionKey)?[(o=g(this,xe,"f"))===null||o===void 0?void 0:o.completionKey,...(c=this.getAliases()[(a=g(this,xe,"f"))===null||a===void 0?void 0:a.completionKey])!==null&&c!==void 0?c:[]].some((A)=>Object.prototype.hasOwnProperty.call(h,A)):!1,S=y||k||s;if(h._.length){if(F.length){let A;for(let I=i||0,W;h._[I]!==void 0;I++)if(W=String(h._[I]),F.includes(W)&&W!==g(this,ke,"f")){let B=g(this,fe,"f").runCommand(W,this,d,I+1,s,y||C||s);return this[St](B,f,!!n,!1)}else if(!A&&W!==g(this,ke,"f")){A=W;break}if(!g(this,fe,"f").hasDefaultCommand()&&g(this,Bn,"f")&&A&&!S)g(this,ce,"f").recommendCommands(A,F)}if(g(this,ke,"f")&&h._.includes(g(this,ke,"f"))&&!k){if(g(this,Ie,"f"))rt(!0);this.showCompletionScript(),this.exit(0)}}if(g(this,fe,"f").hasDefaultCommand()&&!S){let A=g(this,fe,"f").runCommand(null,this,d,0,s,y||C||s);return this[St](A,f,!!n,!1)}if(k){if(g(this,Ie,"f"))rt(!0);e=[].concat(e);let A=e.slice(e.indexOf(`--${g(this,xe,"f").completionKey}`)+1);return g(this,xe,"f").getCompletion(A,(I,W)=>{if(I)throw new le(I.message);(W||[]).forEach((B)=>{g(this,wt,"f").log(B)}),this.exit(0)}),this[St](h,!f,!!n,!1)}if(!g(this,Ae,"f")){if(y){if(g(this,Ie,"f"))rt(!0);u=!0,this.showHelp((A)=>{g(this,wt,"f").log(A),this.exit(0)})}else if(C){if(g(this,Ie,"f"))rt(!0);u=!0,g(this,q,"f").showVersion("log"),this.exit(0)}}if(!u&&g(this,U,"f").skipValidation.length>0)u=Object.keys(h).some((A)=>g(this,U,"f").skipValidation.indexOf(A)>=0&&h[A]===!0);if(!u){if(d.error)throw new le(d.error.message);if(!k){let A=this[Gs](p,{},d.error);if(!n)m=gt(h,this,g(this,Te,"f").getMiddleware(),!0);if(m=this[wo](A,m!==null&&m!==void 0?m:h),ie(m)&&!n)m=m.then(()=>gt(h,this,g(this,Te,"f").getMiddleware(),!1))}}}catch(F){if(F instanceof le)g(this,q,"f").fail(F.message,F);else throw F}return this[St](m!==null&&m!==void 0?m:h,f,!!n,!0)}[Gs](e,t,n,i){let s={...this.getDemandedOptions()};return(r)=>{if(n)throw new le(n.message);g(this,ce,"f").nonOptionCount(r),g(this,ce,"f").requiredArguments(r,s);let o=!1;if(g(this,Et,"f"))o=g(this,ce,"f").unknownCommands(r);if(g(this,Ct,"f")&&!o)g(this,ce,"f").unknownArguments(r,e,t,!!i);else if(g(this,xt,"f"))g(this,ce,"f").unknownArguments(r,e,{},!1,!1);g(this,ce,"f").limitedChoices(r),g(this,ce,"f").implications(r),g(this,ce,"f").conflicting(r)}}[$o](){v(this,Ae,!0,"f")}[kt](e){if(typeof e==="string")g(this,U,"f").key[e]=!0;else for(let t of e)g(this,U,"f").key[t]=!0}}function Qr(e){return!!e&&typeof e.getInternalMethods==="function"}var ol=Oo(Bs),To=ol;import{existsSync as jn,readFileSync as Qs,writeFileSync as Vs,mkdirSync as Mo}from"node:fs";import{homedir as al}from"node:os";import{join as At,dirname as ei}from"node:path";function ti(){return process.env.HOME||al()}function Bo(){return At(ti(),".config","slack-cli","profiles.json")}function Ln(){return At(process.cwd(),".slack-cli","workspace")}function Wn(){return At(ti(),".slack-cli","workspace")}function sn(){let e=Bo();if(!jn(e))return{profiles:{}};return JSON.parse(Qs(e,"utf8"))}function cl(e){let t=Bo();Mo(ei(t),{recursive:!0}),Vs(t,JSON.stringify(e,null,2)+`
82
+ `)}function Jt(e){if(!jn(e))return;return Qs(e,"utf8").trim()||void 0}function Po(e,t){let n=ei(e);Mo(n,{recursive:!0});let i=At(n,".gitignore");if(!jn(i))Vs(i,`*
83
+ `);Vs(e,t+`
84
+ `)}function ul(e){let t={};for(let n of e.split(`
85
+ `)){let i=n.trim();if(!i||i.startsWith("#"))continue;let s=i.indexOf("=");if(s===-1)continue;let r=i.slice(0,s).trim(),o=i.slice(s+1).trim();if(o.startsWith('"')&&o.endsWith('"')||o.startsWith("'")&&o.endsWith("'"))o=o.slice(1,-1);t[r]=o}return t}function Ro(e){if(!jn(e))return{};try{return ul(Qs(e,"utf8"))}catch{return{}}}function Zs(e,t){let n=ti(),i=e;while(!0){for(let o of[At(i,".slack-term",".env.local"),At(i,".env.local")]){let a=Ro(o);for(let c of t)if(a[c])return a[c]}if(i===n)break;let r=ei(i);if(r===i)break;i=r}let s=Ro(At(n,".slack-term",".env.local"));for(let r of t)if(s[r])return s[r];return}function ni(){let e=sn(),t=Jt(Ln()),n=Jt(Wn()),i=t??n;return Object.entries(e.profiles).map(([s,r])=>({name:s,profile:r,current:s===i}))}function No(e){let t=sn();if(!(e in t.profiles))throw Error(`Profile not found: ${e}`);delete t.profiles[e],cl(t)}function vo(e,t=!1){let n=sn();if(!(e in n.profiles))throw Error(`Profile not found: ${e}`);if(t)Po(Wn(),e);else Po(Ln(),e)}function si(e){let n=sn().profiles,i=Object.keys(n);if(e){let u=n[e];if(!u)throw Error(`Workspace "${e}" not found. Available: ${i.join(", ")||"(none)"}`);return u.token}if(process.env.SLACK_TOKEN)return process.env.SLACK_TOKEN;let s=process.env.SLACK_BOT_TOKEN??process.env.SLACK_MCP_XOXP_TOKEN;if(s&&i.length===0)return s;if(s&&i.length>0){let u=Zs(process.cwd(),["SLACK_BOT_TOKEN","SLACK_MCP_XOXP_TOKEN"]);if(s!==u){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 r=Zs(process.cwd(),["SLACK_TOKEN"]);if(r)return r;let o=process.env.SLACK_WORKSPACE;if(o){let u=n[o];if(!u)throw Error(`Workspace "${o}" not found. Available: ${i.join(", ")||"(none)"}`);return u.token}let a=Jt(Ln());if(a){let u=n[a];if(!u)throw Error(`Workspace "${a}" (from .slack-cli/workspace) not found in profiles.`);return u.token}let c=Jt(Wn());if(c){let u=n[c];if(!u)throw Error(`Workspace "${c}" (from ~/.slack-cli/workspace) not found in profiles.`);return u.token}if(i.length>0)throw Error(`Workspace not selected (${i.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 Kt(){let e=process.env.SLACK_BOT_TOKEN;return e&&e.startsWith("xoxb-")?e:void 0}function No(e){let n=sn().profiles;if(e)return n[e]?.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(n).length===0)return process.env.SLACK_MCP_XOXD_COOKIE;let s=Xs(process.cwd(),["SLACK_COOKIE"]);if(s)return s;let r=process.env.SLACK_WORKSPACE;if(r)return n[r]?.cookie;let o=Jt(jn());if(o)return n[o]?.cookie;let a=Jt(Ln());if(a)return n[a]?.cookie;return}class Ge extends Error{retryAfter;constructor(e){super(`Slack rate limited — retry after ${e}s`);this.name="RateLimitError",this.retryAfter=e}}function ti(){return(process.env.SLACK_API_BASE??"https://slack.com/api").replace(/\/$/,"")}async function jo(e,t,n,i){let s={};if(i)s.Cookie=`d=${i}`;let r=await fetch(`${ti()}/${t}`,{...n,headers:{...n.headers??{},Authorization:`Bearer ${e}`,...s}});if(r.status===429){let a=parseInt(r.headers.get("retry-after")??"60",10);throw new Ge(isNaN(a)?60:a)}let o=await r.json();if(o.ok!==!0){let a=o.error??"unknown";if(a==="ratelimited")throw new Ge(60);if(a==="invalid_auth"&&e.startsWith("xoxc-")&&!i)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 Kt(){let e=process.env.SLACK_BOT_TOKEN;return e&&e.startsWith("xoxb-")?e:void 0}function jo(e){let n=sn().profiles;if(e)return n[e]?.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(n).length===0)return process.env.SLACK_MCP_XOXD_COOKIE;let s=Zs(process.cwd(),["SLACK_COOKIE"]);if(s)return s;let r=process.env.SLACK_WORKSPACE;if(r)return n[r]?.cookie;let o=Jt(Ln());if(o)return n[o]?.cookie;let a=Jt(Wn());if(a)return n[a]?.cookie;return}class Ve extends Error{retryAfter;constructor(e){super(`Slack rate limited — retry after ${e}s`);this.name="RateLimitError",this.retryAfter=e}}function ii(){return(process.env.SLACK_API_BASE??"https://slack.com/api").replace(/\/$/,"")}async function Wo(e,t,n,i){let s={};if(i)s.Cookie=`d=${i}`;let r=await fetch(`${ii()}/${t}`,{...n,headers:{...n.headers??{},Authorization:`Bearer ${e}`,...s}});if(r.status===429){let a=parseInt(r.headers.get("retry-after")??"60",10);throw new Ve(isNaN(a)?60:a)}let o=await r.json();if(o.ok!==!0){let a=o.error??"unknown";if(a==="ratelimited")throw new Ve(60);if(a==="invalid_auth"&&e.startsWith("xoxc-")&&!i)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
96
  slack auth token`);if((a==="missing_scope"||a==="cannot_dm_bot")&&e.startsWith("xoxb-"))throw Error(`Slack error on ${t}: ${a} — ${a==="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 ${t}: ${a}`)}return o}async function al(e,t,n,i){let s={};if(i)s.Cookie=`d=${i}`;let r=await fetch(`${ti()}/${t}`,{...n,headers:{...n.headers??{},Authorization:`Bearer ${e}`,...s}});if(r.status===429){let a=parseInt(r.headers.get("retry-after")??"60",10);throw new Ge(isNaN(a)?60:a)}let o=await r.json();if(o.ok!==!0){let a=o.error??"unknown";if(a==="ratelimited")throw new Ge(60);if((a==="invalid_auth"||a==="not_authed")&&!e.startsWith("xoxc-"))throw Error(`The draft API requires a desktop app session token (xoxc-).
99
+ Or import your Slack desktop session: slack auth login`);throw Error(`Slack error on ${t}: ${a}`)}return o}async function ll(e,t,n,i){let s={};if(i)s.Cookie=`d=${i}`;let r=await fetch(`${ii()}/${t}`,{...n,headers:{...n.headers??{},Authorization:`Bearer ${e}`,...s}});if(r.status===429){let a=parseInt(r.headers.get("retry-after")??"60",10);throw new Ve(isNaN(a)?60:a)}let o=await r.json();if(o.ok!==!0){let a=o.error??"unknown";if(a==="ratelimited")throw new Ve(60);if((a==="invalid_auth"||a==="not_authed")&&!e.startsWith("xoxc-"))throw Error(`The draft API requires a desktop app session token (xoxc-).
100
100
  Import from Slack desktop: slack auth login`);if((a==="invalid_auth"||a==="not_authed")&&!i)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 ${t}: ${a}`)}return o}function cl(e,t,n={},i){let s=new URLSearchParams({token:e,...n});return al(e,t,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s.toString()},i)}function we(e,t,n,i){let s=new URLSearchParams(n).toString();return jo(e,`${t}?${s}`,{method:"GET"},i)}function ni(e,t,n,i){return jo(e,t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)},i)}async function zt(e,t){let n=await we(e,"auth.test",{},t);return{team:n.team??"",teamId:n.team_id??"",url:n.url??"",user:n.user??"",userId:n.user_id??""}}async function Lo(e,t){let n={Authorization:`Bearer ${e}`};if(t)n.Cookie=`d=${t}`;let i=await fetch(`${ti()}/auth.test`,{method:"GET",headers:n});if(i.status===429){let o=parseInt(i.headers.get("retry-after")??"60",10);throw new Ge(isNaN(o)?60:o)}let s=i.headers.get("x-oauth-scopes")??"",r=await i.json();if(r.ok!==!0)throw Error(`Slack error on auth.test: ${r.error??"unknown"}`);return{userId:r.user_id??"",user:r.user??"",botId:r.bot_id??"",team:r.team??"",url:r.url??"",scopes:s.split(",").map((o)=>o.trim()).filter(Boolean)}}async function Wo(e,t,n){let i=await we(e,"bots.info",{bot:t},n);return{appId:i.bot?.app_id??"",userId:i.bot?.user_id??""}}async function on(e,t,n=20,i,s,r,o){let a={channel:t,limit:String(n)};if(i!==void 0)a.oldest=i;if(s!==void 0)a.cursor=s;if(o)a.inclusive="true";return we(e,"conversations.history",a,r)}async function Uo(e,t,n,i=50,s){return we(e,"conversations.replies",{channel:t,ts:n,limit:String(i)},s)}async function Wn(e,t,n,i,s){await ni(e,"reactions.add",{channel:t,timestamp:n,name:i},s)}async function Jo(e,t,n,i){return((await we(e,"reactions.get",{channel:t,timestamp:n,full:"true"},i)).message?.reactions??[]).map((r)=>({name:String(r.name??""),users:Array.isArray(r.users)?r.users.map(String):[]}))}async function Un(e,t,n,i,s){await ni(e,"reactions.remove",{channel:t,timestamp:n,name:i},s)}async function ul(e,t,n){let s=(await ni(e,"conversations.open",{users:t},n)).channel?.id;if(!s)throw Error(`Failed to open DM with user ${t}`);return s}function rn(e){return e.toLowerCase().replace(/[-_\s]/g,"")}function si(e){let t=e.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(!t)return;let n=t[1],i=t[2]&&t[3]?`${t[2]}.${t[3]}`:void 0,s=e.indexOf("?"),r=s>=0?new URLSearchParams(e.slice(s)):void 0,o=r?.get("thread_ts")??void 0,u={channel:r?.get("cid")??void 0??n};if(i)u.ts=i;if(o)u.threadTs=o;return u}function ll(e){return si(e)?.channel}function vo(e){return/^[CDG][A-Z0-9]{8,}$/.test(e)}async function Ko(e,t,n){let i=ll(t);if(i)return i;if(!t.startsWith("@")&&!t.startsWith("#")){if(vo(t))return t;throw Error(`Target must start with # or @ (or be a Slack URL/ID), got: ${t}`)}if(t.startsWith("#")&&vo(t.slice(1)))return t.slice(1);let s=t.startsWith("@"),r=t.slice(1),o=rn(r);if(s){let u=await we(e,"auth.test",{},n);if(o==="you"||o==="me"||rn(u.user??"")===o){let m=u.user_id;if(!m)throw Error("auth.test did not return user_id");let y=((await we(e,"conversations.list",{types:"im",limit:"200"},n)).channels??[]).find((E)=>E.user===m);if(y?.id)return String(y.id);return ul(e,m,n)}let l="",d="";while(!0){let m={limit:"200"};if(d)m.cursor=d;let p=await we(e,"users.list",m,n);for(let y of p.members??[]){let E=rn(y.name??""),F=rn(y.real_name??""),k=rn(y.profile?.display_name??"");if(E===o||F===o||k&&k===o){l=y.id??"";break}}if(l)break;if(d=p.response_metadata?.next_cursor??"",!d)break}if(!l)throw Error(`User not found: ${t}`);let h="";while(!0){let m={types:"im",limit:"200"};if(h)m.cursor=h;let p=await we(e,"conversations.list",m,n);for(let y of p.channels??[])if(y.user===l)return String(y.id??"");if(h=p.response_metadata?.next_cursor??"",!h)break}throw Error(`No existing DM with ${t} (${l}). Open it once in Slack first.`)}let a=r.toLowerCase(),c="";while(!0){let u={limit:"200",types:"public_channel,private_channel",exclude_archived:"true"};if(c)u.cursor=c;let f=await we(e,"conversations.list",u,n);for(let l of f.channels??[])if(String(l.name??"").toLowerCase()===a)return String(l.id??"");if(c=f.response_metadata?.next_cursor??"",!c)break}throw Error(`channel not found: ${t}`)}async function Jn(e,t,n){try{let i=await we(e,"users.info",{user:t},n),s=i.user?.profile?.display_name,r=s&&s.length>0?s:i.user?.real_name??i.user?.name??t,o=i.user?.name??t;return[r,o]}catch{return[t,t]}}async function Kn(e,t,n){try{let i=await we(e,"users.info",{user:t},n),s=i.user?.profile?.display_name;if(s&&s.length>0)return s;return i.user?.real_name??i.user?.name??t}catch{return t}}async function zn(e,t){let n=[],i="";while(!0){let s={limit:"200"};if(i)s.cursor=i;let r=await we(e,"users.list",s,t);if(n.push(...r.members??[]),i=r.response_metadata?.next_cursor??"",!i)break}return{members:n}}async function ii(e,t,n){let i=[],s="";while(!0){let r={channel:t,limit:"200"};if(s)r.cursor=s;let o=await we(e,"conversations.members",r,n);if(i.push(...o.members??[]),s=o.response_metadata?.next_cursor??"",!s)break}return i}async function ri(e,t,n){return we(e,"users.info",{user:t},n)}async function zo(e,t,n){return we(e,"conversations.info",{channel:t},n)}async function Ho(e,t){let n=await cl(e,"client.boot",{},t),i=typeof n.url==="string"?n.url:void 0;if(!i){let r=Object.keys(n).join(", ");throw Error(`client.boot did not return a WebSocket URL. Keys: ${r}`)}let s=n.self&&typeof n.self==="object"&&!Array.isArray(n.self)?n.self:{};return{wsUrl:i,selfId:typeof s.id==="string"?s.id:""}}var fl=["chat:write","im:write"],dl=["im:history","im:read"];async function oi(e){let{userId:t,botId:n,team:i,scopes:s}=await Lo(e),r="";if(n)try{r=(await Wo(e,n)).appId}catch{r=""}let o=(u)=>s.includes(u),a=fl.filter((u)=>!o(u)),c=dl.filter((u)=>!o(u));return{canSend:a.length===0,canReceiveReplies:c.length===0,ok:a.length===0&&c.length===0,botUserId:t,appId:r,team:i,grantedScopes:s,missingSendScopes:a,missingReplyScopes:c}}function qo(e){return["",` Bot user: ${e.botUserId||"(unknown)"}`,` App ID: ${e.appId||"(unknown — bots.info unavailable)"}`,` Granted scopes: ${e.grantedScopes.join(", ")||"(none reported)"}`]}function ai(e,t=!1){let n=e.appId?`https://api.slack.com/apps/${e.appId}`:"https://api.slack.com/apps";if(e.ok){let s=["✓ 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:',` ${n} → App Home → "Messages Tab" ON + "Allow users to send messages".`];return t?s:[...s,...qo(e)]}let i=[];if(!e.canSend)i.push(`⚠ This bot CANNOT send DMs — missing scope(s): ${e.missingSendScopes.join(", ")}.`);else i.push("⚠ This bot can send DMs, but the user's replies will NOT be readable.");return i.push(" Make escalation DMs two-way:"),i.push(` 1. ${n} → App Home → enable "Messages Tab" and check`),i.push(' "Allow users to send Slash commands and messages".'),i.push(` 2. OAuth & Permissions → add Bot Token Scopes: ${[...e.missingSendScopes,...e.missingReplyScopes].join(", ")}`),i.push(" 3. Reinstall the app to apply the new scopes."),t?i:[...i,...qo(e)]}import{createInterface as $t}from"node:readline/promises";import{join as hi}from"node:path";import{homedir as _l}from"node:os";import{existsSync as ci,readFileSync as ui,writeFileSync as Xo,mkdirSync as Go}from"node:fs";import{homedir as pl}from"node:os";import{join as li,dirname as Vo}from"node:path";function Zo(){return process.env.HOME||pl()}function Qo(){return li(Zo(),".config","slack-cli","profiles.json")}function hl(){return li(process.cwd(),".slack-cli","workspace")}function gl(){return li(Zo(),".slack-cli","workspace")}function fi(){let e=Qo();if(!ci(e))return{profiles:{}};return JSON.parse(ui(e,"utf8"))}function ea(e){let t=Qo();Go(Vo(t),{recursive:!0}),Xo(t,JSON.stringify(e,null,2)+`
102
- `)}function Yo(e){if(!ci(e))return;return ui(e,"utf8").trim()||void 0}function ta(e,t){Go(Vo(e),{recursive:!0});let n=ci(e)?ui(e,"utf8"):"",i=n?n.split(`
103
- `):[];for(let[s,r]of Object.entries(t)){let o=i.findIndex((c)=>{let u=c.trim();return u.startsWith(s+"=")||u.startsWith(s+" =")}),a=`${s}=${r}`;if(o!==-1)i[o]=a;else i.push(a)}Xo(e,i.join(`
101
+ Attach it with: slack auth chrome (macOS) or slack auth firefox`);throw Error(`Slack error on ${t}: ${a}`)}return o}function fl(e,t,n={},i){let s=new URLSearchParams({token:e,...n});return ll(e,t,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s.toString()},i)}function be(e,t,n,i){let s=new URLSearchParams(n).toString();return Wo(e,`${t}?${s}`,{method:"GET"},i)}function ri(e,t,n,i){return Wo(e,t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)},i)}async function zt(e,t){let n=await be(e,"auth.test",{},t);return{team:n.team??"",teamId:n.team_id??"",url:n.url??"",user:n.user??"",userId:n.user_id??""}}async function Uo(e,t){let n={Authorization:`Bearer ${e}`};if(t)n.Cookie=`d=${t}`;let i=await fetch(`${ii()}/auth.test`,{method:"GET",headers:n});if(i.status===429){let o=parseInt(i.headers.get("retry-after")??"60",10);throw new Ve(isNaN(o)?60:o)}let s=i.headers.get("x-oauth-scopes")??"",r=await i.json();if(r.ok!==!0)throw Error(`Slack error on auth.test: ${r.error??"unknown"}`);return{userId:r.user_id??"",user:r.user??"",botId:r.bot_id??"",team:r.team??"",url:r.url??"",scopes:s.split(",").map((o)=>o.trim()).filter(Boolean)}}async function Jo(e,t,n){let i=await be(e,"bots.info",{bot:t},n);return{appId:i.bot?.app_id??"",userId:i.bot?.user_id??""}}async function on(e,t,n=20,i,s,r,o){let a={channel:t,limit:String(n)};if(i!==void 0)a.oldest=i;if(s!==void 0)a.cursor=s;if(o)a.inclusive="true";return be(e,"conversations.history",a,r)}async function Ko(e,t,n,i=50,s){return be(e,"conversations.replies",{channel:t,ts:n,limit:String(i)},s)}async function Un(e,t,n,i,s){await ri(e,"reactions.add",{channel:t,timestamp:n,name:i},s)}async function zo(e,t,n,i){return((await be(e,"reactions.get",{channel:t,timestamp:n,full:"true"},i)).message?.reactions??[]).map((r)=>({name:String(r.name??""),users:Array.isArray(r.users)?r.users.map(String):[]}))}async function Jn(e,t,n,i,s){await ri(e,"reactions.remove",{channel:t,timestamp:n,name:i},s)}async function dl(e,t,n){let s=(await ri(e,"conversations.open",{users:t},n)).channel?.id;if(!s)throw Error(`Failed to open DM with user ${t}`);return s}function rn(e){return e.toLowerCase().replace(/[-_\s]/g,"")}function oi(e){let t=e.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(!t)return;let n=t[1],i=t[2]&&t[3]?`${t[2]}.${t[3]}`:void 0,s=e.indexOf("?"),r=s>=0?new URLSearchParams(e.slice(s)):void 0,o=r?.get("thread_ts")??void 0,u={channel:r?.get("cid")??void 0??n};if(i)u.ts=i;if(o)u.threadTs=o;return u}function pl(e){return oi(e)?.channel}function Lo(e){return/^[CDG][A-Z0-9]{8,}$/.test(e)}async function Ho(e,t,n){let i=pl(t);if(i)return i;if(!t.startsWith("@")&&!t.startsWith("#")){if(Lo(t))return t;throw Error(`Target must start with # or @ (or be a Slack URL/ID), got: ${t}`)}if(t.startsWith("#")&&Lo(t.slice(1)))return t.slice(1);let s=t.startsWith("@"),r=t.slice(1),o=rn(r);if(s){let u=await be(e,"auth.test",{},n);if(o==="you"||o==="me"||rn(u.user??"")===o){let m=u.user_id;if(!m)throw Error("auth.test did not return user_id");let y=((await be(e,"conversations.list",{types:"im",limit:"200"},n)).channels??[]).find((C)=>C.user===m);if(y?.id)return String(y.id);return dl(e,m,n)}let l="",d="";while(!0){let m={limit:"200"};if(d)m.cursor=d;let p=await be(e,"users.list",m,n);for(let y of p.members??[]){let C=rn(y.name??""),F=rn(y.real_name??""),k=rn(y.profile?.display_name??"");if(C===o||F===o||k&&k===o){l=y.id??"";break}}if(l)break;if(d=p.response_metadata?.next_cursor??"",!d)break}if(!l)throw Error(`User not found: ${t}`);let h="";while(!0){let m={types:"im",limit:"200"};if(h)m.cursor=h;let p=await be(e,"conversations.list",m,n);for(let y of p.channels??[])if(y.user===l)return String(y.id??"");if(h=p.response_metadata?.next_cursor??"",!h)break}throw Error(`No existing DM with ${t} (${l}). Open it once in Slack first.`)}let a=r.toLowerCase(),c="";while(!0){let u={limit:"200",types:"public_channel,private_channel",exclude_archived:"true"};if(c)u.cursor=c;let f=await be(e,"conversations.list",u,n);for(let l of f.channels??[])if(String(l.name??"").toLowerCase()===a)return String(l.id??"");if(c=f.response_metadata?.next_cursor??"",!c)break}throw Error(`channel not found: ${t}`)}async function Kn(e,t,n){try{let i=await be(e,"users.info",{user:t},n),s=i.user?.profile?.display_name,r=s&&s.length>0?s:i.user?.real_name??i.user?.name??t,o=i.user?.name??t;return[r,o]}catch{return[t,t]}}async function zn(e,t,n){try{let i=await be(e,"users.info",{user:t},n),s=i.user?.profile?.display_name;if(s&&s.length>0)return s;return i.user?.real_name??i.user?.name??t}catch{return t}}async function Hn(e,t){let n=[],i="";while(!0){let s={limit:"200"};if(i)s.cursor=i;let r=await be(e,"users.list",s,t);if(n.push(...r.members??[]),i=r.response_metadata?.next_cursor??"",!i)break}return{members:n}}async function ai(e,t,n){let i=[],s="";while(!0){let r={channel:t,limit:"200"};if(s)r.cursor=s;let o=await be(e,"conversations.members",r,n);if(i.push(...o.members??[]),s=o.response_metadata?.next_cursor??"",!s)break}return i}async function ci(e,t,n){return be(e,"users.info",{user:t},n)}async function qo(e,t,n){return be(e,"conversations.info",{channel:t},n)}async function Yo(e,t){let n=await fl(e,"client.boot",{},t),i=typeof n.url==="string"?n.url:void 0;if(!i){let r=Object.keys(n).join(", ");throw Error(`client.boot did not return a WebSocket URL. Keys: ${r}`)}let s=n.self&&typeof n.self==="object"&&!Array.isArray(n.self)?n.self:{};return{wsUrl:i,selfId:typeof s.id==="string"?s.id:""}}var hl=["chat:write","im:write"],gl=["im:history","im:read"];async function ui(e){let{userId:t,botId:n,team:i,scopes:s}=await Uo(e),r="";if(n)try{r=(await Jo(e,n)).appId}catch{r=""}let o=(u)=>s.includes(u),a=hl.filter((u)=>!o(u)),c=gl.filter((u)=>!o(u));return{canSend:a.length===0,canReceiveReplies:c.length===0,ok:a.length===0&&c.length===0,botUserId:t,appId:r,team:i,grantedScopes:s,missingSendScopes:a,missingReplyScopes:c}}function Xo(e){return["",` Bot user: ${e.botUserId||"(unknown)"}`,` App ID: ${e.appId||"(unknown — bots.info unavailable)"}`,` Granted scopes: ${e.grantedScopes.join(", ")||"(none reported)"}`]}function li(e,t=!1){let n=e.appId?`https://api.slack.com/apps/${e.appId}`:"https://api.slack.com/apps";if(e.ok){let s=["✓ 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:',` ${n} → App Home → "Messages Tab" ON + "Allow users to send messages".`];return t?s:[...s,...Xo(e)]}let i=[];if(!e.canSend)i.push(`⚠ This bot CANNOT send DMs — missing scope(s): ${e.missingSendScopes.join(", ")}.`);else i.push("⚠ This bot can send DMs, but the user's replies will NOT be readable.");return i.push(" Make escalation DMs two-way:"),i.push(` 1. ${n} → App Home → enable "Messages Tab" and check`),i.push(' "Allow users to send Slash commands and messages".'),i.push(` 2. OAuth & Permissions → add Bot Token Scopes: ${[...e.missingSendScopes,...e.missingReplyScopes].join(", ")}`),i.push(" 3. Reinstall the app to apply the new scopes."),t?i:[...i,...Xo(e)]}import{createInterface as Ot}from"node:readline/promises";import{join as Di}from"node:path";import{homedir as Al}from"node:os";import{existsSync as fi,readFileSync as di,writeFileSync as Vo,mkdirSync as Zo}from"node:fs";import{homedir as ml}from"node:os";import{join as pi,dirname as Qo}from"node:path";function ea(){return process.env.HOME||ml()}function ta(){return pi(ea(),".config","slack-cli","profiles.json")}function Dl(){return pi(process.cwd(),".slack-cli","workspace")}function yl(){return pi(ea(),".slack-cli","workspace")}function hi(){let e=ta();if(!fi(e))return{profiles:{}};return JSON.parse(di(e,"utf8"))}function na(e){let t=ta();Zo(Qo(t),{recursive:!0}),Vo(t,JSON.stringify(e,null,2)+`
102
+ `)}function Go(e){if(!fi(e))return;return di(e,"utf8").trim()||void 0}function sa(e,t){Zo(Qo(e),{recursive:!0});let n=fi(e)?di(e,"utf8"):"",i=n?n.split(`
103
+ `):[];for(let[s,r]of Object.entries(t)){let o=i.findIndex((c)=>{let u=c.trim();return u.startsWith(s+"=")||u.startsWith(s+" =")}),a=`${s}=${r}`;if(o!==-1)i[o]=a;else i.push(a)}Vo(e,i.join(`
104
104
  `).trimEnd()+`
105
- `)}function Hn(){let e=fi(),t=Yo(hl()),n=Yo(gl()),i=t??n;return Object.entries(e.profiles).map(([s,r])=>({name:s,profile:r,current:s===i}))}function di(e,t){let n=fi();n.profiles[e]=t,ea(n)}function pi(e,t){let n=fi();if(!(e in n.profiles))throw Error(`Profile not found: ${e}`);n.profiles[e].cookie=t,ea(n)}import{readdirSync as qn,readFileSync as an,existsSync as At,copyFileSync as na,unlinkSync as sa}from"node:fs";import{homedir as Yn,tmpdir as ia}from"node:os";import{join as he,dirname as ml}from"node:path";import{pbkdf2Sync as ra,createDecipheriv as oa}from"node:crypto";import{execSync as aa}from"node:child_process";function Dl(){let e=Yn();if(process.platform==="darwin")return he(e,"Library","Application Support","Slack","Local Storage","leveldb");if(process.platform==="linux")return he(e,".config","Slack","Local Storage","leveldb");if(process.platform==="win32"){let t=process.env.APPDATA??he(e,"AppData","Roaming");return he(t,"Slack","Local Storage","leveldb")}throw Error(`Unsupported platform: ${process.platform}`)}function yl(){let e=Yn();if(process.platform==="darwin")return he(e,"Library","Application Support","Slack","Cookies");return""}function wl(e,t){if(e.length<35||e.slice(0,3).toString()!=="v10")throw Error("Not a v10 encrypted cookie");let n=e.slice(19,35),i=e.slice(35),s=oa("aes-128-cbc",t,n);return s.setAutoPadding(!0),Buffer.concat([s.update(i),s.final()]).toString("utf8")}function bl(){if(process.platform!=="darwin")return;let e=yl();if(!At(e))return;let t;try{t=aa('security find-generic-password -w -s "Slack Safe Storage" -a "Slack Key"',{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trimEnd()}catch{return}let n=ra(t,"saltysalt",1003,16,"sha1");try{let{default:i}=qe("bun:sqlite"),s=new i(e,{readonly:!0}),r=s.prepare("SELECT encrypted_value FROM cookies WHERE name='d' AND host_key LIKE '%slack%'").get();if(s.close(),!r)return;return wl(Buffer.from(r.encrypted_value),n)}catch{return}}async function ca(){let e=Dl();if(!At(e))throw Error(`Slack desktop app LevelDB not found at:
105
+ `)}function qn(){let e=hi(),t=Go(Dl()),n=Go(yl()),i=t??n;return Object.entries(e.profiles).map(([s,r])=>({name:s,profile:r,current:s===i}))}function gi(e,t){let n=hi();n.profiles[e]=t,na(n)}function mi(e,t){let n=hi();if(!(e in n.profiles))throw Error(`Profile not found: ${e}`);n.profiles[e].cookie=t,na(n)}import{readdirSync as Yn,readFileSync as an,existsSync as $t,copyFileSync as ia,unlinkSync as ra}from"node:fs";import{homedir as Xn,tmpdir as oa}from"node:os";import{join as he,dirname as wl}from"node:path";import{pbkdf2Sync as aa,createDecipheriv as ca}from"node:crypto";import{execSync as ua}from"node:child_process";function bl(){let e=Xn();if(process.platform==="darwin")return he(e,"Library","Application Support","Slack","Local Storage","leveldb");if(process.platform==="linux")return he(e,".config","Slack","Local Storage","leveldb");if(process.platform==="win32"){let t=process.env.APPDATA??he(e,"AppData","Roaming");return he(t,"Slack","Local Storage","leveldb")}throw Error(`Unsupported platform: ${process.platform}`)}function Fl(){let e=Xn();if(process.platform==="darwin")return he(e,"Library","Application Support","Slack","Cookies");return""}function Cl(e,t){if(e.length<35||e.slice(0,3).toString()!=="v10")throw Error("Not a v10 encrypted cookie");let n=e.slice(19,35),i=e.slice(35),s=ca("aes-128-cbc",t,n);return s.setAutoPadding(!0),Buffer.concat([s.update(i),s.final()]).toString("utf8")}function El(){if(process.platform!=="darwin")return;let e=Fl();if(!$t(e))return;let t;try{t=ua('security find-generic-password -w -s "Slack Safe Storage" -a "Slack Key"',{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trimEnd()}catch{return}let n=aa(t,"saltysalt",1003,16,"sha1");try{let{default:i}=Ye("bun:sqlite"),s=new i(e,{readonly:!0}),r=s.prepare("SELECT encrypted_value FROM cookies WHERE name='d' AND host_key LIKE '%slack%'").get();if(s.close(),!r)return;return Cl(Buffer.from(r.encrypted_value),n)}catch{return}}async function la(){let e=bl();if(!$t(e))throw Error(`Slack desktop app LevelDB not found at:
106
106
  ${e}
107
- Is Slack installed and opened at least once?`);let t=qn(e).filter((a)=>a.endsWith(".ldb")||a.endsWith(".log"));if(t.length===0)throw Error(`No LevelDB data files found in ${e}`);let n=new Map;for(let a of t){let c;try{c=an(he(e,a),"latin1")}catch{continue}if(a.endsWith(".log"))for(let u of c.matchAll(/"token":"(xoxc-[^"]+)"/g)){let f=u[1],l=f.split("-")[1]??"";if(!l||f.length<40)continue;let d=Math.max(0,u.index-2000),h=Math.min(c.length,u.index+2000),m=c.slice(d,h),p=m.match(/"url":"(https:\/\/[a-z0-9-]+\.slack\.com\/)"/),y=m.match(/"(?:team_name|name)":"([^"]{2,60})"/),E=n.get(l);if(!E||f.length>E.token.length){let F={token:f,teamId:l},k=p?.[1]??E?.url,C=y?.[1]??E?.teamName;if(k)F.url=k;if(C)F.teamName=C;n.set(l,F)}}else for(let u of c.matchAll(/xoxc-(\d+)-(\d+)-(\d+)/g)){let f=u[1];if(n.has(f))continue;let l=u.index+u[0].length,d=Math.min(l+10,c.length);while(l<d&&(c.charCodeAt(l)<48||c.charCodeAt(l)>57))l++;let h="";while(l<c.length&&c.charCodeAt(l)>=48&&c.charCodeAt(l)<=57)h+=c[l++];if(c[l]!=="-")continue;l++;let m="";while(l<c.length){let y=c.charCodeAt(l);if(y>=48&&y<=57||y>=97&&y<=102)m+=c[l++];else break}if(m.length<20)continue;let p=`${u[0]}${h}-${m}`;n.set(f,{token:p,teamId:f})}}let s=qn(e).filter((a)=>a.endsWith(".ldb")||a.endsWith(".log")).map((a)=>{try{return an(he(e,a),"latin1").replace(/[^\x20-\x7e]/g," ")}catch{return""}}).join(" ");for(let a of n.values()){if(a.teamName)continue;let c=s.indexOf(a.teamId);if(c!==-1){let u=Math.max(0,c-500),f=Math.min(s.length,c+500),d=s.slice(u,f).match(/"(?:team_name|name)":"([^"]{2,60})"/);if(d?.[1]){a.teamName=d[1];continue}}if(!a.teamName&&a.url){let u=a.url.match(/https:\/\/([a-z0-9-]+)\.slack\.com\//)?.[1];if(u){let f=s.indexOf(u);if(f!==-1){let l=Math.max(0,f-500),d=Math.min(s.length,f+500),m=s.slice(l,d).match(/"(?:team_name|name)":"([^"]{2,60})"/);if(m?.[1]){a.teamName=m[1];continue}}a.teamName=u.split("-").map((l)=>l.charAt(0).toUpperCase()+l.slice(1)).join(" ")}}}let r=bl(),o=[...n.values()];if(r)for(let a of o)a.cookie=r;return o}function Fl(e,t){let n=(i,s)=>{try{let r=oa("aes-128-cbc",t,i);r.setAutoPadding(!0);let o=Buffer.concat([r.update(s),r.final()]).toString("utf8");return o.startsWith("xoxd-")?o:void 0}catch{return}};return n(Buffer.alloc(16,32),e.slice(3))??(e.length>=35?n(e.slice(19,35),e.slice(35)):void 0)}function Cl(e,t){let n=(i,s)=>{if(i&&s)return`${i} (${s})`;return i||s||t};try{let s=JSON.parse(an(he(e,"Local State"),"utf8")).profile?.info_cache?.[t];if(s&&(s.name||s.user_name))return n(s.name??"",s.user_name??"")}catch{}try{let s=JSON.parse(an(he(e,t,"Preferences"),"utf8")).profile;return n(s?.name??"",s?.user_name??"")}catch{return t}}function ua(){if(process.platform!=="darwin")return{candidates:[],totalProfiles:0};let e=he(Yn(),"Library","Application Support","Google","Chrome");if(!At(e))return{candidates:[],totalProfiles:0};let t;try{t=aa('security find-generic-password -a Chrome -s "Chrome Safe Storage" -w',{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trimEnd()}catch{return{candidates:[],totalProfiles:0}}if(!t)return{candidates:[],totalProfiles:0};let n=ra(t,"saltysalt",1003,16,"sha1"),i=["Default",...qn(e).filter((r)=>r.startsWith("Profile "))],s=[];for(let r of i){let o=he(e,r,"Cookies");if(!At(o))continue;let a=he(ia(),`slack-chrome-cookies-${Date.now()}-${r}.db`);try{na(o,a);let{default:c}=qe("bun:sqlite"),u=new c(a,{readonly:!0}),f=u.prepare("SELECT encrypted_value FROM cookies WHERE name='d' AND host_key LIKE '%slack%'").get();if(u.close(),!f)continue;let l=Buffer.from(f.encrypted_value),d=l.slice(0,3).toString();if(d==="v10"){let h=Fl(l,n);if(!h)continue;s.push({profileDir:r,profileName:Cl(e,r),cookie:h})}else if(d==="v20")throw Error(`Chrome cookie uses v20 (app-bound AES-256-GCM) which is not supported yet. Prefix found: ${l.slice(0,4).toString("hex")}`);else throw Error(`Unknown cookie encryption prefix: ${l.slice(0,4).toString("hex")}`)}catch(c){if(c instanceof Error&&(c.message.includes("app-bound")||c.message.includes("Unknown cookie")))throw c}finally{try{sa(a)}catch{}}}return{candidates:s,totalProfiles:i.length}}function El(){let e=Yn();if(process.platform==="darwin")return he(e,"Library","Application Support","Firefox","Profiles");if(process.platform==="linux")return he(e,".mozilla","firefox");if(process.platform==="win32")return he(process.env.APPDATA??he(e,"AppData","Roaming"),"Mozilla","Firefox","Profiles");return""}function xl(e){let t=he(ml(e),"profiles.ini"),n={};if(!At(t))return n;try{let i=an(t,"utf8"),s="",r="";for(let o of i.split(`
108
- `)){let a=o.trim();if(a.startsWith("[")){s="",r="";continue}let c=a.indexOf("=");if(c===-1)continue;let u=a.slice(0,c).trim().toLowerCase(),f=a.slice(c+1).trim();if(u==="name")s=f;if(u==="path")r=f.split(/[\\/]/).pop()??f;if(s&&r)n[r]=s,s="",r=""}}catch{}return n}function la(){let e=El();if(!e||!At(e))return[];let t=xl(e),n=[],i;try{i=qn(e)}catch{return[]}for(let s of i){let r=he(e,s,"cookies.sqlite");if(!At(r))continue;let o=he(ia(),`slack-firefox-cookies-${Date.now()}-${s}.db`);try{na(r,o);let{default:a}=qe("bun:sqlite"),c=new a(o,{readonly:!0}),u=c.prepare("SELECT value FROM moz_cookies WHERE name='d' AND host LIKE '%slack%' LIMIT 1").get();if(c.close(),!u?.value||!u.value.startsWith("xoxd-"))continue;let f=t[s]??s;n.push({profileDir:s,profileName:f,cookie:u.value})}catch{}finally{try{sa(o)}catch{}}}return n}var Sl=["search:read","channels:history","groups:history","im:history","mpim:history","channels:read","groups:read","im:read","mpim:read","users:read","chat:write","files:write"],kl=["channels:history","groups:history","im:history","mpim:history","channels:read","groups:read","im:read","mpim:read","users:read","chat:write","files:write"];function Xn(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function Al(){return JSON.stringify({display_information:{name:"slack-term"},oauth_config:{scopes:{user:Sl}},settings:{org_deploy_enabled:!1,socket_mode_enabled:!1,token_rotation_enabled:!1}},null,2)}function $l(){return JSON.stringify({display_information:{name:"slack-term"},features:{bot_user:{display_name:"slack-term",always_online:!1}},oauth_config:{scopes:{bot:kl}},settings:{org_deploy_enabled:!1,socket_mode_enabled:!1,token_rotation_enabled:!1}},null,2)}async function Ot(e,t){return(await e.question(t)).trim()}async function It(e,t,n,i){console.error("Verifying token...");let s=await zt(t),r=Xn(s.team),o;if(n)o=n;else if(e)o=await Ot(e,`Workspace name [${r}]: `)||r;else o=r;let a=null;if(e){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 c=await Ot(e,"Choice [1/2/3/4, Enter=1]: ");if(c==="2")a=hi(process.cwd(),".slack-term",".env.local");else if(c==="3")a=hi(_l(),".slack-term",".env.local");else if(c==="4")a=null;else a=hi(process.cwd(),".env.local")}if(a===null)if(di(o,{token:t,...s,...i?{cookie:i}:{}}),console.log(`Saved workspace "${o}" to profiles.json: ${s.team} (${s.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 ${o}`);else{let c={SLACK_TOKEN:t};if(i)c.SLACK_COOKIE=i;ta(a,c),console.log(`Saved token to ${a}`),console.log(" SLACK_TOKEN will be picked up automatically in this directory tree.")}return o}async function Ol(e){console.error("Scanning Slack desktop app...");let t=await ca();if(t.length===0)console.error("No sessions found. Make sure Slack is installed and you have signed in at least once."),process.exit(1);if(t.length===1&&e){let n=t[0],i=n.teamName??n.teamId;console.log(`Found workspace: ${i}${n.cookie?" (+ xoxd cookie)":""}`),await It(e,n.token,Xn(i),n.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 n of t){let i=n.teamName??n.teamId,s=Xn(i);di(s,{token:n.token,team:i,teamId:n.teamId,url:n.url??"",user:"",...n.cookie?{cookie:n.cookie}:{}}),console.log(`Added workspace "${s}": ${i}${n.cookie?" + xoxd cookie":""}`)}if(console.log(""),t.length===1){let n=Xn(t[0].teamName??t[0].teamId);console.log(`Run: slack auth use -g ${n}`)}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 fa(e){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 n=await Ot(e,"Choice [1/2]: ")==="2"?"bot":"user",i=n==="user"?"xoxp-":"xoxb-",s=n==="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 "${s}" (starts with ${i})`),console.log("");let r=await Ot(e,"Paste your token: ");if(!r)console.error("No token provided."),process.exit(1);if(!r.startsWith(i))console.error(`Expected a ${i} token, got: ${r.slice(0,10)}...`),process.exit(1);await It(e,r)}async function Gn(e,t){let n=t==="user"?Al():$l(),i=t==="user"?"User OAuth Token (xoxp-...)":"Bot User OAuth Token (xoxb-...)",s=t==="user"?"xoxp-":"xoxb-";if(t==="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(n),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 -> ${i}`),console.log("");let r=await Ot(e,"Paste your token: ");if(!r)console.error("No token provided."),process.exit(1);if(!r.startsWith(s))console.error(`Expected a ${s} token, got: ${r.slice(0,10)}...`),process.exit(1);await It(e,r)}async function da(e={}){if(process.platform!=="darwin")console.error("Chrome cookie extraction is only supported on macOS."),process.exit(1);let t=Hn();if(t.length===0)console.error("No workspaces configured. Run: slack auth login"),process.exit(1);let n;if(e.workspace){if(!t.find((c)=>c.name===e.workspace))console.error(`Workspace "${e.workspace}" not found. Available: ${t.map((c)=>c.name).join(", ")}`),process.exit(1);n=e.workspace}else if(t.length===1)n=t[0].name;else{let a=t.find((c)=>c.current);if(a)n=a.name,console.log(`Using active workspace: ${n}`);else{console.log("Multiple workspaces found. Choose one:"),t.forEach((l,d)=>console.log(` ${d+1}) ${l.name} (${l.profile.team})`));let c=$t({input:process.stdin,output:process.stdout}),u=(await c.question("Choice: ")).trim();c.close();let f=parseInt(u,10)-1;if(isNaN(f)||f<0||f>=t.length)console.error("Invalid choice."),process.exit(1);n=t[f].name}}if(t.find((a)=>a.name===n).profile.token.startsWith("xoxb-")){console.error(`
107
+ Is Slack installed and opened at least once?`);let t=Yn(e).filter((a)=>a.endsWith(".ldb")||a.endsWith(".log"));if(t.length===0)throw Error(`No LevelDB data files found in ${e}`);let n=new Map;for(let a of t){let c;try{c=an(he(e,a),"latin1")}catch{continue}if(a.endsWith(".log"))for(let u of c.matchAll(/"token":"(xoxc-[^"]+)"/g)){let f=u[1],l=f.split("-")[1]??"";if(!l||f.length<40)continue;let d=Math.max(0,u.index-2000),h=Math.min(c.length,u.index+2000),m=c.slice(d,h),p=m.match(/"url":"(https:\/\/[a-z0-9-]+\.slack\.com\/)"/),y=m.match(/"(?:team_name|name)":"([^"]{2,60})"/),C=n.get(l);if(!C||f.length>C.token.length){let F={token:f,teamId:l},k=p?.[1]??C?.url,S=y?.[1]??C?.teamName;if(k)F.url=k;if(S)F.teamName=S;n.set(l,F)}}else for(let u of c.matchAll(/xoxc-(\d+)-(\d+)-(\d+)/g)){let f=u[1];if(n.has(f))continue;let l=u.index+u[0].length,d=Math.min(l+10,c.length);while(l<d&&(c.charCodeAt(l)<48||c.charCodeAt(l)>57))l++;let h="";while(l<c.length&&c.charCodeAt(l)>=48&&c.charCodeAt(l)<=57)h+=c[l++];if(c[l]!=="-")continue;l++;let m="";while(l<c.length){let y=c.charCodeAt(l);if(y>=48&&y<=57||y>=97&&y<=102)m+=c[l++];else break}if(m.length<20)continue;let p=`${u[0]}${h}-${m}`;n.set(f,{token:p,teamId:f})}}let s=Yn(e).filter((a)=>a.endsWith(".ldb")||a.endsWith(".log")).map((a)=>{try{return an(he(e,a),"latin1").replace(/[^\x20-\x7e]/g," ")}catch{return""}}).join(" ");for(let a of n.values()){if(a.teamName)continue;let c=s.indexOf(a.teamId);if(c!==-1){let u=Math.max(0,c-500),f=Math.min(s.length,c+500),d=s.slice(u,f).match(/"(?:team_name|name)":"([^"]{2,60})"/);if(d?.[1]){a.teamName=d[1];continue}}if(!a.teamName&&a.url){let u=a.url.match(/https:\/\/([a-z0-9-]+)\.slack\.com\//)?.[1];if(u){let f=s.indexOf(u);if(f!==-1){let l=Math.max(0,f-500),d=Math.min(s.length,f+500),m=s.slice(l,d).match(/"(?:team_name|name)":"([^"]{2,60})"/);if(m?.[1]){a.teamName=m[1];continue}}a.teamName=u.split("-").map((l)=>l.charAt(0).toUpperCase()+l.slice(1)).join(" ")}}}let r=El(),o=[...n.values()];if(r)for(let a of o)a.cookie=r;return o}function xl(e,t){let n=(i,s)=>{try{let r=ca("aes-128-cbc",t,i);r.setAutoPadding(!0);let o=Buffer.concat([r.update(s),r.final()]).toString("utf8");return o.startsWith("xoxd-")?o:void 0}catch{return}};return n(Buffer.alloc(16,32),e.slice(3))??(e.length>=35?n(e.slice(19,35),e.slice(35)):void 0)}function _l(e,t){let n=(i,s)=>{if(i&&s)return`${i} (${s})`;return i||s||t};try{let s=JSON.parse(an(he(e,"Local State"),"utf8")).profile?.info_cache?.[t];if(s&&(s.name||s.user_name))return n(s.name??"",s.user_name??"")}catch{}try{let s=JSON.parse(an(he(e,t,"Preferences"),"utf8")).profile;return n(s?.name??"",s?.user_name??"")}catch{return t}}function fa(){if(process.platform!=="darwin")return{candidates:[],totalProfiles:0};let e=he(Xn(),"Library","Application Support","Google","Chrome");if(!$t(e))return{candidates:[],totalProfiles:0};let t;try{t=ua('security find-generic-password -a Chrome -s "Chrome Safe Storage" -w',{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trimEnd()}catch{return{candidates:[],totalProfiles:0}}if(!t)return{candidates:[],totalProfiles:0};let n=aa(t,"saltysalt",1003,16,"sha1"),i=["Default",...Yn(e).filter((r)=>r.startsWith("Profile "))],s=[];for(let r of i){let o=he(e,r,"Cookies");if(!$t(o))continue;let a=he(oa(),`slack-chrome-cookies-${Date.now()}-${r}.db`);try{ia(o,a);let{default:c}=Ye("bun:sqlite"),u=new c(a,{readonly:!0}),f=u.prepare("SELECT encrypted_value FROM cookies WHERE name='d' AND host_key LIKE '%slack%'").get();if(u.close(),!f)continue;let l=Buffer.from(f.encrypted_value),d=l.slice(0,3).toString();if(d==="v10"){let h=xl(l,n);if(!h)continue;s.push({profileDir:r,profileName:_l(e,r),cookie:h})}else if(d==="v20")throw Error(`Chrome cookie uses v20 (app-bound AES-256-GCM) which is not supported yet. Prefix found: ${l.slice(0,4).toString("hex")}`);else throw Error(`Unknown cookie encryption prefix: ${l.slice(0,4).toString("hex")}`)}catch(c){if(c instanceof Error&&(c.message.includes("app-bound")||c.message.includes("Unknown cookie")))throw c}finally{try{ra(a)}catch{}}}return{candidates:s,totalProfiles:i.length}}function Sl(){let e=Xn();if(process.platform==="darwin")return he(e,"Library","Application Support","Firefox","Profiles");if(process.platform==="linux")return he(e,".mozilla","firefox");if(process.platform==="win32")return he(process.env.APPDATA??he(e,"AppData","Roaming"),"Mozilla","Firefox","Profiles");return""}function kl(e){let t=he(wl(e),"profiles.ini"),n={};if(!$t(t))return n;try{let i=an(t,"utf8"),s="",r="";for(let o of i.split(`
108
+ `)){let a=o.trim();if(a.startsWith("[")){s="",r="";continue}let c=a.indexOf("=");if(c===-1)continue;let u=a.slice(0,c).trim().toLowerCase(),f=a.slice(c+1).trim();if(u==="name")s=f;if(u==="path")r=f.split(/[\\/]/).pop()??f;if(s&&r)n[r]=s,s="",r=""}}catch{}return n}function da(){let e=Sl();if(!e||!$t(e))return[];let t=kl(e),n=[],i;try{i=Yn(e)}catch{return[]}for(let s of i){let r=he(e,s,"cookies.sqlite");if(!$t(r))continue;let o=he(oa(),`slack-firefox-cookies-${Date.now()}-${s}.db`);try{ia(r,o);let{default:a}=Ye("bun:sqlite"),c=new a(o,{readonly:!0}),u=c.prepare("SELECT value FROM moz_cookies WHERE name='d' AND host LIKE '%slack%' LIMIT 1").get();if(c.close(),!u?.value||!u.value.startsWith("xoxd-"))continue;let f=t[s]??s;n.push({profileDir:s,profileName:f,cookie:u.value})}catch{}finally{try{ra(o)}catch{}}}return n}var $l=["search:read","channels:history","groups:history","im:history","mpim:history","channels:read","groups:read","im:read","mpim:read","users:read","chat:write","files:write"],Ol=["channels:history","groups:history","im:history","mpim:history","channels:read","groups:read","im:read","mpim:read","users:read","chat:write","files:write"];function Gn(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function Il(){return JSON.stringify({display_information:{name:"slack-term"},oauth_config:{scopes:{user:$l}},settings:{org_deploy_enabled:!1,socket_mode_enabled:!1,token_rotation_enabled:!1}},null,2)}function Tl(){return JSON.stringify({display_information:{name:"slack-term"},features:{bot_user:{display_name:"slack-term",always_online:!1}},oauth_config:{scopes:{bot:Ol}},settings:{org_deploy_enabled:!1,socket_mode_enabled:!1,token_rotation_enabled:!1}},null,2)}async function It(e,t){return(await e.question(t)).trim()}async function Tt(e,t,n,i){console.error("Verifying token...");let s=await zt(t),r=Gn(s.team),o;if(n)o=n;else if(e)o=await It(e,`Workspace name [${r}]: `)||r;else o=r;let a=null;if(e){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 c=await It(e,"Choice [1/2/3/4, Enter=1]: ");if(c==="2")a=Di(process.cwd(),".slack-term",".env.local");else if(c==="3")a=Di(Al(),".slack-term",".env.local");else if(c==="4")a=null;else a=Di(process.cwd(),".env.local")}if(a===null)if(gi(o,{token:t,...s,...i?{cookie:i}:{}}),console.log(`Saved workspace "${o}" to profiles.json: ${s.team} (${s.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 ${o}`);else{let c={SLACK_TOKEN:t};if(i)c.SLACK_COOKIE=i;sa(a,c),console.log(`Saved token to ${a}`),console.log(" SLACK_TOKEN will be picked up automatically in this directory tree.")}return o}async function Pl(e){console.error("Scanning Slack desktop app...");let t=await la();if(t.length===0)console.error("No sessions found. Make sure Slack is installed and you have signed in at least once."),process.exit(1);if(t.length===1&&e){let n=t[0],i=n.teamName??n.teamId;console.log(`Found workspace: ${i}${n.cookie?" (+ xoxd cookie)":""}`),await Tt(e,n.token,Gn(i),n.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 n of t){let i=n.teamName??n.teamId,s=Gn(i);gi(s,{token:n.token,team:i,teamId:n.teamId,url:n.url??"",user:"",...n.cookie?{cookie:n.cookie}:{}}),console.log(`Added workspace "${s}": ${i}${n.cookie?" + xoxd cookie":""}`)}if(console.log(""),t.length===1){let n=Gn(t[0].teamName??t[0].teamId);console.log(`Run: slack auth use -g ${n}`)}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 pa(e){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 n=await It(e,"Choice [1/2]: ")==="2"?"bot":"user",i=n==="user"?"xoxp-":"xoxb-",s=n==="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 "${s}" (starts with ${i})`),console.log("");let r=await It(e,"Paste your token: ");if(!r)console.error("No token provided."),process.exit(1);if(!r.startsWith(i))console.error(`Expected a ${i} token, got: ${r.slice(0,10)}...`),process.exit(1);await Tt(e,r)}async function Vn(e,t){let n=t==="user"?Il():Tl(),i=t==="user"?"User OAuth Token (xoxp-...)":"Bot User OAuth Token (xoxb-...)",s=t==="user"?"xoxp-":"xoxb-";if(t==="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(n),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 -> ${i}`),console.log("");let r=await It(e,"Paste your token: ");if(!r)console.error("No token provided."),process.exit(1);if(!r.startsWith(s))console.error(`Expected a ${s} token, got: ${r.slice(0,10)}...`),process.exit(1);await Tt(e,r)}async function ha(e={}){if(process.platform!=="darwin")console.error("Chrome cookie extraction is only supported on macOS."),process.exit(1);let t=qn();if(t.length===0)console.error("No workspaces configured. Run: slack auth login"),process.exit(1);let n;if(e.workspace){if(!t.find((c)=>c.name===e.workspace))console.error(`Workspace "${e.workspace}" not found. Available: ${t.map((c)=>c.name).join(", ")}`),process.exit(1);n=e.workspace}else if(t.length===1)n=t[0].name;else{let a=t.find((c)=>c.current);if(a)n=a.name,console.log(`Using active workspace: ${n}`);else{console.log("Multiple workspaces found. Choose one:"),t.forEach((l,d)=>console.log(` ${d+1}) ${l.name} (${l.profile.team})`));let c=Ot({input:process.stdin,output:process.stdout}),u=(await c.question("Choice: ")).trim();c.close();let f=parseInt(u,10)-1;if(isNaN(f)||f<0||f>=t.length)console.error("Invalid choice."),process.exit(1);n=t[f].name}}if(t.find((a)=>a.name===n).profile.token.startsWith("xoxb-")){console.error(`
109
109
  Workspace "${n}" 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 a=t.filter((c)=>c.profile.token.startsWith("xoxc-")||c.profile.token.startsWith("xoxp-"));if(a.length>0)console.error(` Target a user-token workspace instead: ${a.map((c)=>c.name).join(", ")}`),console.error(` slack auth chrome -w ${a[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 s,r;try{({candidates:s,totalProfiles:r}=ua())}catch(a){console.error(`Failed: ${a instanceof Error?a.message:String(a)}`),process.exit(1)}if(s.length===0)console.error(`No Slack session found in Chrome (scanned ${r} profile${r!==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 o;if(s.length===1&&r<=1)o=s[0].cookie,console.log(`Found session in Chrome profile: ${s[0].profileName}`);else{let a=s.length===1?`Found 1 Slack session across ${r} Chrome profiles:`:`Found ${s.length} Slack sessions across ${r} Chrome profiles:`;console.log(a),s.forEach((d,h)=>console.log(` ${h+1}) ${d.profileName} [${d.profileDir}]`)),console.log("");let c=$t({input:process.stdin,output:process.stdout}),u=s.length===1?" [Enter=1]":"",f=(await c.question(`Choice [1-${s.length}]${u}: `)).trim();c.close();let l=f===""&&s.length===1?0:parseInt(f,10)-1;if(isNaN(l)||l<0||l>=s.length)console.error("Invalid choice."),process.exit(1);o=s[l].cookie}pi(n,o),console.log(`Saved xoxd cookie to workspace "${n}".`),console.log("RTM WebSocket mode is now available: slack tail @you")}async function pa(e={}){let t=Hn();if(t.length===0)console.error("No workspaces configured. Run: slack auth token"),process.exit(1);let n;if(e.workspace){if(!t.find((o)=>o.name===e.workspace))console.error(`Workspace "${e.workspace}" not found. Available: ${t.map((o)=>o.name).join(", ")}`),process.exit(1);n=e.workspace}else if(t.length===1)n=t[0].name;else{let r=t.find((o)=>o.current);if(r)n=r.name,console.log(`Using active workspace: ${n}`);else{console.log("Multiple workspaces found. Choose one:"),t.forEach((u,f)=>console.log(` ${f+1}) ${u.name} (${u.profile.team})`));let o=$t({input:process.stdin,output:process.stdout}),a=(await o.question("Choice: ")).trim();o.close();let c=parseInt(a,10)-1;if(isNaN(c)||c<0||c>=t.length)console.error("Invalid choice."),process.exit(1);n=t[c].name}}console.log("Scanning Firefox profiles for Slack session...");let i=la();if(i.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 s;if(i.length===1)s=i[0].cookie,console.log(`Found session in Firefox profile: ${i[0].profileName}`);else{console.log("Multiple Firefox profiles have a Slack session. Choose one:"),i.forEach((c,u)=>console.log(` ${u+1}) ${c.profileName} [${c.profileDir}]`));let r=$t({input:process.stdin,output:process.stdout}),o=(await r.question("Choice: ")).trim();r.close();let a=parseInt(o,10)-1;if(isNaN(a)||a<0||a>=i.length)console.error("Invalid choice."),process.exit(1);s=i[a].cookie}pi(n,s),console.log(`Saved xoxd cookie to workspace "${n}".`),console.log("RTM WebSocket mode is now available: slack tail @you")}async function ha(e={}){if(e.token){await It(null,e.token,e.name);return}if(!process.stdin.isTTY){let n=[];for await(let s of process.stdin)n.push(s);let i=Buffer.concat(n).toString("utf8").trim();if(!i)console.error("No token provided on stdin."),process.exit(1);await It(null,i,e.name);return}let t=$t({input:process.stdin,output:process.stdout});try{await fa(t)}finally{t.close()}}async function ga(e={}){let t=$t({input:process.stdin,output:process.stdout});try{if(e.bot!==void 0){await Gn(t,e.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 n=await Ot(t,"Choice [1/2, Enter=1]: ");await Gn(t,n==="2"?"bot":"user")}finally{t.close()}}async function Vn(e={}){let t=Hn();if(t.length>0){console.log("Currently logged in:");for(let{name:i,profile:s,current:r}of t)console.log(` ${r?"*":" "} ${i} ${s.team} (${s.user||"unknown"})`);console.log(""),console.log("Adding another workspace:"),console.log("")}if(e.token){await It(null,e.token,e.name);return}if(!process.stdin.isTTY){let i=[];for await(let r of process.stdin)i.push(r);let s=Buffer.concat(i).toString("utf8").trim();if(!s)console.error("No token provided on stdin."),process.exit(1);await It(null,s,e.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 n=$t({input:process.stdin,output:process.stdout});try{let i=await Ot(n,"Choice [1/2/3/4]: ");if(console.log(""),i==="1")await Ol(n);else if(i==="2")await fa(n);else if(i==="3")await Gn(n,"user");else if(i==="4")await Gn(n,"bot");else console.error(`Invalid choice: "${i}". Enter 1, 2, 3, or 4.`),process.exit(1)}finally{n.close()}}async function Zn(e,t,n,i){let s=t,r=[],o=s,a=0;while(!0){let c=o.indexOf("<@U",a);if(c===-1)break;let u=o.slice(c+2),f=u.search(/[>|]/),l=f===-1?u:u.slice(0,f);if(l.length>=9)r.push(l);a=c+1}for(let c of r){if(!n.has(c))n.set(c,await Kn(e,c,i));let u=n.get(c)??c;s=s.replaceAll(`<@${c}>`,`@${u}`),s=s.replace(new RegExp(`<@${c}\\|[^>]*>`,"g"),`@${u}`)}return s}function Qn(e){return e.replace(/<!date\^(\d+)\^[^|>]*(?:\|([^>]*))?>/g,(t,n,i)=>{let s=Number(n);if(!Number.isFinite(s))return i??"date";let r=new Date(s*1000);if(Number.isNaN(r.getTime()))return i??"date";let o=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],a=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],c=o[r.getUTCDay()]??"",u=a[r.getUTCMonth()]??"";return`${c}, ${u} ${String(r.getUTCDate()).padStart(2,"0")}, ${r.getUTCFullYear()}`})}function Da(e){let t=typeof e.ts==="string"?e.ts:"",n=typeof e.thread_ts==="string"?e.thread_ts:"";return n!==""&&n!==t}function Il(e){let[t,n="000000"]=e.split("."),i=new Date(Number(t)*1000),s=i.getUTCFullYear(),r=String(i.getUTCMonth()+1).padStart(2,"0"),o=String(i.getUTCDate()).padStart(2,"0"),a=String(i.getUTCHours()).padStart(2,"0"),c=String(i.getUTCMinutes()).padStart(2,"0"),u=String(i.getUTCSeconds()).padStart(2,"0"),f=n.padEnd(6,"0").slice(0,6);return`${s}-${r}-${o}T${a}:${c}:${u}.${f}`}async function Tl(e,t,n){let i=typeof t.ts==="string"?t.ts:"0.000000",s=Il(i),r="?";if(typeof t.user==="string"){let l=t.user,d="@"+l;if(!n.has(d)){let[,h]=await Jn(e,l);n.set(d,h)}r=n.get(d)??l}else if(typeof t.username==="string")r=t.username;let o=typeof t.text==="string"?t.text:"",c=Qn(await Zn(e,o,n)).split(`
111
+ `+"actions (tail @user, DMs, listing users) would still fail.");let a=t.filter((c)=>c.profile.token.startsWith("xoxc-")||c.profile.token.startsWith("xoxp-"));if(a.length>0)console.error(` Target a user-token workspace instead: ${a.map((c)=>c.name).join(", ")}`),console.error(` slack auth chrome -w ${a[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 s,r;try{({candidates:s,totalProfiles:r}=fa())}catch(a){console.error(`Failed: ${a instanceof Error?a.message:String(a)}`),process.exit(1)}if(s.length===0)console.error(`No Slack session found in Chrome (scanned ${r} profile${r!==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 o;if(s.length===1&&r<=1)o=s[0].cookie,console.log(`Found session in Chrome profile: ${s[0].profileName}`);else{let a=s.length===1?`Found 1 Slack session across ${r} Chrome profiles:`:`Found ${s.length} Slack sessions across ${r} Chrome profiles:`;console.log(a),s.forEach((d,h)=>console.log(` ${h+1}) ${d.profileName} [${d.profileDir}]`)),console.log("");let c=Ot({input:process.stdin,output:process.stdout}),u=s.length===1?" [Enter=1]":"",f=(await c.question(`Choice [1-${s.length}]${u}: `)).trim();c.close();let l=f===""&&s.length===1?0:parseInt(f,10)-1;if(isNaN(l)||l<0||l>=s.length)console.error("Invalid choice."),process.exit(1);o=s[l].cookie}mi(n,o),console.log(`Saved xoxd cookie to workspace "${n}".`),console.log("RTM WebSocket mode is now available: slack tail @you")}async function ga(e={}){let t=qn();if(t.length===0)console.error("No workspaces configured. Run: slack auth token"),process.exit(1);let n;if(e.workspace){if(!t.find((o)=>o.name===e.workspace))console.error(`Workspace "${e.workspace}" not found. Available: ${t.map((o)=>o.name).join(", ")}`),process.exit(1);n=e.workspace}else if(t.length===1)n=t[0].name;else{let r=t.find((o)=>o.current);if(r)n=r.name,console.log(`Using active workspace: ${n}`);else{console.log("Multiple workspaces found. Choose one:"),t.forEach((u,f)=>console.log(` ${f+1}) ${u.name} (${u.profile.team})`));let o=Ot({input:process.stdin,output:process.stdout}),a=(await o.question("Choice: ")).trim();o.close();let c=parseInt(a,10)-1;if(isNaN(c)||c<0||c>=t.length)console.error("Invalid choice."),process.exit(1);n=t[c].name}}console.log("Scanning Firefox profiles for Slack session...");let i=da();if(i.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 s;if(i.length===1)s=i[0].cookie,console.log(`Found session in Firefox profile: ${i[0].profileName}`);else{console.log("Multiple Firefox profiles have a Slack session. Choose one:"),i.forEach((c,u)=>console.log(` ${u+1}) ${c.profileName} [${c.profileDir}]`));let r=Ot({input:process.stdin,output:process.stdout}),o=(await r.question("Choice: ")).trim();r.close();let a=parseInt(o,10)-1;if(isNaN(a)||a<0||a>=i.length)console.error("Invalid choice."),process.exit(1);s=i[a].cookie}mi(n,s),console.log(`Saved xoxd cookie to workspace "${n}".`),console.log("RTM WebSocket mode is now available: slack tail @you")}async function ma(e={}){if(e.token){await Tt(null,e.token,e.name);return}if(!process.stdin.isTTY){let n=[];for await(let s of process.stdin)n.push(s);let i=Buffer.concat(n).toString("utf8").trim();if(!i)console.error("No token provided on stdin."),process.exit(1);await Tt(null,i,e.name);return}let t=Ot({input:process.stdin,output:process.stdout});try{await pa(t)}finally{t.close()}}async function Da(e={}){let t=Ot({input:process.stdin,output:process.stdout});try{if(e.bot!==void 0){await Vn(t,e.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 n=await It(t,"Choice [1/2, Enter=1]: ");await Vn(t,n==="2"?"bot":"user")}finally{t.close()}}async function Zn(e={}){let t=qn();if(t.length>0){console.log("Currently logged in:");for(let{name:i,profile:s,current:r}of t)console.log(` ${r?"*":" "} ${i} ${s.team} (${s.user||"unknown"})`);console.log(""),console.log("Adding another workspace:"),console.log("")}if(e.token){await Tt(null,e.token,e.name);return}if(!process.stdin.isTTY){let i=[];for await(let r of process.stdin)i.push(r);let s=Buffer.concat(i).toString("utf8").trim();if(!s)console.error("No token provided on stdin."),process.exit(1);await Tt(null,s,e.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 n=Ot({input:process.stdin,output:process.stdout});try{let i=await It(n,"Choice [1/2/3/4]: ");if(console.log(""),i==="1")await Pl(n);else if(i==="2")await pa(n);else if(i==="3")await Vn(n,"user");else if(i==="4")await Vn(n,"bot");else console.error(`Invalid choice: "${i}". Enter 1, 2, 3, or 4.`),process.exit(1)}finally{n.close()}}async function Qn(e,t,n,i){let s=t,r=[],o=s,a=0;while(!0){let c=o.indexOf("<@U",a);if(c===-1)break;let u=o.slice(c+2),f=u.search(/[>|]/),l=f===-1?u:u.slice(0,f);if(l.length>=9)r.push(l);a=c+1}for(let c of r){if(!n.has(c))n.set(c,await zn(e,c,i));let u=n.get(c)??c;s=s.replaceAll(`<@${c}>`,`@${u}`),s=s.replace(new RegExp(`<@${c}\\|[^>]*>`,"g"),`@${u}`)}return s}function es(e){return e.replace(/<!date\^(\d+)\^[^|>]*(?:\|([^>]*))?>/g,(t,n,i)=>{let s=Number(n);if(!Number.isFinite(s))return i??"date";let r=new Date(s*1000);if(Number.isNaN(r.getTime()))return i??"date";let o=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],a=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],c=o[r.getUTCDay()]??"",u=a[r.getUTCMonth()]??"";return`${c}, ${u} ${String(r.getUTCDate()).padStart(2,"0")}, ${r.getUTCFullYear()}`})}function wa(e){let t=typeof e.ts==="string"?e.ts:"",n=typeof e.thread_ts==="string"?e.thread_ts:"";return n!==""&&n!==t}function Rl(e){let[t,n="000000"]=e.split("."),i=new Date(Number(t)*1000),s=i.getUTCFullYear(),r=String(i.getUTCMonth()+1).padStart(2,"0"),o=String(i.getUTCDate()).padStart(2,"0"),a=String(i.getUTCHours()).padStart(2,"0"),c=String(i.getUTCMinutes()).padStart(2,"0"),u=String(i.getUTCSeconds()).padStart(2,"0"),f=n.padEnd(6,"0").slice(0,6);return`${s}-${r}-${o}T${a}:${c}:${u}.${f}`}async function Ml(e,t,n){let i=typeof t.ts==="string"?t.ts:"0.000000",s=Rl(i),r="?";if(typeof t.user==="string"){let l=t.user,d="@"+l;if(!n.has(d)){let[,h]=await Kn(e,l);n.set(d,h)}r=n.get(d)??l}else if(typeof t.username==="string")r=t.username;let o=typeof t.text==="string"?t.text:"",c=es(await Qn(e,o,n)).split(`
112
112
  `),u=c[0]+(c.length>1?`
113
113
  `+c.slice(1).map((l)=>` ${l}`).join(`
114
- `):""),f=Da(t)?"↳ ":"";return`${s} ${f}@${r}: ${u}`}async function Pl(e,t,n,i,s,r,o,a){if(a?.aborted)return;return new Promise((c)=>{let u=new e(n);a?.addEventListener("abort",()=>{u.close(),c()},{once:!0}),u.addEventListener("open",()=>{process.stderr.write(`Connected via RTM (experimental).
115
- `)}),u.addEventListener("close",()=>c()),u.addEventListener("error",()=>c()),u.addEventListener("message",(f)=>{(async()=>{try{let l;try{l=JSON.parse(String(f.data))}catch{return}let d=typeof l.type==="string"?l.type:"";if(d==="ping"){u.send(JSON.stringify({type:"pong",reply_to:l.id??0}));return}if(d!=="message")return;if((typeof l.channel==="string"?l.channel:"")!==i)return;let m=typeof l.ts==="string"?l.ts:"";if(!m||r.has(m))return;let p=typeof l.subtype==="string"?l.subtype:"";if(p==="message_changed"||p==="message_deleted")return;if(s.thread){if((typeof l.thread_ts==="string"?l.thread_ts:m)!==s.thread&&m!==s.thread)return}if(s.watchThread&&Da(l)){if((typeof l.thread_ts==="string"?l.thread_ts:"")!==s.watchThread)return}if(s.me&&s.myUserId){if(!(typeof l.text==="string"?l.text:"").includes(`<@${s.myUserId}>`))return}if(r.add(m),r.size>1000){let E=r.values().next().value;if(E!==void 0)r.delete(E)}let y=await Tl(t,l,o);process.stdout.write(y+`
114
+ `):""),f=wa(t)?"↳ ":"";return`${s} ${f}@${r}: ${u}`}async function Bl(e,t,n,i,s,r,o,a){if(a?.aborted)return;return new Promise((c)=>{let u=new e(n);a?.addEventListener("abort",()=>{u.close(),c()},{once:!0}),u.addEventListener("open",()=>{process.stderr.write(`Connected via RTM (experimental).
115
+ `)}),u.addEventListener("close",()=>c()),u.addEventListener("error",()=>c()),u.addEventListener("message",(f)=>{(async()=>{try{let l;try{l=JSON.parse(String(f.data))}catch{return}let d=typeof l.type==="string"?l.type:"";if(d==="ping"){u.send(JSON.stringify({type:"pong",reply_to:l.id??0}));return}if(d!=="message")return;if((typeof l.channel==="string"?l.channel:"")!==i)return;let m=typeof l.ts==="string"?l.ts:"";if(!m||r.has(m))return;let p=typeof l.subtype==="string"?l.subtype:"";if(p==="message_changed"||p==="message_deleted")return;if(s.thread){if((typeof l.thread_ts==="string"?l.thread_ts:m)!==s.thread&&m!==s.thread)return}if(s.watchThread&&wa(l)){if((typeof l.thread_ts==="string"?l.thread_ts:"")!==s.watchThread)return}if(s.me&&s.myUserId){if(!(typeof l.text==="string"?l.text:"").includes(`<@${s.myUserId}>`))return}if(r.add(m),r.size>1000){let C=r.values().next().value;if(C!==void 0)r.delete(C)}let y=await Ml(t,l,o);process.stdout.write(y+`
116
116
  `)}catch(l){process.stderr.write(`RTM message error: ${l instanceof Error?l.message:String(l)}
117
- `)}})()})})}var ma=3,Rl=2000,gi={sleep:(e)=>new Promise((t)=>setTimeout(t,e)),clientBoot:Ho,getWebSocket:()=>{let e=globalThis.WebSocket;return typeof e==="function"?e:void 0}};async function ya(e,t,n,i,s,r,o){let a=gi.getWebSocket();if(!a)return;for(let c=0;c<ma;c++){if(o?.aborted)return;try{let{wsUrl:u}=await gi.clientBoot(e,t);await Pl(a,e,u,n,i,s,r,o)}catch{}if(o?.aborted)return;if(c<ma-1)await gi.sleep(Rl)}}function wa(e){let t=e.match(/^(\d+(?:\.\d+)?)(s|m|h|d)$/);if(!t)throw Error(`Invalid --since format: "${e}" (expected e.g. 10m, 2h, 1d)`);let n=parseFloat(t[1]);switch(t[2]){case"s":return n;case"m":return n*60;case"h":return n*3600;case"d":return n*86400}}var Ue={sleep:(e)=>new Promise((t)=>setTimeout(t,e)),now:()=>Date.now(),tailRTM:ya};function et(e){return e&&typeof e==="object"&&!Array.isArray(e)?e:{}}function mi(e){return Array.isArray(e)?e:[]}function ba(e){return Number(e)||0}function Fa(e){let t=typeof e.ts==="string"?e.ts:"",n=typeof e.thread_ts==="string"?e.thread_ts:"";return n!==""&&n!==t}function Ml(e){let[t,n="000000"]=e.split("."),i=new Date(Number(t)*1000),s=i.getUTCFullYear(),r=String(i.getUTCMonth()+1).padStart(2,"0"),o=String(i.getUTCDate()).padStart(2,"0"),a=String(i.getUTCHours()).padStart(2,"0"),c=String(i.getUTCMinutes()).padStart(2,"0"),u=String(i.getUTCSeconds()).padStart(2,"0"),f=n.padEnd(6,"0").slice(0,6);return`${s}-${r}-${o}T${a}:${c}:${u}.${f}`}async function Bl(e,t,n,i,s){let r=typeof t.ts==="string"?t.ts:"0.000000",o=Ml(r),a="?";if(typeof t.user==="string"){let m=t.user,p="@"+m;if(!n.has(p)){let[,y]=await Jn(e,m,s);n.set(p,y)}a=n.get(p)??m}else if(typeof t.username==="string")a=t.username;let c=typeof t.text==="string"?t.text:"",f=Qn(await Zn(e,c,n,s)).split(`
117
+ `)}})()})})}var ya=3,Nl=2000,yi={sleep:(e)=>new Promise((t)=>setTimeout(t,e)),clientBoot:Yo,getWebSocket:()=>{let e=globalThis.WebSocket;return typeof e==="function"?e:void 0}};async function ba(e,t,n,i,s,r,o){let a=yi.getWebSocket();if(!a)return;for(let c=0;c<ya;c++){if(o?.aborted)return;try{let{wsUrl:u}=await yi.clientBoot(e,t);await Bl(a,e,u,n,i,s,r,o)}catch{}if(o?.aborted)return;if(c<ya-1)await yi.sleep(Nl)}}function Fa(e){let t=e.match(/^(\d+(?:\.\d+)?)(s|m|h|d)$/);if(!t)throw Error(`Invalid --since format: "${e}" (expected e.g. 10m, 2h, 1d)`);let n=parseFloat(t[1]);switch(t[2]){case"s":return n;case"m":return n*60;case"h":return n*3600;case"d":return n*86400}}var Ue={sleep:(e)=>new Promise((t)=>setTimeout(t,e)),now:()=>Date.now(),tailRTM:ba};function tt(e){return e&&typeof e==="object"&&!Array.isArray(e)?e:{}}function wi(e){return Array.isArray(e)?e:[]}function Ca(e){return Number(e)||0}function Ea(e){let t=typeof e.ts==="string"?e.ts:"",n=typeof e.thread_ts==="string"?e.thread_ts:"";return n!==""&&n!==t}function vl(e){let[t,n="000000"]=e.split("."),i=new Date(Number(t)*1000),s=i.getUTCFullYear(),r=String(i.getUTCMonth()+1).padStart(2,"0"),o=String(i.getUTCDate()).padStart(2,"0"),a=String(i.getUTCHours()).padStart(2,"0"),c=String(i.getUTCMinutes()).padStart(2,"0"),u=String(i.getUTCSeconds()).padStart(2,"0"),f=n.padEnd(6,"0").slice(0,6);return`${s}-${r}-${o}T${a}:${c}:${u}.${f}`}async function jl(e,t,n,i,s){let r=typeof t.ts==="string"?t.ts:"0.000000",o=vl(r),a="?";if(typeof t.user==="string"){let m=t.user,p="@"+m;if(!n.has(p)){let[,y]=await Kn(e,m,s);n.set(p,y)}a=n.get(p)??m}else if(typeof t.username==="string")a=t.username;let c=typeof t.text==="string"?t.text:"",f=es(await Qn(e,c,n,s)).split(`
118
118
  `),l=f[0]+(f.length>1?`
119
119
  `+f.slice(1).map((m)=>` ${m}`).join(`
120
- `):""),d=Fa(t)?"↳ ":"",h=i?`${i} @${a}`:`@${a}`;return`${o} ${d}${h}: ${l}`}async function Nl(e,t,n,i,s,r,o){let a=et(await on(e,t,20,o?void 0:n||void 0,o,i.cookie)),c=mi(a.messages).map(et).reverse(),u=et(a.response_metadata),f=a.has_more===!0&&typeof u.next_cursor==="string"?u.next_cursor:void 0,l=[];if(i.watchThread&&!o){let y=et(await Uo(e,t,i.watchThread,50,i.cookie));l=mi(y.messages).map(et).filter((E)=>(typeof E.ts==="string"?E.ts:"")!==i.watchThread)}let d=[...c.map((y)=>({m:y,fromHistory:!0})),...l.map((y)=>({m:y,fromHistory:!1}))].sort((y,E)=>ba(typeof y.m.ts==="string"?y.m.ts:"")-ba(typeof E.m.ts==="string"?E.m.ts:"")),h=[],m=n,p=!1;for(let{m:y,fromHistory:E}of d){let F=typeof y.ts==="string"?y.ts:"";if(!F||s.has(F))continue;let k=typeof y.subtype==="string"?y.subtype:"";if(k==="message_changed"||k==="message_deleted")continue;if(i.thread){if((typeof y.thread_ts==="string"?y.thread_ts:F)!==i.thread&&F!==i.thread)continue}if(i.watchThread&&Fa(y)){if((typeof y.thread_ts==="string"?y.thread_ts:"")!==i.watchThread)continue}if(i.me&&i.myUserId){if(!(typeof y.text==="string"?y.text:"").includes(`<@${i.myUserId}>`))continue}if(s.add(F),s.size>1000){let A=s.values().next().value;if(A!==void 0)s.delete(A)}if(h.push(await Bl(e,y,r,void 0,i.cookie)),E)m=F;let C=typeof y.user==="string"?y.user:"";if(!i.myUserId||C!==i.myUserId)p=!0}return{newCursor:m,lines:h,hasMore:a.has_more===!0,nextPageCursor:f,emittedOther:p}}function vl(e){if(e.includes("slack.com")){let t=si(e),n=t?.threadTs??t?.ts;if(n)return n;throw Error(`--watch-thread: could not extract a timestamp from "${e}"`)}if(/^\d{10}\.\d{6}$/.test(e))return e;if(/^\d{16}$/.test(e))return`${e.slice(0,10)}.${e.slice(10)}`;throw Error(`--watch-thread: "${e}" is not a valid ts or permalink`)}async function Ca(e,t,n={},i){if(n.me&&!t)console.error(`slack tail --me requires a <target> channel.
120
+ `):""),d=Ea(t)?"↳ ":"",h=i?`${i} @${a}`:`@${a}`;return`${o} ${d}${h}: ${l}`}async function Ll(e,t,n,i,s,r,o){let a=tt(await on(e,t,20,o?void 0:n||void 0,o,i.cookie)),c=wi(a.messages).map(tt).reverse(),u=tt(a.response_metadata),f=a.has_more===!0&&typeof u.next_cursor==="string"?u.next_cursor:void 0,l=[];if(i.watchThread&&!o){let y=tt(await Ko(e,t,i.watchThread,50,i.cookie));l=wi(y.messages).map(tt).filter((C)=>(typeof C.ts==="string"?C.ts:"")!==i.watchThread)}let d=[...c.map((y)=>({m:y,fromHistory:!0})),...l.map((y)=>({m:y,fromHistory:!1}))].sort((y,C)=>Ca(typeof y.m.ts==="string"?y.m.ts:"")-Ca(typeof C.m.ts==="string"?C.m.ts:"")),h=[],m=n,p=!1;for(let{m:y,fromHistory:C}of d){let F=typeof y.ts==="string"?y.ts:"";if(!F||s.has(F))continue;let k=typeof y.subtype==="string"?y.subtype:"";if(k==="message_changed"||k==="message_deleted")continue;if(i.thread){if((typeof y.thread_ts==="string"?y.thread_ts:F)!==i.thread&&F!==i.thread)continue}if(i.watchThread&&Ea(y)){if((typeof y.thread_ts==="string"?y.thread_ts:"")!==i.watchThread)continue}if(i.me&&i.myUserId){if(!(typeof y.text==="string"?y.text:"").includes(`<@${i.myUserId}>`))continue}if(s.add(F),s.size>1000){let A=s.values().next().value;if(A!==void 0)s.delete(A)}if(h.push(await jl(e,y,r,void 0,i.cookie)),C)m=F;let S=typeof y.user==="string"?y.user:"";if(!i.myUserId||S!==i.myUserId)p=!0}return{newCursor:m,lines:h,hasMore:a.has_more===!0,nextPageCursor:f,emittedOther:p}}function Wl(e){if(e.includes("slack.com")){let t=oi(e),n=t?.threadTs??t?.ts;if(n)return n;throw Error(`--watch-thread: could not extract a timestamp from "${e}"`)}if(/^\d{10}\.\d{6}$/.test(e))return e;if(/^\d{16}$/.test(e))return`${e.slice(0,10)}.${e.slice(10)}`;throw Error(`--watch-thread: "${e}" is not a valid ts or permalink`)}async function xa(e,t,n={},i){if(n.me&&!t)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(!t)console.error("Usage: slack tail <#channel|@user>\n Run `slack tail --help` for details."),process.exit(1);let s=await Ko(e,t),r=n.interval??60000,o=n.timeout?Ue.now()+wa(n.timeout)*1000:1/0,a=new Map,c=new Set;try{let p=et(await zo(e,s,n.cookie));if(et(p.channel).is_archived===!0)console.error("Warning: this channel is archived — no new messages will arrive.")}catch(p){let y=p instanceof Error?p.message:String(p);if(y.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(y.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(y.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: ${y}`)}let u="";if(n.since){let p=wa(n.since);u=(Ue.now()/1000-p).toFixed(6)}else{let p=et(await on(e,s,1,void 0,void 0,n.cookie)),y=mi(p.messages).map(et);if(y.length>0&&typeof y[0]?.ts==="string")u=y[0].ts,c.add(u);else u=(Ue.now()/1000).toFixed(6)}let f;if(n.me||n.exitOnMessage)f=(await zt(e,n.cookie)).userId||void 0;let l;if(n.watchThread!==void 0)try{l=vl(n.watchThread)}catch(p){console.error(p instanceof Error?p.message:String(p)),process.exit(1)}let d={...n.thread!==void 0?{thread:n.thread}:{},...l!==void 0?{watchThread:l}:{},...n.me!==void 0?{me:n.me}:{},...f!==void 0?{myUserId:f}:{},...n.cookie!==void 0?{cookie:n.cookie}:{}};if(e.startsWith("xoxc-")&&n.cookie!==void 0&&n.noRtm!==!0&&n.since===void 0&&n.timeout===void 0&&n.exitOnMessage!==!0){if(await Ue.tailRTM(e,n.cookie,s,d,c,a,i),i?.aborted)return;console.error("RTM unavailable — switching to polling.")}let h=!0,m=Ue.now();while(!i?.aborted){if(Ue.now()>=o)return;let p=!1;try{let F=Ue.now()-m,k=r>0&&F>r*5,C,A=!0;do{let{newCursor:P,lines:v,nextPageCursor:L,emittedOther:R}=await Nl(e,s,u,d,c,a,C);if(u=P,h&&A&&n.since&&v.length===0)process.stdout.write(`(no messages in the last ${n.since} — watching for new)
123
- `);A=!1;for(let G of v)process.stdout.write(G+`
124
- `);if(R)p=!0;C=k?L:void 0}while(C);h=!1}catch(E){if(E instanceof Ge){console.error(`Warning: Slack rate limit hit — backing off for ${E.retryAfter}s`),await Ue.sleep(E.retryAfter*1000);continue}throw E}if(n.exitOnMessage&&p)return;m=Ue.now();let y=o-Ue.now();if(y<=0)return;await Ue.sleep(Math.min(r,y))}}var Me=[{name:"one",glyph:"1️⃣"},{name:"two",glyph:"2️⃣"},{name:"three",glyph:"3️⃣"},{name:"four",glyph:"4️⃣"},{name:"five",glyph:"5️⃣"},{name:"six",glyph:"6️⃣"},{name:"seven",glyph:"7️⃣"},{name:"eight",glyph:"8️⃣"},{name:"nine",glyph:"9️⃣"},{name:"keycap_ten",glyph:"\uD83D\uDD1F"}],es=Me.length,ts="question";function yi(e){let t=e.split(`
125
- `),n=t[t.length-2];if(n===void 0||!n.startsWith("_:warning: 同時に複数選ばれているため回答として数えていません — どれか 1 つだけ残してください: ")||!n.endsWith("_"))return[];return[...n.matchAll(/<@([UW][A-Z0-9]+)>/g)].map((i)=>i[1])}function wi(e,t){let n=e.split(`
126
- `);if(n.length<2)return e;if(yi(e).length)n.splice(n.length-2,1);if(t.length)n.splice(n.length-1,0,`${"_:warning: 同時に複数選ばれているため回答として数えていません — どれか 1 つだけ残してください: "}${t.map((s)=>`<@${s}>`).join(", ")}_`);let i=n.join(`
127
- `);return i===e?e:i}function jl(e){return e!==void 0&&e.startsWith("_:warning: 同時に複数選ばれているため回答として数えていません — どれか 1 つだけ残してください: ")&&e.endsWith("_")}var bi="white_check_mark",Di=`:${bi}: `;function Ea(e){return e.replace(/\s*\n\s*/g," ")}function xa(e,t,n,i,s){let r=[`:question: *${e}*`];if(t)r.push("",t);if(n.length){if(r.push(""),r.push(...n.map((o,a)=>`${Me[a].glyph} ${Ea(o)}`)),i.length)r.push(""),r.push(...i.map((o,a)=>`(${a+11}) ${Ea(o)}`)),r.push("_11 番目以降はリアクションがないので、返信で答えてください。_");r.push(""),r.push(s?"_下のリアクションを 1 つ押すと回答になります。当てはまるものがなければ、このメッセージの *スレッド* で返信してください (チャンネルへの通常投稿は回答として拾いません)。_":"_下のリアクションを 1 つ押すと回答になります。当てはまるものがなければ、このメッセージに返信してください。_")}else r.push(""),r.push(s?"_このメッセージの *スレッド* で返信してください。本文がそのまま回答になります (チャンネルへの通常投稿は回答として拾いません)。_":"_このメッセージに返信してください。本文がそのまま回答になります。_");return r.join(`
128
- `)}function _a(e,t,n){let i=t.answer.split(`
122
+ Use: slack tail "#channel" --me`),process.exit(1);if(!t)console.error("Usage: slack tail <#channel|@user>\n Run `slack tail --help` for details."),process.exit(1);let s=await Ho(e,t),r=n.interval??60000,o=n.timeout?Ue.now()+Fa(n.timeout)*1000:1/0,a=new Map,c=new Set;try{let p=tt(await qo(e,s,n.cookie));if(tt(p.channel).is_archived===!0)console.error("Warning: this channel is archived — no new messages will arrive.")}catch(p){let y=p instanceof Error?p.message:String(p);if(y.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(y.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(y.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: ${y}`)}let u="";if(n.since){let p=Fa(n.since);u=(Ue.now()/1000-p).toFixed(6)}else{let p=tt(await on(e,s,1,void 0,void 0,n.cookie)),y=wi(p.messages).map(tt);if(y.length>0&&typeof y[0]?.ts==="string")u=y[0].ts,c.add(u);else u=(Ue.now()/1000).toFixed(6)}let f;if(n.me||n.exitOnMessage)f=(await zt(e,n.cookie)).userId||void 0;let l;if(n.watchThread!==void 0)try{l=Wl(n.watchThread)}catch(p){console.error(p instanceof Error?p.message:String(p)),process.exit(1)}let d={...n.thread!==void 0?{thread:n.thread}:{},...l!==void 0?{watchThread:l}:{},...n.me!==void 0?{me:n.me}:{},...f!==void 0?{myUserId:f}:{},...n.cookie!==void 0?{cookie:n.cookie}:{}};if(e.startsWith("xoxc-")&&n.cookie!==void 0&&n.noRtm!==!0&&n.since===void 0&&n.timeout===void 0&&n.exitOnMessage!==!0){if(await Ue.tailRTM(e,n.cookie,s,d,c,a,i),i?.aborted)return;console.error("RTM unavailable — switching to polling.")}let h=!0,m=Ue.now();while(!i?.aborted){if(Ue.now()>=o)return;let p=!1;try{let F=Ue.now()-m,k=r>0&&F>r*5,S,A=!0;do{let{newCursor:I,lines:W,nextPageCursor:B,emittedOther:R}=await Ll(e,s,u,d,c,a,S);if(u=I,h&&A&&n.since&&W.length===0)process.stdout.write(`(no messages in the last ${n.since} — watching for new)
123
+ `);A=!1;for(let Y of W)process.stdout.write(Y+`
124
+ `);if(R)p=!0;S=k?B:void 0}while(S);h=!1}catch(C){if(C instanceof Ve){console.error(`Warning: Slack rate limit hit — backing off for ${C.retryAfter}s`),await Ue.sleep(C.retryAfter*1000);continue}throw C}if(n.exitOnMessage&&p)return;m=Ue.now();let y=o-Ue.now();if(y<=0)return;await Ue.sleep(Math.min(r,y))}}var Re=[{name:"one",glyph:"1️⃣"},{name:"two",glyph:"2️⃣"},{name:"three",glyph:"3️⃣"},{name:"four",glyph:"4️⃣"},{name:"five",glyph:"5️⃣"},{name:"six",glyph:"6️⃣"},{name:"seven",glyph:"7️⃣"},{name:"eight",glyph:"8️⃣"},{name:"nine",glyph:"9️⃣"},{name:"keycap_ten",glyph:"\uD83D\uDD1F"}],ts=Re.length,ns="question";function Fi(e){let t=e.split(`
125
+ `),n=t[t.length-2];if(n===void 0||!n.startsWith("_:warning: 同時に複数選ばれているため回答として数えていません — どれか 1 つだけ残してください: ")||!n.endsWith("_"))return[];return[...n.matchAll(/<@([UW][A-Z0-9]+)>/g)].map((i)=>i[1])}function Ci(e,t){let n=e.split(`
126
+ `);if(n.length<2)return e;if(Fi(e).length)n.splice(n.length-2,1);if(t.length)n.splice(n.length-1,0,`${"_:warning: 同時に複数選ばれているため回答として数えていません — どれか 1 つだけ残してください: "}${t.map((s)=>`<@${s}>`).join(", ")}_`);let i=n.join(`
127
+ `);return i===e?e:i}function Ul(e){return e!==void 0&&e.startsWith("_:warning: 同時に複数選ばれているため回答として数えていません — どれか 1 つだけ残してください: ")&&e.endsWith("_")}var Ei="white_check_mark",bi=`:${Ei}: `;function _a(e){return e.replace(/\s*\n\s*/g," ")}function Sa(e,t,n,i,s){let r=[`:question: *${e}*`];if(t)r.push("",t);if(n.length){if(r.push(""),r.push(...n.map((o,a)=>`${Re[a].glyph} ${_a(o)}`)),i.length)r.push(""),r.push(...i.map((o,a)=>`(${a+11}) ${_a(o)}`)),r.push("_11 番目以降はリアクションがないので、返信で答えてください。_");r.push(""),r.push(s?"_下のリアクションを 1 つ押すと回答になります。当てはまるものがなければ、このメッセージの *スレッド* で返信してください (チャンネルへの通常投稿は回答として拾いません)。_":"_下のリアクションを 1 つ押すと回答になります。当てはまるものがなければ、このメッセージに返信してください。_")}else r.push(""),r.push(s?"_このメッセージの *スレッド* で返信してください。本文がそのまま回答になります (チャンネルへの通常投稿は回答として拾いません)。_":"_このメッセージに返信してください。本文がそのまま回答になります。_");return r.join(`
128
+ `)}function ka(e,t,n){let i=t.answer.split(`
129
129
  `).map((s)=>`> ${s}`).join(`
130
- `);return`${Di}*${e}*
130
+ `);return`${bi}*${e}*
131
131
  _${t.how}で回答済み${n?` (${n})`:""}_
132
132
 
133
- ${i}`}function Sa(e){let t=e.split(`
134
- `);if(e.startsWith(Di)){let l=t[0].slice(Di.length).replace(/^\*/,"").replace(/\*$/,""),d=t.filter((h)=>h.startsWith("> ")).map((h)=>h.slice(2)).join(`
133
+ ${i}`}function Aa(e){let t=e.split(`
134
+ `);if(e.startsWith(bi)){let l=t[0].slice(bi.length).replace(/^\*/,"").replace(/\*$/,""),d=t.filter((h)=>h.startsWith("> ")).map((h)=>h.slice(2)).join(`
135
135
  `);if(!d)return{kind:"other"};return{kind:"resolved",question:l,answer:d}}let n=t[t.length-1]??"",i,s;switch(n){case"_下のリアクションを 1 つ押すと回答になります。当てはまるものがなければ、このメッセージの *スレッド* で返信してください (チャンネルへの通常投稿は回答として拾いません)。_":i=!0,s=!0;break;case"_下のリアクションを 1 つ押すと回答になります。当てはまるものがなければ、このメッセージに返信してください。_":i=!1,s=!0;break;case"_このメッセージの *スレッド* で返信してください。本文がそのまま回答になります (チャンネルへの通常投稿は回答として拾いません)。_":i=!0,s=!1;break;case"_このメッセージに返信してください。本文がそのまま回答になります。_":i=!1,s=!1;break;default:return{kind:"other"}}let r=t[0].startsWith(":question: ")?t[0].slice(11):t[0];if(t[0]=r,!t[0].startsWith("*"))return{kind:"other"};let o=0;while(o<t.length&&!(t[o].endsWith("*")&&(o>0||t[0].length>1)))o++;if(o>=t.length)return{kind:"other"};let a=t.slice(0,o+1).join(`
136
- `).replace(/^\*/,"").replace(/\*$/,""),c=[],u=[];if(s){let f=t.length-2;if(jl(t[f]))f--;if(t[f]!=="")return{kind:"other"};if(f--,t[f]==="_11 番目以降はリアクションがないので、返信で答えてください。_"){f--;while(f>=0&&/^\(\d+\) /.test(t[f]))u.unshift(t[f].replace(/^\(\d+\) /,"")),f--;if(t[f]!=="")return{kind:"other"};f--}let l=[];while(f>=0){let d=t[f];if(!Me.some((h)=>d.startsWith(`${h.glyph} `)||d===h.glyph))break;l.unshift(d),f--}if(!l.length||l.length>es)return{kind:"other"};for(let d=0;d<l.length;d++){let h=Me[d].glyph;if(!(l[d].startsWith(`${h} `)||l[d]===h))return{kind:"other"};c.push(l[d].slice(h.length+1))}if(t[f]!=="")return{kind:"other"};if(f<o+1)return{kind:"other"};for(let d=0;d<u.length;d++)if(!t.includes(`(${d+11}) ${u[d]}`))return{kind:"other"}}return{kind:"open",question:a,reactable:c,overflow:u,threadOnly:i}}var Fi=[{name:"one",glyph:"1️⃣"},{name:"two",glyph:"2️⃣"},{name:"three",glyph:"3️⃣"},{name:"four",glyph:"4️⃣"},{name:"five",glyph:"5️⃣"},{name:"six",glyph:"6️⃣"},{name:"seven",glyph:"7️⃣"},{name:"eight",glyph:"8️⃣"},{name:"nine",glyph:"9️⃣"},{name:"keycap_ten",glyph:"\uD83D\uDD1F"}],kg=Fi.length;function Ci(e){let t=e.split(`
137
- `),n=t[t.length-2];if(n===void 0||!n.startsWith("_:warning: 同時に複数選ばれているため回答として数えていません — どれか 1 つだけ残してください: ")||!n.endsWith("_"))return[];return[...n.matchAll(/<@([UW][A-Z0-9]+)>/g)].map((i)=>i[1])}function ka(e,t){let n=e.split(`
138
- `);if(n.length<2)return e;if(Ci(e).length)n.splice(n.length-2,1);if(t.length)n.splice(n.length-1,0,`${"_:warning: 同時に複数選ばれているため回答として数えていません — どれか 1 つだけ残してください: "}${t.map((s)=>`<@${s}>`).join(", ")}_`);let i=n.join(`
139
- `);return i===e?e:i}function Aa(e){return e!==void 0&&e.startsWith("_:warning: 同時に複数選ばれているため回答として数えていません — どれか 1 つだけ残してください: ")&&e.endsWith("_")}var Ll="white_check_mark",Ag=`:${Ll}: `;var Be=Fi,Ht=Be.length,cn="ballot_box_with_ballot",Ei=`:${cn}: `,Oa="_下のリアクションで投票してください (1 人 1 票、押し直しで変更できます)。_",Ia="_下のリアクションで投票してください (当てはまるものを *いくつでも* 押せます)。_",ns="_締切: ",ss="_",Si="bar_chart",xi=`:${Si}: `;function is(e){return`:${Be[e].name}:`}function $a(e,t){for(let n of[is(t),Be[t].glyph])if(e.startsWith(`${n} `))return e.slice(n.length+1);return null}function Wl(e){return Be.some((t,n)=>e.startsWith(`${is(n)} `)||e.startsWith(`${t.glyph} `))}function _i(e){return e.replace(/\s*\n\s*/g," ")}function Ta(e,t,n,i={}){let s=!!i.multi,r=i.deadline??"",o=i.invalid??[];if(!n.length||n.length>Ht)throw Error(`poll needs 1..${Ht} choices, got ${n.length}`);let a=[`${Ei}*${e}*`];if(t)a.push("",t);if(a.push(""),a.push(...n.map((c,u)=>`${is(u)} ${_i(c)}`)),a.push(""),r)a.push(`${ns}${_i(r)}${ss}`);return a.push(s?Ia:Oa),ka(a.join(`
140
- `),s?[]:o)}function Pa(e,t){let n=t.reduce((s,r)=>s+r.count,0),i=[`${xi}*${e}*`,`_投票終了 (計 ${n} 票)_`,""];return i.push(...t.map((s,r)=>`${is(r)} ×${s.count} ${_i(s.choice)}`)),i.join(`
141
- `)}function Ra(e){let t=e.split(`
142
- `);if(e.startsWith(xi)){let d=t[0].slice(xi.length).replace(/^\*/,"").replace(/\*$/,""),h=[];for(let m=0;m<Be.length;m++){let p=t.map((E)=>$a(E,m)).find((E)=>E!==null&&E.startsWith("×"));if(p===void 0)break;let y=/^×(\d+) (.*)$/.exec(p);if(!y)return{kind:"other"};h.push({choice:y[2],count:Number(y[1])})}if(!h.length)return{kind:"other"};return{kind:"closed",question:d,tallies:h}}let n=t[t.length-1]??"",i;if(n===Oa)i=!1;else if(n===Ia)i=!0;else return{kind:"other"};if(t[0].startsWith(Ei))t[0]=t[0].slice(Ei.length);if(!t[0].startsWith("*"))return{kind:"other"};let s=0;while(s<t.length&&!(t[s].endsWith("*")&&(s>0||t[0].length>1)))s++;if(s>=t.length)return{kind:"other"};let r=t.slice(0,s+1).join(`
143
- `).replace(/^\*/,"").replace(/\*$/,""),o=t.length-2,a=Ci(e);if(Aa(t[o]))o--;let c="",u=t[o];if(u!==void 0&&u.startsWith(ns)&&u.endsWith(ss)&&u.length>ns.length+ss.length)c=u.slice(ns.length,-ss.length),o--;if(t[o]!=="")return{kind:"other"};o--;let f=[];while(o>=0){let d=t[o];if(!Wl(d))break;f.unshift(d),o--}if(!f.length||f.length>Ht)return{kind:"other"};let l=[];for(let d=0;d<f.length;d++){let h=$a(f[d],d);if(h===null)return{kind:"other"};l.push(h)}if(t[o]!=="")return{kind:"other"};if(o<s+1)return{kind:"other"};return{kind:"open",question:r,choices:l,multi:i,deadline:c,invalid:a}}function Ma(e,t,n,i){let s=new Map(t.map((u)=>[u.name,u.users])),r=e.map((u,f)=>(s.get(Be[f].name)??[]).filter((l)=>!n.has(l))),o=[];if(!i){let u=new Map;for(let f of r)for(let l of f)u.set(l,(u.get(l)??0)+1);for(let[f,l]of u)if(l>1)o.push(f)}let a=new Set(o),c=r.map((u)=>u.filter((f)=>!a.has(f)));return{tallies:e.map((u,f)=>({choice:u,count:c[f].length})),voters:c,ambiguous:o}}class qt extends Error{retryAfter;constructor(e){super(`Slack rate limited — retry after ${e}s`);this.name="RateLimitError",this.retryAfter=e}}function ki(){return(process.env.SLACK_API_BASE??"https://slack.com/api").replace(/\/$/,"")}async function Na(e,t,n,i){let s={};if(i)s.Cookie=`d=${i}`;let r=await fetch(`${ki()}/${t}`,{...n,headers:{...n.headers??{},Authorization:`Bearer ${e}`,...s}});if(r.status===429){let a=parseInt(r.headers.get("retry-after")??"60",10);throw new qt(isNaN(a)?60:a)}let o=await r.json();if(o.ok!==!0){let a=o.error??"unknown";if(a==="ratelimited")throw new qt(60);if(a==="invalid_auth"&&e.startsWith("xoxc-")&&!i)throw Error(`Desktop app token (xoxc-) needs its session cookie to be accepted by the public Slack API.
136
+ `).replace(/^\*/,"").replace(/\*$/,""),c=[],u=[];if(s){let f=t.length-2;if(Ul(t[f]))f--;if(t[f]!=="")return{kind:"other"};if(f--,t[f]==="_11 番目以降はリアクションがないので、返信で答えてください。_"){f--;while(f>=0&&/^\(\d+\) /.test(t[f]))u.unshift(t[f].replace(/^\(\d+\) /,"")),f--;if(t[f]!=="")return{kind:"other"};f--}let l=[];while(f>=0){let d=t[f];if(!Re.some((h)=>d.startsWith(`${h.glyph} `)||d===h.glyph))break;l.unshift(d),f--}if(!l.length||l.length>ts)return{kind:"other"};for(let d=0;d<l.length;d++){let h=Re[d].glyph;if(!(l[d].startsWith(`${h} `)||l[d]===h))return{kind:"other"};c.push(l[d].slice(h.length+1))}if(t[f]!=="")return{kind:"other"};if(f<o+1)return{kind:"other"};for(let d=0;d<u.length;d++)if(!t.includes(`(${d+11}) ${u[d]}`))return{kind:"other"}}return{kind:"open",question:a,reactable:c,overflow:u,threadOnly:i}}var xi=[{name:"one",glyph:"1️⃣"},{name:"two",glyph:"2️⃣"},{name:"three",glyph:"3️⃣"},{name:"four",glyph:"4️⃣"},{name:"five",glyph:"5️⃣"},{name:"six",glyph:"6️⃣"},{name:"seven",glyph:"7️⃣"},{name:"eight",glyph:"8️⃣"},{name:"nine",glyph:"9️⃣"},{name:"keycap_ten",glyph:"\uD83D\uDD1F"}],Ig=xi.length;function _i(e){let t=e.split(`
137
+ `),n=t[t.length-2];if(n===void 0||!n.startsWith("_:warning: 同時に複数選ばれているため回答として数えていません — どれか 1 つだけ残してください: ")||!n.endsWith("_"))return[];return[...n.matchAll(/<@([UW][A-Z0-9]+)>/g)].map((i)=>i[1])}function $a(e,t){let n=e.split(`
138
+ `);if(n.length<2)return e;if(_i(e).length)n.splice(n.length-2,1);if(t.length)n.splice(n.length-1,0,`${"_:warning: 同時に複数選ばれているため回答として数えていません — どれか 1 つだけ残してください: "}${t.map((s)=>`<@${s}>`).join(", ")}_`);let i=n.join(`
139
+ `);return i===e?e:i}function Oa(e){return e!==void 0&&e.startsWith("_:warning: 同時に複数選ばれているため回答として数えていません — どれか 1 つだけ残してください: ")&&e.endsWith("_")}var Jl="white_check_mark",Tg=`:${Jl}: `;var Me=xi,Ht=Me.length,cn="ballot_box_with_ballot",Si=`:${cn}: `,Ta="_下のリアクションで投票してください (1 人 1 票、押し直しで変更できます)。_",Pa="_下のリアクションで投票してください (当てはまるものを *いくつでも* 押せます)。_",ss="_締切: ",is="_",$i="bar_chart",ki=`:${$i}: `;function rs(e){return`:${Me[e].name}:`}function Ia(e,t){for(let n of[rs(t),Me[t].glyph])if(e.startsWith(`${n} `))return e.slice(n.length+1);return null}function Kl(e){return Me.some((t,n)=>e.startsWith(`${rs(n)} `)||e.startsWith(`${t.glyph} `))}function Ai(e){return e.replace(/\s*\n\s*/g," ")}function Ra(e,t,n,i={}){let s=!!i.multi,r=i.deadline??"",o=i.invalid??[];if(!n.length||n.length>Ht)throw Error(`poll needs 1..${Ht} choices, got ${n.length}`);let a=[`${Si}*${e}*`];if(t)a.push("",t);if(a.push(""),a.push(...n.map((c,u)=>`${rs(u)} ${Ai(c)}`)),a.push(""),r)a.push(`${ss}${Ai(r)}${is}`);return a.push(s?Pa:Ta),$a(a.join(`
140
+ `),s?[]:o)}function Ma(e,t){let n=t.reduce((s,r)=>s+r.count,0),i=[`${ki}*${e}*`,`_投票終了 (計 ${n} 票)_`,""];return i.push(...t.map((s,r)=>`${rs(r)} ×${s.count} ${Ai(s.choice)}`)),i.join(`
141
+ `)}function Ba(e){let t=e.split(`
142
+ `);if(e.startsWith(ki)){let d=t[0].slice(ki.length).replace(/^\*/,"").replace(/\*$/,""),h=[];for(let m=0;m<Me.length;m++){let p=t.map((C)=>Ia(C,m)).find((C)=>C!==null&&C.startsWith("×"));if(p===void 0)break;let y=/^×(\d+) (.*)$/.exec(p);if(!y)return{kind:"other"};h.push({choice:y[2],count:Number(y[1])})}if(!h.length)return{kind:"other"};return{kind:"closed",question:d,tallies:h}}let n=t[t.length-1]??"",i;if(n===Ta)i=!1;else if(n===Pa)i=!0;else return{kind:"other"};if(t[0].startsWith(Si))t[0]=t[0].slice(Si.length);if(!t[0].startsWith("*"))return{kind:"other"};let s=0;while(s<t.length&&!(t[s].endsWith("*")&&(s>0||t[0].length>1)))s++;if(s>=t.length)return{kind:"other"};let r=t.slice(0,s+1).join(`
143
+ `).replace(/^\*/,"").replace(/\*$/,""),o=t.length-2,a=_i(e);if(Oa(t[o]))o--;let c="",u=t[o];if(u!==void 0&&u.startsWith(ss)&&u.endsWith(is)&&u.length>ss.length+is.length)c=u.slice(ss.length,-is.length),o--;if(t[o]!=="")return{kind:"other"};o--;let f=[];while(o>=0){let d=t[o];if(!Kl(d))break;f.unshift(d),o--}if(!f.length||f.length>Ht)return{kind:"other"};let l=[];for(let d=0;d<f.length;d++){let h=Ia(f[d],d);if(h===null)return{kind:"other"};l.push(h)}if(t[o]!=="")return{kind:"other"};if(o<s+1)return{kind:"other"};return{kind:"open",question:r,choices:l,multi:i,deadline:c,invalid:a}}function Na(e,t,n,i){let s=new Map(t.map((u)=>[u.name,u.users])),r=e.map((u,f)=>(s.get(Me[f].name)??[]).filter((l)=>!n.has(l))),o=[];if(!i){let u=new Map;for(let f of r)for(let l of f)u.set(l,(u.get(l)??0)+1);for(let[f,l]of u)if(l>1)o.push(f)}let a=new Set(o),c=r.map((u)=>u.filter((f)=>!a.has(f)));return{tallies:e.map((u,f)=>({choice:u,count:c[f].length})),voters:c,ambiguous:o}}class qt extends Error{retryAfter;constructor(e){super(`Slack rate limited — retry after ${e}s`);this.name="RateLimitError",this.retryAfter=e}}function Oi(){return(process.env.SLACK_API_BASE??"https://slack.com/api").replace(/\/$/,"")}async function ja(e,t,n,i){let s={};if(i)s.Cookie=`d=${i}`;let r=await fetch(`${Oi()}/${t}`,{...n,headers:{...n.headers??{},Authorization:`Bearer ${e}`,...s}});if(r.status===429){let a=parseInt(r.headers.get("retry-after")??"60",10);throw new qt(isNaN(a)?60:a)}let o=await r.json();if(o.ok!==!0){let a=o.error??"unknown";if(a==="ratelimited")throw new qt(60);if(a==="invalid_auth"&&e.startsWith("xoxc-")&&!i)throw Error(`Desktop app token (xoxc-) needs its session cookie to be accepted by the public Slack API.
144
144
  Attach it: slack auth chrome (macOS) or slack auth firefox
145
145
  Or replace the token with an xoxp- user token:
146
146
  slack auth token`);if((a==="missing_scope"||a==="cannot_dm_bot")&&e.startsWith("xoxb-"))throw Error(`Slack error on ${t}: ${a} — ${a==="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"}.
147
147
  Tailing/DMing people and listing users need a user session, not a bot token.
148
148
  Switch workspace: slack auth ls then slack auth use <name>
149
- Or import your Slack desktop session: slack auth login`);throw Error(`Slack error on ${t}: ${a}`)}return o}async function Ul(e,t,n,i){let s={};if(i)s.Cookie=`d=${i}`;let r=await fetch(`${ki()}/${t}`,{...n,headers:{...n.headers??{},Authorization:`Bearer ${e}`,...s}});if(r.status===429){let a=parseInt(r.headers.get("retry-after")??"60",10);throw new qt(isNaN(a)?60:a)}let o=await r.json();if(o.ok!==!0){let a=o.error??"unknown";if(a==="ratelimited")throw new qt(60);if((a==="invalid_auth"||a==="not_authed")&&!e.startsWith("xoxc-"))throw Error(`The draft API requires a desktop app session token (xoxc-).
149
+ Or import your Slack desktop session: slack auth login`);throw Error(`Slack error on ${t}: ${a}`)}return o}async function zl(e,t,n,i){let s={};if(i)s.Cookie=`d=${i}`;let r=await fetch(`${Oi()}/${t}`,{...n,headers:{...n.headers??{},Authorization:`Bearer ${e}`,...s}});if(r.status===429){let a=parseInt(r.headers.get("retry-after")??"60",10);throw new qt(isNaN(a)?60:a)}let o=await r.json();if(o.ok!==!0){let a=o.error??"unknown";if(a==="ratelimited")throw new qt(60);if((a==="invalid_auth"||a==="not_authed")&&!e.startsWith("xoxc-"))throw Error(`The draft API requires a desktop app session token (xoxc-).
150
150
  Import from Slack desktop: slack auth login`);if((a==="invalid_auth"||a==="not_authed")&&!i)throw Error(`drafts.list also requires the xoxd session cookie.
151
- Attach it with: slack auth chrome (macOS) or slack auth firefox`);throw Error(`Slack error on ${t}: ${a}`)}return o}function Tt(e,t,n={},i){let s=new URLSearchParams({token:e,...n});return Ul(e,t,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s.toString()},i)}function ie(e,t,n,i){let s=new URLSearchParams(n).toString();return Na(e,`${t}?${s}`,{method:"GET"},i)}function Je(e,t,n,i){return Na(e,t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)},i)}async function va(e,t){let n=await ie(e,"auth.test",{},t);return{team:n.team??"",teamId:n.team_id??"",url:n.url??"",user:n.user??"",userId:n.user_id??""}}async function ja(e,t){let n={Authorization:`Bearer ${e}`};if(t)n.Cookie=`d=${t}`;let i=await fetch(`${ki()}/auth.test`,{method:"GET",headers:n});if(i.status===429){let o=parseInt(i.headers.get("retry-after")??"60",10);throw new qt(isNaN(o)?60:o)}let s=i.headers.get("x-oauth-scopes")??"",r=await i.json();if(r.ok!==!0)throw Error(`Slack error on auth.test: ${r.error??"unknown"}`);return{userId:r.user_id??"",user:r.user??"",botId:r.bot_id??"",team:r.team??"",url:r.url??"",scopes:s.split(",").map((o)=>o.trim()).filter(Boolean)}}async function Ze(e,t,n=20,i,s,r,o){let a={channel:t,limit:String(n)};if(i!==void 0)a.oldest=i;if(s!==void 0)a.cursor=s;if(o)a.inclusive="true";return ie(e,"conversations.history",a,r)}async function Ke(e,t,n,i=50,s){return ie(e,"conversations.replies",{channel:t,ts:n,limit:String(i)},s)}async function La(e,t,n){return ie(e,"files.info",{file:t},n)}async function Wa(e,t={},n){let i={count:String(Math.min(Math.max(t.count??100,1),200)),page:String(Math.max(t.page??1,1))};if(t.types)i.types=t.types;if(t.channel)i.channel=t.channel;if(t.user)i.user=t.user;return ie(e,"files.list",i,n)}async function Ua(e,t,n={},i){let s={list_id:t};if(n.limit)s.limit=String(n.limit);if(n.cursor)s.cursor=n.cursor;return Tt(e,"lists.records.list",s,i)}async function Ja(e,t,n,i,s){return ie(e,"search.messages",{query:t,sort:"timestamp",sort_dir:"desc",count:String(Math.min(Math.max(n,1),100)),page:String(Math.max(i,1))},s)}async function Ka(e,t,n){return Ja(e,t,100,1,n)}async function Ai(e,t,n,i){let r=1,o=[],a={ok:!0,messages:{}};while(!0){let u=await Ja(e,t,100,r,i),f=un(u,["messages","matches"]),l=Array.isArray(f)?f:[];o.push(...l);let d=Number(un(u,["messages","paging","pages"])??1);if(a=u,l.length===0||r>=d||o.length>=n)break;r+=1}let c=a;if(!c.messages)c.messages={};return c.messages.matches=o.slice(0,n),c}async function rs(e,t,n,i,s,r,o){let a=o?{channel:t,text:n}:{channel:t,text:n,blocks:[{type:"markdown",text:n}]};if(i!==void 0)a.thread_ts=i;if(s&&i!==void 0)a.reply_broadcast=!0;return(await Je(e,"chat.postMessage",a,r)).ts??""}async function za(e,t,n,i,s,r){let o={channel:t,text:n,post_at:i,blocks:[{type:"markdown",text:n}]};if(s!==void 0)o.thread_ts=s;return(await Je(e,"chat.scheduleMessage",o,r)).scheduled_message_id??""}async function Ha(e,t,n){let i={};if(t)i.channel=t;return ie(e,"chat.scheduledMessages.list",i,n)}async function qa(e,t,n,i){await Je(e,"chat.deleteScheduledMessage",{channel:t,scheduled_message_id:n},i)}async function ln(e,t,n,i){return(await ie(e,"chat.getPermalink",{channel:t,message_ts:n},i)).permalink??""}async function Yt(e,t,n,i,s,r){return(await Je(e,"chat.update",r?{channel:t,ts:n,text:i}:{channel:t,ts:n,text:i,blocks:[{type:"markdown",text:i}]},s)).ts??n}async function Ya(e,t,n,i){await Je(e,"chat.delete",{channel:t,ts:n},i)}async function ct(e,t,n,i,s){await Je(e,"reactions.add",{channel:t,timestamp:n,name:i},s)}async function Xa(e,t,n,i){return((await ie(e,"reactions.get",{channel:t,timestamp:n,full:"true"},i)).message?.reactions??[]).map((r)=>({name:String(r.name??""),users:Array.isArray(r.users)?r.users.map(String):[]}))}async function fn(e,t,n,i,s){await Je(e,"reactions.remove",{channel:t,timestamp:n,name:i},s)}async function Ga(e,t,n=!1,i){let s=await Je(e,"conversations.create",{name:t,is_private:n},i);return{id:s.channel?.id??"",name:s.channel?.name??t}}async function Va(e,t,n,i){await Je(e,"conversations.invite",{channel:t,users:n.join(",")},i)}async function dn(e,t){let n=[],i="";while(!0){let s={limit:"200",types:"public_channel,private_channel,im,mpim"};if(i)s.cursor=i;let r=await ie(e,"conversations.list",s,t);if(n.push(...r.channels??[]),i=r.response_metadata?.next_cursor??"",!i)break}return{channels:n}}async function Pt(e,t,n){let s=(await Je(e,"conversations.open",{users:t},n)).channel?.id;if(!s)throw Error(`Failed to open DM with user ${t}`);return s}function Ve(e){return e.toLowerCase().replace(/[-_\s]/g,"")}async function pn(e,t,n){if(!t.startsWith("@")){if(/^[UW][A-Za-z0-9]{6,}$/.test(t))return t;throw Error(`Expected @user or a user ID, got: ${t}`)}let i=Ve(t.slice(1)),s=await ie(e,"auth.test",{},n);if(i==="you"||i==="me"||Ve(s.user??"")===i){if(!s.user_id)throw Error("auth.test did not return user_id");return s.user_id}let r="";while(!0){let o={limit:"200"};if(r)o.cursor=r;let a=await ie(e,"users.list",o,n);for(let c of a.members??[]){let u=Ve(c.name??""),f=Ve(c.real_name??""),l=Ve(c.profile?.display_name??"");if(u===i||f===i||l&&l===i)return c.id??""}if(r=a.response_metadata?.next_cursor??"",!r)break}throw Error(`User not found: ${t}`)}function Rt(e){let t=e.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(!t)return;let n=t[1],i=t[2]&&t[3]?`${t[2]}.${t[3]}`:void 0,s=e.indexOf("?"),r=s>=0?new URLSearchParams(e.slice(s)):void 0,o=r?.get("thread_ts")??void 0,u={channel:r?.get("cid")??void 0??n};if(i)u.ts=i;if(o)u.threadTs=o;return u}function Jl(e){return Rt(e)?.channel}function Ba(e){return/^[CDG][A-Z0-9]{8,}$/.test(e)}async function De(e,t,n){let i=Jl(t);if(i)return i;if(!t.startsWith("@")&&!t.startsWith("#")){if(Ba(t))return t;throw Error(`Target must start with # or @ (or be a Slack URL/ID), got: ${t}`)}if(t.startsWith("#")&&Ba(t.slice(1)))return t.slice(1);let s=t.startsWith("@"),r=t.slice(1),o=Ve(r);if(s){let u=await ie(e,"auth.test",{},n);if(o==="you"||o==="me"||Ve(u.user??"")===o){let m=u.user_id;if(!m)throw Error("auth.test did not return user_id");let y=((await ie(e,"conversations.list",{types:"im",limit:"200"},n)).channels??[]).find((E)=>E.user===m);if(y?.id)return String(y.id);return Pt(e,m,n)}let l="",d="";while(!0){let m={limit:"200"};if(d)m.cursor=d;let p=await ie(e,"users.list",m,n);for(let y of p.members??[]){let E=Ve(y.name??""),F=Ve(y.real_name??""),k=Ve(y.profile?.display_name??"");if(E===o||F===o||k&&k===o){l=y.id??"";break}}if(l)break;if(d=p.response_metadata?.next_cursor??"",!d)break}if(!l)throw Error(`User not found: ${t}`);let h="";while(!0){let m={types:"im",limit:"200"};if(h)m.cursor=h;let p=await ie(e,"conversations.list",m,n);for(let y of p.channels??[])if(y.user===l)return String(y.id??"");if(h=p.response_metadata?.next_cursor??"",!h)break}throw Error(`No existing DM with ${t} (${l}). Open it once in Slack first.`)}let a=r.toLowerCase(),c="";while(!0){let u={limit:"200",types:"public_channel,private_channel",exclude_archived:"true"};if(c)u.cursor=c;let f=await ie(e,"conversations.list",u,n);for(let l of f.channels??[])if(String(l.name??"").toLowerCase()===a)return String(l.id??"");if(c=f.response_metadata?.next_cursor??"",!c)break}throw Error(`channel not found: ${t}`)}async function hn(e,t,n){try{let i=await ie(e,"users.info",{user:t},n),s=i.user?.profile?.display_name,r=s&&s.length>0?s:i.user?.real_name??i.user?.name??t,o=i.user?.name??t;return[r,o]}catch{return[t,t]}}async function ze(e,t,n){try{let i=await ie(e,"users.info",{user:t},n),s=i.user?.profile?.display_name;if(s&&s.length>0)return s;return i.user?.real_name??i.user?.name??t}catch{return t}}async function $i(e,t){let n=[],i="";while(!0){let s={limit:"200"};if(i)s.cursor=i;let r=await ie(e,"users.list",s,t);if(n.push(...r.members??[]),i=r.response_metadata?.next_cursor??"",!i)break}return{members:n}}async function Za(e,t,n){let i=[],s="";while(!0){let r={channel:t,limit:"200"};if(s)r.cursor=s;let o=await ie(e,"conversations.members",r,n);if(i.push(...o.members??[]),s=o.response_metadata?.next_cursor??"",!s)break}return i}async function gn(e,t){return Tt(e,"drafts.list",{},t)}async function Qa(e,t,n,i){let{randomUUID:s}=await import("node:crypto"),r=JSON.stringify([{type:"rich_text",elements:[{type:"rich_text_section",elements:[{type:"text",text:n}]}]}]);return Tt(e,"drafts.create",{client_msg_id:s(),destinations:JSON.stringify([{channel_id:t}]),blocks:r,file_ids:JSON.stringify([]),is_from_composer:"true"},i)}async function ec(e,t,n,i,s){let r=JSON.stringify([{type:"rich_text",elements:[{type:"rich_text_section",elements:[{type:"text",text:i}]}]}]),o=(Date.now()/1000).toFixed(6);return Tt(e,"drafts.update",{draft_id:t,client_last_updated_ts:o,destinations:JSON.stringify([{channel_id:n}]),blocks:r,file_ids:JSON.stringify([])},s)}async function tc(e,t,n){return Tt(e,"conversations.info",{channel:t},n)}async function os(e,t,n){return ie(e,"users.info",{user:t},n)}async function mn(e,t,n){return ie(e,"conversations.info",{channel:t},n)}async function nc(e,t,n){let i=(Date.now()/1000).toFixed(6);return Tt(e,"drafts.delete",{draft_id:t,client_last_updated_ts:i},n)}async function Oi(e,t){let n=await Tt(e,"auth.test",{},t);return{userId:String(n.user_id??""),teamId:String(n.team_id??"")}}async function sc(e,t,n,i={},s){let{statSync:r,readFileSync:o}=await import("node:fs"),{basename:a}=await import("node:path"),c=r(n),u=a(n),f=await ie(e,"files.getUploadURLExternal",{filename:u,length:String(c.size)},s),l=f.upload_url,d=f.file_id;if(!l||!d)throw Error("files.getUploadURLExternal returned no upload_url/file_id");let h=o(n),m=await fetch(l,{method:"POST",headers:{"Content-Type":"application/octet-stream"},body:h});if(!m.ok)throw Error(`Upload PUT failed: ${m.status} ${m.statusText}`);let p={files:[{id:d,title:i.title??u}],channel_id:t};if(i.threadTs)p.thread_ts=i.threadTs;if(i.initialComment)p.initial_comment=i.initialComment;let y=await Je(e,"files.completeUploadExternal",p,s),E={fileId:d},F=y.files?.[0]?.permalink;if(F)E.permalink=F;return E}function un(e,t){let n=e;for(let i of t){if(n===void 0||n===null)return;if(typeof i==="number"){if(!Array.isArray(n))return;n=n[i]??void 0}else{if(typeof n!=="object"||Array.isArray(n))return;n=n[i]}}return n}import{existsSync as Ql,readFileSync as ef}from"node:fs";import{homedir as tf}from"node:os";import{join as nf}from"node:path";import{existsSync as Kl,mkdirSync as zl,readFileSync as Hl,writeFileSync as ql}from"node:fs";import{homedir as Yl}from"node:os";import{dirname as Xl,join as Gl}from"node:path";var Vl=3600000,as={now:()=>Date.now(),path:()=>Gl(process.env.HOME||Yl(),".config","slack-cli","cache.json")},cs=!0,ut;function ic(){return{channels:{},users:{}}}function Ii(){if(ut)return ut;if(ut=ic(),!cs)return ut;try{let e=as.path();if(!Kl(e))return ut;let t=JSON.parse(Hl(e,"utf8"));for(let n of["channels","users"]){let i=t?.[n];if(!i||typeof i!=="object"||Array.isArray(i))continue;for(let[s,r]of Object.entries(i))if(r&&typeof r==="object"&&typeof r.value==="string"&&typeof r.expires==="number")ut[n][s]={value:r.value,expires:r.expires}}}catch{ut=ic()}return ut}function Zl(e){if(!cs)return;try{let t=as.path();zl(Xl(t),{recursive:!0}),ql(t,JSON.stringify(e,null,2)+`
152
- `)}catch{}}function rc(e,t){return e?`${e} ${t}`:void 0}function Ti(e,t,n){if(!cs)return;let i=rc(t,n);if(!i)return;let s=Ii()[e][i];if(!s)return;if(s.expires<=as.now()){delete Ii()[e][i];return}return s.value}function Pi(e,t,n,i,s=Vl){if(!cs)return;let r=rc(t,n);if(!r)return;let o=Ii();o[e][r]={value:i,expires:as.now()+s},Zl(o)}var Ri={marker:"pushpin",progress:{done:"white_check_mark",dropped:"no_entry_sign",doing:"eyes",pending:"hourglass_flowing_sand"},flags:{alert:"exclamation","needs-discussion":"thinking_face",waiting:"speech_balloon",blocked:"lock"}},Xt=["done","dropped","doing","pending"],cc=["alert","needs-discussion","waiting","blocked"];function sf(){return nf(process.env.HOME||tf(),".config","slack-cli","todo.json")}function us(e){return e.replace(/^:+|:+$/g,"")}function Dn(e=sf()){let t={marker:Ri.marker,progress:{...Ri.progress},flags:{...Ri.flags}};try{if(!Ql(e))return t;let n=JSON.parse(ef(e,"utf8"));if(typeof n.marker==="string"&&n.marker.trim())t.marker=us(n.marker.trim());for(let i of Xt){let s=n.progress?.[i];if(typeof s==="string"&&s.trim())t.progress[i]=us(s.trim())}for(let i of cc){let s=n.flags?.[i];if(typeof s==="string"&&s.trim())t.flags[i]=us(s.trim())}}catch{}return t}function oc(e,t,n=!1){return`${n?"-":""}${t?"has":"hasmy"}::${us(e)}:`}function uc(e,t,n={}){let i=n.shared===!0,s=(a)=>oc(a,i),r=(a)=>oc(a,i,!0),o=[];if(e==="untriaged")o.push(s(t.marker),...Xt.map((a)=>r(t.progress[a])));else if(e==="stuck")o.push(s(t.marker),r(t.progress.done),r(t.progress.dropped),`(${cc.map((a)=>s(t.flags[a])).join(" OR ")})`);else if(e==="open")o.push(s(t.marker),r(t.progress.done),r(t.progress.dropped));else{let a=Xt.indexOf(e);o.push(s(t.progress[e]));for(let c of Xt.slice(0,a))o.push(r(t.progress[c]))}if(n.in){let a=n.in.startsWith("#")||n.in.startsWith("@")?n.in:`#${n.in}`;o.push(`in:${a}`)}if(n.from){let a=n.from==="me"||n.from.startsWith("@")?n.from:`@${n.from}`;o.push(`from:${a}`)}return o.join(" ")}var rf=3,of={sleep:(e)=>new Promise((t)=>setTimeout(t,e))};async function Ae(e,t,n=rf){for(let i=0;;i++)try{return await t()}catch(s){if(!(s instanceof Ge))throw s;if(i>=n)throw Error(`Slack rate limit hit on ${e} — gave up after ${n} retries. Try again in a minute.`);console.error(`Warning: Slack rate limit hit on ${e} — backing off for ${s.retryAfter}s`),await of.sleep(s.retryAfter*1000)}}var ac=new Map;async function lc(e,t){let n=ac.get(e);if(n)return n;let i=await Ae("auth.test",()=>zt(e,t)),s={userId:i.userId,teamId:i.teamId};return ac.set(e,s),s}async function fc(e,t){return(await lc(e,t)).userId}async function dc(e,t){try{return(await lc(e,t)).teamId}catch{return""}}async function Mi(e,t,n,i){if(!t.startsWith("#"))return n(e,t,i);let s=await dc(e,i),r=Ti("channels",s,t);if(r)return r;let o=await Ae("resolveChannel",()=>n(e,t,i));return Pi("channels",s,t,o),o}async function pc(e,t,n,i){let s=await dc(e,i),r=Ti("users",s,t);if(r)return r;let o=await Ae("users.info",()=>n(e,t,i));if(o&&o!==t)Pi("users",s,t,o);return o}async function hc(e,t,n,i,s,r){let o=s.progress[i],a=await fc(e,r),c=await Ae("reactions.get",()=>Jo(e,t,n,r)),u=new Set(c.filter((h)=>h.users.includes(a)).map((h)=>h.name)),f=Xt.map((h)=>s.progress[h]).filter((h)=>u.has(h));if(f.length===1&&f[0]===o)return{noop:!0,removed:[],leftover:[]};if(!u.has(o))await Ae("reactions.add",()=>Wn(e,t,n,o,r));let l=[],d=[];for(let h of f){if(h===o)continue;try{await Ae("reactions.remove",()=>Un(e,t,n,h,r)),l.push(h)}catch{d.push(h)}}return{noop:!1,added:i,removed:l,leftover:d}}async function gc(e,t,n,i,s,r,o){let a=s.flags[i];if(r)await Ae("reactions.remove",()=>Un(e,t,n,a,o));else await Ae("reactions.add",()=>Wn(e,t,n,a,o));return a}var Bi=1000;async function mc(e,t,n,i={}){let s=i.limit??Bi,r=i.cookie,o=await fc(e,r),a=Xt.map((d)=>n.progress[d]),c=[],u=0,f,l=!1;while(u<s){let d=Math.min(200,s-u),h=await Ae("conversations.history",()=>on(e,t,d,void 0,f,r)),m=h.messages??[];u+=m.length;for(let p of m){let y=String(p.ts??"");if(!y)continue;let E=new Set((p.reactions??[]).filter((k)=>(k.users??[]).map(String).includes(o)).map((k)=>String(k.name??""))),F=a.filter((k)=>E.has(k));if(F.length<2)continue;c.push({ts:y,text:String(p.text??"").split(`
153
- `)[0]??"",emoji:F,keep:F[0]})}if(f=h.response_metadata?.next_cursor||void 0,!f||m.length===0)break;if(u>=s){l=!0;break}}if(i.fix)for(let d of c)try{try{await Ae("reactions.add",()=>Wn(e,t,d.ts,d.keep,r))}catch(h){if(!(h instanceof Error)||!/already_reacted/.test(h.message))throw h}for(let h of d.emoji){if(h===d.keep)continue;await Ae("reactions.remove",()=>Un(e,t,d.ts,h,r))}d.fixed=!0}catch(h){d.fixed=!1,d.error=h instanceof Error?h.message:String(h)}return{scanned:u,findings:c,truncated:l}}var af=!0,cf;function Ni(e){if(af=e,!e)cf=void 0}function Mt(e){return e.toLowerCase().replace(/[-_\s]/g,"")}function lt(e){return e&&typeof e==="object"&&!Array.isArray(e)?e:{}}function uf(e,t){let n=Mt(t),i=lt(e.profile);for(let r of[e.name,e.real_name,i.display_name,i.real_name])if(typeof r==="string"&&r&&Mt(r)===n)return!0;let s=typeof i.email==="string"?i.email.toLowerCase():"";return s!==""&&s===t.toLowerCase()}function lf(e){let t=lt(e.profile),n=new Set;for(let i of[t.display_name,e.real_name,e.name,t.real_name])if(typeof i==="string"&&i){let s=Mt(i);if(s.length>=2)n.add(s)}return[...n]}function ff(e,t){let n=Mt(e),i,s=!1;for(let r of t){let o=typeof r.id==="string"?r.id:"";if(!o)continue;for(let a of lf(r)){let c=-1;if(n===a)c=e.length;else for(let u of yc)if(e.length>u.length&&e.endsWith(u)&&Mt(e.slice(0,e.length-u.length))===a){c=e.length-u.length;break}if(c<0)continue;if(!i||a.length>i.formLen)i={userId:o,matchLen:c,formLen:a.length,display:Li(r)},s=!1;else if(a.length===i.formLen&&i.userId!==o)s=!0}}if(!i)return;return s?"ambiguous":{userId:i.userId,matchLen:i.matchLen,display:i.display}}async function Bt(e,t,n,i){let s=`[${wc}ー]+`,r=`${s}(?:[._-]+${s})*`,o=new RegExp(`(?<![A-Za-z0-9._@<-])@(${r})`,"gu"),a=new Set;for(let F of t.matchAll(o))a.add(F[1]);if(a.size===0)return{text:t,resolved:[],unresolved:[]};let c=new Map;for(let F of a)c.set(F,{status:"pending"});let u=(F)=>{for(let k of a){if(c.get(k).status!=="pending")continue;if(ji(k)){let C=ff(k,F);if(C==="ambiguous")c.set(k,{status:"ambiguous"});else if(C)c.set(k,{status:"resolved",userId:C.userId,matchLen:C.matchLen,display:C.display})}else{let C=F.filter((P)=>uf(P,k)),A=new Set(C.map((P)=>typeof P.id==="string"?P.id:"").filter(Boolean));if(A.size===1){let P=C.find((v)=>typeof v.id==="string");c.set(k,{status:"resolved",userId:P.id,matchLen:k.length,display:Li(P)})}else if(A.size>1)c.set(k,{status:"ambiguous"})}}},f=!1;try{let F=await zn(e,i);u((F.members??[]).map(lt)),f=!0}catch{f=!1}let l=[...a].some((F)=>c.get(F).status==="pending"),d=!1,h=!0;if(l&&n){d=!0;try{let F=await ii(e,n,i),k=[];for(let C of F){let A=lt(await ri(e,C,i)),P=lt(A.user);if(typeof P.id!=="string")P.id=C;k.push(P)}u(k)}catch{h=!1}}let m=f&&(n?d&&h:!0),p=[],y=[];for(let F of a){let k=c.get(F);if(k.status==="resolved")p.push({surface:`@${F.slice(0,k.matchLen)}`,display:k.display,userId:k.userId});else if(k.status==="ambiguous")y.push({surface:`@${F}`,reason:"ambiguous"});else y.push({surface:`@${F}`,reason:m?"no-match":"unavailable"})}return{text:t.replace(o,(F,k)=>{let C=c.get(k);if(C&&C.status==="resolved")return`<@${C.userId}>${k.slice(C.matchLen)}`;return F}),resolved:p,unresolved:y}}function yn(e){let t=[],n=!1;for(let i of e)if(i.reason==="ambiguous")t.push(`${i.surface} matches multiple people — not tagged, sent as plain text (use <@USERID> to tag)`);else if(i.reason==="unavailable"){if(n)continue;t.push("could not fetch the user list (users:read missing or an API/connection error) — @mentions not tagged, sent as plain text"),n=!0}else t.push(`${i.surface} matched no one — not tagged, sent as plain text`);return t}async function Dc(e,t,n,i={}){let s=i.warn??((o)=>process.stderr.write(`${o}
154
- `)),r=await Bt(e,t,n,i.cookie);for(let o of yn(r.unresolved))s(`warn: ${o}`);return r.text}var yc=["さん","さま","様","君","くん","ちゃん","氏","先生","先輩","殿","老师","老師","兄","姐","哥","姐妹"],wc="\\p{Script=Han}\\p{Script=Hiragana}\\p{Script=Katakana}A-Za-z0-9";function ji(e){return/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}]/u.test(e)}function df(e){let t=[],n=new RegExp(`([${wc}]{1,12})(${yc.join("|")})`,"gu");for(let i of e.matchAll(n))t.push({ref:i[1],honorific:i[2]});for(let i of e.matchAll(/\b(?:dear|hi|hello|hey)\b[ \t]+([A-Z][A-Za-z'’-]{1,20})/gi))t.push({ref:i[1],honorific:""});for(let i of e.matchAll(/(?:^|\n)[ \t]*([A-Z][A-Za-z'’-]{1,20}),/g))t.push({ref:i[1],honorific:""});return t}function pf(e){let t=lt(e.profile),n=new Set;for(let i of[e.name,e.real_name,t.display_name,t.real_name]){if(typeof i!=="string"||!i)continue;for(let s of[i,...i.split(/\s+/)]){let r=Mt(s);if(r.length>=2)n.add(r)}}return[...n]}function hf(e,t){let n=Mt(e);if(n.length<2)return;for(let i of t)if(n===i)return i;if(ji(e)){for(let i of t)if(n.includes(i)||i.includes(n))return i}return}function Li(e){return[lt(e.profile).display_name,e.real_name,e.name].filter((i)=>typeof i==="string"&&i!=="")[0]??String(e.id??"?")}async function bc(e,t,n){let i=df(t);if(i.length===0)return[];let s=new Set;for(let u of t.matchAll(/<@([A-Z0-9]+)(?:\|[^>]*)?>/g))s.add(u[1]);let o=((await zn(e,n)).members??[]).map(lt).filter((u)=>u.deleted!==!0&&u.is_bot!==!0&&u.id!=="USLACKBOT").map((u)=>({id:typeof u.id==="string"?u.id:"",forms:pf(u),display:Li(u)})).filter((u)=>u.id!==""),a=[],c=new Set;for(let{ref:u,honorific:f}of i)for(let l of o){let d=hf(u,l.forms);if(!d)continue;if(s.has(l.id)||c.has(l.id))break;c.add(l.id),a.push({surface:ji(u)?`${d}${f}`:u,display:l.display,userId:l.id});break}return a}async function Gt(e,t,n,i){let s=t,r=[],o=s,a=0;while(!0){let c=o.indexOf("<@U",a);if(c===-1)break;let u=o.slice(c+2),f=u.search(/[>|]/),l=f===-1?u:u.slice(0,f);if(l.length>=9)r.push(l);a=c+1}for(let c of r){if(!n.has(c))n.set(c,await Kn(e,c,i));let u=n.get(c)??c;s=s.replaceAll(`<@${c}>`,`@${u}`),s=s.replace(new RegExp(`<@${c}\\|[^>]*>`,"g"),`@${u}`)}return s}function wn(e){return e.replace(/<!date\^(\d+)\^[^|>]*(?:\|([^>]*))?>/g,(t,n,i)=>{let s=Number(n);if(!Number.isFinite(s))return i??"date";let r=new Date(s*1000);if(Number.isNaN(r.getTime()))return i??"date";let o=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],a=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],c=o[r.getUTCDay()]??"",u=a[r.getUTCMonth()]??"";return`${c}, ${u} ${String(r.getUTCDate()).padStart(2,"0")}, ${r.getUTCFullYear()}`})}function Fc(e,t=new Date){let n=new Date(e*1000),i=vi(t),s=vi(new Date(t.getTime()-86400000)),r=vi(n);if(r===i)return"Today";if(r===s)return"Yesterday";let o=n.toLocaleDateString("en-US",{weekday:"long"}),a=n.toLocaleDateString("en-US",{month:"short"});return`${o}, ${a} ${String(n.getDate()).padStart(2,"0")}`}function vi(e){return`${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`}function Cc(e){let t=new Date(e*1000),n=t.getFullYear(),i=String(t.getMonth()+1).padStart(2,"0"),s=String(t.getDate()).padStart(2,"0"),r=String(t.getHours()).padStart(2,"0"),o=String(t.getMinutes()).padStart(2,"0");return`${n}-${i}-${s} ${r}:${o}`}function Ec(e=new Date){let t=process.env.SLACK_QUIET_TZ??"Asia/Tokyo",n=Number(process.env.SLACK_QUIET_START??23),i=Number(process.env.SLACK_QUIET_END??8),s,r;try{let c=new Intl.DateTimeFormat("en-GB",{timeZone:t,hour12:!1,weekday:"short",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"});r=c.format(e),s=Number(c.formatToParts(e).find((u)=>u.type==="hour")?.value??"12")}catch{return null}let o=n>i?s>=n||s<i:s>=n&&s<i,a=`\uD83D\uDD50 ${r} (${t})`;if(!o)return a;return`${a}
155
- ⚠ QUIET HOURS (${n}:00-${i}:00) — this will buzz a phone. Send only for a production incident; otherwise hold it until morning.`}function bn(e){if(!$c(e))return;let t=mf(e,"utf8");for(let n of t.split(`
156
- `)){let i=n.trim();if(!i||i.startsWith("#"))continue;let s=i.indexOf("=");if(s===-1)continue;let r=i.slice(0,s).trim(),o=i.slice(s+1).trim();if(o.startsWith('"')&&o.endsWith('"')||o.startsWith("'")&&o.endsWith("'"))o=o.slice(1,-1);if(!(r in process.env))process.env[r]=o}}function yf(e){Df(e,{recursive:!0});let t=ft(e,".gitignore");if(!$c(t))Oc(t,`*
157
- `)}function wf(){bn(ft(xc(),".slack-cli",".env.local")),bn(ft(xc(),".config/slack-cli",".env")),bn(ft(process.cwd(),".slack-cli",".env.local")),bn(ft(process.cwd(),".env.local")),bn(ft(process.cwd(),".env"))}function bf(e){return gf("sha256").update(e).digest("hex")}function T(e){return e&&typeof e==="object"&&!Array.isArray(e)?e:{}}function X(e){return Array.isArray(e)?e:[]}function ls(e){return Number(e.ts??0)}async function Ic(e,t,n){let i=t.user;if(typeof i==="string"){if(!n.has(i))n.set(i,await ze(e,i));return n.get(i)??i}return typeof t.username==="string"?t.username:"bot"}function Wi(e){let t=new Date(e*1000),n=t.getUTCFullYear(),i=String(t.getUTCMonth()+1).padStart(2,"0"),s=String(t.getUTCDate()).padStart(2,"0"),r=String(t.getUTCHours()).padStart(2,"0"),o=String(t.getUTCMinutes()).padStart(2,"0"),a=String(t.getUTCSeconds()).padStart(2,"0");return`${n}-${i}-${s} ${r}:${o}:${a}`}function Ji(e){let[t,n="000000"]=e.split("."),i=Number(t),s=new Date(i*1000),r=s.getUTCFullYear(),o=String(s.getUTCMonth()+1).padStart(2,"0"),a=String(s.getUTCDate()).padStart(2,"0"),c=String(s.getUTCHours()).padStart(2,"0"),u=String(s.getUTCMinutes()).padStart(2,"0"),f=String(s.getUTCSeconds()).padStart(2,"0"),l=n.padEnd(6,"0").slice(0,6);return`${r}-${o}-${a}T${c}:${u}:${f}.${l}`}function Ki(e){let t=e.match(/^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})\.(\d{6})$/);if(!t)throw Error(`Invalid message timestamp "${e}" \u2014 expected 2026-05-11T06:01:04.000100`);let n=Date.parse(t[1]+"Z");if(isNaN(n))throw Error(`Cannot parse date in "${e}"`);return`${Math.floor(n/1000)}.${t[2]}`}function Ff(e){return/^\d{4}-\d{2}-\d{2}T/.test(e)?Ki(e):e}async function ps(e,t,n,i,s){let r=typeof t.ts==="string"?t.ts:`${ls(t)}.000000`,o=Ji(r),a="?";if(typeof t.user==="string"){let F=t.user,k="@"+F;if(!n.has(k)){let C=await pc(e,F,async(A,P,v)=>(await hn(A,P,v))[1],s);n.set(k,C)}a=n.get(k)??F}else if(typeof t.username==="string")a=t.username;let c=typeof t.text==="string"?t.text:"",f=wn(await Gt(e,c,n,s)).split(`
151
+ Attach it with: slack auth chrome (macOS) or slack auth firefox`);throw Error(`Slack error on ${t}: ${a}`)}return o}function Pt(e,t,n={},i){let s=new URLSearchParams({token:e,...n});return zl(e,t,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s.toString()},i)}function oe(e,t,n,i){let s=new URLSearchParams(n).toString();return ja(e,`${t}?${s}`,{method:"GET"},i)}function Je(e,t,n,i){return ja(e,t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)},i)}async function La(e,t){let n=await oe(e,"auth.test",{},t);return{team:n.team??"",teamId:n.team_id??"",url:n.url??"",user:n.user??"",userId:n.user_id??""}}async function Wa(e,t){let n={Authorization:`Bearer ${e}`};if(t)n.Cookie=`d=${t}`;let i=await fetch(`${Oi()}/auth.test`,{method:"GET",headers:n});if(i.status===429){let o=parseInt(i.headers.get("retry-after")??"60",10);throw new qt(isNaN(o)?60:o)}let s=i.headers.get("x-oauth-scopes")??"",r=await i.json();if(r.ok!==!0)throw Error(`Slack error on auth.test: ${r.error??"unknown"}`);return{userId:r.user_id??"",user:r.user??"",botId:r.bot_id??"",team:r.team??"",url:r.url??"",scopes:s.split(",").map((o)=>o.trim()).filter(Boolean)}}async function Qe(e,t,n=20,i,s,r,o){let a={channel:t,limit:String(n)};if(i!==void 0)a.oldest=i;if(s!==void 0)a.cursor=s;if(o)a.inclusive="true";return oe(e,"conversations.history",a,r)}async function Ke(e,t,n,i=50,s){return oe(e,"conversations.replies",{channel:t,ts:n,limit:String(i)},s)}async function Ua(e,t,n){return oe(e,"files.info",{file:t},n)}async function Ja(e,t={},n){let i={count:String(Math.min(Math.max(t.count??100,1),200)),page:String(Math.max(t.page??1,1))};if(t.types)i.types=t.types;if(t.channel)i.channel=t.channel;if(t.user)i.user=t.user;return oe(e,"files.list",i,n)}async function Ka(e,t,n={},i){let s={list_id:t};if(n.limit)s.limit=String(n.limit);if(n.cursor)s.cursor=n.cursor;return Pt(e,"lists.records.list",s,i)}async function za(e,t,n,i,s){return oe(e,"search.messages",{query:t,sort:"timestamp",sort_dir:"desc",count:String(Math.min(Math.max(n,1),100)),page:String(Math.max(i,1))},s)}async function Ha(e,t,n){return za(e,t,100,1,n)}async function Ii(e,t,n,i){let r=1,o=[],a={ok:!0,messages:{}};while(!0){let u=await za(e,t,100,r,i),f=un(u,["messages","matches"]),l=Array.isArray(f)?f:[];o.push(...l);let d=Number(un(u,["messages","paging","pages"])??1);if(a=u,l.length===0||r>=d||o.length>=n)break;r+=1}let c=a;if(!c.messages)c.messages={};return c.messages.matches=o.slice(0,n),c}async function os(e,t,n,i,s,r,o){let a=o?{channel:t,text:n}:{channel:t,text:n,blocks:[{type:"markdown",text:n}]};if(i!==void 0)a.thread_ts=i;if(s&&i!==void 0)a.reply_broadcast=!0;return(await Je(e,"chat.postMessage",a,r)).ts??""}async function qa(e,t,n,i,s,r){let o={channel:t,text:n,post_at:i,blocks:[{type:"markdown",text:n}]};if(s!==void 0)o.thread_ts=s;return(await Je(e,"chat.scheduleMessage",o,r)).scheduled_message_id??""}async function Ya(e,t,n){let i={};if(t)i.channel=t;return oe(e,"chat.scheduledMessages.list",i,n)}async function Xa(e,t,n,i){await Je(e,"chat.deleteScheduledMessage",{channel:t,scheduled_message_id:n},i)}async function ln(e,t,n,i){return(await oe(e,"chat.getPermalink",{channel:t,message_ts:n},i)).permalink??""}async function Yt(e,t,n,i,s,r){return(await Je(e,"chat.update",r?{channel:t,ts:n,text:i}:{channel:t,ts:n,text:i,blocks:[{type:"markdown",text:i}]},s)).ts??n}async function Ga(e,t,n,i){await Je(e,"chat.delete",{channel:t,ts:n},i)}async function ut(e,t,n,i,s){await Je(e,"reactions.add",{channel:t,timestamp:n,name:i},s)}async function Va(e,t,n,i){return((await oe(e,"reactions.get",{channel:t,timestamp:n,full:"true"},i)).message?.reactions??[]).map((r)=>({name:String(r.name??""),users:Array.isArray(r.users)?r.users.map(String):[]}))}async function fn(e,t,n,i,s){await Je(e,"reactions.remove",{channel:t,timestamp:n,name:i},s)}async function Za(e,t,n=!1,i){let s=await Je(e,"conversations.create",{name:t,is_private:n},i);return{id:s.channel?.id??"",name:s.channel?.name??t}}async function Qa(e,t,n,i){await Je(e,"conversations.invite",{channel:t,users:n.join(",")},i)}async function dn(e,t){let n=[],i="";while(!0){let s={limit:"200",types:"public_channel,private_channel,im,mpim"};if(i)s.cursor=i;let r=await oe(e,"conversations.list",s,t);if(n.push(...r.channels??[]),i=r.response_metadata?.next_cursor??"",!i)break}return{channels:n}}async function Rt(e,t,n){let s=(await Je(e,"conversations.open",{users:t},n)).channel?.id;if(!s)throw Error(`Failed to open DM with user ${t}`);return s}function Ze(e){return e.toLowerCase().replace(/[-_\s]/g,"")}async function pn(e,t,n){if(!t.startsWith("@")){if(/^[UW][A-Za-z0-9]{6,}$/.test(t))return t;throw Error(`Expected @user or a user ID, got: ${t}`)}let i=Ze(t.slice(1)),s=await oe(e,"auth.test",{},n);if(i==="you"||i==="me"||Ze(s.user??"")===i){if(!s.user_id)throw Error("auth.test did not return user_id");return s.user_id}let r="";while(!0){let o={limit:"200"};if(r)o.cursor=r;let a=await oe(e,"users.list",o,n);for(let c of a.members??[]){let u=Ze(c.name??""),f=Ze(c.real_name??""),l=Ze(c.profile?.display_name??"");if(u===i||f===i||l&&l===i)return c.id??""}if(r=a.response_metadata?.next_cursor??"",!r)break}throw Error(`User not found: ${t}`)}function Mt(e){let t=e.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(!t)return;let n=t[1],i=t[2]&&t[3]?`${t[2]}.${t[3]}`:void 0,s=e.indexOf("?"),r=s>=0?new URLSearchParams(e.slice(s)):void 0,o=r?.get("thread_ts")??void 0,u={channel:r?.get("cid")??void 0??n};if(i)u.ts=i;if(o)u.threadTs=o;return u}function Hl(e){return Mt(e)?.channel}function va(e){return/^[CDG][A-Z0-9]{8,}$/.test(e)}async function ye(e,t,n){let i=Hl(t);if(i)return i;if(!t.startsWith("@")&&!t.startsWith("#")){if(va(t))return t;throw Error(`Target must start with # or @ (or be a Slack URL/ID), got: ${t}`)}if(t.startsWith("#")&&va(t.slice(1)))return t.slice(1);let s=t.startsWith("@"),r=t.slice(1),o=Ze(r);if(s){let u=await oe(e,"auth.test",{},n);if(o==="you"||o==="me"||Ze(u.user??"")===o){let m=u.user_id;if(!m)throw Error("auth.test did not return user_id");let y=((await oe(e,"conversations.list",{types:"im",limit:"200"},n)).channels??[]).find((C)=>C.user===m);if(y?.id)return String(y.id);return Rt(e,m,n)}let l="",d="";while(!0){let m={limit:"200"};if(d)m.cursor=d;let p=await oe(e,"users.list",m,n);for(let y of p.members??[]){let C=Ze(y.name??""),F=Ze(y.real_name??""),k=Ze(y.profile?.display_name??"");if(C===o||F===o||k&&k===o){l=y.id??"";break}}if(l)break;if(d=p.response_metadata?.next_cursor??"",!d)break}if(!l)throw Error(`User not found: ${t}`);let h="";while(!0){let m={types:"im",limit:"200"};if(h)m.cursor=h;let p=await oe(e,"conversations.list",m,n);for(let y of p.channels??[])if(y.user===l)return String(y.id??"");if(h=p.response_metadata?.next_cursor??"",!h)break}throw Error(`No existing DM with ${t} (${l}). Open it once in Slack first.`)}let a=r.toLowerCase(),c="";while(!0){let u={limit:"200",types:"public_channel,private_channel",exclude_archived:"true"};if(c)u.cursor=c;let f=await oe(e,"conversations.list",u,n);for(let l of f.channels??[])if(String(l.name??"").toLowerCase()===a)return String(l.id??"");if(c=f.response_metadata?.next_cursor??"",!c)break}throw Error(`channel not found: ${t}`)}async function hn(e,t,n){try{let i=await oe(e,"users.info",{user:t},n),s=i.user?.profile?.display_name,r=s&&s.length>0?s:i.user?.real_name??i.user?.name??t,o=i.user?.name??t;return[r,o]}catch{return[t,t]}}async function ze(e,t,n){try{let i=await oe(e,"users.info",{user:t},n),s=i.user?.profile?.display_name;if(s&&s.length>0)return s;return i.user?.real_name??i.user?.name??t}catch{return t}}async function Ti(e,t){let n=[],i="";while(!0){let s={limit:"200"};if(i)s.cursor=i;let r=await oe(e,"users.list",s,t);if(n.push(...r.members??[]),i=r.response_metadata?.next_cursor??"",!i)break}return{members:n}}async function ec(e,t,n){let i=[],s="";while(!0){let r={channel:t,limit:"200"};if(s)r.cursor=s;let o=await oe(e,"conversations.members",r,n);if(i.push(...o.members??[]),s=o.response_metadata?.next_cursor??"",!s)break}return i}async function gn(e,t){return Pt(e,"drafts.list",{},t)}async function tc(e,t,n,i){let{randomUUID:s}=await import("node:crypto"),r=JSON.stringify([{type:"rich_text",elements:[{type:"rich_text_section",elements:[{type:"text",text:n}]}]}]);return Pt(e,"drafts.create",{client_msg_id:s(),destinations:JSON.stringify([{channel_id:t}]),blocks:r,file_ids:JSON.stringify([]),is_from_composer:"true"},i)}async function nc(e,t,n,i,s){let r=JSON.stringify([{type:"rich_text",elements:[{type:"rich_text_section",elements:[{type:"text",text:i}]}]}]),o=(Date.now()/1000).toFixed(6);return Pt(e,"drafts.update",{draft_id:t,client_last_updated_ts:o,destinations:JSON.stringify([{channel_id:n}]),blocks:r,file_ids:JSON.stringify([])},s)}async function sc(e,t,n){return Pt(e,"conversations.info",{channel:t},n)}async function mn(e,t,n){return oe(e,"users.info",{user:t},n)}async function Dn(e,t,n){return oe(e,"conversations.info",{channel:t},n)}async function ic(e,t,n){let i=(Date.now()/1000).toFixed(6);return Pt(e,"drafts.delete",{draft_id:t,client_last_updated_ts:i},n)}async function Pi(e,t){let n=await Pt(e,"auth.test",{},t);return{userId:String(n.user_id??""),teamId:String(n.team_id??"")}}async function rc(e,t,n,i={},s){let{statSync:r,readFileSync:o}=await import("node:fs"),{basename:a}=await import("node:path"),c=r(n),u=a(n),f=await oe(e,"files.getUploadURLExternal",{filename:u,length:String(c.size)},s),l=f.upload_url,d=f.file_id;if(!l||!d)throw Error("files.getUploadURLExternal returned no upload_url/file_id");let h=o(n),m=await fetch(l,{method:"POST",headers:{"Content-Type":"application/octet-stream"},body:h});if(!m.ok)throw Error(`Upload PUT failed: ${m.status} ${m.statusText}`);let p={files:[{id:d,title:i.title??u}],channel_id:t};if(i.threadTs)p.thread_ts=i.threadTs;if(i.initialComment)p.initial_comment=i.initialComment;let y=await Je(e,"files.completeUploadExternal",p,s),C={fileId:d},F=y.files?.[0]?.permalink;if(F)C.permalink=F;return C}function un(e,t){let n=e;for(let i of t){if(n===void 0||n===null)return;if(typeof i==="number"){if(!Array.isArray(n))return;n=n[i]??void 0}else{if(typeof n!=="object"||Array.isArray(n))return;n=n[i]}}return n}import{existsSync as nf,readFileSync as sf}from"node:fs";import{homedir as rf}from"node:os";import{join as of}from"node:path";import{existsSync as ql,mkdirSync as Yl,readFileSync as Xl,writeFileSync as Gl}from"node:fs";import{homedir as Vl}from"node:os";import{dirname as Zl,join as Ql}from"node:path";var ef=3600000,as={now:()=>Date.now(),path:()=>Ql(process.env.HOME||Vl(),".config","slack-cli","cache.json")},cs=!0,lt;function oc(){return{channels:{},users:{}}}function Ri(){if(lt)return lt;if(lt=oc(),!cs)return lt;try{let e=as.path();if(!ql(e))return lt;let t=JSON.parse(Xl(e,"utf8"));for(let n of["channels","users"]){let i=t?.[n];if(!i||typeof i!=="object"||Array.isArray(i))continue;for(let[s,r]of Object.entries(i))if(r&&typeof r==="object"&&typeof r.value==="string"&&typeof r.expires==="number")lt[n][s]={value:r.value,expires:r.expires}}}catch{lt=oc()}return lt}function tf(e){if(!cs)return;try{let t=as.path();Yl(Zl(t),{recursive:!0}),Gl(t,JSON.stringify(e,null,2)+`
152
+ `)}catch{}}function ac(e,t){return e?`${e} ${t}`:void 0}function us(e,t,n){if(!cs)return;let i=ac(t,n);if(!i)return;let s=Ri()[e][i];if(!s)return;if(s.expires<=as.now()){delete Ri()[e][i];return}return s.value}function ls(e,t,n,i,s=ef){if(!cs)return;let r=ac(t,n);if(!r)return;let o=Ri();o[e][r]={value:i,expires:as.now()+s},tf(o)}var Mi={marker:"pushpin",progress:{done:"white_check_mark",dropped:"no_entry_sign",doing:"eyes",pending:"hourglass_flowing_sand"},flags:{alert:"exclamation","needs-discussion":"thinking_face",waiting:"speech_balloon",blocked:"lock"}},Xt=["done","dropped","doing","pending"],fc=["alert","needs-discussion","waiting","blocked"];function af(){return of(process.env.HOME||rf(),".config","slack-cli","todo.json")}function fs(e){return e.replace(/^:+|:+$/g,"")}function yn(e=af()){let t={marker:Mi.marker,progress:{...Mi.progress},flags:{...Mi.flags}};try{if(!nf(e))return t;let n=JSON.parse(sf(e,"utf8"));if(typeof n.marker==="string"&&n.marker.trim())t.marker=fs(n.marker.trim());for(let i of Xt){let s=n.progress?.[i];if(typeof s==="string"&&s.trim())t.progress[i]=fs(s.trim())}for(let i of fc){let s=n.flags?.[i];if(typeof s==="string"&&s.trim())t.flags[i]=fs(s.trim())}}catch{}return t}function cc(e,t,n=!1){return`${n?"-":""}${t?"has":"hasmy"}::${fs(e)}:`}function dc(e,t,n={}){let i=n.shared===!0,s=(a)=>cc(a,i),r=(a)=>cc(a,i,!0),o=[];if(e==="untriaged")o.push(s(t.marker),...Xt.map((a)=>r(t.progress[a])));else if(e==="stuck")o.push(s(t.marker),r(t.progress.done),r(t.progress.dropped),`(${fc.map((a)=>s(t.flags[a])).join(" OR ")})`);else if(e==="open")o.push(s(t.marker),r(t.progress.done),r(t.progress.dropped));else{let a=Xt.indexOf(e);o.push(s(t.progress[e]));for(let c of Xt.slice(0,a))o.push(r(t.progress[c]))}if(n.in){let a=n.in.startsWith("#")||n.in.startsWith("@")?n.in:`#${n.in}`;o.push(`in:${a}`)}if(n.from){let a=n.from==="me"||n.from.startsWith("@")?n.from:`@${n.from}`;o.push(`from:${a}`)}return o.join(" ")}var cf=3,uf={sleep:(e)=>new Promise((t)=>setTimeout(t,e))};async function _e(e,t,n=cf){for(let i=0;;i++)try{return await t()}catch(s){if(!(s instanceof Ve))throw s;if(i>=n)throw Error(`Slack rate limit hit on ${e} — gave up after ${n} retries. Try again in a minute.`);console.error(`Warning: Slack rate limit hit on ${e} — backing off for ${s.retryAfter}s`),await uf.sleep(s.retryAfter*1000)}}var uc=new Map;async function pc(e,t){let n=uc.get(e);if(n)return n;let i=await _e("auth.test",()=>zt(e,t)),s={userId:i.userId,teamId:i.teamId};return uc.set(e,s),s}async function hc(e,t){return(await pc(e,t)).userId}async function Bi(e,t){try{return(await pc(e,t)).teamId}catch{return""}}async function Ni(e,t,n,i){if(!t.startsWith("#"))return n(e,t,i);let s=await Bi(e,i),r=us("channels",s,t);if(r)return r;let o=await _e("resolveChannel",()=>n(e,t,i));return ls("channels",s,t,o),o}async function gc(e,t,n,i){let s=await Bi(e,i),r=us("users",s,t);if(r)return r;let o=await _e("users.info",()=>n(e,t,i));if(o&&o!==t)ls("users",s,t,o);return o}async function mc(e,t,n,i){let s=await Bi(e,i),r=us("users",s,`tz:${t}`);if(r)return r==="?"?null:r;let o=null;try{let a=await _e("users.info",()=>n(e,t,i));if(a?.user?.is_bot===!0||t==="USLACKBOT")return lc(s,t,null);let c=a?.user?.tz;o=typeof c==="string"&&c?c:null}catch{return null}return lc(s,t,o)}function lc(e,t,n){return ls("users",e,`tz:${t}`,n??"?"),n}async function Dc(e,t,n,i,s,r){let o=s.progress[i],a=await hc(e,r),c=await _e("reactions.get",()=>zo(e,t,n,r)),u=new Set(c.filter((h)=>h.users.includes(a)).map((h)=>h.name)),f=Xt.map((h)=>s.progress[h]).filter((h)=>u.has(h));if(f.length===1&&f[0]===o)return{noop:!0,removed:[],leftover:[]};if(!u.has(o))await _e("reactions.add",()=>Un(e,t,n,o,r));let l=[],d=[];for(let h of f){if(h===o)continue;try{await _e("reactions.remove",()=>Jn(e,t,n,h,r)),l.push(h)}catch{d.push(h)}}return{noop:!1,added:i,removed:l,leftover:d}}async function yc(e,t,n,i,s,r,o){let a=s.flags[i];if(r)await _e("reactions.remove",()=>Jn(e,t,n,a,o));else await _e("reactions.add",()=>Un(e,t,n,a,o));return a}var vi=1000;async function wc(e,t,n,i={}){let s=i.limit??vi,r=i.cookie,o=await hc(e,r),a=Xt.map((d)=>n.progress[d]),c=[],u=0,f,l=!1;while(u<s){let d=Math.min(200,s-u),h=await _e("conversations.history",()=>on(e,t,d,void 0,f,r)),m=h.messages??[];u+=m.length;for(let p of m){let y=String(p.ts??"");if(!y)continue;let C=new Set((p.reactions??[]).filter((k)=>(k.users??[]).map(String).includes(o)).map((k)=>String(k.name??""))),F=a.filter((k)=>C.has(k));if(F.length<2)continue;c.push({ts:y,text:String(p.text??"").split(`
153
+ `)[0]??"",emoji:F,keep:F[0]})}if(f=h.response_metadata?.next_cursor||void 0,!f||m.length===0)break;if(u>=s){l=!0;break}}if(i.fix)for(let d of c)try{try{await _e("reactions.add",()=>Un(e,t,d.ts,d.keep,r))}catch(h){if(!(h instanceof Error)||!/already_reacted/.test(h.message))throw h}for(let h of d.emoji){if(h===d.keep)continue;await _e("reactions.remove",()=>Jn(e,t,d.ts,h,r))}d.fixed=!0}catch(h){d.fixed=!1,d.error=h instanceof Error?h.message:String(h)}return{scanned:u,findings:c,truncated:l}}var lf=!0,ff;function ji(e){if(lf=e,!e)ff=void 0}function Bt(e){return e.toLowerCase().replace(/[-_\s]/g,"")}function ft(e){return e&&typeof e==="object"&&!Array.isArray(e)?e:{}}function df(e,t){let n=Bt(t),i=ft(e.profile);for(let r of[e.name,e.real_name,i.display_name,i.real_name])if(typeof r==="string"&&r&&Bt(r)===n)return!0;let s=typeof i.email==="string"?i.email.toLowerCase():"";return s!==""&&s===t.toLowerCase()}function pf(e){let t=ft(e.profile),n=new Set;for(let i of[t.display_name,e.real_name,e.name,t.real_name])if(typeof i==="string"&&i){let s=Bt(i);if(s.length>=2)n.add(s)}return[...n]}function hf(e,t){let n=Bt(e),i,s=!1;for(let r of t){let o=typeof r.id==="string"?r.id:"";if(!o)continue;for(let a of pf(r)){let c=-1;if(n===a)c=e.length;else for(let u of Fc)if(e.length>u.length&&e.endsWith(u)&&Bt(e.slice(0,e.length-u.length))===a){c=e.length-u.length;break}if(c<0)continue;if(!i||a.length>i.formLen)i={userId:o,matchLen:c,formLen:a.length,display:Ui(r)},s=!1;else if(a.length===i.formLen&&i.userId!==o)s=!0}}if(!i)return;return s?"ambiguous":{userId:i.userId,matchLen:i.matchLen,display:i.display}}async function Nt(e,t,n,i){let s=`[${Cc}ー]+`,r=`${s}(?:[._-]+${s})*`,o=new RegExp(`(?<![A-Za-z0-9._@<-])@(${r})`,"gu"),a=new Set;for(let F of t.matchAll(o))a.add(F[1]);if(a.size===0)return{text:t,resolved:[],unresolved:[]};let c=new Map;for(let F of a)c.set(F,{status:"pending"});let u=(F)=>{for(let k of a){if(c.get(k).status!=="pending")continue;if(Wi(k)){let S=hf(k,F);if(S==="ambiguous")c.set(k,{status:"ambiguous"});else if(S)c.set(k,{status:"resolved",userId:S.userId,matchLen:S.matchLen,display:S.display})}else{let S=F.filter((I)=>df(I,k)),A=new Set(S.map((I)=>typeof I.id==="string"?I.id:"").filter(Boolean));if(A.size===1){let I=S.find((W)=>typeof W.id==="string");c.set(k,{status:"resolved",userId:I.id,matchLen:k.length,display:Ui(I)})}else if(A.size>1)c.set(k,{status:"ambiguous"})}}},f=!1;try{let F=await Hn(e,i);u((F.members??[]).map(ft)),f=!0}catch{f=!1}let l=[...a].some((F)=>c.get(F).status==="pending"),d=!1,h=!0;if(l&&n){d=!0;try{let F=await ai(e,n,i),k=[];for(let S of F){let A=ft(await ci(e,S,i)),I=ft(A.user);if(typeof I.id!=="string")I.id=S;k.push(I)}u(k)}catch{h=!1}}let m=f&&(n?d&&h:!0),p=[],y=[];for(let F of a){let k=c.get(F);if(k.status==="resolved")p.push({surface:`@${F.slice(0,k.matchLen)}`,display:k.display,userId:k.userId});else if(k.status==="ambiguous")y.push({surface:`@${F}`,reason:"ambiguous"});else y.push({surface:`@${F}`,reason:m?"no-match":"unavailable"})}return{text:t.replace(o,(F,k)=>{let S=c.get(k);if(S&&S.status==="resolved")return`<@${S.userId}>${k.slice(S.matchLen)}`;return F}),resolved:p,unresolved:y}}function wn(e){let t=[],n=!1;for(let i of e)if(i.reason==="ambiguous")t.push(`${i.surface} matches multiple people — not tagged, sent as plain text (use <@USERID> to tag)`);else if(i.reason==="unavailable"){if(n)continue;t.push("could not fetch the user list (users:read missing or an API/connection error) — @mentions not tagged, sent as plain text"),n=!0}else t.push(`${i.surface} matched no one — not tagged, sent as plain text`);return t}async function bc(e,t,n,i={}){let s=i.warn??((o)=>process.stderr.write(`${o}
154
+ `)),r=await Nt(e,t,n,i.cookie);for(let o of wn(r.unresolved))s(`warn: ${o}`);return r.text}var Fc=["さん","さま","様","君","くん","ちゃん","氏","先生","先輩","殿","老师","老師","兄","姐","哥","姐妹"],Cc="\\p{Script=Han}\\p{Script=Hiragana}\\p{Script=Katakana}A-Za-z0-9";function Wi(e){return/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}]/u.test(e)}function gf(e){let t=[],n=new RegExp(`([${Cc}]{1,12})(${Fc.join("|")})`,"gu");for(let i of e.matchAll(n))t.push({ref:i[1],honorific:i[2]});for(let i of e.matchAll(/\b(?:dear|hi|hello|hey)\b[ \t]+([A-Z][A-Za-z'’-]{1,20})/gi))t.push({ref:i[1],honorific:""});for(let i of e.matchAll(/(?:^|\n)[ \t]*([A-Z][A-Za-z'’-]{1,20}),/g))t.push({ref:i[1],honorific:""});return t}function mf(e){let t=ft(e.profile),n=new Set;for(let i of[e.name,e.real_name,t.display_name,t.real_name]){if(typeof i!=="string"||!i)continue;for(let s of[i,...i.split(/\s+/)]){let r=Bt(s);if(r.length>=2)n.add(r)}}return[...n]}function Df(e,t){let n=Bt(e);if(n.length<2)return;for(let i of t)if(n===i)return i;if(Wi(e)){for(let i of t)if(n.includes(i)||i.includes(n))return i}return}function Ui(e){return[ft(e.profile).display_name,e.real_name,e.name].filter((i)=>typeof i==="string"&&i!=="")[0]??String(e.id??"?")}async function Ec(e,t,n){let i=gf(t);if(i.length===0)return[];let s=new Set;for(let u of t.matchAll(/<@([A-Z0-9]+)(?:\|[^>]*)?>/g))s.add(u[1]);let o=((await Hn(e,n)).members??[]).map(ft).filter((u)=>u.deleted!==!0&&u.is_bot!==!0&&u.id!=="USLACKBOT").map((u)=>({id:typeof u.id==="string"?u.id:"",forms:mf(u),display:Ui(u)})).filter((u)=>u.id!==""),a=[],c=new Set;for(let{ref:u,honorific:f}of i)for(let l of o){let d=Df(u,l.forms);if(!d)continue;if(s.has(l.id)||c.has(l.id))break;c.add(l.id),a.push({surface:Wi(u)?`${d}${f}`:u,display:l.display,userId:l.id});break}return a}async function Gt(e,t,n,i){let s=t,r=[],o=s,a=0;while(!0){let c=o.indexOf("<@U",a);if(c===-1)break;let u=o.slice(c+2),f=u.search(/[>|]/),l=f===-1?u:u.slice(0,f);if(l.length>=9)r.push(l);a=c+1}for(let c of r){if(!n.has(c))n.set(c,await zn(e,c,i));let u=n.get(c)??c;s=s.replaceAll(`<@${c}>`,`@${u}`),s=s.replace(new RegExp(`<@${c}\\|[^>]*>`,"g"),`@${u}`)}return s}function bn(e){return e.replace(/<!date\^(\d+)\^[^|>]*(?:\|([^>]*))?>/g,(t,n,i)=>{let s=Number(n);if(!Number.isFinite(s))return i??"date";let r=new Date(s*1000);if(Number.isNaN(r.getTime()))return i??"date";let o=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],a=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],c=o[r.getUTCDay()]??"",u=a[r.getUTCMonth()]??"";return`${c}, ${u} ${String(r.getUTCDate()).padStart(2,"0")}, ${r.getUTCFullYear()}`})}function xc(e,t=new Date){let n=new Date(e*1000),i=Li(t),s=Li(new Date(t.getTime()-86400000)),r=Li(n);if(r===i)return"Today";if(r===s)return"Yesterday";let o=n.toLocaleDateString("en-US",{weekday:"long"}),a=n.toLocaleDateString("en-US",{month:"short"});return`${o}, ${a} ${String(n.getDate()).padStart(2,"0")}`}function Li(e){return`${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`}function _c(e){let t=new Date(e*1000),n=t.getFullYear(),i=String(t.getMonth()+1).padStart(2,"0"),s=String(t.getDate()).padStart(2,"0"),r=String(t.getHours()).padStart(2,"0"),o=String(t.getMinutes()).padStart(2,"0");return`${n}-${i}-${s} ${r}:${o}`}function Sc(e=new Date,t){let n=process.env.SLACK_QUIET_TZ??"Asia/Tokyo",i=!!t&&yf(t),s=i?t:n,r=Number(process.env.SLACK_QUIET_START??23),o=Number(process.env.SLACK_QUIET_END??8),a,c;try{let h=new Intl.DateTimeFormat("en-GB",{timeZone:s,hour12:!1,weekday:"short",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"});c=h.format(e),a=Number(h.formatToParts(e).find((m)=>m.type==="hour")?.value??"12")}catch{return null}let u=r>o?a>=r||a<o:a>=r&&a<o,f=i?`${s}, recipient`:`${s}, sender — recipient's timezone unknown`,l=`\uD83D\uDD50 ${c} (${f})`;if(!u)return l;return`${l}
155
+ ⚠ QUIET HOURS (${r}:00-${o}:00) — this will buzz a phone.${i?"":" Their local time may differ."} Send only for a production incident; otherwise hold it until morning.`}function yf(e){try{return new Intl.DateTimeFormat("en-GB",{timeZone:e}),!0}catch{return!1}}function Fn(e){if(!Tc(e))return;let t=bf(e,"utf8");for(let n of t.split(`
156
+ `)){let i=n.trim();if(!i||i.startsWith("#"))continue;let s=i.indexOf("=");if(s===-1)continue;let r=i.slice(0,s).trim(),o=i.slice(s+1).trim();if(o.startsWith('"')&&o.endsWith('"')||o.startsWith("'")&&o.endsWith("'"))o=o.slice(1,-1);if(!(r in process.env))process.env[r]=o}}function Cf(e){Ff(e,{recursive:!0});let t=dt(e,".gitignore");if(!Tc(t))Pc(t,`*
157
+ `)}function Ef(){Fn(dt(kc(),".slack-cli",".env.local")),Fn(dt(kc(),".config/slack-cli",".env")),Fn(dt(process.cwd(),".slack-cli",".env.local")),Fn(dt(process.cwd(),".env.local")),Fn(dt(process.cwd(),".env"))}function xf(e){return wf("sha256").update(e).digest("hex")}function P(e){return e&&typeof e==="object"&&!Array.isArray(e)?e:{}}function X(e){return Array.isArray(e)?e:[]}function ds(e){return Number(e.ts??0)}async function Rc(e,t,n){let i=t.user;if(typeof i==="string"){if(!n.has(i))n.set(i,await ze(e,i));return n.get(i)??i}return typeof t.username==="string"?t.username:"bot"}function Ji(e){let t=new Date(e*1000),n=t.getUTCFullYear(),i=String(t.getUTCMonth()+1).padStart(2,"0"),s=String(t.getUTCDate()).padStart(2,"0"),r=String(t.getUTCHours()).padStart(2,"0"),o=String(t.getUTCMinutes()).padStart(2,"0"),a=String(t.getUTCSeconds()).padStart(2,"0");return`${n}-${i}-${s} ${r}:${o}:${a}`}function zi(e){let[t,n="000000"]=e.split("."),i=Number(t),s=new Date(i*1000),r=s.getUTCFullYear(),o=String(s.getUTCMonth()+1).padStart(2,"0"),a=String(s.getUTCDate()).padStart(2,"0"),c=String(s.getUTCHours()).padStart(2,"0"),u=String(s.getUTCMinutes()).padStart(2,"0"),f=String(s.getUTCSeconds()).padStart(2,"0"),l=n.padEnd(6,"0").slice(0,6);return`${r}-${o}-${a}T${c}:${u}:${f}.${l}`}function Hi(e){let t=e.match(/^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})\.(\d{6})$/);if(!t)throw Error(`Invalid message timestamp "${e}" \u2014 expected 2026-05-11T06:01:04.000100`);let n=Date.parse(t[1]+"Z");if(isNaN(n))throw Error(`Cannot parse date in "${e}"`);return`${Math.floor(n/1000)}.${t[2]}`}function _f(e){return/^\d{4}-\d{2}-\d{2}T/.test(e)?Hi(e):e}async function gs(e,t,n,i,s){let r=typeof t.ts==="string"?t.ts:`${ds(t)}.000000`,o=zi(r),a="?";if(typeof t.user==="string"){let F=t.user,k="@"+F;if(!n.has(k)){let S=await gc(e,F,async(A,I,W)=>(await hn(A,I,W))[1],s);n.set(k,S)}a=n.get(k)??F}else if(typeof t.username==="string")a=t.username;let c=typeof t.text==="string"?t.text:"",f=bn(await Gt(e,c,n,s)).split(`
158
158
  `),l=f[0]+(f.length>1?`
159
159
  `+f.slice(1).map((F)=>` ${F}`).join(`
160
- `):""),d=i?`${i} @${a}`:`@${a}`,h=X(t.reactions).map(T).map((F)=>{let k=typeof F.name==="string"?F.name:"",C=Number(F.count??X(F.users).length??0);return k?`:${k}:\xD7${C}`:""}).filter(Boolean).join(" "),m=X(t.files).map(T).map((F)=>{let k=typeof F.name==="string"?F.name:typeof F.title==="string"?F.title:"(file)",C=typeof F.size==="number"?` (${hs(F.size)})`:"",A=typeof F.id==="string"?` [${F.id}]`:"";return`
161
- \uD83D\uDCCE ${k}${C}${A}`}).join(""),p=Number(t.reply_count??0),y=p>0?` [+${p} ${p===1?"reply":"replies"}]`:"",E=(h?`
162
- ${h}`:"")+m;return`${o} ${d}: ${l}${y}${E}`}function hs(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function Cf(e){return X(e.files).map(T).map((t)=>({id:t.id??null,name:t.name??t.title??null,mimetype:t.mimetype??null,size:t.size??null,url_private_download:t.url_private_download??t.url_private??null,permalink:t.permalink??null}))}function Tc(e){let t=Cf(e);return{ts:e.ts??null,user:e.user??null,username:e.username??null,bot_id:e.bot_id??null,thread_ts:e.thread_ts??null,text:typeof e.text==="string"?e.text:"",...e.reply_count!==void 0?{reply_count:e.reply_count}:{},...e.reply_users_count!==void 0?{reply_users_count:e.reply_users_count}:{},...e.latest_reply!==void 0?{latest_reply:e.latest_reply}:{},...t.length>0?{files:t}:{}}}async function Ef(e,t,n,i,s){let r=[];for(let o of n){let a=o;if(Number(o.reply_count??0)>0&&typeof o.ts==="string"){let c=await Ke(e,t,o.ts,200,s),u=X(c.messages).map(T);a=u[u.length-1]??o}if(a.user!==i)r.push(o)}return r}async function xf(e,t,n,i="text",s=!1,r){let o=Rt(t),a=await De(e,t,r),c=new Map,f=await(async()=>{if(o?.threadTs){let d=await Ke(e,a,o.threadTs,n,r);return X(d.messages).map(T)}let l=await Ze(e,a,n,void 0,void 0,r);return X(l.messages).map(T).reverse()})();if(s){let{userId:l}=await va(e,r);f=await Ef(e,a,f,l,r)}if(i==="jsonl"){for(let l of f)console.log(JSON.stringify(Tc(l)));return}for(let l of f)console.log(await ps(e,l,c,void 0,r))}async function _f(e,t,n,i,s="text",r){let o=await De(e,t,r),a=await Ke(e,o,Ff(n),i,r),c=X(a.messages).map(T);if(s==="jsonl"){for(let f of c)console.log(JSON.stringify(Tc(f)));return}let u=new Map;for(let f of c)console.log(await ps(e,f,u,void 0,r))}async function Sf(e){let t=await dn(e),n=X(t.channels).map(T).filter((s)=>s.is_member===!0).sort((s,r)=>Number(r.updated??0)-Number(s.updated??0)).slice(0,10),i=new Map;for(let s of n){let r=String(s.id??""),o=typeof s.name==="string"?s.name:typeof s.user==="string"?s.user:r,a=await Ze(e,r,5),c=X(a.messages).map(T).filter((u)=>u.subtype===void 0||u.subtype===null).filter((u)=>{let f=typeof u.text==="string"?u.text:"";return f.length>0&&!f.startsWith("<@")}).slice(0,3).reverse();if(c.length===0)continue;console.log(`-- #${o} --------------------------------`);for(let u of c){let f=await Ic(e,u,i),l=(typeof u.text==="string"?u.text:"").split(`
163
- `)[0]??"",d=await Gt(e,l,i);console.log(` ${f}: ${d}`)}}}async function kf(e,t){let n=await Ka(e,"to:me"),i=X(un(n,["messages","matches"])).map(T).slice(0,t),s=new Map,r=[];for(let o of i){let a=Fc(ls(o)),c=r[r.length-1];if(c?.label===a)c.msgs.push(o);else r.push({label:a,msgs:[o]})}for(let o=0;o<r.length;o++){let{label:a,msgs:c}=r[o];if(o>0)console.log("");console.log(` ${a}`),console.log(" ----------------------------");for(let u of[...c].reverse()){let f=T(u.channel),l=f.is_im===!0,d=typeof f.name==="string"?f.name:"dm",h;if(l&&d.startsWith("U")){let m="@"+d;if(!s.has(m)){let[,p]=await hn(e,d);s.set(m,p)}h=`@${s.get(m)??d}`}else if(l)h=`@${d}`;else h=`#${d}`;console.log(await ps(e,u,s,h))}}}async function Af(e,t,n,i,s="text"){let r=await dn(e),o=X(r.channels).map(T).filter((a)=>i||a.is_member===!0).filter((a)=>{if(!n)return!0;return(typeof a.name==="string"?a.name:"").toLowerCase().includes(n.toLowerCase())}).sort((a,c)=>Number(c.updated??0)-Number(a.updated??0)).slice(0,t);if(s==="jsonl"){for(let a of o)console.log(JSON.stringify(a));return}for(let a of o){let c=String(a.id??""),u=typeof a.name==="string"?a.name:typeof a.user==="string"?a.user:c,f=a.is_im===!0,l=a.is_mpim===!0,d=f||l?"@":"#",h=a.is_member===!0?"":" (not joined)",m=typeof T(a.purpose).value==="string"?String(T(a.purpose).value):"",p=m?` ${m.split(`
164
- `)[0]?.slice(0,60)}`:"";console.log(`${d}${u} ${c}${h}${p}`)}}function $f(e){let t=(s)=>s.startsWith("xoxp-")||s.startsWith("xoxc-"),n=Qs(),i=n.find((s)=>s.profile.token===e);if(!i)return;return n.find((s)=>t(s.profile.token)&&s.profile.teamId===i.profile.teamId)}async function Pc(e,t,n,i,s){let r=e,o=s,a;try{a=await Ai(r,t,n,o)}catch(f){let l=f instanceof Error?f.message:String(f);if(e.startsWith("xoxb-")&&l.includes("not_allowed_token_type")){let d=$f(e);if(d)console.error(`Note: search.messages needs a user token \u2014 the active profile is a bot token (xoxb-); falling back to profile "${d.name}".`),r=d.profile.token,o=d.profile.cookie,a=await Ai(r,t,n,o);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.
160
+ `):""),d=i?`${i} @${a}`:`@${a}`,h=X(t.reactions).map(P).map((F)=>{let k=typeof F.name==="string"?F.name:"",S=Number(F.count??X(F.users).length??0);return k?`:${k}:\xD7${S}`:""}).filter(Boolean).join(" "),m=X(t.files).map(P).map((F)=>{let k=typeof F.name==="string"?F.name:typeof F.title==="string"?F.title:"(file)",S=typeof F.size==="number"?` (${ms(F.size)})`:"",A=typeof F.id==="string"?` [${F.id}]`:"";return`
161
+ \uD83D\uDCCE ${k}${S}${A}`}).join(""),p=Number(t.reply_count??0),y=p>0?` [+${p} ${p===1?"reply":"replies"}]`:"",C=(h?`
162
+ ${h}`:"")+m;return`${o} ${d}: ${l}${y}${C}`}function ms(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function Sf(e){return X(e.files).map(P).map((t)=>({id:t.id??null,name:t.name??t.title??null,mimetype:t.mimetype??null,size:t.size??null,url_private_download:t.url_private_download??t.url_private??null,permalink:t.permalink??null}))}function Mc(e){let t=Sf(e);return{ts:e.ts??null,user:e.user??null,username:e.username??null,bot_id:e.bot_id??null,thread_ts:e.thread_ts??null,text:typeof e.text==="string"?e.text:"",...e.reply_count!==void 0?{reply_count:e.reply_count}:{},...e.reply_users_count!==void 0?{reply_users_count:e.reply_users_count}:{},...e.latest_reply!==void 0?{latest_reply:e.latest_reply}:{},...t.length>0?{files:t}:{}}}async function kf(e,t,n,i,s){let r=[];for(let o of n){let a=o;if(Number(o.reply_count??0)>0&&typeof o.ts==="string"){let c=await Ke(e,t,o.ts,200,s),u=X(c.messages).map(P);a=u[u.length-1]??o}if(a.user!==i)r.push(o)}return r}async function Af(e,t,n,i="text",s=!1,r){let o=Mt(t),a=await ye(e,t,r),c=new Map,f=await(async()=>{if(o?.threadTs){let d=await Ke(e,a,o.threadTs,n,r);return X(d.messages).map(P)}let l=await Qe(e,a,n,void 0,void 0,r);return X(l.messages).map(P).reverse()})();if(s){let{userId:l}=await La(e,r);f=await kf(e,a,f,l,r)}if(i==="jsonl"){for(let l of f)console.log(JSON.stringify(Mc(l)));return}for(let l of f)console.log(await gs(e,l,c,void 0,r))}async function $f(e,t,n,i,s="text",r){let o=await ye(e,t,r),a=await Ke(e,o,_f(n),i,r),c=X(a.messages).map(P);if(s==="jsonl"){for(let f of c)console.log(JSON.stringify(Mc(f)));return}let u=new Map;for(let f of c)console.log(await gs(e,f,u,void 0,r))}async function Of(e){let t=await dn(e),n=X(t.channels).map(P).filter((s)=>s.is_member===!0).sort((s,r)=>Number(r.updated??0)-Number(s.updated??0)).slice(0,10),i=new Map;for(let s of n){let r=String(s.id??""),o=typeof s.name==="string"?s.name:typeof s.user==="string"?s.user:r,a=await Qe(e,r,5),c=X(a.messages).map(P).filter((u)=>u.subtype===void 0||u.subtype===null).filter((u)=>{let f=typeof u.text==="string"?u.text:"";return f.length>0&&!f.startsWith("<@")}).slice(0,3).reverse();if(c.length===0)continue;console.log(`-- #${o} --------------------------------`);for(let u of c){let f=await Rc(e,u,i),l=(typeof u.text==="string"?u.text:"").split(`
163
+ `)[0]??"",d=await Gt(e,l,i);console.log(` ${f}: ${d}`)}}}async function If(e,t){let n=await Ha(e,"to:me"),i=X(un(n,["messages","matches"])).map(P).slice(0,t),s=new Map,r=[];for(let o of i){let a=xc(ds(o)),c=r[r.length-1];if(c?.label===a)c.msgs.push(o);else r.push({label:a,msgs:[o]})}for(let o=0;o<r.length;o++){let{label:a,msgs:c}=r[o];if(o>0)console.log("");console.log(` ${a}`),console.log(" ----------------------------");for(let u of[...c].reverse()){let f=P(u.channel),l=f.is_im===!0,d=typeof f.name==="string"?f.name:"dm",h;if(l&&d.startsWith("U")){let m="@"+d;if(!s.has(m)){let[,p]=await hn(e,d);s.set(m,p)}h=`@${s.get(m)??d}`}else if(l)h=`@${d}`;else h=`#${d}`;console.log(await gs(e,u,s,h))}}}async function Tf(e,t,n,i,s="text"){let r=await dn(e),o=X(r.channels).map(P).filter((a)=>i||a.is_member===!0).filter((a)=>{if(!n)return!0;return(typeof a.name==="string"?a.name:"").toLowerCase().includes(n.toLowerCase())}).sort((a,c)=>Number(c.updated??0)-Number(a.updated??0)).slice(0,t);if(s==="jsonl"){for(let a of o)console.log(JSON.stringify(a));return}for(let a of o){let c=String(a.id??""),u=typeof a.name==="string"?a.name:typeof a.user==="string"?a.user:c,f=a.is_im===!0,l=a.is_mpim===!0,d=f||l?"@":"#",h=a.is_member===!0?"":" (not joined)",m=typeof P(a.purpose).value==="string"?String(P(a.purpose).value):"",p=m?` ${m.split(`
164
+ `)[0]?.slice(0,60)}`:"";console.log(`${d}${u} ${c}${h}${p}`)}}function Pf(e){let t=(s)=>s.startsWith("xoxp-")||s.startsWith("xoxc-"),n=ni(),i=n.find((s)=>s.profile.token===e);if(!i)return;return n.find((s)=>t(s.profile.token)&&s.profile.teamId===i.profile.teamId)}async function Bc(e,t,n,i,s){let r=e,o=s,a;try{a=await Ii(r,t,n,o)}catch(f){let l=f instanceof Error?f.message:String(f);if(e.startsWith("xoxb-")&&l.includes("not_allowed_token_type")){let d=Pf(e);if(d)console.error(`Note: search.messages needs a user token \u2014 the active profile is a bot token (xoxb-); falling back to profile "${d.name}".`),r=d.profile.token,o=d.profile.cookie,a=await Ii(r,t,n,o);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.
165
165
  `+` Add a user-token profile: slack auth login (or slack auth token)
166
- Then select it: slack auth use <name> (or pass --workspace <name>)`),process.exit(1)}else throw f}if(i){console.log(JSON.stringify(a,null,2));return}let c=X(un(a,["messages","matches"])).map(T),u=new Map;for(let f of c){let l=T(f.channel),d=l.is_im===!0,h=typeof l.name==="string"?l.name:"dm",m;if(d&&h.startsWith("U")){let p="@"+h;if(!u.has(p)){let[,y]=await hn(r,h,o);u.set(p,y)}m=`@${u.get(p)??h}`}else if(d)m=`@${h}`;else m=`#${h}`;console.log(await ps(r,f,u,m,o))}}async function Rc(e,t,n,i){let{ref:s,ts:r}=gs(t);if(!r)console.error("Error: target must embed a message ts (e.g. #chan:1700000000.000100 or a Slack permalink URL)"),process.exit(2);return{channelId:n??await Mi(e,s,De,i),ts:r}}async function Of(e,t){let n=Dn(),i={};if(!t.mine)i.shared=!0;if(t.in)i.in=t.in;if(t.from)i.from=t.from;let s=uc(t.state,n,i);if(!t.json){let r=await Vt(e,t.cookie),o=t.mine?"your reactions only [hasmy:]":"anyone's reactions [has:]";console.error(`(From: ${Bc(r)} \xB7 matching ${o})`),console.error(`(query: ${s})`)}await Ae("search.messages",()=>Pc(e,s,t.count,t.json,t.cookie))}async function If(e,t){let n=Dn(),{channelId:i,ts:s}=await Rc(e,t.target,t.channelId,t.cookie),r=await hc(e,i,s,t.state,n,t.cookie);if(r.noop){console.log(`= Already ${t.state} (ts: ${s})`);return}let o=r.removed.length?`, removed ${r.removed.map((a)=>`:${a}:`).join(" ")}`:"";if(console.log(`\u2713 ${t.state} :${n.progress[t.state]}: (ts: ${s})${o}`),r.leftover.length)console.error(`\u26A0 ${r.leftover.map((a)=>`:${a}:`).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 Tf(e,t){let n=Dn(),{channelId:i,ts:s}=await Rc(e,t.target,t.channelId,t.cookie),r=await gc(e,i,s,t.flag,n,t.remove===!0,t.cookie);console.log(`\u2713 ${t.remove?"Cleared":"Flagged"} ${t.flag} :${r}: (ts: ${s})`)}async function Pf(e,t){let n=Dn(),i=t.channelId??await Mi(e,t.channel,De,t.cookie),s={limit:t.limit};if(t.fix)s.fix=!0;if(t.cookie)s.cookie=t.cookie;let r=await mc(e,i,n,s);if(r.findings.length===0)console.log(`\u2713 No multi-state tasks in ${r.scanned} message(s).`);else{for(let o of r.findings){let a=o.fixed===!0?"fixed":o.fixed===!1?`FAILED: ${o.error??"?"}`:"needs --fix";console.log(`${o.ts} ${o.emoji.map((c)=>`:${c}:`).join(" ")} \u2192 keep :${o.keep}: [${a}] ${te(o.text).slice(0,60)}`)}console.log(`${r.findings.length} multi-state task(s) in ${r.scanned} message(s).`)}if(r.truncated)console.error(`\u26A0 Scan limit reached (${t.limit} messages) \u2014 older history was NOT checked. Raise it with --limit N.`)}async function Rf(e,t,n,i){let s=Math.floor(Date.now()/1000)-t*86400,r=await dn(e),o=X(r.channels).map(T).filter((f)=>f.is_member===!0&&f.is_im!==!0&&f.is_mpim!==!0).filter((f)=>{if(!i)return!0;return(typeof f.name==="string"?f.name:"").toLowerCase().includes(i.toLowerCase())}).sort((f,l)=>Number(l.updated??0)-Number(f.updated??0)),a=new Map,c=0,u=0;for(let f of o){let l=String(f.id??""),d=typeof f.name==="string"?f.name:l,h;try{h=await Ze(e,l,n)}catch(p){console.error(` SKIP #${d}: ${p.message}`);continue}let m=X(h.messages).map(T).filter((p)=>(p.subtype===void 0||p.subtype===null)&&ls(p)>=s);if(m.length===0)continue;u+=1,c+=m.length,console.log(`## #${d} (${m.length} msgs)
167
- `);for(let p of[...m].reverse()){let y=await Ic(e,p,a),E=typeof p.text==="string"?p.text:"",k=wn(await Gt(e,E,a)).split(`
168
- `).join(" \u21B5 ");console.log(`[${Cc(ls(p))}] ${y}: ${k}`)}console.log("")}console.error(`Dumped ${c} messages across ${u} channels (cutoff: ${t}d)`)}function Mf(e){let t=[];function n(i){if(typeof i==="string"){t.push(i);return}if(Array.isArray(i)){for(let s of i)n(s);return}if(i&&typeof i==="object"){let s=i;if(typeof s.text==="string"){t.push(s.text);return}if(Array.isArray(s.elements))n(s.elements);else if(Array.isArray(s.content))n(s.content)}}for(let i of e)n(i);return t.join("").trim()}async function Mc(e,t,n){let i=new Map;return async(s)=>{if(!s)return"(unknown)";if(i.has(s))return i.get(s);try{let r=await tc(e,s,t),o=T(r.channel),a;if(o.is_im===!0){let c=typeof o.user==="string"?o.user:"";if(!c||c===n)a="@self";else{let[u]=await hn(e,c);a=`@${u}`}}else a=`#${typeof o.name==="string"?o.name:s}`;return i.set(s,a),a}catch{return s}}}function zi(e){let t=T(X(e.destinations)[0]);return String(t.channel_id??e.channel_id??e.channel??"")}function fs(e){return Mf(X(e.blocks))||(typeof e.text==="string"?e.text:"(no text)")}async function Bf(e,t,n=!1){let i=await gn(e,t),s=X(i.drafts??i.messages??[]).map(T).filter((u)=>u.is_deleted!==!0),r=n?s:s.filter((u)=>u.is_sent!==!0);if(r.length===0){console.log(n?"No drafts.":"No pending drafts. Run with --all to include sent.");return}let o="";try{({userId:o}=await Oi(e,t))}catch{}let a=await Mc(e,t,o),c=new Map;for(let u of r){let f=zi(u),l=fs(u),d=Number(u.date_created??u.date_create??0),h=d?Wi(d):"?",m=await a(f),p=typeof u.id==="string"?u.id:"",y=u.is_sent===!0?" [SENT]":"",E=wn(await Gt(e,l,c));console.log(`-- ${p} ${m} [${h}]${y}`);for(let F of E.split(`
169
- `))console.log(` ${F}`)}}async function Nf(e,t,n){let i=await gn(e,t),s=X(i.drafts).map(T).find((m)=>String(m.id)===n);if(!s)console.error(`Draft not found: ${n}`),process.exit(1);let r="";try{({userId:r}=await Oi(e,t))}catch{}let o=await Mc(e,t,r),a=zi(s),c=fs(s),u=Number(s.date_created??0),f=String(s.last_updated_ts??"?"),l=await o(a),h=wn(await Gt(e,c,new Map));console.log(`id: ${s.id}`),console.log(`channel: ${l} (${a})`),console.log(`created: ${u?Wi(u):"?"}`),console.log(`updated: ${Wi(Number(f.split(".")[0]))}`),console.log(`status: ${s.is_sent===!0?"sent":"pending"}`),console.log("---"),console.log(h)}function He(...e){return bf(e.join(`
170
- `)).slice(0,4)}function te(e){return e.replace(/\x1b\[[0-9;:?]*[ -/]*[@-~]/g,"").replace(/[\x00-\x1f\x7f-\x9f]/g,"").replace(/[\u061c\u200e\u200f\u202a-\u202e\u2066-\u2069]/g,"")}var vf={"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 tt(e){let t=e instanceof Error?e.message:String(e),n=t.match(/Slack error on (\S+): (\w+)/);if(!n)return t;let[,i,s]=n;switch(s){case"missing_scope":return`Error: token lacks the ${vf[i]??"the required"} scope (needed for ${i}). 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 t}}function ve(e,t,n){for(let s of n)console.log(s);let i=Ec();if(i)console.log(i);if(e!==void 0)console.error(`Code mismatch (got ${e}, expected ${t})`);console.error(`Rerun with --code=${t}`),process.exit(1)}function gs(e){let t=Rt(e);if(t)return t.ts?{ref:t.channel,ts:t.ts}:{ref:t.channel};if(e.startsWith("#")||e.startsWith("@")){let n=e.indexOf(":");if(n>0){let i=e.slice(n+1);if(/^\d{10}\.\d{6}$/.test(i))return{ref:e.slice(0,n),ts:i};if(/^\d{4}-\d{2}-\d{2}T/.test(i))return{ref:e.slice(0,n),ts:Ki(i)}}}return{ref:e}}function Fn(e,t=!0){let n=Rt(e);if(n){if(!t)return{ref:n.channel};let s=n.threadTs??n.ts;return s?{ref:n.channel,threadTs:s}:{ref:n.channel}}let i=e.indexOf(":");if(i>0){let s=e.slice(i+1);if(/^\d{10}\.\d{6}$/.test(s))return{ref:e.slice(0,i),threadTs:s};if(/^\d{4}-\d{2}-\d{2}T/.test(s))return{ref:e.slice(0,i),threadTs:Ki(s)}}return{ref:e}}async function ms(e,t,n,i){let s=n;if(/^#?[CDG][A-Z0-9]{8,}$/.test(n)||!n.startsWith("#")&&!n.startsWith("@"))try{let o=T(await mn(e,t,i)),a=T(o.channel);if(a.is_im===!0){let c=typeof a.user==="string"?a.user:"";s=c?`@${await ze(e,c,i)}`:t}else s=typeof a.name==="string"?`#${a.name}`:t}catch{s=t}return s===t?t:`${s} (${t})`}async function Vt(e,t){try{return await ja(e,t)}catch{return null}}function Nt(e,t){let n;return async()=>{if(n===void 0)n=await Vt(e,t);return n}}function Bc(e,t){let n=t?" [as bot]":"";if(!e)return`(unknown \u2014 auth.test failed)${n}`;let i=te(e.user||e.userId||"?"),s=e.userId?` (${e.userId})`:"",r=e.team?` \u2014 ${te(e.team)}`:"";return`@${i}${s}${r}${n}`}function je(e,t={}){return` ${"From:".padEnd(t.pad??6)}${Bc(e,t.asBot)}`}async function Ui(e,t,n=60,i){let s=typeof t.user==="string"?await ze(e,t.user,i):typeof t.username==="string"?t.username:"?",r=(typeof t.text==="string"?t.text:"").split(`
171
- `)[0]??"",o=r.length>n?`${r.slice(0,n)}\u2026`:r,a=typeof t.ts==="string"?t.ts:"";return`${a?Ji(a).slice(0,16).replace("T"," "):""} @${s}${o?`: ${o}`:""}`}async function jf(e,t,n,i){let s=n.find((r)=>String(r.ts)===t)??n[0];if(!s)return t;return Ui(e,s,40,i)}function _c(e){return e.toLowerCase().replace(/<[@#!][^>]+>/g," ").replace(/[^\p{L}\p{N}\s]/gu," ").replace(/\s+/g," ").trim()}function Lf(e,t){let n=_c(e),i=_c(t);if(!n||!i)return 0;if(n===i)return 1;let s=(u)=>{let f=new Map;for(let l=0;l<u.length-1;l++){let d=u.slice(l,l+2);f.set(d,(f.get(d)??0)+1)}return f},r=s(n),o=s(i);if(r.size===0||o.size===0)return 0;let a=0;for(let[u,f]of r){let l=o.get(u);if(l)a+=Math.min(f,l)}let c=Sc(r)+Sc(o);return c===0?0:2*a/c}function Sc(e){let t=0;for(let n of e.values())t+=n;return t}async function Wf(e,t){let n=Nt(e,t.cookie),{ref:i,ts:s}=gs(t.target);if(!s)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 r;if(t.channelId)r=t.channelId;else r=await De(e,i,t.cookie);let o=await Ke(e,r,s,1,t.cookie),c=X(o.messages).map(T).find((m)=>String(m.ts)===s);if(!c)console.error(`Message not found at ts=${s} in channel ${r}`),process.exit(1);let u=typeof c.text==="string"?c.text:"",f=t.mentions?await Dc(e,t.newText,r,t.cookie?{cookie:t.cookie}:{}):t.newText,l=await n(),d=He(u,f,l?.userId??"");if(t.code!==d)ve(t.code,d,["--- Editing as -------------------------------",je(l),"--- Original message -------------------------",...u.split(`
166
+ Then select it: slack auth use <name> (or pass --workspace <name>)`),process.exit(1)}else throw f}if(i){console.log(JSON.stringify(a,null,2));return}let c=X(un(a,["messages","matches"])).map(P),u=new Map;for(let f of c){let l=P(f.channel),d=l.is_im===!0,h=typeof l.name==="string"?l.name:"dm",m;if(d&&h.startsWith("U")){let p="@"+h;if(!u.has(p)){let[,y]=await hn(r,h,o);u.set(p,y)}m=`@${u.get(p)??h}`}else if(d)m=`@${h}`;else m=`#${h}`;console.log(await gs(r,f,u,m,o))}}async function Nc(e,t,n,i){let{ref:s,ts:r}=Ds(t);if(!r)console.error("Error: target must embed a message ts (e.g. #chan:1700000000.000100 or a Slack permalink URL)"),process.exit(2);return{channelId:n??await Ni(e,s,ye,i),ts:r}}async function Rf(e,t){let n=yn(),i={};if(!t.mine)i.shared=!0;if(t.in)i.in=t.in;if(t.from)i.from=t.from;let s=dc(t.state,n,i);if(!t.json){let r=await Vt(e,t.cookie),o=t.mine?"your reactions only [hasmy:]":"anyone's reactions [has:]";console.error(`(From: ${jc(r)} \xB7 matching ${o})`),console.error(`(query: ${s})`)}await _e("search.messages",()=>Bc(e,s,t.count,t.json,t.cookie))}async function Mf(e,t){let n=yn(),{channelId:i,ts:s}=await Nc(e,t.target,t.channelId,t.cookie),r=await Dc(e,i,s,t.state,n,t.cookie);if(r.noop){console.log(`= Already ${t.state} (ts: ${s})`);return}let o=r.removed.length?`, removed ${r.removed.map((a)=>`:${a}:`).join(" ")}`:"";if(console.log(`\u2713 ${t.state} :${n.progress[t.state]}: (ts: ${s})${o}`),r.leftover.length)console.error(`\u26A0 ${r.leftover.map((a)=>`:${a}:`).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 Bf(e,t){let n=yn(),{channelId:i,ts:s}=await Nc(e,t.target,t.channelId,t.cookie),r=await yc(e,i,s,t.flag,n,t.remove===!0,t.cookie);console.log(`\u2713 ${t.remove?"Cleared":"Flagged"} ${t.flag} :${r}: (ts: ${s})`)}async function Nf(e,t){let n=yn(),i=t.channelId??await Ni(e,t.channel,ye,t.cookie),s={limit:t.limit};if(t.fix)s.fix=!0;if(t.cookie)s.cookie=t.cookie;let r=await wc(e,i,n,s);if(r.findings.length===0)console.log(`\u2713 No multi-state tasks in ${r.scanned} message(s).`);else{for(let o of r.findings){let a=o.fixed===!0?"fixed":o.fixed===!1?`FAILED: ${o.error??"?"}`:"needs --fix";console.log(`${o.ts} ${o.emoji.map((c)=>`:${c}:`).join(" ")} \u2192 keep :${o.keep}: [${a}] ${ne(o.text).slice(0,60)}`)}console.log(`${r.findings.length} multi-state task(s) in ${r.scanned} message(s).`)}if(r.truncated)console.error(`\u26A0 Scan limit reached (${t.limit} messages) \u2014 older history was NOT checked. Raise it with --limit N.`)}async function vf(e,t,n,i){let s=Math.floor(Date.now()/1000)-t*86400,r=await dn(e),o=X(r.channels).map(P).filter((f)=>f.is_member===!0&&f.is_im!==!0&&f.is_mpim!==!0).filter((f)=>{if(!i)return!0;return(typeof f.name==="string"?f.name:"").toLowerCase().includes(i.toLowerCase())}).sort((f,l)=>Number(l.updated??0)-Number(f.updated??0)),a=new Map,c=0,u=0;for(let f of o){let l=String(f.id??""),d=typeof f.name==="string"?f.name:l,h;try{h=await Qe(e,l,n)}catch(p){console.error(` SKIP #${d}: ${p.message}`);continue}let m=X(h.messages).map(P).filter((p)=>(p.subtype===void 0||p.subtype===null)&&ds(p)>=s);if(m.length===0)continue;u+=1,c+=m.length,console.log(`## #${d} (${m.length} msgs)
167
+ `);for(let p of[...m].reverse()){let y=await Rc(e,p,a),C=typeof p.text==="string"?p.text:"",k=bn(await Gt(e,C,a)).split(`
168
+ `).join(" \u21B5 ");console.log(`[${_c(ds(p))}] ${y}: ${k}`)}console.log("")}console.error(`Dumped ${c} messages across ${u} channels (cutoff: ${t}d)`)}function jf(e){let t=[];function n(i){if(typeof i==="string"){t.push(i);return}if(Array.isArray(i)){for(let s of i)n(s);return}if(i&&typeof i==="object"){let s=i;if(typeof s.text==="string"){t.push(s.text);return}if(Array.isArray(s.elements))n(s.elements);else if(Array.isArray(s.content))n(s.content)}}for(let i of e)n(i);return t.join("").trim()}async function vc(e,t,n){let i=new Map;return async(s)=>{if(!s)return"(unknown)";if(i.has(s))return i.get(s);try{let r=await sc(e,s,t),o=P(r.channel),a;if(o.is_im===!0){let c=typeof o.user==="string"?o.user:"";if(!c||c===n)a="@self";else{let[u]=await hn(e,c);a=`@${u}`}}else a=`#${typeof o.name==="string"?o.name:s}`;return i.set(s,a),a}catch{return s}}}function qi(e){let t=P(X(e.destinations)[0]);return String(t.channel_id??e.channel_id??e.channel??"")}function ps(e){return jf(X(e.blocks))||(typeof e.text==="string"?e.text:"(no text)")}async function Lf(e,t,n=!1){let i=await gn(e,t),s=X(i.drafts??i.messages??[]).map(P).filter((u)=>u.is_deleted!==!0),r=n?s:s.filter((u)=>u.is_sent!==!0);if(r.length===0){console.log(n?"No drafts.":"No pending drafts. Run with --all to include sent.");return}let o="";try{({userId:o}=await Pi(e,t))}catch{}let a=await vc(e,t,o),c=new Map;for(let u of r){let f=qi(u),l=ps(u),d=Number(u.date_created??u.date_create??0),h=d?Ji(d):"?",m=await a(f),p=typeof u.id==="string"?u.id:"",y=u.is_sent===!0?" [SENT]":"",C=bn(await Gt(e,l,c));console.log(`-- ${p} ${m} [${h}]${y}`);for(let F of C.split(`
169
+ `))console.log(` ${F}`)}}async function Wf(e,t,n){let i=await gn(e,t),s=X(i.drafts).map(P).find((m)=>String(m.id)===n);if(!s)console.error(`Draft not found: ${n}`),process.exit(1);let r="";try{({userId:r}=await Pi(e,t))}catch{}let o=await vc(e,t,r),a=qi(s),c=ps(s),u=Number(s.date_created??0),f=String(s.last_updated_ts??"?"),l=await o(a),h=bn(await Gt(e,c,new Map));console.log(`id: ${s.id}`),console.log(`channel: ${l} (${a})`),console.log(`created: ${u?Ji(u):"?"}`),console.log(`updated: ${Ji(Number(f.split(".")[0]))}`),console.log(`status: ${s.is_sent===!0?"sent":"pending"}`),console.log("---"),console.log(h)}function He(...e){return xf(e.join(`
170
+ `)).slice(0,4)}function ne(e){return e.replace(/\x1b\[[0-9;:?]*[ -/]*[@-~]/g,"").replace(/[\x00-\x1f\x7f-\x9f]/g,"").replace(/[\u061c\u200e\u200f\u202a-\u202e\u2066-\u2069]/g,"")}var Uf={"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 nt(e){let t=e instanceof Error?e.message:String(e),n=t.match(/Slack error on (\S+): (\w+)/);if(!n)return t;let[,i,s]=n;switch(s){case"missing_scope":return`Error: token lacks the ${Uf[i]??"the required"} scope (needed for ${i}). 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 t}}async function Yi(e,t,n){if(!t.startsWith("D"))return null;try{let i=await ws(e,t,n);if(!i)return null;return await mc(e,i,mn,n)}catch{return null}}function Ne(e,t,n,i){for(let r of n)console.log(r);let s=Sc(new Date,i);if(s)console.log(s);if(e!==void 0)console.error(`Code mismatch (got ${e}, expected ${t})`);console.error(`Rerun with --code=${t}`),process.exit(1)}function Ds(e){let t=Mt(e);if(t)return t.ts?{ref:t.channel,ts:t.ts}:{ref:t.channel};if(e.startsWith("#")||e.startsWith("@")){let n=e.indexOf(":");if(n>0){let i=e.slice(n+1);if(/^\d{10}\.\d{6}$/.test(i))return{ref:e.slice(0,n),ts:i};if(/^\d{4}-\d{2}-\d{2}T/.test(i))return{ref:e.slice(0,n),ts:Hi(i)}}}return{ref:e}}function Cn(e,t=!0){let n=Mt(e);if(n){if(!t)return{ref:n.channel};let s=n.threadTs??n.ts;return s?{ref:n.channel,threadTs:s}:{ref:n.channel}}let i=e.indexOf(":");if(i>0){let s=e.slice(i+1);if(/^\d{10}\.\d{6}$/.test(s))return{ref:e.slice(0,i),threadTs:s};if(/^\d{4}-\d{2}-\d{2}T/.test(s))return{ref:e.slice(0,i),threadTs:Hi(s)}}return{ref:e}}async function ys(e,t,n,i){let s=n;if(/^#?[CDG][A-Z0-9]{8,}$/.test(n)||!n.startsWith("#")&&!n.startsWith("@"))try{let o=P(await Dn(e,t,i)),a=P(o.channel);if(a.is_im===!0){let c=typeof a.user==="string"?a.user:"";s=c?`@${await ze(e,c,i)}`:t}else s=typeof a.name==="string"?`#${a.name}`:t}catch{s=t}return s===t?t:`${s} (${t})`}async function Vt(e,t){try{return await Wa(e,t)}catch{return null}}function vt(e,t){let n;return async()=>{if(n===void 0)n=await Vt(e,t);return n}}function jc(e,t){let n=t?" [as bot]":"";if(!e)return`(unknown \u2014 auth.test failed)${n}`;let i=ne(e.user||e.userId||"?"),s=e.userId?` (${e.userId})`:"",r=e.team?` \u2014 ${ne(e.team)}`:"";return`@${i}${s}${r}${n}`}function ve(e,t={}){return` ${"From:".padEnd(t.pad??6)}${jc(e,t.asBot)}`}async function Ki(e,t,n=60,i){let s=typeof t.user==="string"?await ze(e,t.user,i):typeof t.username==="string"?t.username:"?",r=(typeof t.text==="string"?t.text:"").split(`
171
+ `)[0]??"",o=r.length>n?`${r.slice(0,n)}\u2026`:r,a=typeof t.ts==="string"?t.ts:"";return`${a?zi(a).slice(0,16).replace("T"," "):""} @${s}${o?`: ${o}`:""}`}async function Jf(e,t,n,i){let s=n.find((r)=>String(r.ts)===t)??n[0];if(!s)return t;return Ki(e,s,40,i)}function Ac(e){return e.toLowerCase().replace(/<[@#!][^>]+>/g," ").replace(/[^\p{L}\p{N}\s]/gu," ").replace(/\s+/g," ").trim()}function Kf(e,t){let n=Ac(e),i=Ac(t);if(!n||!i)return 0;if(n===i)return 1;let s=(u)=>{let f=new Map;for(let l=0;l<u.length-1;l++){let d=u.slice(l,l+2);f.set(d,(f.get(d)??0)+1)}return f},r=s(n),o=s(i);if(r.size===0||o.size===0)return 0;let a=0;for(let[u,f]of r){let l=o.get(u);if(l)a+=Math.min(f,l)}let c=$c(r)+$c(o);return c===0?0:2*a/c}function $c(e){let t=0;for(let n of e.values())t+=n;return t}async function zf(e,t){let n=vt(e,t.cookie),{ref:i,ts:s}=Ds(t.target);if(!s)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 r;if(t.channelId)r=t.channelId;else r=await ye(e,i,t.cookie);let o=await Ke(e,r,s,1,t.cookie),c=X(o.messages).map(P).find((m)=>String(m.ts)===s);if(!c)console.error(`Message not found at ts=${s} in channel ${r}`),process.exit(1);let u=typeof c.text==="string"?c.text:"",f=t.mentions?await bc(e,t.newText,r,t.cookie?{cookie:t.cookie}:{}):t.newText,l=await n(),d=He(u,f,l?.userId??"");if(t.code!==d)Ne(t.code,d,["--- Editing as -------------------------------",ve(l),"--- Original message -------------------------",...u.split(`
172
172
  `).map((m)=>` ${m}`),"--- Replacing with ---------------------------",...f.split(`
173
- `).map((m)=>` ${m}`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);let h=await Yt(e,r,s,f,t.cookie);console.log(`\u2713 Edited (ts: ${h})`)}async function Uf(e,t){let n=Nt(e,t.cookie),{ref:i,ts:s}=gs(t.target);if(!s)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 r;if(t.channelId)r=t.channelId;else r=await De(e,i,t.cookie);let o=await Ke(e,r,s,1,t.cookie),c=X(o.messages).map(T).find((d)=>String(d.ts)===s);if(!c)console.error(`Message not found at ts=${s} in channel ${r}`),process.exit(1);let u=typeof c.text==="string"?c.text:"",f=await n(),l=He(r,s,u,f?.userId??"");if(t.code!==l){let d=await ms(e,r,i,t.cookie);ve(t.code,l,["--- Deleting message -------------------------",je(f),` \u2192 ${d} at ${Ji(s)}`,...u.split(`
174
- `).map((h)=>` ${h}`),"---------------------------------------------"])}await Ya(e,r,s,t.cookie),console.log(`\u2713 Deleted (ts: ${s})`)}async function Jf(e,t){let{ref:n,ts:i}=gs(t.target);if(!i)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 s=t.emoji.replace(/^:|:$/g,""),r;if(t.channelId)r=t.channelId;else r=await De(e,n,t.cookie);if(t.remove)await fn(e,r,i,s,t.cookie),console.log(`\u2713 Removed :${s}: (ts: ${i})`);else await ct(e,r,i,s,t.cookie),console.log(`\u2713 Reacted :${s}: (ts: ${i})`)}async function Hi(e,t,n,i){if(!n||!t.startsWith("D"))return!1;try{let s=T(await mn(e,t,i)),r=T(s.channel);return r.is_im===!0&&r.user===n}catch{return!1}}async function Kf(e,t){let{ref:n,threadTs:i}=Fn(t.target),s=t.cookie,r=Nt(e,s),o;if(t.channelId)o=t.channelId;else if(t.userId)o=await Pt(e,t.userId,s);else o=await De(e,n,s);if(!t.asBot&&await Hi(e,o,(await r())?.userId,s))console.error(`Warning: "${t.target}" is a DM to yourself \u2014 Slack will NOT notify you of your own message.
175
- `+` To reach yourself with a notification, send as the bot: slack send '${t.target}' '...' --as-bot`);let a=t.message,c=null;if(t.mentions){c=await Bt(t.mentionToken??e,t.message,o,t.mentionCookie),a=c.text;for(let C of yn(c.unresolved))console.error(`\u26A0 ${te(C)}`)}try{for(let C of await bc(t.mentionToken??e,a,t.mentionCookie))console.error(`\u26A0 possible untagged mention: ${te(C.surface)} \u2014 @${te(C.display)} won't be notified (did you mean <@${C.userId}>?)`)}catch{}let u=[];if(c&&(c.resolved.length>0||c.unresolved.length>0)){u.push("--- Mentions ---------------------------------");for(let C of c.resolved)u.push(` \u2713 ${te(C.surface)} \u2192 @${te(C.display)} (${C.userId}) \u2014 will notify`);for(let C of c.unresolved){let A=C.reason==="ambiguous"?"ambiguous":C.reason==="unavailable"?"lookup unavailable":"no match";u.push(` \u26A0 ${te(C.surface)} \u2014 plain text, NOT notified (${A})`)}}let f="",l="?",d=[],h,m,p;if(i)try{let C=await Ke(e,o,i,100,s);d=X(C.messages).map(T);let A=d[d.length-1];f=typeof A?.text==="string"?A.text:"",h=typeof A?.user==="string"?A.user:void 0,m=typeof A?.bot_id==="string"?A.bot_id:void 0,p=typeof A?.ts==="string"?A.ts:void 0}catch{}else try{let C=await Ze(e,o,1,void 0,void 0,s),A=X(C.messages).map(T),P=A.filter((L)=>L.subtype===void 0||L.subtype===null)[0];f=typeof P?.text==="string"?P.text:"",l=typeof P?.user==="string"?await ze(e,P.user,s):typeof P?.username==="string"?P.username:"?";let v=A[0];h=typeof v?.user==="string"?v.user:void 0,m=typeof v?.bot_id==="string"?v.bot_id:void 0,p=typeof v?.ts==="string"?v.ts:void 0}catch{}if(process.env.SLACK_UNREPLIED_WARN!=="0"&&p&&(h||m))try{let C=await r();if(!!C&&(!!h&&!!C.userId&&C.userId===h||!!m&&!!C.botId&&C.botId===m)){let P=`slack edit "#${o}:${p}" "<\u65B0\u3057\u3044\u672C\u6587>" --channel-id ${o}`;try{let v=await ln(e,o,p,s);if(v)P=`slack edit "${v}" "<\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(` ${P}`),console.error(" \u3053\u306E\u307E\u307E\u9001\u4FE1\u3059\u308B\u5834\u5408\u306F --code=XXXX \u3067\u78BA\u5B9A\u3002")}}catch{}if(i&&d.length){let C={sim:0,msg:null};for(let A of d){let P=typeof A.text==="string"?A.text:"";if(!P)continue;let v=Lf(a,P);if(v>C.sim)C={sim:v,msg:A}}if(C.msg&&C.sim>=0.82){let A=Math.round(C.sim*100);console.error(`\u26A0 possible duplicate: ${A}% similar to an existing thread message \u2014 ${await Ui(e,C.msg,60,s)}`)}}let y=await r(),E=He(o,i??"",f,a,y?.userId??"");if(t.code!==E){let C=await ms(e,o,n,s),A=je(y,{asBot:t.asBot});if(i){let P=await jf(e,i,d,s),v=d.slice(-3),L=v.length?await Promise.all(v.map(async(R)=>` ${await Ui(e,R,60,s)}`)):[" (thread context unavailable)"];ve(t.code,E,["--- Recent messages in thread ----------------",...L,...u,"--- Sending ----------------------------------",A,` \u2192 ${C} thread of ${P} \u2014 THREAD REPLY`,` Message: ${a}`,"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"])}else ve(t.code,E,["--- Last message in channel ------------------",` ${l}: ${f.split(`
176
- `)[0]?.slice(0,100)??"(empty)"}`,...u,"--- Sending ----------------------------------",A,` \u2192 ${C} \u2014 NEW top-level message`,` Message: ${a}`,"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"])}let F=await rs(e,o,a,i,t.broadcast,s),k="";try{k=await ln(e,o,F,s)}catch{}if(k)console.log(`\u2713 Sent: ${k}`);else console.log(`\u2713 Sent (ts: ${F})`);if(t.asBot&&o.startsWith("D"))try{let C=await oi(e);if(!C.ok)for(let A of ai(C,!0))console.error(A);else{let A=C.appId?`https://api.slack.com/apps/${C.appId}`:"https://api.slack.com/apps";console.error(`Note: if ${t.target} can't reply (app messaging may be off), enable Messages Tab: ${A} \u2192 App Home.`)}}catch{}}var zf=2,Ce=3,Hf=1.618033988749895,qf=1000,Yf=5000,kc=8,Xf=(e)=>new Promise((t)=>setTimeout(t,e)),Gf=new Set(["thread_broadcast"]),Vf=/(?<![A-Za-z0-9._@<-])@(here|channel|everyone)(?![A-Za-z0-9._-])/giu;function ds(e){let t=new Set;return{text:e.replace(Vf,(i,s)=>{let r=s.toLowerCase();return t.add(r),`<!${r}>`}),kinds:t}}async function qi(e,t,n){if(!t.startsWith("D"))return;try{let i=T(await mn(e,t,n)),s=T(i.channel);return s.is_im===!0&&typeof s.user==="string"?s.user:void 0}catch{return}}async function Nc(e,t){let{channelId:n,ts:i,question:s,reactable:r,threadOnly:o,audience:a,broadcast:c,cookie:u,timeout:f,shown:l}=t,d=t.askerUserId,h=t.askerBotId,m=(L)=>typeof L==="string"&&!!L&&L!==d&&(c||a.has(L));function p(L){let R=X(L.reactions).map(T),G=[];for(let S=0;S<r.length;S++){let x=R.find((W)=>W.name===Me[S].name),O=x?X(x.users).filter(m):[];if(O.length)G.push({index:S,users:O})}return G}async function y(L,R){let G=typeof L.text==="string"?L.text:"";if(!G)return;let S=wi(G,R);if(S===G)return;try{await Yt(e,n,i,S,u,!0)}catch(x){console.error(` (\u8CEA\u554F\u6587\u306B\u6CE8\u610F\u66F8\u304D\u3092\u5165\u308C\u3089\u308C\u307E\u305B\u3093\u3067\u3057\u305F: ${x instanceof Error?x.message:String(x)})`)}}async function E(L){let R=p(L);if(R.length<=1&&yi(typeof L.text==="string"?L.text:"").length)await y(L,[]);if(!R.length)return null;if(R.length===1){let{index:x,users:O}=R[0];return{answer:r[x],how:`\u30EA\u30A2\u30AF\u30B7\u30E7\u30F3 ${Me[x].glyph}`,who:O[0]}}let G=R.map((x)=>Me[x.index].glyph).join(" / ");console.error(` (${G} \u304C\u540C\u6642\u306B\u9078\u3070\u308C\u3066\u3044\u307E\u3059\u30021 \u3064\u306B\u7D5E\u3063\u3066\u3082\u3089\u3046\u307E\u3067\u5F85\u3061\u307E\u3059)`);let S=[...new Set(R.flatMap((x)=>x.users))].sort();return await y(L,S),null}function F(L,R=1/0){let G=[...L].sort((S,x)=>Number(S.ts)-Number(x.ts));for(let S of G){if(!(Number(S.ts)>Number(i)))continue;if(!m(S.user))continue;if(typeof S.subtype==="string"&&!Gf.has(S.subtype))continue;if(Number(S.ts)>=R)break;let x=typeof S.text==="string"?S.text.trim():"";if(x)return{answer:x,how:"\u8FD4\u4FE1",who:S.user}}return null}async function k(){if(t.threadParentTs){let S=T(await Ke(e,n,t.threadParentTs,100,u)),x=X(S.messages).map(T),O=x.find((W)=>W.ts===i);if(O){let W=await E(O);if(W)return W}return F(x)}let L=T(await Ze(e,n,30,i,void 0,u,!0)),R=X(L.messages).map(T),G=R.find((S)=>S.ts===i);if(G){let S=await E(G);if(S)return S}if(!o){let S=R.filter((O)=>Number(O.ts)>Number(i)&&(h&&O.bot_id===h||d&&O.user===d)).reduce((O,W)=>Math.min(O,Number(W.ts)),1/0),x=F(R,S);if(x)return x}if(G&&Number(G.reply_count)>0){let S=T(await Ke(e,n,i,30,u)),x=F(X(S.messages).map(T));if(x)return x}return null}async function C(L){for(let G=0;G<r.length;G++)try{await fn(e,n,i,Me[G].name,u)}catch{}let R="";if(L.who)try{R=await ze(e,L.who,u)}catch{R=L.who}if(R)console.error(` \u56DE\u7B54\u8005: ${te(R)}`);try{await Yt(e,n,i,_a(s,L,R),u,!0);try{await ct(e,n,i,bi,u),await fn(e,n,i,ts,u)}catch{}}catch(G){console.error(` (\u5143\u30E1\u30C3\u30BB\u30FC\u30B8\u306E\u66F4\u65B0\u306B\u5931\u6557: ${G instanceof Error?G.message:String(G)})`)}}let A=Date.now()+f*1000,P=0,v=qf;for(;;){let L=null;try{L=await k(),P=0}catch(R){if(P++,P>=kc)console.error(`Error: Slack \u3078\u306E\u554F\u3044\u5408\u308F\u305B\u306B ${P} \u56DE\u9023\u7D9A\u3067\u5931\u6557\u3057\u307E\u3057\u305F: ${R instanceof Error?R.message:String(R)}`),process.exit(Ce);console.error(` (Slack \u30A8\u30E9\u30FC ${P}/${kc}, \u518D\u8A66\u884C\u3057\u307E\u3059: ${R instanceof Error?R.message:String(R)})`)}if(L)await C(L),console.log(L.answer),process.exit(0);if(Date.now()>=A)break;await Xf(Math.min(v,Math.max(0,A-Date.now()))),v=Math.min(v*Hf,Yf)}if(f===0)console.error(`\u307E\u3060\u56DE\u7B54\u304C\u3042\u308A\u307E\u305B\u3093: ${l}`);else console.error(`Error: ${f}s \u4EE5\u5185\u306B\u56DE\u7B54\u304C\u3042\u308A\u307E\u305B\u3093\u3067\u3057\u305F (\u30E1\u30C3\u30BB\u30FC\u30B8\u306F\u305D\u306E\u307E\u307E\u6B8B\u3063\u3066\u3044\u307E\u3059)`),console.error(` ${l}`),console.error(` \u3042\u3068\u3067\u56DE\u53CE\u3059\u308B: ${vc(l,t.asBot)}`);process.exit(zf)}function vc(e,t){return`slack ask --waitFor='${e}'${t?" --as-bot":""}`}async function Zf(e,t){let{ref:n,threadTs:i}=Fn(t.target,!1),s=t.cookie,r=Nt(e,s),o;if(t.channelId)o=t.channelId;else if(t.userId)o=await Pt(e,t.userId,s);else o=await De(e,n,s);let a=(await r())?.userId??"",c=await qi(e,o,s);if(!t.asBot&&!!a&&c===a)console.error(`Warning: "${t.target}" is a DM to yourself \u2014 Slack will NOT notify you of your own message.
177
- `+` To reach yourself with a notification, ask as the bot: slack ask '${t.target}' '...' --as-bot`);let u=ds(t.question),f=ds(t.body??""),l=new Set([...u.kinds,...f.kinds]),d=t.mentionToken??e,h=await Bt(d,u.text,o,t.mentionCookie),m=f.text?await Bt(d,f.text,o,t.mentionCookie):{text:"",resolved:[],unresolved:[]},p=h.text,y=m.text,E=[...h.resolved,...m.resolved],F=[...h.unresolved,...m.unresolved];for(let J of yn(F))console.error(`\u26A0 ${te(J)}`);let k=l.size>0,C=new Set(E.map((J)=>J.userId).filter((J)=>J!==a)),A=new Map(E.map((J)=>[J.userId,J.display])),P;if(k)P=`anyone in ${n} (${[...l].map((J)=>`@${J}`).join(", ")})`;else{if(!C.size&&c&&c!==a)C.add(c),A.set(c,await ze(e,c,s));if(!C.size)console.error("Error: `ask` will not post a question nobody is addressed to \u2014 no one is tagged.\n"+(F.length?` (${F.map((J)=>te(J.surface)).join(", ")} matched no one, so it names nobody.)
173
+ `).map((m)=>` ${m}`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);let h=await Yt(e,r,s,f,t.cookie);console.log(`\u2713 Edited (ts: ${h})`)}async function Hf(e,t){let n=vt(e,t.cookie),{ref:i,ts:s}=Ds(t.target);if(!s)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 r;if(t.channelId)r=t.channelId;else r=await ye(e,i,t.cookie);let o=await Ke(e,r,s,1,t.cookie),c=X(o.messages).map(P).find((d)=>String(d.ts)===s);if(!c)console.error(`Message not found at ts=${s} in channel ${r}`),process.exit(1);let u=typeof c.text==="string"?c.text:"",f=await n(),l=He(r,s,u,f?.userId??"");if(t.code!==l){let d=await ys(e,r,i,t.cookie);Ne(t.code,l,["--- Deleting message -------------------------",ve(f),` \u2192 ${d} at ${zi(s)}`,...u.split(`
174
+ `).map((h)=>` ${h}`),"---------------------------------------------"])}await Ga(e,r,s,t.cookie),console.log(`\u2713 Deleted (ts: ${s})`)}async function qf(e,t){let{ref:n,ts:i}=Ds(t.target);if(!i)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 s=t.emoji.replace(/^:|:$/g,""),r;if(t.channelId)r=t.channelId;else r=await ye(e,n,t.cookie);if(t.remove)await fn(e,r,i,s,t.cookie),console.log(`\u2713 Removed :${s}: (ts: ${i})`);else await ut(e,r,i,s,t.cookie),console.log(`\u2713 Reacted :${s}: (ts: ${i})`)}async function Xi(e,t,n,i){if(!n||!t.startsWith("D"))return!1;try{let s=P(await Dn(e,t,i)),r=P(s.channel);return r.is_im===!0&&r.user===n}catch{return!1}}async function Yf(e,t){let{ref:n,threadTs:i}=Cn(t.target),s=t.cookie,r=vt(e,s),o;if(t.channelId)o=t.channelId;else if(t.userId)o=await Rt(e,t.userId,s);else o=await ye(e,n,s);if(!t.asBot&&await Xi(e,o,(await r())?.userId,s))console.error(`Warning: "${t.target}" is a DM to yourself \u2014 Slack will NOT notify you of your own message.
175
+ `+` To reach yourself with a notification, send as the bot: slack send '${t.target}' '...' --as-bot`);let a=t.message,c=null;if(t.mentions){c=await Nt(t.mentionToken??e,t.message,o,t.mentionCookie),a=c.text;for(let A of wn(c.unresolved))console.error(`\u26A0 ${ne(A)}`)}try{for(let A of await Ec(t.mentionToken??e,a,t.mentionCookie))console.error(`\u26A0 possible untagged mention: ${ne(A.surface)} \u2014 @${ne(A.display)} won't be notified (did you mean <@${A.userId}>?)`)}catch{}let u=[];if(c&&(c.resolved.length>0||c.unresolved.length>0)){u.push("--- Mentions ---------------------------------");for(let A of c.resolved)u.push(` \u2713 ${ne(A.surface)} \u2192 @${ne(A.display)} (${A.userId}) \u2014 will notify`);for(let A of c.unresolved){let I=A.reason==="ambiguous"?"ambiguous":A.reason==="unavailable"?"lookup unavailable":"no match";u.push(` \u26A0 ${ne(A.surface)} \u2014 plain text, NOT notified (${I})`)}}let f="",l="?",d=[],h,m,p;if(i)try{let A=await Ke(e,o,i,100,s);d=X(A.messages).map(P);let I=d[d.length-1];f=typeof I?.text==="string"?I.text:"",h=typeof I?.user==="string"?I.user:void 0,m=typeof I?.bot_id==="string"?I.bot_id:void 0,p=typeof I?.ts==="string"?I.ts:void 0}catch{}else try{let A=await Qe(e,o,1,void 0,void 0,s),I=X(A.messages).map(P),W=I.filter((R)=>R.subtype===void 0||R.subtype===null)[0];f=typeof W?.text==="string"?W.text:"",l=typeof W?.user==="string"?await ze(e,W.user,s):typeof W?.username==="string"?W.username:"?";let B=I[0];h=typeof B?.user==="string"?B.user:void 0,m=typeof B?.bot_id==="string"?B.bot_id:void 0,p=typeof B?.ts==="string"?B.ts:void 0}catch{}if(process.env.SLACK_UNREPLIED_WARN!=="0"&&p&&(h||m))try{let A=await r();if(!!A&&(!!h&&!!A.userId&&A.userId===h||!!m&&!!A.botId&&A.botId===m)){let W=`slack edit "#${o}:${p}" "<\u65B0\u3057\u3044\u672C\u6587>" --channel-id ${o}`;try{let B=await ln(e,o,p,s);if(B)W=`slack edit "${B}" "<\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(` ${W}`),console.error(" \u3053\u306E\u307E\u307E\u9001\u4FE1\u3059\u308B\u5834\u5408\u306F --code=XXXX \u3067\u78BA\u5B9A\u3002")}}catch{}if(i&&d.length){let A={sim:0,msg:null};for(let I of d){let W=typeof I.text==="string"?I.text:"";if(!W)continue;let B=Kf(a,W);if(B>A.sim)A={sim:B,msg:I}}if(A.msg&&A.sim>=0.82){let I=Math.round(A.sim*100);console.error(`\u26A0 possible duplicate: ${I}% similar to an existing thread message \u2014 ${await Ki(e,A.msg,60,s)}`)}}let y=await r(),C=await Yi(e,o,s),F=He(o,i??"",f,a,y?.userId??"");if(t.code!==F){let A=await ys(e,o,n,s),I=ve(y,{asBot:t.asBot});if(i){let W=await Jf(e,i,d,s),B=d.slice(-3),R=B.length?await Promise.all(B.map(async(Y)=>` ${await Ki(e,Y,60,s)}`)):[" (thread context unavailable)"];Ne(t.code,F,["--- Recent messages in thread ----------------",...R,...u,"--- Sending ----------------------------------",I,` \u2192 ${A} thread of ${W} \u2014 THREAD REPLY`,` Message: ${a}`,"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"],C)}else Ne(t.code,F,["--- Last message in channel ------------------",` ${l}: ${f.split(`
176
+ `)[0]?.slice(0,100)??"(empty)"}`,...u,"--- Sending ----------------------------------",I,` \u2192 ${A} \u2014 NEW top-level message`,` Message: ${a}`,"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"],C)}let k=await os(e,o,a,i,t.broadcast,s),S="";try{S=await ln(e,o,k,s)}catch{}if(S)console.log(`\u2713 Sent: ${S}`);else console.log(`\u2713 Sent (ts: ${k})`);if(t.asBot&&o.startsWith("D"))try{let A=await ui(e);if(!A.ok)for(let I of li(A,!0))console.error(I);else{let I=A.appId?`https://api.slack.com/apps/${A.appId}`:"https://api.slack.com/apps";console.error(`Note: if ${t.target} can't reply (app messaging may be off), enable Messages Tab: ${I} \u2192 App Home.`)}}catch{}}var Xf=2,Ee=3,Gf=1.618033988749895,Vf=1000,Zf=5000,Oc=8,Qf=(e)=>new Promise((t)=>setTimeout(t,e)),ed=new Set(["thread_broadcast"]),td=/(?<![A-Za-z0-9._@<-])@(here|channel|everyone)(?![A-Za-z0-9._-])/giu;function hs(e){let t=new Set;return{text:e.replace(td,(i,s)=>{let r=s.toLowerCase();return t.add(r),`<!${r}>`}),kinds:t}}async function ws(e,t,n){if(!t.startsWith("D"))return;try{let i=P(await Dn(e,t,n)),s=P(i.channel);return s.is_im===!0&&typeof s.user==="string"?s.user:void 0}catch{return}}async function Lc(e,t){let{channelId:n,ts:i,question:s,reactable:r,threadOnly:o,audience:a,broadcast:c,cookie:u,timeout:f,shown:l}=t,d=t.askerUserId,h=t.askerBotId,m=(B)=>typeof B==="string"&&!!B&&B!==d&&(c||a.has(B));function p(B){let R=X(B.reactions).map(P),Y=[];for(let _=0;_<r.length;_++){let E=R.find((j)=>j.name===Re[_].name),O=E?X(E.users).filter(m):[];if(O.length)Y.push({index:_,users:O})}return Y}async function y(B,R){let Y=typeof B.text==="string"?B.text:"";if(!Y)return;let _=Ci(Y,R);if(_===Y)return;try{await Yt(e,n,i,_,u,!0)}catch(E){console.error(` (\u8CEA\u554F\u6587\u306B\u6CE8\u610F\u66F8\u304D\u3092\u5165\u308C\u3089\u308C\u307E\u305B\u3093\u3067\u3057\u305F: ${E instanceof Error?E.message:String(E)})`)}}async function C(B){let R=p(B);if(R.length<=1&&Fi(typeof B.text==="string"?B.text:"").length)await y(B,[]);if(!R.length)return null;if(R.length===1){let{index:E,users:O}=R[0];return{answer:r[E],how:`\u30EA\u30A2\u30AF\u30B7\u30E7\u30F3 ${Re[E].glyph}`,who:O[0]}}let Y=R.map((E)=>Re[E.index].glyph).join(" / ");console.error(` (${Y} \u304C\u540C\u6642\u306B\u9078\u3070\u308C\u3066\u3044\u307E\u3059\u30021 \u3064\u306B\u7D5E\u3063\u3066\u3082\u3089\u3046\u307E\u3067\u5F85\u3061\u307E\u3059)`);let _=[...new Set(R.flatMap((E)=>E.users))].sort();return await y(B,_),null}function F(B,R=1/0){let Y=[...B].sort((_,E)=>Number(_.ts)-Number(E.ts));for(let _ of Y){if(!(Number(_.ts)>Number(i)))continue;if(!m(_.user))continue;if(typeof _.subtype==="string"&&!ed.has(_.subtype))continue;if(Number(_.ts)>=R)break;let E=typeof _.text==="string"?_.text.trim():"";if(E)return{answer:E,how:"\u8FD4\u4FE1",who:_.user}}return null}async function k(){if(t.threadParentTs){let _=P(await Ke(e,n,t.threadParentTs,100,u)),E=X(_.messages).map(P),O=E.find((j)=>j.ts===i);if(O){let j=await C(O);if(j)return j}return F(E)}let B=P(await Qe(e,n,30,i,void 0,u,!0)),R=X(B.messages).map(P),Y=R.find((_)=>_.ts===i);if(Y){let _=await C(Y);if(_)return _}if(!o){let _=R.filter((O)=>Number(O.ts)>Number(i)&&(h&&O.bot_id===h||d&&O.user===d)).reduce((O,j)=>Math.min(O,Number(j.ts)),1/0),E=F(R,_);if(E)return E}if(Y&&Number(Y.reply_count)>0){let _=P(await Ke(e,n,i,30,u)),E=F(X(_.messages).map(P));if(E)return E}return null}async function S(B){for(let Y=0;Y<r.length;Y++)try{await fn(e,n,i,Re[Y].name,u)}catch{}let R="";if(B.who)try{R=await ze(e,B.who,u)}catch{R=B.who}if(R)console.error(` \u56DE\u7B54\u8005: ${ne(R)}`);try{await Yt(e,n,i,ka(s,B,R),u,!0);try{await ut(e,n,i,Ei,u),await fn(e,n,i,ns,u)}catch{}}catch(Y){console.error(` (\u5143\u30E1\u30C3\u30BB\u30FC\u30B8\u306E\u66F4\u65B0\u306B\u5931\u6557: ${Y instanceof Error?Y.message:String(Y)})`)}}let A=Date.now()+f*1000,I=0,W=Vf;for(;;){let B=null;try{B=await k(),I=0}catch(R){if(I++,I>=Oc)console.error(`Error: Slack \u3078\u306E\u554F\u3044\u5408\u308F\u305B\u306B ${I} \u56DE\u9023\u7D9A\u3067\u5931\u6557\u3057\u307E\u3057\u305F: ${R instanceof Error?R.message:String(R)}`),process.exit(Ee);console.error(` (Slack \u30A8\u30E9\u30FC ${I}/${Oc}, \u518D\u8A66\u884C\u3057\u307E\u3059: ${R instanceof Error?R.message:String(R)})`)}if(B)await S(B),console.log(B.answer),process.exit(0);if(Date.now()>=A)break;await Qf(Math.min(W,Math.max(0,A-Date.now()))),W=Math.min(W*Gf,Zf)}if(f===0)console.error(`\u307E\u3060\u56DE\u7B54\u304C\u3042\u308A\u307E\u305B\u3093: ${l}`);else console.error(`Error: ${f}s \u4EE5\u5185\u306B\u56DE\u7B54\u304C\u3042\u308A\u307E\u305B\u3093\u3067\u3057\u305F (\u30E1\u30C3\u30BB\u30FC\u30B8\u306F\u305D\u306E\u307E\u307E\u6B8B\u3063\u3066\u3044\u307E\u3059)`),console.error(` ${l}`),console.error(` \u3042\u3068\u3067\u56DE\u53CE\u3059\u308B: ${Wc(l,t.asBot)}`);process.exit(Xf)}function Wc(e,t){return`slack ask --waitFor='${e}'${t?" --as-bot":""}`}async function nd(e,t){let{ref:n,threadTs:i}=Cn(t.target,!1),s=t.cookie,r=vt(e,s),o;if(t.channelId)o=t.channelId;else if(t.userId)o=await Rt(e,t.userId,s);else o=await ye(e,n,s);let a=(await r())?.userId??"",c=await ws(e,o,s);if(!t.asBot&&!!a&&c===a)console.error(`Warning: "${t.target}" is a DM to yourself \u2014 Slack will NOT notify you of your own message.
177
+ `+` To reach yourself with a notification, ask as the bot: slack ask '${t.target}' '...' --as-bot`);let u=hs(t.question),f=hs(t.body??""),l=new Set([...u.kinds,...f.kinds]),d=t.mentionToken??e,h=await Nt(d,u.text,o,t.mentionCookie),m=f.text?await Nt(d,f.text,o,t.mentionCookie):{text:"",resolved:[],unresolved:[]},p=h.text,y=m.text,C=[...h.resolved,...m.resolved],F=[...h.unresolved,...m.unresolved];for(let V of wn(F))console.error(`\u26A0 ${ne(V)}`);let k=l.size>0,S=new Set(C.map((V)=>V.userId).filter((V)=>V!==a)),A=new Map(C.map((V)=>[V.userId,V.display])),I;if(k)I=`anyone in ${n} (${[...l].map((V)=>`@${V}`).join(", ")})`;else{if(!S.size&&c&&c!==a)S.add(c),A.set(c,await ze(e,c,s));if(!S.size)console.error("Error: `ask` will not post a question nobody is addressed to \u2014 no one is tagged.\n"+(F.length?` (${F.map((V)=>ne(V.surface)).join(", ")} matched no one, so it names nobody.)
178
178
  `:"")+` Tag the person who should answer: slack ask '${t.target}' '@alice ${t.question}' ...
179
179
  Or open it to the whole channel: slack ask '${t.target}' '@here ${t.question}' ...
180
- (In a 1:1 DM the other person counts automatically.)`),process.exit(Ce);P=[...C].map((J)=>`@${te(A.get(J)??J)} (${J})`).join(", ")}let v=t.choices.slice(0,es),L=t.choices.slice(es),R=!o.startsWith("D")||!!i,G=xa(p,y,v,L,R),S="",x="?";try{let J=await Ze(e,o,1,void 0,void 0,s),ae=X(J.messages).map(T).filter((Oe)=>Oe.subtype===void 0||Oe.subtype===null)[0];S=typeof ae?.text==="string"?ae.text:"",x=typeof ae?.user==="string"?await ze(e,ae.user,s):typeof ae?.username==="string"?ae.username:"?"}catch{}let O=await r(),W=He(o,i??"",S,G,O?.userId??"");if(t.code!==W){let J=await ms(e,o,n,s),ae=v.length?["--- Choices (seeded as reactions) ------------",...v.map((Oe,z)=>` ${Me[z].glyph} ${Oe}`),...L.map((Oe,z)=>` (${z+11}) ${Oe} \u2014 text answer only`)]:["--- Choices ----------------------------------"," (none \u2014 free-text reply)"];ve(t.code,W,["--- Last message in channel ------------------",` ${x}: ${S.split(`
181
- `)[0]?.slice(0,100)??"(empty)"}`,...ae,"--- Asking -----------------------------------",je(O,{asBot:t.asBot}),` \u2192 ${J}${i?" \u2014 THREAD REPLY":" \u2014 NEW top-level message"}`,` Question: ${p}`,` Answerable by: ${P}`,` Via: ${R?"reactions or thread replies":"reactions or replies in this DM"}`,"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"])}let Z=await rs(e,o,G,i,!1,s,!0);try{await ct(e,o,Z,ts,s)}catch(J){console.error(` (marker ${ts} \u3092\u4ED8\u3051\u3089\u308C\u307E\u305B\u3093\u3067\u3057\u305F: ${J instanceof Error?J.message:String(J)})`)}for(let J=0;J<v.length;J++)try{await ct(e,o,Z,Me[J].name,s)}catch(ae){console.error(` (\u30EA\u30A2\u30AF\u30B7\u30E7\u30F3 ${Me[J].name} \u3092\u4ED8\u3051\u3089\u308C\u307E\u305B\u3093\u3067\u3057\u305F: ${ae instanceof Error?ae.message:String(ae)})`)}let re="";try{re=await ln(e,o,Z,s)}catch{}let Q=re||`${o}:${Z}`;if(console.error(`\u2713 Asked: ${Q}`),!t.wait){console.log(vc(Q,!!t.asBot));return}let oe=t.timeout??3600;console.error(` \u56DE\u7B54\u3092\u5F85\u3063\u3066\u3044\u307E\u3059 (\u6700\u5927 ${oe}s)\u2026 Ctrl-C \u3067\u4E2D\u65AD`);let $e={channelId:o,ts:Z,question:p,reactable:v,threadOnly:R,audience:C,broadcast:k,askerUserId:O?.userId??"",askerBotId:O?.botId??"",timeout:oe,shown:Q,asBot:!!t.asBot};if(i)$e.threadParentTs=i;if(s)$e.cookie=s;await Nc(e,$e)}async function Qf(e,t){let n=Rt(t.link),i,s,r;if(n?.ts)i=n.channel,s=n.ts,r=n.threadTs&&n.threadTs!==n.ts?n.threadTs:void 0;else{let m=t.link.match(/^([A-Za-z0-9]+):(\d{10}\.\d{6})$/);if(!m)console.error(`Error: --waitFor needs the permalink of a question (or 'C\u2026:1700000000.000100').
182
- `+` Got: ${te(t.link)}`),process.exit(Ce);i=m[1],s=m[2]}let o;if(r){let m=T(await Ke(e,i,r,100,t.cookie));o=X(m.messages).map(T).find((p)=>p.ts===s)}else{let m=T(await Ze(e,i,1,s,void 0,t.cookie,!0));o=X(m.messages).map(T).find((p)=>p.ts===s)}if(!o)console.error(`Error: \u305D\u306E\u30E1\u30C3\u30BB\u30FC\u30B8\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093: ${te(t.link)}`),process.exit(Ce);let a=typeof o.text==="string"?o.text:"",c=Sa(a);if(c.kind==="other")console.error("Error: \u3053\u308C\u306F `slack ask` \u306E\u8CEA\u554F\u3067\u306F\u3042\u308A\u307E\u305B\u3093 (\u56DE\u7B54\u306E\u8AAD\u307F\u53D6\u308A\u65B9\u304C\u5206\u304B\u308A\u307E\u305B\u3093)\u3002\n"+` ${te(t.link)}`),process.exit(Ce);if(c.kind==="resolved"){console.error(`\u2713 \u56DE\u7B54\u6E08\u307F: ${te(c.question)}`),console.log(c.answer);return}let u=typeof o.user==="string"?o.user:"",f=typeof o.bot_id==="string"?o.bot_id:"",l=/<!(here|channel|everyone)(\^[^>]*)?(\|[^>]*)?>/.test(a),d=new Set;for(let m of a.matchAll(/<@([UW][A-Z0-9]+)>/g))if(m[1]!==u)d.add(m[1]);if(!d.size&&!l){let m=await qi(e,i,t.cookie);if(m&&m!==u)d.add(m)}if(!d.size&&!l)console.error(`Error: \u3053\u306E\u8CEA\u554F\u306F\u8AB0\u306B\u3082\u5B9B\u3066\u3089\u308C\u3066\u3044\u306A\u3044\u305F\u3081\u3001\u6709\u52B9\u306A\u56DE\u7B54\u8005\u3092\u5224\u5B9A\u3067\u304D\u307E\u305B\u3093: ${te(t.link)}`),process.exit(Ce);if(t.timeout>0)console.error(` \u56DE\u7B54\u3092\u5F85\u3063\u3066\u3044\u307E\u3059 (\u6700\u5927 ${t.timeout}s)\u2026 Ctrl-C \u3067\u4E2D\u65AD`);let h={channelId:i,ts:s,question:c.question,reactable:c.reactable,threadOnly:c.threadOnly,audience:d,broadcast:l,askerUserId:u,askerBotId:f,timeout:t.timeout,shown:t.link,asBot:t.asBot};if(r)h.threadParentTs=r;if(t.cookie)h.cookie=t.cookie;await Nc(e,h)}var Ne=3;function ed(e){return`slack poll --results='${e}'`}async function td(e,t){let{ref:n,threadTs:i}=Fn(t.target,!1),s=t.cookie,r=Nt(e,s),o;if(t.channelId)o=t.channelId;else if(t.userId)o=await Pt(e,t.userId,s);else o=await De(e,n,s);let a=(await r())?.userId??"",c=await qi(e,o,s);if(!t.asBot&&!!a&&c===a)console.error(`Warning: "${t.target}" is a DM to yourself \u2014 Slack will NOT notify you of your own message.
183
- `+` To reach yourself with a notification, post as the bot: slack poll '${t.target}' '...' --as-bot`);let u=ds(t.question),f=ds(t.body??""),l=t.mentionToken??e,d=await Bt(l,u.text,o,t.mentionCookie),h=f.text?await Bt(l,f.text,o,t.mentionCookie):{text:"",resolved:[],unresolved:[]},m=d.text,p=h.text;for(let S of yn([...d.unresolved,...h.unresolved]))console.error(`\u26A0 ${te(S)}`);let y=t.choices,E=!!t.multi,F=t.until??"",k=Ta(m,p,y,{multi:E,deadline:F}),C="",A="?";try{let S=await Ze(e,o,1,void 0,void 0,s),x=X(S.messages).map(T).filter((O)=>O.subtype===void 0||O.subtype===null)[0];C=typeof x?.text==="string"?x.text:"",A=typeof x?.user==="string"?await ze(e,x.user,s):typeof x?.username==="string"?x.username:"?"}catch{}let P=await r(),v=He(o,i??"",C,k,P?.userId??"");if(t.code!==v){let S=await ms(e,o,n,s);ve(t.code,v,["--- Last message in channel ------------------",` ${A}: ${C.split(`
184
- `)[0]?.slice(0,100)??"(empty)"}`,"--- Ballot (seeded as reactions) -------------",...y.map((x,O)=>` ${Be[O].glyph} ${x}`),"--- Posting ----------------------------------",je(P,{asBot:t.asBot}),` \u2192 ${S}${i?" \u2014 THREAD REPLY":" \u2014 NEW top-level message"}`,` Question: ${m}`,` Rule: ${E?"1 \u4EBA \u4F55\u7968\u3067\u3082 (--multi)":"1 \u4EBA 1 \u7968"}${F?` \u2014 \u7DE0\u5207 ${F}`:""}`," Note: \u3042\u306A\u305F\u81EA\u8EAB\u306E\u7968\u306F\u6570\u3048\u307E\u305B\u3093 (\u30D4\u30EB\u306F\u3042\u306A\u305F\u304C\u4ED8\u3051\u305F\u7A2E\u306A\u306E\u3067\u533A\u5225\u3067\u304D\u307E\u305B\u3093)","--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"])}let L=await rs(e,o,k,i,!1,s,!0);try{await ct(e,o,L,cn,s)}catch(S){console.error(` (marker ${cn} \u3092\u4ED8\u3051\u3089\u308C\u307E\u305B\u3093\u3067\u3057\u305F: ${S instanceof Error?S.message:String(S)})`)}for(let S=0;S<y.length;S++)try{await ct(e,o,L,Be[S].name,s)}catch(x){console.error(` (\u30EA\u30A2\u30AF\u30B7\u30E7\u30F3 ${Be[S].name} \u3092\u4ED8\u3051\u3089\u308C\u307E\u305B\u3093\u3067\u3057\u305F: ${x instanceof Error?x.message:String(x)})`)}let R="";try{R=await ln(e,o,L,s)}catch{}let G=R||`${o}:${L}`;console.error(`\u2713 Posted: ${G}`),console.log(ed(G)),console.error(` \u7DE0\u3081\u5207\u308B: slack poll --close='${G}'${t.asBot?" --as-bot":""}`)}async function nd(e,t,n){let i=Rt(t),s,r,o;if(i?.ts)s=i.channel,r=i.ts,o=i.threadTs&&i.threadTs!==i.ts?i.threadTs:void 0;else{let c=t.match(/^([A-Za-z0-9]+):(\d{10}\.\d{6})$/);if(!c)console.error(`Error: --results/--close needs the permalink of a poll (or 'C\u2026:1700000000.000100').
185
- `+` Got: ${te(t)}`),process.exit(Ne);s=c[1],r=c[2]}let a;if(o){let c=T(await Ke(e,s,o,100,n));a=X(c.messages).map(T).find((u)=>u.ts===r)}else{let c=T(await Ze(e,s,1,r,void 0,n,!0));a=X(c.messages).map(T).find((u)=>u.ts===r)}if(!a)console.error(`Error: \u305D\u306E\u30E1\u30C3\u30BB\u30FC\u30B8\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093: ${te(t)}`),process.exit(Ne);return{channelId:s,ts:r,msg:a}}function Ac(e){let t=Math.max(1,...e.map((n)=>n.count));return e.map((n,i)=>`${Be[i].glyph} ${String(n.count).padStart(3)} ${"\u2588".repeat(Math.round(n.count/t*20))}${n.count?" ":""}${n.choice}`)}async function sd(e,t){let{channelId:n,ts:i,msg:s}=await nd(e,t.link,t.cookie),r=typeof s.text==="string"?s.text:"",o=Ra(r);if(o.kind==="other")console.error("Error: \u3053\u308C\u306F `slack poll` \u306E\u6295\u7968\u3067\u306F\u3042\u308A\u307E\u305B\u3093 (\u7968\u306E\u6570\u3048\u65B9\u304C\u5206\u304B\u308A\u307E\u305B\u3093)\u3002\n"+` ${te(t.link)}`),process.exit(Ne);if(o.kind==="closed"){console.error(`\u2713 \u6295\u7968\u7D42\u4E86: ${te(o.question)}`);for(let h of Ac(o.tallies))console.log(h);return}let a=new Set;if(typeof s.user==="string"&&s.user)a.add(s.user);let c=await Xa(e,n,i,t.cookie),u=Ma(o.choices,c,a,o.multi);console.error(`${te(o.question)}${o.deadline?` (\u7DE0\u5207 ${o.deadline})`:""}`);for(let h of Ac(u.tallies))console.log(h);let f=u.tallies.reduce((h,m)=>h+m.count,0);if(console.error(` \u8A08 ${f} \u7968${o.multi?" (\u8907\u6570\u9078\u629E\u53EF)":""}`),t.names)for(let h=0;h<u.voters.length;h++){if(!u.voters[h].length)continue;let m=await Promise.all(u.voters[h].map((p)=>ze(e,p,t.cookie)));console.error(` ${Be[h].glyph} ${m.map((p)=>`@${te(p)}`).join(", ")}`)}let l=o.multi?[]:u.ambiguous,d=wi(r,l);if(d!==r&&!t.noNotify)try{await Yt(t.writeToken??e,n,i,d,t.writeToken?t.writeCookie:t.cookie,!0)}catch(h){console.error(` (\u6295\u7968\u6587\u306B\u6CE8\u610F\u66F8\u304D\u3092\u5165\u308C\u3089\u308C\u307E\u305B\u3093\u3067\u3057\u305F: ${h instanceof Error?h.message:String(h)})
186
- `+" \u30E1\u30C3\u30BB\u30FC\u30B8\u3092\u66F8\u304D\u63DB\u3048\u3089\u308C\u308B\u306E\u306F\u6295\u7A3F\u8005\u3060\u3051\u3067\u3059 \u2014 bot \u304C\u6295\u7A3F\u3057\u305F\u6295\u7968\u306A\u3089 --as-bot \u3092\u4ED8\u3051\u3066\u304F\u3060\u3055\u3044\u3002")}if(u.ambiguous.length){let h=await Promise.all(u.ambiguous.map((m)=>ze(e,m,t.cookie)));console.error(`\u26A0 1 \u4EBA 1 \u7968\u306A\u306E\u306B\u8907\u6570\u62BC\u3057\u3066\u3044\u308B\u4EBA\u304C\u3044\u307E\u3059 (\u7121\u52B9\u7968): ${h.map((m)=>`@${te(m)}`).join(", ")}`)}if(!t.close)return;await Yt(t.writeToken??e,n,i,Pa(o.question,u.tallies),t.writeToken?t.writeCookie:t.cookie,!0);try{await ct(t.writeToken??e,n,i,Si,t.writeToken?t.writeCookie:t.cookie),await fn(t.writeToken??e,n,i,cn,t.writeToken?t.writeCookie:t.cookie)}catch{}console.error(`\u2713 \u6295\u7968\u3092\u7DE0\u3081\u5207\u308A\u307E\u3057\u305F: ${te(t.link)}`)}async function id(e){let t=await oi(e);for(let n of ai(t,!1))console.log(n);if(!t.ok)process.exit(1)}function rd(e){if(/^\d{10,}$/.test(e))return parseInt(e,10);let t=new Date(e.replace(" ","T"));if(isNaN(t.getTime()))throw Error(`Cannot parse time: ${e}`);return Math.floor(t.getTime()/1000)}function od(e){let t=new Date(e*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(t).replace(/\u2212/g,"-")} (local) / ${t.toISOString()} (Unix: ${e})`}async function ad(e,t){let n=Nt(e,t.cookie),{ref:i,threadTs:s}=Fn(t.target),r;if(t.channelId)r=t.channelId;else if(t.userId)r=await Pt(e,t.userId,t.cookie);else r=await De(e,i,t.cookie);let o=rd(t.at),a=new Date(o*1000).toISOString(),c=await n();if(await Hi(e,r,c?.userId,t.cookie))console.error(`Warning: "${t.target}" is a DM to yourself \u2014 Slack will NOT notify you when this fires.`);let u=He(r,t.message,String(o),c?.userId??"");if(t.code!==u)ve(t.code,u,["--- Scheduling message -----------------------",je(c,{pad:9}),` To: ${i}${s?` (thread ${s})`:""}`,` At: ${od(o)}`,` Message: ${t.message}`,"---------------------------------------------"]);let f=await za(e,r,t.message,o,s,t.cookie);console.log(`\u2713 Scheduled (id: ${f}, at: ${a})`)}async function cd(e,t,n,i){let s;if(n)s=n;else if(t)s=await De(e,t,i);let o=(await Ha(e,s,i)).scheduled_messages??[];if(o.length===0){console.log("(no scheduled messages)");return}for(let a of o){let c=new Date(a.post_at*1000).toISOString();console.log(`${a.id} ${c} [${a.channel_id}] ${a.text.split(`
187
- `)[0]?.slice(0,80)??""}`)}}async function ud(e,t){let n;if(t.channelId)n=t.channelId;else n=await De(e,t.target,t.cookie);let i=await Vt(e,t.cookie),s=He(n,t.id,i?.userId??"");if(t.code!==s)ve(t.code,s,["--- Deleting scheduled message ---------------",je(i,{pad:9}),` Channel: ${t.target}`,` ID: ${t.id}`,"---------------------------------------------"]);await qa(e,n,t.id,t.cookie),console.log(`\u2713 Deleted scheduled message ${t.id}`)}async function ld(e,t){let n=Nt(e,t.cookie),{statSync:i,existsSync:s}=await import("fs"),{basename:r}=await import("path");for(let m of t.filePaths)if(!s(m))console.error(`Error: file not found: ${m}`),process.exit(1);let{ref:o,threadTs:a}=Fn(t.target),c;if(t.channelId)c=t.channelId;else if(t.userId)c=await Pt(e,t.userId,t.cookie);else c=await De(e,o,t.cookie);if(await Hi(e,c,(await n())?.userId,t.cookie))console.error(`Warning: "${t.target}" is a DM to yourself \u2014 Slack will NOT notify you of your own upload.`);let u=t.filePaths.length>1,f=t.filePaths.map((m)=>{let p=r(m),y=u?p:t.title??p;return{fp:m,filename:p,title:y,sizeFmt:hs(i(m).size)}}),l=await n(),d=He(c,...f.flatMap((m)=>[m.fp,m.title]),l?.userId??"");if(t.code!==d){let m=` To: ${o}${a?` (thread ${a})`:""}`,p=u?[`--- Uploading ${f.length} files ------------------------`,je(l,{pad:7}),m,...f.map((y)=>` ${y.filename} (${y.sizeFmt})`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]:["--- Uploading file ---------------------------",je(l,{pad:7}),m,` File: ${f[0].fp}`,` Title: ${f[0].title}`,` Size: ${f[0].sizeFmt}`,"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"];ve(t.code,d,p)}let h=f.length;for(let m=0;m<h;m++){let p=f[m],y={title:p.title};if(a!==void 0)y.threadTs=a;if(t.comment!==void 0&&m===0)y.initialComment=t.comment;let{fileId:E,permalink:F}=await sc(e,c,p.fp,y,t.cookie),k=h>1?`[${m+1}/${h}] `:"";console.log(`${k}\u2713 Uploaded (file_id: ${E}${F?`, url: ${F}`:""})`)}}async function fd(e,t,n){let i=n.channel?await De(e,n.channel,t):void 0,s=[],r=1,o=1;do{let c={page:r,count:200};if(n.types)c.types=n.types;if(i)c.channel=i;if(n.user)c.user=n.user;let u=T(await Wa(e,c,t));for(let f of X(u.files))s.push(T(f));o=Number(T(u.paging).pages??1),r++}while(s.length<n.limit&&r<=o);let a=s.slice(0,n.limit);if(n.format==="jsonl"){for(let c of a)console.log(JSON.stringify({id:c.id??null,name:c.name??c.title??null,filetype:c.filetype??null,size:c.size??null,user:c.user??null,created:c.created??null,permalink:c.permalink??null}));return}for(let c of a){let u=String(c.id??""),f=typeof c.name==="string"?c.name:typeof c.title==="string"?c.title:u,l=typeof c.filetype==="string"?c.filetype:"?",d=typeof c.size==="number"?hs(c.size):"";console.log(`${u} ${l.padEnd(7)} ${d.padStart(9)} ${f}`)}}function dd(e){if(/^F[A-Z0-9]+$/i.test(e))return e;return e.match(/\/lists\/[A-Za-z0-9]+\/(F[A-Za-z0-9]+)/i)?.[1]??e.match(/\/lists\/(F[A-Za-z0-9]+)/i)?.[1]}function pd(e){if(typeof e.text==="string"&&e.text)return e.text;let t=e.value;if(typeof t==="string"||typeof t==="number"||typeof t==="boolean")return String(t);if(Array.isArray(t))return t.map((n)=>typeof n==="string"?n:String(T(n).text??T(n).name??T(n).value??"")).filter(Boolean).join(", ");for(let n of["rich_text","select","user","date","number","checkbox","email","phone"]){let i=e[n];if(i!=null)return typeof i==="object"?JSON.stringify(i):String(i)}return""}async function hd(e,t,n,i){let s=dd(n);if(!s)throw Error(`Not a list ID or list URL: ${n}
188
- `+"Expected F\u2026 or https://<ws>.slack.com/lists/<TEAM>/<F-id>");let r=[],o;do{let c={limit:200};if(o)c.cursor=o;let u=T(await Ua(e,s,c,t));for(let l of X(u.items??u.records))r.push(T(l));let f=T(u.response_metadata).next_cursor;o=typeof f==="string"&&f?f:void 0}while(o&&r.length<i.limit);let a=r.slice(0,i.limit);if(i.format==="jsonl"){for(let c of a)console.log(JSON.stringify(c));return}for(let c of a){let u=String(c.id??""),f=X(c.fields).map(T).map((l)=>{let d=String(l.key??l.column_id??"?"),h=pd(l);return h?`${d}=${h}`:""}).filter(Boolean);console.log(`${u} ${f.join(" | ")}`)}}function gd(e){if(/^F[A-Z0-9]+$/i.test(e))return e;return e.match(/\/files\/[A-Za-z0-9]+\/(F[A-Za-z0-9]+)/)?.[1]}async function md(e,t,n,i){let s=gd(n);if(!s)throw Error(`Not a file ID or file permalink: ${n}
189
- `+"Expected F\u2026 or https://<ws>.slack.com/files/<UID>/<FID>/<name>");let r=T(await La(e,s,t)),o=T(r.file),a=typeof o.name==="string"?o.name:typeof o.title==="string"?o.title:s,c=typeof o.url_private_download==="string"?o.url_private_download:typeof o.url_private==="string"?o.url_private:"";if(!c)throw Error(`files.info returned no download URL for ${s}`);let u={Authorization:`Bearer ${e}`};if(t)u.Cookie=`d=${t}`;let f=await fetch(c,{headers:u});if(!f.ok)throw Error(`Download failed: HTTP ${f.status} ${f.statusText}`);let l=Buffer.from(await f.arrayBuffer()),{statSync:d,existsSync:h}=await import("fs"),{basename:m}=await import("path"),p=i??a;if(i&&h(i)&&d(i).isDirectory())p=ft(i,m(a));Oc(p,l),console.log(`\u2713 Downloaded ${a} (${hs(l.length)}) \u2192 ${p}`)}async function Dd(){wf();let e=(s)=>ei(s.workspace),t=(s)=>No(s.workspace),n={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"},in:{type:"string",describe:"Limit to a channel (#chan)"},from:{type:"string",describe:"Limit to a sender (@user, or 'me') \u2014 usually the person a task is waiting on"},n:{alias:"count",type:"number",default:50,describe:"Max results"},json:{type:"boolean",default:!1}},i=async(s,r)=>{let o={state:s.state??"open",mine:r||s.mine===!0,count:s.n??50,json:s.json===!0};if(s.in)o.in=s.in;if(s.from)o.from=s.from;let a=t(s);if(a)o.cookie=a;await Of(e(s),o)};await Oo(Is(process.argv)).scriptName("slack").showHelpOnFail(!1).fail((s,r,o)=>{if(r)console.error(r.message),process.exit(1);console.error(s),console.error(""),o.showHelp(),process.exit(1)}).option("workspace",{alias:"w",type:"string",describe:"Workspace name"}).middleware(async(s)=>{let r=String((s._??[])[0]??"");if(!r||r==="auth"||r==="login")return;try{ei(s.workspace)}catch(o){if((o instanceof Error?o.message:String(o)).startsWith("No profiles configured"))console.log(`No workspace configured. Let's set that up:
190
- `),await Vn(),process.exit(0);throw o}},!0).command(["read [target]","msgs [target]"],"Browse messages",(s)=>s.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(s)=>{let r=e(s),o=s.json?"jsonl":s.format;if(s.target)await xf(r,s.target,s.limit,o,s.unreplied,t(s));else await Sf(r)}).command("thread <target> <ts>","Show thread messages",(s)=>s.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(s)=>{let r=s.json?"jsonl":s.format;await _f(e(s),s.target,s.ts,s.limit,r,t(s))}).command(["channel","channels","ch"],"Channel commands",(s)=>s.command(["ls","list"],"List channels",(r)=>r.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(r)=>{await Af(e(r),r.limit,r.filter,r.all,r.json?"jsonl":r.format)}).command("get <channel>","Show channel details",(r)=>r.positional("channel",{type:"string",demandOption:!0,describe:"#name or channel ID"}),async(r)=>{let o=e(r),a=t(r),c=r.channel,u=c.startsWith("#")||c.startsWith("@")||c.startsWith("C")||c.startsWith("G")||c.startsWith("D")?c:`#${c}`,f=await De(o,u,a),l=T(await mn(o,f,a)),d=T(l.channel),h=typeof d.name==="string"?d.name:f,p=d.is_im===!0?"@":"#",y=String(T(d.purpose).value??""),E=String(T(d.topic).value??""),F=d.num_members??d.member_count??"";if(console.log(`${p}${h} ${f}`),E)console.log(`topic: ${E}`);if(y)console.log(`purpose: ${y}`);if(F)console.log(`members: ${F}`);console.log(`private: ${d.is_private===!0}`)}).command(["create <name>","new <name>"],"Create a channel (confirm-hash safety gate)",(r)=>r.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(r)=>{let o=e(r),a=t(r),c=r.name.replace(/^#/,"").toLowerCase(),u=r.private===!0,f=r.invite.filter(Boolean),l=await Vt(o,a),d=He(c,String(u),f.join(","),l?.userId??"");if(r.code!==d)ve(r.code,d,["--- Creating channel -------------------------",je(l,{pad:9}),` name: ${u?"\uD83D\uDD12 ":"#"}${c}`,` private: ${u}`,...f.length?[` invite: ${f.join(", ")}`]:[],"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);let h;try{h=await Ga(o,c,u,a)}catch(m){console.error(m instanceof Error?m.message:String(m)),process.exit(1)}if(console.log(`\u2713 Created ${u?"\uD83D\uDD12 ":"#"}${h.name} (${h.id})`),f.length){let m=[];for(let p of f)try{m.push(p.startsWith("U")||p.startsWith("W")?p:await pn(o,p,a))}catch(y){console.error(` ! could not resolve ${p}: ${y instanceof Error?y.message:String(y)}`)}for(let p of m)try{let y=T(await os(o,p,a)),E=T(y.user);if(E.is_ultra_restricted===!0)console.error(`\u26A0 ${p} 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(E.is_restricted===!0)console.error(`\u26A0 ${p} is a multi-channel guest \u2014 double-check they were actually added (guest invites can silently no-op depending on workspace restrictions).`)}catch{}if(m.length)try{await Va(o,h.id,m,a),console.log(`\u2713 Invited ${m.length} member${m.length===1?"":"s"}`)}catch(p){console.error(` ! invite failed: ${p instanceof Error?p.message:String(p)}`)}}}).demandCommand(1,"").showHelpOnFail(!0)).command(["user","usr"],"User commands",(s)=>s.command(["ls","list"],"List workspace members",(r)=>r.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"}).option("external",{type:"boolean",default:!1,describe:"Also include people reachable only through Slack Connect shared channels \u2014 they are in ANOTHER workspace, so users.list never returns them (costs one API call per shared channel)"}),async(r)=>{let o=r.json?"jsonl":r.format,a=e(r),c=t(r),u=await $i(a,c),f=r.filter?.toLowerCase(),l=X(u.members).map(T);if(r.external){let p=new Set(l.map((k)=>String(k.id))),y=T(await dn(a,c)),E=X(y.channels).map(T).filter((k)=>k.is_ext_shared===!0&&!!k.name),F=new Set;for(let k of E)try{for(let C of await Za(a,String(k.id),c))if(!p.has(C))F.add(C)}catch{}for(let k of F)try{let C=T(await os(a,k,c)),A=T(C.user);if(A.id)l.push(A)}catch{}}let d=l.filter((p)=>p.deleted!==!0&&p.is_bot!==!0&&String(p.id)!=="USLACKBOT").filter((p)=>{if(!f)return!0;let y=String(p.name??"").toLowerCase(),E=String(T(p.profile).real_name??"").toLowerCase(),F=String(T(p.profile).email??"").toLowerCase();return y.includes(f)||E.includes(f)||F.includes(f)}).slice(0,r.limit);if(o==="jsonl"){for(let p of d)console.log(JSON.stringify(p));return}if(o==="yaml"){for(let p of d){let y=function(E,F=""){if(E===null)return"null";if(typeof E==="string")return E.includes(`
180
+ (In a 1:1 DM the other person counts automatically.)`),process.exit(Ee);I=[...S].map((V)=>`@${ne(A.get(V)??V)} (${V})`).join(", ")}let W=t.choices.slice(0,ts),B=t.choices.slice(ts),R=!o.startsWith("D")||!!i,Y=Sa(p,y,W,B,R),_="",E="?";try{let V=await Qe(e,o,1,void 0,void 0,s),ge=X(V.messages).map(P).filter((J)=>J.subtype===void 0||J.subtype===null)[0];_=typeof ge?.text==="string"?ge.text:"",E=typeof ge?.user==="string"?await ze(e,ge.user,s):typeof ge?.username==="string"?ge.username:"?"}catch{}let O=await r(),j=await Yi(e,o,s),Q=He(o,i??"",_,Y,O?.userId??"");if(t.code!==Q){let V=await ys(e,o,n,s),ge=W.length?["--- Choices (seeded as reactions) ------------",...W.map((J,qe)=>` ${Re[qe].glyph} ${J}`),...B.map((J,qe)=>` (${qe+11}) ${J} \u2014 text answer only`)]:["--- Choices ----------------------------------"," (none \u2014 free-text reply)"];Ne(t.code,Q,["--- Last message in channel ------------------",` ${E}: ${_.split(`
181
+ `)[0]?.slice(0,100)??"(empty)"}`,...ge,"--- Asking -----------------------------------",ve(O,{asBot:t.asBot}),` \u2192 ${V}${i?" \u2014 THREAD REPLY":" \u2014 NEW top-level message"}`,` Question: ${p}`,` Answerable by: ${I}`,` Via: ${R?"reactions or thread replies":"reactions or replies in this DM"}`,"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"],j)}let se=await os(e,o,Y,i,!1,s,!0);try{await ut(e,o,se,ns,s)}catch(V){console.error(` (marker ${ns} \u3092\u4ED8\u3051\u3089\u308C\u307E\u305B\u3093\u3067\u3057\u305F: ${V instanceof Error?V.message:String(V)})`)}for(let V=0;V<W.length;V++)try{await ut(e,o,se,Re[V].name,s)}catch(ge){console.error(` (\u30EA\u30A2\u30AF\u30B7\u30E7\u30F3 ${Re[V].name} \u3092\u4ED8\u3051\u3089\u308C\u307E\u305B\u3093\u3067\u3057\u305F: ${ge instanceof Error?ge.message:String(ge)})`)}let Z="";try{Z=await ln(e,o,se,s)}catch{}let ae=Z||`${o}:${se}`;if(console.error(`\u2713 Asked: ${ae}`),!t.wait){console.log(Wc(ae,!!t.asBot));return}let je=t.timeout??3600;console.error(` \u56DE\u7B54\u3092\u5F85\u3063\u3066\u3044\u307E\u3059 (\u6700\u5927 ${je}s)\u2026 Ctrl-C \u3067\u4E2D\u65AD`);let ee={channelId:o,ts:se,question:p,reactable:W,threadOnly:R,audience:S,broadcast:k,askerUserId:O?.userId??"",askerBotId:O?.botId??"",timeout:je,shown:ae,asBot:!!t.asBot};if(i)ee.threadParentTs=i;if(s)ee.cookie=s;await Lc(e,ee)}async function sd(e,t){let n=Mt(t.link),i,s,r;if(n?.ts)i=n.channel,s=n.ts,r=n.threadTs&&n.threadTs!==n.ts?n.threadTs:void 0;else{let m=t.link.match(/^([A-Za-z0-9]+):(\d{10}\.\d{6})$/);if(!m)console.error(`Error: --waitFor needs the permalink of a question (or 'C\u2026:1700000000.000100').
182
+ `+` Got: ${ne(t.link)}`),process.exit(Ee);i=m[1],s=m[2]}let o;if(r){let m=P(await Ke(e,i,r,100,t.cookie));o=X(m.messages).map(P).find((p)=>p.ts===s)}else{let m=P(await Qe(e,i,1,s,void 0,t.cookie,!0));o=X(m.messages).map(P).find((p)=>p.ts===s)}if(!o)console.error(`Error: \u305D\u306E\u30E1\u30C3\u30BB\u30FC\u30B8\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093: ${ne(t.link)}`),process.exit(Ee);let a=typeof o.text==="string"?o.text:"",c=Aa(a);if(c.kind==="other")console.error("Error: \u3053\u308C\u306F `slack ask` \u306E\u8CEA\u554F\u3067\u306F\u3042\u308A\u307E\u305B\u3093 (\u56DE\u7B54\u306E\u8AAD\u307F\u53D6\u308A\u65B9\u304C\u5206\u304B\u308A\u307E\u305B\u3093)\u3002\n"+` ${ne(t.link)}`),process.exit(Ee);if(c.kind==="resolved"){console.error(`\u2713 \u56DE\u7B54\u6E08\u307F: ${ne(c.question)}`),console.log(c.answer);return}let u=typeof o.user==="string"?o.user:"",f=typeof o.bot_id==="string"?o.bot_id:"",l=/<!(here|channel|everyone)(\^[^>]*)?(\|[^>]*)?>/.test(a),d=new Set;for(let m of a.matchAll(/<@([UW][A-Z0-9]+)>/g))if(m[1]!==u)d.add(m[1]);if(!d.size&&!l){let m=await ws(e,i,t.cookie);if(m&&m!==u)d.add(m)}if(!d.size&&!l)console.error(`Error: \u3053\u306E\u8CEA\u554F\u306F\u8AB0\u306B\u3082\u5B9B\u3066\u3089\u308C\u3066\u3044\u306A\u3044\u305F\u3081\u3001\u6709\u52B9\u306A\u56DE\u7B54\u8005\u3092\u5224\u5B9A\u3067\u304D\u307E\u305B\u3093: ${ne(t.link)}`),process.exit(Ee);if(t.timeout>0)console.error(` \u56DE\u7B54\u3092\u5F85\u3063\u3066\u3044\u307E\u3059 (\u6700\u5927 ${t.timeout}s)\u2026 Ctrl-C \u3067\u4E2D\u65AD`);let h={channelId:i,ts:s,question:c.question,reactable:c.reactable,threadOnly:c.threadOnly,audience:d,broadcast:l,askerUserId:u,askerBotId:f,timeout:t.timeout,shown:t.link,asBot:t.asBot};if(r)h.threadParentTs=r;if(t.cookie)h.cookie=t.cookie;await Lc(e,h)}var Be=3;function id(e){return`slack poll --results='${e}'`}async function rd(e,t){let{ref:n,threadTs:i}=Cn(t.target,!1),s=t.cookie,r=vt(e,s),o;if(t.channelId)o=t.channelId;else if(t.userId)o=await Rt(e,t.userId,s);else o=await ye(e,n,s);let a=(await r())?.userId??"",c=await ws(e,o,s);if(!t.asBot&&!!a&&c===a)console.error(`Warning: "${t.target}" is a DM to yourself \u2014 Slack will NOT notify you of your own message.
183
+ `+` To reach yourself with a notification, post as the bot: slack poll '${t.target}' '...' --as-bot`);let u=hs(t.question),f=hs(t.body??""),l=t.mentionToken??e,d=await Nt(l,u.text,o,t.mentionCookie),h=f.text?await Nt(l,f.text,o,t.mentionCookie):{text:"",resolved:[],unresolved:[]},m=d.text,p=h.text;for(let E of wn([...d.unresolved,...h.unresolved]))console.error(`\u26A0 ${ne(E)}`);let y=t.choices,C=!!t.multi,F=t.until??"",k=Ra(m,p,y,{multi:C,deadline:F}),S="",A="?";try{let E=await Qe(e,o,1,void 0,void 0,s),O=X(E.messages).map(P).filter((j)=>j.subtype===void 0||j.subtype===null)[0];S=typeof O?.text==="string"?O.text:"",A=typeof O?.user==="string"?await ze(e,O.user,s):typeof O?.username==="string"?O.username:"?"}catch{}let I=await r(),W=await Yi(e,o,s),B=He(o,i??"",S,k,I?.userId??"");if(t.code!==B){let E=await ys(e,o,n,s);Ne(t.code,B,["--- Last message in channel ------------------",` ${A}: ${S.split(`
184
+ `)[0]?.slice(0,100)??"(empty)"}`,"--- Ballot (seeded as reactions) -------------",...y.map((O,j)=>` ${Me[j].glyph} ${O}`),"--- Posting ----------------------------------",ve(I,{asBot:t.asBot}),` \u2192 ${E}${i?" \u2014 THREAD REPLY":" \u2014 NEW top-level message"}`,` Question: ${m}`,` Rule: ${C?"1 \u4EBA \u4F55\u7968\u3067\u3082 (--multi)":"1 \u4EBA 1 \u7968"}${F?` \u2014 \u7DE0\u5207 ${F}`:""}`," Note: \u3042\u306A\u305F\u81EA\u8EAB\u306E\u7968\u306F\u6570\u3048\u307E\u305B\u3093 (\u30D4\u30EB\u306F\u3042\u306A\u305F\u304C\u4ED8\u3051\u305F\u7A2E\u306A\u306E\u3067\u533A\u5225\u3067\u304D\u307E\u305B\u3093)","--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"],W)}let R=await os(e,o,k,i,!1,s,!0);try{await ut(e,o,R,cn,s)}catch(E){console.error(` (marker ${cn} \u3092\u4ED8\u3051\u3089\u308C\u307E\u305B\u3093\u3067\u3057\u305F: ${E instanceof Error?E.message:String(E)})`)}for(let E=0;E<y.length;E++)try{await ut(e,o,R,Me[E].name,s)}catch(O){console.error(` (\u30EA\u30A2\u30AF\u30B7\u30E7\u30F3 ${Me[E].name} \u3092\u4ED8\u3051\u3089\u308C\u307E\u305B\u3093\u3067\u3057\u305F: ${O instanceof Error?O.message:String(O)})`)}let Y="";try{Y=await ln(e,o,R,s)}catch{}let _=Y||`${o}:${R}`;console.error(`\u2713 Posted: ${_}`),console.log(id(_)),console.error(` \u7DE0\u3081\u5207\u308B: slack poll --close='${_}'${t.asBot?" --as-bot":""}`)}async function od(e,t,n){let i=Mt(t),s,r,o;if(i?.ts)s=i.channel,r=i.ts,o=i.threadTs&&i.threadTs!==i.ts?i.threadTs:void 0;else{let c=t.match(/^([A-Za-z0-9]+):(\d{10}\.\d{6})$/);if(!c)console.error(`Error: --results/--close needs the permalink of a poll (or 'C\u2026:1700000000.000100').
185
+ `+` Got: ${ne(t)}`),process.exit(Be);s=c[1],r=c[2]}let a;if(o){let c=P(await Ke(e,s,o,100,n));a=X(c.messages).map(P).find((u)=>u.ts===r)}else{let c=P(await Qe(e,s,1,r,void 0,n,!0));a=X(c.messages).map(P).find((u)=>u.ts===r)}if(!a)console.error(`Error: \u305D\u306E\u30E1\u30C3\u30BB\u30FC\u30B8\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093: ${ne(t)}`),process.exit(Be);return{channelId:s,ts:r,msg:a}}function Ic(e){let t=Math.max(1,...e.map((n)=>n.count));return e.map((n,i)=>`${Me[i].glyph} ${String(n.count).padStart(3)} ${"\u2588".repeat(Math.round(n.count/t*20))}${n.count?" ":""}${n.choice}`)}async function ad(e,t){let{channelId:n,ts:i,msg:s}=await od(e,t.link,t.cookie),r=typeof s.text==="string"?s.text:"",o=Ba(r);if(o.kind==="other")console.error("Error: \u3053\u308C\u306F `slack poll` \u306E\u6295\u7968\u3067\u306F\u3042\u308A\u307E\u305B\u3093 (\u7968\u306E\u6570\u3048\u65B9\u304C\u5206\u304B\u308A\u307E\u305B\u3093)\u3002\n"+` ${ne(t.link)}`),process.exit(Be);if(o.kind==="closed"){console.error(`\u2713 \u6295\u7968\u7D42\u4E86: ${ne(o.question)}`);for(let h of Ic(o.tallies))console.log(h);return}let a=new Set;if(typeof s.user==="string"&&s.user)a.add(s.user);let c=await Va(e,n,i,t.cookie),u=Na(o.choices,c,a,o.multi);console.error(`${ne(o.question)}${o.deadline?` (\u7DE0\u5207 ${o.deadline})`:""}`);for(let h of Ic(u.tallies))console.log(h);let f=u.tallies.reduce((h,m)=>h+m.count,0);if(console.error(` \u8A08 ${f} \u7968${o.multi?" (\u8907\u6570\u9078\u629E\u53EF)":""}`),t.names)for(let h=0;h<u.voters.length;h++){if(!u.voters[h].length)continue;let m=await Promise.all(u.voters[h].map((p)=>ze(e,p,t.cookie)));console.error(` ${Me[h].glyph} ${m.map((p)=>`@${ne(p)}`).join(", ")}`)}let l=o.multi?[]:u.ambiguous,d=Ci(r,l);if(d!==r&&!t.noNotify)try{await Yt(t.writeToken??e,n,i,d,t.writeToken?t.writeCookie:t.cookie,!0)}catch(h){console.error(` (\u6295\u7968\u6587\u306B\u6CE8\u610F\u66F8\u304D\u3092\u5165\u308C\u3089\u308C\u307E\u305B\u3093\u3067\u3057\u305F: ${h instanceof Error?h.message:String(h)})
186
+ `+" \u30E1\u30C3\u30BB\u30FC\u30B8\u3092\u66F8\u304D\u63DB\u3048\u3089\u308C\u308B\u306E\u306F\u6295\u7A3F\u8005\u3060\u3051\u3067\u3059 \u2014 bot \u304C\u6295\u7A3F\u3057\u305F\u6295\u7968\u306A\u3089 --as-bot \u3092\u4ED8\u3051\u3066\u304F\u3060\u3055\u3044\u3002")}if(u.ambiguous.length){let h=await Promise.all(u.ambiguous.map((m)=>ze(e,m,t.cookie)));console.error(`\u26A0 1 \u4EBA 1 \u7968\u306A\u306E\u306B\u8907\u6570\u62BC\u3057\u3066\u3044\u308B\u4EBA\u304C\u3044\u307E\u3059 (\u7121\u52B9\u7968): ${h.map((m)=>`@${ne(m)}`).join(", ")}`)}if(!t.close)return;await Yt(t.writeToken??e,n,i,Ma(o.question,u.tallies),t.writeToken?t.writeCookie:t.cookie,!0);try{await ut(t.writeToken??e,n,i,$i,t.writeToken?t.writeCookie:t.cookie),await fn(t.writeToken??e,n,i,cn,t.writeToken?t.writeCookie:t.cookie)}catch{}console.error(`\u2713 \u6295\u7968\u3092\u7DE0\u3081\u5207\u308A\u307E\u3057\u305F: ${ne(t.link)}`)}async function cd(e){let t=await ui(e);for(let n of li(t,!1))console.log(n);if(!t.ok)process.exit(1)}function ud(e){if(/^\d{10,}$/.test(e))return parseInt(e,10);let t=new Date(e.replace(" ","T"));if(isNaN(t.getTime()))throw Error(`Cannot parse time: ${e}`);return Math.floor(t.getTime()/1000)}function ld(e){let t=new Date(e*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(t).replace(/\u2212/g,"-")} (local) / ${t.toISOString()} (Unix: ${e})`}async function fd(e,t){let n=vt(e,t.cookie),{ref:i,threadTs:s}=Cn(t.target),r;if(t.channelId)r=t.channelId;else if(t.userId)r=await Rt(e,t.userId,t.cookie);else r=await ye(e,i,t.cookie);let o=ud(t.at),a=new Date(o*1000).toISOString(),c=await n();if(await Xi(e,r,c?.userId,t.cookie))console.error(`Warning: "${t.target}" is a DM to yourself \u2014 Slack will NOT notify you when this fires.`);let u=He(r,t.message,String(o),c?.userId??"");if(t.code!==u)Ne(t.code,u,["--- Scheduling message -----------------------",ve(c,{pad:9}),` To: ${i}${s?` (thread ${s})`:""}`,` At: ${ld(o)}`,` Message: ${t.message}`,"---------------------------------------------"]);let f=await qa(e,r,t.message,o,s,t.cookie);console.log(`\u2713 Scheduled (id: ${f}, at: ${a})`)}async function dd(e,t,n,i){let s;if(n)s=n;else if(t)s=await ye(e,t,i);let o=(await Ya(e,s,i)).scheduled_messages??[];if(o.length===0){console.log("(no scheduled messages)");return}for(let a of o){let c=new Date(a.post_at*1000).toISOString();console.log(`${a.id} ${c} [${a.channel_id}] ${a.text.split(`
187
+ `)[0]?.slice(0,80)??""}`)}}async function pd(e,t){let n;if(t.channelId)n=t.channelId;else n=await ye(e,t.target,t.cookie);let i=await Vt(e,t.cookie),s=He(n,t.id,i?.userId??"");if(t.code!==s)Ne(t.code,s,["--- Deleting scheduled message ---------------",ve(i,{pad:9}),` Channel: ${t.target}`,` ID: ${t.id}`,"---------------------------------------------"]);await Xa(e,n,t.id,t.cookie),console.log(`\u2713 Deleted scheduled message ${t.id}`)}async function hd(e,t){let n=vt(e,t.cookie),{statSync:i,existsSync:s}=await import("fs"),{basename:r}=await import("path");for(let m of t.filePaths)if(!s(m))console.error(`Error: file not found: ${m}`),process.exit(1);let{ref:o,threadTs:a}=Cn(t.target),c;if(t.channelId)c=t.channelId;else if(t.userId)c=await Rt(e,t.userId,t.cookie);else c=await ye(e,o,t.cookie);if(await Xi(e,c,(await n())?.userId,t.cookie))console.error(`Warning: "${t.target}" is a DM to yourself \u2014 Slack will NOT notify you of your own upload.`);let u=t.filePaths.length>1,f=t.filePaths.map((m)=>{let p=r(m),y=u?p:t.title??p;return{fp:m,filename:p,title:y,sizeFmt:ms(i(m).size)}}),l=await n(),d=He(c,...f.flatMap((m)=>[m.fp,m.title]),l?.userId??"");if(t.code!==d){let m=` To: ${o}${a?` (thread ${a})`:""}`,p=u?[`--- Uploading ${f.length} files ------------------------`,ve(l,{pad:7}),m,...f.map((y)=>` ${y.filename} (${y.sizeFmt})`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]:["--- Uploading file ---------------------------",ve(l,{pad:7}),m,` File: ${f[0].fp}`,` Title: ${f[0].title}`,` Size: ${f[0].sizeFmt}`,"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"];Ne(t.code,d,p)}let h=f.length;for(let m=0;m<h;m++){let p=f[m],y={title:p.title};if(a!==void 0)y.threadTs=a;if(t.comment!==void 0&&m===0)y.initialComment=t.comment;let{fileId:C,permalink:F}=await rc(e,c,p.fp,y,t.cookie),k=h>1?`[${m+1}/${h}] `:"";console.log(`${k}\u2713 Uploaded (file_id: ${C}${F?`, url: ${F}`:""})`)}}async function gd(e,t,n){let i=n.channel?await ye(e,n.channel,t):void 0,s=[],r=1,o=1;do{let c={page:r,count:200};if(n.types)c.types=n.types;if(i)c.channel=i;if(n.user)c.user=n.user;let u=P(await Ja(e,c,t));for(let f of X(u.files))s.push(P(f));o=Number(P(u.paging).pages??1),r++}while(s.length<n.limit&&r<=o);let a=s.slice(0,n.limit);if(n.format==="jsonl"){for(let c of a)console.log(JSON.stringify({id:c.id??null,name:c.name??c.title??null,filetype:c.filetype??null,size:c.size??null,user:c.user??null,created:c.created??null,permalink:c.permalink??null}));return}for(let c of a){let u=String(c.id??""),f=typeof c.name==="string"?c.name:typeof c.title==="string"?c.title:u,l=typeof c.filetype==="string"?c.filetype:"?",d=typeof c.size==="number"?ms(c.size):"";console.log(`${u} ${l.padEnd(7)} ${d.padStart(9)} ${f}`)}}function md(e){if(/^F[A-Z0-9]+$/i.test(e))return e;return e.match(/\/lists\/[A-Za-z0-9]+\/(F[A-Za-z0-9]+)/i)?.[1]??e.match(/\/lists\/(F[A-Za-z0-9]+)/i)?.[1]}function Dd(e){if(typeof e.text==="string"&&e.text)return e.text;let t=e.value;if(typeof t==="string"||typeof t==="number"||typeof t==="boolean")return String(t);if(Array.isArray(t))return t.map((n)=>typeof n==="string"?n:String(P(n).text??P(n).name??P(n).value??"")).filter(Boolean).join(", ");for(let n of["rich_text","select","user","date","number","checkbox","email","phone"]){let i=e[n];if(i!=null)return typeof i==="object"?JSON.stringify(i):String(i)}return""}async function yd(e,t,n,i){let s=md(n);if(!s)throw Error(`Not a list ID or list URL: ${n}
188
+ `+"Expected F\u2026 or https://<ws>.slack.com/lists/<TEAM>/<F-id>");let r=[],o;do{let c={limit:200};if(o)c.cursor=o;let u=P(await Ka(e,s,c,t));for(let l of X(u.items??u.records))r.push(P(l));let f=P(u.response_metadata).next_cursor;o=typeof f==="string"&&f?f:void 0}while(o&&r.length<i.limit);let a=r.slice(0,i.limit);if(i.format==="jsonl"){for(let c of a)console.log(JSON.stringify(c));return}for(let c of a){let u=String(c.id??""),f=X(c.fields).map(P).map((l)=>{let d=String(l.key??l.column_id??"?"),h=Dd(l);return h?`${d}=${h}`:""}).filter(Boolean);console.log(`${u} ${f.join(" | ")}`)}}function wd(e){if(/^F[A-Z0-9]+$/i.test(e))return e;return e.match(/\/files\/[A-Za-z0-9]+\/(F[A-Za-z0-9]+)/)?.[1]}async function bd(e,t,n,i){let s=wd(n);if(!s)throw Error(`Not a file ID or file permalink: ${n}
189
+ `+"Expected F\u2026 or https://<ws>.slack.com/files/<UID>/<FID>/<name>");let r=P(await Ua(e,s,t)),o=P(r.file),a=typeof o.name==="string"?o.name:typeof o.title==="string"?o.title:s,c=typeof o.url_private_download==="string"?o.url_private_download:typeof o.url_private==="string"?o.url_private:"";if(!c)throw Error(`files.info returned no download URL for ${s}`);let u={Authorization:`Bearer ${e}`};if(t)u.Cookie=`d=${t}`;let f=await fetch(c,{headers:u});if(!f.ok)throw Error(`Download failed: HTTP ${f.status} ${f.statusText}`);let l=Buffer.from(await f.arrayBuffer()),{statSync:d,existsSync:h}=await import("fs"),{basename:m}=await import("path"),p=i??a;if(i&&h(i)&&d(i).isDirectory())p=dt(i,m(a));Pc(p,l),console.log(`\u2713 Downloaded ${a} (${ms(l.length)}) \u2192 ${p}`)}async function Fd(){Ef();let e=(s)=>si(s.workspace),t=(s)=>jo(s.workspace),n={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"},in:{type:"string",describe:"Limit to a channel (#chan)"},from:{type:"string",describe:"Limit to a sender (@user, or 'me') \u2014 usually the person a task is waiting on"},n:{alias:"count",type:"number",default:50,describe:"Max results"},json:{type:"boolean",default:!1}},i=async(s,r)=>{let o={state:s.state??"open",mine:r||s.mine===!0,count:s.n??50,json:s.json===!0};if(s.in)o.in=s.in;if(s.from)o.from=s.from;let a=t(s);if(a)o.cookie=a;await Rf(e(s),o)};await To(Rs(process.argv)).scriptName("slack").showHelpOnFail(!1).fail((s,r,o)=>{if(r)console.error(r.message),process.exit(1);console.error(s),console.error(""),o.showHelp(),process.exit(1)}).option("workspace",{alias:"w",type:"string",describe:"Workspace name"}).middleware(async(s)=>{let r=String((s._??[])[0]??"");if(!r||r==="auth"||r==="login")return;try{si(s.workspace)}catch(o){if((o instanceof Error?o.message:String(o)).startsWith("No profiles configured"))console.log(`No workspace configured. Let's set that up:
190
+ `),await Zn(),process.exit(0);throw o}},!0).command(["read [target]","msgs [target]"],"Browse messages",(s)=>s.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(s)=>{let r=e(s),o=s.json?"jsonl":s.format;if(s.target)await Af(r,s.target,s.limit,o,s.unreplied,t(s));else await Of(r)}).command("thread <target> <ts>","Show thread messages",(s)=>s.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(s)=>{let r=s.json?"jsonl":s.format;await $f(e(s),s.target,s.ts,s.limit,r,t(s))}).command(["channel","channels","ch"],"Channel commands",(s)=>s.command(["ls","list"],"List channels",(r)=>r.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(r)=>{await Tf(e(r),r.limit,r.filter,r.all,r.json?"jsonl":r.format)}).command("get <channel>","Show channel details",(r)=>r.positional("channel",{type:"string",demandOption:!0,describe:"#name or channel ID"}),async(r)=>{let o=e(r),a=t(r),c=r.channel,u=c.startsWith("#")||c.startsWith("@")||c.startsWith("C")||c.startsWith("G")||c.startsWith("D")?c:`#${c}`,f=await ye(o,u,a),l=P(await Dn(o,f,a)),d=P(l.channel),h=typeof d.name==="string"?d.name:f,p=d.is_im===!0?"@":"#",y=String(P(d.purpose).value??""),C=String(P(d.topic).value??""),F=d.num_members??d.member_count??"";if(console.log(`${p}${h} ${f}`),C)console.log(`topic: ${C}`);if(y)console.log(`purpose: ${y}`);if(F)console.log(`members: ${F}`);console.log(`private: ${d.is_private===!0}`)}).command(["create <name>","new <name>"],"Create a channel (confirm-hash safety gate)",(r)=>r.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(r)=>{let o=e(r),a=t(r),c=r.name.replace(/^#/,"").toLowerCase(),u=r.private===!0,f=r.invite.filter(Boolean),l=await Vt(o,a),d=He(c,String(u),f.join(","),l?.userId??"");if(r.code!==d)Ne(r.code,d,["--- Creating channel -------------------------",ve(l,{pad:9}),` name: ${u?"\uD83D\uDD12 ":"#"}${c}`,` private: ${u}`,...f.length?[` invite: ${f.join(", ")}`]:[],"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);let h;try{h=await Za(o,c,u,a)}catch(m){console.error(m instanceof Error?m.message:String(m)),process.exit(1)}if(console.log(`\u2713 Created ${u?"\uD83D\uDD12 ":"#"}${h.name} (${h.id})`),f.length){let m=[];for(let p of f)try{m.push(p.startsWith("U")||p.startsWith("W")?p:await pn(o,p,a))}catch(y){console.error(` ! could not resolve ${p}: ${y instanceof Error?y.message:String(y)}`)}for(let p of m)try{let y=P(await mn(o,p,a)),C=P(y.user);if(C.is_ultra_restricted===!0)console.error(`\u26A0 ${p} 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(C.is_restricted===!0)console.error(`\u26A0 ${p} is a multi-channel guest \u2014 double-check they were actually added (guest invites can silently no-op depending on workspace restrictions).`)}catch{}if(m.length)try{await Qa(o,h.id,m,a),console.log(`\u2713 Invited ${m.length} member${m.length===1?"":"s"}`)}catch(p){console.error(` ! invite failed: ${p instanceof Error?p.message:String(p)}`)}}}).demandCommand(1,"").showHelpOnFail(!0)).command(["user","usr"],"User commands",(s)=>s.command(["ls","list"],"List workspace members",(r)=>r.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"}).option("external",{type:"boolean",default:!1,describe:"Also include people reachable only through Slack Connect shared channels \u2014 they are in ANOTHER workspace, so users.list never returns them (costs one API call per shared channel)"}),async(r)=>{let o=r.json?"jsonl":r.format,a=e(r),c=t(r),u=await Ti(a,c),f=r.filter?.toLowerCase(),l=X(u.members).map(P);if(r.external){let p=new Set(l.map((k)=>String(k.id))),y=P(await dn(a,c)),C=X(y.channels).map(P).filter((k)=>k.is_ext_shared===!0&&!!k.name),F=new Set;for(let k of C)try{for(let S of await ec(a,String(k.id),c))if(!p.has(S))F.add(S)}catch{}for(let k of F)try{let S=P(await mn(a,k,c)),A=P(S.user);if(A.id)l.push(A)}catch{}}let d=l.filter((p)=>p.deleted!==!0&&p.is_bot!==!0&&String(p.id)!=="USLACKBOT").filter((p)=>{if(!f)return!0;let y=String(p.name??"").toLowerCase(),C=String(P(p.profile).real_name??"").toLowerCase(),F=String(P(p.profile).email??"").toLowerCase();return y.includes(f)||C.includes(f)||F.includes(f)}).slice(0,r.limit);if(o==="jsonl"){for(let p of d)console.log(JSON.stringify(p));return}if(o==="yaml"){for(let p of d){let y=function(C,F=""){if(C===null)return"null";if(typeof C==="string")return C.includes(`
191
191
  `)?`|
192
- ${E.split(`
192
+ ${C.split(`
193
193
  `).join(`
194
- `)}`:E;if(typeof E!=="object")return String(E);if(Array.isArray(E))return E.map((k)=>`
195
- ${F} - ${y(k,F+" ")}`).join("");return Object.entries(E).map(([k,C])=>`
196
- ${F} ${k}: ${y(C,F+" ")}`).join("")};console.log("---");for(let[E,F]of Object.entries(p))console.log(`${E}: ${y(F)}`)}return}let h=Intl.DateTimeFormat().resolvedOptions().timeZone,m=d.length?String(T(X(u.members).map(T)[0]??{}).team_id??""):"";for(let p of d){let y=T(p.profile),E=String(p.name??p.id),F=String(p.id??""),k=String(y.display_name||""),C=String(y.real_name||""),A=String(y.email||""),P=String(p.tz??""),L=[...new Set([k,C].filter((O)=>O&&O!==E))].join(" / "),R=P&&P!==h?P:"",G=String(p.team_id??""),S=p.is_stranger===!0||m&&G&&G!==m?`external:${G||"?"}`:p.is_ultra_restricted===!0?"single-channel guest":p.is_restricted===!0?"guest":"",x=[A,R].filter(Boolean).join(" ");console.log(`@${E} ${F} ${L}${x?" "+x:""}${S?` [${S}]`:""}`)}}).command("get <user>","Show user details",(r)=>r.positional("user",{type:"string",demandOption:!0,describe:"@handle or user ID"}),async(r)=>{let o=e(r),a=r.user.startsWith("@")?r.user.slice(1):r.user,c=a;if(!/^U[A-Z0-9]+$/.test(a)){let P=await $i(o,t(r)),v=X(P.members).map(T).find((L)=>String(L.name??"")===a);if(!v)console.error(`User not found: @${a}`),process.exit(1);c=String(v.id)}let u=T(await os(o,c)),f=T(u.user),l=T(f.profile),d=Intl.DateTimeFormat().resolvedOptions().timeZone,h=String(f.name??c),m=String(f.id??c),p=String(l.display_name||""),y=String(l.real_name||""),E=String(l.email||""),F=String(f.tz??""),k=String(l.phone||""),C=String(l.title||"");console.log(`@${h} ${m}`);let A=[...new Set([p,y].filter((P)=>P&&P!==h))];if(A.length)console.log(`name: ${A.join(" / ")}`);if(E)console.log(`email: ${E}`);if(k)console.log(`phone: ${k}`);if(C)console.log(`title: ${C}`);if(F&&F!==d)console.log(`tz: ${F}`)}).demandCommand(1,"").showHelpOnFail(!0)).command("news","Activity feed (mentions to you)",(s)=>s.option("limit",{alias:"l",type:"number",default:20}),async(s)=>{await kf(e(s),s.limit)}).command("search <query>","Full-text search",(s)=>s.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(s)=>{await Pc(e(s),s.query,s.count,s.json,t(s))}).command("send <target> <message>","Send a message (confirm-hash safety gate)",(s)=>s.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(s)=>{let r={target:s.target,message:s.message};if(s.code)r.code=s.code;if(s["channel-id"])r.channelId=s["channel-id"];if(s["user-id"])r.userId=s["user-id"];if(s.broadcast)r.broadcast=!0;if(s.mentions!==!1){r.mentions=!0,r.mentionToken=e(s);let a=t(s);if(a)r.mentionCookie=a}let o;if(s["as-bot"]){let a=Kt();if(!a)console.error(`Error: --as-bot needs a bot token, but no xoxb- token was found.
194
+ `)}`:C;if(typeof C!=="object")return String(C);if(Array.isArray(C))return C.map((k)=>`
195
+ ${F} - ${y(k,F+" ")}`).join("");return Object.entries(C).map(([k,S])=>`
196
+ ${F} ${k}: ${y(S,F+" ")}`).join("")};console.log("---");for(let[C,F]of Object.entries(p))console.log(`${C}: ${y(F)}`)}return}let h=Intl.DateTimeFormat().resolvedOptions().timeZone,m=d.length?String(P(X(u.members).map(P)[0]??{}).team_id??""):"";for(let p of d){let y=P(p.profile),C=String(p.name??p.id),F=String(p.id??""),k=String(y.display_name||""),S=String(y.real_name||""),A=String(y.email||""),I=String(p.tz??""),B=[...new Set([k,S].filter((O)=>O&&O!==C))].join(" / "),R=I&&I!==h?I:"",Y=String(p.team_id??""),_=p.is_stranger===!0||m&&Y&&Y!==m?`external:${Y||"?"}`:p.is_ultra_restricted===!0?"single-channel guest":p.is_restricted===!0?"guest":"",E=[A,R].filter(Boolean).join(" ");console.log(`@${C} ${F} ${B}${E?" "+E:""}${_?` [${_}]`:""}`)}}).command("get <user>","Show user details",(r)=>r.positional("user",{type:"string",demandOption:!0,describe:"@handle or user ID"}),async(r)=>{let o=e(r),a=r.user.startsWith("@")?r.user.slice(1):r.user,c=a;if(!/^U[A-Z0-9]+$/.test(a)){let I=await Ti(o,t(r)),W=X(I.members).map(P).find((B)=>String(B.name??"")===a);if(!W)console.error(`User not found: @${a}`),process.exit(1);c=String(W.id)}let u=P(await mn(o,c)),f=P(u.user),l=P(f.profile),d=Intl.DateTimeFormat().resolvedOptions().timeZone,h=String(f.name??c),m=String(f.id??c),p=String(l.display_name||""),y=String(l.real_name||""),C=String(l.email||""),F=String(f.tz??""),k=String(l.phone||""),S=String(l.title||"");console.log(`@${h} ${m}`);let A=[...new Set([p,y].filter((I)=>I&&I!==h))];if(A.length)console.log(`name: ${A.join(" / ")}`);if(C)console.log(`email: ${C}`);if(k)console.log(`phone: ${k}`);if(S)console.log(`title: ${S}`);if(F&&F!==d)console.log(`tz: ${F}`)}).demandCommand(1,"").showHelpOnFail(!0)).command("news","Activity feed (mentions to you)",(s)=>s.option("limit",{alias:"l",type:"number",default:20}),async(s)=>{await If(e(s),s.limit)}).command("search <query>","Full-text search",(s)=>s.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(s)=>{await Bc(e(s),s.query,s.count,s.json,t(s))}).command("send <target> <message>","Send a message (confirm-hash safety gate)",(s)=>s.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(s)=>{let r={target:s.target,message:s.message};if(s.code)r.code=s.code;if(s["channel-id"])r.channelId=s["channel-id"];if(s["user-id"])r.userId=s["user-id"];if(s.broadcast)r.broadcast=!0;if(s.mentions!==!1){r.mentions=!0,r.mentionToken=e(s);let a=t(s);if(a)r.mentionCookie=a}let o;if(s["as-bot"]){let a=Kt();if(!a)console.error(`Error: --as-bot needs a bot token, but no xoxb- token was found.
197
197
  Set SLACK_BOT_TOKEN=xoxb-... in ~/.config/slack-cli/.env (or your shell).`),process.exit(1);if(!r.channelId&&!r.userId&&r.target.startsWith("@"))try{r.userId=await pn(e(s),r.target,t(s))}catch(c){console.error(`Error: could not resolve ${r.target} to a user for the bot DM.
198
198
  ${c instanceof Error?c.message:String(c)}
199
- Tip: pass --user-id <Uxxxx> to skip the lookup.`),process.exit(1)}o=a,r.asBot=!0}else{o=e(s);let a=t(s);if(a)r.cookie=a}try{await Kf(o,r)}catch(a){console.error(tt(a)),process.exit(1)}}).command("ask [target] [question] [choices..]","Ask a question with its choices pre-seeded as 1\uFE0F\u20E3..\uD83D\uDD1F reactions (confirm-hash safety gate)",(s)=>s.positional("target",{type:"string",describe:"#chan, @user, #chan:thread_ts, or permalink (omit with --waitFor)"}).positional("question",{type:"string",describe:"The question. Must @tag whoever may answer (@alice), or the whole channel (@here / @channel / @everyone) \u2014 only their answer counts. In a 1:1 DM the other party counts automatically."}).positional("choices",{type:"string",array:!0,describe:"Up to 10 choices, seeded as 1\uFE0F\u20E3..\uD83D\uDD1F reactions. Beyond 10 they are listed but answerable only by text. With none, the question asks for a free-text reply."}).option("code",{type:"string",describe:"Safety hash to confirm the ask"}).option("body",{type:"string",describe:"Extra context shown under the question"}).option("wait",{type:"boolean",default:!1,describe:"Block until answered; print ONLY the answer on stdout. Exit 0 = answered, 2 = timed out, 3 = transport failure."}).option("waitFor",{type:"string",describe:"Collect the answer to a question already posted: pass its permalink. Nothing is posted. Same stdout/exit contract as --wait; --timeout 0 checks once and exits 2 if still open."}).option("timeout",{type:"number",default:3600,describe:"Overall limit for --wait / --waitFor, in seconds (0 with --waitFor = check once)"}).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:"Ask via the bot token (xoxb / SLACK_BOT_TOKEN) so a DM notifies the recipient"}),async(s)=>{let r=s.waitFor?String(s.waitFor):"",o=Number(s.timeout);if(!Number.isFinite(o)||o<0||o===0&&!r)console.error("Error: --timeout must be a positive number of seconds"),process.exit(Ce);if(r){if(s.target||s.question||s.choices?.length)console.error("Error: --waitFor collects an existing question \u2014 do not also pass a target/question/choices."),process.exit(Ce);let l,d;if(s["as-bot"]){let h=Kt();if(!h)console.error(`Error: --as-bot needs a bot token, but no xoxb- token was found.
200
- Set SLACK_BOT_TOKEN=xoxb-... in ~/.config/slack-cli/.env (or your shell).`),process.exit(Ce);l=h}else l=e(s),d=t(s);try{let h={link:r,timeout:o,asBot:!!s["as-bot"]};if(d)h.cookie=d;await Qf(l,h)}catch(h){console.error(tt(h)),process.exit(Ce)}return}if(!s.target)console.error("Error: target is required (or use --waitFor <permalink> to collect an answer)"),process.exit(Ce);let a=String(s.question??"").trim();if(!a)console.error("Error: question is empty"),process.exit(Ce);let c={target:s.target,question:a,choices:(s.choices??[]).map((l)=>String(l).trim()).filter(Boolean),timeout:o};if(s.code)c.code=s.code;if(s.body)c.body=s.body;if(s.wait)c.wait=!0;if(s["channel-id"])c.channelId=s["channel-id"];if(s["user-id"])c.userId=s["user-id"];c.mentionToken=e(s);let u=t(s);if(u)c.mentionCookie=u;let f;if(s["as-bot"]){let l=Kt();if(!l)console.error(`Error: --as-bot needs a bot token, but no xoxb- token was found.
201
- Set SLACK_BOT_TOKEN=xoxb-... in ~/.config/slack-cli/.env (or your shell).`),process.exit(Ce);if(!c.channelId&&!c.userId&&c.target.startsWith("@"))try{c.userId=await pn(e(s),c.target,t(s))}catch(d){console.error(`Error: could not resolve ${c.target} to a user for the bot DM.
199
+ Tip: pass --user-id <Uxxxx> to skip the lookup.`),process.exit(1)}o=a,r.asBot=!0}else{o=e(s);let a=t(s);if(a)r.cookie=a}try{await Yf(o,r)}catch(a){console.error(nt(a)),process.exit(1)}}).command("ask [target] [question] [choices..]","Ask a question with its choices pre-seeded as 1\uFE0F\u20E3..\uD83D\uDD1F reactions (confirm-hash safety gate)",(s)=>s.positional("target",{type:"string",describe:"#chan, @user, #chan:thread_ts, or permalink (omit with --waitFor)"}).positional("question",{type:"string",describe:"The question. Must @tag whoever may answer (@alice), or the whole channel (@here / @channel / @everyone) \u2014 only their answer counts. In a 1:1 DM the other party counts automatically."}).positional("choices",{type:"string",array:!0,describe:"Up to 10 choices, seeded as 1\uFE0F\u20E3..\uD83D\uDD1F reactions. Beyond 10 they are listed but answerable only by text. With none, the question asks for a free-text reply."}).option("code",{type:"string",describe:"Safety hash to confirm the ask"}).option("body",{type:"string",describe:"Extra context shown under the question"}).option("wait",{type:"boolean",default:!1,describe:"Block until answered; print ONLY the answer on stdout. Exit 0 = answered, 2 = timed out, 3 = transport failure."}).option("waitFor",{type:"string",describe:"Collect the answer to a question already posted: pass its permalink. Nothing is posted. Same stdout/exit contract as --wait; --timeout 0 checks once and exits 2 if still open."}).option("timeout",{type:"number",default:3600,describe:"Overall limit for --wait / --waitFor, in seconds (0 with --waitFor = check once)"}).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:"Ask via the bot token (xoxb / SLACK_BOT_TOKEN) so a DM notifies the recipient"}),async(s)=>{let r=s.waitFor?String(s.waitFor):"",o=Number(s.timeout);if(!Number.isFinite(o)||o<0||o===0&&!r)console.error("Error: --timeout must be a positive number of seconds"),process.exit(Ee);if(r){if(s.target||s.question||s.choices?.length)console.error("Error: --waitFor collects an existing question \u2014 do not also pass a target/question/choices."),process.exit(Ee);let l,d;if(s["as-bot"]){let h=Kt();if(!h)console.error(`Error: --as-bot needs a bot token, but no xoxb- token was found.
200
+ Set SLACK_BOT_TOKEN=xoxb-... in ~/.config/slack-cli/.env (or your shell).`),process.exit(Ee);l=h}else l=e(s),d=t(s);try{let h={link:r,timeout:o,asBot:!!s["as-bot"]};if(d)h.cookie=d;await sd(l,h)}catch(h){console.error(nt(h)),process.exit(Ee)}return}if(!s.target)console.error("Error: target is required (or use --waitFor <permalink> to collect an answer)"),process.exit(Ee);let a=String(s.question??"").trim();if(!a)console.error("Error: question is empty"),process.exit(Ee);let c={target:s.target,question:a,choices:(s.choices??[]).map((l)=>String(l).trim()).filter(Boolean),timeout:o};if(s.code)c.code=s.code;if(s.body)c.body=s.body;if(s.wait)c.wait=!0;if(s["channel-id"])c.channelId=s["channel-id"];if(s["user-id"])c.userId=s["user-id"];c.mentionToken=e(s);let u=t(s);if(u)c.mentionCookie=u;let f;if(s["as-bot"]){let l=Kt();if(!l)console.error(`Error: --as-bot needs a bot token, but no xoxb- token was found.
201
+ Set SLACK_BOT_TOKEN=xoxb-... in ~/.config/slack-cli/.env (or your shell).`),process.exit(Ee);if(!c.channelId&&!c.userId&&c.target.startsWith("@"))try{c.userId=await pn(e(s),c.target,t(s))}catch(d){console.error(`Error: could not resolve ${c.target} to a user for the bot DM.
202
202
  ${d instanceof Error?d.message:String(d)}
203
- Tip: pass --user-id <Uxxxx> to skip the lookup.`),process.exit(Ce)}f=l,c.asBot=!0}else{f=e(s);let l=t(s);if(l)c.cookie=l}try{await Zf(f,c)}catch(l){console.error(tt(l)),process.exit(Ce)}}).command(["poll [target] [question] [choices..]","vote [target] [question] [choices..]"],"Post a poll with its choices pre-seeded as 1\uFE0F\u20E3..\uD83D\uDD1F reactions, then count them (confirm-hash safety gate)",(s)=>s.positional("target",{type:"string",describe:"#chan, @user, #chan:thread_ts, or permalink (omit with --results/--close)"}).positional("question",{type:"string",describe:"The question. @tags are optional here \u2014 unlike `ask`, a poll needs no addressee: anyone who can see it may vote."}).positional("choices",{type:"string",array:!0,describe:"2..10 choices, seeded as 1\uFE0F\u20E3..\uD83D\uDD1F reactions for voters to click"}).option("multi",{type:"boolean",default:!1,describe:"Let one person pick several choices (default: 1 \u4EBA 1 \u7968)"}).option("until",{type:"string",describe:"Deadline shown in the message (display only \u2014 closing is still `--close`)"}).option("results",{type:"string",describe:"Count an existing poll: pass its permalink. Posts nothing; only edit is the invalid-ballot notice in the poll itself (--no-notify to suppress)."}).option("close",{type:"string",describe:"Count an existing poll AND freeze the tally into the message. Only the poster can do this."}).option("names",{type:"boolean",default:!1,describe:"Also list who voted for what (stderr)"}).option("no-notify",{type:"boolean",default:!1,describe:"With --results: do not write the invalid-ballot notice back into the message (keeps it strictly read-only)"}).option("code",{type:"string",describe:"Safety hash to confirm the post"}).option("body",{type:"string",describe:"Extra context shown under the question"}).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:"Post via the bot token (xoxb / SLACK_BOT_TOKEN) so a DM notifies the recipient \u2014 and so YOUR OWN vote counts, since the seeds are then the bot's"}),async(s)=>{let r=s.close?String(s.close):s.results?String(s.results):"";if(s.results&&s.close)console.error("Error: pass --results or --close, not both (--close counts as well)."),process.exit(Ne);let o=()=>{let d=Kt();if(!d)console.error(`Error: --as-bot needs a bot token, but no xoxb- token was found.
204
- Set SLACK_BOT_TOKEN=xoxb-... in ~/.config/slack-cli/.env (or your shell).`),process.exit(Ne);return d};if(r){if(s.target||s.question||s.choices?.length)console.error("Error: --results/--close reads an existing poll \u2014 do not also pass a target/question/choices."),process.exit(Ne);let d=e(s),h=t(s);try{let m={link:r};if(s.close)m.close=!0;if(s.names)m.names=!0;if(s["no-notify"])m.noNotify=!0;if(h)m.cookie=h;if(s["as-bot"])m.writeToken=o();await sd(d,m)}catch(m){console.error(tt(m)),process.exit(Ne)}return}if(!s.target)console.error("Error: target is required (or use --results <permalink> to count a poll)"),process.exit(Ne);let a=String(s.question??"").trim();if(!a)console.error("Error: question is empty"),process.exit(Ne);let c=(s.choices??[]).map((d)=>String(d).trim()).filter(Boolean);if(c.length<2||c.length>Ht)console.error(`Error: poll needs 2..${Ht} choices (got ${c.length}). For a free-text question use \`slack ask\`.`),process.exit(Ne);let u={target:s.target,question:a,choices:c};if(s.multi)u.multi=!0;if(s.until)u.until=String(s.until);if(s.code)u.code=s.code;if(s.body)u.body=s.body;if(s["channel-id"])u.channelId=s["channel-id"];if(s["user-id"])u.userId=s["user-id"];u.mentionToken=e(s);let f=t(s);if(f)u.mentionCookie=f;let l;if(s["as-bot"]){let d=o();if(!u.channelId&&!u.userId&&u.target.startsWith("@"))try{u.userId=await pn(e(s),u.target,t(s))}catch(h){console.error(`Error: could not resolve ${u.target} to a user for the bot DM.
203
+ Tip: pass --user-id <Uxxxx> to skip the lookup.`),process.exit(Ee)}f=l,c.asBot=!0}else{f=e(s);let l=t(s);if(l)c.cookie=l}try{await nd(f,c)}catch(l){console.error(nt(l)),process.exit(Ee)}}).command(["poll [target] [question] [choices..]","vote [target] [question] [choices..]"],"Post a poll with its choices pre-seeded as 1\uFE0F\u20E3..\uD83D\uDD1F reactions, then count them (confirm-hash safety gate)",(s)=>s.positional("target",{type:"string",describe:"#chan, @user, #chan:thread_ts, or permalink (omit with --results/--close)"}).positional("question",{type:"string",describe:"The question. @tags are optional here \u2014 unlike `ask`, a poll needs no addressee: anyone who can see it may vote."}).positional("choices",{type:"string",array:!0,describe:"2..10 choices, seeded as 1\uFE0F\u20E3..\uD83D\uDD1F reactions for voters to click"}).option("multi",{type:"boolean",default:!1,describe:"Let one person pick several choices (default: 1 \u4EBA 1 \u7968)"}).option("until",{type:"string",describe:"Deadline shown in the message (display only \u2014 closing is still `--close`)"}).option("results",{type:"string",describe:"Count an existing poll: pass its permalink. Posts nothing; only edit is the invalid-ballot notice in the poll itself (--no-notify to suppress)."}).option("close",{type:"string",describe:"Count an existing poll AND freeze the tally into the message. Only the poster can do this."}).option("names",{type:"boolean",default:!1,describe:"Also list who voted for what (stderr)"}).option("no-notify",{type:"boolean",default:!1,describe:"With --results: do not write the invalid-ballot notice back into the message (keeps it strictly read-only)"}).option("code",{type:"string",describe:"Safety hash to confirm the post"}).option("body",{type:"string",describe:"Extra context shown under the question"}).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:"Post via the bot token (xoxb / SLACK_BOT_TOKEN) so a DM notifies the recipient \u2014 and so YOUR OWN vote counts, since the seeds are then the bot's"}),async(s)=>{let r=s.close?String(s.close):s.results?String(s.results):"";if(s.results&&s.close)console.error("Error: pass --results or --close, not both (--close counts as well)."),process.exit(Be);let o=()=>{let d=Kt();if(!d)console.error(`Error: --as-bot needs a bot token, but no xoxb- token was found.
204
+ Set SLACK_BOT_TOKEN=xoxb-... in ~/.config/slack-cli/.env (or your shell).`),process.exit(Be);return d};if(r){if(s.target||s.question||s.choices?.length)console.error("Error: --results/--close reads an existing poll \u2014 do not also pass a target/question/choices."),process.exit(Be);let d=e(s),h=t(s);try{let m={link:r};if(s.close)m.close=!0;if(s.names)m.names=!0;if(s["no-notify"])m.noNotify=!0;if(h)m.cookie=h;if(s["as-bot"])m.writeToken=o();await ad(d,m)}catch(m){console.error(nt(m)),process.exit(Be)}return}if(!s.target)console.error("Error: target is required (or use --results <permalink> to count a poll)"),process.exit(Be);let a=String(s.question??"").trim();if(!a)console.error("Error: question is empty"),process.exit(Be);let c=(s.choices??[]).map((d)=>String(d).trim()).filter(Boolean);if(c.length<2||c.length>Ht)console.error(`Error: poll needs 2..${Ht} choices (got ${c.length}). For a free-text question use \`slack ask\`.`),process.exit(Be);let u={target:s.target,question:a,choices:c};if(s.multi)u.multi=!0;if(s.until)u.until=String(s.until);if(s.code)u.code=s.code;if(s.body)u.body=s.body;if(s["channel-id"])u.channelId=s["channel-id"];if(s["user-id"])u.userId=s["user-id"];u.mentionToken=e(s);let f=t(s);if(f)u.mentionCookie=f;let l;if(s["as-bot"]){let d=o();if(!u.channelId&&!u.userId&&u.target.startsWith("@"))try{u.userId=await pn(e(s),u.target,t(s))}catch(h){console.error(`Error: could not resolve ${u.target} to a user for the bot DM.
205
205
  ${h instanceof Error?h.message:String(h)}
206
- Tip: pass --user-id <Uxxxx> to skip the lookup.`),process.exit(Ne)}l=d,u.asBot=!0}else{l=e(s);let d=t(s);if(d)u.cookie=d}try{await td(l,u)}catch(d){console.error(tt(d)),process.exit(Ne)}}).command("doctor","Check the bot token (xoxb) can carry a two-way DM (scopes + Messages Tab)",(s)=>s,async()=>{let s=Kt();if(!s)console.error(`Error: slack doctor checks the bot token, but no xoxb- token was found.
207
- Set SLACK_BOT_TOKEN=xoxb-... in ~/.config/slack-cli/.env (or your shell).`),process.exit(1);await id(s)}).command("schedule","Manage scheduled messages",(s)=>s.command("send <target> <message>","Schedule a message for later delivery",(r)=>r.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(r)=>{let o={target:r.target,message:r.message,at:r.at};if(r.code)o.code=r.code;if(r["channel-id"])o.channelId=r["channel-id"];if(r["user-id"])o.userId=r["user-id"];let a=t(r);if(a)o.cookie=a;await ad(e(r),o)}).command(["ls","list"],"List pending scheduled messages",(r)=>r.positional("target",{type:"string",describe:"#channel to filter by"}).option("channel-id",{type:"string",describe:"Raw channel ID"}),async(r)=>{await cd(e(r),r.target,r["channel-id"],t(r))}).command("rm <target> <id>","Delete a scheduled message",(r)=>r.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(r)=>{let o={target:r.target,id:r.id};if(r.code)o.code=r.code;let a=t(r);if(a)o.cookie=a;if(r["channel-id"])o.channelId=r["channel-id"];await ud(e(r),o)}).demandCommand(1,"").showHelpOnFail(!0),()=>{}).command("edit <target> <newText>","Edit a sent message",(s)=>s.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(s)=>{let r={target:s.target,newText:s.newText};if(s.code)r.code=s.code;if(s["channel-id"])r.channelId=s["channel-id"];if(s.mentions!==!1)r.mentions=!0;let o=t(s);if(o)r.cookie=o;await Wf(e(s),r)}).command("delete <target>","Delete a sent message (confirm-hash safety gate)",(s)=>s.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(s)=>{let r={target:s.target};if(s.code)r.code=s.code;if(s["channel-id"])r.channelId=s["channel-id"];let o=t(s);if(o)r.cookie=o;await Uf(e(s),r)}).command("react <target> <emoji>","Add (or --remove) an emoji reaction \u2014 a lightweight ack that doesn't grow the thread",(s)=>s.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(s)=>{let r={target:s.target,emoji:s.emoji};if(s.remove)r.remove=!0;if(s["channel-id"])r.channelId=s["channel-id"];let o=t(s);if(o)r.cookie=o;try{await Jf(e(s),r)}catch(a){console.error(tt(a)),process.exit(1)}}).command("todo","Reaction-backed task tracking (:pushpin: marks a task, progress lives in a second reaction)",(s)=>s.option("cache",{type:"boolean",default:!0,describe:"Use ~/.config/slack-cli/cache.json for channel/user lookups (--no-cache to bypass)"}).middleware((r)=>{if(r.cache===!1)Ni(!1)}).command(["ls","list"],"List everyone's tasks (has: \u2014 read-only, one search per run)",(r)=>r.options(n).option("mine",{type:"boolean",default:!1,describe:"Only your own reactions (hasmy:) \u2014 same as `slack mytodo ls`"}).option("shared",{type:"boolean",default:!1,hidden:!0,describe:"Deprecated \u2014 anyone's reactions is the default for `todo ls`"}),async(r)=>{await i(r,!1)}).command("set <target> <state>","Move a task to a progress state (adds the new reaction before removing the old one)",(r)=>r.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(r)=>{let o={target:r.target,state:r.state};if(r["channel-id"])o.channelId=r["channel-id"];let a=t(r);if(a)o.cookie=a;try{await If(e(r),o)}catch(c){console.error(tt(c)),process.exit(1)}}).command("flag <target> <flag>","Add (or --remove) a reason flag (alert | needs-discussion | waiting | blocked) \u2014 flags stack, independent of progress",(r)=>r.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(r)=>{let o={target:r.target,flag:r.flag};if(r.remove)o.remove=!0;if(r["channel-id"])o.channelId=r["channel-id"];let a=t(r);if(a)o.cookie=a;try{await Tf(e(r),o)}catch(c){console.error(tt(c)),process.exit(1)}}).command("doctor","Find messages carrying two or more progress reactions (--fix repairs them)",(r)=>r.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:Bi,describe:"Max messages to scan"}).option("channel-id",{type:"string",describe:"Raw channel ID"}),async(r)=>{let o={channel:r.in,limit:r.limit};if(r.fix)o.fix=!0;if(r["channel-id"])o.channelId=r["channel-id"];let a=t(r);if(a)o.cookie=a;await Pf(e(r),o)}).demandCommand(1,"Specify a todo subcommand (ls, set, flag, doctor)"),()=>{}).command("mytodo","Tasks carrying YOUR reactions (hasmy:) \u2014 the my-only half of `todo`",(s)=>s.option("cache",{type:"boolean",default:!0,describe:"Use ~/.config/slack-cli/cache.json for channel/user lookups (--no-cache to bypass)"}).middleware((r)=>{if(r.cache===!1)Ni(!1)}).command(["ls","list"],"List tasks you have reacted to (hasmy: \u2014 read-only, one search per run)",(r)=>r.options(n),async(r)=>{await i(r,!0)}).demandCommand(1,"Specify a mytodo subcommand (ls)"),()=>{}).command("upload <target> <file..>","Upload one or more files to a channel or DM",(s)=>s.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(s)=>{let r={target:s.target,filePaths:s.file};if(s.title)r.title=s.title;if(s.comment)r.comment=s.comment;if(s.code)r.code=s.code;if(s["channel-id"])r.channelId=s["channel-id"];if(s["user-id"])r.userId=s["user-id"];let o=t(s);if(o)r.cookie=o;await ld(e(s),r)}).command("files","File commands",(s)=>s.command(["ls","list"],"List files visible to you (files.list)",(r)=>r.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(r)=>{let o={limit:r.limit,format:r.json?"jsonl":r.format};if(r.type)o.types=r.type;if(r.channel)o.channel=r.channel;if(r.user)o.user=r.user;await fd(e(r),t(r),o)}).demandCommand(1,"").showHelpOnFail(!0),()=>{}).command("lists <ref>","Read a Slack List's rows (by list URL or F-id) \u2014 read-only",(s)=>s.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(s)=>{let r=s.json?"jsonl":s.format;try{await hd(e(s),t(s),s.ref,{limit:s.limit,format:r})}catch(o){console.error(tt(o)),process.exit(1)}}).command("download <ref> [dest]","Download a file attachment (by file ID or file permalink) to disk",(s)=>s.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(s)=>{await md(e(s),t(s),s.ref,s.dest)}).command("dump","Bulk export channel history as markdown",(s)=>s.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(s)=>{await Rf(e(s),s.days,s.limit,s.filter)}).command("drafts","Manage message drafts (requires xoxc desktop token)",(s)=>s.command(["$0","ls","list"],"List pending drafts",(r)=>r.option("all",{alias:"a",type:"boolean",default:!1,describe:"Include sent drafts"}),async(r)=>{await Bf(e(r),t(r),r.all)}).command(["new <channel> [text..]","save <channel> [text..]"],"Create a draft",(r)=>r.positional("channel",{type:"string",demandOption:!0}).positional("text",{type:"string",array:!0,default:[]}),async(r)=>{let o=e(r),a=t(r),c=r.text.join(" ");if(!c)console.error("Usage: slack drafts new <#channel|@user> <text>"),process.exit(2);let u=await De(o,r.channel,a),f=await Qa(o,u,c,a);console.log(`\u2713 Draft created (id: ${T(f.draft).id??"?"})`)}).command("get <id>","Show a draft",(r)=>r.positional("id",{type:"string",demandOption:!0}),async(r)=>{await Nf(e(r),t(r),r.id)}).command(["edit <id> [text..]","update <id> [text..]"],"Edit a draft",(r)=>r.positional("id",{type:"string",demandOption:!0}).positional("text",{type:"string",array:!0,default:[]}).option("code",{type:"string"}),async(r)=>{let o=e(r),a=t(r),c=r.text.join(" ");if(!c)console.error("Usage: slack drafts edit <id> <new-text>"),process.exit(2);let u=await gn(o,a),f=X(u.drafts).map(T).find((p)=>String(p.id)===r.id);if(!f)console.error(`Draft not found: ${r.id}`),process.exit(1);let l=fs(f),d=await Vt(o,a),h=He(l,c,d?.userId??"");if(r.code!==h)ve(r.code,h,["--- Editing draft as -------------------------",je(d),"--- Current draft ----------------------------",...l.split(`
206
+ Tip: pass --user-id <Uxxxx> to skip the lookup.`),process.exit(Be)}l=d,u.asBot=!0}else{l=e(s);let d=t(s);if(d)u.cookie=d}try{await rd(l,u)}catch(d){console.error(nt(d)),process.exit(Be)}}).command("doctor","Check the bot token (xoxb) can carry a two-way DM (scopes + Messages Tab)",(s)=>s,async()=>{let s=Kt();if(!s)console.error(`Error: slack doctor checks the bot token, but no xoxb- token was found.
207
+ Set SLACK_BOT_TOKEN=xoxb-... in ~/.config/slack-cli/.env (or your shell).`),process.exit(1);await cd(s)}).command("schedule","Manage scheduled messages",(s)=>s.command("send <target> <message>","Schedule a message for later delivery",(r)=>r.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(r)=>{let o={target:r.target,message:r.message,at:r.at};if(r.code)o.code=r.code;if(r["channel-id"])o.channelId=r["channel-id"];if(r["user-id"])o.userId=r["user-id"];let a=t(r);if(a)o.cookie=a;await fd(e(r),o)}).command(["ls","list"],"List pending scheduled messages",(r)=>r.positional("target",{type:"string",describe:"#channel to filter by"}).option("channel-id",{type:"string",describe:"Raw channel ID"}),async(r)=>{await dd(e(r),r.target,r["channel-id"],t(r))}).command("rm <target> <id>","Delete a scheduled message",(r)=>r.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(r)=>{let o={target:r.target,id:r.id};if(r.code)o.code=r.code;let a=t(r);if(a)o.cookie=a;if(r["channel-id"])o.channelId=r["channel-id"];await pd(e(r),o)}).demandCommand(1,"").showHelpOnFail(!0),()=>{}).command("edit <target> <newText>","Edit a sent message",(s)=>s.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(s)=>{let r={target:s.target,newText:s.newText};if(s.code)r.code=s.code;if(s["channel-id"])r.channelId=s["channel-id"];if(s.mentions!==!1)r.mentions=!0;let o=t(s);if(o)r.cookie=o;await zf(e(s),r)}).command("delete <target>","Delete a sent message (confirm-hash safety gate)",(s)=>s.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(s)=>{let r={target:s.target};if(s.code)r.code=s.code;if(s["channel-id"])r.channelId=s["channel-id"];let o=t(s);if(o)r.cookie=o;await Hf(e(s),r)}).command("react <target> <emoji>","Add (or --remove) an emoji reaction \u2014 a lightweight ack that doesn't grow the thread",(s)=>s.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(s)=>{let r={target:s.target,emoji:s.emoji};if(s.remove)r.remove=!0;if(s["channel-id"])r.channelId=s["channel-id"];let o=t(s);if(o)r.cookie=o;try{await qf(e(s),r)}catch(a){console.error(nt(a)),process.exit(1)}}).command("todo","Reaction-backed task tracking (:pushpin: marks a task, progress lives in a second reaction)",(s)=>s.option("cache",{type:"boolean",default:!0,describe:"Use ~/.config/slack-cli/cache.json for channel/user lookups (--no-cache to bypass)"}).middleware((r)=>{if(r.cache===!1)ji(!1)}).command(["ls","list"],"List everyone's tasks (has: \u2014 read-only, one search per run)",(r)=>r.options(n).option("mine",{type:"boolean",default:!1,describe:"Only your own reactions (hasmy:) \u2014 same as `slack mytodo ls`"}).option("shared",{type:"boolean",default:!1,hidden:!0,describe:"Deprecated \u2014 anyone's reactions is the default for `todo ls`"}),async(r)=>{await i(r,!1)}).command("set <target> <state>","Move a task to a progress state (adds the new reaction before removing the old one)",(r)=>r.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(r)=>{let o={target:r.target,state:r.state};if(r["channel-id"])o.channelId=r["channel-id"];let a=t(r);if(a)o.cookie=a;try{await Mf(e(r),o)}catch(c){console.error(nt(c)),process.exit(1)}}).command("flag <target> <flag>","Add (or --remove) a reason flag (alert | needs-discussion | waiting | blocked) \u2014 flags stack, independent of progress",(r)=>r.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(r)=>{let o={target:r.target,flag:r.flag};if(r.remove)o.remove=!0;if(r["channel-id"])o.channelId=r["channel-id"];let a=t(r);if(a)o.cookie=a;try{await Bf(e(r),o)}catch(c){console.error(nt(c)),process.exit(1)}}).command("doctor","Find messages carrying two or more progress reactions (--fix repairs them)",(r)=>r.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:vi,describe:"Max messages to scan"}).option("channel-id",{type:"string",describe:"Raw channel ID"}),async(r)=>{let o={channel:r.in,limit:r.limit};if(r.fix)o.fix=!0;if(r["channel-id"])o.channelId=r["channel-id"];let a=t(r);if(a)o.cookie=a;await Nf(e(r),o)}).demandCommand(1,"Specify a todo subcommand (ls, set, flag, doctor)"),()=>{}).command("mytodo","Tasks carrying YOUR reactions (hasmy:) \u2014 the my-only half of `todo`",(s)=>s.option("cache",{type:"boolean",default:!0,describe:"Use ~/.config/slack-cli/cache.json for channel/user lookups (--no-cache to bypass)"}).middleware((r)=>{if(r.cache===!1)ji(!1)}).command(["ls","list"],"List tasks you have reacted to (hasmy: \u2014 read-only, one search per run)",(r)=>r.options(n),async(r)=>{await i(r,!0)}).demandCommand(1,"Specify a mytodo subcommand (ls)"),()=>{}).command("upload <target> <file..>","Upload one or more files to a channel or DM",(s)=>s.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(s)=>{let r={target:s.target,filePaths:s.file};if(s.title)r.title=s.title;if(s.comment)r.comment=s.comment;if(s.code)r.code=s.code;if(s["channel-id"])r.channelId=s["channel-id"];if(s["user-id"])r.userId=s["user-id"];let o=t(s);if(o)r.cookie=o;await hd(e(s),r)}).command("files","File commands",(s)=>s.command(["ls","list"],"List files visible to you (files.list)",(r)=>r.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(r)=>{let o={limit:r.limit,format:r.json?"jsonl":r.format};if(r.type)o.types=r.type;if(r.channel)o.channel=r.channel;if(r.user)o.user=r.user;await gd(e(r),t(r),o)}).demandCommand(1,"").showHelpOnFail(!0),()=>{}).command("lists <ref>","Read a Slack List's rows (by list URL or F-id) \u2014 read-only",(s)=>s.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(s)=>{let r=s.json?"jsonl":s.format;try{await yd(e(s),t(s),s.ref,{limit:s.limit,format:r})}catch(o){console.error(nt(o)),process.exit(1)}}).command("download <ref> [dest]","Download a file attachment (by file ID or file permalink) to disk",(s)=>s.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(s)=>{await bd(e(s),t(s),s.ref,s.dest)}).command("dump","Bulk export channel history as markdown",(s)=>s.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(s)=>{await vf(e(s),s.days,s.limit,s.filter)}).command("drafts","Manage message drafts (requires xoxc desktop token)",(s)=>s.command(["$0","ls","list"],"List pending drafts",(r)=>r.option("all",{alias:"a",type:"boolean",default:!1,describe:"Include sent drafts"}),async(r)=>{await Lf(e(r),t(r),r.all)}).command(["new <channel> [text..]","save <channel> [text..]"],"Create a draft",(r)=>r.positional("channel",{type:"string",demandOption:!0}).positional("text",{type:"string",array:!0,default:[]}),async(r)=>{let o=e(r),a=t(r),c=r.text.join(" ");if(!c)console.error("Usage: slack drafts new <#channel|@user> <text>"),process.exit(2);let u=await ye(o,r.channel,a),f=await tc(o,u,c,a);console.log(`\u2713 Draft created (id: ${P(f.draft).id??"?"})`)}).command("get <id>","Show a draft",(r)=>r.positional("id",{type:"string",demandOption:!0}),async(r)=>{await Wf(e(r),t(r),r.id)}).command(["edit <id> [text..]","update <id> [text..]"],"Edit a draft",(r)=>r.positional("id",{type:"string",demandOption:!0}).positional("text",{type:"string",array:!0,default:[]}).option("code",{type:"string"}),async(r)=>{let o=e(r),a=t(r),c=r.text.join(" ");if(!c)console.error("Usage: slack drafts edit <id> <new-text>"),process.exit(2);let u=await gn(o,a),f=X(u.drafts).map(P).find((p)=>String(p.id)===r.id);if(!f)console.error(`Draft not found: ${r.id}`),process.exit(1);let l=ps(f),d=await Vt(o,a),h=He(l,c,d?.userId??"");if(r.code!==h)Ne(r.code,h,["--- Editing draft as -------------------------",ve(d),"--- Current draft ----------------------------",...l.split(`
208
208
  `).map((p)=>` ${p}`),"--- Replacing with ---------------------------",...c.split(`
209
- `).map((p)=>` ${p}`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);let m=await ec(o,r.id,zi(f),c,a);console.log(`\u2713 Draft updated (id: ${T(m.draft).id??"?"})`)}).command(["delete <id>","rm <id>"],"Delete a draft",(r)=>r.positional("id",{type:"string",demandOption:!0}).option("code",{type:"string"}),async(r)=>{let o=e(r),a=t(r),c=await gn(o,a),u=X(c.drafts).map(T).find((h)=>String(h.id)===r.id);if(!u)console.error(`Draft not found: ${r.id}`),process.exit(1);let f=fs(u),l=await Vt(o,a),d=He(r.id,f,l?.userId??"");if(r.code!==d)ve(r.code,d,["\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",je(l),` id: ${r.id}`,...f.split(`
210
- `).map((h)=>` ${h}`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);await nc(o,r.id,a),console.log(`\u2713 Draft deleted (id: ${r.id})`)})).command("auth","Authentication and workspace management",(s)=>s.command("token","Add a workspace \u2014 paste an existing xoxp-/xoxb- token",(r)=>r.option("token",{type:"string",describe:"Token to save directly (non-interactive)"}).option("name",{type:"string",describe:"Workspace name (used with --token)"}),async(r)=>{await ha({...r.token!==void 0?{token:r.token}:{},...r.name!==void 0?{name:r.name}:{}})}).command("app","Create a new Slack app and obtain a token (guided wizard)",(r)=>r.option("bot",{type:"boolean",describe:"Create a bot token (xoxb-) instead of user (xoxp-)"}),async(r)=>{await ga({...r.bot!==void 0?{bot:r.bot}:{}})}).command("login","Interactive auth wizard (all auth methods: desktop app, token, new app)",(r)=>r.option("token",{type:"string",describe:"Token to save directly (non-interactive)"}).option("name",{type:"string",describe:"Workspace name (used with --token)"}),async(r)=>{await Vn({...r.token!==void 0?{token:r.token}:{},...r.name!==void 0?{name:r.name}:{}})}).command(["ls","status"],"Show auth status",()=>{},()=>{let r=Qs();if(r.length===0){console.log("No workspaces configured. Run: slack auth login");return}for(let{name:o,profile:a,current:c}of r)console.log(`${c?"* ":" "}${o} ${a.team} (${a.user}) ${a.url??""}`)}).command("use <name>","Switch active workspace",(r)=>r.positional("name",{type:"string",demandOption:!0}).option("g",{type:"boolean",default:!1,describe:"Write global lockfile (~/.slack-cli/workspace)"}),(r)=>{if(!r.g)yf(ft(process.cwd(),".slack-cli"));Bo(r.name,r.g),console.log(`Switched to workspace "${r.name}" ${r.g?"globally":"locally"}`)}).command(["logout <name>","rm <name>","remove <name>"],"Remove a workspace",(r)=>r.positional("name",{type:"string",demandOption:!0}),(r)=>{Mo(r.name),console.log(`Removed workspace "${r.name}"`)}).command(["chrome","cookie"],"Attach Chrome browser xoxd cookie to a workspace (macOS, interactive)",(r)=>r.option("workspace",{type:"string",alias:"w",describe:"Workspace name to update (default: active)"}),async(r)=>{await da({...r.workspace!==void 0?{workspace:r.workspace}:{}})}).command("firefox","Attach Firefox browser xoxd cookie to a workspace (all platforms)",(r)=>r.option("workspace",{type:"string",alias:"w",describe:"Workspace name to update (default: active)"}),async(r)=>{await pa({...r.workspace!==void 0?{workspace:r.workspace}:{}})}).command("$0",!1,()=>{},()=>{s.showHelp(),process.exit(0)})).command("tail [target]","Stream new messages in real time (like tail -f)",(s)=>s.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(s)=>{let r=e(s),o=t(s),a=new AbortController;process.on("SIGINT",()=>{a.abort(),process.exit(0)}),await Ca(r,s.target,{...s.since!==void 0?{since:s.since}:{},...s.thread!==void 0?{thread:s.thread}:{},...s["watch-thread"]!==void 0?{watchThread:s["watch-thread"]}:{},me:s.me,interval:s.interval,...s.timeout!==void 0?{timeout:s.timeout}:{},...s["exit-on-message"]===!0?{exitOnMessage:!0}:{},...o!==void 0?{cookie:o}:{},...s.rtm===!1?{noRtm:!0}:{}},a.signal)}).command("login",!1,(s)=>s.option("token",{type:"string"}).option("name",{type:"string"}),async(s)=>{await Vn({...s.token!==void 0?{token:s.token}:{},...s.name!==void 0?{name:s.name}:{}})}).demandCommand(1,"Specify a command. Run with --help for usage.").strict().help().alias("help","h").parseAsync()}Dd().catch((e)=>{console.error(e instanceof Error?e.message:String(e)),process.exit(1)});
209
+ `).map((p)=>` ${p}`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);let m=await nc(o,r.id,qi(f),c,a);console.log(`\u2713 Draft updated (id: ${P(m.draft).id??"?"})`)}).command(["delete <id>","rm <id>"],"Delete a draft",(r)=>r.positional("id",{type:"string",demandOption:!0}).option("code",{type:"string"}),async(r)=>{let o=e(r),a=t(r),c=await gn(o,a),u=X(c.drafts).map(P).find((h)=>String(h.id)===r.id);if(!u)console.error(`Draft not found: ${r.id}`),process.exit(1);let f=ps(u),l=await Vt(o,a),d=He(r.id,f,l?.userId??"");if(r.code!==d)Ne(r.code,d,["\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",ve(l),` id: ${r.id}`,...f.split(`
210
+ `).map((h)=>` ${h}`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);await ic(o,r.id,a),console.log(`\u2713 Draft deleted (id: ${r.id})`)})).command("auth","Authentication and workspace management",(s)=>s.command("token","Add a workspace \u2014 paste an existing xoxp-/xoxb- token",(r)=>r.option("token",{type:"string",describe:"Token to save directly (non-interactive)"}).option("name",{type:"string",describe:"Workspace name (used with --token)"}),async(r)=>{await ma({...r.token!==void 0?{token:r.token}:{},...r.name!==void 0?{name:r.name}:{}})}).command("app","Create a new Slack app and obtain a token (guided wizard)",(r)=>r.option("bot",{type:"boolean",describe:"Create a bot token (xoxb-) instead of user (xoxp-)"}),async(r)=>{await Da({...r.bot!==void 0?{bot:r.bot}:{}})}).command("login","Interactive auth wizard (all auth methods: desktop app, token, new app)",(r)=>r.option("token",{type:"string",describe:"Token to save directly (non-interactive)"}).option("name",{type:"string",describe:"Workspace name (used with --token)"}),async(r)=>{await Zn({...r.token!==void 0?{token:r.token}:{},...r.name!==void 0?{name:r.name}:{}})}).command(["ls","status"],"Show auth status",()=>{},()=>{let r=ni();if(r.length===0){console.log("No workspaces configured. Run: slack auth login");return}for(let{name:o,profile:a,current:c}of r)console.log(`${c?"* ":" "}${o} ${a.team} (${a.user}) ${a.url??""}`)}).command("use <name>","Switch active workspace",(r)=>r.positional("name",{type:"string",demandOption:!0}).option("g",{type:"boolean",default:!1,describe:"Write global lockfile (~/.slack-cli/workspace)"}),(r)=>{if(!r.g)Cf(dt(process.cwd(),".slack-cli"));vo(r.name,r.g),console.log(`Switched to workspace "${r.name}" ${r.g?"globally":"locally"}`)}).command(["logout <name>","rm <name>","remove <name>"],"Remove a workspace",(r)=>r.positional("name",{type:"string",demandOption:!0}),(r)=>{No(r.name),console.log(`Removed workspace "${r.name}"`)}).command(["chrome","cookie"],"Attach Chrome browser xoxd cookie to a workspace (macOS, interactive)",(r)=>r.option("workspace",{type:"string",alias:"w",describe:"Workspace name to update (default: active)"}),async(r)=>{await ha({...r.workspace!==void 0?{workspace:r.workspace}:{}})}).command("firefox","Attach Firefox browser xoxd cookie to a workspace (all platforms)",(r)=>r.option("workspace",{type:"string",alias:"w",describe:"Workspace name to update (default: active)"}),async(r)=>{await ga({...r.workspace!==void 0?{workspace:r.workspace}:{}})}).command("$0",!1,()=>{},()=>{s.showHelp(),process.exit(0)})).command("tail [target]","Stream new messages in real time (like tail -f)",(s)=>s.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(s)=>{let r=e(s),o=t(s),a=new AbortController;process.on("SIGINT",()=>{a.abort(),process.exit(0)}),await xa(r,s.target,{...s.since!==void 0?{since:s.since}:{},...s.thread!==void 0?{thread:s.thread}:{},...s["watch-thread"]!==void 0?{watchThread:s["watch-thread"]}:{},me:s.me,interval:s.interval,...s.timeout!==void 0?{timeout:s.timeout}:{},...s["exit-on-message"]===!0?{exitOnMessage:!0}:{},...o!==void 0?{cookie:o}:{},...s.rtm===!1?{noRtm:!0}:{}},a.signal)}).command("login",!1,(s)=>s.option("token",{type:"string"}).option("name",{type:"string"}),async(s)=>{await Zn({...s.token!==void 0?{token:s.token}:{},...s.name!==void 0?{name:s.name}:{}})}).demandCommand(1,"Specify a command. Run with --help for usage.").strict().help().alias("help","h").parseAsync()}Fd().catch((e)=>{console.error(e instanceof Error?e.message:String(e)),process.exit(1)});