slack-term 1.32.2 → 1.32.4

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 wu}from"node:module";var pu=Object.create;var{getPrototypeOf:hu,defineProperty:ii,getOwnPropertyNames:gu}=Object;var oi=Object.prototype.hasOwnProperty;function mu(e){return this[e]}var Du,yu,ai=(e,t,n)=>{var r=e!=null&&typeof e==="object";if(r){var s=t?Du??=new WeakMap:yu??=new WeakMap,i=s.get(e);if(i)return i}n=e!=null?pu(hu(e)):{};let o=t||!e||!e.__esModule||!oi.call(e,"default")?ii(n,"default",{value:e,enumerable:!0}):n;if(e&&typeof e==="object"||typeof e==="function"){for(let a of gu(e))if(!oi.call(o,a))ii(o,a,{get:mu.bind(e,a),enumerable:!0})}if(r)s.set(e,o);return o};var ci=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var As=wu(import.meta.url);var ki=ci(function(Dp,_i){_i.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 Zi=ci(function(ih,Vi){Vi.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,i){return i};var r=Error().stack;if(Error.prepareStackTrace=n,r!==null&&typeof r==="object")return r[t]?r[t].getFileName():void 0}});import{createHash as Xf}from"crypto";import{existsSync as ru,readFileSync as Gf,mkdirSync as Vf,writeFileSync as iu}from"fs";import{homedir as Gc}from"os";import{join as dt}from"path";import{notStrictEqual as rl,strictEqual as il}from"assert";var bu={right:Eu,center:xu};class li{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((r)=>r.split("\t")),n=0;return t.forEach((r)=>{if(r.length>1&&Se.stringWidth(r[0])>n)n=Math.min(Math.floor(this.width*0.5),Se.stringWidth(r[0]))}),t.forEach((r)=>{this.div(...r.map((s,i)=>({text:s.trim(),padding:this.measurePadding(s),width:i===0&&r.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,r)=>{let s="";n.forEach((i,o)=>{let{width:a}=e[o],c=this.negatePadding(e[o]),u=i;if(c>Se.stringWidth(i))u+=" ".repeat(c-Se.stringWidth(i));if(e[o].align&&e[o].align!=="left"&&this.wrap){let l=bu[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+=ui(e[o],u,"| "),s+=u,s+=ui(e[o],u," |"),f[1])s+=" ".repeat(f[1]);if(r===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(/^ */),r=n?n[0].length:0,s=t.text,i=Se.stringWidth(s.trimRight());if(!t.span)return e;if(!this.wrap)return t.hidden=!0,s+e;if(r<i)return e;return t.hidden=!0,s.trimRight()+" ".repeat(r-i)+e.trimLeft()}rasterize(e){let t=[],n=this.columnWidths(e),r;return e.forEach((s,i)=>{if(s.width=n[i],this.wrap)r=Se.wrap(s.text,this.negatePadding(s),{hard:!0}).split(`
3
+ import{createRequire as Fu}from"node:module";var gu=Object.create;var{getPrototypeOf:mu,defineProperty:io,getOwnPropertyNames:Du}=Object;var ao=Object.prototype.hasOwnProperty;function yu(e){return this[e]}var bu,wu,co=(e,t,n)=>{var r=e!=null&&typeof e==="object";if(r){var s=t?bu??=new WeakMap:wu??=new WeakMap,o=s.get(e);if(o)return o}n=e!=null?gu(mu(e)):{};let i=t||!e||!e.__esModule||!ao.call(e,"default")?io(n,"default",{value:e,enumerable:!0}):n;if(e&&typeof e==="object"||typeof e==="function"){for(let a of Du(e))if(!ao.call(i,a))io(i,a,{get:yu.bind(e,a),enumerable:!0})}if(r)s.set(e,i);return i};var uo=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var $s=Fu(import.meta.url);var Ao=uo(function(wh,So){So.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 ei=uo(function(cp,Qo){Qo.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,o){return o};var r=Error().stack;if(Error.prepareStackTrace=n,r!==null&&typeof r==="object")return r[t]?r[t].getFileName():void 0}});import{createHash as Zf}from"crypto";import{existsSync as iu,readFileSync as Qf,mkdirSync as ed,writeFileSync as au}from"fs";import{homedir as Vc}from"os";import{join as ht}from"path";import{notStrictEqual as il,strictEqual as al}from"assert";var Cu={right:_u,center:ku};class fo{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((r)=>r.split("\t")),n=0;return t.forEach((r)=>{if(r.length>1&&Se.stringWidth(r[0])>n)n=Math.min(Math.floor(this.width*0.5),Se.stringWidth(r[0]))}),t.forEach((r)=>{this.div(...r.map((s,o)=>({text:s.trim(),padding:this.measurePadding(s),width:o===0&&r.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,r)=>{let s="";n.forEach((o,i)=>{let{width:a}=e[i],c=this.negatePadding(e[i]),u=o;if(c>Se.stringWidth(o))u+=" ".repeat(c-Se.stringWidth(o));if(e[i].align&&e[i].align!=="left"&&this.wrap){let l=Cu[e[i].align];if(u=l(u,c),Se.stringWidth(u)<c)u+=" ".repeat((a||0)-Se.stringWidth(u)-1)}let f=e[i].padding||[0,0,0,0];if(f[3])s+=" ".repeat(f[3]);if(s+=lo(e[i],u,"| "),s+=u,s+=lo(e[i],u," |"),f[1])s+=" ".repeat(f[1]);if(r===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(/^ */),r=n?n[0].length:0,s=t.text,o=Se.stringWidth(s.trimRight());if(!t.span)return e;if(!this.wrap)return t.hidden=!0,s+e;if(r<o)return e;return t.hidden=!0,s.trimRight()+" ".repeat(r-o)+e.trimLeft()}rasterize(e){let t=[],n=this.columnWidths(e),r;return e.forEach((s,o)=>{if(s.width=n[o],this.wrap)r=Se.wrap(s.text,this.negatePadding(s),{hard:!0}).split(`
6
6
  `);else r=s.text.split(`
7
- `);if(s.border)r.unshift("."+"-".repeat(this.negatePadding(s)+2)+"."),r.push("'"+"-".repeat(this.negatePadding(s)+2)+"'");if(s.padding)r.unshift(...Array(s.padding[0]||0).fill("")),r.push(...Array(s.padding[2]||0).fill(""));r.forEach((o,a)=>{if(!t[a])t.push([]);let c=t[a];for(let u=0;u<i;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((i)=>i.width||Se.stringWidth(i.text));let t=e.length,n=this.width,r=e.map((i)=>{if(i.width)return t--,n-=i.width,i.width;return}),s=t?Math.floor(n/t):0;return r.map((i,o)=>{if(i===void 0)return Math.max(s,Fu(e[o]));return i})}}function ui(e,t,n){if(e.border){if(/[.']-+[.']/.test(t))return"";if(t.trim().length!==0)return n;return" "}return""}function Fu(e){let t=e.padding||[],n=1+(t[3]||0)+(t[1]||0);if(e.border)return n+4;return n}function Cu(){if(typeof process==="object"&&process.stdout&&process.stdout.columns)return process.stdout.columns;return 80}function Eu(e,t){e=e.trim();let n=Se.stringWidth(e);if(n<t)return" ".repeat(t-n)+e;return e}function xu(e,t){e=e.trim();let n=Se.stringWidth(e);if(n>=t)return e;return" ".repeat(t-n>>1)+e}var Se;function fi(e,t){return Se=t,new li({width:(e===null||e===void 0?void 0:e.width)||Cu(),wrap:e===null||e===void 0?void 0:e.wrap})}function $s({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 _u=$s();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(_u,"")}var di=161,pi=1114109,hi=[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],gi=12288,mi=65510,Di=[12288,12288,65281,65376,65504,65510];var yi=4352,wi=262141,Os=[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 kn=(e,t)=>{let n=0,r=Math.floor(e.length/2)-1;while(n<=r){let s=Math.floor((n+r)/2),i=s*2;if(t<e[i])r=s-1;else if(t>e[i+1])n=s+1;else return!0}return!1};var bi=19968,[ku,Su]=Au(Os);function Au(e){let t=e[0],n=e[1];for(let r=0;r<e.length;r+=2){let s=e[r],i=e[r+1];if(bi>=s&&bi<=i)return[s,i];if(i-s>n-t)t=s,n=i}return[t,n]}var Fi=(e)=>{if(e<di||e>pi)return!1;return kn(hi,e)},Ci=(e)=>{if(e<gi||e>mi)return!1;return kn(Di,e)};var Ei=(e)=>{if(e>=ku&&e<=Su)return!0;if(e<yi||e>wi)return!1;return kn(Os,e)};function $u(e){if(!Number.isSafeInteger(e))throw TypeError(`Expected a code point, got \`${typeof e}\`.`)}function xi(e,{ambiguousAsWide:t=!1}={}){if($u(e),Ci(e)||Ei(e)||t&&Fi(e))return 2;return 1}var Si=ai(ki(),1),Ou=new Intl.Segmenter,Iu=/^\p{Default_Ignorable_Code_Point}$/u;function We(e,t={}){if(typeof e!=="string"||e.length===0)return 0;let{ambiguousIsNarrow:n=!0,countAnsiEscapeCodes:r=!1}=t;if(!r)e=pt(e);if(e.length===0)return 0;let s=0,i={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(Iu.test(o))continue;if(Si.default().test(o)){s+=2;continue}s+=xi(a,i)}return s}var Ai=(e=0)=>(t)=>`\x1B[${t+e}m`,$i=(e=0)=>(t)=>`\x1B[${38+e};5;${t}m`,Oi=(e=0)=>(t,n,r)=>`\x1B[${38+e};2;${t};${n};${r}m`,ie={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]}},Fp=Object.keys(ie.modifier),Tu=Object.keys(ie.color),Pu=Object.keys(ie.bgColor),Cp=[...Tu,...Pu];function Ru(){let e=new Map;for(let[t,n]of Object.entries(ie)){for(let[r,s]of Object.entries(n))ie[r]={open:`\x1B[${s[0]}m`,close:`\x1B[${s[1]}m`},n[r]=ie[r],e.set(s[0],s[1]);Object.defineProperty(ie,t,{value:n,enumerable:!1})}return Object.defineProperty(ie,"codes",{value:e,enumerable:!1}),ie.color.close="\x1B[39m",ie.bgColor.close="\x1B[49m",ie.color.ansi=Ai(),ie.color.ansi256=$i(),ie.color.ansi16m=Oi(),ie.bgColor.ansi=Ai(10),ie.bgColor.ansi256=$i(10),ie.bgColor.ansi16m=Oi(10),Object.defineProperties(ie,{rgbToAnsi256:{value(t,n,r){if(t===n&&n===r){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(r/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[r]=n;if(r.length===3)r=[...r].map((i)=>i+i).join("");let s=Number.parseInt(r,16);return[s>>16&255,s>>8&255,s&255]},enumerable:!1},hexToAnsi256:{value:(t)=>ie.rgbToAnsi256(...ie.hexToRgb(t)),enumerable:!1},ansi256ToAnsi:{value(t){if(t<8)return 30+t;if(t<16)return 90+(t-8);let n,r,s;if(t>=232)n=((t-232)*10+8)/255,r=n,s=n;else{t-=16;let a=t%36;n=Math.floor(t/36)/5,r=Math.floor(a/6)/5,s=a%6/5}let i=Math.max(n,r,s)*2;if(i===0)return 30;let o=30+(Math.round(s)<<2|Math.round(r)<<1|Math.round(n));if(i===2)o+=60;return o},enumerable:!1},rgbToAnsi:{value:(t,n,r)=>ie.ansi256ToAnsi(ie.rgbToAnsi256(t,n,r)),enumerable:!1},hexToAnsi:{value:(t)=>ie.ansi256ToAnsi(ie.hexToAnsi256(t)),enumerable:!1}}),ie}var Mu=Ru(),Ii=Mu;var An=new Set(["\x1B","›"]),Bu=39,Ts="\x07",Ri="[",Nu="]",Mi="m",Sn=`${Nu}8;;`,Ti=(e)=>`${An.values().next().value}${Ri}${e}${Mi}`,Pi=(e)=>`${An.values().next().value}${Sn}${e}${Ts}`,vu=(e)=>e.split(" ").map((t)=>We(t)),Is=(e,t,n)=>{let r=[...t],s=!1,i=!1,o=We(pt(e.at(-1)));for(let[a,c]of r.entries()){let u=We(c);if(o+u<=n)e[e.length-1]+=c;else e.push(c),o=0;if(An.has(c))s=!0,i=r.slice(a+1,a+1+Sn.length).join("")===Sn;if(s){if(i){if(c===Ts)s=!1,i=!1}else if(c===Mi)s=!1;continue}if(o+=u,o===n&&a<r.length-1)e.push(""),o=0}if(!o&&e.at(-1).length>0&&e.length>1)e[e.length-2]+=e.pop()},ju=(e)=>{let t=e.split(" "),n=t.length;while(n>0){if(We(t[n-1])>0)break;n--}if(n===t.length)return e;return t.slice(0,n).join(" ")+t.slice(n).join("")},Lu=(e,t,n={})=>{if(n.trim!==!1&&e.trim()==="")return"";let r="",s,i,o=vu(e),a=[""];for(let[l,d]of e.split(" ").entries()){if(n.trim!==!1)a[a.length-1]=a.at(-1).trimStart();let p=We(a.at(-1));if(l!==0){if(p>=t&&(n.wordWrap===!1||n.trim===!1))a.push(""),p=0;if(p>0||n.trim===!1)a[a.length-1]+=" ",p++}if(n.hard&&o[l]>t){let m=t-p,h=1+Math.floor((o[l]-m-1)/t);if(Math.floor((o[l]-1)/t)<h)a.push("");Is(a,d,t);continue}if(p+o[l]>t&&p>0&&o[l]>0){if(n.wordWrap===!1&&p<t){Is(a,d,t);continue}a.push("")}if(p+o[l]>t&&n.wordWrap===!1){Is(a,d,t);continue}a[a.length-1]+=d}if(n.trim!==!1)a=a.map((l)=>ju(l));let c=a.join(`
8
- `),u=[...c],f=0;for(let[l,d]of u.entries()){if(r+=d,An.has(d)){let{groups:m}=new RegExp(`(?:\\${Ri}(?<code>\\d+)m|\\${Sn}(?<uri>.*)${Ts})`).exec(c.slice(f))||{groups:{}};if(m.code!==void 0){let h=Number.parseFloat(m.code);s=h===Bu?void 0:h}else if(m.uri!==void 0)i=m.uri.length===0?void 0:m.uri}let p=Ii.codes.get(Number(s));if(u[l+1]===`
9
- `){if(i)r+=Pi("");if(s&&p)r+=Ti(p)}else if(d===`
10
- `){if(s&&p)r+=Ti(s);if(i)r+=Pi(i)}f+=d.length}return r};function Ps(e,t,n){return String(e).normalize().replaceAll(`\r
7
+ `);if(s.border)r.unshift("."+"-".repeat(this.negatePadding(s)+2)+"."),r.push("'"+"-".repeat(this.negatePadding(s)+2)+"'");if(s.padding)r.unshift(...Array(s.padding[0]||0).fill("")),r.push(...Array(s.padding[2]||0).fill(""));r.forEach((i,a)=>{if(!t[a])t.push([]);let c=t[a];for(let u=0;u<o;u++)if(c[u]===void 0)c.push("");c.push(i)})}),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((o)=>o.width||Se.stringWidth(o.text));let t=e.length,n=this.width,r=e.map((o)=>{if(o.width)return t--,n-=o.width,o.width;return}),s=t?Math.floor(n/t):0;return r.map((o,i)=>{if(o===void 0)return Math.max(s,Eu(e[i]));return o})}}function lo(e,t,n){if(e.border){if(/[.']-+[.']/.test(t))return"";if(t.trim().length!==0)return n;return" "}return""}function Eu(e){let t=e.padding||[],n=1+(t[3]||0)+(t[1]||0);if(e.border)return n+4;return n}function xu(){if(typeof process==="object"&&process.stdout&&process.stdout.columns)return process.stdout.columns;return 80}function _u(e,t){e=e.trim();let n=Se.stringWidth(e);if(n<t)return" ".repeat(t-n)+e;return e}function ku(e,t){e=e.trim();let n=Se.stringWidth(e);if(n>=t)return e;return" ".repeat(t-n>>1)+e}var Se;function ho(e,t){return Se=t,new fo({width:(e===null||e===void 0?void 0:e.width)||xu(),wrap:e===null||e===void 0?void 0:e.wrap})}function Os({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 Su=Os();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(Su,"")}var po=161,go=1114109,mo=[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],Do=12288,yo=65510,bo=[12288,12288,65281,65376,65504,65510];var wo=4352,Fo=262141,Is=[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 Sn=(e,t)=>{let n=0,r=Math.floor(e.length/2)-1;while(n<=r){let s=Math.floor((n+r)/2),o=s*2;if(t<e[o])r=s-1;else if(t>e[o+1])n=s+1;else return!0}return!1};var Co=19968,[Au,$u]=Ou(Is);function Ou(e){let t=e[0],n=e[1];for(let r=0;r<e.length;r+=2){let s=e[r],o=e[r+1];if(Co>=s&&Co<=o)return[s,o];if(o-s>n-t)t=s,n=o}return[t,n]}var Eo=(e)=>{if(e<po||e>go)return!1;return Sn(mo,e)},xo=(e)=>{if(e<Do||e>yo)return!1;return Sn(bo,e)};var _o=(e)=>{if(e>=Au&&e<=$u)return!0;if(e<wo||e>Fo)return!1;return Sn(Is,e)};function Iu(e){if(!Number.isSafeInteger(e))throw TypeError(`Expected a code point, got \`${typeof e}\`.`)}function ko(e,{ambiguousAsWide:t=!1}={}){if(Iu(e),xo(e)||_o(e)||t&&Eo(e))return 2;return 1}var $o=co(Ao(),1),Tu=new Intl.Segmenter,Pu=/^\p{Default_Ignorable_Code_Point}$/u;function We(e,t={}){if(typeof e!=="string"||e.length===0)return 0;let{ambiguousIsNarrow:n=!0,countAnsiEscapeCodes:r=!1}=t;if(!r)e=pt(e);if(e.length===0)return 0;let s=0,o={ambiguousAsWide:!n};for(let{segment:i}of Tu.segment(e)){let a=i.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(Pu.test(i))continue;if($o.default().test(i)){s+=2;continue}s+=ko(a,o)}return s}var Oo=(e=0)=>(t)=>`\x1B[${t+e}m`,Io=(e=0)=>(t)=>`\x1B[${38+e};5;${t}m`,To=(e=0)=>(t,n,r)=>`\x1B[${38+e};2;${t};${n};${r}m`,oe={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]}},xh=Object.keys(oe.modifier),Ru=Object.keys(oe.color),Mu=Object.keys(oe.bgColor),_h=[...Ru,...Mu];function Bu(){let e=new Map;for(let[t,n]of Object.entries(oe)){for(let[r,s]of Object.entries(n))oe[r]={open:`\x1B[${s[0]}m`,close:`\x1B[${s[1]}m`},n[r]=oe[r],e.set(s[0],s[1]);Object.defineProperty(oe,t,{value:n,enumerable:!1})}return Object.defineProperty(oe,"codes",{value:e,enumerable:!1}),oe.color.close="\x1B[39m",oe.bgColor.close="\x1B[49m",oe.color.ansi=Oo(),oe.color.ansi256=Io(),oe.color.ansi16m=To(),oe.bgColor.ansi=Oo(10),oe.bgColor.ansi256=Io(10),oe.bgColor.ansi16m=To(10),Object.defineProperties(oe,{rgbToAnsi256:{value(t,n,r){if(t===n&&n===r){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(r/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[r]=n;if(r.length===3)r=[...r].map((o)=>o+o).join("");let s=Number.parseInt(r,16);return[s>>16&255,s>>8&255,s&255]},enumerable:!1},hexToAnsi256:{value:(t)=>oe.rgbToAnsi256(...oe.hexToRgb(t)),enumerable:!1},ansi256ToAnsi:{value(t){if(t<8)return 30+t;if(t<16)return 90+(t-8);let n,r,s;if(t>=232)n=((t-232)*10+8)/255,r=n,s=n;else{t-=16;let a=t%36;n=Math.floor(t/36)/5,r=Math.floor(a/6)/5,s=a%6/5}let o=Math.max(n,r,s)*2;if(o===0)return 30;let i=30+(Math.round(s)<<2|Math.round(r)<<1|Math.round(n));if(o===2)i+=60;return i},enumerable:!1},rgbToAnsi:{value:(t,n,r)=>oe.ansi256ToAnsi(oe.rgbToAnsi256(t,n,r)),enumerable:!1},hexToAnsi:{value:(t)=>oe.ansi256ToAnsi(oe.hexToAnsi256(t)),enumerable:!1}}),oe}var Nu=Bu(),Po=Nu;var $n=new Set(["\x1B","›"]),vu=39,Ps="\x07",Bo="[",ju="]",No="m",An=`${ju}8;;`,Ro=(e)=>`${$n.values().next().value}${Bo}${e}${No}`,Mo=(e)=>`${$n.values().next().value}${An}${e}${Ps}`,Lu=(e)=>e.split(" ").map((t)=>We(t)),Ts=(e,t,n)=>{let r=[...t],s=!1,o=!1,i=We(pt(e.at(-1)));for(let[a,c]of r.entries()){let u=We(c);if(i+u<=n)e[e.length-1]+=c;else e.push(c),i=0;if($n.has(c))s=!0,o=r.slice(a+1,a+1+An.length).join("")===An;if(s){if(o){if(c===Ps)s=!1,o=!1}else if(c===No)s=!1;continue}if(i+=u,i===n&&a<r.length-1)e.push(""),i=0}if(!i&&e.at(-1).length>0&&e.length>1)e[e.length-2]+=e.pop()},Wu=(e)=>{let t=e.split(" "),n=t.length;while(n>0){if(We(t[n-1])>0)break;n--}if(n===t.length)return e;return t.slice(0,n).join(" ")+t.slice(n).join("")},Uu=(e,t,n={})=>{if(n.trim!==!1&&e.trim()==="")return"";let r="",s,o,i=Lu(e),a=[""];for(let[l,d]of e.split(" ").entries()){if(n.trim!==!1)a[a.length-1]=a.at(-1).trimStart();let p=We(a.at(-1));if(l!==0){if(p>=t&&(n.wordWrap===!1||n.trim===!1))a.push(""),p=0;if(p>0||n.trim===!1)a[a.length-1]+=" ",p++}if(n.hard&&i[l]>t){let m=t-p,h=1+Math.floor((i[l]-m-1)/t);if(Math.floor((i[l]-1)/t)<h)a.push("");Ts(a,d,t);continue}if(p+i[l]>t&&p>0&&i[l]>0){if(n.wordWrap===!1&&p<t){Ts(a,d,t);continue}a.push("")}if(p+i[l]>t&&n.wordWrap===!1){Ts(a,d,t);continue}a[a.length-1]+=d}if(n.trim!==!1)a=a.map((l)=>Wu(l));let c=a.join(`
8
+ `),u=[...c],f=0;for(let[l,d]of u.entries()){if(r+=d,$n.has(d)){let{groups:m}=new RegExp(`(?:\\${Bo}(?<code>\\d+)m|\\${An}(?<uri>.*)${Ps})`).exec(c.slice(f))||{groups:{}};if(m.code!==void 0){let h=Number.parseFloat(m.code);s=h===vu?void 0:h}else if(m.uri!==void 0)o=m.uri.length===0?void 0:m.uri}let p=Po.codes.get(Number(s));if(u[l+1]===`
9
+ `){if(o)r+=Mo("");if(s&&p)r+=Ro(p)}else if(d===`
10
+ `){if(s&&p)r+=Ro(s);if(o)r+=Mo(o)}f+=d.length}return r};function Rs(e,t,n){return String(e).normalize().replaceAll(`\r
11
11
  `,`
12
12
  `).split(`
13
- `).map((r)=>Lu(r,t,n)).join(`
14
- `)}function Rs(e){return fi(e,{stringWidth:We,stripAnsi:pt,wrap:Ps})}import{dirname as Bi,resolve as Ni}from"path";import{readdirSync as Wu,statSync as Uu}from"fs";function Ms(e,t){let n=Ni(".",e),r;if(!Uu(n).isDirectory())n=Bi(n);while(!0){if(r=t(n,Wu(n)),r)return Ni(n,r);if(n=Bi(r=n),r===n)break}}import{inspect as ol}from"util";import{fileURLToPath as eo}from"url";import{format as zu}from"util";import{normalize as Hu,resolve as qu}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="",r=!1,s=e.match(/^-+/);for(let i=s?s[0].length:0;i<e.length;i++){let o=e.charAt(i);if(r)r=!1,o=o.toUpperCase();if(i!==0&&(o==="-"||o==="_"))r=!0;else if(o!=="-"&&o!=="_")n+=o}return n}}function $n(e,t){let n=e.toLowerCase();t=t||"-";let r="";for(let s=0;s<e.length;s++){let i=n.charAt(s),o=e.charAt(s);if(i!==o&&s>0)r+=`${t}${n.charAt(s)}`;else r+=o}return r}function On(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 vi(e){if(Array.isArray(e))return e.map((o)=>typeof o!=="string"?o+"":o);e=e.trim();let t=0,n=null,r=null,s=null,i=[];for(let o=0;o<e.length;o++){if(n=r,r=e.charAt(o),r===" "&&!s){if(n!==" ")t++;continue}if(r===s)s=null;else if((r==="'"||r==='"')&&!s)s=r;if(!i[t])i[t]="";i[t]+=r}return i}var Te;(function(e){e.BOOLEAN="boolean",e.STRING="string",e.NUMBER="number",e.ARRAY="array"})(Te||(Te={}));var Ze;class Ns{constructor(e){Ze=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),r=vi(e),s=typeof e==="string",i=Ku(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),p=Object.create(null),m=n.__||Ze.format,h={aliases:Object.create(null),arrays:Object.create(null),bools:Object.create(null),strings:Object.create(null),numbers:Object.create(null),counts:Object.create(null),normalize:Object.create(null),configs:Object.create(null),nargs:Object.create(null),coercions:Object.create(null),keys:[]},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,T=Object.keys(D).map(function(x){return{boolean:"bools",string:"strings",number:"numbers"}[x]}).filter(Boolean).pop();if(T)h[T][b]=!0;h.arrays[b]=!0,h.keys.push(b)}),[].concat(n.boolean||[]).filter(Boolean).forEach(function(D){h.bools[D]=!0,h.keys.push(D)}),[].concat(n.string||[]).filter(Boolean).forEach(function(D){h.strings[D]=!0,h.keys.push(D)}),[].concat(n.number||[]).filter(Boolean).forEach(function(D){h.numbers[D]=!0,h.keys.push(D)}),[].concat(n.count||[]).filter(Boolean).forEach(function(D){h.counts[D]=!0,h.keys.push(D)}),[].concat(n.normalize||[]).filter(Boolean).forEach(function(D){h.normalize[D]=!0,h.keys.push(D)}),typeof n.narg==="object")Object.entries(n.narg).forEach(([D,b])=>{if(typeof b==="number")h.nargs[D]=b,h.keys.push(D)});if(typeof n.coerce==="object")Object.entries(n.coerce).forEach(([D,b])=>{if(typeof b==="function")h.coercions[D]=b,h.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){h.configs[D]=!0});else if(typeof n.config==="object")Object.entries(n.config).forEach(([D,b])=>{if(typeof b==="boolean"||typeof b==="function")h.configs[D]=b})}Q(n.key,i,n.default,h.arrays),Object.keys(a).forEach(function(D){(h.aliases[D]||[]).forEach(function(b){a[b]=a[D]})});let F=null;Ss();let A=[],_=Object.assign(Object.create(null),{_:[]}),B={};for(let D=0;D<r.length;D++){let b=r[D],T=b.replace(/^-{3,}/,"---"),x,w,U,M,J,ge;if(b!=="--"&&/^-/.test(b)&&se(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(N(M[1],h.arrays))D=V(D,M[1],r,M[2]);else if(N(M[1],h.nargs)!==!1)D=R(D,M[1],r,M[2]);else L(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],L(w,N(w,h.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],N(w,h.arrays))D=V(D,w,r);else if(N(w,h.nargs)!==!1)D=R(D,w,r);else if(J=r[D+1],J!==void 0&&(!J.match(/^-/)||J.match(y))&&!N(w,h.bools)&&!N(w,h.counts))L(w,J),D++;else if(/^(true|false)$/.test(J))L(w,J),D++;else L(w,Z(w))}else if(b.match(/^-.\..+=/)){if(M=b.match(/^-([^=]+)=([\s\S]*)$/),M!==null&&Array.isArray(M)&&M.length>=3)L(M[1],M[2])}else if(b.match(/^-.\..+/)&&!b.match(y)){if(J=r[D+1],M=b.match(/^-(.\..+)/),M!==null&&Array.isArray(M)&&M.length>=2)if(w=M[1],J!==void 0&&!J.match(/^-/)&&!N(w,h.bools)&&!N(w,h.counts))L(w,J),D++;else L(w,Z(w))}else if(b.match(/^-[^-]+/)&&!b.match(y)){U=b.slice(1,-1).split(""),x=!1;for(let Fe=0;Fe<U.length;Fe++){if(J=b.slice(Fe+2),U[Fe+1]&&U[Fe+1]==="="){if(ge=b.slice(Fe+3),w=U[Fe],N(w,h.arrays))D=V(D,w,r,ge);else if(N(w,h.nargs)!==!1)D=R(D,w,r,ge);else L(w,ge);x=!0;break}if(J==="-"){L(U[Fe],J);continue}if(/[A-Za-z]/.test(U[Fe])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(J)&&N(J,h.bools)===!1){L(U[Fe],J),x=!0;break}if(U[Fe+1]&&U[Fe+1].match(/\W/)){L(U[Fe],J),x=!0;break}else L(U[Fe],Z(U[Fe]))}if(w=b.slice(-1)[0],!x&&w!=="-")if(N(w,h.arrays))D=V(D,w,r);else if(N(w,h.nargs)!==!1)D=R(D,w,r);else if(J=r[D+1],J!==void 0&&(!/^(-|--)[^-]/.test(J)||J.match(y))&&!N(w,h.bools)&&!N(w,h.counts))L(w,J),D++;else if(/^(true|false)$/.test(J))L(w,J),D++;else L(w,Z(w))}else if(b.match(/^-[0-9]$/)&&b.match(y)&&N(b.slice(1),h.bools))w=b.slice(1),L(w,Z(w));else if(b==="--"){A=r.slice(D+1);break}else if(o["halt-at-non-option"]){A=r.slice(D);break}else I(b)}if(G(_,!0),G(_,!1),S(_),W(),Ie(_,h.aliases,a,!0),q(_),o["set-placeholder-key"])ae(_);if(Object.keys(h.counts).forEach(function(D){if(!te(_,D.split(".")))L(D,0)}),f&&A.length)_[l]=[];if(A.forEach(function(D){_[l].push(D)}),o["camel-case-expansion"]&&o["strip-dashed"])Object.keys(_).filter((D)=>D!=="--"&&D.includes("-")).forEach((D)=>{delete _[D]});if(o["strip-aliased"])[].concat(...Object.keys(i).map((D)=>i[D])).forEach((D)=>{if(o["camel-case-expansion"]&&D.includes("-"))delete _[D.split(".").map((b)=>ht(b)).join(".")];delete _[D]});function I(D){let b=C("_",D);if(typeof b==="string"||typeof b==="number")_._.push(b)}function R(D,b,T,x){let w,U=N(b,h.nargs);if(U=typeof U!=="number"||isNaN(U)?1:U,U===0){if(!pe(x))F=Error(m("Argument unexpected for: %s",b));return L(b,Z(b)),D}let M=pe(x)?0:1;if(o["nargs-eats-options"]){if(T.length-(D+1)+M<U)F=Error(m("Not enough arguments following: %s",b));M=U}else{for(w=D+1;w<T.length;w++)if(!T[w].match(/^-[^0-9]/)||T[w].match(y)||se(T[w]))M++;else break;if(M<U)F=Error(m("Not enough arguments following: %s",b))}let J=Math.min(M,U);if(!pe(x)&&J>0)L(b,x),J--;for(w=D+1;w<J+D+1;w++)L(b,T[w]);return D+J}function V(D,b,T,x){let w=[],U=x||T[D+1],M=N(b,h.nargs);if(N(b,h.bools)&&!/^(true|false)$/.test(U))w.push(!0);else if(pe(U)||pe(x)&&/^-/.test(U)&&!y.test(U)&&!se(U)){if(a[b]!==void 0){let J=a[b];w=Array.isArray(J)?J:[J]}}else{if(!pe(x))w.push(k(b,x,!0));for(let J=D+1;J<T.length;J++){if(!o["greedy-arrays"]&&w.length>0||M&&typeof M==="number"&&w.length>=M)break;if(U=T[J],/^-/.test(U)&&!y.test(U)&&!se(U))break;D=J,w.push(k(b,U,s))}}if(typeof M==="number"&&(M&&w.length<M||isNaN(M)&&w.length===0))F=Error(m("Not enough arguments following: %s",b));return L(b,w),D}function L(D,b,T=s){if(/-/.test(D)&&o["camel-case-expansion"]){let U=D.split(".").map(function(M){return ht(M)}).join(".");ne(D,U)}let x=k(D,b,T),w=D.split(".");if(ke(_,w,x),h.aliases[D])h.aliases[D].forEach(function(U){let M=U.split(".");ke(_,M,x)});if(w.length>1&&o["dot-notation"])(h.aliases[w[0]]||[]).forEach(function(U){let M=U.split("."),J=[].concat(w);if(J.shift(),M=M.concat(J),!(h.aliases[D]||[]).includes(M.join(".")))ke(_,M,x)});if(N(D,h.normalize)&&!N(D,h.arrays))[D].concat(h.aliases[D]||[]).forEach(function(M){Object.defineProperty(B,M,{enumerable:!0,get(){return b},set(J){b=typeof J==="string"?Ze.normalize(J):J}})})}function ne(D,b){if(!(h.aliases[D]&&h.aliases[D].length))h.aliases[D]=[b],d[b]=!0;if(!(h.aliases[b]&&h.aliases[b].length))ne(b,D)}function k(D,b,T){if(T)b=Ju(b);if(N(D,h.bools)||N(D,h.counts)){if(typeof b==="string")b=b==="true"}let x=Array.isArray(b)?b.map(function(w){return C(D,w)}):C(D,b);if(N(D,h.counts)&&(pe(x)||typeof x==="boolean"))x=Bs();if(N(D,h.normalize)&&N(D,h.arrays))if(Array.isArray(b))x=b.map((w)=>Ze.normalize(w));else x=Ze.normalize(b);return x}function C(D,b){if(!o["parse-positional-numbers"]&&D==="_")return b;if(!N(D,h.strings)&&!N(D,h.bools)&&!Array.isArray(b)){if(On(b)&&o["parse-numbers"]&&Number.isSafeInteger(Math.floor(parseFloat(`${b}`)))||!pe(b)&&N(D,h.numbers))b=Number(b)}return b}function S(D){let b=Object.create(null);Ie(b,h.aliases,a),Object.keys(h.configs).forEach(function(T){let x=D[T]||b[T];if(x)try{let w=null,U=Ze.resolve(Ze.cwd(),x),M=h.configs[T];if(typeof M==="function"){try{w=M(U)}catch(J){w=J}if(w instanceof Error){F=w;return}}else w=Ze.require(U);O(w)}catch(w){if(w.name==="PermissionDenied")F=w;else if(D[T])F=Error(m("Invalid JSON config file: %s",x))}})}function O(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"])O(x,w);else if(!te(_,w.split("."))||N(w,h.arrays)&&o["combine-arrays"])L(w,x)})}function W(){if(typeof c<"u")c.forEach(function(D){O(D)})}function G(D,b){if(typeof u>"u")return;let T=typeof u==="string"?u:"",x=Ze.env();Object.keys(x).forEach(function(w){if(T===""||w.lastIndexOf(T,0)===0){let U=w.split("__").map(function(M,J){if(J===0)M=M.substring(T.length);return ht(M)});if((b&&h.configs[U.join(".")]||!b)&&!te(D,U))L(U.join("."),x[w])}})}function q(D){let b,T=new Set;Object.keys(D).forEach(function(x){if(!T.has(x)){if(b=N(x,h.coercions),typeof b==="function")try{let w=C(x,b(D[x]));[].concat(h.aliases[x]||[],x).forEach((U)=>{T.add(U),D[U]=w})}catch(w){F=w}}})}function ae(D){return h.keys.forEach((b)=>{if(~b.indexOf("."))return;if(typeof D[b]>"u")D[b]=void 0}),D}function Ie(D,b,T,x=!1){Object.keys(T).forEach(function(w){if(!te(D,w.split("."))){if(ke(D,w.split("."),T[w]),x)p[w]=!0;(b[w]||[]).forEach(function(U){if(te(D,U.split(".")))return;ke(D,U.split("."),T[w])})}})}function te(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 ke(D,b,T){let x=D;if(!o["dot-notation"])b=[b.join(".")];b.slice(0,-1).forEach(function(ge){if(ge=ji(ge),typeof x==="object"&&x[ge]===void 0)x[ge]={};if(typeof x[ge]!=="object"||Array.isArray(x[ge])){if(Array.isArray(x[ge]))x[ge].push({});else x[ge]=[x[ge],{}];x=x[ge][x[ge].length-1]}else x=x[ge]});let w=ji(b[b.length-1]),U=N(b.join("."),h.arrays),M=Array.isArray(T),J=o["duplicate-arguments-array"];if(!J&&N(w,h.nargs)){if(J=!0,!pe(x[w])&&h.nargs[w]===1||Array.isArray(x[w])&&x[w].length===h.nargs[w])x[w]=void 0}if(T===Bs())x[w]=Bs(x[w]);else if(Array.isArray(x[w]))if(J&&U&&M)x[w]=o["flatten-duplicate-arrays"]?x[w].concat(T):(Array.isArray(x[w][0])?x[w]:[x[w]]).concat([T]);else if(!J&&Boolean(U)===Boolean(M))x[w]=T;else x[w]=x[w].concat([T]);else if(x[w]===void 0&&U)x[w]=M?T:[T];else if(J&&!(x[w]===void 0||N(w,h.counts)||N(w,h.bools)))x[w]=[x[w],T];else x[w]=T}function Q(...D){D.forEach(function(b){Object.keys(b||{}).forEach(function(T){if(h.aliases[T])return;h.aliases[T]=[].concat(i[T]||[]),h.aliases[T].concat(T).forEach(function(x){if(/-/.test(x)&&o["camel-case-expansion"]){let w=ht(x);if(w!==T&&h.aliases[T].indexOf(w)===-1)h.aliases[T].push(w),d[w]=!0}}),h.aliases[T].concat(T).forEach(function(x){if(x.length>1&&/[A-Z]/.test(x)&&o["camel-case-expansion"]){let w=$n(x,"-");if(w!==T&&h.aliases[T].indexOf(w)===-1)h.aliases[T].push(w),d[w]=!0}}),h.aliases[T].forEach(function(x){h.aliases[x]=[T].concat(h.aliases[T].filter(function(w){return x!==w}))})})})}function N(D,b){let T=[].concat(h.aliases[D]||[],D),x=Object.keys(b),w=T.find((U)=>x.includes(U));return w?b[w]:!1}function be(D){let b=Object.keys(h);return[].concat(b.map((x)=>h[x])).some(function(x){return Array.isArray(x)?x.includes(D):x[D]})}function Wt(D,...b){return[].concat(...b).some(function(x){let w=D.match(x);return w&&be(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),!be(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 se(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!Wt(D,/^-+([^=]+?)=[\s\S]*$/,E,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}function Z(D){if(!N(D,h.bools)&&!N(D,h.counts)&&`${D}`in a)return a[D];else return ye(ue(D))}function ye(D){return{[Te.BOOLEAN]:!0,[Te.STRING]:"",[Te.NUMBER]:void 0,[Te.ARRAY]:[]}[D]}function ue(D){let b=Te.BOOLEAN;if(N(D,h.strings))b=Te.STRING;else if(N(D,h.numbers))b=Te.NUMBER;else if(N(D,h.bools))b=Te.BOOLEAN;else if(N(D,h.arrays))b=Te.ARRAY;return b}function pe(D){return D===void 0}function Ss(){Object.keys(h.counts).find((D)=>{if(N(D,h.arrays))return F=Error(m("Invalid configuration: %s, opts.count excludes opts.array.",D)),!0;else if(N(D,h.nargs))return F=Error(m("Invalid configuration: %s, opts.count excludes opts.narg.",D)),!0;return!1})}return{aliases:Object.assign({},h.aliases),argv:Object.assign(B,_),configuration:o,defaulted:Object.assign({},p),error:F,newAliases:Object.assign({},d)}}}function Ku(e){let t=[],n=Object.create(null),r=!0;Object.keys(e).forEach(function(s){t.push([].concat(e[s],s))});while(r){r=!1;for(let s=0;s<t.length;s++)for(let i=s+1;i<t.length;i++)if(t[s].filter(function(a){return t[i].indexOf(a)!==-1}).length){t[s]=t[s].concat(t[i]),t.splice(i,1),r=!0;break}}return t.forEach(function(s){s=s.filter(function(o,a,c){return c.indexOf(o)===a});let i=s.pop();if(i!==void 0&&typeof i==="string")n[i]=s}),n}function Bs(e){return e!==void 0?e+1:1}function ji(e){if(e==="__proto__")return"___proto___";return e}function Ju(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 Yu}from"fs";import{createRequire as Li}from"node:module";var vs,js,Ls,Wi=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):20,Ui=(js=(vs=process===null||process===void 0?void 0:process.versions)===null||vs===void 0?void 0:vs.node)!==null&&js!==void 0?js:(Ls=process===null||process===void 0?void 0:process.version)===null||Ls===void 0?void 0:Ls.slice(1);if(Ui){if(Number(Ui.match(/^([^.]+)/)[1])<Wi)throw Error(`yargs parser supports a minimum Node.js version of ${Wi}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`)}var Xu=process?process.env:{},Ki=Li?Li(import.meta.url):void 0,Ji=new Ns({cwd:process.cwd,env:()=>Xu,format:zu,normalize:Hu,resolve:qu,require:(e)=>{if(typeof Ki<"u")return Ki(e);else if(e.match(/\.json$/))return JSON.parse(Yu(e,"utf8"));else throw Error("only .json config files are supported in ESM")}}),tn=function(t,n){return Ji.parse(t.slice(),n).argv};tn.detailed=function(e,t){return Ji.parse(e.slice(),t)};tn.camelCase=ht;tn.decamelize=$n;tn.looksLikeNumber=On;var Ws=tn;import{basename as al,dirname as cl,extname as ul,relative as ll,resolve as Qi,join as fl}from"path";function zi(){if(Gu())return 0;return 1}function Gu(){return Vu()&&!process.defaultApp}function Vu(){return!!process.versions.electron}function Us(e){return e.slice(zi()+1)}function Hi(){return process.argv[zi()]}import{readFileSync as Zu,statSync as Qu,writeFile as el}from"fs";import{format as tl}from"util";import{resolve as nl}from"path";var qi={fs:{readFileSync:Zu,writeFile:el},format:tl,resolve:nl,exists:(e)=>{try{return Qu(e).isFile()}catch(t){return!1}}};var Ue;class Yi{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 Ue.format.apply(Ue.format,[this.cache[this.locale][t]||t].concat(e))}__n(){let e=Array.prototype.slice.call(arguments),t=e.shift(),n=e.shift(),r=e.shift(),s=function(){};if(typeof e[e.length-1]==="function")s=e.pop();if(!this.cache[this.locale])this._readLocaleFile();let i=r===1?t:n;if(this.cache[this.locale][t])i=this.cache[this.locale][t][r===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=[i];if(~i.indexOf("%d"))o.push(r);return Ue.format.apply(Ue.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(r,s){let i=t[s+1];if(n+=r,typeof i<"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],{directory:n,locale:r,cb:s}=t,i=this._resolveLocaleFile(n,r),o=JSON.stringify(this.cache[r],null,2);Ue.fs.writeFile(i,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(Ue.fs.readFileSync)e=JSON.parse(Ue.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=Ue.resolve(e,"./",t+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(n)&&~t.lastIndexOf("_")){let r=Ue.resolve(e,"./",t.split("_")[0]+".json");if(this._fileExistsSync(r))n=r}return n}_fileExistsSync(e){return Ue.exists(e)}}function Xi(e,t){Ue=t;let n=new Yi(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 sl=(e)=>Xi(e,qi),Gi=sl;var to=ai(Zi(),1);import{createRequire as dl}from"node:module";import{readFileSync as pl,readdirSync as hl}from"node:fs";var Ks=eo(import.meta.url),gl=Ks.substring(0,Ks.lastIndexOf("node_modules")),ml=dl(import.meta.url),Js={assert:{notStrictEqual:rl,strictEqual:il},cliui:Rs,findUp:Ms,getEnv:(e)=>process.env[e],inspect:ol,getProcessArgvBin:Hi,mainFilename:gl||process.cwd(),Parser:Ws,path:{basename:al,dirname:cl,extname:ul,relative:ll,resolve:Qi,join:fl},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:pl,readdirSync:hl,require:ml,getCallerFile:()=>{let e=to.default(3);return e.match(/^file:\/\//)?eo(e):e},stringWidth:We,y18n:Gi({directory:Qi(Ks,"../../../locales"),updateFiles:!1})};function Ce(e,t,n,r){n.assert.notStrictEqual(e,t,r)}function zs(e,t){t.assert.strictEqual(typeof e,"string")}function Ut(e){return Object.keys(e)}function re(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 tt(e){let n=e.replace(/\s{2,}/g," ").split(/\s+(?![^[]*]|[^<]*>)/),r=/\.*[\][<>]/g,s=n.shift();if(!s)throw Error(`No command found in: ${e}`);let i={cmd:s.replace(r,""),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))i.optional.push({cmd:o.replace(r,"").split("|"),variadic:c});else i.demanded.push({cmd:o.replace(r,"").split("|"),variadic:c})}),i}var Dl=["first","second","third","fourth","fifth","sixth"];function v(e,t,n){function r(){return typeof e==="object"?[{demanded:[],optional:[]},e,t]:[tt(`cmd ${e}`),t,n]}try{let s=0,[i,o,a]=r(),c=[].slice.call(o);while(c.length&&c[c.length-1]===void 0)c.pop();let u=a||c.length;if(u<i.demanded.length)throw new le(`Not enough arguments provided. Expected ${i.demanded.length} but received ${c.length}.`);let f=i.demanded.length+i.optional.length;if(u>f)throw new le(`Too many arguments provided. Expected max ${f} but received ${u}.`);i.demanded.forEach((l)=>{let d=c.shift(),p=no(d);if(l.cmd.filter((h)=>h===p||h==="*").length===0)so(p,l.cmd,s);s+=1}),i.optional.forEach((l)=>{if(c.length===0)return;let d=c.shift(),p=no(d);if(l.cmd.filter((h)=>h===p||h==="*").length===0)so(p,l.cmd,s);s+=1})}catch(s){console.warn(s.stack)}}function no(e){if(Array.isArray(e))return"array";else if(e===null)return"null";return typeof e}function so(e,t,n){throw new le(`Invalid ${Dl[n]||"manyith"} argument. Expected ${t.join(" or ")} but received ${e}.`)}class Hs{constructor(e){this.globalMiddleware=[],this.frozens=[],this.yargs=e}addMiddleware(e,t,n=!0,r=!1){if(v("<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 i=e[s];i.applyBeforeValidation=t,i.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=r,this.globalMiddleware.push(e)}return this.yargs}addCoerceMiddleware(e,t){let n=this.yargs.getAliases();return this.globalMiddleware=this.globalMiddleware.filter((r)=>{let s=[...n[t]||[],t];if(!r.option)return!0;else return!s.includes(r.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 ro(e){if(!e)return[];return e.map((t)=>(t.applyBeforeValidation=!1,t))}function gt(e,t,n,r){return n.reduce((s,i)=>{if(i.applyBeforeValidation!==r)return s;if(i.mutates){if(i.applied)return s;i.applied=!0}if(re(s))return s.then((o)=>Promise.all([o,i(o,t)])).then(([o,a])=>Object.assign(o,a));else{let o=i(s,t);return re(o)?o.then((a)=>Object.assign(s,a)):Object.assign(s,o)}},e)}function mt(e,t,n=(r)=>{throw r}){try{let r=yl(e)?e():e;return re(r)?r.then((s)=>t(s)):t(r)}catch(r){return n(r)}}function yl(e){return typeof e==="function"}var Kt=/(^\*)|(^\$0)/;class oo{constructor(e,t,n,r){this.requireCache=new Set,this.handlers={},this.aliasMap={},this.frozens=[],this.shim=r,this.usage=e,this.globalMiddleware=n,this.validation=t}addDirectory(e,t,n,r){r=r||{},this.requireCache.add(n);let s=this.shim.path.resolve(this.shim.path.dirname(n),e),i=this.shim.readdirSync(s,{recursive:r.recurse?!0:!1});if(!Array.isArray(r.extensions))r.extensions=["js"];let o=typeof r.visit==="function"?r.visit:(a)=>a;for(let a of i){let c=a.toString();if(r.exclude){let f=!1;if(typeof r.exclude==="function")f=r.exclude(c);else f=r.exclude.test(c);if(f)continue}if(r.include){let f=!1;if(typeof r.include==="function")f=r.include(c);else f=r.include.test(c);if(!f)continue}let u=!1;for(let f of r.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,r,s,i){let o=[],a=ro(s);if(r=r||(()=>{}),Array.isArray(e))if(wl(e))[e,...o]=e;else for(let c of e)this.addHandler(c);else if(Fl(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(io(n)){this.addHandler([e].concat(o),t,n.builder,n.handler,n.middlewares,n.deprecated);return}if(typeof e==="string"){let c=tt(e);o=o.map((l)=>tt(l).cmd);let u=!1,f=[c.cmd].concat(o).filter((l)=>{if(Kt.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(Kt,c.cmd);if(o.forEach((l)=>{this.aliasMap[l]=c.cmd}),t!==!1)this.usage.command(e,t,u,o,i);if(this.handlers[c.cmd]={original:e,description:t,handler:r,builder:n||{},middlewares:a,deprecated:i,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,r,s,i){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,r,s,i);return re(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,r,s,i,o,a){let c=t.builder,u=n;if(In(c)){n.getInternalMethods().getUsageInstance().freeze();let f=c(n.getInternalMethods().reset(r),a);if(re(f))return f.then((l)=>(u=co(l)?l:n,this.parseAndUpdateUsage(e,t,u,s,i,o)))}else if(bl(c))n.getInternalMethods().getUsageInstance().freeze(),u=n.getInternalMethods().reset(r),Object.keys(t.builder).forEach((f)=>{u.option(f,c[f])});return this.parseAndUpdateUsage(e,t,u,s,i,o)}parseAndUpdateUsage(e,t,n,r,s,i){if(e)n.getInternalMethods().getUsageInstance().unfreeze(!0);if(this.shouldUpdateUsage(n))n.getInternalMethods().getUsageInstance().usage(this.usageFromParentCommandsCommandHandler(r,t),t.description);let o=n.getInternalMethods().runYargsParserAndExecuteCommands(null,void 0,!0,s,i);return re(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=Kt.test(t.original)?t.original.replace(Kt,"").trim():t.original,r=e.filter((s)=>!Kt.test(s));return r.push(n),`$0 ${r.join(" ")}`}handleValidationAndGetResult(e,t,n,r,s,i,o,a){if(!i.getInternalMethods().getHasOutput()){let c=i.getInternalMethods().runValidation(s,a,i.parsed.error,e);n=mt(n,(u)=>(c(u),u))}if(t.handler&&!i.getInternalMethods().getHasOutput()){i.getInternalMethods().setHasOutput();let c=!!i.getOptions().configuration["populate--"];if(i.getInternalMethods().postProcess(n,c,!1,!1),n=gt(n,i,o,!1),n=mt(n,(u)=>{let f=t.handler(u);return re(f)?f.then(()=>u):u}),!e)i.getInternalMethods().getUsageInstance().cacheHelpMessage();if(re(n)&&!i.getInternalMethods().hasParseCallback())n.catch((u)=>{try{i.getInternalMethods().getUsageInstance().fail(null,u)}catch(f){}})}if(!e)r.commands.pop(),r.fullCommands.pop();return n}applyMiddlewareAndGetResult(e,t,n,r,s,i,o){let a={};if(s)return n;if(!o.getInternalMethods().getHasOutput())a=this.populatePositionals(t,n,r,o);let c=this.globalMiddleware.getMiddleware().slice(0).concat(t.middlewares),u=gt(n,o,c,!0);return re(u)?u.then((f)=>this.handleValidationAndGetResult(e,t,f,r,i,o,c,a)):this.handleValidationAndGetResult(e,t,u,r,i,o,c,a)}populatePositionals(e,t,n,r){t._=t._.slice(n.commands.length);let s=e.demanded.slice(0),i=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(i.length){let a=i.shift();this.populatePositional(a,t,o)}return t._=n.commands.concat(t._.map((a)=>""+a)),this.postProcessPositionals(t,o,this.cmdToParseOptions(e.original),r),o}populatePositional(e,t,n){let r=e.cmd[0];if(e.variadic)n[r]=t._.splice(0).map(String);else if(t._.length)n[r]=[String(t._.shift())]}cmdToParseOptions(e){let t={array:[],default:{},alias:{},demand:{}},n=tt(e);return n.demanded.forEach((r)=>{let[s,...i]=r.cmd;if(r.variadic)t.array.push(s),t.default[s]=[];t.alias[s]=i,t.demand[s]=!0}),n.optional.forEach((r)=>{let[s,...i]=r.cmd;if(r.variadic)t.array.push(s),t.default[s]=[];t.alias[s]=i}),t}postProcessPositionals(e,t,n,r){let s=Object.assign({},r.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 i=[];if(Object.keys(t).forEach((c)=>{t[c].map((u)=>{if(s.configuration["unknown-options-as-args"])s.key[c]=!0;i.push(`--${c}`),i.push(u)})}),!i.length)return;let o=Object.assign({},s.configuration,{"populate--":!1}),a=this.shim.Parser.detailed(i,Object.assign({},s,{configuration:o}));if(a.error)r.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(r,u)&&!this.isDefaulted(r,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((r)=>Object.prototype.hasOwnProperty.call(r,t))||n.some((r)=>Object.prototype.hasOwnProperty.call(r,this.shim.Parser.camelCase(t)))}runDefaultBuilderOn(e){if(!this.defaultCommand)return;if(this.shouldUpdateUsage(e)){let n=Kt.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(In(t))return t(e,!0);else if(!io(t))Object.keys(t).forEach((n)=>{e.option(n,t[n])});return}extractDesc({describe:e,description:t,desc:n}){for(let r of[e,t,n]){if(typeof r==="string"||r===!1)return r;Ce(r,!0,this.shim)}return!1}freeze(){this.frozens.push({handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand})}unfreeze(){let e=this.frozens.pop();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 ao(e,t,n,r){return new oo(e,t,n,r)}function io(e){return typeof e==="object"&&!!e.builder&&typeof e.handler==="function"}function wl(e){return e.every((t)=>typeof t==="string")}function In(e){return typeof e==="function"}function bl(e){return typeof e==="object"}function Fl(e){return typeof e==="object"&&!Array.isArray(e)}function nt(e={},t=()=>!0){let n={};return Ut(e).forEach((r)=>{if(t(r,e[r]))n[r]=e[r]}),n}function st(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 Cl(e){return typeof e==="boolean"}function lo(e,t){let n=t.y18n.__,r={},s=[];r.failFn=function(C){s.push(C)};let i=null,o=null,a=!0;r.showHelpOnFail=function(C=!0,S){let[O,W]=typeof C==="string"?[!0,C]:[C,S];if(e.getInternalMethods().isGlobalContext())o=W;return i=W,a=O,r};let c=!1;r.fail=function(C,S){let O=e.getInternalMethods().getLoggerInstance();if(s.length)for(let W=s.length-1;W>=0;--W){let G=s[W];if(Cl(G)){if(S)throw S;else if(C)throw Error(C)}else G(C,S,r)}else{if(e.getExitProcess())st(!0);if(!c){if(c=!0,a)e.showHelp("error"),O.error();if(C||S)O.error(C||S);let W=i||o;if(W){if(C||S)O.error("");O.error(W)}}if(S=S||new le(C),e.getExitProcess())return e.exit(1);else if(e.getInternalMethods().hasParseCallback())return e.exit(1,S);else throw S}};let u=[],f=!1;r.usage=(k,C)=>{if(k===null)return f=!0,u=[],r;return f=!1,u.push([k,C||""]),r},r.getUsage=()=>u,r.getUsageDisabled=()=>f,r.getPositionalGroupName=()=>n("Positionals:");let l=[];r.example=(k,C)=>{l.push([k,C||""])};let d=[];r.command=function(C,S,O,W,G=!1){if(O)d=d.map((q)=>(q[2]=!1,q));d.push([C,S||"",O,W,G])},r.getCommands=()=>d;let p={};r.describe=function(C,S){if(Array.isArray(C))C.forEach((O)=>{r.describe(O,S)});else if(typeof C==="object")Object.keys(C).forEach((O)=>{r.describe(O,C[O])});else p[C]=S},r.getDescriptions=()=>p;let m=[];r.epilog=(k)=>{m.push(k)};let h=!1,y;r.wrap=(k)=>{h=!0,y=k},r.getWrap=()=>{if(t.getEnv("YARGS_DISABLE_WRAP"))return null;if(!h)y=V(),h=!0;return y};let E="__yargsString__:";r.deferY18nLookup=(k)=>E+k,r.help=function(){if(_)return _;A();let C=e.customScriptName?e.$0:t.path.basename(e.$0),S=e.getDemandedOptions(),O=e.getDemandedCommands(),W=e.getDeprecatedOptions(),G=e.getGroups(),q=e.getOptions(),ae=[];ae=ae.concat(Object.keys(p)),ae=ae.concat(Object.keys(S)),ae=ae.concat(Object.keys(O)),ae=ae.concat(Object.keys(q.default)),ae=ae.filter(I),ae=Object.keys(ae.reduce((z,se)=>{if(se!=="_")z[se]=!0;return z},{}));let Ie=r.getWrap(),te=t.cliui({width:Ie,wrap:!!Ie});if(!f){if(u.length)u.forEach((z)=>{if(te.div({text:`${z[0].replace(/\$0/g,C)}`}),z[1])te.div({text:`${z[1]}`,padding:[1,0,0,0]})}),te.div();else if(d.length){let z=null;if(O._)z=`${C} <${n("command")}>
13
+ `).map((r)=>Uu(r,t,n)).join(`
14
+ `)}function Ms(e){return ho(e,{stringWidth:We,stripAnsi:pt,wrap:Rs})}import{dirname as vo,resolve as jo}from"path";import{readdirSync as Ku,statSync as Ju}from"fs";function Bs(e,t){let n=jo(".",e),r;if(!Ju(n).isDirectory())n=vo(n);while(!0){if(r=t(n,Ku(n)),r)return jo(n,r);if(n=vo(r=n),r===n)break}}import{inspect as cl}from"util";import{fileURLToPath as ni}from"url";import{format as qu}from"util";import{normalize as Yu,resolve as Xu}from"path";function gt(e){if(!(e!==e.toLowerCase()&&e!==e.toUpperCase()))e=e.toLowerCase();if(e.indexOf("-")===-1&&e.indexOf("_")===-1)return e;else{let n="",r=!1,s=e.match(/^-+/);for(let o=s?s[0].length:0;o<e.length;o++){let i=e.charAt(o);if(r)r=!1,i=i.toUpperCase();if(o!==0&&(i==="-"||i==="_"))r=!0;else if(i!=="-"&&i!=="_")n+=i}return n}}function On(e,t){let n=e.toLowerCase();t=t||"-";let r="";for(let s=0;s<e.length;s++){let o=n.charAt(s),i=e.charAt(s);if(o!==i&&s>0)r+=`${t}${n.charAt(s)}`;else r+=i}return r}function In(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 Lo(e){if(Array.isArray(e))return e.map((i)=>typeof i!=="string"?i+"":i);e=e.trim();let t=0,n=null,r=null,s=null,o=[];for(let i=0;i<e.length;i++){if(n=r,r=e.charAt(i),r===" "&&!s){if(n!==" ")t++;continue}if(r===s)s=null;else if((r==="'"||r==='"')&&!s)s=r;if(!o[t])o[t]="";o[t]+=r}return o}var Te;(function(e){e.BOOLEAN="boolean",e.STRING="string",e.NUMBER="number",e.ARRAY="array"})(Te||(Te={}));var Ze;class vs{constructor(e){Ze=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),r=Lo(e),s=typeof e==="string",o=zu(Object.assign(Object.create(null),n.alias)),i=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=i["populate--"],l=f?"--":"_",d=Object.create(null),p=Object.create(null),m=n.__||Ze.format,h={aliases:Object.create(null),arrays:Object.create(null),bools:Object.create(null),strings:Object.create(null),numbers:Object.create(null),counts:Object.create(null),normalize:Object.create(null),configs:Object.create(null),nargs:Object.create(null),coercions:Object.create(null),keys:[]},y=/^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/,E=new RegExp("^--"+i["negation-prefix"]+"(.+)");if([].concat(n.array||[]).filter(Boolean).forEach(function(D){let w=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)h[T][w]=!0;h.arrays[w]=!0,h.keys.push(w)}),[].concat(n.boolean||[]).filter(Boolean).forEach(function(D){h.bools[D]=!0,h.keys.push(D)}),[].concat(n.string||[]).filter(Boolean).forEach(function(D){h.strings[D]=!0,h.keys.push(D)}),[].concat(n.number||[]).filter(Boolean).forEach(function(D){h.numbers[D]=!0,h.keys.push(D)}),[].concat(n.count||[]).filter(Boolean).forEach(function(D){h.counts[D]=!0,h.keys.push(D)}),[].concat(n.normalize||[]).filter(Boolean).forEach(function(D){h.normalize[D]=!0,h.keys.push(D)}),typeof n.narg==="object")Object.entries(n.narg).forEach(([D,w])=>{if(typeof w==="number")h.nargs[D]=w,h.keys.push(D)});if(typeof n.coerce==="object")Object.entries(n.coerce).forEach(([D,w])=>{if(typeof w==="function")h.coercions[D]=w,h.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){h.configs[D]=!0});else if(typeof n.config==="object")Object.entries(n.config).forEach(([D,w])=>{if(typeof w==="boolean"||typeof w==="function")h.configs[D]=w})}ee(n.key,o,n.default,h.arrays),Object.keys(a).forEach(function(D){(h.aliases[D]||[]).forEach(function(w){a[w]=a[D]})});let F=null;As();let A=[],k=Object.assign(Object.create(null),{_:[]}),B={};for(let D=0;D<r.length;D++){let w=r[D],T=w.replace(/^-{3,}/,"---"),x,b,U,M,J,ge;if(w!=="--"&&/^-/.test(w)&&se(w))I(w);else if(T.match(/^---+(=|$)/)){I(w);continue}else if(w.match(/^--.+=/)||!i["short-option-groups"]&&w.match(/^-.+=/)){if(M=w.match(/^--?([^=]+)=([\s\S]*)$/),M!==null&&Array.isArray(M)&&M.length>=3)if(N(M[1],h.arrays))D=V(D,M[1],r,M[2]);else if(N(M[1],h.nargs)!==!1)D=R(D,M[1],r,M[2]);else L(M[1],M[2],!0)}else if(w.match(E)&&i["boolean-negation"]){if(M=w.match(E),M!==null&&Array.isArray(M)&&M.length>=2)b=M[1],L(b,N(b,h.arrays)?[!1]:!1)}else if(w.match(/^--.+/)||!i["short-option-groups"]&&w.match(/^-[^-]+/)){if(M=w.match(/^--?(.+)/),M!==null&&Array.isArray(M)&&M.length>=2)if(b=M[1],N(b,h.arrays))D=V(D,b,r);else if(N(b,h.nargs)!==!1)D=R(D,b,r);else if(J=r[D+1],J!==void 0&&(!J.match(/^-/)||J.match(y))&&!N(b,h.bools)&&!N(b,h.counts))L(b,J),D++;else if(/^(true|false)$/.test(J))L(b,J),D++;else L(b,Z(b))}else if(w.match(/^-.\..+=/)){if(M=w.match(/^-([^=]+)=([\s\S]*)$/),M!==null&&Array.isArray(M)&&M.length>=3)L(M[1],M[2])}else if(w.match(/^-.\..+/)&&!w.match(y)){if(J=r[D+1],M=w.match(/^-(.\..+)/),M!==null&&Array.isArray(M)&&M.length>=2)if(b=M[1],J!==void 0&&!J.match(/^-/)&&!N(b,h.bools)&&!N(b,h.counts))L(b,J),D++;else L(b,Z(b))}else if(w.match(/^-[^-]+/)&&!w.match(y)){U=w.slice(1,-1).split(""),x=!1;for(let Fe=0;Fe<U.length;Fe++){if(J=w.slice(Fe+2),U[Fe+1]&&U[Fe+1]==="="){if(ge=w.slice(Fe+3),b=U[Fe],N(b,h.arrays))D=V(D,b,r,ge);else if(N(b,h.nargs)!==!1)D=R(D,b,r,ge);else L(b,ge);x=!0;break}if(J==="-"){L(U[Fe],J);continue}if(/[A-Za-z]/.test(U[Fe])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(J)&&N(J,h.bools)===!1){L(U[Fe],J),x=!0;break}if(U[Fe+1]&&U[Fe+1].match(/\W/)){L(U[Fe],J),x=!0;break}else L(U[Fe],Z(U[Fe]))}if(b=w.slice(-1)[0],!x&&b!=="-")if(N(b,h.arrays))D=V(D,b,r);else if(N(b,h.nargs)!==!1)D=R(D,b,r);else if(J=r[D+1],J!==void 0&&(!/^(-|--)[^-]/.test(J)||J.match(y))&&!N(b,h.bools)&&!N(b,h.counts))L(b,J),D++;else if(/^(true|false)$/.test(J))L(b,J),D++;else L(b,Z(b))}else if(w.match(/^-[0-9]$/)&&w.match(y)&&N(w.slice(1),h.bools))b=w.slice(1),L(b,Z(b));else if(w==="--"){A=r.slice(D+1);break}else if(i["halt-at-non-option"]){A=r.slice(D);break}else I(w)}if(G(k,!0),G(k,!1),S(k),W(),Ie(k,h.aliases,a,!0),q(k),i["set-placeholder-key"])ae(k);if(Object.keys(h.counts).forEach(function(D){if(!te(k,D.split(".")))L(D,0)}),f&&A.length)k[l]=[];if(A.forEach(function(D){k[l].push(D)}),i["camel-case-expansion"]&&i["strip-dashed"])Object.keys(k).filter((D)=>D!=="--"&&D.includes("-")).forEach((D)=>{delete k[D]});if(i["strip-aliased"])[].concat(...Object.keys(o).map((D)=>o[D])).forEach((D)=>{if(i["camel-case-expansion"]&&D.includes("-"))delete k[D.split(".").map((w)=>gt(w)).join(".")];delete k[D]});function I(D){let w=C("_",D);if(typeof w==="string"||typeof w==="number")k._.push(w)}function R(D,w,T,x){let b,U=N(w,h.nargs);if(U=typeof U!=="number"||isNaN(U)?1:U,U===0){if(!he(x))F=Error(m("Argument unexpected for: %s",w));return L(w,Z(w)),D}let M=he(x)?0:1;if(i["nargs-eats-options"]){if(T.length-(D+1)+M<U)F=Error(m("Not enough arguments following: %s",w));M=U}else{for(b=D+1;b<T.length;b++)if(!T[b].match(/^-[^0-9]/)||T[b].match(y)||se(T[b]))M++;else break;if(M<U)F=Error(m("Not enough arguments following: %s",w))}let J=Math.min(M,U);if(!he(x)&&J>0)L(w,x),J--;for(b=D+1;b<J+D+1;b++)L(w,T[b]);return D+J}function V(D,w,T,x){let b=[],U=x||T[D+1],M=N(w,h.nargs);if(N(w,h.bools)&&!/^(true|false)$/.test(U))b.push(!0);else if(he(U)||he(x)&&/^-/.test(U)&&!y.test(U)&&!se(U)){if(a[w]!==void 0){let J=a[w];b=Array.isArray(J)?J:[J]}}else{if(!he(x))b.push(_(w,x,!0));for(let J=D+1;J<T.length;J++){if(!i["greedy-arrays"]&&b.length>0||M&&typeof M==="number"&&b.length>=M)break;if(U=T[J],/^-/.test(U)&&!y.test(U)&&!se(U))break;D=J,b.push(_(w,U,s))}}if(typeof M==="number"&&(M&&b.length<M||isNaN(M)&&b.length===0))F=Error(m("Not enough arguments following: %s",w));return L(w,b),D}function L(D,w,T=s){if(/-/.test(D)&&i["camel-case-expansion"]){let U=D.split(".").map(function(M){return gt(M)}).join(".");ne(D,U)}let x=_(D,w,T),b=D.split(".");if(ke(k,b,x),h.aliases[D])h.aliases[D].forEach(function(U){let M=U.split(".");ke(k,M,x)});if(b.length>1&&i["dot-notation"])(h.aliases[b[0]]||[]).forEach(function(U){let M=U.split("."),J=[].concat(b);if(J.shift(),M=M.concat(J),!(h.aliases[D]||[]).includes(M.join(".")))ke(k,M,x)});if(N(D,h.normalize)&&!N(D,h.arrays))[D].concat(h.aliases[D]||[]).forEach(function(M){Object.defineProperty(B,M,{enumerable:!0,get(){return w},set(J){w=typeof J==="string"?Ze.normalize(J):J}})})}function ne(D,w){if(!(h.aliases[D]&&h.aliases[D].length))h.aliases[D]=[w],d[w]=!0;if(!(h.aliases[w]&&h.aliases[w].length))ne(w,D)}function _(D,w,T){if(T)w=Hu(w);if(N(D,h.bools)||N(D,h.counts)){if(typeof w==="string")w=w==="true"}let x=Array.isArray(w)?w.map(function(b){return C(D,b)}):C(D,w);if(N(D,h.counts)&&(he(x)||typeof x==="boolean"))x=Ns();if(N(D,h.normalize)&&N(D,h.arrays))if(Array.isArray(w))x=w.map((b)=>Ze.normalize(b));else x=Ze.normalize(w);return x}function C(D,w){if(!i["parse-positional-numbers"]&&D==="_")return w;if(!N(D,h.strings)&&!N(D,h.bools)&&!Array.isArray(w)){if(In(w)&&i["parse-numbers"]&&Number.isSafeInteger(Math.floor(parseFloat(`${w}`)))||!he(w)&&N(D,h.numbers))w=Number(w)}return w}function S(D){let w=Object.create(null);Ie(w,h.aliases,a),Object.keys(h.configs).forEach(function(T){let x=D[T]||w[T];if(x)try{let b=null,U=Ze.resolve(Ze.cwd(),x),M=h.configs[T];if(typeof M==="function"){try{b=M(U)}catch(J){b=J}if(b instanceof Error){F=b;return}}else b=Ze.require(U);O(b)}catch(b){if(b.name==="PermissionDenied")F=b;else if(D[T])F=Error(m("Invalid JSON config file: %s",x))}})}function O(D,w){Object.keys(D).forEach(function(T){let x=D[T],b=w?w+"."+T:T;if(typeof x==="object"&&x!==null&&!Array.isArray(x)&&i["dot-notation"])O(x,b);else if(!te(k,b.split("."))||N(b,h.arrays)&&i["combine-arrays"])L(b,x)})}function W(){if(typeof c<"u")c.forEach(function(D){O(D)})}function G(D,w){if(typeof u>"u")return;let T=typeof u==="string"?u:"",x=Ze.env();Object.keys(x).forEach(function(b){if(T===""||b.lastIndexOf(T,0)===0){let U=b.split("__").map(function(M,J){if(J===0)M=M.substring(T.length);return gt(M)});if((w&&h.configs[U.join(".")]||!w)&&!te(D,U))L(U.join("."),x[b])}})}function q(D){let w,T=new Set;Object.keys(D).forEach(function(x){if(!T.has(x)){if(w=N(x,h.coercions),typeof w==="function")try{let b=C(x,w(D[x]));[].concat(h.aliases[x]||[],x).forEach((U)=>{T.add(U),D[U]=b})}catch(b){F=b}}})}function ae(D){return h.keys.forEach((w)=>{if(~w.indexOf("."))return;if(typeof D[w]>"u")D[w]=void 0}),D}function Ie(D,w,T,x=!1){Object.keys(T).forEach(function(b){if(!te(D,b.split("."))){if(ke(D,b.split("."),T[b]),x)p[b]=!0;(w[b]||[]).forEach(function(U){if(te(D,U.split(".")))return;ke(D,U.split("."),T[b])})}})}function te(D,w){let T=D;if(!i["dot-notation"])w=[w.join(".")];w.slice(0,-1).forEach(function(b){T=T[b]||{}});let x=w[w.length-1];if(typeof T!=="object")return!1;else return x in T}function ke(D,w,T){let x=D;if(!i["dot-notation"])w=[w.join(".")];w.slice(0,-1).forEach(function(ge){if(ge=Wo(ge),typeof x==="object"&&x[ge]===void 0)x[ge]={};if(typeof x[ge]!=="object"||Array.isArray(x[ge])){if(Array.isArray(x[ge]))x[ge].push({});else x[ge]=[x[ge],{}];x=x[ge][x[ge].length-1]}else x=x[ge]});let b=Wo(w[w.length-1]),U=N(w.join("."),h.arrays),M=Array.isArray(T),J=i["duplicate-arguments-array"];if(!J&&N(b,h.nargs)){if(J=!0,!he(x[b])&&h.nargs[b]===1||Array.isArray(x[b])&&x[b].length===h.nargs[b])x[b]=void 0}if(T===Ns())x[b]=Ns(x[b]);else if(Array.isArray(x[b]))if(J&&U&&M)x[b]=i["flatten-duplicate-arrays"]?x[b].concat(T):(Array.isArray(x[b][0])?x[b]:[x[b]]).concat([T]);else if(!J&&Boolean(U)===Boolean(M))x[b]=T;else x[b]=x[b].concat([T]);else if(x[b]===void 0&&U)x[b]=M?T:[T];else if(J&&!(x[b]===void 0||N(b,h.counts)||N(b,h.bools)))x[b]=[x[b],T];else x[b]=T}function ee(...D){D.forEach(function(w){Object.keys(w||{}).forEach(function(T){if(h.aliases[T])return;h.aliases[T]=[].concat(o[T]||[]),h.aliases[T].concat(T).forEach(function(x){if(/-/.test(x)&&i["camel-case-expansion"]){let b=gt(x);if(b!==T&&h.aliases[T].indexOf(b)===-1)h.aliases[T].push(b),d[b]=!0}}),h.aliases[T].concat(T).forEach(function(x){if(x.length>1&&/[A-Z]/.test(x)&&i["camel-case-expansion"]){let b=On(x,"-");if(b!==T&&h.aliases[T].indexOf(b)===-1)h.aliases[T].push(b),d[b]=!0}}),h.aliases[T].forEach(function(x){h.aliases[x]=[T].concat(h.aliases[T].filter(function(b){return x!==b}))})})})}function N(D,w){let T=[].concat(h.aliases[D]||[],D),x=Object.keys(w),b=T.find((U)=>x.includes(U));return b?w[b]:!1}function we(D){let w=Object.keys(h);return[].concat(w.map((x)=>h[x])).some(function(x){return Array.isArray(x)?x.includes(D):x[D]})}function Wt(D,...w){return[].concat(...w).some(function(x){let b=D.match(x);return b&&we(b[1])})}function z(D){if(D.match(y)||!D.match(/^-[^-]+/))return!1;let w=!0,T,x=D.slice(1).split("");for(let b=0;b<x.length;b++){if(T=D.slice(b+2),!we(x[b])){w=!1;break}if(x[b+1]&&x[b+1]==="="||T==="-"||/[A-Za-z]/.test(x[b])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(T)||x[b+1]&&x[b+1].match(/\W/))break}return w}function se(D){return i["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!Wt(D,/^-+([^=]+?)=[\s\S]*$/,E,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}function Z(D){if(!N(D,h.bools)&&!N(D,h.counts)&&`${D}`in a)return a[D];else return ye(ue(D))}function ye(D){return{[Te.BOOLEAN]:!0,[Te.STRING]:"",[Te.NUMBER]:void 0,[Te.ARRAY]:[]}[D]}function ue(D){let w=Te.BOOLEAN;if(N(D,h.strings))w=Te.STRING;else if(N(D,h.numbers))w=Te.NUMBER;else if(N(D,h.bools))w=Te.BOOLEAN;else if(N(D,h.arrays))w=Te.ARRAY;return w}function he(D){return D===void 0}function As(){Object.keys(h.counts).find((D)=>{if(N(D,h.arrays))return F=Error(m("Invalid configuration: %s, opts.count excludes opts.array.",D)),!0;else if(N(D,h.nargs))return F=Error(m("Invalid configuration: %s, opts.count excludes opts.narg.",D)),!0;return!1})}return{aliases:Object.assign({},h.aliases),argv:Object.assign(B,k),configuration:i,defaulted:Object.assign({},p),error:F,newAliases:Object.assign({},d)}}}function zu(e){let t=[],n=Object.create(null),r=!0;Object.keys(e).forEach(function(s){t.push([].concat(e[s],s))});while(r){r=!1;for(let s=0;s<t.length;s++)for(let o=s+1;o<t.length;o++)if(t[s].filter(function(a){return t[o].indexOf(a)!==-1}).length){t[s]=t[s].concat(t[o]),t.splice(o,1),r=!0;break}}return t.forEach(function(s){s=s.filter(function(i,a,c){return c.indexOf(i)===a});let o=s.pop();if(o!==void 0&&typeof o==="string")n[o]=s}),n}function Ns(e){return e!==void 0?e+1:1}function Wo(e){if(e==="__proto__")return"___proto___";return e}function Hu(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 Gu}from"fs";import{createRequire as Uo}from"node:module";var js,Ls,Ws,Ko=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):20,Jo=(Ls=(js=process===null||process===void 0?void 0:process.versions)===null||js===void 0?void 0:js.node)!==null&&Ls!==void 0?Ls:(Ws=process===null||process===void 0?void 0:process.version)===null||Ws===void 0?void 0:Ws.slice(1);if(Jo){if(Number(Jo.match(/^([^.]+)/)[1])<Ko)throw Error(`yargs parser supports a minimum Node.js version of ${Ko}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`)}var Vu=process?process.env:{},zo=Uo?Uo(import.meta.url):void 0,Ho=new vs({cwd:process.cwd,env:()=>Vu,format:qu,normalize:Yu,resolve:Xu,require:(e)=>{if(typeof zo<"u")return zo(e);else if(e.match(/\.json$/))return JSON.parse(Gu(e,"utf8"));else throw Error("only .json config files are supported in ESM")}}),tn=function(t,n){return Ho.parse(t.slice(),n).argv};tn.detailed=function(e,t){return Ho.parse(e.slice(),t)};tn.camelCase=gt;tn.decamelize=On;tn.looksLikeNumber=In;var Us=tn;import{basename as ul,dirname as ll,extname as fl,relative as dl,resolve as ti,join as hl}from"path";function qo(){if(Zu())return 0;return 1}function Zu(){return Qu()&&!process.defaultApp}function Qu(){return!!process.versions.electron}function Ks(e){return e.slice(qo()+1)}function Yo(){return process.argv[qo()]}import{readFileSync as el,statSync as tl,writeFile as nl}from"fs";import{format as sl}from"util";import{resolve as rl}from"path";var Xo={fs:{readFileSync:el,writeFile:nl},format:sl,resolve:rl,exists:(e)=>{try{return tl(e).isFile()}catch(t){return!1}}};var Ue;class Go{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 Ue.format.apply(Ue.format,[this.cache[this.locale][t]||t].concat(e))}__n(){let e=Array.prototype.slice.call(arguments),t=e.shift(),n=e.shift(),r=e.shift(),s=function(){};if(typeof e[e.length-1]==="function")s=e.pop();if(!this.cache[this.locale])this._readLocaleFile();let o=r===1?t:n;if(this.cache[this.locale][t])o=this.cache[this.locale][t][r===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 i=[o];if(~o.indexOf("%d"))i.push(r);return Ue.format.apply(Ue.format,i.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(r,s){let o=t[s+1];if(n+=r,typeof o<"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],{directory:n,locale:r,cb:s}=t,o=this._resolveLocaleFile(n,r),i=JSON.stringify(this.cache[r],null,2);Ue.fs.writeFile(o,i,"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(Ue.fs.readFileSync)e=JSON.parse(Ue.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=Ue.resolve(e,"./",t+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(n)&&~t.lastIndexOf("_")){let r=Ue.resolve(e,"./",t.split("_")[0]+".json");if(this._fileExistsSync(r))n=r}return n}_fileExistsSync(e){return Ue.exists(e)}}function Vo(e,t){Ue=t;let n=new Go(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 ol=(e)=>Vo(e,Xo),Zo=ol;var si=co(ei(),1);import{createRequire as pl}from"node:module";import{readFileSync as gl,readdirSync as ml}from"node:fs";var Js=ni(import.meta.url),Dl=Js.substring(0,Js.lastIndexOf("node_modules")),yl=pl(import.meta.url),zs={assert:{notStrictEqual:il,strictEqual:al},cliui:Ms,findUp:Bs,getEnv:(e)=>process.env[e],inspect:cl,getProcessArgvBin:Yo,mainFilename:Dl||process.cwd(),Parser:Us,path:{basename:ul,dirname:ll,extname:fl,relative:dl,resolve:ti,join:hl},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:gl,readdirSync:ml,require:yl,getCallerFile:()=>{let e=si.default(3);return e.match(/^file:\/\//)?ni(e):e},stringWidth:We,y18n:Zo({directory:ti(Js,"../../../locales"),updateFiles:!1})};function Ce(e,t,n,r){n.assert.notStrictEqual(e,t,r)}function Hs(e,t){t.assert.strictEqual(typeof e,"string")}function Ut(e){return Object.keys(e)}function re(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+(?![^[]*]|[^<]*>)/),r=/\.*[\][<>]/g,s=n.shift();if(!s)throw Error(`No command found in: ${e}`);let o={cmd:s.replace(r,""),demanded:[],optional:[]};return n.forEach((i,a)=>{let c=!1;if(i=i.replace(/\s/g,""),/\.+[\]>]/.test(i)&&a===n.length-1)c=!0;if(/^\[/.test(i))o.optional.push({cmd:i.replace(r,"").split("|"),variadic:c});else o.demanded.push({cmd:i.replace(r,"").split("|"),variadic:c})}),o}var bl=["first","second","third","fourth","fifth","sixth"];function v(e,t,n){function r(){return typeof e==="object"?[{demanded:[],optional:[]},e,t]:[st(`cmd ${e}`),t,n]}try{let s=0,[o,i,a]=r(),c=[].slice.call(i);while(c.length&&c[c.length-1]===void 0)c.pop();let u=a||c.length;if(u<o.demanded.length)throw new le(`Not enough arguments provided. Expected ${o.demanded.length} but received ${c.length}.`);let f=o.demanded.length+o.optional.length;if(u>f)throw new le(`Too many arguments provided. Expected max ${f} but received ${u}.`);o.demanded.forEach((l)=>{let d=c.shift(),p=ri(d);if(l.cmd.filter((h)=>h===p||h==="*").length===0)oi(p,l.cmd,s);s+=1}),o.optional.forEach((l)=>{if(c.length===0)return;let d=c.shift(),p=ri(d);if(l.cmd.filter((h)=>h===p||h==="*").length===0)oi(p,l.cmd,s);s+=1})}catch(s){console.warn(s.stack)}}function ri(e){if(Array.isArray(e))return"array";else if(e===null)return"null";return typeof e}function oi(e,t,n){throw new le(`Invalid ${bl[n]||"manyith"} argument. Expected ${t.join(" or ")} but received ${e}.`)}class qs{constructor(e){this.globalMiddleware=[],this.frozens=[],this.yargs=e}addMiddleware(e,t,n=!0,r=!1){if(v("<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 o=e[s];o.applyBeforeValidation=t,o.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=r,this.globalMiddleware.push(e)}return this.yargs}addCoerceMiddleware(e,t){let n=this.yargs.getAliases();return this.globalMiddleware=this.globalMiddleware.filter((r)=>{let s=[...n[t]||[],t];if(!r.option)return!0;else return!s.includes(r.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 ii(e){if(!e)return[];return e.map((t)=>(t.applyBeforeValidation=!1,t))}function mt(e,t,n,r){return n.reduce((s,o)=>{if(o.applyBeforeValidation!==r)return s;if(o.mutates){if(o.applied)return s;o.applied=!0}if(re(s))return s.then((i)=>Promise.all([i,o(i,t)])).then(([i,a])=>Object.assign(i,a));else{let i=o(s,t);return re(i)?i.then((a)=>Object.assign(s,a)):Object.assign(s,i)}},e)}function Dt(e,t,n=(r)=>{throw r}){try{let r=wl(e)?e():e;return re(r)?r.then((s)=>t(s)):t(r)}catch(r){return n(r)}}function wl(e){return typeof e==="function"}var Kt=/(^\*)|(^\$0)/;class ci{constructor(e,t,n,r){this.requireCache=new Set,this.handlers={},this.aliasMap={},this.frozens=[],this.shim=r,this.usage=e,this.globalMiddleware=n,this.validation=t}addDirectory(e,t,n,r){r=r||{},this.requireCache.add(n);let s=this.shim.path.resolve(this.shim.path.dirname(n),e),o=this.shim.readdirSync(s,{recursive:r.recurse?!0:!1});if(!Array.isArray(r.extensions))r.extensions=["js"];let i=typeof r.visit==="function"?r.visit:(a)=>a;for(let a of o){let c=a.toString();if(r.exclude){let f=!1;if(typeof r.exclude==="function")f=r.exclude(c);else f=r.exclude.test(c);if(f)continue}if(r.include){let f=!1;if(typeof r.include==="function")f=r.include(c);else f=r.include.test(c);if(!f)continue}let u=!1;for(let f of r.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(i(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,r,s,o){let i=[],a=ii(s);if(r=r||(()=>{}),Array.isArray(e))if(Fl(e))[e,...i]=e;else for(let c of e)this.addHandler(c);else if(El(e)){let c=Array.isArray(e.command)||typeof e.command==="string"?e.command:null;if(c===null)throw Error(`No command name given for module: ${this.shim.inspect(e)}`);if(e.aliases)c=[].concat(c).concat(e.aliases);this.addHandler(c,this.extractDesc(e),e.builder,e.handler,e.middlewares,e.deprecated);return}else if(ai(n)){this.addHandler([e].concat(i),t,n.builder,n.handler,n.middlewares,n.deprecated);return}if(typeof e==="string"){let c=st(e);i=i.map((l)=>st(l).cmd);let u=!1,f=[c.cmd].concat(i).filter((l)=>{if(Kt.test(l))return u=!0,!1;return!0});if(f.length===0&&u)f.push("$0");if(u)c.cmd=f[0],i=f.slice(1),e=e.replace(Kt,c.cmd);if(i.forEach((l)=>{this.aliasMap[l]=c.cmd}),t!==!1)this.usage.command(e,t,u,i,o);if(this.handlers[c.cmd]={original:e,description:t,handler:r,builder:n||{},middlewares:a,deprecated:o,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,r,s,o){let i=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(i.original);let f=this.applyBuilderUpdateUsageAndParse(u,i,t,n.aliases,c,r,s,o);return re(f)?f.then((l)=>this.applyMiddlewareAndGetResult(u,i,l.innerArgv,a,s,l.aliases,t)):this.applyMiddlewareAndGetResult(u,i,f.innerArgv,a,s,f.aliases,t)}applyBuilderUpdateUsageAndParse(e,t,n,r,s,o,i,a){let c=t.builder,u=n;if(Tn(c)){n.getInternalMethods().getUsageInstance().freeze();let f=c(n.getInternalMethods().reset(r),a);if(re(f))return f.then((l)=>(u=li(l)?l:n,this.parseAndUpdateUsage(e,t,u,s,o,i)))}else if(Cl(c))n.getInternalMethods().getUsageInstance().freeze(),u=n.getInternalMethods().reset(r),Object.keys(t.builder).forEach((f)=>{u.option(f,c[f])});return this.parseAndUpdateUsage(e,t,u,s,o,i)}parseAndUpdateUsage(e,t,n,r,s,o){if(e)n.getInternalMethods().getUsageInstance().unfreeze(!0);if(this.shouldUpdateUsage(n))n.getInternalMethods().getUsageInstance().usage(this.usageFromParentCommandsCommandHandler(r,t),t.description);let i=n.getInternalMethods().runYargsParserAndExecuteCommands(null,void 0,!0,s,o);return re(i)?i.then((a)=>({aliases:n.parsed.aliases,innerArgv:a})):{aliases:n.parsed.aliases,innerArgv:i}}shouldUpdateUsage(e){return!e.getInternalMethods().getUsageInstance().getUsageDisabled()&&e.getInternalMethods().getUsageInstance().getUsage().length===0}usageFromParentCommandsCommandHandler(e,t){let n=Kt.test(t.original)?t.original.replace(Kt,"").trim():t.original,r=e.filter((s)=>!Kt.test(s));return r.push(n),`$0 ${r.join(" ")}`}handleValidationAndGetResult(e,t,n,r,s,o,i,a){if(!o.getInternalMethods().getHasOutput()){let c=o.getInternalMethods().runValidation(s,a,o.parsed.error,e);n=Dt(n,(u)=>(c(u),u))}if(t.handler&&!o.getInternalMethods().getHasOutput()){o.getInternalMethods().setHasOutput();let c=!!o.getOptions().configuration["populate--"];if(o.getInternalMethods().postProcess(n,c,!1,!1),n=mt(n,o,i,!1),n=Dt(n,(u)=>{let f=t.handler(u);return re(f)?f.then(()=>u):u}),!e)o.getInternalMethods().getUsageInstance().cacheHelpMessage();if(re(n)&&!o.getInternalMethods().hasParseCallback())n.catch((u)=>{try{o.getInternalMethods().getUsageInstance().fail(null,u)}catch(f){}})}if(!e)r.commands.pop(),r.fullCommands.pop();return n}applyMiddlewareAndGetResult(e,t,n,r,s,o,i){let a={};if(s)return n;if(!i.getInternalMethods().getHasOutput())a=this.populatePositionals(t,n,r,i);let c=this.globalMiddleware.getMiddleware().slice(0).concat(t.middlewares),u=mt(n,i,c,!0);return re(u)?u.then((f)=>this.handleValidationAndGetResult(e,t,f,r,o,i,c,a)):this.handleValidationAndGetResult(e,t,u,r,o,i,c,a)}populatePositionals(e,t,n,r){t._=t._.slice(n.commands.length);let s=e.demanded.slice(0),o=e.optional.slice(0),i={};this.validation.positionalCount(s.length,t._.length);while(s.length){let a=s.shift();this.populatePositional(a,t,i)}while(o.length){let a=o.shift();this.populatePositional(a,t,i)}return t._=n.commands.concat(t._.map((a)=>""+a)),this.postProcessPositionals(t,i,this.cmdToParseOptions(e.original),r),i}populatePositional(e,t,n){let r=e.cmd[0];if(e.variadic)n[r]=t._.splice(0).map(String);else if(t._.length)n[r]=[String(t._.shift())]}cmdToParseOptions(e){let t={array:[],default:{},alias:{},demand:{}},n=st(e);return n.demanded.forEach((r)=>{let[s,...o]=r.cmd;if(r.variadic)t.array.push(s),t.default[s]=[];t.alias[s]=o,t.demand[s]=!0}),n.optional.forEach((r)=>{let[s,...o]=r.cmd;if(r.variadic)t.array.push(s),t.default[s]=[];t.alias[s]=o}),t}postProcessPositionals(e,t,n,r){let s=Object.assign({},r.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 o=[];if(Object.keys(t).forEach((c)=>{t[c].map((u)=>{if(s.configuration["unknown-options-as-args"])s.key[c]=!0;o.push(`--${c}`),o.push(u)})}),!o.length)return;let i=Object.assign({},s.configuration,{"populate--":!1}),a=this.shim.Parser.detailed(o,Object.assign({},s,{configuration:i}));if(a.error)r.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(r,u)&&!this.isDefaulted(r,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((r)=>Object.prototype.hasOwnProperty.call(r,t))||n.some((r)=>Object.prototype.hasOwnProperty.call(r,this.shim.Parser.camelCase(t)))}runDefaultBuilderOn(e){if(!this.defaultCommand)return;if(this.shouldUpdateUsage(e)){let n=Kt.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(Tn(t))return t(e,!0);else if(!ai(t))Object.keys(t).forEach((n)=>{e.option(n,t[n])});return}extractDesc({describe:e,description:t,desc:n}){for(let r of[e,t,n]){if(typeof r==="string"||r===!1)return r;Ce(r,!0,this.shim)}return!1}freeze(){this.frozens.push({handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand})}unfreeze(){let e=this.frozens.pop();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 ui(e,t,n,r){return new ci(e,t,n,r)}function ai(e){return typeof e==="object"&&!!e.builder&&typeof e.handler==="function"}function Fl(e){return e.every((t)=>typeof t==="string")}function Tn(e){return typeof e==="function"}function Cl(e){return typeof e==="object"}function El(e){return typeof e==="object"&&!Array.isArray(e)}function rt(e={},t=()=>!0){let n={};return Ut(e).forEach((r)=>{if(t(r,e[r]))n[r]=e[r]}),n}function ot(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 xl(e){return typeof e==="boolean"}function di(e,t){let n=t.y18n.__,r={},s=[];r.failFn=function(C){s.push(C)};let o=null,i=null,a=!0;r.showHelpOnFail=function(C=!0,S){let[O,W]=typeof C==="string"?[!0,C]:[C,S];if(e.getInternalMethods().isGlobalContext())i=W;return o=W,a=O,r};let c=!1;r.fail=function(C,S){let O=e.getInternalMethods().getLoggerInstance();if(s.length)for(let W=s.length-1;W>=0;--W){let G=s[W];if(xl(G)){if(S)throw S;else if(C)throw Error(C)}else G(C,S,r)}else{if(e.getExitProcess())ot(!0);if(!c){if(c=!0,a)e.showHelp("error"),O.error();if(C||S)O.error(C||S);let W=o||i;if(W){if(C||S)O.error("");O.error(W)}}if(S=S||new le(C),e.getExitProcess())return e.exit(1);else if(e.getInternalMethods().hasParseCallback())return e.exit(1,S);else throw S}};let u=[],f=!1;r.usage=(_,C)=>{if(_===null)return f=!0,u=[],r;return f=!1,u.push([_,C||""]),r},r.getUsage=()=>u,r.getUsageDisabled=()=>f,r.getPositionalGroupName=()=>n("Positionals:");let l=[];r.example=(_,C)=>{l.push([_,C||""])};let d=[];r.command=function(C,S,O,W,G=!1){if(O)d=d.map((q)=>(q[2]=!1,q));d.push([C,S||"",O,W,G])},r.getCommands=()=>d;let p={};r.describe=function(C,S){if(Array.isArray(C))C.forEach((O)=>{r.describe(O,S)});else if(typeof C==="object")Object.keys(C).forEach((O)=>{r.describe(O,C[O])});else p[C]=S},r.getDescriptions=()=>p;let m=[];r.epilog=(_)=>{m.push(_)};let h=!1,y;r.wrap=(_)=>{h=!0,y=_},r.getWrap=()=>{if(t.getEnv("YARGS_DISABLE_WRAP"))return null;if(!h)y=V(),h=!0;return y};let E="__yargsString__:";r.deferY18nLookup=(_)=>E+_,r.help=function(){if(k)return k;A();let C=e.customScriptName?e.$0:t.path.basename(e.$0),S=e.getDemandedOptions(),O=e.getDemandedCommands(),W=e.getDeprecatedOptions(),G=e.getGroups(),q=e.getOptions(),ae=[];ae=ae.concat(Object.keys(p)),ae=ae.concat(Object.keys(S)),ae=ae.concat(Object.keys(O)),ae=ae.concat(Object.keys(q.default)),ae=ae.filter(I),ae=Object.keys(ae.reduce((z,se)=>{if(se!=="_")z[se]=!0;return z},{}));let Ie=r.getWrap(),te=t.cliui({width:Ie,wrap:!!Ie});if(!f){if(u.length)u.forEach((z)=>{if(te.div({text:`${z[0].replace(/\$0/g,C)}`}),z[1])te.div({text:`${z[1]}`,padding:[1,0,0,0]})}),te.div();else if(d.length){let z=null;if(O._)z=`${C} <${n("command")}>
15
15
  `;else z=`${C} [${n("command")}]
16
- `;te.div(`${z}`)}}if(d.length>1||d.length===1&&!d[0][2]){te.div(n("Commands:"));let z=e.getInternalMethods().getContext(),se=z.commands.length?`${z.commands.join(" ")} `:"";if(e.getInternalMethods().getParserConfiguration()["sort-commands"]===!0)d=d.sort((Z,ye)=>Z[0].localeCompare(ye[0]));let de=C?`${C} `:"";d.forEach((Z)=>{let ye=`${de}${se}${Z[0].replace(/^\$0 ?/,"")}`;te.span({text:ye,padding:[0,2,0,2],width:F(d,Ie,`${C}${se}`)+4},{text:Z[1]});let ue=[];if(Z[2])ue.push(`[${n("default")}]`);if(Z[3]&&Z[3].length)ue.push(`[${n("aliases:")} ${Z[3].join(", ")}]`);if(Z[4])if(typeof Z[4]==="string")ue.push(`[${n("deprecated: %s",Z[4])}]`);else ue.push(`[${n("deprecated")}]`);if(ue.length)te.div({text:ue.join(" "),padding:[0,0,0,2],align:"right"});else te.div()}),te.div()}let ke=(Object.keys(q.alias)||[]).concat(Object.keys(e.parsed.newAliases)||[]);ae=ae.filter((z)=>!e.parsed.newAliases[z]&&ke.every((se)=>(q.alias[se]||[]).indexOf(z)===-1));let Q=n("Options:");if(!G[Q])G[Q]=[];B(ae,q.alias,G,Q);let N=(z)=>/^--/.test(Tn(z)),be=Object.keys(G).filter((z)=>G[z].length>0).map((z)=>{let se=G[z].filter(I).map((de)=>{if(ke.includes(de))return de;for(let Z=0,ye;(ye=ke[Z])!==void 0;Z++)if((q.alias[ye]||[]).includes(de))return ye;return de});return{groupName:z,normalizedKeys:se}}).filter(({normalizedKeys:z})=>z.length>0).map(({groupName:z,normalizedKeys:se})=>{let de=se.reduce((Z,ye)=>(Z[ye]=[ye].concat(q.alias[ye]||[]).map((ue)=>{if(z===r.getPositionalGroupName())return ue;else return(/^[0-9]$/.test(ue)?q.boolean.includes(ye)?"-":"--":ue.length>1?"--":"-")+ue}).sort((ue,pe)=>N(ue)===N(pe)?0:N(ue)?1:-1).join(", "),Z),{});return{groupName:z,normalizedKeys:se,switches:de}});if(be.filter(({groupName:z})=>z!==r.getPositionalGroupName()).some(({normalizedKeys:z,switches:se})=>!z.every((de)=>N(se[de]))))be.filter(({groupName:z})=>z!==r.getPositionalGroupName()).forEach(({normalizedKeys:z,switches:se})=>{z.forEach((de)=>{if(N(se[de]))se[de]=El(se[de],4)})});if(be.forEach(({groupName:z,normalizedKeys:se,switches:de})=>{te.div(z),se.forEach((Z)=>{let ye=de[Z],ue=p[Z]||"",pe=null;if(ue.includes(E))ue=n(ue.substring(E.length));if(q.boolean.includes(Z))pe=`[${n("boolean")}]`;if(q.count.includes(Z))pe=`[${n("count")}]`;if(q.string.includes(Z))pe=`[${n("string")}]`;if(q.normalize.includes(Z))pe=`[${n("string")}]`;if(q.array.includes(Z))pe=`[${n("array")}]`;if(q.number.includes(Z))pe=`[${n("number")}]`;let Ss=(T)=>typeof T==="string"?`[${n("deprecated: %s",T)}]`:`[${n("deprecated")}]`,D=[Z in W?Ss(W[Z]):null,pe,Z in S?`[${n("required")}]`:null,q.choices&&q.choices[Z]?`[${n("choices:")} ${r.stringifiedValues(q.choices[Z])}]`:null,R(q.default[Z],q.defaultDescription[Z])].filter(Boolean).join(" ");te.span({text:Tn(ye),padding:[0,2,0,2+uo(ye)],width:F(de,Ie)+4},ue);let b=e.getInternalMethods().getUsageConfiguration()["hide-types"]===!0;if(D&&!b)te.div({text:D,padding:[0,0,0,2],align:"right"});else te.div()}),te.div()}),l.length)te.div(n("Examples:")),l.forEach((z)=>{z[0]=z[0].replace(/\$0/g,C)}),l.forEach((z)=>{if(z[1]==="")te.div({text:z[0],padding:[0,2,0,2]});else te.div({text:z[0],padding:[0,2,0,2],width:F(l,Ie)+4},{text:z[1]})}),te.div();if(m.length>0){let z=m.map((se)=>se.replace(/\$0/g,C)).join(`
16
+ `;te.div(`${z}`)}}if(d.length>1||d.length===1&&!d[0][2]){te.div(n("Commands:"));let z=e.getInternalMethods().getContext(),se=z.commands.length?`${z.commands.join(" ")} `:"";if(e.getInternalMethods().getParserConfiguration()["sort-commands"]===!0)d=d.sort((Z,ye)=>Z[0].localeCompare(ye[0]));let de=C?`${C} `:"";d.forEach((Z)=>{let ye=`${de}${se}${Z[0].replace(/^\$0 ?/,"")}`;te.span({text:ye,padding:[0,2,0,2],width:F(d,Ie,`${C}${se}`)+4},{text:Z[1]});let ue=[];if(Z[2])ue.push(`[${n("default")}]`);if(Z[3]&&Z[3].length)ue.push(`[${n("aliases:")} ${Z[3].join(", ")}]`);if(Z[4])if(typeof Z[4]==="string")ue.push(`[${n("deprecated: %s",Z[4])}]`);else ue.push(`[${n("deprecated")}]`);if(ue.length)te.div({text:ue.join(" "),padding:[0,0,0,2],align:"right"});else te.div()}),te.div()}let ke=(Object.keys(q.alias)||[]).concat(Object.keys(e.parsed.newAliases)||[]);ae=ae.filter((z)=>!e.parsed.newAliases[z]&&ke.every((se)=>(q.alias[se]||[]).indexOf(z)===-1));let ee=n("Options:");if(!G[ee])G[ee]=[];B(ae,q.alias,G,ee);let N=(z)=>/^--/.test(Pn(z)),we=Object.keys(G).filter((z)=>G[z].length>0).map((z)=>{let se=G[z].filter(I).map((de)=>{if(ke.includes(de))return de;for(let Z=0,ye;(ye=ke[Z])!==void 0;Z++)if((q.alias[ye]||[]).includes(de))return ye;return de});return{groupName:z,normalizedKeys:se}}).filter(({normalizedKeys:z})=>z.length>0).map(({groupName:z,normalizedKeys:se})=>{let de=se.reduce((Z,ye)=>(Z[ye]=[ye].concat(q.alias[ye]||[]).map((ue)=>{if(z===r.getPositionalGroupName())return ue;else return(/^[0-9]$/.test(ue)?q.boolean.includes(ye)?"-":"--":ue.length>1?"--":"-")+ue}).sort((ue,he)=>N(ue)===N(he)?0:N(ue)?1:-1).join(", "),Z),{});return{groupName:z,normalizedKeys:se,switches:de}});if(we.filter(({groupName:z})=>z!==r.getPositionalGroupName()).some(({normalizedKeys:z,switches:se})=>!z.every((de)=>N(se[de]))))we.filter(({groupName:z})=>z!==r.getPositionalGroupName()).forEach(({normalizedKeys:z,switches:se})=>{z.forEach((de)=>{if(N(se[de]))se[de]=_l(se[de],4)})});if(we.forEach(({groupName:z,normalizedKeys:se,switches:de})=>{te.div(z),se.forEach((Z)=>{let ye=de[Z],ue=p[Z]||"",he=null;if(ue.includes(E))ue=n(ue.substring(E.length));if(q.boolean.includes(Z))he=`[${n("boolean")}]`;if(q.count.includes(Z))he=`[${n("count")}]`;if(q.string.includes(Z))he=`[${n("string")}]`;if(q.normalize.includes(Z))he=`[${n("string")}]`;if(q.array.includes(Z))he=`[${n("array")}]`;if(q.number.includes(Z))he=`[${n("number")}]`;let As=(T)=>typeof T==="string"?`[${n("deprecated: %s",T)}]`:`[${n("deprecated")}]`,D=[Z in W?As(W[Z]):null,he,Z in S?`[${n("required")}]`:null,q.choices&&q.choices[Z]?`[${n("choices:")} ${r.stringifiedValues(q.choices[Z])}]`:null,R(q.default[Z],q.defaultDescription[Z])].filter(Boolean).join(" ");te.span({text:Pn(ye),padding:[0,2,0,2+fi(ye)],width:F(de,Ie)+4},ue);let w=e.getInternalMethods().getUsageConfiguration()["hide-types"]===!0;if(D&&!w)te.div({text:D,padding:[0,0,0,2],align:"right"});else te.div()}),te.div()}),l.length)te.div(n("Examples:")),l.forEach((z)=>{z[0]=z[0].replace(/\$0/g,C)}),l.forEach((z)=>{if(z[1]==="")te.div({text:z[0],padding:[0,2,0,2]});else te.div({text:z[0],padding:[0,2,0,2],width:F(l,Ie)+4},{text:z[1]})}),te.div();if(m.length>0){let z=m.map((se)=>se.replace(/\$0/g,C)).join(`
17
17
  `);te.div(`${z}
18
- `)}return te.toString().replace(/\s*$/,"")};function F(k,C,S){let O=0;if(!Array.isArray(k))k=Object.values(k).map((W)=>[W]);if(k.forEach((W)=>{O=Math.max(t.stringWidth(S?`${S} ${Tn(W[0])}`:Tn(W[0]))+uo(W[0]),O)}),C)O=Math.min(O,parseInt((C*0.5).toString(),10));return O}function A(){let k=e.getDemandedOptions(),C=e.getOptions();(Object.keys(C.alias)||[]).forEach((S)=>{C.alias[S].forEach((O)=>{if(p[O])r.describe(S,p[O]);if(O in k)e.demandOption(S,k[O]);if(C.boolean.includes(O))e.boolean(S);if(C.count.includes(O))e.count(S);if(C.string.includes(O))e.string(S);if(C.normalize.includes(O))e.normalize(S);if(C.array.includes(O))e.array(S);if(C.number.includes(O))e.number(S)})})}let _;r.cacheHelpMessage=function(){_=this.help()},r.clearCachedHelpMessage=function(){_=void 0},r.hasCachedHelpMessage=function(){return!!_};function B(k,C,S,O){let W=[],G=null;return Object.keys(S).forEach((q)=>{W=W.concat(S[q])}),k.forEach((q)=>{if(G=[q].concat(C[q]),!G.some((ae)=>W.indexOf(ae)!==-1))S[O].push(q)}),W}function I(k){return e.getOptions().hiddenOptions.indexOf(k)<0||e.parsed.argv[e.getOptions().showHiddenOpt]}r.showHelp=(k)=>{let C=e.getInternalMethods().getLoggerInstance();if(!k)k="error";(typeof k==="function"?k:C[k])(r.help())},r.functionDescription=(k)=>["(",k.name?t.Parser.decamelize(k.name,"-"):n("generated-value"),")"].join(""),r.stringifiedValues=function(C,S){let O="",W=S||", ",G=[].concat(C);if(!C||!G.length)return O;return G.forEach((q)=>{if(O.length)O+=W;O+=JSON.stringify(q)}),O};function R(k,C){let S=`[${n("default:")} `;if(k===void 0&&!C)return null;if(C)S+=C;else switch(typeof k){case"string":S+=`"${k}"`;break;case"object":S+=JSON.stringify(k);break;default:S+=k}return`${S}]`}function V(){if(t.process.stdColumns)return Math.min(80,t.process.stdColumns);else return 80}let L=null;r.version=(k)=>{L=k},r.showVersion=(k)=>{let C=e.getInternalMethods().getLoggerInstance();if(!k)k="error";(typeof k==="function"?k:C[k])(L)},r.reset=function(C){return i=null,c=!1,u=[],f=!1,m=[],l=[],d=[],p=nt(p,(S)=>!C[S]),r};let ne=[];return r.freeze=function(){ne.push({failMessage:i,failureOutput:c,usages:u,usageDisabled:f,epilogs:m,examples:l,commands:d,descriptions:p})},r.unfreeze=function(C=!1){let S=ne.pop();if(!S)return;if(C)p={...S.descriptions,...p},d=[...S.commands,...d],u=[...S.usages,...u],l=[...S.examples,...l],m=[...S.epilogs,...m];else({failMessage:i,failureOutput:c,usages:u,usageDisabled:f,epilogs:m,examples:l,commands:d,descriptions:p}=S)},r}function qs(e){return typeof e==="object"}function El(e,t){return qs(e)?{text:e.text,indentation:e.indentation+t}:{text:e,indentation:t}}function uo(e){return qs(e)?e.indentation:0}function Tn(e){return qs(e)?e.text:e}var fo=`###-begin-{{app_name}}-completions-###
18
+ `)}return te.toString().replace(/\s*$/,"")};function F(_,C,S){let O=0;if(!Array.isArray(_))_=Object.values(_).map((W)=>[W]);if(_.forEach((W)=>{O=Math.max(t.stringWidth(S?`${S} ${Pn(W[0])}`:Pn(W[0]))+fi(W[0]),O)}),C)O=Math.min(O,parseInt((C*0.5).toString(),10));return O}function A(){let _=e.getDemandedOptions(),C=e.getOptions();(Object.keys(C.alias)||[]).forEach((S)=>{C.alias[S].forEach((O)=>{if(p[O])r.describe(S,p[O]);if(O in _)e.demandOption(S,_[O]);if(C.boolean.includes(O))e.boolean(S);if(C.count.includes(O))e.count(S);if(C.string.includes(O))e.string(S);if(C.normalize.includes(O))e.normalize(S);if(C.array.includes(O))e.array(S);if(C.number.includes(O))e.number(S)})})}let k;r.cacheHelpMessage=function(){k=this.help()},r.clearCachedHelpMessage=function(){k=void 0},r.hasCachedHelpMessage=function(){return!!k};function B(_,C,S,O){let W=[],G=null;return Object.keys(S).forEach((q)=>{W=W.concat(S[q])}),_.forEach((q)=>{if(G=[q].concat(C[q]),!G.some((ae)=>W.indexOf(ae)!==-1))S[O].push(q)}),W}function I(_){return e.getOptions().hiddenOptions.indexOf(_)<0||e.parsed.argv[e.getOptions().showHiddenOpt]}r.showHelp=(_)=>{let C=e.getInternalMethods().getLoggerInstance();if(!_)_="error";(typeof _==="function"?_:C[_])(r.help())},r.functionDescription=(_)=>["(",_.name?t.Parser.decamelize(_.name,"-"):n("generated-value"),")"].join(""),r.stringifiedValues=function(C,S){let O="",W=S||", ",G=[].concat(C);if(!C||!G.length)return O;return G.forEach((q)=>{if(O.length)O+=W;O+=JSON.stringify(q)}),O};function R(_,C){let S=`[${n("default:")} `;if(_===void 0&&!C)return null;if(C)S+=C;else switch(typeof _){case"string":S+=`"${_}"`;break;case"object":S+=JSON.stringify(_);break;default:S+=_}return`${S}]`}function V(){if(t.process.stdColumns)return Math.min(80,t.process.stdColumns);else return 80}let L=null;r.version=(_)=>{L=_},r.showVersion=(_)=>{let C=e.getInternalMethods().getLoggerInstance();if(!_)_="error";(typeof _==="function"?_:C[_])(L)},r.reset=function(C){return o=null,c=!1,u=[],f=!1,m=[],l=[],d=[],p=rt(p,(S)=>!C[S]),r};let ne=[];return r.freeze=function(){ne.push({failMessage:o,failureOutput:c,usages:u,usageDisabled:f,epilogs:m,examples:l,commands:d,descriptions:p})},r.unfreeze=function(C=!1){let S=ne.pop();if(!S)return;if(C)p={...S.descriptions,...p},d=[...S.commands,...d],u=[...S.usages,...u],l=[...S.examples,...l],m=[...S.epilogs,...m];else({failMessage:o,failureOutput:c,usages:u,usageDisabled:f,epilogs:m,examples:l,commands:d,descriptions:p}=S)},r}function Ys(e){return typeof e==="object"}function _l(e,t){return Ys(e)?{text:e.text,indentation:e.indentation+t}:{text:e,indentation:t}}function fi(e){return Ys(e)?e.indentation:0}function Pn(e){return Ys(e)?e.text:e}var hi=`###-begin-{{app_name}}-completions-###
19
19
  #
20
20
  # yargs command completion script
21
21
  #
@@ -44,7 +44,7 @@ _{{app_name}}_yargs_completions()
44
44
  }
45
45
  complete -o bashdefault -o default -F _{{app_name}}_yargs_completions {{app_name}}
46
46
  ###-end-{{app_name}}-completions-###
47
- `,po=`#compdef {{app_name}}
47
+ `,pi=`#compdef {{app_name}}
48
48
  ###-begin-{{app_name}}-completions-###
49
49
  #
50
50
  # yargs command completion script
@@ -71,162 +71,165 @@ else
71
71
  compdef _{{app_name}}_yargs_completions {{app_name}}
72
72
  fi
73
73
  ###-end-{{app_name}}-completions-###
74
- `;class ho{constructor(e,t,n,r){var s,i,o;this.yargs=e,this.usage=t,this.command=n,this.shim=r,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"))||((i=this.shim.getEnv("ZSH_NAME"))===null||i===void 0?void 0:i.includes("zsh")))!==null&&o!==void 0?o:!1}defaultCompletion(e,t,n,r){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(In(c)){this.indexAfterLastReset=o+1;let u=this.yargs.getInternalMethods().reset();return c(u,!0),u.argv}}let i=[];this.commandCompletions(i,e,n),this.optionCompletions(i,e,t,n),this.choicesFromOptionsCompletions(i,e,t,n),this.choicesFromPositionalsCompletions(i,e,t,n),r(null,i)}commandCompletions(e,t,n){let r=this.yargs.getInternalMethods().getContext().commands;if(!n.match(/^-/)&&r[r.length-1]!==n&&!this.previousArgHasChoices(t))this.usage.getCommands().forEach((s)=>{let i=tt(s[0]).cmd;if(t.indexOf(i)===-1)if(!this.zshShell)e.push(i);else{let o=s[1]||"";e.push(i.replace(/:/g,"\\:")+":"+o)}})}optionCompletions(e,t,n,r){if((r.match(/^-/)||r===""&&e.length===0)&&!this.previousArgHasChoices(t)){let s=this.yargs.getOptions(),i=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[];Object.keys(s.key).forEach((o)=>{let a=!!s.configuration["boolean-negation"]&&s.boolean.includes(o);if(!i.includes(o)&&!s.hiddenOptions.includes(o)&&!this.argsContainKey(t,o,a))this.completeOptionKey(o,e,r,a&&!!s.default[o])})}}choicesFromOptionsCompletions(e,t,n,r){if(this.previousArgHasChoices(t)){let s=this.getPreviousArgChoices(t);if(s&&s.length>0)e.push(...s.map((i)=>i.replace(/:/g,"\\:")))}}choicesFromPositionalsCompletions(e,t,n,r){if(r===""&&e.length>0&&this.previousArgHasChoices(t))return;let s=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[],i=Math.max(this.indexAfterLastReset,this.yargs.getInternalMethods().getContext().commands.length+1),o=s[n._.length-i-1];if(!o)return;let a=this.yargs.getOptions().choices[o]||[];for(let c of a)if(c.startsWith(r))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 r=t.replace(/^-+/,""),s=this.yargs.getOptions(),i=[r,...this.yargs.getAliases()[r]||[]],o;for(let a of i)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 r=(s)=>e.indexOf((/^[^0-9]$/.test(s)?"-":"--")+s)!==-1;if(r(t))return!0;if(n&&r(`no-${t}`))return!0;if(this.aliases){for(let s of this.aliases[t])if(r(s))return!0}return!1}completeOptionKey(e,t,n,r){var s,i,o,a;let c=e;if(this.zshShell){let d=this.usage.getDescriptions(),p=(i=(s=this===null||this===void 0?void 0:this.aliases)===null||s===void 0?void 0:s[e])===null||i===void 0?void 0:i.find((y)=>{let E=d[y];return typeof E==="string"&&E.length>0}),m=p?d[p]:void 0,h=(a=(o=d[e])!==null&&o!==void 0?o:m)!==null&&a!==void 0?a:"";c=`${e.replace(/:/g,"\\:")}:${h.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),r)t.push(l+"no-"+c)}customCompletion(e,t,n,r){if(Ce(this.customCompletionFunction,null,this.shim),_l(this.customCompletionFunction)){let s=this.customCompletionFunction(n,t);if(re(s))return s.then((i)=>{this.shim.process.nextTick(()=>{r(null,i)})}).catch((i)=>{this.shim.process.nextTick(()=>{r(i,void 0)})});return r(null,s)}else if(kl(this.customCompletionFunction))return this.customCompletionFunction(n,t,(s=r)=>this.defaultCompletion(e,t,n,s),(s)=>{r(null,s)});else return this.customCompletionFunction(n,t,(s)=>{r(null,s)})}getCompletion(e,t){let n=e.length?e[e.length-1]:"",r=this.yargs.parse(e,!0),s=this.customCompletionFunction?(i)=>this.customCompletion(e,i,n,t):(i)=>this.defaultCompletion(e,i,n,t);return re(r)?r.then(s):s(r)}generateCompletionScript(e,t){let n=this.zshShell?po:fo,r=this.shim.path.basename(e);if(e.match(/\.js$/))e=`./${e}`;return n=n.replace(/{{app_name}}/g,r),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 go(e,t,n,r){return new ho(e,t,n,r)}function _l(e){return e.length<3}function kl(e){return e.length>3}function mo(e,t){if(e.length===0)return t.length;if(t.length===0)return e.length;let n=[],r;for(r=0;r<=t.length;r++)n[r]=[r];let s;for(s=0;s<=e.length;s++)n[0][s]=s;for(r=1;r<=t.length;r++)for(s=1;s<=e.length;s++)if(t.charAt(r-1)===e.charAt(s-1))n[r][s]=n[r-1][s-1];else if(r>1&&s>1&&t.charAt(r-2)===e.charAt(s-1)&&t.charAt(r-1)===e.charAt(s-2))n[r][s]=n[r-2][s-2]+1;else n[r][s]=Math.min(n[r-1][s-1]+1,Math.min(n[r][s-1]+1,n[r-1][s]+1));return n[t.length][e.length]}var Do=["$0","--","_"];function yo(e,t,n){let r=n.y18n.__,s=n.y18n.__n,i={};i.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()))}},i.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+""))},i.requiredArguments=function(l,d){let p=null;for(let m of Object.keys(d))if(!Object.prototype.hasOwnProperty.call(l,m)||typeof l[m]>"u")p=p||{},p[m]=d[m];if(p){let m=[];for(let y of Object.keys(p)){let E=p[y];if(E&&m.indexOf(E)<0)m.push(E)}let h=m.length?`
74
+ `;class gi{constructor(e,t,n,r){var s,o,i;this.yargs=e,this.usage=t,this.command=n,this.shim=r,this.completionKey="get-yargs-completions",this.aliases=null,this.customCompletionFunction=null,this.indexAfterLastReset=0,this.zshShell=(i=((s=this.shim.getEnv("SHELL"))===null||s===void 0?void 0:s.includes("zsh"))||((o=this.shim.getEnv("ZSH_NAME"))===null||o===void 0?void 0:o.includes("zsh")))!==null&&i!==void 0?i:!1}defaultCompletion(e,t,n,r){let s=this.command.getCommandHandlers();for(let i=0,a=e.length;i<a;++i)if(s[e[i]]&&s[e[i]].builder){let c=s[e[i]].builder;if(Tn(c)){this.indexAfterLastReset=i+1;let u=this.yargs.getInternalMethods().reset();return c(u,!0),u.argv}}let o=[];this.commandCompletions(o,e,n),this.optionCompletions(o,e,t,n),this.choicesFromOptionsCompletions(o,e,t,n),this.choicesFromPositionalsCompletions(o,e,t,n),r(null,o)}commandCompletions(e,t,n){let r=this.yargs.getInternalMethods().getContext().commands;if(!n.match(/^-/)&&r[r.length-1]!==n&&!this.previousArgHasChoices(t))this.usage.getCommands().forEach((s)=>{let o=st(s[0]).cmd;if(t.indexOf(o)===-1)if(!this.zshShell)e.push(o);else{let i=s[1]||"";e.push(o.replace(/:/g,"\\:")+":"+i)}})}optionCompletions(e,t,n,r){if((r.match(/^-/)||r===""&&e.length===0)&&!this.previousArgHasChoices(t)){let s=this.yargs.getOptions(),o=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[];Object.keys(s.key).forEach((i)=>{let a=!!s.configuration["boolean-negation"]&&s.boolean.includes(i);if(!o.includes(i)&&!s.hiddenOptions.includes(i)&&!this.argsContainKey(t,i,a))this.completeOptionKey(i,e,r,a&&!!s.default[i])})}}choicesFromOptionsCompletions(e,t,n,r){if(this.previousArgHasChoices(t)){let s=this.getPreviousArgChoices(t);if(s&&s.length>0)e.push(...s.map((o)=>o.replace(/:/g,"\\:")))}}choicesFromPositionalsCompletions(e,t,n,r){if(r===""&&e.length>0&&this.previousArgHasChoices(t))return;let s=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[],o=Math.max(this.indexAfterLastReset,this.yargs.getInternalMethods().getContext().commands.length+1),i=s[n._.length-o-1];if(!i)return;let a=this.yargs.getOptions().choices[i]||[];for(let c of a)if(c.startsWith(r))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 r=t.replace(/^-+/,""),s=this.yargs.getOptions(),o=[r,...this.yargs.getAliases()[r]||[]],i;for(let a of o)if(Object.prototype.hasOwnProperty.call(s.key,a)&&Array.isArray(s.choices[a])){i=s.choices[a];break}if(i)return i.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 r=(s)=>e.indexOf((/^[^0-9]$/.test(s)?"-":"--")+s)!==-1;if(r(t))return!0;if(n&&r(`no-${t}`))return!0;if(this.aliases){for(let s of this.aliases[t])if(r(s))return!0}return!1}completeOptionKey(e,t,n,r){var s,o,i,a;let c=e;if(this.zshShell){let d=this.usage.getDescriptions(),p=(o=(s=this===null||this===void 0?void 0:this.aliases)===null||s===void 0?void 0:s[e])===null||o===void 0?void 0:o.find((y)=>{let E=d[y];return typeof E==="string"&&E.length>0}),m=p?d[p]:void 0,h=(a=(i=d[e])!==null&&i!==void 0?i:m)!==null&&a!==void 0?a:"";c=`${e.replace(/:/g,"\\:")}:${h.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),r)t.push(l+"no-"+c)}customCompletion(e,t,n,r){if(Ce(this.customCompletionFunction,null,this.shim),Sl(this.customCompletionFunction)){let s=this.customCompletionFunction(n,t);if(re(s))return s.then((o)=>{this.shim.process.nextTick(()=>{r(null,o)})}).catch((o)=>{this.shim.process.nextTick(()=>{r(o,void 0)})});return r(null,s)}else if(Al(this.customCompletionFunction))return this.customCompletionFunction(n,t,(s=r)=>this.defaultCompletion(e,t,n,s),(s)=>{r(null,s)});else return this.customCompletionFunction(n,t,(s)=>{r(null,s)})}getCompletion(e,t){let n=e.length?e[e.length-1]:"",r=this.yargs.parse(e,!0),s=this.customCompletionFunction?(o)=>this.customCompletion(e,o,n,t):(o)=>this.defaultCompletion(e,o,n,t);return re(r)?r.then(s):s(r)}generateCompletionScript(e,t){let n=this.zshShell?pi:hi,r=this.shim.path.basename(e);if(e.match(/\.js$/))e=`./${e}`;return n=n.replace(/{{app_name}}/g,r),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 mi(e,t,n,r){return new gi(e,t,n,r)}function Sl(e){return e.length<3}function Al(e){return e.length>3}function Di(e,t){if(e.length===0)return t.length;if(t.length===0)return e.length;let n=[],r;for(r=0;r<=t.length;r++)n[r]=[r];let s;for(s=0;s<=e.length;s++)n[0][s]=s;for(r=1;r<=t.length;r++)for(s=1;s<=e.length;s++)if(t.charAt(r-1)===e.charAt(s-1))n[r][s]=n[r-1][s-1];else if(r>1&&s>1&&t.charAt(r-2)===e.charAt(s-1)&&t.charAt(r-1)===e.charAt(s-2))n[r][s]=n[r-2][s-2]+1;else n[r][s]=Math.min(n[r-1][s-1]+1,Math.min(n[r][s-1]+1,n[r-1][s]+1));return n[t.length][e.length]}var yi=["$0","--","_"];function bi(e,t,n){let r=n.y18n.__,s=n.y18n.__n,o={};o.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()))}},o.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+""))},o.requiredArguments=function(l,d){let p=null;for(let m of Object.keys(d))if(!Object.prototype.hasOwnProperty.call(l,m)||typeof l[m]>"u")p=p||{},p[m]=d[m];if(p){let m=[];for(let y of Object.keys(p)){let E=p[y];if(E&&m.indexOf(E)<0)m.push(E)}let h=m.length?`
75
75
  ${m.join(`
76
- `)}`:"";t.fail(s("Missing required argument: %s","Missing required arguments: %s",Object.keys(p).length,Object.keys(p).join(", ")+h))}},i.unknownArguments=function(l,d,p,m,h=!0){var y;let E=e.getInternalMethods().getCommandInstance().getCommands(),F=[],A=e.getInternalMethods().getContext();if(Object.keys(l).forEach((_)=>{if(!Do.includes(_)&&!Object.prototype.hasOwnProperty.call(p,_)&&!Object.prototype.hasOwnProperty.call(e.getInternalMethods().getParseContext(),_)&&!i.isValidAndSomeAliasIsNotNew(_,d))F.push(_)}),h&&(A.commands.length>0||E.length>0||m))l._.slice(A.commands.length).forEach((_)=>{if(!E.includes(""+_))F.push(""+_)});if(h){let B=((y=e.getDemandedCommands()._)===null||y===void 0?void 0:y.max)||0,I=A.commands.length+B;if(I<l._.length)l._.slice(I).forEach((R)=>{if(R=String(R),!A.commands.includes(R)&&!F.includes(R))F.push(R)})}if(F.length)t.fail(s("Unknown argument: %s","Unknown arguments: %s",F.length,F.map((_)=>_.trim()?_:`"${_}"`).join(", ")))},i.unknownCommands=function(l){let d=e.getInternalMethods().getCommandInstance().getCommands(),p=[],m=e.getInternalMethods().getContext();if(m.commands.length>0||d.length>0)l._.slice(m.commands.length).forEach((h)=>{if(!d.includes(""+h))p.push(""+h)});if(p.length>0)return t.fail(s("Unknown command: %s","Unknown commands: %s",p.length,p.join(", "))),!0;else return!1},i.isValidAndSomeAliasIsNotNew=function(l,d){if(!Object.prototype.hasOwnProperty.call(d,l))return!1;let p=e.parsed.newAliases;return[l,...d[l]].some((m)=>!Object.prototype.hasOwnProperty.call(p,m)||!p[l])},i.limitedChoices=function(l){let d=e.getOptions(),p={};if(!Object.keys(d.choices).length)return;Object.keys(l).forEach((y)=>{if(Do.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)p[y]=(p[y]||[]).concat(E)})});let m=Object.keys(p);if(!m.length)return;let h=r("Invalid values:");m.forEach((y)=>{h+=`
77
- ${r("Argument: %s, Given: %s, Choices: %s",y,t.stringifiedValues(p[y]),t.stringifiedValues(d.choices[y]))}`}),t.fail(h)};let o={};i.implies=function(l,d){if(v("<string|object> [array|number|string]",[l,d],arguments.length),typeof l==="object")Object.keys(l).forEach((p)=>{i.implies(p,l[p])});else{if(e.global(l),!o[l])o[l]=[];if(Array.isArray(d))d.forEach((p)=>i.implies(l,p));else Ce(d,void 0,n),o[l].push(d)}},i.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}i.implications=function(l){let d=[];if(Object.keys(o).forEach((p)=>{let m=p;(o[p]||[]).forEach((h)=>{let y=m,E=h;if(y=a(l,y),h=a(l,h),y&&!h)d.push(` ${m} -> ${E}`)})}),d.length){let p=`${r("Implications failed:")}
78
- `;d.forEach((m)=>{p+=m}),t.fail(p)}};let c={};i.conflicts=function(l,d){if(v("<string|object> [array|string]",[l,d],arguments.length),typeof l==="object")Object.keys(l).forEach((p)=>{i.conflicts(p,l[p])});else{if(e.global(l),!c[l])c[l]=[];if(Array.isArray(d))d.forEach((p)=>i.conflicts(l,p));else c[l].push(d)}},i.getConflicting=()=>c,i.conflicting=function(l){if(Object.keys(l).forEach((d)=>{if(c[d])c[d].forEach((p)=>{if(p&&l[d]!==void 0&&l[p]!==void 0)t.fail(r("Arguments %s and %s are mutually exclusive",d,p))})}),e.getInternalMethods().getParserConfiguration()["strip-dashed"])Object.keys(c).forEach((d)=>{c[d].forEach((p)=>{if(p&&l[n.Parser.camelCase(d)]!==void 0&&l[n.Parser.camelCase(p)]!==void 0)t.fail(r("Arguments %s and %s are mutually exclusive",d,p))})})},i.recommendCommands=function(l,d){d=d.sort((y,E)=>E.length-y.length);let m=null,h=1/0;for(let y=0,E;(E=d[y])!==void 0;y++){let F=mo(l,E);if(F<=3&&F<h)h=F,m=E}if(m)t.fail(r("Did you mean %s?",m))},i.reset=function(l){return o=nt(o,(d)=>!l[d]),c=nt(c,(d)=>!l[d]),i};let u=[];return i.freeze=function(){u.push({implied:o,conflicting:c})},i.unfreeze=function(){let l=u.pop();Ce(l,void 0,n),{implied:o,conflicting:c}=l},i}var Ys=[],nn;function sn(e,t,n,r){nn=r;let s={};if(Object.prototype.hasOwnProperty.call(e,"extends")){if(typeof e.extends!=="string")return s;let i=/\.json|\..*rc$/.test(e.extends),o=null;if(!i)try{o=import.meta.resolve(e.extends)}catch(a){return e}else o=Al(t,e.extends);Sl(o),Ys.push(o),s=i?JSON.parse(nn.readFileSync(o,"utf8")):r.require(e.extends),delete e.extends,s=sn(s,nn.path.dirname(o),n,nn)}return Ys=[],n?wo(s,e):Object.assign({},s,e)}function Sl(e){if(Ys.indexOf(e)>-1)throw new le(`Circular extended configurations: '${e}'.`)}function Al(e,t){return nn.path.resolve(e,t)}function wo(e,t){let n={};function r(s){return s&&typeof s==="object"&&!Array.isArray(s)}Object.assign(n,e);for(let s of Object.keys(t))if(r(t[s])&&r(n[s]))n[s]=wo(e[s],t[s]);else n[s]=t[s];return n}var j=function(e,t,n,r,s){if(r==="m")throw TypeError("Private method is not writable");if(r==="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 r==="a"?s.call(e,n):s?s.value=n:t.set(e,n),n},g=function(e,t,n,r){if(n==="a"&&!r)throw TypeError("Private accessor was defined without a getter");if(typeof t==="function"?e!==t||!r:!t.has(e))throw TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?r:n==="a"?r.call(e):r?r.value:t.get(e)},fe,Dt,rn,xe,Ae,Pn,rt,yt,Rn,Pe,Mn,Re,Xe,$e,Me,Bn,wt,me,K,Nn,vn,Oe,bt,Jt,Ft,it,jn,H,Ct,Et,xt,Y,Ln,Ge,ce;function jo(e){return(t=[],n=e.process.cwd(),r)=>{let s=new Lo(t,n,r,e);return Object.defineProperty(s,"argv",{get:()=>s.parse(),enumerable:!0}),s.help(),s.version(),s}}var bo=Symbol("copyDoubleDash"),Fo=Symbol("copyDoubleDash"),Xs=Symbol("deleteFromParserHintObject"),Co=Symbol("emitWarning"),Eo=Symbol("freeze"),xo=Symbol("getDollarZero"),_t=Symbol("getParserConfiguration"),_o=Symbol("getUsageConfiguration"),Gs=Symbol("guessLocale"),ko=Symbol("guessVersion"),So=Symbol("parsePositionalNumbers"),Vs=Symbol("pkgUp"),ot=Symbol("populateParserHintArray"),zt=Symbol("populateParserHintSingleValueDictionary"),Zs=Symbol("populateParserHintArrayDictionary"),Qs=Symbol("populateParserHintDictionary"),er=Symbol("sanitizeKey"),tr=Symbol("setKey"),nr=Symbol("unfreeze"),Ao=Symbol("validateAsync"),$o=Symbol("getCommandInstance"),Oo=Symbol("getContext"),Io=Symbol("getHasOutput"),To=Symbol("getLoggerInstance"),Po=Symbol("getParseContext"),Ro=Symbol("getUsageInstance"),Mo=Symbol("getValidationInstance"),Wn=Symbol("hasParseCallback"),Bo=Symbol("isGlobalContext"),kt=Symbol("postProcess"),No=Symbol("rebase"),sr=Symbol("reset"),on=Symbol("runYargsParserAndExecuteCommands"),rr=Symbol("runValidation"),vo=Symbol("setHasOutput"),St=Symbol("kTrackManuallySetKeys"),$l="en_US";class Lo{constructor(e=[],t,n,r){this.customScriptName=!1,this.parsed=!1,fe.set(this,void 0),Dt.set(this,void 0),rn.set(this,{commands:[],fullCommands:[]}),xe.set(this,null),Ae.set(this,null),Pn.set(this,"show-hidden"),rt.set(this,null),yt.set(this,!0),Rn.set(this,{}),Pe.set(this,!0),Mn.set(this,[]),Re.set(this,void 0),Xe.set(this,{}),$e.set(this,!1),Me.set(this,null),Bn.set(this,!0),wt.set(this,void 0),me.set(this,""),K.set(this,void 0),Nn.set(this,void 0),vn.set(this,{}),Oe.set(this,null),bt.set(this,null),Jt.set(this,{}),Ft.set(this,{}),it.set(this,void 0),jn.set(this,!1),H.set(this,void 0),Ct.set(this,!1),Et.set(this,!1),xt.set(this,!1),Y.set(this,void 0),Ln.set(this,{}),Ge.set(this,null),ce.set(this,void 0),j(this,H,r,"f"),j(this,it,e,"f"),j(this,Dt,t,"f"),j(this,Nn,n,"f"),j(this,Re,new Hs(this),"f"),this.$0=this[xo](),this[sr](),j(this,fe,g(this,fe,"f"),"f"),j(this,Y,g(this,Y,"f"),"f"),j(this,ce,g(this,ce,"f"),"f"),j(this,K,g(this,K,"f"),"f"),g(this,K,"f").showHiddenOpt=g(this,Pn,"f"),j(this,wt,this[Fo](),"f"),g(this,H,"f").y18n.setLocale($l)}addHelpOpt(e,t){if(v("[string|boolean] [string]",[e,t],arguments.length),g(this,Me,"f"))this[Xs](g(this,Me,"f")),j(this,Me,null,"f");if(e===!1&&t===void 0)return this;return j(this,Me,typeof e==="string"?e:"help","f"),this.boolean(g(this,Me,"f")),this.describe(g(this,Me,"f"),t||g(this,Y,"f").deferY18nLookup("Show help")),this}help(e,t){return this.addHelpOpt(e,t)}addShowHiddenOpt(e,t){if(v("[string|boolean] [string]",[e,t],arguments.length),e===!1&&t===void 0)return this;let n=typeof e==="string"?e:g(this,Pn,"f");return this.boolean(n),this.describe(n,t||g(this,Y,"f").deferY18nLookup("Show hidden options")),g(this,K,"f").showHiddenOpt=n,this}showHidden(e,t){return this.addShowHiddenOpt(e,t)}alias(e,t){return v("<object|string|array> [string|array]",[e,t],arguments.length),this[Zs](this.alias.bind(this),"alias",e,t),this}array(e){return v("<array|string>",[e],arguments.length),this[ot]("array",e),this[St](e),this}boolean(e){return v("<array|string>",[e],arguments.length),this[ot]("boolean",e),this[St](e),this}check(e,t){return v("<function> [boolean]",[e,t],arguments.length),this.middleware((n,r)=>mt(()=>e(n,r.getOptions()),(s)=>{if(!s)g(this,Y,"f").fail(g(this,H,"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 v("<object|string|array> [string|array]",[e,t],arguments.length),this[Zs](this.choices.bind(this),"choices",e,t),this}coerce(e,t){if(v("<object|string|array> [function]",[e,t],arguments.length),Array.isArray(e)){if(!t)throw new le("coerce callback must be provided");for(let r of e)this.coerce(r,t);return this}else if(typeof e==="object"){for(let r of Object.keys(e))this.coerce(r,e[r]);return this}if(!t)throw new le("coerce callback must be provided");let n=e;return g(this,K,"f").key[n]=!0,g(this,Re,"f").addCoerceMiddleware((r,s)=>{var i;let o=(i=s.getAliases()[n])!==null&&i!==void 0?i:[],a=[n,...o].filter((c)=>Object.prototype.hasOwnProperty.call(r,c));if(a.length===0)return r;return mt(()=>t(r[a[0]]),(c)=>(a.forEach((u)=>{r[u]=c}),r),(c)=>{throw new le(c.message)})},n),this}conflicts(e,t){return v("<string|object> [string|array]",[e,t],arguments.length),g(this,ce,"f").conflicts(e,t),this}config(e="config",t,n){if(v("[object|string] [string|function] [function]",[e,t,n],arguments.length),typeof e==="object"&&!Array.isArray(e))return e=sn(e,g(this,Dt,"f"),this[_t]()["deep-merge-config"]||!1,g(this,H,"f")),g(this,K,"f").configObjects=(g(this,K,"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((r)=>{g(this,K,"f").config[r]=n||!0}),this}completion(e,t,n){if(v("[string] [string|boolean|function] [function]",[e,t,n],arguments.length),typeof t==="function")n=t,t=void 0;if(j(this,Ae,e||g(this,Ae,"f")||"completion","f"),!t&&t!==!1)t="generate completion script";if(this.command(g(this,Ae,"f"),t),n)g(this,xe,"f").registerFunction(n);return this}command(e,t,n,r,s,i){return v("<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]",[e,t,n,r,s,i],arguments.length),g(this,fe,"f").addHandler(e,t,n,r,s,i),this}commands(e,t,n,r,s,i){return this.command(e,t,n,r,s,i)}commandDir(e,t){v("<string> [object]",[e,t],arguments.length);let n=g(this,Nn,"f")||g(this,H,"f").require;return g(this,fe,"f").addDirectory(e,n,g(this,H,"f").getCallerFile(),t),this}count(e){return v("<array|string>",[e],arguments.length),this[ot]("count",e),this[St](e),this}default(e,t,n){if(v("<object|string|array> [*] [string]",[e,t,n],arguments.length),n)zs(e,g(this,H,"f")),g(this,K,"f").defaultDescription[e]=n;if(typeof t==="function"){if(zs(e,g(this,H,"f")),!g(this,K,"f").defaultDescription[e])g(this,K,"f").defaultDescription[e]=g(this,Y,"f").functionDescription(t);t=t.call()}return this[zt](this.default.bind(this),"default",e,t),this}defaults(e,t,n){return this.default(e,t,n)}demandCommand(e=1,t,n,r){if(v("[number] [number|string] [string|null|undefined] [string|null|undefined]",[e,t,n,r],arguments.length),typeof t!=="number")n=t,t=1/0;return this.global("_",!1),g(this,K,"f").demandedCommands._={min:e,max:t,minMsg:n,maxMsg:r},this}demand(e,t,n){if(Array.isArray(t))t.forEach((r)=>{Ce(n,!0,g(this,H,"f")),this.demandOption(r,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((r)=>{Ce(n,!0,g(this,H,"f")),this.demandOption(r,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 v("<object|string|array> [string]",[e,t],arguments.length),this[zt](this.demandOption.bind(this),"demandedOptions",e,t),this}deprecateOption(e,t){return v("<string> [string|boolean]",[e,t],arguments.length),g(this,K,"f").deprecatedOptions[e]=t,this}describe(e,t){return v("<object|string|array> [string]",[e,t],arguments.length),this[tr](e,!0),g(this,Y,"f").describe(e,t),this}detectLocale(e){return v("<boolean>",[e],arguments.length),j(this,yt,e,"f"),this}env(e){if(v("[string|boolean]",[e],arguments.length),e===!1)delete g(this,K,"f").envPrefix;else g(this,K,"f").envPrefix=e||"";return this}epilogue(e){return v("<string>",[e],arguments.length),g(this,Y,"f").epilog(e),this}epilog(e){return this.epilogue(e)}example(e,t){if(v("<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(j(this,$e,!0,"f"),j(this,rt,t,"f"),g(this,Pe,"f"))g(this,H,"f").process.exit(e)}exitProcess(e=!0){return v("[boolean]",[e],arguments.length),j(this,Pe,e,"f"),this}fail(e){if(v("<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(v("<array> [function]",[e,t],arguments.length),!t)return new Promise((n,r)=>{g(this,xe,"f").getCompletion(e,(s,i)=>{if(s)r(s);else n(i)})});else return g(this,xe,"f").getCompletion(e,t)}getDemandedOptions(){return v([],0),g(this,K,"f").demandedOptions}getDemandedCommands(){return v([],0),g(this,K,"f").demandedCommands}getDeprecatedOptions(){return v([],0),g(this,K,"f").deprecatedOptions}getDetectLocale(){return g(this,yt,"f")}getExitProcess(){return g(this,Pe,"f")}getGroups(){return Object.assign({},g(this,Xe,"f"),g(this,Ft,"f"))}getHelp(){if(j(this,$e,!0,"f"),!g(this,Y,"f").hasCachedHelpMessage()){if(!this.parsed){let t=this[on](g(this,it,"f"),void 0,void 0,0,!0);if(re(t))return t.then(()=>g(this,Y,"f").help())}let e=g(this,fe,"f").runDefaultBuilderOn(this);if(re(e))return e.then(()=>g(this,Y,"f").help())}return Promise.resolve(g(this,Y,"f").help())}getOptions(){return g(this,K,"f")}getStrict(){return g(this,Ct,"f")}getStrictCommands(){return g(this,Et,"f")}getStrictOptions(){return g(this,xt,"f")}global(e,t){if(v("<string|array> [boolean]",[e,t],arguments.length),e=[].concat(e),t!==!1)g(this,K,"f").local=g(this,K,"f").local.filter((n)=>e.indexOf(n)===-1);else e.forEach((n)=>{if(!g(this,K,"f").local.includes(n))g(this,K,"f").local.push(n)});return this}group(e,t){v("<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 r={};return g(this,Xe,"f")[t]=(n||[]).concat(e).filter((s)=>{if(r[s])return!1;return r[s]=!0}),this}hide(e){return v("<string>",[e],arguments.length),g(this,K,"f").hiddenOptions.push(e),this}implies(e,t){return v("<string|object> [number|string|array]",[e,t],arguments.length),g(this,ce,"f").implies(e,t),this}locale(e){if(v("[string]",[e],arguments.length),e===void 0)return this[Gs](),g(this,H,"f").y18n.getLocale();return j(this,yt,!1,"f"),g(this,H,"f").y18n.setLocale(e),this}middleware(e,t,n){return g(this,Re,"f").addMiddleware(e,!!t,n)}nargs(e,t){return v("<string|object|array> [number]",[e,t],arguments.length),this[zt](this.nargs.bind(this),"narg",e,t),this}normalize(e){return v("<array|string>",[e],arguments.length),this[ot]("normalize",e),this}number(e){return v("<array|string>",[e],arguments.length),this[ot]("number",e),this[St](e),this}option(e,t){if(v("<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,Ge,"f")&&(e==="version"||(t===null||t===void 0?void 0:t.alias)==="version"))this[Co](['"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,K,"f").key[e]=!0,t.alias)this.alias(e,t.alias);let n=t.deprecate||t.deprecated;if(n)this.deprecateOption(e,n);let r=t.demand||t.required||t.require;if(r)this.demand(e,r);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,K,"f").defaultDescription[e]=t.defaultDescription;if(t.skipValidation)this.skipValidation(e);let s=t.describe||t.description||t.desc,i=g(this,Y,"f").getDescriptions();if(!Object.prototype.hasOwnProperty.call(i,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(v("[string|array] [function|boolean|object] [function]",[e,t,n],arguments.length),this[Eo](),typeof e>"u")e=g(this,it,"f");if(typeof t==="object")j(this,bt,t,"f"),t=n;if(typeof t==="function")j(this,Oe,t,"f"),t=!1;if(!t)j(this,it,e,"f");if(g(this,Oe,"f"))j(this,Pe,!1,"f");let r=this[on](e,!!t),s=this.parsed;if(g(this,xe,"f").setParsed(this.parsed),re(r))return r.then((i)=>{if(g(this,Oe,"f"))g(this,Oe,"f").call(this,g(this,rt,"f"),i,g(this,me,"f"));return i}).catch((i)=>{if(g(this,Oe,"f"))g(this,Oe,"f")(i,this.parsed.argv,g(this,me,"f"));throw i}).finally(()=>{this[nr](),this.parsed=s});else{if(g(this,Oe,"f"))g(this,Oe,"f").call(this,g(this,rt,"f"),r,g(this,me,"f"));this[nr](),this.parsed=s}return r}parseAsync(e,t,n){let r=this.parse(e,t,n);return!re(r)?Promise.resolve(r):r}parseSync(e,t,n){let r=this.parse(e,t,n);if(re(r))throw new le(".parseSync() must not be used with asynchronous builders, handlers, or middleware");return r}parserConfiguration(e){return v("<object>",[e],arguments.length),j(this,vn,e,"f"),this}pkgConf(e,t){v("<string> [string]",[e,t],arguments.length);let n=null,r=this[Vs](t||g(this,Dt,"f"));if(r[e]&&typeof r[e]==="object")n=sn(r[e],t||g(this,Dt,"f"),this[_t]()["deep-merge-config"]||!1,g(this,H,"f")),g(this,K,"f").configObjects=(g(this,K,"f").configObjects||[]).concat(n);return this}positional(e,t){v("<string> <object>",[e,t],arguments.length);let n=["default","defaultDescription","implies","normalize","choices","conflicts","coerce","type","describe","desc","description","alias"];t=nt(t,(i,o)=>{if(i==="type"&&!["string","number","boolean"].includes(o))return!1;return n.includes(i)});let r=g(this,rn,"f").fullCommands[g(this,rn,"f").fullCommands.length-1],s=r?g(this,fe,"f").cmdToParseOptions(r):{array:[],alias:{},default:{},demand:{}};return Ut(s).forEach((i)=>{let o=s[i];if(Array.isArray(o)){if(o.indexOf(e)!==-1)t[i]=!0}else if(o[e]&&!(i in t))t[i]=o[e]}),this.group(e,g(this,Y,"f").getPositionalGroupName()),this.option(e,t)}recommendCommands(e=!0){return v("[boolean]",[e],arguments.length),j(this,jn,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(v("<array|string|object> [number]",[e],arguments.length),typeof e==="string"&&g(this,K,"f").narg[e])return this;else this[zt](this.requiresArg.bind(this),"narg",e,NaN);return this}showCompletionScript(e,t){return v("[string] [string]",[e,t],arguments.length),e=e||this.$0,g(this,wt,"f").log(g(this,xe,"f").generateCompletionScript(e,t||g(this,Ae,"f")||"completion")),this}showHelp(e){if(v("[string|function]",[e],arguments.length),j(this,$e,!0,"f"),!g(this,Y,"f").hasCachedHelpMessage()){if(!this.parsed){let n=this[on](g(this,it,"f"),void 0,void 0,0,!0);if(re(n))return n.then(()=>{g(this,Y,"f").showHelp(e)}),this}let t=g(this,fe,"f").runDefaultBuilderOn(this);if(re(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 v("[boolean|string] [string]",[e,t],arguments.length),g(this,Y,"f").showHelpOnFail(e,t),this}showVersion(e){return v("[string|function]",[e],arguments.length),g(this,Y,"f").showVersion(e),this}skipValidation(e){return v("<array|string>",[e],arguments.length),this[ot]("skipValidation",e),this}strict(e){return v("[boolean]",[e],arguments.length),j(this,Ct,e!==!1,"f"),this}strictCommands(e){return v("[boolean]",[e],arguments.length),j(this,Et,e!==!1,"f"),this}strictOptions(e){return v("[boolean]",[e],arguments.length),j(this,xt,e!==!1,"f"),this}string(e){return v("<array|string>",[e],arguments.length),this[ot]("string",e),this[St](e),this}terminalWidth(){return v([],0),g(this,H,"f").process.stdColumns}updateLocale(e){return this.updateStrings(e)}updateStrings(e){return v("<object>",[e],arguments.length),j(this,yt,!1,"f"),g(this,H,"f").y18n.updateLocale(e),this}usage(e,t,n,r){if(v("<string|null|undefined> [string|boolean] [function|object] [function]",[e,t,n,r],arguments.length),t!==void 0)if(Ce(e,null,g(this,H,"f")),(e||"").match(/^\$0( |$)/))return this.command(e,t,n,r);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 v("<object>",[e],arguments.length),j(this,Ln,e,"f"),this}version(e,t,n){if(v("[boolean|string] [string] [string]",[e,t,n],arguments.length),g(this,Ge,"f"))this[Xs](g(this,Ge,"f")),g(this,Y,"f").version(void 0),j(this,Ge,null,"f");if(arguments.length===0)n=this[ko](),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 j(this,Ge,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,Ge,"f")),this.describe(g(this,Ge,"f"),t),this}wrap(e){return v("<number|null|undefined>",[e],arguments.length),g(this,Y,"f").wrap(e),this}[(fe=new WeakMap,Dt=new WeakMap,rn=new WeakMap,xe=new WeakMap,Ae=new WeakMap,Pn=new WeakMap,rt=new WeakMap,yt=new WeakMap,Rn=new WeakMap,Pe=new WeakMap,Mn=new WeakMap,Re=new WeakMap,Xe=new WeakMap,$e=new WeakMap,Me=new WeakMap,Bn=new WeakMap,wt=new WeakMap,me=new WeakMap,K=new WeakMap,Nn=new WeakMap,vn=new WeakMap,Oe=new WeakMap,bt=new WeakMap,Jt=new WeakMap,Ft=new WeakMap,it=new WeakMap,jn=new WeakMap,H=new WeakMap,Ct=new WeakMap,Et=new WeakMap,xt=new WeakMap,Y=new WeakMap,Ln=new WeakMap,Ge=new WeakMap,ce=new WeakMap,bo)](e){if(!e._||!e["--"])return e;e._.push.apply(e._,e["--"]);try{delete e["--"]}catch(t){}return e}[Fo](){return{log:(...e)=>{if(!this[Wn]())console.log(...e);if(j(this,$e,!0,"f"),g(this,me,"f").length)j(this,me,g(this,me,"f")+`
80
- `,"f");j(this,me,g(this,me,"f")+e.join(" "),"f")},error:(...e)=>{if(!this[Wn]())console.error(...e);if(j(this,$e,!0,"f"),g(this,me,"f").length)j(this,me,g(this,me,"f")+`
81
- `,"f");j(this,me,g(this,me,"f")+e.join(" "),"f")}}}[Xs](e){Ut(g(this,K,"f")).forEach((t)=>{if(((r)=>r==="configObjects")(t))return;let n=g(this,K,"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]}[Co](e,t,n){if(!g(this,Rn,"f")[n])g(this,H,"f").process.emitWarning(e,t),g(this,Rn,"f")[n]=!0}[Eo](){g(this,Mn,"f").push({options:g(this,K,"f"),configObjects:g(this,K,"f").configObjects.slice(0),exitProcess:g(this,Pe,"f"),groups:g(this,Xe,"f"),strict:g(this,Ct,"f"),strictCommands:g(this,Et,"f"),strictOptions:g(this,xt,"f"),completionCommand:g(this,Ae,"f"),output:g(this,me,"f"),exitError:g(this,rt,"f"),hasOutput:g(this,$e,"f"),parsed:this.parsed,parseFn:g(this,Oe,"f"),parseContext:g(this,bt,"f")}),g(this,Y,"f").freeze(),g(this,ce,"f").freeze(),g(this,fe,"f").freeze(),g(this,Re,"f").freeze()}[xo](){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 r=this[No](g(this,Dt,"f"),n);return n.match(/^(\/|([a-zA-Z]:)?\\)/)&&r.length<n.length?r: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,vn,"f")}[_o](){return g(this,Ln,"f")}[Gs](){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(/[.:].*/,""))}[ko](){return this[Vs]().version||"unknown"}[So](e){let t=e["--"]?e["--"]:e._;for(let n=0,r;(r=t[n])!==void 0;n++)if(g(this,H,"f").Parser.looksLikeNumber(r)&&Number.isSafeInteger(Math.floor(parseFloat(`${r}`))))t[n]=Number(r);return e}[Vs](e){let t=e||"*";if(g(this,Jt,"f")[t])return g(this,Jt,"f")[t];let n={};try{let r=e||g(this,H,"f").mainFilename;if(g(this,H,"f").path.extname(r))r=g(this,H,"f").path.dirname(r);let s=g(this,H,"f").findUp(r,(i,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(r){}return g(this,Jt,"f")[t]=n||{},g(this,Jt,"f")[t]}[ot](e,t){t=[].concat(t),t.forEach((n)=>{n=this[er](n),g(this,K,"f")[e].push(n)})}[zt](e,t,n,r){this[Qs](e,t,n,r,(s,i,o)=>{g(this,K,"f")[s][i]=o})}[Zs](e,t,n,r){this[Qs](e,t,n,r,(s,i,o)=>{g(this,K,"f")[s][i]=(g(this,K,"f")[s][i]||[]).concat(o)})}[Qs](e,t,n,r,s){if(Array.isArray(n))n.forEach((i)=>{e(i,r)});else if(((i)=>typeof i==="object")(n))for(let i of Ut(n))e(i,n[i]);else s(t,this[er](n),r)}[er](e){if(e==="__proto__")return"___proto___";return e}[tr](e,t){return this[zt](this[tr].bind(this),"key",e,t),this}[nr](){var e,t,n,r,s,i,o,a,c,u,f,l;let d=g(this,Mn,"f").pop();Ce(d,void 0,g(this,H,"f"));let p;e=this,t=this,n=this,r=this,s=this,i=this,o=this,a=this,c=this,u=this,f=this,l=this,{options:{set value(m){j(e,K,m,"f")}}.value,configObjects:p,exitProcess:{set value(m){j(t,Pe,m,"f")}}.value,groups:{set value(m){j(n,Xe,m,"f")}}.value,output:{set value(m){j(r,me,m,"f")}}.value,exitError:{set value(m){j(s,rt,m,"f")}}.value,hasOutput:{set value(m){j(i,$e,m,"f")}}.value,parsed:this.parsed,strict:{set value(m){j(o,Ct,m,"f")}}.value,strictCommands:{set value(m){j(a,Et,m,"f")}}.value,strictOptions:{set value(m){j(c,xt,m,"f")}}.value,completionCommand:{set value(m){j(u,Ae,m,"f")}}.value,parseFn:{set value(m){j(f,Oe,m,"f")}}.value,parseContext:{set value(m){j(l,bt,m,"f")}}.value}=d,g(this,K,"f").configObjects=p,g(this,Y,"f").unfreeze(),g(this,ce,"f").unfreeze(),g(this,fe,"f").unfreeze(),g(this,Re,"f").unfreeze()}[Ao](e,t){return mt(t,(n)=>(e(n),n))}getInternalMethods(){return{getCommandInstance:this[$o].bind(this),getContext:this[Oo].bind(this),getHasOutput:this[Io].bind(this),getLoggerInstance:this[To].bind(this),getParseContext:this[Po].bind(this),getParserConfiguration:this[_t].bind(this),getUsageConfiguration:this[_o].bind(this),getUsageInstance:this[Ro].bind(this),getValidationInstance:this[Mo].bind(this),hasParseCallback:this[Wn].bind(this),isGlobalContext:this[Bo].bind(this),postProcess:this[kt].bind(this),reset:this[sr].bind(this),runValidation:this[rr].bind(this),runYargsParserAndExecuteCommands:this[on].bind(this),setHasOutput:this[vo].bind(this)}}[$o](){return g(this,fe,"f")}[Oo](){return g(this,rn,"f")}[Io](){return g(this,$e,"f")}[To](){return g(this,wt,"f")}[Po](){return g(this,bt,"f")||{}}[Ro](){return g(this,Y,"f")}[Mo](){return g(this,ce,"f")}[Wn](){return!!g(this,Oe,"f")}[Bo](){return g(this,Bn,"f")}[kt](e,t,n,r){if(n)return e;if(re(e))return e;if(!t)e=this[bo](e);if(this[_t]()["parse-positional-numbers"]||this[_t]()["parse-positional-numbers"]===void 0)e=this[So](e);if(r)e=gt(e,this,g(this,Re,"f").getMiddleware(),!1);return e}[sr](e={}){j(this,K,g(this,K,"f")||{},"f");let t={};t.local=g(this,K,"f").local||[],t.configObjects=g(this,K,"f").configObjects||[];let n={};t.local.forEach((i)=>{n[i]=!0,(e[i]||[]).forEach((o)=>{n[o]=!0})}),Object.assign(g(this,Ft,"f"),Object.keys(g(this,Xe,"f")).reduce((i,o)=>{let a=g(this,Xe,"f")[o].filter((c)=>!(c in n));if(a.length>0)i[o]=a;return i},{})),j(this,Xe,{},"f");let r=["array","boolean","string","skipValidation","count","normalize","number","hiddenOptions"],s=["narg","key","alias","default","defaultDescription","config","choices","demandedOptions","demandedCommands","deprecatedOptions"];if(r.forEach((i)=>{t[i]=(g(this,K,"f")[i]||[]).filter((o)=>!n[o])}),s.forEach((i)=>{t[i]=nt(g(this,K,"f")[i],(o)=>!n[o])}),t.envPrefix=g(this,K,"f").envPrefix,j(this,K,t,"f"),j(this,Y,g(this,Y,"f")?g(this,Y,"f").reset(n):lo(this,g(this,H,"f")),"f"),j(this,ce,g(this,ce,"f")?g(this,ce,"f").reset(n):yo(this,g(this,Y,"f"),g(this,H,"f")),"f"),j(this,fe,g(this,fe,"f")?g(this,fe,"f").reset():ao(g(this,Y,"f"),g(this,ce,"f"),g(this,Re,"f"),g(this,H,"f")),"f"),!g(this,xe,"f"))j(this,xe,go(this,g(this,Y,"f"),g(this,fe,"f"),g(this,H,"f")),"f");return g(this,Re,"f").reset(),j(this,Ae,null,"f"),j(this,me,"","f"),j(this,rt,null,"f"),j(this,$e,!1,"f"),this.parsed=!1,this}[No](e,t){return g(this,H,"f").path.relative(e,t)}[on](e,t,n,r=0,s=!1){var i,o,a,c;let u=!!n||s;e=e||g(this,it,"f"),g(this,K,"f").__=g(this,H,"f").y18n.__,g(this,K,"f").configuration=this[_t]();let f=!!g(this,K,"f").configuration["populate--"],l=Object.assign({},g(this,K,"f").configuration,{"populate--":!0}),d=g(this,H,"f").Parser.detailed(e,Object.assign({},g(this,K,"f"),{configuration:{"parse-positional-numbers":!1,...l}})),p=Object.assign(d.argv,g(this,bt,"f")),m=void 0,h=d.aliases,y=!1,E=!1;if(Object.keys(p).forEach((F)=>{if(F===g(this,Me,"f")&&p[F])y=!0;else if(F===g(this,Ge,"f")&&p[F])E=!0}),p.$0=this.$0,this.parsed=d,r===0)g(this,Y,"f").clearCachedHelpMessage();try{if(this[Gs](),t)return this[kt](p,f,!!n,!1);if(g(this,Me,"f")){if([g(this,Me,"f")].concat(h[g(this,Me,"f")]||[]).filter((I)=>I.length>1).includes(""+p._[p._.length-1]))p._.pop(),y=!0}j(this,Bn,!1,"f");let F=g(this,fe,"f").getCommands(),A=((i=g(this,xe,"f"))===null||i===void 0?void 0:i.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((B)=>Object.prototype.hasOwnProperty.call(p,B)):!1,_=y||A||s;if(p._.length){if(F.length){let B;for(let I=r||0,R;p._[I]!==void 0;I++)if(R=String(p._[I]),F.includes(R)&&R!==g(this,Ae,"f")){let V=g(this,fe,"f").runCommand(R,this,d,I+1,s,y||E||s);return this[kt](V,f,!!n,!1)}else if(!B&&R!==g(this,Ae,"f")){B=R;break}if(!g(this,fe,"f").hasDefaultCommand()&&g(this,jn,"f")&&B&&!_)g(this,ce,"f").recommendCommands(B,F)}if(g(this,Ae,"f")&&p._.includes(g(this,Ae,"f"))&&!A){if(g(this,Pe,"f"))st(!0);this.showCompletionScript(),this.exit(0)}}if(g(this,fe,"f").hasDefaultCommand()&&!_){let B=g(this,fe,"f").runCommand(null,this,d,0,s,y||E||s);return this[kt](B,f,!!n,!1)}if(A){if(g(this,Pe,"f"))st(!0);e=[].concat(e);let B=e.slice(e.indexOf(`--${g(this,xe,"f").completionKey}`)+1);return g(this,xe,"f").getCompletion(B,(I,R)=>{if(I)throw new le(I.message);(R||[]).forEach((V)=>{g(this,wt,"f").log(V)}),this.exit(0)}),this[kt](p,!f,!!n,!1)}if(!g(this,$e,"f")){if(y){if(g(this,Pe,"f"))st(!0);u=!0,this.showHelp((B)=>{g(this,wt,"f").log(B),this.exit(0)})}else if(E){if(g(this,Pe,"f"))st(!0);u=!0,g(this,Y,"f").showVersion("log"),this.exit(0)}}if(!u&&g(this,K,"f").skipValidation.length>0)u=Object.keys(p).some((B)=>g(this,K,"f").skipValidation.indexOf(B)>=0&&p[B]===!0);if(!u){if(d.error)throw new le(d.error.message);if(!A){let B=this[rr](h,{},d.error);if(!n)m=gt(p,this,g(this,Re,"f").getMiddleware(),!0);if(m=this[Ao](B,m!==null&&m!==void 0?m:p),re(m)&&!n)m=m.then(()=>gt(p,this,g(this,Re,"f").getMiddleware(),!1))}}}catch(F){if(F instanceof le)g(this,Y,"f").fail(F.message,F);else throw F}return this[kt](m!==null&&m!==void 0?m:p,f,!!n,!0)}[rr](e,t,n,r){let s={...this.getDemandedOptions()};return(i)=>{if(n)throw new le(n.message);g(this,ce,"f").nonOptionCount(i),g(this,ce,"f").requiredArguments(i,s);let o=!1;if(g(this,Et,"f"))o=g(this,ce,"f").unknownCommands(i);if(g(this,Ct,"f")&&!o)g(this,ce,"f").unknownArguments(i,e,t,!!r);else if(g(this,xt,"f"))g(this,ce,"f").unknownArguments(i,e,{},!1,!1);g(this,ce,"f").limitedChoices(i),g(this,ce,"f").implications(i),g(this,ce,"f").conflicting(i)}}[vo](){j(this,$e,!0,"f")}[St](e){if(typeof e==="string")g(this,K,"f").key[e]=!0;else for(let t of e)g(this,K,"f").key[t]=!0}}function co(e){return!!e&&typeof e.getInternalMethods==="function"}var Ol=jo(Js),Wo=Ol;import{existsSync as Un,readFileSync as ar,writeFileSync as ir,mkdirSync as Jo}from"node:fs";import{homedir as Il}from"node:os";import{join as At,dirname as cr}from"node:path";function ur(){return process.env.HOME||Il()}function zo(){return At(ur(),".config","slack-cli","profiles.json")}function Kn(){return At(process.cwd(),".slack-cli","workspace")}function Jn(){return At(ur(),".slack-cli","workspace")}function an(){let e=zo();if(!Un(e))return{profiles:{}};return JSON.parse(ar(e,"utf8"))}function Tl(e){let t=zo();Jo(cr(t),{recursive:!0}),ir(t,JSON.stringify(e,null,2)+`
82
- `)}function Ht(e){if(!Un(e))return;return ar(e,"utf8").trim()||void 0}function Uo(e,t){let n=cr(e);Jo(n,{recursive:!0});let r=At(n,".gitignore");if(!Un(r))ir(r,`*
76
+ `)}`:"";t.fail(s("Missing required argument: %s","Missing required arguments: %s",Object.keys(p).length,Object.keys(p).join(", ")+h))}},o.unknownArguments=function(l,d,p,m,h=!0){var y;let E=e.getInternalMethods().getCommandInstance().getCommands(),F=[],A=e.getInternalMethods().getContext();if(Object.keys(l).forEach((k)=>{if(!yi.includes(k)&&!Object.prototype.hasOwnProperty.call(p,k)&&!Object.prototype.hasOwnProperty.call(e.getInternalMethods().getParseContext(),k)&&!o.isValidAndSomeAliasIsNotNew(k,d))F.push(k)}),h&&(A.commands.length>0||E.length>0||m))l._.slice(A.commands.length).forEach((k)=>{if(!E.includes(""+k))F.push(""+k)});if(h){let B=((y=e.getDemandedCommands()._)===null||y===void 0?void 0:y.max)||0,I=A.commands.length+B;if(I<l._.length)l._.slice(I).forEach((R)=>{if(R=String(R),!A.commands.includes(R)&&!F.includes(R))F.push(R)})}if(F.length)t.fail(s("Unknown argument: %s","Unknown arguments: %s",F.length,F.map((k)=>k.trim()?k:`"${k}"`).join(", ")))},o.unknownCommands=function(l){let d=e.getInternalMethods().getCommandInstance().getCommands(),p=[],m=e.getInternalMethods().getContext();if(m.commands.length>0||d.length>0)l._.slice(m.commands.length).forEach((h)=>{if(!d.includes(""+h))p.push(""+h)});if(p.length>0)return t.fail(s("Unknown command: %s","Unknown commands: %s",p.length,p.join(", "))),!0;else return!1},o.isValidAndSomeAliasIsNotNew=function(l,d){if(!Object.prototype.hasOwnProperty.call(d,l))return!1;let p=e.parsed.newAliases;return[l,...d[l]].some((m)=>!Object.prototype.hasOwnProperty.call(p,m)||!p[l])},o.limitedChoices=function(l){let d=e.getOptions(),p={};if(!Object.keys(d.choices).length)return;Object.keys(l).forEach((y)=>{if(yi.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)p[y]=(p[y]||[]).concat(E)})});let m=Object.keys(p);if(!m.length)return;let h=r("Invalid values:");m.forEach((y)=>{h+=`
77
+ ${r("Argument: %s, Given: %s, Choices: %s",y,t.stringifiedValues(p[y]),t.stringifiedValues(d.choices[y]))}`}),t.fail(h)};let i={};o.implies=function(l,d){if(v("<string|object> [array|number|string]",[l,d],arguments.length),typeof l==="object")Object.keys(l).forEach((p)=>{o.implies(p,l[p])});else{if(e.global(l),!i[l])i[l]=[];if(Array.isArray(d))d.forEach((p)=>o.implies(l,p));else Ce(d,void 0,n),i[l].push(d)}},o.getImplied=function(){return i};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}o.implications=function(l){let d=[];if(Object.keys(i).forEach((p)=>{let m=p;(i[p]||[]).forEach((h)=>{let y=m,E=h;if(y=a(l,y),h=a(l,h),y&&!h)d.push(` ${m} -> ${E}`)})}),d.length){let p=`${r("Implications failed:")}
78
+ `;d.forEach((m)=>{p+=m}),t.fail(p)}};let c={};o.conflicts=function(l,d){if(v("<string|object> [array|string]",[l,d],arguments.length),typeof l==="object")Object.keys(l).forEach((p)=>{o.conflicts(p,l[p])});else{if(e.global(l),!c[l])c[l]=[];if(Array.isArray(d))d.forEach((p)=>o.conflicts(l,p));else c[l].push(d)}},o.getConflicting=()=>c,o.conflicting=function(l){if(Object.keys(l).forEach((d)=>{if(c[d])c[d].forEach((p)=>{if(p&&l[d]!==void 0&&l[p]!==void 0)t.fail(r("Arguments %s and %s are mutually exclusive",d,p))})}),e.getInternalMethods().getParserConfiguration()["strip-dashed"])Object.keys(c).forEach((d)=>{c[d].forEach((p)=>{if(p&&l[n.Parser.camelCase(d)]!==void 0&&l[n.Parser.camelCase(p)]!==void 0)t.fail(r("Arguments %s and %s are mutually exclusive",d,p))})})},o.recommendCommands=function(l,d){d=d.sort((y,E)=>E.length-y.length);let m=null,h=1/0;for(let y=0,E;(E=d[y])!==void 0;y++){let F=Di(l,E);if(F<=3&&F<h)h=F,m=E}if(m)t.fail(r("Did you mean %s?",m))},o.reset=function(l){return i=rt(i,(d)=>!l[d]),c=rt(c,(d)=>!l[d]),o};let u=[];return o.freeze=function(){u.push({implied:i,conflicting:c})},o.unfreeze=function(){let l=u.pop();Ce(l,void 0,n),{implied:i,conflicting:c}=l},o}var Xs=[],nn;function sn(e,t,n,r){nn=r;let s={};if(Object.prototype.hasOwnProperty.call(e,"extends")){if(typeof e.extends!=="string")return s;let o=/\.json|\..*rc$/.test(e.extends),i=null;if(!o)try{i=import.meta.resolve(e.extends)}catch(a){return e}else i=Ol(t,e.extends);$l(i),Xs.push(i),s=o?JSON.parse(nn.readFileSync(i,"utf8")):r.require(e.extends),delete e.extends,s=sn(s,nn.path.dirname(i),n,nn)}return Xs=[],n?wi(s,e):Object.assign({},s,e)}function $l(e){if(Xs.indexOf(e)>-1)throw new le(`Circular extended configurations: '${e}'.`)}function Ol(e,t){return nn.path.resolve(e,t)}function wi(e,t){let n={};function r(s){return s&&typeof s==="object"&&!Array.isArray(s)}Object.assign(n,e);for(let s of Object.keys(t))if(r(t[s])&&r(n[s]))n[s]=wi(e[s],t[s]);else n[s]=t[s];return n}var j=function(e,t,n,r,s){if(r==="m")throw TypeError("Private method is not writable");if(r==="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 r==="a"?s.call(e,n):s?s.value=n:t.set(e,n),n},g=function(e,t,n,r){if(n==="a"&&!r)throw TypeError("Private accessor was defined without a getter");if(typeof t==="function"?e!==t||!r:!t.has(e))throw TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?r:n==="a"?r.call(e):r?r.value:t.get(e)},fe,yt,rn,xe,Ae,Rn,it,bt,Mn,Pe,Bn,Re,Xe,$e,Me,Nn,wt,me,K,vn,jn,Oe,Ft,Jt,Ct,at,Ln,H,Et,xt,_t,Y,Wn,Ge,ce;function Li(e){return(t=[],n=e.process.cwd(),r)=>{let s=new Wi(t,n,r,e);return Object.defineProperty(s,"argv",{get:()=>s.parse(),enumerable:!0}),s.help(),s.version(),s}}var Fi=Symbol("copyDoubleDash"),Ci=Symbol("copyDoubleDash"),Gs=Symbol("deleteFromParserHintObject"),Ei=Symbol("emitWarning"),xi=Symbol("freeze"),_i=Symbol("getDollarZero"),kt=Symbol("getParserConfiguration"),ki=Symbol("getUsageConfiguration"),Vs=Symbol("guessLocale"),Si=Symbol("guessVersion"),Ai=Symbol("parsePositionalNumbers"),Zs=Symbol("pkgUp"),ct=Symbol("populateParserHintArray"),zt=Symbol("populateParserHintSingleValueDictionary"),Qs=Symbol("populateParserHintArrayDictionary"),er=Symbol("populateParserHintDictionary"),tr=Symbol("sanitizeKey"),nr=Symbol("setKey"),sr=Symbol("unfreeze"),$i=Symbol("validateAsync"),Oi=Symbol("getCommandInstance"),Ii=Symbol("getContext"),Ti=Symbol("getHasOutput"),Pi=Symbol("getLoggerInstance"),Ri=Symbol("getParseContext"),Mi=Symbol("getUsageInstance"),Bi=Symbol("getValidationInstance"),Un=Symbol("hasParseCallback"),Ni=Symbol("isGlobalContext"),St=Symbol("postProcess"),vi=Symbol("rebase"),rr=Symbol("reset"),on=Symbol("runYargsParserAndExecuteCommands"),or=Symbol("runValidation"),ji=Symbol("setHasOutput"),At=Symbol("kTrackManuallySetKeys"),Il="en_US";class Wi{constructor(e=[],t,n,r){this.customScriptName=!1,this.parsed=!1,fe.set(this,void 0),yt.set(this,void 0),rn.set(this,{commands:[],fullCommands:[]}),xe.set(this,null),Ae.set(this,null),Rn.set(this,"show-hidden"),it.set(this,null),bt.set(this,!0),Mn.set(this,{}),Pe.set(this,!0),Bn.set(this,[]),Re.set(this,void 0),Xe.set(this,{}),$e.set(this,!1),Me.set(this,null),Nn.set(this,!0),wt.set(this,void 0),me.set(this,""),K.set(this,void 0),vn.set(this,void 0),jn.set(this,{}),Oe.set(this,null),Ft.set(this,null),Jt.set(this,{}),Ct.set(this,{}),at.set(this,void 0),Ln.set(this,!1),H.set(this,void 0),Et.set(this,!1),xt.set(this,!1),_t.set(this,!1),Y.set(this,void 0),Wn.set(this,{}),Ge.set(this,null),ce.set(this,void 0),j(this,H,r,"f"),j(this,at,e,"f"),j(this,yt,t,"f"),j(this,vn,n,"f"),j(this,Re,new qs(this),"f"),this.$0=this[_i](),this[rr](),j(this,fe,g(this,fe,"f"),"f"),j(this,Y,g(this,Y,"f"),"f"),j(this,ce,g(this,ce,"f"),"f"),j(this,K,g(this,K,"f"),"f"),g(this,K,"f").showHiddenOpt=g(this,Rn,"f"),j(this,wt,this[Ci](),"f"),g(this,H,"f").y18n.setLocale(Il)}addHelpOpt(e,t){if(v("[string|boolean] [string]",[e,t],arguments.length),g(this,Me,"f"))this[Gs](g(this,Me,"f")),j(this,Me,null,"f");if(e===!1&&t===void 0)return this;return j(this,Me,typeof e==="string"?e:"help","f"),this.boolean(g(this,Me,"f")),this.describe(g(this,Me,"f"),t||g(this,Y,"f").deferY18nLookup("Show help")),this}help(e,t){return this.addHelpOpt(e,t)}addShowHiddenOpt(e,t){if(v("[string|boolean] [string]",[e,t],arguments.length),e===!1&&t===void 0)return this;let n=typeof e==="string"?e:g(this,Rn,"f");return this.boolean(n),this.describe(n,t||g(this,Y,"f").deferY18nLookup("Show hidden options")),g(this,K,"f").showHiddenOpt=n,this}showHidden(e,t){return this.addShowHiddenOpt(e,t)}alias(e,t){return v("<object|string|array> [string|array]",[e,t],arguments.length),this[Qs](this.alias.bind(this),"alias",e,t),this}array(e){return v("<array|string>",[e],arguments.length),this[ct]("array",e),this[At](e),this}boolean(e){return v("<array|string>",[e],arguments.length),this[ct]("boolean",e),this[At](e),this}check(e,t){return v("<function> [boolean]",[e,t],arguments.length),this.middleware((n,r)=>Dt(()=>e(n,r.getOptions()),(s)=>{if(!s)g(this,Y,"f").fail(g(this,H,"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 v("<object|string|array> [string|array]",[e,t],arguments.length),this[Qs](this.choices.bind(this),"choices",e,t),this}coerce(e,t){if(v("<object|string|array> [function]",[e,t],arguments.length),Array.isArray(e)){if(!t)throw new le("coerce callback must be provided");for(let r of e)this.coerce(r,t);return this}else if(typeof e==="object"){for(let r of Object.keys(e))this.coerce(r,e[r]);return this}if(!t)throw new le("coerce callback must be provided");let n=e;return g(this,K,"f").key[n]=!0,g(this,Re,"f").addCoerceMiddleware((r,s)=>{var o;let i=(o=s.getAliases()[n])!==null&&o!==void 0?o:[],a=[n,...i].filter((c)=>Object.prototype.hasOwnProperty.call(r,c));if(a.length===0)return r;return Dt(()=>t(r[a[0]]),(c)=>(a.forEach((u)=>{r[u]=c}),r),(c)=>{throw new le(c.message)})},n),this}conflicts(e,t){return v("<string|object> [string|array]",[e,t],arguments.length),g(this,ce,"f").conflicts(e,t),this}config(e="config",t,n){if(v("[object|string] [string|function] [function]",[e,t,n],arguments.length),typeof e==="object"&&!Array.isArray(e))return e=sn(e,g(this,yt,"f"),this[kt]()["deep-merge-config"]||!1,g(this,H,"f")),g(this,K,"f").configObjects=(g(this,K,"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((r)=>{g(this,K,"f").config[r]=n||!0}),this}completion(e,t,n){if(v("[string] [string|boolean|function] [function]",[e,t,n],arguments.length),typeof t==="function")n=t,t=void 0;if(j(this,Ae,e||g(this,Ae,"f")||"completion","f"),!t&&t!==!1)t="generate completion script";if(this.command(g(this,Ae,"f"),t),n)g(this,xe,"f").registerFunction(n);return this}command(e,t,n,r,s,o){return v("<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]",[e,t,n,r,s,o],arguments.length),g(this,fe,"f").addHandler(e,t,n,r,s,o),this}commands(e,t,n,r,s,o){return this.command(e,t,n,r,s,o)}commandDir(e,t){v("<string> [object]",[e,t],arguments.length);let n=g(this,vn,"f")||g(this,H,"f").require;return g(this,fe,"f").addDirectory(e,n,g(this,H,"f").getCallerFile(),t),this}count(e){return v("<array|string>",[e],arguments.length),this[ct]("count",e),this[At](e),this}default(e,t,n){if(v("<object|string|array> [*] [string]",[e,t,n],arguments.length),n)Hs(e,g(this,H,"f")),g(this,K,"f").defaultDescription[e]=n;if(typeof t==="function"){if(Hs(e,g(this,H,"f")),!g(this,K,"f").defaultDescription[e])g(this,K,"f").defaultDescription[e]=g(this,Y,"f").functionDescription(t);t=t.call()}return this[zt](this.default.bind(this),"default",e,t),this}defaults(e,t,n){return this.default(e,t,n)}demandCommand(e=1,t,n,r){if(v("[number] [number|string] [string|null|undefined] [string|null|undefined]",[e,t,n,r],arguments.length),typeof t!=="number")n=t,t=1/0;return this.global("_",!1),g(this,K,"f").demandedCommands._={min:e,max:t,minMsg:n,maxMsg:r},this}demand(e,t,n){if(Array.isArray(t))t.forEach((r)=>{Ce(n,!0,g(this,H,"f")),this.demandOption(r,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((r)=>{Ce(n,!0,g(this,H,"f")),this.demandOption(r,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 v("<object|string|array> [string]",[e,t],arguments.length),this[zt](this.demandOption.bind(this),"demandedOptions",e,t),this}deprecateOption(e,t){return v("<string> [string|boolean]",[e,t],arguments.length),g(this,K,"f").deprecatedOptions[e]=t,this}describe(e,t){return v("<object|string|array> [string]",[e,t],arguments.length),this[nr](e,!0),g(this,Y,"f").describe(e,t),this}detectLocale(e){return v("<boolean>",[e],arguments.length),j(this,bt,e,"f"),this}env(e){if(v("[string|boolean]",[e],arguments.length),e===!1)delete g(this,K,"f").envPrefix;else g(this,K,"f").envPrefix=e||"";return this}epilogue(e){return v("<string>",[e],arguments.length),g(this,Y,"f").epilog(e),this}epilog(e){return this.epilogue(e)}example(e,t){if(v("<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(j(this,$e,!0,"f"),j(this,it,t,"f"),g(this,Pe,"f"))g(this,H,"f").process.exit(e)}exitProcess(e=!0){return v("[boolean]",[e],arguments.length),j(this,Pe,e,"f"),this}fail(e){if(v("<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(v("<array> [function]",[e,t],arguments.length),!t)return new Promise((n,r)=>{g(this,xe,"f").getCompletion(e,(s,o)=>{if(s)r(s);else n(o)})});else return g(this,xe,"f").getCompletion(e,t)}getDemandedOptions(){return v([],0),g(this,K,"f").demandedOptions}getDemandedCommands(){return v([],0),g(this,K,"f").demandedCommands}getDeprecatedOptions(){return v([],0),g(this,K,"f").deprecatedOptions}getDetectLocale(){return g(this,bt,"f")}getExitProcess(){return g(this,Pe,"f")}getGroups(){return Object.assign({},g(this,Xe,"f"),g(this,Ct,"f"))}getHelp(){if(j(this,$e,!0,"f"),!g(this,Y,"f").hasCachedHelpMessage()){if(!this.parsed){let t=this[on](g(this,at,"f"),void 0,void 0,0,!0);if(re(t))return t.then(()=>g(this,Y,"f").help())}let e=g(this,fe,"f").runDefaultBuilderOn(this);if(re(e))return e.then(()=>g(this,Y,"f").help())}return Promise.resolve(g(this,Y,"f").help())}getOptions(){return g(this,K,"f")}getStrict(){return g(this,Et,"f")}getStrictCommands(){return g(this,xt,"f")}getStrictOptions(){return g(this,_t,"f")}global(e,t){if(v("<string|array> [boolean]",[e,t],arguments.length),e=[].concat(e),t!==!1)g(this,K,"f").local=g(this,K,"f").local.filter((n)=>e.indexOf(n)===-1);else e.forEach((n)=>{if(!g(this,K,"f").local.includes(n))g(this,K,"f").local.push(n)});return this}group(e,t){v("<string|array> <string>",[e,t],arguments.length);let n=g(this,Ct,"f")[t]||g(this,Xe,"f")[t];if(g(this,Ct,"f")[t])delete g(this,Ct,"f")[t];let r={};return g(this,Xe,"f")[t]=(n||[]).concat(e).filter((s)=>{if(r[s])return!1;return r[s]=!0}),this}hide(e){return v("<string>",[e],arguments.length),g(this,K,"f").hiddenOptions.push(e),this}implies(e,t){return v("<string|object> [number|string|array]",[e,t],arguments.length),g(this,ce,"f").implies(e,t),this}locale(e){if(v("[string]",[e],arguments.length),e===void 0)return this[Vs](),g(this,H,"f").y18n.getLocale();return j(this,bt,!1,"f"),g(this,H,"f").y18n.setLocale(e),this}middleware(e,t,n){return g(this,Re,"f").addMiddleware(e,!!t,n)}nargs(e,t){return v("<string|object|array> [number]",[e,t],arguments.length),this[zt](this.nargs.bind(this),"narg",e,t),this}normalize(e){return v("<array|string>",[e],arguments.length),this[ct]("normalize",e),this}number(e){return v("<array|string>",[e],arguments.length),this[ct]("number",e),this[At](e),this}option(e,t){if(v("<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[At](e),g(this,Ge,"f")&&(e==="version"||(t===null||t===void 0?void 0:t.alias)==="version"))this[Ei](['"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,K,"f").key[e]=!0,t.alias)this.alias(e,t.alias);let n=t.deprecate||t.deprecated;if(n)this.deprecateOption(e,n);let r=t.demand||t.required||t.require;if(r)this.demand(e,r);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,K,"f").defaultDescription[e]=t.defaultDescription;if(t.skipValidation)this.skipValidation(e);let s=t.describe||t.description||t.desc,o=g(this,Y,"f").getDescriptions();if(!Object.prototype.hasOwnProperty.call(o,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(v("[string|array] [function|boolean|object] [function]",[e,t,n],arguments.length),this[xi](),typeof e>"u")e=g(this,at,"f");if(typeof t==="object")j(this,Ft,t,"f"),t=n;if(typeof t==="function")j(this,Oe,t,"f"),t=!1;if(!t)j(this,at,e,"f");if(g(this,Oe,"f"))j(this,Pe,!1,"f");let r=this[on](e,!!t),s=this.parsed;if(g(this,xe,"f").setParsed(this.parsed),re(r))return r.then((o)=>{if(g(this,Oe,"f"))g(this,Oe,"f").call(this,g(this,it,"f"),o,g(this,me,"f"));return o}).catch((o)=>{if(g(this,Oe,"f"))g(this,Oe,"f")(o,this.parsed.argv,g(this,me,"f"));throw o}).finally(()=>{this[sr](),this.parsed=s});else{if(g(this,Oe,"f"))g(this,Oe,"f").call(this,g(this,it,"f"),r,g(this,me,"f"));this[sr](),this.parsed=s}return r}parseAsync(e,t,n){let r=this.parse(e,t,n);return!re(r)?Promise.resolve(r):r}parseSync(e,t,n){let r=this.parse(e,t,n);if(re(r))throw new le(".parseSync() must not be used with asynchronous builders, handlers, or middleware");return r}parserConfiguration(e){return v("<object>",[e],arguments.length),j(this,jn,e,"f"),this}pkgConf(e,t){v("<string> [string]",[e,t],arguments.length);let n=null,r=this[Zs](t||g(this,yt,"f"));if(r[e]&&typeof r[e]==="object")n=sn(r[e],t||g(this,yt,"f"),this[kt]()["deep-merge-config"]||!1,g(this,H,"f")),g(this,K,"f").configObjects=(g(this,K,"f").configObjects||[]).concat(n);return this}positional(e,t){v("<string> <object>",[e,t],arguments.length);let n=["default","defaultDescription","implies","normalize","choices","conflicts","coerce","type","describe","desc","description","alias"];t=rt(t,(o,i)=>{if(o==="type"&&!["string","number","boolean"].includes(i))return!1;return n.includes(o)});let r=g(this,rn,"f").fullCommands[g(this,rn,"f").fullCommands.length-1],s=r?g(this,fe,"f").cmdToParseOptions(r):{array:[],alias:{},default:{},demand:{}};return Ut(s).forEach((o)=>{let i=s[o];if(Array.isArray(i)){if(i.indexOf(e)!==-1)t[o]=!0}else if(i[e]&&!(o in t))t[o]=i[e]}),this.group(e,g(this,Y,"f").getPositionalGroupName()),this.option(e,t)}recommendCommands(e=!0){return v("[boolean]",[e],arguments.length),j(this,Ln,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(v("<array|string|object> [number]",[e],arguments.length),typeof e==="string"&&g(this,K,"f").narg[e])return this;else this[zt](this.requiresArg.bind(this),"narg",e,NaN);return this}showCompletionScript(e,t){return v("[string] [string]",[e,t],arguments.length),e=e||this.$0,g(this,wt,"f").log(g(this,xe,"f").generateCompletionScript(e,t||g(this,Ae,"f")||"completion")),this}showHelp(e){if(v("[string|function]",[e],arguments.length),j(this,$e,!0,"f"),!g(this,Y,"f").hasCachedHelpMessage()){if(!this.parsed){let n=this[on](g(this,at,"f"),void 0,void 0,0,!0);if(re(n))return n.then(()=>{g(this,Y,"f").showHelp(e)}),this}let t=g(this,fe,"f").runDefaultBuilderOn(this);if(re(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 v("[boolean|string] [string]",[e,t],arguments.length),g(this,Y,"f").showHelpOnFail(e,t),this}showVersion(e){return v("[string|function]",[e],arguments.length),g(this,Y,"f").showVersion(e),this}skipValidation(e){return v("<array|string>",[e],arguments.length),this[ct]("skipValidation",e),this}strict(e){return v("[boolean]",[e],arguments.length),j(this,Et,e!==!1,"f"),this}strictCommands(e){return v("[boolean]",[e],arguments.length),j(this,xt,e!==!1,"f"),this}strictOptions(e){return v("[boolean]",[e],arguments.length),j(this,_t,e!==!1,"f"),this}string(e){return v("<array|string>",[e],arguments.length),this[ct]("string",e),this[At](e),this}terminalWidth(){return v([],0),g(this,H,"f").process.stdColumns}updateLocale(e){return this.updateStrings(e)}updateStrings(e){return v("<object>",[e],arguments.length),j(this,bt,!1,"f"),g(this,H,"f").y18n.updateLocale(e),this}usage(e,t,n,r){if(v("<string|null|undefined> [string|boolean] [function|object] [function]",[e,t,n,r],arguments.length),t!==void 0)if(Ce(e,null,g(this,H,"f")),(e||"").match(/^\$0( |$)/))return this.command(e,t,n,r);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 v("<object>",[e],arguments.length),j(this,Wn,e,"f"),this}version(e,t,n){if(v("[boolean|string] [string] [string]",[e,t,n],arguments.length),g(this,Ge,"f"))this[Gs](g(this,Ge,"f")),g(this,Y,"f").version(void 0),j(this,Ge,null,"f");if(arguments.length===0)n=this[Si](),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 j(this,Ge,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,Ge,"f")),this.describe(g(this,Ge,"f"),t),this}wrap(e){return v("<number|null|undefined>",[e],arguments.length),g(this,Y,"f").wrap(e),this}[(fe=new WeakMap,yt=new WeakMap,rn=new WeakMap,xe=new WeakMap,Ae=new WeakMap,Rn=new WeakMap,it=new WeakMap,bt=new WeakMap,Mn=new WeakMap,Pe=new WeakMap,Bn=new WeakMap,Re=new WeakMap,Xe=new WeakMap,$e=new WeakMap,Me=new WeakMap,Nn=new WeakMap,wt=new WeakMap,me=new WeakMap,K=new WeakMap,vn=new WeakMap,jn=new WeakMap,Oe=new WeakMap,Ft=new WeakMap,Jt=new WeakMap,Ct=new WeakMap,at=new WeakMap,Ln=new WeakMap,H=new WeakMap,Et=new WeakMap,xt=new WeakMap,_t=new WeakMap,Y=new WeakMap,Wn=new WeakMap,Ge=new WeakMap,ce=new WeakMap,Fi)](e){if(!e._||!e["--"])return e;e._.push.apply(e._,e["--"]);try{delete e["--"]}catch(t){}return e}[Ci](){return{log:(...e)=>{if(!this[Un]())console.log(...e);if(j(this,$e,!0,"f"),g(this,me,"f").length)j(this,me,g(this,me,"f")+`
80
+ `,"f");j(this,me,g(this,me,"f")+e.join(" "),"f")},error:(...e)=>{if(!this[Un]())console.error(...e);if(j(this,$e,!0,"f"),g(this,me,"f").length)j(this,me,g(this,me,"f")+`
81
+ `,"f");j(this,me,g(this,me,"f")+e.join(" "),"f")}}}[Gs](e){Ut(g(this,K,"f")).forEach((t)=>{if(((r)=>r==="configObjects")(t))return;let n=g(this,K,"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]}[Ei](e,t,n){if(!g(this,Mn,"f")[n])g(this,H,"f").process.emitWarning(e,t),g(this,Mn,"f")[n]=!0}[xi](){g(this,Bn,"f").push({options:g(this,K,"f"),configObjects:g(this,K,"f").configObjects.slice(0),exitProcess:g(this,Pe,"f"),groups:g(this,Xe,"f"),strict:g(this,Et,"f"),strictCommands:g(this,xt,"f"),strictOptions:g(this,_t,"f"),completionCommand:g(this,Ae,"f"),output:g(this,me,"f"),exitError:g(this,it,"f"),hasOutput:g(this,$e,"f"),parsed:this.parsed,parseFn:g(this,Oe,"f"),parseContext:g(this,Ft,"f")}),g(this,Y,"f").freeze(),g(this,ce,"f").freeze(),g(this,fe,"f").freeze(),g(this,Re,"f").freeze()}[_i](){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 r=this[vi](g(this,yt,"f"),n);return n.match(/^(\/|([a-zA-Z]:)?\\)/)&&r.length<n.length?r: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}[kt](){return g(this,jn,"f")}[ki](){return g(this,Wn,"f")}[Vs](){if(!g(this,bt,"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(/[.:].*/,""))}[Si](){return this[Zs]().version||"unknown"}[Ai](e){let t=e["--"]?e["--"]:e._;for(let n=0,r;(r=t[n])!==void 0;n++)if(g(this,H,"f").Parser.looksLikeNumber(r)&&Number.isSafeInteger(Math.floor(parseFloat(`${r}`))))t[n]=Number(r);return e}[Zs](e){let t=e||"*";if(g(this,Jt,"f")[t])return g(this,Jt,"f")[t];let n={};try{let r=e||g(this,H,"f").mainFilename;if(g(this,H,"f").path.extname(r))r=g(this,H,"f").path.dirname(r);let s=g(this,H,"f").findUp(r,(o,i)=>{if(i.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(r){}return g(this,Jt,"f")[t]=n||{},g(this,Jt,"f")[t]}[ct](e,t){t=[].concat(t),t.forEach((n)=>{n=this[tr](n),g(this,K,"f")[e].push(n)})}[zt](e,t,n,r){this[er](e,t,n,r,(s,o,i)=>{g(this,K,"f")[s][o]=i})}[Qs](e,t,n,r){this[er](e,t,n,r,(s,o,i)=>{g(this,K,"f")[s][o]=(g(this,K,"f")[s][o]||[]).concat(i)})}[er](e,t,n,r,s){if(Array.isArray(n))n.forEach((o)=>{e(o,r)});else if(((o)=>typeof o==="object")(n))for(let o of Ut(n))e(o,n[o]);else s(t,this[tr](n),r)}[tr](e){if(e==="__proto__")return"___proto___";return e}[nr](e,t){return this[zt](this[nr].bind(this),"key",e,t),this}[sr](){var e,t,n,r,s,o,i,a,c,u,f,l;let d=g(this,Bn,"f").pop();Ce(d,void 0,g(this,H,"f"));let p;e=this,t=this,n=this,r=this,s=this,o=this,i=this,a=this,c=this,u=this,f=this,l=this,{options:{set value(m){j(e,K,m,"f")}}.value,configObjects:p,exitProcess:{set value(m){j(t,Pe,m,"f")}}.value,groups:{set value(m){j(n,Xe,m,"f")}}.value,output:{set value(m){j(r,me,m,"f")}}.value,exitError:{set value(m){j(s,it,m,"f")}}.value,hasOutput:{set value(m){j(o,$e,m,"f")}}.value,parsed:this.parsed,strict:{set value(m){j(i,Et,m,"f")}}.value,strictCommands:{set value(m){j(a,xt,m,"f")}}.value,strictOptions:{set value(m){j(c,_t,m,"f")}}.value,completionCommand:{set value(m){j(u,Ae,m,"f")}}.value,parseFn:{set value(m){j(f,Oe,m,"f")}}.value,parseContext:{set value(m){j(l,Ft,m,"f")}}.value}=d,g(this,K,"f").configObjects=p,g(this,Y,"f").unfreeze(),g(this,ce,"f").unfreeze(),g(this,fe,"f").unfreeze(),g(this,Re,"f").unfreeze()}[$i](e,t){return Dt(t,(n)=>(e(n),n))}getInternalMethods(){return{getCommandInstance:this[Oi].bind(this),getContext:this[Ii].bind(this),getHasOutput:this[Ti].bind(this),getLoggerInstance:this[Pi].bind(this),getParseContext:this[Ri].bind(this),getParserConfiguration:this[kt].bind(this),getUsageConfiguration:this[ki].bind(this),getUsageInstance:this[Mi].bind(this),getValidationInstance:this[Bi].bind(this),hasParseCallback:this[Un].bind(this),isGlobalContext:this[Ni].bind(this),postProcess:this[St].bind(this),reset:this[rr].bind(this),runValidation:this[or].bind(this),runYargsParserAndExecuteCommands:this[on].bind(this),setHasOutput:this[ji].bind(this)}}[Oi](){return g(this,fe,"f")}[Ii](){return g(this,rn,"f")}[Ti](){return g(this,$e,"f")}[Pi](){return g(this,wt,"f")}[Ri](){return g(this,Ft,"f")||{}}[Mi](){return g(this,Y,"f")}[Bi](){return g(this,ce,"f")}[Un](){return!!g(this,Oe,"f")}[Ni](){return g(this,Nn,"f")}[St](e,t,n,r){if(n)return e;if(re(e))return e;if(!t)e=this[Fi](e);if(this[kt]()["parse-positional-numbers"]||this[kt]()["parse-positional-numbers"]===void 0)e=this[Ai](e);if(r)e=mt(e,this,g(this,Re,"f").getMiddleware(),!1);return e}[rr](e={}){j(this,K,g(this,K,"f")||{},"f");let t={};t.local=g(this,K,"f").local||[],t.configObjects=g(this,K,"f").configObjects||[];let n={};t.local.forEach((o)=>{n[o]=!0,(e[o]||[]).forEach((i)=>{n[i]=!0})}),Object.assign(g(this,Ct,"f"),Object.keys(g(this,Xe,"f")).reduce((o,i)=>{let a=g(this,Xe,"f")[i].filter((c)=>!(c in n));if(a.length>0)o[i]=a;return o},{})),j(this,Xe,{},"f");let r=["array","boolean","string","skipValidation","count","normalize","number","hiddenOptions"],s=["narg","key","alias","default","defaultDescription","config","choices","demandedOptions","demandedCommands","deprecatedOptions"];if(r.forEach((o)=>{t[o]=(g(this,K,"f")[o]||[]).filter((i)=>!n[i])}),s.forEach((o)=>{t[o]=rt(g(this,K,"f")[o],(i)=>!n[i])}),t.envPrefix=g(this,K,"f").envPrefix,j(this,K,t,"f"),j(this,Y,g(this,Y,"f")?g(this,Y,"f").reset(n):di(this,g(this,H,"f")),"f"),j(this,ce,g(this,ce,"f")?g(this,ce,"f").reset(n):bi(this,g(this,Y,"f"),g(this,H,"f")),"f"),j(this,fe,g(this,fe,"f")?g(this,fe,"f").reset():ui(g(this,Y,"f"),g(this,ce,"f"),g(this,Re,"f"),g(this,H,"f")),"f"),!g(this,xe,"f"))j(this,xe,mi(this,g(this,Y,"f"),g(this,fe,"f"),g(this,H,"f")),"f");return g(this,Re,"f").reset(),j(this,Ae,null,"f"),j(this,me,"","f"),j(this,it,null,"f"),j(this,$e,!1,"f"),this.parsed=!1,this}[vi](e,t){return g(this,H,"f").path.relative(e,t)}[on](e,t,n,r=0,s=!1){var o,i,a,c;let u=!!n||s;e=e||g(this,at,"f"),g(this,K,"f").__=g(this,H,"f").y18n.__,g(this,K,"f").configuration=this[kt]();let f=!!g(this,K,"f").configuration["populate--"],l=Object.assign({},g(this,K,"f").configuration,{"populate--":!0}),d=g(this,H,"f").Parser.detailed(e,Object.assign({},g(this,K,"f"),{configuration:{"parse-positional-numbers":!1,...l}})),p=Object.assign(d.argv,g(this,Ft,"f")),m=void 0,h=d.aliases,y=!1,E=!1;if(Object.keys(p).forEach((F)=>{if(F===g(this,Me,"f")&&p[F])y=!0;else if(F===g(this,Ge,"f")&&p[F])E=!0}),p.$0=this.$0,this.parsed=d,r===0)g(this,Y,"f").clearCachedHelpMessage();try{if(this[Vs](),t)return this[St](p,f,!!n,!1);if(g(this,Me,"f")){if([g(this,Me,"f")].concat(h[g(this,Me,"f")]||[]).filter((I)=>I.length>1).includes(""+p._[p._.length-1]))p._.pop(),y=!0}j(this,Nn,!1,"f");let F=g(this,fe,"f").getCommands(),A=((o=g(this,xe,"f"))===null||o===void 0?void 0:o.completionKey)?[(i=g(this,xe,"f"))===null||i===void 0?void 0:i.completionKey,...(c=this.getAliases()[(a=g(this,xe,"f"))===null||a===void 0?void 0:a.completionKey])!==null&&c!==void 0?c:[]].some((B)=>Object.prototype.hasOwnProperty.call(p,B)):!1,k=y||A||s;if(p._.length){if(F.length){let B;for(let I=r||0,R;p._[I]!==void 0;I++)if(R=String(p._[I]),F.includes(R)&&R!==g(this,Ae,"f")){let V=g(this,fe,"f").runCommand(R,this,d,I+1,s,y||E||s);return this[St](V,f,!!n,!1)}else if(!B&&R!==g(this,Ae,"f")){B=R;break}if(!g(this,fe,"f").hasDefaultCommand()&&g(this,Ln,"f")&&B&&!k)g(this,ce,"f").recommendCommands(B,F)}if(g(this,Ae,"f")&&p._.includes(g(this,Ae,"f"))&&!A){if(g(this,Pe,"f"))ot(!0);this.showCompletionScript(),this.exit(0)}}if(g(this,fe,"f").hasDefaultCommand()&&!k){let B=g(this,fe,"f").runCommand(null,this,d,0,s,y||E||s);return this[St](B,f,!!n,!1)}if(A){if(g(this,Pe,"f"))ot(!0);e=[].concat(e);let B=e.slice(e.indexOf(`--${g(this,xe,"f").completionKey}`)+1);return g(this,xe,"f").getCompletion(B,(I,R)=>{if(I)throw new le(I.message);(R||[]).forEach((V)=>{g(this,wt,"f").log(V)}),this.exit(0)}),this[St](p,!f,!!n,!1)}if(!g(this,$e,"f")){if(y){if(g(this,Pe,"f"))ot(!0);u=!0,this.showHelp((B)=>{g(this,wt,"f").log(B),this.exit(0)})}else if(E){if(g(this,Pe,"f"))ot(!0);u=!0,g(this,Y,"f").showVersion("log"),this.exit(0)}}if(!u&&g(this,K,"f").skipValidation.length>0)u=Object.keys(p).some((B)=>g(this,K,"f").skipValidation.indexOf(B)>=0&&p[B]===!0);if(!u){if(d.error)throw new le(d.error.message);if(!A){let B=this[or](h,{},d.error);if(!n)m=mt(p,this,g(this,Re,"f").getMiddleware(),!0);if(m=this[$i](B,m!==null&&m!==void 0?m:p),re(m)&&!n)m=m.then(()=>mt(p,this,g(this,Re,"f").getMiddleware(),!1))}}}catch(F){if(F instanceof le)g(this,Y,"f").fail(F.message,F);else throw F}return this[St](m!==null&&m!==void 0?m:p,f,!!n,!0)}[or](e,t,n,r){let s={...this.getDemandedOptions()};return(o)=>{if(n)throw new le(n.message);g(this,ce,"f").nonOptionCount(o),g(this,ce,"f").requiredArguments(o,s);let i=!1;if(g(this,xt,"f"))i=g(this,ce,"f").unknownCommands(o);if(g(this,Et,"f")&&!i)g(this,ce,"f").unknownArguments(o,e,t,!!r);else if(g(this,_t,"f"))g(this,ce,"f").unknownArguments(o,e,{},!1,!1);g(this,ce,"f").limitedChoices(o),g(this,ce,"f").implications(o),g(this,ce,"f").conflicting(o)}}[ji](){j(this,$e,!0,"f")}[At](e){if(typeof e==="string")g(this,K,"f").key[e]=!0;else for(let t of e)g(this,K,"f").key[t]=!0}}function li(e){return!!e&&typeof e.getInternalMethods==="function"}var Tl=Li(zs),Ui=Tl;function Pl(e){return[...e.matchAll(/<https?:\/\/[^\s<>|]+(?:\|[^<>\r\n]*)?>|https?:\/\/[^\t\n\v\f\r <]+/gi)].map(([n])=>n).filter((n)=>!n.startsWith("<")&&(/[^\x00-\x7f]/.test(n)||n.includes(">")))}function Kn(e,t=!1,n=console.error){let r=Pl(e);if(!r.length)return;let s=`Ambiguous URL boundary: ${r.map((o)=>JSON.stringify(o)).join(", ")}. Put the URL on its own line, or wrap it as <url> / <url|label>. Use --allow-url-adjacent to warn only.`;if(!t)throw Error(s);n(`Warning: ${s}`)}import{existsSync as Jn,readFileSync as cr,writeFileSync as ir,mkdirSync as zi}from"node:fs";import{homedir as Rl}from"node:os";import{join as $t,dirname as ur}from"node:path";function lr(){return process.env.HOME||Rl()}function Hi(){return $t(lr(),".config","slack-cli","profiles.json")}function zn(){return $t(process.cwd(),".slack-cli","workspace")}function Hn(){return $t(lr(),".slack-cli","workspace")}function an(){let e=Hi();if(!Jn(e))return{profiles:{}};return JSON.parse(cr(e,"utf8"))}function Ml(e){let t=Hi();zi(ur(t),{recursive:!0}),ir(t,JSON.stringify(e,null,2)+`
82
+ `)}function Ht(e){if(!Jn(e))return;return cr(e,"utf8").trim()||void 0}function Ki(e,t){let n=ur(e);zi(n,{recursive:!0});let r=$t(n,".gitignore");if(!Jn(r))ir(r,`*
83
83
  `);ir(e,t+`
84
- `)}function Pl(e){let t={};for(let n of e.split(`
85
- `)){let r=n.trim();if(!r||r.startsWith("#"))continue;let s=r.indexOf("=");if(s===-1)continue;let i=r.slice(0,s).trim(),o=r.slice(s+1).trim();if(o.startsWith('"')&&o.endsWith('"')||o.startsWith("'")&&o.endsWith("'"))o=o.slice(1,-1);t[i]=o}return t}function Ko(e){if(!Un(e))return{};try{return Pl(ar(e,"utf8"))}catch{return{}}}function or(e,t){let n=ur(),r=e;while(!0){for(let o of[At(r,".slack-term",".env.local"),At(r,".env.local")]){let a=Ko(o);for(let c of t)if(a[c])return a[c]}if(r===n)break;let i=cr(r);if(i===r)break;r=i}let s=Ko(At(n,".slack-term",".env.local"));for(let i of t)if(s[i])return s[i];return}function lr(){let e=an(),t=Ht(Kn()),n=Ht(Jn()),r=t??n;return Object.entries(e.profiles).map(([s,i])=>({name:s,profile:i,current:s===r}))}function Ho(e){let t=an();if(!(e in t.profiles))throw Error(`Profile not found: ${e}`);delete t.profiles[e],Tl(t)}function qo(e,t=!1){let n=an();if(!(e in n.profiles))throw Error(`Profile not found: ${e}`);if(t)Uo(Jn(),e);else Uo(Kn(),e)}function fr(e){let n=an().profiles,r=Object.keys(n);if(e){let u=n[e];if(!u)throw Error(`Workspace "${e}" not found. Available: ${r.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&&r.length===0)return s;if(s&&r.length>0){let u=or(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 i=or(process.cwd(),["SLACK_TOKEN"]);if(i)return i;let o=process.env.SLACK_WORKSPACE;if(o){let u=n[o];if(!u)throw Error(`Workspace "${o}" not found. Available: ${r.join(", ")||"(none)"}`);return u.token}let a=Ht(Kn());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=Ht(Jn());if(c){let u=n[c];if(!u)throw Error(`Workspace "${c}" (from ~/.slack-cli/workspace) not found in profiles.`);return u.token}if(r.length>0)throw Error(`Workspace not selected (${r.join(", ")} available).
84
+ `)}function Bl(e){let t={};for(let n of e.split(`
85
+ `)){let r=n.trim();if(!r||r.startsWith("#"))continue;let s=r.indexOf("=");if(s===-1)continue;let o=r.slice(0,s).trim(),i=r.slice(s+1).trim();if(i.startsWith('"')&&i.endsWith('"')||i.startsWith("'")&&i.endsWith("'"))i=i.slice(1,-1);t[o]=i}return t}function Ji(e){if(!Jn(e))return{};try{return Bl(cr(e,"utf8"))}catch{return{}}}function ar(e,t){let n=lr(),r=e;while(!0){for(let i of[$t(r,".slack-term",".env.local"),$t(r,".env.local")]){let a=Ji(i);for(let c of t)if(a[c])return a[c]}if(r===n)break;let o=ur(r);if(o===r)break;r=o}let s=Ji($t(n,".slack-term",".env.local"));for(let o of t)if(s[o])return s[o];return}function fr(){let e=an(),t=Ht(zn()),n=Ht(Hn()),r=t??n;return Object.entries(e.profiles).map(([s,o])=>({name:s,profile:o,current:s===r}))}function qi(e){let t=an();if(!(e in t.profiles))throw Error(`Profile not found: ${e}`);delete t.profiles[e],Ml(t)}function Yi(e,t=!1){let n=an();if(!(e in n.profiles))throw Error(`Profile not found: ${e}`);if(t)Ki(Hn(),e);else Ki(zn(),e)}function dr(e){let n=an().profiles,r=Object.keys(n);if(e){let u=n[e];if(!u)throw Error(`Workspace "${e}" not found. Available: ${r.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&&r.length===0)return s;if(s&&r.length>0){let u=ar(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 o=ar(process.cwd(),["SLACK_TOKEN"]);if(o)return o;let i=process.env.SLACK_WORKSPACE;if(i){let u=n[i];if(!u)throw Error(`Workspace "${i}" not found. Available: ${r.join(", ")||"(none)"}`);return u.token}let a=Ht(zn());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=Ht(Hn());if(c){let u=n[c];if(!u)throw Error(`Workspace "${c}" (from ~/.slack-cli/workspace) not found in profiles.`);return u.token}if(r.length>0)throw Error(`Workspace not selected (${r.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 $t(){let e=process.env.SLACK_BOT_TOKEN;return e&&e.startsWith("xoxb-")?e:void 0}function Yo(e){let n=an().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=or(process.cwd(),["SLACK_COOKIE"]);if(s)return s;let i=process.env.SLACK_WORKSPACE;if(i)return n[i]?.cookie;let o=Ht(Kn());if(o)return n[o]?.cookie;let a=Ht(Jn());if(a)return n[a]?.cookie;return}class Ke extends Error{retryAfter;constructor(e){super(`Slack rate limited — retry after ${e}s`);this.name="RateLimitError",this.retryAfter=e}}function pr(){return(process.env.SLACK_API_BASE??"https://slack.com/api").replace(/\/$/,"")}async function Zo(e,t,n,r){let s={};if(r)s.Cookie=`d=${r}`;let i=await fetch(`${pr()}/${t}`,{...n,headers:{...n.headers??{},Authorization:`Bearer ${e}`,...s}});if(i.status===429){let a=parseInt(i.headers.get("retry-after")??"60",10);throw new Ke(isNaN(a)?60:a)}let o=await i.json();if(o.ok!==!0){let a=o.error??"unknown";if(a==="ratelimited")throw new Ke(60);if(a==="invalid_auth"&&e.startsWith("xoxc-")&&!r)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 ut(){let e=process.env.SLACK_BOT_TOKEN;return e&&e.startsWith("xoxb-")?e:void 0}function Xi(e){let n=an().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=ar(process.cwd(),["SLACK_COOKIE"]);if(s)return s;let o=process.env.SLACK_WORKSPACE;if(o)return n[o]?.cookie;let i=Ht(zn());if(i)return n[i]?.cookie;let a=Ht(Hn());if(a)return n[a]?.cookie;return}class Ke extends Error{retryAfter;constructor(e){super(`Slack rate limited — retry after ${e}s`);this.name="RateLimitError",this.retryAfter=e}}function pr(){return(process.env.SLACK_API_BASE??"https://slack.com/api").replace(/\/$/,"")}async function Qi(e,t,n,r){let s={};if(r)s.Cookie=`d=${r}`;let o=await fetch(`${pr()}/${t}`,{...n,headers:{...n.headers??{},Authorization:`Bearer ${e}`,...s}});if(o.status===429){let a=parseInt(o.headers.get("retry-after")??"60",10);throw new Ke(isNaN(a)?60:a)}let i=await o.json();if(i.ok!==!0){let a=i.error??"unknown";if(a==="ratelimited")throw new Ke(60);if(a==="invalid_auth"&&e.startsWith("xoxc-")&&!r)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 Rl(e,t,n,r){let s={};if(r)s.Cookie=`d=${r}`;let i=await fetch(`${pr()}/${t}`,{...n,headers:{...n.headers??{},Authorization:`Bearer ${e}`,...s}});if(i.status===429){let a=parseInt(i.headers.get("retry-after")??"60",10);throw new Ke(isNaN(a)?60:a)}let o=await i.json();if(o.ok!==!0){let a=o.error??"unknown";if(a==="ratelimited")throw new Ke(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 i}async function Nl(e,t,n,r){let s={};if(r)s.Cookie=`d=${r}`;let o=await fetch(`${pr()}/${t}`,{...n,headers:{...n.headers??{},Authorization:`Bearer ${e}`,...s}});if(o.status===429){let a=parseInt(o.headers.get("retry-after")??"60",10);throw new Ke(isNaN(a)?60:a)}let i=await o.json();if(i.ok!==!0){let a=i.error??"unknown";if(a==="ratelimited")throw new Ke(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")&&!r)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 Ml(e,t,n={},r){let s=new URLSearchParams({token:e,...n});return Rl(e,t,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s.toString()},r)}function we(e,t,n,r){let s=new URLSearchParams(n).toString();return Zo(e,`${t}?${s}`,{method:"GET"},r)}function hr(e,t,n,r){return Zo(e,t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)},r)}async function qt(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 Qo(e,t){let n={Authorization:`Bearer ${e}`};if(t)n.Cookie=`d=${t}`;let r=await fetch(`${pr()}/auth.test`,{method:"GET",headers:n});if(r.status===429){let o=parseInt(r.headers.get("retry-after")??"60",10);throw new Ke(isNaN(o)?60:o)}let s=r.headers.get("x-oauth-scopes")??"",i=await r.json();if(i.ok!==!0)throw Error(`Slack error on auth.test: ${i.error??"unknown"}`);return{userId:i.user_id??"",user:i.user??"",botId:i.bot_id??"",team:i.team??"",url:i.url??"",scopes:s.split(",").map((o)=>o.trim()).filter(Boolean)}}async function ea(e,t,n){let r=await we(e,"bots.info",{bot:t},n);return{appId:r.bot?.app_id??"",userId:r.bot?.user_id??""}}async function un(e,t,n=20,r,s,i,o){let a={channel:t,limit:String(n)};if(r!==void 0)a.oldest=r;if(s!==void 0)a.cursor=s;if(o)a.inclusive="true";return we(e,"conversations.history",a,i)}async function ta(e,t,n,r=50,s){return we(e,"conversations.replies",{channel:t,ts:n,limit:String(r)},s)}async function zn(e,t,n,r,s){await hr(e,"reactions.add",{channel:t,timestamp:n,name:r},s)}async function na(e,t,n,r){return((await we(e,"reactions.get",{channel:t,timestamp:n,full:"true"},r)).message?.reactions??[]).map((i)=>({name:String(i.name??""),users:Array.isArray(i.users)?i.users.map(String):[]}))}async function Hn(e,t,n,r,s){await hr(e,"reactions.remove",{channel:t,timestamp:n,name:r},s)}async function Bl(e,t,n){let s=(await hr(e,"conversations.open",{users:t},n)).channel?.id;if(!s)throw Error(`Failed to open DM with user ${t}`);return s}async function sa(e,t,n){let r="";while(!0){let s={types:"im",limit:"200"};if(r)s.cursor=r;let i=await we(e,"conversations.list",s,n);for(let o of i.channels??[])if(o.user===t)return String(o.id??"");if(r=i.response_metadata?.next_cursor??"",!r)break}return""}async function dr(e,t,n,r){let s=await sa(e,t,n);if(s)return s;let i=r?`${r} (${t})`:t;throw Error(`No existing DM with ${i}. Open it once in Slack first.`)}function cn(e){return e.toLowerCase().replace(/[-_\s]/g,"")}function Xo(e,t){let n=cn(e.name??""),r=cn(e.real_name??e.profile?.real_name??""),s=cn(e.profile?.display_name??"");return n===t||r===t||!!s&&s===t}var ra=200;async function Nl(e,t,n){let r=0,s=new Set,i="";while(!0){let f={limit:"200"};if(i)f.cursor=i;let l=await we(e,"users.list",f,n);for(let d of l.members??[]){if(r++,d.id)s.add(d.id);if(Xo(d,t))return{id:d.id??"",workspaceCount:r,connectCount:0,skipped:0,capped:!1}}if(i=l.response_metadata?.next_cursor??"",!i)break}let o=0,a=0,c=!1,u="";while(!0){let f={types:"im",limit:"200"};if(u)f.cursor=u;let l=await we(e,"conversations.list",f,n);for(let d of l.channels??[]){let p=d.user;if(!p||s.has(p))continue;if(o>=ra){c=!0;break}s.add(p),o++;let m;try{m=(await we(e,"users.info",{user:p},n)).user}catch(h){if(h instanceof Ke)throw h;a++;continue}if(m&&Xo(m,t))return{id:p,dm:String(d.id??""),workspaceCount:r,connectCount:o,skipped:a,capped:c}}if(c)break;if(u=l.response_metadata?.next_cursor??"",!u)break}return{id:"",workspaceCount:r,connectCount:o,skipped:a,capped:c}}function vl(e,t){if(t.workspaceCount===0)return Error(`Cannot resolve ${e}: users.list returned no members at all, so nothing could have matched.
101
+ Attach it with: slack auth chrome (macOS) or slack auth firefox`);throw Error(`Slack error on ${t}: ${a}`)}return i}function vl(e,t,n={},r){let s=new URLSearchParams({token:e,...n});return Nl(e,t,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s.toString()},r)}function be(e,t,n,r){let s=new URLSearchParams(n).toString();return Qi(e,`${t}?${s}`,{method:"GET"},r)}function gr(e,t,n,r){return Qi(e,t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)},r)}async function qt(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 ea(e,t){let n={Authorization:`Bearer ${e}`};if(t)n.Cookie=`d=${t}`;let r=await fetch(`${pr()}/auth.test`,{method:"GET",headers:n});if(r.status===429){let i=parseInt(r.headers.get("retry-after")??"60",10);throw new Ke(isNaN(i)?60:i)}let s=r.headers.get("x-oauth-scopes")??"",o=await r.json();if(o.ok!==!0)throw Error(`Slack error on auth.test: ${o.error??"unknown"}`);return{userId:o.user_id??"",user:o.user??"",botId:o.bot_id??"",team:o.team??"",url:o.url??"",scopes:s.split(",").map((i)=>i.trim()).filter(Boolean)}}async function ta(e,t,n){let r=await be(e,"bots.info",{bot:t},n);return{appId:r.bot?.app_id??"",userId:r.bot?.user_id??""}}async function un(e,t,n=20,r,s,o,i){let a={channel:t,limit:String(n)};if(r!==void 0)a.oldest=r;if(s!==void 0)a.cursor=s;if(i)a.inclusive="true";return be(e,"conversations.history",a,o)}async function na(e,t,n,r=50,s){return be(e,"conversations.replies",{channel:t,ts:n,limit:String(r)},s)}async function qn(e,t,n,r,s){await gr(e,"reactions.add",{channel:t,timestamp:n,name:r},s)}async function sa(e,t,n,r){return((await be(e,"reactions.get",{channel:t,timestamp:n,full:"true"},r)).message?.reactions??[]).map((o)=>({name:String(o.name??""),users:Array.isArray(o.users)?o.users.map(String):[]}))}async function Yn(e,t,n,r,s){await gr(e,"reactions.remove",{channel:t,timestamp:n,name:r},s)}async function jl(e,t,n){let s=(await gr(e,"conversations.open",{users:t},n)).channel?.id;if(!s)throw Error(`Failed to open DM with user ${t}`);return s}async function ra(e,t,n){let r="";while(!0){let s={types:"im",limit:"200"};if(r)s.cursor=r;let o=await be(e,"conversations.list",s,n);for(let i of o.channels??[])if(i.user===t)return String(i.id??"");if(r=o.response_metadata?.next_cursor??"",!r)break}return""}async function hr(e,t,n,r){let s=await ra(e,t,n);if(s)return s;let o=r?`${r} (${t})`:t;throw Error(`No existing DM with ${o}. Open it once in Slack first.`)}function cn(e){return e.toLowerCase().replace(/[-_\s]/g,"")}function Gi(e,t){let n=cn(e.name??""),r=cn(e.real_name??e.profile?.real_name??""),s=cn(e.profile?.display_name??"");return n===t||r===t||!!s&&s===t}var oa=200;async function Ll(e,t,n){let r=0,s=new Set,o="";while(!0){let f={limit:"200"};if(o)f.cursor=o;let l=await be(e,"users.list",f,n);for(let d of l.members??[]){if(r++,d.id)s.add(d.id);if(Gi(d,t))return{id:d.id??"",workspaceCount:r,connectCount:0,skipped:0,capped:!1}}if(o=l.response_metadata?.next_cursor??"",!o)break}let i=0,a=0,c=!1,u="";while(!0){let f={types:"im",limit:"200"};if(u)f.cursor=u;let l=await be(e,"conversations.list",f,n);for(let d of l.channels??[]){let p=d.user;if(!p||s.has(p))continue;if(i>=oa){c=!0;break}s.add(p),i++;let m;try{m=(await be(e,"users.info",{user:p},n)).user}catch(h){if(h instanceof Ke)throw h;a++;continue}if(m&&Gi(m,t))return{id:p,dm:String(d.id??""),workspaceCount:r,connectCount:i,skipped:a,capped:c}}if(c)break;if(u=l.response_metadata?.next_cursor??"",!u)break}return{id:"",workspaceCount:r,connectCount:i,skipped:a,capped:c}}function Wl(e,t){if(t.workspaceCount===0)return Error(`Cannot resolve ${e}: users.list returned no members at all, so nothing could have matched.
102
102
  `+`That is a token or scope fault, not a wrong handle — this says nothing about whether ${e} exists.
103
- Check who you are: slack auth ls`);let n=t.connectCount?`${t.workspaceCount} workspace account(s) and ${t.connectCount} Slack Connect DM partner(s)`:`${t.workspaceCount} workspace account(s)`,r=[];if(t.capped)r.push(`stopped after ${ra} Slack Connect DM partners, so there may be more`);if(t.skipped)r.push(`${t.skipped} DM partner profile(s) could not be read and were never compared`);return Error(`User not found: ${e} — searched ${n}, none matched.
103
+ Check who you are: slack auth ls`);let n=t.connectCount?`${t.workspaceCount} workspace account(s) and ${t.connectCount} Slack Connect DM partner(s)`:`${t.workspaceCount} workspace account(s)`,r=[];if(t.capped)r.push(`stopped after ${oa} Slack Connect DM partners, so there may be more`);if(t.skipped)r.push(`${t.skipped} DM partner profile(s) could not be read and were never compared`);return Error(`User not found: ${e} — searched ${n}, none matched.
104
104
  `+(r.length?`This search was incomplete: ${r.join("; ")}.
105
105
  `:"")+`Slack Connect people from another workspace are not in users.list, so if they never
106
106
  DMed you they cannot be found by name at all. Look them up and use their ID:
107
- slack user ls --external`)}function gr(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],r=t[2]&&t[3]?`${t[2]}.${t[3]}`:void 0,s=e.indexOf("?"),i=s>=0?new URLSearchParams(e.slice(s)):void 0,o=i?.get("thread_ts")??void 0,u={channel:i?.get("cid")??void 0??n};if(r)u.ts=r;if(o)u.threadTs=o;return u}function jl(e){return gr(e)?.channel}function Go(e){return/^[CDG][A-Z0-9]{8,}$/.test(e)}function Vo(e){return/^[UW][A-Z0-9]{6,}$/.test(e)}async function ia(e,t,n){let r=jl(t);if(r)return r;if(!t.startsWith("@")&&!t.startsWith("#")){if(Go(t))return t;if(Vo(t))return dr(e,t,n);throw Error(`Target must start with # or @ (or be a Slack URL/ID), got: ${t}`)}if(t.startsWith("#")&&Go(t.slice(1)))return t.slice(1);let s=t.startsWith("@"),i=t.slice(1),o=cn(i);if(s){if(Vo(i))return dr(e,i,n);let u=await we(e,"auth.test",{},n);if(o==="you"||o==="me"||cn(u.user??"")===o){let d=u.user_id;if(!d)throw Error("auth.test did not return user_id");return await sa(e,d,n)||Bl(e,d,n)}let l=await Nl(e,o,n);if(!l.id)throw vl(t,l);if(l.dm)return l.dm;return dr(e,l.id,n,t)}let a=i.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 qn(e,t,n){try{let r=await we(e,"users.info",{user:t},n),s=r.user?.profile?.display_name,i=s&&s.length>0?s:r.user?.real_name??r.user?.name??t,o=r.user?.name??t;return[i,o]}catch{return[t,t]}}async function Yn(e,t,n){try{let r=await we(e,"users.info",{user:t},n),s=r.user?.profile?.display_name;if(s&&s.length>0)return s;return r.user?.real_name??r.user?.name??t}catch{return t}}async function Xn(e,t){let n=[],r="";while(!0){let s={limit:"200"};if(r)s.cursor=r;let i=await we(e,"users.list",s,t);if(n.push(...i.members??[]),r=i.response_metadata?.next_cursor??"",!r)break}return{members:n}}async function mr(e,t,n){let r=[],s="";while(!0){let i={channel:t,limit:"200"};if(s)i.cursor=s;let o=await we(e,"conversations.members",i,n);if(r.push(...o.members??[]),s=o.response_metadata?.next_cursor??"",!s)break}return r}async function Dr(e,t,n){return we(e,"users.info",{user:t},n)}async function oa(e,t,n){return we(e,"conversations.info",{channel:t},n)}async function aa(e,t){let n=await Ml(e,"client.boot",{},t),r=typeof n.url==="string"?n.url:void 0;if(!r){let i=Object.keys(n).join(", ");throw Error(`client.boot did not return a WebSocket URL. Keys: ${i}`)}let s=n.self&&typeof n.self==="object"&&!Array.isArray(n.self)?n.self:{};return{wsUrl:r,selfId:typeof s.id==="string"?s.id:""}}var Ll=["chat:write","im:write"],Wl=["im:history","im:read"];async function Gn(e){let{userId:t,botId:n,team:r,scopes:s}=await Qo(e),i="";if(n)try{i=(await ea(e,n)).appId}catch{i=""}let o=(u)=>s.includes(u),a=Ll.filter((u)=>!o(u)),c=Wl.filter((u)=>!o(u));return{canSend:a.length===0,canReceiveReplies:c.length===0,ok:a.length===0&&c.length===0,botUserId:t,appId:i,team:r,grantedScopes:s,missingSendScopes:a,missingReplyScopes:c}}function ca(e){return["",` Bot user: ${e.botUserId||"(unknown)"}`,` App ID: ${e.appId||"(unknown — bots.info unavailable)"}`,` Granted scopes: ${e.grantedScopes.join(", ")||"(none reported)"}`]}function Vn(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,...ca(e)]}let r=[];if(!e.canSend)r.push(`⚠ This bot CANNOT send DMs — missing scope(s): ${e.missingSendScopes.join(", ")}.`);else r.push("⚠ This bot can send DMs, but the user's replies will NOT be readable.");return r.push(" Make escalation DMs two-way:"),r.push(` 1. ${n} → App Home → enable "Messages Tab" and check`),r.push(' "Allow users to send Slash commands and messages".'),r.push(` 2. OAuth & Permissions → add Bot Token Scopes: ${[...e.missingSendScopes,...e.missingReplyScopes].join(", ")}`),r.push(" 3. Reinstall the app to apply the new scopes."),t?r:[...r,...ca(e)]}import{createInterface as It}from"node:readline/promises";import{join as xr}from"node:path";import{homedir as ef}from"node:os";import{existsSync as yr,readFileSync as wr,writeFileSync as la,mkdirSync as fa}from"node:fs";import{homedir as Ul}from"node:os";import{join as br,dirname as da}from"node:path";function pa(){return process.env.HOME||Ul()}function ha(){return br(pa(),".config","slack-cli","profiles.json")}function Kl(){return br(process.cwd(),".slack-cli","workspace")}function Jl(){return br(pa(),".slack-cli","workspace")}function Fr(){let e=ha();if(!yr(e))return{profiles:{}};return JSON.parse(wr(e,"utf8"))}function ga(e){let t=ha();fa(da(t),{recursive:!0}),la(t,JSON.stringify(e,null,2)+`
108
- `)}function ua(e){if(!yr(e))return;return wr(e,"utf8").trim()||void 0}function ma(e,t){fa(da(e),{recursive:!0});let n=yr(e)?wr(e,"utf8"):"",r=n?n.split(`
109
- `):[];for(let[s,i]of Object.entries(t)){let o=r.findIndex((c)=>{let u=c.trim();return u.startsWith(s+"=")||u.startsWith(s+" =")}),a=`${s}=${i}`;if(o!==-1)r[o]=a;else r.push(a)}la(e,r.join(`
107
+ slack user ls --external`)}function mr(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],r=t[2]&&t[3]?`${t[2]}.${t[3]}`:void 0,s=e.indexOf("?"),o=s>=0?new URLSearchParams(e.slice(s)):void 0,i=o?.get("thread_ts")??void 0,u={channel:o?.get("cid")??void 0??n};if(r)u.ts=r;if(i)u.threadTs=i;return u}function Ul(e){return mr(e)?.channel}function Vi(e){return/^[CDG][A-Z0-9]{8,}$/.test(e)}function Zi(e){return/^[UW][A-Z0-9]{6,}$/.test(e)}async function ia(e,t,n){let r=Ul(t);if(r)return r;if(!t.startsWith("@")&&!t.startsWith("#")){if(Vi(t))return t;if(Zi(t))return hr(e,t,n);throw Error(`Target must start with # or @ (or be a Slack URL/ID), got: ${t}`)}if(t.startsWith("#")&&Vi(t.slice(1)))return t.slice(1);let s=t.startsWith("@"),o=t.slice(1),i=cn(o);if(s){if(Zi(o))return hr(e,o,n);let u=await be(e,"auth.test",{},n);if(i==="you"||i==="me"||cn(u.user??"")===i){let d=u.user_id;if(!d)throw Error("auth.test did not return user_id");return await ra(e,d,n)||jl(e,d,n)}let l=await Ll(e,i,n);if(!l.id)throw Wl(t,l);if(l.dm)return l.dm;return hr(e,l.id,n,t)}let a=o.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 Xn(e,t,n){try{let r=await be(e,"users.info",{user:t},n),s=r.user?.profile?.display_name,o=s&&s.length>0?s:r.user?.real_name??r.user?.name??t,i=r.user?.name??t;return[o,i]}catch{return[t,t]}}async function Gn(e,t,n){try{let r=await be(e,"users.info",{user:t},n),s=r.user?.profile?.display_name;if(s&&s.length>0)return s;return r.user?.real_name??r.user?.name??t}catch{return t}}async function Vn(e,t){let n=[],r="";while(!0){let s={limit:"200"};if(r)s.cursor=r;let o=await be(e,"users.list",s,t);if(n.push(...o.members??[]),r=o.response_metadata?.next_cursor??"",!r)break}return{members:n}}async function Dr(e,t,n){let r=[],s="";while(!0){let o={channel:t,limit:"200"};if(s)o.cursor=s;let i=await be(e,"conversations.members",o,n);if(r.push(...i.members??[]),s=i.response_metadata?.next_cursor??"",!s)break}return r}async function yr(e,t,n){return be(e,"users.info",{user:t},n)}async function aa(e,t,n){return be(e,"conversations.info",{channel:t},n)}async function ca(e,t){let n=await vl(e,"client.boot",{},t),r=typeof n.url==="string"?n.url:void 0;if(!r){let o=Object.keys(n).join(", ");throw Error(`client.boot did not return a WebSocket URL. Keys: ${o}`)}let s=n.self&&typeof n.self==="object"&&!Array.isArray(n.self)?n.self:{};return{wsUrl:r,selfId:typeof s.id==="string"?s.id:""}}var Kl=["chat:write","im:write"],Jl=["im:history","im:read"];async function Zn(e){let{userId:t,botId:n,team:r,scopes:s}=await ea(e),o="";if(n)try{o=(await ta(e,n)).appId}catch{o=""}let i=(u)=>s.includes(u),a=Kl.filter((u)=>!i(u)),c=Jl.filter((u)=>!i(u));return{canSend:a.length===0,canReceiveReplies:c.length===0,ok:a.length===0&&c.length===0,botUserId:t,appId:o,team:r,grantedScopes:s,missingSendScopes:a,missingReplyScopes:c}}function ua(e){return["",` Bot user: ${e.botUserId||"(unknown)"}`,` App ID: ${e.appId||"(unknown — bots.info unavailable)"}`,` Granted scopes: ${e.grantedScopes.join(", ")||"(none reported)"}`]}function Qn(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,...ua(e)]}let r=[];if(!e.canSend)r.push(`⚠ This bot CANNOT send DMs — missing scope(s): ${e.missingSendScopes.join(", ")}.`);else r.push("⚠ This bot can send DMs, but the user's replies will NOT be readable.");return r.push(" Make escalation DMs two-way:"),r.push(` 1. ${n} → App Home → enable "Messages Tab" and check`),r.push(' "Allow users to send Slash commands and messages".'),r.push(` 2. OAuth & Permissions → add Bot Token Scopes: ${[...e.missingSendScopes,...e.missingReplyScopes].join(", ")}`),r.push(" 3. Reinstall the app to apply the new scopes."),t?r:[...r,...ua(e)]}import{createInterface as It}from"node:readline/promises";import{join as _r}from"node:path";import{homedir as sf}from"node:os";import{existsSync as br,readFileSync as wr,writeFileSync as fa,mkdirSync as da}from"node:fs";import{homedir as zl}from"node:os";import{join as Fr,dirname as ha}from"node:path";function pa(){return process.env.HOME||zl()}function ga(){return Fr(pa(),".config","slack-cli","profiles.json")}function Hl(){return Fr(process.cwd(),".slack-cli","workspace")}function ql(){return Fr(pa(),".slack-cli","workspace")}function Cr(){let e=ga();if(!br(e))return{profiles:{}};return JSON.parse(wr(e,"utf8"))}function ma(e){let t=ga();da(ha(t),{recursive:!0}),fa(t,JSON.stringify(e,null,2)+`
108
+ `)}function la(e){if(!br(e))return;return wr(e,"utf8").trim()||void 0}function Da(e,t){da(ha(e),{recursive:!0});let n=br(e)?wr(e,"utf8"):"",r=n?n.split(`
109
+ `):[];for(let[s,o]of Object.entries(t)){let i=r.findIndex((c)=>{let u=c.trim();return u.startsWith(s+"=")||u.startsWith(s+" =")}),a=`${s}=${o}`;if(i!==-1)r[i]=a;else r.push(a)}fa(e,r.join(`
110
110
  `).trimEnd()+`
111
- `)}function Zn(){let e=Fr(),t=ua(Kl()),n=ua(Jl()),r=t??n;return Object.entries(e.profiles).map(([s,i])=>({name:s,profile:i,current:s===r}))}function Cr(e,t){let n=Fr();n.profiles[e]=t,ga(n)}function Er(e,t){let n=Fr();if(!(e in n.profiles))throw Error(`Profile not found: ${e}`);n.profiles[e].cookie=t,ga(n)}import{readdirSync as Qn,readFileSync as ln,existsSync as Ot,copyFileSync as Da,unlinkSync as ya}from"node:fs";import{homedir as es,tmpdir as wa}from"node:os";import{join as he,dirname as zl}from"node:path";import{pbkdf2Sync as ba,createDecipheriv as Fa}from"node:crypto";import{execSync as Ca}from"node:child_process";function Hl(){let e=es();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 ql(){let e=es();if(process.platform==="darwin")return he(e,"Library","Application Support","Slack","Cookies");return""}function Yl(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),r=e.slice(35),s=Fa("aes-128-cbc",t,n);return s.setAutoPadding(!0),Buffer.concat([s.update(r),s.final()]).toString("utf8")}function Xl(){if(process.platform!=="darwin")return;let e=ql();if(!Ot(e))return;let t;try{t=Ca('security find-generic-password -w -s "Slack Safe Storage" -a "Slack Key"',{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trimEnd()}catch{return}let n=ba(t,"saltysalt",1003,16,"sha1");try{let{default:r}=As("bun:sqlite"),s=new r(e,{readonly:!0}),i=s.prepare("SELECT encrypted_value FROM cookies WHERE name='d' AND host_key LIKE '%slack%'").get();if(s.close(),!i)return;return Yl(Buffer.from(i.encrypted_value),n)}catch{return}}async function Ea(){let e=Hl();if(!Ot(e))throw Error(`Slack desktop app LevelDB not found at:
111
+ `)}function es(){let e=Cr(),t=la(Hl()),n=la(ql()),r=t??n;return Object.entries(e.profiles).map(([s,o])=>({name:s,profile:o,current:s===r}))}function Er(e,t){let n=Cr();n.profiles[e]=t,ma(n)}function xr(e,t){let n=Cr();if(!(e in n.profiles))throw Error(`Profile not found: ${e}`);n.profiles[e].cookie=t,ma(n)}import{readdirSync as ts,readFileSync as ln,existsSync as Ot,copyFileSync as ya,unlinkSync as ba}from"node:fs";import{homedir as ns,tmpdir as wa}from"node:os";import{join as pe,dirname as Yl}from"node:path";import{pbkdf2Sync as Fa,createDecipheriv as Ca}from"node:crypto";import{execSync as Ea}from"node:child_process";function Xl(){let e=ns();if(process.platform==="darwin")return pe(e,"Library","Application Support","Slack","Local Storage","leveldb");if(process.platform==="linux")return pe(e,".config","Slack","Local Storage","leveldb");if(process.platform==="win32"){let t=process.env.APPDATA??pe(e,"AppData","Roaming");return pe(t,"Slack","Local Storage","leveldb")}throw Error(`Unsupported platform: ${process.platform}`)}function Gl(){let e=ns();if(process.platform==="darwin")return pe(e,"Library","Application Support","Slack","Cookies");return""}function Vl(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),r=e.slice(35),s=Ca("aes-128-cbc",t,n);return s.setAutoPadding(!0),Buffer.concat([s.update(r),s.final()]).toString("utf8")}function Zl(){if(process.platform!=="darwin")return;let e=Gl();if(!Ot(e))return;let t;try{t=Ea('security find-generic-password -w -s "Slack Safe Storage" -a "Slack Key"',{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trimEnd()}catch{return}let n=Fa(t,"saltysalt",1003,16,"sha1");try{let{default:r}=$s("bun:sqlite"),s=new r(e,{readonly:!0}),o=s.prepare("SELECT encrypted_value FROM cookies WHERE name='d' AND host_key LIKE '%slack%'").get();if(s.close(),!o)return;return Vl(Buffer.from(o.encrypted_value),n)}catch{return}}async function xa(){let e=Xl();if(!Ot(e))throw Error(`Slack desktop app LevelDB not found at:
112
112
  ${e}
113
- 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=ln(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),p=Math.min(c.length,u.index+2000),m=c.slice(d,p),h=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},A=h?.[1]??E?.url,_=y?.[1]??E?.teamName;if(A)F.url=A;if(_)F.teamName=_;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 p="";while(l<c.length&&c.charCodeAt(l)>=48&&c.charCodeAt(l)<=57)p+=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 h=`${u[0]}${p}-${m}`;n.set(f,{token:h,teamId:f})}}let s=Qn(e).filter((a)=>a.endsWith(".ldb")||a.endsWith(".log")).map((a)=>{try{return ln(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 i=Xl(),o=[...n.values()];if(i)for(let a of o)a.cookie=i;return o}function Gl(e,t){let n=(r,s)=>{try{let i=Fa("aes-128-cbc",t,r);i.setAutoPadding(!0);let o=Buffer.concat([i.update(s),i.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 Vl(e,t){let n=(r,s)=>{if(r&&s)return`${r} (${s})`;return r||s||t};try{let s=JSON.parse(ln(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(ln(he(e,t,"Preferences"),"utf8")).profile;return n(s?.name??"",s?.user_name??"")}catch{return t}}function xa(){if(process.platform!=="darwin")return{candidates:[],totalProfiles:0};let e=he(es(),"Library","Application Support","Google","Chrome");if(!Ot(e))return{candidates:[],totalProfiles:0};let t;try{t=Ca('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=ba(t,"saltysalt",1003,16,"sha1"),r=["Default",...Qn(e).filter((i)=>i.startsWith("Profile "))],s=[];for(let i of r){let o=he(e,i,"Cookies");if(!Ot(o))continue;let a=he(wa(),`slack-chrome-cookies-${Date.now()}-${i}.db`);try{Da(o,a);let{default:c}=As("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 p=Gl(l,n);if(!p)continue;s.push({profileDir:i,profileName:Vl(e,i),cookie:p})}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{ya(a)}catch{}}}return{candidates:s,totalProfiles:r.length}}function Zl(){let e=es();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 Ql(e){let t=he(zl(e),"profiles.ini"),n={};if(!Ot(t))return n;try{let r=ln(t,"utf8"),s="",i="";for(let o of r.split(`
114
- `)){let a=o.trim();if(a.startsWith("[")){s="",i="";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")i=f.split(/[\\/]/).pop()??f;if(s&&i)n[i]=s,s="",i=""}}catch{}return n}function _a(){let e=Zl();if(!e||!Ot(e))return[];let t=Ql(e),n=[],r;try{r=Qn(e)}catch{return[]}for(let s of r){let i=he(e,s,"cookies.sqlite");if(!Ot(i))continue;let o=he(wa(),`slack-firefox-cookies-${Date.now()}-${s}.db`);try{Da(i,o);let{default:a}=As("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{ya(o)}catch{}}}return n}var tf=["search:read","channels:history","groups:history","im:history","mpim:history","channels:read","groups:read","im:read","mpim:read","users:read","chat:write","files:write"],nf=["channels:history","groups:history","im:history","mpim:history","channels:read","groups:read","im:read","mpim:read","users:read","chat:write","files:write"];function ts(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function sf(){return JSON.stringify({display_information:{name:"slack-term"},oauth_config:{scopes:{user:tf}},settings:{org_deploy_enabled:!1,socket_mode_enabled:!1,token_rotation_enabled:!1}},null,2)}function rf(){return JSON.stringify({display_information:{name:"slack-term"},features:{bot_user:{display_name:"slack-term",always_online:!1}},oauth_config:{scopes:{bot:nf}},settings:{org_deploy_enabled:!1,socket_mode_enabled:!1,token_rotation_enabled:!1}},null,2)}async function Tt(e,t){return(await e.question(t)).trim()}async function Pt(e,t,n,r){console.error("Verifying token...");let s=await qt(t),i=ts(s.team),o;if(n)o=n;else if(e)o=await Tt(e,`Workspace name [${i}]: `)||i;else o=i;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 Tt(e,"Choice [1/2/3/4, Enter=1]: ");if(c==="2")a=xr(process.cwd(),".slack-term",".env.local");else if(c==="3")a=xr(ef(),".slack-term",".env.local");else if(c==="4")a=null;else a=xr(process.cwd(),".env.local")}if(a===null)if(Cr(o,{token:t,...s,...r?{cookie:r}:{}}),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(r)c.SLACK_COOKIE=r;ma(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 of(e){console.error("Scanning Slack desktop app...");let t=await Ea();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],r=n.teamName??n.teamId;console.log(`Found workspace: ${r}${n.cookie?" (+ xoxd cookie)":""}`),await Pt(e,n.token,ts(r),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 r=n.teamName??n.teamId,s=ts(r);Cr(s,{token:n.token,team:r,teamId:n.teamId,url:n.url??"",user:"",...n.cookie?{cookie:n.cookie}:{}}),console.log(`Added workspace "${s}": ${r}${n.cookie?" + xoxd cookie":""}`)}if(console.log(""),t.length===1){let n=ts(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 ka(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 Tt(e,"Choice [1/2]: ")==="2"?"bot":"user",r=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 ${r})`),console.log("");let i=await Tt(e,"Paste your token: ");if(!i)console.error("No token provided."),process.exit(1);if(!i.startsWith(r))console.error(`Expected a ${r} token, got: ${i.slice(0,10)}...`),process.exit(1);await Pt(e,i)}async function ns(e,t){let n=t==="user"?sf():rf(),r=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 -> ${r}`),console.log("");let i=await Tt(e,"Paste your token: ");if(!i)console.error("No token provided."),process.exit(1);if(!i.startsWith(s))console.error(`Expected a ${s} token, got: ${i.slice(0,10)}...`),process.exit(1);await Pt(e,i)}async function Sa(e={}){if(process.platform!=="darwin")console.error("Chrome cookie extraction is only supported on macOS."),process.exit(1);let t=Zn();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=It({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(`
113
+ Is Slack installed and opened at least once?`);let t=ts(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=ln(pe(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),p=Math.min(c.length,u.index+2000),m=c.slice(d,p),h=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},A=h?.[1]??E?.url,k=y?.[1]??E?.teamName;if(A)F.url=A;if(k)F.teamName=k;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 p="";while(l<c.length&&c.charCodeAt(l)>=48&&c.charCodeAt(l)<=57)p+=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 h=`${u[0]}${p}-${m}`;n.set(f,{token:h,teamId:f})}}let s=ts(e).filter((a)=>a.endsWith(".ldb")||a.endsWith(".log")).map((a)=>{try{return ln(pe(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 o=Zl(),i=[...n.values()];if(o)for(let a of i)a.cookie=o;return i}function Ql(e,t){let n=(r,s)=>{try{let o=Ca("aes-128-cbc",t,r);o.setAutoPadding(!0);let i=Buffer.concat([o.update(s),o.final()]).toString("utf8");return i.startsWith("xoxd-")?i: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 ef(e,t){let n=(r,s)=>{if(r&&s)return`${r} (${s})`;return r||s||t};try{let s=JSON.parse(ln(pe(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(ln(pe(e,t,"Preferences"),"utf8")).profile;return n(s?.name??"",s?.user_name??"")}catch{return t}}function _a(){if(process.platform!=="darwin")return{candidates:[],totalProfiles:0};let e=pe(ns(),"Library","Application Support","Google","Chrome");if(!Ot(e))return{candidates:[],totalProfiles:0};let t;try{t=Ea('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=Fa(t,"saltysalt",1003,16,"sha1"),r=["Default",...ts(e).filter((o)=>o.startsWith("Profile "))],s=[];for(let o of r){let i=pe(e,o,"Cookies");if(!Ot(i))continue;let a=pe(wa(),`slack-chrome-cookies-${Date.now()}-${o}.db`);try{ya(i,a);let{default:c}=$s("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 p=Ql(l,n);if(!p)continue;s.push({profileDir:o,profileName:ef(e,o),cookie:p})}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{ba(a)}catch{}}}return{candidates:s,totalProfiles:r.length}}function tf(){let e=ns();if(process.platform==="darwin")return pe(e,"Library","Application Support","Firefox","Profiles");if(process.platform==="linux")return pe(e,".mozilla","firefox");if(process.platform==="win32")return pe(process.env.APPDATA??pe(e,"AppData","Roaming"),"Mozilla","Firefox","Profiles");return""}function nf(e){let t=pe(Yl(e),"profiles.ini"),n={};if(!Ot(t))return n;try{let r=ln(t,"utf8"),s="",o="";for(let i of r.split(`
114
+ `)){let a=i.trim();if(a.startsWith("[")){s="",o="";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")o=f.split(/[\\/]/).pop()??f;if(s&&o)n[o]=s,s="",o=""}}catch{}return n}function ka(){let e=tf();if(!e||!Ot(e))return[];let t=nf(e),n=[],r;try{r=ts(e)}catch{return[]}for(let s of r){let o=pe(e,s,"cookies.sqlite");if(!Ot(o))continue;let i=pe(wa(),`slack-firefox-cookies-${Date.now()}-${s}.db`);try{ya(o,i);let{default:a}=$s("bun:sqlite"),c=new a(i,{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{ba(i)}catch{}}}return n}var rf=["search:read","channels:history","groups:history","im:history","mpim:history","channels:read","groups:read","im:read","mpim:read","users:read","chat:write","files:write"],of=["channels:history","groups:history","im:history","mpim:history","channels:read","groups:read","im:read","mpim:read","users:read","chat:write","files:write"];function ss(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function af(){return JSON.stringify({display_information:{name:"slack-term"},oauth_config:{scopes:{user:rf}},settings:{org_deploy_enabled:!1,socket_mode_enabled:!1,token_rotation_enabled:!1}},null,2)}function cf(){return JSON.stringify({display_information:{name:"slack-term"},features:{bot_user:{display_name:"slack-term",always_online:!1}},oauth_config:{scopes:{bot:of}},settings:{org_deploy_enabled:!1,socket_mode_enabled:!1,token_rotation_enabled:!1}},null,2)}async function Tt(e,t){return(await e.question(t)).trim()}async function Pt(e,t,n,r){console.error("Verifying token...");let s=await qt(t),o=ss(s.team),i;if(n)i=n;else if(e)i=await Tt(e,`Workspace name [${o}]: `)||o;else i=o;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 Tt(e,"Choice [1/2/3/4, Enter=1]: ");if(c==="2")a=_r(process.cwd(),".slack-term",".env.local");else if(c==="3")a=_r(sf(),".slack-term",".env.local");else if(c==="4")a=null;else a=_r(process.cwd(),".env.local")}if(a===null)if(Er(i,{token:t,...s,...r?{cookie:r}:{}}),console.log(`Saved workspace "${i}" 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 ${i}`);else{let c={SLACK_TOKEN:t};if(r)c.SLACK_COOKIE=r;Da(a,c),console.log(`Saved token to ${a}`),console.log(" SLACK_TOKEN will be picked up automatically in this directory tree.")}return i}async function uf(e){console.error("Scanning Slack desktop app...");let t=await xa();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],r=n.teamName??n.teamId;console.log(`Found workspace: ${r}${n.cookie?" (+ xoxd cookie)":""}`),await Pt(e,n.token,ss(r),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 r=n.teamName??n.teamId,s=ss(r);Er(s,{token:n.token,team:r,teamId:n.teamId,url:n.url??"",user:"",...n.cookie?{cookie:n.cookie}:{}}),console.log(`Added workspace "${s}": ${r}${n.cookie?" + xoxd cookie":""}`)}if(console.log(""),t.length===1){let n=ss(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 Sa(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 Tt(e,"Choice [1/2]: ")==="2"?"bot":"user",r=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 ${r})`),console.log("");let o=await Tt(e,"Paste your token: ");if(!o)console.error("No token provided."),process.exit(1);if(!o.startsWith(r))console.error(`Expected a ${r} token, got: ${o.slice(0,10)}...`),process.exit(1);await Pt(e,o)}async function rs(e,t){let n=t==="user"?af():cf(),r=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 -> ${r}`),console.log("");let o=await Tt(e,"Paste your token: ");if(!o)console.error("No token provided."),process.exit(1);if(!o.startsWith(s))console.error(`Expected a ${s} token, got: ${o.slice(0,10)}...`),process.exit(1);await Pt(e,o)}async function Aa(e={}){if(process.platform!=="darwin")console.error("Chrome cookie extraction is only supported on macOS."),process.exit(1);let t=es();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=It({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(`
115
115
  Workspace "${n}" uses a bot token (xoxb-). A Chrome session cookie only
116
116
  `+`augments a user session token (xoxc-) — it has no effect on a bot token, so user-level
117
- `+"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,i;try{({candidates:s,totalProfiles:i}=xa())}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 ${i} profile${i!==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&&i<=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 ${i} Chrome profiles:`:`Found ${s.length} Slack sessions across ${i} Chrome profiles:`;console.log(a),s.forEach((d,p)=>console.log(` ${p+1}) ${d.profileName} [${d.profileDir}]`)),console.log("");let c=It({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}Er(n,o),console.log(`Saved xoxd cookie to workspace "${n}".`),console.log("RTM WebSocket mode is now available: slack tail @you")}async function Aa(e={}){let t=Zn();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 i=t.find((o)=>o.current);if(i)n=i.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=It({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 r=_a();if(r.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(r.length===1)s=r[0].cookie,console.log(`Found session in Firefox profile: ${r[0].profileName}`);else{console.log("Multiple Firefox profiles have a Slack session. Choose one:"),r.forEach((c,u)=>console.log(` ${u+1}) ${c.profileName} [${c.profileDir}]`));let i=It({input:process.stdin,output:process.stdout}),o=(await i.question("Choice: ")).trim();i.close();let a=parseInt(o,10)-1;if(isNaN(a)||a<0||a>=r.length)console.error("Invalid choice."),process.exit(1);s=r[a].cookie}Er(n,s),console.log(`Saved xoxd cookie to workspace "${n}".`),console.log("RTM WebSocket mode is now available: slack tail @you")}async function $a(e={}){if(e.token){await Pt(null,e.token,e.name);return}if(!process.stdin.isTTY){let n=[];for await(let s of process.stdin)n.push(s);let r=Buffer.concat(n).toString("utf8").trim();if(!r)console.error("No token provided on stdin."),process.exit(1);await Pt(null,r,e.name);return}let t=It({input:process.stdin,output:process.stdout});try{await ka(t)}finally{t.close()}}async function Oa(e={}){let t=It({input:process.stdin,output:process.stdout});try{if(e.bot!==void 0){await ns(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 Tt(t,"Choice [1/2, Enter=1]: ");await ns(t,n==="2"?"bot":"user")}finally{t.close()}}async function ss(e={}){let t=Zn();if(t.length>0){console.log("Currently logged in:");for(let{name:r,profile:s,current:i}of t)console.log(` ${i?"*":" "} ${r} ${s.team} (${s.user||"unknown"})`);console.log(""),console.log("Adding another workspace:"),console.log("")}if(e.token){await Pt(null,e.token,e.name);return}if(!process.stdin.isTTY){let r=[];for await(let i of process.stdin)r.push(i);let s=Buffer.concat(r).toString("utf8").trim();if(!s)console.error("No token provided on stdin."),process.exit(1);await Pt(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=It({input:process.stdin,output:process.stdout});try{let r=await Tt(n,"Choice [1/2/3/4]: ");if(console.log(""),r==="1")await of(n);else if(r==="2")await ka(n);else if(r==="3")await ns(n,"user");else if(r==="4")await ns(n,"bot");else console.error(`Invalid choice: "${r}". Enter 1, 2, 3, or 4.`),process.exit(1)}finally{n.close()}}async function rs(e,t,n,r){let s=t,i=[],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)i.push(l);a=c+1}for(let c of i){if(!n.has(c))n.set(c,await Yn(e,c,r));let u=n.get(c)??c;s=s.replaceAll(`<@${c}>`,`@${u}`),s=s.replace(new RegExp(`<@${c}\\|[^>]*>`,"g"),`@${u}`)}return s}function is(e){return e.replace(/<!date\^(\d+)\^[^|>]*(?:\|([^>]*))?>/g,(t,n,r)=>{let s=Number(n);if(!Number.isFinite(s))return r??"date";let i=new Date(s*1000);if(Number.isNaN(i.getTime()))return r??"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[i.getUTCDay()]??"",u=a[i.getUTCMonth()]??"";return`${c}, ${u} ${String(i.getUTCDate()).padStart(2,"0")}, ${i.getUTCFullYear()}`})}function Ta(e){let t=typeof e.ts==="string"?e.ts:"",n=typeof e.thread_ts==="string"?e.thread_ts:"";return n!==""&&n!==t}function af(e){let[t,n="000000"]=e.split("."),r=new Date(Number(t)*1000),s=r.getUTCFullYear(),i=String(r.getUTCMonth()+1).padStart(2,"0"),o=String(r.getUTCDate()).padStart(2,"0"),a=String(r.getUTCHours()).padStart(2,"0"),c=String(r.getUTCMinutes()).padStart(2,"0"),u=String(r.getUTCSeconds()).padStart(2,"0"),f=n.padEnd(6,"0").slice(0,6);return`${s}-${i}-${o}T${a}:${c}:${u}.${f}`}async function cf(e,t,n){let r=typeof t.ts==="string"?t.ts:"0.000000",s=af(r),i="?";if(typeof t.user==="string"){let l=t.user,d="@"+l;if(!n.has(d)){let[,p]=await qn(e,l);n.set(d,p)}i=n.get(d)??l}else if(typeof t.username==="string")i=t.username;let o=typeof t.text==="string"?t.text:"",c=is(await rs(e,o,n)).split(`
117
+ `+"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,o;try{({candidates:s,totalProfiles:o}=_a())}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 ${o} profile${o!==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 i;if(s.length===1&&o<=1)i=s[0].cookie,console.log(`Found session in Chrome profile: ${s[0].profileName}`);else{let a=s.length===1?`Found 1 Slack session across ${o} Chrome profiles:`:`Found ${s.length} Slack sessions across ${o} Chrome profiles:`;console.log(a),s.forEach((d,p)=>console.log(` ${p+1}) ${d.profileName} [${d.profileDir}]`)),console.log("");let c=It({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);i=s[l].cookie}xr(n,i),console.log(`Saved xoxd cookie to workspace "${n}".`),console.log("RTM WebSocket mode is now available: slack tail @you")}async function $a(e={}){let t=es();if(t.length===0)console.error("No workspaces configured. Run: slack auth token"),process.exit(1);let n;if(e.workspace){if(!t.find((i)=>i.name===e.workspace))console.error(`Workspace "${e.workspace}" not found. Available: ${t.map((i)=>i.name).join(", ")}`),process.exit(1);n=e.workspace}else if(t.length===1)n=t[0].name;else{let o=t.find((i)=>i.current);if(o)n=o.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 i=It({input:process.stdin,output:process.stdout}),a=(await i.question("Choice: ")).trim();i.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 r=ka();if(r.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(r.length===1)s=r[0].cookie,console.log(`Found session in Firefox profile: ${r[0].profileName}`);else{console.log("Multiple Firefox profiles have a Slack session. Choose one:"),r.forEach((c,u)=>console.log(` ${u+1}) ${c.profileName} [${c.profileDir}]`));let o=It({input:process.stdin,output:process.stdout}),i=(await o.question("Choice: ")).trim();o.close();let a=parseInt(i,10)-1;if(isNaN(a)||a<0||a>=r.length)console.error("Invalid choice."),process.exit(1);s=r[a].cookie}xr(n,s),console.log(`Saved xoxd cookie to workspace "${n}".`),console.log("RTM WebSocket mode is now available: slack tail @you")}async function Oa(e={}){if(e.token){await Pt(null,e.token,e.name);return}if(!process.stdin.isTTY){let n=[];for await(let s of process.stdin)n.push(s);let r=Buffer.concat(n).toString("utf8").trim();if(!r)console.error("No token provided on stdin."),process.exit(1);await Pt(null,r,e.name);return}let t=It({input:process.stdin,output:process.stdout});try{await Sa(t)}finally{t.close()}}async function Ia(e={}){let t=It({input:process.stdin,output:process.stdout});try{if(e.bot!==void 0){await rs(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 Tt(t,"Choice [1/2, Enter=1]: ");await rs(t,n==="2"?"bot":"user")}finally{t.close()}}async function os(e={}){let t=es();if(t.length>0){console.log("Currently logged in:");for(let{name:r,profile:s,current:o}of t)console.log(` ${o?"*":" "} ${r} ${s.team} (${s.user||"unknown"})`);console.log(""),console.log("Adding another workspace:"),console.log("")}if(e.token){await Pt(null,e.token,e.name);return}if(!process.stdin.isTTY){let r=[];for await(let o of process.stdin)r.push(o);let s=Buffer.concat(r).toString("utf8").trim();if(!s)console.error("No token provided on stdin."),process.exit(1);await Pt(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=It({input:process.stdin,output:process.stdout});try{let r=await Tt(n,"Choice [1/2/3/4]: ");if(console.log(""),r==="1")await uf(n);else if(r==="2")await Sa(n);else if(r==="3")await rs(n,"user");else if(r==="4")await rs(n,"bot");else console.error(`Invalid choice: "${r}". Enter 1, 2, 3, or 4.`),process.exit(1)}finally{n.close()}}async function is(e,t,n,r){let s=t,o=[],i=s,a=0;while(!0){let c=i.indexOf("<@U",a);if(c===-1)break;let u=i.slice(c+2),f=u.search(/[>|]/),l=f===-1?u:u.slice(0,f);if(l.length>=9)o.push(l);a=c+1}for(let c of o){if(!n.has(c))n.set(c,await Gn(e,c,r));let u=n.get(c)??c;s=s.replaceAll(`<@${c}>`,`@${u}`),s=s.replace(new RegExp(`<@${c}\\|[^>]*>`,"g"),`@${u}`)}return s}function as(e){return e.replace(/<!date\^(\d+)\^[^|>]*(?:\|([^>]*))?>/g,(t,n,r)=>{let s=Number(n);if(!Number.isFinite(s))return r??"date";let o=new Date(s*1000);if(Number.isNaN(o.getTime()))return r??"date";let i=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],a=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],c=i[o.getUTCDay()]??"",u=a[o.getUTCMonth()]??"";return`${c}, ${u} ${String(o.getUTCDate()).padStart(2,"0")}, ${o.getUTCFullYear()}`})}function Pa(e){let t=typeof e.ts==="string"?e.ts:"",n=typeof e.thread_ts==="string"?e.thread_ts:"";return n!==""&&n!==t}function lf(e){let[t,n="000000"]=e.split("."),r=new Date(Number(t)*1000),s=r.getUTCFullYear(),o=String(r.getUTCMonth()+1).padStart(2,"0"),i=String(r.getUTCDate()).padStart(2,"0"),a=String(r.getUTCHours()).padStart(2,"0"),c=String(r.getUTCMinutes()).padStart(2,"0"),u=String(r.getUTCSeconds()).padStart(2,"0"),f=n.padEnd(6,"0").slice(0,6);return`${s}-${o}-${i}T${a}:${c}:${u}.${f}`}async function ff(e,t,n){let r=typeof t.ts==="string"?t.ts:"0.000000",s=lf(r),o="?";if(typeof t.user==="string"){let l=t.user,d="@"+l;if(!n.has(d)){let[,p]=await Xn(e,l);n.set(d,p)}o=n.get(d)??l}else if(typeof t.username==="string")o=t.username;let i=typeof t.text==="string"?t.text:"",c=as(await is(e,i,n)).split(`
118
118
  `),u=c[0]+(c.length>1?`
119
119
  `+c.slice(1).map((l)=>` ${l}`).join(`
120
- `):""),f=Ta(t)?"↳ ":"";return`${s} ${f}@${i}: ${u}`}async function uf(e,t,n,r,s,i,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).
121
- `)}),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:"")!==r)return;let m=typeof l.ts==="string"?l.ts:"";if(!m||i.has(m))return;let h=typeof l.subtype==="string"?l.subtype:"";if(h==="message_changed"||h==="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&&Ta(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(i.add(m),i.size>1000){let E=i.values().next().value;if(E!==void 0)i.delete(E)}let y=await cf(t,l,o);process.stdout.write(y+`
120
+ `):""),f=Pa(t)?"↳ ":"";return`${s} ${f}@${o}: ${u}`}async function df(e,t,n,r,s,o,i,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).
121
+ `)}),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:"")!==r)return;let m=typeof l.ts==="string"?l.ts:"";if(!m||o.has(m))return;let h=typeof l.subtype==="string"?l.subtype:"";if(h==="message_changed"||h==="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&&Pa(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(o.add(m),o.size>1000){let E=o.values().next().value;if(E!==void 0)o.delete(E)}let y=await ff(t,l,i);process.stdout.write(y+`
122
122
  `)}catch(l){process.stderr.write(`RTM message error: ${l instanceof Error?l.message:String(l)}
123
- `)}})()})})}var Ia=3,lf=2000,_r={sleep:(e)=>new Promise((t)=>setTimeout(t,e)),clientBoot:aa,getWebSocket:()=>{let e=globalThis.WebSocket;return typeof e==="function"?e:void 0}};async function Pa(e,t,n,r,s,i,o){let a=_r.getWebSocket();if(!a)return;for(let c=0;c<Ia;c++){if(o?.aborted)return;try{let{wsUrl:u}=await _r.clientBoot(e,t);await uf(a,e,u,n,r,s,i,o)}catch{}if(o?.aborted)return;if(c<Ia-1)await _r.sleep(lf)}}function Ra(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 Je={sleep:(e)=>new Promise((t)=>setTimeout(t,e)),now:()=>Date.now(),tailRTM:Pa};function Qe(e){return e&&typeof e==="object"&&!Array.isArray(e)?e:{}}function kr(e){return Array.isArray(e)?e:[]}function Ma(e){return Number(e)||0}function Ba(e){let t=typeof e.ts==="string"?e.ts:"",n=typeof e.thread_ts==="string"?e.thread_ts:"";return n!==""&&n!==t}function ff(e){let[t,n="000000"]=e.split("."),r=new Date(Number(t)*1000),s=r.getUTCFullYear(),i=String(r.getUTCMonth()+1).padStart(2,"0"),o=String(r.getUTCDate()).padStart(2,"0"),a=String(r.getUTCHours()).padStart(2,"0"),c=String(r.getUTCMinutes()).padStart(2,"0"),u=String(r.getUTCSeconds()).padStart(2,"0"),f=n.padEnd(6,"0").slice(0,6);return`${s}-${i}-${o}T${a}:${c}:${u}.${f}`}async function df(e,t,n,r,s){let i=typeof t.ts==="string"?t.ts:"0.000000",o=ff(i),a="?";if(typeof t.user==="string"){let m=t.user,h="@"+m;if(!n.has(h)){let[,y]=await qn(e,m,s);n.set(h,y)}a=n.get(h)??m}else if(typeof t.username==="string")a=t.username;let c=typeof t.text==="string"?t.text:"",f=is(await rs(e,c,n,s)).split(`
123
+ `)}})()})})}var Ta=3,hf=2000,kr={sleep:(e)=>new Promise((t)=>setTimeout(t,e)),clientBoot:ca,getWebSocket:()=>{let e=globalThis.WebSocket;return typeof e==="function"?e:void 0}};async function Ra(e,t,n,r,s,o,i){let a=kr.getWebSocket();if(!a)return;for(let c=0;c<Ta;c++){if(i?.aborted)return;try{let{wsUrl:u}=await kr.clientBoot(e,t);await df(a,e,u,n,r,s,o,i)}catch{}if(i?.aborted)return;if(c<Ta-1)await kr.sleep(hf)}}function Ma(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 Je={sleep:(e)=>new Promise((t)=>setTimeout(t,e)),now:()=>Date.now(),tailRTM:Ra};function Qe(e){return e&&typeof e==="object"&&!Array.isArray(e)?e:{}}function Sr(e){return Array.isArray(e)?e:[]}function Ba(e){return Number(e)||0}function Na(e){let t=typeof e.ts==="string"?e.ts:"",n=typeof e.thread_ts==="string"?e.thread_ts:"";return n!==""&&n!==t}function pf(e){let[t,n="000000"]=e.split("."),r=new Date(Number(t)*1000),s=r.getUTCFullYear(),o=String(r.getUTCMonth()+1).padStart(2,"0"),i=String(r.getUTCDate()).padStart(2,"0"),a=String(r.getUTCHours()).padStart(2,"0"),c=String(r.getUTCMinutes()).padStart(2,"0"),u=String(r.getUTCSeconds()).padStart(2,"0"),f=n.padEnd(6,"0").slice(0,6);return`${s}-${o}-${i}T${a}:${c}:${u}.${f}`}async function gf(e,t,n,r,s){let o=typeof t.ts==="string"?t.ts:"0.000000",i=pf(o),a="?";if(typeof t.user==="string"){let m=t.user,h="@"+m;if(!n.has(h)){let[,y]=await Xn(e,m,s);n.set(h,y)}a=n.get(h)??m}else if(typeof t.username==="string")a=t.username;let c=typeof t.text==="string"?t.text:"",f=as(await is(e,c,n,s)).split(`
124
124
  `),l=f[0]+(f.length>1?`
125
125
  `+f.slice(1).map((m)=>` ${m}`).join(`
126
- `):""),d=Ba(t)?"↳ ":"",p=r?`${r} @${a}`:`@${a}`;return`${o} ${d}${p}: ${l}`}async function pf(e,t,n,r,s,i,o){let a=Qe(await un(e,t,20,o?void 0:n||void 0,o,r.cookie)),c=kr(a.messages).map(Qe).reverse(),u=Qe(a.response_metadata),f=a.has_more===!0&&typeof u.next_cursor==="string"?u.next_cursor:void 0,l=[];if(r.watchThread&&!o){let y=Qe(await ta(e,t,r.watchThread,50,r.cookie));l=kr(y.messages).map(Qe).filter((E)=>(typeof E.ts==="string"?E.ts:"")!==r.watchThread)}let d=[...c.map((y)=>({m:y,fromHistory:!0})),...l.map((y)=>({m:y,fromHistory:!1}))].sort((y,E)=>Ma(typeof y.m.ts==="string"?y.m.ts:"")-Ma(typeof E.m.ts==="string"?E.m.ts:"")),p=[],m=n,h=!1;for(let{m:y,fromHistory:E}of d){let F=typeof y.ts==="string"?y.ts:"";if(!F||s.has(F))continue;let A=typeof y.subtype==="string"?y.subtype:"";if(A==="message_changed"||A==="message_deleted")continue;if(r.thread){if((typeof y.thread_ts==="string"?y.thread_ts:F)!==r.thread&&F!==r.thread)continue}if(r.watchThread&&Ba(y)){if((typeof y.thread_ts==="string"?y.thread_ts:"")!==r.watchThread)continue}if(r.me&&r.myUserId){if(!(typeof y.text==="string"?y.text:"").includes(`<@${r.myUserId}>`))continue}if(s.add(F),s.size>1000){let B=s.values().next().value;if(B!==void 0)s.delete(B)}if(p.push(await df(e,y,i,void 0,r.cookie)),E)m=F;let _=typeof y.user==="string"?y.user:"";if(!r.myUserId||_!==r.myUserId)h=!0}return{newCursor:m,lines:p,hasMore:a.has_more===!0,nextPageCursor:f,emittedOther:h}}function hf(e){if(e.includes("slack.com")){let t=gr(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 Na(e,t,n={},r){if(n.me&&!t)console.error(`slack tail --me requires a <target> channel.
126
+ `):""),d=Na(t)?"↳ ":"",p=r?`${r} @${a}`:`@${a}`;return`${i} ${d}${p}: ${l}`}async function mf(e,t,n,r,s,o,i){let a=Qe(await un(e,t,20,i?void 0:n||void 0,i,r.cookie)),c=Sr(a.messages).map(Qe).reverse(),u=Qe(a.response_metadata),f=a.has_more===!0&&typeof u.next_cursor==="string"?u.next_cursor:void 0,l=[];if(r.watchThread&&!i){let y=Qe(await na(e,t,r.watchThread,50,r.cookie));l=Sr(y.messages).map(Qe).filter((E)=>(typeof E.ts==="string"?E.ts:"")!==r.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:"")),p=[],m=n,h=!1;for(let{m:y,fromHistory:E}of d){let F=typeof y.ts==="string"?y.ts:"";if(!F||s.has(F))continue;let A=typeof y.subtype==="string"?y.subtype:"";if(A==="message_changed"||A==="message_deleted")continue;if(r.thread){if((typeof y.thread_ts==="string"?y.thread_ts:F)!==r.thread&&F!==r.thread)continue}if(r.watchThread&&Na(y)){if((typeof y.thread_ts==="string"?y.thread_ts:"")!==r.watchThread)continue}if(r.me&&r.myUserId){if(!(typeof y.text==="string"?y.text:"").includes(`<@${r.myUserId}>`))continue}if(s.add(F),s.size>1000){let B=s.values().next().value;if(B!==void 0)s.delete(B)}if(p.push(await gf(e,y,o,void 0,r.cookie)),E)m=F;let k=typeof y.user==="string"?y.user:"";if(!r.myUserId||k!==r.myUserId)h=!0}return{newCursor:m,lines:p,hasMore:a.has_more===!0,nextPageCursor:f,emittedOther:h}}function Df(e){if(e.includes("slack.com")){let t=mr(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 va(e,t,n={},r){if(n.me&&!t)console.error(`slack tail --me requires a <target> channel.
127
127
  Cross-channel mention streaming is not yet supported.
128
- 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 ia(e,t,n.cookie),i=n.interval??60000,o=n.timeout?Je.now()+Ra(n.timeout)*1000:1/0,a=new Map,c=new Set;try{let h=Qe(await oa(e,s,n.cookie));if(Qe(h.channel).is_archived===!0)console.error("Warning: this channel is archived — no new messages will arrive.")}catch(h){let y=h instanceof Error?h.message:String(h);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 h=Ra(n.since);u=(Je.now()/1000-h).toFixed(6)}else{let h=Qe(await un(e,s,1,void 0,void 0,n.cookie)),y=kr(h.messages).map(Qe);if(y.length>0&&typeof y[0]?.ts==="string")u=y[0].ts,c.add(u);else u=(Je.now()/1000).toFixed(6)}let f;if(n.me||n.exitOnMessage)f=(await qt(e,n.cookie)).userId||void 0;let l;if(n.watchThread!==void 0)try{l=hf(n.watchThread)}catch(h){console.error(h instanceof Error?h.message:String(h)),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 Je.tailRTM(e,n.cookie,s,d,c,a,r),r?.aborted)return;console.error("RTM unavailable — switching to polling.")}let p=!0,m=Je.now();while(!r?.aborted){if(Je.now()>=o)return;let h=!1;try{let F=Je.now()-m,A=i>0&&F>i*5,_,B=!0;do{let{newCursor:I,lines:R,nextPageCursor:V,emittedOther:L}=await pf(e,s,u,d,c,a,_);if(u=I,p&&B&&n.since&&R.length===0)process.stdout.write(`(no messages in the last ${n.since} — watching for new)
128
+ 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 ia(e,t,n.cookie),o=n.interval??60000,i=n.timeout?Je.now()+Ma(n.timeout)*1000:1/0,a=new Map,c=new Set;try{let h=Qe(await aa(e,s,n.cookie));if(Qe(h.channel).is_archived===!0)console.error("Warning: this channel is archived — no new messages will arrive.")}catch(h){let y=h instanceof Error?h.message:String(h);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 h=Ma(n.since);u=(Je.now()/1000-h).toFixed(6)}else{let h=Qe(await un(e,s,1,void 0,void 0,n.cookie)),y=Sr(h.messages).map(Qe);if(y.length>0&&typeof y[0]?.ts==="string")u=y[0].ts,c.add(u);else u=(Je.now()/1000).toFixed(6)}let f;if(n.me||n.exitOnMessage)f=(await qt(e,n.cookie)).userId||void 0;let l;if(n.watchThread!==void 0)try{l=Df(n.watchThread)}catch(h){console.error(h instanceof Error?h.message:String(h)),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 Je.tailRTM(e,n.cookie,s,d,c,a,r),r?.aborted)return;console.error("RTM unavailable — switching to polling.")}let p=!0,m=Je.now();while(!r?.aborted){if(Je.now()>=i)return;let h=!1;try{let F=Je.now()-m,A=o>0&&F>o*5,k,B=!0;do{let{newCursor:I,lines:R,nextPageCursor:V,emittedOther:L}=await mf(e,s,u,d,c,a,k);if(u=I,p&&B&&n.since&&R.length===0)process.stdout.write(`(no messages in the last ${n.since} — watching for new)
129
129
  `);B=!1;for(let ne of R)process.stdout.write(ne+`
130
- `);if(L)h=!0;_=A?V:void 0}while(_);p=!1}catch(E){if(E instanceof Ke){console.error(`Warning: Slack rate limit hit — backing off for ${E.retryAfter}s`),await Je.sleep(E.retryAfter*1000);continue}throw E}if(n.exitOnMessage&&h)return;m=Je.now();let y=o-Je.now();if(y<=0)return;await Je.sleep(Math.min(i,y))}}var Be=[{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"}],as=Be.length,cs="question";function Ar(e){let t=e.split(`
131
- `),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((r)=>r[1])}function $r(e,t){let n=e.split(`
132
- `);if(n.length<2)return e;if(Ar(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 r=n.join(`
133
- `);return r===e?e:r}function gf(e){return e!==void 0&&e.startsWith("_:warning: 同時に複数選ばれているため回答として数えていません — どれか 1 つだけ残してください: ")&&e.endsWith("_")}var Or="white_check_mark",os=`:${Or}: `;function va(e){return`:${Be[e].name}:`}function ja(e,t){let n=Be[t];for(let r of[va(t),n.glyph]){if(e.startsWith(`${r} `))return e.slice(r.length+1);if(e===r)return""}return null}function mf(e){return Be.some((t,n)=>ja(e,n)!==null)}function Yt(e){return e.replace(/\s*\n\s*/g," ")}function La(e,t,n,r,s){let i=[`:question: *${e}*`];if(t)i.push("",t);if(n.length){if(i.push(""),i.push(...n.map((o,a)=>`${va(a)} ${Yt(o)}`)),r.length)i.push(""),i.push(...r.map((o,a)=>`(${a+11}) ${Yt(o)}`)),i.push("_11 番目以降はリアクションがないので、返信で答えてください。_");i.push(""),i.push(s?"_下のリアクションを 1 つ押すと回答になります。当てはまるものがなければ、このメッセージの *スレッド* で返信してください (チャンネルへの通常投稿は回答として拾いません)。_":"_下のリアクションを 1 つ押すと回答になります。当てはまるものがなければ、このメッセージに返信してください。_")}else i.push(""),i.push(s?"_このメッセージの *スレッド* で返信してください。本文がそのまま回答になります (チャンネルへの通常投稿は回答として拾いません)。_":"_このメッセージに返信してください。本文がそのまま回答になります。_");return i.join(`
134
- `)}function Wa(e,t,n){let r=t.answer.split(`
130
+ `);if(L)h=!0;k=A?V:void 0}while(k);p=!1}catch(E){if(E instanceof Ke){console.error(`Warning: Slack rate limit hit — backing off for ${E.retryAfter}s`),await Je.sleep(E.retryAfter*1000);continue}throw E}if(n.exitOnMessage&&h)return;m=Je.now();let y=i-Je.now();if(y<=0)return;await Je.sleep(Math.min(o,y))}}var Be=[{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"}],us=Be.length,ls="question";function $r(e){let t=e.split(`
131
+ `),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((r)=>r[1])}function Or(e,t){let n=e.split(`
132
+ `);if(n.length<2)return e;if($r(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 r=n.join(`
133
+ `);return r===e?e:r}function yf(e){return e!==void 0&&e.startsWith("_:warning: 同時に複数選ばれているため回答として数えていません — どれか 1 つだけ残してください: ")&&e.endsWith("_")}var Ir="white_check_mark",cs=`:${Ir}: `;function ja(e){return`:${Be[e].name}:`}function La(e,t){let n=Be[t];for(let r of[ja(t),n.glyph]){if(e.startsWith(`${r} `))return e.slice(r.length+1);if(e===r)return""}return null}function bf(e){return Be.some((t,n)=>La(e,n)!==null)}function Yt(e){return e.replace(/\s*\n\s*/g," ")}function Wa(e,t,n,r,s){let o=[`:question: *${e}*`];if(t)o.push("",t);if(n.length){if(o.push(""),o.push(...n.map((i,a)=>`${ja(a)} ${Yt(i)}`)),r.length)o.push(""),o.push(...r.map((i,a)=>`(${a+11}) ${Yt(i)}`)),o.push("_11 番目以降はリアクションがないので、返信で答えてください。_");o.push(""),o.push(s?"_下のリアクションを 1 つ押すと回答になります。当てはまるものがなければ、このメッセージの *スレッド* で返信してください (チャンネルへの通常投稿は回答として拾いません)。_":"_下のリアクションを 1 つ押すと回答になります。当てはまるものがなければ、このメッセージに返信してください。_")}else o.push(""),o.push(s?"_このメッセージの *スレッド* で返信してください。本文がそのまま回答になります (チャンネルへの通常投稿は回答として拾いません)。_":"_このメッセージに返信してください。本文がそのまま回答になります。_");return o.join(`
134
+ `)}function Ua(e,t,n){let r=t.answer.split(`
135
135
  `).map((s)=>`> ${s}`).join(`
136
- `);return`${os}*${e}*
136
+ `);return`${cs}*${e}*
137
137
  _${t.how}で回答済み${n?` (${n})`:""}_
138
138
 
139
- ${r}`}function Ua(e){if(!e.trim())return"本文が空です (bot 投稿や添付のみのメッセージかもしれません)";let t=e.split(`
140
- `),n=t[t.length-1]??"";if(e.startsWith(os))return"回答済みマーク付きですが、引用された回答本文が見つかりません";if(!/_$/.test(n))return"末尾が `ask` の案内文ではありません — このメッセージは `slack ask` で投稿されたものではないか、本文が編集されています";if(!t[0].startsWith(":question: ")&&!t[0].startsWith("*"))return"先頭が質問文 (太字) ではありません — 本文が編集されている可能性があります";return"選択肢の並びを読み取れません — 番号が 1 から連番になっていないか、本文が編集されています"}function Ka(e){let t=e.split(`
141
- `);if(e.startsWith(os)){let l=t[0].slice(os.length).replace(/^\*/,"").replace(/\*$/,""),d=t.filter((p)=>p.startsWith("> ")).map((p)=>p.slice(2)).join(`
142
- `);if(!d)return{kind:"other"};return{kind:"resolved",question:l,answer:d}}let n=t[t.length-1]??"",r,s;switch(n){case"_下のリアクションを 1 つ押すと回答になります。当てはまるものがなければ、このメッセージの *スレッド* で返信してください (チャンネルへの通常投稿は回答として拾いません)。_":r=!0,s=!0;break;case"_下のリアクションを 1 つ押すと回答になります。当てはまるものがなければ、このメッセージに返信してください。_":r=!1,s=!0;break;case"_このメッセージの *スレッド* で返信してください。本文がそのまま回答になります (チャンネルへの通常投稿は回答として拾いません)。_":r=!0,s=!1;break;case"_このメッセージに返信してください。本文がそのまま回答になります。_":r=!1,s=!1;break;default:return{kind:"other"}}let i=t[0].startsWith(":question: ")?t[0].slice(11):t[0];if(t[0]=i,!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(`
143
- `).replace(/^\*/,"").replace(/\*$/,""),c=[],u=[];if(s){let f=t.length-2;if(gf(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(!mf(d))break;l.unshift(d),f--}if(!l.length||l.length>as)return{kind:"other"};for(let d=0;d<l.length;d++){let p=ja(l[d],d);if(p===null)return{kind:"other"};c.push(p)}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:r}}function Sr(e){return e.normalize("NFKC").replace(/[*_`~]/g,"").trim().replace(/^[\s"'`「『((\[]+/,"").replace(/[\s"'`」』))\]。..!!??、,]+$/,"").replace(/\s+/g," ").trim().toLowerCase()}function Ja(e,t){let n=Sr(e);if(!n)return{kind:"none"};let r=t.map(Sr),s=new Set;r.forEach((u,f)=>{if(u&&u===n)s.add(f+1)}),Be.forEach((u,f)=>{if(f<t.length&&e.trim()===u.glyph)s.add(f+1)});let i=0,o="",a=n.match(/^(\d{1,2})$/);if(a)i=Number(a[1]);else if(a=n.match(/^(\d{1,2})(?:\s*[.)::、。\-\]]\s*|\s+)(.*)$/)){if(i=Number(a[1]),o=Sr(a[2]),!o)return{kind:"none"};if(/^\d+$/.test(o))return{kind:"none"}}if(i>=1&&i<=t.length&&(o===""||o===r[i-1]))s.add(i);let c=[...s].sort((u,f)=>u-f);if(!c.length)return{kind:"none"};if(c.length>1)return{kind:"ambiguous",indexes:c};return{kind:"chosen",index:c[0]}}var Ir=[{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"}],om=Ir.length;function Tr(e){let t=e.split(`
144
- `),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((r)=>r[1])}function za(e,t){let n=e.split(`
145
- `);if(n.length<2)return e;if(Tr(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 r=n.join(`
146
- `);return r===e?e:r}function Ha(e){return e!==void 0&&e.startsWith("_:warning: 同時に複数選ばれているため回答として数えていません — どれか 1 つだけ残してください: ")&&e.endsWith("_")}var Df="white_check_mark",am=`:${Df}: `;var ze=Ir,Xt=ze.length,dn="ballot_box_with_ballot",Pr=`:${dn}: `,Ya="_下のリアクションで投票してください (1 人 1 票、押し直しで変更できます)。_",Xa="_下のリアクションで投票してください (当てはまるものを *いくつでも* 押せます)。_",us="_締切: ",ls="_",Mr="bar_chart",Rr=`:${Mr}: `;function fs(e){return`:${ze[e].name}:`}function qa(e,t){for(let n of[fs(t),ze[t].glyph])if(e.startsWith(`${n} `))return e.slice(n.length+1);return null}function yf(e){return ze.some((t,n)=>e.startsWith(`${fs(n)} `)||e.startsWith(`${t.glyph} `))}function fn(e){return e.replace(/\s*\n\s*/g," ")}function Ga(e,t,n,r={}){let s=!!r.multi,i=r.deadline??"",o=r.invalid??[];if(!n.length||n.length>Xt)throw Error(`poll needs 1..${Xt} choices, got ${n.length}`);let a=[`${Pr}*${e}*`];if(t)a.push("",t);if(a.push(""),a.push(...n.map((c,u)=>`${fs(u)} ${fn(c)}`)),a.push(""),i)a.push(`${us}${fn(i)}${ls}`);return a.push(s?Xa:Ya),za(a.join(`
147
- `),s?[]:o)}function Va(e,t){let n=t.reduce((s,i)=>s+i.count,0),r=[`${Rr}*${e}*`,`_投票終了 (計 ${n} 票)_`,""];return r.push(...t.map((s,i)=>`${fs(i)} ×${s.count} ${fn(s.choice)}`)),r.join(`
148
- `)}function Za(e){let t=e.split(`
149
- `);if(e.startsWith(Rr)){let d=t[0].slice(Rr.length).replace(/^\*/,"").replace(/\*$/,""),p=[];for(let m=0;m<ze.length;m++){let h=t.map((E)=>qa(E,m)).find((E)=>E!==null&&E.startsWith("×"));if(h===void 0)break;let y=/^×(\d+) (.*)$/.exec(h);if(!y)return{kind:"other"};p.push({choice:y[2],count:Number(y[1])})}if(!p.length)return{kind:"other"};return{kind:"closed",question:d,tallies:p}}let n=t[t.length-1]??"",r;if(n===Ya)r=!1;else if(n===Xa)r=!0;else return{kind:"other"};if(t[0].startsWith(Pr))t[0]=t[0].slice(Pr.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 i=t.slice(0,s+1).join(`
150
- `).replace(/^\*/,"").replace(/\*$/,""),o=t.length-2,a=Tr(e);if(Ha(t[o]))o--;let c="",u=t[o];if(u!==void 0&&u.startsWith(us)&&u.endsWith(ls)&&u.length>us.length+ls.length)c=u.slice(us.length,-ls.length),o--;if(t[o]!=="")return{kind:"other"};o--;let f=[];while(o>=0){let d=t[o];if(!yf(d))break;f.unshift(d),o--}if(!f.length||f.length>Xt)return{kind:"other"};let l=[];for(let d=0;d<f.length;d++){let p=qa(f[d],d);if(p===null)return{kind:"other"};l.push(p)}if(t[o]!=="")return{kind:"other"};if(o<s+1)return{kind:"other"};return{kind:"open",question:i,choices:l,multi:r,deadline:c,invalid:a}}function Qa(e,t,n,r){let s=new Map(t.map((u)=>[u.name,u.users])),i=e.map((u,f)=>(s.get(ze[f].name)??[]).filter((l)=>!n.has(l))),o=[];if(!r){let u=new Map;for(let f of i)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=i.map((u)=>u.filter((f)=>!a.has(f)));return{tallies:e.map((u,f)=>({choice:u,count:c[f].length})),voters:c,ambiguous:o}}function wf(e=process.env){return!!e.VITEST||e.NODE_ENV==="test"||!!e.BUN_TEST}var ec={isTestEnv:()=>wf(),sleep:(e)=>ec.isTestEnv()?Promise.resolve():new Promise((t)=>setTimeout(t,e))};function bf(e=process.env){let t=e.SLACK_REACTION_SEED_GAP_MS;if(t===void 0||t==="")return 1100;let n=Number(t);if(!Number.isFinite(n)||n<0)return 1100;return n}async function Br(e,t,n,r=bf()){for(let s=0;s<e.length;s++){let i=!0;try{await t(e[s])}catch(o){i=!1,n(e[s],o)}if(i&&r>0&&s<e.length-1)await ec.sleep(r)}}class Mt extends Error{retryAfter;constructor(e){super(`Slack rate limited — retry after ${e}s`);this.name="RateLimitError",this.retryAfter=e}}function jr(){return(process.env.SLACK_API_BASE??"https://slack.com/api").replace(/\/$/,"")}async function sc(e,t,n,r){let s={};if(r)s.Cookie=`d=${r}`;let i=await fetch(`${jr()}/${t}`,{...n,headers:{...n.headers??{},Authorization:`Bearer ${e}`,...s}});if(i.status===429){let a=parseInt(i.headers.get("retry-after")??"60",10);throw new Mt(isNaN(a)?60:a)}let o=await i.json();if(o.ok!==!0){let a=o.error??"unknown";if(a==="ratelimited")throw new Mt(60);if(a==="invalid_auth"&&e.startsWith("xoxc-")&&!r)throw Error(`Desktop app token (xoxc-) needs its session cookie to be accepted by the public Slack API.
139
+ ${r}`}function Ka(e){if(!e.trim())return"本文が空です (bot 投稿や添付のみのメッセージかもしれません)";let t=e.split(`
140
+ `),n=t[t.length-1]??"";if(e.startsWith(cs))return"回答済みマーク付きですが、引用された回答本文が見つかりません";if(!/_$/.test(n))return"末尾が `ask` の案内文ではありません — このメッセージは `slack ask` で投稿されたものではないか、本文が編集されています";if(!t[0].startsWith(":question: ")&&!t[0].startsWith("*"))return"先頭が質問文 (太字) ではありません — 本文が編集されている可能性があります";return"選択肢の並びを読み取れません — 番号が 1 から連番になっていないか、本文が編集されています"}function Ja(e){let t=e.split(`
141
+ `);if(e.startsWith(cs)){let l=t[0].slice(cs.length).replace(/^\*/,"").replace(/\*$/,""),d=t.filter((p)=>p.startsWith("> ")).map((p)=>p.slice(2)).join(`
142
+ `);if(!d)return{kind:"other"};return{kind:"resolved",question:l,answer:d}}let n=t[t.length-1]??"",r,s;switch(n){case"_下のリアクションを 1 つ押すと回答になります。当てはまるものがなければ、このメッセージの *スレッド* で返信してください (チャンネルへの通常投稿は回答として拾いません)。_":r=!0,s=!0;break;case"_下のリアクションを 1 つ押すと回答になります。当てはまるものがなければ、このメッセージに返信してください。_":r=!1,s=!0;break;case"_このメッセージの *スレッド* で返信してください。本文がそのまま回答になります (チャンネルへの通常投稿は回答として拾いません)。_":r=!0,s=!1;break;case"_このメッセージに返信してください。本文がそのまま回答になります。_":r=!1,s=!1;break;default:return{kind:"other"}}let o=t[0].startsWith(":question: ")?t[0].slice(11):t[0];if(t[0]=o,!t[0].startsWith("*"))return{kind:"other"};let i=0;while(i<t.length&&!(t[i].endsWith("*")&&(i>0||t[0].length>1)))i++;if(i>=t.length)return{kind:"other"};let a=t.slice(0,i+1).join(`
143
+ `).replace(/^\*/,"").replace(/\*$/,""),c=[],u=[];if(s){let f=t.length-2;if(yf(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(!bf(d))break;l.unshift(d),f--}if(!l.length||l.length>us)return{kind:"other"};for(let d=0;d<l.length;d++){let p=La(l[d],d);if(p===null)return{kind:"other"};c.push(p)}if(t[f]!=="")return{kind:"other"};if(f<i+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:r}}function Ar(e){return e.normalize("NFKC").replace(/[*_`~]/g,"").trim().replace(/^[\s"'`「『((\[]+/,"").replace(/[\s"'`」』))\]。..!!??、,]+$/,"").replace(/\s+/g," ").trim().toLowerCase()}function za(e,t){let n=Ar(e);if(!n)return{kind:"none"};let r=t.map(Ar),s=new Set;r.forEach((u,f)=>{if(u&&u===n)s.add(f+1)}),Be.forEach((u,f)=>{if(f<t.length&&e.trim()===u.glyph)s.add(f+1)});let o=0,i="",a=n.match(/^(\d{1,2})$/);if(a)o=Number(a[1]);else if(a=n.match(/^(\d{1,2})(?:\s*[.)::、。\-\]]\s*|\s+)(.*)$/)){if(o=Number(a[1]),i=Ar(a[2]),!i)return{kind:"none"};if(/^\d+$/.test(i))return{kind:"none"}}if(o>=1&&o<=t.length&&(i===""||i===r[o-1]))s.add(o);let c=[...s].sort((u,f)=>u-f);if(!c.length)return{kind:"none"};if(c.length>1)return{kind:"ambiguous",indexes:c};return{kind:"chosen",index:c[0]}}var Tr=[{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"}],lm=Tr.length;function Pr(e){let t=e.split(`
144
+ `),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((r)=>r[1])}function Ha(e,t){let n=e.split(`
145
+ `);if(n.length<2)return e;if(Pr(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 r=n.join(`
146
+ `);return r===e?e:r}function qa(e){return e!==void 0&&e.startsWith("_:warning: 同時に複数選ばれているため回答として数えていません — どれか 1 つだけ残してください: ")&&e.endsWith("_")}var wf="white_check_mark",fm=`:${wf}: `;var ze=Tr,Xt=ze.length,dn="ballot_box_with_ballot",Rr=`:${dn}: `,Xa="_下のリアクションで投票してください (1 人 1 票、押し直しで変更できます)。_",Ga="_下のリアクションで投票してください (当てはまるものを *いくつでも* 押せます)。_",fs="_締切: ",ds="_",Br="bar_chart",Mr=`:${Br}: `;function hs(e){return`:${ze[e].name}:`}function Ya(e,t){for(let n of[hs(t),ze[t].glyph])if(e.startsWith(`${n} `))return e.slice(n.length+1);return null}function Ff(e){return ze.some((t,n)=>e.startsWith(`${hs(n)} `)||e.startsWith(`${t.glyph} `))}function fn(e){return e.replace(/\s*\n\s*/g," ")}function Va(e,t,n,r={}){let s=!!r.multi,o=r.deadline??"",i=r.invalid??[];if(!n.length||n.length>Xt)throw Error(`poll needs 1..${Xt} choices, got ${n.length}`);let a=[`${Rr}*${e}*`];if(t)a.push("",t);if(a.push(""),a.push(...n.map((c,u)=>`${hs(u)} ${fn(c)}`)),a.push(""),o)a.push(`${fs}${fn(o)}${ds}`);return a.push(s?Ga:Xa),Ha(a.join(`
147
+ `),s?[]:i)}function Za(e,t){let n=t.reduce((s,o)=>s+o.count,0),r=[`${Mr}*${e}*`,`_投票終了 (計 ${n} 票)_`,""];return r.push(...t.map((s,o)=>`${hs(o)} ×${s.count} ${fn(s.choice)}`)),r.join(`
148
+ `)}function Qa(e){let t=e.split(`
149
+ `);if(e.startsWith(Mr)){let d=t[0].slice(Mr.length).replace(/^\*/,"").replace(/\*$/,""),p=[];for(let m=0;m<ze.length;m++){let h=t.map((E)=>Ya(E,m)).find((E)=>E!==null&&E.startsWith("×"));if(h===void 0)break;let y=/^×(\d+) (.*)$/.exec(h);if(!y)return{kind:"other"};p.push({choice:y[2],count:Number(y[1])})}if(!p.length)return{kind:"other"};return{kind:"closed",question:d,tallies:p}}let n=t[t.length-1]??"",r;if(n===Xa)r=!1;else if(n===Ga)r=!0;else return{kind:"other"};if(t[0].startsWith(Rr))t[0]=t[0].slice(Rr.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 o=t.slice(0,s+1).join(`
150
+ `).replace(/^\*/,"").replace(/\*$/,""),i=t.length-2,a=Pr(e);if(qa(t[i]))i--;let c="",u=t[i];if(u!==void 0&&u.startsWith(fs)&&u.endsWith(ds)&&u.length>fs.length+ds.length)c=u.slice(fs.length,-ds.length),i--;if(t[i]!=="")return{kind:"other"};i--;let f=[];while(i>=0){let d=t[i];if(!Ff(d))break;f.unshift(d),i--}if(!f.length||f.length>Xt)return{kind:"other"};let l=[];for(let d=0;d<f.length;d++){let p=Ya(f[d],d);if(p===null)return{kind:"other"};l.push(p)}if(t[i]!=="")return{kind:"other"};if(i<s+1)return{kind:"other"};return{kind:"open",question:o,choices:l,multi:r,deadline:c,invalid:a}}function ec(e,t,n,r){let s=new Map(t.map((u)=>[u.name,u.users])),o=e.map((u,f)=>(s.get(ze[f].name)??[]).filter((l)=>!n.has(l))),i=[];if(!r){let u=new Map;for(let f of o)for(let l of f)u.set(l,(u.get(l)??0)+1);for(let[f,l]of u)if(l>1)i.push(f)}let a=new Set(i),c=o.map((u)=>u.filter((f)=>!a.has(f)));return{tallies:e.map((u,f)=>({choice:u,count:c[f].length})),voters:c,ambiguous:i}}function Cf(e=process.env){return!!e.VITEST||e.NODE_ENV==="test"||!!e.BUN_TEST}var tc={isTestEnv:()=>Cf(),sleep:(e)=>tc.isTestEnv()?Promise.resolve():new Promise((t)=>setTimeout(t,e))};function Ef(e=process.env){let t=e.SLACK_REACTION_SEED_GAP_MS;if(t===void 0||t==="")return 1100;let n=Number(t);if(!Number.isFinite(n)||n<0)return 1100;return n}async function Nr(e,t,n,r=Ef()){for(let s=0;s<e.length;s++){let o=!0;try{await t(e[s])}catch(i){o=!1,n(e[s],i)}if(o&&r>0&&s<e.length-1)await tc.sleep(r)}}class Mt extends Error{retryAfter;constructor(e){super(`Slack rate limited — retry after ${e}s`);this.name="RateLimitError",this.retryAfter=e}}function Lr(){return(process.env.SLACK_API_BASE??"https://slack.com/api").replace(/\/$/,"")}async function rc(e,t,n,r){let s={};if(r)s.Cookie=`d=${r}`;let o=await fetch(`${Lr()}/${t}`,{...n,headers:{...n.headers??{},Authorization:`Bearer ${e}`,...s}});if(o.status===429){let a=parseInt(o.headers.get("retry-after")??"60",10);throw new Mt(isNaN(a)?60:a)}let i=await o.json();if(i.ok!==!0){let a=i.error??"unknown";if(a==="ratelimited")throw new Mt(60);if(a==="invalid_auth"&&e.startsWith("xoxc-")&&!r)throw Error(`Desktop app token (xoxc-) needs its session cookie to be accepted by the public Slack API.
151
151
  Attach it: slack auth chrome (macOS) or slack auth firefox
152
152
  Or replace the token with an xoxp- user token:
153
153
  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"}.
154
154
  Tailing/DMing people and listing users need a user session, not a bot token.
155
155
  Switch workspace: slack auth ls then slack auth use <name>
156
- Or import your Slack desktop session: slack auth login`);throw Error(`Slack error on ${t}: ${a}`)}return o}async function Ff(e,t,n,r){let s={};if(r)s.Cookie=`d=${r}`;let i=await fetch(`${jr()}/${t}`,{...n,headers:{...n.headers??{},Authorization:`Bearer ${e}`,...s}});if(i.status===429){let a=parseInt(i.headers.get("retry-after")??"60",10);throw new Mt(isNaN(a)?60:a)}let o=await i.json();if(o.ok!==!0){let a=o.error??"unknown";if(a==="ratelimited")throw new Mt(60);if((a==="invalid_auth"||a==="not_authed")&&!e.startsWith("xoxc-"))throw Error(`The draft API requires a desktop app session token (xoxc-).
156
+ Or import your Slack desktop session: slack auth login`);throw Error(`Slack error on ${t}: ${a}`)}return i}async function xf(e,t,n,r){let s={};if(r)s.Cookie=`d=${r}`;let o=await fetch(`${Lr()}/${t}`,{...n,headers:{...n.headers??{},Authorization:`Bearer ${e}`,...s}});if(o.status===429){let a=parseInt(o.headers.get("retry-after")??"60",10);throw new Mt(isNaN(a)?60:a)}let i=await o.json();if(i.ok!==!0){let a=i.error??"unknown";if(a==="ratelimited")throw new Mt(60);if((a==="invalid_auth"||a==="not_authed")&&!e.startsWith("xoxc-"))throw Error(`The draft API requires a desktop app session token (xoxc-).
157
157
  Import from Slack desktop: slack auth login`);if((a==="invalid_auth"||a==="not_authed")&&!r)throw Error(`drafts.list also requires the xoxd session cookie.
158
- Attach it with: slack auth chrome (macOS) or slack auth firefox`);throw Error(`Slack error on ${t}: ${a}`)}return o}function Bt(e,t,n={},r){let s=new URLSearchParams({token:e,...n});return Ff(e,t,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s.toString()},r)}function oe(e,t,n,r){let s=new URLSearchParams(n).toString();return sc(e,`${t}?${s}`,{method:"GET"},r)}function He(e,t,n,r){return sc(e,t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)},r)}async function rc(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 ic(e,t){let n={Authorization:`Bearer ${e}`};if(t)n.Cookie=`d=${t}`;let r=await fetch(`${jr()}/auth.test`,{method:"GET",headers:n});if(r.status===429){let o=parseInt(r.headers.get("retry-after")??"60",10);throw new Mt(isNaN(o)?60:o)}let s=r.headers.get("x-oauth-scopes")??"",i=await r.json();if(i.ok!==!0)throw Error(`Slack error on auth.test: ${i.error??"unknown"}`);return{userId:i.user_id??"",user:i.user??"",botId:i.bot_id??"",team:i.team??"",url:i.url??"",scopes:s.split(",").map((o)=>o.trim()).filter(Boolean)}}async function Ve(e,t,n=20,r,s,i,o){let a={channel:t,limit:String(n)};if(r!==void 0)a.oldest=r;if(s!==void 0)a.cursor=s;if(o)a.inclusive="true";return oe(e,"conversations.history",a,i)}async function qe(e,t,n,r=50,s){return oe(e,"conversations.replies",{channel:t,ts:n,limit:String(r)},s)}async function oc(e,t,n){return oe(e,"files.info",{file:t},n)}async function ac(e,t={},n){let r={count:String(Math.min(Math.max(t.count??100,1),200)),page:String(Math.max(t.page??1,1))};if(t.types)r.types=t.types;if(t.channel)r.channel=t.channel;if(t.user)r.user=t.user;return oe(e,"files.list",r,n)}async function cc(e,t,n={},r){let s={list_id:t};if(n.limit)s.limit=String(n.limit);if(n.cursor)s.cursor=n.cursor;return Bt(e,"lists.records.list",s,r)}async function uc(e,t,n,r,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(r,1))},s)}async function lc(e,t,n){return uc(e,t,100,1,n)}async function Lr(e,t,n,r){let i=1,o=[],a={ok:!0,messages:{}};while(!0){let u=await uc(e,t,100,i,r),f=pn(u,["messages","matches"]),l=Array.isArray(f)?f:[];o.push(...l);let d=Number(pn(u,["messages","paging","pages"])??1);if(a=u,l.length===0||i>=d||o.length>=n)break;i+=1}let c=a;if(!c.messages)c.messages={};return c.messages.matches=o.slice(0,n),c}async function ds(e,t,n,r,s,i,o){let a=o?{channel:t,text:n}:{channel:t,text:n,blocks:[{type:"markdown",text:n}]};if(r!==void 0)a.thread_ts=r;if(s&&r!==void 0)a.reply_broadcast=!0;return(await He(e,"chat.postMessage",a,i)).ts??""}async function fc(e,t,n,r,s,i){let o={channel:t,text:n,post_at:r,blocks:[{type:"markdown",text:n}]};if(s!==void 0)o.thread_ts=s;return(await He(e,"chat.scheduleMessage",o,i)).scheduled_message_id??""}async function dc(e,t,n){let r={};if(t)r.channel=t;return oe(e,"chat.scheduledMessages.list",r,n)}async function pc(e,t,n,r){await He(e,"chat.deleteScheduledMessage",{channel:t,scheduled_message_id:n},r)}async function hn(e,t,n,r){return(await oe(e,"chat.getPermalink",{channel:t,message_ts:n},r)).permalink??""}async function Gt(e,t,n,r,s,i){return(await He(e,"chat.update",i?{channel:t,ts:n,text:r}:{channel:t,ts:n,text:r,blocks:[{type:"markdown",text:r}]},s)).ts??n}async function hc(e,t,n,r){await He(e,"chat.delete",{channel:t,ts:n},r)}async function Vt(e,t,n,r,s){await He(e,"reactions.add",{channel:t,timestamp:n,name:r},s)}async function gc(e,t,n,r){return((await oe(e,"reactions.get",{channel:t,timestamp:n,full:"true"},r)).message?.reactions??[]).map((i)=>({name:String(i.name??""),users:Array.isArray(i.users)?i.users.map(String):[]}))}async function gn(e,t,n,r,s){await He(e,"reactions.remove",{channel:t,timestamp:n,name:r},s)}async function mc(e,t,n=!1,r){let s=await He(e,"conversations.create",{name:t,is_private:n},r);return{id:s.channel?.id??"",name:s.channel?.name??t}}async function Dc(e,t,n,r){await He(e,"conversations.invite",{channel:t,users:n.join(",")},r)}async function mn(e,t){let n=[],r="";while(!0){let s={limit:"200",types:"public_channel,private_channel,im,mpim"};if(r)s.cursor=r;let i=await oe(e,"conversations.list",s,t);if(n.push(...i.channels??[]),r=i.response_metadata?.next_cursor??"",!r)break}return{channels:n}}async function at(e,t,n){let s=(await He(e,"conversations.open",{users:t},n)).channel?.id;if(!s)throw Error(`Failed to open DM with user ${t}`);return s}async function yc(e,t,n){let r="";while(!0){let s={types:"im",limit:"200"};if(r)s.cursor=r;let i=await oe(e,"conversations.list",s,n);for(let o of i.channels??[])if(o.user===t)return String(o.id??"");if(r=i.response_metadata?.next_cursor??"",!r)break}return""}async function Nr(e,t,n,r){let s=await yc(e,t,n);if(s)return s;let i=r?`${r} (${t})`:t;throw Error(`No existing DM with ${i}. Open it once in Slack first.`)}function Rt(e){return e.toLowerCase().replace(/[-_\s]/g,"")}function tc(e,t){let n=Rt(e.name??""),r=Rt(e.real_name??e.profile?.real_name??""),s=Rt(e.profile?.display_name??"");return n===t||r===t||!!s&&s===t}var wc=200;async function bc(e,t,n){let r=0,s=new Set,i="";while(!0){let f={limit:"200"};if(i)f.cursor=i;let l=await oe(e,"users.list",f,n);for(let d of l.members??[]){if(r++,d.id)s.add(d.id);if(tc(d,t))return{id:d.id??"",workspaceCount:r,connectCount:0,skipped:0,capped:!1}}if(i=l.response_metadata?.next_cursor??"",!i)break}let o=0,a=0,c=!1,u="";while(!0){let f={types:"im",limit:"200"};if(u)f.cursor=u;let l=await oe(e,"conversations.list",f,n);for(let d of l.channels??[]){let p=d.user;if(!p||s.has(p))continue;if(o>=wc){c=!0;break}s.add(p),o++;let m;try{m=(await oe(e,"users.info",{user:p},n)).user}catch(h){if(h instanceof Mt)throw h;a++;continue}if(m&&tc(m,t))return{id:p,dm:String(d.id??""),workspaceCount:r,connectCount:o,skipped:a,capped:c}}if(c)break;if(u=l.response_metadata?.next_cursor??"",!u)break}return{id:"",workspaceCount:r,connectCount:o,skipped:a,capped:c}}function Fc(e,t){if(t.workspaceCount===0)return Error(`Cannot resolve ${e}: users.list returned no members at all, so nothing could have matched.
158
+ Attach it with: slack auth chrome (macOS) or slack auth firefox`);throw Error(`Slack error on ${t}: ${a}`)}return i}function Bt(e,t,n={},r){let s=new URLSearchParams({token:e,...n});return xf(e,t,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s.toString()},r)}function ie(e,t,n,r){let s=new URLSearchParams(n).toString();return rc(e,`${t}?${s}`,{method:"GET"},r)}function He(e,t,n,r){return rc(e,t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)},r)}async function oc(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 ic(e,t){let n={Authorization:`Bearer ${e}`};if(t)n.Cookie=`d=${t}`;let r=await fetch(`${Lr()}/auth.test`,{method:"GET",headers:n});if(r.status===429){let i=parseInt(r.headers.get("retry-after")??"60",10);throw new Mt(isNaN(i)?60:i)}let s=r.headers.get("x-oauth-scopes")??"",o=await r.json();if(o.ok!==!0)throw Error(`Slack error on auth.test: ${o.error??"unknown"}`);return{userId:o.user_id??"",user:o.user??"",botId:o.bot_id??"",team:o.team??"",url:o.url??"",scopes:s.split(",").map((i)=>i.trim()).filter(Boolean)}}async function Ve(e,t,n=20,r,s,o,i){let a={channel:t,limit:String(n)};if(r!==void 0)a.oldest=r;if(s!==void 0)a.cursor=s;if(i)a.inclusive="true";return ie(e,"conversations.history",a,o)}async function qe(e,t,n,r=50,s){return ie(e,"conversations.replies",{channel:t,ts:n,limit:String(r)},s)}async function ac(e,t,n){return ie(e,"files.info",{file:t},n)}async function cc(e,t={},n){let r={count:String(Math.min(Math.max(t.count??100,1),200)),page:String(Math.max(t.page??1,1))};if(t.types)r.types=t.types;if(t.channel)r.channel=t.channel;if(t.user)r.user=t.user;return ie(e,"files.list",r,n)}async function uc(e,t,n={},r){let s={list_id:t};if(n.limit)s.limit=String(n.limit);if(n.cursor)s.cursor=n.cursor;return Bt(e,"lists.records.list",s,r)}async function lc(e,t,n,r,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(r,1))},s)}async function fc(e,t,n){return lc(e,t,100,1,n)}async function Wr(e,t,n,r){let o=1,i=[],a={ok:!0,messages:{}};while(!0){let u=await lc(e,t,100,o,r),f=hn(u,["messages","matches"]),l=Array.isArray(f)?f:[];i.push(...l);let d=Number(hn(u,["messages","paging","pages"])??1);if(a=u,l.length===0||o>=d||i.length>=n)break;o+=1}let c=a;if(!c.messages)c.messages={};return c.messages.matches=i.slice(0,n),c}async function ps(e,t,n,r,s,o,i){let a=i?{channel:t,text:n}:{channel:t,text:n,blocks:[{type:"markdown",text:n}]};if(r!==void 0)a.thread_ts=r;if(s&&r!==void 0)a.reply_broadcast=!0;return(await He(e,"chat.postMessage",a,o)).ts??""}async function dc(e,t,n,r,s,o){let i={channel:t,text:n,post_at:r,blocks:[{type:"markdown",text:n}]};if(s!==void 0)i.thread_ts=s;return(await He(e,"chat.scheduleMessage",i,o)).scheduled_message_id??""}async function hc(e,t,n){let r={};if(t)r.channel=t;return ie(e,"chat.scheduledMessages.list",r,n)}async function pc(e,t,n,r){await He(e,"chat.deleteScheduledMessage",{channel:t,scheduled_message_id:n},r)}async function pn(e,t,n,r){return(await ie(e,"chat.getPermalink",{channel:t,message_ts:n},r)).permalink??""}async function Gt(e,t,n,r,s,o){return(await He(e,"chat.update",o?{channel:t,ts:n,text:r}:{channel:t,ts:n,text:r,blocks:[{type:"markdown",text:r}]},s)).ts??n}async function gc(e,t,n,r){await He(e,"chat.delete",{channel:t,ts:n},r)}async function Vt(e,t,n,r,s){await He(e,"reactions.add",{channel:t,timestamp:n,name:r},s)}async function mc(e,t,n,r){return((await ie(e,"reactions.get",{channel:t,timestamp:n,full:"true"},r)).message?.reactions??[]).map((o)=>({name:String(o.name??""),users:Array.isArray(o.users)?o.users.map(String):[]}))}async function gn(e,t,n,r,s){await He(e,"reactions.remove",{channel:t,timestamp:n,name:r},s)}async function Dc(e,t,n=!1,r){let s=await He(e,"conversations.create",{name:t,is_private:n},r);return{id:s.channel?.id??"",name:s.channel?.name??t}}async function yc(e,t,n,r){await He(e,"conversations.invite",{channel:t,users:n.join(",")},r)}async function mn(e,t){let n=[],r="";while(!0){let s={limit:"200",types:"public_channel,private_channel,im,mpim"};if(r)s.cursor=r;let o=await ie(e,"conversations.list",s,t);if(n.push(...o.channels??[]),r=o.response_metadata?.next_cursor??"",!r)break}return{channels:n}}async function et(e,t,n){let s=(await He(e,"conversations.open",{users:t},n)).channel?.id;if(!s)throw Error(`Failed to open DM with user ${t}`);return s}async function bc(e,t,n){let r="";while(!0){let s={types:"im",limit:"200"};if(r)s.cursor=r;let o=await ie(e,"conversations.list",s,n);for(let i of o.channels??[])if(i.user===t)return String(i.id??"");if(r=o.response_metadata?.next_cursor??"",!r)break}return""}async function vr(e,t,n,r){let s=await bc(e,t,n);if(s)return s;let o=r?`${r} (${t})`:t;throw Error(`No existing DM with ${o}. Open it once in Slack first.`)}function Rt(e){return e.toLowerCase().replace(/[-_\s]/g,"")}function nc(e,t){let n=Rt(e.name??""),r=Rt(e.real_name??e.profile?.real_name??""),s=Rt(e.profile?.display_name??"");return n===t||r===t||!!s&&s===t}var wc=200;async function Fc(e,t,n){let r=0,s=new Set,o="";while(!0){let f={limit:"200"};if(o)f.cursor=o;let l=await ie(e,"users.list",f,n);for(let d of l.members??[]){if(r++,d.id)s.add(d.id);if(nc(d,t))return{id:d.id??"",workspaceCount:r,connectCount:0,skipped:0,capped:!1}}if(o=l.response_metadata?.next_cursor??"",!o)break}let i=0,a=0,c=!1,u="";while(!0){let f={types:"im",limit:"200"};if(u)f.cursor=u;let l=await ie(e,"conversations.list",f,n);for(let d of l.channels??[]){let p=d.user;if(!p||s.has(p))continue;if(i>=wc){c=!0;break}s.add(p),i++;let m;try{m=(await ie(e,"users.info",{user:p},n)).user}catch(h){if(h instanceof Mt)throw h;a++;continue}if(m&&nc(m,t))return{id:p,dm:String(d.id??""),workspaceCount:r,connectCount:i,skipped:a,capped:c}}if(c)break;if(u=l.response_metadata?.next_cursor??"",!u)break}return{id:"",workspaceCount:r,connectCount:i,skipped:a,capped:c}}function Cc(e,t){if(t.workspaceCount===0)return Error(`Cannot resolve ${e}: users.list returned no members at all, so nothing could have matched.
159
159
  `+`That is a token or scope fault, not a wrong handle — this says nothing about whether ${e} exists.
160
160
  Check who you are: slack auth ls`);let n=t.connectCount?`${t.workspaceCount} workspace account(s) and ${t.connectCount} Slack Connect DM partner(s)`:`${t.workspaceCount} workspace account(s)`,r=[];if(t.capped)r.push(`stopped after ${wc} Slack Connect DM partners, so there may be more`);if(t.skipped)r.push(`${t.skipped} DM partner profile(s) could not be read and were never compared`);return Error(`User not found: ${e} — searched ${n}, none matched.
161
161
  `+(r.length?`This search was incomplete: ${r.join("; ")}.
162
162
  `:"")+`Slack Connect people from another workspace are not in users.list, so if they never
163
163
  DMed you they cannot be found by name at all. Look them up and use their ID:
164
- slack user ls --external`)}async function ct(e,t,n){let r=t.startsWith("@")?t.slice(1):t;if(vr(r))return r;if(!t.startsWith("@"))throw Error(`Expected @user or a user ID, got: ${t}`);let s=Rt(r),i=await oe(e,"auth.test",{},n);if(s==="you"||s==="me"||Rt(i.user??"")===s){if(!i.user_id)throw Error("auth.test did not return user_id");return i.user_id}let o=await bc(e,s,n);if(o.id)return o.id;throw Fc(t,o)}function Nt(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],r=t[2]&&t[3]?`${t[2]}.${t[3]}`:void 0,s=e.indexOf("?"),i=s>=0?new URLSearchParams(e.slice(s)):void 0,o=i?.get("thread_ts")??void 0,u={channel:i?.get("cid")??void 0??n};if(r)u.ts=r;if(o)u.threadTs=o;return u}function Cf(e){return Nt(e)?.channel}function nc(e){return/^[CDG][A-Z0-9]{8,}$/.test(e)}function vr(e){return/^[UW][A-Z0-9]{6,}$/.test(e)}async function De(e,t,n){let r=Cf(t);if(r)return r;if(!t.startsWith("@")&&!t.startsWith("#")){if(nc(t))return t;if(vr(t))return Nr(e,t,n);throw Error(`Target must start with # or @ (or be a Slack URL/ID), got: ${t}`)}if(t.startsWith("#")&&nc(t.slice(1)))return t.slice(1);let s=t.startsWith("@"),i=t.slice(1),o=Rt(i);if(s){if(vr(i))return Nr(e,i,n);let u=await oe(e,"auth.test",{},n);if(o==="you"||o==="me"||Rt(u.user??"")===o){let d=u.user_id;if(!d)throw Error("auth.test did not return user_id");return await yc(e,d,n)||at(e,d,n)}let l=await bc(e,o,n);if(!l.id)throw Fc(t,l);if(l.dm)return l.dm;return Nr(e,l.id,n,t)}let a=i.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 Dn(e,t,n){try{let r=await oe(e,"users.info",{user:t},n),s=r.user?.profile?.display_name,i=s&&s.length>0?s:r.user?.real_name??r.user?.name??t,o=r.user?.name??t;return[i,o]}catch{return[t,t]}}async function Ne(e,t,n){try{let r=await oe(e,"users.info",{user:t},n),s=r.user?.profile?.display_name;if(s&&s.length>0)return s;return r.user?.real_name??r.user?.name??t}catch{return t}}async function Cc(e,t){let n=[],r="";while(!0){let s={limit:"200"};if(r)s.cursor=r;let i=await oe(e,"users.list",s,t);if(n.push(...i.members??[]),r=i.response_metadata?.next_cursor??"",!r)break}return{members:n}}async function Ec(e,t,n){let r=[],s="";while(!0){let i={channel:t,limit:"200"};if(s)i.cursor=s;let o=await oe(e,"conversations.members",i,n);if(r.push(...o.members??[]),s=o.response_metadata?.next_cursor??"",!s)break}return r}async function yn(e,t){return Bt(e,"drafts.list",{},t)}async function xc(e,t,n,r){let{randomUUID:s}=await import("node:crypto"),i=JSON.stringify([{type:"rich_text",elements:[{type:"rich_text_section",elements:[{type:"text",text:n}]}]}]);return Bt(e,"drafts.create",{client_msg_id:s(),destinations:JSON.stringify([{channel_id:t}]),blocks:i,file_ids:JSON.stringify([]),is_from_composer:"true"},r)}async function _c(e,t,n,r,s){let i=JSON.stringify([{type:"rich_text",elements:[{type:"rich_text_section",elements:[{type:"text",text:r}]}]}]),o=(Date.now()/1000).toFixed(6);return Bt(e,"drafts.update",{draft_id:t,client_last_updated_ts:o,destinations:JSON.stringify([{channel_id:n}]),blocks:i,file_ids:JSON.stringify([])},s)}async function kc(e,t,n){return Bt(e,"conversations.info",{channel:t},n)}async function wn(e,t,n){return oe(e,"users.info",{user:t},n)}async function bn(e,t,n){return oe(e,"conversations.info",{channel:t},n)}async function Sc(e,t,n){let r=(Date.now()/1000).toFixed(6);return Bt(e,"drafts.delete",{draft_id:t,client_last_updated_ts:r},n)}async function Wr(e,t){let n=await Bt(e,"auth.test",{},t);return{userId:String(n.user_id??""),teamId:String(n.team_id??"")}}async function Ac(e,t,n,r={},s){let{statSync:i,readFileSync:o}=await import("node:fs"),{basename:a}=await import("node:path"),c=i(n),u=a(n),f=await oe(e,"files.getUploadURLExternal",{filename:u,length:String(c.size)},s),{upload_url:l,file_id:d}=f;if(!l||!d)throw Error("files.getUploadURLExternal returned no upload_url/file_id");let p=o(n),m=await fetch(l,{method:"POST",headers:{"Content-Type":"application/octet-stream"},body:p});if(!m.ok)throw Error(`Upload PUT failed: ${m.status} ${m.statusText}`);let h={files:[{id:d,title:r.title??u}],channel_id:t};if(r.threadTs)h.thread_ts=r.threadTs;if(r.initialComment)h.initial_comment=r.initialComment;let y=await He(e,"files.completeUploadExternal",h,s),E={fileId:d},F=y.files?.[0]?.permalink;if(F)E.permalink=F;return E}function pn(e,t){let n=e;for(let r of t){if(n===void 0||n===null)return;if(typeof r==="number"){if(!Array.isArray(n))return;n=n[r]??void 0}else{if(typeof n!=="object"||Array.isArray(n))return;n=n[r]}}return n}import{existsSync as Tf,readFileSync as Pf}from"node:fs";import{homedir as Rf}from"node:os";import{join as Mf}from"node:path";import{existsSync as Ef,mkdirSync as xf,readFileSync as _f,writeFileSync as kf}from"node:fs";import{homedir as Sf}from"node:os";import{dirname as Af,join as $f}from"node:path";var Of=3600000,ps={now:()=>Date.now(),path:()=>$f(process.env.HOME||Sf(),".config","slack-cli","cache.json")},hs=!0,ut;function $c(){return{channels:{},users:{}}}function Ur(){if(ut)return ut;if(ut=$c(),!hs)return ut;try{let e=ps.path();if(!Ef(e))return ut;let t=JSON.parse(_f(e,"utf8"));for(let n of["channels","users"]){let r=t?.[n];if(!r||typeof r!=="object"||Array.isArray(r))continue;for(let[s,i]of Object.entries(r))if(i&&typeof i==="object"&&typeof i.value==="string"&&typeof i.expires==="number")ut[n][s]={value:i.value,expires:i.expires}}}catch{ut=$c()}return ut}function If(e){if(!hs)return;try{let t=ps.path();xf(Af(t),{recursive:!0}),kf(t,JSON.stringify(e,null,2)+`
165
- `)}catch{}}function Oc(e,t){return e?`${e} ${t}`:void 0}function gs(e,t,n){if(!hs)return;let r=Oc(t,n);if(!r)return;let s=Ur()[e][r];if(!s)return;if(s.expires<=ps.now()){delete Ur()[e][r];return}return s.value}function ms(e,t,n,r,s=Of){if(!hs)return;let i=Oc(t,n);if(!i)return;let o=Ur();o[e][i]={value:r,expires:ps.now()+s},If(o)}var Kr={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"}},Zt=["done","dropped","doing","pending"],Rc=["alert","needs-discussion","waiting","blocked"];function Bf(){return Mf(process.env.HOME||Rf(),".config","slack-cli","todo.json")}function Ds(e){return e.replace(/^:+|:+$/g,"")}function Fn(e=Bf()){let t={marker:Kr.marker,progress:{...Kr.progress},flags:{...Kr.flags}};try{if(!Tf(e))return t;let n=JSON.parse(Pf(e,"utf8"));if(typeof n.marker==="string"&&n.marker.trim())t.marker=Ds(n.marker.trim());for(let r of Zt){let s=n.progress?.[r];if(typeof s==="string"&&s.trim())t.progress[r]=Ds(s.trim())}for(let r of Rc){let s=n.flags?.[r];if(typeof s==="string"&&s.trim())t.flags[r]=Ds(s.trim())}}catch{}return t}function Ic(e,t,n=!1){return`${n?"-":""}${t?"has":"hasmy"}::${Ds(e)}:`}function Mc(e,t,n={}){let r=n.shared===!0,s=(a)=>Ic(a,r),i=(a)=>Ic(a,r,!0),o=[];if(e==="untriaged")o.push(s(t.marker),...Zt.map((a)=>i(t.progress[a])));else if(e==="stuck")o.push(s(t.marker),i(t.progress.done),i(t.progress.dropped),`(${Rc.map((a)=>s(t.flags[a])).join(" OR ")})`);else if(e==="open")o.push(s(t.marker),i(t.progress.done),i(t.progress.dropped));else{let a=Zt.indexOf(e);o.push(s(t.progress[e]));for(let c of Zt.slice(0,a))o.push(i(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 Nf=3,vf={sleep:(e)=>jf()?Promise.resolve():new Promise((t)=>setTimeout(t,e))};function jf(){return!!process.env.VITEST||!1||!!process.env.BUN_TEST}async function _e(e,t,n=Nf){for(let r=0;;r++)try{return await t()}catch(s){if(!(s instanceof Ke))throw s;if(r>=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 vf.sleep(s.retryAfter*1000)}}var Tc=new Map;async function Bc(e,t){let n=Tc.get(e);if(n)return n;let r=await _e("auth.test",()=>qt(e,t)),s={userId:r.userId,teamId:r.teamId};return Tc.set(e,s),s}async function Nc(e,t){return(await Bc(e,t)).userId}async function Jr(e,t){try{return(await Bc(e,t)).teamId}catch{return""}}async function zr(e,t,n,r){if(!t.startsWith("#"))return n(e,t,r);let s=await Jr(e,r),i=gs("channels",s,t);if(i)return i;let o=await _e("resolveChannel",()=>n(e,t,r));return ms("channels",s,t,o),o}async function vc(e,t,n,r){let s=await Jr(e,r),i=gs("users",s,t);if(i)return i;let o=await _e("users.info",()=>n(e,t,r));if(o&&o!==t)ms("users",s,t,o);return o}async function jc(e,t,n,r){let s=await Jr(e,r),i=gs("users",s,`tz:${t}`);if(i)return i==="?"?null:i;let o=null;try{let a=await _e("users.info",()=>n(e,t,r));if(a?.user?.is_bot===!0||t==="USLACKBOT")return Pc(s,t,null);let c=a?.user?.tz;o=typeof c==="string"&&c?c:null}catch{return null}return Pc(s,t,o)}function Pc(e,t,n){return ms("users",e,`tz:${t}`,n??"?"),n}async function Lc(e,t,n,r,s,i){let o=s.progress[r],a=await Nc(e,i),c=await _e("reactions.get",()=>na(e,t,n,i)),u=new Set(c.filter((p)=>p.users.includes(a)).map((p)=>p.name)),f=Zt.map((p)=>s.progress[p]).filter((p)=>u.has(p));if(f.length===1&&f[0]===o)return{noop:!0,removed:[],leftover:[]};if(!u.has(o))await _e("reactions.add",()=>zn(e,t,n,o,i));let l=[],d=[];for(let p of f){if(p===o)continue;try{await _e("reactions.remove",()=>Hn(e,t,n,p,i)),l.push(p)}catch{d.push(p)}}return{noop:!1,added:r,removed:l,leftover:d}}async function Wc(e,t,n,r,s,i,o){let a=s.flags[r];if(i)await _e("reactions.remove",()=>Hn(e,t,n,a,o));else await _e("reactions.add",()=>zn(e,t,n,a,o));return a}var Hr=1000;async function Uc(e,t,n,r={}){let s=r.limit??Hr,i=r.cookie,o=await Nc(e,i),a=Zt.map((d)=>n.progress[d]),c=[],u=0,f,l=!1;while(u<s){let d=Math.min(200,s-u),p=await _e("conversations.history",()=>un(e,t,d,void 0,f,i)),m=p.messages??[];u+=m.length;for(let h of m){let y=String(h.ts??"");if(!y)continue;let E=new Set((h.reactions??[]).filter((A)=>(A.users??[]).map(String).includes(o)).map((A)=>String(A.name??""))),F=a.filter((A)=>E.has(A));if(F.length<2)continue;c.push({ts:y,text:String(h.text??"").split(`
166
- `)[0]??"",emoji:F,keep:F[0]})}if(f=p.response_metadata?.next_cursor||void 0,!f||m.length===0)break;if(u>=s){l=!0;break}}if(r.fix)for(let d of c)try{try{await _e("reactions.add",()=>zn(e,t,d.ts,d.keep,i))}catch(p){if(!(p instanceof Error)||!/already_reacted/.test(p.message))throw p}for(let p of d.emoji){if(p===d.keep)continue;await _e("reactions.remove",()=>Hn(e,t,d.ts,p,i))}d.fixed=!0}catch(p){d.fixed=!1,d.error=p instanceof Error?p.message:String(p)}return{scanned:u,findings:c,truncated:l}}var Lf=!0,Wf;function qr(e){if(Lf=e,!e)Wf=void 0}function lt(e){return e.replace(new RegExp(`[${"\\\\¥"}](.)`,"gs"),(t,n)=>{switch(n){case"n":return`
167
- `;case"t":return"\t";case"\\":case"¥":return n==="¥"?"¥":"\\";default:return t}})}function vt(e){return e.toLowerCase().replace(/[-_\s]/g,"")}function ft(e){return e&&typeof e==="object"&&!Array.isArray(e)?e:{}}function Uf(e,t){let n=vt(t),r=ft(e.profile);for(let i of[e.name,e.real_name,r.display_name,r.real_name])if(typeof i==="string"&&i&&vt(i)===n)return!0;let s=typeof r.email==="string"?r.email.toLowerCase():"";return s!==""&&s===t.toLowerCase()}function Kf(e){let t=ft(e.profile),n=new Set;for(let r of[t.display_name,e.real_name,e.name,t.real_name])if(typeof r==="string"&&r){let s=vt(r);if(s.length>=2)n.add(s)}return[...n]}function Jf(e,t){let n=vt(e),r,s=!1;for(let i of t){let o=typeof i.id==="string"?i.id:"";if(!o)continue;for(let a of Kf(i)){let c=-1;if(n===a)c=e.length;else for(let u of Jc)if(e.length>u.length&&e.endsWith(u)&&vt(e.slice(0,e.length-u.length))===a){c=e.length-u.length;break}if(c<0)continue;if(!r||a.length>r.formLen)r={userId:o,matchLen:c,formLen:a.length,display:Gr(i)},s=!1;else if(a.length===r.formLen&&r.userId!==o)s=!0}}if(!r)return;return s?"ambiguous":{userId:r.userId,matchLen:r.matchLen,display:r.display}}async function jt(e,t,n,r){let s=`[${zc}ー]+`,i=`${s}(?:[._-]+${s})*`,o=new RegExp(`(?<![A-Za-z0-9._@<-])@(${i})`,"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 A of a){if(c.get(A).status!=="pending")continue;if(Xr(A)){let _=Jf(A,F);if(_==="ambiguous")c.set(A,{status:"ambiguous"});else if(_)c.set(A,{status:"resolved",userId:_.userId,matchLen:_.matchLen,display:_.display})}else{let _=F.filter((I)=>Uf(I,A)),B=new Set(_.map((I)=>typeof I.id==="string"?I.id:"").filter(Boolean));if(B.size===1){let I=_.find((R)=>typeof R.id==="string");c.set(A,{status:"resolved",userId:I.id,matchLen:A.length,display:Gr(I)})}else if(B.size>1)c.set(A,{status:"ambiguous"})}}},f=!1;try{let F=await Xn(e,r);u((F.members??[]).map(ft)),f=!0}catch{f=!1}let l=[...a].some((F)=>c.get(F).status==="pending"),d=!1,p=!0;if(l&&n){d=!0;try{let F=await mr(e,n,r),A=[];for(let _ of F){let B=ft(await Dr(e,_,r)),I=ft(B.user);if(typeof I.id!=="string")I.id=_;A.push(I)}u(A)}catch{p=!1}}let m=f&&(n?d&&p:!0),h=[],y=[];for(let F of a){let A=c.get(F);if(A.status==="resolved")h.push({surface:`@${F.slice(0,A.matchLen)}`,display:A.display,userId:A.userId});else if(A.status==="ambiguous")y.push({surface:`@${F}`,reason:"ambiguous"});else y.push({surface:`@${F}`,reason:m?"no-match":"unavailable"})}return{text:t.replace(o,(F,A)=>{let _=c.get(A);if(_&&_.status==="resolved")return`<@${_.userId}>${A.slice(_.matchLen)}`;return F}),resolved:h,unresolved:y}}function Cn(e){let t=[],n=!1;for(let r of e)if(r.reason==="ambiguous")t.push(`${r.surface} matches multiple people — not tagged, sent as plain text (use <@USERID> to tag)`);else if(r.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(`${r.surface} matched no one — not tagged, sent as plain text`);return t}async function Kc(e,t,n,r={}){let s=r.warn??((o)=>process.stderr.write(`${o}
168
- `)),i=await jt(e,t,n,r.cookie);for(let o of Cn(i.unresolved))s(`warn: ${o}`);return i.text}var Jc=["さん","さま","様","君","くん","ちゃん","氏","先生","先輩","殿","老师","老師","兄","姐","哥","姐妹"],zc="\\p{Script=Han}\\p{Script=Hiragana}\\p{Script=Katakana}A-Za-z0-9";function Xr(e){return/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}]/u.test(e)}function zf(e){let t=[],n=new RegExp(`([${zc}]{1,12})(${Jc.join("|")})`,"gu");for(let r of e.matchAll(n))t.push({ref:r[1],honorific:r[2]});for(let r of e.matchAll(/\b(?:dear|hi|hello|hey)\b[ \t]+([A-Z][A-Za-z'’-]{1,20})/gi))t.push({ref:r[1],honorific:""});for(let r of e.matchAll(/(?:^|\n)[ \t]*([A-Z][A-Za-z'’-]{1,20}),/g))t.push({ref:r[1],honorific:""});return t}function Hf(e){let t=ft(e.profile),n=new Set;for(let r of[e.name,e.real_name,t.display_name,t.real_name]){if(typeof r!=="string"||!r)continue;for(let s of[r,...r.split(/\s+/)]){let i=vt(s);if(i.length>=2)n.add(i)}}return[...n]}function qf(e,t){let n=vt(e);if(n.length<2)return;for(let r of t)if(n===r)return r;if(Xr(e)){for(let r of t)if(n.includes(r)||r.includes(n))return r}return}function Gr(e){return[ft(e.profile).display_name,e.real_name,e.name].filter((r)=>typeof r==="string"&&r!=="")[0]??String(e.id??"?")}async function Hc(e,t,n){let r=zf(t);if(r.length===0)return[];let s=new Set;for(let u of t.matchAll(/<@([A-Z0-9]+)(?:\|[^>]*)?>/g))s.add(u[1]);let o=((await Xn(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:Hf(u),display:Gr(u)})).filter((u)=>u.id!==""),a=[],c=new Set;for(let{ref:u,honorific:f}of r)for(let l of o){let d=qf(u,l.forms);if(!d)continue;if(s.has(l.id)||c.has(l.id))break;c.add(l.id),a.push({surface:Xr(u)?`${d}${f}`:u,display:l.display,userId:l.id});break}return a}async function Qt(e,t,n,r){let s=t,i=[],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)i.push(l);a=c+1}for(let c of i){if(!n.has(c))n.set(c,await Yn(e,c,r));let u=n.get(c)??c;s=s.replaceAll(`<@${c}>`,`@${u}`),s=s.replace(new RegExp(`<@${c}\\|[^>]*>`,"g"),`@${u}`)}return s}function En(e){return e.replace(/<!date\^(\d+)\^[^|>]*(?:\|([^>]*))?>/g,(t,n,r)=>{let s=Number(n);if(!Number.isFinite(s))return r??"date";let i=new Date(s*1000);if(Number.isNaN(i.getTime()))return r??"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[i.getUTCDay()]??"",u=a[i.getUTCMonth()]??"";return`${c}, ${u} ${String(i.getUTCDate()).padStart(2,"0")}, ${i.getUTCFullYear()}`})}function qc(e,t=new Date){let n=new Date(e*1000),r=Yr(t),s=Yr(new Date(t.getTime()-86400000)),i=Yr(n);if(i===r)return"Today";if(i===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 Yr(e){return`${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`}function Yc(e){let t=new Date(e*1000),n=t.getFullYear(),r=String(t.getMonth()+1).padStart(2,"0"),s=String(t.getDate()).padStart(2,"0"),i=String(t.getHours()).padStart(2,"0"),o=String(t.getMinutes()).padStart(2,"0");return`${n}-${r}-${s} ${i}:${o}`}function Xc(e=new Date,t){let n=process.env.SLACK_QUIET_TZ??"Asia/Tokyo",r=!!t&&Yf(t),s=r?t:n,i=Number(process.env.SLACK_QUIET_START??23),o=Number(process.env.SLACK_QUIET_END??8),a,c;try{let p=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=p.format(e),a=Number(p.formatToParts(e).find((m)=>m.type==="hour")?.value??"12")}catch{return null}let u=i>o?a>=i||a<o:a>=i&&a<o,f=r?`${s}, recipient`:`${s}, sender — recipient's timezone unknown`,l=`\uD83D\uDD50 ${c} (${f})`;if(!u)return l;return`${l}
169
- ⚠ QUIET HOURS (${i}:00-${o}:00) — this will buzz a phone.${r?"":" 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 xn(e){if(!ru(e))return;let t=Gf(e,"utf8");for(let n of t.split(`
170
- `)){let r=n.trim();if(!r||r.startsWith("#"))continue;let s=r.indexOf("=");if(s===-1)continue;let i=r.slice(0,s).trim(),o=r.slice(s+1).trim();if(o.startsWith('"')&&o.endsWith('"')||o.startsWith("'")&&o.endsWith("'"))o=o.slice(1,-1);if(!(i in process.env))process.env[i]=o}}function Zf(e){Vf(e,{recursive:!0});let t=dt(e,".gitignore");if(!ru(t))iu(t,`*
171
- `)}function Qf(){xn(dt(Gc(),".slack-cli",".env.local")),xn(dt(Gc(),".config/slack-cli",".env")),xn(dt(process.cwd(),".slack-cli",".env.local")),xn(dt(process.cwd(),".env.local")),xn(dt(process.cwd(),".env"))}function ed(e){return Xf("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 ys(e){return Number(e.ts??0)}async function ou(e,t,n){let r=t.user;if(typeof r==="string"){if(!n.has(r))n.set(r,await Ne(e,r));return n.get(r)??r}return typeof t.username==="string"?t.username:"bot"}function Zr(e){let t=new Date(e*1000),n=t.getUTCFullYear(),r=String(t.getUTCMonth()+1).padStart(2,"0"),s=String(t.getUTCDate()).padStart(2,"0"),i=String(t.getUTCHours()).padStart(2,"0"),o=String(t.getUTCMinutes()).padStart(2,"0"),a=String(t.getUTCSeconds()).padStart(2,"0");return`${n}-${r}-${s} ${i}:${o}:${a}`}function ti(e){let[t,n="000000"]=e.split("."),r=Number(t),s=new Date(r*1000),i=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`${i}-${o}-${a}T${c}:${u}:${f}.${l}`}function ni(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 td(e){return/^\d{4}-\d{2}-\d{2}T/.test(e)?ni(e):e}async function Fs(e,t,n,r,s){let i=typeof t.ts==="string"?t.ts:`${ys(t)}.000000`,o=ti(i),a="?";if(typeof t.user==="string"){let F=t.user,A="@"+F;if(!n.has(A)){let _=await vc(e,F,async(B,I,R)=>(await Dn(B,I,R))[1],s);n.set(A,_)}a=n.get(A)??F}else if(typeof t.username==="string")a=t.username;let c=typeof t.text==="string"?t.text:"",f=En(await Qt(e,c,n,s)).split(`
164
+ slack user ls --external`)}async function tt(e,t,n){let r=t.startsWith("@")?t.slice(1):t;if(jr(r))return r;if(!t.startsWith("@"))throw Error(`Expected @user or a user ID, got: ${t}`);let s=Rt(r),o=await ie(e,"auth.test",{},n);if(s==="you"||s==="me"||Rt(o.user??"")===s){if(!o.user_id)throw Error("auth.test did not return user_id");return o.user_id}let i=await Fc(e,s,n);if(i.id)return i.id;throw Cc(t,i)}function Nt(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],r=t[2]&&t[3]?`${t[2]}.${t[3]}`:void 0,s=e.indexOf("?"),o=s>=0?new URLSearchParams(e.slice(s)):void 0,i=o?.get("thread_ts")??void 0,u={channel:o?.get("cid")??void 0??n};if(r)u.ts=r;if(i)u.threadTs=i;return u}function _f(e){return Nt(e)?.channel}function sc(e){return/^[CDG][A-Z0-9]{8,}$/.test(e)}function jr(e){return/^[UW][A-Z0-9]{6,}$/.test(e)}async function De(e,t,n){let r=_f(t);if(r)return r;if(!t.startsWith("@")&&!t.startsWith("#")){if(sc(t))return t;if(jr(t))return vr(e,t,n);throw Error(`Target must start with # or @ (or be a Slack URL/ID), got: ${t}`)}if(t.startsWith("#")&&sc(t.slice(1)))return t.slice(1);let s=t.startsWith("@"),o=t.slice(1),i=Rt(o);if(s){if(jr(o))return vr(e,o,n);let u=await ie(e,"auth.test",{},n);if(i==="you"||i==="me"||Rt(u.user??"")===i){let d=u.user_id;if(!d)throw Error("auth.test did not return user_id");return await bc(e,d,n)||et(e,d,n)}let l=await Fc(e,i,n);if(!l.id)throw Cc(t,l);if(l.dm)return l.dm;return vr(e,l.id,n,t)}let a=o.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 Dn(e,t,n){try{let r=await ie(e,"users.info",{user:t},n),s=r.user?.profile?.display_name,o=s&&s.length>0?s:r.user?.real_name??r.user?.name??t,i=r.user?.name??t;return[o,i]}catch{return[t,t]}}async function Ne(e,t,n){try{let r=await ie(e,"users.info",{user:t},n),s=r.user?.profile?.display_name;if(s&&s.length>0)return s;return r.user?.real_name??r.user?.name??t}catch{return t}}async function Ec(e,t){let n=[],r="";while(!0){let s={limit:"200"};if(r)s.cursor=r;let o=await ie(e,"users.list",s,t);if(n.push(...o.members??[]),r=o.response_metadata?.next_cursor??"",!r)break}return{members:n}}async function xc(e,t,n){let r=[],s="";while(!0){let o={channel:t,limit:"200"};if(s)o.cursor=s;let i=await ie(e,"conversations.members",o,n);if(r.push(...i.members??[]),s=i.response_metadata?.next_cursor??"",!s)break}return r}async function yn(e,t){return Bt(e,"drafts.list",{},t)}async function _c(e,t,n,r){let{randomUUID:s}=await import("node:crypto"),o=JSON.stringify([{type:"rich_text",elements:[{type:"rich_text_section",elements:[{type:"text",text:n}]}]}]);return Bt(e,"drafts.create",{client_msg_id:s(),destinations:JSON.stringify([{channel_id:t}]),blocks:o,file_ids:JSON.stringify([]),is_from_composer:"true"},r)}async function kc(e,t,n,r,s){let o=JSON.stringify([{type:"rich_text",elements:[{type:"rich_text_section",elements:[{type:"text",text:r}]}]}]),i=(Date.now()/1000).toFixed(6);return Bt(e,"drafts.update",{draft_id:t,client_last_updated_ts:i,destinations:JSON.stringify([{channel_id:n}]),blocks:o,file_ids:JSON.stringify([])},s)}async function Sc(e,t,n){return Bt(e,"conversations.info",{channel:t},n)}async function bn(e,t,n){return ie(e,"users.info",{user:t},n)}async function wn(e,t,n){return ie(e,"conversations.info",{channel:t},n)}async function Ac(e,t,n){let r=(Date.now()/1000).toFixed(6);return Bt(e,"drafts.delete",{draft_id:t,client_last_updated_ts:r},n)}async function Ur(e,t){let n=await Bt(e,"auth.test",{},t);return{userId:String(n.user_id??""),teamId:String(n.team_id??"")}}async function $c(e,t,n,r={},s){let{statSync:o,readFileSync:i}=await import("node:fs"),{basename:a}=await import("node:path"),c=o(n),u=a(n),f=await ie(e,"files.getUploadURLExternal",{filename:u,length:String(c.size)},s),{upload_url:l,file_id:d}=f;if(!l||!d)throw Error("files.getUploadURLExternal returned no upload_url/file_id");let p=i(n),m=await fetch(l,{method:"POST",headers:{"Content-Type":"application/octet-stream"},body:p});if(!m.ok)throw Error(`Upload PUT failed: ${m.status} ${m.statusText}`);let h={files:[{id:d,title:r.title??u}],channel_id:t};if(r.threadTs)h.thread_ts=r.threadTs;if(r.initialComment)h.initial_comment=r.initialComment;let y=await He(e,"files.completeUploadExternal",h,s),E={fileId:d},F=y.files?.[0]?.permalink;if(F)E.permalink=F;return E}function hn(e,t){let n=e;for(let r of t){if(n===void 0||n===null)return;if(typeof r==="number"){if(!Array.isArray(n))return;n=n[r]??void 0}else{if(typeof n!=="object"||Array.isArray(n))return;n=n[r]}}return n}import{existsSync as Mf,readFileSync as Bf}from"node:fs";import{homedir as Nf}from"node:os";import{join as vf}from"node:path";import{existsSync as kf,mkdirSync as Sf,readFileSync as Af,writeFileSync as $f}from"node:fs";import{homedir as Of}from"node:os";import{dirname as If,join as Tf}from"node:path";var Pf=3600000,gs={now:()=>Date.now(),path:()=>Tf(process.env.HOME||Of(),".config","slack-cli","cache.json")},ms=!0,lt;function Oc(){return{channels:{},users:{}}}function Kr(){if(lt)return lt;if(lt=Oc(),!ms)return lt;try{let e=gs.path();if(!kf(e))return lt;let t=JSON.parse(Af(e,"utf8"));for(let n of["channels","users"]){let r=t?.[n];if(!r||typeof r!=="object"||Array.isArray(r))continue;for(let[s,o]of Object.entries(r))if(o&&typeof o==="object"&&typeof o.value==="string"&&typeof o.expires==="number")lt[n][s]={value:o.value,expires:o.expires}}}catch{lt=Oc()}return lt}function Rf(e){if(!ms)return;try{let t=gs.path();Sf(If(t),{recursive:!0}),$f(t,JSON.stringify(e,null,2)+`
165
+ `)}catch{}}function Ic(e,t){return e?`${e} ${t}`:void 0}function Ds(e,t,n){if(!ms)return;let r=Ic(t,n);if(!r)return;let s=Kr()[e][r];if(!s)return;if(s.expires<=gs.now()){delete Kr()[e][r];return}return s.value}function ys(e,t,n,r,s=Pf){if(!ms)return;let o=Ic(t,n);if(!o)return;let i=Kr();i[e][o]={value:r,expires:gs.now()+s},Rf(i)}var Jr={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"}},Zt=["done","dropped","doing","pending"],Mc=["alert","needs-discussion","waiting","blocked"];function jf(){return vf(process.env.HOME||Nf(),".config","slack-cli","todo.json")}function bs(e){return e.replace(/^:+|:+$/g,"")}function Fn(e=jf()){let t={marker:Jr.marker,progress:{...Jr.progress},flags:{...Jr.flags}};try{if(!Mf(e))return t;let n=JSON.parse(Bf(e,"utf8"));if(typeof n.marker==="string"&&n.marker.trim())t.marker=bs(n.marker.trim());for(let r of Zt){let s=n.progress?.[r];if(typeof s==="string"&&s.trim())t.progress[r]=bs(s.trim())}for(let r of Mc){let s=n.flags?.[r];if(typeof s==="string"&&s.trim())t.flags[r]=bs(s.trim())}}catch{}return t}function Tc(e,t,n=!1){return`${n?"-":""}${t?"has":"hasmy"}::${bs(e)}:`}function Bc(e,t,n={}){let r=n.shared===!0,s=(a)=>Tc(a,r),o=(a)=>Tc(a,r,!0),i=[];if(e==="untriaged")i.push(s(t.marker),...Zt.map((a)=>o(t.progress[a])));else if(e==="stuck")i.push(s(t.marker),o(t.progress.done),o(t.progress.dropped),`(${Mc.map((a)=>s(t.flags[a])).join(" OR ")})`);else if(e==="open")i.push(s(t.marker),o(t.progress.done),o(t.progress.dropped));else{let a=Zt.indexOf(e);i.push(s(t.progress[e]));for(let c of Zt.slice(0,a))i.push(o(t.progress[c]))}if(n.in){let a=n.in.startsWith("#")||n.in.startsWith("@")?n.in:`#${n.in}`;i.push(`in:${a}`)}if(n.from){let a=n.from==="me"||n.from.startsWith("@")?n.from:`@${n.from}`;i.push(`from:${a}`)}return i.join(" ")}var Lf=3,Wf={sleep:(e)=>Uf()?Promise.resolve():new Promise((t)=>setTimeout(t,e))};function Uf(){return!!process.env.VITEST||!1||!!process.env.BUN_TEST}async function _e(e,t,n=Lf){for(let r=0;;r++)try{return await t()}catch(s){if(!(s instanceof Ke))throw s;if(r>=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 Wf.sleep(s.retryAfter*1000)}}var Pc=new Map;async function Nc(e,t){let n=Pc.get(e);if(n)return n;let r=await _e("auth.test",()=>qt(e,t)),s={userId:r.userId,teamId:r.teamId};return Pc.set(e,s),s}async function vc(e,t){return(await Nc(e,t)).userId}async function zr(e,t){try{return(await Nc(e,t)).teamId}catch{return""}}async function Hr(e,t,n,r){if(!t.startsWith("#"))return n(e,t,r);let s=await zr(e,r),o=Ds("channels",s,t);if(o)return o;let i=await _e("resolveChannel",()=>n(e,t,r));return ys("channels",s,t,i),i}async function jc(e,t,n,r){let s=await zr(e,r),o=Ds("users",s,t);if(o)return o;let i=await _e("users.info",()=>n(e,t,r));if(i&&i!==t)ys("users",s,t,i);return i}async function Lc(e,t,n,r){let s=await zr(e,r),o=Ds("users",s,`tz:${t}`);if(o)return o==="?"?null:o;let i=null;try{let a=await _e("users.info",()=>n(e,t,r));if(a?.user?.is_bot===!0||t==="USLACKBOT")return Rc(s,t,null);let c=a?.user?.tz;i=typeof c==="string"&&c?c:null}catch{return null}return Rc(s,t,i)}function Rc(e,t,n){return ys("users",e,`tz:${t}`,n??"?"),n}async function Wc(e,t,n,r,s,o){let i=s.progress[r],a=await vc(e,o),c=await _e("reactions.get",()=>sa(e,t,n,o)),u=new Set(c.filter((p)=>p.users.includes(a)).map((p)=>p.name)),f=Zt.map((p)=>s.progress[p]).filter((p)=>u.has(p));if(f.length===1&&f[0]===i)return{noop:!0,removed:[],leftover:[]};if(!u.has(i))await _e("reactions.add",()=>qn(e,t,n,i,o));let l=[],d=[];for(let p of f){if(p===i)continue;try{await _e("reactions.remove",()=>Yn(e,t,n,p,o)),l.push(p)}catch{d.push(p)}}return{noop:!1,added:r,removed:l,leftover:d}}async function Uc(e,t,n,r,s,o,i){let a=s.flags[r];if(o)await _e("reactions.remove",()=>Yn(e,t,n,a,i));else await _e("reactions.add",()=>qn(e,t,n,a,i));return a}var qr=1000;async function Kc(e,t,n,r={}){let s=r.limit??qr,o=r.cookie,i=await vc(e,o),a=Zt.map((d)=>n.progress[d]),c=[],u=0,f,l=!1;while(u<s){let d=Math.min(200,s-u),p=await _e("conversations.history",()=>un(e,t,d,void 0,f,o)),m=p.messages??[];u+=m.length;for(let h of m){let y=String(h.ts??"");if(!y)continue;let E=new Set((h.reactions??[]).filter((A)=>(A.users??[]).map(String).includes(i)).map((A)=>String(A.name??""))),F=a.filter((A)=>E.has(A));if(F.length<2)continue;c.push({ts:y,text:String(h.text??"").split(`
166
+ `)[0]??"",emoji:F,keep:F[0]})}if(f=p.response_metadata?.next_cursor||void 0,!f||m.length===0)break;if(u>=s){l=!0;break}}if(r.fix)for(let d of c)try{try{await _e("reactions.add",()=>qn(e,t,d.ts,d.keep,o))}catch(p){if(!(p instanceof Error)||!/already_reacted/.test(p.message))throw p}for(let p of d.emoji){if(p===d.keep)continue;await _e("reactions.remove",()=>Yn(e,t,d.ts,p,o))}d.fixed=!0}catch(p){d.fixed=!1,d.error=p instanceof Error?p.message:String(p)}return{scanned:u,findings:c,truncated:l}}var Kf=!0,Jf;function Yr(e){if(Kf=e,!e)Jf=void 0}function ft(e){return e.replace(new RegExp(`[${"\\\\¥"}](.)`,"gs"),(t,n)=>{switch(n){case"n":return`
167
+ `;case"t":return"\t";case"\\":case"¥":return n==="¥"?"¥":"\\";default:return t}})}function vt(e){return e.toLowerCase().replace(/[-_\s]/g,"")}function dt(e){return e&&typeof e==="object"&&!Array.isArray(e)?e:{}}function zf(e,t){let n=vt(t),r=dt(e.profile);for(let o of[e.name,e.real_name,r.display_name,r.real_name])if(typeof o==="string"&&o&&vt(o)===n)return!0;let s=typeof r.email==="string"?r.email.toLowerCase():"";return s!==""&&s===t.toLowerCase()}function Hf(e){let t=dt(e.profile),n=new Set;for(let r of[t.display_name,e.real_name,e.name,t.real_name])if(typeof r==="string"&&r){let s=vt(r);if(s.length>=2)n.add(s)}return[...n]}function qf(e,t){let n=vt(e),r,s=!1;for(let o of t){let i=typeof o.id==="string"?o.id:"";if(!i)continue;for(let a of Hf(o)){let c=-1;if(n===a)c=e.length;else for(let u of zc)if(e.length>u.length&&e.endsWith(u)&&vt(e.slice(0,e.length-u.length))===a){c=e.length-u.length;break}if(c<0)continue;if(!r||a.length>r.formLen)r={userId:i,matchLen:c,formLen:a.length,display:Vr(o)},s=!1;else if(a.length===r.formLen&&r.userId!==i)s=!0}}if(!r)return;return s?"ambiguous":{userId:r.userId,matchLen:r.matchLen,display:r.display}}async function jt(e,t,n,r){let s=`[${Hc}ー]+`,o=`${s}(?:[._-]+${s})*`,i=new RegExp(`(?<![A-Za-z0-9._@<-])@(${o})`,"gu"),a=new Set;for(let F of t.matchAll(i))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 A of a){if(c.get(A).status!=="pending")continue;if(Gr(A)){let k=qf(A,F);if(k==="ambiguous")c.set(A,{status:"ambiguous"});else if(k)c.set(A,{status:"resolved",userId:k.userId,matchLen:k.matchLen,display:k.display})}else{let k=F.filter((I)=>zf(I,A)),B=new Set(k.map((I)=>typeof I.id==="string"?I.id:"").filter(Boolean));if(B.size===1){let I=k.find((R)=>typeof R.id==="string");c.set(A,{status:"resolved",userId:I.id,matchLen:A.length,display:Vr(I)})}else if(B.size>1)c.set(A,{status:"ambiguous"})}}},f=!1;try{let F=await Vn(e,r);u((F.members??[]).map(dt)),f=!0}catch{f=!1}let l=[...a].some((F)=>c.get(F).status==="pending"),d=!1,p=!0;if(l&&n){d=!0;try{let F=await Dr(e,n,r),A=[];for(let k of F){let B=dt(await yr(e,k,r)),I=dt(B.user);if(typeof I.id!=="string")I.id=k;A.push(I)}u(A)}catch{p=!1}}let m=f&&(n?d&&p:!0),h=[],y=[];for(let F of a){let A=c.get(F);if(A.status==="resolved")h.push({surface:`@${F.slice(0,A.matchLen)}`,display:A.display,userId:A.userId});else if(A.status==="ambiguous")y.push({surface:`@${F}`,reason:"ambiguous"});else y.push({surface:`@${F}`,reason:m?"no-match":"unavailable"})}return{text:t.replace(i,(F,A)=>{let k=c.get(A);if(k&&k.status==="resolved")return`<@${k.userId}>${A.slice(k.matchLen)}`;return F}),resolved:h,unresolved:y}}function Cn(e){let t=[],n=!1;for(let r of e)if(r.reason==="ambiguous")t.push(`${r.surface} matches multiple people — not tagged, sent as plain text (use <@USERID> to tag)`);else if(r.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(`${r.surface} matched no one — not tagged, sent as plain text`);return t}async function Jc(e,t,n,r={}){let s=r.warn??((i)=>process.stderr.write(`${i}
168
+ `)),o=await jt(e,t,n,r.cookie);for(let i of Cn(o.unresolved))s(`warn: ${i}`);return o.text}var zc=["さん","さま","様","君","くん","ちゃん","氏","先生","先輩","殿","老师","老師","兄","姐","哥","姐妹"],Hc="\\p{Script=Han}\\p{Script=Hiragana}\\p{Script=Katakana}A-Za-z0-9";function Gr(e){return/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}]/u.test(e)}function Yf(e){let t=[],n=new RegExp(`([${Hc}]{1,12})(${zc.join("|")})`,"gu");for(let r of e.matchAll(n))t.push({ref:r[1],honorific:r[2]});for(let r of e.matchAll(/\b(?:dear|hi|hello|hey)\b[ \t]+([A-Z][A-Za-z'’-]{1,20})/gi))t.push({ref:r[1],honorific:""});for(let r of e.matchAll(/(?:^|\n)[ \t]*([A-Z][A-Za-z'’-]{1,20}),/g))t.push({ref:r[1],honorific:""});return t}function Xf(e){let t=dt(e.profile),n=new Set;for(let r of[e.name,e.real_name,t.display_name,t.real_name]){if(typeof r!=="string"||!r)continue;for(let s of[r,...r.split(/\s+/)]){let o=vt(s);if(o.length>=2)n.add(o)}}return[...n]}function Gf(e,t){let n=vt(e);if(n.length<2)return;for(let r of t)if(n===r)return r;if(Gr(e)){for(let r of t)if(n.includes(r)||r.includes(n))return r}return}function Vr(e){return[dt(e.profile).display_name,e.real_name,e.name].filter((r)=>typeof r==="string"&&r!=="")[0]??String(e.id??"?")}async function qc(e,t,n){let r=Yf(t);if(r.length===0)return[];let s=new Set;for(let u of t.matchAll(/<@([A-Z0-9]+)(?:\|[^>]*)?>/g))s.add(u[1]);let i=((await Vn(e,n)).members??[]).map(dt).filter((u)=>u.deleted!==!0&&u.is_bot!==!0&&u.id!=="USLACKBOT").map((u)=>({id:typeof u.id==="string"?u.id:"",forms:Xf(u),display:Vr(u)})).filter((u)=>u.id!==""),a=[],c=new Set;for(let{ref:u,honorific:f}of r)for(let l of i){let d=Gf(u,l.forms);if(!d)continue;if(s.has(l.id)||c.has(l.id))break;c.add(l.id),a.push({surface:Gr(u)?`${d}${f}`:u,display:l.display,userId:l.id});break}return a}async function Qt(e,t,n,r){let s=t,o=[],i=s,a=0;while(!0){let c=i.indexOf("<@U",a);if(c===-1)break;let u=i.slice(c+2),f=u.search(/[>|]/),l=f===-1?u:u.slice(0,f);if(l.length>=9)o.push(l);a=c+1}for(let c of o){if(!n.has(c))n.set(c,await Gn(e,c,r));let u=n.get(c)??c;s=s.replaceAll(`<@${c}>`,`@${u}`),s=s.replace(new RegExp(`<@${c}\\|[^>]*>`,"g"),`@${u}`)}return s}function En(e){return e.replace(/<!date\^(\d+)\^[^|>]*(?:\|([^>]*))?>/g,(t,n,r)=>{let s=Number(n);if(!Number.isFinite(s))return r??"date";let o=new Date(s*1000);if(Number.isNaN(o.getTime()))return r??"date";let i=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],a=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],c=i[o.getUTCDay()]??"",u=a[o.getUTCMonth()]??"";return`${c}, ${u} ${String(o.getUTCDate()).padStart(2,"0")}, ${o.getUTCFullYear()}`})}function Yc(e,t=new Date){let n=new Date(e*1000),r=Xr(t),s=Xr(new Date(t.getTime()-86400000)),o=Xr(n);if(o===r)return"Today";if(o===s)return"Yesterday";let i=n.toLocaleDateString("en-US",{weekday:"long"}),a=n.toLocaleDateString("en-US",{month:"short"});return`${i}, ${a} ${String(n.getDate()).padStart(2,"0")}`}function Xr(e){return`${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`}function Xc(e){let t=new Date(e*1000),n=t.getFullYear(),r=String(t.getMonth()+1).padStart(2,"0"),s=String(t.getDate()).padStart(2,"0"),o=String(t.getHours()).padStart(2,"0"),i=String(t.getMinutes()).padStart(2,"0");return`${n}-${r}-${s} ${o}:${i}`}function Gc(e=new Date,t){let n=process.env.SLACK_QUIET_TZ??"Asia/Tokyo",r=!!t&&Vf(t),s=r?t:n,o=Number(process.env.SLACK_QUIET_START??23),i=Number(process.env.SLACK_QUIET_END??8),a,c;try{let p=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=p.format(e),a=Number(p.formatToParts(e).find((m)=>m.type==="hour")?.value??"12")}catch{return null}let u=o>i?a>=o||a<i:a>=o&&a<i,f=r?`${s}, recipient`:`${s}, sender — recipient's timezone unknown`,l=`\uD83D\uDD50 ${c} (${f})`;if(!u)return l;return`${l}
169
+ ⚠ QUIET HOURS (${o}:00-${i}:00) — this will buzz a phone.${r?"":" Their local time may differ."} Send only for a production incident; otherwise hold it until morning.`}function Vf(e){try{return new Intl.DateTimeFormat("en-GB",{timeZone:e}),!0}catch{return!1}}function xn(e){if(!iu(e))return;let t=Qf(e,"utf8");for(let n of t.split(`
170
+ `)){let r=n.trim();if(!r||r.startsWith("#"))continue;let s=r.indexOf("=");if(s===-1)continue;let o=r.slice(0,s).trim(),i=r.slice(s+1).trim();if(i.startsWith('"')&&i.endsWith('"')||i.startsWith("'")&&i.endsWith("'"))i=i.slice(1,-1);if(!(o in process.env))process.env[o]=i}}function td(e){ed(e,{recursive:!0});let t=ht(e,".gitignore");if(!iu(t))au(t,`*
171
+ `)}function nd(){xn(ht(Vc(),".slack-cli",".env.local")),xn(ht(Vc(),".config/slack-cli",".env")),xn(ht(process.cwd(),".slack-cli",".env.local")),xn(ht(process.cwd(),".env.local")),xn(ht(process.cwd(),".env"))}function sd(e){return Zf("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 ws(e){return Number(e.ts??0)}async function cu(e,t,n){let r=t.user;if(typeof r==="string"){if(!n.has(r))n.set(r,await Ne(e,r));return n.get(r)??r}return typeof t.username==="string"?t.username:"bot"}function Qr(e){let t=new Date(e*1000),n=t.getUTCFullYear(),r=String(t.getUTCMonth()+1).padStart(2,"0"),s=String(t.getUTCDate()).padStart(2,"0"),o=String(t.getUTCHours()).padStart(2,"0"),i=String(t.getUTCMinutes()).padStart(2,"0"),a=String(t.getUTCSeconds()).padStart(2,"0");return`${n}-${r}-${s} ${o}:${i}:${a}`}function no(e){let[t,n="000000"]=e.split("."),r=Number(t),s=new Date(r*1000),o=s.getUTCFullYear(),i=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`${o}-${i}-${a}T${c}:${u}:${f}.${l}`}function so(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 rd(e){return/^\d{4}-\d{2}-\d{2}T/.test(e)?so(e):e}async function Es(e,t,n,r,s){let o=typeof t.ts==="string"?t.ts:`${ws(t)}.000000`,i=no(o),a="?";if(typeof t.user==="string"){let F=t.user,A="@"+F;if(!n.has(A)){let k=await jc(e,F,async(B,I,R)=>(await Dn(B,I,R))[1],s);n.set(A,k)}a=n.get(A)??F}else if(typeof t.username==="string")a=t.username;let c=typeof t.text==="string"?t.text:"",f=En(await Qt(e,c,n,s)).split(`
172
172
  `),l=f[0]+(f.length>1?`
173
173
  `+f.slice(1).map((F)=>` ${F}`).join(`
174
- `):""),d=r?`${r} @${a}`:`@${a}`,p=X(t.reactions).map(P).map((F)=>{let A=typeof F.name==="string"?F.name:"",_=Number(F.count??X(F.users).length??0);return A?`:${A}:\xD7${_}`:""}).filter(Boolean).join(" "),m=X(t.files).map(P).map((F)=>{let A=typeof F.name==="string"?F.name:typeof F.title==="string"?F.title:"(file)",_=typeof F.size==="number"?` (${Cs(F.size)})`:"",B=typeof F.id==="string"?` [${F.id}]`:"";return`
175
- \uD83D\uDCCE ${A}${_}${B}`}).join(""),h=Number(t.reply_count??0),y=h>0?` [+${h} ${h===1?"reply":"replies"}]`:"",E=(p?`
176
- ${p}`:"")+m;return`${o} ${d}: ${l}${y}${E}`}function Cs(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function nd(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 au(e){let t=nd(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:"",...Array.isArray(e.reactions)&&e.reactions.length?{reactions:X(e.reactions).map(P).map((n)=>({name:n.name??null,count:n.count??null,users:Array.isArray(n.users)?n.users:[]}))}:{},...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 sd(e,t,n,r,s){let i=[];for(let o of n){let a=o;if(Number(o.reply_count??0)>0&&typeof o.ts==="string"){let c=await qe(e,t,o.ts,200,s),u=X(c.messages).map(P);a=u[u.length-1]??o}if(a.user!==r)i.push(o)}return i}async function rd(e,t,n,r="text",s=!1,i){let o=Nt(t),a=await De(e,t,i),c=new Map,f=await(async()=>{if(o?.threadTs){let d=await qe(e,a,o.threadTs,n,i);return X(d.messages).map(P)}let l=await Ve(e,a,n,void 0,void 0,i);return X(l.messages).map(P).reverse()})();if(s){let{userId:l}=await rc(e,i);f=await sd(e,a,f,l,i)}if(r==="jsonl"){for(let l of f)console.log(JSON.stringify(au(l)));return}for(let l of f)console.log(await Fs(e,l,c,void 0,i))}async function id(e,t,n,r,s="text",i){let o=await De(e,t,i),a=await qe(e,o,td(n),r,i),c=X(a.messages).map(P);if(s==="jsonl"){for(let f of c)console.log(JSON.stringify(au(f)));return}let u=new Map;for(let f of c)console.log(await Fs(e,f,u,void 0,i))}async function od(e){let t=await mn(e),n=X(t.channels).map(P).filter((s)=>s.is_member===!0).sort((s,i)=>Number(i.updated??0)-Number(s.updated??0)).slice(0,10),r=new Map;for(let s of n){let i=String(s.id??""),o=typeof s.name==="string"?s.name:typeof s.user==="string"?s.user:i,a=await Ve(e,i,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 ou(e,u,r),l=(typeof u.text==="string"?u.text:"").split(`
177
- `)[0]??"",d=await Qt(e,l,r);console.log(` ${f}: ${d}`)}}}async function ad(e,t){let n=await lc(e,"to:me"),r=X(pn(n,["messages","matches"])).map(P).slice(0,t),s=new Map,i=[];for(let o of r){let a=qc(ys(o)),c=i[i.length-1];if(c?.label===a)c.msgs.push(o);else i.push({label:a,msgs:[o]})}for(let o=0;o<i.length;o++){let{label:a,msgs:c}=i[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",p;if(l&&d.startsWith("U")){let m="@"+d;if(!s.has(m)){let[,h]=await Dn(e,d);s.set(m,h)}p=`@${s.get(m)??d}`}else if(l)p=`@${d}`;else p=`#${d}`;console.log(await Fs(e,u,s,p))}}}async function cd(e,t,n,r,s="text"){let i=await mn(e),o=X(i.channels).map(P).filter((a)=>r||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?"@":"#",p=a.is_member===!0?"":" (not joined)",m=typeof P(a.purpose).value==="string"?String(P(a.purpose).value):"",h=m?` ${m.split(`
178
- `)[0]?.slice(0,60)}`:"";console.log(`${d}${u} ${c}${p}${h}`)}}function ud(e){let t=(s)=>s.startsWith("xoxp-")||s.startsWith("xoxc-"),n=lr(),r=n.find((s)=>s.profile.token===e);if(!r)return;return n.find((s)=>t(s.profile.token)&&s.profile.teamId===r.profile.teamId)}async function cu(e,t,n,r,s){let i=e,o=s,a;try{a=await Lr(i,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=ud(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}".`),i=d.profile.token,o=d.profile.cookie,a=await Lr(i,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.
174
+ `):""),d=r?`${r} @${a}`:`@${a}`,p=X(t.reactions).map(P).map((F)=>{let A=typeof F.name==="string"?F.name:"",k=Number(F.count??X(F.users).length??0);return A?`:${A}:\xD7${k}`:""}).filter(Boolean).join(" "),m=X(t.files).map(P).map((F)=>{let A=typeof F.name==="string"?F.name:typeof F.title==="string"?F.title:"(file)",k=typeof F.size==="number"?` (${xs(F.size)})`:"",B=typeof F.id==="string"?` [${F.id}]`:"";return`
175
+ \uD83D\uDCCE ${A}${k}${B}`}).join(""),h=Number(t.reply_count??0),y=h>0?` [+${h} ${h===1?"reply":"replies"}]`:"",E=(p?`
176
+ ${p}`:"")+m;return`${i} ${d}: ${l}${y}${E}`}function xs(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function od(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 uu(e){let t=od(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:"",...Array.isArray(e.reactions)&&e.reactions.length?{reactions:X(e.reactions).map(P).map((n)=>({name:n.name??null,count:n.count??null,users:Array.isArray(n.users)?n.users:[]}))}:{},...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 id(e,t,n,r,s){let o=[];for(let i of n){let a=i;if(Number(i.reply_count??0)>0&&typeof i.ts==="string"){let c=await qe(e,t,i.ts,200,s),u=X(c.messages).map(P);a=u[u.length-1]??i}if(a.user!==r)o.push(i)}return o}async function ad(e,t,n,r="text",s=!1,o){let i=Nt(t),a=await De(e,t,o),c=new Map,f=await(async()=>{if(i?.threadTs){let d=await qe(e,a,i.threadTs,n,o);return X(d.messages).map(P)}let l=await Ve(e,a,n,void 0,void 0,o);return X(l.messages).map(P).reverse()})();if(s){let{userId:l}=await oc(e,o);f=await id(e,a,f,l,o)}if(r==="jsonl"){for(let l of f)console.log(JSON.stringify(uu(l)));return}for(let l of f)console.log(await Es(e,l,c,void 0,o))}async function cd(e,t,n,r,s="text",o){let i=await De(e,t,o),a=await qe(e,i,rd(n),r,o),c=X(a.messages).map(P);if(s==="jsonl"){for(let f of c)console.log(JSON.stringify(uu(f)));return}let u=new Map;for(let f of c)console.log(await Es(e,f,u,void 0,o))}async function ud(e){let t=await mn(e),n=X(t.channels).map(P).filter((s)=>s.is_member===!0).sort((s,o)=>Number(o.updated??0)-Number(s.updated??0)).slice(0,10),r=new Map;for(let s of n){let o=String(s.id??""),i=typeof s.name==="string"?s.name:typeof s.user==="string"?s.user:o,a=await Ve(e,o,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(`-- #${i} --------------------------------`);for(let u of c){let f=await cu(e,u,r),l=(typeof u.text==="string"?u.text:"").split(`
177
+ `)[0]??"",d=await Qt(e,l,r);console.log(` ${f}: ${d}`)}}}async function ld(e,t){let n=await fc(e,"to:me"),r=X(hn(n,["messages","matches"])).map(P).slice(0,t),s=new Map,o=[];for(let i of r){let a=Yc(ws(i)),c=o[o.length-1];if(c?.label===a)c.msgs.push(i);else o.push({label:a,msgs:[i]})}for(let i=0;i<o.length;i++){let{label:a,msgs:c}=o[i];if(i>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",p;if(l&&d.startsWith("U")){let m="@"+d;if(!s.has(m)){let[,h]=await Dn(e,d);s.set(m,h)}p=`@${s.get(m)??d}`}else if(l)p=`@${d}`;else p=`#${d}`;console.log(await Es(e,u,s,p))}}}async function fd(e,t,n,r,s="text"){let o=await mn(e),i=X(o.channels).map(P).filter((a)=>r||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 i)console.log(JSON.stringify(a));return}for(let a of i){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?"@":"#",p=a.is_member===!0?"":" (not joined)",m=typeof P(a.purpose).value==="string"?String(P(a.purpose).value):"",h=m?` ${m.split(`
178
+ `)[0]?.slice(0,60)}`:"";console.log(`${d}${u} ${c}${p}${h}`)}}function dd(e){let t=(s)=>s.startsWith("xoxp-")||s.startsWith("xoxc-"),n=fr(),r=n.find((s)=>s.profile.token===e);if(!r)return;return n.find((s)=>t(s.profile.token)&&s.profile.teamId===r.profile.teamId)}async function lu(e,t,n,r,s){let o=e,i=s,a;try{a=await Wr(o,t,n,i)}catch(f){let l=f instanceof Error?f.message:String(f);if(e.startsWith("xoxb-")&&l.includes("not_allowed_token_type")){let d=dd(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}".`),o=d.profile.token,i=d.profile.cookie,a=await Wr(o,t,n,i);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.
179
179
  `+` Add a user-token profile: slack auth login (or slack auth token)
180
- Then select it: slack auth use <name> (or pass --workspace <name>)`),process.exit(1)}else throw f}if(r){console.log(JSON.stringify(a,null,2));return}let c=X(pn(a,["messages","matches"])).map(P),u=new Map;for(let f of c){let l=P(f.channel),d=l.is_im===!0,p=typeof l.name==="string"?l.name:"dm",m;if(d&&p.startsWith("U")){let h="@"+p;if(!u.has(h)){let[,y]=await Dn(i,p,o);u.set(h,y)}m=`@${u.get(h)??p}`}else if(d)m=`@${p}`;else m=`#${p}`;console.log(await Fs(i,f,u,m,o))}}async function uu(e,t,n,r){let{ref:s,ts:i}=xs(t);if(!i)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 zr(e,s,De,r),ts:i}}async function ld(e,t){let n=Fn(),r={};if(!t.mine)r.shared=!0;if(t.in)r.in=t.in;if(t.from)r.from=t.from;let s=Mc(t.state,n,r);if(!t.json){let i=await en(e,t.cookie),o=t.mine?"your reactions only [hasmy:]":"anyone's reactions [has:]";console.error(`(From: ${fu(i)} \xB7 matching ${o})`),console.error(`(query: ${s})`)}await _e("search.messages",()=>cu(e,s,t.count,t.json,t.cookie))}async function fd(e,t){let n=Fn(),{channelId:r,ts:s}=await uu(e,t.target,t.channelId,t.cookie),i=await Lc(e,r,s,t.state,n,t.cookie);if(i.noop){console.log(`= Already ${t.state} (ts: ${s})`);return}let o=i.removed.length?`, removed ${i.removed.map((a)=>`:${a}:`).join(" ")}`:"";if(console.log(`\u2713 ${t.state} :${n.progress[t.state]}: (ts: ${s})${o}`),i.leftover.length)console.error(`\u26A0 ${i.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 dd(e,t){let n=Fn(),{channelId:r,ts:s}=await uu(e,t.target,t.channelId,t.cookie),i=await Wc(e,r,s,t.flag,n,t.remove===!0,t.cookie);console.log(`\u2713 ${t.remove?"Cleared":"Flagged"} ${t.flag} :${i}: (ts: ${s})`)}async function pd(e,t){let n=Fn(),r=t.channelId??await zr(e,t.channel,De,t.cookie),s={limit:t.limit};if(t.fix)s.fix=!0;if(t.cookie)s.cookie=t.cookie;let i=await Uc(e,r,n,s);if(i.findings.length===0)console.log(`\u2713 No multi-state tasks in ${i.scanned} message(s).`);else{for(let o of i.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}] ${ee(o.text).slice(0,60)}`)}console.log(`${i.findings.length} multi-state task(s) in ${i.scanned} message(s).`)}if(i.truncated)console.error(`\u26A0 Scan limit reached (${t.limit} messages) \u2014 older history was NOT checked. Raise it with --limit N.`)}async function hd(e,t,n,r){let s=Math.floor(Date.now()/1000)-t*86400,i=await mn(e),o=X(i.channels).map(P).filter((f)=>f.is_member===!0&&f.is_im!==!0&&f.is_mpim!==!0).filter((f)=>{if(!r)return!0;return(typeof f.name==="string"?f.name:"").toLowerCase().includes(r.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,p;try{p=await Ve(e,l,n)}catch(h){console.error(` SKIP #${d}: ${h.message}`);continue}let m=X(p.messages).map(P).filter((h)=>(h.subtype===void 0||h.subtype===null)&&ys(h)>=s);if(m.length===0)continue;u+=1,c+=m.length,console.log(`## #${d} (${m.length} msgs)
181
- `);for(let h of[...m].reverse()){let y=await ou(e,h,a),E=typeof h.text==="string"?h.text:"",A=En(await Qt(e,E,a)).split(`
182
- `).join(" \u21B5 ");console.log(`[${Yc(ys(h))}] ${y}: ${A}`)}console.log("")}console.error(`Dumped ${c} messages across ${u} channels (cutoff: ${t}d)`)}function gd(e){let t=[];function n(r){if(typeof r==="string"){t.push(r);return}if(Array.isArray(r)){for(let s of r)n(s);return}if(r&&typeof r==="object"){let s=r;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 r of e)n(r);return t.join("").trim()}async function lu(e,t,n){let r=new Map;return async(s)=>{if(!s)return"(unknown)";if(r.has(s))return r.get(s);try{let i=await kc(e,s,t),o=P(i.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 Dn(e,c);a=`@${u}`}}else a=`#${typeof o.name==="string"?o.name:s}`;return r.set(s,a),a}catch{return s}}}function si(e){let t=P(X(e.destinations)[0]);return String(t.channel_id??e.channel_id??e.channel??"")}function ws(e){return gd(X(e.blocks))||(typeof e.text==="string"?e.text:"(no text)")}async function md(e,t,n=!1){let r=await yn(e,t),s=X(r.drafts??r.messages??[]).map(P).filter((u)=>u.is_deleted!==!0),i=n?s:s.filter((u)=>u.is_sent!==!0);if(i.length===0){console.log(n?"No drafts.":"No pending drafts. Run with --all to include sent.");return}let o="";try{({userId:o}=await Wr(e,t))}catch{}let a=await lu(e,t,o),c=new Map;for(let u of i){let f=si(u),l=ws(u),d=Number(u.date_created??u.date_create??0),p=d?Zr(d):"?",m=await a(f),h=typeof u.id==="string"?u.id:"",y=u.is_sent===!0?" [SENT]":"",E=En(await Qt(e,l,c));console.log(`-- ${h} ${m} [${p}]${y}`);for(let F of E.split(`
183
- `))console.log(` ${F}`)}}async function Dd(e,t,n){let r=await yn(e,t),s=X(r.drafts).map(P).find((m)=>String(m.id)===n);if(!s)console.error(`Draft not found: ${n}`),process.exit(1);let i="";try{({userId:i}=await Wr(e,t))}catch{}let o=await lu(e,t,i),a=si(s),c=ws(s),u=Number(s.date_created??0),f=String(s.last_updated_ts??"?"),l=await o(a),p=En(await Qt(e,c,new Map));console.log(`id: ${s.id}`),console.log(`channel: ${l} (${a})`),console.log(`created: ${u?Zr(u):"?"}`),console.log(`updated: ${Zr(Number(f.split(".")[0]))}`),console.log(`status: ${s.is_sent===!0?"sent":"pending"}`),console.log("---"),console.log(p)}function Ye(...e){return ed(e.join(`
184
- `)).slice(0,4)}function ee(e){return e.replace(/\x1b\[[0-9;:?]*[ -/]*[@-~]/g,"").replace(/[\x00-\x1f\x7f-\x9f]/g,"").replace(/[\u061c\u200e\u200f\u202a-\u202e\u2066-\u2069]/g,"")}var yd={"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 et(e){let t=e instanceof Error?e.message:String(e),n=t.match(/Slack error on (\S+): (\w+)/);if(!n)return t;let[,r,s]=n;switch(s){case"missing_scope":return`Error: token lacks the ${yd[r]??"the required"} scope (needed for ${r}). 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 Es(e,t,n){if(!t.startsWith("D"))return null;try{let r=await ks(e,t,n);if(!r)return null;return await jc(e,r,wn,n)}catch{return null}}function je(e,t,n,r,s=new Date){for(let o of n)console.log(o);let i=Xc(s,r);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 xs(e){let t=Nt(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 r=e.slice(n+1);if(/^\d{10}\.\d{6}$/.test(r))return{ref:e.slice(0,n),ts:r};if(/^\d{4}-\d{2}-\d{2}T/.test(r))return{ref:e.slice(0,n),ts:ni(r)}}}return{ref:e}}function _n(e,t=!0){let n=Nt(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 r=e.indexOf(":");if(r>0){let s=e.slice(r+1);if(/^\d{10}\.\d{6}$/.test(s))return{ref:e.slice(0,r),threadTs:s};if(/^\d{4}-\d{2}-\d{2}T/.test(s))return{ref:e.slice(0,r),threadTs:ni(s)}}return{ref:e}}async function _s(e,t,n,r){let s=n;if(/^#?[CDG][A-Z0-9]{8,}$/.test(n)||!n.startsWith("#")&&!n.startsWith("@"))try{let o=P(await bn(e,t,r)),a=P(o.channel);if(a.is_im===!0){let c=typeof a.user==="string"?a.user:"";s=c?`@${await Ne(e,c,r)}`:t}else s=typeof a.name==="string"?`#${a.name}`:t}catch{s=t}return s===t?t:`${s} (${t})`}async function en(e,t){try{return await ic(e,t)}catch{return null}}function Lt(e,t){let n;return async()=>{if(n===void 0)n=await en(e,t);return n}}function fu(e,t){let n=t?" [as bot]":"";if(!e)return`(unknown \u2014 auth.test failed)${n}`;let r=ee(e.user||e.userId||"?"),s=e.userId?` (${e.userId})`:"",i=e.team?` \u2014 ${ee(e.team)}`:"";return`@${r}${s}${i}${n}`}function Le(e,t={}){return` ${"From:".padEnd(t.pad??6)}${fu(e,t.asBot)}`}async function Qr(e,t,n=60,r){let s=typeof t.user==="string"?await Ne(e,t.user,r):typeof t.username==="string"?t.username:"?",i=(typeof t.text==="string"?t.text:"").split(`
185
- `)[0]??"",o=i.length>n?`${i.slice(0,n)}\u2026`:i,a=typeof t.ts==="string"?t.ts:"";return`${a?ti(a).slice(0,16).replace("T"," "):""} @${s}${o?`: ${o}`:""}`}async function wd(e,t,n,r){let s=n.find((i)=>String(i.ts)===t)??n[0];if(!s)return t;return Qr(e,s,40,r)}function Vc(e){return e.toLowerCase().replace(/<[@#!][^>]+>/g," ").replace(/[^\p{L}\p{N}\s]/gu," ").replace(/\s+/g," ").trim()}function bd(e,t){let n=Vc(e),r=Vc(t);if(!n||!r)return 0;if(n===r)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},i=s(n),o=s(r);if(i.size===0||o.size===0)return 0;let a=0;for(let[u,f]of i){let l=o.get(u);if(l)a+=Math.min(f,l)}let c=Zc(i)+Zc(o);return c===0?0:2*a/c}function Zc(e){let t=0;for(let n of e.values())t+=n;return t}async function Fd(e,t){let n=Lt(e,t.cookie),{ref:r,ts:s}=xs(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 i;if(t.channelId)i=t.channelId;else i=await De(e,r,t.cookie);let o=await qe(e,i,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 ${i}`),process.exit(1);let u=typeof c.text==="string"?c.text:"",f=t.mentions?await Kc(e,t.newText,i,t.cookie?{cookie:t.cookie}:{}):t.newText,l=await n(),d=Ye(u,f,l?.userId??"");if(t.code!==d)je(t.code,d,["--- Editing as -------------------------------",Le(l),"--- Original message -------------------------",...u.split(`
186
- `).map((m)=>` ${m}`),"--- Replacing with ---------------------------",...f.split(`
187
- `).map((m)=>` ${m}`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);let p=await Gt(e,i,s,f,t.cookie);console.log(`\u2713 Edited (ts: ${p})`)}async function Cd(e,t){let n=Lt(e,t.cookie),{ref:r,ts:s}=xs(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 i;if(t.channelId)i=t.channelId;else i=await De(e,r,t.cookie);let o=await qe(e,i,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 ${i}`),process.exit(1);let u=typeof c.text==="string"?c.text:"",f=await n(),l=Ye(i,s,u,f?.userId??"");if(t.code!==l){let d=await _s(e,i,r,t.cookie);je(t.code,l,["--- Deleting message -------------------------",Le(f),` \u2192 ${d} at ${ti(s)}`,...u.split(`
188
- `).map((p)=>` ${p}`),"---------------------------------------------"])}await hc(e,i,s,t.cookie),console.log(`\u2713 Deleted (ts: ${s})`)}async function Ed(e,t){let{ref:n,ts:r}=xs(t.target);if(!r)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,""),i;if(t.channelId)i=t.channelId;else i=await De(e,n,t.cookie);if(t.remove)await gn(e,i,r,s,t.cookie),console.log(`\u2713 Removed :${s}: (ts: ${r})`);else await Vt(e,i,r,s,t.cookie),console.log(`\u2713 Reacted :${s}: (ts: ${r})`)}async function ri(e,t,n,r){if(!n||!t.startsWith("D"))return!1;try{let s=P(await bn(e,t,r)),i=P(s.channel);return i.is_im===!0&&i.user===n}catch{return!1}}async function xd(e,t){let{ref:n,threadTs:r}=_n(t.target),s=t.cookie,i=Lt(e,s),o;if(t.channelId)o=t.channelId;else if(t.userId)o=await at(e,t.userId,s);else o=await De(e,n,s);if(!t.asBot&&await ri(e,o,(await i())?.userId,s))console.error(`Warning: "${t.target}" is a DM to yourself \u2014 Slack will NOT notify you of your own message.
189
- `+` To reach yourself with a notification, send as the bot: slack send '${t.target}' '...' --as-bot`);let a=lt(t.message),c=a,u=null;if(t.mentions){u=await jt(t.mentionToken??e,a,o,t.mentionCookie),c=u.text;for(let I of Cn(u.unresolved))console.error(`\u26A0 ${ee(I)}`)}try{for(let I of await Hc(t.mentionToken??e,c,t.mentionCookie))console.error(`\u26A0 possible untagged mention: ${ee(I.surface)} \u2014 @${ee(I.display)} won't be notified (did you mean <@${I.userId}>?)`)}catch{}let f=[];if(u&&(u.resolved.length>0||u.unresolved.length>0)){f.push("--- Mentions ---------------------------------");for(let I of u.resolved)f.push(` \u2713 ${ee(I.surface)} \u2192 @${ee(I.display)} (${I.userId}) \u2014 will notify`);for(let I of u.unresolved){let R=I.reason==="ambiguous"?"ambiguous":I.reason==="unavailable"?"lookup unavailable":"no match";f.push(` \u26A0 ${ee(I.surface)} \u2014 plain text, NOT notified (${R})`)}}let l="",d="?",p=[],m,h,y;if(r)try{let I=await qe(e,o,r,100,s);p=X(I.messages).map(P);let R=p[p.length-1];l=typeof R?.text==="string"?R.text:"",m=typeof R?.user==="string"?R.user:void 0,h=typeof R?.bot_id==="string"?R.bot_id:void 0,y=typeof R?.ts==="string"?R.ts:void 0}catch{}else try{let I=await Ve(e,o,1,void 0,void 0,s),R=X(I.messages).map(P),V=R.filter((ne)=>ne.subtype===void 0||ne.subtype===null)[0];l=typeof V?.text==="string"?V.text:"",d=typeof V?.user==="string"?await Ne(e,V.user,s):typeof V?.username==="string"?V.username:"?";let L=R[0];m=typeof L?.user==="string"?L.user:void 0,h=typeof L?.bot_id==="string"?L.bot_id:void 0,y=typeof L?.ts==="string"?L.ts:void 0}catch{}if(process.env.SLACK_UNREPLIED_WARN!=="0"&&y&&(m||h))try{let I=await i();if(!!I&&(!!m&&!!I.userId&&I.userId===m||!!h&&!!I.botId&&I.botId===h)){let V=`slack edit "#${o}:${y}" "<\u65B0\u3057\u3044\u672C\u6587>" --channel-id ${o}`;try{let L=await hn(e,o,y,s);if(L)V=`slack edit "${L}" "<\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(` ${V}`),console.error(" \u3053\u306E\u307E\u307E\u9001\u4FE1\u3059\u308B\u5834\u5408\u306F --code=XXXX \u3067\u78BA\u5B9A\u3002")}}catch{}if(r&&p.length){let I={sim:0,msg:null};for(let R of p){let V=typeof R.text==="string"?R.text:"";if(!V)continue;let L=bd(c,V);if(L>I.sim)I={sim:L,msg:R}}if(I.msg&&I.sim>=0.82){let R=Math.round(I.sim*100);console.error(`\u26A0 possible duplicate: ${R}% similar to an existing thread message \u2014 ${await Qr(e,I.msg,60,s)}`)}}let E=await i(),F=await Es(e,o,s),A=Ye(o,r??"",l,c,E?.userId??"");if(t.code!==A){let I=await _s(e,o,n,s),R=Le(E,{asBot:t.asBot});if(r){let V=await wd(e,r,p,s),L=p.slice(-3),ne=L.length?await Promise.all(L.map(async(k)=>` ${await Qr(e,k,60,s)}`)):[" (thread context unavailable)"];je(t.code,A,["--- Recent messages in thread ----------------",...ne,...f,"--- Sending ----------------------------------",R,` \u2192 ${I} thread of ${V} \u2014 THREAD REPLY`,` Message: ${c}`,"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"],F)}else je(t.code,A,["--- Last message in channel ------------------",` ${d}: ${l.split(`
190
- `)[0]?.slice(0,100)??"(empty)"}`,...f,"--- Sending ----------------------------------",R,` \u2192 ${I} \u2014 NEW top-level message`,` Message: ${c}`,"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"],F)}let _=await ds(e,o,c,r,t.broadcast,s),B="";try{B=await hn(e,o,_,s)}catch{}if(B)console.log(`\u2713 Sent: ${B}`);else console.log(`\u2713 Sent (ts: ${_})`);if(t.asBot&&o.startsWith("D"))try{let I=await Gn(e);if(!I.ok)for(let R of Vn(I,!0))console.error(R);else{let R=I.appId?`https://api.slack.com/apps/${I.appId}`:"https://api.slack.com/apps";console.error(`Note: if ${t.target} can't reply (app messaging may be off), enable Messages Tab: ${R} \u2192 App Home.`)}}catch{}}var _d=2,Ee=3,kd=4,Sd=1.618033988749895,Ad=1000,$d=5000,Qc=8,Od=(e)=>new Promise((t)=>setTimeout(t,e)),Id=new Set(["thread_broadcast"]),Td=/(?<![A-Za-z0-9._@<-])@(here|channel|everyone)(?![A-Za-z0-9._-])/giu;function bs(e){let t=new Set;return{text:e.replace(Td,(r,s)=>{let i=s.toLowerCase();return t.add(i),`<!${i}>`}),kinds:t}}async function ks(e,t,n){if(!t.startsWith("D"))return;try{let r=P(await bn(e,t,n)),s=P(r.channel);return s.is_im===!0&&typeof s.user==="string"?s.user:void 0}catch{return}}async function du(e,t){let{channelId:n,ts:r,question:s,reactable:i,threadOnly:o,audience:a,broadcast:c,cookie:u,timeout:f,shown:l}=t,{askerUserId:d,askerBotId:p}=t,m=(k)=>typeof k==="string"&&!!k&&k!==d&&(c||a.has(k)),h,y="";function E(k){let C=X(k.reactions).map(P),S=[];for(let O=0;O<i.length;O++){let W=C.find((q)=>q.name===Be[O].name),G=W?X(W.users).filter(m):[];if(G.length)S.push({index:O,users:G})}return S}async function F(k,C){let S=typeof k.text==="string"?k.text:"";if(!S)return;let O=$r(S,C);if(O===S)return;try{await Gt(e,n,r,O,u,!0)}catch(W){console.error(` (\u8CEA\u554F\u6587\u306B\u6CE8\u610F\u66F8\u304D\u3092\u5165\u308C\u3089\u308C\u307E\u305B\u3093\u3067\u3057\u305F: ${W instanceof Error?W.message:String(W)})`)}}async function A(k){let C=E(k);if(C.length<=1&&Ar(typeof k.text==="string"?k.text:"").length)await F(k,[]);if(!C.length)return null;if(C.length===1){let{index:W,users:G}=C[0];return{answer:i[W],how:`\u30EA\u30A2\u30AF\u30B7\u30E7\u30F3 ${Be[W].glyph}`,who:G[0]}}let S=C.map((W)=>Be[W.index].glyph).join(" / ");console.error(` (${S} \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 O=[...new Set(C.flatMap((W)=>W.users))].sort();return await F(k,O),null}let _=[...i,...t.overflow];function B(k,C=1/0){let S=[...k].sort((O,W)=>Number(O.ts)-Number(W.ts));for(let O of S){if(!(Number(O.ts)>Number(r)))continue;if(!m(O.user))continue;if(typeof O.subtype==="string"&&!Id.has(O.subtype))continue;if(Number(O.ts)>=C)break;let W=typeof O.text==="string"?O.text.trim():"";if(!W)continue;if(!_.length)return{answer:W,how:"\u8FD4\u4FE1",who:O.user};let G=Ja(W,_);if(G.kind==="chosen")return{answer:_[G.index-1],how:`\u8FD4\u4FE1 (${G.index})`,who:O.user};if(!h||Number(O.ts)<Number(h.ts))h={text:W,who:typeof O.user==="string"?O.user:"",ts:String(O.ts),ambiguous:G.kind==="ambiguous"}}return null}async function I(){if(h=void 0,t.threadParentTs){let O=P(await qe(e,n,t.threadParentTs,100,u)),W=X(O.messages).map(P),G=W.find((q)=>q.ts===r);if(G){let q=await A(G);if(q)return q}return B(W)}let k=P(await Ve(e,n,30,r,void 0,u,!0)),C=X(k.messages).map(P),S=C.find((O)=>O.ts===r);if(S){let O=await A(S);if(O)return O}if(!o){let O=C.filter((G)=>Number(G.ts)>Number(r)&&(p&&G.bot_id===p||d&&G.user===d)).reduce((G,q)=>Math.min(G,Number(q.ts)),1/0),W=B(C,O);if(W)return W}if(S&&Number(S.reply_count)>0){let O=P(await qe(e,n,r,30,u)),W=B(X(O.messages).map(P));if(W)return W}return null}async function R(k){for(let S=0;S<i.length;S++)try{await gn(e,n,r,Be[S].name,u)}catch{}let C="";if(k.who)try{C=await Ne(e,k.who,u)}catch{C=k.who}if(C)console.error(` \u56DE\u7B54\u8005: ${ee(C)}`);try{await Gt(e,n,r,Wa(s,k,C),u,!0);try{await Vt(e,n,r,Or,u),await gn(e,n,r,cs,u)}catch{}}catch(S){console.error(` (\u5143\u30E1\u30C3\u30BB\u30FC\u30B8\u306E\u66F4\u65B0\u306B\u5931\u6557: ${S instanceof Error?S.message:String(S)})`)}}let V=Date.now()+f*1000,L=0,ne=Ad;for(;;){let k=null;try{k=await I(),L=0}catch(C){if(L++,L>=Qc)console.error(`Error: Slack \u3078\u306E\u554F\u3044\u5408\u308F\u305B\u306B ${L} \u56DE\u9023\u7D9A\u3067\u5931\u6557\u3057\u307E\u3057\u305F: ${C instanceof Error?C.message:String(C)}`),process.exit(Ee);console.error(` (Slack \u30A8\u30E9\u30FC ${L}/${Qc}, \u518D\u8A66\u884C\u3057\u307E\u3059: ${C instanceof Error?C.message:String(C)})`)}if(k)await R(k),console.log(k.answer),process.exit(0);if(h&&h.ts!==y){y=h.ts;let C=h.who;try{if(C)C=await Ne(e,C,u)}catch{}console.error(h.ambiguous?` (${ee(C)} \u306E\u8FD4\u4FE1\u306F\u8907\u6570\u306E\u9078\u629E\u80A2\u306B\u4E00\u81F4\u3057\u307E\u3059\u30021 \u3064\u306B\u7D5E\u3063\u3066\u3082\u3089\u3046\u307E\u3067\u5F85\u3061\u307E\u3059)`:` (${ee(C)} \u304C\u8FD4\u4FE1\u3057\u307E\u3057\u305F\u304C\u3001\u9078\u629E\u80A2\u306E\u3069\u308C\u3067\u3082\u3042\u308A\u307E\u305B\u3093\u3002\u5F85\u6A5F\u3092\u7D9A\u3051\u307E\u3059)`),console.error(` \u300C${ee(h.text)}\u300D`)}if(Date.now()>=V)break;await Od(Math.min(ne,Math.max(0,V-Date.now()))),ne=Math.min(ne*Sd,$d)}if(h)console.error(h.ambiguous?"Error: \u8FD4\u4FE1\u306F\u3042\u308A\u307E\u3057\u305F\u304C\u3001\u8907\u6570\u306E\u9078\u629E\u80A2\u306B\u4E00\u81F4\u3059\u308B\u305F\u3081\u78BA\u5B9A\u3067\u304D\u307E\u305B\u3093 (\u30E1\u30C3\u30BB\u30FC\u30B8\u306F\u305D\u306E\u307E\u307E\u6B8B\u3063\u3066\u3044\u307E\u3059)":"Error: \u8FD4\u4FE1\u306F\u3042\u308A\u307E\u3057\u305F\u304C\u3001\u9078\u629E\u80A2\u306E\u3069\u308C\u3082\u9078\u3070\u308C\u3066\u3044\u307E\u305B\u3093 (\u30E1\u30C3\u30BB\u30FC\u30B8\u306F\u305D\u306E\u307E\u307E\u6B8B\u3063\u3066\u3044\u307E\u3059)"),console.error(` \u8FD4\u4FE1: \u300C${ee(h.text)}\u300D`),console.error(` \u9078\u629E\u80A2: ${_.map((k,C)=>`${C+1}. ${ee(Yt(k))}`).join(" ")}`),console.error(` ${l}`),console.error(` \u8FD4\u7B54\u3057\u3066\u304B\u3089\u56DE\u53CE\u3059\u308B: ${ei(l,t.asBot)}`),process.exit(kd);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: ${ei(l,t.asBot)}`);process.exit(_d)}function ei(e,t){return`slack ask --waitFor='${e}'${t?" --as-bot":""}`}async function Pd(e,t){let{ref:n,threadTs:r}=_n(t.target,!1),s=t.cookie,i=Lt(e,s),o;if(t.channelId)o=t.channelId;else if(t.userId)o=await at(e,t.userId,s);else o=await De(e,n,s);let a=(await i())?.userId??"",c=await ks(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.
191
- `+` To reach yourself with a notification, ask as the bot: slack ask '${t.target}' '...' --as-bot`);let u=bs(lt(t.question)),f=bs(lt(t.body??"")),l=new Set([...u.kinds,...f.kinds]),d=t.mentionToken??e,p=await jt(d,u.text,o,t.mentionCookie),m=f.text?await jt(d,f.text,o,t.mentionCookie):{text:"",resolved:[],unresolved:[]},h=p.text,y=m.text,E=[...p.resolved,...m.resolved],F=[...p.unresolved,...m.unresolved];for(let Q of Cn(F))console.error(`\u26A0 ${ee(Q)}`);let A=l.size>0,_=new Set(E.map((Q)=>Q.userId).filter((Q)=>Q!==a)),B=new Map(E.map((Q)=>[Q.userId,Q.display])),I;if(A)I=`anyone in ${n} (${[...l].map((Q)=>`@${Q}`).join(", ")})`;else{if(!_.size&&c&&c!==a)_.add(c),B.set(c,await Ne(e,c,s));if(!_.size)console.error("Error: `ask` will not post a question nobody is addressed to \u2014 no one is tagged.\n"+(F.length?` (${F.map((Q)=>ee(Q.surface)).join(", ")} matched no one, so it names nobody.)
180
+ Then select it: slack auth use <name> (or pass --workspace <name>)`),process.exit(1)}else throw f}if(r){console.log(JSON.stringify(a,null,2));return}let c=X(hn(a,["messages","matches"])).map(P),u=new Map;for(let f of c){let l=P(f.channel),d=l.is_im===!0,p=typeof l.name==="string"?l.name:"dm",m;if(d&&p.startsWith("U")){let h="@"+p;if(!u.has(h)){let[,y]=await Dn(o,p,i);u.set(h,y)}m=`@${u.get(h)??p}`}else if(d)m=`@${p}`;else m=`#${p}`;console.log(await Es(o,f,u,m,i))}}async function fu(e,t,n,r){let{ref:s,ts:o}=_n(t);if(!o)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 Hr(e,s,De,r),ts:o}}async function hd(e,t){let n=Fn(),r={};if(!t.mine)r.shared=!0;if(t.in)r.in=t.in;if(t.from)r.from=t.from;let s=Bc(t.state,n,r);if(!t.json){let o=await en(e,t.cookie),i=t.mine?"your reactions only [hasmy:]":"anyone's reactions [has:]";console.error(`(From: ${hu(o)} \xB7 matching ${i})`),console.error(`(query: ${s})`)}await _e("search.messages",()=>lu(e,s,t.count,t.json,t.cookie))}async function pd(e,t){let n=Fn(),{channelId:r,ts:s}=await fu(e,t.target,t.channelId,t.cookie),o=await Wc(e,r,s,t.state,n,t.cookie);if(o.noop){console.log(`= Already ${t.state} (ts: ${s})`);return}let i=o.removed.length?`, removed ${o.removed.map((a)=>`:${a}:`).join(" ")}`:"";if(console.log(`\u2713 ${t.state} :${n.progress[t.state]}: (ts: ${s})${i}`),o.leftover.length)console.error(`\u26A0 ${o.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 gd(e,t){let n=Fn(),{channelId:r,ts:s}=await fu(e,t.target,t.channelId,t.cookie),o=await Uc(e,r,s,t.flag,n,t.remove===!0,t.cookie);console.log(`\u2713 ${t.remove?"Cleared":"Flagged"} ${t.flag} :${o}: (ts: ${s})`)}async function md(e,t){let n=Fn(),r=t.channelId??await Hr(e,t.channel,De,t.cookie),s={limit:t.limit};if(t.fix)s.fix=!0;if(t.cookie)s.cookie=t.cookie;let o=await Kc(e,r,n,s);if(o.findings.length===0)console.log(`\u2713 No multi-state tasks in ${o.scanned} message(s).`);else{for(let i of o.findings){let a=i.fixed===!0?"fixed":i.fixed===!1?`FAILED: ${i.error??"?"}`:"needs --fix";console.log(`${i.ts} ${i.emoji.map((c)=>`:${c}:`).join(" ")} \u2192 keep :${i.keep}: [${a}] ${Q(i.text).slice(0,60)}`)}console.log(`${o.findings.length} multi-state task(s) in ${o.scanned} message(s).`)}if(o.truncated)console.error(`\u26A0 Scan limit reached (${t.limit} messages) \u2014 older history was NOT checked. Raise it with --limit N.`)}async function Dd(e,t,n,r){let s=Math.floor(Date.now()/1000)-t*86400,o=await mn(e),i=X(o.channels).map(P).filter((f)=>f.is_member===!0&&f.is_im!==!0&&f.is_mpim!==!0).filter((f)=>{if(!r)return!0;return(typeof f.name==="string"?f.name:"").toLowerCase().includes(r.toLowerCase())}).sort((f,l)=>Number(l.updated??0)-Number(f.updated??0)),a=new Map,c=0,u=0;for(let f of i){let l=String(f.id??""),d=typeof f.name==="string"?f.name:l,p;try{p=await Ve(e,l,n)}catch(h){console.error(` SKIP #${d}: ${h.message}`);continue}let m=X(p.messages).map(P).filter((h)=>(h.subtype===void 0||h.subtype===null)&&ws(h)>=s);if(m.length===0)continue;u+=1,c+=m.length,console.log(`## #${d} (${m.length} msgs)
181
+ `);for(let h of[...m].reverse()){let y=await cu(e,h,a),E=typeof h.text==="string"?h.text:"",A=En(await Qt(e,E,a)).split(`
182
+ `).join(" \u21B5 ");console.log(`[${Xc(ws(h))}] ${y}: ${A}`)}console.log("")}console.error(`Dumped ${c} messages across ${u} channels (cutoff: ${t}d)`)}function yd(e){let t=[];function n(r){if(typeof r==="string"){t.push(r);return}if(Array.isArray(r)){for(let s of r)n(s);return}if(r&&typeof r==="object"){let s=r;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 r of e)n(r);return t.join("").trim()}async function du(e,t,n){let r=new Map;return async(s)=>{if(!s)return"(unknown)";if(r.has(s))return r.get(s);try{let o=await Sc(e,s,t),i=P(o.channel),a;if(i.is_im===!0){let c=typeof i.user==="string"?i.user:"";if(!c||c===n)a="@self";else{let[u]=await Dn(e,c);a=`@${u}`}}else a=`#${typeof i.name==="string"?i.name:s}`;return r.set(s,a),a}catch{return s}}}function ro(e){let t=P(X(e.destinations)[0]);return String(t.channel_id??e.channel_id??e.channel??"")}function Fs(e){return yd(X(e.blocks))||(typeof e.text==="string"?e.text:"(no text)")}async function bd(e,t,n=!1){let r=await yn(e,t),s=X(r.drafts??r.messages??[]).map(P).filter((u)=>u.is_deleted!==!0),o=n?s:s.filter((u)=>u.is_sent!==!0);if(o.length===0){console.log(n?"No drafts.":"No pending drafts. Run with --all to include sent.");return}let i="";try{({userId:i}=await Ur(e,t))}catch{}let a=await du(e,t,i),c=new Map;for(let u of o){let f=ro(u),l=Fs(u),d=Number(u.date_created??u.date_create??0),p=d?Qr(d):"?",m=await a(f),h=typeof u.id==="string"?u.id:"",y=u.is_sent===!0?" [SENT]":"",E=En(await Qt(e,l,c));console.log(`-- ${h} ${m} [${p}]${y}`);for(let F of E.split(`
183
+ `))console.log(` ${F}`)}}async function wd(e,t,n){let r=await yn(e,t),s=X(r.drafts).map(P).find((m)=>String(m.id)===n);if(!s)console.error(`Draft not found: ${n}`),process.exit(1);let o="";try{({userId:o}=await Ur(e,t))}catch{}let i=await du(e,t,o),a=ro(s),c=Fs(s),u=Number(s.date_created??0),f=String(s.last_updated_ts??"?"),l=await i(a),p=En(await Qt(e,c,new Map));console.log(`id: ${s.id}`),console.log(`channel: ${l} (${a})`),console.log(`created: ${u?Qr(u):"?"}`),console.log(`updated: ${Qr(Number(f.split(".")[0]))}`),console.log(`status: ${s.is_sent===!0?"sent":"pending"}`),console.log("---"),console.log(p)}function Ye(...e){return sd(e.join(`
184
+ `)).slice(0,4)}function Q(e){return e.replace(/\x1b\[[0-9;:?]*[ -/]*[@-~]/g,"").replace(/[\x00-\x1f\x7f-\x9f]/g,"").replace(/[\u061c\u200e\u200f\u202a-\u202e\u2066-\u2069]/g,"")}var Fd={"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[,r,s]=n;switch(s){case"missing_scope":return`Error: token lacks the ${Fd[r]??"the required"} scope (needed for ${r}). 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 _s(e,t,n){if(!t.startsWith("D"))return null;try{let r=await Ss(e,t,n);if(!r)return null;return await Lc(e,r,bn,n)}catch{return null}}function je(e,t,n,r,s=new Date){for(let i of n)console.log(i);let o=Gc(s,r);if(o)console.log(o);if(e!==void 0)console.error(`Code mismatch (got ${e}, expected ${t})`);console.error(`Rerun with --code=${t}`),process.exit(1)}function _n(e){let t=Nt(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 r=e.slice(n+1);if(/^\d{10}\.\d{6}$/.test(r))return{ref:e.slice(0,n),ts:r};if(/^\d{4}-\d{2}-\d{2}T/.test(r))return{ref:e.slice(0,n),ts:so(r)}}}return{ref:e}}function kn(e,t=!0){let n=Nt(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 r=e.indexOf(":");if(r>0){let s=e.slice(r+1);if(/^\d{10}\.\d{6}$/.test(s))return{ref:e.slice(0,r),threadTs:s};if(/^\d{4}-\d{2}-\d{2}T/.test(s))return{ref:e.slice(0,r),threadTs:so(s)}}return{ref:e}}async function ks(e,t,n,r){let s=n;if(/^#?[CDG][A-Z0-9]{8,}$/.test(n)||!n.startsWith("#")&&!n.startsWith("@"))try{let i=P(await wn(e,t,r)),a=P(i.channel);if(a.is_im===!0){let c=typeof a.user==="string"?a.user:"";s=c?`@${await Ne(e,c,r)}`:t}else s=typeof a.name==="string"?`#${a.name}`:t}catch{s=t}return s===t?t:`${s} (${t})`}async function en(e,t){try{return await ic(e,t)}catch{return null}}function Lt(e,t){let n;return async()=>{if(n===void 0)n=await en(e,t);return n}}function hu(e,t){let n=t?" [as bot]":"";if(!e)return`(unknown \u2014 auth.test failed)${n}`;let r=Q(e.user||e.userId||"?"),s=e.userId?` (${e.userId})`:"",o=e.team?` \u2014 ${Q(e.team)}`:"";return`@${r}${s}${o}${n}`}function Le(e,t={}){return` ${"From:".padEnd(t.pad??6)}${hu(e,t.asBot)}`}async function eo(e,t,n=60,r){let s=typeof t.user==="string"?await Ne(e,t.user,r):typeof t.username==="string"?t.username:"?",o=(typeof t.text==="string"?t.text:"").split(`
185
+ `)[0]??"",i=o.length>n?`${o.slice(0,n)}\u2026`:o,a=typeof t.ts==="string"?t.ts:"";return`${a?no(a).slice(0,16).replace("T"," "):""} @${s}${i?`: ${i}`:""}`}async function Cd(e,t,n,r){let s=n.find((o)=>String(o.ts)===t)??n[0];if(!s)return t;return eo(e,s,40,r)}function Zc(e){return e.toLowerCase().replace(/<[@#!][^>]+>/g," ").replace(/[^\p{L}\p{N}\s]/gu," ").replace(/\s+/g," ").trim()}function Ed(e,t){let n=Zc(e),r=Zc(t);if(!n||!r)return 0;if(n===r)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},o=s(n),i=s(r);if(o.size===0||i.size===0)return 0;let a=0;for(let[u,f]of o){let l=i.get(u);if(l)a+=Math.min(f,l)}let c=Qc(o)+Qc(i);return c===0?0:2*a/c}function Qc(e){let t=0;for(let n of e.values())t+=n;return t}async function eu(e,t,n,r){let s=ut();if(!s)console.error(`Error: --as-bot needs a bot token, but no xoxb- token was found.
186
+ Set SLACK_BOT_TOKEN=xoxb-... in ~/.config/slack-cli/.env (or your shell).`),process.exit(1);if(r)return{botToken:s};let{ref:o}=_n(e);if(!o.startsWith("@"))return{botToken:s};try{let i=await tt(t,o,n);return{botToken:s,channelId:await et(s,i)}}catch(i){console.error(`Error: could not resolve ${Q(o)} to the bot's DM.
187
+ ${i instanceof Error?i.message:String(i)}
188
+ `+" Tip: pass the message permalink, or --channel-id <D\u2026>, to skip the lookup."),process.exit(1)}}async function xd(e,t){let n=Lt(e,t.cookie),{ref:r,ts:s}=_n(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 o;if(t.channelId)o=t.channelId;else o=await De(e,r,t.cookie);let i=await qe(e,o,s,1,t.cookie),c=X(i.messages).map(P).find((h)=>String(h.ts)===s);if(!c)console.error(`Message not found at ts=${s} in channel ${o}`),process.exit(1);let u=typeof c.text==="string"?c.text:"",f=t.mentionCookie??t.cookie,l=t.mentions?await Jc(t.mentionToken??e,t.newText,o,f?{cookie:f}:{}):t.newText;Kn(l,t.allowUrlAdjacent);let d=await n(),p=Ye(u,l,d?.userId??"");if(t.code!==p)je(t.code,p,["--- Editing as -------------------------------",Le(d,{asBot:t.asBot}),"--- Original message -------------------------",...u.split(`
189
+ `).map((h)=>` ${h}`),"--- Replacing with ---------------------------",...l.split(`
190
+ `).map((h)=>` ${h}`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);let m=await Gt(e,o,s,l,t.cookie);console.log(`\u2713 Edited (ts: ${m})`)}async function _d(e,t){let n=Lt(e,t.cookie),{ref:r,ts:s}=_n(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 o;if(t.channelId)o=t.channelId;else o=await De(e,r,t.cookie);let i=await qe(e,o,s,1,t.cookie),c=X(i.messages).map(P).find((d)=>String(d.ts)===s);if(!c)console.error(`Message not found at ts=${s} in channel ${o}`),process.exit(1);let u=typeof c.text==="string"?c.text:"",f=await n(),l=Ye(o,s,u,f?.userId??"");if(t.code!==l){let d=await ks(e,o,r,t.cookie);je(t.code,l,["--- Deleting message -------------------------",Le(f,{asBot:t.asBot}),` \u2192 ${d} at ${no(s)}`,...u.split(`
191
+ `).map((p)=>` ${p}`),"---------------------------------------------"])}await gc(e,o,s,t.cookie),console.log(`\u2713 Deleted (ts: ${s})`)}async function kd(e,t){let{ref:n,ts:r}=_n(t.target);if(!r)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,""),o;if(t.channelId)o=t.channelId;else o=await De(e,n,t.cookie);if(t.remove)await gn(e,o,r,s,t.cookie),console.log(`\u2713 Removed :${s}: (ts: ${r})`);else await Vt(e,o,r,s,t.cookie),console.log(`\u2713 Reacted :${s}: (ts: ${r})`)}async function oo(e,t,n,r){if(!n||!t.startsWith("D"))return!1;try{let s=P(await wn(e,t,r)),o=P(s.channel);return o.is_im===!0&&o.user===n}catch{return!1}}async function Sd(e,t){let{ref:n,threadTs:r}=kn(t.target),s=t.cookie,o=Lt(e,s),i;if(t.channelId)i=t.channelId;else if(t.userId)i=await et(e,t.userId,s);else i=await De(e,n,s);if(!t.asBot&&await oo(e,i,(await o())?.userId,s))console.error(`Warning: "${t.target}" is a DM to yourself \u2014 Slack will NOT notify you of your own message.
192
+ `+` To reach yourself with a notification, send as the bot: slack send '${t.target}' '...' --as-bot`);let a=ft(t.message);Kn(a,t.allowUrlAdjacent);let c=a,u=null;if(t.mentions){u=await jt(t.mentionToken??e,a,i,t.mentionCookie),c=u.text;for(let I of Cn(u.unresolved))console.error(`\u26A0 ${Q(I)}`)}try{for(let I of await qc(t.mentionToken??e,c,t.mentionCookie))console.error(`\u26A0 possible untagged mention: ${Q(I.surface)} \u2014 @${Q(I.display)} won't be notified (did you mean <@${I.userId}>?)`)}catch{}let f=[];if(u&&(u.resolved.length>0||u.unresolved.length>0)){f.push("--- Mentions ---------------------------------");for(let I of u.resolved)f.push(` \u2713 ${Q(I.surface)} \u2192 @${Q(I.display)} (${I.userId}) \u2014 will notify`);for(let I of u.unresolved){let R=I.reason==="ambiguous"?"ambiguous":I.reason==="unavailable"?"lookup unavailable":"no match";f.push(` \u26A0 ${Q(I.surface)} \u2014 plain text, NOT notified (${R})`)}}let l="",d="?",p=[],m,h,y;if(r)try{let I=await qe(e,i,r,100,s);p=X(I.messages).map(P);let R=p[p.length-1];l=typeof R?.text==="string"?R.text:"",m=typeof R?.user==="string"?R.user:void 0,h=typeof R?.bot_id==="string"?R.bot_id:void 0,y=typeof R?.ts==="string"?R.ts:void 0}catch{}else try{let I=await Ve(e,i,1,void 0,void 0,s),R=X(I.messages).map(P),V=R.filter((ne)=>ne.subtype===void 0||ne.subtype===null)[0];l=typeof V?.text==="string"?V.text:"",d=typeof V?.user==="string"?await Ne(e,V.user,s):typeof V?.username==="string"?V.username:"?";let L=R[0];m=typeof L?.user==="string"?L.user:void 0,h=typeof L?.bot_id==="string"?L.bot_id:void 0,y=typeof L?.ts==="string"?L.ts:void 0}catch{}if(process.env.SLACK_UNREPLIED_WARN!=="0"&&y&&(m||h))try{let I=await o();if(!!I&&(!!m&&!!I.userId&&I.userId===m||!!h&&!!I.botId&&I.botId===h)){let V=`slack edit "#${i}:${y}" "<\u65B0\u3057\u3044\u672C\u6587>" --channel-id ${i}`;try{let L=await pn(e,i,y,s);if(L)V=`slack edit "${L}" "<\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(` ${V}`),console.error(" \u3053\u306E\u307E\u307E\u9001\u4FE1\u3059\u308B\u5834\u5408\u306F --code=XXXX \u3067\u78BA\u5B9A\u3002")}}catch{}if(r&&p.length){let I={sim:0,msg:null};for(let R of p){let V=typeof R.text==="string"?R.text:"";if(!V)continue;let L=Ed(c,V);if(L>I.sim)I={sim:L,msg:R}}if(I.msg&&I.sim>=0.82){let R=Math.round(I.sim*100);console.error(`\u26A0 possible duplicate: ${R}% similar to an existing thread message \u2014 ${await eo(e,I.msg,60,s)}`)}}let E=await o(),F=await _s(e,i,s),A=Ye(i,r??"",l,c,E?.userId??"");if(t.code!==A){let I=await ks(e,i,n,s),R=Le(E,{asBot:t.asBot});if(r){let V=await Cd(e,r,p,s),L=p.slice(-3),ne=L.length?await Promise.all(L.map(async(_)=>` ${await eo(e,_,60,s)}`)):[" (thread context unavailable)"];je(t.code,A,["--- Recent messages in thread ----------------",...ne,...f,"--- Sending ----------------------------------",R,` \u2192 ${I} thread of ${V} \u2014 THREAD REPLY`,` Message: ${c}`,"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"],F)}else je(t.code,A,["--- Last message in channel ------------------",` ${d}: ${l.split(`
193
+ `)[0]?.slice(0,100)??"(empty)"}`,...f,"--- Sending ----------------------------------",R,` \u2192 ${I} \u2014 NEW top-level message`,` Message: ${c}`,"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"],F)}let k=await ps(e,i,c,r,t.broadcast,s),B="";try{B=await pn(e,i,k,s)}catch{}if(B)console.log(`\u2713 Sent: ${B}`);else console.log(`\u2713 Sent (ts: ${k})`);if(t.asBot&&i.startsWith("D"))try{let I=await Zn(e);if(!I.ok)for(let R of Qn(I,!0))console.error(R);else{let R=I.appId?`https://api.slack.com/apps/${I.appId}`:"https://api.slack.com/apps";console.error(`Note: if ${t.target} can't reply (app messaging may be off), enable Messages Tab: ${R} \u2192 App Home.`)}}catch{}}var Ad=2,Ee=3,$d=4,Od=1.618033988749895,Id=1000,Td=5000,tu=8,Pd=(e)=>new Promise((t)=>setTimeout(t,e)),Rd=new Set(["thread_broadcast"]),Md=/(?<![A-Za-z0-9._@<-])@(here|channel|everyone)(?![A-Za-z0-9._-])/giu;function Cs(e){let t=new Set;return{text:e.replace(Md,(r,s)=>{let o=s.toLowerCase();return t.add(o),`<!${o}>`}),kinds:t}}async function Ss(e,t,n){if(!t.startsWith("D"))return;try{let r=P(await wn(e,t,n)),s=P(r.channel);return s.is_im===!0&&typeof s.user==="string"?s.user:void 0}catch{return}}async function pu(e,t){let{channelId:n,ts:r,question:s,reactable:o,threadOnly:i,audience:a,broadcast:c,cookie:u,timeout:f,shown:l}=t,{askerUserId:d,askerBotId:p}=t,m=(_)=>typeof _==="string"&&!!_&&_!==d&&(c||a.has(_)),h,y="";function E(_){let C=X(_.reactions).map(P),S=[];for(let O=0;O<o.length;O++){let W=C.find((q)=>q.name===Be[O].name),G=W?X(W.users).filter(m):[];if(G.length)S.push({index:O,users:G})}return S}async function F(_,C){let S=typeof _.text==="string"?_.text:"";if(!S)return;let O=Or(S,C);if(O===S)return;try{await Gt(e,n,r,O,u,!0)}catch(W){console.error(` (\u8CEA\u554F\u6587\u306B\u6CE8\u610F\u66F8\u304D\u3092\u5165\u308C\u3089\u308C\u307E\u305B\u3093\u3067\u3057\u305F: ${W instanceof Error?W.message:String(W)})`)}}async function A(_){let C=E(_);if(C.length<=1&&$r(typeof _.text==="string"?_.text:"").length)await F(_,[]);if(!C.length)return null;if(C.length===1){let{index:W,users:G}=C[0];return{answer:o[W],how:`\u30EA\u30A2\u30AF\u30B7\u30E7\u30F3 ${Be[W].glyph}`,who:G[0]}}let S=C.map((W)=>Be[W.index].glyph).join(" / ");console.error(` (${S} \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 O=[...new Set(C.flatMap((W)=>W.users))].sort();return await F(_,O),null}let k=[...o,...t.overflow];function B(_,C=1/0){let S=[..._].sort((O,W)=>Number(O.ts)-Number(W.ts));for(let O of S){if(!(Number(O.ts)>Number(r)))continue;if(!m(O.user))continue;if(typeof O.subtype==="string"&&!Rd.has(O.subtype))continue;if(Number(O.ts)>=C)break;let W=typeof O.text==="string"?O.text.trim():"";if(!W)continue;if(!k.length)return{answer:W,how:"\u8FD4\u4FE1",who:O.user};let G=za(W,k);if(G.kind==="chosen")return{answer:k[G.index-1],how:`\u8FD4\u4FE1 (${G.index})`,who:O.user};if(!h||Number(O.ts)<Number(h.ts))h={text:W,who:typeof O.user==="string"?O.user:"",ts:String(O.ts),ambiguous:G.kind==="ambiguous"}}return null}async function I(){if(h=void 0,t.threadParentTs){let O=P(await qe(e,n,t.threadParentTs,100,u)),W=X(O.messages).map(P),G=W.find((q)=>q.ts===r);if(G){let q=await A(G);if(q)return q}return B(W)}let _=P(await Ve(e,n,30,r,void 0,u,!0)),C=X(_.messages).map(P),S=C.find((O)=>O.ts===r);if(S){let O=await A(S);if(O)return O}if(!i){let O=C.filter((G)=>Number(G.ts)>Number(r)&&(p&&G.bot_id===p||d&&G.user===d)).reduce((G,q)=>Math.min(G,Number(q.ts)),1/0),W=B(C,O);if(W)return W}if(S&&Number(S.reply_count)>0){let O=P(await qe(e,n,r,30,u)),W=B(X(O.messages).map(P));if(W)return W}return null}async function R(_){for(let S=0;S<o.length;S++)try{await gn(e,n,r,Be[S].name,u)}catch{}let C="";if(_.who)try{C=await Ne(e,_.who,u)}catch{C=_.who}if(C)console.error(` \u56DE\u7B54\u8005: ${Q(C)}`);try{await Gt(e,n,r,Ua(s,_,C),u,!0);try{await Vt(e,n,r,Ir,u),await gn(e,n,r,ls,u)}catch{}}catch(S){console.error(` (\u5143\u30E1\u30C3\u30BB\u30FC\u30B8\u306E\u66F4\u65B0\u306B\u5931\u6557: ${S instanceof Error?S.message:String(S)})`)}}let V=Date.now()+f*1000,L=0,ne=Id;for(;;){let _=null;try{_=await I(),L=0}catch(C){if(L++,L>=tu)console.error(`Error: Slack \u3078\u306E\u554F\u3044\u5408\u308F\u305B\u306B ${L} \u56DE\u9023\u7D9A\u3067\u5931\u6557\u3057\u307E\u3057\u305F: ${C instanceof Error?C.message:String(C)}`),process.exit(Ee);console.error(` (Slack \u30A8\u30E9\u30FC ${L}/${tu}, \u518D\u8A66\u884C\u3057\u307E\u3059: ${C instanceof Error?C.message:String(C)})`)}if(_)await R(_),console.log(_.answer),process.exit(0);if(h&&h.ts!==y){y=h.ts;let C=h.who;try{if(C)C=await Ne(e,C,u)}catch{}console.error(h.ambiguous?` (${Q(C)} \u306E\u8FD4\u4FE1\u306F\u8907\u6570\u306E\u9078\u629E\u80A2\u306B\u4E00\u81F4\u3057\u307E\u3059\u30021 \u3064\u306B\u7D5E\u3063\u3066\u3082\u3089\u3046\u307E\u3067\u5F85\u3061\u307E\u3059)`:` (${Q(C)} \u304C\u8FD4\u4FE1\u3057\u307E\u3057\u305F\u304C\u3001\u9078\u629E\u80A2\u306E\u3069\u308C\u3067\u3082\u3042\u308A\u307E\u305B\u3093\u3002\u5F85\u6A5F\u3092\u7D9A\u3051\u307E\u3059)`),console.error(` \u300C${Q(h.text)}\u300D`)}if(Date.now()>=V)break;await Pd(Math.min(ne,Math.max(0,V-Date.now()))),ne=Math.min(ne*Od,Td)}if(h)console.error(h.ambiguous?"Error: \u8FD4\u4FE1\u306F\u3042\u308A\u307E\u3057\u305F\u304C\u3001\u8907\u6570\u306E\u9078\u629E\u80A2\u306B\u4E00\u81F4\u3059\u308B\u305F\u3081\u78BA\u5B9A\u3067\u304D\u307E\u305B\u3093 (\u30E1\u30C3\u30BB\u30FC\u30B8\u306F\u305D\u306E\u307E\u307E\u6B8B\u3063\u3066\u3044\u307E\u3059)":"Error: \u8FD4\u4FE1\u306F\u3042\u308A\u307E\u3057\u305F\u304C\u3001\u9078\u629E\u80A2\u306E\u3069\u308C\u3082\u9078\u3070\u308C\u3066\u3044\u307E\u305B\u3093 (\u30E1\u30C3\u30BB\u30FC\u30B8\u306F\u305D\u306E\u307E\u307E\u6B8B\u3063\u3066\u3044\u307E\u3059)"),console.error(` \u8FD4\u4FE1: \u300C${Q(h.text)}\u300D`),console.error(` \u9078\u629E\u80A2: ${k.map((_,C)=>`${C+1}. ${Q(Yt(_))}`).join(" ")}`),console.error(` ${l}`),console.error(` \u8FD4\u7B54\u3057\u3066\u304B\u3089\u56DE\u53CE\u3059\u308B: ${to(l,t.asBot)}`),process.exit($d);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: ${to(l,t.asBot)}`);process.exit(Ad)}function to(e,t){return`slack ask --waitFor='${e}'${t?" --as-bot":""}`}async function Bd(e,t){let{ref:n,threadTs:r}=kn(t.target,!1),s=t.cookie,o=Lt(e,s),i;if(t.channelId)i=t.channelId;else if(t.userId)i=await et(e,t.userId,s);else i=await De(e,n,s);let a=(await o())?.userId??"",c=await Ss(e,i,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.
194
+ `+` To reach yourself with a notification, ask as the bot: slack ask '${t.target}' '...' --as-bot`);let u=Cs(ft(t.question)),f=Cs(ft(t.body??"")),l=new Set([...u.kinds,...f.kinds]),d=t.mentionToken??e,p=await jt(d,u.text,i,t.mentionCookie),m=f.text?await jt(d,f.text,i,t.mentionCookie):{text:"",resolved:[],unresolved:[]},h=p.text,y=m.text,E=[...p.resolved,...m.resolved],F=[...p.unresolved,...m.unresolved];for(let ee of Cn(F))console.error(`\u26A0 ${Q(ee)}`);let A=l.size>0,k=new Set(E.map((ee)=>ee.userId).filter((ee)=>ee!==a)),B=new Map(E.map((ee)=>[ee.userId,ee.display])),I;if(A)I=`anyone in ${n} (${[...l].map((ee)=>`@${ee}`).join(", ")})`;else{if(!k.size&&c&&c!==a)k.add(c),B.set(c,await Ne(e,c,s));if(!k.size)console.error("Error: `ask` will not post a question nobody is addressed to \u2014 no one is tagged.\n"+(F.length?` (${F.map((ee)=>Q(ee.surface)).join(", ")} matched no one, so it names nobody.)
192
195
  `:"")+` Tag the person who should answer: slack ask '${t.target}' '@alice ${t.question}' ...
193
196
  Or open it to the whole channel: slack ask '${t.target}' '@here ${t.question}' ...
194
- (In a 1:1 DM the other person counts automatically.)`),process.exit(Ee);I=[..._].map((Q)=>`@${ee(B.get(Q)??Q)} (${Q})`).join(", ")}let R=t.choices.map(lt),V=R.slice(0,as),L=R.slice(as),ne=!o.startsWith("D")||!!r,k=La(h,y,V,L,ne),C="",S="?";try{let Q=await Ve(e,o,1,void 0,void 0,s),N=X(Q.messages).map(P).filter((be)=>be.subtype===void 0||be.subtype===null)[0];C=typeof N?.text==="string"?N.text:"",S=typeof N?.user==="string"?await Ne(e,N.user,s):typeof N?.username==="string"?N.username:"?"}catch{}let O=await i(),W=await Es(e,o,s),G=Ye(o,r??"",C,k,O?.userId??"");if(t.code!==G){let Q=await _s(e,o,n,s),N=V.length?["--- Choices (seeded as reactions) ------------",...V.map((be,Wt)=>` ${Be[Wt].glyph} ${Yt(be)}`),...L.map((be,Wt)=>` (${Wt+11}) ${Yt(be)} \u2014 text answer only`)]:["--- Choices ----------------------------------"," (none \u2014 free-text reply)"];je(t.code,G,["--- Last message in channel ------------------",` ${S}: ${C.split(`
195
- `)[0]?.slice(0,100)??"(empty)"}`,...N,"--- Asking -----------------------------------",Le(O,{asBot:t.asBot}),` \u2192 ${Q}${r?" \u2014 THREAD REPLY":" \u2014 NEW top-level message"}`,` Question: ${h}`,` Answerable by: ${I}`,` Via: ${ne?"reactions or thread replies":"reactions or replies in this DM"}`,"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"],W)}let q=await ds(e,o,k,r,!1,s,!0);await Br([cs,...V.map((Q,N)=>Be[N].name)],(Q)=>Vt(e,o,q,Q,s),(Q,N)=>{let be=N instanceof Error?N.message:String(N);if(Q===cs)console.error(` (marker ${Q} \u3092\u4ED8\u3051\u3089\u308C\u307E\u305B\u3093\u3067\u3057\u305F: ${be})`);else console.error(` (\u30EA\u30A2\u30AF\u30B7\u30E7\u30F3 ${Q} \u3092\u4ED8\u3051\u3089\u308C\u307E\u305B\u3093\u3067\u3057\u305F: ${be})`)});let ae="";try{ae=await hn(e,o,q,s)}catch{}let Ie=ae||`${o}:${q}`;if(console.error(`\u2713 Asked: ${Ie}`),!t.wait){console.log(ei(Ie,!!t.asBot));return}let te=t.timeout??3600;console.error(` \u56DE\u7B54\u3092\u5F85\u3063\u3066\u3044\u307E\u3059 (\u6700\u5927 ${te}s)\u2026 Ctrl-C \u3067\u4E2D\u65AD`);let ke={channelId:o,ts:q,question:h,reactable:V,overflow:L,threadOnly:ne,audience:_,broadcast:A,askerUserId:O?.userId??"",askerBotId:O?.botId??"",timeout:te,shown:Ie,asBot:!!t.asBot};if(r)ke.threadParentTs=r;if(s)ke.cookie=s;await du(e,ke)}async function Rd(e,t){let n=Nt(t.link),r,s,i;if(n?.ts)r=n.channel,s=n.ts,i=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').
196
- `+` Got: ${ee(t.link)}`),process.exit(Ee);r=m[1],s=m[2]}let o;if(i){let m=P(await qe(e,r,i,100,t.cookie));o=X(m.messages).map(P).find((h)=>h.ts===s)}else{let m=P(await Ve(e,r,1,s,void 0,t.cookie,!0));o=X(m.messages).map(P).find((h)=>h.ts===s)}if(!o)console.error(`Error: \u305D\u306E\u30E1\u30C3\u30BB\u30FC\u30B8\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093: ${ee(t.link)}`),process.exit(Ee);let a=typeof o.text==="string"?o.text:"",c=Ka(a);if(c.kind==="other")console.error("Error: \u3053\u308C\u306F `slack ask` \u306E\u8CEA\u554F\u3068\u3057\u3066\u8AAD\u307F\u53D6\u308C\u307E\u305B\u3093\u3002\n"+` \u7406\u7531: ${Ua(a)}
197
- ${ee(t.link)}
198
- `+` (\u62BC\u3055\u308C\u305F\u30EA\u30A2\u30AF\u30B7\u30E7\u30F3\u306F\u6B8B\u3063\u3066\u3044\u307E\u3059: slack read '${ee(t.link)}' \u3067\u78BA\u8A8D\u3067\u304D\u307E\u3059)`),process.exit(Ee);if(c.kind==="resolved"){console.error(`\u2713 \u56DE\u7B54\u6E08\u307F: ${ee(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 ks(e,r,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: ${ee(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 p={channelId:r,ts:s,question:c.question,reactable:c.reactable,overflow:c.overflow,threadOnly:c.threadOnly,audience:d,broadcast:l,askerUserId:u,askerBotId:f,timeout:t.timeout,shown:t.link,asBot:t.asBot};if(i)p.threadParentTs=i;if(t.cookie)p.cookie=t.cookie;await du(e,p)}var ve=3;function Md(e){return`slack poll --results='${e}'`}async function Bd(e,t){let{ref:n,threadTs:r}=_n(t.target,!1),s=t.cookie,i=Lt(e,s),o;if(t.channelId)o=t.channelId;else if(t.userId)o=await at(e,t.userId,s);else o=await De(e,n,s);let a=(await i())?.userId??"",c=await ks(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.
199
- `+` To reach yourself with a notification, post as the bot: slack poll '${t.target}' '...' --as-bot`);let u=bs(lt(t.question)),f=bs(lt(t.body??"")),l=t.mentionToken??e,d=await jt(l,u.text,o,t.mentionCookie),p=f.text?await jt(l,f.text,o,t.mentionCookie):{text:"",resolved:[],unresolved:[]},m=d.text,h=p.text;for(let C of Cn([...d.unresolved,...p.unresolved]))console.error(`\u26A0 ${ee(C)}`);let y=t.choices.map(lt),E=!!t.multi,F=t.until??"",A=Ga(m,h,y,{multi:E,deadline:F}),_="",B="?";try{let C=await Ve(e,o,1,void 0,void 0,s),S=X(C.messages).map(P).filter((O)=>O.subtype===void 0||O.subtype===null)[0];_=typeof S?.text==="string"?S.text:"",B=typeof S?.user==="string"?await Ne(e,S.user,s):typeof S?.username==="string"?S.username:"?"}catch{}let I=await i(),R=await Es(e,o,s),V=Ye(o,r??"",_,A,I?.userId??"");if(t.code!==V){let C=await _s(e,o,n,s);je(t.code,V,["--- Last message in channel ------------------",` ${B}: ${_.split(`
200
- `)[0]?.slice(0,100)??"(empty)"}`,"--- Ballot (seeded as reactions) -------------",...y.map((S,O)=>` ${ze[O].glyph} ${fn(S)}`),"--- Posting ----------------------------------",Le(I,{asBot:t.asBot}),` \u2192 ${C}${r?" \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"],R)}let L=await ds(e,o,A,r,!1,s,!0);await Br([dn,...y.map((C,S)=>ze[S].name)],(C)=>Vt(e,o,L,C,s),(C,S)=>{let O=S instanceof Error?S.message:String(S);if(C===dn)console.error(` (marker ${C} \u3092\u4ED8\u3051\u3089\u308C\u307E\u305B\u3093\u3067\u3057\u305F: ${O})`);else console.error(` (\u30EA\u30A2\u30AF\u30B7\u30E7\u30F3 ${C} \u3092\u4ED8\u3051\u3089\u308C\u307E\u305B\u3093\u3067\u3057\u305F: ${O})`)});let ne="";try{ne=await hn(e,o,L,s)}catch{}let k=ne||`${o}:${L}`;console.error(`\u2713 Posted: ${k}`),console.log(Md(k)),console.error(` \u7DE0\u3081\u5207\u308B: slack poll --close='${k}'${t.asBot?" --as-bot":""}`)}async function Nd(e,t,n){let r=Nt(t),s,i,o;if(r?.ts)s=r.channel,i=r.ts,o=r.threadTs&&r.threadTs!==r.ts?r.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').
201
- `+` Got: ${ee(t)}`),process.exit(ve);s=c[1],i=c[2]}let a;if(o){let c=P(await qe(e,s,o,100,n));a=X(c.messages).map(P).find((u)=>u.ts===i)}else{let c=P(await Ve(e,s,1,i,void 0,n,!0));a=X(c.messages).map(P).find((u)=>u.ts===i)}if(!a)console.error(`Error: \u305D\u306E\u30E1\u30C3\u30BB\u30FC\u30B8\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093: ${ee(t)}`),process.exit(ve);return{channelId:s,ts:i,msg:a}}function eu(e){let t=Math.max(1,...e.map((n)=>n.count));return e.map((n,r)=>`${ze[r].glyph} ${String(n.count).padStart(3)} ${"\u2588".repeat(Math.round(n.count/t*20))}${n.count?" ":""}${n.choice}`)}async function vd(e,t){let{channelId:n,ts:r,msg:s}=await Nd(e,t.link,t.cookie),i=typeof s.text==="string"?s.text:"",o=Za(i);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"+` ${ee(t.link)}`),process.exit(ve);if(o.kind==="closed"){console.error(`\u2713 \u6295\u7968\u7D42\u4E86: ${ee(o.question)}`);for(let p of eu(o.tallies))console.log(p);return}let a=new Set;if(typeof s.user==="string"&&s.user)a.add(s.user);let c=await gc(e,n,r,t.cookie),u=Qa(o.choices,c,a,o.multi);console.error(`${ee(o.question)}${o.deadline?` (\u7DE0\u5207 ${o.deadline})`:""}`);for(let p of eu(u.tallies))console.log(p);let f=u.tallies.reduce((p,m)=>p+m.count,0);if(console.error(` \u8A08 ${f} \u7968${o.multi?" (\u8907\u6570\u9078\u629E\u53EF)":""}`),t.names)for(let p=0;p<u.voters.length;p++){if(!u.voters[p].length)continue;let m=await Promise.all(u.voters[p].map((h)=>Ne(e,h,t.cookie)));console.error(` ${ze[p].glyph} ${m.map((h)=>`@${ee(h)}`).join(", ")}`)}let l=o.multi?[]:u.ambiguous,d=$r(i,l);if(d!==i&&!t.noNotify)try{await Gt(t.writeToken??e,n,r,d,t.writeToken?t.writeCookie:t.cookie,!0)}catch(p){console.error(` (\u6295\u7968\u6587\u306B\u6CE8\u610F\u66F8\u304D\u3092\u5165\u308C\u3089\u308C\u307E\u305B\u3093\u3067\u3057\u305F: ${p instanceof Error?p.message:String(p)})
202
- `+" \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 p=await Promise.all(u.ambiguous.map((m)=>Ne(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): ${p.map((m)=>`@${ee(m)}`).join(", ")}`)}if(!t.close)return;await Gt(t.writeToken??e,n,r,Va(o.question,u.tallies),t.writeToken?t.writeCookie:t.cookie,!0);try{await Vt(t.writeToken??e,n,r,Mr,t.writeToken?t.writeCookie:t.cookie),await gn(t.writeToken??e,n,r,dn,t.writeToken?t.writeCookie:t.cookie)}catch{}console.error(`\u2713 \u6295\u7968\u3092\u7DE0\u3081\u5207\u308A\u307E\u3057\u305F: ${ee(t.link)}`)}async function jd(e){let t=await Gn(e);for(let n of Vn(t,!1))console.log(n);if(!t.ok)process.exit(1)}function Vr(){let e=$t();if(!e)console.error(`Error: --as-bot needs a bot token, but no xoxb- token was found.
203
- Set SLACK_BOT_TOKEN=xoxb-... in ~/.config/slack-cli/.env (or your shell).`),process.exit(1);return e}async function tu(e,t,n,r){let s=await ct(n,e,r);return at(t,s)}function Ld(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 Wd(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 Ud(e,t){let n=Lt(e,t.cookie),{ref:r,threadTs:s}=_n(t.target),i;if(t.channelId)i=t.channelId;else if(t.userId)i=await at(e,t.userId,t.cookie);else i=await De(e,r,t.cookie);let o=Ld(t.at),a=new Date(o*1000).toISOString(),c=await n();if(!t.asBot&&await ri(e,i,c?.userId,t.cookie))console.error(`Warning: "${t.target}" is a DM to yourself \u2014 Slack will NOT notify you when this fires.
204
- `+` To be notified, schedule it as the bot: slack schedule send '${t.target}' '...' --at '${t.at}' --as-bot`);let u=Ye(i,t.message,String(o),c?.userId??""),f=t.targetOverride?` [${t.targetOverride} \u2192 ${i}]`:"";if(t.code!==u){let d=await Es(e,i,t.cookie);je(t.code,u,["--- Scheduling message -----------------------",Le(c,{asBot:t.asBot,pad:9}),` To: ${r}${s?` (thread ${s})`:""}${f}`,` At: ${Wd(o)}`,` Message: ${t.message}`,"---------------------------------------------"],d,new Date(o*1000))}let l=await fc(e,i,t.message,o,s,t.cookie);if(console.log(`\u2713 Scheduled (id: ${l}, at: ${a})`),t.asBot){if(console.error(` Scheduled as the bot \u2014 the user token cannot see or cancel it. Use the same flag:
197
+ (In a 1:1 DM the other person counts automatically.)`),process.exit(Ee);I=[...k].map((ee)=>`@${Q(B.get(ee)??ee)} (${ee})`).join(", ")}let R=t.choices.map(ft),V=R.slice(0,us),L=R.slice(us),ne=!i.startsWith("D")||!!r,_=Wa(h,y,V,L,ne);Kn(_,t.allowUrlAdjacent);let C="",S="?";try{let ee=await Ve(e,i,1,void 0,void 0,s),N=X(ee.messages).map(P).filter((we)=>we.subtype===void 0||we.subtype===null)[0];C=typeof N?.text==="string"?N.text:"",S=typeof N?.user==="string"?await Ne(e,N.user,s):typeof N?.username==="string"?N.username:"?"}catch{}let O=await o(),W=await _s(e,i,s),G=Ye(i,r??"",C,_,O?.userId??"");if(t.code!==G){let ee=await ks(e,i,n,s),N=V.length?["--- Choices (seeded as reactions) ------------",...V.map((we,Wt)=>` ${Be[Wt].glyph} ${Yt(we)}`),...L.map((we,Wt)=>` (${Wt+11}) ${Yt(we)} \u2014 text answer only`)]:["--- Choices ----------------------------------"," (none \u2014 free-text reply)"];je(t.code,G,["--- Last message in channel ------------------",` ${S}: ${C.split(`
198
+ `)[0]?.slice(0,100)??"(empty)"}`,...N,"--- Asking -----------------------------------",Le(O,{asBot:t.asBot}),` \u2192 ${ee}${r?" \u2014 THREAD REPLY":" \u2014 NEW top-level message"}`,` Question: ${h}`,` Answerable by: ${I}`,` Via: ${ne?"reactions or thread replies":"reactions or replies in this DM"}`,"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"],W)}let q=await ps(e,i,_,r,!1,s,!0);await Nr([ls,...V.map((ee,N)=>Be[N].name)],(ee)=>Vt(e,i,q,ee,s),(ee,N)=>{let we=N instanceof Error?N.message:String(N);if(ee===ls)console.error(` (marker ${ee} \u3092\u4ED8\u3051\u3089\u308C\u307E\u305B\u3093\u3067\u3057\u305F: ${we})`);else console.error(` (\u30EA\u30A2\u30AF\u30B7\u30E7\u30F3 ${ee} \u3092\u4ED8\u3051\u3089\u308C\u307E\u305B\u3093\u3067\u3057\u305F: ${we})`)});let ae="";try{ae=await pn(e,i,q,s)}catch{}let Ie=ae||`${i}:${q}`;if(console.error(`\u2713 Asked: ${Ie}`),!t.wait){console.log(to(Ie,!!t.asBot));return}let te=t.timeout??3600;console.error(` \u56DE\u7B54\u3092\u5F85\u3063\u3066\u3044\u307E\u3059 (\u6700\u5927 ${te}s)\u2026 Ctrl-C \u3067\u4E2D\u65AD`);let ke={channelId:i,ts:q,question:h,reactable:V,overflow:L,threadOnly:ne,audience:k,broadcast:A,askerUserId:O?.userId??"",askerBotId:O?.botId??"",timeout:te,shown:Ie,asBot:!!t.asBot};if(r)ke.threadParentTs=r;if(s)ke.cookie=s;await pu(e,ke)}async function Nd(e,t){let n=Nt(t.link),r,s,o;if(n?.ts)r=n.channel,s=n.ts,o=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').
199
+ `+` Got: ${Q(t.link)}`),process.exit(Ee);r=m[1],s=m[2]}let i;if(o){let m=P(await qe(e,r,o,100,t.cookie));i=X(m.messages).map(P).find((h)=>h.ts===s)}else{let m=P(await Ve(e,r,1,s,void 0,t.cookie,!0));i=X(m.messages).map(P).find((h)=>h.ts===s)}if(!i)console.error(`Error: \u305D\u306E\u30E1\u30C3\u30BB\u30FC\u30B8\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093: ${Q(t.link)}`),process.exit(Ee);let a=typeof i.text==="string"?i.text:"",c=Ja(a);if(c.kind==="other")console.error("Error: \u3053\u308C\u306F `slack ask` \u306E\u8CEA\u554F\u3068\u3057\u3066\u8AAD\u307F\u53D6\u308C\u307E\u305B\u3093\u3002\n"+` \u7406\u7531: ${Ka(a)}
200
+ ${Q(t.link)}
201
+ `+` (\u62BC\u3055\u308C\u305F\u30EA\u30A2\u30AF\u30B7\u30E7\u30F3\u306F\u6B8B\u3063\u3066\u3044\u307E\u3059: slack read '${Q(t.link)}' \u3067\u78BA\u8A8D\u3067\u304D\u307E\u3059)`),process.exit(Ee);if(c.kind==="resolved"){console.error(`\u2713 \u56DE\u7B54\u6E08\u307F: ${Q(c.question)}`),console.log(c.answer);return}let u=typeof i.user==="string"?i.user:"",f=typeof i.bot_id==="string"?i.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 Ss(e,r,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: ${Q(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 p={channelId:r,ts:s,question:c.question,reactable:c.reactable,overflow:c.overflow,threadOnly:c.threadOnly,audience:d,broadcast:l,askerUserId:u,askerBotId:f,timeout:t.timeout,shown:t.link,asBot:t.asBot};if(o)p.threadParentTs=o;if(t.cookie)p.cookie=t.cookie;await pu(e,p)}var ve=3;function vd(e){return`slack poll --results='${e}'`}async function jd(e,t){let{ref:n,threadTs:r}=kn(t.target,!1),s=t.cookie,o=Lt(e,s),i;if(t.channelId)i=t.channelId;else if(t.userId)i=await et(e,t.userId,s);else i=await De(e,n,s);let a=(await o())?.userId??"",c=await Ss(e,i,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.
202
+ `+` To reach yourself with a notification, post as the bot: slack poll '${t.target}' '...' --as-bot`);let u=Cs(ft(t.question)),f=Cs(ft(t.body??"")),l=t.mentionToken??e,d=await jt(l,u.text,i,t.mentionCookie),p=f.text?await jt(l,f.text,i,t.mentionCookie):{text:"",resolved:[],unresolved:[]},m=d.text,h=p.text;for(let C of Cn([...d.unresolved,...p.unresolved]))console.error(`\u26A0 ${Q(C)}`);let y=t.choices.map(ft),E=!!t.multi,F=t.until??"",A=Va(m,h,y,{multi:E,deadline:F}),k="",B="?";try{let C=await Ve(e,i,1,void 0,void 0,s),S=X(C.messages).map(P).filter((O)=>O.subtype===void 0||O.subtype===null)[0];k=typeof S?.text==="string"?S.text:"",B=typeof S?.user==="string"?await Ne(e,S.user,s):typeof S?.username==="string"?S.username:"?"}catch{}let I=await o(),R=await _s(e,i,s),V=Ye(i,r??"",k,A,I?.userId??"");if(t.code!==V){let C=await ks(e,i,n,s);je(t.code,V,["--- Last message in channel ------------------",` ${B}: ${k.split(`
203
+ `)[0]?.slice(0,100)??"(empty)"}`,"--- Ballot (seeded as reactions) -------------",...y.map((S,O)=>` ${ze[O].glyph} ${fn(S)}`),"--- Posting ----------------------------------",Le(I,{asBot:t.asBot}),` \u2192 ${C}${r?" \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"],R)}let L=await ps(e,i,A,r,!1,s,!0);await Nr([dn,...y.map((C,S)=>ze[S].name)],(C)=>Vt(e,i,L,C,s),(C,S)=>{let O=S instanceof Error?S.message:String(S);if(C===dn)console.error(` (marker ${C} \u3092\u4ED8\u3051\u3089\u308C\u307E\u305B\u3093\u3067\u3057\u305F: ${O})`);else console.error(` (\u30EA\u30A2\u30AF\u30B7\u30E7\u30F3 ${C} \u3092\u4ED8\u3051\u3089\u308C\u307E\u305B\u3093\u3067\u3057\u305F: ${O})`)});let ne="";try{ne=await pn(e,i,L,s)}catch{}let _=ne||`${i}:${L}`;console.error(`\u2713 Posted: ${_}`),console.log(vd(_)),console.error(` \u7DE0\u3081\u5207\u308B: slack poll --close='${_}'${t.asBot?" --as-bot":""}`)}async function Ld(e,t,n){let r=Nt(t),s,o,i;if(r?.ts)s=r.channel,o=r.ts,i=r.threadTs&&r.threadTs!==r.ts?r.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').
204
+ `+` Got: ${Q(t)}`),process.exit(ve);s=c[1],o=c[2]}let a;if(i){let c=P(await qe(e,s,i,100,n));a=X(c.messages).map(P).find((u)=>u.ts===o)}else{let c=P(await Ve(e,s,1,o,void 0,n,!0));a=X(c.messages).map(P).find((u)=>u.ts===o)}if(!a)console.error(`Error: \u305D\u306E\u30E1\u30C3\u30BB\u30FC\u30B8\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093: ${Q(t)}`),process.exit(ve);return{channelId:s,ts:o,msg:a}}function nu(e){let t=Math.max(1,...e.map((n)=>n.count));return e.map((n,r)=>`${ze[r].glyph} ${String(n.count).padStart(3)} ${"\u2588".repeat(Math.round(n.count/t*20))}${n.count?" ":""}${n.choice}`)}async function Wd(e,t){let{channelId:n,ts:r,msg:s}=await Ld(e,t.link,t.cookie),o=typeof s.text==="string"?s.text:"",i=Qa(o);if(i.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"+` ${Q(t.link)}`),process.exit(ve);if(i.kind==="closed"){console.error(`\u2713 \u6295\u7968\u7D42\u4E86: ${Q(i.question)}`);for(let p of nu(i.tallies))console.log(p);return}let a=new Set;if(typeof s.user==="string"&&s.user)a.add(s.user);let c=await mc(e,n,r,t.cookie),u=ec(i.choices,c,a,i.multi);console.error(`${Q(i.question)}${i.deadline?` (\u7DE0\u5207 ${i.deadline})`:""}`);for(let p of nu(u.tallies))console.log(p);let f=u.tallies.reduce((p,m)=>p+m.count,0);if(console.error(` \u8A08 ${f} \u7968${i.multi?" (\u8907\u6570\u9078\u629E\u53EF)":""}`),t.names)for(let p=0;p<u.voters.length;p++){if(!u.voters[p].length)continue;let m=await Promise.all(u.voters[p].map((h)=>Ne(e,h,t.cookie)));console.error(` ${ze[p].glyph} ${m.map((h)=>`@${Q(h)}`).join(", ")}`)}let l=i.multi?[]:u.ambiguous,d=Or(o,l);if(d!==o&&!t.noNotify)try{await Gt(t.writeToken??e,n,r,d,t.writeToken?t.writeCookie:t.cookie,!0)}catch(p){console.error(` (\u6295\u7968\u6587\u306B\u6CE8\u610F\u66F8\u304D\u3092\u5165\u308C\u3089\u308C\u307E\u305B\u3093\u3067\u3057\u305F: ${p instanceof Error?p.message:String(p)})
205
+ `+" \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 p=await Promise.all(u.ambiguous.map((m)=>Ne(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): ${p.map((m)=>`@${Q(m)}`).join(", ")}`)}if(!t.close)return;await Gt(t.writeToken??e,n,r,Za(i.question,u.tallies),t.writeToken?t.writeCookie:t.cookie,!0);try{await Vt(t.writeToken??e,n,r,Br,t.writeToken?t.writeCookie:t.cookie),await gn(t.writeToken??e,n,r,dn,t.writeToken?t.writeCookie:t.cookie)}catch{}console.error(`\u2713 \u6295\u7968\u3092\u7DE0\u3081\u5207\u308A\u307E\u3057\u305F: ${Q(t.link)}`)}async function Ud(e){let t=await Zn(e);for(let n of Qn(t,!1))console.log(n);if(!t.ok)process.exit(1)}function Zr(){let e=ut();if(!e)console.error(`Error: --as-bot needs a bot token, but no xoxb- token was found.
206
+ Set SLACK_BOT_TOKEN=xoxb-... in ~/.config/slack-cli/.env (or your shell).`),process.exit(1);return e}async function su(e,t,n,r){let s=await tt(n,e,r);return et(t,s)}function Kd(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 Jd(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 zd(e,t){let n=Lt(e,t.cookie),{ref:r,threadTs:s}=kn(t.target),o;if(t.channelId)o=t.channelId;else if(t.userId)o=await et(e,t.userId,t.cookie);else o=await De(e,r,t.cookie);let i=Kd(t.at),a=new Date(i*1000).toISOString(),c=await n();if(!t.asBot&&await oo(e,o,c?.userId,t.cookie))console.error(`Warning: "${t.target}" is a DM to yourself \u2014 Slack will NOT notify you when this fires.
207
+ `+` To be notified, schedule it as the bot: slack schedule send '${t.target}' '...' --at '${t.at}' --as-bot`);let u=Ye(o,t.message,String(i),c?.userId??""),f=t.targetOverride?` [${t.targetOverride} \u2192 ${o}]`:"";if(t.code!==u){let d=await _s(e,o,t.cookie);je(t.code,u,["--- Scheduling message -----------------------",Le(c,{asBot:t.asBot,pad:9}),` To: ${r}${s?` (thread ${s})`:""}${f}`,` At: ${Jd(i)}`,` Message: ${t.message}`,"---------------------------------------------"],d,new Date(i*1000))}let l=await dc(e,o,t.message,i,s,t.cookie);if(console.log(`\u2713 Scheduled (id: ${l}, at: ${a})`),t.asBot){if(console.error(` Scheduled as the bot \u2014 the user token cannot see or cancel it. Use the same flag:
205
208
  `+` slack schedule ls --as-bot
206
- slack schedule rm '${t.target}' ${l} --as-bot`),i.startsWith("D"))try{let d=await Gn(e);if(!d.ok)for(let p of Vn(d,!0))console.error(p);else{let p=d.appId?`https://api.slack.com/apps/${d.appId}`:"https://api.slack.com/apps";console.error(`Note: if ${t.target} can't reply (app messaging may be off), enable Messages Tab: ${p} \u2192 App Home.`)}}catch{}}}async function nu(e,t,n,r){let s;if(n)s=n;else if(t)s=await De(e,t,r);let o=(await dc(e,s,r)).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(`
207
- `)[0]?.slice(0,80)??""}`)}}async function su(e,t){let n;if(t.channelId)n=t.channelId;else n=await De(e,t.target,t.cookie);let r=await en(e,t.cookie),s=Ye(n,t.id,r?.userId??"");if(t.code!==s)je(t.code,s,["--- Deleting scheduled message ---------------",Le(r,{asBot:t.asBot,pad:9}),` Channel: ${t.target}${t.targetOverride?` [${t.targetOverride} \u2192 ${n}]`:""}`,` ID: ${t.id}`,"---------------------------------------------"]);await pc(e,n,t.id,t.cookie),console.log(`\u2713 Deleted scheduled message ${t.id}`)}async function Kd(e,t){let n=Lt(e,t.cookie),{statSync:r,existsSync:s}=await import("fs"),{basename:i}=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}=_n(t.target),c;if(t.channelId)c=t.channelId;else if(t.userId)c=await at(e,t.userId,t.cookie);else c=await De(e,o,t.cookie);if(await ri(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 h=i(m),y=u?h:t.title??h;return{fp:m,filename:h,title:y,sizeFmt:Cs(r(m).size)}}),l=await n(),d=Ye(c,...f.flatMap((m)=>[m.fp,m.title]),l?.userId??"");if(t.code!==d){let m=` To: ${o}${a?` (thread ${a})`:""}`,h=u?[`--- Uploading ${f.length} files ------------------------`,Le(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 ---------------------------",Le(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"];je(t.code,d,h)}let p=f.length;for(let m=0;m<p;m++){let h=f[m],y={title:h.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 Ac(e,c,h.fp,y,t.cookie),A=p>1?`[${m+1}/${p}] `:"";console.log(`${A}\u2713 Uploaded (file_id: ${E}${F?`, url: ${F}`:""})`)}}async function Jd(e,t,n){let r=n.channel?await De(e,n.channel,t):void 0,s=[],i=1,o=1;do{let c={page:i,count:200};if(n.types)c.types=n.types;if(r)c.channel=r;if(n.user)c.user=n.user;let u=P(await ac(e,c,t));for(let f of X(u.files))s.push(P(f));o=Number(P(u.paging).pages??1),i++}while(s.length<n.limit&&i<=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"?Cs(c.size):"";console.log(`${u} ${l.padEnd(7)} ${d.padStart(9)} ${f}`)}}function zd(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 Hd(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 r=e[n];if(r!=null)return typeof r==="object"?JSON.stringify(r):String(r)}return""}async function qd(e,t,n,r){let s=zd(n);if(!s)throw Error(`Not a list ID or list URL: ${n}
208
- `+"Expected F\u2026 or https://<ws>.slack.com/lists/<TEAM>/<F-id>");let i=[],o;do{let c={limit:200};if(o)c.cursor=o;let u=P(await cc(e,s,c,t));for(let l of X(u.items??u.records))i.push(P(l));let f=P(u.response_metadata).next_cursor;o=typeof f==="string"&&f?f:void 0}while(o&&i.length<r.limit);let a=i.slice(0,r.limit);if(r.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??"?"),p=Hd(l);return p?`${d}=${p}`:""}).filter(Boolean);console.log(`${u} ${f.join(" | ")}`)}}function Yd(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 Xd(e,t,n,r){let s=Yd(n);if(!s)throw Error(`Not a file ID or file permalink: ${n}
209
- `+"Expected F\u2026 or https://<ws>.slack.com/files/<UID>/<FID>/<name>");let i=P(await oc(e,s,t)),o=P(i.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:p}=await import("fs"),{basename:m}=await import("path"),h=r??a;if(r&&p(r)&&d(r).isDirectory())h=dt(r,m(a));iu(h,l),console.log(`\u2713 Downloaded ${a} (${Cs(l.length)}) \u2192 ${h}`)}async function Gd(){Qf();let e=(s)=>fr(s.workspace),t=(s)=>Yo(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}},r=async(s,i)=>{let o={state:s.state??"open",mine:i||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 ld(e(s),o)};await Wo(Us(process.argv)).scriptName("slack").showHelpOnFail(!1).fail((s,i,o)=>{if(i)console.error(i.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 i=String((s._??[])[0]??"");if(!i||i==="auth"||i==="login")return;try{fr(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:
210
- `),await ss(),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 i=e(s),o=s.json?"jsonl":s.format;if(s.target)await rd(i,s.target,s.limit,o,s.unreplied,t(s));else await od(i)}).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 i=s.json?"jsonl":s.format;await id(e(s),s.target,s.ts,s.limit,i,t(s))}).command(["channel","channels","ch"],"Channel commands",(s)=>s.command(["ls","list"],"List channels",(i)=>i.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(i)=>{await cd(e(i),i.limit,i.filter,i.all,i.json?"jsonl":i.format)}).command("get <channel>","Show channel details",(i)=>i.positional("channel",{type:"string",demandOption:!0,describe:"#name or channel ID"}),async(i)=>{let o=e(i),a=t(i),c=i.channel,u=c.startsWith("#")||c.startsWith("@")||c.startsWith("C")||c.startsWith("G")||c.startsWith("D")?c:`#${c}`,f=await De(o,u,a),l=P(await bn(o,f,a)),d=P(l.channel),p=typeof d.name==="string"?d.name:f,h=d.is_im===!0?"@":"#",y=String(P(d.purpose).value??""),E=String(P(d.topic).value??""),F=d.num_members??d.member_count??"";if(console.log(`${h}${p} ${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)",(i)=>i.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(i)=>{let o=e(i),a=t(i),c=i.name.replace(/^#/,"").toLowerCase(),u=i.private===!0,f=i.invite.filter(Boolean),l=await en(o,a),d=Ye(c,String(u),f.join(","),l?.userId??"");if(i.code!==d)je(i.code,d,["--- Creating channel -------------------------",Le(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 p;try{p=await mc(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 ":"#"}${p.name} (${p.id})`),f.length){let m=[];for(let h of f)try{m.push(h.startsWith("U")||h.startsWith("W")?h:await ct(o,h,a))}catch(y){console.error(` ! could not resolve ${h}: ${y instanceof Error?y.message:String(y)}`)}for(let h of m)try{let y=P(await wn(o,h,a)),E=P(y.user);if(E.is_ultra_restricted===!0)console.error(`\u26A0 ${h} 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 ${h} 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 Dc(o,p.id,m,a),console.log(`\u2713 Invited ${m.length} member${m.length===1?"":"s"}`)}catch(h){console.error(` ! invite failed: ${h instanceof Error?h.message:String(h)}`)}}}).demandCommand(1,"").showHelpOnFail(!0)).command(["user","usr"],"User commands",(s)=>s.command(["ls","list"],"List workspace members",(i)=>i.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(i)=>{let o=i.json?"jsonl":i.format,a=e(i),c=t(i),u=await Cc(a,c),f=i.filter?.toLowerCase(),l=X(u.members).map(P);if(i.external){let h=new Set(l.map((A)=>String(A.id))),y=P(await mn(a,c)),E=X(y.channels).map(P).filter((A)=>A.is_ext_shared===!0&&!!A.name),F=new Set;for(let A of E)try{for(let _ of await Ec(a,String(A.id),c))if(!h.has(_))F.add(_)}catch{}for(let A of F)try{let _=P(await wn(a,A,c)),B=P(_.user);if(B.id)l.push(B)}catch{}}let d=l.filter((h)=>h.deleted!==!0&&h.is_bot!==!0&&String(h.id)!=="USLACKBOT").filter((h)=>{if(!f)return!0;let y=String(h.name??"").toLowerCase(),E=String(P(h.profile).real_name??"").toLowerCase(),F=String(P(h.profile).email??"").toLowerCase();return y.includes(f)||E.includes(f)||F.includes(f)}).slice(0,i.limit);if(o==="jsonl"){for(let h of d)console.log(JSON.stringify(h));return}if(o==="yaml"){for(let h of d){let y=function(E,F=""){if(E===null)return"null";if(typeof E==="string")return E.includes(`
209
+ slack schedule rm '${t.target}' ${l} --as-bot`),o.startsWith("D"))try{let d=await Zn(e);if(!d.ok)for(let p of Qn(d,!0))console.error(p);else{let p=d.appId?`https://api.slack.com/apps/${d.appId}`:"https://api.slack.com/apps";console.error(`Note: if ${t.target} can't reply (app messaging may be off), enable Messages Tab: ${p} \u2192 App Home.`)}}catch{}}}async function ru(e,t,n,r){let s;if(n)s=n;else if(t)s=await De(e,t,r);let i=(await hc(e,s,r)).scheduled_messages??[];if(i.length===0){console.log("(no scheduled messages)");return}for(let a of i){let c=new Date(a.post_at*1000).toISOString();console.log(`${a.id} ${c} [${a.channel_id}] ${a.text.split(`
210
+ `)[0]?.slice(0,80)??""}`)}}async function ou(e,t){let n;if(t.channelId)n=t.channelId;else n=await De(e,t.target,t.cookie);let r=await en(e,t.cookie),s=Ye(n,t.id,r?.userId??"");if(t.code!==s)je(t.code,s,["--- Deleting scheduled message ---------------",Le(r,{asBot:t.asBot,pad:9}),` Channel: ${t.target}${t.targetOverride?` [${t.targetOverride} \u2192 ${n}]`:""}`,` ID: ${t.id}`,"---------------------------------------------"]);await pc(e,n,t.id,t.cookie),console.log(`\u2713 Deleted scheduled message ${t.id}`)}async function Hd(e,t){let n=Lt(e,t.cookie),{statSync:r,existsSync:s}=await import("fs"),{basename:o}=await import("path");for(let m of t.filePaths)if(!s(m))console.error(`Error: file not found: ${m}`),process.exit(1);let{ref:i,threadTs:a}=kn(t.target),c;if(t.channelId)c=t.channelId;else if(t.userId)c=await et(e,t.userId,t.cookie);else c=await De(e,i,t.cookie);if(await oo(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 h=o(m),y=u?h:t.title??h;return{fp:m,filename:h,title:y,sizeFmt:xs(r(m).size)}}),l=await n(),d=Ye(c,...f.flatMap((m)=>[m.fp,m.title]),l?.userId??"");if(t.code!==d){let m=` To: ${i}${a?` (thread ${a})`:""}`,h=u?[`--- Uploading ${f.length} files ------------------------`,Le(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 ---------------------------",Le(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"];je(t.code,d,h)}let p=f.length;for(let m=0;m<p;m++){let h=f[m],y={title:h.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 $c(e,c,h.fp,y,t.cookie),A=p>1?`[${m+1}/${p}] `:"";console.log(`${A}\u2713 Uploaded (file_id: ${E}${F?`, url: ${F}`:""})`)}}async function qd(e,t,n){let r=n.channel?await De(e,n.channel,t):void 0,s=[],o=1,i=1;do{let c={page:o,count:200};if(n.types)c.types=n.types;if(r)c.channel=r;if(n.user)c.user=n.user;let u=P(await cc(e,c,t));for(let f of X(u.files))s.push(P(f));i=Number(P(u.paging).pages??1),o++}while(s.length<n.limit&&o<=i);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"?xs(c.size):"";console.log(`${u} ${l.padEnd(7)} ${d.padStart(9)} ${f}`)}}function Yd(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 Xd(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 r=e[n];if(r!=null)return typeof r==="object"?JSON.stringify(r):String(r)}return""}async function Gd(e,t,n,r){let s=Yd(n);if(!s)throw Error(`Not a list ID or list URL: ${n}
211
+ `+"Expected F\u2026 or https://<ws>.slack.com/lists/<TEAM>/<F-id>");let o=[],i;do{let c={limit:200};if(i)c.cursor=i;let u=P(await uc(e,s,c,t));for(let l of X(u.items??u.records))o.push(P(l));let f=P(u.response_metadata).next_cursor;i=typeof f==="string"&&f?f:void 0}while(i&&o.length<r.limit);let a=o.slice(0,r.limit);if(r.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??"?"),p=Xd(l);return p?`${d}=${p}`:""}).filter(Boolean);console.log(`${u} ${f.join(" | ")}`)}}function Vd(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 Zd(e,t,n,r){let s=Vd(n);if(!s)throw Error(`Not a file ID or file permalink: ${n}
212
+ `+"Expected F\u2026 or https://<ws>.slack.com/files/<UID>/<FID>/<name>");let o=P(await ac(e,s,t)),i=P(o.file),a=typeof i.name==="string"?i.name:typeof i.title==="string"?i.title:s,c=typeof i.url_private_download==="string"?i.url_private_download:typeof i.url_private==="string"?i.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:p}=await import("fs"),{basename:m}=await import("path"),h=r??a;if(r&&p(r)&&d(r).isDirectory())h=ht(r,m(a));au(h,l),console.log(`\u2713 Downloaded ${a} (${xs(l.length)}) \u2192 ${h}`)}async function Qd(){nd();let e=(s)=>dr(s.workspace),t=(s)=>Xi(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}},r=async(s,o)=>{let i={state:s.state??"open",mine:o||s.mine===!0,count:s.n??50,json:s.json===!0};if(s.in)i.in=s.in;if(s.from)i.from=s.from;let a=t(s);if(a)i.cookie=a;await hd(e(s),i)};await Ui(Ks(process.argv)).scriptName("slack").showHelpOnFail(!1).fail((s,o,i)=>{if(o)console.error(o.message),process.exit(1);console.error(s),console.error(""),i.showHelp(),process.exit(1)}).option("workspace",{alias:"w",type:"string",describe:"Workspace name"}).middleware(async(s)=>{let o=String((s._??[])[0]??"");if(!o||o==="auth"||o==="login")return;try{dr(s.workspace)}catch(i){if((i instanceof Error?i.message:String(i)).startsWith("No profiles configured"))console.log(`No workspace configured. Let's set that up:
213
+ `),await os(),process.exit(0);throw i}},!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 o=e(s),i=s.json?"jsonl":s.format;if(s.target)await ad(o,s.target,s.limit,i,s.unreplied,t(s));else await ud(o)}).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 o=s.json?"jsonl":s.format;await cd(e(s),s.target,s.ts,s.limit,o,t(s))}).command(["channel","channels","ch"],"Channel commands",(s)=>s.command(["ls","list"],"List channels",(o)=>o.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(o)=>{await fd(e(o),o.limit,o.filter,o.all,o.json?"jsonl":o.format)}).command("get <channel>","Show channel details",(o)=>o.positional("channel",{type:"string",demandOption:!0,describe:"#name or channel ID"}),async(o)=>{let i=e(o),a=t(o),c=o.channel,u=c.startsWith("#")||c.startsWith("@")||c.startsWith("C")||c.startsWith("G")||c.startsWith("D")?c:`#${c}`,f=await De(i,u,a),l=P(await wn(i,f,a)),d=P(l.channel),p=typeof d.name==="string"?d.name:f,h=d.is_im===!0?"@":"#",y=String(P(d.purpose).value??""),E=String(P(d.topic).value??""),F=d.num_members??d.member_count??"";if(console.log(`${h}${p} ${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)",(o)=>o.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(o)=>{let i=e(o),a=t(o),c=o.name.replace(/^#/,"").toLowerCase(),u=o.private===!0,f=o.invite.filter(Boolean),l=await en(i,a),d=Ye(c,String(u),f.join(","),l?.userId??"");if(o.code!==d)je(o.code,d,["--- Creating channel -------------------------",Le(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 p;try{p=await Dc(i,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 ":"#"}${p.name} (${p.id})`),f.length){let m=[];for(let h of f)try{m.push(h.startsWith("U")||h.startsWith("W")?h:await tt(i,h,a))}catch(y){console.error(` ! could not resolve ${h}: ${y instanceof Error?y.message:String(y)}`)}for(let h of m)try{let y=P(await bn(i,h,a)),E=P(y.user);if(E.is_ultra_restricted===!0)console.error(`\u26A0 ${h} 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 ${h} 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 yc(i,p.id,m,a),console.log(`\u2713 Invited ${m.length} member${m.length===1?"":"s"}`)}catch(h){console.error(` ! invite failed: ${h instanceof Error?h.message:String(h)}`)}}}).demandCommand(1,"").showHelpOnFail(!0)).command(["user","usr"],"User commands",(s)=>s.command(["ls","list"],"List workspace members",(o)=>o.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(o)=>{let i=o.json?"jsonl":o.format,a=e(o),c=t(o),u=await Ec(a,c),f=o.filter?.toLowerCase(),l=X(u.members).map(P);if(o.external){let h=new Set(l.map((A)=>String(A.id))),y=P(await mn(a,c)),E=X(y.channels).map(P).filter((A)=>A.is_ext_shared===!0&&!!A.name),F=new Set;for(let A of E)try{for(let k of await xc(a,String(A.id),c))if(!h.has(k))F.add(k)}catch{}for(let A of F)try{let k=P(await bn(a,A,c)),B=P(k.user);if(B.id)l.push(B)}catch{}}let d=l.filter((h)=>h.deleted!==!0&&h.is_bot!==!0&&String(h.id)!=="USLACKBOT").filter((h)=>{if(!f)return!0;let y=String(h.name??"").toLowerCase(),E=String(P(h.profile).real_name??"").toLowerCase(),F=String(P(h.profile).email??"").toLowerCase();return y.includes(f)||E.includes(f)||F.includes(f)}).slice(0,o.limit);if(i==="jsonl"){for(let h of d)console.log(JSON.stringify(h));return}if(i==="yaml"){for(let h of d){let y=function(E,F=""){if(E===null)return"null";if(typeof E==="string")return E.includes(`
211
214
  `)?`|
212
215
  ${E.split(`
213
216
  `).join(`
214
217
  `)}`:E;if(typeof E!=="object")return String(E);if(Array.isArray(E))return E.map((A)=>`
215
- ${F} - ${y(A,F+" ")}`).join("");return Object.entries(E).map(([A,_])=>`
216
- ${F} ${A}: ${y(_,F+" ")}`).join("")};console.log("---");for(let[E,F]of Object.entries(h))console.log(`${E}: ${y(F)}`)}return}let p=Intl.DateTimeFormat().resolvedOptions().timeZone,m=d.length?String(P(X(u.members).map(P)[0]??{}).team_id??""):"";for(let h of d){let y=P(h.profile),E=String(h.name??h.id),F=String(h.id??""),A=String(y.display_name||""),_=String(y.real_name||""),B=String(y.email||""),I=String(h.tz??""),V=[...new Set([A,_].filter((S)=>S&&S!==E))].join(" / "),L=I&&I!==p?I:"",ne=String(h.team_id??""),k=h.is_stranger===!0||m&&ne&&ne!==m?`external:${ne||"?"}`:h.is_ultra_restricted===!0?"single-channel guest":h.is_restricted===!0?"guest":"",C=[B,L].filter(Boolean).join(" ");console.log(`@${E} ${F} ${V}${C?" "+C:""}${k?` [${k}]`:""}`)}}).command("get <user>","Show user details",(i)=>i.positional("user",{type:"string",demandOption:!0,describe:"@handle or user ID"}),async(i)=>{let o=e(i),a=t(i),c=i.user.startsWith("@")?i.user:`@${i.user}`,u="";try{u=await ct(o,c,a)}catch(R){console.error(R instanceof Error?R.message:String(R)),process.exit(1)}let f=P(await wn(o,u,a)),l=P(f.user),d=P(l.profile),p=Intl.DateTimeFormat().resolvedOptions().timeZone,m=String(l.name??u),h=String(l.id??u),y=String(d.display_name||""),E=String(d.real_name||""),F=String(d.email||""),A=String(l.tz??""),_=String(d.phone||""),B=String(d.title||"");console.log(`@${m} ${h}`);let I=[...new Set([y,E].filter((R)=>R&&R!==m))];if(I.length)console.log(`name: ${I.join(" / ")}`);if(F)console.log(`email: ${F}`);if(_)console.log(`phone: ${_}`);if(B)console.log(`title: ${B}`);if(A&&A!==p)console.log(`tz: ${A}`)}).demandCommand(1,"").showHelpOnFail(!0)).command("news","Activity feed (mentions to you)",(s)=>s.option("limit",{alias:"l",type:"number",default:20}),async(s)=>{await ad(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 cu(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 i={target:s.target,message:s.message};if(s.code)i.code=s.code;if(s["channel-id"])i.channelId=s["channel-id"];if(s["user-id"])i.userId=s["user-id"];if(s.broadcast)i.broadcast=!0;if(s.mentions!==!1){i.mentions=!0,i.mentionToken=e(s);let a=t(s);if(a)i.mentionCookie=a}let o;if(s["as-bot"]){let a=$t();if(!a)console.error(`Error: --as-bot needs a bot token, but no xoxb- token was found.
217
- Set SLACK_BOT_TOKEN=xoxb-... in ~/.config/slack-cli/.env (or your shell).`),process.exit(1);if(!i.channelId&&!i.userId&&i.target.startsWith("@"))try{i.userId=await ct(e(s),i.target,t(s))}catch(c){console.error(`Error: could not resolve ${i.target} to a user for the bot DM.
218
+ ${F} - ${y(A,F+" ")}`).join("");return Object.entries(E).map(([A,k])=>`
219
+ ${F} ${A}: ${y(k,F+" ")}`).join("")};console.log("---");for(let[E,F]of Object.entries(h))console.log(`${E}: ${y(F)}`)}return}let p=Intl.DateTimeFormat().resolvedOptions().timeZone,m=d.length?String(P(X(u.members).map(P)[0]??{}).team_id??""):"";for(let h of d){let y=P(h.profile),E=String(h.name??h.id),F=String(h.id??""),A=String(y.display_name||""),k=String(y.real_name||""),B=String(y.email||""),I=String(h.tz??""),V=[...new Set([A,k].filter((S)=>S&&S!==E))].join(" / "),L=I&&I!==p?I:"",ne=String(h.team_id??""),_=h.is_stranger===!0||m&&ne&&ne!==m?`external:${ne||"?"}`:h.is_ultra_restricted===!0?"single-channel guest":h.is_restricted===!0?"guest":"",C=[B,L].filter(Boolean).join(" ");console.log(`@${E} ${F} ${V}${C?" "+C:""}${_?` [${_}]`:""}`)}}).command("get <user>","Show user details",(o)=>o.positional("user",{type:"string",demandOption:!0,describe:"@handle or user ID"}),async(o)=>{let i=e(o),a=t(o),c=o.user.startsWith("@")?o.user:`@${o.user}`,u="";try{u=await tt(i,c,a)}catch(R){console.error(R instanceof Error?R.message:String(R)),process.exit(1)}let f=P(await bn(i,u,a)),l=P(f.user),d=P(l.profile),p=Intl.DateTimeFormat().resolvedOptions().timeZone,m=String(l.name??u),h=String(l.id??u),y=String(d.display_name||""),E=String(d.real_name||""),F=String(d.email||""),A=String(l.tz??""),k=String(d.phone||""),B=String(d.title||"");console.log(`@${m} ${h}`);let I=[...new Set([y,E].filter((R)=>R&&R!==m))];if(I.length)console.log(`name: ${I.join(" / ")}`);if(F)console.log(`email: ${F}`);if(k)console.log(`phone: ${k}`);if(B)console.log(`title: ${B}`);if(A&&A!==p)console.log(`tz: ${A}`)}).demandCommand(1,"").showHelpOnFail(!0)).command("news","Activity feed (mentions to you)",(s)=>s.option("limit",{alias:"l",type:"number",default:20}),async(s)=>{await ld(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 lu(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("allow-url-adjacent",{type:"boolean",default:!1,describe:"Warn instead of refusing ambiguous bare URL boundaries"}).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 o={target:s.target,message:s.message,allowUrlAdjacent:s["allow-url-adjacent"]};if(s.code)o.code=s.code;if(s["channel-id"])o.channelId=s["channel-id"];if(s["user-id"])o.userId=s["user-id"];if(s.broadcast)o.broadcast=!0;if(s.mentions!==!1){o.mentions=!0,o.mentionToken=e(s);let a=t(s);if(a)o.mentionCookie=a}let i;if(s["as-bot"]){let a=ut();if(!a)console.error(`Error: --as-bot needs a bot token, but no xoxb- token was found.
220
+ Set SLACK_BOT_TOKEN=xoxb-... in ~/.config/slack-cli/.env (or your shell).`),process.exit(1);if(!o.channelId&&!o.userId&&o.target.startsWith("@"))try{o.userId=await tt(e(s),o.target,t(s))}catch(c){console.error(`Error: could not resolve ${o.target} to a user for the bot DM.
218
221
  ${c instanceof Error?c.message:String(c)}
219
- Tip: pass --user-id <Uxxxx> to skip the lookup.`),process.exit(1)}o=a,i.asBot=!0}else{o=e(s);let a=t(s);if(a)i.cookie=a}try{await xd(o,i)}catch(a){console.error(et(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 = nobody replied, 3 = transport failure, 4 = somebody replied but picked none of the choices (stdout empty \u2014 do not act on it)."}).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 i=s.waitFor?String(s.waitFor):"",o=Number(s.timeout);if(!Number.isFinite(o)||o<0||o===0&&!i)console.error("Error: --timeout must be a positive number of seconds"),process.exit(Ee);if(i){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 p=$t();if(!p)console.error(`Error: --as-bot needs a bot token, but no xoxb- token was found.
220
- Set SLACK_BOT_TOKEN=xoxb-... in ~/.config/slack-cli/.env (or your shell).`),process.exit(Ee);l=p}else l=e(s),d=t(s);try{let p={link:i,timeout:o,asBot:!!s["as-bot"]};if(d)p.cookie=d;await Rd(l,p)}catch(p){console.error(et(p)),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=$t();if(!l)console.error(`Error: --as-bot needs a bot token, but no xoxb- token was found.
221
- 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 ct(e(s),c.target,t(s))}catch(d){console.error(`Error: could not resolve ${c.target} to a user for the bot DM.
222
+ Tip: pass --user-id <Uxxxx> to skip the lookup.`),process.exit(1)}i=a,o.asBot=!0}else{i=e(s);let a=t(s);if(a)o.cookie=a}try{await Sd(i,o)}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("allow-url-adjacent",{type:"boolean",default:!1,describe:"Warn instead of refusing ambiguous bare URL boundaries"}).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 = nobody replied, 3 = transport failure, 4 = somebody replied but picked none of the choices (stdout empty \u2014 do not act on it)."}).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 o=s.waitFor?String(s.waitFor):"",i=Number(s.timeout);if(!Number.isFinite(i)||i<0||i===0&&!o)console.error("Error: --timeout must be a positive number of seconds"),process.exit(Ee);if(o){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 p=ut();if(!p)console.error(`Error: --as-bot needs a bot token, but no xoxb- token was found.
223
+ Set SLACK_BOT_TOKEN=xoxb-... in ~/.config/slack-cli/.env (or your shell).`),process.exit(Ee);l=p}else l=e(s),d=t(s);try{let p={link:o,timeout:i,asBot:!!s["as-bot"]};if(d)p.cookie=d;await Nd(l,p)}catch(p){console.error(nt(p)),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={allowUrlAdjacent:s["allow-url-adjacent"],target:s.target,question:a,choices:(s.choices??[]).map((l)=>String(l).trim()).filter(Boolean),timeout:i};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=ut();if(!l)console.error(`Error: --as-bot needs a bot token, but no xoxb- token was found.
224
+ 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 tt(e(s),c.target,t(s))}catch(d){console.error(`Error: could not resolve ${c.target} to a user for the bot DM.
222
225
  ${d instanceof Error?d.message:String(d)}
223
- 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 Pd(f,c)}catch(l){console.error(et(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 i=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(ve);let o=()=>{let d=$t();if(!d)console.error(`Error: --as-bot needs a bot token, but no xoxb- token was found.
224
- Set SLACK_BOT_TOKEN=xoxb-... in ~/.config/slack-cli/.env (or your shell).`),process.exit(ve);return d};if(i){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(ve);let d=e(s),p=t(s);try{let m={link:i};if(s.close)m.close=!0;if(s.names)m.names=!0;if(s["no-notify"])m.noNotify=!0;if(p)m.cookie=p;if(s["as-bot"])m.writeToken=o();await vd(d,m)}catch(m){console.error(et(m)),process.exit(ve)}return}if(!s.target)console.error("Error: target is required (or use --results <permalink> to count a poll)"),process.exit(ve);let a=String(s.question??"").trim();if(!a)console.error("Error: question is empty"),process.exit(ve);let c=(s.choices??[]).map((d)=>String(d).trim()).filter(Boolean);if(c.length<2||c.length>Xt)console.error(`Error: poll needs 2..${Xt} choices (got ${c.length}). For a free-text question use \`slack ask\`.`),process.exit(ve);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 ct(e(s),u.target,t(s))}catch(p){console.error(`Error: could not resolve ${u.target} to a user for the bot DM.
226
+ 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 Bd(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 o=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(ve);let i=()=>{let d=ut();if(!d)console.error(`Error: --as-bot needs a bot token, but no xoxb- token was found.
227
+ Set SLACK_BOT_TOKEN=xoxb-... in ~/.config/slack-cli/.env (or your shell).`),process.exit(ve);return d};if(o){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(ve);let d=e(s),p=t(s);try{let m={link:o};if(s.close)m.close=!0;if(s.names)m.names=!0;if(s["no-notify"])m.noNotify=!0;if(p)m.cookie=p;if(s["as-bot"])m.writeToken=i();await Wd(d,m)}catch(m){console.error(nt(m)),process.exit(ve)}return}if(!s.target)console.error("Error: target is required (or use --results <permalink> to count a poll)"),process.exit(ve);let a=String(s.question??"").trim();if(!a)console.error("Error: question is empty"),process.exit(ve);let c=(s.choices??[]).map((d)=>String(d).trim()).filter(Boolean);if(c.length<2||c.length>Xt)console.error(`Error: poll needs 2..${Xt} choices (got ${c.length}). For a free-text question use \`slack ask\`.`),process.exit(ve);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=i();if(!u.channelId&&!u.userId&&u.target.startsWith("@"))try{u.userId=await tt(e(s),u.target,t(s))}catch(p){console.error(`Error: could not resolve ${u.target} to a user for the bot DM.
225
228
  ${p instanceof Error?p.message:String(p)}
226
- Tip: pass --user-id <Uxxxx> to skip the lookup.`),process.exit(ve)}l=d,u.asBot=!0}else{l=e(s);let d=t(s);if(d)u.cookie=d}try{await Bd(l,u)}catch(d){console.error(et(d)),process.exit(ve)}}).command("doctor","Check the bot token (xoxb) can carry a two-way DM (scopes + Messages Tab)",(s)=>s,async()=>{let s=$t();if(!s)console.error(`Error: slack doctor checks the bot token, but no xoxb- token was found.
227
- Set SLACK_BOT_TOKEN=xoxb-... in ~/.config/slack-cli/.env (or your shell).`),process.exit(1);await jd(s)}).command("schedule","Manage scheduled messages",(s)=>s.command("send <target> <message>","Schedule a message for later delivery",(i)=>i.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)"}).option("as-bot",{type:"boolean",default:!1,describe:"Schedule via the bot token (xoxb / SLACK_BOT_TOKEN) so a DM notifies the recipient. Without it a scheduled DM to yourself is posted by you, and Slack never notifies you of your own message \u2014 it fires into silence."}),async(i)=>{let o={target:i.target,message:i.message,at:i.at};if(i.code)o.code=i.code;if(i["channel-id"])o.channelId=i["channel-id"],o.targetOverride=`--channel-id ${i["channel-id"]}`;if(i["user-id"])o.userId=i["user-id"],o.targetOverride=`--user-id ${i["user-id"]}`;let a;if(i["as-bot"]){let c=Vr();if(!o.channelId&&!o.userId&&o.target.startsWith("@"))try{o.userId=await ct(e(i),o.target,t(i))}catch(u){console.error(`Error: could not resolve ${o.target} to a user for the bot DM.
229
+ Tip: pass --user-id <Uxxxx> to skip the lookup.`),process.exit(ve)}l=d,u.asBot=!0}else{l=e(s);let d=t(s);if(d)u.cookie=d}try{await jd(l,u)}catch(d){console.error(nt(d)),process.exit(ve)}}).command("doctor","Check the bot token (xoxb) can carry a two-way DM (scopes + Messages Tab)",(s)=>s,async()=>{let s=ut();if(!s)console.error(`Error: slack doctor checks the bot token, but no xoxb- token was found.
230
+ Set SLACK_BOT_TOKEN=xoxb-... in ~/.config/slack-cli/.env (or your shell).`),process.exit(1);await Ud(s)}).command("schedule","Manage scheduled messages",(s)=>s.command("send <target> <message>","Schedule a message for later delivery",(o)=>o.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)"}).option("as-bot",{type:"boolean",default:!1,describe:"Schedule via the bot token (xoxb / SLACK_BOT_TOKEN) so a DM notifies the recipient. Without it a scheduled DM to yourself is posted by you, and Slack never notifies you of your own message \u2014 it fires into silence."}),async(o)=>{let i={target:o.target,message:o.message,at:o.at};if(o.code)i.code=o.code;if(o["channel-id"])i.channelId=o["channel-id"],i.targetOverride=`--channel-id ${o["channel-id"]}`;if(o["user-id"])i.userId=o["user-id"],i.targetOverride=`--user-id ${o["user-id"]}`;let a;if(o["as-bot"]){let c=Zr();if(!i.channelId&&!i.userId&&i.target.startsWith("@"))try{i.userId=await tt(e(o),i.target,t(o))}catch(u){console.error(`Error: could not resolve ${i.target} to a user for the bot DM.
228
231
  ${u instanceof Error?u.message:String(u)}
229
- Tip: pass --user-id <Uxxxx> to skip the lookup.`),process.exit(1)}a=c,o.asBot=!0}else{a=e(i);let c=t(i);if(c)o.cookie=c}await Ud(a,o)}).command(["ls","list"],"List pending scheduled messages",(i)=>i.positional("target",{type:"string",describe:"#channel to filter by"}).option("channel-id",{type:"string",describe:"Raw channel ID"}).option("as-bot",{type:"boolean",default:!1,describe:"List what the BOT token scheduled. A message from `schedule send --as-bot` belongs to the app, so the user token's listing does not contain it \u2014 and an invisible pending message cannot be cancelled."}),async(i)=>{let o=i.target;if(i["as-bot"]){let a=Vr(),c=i["channel-id"];if(!c&&o?.startsWith("@"))c=await tu(o,a,e(i),t(i));await nu(a,o,c);return}await nu(e(i),o,i["channel-id"],t(i))}).command("rm <target> <id>","Delete a scheduled message",(i)=>i.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"}).option("as-bot",{type:"boolean",default:!1,describe:"Cancel a message scheduled with `schedule send --as-bot`. It belongs to the bot token, so the user token cannot delete it."}),async(i)=>{let o={target:i.target,id:i.id};if(i.code)o.code=i.code;if(i["channel-id"])o.channelId=i["channel-id"],o.targetOverride=`--channel-id ${i["channel-id"]}`;if(i["as-bot"]){let c=Vr();if(!o.channelId&&o.target.startsWith("@"))o.channelId=await tu(o.target,c,e(i),t(i));o.asBot=!0,await su(c,o);return}let a=t(i);if(a)o.cookie=a;await su(e(i),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 i={target:s.target,newText:s.newText};if(s.code)i.code=s.code;if(s["channel-id"])i.channelId=s["channel-id"];if(s.mentions!==!1)i.mentions=!0;let o=t(s);if(o)i.cookie=o;await Fd(e(s),i)}).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 i={target:s.target};if(s.code)i.code=s.code;if(s["channel-id"])i.channelId=s["channel-id"];let o=t(s);if(o)i.cookie=o;await Cd(e(s),i)}).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 i={target:s.target,emoji:s.emoji};if(s.remove)i.remove=!0;if(s["channel-id"])i.channelId=s["channel-id"];let o=t(s);if(o)i.cookie=o;try{await Ed(e(s),i)}catch(a){console.error(et(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((i)=>{if(i.cache===!1)qr(!1)}).command(["ls","list"],"List everyone's tasks (has: \u2014 read-only, one search per run)",(i)=>i.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(i)=>{await r(i,!1)}).command("set <target> <state>","Move a task to a progress state (adds the new reaction before removing the old one)",(i)=>i.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(i)=>{let o={target:i.target,state:i.state};if(i["channel-id"])o.channelId=i["channel-id"];let a=t(i);if(a)o.cookie=a;try{await fd(e(i),o)}catch(c){console.error(et(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",(i)=>i.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(i)=>{let o={target:i.target,flag:i.flag};if(i.remove)o.remove=!0;if(i["channel-id"])o.channelId=i["channel-id"];let a=t(i);if(a)o.cookie=a;try{await dd(e(i),o)}catch(c){console.error(et(c)),process.exit(1)}}).command("doctor","Find messages carrying two or more progress reactions (--fix repairs them)",(i)=>i.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:Hr,describe:"Max messages to scan"}).option("channel-id",{type:"string",describe:"Raw channel ID"}),async(i)=>{let o={channel:i.in,limit:i.limit};if(i.fix)o.fix=!0;if(i["channel-id"])o.channelId=i["channel-id"];let a=t(i);if(a)o.cookie=a;await pd(e(i),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((i)=>{if(i.cache===!1)qr(!1)}).command(["ls","list"],"List tasks you have reacted to (hasmy: \u2014 read-only, one search per run)",(i)=>i.options(n),async(i)=>{await r(i,!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 i={target:s.target,filePaths:s.file};if(s.title)i.title=s.title;if(s.comment)i.comment=s.comment;if(s.code)i.code=s.code;if(s["channel-id"])i.channelId=s["channel-id"];if(s["user-id"])i.userId=s["user-id"];let o=t(s);if(o)i.cookie=o;await Kd(e(s),i)}).command("files","File commands",(s)=>s.command(["ls","list"],"List files visible to you (files.list)",(i)=>i.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(i)=>{let o={limit:i.limit,format:i.json?"jsonl":i.format};if(i.type)o.types=i.type;if(i.channel)o.channel=i.channel;if(i.user)o.user=i.user;await Jd(e(i),t(i),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 i=s.json?"jsonl":s.format;try{await qd(e(s),t(s),s.ref,{limit:s.limit,format:i})}catch(o){console.error(et(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 Xd(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 hd(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",(i)=>i.option("all",{alias:"a",type:"boolean",default:!1,describe:"Include sent drafts"}),async(i)=>{await md(e(i),t(i),i.all)}).command(["new <channel> [text..]","save <channel> [text..]"],"Create a draft",(i)=>i.positional("channel",{type:"string",demandOption:!0}).positional("text",{type:"string",array:!0,default:[]}),async(i)=>{let o=e(i),a=t(i),c=i.text.join(" ");if(!c)console.error("Usage: slack drafts new <#channel|@user> <text>"),process.exit(2);let u=await De(o,i.channel,a),f=await xc(o,u,c,a);console.log(`\u2713 Draft created (id: ${P(f.draft).id??"?"})`)}).command("get <id>","Show a draft",(i)=>i.positional("id",{type:"string",demandOption:!0}),async(i)=>{await Dd(e(i),t(i),i.id)}).command(["edit <id> [text..]","update <id> [text..]"],"Edit a draft",(i)=>i.positional("id",{type:"string",demandOption:!0}).positional("text",{type:"string",array:!0,default:[]}).option("code",{type:"string"}),async(i)=>{let o=e(i),a=t(i),c=i.text.join(" ");if(!c)console.error("Usage: slack drafts edit <id> <new-text>"),process.exit(2);let u=await yn(o,a),f=X(u.drafts).map(P).find((h)=>String(h.id)===i.id);if(!f)console.error(`Draft not found: ${i.id}`),process.exit(1);let l=ws(f),d=await en(o,a),p=Ye(l,c,d?.userId??"");if(i.code!==p)je(i.code,p,["--- Editing draft as -------------------------",Le(d),"--- Current draft ----------------------------",...l.split(`
232
+ Tip: pass --user-id <Uxxxx> to skip the lookup.`),process.exit(1)}a=c,i.asBot=!0}else{a=e(o);let c=t(o);if(c)i.cookie=c}await zd(a,i)}).command(["ls","list"],"List pending scheduled messages",(o)=>o.positional("target",{type:"string",describe:"#channel to filter by"}).option("channel-id",{type:"string",describe:"Raw channel ID"}).option("as-bot",{type:"boolean",default:!1,describe:"List what the BOT token scheduled. A message from `schedule send --as-bot` belongs to the app, so the user token's listing does not contain it \u2014 and an invisible pending message cannot be cancelled."}),async(o)=>{let i=o.target;if(o["as-bot"]){let a=Zr(),c=o["channel-id"];if(!c&&i?.startsWith("@"))c=await su(i,a,e(o),t(o));await ru(a,i,c);return}await ru(e(o),i,o["channel-id"],t(o))}).command("rm <target> <id>","Delete a scheduled message",(o)=>o.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"}).option("as-bot",{type:"boolean",default:!1,describe:"Cancel a message scheduled with `schedule send --as-bot`. It belongs to the bot token, so the user token cannot delete it."}),async(o)=>{let i={target:o.target,id:o.id};if(o.code)i.code=o.code;if(o["channel-id"])i.channelId=o["channel-id"],i.targetOverride=`--channel-id ${o["channel-id"]}`;if(o["as-bot"]){let c=Zr();if(!i.channelId&&i.target.startsWith("@"))i.channelId=await su(i.target,c,e(o),t(o));i.asBot=!0,await ou(c,i);return}let a=t(o);if(a)i.cookie=a;await ou(e(o),i)}).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("allow-url-adjacent",{type:"boolean",default:!1,describe:"Warn instead of refusing ambiguous bare URL boundaries"}).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."}).option("as-bot",{type:"boolean",default:!1,describe:"Edit as the bot (xoxb / SLACK_BOT_TOKEN). REQUIRED to correct a message the bot posted: Slack only lets a token edit its OWN messages, so a bot-authored message is uneditable by the user token and chat.update returns cant_update_message. Address it by permalink or --channel-id; an @user target resolves against the BOT's DM list, which is where a bot-authored DM actually lives."}),async(s)=>{let o={target:s.target,newText:s.newText,allowUrlAdjacent:s["allow-url-adjacent"]};if(s.code)o.code=s.code;if(s["channel-id"])o.channelId=s["channel-id"];if(s.mentions!==!1)o.mentions=!0;let i;if(s["as-bot"]){let a=await eu(o.target,e(s),t(s),o.channelId);if(i=a.botToken,a.channelId&&!o.channelId)o.channelId=a.channelId;o.asBot=!0,o.mentionToken=e(s);let c=t(s);if(c)o.mentionCookie=c}else{i=e(s);let a=t(s);if(a)o.cookie=a}await xd(i,o)}).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"}).option("as-bot",{type:"boolean",default:!1,describe:"Delete as the bot (xoxb / SLACK_BOT_TOKEN). REQUIRED for a message the bot posted: chat.delete refuses another token's message exactly as chat.update does."}),async(s)=>{let o={target:s.target};if(s.code)o.code=s.code;if(s["channel-id"])o.channelId=s["channel-id"];let i;if(s["as-bot"]){let a=await eu(o.target,e(s),t(s),o.channelId);if(i=a.botToken,a.channelId&&!o.channelId)o.channelId=a.channelId;o.asBot=!0}else{i=e(s);let a=t(s);if(a)o.cookie=a}await _d(i,o)}).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 o={target:s.target,emoji:s.emoji};if(s.remove)o.remove=!0;if(s["channel-id"])o.channelId=s["channel-id"];let i=t(s);if(i)o.cookie=i;try{await kd(e(s),o)}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((o)=>{if(o.cache===!1)Yr(!1)}).command(["ls","list"],"List everyone's tasks (has: \u2014 read-only, one search per run)",(o)=>o.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(o)=>{await r(o,!1)}).command("set <target> <state>","Move a task to a progress state (adds the new reaction before removing the old one)",(o)=>o.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(o)=>{let i={target:o.target,state:o.state};if(o["channel-id"])i.channelId=o["channel-id"];let a=t(o);if(a)i.cookie=a;try{await pd(e(o),i)}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",(o)=>o.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(o)=>{let i={target:o.target,flag:o.flag};if(o.remove)i.remove=!0;if(o["channel-id"])i.channelId=o["channel-id"];let a=t(o);if(a)i.cookie=a;try{await gd(e(o),i)}catch(c){console.error(nt(c)),process.exit(1)}}).command("doctor","Find messages carrying two or more progress reactions (--fix repairs them)",(o)=>o.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:qr,describe:"Max messages to scan"}).option("channel-id",{type:"string",describe:"Raw channel ID"}),async(o)=>{let i={channel:o.in,limit:o.limit};if(o.fix)i.fix=!0;if(o["channel-id"])i.channelId=o["channel-id"];let a=t(o);if(a)i.cookie=a;await md(e(o),i)}).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((o)=>{if(o.cache===!1)Yr(!1)}).command(["ls","list"],"List tasks you have reacted to (hasmy: \u2014 read-only, one search per run)",(o)=>o.options(n),async(o)=>{await r(o,!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 o={target:s.target,filePaths:s.file};if(s.title)o.title=s.title;if(s.comment)o.comment=s.comment;if(s.code)o.code=s.code;if(s["channel-id"])o.channelId=s["channel-id"];if(s["user-id"])o.userId=s["user-id"];let i=t(s);if(i)o.cookie=i;await Hd(e(s),o)}).command("files","File commands",(s)=>s.command(["ls","list"],"List files visible to you (files.list)",(o)=>o.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(o)=>{let i={limit:o.limit,format:o.json?"jsonl":o.format};if(o.type)i.types=o.type;if(o.channel)i.channel=o.channel;if(o.user)i.user=o.user;await qd(e(o),t(o),i)}).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 o=s.json?"jsonl":s.format;try{await Gd(e(s),t(s),s.ref,{limit:s.limit,format:o})}catch(i){console.error(nt(i)),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 Zd(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 Dd(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",(o)=>o.option("all",{alias:"a",type:"boolean",default:!1,describe:"Include sent drafts"}),async(o)=>{await bd(e(o),t(o),o.all)}).command(["new <channel> [text..]","save <channel> [text..]"],"Create a draft",(o)=>o.positional("channel",{type:"string",demandOption:!0}).positional("text",{type:"string",array:!0,default:[]}),async(o)=>{let i=e(o),a=t(o),c=o.text.join(" ");if(!c)console.error("Usage: slack drafts new <#channel|@user> <text>"),process.exit(2);let u=await De(i,o.channel,a),f=await _c(i,u,c,a);console.log(`\u2713 Draft created (id: ${P(f.draft).id??"?"})`)}).command("get <id>","Show a draft",(o)=>o.positional("id",{type:"string",demandOption:!0}),async(o)=>{await wd(e(o),t(o),o.id)}).command(["edit <id> [text..]","update <id> [text..]"],"Edit a draft",(o)=>o.positional("id",{type:"string",demandOption:!0}).positional("text",{type:"string",array:!0,default:[]}).option("code",{type:"string"}),async(o)=>{let i=e(o),a=t(o),c=o.text.join(" ");if(!c)console.error("Usage: slack drafts edit <id> <new-text>"),process.exit(2);let u=await yn(i,a),f=X(u.drafts).map(P).find((h)=>String(h.id)===o.id);if(!f)console.error(`Draft not found: ${o.id}`),process.exit(1);let l=Fs(f),d=await en(i,a),p=Ye(l,c,d?.userId??"");if(o.code!==p)je(o.code,p,["--- Editing draft as -------------------------",Le(d),"--- Current draft ----------------------------",...l.split(`
230
233
  `).map((h)=>` ${h}`),"--- Replacing with ---------------------------",...c.split(`
231
- `).map((h)=>` ${h}`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);let m=await _c(o,i.id,si(f),c,a);console.log(`\u2713 Draft updated (id: ${P(m.draft).id??"?"})`)}).command(["delete <id>","rm <id>"],"Delete a draft",(i)=>i.positional("id",{type:"string",demandOption:!0}).option("code",{type:"string"}),async(i)=>{let o=e(i),a=t(i),c=await yn(o,a),u=X(c.drafts).map(P).find((p)=>String(p.id)===i.id);if(!u)console.error(`Draft not found: ${i.id}`),process.exit(1);let f=ws(u),l=await en(o,a),d=Ye(i.id,f,l?.userId??"");if(i.code!==d)je(i.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",Le(l),` id: ${i.id}`,...f.split(`
232
- `).map((p)=>` ${p}`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);await Sc(o,i.id,a),console.log(`\u2713 Draft deleted (id: ${i.id})`)})).command("auth","Authentication and workspace management",(s)=>s.command("token","Add a workspace \u2014 paste an existing xoxp-/xoxb- token",(i)=>i.option("token",{type:"string",describe:"Token to save directly (non-interactive)"}).option("name",{type:"string",describe:"Workspace name (used with --token)"}),async(i)=>{await $a({...i.token!==void 0?{token:i.token}:{},...i.name!==void 0?{name:i.name}:{}})}).command("app","Create a new Slack app and obtain a token (guided wizard)",(i)=>i.option("bot",{type:"boolean",describe:"Create a bot token (xoxb-) instead of user (xoxp-)"}),async(i)=>{await Oa({...i.bot!==void 0?{bot:i.bot}:{}})}).command("login","Interactive auth wizard (all auth methods: desktop app, token, new app)",(i)=>i.option("token",{type:"string",describe:"Token to save directly (non-interactive)"}).option("name",{type:"string",describe:"Workspace name (used with --token)"}),async(i)=>{await ss({...i.token!==void 0?{token:i.token}:{},...i.name!==void 0?{name:i.name}:{}})}).command(["ls","status"],"Show auth status",()=>{},()=>{let i=lr();if(i.length===0){console.log("No workspaces configured. Run: slack auth login");return}for(let{name:o,profile:a,current:c}of i)console.log(`${c?"* ":" "}${o} ${a.team} (${a.user}) ${a.url??""}`)}).command("use <name>","Switch active workspace",(i)=>i.positional("name",{type:"string",demandOption:!0}).option("g",{type:"boolean",default:!1,describe:"Write global lockfile (~/.slack-cli/workspace)"}),(i)=>{if(!i.g)Zf(dt(process.cwd(),".slack-cli"));qo(i.name,i.g),console.log(`Switched to workspace "${i.name}" ${i.g?"globally":"locally"}`)}).command(["logout <name>","rm <name>","remove <name>"],"Remove a workspace",(i)=>i.positional("name",{type:"string",demandOption:!0}),(i)=>{Ho(i.name),console.log(`Removed workspace "${i.name}"`)}).command(["chrome","cookie"],"Attach Chrome browser xoxd cookie to a workspace (macOS, interactive)",(i)=>i.option("workspace",{type:"string",alias:"w",describe:"Workspace name to update (default: active)"}),async(i)=>{await Sa({...i.workspace!==void 0?{workspace:i.workspace}:{}})}).command("firefox","Attach Firefox browser xoxd cookie to a workspace (all platforms)",(i)=>i.option("workspace",{type:"string",alias:"w",describe:"Workspace name to update (default: active)"}),async(i)=>{await Aa({...i.workspace!==void 0?{workspace:i.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 i=e(s),o=t(s),a=new AbortController;process.on("SIGINT",()=>{a.abort(),process.exit(0)}),await Na(i,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 ss({...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()}Gd().catch((e)=>{console.error(e instanceof Error?e.message:String(e)),process.exit(1)});
234
+ `).map((h)=>` ${h}`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);let m=await kc(i,o.id,ro(f),c,a);console.log(`\u2713 Draft updated (id: ${P(m.draft).id??"?"})`)}).command(["delete <id>","rm <id>"],"Delete a draft",(o)=>o.positional("id",{type:"string",demandOption:!0}).option("code",{type:"string"}),async(o)=>{let i=e(o),a=t(o),c=await yn(i,a),u=X(c.drafts).map(P).find((p)=>String(p.id)===o.id);if(!u)console.error(`Draft not found: ${o.id}`),process.exit(1);let f=Fs(u),l=await en(i,a),d=Ye(o.id,f,l?.userId??"");if(o.code!==d)je(o.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",Le(l),` id: ${o.id}`,...f.split(`
235
+ `).map((p)=>` ${p}`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);await Ac(i,o.id,a),console.log(`\u2713 Draft deleted (id: ${o.id})`)})).command("auth","Authentication and workspace management",(s)=>s.command("token","Add a workspace \u2014 paste an existing xoxp-/xoxb- token",(o)=>o.option("token",{type:"string",describe:"Token to save directly (non-interactive)"}).option("name",{type:"string",describe:"Workspace name (used with --token)"}),async(o)=>{await Oa({...o.token!==void 0?{token:o.token}:{},...o.name!==void 0?{name:o.name}:{}})}).command("app","Create a new Slack app and obtain a token (guided wizard)",(o)=>o.option("bot",{type:"boolean",describe:"Create a bot token (xoxb-) instead of user (xoxp-)"}),async(o)=>{await Ia({...o.bot!==void 0?{bot:o.bot}:{}})}).command("login","Interactive auth wizard (all auth methods: desktop app, token, new app)",(o)=>o.option("token",{type:"string",describe:"Token to save directly (non-interactive)"}).option("name",{type:"string",describe:"Workspace name (used with --token)"}),async(o)=>{await os({...o.token!==void 0?{token:o.token}:{},...o.name!==void 0?{name:o.name}:{}})}).command(["ls","status"],"Show auth status",()=>{},()=>{let o=fr();if(o.length===0){console.log("No workspaces configured. Run: slack auth login");return}for(let{name:i,profile:a,current:c}of o)console.log(`${c?"* ":" "}${i} ${a.team} (${a.user}) ${a.url??""}`)}).command("use <name>","Switch active workspace",(o)=>o.positional("name",{type:"string",demandOption:!0}).option("g",{type:"boolean",default:!1,describe:"Write global lockfile (~/.slack-cli/workspace)"}),(o)=>{if(!o.g)td(ht(process.cwd(),".slack-cli"));Yi(o.name,o.g),console.log(`Switched to workspace "${o.name}" ${o.g?"globally":"locally"}`)}).command(["logout <name>","rm <name>","remove <name>"],"Remove a workspace",(o)=>o.positional("name",{type:"string",demandOption:!0}),(o)=>{qi(o.name),console.log(`Removed workspace "${o.name}"`)}).command(["chrome","cookie"],"Attach Chrome browser xoxd cookie to a workspace (macOS, interactive)",(o)=>o.option("workspace",{type:"string",alias:"w",describe:"Workspace name to update (default: active)"}),async(o)=>{await Aa({...o.workspace!==void 0?{workspace:o.workspace}:{}})}).command("firefox","Attach Firefox browser xoxd cookie to a workspace (all platforms)",(o)=>o.option("workspace",{type:"string",alias:"w",describe:"Workspace name to update (default: active)"}),async(o)=>{await $a({...o.workspace!==void 0?{workspace:o.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 o=e(s),i=t(s),a=new AbortController;process.on("SIGINT",()=>{a.abort(),process.exit(0)}),await va(o,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}:{},...i!==void 0?{cookie:i}:{},...s.rtm===!1?{noRtm:!0}:{}},a.signal)}).command("login",!1,(s)=>s.option("token",{type:"string"}).option("name",{type:"string"}),async(s)=>{await os({...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()}Qd().catch((e)=>{console.error(e instanceof Error?e.message:String(e)),process.exit(1)});