slack-term 1.34.0 → 1.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -3
- package/SKILL.md +27 -9
- package/dist/cli.js +184 -138
- package/package.json +1 -1
- package/ts/agent.ts +148 -0
- package/ts/ask.ts +14 -3
- package/ts/auth.ts +185 -16
- package/ts/cli.ts +216 -38
- package/ts/profiles.ts +11 -5
- package/ts/sentlog.ts +356 -0
- package/ts/slack-app.ts +180 -102
- package/ts/slack.ts +56 -5
package/dist/cli.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
import{createRequire as _u}from"node:module";var bu=Object.create;var{getPrototypeOf:wu,defineProperty:fo,getOwnPropertyNames:Fu}=Object;var ho=Object.prototype.hasOwnProperty;function Cu(e){return this[e]}var Eu,xu,po=(e,t,n)=>{var r=e!=null&&typeof e==="object";if(r){var s=t?Eu??=new WeakMap:xu??=new WeakMap,o=s.get(e);if(o)return o}n=e!=null?bu(wu(e)):{};let i=t||!e||!e.__esModule||!ho.call(e,"default")?fo(n,"default",{value:e,enumerable:!0}):n;if(e&&typeof e==="object"||typeof e==="function"){for(let a of Fu(e))if(!ho.call(i,a))fo(i,a,{get:Cu.bind(e,a),enumerable:!0})}if(r)s.set(e,i);return i};var go=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Bs=_u(import.meta.url);var Po=go(function(xh,To){To.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 oi=go(function(dp,ri){ri.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 nd}from"crypto";import{existsSync as lu,readFileSync as sd,mkdirSync as rd,writeFileSync as fu}from"fs";import{homedir as tu}from"os";import{join as ht}from"path";import{notStrictEqual as ll,strictEqual as fl}from"assert";var ku={right:$u,center:Ou};class Do{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&&
|
|
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>
|
|
3
|
+
import{createRequire as fl}from"node:module";var ol=Object.create;var{getPrototypeOf:il,defineProperty:Lo,getOwnPropertyNames:al}=Object;var jo=Object.prototype.hasOwnProperty;function cl(e){return this[e]}var ul,ll,Wo=(e,t,n)=>{var r=e!=null&&typeof e==="object";if(r){var s=t?ul??=new WeakMap:ll??=new WeakMap,o=s.get(e);if(o)return o}n=e!=null?ol(il(e)):{};let i=t||!e||!e.__esModule||!jo.call(e,"default")?Lo(n,"default",{value:e,enumerable:!0}):n;if(e&&typeof e==="object"||typeof e==="function"){for(let a of al(e))if(!jo.call(i,a))Lo(i,a,{get:cl.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 Ln=fl(import.meta.url);var ii=Uo(function(Ph,oi){oi.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 Oi=Uo(function(Cg,Ii){Ii.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 ap}from"crypto";import{existsSync as Yu,readFileSync as cp,mkdirSync as up,realpathSync as lp,writeFileSync as Vu}from"fs";import{homedir as Wu}from"os";import{join as yt,resolve as fp}from"path";import{notStrictEqual as Yl,strictEqual as Vl}from"assert";var dl={right:gl,center:ml};class Jo{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&&ke.stringWidth(r[0])>n)n=Math.min(Math.floor(this.width*0.5),ke.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=ke.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>ke.stringWidth(o))u+=" ".repeat(c-ke.stringWidth(o));if(e[i].align&&e[i].align!=="left"&&this.wrap){let l=dl[e[i].align];if(u=l(u,c),ke.stringWidth(u)<c)u+=" ".repeat((a||0)-ke.stringWidth(u)-1)}let d=e[i].padding||[0,0,0,0];if(d[3])s+=" ".repeat(d[3]);if(s+=Ko(e[i],u,"| "),s+=u,s+=Ko(e[i],u," |"),d[1])s+=" ".repeat(d[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=ke.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=ke.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((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,Su(e[i]));return o})}}function mo(e,t,n){if(e.border){if(/[.']-+[.']/.test(t))return"";if(t.trim().length!==0)return n;return" "}return""}function Su(e){let t=e.padding||[],n=1+(t[3]||0)+(t[1]||0);if(e.border)return n+4;return n}function Au(){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 Ou(e,t){e=e.trim();let n=Se.stringWidth(e);if(n>=t)return e;return" ".repeat(t-n>>1)+e}var Se;function yo(e,t){return Se=t,new Do({width:(e===null||e===void 0?void 0:e.width)||Au(),wrap:e===null||e===void 0?void 0:e.wrap})}function Ns({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 Iu=Ns();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(Iu,"")}var bo=161,wo=1114109,Fo=[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],Co=12288,Eo=65510,xo=[12288,12288,65281,65376,65504,65510];var _o=4352,ko=262141,vs=[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 On=(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 So=19968,[Tu,Pu]=Ru(vs);function Ru(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(So>=s&&So<=o)return[s,o];if(o-s>n-t)t=s,n=o}return[t,n]}var Ao=(e)=>{if(e<bo||e>wo)return!1;return On(Fo,e)},$o=(e)=>{if(e<Co||e>Eo)return!1;return On(xo,e)};var Oo=(e)=>{if(e>=Tu&&e<=Pu)return!0;if(e<_o||e>ko)return!1;return On(vs,e)};function Mu(e){if(!Number.isSafeInteger(e))throw TypeError(`Expected a code point, got \`${typeof e}\`.`)}function Io(e,{ambiguousAsWide:t=!1}={}){if(Mu(e),$o(e)||Oo(e)||t&&Ao(e))return 2;return 1}var Ro=po(Po(),1),Bu=new Intl.Segmenter,Nu=/^\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 Bu.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(Nu.test(i))continue;if(Ro.default().test(i)){s+=2;continue}s+=Io(a,o)}return s}var Mo=(e=0)=>(t)=>`\x1B[${t+e}m`,Bo=(e=0)=>(t)=>`\x1B[${38+e};5;${t}m`,No=(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]}},Ah=Object.keys(oe.modifier),vu=Object.keys(oe.color),ju=Object.keys(oe.bgColor),$h=[...vu,...ju];function Lu(){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=Mo(),oe.color.ansi256=Bo(),oe.color.ansi16m=No(),oe.bgColor.ansi=Mo(10),oe.bgColor.ansi256=Bo(10),oe.bgColor.ansi16m=No(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 Wu=Lu(),vo=Wu;var Tn=new Set(["\x1B",""]),Uu=39,Ls="\x07",Wo="[",Ku="]",Uo="m",In=`${Ku}8;;`,jo=(e)=>`${Tn.values().next().value}${Wo}${e}${Uo}`,Lo=(e)=>`${Tn.values().next().value}${In}${e}${Ls}`,Ju=(e)=>e.split(" ").map((t)=>We(t)),js=(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(Tn.has(c))s=!0,o=r.slice(a+1,a+1+In.length).join("")===In;if(s){if(o){if(c===Ls)s=!1,o=!1}else if(c===Uo)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()},zu=(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("")},Hu=(e,t,n={})=>{if(n.trim!==!1&&e.trim()==="")return"";let r="",s,o,i=Ju(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("");js(a,d,t);continue}if(p+i[l]>t&&p>0&&i[l]>0){if(n.wordWrap===!1&&p<t){js(a,d,t);continue}a.push("")}if(p+i[l]>t&&n.wordWrap===!1){js(a,d,t);continue}a[a.length-1]+=d}if(n.trim!==!1)a=a.map((l)=>zu(l));let c=a.join(`
|
|
8
|
-
`),u=[...c],
|
|
9
|
-
`){if(o)r+=
|
|
10
|
-
`){if(s&&
|
|
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||ke.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,pl(e[i]));return o})}}function Ko(e,t,n){if(e.border){if(/[.']-+[.']/.test(t))return"";if(t.trim().length!==0)return n;return" "}return""}function pl(e){let t=e.padding||[],n=1+(t[3]||0)+(t[1]||0);if(e.border)return n+4;return n}function hl(){if(typeof process==="object"&&process.stdout&&process.stdout.columns)return process.stdout.columns;return 80}function gl(e,t){e=e.trim();let n=ke.stringWidth(e);if(n<t)return" ".repeat(t-n)+e;return e}function ml(e,t){e=e.trim();let n=ke.stringWidth(e);if(n>=t)return e;return" ".repeat(t-n>>1)+e}var ke;function zo(e,t){return ke=t,new Jo({width:(e===null||e===void 0?void 0:e.width)||hl(),wrap:e===null||e===void 0?void 0:e.wrap})}function Xs({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 Dl=Xs();function wt(e){if(typeof e!=="string")throw TypeError(`Expected a \`string\`, got \`${typeof e}\``);if(!e.includes("\x1B")&&!e.includes(""))return e;return e.replace(Dl,"")}var Ho=161,qo=1114109,Xo=[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],Go=12288,Yo=65510,Vo=[12288,12288,65281,65376,65504,65510];var Zo=4352,Qo=262141,Gs=[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 jn=(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 ei=19968,[yl,wl]=bl(Gs);function bl(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(ei>=s&&ei<=o)return[s,o];if(o-s>n-t)t=s,n=o}return[t,n]}var ti=(e)=>{if(e<Ho||e>qo)return!1;return jn(Xo,e)},ni=(e)=>{if(e<Go||e>Yo)return!1;return jn(Vo,e)};var si=(e)=>{if(e>=yl&&e<=wl)return!0;if(e<Zo||e>Qo)return!1;return jn(Gs,e)};function Cl(e){if(!Number.isSafeInteger(e))throw TypeError(`Expected a code point, got \`${typeof e}\`.`)}function ri(e,{ambiguousAsWide:t=!1}={}){if(Cl(e),ni(e)||si(e)||t&&ti(e))return 2;return 1}var ai=Wo(ii(),1),El=new Intl.Segmenter,Fl=/^\p{Default_Ignorable_Code_Point}$/u;function Ke(e,t={}){if(typeof e!=="string"||e.length===0)return 0;let{ambiguousIsNarrow:n=!0,countAnsiEscapeCodes:r=!1}=t;if(!r)e=wt(e);if(e.length===0)return 0;let s=0,o={ambiguousAsWide:!n};for(let{segment:i}of El.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(Fl.test(i))continue;if(ai.default().test(i)){s+=2;continue}s+=ri(a,o)}return s}var ci=(e=0)=>(t)=>`\x1B[${t+e}m`,ui=(e=0)=>(t)=>`\x1B[${38+e};5;${t}m`,li=(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]}},vh=Object.keys(ie.modifier),xl=Object.keys(ie.color),kl=Object.keys(ie.bgColor),Bh=[...xl,...kl];function _l(){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=ci(),ie.color.ansi256=ui(),ie.color.ansi16m=li(),ie.bgColor.ansi=ci(10),ie.bgColor.ansi256=ui(10),ie.bgColor.ansi16m=li(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((o)=>o+o).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 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)=>ie.ansi256ToAnsi(ie.rgbToAnsi256(t,n,r)),enumerable:!1},hexToAnsi:{value:(t)=>ie.ansi256ToAnsi(ie.hexToAnsi256(t)),enumerable:!1}}),ie}var Sl=_l(),fi=Sl;var Un=new Set(["\x1B",""]),Al=39,Vs="\x07",hi="[",$l="]",gi="m",Wn=`${$l}8;;`,di=(e)=>`${Un.values().next().value}${hi}${e}${gi}`,pi=(e)=>`${Un.values().next().value}${Wn}${e}${Vs}`,Tl=(e)=>e.split(" ").map((t)=>Ke(t)),Ys=(e,t,n)=>{let r=[...t],s=!1,o=!1,i=Ke(wt(e.at(-1)));for(let[a,c]of r.entries()){let u=Ke(c);if(i+u<=n)e[e.length-1]+=c;else e.push(c),i=0;if(Un.has(c))s=!0,o=r.slice(a+1,a+1+Wn.length).join("")===Wn;if(s){if(o){if(c===Vs)s=!1,o=!1}else if(c===gi)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()},Il=(e)=>{let t=e.split(" "),n=t.length;while(n>0){if(Ke(t[n-1])>0)break;n--}if(n===t.length)return e;return t.slice(0,n).join(" ")+t.slice(n).join("")},Ol=(e,t,n={})=>{if(n.trim!==!1&&e.trim()==="")return"";let r="",s,o,i=Tl(e),a=[""];for(let[l,f]of e.split(" ").entries()){if(n.trim!==!1)a[a.length-1]=a.at(-1).trimStart();let h=Ke(a.at(-1));if(l!==0){if(h>=t&&(n.wordWrap===!1||n.trim===!1))a.push(""),h=0;if(h>0||n.trim===!1)a[a.length-1]+=" ",h++}if(n.hard&&i[l]>t){let m=t-h,p=1+Math.floor((i[l]-m-1)/t);if(Math.floor((i[l]-1)/t)<p)a.push("");Ys(a,f,t);continue}if(h+i[l]>t&&h>0&&i[l]>0){if(n.wordWrap===!1&&h<t){Ys(a,f,t);continue}a.push("")}if(h+i[l]>t&&n.wordWrap===!1){Ys(a,f,t);continue}a[a.length-1]+=f}if(n.trim!==!1)a=a.map((l)=>Il(l));let c=a.join(`
|
|
8
|
+
`),u=[...c],d=0;for(let[l,f]of u.entries()){if(r+=f,Un.has(f)){let{groups:m}=new RegExp(`(?:\\${hi}(?<code>\\d+)m|\\${Wn}(?<uri>.*)${Vs})`).exec(c.slice(d))||{groups:{}};if(m.code!==void 0){let p=Number.parseFloat(m.code);s=p===Al?void 0:p}else if(m.uri!==void 0)o=m.uri.length===0?void 0:m.uri}let h=fi.codes.get(Number(s));if(u[l+1]===`
|
|
9
|
+
`){if(o)r+=pi("");if(s&&h)r+=di(h)}else if(f===`
|
|
10
|
+
`){if(s&&h)r+=di(s);if(o)r+=pi(o)}d+=f.length}return r};function Zs(e,t,n){return String(e).normalize().replaceAll(`\r
|
|
11
11
|
`,`
|
|
12
12
|
`).split(`
|
|
13
|
-
`).map((r)=>
|
|
14
|
-
`)}function Us(e){return yo(e,{stringWidth:We,stripAnsi:pt,wrap:Ws})}import{dirname as Ko,resolve as Jo}from"path";import{readdirSync as qu,statSync as Yu}from"fs";function Ks(e,t){let n=Jo(".",e),r;if(!Yu(n).isDirectory())n=Ko(n);while(!0){if(r=t(n,qu(n)),r)return Jo(n,r);if(n=Ko(r=n),r===n)break}}import{inspect as dl}from"util";import{fileURLToPath as ai}from"url";import{format as Vu}from"util";import{normalize as Zu,resolve as Qu}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 Pn(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 Rn(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 zo(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 zs{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=zo(e),s=typeof e==="string",o=Xu(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;Ms();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=Gu(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=Js();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(Rn(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=Ho(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=Ho(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===Js())x[b]=Js(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=Pn(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 Ms(){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 Xu(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 Js(e){return e!==void 0?e+1:1}function Ho(e){if(e==="__proto__")return"___proto___";return e}function Gu(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 el}from"fs";import{createRequire as qo}from"node:module";var Hs,qs,Ys,Yo=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):20,Xo=(qs=(Hs=process===null||process===void 0?void 0:process.versions)===null||Hs===void 0?void 0:Hs.node)!==null&&qs!==void 0?qs:(Ys=process===null||process===void 0?void 0:process.version)===null||Ys===void 0?void 0:Ys.slice(1);if(Xo){if(Number(Xo.match(/^([^.]+)/)[1])<Yo)throw Error(`yargs parser supports a minimum Node.js version of ${Yo}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`)}var tl=process?process.env:{},Go=qo?qo(import.meta.url):void 0,Vo=new zs({cwd:process.cwd,env:()=>tl,format:Vu,normalize:Zu,resolve:Qu,require:(e)=>{if(typeof Go<"u")return Go(e);else if(e.match(/\.json$/))return JSON.parse(el(e,"utf8"));else throw Error("only .json config files are supported in ESM")}}),sn=function(t,n){return Vo.parse(t.slice(),n).argv};sn.detailed=function(e,t){return Vo.parse(e.slice(),t)};sn.camelCase=gt;sn.decamelize=Pn;sn.looksLikeNumber=Rn;var Xs=sn;import{basename as hl,dirname as pl,extname as gl,relative as ml,resolve as ii,join as Dl}from"path";function Zo(){if(nl())return 0;return 1}function nl(){return sl()&&!process.defaultApp}function sl(){return!!process.versions.electron}function Gs(e){return e.slice(Zo()+1)}function Qo(){return process.argv[Zo()]}import{readFileSync as rl,statSync as ol,writeFile as il}from"fs";import{format as al}from"util";import{resolve as cl}from"path";var ei={fs:{readFileSync:rl,writeFile:il},format:al,resolve:cl,exists:(e)=>{try{return ol(e).isFile()}catch(t){return!1}}};var Ue;class ti{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 ni(e,t){Ue=t;let n=new ti(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 ul=(e)=>ni(e,ei),si=ul;var ci=po(oi(),1);import{createRequire as yl}from"node:module";import{readFileSync as bl,readdirSync as wl}from"node:fs";var Vs=ai(import.meta.url),Fl=Vs.substring(0,Vs.lastIndexOf("node_modules")),Cl=yl(import.meta.url),Zs={assert:{notStrictEqual:ll,strictEqual:fl},cliui:Us,findUp:Ks,getEnv:(e)=>process.env[e],inspect:dl,getProcessArgvBin:Qo,mainFilename:Fl||process.cwd(),Parser:Xs,path:{basename:hl,dirname:pl,extname:gl,relative:ml,resolve:ii,join:Dl},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:bl,readdirSync:wl,require:Cl,getCallerFile:()=>{let e=ci.default(3);return e.match(/^file:\/\//)?ai(e):e},stringWidth:We,y18n:si({directory:ii(Vs,"../../../locales"),updateFiles:!1})};function Ce(e,t,n,r){n.assert.notStrictEqual(e,t,r)}function Qs(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 El=["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=ui(d);if(l.cmd.filter((h)=>h===p||h==="*").length===0)li(p,l.cmd,s);s+=1}),o.optional.forEach((l)=>{if(c.length===0)return;let d=c.shift(),p=ui(d);if(l.cmd.filter((h)=>h===p||h==="*").length===0)li(p,l.cmd,s);s+=1})}catch(s){console.warn(s.stack)}}function ui(e){if(Array.isArray(e))return"array";else if(e===null)return"null";return typeof e}function li(e,t,n){throw new le(`Invalid ${El[n]||"manyith"} argument. Expected ${t.join(" or ")} but received ${e}.`)}class er{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 fi(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=xl(e)?e():e;return re(r)?r.then((s)=>t(s)):t(r)}catch(r){return n(r)}}function xl(e){return typeof e==="function"}var Kt=/(^\*)|(^\$0)/;class hi{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=fi(s);if(r=r||(()=>{}),Array.isArray(e))if(_l(e))[e,...i]=e;else for(let c of e)this.addHandler(c);else if(Sl(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(di(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(Mn(c)){n.getInternalMethods().getUsageInstance().freeze();let f=c(n.getInternalMethods().reset(r),a);if(re(f))return f.then((l)=>(u=gi(l)?l:n,this.parseAndUpdateUsage(e,t,u,s,o,i)))}else if(kl(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(Mn(t))return t(e,!0);else if(!di(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 pi(e,t,n,r){return new hi(e,t,n,r)}function di(e){return typeof e==="object"&&!!e.builder&&typeof e.handler==="function"}function _l(e){return e.every((t)=>typeof t==="string")}function Mn(e){return typeof e==="function"}function kl(e){return typeof e==="object"}function Sl(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 Al(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(Al(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
|
-
`;else
|
|
16
|
-
`;te.div(`${
|
|
17
|
-
`);te.div(`${
|
|
18
|
-
`)}return te.toString().replace(/\s*$/,"")};function
|
|
13
|
+
`).map((r)=>Ol(r,t,n)).join(`
|
|
14
|
+
`)}function Qs(e){return zo(e,{stringWidth:Ke,stripAnsi:wt,wrap:Zs})}import{dirname as mi,resolve as Di}from"path";import{readdirSync as Pl,statSync as Rl}from"fs";function er(e,t){let n=Di(".",e),r;if(!Rl(n).isDirectory())n=mi(n);while(!0){if(r=t(n,Pl(n)),r)return Di(n,r);if(n=mi(r=n),r===n)break}}import{inspect as Zl}from"util";import{fileURLToPath as Ri}from"url";import{format as vl}from"util";import{normalize as Bl,resolve as Ll}from"path";function bt(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 Kn(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 Jn(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 yi(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 Pe;(function(e){e.BOOLEAN="boolean",e.STRING="string",e.NUMBER="number",e.ARRAY="array"})(Pe||(Pe={}));var tt;class nr{constructor(e){tt=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=yi(e),s=typeof e==="string",o=Ml(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,d=i["populate--"],l=d?"--":"_",f=Object.create(null),h=Object.create(null),m=n.__||tt.format,p={aliases:Object.create(null),arrays:Object.create(null),bools:Object.create(null),strings:Object.create(null),numbers:Object.create(null),counts:Object.create(null),normalize:Object.create(null),configs:Object.create(null),nargs:Object.create(null),coercions:Object.create(null),keys:[]},y=/^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/,F=new RegExp("^--"+i["negation-prefix"]+"(.+)");if([].concat(n.array||[]).filter(Boolean).forEach(function(D){let b=typeof D==="object"?D.key:D,I=Object.keys(D).map(function(x){return{boolean:"bools",string:"strings",number:"numbers"}[x]}).filter(Boolean).pop();if(I)p[I][b]=!0;p.arrays[b]=!0,p.keys.push(b)}),[].concat(n.boolean||[]).filter(Boolean).forEach(function(D){p.bools[D]=!0,p.keys.push(D)}),[].concat(n.string||[]).filter(Boolean).forEach(function(D){p.strings[D]=!0,p.keys.push(D)}),[].concat(n.number||[]).filter(Boolean).forEach(function(D){p.numbers[D]=!0,p.keys.push(D)}),[].concat(n.count||[]).filter(Boolean).forEach(function(D){p.counts[D]=!0,p.keys.push(D)}),[].concat(n.normalize||[]).filter(Boolean).forEach(function(D){p.normalize[D]=!0,p.keys.push(D)}),typeof n.narg==="object")Object.entries(n.narg).forEach(([D,b])=>{if(typeof b==="number")p.nargs[D]=b,p.keys.push(D)});if(typeof n.coerce==="object")Object.entries(n.coerce).forEach(([D,b])=>{if(typeof b==="function")p.coercions[D]=b,p.keys.push(D)});if(typeof n.config<"u"){if(Array.isArray(n.config)||typeof n.config==="string")[].concat(n.config).filter(Boolean).forEach(function(D){p.configs[D]=!0});else if(typeof n.config==="object")Object.entries(n.config).forEach(([D,b])=>{if(typeof b==="boolean"||typeof b==="function")p.configs[D]=b})}et(n.key,o,n.default,p.arrays),Object.keys(a).forEach(function(D){(p.aliases[D]||[]).forEach(function(b){a[b]=a[D]})});let C=null;qs();let T=[],S=Object.assign(Object.create(null),{_:[]}),v={};for(let D=0;D<r.length;D++){let b=r[D],I=b.replace(/^-{3,}/,"---"),x,w,j,N,J,ge;if(b!=="--"&&/^-/.test(b)&&se(b))K(b);else if(I.match(/^---+(=|$)/)){K(b);continue}else if(b.match(/^--.+=/)||!i["short-option-groups"]&&b.match(/^-.+=/)){if(N=b.match(/^--?([^=]+)=([\s\S]*)$/),N!==null&&Array.isArray(N)&&N.length>=3)if(R(N[1],p.arrays))D=z(D,N[1],r,N[2]);else if(R(N[1],p.nargs)!==!1)D=P(D,N[1],r,N[2]);else W(N[1],N[2],!0)}else if(b.match(F)&&i["boolean-negation"]){if(N=b.match(F),N!==null&&Array.isArray(N)&&N.length>=2)w=N[1],W(w,R(w,p.arrays)?[!1]:!1)}else if(b.match(/^--.+/)||!i["short-option-groups"]&&b.match(/^-[^-]+/)){if(N=b.match(/^--?(.+)/),N!==null&&Array.isArray(N)&&N.length>=2)if(w=N[1],R(w,p.arrays))D=z(D,w,r);else if(R(w,p.nargs)!==!1)D=P(D,w,r);else if(J=r[D+1],J!==void 0&&(!J.match(/^-/)||J.match(y))&&!R(w,p.bools)&&!R(w,p.counts))W(w,J),D++;else if(/^(true|false)$/.test(J))W(w,J),D++;else W(w,Q(w))}else if(b.match(/^-.\..+=/)){if(N=b.match(/^-([^=]+)=([\s\S]*)$/),N!==null&&Array.isArray(N)&&N.length>=3)W(N[1],N[2])}else if(b.match(/^-.\..+/)&&!b.match(y)){if(J=r[D+1],N=b.match(/^-(.\..+)/),N!==null&&Array.isArray(N)&&N.length>=2)if(w=N[1],J!==void 0&&!J.match(/^-/)&&!R(w,p.bools)&&!R(w,p.counts))W(w,J),D++;else W(w,Q(w))}else if(b.match(/^-[^-]+/)&&!b.match(y)){j=b.slice(1,-1).split(""),x=!1;for(let Ce=0;Ce<j.length;Ce++){if(J=b.slice(Ce+2),j[Ce+1]&&j[Ce+1]==="="){if(ge=b.slice(Ce+3),w=j[Ce],R(w,p.arrays))D=z(D,w,r,ge);else if(R(w,p.nargs)!==!1)D=P(D,w,r,ge);else W(w,ge);x=!0;break}if(J==="-"){W(j[Ce],J);continue}if(/[A-Za-z]/.test(j[Ce])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(J)&&R(J,p.bools)===!1){W(j[Ce],J),x=!0;break}if(j[Ce+1]&&j[Ce+1].match(/\W/)){W(j[Ce],J),x=!0;break}else W(j[Ce],Q(j[Ce]))}if(w=b.slice(-1)[0],!x&&w!=="-")if(R(w,p.arrays))D=z(D,w,r);else if(R(w,p.nargs)!==!1)D=P(D,w,r);else if(J=r[D+1],J!==void 0&&(!/^(-|--)[^-]/.test(J)||J.match(y))&&!R(w,p.bools)&&!R(w,p.counts))W(w,J),D++;else if(/^(true|false)$/.test(J))W(w,J),D++;else W(w,Q(w))}else if(b.match(/^-[0-9]$/)&&b.match(y)&&R(b.slice(1),p.bools))w=b.slice(1),W(w,Q(w));else if(b==="--"){T=r.slice(D+1);break}else if(i["halt-at-non-option"]){T=r.slice(D);break}else K(b)}if(V(S,!0),V(S,!1),A(S),M(),Te(S,p.aliases,a,!0),X(S),i["set-placeholder-key"])re(S);if(Object.keys(p.counts).forEach(function(D){if(!te(S,D.split(".")))W(D,0)}),d&&T.length)S[l]=[];if(T.forEach(function(D){S[l].push(D)}),i["camel-case-expansion"]&&i["strip-dashed"])Object.keys(S).filter((D)=>D!=="--"&&D.includes("-")).forEach((D)=>{delete S[D]});if(i["strip-aliased"])[].concat(...Object.keys(o).map((D)=>o[D])).forEach((D)=>{if(i["camel-case-expansion"]&&D.includes("-"))delete S[D.split(".").map((b)=>bt(b)).join(".")];delete S[D]});function K(D){let b=E("_",D);if(typeof b==="string"||typeof b==="number")S._.push(b)}function P(D,b,I,x){let w,j=R(b,p.nargs);if(j=typeof j!=="number"||isNaN(j)?1:j,j===0){if(!he(x))C=Error(m("Argument unexpected for: %s",b));return W(b,Q(b)),D}let N=he(x)?0:1;if(i["nargs-eats-options"]){if(I.length-(D+1)+N<j)C=Error(m("Not enough arguments following: %s",b));N=j}else{for(w=D+1;w<I.length;w++)if(!I[w].match(/^-[^0-9]/)||I[w].match(y)||se(I[w]))N++;else break;if(N<j)C=Error(m("Not enough arguments following: %s",b))}let J=Math.min(N,j);if(!he(x)&&J>0)W(b,x),J--;for(w=D+1;w<J+D+1;w++)W(b,I[w]);return D+J}function z(D,b,I,x){let w=[],j=x||I[D+1],N=R(b,p.nargs);if(R(b,p.bools)&&!/^(true|false)$/.test(j))w.push(!0);else if(he(j)||he(x)&&/^-/.test(j)&&!y.test(j)&&!se(j)){if(a[b]!==void 0){let J=a[b];w=Array.isArray(J)?J:[J]}}else{if(!he(x))w.push(k(b,x,!0));for(let J=D+1;J<I.length;J++){if(!i["greedy-arrays"]&&w.length>0||N&&typeof N==="number"&&w.length>=N)break;if(j=I[J],/^-/.test(j)&&!y.test(j)&&!se(j))break;D=J,w.push(k(b,j,s))}}if(typeof N==="number"&&(N&&w.length<N||isNaN(N)&&w.length===0))C=Error(m("Not enough arguments following: %s",b));return W(b,w),D}function W(D,b,I=s){if(/-/.test(D)&&i["camel-case-expansion"]){let j=D.split(".").map(function(N){return bt(N)}).join(".");Z(D,j)}let x=k(D,b,I),w=D.split(".");if(Ie(S,w,x),p.aliases[D])p.aliases[D].forEach(function(j){let N=j.split(".");Ie(S,N,x)});if(w.length>1&&i["dot-notation"])(p.aliases[w[0]]||[]).forEach(function(j){let N=j.split("."),J=[].concat(w);if(J.shift(),N=N.concat(J),!(p.aliases[D]||[]).includes(N.join(".")))Ie(S,N,x)});if(R(D,p.normalize)&&!R(D,p.arrays))[D].concat(p.aliases[D]||[]).forEach(function(N){Object.defineProperty(v,N,{enumerable:!0,get(){return b},set(J){b=typeof J==="string"?tt.normalize(J):J}})})}function Z(D,b){if(!(p.aliases[D]&&p.aliases[D].length))p.aliases[D]=[b],f[b]=!0;if(!(p.aliases[b]&&p.aliases[b].length))Z(b,D)}function k(D,b,I){if(I)b=Nl(b);if(R(D,p.bools)||R(D,p.counts)){if(typeof b==="string")b=b==="true"}let x=Array.isArray(b)?b.map(function(w){return E(D,w)}):E(D,b);if(R(D,p.counts)&&(he(x)||typeof x==="boolean"))x=tr();if(R(D,p.normalize)&&R(D,p.arrays))if(Array.isArray(b))x=b.map((w)=>tt.normalize(w));else x=tt.normalize(b);return x}function E(D,b){if(!i["parse-positional-numbers"]&&D==="_")return b;if(!R(D,p.strings)&&!R(D,p.bools)&&!Array.isArray(b)){if(Jn(b)&&i["parse-numbers"]&&Number.isSafeInteger(Math.floor(parseFloat(`${b}`)))||!he(b)&&R(D,p.numbers))b=Number(b)}return b}function A(D){let b=Object.create(null);Te(b,p.aliases,a),Object.keys(p.configs).forEach(function(I){let x=D[I]||b[I];if(x)try{let w=null,j=tt.resolve(tt.cwd(),x),N=p.configs[I];if(typeof N==="function"){try{w=N(j)}catch(J){w=J}if(w instanceof Error){C=w;return}}else w=tt.require(j);_(w)}catch(w){if(w.name==="PermissionDenied")C=w;else if(D[I])C=Error(m("Invalid JSON config file: %s",x))}})}function _(D,b){Object.keys(D).forEach(function(I){let x=D[I],w=b?b+"."+I:I;if(typeof x==="object"&&x!==null&&!Array.isArray(x)&&i["dot-notation"])_(x,w);else if(!te(S,w.split("."))||R(w,p.arrays)&&i["combine-arrays"])W(w,x)})}function M(){if(typeof c<"u")c.forEach(function(D){_(D)})}function V(D,b){if(typeof u>"u")return;let I=typeof u==="string"?u:"",x=tt.env();Object.keys(x).forEach(function(w){if(I===""||w.lastIndexOf(I,0)===0){let j=w.split("__").map(function(N,J){if(J===0)N=N.substring(I.length);return bt(N)});if((b&&p.configs[j.join(".")]||!b)&&!te(D,j))W(j.join("."),x[w])}})}function X(D){let b,I=new Set;Object.keys(D).forEach(function(x){if(!I.has(x)){if(b=R(x,p.coercions),typeof b==="function")try{let w=E(x,b(D[x]));[].concat(p.aliases[x]||[],x).forEach((j)=>{I.add(j),D[j]=w})}catch(w){C=w}}})}function re(D){return p.keys.forEach((b)=>{if(~b.indexOf("."))return;if(typeof D[b]>"u")D[b]=void 0}),D}function Te(D,b,I,x=!1){Object.keys(I).forEach(function(w){if(!te(D,w.split("."))){if(Ie(D,w.split("."),I[w]),x)h[w]=!0;(b[w]||[]).forEach(function(j){if(te(D,j.split(".")))return;Ie(D,j.split("."),I[w])})}})}function te(D,b){let I=D;if(!i["dot-notation"])b=[b.join(".")];b.slice(0,-1).forEach(function(w){I=I[w]||{}});let x=b[b.length-1];if(typeof I!=="object")return!1;else return x in I}function Ie(D,b,I){let x=D;if(!i["dot-notation"])b=[b.join(".")];b.slice(0,-1).forEach(function(ge){if(ge=wi(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=wi(b[b.length-1]),j=R(b.join("."),p.arrays),N=Array.isArray(I),J=i["duplicate-arguments-array"];if(!J&&R(w,p.nargs)){if(J=!0,!he(x[w])&&p.nargs[w]===1||Array.isArray(x[w])&&x[w].length===p.nargs[w])x[w]=void 0}if(I===tr())x[w]=tr(x[w]);else if(Array.isArray(x[w]))if(J&&j&&N)x[w]=i["flatten-duplicate-arrays"]?x[w].concat(I):(Array.isArray(x[w][0])?x[w]:[x[w]]).concat([I]);else if(!J&&Boolean(j)===Boolean(N))x[w]=I;else x[w]=x[w].concat([I]);else if(x[w]===void 0&&j)x[w]=N?I:[I];else if(J&&!(x[w]===void 0||R(w,p.counts)||R(w,p.bools)))x[w]=[x[w],I];else x[w]=I}function et(...D){D.forEach(function(b){Object.keys(b||{}).forEach(function(I){if(p.aliases[I])return;p.aliases[I]=[].concat(o[I]||[]),p.aliases[I].concat(I).forEach(function(x){if(/-/.test(x)&&i["camel-case-expansion"]){let w=bt(x);if(w!==I&&p.aliases[I].indexOf(w)===-1)p.aliases[I].push(w),f[w]=!0}}),p.aliases[I].concat(I).forEach(function(x){if(x.length>1&&/[A-Z]/.test(x)&&i["camel-case-expansion"]){let w=Kn(x,"-");if(w!==I&&p.aliases[I].indexOf(w)===-1)p.aliases[I].push(w),f[w]=!0}}),p.aliases[I].forEach(function(x){p.aliases[x]=[I].concat(p.aliases[I].filter(function(w){return x!==w}))})})})}function R(D,b){let I=[].concat(p.aliases[D]||[],D),x=Object.keys(b),w=I.find((j)=>x.includes(j));return w?b[w]:!1}function ue(D){let b=Object.keys(p);return[].concat(b.map((x)=>p[x])).some(function(x){return Array.isArray(x)?x.includes(D):x[D]})}function Oe(D,...b){return[].concat(...b).some(function(x){let w=D.match(x);return w&&ue(w[1])})}function H(D){if(D.match(y)||!D.match(/^-[^-]+/))return!1;let b=!0,I,x=D.slice(1).split("");for(let w=0;w<x.length;w++){if(I=D.slice(w+2),!ue(x[w])){b=!1;break}if(x[w+1]&&x[w+1]==="="||I==="-"||/[A-Za-z]/.test(x[w])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(I)||x[w+1]&&x[w+1].match(/\W/))break}return b}function se(D){return i["unknown-options-as-args"]&&pe(D)}function pe(D){if(D=D.replace(/^-{3,}/,"--"),D.match(y))return!1;if(H(D))return!1;return!Oe(D,/^-+([^=]+?)=[\s\S]*$/,F,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}function Q(D){if(!R(D,p.bools)&&!R(D,p.counts)&&`${D}`in a)return a[D];else return ye(le(D))}function ye(D){return{[Pe.BOOLEAN]:!0,[Pe.STRING]:"",[Pe.NUMBER]:void 0,[Pe.ARRAY]:[]}[D]}function le(D){let b=Pe.BOOLEAN;if(R(D,p.strings))b=Pe.STRING;else if(R(D,p.numbers))b=Pe.NUMBER;else if(R(D,p.bools))b=Pe.BOOLEAN;else if(R(D,p.arrays))b=Pe.ARRAY;return b}function he(D){return D===void 0}function qs(){Object.keys(p.counts).find((D)=>{if(R(D,p.arrays))return C=Error(m("Invalid configuration: %s, opts.count excludes opts.array.",D)),!0;else if(R(D,p.nargs))return C=Error(m("Invalid configuration: %s, opts.count excludes opts.narg.",D)),!0;return!1})}return{aliases:Object.assign({},p.aliases),argv:Object.assign(v,S),configuration:i,defaulted:Object.assign({},h),error:C,newAliases:Object.assign({},f)}}}function Ml(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 tr(e){return e!==void 0?e+1:1}function wi(e){if(e==="__proto__")return"___proto___";return e}function Nl(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 jl}from"fs";import{createRequire as bi}from"node:module";var sr,rr,or,Ci=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):20,Ei=(rr=(sr=process===null||process===void 0?void 0:process.versions)===null||sr===void 0?void 0:sr.node)!==null&&rr!==void 0?rr:(or=process===null||process===void 0?void 0:process.version)===null||or===void 0?void 0:or.slice(1);if(Ei){if(Number(Ei.match(/^([^.]+)/)[1])<Ci)throw Error(`yargs parser supports a minimum Node.js version of ${Ci}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`)}var Wl=process?process.env:{},Fi=bi?bi(import.meta.url):void 0,xi=new nr({cwd:process.cwd,env:()=>Wl,format:vl,normalize:Bl,resolve:Ll,require:(e)=>{if(typeof Fi<"u")return Fi(e);else if(e.match(/\.json$/))return JSON.parse(jl(e,"utf8"));else throw Error("only .json config files are supported in ESM")}}),an=function(t,n){return xi.parse(t.slice(),n).argv};an.detailed=function(e,t){return xi.parse(e.slice(),t)};an.camelCase=bt;an.decamelize=Kn;an.looksLikeNumber=Jn;var ir=an;import{basename as Ql,dirname as ef,extname as tf,relative as nf,resolve as Pi,join as sf}from"path";function ki(){if(Ul())return 0;return 1}function Ul(){return Kl()&&!process.defaultApp}function Kl(){return!!process.versions.electron}function ar(e){return e.slice(ki()+1)}function _i(){return process.argv[ki()]}import{readFileSync as Jl,statSync as zl,writeFile as Hl}from"fs";import{format as ql}from"util";import{resolve as Xl}from"path";var Si={fs:{readFileSync:Jl,writeFile:Hl},format:ql,resolve:Xl,exists:(e)=>{try{return zl(e).isFile()}catch(t){return!1}}};var Je;class Ai{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 Je.format.apply(Je.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 Je.format.apply(Je.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);Je.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(Je.fs.readFileSync)e=JSON.parse(Je.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=Je.resolve(e,"./",t+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(n)&&~t.lastIndexOf("_")){let r=Je.resolve(e,"./",t.split("_")[0]+".json");if(this._fileExistsSync(r))n=r}return n}_fileExistsSync(e){return Je.exists(e)}}function $i(e,t){Je=t;let n=new Ai(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 Gl=(e)=>$i(e,Si),Ti=Gl;var Mi=Wo(Oi(),1);import{createRequire as rf}from"node:module";import{readFileSync as of,readdirSync as af}from"node:fs";var cr=Ri(import.meta.url),cf=cr.substring(0,cr.lastIndexOf("node_modules")),uf=rf(import.meta.url),ur={assert:{notStrictEqual:Yl,strictEqual:Vl},cliui:Qs,findUp:er,getEnv:(e)=>process.env[e],inspect:Zl,getProcessArgvBin:_i,mainFilename:cf||process.cwd(),Parser:ir,path:{basename:Ql,dirname:ef,extname:tf,relative:nf,resolve:Pi,join:sf},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:of,readdirSync:af,require:uf,getCallerFile:()=>{let e=Mi.default(3);return e.match(/^file:\/\//)?Ri(e):e},stringWidth:Ke,y18n:Ti({directory:Pi(cr,"../../../locales"),updateFiles:!1})};function Ee(e,t,n,r){n.assert.notStrictEqual(e,t,r)}function lr(e,t){t.assert.strictEqual(typeof e,"string")}function Jt(e){return Object.keys(e)}function oe(e){return!!e&&!!e.then&&typeof e.then==="function"}class fe extends Error{constructor(e){super(e||"yargs error");if(this.name="YError",Error.captureStackTrace)Error.captureStackTrace(this,fe)}}function it(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 lf=["first","second","third","fourth","fifth","sixth"];function B(e,t,n){function r(){return typeof e==="object"?[{demanded:[],optional:[]},e,t]:[it(`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 fe(`Not enough arguments provided. Expected ${o.demanded.length} but received ${c.length}.`);let d=o.demanded.length+o.optional.length;if(u>d)throw new fe(`Too many arguments provided. Expected max ${d} but received ${u}.`);o.demanded.forEach((l)=>{let f=c.shift(),h=Ni(f);if(l.cmd.filter((p)=>p===h||p==="*").length===0)vi(h,l.cmd,s);s+=1}),o.optional.forEach((l)=>{if(c.length===0)return;let f=c.shift(),h=Ni(f);if(l.cmd.filter((p)=>p===h||p==="*").length===0)vi(h,l.cmd,s);s+=1})}catch(s){console.warn(s.stack)}}function Ni(e){if(Array.isArray(e))return"array";else if(e===null)return"null";return typeof e}function vi(e,t,n){throw new fe(`Invalid ${lf[n]||"manyith"} argument. Expected ${t.join(" or ")} but received ${e}.`)}class fr{constructor(e){this.globalMiddleware=[],this.frozens=[],this.yargs=e}addMiddleware(e,t,n=!0,r=!1){if(B("<array|function> [boolean] [boolean] [boolean]",[e,t,n],arguments.length),Array.isArray(e)){for(let s=0;s<e.length;s++){if(typeof e[s]!=="function")throw Error("middleware must be a function");let 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 Bi(e){if(!e)return[];return e.map((t)=>(t.applyBeforeValidation=!1,t))}function Ct(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(oe(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 oe(i)?i.then((a)=>Object.assign(s,a)):Object.assign(s,i)}},e)}function Et(e,t,n=(r)=>{throw r}){try{let r=ff(e)?e():e;return oe(r)?r.then((s)=>t(s)):t(r)}catch(r){return n(r)}}function ff(e){return typeof e==="function"}var zt=/(^\*)|(^\$0)/;class ji{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 d=!1;if(typeof r.exclude==="function")d=r.exclude(c);else d=r.exclude.test(c);if(d)continue}if(r.include){let d=!1;if(typeof r.include==="function")d=r.include(c);else d=r.include.test(c);if(!d)continue}let u=!1;for(let d of r.extensions)if(c.endsWith(d))u=!0;if(u){let d=this.shim.path.join(s,c),l=t(d),f=Object.create(null,Object.getOwnPropertyDescriptors({...l}));if(i(f,d,c)){if(this.requireCache.has(d))continue;else this.requireCache.add(d);if(!f.command)f.command=this.shim.path.basename(d,this.shim.path.extname(d));this.addHandler(f)}}}}addHandler(e,t,n,r,s,o){let i=[],a=Bi(s);if(r=r||(()=>{}),Array.isArray(e))if(df(e))[e,...i]=e;else for(let c of e)this.addHandler(c);else if(hf(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(Li(n)){this.addHandler([e].concat(i),t,n.builder,n.handler,n.middlewares,n.deprecated);return}if(typeof e==="string"){let c=it(e);i=i.map((l)=>it(l).cmd);let u=!1,d=[c.cmd].concat(i).filter((l)=>{if(zt.test(l))return u=!0,!1;return!0});if(d.length===0&&u)d.push("$0");if(u)c.cmd=d[0],i=d.slice(1),e=e.replace(zt,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 d=this.applyBuilderUpdateUsageAndParse(u,i,t,n.aliases,c,r,s,o);return oe(d)?d.then((l)=>this.applyMiddlewareAndGetResult(u,i,l.innerArgv,a,s,l.aliases,t)):this.applyMiddlewareAndGetResult(u,i,d.innerArgv,a,s,d.aliases,t)}applyBuilderUpdateUsageAndParse(e,t,n,r,s,o,i,a){let c=t.builder,u=n;if(zn(c)){n.getInternalMethods().getUsageInstance().freeze();let d=c(n.getInternalMethods().reset(r),a);if(oe(d))return d.then((l)=>(u=Ui(l)?l:n,this.parseAndUpdateUsage(e,t,u,s,o,i)))}else if(pf(c))n.getInternalMethods().getUsageInstance().freeze(),u=n.getInternalMethods().reset(r),Object.keys(t.builder).forEach((d)=>{u.option(d,c[d])});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 oe(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=zt.test(t.original)?t.original.replace(zt,"").trim():t.original,r=e.filter((s)=>!zt.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=Et(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=Ct(n,o,i,!1),n=Et(n,(u)=>{let d=t.handler(u);return oe(d)?d.then(()=>u):u}),!e)o.getInternalMethods().getUsageInstance().cacheHelpMessage();if(oe(n)&&!o.getInternalMethods().hasParseCallback())n.catch((u)=>{try{o.getInternalMethods().getUsageInstance().fail(null,u)}catch(d){}})}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=Ct(n,i,c,!0);return oe(u)?u.then((d)=>this.handleValidationAndGetResult(e,t,d,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=it(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=zt.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(zn(t))return t(e,!0);else if(!Li(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;Ee(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();Ee(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 Wi(e,t,n,r){return new ji(e,t,n,r)}function Li(e){return typeof e==="object"&&!!e.builder&&typeof e.handler==="function"}function df(e){return e.every((t)=>typeof t==="string")}function zn(e){return typeof e==="function"}function pf(e){return typeof e==="object"}function hf(e){return typeof e==="object"&&!Array.isArray(e)}function at(e={},t=()=>!0){let n={};return Jt(e).forEach((r)=>{if(t(r,e[r]))n[r]=e[r]}),n}function ct(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 gf(e){return typeof e==="boolean"}function Ji(e,t){let n=t.y18n.__,r={},s=[];r.failFn=function(E){s.push(E)};let o=null,i=null,a=!0;r.showHelpOnFail=function(E=!0,A){let[_,M]=typeof E==="string"?[!0,E]:[E,A];if(e.getInternalMethods().isGlobalContext())i=M;return o=M,a=_,r};let c=!1;r.fail=function(E,A){let _=e.getInternalMethods().getLoggerInstance();if(s.length)for(let M=s.length-1;M>=0;--M){let V=s[M];if(gf(V)){if(A)throw A;else if(E)throw Error(E)}else V(E,A,r)}else{if(e.getExitProcess())ct(!0);if(!c){if(c=!0,a)e.showHelp("error"),_.error();if(E||A)_.error(E||A);let M=o||i;if(M){if(E||A)_.error("");_.error(M)}}if(A=A||new fe(E),e.getExitProcess())return e.exit(1);else if(e.getInternalMethods().hasParseCallback())return e.exit(1,A);else throw A}};let u=[],d=!1;r.usage=(k,E)=>{if(k===null)return d=!0,u=[],r;return d=!1,u.push([k,E||""]),r},r.getUsage=()=>u,r.getUsageDisabled=()=>d,r.getPositionalGroupName=()=>n("Positionals:");let l=[];r.example=(k,E)=>{l.push([k,E||""])};let f=[];r.command=function(E,A,_,M,V=!1){if(_)f=f.map((X)=>(X[2]=!1,X));f.push([E,A||"",_,M,V])},r.getCommands=()=>f;let h={};r.describe=function(E,A){if(Array.isArray(E))E.forEach((_)=>{r.describe(_,A)});else if(typeof E==="object")Object.keys(E).forEach((_)=>{r.describe(_,E[_])});else h[E]=A},r.getDescriptions=()=>h;let m=[];r.epilog=(k)=>{m.push(k)};let p=!1,y;r.wrap=(k)=>{p=!0,y=k},r.getWrap=()=>{if(t.getEnv("YARGS_DISABLE_WRAP"))return null;if(!p)y=z(),p=!0;return y};let F="__yargsString__:";r.deferY18nLookup=(k)=>F+k,r.help=function(){if(S)return S;T();let E=e.customScriptName?e.$0:t.path.basename(e.$0),A=e.getDemandedOptions(),_=e.getDemandedCommands(),M=e.getDeprecatedOptions(),V=e.getGroups(),X=e.getOptions(),re=[];re=re.concat(Object.keys(h)),re=re.concat(Object.keys(A)),re=re.concat(Object.keys(_)),re=re.concat(Object.keys(X.default)),re=re.filter(K),re=Object.keys(re.reduce((H,se)=>{if(se!=="_")H[se]=!0;return H},{}));let Te=r.getWrap(),te=t.cliui({width:Te,wrap:!!Te});if(!d){if(u.length)u.forEach((H)=>{if(te.div({text:`${H[0].replace(/\$0/g,E)}`}),H[1])te.div({text:`${H[1]}`,padding:[1,0,0,0]})}),te.div();else if(f.length){let H=null;if(_._)H=`${E} <${n("command")}>
|
|
15
|
+
`;else H=`${E} [${n("command")}]
|
|
16
|
+
`;te.div(`${H}`)}}if(f.length>1||f.length===1&&!f[0][2]){te.div(n("Commands:"));let H=e.getInternalMethods().getContext(),se=H.commands.length?`${H.commands.join(" ")} `:"";if(e.getInternalMethods().getParserConfiguration()["sort-commands"]===!0)f=f.sort((Q,ye)=>Q[0].localeCompare(ye[0]));let pe=E?`${E} `:"";f.forEach((Q)=>{let ye=`${pe}${se}${Q[0].replace(/^\$0 ?/,"")}`;te.span({text:ye,padding:[0,2,0,2],width:C(f,Te,`${E}${se}`)+4},{text:Q[1]});let le=[];if(Q[2])le.push(`[${n("default")}]`);if(Q[3]&&Q[3].length)le.push(`[${n("aliases:")} ${Q[3].join(", ")}]`);if(Q[4])if(typeof Q[4]==="string")le.push(`[${n("deprecated: %s",Q[4])}]`);else le.push(`[${n("deprecated")}]`);if(le.length)te.div({text:le.join(" "),padding:[0,0,0,2],align:"right"});else te.div()}),te.div()}let Ie=(Object.keys(X.alias)||[]).concat(Object.keys(e.parsed.newAliases)||[]);re=re.filter((H)=>!e.parsed.newAliases[H]&&Ie.every((se)=>(X.alias[se]||[]).indexOf(H)===-1));let et=n("Options:");if(!V[et])V[et]=[];v(re,X.alias,V,et);let R=(H)=>/^--/.test(Hn(H)),ue=Object.keys(V).filter((H)=>V[H].length>0).map((H)=>{let se=V[H].filter(K).map((pe)=>{if(Ie.includes(pe))return pe;for(let Q=0,ye;(ye=Ie[Q])!==void 0;Q++)if((X.alias[ye]||[]).includes(pe))return ye;return pe});return{groupName:H,normalizedKeys:se}}).filter(({normalizedKeys:H})=>H.length>0).map(({groupName:H,normalizedKeys:se})=>{let pe=se.reduce((Q,ye)=>(Q[ye]=[ye].concat(X.alias[ye]||[]).map((le)=>{if(H===r.getPositionalGroupName())return le;else return(/^[0-9]$/.test(le)?X.boolean.includes(ye)?"-":"--":le.length>1?"--":"-")+le}).sort((le,he)=>R(le)===R(he)?0:R(le)?1:-1).join(", "),Q),{});return{groupName:H,normalizedKeys:se,switches:pe}});if(ue.filter(({groupName:H})=>H!==r.getPositionalGroupName()).some(({normalizedKeys:H,switches:se})=>!H.every((pe)=>R(se[pe]))))ue.filter(({groupName:H})=>H!==r.getPositionalGroupName()).forEach(({normalizedKeys:H,switches:se})=>{H.forEach((pe)=>{if(R(se[pe]))se[pe]=mf(se[pe],4)})});if(ue.forEach(({groupName:H,normalizedKeys:se,switches:pe})=>{te.div(H),se.forEach((Q)=>{let ye=pe[Q],le=h[Q]||"",he=null;if(le.includes(F))le=n(le.substring(F.length));if(X.boolean.includes(Q))he=`[${n("boolean")}]`;if(X.count.includes(Q))he=`[${n("count")}]`;if(X.string.includes(Q))he=`[${n("string")}]`;if(X.normalize.includes(Q))he=`[${n("string")}]`;if(X.array.includes(Q))he=`[${n("array")}]`;if(X.number.includes(Q))he=`[${n("number")}]`;let qs=(I)=>typeof I==="string"?`[${n("deprecated: %s",I)}]`:`[${n("deprecated")}]`,D=[Q in M?qs(M[Q]):null,he,Q in A?`[${n("required")}]`:null,X.choices&&X.choices[Q]?`[${n("choices:")} ${r.stringifiedValues(X.choices[Q])}]`:null,P(X.default[Q],X.defaultDescription[Q])].filter(Boolean).join(" ");te.span({text:Hn(ye),padding:[0,2,0,2+Ki(ye)],width:C(pe,Te)+4},le);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((H)=>{H[0]=H[0].replace(/\$0/g,E)}),l.forEach((H)=>{if(H[1]==="")te.div({text:H[0],padding:[0,2,0,2]});else te.div({text:H[0],padding:[0,2,0,2],width:C(l,Te)+4},{text:H[1]})}),te.div();if(m.length>0){let H=m.map((se)=>se.replace(/\$0/g,E)).join(`
|
|
17
|
+
`);te.div(`${H}
|
|
18
|
+
`)}return te.toString().replace(/\s*$/,"")};function C(k,E,A){let _=0;if(!Array.isArray(k))k=Object.values(k).map((M)=>[M]);if(k.forEach((M)=>{_=Math.max(t.stringWidth(A?`${A} ${Hn(M[0])}`:Hn(M[0]))+Ki(M[0]),_)}),E)_=Math.min(_,parseInt((E*0.5).toString(),10));return _}function T(){let k=e.getDemandedOptions(),E=e.getOptions();(Object.keys(E.alias)||[]).forEach((A)=>{E.alias[A].forEach((_)=>{if(h[_])r.describe(A,h[_]);if(_ in k)e.demandOption(A,k[_]);if(E.boolean.includes(_))e.boolean(A);if(E.count.includes(_))e.count(A);if(E.string.includes(_))e.string(A);if(E.normalize.includes(_))e.normalize(A);if(E.array.includes(_))e.array(A);if(E.number.includes(_))e.number(A)})})}let S;r.cacheHelpMessage=function(){S=this.help()},r.clearCachedHelpMessage=function(){S=void 0},r.hasCachedHelpMessage=function(){return!!S};function v(k,E,A,_){let M=[],V=null;return Object.keys(A).forEach((X)=>{M=M.concat(A[X])}),k.forEach((X)=>{if(V=[X].concat(E[X]),!V.some((re)=>M.indexOf(re)!==-1))A[_].push(X)}),M}function K(k){return e.getOptions().hiddenOptions.indexOf(k)<0||e.parsed.argv[e.getOptions().showHiddenOpt]}r.showHelp=(k)=>{let E=e.getInternalMethods().getLoggerInstance();if(!k)k="error";(typeof k==="function"?k:E[k])(r.help())},r.functionDescription=(k)=>["(",k.name?t.Parser.decamelize(k.name,"-"):n("generated-value"),")"].join(""),r.stringifiedValues=function(E,A){let _="",M=A||", ",V=[].concat(E);if(!E||!V.length)return _;return V.forEach((X)=>{if(_.length)_+=M;_+=JSON.stringify(X)}),_};function P(k,E){let A=`[${n("default:")} `;if(k===void 0&&!E)return null;if(E)A+=E;else switch(typeof k){case"string":A+=`"${k}"`;break;case"object":A+=JSON.stringify(k);break;default:A+=k}return`${A}]`}function z(){if(t.process.stdColumns)return Math.min(80,t.process.stdColumns);else return 80}let W=null;r.version=(k)=>{W=k},r.showVersion=(k)=>{let E=e.getInternalMethods().getLoggerInstance();if(!k)k="error";(typeof k==="function"?k:E[k])(W)},r.reset=function(E){return o=null,c=!1,u=[],d=!1,m=[],l=[],f=[],h=at(h,(A)=>!E[A]),r};let Z=[];return r.freeze=function(){Z.push({failMessage:o,failureOutput:c,usages:u,usageDisabled:d,epilogs:m,examples:l,commands:f,descriptions:h})},r.unfreeze=function(E=!1){let A=Z.pop();if(!A)return;if(E)h={...A.descriptions,...h},f=[...A.commands,...f],u=[...A.usages,...u],l=[...A.examples,...l],m=[...A.epilogs,...m];else({failMessage:o,failureOutput:c,usages:u,usageDisabled:d,epilogs:m,examples:l,commands:f,descriptions:h}=A)},r}function dr(e){return typeof e==="object"}function mf(e,t){return dr(e)?{text:e.text,indentation:e.indentation+t}:{text:e,indentation:t}}function Ki(e){return dr(e)?e.indentation:0}function Hn(e){return dr(e)?e.text:e}var zi=`###-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
|
-
`,
|
|
47
|
+
`,Hi=`#compdef {{app_name}}
|
|
48
48
|
###-begin-{{app_name}}-completions-###
|
|
49
49
|
#
|
|
50
50
|
# yargs command completion script
|
|
@@ -71,167 +71,213 @@ else
|
|
|
71
71
|
compdef _{{app_name}}_yargs_completions {{app_name}}
|
|
72
72
|
fi
|
|
73
73
|
###-end-{{app_name}}-completions-###
|
|
74
|
-
`;class
|
|
74
|
+
`;class qi{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(zn(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=it(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 f=this.usage.getDescriptions(),h=(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 F=f[y];return typeof F==="string"&&F.length>0}),m=h?f[h]:void 0,p=(a=(i=f[e])!==null&&i!==void 0?i:m)!==null&&a!==void 0?a:"";c=`${e.replace(/:/g,"\\:")}:${p.replace("__yargsString__:","").replace(/(\r\n|\n|\r)/gm," ")}`}let u=(f)=>/^--/.test(f),d=(f)=>/^[^0-9]$/.test(f),l=!u(n)&&d(e)?"-":"--";if(t.push(l+c),r)t.push(l+"no-"+c)}customCompletion(e,t,n,r){if(Ee(this.customCompletionFunction,null,this.shim),yf(this.customCompletionFunction)){let s=this.customCompletionFunction(n,t);if(oe(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(wf(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 oe(r)?r.then(s):s(r)}generateCompletionScript(e,t){let n=this.zshShell?Hi:zi,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 Xi(e,t,n,r){return new qi(e,t,n,r)}function yf(e){return e.length<3}function wf(e){return e.length>3}function Gi(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 Vi(e,t,n){let r=n.y18n.__,s=n.y18n.__n,o={};o.nonOptionCount=function(l){let f=e.getDemandedCommands(),m=l._.length+(l["--"]?l["--"].length:0)-e.getInternalMethods().getContext().commands.length;if(f._&&(m<f._.min||m>f._.max)){if(m<f._.min)if(f._.minMsg!==void 0)t.fail(f._.minMsg?f._.minMsg.replace(/\$0/g,m.toString()).replace(/\$1/,f._.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(),f._.min.toString()));else if(m>f._.max)if(f._.maxMsg!==void 0)t.fail(f._.maxMsg?f._.maxMsg.replace(/\$0/g,m.toString()).replace(/\$1/,f._.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(),f._.max.toString()))}},o.positionalCount=function(l,f){if(f<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",f,f+"",l+""))},o.requiredArguments=function(l,f){let h=null;for(let m of Object.keys(f))if(!Object.prototype.hasOwnProperty.call(l,m)||typeof l[m]>"u")h=h||{},h[m]=f[m];if(h){let m=[];for(let y of Object.keys(h)){let F=h[y];if(F&&m.indexOf(F)<0)m.push(F)}let p=m.length?`
|
|
75
75
|
${m.join(`
|
|
76
|
-
`)}`:"";t.fail(s("Missing required argument: %s","Missing required arguments: %s",Object.keys(
|
|
77
|
-
${r("Argument: %s, Given: %s, Choices: %s",y,t.stringifiedValues(
|
|
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=Ci(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 nr=[],rn;function on(e,t,n,r){rn=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=Rl(t,e.extends);Pl(i),nr.push(i),s=o?JSON.parse(rn.readFileSync(i,"utf8")):r.require(e.extends),delete e.extends,s=on(s,rn.path.dirname(i),n,rn)}return nr=[],n?_i(s,e):Object.assign({},s,e)}function Pl(e){if(nr.indexOf(e)>-1)throw new le(`Circular extended configurations: '${e}'.`)}function Rl(e,t){return rn.path.resolve(e,t)}function _i(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]=_i(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,an,xe,Ae,Nn,it,bt,vn,Pe,jn,Re,Xe,$e,Me,Ln,wt,me,K,Wn,Un,Oe,Ft,Jt,Ct,at,Kn,H,Et,xt,_t,Y,Jn,Ge,ce;function zi(e){return(t=[],n=e.process.cwd(),r)=>{let s=new Hi(t,n,r,e);return Object.defineProperty(s,"argv",{get:()=>s.parse(),enumerable:!0}),s.help(),s.version(),s}}var ki=Symbol("copyDoubleDash"),Si=Symbol("copyDoubleDash"),sr=Symbol("deleteFromParserHintObject"),Ai=Symbol("emitWarning"),$i=Symbol("freeze"),Oi=Symbol("getDollarZero"),kt=Symbol("getParserConfiguration"),Ii=Symbol("getUsageConfiguration"),rr=Symbol("guessLocale"),Ti=Symbol("guessVersion"),Pi=Symbol("parsePositionalNumbers"),or=Symbol("pkgUp"),ct=Symbol("populateParserHintArray"),zt=Symbol("populateParserHintSingleValueDictionary"),ir=Symbol("populateParserHintArrayDictionary"),ar=Symbol("populateParserHintDictionary"),cr=Symbol("sanitizeKey"),ur=Symbol("setKey"),lr=Symbol("unfreeze"),Ri=Symbol("validateAsync"),Mi=Symbol("getCommandInstance"),Bi=Symbol("getContext"),Ni=Symbol("getHasOutput"),vi=Symbol("getLoggerInstance"),ji=Symbol("getParseContext"),Li=Symbol("getUsageInstance"),Wi=Symbol("getValidationInstance"),zn=Symbol("hasParseCallback"),Ui=Symbol("isGlobalContext"),St=Symbol("postProcess"),Ki=Symbol("rebase"),fr=Symbol("reset"),cn=Symbol("runYargsParserAndExecuteCommands"),dr=Symbol("runValidation"),Ji=Symbol("setHasOutput"),At=Symbol("kTrackManuallySetKeys"),Ml="en_US";class Hi{constructor(e=[],t,n,r){this.customScriptName=!1,this.parsed=!1,fe.set(this,void 0),yt.set(this,void 0),an.set(this,{commands:[],fullCommands:[]}),xe.set(this,null),Ae.set(this,null),Nn.set(this,"show-hidden"),it.set(this,null),bt.set(this,!0),vn.set(this,{}),Pe.set(this,!0),jn.set(this,[]),Re.set(this,void 0),Xe.set(this,{}),$e.set(this,!1),Me.set(this,null),Ln.set(this,!0),wt.set(this,void 0),me.set(this,""),K.set(this,void 0),Wn.set(this,void 0),Un.set(this,{}),Oe.set(this,null),Ft.set(this,null),Jt.set(this,{}),Ct.set(this,{}),at.set(this,void 0),Kn.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),Jn.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,Wn,n,"f"),j(this,Re,new er(this),"f"),this.$0=this[Oi](),this[fr](),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,Nn,"f"),j(this,wt,this[Si](),"f"),g(this,H,"f").y18n.setLocale(Ml)}addHelpOpt(e,t){if(v("[string|boolean] [string]",[e,t],arguments.length),g(this,Me,"f"))this[sr](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,Nn,"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[ir](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[ir](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=on(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,Wn,"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)Qs(e,g(this,H,"f")),g(this,K,"f").defaultDescription[e]=n;if(typeof t==="function"){if(Qs(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[ur](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[cn](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[rr](),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[Ai](['"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,
|
|
80
|
-
`,"f");
|
|
81
|
-
`,"f");j(this,me,g(this,me,"f")+e.join(" "),"f")}}}[sr](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]}[Ai](e,t,n){if(!g(this,vn,"f")[n])g(this,H,"f").process.emitWarning(e,t),g(this,vn,"f")[n]=!0}[$i](){g(this,jn,"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()}[Oi](){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[Ki](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,Un,"f")}[Ii](){return g(this,Jn,"f")}[rr](){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(/[.:].*/,""))}[Ti](){return this[or]().version||"unknown"}[Pi](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}[or](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[cr](n),g(this,K,"f")[e].push(n)})}[zt](e,t,n,r){this[ar](e,t,n,r,(s,o,i)=>{g(this,K,"f")[s][o]=i})}[ir](e,t,n,r){this[ar](e,t,n,r,(s,o,i)=>{g(this,K,"f")[s][o]=(g(this,K,"f")[s][o]||[]).concat(i)})}[ar](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[cr](n),r)}[cr](e){if(e==="__proto__")return"___proto___";return e}[ur](e,t){return this[zt](this[ur].bind(this),"key",e,t),this}[lr](){var e,t,n,r,s,o,i,a,c,u,f,l;let d=g(this,jn,"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()}[Ri](e,t){return Dt(t,(n)=>(e(n),n))}getInternalMethods(){return{getCommandInstance:this[Mi].bind(this),getContext:this[Bi].bind(this),getHasOutput:this[Ni].bind(this),getLoggerInstance:this[vi].bind(this),getParseContext:this[ji].bind(this),getParserConfiguration:this[kt].bind(this),getUsageConfiguration:this[Ii].bind(this),getUsageInstance:this[Li].bind(this),getValidationInstance:this[Wi].bind(this),hasParseCallback:this[zn].bind(this),isGlobalContext:this[Ui].bind(this),postProcess:this[St].bind(this),reset:this[fr].bind(this),runValidation:this[dr].bind(this),runYargsParserAndExecuteCommands:this[cn].bind(this),setHasOutput:this[Ji].bind(this)}}[Mi](){return g(this,fe,"f")}[Bi](){return g(this,an,"f")}[Ni](){return g(this,$e,"f")}[vi](){return g(this,wt,"f")}[ji](){return g(this,Ft,"f")||{}}[Li](){return g(this,Y,"f")}[Wi](){return g(this,ce,"f")}[zn](){return!!g(this,Oe,"f")}[Ui](){return g(this,Ln,"f")}[St](e,t,n,r){if(n)return e;if(re(e))return e;if(!t)e=this[ki](e);if(this[kt]()["parse-positional-numbers"]||this[kt]()["parse-positional-numbers"]===void 0)e=this[Pi](e);if(r)e=mt(e,this,g(this,Re,"f").getMiddleware(),!1);return e}[fr](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):xi(this,g(this,Y,"f"),g(this,H,"f")),"f"),j(this,fe,g(this,fe,"f")?g(this,fe,"f").reset():pi(g(this,Y,"f"),g(this,ce,"f"),g(this,Re,"f"),g(this,H,"f")),"f"),!g(this,xe,"f"))j(this,xe,Fi(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}[Ki](e,t){return g(this,H,"f").path.relative(e,t)}[cn](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[rr](),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,Ln,!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,Kn,"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[dr](h,{},d.error);if(!n)m=mt(p,this,g(this,Re,"f").getMiddleware(),!0);if(m=this[Ri](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)}[dr](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 gi(e){return!!e&&typeof e.getInternalMethods==="function"}var Bl=zi(Zs),qi=Bl;function Nl(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 Hn(e,t=!1,n=console.error){let r=Nl(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 qn,readFileSync as gr,writeFileSync as hr,mkdirSync as Gi}from"node:fs";import{homedir as vl}from"node:os";import{join as $t,dirname as mr}from"node:path";function Dr(){return process.env.HOME||vl()}function Vi(){return $t(Dr(),".config","slack-cli","profiles.json")}function Yn(){return $t(process.cwd(),".slack-cli","workspace")}function Xn(){return $t(Dr(),".slack-cli","workspace")}function un(){let e=Vi();if(!qn(e))return{profiles:{}};return JSON.parse(gr(e,"utf8"))}function jl(e){let t=Vi();Gi(mr(t),{recursive:!0}),hr(t,JSON.stringify(e,null,2)+`
|
|
82
|
-
|
|
83
|
-
`);
|
|
84
|
-
`)}function
|
|
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
|
|
86
|
-
`+" Migrate to SLACK_TOKEN=... or remove from your shell config.")}}let o=
|
|
76
|
+
`)}`:"";t.fail(s("Missing required argument: %s","Missing required arguments: %s",Object.keys(h).length,Object.keys(h).join(", ")+p))}},o.unknownArguments=function(l,f,h,m,p=!0){var y;let F=e.getInternalMethods().getCommandInstance().getCommands(),C=[],T=e.getInternalMethods().getContext();if(Object.keys(l).forEach((S)=>{if(!Yi.includes(S)&&!Object.prototype.hasOwnProperty.call(h,S)&&!Object.prototype.hasOwnProperty.call(e.getInternalMethods().getParseContext(),S)&&!o.isValidAndSomeAliasIsNotNew(S,f))C.push(S)}),p&&(T.commands.length>0||F.length>0||m))l._.slice(T.commands.length).forEach((S)=>{if(!F.includes(""+S))C.push(""+S)});if(p){let v=((y=e.getDemandedCommands()._)===null||y===void 0?void 0:y.max)||0,K=T.commands.length+v;if(K<l._.length)l._.slice(K).forEach((P)=>{if(P=String(P),!T.commands.includes(P)&&!C.includes(P))C.push(P)})}if(C.length)t.fail(s("Unknown argument: %s","Unknown arguments: %s",C.length,C.map((S)=>S.trim()?S:`"${S}"`).join(", ")))},o.unknownCommands=function(l){let f=e.getInternalMethods().getCommandInstance().getCommands(),h=[],m=e.getInternalMethods().getContext();if(m.commands.length>0||f.length>0)l._.slice(m.commands.length).forEach((p)=>{if(!f.includes(""+p))h.push(""+p)});if(h.length>0)return t.fail(s("Unknown command: %s","Unknown commands: %s",h.length,h.join(", "))),!0;else return!1},o.isValidAndSomeAliasIsNotNew=function(l,f){if(!Object.prototype.hasOwnProperty.call(f,l))return!1;let h=e.parsed.newAliases;return[l,...f[l]].some((m)=>!Object.prototype.hasOwnProperty.call(h,m)||!h[l])},o.limitedChoices=function(l){let f=e.getOptions(),h={};if(!Object.keys(f.choices).length)return;Object.keys(l).forEach((y)=>{if(Yi.indexOf(y)===-1&&Object.prototype.hasOwnProperty.call(f.choices,y))[].concat(l[y]).forEach((F)=>{if(f.choices[y].indexOf(F)===-1&&F!==void 0)h[y]=(h[y]||[]).concat(F)})});let m=Object.keys(h);if(!m.length)return;let p=r("Invalid values:");m.forEach((y)=>{p+=`
|
|
77
|
+
${r("Argument: %s, Given: %s, Choices: %s",y,t.stringifiedValues(h[y]),t.stringifiedValues(f.choices[y]))}`}),t.fail(p)};let i={};o.implies=function(l,f){if(B("<string|object> [array|number|string]",[l,f],arguments.length),typeof l==="object")Object.keys(l).forEach((h)=>{o.implies(h,l[h])});else{if(e.global(l),!i[l])i[l]=[];if(Array.isArray(f))f.forEach((h)=>o.implies(l,h));else Ee(f,void 0,n),i[l].push(f)}},o.getImplied=function(){return i};function a(d,l){let f=Number(l);if(l=isNaN(f)?l:f,typeof l==="number")l=d._.length>=l;else if(l.match(/^--no-.+/))l=l.match(/^--no-(.+)/)[1],l=!Object.prototype.hasOwnProperty.call(d,l);else l=Object.prototype.hasOwnProperty.call(d,l);return l}o.implications=function(l){let f=[];if(Object.keys(i).forEach((h)=>{let m=h;(i[h]||[]).forEach((p)=>{let y=m,F=p;if(y=a(l,y),p=a(l,p),y&&!p)f.push(` ${m} -> ${F}`)})}),f.length){let h=`${r("Implications failed:")}
|
|
78
|
+
`;f.forEach((m)=>{h+=m}),t.fail(h)}};let c={};o.conflicts=function(l,f){if(B("<string|object> [array|string]",[l,f],arguments.length),typeof l==="object")Object.keys(l).forEach((h)=>{o.conflicts(h,l[h])});else{if(e.global(l),!c[l])c[l]=[];if(Array.isArray(f))f.forEach((h)=>o.conflicts(l,h));else c[l].push(f)}},o.getConflicting=()=>c,o.conflicting=function(l){if(Object.keys(l).forEach((f)=>{if(c[f])c[f].forEach((h)=>{if(h&&l[f]!==void 0&&l[h]!==void 0)t.fail(r("Arguments %s and %s are mutually exclusive",f,h))})}),e.getInternalMethods().getParserConfiguration()["strip-dashed"])Object.keys(c).forEach((f)=>{c[f].forEach((h)=>{if(h&&l[n.Parser.camelCase(f)]!==void 0&&l[n.Parser.camelCase(h)]!==void 0)t.fail(r("Arguments %s and %s are mutually exclusive",f,h))})})},o.recommendCommands=function(l,f){f=f.sort((y,F)=>F.length-y.length);let m=null,p=1/0;for(let y=0,F;(F=f[y])!==void 0;y++){let C=Gi(l,F);if(C<=3&&C<p)p=C,m=F}if(m)t.fail(r("Did you mean %s?",m))},o.reset=function(l){return i=at(i,(f)=>!l[f]),c=at(c,(f)=>!l[f]),o};let u=[];return o.freeze=function(){u.push({implied:i,conflicting:c})},o.unfreeze=function(){let l=u.pop();Ee(l,void 0,n),{implied:i,conflicting:c}=l},o}var pr=[],cn;function un(e,t,n,r){cn=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=Cf(t,e.extends);bf(i),pr.push(i),s=o?JSON.parse(cn.readFileSync(i,"utf8")):r.require(e.extends),delete e.extends,s=un(s,cn.path.dirname(i),n,cn)}return pr=[],n?Zi(s,e):Object.assign({},s,e)}function bf(e){if(pr.indexOf(e)>-1)throw new fe(`Circular extended configurations: '${e}'.`)}function Cf(e,t){return cn.path.resolve(e,t)}function Zi(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]=Zi(e[s],t[s]);else n[s]=t[s];return n}var L=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)},de,Ft,ln,Fe,_e,qn,ut,xt,Xn,Re,Gn,Me,Ve,Se,Ne,Yn,kt,me,U,Vn,Zn,Ae,_t,Ht,St,lt,Qn,q,At,$t,Tt,G,es,Ze,ce;function ya(e){return(t=[],n=e.process.cwd(),r)=>{let s=new wa(t,n,r,e);return Object.defineProperty(s,"argv",{get:()=>s.parse(),enumerable:!0}),s.help(),s.version(),s}}var Qi=Symbol("copyDoubleDash"),ea=Symbol("copyDoubleDash"),hr=Symbol("deleteFromParserHintObject"),ta=Symbol("emitWarning"),na=Symbol("freeze"),sa=Symbol("getDollarZero"),It=Symbol("getParserConfiguration"),ra=Symbol("getUsageConfiguration"),gr=Symbol("guessLocale"),oa=Symbol("guessVersion"),ia=Symbol("parsePositionalNumbers"),mr=Symbol("pkgUp"),ft=Symbol("populateParserHintArray"),qt=Symbol("populateParserHintSingleValueDictionary"),Dr=Symbol("populateParserHintArrayDictionary"),yr=Symbol("populateParserHintDictionary"),wr=Symbol("sanitizeKey"),br=Symbol("setKey"),Cr=Symbol("unfreeze"),aa=Symbol("validateAsync"),ca=Symbol("getCommandInstance"),ua=Symbol("getContext"),la=Symbol("getHasOutput"),fa=Symbol("getLoggerInstance"),da=Symbol("getParseContext"),pa=Symbol("getUsageInstance"),ha=Symbol("getValidationInstance"),ts=Symbol("hasParseCallback"),ga=Symbol("isGlobalContext"),Ot=Symbol("postProcess"),ma=Symbol("rebase"),Er=Symbol("reset"),fn=Symbol("runYargsParserAndExecuteCommands"),Fr=Symbol("runValidation"),Da=Symbol("setHasOutput"),Pt=Symbol("kTrackManuallySetKeys"),Ef="en_US";class wa{constructor(e=[],t,n,r){this.customScriptName=!1,this.parsed=!1,de.set(this,void 0),Ft.set(this,void 0),ln.set(this,{commands:[],fullCommands:[]}),Fe.set(this,null),_e.set(this,null),qn.set(this,"show-hidden"),ut.set(this,null),xt.set(this,!0),Xn.set(this,{}),Re.set(this,!0),Gn.set(this,[]),Me.set(this,void 0),Ve.set(this,{}),Se.set(this,!1),Ne.set(this,null),Yn.set(this,!0),kt.set(this,void 0),me.set(this,""),U.set(this,void 0),Vn.set(this,void 0),Zn.set(this,{}),Ae.set(this,null),_t.set(this,null),Ht.set(this,{}),St.set(this,{}),lt.set(this,void 0),Qn.set(this,!1),q.set(this,void 0),At.set(this,!1),$t.set(this,!1),Tt.set(this,!1),G.set(this,void 0),es.set(this,{}),Ze.set(this,null),ce.set(this,void 0),L(this,q,r,"f"),L(this,lt,e,"f"),L(this,Ft,t,"f"),L(this,Vn,n,"f"),L(this,Me,new fr(this),"f"),this.$0=this[sa](),this[Er](),L(this,de,g(this,de,"f"),"f"),L(this,G,g(this,G,"f"),"f"),L(this,ce,g(this,ce,"f"),"f"),L(this,U,g(this,U,"f"),"f"),g(this,U,"f").showHiddenOpt=g(this,qn,"f"),L(this,kt,this[ea](),"f"),g(this,q,"f").y18n.setLocale(Ef)}addHelpOpt(e,t){if(B("[string|boolean] [string]",[e,t],arguments.length),g(this,Ne,"f"))this[hr](g(this,Ne,"f")),L(this,Ne,null,"f");if(e===!1&&t===void 0)return this;return L(this,Ne,typeof e==="string"?e:"help","f"),this.boolean(g(this,Ne,"f")),this.describe(g(this,Ne,"f"),t||g(this,G,"f").deferY18nLookup("Show help")),this}help(e,t){return this.addHelpOpt(e,t)}addShowHiddenOpt(e,t){if(B("[string|boolean] [string]",[e,t],arguments.length),e===!1&&t===void 0)return this;let n=typeof e==="string"?e:g(this,qn,"f");return this.boolean(n),this.describe(n,t||g(this,G,"f").deferY18nLookup("Show hidden options")),g(this,U,"f").showHiddenOpt=n,this}showHidden(e,t){return this.addShowHiddenOpt(e,t)}alias(e,t){return B("<object|string|array> [string|array]",[e,t],arguments.length),this[Dr](this.alias.bind(this),"alias",e,t),this}array(e){return B("<array|string>",[e],arguments.length),this[ft]("array",e),this[Pt](e),this}boolean(e){return B("<array|string>",[e],arguments.length),this[ft]("boolean",e),this[Pt](e),this}check(e,t){return B("<function> [boolean]",[e,t],arguments.length),this.middleware((n,r)=>Et(()=>e(n,r.getOptions()),(s)=>{if(!s)g(this,G,"f").fail(g(this,q,"f").y18n.__("Argument check failed: %s",e.toString()));else if(typeof s==="string"||s instanceof Error)g(this,G,"f").fail(s.toString(),s);return n},(s)=>(g(this,G,"f").fail(s.message?s.message:s.toString(),s),n)),!1,t),this}choices(e,t){return B("<object|string|array> [string|array]",[e,t],arguments.length),this[Dr](this.choices.bind(this),"choices",e,t),this}coerce(e,t){if(B("<object|string|array> [function]",[e,t],arguments.length),Array.isArray(e)){if(!t)throw new fe("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 fe("coerce callback must be provided");let n=e;return g(this,U,"f").key[n]=!0,g(this,Me,"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 Et(()=>t(r[a[0]]),(c)=>(a.forEach((u)=>{r[u]=c}),r),(c)=>{throw new fe(c.message)})},n),this}conflicts(e,t){return B("<string|object> [string|array]",[e,t],arguments.length),g(this,ce,"f").conflicts(e,t),this}config(e="config",t,n){if(B("[object|string] [string|function] [function]",[e,t,n],arguments.length),typeof e==="object"&&!Array.isArray(e))return e=un(e,g(this,Ft,"f"),this[It]()["deep-merge-config"]||!1,g(this,q,"f")),g(this,U,"f").configObjects=(g(this,U,"f").configObjects||[]).concat(e),this;if(typeof t==="function")n=t,t=void 0;return this.describe(e,t||g(this,G,"f").deferY18nLookup("Path to JSON config file")),(Array.isArray(e)?e:[e]).forEach((r)=>{g(this,U,"f").config[r]=n||!0}),this}completion(e,t,n){if(B("[string] [string|boolean|function] [function]",[e,t,n],arguments.length),typeof t==="function")n=t,t=void 0;if(L(this,_e,e||g(this,_e,"f")||"completion","f"),!t&&t!==!1)t="generate completion script";if(this.command(g(this,_e,"f"),t),n)g(this,Fe,"f").registerFunction(n);return this}command(e,t,n,r,s,o){return B("<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]",[e,t,n,r,s,o],arguments.length),g(this,de,"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){B("<string> [object]",[e,t],arguments.length);let n=g(this,Vn,"f")||g(this,q,"f").require;return g(this,de,"f").addDirectory(e,n,g(this,q,"f").getCallerFile(),t),this}count(e){return B("<array|string>",[e],arguments.length),this[ft]("count",e),this[Pt](e),this}default(e,t,n){if(B("<object|string|array> [*] [string]",[e,t,n],arguments.length),n)lr(e,g(this,q,"f")),g(this,U,"f").defaultDescription[e]=n;if(typeof t==="function"){if(lr(e,g(this,q,"f")),!g(this,U,"f").defaultDescription[e])g(this,U,"f").defaultDescription[e]=g(this,G,"f").functionDescription(t);t=t.call()}return this[qt](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(B("[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,U,"f").demandedCommands._={min:e,max:t,minMsg:n,maxMsg:r},this}demand(e,t,n){if(Array.isArray(t))t.forEach((r)=>{Ee(n,!0,g(this,q,"f")),this.demandOption(r,n)}),t=1/0;else if(typeof t!=="number")n=t,t=1/0;if(typeof e==="number")Ee(n,!0,g(this,q,"f")),this.demandCommand(e,t,n,n);else if(Array.isArray(e))e.forEach((r)=>{Ee(n,!0,g(this,q,"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 B("<object|string|array> [string]",[e,t],arguments.length),this[qt](this.demandOption.bind(this),"demandedOptions",e,t),this}deprecateOption(e,t){return B("<string> [string|boolean]",[e,t],arguments.length),g(this,U,"f").deprecatedOptions[e]=t,this}describe(e,t){return B("<object|string|array> [string]",[e,t],arguments.length),this[br](e,!0),g(this,G,"f").describe(e,t),this}detectLocale(e){return B("<boolean>",[e],arguments.length),L(this,xt,e,"f"),this}env(e){if(B("[string|boolean]",[e],arguments.length),e===!1)delete g(this,U,"f").envPrefix;else g(this,U,"f").envPrefix=e||"";return this}epilogue(e){return B("<string>",[e],arguments.length),g(this,G,"f").epilog(e),this}epilog(e){return this.epilogue(e)}example(e,t){if(B("<string|array> [string]",[e,t],arguments.length),Array.isArray(e))e.forEach((n)=>this.example(...n));else g(this,G,"f").example(e,t);return this}exit(e,t){if(L(this,Se,!0,"f"),L(this,ut,t,"f"),g(this,Re,"f"))g(this,q,"f").process.exit(e)}exitProcess(e=!0){return B("[boolean]",[e],arguments.length),L(this,Re,e,"f"),this}fail(e){if(B("<function|boolean>",[e],arguments.length),typeof e==="boolean"&&e!==!1)throw new fe("Invalid first argument. Expected function or boolean 'false'");return g(this,G,"f").failFn(e),this}getAliases(){return this.parsed?this.parsed.aliases:{}}async getCompletion(e,t){if(B("<array> [function]",[e,t],arguments.length),!t)return new Promise((n,r)=>{g(this,Fe,"f").getCompletion(e,(s,o)=>{if(s)r(s);else n(o)})});else return g(this,Fe,"f").getCompletion(e,t)}getDemandedOptions(){return B([],0),g(this,U,"f").demandedOptions}getDemandedCommands(){return B([],0),g(this,U,"f").demandedCommands}getDeprecatedOptions(){return B([],0),g(this,U,"f").deprecatedOptions}getDetectLocale(){return g(this,xt,"f")}getExitProcess(){return g(this,Re,"f")}getGroups(){return Object.assign({},g(this,Ve,"f"),g(this,St,"f"))}getHelp(){if(L(this,Se,!0,"f"),!g(this,G,"f").hasCachedHelpMessage()){if(!this.parsed){let t=this[fn](g(this,lt,"f"),void 0,void 0,0,!0);if(oe(t))return t.then(()=>g(this,G,"f").help())}let e=g(this,de,"f").runDefaultBuilderOn(this);if(oe(e))return e.then(()=>g(this,G,"f").help())}return Promise.resolve(g(this,G,"f").help())}getOptions(){return g(this,U,"f")}getStrict(){return g(this,At,"f")}getStrictCommands(){return g(this,$t,"f")}getStrictOptions(){return g(this,Tt,"f")}global(e,t){if(B("<string|array> [boolean]",[e,t],arguments.length),e=[].concat(e),t!==!1)g(this,U,"f").local=g(this,U,"f").local.filter((n)=>e.indexOf(n)===-1);else e.forEach((n)=>{if(!g(this,U,"f").local.includes(n))g(this,U,"f").local.push(n)});return this}group(e,t){B("<string|array> <string>",[e,t],arguments.length);let n=g(this,St,"f")[t]||g(this,Ve,"f")[t];if(g(this,St,"f")[t])delete g(this,St,"f")[t];let r={};return g(this,Ve,"f")[t]=(n||[]).concat(e).filter((s)=>{if(r[s])return!1;return r[s]=!0}),this}hide(e){return B("<string>",[e],arguments.length),g(this,U,"f").hiddenOptions.push(e),this}implies(e,t){return B("<string|object> [number|string|array]",[e,t],arguments.length),g(this,ce,"f").implies(e,t),this}locale(e){if(B("[string]",[e],arguments.length),e===void 0)return this[gr](),g(this,q,"f").y18n.getLocale();return L(this,xt,!1,"f"),g(this,q,"f").y18n.setLocale(e),this}middleware(e,t,n){return g(this,Me,"f").addMiddleware(e,!!t,n)}nargs(e,t){return B("<string|object|array> [number]",[e,t],arguments.length),this[qt](this.nargs.bind(this),"narg",e,t),this}normalize(e){return B("<array|string>",[e],arguments.length),this[ft]("normalize",e),this}number(e){return B("<array|string>",[e],arguments.length),this[ft]("number",e),this[Pt](e),this}option(e,t){if(B("<string|object> [object]",[e,t],arguments.length),typeof e==="object")Object.keys(e).forEach((n)=>{this.options(n,e[n])});else{if(typeof t!=="object")t={};if(this[Pt](e),g(this,Ze,"f")&&(e==="version"||(t===null||t===void 0?void 0:t.alias)==="version"))this[ta](['"version" is a reserved word.',"Please do one of the following:",'- Disable version with `yargs.version(false)` if using "version" as an option',"- Use the built-in `yargs.version` method instead (if applicable)","- Use a different option key","https://yargs.js.org/docs/#api-reference-version"].join(`
|
|
79
|
+
`),void 0,"versionWarning");if(g(this,U,"f").key[e]=!0,t.alias)this.alias(e,t.alias);let n=t.deprecate||t.deprecated;if(n)this.deprecateOption(e,n);let 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,U,"f").defaultDescription[e]=t.defaultDescription;if(t.skipValidation)this.skipValidation(e);let s=t.describe||t.description||t.desc,o=g(this,G,"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(B("[string|array] [function|boolean|object] [function]",[e,t,n],arguments.length),this[na](),typeof e>"u")e=g(this,lt,"f");if(typeof t==="object")L(this,_t,t,"f"),t=n;if(typeof t==="function")L(this,Ae,t,"f"),t=!1;if(!t)L(this,lt,e,"f");if(g(this,Ae,"f"))L(this,Re,!1,"f");let r=this[fn](e,!!t),s=this.parsed;if(g(this,Fe,"f").setParsed(this.parsed),oe(r))return r.then((o)=>{if(g(this,Ae,"f"))g(this,Ae,"f").call(this,g(this,ut,"f"),o,g(this,me,"f"));return o}).catch((o)=>{if(g(this,Ae,"f"))g(this,Ae,"f")(o,this.parsed.argv,g(this,me,"f"));throw o}).finally(()=>{this[Cr](),this.parsed=s});else{if(g(this,Ae,"f"))g(this,Ae,"f").call(this,g(this,ut,"f"),r,g(this,me,"f"));this[Cr](),this.parsed=s}return r}parseAsync(e,t,n){let r=this.parse(e,t,n);return!oe(r)?Promise.resolve(r):r}parseSync(e,t,n){let r=this.parse(e,t,n);if(oe(r))throw new fe(".parseSync() must not be used with asynchronous builders, handlers, or middleware");return r}parserConfiguration(e){return B("<object>",[e],arguments.length),L(this,Zn,e,"f"),this}pkgConf(e,t){B("<string> [string]",[e,t],arguments.length);let n=null,r=this[mr](t||g(this,Ft,"f"));if(r[e]&&typeof r[e]==="object")n=un(r[e],t||g(this,Ft,"f"),this[It]()["deep-merge-config"]||!1,g(this,q,"f")),g(this,U,"f").configObjects=(g(this,U,"f").configObjects||[]).concat(n);return this}positional(e,t){B("<string> <object>",[e,t],arguments.length);let n=["default","defaultDescription","implies","normalize","choices","conflicts","coerce","type","describe","desc","description","alias"];t=at(t,(o,i)=>{if(o==="type"&&!["string","number","boolean"].includes(i))return!1;return n.includes(o)});let r=g(this,ln,"f").fullCommands[g(this,ln,"f").fullCommands.length-1],s=r?g(this,de,"f").cmdToParseOptions(r):{array:[],alias:{},default:{},demand:{}};return Jt(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,G,"f").getPositionalGroupName()),this.option(e,t)}recommendCommands(e=!0){return B("[boolean]",[e],arguments.length),L(this,Qn,e,"f"),this}required(e,t,n){return this.demand(e,t,n)}require(e,t,n){return this.demand(e,t,n)}requiresArg(e){if(B("<array|string|object> [number]",[e],arguments.length),typeof e==="string"&&g(this,U,"f").narg[e])return this;else this[qt](this.requiresArg.bind(this),"narg",e,NaN);return this}showCompletionScript(e,t){return B("[string] [string]",[e,t],arguments.length),e=e||this.$0,g(this,kt,"f").log(g(this,Fe,"f").generateCompletionScript(e,t||g(this,_e,"f")||"completion")),this}showHelp(e){if(B("[string|function]",[e],arguments.length),L(this,Se,!0,"f"),!g(this,G,"f").hasCachedHelpMessage()){if(!this.parsed){let n=this[fn](g(this,lt,"f"),void 0,void 0,0,!0);if(oe(n))return n.then(()=>{g(this,G,"f").showHelp(e)}),this}let t=g(this,de,"f").runDefaultBuilderOn(this);if(oe(t))return t.then(()=>{g(this,G,"f").showHelp(e)}),this}return g(this,G,"f").showHelp(e),this}scriptName(e){return this.customScriptName=!0,this.$0=e,this}showHelpOnFail(e,t){return B("[boolean|string] [string]",[e,t],arguments.length),g(this,G,"f").showHelpOnFail(e,t),this}showVersion(e){return B("[string|function]",[e],arguments.length),g(this,G,"f").showVersion(e),this}skipValidation(e){return B("<array|string>",[e],arguments.length),this[ft]("skipValidation",e),this}strict(e){return B("[boolean]",[e],arguments.length),L(this,At,e!==!1,"f"),this}strictCommands(e){return B("[boolean]",[e],arguments.length),L(this,$t,e!==!1,"f"),this}strictOptions(e){return B("[boolean]",[e],arguments.length),L(this,Tt,e!==!1,"f"),this}string(e){return B("<array|string>",[e],arguments.length),this[ft]("string",e),this[Pt](e),this}terminalWidth(){return B([],0),g(this,q,"f").process.stdColumns}updateLocale(e){return this.updateStrings(e)}updateStrings(e){return B("<object>",[e],arguments.length),L(this,xt,!1,"f"),g(this,q,"f").y18n.updateLocale(e),this}usage(e,t,n,r){if(B("<string|null|undefined> [string|boolean] [function|object] [function]",[e,t,n,r],arguments.length),t!==void 0)if(Ee(e,null,g(this,q,"f")),(e||"").match(/^\$0( |$)/))return this.command(e,t,n,r);else throw new fe(".usage() description must start with $0 if being used as alias for .command()");else return g(this,G,"f").usage(e),this}usageConfiguration(e){return B("<object>",[e],arguments.length),L(this,es,e,"f"),this}version(e,t,n){if(B("[boolean|string] [string] [string]",[e,t,n],arguments.length),g(this,Ze,"f"))this[hr](g(this,Ze,"f")),g(this,G,"f").version(void 0),L(this,Ze,null,"f");if(arguments.length===0)n=this[oa](),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 L(this,Ze,typeof e==="string"?e:"version","f"),t=t||g(this,G,"f").deferY18nLookup("Show version number"),g(this,G,"f").version(n||void 0),this.boolean(g(this,Ze,"f")),this.describe(g(this,Ze,"f"),t),this}wrap(e){return B("<number|null|undefined>",[e],arguments.length),g(this,G,"f").wrap(e),this}[(de=new WeakMap,Ft=new WeakMap,ln=new WeakMap,Fe=new WeakMap,_e=new WeakMap,qn=new WeakMap,ut=new WeakMap,xt=new WeakMap,Xn=new WeakMap,Re=new WeakMap,Gn=new WeakMap,Me=new WeakMap,Ve=new WeakMap,Se=new WeakMap,Ne=new WeakMap,Yn=new WeakMap,kt=new WeakMap,me=new WeakMap,U=new WeakMap,Vn=new WeakMap,Zn=new WeakMap,Ae=new WeakMap,_t=new WeakMap,Ht=new WeakMap,St=new WeakMap,lt=new WeakMap,Qn=new WeakMap,q=new WeakMap,At=new WeakMap,$t=new WeakMap,Tt=new WeakMap,G=new WeakMap,es=new WeakMap,Ze=new WeakMap,ce=new WeakMap,Qi)](e){if(!e._||!e["--"])return e;e._.push.apply(e._,e["--"]);try{delete e["--"]}catch(t){}return e}[ea](){return{log:(...e)=>{if(!this[ts]())console.log(...e);if(L(this,Se,!0,"f"),g(this,me,"f").length)L(this,me,g(this,me,"f")+`
|
|
80
|
+
`,"f");L(this,me,g(this,me,"f")+e.join(" "),"f")},error:(...e)=>{if(!this[ts]())console.error(...e);if(L(this,Se,!0,"f"),g(this,me,"f").length)L(this,me,g(this,me,"f")+`
|
|
81
|
+
`,"f");L(this,me,g(this,me,"f")+e.join(" "),"f")}}}[hr](e){Jt(g(this,U,"f")).forEach((t)=>{if(((r)=>r==="configObjects")(t))return;let n=g(this,U,"f")[t];if(Array.isArray(n)){if(n.includes(e))n.splice(n.indexOf(e),1)}else if(typeof n==="object")delete n[e]}),delete g(this,G,"f").getDescriptions()[e]}[ta](e,t,n){if(!g(this,Xn,"f")[n])g(this,q,"f").process.emitWarning(e,t),g(this,Xn,"f")[n]=!0}[na](){g(this,Gn,"f").push({options:g(this,U,"f"),configObjects:g(this,U,"f").configObjects.slice(0),exitProcess:g(this,Re,"f"),groups:g(this,Ve,"f"),strict:g(this,At,"f"),strictCommands:g(this,$t,"f"),strictOptions:g(this,Tt,"f"),completionCommand:g(this,_e,"f"),output:g(this,me,"f"),exitError:g(this,ut,"f"),hasOutput:g(this,Se,"f"),parsed:this.parsed,parseFn:g(this,Ae,"f"),parseContext:g(this,_t,"f")}),g(this,G,"f").freeze(),g(this,ce,"f").freeze(),g(this,de,"f").freeze(),g(this,Me,"f").freeze()}[sa](){let e="",t;if(/\b(node|iojs|electron)(\.exe)?$/.test(g(this,q,"f").process.argv()[0]))t=g(this,q,"f").process.argv().slice(1,2);else t=g(this,q,"f").process.argv().slice(0,1);if(e=t.map((n)=>{let r=this[ma](g(this,Ft,"f"),n);return n.match(/^(\/|([a-zA-Z]:)?\\)/)&&r.length<n.length?r:n}).join(" ").trim(),g(this,q,"f").getEnv("_")&&g(this,q,"f").getProcessArgvBin()===g(this,q,"f").getEnv("_"))e=g(this,q,"f").getEnv("_").replace(`${g(this,q,"f").path.dirname(g(this,q,"f").process.execPath())}/`,"");return e}[It](){return g(this,Zn,"f")}[ra](){return g(this,es,"f")}[gr](){if(!g(this,xt,"f"))return;let e=g(this,q,"f").getEnv("LC_ALL")||g(this,q,"f").getEnv("LC_MESSAGES")||g(this,q,"f").getEnv("LANG")||g(this,q,"f").getEnv("LANGUAGE")||"en_US";this.locale(e.replace(/[.:].*/,""))}[oa](){return this[mr]().version||"unknown"}[ia](e){let t=e["--"]?e["--"]:e._;for(let n=0,r;(r=t[n])!==void 0;n++)if(g(this,q,"f").Parser.looksLikeNumber(r)&&Number.isSafeInteger(Math.floor(parseFloat(`${r}`))))t[n]=Number(r);return e}[mr](e){let t=e||"*";if(g(this,Ht,"f")[t])return g(this,Ht,"f")[t];let n={};try{let r=e||g(this,q,"f").mainFilename;if(g(this,q,"f").path.extname(r))r=g(this,q,"f").path.dirname(r);let s=g(this,q,"f").findUp(r,(o,i)=>{if(i.includes("package.json"))return"package.json";else return});Ee(s,void 0,g(this,q,"f")),n=JSON.parse(g(this,q,"f").readFileSync(s,"utf8"))}catch(r){}return g(this,Ht,"f")[t]=n||{},g(this,Ht,"f")[t]}[ft](e,t){t=[].concat(t),t.forEach((n)=>{n=this[wr](n),g(this,U,"f")[e].push(n)})}[qt](e,t,n,r){this[yr](e,t,n,r,(s,o,i)=>{g(this,U,"f")[s][o]=i})}[Dr](e,t,n,r){this[yr](e,t,n,r,(s,o,i)=>{g(this,U,"f")[s][o]=(g(this,U,"f")[s][o]||[]).concat(i)})}[yr](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 Jt(n))e(o,n[o]);else s(t,this[wr](n),r)}[wr](e){if(e==="__proto__")return"___proto___";return e}[br](e,t){return this[qt](this[br].bind(this),"key",e,t),this}[Cr](){var e,t,n,r,s,o,i,a,c,u,d,l;let f=g(this,Gn,"f").pop();Ee(f,void 0,g(this,q,"f"));let h;e=this,t=this,n=this,r=this,s=this,o=this,i=this,a=this,c=this,u=this,d=this,l=this,{options:{set value(m){L(e,U,m,"f")}}.value,configObjects:h,exitProcess:{set value(m){L(t,Re,m,"f")}}.value,groups:{set value(m){L(n,Ve,m,"f")}}.value,output:{set value(m){L(r,me,m,"f")}}.value,exitError:{set value(m){L(s,ut,m,"f")}}.value,hasOutput:{set value(m){L(o,Se,m,"f")}}.value,parsed:this.parsed,strict:{set value(m){L(i,At,m,"f")}}.value,strictCommands:{set value(m){L(a,$t,m,"f")}}.value,strictOptions:{set value(m){L(c,Tt,m,"f")}}.value,completionCommand:{set value(m){L(u,_e,m,"f")}}.value,parseFn:{set value(m){L(d,Ae,m,"f")}}.value,parseContext:{set value(m){L(l,_t,m,"f")}}.value}=f,g(this,U,"f").configObjects=h,g(this,G,"f").unfreeze(),g(this,ce,"f").unfreeze(),g(this,de,"f").unfreeze(),g(this,Me,"f").unfreeze()}[aa](e,t){return Et(t,(n)=>(e(n),n))}getInternalMethods(){return{getCommandInstance:this[ca].bind(this),getContext:this[ua].bind(this),getHasOutput:this[la].bind(this),getLoggerInstance:this[fa].bind(this),getParseContext:this[da].bind(this),getParserConfiguration:this[It].bind(this),getUsageConfiguration:this[ra].bind(this),getUsageInstance:this[pa].bind(this),getValidationInstance:this[ha].bind(this),hasParseCallback:this[ts].bind(this),isGlobalContext:this[ga].bind(this),postProcess:this[Ot].bind(this),reset:this[Er].bind(this),runValidation:this[Fr].bind(this),runYargsParserAndExecuteCommands:this[fn].bind(this),setHasOutput:this[Da].bind(this)}}[ca](){return g(this,de,"f")}[ua](){return g(this,ln,"f")}[la](){return g(this,Se,"f")}[fa](){return g(this,kt,"f")}[da](){return g(this,_t,"f")||{}}[pa](){return g(this,G,"f")}[ha](){return g(this,ce,"f")}[ts](){return!!g(this,Ae,"f")}[ga](){return g(this,Yn,"f")}[Ot](e,t,n,r){if(n)return e;if(oe(e))return e;if(!t)e=this[Qi](e);if(this[It]()["parse-positional-numbers"]||this[It]()["parse-positional-numbers"]===void 0)e=this[ia](e);if(r)e=Ct(e,this,g(this,Me,"f").getMiddleware(),!1);return e}[Er](e={}){L(this,U,g(this,U,"f")||{},"f");let t={};t.local=g(this,U,"f").local||[],t.configObjects=g(this,U,"f").configObjects||[];let n={};t.local.forEach((o)=>{n[o]=!0,(e[o]||[]).forEach((i)=>{n[i]=!0})}),Object.assign(g(this,St,"f"),Object.keys(g(this,Ve,"f")).reduce((o,i)=>{let a=g(this,Ve,"f")[i].filter((c)=>!(c in n));if(a.length>0)o[i]=a;return o},{})),L(this,Ve,{},"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,U,"f")[o]||[]).filter((i)=>!n[i])}),s.forEach((o)=>{t[o]=at(g(this,U,"f")[o],(i)=>!n[i])}),t.envPrefix=g(this,U,"f").envPrefix,L(this,U,t,"f"),L(this,G,g(this,G,"f")?g(this,G,"f").reset(n):Ji(this,g(this,q,"f")),"f"),L(this,ce,g(this,ce,"f")?g(this,ce,"f").reset(n):Vi(this,g(this,G,"f"),g(this,q,"f")),"f"),L(this,de,g(this,de,"f")?g(this,de,"f").reset():Wi(g(this,G,"f"),g(this,ce,"f"),g(this,Me,"f"),g(this,q,"f")),"f"),!g(this,Fe,"f"))L(this,Fe,Xi(this,g(this,G,"f"),g(this,de,"f"),g(this,q,"f")),"f");return g(this,Me,"f").reset(),L(this,_e,null,"f"),L(this,me,"","f"),L(this,ut,null,"f"),L(this,Se,!1,"f"),this.parsed=!1,this}[ma](e,t){return g(this,q,"f").path.relative(e,t)}[fn](e,t,n,r=0,s=!1){var o,i,a,c;let u=!!n||s;e=e||g(this,lt,"f"),g(this,U,"f").__=g(this,q,"f").y18n.__,g(this,U,"f").configuration=this[It]();let d=!!g(this,U,"f").configuration["populate--"],l=Object.assign({},g(this,U,"f").configuration,{"populate--":!0}),f=g(this,q,"f").Parser.detailed(e,Object.assign({},g(this,U,"f"),{configuration:{"parse-positional-numbers":!1,...l}})),h=Object.assign(f.argv,g(this,_t,"f")),m=void 0,p=f.aliases,y=!1,F=!1;if(Object.keys(h).forEach((C)=>{if(C===g(this,Ne,"f")&&h[C])y=!0;else if(C===g(this,Ze,"f")&&h[C])F=!0}),h.$0=this.$0,this.parsed=f,r===0)g(this,G,"f").clearCachedHelpMessage();try{if(this[gr](),t)return this[Ot](h,d,!!n,!1);if(g(this,Ne,"f")){if([g(this,Ne,"f")].concat(p[g(this,Ne,"f")]||[]).filter((K)=>K.length>1).includes(""+h._[h._.length-1]))h._.pop(),y=!0}L(this,Yn,!1,"f");let C=g(this,de,"f").getCommands(),T=((o=g(this,Fe,"f"))===null||o===void 0?void 0:o.completionKey)?[(i=g(this,Fe,"f"))===null||i===void 0?void 0:i.completionKey,...(c=this.getAliases()[(a=g(this,Fe,"f"))===null||a===void 0?void 0:a.completionKey])!==null&&c!==void 0?c:[]].some((v)=>Object.prototype.hasOwnProperty.call(h,v)):!1,S=y||T||s;if(h._.length){if(C.length){let v;for(let K=r||0,P;h._[K]!==void 0;K++)if(P=String(h._[K]),C.includes(P)&&P!==g(this,_e,"f")){let z=g(this,de,"f").runCommand(P,this,f,K+1,s,y||F||s);return this[Ot](z,d,!!n,!1)}else if(!v&&P!==g(this,_e,"f")){v=P;break}if(!g(this,de,"f").hasDefaultCommand()&&g(this,Qn,"f")&&v&&!S)g(this,ce,"f").recommendCommands(v,C)}if(g(this,_e,"f")&&h._.includes(g(this,_e,"f"))&&!T){if(g(this,Re,"f"))ct(!0);this.showCompletionScript(),this.exit(0)}}if(g(this,de,"f").hasDefaultCommand()&&!S){let v=g(this,de,"f").runCommand(null,this,f,0,s,y||F||s);return this[Ot](v,d,!!n,!1)}if(T){if(g(this,Re,"f"))ct(!0);e=[].concat(e);let v=e.slice(e.indexOf(`--${g(this,Fe,"f").completionKey}`)+1);return g(this,Fe,"f").getCompletion(v,(K,P)=>{if(K)throw new fe(K.message);(P||[]).forEach((z)=>{g(this,kt,"f").log(z)}),this.exit(0)}),this[Ot](h,!d,!!n,!1)}if(!g(this,Se,"f")){if(y){if(g(this,Re,"f"))ct(!0);u=!0,this.showHelp((v)=>{g(this,kt,"f").log(v),this.exit(0)})}else if(F){if(g(this,Re,"f"))ct(!0);u=!0,g(this,G,"f").showVersion("log"),this.exit(0)}}if(!u&&g(this,U,"f").skipValidation.length>0)u=Object.keys(h).some((v)=>g(this,U,"f").skipValidation.indexOf(v)>=0&&h[v]===!0);if(!u){if(f.error)throw new fe(f.error.message);if(!T){let v=this[Fr](p,{},f.error);if(!n)m=Ct(h,this,g(this,Me,"f").getMiddleware(),!0);if(m=this[aa](v,m!==null&&m!==void 0?m:h),oe(m)&&!n)m=m.then(()=>Ct(h,this,g(this,Me,"f").getMiddleware(),!1))}}}catch(C){if(C instanceof fe)g(this,G,"f").fail(C.message,C);else throw C}return this[Ot](m!==null&&m!==void 0?m:h,d,!!n,!0)}[Fr](e,t,n,r){let s={...this.getDemandedOptions()};return(o)=>{if(n)throw new fe(n.message);g(this,ce,"f").nonOptionCount(o),g(this,ce,"f").requiredArguments(o,s);let i=!1;if(g(this,$t,"f"))i=g(this,ce,"f").unknownCommands(o);if(g(this,At,"f")&&!i)g(this,ce,"f").unknownArguments(o,e,t,!!r);else if(g(this,Tt,"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)}}[Da](){L(this,Se,!0,"f")}[Pt](e){if(typeof e==="string")g(this,U,"f").key[e]=!0;else for(let t of e)g(this,U,"f").key[t]=!0}}function Ui(e){return!!e&&typeof e.getInternalMethods==="function"}var Ff=ya(ur),ba=Ff;function xf(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 ns(e,t=!1,n=console.error){let r=xf(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 dn,readFileSync as _r,writeFileSync as xr,mkdirSync as xa,chmodSync as Ca}from"node:fs";import{homedir as kf}from"node:os";import{join as Rt,dirname as Sr}from"node:path";function Ar(){return process.env.HOME||kf()}function ka(){return Rt(Ar(),".config","slack-cli","profiles.json")}function ss(){return Rt(process.cwd(),".slack-cli","workspace")}function rs(){return Rt(Ar(),".slack-cli","workspace")}function pn(){let e=ka();if(!dn(e))return{profiles:{}};return JSON.parse(_r(e,"utf8"))}function _f(e){let t=ka();if(xa(Sr(t),{recursive:!0}),process.platform!=="win32"&&dn(t))Ca(t,384);if(xr(t,JSON.stringify(e,null,2)+`
|
|
82
|
+
`,{mode:384}),process.platform!=="win32")Ca(t,384)}function Xt(e){if(!dn(e))return;return _r(e,"utf8").trim()||void 0}function Ea(e,t){let n=Sr(e);xa(n,{recursive:!0});let r=Rt(n,".gitignore");if(!dn(r))xr(r,`*
|
|
83
|
+
`);xr(e,t+`
|
|
84
|
+
`)}function Sf(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 Fa(e){if(!dn(e))return{};try{return Sf(_r(e,"utf8"))}catch{return{}}}function kr(e,t){let n=Ar(),r=e;while(!0){for(let i of[Rt(r,".slack-term",".env.local"),Rt(r,".env.local")]){let a=Fa(i);for(let c of t)if(a[c])return a[c]}if(r===n)break;let o=Sr(r);if(o===r)break;r=o}let s=Fa(Rt(n,".slack-term",".env.local"));for(let o of t)if(s[o])return s[o];return}function $r(){let e=pn(),t=Xt(ss()),n=Xt(rs()),r=t??n;return Object.entries(e.profiles).map(([s,o])=>({name:s,profile:o,current:s===r}))}function _a(e){let t=pn();if(!(e in t.profiles))throw Error(`Profile not found: ${e}`);delete t.profiles[e],_f(t)}function Sa(e,t=!1){let n=pn();if(!(e in n.profiles))throw Error(`Profile not found: ${e}`);if(t)Ea(rs(),e);else Ea(ss(),e)}function hn(e){let n=pn().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=kr(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=kr(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=Xt(ss());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=Xt(rs());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
|
-
`+` slack auth login —
|
|
91
|
-
`+` slack auth
|
|
90
|
+
`+` slack auth login — interactive wizard (desktop session, token, or new app)
|
|
91
|
+
`+` slack auth token — print the active token, or save one with --token
|
|
92
|
+
`+` slack auth chrome — import the xoxd cookie from Chrome (macOS/Linux)
|
|
93
|
+
`+` slack auth firefox — import the xoxd cookie from Firefox (all platforms)
|
|
92
94
|
`+` slack auth app — guided Slack app creation
|
|
93
|
-
`+" Or set SLACK_TOKEN=xoxp-... in .slack-term/.env.local")}function
|
|
94
|
-
|
|
95
|
-
`)){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
|
|
96
|
-
`):[];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)}
|
|
95
|
+
`+" Or set SLACK_TOKEN=xoxp-... in .slack-term/.env.local")}function dt(){let e=process.env.SLACK_BOT_TOKEN;return e&&e.startsWith("xoxb-")?e:void 0}function Tr(e){let n=pn().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=kr(process.cwd(),["SLACK_COOKIE"]);if(s)return s;let o=process.env.SLACK_WORKSPACE;if(o)return n[o]?.cookie;let i=Xt(ss());if(i)return n[i]?.cookie;let a=Xt(rs());if(a)return n[a]?.cookie;return}import{existsSync as Yt,readFileSync as is,writeFileSync as $a,mkdirSync as Ta,chmodSync as os}from"node:fs";import{homedir as Af}from"node:os";import{join as Gt,dirname as Or}from"node:path";function Pr(){return process.env.HOME||Af()}function Ia(){return Gt(Pr(),".config","slack-cli","profiles.json")}function Rr(){return Gt(process.cwd(),".slack-cli","workspace")}function Mr(){return Gt(Pr(),".slack-cli","workspace")}function gn(){let e=Ia();if(!Yt(e))return{profiles:{}};return JSON.parse(is(e,"utf8"))}function Oa(e){let t=Ia();if(Ta(Or(t),{recursive:!0}),process.platform!=="win32"&&Yt(t))os(t,384);if($a(t,JSON.stringify(e,null,2)+`
|
|
96
|
+
`,{mode:384}),process.platform!=="win32")os(t,384)}function Vt(e){if(!Yt(e))return;return is(e,"utf8").trim()||void 0}function $f(e){let t={};for(let n of e.split(`
|
|
97
|
+
`)){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 Aa(e){if(!Yt(e))return{};try{return $f(is(e,"utf8"))}catch{return{}}}function Ir(e,t){let n=Pr(),r=e;while(!0){for(let i of[Gt(r,".slack-term",".env.local"),Gt(r,".env.local")]){let a=Aa(i);for(let c of t)if(a[c])return a[c]}if(r===n)break;let o=Or(r);if(o===r)break;r=o}let s=Aa(Gt(n,".slack-term",".env.local"));for(let o of t)if(s[o])return s[o];return}function Nr(e,t){Ta(Or(e),{recursive:!0});let n=Yt(e)?is(e,"utf8"):"",r=n?n.split(`
|
|
98
|
+
`):[];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)}if(process.platform!=="win32"&&Yt(e))os(e,384);if($a(e,r.join(`
|
|
97
99
|
`).trimEnd()+`
|
|
98
|
-
|
|
99
|
-
|
|
100
|
+
`,{mode:384}),process.platform!=="win32")os(e,384)}function mn(){let e=gn(),t=Vt(Rr()),n=Vt(Mr()),r=t??n;return Object.entries(e.profiles).map(([s,o])=>({name:s,profile:o,current:s===r}))}function vr(e,t){let n=gn();n.profiles[e]=t,Oa(n)}function Br(e,t){let n=gn();if(!(e in n.profiles))throw Error(`Profile not found: ${e}`);n.profiles[e].cookie=t,Oa(n)}function Pa(e){let n=gn().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=Ir(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.
|
|
101
|
+
`+" Migrate to SLACK_TOKEN=... or remove from your shell config.")}}let o=Ir(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=Vt(Rr());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=Vt(Mr());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).
|
|
102
|
+
Select locally: slack auth use <name> (writes .slack-cli/workspace)
|
|
103
|
+
Select globally: slack auth use -g <name> (writes ~/.slack-cli/workspace)`);throw Error(`No Slack token found.
|
|
104
|
+
Run one of:
|
|
105
|
+
`+` slack auth login — interactive wizard (desktop session, token, or new app)
|
|
106
|
+
`+` slack auth token — print the active token, or save one with --token
|
|
107
|
+
`+` slack auth chrome — import the xoxd cookie from Chrome (macOS/Linux)
|
|
108
|
+
`+` slack auth firefox — import the xoxd cookie from Firefox (all platforms)
|
|
109
|
+
`+` slack auth app — guided Slack app creation
|
|
110
|
+
`+" Or set SLACK_TOKEN=xoxp-... in .slack-term/.env.local")}function as(){let e=process.env.SLACK_BOT_TOKEN;return e&&e.startsWith("xoxb-")?e:void 0}function pt(e){let n=gn().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=Ir(process.cwd(),["SLACK_COOKIE"]);if(s)return s;let o=process.env.SLACK_WORKSPACE;if(o)return n[o]?.cookie;let i=Vt(Rr());if(i)return n[i]?.cookie;let a=Vt(Mr());if(a)return n[a]?.cookie;return}class ze 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 Wr(e,t,n,r){r=e.startsWith("xoxc-")?r??pt():void 0;let s={};if(r)s.Cookie=`d=${r}`;let o=await fetch(`${jr()}/${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 ze(isNaN(a)?60:a)}let i=await o.json();if(i.ok!==!0){let a=i.error??"unknown";if(a==="ratelimited")throw new ze(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.
|
|
111
|
+
Attach it: slack auth firefox (Linux/macOS/Windows) or slack auth chrome (macOS/Linux)
|
|
100
112
|
Or replace the token with an xoxp- user token:
|
|
101
|
-
slack auth login`);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"}.
|
|
113
|
+
slack auth login`);if((a==="missing_scope"||a==="cannot_dm_bot")&&e.startsWith("xoxb-")){if(t.startsWith("agents.sessions."))throw Error(`Slack error on ${t}: ${a}. Agent sessions need a granular bot token with chat:write and app membership in the channel.`);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"}.
|
|
102
114
|
Tailing/DMing people and listing users need a user session, not a bot token.
|
|
103
115
|
Switch workspace: slack auth ls then slack auth use <name>
|
|
104
|
-
Or import your Slack desktop session: slack auth login`)
|
|
116
|
+
Or import your Slack desktop session: slack auth login`)}throw Error(`Slack error on ${t}: ${a}`)}return i}async function Tf(e,t,n,r){let s={};if(r)s.Cookie=`d=${r}`;let o=await fetch(`${jr()}/${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 ze(isNaN(a)?60:a)}let i=await o.json();if(i.ok!==!0){let a=i.error??"unknown";if(a==="ratelimited")throw new ze(60);if((a==="invalid_auth"||a==="not_authed")&&!e.startsWith("xoxc-"))throw Error(`The draft API requires a desktop app session token (xoxc-).
|
|
105
117
|
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.
|
|
106
|
-
Attach it with: slack auth
|
|
118
|
+
Attach it with: slack auth firefox (Linux/macOS/Windows) or slack auth chrome (macOS/Linux)`);throw Error(`Slack error on ${t}: ${a}`)}return i}function If(e,t,n={},r){let s=new URLSearchParams({token:e,...n});return Tf(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 Wr(e,`${t}?${s}`,{method:"GET"},r)}function Ur(e,t,n,r){return Wr(e,t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)},r)}async function va(e,t,n){if(!e.startsWith("xoxb-"))throw Error("Agent sessions require a bot token (xoxb); user tokens are refused.");return Wr(e,t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n),signal:AbortSignal.timeout(1e4)})}function yn(e,t,n){return va(e,"agents.sessions.setStatus",{...t,status:n})}function Kr(e,t,n){return va(e,"agents.sessions.rename",{...t,title:n})}async function Zt(e,t){let n=await we(e,"auth.test",{},t);return{team:n.team??"",teamId:n.team_id??"",url:n.url??"",user:n.user??"",userId:n.user_id??""}}async function Ba(e,t){t=e.startsWith("xoxc-")?t??pt():void 0;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 i=parseInt(r.headers.get("retry-after")??"60",10);throw new ze(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 La(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 wn(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 we(e,"conversations.history",a,o)}async function ja(e,t,n,r=50,s){return we(e,"conversations.replies",{channel:t,ts:n,limit:String(r)},s)}async function cs(e,t,n,r,s){await Ur(e,"reactions.add",{channel:t,timestamp:n,name:r},s)}async function Wa(e,t,n,r){return((await we(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 us(e,t,n,r,s){await Ur(e,"reactions.remove",{channel:t,timestamp:n,name:r},s)}async function Of(e,t,n){let s=(await Ur(e,"conversations.open",{users:t},n)).channel?.id;if(!s)throw Error(`Failed to open DM with user ${t}`);return s}async function Ua(e,t,n){let r="";while(!0){let s={types:"im",limit:"200"};if(r)s.cursor=r;let o=await we(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 Lr(e,t,n,r){let s=await Ua(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 Dn(e){return e.toLowerCase().replace(/[-_\s]/g,"")}function Ra(e,t){let n=Dn(e.name??""),r=Dn(e.real_name??e.profile?.real_name??""),s=Dn(e.profile?.display_name??"");return n===t||r===t||!!s&&s===t}var Ka=200;async function Pf(e,t,n){let r=0,s=new Set,o="";while(!0){let d={limit:"200"};if(o)d.cursor=o;let l=await we(e,"users.list",d,n);for(let f of l.members??[]){if(r++,f.id)s.add(f.id);if(Ra(f,t))return{id:f.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 d={types:"im",limit:"200"};if(u)d.cursor=u;let l=await we(e,"conversations.list",d,n);for(let f of l.channels??[]){let h=f.user;if(!h||s.has(h))continue;if(i>=Ka){c=!0;break}s.add(h),i++;let m;try{m=(await we(e,"users.info",{user:h},n)).user}catch(p){if(p instanceof ze)throw p;a++;continue}if(m&&Ra(m,t))return{id:h,dm:String(f.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 Rf(e,t){if(t.workspaceCount===0)return Error(`Cannot resolve ${e}: users.list returned no members at all, so nothing could have matched.
|
|
107
119
|
`+`That is a token or scope fault, not a wrong handle — this says nothing about whether ${e} exists.
|
|
108
|
-
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 ${
|
|
120
|
+
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 ${Ka} 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.
|
|
109
121
|
`+(r.length?`This search was incomplete: ${r.join("; ")}.
|
|
110
122
|
`:"")+`Slack Connect people from another workspace are not in users.list, so if they never
|
|
111
123
|
DMed you they cannot be found by name at all. Look them up and use their ID:
|
|
112
|
-
slack user ls --external`)}function
|
|
113
|
-
${
|
|
114
|
-
|
|
115
|
-
|
|
124
|
+
slack user ls --external`)}function Jr(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 Mf(e){return Jr(e)?.channel}function Ma(e){return/^[CDG][A-Z0-9]{8,}$/.test(e)}function Na(e){return/^[UW][A-Z0-9]{6,}$/.test(e)}async function ls(e,t,n){let r=Mf(t);if(r)return r;if(!t.startsWith("@")&&!t.startsWith("#")){if(Ma(t))return t;if(Na(t))return Lr(e,t,n);throw Error(`Target must start with # or @ (or be a Slack URL/ID), got: ${t}`)}if(t.startsWith("#")&&Ma(t.slice(1)))return t.slice(1);let s=t.startsWith("@"),o=t.slice(1),i=Dn(o);if(s){if(Na(o))return Lr(e,o,n);let u=await we(e,"auth.test",{},n);if(i==="you"||i==="me"||Dn(u.user??"")===i){let f=u.user_id;if(!f)throw Error("auth.test did not return user_id");return await Ua(e,f,n)||Of(e,f,n)}let l=await Pf(e,i,n);if(!l.id)throw Rf(t,l);if(l.dm)return l.dm;return Lr(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 d=await we(e,"conversations.list",u,n);for(let l of d.channels??[])if(String(l.name??"").toLowerCase()===a)return String(l.id??"");if(c=d.response_metadata?.next_cursor??"",!c)break}throw Error(`channel not found: ${t}`)}async function fs(e,t,n){try{let r=await we(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 ds(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 ps(e,t){let n=[],r="";while(!0){let s={limit:"200"};if(r)s.cursor=r;let o=await we(e,"users.list",s,t);if(n.push(...o.members??[]),r=o.response_metadata?.next_cursor??"",!r)break}return{members:n}}async function zr(e,t,n){let r=[],s="";while(!0){let o={channel:t,limit:"200"};if(s)o.cursor=s;let i=await we(e,"conversations.members",o,n);if(r.push(...i.members??[]),s=i.response_metadata?.next_cursor??"",!s)break}return r}async function Hr(e,t,n){return we(e,"users.info",{user:t},n)}async function Ja(e,t,n){return we(e,"conversations.info",{channel:t},n)}async function za(e,t){let n=await If(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 Nf=["chat:write","im:write"],vf=["im:history","im:read"];async function hs(e){let{userId:t,botId:n,team:r,scopes:s}=await Ba(e),o="";if(n)try{o=(await La(e,n)).appId}catch{o=""}let i=(u)=>s.includes(u),a=Nf.filter((u)=>!i(u)),c=vf.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 Ha(e){return["",` Bot user: ${e.botUserId||"(unknown)"}`,` App ID: ${e.appId||"(unknown — bots.info unavailable)"}`,` Granted scopes: ${e.grantedScopes.join(", ")||"(none reported)"}`]}function gs(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,...Ha(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,...Ha(e)]}import{createInterface as ve}from"node:readline/promises";import{join as Vr,resolve as Gf}from"node:path";import{homedir as Yf}from"node:os";import{readdirSync as bn,readFileSync as Cn,existsSync as He,copyFileSync as Xr,mkdtempSync as Xa,rmSync as Ga}from"node:fs";import{homedir as Ds,tmpdir as Ya}from"node:os";import{join as ne,dirname as Bf}from"node:path";import{pbkdf2Sync as ms,createDecipheriv as Va,createHash as Lf,timingSafeEqual as jf}from"node:crypto";import{execSync as Za,execFileSync as Wf}from"node:child_process";function qa(){let e=process.env.HOME??Ds();if(process.platform==="darwin")return[ne(e,"Library","Application Support","Slack","Local Storage","leveldb")];if(process.platform==="linux")return[ne(e,".config","Slack","Local Storage","leveldb"),ne(e,"snap","slack","current",".config","Slack","Local Storage","leveldb"),ne(e,".var","app","com.slack.Slack","config","Slack","Local Storage","leveldb")];if(process.platform==="win32"){let t=process.env.APPDATA??ne(e,"AppData","Roaming");return[ne(t,"Slack","Local Storage","leveldb")]}throw Error(`Unsupported platform: ${process.platform}`)}function Uf(){let e=process.env.HOME??Ds();if(process.platform==="darwin")return ne(e,"Library","Application Support","Slack","Cookies");return""}function Kf(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=Va("aes-128-cbc",t,n);return s.setAutoPadding(!0),Buffer.concat([s.update(r),s.final()]).toString("utf8")}function Jf(){if(process.platform!=="darwin")return;let e=Uf();if(!He(e))return;let t;try{t=Za('security find-generic-password -w -s "Slack Safe Storage" -a "Slack Key"',{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trimEnd()}catch{return}let n=ms(t,"saltysalt",1003,16,"sha1");try{let{default:r}=Ln("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 Kf(Buffer.from(o.encrypted_value),n)}catch{return}}async function Gr(e){let t=e??qa().find(He);if(!t)throw Error(`Slack desktop app LevelDB not found at:
|
|
125
|
+
${qa().join(`
|
|
126
|
+
`)}
|
|
127
|
+
Is Slack installed and opened at least once?`);let n=bn(t).filter((c)=>c.endsWith(".ldb")||c.endsWith(".log"));if(n.length===0)throw Error(`No LevelDB data files found in ${t}`);let r=new Map;for(let c of n){let u;try{u=Cn(ne(t,c),"latin1")}catch{continue}if(c.endsWith(".log"))for(let d of u.matchAll(/"token":"(xoxc-[^"]+)"/g)){let l=d[1],f=l.split("-")[1]??"";if(!f||l.length<40)continue;let h=Math.max(0,d.index-2000),m=Math.min(u.length,d.index+2000),p=u.slice(h,m),y=p.match(/"url":"(https:\/\/[a-z0-9-]+\.slack\.com\/)"/),F=p.match(/"(?:team_name|name)":"([^"]{2,60})"/),C=r.get(f);if(!C||l.length>C.token.length){let T={token:l,teamId:f},S=y?.[1]??C?.url,v=F?.[1]??C?.teamName;if(S)T.url=S;if(v)T.teamName=v;r.set(f,T)}}else for(let d of u.matchAll(/xoxc-(\d+)-(\d+)-(\d+)/g)){let l=d[1];if(r.has(l))continue;let f=d.index+d[0].length,h=Math.min(f+10,u.length);while(f<h&&(u.charCodeAt(f)<48||u.charCodeAt(f)>57))f++;let m="";while(f<u.length&&u.charCodeAt(f)>=48&&u.charCodeAt(f)<=57)m+=u[f++];if(u[f]!=="-")continue;f++;let p="";while(f<u.length){let F=u.charCodeAt(f);if(F>=48&&F<=57||F>=97&&F<=102)p+=u[f++];else break}if(p.length<20)continue;let y=`${d[0]}${m}-${p}`;r.set(l,{token:y,teamId:l})}}let o=bn(t).filter((c)=>c.endsWith(".ldb")||c.endsWith(".log")).map((c)=>{try{return Cn(ne(t,c),"latin1").replace(/[^\x20-\x7e]/g," ")}catch{return""}}).join(" ");for(let c of r.values()){if(c.teamName)continue;let u=o.indexOf(c.teamId);if(u!==-1){let d=Math.max(0,u-500),l=Math.min(o.length,u+500),h=o.slice(d,l).match(/"(?:team_name|name)":"([^"]{2,60})"/);if(h?.[1]){c.teamName=h[1];continue}}if(!c.teamName&&c.url){let d=c.url.match(/https:\/\/([a-z0-9-]+)\.slack\.com\//)?.[1];if(d){let l=o.indexOf(d);if(l!==-1){let f=Math.max(0,l-500),h=Math.min(o.length,l+500),p=o.slice(f,h).match(/"(?:team_name|name)":"([^"]{2,60})"/);if(p?.[1]){c.teamName=p[1];continue}}c.teamName=d.split("-").map((f)=>f.charAt(0).toUpperCase()+f.slice(1)).join(" ")}}}let i=e?void 0:Jf(),a=[...r.values()];if(i)for(let c of a)c.cookie=i;return a}function qr(e,t,n,r=!1){let s=(o,i)=>{try{let a=Va("aes-128-cbc",t,o);a.setAutoPadding(!0);let c=Buffer.concat([a.update(i),a.final()]);if(c.subarray(0,5).toString()==="xoxd-")return c.toString("utf8");if(c.length>=37){let u=Lf("sha256").update(n).digest();if(jf(c.subarray(0,32),u)){let d=c.subarray(32).toString("utf8");if(d.startsWith("xoxd-"))return d}}return}catch{return}};return s(Buffer.alloc(16,32),e.slice(3))??(r&&e.length>=35?s(e.slice(19,35),e.slice(35)):void 0)}function zf(e,t){let n=(r,s)=>{if(r&&s)return`${r} (${s})`;return r||s||t};try{let s=JSON.parse(Cn(ne(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(Cn(ne(e,t,"Preferences"),"utf8")).profile;return n(s?.name??"",s?.user_name??"")}catch{return t}}function Qa(){let e=process.env.HOME??Ds();if(process.platform==="darwin")return ne(e,"Library","Application Support","Google","Chrome");if(process.platform==="linux")return ne(process.env.XDG_CONFIG_HOME??ne(e,".config"),"google-chrome");return""}function Hf(){try{return Wf("secret-tool",["lookup","application","chrome"],{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trimEnd()||void 0}catch{return}}function ys(){if(process.platform!=="darwin"&&process.platform!=="linux")return{candidates:[],totalProfiles:0};let e=Qa();if(!He(e))return{candidates:[],totalProfiles:0};let t;if(process.platform==="darwin"){let i;try{i=Za('security find-generic-password -a Chrome -s "Chrome Safe Storage" -w',{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trimEnd()}catch{return{candidates:[],totalProfiles:0}}if(!i)return{candidates:[],totalProfiles:0};t=ms(i,"saltysalt",1003,16,"sha1")}let n=["Default",...bn(e).filter((i)=>i.startsWith("Profile "))],r=[],s,o=!1;for(let i of n){let a=[ne(e,i,"Network","Cookies"),ne(e,i,"Cookies")].find(He);if(!a)continue;let c=Xa(ne(Ya(),"slack-chrome-cookies-")),u=ne(c,"Cookies");try{if(Xr(a,u),He(`${a}-wal`))Xr(`${a}-wal`,`${u}-wal`);let{default:d}=Ln("bun:sqlite"),l=new d(u,{readonly:!0}),f;try{f=l.prepare("SELECT encrypted_value, value, host_key FROM cookies WHERE name='d' AND (host_key='slack.com' OR host_key LIKE '%.slack.com') LIMIT 1").get()}finally{l.close()}if(!f)continue;let h=Buffer.from(f.encrypted_value),m=h.subarray(0,3).toString(),p;if(m==="v20")throw Error("Chrome cookie uses unsupported v20 app-bound encryption.");if(process.platform==="linux"){if(!h.length&&f.value?.startsWith("xoxd-"))p=f.value;else if(m==="v10")p=qr(h,ms("peanuts","saltysalt",1,16,"sha1"),f.host_key);else if(m==="v11"){if(!s){let y=Hf();if(y)s=ms(y,"saltysalt",1,16,"sha1")}if(s)p=qr(h,s,f.host_key);else o=!0}}else if(m==="v10"&&t)p=qr(h,t,f.host_key,!0);else if(m!=="v10")throw Error("Unknown cookie encryption prefix.");if(p)r.push({profileDir:i,profileName:zf(e,i),cookie:p})}catch(d){if(d instanceof Error&&(d.message.includes("unsupported v20")||d.message.includes("Unknown cookie")))throw d}finally{Ga(c,{recursive:!0,force:!0})}}if(o&&r.length===0)throw Error("Chrome v11 cookie key is unavailable. Install secret-tool and unlock the GNOME keyring, or use slack auth firefox.");return{candidates:r,totalProfiles:n.length}}async function Yr(){if(process.platform!=="linux")throw Error("Chrome session import is currently supported on Linux only.");let e=Qa();if(!He(e))throw Error("Chrome profile directory was not found.");let t=new Map(ys().candidates.map((s)=>[s.profileDir,s.cookie])),n=new Map,r=["Default",...bn(e).filter((s)=>s.startsWith("Profile "))];for(let s of r){let o=ne(e,s,"Local Storage","leveldb");if(!He(o))continue;let i;try{i=await Gr(o)}catch{continue}for(let a of i){if(n.has(a.teamId))throw Error("More than one Chrome profile has a token for the same workspace. Select one browser profile first.");let c=t.get(s);if(c)a.cookie=c;n.set(a.teamId,a)}}return[...n.values()]}function qf(){let e=process.env.HOME??Ds();if(process.platform==="darwin")return[ne(e,"Library","Application Support","Firefox","Profiles")];if(process.platform==="linux")return[ne(e,".mozilla","firefox"),ne(e,"snap","firefox","common",".mozilla","firefox"),ne(e,".var","app","org.mozilla.firefox",".mozilla","firefox")];if(process.platform==="win32")return[ne(process.env.APPDATA??ne(e,"AppData","Roaming"),"Mozilla","Firefox","Profiles")];return[]}function Xf(e){let t=ne(e,"profiles.ini"),n=He(t)?t:ne(Bf(e),"profiles.ini"),r={};if(!He(n))return r;try{let s=Cn(n,"utf8"),o="",i="";for(let a of s.split(`
|
|
128
|
+
`)){let c=a.trim();if(c.startsWith("[")){o="",i="";continue}let u=c.indexOf("=");if(u===-1)continue;let d=c.slice(0,u).trim().toLowerCase(),l=c.slice(u+1).trim();if(d==="name")o=l;if(d==="path")i=l.split(/[\\/]/).pop()??l;if(o&&i)r[i]=o,o="",i=""}}catch{}return r}function ws(){let e=[];for(let t of qf().filter(He)){let n=Xf(t),r;try{r=bn(t)}catch{continue}for(let s of r){let o=ne(t,s,"cookies.sqlite");if(!He(o))continue;let i=Xa(ne(Ya(),"slack-firefox-cookies-")),a=ne(i,"cookies.sqlite");try{Xr(o,a);let{default:c}=Ln("bun:sqlite"),u=new c(a,{readonly:!0}),d=u.prepare("SELECT value FROM moz_cookies WHERE name='d' AND (host='slack.com' OR host LIKE '%.slack.com') LIMIT 1").get();if(u.close(),!d?.value||!d.value.startsWith("xoxd-"))continue;let l=n[s]??s;e.push({profileDir:s,profileName:l,cookie:d.value})}catch{}finally{Ga(i,{recursive:!0,force:!0})}}}return e}var Vf=["search:read","channels:history","groups:history","im:history","mpim:history","channels:read","groups:read","im:read","mpim:read","users:read","chat:write","files:write"],Zf=["channels:history","groups:history","im:history","mpim:history","channels:read","groups:read","im:read","mpim:read","users:read","chat:write","files:write"];function bs(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function Qf(){return JSON.stringify({display_information:{name:"slack-term"},oauth_config:{scopes:{user:Vf}},settings:{org_deploy_enabled:!1,socket_mode_enabled:!1,token_rotation_enabled:!1}},null,2)}function ed(){return JSON.stringify({display_information:{name:"slack-term"},features:{bot_user:{display_name:"slack-term",always_online:!1}},oauth_config:{scopes:{bot:Zf}},settings:{org_deploy_enabled:!1,socket_mode_enabled:!1,token_rotation_enabled:!1}},null,2)}async function ht(e,t){return(await e.question(t)).trim()}async function En(e,t){if(t)return!0;if(!e)return!1;let n=await ht(e,"Read local browser profiles and Slack session cookies? [y/N]: ");return n.toLowerCase()==="y"||n.toLowerCase()==="yes"}async function Mt(e,t,n,r){console.error("Verifying token...");let s=await Zt(t,r),o=bs(s.team),i;if(n)i=n;else if(e)i=await ht(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 ht(e,"Choice [1/2/3/4, Enter=1]: ");if(c==="2")a=Vr(process.cwd(),".slack-term",".env.local");else if(c==="3")a=Vr(Yf(),".slack-term",".env.local");else if(c==="4")a=null;else a=Vr(process.cwd(),".env.local")}if(a===null)if(vr(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;Nr(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 Zr(e,t=!1,n="auto",r=!1){console.error("Scanning Slack desktop app...");let s=await Gr();if(s.length===0)console.error("No sessions found. Make sure Slack is installed and you have signed in at least once."),process.exit(1);if(process.platform==="linux"&&n!=="none"&&s.some((o)=>!o.cookie)&&await En(e,t)){let o=[];if(n!=="chrome")for(let i of ws())o.push({source:"Firefox",profileName:i.profileName,cookie:i.cookie});if(n==="chrome"||n==="all"||n==="auto"&&o.length===0)try{for(let i of ys().candidates)o.push({source:"Chrome",profileName:i.profileName,cookie:i.cookie})}catch(i){console.error(i instanceof Error?i.message:String(i))}if(o.length===1){for(let i of s)i.cookie??=o[0].cookie;console.log(`Found Slack session cookie in ${o[0].source} profile: ${o[0].profileName}`)}else if(o.length>1)console.log("Multiple browser sessions found. Choose one later with slack auth chrome or slack auth firefox.");if(s.some((i)=>!i.cookie))console.log("Desktop session needs an xoxd cookie on Linux. Run: slack auth chrome or slack auth firefox")}await Qr(s,e,r)}async function Qr(e,t,n=!1){if(e.length===1&&t&&e[0]?.cookie&&!n){let r=e[0],s=r.teamName??r.teamId;console.log(`Found workspace: ${s}${r.cookie?" (+ xoxd cookie)":""}`),await Mt(t,r.token,bs(s),r.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 r of e){let s=r.teamName??r.teamId,o=bs(s);vr(o,{token:r.token,team:s,teamId:r.teamId,url:r.url??"",user:"",...r.cookie?{cookie:r.cookie}:{}}),console.log(`Added workspace "${o}": ${s}${r.cookie?" + xoxd cookie":""}`)}if(console.log(""),e.length===1){let r=bs(e[0].teamName??e[0].teamId);console.log(`Run: slack auth use -g ${r}`)}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 ec(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 ht(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 ht(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 Mt(e,o)}async function Cs(e,t){let n=t==="user"?Qf():ed(),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 ht(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 Mt(e,o)}async function tc(e={}){if(process.platform!=="darwin"&&process.platform!=="linux")console.error("Chrome cookie extraction is supported on macOS and Linux."),process.exit(1);let t=mn();if(t.length===0)console.error("No workspaces configured. Run: slack auth login"),process.exit(1);let n;if(e.workspace){if(!t.find((u)=>u.name===e.workspace))console.error(`Workspace "${e.workspace}" not found. Available: ${t.map((u)=>u.name).join(", ")}`),process.exit(1);n=e.workspace}else if(t.length===1)n=t[0].name;else{let c=t.find((u)=>u.current);if(c)n=c.name,console.log(`Using active workspace: ${n}`);else{console.log("Multiple workspaces found. Choose one:"),t.forEach((f,h)=>console.log(` ${h+1}) ${f.name} (${f.profile.team})`));let u=ve({input:process.stdin,output:process.stdout}),d=(await u.question("Choice: ")).trim();u.close();let l=parseInt(d,10)-1;if(isNaN(l)||l<0||l>=t.length)console.error("Invalid choice."),process.exit(1);n=t[l].name}}if(t.find((c)=>c.name===n).profile.token.startsWith("xoxb-")){console.error(`
|
|
116
129
|
Workspace "${n}" uses a bot token (xoxb-). A Chrome session cookie only
|
|
117
130
|
`+`augments a user session token (xoxc-) — it has no effect on a bot token, so user-level
|
|
118
|
-
`+"actions (tail @user, DMs, listing users) would still fail.");let
|
|
131
|
+
`+"actions (tail @user, DMs, listing users) would still fail.");let c=t.filter((u)=>u.profile.token.startsWith("xoxc-")||u.profile.token.startsWith("xoxp-"));if(c.length>0)console.error(` Target a user-token workspace instead: ${c.map((u)=>u.name).join(", ")}`),console.error(` slack auth chrome -w ${c[0].name}`);else console.error(" Import your Slack desktop user session instead: slack auth login");process.exit(1)}if(!e.yes&&!process.stdin.isTTY)console.error("Reading browser profiles requires confirmation. Re-run interactively or pass --yes."),process.exit(1);let s=e.yes?void 0:ve({input:process.stdin,output:process.stdout});try{if(!await En(s,e.yes??!1)){console.log("Browser profile scan cancelled.");return}}finally{s?.close()}if(console.log("Scanning Chrome profiles for Slack session..."),process.platform==="darwin")console.log("macOS may show a dialog asking for your login password — click Allow.");let o,i;try{({candidates:o,totalProfiles:i}=ys())}catch(c){console.error(`Failed: ${c instanceof Error?c.message:String(c)}`),process.exit(1)}if(o.length===0){if(console.error(`No Slack session found in Chrome (scanned ${i} profile${i!==1?"s":""}). Possible reasons:`),process.platform==="darwin")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 a;if(o.length===1&&i<=1)a=o[0].cookie,console.log(`Found session in Chrome profile: ${o[0].profileName}`);else{let c=o.length===1?`Found 1 Slack session across ${i} Chrome profiles:`:`Found ${o.length} Slack sessions across ${i} Chrome profiles:`;console.log(c),o.forEach((h,m)=>console.log(` ${m+1}) ${h.profileName} [${h.profileDir}]`)),console.log("");let u=ve({input:process.stdin,output:process.stdout}),d=o.length===1?" [Enter=1]":"",l=(await u.question(`Choice [1-${o.length}]${d}: `)).trim();u.close();let f=l===""&&o.length===1?0:parseInt(l,10)-1;if(isNaN(f)||f<0||f>=o.length)console.error("Invalid choice."),process.exit(1);a=o[f].cookie}Br(n,a),console.log(`Saved xoxd cookie to workspace "${n}".`),console.log("RTM WebSocket mode is now available: slack tail @you")}async function nc(e={}){let t=mn();if(t.length===0)console.error("No workspaces configured. Run: slack auth login"),process.exit(1);let n;if(e.workspace){if(!t.find((a)=>a.name===e.workspace))console.error(`Workspace "${e.workspace}" not found. Available: ${t.map((a)=>a.name).join(", ")}`),process.exit(1);n=e.workspace}else if(t.length===1)n=t[0].name;else{let i=t.find((a)=>a.current);if(i)n=i.name,console.log(`Using active workspace: ${n}`);else{console.log("Multiple workspaces found. Choose one:"),t.forEach((d,l)=>console.log(` ${l+1}) ${d.name} (${d.profile.team})`));let a=ve({input:process.stdin,output:process.stdout}),c=(await a.question("Choice: ")).trim();a.close();let u=parseInt(c,10)-1;if(isNaN(u)||u<0||u>=t.length)console.error("Invalid choice."),process.exit(1);n=t[u].name}}if(!e.yes&&!process.stdin.isTTY)console.error("Reading browser profiles requires confirmation. Re-run interactively or pass --yes."),process.exit(1);let r=e.yes?void 0:ve({input:process.stdin,output:process.stdout});try{if(!await En(r,e.yes??!1)){console.log("Browser profile scan cancelled.");return}}finally{r?.close()}console.log("Scanning Firefox profiles for Slack session...");let s=ws();if(s.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 o;if(s.length===1)o=s[0].cookie,console.log(`Found session in Firefox profile: ${s[0].profileName}`);else{console.log("Multiple Firefox profiles have a Slack session. Choose one:"),s.forEach((u,d)=>console.log(` ${d+1}) ${u.profileName} [${u.profileDir}]`));let i=ve({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>=s.length)console.error("Invalid choice."),process.exit(1);o=s[c].cookie}Br(n,o),console.log(`Saved xoxd cookie to workspace "${n}".`),console.log("RTM WebSocket mode is now available: slack tail @you")}async function sc(e={}){if(e.token){await Mt(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 Mt(null,r,e.name);return}let t=ve({input:process.stdin,output:process.stdout});try{await ec(t)}finally{t.close()}}async function rc(e={}){let t=ve({input:process.stdin,output:process.stdout});try{if(e.bot!==void 0){await Cs(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 ht(t,"Choice [1/2, Enter=1]: ");await Cs(t,n==="2"?"bot":"user")}finally{t.close()}}function oc(e={}){let t=(s,o)=>{if(/[\r\n]/.test(o))throw Error(`Invalid newline in ${s}.`);return`${s}=${/^[A-Za-z0-9._=-]+$/.test(o)?o:JSON.stringify(o)}`},n=[t("SLACK_TOKEN",Pa(e.workspace))],r=pt(e.workspace);if(r)n.push(t("SLACK_COOKIE",r));if(!e.workspace){let s=as();if(s)n.push(t("SLACK_BOT_TOKEN",s))}console.log(n.join(`
|
|
132
|
+
`))}function ic(e){let t=mn(),n=e.workspace?t.find((s)=>s.name===e.workspace):t.find((s)=>s.current)??(t.length===1?t[0]:void 0);if(!n)throw Error(e.workspace?`Workspace "${e.workspace}" not found. Run: slack auth ls`:"Select a workspace with slack auth use <name>, or pass --workspace <name>.");if(!n.profile.cookie)throw Error(`Workspace "${n.name}" has no session cookie. Run: slack auth chrome -w ${n.name} or slack auth firefox -w ${n.name}`);let r=Gf(e.envfile);Nr(r,{SLACK_TOKEN:n.profile.token,SLACK_COOKIE:n.profile.cookie}),console.log(`Saved token and cookie for workspace "${n.name}" to ${r}`)}async function Es(e={}){let t=mn();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.fromChrome,e.fromFirefox,e.fromAll].filter(Boolean).length>1)throw Error("Choose only one browser source: --from-chrome, --from-firefox, or --from-all.");if(e.fromChrome&&!e.fromDesktop){if(!e.yes&&!process.stdin.isTTY)throw Error("Reading browser profiles requires confirmation. Re-run interactively or pass --yes.");let r=process.stdin.isTTY?ve({input:process.stdin,output:process.stdout}):void 0;try{if(!await En(r,e.yes??!1)){console.log("Browser profile scan cancelled.");return}let s=await Yr();if(s.length===0)throw Error("No Slack session token found in Chrome profiles.");await Qr(s,r,!0)}finally{r?.close()}return}if(e.fromAll&&!e.fromDesktop){if(!e.yes&&!process.stdin.isTTY)throw Error("Reading browser profiles requires confirmation. Re-run interactively or pass --yes.");let r=process.stdin.isTTY?ve({input:process.stdin,output:process.stdout}):void 0;try{try{await Zr(r,e.yes??!1,"all",!0)}catch(s){if(!(s instanceof Error)||!s.message.startsWith("Slack desktop app LevelDB not found"))throw s;if(!await En(r,e.yes??!1)){console.log("Browser profile scan cancelled.");return}let o=await Yr();if(o.length===0)throw Error("No Slack session token found in Chrome profiles.");if(o.every((i)=>!i.cookie)){let i=ws();if(i.length===1)for(let a of o)a.cookie=i[0].cookie}await Qr(o,r,!0)}}finally{r?.close()}return}if(e.fromDesktop||e.fromChrome||e.fromFirefox||e.fromAll){let r=e.fromChrome?"chrome":e.fromFirefox?"firefox":e.fromAll?"all":"none";if(r!=="none"&&!e.yes&&!process.stdin.isTTY)throw Error("Reading browser profiles requires confirmation. Re-run interactively or pass --yes.");let s=process.stdin.isTTY?ve({input:process.stdin,output:process.stdout}):void 0;try{await Zr(s,e.yes??!1,r,!0)}finally{s?.close()}return}if(e.token){await Mt(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 Mt(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, or Chrome/Firefox on Linux"),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=ve({input:process.stdin,output:process.stdout});try{let r=await ht(n,"Choice [1/2/3/4]: ");if(console.log(""),r==="1")await Zr(n,e.yes??!1);else if(r==="2")await ec(n);else if(r==="3")await Cs(n,"user");else if(r==="4")await Cs(n,"bot");else console.error(`Invalid choice: "${r}". Enter 1, 2, 3, or 4.`),process.exit(1)}finally{n.close()}}async function Fs(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),d=u.search(/[>|]/),l=d===-1?u:u.slice(0,d);if(l.length>=9)o.push(l);a=c+1}for(let c of o){if(!n.has(c))n.set(c,await ds(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 xs(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 cc(e){let t=typeof e.ts==="string"?e.ts:"",n=typeof e.thread_ts==="string"?e.thread_ts:"";return n!==""&&n!==t}function td(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"),d=n.padEnd(6,"0").slice(0,6);return`${s}-${o}-${i}T${a}:${c}:${u}.${d}`}async function nd(e,t,n){let r=typeof t.ts==="string"?t.ts:"0.000000",s=td(r),o="?";if(typeof t.user==="string"){let l=t.user,f="@"+l;if(!n.has(f)){let[,h]=await fs(e,l);n.set(f,h)}o=n.get(f)??l}else if(typeof t.username==="string")o=t.username;let i=typeof t.text==="string"?t.text:"",c=xs(await Fs(e,i,n)).split(`
|
|
119
133
|
`),u=c[0]+(c.length>1?`
|
|
120
134
|
`+c.slice(1).map((l)=>` ${l}`).join(`
|
|
121
|
-
`):""),
|
|
122
|
-
`)}),u.addEventListener("close",()=>c()),u.addEventListener("error",()=>c()),u.addEventListener("message",(
|
|
135
|
+
`):""),d=cc(t)?"↳ ":"";return`${s} ${d}@${o}: ${u}`}async function sd(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).
|
|
136
|
+
`)}),u.addEventListener("close",()=>c()),u.addEventListener("error",()=>c()),u.addEventListener("message",(d)=>{(async()=>{try{let l;try{l=JSON.parse(String(d.data))}catch{return}let f=typeof l.type==="string"?l.type:"";if(f==="ping"){u.send(JSON.stringify({type:"pong",reply_to:l.id??0}));return}if(f!=="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 p=typeof l.subtype==="string"?l.subtype:"";if(p==="message_changed"||p==="message_deleted")return;if(s.thread){if((typeof l.thread_ts==="string"?l.thread_ts:m)!==s.thread&&m!==s.thread)return}if(s.watchThread&&cc(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 F=o.values().next().value;if(F!==void 0)o.delete(F)}let y=await nd(t,l,i);process.stdout.write(y+`
|
|
123
137
|
`)}catch(l){process.stderr.write(`RTM message error: ${l instanceof Error?l.message:String(l)}
|
|
124
|
-
`)}})()})})}var
|
|
125
|
-
`),l=
|
|
126
|
-
`+
|
|
127
|
-
`):""),
|
|
138
|
+
`)}})()})})}var ac=3,rd=2000,eo={sleep:(e)=>new Promise((t)=>setTimeout(t,e)),clientBoot:za,getWebSocket:()=>{let e=globalThis.WebSocket;return typeof e==="function"?e:void 0}};async function uc(e,t,n,r,s,o,i){let a=eo.getWebSocket();if(!a)return;for(let c=0;c<ac;c++){if(i?.aborted)return;try{let{wsUrl:u}=await eo.clientBoot(e,t);await sd(a,e,u,n,r,s,o,i)}catch{}if(i?.aborted)return;if(c<ac-1)await eo.sleep(rd)}}function lc(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 qe={sleep:(e)=>new Promise((t)=>setTimeout(t,e)),now:()=>Date.now(),tailRTM:uc};function nt(e){return e&&typeof e==="object"&&!Array.isArray(e)?e:{}}function to(e){return Array.isArray(e)?e:[]}function fc(e){return Number(e)||0}function dc(e){let t=typeof e.ts==="string"?e.ts:"",n=typeof e.thread_ts==="string"?e.thread_ts:"";return n!==""&&n!==t}function od(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"),d=n.padEnd(6,"0").slice(0,6);return`${s}-${o}-${i}T${a}:${c}:${u}.${d}`}async function id(e,t,n,r,s){let o=typeof t.ts==="string"?t.ts:"0.000000",i=od(o),a="?";if(typeof t.user==="string"){let m=t.user,p="@"+m;if(!n.has(p)){let[,y]=await fs(e,m,s);n.set(p,y)}a=n.get(p)??m}else if(typeof t.username==="string")a=t.username;let c=typeof t.text==="string"?t.text:"",d=xs(await Fs(e,c,n,s)).split(`
|
|
139
|
+
`),l=d[0]+(d.length>1?`
|
|
140
|
+
`+d.slice(1).map((m)=>` ${m}`).join(`
|
|
141
|
+
`):""),f=dc(t)?"↳ ":"",h=r?`${r} @${a}`:`@${a}`;return`${i} ${f}${h}: ${l}`}async function ad(e,t,n,r,s,o,i){let a=nt(await wn(e,t,20,i?void 0:n||void 0,i,r.cookie)),c=to(a.messages).map(nt).reverse(),u=nt(a.response_metadata),d=a.has_more===!0&&typeof u.next_cursor==="string"?u.next_cursor:void 0,l=[];if(r.watchThread&&!i){let y=nt(await ja(e,t,r.watchThread,50,r.cookie));l=to(y.messages).map(nt).filter((F)=>(typeof F.ts==="string"?F.ts:"")!==r.watchThread)}let f=[...c.map((y)=>({m:y,fromHistory:!0})),...l.map((y)=>({m:y,fromHistory:!1}))].sort((y,F)=>fc(typeof y.m.ts==="string"?y.m.ts:"")-fc(typeof F.m.ts==="string"?F.m.ts:"")),h=[],m=n,p=!1;for(let{m:y,fromHistory:F}of f){let C=typeof y.ts==="string"?y.ts:"";if(!C||s.has(C))continue;let T=typeof y.subtype==="string"?y.subtype:"";if(T==="message_changed"||T==="message_deleted")continue;if(r.thread){if((typeof y.thread_ts==="string"?y.thread_ts:C)!==r.thread&&C!==r.thread)continue}if(r.watchThread&&dc(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(C),s.size>1000){let v=s.values().next().value;if(v!==void 0)s.delete(v)}if(h.push(await id(e,y,o,void 0,r.cookie)),F)m=C;let S=typeof y.user==="string"?y.user:"";if(!r.myUserId||S!==r.myUserId)p=!0}return{newCursor:m,lines:h,hasMore:a.has_more===!0,nextPageCursor:d,emittedOther:p}}function cd(e){if(e.includes("slack.com")){let t=Jr(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 pc(e,t,n={},r){if(n.me&&!t)console.error(`slack tail --me requires a <target> channel.
|
|
128
142
|
Cross-channel mention streaming is not yet supported.
|
|
129
|
-
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
|
|
130
|
-
`);
|
|
131
|
-
`);if(
|
|
132
|
-
`),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
|
|
133
|
-
`);if(n.length<2)return e;if(
|
|
134
|
-
`);return r===e?e:r}function
|
|
135
|
-
`)}function
|
|
143
|
+
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 ls(e,t,n.cookie),o=n.interval??60000,i=n.timeout?qe.now()+lc(n.timeout)*1000:1/0,a=new Map,c=new Set;try{let p=nt(await Ja(e,s,n.cookie));if(nt(p.channel).is_archived===!0)console.error("Warning: this channel is archived — no new messages will arrive.")}catch(p){let y=p instanceof Error?p.message:String(p);if(y.includes("not_in_channel"))console.error("Error: you are not a member of that channel. Join it in Slack first, then retry."),process.exit(1);if(y.includes("missing_scope"))console.error("Error: token lacks the required history scope. Check your token's channels:history (or groups:history) permission."),process.exit(1);if(y.includes("channel_not_found"))console.error("Error: channel not found — it may be a private channel inaccessible with your token."),process.exit(1);console.error(`Warning: preflight check failed: ${y}`)}let u="";if(n.since){let p=lc(n.since);u=(qe.now()/1000-p).toFixed(6)}else{let p=nt(await wn(e,s,1,void 0,void 0,n.cookie)),y=to(p.messages).map(nt);if(y.length>0&&typeof y[0]?.ts==="string")u=y[0].ts,c.add(u);else u=(qe.now()/1000).toFixed(6)}let d;if(n.me||n.exitOnMessage)d=(await Zt(e,n.cookie)).userId||void 0;let l;if(n.watchThread!==void 0)try{l=cd(n.watchThread)}catch(p){console.error(p instanceof Error?p.message:String(p)),process.exit(1)}let f={...n.thread!==void 0?{thread:n.thread}:{},...l!==void 0?{watchThread:l}:{},...n.me!==void 0?{me:n.me}:{},...d!==void 0?{myUserId:d}:{},...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 qe.tailRTM(e,n.cookie,s,f,c,a,r),r?.aborted)return;console.error("RTM unavailable — switching to polling.")}let h=!0,m=qe.now();while(!r?.aborted){if(qe.now()>=i)return;let p=!1;try{let C=qe.now()-m,T=o>0&&C>o*5,S,v=!0;do{let{newCursor:K,lines:P,nextPageCursor:z,emittedOther:W}=await ad(e,s,u,f,c,a,S);if(u=K,h&&v&&n.since&&P.length===0)process.stdout.write(`(no messages in the last ${n.since} — watching for new)
|
|
144
|
+
`);v=!1;for(let Z of P)process.stdout.write(Z+`
|
|
145
|
+
`);if(W)p=!0;S=T?z:void 0}while(S);h=!1}catch(F){if(F instanceof ze){console.error(`Warning: Slack rate limit hit — backing off for ${F.retryAfter}s`),await qe.sleep(F.retryAfter*1000);continue}throw F}if(n.exitOnMessage&&p)return;m=qe.now();let y=i-qe.now();if(y<=0)return;await qe.sleep(Math.min(o,y))}}import{spawn as ud}from"node:child_process";import{constants as hc}from"node:os";var ld=["processing","active","suspended","closed"];function gc(e){if(e!==void 0&&!/^[A-Za-z_][A-Za-z0-9_]*$/.test(e))throw Error("--bot-token-env must name an environment variable, not contain a token.");let t=e===void 0?as():process.env[e];if(!t?.startsWith("xoxb-"))throw Error("Agent commands require a bot token (xoxb). Set SLACK_BOT_TOKEN or --bot-token-env NAME; user tokens are refused.");return t}function mc(e){if(e!==void 0&&(!e.trim()||[...e].length>200))throw Error("--title must contain 1–200 characters.")}async function Dc(e,t,n){let{ref:r,threadTs:s}=n(t);if(!s||!/^\d{10}\.\d{6}$/.test(s))throw Error("Target must include a thread root: C00000001:1700000000.000100, #channel:ts, or a message permalink.");return{channel_id:await ls(e,r),thread_ts:s}}function no(e,t){console.error(`agent: ${e}: ${t instanceof Error?t.message:"request failed"}`)}async function fd(e,t,n,r){let s,o,i,a,c,u=!1,d=!1,l=1,f=(p)=>{if(o)return;if(o=p,u=!0,s&&s.exitCode===null&&s.signalCode===null)s.kill(p),i=setTimeout(()=>s?.kill("SIGKILL"),5000)},h=()=>f("SIGINT"),m=()=>f("SIGTERM");process.on("SIGINT",h),process.on("SIGTERM",m);try{if(d=!0,await yn(e,t,"processing"),!u&&r.title!==void 0)await Kr(e,t,r.title);if(!u){s=ud(n[0],n.slice(1),{stdio:"inherit"});let p=new Promise((y)=>{s.once("error",()=>{console.error("agent: could not start command"),y(127)}),s.once("exit",(F,C)=>{y(F??(C?128+hc.signals[C]:1))})});a=setInterval(()=>{if(u||c)return;c=yn(e,t,"processing").then(()=>{}).catch((y)=>no("heartbeat failed; retrying on next tick",y)).finally(()=>{c=void 0})},r.every*1000),l=await p}}catch(p){no("could not start agent session",p)}finally{if(u=!0,clearInterval(a),clearTimeout(i),await c,d)try{await yn(e,t,r.close?"closed":"active")}catch(p){if(no("final status clear failed",p),l===0)l=1}process.removeListener("SIGINT",h),process.removeListener("SIGTERM",m)}return o?128+hc.signals[o]:l}function yc(e,t){let n=(r)=>r.positional("target",{type:"string",demandOption:!0,describe:"Thread root: raw channel ID:ts (avoids listing), #channel:ts, or permalink"}).option("title",{type:"string",describe:"Rename the session (1–200 characters)"}).option("bot-token-env",{type:"string",describe:"Environment variable holding an agent-enabled app's xoxb token (default SLACK_BOT_TOKEN); requires chat:write and channel membership"});return e.command("status <target> <status>","Set a bot agent session's status",(r)=>n(r).positional("status",{type:"string",choices:ld,demandOption:!0}),async(r)=>{mc(r.title);let s=gc(r["bot-token-env"]),o=await Dc(s,r.target,t);if(await yn(s,o,r.status),r.title!==void 0)await Kr(s,o,r.title)}).command("run <target>","Keep a thread working while a command runs: run <target> -- <command...>",(r)=>n(r).parserConfiguration({"populate--":!0}).option("every",{type:"number",default:300,describe:"Heartbeat seconds (>0 and <3600); processing expires after one hour"}).option("close",{type:"boolean",default:!1,describe:"Finish with closed instead of active (also on failure or interrupt)"}),async(r)=>{if(mc(r.title),!Number.isFinite(r.every)||r.every<=0||r.every>=3600)throw Error("--every must be greater than 0 and less than 3600 seconds.");let s=process.argv.indexOf("--"),o=s<0?[]:process.argv.slice(s+1);if(!o[0])throw Error("agent run requires -- <command...>");let i=gc(r["bot-token-env"]),a=await Dc(i,r.target,t);process.exitCode=await fd(i,a,o,{every:r.every,close:r.close,...r.title!==void 0?{title:r.title}:{}})}).demandCommand(1,"Choose agent status or agent run.")}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"}],_s=Be.length,Ss="question";function ro(e){let t=e.split(`
|
|
146
|
+
`),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 oo(e,t){let n=e.split(`
|
|
147
|
+
`);if(n.length<2)return e;if(ro(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(`
|
|
148
|
+
`);return r===e?e:r}function dd(e){return e!==void 0&&e.startsWith("_:warning: 同時に複数選ばれているため回答として数えていません — どれか 1 つだけ残してください: ")&&e.endsWith("_")}var io="white_check_mark",ks=`:${io}: `;function bc(e){return`:${Be[e].name}:`}function Cc(e,t){let n=Be[t];for(let r of[bc(t),n.glyph]){if(e.startsWith(`${r} `))return e.slice(r.length+1);if(e===r)return""}return null}function pd(e){return Be.some((t,n)=>Cc(e,n)!==null)}function Nt(e){return e.replace(/\s*\n\s*/g," ")}function Ec(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)=>`${bc(a)} ${Nt(i)}`)),r.length)o.push(""),o.push(...r.map((i,a)=>`(${a+11}) ${Nt(i)}`)),o.push("_11 番目以降はリアクションがないので、返信で答えてください。_");o.push(""),o.push(s?"_下のリアクションを 1 つ押すと回答になります。当てはまるものがなければ、このメッセージの *スレッド* で返信してください (チャンネルへの通常投稿は回答として拾いません)。_":"_下のリアクションを 1 つ押すと回答になります。当てはまるものがなければ、このメッセージに返信してください。_")}else o.push(""),o.push(s?"_このメッセージの *スレッド* で返信してください。本文がそのまま回答になります (チャンネルへの通常投稿は回答として拾いません)。_":"_このメッセージに返信してください。本文がそのまま回答になります。_");return o.join(`
|
|
149
|
+
`)}function Fc(e,t,n){let r=t.answer.split(`
|
|
136
150
|
`).map((s)=>`> ${s}`).join(`
|
|
137
|
-
`);return`${
|
|
151
|
+
`);return`${ks}*${e}*
|
|
138
152
|
_${t.how}で回答済み${n?` (${n})`:""}_
|
|
139
153
|
|
|
140
|
-
${r}`}function
|
|
141
|
-
`),n=t[t.length-1]??"";if(e.startsWith(
|
|
142
|
-
`);if(e.startsWith(
|
|
143
|
-
`);if(!
|
|
144
|
-
`).replace(/^\*/,"").replace(/\*$/,""),c=[],u=[];if(s){let
|
|
145
|
-
`),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
|
|
146
|
-
`);if(n.length<2)return e;if(
|
|
147
|
-
`);return r===e?e:r}function
|
|
148
|
-
`),s?[]:i)}function
|
|
149
|
-
`)}function
|
|
150
|
-
`);if(e.startsWith(
|
|
151
|
-
`).replace(/^\*/,"").replace(/\*$/,""),i=t.length-2,a=
|
|
152
|
-
|
|
154
|
+
${r}`}function wc(e){return e.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&")}function xc(e){if(!e.trim())return"本文が空です (bot 投稿や添付のみのメッセージかもしれません)";let t=e.split(`
|
|
155
|
+
`),n=t[t.length-1]??"";if(e.startsWith(ks))return"回答済みマーク付きですが、引用された回答本文が見つかりません";if(!/_$/.test(n))return"末尾が `ask` の案内文ではありません — このメッセージは `slack ask` で投稿されたものではないか、本文が編集されています";if(!t[0].startsWith(":question: ")&&!t[0].startsWith("*"))return"先頭が質問文 (太字) ではありません — 本文が編集されている可能性があります";return"選択肢の並びを読み取れません — 番号が 1 から連番になっていないか、本文が編集されています"}function kc(e){let t=e.split(`
|
|
156
|
+
`);if(e.startsWith(ks)){let d=t[0].slice(ks.length),l=wc(d.replace(/^\*/,"").replace(/\*$/,"")),f=t.map((h)=>h.startsWith("> ")?h.slice(2):h.startsWith("> ")?h.slice(5):null).filter((h)=>h!==null).map(wc).join(`
|
|
157
|
+
`);if(!f)return{kind:"other"};return{kind:"resolved",question:l,answer:f}}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(`
|
|
158
|
+
`).replace(/^\*/,"").replace(/\*$/,""),c=[],u=[];if(s){let d=t.length-2;if(dd(t[d]))d--;if(t[d]!=="")return{kind:"other"};if(d--,t[d]==="_11 番目以降はリアクションがないので、返信で答えてください。_"){d--;while(d>=0&&/^\(\d+\) /.test(t[d]))u.unshift(t[d].replace(/^\(\d+\) /,"")),d--;if(t[d]!=="")return{kind:"other"};d--}let l=[];while(d>=0){let f=t[d];if(!pd(f))break;l.unshift(f),d--}if(!l.length||l.length>_s)return{kind:"other"};for(let f=0;f<l.length;f++){let h=Cc(l[f],f);if(h===null)return{kind:"other"};c.push(h)}if(t[d]!=="")return{kind:"other"};if(d<i+1)return{kind:"other"};for(let f=0;f<u.length;f++)if(!t.includes(`(${f+11}) ${u[f]}`))return{kind:"other"}}return{kind:"open",question:a,reactable:c,overflow:u,threadOnly:r}}function so(e){return e.normalize("NFKC").replace(/[*_`~]/g,"").trim().replace(/^[\s"'`「『((\[]+/,"").replace(/[\s"'`」』))\]。..!!??、,]+$/,"").replace(/\s+/g," ").trim().toLowerCase()}function _c(e,t){let n=so(e);if(!n)return{kind:"none"};let r=t.map(so),s=new Set;r.forEach((u,d)=>{if(u&&u===n)s.add(d+1)}),Be.forEach((u,d)=>{if(d<t.length&&e.trim()===u.glyph)s.add(d+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=so(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,d)=>u-d);if(!c.length)return{kind:"none"};if(c.length>1)return{kind:"ambiguous",indexes:c};return{kind:"chosen",index:c[0]}}var ao=[{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"}],$D=ao.length;function co(e){let t=e.split(`
|
|
159
|
+
`),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 Sc(e,t){let n=e.split(`
|
|
160
|
+
`);if(n.length<2)return e;if(co(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(`
|
|
161
|
+
`);return r===e?e:r}function Ac(e){return e!==void 0&&e.startsWith("_:warning: 同時に複数選ばれているため回答として数えていません — どれか 1 つだけ残してください: ")&&e.endsWith("_")}var hd="white_check_mark",TD=`:${hd}: `;var Xe=ao,Qt=Xe.length,xn="ballot_box_with_ballot",uo=`:${xn}: `,Tc="_下のリアクションで投票してください (1 人 1 票、押し直しで変更できます)。_",Ic="_下のリアクションで投票してください (当てはまるものを *いくつでも* 押せます)。_",As="_締切: ",$s="_",fo="bar_chart",lo=`:${fo}: `;function Ts(e){return`:${Xe[e].name}:`}function $c(e,t){for(let n of[Ts(t),Xe[t].glyph])if(e.startsWith(`${n} `))return e.slice(n.length+1);return null}function gd(e){return Xe.some((t,n)=>e.startsWith(`${Ts(n)} `)||e.startsWith(`${t.glyph} `))}function Fn(e){return e.replace(/\s*\n\s*/g," ")}function Oc(e,t,n,r={}){let s=!!r.multi,o=r.deadline??"",i=r.invalid??[];if(!n.length||n.length>Qt)throw Error(`poll needs 1..${Qt} choices, got ${n.length}`);let a=[`${uo}*${e}*`];if(t)a.push("",t);if(a.push(""),a.push(...n.map((c,u)=>`${Ts(u)} ${Fn(c)}`)),a.push(""),o)a.push(`${As}${Fn(o)}${$s}`);return a.push(s?Ic:Tc),Sc(a.join(`
|
|
162
|
+
`),s?[]:i)}function Pc(e,t){let n=t.reduce((s,o)=>s+o.count,0),r=[`${lo}*${e}*`,`_投票終了 (計 ${n} 票)_`,""];return r.push(...t.map((s,o)=>`${Ts(o)} ×${s.count} ${Fn(s.choice)}`)),r.join(`
|
|
163
|
+
`)}function Rc(e){let t=e.split(`
|
|
164
|
+
`);if(e.startsWith(lo)){let f=t[0].slice(lo.length).replace(/^\*/,"").replace(/\*$/,""),h=[];for(let m=0;m<Xe.length;m++){let p=t.map((F)=>$c(F,m)).find((F)=>F!==null&&F.startsWith("×"));if(p===void 0)break;let y=/^×(\d+) (.*)$/.exec(p);if(!y)return{kind:"other"};h.push({choice:y[2],count:Number(y[1])})}if(!h.length)return{kind:"other"};return{kind:"closed",question:f,tallies:h}}let n=t[t.length-1]??"",r;if(n===Tc)r=!1;else if(n===Ic)r=!0;else return{kind:"other"};if(t[0].startsWith(uo))t[0]=t[0].slice(uo.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(`
|
|
165
|
+
`).replace(/^\*/,"").replace(/\*$/,""),i=t.length-2,a=co(e);if(Ac(t[i]))i--;let c="",u=t[i];if(u!==void 0&&u.startsWith(As)&&u.endsWith($s)&&u.length>As.length+$s.length)c=u.slice(As.length,-$s.length),i--;if(t[i]!=="")return{kind:"other"};i--;let d=[];while(i>=0){let f=t[i];if(!gd(f))break;d.unshift(f),i--}if(!d.length||d.length>Qt)return{kind:"other"};let l=[];for(let f=0;f<d.length;f++){let h=$c(d[f],f);if(h===null)return{kind:"other"};l.push(h)}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 Mc(e,t,n,r){let s=new Map(t.map((u)=>[u.name,u.users])),o=e.map((u,d)=>(s.get(Xe[d].name)??[]).filter((l)=>!n.has(l))),i=[];if(!r){let u=new Map;for(let d of o)for(let l of d)u.set(l,(u.get(l)??0)+1);for(let[d,l]of u)if(l>1)i.push(d)}let a=new Set(i),c=o.map((u)=>u.filter((d)=>!a.has(d)));return{tallies:e.map((u,d)=>({choice:u,count:c[d].length})),voters:c,ambiguous:i}}function md(e=process.env){return!!e.VITEST||e.NODE_ENV==="test"||!!e.BUN_TEST}var Nc={isTestEnv:()=>md(),sleep:(e)=>Nc.isTestEnv()?Promise.resolve():new Promise((t)=>setTimeout(t,e))};function Dd(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 po(e,t,n,r=Dd()){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 Nc.sleep(r)}}import{spawnSync as Bc}from"node:child_process";import{chmodSync as yd,mkdirSync as wd}from"node:fs";import{homedir as bd,hostname as Cd}from"node:os";import{basename as Ed,dirname as Fd,join as xd}from"node:path";function go(){return!/^(0|off|false|no)$/i.test(process.env.SLACK_TERM_ATTRIBUTION??"")}var Lc={claude:"claude-code",codex:"codex",gemini:"gemini",opencode:"opencode","cursor-agent":"cursor-agent",aider:"aider",amp:"amp"};function kd(e){try{let n=(Bc("ps",["-o","ppid=,comm=","-p",String(e)],{encoding:"utf8",timeout:2000}).stdout??"").trim().match(/^(\d+)\s+(.+)$/);if(!n)return;return{pid:e,ppid:Number(n[1]),comm:Ed(n[2].trim())}}catch{return}}function _d(){let e=process.ppid;for(let t=0;t<12&&e>1;t++){let n=kd(e);if(!n)return;if(Lc[n.comm])return n;e=n.ppid}return}function vc(e){let t=Number(e);return Number.isInteger(t)&&t>0?t:void 0}function jc(e=process.env){let t={pid:process.pid,host:Sd(),cwd:process.cwd()},n=e.SLACK_TERM_AGENT_CLI||void 0;if(!n&&e.AI_AGENT)n=e.AI_AGENT.split("_")[0]||void 0;if(!n&&e.CLAUDECODE==="1")n="claude-code";let r=vc(e.SLACK_TERM_AGENT_PID)??vc(e.CLAUDE_PID);if(!r||!n){let i=_d();if(i)r??=i.pid,n??=Lc[i.comm]}if(n)t.cli=n;if(r)t.agentPid=r;let s=e.SLACK_TERM_AGENT_SESSION||e.CLAUDE_CODE_SESSION_ID;if(s)t.sessionId=s;let o=Ad(t.cwd);if(o)t.gitBranch=o;return t}function Sd(){try{return Cd()}catch{return""}}function Ad(e){try{let t=Bc("git",["rev-parse","--abbrev-ref","HEAD"],{cwd:e,encoding:"utf8",timeout:2000});return(t.status===0?(t.stdout??"").trim():"")||void 0}catch{return}}var $d="slack_term_sent";function Wc(e,t){let n={kind:e,pid:t.pid,host:t.host,cwd:t.cwd};if(t.agentPid)n.agent_pid=t.agentPid;if(t.gitBranch)n.git_branch=t.gitBranch;if(t.cli)n.cli=t.cli;if(t.sessionId)n.session_id=t.sessionId;return{event_type:$d,event_payload:n}}function kn(){if(process.env.SLACK_TERM_SENT_DB)return process.env.SLACK_TERM_SENT_DB;return xd(process.env.HOME||bd(),".config","slack-cli","sent.sqlite")}function Td(e){try{if(typeof globalThis.Bun<"u"){let{Database:n}=Ln("bun:sqlite");return new n(e,{create:!0})}let t=process.getBuiltinModule?.("node:sqlite");if(t?.DatabaseSync)return new t.DatabaseSync(e)}catch{}return}var Id=`
|
|
166
|
+
CREATE TABLE IF NOT EXISTS sent (
|
|
167
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
168
|
+
kind TEXT NOT NULL,
|
|
169
|
+
team TEXT,
|
|
170
|
+
channel TEXT NOT NULL,
|
|
171
|
+
target TEXT,
|
|
172
|
+
ts TEXT NOT NULL,
|
|
173
|
+
thread_ts TEXT,
|
|
174
|
+
permalink TEXT,
|
|
175
|
+
text TEXT NOT NULL,
|
|
176
|
+
sent_at INTEGER NOT NULL,
|
|
177
|
+
pid INTEGER NOT NULL,
|
|
178
|
+
agent_pid INTEGER,
|
|
179
|
+
host TEXT,
|
|
180
|
+
cwd TEXT NOT NULL,
|
|
181
|
+
git_branch TEXT,
|
|
182
|
+
cli TEXT,
|
|
183
|
+
session_id TEXT,
|
|
184
|
+
as_bot INTEGER NOT NULL DEFAULT 0,
|
|
185
|
+
collected_at INTEGER,
|
|
186
|
+
answer TEXT,
|
|
187
|
+
answer_exit INTEGER,
|
|
188
|
+
delivered_at INTEGER
|
|
189
|
+
);
|
|
190
|
+
CREATE INDEX IF NOT EXISTS sent_msg ON sent(channel, ts);
|
|
191
|
+
CREATE INDEX IF NOT EXISTS sent_at ON sent(sent_at);
|
|
192
|
+
`;function Uc(){let e=kn();try{wd(Fd(e),{recursive:!0})}catch{}let t=Td(e);if(!t)return;try{yd(e,384)}catch{}try{return t.exec(Id),t}catch{try{t.close()}catch{}return}}function Kc(e){if(!go())return!1;let t=Uc();if(!t)return console.error(` (送信ログに記録できませんでした: ${mo} — ${kn()})`),!1;try{let n=e.attribution;return t.prepare(`INSERT INTO sent (kind, team, channel, target, ts, thread_ts, permalink, text, sent_at, pid, agent_pid, host, cwd, git_branch, cli, session_id, as_bot)
|
|
193
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(e.kind,e.team??null,e.channel,e.target??null,e.ts,e.threadTs??null,e.permalink??null,e.text,Date.now(),n.pid,n.agentPid??null,n.host||null,n.cwd,n.gitBranch??null,n.cli??null,n.sessionId??null,e.asBot?1:0),!0}catch(n){return console.error(` (送信ログに記録できませんでした: ${n instanceof Error?n.message:String(n)})`),!1}finally{try{t.close()}catch{}}}var mo="送信ログを開けません: SQLite が使えないランタイムです (bun、または node >= 22.5 の node:sqlite が必要)";function Jc(e){let t=Uc();if(!t)return;try{let n=[],r=[];if(e.text)n.push("text LIKE ? ESCAPE '\\'"),r.push(`%${ho(e.text)}%`);if(e.channel)n.push("(channel = ? OR target = ?)"),r.push(e.channel,e.channel);if(e.sinceMs!==void 0)n.push("sent_at >= ?"),r.push(e.sinceMs);if(e.session)n.push("session_id LIKE ? ESCAPE '\\'"),r.push(`${ho(e.session)}%`);if(e.cwd)n.push("cwd LIKE ? ESCAPE '\\'"),r.push(`${ho(e.cwd)}%`);if(e.kind)n.push("kind = ?"),r.push(e.kind);let s=`SELECT * FROM sent${n.length?` WHERE ${n.join(" AND ")}`:""} ORDER BY sent_at DESC, id DESC LIMIT ?`;return r.push(e.limit??50),t.prepare(s).all(...r)}finally{try{t.close()}catch{}}}function ho(e){return e.replace(/[\\%_]/g,(t)=>`\\${t}`)}function zc(e,t=Date.now()){let n=e.trim().match(/^(\d+(?:\.\d+)?)\s*(s|m|h|d|w)$/i);if(n){let s={s:1000,m:60000,h:3600000,d:86400000,w:604800000}[n[2].toLowerCase()];return t-Number(n[1])*s}let r=Date.parse(e);return Number.isNaN(r)?void 0:r}class Bt extends Error{retryAfter;constructor(e){super(`Slack rate limited — retry after ${e}s`);this.name="RateLimitError",this.retryAfter=e}}function wo(){return(process.env.SLACK_API_BASE??"https://slack.com/api").replace(/\/$/,"")}async function Xc(e,t,n,r){r=e.startsWith("xoxc-")?r??pt():void 0;let s={};if(r)s.Cookie=`d=${r}`;let o=await fetch(`${wo()}/${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 Bt(isNaN(a)?60:a)}let i=await o.json();if(i.ok!==!0){let a=i.error??"unknown";if(a==="ratelimited")throw new Bt(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.
|
|
194
|
+
Attach it: slack auth firefox (Linux/macOS/Windows) or slack auth chrome (macOS/Linux)
|
|
153
195
|
Or replace the token with an xoxp- user token:
|
|
154
|
-
slack auth login`);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"}.
|
|
196
|
+
slack auth login`);if((a==="missing_scope"||a==="cannot_dm_bot")&&e.startsWith("xoxb-")){if(t.startsWith("agents.sessions."))throw Error(`Slack error on ${t}: ${a}. Agent sessions need a granular bot token with chat:write and app membership in the channel.`);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"}.
|
|
155
197
|
Tailing/DMing people and listing users need a user session, not a bot token.
|
|
156
198
|
Switch workspace: slack auth ls then slack auth use <name>
|
|
157
|
-
Or import your Slack desktop session: slack auth login`)
|
|
199
|
+
Or import your Slack desktop session: slack auth login`)}throw Error(`Slack error on ${t}: ${a}`)}return i}async function Od(e,t,n,r){let s={};if(r)s.Cookie=`d=${r}`;let o=await fetch(`${wo()}/${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 Bt(isNaN(a)?60:a)}let i=await o.json();if(i.ok!==!0){let a=i.error??"unknown";if(a==="ratelimited")throw new Bt(60);if((a==="invalid_auth"||a==="not_authed")&&!e.startsWith("xoxc-"))throw Error(`The draft API requires a desktop app session token (xoxc-).
|
|
158
200
|
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.
|
|
159
|
-
Attach it with: slack auth
|
|
201
|
+
Attach it with: slack auth firefox (Linux/macOS/Windows) or slack auth chrome (macOS/Linux)`);throw Error(`Slack error on ${t}: ${a}`)}return i}function Lt(e,t,n={},r){let s=new URLSearchParams({token:e,...n});return Od(e,t,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s.toString()},r)}function ae(e,t,n,r){let s=new URLSearchParams(n).toString();return Xc(e,`${t}?${s}`,{method:"GET"},r)}function Le(e,t,n,r){return Xc(e,t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)},r)}async function Gc(e,t){let n=await ae(e,"auth.test",{},t);return{team:n.team??"",teamId:n.team_id??"",url:n.url??"",user:n.user??"",userId:n.user_id??""}}async function Yc(e,t){t=e.startsWith("xoxc-")?t??pt():void 0;let n={Authorization:`Bearer ${e}`};if(t)n.Cookie=`d=${t}`;let r=await fetch(`${wo()}/auth.test`,{method:"GET",headers:n});if(r.status===429){let i=parseInt(r.headers.get("retry-after")??"60",10);throw new Bt(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 Qe(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 ae(e,"conversations.history",a,o)}async function Ge(e,t,n,r=50,s){return ae(e,"conversations.replies",{channel:t,ts:n,limit:String(r)},s)}async function Vc(e,t,n){return ae(e,"files.info",{file:t},n)}async function Zc(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 ae(e,"files.list",r,n)}async function Qc(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 Lt(e,"lists.records.list",s,r)}async function eu(e,t,n,r,s){return ae(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 tu(e,t,n){return eu(e,t,100,1,n)}async function bo(e,t,n,r){let o=1,i=[],a={ok:!0,messages:{}};while(!0){let u=await eu(e,t,100,o,r),d=_n(u,["messages","matches"]),l=Array.isArray(d)?d:[];i.push(...l);let f=Number(_n(u,["messages","paging","pages"])??1);if(a=u,l.length===0||o>=f||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 Is(e,t,n,r,s,o,i,a){let c=i?{channel:t,text:n}:{channel:t,text:n,blocks:[{type:"markdown",text:n}]};if(r!==void 0)c.thread_ts=r;if(s&&r!==void 0)c.reply_broadcast=!0;return(await nu(e,"chat.postMessage",c,a,o)).ts??""}function Pd(e){return e instanceof Error&&/: (invalid_metadata\w*|metadata_\w+)$/.test(e.message)}async function nu(e,t,n,r,s){if(!r)return Le(e,t,n,s);try{return await Le(e,t,{...n,metadata:r},s)}catch(o){if(!Pd(o))throw o;return Le(e,t,n,s)}}async function su(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 Le(e,"chat.scheduleMessage",i,o)).scheduled_message_id??""}async function ru(e,t,n){let r={};if(t)r.channel=t;return ae(e,"chat.scheduledMessages.list",r,n)}async function ou(e,t,n,r){await Le(e,"chat.deleteScheduledMessage",{channel:t,scheduled_message_id:n},r)}async function Sn(e,t,n,r){return(await ae(e,"chat.getPermalink",{channel:t,message_ts:n},r)).permalink??""}async function en(e,t,n,r,s,o,i){return(await nu(e,"chat.update",o?{channel:t,ts:n,text:r}:{channel:t,ts:n,text:r,blocks:[{type:"markdown",text:r}]},i,s)).ts??n}async function iu(e,t,n,r){await Le(e,"chat.delete",{channel:t,ts:n},r)}async function tn(e,t,n,r,s){await Le(e,"reactions.add",{channel:t,timestamp:n,name:r},s)}async function au(e,t,n,r){return((await ae(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 An(e,t,n,r,s){await Le(e,"reactions.remove",{channel:t,timestamp:n,name:r},s)}async function cu(e,t,n=!1,r){let s=await Le(e,"conversations.create",{name:t,is_private:n},r);return{id:s.channel?.id??"",name:s.channel?.name??t}}async function uu(e,t,n,r){await Le(e,"conversations.invite",{channel:t,users:n.join(",")},r)}async function $n(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 ae(e,"conversations.list",s,t);if(n.push(...o.channels??[]),r=o.response_metadata?.next_cursor??"",!r)break}return{channels:n}}async function st(e,t,n){let s=(await Le(e,"conversations.open",{users:t},n)).channel?.id;if(!s)throw Error(`Failed to open DM with user ${t}`);return s}async function lu(e,t,n){let r="";while(!0){let s={types:"im",limit:"200"};if(r)s.cursor=r;let o=await ae(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 Do(e,t,n,r){let s=await lu(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 vt(e){return e.toLowerCase().replace(/[-_\s]/g,"")}function Hc(e,t){let n=vt(e.name??""),r=vt(e.real_name??e.profile?.real_name??""),s=vt(e.profile?.display_name??"");return n===t||r===t||!!s&&s===t}var fu=200;async function du(e,t,n){let r=0,s=new Set,o="";while(!0){let d={limit:"200"};if(o)d.cursor=o;let l=await ae(e,"users.list",d,n);for(let f of l.members??[]){if(r++,f.id)s.add(f.id);if(Hc(f,t))return{id:f.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 d={types:"im",limit:"200"};if(u)d.cursor=u;let l=await ae(e,"conversations.list",d,n);for(let f of l.channels??[]){let h=f.user;if(!h||s.has(h))continue;if(i>=fu){c=!0;break}s.add(h),i++;let m;try{m=(await ae(e,"users.info",{user:h},n)).user}catch(p){if(p instanceof Bt)throw p;a++;continue}if(m&&Hc(m,t))return{id:h,dm:String(f.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 pu(e,t){if(t.workspaceCount===0)return Error(`Cannot resolve ${e}: users.list returned no members at all, so nothing could have matched.
|
|
160
202
|
`+`That is a token or scope fault, not a wrong handle — this says nothing about whether ${e} exists.
|
|
161
|
-
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 ${
|
|
203
|
+
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 ${fu} 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.
|
|
162
204
|
`+(r.length?`This search was incomplete: ${r.join("; ")}.
|
|
163
205
|
`:"")+`Slack Connect people from another workspace are not in users.list, so if they never
|
|
164
206
|
DMed you they cannot be found by name at all. Look them up and use their ID:
|
|
165
|
-
slack user ls --external`)}async function
|
|
166
|
-
`)}catch{}}function
|
|
167
|
-
`)[0]??"",emoji:
|
|
168
|
-
`;case"t":return"\t";case"\\":case"¥":return n==="¥"?"¥":"\\";default:return t}})}function
|
|
169
|
-
`)),o=await
|
|
170
|
-
⚠ 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
|
|
171
|
-
`)){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
|
|
172
|
-
`)}function
|
|
173
|
-
`),l=
|
|
174
|
-
`+
|
|
175
|
-
`):""),
|
|
176
|
-
\uD83D\uDCCE ${
|
|
177
|
-
${
|
|
178
|
-
`)[0]??"",
|
|
179
|
-
`)[0]?.slice(0,60)}`:"";console.log(`${
|
|
207
|
+
slack user ls --external`)}async function rt(e,t,n){let r=t.startsWith("@")?t.slice(1):t;if(yo(r))return r;if(!t.startsWith("@"))throw Error(`Expected @user or a user ID, got: ${t}`);let s=vt(r),o=await ae(e,"auth.test",{},n);if(s==="you"||s==="me"||vt(o.user??"")===s){if(!o.user_id)throw Error("auth.test did not return user_id");return o.user_id}let i=await du(e,s,n);if(i.id)return i.id;throw pu(t,i)}function jt(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 Rd(e){return jt(e)?.channel}function qc(e){return/^[CDG][A-Z0-9]{8,}$/.test(e)}function yo(e){return/^[UW][A-Z0-9]{6,}$/.test(e)}async function De(e,t,n){let r=Rd(t);if(r)return r;if(!t.startsWith("@")&&!t.startsWith("#")){if(qc(t))return t;if(yo(t))return Do(e,t,n);throw Error(`Target must start with # or @ (or be a Slack URL/ID), got: ${t}`)}if(t.startsWith("#")&&qc(t.slice(1)))return t.slice(1);let s=t.startsWith("@"),o=t.slice(1),i=vt(o);if(s){if(yo(o))return Do(e,o,n);let u=await ae(e,"auth.test",{},n);if(i==="you"||i==="me"||vt(u.user??"")===i){let f=u.user_id;if(!f)throw Error("auth.test did not return user_id");return await lu(e,f,n)||st(e,f,n)}let l=await du(e,i,n);if(!l.id)throw pu(t,l);if(l.dm)return l.dm;return Do(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 d=await ae(e,"conversations.list",u,n);for(let l of d.channels??[])if(String(l.name??"").toLowerCase()===a)return String(l.id??"");if(c=d.response_metadata?.next_cursor??"",!c)break}throw Error(`channel not found: ${t}`)}async function Tn(e,t,n){try{let r=await ae(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 $e(e,t,n){try{let r=await ae(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 hu(e,t){let n=[],r="";while(!0){let s={limit:"200"};if(r)s.cursor=r;let o=await ae(e,"users.list",s,t);if(n.push(...o.members??[]),r=o.response_metadata?.next_cursor??"",!r)break}return{members:n}}async function gu(e,t,n){let r=[],s="";while(!0){let o={channel:t,limit:"200"};if(s)o.cursor=s;let i=await ae(e,"conversations.members",o,n);if(r.push(...i.members??[]),s=i.response_metadata?.next_cursor??"",!s)break}return r}async function In(e,t){return Lt(e,"drafts.list",{},t)}async function mu(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 Lt(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 Du(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 Lt(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 yu(e,t,n){return Lt(e,"conversations.info",{channel:t},n)}async function On(e,t,n){return ae(e,"users.info",{user:t},n)}async function Pn(e,t,n){return ae(e,"conversations.info",{channel:t},n)}async function wu(e,t,n){let r=(Date.now()/1000).toFixed(6);return Lt(e,"drafts.delete",{draft_id:t,client_last_updated_ts:r},n)}async function Co(e,t){let n=await Lt(e,"auth.test",{},t);return{userId:String(n.user_id??""),teamId:String(n.team_id??"")}}async function bu(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),d=await ae(e,"files.getUploadURLExternal",{filename:u,length:String(c.size)},s),{upload_url:l,file_id:f}=d;if(!l||!f)throw Error("files.getUploadURLExternal returned no upload_url/file_id");let h=i(n),m=await fetch(l,{method:"POST",headers:{"Content-Type":"application/octet-stream"},body:h});if(!m.ok)throw Error(`Upload PUT failed: ${m.status} ${m.statusText}`);let p={files:[{id:f,title:r.title??u}],channel_id:t};if(r.threadTs)p.thread_ts=r.threadTs;if(r.initialComment)p.initial_comment=r.initialComment;let y=await Le(e,"files.completeUploadExternal",p,s),F={fileId:f},C=y.files?.[0]?.permalink;if(C)F.permalink=C;return F}function _n(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 Jd,readFileSync as zd}from"node:fs";import{homedir as Hd}from"node:os";import{join as qd}from"node:path";import{existsSync as Md,mkdirSync as Nd,readFileSync as vd,writeFileSync as Bd}from"node:fs";import{homedir as Ld}from"node:os";import{dirname as jd,join as Wd}from"node:path";var Ud=3600000,Os={now:()=>Date.now(),path:()=>Wd(process.env.HOME||Ld(),".config","slack-cli","cache.json")},Ps=!0,gt;function Cu(){return{channels:{},users:{}}}function Eo(){if(gt)return gt;if(gt=Cu(),!Ps)return gt;try{let e=Os.path();if(!Md(e))return gt;let t=JSON.parse(vd(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")gt[n][s]={value:o.value,expires:o.expires}}}catch{gt=Cu()}return gt}function Kd(e){if(!Ps)return;try{let t=Os.path();Nd(jd(t),{recursive:!0}),Bd(t,JSON.stringify(e,null,2)+`
|
|
208
|
+
`)}catch{}}function Eu(e,t){return e?`${e} ${t}`:void 0}function Rs(e,t,n){if(!Ps)return;let r=Eu(t,n);if(!r)return;let s=Eo()[e][r];if(!s)return;if(s.expires<=Os.now()){delete Eo()[e][r];return}return s.value}function Ms(e,t,n,r,s=Ud){if(!Ps)return;let o=Eu(t,n);if(!o)return;let i=Eo();i[e][o]={value:r,expires:Os.now()+s},Kd(i)}var Fo={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"}},nn=["done","dropped","doing","pending"],_u=["alert","needs-discussion","waiting","blocked"];function Xd(){return qd(process.env.HOME||Hd(),".config","slack-cli","todo.json")}function Ns(e){return e.replace(/^:+|:+$/g,"")}function Rn(e=Xd()){let t={marker:Fo.marker,progress:{...Fo.progress},flags:{...Fo.flags}};try{if(!Jd(e))return t;let n=JSON.parse(zd(e,"utf8"));if(typeof n.marker==="string"&&n.marker.trim())t.marker=Ns(n.marker.trim());for(let r of nn){let s=n.progress?.[r];if(typeof s==="string"&&s.trim())t.progress[r]=Ns(s.trim())}for(let r of _u){let s=n.flags?.[r];if(typeof s==="string"&&s.trim())t.flags[r]=Ns(s.trim())}}catch{}return t}function Fu(e,t,n=!1){return`${n?"-":""}${t?"has":"hasmy"}::${Ns(e)}:`}function Su(e,t,n={}){let r=n.shared===!0,s=(a)=>Fu(a,r),o=(a)=>Fu(a,r,!0),i=[];if(e==="untriaged")i.push(s(t.marker),...nn.map((a)=>o(t.progress[a])));else if(e==="stuck")i.push(s(t.marker),o(t.progress.done),o(t.progress.dropped),`(${_u.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=nn.indexOf(e);i.push(s(t.progress[e]));for(let c of nn.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 Gd=3,Yd={sleep:(e)=>Vd()?Promise.resolve():new Promise((t)=>setTimeout(t,e))};function Vd(){return!!process.env.VITEST||!1||!!process.env.BUN_TEST}async function xe(e,t,n=Gd){for(let r=0;;r++)try{return await t()}catch(s){if(!(s instanceof ze))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 Yd.sleep(s.retryAfter*1000)}}var xu=new Map;async function Au(e,t){let n=xu.get(e);if(n)return n;let r=await xe("auth.test",()=>Zt(e,t)),s={userId:r.userId,teamId:r.teamId};return xu.set(e,s),s}async function $u(e,t){return(await Au(e,t)).userId}async function xo(e,t){try{return(await Au(e,t)).teamId}catch{return""}}async function ko(e,t,n,r){if(!t.startsWith("#"))return n(e,t,r);let s=await xo(e,r),o=Rs("channels",s,t);if(o)return o;let i=await xe("resolveChannel",()=>n(e,t,r));return Ms("channels",s,t,i),i}async function Tu(e,t,n,r){let s=await xo(e,r),o=Rs("users",s,t);if(o)return o;let i=await xe("users.info",()=>n(e,t,r));if(i&&i!==t)Ms("users",s,t,i);return i}async function Iu(e,t,n,r){let s=await xo(e,r),o=Rs("users",s,`tz:${t}`);if(o)return o==="?"?null:o;let i=null;try{let a=await xe("users.info",()=>n(e,t,r));if(a?.user?.is_bot===!0||t==="USLACKBOT")return ku(s,t,null);let c=a?.user?.tz;i=typeof c==="string"&&c?c:null}catch{return null}return ku(s,t,i)}function ku(e,t,n){return Ms("users",e,`tz:${t}`,n??"?"),n}async function Ou(e,t,n,r,s,o){let i=s.progress[r],a=await $u(e,o),c=await xe("reactions.get",()=>Wa(e,t,n,o)),u=new Set(c.filter((h)=>h.users.includes(a)).map((h)=>h.name)),d=nn.map((h)=>s.progress[h]).filter((h)=>u.has(h));if(d.length===1&&d[0]===i)return{noop:!0,removed:[],leftover:[]};if(!u.has(i))await xe("reactions.add",()=>cs(e,t,n,i,o));let l=[],f=[];for(let h of d){if(h===i)continue;try{await xe("reactions.remove",()=>us(e,t,n,h,o)),l.push(h)}catch{f.push(h)}}return{noop:!1,added:r,removed:l,leftover:f}}async function Pu(e,t,n,r,s,o,i){let a=s.flags[r];if(o)await xe("reactions.remove",()=>us(e,t,n,a,i));else await xe("reactions.add",()=>cs(e,t,n,a,i));return a}var _o=1000;async function Ru(e,t,n,r={}){let s=r.limit??_o,o=r.cookie,i=await $u(e,o),a=nn.map((f)=>n.progress[f]),c=[],u=0,d,l=!1;while(u<s){let f=Math.min(200,s-u),h=await xe("conversations.history",()=>wn(e,t,f,void 0,d,o)),m=h.messages??[];u+=m.length;for(let p of m){let y=String(p.ts??"");if(!y)continue;let F=new Set((p.reactions??[]).filter((T)=>(T.users??[]).map(String).includes(i)).map((T)=>String(T.name??""))),C=a.filter((T)=>F.has(T));if(C.length<2)continue;c.push({ts:y,text:String(p.text??"").split(`
|
|
209
|
+
`)[0]??"",emoji:C,keep:C[0]})}if(d=h.response_metadata?.next_cursor||void 0,!d||m.length===0)break;if(u>=s){l=!0;break}}if(r.fix)for(let f of c)try{try{await xe("reactions.add",()=>cs(e,t,f.ts,f.keep,o))}catch(h){if(!(h instanceof Error)||!/already_reacted/.test(h.message))throw h}for(let h of f.emoji){if(h===f.keep)continue;await xe("reactions.remove",()=>us(e,t,f.ts,h,o))}f.fixed=!0}catch(h){f.fixed=!1,f.error=h instanceof Error?h.message:String(h)}return{scanned:u,findings:c,truncated:l}}var Zd=!0,Qd;function So(e){if(Zd=e,!e)Qd=void 0}function mt(e){return e.replace(new RegExp(`[${"\\\\¥"}](.)`,"gs"),(t,n)=>{switch(n){case"n":return`
|
|
210
|
+
`;case"t":return"\t";case"\\":case"¥":return n==="¥"?"¥":"\\";default:return t}})}function Wt(e){return e.toLowerCase().replace(/[-_\s]/g,"")}function Dt(e){return e&&typeof e==="object"&&!Array.isArray(e)?e:{}}function ep(e,t){let n=Wt(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&&Wt(o)===n)return!0;let s=typeof r.email==="string"?r.email.toLowerCase():"";return s!==""&&s===t.toLowerCase()}function tp(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=Wt(r);if(s.length>=2)n.add(s)}return[...n]}function np(e,t){let n=Wt(e),r,s=!1;for(let o of t){let i=typeof o.id==="string"?o.id:"";if(!i)continue;for(let a of tp(o)){let c=-1;if(n===a)c=e.length;else for(let u of Nu)if(e.length>u.length&&e.endsWith(u)&&Wt(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:To(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 Ut(e,t,n,r){let s=`[${vu}ー]+`,o=`${s}(?:[._-]+${s})*`,i=new RegExp(`(?<![A-Za-z0-9._@<-])@(${o})`,"gu"),a=new Set;for(let C of t.matchAll(i))a.add(C[1]);if(a.size===0)return{text:t,resolved:[],unresolved:[]};let c=new Map;for(let C of a)c.set(C,{status:"pending"});let u=(C)=>{for(let T of a){if(c.get(T).status!=="pending")continue;if($o(T)){let S=np(T,C);if(S==="ambiguous")c.set(T,{status:"ambiguous"});else if(S)c.set(T,{status:"resolved",userId:S.userId,matchLen:S.matchLen,display:S.display})}else{let S=C.filter((K)=>ep(K,T)),v=new Set(S.map((K)=>typeof K.id==="string"?K.id:"").filter(Boolean));if(v.size===1){let K=S.find((P)=>typeof P.id==="string");c.set(T,{status:"resolved",userId:K.id,matchLen:T.length,display:To(K)})}else if(v.size>1)c.set(T,{status:"ambiguous"})}}},d=!1;try{let C=await ps(e,r);u((C.members??[]).map(Dt)),d=!0}catch{d=!1}let l=[...a].some((C)=>c.get(C).status==="pending"),f=!1,h=!0;if(l&&n){f=!0;try{let C=await zr(e,n,r),T=[];for(let S of C){let v=Dt(await Hr(e,S,r)),K=Dt(v.user);if(typeof K.id!=="string")K.id=S;T.push(K)}u(T)}catch{h=!1}}let m=d&&(n?f&&h:!0),p=[],y=[];for(let C of a){let T=c.get(C);if(T.status==="resolved")p.push({surface:`@${C.slice(0,T.matchLen)}`,display:T.display,userId:T.userId});else if(T.status==="ambiguous")y.push({surface:`@${C}`,reason:"ambiguous"});else y.push({surface:`@${C}`,reason:m?"no-match":"unavailable"})}return{text:t.replace(i,(C,T)=>{let S=c.get(T);if(S&&S.status==="resolved")return`<@${S.userId}>${T.slice(S.matchLen)}`;return C}),resolved:p,unresolved:y}}function Mn(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 Mu(e,t,n,r={}){let s=r.warn??((i)=>process.stderr.write(`${i}
|
|
211
|
+
`)),o=await Ut(e,t,n,r.cookie);for(let i of Mn(o.unresolved))s(`warn: ${i}`);return o.text}var Nu=["さん","さま","様","君","くん","ちゃん","氏","先生","先輩","殿","老师","老師","兄","姐","哥","姐妹"],vu="\\p{Script=Han}\\p{Script=Hiragana}\\p{Script=Katakana}A-Za-z0-9";function $o(e){return/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}]/u.test(e)}function sp(e){let t=[],n=new RegExp(`([${vu}]{1,12})(${Nu.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 rp(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=Wt(s);if(o.length>=2)n.add(o)}}return[...n]}function op(e,t){let n=Wt(e);if(n.length<2)return;for(let r of t)if(n===r)return r;if($o(e)){for(let r of t)if(n.includes(r)||r.includes(n))return r}return}function To(e){return[Dt(e.profile).display_name,e.real_name,e.name].filter((r)=>typeof r==="string"&&r!=="")[0]??String(e.id??"?")}async function Bu(e,t,n){let r=sp(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 ps(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:rp(u),display:To(u)})).filter((u)=>u.id!==""),a=[],c=new Set;for(let{ref:u,honorific:d}of r)for(let l of i){let f=op(u,l.forms);if(!f)continue;if(s.has(l.id)||c.has(l.id))break;c.add(l.id),a.push({surface:$o(u)?`${f}${d}`:u,display:l.display,userId:l.id});break}return a}async function sn(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),d=u.search(/[>|]/),l=d===-1?u:u.slice(0,d);if(l.length>=9)o.push(l);a=c+1}for(let c of o){if(!n.has(c))n.set(c,await ds(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 Nn(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 Lu(e,t=new Date){let n=new Date(e*1000),r=Ao(t),s=Ao(new Date(t.getTime()-86400000)),o=Ao(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 Ao(e){return`${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`}function Io(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 ju(e=new Date,t){let n=process.env.SLACK_QUIET_TZ??"Asia/Tokyo",r=!!t&&ip(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 h=new Intl.DateTimeFormat("en-GB",{timeZone:s,hour12:!1,weekday:"short",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"});c=h.format(e),a=Number(h.formatToParts(e).find((m)=>m.type==="hour")?.value??"12")}catch{return null}let u=o>i?a>=o||a<i:a>=o&&a<i,d=r?`${s}, recipient`:`${s}, sender — recipient's timezone unknown`,l=`\uD83D\uDD50 ${c} (${d})`;if(!u)return l;return`${l}
|
|
212
|
+
⚠ 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 ip(e){try{return new Intl.DateTimeFormat("en-GB",{timeZone:e}),!0}catch{return!1}}function vn(e){if(!Yu(e))return;let t=cp(e,"utf8");for(let n of t.split(`
|
|
213
|
+
`)){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 dp(e){up(e,{recursive:!0});let t=yt(e,".gitignore");if(!Yu(t))Vu(t,`*
|
|
214
|
+
`)}function pp(){vn(yt(Wu(),".slack-cli",".env.local")),vn(yt(Wu(),".config/slack-cli",".env")),vn(yt(process.cwd(),".slack-cli",".env.local")),vn(yt(process.cwd(),".env.local")),vn(yt(process.cwd(),".env"))}function hp(e){return ap("sha256").update(e).digest("hex")}function O(e){return e&&typeof e==="object"&&!Array.isArray(e)?e:{}}function Y(e){return Array.isArray(e)?e:[]}function Bs(e){return Number(e.ts??0)}async function Zu(e,t,n){let r=t.user;if(typeof r==="string"){if(!n.has(r))n.set(r,await $e(e,r));return n.get(r)??r}return typeof t.username==="string"?t.username:"bot"}function Po(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 Mo(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"),d=String(s.getUTCSeconds()).padStart(2,"0"),l=n.padEnd(6,"0").slice(0,6);return`${o}-${i}-${a}T${c}:${u}:${d}.${l}`}function No(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 gp(e){return/^\d{4}-\d{2}-\d{2}T/.test(e)?No(e):e}async function Ws(e,t,n,r,s){let o=typeof t.ts==="string"?t.ts:`${Bs(t)}.000000`,i=Mo(o),a="?";if(typeof t.user==="string"){let C=t.user,T="@"+C;if(!n.has(T)){let S=await Tu(e,C,async(v,K,P)=>(await Tn(v,K,P))[1],s);n.set(T,S)}a=n.get(T)??C}else if(typeof t.username==="string")a=t.username;let c=typeof t.text==="string"?t.text:"",d=Nn(await sn(e,c,n,s)).split(`
|
|
215
|
+
`),l=d[0]+(d.length>1?`
|
|
216
|
+
`+d.slice(1).map((C)=>` ${C}`).join(`
|
|
217
|
+
`):""),f=r?`${r} @${a}`:`@${a}`,h=Y(t.reactions).map(O).map((C)=>{let T=typeof C.name==="string"?C.name:"",S=Number(C.count??Y(C.users).length??0);return T?`:${T}:\xD7${S}`:""}).filter(Boolean).join(" "),m=Y(t.files).map(O).map((C)=>{let T=typeof C.name==="string"?C.name:typeof C.title==="string"?C.title:"(file)",S=typeof C.size==="number"?` (${Us(C.size)})`:"",v=typeof C.id==="string"?` [${C.id}]`:"";return`
|
|
218
|
+
\uD83D\uDCCE ${T}${S}${v}`}).join(""),p=Number(t.reply_count??0),y=p>0?` [+${p} ${p===1?"reply":"replies"}]`:"",F=(h?`
|
|
219
|
+
${h}`:"")+m;return`${i} ${f}: ${l}${y}${F}`}function Us(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function mp(e){return Y(e.files).map(O).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 Qu(e){let t=mp(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:Y(e.reactions).map(O).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 Dp(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 Ge(e,t,i.ts,200,s),u=Y(c.messages).map(O);a=u[u.length-1]??i}if(a.user!==r)o.push(i)}return o}async function yp(e,t,n,r="text",s=!1,o){let i=jt(t),a=await De(e,t,o),c=new Map,d=await(async()=>{if(i?.threadTs){let f=await Ge(e,a,i.threadTs,n,o);return Y(f.messages).map(O)}let l=await Qe(e,a,n,void 0,void 0,o);return Y(l.messages).map(O).reverse()})();if(s){let{userId:l}=await Gc(e,o);d=await Dp(e,a,d,l,o)}if(r==="jsonl"){for(let l of d)console.log(JSON.stringify(Qu(l)));return}for(let l of d)console.log(await Ws(e,l,c,void 0,o))}async function wp(e,t,n,r,s="text",o){let i=await De(e,t,o),a=await Ge(e,i,gp(n),r,o),c=Y(a.messages).map(O);if(s==="jsonl"){for(let d of c)console.log(JSON.stringify(Qu(d)));return}let u=new Map;for(let d of c)console.log(await Ws(e,d,u,void 0,o))}async function bp(e){let t=await $n(e),n=Y(t.channels).map(O).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 Qe(e,o,5),c=Y(a.messages).map(O).filter((u)=>u.subtype===void 0||u.subtype===null).filter((u)=>{let d=typeof u.text==="string"?u.text:"";return d.length>0&&!d.startsWith("<@")}).slice(0,3).reverse();if(c.length===0)continue;console.log(`-- #${i} --------------------------------`);for(let u of c){let d=await Zu(e,u,r),l=(typeof u.text==="string"?u.text:"").split(`
|
|
220
|
+
`)[0]??"",f=await sn(e,l,r);console.log(` ${d}: ${f}`)}}}async function Cp(e,t){let n=await tu(e,"to:me"),r=Y(_n(n,["messages","matches"])).map(O).slice(0,t),s=new Map,o=[];for(let i of r){let a=Lu(Bs(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 d=O(u.channel),l=d.is_im===!0,f=typeof d.name==="string"?d.name:"dm",h;if(l&&f.startsWith("U")){let m="@"+f;if(!s.has(m)){let[,p]=await Tn(e,f);s.set(m,p)}h=`@${s.get(m)??f}`}else if(l)h=`@${f}`;else h=`#${f}`;console.log(await Ws(e,u,s,h))}}}async function Ep(e,t,n,r,s="text",o){let i=await $n(e,o),a=Y(i.channels).map(O).filter((c)=>r||c.is_member===!0).filter((c)=>{if(!n)return!0;return(typeof c.name==="string"?c.name:"").toLowerCase().includes(n.toLowerCase())}).sort((c,u)=>Number(u.updated??0)-Number(c.updated??0)).slice(0,t);if(s==="jsonl"){for(let c of a)console.log(JSON.stringify(c));return}for(let c of a){let u=String(c.id??""),d=typeof c.name==="string"?c.name:typeof c.user==="string"?c.user:u,l=c.is_im===!0,f=c.is_mpim===!0,h=l||f?"@":"#",m=c.is_member===!0?"":" (not joined)",p=typeof O(c.purpose).value==="string"?String(O(c.purpose).value):"",y=p?` ${p.split(`
|
|
221
|
+
`)[0]?.slice(0,60)}`:"";console.log(`${h}${d} ${u}${m}${y}`)}}function Fp(e){let t=(s)=>s.startsWith("xoxp-")||s.startsWith("xoxc-"),n=$r(),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 el(e,t,n,r,s){let o=e,i=s,a;try{a=await bo(o,t,n,i)}catch(d){let l=d instanceof Error?d.message:String(d);if(e.startsWith("xoxb-")&&l.includes("not_allowed_token_type")){let f=Fp(e);if(f)console.error(`Note: search.messages needs a user token \u2014 the active profile is a bot token (xoxb-); falling back to profile "${f.name}".`),o=f.profile.token,i=f.profile.cookie,a=await bo(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.
|
|
180
222
|
`+` Add a user-token profile: slack auth login (or slack auth login --token <token>)
|
|
181
|
-
Then select it: slack auth use <name> (or pass --workspace <name>)`),process.exit(1)}else throw
|
|
182
|
-
`);for(let
|
|
183
|
-
`).join(" \u21B5 ");console.log(`[${
|
|
184
|
-
`))console.log(` ${
|
|
185
|
-
`)).slice(0,4)}function
|
|
186
|
-
`)[0]??""
|
|
187
|
-
|
|
223
|
+
Then select it: slack auth use <name> (or pass --workspace <name>)`),process.exit(1)}else throw d}if(r){console.log(JSON.stringify(a,null,2));return}let c=Y(_n(a,["messages","matches"])).map(O),u=new Map;for(let d of c){let l=O(d.channel),f=l.is_im===!0,h=typeof l.name==="string"?l.name:"dm",m;if(f&&h.startsWith("U")){let p="@"+h;if(!u.has(p)){let[,y]=await Tn(o,h,i);u.set(p,y)}m=`@${u.get(p)??h}`}else if(f)m=`@${h}`;else m=`#${h}`;console.log(await Ws(o,d,u,m,i))}}async function tl(e,t,n,r){let{ref:s,ts:o}=Bn(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 ko(e,s,De,r),ts:o}}async function xp(e,t){let n=Rn(),r={};if(!t.mine)r.shared=!0;if(t.in)r.in=t.in;if(t.from)r.from=t.from;let s=Su(t.state,n,r);if(!t.json){let o=await rn(e,t.cookie),i=t.mine?"your reactions only [hasmy:]":"anyone's reactions [has:]";console.error(`(From: ${sl(o)} \xB7 matching ${i})`),console.error(`(query: ${s})`)}await xe("search.messages",()=>el(e,s,t.count,t.json,t.cookie))}async function kp(e,t){let n=Rn(),{channelId:r,ts:s}=await tl(e,t.target,t.channelId,t.cookie),o=await Ou(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 _p(e,t){let n=Rn(),{channelId:r,ts:s}=await tl(e,t.target,t.channelId,t.cookie),o=await Pu(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 Sp(e,t){let n=Rn(),r=t.channelId??await ko(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 Ru(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}] ${ee(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 Ap(e,t,n,r){let s=Math.floor(Date.now()/1000)-t*86400,o=await $n(e),i=Y(o.channels).map(O).filter((d)=>d.is_member===!0&&d.is_im!==!0&&d.is_mpim!==!0).filter((d)=>{if(!r)return!0;return(typeof d.name==="string"?d.name:"").toLowerCase().includes(r.toLowerCase())}).sort((d,l)=>Number(l.updated??0)-Number(d.updated??0)),a=new Map,c=0,u=0;for(let d of i){let l=String(d.id??""),f=typeof d.name==="string"?d.name:l,h;try{h=await Qe(e,l,n)}catch(p){console.error(` SKIP #${f}: ${p.message}`);continue}let m=Y(h.messages).map(O).filter((p)=>(p.subtype===void 0||p.subtype===null)&&Bs(p)>=s);if(m.length===0)continue;u+=1,c+=m.length,console.log(`## #${f} (${m.length} msgs)
|
|
224
|
+
`);for(let p of[...m].reverse()){let y=await Zu(e,p,a),F=typeof p.text==="string"?p.text:"",T=Nn(await sn(e,F,a)).split(`
|
|
225
|
+
`).join(" \u21B5 ");console.log(`[${Io(Bs(p))}] ${y}: ${T}`)}console.log("")}console.error(`Dumped ${c} messages across ${u} channels (cutoff: ${t}d)`)}function $p(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 nl(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 yu(e,s,t),i=O(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 Tn(e,c);a=`@${u}`}}else a=`#${typeof i.name==="string"?i.name:s}`;return r.set(s,a),a}catch{return s}}}function vo(e){let t=O(Y(e.destinations)[0]);return String(t.channel_id??e.channel_id??e.channel??"")}function Ls(e){return $p(Y(e.blocks))||(typeof e.text==="string"?e.text:"(no text)")}async function Tp(e,t,n=!1){let r=await In(e,t),s=Y(r.drafts??r.messages??[]).map(O).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 Co(e,t))}catch{}let a=await nl(e,t,i),c=new Map;for(let u of o){let d=vo(u),l=Ls(u),f=Number(u.date_created??u.date_create??0),h=f?Po(f):"?",m=await a(d),p=typeof u.id==="string"?u.id:"",y=u.is_sent===!0?" [SENT]":"",F=Nn(await sn(e,l,c));console.log(`-- ${p} ${m} [${h}]${y}`);for(let C of F.split(`
|
|
226
|
+
`))console.log(` ${C}`)}}async function Ip(e,t,n){let r=await In(e,t),s=Y(r.drafts).map(O).find((m)=>String(m.id)===n);if(!s)console.error(`Draft not found: ${n}`),process.exit(1);let o="";try{({userId:o}=await Co(e,t))}catch{}let i=await nl(e,t,o),a=vo(s),c=Ls(s),u=Number(s.date_created??0),d=String(s.last_updated_ts??"?"),l=await i(a),h=Nn(await sn(e,c,new Map));console.log(`id: ${s.id}`),console.log(`channel: ${l} (${a})`),console.log(`created: ${u?Po(u):"?"}`),console.log(`updated: ${Po(Number(d.split(".")[0]))}`),console.log(`status: ${s.is_sent===!0?"sent":"pending"}`),console.log("---"),console.log(h)}function Ye(...e){return hp(e.join(`
|
|
227
|
+
`)).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 Op={"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 ot(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 ${Op[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 Ks(e,t,n){if(!t.startsWith("D"))return null;try{let r=await Hs(e,t,n);if(!r)return null;return await Iu(e,r,On,n)}catch{return null}}function We(e,t,n,r,s=new Date){for(let i of n)console.log(i);let o=ju(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 Bn(e){let t=jt(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:No(r)}}}return{ref:e}}function on(e,t=!0){let n=jt(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:No(s)}}return{ref:e}}async function Js(e,t,n,r){let s=n;if(/^#?[CDG][A-Z0-9]{8,}$/.test(n)||!n.startsWith("#")&&!n.startsWith("@"))try{let i=O(await Pn(e,t,r)),a=O(i.channel);if(a.is_im===!0){let c=typeof a.user==="string"?a.user:"";s=c?`@${await $e(e,c,r)}`:t}else s=typeof a.name==="string"?`#${a.name}`:t}catch{s=t}return s===t?t:`${s} (${t})`}async function rn(e,t){try{return await Yc(e,t)}catch{return null}}function Kt(e,t){let n;return async()=>{if(n===void 0)n=await rn(e,t);return n}}function zs(e){if(!go())return{record:()=>{}};let t=jc();return{metadata:Wc(e,t),record:(n)=>{Kc({...n,kind:e,attribution:t})}}}function Pp(e){let t=ee(e.text.split(`
|
|
228
|
+
`)[0]??"").slice(0,100),n=e.permalink||`${e.channel}:${e.ts}`,r=[e.cli??"?",e.session_id?`session=${e.session_id}`:"",e.agent_pid?`pid=${e.agent_pid}`:`pid=${e.pid}`,e.git_branch?`branch=${e.git_branch}`:"",`cwd=${e.cwd}`].filter(Boolean).join(" ");return`${Io(e.sent_at/1000)} ${e.kind.padEnd(4)} ${ee(e.target??e.channel)} ${n}
|
|
229
|
+
${t}
|
|
230
|
+
${ee(r)}`}function sl(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})`:"",o=e.team?` \u2014 ${ee(e.team)}`:"";return`@${r}${s}${o}${n}`}function Ue(e,t={}){return` ${"From:".padEnd(t.pad??6)}${sl(e,t.asBot)}`}async function Ro(e,t,n=60,r){let s=typeof t.user==="string"?await $e(e,t.user,r):typeof t.username==="string"?t.username:"?",o=(typeof t.text==="string"?t.text:"").split(`
|
|
231
|
+
`)[0]??"",i=o.length>n?`${o.slice(0,n)}\u2026`:o,a=typeof t.ts==="string"?t.ts:"";return`${a?Mo(a).slice(0,16).replace("T"," "):""} @${s}${i?`: ${i}`:""}`}async function Rp(e,t,n,r){let s=n.find((o)=>String(o.ts)===t)??n[0];if(!s)return t;return Ro(e,s,40,r)}function Uu(e){return e.toLowerCase().replace(/<[@#!][^>]+>/g," ").replace(/[^\p{L}\p{N}\s]/gu," ").replace(/\s+/g," ").trim()}function Mp(e,t){let n=Uu(e),r=Uu(t);if(!n||!r)return 0;if(n===r)return 1;let s=(u)=>{let d=new Map;for(let l=0;l<u.length-1;l++){let f=u.slice(l,l+2);d.set(f,(d.get(f)??0)+1)}return d},o=s(n),i=s(r);if(o.size===0||i.size===0)return 0;let a=0;for(let[u,d]of o){let l=i.get(u);if(l)a+=Math.min(d,l)}let c=Ku(o)+Ku(i);return c===0?0:2*a/c}function Ku(e){let t=0;for(let n of e.values())t+=n;return t}async function Ju(e,t,n,r){let s=dt();if(!s)console.error(`Error: --as-bot needs a bot token, but no xoxb- token was found.
|
|
232
|
+
Set SLACK_BOT_TOKEN=xoxb-... in ~/.config/slack-cli/.env (or your shell).`),process.exit(1);if(r)return{botToken:s};let{ref:o}=Bn(e);if(!o.startsWith("@"))return{botToken:s};try{let i=await rt(t,o,n);return{botToken:s,channelId:await st(s,i)}}catch(i){console.error(`Error: could not resolve ${ee(o)} to the bot's DM.
|
|
188
233
|
${i instanceof Error?i.message:String(i)}
|
|
189
|
-
`+" Tip: pass the message permalink, or --channel-id <D\u2026>, to skip the lookup."),process.exit(1)}}async function
|
|
190
|
-
`).map((
|
|
191
|
-
`).map((
|
|
192
|
-
`).map((
|
|
193
|
-
`+` To reach yourself with a notification, send as the bot: slack send '${t.target}' '...' --as-bot`);let a=
|
|
194
|
-
`)[0]?.slice(0,100)??"(empty)"}`,...
|
|
195
|
-
`+` To reach yourself with a notification, ask as the bot: slack ask '${t.target}' '...' --as-bot`);let u
|
|
234
|
+
`+" Tip: pass the message permalink, or --channel-id <D\u2026>, to skip the lookup."),process.exit(1)}}async function Np(e,t){let n=Kt(e,t.cookie),{ref:r,ts:s}=Bn(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 Ge(e,o,s,1,t.cookie),c=Y(i.messages).map(O).find((y)=>String(y.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:"",d=t.mentionCookie??t.cookie,l=t.mentions?await Mu(t.mentionToken??e,t.newText,o,d?{cookie:d}:{}):t.newText;ns(l,t.allowUrlAdjacent);let f=await n(),h=Ye(u,l,f?.userId??"");if(t.code!==h)We(t.code,h,["--- Editing as -------------------------------",Ue(f,{asBot:t.asBot}),"--- Original message -------------------------",...u.split(`
|
|
235
|
+
`).map((y)=>` ${y}`),"--- Replacing with ---------------------------",...l.split(`
|
|
236
|
+
`).map((y)=>` ${y}`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);let m=zs("edit"),p=await en(e,o,s,l,t.cookie,void 0,m.metadata);console.log(`\u2713 Edited (ts: ${p})`),m.record({team:f?.team,channel:o,target:t.target,ts:s,text:l,asBot:t.asBot})}async function vp(e,t){let n=Kt(e,t.cookie),{ref:r,ts:s}=Bn(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 Ge(e,o,s,1,t.cookie),c=Y(i.messages).map(O).find((f)=>String(f.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:"",d=await n(),l=Ye(o,s,u,d?.userId??"");if(t.code!==l){let f=await Js(e,o,r,t.cookie);We(t.code,l,["--- Deleting message -------------------------",Ue(d,{asBot:t.asBot}),` \u2192 ${f} at ${Mo(s)}`,...u.split(`
|
|
237
|
+
`).map((h)=>` ${h}`),"---------------------------------------------"])}await iu(e,o,s,t.cookie),console.log(`\u2713 Deleted (ts: ${s})`)}async function Bp(e,t){let{ref:n,ts:r}=Bn(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 An(e,o,r,s,t.cookie),console.log(`\u2713 Removed :${s}: (ts: ${r})`);else await tn(e,o,r,s,t.cookie),console.log(`\u2713 Reacted :${s}: (ts: ${r})`)}async function Bo(e,t,n,r){if(!n||!t.startsWith("D"))return!1;try{let s=O(await Pn(e,t,r)),o=O(s.channel);return o.is_im===!0&&o.user===n}catch{return!1}}async function Lp(e,t){let{ref:n,threadTs:r}=on(t.target),s=t.cookie,o=Kt(e,s),i;if(t.channelId)i=t.channelId;else if(t.userId)i=await st(e,t.userId,s);else i=await De(e,n,s);if(!t.asBot&&await Bo(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.
|
|
238
|
+
`+` To reach yourself with a notification, send as the bot: slack send '${t.target}' '...' --as-bot`);let a=mt(t.message);ns(a,t.allowUrlAdjacent);let c=a,u=null;if(t.mentions){u=await Ut(t.mentionToken??e,a,i,t.mentionCookie),c=u.text;for(let P of Mn(u.unresolved))console.error(`\u26A0 ${ee(P)}`)}try{for(let P of await Bu(t.mentionToken??e,c,t.mentionCookie))console.error(`\u26A0 possible untagged mention: ${ee(P.surface)} \u2014 @${ee(P.display)} won't be notified (did you mean <@${P.userId}>?)`)}catch{}let d=[];if(u&&(u.resolved.length>0||u.unresolved.length>0)){d.push("--- Mentions ---------------------------------");for(let P of u.resolved)d.push(` \u2713 ${ee(P.surface)} \u2192 @${ee(P.display)} (${P.userId}) \u2014 will notify`);for(let P of u.unresolved){let z=P.reason==="ambiguous"?"ambiguous":P.reason==="unavailable"?"lookup unavailable":"no match";d.push(` \u26A0 ${ee(P.surface)} \u2014 plain text, NOT notified (${z})`)}}let l="",f="?",h=[],m,p,y;if(r)try{let P=await Ge(e,i,r,100,s);h=Y(P.messages).map(O);let z=h[h.length-1];l=typeof z?.text==="string"?z.text:"",m=typeof z?.user==="string"?z.user:void 0,p=typeof z?.bot_id==="string"?z.bot_id:void 0,y=typeof z?.ts==="string"?z.ts:void 0}catch{}else try{let P=await Qe(e,i,1,void 0,void 0,s),z=Y(P.messages).map(O),W=z.filter((k)=>k.subtype===void 0||k.subtype===null)[0];l=typeof W?.text==="string"?W.text:"",f=typeof W?.user==="string"?await $e(e,W.user,s):typeof W?.username==="string"?W.username:"?";let Z=z[0];m=typeof Z?.user==="string"?Z.user:void 0,p=typeof Z?.bot_id==="string"?Z.bot_id:void 0,y=typeof Z?.ts==="string"?Z.ts:void 0}catch{}if(process.env.SLACK_UNREPLIED_WARN!=="0"&&y&&(m||p))try{let P=await o();if(!!P&&(!!m&&!!P.userId&&P.userId===m||!!p&&!!P.botId&&P.botId===p)){let W=`slack edit "#${i}:${y}" "<\u65B0\u3057\u3044\u672C\u6587>" --channel-id ${i}`;try{let Z=await Sn(e,i,y,s);if(Z)W=`slack edit "${Z}" "<\u65B0\u3057\u3044\u672C\u6587>"`}catch{}console.error("\u26A0 \u76F8\u624B\u306F\u307E\u3060\u8FD4\u4FE1\u3057\u3066\u3044\u307E\u305B\u3093(\u6700\u5F8C\u306E\u30E1\u30C3\u30BB\u30FC\u30B8\u306F\u3042\u306A\u305F\u306E\u3082\u306E\u3067\u3059)\u3002"),console.error(" \u9023\u6295\u3092\u907F\u3051\u308B\u305F\u3081\u3001\u65B0\u898F\u9001\u4FE1\u3067\u306A\u304F\u76F4\u524D\u306E\u30E1\u30C3\u30BB\u30FC\u30B8\u306E edit \u3092\u691C\u8A0E\u3057\u3066\u304F\u3060\u3055\u3044:"),console.error(` ${W}`),console.error(" \u3053\u306E\u307E\u307E\u9001\u4FE1\u3059\u308B\u5834\u5408\u306F --code=XXXX \u3067\u78BA\u5B9A\u3002")}}catch{}if(r&&h.length){let P={sim:0,msg:null};for(let z of h){let W=typeof z.text==="string"?z.text:"";if(!W)continue;let Z=Mp(c,W);if(Z>P.sim)P={sim:Z,msg:z}}if(P.msg&&P.sim>=0.82){let z=Math.round(P.sim*100);console.error(`\u26A0 possible duplicate: ${z}% similar to an existing thread message \u2014 ${await Ro(e,P.msg,60,s)}`)}}let F=await o(),C=await Ks(e,i,s),T=Ye(i,r??"",l,c,F?.userId??"");if(t.code!==T){let P=await Js(e,i,n,s),z=Ue(F,{asBot:t.asBot});if(r){let W=await Rp(e,r,h,s),Z=h.slice(-3),k=Z.length?await Promise.all(Z.map(async(E)=>` ${await Ro(e,E,60,s)}`)):[" (thread context unavailable)"];We(t.code,T,["--- Recent messages in thread ----------------",...k,...d,"--- Sending ----------------------------------",z,` \u2192 ${P} thread of ${W} \u2014 THREAD REPLY`,` Message: ${c}`,"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"],C)}else We(t.code,T,["--- Last message in channel ------------------",` ${f}: ${l.split(`
|
|
239
|
+
`)[0]?.slice(0,100)??"(empty)"}`,...d,"--- Sending ----------------------------------",z,` \u2192 ${P} \u2014 NEW top-level message`,` Message: ${c}`,"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"],C)}let S=zs("send"),v=await Is(e,i,c,r,t.broadcast,s,void 0,S.metadata),K="";try{K=await Sn(e,i,v,s)}catch{}if(S.record({team:(await o())?.team,channel:i,target:t.target,ts:v,threadTs:r,permalink:K,text:c,asBot:t.asBot}),K)console.log(`\u2713 Sent: ${K}`);else console.log(`\u2713 Sent (ts: ${v})`);if(t.asBot&&i.startsWith("D"))try{let P=await hs(e);if(!P.ok)for(let z of gs(P,!0))console.error(z);else{let z=P.appId?`https://api.slack.com/apps/${P.appId}`:"https://api.slack.com/apps";console.error(`Note: if ${t.target} can't reply (app messaging may be off), enable Messages Tab: ${z} \u2192 App Home.`)}}catch{}}var jp=2,be=3,Wp=4,Up=5,Kp=1.618033988749895,Jp=1000,zp=5000,zu=8,Hp=(e)=>new Promise((t)=>setTimeout(t,e)),qp=new Set(["thread_broadcast"]),Xp=/(?<![A-Za-z0-9._@<-])@(here|channel|everyone)(?![A-Za-z0-9._-])/giu;function js(e){let t=new Set;return{text:e.replace(Xp,(r,s)=>{let o=s.toLowerCase();return t.add(o),`<!${o}>`}),kinds:t}}async function Hs(e,t,n){if(!t.startsWith("D"))return;try{let r=O(await Pn(e,t,n)),s=O(r.channel);return s.is_im===!0&&typeof s.user==="string"?s.user:void 0}catch{return}}async function rl(e,t){let{channelId:n,ts:r,question:s,reactable:o,threadOnly:i,audience:a,broadcast:c,cookie:u,timeout:d,shown:l}=t,{askerUserId:f,askerBotId:h}=t,m=(k)=>typeof k==="string"&&!!k&&k!==f&&(c||a.has(k)),p,y="";function F(k){let E=Y(k.reactions).map(O),A=[];for(let _=0;_<o.length;_++){let M=E.find((X)=>X.name===Be[_].name),V=M?Y(M.users).filter(m):[];if(V.length)A.push({index:_,users:V})}return A}async function C(k,E){let A=typeof k.text==="string"?k.text:"";if(!A)return;let _=oo(A,E);if(_===A)return;try{await en(e,n,r,_,u,!0)}catch(M){console.error(` (\u8CEA\u554F\u6587\u306B\u6CE8\u610F\u66F8\u304D\u3092\u5165\u308C\u3089\u308C\u307E\u305B\u3093\u3067\u3057\u305F: ${M instanceof Error?M.message:String(M)})`)}}async function T(k){let E=F(k);if(E.length<=1&&ro(typeof k.text==="string"?k.text:"").length)await C(k,[]);if(!E.length)return null;if(E.length===1){let{index:M,users:V}=E[0];return{answer:o[M],how:`\u30EA\u30A2\u30AF\u30B7\u30E7\u30F3 ${Be[M].glyph}`,who:V[0]}}let A=E.map((M)=>Be[M.index].glyph).join(" / ");console.error(` (${A} \u304C\u540C\u6642\u306B\u9078\u3070\u308C\u3066\u3044\u307E\u3059\u30021 \u3064\u306B\u7D5E\u3063\u3066\u3082\u3089\u3046\u307E\u3067\u5F85\u3061\u307E\u3059)`);let _=[...new Set(E.flatMap((M)=>M.users))].sort();return await C(k,_),null}let S=[...o,...t.overflow];function v(k,E=1/0){let A=[...k].sort((_,M)=>Number(_.ts)-Number(M.ts));for(let _ of A){if(!(Number(_.ts)>Number(r)))continue;if(t.after&&!(Number(_.ts)>Number(t.after)))continue;if(!m(_.user))continue;if(typeof _.subtype==="string"&&!qp.has(_.subtype))continue;if(Number(_.ts)>=E)break;let M=typeof _.text==="string"?_.text.trim():"";if(!M)continue;if(!S.length)return{answer:M,how:"\u8FD4\u4FE1",who:_.user};let V=_c(M,S);if(V.kind==="chosen")return{answer:S[V.index-1],how:`\u8FD4\u4FE1 (${V.index})`,who:_.user};let X=V.kind==="ambiguous";if(!p||p.ambiguous&&!X||p.ambiguous===X&&Number(_.ts)<Number(p.ts))p={text:M,who:typeof _.user==="string"?_.user:"",ts:String(_.ts),ambiguous:X}}return null}async function K(){if(p=void 0,t.threadParentTs){let _=O(await Ge(e,n,t.threadParentTs,100,u)),M=Y(_.messages).map(O),V=M.find((X)=>X.ts===r);if(V){let X=await T(V);if(X)return X}return v(M)}let k=O(await Qe(e,n,30,r,void 0,u,!0)),E=Y(k.messages).map(O),A=E.find((_)=>_.ts===r);if(A){let _=await T(A);if(_)return _}if(!i){let _=E.filter((V)=>Number(V.ts)>Number(r)&&(h&&V.bot_id===h||f&&V.user===f)).reduce((V,X)=>Math.min(V,Number(X.ts)),1/0),M=v(E,_);if(M)return M}if(A&&Number(A.reply_count)>0){let _=O(await Ge(e,n,r,30,u)),M=v(Y(_.messages).map(O));if(M)return M}return null}async function P(k){for(let A=0;A<o.length;A++)try{await An(e,n,r,Be[A].name,u)}catch{}let E="";if(k.who)try{E=await $e(e,k.who,u)}catch{E=k.who}if(E)console.error(` \u56DE\u7B54\u8005: ${ee(E)}`);try{await en(e,n,r,Fc(s,k,E),u,!0);try{await tn(e,n,r,io,u),await An(e,n,r,Ss,u)}catch{}}catch(A){console.error(` (\u5143\u30E1\u30C3\u30BB\u30FC\u30B8\u306E\u66F4\u65B0\u306B\u5931\u6557: ${A instanceof Error?A.message:String(A)})`)}}let z=Date.now()+d*1000,W=0,Z=Jp;for(;;){let k=null;try{k=await K(),W=0}catch(E){if(W++,W>=zu)console.error(`Error: Slack \u3078\u306E\u554F\u3044\u5408\u308F\u305B\u306B ${W} \u56DE\u9023\u7D9A\u3067\u5931\u6557\u3057\u307E\u3057\u305F: ${E instanceof Error?E.message:String(E)}`),process.exit(be);console.error(` (Slack \u30A8\u30E9\u30FC ${W}/${zu}, \u518D\u8A66\u884C\u3057\u307E\u3059: ${E instanceof Error?E.message:String(E)})`)}if(k)await P(k),console.log(k.answer),process.exit(0);if(p&&!p.ambiguous){let E=p.who;try{if(E)E=await $e(e,E,u)}catch{}console.error(` (${ee(E)} \u304C\u9078\u629E\u80A2\u5916\u306E\u8FD4\u4FE1\u3092\u3057\u307E\u3057\u305F \u2014 \u6C7A\u5B9A\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002\u672C\u6587\u3092 stdout \u306B\u51FA\u3057\u307E\u3059)`),console.error(` \u9078\u629E\u80A2: ${S.map((A,_)=>`${_+1}. ${ee(Nt(A))}`).join(" ")}`),console.error(` ${l}`),console.error(` \u3053\u306E\u8FD4\u4FE1\u306E\u5F8C\u3092\u5F85\u3064: ${vs(l,t.asBot,p.ts)}`),console.log(p.text),process.exit(Up)}if(p&&p.ts!==y){y=p.ts;let E=p.who;try{if(E)E=await $e(e,E,u)}catch{}console.error(` (${ee(E)} \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)`),console.error(` \u300C${ee(p.text)}\u300D`)}if(Date.now()>=z)break;await Hp(Math.min(Z,Math.max(0,z-Date.now()))),Z=Math.min(Z*Kp,zp)}if(p)console.error("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)"),console.error(` \u8FD4\u4FE1: \u300C${ee(p.text)}\u300D`),console.error(` \u9078\u629E\u80A2: ${S.map((k,E)=>`${E+1}. ${ee(Nt(k))}`).join(" ")}`),console.error(` ${l}`),console.error(` \u8FD4\u7B54\u3057\u3066\u304B\u3089\u56DE\u53CE\u3059\u308B: ${vs(l,t.asBot,t.after)}`),process.exit(Wp);if(d===0)console.error(`\u307E\u3060\u56DE\u7B54\u304C\u3042\u308A\u307E\u305B\u3093: ${l}`);else console.error(`Error: ${d}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: ${vs(l,t.asBot,t.after)}`);process.exit(jp)}function vs(e,t,n){return`slack ask --waitFor='${e}'${t?" --as-bot":""}${n?` --after=${n}`:""}`}async function Gp(e,t){let{ref:n,threadTs:r}=on(t.target,!1),s=t.cookie,o=Kt(e,s),i;if(t.channelId)i=t.channelId;else if(t.userId)i=await st(e,t.userId,s);else i=await De(e,n,s);let a=(await o())?.userId??"",c=await Hs(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.
|
|
240
|
+
`+` To reach yourself with a notification, ask as the bot: slack ask '${t.target}' '...' --as-bot`);let u=js(mt(t.question)),d=js(mt(t.body??"")),l=new Set([...u.kinds,...d.kinds]),f=t.mentionToken??e,h=await Ut(f,u.text,i,t.mentionCookie),m=d.text?await Ut(f,d.text,i,t.mentionCookie):{text:"",resolved:[],unresolved:[]},p=h.text,y=m.text,F=[...h.resolved,...m.resolved],C=[...h.unresolved,...m.unresolved];for(let R of Mn(C))console.error(`\u26A0 ${ee(R)}`);let T=l.size>0,S=new Set(F.map((R)=>R.userId).filter((R)=>R!==a)),v=new Map(F.map((R)=>[R.userId,R.display])),K;if(T)K=`anyone in ${n} (${[...l].map((R)=>`@${R}`).join(", ")})`;else{if(!S.size&&c&&c!==a)S.add(c),v.set(c,await $e(e,c,s));if(!S.size)console.error("Error: `ask` will not post a question nobody is addressed to \u2014 no one is tagged.\n"+(C.length?` (${C.map((R)=>ee(R.surface)).join(", ")} matched no one, so it names nobody.)
|
|
196
241
|
`:"")+` Tag the person who should answer: slack ask '${t.target}' '@alice ${t.question}' ...
|
|
197
242
|
Or open it to the whole channel: slack ask '${t.target}' '@here ${t.question}' ...
|
|
198
|
-
(In a 1:1 DM the other person counts automatically.)`),process.exit(
|
|
199
|
-
`)[0]?.slice(0,100)??"(empty)"}`,...
|
|
200
|
-
`+` Got: ${
|
|
201
|
-
${
|
|
202
|
-
`+` (\u62BC\u3055\u308C\u305F\u30EA\u30A2\u30AF\u30B7\u30E7\u30F3\u306F\u6B8B\u3063\u3066\u3044\u307E\u3059: slack read '${
|
|
203
|
-
`+` To reach yourself with a notification, post as the bot: slack poll '${t.target}' '...' --as-bot`);let u
|
|
204
|
-
`)[0]?.slice(0,100)??"(empty)"}`,"--- Ballot (seeded as reactions) -------------",...y.map((
|
|
205
|
-
`+` Got: ${
|
|
206
|
-
`+" \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
|
|
207
|
-
Set SLACK_BOT_TOKEN=xoxb-... in ~/.config/slack-cli/.env (or your shell).`),process.exit(1);return e}async function
|
|
208
|
-
`+` 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??""),
|
|
243
|
+
(In a 1:1 DM the other person counts automatically.)`),process.exit(be);K=[...S].map((R)=>`@${ee(v.get(R)??R)} (${R})`).join(", ")}let P=t.choices.map(mt),z=P.slice(0,_s),W=P.slice(_s),Z=!i.startsWith("D")||!!r,k=Ec(p,y,z,W,Z);ns(k,t.allowUrlAdjacent);let E="",A="?";try{let R=await Qe(e,i,1,void 0,void 0,s),ue=Y(R.messages).map(O).filter((Oe)=>Oe.subtype===void 0||Oe.subtype===null)[0];E=typeof ue?.text==="string"?ue.text:"",A=typeof ue?.user==="string"?await $e(e,ue.user,s):typeof ue?.username==="string"?ue.username:"?"}catch{}let _=await o(),M=await Ks(e,i,s),V=Ye(i,r??"",E,k,_?.userId??"");if(t.code!==V){let R=await Js(e,i,n,s),ue=z.length?["--- Choices (seeded as reactions) ------------",...z.map((Oe,H)=>` ${Be[H].glyph} ${Nt(Oe)}`),...W.map((Oe,H)=>` (${H+11}) ${Nt(Oe)} \u2014 text answer only`)]:["--- Choices ----------------------------------"," (none \u2014 free-text reply)"];We(t.code,V,["--- Last message in channel ------------------",` ${A}: ${E.split(`
|
|
244
|
+
`)[0]?.slice(0,100)??"(empty)"}`,...ue,"--- Asking -----------------------------------",Ue(_,{asBot:t.asBot}),` \u2192 ${R}${r?" \u2014 THREAD REPLY":" \u2014 NEW top-level message"}`,` Question: ${p}`,` Answerable by: ${K}`,` Via: ${Z?"reactions or thread replies":"reactions or replies in this DM"}`,"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"],M)}let X=zs("ask"),re=await Is(e,i,k,r,!1,s,!0,X.metadata);await po([Ss,...z.map((R,ue)=>Be[ue].name)],(R)=>tn(e,i,re,R,s),(R,ue)=>{let Oe=ue instanceof Error?ue.message:String(ue);if(R===Ss)console.error(` (marker ${R} \u3092\u4ED8\u3051\u3089\u308C\u307E\u305B\u3093\u3067\u3057\u305F: ${Oe})`);else console.error(` (\u30EA\u30A2\u30AF\u30B7\u30E7\u30F3 ${R} \u3092\u4ED8\u3051\u3089\u308C\u307E\u305B\u3093\u3067\u3057\u305F: ${Oe})`)});let Te="";try{Te=await Sn(e,i,re,s)}catch{}let te=Te||`${i}:${re}`;if(console.error(`\u2713 Asked: ${te}`),X.record({team:_?.team,channel:i,target:t.target,ts:re,threadTs:r,permalink:Te,text:k,asBot:t.asBot}),!t.wait){console.log(vs(te,!!t.asBot));return}let Ie=t.timeout??3600;console.error(` \u56DE\u7B54\u3092\u5F85\u3063\u3066\u3044\u307E\u3059 (\u6700\u5927 ${Ie}s)\u2026 Ctrl-C \u3067\u4E2D\u65AD`);let et={channelId:i,ts:re,question:p,reactable:z,overflow:W,threadOnly:Z,audience:S,broadcast:T,askerUserId:_?.userId??"",askerBotId:_?.botId??"",timeout:Ie,shown:te,asBot:!!t.asBot};if(r)et.threadParentTs=r;if(s)et.cookie=s;await rl(e,et)}async function Yp(e,t){let n=jt(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').
|
|
245
|
+
`+` Got: ${ee(t.link)}`),process.exit(be);r=m[1],s=m[2]}let i;if(o){let m=O(await Ge(e,r,o,100,t.cookie));i=Y(m.messages).map(O).find((p)=>p.ts===s)}else{let m=O(await Qe(e,r,1,s,void 0,t.cookie,!0));i=Y(m.messages).map(O).find((p)=>p.ts===s)}if(!i)console.error(`Error: \u305D\u306E\u30E1\u30C3\u30BB\u30FC\u30B8\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093: ${ee(t.link)}`),process.exit(be);let a=typeof i.text==="string"?i.text:"",c=kc(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: ${xc(a)}
|
|
246
|
+
${ee(t.link)}
|
|
247
|
+
`+` (\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(be);if(c.kind==="resolved"){console.error(`\u2713 \u56DE\u7B54\u6E08\u307F: ${ee(c.question)}`),console.log(c.answer);return}let u=typeof i.user==="string"?i.user:"",d=typeof i.bot_id==="string"?i.bot_id:"",l=/<!(here|channel|everyone)(\^[^>]*)?(\|[^>]*)?>/.test(a),f=new Set;for(let m of a.matchAll(/<@([UW][A-Z0-9]+)>/g))if(m[1]!==u)f.add(m[1]);if(!f.size&&!l){let m=await Hs(e,r,t.cookie);if(m&&m!==u)f.add(m)}if(!f.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(be);if(t.timeout>0)console.error(` \u56DE\u7B54\u3092\u5F85\u3063\u3066\u3044\u307E\u3059 (\u6700\u5927 ${t.timeout}s)\u2026 Ctrl-C \u3067\u4E2D\u65AD`);let h={channelId:r,ts:s,question:c.question,reactable:c.reactable,overflow:c.overflow,threadOnly:c.threadOnly,audience:f,broadcast:l,askerUserId:u,askerBotId:d,timeout:t.timeout,shown:t.link,asBot:t.asBot};if(o)h.threadParentTs=o;if(t.cookie)h.cookie=t.cookie;if(t.after)h.after=t.after;await rl(e,h)}var je=3;function Vp(e){return`slack poll --results='${e}'`}async function Zp(e,t){let{ref:n,threadTs:r}=on(t.target,!1),s=t.cookie,o=Kt(e,s),i;if(t.channelId)i=t.channelId;else if(t.userId)i=await st(e,t.userId,s);else i=await De(e,n,s);let a=(await o())?.userId??"",c=await Hs(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.
|
|
248
|
+
`+` To reach yourself with a notification, post as the bot: slack poll '${t.target}' '...' --as-bot`);let u=js(mt(t.question)),d=js(mt(t.body??"")),l=t.mentionToken??e,f=await Ut(l,u.text,i,t.mentionCookie),h=d.text?await Ut(l,d.text,i,t.mentionCookie):{text:"",resolved:[],unresolved:[]},m=f.text,p=h.text;for(let A of Mn([...f.unresolved,...h.unresolved]))console.error(`\u26A0 ${ee(A)}`);let y=t.choices.map(mt),F=!!t.multi,C=t.until??"",T=Oc(m,p,y,{multi:F,deadline:C}),S="",v="?";try{let A=await Qe(e,i,1,void 0,void 0,s),_=Y(A.messages).map(O).filter((M)=>M.subtype===void 0||M.subtype===null)[0];S=typeof _?.text==="string"?_.text:"",v=typeof _?.user==="string"?await $e(e,_.user,s):typeof _?.username==="string"?_.username:"?"}catch{}let K=await o(),P=await Ks(e,i,s),z=Ye(i,r??"",S,T,K?.userId??"");if(t.code!==z){let A=await Js(e,i,n,s);We(t.code,z,["--- Last message in channel ------------------",` ${v}: ${S.split(`
|
|
249
|
+
`)[0]?.slice(0,100)??"(empty)"}`,"--- Ballot (seeded as reactions) -------------",...y.map((_,M)=>` ${Xe[M].glyph} ${Fn(_)}`),"--- Posting ----------------------------------",Ue(K,{asBot:t.asBot}),` \u2192 ${A}${r?" \u2014 THREAD REPLY":" \u2014 NEW top-level message"}`,` Question: ${m}`,` Rule: ${F?"1 \u4EBA \u4F55\u7968\u3067\u3082 (--multi)":"1 \u4EBA 1 \u7968"}${C?` \u2014 \u7DE0\u5207 ${C}`:""}`," 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"],P)}let W=zs("poll"),Z=await Is(e,i,T,r,!1,s,!0,W.metadata);await po([xn,...y.map((A,_)=>Xe[_].name)],(A)=>tn(e,i,Z,A,s),(A,_)=>{let M=_ instanceof Error?_.message:String(_);if(A===xn)console.error(` (marker ${A} \u3092\u4ED8\u3051\u3089\u308C\u307E\u305B\u3093\u3067\u3057\u305F: ${M})`);else console.error(` (\u30EA\u30A2\u30AF\u30B7\u30E7\u30F3 ${A} \u3092\u4ED8\u3051\u3089\u308C\u307E\u305B\u3093\u3067\u3057\u305F: ${M})`)});let k="";try{k=await Sn(e,i,Z,s)}catch{}let E=k||`${i}:${Z}`;console.error(`\u2713 Posted: ${E}`),W.record({team:K?.team,channel:i,target:t.target,ts:Z,threadTs:r,permalink:k,text:T,asBot:t.asBot}),console.log(Vp(E)),console.error(` \u7DE0\u3081\u5207\u308B: slack poll --close='${E}'${t.asBot?" --as-bot":""}`)}async function Qp(e,t,n){let r=jt(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').
|
|
250
|
+
`+` Got: ${ee(t)}`),process.exit(je);s=c[1],o=c[2]}let a;if(i){let c=O(await Ge(e,s,i,100,n));a=Y(c.messages).map(O).find((u)=>u.ts===o)}else{let c=O(await Qe(e,s,1,o,void 0,n,!0));a=Y(c.messages).map(O).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: ${ee(t)}`),process.exit(je);return{channelId:s,ts:o,msg:a}}function Hu(e){let t=Math.max(1,...e.map((n)=>n.count));return e.map((n,r)=>`${Xe[r].glyph} ${String(n.count).padStart(3)} ${"\u2588".repeat(Math.round(n.count/t*20))}${n.count?" ":""}${n.choice}`)}async function eh(e,t){let{channelId:n,ts:r,msg:s}=await Qp(e,t.link,t.cookie),o=typeof s.text==="string"?s.text:"",i=Rc(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"+` ${ee(t.link)}`),process.exit(je);if(i.kind==="closed"){console.error(`\u2713 \u6295\u7968\u7D42\u4E86: ${ee(i.question)}`);for(let h of Hu(i.tallies))console.log(h);return}let a=new Set;if(typeof s.user==="string"&&s.user)a.add(s.user);let c=await au(e,n,r,t.cookie),u=Mc(i.choices,c,a,i.multi);console.error(`${ee(i.question)}${i.deadline?` (\u7DE0\u5207 ${i.deadline})`:""}`);for(let h of Hu(u.tallies))console.log(h);let d=u.tallies.reduce((h,m)=>h+m.count,0);if(console.error(` \u8A08 ${d} \u7968${i.multi?" (\u8907\u6570\u9078\u629E\u53EF)":""}`),t.names)for(let h=0;h<u.voters.length;h++){if(!u.voters[h].length)continue;let m=await Promise.all(u.voters[h].map((p)=>$e(e,p,t.cookie)));console.error(` ${Xe[h].glyph} ${m.map((p)=>`@${ee(p)}`).join(", ")}`)}let l=i.multi?[]:u.ambiguous,f=oo(o,l);if(f!==o&&!t.noNotify)try{await en(t.writeToken??e,n,r,f,t.writeToken?t.writeCookie:t.cookie,!0)}catch(h){console.error(` (\u6295\u7968\u6587\u306B\u6CE8\u610F\u66F8\u304D\u3092\u5165\u308C\u3089\u308C\u307E\u305B\u3093\u3067\u3057\u305F: ${h instanceof Error?h.message:String(h)})
|
|
251
|
+
`+" \u30E1\u30C3\u30BB\u30FC\u30B8\u3092\u66F8\u304D\u63DB\u3048\u3089\u308C\u308B\u306E\u306F\u6295\u7A3F\u8005\u3060\u3051\u3067\u3059 \u2014 bot \u304C\u6295\u7A3F\u3057\u305F\u6295\u7968\u306A\u3089 --as-bot \u3092\u4ED8\u3051\u3066\u304F\u3060\u3055\u3044\u3002")}if(u.ambiguous.length){let h=await Promise.all(u.ambiguous.map((m)=>$e(e,m,t.cookie)));console.error(`\u26A0 1 \u4EBA 1 \u7968\u306A\u306E\u306B\u8907\u6570\u62BC\u3057\u3066\u3044\u308B\u4EBA\u304C\u3044\u307E\u3059 (\u7121\u52B9\u7968): ${h.map((m)=>`@${ee(m)}`).join(", ")}`)}if(!t.close)return;await en(t.writeToken??e,n,r,Pc(i.question,u.tallies),t.writeToken?t.writeCookie:t.cookie,!0);try{await tn(t.writeToken??e,n,r,fo,t.writeToken?t.writeCookie:t.cookie),await An(t.writeToken??e,n,r,xn,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 th(e){let t=await hs(e);for(let n of gs(t,!1))console.log(n);if(!t.ok)process.exit(1)}function Oo(){let e=dt();if(!e)console.error(`Error: --as-bot needs a bot token, but no xoxb- token was found.
|
|
252
|
+
Set SLACK_BOT_TOKEN=xoxb-... in ~/.config/slack-cli/.env (or your shell).`),process.exit(1);return e}async function qu(e,t,n,r){let s=await rt(n,e,r);return st(t,s)}function nh(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 sh(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 rh(e,t){let n=Kt(e,t.cookie),{ref:r,threadTs:s}=on(t.target),o;if(t.channelId)o=t.channelId;else if(t.userId)o=await st(e,t.userId,t.cookie);else o=await De(e,r,t.cookie);let i=nh(t.at),a=new Date(i*1000).toISOString(),c=await n();if(!t.asBot&&await Bo(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.
|
|
253
|
+
`+` 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??""),d=t.targetOverride?` [${t.targetOverride} \u2192 ${o}]`:"";if(t.code!==u){let f=await Ks(e,o,t.cookie);We(t.code,u,["--- Scheduling message -----------------------",Ue(c,{asBot:t.asBot,pad:9}),` To: ${r}${s?` (thread ${s})`:""}${d}`,` At: ${sh(i)}`,` Message: ${t.message}`,"---------------------------------------------"],f,new Date(i*1000))}let l=await su(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:
|
|
209
254
|
`+` slack schedule ls --as-bot
|
|
210
|
-
slack schedule rm '${t.target}' ${l} --as-bot`),o.startsWith("D"))try{let
|
|
211
|
-
`)[0]?.slice(0,80)??""}`)}}async function
|
|
212
|
-
`+"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=
|
|
213
|
-
`+"Expected F\u2026 or https://<ws>.slack.com/files/<UID>/<FID>/<name>");let o=
|
|
214
|
-
`),await
|
|
255
|
+
slack schedule rm '${t.target}' ${l} --as-bot`),o.startsWith("D"))try{let f=await hs(e);if(!f.ok)for(let h of gs(f,!0))console.error(h);else{let h=f.appId?`https://api.slack.com/apps/${f.appId}`:"https://api.slack.com/apps";console.error(`Note: if ${t.target} can't reply (app messaging may be off), enable Messages Tab: ${h} \u2192 App Home.`)}}catch{}}}async function Xu(e,t,n,r){let s;if(n)s=n;else if(t)s=await De(e,t,r);let i=(await ru(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(`
|
|
256
|
+
`)[0]?.slice(0,80)??""}`)}}async function Gu(e,t){let n;if(t.channelId)n=t.channelId;else n=await De(e,t.target,t.cookie);let r=await rn(e,t.cookie),s=Ye(n,t.id,r?.userId??"");if(t.code!==s)We(t.code,s,["--- Deleting scheduled message ---------------",Ue(r,{asBot:t.asBot,pad:9}),` Channel: ${t.target}${t.targetOverride?` [${t.targetOverride} \u2192 ${n}]`:""}`,` ID: ${t.id}`,"---------------------------------------------"]);await ou(e,n,t.id,t.cookie),console.log(`\u2713 Deleted scheduled message ${t.id}`)}async function oh(e,t){let n=Kt(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}=on(t.target),c;if(t.channelId)c=t.channelId;else if(t.userId)c=await st(e,t.userId,t.cookie);else c=await De(e,i,t.cookie);if(await Bo(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,d=t.filePaths.map((m)=>{let p=o(m),y=u?p:t.title??p;return{fp:m,filename:p,title:y,sizeFmt:Us(r(m).size)}}),l=await n(),f=Ye(c,...d.flatMap((m)=>[m.fp,m.title]),l?.userId??"");if(t.code!==f){let m=` To: ${i}${a?` (thread ${a})`:""}`,p=u?[`--- Uploading ${d.length} files ------------------------`,Ue(l,{pad:7}),m,...d.map((y)=>` ${y.filename} (${y.sizeFmt})`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]:["--- Uploading file ---------------------------",Ue(l,{pad:7}),m,` File: ${d[0].fp}`,` Title: ${d[0].title}`,` Size: ${d[0].sizeFmt}`,"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"];We(t.code,f,p)}let h=d.length;for(let m=0;m<h;m++){let p=d[m],y={title:p.title};if(a!==void 0)y.threadTs=a;if(t.comment!==void 0&&m===0)y.initialComment=t.comment;let{fileId:F,permalink:C}=await bu(e,c,p.fp,y,t.cookie),T=h>1?`[${m+1}/${h}] `:"";console.log(`${T}\u2713 Uploaded (file_id: ${F}${C?`, url: ${C}`:""})`)}}async function ih(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=O(await Zc(e,c,t));for(let d of Y(u.files))s.push(O(d));i=Number(O(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??""),d=typeof c.name==="string"?c.name:typeof c.title==="string"?c.title:u,l=typeof c.filetype==="string"?c.filetype:"?",f=typeof c.size==="number"?Us(c.size):"";console.log(`${u} ${l.padEnd(7)} ${f.padStart(9)} ${d}`)}}function ah(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 ch(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(O(n).text??O(n).name??O(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 uh(e,t,n,r){let s=ah(n);if(!s)throw Error(`Not a list ID or list URL: ${n}
|
|
257
|
+
`+"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=O(await Qc(e,s,c,t));for(let l of Y(u.items??u.records))o.push(O(l));let d=O(u.response_metadata).next_cursor;i=typeof d==="string"&&d?d: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??""),d=Y(c.fields).map(O).map((l)=>{let f=String(l.key??l.column_id??"?"),h=ch(l);return h?`${f}=${h}`:""}).filter(Boolean);console.log(`${u} ${d.join(" | ")}`)}}function lh(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 fh(e,t,n,r){let s=lh(n);if(!s)throw Error(`Not a file ID or file permalink: ${n}
|
|
258
|
+
`+"Expected F\u2026 or https://<ws>.slack.com/files/<UID>/<FID>/<name>");let o=O(await Vc(e,s,t)),i=O(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 d=await fetch(c,{headers:u});if(!d.ok)throw Error(`Download failed: HTTP ${d.status} ${d.statusText}`);let l=Buffer.from(await d.arrayBuffer()),{statSync:f,existsSync:h}=await import("fs"),{basename:m}=await import("path"),p=r??a;if(r&&h(r)&&f(r).isDirectory())p=yt(r,m(a));Vu(p,l),console.log(`\u2713 Downloaded ${a} (${Us(l.length)}) \u2192 ${p}`)}async function dh(){pp();let e=(s)=>hn(s.workspace),t=(s)=>Tr(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 xp(e(s),i)};await ba(ar(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"||o==="agent"||o==="sent")return;try{hn(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:
|
|
259
|
+
`),await Es(),process.exit(0);throw i}},!0).command("agent","Bot agent session status and command heartbeat",(s)=>yc(s,on)).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 yp(o,s.target,s.limit,i,s.unreplied,t(s));else await bp(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 wp(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 Ep(e(o),o.limit,o.filter,o.all,o.json?"jsonl":o.format,t(o))}).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}`,d=await De(i,u,a),l=O(await Pn(i,d,a)),f=O(l.channel),h=typeof f.name==="string"?f.name:d,p=f.is_im===!0?"@":"#",y=String(O(f.purpose).value??""),F=String(O(f.topic).value??""),C=f.num_members??f.member_count??"";if(console.log(`${p}${h} ${d}`),F)console.log(`topic: ${F}`);if(y)console.log(`purpose: ${y}`);if(C)console.log(`members: ${C}`);console.log(`private: ${f.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,d=o.invite.filter(Boolean),l=await rn(i,a),f=Ye(c,String(u),d.join(","),l?.userId??"");if(o.code!==f)We(o.code,f,["--- Creating channel -------------------------",Ue(l,{pad:9}),` name: ${u?"\uD83D\uDD12 ":"#"}${c}`,` private: ${u}`,...d.length?[` invite: ${d.join(", ")}`]:[],"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);let h;try{h=await cu(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 ":"#"}${h.name} (${h.id})`),d.length){let m=[];for(let p of d)try{m.push(p.startsWith("U")||p.startsWith("W")?p:await rt(i,p,a))}catch(y){console.error(` ! could not resolve ${p}: ${y instanceof Error?y.message:String(y)}`)}for(let p of m)try{let y=O(await On(i,p,a)),F=O(y.user);if(F.is_ultra_restricted===!0)console.error(`\u26A0 ${p} is a single-channel guest \u2014 Slack restricts them to their one existing channel; this invite will likely report success but not actually add them.`);else if(F.is_restricted===!0)console.error(`\u26A0 ${p} is a multi-channel guest \u2014 double-check they were actually added (guest invites can silently no-op depending on workspace restrictions).`)}catch{}if(m.length)try{await uu(i,h.id,m,a),console.log(`\u2713 Invited ${m.length} member${m.length===1?"":"s"}`)}catch(p){console.error(` ! invite failed: ${p instanceof Error?p.message:String(p)}`)}}}).demandCommand(1,"").showHelpOnFail(!0)).command(["user","usr"],"User commands",(s)=>s.command(["ls","list"],"List workspace members",(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 hu(a,c),d=o.filter?.toLowerCase(),l=Y(u.members).map(O);if(o.external){let p=new Set(l.map((T)=>String(T.id))),y=O(await $n(a,c)),F=Y(y.channels).map(O).filter((T)=>T.is_ext_shared===!0&&!!T.name),C=new Set;for(let T of F)try{for(let S of await gu(a,String(T.id),c))if(!p.has(S))C.add(S)}catch{}for(let T of C)try{let S=O(await On(a,T,c)),v=O(S.user);if(v.id)l.push(v)}catch{}}let f=l.filter((p)=>p.deleted!==!0&&p.is_bot!==!0&&String(p.id)!=="USLACKBOT").filter((p)=>{if(!d)return!0;let y=String(p.name??"").toLowerCase(),F=String(O(p.profile).real_name??"").toLowerCase(),C=String(O(p.profile).email??"").toLowerCase();return y.includes(d)||F.includes(d)||C.includes(d)}).slice(0,o.limit);if(i==="jsonl"){for(let p of f)console.log(JSON.stringify(p));return}if(i==="yaml"){for(let p of f){let y=function(F,C=""){if(F===null)return"null";if(typeof F==="string")return F.includes(`
|
|
215
260
|
`)?`|
|
|
216
|
-
${
|
|
261
|
+
${F.split(`
|
|
217
262
|
`).join(`
|
|
218
|
-
`)}`:
|
|
219
|
-
${
|
|
220
|
-
${
|
|
221
|
-
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
|
|
263
|
+
`)}`:F;if(typeof F!=="object")return String(F);if(Array.isArray(F))return F.map((T)=>`
|
|
264
|
+
${C} - ${y(T,C+" ")}`).join("");return Object.entries(F).map(([T,S])=>`
|
|
265
|
+
${C} ${T}: ${y(S,C+" ")}`).join("")};console.log("---");for(let[F,C]of Object.entries(p))console.log(`${F}: ${y(C)}`)}return}let h=Intl.DateTimeFormat().resolvedOptions().timeZone,m=f.length?String(O(Y(u.members).map(O)[0]??{}).team_id??""):"";for(let p of f){let y=O(p.profile),F=String(p.name??p.id),C=String(p.id??""),T=String(y.display_name||""),S=String(y.real_name||""),v=String(y.email||""),K=String(p.tz??""),z=[...new Set([T,S].filter((A)=>A&&A!==F))].join(" / "),W=K&&K!==h?K:"",Z=String(p.team_id??""),k=p.is_stranger===!0||m&&Z&&Z!==m?`external:${Z||"?"}`:p.is_ultra_restricted===!0?"single-channel guest":p.is_restricted===!0?"guest":"",E=[v,W].filter(Boolean).join(" ");console.log(`@${F} ${C} ${z}${E?" "+E:""}${k?` [${k}]`:""}`)}}).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 rt(i,c,a)}catch(P){console.error(P instanceof Error?P.message:String(P)),process.exit(1)}let d=O(await On(i,u,a)),l=O(d.user),f=O(l.profile),h=Intl.DateTimeFormat().resolvedOptions().timeZone,m=String(l.name??u),p=String(l.id??u),y=String(f.display_name||""),F=String(f.real_name||""),C=String(f.email||""),T=String(l.tz??""),S=String(f.phone||""),v=String(f.title||"");console.log(`@${m} ${p}`);let K=[...new Set([y,F].filter((P)=>P&&P!==m))];if(K.length)console.log(`name: ${K.join(" / ")}`);if(C)console.log(`email: ${C}`);if(S)console.log(`phone: ${S}`);if(v)console.log(`title: ${v}`);if(T&&T!==h)console.log(`tz: ${T}`)}).demandCommand(1,"").showHelpOnFail(!0)).command("news","Activity feed (mentions to you)",(s)=>s.option("limit",{alias:"l",type:"number",default:20}),async(s)=>{await Cp(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 el(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=dt();if(!a)console.error(`Error: --as-bot needs a bot token, but no xoxb- token was found.
|
|
266
|
+
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 rt(e(s),o.target,t(s))}catch(c){console.error(`Error: could not resolve ${o.target} to a user for the bot DM.
|
|
222
267
|
${c instanceof Error?c.message:String(c)}
|
|
223
|
-
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
|
|
224
|
-
Set SLACK_BOT_TOKEN=xoxb-... in ~/.config/slack-cli/.env (or your shell).`),process.exit(
|
|
225
|
-
Set SLACK_BOT_TOKEN=xoxb-... in ~/.config/slack-cli/.env (or your shell).`),process.exit(
|
|
226
|
-
${
|
|
227
|
-
Tip: pass --user-id <Uxxxx> to skip the lookup.`),process.exit(
|
|
228
|
-
Set SLACK_BOT_TOKEN=xoxb-... in ~/.config/slack-cli/.env (or your shell).`),process.exit(
|
|
229
|
-
${
|
|
230
|
-
Tip: pass --user-id <Uxxxx> to skip the lookup.`),process.exit(
|
|
231
|
-
|
|
268
|
+
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 Lp(i,o)}catch(a){console.error(ot(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 = a reply matched several choices (stdout empty), 5 = a free-text reply that picked none of the choices (the reply is on stdout; NOT a decision \u2014 the question stays open)."}).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("after",{type:"string",describe:"With --waitFor: ignore text replies at or before this ts (the reply an exit 5 already delivered). Reactions still count."}).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(be);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(be);let l,f;if(s["as-bot"]){let h=dt();if(!h)console.error(`Error: --as-bot needs a bot token, but no xoxb- token was found.
|
|
269
|
+
Set SLACK_BOT_TOKEN=xoxb-... in ~/.config/slack-cli/.env (or your shell).`),process.exit(be);l=h}else l=e(s),f=t(s);try{let h={link:o,timeout:i,asBot:!!s["as-bot"]};if(f)h.cookie=f;if(s.after){let m=String(s.after);if(!/^\d{10}\.\d{6}$/.test(m))console.error(`Error: --after needs a message ts like 1700000000.000100 (got ${ee(m)})`),process.exit(be);h.after=m}await Yp(l,h)}catch(h){console.error(ot(h)),process.exit(be)}return}if(!s.target)console.error("Error: target is required (or use --waitFor <permalink> to collect an answer)"),process.exit(be);let a=String(s.question??"").trim();if(!a)console.error("Error: question is empty"),process.exit(be);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 d;if(s["as-bot"]){let l=dt();if(!l)console.error(`Error: --as-bot needs a bot token, but no xoxb- token was found.
|
|
270
|
+
Set SLACK_BOT_TOKEN=xoxb-... in ~/.config/slack-cli/.env (or your shell).`),process.exit(be);if(!c.channelId&&!c.userId&&c.target.startsWith("@"))try{c.userId=await rt(e(s),c.target,t(s))}catch(f){console.error(`Error: could not resolve ${c.target} to a user for the bot DM.
|
|
271
|
+
${f instanceof Error?f.message:String(f)}
|
|
272
|
+
Tip: pass --user-id <Uxxxx> to skip the lookup.`),process.exit(be)}d=l,c.asBot=!0}else{d=e(s);let l=t(s);if(l)c.cookie=l}try{await Gp(d,c)}catch(l){console.error(ot(l)),process.exit(be)}}).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(je);let i=()=>{let f=dt();if(!f)console.error(`Error: --as-bot needs a bot token, but no xoxb- token was found.
|
|
273
|
+
Set SLACK_BOT_TOKEN=xoxb-... in ~/.config/slack-cli/.env (or your shell).`),process.exit(je);return f};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(je);let f=e(s),h=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(h)m.cookie=h;if(s["as-bot"])m.writeToken=i();await eh(f,m)}catch(m){console.error(ot(m)),process.exit(je)}return}if(!s.target)console.error("Error: target is required (or use --results <permalink> to count a poll)"),process.exit(je);let a=String(s.question??"").trim();if(!a)console.error("Error: question is empty"),process.exit(je);let c=(s.choices??[]).map((f)=>String(f).trim()).filter(Boolean);if(c.length<2||c.length>Qt)console.error(`Error: poll needs 2..${Qt} choices (got ${c.length}). For a free-text question use \`slack ask\`.`),process.exit(je);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 d=t(s);if(d)u.mentionCookie=d;let l;if(s["as-bot"]){let f=i();if(!u.channelId&&!u.userId&&u.target.startsWith("@"))try{u.userId=await rt(e(s),u.target,t(s))}catch(h){console.error(`Error: could not resolve ${u.target} to a user for the bot DM.
|
|
274
|
+
${h instanceof Error?h.message:String(h)}
|
|
275
|
+
Tip: pass --user-id <Uxxxx> to skip the lookup.`),process.exit(je)}l=f,u.asBot=!0}else{l=e(s);let f=t(s);if(f)u.cookie=f}try{await Zp(l,u)}catch(f){console.error(ot(f)),process.exit(je)}}).command("sent [query]","Search what THIS machine posted/edited (send, ask, poll, edit) and who sent it \u2014 read-only, local log",(s)=>s.positional("query",{type:"string",describe:"Substring of the message text (case-insensitive)"}).option("channel",{type:"string",describe:"Channel/DM id (C\u2026/D\u2026) or the target as typed (#eng, @bob)"}).option("since",{type:"string",describe:"Only newer than this: 30m, 2h, 7d, 1w, or an ISO date"}).option("session",{type:"string",describe:"Agent session id (prefix match)"}).option("cwd",{type:"string",describe:"Working directory the sender ran in (prefix match)"}).option("kind",{type:"string",choices:["send","ask","poll","edit"],describe:"Only this kind of write"}).option("json",{type:"boolean",default:!1,describe:"One JSON object per line (every recorded field)"}).option("count",{alias:"n",type:"number",default:50,describe:"Max rows (newest first)"}),(s)=>{let o;if(s.since!==void 0){if(o=zc(String(s.since)),o===void 0)console.error(`Error: --since needs 30m / 2h / 7d / 1w or an ISO date (got ${ee(String(s.since))})`),process.exit(1)}let i={limit:Number(s.count)||50};if(s.query)i.text=String(s.query);if(s.channel)i.channel=String(s.channel);if(o!==void 0)i.sinceMs=o;if(s.session)i.session=String(s.session);if(s.cwd){let c=fp(String(s.cwd));try{i.cwd=lp(c)}catch{i.cwd=c}}if(s.kind)i.kind=s.kind;let a=Jc(i);if(!a)console.error(`Error: ${mo}
|
|
276
|
+
(${kn()})`),process.exit(1);if(s.json){for(let c of a)console.log(JSON.stringify(c));return}if(!a.length){console.error(`No sent messages match (log: ${kn()}).`);return}for(let c of a)console.log(Pp(c))}).command("doctor","Check the bot token (xoxb) can carry a two-way DM (scopes + Messages Tab)",(s)=>s,async()=>{let s=dt();if(!s)console.error(`Error: slack doctor checks the bot token, but no xoxb- token was found.
|
|
277
|
+
Set SLACK_BOT_TOKEN=xoxb-... in ~/.config/slack-cli/.env (or your shell).`),process.exit(1);await th(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=Oo();if(!i.channelId&&!i.userId&&i.target.startsWith("@"))try{i.userId=await rt(e(o),i.target,t(o))}catch(u){console.error(`Error: could not resolve ${i.target} to a user for the bot DM.
|
|
232
278
|
${u instanceof Error?u.message:String(u)}
|
|
233
|
-
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 Xd(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=so(),c=o["channel-id"];if(!c&&i?.startsWith("@"))c=await au(i,a,e(o),t(o));await cu(a,i,c);return}await cu(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=so();if(!i.channelId&&i.target.startsWith("@"))i.channelId=await au(i.target,c,e(o),t(o));i.asBot=!0,await uu(c,i);return}let a=t(o);if(a)i.cookie=a;await uu(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 ru(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 Ad(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 ru(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 Od(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)Qr(!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 yd(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 bd(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:Zr,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 wd(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)Qr(!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 Gd(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 Vd(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 eh(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 nh(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 Fd(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 Ed(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 xd(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 Fn(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=As(f),d=await nn(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(`
|
|
234
|
-
`).map((
|
|
235
|
-
`).map((
|
|
236
|
-
`).map((
|
|
237
|
-
`))}).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
|
|
279
|
+
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 rh(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=Oo(),c=o["channel-id"];if(!c&&i?.startsWith("@"))c=await qu(i,a,e(o),t(o));await Xu(a,i,c);return}await Xu(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=Oo();if(!i.channelId&&i.target.startsWith("@"))i.channelId=await qu(i.target,c,e(o),t(o));i.asBot=!0,await Gu(c,i);return}let a=t(o);if(a)i.cookie=a;await Gu(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 Ju(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 Np(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 Ju(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 vp(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 Bp(e(s),o)}catch(a){console.error(ot(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)So(!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 kp(e(o),i)}catch(c){console.error(ot(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 _p(e(o),i)}catch(c){console.error(ot(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:_o,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 Sp(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)So(!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 oh(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 ih(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 uh(e(s),t(s),s.ref,{limit:s.limit,format:o})}catch(i){console.error(ot(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 fh(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 Ap(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 Tp(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),d=await mu(i,u,c,a);console.log(`\u2713 Draft created (id: ${O(d.draft).id??"?"})`)}).command("get <id>","Show a draft",(o)=>o.positional("id",{type:"string",demandOption:!0}),async(o)=>{await Ip(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 In(i,a),d=Y(u.drafts).map(O).find((p)=>String(p.id)===o.id);if(!d)console.error(`Draft not found: ${o.id}`),process.exit(1);let l=Ls(d),f=await rn(i,a),h=Ye(l,c,f?.userId??"");if(o.code!==h)We(o.code,h,["--- Editing draft as -------------------------",Ue(f),"--- Current draft ----------------------------",...l.split(`
|
|
280
|
+
`).map((p)=>` ${p}`),"--- Replacing with ---------------------------",...c.split(`
|
|
281
|
+
`).map((p)=>` ${p}`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);let m=await Du(i,o.id,vo(d),c,a);console.log(`\u2713 Draft updated (id: ${O(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 In(i,a),u=Y(c.drafts).map(O).find((h)=>String(h.id)===o.id);if(!u)console.error(`Draft not found: ${o.id}`),process.exit(1);let d=Ls(u),l=await rn(i,a),f=Ye(o.id,d,l?.userId??"");if(o.code!==f)We(o.code,f,["\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",Ue(l),` id: ${o.id}`,...d.split(`
|
|
282
|
+
`).map((h)=>` ${h}`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);await wu(i,o.id,a),console.log(`\u2713 Draft deleted (id: ${o.id})`)})).command("auth","Authentication and workspace management",(s)=>s.command("token","Print the active token (or save one with --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)=>{if(o.token===void 0){console.log(hn(o.workspace));return}await sc({...o.token!==void 0?{token:o.token}:{},...o.name!==void 0?{name:o.name}:{}})}).command("env","Print active workspace credentials in dotenv format",()=>{},(o)=>{let i=hn(o.workspace),a=i.startsWith("xoxc-")?Tr(o.workspace):void 0,c=[["SLACK_TOKEN",i]];if(a)c.push(["SLACK_COOKIE",a]);let u=c.map(([d,l])=>{if(/[\r\n\0']/.test(l))throw Error(`Cannot export ${d}: unsupported characters in credential`);return`${d}='${l}'`});console.log(u.join(`
|
|
283
|
+
`))}).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 rc({...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)"}).option("yes",{type:"boolean",default:!1,describe:"Allow reading browser profiles without a confirmation prompt"}).option("from-desktop",{type:"boolean",default:!1,describe:"Import the Slack Desktop token without scanning a browser"}).option("from-chrome",{type:"boolean",default:!1,describe:"Import the desktop token and Chrome cookie"}).option("from-firefox",{type:"boolean",default:!1,describe:"Import the desktop token and Firefox cookie"}).option("from-all",{type:"boolean",default:!1,describe:"Import the desktop token and scan Chrome and Firefox"}),async(o)=>{await Es({...o.token!==void 0?{token:o.token}:{},...o.name!==void 0?{name:o.name}:{},yes:o.yes,fromDesktop:o.fromDesktop,fromChrome:o.fromChrome,fromFirefox:o.fromFirefox,fromAll:o.fromAll})}).command("tokens","Print the selected credentials as dotenv assignments",(o)=>o.option("workspace",{type:"string",alias:"w",describe:"Workspace name (default: active)"}),(o)=>oc({...o.workspace!==void 0?{workspace:o.workspace}:{}})).command("save","Save the active profile token and cookie to an env file",(o)=>o.option("envfile",{type:"string",demandOption:!0,describe:"Destination env file (e.g. ./.env.local)"}).option("workspace",{type:"string",alias:"w",describe:"Workspace name (default: active)"}),(o)=>ic({envfile:o.envfile,...o.workspace!==void 0?{workspace:o.workspace}:{}})).command(["ls","status"],"Show auth status",()=>{},()=>{let o=$r();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)dp(yt(process.cwd(),".slack-cli"));Sa(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)=>{_a(o.name),console.log(`Removed workspace "${o.name}"`)}).command(["chrome","cookie"],"Attach Chrome browser xoxd cookie to a workspace (macOS/Linux, interactive)",(o)=>o.option("workspace",{type:"string",alias:"w",describe:"Workspace name to update (default: active)"}).option("yes",{type:"boolean",default:!1,describe:"Allow reading browser profiles without a confirmation prompt"}),async(o)=>{await tc({...o.workspace!==void 0?{workspace:o.workspace}:{},yes:o.yes})}).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)"}).option("yes",{type:"boolean",default:!1,describe:"Allow reading browser profiles without a confirmation prompt"}),async(o)=>{await nc({...o.workspace!==void 0?{workspace:o.workspace}:{},yes:o.yes})}).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 pc(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"}).option("yes",{type:"boolean",default:!1}).option("from-desktop",{type:"boolean",default:!1}).option("from-chrome",{type:"boolean",default:!1}).option("from-firefox",{type:"boolean",default:!1}).option("from-all",{type:"boolean",default:!1}),async(s)=>{await Es({...s.token!==void 0?{token:s.token}:{},...s.name!==void 0?{name:s.name}:{},yes:s.yes,fromDesktop:s.fromDesktop,fromChrome:s.fromChrome,fromFirefox:s.fromFirefox,fromAll:s.fromAll})}).demandCommand(1,"Specify a command. Run with --help for usage.").strict().help().alias("help","h").parseAsync()}dh().catch((e)=>{console.error(e instanceof Error?e.message:String(e)),process.exit(1)});
|