slack-term 1.28.1 → 1.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +74 -73
- package/package.json +1 -1
- package/ts/cli.ts +8 -0
- package/ts/quietHours.ts +43 -0
package/dist/cli.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
import{createRequire as zc}from"node:module";var vc=Object.create;var{getPrototypeOf:jc,defineProperty:Xi,getOwnPropertyNames:Lc}=Object;var Wc=Object.prototype.hasOwnProperty;function Uc(e){return this[e]}var Jc,Kc,Gi=(e,t,n)=>{var i=e!=null&&typeof e==="object";if(i){var s=t?Jc??=new WeakMap:Kc??=new WeakMap,r=s.get(e);if(r)return r}n=e!=null?vc(jc(e)):{};let o=t||!e||!e.__esModule?Xi(n,"default",{value:e,enumerable:!0}):n;if(e&&typeof e==="object"||typeof e==="function"){for(let a of Lc(e))if(!Wc.call(o,a))Xi(o,a,{get:Uc.bind(e,a),enumerable:!0})}if(i)s.set(e,o);return o};var Vi=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var qe=zc(import.meta.url);var gr=Vi(function(Nd,hr){hr.exports=()=>/[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E-\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED8\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])))?))?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3C-\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE8A\uDE8E-\uDEC2\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF]|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g});var Wr=Vi(function(_p,Lr){Lr.exports=function(t){if(t===void 0)t=2;if(t>=Error.stackTraceLimit)throw TypeError("getCallerFile(position) requires position be less then Error.stackTraceLimit but position was: `"+t+"` and Error.stackTraceLimit was: `"+Error.stackTraceLimit+"`");var n=Error.prepareStackTrace;Error.prepareStackTrace=function(s,r){return r};var i=Error().stack;if(Error.prepareStackTrace=n,i!==null&&typeof i==="object")return i[t]?i[t].getFileName():void 0}});import{createHash as hf}from"crypto";import{existsSync as Ac,readFileSync as gf,mkdirSync as mf,writeFileSync as $c}from"fs";import{homedir as Ec}from"os";import{join as ft}from"path";import{notStrictEqual as Ou,strictEqual as Iu}from"assert";var Hc={right:Xc,center:Gc};class Qi{constructor(e){var t;this.width=e.width,this.wrap=(t=e.wrap)!==null&&t!==void 0?t:!0,this.rows=[]}span(...e){let t=this.div(...e);t.span=!0}resetOutput(){this.rows=[]}div(...e){if(e.length===0)this.div("");if(this.wrap&&this.shouldApplyLayoutDSL(...e)&&typeof e[0]==="string")return this.applyLayoutDSL(e[0]);let t=e.map((n)=>{if(typeof n==="string")return this.colFromString(n);return n});return this.rows.push(t),t}shouldApplyLayoutDSL(...e){return e.length===1&&typeof e[0]==="string"&&/[\t\n]/.test(e[0])}applyLayoutDSL(e){let t=e.split(`
|
|
3
|
+
import{createRequire as Hc}from"node:module";var jc=Object.create;var{getPrototypeOf:Lc,defineProperty:Xi,getOwnPropertyNames:Wc}=Object;var Uc=Object.prototype.hasOwnProperty;function Jc(e){return this[e]}var Kc,zc,Gi=(e,t,n)=>{var i=e!=null&&typeof e==="object";if(i){var s=t?Kc??=new WeakMap:zc??=new WeakMap,r=s.get(e);if(r)return r}n=e!=null?jc(Lc(e)):{};let o=t||!e||!e.__esModule?Xi(n,"default",{value:e,enumerable:!0}):n;if(e&&typeof e==="object"||typeof e==="function"){for(let a of Wc(e))if(!Uc.call(o,a))Xi(o,a,{get:Jc.bind(e,a),enumerable:!0})}if(i)s.set(e,o);return o};var Vi=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var qe=Hc(import.meta.url);var gr=Vi(function(vd,hr){hr.exports=()=>/[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E-\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED8\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])))?))?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3C-\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE8A\uDE8E-\uDEC2\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF]|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g});var Wr=Vi(function(Sp,Lr){Lr.exports=function(t){if(t===void 0)t=2;if(t>=Error.stackTraceLimit)throw TypeError("getCallerFile(position) requires position be less then Error.stackTraceLimit but position was: `"+t+"` and Error.stackTraceLimit was: `"+Error.stackTraceLimit+"`");var n=Error.prepareStackTrace;Error.prepareStackTrace=function(s,r){return r};var i=Error().stack;if(Error.prepareStackTrace=n,i!==null&&typeof i==="object")return i[t]?i[t].getFileName():void 0}});import{createHash as gf}from"crypto";import{existsSync as $c,readFileSync as mf,mkdirSync as Df,writeFileSync as Oc}from"fs";import{homedir as xc}from"os";import{join as ft}from"path";import{notStrictEqual as Iu,strictEqual as Tu}from"assert";var qc={right:Gc,center:Vc};class Qi{constructor(e){var t;this.width=e.width,this.wrap=(t=e.wrap)!==null&&t!==void 0?t:!0,this.rows=[]}span(...e){let t=this.div(...e);t.span=!0}resetOutput(){this.rows=[]}div(...e){if(e.length===0)this.div("");if(this.wrap&&this.shouldApplyLayoutDSL(...e)&&typeof e[0]==="string")return this.applyLayoutDSL(e[0]);let t=e.map((n)=>{if(typeof n==="string")return this.colFromString(n);return n});return this.rows.push(t),t}shouldApplyLayoutDSL(...e){return e.length===1&&typeof e[0]==="string"&&/[\t\n]/.test(e[0])}applyLayoutDSL(e){let t=e.split(`
|
|
4
4
|
`).map((i)=>i.split("\t")),n=0;return t.forEach((i)=>{if(i.length>1&&xe.stringWidth(i[0])>n)n=Math.min(Math.floor(this.width*0.5),xe.stringWidth(i[0]))}),t.forEach((i)=>{this.div(...i.map((s,r)=>({text:s.trim(),padding:this.measurePadding(s),width:r===0&&i.length>1?n:void 0})))}),this.rows[this.rows.length-1]}colFromString(e){return{text:e,padding:this.measurePadding(e)}}measurePadding(e){let t=xe.stripAnsi(e);return[0,t.match(/\s*$/)[0].length,0,t.match(/^\s*/)[0].length]}toString(){let e=[];return this.rows.forEach((t)=>{this.rowToString(t,e)}),e.filter((t)=>!t.hidden).map((t)=>t.text).join(`
|
|
5
|
-
`)}rowToString(e,t){return this.rasterize(e).forEach((n,i)=>{let s="";n.forEach((r,o)=>{let{width:a}=e[o],c=this.negatePadding(e[o]),u=r;if(c>xe.stringWidth(r))u+=" ".repeat(c-xe.stringWidth(r));if(e[o].align&&e[o].align!=="left"&&this.wrap){let l=
|
|
5
|
+
`)}rowToString(e,t){return this.rasterize(e).forEach((n,i)=>{let s="";n.forEach((r,o)=>{let{width:a}=e[o],c=this.negatePadding(e[o]),u=r;if(c>xe.stringWidth(r))u+=" ".repeat(c-xe.stringWidth(r));if(e[o].align&&e[o].align!=="left"&&this.wrap){let l=qc[e[o].align];if(u=l(u,c),xe.stringWidth(u)<c)u+=" ".repeat((a||0)-xe.stringWidth(u)-1)}let f=e[o].padding||[0,0,0,0];if(f[3])s+=" ".repeat(f[3]);if(s+=Zi(e[o],u,"| "),s+=u,s+=Zi(e[o],u," |"),f[1])s+=" ".repeat(f[1]);if(i===0&&t.length>0)s=this.renderInline(s,t[t.length-1])}),t.push({text:s.replace(/ +$/,""),span:e.span})}),t}renderInline(e,t){let n=e.match(/^ */),i=n?n[0].length:0,s=t.text,r=xe.stringWidth(s.trimRight());if(!t.span)return e;if(!this.wrap)return t.hidden=!0,s+e;if(i<r)return e;return t.hidden=!0,s.trimRight()+" ".repeat(i-r)+e.trimLeft()}rasterize(e){let t=[],n=this.columnWidths(e),i;return e.forEach((s,r)=>{if(s.width=n[r],this.wrap)i=xe.wrap(s.text,this.negatePadding(s),{hard:!0}).split(`
|
|
6
6
|
`);else i=s.text.split(`
|
|
7
|
-
`);if(s.border)i.unshift("."+"-".repeat(this.negatePadding(s)+2)+"."),i.push("'"+"-".repeat(this.negatePadding(s)+2)+"'");if(s.padding)i.unshift(...Array(s.padding[0]||0).fill("")),i.push(...Array(s.padding[2]||0).fill(""));i.forEach((o,a)=>{if(!t[a])t.push([]);let c=t[a];for(let u=0;u<r;u++)if(c[u]===void 0)c.push("");c.push(o)})}),t}negatePadding(e){let t=e.width||0;if(e.padding)t-=(e.padding[3]||0)+(e.padding[1]||0);if(e.border)t-=4;return t}columnWidths(e){if(!this.wrap)return e.map((r)=>r.width||xe.stringWidth(r.text));let t=e.length,n=this.width,i=e.map((r)=>{if(r.width)return t--,n-=r.width,r.width;return}),s=t?Math.floor(n/t):0;return i.map((r,o)=>{if(r===void 0)return Math.max(s,qc(e[o]));return r})}}function Zi(e,t,n){if(e.border){if(/[.']-+[.']/.test(t))return"";if(t.trim().length!==0)return n;return" "}return""}function qc(e){let t=e.padding||[],n=1+(t[3]||0)+(t[1]||0);if(e.border)return n+4;return n}function Yc(){if(typeof process==="object"&&process.stdout&&process.stdout.columns)return process.stdout.columns;return 80}function Xc(e,t){e=e.trim();let n=xe.stringWidth(e);if(n<t)return" ".repeat(t-n)+e;return e}function Gc(e,t){e=e.trim();let n=xe.stringWidth(e);if(n>=t)return e;return" ".repeat(t-n>>1)+e}var xe;function er(e,t){return xe=t,new Qi({width:(e===null||e===void 0?void 0:e.width)||Yc(),wrap:e===null||e===void 0?void 0:e.wrap})}function ys({onlyFirst:e=!1}={}){return new RegExp("(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]",e?void 0:"g")}var Vc=ys();function dt(e){if(typeof e!=="string")throw TypeError(`Expected a \`string\`, got \`${typeof e}\``);if(!e.includes("\x1B")&&!e.includes(""))return e;return e.replace(Vc,"")}var tr=161,nr=1114109,sr=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],ir=12288,rr=65510,or=[12288,12288,65281,65376,65504,65510];var ar=4352,cr=262141,ws=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141];var Cn=(e,t)=>{let n=0,i=Math.floor(e.length/2)-1;while(n<=i){let s=Math.floor((n+i)/2),r=s*2;if(t<e[r])i=s-1;else if(t>e[r+1])n=s+1;else return!0}return!1};var ur=19968,[Zc,Qc]=eu(ws);function eu(e){let t=e[0],n=e[1];for(let i=0;i<e.length;i+=2){let s=e[i],r=e[i+1];if(ur>=s&&ur<=r)return[s,r];if(r-s>n-t)t=s,n=r}return[t,n]}var lr=(e)=>{if(e<tr||e>nr)return!1;return Cn(sr,e)},fr=(e)=>{if(e<ir||e>rr)return!1;return Cn(or,e)};var dr=(e)=>{if(e>=Zc&&e<=Qc)return!0;if(e<ar||e>cr)return!1;return Cn(ws,e)};function tu(e){if(!Number.isSafeInteger(e))throw TypeError(`Expected a code point, got \`${typeof e}\`.`)}function pr(e,{ambiguousAsWide:t=!1}={}){if(tu(e),fr(e)||dr(e)||t&&lr(e))return 2;return 1}var mr=Gi(gr(),1),nu=new Intl.Segmenter,su=/^\p{Default_Ignorable_Code_Point}$/u;function Le(e,t={}){if(typeof e!=="string"||e.length===0)return 0;let{ambiguousIsNarrow:n=!0,countAnsiEscapeCodes:i=!1}=t;if(!i)e=dt(e);if(e.length===0)return 0;let s=0,r={ambiguousAsWide:!n};for(let{segment:o}of nu.segment(e)){let a=o.codePointAt(0);if(a<=31||a>=127&&a<=159)continue;if(a>=8203&&a<=8207||a===65279)continue;if(a>=768&&a<=879||a>=6832&&a<=6911||a>=7616&&a<=7679||a>=8400&&a<=8447||a>=65056&&a<=65071)continue;if(a>=55296&&a<=57343)continue;if(a>=65024&&a<=65039)continue;if(su.test(o))continue;if(mr.default().test(o)){s+=2;continue}s+=pr(a,r)}return s}var Dr=(e=0)=>(t)=>`\x1B[${t+e}m`,yr=(e=0)=>(t)=>`\x1B[${38+e};5;${t}m`,wr=(e=0)=>(t,n,i)=>`\x1B[${38+e};2;${t};${n};${i}m`,se={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},Wd=Object.keys(se.modifier),iu=Object.keys(se.color),ru=Object.keys(se.bgColor),Ud=[...iu,...ru];function ou(){let e=new Map;for(let[t,n]of Object.entries(se)){for(let[i,s]of Object.entries(n))se[i]={open:`\x1B[${s[0]}m`,close:`\x1B[${s[1]}m`},n[i]=se[i],e.set(s[0],s[1]);Object.defineProperty(se,t,{value:n,enumerable:!1})}return Object.defineProperty(se,"codes",{value:e,enumerable:!1}),se.color.close="\x1B[39m",se.bgColor.close="\x1B[49m",se.color.ansi=Dr(),se.color.ansi256=yr(),se.color.ansi16m=wr(),se.bgColor.ansi=Dr(10),se.bgColor.ansi256=yr(10),se.bgColor.ansi16m=wr(10),Object.defineProperties(se,{rgbToAnsi256:{value(t,n,i){if(t===n&&n===i){if(t<8)return 16;if(t>248)return 231;return Math.round((t-8)/247*24)+232}return 16+36*Math.round(t/255*5)+6*Math.round(n/255*5)+Math.round(i/255*5)},enumerable:!1},hexToRgb:{value(t){let n=/[a-f\d]{6}|[a-f\d]{3}/i.exec(t.toString(16));if(!n)return[0,0,0];let[i]=n;if(i.length===3)i=[...i].map((r)=>r+r).join("");let s=Number.parseInt(i,16);return[s>>16&255,s>>8&255,s&255]},enumerable:!1},hexToAnsi256:{value:(t)=>se.rgbToAnsi256(...se.hexToRgb(t)),enumerable:!1},ansi256ToAnsi:{value(t){if(t<8)return 30+t;if(t<16)return 90+(t-8);let n,i,s;if(t>=232)n=((t-232)*10+8)/255,i=n,s=n;else{t-=16;let a=t%36;n=Math.floor(t/36)/5,i=Math.floor(a/6)/5,s=a%6/5}let r=Math.max(n,i,s)*2;if(r===0)return 30;let o=30+(Math.round(s)<<2|Math.round(i)<<1|Math.round(n));if(r===2)o+=60;return o},enumerable:!1},rgbToAnsi:{value:(t,n,i)=>se.ansi256ToAnsi(se.rgbToAnsi256(t,n,i)),enumerable:!1},hexToAnsi:{value:(t)=>se.ansi256ToAnsi(se.hexToAnsi256(t)),enumerable:!1}}),se}var au=ou(),br=au;var xn=new Set(["\x1B",""]),cu=39,Fs="\x07",Er="[",uu="]",xr="m",En=`${uu}8;;`,Fr=(e)=>`${xn.values().next().value}${Er}${e}${xr}`,Cr=(e)=>`${xn.values().next().value}${En}${e}${Fs}`,lu=(e)=>e.split(" ").map((t)=>Le(t)),bs=(e,t,n)=>{let i=[...t],s=!1,r=!1,o=Le(dt(e.at(-1)));for(let[a,c]of i.entries()){let u=Le(c);if(o+u<=n)e[e.length-1]+=c;else e.push(c),o=0;if(xn.has(c))s=!0,r=i.slice(a+1,a+1+En.length).join("")===En;if(s){if(r){if(c===Fs)s=!1,r=!1}else if(c===xr)s=!1;continue}if(o+=u,o===n&&a<i.length-1)e.push(""),o=0}if(!o&&e.at(-1).length>0&&e.length>1)e[e.length-2]+=e.pop()},fu=(e)=>{let t=e.split(" "),n=t.length;while(n>0){if(Le(t[n-1])>0)break;n--}if(n===t.length)return e;return t.slice(0,n).join(" ")+t.slice(n).join("")},du=(e,t,n={})=>{if(n.trim!==!1&&e.trim()==="")return"";let i="",s,r,o=lu(e),a=[""];for(let[l,d]of e.split(" ").entries()){if(n.trim!==!1)a[a.length-1]=a.at(-1).trimStart();let h=Le(a.at(-1));if(l!==0){if(h>=t&&(n.wordWrap===!1||n.trim===!1))a.push(""),h=0;if(h>0||n.trim===!1)a[a.length-1]+=" ",h++}if(n.hard&&o[l]>t){let m=t-h,p=1+Math.floor((o[l]-m-1)/t);if(Math.floor((o[l]-1)/t)<p)a.push("");bs(a,d,t);continue}if(h+o[l]>t&&h>0&&o[l]>0){if(n.wordWrap===!1&&h<t){bs(a,d,t);continue}a.push("")}if(h+o[l]>t&&n.wordWrap===!1){bs(a,d,t);continue}a[a.length-1]+=d}if(n.trim!==!1)a=a.map((l)=>fu(l));let c=a.join(`
|
|
8
|
-
`),u=[...c],f=0;for(let[l,d]of u.entries()){if(i+=d,xn.has(d)){let{groups:m}=new RegExp(`(?:\\${Er}(?<code>\\d+)m|\\${En}(?<uri>.*)${Fs})`).exec(c.slice(f))||{groups:{}};if(m.code!==void 0){let p=Number.parseFloat(m.code);s=p===
|
|
7
|
+
`);if(s.border)i.unshift("."+"-".repeat(this.negatePadding(s)+2)+"."),i.push("'"+"-".repeat(this.negatePadding(s)+2)+"'");if(s.padding)i.unshift(...Array(s.padding[0]||0).fill("")),i.push(...Array(s.padding[2]||0).fill(""));i.forEach((o,a)=>{if(!t[a])t.push([]);let c=t[a];for(let u=0;u<r;u++)if(c[u]===void 0)c.push("");c.push(o)})}),t}negatePadding(e){let t=e.width||0;if(e.padding)t-=(e.padding[3]||0)+(e.padding[1]||0);if(e.border)t-=4;return t}columnWidths(e){if(!this.wrap)return e.map((r)=>r.width||xe.stringWidth(r.text));let t=e.length,n=this.width,i=e.map((r)=>{if(r.width)return t--,n-=r.width,r.width;return}),s=t?Math.floor(n/t):0;return i.map((r,o)=>{if(r===void 0)return Math.max(s,Yc(e[o]));return r})}}function Zi(e,t,n){if(e.border){if(/[.']-+[.']/.test(t))return"";if(t.trim().length!==0)return n;return" "}return""}function Yc(e){let t=e.padding||[],n=1+(t[3]||0)+(t[1]||0);if(e.border)return n+4;return n}function Xc(){if(typeof process==="object"&&process.stdout&&process.stdout.columns)return process.stdout.columns;return 80}function Gc(e,t){e=e.trim();let n=xe.stringWidth(e);if(n<t)return" ".repeat(t-n)+e;return e}function Vc(e,t){e=e.trim();let n=xe.stringWidth(e);if(n>=t)return e;return" ".repeat(t-n>>1)+e}var xe;function er(e,t){return xe=t,new Qi({width:(e===null||e===void 0?void 0:e.width)||Xc(),wrap:e===null||e===void 0?void 0:e.wrap})}function ys({onlyFirst:e=!1}={}){return new RegExp("(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]",e?void 0:"g")}var Zc=ys();function dt(e){if(typeof e!=="string")throw TypeError(`Expected a \`string\`, got \`${typeof e}\``);if(!e.includes("\x1B")&&!e.includes(""))return e;return e.replace(Zc,"")}var tr=161,nr=1114109,sr=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],ir=12288,rr=65510,or=[12288,12288,65281,65376,65504,65510];var ar=4352,cr=262141,ws=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141];var Cn=(e,t)=>{let n=0,i=Math.floor(e.length/2)-1;while(n<=i){let s=Math.floor((n+i)/2),r=s*2;if(t<e[r])i=s-1;else if(t>e[r+1])n=s+1;else return!0}return!1};var ur=19968,[Qc,eu]=tu(ws);function tu(e){let t=e[0],n=e[1];for(let i=0;i<e.length;i+=2){let s=e[i],r=e[i+1];if(ur>=s&&ur<=r)return[s,r];if(r-s>n-t)t=s,n=r}return[t,n]}var lr=(e)=>{if(e<tr||e>nr)return!1;return Cn(sr,e)},fr=(e)=>{if(e<ir||e>rr)return!1;return Cn(or,e)};var dr=(e)=>{if(e>=Qc&&e<=eu)return!0;if(e<ar||e>cr)return!1;return Cn(ws,e)};function nu(e){if(!Number.isSafeInteger(e))throw TypeError(`Expected a code point, got \`${typeof e}\`.`)}function pr(e,{ambiguousAsWide:t=!1}={}){if(nu(e),fr(e)||dr(e)||t&&lr(e))return 2;return 1}var mr=Gi(gr(),1),su=new Intl.Segmenter,iu=/^\p{Default_Ignorable_Code_Point}$/u;function Le(e,t={}){if(typeof e!=="string"||e.length===0)return 0;let{ambiguousIsNarrow:n=!0,countAnsiEscapeCodes:i=!1}=t;if(!i)e=dt(e);if(e.length===0)return 0;let s=0,r={ambiguousAsWide:!n};for(let{segment:o}of su.segment(e)){let a=o.codePointAt(0);if(a<=31||a>=127&&a<=159)continue;if(a>=8203&&a<=8207||a===65279)continue;if(a>=768&&a<=879||a>=6832&&a<=6911||a>=7616&&a<=7679||a>=8400&&a<=8447||a>=65056&&a<=65071)continue;if(a>=55296&&a<=57343)continue;if(a>=65024&&a<=65039)continue;if(iu.test(o))continue;if(mr.default().test(o)){s+=2;continue}s+=pr(a,r)}return s}var Dr=(e=0)=>(t)=>`\x1B[${t+e}m`,yr=(e=0)=>(t)=>`\x1B[${38+e};5;${t}m`,wr=(e=0)=>(t,n,i)=>`\x1B[${38+e};2;${t};${n};${i}m`,se={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},Ud=Object.keys(se.modifier),ru=Object.keys(se.color),ou=Object.keys(se.bgColor),Jd=[...ru,...ou];function au(){let e=new Map;for(let[t,n]of Object.entries(se)){for(let[i,s]of Object.entries(n))se[i]={open:`\x1B[${s[0]}m`,close:`\x1B[${s[1]}m`},n[i]=se[i],e.set(s[0],s[1]);Object.defineProperty(se,t,{value:n,enumerable:!1})}return Object.defineProperty(se,"codes",{value:e,enumerable:!1}),se.color.close="\x1B[39m",se.bgColor.close="\x1B[49m",se.color.ansi=Dr(),se.color.ansi256=yr(),se.color.ansi16m=wr(),se.bgColor.ansi=Dr(10),se.bgColor.ansi256=yr(10),se.bgColor.ansi16m=wr(10),Object.defineProperties(se,{rgbToAnsi256:{value(t,n,i){if(t===n&&n===i){if(t<8)return 16;if(t>248)return 231;return Math.round((t-8)/247*24)+232}return 16+36*Math.round(t/255*5)+6*Math.round(n/255*5)+Math.round(i/255*5)},enumerable:!1},hexToRgb:{value(t){let n=/[a-f\d]{6}|[a-f\d]{3}/i.exec(t.toString(16));if(!n)return[0,0,0];let[i]=n;if(i.length===3)i=[...i].map((r)=>r+r).join("");let s=Number.parseInt(i,16);return[s>>16&255,s>>8&255,s&255]},enumerable:!1},hexToAnsi256:{value:(t)=>se.rgbToAnsi256(...se.hexToRgb(t)),enumerable:!1},ansi256ToAnsi:{value(t){if(t<8)return 30+t;if(t<16)return 90+(t-8);let n,i,s;if(t>=232)n=((t-232)*10+8)/255,i=n,s=n;else{t-=16;let a=t%36;n=Math.floor(t/36)/5,i=Math.floor(a/6)/5,s=a%6/5}let r=Math.max(n,i,s)*2;if(r===0)return 30;let o=30+(Math.round(s)<<2|Math.round(i)<<1|Math.round(n));if(r===2)o+=60;return o},enumerable:!1},rgbToAnsi:{value:(t,n,i)=>se.ansi256ToAnsi(se.rgbToAnsi256(t,n,i)),enumerable:!1},hexToAnsi:{value:(t)=>se.ansi256ToAnsi(se.hexToAnsi256(t)),enumerable:!1}}),se}var cu=au(),br=cu;var xn=new Set(["\x1B",""]),uu=39,Fs="\x07",Er="[",lu="]",xr="m",En=`${lu}8;;`,Fr=(e)=>`${xn.values().next().value}${Er}${e}${xr}`,Cr=(e)=>`${xn.values().next().value}${En}${e}${Fs}`,fu=(e)=>e.split(" ").map((t)=>Le(t)),bs=(e,t,n)=>{let i=[...t],s=!1,r=!1,o=Le(dt(e.at(-1)));for(let[a,c]of i.entries()){let u=Le(c);if(o+u<=n)e[e.length-1]+=c;else e.push(c),o=0;if(xn.has(c))s=!0,r=i.slice(a+1,a+1+En.length).join("")===En;if(s){if(r){if(c===Fs)s=!1,r=!1}else if(c===xr)s=!1;continue}if(o+=u,o===n&&a<i.length-1)e.push(""),o=0}if(!o&&e.at(-1).length>0&&e.length>1)e[e.length-2]+=e.pop()},du=(e)=>{let t=e.split(" "),n=t.length;while(n>0){if(Le(t[n-1])>0)break;n--}if(n===t.length)return e;return t.slice(0,n).join(" ")+t.slice(n).join("")},pu=(e,t,n={})=>{if(n.trim!==!1&&e.trim()==="")return"";let i="",s,r,o=fu(e),a=[""];for(let[l,d]of e.split(" ").entries()){if(n.trim!==!1)a[a.length-1]=a.at(-1).trimStart();let h=Le(a.at(-1));if(l!==0){if(h>=t&&(n.wordWrap===!1||n.trim===!1))a.push(""),h=0;if(h>0||n.trim===!1)a[a.length-1]+=" ",h++}if(n.hard&&o[l]>t){let m=t-h,p=1+Math.floor((o[l]-m-1)/t);if(Math.floor((o[l]-1)/t)<p)a.push("");bs(a,d,t);continue}if(h+o[l]>t&&h>0&&o[l]>0){if(n.wordWrap===!1&&h<t){bs(a,d,t);continue}a.push("")}if(h+o[l]>t&&n.wordWrap===!1){bs(a,d,t);continue}a[a.length-1]+=d}if(n.trim!==!1)a=a.map((l)=>du(l));let c=a.join(`
|
|
8
|
+
`),u=[...c],f=0;for(let[l,d]of u.entries()){if(i+=d,xn.has(d)){let{groups:m}=new RegExp(`(?:\\${Er}(?<code>\\d+)m|\\${En}(?<uri>.*)${Fs})`).exec(c.slice(f))||{groups:{}};if(m.code!==void 0){let p=Number.parseFloat(m.code);s=p===uu?void 0:p}else if(m.uri!==void 0)r=m.uri.length===0?void 0:m.uri}let h=br.codes.get(Number(s));if(u[l+1]===`
|
|
9
9
|
`){if(r)i+=Cr("");if(s&&h)i+=Fr(h)}else if(d===`
|
|
10
10
|
`){if(s&&h)i+=Fr(s);if(r)i+=Cr(r)}f+=d.length}return i};function Cs(e,t,n){return String(e).normalize().replaceAll(`\r
|
|
11
11
|
`,`
|
|
12
12
|
`).split(`
|
|
13
|
-
`).map((i)=>
|
|
14
|
-
`)}function Es(e){return er(e,{stringWidth:Le,stripAnsi:dt,wrap:Cs})}import{dirname as _r,resolve as Sr}from"path";import{readdirSync as pu,statSync as hu}from"fs";function xs(e,t){let n=Sr(".",e),i;if(!hu(n).isDirectory())n=_r(n);while(!0){if(i=t(n,pu(n)),i)return Sr(n,i);if(n=_r(i=n),i===n)break}}import{inspect as Pu}from"util";import{fileURLToPath as Jr}from"url";import{format as Du}from"util";import{normalize as yu,resolve as wu}from"path";function pt(e){if(!(e!==e.toLowerCase()&&e!==e.toUpperCase()))e=e.toLowerCase();if(e.indexOf("-")===-1&&e.indexOf("_")===-1)return e;else{let n="",i=!1,s=e.match(/^-+/);for(let r=s?s[0].length:0;r<e.length;r++){let o=e.charAt(r);if(i)i=!1,o=o.toUpperCase();if(r!==0&&(o==="-"||o==="_"))i=!0;else if(o!=="-"&&o!=="_")n+=o}return n}}function _n(e,t){let n=e.toLowerCase();t=t||"-";let i="";for(let s=0;s<e.length;s++){let r=n.charAt(s),o=e.charAt(s);if(r!==o&&s>0)i+=`${t}${n.charAt(s)}`;else i+=o}return i}function Sn(e){if(e===null||e===void 0)return!1;if(typeof e==="number")return!0;if(/^0x[0-9a-f]+$/i.test(e))return!0;if(/^0[^.]/.test(e))return!1;return/^[-]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(e)}function kr(e){if(Array.isArray(e))return e.map((o)=>typeof o!=="string"?o+"":o);e=e.trim();let t=0,n=null,i=null,s=null,r=[];for(let o=0;o<e.length;o++){if(n=i,i=e.charAt(o),i===" "&&!s){if(n!==" ")t++;continue}if(i===s)s=null;else if((i==="'"||i==='"')&&!s)s=i;if(!r[t])r[t]="";r[t]+=i}return r}var Ie;(function(e){e.BOOLEAN="boolean",e.STRING="string",e.NUMBER="number",e.ARRAY="array"})(Ie||(Ie={}));var Qe;class Ss{constructor(e){Qe=e}parse(e,t){let n=Object.assign({alias:void 0,array:void 0,boolean:void 0,config:void 0,configObjects:void 0,configuration:void 0,coerce:void 0,count:void 0,default:void 0,envPrefix:void 0,narg:void 0,normalize:void 0,string:void 0,number:void 0,__:void 0,key:void 0},t),i=kr(e),s=typeof e==="string",r=gu(Object.assign(Object.create(null),n.alias)),o=Object.assign({"boolean-negation":!0,"camel-case-expansion":!0,"combine-arrays":!1,"dot-notation":!0,"duplicate-arguments-array":!0,"flatten-duplicate-arrays":!0,"greedy-arrays":!0,"halt-at-non-option":!1,"nargs-eats-options":!1,"negation-prefix":"no-","parse-numbers":!0,"parse-positional-numbers":!0,"populate--":!1,"set-placeholder-key":!1,"short-option-groups":!0,"strip-aliased":!1,"strip-dashed":!1,"unknown-options-as-args":!1},n.configuration),a=Object.assign(Object.create(null),n.default),c=n.configObjects||[],u=n.envPrefix,f=o["populate--"],l=f?"--":"_",d=Object.create(null),h=Object.create(null),m=n.__||Qe.format,p={aliases:Object.create(null),arrays:Object.create(null),bools:Object.create(null),strings:Object.create(null),numbers:Object.create(null),counts:Object.create(null),normalize:Object.create(null),configs:Object.create(null),nargs:Object.create(null),coercions:Object.create(null),keys:[]},y=/^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/,E=new RegExp("^--"+o["negation-prefix"]+"(.+)");if([].concat(n.array||[]).filter(Boolean).forEach(function(D){let b=typeof D==="object"?D.key:D,I=Object.keys(D).map(function(_){return{boolean:"bools",string:"strings",number:"numbers"}[_]}).filter(Boolean).pop();if(I)p[I][b]=!0;p.arrays[b]=!0,p.keys.push(b)}),[].concat(n.boolean||[]).filter(Boolean).forEach(function(D){p.bools[D]=!0,p.keys.push(D)}),[].concat(n.string||[]).filter(Boolean).forEach(function(D){p.strings[D]=!0,p.keys.push(D)}),[].concat(n.number||[]).filter(Boolean).forEach(function(D){p.numbers[D]=!0,p.keys.push(D)}),[].concat(n.count||[]).filter(Boolean).forEach(function(D){p.counts[D]=!0,p.keys.push(D)}),[].concat(n.normalize||[]).filter(Boolean).forEach(function(D){p.normalize[D]=!0,p.keys.push(D)}),typeof n.narg==="object")Object.entries(n.narg).forEach(([D,b])=>{if(typeof b==="number")p.nargs[D]=b,p.keys.push(D)});if(typeof n.coerce==="object")Object.entries(n.coerce).forEach(([D,b])=>{if(typeof b==="function")p.coercions[D]=b,p.keys.push(D)});if(typeof n.config<"u"){if(Array.isArray(n.config)||typeof n.config==="string")[].concat(n.config).filter(Boolean).forEach(function(D){p.configs[D]=!0});else if(typeof n.config==="object")Object.entries(n.config).forEach(([D,b])=>{if(typeof b==="boolean"||typeof b==="function")p.configs[D]=b})}Oe(n.key,r,n.default,p.arrays),Object.keys(a).forEach(function(D){(p.aliases[D]||[]).forEach(function(b){a[b]=a[D]})});let F=null;Ds();let k=[],C=Object.assign(Object.create(null),{_:[]}),A={};for(let D=0;D<i.length;D++){let b=i[D],I=b.replace(/^-{3,}/,"---"),_,w,j,M,K,ge;if(b!=="--"&&/^-/.test(b)&&ee(b))T(b);else if(I.match(/^---+(=|$)/)){T(b);continue}else if(b.match(/^--.+=/)||!o["short-option-groups"]&&b.match(/^-.+=/)){if(M=b.match(/^--?([^=]+)=([\s\S]*)$/),M!==null&&Array.isArray(M)&&M.length>=3)if(z(M[1],p.arrays))D=L(D,M[1],i,M[2]);else if(z(M[1],p.nargs)!==!1)D=v(D,M[1],i,M[2]);else R(M[1],M[2],!0)}else if(b.match(E)&&o["boolean-negation"]){if(M=b.match(E),M!==null&&Array.isArray(M)&&M.length>=2)w=M[1],R(w,z(w,p.arrays)?[!1]:!1)}else if(b.match(/^--.+/)||!o["short-option-groups"]&&b.match(/^-[^-]+/)){if(M=b.match(/^--?(.+)/),M!==null&&Array.isArray(M)&&M.length>=2)if(w=M[1],z(w,p.arrays))D=L(D,w,i);else if(z(w,p.nargs)!==!1)D=v(D,w,i);else if(K=i[D+1],K!==void 0&&(!K.match(/^-/)||K.match(y))&&!z(w,p.bools)&&!z(w,p.counts))R(w,K),D++;else if(/^(true|false)$/.test(K))R(w,K),D++;else R(w,V(w))}else if(b.match(/^-.\..+=/)){if(M=b.match(/^-([^=]+)=([\s\S]*)$/),M!==null&&Array.isArray(M)&&M.length>=3)R(M[1],M[2])}else if(b.match(/^-.\..+/)&&!b.match(y)){if(K=i[D+1],M=b.match(/^-(.\..+)/),M!==null&&Array.isArray(M)&&M.length>=2)if(w=M[1],K!==void 0&&!K.match(/^-/)&&!z(w,p.bools)&&!z(w,p.counts))R(w,K),D++;else R(w,V(w))}else if(b.match(/^-[^-]+/)&&!b.match(y)){j=b.slice(1,-1).split(""),_=!1;for(let be=0;be<j.length;be++){if(K=b.slice(be+2),j[be+1]&&j[be+1]==="="){if(ge=b.slice(be+3),w=j[be],z(w,p.arrays))D=L(D,w,i,ge);else if(z(w,p.nargs)!==!1)D=v(D,w,i,ge);else R(w,ge);_=!0;break}if(K==="-"){R(j[be],K);continue}if(/[A-Za-z]/.test(j[be])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(K)&&z(K,p.bools)===!1){R(j[be],K),_=!0;break}if(j[be+1]&&j[be+1].match(/\W/)){R(j[be],K),_=!0;break}else R(j[be],V(j[be]))}if(w=b.slice(-1)[0],!_&&w!=="-")if(z(w,p.arrays))D=L(D,w,i);else if(z(w,p.nargs)!==!1)D=v(D,w,i);else if(K=i[D+1],K!==void 0&&(!/^(-|--)[^-]/.test(K)||K.match(y))&&!z(w,p.bools)&&!z(w,p.counts))R(w,K),D++;else if(/^(true|false)$/.test(K))R(w,K),D++;else R(w,V(w))}else if(b.match(/^-[0-9]$/)&&b.match(y)&&z(b.slice(1),p.bools))w=b.slice(1),R(w,V(w));else if(b==="--"){k=i.slice(D+1);break}else if(o["halt-at-non-option"]){k=i.slice(D);break}else T(b)}if(re(C,!0),re(C,!1),O(C),Z(),$e(C,p.aliases,a,!0),Q(C),o["set-placeholder-key"])oe(C);if(Object.keys(p.counts).forEach(function(D){if(!J(C,D.split(".")))R(D,0)}),f&&k.length)C[l]=[];if(k.forEach(function(D){C[l].push(D)}),o["camel-case-expansion"]&&o["strip-dashed"])Object.keys(C).filter((D)=>D!=="--"&&D.includes("-")).forEach((D)=>{delete C[D]});if(o["strip-aliased"])[].concat(...Object.keys(r).map((D)=>r[D])).forEach((D)=>{if(o["camel-case-expansion"]&&D.includes("-"))delete C[D.split(".").map((b)=>pt(b)).join(".")];delete C[D]});function T(D){let b=x("_",D);if(typeof b==="string"||typeof b==="number")C._.push(b)}function v(D,b,I,_){let w,j=z(b,p.nargs);if(j=typeof j!=="number"||isNaN(j)?1:j,j===0){if(!pe(_))F=Error(m("Argument unexpected for: %s",b));return R(b,V(b)),D}let M=pe(_)?0:1;if(o["nargs-eats-options"]){if(I.length-(D+1)+M<j)F=Error(m("Not enough arguments following: %s",b));M=j}else{for(w=D+1;w<I.length;w++)if(!I[w].match(/^-[^0-9]/)||I[w].match(y)||ee(I[w]))M++;else break;if(M<j)F=Error(m("Not enough arguments following: %s",b))}let K=Math.min(M,j);if(!pe(_)&&K>0)R(b,_),K--;for(w=D+1;w<K+D+1;w++)R(b,I[w]);return D+K}function L(D,b,I,_){let w=[],j=_||I[D+1],M=z(b,p.nargs);if(z(b,p.bools)&&!/^(true|false)$/.test(j))w.push(!0);else if(pe(j)||pe(_)&&/^-/.test(j)&&!y.test(j)&&!ee(j)){if(a[b]!==void 0){let K=a[b];w=Array.isArray(K)?K:[K]}}else{if(!pe(_))w.push(S(b,_,!0));for(let K=D+1;K<I.length;K++){if(!o["greedy-arrays"]&&w.length>0||M&&typeof M==="number"&&w.length>=M)break;if(j=I[K],/^-/.test(j)&&!y.test(j)&&!ee(j))break;D=K,w.push(S(b,j,s))}}if(typeof M==="number"&&(M&&w.length<M||isNaN(M)&&w.length===0))F=Error(m("Not enough arguments following: %s",b));return R(b,w),D}function R(D,b,I=s){if(/-/.test(D)&&o["camel-case-expansion"]){let j=D.split(".").map(function(M){return pt(M)}).join(".");G(D,j)}let _=S(D,b,I),w=D.split(".");if(ae(C,w,_),p.aliases[D])p.aliases[D].forEach(function(j){let M=j.split(".");ae(C,M,_)});if(w.length>1&&o["dot-notation"])(p.aliases[w[0]]||[]).forEach(function(j){let M=j.split("."),K=[].concat(w);if(K.shift(),M=M.concat(K),!(p.aliases[D]||[]).includes(M.join(".")))ae(C,M,_)});if(z(D,p.normalize)&&!z(D,p.arrays))[D].concat(p.aliases[D]||[]).forEach(function(M){Object.defineProperty(A,M,{enumerable:!0,get(){return b},set(K){b=typeof K==="string"?Qe.normalize(K):K}})})}function G(D,b){if(!(p.aliases[D]&&p.aliases[D].length))p.aliases[D]=[b],d[b]=!0;if(!(p.aliases[b]&&p.aliases[b].length))G(b,D)}function S(D,b,I){if(I)b=mu(b);if(z(D,p.bools)||z(D,p.counts)){if(typeof b==="string")b=b==="true"}let _=Array.isArray(b)?b.map(function(w){return x(D,w)}):x(D,b);if(z(D,p.counts)&&(pe(_)||typeof _==="boolean"))_=_s();if(z(D,p.normalize)&&z(D,p.arrays))if(Array.isArray(b))_=b.map((w)=>Qe.normalize(w));else _=Qe.normalize(b);return _}function x(D,b){if(!o["parse-positional-numbers"]&&D==="_")return b;if(!z(D,p.strings)&&!z(D,p.bools)&&!Array.isArray(b)){if(Sn(b)&&o["parse-numbers"]&&Number.isSafeInteger(Math.floor(parseFloat(`${b}`)))||!pe(b)&&z(D,p.numbers))b=Number(b)}return b}function O(D){let b=Object.create(null);$e(b,p.aliases,a),Object.keys(p.configs).forEach(function(I){let _=D[I]||b[I];if(_)try{let w=null,j=Qe.resolve(Qe.cwd(),_),M=p.configs[I];if(typeof M==="function"){try{w=M(j)}catch(K){w=K}if(w instanceof Error){F=w;return}}else w=Qe.require(j);W(w)}catch(w){if(w.name==="PermissionDenied")F=w;else if(D[I])F=Error(m("Invalid JSON config file: %s",_))}})}function W(D,b){Object.keys(D).forEach(function(I){let _=D[I],w=b?b+"."+I:I;if(typeof _==="object"&&_!==null&&!Array.isArray(_)&&o["dot-notation"])W(_,w);else if(!J(C,w.split("."))||z(w,p.arrays)&&o["combine-arrays"])R(w,_)})}function Z(){if(typeof c<"u")c.forEach(function(D){W(D)})}function re(D,b){if(typeof u>"u")return;let I=typeof u==="string"?u:"",_=Qe.env();Object.keys(_).forEach(function(w){if(I===""||w.lastIndexOf(I,0)===0){let j=w.split("__").map(function(M,K){if(K===0)M=M.substring(I.length);return pt(M)});if((b&&p.configs[j.join(".")]||!b)&&!J(D,j))R(j.join("."),_[w])}})}function Q(D){let b,I=new Set;Object.keys(D).forEach(function(_){if(!I.has(_)){if(b=z(_,p.coercions),typeof b==="function")try{let w=x(_,b(D[_]));[].concat(p.aliases[_]||[],_).forEach((j)=>{I.add(j),D[j]=w})}catch(w){F=w}}})}function oe(D){return p.keys.forEach((b)=>{if(~b.indexOf("."))return;if(typeof D[b]>"u")D[b]=void 0}),D}function $e(D,b,I,_=!1){Object.keys(I).forEach(function(w){if(!J(D,w.split("."))){if(ae(D,w.split("."),I[w]),_)h[w]=!0;(b[w]||[]).forEach(function(j){if(J(D,j.split(".")))return;ae(D,j.split("."),I[w])})}})}function J(D,b){let I=D;if(!o["dot-notation"])b=[b.join(".")];b.slice(0,-1).forEach(function(w){I=I[w]||{}});let _=b[b.length-1];if(typeof I!=="object")return!1;else return _ in I}function ae(D,b,I){let _=D;if(!o["dot-notation"])b=[b.join(".")];b.slice(0,-1).forEach(function(ge){if(ge=Ar(ge),typeof _==="object"&&_[ge]===void 0)_[ge]={};if(typeof _[ge]!=="object"||Array.isArray(_[ge])){if(Array.isArray(_[ge]))_[ge].push({});else _[ge]=[_[ge],{}];_=_[ge][_[ge].length-1]}else _=_[ge]});let w=Ar(b[b.length-1]),j=z(b.join("."),p.arrays),M=Array.isArray(I),K=o["duplicate-arguments-array"];if(!K&&z(w,p.nargs)){if(K=!0,!pe(_[w])&&p.nargs[w]===1||Array.isArray(_[w])&&_[w].length===p.nargs[w])_[w]=void 0}if(I===_s())_[w]=_s(_[w]);else if(Array.isArray(_[w]))if(K&&j&&M)_[w]=o["flatten-duplicate-arrays"]?_[w].concat(I):(Array.isArray(_[w][0])?_[w]:[_[w]]).concat([I]);else if(!K&&Boolean(j)===Boolean(M))_[w]=I;else _[w]=_[w].concat([I]);else if(_[w]===void 0&&j)_[w]=M?I:[I];else if(K&&!(_[w]===void 0||z(w,p.counts)||z(w,p.bools)))_[w]=[_[w],I];else _[w]=I}function Oe(...D){D.forEach(function(b){Object.keys(b||{}).forEach(function(I){if(p.aliases[I])return;p.aliases[I]=[].concat(r[I]||[]),p.aliases[I].concat(I).forEach(function(_){if(/-/.test(_)&&o["camel-case-expansion"]){let w=pt(_);if(w!==I&&p.aliases[I].indexOf(w)===-1)p.aliases[I].push(w),d[w]=!0}}),p.aliases[I].concat(I).forEach(function(_){if(_.length>1&&/[A-Z]/.test(_)&&o["camel-case-expansion"]){let w=_n(_,"-");if(w!==I&&p.aliases[I].indexOf(w)===-1)p.aliases[I].push(w),d[w]=!0}}),p.aliases[I].forEach(function(_){p.aliases[_]=[I].concat(p.aliases[I].filter(function(w){return _!==w}))})})})}function z(D,b){let I=[].concat(p.aliases[D]||[],D),_=Object.keys(b),w=I.find((j)=>_.includes(j));return w?b[w]:!1}function vt(D){let b=Object.keys(p);return[].concat(b.map((_)=>p[_])).some(function(_){return Array.isArray(_)?_.includes(D):_[D]})}function Yi(D,...b){return[].concat(...b).some(function(_){let w=D.match(_);return w&&vt(w[1])})}function H(D){if(D.match(y)||!D.match(/^-[^-]+/))return!1;let b=!0,I,_=D.slice(1).split("");for(let w=0;w<_.length;w++){if(I=D.slice(w+2),!vt(_[w])){b=!1;break}if(_[w+1]&&_[w+1]==="="||I==="-"||/[A-Za-z]/.test(_[w])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(I)||_[w+1]&&_[w+1].match(/\W/))break}return b}function ee(D){return o["unknown-options-as-args"]&&de(D)}function de(D){if(D=D.replace(/^-{3,}/,"--"),D.match(y))return!1;if(H(D))return!1;return!Yi(D,/^-+([^=]+?)=[\s\S]*$/,E,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}function V(D){if(!z(D,p.bools)&&!z(D,p.counts)&&`${D}`in a)return a[D];else return ye(ue(D))}function ye(D){return{[Ie.BOOLEAN]:!0,[Ie.STRING]:"",[Ie.NUMBER]:void 0,[Ie.ARRAY]:[]}[D]}function ue(D){let b=Ie.BOOLEAN;if(z(D,p.strings))b=Ie.STRING;else if(z(D,p.numbers))b=Ie.NUMBER;else if(z(D,p.bools))b=Ie.BOOLEAN;else if(z(D,p.arrays))b=Ie.ARRAY;return b}function pe(D){return D===void 0}function Ds(){Object.keys(p.counts).find((D)=>{if(z(D,p.arrays))return F=Error(m("Invalid configuration: %s, opts.count excludes opts.array.",D)),!0;else if(z(D,p.nargs))return F=Error(m("Invalid configuration: %s, opts.count excludes opts.narg.",D)),!0;return!1})}return{aliases:Object.assign({},p.aliases),argv:Object.assign(A,C),configuration:o,defaulted:Object.assign({},h),error:F,newAliases:Object.assign({},d)}}}function gu(e){let t=[],n=Object.create(null),i=!0;Object.keys(e).forEach(function(s){t.push([].concat(e[s],s))});while(i){i=!1;for(let s=0;s<t.length;s++)for(let r=s+1;r<t.length;r++)if(t[s].filter(function(a){return t[r].indexOf(a)!==-1}).length){t[s]=t[s].concat(t[r]),t.splice(r,1),i=!0;break}}return t.forEach(function(s){s=s.filter(function(o,a,c){return c.indexOf(o)===a});let r=s.pop();if(r!==void 0&&typeof r==="string")n[r]=s}),n}function _s(e){return e!==void 0?e+1:1}function Ar(e){if(e==="__proto__")return"___proto___";return e}function mu(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 bu}from"fs";import{createRequire as $r}from"node:module";var ks,As,$s,Or=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):20,Ir=(As=(ks=process===null||process===void 0?void 0:process.versions)===null||ks===void 0?void 0:ks.node)!==null&&As!==void 0?As:($s=process===null||process===void 0?void 0:process.version)===null||$s===void 0?void 0:$s.slice(1);if(Ir){if(Number(Ir.match(/^([^.]+)/)[1])<Or)throw Error(`yargs parser supports a minimum Node.js version of ${Or}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`)}var Fu=process?process.env:{},Pr=$r?$r(import.meta.url):void 0,Tr=new Ss({cwd:process.cwd,env:()=>Fu,format:Du,normalize:yu,resolve:wu,require:(e)=>{if(typeof Pr<"u")return Pr(e);else if(e.match(/\.json$/))return JSON.parse(bu(e,"utf8"));else throw Error("only .json config files are supported in ESM")}}),Zt=function(t,n){return Tr.parse(t.slice(),n).argv};Zt.detailed=function(e,t){return Tr.parse(e.slice(),t)};Zt.camelCase=pt;Zt.decamelize=_n;Zt.looksLikeNumber=Sn;var Os=Zt;import{basename as Tu,dirname as Ru,extname as Mu,relative as Bu,resolve as Ur,join as Nu}from"path";function Rr(){if(Cu())return 0;return 1}function Cu(){return Eu()&&!process.defaultApp}function Eu(){return!!process.versions.electron}function Is(e){return e.slice(Rr()+1)}function Mr(){return process.argv[Rr()]}import{readFileSync as xu,statSync as _u,writeFile as Su}from"fs";import{format as ku}from"util";import{resolve as Au}from"path";var Br={fs:{readFileSync:xu,writeFile:Su},format:ku,resolve:Au,exists:(e)=>{try{return _u(e).isFile()}catch(t){return!1}}};var We;class Nr{constructor(e){e=e||{},this.directory=e.directory||"./locales",this.updateFiles=typeof e.updateFiles==="boolean"?e.updateFiles:!0,this.locale=e.locale||"en",this.fallbackToLanguage=typeof e.fallbackToLanguage==="boolean"?e.fallbackToLanguage:!0,this.cache=Object.create(null),this.writeQueue=[]}__(...e){if(typeof arguments[0]!=="string")return this._taggedLiteral(arguments[0],...arguments);let t=e.shift(),n=function(){};if(typeof e[e.length-1]==="function")n=e.pop();if(n=n||function(){},!this.cache[this.locale])this._readLocaleFile();if(!this.cache[this.locale][t]&&this.updateFiles)this.cache[this.locale][t]=t,this._enqueueWrite({directory:this.directory,locale:this.locale,cb:n});else n();return We.format.apply(We.format,[this.cache[this.locale][t]||t].concat(e))}__n(){let e=Array.prototype.slice.call(arguments),t=e.shift(),n=e.shift(),i=e.shift(),s=function(){};if(typeof e[e.length-1]==="function")s=e.pop();if(!this.cache[this.locale])this._readLocaleFile();let r=i===1?t:n;if(this.cache[this.locale][t])r=this.cache[this.locale][t][i===1?"one":"other"];if(!this.cache[this.locale][t]&&this.updateFiles)this.cache[this.locale][t]={one:t,other:n},this._enqueueWrite({directory:this.directory,locale:this.locale,cb:s});else s();let o=[r];if(~r.indexOf("%d"))o.push(i);return We.format.apply(We.format,o.concat(e))}setLocale(e){this.locale=e}getLocale(){return this.locale}updateLocale(e){if(!this.cache[this.locale])this._readLocaleFile();for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t))this.cache[this.locale][t]=e[t]}_taggedLiteral(e,...t){let n="";return e.forEach(function(i,s){let r=t[s+1];if(n+=i,typeof r<"u")n+="%s"}),this.__.apply(this,[n].concat([].slice.call(t,1)))}_enqueueWrite(e){if(this.writeQueue.push(e),this.writeQueue.length===1)this._processWriteQueue()}_processWriteQueue(){let e=this,t=this.writeQueue[0],n=t.directory,i=t.locale,s=t.cb,r=this._resolveLocaleFile(n,i),o=JSON.stringify(this.cache[i],null,2);We.fs.writeFile(r,o,"utf-8",function(a){if(e.writeQueue.shift(),e.writeQueue.length>0)e._processWriteQueue();s(a)})}_readLocaleFile(){let e={},t=this._resolveLocaleFile(this.directory,this.locale);try{if(We.fs.readFileSync)e=JSON.parse(We.fs.readFileSync(t,"utf-8"))}catch(n){if(n instanceof SyntaxError)n.message="syntax error in "+t;if(n.code==="ENOENT")e={};else throw n}this.cache[this.locale]=e}_resolveLocaleFile(e,t){let n=We.resolve(e,"./",t+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(n)&&~t.lastIndexOf("_")){let i=We.resolve(e,"./",t.split("_")[0]+".json");if(this._fileExistsSync(i))n=i}return n}_fileExistsSync(e){return We.exists(e)}}function vr(e,t){We=t;let n=new Nr(e);return{__:n.__.bind(n),__n:n.__n.bind(n),setLocale:n.setLocale.bind(n),getLocale:n.getLocale.bind(n),updateLocale:n.updateLocale.bind(n),locale:n.locale}}var $u=(e)=>vr(e,Br),jr=$u;var Kr=Gi(Wr(),1);import{createRequire as vu}from"node:module";import{readFileSync as ju,readdirSync as Lu}from"node:fs";var Ps=Jr(import.meta.url),Wu=Ps.substring(0,Ps.lastIndexOf("node_modules")),Uu=vu(import.meta.url),Ts={assert:{notStrictEqual:Ou,strictEqual:Iu},cliui:Es,findUp:xs,getEnv:(e)=>process.env[e],inspect:Pu,getProcessArgvBin:Mr,mainFilename:Wu||process.cwd(),Parser:Os,path:{basename:Tu,dirname:Ru,extname:Mu,relative:Bu,resolve:Ur,join:Nu},process:{argv:()=>process.argv,cwd:process.cwd,emitWarning:(e,t)=>process.emitWarning(e,t),execPath:()=>process.execPath,exit:(e)=>{process.exit(e)},nextTick:process.nextTick,stdColumns:typeof process.stdout.columns<"u"?process.stdout.columns:null},readFileSync:ju,readdirSync:Lu,require:Uu,getCallerFile:()=>{let e=Kr.default(3);return e.match(/^file:\/\//)?Jr(e):e},stringWidth:Le,y18n:jr({directory:Ur(Ps,"../../../locales"),updateFiles:!1})};function Fe(e,t,n,i){n.assert.notStrictEqual(e,t,i)}function Rs(e,t){t.assert.strictEqual(typeof e,"string")}function jt(e){return Object.keys(e)}function ne(e){return!!e&&!!e.then&&typeof e.then==="function"}class le extends Error{constructor(e){super(e||"yargs error");if(this.name="YError",Error.captureStackTrace)Error.captureStackTrace(this,le)}}function nt(e){let n=e.replace(/\s{2,}/g," ").split(/\s+(?![^[]*]|[^<]*>)/),i=/\.*[\][<>]/g,s=n.shift();if(!s)throw Error(`No command found in: ${e}`);let r={cmd:s.replace(i,""),demanded:[],optional:[]};return n.forEach((o,a)=>{let c=!1;if(o=o.replace(/\s/g,""),/\.+[\]>]/.test(o)&&a===n.length-1)c=!0;if(/^\[/.test(o))r.optional.push({cmd:o.replace(i,"").split("|"),variadic:c});else r.demanded.push({cmd:o.replace(i,"").split("|"),variadic:c})}),r}var Ju=["first","second","third","fourth","fifth","sixth"];function B(e,t,n){function i(){return typeof e==="object"?[{demanded:[],optional:[]},e,t]:[nt(`cmd ${e}`),t,n]}try{let s=0,[r,o,a]=i(),c=[].slice.call(o);while(c.length&&c[c.length-1]===void 0)c.pop();let u=a||c.length;if(u<r.demanded.length)throw new le(`Not enough arguments provided. Expected ${r.demanded.length} but received ${c.length}.`);let f=r.demanded.length+r.optional.length;if(u>f)throw new le(`Too many arguments provided. Expected max ${f} but received ${u}.`);r.demanded.forEach((l)=>{let d=c.shift(),h=zr(d);if(l.cmd.filter((p)=>p===h||p==="*").length===0)Hr(h,l.cmd,s);s+=1}),r.optional.forEach((l)=>{if(c.length===0)return;let d=c.shift(),h=zr(d);if(l.cmd.filter((p)=>p===h||p==="*").length===0)Hr(h,l.cmd,s);s+=1})}catch(s){console.warn(s.stack)}}function zr(e){if(Array.isArray(e))return"array";else if(e===null)return"null";return typeof e}function Hr(e,t,n){throw new le(`Invalid ${Ju[n]||"manyith"} argument. Expected ${t.join(" or ")} but received ${e}.`)}class Ms{constructor(e){this.globalMiddleware=[],this.frozens=[],this.yargs=e}addMiddleware(e,t,n=!0,i=!1){if(B("<array|function> [boolean] [boolean] [boolean]",[e,t,n],arguments.length),Array.isArray(e)){for(let s=0;s<e.length;s++){if(typeof e[s]!=="function")throw Error("middleware must be a function");let r=e[s];r.applyBeforeValidation=t,r.global=n}Array.prototype.push.apply(this.globalMiddleware,e)}else if(typeof e==="function"){let s=e;s.applyBeforeValidation=t,s.global=n,s.mutates=i,this.globalMiddleware.push(e)}return this.yargs}addCoerceMiddleware(e,t){let n=this.yargs.getAliases();return this.globalMiddleware=this.globalMiddleware.filter((i)=>{let s=[...n[t]||[],t];if(!i.option)return!0;else return!s.includes(i.option)}),e.option=t,this.addMiddleware(e,!0,!0,!0)}getMiddleware(){return this.globalMiddleware}freeze(){this.frozens.push([...this.globalMiddleware])}unfreeze(){let e=this.frozens.pop();if(e!==void 0)this.globalMiddleware=e}reset(){this.globalMiddleware=this.globalMiddleware.filter((e)=>e.global)}}function qr(e){if(!e)return[];return e.map((t)=>(t.applyBeforeValidation=!1,t))}function ht(e,t,n,i){return n.reduce((s,r)=>{if(r.applyBeforeValidation!==i)return s;if(r.mutates){if(r.applied)return s;r.applied=!0}if(ne(s))return s.then((o)=>Promise.all([o,r(o,t)])).then(([o,a])=>Object.assign(o,a));else{let o=r(s,t);return ne(o)?o.then((a)=>Object.assign(s,a)):Object.assign(s,o)}},e)}function gt(e,t,n=(i)=>{throw i}){try{let i=Ku(e)?e():e;return ne(i)?i.then((s)=>t(s)):t(i)}catch(i){return n(i)}}function Ku(e){return typeof e==="function"}var Lt=/(^\*)|(^\$0)/;class Xr{constructor(e,t,n,i){this.requireCache=new Set,this.handlers={},this.aliasMap={},this.frozens=[],this.shim=i,this.usage=e,this.globalMiddleware=n,this.validation=t}addDirectory(e,t,n,i){i=i||{},this.requireCache.add(n);let s=this.shim.path.resolve(this.shim.path.dirname(n),e),r=this.shim.readdirSync(s,{recursive:i.recurse?!0:!1});if(!Array.isArray(i.extensions))i.extensions=["js"];let o=typeof i.visit==="function"?i.visit:(a)=>a;for(let a of r){let c=a.toString();if(i.exclude){let f=!1;if(typeof i.exclude==="function")f=i.exclude(c);else f=i.exclude.test(c);if(f)continue}if(i.include){let f=!1;if(typeof i.include==="function")f=i.include(c);else f=i.include.test(c);if(!f)continue}let u=!1;for(let f of i.extensions)if(c.endsWith(f))u=!0;if(u){let f=this.shim.path.join(s,c),l=t(f),d=Object.create(null,Object.getOwnPropertyDescriptors({...l}));if(o(d,f,c)){if(this.requireCache.has(f))continue;else this.requireCache.add(f);if(!d.command)d.command=this.shim.path.basename(f,this.shim.path.extname(f));this.addHandler(d)}}}}addHandler(e,t,n,i,s,r){let o=[],a=qr(s);if(i=i||(()=>{}),Array.isArray(e))if(zu(e))[e,...o]=e;else for(let c of e)this.addHandler(c);else if(qu(e)){let c=Array.isArray(e.command)||typeof e.command==="string"?e.command:null;if(c===null)throw Error(`No command name given for module: ${this.shim.inspect(e)}`);if(e.aliases)c=[].concat(c).concat(e.aliases);this.addHandler(c,this.extractDesc(e),e.builder,e.handler,e.middlewares,e.deprecated);return}else if(Yr(n)){this.addHandler([e].concat(o),t,n.builder,n.handler,n.middlewares,n.deprecated);return}if(typeof e==="string"){let c=nt(e);o=o.map((l)=>nt(l).cmd);let u=!1,f=[c.cmd].concat(o).filter((l)=>{if(Lt.test(l))return u=!0,!1;return!0});if(f.length===0&&u)f.push("$0");if(u)c.cmd=f[0],o=f.slice(1),e=e.replace(Lt,c.cmd);if(o.forEach((l)=>{this.aliasMap[l]=c.cmd}),t!==!1)this.usage.command(e,t,u,o,r);if(this.handlers[c.cmd]={original:e,description:t,handler:i,builder:n||{},middlewares:a,deprecated:r,demanded:c.demanded,optional:c.optional},u)this.defaultCommand=this.handlers[c.cmd]}}getCommandHandlers(){return this.handlers}getCommands(){return Object.keys(this.handlers).concat(Object.keys(this.aliasMap))}hasDefaultCommand(){return!!this.defaultCommand}runCommand(e,t,n,i,s,r){let o=this.handlers[e]||this.handlers[this.aliasMap[e]]||this.defaultCommand,a=t.getInternalMethods().getContext(),c=a.commands.slice(),u=!e;if(e)a.commands.push(e),a.fullCommands.push(o.original);let f=this.applyBuilderUpdateUsageAndParse(u,o,t,n.aliases,c,i,s,r);return ne(f)?f.then((l)=>this.applyMiddlewareAndGetResult(u,o,l.innerArgv,a,s,l.aliases,t)):this.applyMiddlewareAndGetResult(u,o,f.innerArgv,a,s,f.aliases,t)}applyBuilderUpdateUsageAndParse(e,t,n,i,s,r,o,a){let c=t.builder,u=n;if(kn(c)){n.getInternalMethods().getUsageInstance().freeze();let f=c(n.getInternalMethods().reset(i),a);if(ne(f))return f.then((l)=>(u=Vr(l)?l:n,this.parseAndUpdateUsage(e,t,u,s,r,o)))}else if(Hu(c))n.getInternalMethods().getUsageInstance().freeze(),u=n.getInternalMethods().reset(i),Object.keys(t.builder).forEach((f)=>{u.option(f,c[f])});return this.parseAndUpdateUsage(e,t,u,s,r,o)}parseAndUpdateUsage(e,t,n,i,s,r){if(e)n.getInternalMethods().getUsageInstance().unfreeze(!0);if(this.shouldUpdateUsage(n))n.getInternalMethods().getUsageInstance().usage(this.usageFromParentCommandsCommandHandler(i,t),t.description);let o=n.getInternalMethods().runYargsParserAndExecuteCommands(null,void 0,!0,s,r);return ne(o)?o.then((a)=>({aliases:n.parsed.aliases,innerArgv:a})):{aliases:n.parsed.aliases,innerArgv:o}}shouldUpdateUsage(e){return!e.getInternalMethods().getUsageInstance().getUsageDisabled()&&e.getInternalMethods().getUsageInstance().getUsage().length===0}usageFromParentCommandsCommandHandler(e,t){let n=Lt.test(t.original)?t.original.replace(Lt,"").trim():t.original,i=e.filter((s)=>!Lt.test(s));return i.push(n),`$0 ${i.join(" ")}`}handleValidationAndGetResult(e,t,n,i,s,r,o,a){if(!r.getInternalMethods().getHasOutput()){let c=r.getInternalMethods().runValidation(s,a,r.parsed.error,e);n=gt(n,(u)=>(c(u),u))}if(t.handler&&!r.getInternalMethods().getHasOutput()){r.getInternalMethods().setHasOutput();let c=!!r.getOptions().configuration["populate--"];if(r.getInternalMethods().postProcess(n,c,!1,!1),n=ht(n,r,o,!1),n=gt(n,(u)=>{let f=t.handler(u);return ne(f)?f.then(()=>u):u}),!e)r.getInternalMethods().getUsageInstance().cacheHelpMessage();if(ne(n)&&!r.getInternalMethods().hasParseCallback())n.catch((u)=>{try{r.getInternalMethods().getUsageInstance().fail(null,u)}catch(f){}})}if(!e)i.commands.pop(),i.fullCommands.pop();return n}applyMiddlewareAndGetResult(e,t,n,i,s,r,o){let a={};if(s)return n;if(!o.getInternalMethods().getHasOutput())a=this.populatePositionals(t,n,i,o);let c=this.globalMiddleware.getMiddleware().slice(0).concat(t.middlewares),u=ht(n,o,c,!0);return ne(u)?u.then((f)=>this.handleValidationAndGetResult(e,t,f,i,r,o,c,a)):this.handleValidationAndGetResult(e,t,u,i,r,o,c,a)}populatePositionals(e,t,n,i){t._=t._.slice(n.commands.length);let s=e.demanded.slice(0),r=e.optional.slice(0),o={};this.validation.positionalCount(s.length,t._.length);while(s.length){let a=s.shift();this.populatePositional(a,t,o)}while(r.length){let a=r.shift();this.populatePositional(a,t,o)}return t._=n.commands.concat(t._.map((a)=>""+a)),this.postProcessPositionals(t,o,this.cmdToParseOptions(e.original),i),o}populatePositional(e,t,n){let i=e.cmd[0];if(e.variadic)n[i]=t._.splice(0).map(String);else if(t._.length)n[i]=[String(t._.shift())]}cmdToParseOptions(e){let t={array:[],default:{},alias:{},demand:{}},n=nt(e);return n.demanded.forEach((i)=>{let[s,...r]=i.cmd;if(i.variadic)t.array.push(s),t.default[s]=[];t.alias[s]=r,t.demand[s]=!0}),n.optional.forEach((i)=>{let[s,...r]=i.cmd;if(i.variadic)t.array.push(s),t.default[s]=[];t.alias[s]=r}),t}postProcessPositionals(e,t,n,i){let s=Object.assign({},i.getOptions());s.default=Object.assign(n.default,s.default);for(let c of Object.keys(n.alias))s.alias[c]=(s.alias[c]||[]).concat(n.alias[c]);s.array=s.array.concat(n.array),s.config={};let r=[];if(Object.keys(t).forEach((c)=>{t[c].map((u)=>{if(s.configuration["unknown-options-as-args"])s.key[c]=!0;r.push(`--${c}`),r.push(u)})}),!r.length)return;let o=Object.assign({},s.configuration,{"populate--":!1}),a=this.shim.Parser.detailed(r,Object.assign({},s,{configuration:o}));if(a.error)i.getInternalMethods().getUsageInstance().fail(a.error.message,a.error);else{let c=Object.keys(t);Object.keys(t).forEach((u)=>{c.push(...a.aliases[u])}),Object.keys(a.argv).forEach((u)=>{if(c.includes(u)){if(!t[u])t[u]=a.argv[u];if(!this.isInConfigs(i,u)&&!this.isDefaulted(i,u)&&Object.prototype.hasOwnProperty.call(e,u)&&Object.prototype.hasOwnProperty.call(a.argv,u)&&(Array.isArray(e[u])||Array.isArray(a.argv[u])))e[u]=[].concat(e[u],a.argv[u]);else e[u]=a.argv[u]}})}}isDefaulted(e,t){let{default:n}=e.getOptions();return Object.prototype.hasOwnProperty.call(n,t)||Object.prototype.hasOwnProperty.call(n,this.shim.Parser.camelCase(t))}isInConfigs(e,t){let{configObjects:n}=e.getOptions();return n.some((i)=>Object.prototype.hasOwnProperty.call(i,t))||n.some((i)=>Object.prototype.hasOwnProperty.call(i,this.shim.Parser.camelCase(t)))}runDefaultBuilderOn(e){if(!this.defaultCommand)return;if(this.shouldUpdateUsage(e)){let n=Lt.test(this.defaultCommand.original)?this.defaultCommand.original:this.defaultCommand.original.replace(/^[^[\]<>]*/,"$0 ");e.getInternalMethods().getUsageInstance().usage(n,this.defaultCommand.description)}let t=this.defaultCommand.builder;if(kn(t))return t(e,!0);else if(!Yr(t))Object.keys(t).forEach((n)=>{e.option(n,t[n])});return}extractDesc({describe:e,description:t,desc:n}){for(let i of[e,t,n]){if(typeof i==="string"||i===!1)return i;Fe(i,!0,this.shim)}return!1}freeze(){this.frozens.push({handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand})}unfreeze(){let e=this.frozens.pop();Fe(e,void 0,this.shim),{handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand}=e}reset(){return this.handlers={},this.aliasMap={},this.defaultCommand=void 0,this.requireCache=new Set,this}}function Gr(e,t,n,i){return new Xr(e,t,n,i)}function Yr(e){return typeof e==="object"&&!!e.builder&&typeof e.handler==="function"}function zu(e){return e.every((t)=>typeof t==="string")}function kn(e){return typeof e==="function"}function Hu(e){return typeof e==="object"}function qu(e){return typeof e==="object"&&!Array.isArray(e)}function st(e={},t=()=>!0){let n={};return jt(e).forEach((i)=>{if(t(i,e[i]))n[i]=e[i]}),n}function it(e){if(typeof process>"u")return;[process.stdout,process.stderr].forEach((t)=>{let n=t;if(n._handle&&n.isTTY&&typeof n._handle.setBlocking==="function")n._handle.setBlocking(e)})}function Yu(e){return typeof e==="boolean"}function Qr(e,t){let n=t.y18n.__,i={},s=[];i.failFn=function(x){s.push(x)};let r=null,o=null,a=!0;i.showHelpOnFail=function(x=!0,O){let[W,Z]=typeof x==="string"?[!0,x]:[x,O];if(e.getInternalMethods().isGlobalContext())o=Z;return r=Z,a=W,i};let c=!1;i.fail=function(x,O){let W=e.getInternalMethods().getLoggerInstance();if(s.length)for(let Z=s.length-1;Z>=0;--Z){let re=s[Z];if(Yu(re)){if(O)throw O;else if(x)throw Error(x)}else re(x,O,i)}else{if(e.getExitProcess())it(!0);if(!c){if(c=!0,a)e.showHelp("error"),W.error();if(x||O)W.error(x||O);let Z=r||o;if(Z){if(x||O)W.error("");W.error(Z)}}if(O=O||new le(x),e.getExitProcess())return e.exit(1);else if(e.getInternalMethods().hasParseCallback())return e.exit(1,O);else throw O}};let u=[],f=!1;i.usage=(S,x)=>{if(S===null)return f=!0,u=[],i;return f=!1,u.push([S,x||""]),i},i.getUsage=()=>u,i.getUsageDisabled=()=>f,i.getPositionalGroupName=()=>n("Positionals:");let l=[];i.example=(S,x)=>{l.push([S,x||""])};let d=[];i.command=function(x,O,W,Z,re=!1){if(W)d=d.map((Q)=>(Q[2]=!1,Q));d.push([x,O||"",W,Z,re])},i.getCommands=()=>d;let h={};i.describe=function(x,O){if(Array.isArray(x))x.forEach((W)=>{i.describe(W,O)});else if(typeof x==="object")Object.keys(x).forEach((W)=>{i.describe(W,x[W])});else h[x]=O},i.getDescriptions=()=>h;let m=[];i.epilog=(S)=>{m.push(S)};let p=!1,y;i.wrap=(S)=>{p=!0,y=S},i.getWrap=()=>{if(t.getEnv("YARGS_DISABLE_WRAP"))return null;if(!p)y=L(),p=!0;return y};let E="__yargsString__:";i.deferY18nLookup=(S)=>E+S,i.help=function(){if(C)return C;k();let x=e.customScriptName?e.$0:t.path.basename(e.$0),O=e.getDemandedOptions(),W=e.getDemandedCommands(),Z=e.getDeprecatedOptions(),re=e.getGroups(),Q=e.getOptions(),oe=[];oe=oe.concat(Object.keys(h)),oe=oe.concat(Object.keys(O)),oe=oe.concat(Object.keys(W)),oe=oe.concat(Object.keys(Q.default)),oe=oe.filter(T),oe=Object.keys(oe.reduce((H,ee)=>{if(ee!=="_")H[ee]=!0;return H},{}));let $e=i.getWrap(),J=t.cliui({width:$e,wrap:!!$e});if(!f){if(u.length)u.forEach((H)=>{if(J.div({text:`${H[0].replace(/\$0/g,x)}`}),H[1])J.div({text:`${H[1]}`,padding:[1,0,0,0]})}),J.div();else if(d.length){let H=null;if(W._)H=`${x} <${n("command")}>
|
|
13
|
+
`).map((i)=>pu(i,t,n)).join(`
|
|
14
|
+
`)}function Es(e){return er(e,{stringWidth:Le,stripAnsi:dt,wrap:Cs})}import{dirname as _r,resolve as Sr}from"path";import{readdirSync as hu,statSync as gu}from"fs";function xs(e,t){let n=Sr(".",e),i;if(!gu(n).isDirectory())n=_r(n);while(!0){if(i=t(n,hu(n)),i)return Sr(n,i);if(n=_r(i=n),i===n)break}}import{inspect as Pu}from"util";import{fileURLToPath as Jr}from"url";import{format as yu}from"util";import{normalize as wu,resolve as bu}from"path";function pt(e){if(!(e!==e.toLowerCase()&&e!==e.toUpperCase()))e=e.toLowerCase();if(e.indexOf("-")===-1&&e.indexOf("_")===-1)return e;else{let n="",i=!1,s=e.match(/^-+/);for(let r=s?s[0].length:0;r<e.length;r++){let o=e.charAt(r);if(i)i=!1,o=o.toUpperCase();if(r!==0&&(o==="-"||o==="_"))i=!0;else if(o!=="-"&&o!=="_")n+=o}return n}}function _n(e,t){let n=e.toLowerCase();t=t||"-";let i="";for(let s=0;s<e.length;s++){let r=n.charAt(s),o=e.charAt(s);if(r!==o&&s>0)i+=`${t}${n.charAt(s)}`;else i+=o}return i}function Sn(e){if(e===null||e===void 0)return!1;if(typeof e==="number")return!0;if(/^0x[0-9a-f]+$/i.test(e))return!0;if(/^0[^.]/.test(e))return!1;return/^[-]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(e)}function kr(e){if(Array.isArray(e))return e.map((o)=>typeof o!=="string"?o+"":o);e=e.trim();let t=0,n=null,i=null,s=null,r=[];for(let o=0;o<e.length;o++){if(n=i,i=e.charAt(o),i===" "&&!s){if(n!==" ")t++;continue}if(i===s)s=null;else if((i==="'"||i==='"')&&!s)s=i;if(!r[t])r[t]="";r[t]+=i}return r}var Ie;(function(e){e.BOOLEAN="boolean",e.STRING="string",e.NUMBER="number",e.ARRAY="array"})(Ie||(Ie={}));var Qe;class Ss{constructor(e){Qe=e}parse(e,t){let n=Object.assign({alias:void 0,array:void 0,boolean:void 0,config:void 0,configObjects:void 0,configuration:void 0,coerce:void 0,count:void 0,default:void 0,envPrefix:void 0,narg:void 0,normalize:void 0,string:void 0,number:void 0,__:void 0,key:void 0},t),i=kr(e),s=typeof e==="string",r=mu(Object.assign(Object.create(null),n.alias)),o=Object.assign({"boolean-negation":!0,"camel-case-expansion":!0,"combine-arrays":!1,"dot-notation":!0,"duplicate-arguments-array":!0,"flatten-duplicate-arrays":!0,"greedy-arrays":!0,"halt-at-non-option":!1,"nargs-eats-options":!1,"negation-prefix":"no-","parse-numbers":!0,"parse-positional-numbers":!0,"populate--":!1,"set-placeholder-key":!1,"short-option-groups":!0,"strip-aliased":!1,"strip-dashed":!1,"unknown-options-as-args":!1},n.configuration),a=Object.assign(Object.create(null),n.default),c=n.configObjects||[],u=n.envPrefix,f=o["populate--"],l=f?"--":"_",d=Object.create(null),h=Object.create(null),m=n.__||Qe.format,p={aliases:Object.create(null),arrays:Object.create(null),bools:Object.create(null),strings:Object.create(null),numbers:Object.create(null),counts:Object.create(null),normalize:Object.create(null),configs:Object.create(null),nargs:Object.create(null),coercions:Object.create(null),keys:[]},y=/^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/,E=new RegExp("^--"+o["negation-prefix"]+"(.+)");if([].concat(n.array||[]).filter(Boolean).forEach(function(D){let b=typeof D==="object"?D.key:D,I=Object.keys(D).map(function(_){return{boolean:"bools",string:"strings",number:"numbers"}[_]}).filter(Boolean).pop();if(I)p[I][b]=!0;p.arrays[b]=!0,p.keys.push(b)}),[].concat(n.boolean||[]).filter(Boolean).forEach(function(D){p.bools[D]=!0,p.keys.push(D)}),[].concat(n.string||[]).filter(Boolean).forEach(function(D){p.strings[D]=!0,p.keys.push(D)}),[].concat(n.number||[]).filter(Boolean).forEach(function(D){p.numbers[D]=!0,p.keys.push(D)}),[].concat(n.count||[]).filter(Boolean).forEach(function(D){p.counts[D]=!0,p.keys.push(D)}),[].concat(n.normalize||[]).filter(Boolean).forEach(function(D){p.normalize[D]=!0,p.keys.push(D)}),typeof n.narg==="object")Object.entries(n.narg).forEach(([D,b])=>{if(typeof b==="number")p.nargs[D]=b,p.keys.push(D)});if(typeof n.coerce==="object")Object.entries(n.coerce).forEach(([D,b])=>{if(typeof b==="function")p.coercions[D]=b,p.keys.push(D)});if(typeof n.config<"u"){if(Array.isArray(n.config)||typeof n.config==="string")[].concat(n.config).filter(Boolean).forEach(function(D){p.configs[D]=!0});else if(typeof n.config==="object")Object.entries(n.config).forEach(([D,b])=>{if(typeof b==="boolean"||typeof b==="function")p.configs[D]=b})}Oe(n.key,r,n.default,p.arrays),Object.keys(a).forEach(function(D){(p.aliases[D]||[]).forEach(function(b){a[b]=a[D]})});let F=null;Ds();let k=[],C=Object.assign(Object.create(null),{_:[]}),A={};for(let D=0;D<i.length;D++){let b=i[D],I=b.replace(/^-{3,}/,"---"),_,w,j,M,K,ge;if(b!=="--"&&/^-/.test(b)&&ee(b))P(b);else if(I.match(/^---+(=|$)/)){P(b);continue}else if(b.match(/^--.+=/)||!o["short-option-groups"]&&b.match(/^-.+=/)){if(M=b.match(/^--?([^=]+)=([\s\S]*)$/),M!==null&&Array.isArray(M)&&M.length>=3)if(z(M[1],p.arrays))D=L(D,M[1],i,M[2]);else if(z(M[1],p.nargs)!==!1)D=v(D,M[1],i,M[2]);else R(M[1],M[2],!0)}else if(b.match(E)&&o["boolean-negation"]){if(M=b.match(E),M!==null&&Array.isArray(M)&&M.length>=2)w=M[1],R(w,z(w,p.arrays)?[!1]:!1)}else if(b.match(/^--.+/)||!o["short-option-groups"]&&b.match(/^-[^-]+/)){if(M=b.match(/^--?(.+)/),M!==null&&Array.isArray(M)&&M.length>=2)if(w=M[1],z(w,p.arrays))D=L(D,w,i);else if(z(w,p.nargs)!==!1)D=v(D,w,i);else if(K=i[D+1],K!==void 0&&(!K.match(/^-/)||K.match(y))&&!z(w,p.bools)&&!z(w,p.counts))R(w,K),D++;else if(/^(true|false)$/.test(K))R(w,K),D++;else R(w,V(w))}else if(b.match(/^-.\..+=/)){if(M=b.match(/^-([^=]+)=([\s\S]*)$/),M!==null&&Array.isArray(M)&&M.length>=3)R(M[1],M[2])}else if(b.match(/^-.\..+/)&&!b.match(y)){if(K=i[D+1],M=b.match(/^-(.\..+)/),M!==null&&Array.isArray(M)&&M.length>=2)if(w=M[1],K!==void 0&&!K.match(/^-/)&&!z(w,p.bools)&&!z(w,p.counts))R(w,K),D++;else R(w,V(w))}else if(b.match(/^-[^-]+/)&&!b.match(y)){j=b.slice(1,-1).split(""),_=!1;for(let be=0;be<j.length;be++){if(K=b.slice(be+2),j[be+1]&&j[be+1]==="="){if(ge=b.slice(be+3),w=j[be],z(w,p.arrays))D=L(D,w,i,ge);else if(z(w,p.nargs)!==!1)D=v(D,w,i,ge);else R(w,ge);_=!0;break}if(K==="-"){R(j[be],K);continue}if(/[A-Za-z]/.test(j[be])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(K)&&z(K,p.bools)===!1){R(j[be],K),_=!0;break}if(j[be+1]&&j[be+1].match(/\W/)){R(j[be],K),_=!0;break}else R(j[be],V(j[be]))}if(w=b.slice(-1)[0],!_&&w!=="-")if(z(w,p.arrays))D=L(D,w,i);else if(z(w,p.nargs)!==!1)D=v(D,w,i);else if(K=i[D+1],K!==void 0&&(!/^(-|--)[^-]/.test(K)||K.match(y))&&!z(w,p.bools)&&!z(w,p.counts))R(w,K),D++;else if(/^(true|false)$/.test(K))R(w,K),D++;else R(w,V(w))}else if(b.match(/^-[0-9]$/)&&b.match(y)&&z(b.slice(1),p.bools))w=b.slice(1),R(w,V(w));else if(b==="--"){k=i.slice(D+1);break}else if(o["halt-at-non-option"]){k=i.slice(D);break}else P(b)}if(re(C,!0),re(C,!1),O(C),Z(),$e(C,p.aliases,a,!0),Q(C),o["set-placeholder-key"])oe(C);if(Object.keys(p.counts).forEach(function(D){if(!J(C,D.split(".")))R(D,0)}),f&&k.length)C[l]=[];if(k.forEach(function(D){C[l].push(D)}),o["camel-case-expansion"]&&o["strip-dashed"])Object.keys(C).filter((D)=>D!=="--"&&D.includes("-")).forEach((D)=>{delete C[D]});if(o["strip-aliased"])[].concat(...Object.keys(r).map((D)=>r[D])).forEach((D)=>{if(o["camel-case-expansion"]&&D.includes("-"))delete C[D.split(".").map((b)=>pt(b)).join(".")];delete C[D]});function P(D){let b=x("_",D);if(typeof b==="string"||typeof b==="number")C._.push(b)}function v(D,b,I,_){let w,j=z(b,p.nargs);if(j=typeof j!=="number"||isNaN(j)?1:j,j===0){if(!pe(_))F=Error(m("Argument unexpected for: %s",b));return R(b,V(b)),D}let M=pe(_)?0:1;if(o["nargs-eats-options"]){if(I.length-(D+1)+M<j)F=Error(m("Not enough arguments following: %s",b));M=j}else{for(w=D+1;w<I.length;w++)if(!I[w].match(/^-[^0-9]/)||I[w].match(y)||ee(I[w]))M++;else break;if(M<j)F=Error(m("Not enough arguments following: %s",b))}let K=Math.min(M,j);if(!pe(_)&&K>0)R(b,_),K--;for(w=D+1;w<K+D+1;w++)R(b,I[w]);return D+K}function L(D,b,I,_){let w=[],j=_||I[D+1],M=z(b,p.nargs);if(z(b,p.bools)&&!/^(true|false)$/.test(j))w.push(!0);else if(pe(j)||pe(_)&&/^-/.test(j)&&!y.test(j)&&!ee(j)){if(a[b]!==void 0){let K=a[b];w=Array.isArray(K)?K:[K]}}else{if(!pe(_))w.push(S(b,_,!0));for(let K=D+1;K<I.length;K++){if(!o["greedy-arrays"]&&w.length>0||M&&typeof M==="number"&&w.length>=M)break;if(j=I[K],/^-/.test(j)&&!y.test(j)&&!ee(j))break;D=K,w.push(S(b,j,s))}}if(typeof M==="number"&&(M&&w.length<M||isNaN(M)&&w.length===0))F=Error(m("Not enough arguments following: %s",b));return R(b,w),D}function R(D,b,I=s){if(/-/.test(D)&&o["camel-case-expansion"]){let j=D.split(".").map(function(M){return pt(M)}).join(".");G(D,j)}let _=S(D,b,I),w=D.split(".");if(ae(C,w,_),p.aliases[D])p.aliases[D].forEach(function(j){let M=j.split(".");ae(C,M,_)});if(w.length>1&&o["dot-notation"])(p.aliases[w[0]]||[]).forEach(function(j){let M=j.split("."),K=[].concat(w);if(K.shift(),M=M.concat(K),!(p.aliases[D]||[]).includes(M.join(".")))ae(C,M,_)});if(z(D,p.normalize)&&!z(D,p.arrays))[D].concat(p.aliases[D]||[]).forEach(function(M){Object.defineProperty(A,M,{enumerable:!0,get(){return b},set(K){b=typeof K==="string"?Qe.normalize(K):K}})})}function G(D,b){if(!(p.aliases[D]&&p.aliases[D].length))p.aliases[D]=[b],d[b]=!0;if(!(p.aliases[b]&&p.aliases[b].length))G(b,D)}function S(D,b,I){if(I)b=Du(b);if(z(D,p.bools)||z(D,p.counts)){if(typeof b==="string")b=b==="true"}let _=Array.isArray(b)?b.map(function(w){return x(D,w)}):x(D,b);if(z(D,p.counts)&&(pe(_)||typeof _==="boolean"))_=_s();if(z(D,p.normalize)&&z(D,p.arrays))if(Array.isArray(b))_=b.map((w)=>Qe.normalize(w));else _=Qe.normalize(b);return _}function x(D,b){if(!o["parse-positional-numbers"]&&D==="_")return b;if(!z(D,p.strings)&&!z(D,p.bools)&&!Array.isArray(b)){if(Sn(b)&&o["parse-numbers"]&&Number.isSafeInteger(Math.floor(parseFloat(`${b}`)))||!pe(b)&&z(D,p.numbers))b=Number(b)}return b}function O(D){let b=Object.create(null);$e(b,p.aliases,a),Object.keys(p.configs).forEach(function(I){let _=D[I]||b[I];if(_)try{let w=null,j=Qe.resolve(Qe.cwd(),_),M=p.configs[I];if(typeof M==="function"){try{w=M(j)}catch(K){w=K}if(w instanceof Error){F=w;return}}else w=Qe.require(j);W(w)}catch(w){if(w.name==="PermissionDenied")F=w;else if(D[I])F=Error(m("Invalid JSON config file: %s",_))}})}function W(D,b){Object.keys(D).forEach(function(I){let _=D[I],w=b?b+"."+I:I;if(typeof _==="object"&&_!==null&&!Array.isArray(_)&&o["dot-notation"])W(_,w);else if(!J(C,w.split("."))||z(w,p.arrays)&&o["combine-arrays"])R(w,_)})}function Z(){if(typeof c<"u")c.forEach(function(D){W(D)})}function re(D,b){if(typeof u>"u")return;let I=typeof u==="string"?u:"",_=Qe.env();Object.keys(_).forEach(function(w){if(I===""||w.lastIndexOf(I,0)===0){let j=w.split("__").map(function(M,K){if(K===0)M=M.substring(I.length);return pt(M)});if((b&&p.configs[j.join(".")]||!b)&&!J(D,j))R(j.join("."),_[w])}})}function Q(D){let b,I=new Set;Object.keys(D).forEach(function(_){if(!I.has(_)){if(b=z(_,p.coercions),typeof b==="function")try{let w=x(_,b(D[_]));[].concat(p.aliases[_]||[],_).forEach((j)=>{I.add(j),D[j]=w})}catch(w){F=w}}})}function oe(D){return p.keys.forEach((b)=>{if(~b.indexOf("."))return;if(typeof D[b]>"u")D[b]=void 0}),D}function $e(D,b,I,_=!1){Object.keys(I).forEach(function(w){if(!J(D,w.split("."))){if(ae(D,w.split("."),I[w]),_)h[w]=!0;(b[w]||[]).forEach(function(j){if(J(D,j.split(".")))return;ae(D,j.split("."),I[w])})}})}function J(D,b){let I=D;if(!o["dot-notation"])b=[b.join(".")];b.slice(0,-1).forEach(function(w){I=I[w]||{}});let _=b[b.length-1];if(typeof I!=="object")return!1;else return _ in I}function ae(D,b,I){let _=D;if(!o["dot-notation"])b=[b.join(".")];b.slice(0,-1).forEach(function(ge){if(ge=Ar(ge),typeof _==="object"&&_[ge]===void 0)_[ge]={};if(typeof _[ge]!=="object"||Array.isArray(_[ge])){if(Array.isArray(_[ge]))_[ge].push({});else _[ge]=[_[ge],{}];_=_[ge][_[ge].length-1]}else _=_[ge]});let w=Ar(b[b.length-1]),j=z(b.join("."),p.arrays),M=Array.isArray(I),K=o["duplicate-arguments-array"];if(!K&&z(w,p.nargs)){if(K=!0,!pe(_[w])&&p.nargs[w]===1||Array.isArray(_[w])&&_[w].length===p.nargs[w])_[w]=void 0}if(I===_s())_[w]=_s(_[w]);else if(Array.isArray(_[w]))if(K&&j&&M)_[w]=o["flatten-duplicate-arrays"]?_[w].concat(I):(Array.isArray(_[w][0])?_[w]:[_[w]]).concat([I]);else if(!K&&Boolean(j)===Boolean(M))_[w]=I;else _[w]=_[w].concat([I]);else if(_[w]===void 0&&j)_[w]=M?I:[I];else if(K&&!(_[w]===void 0||z(w,p.counts)||z(w,p.bools)))_[w]=[_[w],I];else _[w]=I}function Oe(...D){D.forEach(function(b){Object.keys(b||{}).forEach(function(I){if(p.aliases[I])return;p.aliases[I]=[].concat(r[I]||[]),p.aliases[I].concat(I).forEach(function(_){if(/-/.test(_)&&o["camel-case-expansion"]){let w=pt(_);if(w!==I&&p.aliases[I].indexOf(w)===-1)p.aliases[I].push(w),d[w]=!0}}),p.aliases[I].concat(I).forEach(function(_){if(_.length>1&&/[A-Z]/.test(_)&&o["camel-case-expansion"]){let w=_n(_,"-");if(w!==I&&p.aliases[I].indexOf(w)===-1)p.aliases[I].push(w),d[w]=!0}}),p.aliases[I].forEach(function(_){p.aliases[_]=[I].concat(p.aliases[I].filter(function(w){return _!==w}))})})})}function z(D,b){let I=[].concat(p.aliases[D]||[],D),_=Object.keys(b),w=I.find((j)=>_.includes(j));return w?b[w]:!1}function vt(D){let b=Object.keys(p);return[].concat(b.map((_)=>p[_])).some(function(_){return Array.isArray(_)?_.includes(D):_[D]})}function Yi(D,...b){return[].concat(...b).some(function(_){let w=D.match(_);return w&&vt(w[1])})}function H(D){if(D.match(y)||!D.match(/^-[^-]+/))return!1;let b=!0,I,_=D.slice(1).split("");for(let w=0;w<_.length;w++){if(I=D.slice(w+2),!vt(_[w])){b=!1;break}if(_[w+1]&&_[w+1]==="="||I==="-"||/[A-Za-z]/.test(_[w])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(I)||_[w+1]&&_[w+1].match(/\W/))break}return b}function ee(D){return o["unknown-options-as-args"]&&de(D)}function de(D){if(D=D.replace(/^-{3,}/,"--"),D.match(y))return!1;if(H(D))return!1;return!Yi(D,/^-+([^=]+?)=[\s\S]*$/,E,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}function V(D){if(!z(D,p.bools)&&!z(D,p.counts)&&`${D}`in a)return a[D];else return ye(ue(D))}function ye(D){return{[Ie.BOOLEAN]:!0,[Ie.STRING]:"",[Ie.NUMBER]:void 0,[Ie.ARRAY]:[]}[D]}function ue(D){let b=Ie.BOOLEAN;if(z(D,p.strings))b=Ie.STRING;else if(z(D,p.numbers))b=Ie.NUMBER;else if(z(D,p.bools))b=Ie.BOOLEAN;else if(z(D,p.arrays))b=Ie.ARRAY;return b}function pe(D){return D===void 0}function Ds(){Object.keys(p.counts).find((D)=>{if(z(D,p.arrays))return F=Error(m("Invalid configuration: %s, opts.count excludes opts.array.",D)),!0;else if(z(D,p.nargs))return F=Error(m("Invalid configuration: %s, opts.count excludes opts.narg.",D)),!0;return!1})}return{aliases:Object.assign({},p.aliases),argv:Object.assign(A,C),configuration:o,defaulted:Object.assign({},h),error:F,newAliases:Object.assign({},d)}}}function mu(e){let t=[],n=Object.create(null),i=!0;Object.keys(e).forEach(function(s){t.push([].concat(e[s],s))});while(i){i=!1;for(let s=0;s<t.length;s++)for(let r=s+1;r<t.length;r++)if(t[s].filter(function(a){return t[r].indexOf(a)!==-1}).length){t[s]=t[s].concat(t[r]),t.splice(r,1),i=!0;break}}return t.forEach(function(s){s=s.filter(function(o,a,c){return c.indexOf(o)===a});let r=s.pop();if(r!==void 0&&typeof r==="string")n[r]=s}),n}function _s(e){return e!==void 0?e+1:1}function Ar(e){if(e==="__proto__")return"___proto___";return e}function Du(e){return typeof e==="string"&&(e[0]==="'"||e[0]==='"')&&e[e.length-1]===e[0]?e.substring(1,e.length-1):e}import{readFileSync as Fu}from"fs";import{createRequire as $r}from"node:module";var ks,As,$s,Or=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):20,Ir=(As=(ks=process===null||process===void 0?void 0:process.versions)===null||ks===void 0?void 0:ks.node)!==null&&As!==void 0?As:($s=process===null||process===void 0?void 0:process.version)===null||$s===void 0?void 0:$s.slice(1);if(Ir){if(Number(Ir.match(/^([^.]+)/)[1])<Or)throw Error(`yargs parser supports a minimum Node.js version of ${Or}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`)}var Cu=process?process.env:{},Tr=$r?$r(import.meta.url):void 0,Pr=new Ss({cwd:process.cwd,env:()=>Cu,format:yu,normalize:wu,resolve:bu,require:(e)=>{if(typeof Tr<"u")return Tr(e);else if(e.match(/\.json$/))return JSON.parse(Fu(e,"utf8"));else throw Error("only .json config files are supported in ESM")}}),Zt=function(t,n){return Pr.parse(t.slice(),n).argv};Zt.detailed=function(e,t){return Pr.parse(e.slice(),t)};Zt.camelCase=pt;Zt.decamelize=_n;Zt.looksLikeNumber=Sn;var Os=Zt;import{basename as Ru,dirname as Mu,extname as Bu,relative as Nu,resolve as Ur,join as vu}from"path";function Rr(){if(Eu())return 0;return 1}function Eu(){return xu()&&!process.defaultApp}function xu(){return!!process.versions.electron}function Is(e){return e.slice(Rr()+1)}function Mr(){return process.argv[Rr()]}import{readFileSync as _u,statSync as Su,writeFile as ku}from"fs";import{format as Au}from"util";import{resolve as $u}from"path";var Br={fs:{readFileSync:_u,writeFile:ku},format:Au,resolve:$u,exists:(e)=>{try{return Su(e).isFile()}catch(t){return!1}}};var We;class Nr{constructor(e){e=e||{},this.directory=e.directory||"./locales",this.updateFiles=typeof e.updateFiles==="boolean"?e.updateFiles:!0,this.locale=e.locale||"en",this.fallbackToLanguage=typeof e.fallbackToLanguage==="boolean"?e.fallbackToLanguage:!0,this.cache=Object.create(null),this.writeQueue=[]}__(...e){if(typeof arguments[0]!=="string")return this._taggedLiteral(arguments[0],...arguments);let t=e.shift(),n=function(){};if(typeof e[e.length-1]==="function")n=e.pop();if(n=n||function(){},!this.cache[this.locale])this._readLocaleFile();if(!this.cache[this.locale][t]&&this.updateFiles)this.cache[this.locale][t]=t,this._enqueueWrite({directory:this.directory,locale:this.locale,cb:n});else n();return We.format.apply(We.format,[this.cache[this.locale][t]||t].concat(e))}__n(){let e=Array.prototype.slice.call(arguments),t=e.shift(),n=e.shift(),i=e.shift(),s=function(){};if(typeof e[e.length-1]==="function")s=e.pop();if(!this.cache[this.locale])this._readLocaleFile();let r=i===1?t:n;if(this.cache[this.locale][t])r=this.cache[this.locale][t][i===1?"one":"other"];if(!this.cache[this.locale][t]&&this.updateFiles)this.cache[this.locale][t]={one:t,other:n},this._enqueueWrite({directory:this.directory,locale:this.locale,cb:s});else s();let o=[r];if(~r.indexOf("%d"))o.push(i);return We.format.apply(We.format,o.concat(e))}setLocale(e){this.locale=e}getLocale(){return this.locale}updateLocale(e){if(!this.cache[this.locale])this._readLocaleFile();for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t))this.cache[this.locale][t]=e[t]}_taggedLiteral(e,...t){let n="";return e.forEach(function(i,s){let r=t[s+1];if(n+=i,typeof r<"u")n+="%s"}),this.__.apply(this,[n].concat([].slice.call(t,1)))}_enqueueWrite(e){if(this.writeQueue.push(e),this.writeQueue.length===1)this._processWriteQueue()}_processWriteQueue(){let e=this,t=this.writeQueue[0],n=t.directory,i=t.locale,s=t.cb,r=this._resolveLocaleFile(n,i),o=JSON.stringify(this.cache[i],null,2);We.fs.writeFile(r,o,"utf-8",function(a){if(e.writeQueue.shift(),e.writeQueue.length>0)e._processWriteQueue();s(a)})}_readLocaleFile(){let e={},t=this._resolveLocaleFile(this.directory,this.locale);try{if(We.fs.readFileSync)e=JSON.parse(We.fs.readFileSync(t,"utf-8"))}catch(n){if(n instanceof SyntaxError)n.message="syntax error in "+t;if(n.code==="ENOENT")e={};else throw n}this.cache[this.locale]=e}_resolveLocaleFile(e,t){let n=We.resolve(e,"./",t+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(n)&&~t.lastIndexOf("_")){let i=We.resolve(e,"./",t.split("_")[0]+".json");if(this._fileExistsSync(i))n=i}return n}_fileExistsSync(e){return We.exists(e)}}function vr(e,t){We=t;let n=new Nr(e);return{__:n.__.bind(n),__n:n.__n.bind(n),setLocale:n.setLocale.bind(n),getLocale:n.getLocale.bind(n),updateLocale:n.updateLocale.bind(n),locale:n.locale}}var Ou=(e)=>vr(e,Br),jr=Ou;var Kr=Gi(Wr(),1);import{createRequire as ju}from"node:module";import{readFileSync as Lu,readdirSync as Wu}from"node:fs";var Ts=Jr(import.meta.url),Uu=Ts.substring(0,Ts.lastIndexOf("node_modules")),Ju=ju(import.meta.url),Ps={assert:{notStrictEqual:Iu,strictEqual:Tu},cliui:Es,findUp:xs,getEnv:(e)=>process.env[e],inspect:Pu,getProcessArgvBin:Mr,mainFilename:Uu||process.cwd(),Parser:Os,path:{basename:Ru,dirname:Mu,extname:Bu,relative:Nu,resolve:Ur,join:vu},process:{argv:()=>process.argv,cwd:process.cwd,emitWarning:(e,t)=>process.emitWarning(e,t),execPath:()=>process.execPath,exit:(e)=>{process.exit(e)},nextTick:process.nextTick,stdColumns:typeof process.stdout.columns<"u"?process.stdout.columns:null},readFileSync:Lu,readdirSync:Wu,require:Ju,getCallerFile:()=>{let e=Kr.default(3);return e.match(/^file:\/\//)?Jr(e):e},stringWidth:Le,y18n:jr({directory:Ur(Ts,"../../../locales"),updateFiles:!1})};function Fe(e,t,n,i){n.assert.notStrictEqual(e,t,i)}function Rs(e,t){t.assert.strictEqual(typeof e,"string")}function jt(e){return Object.keys(e)}function ne(e){return!!e&&!!e.then&&typeof e.then==="function"}class le extends Error{constructor(e){super(e||"yargs error");if(this.name="YError",Error.captureStackTrace)Error.captureStackTrace(this,le)}}function nt(e){let n=e.replace(/\s{2,}/g," ").split(/\s+(?![^[]*]|[^<]*>)/),i=/\.*[\][<>]/g,s=n.shift();if(!s)throw Error(`No command found in: ${e}`);let r={cmd:s.replace(i,""),demanded:[],optional:[]};return n.forEach((o,a)=>{let c=!1;if(o=o.replace(/\s/g,""),/\.+[\]>]/.test(o)&&a===n.length-1)c=!0;if(/^\[/.test(o))r.optional.push({cmd:o.replace(i,"").split("|"),variadic:c});else r.demanded.push({cmd:o.replace(i,"").split("|"),variadic:c})}),r}var Ku=["first","second","third","fourth","fifth","sixth"];function B(e,t,n){function i(){return typeof e==="object"?[{demanded:[],optional:[]},e,t]:[nt(`cmd ${e}`),t,n]}try{let s=0,[r,o,a]=i(),c=[].slice.call(o);while(c.length&&c[c.length-1]===void 0)c.pop();let u=a||c.length;if(u<r.demanded.length)throw new le(`Not enough arguments provided. Expected ${r.demanded.length} but received ${c.length}.`);let f=r.demanded.length+r.optional.length;if(u>f)throw new le(`Too many arguments provided. Expected max ${f} but received ${u}.`);r.demanded.forEach((l)=>{let d=c.shift(),h=zr(d);if(l.cmd.filter((p)=>p===h||p==="*").length===0)Hr(h,l.cmd,s);s+=1}),r.optional.forEach((l)=>{if(c.length===0)return;let d=c.shift(),h=zr(d);if(l.cmd.filter((p)=>p===h||p==="*").length===0)Hr(h,l.cmd,s);s+=1})}catch(s){console.warn(s.stack)}}function zr(e){if(Array.isArray(e))return"array";else if(e===null)return"null";return typeof e}function Hr(e,t,n){throw new le(`Invalid ${Ku[n]||"manyith"} argument. Expected ${t.join(" or ")} but received ${e}.`)}class Ms{constructor(e){this.globalMiddleware=[],this.frozens=[],this.yargs=e}addMiddleware(e,t,n=!0,i=!1){if(B("<array|function> [boolean] [boolean] [boolean]",[e,t,n],arguments.length),Array.isArray(e)){for(let s=0;s<e.length;s++){if(typeof e[s]!=="function")throw Error("middleware must be a function");let r=e[s];r.applyBeforeValidation=t,r.global=n}Array.prototype.push.apply(this.globalMiddleware,e)}else if(typeof e==="function"){let s=e;s.applyBeforeValidation=t,s.global=n,s.mutates=i,this.globalMiddleware.push(e)}return this.yargs}addCoerceMiddleware(e,t){let n=this.yargs.getAliases();return this.globalMiddleware=this.globalMiddleware.filter((i)=>{let s=[...n[t]||[],t];if(!i.option)return!0;else return!s.includes(i.option)}),e.option=t,this.addMiddleware(e,!0,!0,!0)}getMiddleware(){return this.globalMiddleware}freeze(){this.frozens.push([...this.globalMiddleware])}unfreeze(){let e=this.frozens.pop();if(e!==void 0)this.globalMiddleware=e}reset(){this.globalMiddleware=this.globalMiddleware.filter((e)=>e.global)}}function qr(e){if(!e)return[];return e.map((t)=>(t.applyBeforeValidation=!1,t))}function ht(e,t,n,i){return n.reduce((s,r)=>{if(r.applyBeforeValidation!==i)return s;if(r.mutates){if(r.applied)return s;r.applied=!0}if(ne(s))return s.then((o)=>Promise.all([o,r(o,t)])).then(([o,a])=>Object.assign(o,a));else{let o=r(s,t);return ne(o)?o.then((a)=>Object.assign(s,a)):Object.assign(s,o)}},e)}function gt(e,t,n=(i)=>{throw i}){try{let i=zu(e)?e():e;return ne(i)?i.then((s)=>t(s)):t(i)}catch(i){return n(i)}}function zu(e){return typeof e==="function"}var Lt=/(^\*)|(^\$0)/;class Xr{constructor(e,t,n,i){this.requireCache=new Set,this.handlers={},this.aliasMap={},this.frozens=[],this.shim=i,this.usage=e,this.globalMiddleware=n,this.validation=t}addDirectory(e,t,n,i){i=i||{},this.requireCache.add(n);let s=this.shim.path.resolve(this.shim.path.dirname(n),e),r=this.shim.readdirSync(s,{recursive:i.recurse?!0:!1});if(!Array.isArray(i.extensions))i.extensions=["js"];let o=typeof i.visit==="function"?i.visit:(a)=>a;for(let a of r){let c=a.toString();if(i.exclude){let f=!1;if(typeof i.exclude==="function")f=i.exclude(c);else f=i.exclude.test(c);if(f)continue}if(i.include){let f=!1;if(typeof i.include==="function")f=i.include(c);else f=i.include.test(c);if(!f)continue}let u=!1;for(let f of i.extensions)if(c.endsWith(f))u=!0;if(u){let f=this.shim.path.join(s,c),l=t(f),d=Object.create(null,Object.getOwnPropertyDescriptors({...l}));if(o(d,f,c)){if(this.requireCache.has(f))continue;else this.requireCache.add(f);if(!d.command)d.command=this.shim.path.basename(f,this.shim.path.extname(f));this.addHandler(d)}}}}addHandler(e,t,n,i,s,r){let o=[],a=qr(s);if(i=i||(()=>{}),Array.isArray(e))if(Hu(e))[e,...o]=e;else for(let c of e)this.addHandler(c);else if(Yu(e)){let c=Array.isArray(e.command)||typeof e.command==="string"?e.command:null;if(c===null)throw Error(`No command name given for module: ${this.shim.inspect(e)}`);if(e.aliases)c=[].concat(c).concat(e.aliases);this.addHandler(c,this.extractDesc(e),e.builder,e.handler,e.middlewares,e.deprecated);return}else if(Yr(n)){this.addHandler([e].concat(o),t,n.builder,n.handler,n.middlewares,n.deprecated);return}if(typeof e==="string"){let c=nt(e);o=o.map((l)=>nt(l).cmd);let u=!1,f=[c.cmd].concat(o).filter((l)=>{if(Lt.test(l))return u=!0,!1;return!0});if(f.length===0&&u)f.push("$0");if(u)c.cmd=f[0],o=f.slice(1),e=e.replace(Lt,c.cmd);if(o.forEach((l)=>{this.aliasMap[l]=c.cmd}),t!==!1)this.usage.command(e,t,u,o,r);if(this.handlers[c.cmd]={original:e,description:t,handler:i,builder:n||{},middlewares:a,deprecated:r,demanded:c.demanded,optional:c.optional},u)this.defaultCommand=this.handlers[c.cmd]}}getCommandHandlers(){return this.handlers}getCommands(){return Object.keys(this.handlers).concat(Object.keys(this.aliasMap))}hasDefaultCommand(){return!!this.defaultCommand}runCommand(e,t,n,i,s,r){let o=this.handlers[e]||this.handlers[this.aliasMap[e]]||this.defaultCommand,a=t.getInternalMethods().getContext(),c=a.commands.slice(),u=!e;if(e)a.commands.push(e),a.fullCommands.push(o.original);let f=this.applyBuilderUpdateUsageAndParse(u,o,t,n.aliases,c,i,s,r);return ne(f)?f.then((l)=>this.applyMiddlewareAndGetResult(u,o,l.innerArgv,a,s,l.aliases,t)):this.applyMiddlewareAndGetResult(u,o,f.innerArgv,a,s,f.aliases,t)}applyBuilderUpdateUsageAndParse(e,t,n,i,s,r,o,a){let c=t.builder,u=n;if(kn(c)){n.getInternalMethods().getUsageInstance().freeze();let f=c(n.getInternalMethods().reset(i),a);if(ne(f))return f.then((l)=>(u=Vr(l)?l:n,this.parseAndUpdateUsage(e,t,u,s,r,o)))}else if(qu(c))n.getInternalMethods().getUsageInstance().freeze(),u=n.getInternalMethods().reset(i),Object.keys(t.builder).forEach((f)=>{u.option(f,c[f])});return this.parseAndUpdateUsage(e,t,u,s,r,o)}parseAndUpdateUsage(e,t,n,i,s,r){if(e)n.getInternalMethods().getUsageInstance().unfreeze(!0);if(this.shouldUpdateUsage(n))n.getInternalMethods().getUsageInstance().usage(this.usageFromParentCommandsCommandHandler(i,t),t.description);let o=n.getInternalMethods().runYargsParserAndExecuteCommands(null,void 0,!0,s,r);return ne(o)?o.then((a)=>({aliases:n.parsed.aliases,innerArgv:a})):{aliases:n.parsed.aliases,innerArgv:o}}shouldUpdateUsage(e){return!e.getInternalMethods().getUsageInstance().getUsageDisabled()&&e.getInternalMethods().getUsageInstance().getUsage().length===0}usageFromParentCommandsCommandHandler(e,t){let n=Lt.test(t.original)?t.original.replace(Lt,"").trim():t.original,i=e.filter((s)=>!Lt.test(s));return i.push(n),`$0 ${i.join(" ")}`}handleValidationAndGetResult(e,t,n,i,s,r,o,a){if(!r.getInternalMethods().getHasOutput()){let c=r.getInternalMethods().runValidation(s,a,r.parsed.error,e);n=gt(n,(u)=>(c(u),u))}if(t.handler&&!r.getInternalMethods().getHasOutput()){r.getInternalMethods().setHasOutput();let c=!!r.getOptions().configuration["populate--"];if(r.getInternalMethods().postProcess(n,c,!1,!1),n=ht(n,r,o,!1),n=gt(n,(u)=>{let f=t.handler(u);return ne(f)?f.then(()=>u):u}),!e)r.getInternalMethods().getUsageInstance().cacheHelpMessage();if(ne(n)&&!r.getInternalMethods().hasParseCallback())n.catch((u)=>{try{r.getInternalMethods().getUsageInstance().fail(null,u)}catch(f){}})}if(!e)i.commands.pop(),i.fullCommands.pop();return n}applyMiddlewareAndGetResult(e,t,n,i,s,r,o){let a={};if(s)return n;if(!o.getInternalMethods().getHasOutput())a=this.populatePositionals(t,n,i,o);let c=this.globalMiddleware.getMiddleware().slice(0).concat(t.middlewares),u=ht(n,o,c,!0);return ne(u)?u.then((f)=>this.handleValidationAndGetResult(e,t,f,i,r,o,c,a)):this.handleValidationAndGetResult(e,t,u,i,r,o,c,a)}populatePositionals(e,t,n,i){t._=t._.slice(n.commands.length);let s=e.demanded.slice(0),r=e.optional.slice(0),o={};this.validation.positionalCount(s.length,t._.length);while(s.length){let a=s.shift();this.populatePositional(a,t,o)}while(r.length){let a=r.shift();this.populatePositional(a,t,o)}return t._=n.commands.concat(t._.map((a)=>""+a)),this.postProcessPositionals(t,o,this.cmdToParseOptions(e.original),i),o}populatePositional(e,t,n){let i=e.cmd[0];if(e.variadic)n[i]=t._.splice(0).map(String);else if(t._.length)n[i]=[String(t._.shift())]}cmdToParseOptions(e){let t={array:[],default:{},alias:{},demand:{}},n=nt(e);return n.demanded.forEach((i)=>{let[s,...r]=i.cmd;if(i.variadic)t.array.push(s),t.default[s]=[];t.alias[s]=r,t.demand[s]=!0}),n.optional.forEach((i)=>{let[s,...r]=i.cmd;if(i.variadic)t.array.push(s),t.default[s]=[];t.alias[s]=r}),t}postProcessPositionals(e,t,n,i){let s=Object.assign({},i.getOptions());s.default=Object.assign(n.default,s.default);for(let c of Object.keys(n.alias))s.alias[c]=(s.alias[c]||[]).concat(n.alias[c]);s.array=s.array.concat(n.array),s.config={};let r=[];if(Object.keys(t).forEach((c)=>{t[c].map((u)=>{if(s.configuration["unknown-options-as-args"])s.key[c]=!0;r.push(`--${c}`),r.push(u)})}),!r.length)return;let o=Object.assign({},s.configuration,{"populate--":!1}),a=this.shim.Parser.detailed(r,Object.assign({},s,{configuration:o}));if(a.error)i.getInternalMethods().getUsageInstance().fail(a.error.message,a.error);else{let c=Object.keys(t);Object.keys(t).forEach((u)=>{c.push(...a.aliases[u])}),Object.keys(a.argv).forEach((u)=>{if(c.includes(u)){if(!t[u])t[u]=a.argv[u];if(!this.isInConfigs(i,u)&&!this.isDefaulted(i,u)&&Object.prototype.hasOwnProperty.call(e,u)&&Object.prototype.hasOwnProperty.call(a.argv,u)&&(Array.isArray(e[u])||Array.isArray(a.argv[u])))e[u]=[].concat(e[u],a.argv[u]);else e[u]=a.argv[u]}})}}isDefaulted(e,t){let{default:n}=e.getOptions();return Object.prototype.hasOwnProperty.call(n,t)||Object.prototype.hasOwnProperty.call(n,this.shim.Parser.camelCase(t))}isInConfigs(e,t){let{configObjects:n}=e.getOptions();return n.some((i)=>Object.prototype.hasOwnProperty.call(i,t))||n.some((i)=>Object.prototype.hasOwnProperty.call(i,this.shim.Parser.camelCase(t)))}runDefaultBuilderOn(e){if(!this.defaultCommand)return;if(this.shouldUpdateUsage(e)){let n=Lt.test(this.defaultCommand.original)?this.defaultCommand.original:this.defaultCommand.original.replace(/^[^[\]<>]*/,"$0 ");e.getInternalMethods().getUsageInstance().usage(n,this.defaultCommand.description)}let t=this.defaultCommand.builder;if(kn(t))return t(e,!0);else if(!Yr(t))Object.keys(t).forEach((n)=>{e.option(n,t[n])});return}extractDesc({describe:e,description:t,desc:n}){for(let i of[e,t,n]){if(typeof i==="string"||i===!1)return i;Fe(i,!0,this.shim)}return!1}freeze(){this.frozens.push({handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand})}unfreeze(){let e=this.frozens.pop();Fe(e,void 0,this.shim),{handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand}=e}reset(){return this.handlers={},this.aliasMap={},this.defaultCommand=void 0,this.requireCache=new Set,this}}function Gr(e,t,n,i){return new Xr(e,t,n,i)}function Yr(e){return typeof e==="object"&&!!e.builder&&typeof e.handler==="function"}function Hu(e){return e.every((t)=>typeof t==="string")}function kn(e){return typeof e==="function"}function qu(e){return typeof e==="object"}function Yu(e){return typeof e==="object"&&!Array.isArray(e)}function st(e={},t=()=>!0){let n={};return jt(e).forEach((i)=>{if(t(i,e[i]))n[i]=e[i]}),n}function it(e){if(typeof process>"u")return;[process.stdout,process.stderr].forEach((t)=>{let n=t;if(n._handle&&n.isTTY&&typeof n._handle.setBlocking==="function")n._handle.setBlocking(e)})}function Xu(e){return typeof e==="boolean"}function Qr(e,t){let n=t.y18n.__,i={},s=[];i.failFn=function(x){s.push(x)};let r=null,o=null,a=!0;i.showHelpOnFail=function(x=!0,O){let[W,Z]=typeof x==="string"?[!0,x]:[x,O];if(e.getInternalMethods().isGlobalContext())o=Z;return r=Z,a=W,i};let c=!1;i.fail=function(x,O){let W=e.getInternalMethods().getLoggerInstance();if(s.length)for(let Z=s.length-1;Z>=0;--Z){let re=s[Z];if(Xu(re)){if(O)throw O;else if(x)throw Error(x)}else re(x,O,i)}else{if(e.getExitProcess())it(!0);if(!c){if(c=!0,a)e.showHelp("error"),W.error();if(x||O)W.error(x||O);let Z=r||o;if(Z){if(x||O)W.error("");W.error(Z)}}if(O=O||new le(x),e.getExitProcess())return e.exit(1);else if(e.getInternalMethods().hasParseCallback())return e.exit(1,O);else throw O}};let u=[],f=!1;i.usage=(S,x)=>{if(S===null)return f=!0,u=[],i;return f=!1,u.push([S,x||""]),i},i.getUsage=()=>u,i.getUsageDisabled=()=>f,i.getPositionalGroupName=()=>n("Positionals:");let l=[];i.example=(S,x)=>{l.push([S,x||""])};let d=[];i.command=function(x,O,W,Z,re=!1){if(W)d=d.map((Q)=>(Q[2]=!1,Q));d.push([x,O||"",W,Z,re])},i.getCommands=()=>d;let h={};i.describe=function(x,O){if(Array.isArray(x))x.forEach((W)=>{i.describe(W,O)});else if(typeof x==="object")Object.keys(x).forEach((W)=>{i.describe(W,x[W])});else h[x]=O},i.getDescriptions=()=>h;let m=[];i.epilog=(S)=>{m.push(S)};let p=!1,y;i.wrap=(S)=>{p=!0,y=S},i.getWrap=()=>{if(t.getEnv("YARGS_DISABLE_WRAP"))return null;if(!p)y=L(),p=!0;return y};let E="__yargsString__:";i.deferY18nLookup=(S)=>E+S,i.help=function(){if(C)return C;k();let x=e.customScriptName?e.$0:t.path.basename(e.$0),O=e.getDemandedOptions(),W=e.getDemandedCommands(),Z=e.getDeprecatedOptions(),re=e.getGroups(),Q=e.getOptions(),oe=[];oe=oe.concat(Object.keys(h)),oe=oe.concat(Object.keys(O)),oe=oe.concat(Object.keys(W)),oe=oe.concat(Object.keys(Q.default)),oe=oe.filter(P),oe=Object.keys(oe.reduce((H,ee)=>{if(ee!=="_")H[ee]=!0;return H},{}));let $e=i.getWrap(),J=t.cliui({width:$e,wrap:!!$e});if(!f){if(u.length)u.forEach((H)=>{if(J.div({text:`${H[0].replace(/\$0/g,x)}`}),H[1])J.div({text:`${H[1]}`,padding:[1,0,0,0]})}),J.div();else if(d.length){let H=null;if(W._)H=`${x} <${n("command")}>
|
|
15
15
|
`;else H=`${x} [${n("command")}]
|
|
16
|
-
`;J.div(`${H}`)}}if(d.length>1||d.length===1&&!d[0][2]){J.div(n("Commands:"));let H=e.getInternalMethods().getContext(),ee=H.commands.length?`${H.commands.join(" ")} `:"";if(e.getInternalMethods().getParserConfiguration()["sort-commands"]===!0)d=d.sort((V,ye)=>V[0].localeCompare(ye[0]));let de=x?`${x} `:"";d.forEach((V)=>{let ye=`${de}${ee}${V[0].replace(/^\$0 ?/,"")}`;J.span({text:ye,padding:[0,2,0,2],width:F(d,$e,`${x}${ee}`)+4},{text:V[1]});let ue=[];if(V[2])ue.push(`[${n("default")}]`);if(V[3]&&V[3].length)ue.push(`[${n("aliases:")} ${V[3].join(", ")}]`);if(V[4])if(typeof V[4]==="string")ue.push(`[${n("deprecated: %s",V[4])}]`);else ue.push(`[${n("deprecated")}]`);if(ue.length)J.div({text:ue.join(" "),padding:[0,0,0,2],align:"right"});else J.div()}),J.div()}let ae=(Object.keys(Q.alias)||[]).concat(Object.keys(e.parsed.newAliases)||[]);oe=oe.filter((H)=>!e.parsed.newAliases[H]&&ae.every((ee)=>(Q.alias[ee]||[]).indexOf(H)===-1));let Oe=n("Options:");if(!re[Oe])re[Oe]=[];A(oe,Q.alias,re,Oe);let z=(H)=>/^--/.test(An(H)),vt=Object.keys(re).filter((H)=>re[H].length>0).map((H)=>{let ee=re[H].filter(
|
|
16
|
+
`;J.div(`${H}`)}}if(d.length>1||d.length===1&&!d[0][2]){J.div(n("Commands:"));let H=e.getInternalMethods().getContext(),ee=H.commands.length?`${H.commands.join(" ")} `:"";if(e.getInternalMethods().getParserConfiguration()["sort-commands"]===!0)d=d.sort((V,ye)=>V[0].localeCompare(ye[0]));let de=x?`${x} `:"";d.forEach((V)=>{let ye=`${de}${ee}${V[0].replace(/^\$0 ?/,"")}`;J.span({text:ye,padding:[0,2,0,2],width:F(d,$e,`${x}${ee}`)+4},{text:V[1]});let ue=[];if(V[2])ue.push(`[${n("default")}]`);if(V[3]&&V[3].length)ue.push(`[${n("aliases:")} ${V[3].join(", ")}]`);if(V[4])if(typeof V[4]==="string")ue.push(`[${n("deprecated: %s",V[4])}]`);else ue.push(`[${n("deprecated")}]`);if(ue.length)J.div({text:ue.join(" "),padding:[0,0,0,2],align:"right"});else J.div()}),J.div()}let ae=(Object.keys(Q.alias)||[]).concat(Object.keys(e.parsed.newAliases)||[]);oe=oe.filter((H)=>!e.parsed.newAliases[H]&&ae.every((ee)=>(Q.alias[ee]||[]).indexOf(H)===-1));let Oe=n("Options:");if(!re[Oe])re[Oe]=[];A(oe,Q.alias,re,Oe);let z=(H)=>/^--/.test(An(H)),vt=Object.keys(re).filter((H)=>re[H].length>0).map((H)=>{let ee=re[H].filter(P).map((de)=>{if(ae.includes(de))return de;for(let V=0,ye;(ye=ae[V])!==void 0;V++)if((Q.alias[ye]||[]).includes(de))return ye;return de});return{groupName:H,normalizedKeys:ee}}).filter(({normalizedKeys:H})=>H.length>0).map(({groupName:H,normalizedKeys:ee})=>{let de=ee.reduce((V,ye)=>(V[ye]=[ye].concat(Q.alias[ye]||[]).map((ue)=>{if(H===i.getPositionalGroupName())return ue;else return(/^[0-9]$/.test(ue)?Q.boolean.includes(ye)?"-":"--":ue.length>1?"--":"-")+ue}).sort((ue,pe)=>z(ue)===z(pe)?0:z(ue)?1:-1).join(", "),V),{});return{groupName:H,normalizedKeys:ee,switches:de}});if(vt.filter(({groupName:H})=>H!==i.getPositionalGroupName()).some(({normalizedKeys:H,switches:ee})=>!H.every((de)=>z(ee[de]))))vt.filter(({groupName:H})=>H!==i.getPositionalGroupName()).forEach(({normalizedKeys:H,switches:ee})=>{H.forEach((de)=>{if(z(ee[de]))ee[de]=Gu(ee[de],4)})});if(vt.forEach(({groupName:H,normalizedKeys:ee,switches:de})=>{J.div(H),ee.forEach((V)=>{let ye=de[V],ue=h[V]||"",pe=null;if(ue.includes(E))ue=n(ue.substring(E.length));if(Q.boolean.includes(V))pe=`[${n("boolean")}]`;if(Q.count.includes(V))pe=`[${n("count")}]`;if(Q.string.includes(V))pe=`[${n("string")}]`;if(Q.normalize.includes(V))pe=`[${n("string")}]`;if(Q.array.includes(V))pe=`[${n("array")}]`;if(Q.number.includes(V))pe=`[${n("number")}]`;let Ds=(I)=>typeof I==="string"?`[${n("deprecated: %s",I)}]`:`[${n("deprecated")}]`,D=[V in Z?Ds(Z[V]):null,pe,V in O?`[${n("required")}]`:null,Q.choices&&Q.choices[V]?`[${n("choices:")} ${i.stringifiedValues(Q.choices[V])}]`:null,v(Q.default[V],Q.defaultDescription[V])].filter(Boolean).join(" ");J.span({text:An(ye),padding:[0,2,0,2+Zr(ye)],width:F(de,$e)+4},ue);let b=e.getInternalMethods().getUsageConfiguration()["hide-types"]===!0;if(D&&!b)J.div({text:D,padding:[0,0,0,2],align:"right"});else J.div()}),J.div()}),l.length)J.div(n("Examples:")),l.forEach((H)=>{H[0]=H[0].replace(/\$0/g,x)}),l.forEach((H)=>{if(H[1]==="")J.div({text:H[0],padding:[0,2,0,2]});else J.div({text:H[0],padding:[0,2,0,2],width:F(l,$e)+4},{text:H[1]})}),J.div();if(m.length>0){let H=m.map((ee)=>ee.replace(/\$0/g,x)).join(`
|
|
17
17
|
`);J.div(`${H}
|
|
18
|
-
`)}return J.toString().replace(/\s*$/,"")};function F(S,x,O){let W=0;if(!Array.isArray(S))S=Object.values(S).map((Z)=>[Z]);if(S.forEach((Z)=>{W=Math.max(t.stringWidth(O?`${O} ${An(Z[0])}`:An(Z[0]))+Zr(Z[0]),W)}),x)W=Math.min(W,parseInt((x*0.5).toString(),10));return W}function k(){let S=e.getDemandedOptions(),x=e.getOptions();(Object.keys(x.alias)||[]).forEach((O)=>{x.alias[O].forEach((W)=>{if(h[W])i.describe(O,h[W]);if(W in S)e.demandOption(O,S[W]);if(x.boolean.includes(W))e.boolean(O);if(x.count.includes(W))e.count(O);if(x.string.includes(W))e.string(O);if(x.normalize.includes(W))e.normalize(O);if(x.array.includes(W))e.array(O);if(x.number.includes(W))e.number(O)})})}let C;i.cacheHelpMessage=function(){C=this.help()},i.clearCachedHelpMessage=function(){C=void 0},i.hasCachedHelpMessage=function(){return!!C};function A(S,x,O,W){let Z=[],re=null;return Object.keys(O).forEach((Q)=>{Z=Z.concat(O[Q])}),S.forEach((Q)=>{if(re=[Q].concat(x[Q]),!re.some((oe)=>Z.indexOf(oe)!==-1))O[W].push(Q)}),Z}function
|
|
18
|
+
`)}return J.toString().replace(/\s*$/,"")};function F(S,x,O){let W=0;if(!Array.isArray(S))S=Object.values(S).map((Z)=>[Z]);if(S.forEach((Z)=>{W=Math.max(t.stringWidth(O?`${O} ${An(Z[0])}`:An(Z[0]))+Zr(Z[0]),W)}),x)W=Math.min(W,parseInt((x*0.5).toString(),10));return W}function k(){let S=e.getDemandedOptions(),x=e.getOptions();(Object.keys(x.alias)||[]).forEach((O)=>{x.alias[O].forEach((W)=>{if(h[W])i.describe(O,h[W]);if(W in S)e.demandOption(O,S[W]);if(x.boolean.includes(W))e.boolean(O);if(x.count.includes(W))e.count(O);if(x.string.includes(W))e.string(O);if(x.normalize.includes(W))e.normalize(O);if(x.array.includes(W))e.array(O);if(x.number.includes(W))e.number(O)})})}let C;i.cacheHelpMessage=function(){C=this.help()},i.clearCachedHelpMessage=function(){C=void 0},i.hasCachedHelpMessage=function(){return!!C};function A(S,x,O,W){let Z=[],re=null;return Object.keys(O).forEach((Q)=>{Z=Z.concat(O[Q])}),S.forEach((Q)=>{if(re=[Q].concat(x[Q]),!re.some((oe)=>Z.indexOf(oe)!==-1))O[W].push(Q)}),Z}function P(S){return e.getOptions().hiddenOptions.indexOf(S)<0||e.parsed.argv[e.getOptions().showHiddenOpt]}i.showHelp=(S)=>{let x=e.getInternalMethods().getLoggerInstance();if(!S)S="error";(typeof S==="function"?S:x[S])(i.help())},i.functionDescription=(S)=>["(",S.name?t.Parser.decamelize(S.name,"-"):n("generated-value"),")"].join(""),i.stringifiedValues=function(x,O){let W="",Z=O||", ",re=[].concat(x);if(!x||!re.length)return W;return re.forEach((Q)=>{if(W.length)W+=Z;W+=JSON.stringify(Q)}),W};function v(S,x){let O=`[${n("default:")} `;if(S===void 0&&!x)return null;if(x)O+=x;else switch(typeof S){case"string":O+=`"${S}"`;break;case"object":O+=JSON.stringify(S);break;default:O+=S}return`${O}]`}function L(){if(t.process.stdColumns)return Math.min(80,t.process.stdColumns);else return 80}let R=null;i.version=(S)=>{R=S},i.showVersion=(S)=>{let x=e.getInternalMethods().getLoggerInstance();if(!S)S="error";(typeof S==="function"?S:x[S])(R)},i.reset=function(x){return r=null,c=!1,u=[],f=!1,m=[],l=[],d=[],h=st(h,(O)=>!x[O]),i};let G=[];return i.freeze=function(){G.push({failMessage:r,failureOutput:c,usages:u,usageDisabled:f,epilogs:m,examples:l,commands:d,descriptions:h})},i.unfreeze=function(x=!1){let O=G.pop();if(!O)return;if(x)h={...O.descriptions,...h},d=[...O.commands,...d],u=[...O.usages,...u],l=[...O.examples,...l],m=[...O.epilogs,...m];else({failMessage:r,failureOutput:c,usages:u,usageDisabled:f,epilogs:m,examples:l,commands:d,descriptions:h}=O)},i}function Bs(e){return typeof e==="object"}function Gu(e,t){return Bs(e)?{text:e.text,indentation:e.indentation+t}:{text:e,indentation:t}}function Zr(e){return Bs(e)?e.indentation:0}function An(e){return Bs(e)?e.text:e}var eo=`###-begin-{{app_name}}-completions-###
|
|
19
19
|
#
|
|
20
20
|
# yargs command completion script
|
|
21
21
|
#
|
|
@@ -71,18 +71,18 @@ else
|
|
|
71
71
|
compdef _{{app_name}}_yargs_completions {{app_name}}
|
|
72
72
|
fi
|
|
73
73
|
###-end-{{app_name}}-completions-###
|
|
74
|
-
`;class no{constructor(e,t,n,i){var s,r,o;this.yargs=e,this.usage=t,this.command=n,this.shim=i,this.completionKey="get-yargs-completions",this.aliases=null,this.customCompletionFunction=null,this.indexAfterLastReset=0,this.zshShell=(o=((s=this.shim.getEnv("SHELL"))===null||s===void 0?void 0:s.includes("zsh"))||((r=this.shim.getEnv("ZSH_NAME"))===null||r===void 0?void 0:r.includes("zsh")))!==null&&o!==void 0?o:!1}defaultCompletion(e,t,n,i){let s=this.command.getCommandHandlers();for(let o=0,a=e.length;o<a;++o)if(s[e[o]]&&s[e[o]].builder){let c=s[e[o]].builder;if(kn(c)){this.indexAfterLastReset=o+1;let u=this.yargs.getInternalMethods().reset();return c(u,!0),u.argv}}let r=[];this.commandCompletions(r,e,n),this.optionCompletions(r,e,t,n),this.choicesFromOptionsCompletions(r,e,t,n),this.choicesFromPositionalsCompletions(r,e,t,n),i(null,r)}commandCompletions(e,t,n){let i=this.yargs.getInternalMethods().getContext().commands;if(!n.match(/^-/)&&i[i.length-1]!==n&&!this.previousArgHasChoices(t))this.usage.getCommands().forEach((s)=>{let r=nt(s[0]).cmd;if(t.indexOf(r)===-1)if(!this.zshShell)e.push(r);else{let o=s[1]||"";e.push(r.replace(/:/g,"\\:")+":"+o)}})}optionCompletions(e,t,n,i){if((i.match(/^-/)||i===""&&e.length===0)&&!this.previousArgHasChoices(t)){let s=this.yargs.getOptions(),r=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[];Object.keys(s.key).forEach((o)=>{let a=!!s.configuration["boolean-negation"]&&s.boolean.includes(o);if(!r.includes(o)&&!s.hiddenOptions.includes(o)&&!this.argsContainKey(t,o,a))this.completeOptionKey(o,e,i,a&&!!s.default[o])})}}choicesFromOptionsCompletions(e,t,n,i){if(this.previousArgHasChoices(t)){let s=this.getPreviousArgChoices(t);if(s&&s.length>0)e.push(...s.map((r)=>r.replace(/:/g,"\\:")))}}choicesFromPositionalsCompletions(e,t,n,i){if(i===""&&e.length>0&&this.previousArgHasChoices(t))return;let s=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[],r=Math.max(this.indexAfterLastReset,this.yargs.getInternalMethods().getContext().commands.length+1),o=s[n._.length-r-1];if(!o)return;let a=this.yargs.getOptions().choices[o]||[];for(let c of a)if(c.startsWith(i))e.push(c.replace(/:/g,"\\:"))}getPreviousArgChoices(e){if(e.length<1)return;let t=e[e.length-1],n="";if(!t.startsWith("-")&&e.length>1)n=t,t=e[e.length-2];if(!t.startsWith("-"))return;let i=t.replace(/^-+/,""),s=this.yargs.getOptions(),r=[i,...this.yargs.getAliases()[i]||[]],o;for(let a of r)if(Object.prototype.hasOwnProperty.call(s.key,a)&&Array.isArray(s.choices[a])){o=s.choices[a];break}if(o)return o.filter((a)=>!n||a.startsWith(n))}previousArgHasChoices(e){let t=this.getPreviousArgChoices(e);return t!==void 0&&t.length>0}argsContainKey(e,t,n){let i=(s)=>e.indexOf((/^[^0-9]$/.test(s)?"-":"--")+s)!==-1;if(i(t))return!0;if(n&&i(`no-${t}`))return!0;if(this.aliases){for(let s of this.aliases[t])if(i(s))return!0}return!1}completeOptionKey(e,t,n,i){var s,r,o,a;let c=e;if(this.zshShell){let d=this.usage.getDescriptions(),h=(r=(s=this===null||this===void 0?void 0:this.aliases)===null||s===void 0?void 0:s[e])===null||r===void 0?void 0:r.find((y)=>{let E=d[y];return typeof E==="string"&&E.length>0}),m=h?d[h]:void 0,p=(a=(o=d[e])!==null&&o!==void 0?o:m)!==null&&a!==void 0?a:"";c=`${e.replace(/:/g,"\\:")}:${p.replace("__yargsString__:","").replace(/(\r\n|\n|\r)/gm," ")}`}let u=(d)=>/^--/.test(d),f=(d)=>/^[^0-9]$/.test(d),l=!u(n)&&f(e)?"-":"--";if(t.push(l+c),i)t.push(l+"no-"+c)}customCompletion(e,t,n,i){if(Fe(this.customCompletionFunction,null,this.shim),
|
|
74
|
+
`;class no{constructor(e,t,n,i){var s,r,o;this.yargs=e,this.usage=t,this.command=n,this.shim=i,this.completionKey="get-yargs-completions",this.aliases=null,this.customCompletionFunction=null,this.indexAfterLastReset=0,this.zshShell=(o=((s=this.shim.getEnv("SHELL"))===null||s===void 0?void 0:s.includes("zsh"))||((r=this.shim.getEnv("ZSH_NAME"))===null||r===void 0?void 0:r.includes("zsh")))!==null&&o!==void 0?o:!1}defaultCompletion(e,t,n,i){let s=this.command.getCommandHandlers();for(let o=0,a=e.length;o<a;++o)if(s[e[o]]&&s[e[o]].builder){let c=s[e[o]].builder;if(kn(c)){this.indexAfterLastReset=o+1;let u=this.yargs.getInternalMethods().reset();return c(u,!0),u.argv}}let r=[];this.commandCompletions(r,e,n),this.optionCompletions(r,e,t,n),this.choicesFromOptionsCompletions(r,e,t,n),this.choicesFromPositionalsCompletions(r,e,t,n),i(null,r)}commandCompletions(e,t,n){let i=this.yargs.getInternalMethods().getContext().commands;if(!n.match(/^-/)&&i[i.length-1]!==n&&!this.previousArgHasChoices(t))this.usage.getCommands().forEach((s)=>{let r=nt(s[0]).cmd;if(t.indexOf(r)===-1)if(!this.zshShell)e.push(r);else{let o=s[1]||"";e.push(r.replace(/:/g,"\\:")+":"+o)}})}optionCompletions(e,t,n,i){if((i.match(/^-/)||i===""&&e.length===0)&&!this.previousArgHasChoices(t)){let s=this.yargs.getOptions(),r=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[];Object.keys(s.key).forEach((o)=>{let a=!!s.configuration["boolean-negation"]&&s.boolean.includes(o);if(!r.includes(o)&&!s.hiddenOptions.includes(o)&&!this.argsContainKey(t,o,a))this.completeOptionKey(o,e,i,a&&!!s.default[o])})}}choicesFromOptionsCompletions(e,t,n,i){if(this.previousArgHasChoices(t)){let s=this.getPreviousArgChoices(t);if(s&&s.length>0)e.push(...s.map((r)=>r.replace(/:/g,"\\:")))}}choicesFromPositionalsCompletions(e,t,n,i){if(i===""&&e.length>0&&this.previousArgHasChoices(t))return;let s=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[],r=Math.max(this.indexAfterLastReset,this.yargs.getInternalMethods().getContext().commands.length+1),o=s[n._.length-r-1];if(!o)return;let a=this.yargs.getOptions().choices[o]||[];for(let c of a)if(c.startsWith(i))e.push(c.replace(/:/g,"\\:"))}getPreviousArgChoices(e){if(e.length<1)return;let t=e[e.length-1],n="";if(!t.startsWith("-")&&e.length>1)n=t,t=e[e.length-2];if(!t.startsWith("-"))return;let i=t.replace(/^-+/,""),s=this.yargs.getOptions(),r=[i,...this.yargs.getAliases()[i]||[]],o;for(let a of r)if(Object.prototype.hasOwnProperty.call(s.key,a)&&Array.isArray(s.choices[a])){o=s.choices[a];break}if(o)return o.filter((a)=>!n||a.startsWith(n))}previousArgHasChoices(e){let t=this.getPreviousArgChoices(e);return t!==void 0&&t.length>0}argsContainKey(e,t,n){let i=(s)=>e.indexOf((/^[^0-9]$/.test(s)?"-":"--")+s)!==-1;if(i(t))return!0;if(n&&i(`no-${t}`))return!0;if(this.aliases){for(let s of this.aliases[t])if(i(s))return!0}return!1}completeOptionKey(e,t,n,i){var s,r,o,a;let c=e;if(this.zshShell){let d=this.usage.getDescriptions(),h=(r=(s=this===null||this===void 0?void 0:this.aliases)===null||s===void 0?void 0:s[e])===null||r===void 0?void 0:r.find((y)=>{let E=d[y];return typeof E==="string"&&E.length>0}),m=h?d[h]:void 0,p=(a=(o=d[e])!==null&&o!==void 0?o:m)!==null&&a!==void 0?a:"";c=`${e.replace(/:/g,"\\:")}:${p.replace("__yargsString__:","").replace(/(\r\n|\n|\r)/gm," ")}`}let u=(d)=>/^--/.test(d),f=(d)=>/^[^0-9]$/.test(d),l=!u(n)&&f(e)?"-":"--";if(t.push(l+c),i)t.push(l+"no-"+c)}customCompletion(e,t,n,i){if(Fe(this.customCompletionFunction,null,this.shim),Zu(this.customCompletionFunction)){let s=this.customCompletionFunction(n,t);if(ne(s))return s.then((r)=>{this.shim.process.nextTick(()=>{i(null,r)})}).catch((r)=>{this.shim.process.nextTick(()=>{i(r,void 0)})});return i(null,s)}else if(Qu(this.customCompletionFunction))return this.customCompletionFunction(n,t,(s=i)=>this.defaultCompletion(e,t,n,s),(s)=>{i(null,s)});else return this.customCompletionFunction(n,t,(s)=>{i(null,s)})}getCompletion(e,t){let n=e.length?e[e.length-1]:"",i=this.yargs.parse(e,!0),s=this.customCompletionFunction?(r)=>this.customCompletion(e,r,n,t):(r)=>this.defaultCompletion(e,r,n,t);return ne(i)?i.then(s):s(i)}generateCompletionScript(e,t){let n=this.zshShell?to:eo,i=this.shim.path.basename(e);if(e.match(/\.js$/))e=`./${e}`;return n=n.replace(/{{app_name}}/g,i),n=n.replace(/{{completion_command}}/g,t),n.replace(/{{app_path}}/g,e)}registerFunction(e){this.customCompletionFunction=e}setParsed(e){this.aliases=e.aliases}}function so(e,t,n,i){return new no(e,t,n,i)}function Zu(e){return e.length<3}function Qu(e){return e.length>3}function io(e,t){if(e.length===0)return t.length;if(t.length===0)return e.length;let n=[],i;for(i=0;i<=t.length;i++)n[i]=[i];let s;for(s=0;s<=e.length;s++)n[0][s]=s;for(i=1;i<=t.length;i++)for(s=1;s<=e.length;s++)if(t.charAt(i-1)===e.charAt(s-1))n[i][s]=n[i-1][s-1];else if(i>1&&s>1&&t.charAt(i-2)===e.charAt(s-1)&&t.charAt(i-1)===e.charAt(s-2))n[i][s]=n[i-2][s-2]+1;else n[i][s]=Math.min(n[i-1][s-1]+1,Math.min(n[i][s-1]+1,n[i-1][s]+1));return n[t.length][e.length]}var ro=["$0","--","_"];function oo(e,t,n){let i=n.y18n.__,s=n.y18n.__n,r={};r.nonOptionCount=function(l){let d=e.getDemandedCommands(),m=l._.length+(l["--"]?l["--"].length:0)-e.getInternalMethods().getContext().commands.length;if(d._&&(m<d._.min||m>d._.max)){if(m<d._.min)if(d._.minMsg!==void 0)t.fail(d._.minMsg?d._.minMsg.replace(/\$0/g,m.toString()).replace(/\$1/,d._.min.toString()):null);else t.fail(s("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",m,m.toString(),d._.min.toString()));else if(m>d._.max)if(d._.maxMsg!==void 0)t.fail(d._.maxMsg?d._.maxMsg.replace(/\$0/g,m.toString()).replace(/\$1/,d._.max.toString()):null);else t.fail(s("Too many non-option arguments: got %s, maximum of %s","Too many non-option arguments: got %s, maximum of %s",m,m.toString(),d._.max.toString()))}},r.positionalCount=function(l,d){if(d<l)t.fail(s("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",d,d+"",l+""))},r.requiredArguments=function(l,d){let h=null;for(let m of Object.keys(d))if(!Object.prototype.hasOwnProperty.call(l,m)||typeof l[m]>"u")h=h||{},h[m]=d[m];if(h){let m=[];for(let y of Object.keys(h)){let E=h[y];if(E&&m.indexOf(E)<0)m.push(E)}let p=m.length?`
|
|
75
75
|
${m.join(`
|
|
76
|
-
`)}`:"";t.fail(s("Missing required argument: %s","Missing required arguments: %s",Object.keys(h).length,Object.keys(h).join(", ")+p))}},r.unknownArguments=function(l,d,h,m,p=!0){var y;let E=e.getInternalMethods().getCommandInstance().getCommands(),F=[],k=e.getInternalMethods().getContext();if(Object.keys(l).forEach((C)=>{if(!ro.includes(C)&&!Object.prototype.hasOwnProperty.call(h,C)&&!Object.prototype.hasOwnProperty.call(e.getInternalMethods().getParseContext(),C)&&!r.isValidAndSomeAliasIsNotNew(C,d))F.push(C)}),p&&(k.commands.length>0||E.length>0||m))l._.slice(k.commands.length).forEach((C)=>{if(!E.includes(""+C))F.push(""+C)});if(p){let A=((y=e.getDemandedCommands()._)===null||y===void 0?void 0:y.max)||0,
|
|
76
|
+
`)}`:"";t.fail(s("Missing required argument: %s","Missing required arguments: %s",Object.keys(h).length,Object.keys(h).join(", ")+p))}},r.unknownArguments=function(l,d,h,m,p=!0){var y;let E=e.getInternalMethods().getCommandInstance().getCommands(),F=[],k=e.getInternalMethods().getContext();if(Object.keys(l).forEach((C)=>{if(!ro.includes(C)&&!Object.prototype.hasOwnProperty.call(h,C)&&!Object.prototype.hasOwnProperty.call(e.getInternalMethods().getParseContext(),C)&&!r.isValidAndSomeAliasIsNotNew(C,d))F.push(C)}),p&&(k.commands.length>0||E.length>0||m))l._.slice(k.commands.length).forEach((C)=>{if(!E.includes(""+C))F.push(""+C)});if(p){let A=((y=e.getDemandedCommands()._)===null||y===void 0?void 0:y.max)||0,P=k.commands.length+A;if(P<l._.length)l._.slice(P).forEach((v)=>{if(v=String(v),!k.commands.includes(v)&&!F.includes(v))F.push(v)})}if(F.length)t.fail(s("Unknown argument: %s","Unknown arguments: %s",F.length,F.map((C)=>C.trim()?C:`"${C}"`).join(", ")))},r.unknownCommands=function(l){let d=e.getInternalMethods().getCommandInstance().getCommands(),h=[],m=e.getInternalMethods().getContext();if(m.commands.length>0||d.length>0)l._.slice(m.commands.length).forEach((p)=>{if(!d.includes(""+p))h.push(""+p)});if(h.length>0)return t.fail(s("Unknown command: %s","Unknown commands: %s",h.length,h.join(", "))),!0;else return!1},r.isValidAndSomeAliasIsNotNew=function(l,d){if(!Object.prototype.hasOwnProperty.call(d,l))return!1;let h=e.parsed.newAliases;return[l,...d[l]].some((m)=>!Object.prototype.hasOwnProperty.call(h,m)||!h[l])},r.limitedChoices=function(l){let d=e.getOptions(),h={};if(!Object.keys(d.choices).length)return;Object.keys(l).forEach((y)=>{if(ro.indexOf(y)===-1&&Object.prototype.hasOwnProperty.call(d.choices,y))[].concat(l[y]).forEach((E)=>{if(d.choices[y].indexOf(E)===-1&&E!==void 0)h[y]=(h[y]||[]).concat(E)})});let m=Object.keys(h);if(!m.length)return;let p=i("Invalid values:");m.forEach((y)=>{p+=`
|
|
77
77
|
${i("Argument: %s, Given: %s, Choices: %s",y,t.stringifiedValues(h[y]),t.stringifiedValues(d.choices[y]))}`}),t.fail(p)};let o={};r.implies=function(l,d){if(B("<string|object> [array|number|string]",[l,d],arguments.length),typeof l==="object")Object.keys(l).forEach((h)=>{r.implies(h,l[h])});else{if(e.global(l),!o[l])o[l]=[];if(Array.isArray(d))d.forEach((h)=>r.implies(l,h));else Fe(d,void 0,n),o[l].push(d)}},r.getImplied=function(){return o};function a(f,l){let d=Number(l);if(l=isNaN(d)?l:d,typeof l==="number")l=f._.length>=l;else if(l.match(/^--no-.+/))l=l.match(/^--no-(.+)/)[1],l=!Object.prototype.hasOwnProperty.call(f,l);else l=Object.prototype.hasOwnProperty.call(f,l);return l}r.implications=function(l){let d=[];if(Object.keys(o).forEach((h)=>{let m=h;(o[h]||[]).forEach((p)=>{let y=m,E=p;if(y=a(l,y),p=a(l,p),y&&!p)d.push(` ${m} -> ${E}`)})}),d.length){let h=`${i("Implications failed:")}
|
|
78
|
-
`;d.forEach((m)=>{h+=m}),t.fail(h)}};let c={};r.conflicts=function(l,d){if(B("<string|object> [array|string]",[l,d],arguments.length),typeof l==="object")Object.keys(l).forEach((h)=>{r.conflicts(h,l[h])});else{if(e.global(l),!c[l])c[l]=[];if(Array.isArray(d))d.forEach((h)=>r.conflicts(l,h));else c[l].push(d)}},r.getConflicting=()=>c,r.conflicting=function(l){if(Object.keys(l).forEach((d)=>{if(c[d])c[d].forEach((h)=>{if(h&&l[d]!==void 0&&l[h]!==void 0)t.fail(i("Arguments %s and %s are mutually exclusive",d,h))})}),e.getInternalMethods().getParserConfiguration()["strip-dashed"])Object.keys(c).forEach((d)=>{c[d].forEach((h)=>{if(h&&l[n.Parser.camelCase(d)]!==void 0&&l[n.Parser.camelCase(h)]!==void 0)t.fail(i("Arguments %s and %s are mutually exclusive",d,h))})})},r.recommendCommands=function(l,d){d=d.sort((y,E)=>E.length-y.length);let m=null,p=1/0;for(let y=0,E;(E=d[y])!==void 0;y++){let F=io(l,E);if(F<=3&&F<p)p=F,m=E}if(m)t.fail(i("Did you mean %s?",m))},r.reset=function(l){return o=st(o,(d)=>!l[d]),c=st(c,(d)=>!l[d]),r};let u=[];return r.freeze=function(){u.push({implied:o,conflicting:c})},r.unfreeze=function(){let l=u.pop();Fe(l,void 0,n),{implied:o,conflicting:c}=l},r}var Ns=[],Qt;function en(e,t,n,i){Qt=i;let s={};if(Object.prototype.hasOwnProperty.call(e,"extends")){if(typeof e.extends!=="string")return s;let r=/\.json|\..*rc$/.test(e.extends),o=null;if(!r)try{o=import.meta.resolve(e.extends)}catch(a){return e}else o=el(t,e.extends);Qu(o),Ns.push(o),s=r?JSON.parse(Qt.readFileSync(o,"utf8")):i.require(e.extends),delete e.extends,s=en(s,Qt.path.dirname(o),n,Qt)}return Ns=[],n?ao(s,e):Object.assign({},s,e)}function Qu(e){if(Ns.indexOf(e)>-1)throw new le(`Circular extended configurations: '${e}'.`)}function el(e,t){return Qt.path.resolve(e,t)}function ao(e,t){let n={};function i(s){return s&&typeof s==="object"&&!Array.isArray(s)}Object.assign(n,e);for(let s of Object.keys(t))if(i(t[s])&&i(n[s]))n[s]=ao(e[s],t[s]);else n[s]=t[s];return n}var N=function(e,t,n,i,s){if(i==="m")throw TypeError("Private method is not writable");if(i==="a"&&!s)throw TypeError("Private accessor was defined without a setter");if(typeof t==="function"?e!==t||!s:!t.has(e))throw TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(e,n):s?s.value=n:t.set(e,n),n},g=function(e,t,n,i){if(n==="a"&&!i)throw TypeError("Private accessor was defined without a getter");if(typeof t==="function"?e!==t||!i:!t.has(e))throw TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?i:n==="a"?i.call(e):i?i.value:t.get(e)},fe,mt,tn,Ee,_e,$n,rt,Dt,On,Pe,In,Te,Ye,Se,Re,Pn,yt,me,U,Tn,Rn,ke,wt,Wt,bt,ot,Mn,q,Ft,Ct,Et,Y,Bn,Xe,ce;function Ao(e){return(t=[],n=e.process.cwd(),i)=>{let s=new $o(t,n,i,e);return Object.defineProperty(s,"argv",{get:()=>s.parse(),enumerable:!0}),s.help(),s.version(),s}}var co=Symbol("copyDoubleDash"),uo=Symbol("copyDoubleDash"),vs=Symbol("deleteFromParserHintObject"),lo=Symbol("emitWarning"),fo=Symbol("freeze"),po=Symbol("getDollarZero"),xt=Symbol("getParserConfiguration"),ho=Symbol("getUsageConfiguration"),js=Symbol("guessLocale"),go=Symbol("guessVersion"),mo=Symbol("parsePositionalNumbers"),Ls=Symbol("pkgUp"),at=Symbol("populateParserHintArray"),Ut=Symbol("populateParserHintSingleValueDictionary"),Ws=Symbol("populateParserHintArrayDictionary"),Us=Symbol("populateParserHintDictionary"),Js=Symbol("sanitizeKey"),Ks=Symbol("setKey"),zs=Symbol("unfreeze"),Do=Symbol("validateAsync"),yo=Symbol("getCommandInstance"),wo=Symbol("getContext"),bo=Symbol("getHasOutput"),Fo=Symbol("getLoggerInstance"),Co=Symbol("getParseContext"),Eo=Symbol("getUsageInstance"),xo=Symbol("getValidationInstance"),Nn=Symbol("hasParseCallback"),_o=Symbol("isGlobalContext"),_t=Symbol("postProcess"),So=Symbol("rebase"),Hs=Symbol("reset"),nn=Symbol("runYargsParserAndExecuteCommands"),qs=Symbol("runValidation"),ko=Symbol("setHasOutput"),St=Symbol("kTrackManuallySetKeys"),tl="en_US";class $o{constructor(e=[],t,n,i){this.customScriptName=!1,this.parsed=!1,fe.set(this,void 0),mt.set(this,void 0),tn.set(this,{commands:[],fullCommands:[]}),Ee.set(this,null),_e.set(this,null),$n.set(this,"show-hidden"),rt.set(this,null),Dt.set(this,!0),On.set(this,{}),Pe.set(this,!0),In.set(this,[]),Te.set(this,void 0),Ye.set(this,{}),Se.set(this,!1),Re.set(this,null),Pn.set(this,!0),yt.set(this,void 0),me.set(this,""),U.set(this,void 0),Tn.set(this,void 0),Rn.set(this,{}),ke.set(this,null),wt.set(this,null),Wt.set(this,{}),bt.set(this,{}),ot.set(this,void 0),Mn.set(this,!1),q.set(this,void 0),Ft.set(this,!1),Ct.set(this,!1),Et.set(this,!1),Y.set(this,void 0),Bn.set(this,{}),Xe.set(this,null),ce.set(this,void 0),N(this,q,i,"f"),N(this,ot,e,"f"),N(this,mt,t,"f"),N(this,Tn,n,"f"),N(this,Te,new Ms(this),"f"),this.$0=this[po](),this[Hs](),N(this,fe,g(this,fe,"f"),"f"),N(this,Y,g(this,Y,"f"),"f"),N(this,ce,g(this,ce,"f"),"f"),N(this,U,g(this,U,"f"),"f"),g(this,U,"f").showHiddenOpt=g(this,$n,"f"),N(this,yt,this[uo](),"f"),g(this,q,"f").y18n.setLocale(tl)}addHelpOpt(e,t){if(B("[string|boolean] [string]",[e,t],arguments.length),g(this,Re,"f"))this[vs](g(this,Re,"f")),N(this,Re,null,"f");if(e===!1&&t===void 0)return this;return N(this,Re,typeof e==="string"?e:"help","f"),this.boolean(g(this,Re,"f")),this.describe(g(this,Re,"f"),t||g(this,Y,"f").deferY18nLookup("Show help")),this}help(e,t){return this.addHelpOpt(e,t)}addShowHiddenOpt(e,t){if(B("[string|boolean] [string]",[e,t],arguments.length),e===!1&&t===void 0)return this;let n=typeof e==="string"?e:g(this,$n,"f");return this.boolean(n),this.describe(n,t||g(this,Y,"f").deferY18nLookup("Show hidden options")),g(this,U,"f").showHiddenOpt=n,this}showHidden(e,t){return this.addShowHiddenOpt(e,t)}alias(e,t){return B("<object|string|array> [string|array]",[e,t],arguments.length),this[Ws](this.alias.bind(this),"alias",e,t),this}array(e){return B("<array|string>",[e],arguments.length),this[at]("array",e),this[St](e),this}boolean(e){return B("<array|string>",[e],arguments.length),this[at]("boolean",e),this[St](e),this}check(e,t){return B("<function> [boolean]",[e,t],arguments.length),this.middleware((n,i)=>gt(()=>e(n,i.getOptions()),(s)=>{if(!s)g(this,Y,"f").fail(g(this,q,"f").y18n.__("Argument check failed: %s",e.toString()));else if(typeof s==="string"||s instanceof Error)g(this,Y,"f").fail(s.toString(),s);return n},(s)=>(g(this,Y,"f").fail(s.message?s.message:s.toString(),s),n)),!1,t),this}choices(e,t){return B("<object|string|array> [string|array]",[e,t],arguments.length),this[Ws](this.choices.bind(this),"choices",e,t),this}coerce(e,t){if(B("<object|string|array> [function]",[e,t],arguments.length),Array.isArray(e)){if(!t)throw new le("coerce callback must be provided");for(let i of e)this.coerce(i,t);return this}else if(typeof e==="object"){for(let i of Object.keys(e))this.coerce(i,e[i]);return this}if(!t)throw new le("coerce callback must be provided");let n=e;return g(this,U,"f").key[n]=!0,g(this,Te,"f").addCoerceMiddleware((i,s)=>{var r;let o=(r=s.getAliases()[n])!==null&&r!==void 0?r:[],a=[n,...o].filter((c)=>Object.prototype.hasOwnProperty.call(i,c));if(a.length===0)return i;return gt(()=>t(i[a[0]]),(c)=>(a.forEach((u)=>{i[u]=c}),i),(c)=>{throw new le(c.message)})},n),this}conflicts(e,t){return B("<string|object> [string|array]",[e,t],arguments.length),g(this,ce,"f").conflicts(e,t),this}config(e="config",t,n){if(B("[object|string] [string|function] [function]",[e,t,n],arguments.length),typeof e==="object"&&!Array.isArray(e))return e=en(e,g(this,mt,"f"),this[xt]()["deep-merge-config"]||!1,g(this,q,"f")),g(this,U,"f").configObjects=(g(this,U,"f").configObjects||[]).concat(e),this;if(typeof t==="function")n=t,t=void 0;return this.describe(e,t||g(this,Y,"f").deferY18nLookup("Path to JSON config file")),(Array.isArray(e)?e:[e]).forEach((i)=>{g(this,U,"f").config[i]=n||!0}),this}completion(e,t,n){if(B("[string] [string|boolean|function] [function]",[e,t,n],arguments.length),typeof t==="function")n=t,t=void 0;if(N(this,_e,e||g(this,_e,"f")||"completion","f"),!t&&t!==!1)t="generate completion script";if(this.command(g(this,_e,"f"),t),n)g(this,Ee,"f").registerFunction(n);return this}command(e,t,n,i,s,r){return B("<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]",[e,t,n,i,s,r],arguments.length),g(this,fe,"f").addHandler(e,t,n,i,s,r),this}commands(e,t,n,i,s,r){return this.command(e,t,n,i,s,r)}commandDir(e,t){B("<string> [object]",[e,t],arguments.length);let n=g(this,Tn,"f")||g(this,q,"f").require;return g(this,fe,"f").addDirectory(e,n,g(this,q,"f").getCallerFile(),t),this}count(e){return B("<array|string>",[e],arguments.length),this[at]("count",e),this[St](e),this}default(e,t,n){if(B("<object|string|array> [*] [string]",[e,t,n],arguments.length),n)Rs(e,g(this,q,"f")),g(this,U,"f").defaultDescription[e]=n;if(typeof t==="function"){if(Rs(e,g(this,q,"f")),!g(this,U,"f").defaultDescription[e])g(this,U,"f").defaultDescription[e]=g(this,Y,"f").functionDescription(t);t=t.call()}return this[Ut](this.default.bind(this),"default",e,t),this}defaults(e,t,n){return this.default(e,t,n)}demandCommand(e=1,t,n,i){if(B("[number] [number|string] [string|null|undefined] [string|null|undefined]",[e,t,n,i],arguments.length),typeof t!=="number")n=t,t=1/0;return this.global("_",!1),g(this,U,"f").demandedCommands._={min:e,max:t,minMsg:n,maxMsg:i},this}demand(e,t,n){if(Array.isArray(t))t.forEach((i)=>{Fe(n,!0,g(this,q,"f")),this.demandOption(i,n)}),t=1/0;else if(typeof t!=="number")n=t,t=1/0;if(typeof e==="number")Fe(n,!0,g(this,q,"f")),this.demandCommand(e,t,n,n);else if(Array.isArray(e))e.forEach((i)=>{Fe(n,!0,g(this,q,"f")),this.demandOption(i,n)});else if(typeof n==="string")this.demandOption(e,n);else if(n===!0||typeof n>"u")this.demandOption(e);return this}demandOption(e,t){return B("<object|string|array> [string]",[e,t],arguments.length),this[Ut](this.demandOption.bind(this),"demandedOptions",e,t),this}deprecateOption(e,t){return B("<string> [string|boolean]",[e,t],arguments.length),g(this,U,"f").deprecatedOptions[e]=t,this}describe(e,t){return B("<object|string|array> [string]",[e,t],arguments.length),this[Ks](e,!0),g(this,Y,"f").describe(e,t),this}detectLocale(e){return B("<boolean>",[e],arguments.length),N(this,Dt,e,"f"),this}env(e){if(B("[string|boolean]",[e],arguments.length),e===!1)delete g(this,U,"f").envPrefix;else g(this,U,"f").envPrefix=e||"";return this}epilogue(e){return B("<string>",[e],arguments.length),g(this,Y,"f").epilog(e),this}epilog(e){return this.epilogue(e)}example(e,t){if(B("<string|array> [string]",[e,t],arguments.length),Array.isArray(e))e.forEach((n)=>this.example(...n));else g(this,Y,"f").example(e,t);return this}exit(e,t){if(N(this,Se,!0,"f"),N(this,rt,t,"f"),g(this,Pe,"f"))g(this,q,"f").process.exit(e)}exitProcess(e=!0){return B("[boolean]",[e],arguments.length),N(this,Pe,e,"f"),this}fail(e){if(B("<function|boolean>",[e],arguments.length),typeof e==="boolean"&&e!==!1)throw new le("Invalid first argument. Expected function or boolean 'false'");return g(this,Y,"f").failFn(e),this}getAliases(){return this.parsed?this.parsed.aliases:{}}async getCompletion(e,t){if(B("<array> [function]",[e,t],arguments.length),!t)return new Promise((n,i)=>{g(this,Ee,"f").getCompletion(e,(s,r)=>{if(s)i(s);else n(r)})});else return g(this,Ee,"f").getCompletion(e,t)}getDemandedOptions(){return B([],0),g(this,U,"f").demandedOptions}getDemandedCommands(){return B([],0),g(this,U,"f").demandedCommands}getDeprecatedOptions(){return B([],0),g(this,U,"f").deprecatedOptions}getDetectLocale(){return g(this,Dt,"f")}getExitProcess(){return g(this,Pe,"f")}getGroups(){return Object.assign({},g(this,Ye,"f"),g(this,bt,"f"))}getHelp(){if(N(this,Se,!0,"f"),!g(this,Y,"f").hasCachedHelpMessage()){if(!this.parsed){let t=this[nn](g(this,ot,"f"),void 0,void 0,0,!0);if(ne(t))return t.then(()=>g(this,Y,"f").help())}let e=g(this,fe,"f").runDefaultBuilderOn(this);if(ne(e))return e.then(()=>g(this,Y,"f").help())}return Promise.resolve(g(this,Y,"f").help())}getOptions(){return g(this,U,"f")}getStrict(){return g(this,Ft,"f")}getStrictCommands(){return g(this,Ct,"f")}getStrictOptions(){return g(this,Et,"f")}global(e,t){if(B("<string|array> [boolean]",[e,t],arguments.length),e=[].concat(e),t!==!1)g(this,U,"f").local=g(this,U,"f").local.filter((n)=>e.indexOf(n)===-1);else e.forEach((n)=>{if(!g(this,U,"f").local.includes(n))g(this,U,"f").local.push(n)});return this}group(e,t){B("<string|array> <string>",[e,t],arguments.length);let n=g(this,bt,"f")[t]||g(this,Ye,"f")[t];if(g(this,bt,"f")[t])delete g(this,bt,"f")[t];let i={};return g(this,Ye,"f")[t]=(n||[]).concat(e).filter((s)=>{if(i[s])return!1;return i[s]=!0}),this}hide(e){return B("<string>",[e],arguments.length),g(this,U,"f").hiddenOptions.push(e),this}implies(e,t){return B("<string|object> [number|string|array]",[e,t],arguments.length),g(this,ce,"f").implies(e,t),this}locale(e){if(B("[string]",[e],arguments.length),e===void 0)return this[js](),g(this,q,"f").y18n.getLocale();return N(this,Dt,!1,"f"),g(this,q,"f").y18n.setLocale(e),this}middleware(e,t,n){return g(this,Te,"f").addMiddleware(e,!!t,n)}nargs(e,t){return B("<string|object|array> [number]",[e,t],arguments.length),this[Ut](this.nargs.bind(this),"narg",e,t),this}normalize(e){return B("<array|string>",[e],arguments.length),this[at]("normalize",e),this}number(e){return B("<array|string>",[e],arguments.length),this[at]("number",e),this[St](e),this}option(e,t){if(B("<string|object> [object]",[e,t],arguments.length),typeof e==="object")Object.keys(e).forEach((n)=>{this.options(n,e[n])});else{if(typeof t!=="object")t={};if(this[St](e),g(this,Xe,"f")&&(e==="version"||(t===null||t===void 0?void 0:t.alias)==="version"))this[lo](['"version" is a reserved word.',"Please do one of the following:",'- Disable version with `yargs.version(false)` if using "version" as an option',"- Use the built-in `yargs.version` method instead (if applicable)","- Use a different option key","https://yargs.js.org/docs/#api-reference-version"].join(`
|
|
79
|
-
`),void 0,"versionWarning");if(g(this,U,"f").key[e]=!0,t.alias)this.alias(e,t.alias);let n=t.deprecate||t.deprecated;if(n)this.deprecateOption(e,n);let i=t.demand||t.required||t.require;if(i)this.demand(e,i);if(t.demandOption)this.demandOption(e,typeof t.demandOption==="string"?t.demandOption:void 0);if(t.conflicts)this.conflicts(e,t.conflicts);if("default"in t)this.default(e,t.default);if(t.implies!==void 0)this.implies(e,t.implies);if(t.nargs!==void 0)this.nargs(e,t.nargs);if(t.config)this.config(e,t.configParser);if(t.normalize)this.normalize(e);if(t.choices)this.choices(e,t.choices);if(t.coerce)this.coerce(e,t.coerce);if(t.group)this.group(e,t.group);if(t.boolean||t.type==="boolean"){if(this.boolean(e),t.alias)this.boolean(t.alias)}if(t.array||t.type==="array"){if(this.array(e),t.alias)this.array(t.alias)}if(t.number||t.type==="number"){if(this.number(e),t.alias)this.number(t.alias)}if(t.string||t.type==="string"){if(this.string(e),t.alias)this.string(t.alias)}if(t.count||t.type==="count")this.count(e);if(typeof t.global==="boolean")this.global(e,t.global);if(t.defaultDescription)g(this,U,"f").defaultDescription[e]=t.defaultDescription;if(t.skipValidation)this.skipValidation(e);let s=t.describe||t.description||t.desc,r=g(this,Y,"f").getDescriptions();if(!Object.prototype.hasOwnProperty.call(r,e)||typeof s==="string")this.describe(e,s);if(t.hidden)this.hide(e);if(t.requiresArg)this.requiresArg(e)}return this}options(e,t){return this.option(e,t)}parse(e,t,n){if(B("[string|array] [function|boolean|object] [function]",[e,t,n],arguments.length),this[fo](),typeof e>"u")e=g(this,ot,"f");if(typeof t==="object")N(this,wt,t,"f"),t=n;if(typeof t==="function")N(this,ke,t,"f"),t=!1;if(!t)N(this,ot,e,"f");if(g(this,ke,"f"))N(this,
|
|
78
|
+
`;d.forEach((m)=>{h+=m}),t.fail(h)}};let c={};r.conflicts=function(l,d){if(B("<string|object> [array|string]",[l,d],arguments.length),typeof l==="object")Object.keys(l).forEach((h)=>{r.conflicts(h,l[h])});else{if(e.global(l),!c[l])c[l]=[];if(Array.isArray(d))d.forEach((h)=>r.conflicts(l,h));else c[l].push(d)}},r.getConflicting=()=>c,r.conflicting=function(l){if(Object.keys(l).forEach((d)=>{if(c[d])c[d].forEach((h)=>{if(h&&l[d]!==void 0&&l[h]!==void 0)t.fail(i("Arguments %s and %s are mutually exclusive",d,h))})}),e.getInternalMethods().getParserConfiguration()["strip-dashed"])Object.keys(c).forEach((d)=>{c[d].forEach((h)=>{if(h&&l[n.Parser.camelCase(d)]!==void 0&&l[n.Parser.camelCase(h)]!==void 0)t.fail(i("Arguments %s and %s are mutually exclusive",d,h))})})},r.recommendCommands=function(l,d){d=d.sort((y,E)=>E.length-y.length);let m=null,p=1/0;for(let y=0,E;(E=d[y])!==void 0;y++){let F=io(l,E);if(F<=3&&F<p)p=F,m=E}if(m)t.fail(i("Did you mean %s?",m))},r.reset=function(l){return o=st(o,(d)=>!l[d]),c=st(c,(d)=>!l[d]),r};let u=[];return r.freeze=function(){u.push({implied:o,conflicting:c})},r.unfreeze=function(){let l=u.pop();Fe(l,void 0,n),{implied:o,conflicting:c}=l},r}var Ns=[],Qt;function en(e,t,n,i){Qt=i;let s={};if(Object.prototype.hasOwnProperty.call(e,"extends")){if(typeof e.extends!=="string")return s;let r=/\.json|\..*rc$/.test(e.extends),o=null;if(!r)try{o=import.meta.resolve(e.extends)}catch(a){return e}else o=tl(t,e.extends);el(o),Ns.push(o),s=r?JSON.parse(Qt.readFileSync(o,"utf8")):i.require(e.extends),delete e.extends,s=en(s,Qt.path.dirname(o),n,Qt)}return Ns=[],n?ao(s,e):Object.assign({},s,e)}function el(e){if(Ns.indexOf(e)>-1)throw new le(`Circular extended configurations: '${e}'.`)}function tl(e,t){return Qt.path.resolve(e,t)}function ao(e,t){let n={};function i(s){return s&&typeof s==="object"&&!Array.isArray(s)}Object.assign(n,e);for(let s of Object.keys(t))if(i(t[s])&&i(n[s]))n[s]=ao(e[s],t[s]);else n[s]=t[s];return n}var N=function(e,t,n,i,s){if(i==="m")throw TypeError("Private method is not writable");if(i==="a"&&!s)throw TypeError("Private accessor was defined without a setter");if(typeof t==="function"?e!==t||!s:!t.has(e))throw TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(e,n):s?s.value=n:t.set(e,n),n},g=function(e,t,n,i){if(n==="a"&&!i)throw TypeError("Private accessor was defined without a getter");if(typeof t==="function"?e!==t||!i:!t.has(e))throw TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?i:n==="a"?i.call(e):i?i.value:t.get(e)},fe,mt,tn,Ee,_e,$n,rt,Dt,On,Te,In,Pe,Ye,Se,Re,Tn,yt,me,U,Pn,Rn,ke,wt,Wt,bt,ot,Mn,q,Ft,Ct,Et,Y,Bn,Xe,ce;function Ao(e){return(t=[],n=e.process.cwd(),i)=>{let s=new $o(t,n,i,e);return Object.defineProperty(s,"argv",{get:()=>s.parse(),enumerable:!0}),s.help(),s.version(),s}}var co=Symbol("copyDoubleDash"),uo=Symbol("copyDoubleDash"),vs=Symbol("deleteFromParserHintObject"),lo=Symbol("emitWarning"),fo=Symbol("freeze"),po=Symbol("getDollarZero"),xt=Symbol("getParserConfiguration"),ho=Symbol("getUsageConfiguration"),js=Symbol("guessLocale"),go=Symbol("guessVersion"),mo=Symbol("parsePositionalNumbers"),Ls=Symbol("pkgUp"),at=Symbol("populateParserHintArray"),Ut=Symbol("populateParserHintSingleValueDictionary"),Ws=Symbol("populateParserHintArrayDictionary"),Us=Symbol("populateParserHintDictionary"),Js=Symbol("sanitizeKey"),Ks=Symbol("setKey"),zs=Symbol("unfreeze"),Do=Symbol("validateAsync"),yo=Symbol("getCommandInstance"),wo=Symbol("getContext"),bo=Symbol("getHasOutput"),Fo=Symbol("getLoggerInstance"),Co=Symbol("getParseContext"),Eo=Symbol("getUsageInstance"),xo=Symbol("getValidationInstance"),Nn=Symbol("hasParseCallback"),_o=Symbol("isGlobalContext"),_t=Symbol("postProcess"),So=Symbol("rebase"),Hs=Symbol("reset"),nn=Symbol("runYargsParserAndExecuteCommands"),qs=Symbol("runValidation"),ko=Symbol("setHasOutput"),St=Symbol("kTrackManuallySetKeys"),nl="en_US";class $o{constructor(e=[],t,n,i){this.customScriptName=!1,this.parsed=!1,fe.set(this,void 0),mt.set(this,void 0),tn.set(this,{commands:[],fullCommands:[]}),Ee.set(this,null),_e.set(this,null),$n.set(this,"show-hidden"),rt.set(this,null),Dt.set(this,!0),On.set(this,{}),Te.set(this,!0),In.set(this,[]),Pe.set(this,void 0),Ye.set(this,{}),Se.set(this,!1),Re.set(this,null),Tn.set(this,!0),yt.set(this,void 0),me.set(this,""),U.set(this,void 0),Pn.set(this,void 0),Rn.set(this,{}),ke.set(this,null),wt.set(this,null),Wt.set(this,{}),bt.set(this,{}),ot.set(this,void 0),Mn.set(this,!1),q.set(this,void 0),Ft.set(this,!1),Ct.set(this,!1),Et.set(this,!1),Y.set(this,void 0),Bn.set(this,{}),Xe.set(this,null),ce.set(this,void 0),N(this,q,i,"f"),N(this,ot,e,"f"),N(this,mt,t,"f"),N(this,Pn,n,"f"),N(this,Pe,new Ms(this),"f"),this.$0=this[po](),this[Hs](),N(this,fe,g(this,fe,"f"),"f"),N(this,Y,g(this,Y,"f"),"f"),N(this,ce,g(this,ce,"f"),"f"),N(this,U,g(this,U,"f"),"f"),g(this,U,"f").showHiddenOpt=g(this,$n,"f"),N(this,yt,this[uo](),"f"),g(this,q,"f").y18n.setLocale(nl)}addHelpOpt(e,t){if(B("[string|boolean] [string]",[e,t],arguments.length),g(this,Re,"f"))this[vs](g(this,Re,"f")),N(this,Re,null,"f");if(e===!1&&t===void 0)return this;return N(this,Re,typeof e==="string"?e:"help","f"),this.boolean(g(this,Re,"f")),this.describe(g(this,Re,"f"),t||g(this,Y,"f").deferY18nLookup("Show help")),this}help(e,t){return this.addHelpOpt(e,t)}addShowHiddenOpt(e,t){if(B("[string|boolean] [string]",[e,t],arguments.length),e===!1&&t===void 0)return this;let n=typeof e==="string"?e:g(this,$n,"f");return this.boolean(n),this.describe(n,t||g(this,Y,"f").deferY18nLookup("Show hidden options")),g(this,U,"f").showHiddenOpt=n,this}showHidden(e,t){return this.addShowHiddenOpt(e,t)}alias(e,t){return B("<object|string|array> [string|array]",[e,t],arguments.length),this[Ws](this.alias.bind(this),"alias",e,t),this}array(e){return B("<array|string>",[e],arguments.length),this[at]("array",e),this[St](e),this}boolean(e){return B("<array|string>",[e],arguments.length),this[at]("boolean",e),this[St](e),this}check(e,t){return B("<function> [boolean]",[e,t],arguments.length),this.middleware((n,i)=>gt(()=>e(n,i.getOptions()),(s)=>{if(!s)g(this,Y,"f").fail(g(this,q,"f").y18n.__("Argument check failed: %s",e.toString()));else if(typeof s==="string"||s instanceof Error)g(this,Y,"f").fail(s.toString(),s);return n},(s)=>(g(this,Y,"f").fail(s.message?s.message:s.toString(),s),n)),!1,t),this}choices(e,t){return B("<object|string|array> [string|array]",[e,t],arguments.length),this[Ws](this.choices.bind(this),"choices",e,t),this}coerce(e,t){if(B("<object|string|array> [function]",[e,t],arguments.length),Array.isArray(e)){if(!t)throw new le("coerce callback must be provided");for(let i of e)this.coerce(i,t);return this}else if(typeof e==="object"){for(let i of Object.keys(e))this.coerce(i,e[i]);return this}if(!t)throw new le("coerce callback must be provided");let n=e;return g(this,U,"f").key[n]=!0,g(this,Pe,"f").addCoerceMiddleware((i,s)=>{var r;let o=(r=s.getAliases()[n])!==null&&r!==void 0?r:[],a=[n,...o].filter((c)=>Object.prototype.hasOwnProperty.call(i,c));if(a.length===0)return i;return gt(()=>t(i[a[0]]),(c)=>(a.forEach((u)=>{i[u]=c}),i),(c)=>{throw new le(c.message)})},n),this}conflicts(e,t){return B("<string|object> [string|array]",[e,t],arguments.length),g(this,ce,"f").conflicts(e,t),this}config(e="config",t,n){if(B("[object|string] [string|function] [function]",[e,t,n],arguments.length),typeof e==="object"&&!Array.isArray(e))return e=en(e,g(this,mt,"f"),this[xt]()["deep-merge-config"]||!1,g(this,q,"f")),g(this,U,"f").configObjects=(g(this,U,"f").configObjects||[]).concat(e),this;if(typeof t==="function")n=t,t=void 0;return this.describe(e,t||g(this,Y,"f").deferY18nLookup("Path to JSON config file")),(Array.isArray(e)?e:[e]).forEach((i)=>{g(this,U,"f").config[i]=n||!0}),this}completion(e,t,n){if(B("[string] [string|boolean|function] [function]",[e,t,n],arguments.length),typeof t==="function")n=t,t=void 0;if(N(this,_e,e||g(this,_e,"f")||"completion","f"),!t&&t!==!1)t="generate completion script";if(this.command(g(this,_e,"f"),t),n)g(this,Ee,"f").registerFunction(n);return this}command(e,t,n,i,s,r){return B("<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]",[e,t,n,i,s,r],arguments.length),g(this,fe,"f").addHandler(e,t,n,i,s,r),this}commands(e,t,n,i,s,r){return this.command(e,t,n,i,s,r)}commandDir(e,t){B("<string> [object]",[e,t],arguments.length);let n=g(this,Pn,"f")||g(this,q,"f").require;return g(this,fe,"f").addDirectory(e,n,g(this,q,"f").getCallerFile(),t),this}count(e){return B("<array|string>",[e],arguments.length),this[at]("count",e),this[St](e),this}default(e,t,n){if(B("<object|string|array> [*] [string]",[e,t,n],arguments.length),n)Rs(e,g(this,q,"f")),g(this,U,"f").defaultDescription[e]=n;if(typeof t==="function"){if(Rs(e,g(this,q,"f")),!g(this,U,"f").defaultDescription[e])g(this,U,"f").defaultDescription[e]=g(this,Y,"f").functionDescription(t);t=t.call()}return this[Ut](this.default.bind(this),"default",e,t),this}defaults(e,t,n){return this.default(e,t,n)}demandCommand(e=1,t,n,i){if(B("[number] [number|string] [string|null|undefined] [string|null|undefined]",[e,t,n,i],arguments.length),typeof t!=="number")n=t,t=1/0;return this.global("_",!1),g(this,U,"f").demandedCommands._={min:e,max:t,minMsg:n,maxMsg:i},this}demand(e,t,n){if(Array.isArray(t))t.forEach((i)=>{Fe(n,!0,g(this,q,"f")),this.demandOption(i,n)}),t=1/0;else if(typeof t!=="number")n=t,t=1/0;if(typeof e==="number")Fe(n,!0,g(this,q,"f")),this.demandCommand(e,t,n,n);else if(Array.isArray(e))e.forEach((i)=>{Fe(n,!0,g(this,q,"f")),this.demandOption(i,n)});else if(typeof n==="string")this.demandOption(e,n);else if(n===!0||typeof n>"u")this.demandOption(e);return this}demandOption(e,t){return B("<object|string|array> [string]",[e,t],arguments.length),this[Ut](this.demandOption.bind(this),"demandedOptions",e,t),this}deprecateOption(e,t){return B("<string> [string|boolean]",[e,t],arguments.length),g(this,U,"f").deprecatedOptions[e]=t,this}describe(e,t){return B("<object|string|array> [string]",[e,t],arguments.length),this[Ks](e,!0),g(this,Y,"f").describe(e,t),this}detectLocale(e){return B("<boolean>",[e],arguments.length),N(this,Dt,e,"f"),this}env(e){if(B("[string|boolean]",[e],arguments.length),e===!1)delete g(this,U,"f").envPrefix;else g(this,U,"f").envPrefix=e||"";return this}epilogue(e){return B("<string>",[e],arguments.length),g(this,Y,"f").epilog(e),this}epilog(e){return this.epilogue(e)}example(e,t){if(B("<string|array> [string]",[e,t],arguments.length),Array.isArray(e))e.forEach((n)=>this.example(...n));else g(this,Y,"f").example(e,t);return this}exit(e,t){if(N(this,Se,!0,"f"),N(this,rt,t,"f"),g(this,Te,"f"))g(this,q,"f").process.exit(e)}exitProcess(e=!0){return B("[boolean]",[e],arguments.length),N(this,Te,e,"f"),this}fail(e){if(B("<function|boolean>",[e],arguments.length),typeof e==="boolean"&&e!==!1)throw new le("Invalid first argument. Expected function or boolean 'false'");return g(this,Y,"f").failFn(e),this}getAliases(){return this.parsed?this.parsed.aliases:{}}async getCompletion(e,t){if(B("<array> [function]",[e,t],arguments.length),!t)return new Promise((n,i)=>{g(this,Ee,"f").getCompletion(e,(s,r)=>{if(s)i(s);else n(r)})});else return g(this,Ee,"f").getCompletion(e,t)}getDemandedOptions(){return B([],0),g(this,U,"f").demandedOptions}getDemandedCommands(){return B([],0),g(this,U,"f").demandedCommands}getDeprecatedOptions(){return B([],0),g(this,U,"f").deprecatedOptions}getDetectLocale(){return g(this,Dt,"f")}getExitProcess(){return g(this,Te,"f")}getGroups(){return Object.assign({},g(this,Ye,"f"),g(this,bt,"f"))}getHelp(){if(N(this,Se,!0,"f"),!g(this,Y,"f").hasCachedHelpMessage()){if(!this.parsed){let t=this[nn](g(this,ot,"f"),void 0,void 0,0,!0);if(ne(t))return t.then(()=>g(this,Y,"f").help())}let e=g(this,fe,"f").runDefaultBuilderOn(this);if(ne(e))return e.then(()=>g(this,Y,"f").help())}return Promise.resolve(g(this,Y,"f").help())}getOptions(){return g(this,U,"f")}getStrict(){return g(this,Ft,"f")}getStrictCommands(){return g(this,Ct,"f")}getStrictOptions(){return g(this,Et,"f")}global(e,t){if(B("<string|array> [boolean]",[e,t],arguments.length),e=[].concat(e),t!==!1)g(this,U,"f").local=g(this,U,"f").local.filter((n)=>e.indexOf(n)===-1);else e.forEach((n)=>{if(!g(this,U,"f").local.includes(n))g(this,U,"f").local.push(n)});return this}group(e,t){B("<string|array> <string>",[e,t],arguments.length);let n=g(this,bt,"f")[t]||g(this,Ye,"f")[t];if(g(this,bt,"f")[t])delete g(this,bt,"f")[t];let i={};return g(this,Ye,"f")[t]=(n||[]).concat(e).filter((s)=>{if(i[s])return!1;return i[s]=!0}),this}hide(e){return B("<string>",[e],arguments.length),g(this,U,"f").hiddenOptions.push(e),this}implies(e,t){return B("<string|object> [number|string|array]",[e,t],arguments.length),g(this,ce,"f").implies(e,t),this}locale(e){if(B("[string]",[e],arguments.length),e===void 0)return this[js](),g(this,q,"f").y18n.getLocale();return N(this,Dt,!1,"f"),g(this,q,"f").y18n.setLocale(e),this}middleware(e,t,n){return g(this,Pe,"f").addMiddleware(e,!!t,n)}nargs(e,t){return B("<string|object|array> [number]",[e,t],arguments.length),this[Ut](this.nargs.bind(this),"narg",e,t),this}normalize(e){return B("<array|string>",[e],arguments.length),this[at]("normalize",e),this}number(e){return B("<array|string>",[e],arguments.length),this[at]("number",e),this[St](e),this}option(e,t){if(B("<string|object> [object]",[e,t],arguments.length),typeof e==="object")Object.keys(e).forEach((n)=>{this.options(n,e[n])});else{if(typeof t!=="object")t={};if(this[St](e),g(this,Xe,"f")&&(e==="version"||(t===null||t===void 0?void 0:t.alias)==="version"))this[lo](['"version" is a reserved word.',"Please do one of the following:",'- Disable version with `yargs.version(false)` if using "version" as an option',"- Use the built-in `yargs.version` method instead (if applicable)","- Use a different option key","https://yargs.js.org/docs/#api-reference-version"].join(`
|
|
79
|
+
`),void 0,"versionWarning");if(g(this,U,"f").key[e]=!0,t.alias)this.alias(e,t.alias);let n=t.deprecate||t.deprecated;if(n)this.deprecateOption(e,n);let i=t.demand||t.required||t.require;if(i)this.demand(e,i);if(t.demandOption)this.demandOption(e,typeof t.demandOption==="string"?t.demandOption:void 0);if(t.conflicts)this.conflicts(e,t.conflicts);if("default"in t)this.default(e,t.default);if(t.implies!==void 0)this.implies(e,t.implies);if(t.nargs!==void 0)this.nargs(e,t.nargs);if(t.config)this.config(e,t.configParser);if(t.normalize)this.normalize(e);if(t.choices)this.choices(e,t.choices);if(t.coerce)this.coerce(e,t.coerce);if(t.group)this.group(e,t.group);if(t.boolean||t.type==="boolean"){if(this.boolean(e),t.alias)this.boolean(t.alias)}if(t.array||t.type==="array"){if(this.array(e),t.alias)this.array(t.alias)}if(t.number||t.type==="number"){if(this.number(e),t.alias)this.number(t.alias)}if(t.string||t.type==="string"){if(this.string(e),t.alias)this.string(t.alias)}if(t.count||t.type==="count")this.count(e);if(typeof t.global==="boolean")this.global(e,t.global);if(t.defaultDescription)g(this,U,"f").defaultDescription[e]=t.defaultDescription;if(t.skipValidation)this.skipValidation(e);let s=t.describe||t.description||t.desc,r=g(this,Y,"f").getDescriptions();if(!Object.prototype.hasOwnProperty.call(r,e)||typeof s==="string")this.describe(e,s);if(t.hidden)this.hide(e);if(t.requiresArg)this.requiresArg(e)}return this}options(e,t){return this.option(e,t)}parse(e,t,n){if(B("[string|array] [function|boolean|object] [function]",[e,t,n],arguments.length),this[fo](),typeof e>"u")e=g(this,ot,"f");if(typeof t==="object")N(this,wt,t,"f"),t=n;if(typeof t==="function")N(this,ke,t,"f"),t=!1;if(!t)N(this,ot,e,"f");if(g(this,ke,"f"))N(this,Te,!1,"f");let i=this[nn](e,!!t),s=this.parsed;if(g(this,Ee,"f").setParsed(this.parsed),ne(i))return i.then((r)=>{if(g(this,ke,"f"))g(this,ke,"f").call(this,g(this,rt,"f"),r,g(this,me,"f"));return r}).catch((r)=>{if(g(this,ke,"f"))g(this,ke,"f")(r,this.parsed.argv,g(this,me,"f"));throw r}).finally(()=>{this[zs](),this.parsed=s});else{if(g(this,ke,"f"))g(this,ke,"f").call(this,g(this,rt,"f"),i,g(this,me,"f"));this[zs](),this.parsed=s}return i}parseAsync(e,t,n){let i=this.parse(e,t,n);return!ne(i)?Promise.resolve(i):i}parseSync(e,t,n){let i=this.parse(e,t,n);if(ne(i))throw new le(".parseSync() must not be used with asynchronous builders, handlers, or middleware");return i}parserConfiguration(e){return B("<object>",[e],arguments.length),N(this,Rn,e,"f"),this}pkgConf(e,t){B("<string> [string]",[e,t],arguments.length);let n=null,i=this[Ls](t||g(this,mt,"f"));if(i[e]&&typeof i[e]==="object")n=en(i[e],t||g(this,mt,"f"),this[xt]()["deep-merge-config"]||!1,g(this,q,"f")),g(this,U,"f").configObjects=(g(this,U,"f").configObjects||[]).concat(n);return this}positional(e,t){B("<string> <object>",[e,t],arguments.length);let n=["default","defaultDescription","implies","normalize","choices","conflicts","coerce","type","describe","desc","description","alias"];t=st(t,(r,o)=>{if(r==="type"&&!["string","number","boolean"].includes(o))return!1;return n.includes(r)});let i=g(this,tn,"f").fullCommands[g(this,tn,"f").fullCommands.length-1],s=i?g(this,fe,"f").cmdToParseOptions(i):{array:[],alias:{},default:{},demand:{}};return jt(s).forEach((r)=>{let o=s[r];if(Array.isArray(o)){if(o.indexOf(e)!==-1)t[r]=!0}else if(o[e]&&!(r in t))t[r]=o[e]}),this.group(e,g(this,Y,"f").getPositionalGroupName()),this.option(e,t)}recommendCommands(e=!0){return B("[boolean]",[e],arguments.length),N(this,Mn,e,"f"),this}required(e,t,n){return this.demand(e,t,n)}require(e,t,n){return this.demand(e,t,n)}requiresArg(e){if(B("<array|string|object> [number]",[e],arguments.length),typeof e==="string"&&g(this,U,"f").narg[e])return this;else this[Ut](this.requiresArg.bind(this),"narg",e,NaN);return this}showCompletionScript(e,t){return B("[string] [string]",[e,t],arguments.length),e=e||this.$0,g(this,yt,"f").log(g(this,Ee,"f").generateCompletionScript(e,t||g(this,_e,"f")||"completion")),this}showHelp(e){if(B("[string|function]",[e],arguments.length),N(this,Se,!0,"f"),!g(this,Y,"f").hasCachedHelpMessage()){if(!this.parsed){let n=this[nn](g(this,ot,"f"),void 0,void 0,0,!0);if(ne(n))return n.then(()=>{g(this,Y,"f").showHelp(e)}),this}let t=g(this,fe,"f").runDefaultBuilderOn(this);if(ne(t))return t.then(()=>{g(this,Y,"f").showHelp(e)}),this}return g(this,Y,"f").showHelp(e),this}scriptName(e){return this.customScriptName=!0,this.$0=e,this}showHelpOnFail(e,t){return B("[boolean|string] [string]",[e,t],arguments.length),g(this,Y,"f").showHelpOnFail(e,t),this}showVersion(e){return B("[string|function]",[e],arguments.length),g(this,Y,"f").showVersion(e),this}skipValidation(e){return B("<array|string>",[e],arguments.length),this[at]("skipValidation",e),this}strict(e){return B("[boolean]",[e],arguments.length),N(this,Ft,e!==!1,"f"),this}strictCommands(e){return B("[boolean]",[e],arguments.length),N(this,Ct,e!==!1,"f"),this}strictOptions(e){return B("[boolean]",[e],arguments.length),N(this,Et,e!==!1,"f"),this}string(e){return B("<array|string>",[e],arguments.length),this[at]("string",e),this[St](e),this}terminalWidth(){return B([],0),g(this,q,"f").process.stdColumns}updateLocale(e){return this.updateStrings(e)}updateStrings(e){return B("<object>",[e],arguments.length),N(this,Dt,!1,"f"),g(this,q,"f").y18n.updateLocale(e),this}usage(e,t,n,i){if(B("<string|null|undefined> [string|boolean] [function|object] [function]",[e,t,n,i],arguments.length),t!==void 0)if(Fe(e,null,g(this,q,"f")),(e||"").match(/^\$0( |$)/))return this.command(e,t,n,i);else throw new le(".usage() description must start with $0 if being used as alias for .command()");else return g(this,Y,"f").usage(e),this}usageConfiguration(e){return B("<object>",[e],arguments.length),N(this,Bn,e,"f"),this}version(e,t,n){if(B("[boolean|string] [string] [string]",[e,t,n],arguments.length),g(this,Xe,"f"))this[vs](g(this,Xe,"f")),g(this,Y,"f").version(void 0),N(this,Xe,null,"f");if(arguments.length===0)n=this[go](),e="version";else if(arguments.length===1){if(e===!1)return this;n=e,e="version"}else if(arguments.length===2)n=t,t=void 0;return N(this,Xe,typeof e==="string"?e:"version","f"),t=t||g(this,Y,"f").deferY18nLookup("Show version number"),g(this,Y,"f").version(n||void 0),this.boolean(g(this,Xe,"f")),this.describe(g(this,Xe,"f"),t),this}wrap(e){return B("<number|null|undefined>",[e],arguments.length),g(this,Y,"f").wrap(e),this}[(fe=new WeakMap,mt=new WeakMap,tn=new WeakMap,Ee=new WeakMap,_e=new WeakMap,$n=new WeakMap,rt=new WeakMap,Dt=new WeakMap,On=new WeakMap,Te=new WeakMap,In=new WeakMap,Pe=new WeakMap,Ye=new WeakMap,Se=new WeakMap,Re=new WeakMap,Tn=new WeakMap,yt=new WeakMap,me=new WeakMap,U=new WeakMap,Pn=new WeakMap,Rn=new WeakMap,ke=new WeakMap,wt=new WeakMap,Wt=new WeakMap,bt=new WeakMap,ot=new WeakMap,Mn=new WeakMap,q=new WeakMap,Ft=new WeakMap,Ct=new WeakMap,Et=new WeakMap,Y=new WeakMap,Bn=new WeakMap,Xe=new WeakMap,ce=new WeakMap,co)](e){if(!e._||!e["--"])return e;e._.push.apply(e._,e["--"]);try{delete e["--"]}catch(t){}return e}[uo](){return{log:(...e)=>{if(!this[Nn]())console.log(...e);if(N(this,Se,!0,"f"),g(this,me,"f").length)N(this,me,g(this,me,"f")+`
|
|
80
80
|
`,"f");N(this,me,g(this,me,"f")+e.join(" "),"f")},error:(...e)=>{if(!this[Nn]())console.error(...e);if(N(this,Se,!0,"f"),g(this,me,"f").length)N(this,me,g(this,me,"f")+`
|
|
81
|
-
`,"f");N(this,me,g(this,me,"f")+e.join(" "),"f")}}}[vs](e){jt(g(this,U,"f")).forEach((t)=>{if(((i)=>i==="configObjects")(t))return;let n=g(this,U,"f")[t];if(Array.isArray(n)){if(n.includes(e))n.splice(n.indexOf(e),1)}else if(typeof n==="object")delete n[e]}),delete g(this,Y,"f").getDescriptions()[e]}[lo](e,t,n){if(!g(this,On,"f")[n])g(this,q,"f").process.emitWarning(e,t),g(this,On,"f")[n]=!0}[fo](){g(this,In,"f").push({options:g(this,U,"f"),configObjects:g(this,U,"f").configObjects.slice(0),exitProcess:g(this,Pe,"f"),groups:g(this,Ye,"f"),strict:g(this,Ft,"f"),strictCommands:g(this,Ct,"f"),strictOptions:g(this,Et,"f"),completionCommand:g(this,_e,"f"),output:g(this,me,"f"),exitError:g(this,rt,"f"),hasOutput:g(this,Se,"f"),parsed:this.parsed,parseFn:g(this,ke,"f"),parseContext:g(this,wt,"f")}),g(this,Y,"f").freeze(),g(this,ce,"f").freeze(),g(this,fe,"f").freeze(),g(this,Te,"f").freeze()}[po](){let e="",t;if(/\b(node|iojs|electron)(\.exe)?$/.test(g(this,q,"f").process.argv()[0]))t=g(this,q,"f").process.argv().slice(1,2);else t=g(this,q,"f").process.argv().slice(0,1);if(e=t.map((n)=>{let i=this[So](g(this,mt,"f"),n);return n.match(/^(\/|([a-zA-Z]:)?\\)/)&&i.length<n.length?i:n}).join(" ").trim(),g(this,q,"f").getEnv("_")&&g(this,q,"f").getProcessArgvBin()===g(this,q,"f").getEnv("_"))e=g(this,q,"f").getEnv("_").replace(`${g(this,q,"f").path.dirname(g(this,q,"f").process.execPath())}/`,"");return e}[xt](){return g(this,Rn,"f")}[ho](){return g(this,Bn,"f")}[js](){if(!g(this,Dt,"f"))return;let e=g(this,q,"f").getEnv("LC_ALL")||g(this,q,"f").getEnv("LC_MESSAGES")||g(this,q,"f").getEnv("LANG")||g(this,q,"f").getEnv("LANGUAGE")||"en_US";this.locale(e.replace(/[.:].*/,""))}[go](){return this[Ls]().version||"unknown"}[mo](e){let t=e["--"]?e["--"]:e._;for(let n=0,i;(i=t[n])!==void 0;n++)if(g(this,q,"f").Parser.looksLikeNumber(i)&&Number.isSafeInteger(Math.floor(parseFloat(`${i}`))))t[n]=Number(i);return e}[Ls](e){let t=e||"*";if(g(this,Wt,"f")[t])return g(this,Wt,"f")[t];let n={};try{let i=e||g(this,q,"f").mainFilename;if(g(this,q,"f").path.extname(i))i=g(this,q,"f").path.dirname(i);let s=g(this,q,"f").findUp(i,(r,o)=>{if(o.includes("package.json"))return"package.json";else return});Fe(s,void 0,g(this,q,"f")),n=JSON.parse(g(this,q,"f").readFileSync(s,"utf8"))}catch(i){}return g(this,Wt,"f")[t]=n||{},g(this,Wt,"f")[t]}[at](e,t){t=[].concat(t),t.forEach((n)=>{n=this[Js](n),g(this,U,"f")[e].push(n)})}[Ut](e,t,n,i){this[Us](e,t,n,i,(s,r,o)=>{g(this,U,"f")[s][r]=o})}[Ws](e,t,n,i){this[Us](e,t,n,i,(s,r,o)=>{g(this,U,"f")[s][r]=(g(this,U,"f")[s][r]||[]).concat(o)})}[Us](e,t,n,i,s){if(Array.isArray(n))n.forEach((r)=>{e(r,i)});else if(((r)=>typeof r==="object")(n))for(let r of jt(n))e(r,n[r]);else s(t,this[Js](n),i)}[Js](e){if(e==="__proto__")return"___proto___";return e}[Ks](e,t){return this[Ut](this[Ks].bind(this),"key",e,t),this}[zs](){var e,t,n,i,s,r,o,a,c,u,f,l;let d=g(this,In,"f").pop();Fe(d,void 0,g(this,q,"f"));let h;e=this,t=this,n=this,i=this,s=this,r=this,o=this,a=this,c=this,u=this,f=this,l=this,{options:{set value(m){N(e,U,m,"f")}}.value,configObjects:h,exitProcess:{set value(m){N(t,Pe,m,"f")}}.value,groups:{set value(m){N(n,Ye,m,"f")}}.value,output:{set value(m){N(i,me,m,"f")}}.value,exitError:{set value(m){N(s,rt,m,"f")}}.value,hasOutput:{set value(m){N(r,Se,m,"f")}}.value,parsed:this.parsed,strict:{set value(m){N(o,Ft,m,"f")}}.value,strictCommands:{set value(m){N(a,Ct,m,"f")}}.value,strictOptions:{set value(m){N(c,Et,m,"f")}}.value,completionCommand:{set value(m){N(u,_e,m,"f")}}.value,parseFn:{set value(m){N(f,ke,m,"f")}}.value,parseContext:{set value(m){N(l,wt,m,"f")}}.value}=d,g(this,U,"f").configObjects=h,g(this,Y,"f").unfreeze(),g(this,ce,"f").unfreeze(),g(this,fe,"f").unfreeze(),g(this,Te,"f").unfreeze()}[Do](e,t){return gt(t,(n)=>(e(n),n))}getInternalMethods(){return{getCommandInstance:this[yo].bind(this),getContext:this[wo].bind(this),getHasOutput:this[bo].bind(this),getLoggerInstance:this[Fo].bind(this),getParseContext:this[Co].bind(this),getParserConfiguration:this[xt].bind(this),getUsageConfiguration:this[ho].bind(this),getUsageInstance:this[Eo].bind(this),getValidationInstance:this[xo].bind(this),hasParseCallback:this[Nn].bind(this),isGlobalContext:this[_o].bind(this),postProcess:this[_t].bind(this),reset:this[Hs].bind(this),runValidation:this[qs].bind(this),runYargsParserAndExecuteCommands:this[nn].bind(this),setHasOutput:this[ko].bind(this)}}[yo](){return g(this,fe,"f")}[wo](){return g(this,tn,"f")}[bo](){return g(this,Se,"f")}[Fo](){return g(this,yt,"f")}[Co](){return g(this,wt,"f")||{}}[Eo](){return g(this,Y,"f")}[xo](){return g(this,ce,"f")}[Nn](){return!!g(this,ke,"f")}[_o](){return g(this,Pn,"f")}[_t](e,t,n,i){if(n)return e;if(ne(e))return e;if(!t)e=this[co](e);if(this[xt]()["parse-positional-numbers"]||this[xt]()["parse-positional-numbers"]===void 0)e=this[mo](e);if(i)e=ht(e,this,g(this,Te,"f").getMiddleware(),!1);return e}[Hs](e={}){N(this,U,g(this,U,"f")||{},"f");let t={};t.local=g(this,U,"f").local||[],t.configObjects=g(this,U,"f").configObjects||[];let n={};t.local.forEach((r)=>{n[r]=!0,(e[r]||[]).forEach((o)=>{n[o]=!0})}),Object.assign(g(this,bt,"f"),Object.keys(g(this,Ye,"f")).reduce((r,o)=>{let a=g(this,Ye,"f")[o].filter((c)=>!(c in n));if(a.length>0)r[o]=a;return r},{})),N(this,Ye,{},"f");let i=["array","boolean","string","skipValidation","count","normalize","number","hiddenOptions"],s=["narg","key","alias","default","defaultDescription","config","choices","demandedOptions","demandedCommands","deprecatedOptions"];if(i.forEach((r)=>{t[r]=(g(this,U,"f")[r]||[]).filter((o)=>!n[o])}),s.forEach((r)=>{t[r]=st(g(this,U,"f")[r],(o)=>!n[o])}),t.envPrefix=g(this,U,"f").envPrefix,N(this,U,t,"f"),N(this,Y,g(this,Y,"f")?g(this,Y,"f").reset(n):Qr(this,g(this,q,"f")),"f"),N(this,ce,g(this,ce,"f")?g(this,ce,"f").reset(n):oo(this,g(this,Y,"f"),g(this,q,"f")),"f"),N(this,fe,g(this,fe,"f")?g(this,fe,"f").reset():Gr(g(this,Y,"f"),g(this,ce,"f"),g(this,Te,"f"),g(this,q,"f")),"f"),!g(this,Ee,"f"))N(this,Ee,so(this,g(this,Y,"f"),g(this,fe,"f"),g(this,q,"f")),"f");return g(this,Te,"f").reset(),N(this,_e,null,"f"),N(this,me,"","f"),N(this,rt,null,"f"),N(this,Se,!1,"f"),this.parsed=!1,this}[So](e,t){return g(this,q,"f").path.relative(e,t)}[nn](e,t,n,i=0,s=!1){var r,o,a,c;let u=!!n||s;e=e||g(this,ot,"f"),g(this,U,"f").__=g(this,q,"f").y18n.__,g(this,U,"f").configuration=this[xt]();let f=!!g(this,U,"f").configuration["populate--"],l=Object.assign({},g(this,U,"f").configuration,{"populate--":!0}),d=g(this,q,"f").Parser.detailed(e,Object.assign({},g(this,U,"f"),{configuration:{"parse-positional-numbers":!1,...l}})),h=Object.assign(d.argv,g(this,wt,"f")),m=void 0,p=d.aliases,y=!1,E=!1;if(Object.keys(h).forEach((F)=>{if(F===g(this,Re,"f")&&h[F])y=!0;else if(F===g(this,Xe,"f")&&h[F])E=!0}),h.$0=this.$0,this.parsed=d,i===0)g(this,Y,"f").clearCachedHelpMessage();try{if(this[js](),t)return this[_t](h,f,!!n,!1);if(g(this,Re,"f")){if([g(this,Re,"f")].concat(p[g(this,Re,"f")]||[]).filter((T)=>T.length>1).includes(""+h._[h._.length-1]))h._.pop(),y=!0}N(this,Pn,!1,"f");let F=g(this,fe,"f").getCommands(),k=((r=g(this,Ee,"f"))===null||r===void 0?void 0:r.completionKey)?[(o=g(this,Ee,"f"))===null||o===void 0?void 0:o.completionKey,...(c=this.getAliases()[(a=g(this,Ee,"f"))===null||a===void 0?void 0:a.completionKey])!==null&&c!==void 0?c:[]].some((A)=>Object.prototype.hasOwnProperty.call(h,A)):!1,C=y||k||s;if(h._.length){if(F.length){let A;for(let T=i||0,v;h._[T]!==void 0;T++)if(v=String(h._[T]),F.includes(v)&&v!==g(this,_e,"f")){let L=g(this,fe,"f").runCommand(v,this,d,T+1,s,y||E||s);return this[_t](L,f,!!n,!1)}else if(!A&&v!==g(this,_e,"f")){A=v;break}if(!g(this,fe,"f").hasDefaultCommand()&&g(this,Mn,"f")&&A&&!C)g(this,ce,"f").recommendCommands(A,F)}if(g(this,_e,"f")&&h._.includes(g(this,_e,"f"))&&!k){if(g(this,Pe,"f"))it(!0);this.showCompletionScript(),this.exit(0)}}if(g(this,fe,"f").hasDefaultCommand()&&!C){let A=g(this,fe,"f").runCommand(null,this,d,0,s,y||E||s);return this[_t](A,f,!!n,!1)}if(k){if(g(this,Pe,"f"))it(!0);e=[].concat(e);let A=e.slice(e.indexOf(`--${g(this,Ee,"f").completionKey}`)+1);return g(this,Ee,"f").getCompletion(A,(T,v)=>{if(T)throw new le(T.message);(v||[]).forEach((L)=>{g(this,yt,"f").log(L)}),this.exit(0)}),this[_t](h,!f,!!n,!1)}if(!g(this,Se,"f")){if(y){if(g(this,Pe,"f"))it(!0);u=!0,this.showHelp((A)=>{g(this,yt,"f").log(A),this.exit(0)})}else if(E){if(g(this,Pe,"f"))it(!0);u=!0,g(this,Y,"f").showVersion("log"),this.exit(0)}}if(!u&&g(this,U,"f").skipValidation.length>0)u=Object.keys(h).some((A)=>g(this,U,"f").skipValidation.indexOf(A)>=0&&h[A]===!0);if(!u){if(d.error)throw new le(d.error.message);if(!k){let A=this[qs](p,{},d.error);if(!n)m=ht(h,this,g(this,Te,"f").getMiddleware(),!0);if(m=this[Do](A,m!==null&&m!==void 0?m:h),ne(m)&&!n)m=m.then(()=>ht(h,this,g(this,Te,"f").getMiddleware(),!1))}}}catch(F){if(F instanceof le)g(this,Y,"f").fail(F.message,F);else throw F}return this[_t](m!==null&&m!==void 0?m:h,f,!!n,!0)}[qs](e,t,n,i){let s={...this.getDemandedOptions()};return(r)=>{if(n)throw new le(n.message);g(this,ce,"f").nonOptionCount(r),g(this,ce,"f").requiredArguments(r,s);let o=!1;if(g(this,Ct,"f"))o=g(this,ce,"f").unknownCommands(r);if(g(this,Ft,"f")&&!o)g(this,ce,"f").unknownArguments(r,e,t,!!i);else if(g(this,Et,"f"))g(this,ce,"f").unknownArguments(r,e,{},!1,!1);g(this,ce,"f").limitedChoices(r),g(this,ce,"f").implications(r),g(this,ce,"f").conflicting(r)}}[ko](){N(this,Se,!0,"f")}[St](e){if(typeof e==="string")g(this,U,"f").key[e]=!0;else for(let t of e)g(this,U,"f").key[t]=!0}}function Vr(e){return!!e&&typeof e.getInternalMethods==="function"}var nl=Ao(Ts),Oo=nl;import{existsSync as vn,readFileSync as Gs,writeFileSync as Ys,mkdirSync as To}from"node:fs";import{homedir as sl}from"node:os";import{join as kt,dirname as Vs}from"node:path";function Zs(){return process.env.HOME||sl()}function Ro(){return kt(Zs(),".config","slack-cli","profiles.json")}function jn(){return kt(process.cwd(),".slack-cli","workspace")}function Ln(){return kt(Zs(),".slack-cli","workspace")}function sn(){let e=Ro();if(!vn(e))return{profiles:{}};return JSON.parse(Gs(e,"utf8"))}function il(e){let t=Ro();To(Vs(t),{recursive:!0}),Ys(t,JSON.stringify(e,null,2)+`
|
|
82
|
-
`)}function Jt(e){if(!vn(e))return;return Gs(e,"utf8").trim()||void 0}function Io(e,t){let n=Vs(e);
|
|
81
|
+
`,"f");N(this,me,g(this,me,"f")+e.join(" "),"f")}}}[vs](e){jt(g(this,U,"f")).forEach((t)=>{if(((i)=>i==="configObjects")(t))return;let n=g(this,U,"f")[t];if(Array.isArray(n)){if(n.includes(e))n.splice(n.indexOf(e),1)}else if(typeof n==="object")delete n[e]}),delete g(this,Y,"f").getDescriptions()[e]}[lo](e,t,n){if(!g(this,On,"f")[n])g(this,q,"f").process.emitWarning(e,t),g(this,On,"f")[n]=!0}[fo](){g(this,In,"f").push({options:g(this,U,"f"),configObjects:g(this,U,"f").configObjects.slice(0),exitProcess:g(this,Te,"f"),groups:g(this,Ye,"f"),strict:g(this,Ft,"f"),strictCommands:g(this,Ct,"f"),strictOptions:g(this,Et,"f"),completionCommand:g(this,_e,"f"),output:g(this,me,"f"),exitError:g(this,rt,"f"),hasOutput:g(this,Se,"f"),parsed:this.parsed,parseFn:g(this,ke,"f"),parseContext:g(this,wt,"f")}),g(this,Y,"f").freeze(),g(this,ce,"f").freeze(),g(this,fe,"f").freeze(),g(this,Pe,"f").freeze()}[po](){let e="",t;if(/\b(node|iojs|electron)(\.exe)?$/.test(g(this,q,"f").process.argv()[0]))t=g(this,q,"f").process.argv().slice(1,2);else t=g(this,q,"f").process.argv().slice(0,1);if(e=t.map((n)=>{let i=this[So](g(this,mt,"f"),n);return n.match(/^(\/|([a-zA-Z]:)?\\)/)&&i.length<n.length?i:n}).join(" ").trim(),g(this,q,"f").getEnv("_")&&g(this,q,"f").getProcessArgvBin()===g(this,q,"f").getEnv("_"))e=g(this,q,"f").getEnv("_").replace(`${g(this,q,"f").path.dirname(g(this,q,"f").process.execPath())}/`,"");return e}[xt](){return g(this,Rn,"f")}[ho](){return g(this,Bn,"f")}[js](){if(!g(this,Dt,"f"))return;let e=g(this,q,"f").getEnv("LC_ALL")||g(this,q,"f").getEnv("LC_MESSAGES")||g(this,q,"f").getEnv("LANG")||g(this,q,"f").getEnv("LANGUAGE")||"en_US";this.locale(e.replace(/[.:].*/,""))}[go](){return this[Ls]().version||"unknown"}[mo](e){let t=e["--"]?e["--"]:e._;for(let n=0,i;(i=t[n])!==void 0;n++)if(g(this,q,"f").Parser.looksLikeNumber(i)&&Number.isSafeInteger(Math.floor(parseFloat(`${i}`))))t[n]=Number(i);return e}[Ls](e){let t=e||"*";if(g(this,Wt,"f")[t])return g(this,Wt,"f")[t];let n={};try{let i=e||g(this,q,"f").mainFilename;if(g(this,q,"f").path.extname(i))i=g(this,q,"f").path.dirname(i);let s=g(this,q,"f").findUp(i,(r,o)=>{if(o.includes("package.json"))return"package.json";else return});Fe(s,void 0,g(this,q,"f")),n=JSON.parse(g(this,q,"f").readFileSync(s,"utf8"))}catch(i){}return g(this,Wt,"f")[t]=n||{},g(this,Wt,"f")[t]}[at](e,t){t=[].concat(t),t.forEach((n)=>{n=this[Js](n),g(this,U,"f")[e].push(n)})}[Ut](e,t,n,i){this[Us](e,t,n,i,(s,r,o)=>{g(this,U,"f")[s][r]=o})}[Ws](e,t,n,i){this[Us](e,t,n,i,(s,r,o)=>{g(this,U,"f")[s][r]=(g(this,U,"f")[s][r]||[]).concat(o)})}[Us](e,t,n,i,s){if(Array.isArray(n))n.forEach((r)=>{e(r,i)});else if(((r)=>typeof r==="object")(n))for(let r of jt(n))e(r,n[r]);else s(t,this[Js](n),i)}[Js](e){if(e==="__proto__")return"___proto___";return e}[Ks](e,t){return this[Ut](this[Ks].bind(this),"key",e,t),this}[zs](){var e,t,n,i,s,r,o,a,c,u,f,l;let d=g(this,In,"f").pop();Fe(d,void 0,g(this,q,"f"));let h;e=this,t=this,n=this,i=this,s=this,r=this,o=this,a=this,c=this,u=this,f=this,l=this,{options:{set value(m){N(e,U,m,"f")}}.value,configObjects:h,exitProcess:{set value(m){N(t,Te,m,"f")}}.value,groups:{set value(m){N(n,Ye,m,"f")}}.value,output:{set value(m){N(i,me,m,"f")}}.value,exitError:{set value(m){N(s,rt,m,"f")}}.value,hasOutput:{set value(m){N(r,Se,m,"f")}}.value,parsed:this.parsed,strict:{set value(m){N(o,Ft,m,"f")}}.value,strictCommands:{set value(m){N(a,Ct,m,"f")}}.value,strictOptions:{set value(m){N(c,Et,m,"f")}}.value,completionCommand:{set value(m){N(u,_e,m,"f")}}.value,parseFn:{set value(m){N(f,ke,m,"f")}}.value,parseContext:{set value(m){N(l,wt,m,"f")}}.value}=d,g(this,U,"f").configObjects=h,g(this,Y,"f").unfreeze(),g(this,ce,"f").unfreeze(),g(this,fe,"f").unfreeze(),g(this,Pe,"f").unfreeze()}[Do](e,t){return gt(t,(n)=>(e(n),n))}getInternalMethods(){return{getCommandInstance:this[yo].bind(this),getContext:this[wo].bind(this),getHasOutput:this[bo].bind(this),getLoggerInstance:this[Fo].bind(this),getParseContext:this[Co].bind(this),getParserConfiguration:this[xt].bind(this),getUsageConfiguration:this[ho].bind(this),getUsageInstance:this[Eo].bind(this),getValidationInstance:this[xo].bind(this),hasParseCallback:this[Nn].bind(this),isGlobalContext:this[_o].bind(this),postProcess:this[_t].bind(this),reset:this[Hs].bind(this),runValidation:this[qs].bind(this),runYargsParserAndExecuteCommands:this[nn].bind(this),setHasOutput:this[ko].bind(this)}}[yo](){return g(this,fe,"f")}[wo](){return g(this,tn,"f")}[bo](){return g(this,Se,"f")}[Fo](){return g(this,yt,"f")}[Co](){return g(this,wt,"f")||{}}[Eo](){return g(this,Y,"f")}[xo](){return g(this,ce,"f")}[Nn](){return!!g(this,ke,"f")}[_o](){return g(this,Tn,"f")}[_t](e,t,n,i){if(n)return e;if(ne(e))return e;if(!t)e=this[co](e);if(this[xt]()["parse-positional-numbers"]||this[xt]()["parse-positional-numbers"]===void 0)e=this[mo](e);if(i)e=ht(e,this,g(this,Pe,"f").getMiddleware(),!1);return e}[Hs](e={}){N(this,U,g(this,U,"f")||{},"f");let t={};t.local=g(this,U,"f").local||[],t.configObjects=g(this,U,"f").configObjects||[];let n={};t.local.forEach((r)=>{n[r]=!0,(e[r]||[]).forEach((o)=>{n[o]=!0})}),Object.assign(g(this,bt,"f"),Object.keys(g(this,Ye,"f")).reduce((r,o)=>{let a=g(this,Ye,"f")[o].filter((c)=>!(c in n));if(a.length>0)r[o]=a;return r},{})),N(this,Ye,{},"f");let i=["array","boolean","string","skipValidation","count","normalize","number","hiddenOptions"],s=["narg","key","alias","default","defaultDescription","config","choices","demandedOptions","demandedCommands","deprecatedOptions"];if(i.forEach((r)=>{t[r]=(g(this,U,"f")[r]||[]).filter((o)=>!n[o])}),s.forEach((r)=>{t[r]=st(g(this,U,"f")[r],(o)=>!n[o])}),t.envPrefix=g(this,U,"f").envPrefix,N(this,U,t,"f"),N(this,Y,g(this,Y,"f")?g(this,Y,"f").reset(n):Qr(this,g(this,q,"f")),"f"),N(this,ce,g(this,ce,"f")?g(this,ce,"f").reset(n):oo(this,g(this,Y,"f"),g(this,q,"f")),"f"),N(this,fe,g(this,fe,"f")?g(this,fe,"f").reset():Gr(g(this,Y,"f"),g(this,ce,"f"),g(this,Pe,"f"),g(this,q,"f")),"f"),!g(this,Ee,"f"))N(this,Ee,so(this,g(this,Y,"f"),g(this,fe,"f"),g(this,q,"f")),"f");return g(this,Pe,"f").reset(),N(this,_e,null,"f"),N(this,me,"","f"),N(this,rt,null,"f"),N(this,Se,!1,"f"),this.parsed=!1,this}[So](e,t){return g(this,q,"f").path.relative(e,t)}[nn](e,t,n,i=0,s=!1){var r,o,a,c;let u=!!n||s;e=e||g(this,ot,"f"),g(this,U,"f").__=g(this,q,"f").y18n.__,g(this,U,"f").configuration=this[xt]();let f=!!g(this,U,"f").configuration["populate--"],l=Object.assign({},g(this,U,"f").configuration,{"populate--":!0}),d=g(this,q,"f").Parser.detailed(e,Object.assign({},g(this,U,"f"),{configuration:{"parse-positional-numbers":!1,...l}})),h=Object.assign(d.argv,g(this,wt,"f")),m=void 0,p=d.aliases,y=!1,E=!1;if(Object.keys(h).forEach((F)=>{if(F===g(this,Re,"f")&&h[F])y=!0;else if(F===g(this,Xe,"f")&&h[F])E=!0}),h.$0=this.$0,this.parsed=d,i===0)g(this,Y,"f").clearCachedHelpMessage();try{if(this[js](),t)return this[_t](h,f,!!n,!1);if(g(this,Re,"f")){if([g(this,Re,"f")].concat(p[g(this,Re,"f")]||[]).filter((P)=>P.length>1).includes(""+h._[h._.length-1]))h._.pop(),y=!0}N(this,Tn,!1,"f");let F=g(this,fe,"f").getCommands(),k=((r=g(this,Ee,"f"))===null||r===void 0?void 0:r.completionKey)?[(o=g(this,Ee,"f"))===null||o===void 0?void 0:o.completionKey,...(c=this.getAliases()[(a=g(this,Ee,"f"))===null||a===void 0?void 0:a.completionKey])!==null&&c!==void 0?c:[]].some((A)=>Object.prototype.hasOwnProperty.call(h,A)):!1,C=y||k||s;if(h._.length){if(F.length){let A;for(let P=i||0,v;h._[P]!==void 0;P++)if(v=String(h._[P]),F.includes(v)&&v!==g(this,_e,"f")){let L=g(this,fe,"f").runCommand(v,this,d,P+1,s,y||E||s);return this[_t](L,f,!!n,!1)}else if(!A&&v!==g(this,_e,"f")){A=v;break}if(!g(this,fe,"f").hasDefaultCommand()&&g(this,Mn,"f")&&A&&!C)g(this,ce,"f").recommendCommands(A,F)}if(g(this,_e,"f")&&h._.includes(g(this,_e,"f"))&&!k){if(g(this,Te,"f"))it(!0);this.showCompletionScript(),this.exit(0)}}if(g(this,fe,"f").hasDefaultCommand()&&!C){let A=g(this,fe,"f").runCommand(null,this,d,0,s,y||E||s);return this[_t](A,f,!!n,!1)}if(k){if(g(this,Te,"f"))it(!0);e=[].concat(e);let A=e.slice(e.indexOf(`--${g(this,Ee,"f").completionKey}`)+1);return g(this,Ee,"f").getCompletion(A,(P,v)=>{if(P)throw new le(P.message);(v||[]).forEach((L)=>{g(this,yt,"f").log(L)}),this.exit(0)}),this[_t](h,!f,!!n,!1)}if(!g(this,Se,"f")){if(y){if(g(this,Te,"f"))it(!0);u=!0,this.showHelp((A)=>{g(this,yt,"f").log(A),this.exit(0)})}else if(E){if(g(this,Te,"f"))it(!0);u=!0,g(this,Y,"f").showVersion("log"),this.exit(0)}}if(!u&&g(this,U,"f").skipValidation.length>0)u=Object.keys(h).some((A)=>g(this,U,"f").skipValidation.indexOf(A)>=0&&h[A]===!0);if(!u){if(d.error)throw new le(d.error.message);if(!k){let A=this[qs](p,{},d.error);if(!n)m=ht(h,this,g(this,Pe,"f").getMiddleware(),!0);if(m=this[Do](A,m!==null&&m!==void 0?m:h),ne(m)&&!n)m=m.then(()=>ht(h,this,g(this,Pe,"f").getMiddleware(),!1))}}}catch(F){if(F instanceof le)g(this,Y,"f").fail(F.message,F);else throw F}return this[_t](m!==null&&m!==void 0?m:h,f,!!n,!0)}[qs](e,t,n,i){let s={...this.getDemandedOptions()};return(r)=>{if(n)throw new le(n.message);g(this,ce,"f").nonOptionCount(r),g(this,ce,"f").requiredArguments(r,s);let o=!1;if(g(this,Ct,"f"))o=g(this,ce,"f").unknownCommands(r);if(g(this,Ft,"f")&&!o)g(this,ce,"f").unknownArguments(r,e,t,!!i);else if(g(this,Et,"f"))g(this,ce,"f").unknownArguments(r,e,{},!1,!1);g(this,ce,"f").limitedChoices(r),g(this,ce,"f").implications(r),g(this,ce,"f").conflicting(r)}}[ko](){N(this,Se,!0,"f")}[St](e){if(typeof e==="string")g(this,U,"f").key[e]=!0;else for(let t of e)g(this,U,"f").key[t]=!0}}function Vr(e){return!!e&&typeof e.getInternalMethods==="function"}var sl=Ao(Ps),Oo=sl;import{existsSync as vn,readFileSync as Gs,writeFileSync as Ys,mkdirSync as Po}from"node:fs";import{homedir as il}from"node:os";import{join as kt,dirname as Vs}from"node:path";function Zs(){return process.env.HOME||il()}function Ro(){return kt(Zs(),".config","slack-cli","profiles.json")}function jn(){return kt(process.cwd(),".slack-cli","workspace")}function Ln(){return kt(Zs(),".slack-cli","workspace")}function sn(){let e=Ro();if(!vn(e))return{profiles:{}};return JSON.parse(Gs(e,"utf8"))}function rl(e){let t=Ro();Po(Vs(t),{recursive:!0}),Ys(t,JSON.stringify(e,null,2)+`
|
|
82
|
+
`)}function Jt(e){if(!vn(e))return;return Gs(e,"utf8").trim()||void 0}function Io(e,t){let n=Vs(e);Po(n,{recursive:!0});let i=kt(n,".gitignore");if(!vn(i))Ys(i,`*
|
|
83
83
|
`);Ys(e,t+`
|
|
84
|
-
`)}function
|
|
85
|
-
`)){let i=n.trim();if(!i||i.startsWith("#"))continue;let s=i.indexOf("=");if(s===-1)continue;let r=i.slice(0,s).trim(),o=i.slice(s+1).trim();if(o.startsWith('"')&&o.endsWith('"')||o.startsWith("'")&&o.endsWith("'"))o=o.slice(1,-1);t[r]=o}return t}function
|
|
84
|
+
`)}function ol(e){let t={};for(let n of e.split(`
|
|
85
|
+
`)){let i=n.trim();if(!i||i.startsWith("#"))continue;let s=i.indexOf("=");if(s===-1)continue;let r=i.slice(0,s).trim(),o=i.slice(s+1).trim();if(o.startsWith('"')&&o.endsWith('"')||o.startsWith("'")&&o.endsWith("'"))o=o.slice(1,-1);t[r]=o}return t}function To(e){if(!vn(e))return{};try{return ol(Gs(e,"utf8"))}catch{return{}}}function Xs(e,t){let n=Zs(),i=e;while(!0){for(let o of[kt(i,".slack-term",".env.local"),kt(i,".env.local")]){let a=To(o);for(let c of t)if(a[c])return a[c]}if(i===n)break;let r=Vs(i);if(r===i)break;i=r}let s=To(kt(n,".slack-term",".env.local"));for(let r of t)if(s[r])return s[r];return}function Qs(){let e=sn(),t=Jt(jn()),n=Jt(Ln()),i=t??n;return Object.entries(e.profiles).map(([s,r])=>({name:s,profile:r,current:s===i}))}function Mo(e){let t=sn();if(!(e in t.profiles))throw Error(`Profile not found: ${e}`);delete t.profiles[e],rl(t)}function Bo(e,t=!1){let n=sn();if(!(e in n.profiles))throw Error(`Profile not found: ${e}`);if(t)Io(Ln(),e);else Io(jn(),e)}function ei(e){let n=sn().profiles,i=Object.keys(n);if(e){let u=n[e];if(!u)throw Error(`Workspace "${e}" not found. Available: ${i.join(", ")||"(none)"}`);return u.token}if(process.env.SLACK_TOKEN)return process.env.SLACK_TOKEN;let s=process.env.SLACK_BOT_TOKEN??process.env.SLACK_MCP_XOXP_TOKEN;if(s&&i.length===0)return s;if(s&&i.length>0){let u=Xs(process.cwd(),["SLACK_BOT_TOKEN","SLACK_MCP_XOXP_TOKEN"]);if(s!==u){if(!globalThis.__slackEnvWarnShown)globalThis.__slackEnvWarnShown=!0,console.error(`Warning: SLACK_MCP_XOXP_TOKEN / SLACK_BOT_TOKEN is set but workspace profiles exist — using profiles.
|
|
86
86
|
`+" Migrate to SLACK_TOKEN=... or remove from your shell config.")}}let r=Xs(process.cwd(),["SLACK_TOKEN"]);if(r)return r;let o=process.env.SLACK_WORKSPACE;if(o){let u=n[o];if(!u)throw Error(`Workspace "${o}" not found. Available: ${i.join(", ")||"(none)"}`);return u.token}let a=Jt(jn());if(a){let u=n[a];if(!u)throw Error(`Workspace "${a}" (from .slack-cli/workspace) not found in profiles.`);return u.token}let c=Jt(Ln());if(c){let u=n[c];if(!u)throw Error(`Workspace "${c}" (from ~/.slack-cli/workspace) not found in profiles.`);return u.token}if(i.length>0)throw Error(`Workspace not selected (${i.join(", ")} available).
|
|
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.
|
|
@@ -96,35 +96,35 @@ Or replace the token with an xoxp- user token:
|
|
|
96
96
|
slack auth token`);if((a==="missing_scope"||a==="cannot_dm_bot")&&e.startsWith("xoxb-"))throw Error(`Slack error on ${t}: ${a} — ${a==="cannot_dm_bot"?`you're authenticated as a bot, so "@you" is the bot itself and it can't DM itself`:"this bot token lacks the user scope this action needs"}.
|
|
97
97
|
Tailing/DMing people and listing users need a user session, not a bot token.
|
|
98
98
|
Switch workspace: slack auth ls then slack auth use <name>
|
|
99
|
-
Or import your Slack desktop session: slack auth login`);throw Error(`Slack error on ${t}: ${a}`)}return o}async function
|
|
99
|
+
Or import your Slack desktop session: slack auth login`);throw Error(`Slack error on ${t}: ${a}`)}return o}async function al(e,t,n,i){let s={};if(i)s.Cookie=`d=${i}`;let r=await fetch(`${ti()}/${t}`,{...n,headers:{...n.headers??{},Authorization:`Bearer ${e}`,...s}});if(r.status===429){let a=parseInt(r.headers.get("retry-after")??"60",10);throw new Ge(isNaN(a)?60:a)}let o=await r.json();if(o.ok!==!0){let a=o.error??"unknown";if(a==="ratelimited")throw new Ge(60);if((a==="invalid_auth"||a==="not_authed")&&!e.startsWith("xoxc-"))throw Error(`The draft API requires a desktop app session token (xoxc-).
|
|
100
100
|
Import from Slack desktop: slack auth login`);if((a==="invalid_auth"||a==="not_authed")&&!i)throw Error(`drafts.list also requires the xoxd session cookie.
|
|
101
|
-
Attach it with: slack auth chrome (macOS) or slack auth firefox`);throw Error(`Slack error on ${t}: ${a}`)}return o}function
|
|
101
|
+
Attach it with: slack auth chrome (macOS) or slack auth firefox`);throw Error(`Slack error on ${t}: ${a}`)}return o}function cl(e,t,n={},i){let s=new URLSearchParams({token:e,...n});return al(e,t,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s.toString()},i)}function we(e,t,n,i){let s=new URLSearchParams(n).toString();return jo(e,`${t}?${s}`,{method:"GET"},i)}function ni(e,t,n,i){return jo(e,t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)},i)}async function zt(e,t){let n=await we(e,"auth.test",{},t);return{team:n.team??"",teamId:n.team_id??"",url:n.url??"",user:n.user??"",userId:n.user_id??""}}async function Lo(e,t){let n={Authorization:`Bearer ${e}`};if(t)n.Cookie=`d=${t}`;let i=await fetch(`${ti()}/auth.test`,{method:"GET",headers:n});if(i.status===429){let o=parseInt(i.headers.get("retry-after")??"60",10);throw new Ge(isNaN(o)?60:o)}let s=i.headers.get("x-oauth-scopes")??"",r=await i.json();if(r.ok!==!0)throw Error(`Slack error on auth.test: ${r.error??"unknown"}`);return{userId:r.user_id??"",user:r.user??"",botId:r.bot_id??"",team:r.team??"",url:r.url??"",scopes:s.split(",").map((o)=>o.trim()).filter(Boolean)}}async function Wo(e,t,n){let i=await we(e,"bots.info",{bot:t},n);return{appId:i.bot?.app_id??"",userId:i.bot?.user_id??""}}async function on(e,t,n=20,i,s,r,o){let a={channel:t,limit:String(n)};if(i!==void 0)a.oldest=i;if(s!==void 0)a.cursor=s;if(o)a.inclusive="true";return we(e,"conversations.history",a,r)}async function Uo(e,t,n,i=50,s){return we(e,"conversations.replies",{channel:t,ts:n,limit:String(i)},s)}async function Wn(e,t,n,i,s){await ni(e,"reactions.add",{channel:t,timestamp:n,name:i},s)}async function Jo(e,t,n,i){return((await we(e,"reactions.get",{channel:t,timestamp:n,full:"true"},i)).message?.reactions??[]).map((r)=>({name:String(r.name??""),users:Array.isArray(r.users)?r.users.map(String):[]}))}async function Un(e,t,n,i,s){await ni(e,"reactions.remove",{channel:t,timestamp:n,name:i},s)}async function ul(e,t,n){let s=(await ni(e,"conversations.open",{users:t},n)).channel?.id;if(!s)throw Error(`Failed to open DM with user ${t}`);return s}function rn(e){return e.toLowerCase().replace(/[-_\s]/g,"")}function si(e){let t=e.match(/(?:app\.slack\.com\/client\/T[A-Za-z0-9]+|[A-Za-z0-9-]+\.slack\.com\/archives)\/([A-Za-z0-9]+)(?:\/p(\d{10})(\d{6}))?/);if(!t)return;let n=t[1],i=t[2]&&t[3]?`${t[2]}.${t[3]}`:void 0,s=e.indexOf("?"),r=s>=0?new URLSearchParams(e.slice(s)):void 0,o=r?.get("thread_ts")??void 0,u={channel:r?.get("cid")??void 0??n};if(i)u.ts=i;if(o)u.threadTs=o;return u}function ll(e){return si(e)?.channel}function vo(e){return/^[CDG][A-Z0-9]{8,}$/.test(e)}async function Ko(e,t,n){let i=ll(t);if(i)return i;if(!t.startsWith("@")&&!t.startsWith("#")){if(vo(t))return t;throw Error(`Target must start with # or @ (or be a Slack URL/ID), got: ${t}`)}if(t.startsWith("#")&&vo(t.slice(1)))return t.slice(1);let s=t.startsWith("@"),r=t.slice(1),o=rn(r);if(s){let u=await we(e,"auth.test",{},n);if(o==="you"||o==="me"||rn(u.user??"")===o){let m=u.user_id;if(!m)throw Error("auth.test did not return user_id");let y=((await we(e,"conversations.list",{types:"im",limit:"200"},n)).channels??[]).find((E)=>E.user===m);if(y?.id)return String(y.id);return ul(e,m,n)}let l="",d="";while(!0){let m={limit:"200"};if(d)m.cursor=d;let p=await we(e,"users.list",m,n);for(let y of p.members??[]){let E=rn(y.name??""),F=rn(y.real_name??""),k=rn(y.profile?.display_name??"");if(E===o||F===o||k&&k===o){l=y.id??"";break}}if(l)break;if(d=p.response_metadata?.next_cursor??"",!d)break}if(!l)throw Error(`User not found: ${t}`);let h="";while(!0){let m={types:"im",limit:"200"};if(h)m.cursor=h;let p=await we(e,"conversations.list",m,n);for(let y of p.channels??[])if(y.user===l)return String(y.id??"");if(h=p.response_metadata?.next_cursor??"",!h)break}throw Error(`No existing DM with ${t} (${l}). Open it once in Slack first.`)}let a=r.toLowerCase(),c="";while(!0){let u={limit:"200",types:"public_channel,private_channel",exclude_archived:"true"};if(c)u.cursor=c;let f=await we(e,"conversations.list",u,n);for(let l of f.channels??[])if(String(l.name??"").toLowerCase()===a)return String(l.id??"");if(c=f.response_metadata?.next_cursor??"",!c)break}throw Error(`channel not found: ${t}`)}async function Jn(e,t,n){try{let i=await we(e,"users.info",{user:t},n),s=i.user?.profile?.display_name,r=s&&s.length>0?s:i.user?.real_name??i.user?.name??t,o=i.user?.name??t;return[r,o]}catch{return[t,t]}}async function Kn(e,t,n){try{let i=await we(e,"users.info",{user:t},n),s=i.user?.profile?.display_name;if(s&&s.length>0)return s;return i.user?.real_name??i.user?.name??t}catch{return t}}async function zn(e,t){let n=[],i="";while(!0){let s={limit:"200"};if(i)s.cursor=i;let r=await we(e,"users.list",s,t);if(n.push(...r.members??[]),i=r.response_metadata?.next_cursor??"",!i)break}return{members:n}}async function ii(e,t,n){let i=[],s="";while(!0){let r={channel:t,limit:"200"};if(s)r.cursor=s;let o=await we(e,"conversations.members",r,n);if(i.push(...o.members??[]),s=o.response_metadata?.next_cursor??"",!s)break}return i}async function ri(e,t,n){return we(e,"users.info",{user:t},n)}async function zo(e,t,n){return we(e,"conversations.info",{channel:t},n)}async function Ho(e,t){let n=await cl(e,"client.boot",{},t),i=typeof n.url==="string"?n.url:void 0;if(!i){let r=Object.keys(n).join(", ");throw Error(`client.boot did not return a WebSocket URL. Keys: ${r}`)}let s=n.self&&typeof n.self==="object"&&!Array.isArray(n.self)?n.self:{};return{wsUrl:i,selfId:typeof s.id==="string"?s.id:""}}var fl=["chat:write","im:write"],dl=["im:history","im:read"];async function oi(e){let{userId:t,botId:n,team:i,scopes:s}=await Lo(e),r="";if(n)try{r=(await Wo(e,n)).appId}catch{r=""}let o=(u)=>s.includes(u),a=fl.filter((u)=>!o(u)),c=dl.filter((u)=>!o(u));return{canSend:a.length===0,canReceiveReplies:c.length===0,ok:a.length===0&&c.length===0,botUserId:t,appId:r,team:i,grantedScopes:s,missingSendScopes:a,missingReplyScopes:c}}function qo(e){return["",` Bot user: ${e.botUserId||"(unknown)"}`,` App ID: ${e.appId||"(unknown — bots.info unavailable)"}`,` Granted scopes: ${e.grantedScopes.join(", ")||"(none reported)"}`]}function ai(e,t=!1){let n=e.appId?`https://api.slack.com/apps/${e.appId}`:"https://api.slack.com/apps";if(e.ok){let s=["✓ Bot DM scopes are complete (send + read replies)."," Two-way replies also require the Messages Tab, which is not API-detectable.",' If recipients see "Sending messages to this app is turned off", enable it:',` ${n} → App Home → "Messages Tab" ON + "Allow users to send messages".`];return t?s:[...s,...qo(e)]}let i=[];if(!e.canSend)i.push(`⚠ This bot CANNOT send DMs — missing scope(s): ${e.missingSendScopes.join(", ")}.`);else i.push("⚠ This bot can send DMs, but the user's replies will NOT be readable.");return i.push(" Make escalation DMs two-way:"),i.push(` 1. ${n} → App Home → enable "Messages Tab" and check`),i.push(' "Allow users to send Slash commands and messages".'),i.push(` 2. OAuth & Permissions → add Bot Token Scopes: ${[...e.missingSendScopes,...e.missingReplyScopes].join(", ")}`),i.push(" 3. Reinstall the app to apply the new scopes."),t?i:[...i,...qo(e)]}import{createInterface as $t}from"node:readline/promises";import{join as hi}from"node:path";import{homedir as _l}from"node:os";import{existsSync as ci,readFileSync as ui,writeFileSync as Xo,mkdirSync as Go}from"node:fs";import{homedir as pl}from"node:os";import{join as li,dirname as Vo}from"node:path";function Zo(){return process.env.HOME||pl()}function Qo(){return li(Zo(),".config","slack-cli","profiles.json")}function hl(){return li(process.cwd(),".slack-cli","workspace")}function gl(){return li(Zo(),".slack-cli","workspace")}function fi(){let e=Qo();if(!ci(e))return{profiles:{}};return JSON.parse(ui(e,"utf8"))}function ea(e){let t=Qo();Go(Vo(t),{recursive:!0}),Xo(t,JSON.stringify(e,null,2)+`
|
|
102
102
|
`)}function Yo(e){if(!ci(e))return;return ui(e,"utf8").trim()||void 0}function ta(e,t){Go(Vo(e),{recursive:!0});let n=ci(e)?ui(e,"utf8"):"",i=n?n.split(`
|
|
103
103
|
`):[];for(let[s,r]of Object.entries(t)){let o=i.findIndex((c)=>{let u=c.trim();return u.startsWith(s+"=")||u.startsWith(s+" =")}),a=`${s}=${r}`;if(o!==-1)i[o]=a;else i.push(a)}Xo(e,i.join(`
|
|
104
104
|
`).trimEnd()+`
|
|
105
|
-
`)}function Hn(){let e=fi(),t=Yo(
|
|
105
|
+
`)}function Hn(){let e=fi(),t=Yo(hl()),n=Yo(gl()),i=t??n;return Object.entries(e.profiles).map(([s,r])=>({name:s,profile:r,current:s===i}))}function di(e,t){let n=fi();n.profiles[e]=t,ea(n)}function pi(e,t){let n=fi();if(!(e in n.profiles))throw Error(`Profile not found: ${e}`);n.profiles[e].cookie=t,ea(n)}import{readdirSync as qn,readFileSync as an,existsSync as At,copyFileSync as na,unlinkSync as sa}from"node:fs";import{homedir as Yn,tmpdir as ia}from"node:os";import{join as he,dirname as ml}from"node:path";import{pbkdf2Sync as ra,createDecipheriv as oa}from"node:crypto";import{execSync as aa}from"node:child_process";function Dl(){let e=Yn();if(process.platform==="darwin")return he(e,"Library","Application Support","Slack","Local Storage","leveldb");if(process.platform==="linux")return he(e,".config","Slack","Local Storage","leveldb");if(process.platform==="win32"){let t=process.env.APPDATA??he(e,"AppData","Roaming");return he(t,"Slack","Local Storage","leveldb")}throw Error(`Unsupported platform: ${process.platform}`)}function yl(){let e=Yn();if(process.platform==="darwin")return he(e,"Library","Application Support","Slack","Cookies");return""}function wl(e,t){if(e.length<35||e.slice(0,3).toString()!=="v10")throw Error("Not a v10 encrypted cookie");let n=e.slice(19,35),i=e.slice(35),s=oa("aes-128-cbc",t,n);return s.setAutoPadding(!0),Buffer.concat([s.update(i),s.final()]).toString("utf8")}function bl(){if(process.platform!=="darwin")return;let e=yl();if(!At(e))return;let t;try{t=aa('security find-generic-password -w -s "Slack Safe Storage" -a "Slack Key"',{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trimEnd()}catch{return}let n=ra(t,"saltysalt",1003,16,"sha1");try{let{default:i}=qe("bun:sqlite"),s=new i(e,{readonly:!0}),r=s.prepare("SELECT encrypted_value FROM cookies WHERE name='d' AND host_key LIKE '%slack%'").get();if(s.close(),!r)return;return wl(Buffer.from(r.encrypted_value),n)}catch{return}}async function ca(){let e=Dl();if(!At(e))throw Error(`Slack desktop app LevelDB not found at:
|
|
106
106
|
${e}
|
|
107
|
-
Is Slack installed and opened at least once?`);let t=qn(e).filter((a)=>a.endsWith(".ldb")||a.endsWith(".log"));if(t.length===0)throw Error(`No LevelDB data files found in ${e}`);let n=new Map;for(let a of t){let c;try{c=an(he(e,a),"latin1")}catch{continue}if(a.endsWith(".log"))for(let u of c.matchAll(/"token":"(xoxc-[^"]+)"/g)){let f=u[1],l=f.split("-")[1]??"";if(!l||f.length<40)continue;let d=Math.max(0,u.index-2000),h=Math.min(c.length,u.index+2000),m=c.slice(d,h),p=m.match(/"url":"(https:\/\/[a-z0-9-]+\.slack\.com\/)"/),y=m.match(/"(?:team_name|name)":"([^"]{2,60})"/),E=n.get(l);if(!E||f.length>E.token.length){let F={token:f,teamId:l},k=p?.[1]??E?.url,C=y?.[1]??E?.teamName;if(k)F.url=k;if(C)F.teamName=C;n.set(l,F)}}else for(let u of c.matchAll(/xoxc-(\d+)-(\d+)-(\d+)/g)){let f=u[1];if(n.has(f))continue;let l=u.index+u[0].length,d=Math.min(l+10,c.length);while(l<d&&(c.charCodeAt(l)<48||c.charCodeAt(l)>57))l++;let h="";while(l<c.length&&c.charCodeAt(l)>=48&&c.charCodeAt(l)<=57)h+=c[l++];if(c[l]!=="-")continue;l++;let m="";while(l<c.length){let y=c.charCodeAt(l);if(y>=48&&y<=57||y>=97&&y<=102)m+=c[l++];else break}if(m.length<20)continue;let p=`${u[0]}${h}-${m}`;n.set(f,{token:p,teamId:f})}}let s=qn(e).filter((a)=>a.endsWith(".ldb")||a.endsWith(".log")).map((a)=>{try{return an(he(e,a),"latin1").replace(/[^\x20-\x7e]/g," ")}catch{return""}}).join(" ");for(let a of n.values()){if(a.teamName)continue;let c=s.indexOf(a.teamId);if(c!==-1){let u=Math.max(0,c-500),f=Math.min(s.length,c+500),d=s.slice(u,f).match(/"(?:team_name|name)":"([^"]{2,60})"/);if(d?.[1]){a.teamName=d[1];continue}}if(!a.teamName&&a.url){let u=a.url.match(/https:\/\/([a-z0-9-]+)\.slack\.com\//)?.[1];if(u){let f=s.indexOf(u);if(f!==-1){let l=Math.max(0,f-500),d=Math.min(s.length,f+500),m=s.slice(l,d).match(/"(?:team_name|name)":"([^"]{2,60})"/);if(m?.[1]){a.teamName=m[1];continue}}a.teamName=u.split("-").map((l)=>l.charAt(0).toUpperCase()+l.slice(1)).join(" ")}}}let r=
|
|
108
|
-
`)){let a=o.trim();if(a.startsWith("[")){s="",r="";continue}let c=a.indexOf("=");if(c===-1)continue;let u=a.slice(0,c).trim().toLowerCase(),f=a.slice(c+1).trim();if(u==="name")s=f;if(u==="path")r=f.split(/[\\/]/).pop()??f;if(s&&r)n[r]=s,s="",r=""}}catch{}return n}function la(){let e=
|
|
107
|
+
Is Slack installed and opened at least once?`);let t=qn(e).filter((a)=>a.endsWith(".ldb")||a.endsWith(".log"));if(t.length===0)throw Error(`No LevelDB data files found in ${e}`);let n=new Map;for(let a of t){let c;try{c=an(he(e,a),"latin1")}catch{continue}if(a.endsWith(".log"))for(let u of c.matchAll(/"token":"(xoxc-[^"]+)"/g)){let f=u[1],l=f.split("-")[1]??"";if(!l||f.length<40)continue;let d=Math.max(0,u.index-2000),h=Math.min(c.length,u.index+2000),m=c.slice(d,h),p=m.match(/"url":"(https:\/\/[a-z0-9-]+\.slack\.com\/)"/),y=m.match(/"(?:team_name|name)":"([^"]{2,60})"/),E=n.get(l);if(!E||f.length>E.token.length){let F={token:f,teamId:l},k=p?.[1]??E?.url,C=y?.[1]??E?.teamName;if(k)F.url=k;if(C)F.teamName=C;n.set(l,F)}}else for(let u of c.matchAll(/xoxc-(\d+)-(\d+)-(\d+)/g)){let f=u[1];if(n.has(f))continue;let l=u.index+u[0].length,d=Math.min(l+10,c.length);while(l<d&&(c.charCodeAt(l)<48||c.charCodeAt(l)>57))l++;let h="";while(l<c.length&&c.charCodeAt(l)>=48&&c.charCodeAt(l)<=57)h+=c[l++];if(c[l]!=="-")continue;l++;let m="";while(l<c.length){let y=c.charCodeAt(l);if(y>=48&&y<=57||y>=97&&y<=102)m+=c[l++];else break}if(m.length<20)continue;let p=`${u[0]}${h}-${m}`;n.set(f,{token:p,teamId:f})}}let s=qn(e).filter((a)=>a.endsWith(".ldb")||a.endsWith(".log")).map((a)=>{try{return an(he(e,a),"latin1").replace(/[^\x20-\x7e]/g," ")}catch{return""}}).join(" ");for(let a of n.values()){if(a.teamName)continue;let c=s.indexOf(a.teamId);if(c!==-1){let u=Math.max(0,c-500),f=Math.min(s.length,c+500),d=s.slice(u,f).match(/"(?:team_name|name)":"([^"]{2,60})"/);if(d?.[1]){a.teamName=d[1];continue}}if(!a.teamName&&a.url){let u=a.url.match(/https:\/\/([a-z0-9-]+)\.slack\.com\//)?.[1];if(u){let f=s.indexOf(u);if(f!==-1){let l=Math.max(0,f-500),d=Math.min(s.length,f+500),m=s.slice(l,d).match(/"(?:team_name|name)":"([^"]{2,60})"/);if(m?.[1]){a.teamName=m[1];continue}}a.teamName=u.split("-").map((l)=>l.charAt(0).toUpperCase()+l.slice(1)).join(" ")}}}let r=bl(),o=[...n.values()];if(r)for(let a of o)a.cookie=r;return o}function Fl(e,t){let n=(i,s)=>{try{let r=oa("aes-128-cbc",t,i);r.setAutoPadding(!0);let o=Buffer.concat([r.update(s),r.final()]).toString("utf8");return o.startsWith("xoxd-")?o:void 0}catch{return}};return n(Buffer.alloc(16,32),e.slice(3))??(e.length>=35?n(e.slice(19,35),e.slice(35)):void 0)}function Cl(e,t){let n=(i,s)=>{if(i&&s)return`${i} (${s})`;return i||s||t};try{let s=JSON.parse(an(he(e,"Local State"),"utf8")).profile?.info_cache?.[t];if(s&&(s.name||s.user_name))return n(s.name??"",s.user_name??"")}catch{}try{let s=JSON.parse(an(he(e,t,"Preferences"),"utf8")).profile;return n(s?.name??"",s?.user_name??"")}catch{return t}}function ua(){if(process.platform!=="darwin")return{candidates:[],totalProfiles:0};let e=he(Yn(),"Library","Application Support","Google","Chrome");if(!At(e))return{candidates:[],totalProfiles:0};let t;try{t=aa('security find-generic-password -a Chrome -s "Chrome Safe Storage" -w',{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trimEnd()}catch{return{candidates:[],totalProfiles:0}}if(!t)return{candidates:[],totalProfiles:0};let n=ra(t,"saltysalt",1003,16,"sha1"),i=["Default",...qn(e).filter((r)=>r.startsWith("Profile "))],s=[];for(let r of i){let o=he(e,r,"Cookies");if(!At(o))continue;let a=he(ia(),`slack-chrome-cookies-${Date.now()}-${r}.db`);try{na(o,a);let{default:c}=qe("bun:sqlite"),u=new c(a,{readonly:!0}),f=u.prepare("SELECT encrypted_value FROM cookies WHERE name='d' AND host_key LIKE '%slack%'").get();if(u.close(),!f)continue;let l=Buffer.from(f.encrypted_value),d=l.slice(0,3).toString();if(d==="v10"){let h=Fl(l,n);if(!h)continue;s.push({profileDir:r,profileName:Cl(e,r),cookie:h})}else if(d==="v20")throw Error(`Chrome cookie uses v20 (app-bound AES-256-GCM) which is not supported yet. Prefix found: ${l.slice(0,4).toString("hex")}`);else throw Error(`Unknown cookie encryption prefix: ${l.slice(0,4).toString("hex")}`)}catch(c){if(c instanceof Error&&(c.message.includes("app-bound")||c.message.includes("Unknown cookie")))throw c}finally{try{sa(a)}catch{}}}return{candidates:s,totalProfiles:i.length}}function El(){let e=Yn();if(process.platform==="darwin")return he(e,"Library","Application Support","Firefox","Profiles");if(process.platform==="linux")return he(e,".mozilla","firefox");if(process.platform==="win32")return he(process.env.APPDATA??he(e,"AppData","Roaming"),"Mozilla","Firefox","Profiles");return""}function xl(e){let t=he(ml(e),"profiles.ini"),n={};if(!At(t))return n;try{let i=an(t,"utf8"),s="",r="";for(let o of i.split(`
|
|
108
|
+
`)){let a=o.trim();if(a.startsWith("[")){s="",r="";continue}let c=a.indexOf("=");if(c===-1)continue;let u=a.slice(0,c).trim().toLowerCase(),f=a.slice(c+1).trim();if(u==="name")s=f;if(u==="path")r=f.split(/[\\/]/).pop()??f;if(s&&r)n[r]=s,s="",r=""}}catch{}return n}function la(){let e=El();if(!e||!At(e))return[];let t=xl(e),n=[],i;try{i=qn(e)}catch{return[]}for(let s of i){let r=he(e,s,"cookies.sqlite");if(!At(r))continue;let o=he(ia(),`slack-firefox-cookies-${Date.now()}-${s}.db`);try{na(r,o);let{default:a}=qe("bun:sqlite"),c=new a(o,{readonly:!0}),u=c.prepare("SELECT value FROM moz_cookies WHERE name='d' AND host LIKE '%slack%' LIMIT 1").get();if(c.close(),!u?.value||!u.value.startsWith("xoxd-"))continue;let f=t[s]??s;n.push({profileDir:s,profileName:f,cookie:u.value})}catch{}finally{try{sa(o)}catch{}}}return n}var Sl=["search:read","channels:history","groups:history","im:history","mpim:history","channels:read","groups:read","im:read","mpim:read","users:read","chat:write","files:write"],kl=["channels:history","groups:history","im:history","mpim:history","channels:read","groups:read","im:read","mpim:read","users:read","chat:write","files:write"];function Xn(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function Al(){return JSON.stringify({display_information:{name:"slack-term"},oauth_config:{scopes:{user:Sl}},settings:{org_deploy_enabled:!1,socket_mode_enabled:!1,token_rotation_enabled:!1}},null,2)}function $l(){return JSON.stringify({display_information:{name:"slack-term"},features:{bot_user:{display_name:"slack-term",always_online:!1}},oauth_config:{scopes:{bot:kl}},settings:{org_deploy_enabled:!1,socket_mode_enabled:!1,token_rotation_enabled:!1}},null,2)}async function Ot(e,t){return(await e.question(t)).trim()}async function It(e,t,n,i){console.error("Verifying token...");let s=await zt(t),r=Xn(s.team),o;if(n)o=n;else if(e)o=await Ot(e,`Workspace name [${r}]: `)||r;else o=r;let a=null;if(e){console.log(""),console.log("Where to save the token?"),console.log(" 1) ./.env.local (current directory) [default]"),console.log(" 2) ./.slack-term/.env.local (current directory, slack-specific)"),console.log(" 3) ~/.slack-term/.env.local (global, available everywhere)"),console.log(" 4) profiles.json (multi-workspace: slack auth use)"),console.log("");let c=await Ot(e,"Choice [1/2/3/4, Enter=1]: ");if(c==="2")a=hi(process.cwd(),".slack-term",".env.local");else if(c==="3")a=hi(_l(),".slack-term",".env.local");else if(c==="4")a=null;else a=hi(process.cwd(),".env.local")}if(a===null)if(di(o,{token:t,...s,...i?{cookie:i}:{}}),console.log(`Saved workspace "${o}" to profiles.json: ${s.team} (${s.user})`),process.env.SLACK_MCP_XOXP_TOKEN)console.log(""),console.log("Warning: SLACK_MCP_XOXP_TOKEN is set — it conflicts with profiles."),console.log(" Unset it: unset SLACK_MCP_XOXP_TOKEN (and remove from ~/.zshrc / ~/.bashrc)");else console.log(` Run: slack auth use -g ${o}`);else{let c={SLACK_TOKEN:t};if(i)c.SLACK_COOKIE=i;ta(a,c),console.log(`Saved token to ${a}`),console.log(" SLACK_TOKEN will be picked up automatically in this directory tree.")}return o}async function Ol(e){console.error("Scanning Slack desktop app...");let t=await ca();if(t.length===0)console.error("No sessions found. Make sure Slack is installed and you have signed in at least once."),process.exit(1);if(t.length===1&&e){let n=t[0],i=n.teamName??n.teamId;console.log(`Found workspace: ${i}${n.cookie?" (+ xoxd cookie)":""}`),await It(e,n.token,Xn(i),n.cookie),console.log(""),console.log("Note: desktop app tokens (xoxc-) are internal Slack tokens."),console.log("If API calls fail, replace with an xoxp- token: slack auth login");return}for(let n of t){let i=n.teamName??n.teamId,s=Xn(i);di(s,{token:n.token,team:i,teamId:n.teamId,url:n.url??"",user:"",...n.cookie?{cookie:n.cookie}:{}}),console.log(`Added workspace "${s}": ${i}${n.cookie?" + xoxd cookie":""}`)}if(console.log(""),t.length===1){let n=Xn(t[0].teamName??t[0].teamId);console.log(`Run: slack auth use -g ${n}`)}else console.log("Run: slack auth ls then: slack auth use -g <name>");console.log(""),console.log("Note: desktop app tokens (xoxc-) are internal Slack tokens."),console.log("If API calls fail, replace with an xoxp- user token by re-running: slack auth login")}async function fa(e){console.log("Which token type does your app use?"),console.log(""),console.log(" 1) User token (xoxp-) -full access including search [recommended]"),console.log(" 2) Bot token (xoxb-) -search and news unavailable"),console.log("");let n=await Ot(e,"Choice [1/2]: ")==="2"?"bot":"user",i=n==="user"?"xoxp-":"xoxb-",s=n==="user"?"User OAuth Token":"Bot User OAuth Token";console.log(""),console.log("Find your token here:"),console.log(" https://api.slack.com/apps"),console.log(" -> Select your app -> OAuth & Permissions"),console.log(` -> Copy the "${s}" (starts with ${i})`),console.log("");let r=await Ot(e,"Paste your token: ");if(!r)console.error("No token provided."),process.exit(1);if(!r.startsWith(i))console.error(`Expected a ${i} token, got: ${r.slice(0,10)}...`),process.exit(1);await It(e,r)}async function Gn(e,t){let n=t==="user"?Al():$l(),i=t==="user"?"User OAuth Token (xoxp-...)":"Bot User OAuth Token (xoxb-...)",s=t==="user"?"xoxp-":"xoxb-";if(t==="bot")console.log("Note: bot tokens cannot use search:read (user-only scope)."),console.log(" The news and search commands will not work with a bot token."),console.log("");console.log("Step 1 -Create your Slack app:"),console.log(" Open: https://api.slack.com/apps"),console.log(' Click "Create New App" -> "From a manifest" -> select your workspace'),console.log(" Paste this manifest (JSON tab):"),console.log(""),console.log("-------------------------------------------------------------"),console.log(n),console.log("-------------------------------------------------------------"),console.log(""),console.log('Step 2 -Install: "Install App" -> "Install to Workspace" -> Authorize'),console.log(""),console.log("Step 3 -Copy your token:"),console.log(` OAuth & Permissions -> ${i}`),console.log("");let r=await Ot(e,"Paste your token: ");if(!r)console.error("No token provided."),process.exit(1);if(!r.startsWith(s))console.error(`Expected a ${s} token, got: ${r.slice(0,10)}...`),process.exit(1);await It(e,r)}async function da(e={}){if(process.platform!=="darwin")console.error("Chrome cookie extraction is only supported on macOS."),process.exit(1);let t=Hn();if(t.length===0)console.error("No workspaces configured. Run: slack auth login"),process.exit(1);let n;if(e.workspace){if(!t.find((c)=>c.name===e.workspace))console.error(`Workspace "${e.workspace}" not found. Available: ${t.map((c)=>c.name).join(", ")}`),process.exit(1);n=e.workspace}else if(t.length===1)n=t[0].name;else{let a=t.find((c)=>c.current);if(a)n=a.name,console.log(`Using active workspace: ${n}`);else{console.log("Multiple workspaces found. Choose one:"),t.forEach((l,d)=>console.log(` ${d+1}) ${l.name} (${l.profile.team})`));let c=$t({input:process.stdin,output:process.stdout}),u=(await c.question("Choice: ")).trim();c.close();let f=parseInt(u,10)-1;if(isNaN(f)||f<0||f>=t.length)console.error("Invalid choice."),process.exit(1);n=t[f].name}}if(t.find((a)=>a.name===n).profile.token.startsWith("xoxb-")){console.error(`
|
|
109
109
|
Workspace "${n}" uses a bot token (xoxb-). A Chrome session cookie only
|
|
110
110
|
`+`augments a user session token (xoxc-) — it has no effect on a bot token, so user-level
|
|
111
|
-
`+"actions (tail @user, DMs, listing users) would still fail.");let a=t.filter((c)=>c.profile.token.startsWith("xoxc-")||c.profile.token.startsWith("xoxp-"));if(a.length>0)console.error(` Target a user-token workspace instead: ${a.map((c)=>c.name).join(", ")}`),console.error(` slack auth chrome -w ${a[0].name}`);else console.error(" Import your Slack desktop user session instead: slack auth login");process.exit(1)}console.log("Scanning Chrome profiles for Slack session..."),console.log("macOS may show a dialog asking for your login password — click Allow.");let s,r;try{({candidates:s,totalProfiles:r}=ua())}catch(a){console.error(`Failed: ${a instanceof Error?a.message:String(a)}`),process.exit(1)}if(s.length===0)console.error(`No Slack session found in Chrome (scanned ${r} profile${r!==1?"s":""}). Possible reasons:`),console.error(" - You denied the keychain dialog (try running again and click Allow)"),console.error(" - Chrome is not installed or has no Slack session"),console.error(" - You're not logged in to Slack in Chrome"),process.exit(1);let o;if(s.length===1&&r<=1)o=s[0].cookie,console.log(`Found session in Chrome profile: ${s[0].profileName}`);else{let a=s.length===1?`Found 1 Slack session across ${r} Chrome profiles:`:`Found ${s.length} Slack sessions across ${r} Chrome profiles:`;console.log(a),s.forEach((d,h)=>console.log(` ${h+1}) ${d.profileName} [${d.profileDir}]`)),console.log("");let c=$t({input:process.stdin,output:process.stdout}),u=s.length===1?" [Enter=1]":"",f=(await c.question(`Choice [1-${s.length}]${u}: `)).trim();c.close();let l=f===""&&s.length===1?0:parseInt(f,10)-1;if(isNaN(l)||l<0||l>=s.length)console.error("Invalid choice."),process.exit(1);o=s[l].cookie}pi(n,o),console.log(`Saved xoxd cookie to workspace "${n}".`),console.log("RTM WebSocket mode is now available: slack tail @you")}async function pa(e={}){let t=Hn();if(t.length===0)console.error("No workspaces configured. Run: slack auth token"),process.exit(1);let n;if(e.workspace){if(!t.find((o)=>o.name===e.workspace))console.error(`Workspace "${e.workspace}" not found. Available: ${t.map((o)=>o.name).join(", ")}`),process.exit(1);n=e.workspace}else if(t.length===1)n=t[0].name;else{let r=t.find((o)=>o.current);if(r)n=r.name,console.log(`Using active workspace: ${n}`);else{console.log("Multiple workspaces found. Choose one:"),t.forEach((u,f)=>console.log(` ${f+1}) ${u.name} (${u.profile.team})`));let o=$t({input:process.stdin,output:process.stdout}),a=(await o.question("Choice: ")).trim();o.close();let c=parseInt(a,10)-1;if(isNaN(c)||c<0||c>=t.length)console.error("Invalid choice."),process.exit(1);n=t[c].name}}console.log("Scanning Firefox profiles for Slack session...");let i=la();if(i.length===0)console.error("No Slack session found in Firefox. Possible reasons:"),console.error(" - Firefox is not installed"),console.error(" - You are not logged in to Slack in Firefox"),process.exit(1);let s;if(i.length===1)s=i[0].cookie,console.log(`Found session in Firefox profile: ${i[0].profileName}`);else{console.log("Multiple Firefox profiles have a Slack session. Choose one:"),i.forEach((c,u)=>console.log(` ${u+1}) ${c.profileName} [${c.profileDir}]`));let r=$t({input:process.stdin,output:process.stdout}),o=(await r.question("Choice: ")).trim();r.close();let a=parseInt(o,10)-1;if(isNaN(a)||a<0||a>=i.length)console.error("Invalid choice."),process.exit(1);s=i[a].cookie}pi(n,s),console.log(`Saved xoxd cookie to workspace "${n}".`),console.log("RTM WebSocket mode is now available: slack tail @you")}async function ha(e={}){if(e.token){await It(null,e.token,e.name);return}if(!process.stdin.isTTY){let n=[];for await(let s of process.stdin)n.push(s);let i=Buffer.concat(n).toString("utf8").trim();if(!i)console.error("No token provided on stdin."),process.exit(1);await It(null,i,e.name);return}let t=$t({input:process.stdin,output:process.stdout});try{await fa(t)}finally{t.close()}}async function ga(e={}){let t=$t({input:process.stdin,output:process.stdout});try{if(e.bot!==void 0){await Gn(t,e.bot?"bot":"user");return}console.log("Which token type?"),console.log(" 1) User token (xoxp-) -full access including search [default]"),console.log(" 2) Bot token (xoxb-) -search and news unavailable"),console.log("");let n=await Ot(t,"Choice [1/2, Enter=1]: ");await Gn(t,n==="2"?"bot":"user")}finally{t.close()}}async function Vn(e={}){let t=Hn();if(t.length>0){console.log("Currently logged in:");for(let{name:i,profile:s,current:r}of t)console.log(` ${r?"*":" "} ${i} ${s.team} (${s.user||"unknown"})`);console.log(""),console.log("Adding another workspace:"),console.log("")}if(e.token){await It(null,e.token,e.name);return}if(!process.stdin.isTTY){let i=[];for await(let r of process.stdin)i.push(r);let s=Buffer.concat(i).toString("utf8").trim();if(!s)console.error("No token provided on stdin."),process.exit(1);await It(null,s,e.name);return}console.log("How would you like to authenticate with Slack?"),console.log(""),console.log(" 1) Slack desktop app - import session token"),console.log(" Reads the xoxc- token directly from the installed app."),console.log(" Token: all platforms | xoxd cookie: macOS only"),console.log(""),console.log(" 2) Connect existing Slack app [recommended if you have one]"),console.log(" Paste a token from an app you already created."),console.log(""),console.log(" 3) Create new Slack app - user token (xoxp-)"),console.log(" Guided setup with manifest. Full access including search."),console.log(""),console.log(" 4) Create new Slack app - bot token (xoxb-)"),console.log(" Bot is invited to channels. Search and news unavailable."),console.log("");let n=$t({input:process.stdin,output:process.stdout});try{let i=await Ot(n,"Choice [1/2/3/4]: ");if(console.log(""),i==="1")await
|
|
111
|
+
`+"actions (tail @user, DMs, listing users) would still fail.");let a=t.filter((c)=>c.profile.token.startsWith("xoxc-")||c.profile.token.startsWith("xoxp-"));if(a.length>0)console.error(` Target a user-token workspace instead: ${a.map((c)=>c.name).join(", ")}`),console.error(` slack auth chrome -w ${a[0].name}`);else console.error(" Import your Slack desktop user session instead: slack auth login");process.exit(1)}console.log("Scanning Chrome profiles for Slack session..."),console.log("macOS may show a dialog asking for your login password — click Allow.");let s,r;try{({candidates:s,totalProfiles:r}=ua())}catch(a){console.error(`Failed: ${a instanceof Error?a.message:String(a)}`),process.exit(1)}if(s.length===0)console.error(`No Slack session found in Chrome (scanned ${r} profile${r!==1?"s":""}). Possible reasons:`),console.error(" - You denied the keychain dialog (try running again and click Allow)"),console.error(" - Chrome is not installed or has no Slack session"),console.error(" - You're not logged in to Slack in Chrome"),process.exit(1);let o;if(s.length===1&&r<=1)o=s[0].cookie,console.log(`Found session in Chrome profile: ${s[0].profileName}`);else{let a=s.length===1?`Found 1 Slack session across ${r} Chrome profiles:`:`Found ${s.length} Slack sessions across ${r} Chrome profiles:`;console.log(a),s.forEach((d,h)=>console.log(` ${h+1}) ${d.profileName} [${d.profileDir}]`)),console.log("");let c=$t({input:process.stdin,output:process.stdout}),u=s.length===1?" [Enter=1]":"",f=(await c.question(`Choice [1-${s.length}]${u}: `)).trim();c.close();let l=f===""&&s.length===1?0:parseInt(f,10)-1;if(isNaN(l)||l<0||l>=s.length)console.error("Invalid choice."),process.exit(1);o=s[l].cookie}pi(n,o),console.log(`Saved xoxd cookie to workspace "${n}".`),console.log("RTM WebSocket mode is now available: slack tail @you")}async function pa(e={}){let t=Hn();if(t.length===0)console.error("No workspaces configured. Run: slack auth token"),process.exit(1);let n;if(e.workspace){if(!t.find((o)=>o.name===e.workspace))console.error(`Workspace "${e.workspace}" not found. Available: ${t.map((o)=>o.name).join(", ")}`),process.exit(1);n=e.workspace}else if(t.length===1)n=t[0].name;else{let r=t.find((o)=>o.current);if(r)n=r.name,console.log(`Using active workspace: ${n}`);else{console.log("Multiple workspaces found. Choose one:"),t.forEach((u,f)=>console.log(` ${f+1}) ${u.name} (${u.profile.team})`));let o=$t({input:process.stdin,output:process.stdout}),a=(await o.question("Choice: ")).trim();o.close();let c=parseInt(a,10)-1;if(isNaN(c)||c<0||c>=t.length)console.error("Invalid choice."),process.exit(1);n=t[c].name}}console.log("Scanning Firefox profiles for Slack session...");let i=la();if(i.length===0)console.error("No Slack session found in Firefox. Possible reasons:"),console.error(" - Firefox is not installed"),console.error(" - You are not logged in to Slack in Firefox"),process.exit(1);let s;if(i.length===1)s=i[0].cookie,console.log(`Found session in Firefox profile: ${i[0].profileName}`);else{console.log("Multiple Firefox profiles have a Slack session. Choose one:"),i.forEach((c,u)=>console.log(` ${u+1}) ${c.profileName} [${c.profileDir}]`));let r=$t({input:process.stdin,output:process.stdout}),o=(await r.question("Choice: ")).trim();r.close();let a=parseInt(o,10)-1;if(isNaN(a)||a<0||a>=i.length)console.error("Invalid choice."),process.exit(1);s=i[a].cookie}pi(n,s),console.log(`Saved xoxd cookie to workspace "${n}".`),console.log("RTM WebSocket mode is now available: slack tail @you")}async function ha(e={}){if(e.token){await It(null,e.token,e.name);return}if(!process.stdin.isTTY){let n=[];for await(let s of process.stdin)n.push(s);let i=Buffer.concat(n).toString("utf8").trim();if(!i)console.error("No token provided on stdin."),process.exit(1);await It(null,i,e.name);return}let t=$t({input:process.stdin,output:process.stdout});try{await fa(t)}finally{t.close()}}async function ga(e={}){let t=$t({input:process.stdin,output:process.stdout});try{if(e.bot!==void 0){await Gn(t,e.bot?"bot":"user");return}console.log("Which token type?"),console.log(" 1) User token (xoxp-) -full access including search [default]"),console.log(" 2) Bot token (xoxb-) -search and news unavailable"),console.log("");let n=await Ot(t,"Choice [1/2, Enter=1]: ");await Gn(t,n==="2"?"bot":"user")}finally{t.close()}}async function Vn(e={}){let t=Hn();if(t.length>0){console.log("Currently logged in:");for(let{name:i,profile:s,current:r}of t)console.log(` ${r?"*":" "} ${i} ${s.team} (${s.user||"unknown"})`);console.log(""),console.log("Adding another workspace:"),console.log("")}if(e.token){await It(null,e.token,e.name);return}if(!process.stdin.isTTY){let i=[];for await(let r of process.stdin)i.push(r);let s=Buffer.concat(i).toString("utf8").trim();if(!s)console.error("No token provided on stdin."),process.exit(1);await It(null,s,e.name);return}console.log("How would you like to authenticate with Slack?"),console.log(""),console.log(" 1) Slack desktop app - import session token"),console.log(" Reads the xoxc- token directly from the installed app."),console.log(" Token: all platforms | xoxd cookie: macOS only"),console.log(""),console.log(" 2) Connect existing Slack app [recommended if you have one]"),console.log(" Paste a token from an app you already created."),console.log(""),console.log(" 3) Create new Slack app - user token (xoxp-)"),console.log(" Guided setup with manifest. Full access including search."),console.log(""),console.log(" 4) Create new Slack app - bot token (xoxb-)"),console.log(" Bot is invited to channels. Search and news unavailable."),console.log("");let n=$t({input:process.stdin,output:process.stdout});try{let i=await Ot(n,"Choice [1/2/3/4]: ");if(console.log(""),i==="1")await Ol(n);else if(i==="2")await fa(n);else if(i==="3")await Gn(n,"user");else if(i==="4")await Gn(n,"bot");else console.error(`Invalid choice: "${i}". Enter 1, 2, 3, or 4.`),process.exit(1)}finally{n.close()}}async function Zn(e,t,n,i){let s=t,r=[],o=s,a=0;while(!0){let c=o.indexOf("<@U",a);if(c===-1)break;let u=o.slice(c+2),f=u.search(/[>|]/),l=f===-1?u:u.slice(0,f);if(l.length>=9)r.push(l);a=c+1}for(let c of r){if(!n.has(c))n.set(c,await Kn(e,c,i));let u=n.get(c)??c;s=s.replaceAll(`<@${c}>`,`@${u}`),s=s.replace(new RegExp(`<@${c}\\|[^>]*>`,"g"),`@${u}`)}return s}function Qn(e){return e.replace(/<!date\^(\d+)\^[^|>]*(?:\|([^>]*))?>/g,(t,n,i)=>{let s=Number(n);if(!Number.isFinite(s))return i??"date";let r=new Date(s*1000);if(Number.isNaN(r.getTime()))return i??"date";let o=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],a=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],c=o[r.getUTCDay()]??"",u=a[r.getUTCMonth()]??"";return`${c}, ${u} ${String(r.getUTCDate()).padStart(2,"0")}, ${r.getUTCFullYear()}`})}function Da(e){let t=typeof e.ts==="string"?e.ts:"",n=typeof e.thread_ts==="string"?e.thread_ts:"";return n!==""&&n!==t}function Il(e){let[t,n="000000"]=e.split("."),i=new Date(Number(t)*1000),s=i.getUTCFullYear(),r=String(i.getUTCMonth()+1).padStart(2,"0"),o=String(i.getUTCDate()).padStart(2,"0"),a=String(i.getUTCHours()).padStart(2,"0"),c=String(i.getUTCMinutes()).padStart(2,"0"),u=String(i.getUTCSeconds()).padStart(2,"0"),f=n.padEnd(6,"0").slice(0,6);return`${s}-${r}-${o}T${a}:${c}:${u}.${f}`}async function Tl(e,t,n){let i=typeof t.ts==="string"?t.ts:"0.000000",s=Il(i),r="?";if(typeof t.user==="string"){let l=t.user,d="@"+l;if(!n.has(d)){let[,h]=await Jn(e,l);n.set(d,h)}r=n.get(d)??l}else if(typeof t.username==="string")r=t.username;let o=typeof t.text==="string"?t.text:"",c=Qn(await Zn(e,o,n)).split(`
|
|
112
112
|
`),u=c[0]+(c.length>1?`
|
|
113
113
|
`+c.slice(1).map((l)=>` ${l}`).join(`
|
|
114
114
|
`):""),f=Da(t)?"↳ ":"";return`${s} ${f}@${r}: ${u}`}async function Pl(e,t,n,i,s,r,o,a){if(a?.aborted)return;return new Promise((c)=>{let u=new e(n);a?.addEventListener("abort",()=>{u.close(),c()},{once:!0}),u.addEventListener("open",()=>{process.stderr.write(`Connected via RTM (experimental).
|
|
115
|
-
`)}),u.addEventListener("close",()=>c()),u.addEventListener("error",()=>c()),u.addEventListener("message",(f)=>{(async()=>{try{let l;try{l=JSON.parse(String(f.data))}catch{return}let d=typeof l.type==="string"?l.type:"";if(d==="ping"){u.send(JSON.stringify({type:"pong",reply_to:l.id??0}));return}if(d!=="message")return;if((typeof l.channel==="string"?l.channel:"")!==i)return;let m=typeof l.ts==="string"?l.ts:"";if(!m||r.has(m))return;let p=typeof l.subtype==="string"?l.subtype:"";if(p==="message_changed"||p==="message_deleted")return;if(s.thread){if((typeof l.thread_ts==="string"?l.thread_ts:m)!==s.thread&&m!==s.thread)return}if(s.watchThread&&Da(l)){if((typeof l.thread_ts==="string"?l.thread_ts:"")!==s.watchThread)return}if(s.me&&s.myUserId){if(!(typeof l.text==="string"?l.text:"").includes(`<@${s.myUserId}>`))return}if(r.add(m),r.size>1000){let E=r.values().next().value;if(E!==void 0)r.delete(E)}let y=await
|
|
115
|
+
`)}),u.addEventListener("close",()=>c()),u.addEventListener("error",()=>c()),u.addEventListener("message",(f)=>{(async()=>{try{let l;try{l=JSON.parse(String(f.data))}catch{return}let d=typeof l.type==="string"?l.type:"";if(d==="ping"){u.send(JSON.stringify({type:"pong",reply_to:l.id??0}));return}if(d!=="message")return;if((typeof l.channel==="string"?l.channel:"")!==i)return;let m=typeof l.ts==="string"?l.ts:"";if(!m||r.has(m))return;let p=typeof l.subtype==="string"?l.subtype:"";if(p==="message_changed"||p==="message_deleted")return;if(s.thread){if((typeof l.thread_ts==="string"?l.thread_ts:m)!==s.thread&&m!==s.thread)return}if(s.watchThread&&Da(l)){if((typeof l.thread_ts==="string"?l.thread_ts:"")!==s.watchThread)return}if(s.me&&s.myUserId){if(!(typeof l.text==="string"?l.text:"").includes(`<@${s.myUserId}>`))return}if(r.add(m),r.size>1000){let E=r.values().next().value;if(E!==void 0)r.delete(E)}let y=await Tl(t,l,o);process.stdout.write(y+`
|
|
116
116
|
`)}catch(l){process.stderr.write(`RTM message error: ${l instanceof Error?l.message:String(l)}
|
|
117
|
-
`)}})()})})}var ma=3,
|
|
117
|
+
`)}})()})})}var ma=3,Rl=2000,gi={sleep:(e)=>new Promise((t)=>setTimeout(t,e)),clientBoot:Ho,getWebSocket:()=>{let e=globalThis.WebSocket;return typeof e==="function"?e:void 0}};async function ya(e,t,n,i,s,r,o){let a=gi.getWebSocket();if(!a)return;for(let c=0;c<ma;c++){if(o?.aborted)return;try{let{wsUrl:u}=await gi.clientBoot(e,t);await Pl(a,e,u,n,i,s,r,o)}catch{}if(o?.aborted)return;if(c<ma-1)await gi.sleep(Rl)}}function wa(e){let t=e.match(/^(\d+(?:\.\d+)?)(s|m|h|d)$/);if(!t)throw Error(`Invalid --since format: "${e}" (expected e.g. 10m, 2h, 1d)`);let n=parseFloat(t[1]);switch(t[2]){case"s":return n;case"m":return n*60;case"h":return n*3600;case"d":return n*86400}}var Ue={sleep:(e)=>new Promise((t)=>setTimeout(t,e)),now:()=>Date.now(),tailRTM:ya};function et(e){return e&&typeof e==="object"&&!Array.isArray(e)?e:{}}function mi(e){return Array.isArray(e)?e:[]}function ba(e){return Number(e)||0}function Fa(e){let t=typeof e.ts==="string"?e.ts:"",n=typeof e.thread_ts==="string"?e.thread_ts:"";return n!==""&&n!==t}function Ml(e){let[t,n="000000"]=e.split("."),i=new Date(Number(t)*1000),s=i.getUTCFullYear(),r=String(i.getUTCMonth()+1).padStart(2,"0"),o=String(i.getUTCDate()).padStart(2,"0"),a=String(i.getUTCHours()).padStart(2,"0"),c=String(i.getUTCMinutes()).padStart(2,"0"),u=String(i.getUTCSeconds()).padStart(2,"0"),f=n.padEnd(6,"0").slice(0,6);return`${s}-${r}-${o}T${a}:${c}:${u}.${f}`}async function Bl(e,t,n,i,s){let r=typeof t.ts==="string"?t.ts:"0.000000",o=Ml(r),a="?";if(typeof t.user==="string"){let m=t.user,p="@"+m;if(!n.has(p)){let[,y]=await Jn(e,m,s);n.set(p,y)}a=n.get(p)??m}else if(typeof t.username==="string")a=t.username;let c=typeof t.text==="string"?t.text:"",f=Qn(await Zn(e,c,n,s)).split(`
|
|
118
118
|
`),l=f[0]+(f.length>1?`
|
|
119
119
|
`+f.slice(1).map((m)=>` ${m}`).join(`
|
|
120
|
-
`):""),d=Fa(t)?"↳ ":"",h=i?`${i} @${a}`:`@${a}`;return`${o} ${d}${h}: ${l}`}async function
|
|
120
|
+
`):""),d=Fa(t)?"↳ ":"",h=i?`${i} @${a}`:`@${a}`;return`${o} ${d}${h}: ${l}`}async function Nl(e,t,n,i,s,r,o){let a=et(await on(e,t,20,o?void 0:n||void 0,o,i.cookie)),c=mi(a.messages).map(et).reverse(),u=et(a.response_metadata),f=a.has_more===!0&&typeof u.next_cursor==="string"?u.next_cursor:void 0,l=[];if(i.watchThread&&!o){let y=et(await Uo(e,t,i.watchThread,50,i.cookie));l=mi(y.messages).map(et).filter((E)=>(typeof E.ts==="string"?E.ts:"")!==i.watchThread)}let d=[...c.map((y)=>({m:y,fromHistory:!0})),...l.map((y)=>({m:y,fromHistory:!1}))].sort((y,E)=>ba(typeof y.m.ts==="string"?y.m.ts:"")-ba(typeof E.m.ts==="string"?E.m.ts:"")),h=[],m=n,p=!1;for(let{m:y,fromHistory:E}of d){let F=typeof y.ts==="string"?y.ts:"";if(!F||s.has(F))continue;let k=typeof y.subtype==="string"?y.subtype:"";if(k==="message_changed"||k==="message_deleted")continue;if(i.thread){if((typeof y.thread_ts==="string"?y.thread_ts:F)!==i.thread&&F!==i.thread)continue}if(i.watchThread&&Fa(y)){if((typeof y.thread_ts==="string"?y.thread_ts:"")!==i.watchThread)continue}if(i.me&&i.myUserId){if(!(typeof y.text==="string"?y.text:"").includes(`<@${i.myUserId}>`))continue}if(s.add(F),s.size>1000){let A=s.values().next().value;if(A!==void 0)s.delete(A)}if(h.push(await Bl(e,y,r,void 0,i.cookie)),E)m=F;let C=typeof y.user==="string"?y.user:"";if(!i.myUserId||C!==i.myUserId)p=!0}return{newCursor:m,lines:h,hasMore:a.has_more===!0,nextPageCursor:f,emittedOther:p}}function vl(e){if(e.includes("slack.com")){let t=si(e),n=t?.threadTs??t?.ts;if(n)return n;throw Error(`--watch-thread: could not extract a timestamp from "${e}"`)}if(/^\d{10}\.\d{6}$/.test(e))return e;if(/^\d{16}$/.test(e))return`${e.slice(0,10)}.${e.slice(10)}`;throw Error(`--watch-thread: "${e}" is not a valid ts or permalink`)}async function Ca(e,t,n={},i){if(n.me&&!t)console.error(`slack tail --me requires a <target> channel.
|
|
121
121
|
Cross-channel mention streaming is not yet supported.
|
|
122
|
-
Use: slack tail "#channel" --me`),process.exit(1);if(!t)console.error("Usage: slack tail <#channel|@user>\n Run `slack tail --help` for details."),process.exit(1);let s=await Ko(e,t),r=n.interval??60000,o=n.timeout?Ue.now()+wa(n.timeout)*1000:1/0,a=new Map,c=new Set;try{let p=et(await zo(e,s,n.cookie));if(et(p.channel).is_archived===!0)console.error("Warning: this channel is archived — no new messages will arrive.")}catch(p){let y=p instanceof Error?p.message:String(p);if(y.includes("not_in_channel"))console.error("Error: you are not a member of that channel. Join it in Slack first, then retry."),process.exit(1);if(y.includes("missing_scope"))console.error("Error: token lacks the required history scope. Check your token's channels:history (or groups:history) permission."),process.exit(1);if(y.includes("channel_not_found"))console.error("Error: channel not found — it may be a private channel inaccessible with your token."),process.exit(1);console.error(`Warning: preflight check failed: ${y}`)}let u="";if(n.since){let p=wa(n.since);u=(Ue.now()/1000-p).toFixed(6)}else{let p=et(await on(e,s,1,void 0,void 0,n.cookie)),y=mi(p.messages).map(et);if(y.length>0&&typeof y[0]?.ts==="string")u=y[0].ts,c.add(u);else u=(Ue.now()/1000).toFixed(6)}let f;if(n.me||n.exitOnMessage)f=(await zt(e,n.cookie)).userId||void 0;let l;if(n.watchThread!==void 0)try{l=
|
|
122
|
+
Use: slack tail "#channel" --me`),process.exit(1);if(!t)console.error("Usage: slack tail <#channel|@user>\n Run `slack tail --help` for details."),process.exit(1);let s=await Ko(e,t),r=n.interval??60000,o=n.timeout?Ue.now()+wa(n.timeout)*1000:1/0,a=new Map,c=new Set;try{let p=et(await zo(e,s,n.cookie));if(et(p.channel).is_archived===!0)console.error("Warning: this channel is archived — no new messages will arrive.")}catch(p){let y=p instanceof Error?p.message:String(p);if(y.includes("not_in_channel"))console.error("Error: you are not a member of that channel. Join it in Slack first, then retry."),process.exit(1);if(y.includes("missing_scope"))console.error("Error: token lacks the required history scope. Check your token's channels:history (or groups:history) permission."),process.exit(1);if(y.includes("channel_not_found"))console.error("Error: channel not found — it may be a private channel inaccessible with your token."),process.exit(1);console.error(`Warning: preflight check failed: ${y}`)}let u="";if(n.since){let p=wa(n.since);u=(Ue.now()/1000-p).toFixed(6)}else{let p=et(await on(e,s,1,void 0,void 0,n.cookie)),y=mi(p.messages).map(et);if(y.length>0&&typeof y[0]?.ts==="string")u=y[0].ts,c.add(u);else u=(Ue.now()/1000).toFixed(6)}let f;if(n.me||n.exitOnMessage)f=(await zt(e,n.cookie)).userId||void 0;let l;if(n.watchThread!==void 0)try{l=vl(n.watchThread)}catch(p){console.error(p instanceof Error?p.message:String(p)),process.exit(1)}let d={...n.thread!==void 0?{thread:n.thread}:{},...l!==void 0?{watchThread:l}:{},...n.me!==void 0?{me:n.me}:{},...f!==void 0?{myUserId:f}:{},...n.cookie!==void 0?{cookie:n.cookie}:{}};if(e.startsWith("xoxc-")&&n.cookie!==void 0&&n.noRtm!==!0&&n.since===void 0&&n.timeout===void 0&&n.exitOnMessage!==!0){if(await Ue.tailRTM(e,n.cookie,s,d,c,a,i),i?.aborted)return;console.error("RTM unavailable — switching to polling.")}let h=!0,m=Ue.now();while(!i?.aborted){if(Ue.now()>=o)return;let p=!1;try{let F=Ue.now()-m,k=r>0&&F>r*5,C,A=!0;do{let{newCursor:P,lines:v,nextPageCursor:L,emittedOther:R}=await Nl(e,s,u,d,c,a,C);if(u=P,h&&A&&n.since&&v.length===0)process.stdout.write(`(no messages in the last ${n.since} — watching for new)
|
|
123
123
|
`);A=!1;for(let G of v)process.stdout.write(G+`
|
|
124
124
|
`);if(R)p=!0;C=k?L:void 0}while(C);h=!1}catch(E){if(E instanceof Ge){console.error(`Warning: Slack rate limit hit — backing off for ${E.retryAfter}s`),await Ue.sleep(E.retryAfter*1000);continue}throw E}if(n.exitOnMessage&&p)return;m=Ue.now();let y=o-Ue.now();if(y<=0)return;await Ue.sleep(Math.min(r,y))}}var Me=[{name:"one",glyph:"1️⃣"},{name:"two",glyph:"2️⃣"},{name:"three",glyph:"3️⃣"},{name:"four",glyph:"4️⃣"},{name:"five",glyph:"5️⃣"},{name:"six",glyph:"6️⃣"},{name:"seven",glyph:"7️⃣"},{name:"eight",glyph:"8️⃣"},{name:"nine",glyph:"9️⃣"},{name:"keycap_ten",glyph:"\uD83D\uDD1F"}],es=Me.length,ts="question";function yi(e){let t=e.split(`
|
|
125
125
|
`),n=t[t.length-2];if(n===void 0||!n.startsWith("_:warning: 同時に複数選ばれているため回答として数えていません — どれか 1 つだけ残してください: ")||!n.endsWith("_"))return[];return[...n.matchAll(/<@([UW][A-Z0-9]+)>/g)].map((i)=>i[1])}function wi(e,t){let n=e.split(`
|
|
126
126
|
`);if(n.length<2)return e;if(yi(e).length)n.splice(n.length-2,1);if(t.length)n.splice(n.length-1,0,`${"_:warning: 同時に複数選ばれているため回答として数えていません — どれか 1 つだけ残してください: "}${t.map((s)=>`<@${s}>`).join(", ")}_`);let i=n.join(`
|
|
127
|
-
`);return i===e?e:i}function
|
|
127
|
+
`);return i===e?e:i}function jl(e){return e!==void 0&&e.startsWith("_:warning: 同時に複数選ばれているため回答として数えていません — どれか 1 つだけ残してください: ")&&e.endsWith("_")}var bi="white_check_mark",Di=`:${bi}: `;function Ea(e){return e.replace(/\s*\n\s*/g," ")}function xa(e,t,n,i,s){let r=[`:question: *${e}*`];if(t)r.push("",t);if(n.length){if(r.push(""),r.push(...n.map((o,a)=>`${Me[a].glyph} ${Ea(o)}`)),i.length)r.push(""),r.push(...i.map((o,a)=>`(${a+11}) ${Ea(o)}`)),r.push("_11 番目以降はリアクションがないので、返信で答えてください。_");r.push(""),r.push(s?"_下のリアクションを 1 つ押すと回答になります。当てはまるものがなければ、このメッセージの *スレッド* で返信してください (チャンネルへの通常投稿は回答として拾いません)。_":"_下のリアクションを 1 つ押すと回答になります。当てはまるものがなければ、このメッセージに返信してください。_")}else r.push(""),r.push(s?"_このメッセージの *スレッド* で返信してください。本文がそのまま回答になります (チャンネルへの通常投稿は回答として拾いません)。_":"_このメッセージに返信してください。本文がそのまま回答になります。_");return r.join(`
|
|
128
128
|
`)}function _a(e,t,n){let i=t.answer.split(`
|
|
129
129
|
`).map((s)=>`> ${s}`).join(`
|
|
130
130
|
`);return`${Di}*${e}*
|
|
@@ -133,77 +133,78 @@ _${t.how}で回答済み${n?` (${n})`:""}_
|
|
|
133
133
|
${i}`}function Sa(e){let t=e.split(`
|
|
134
134
|
`);if(e.startsWith(Di)){let l=t[0].slice(Di.length).replace(/^\*/,"").replace(/\*$/,""),d=t.filter((h)=>h.startsWith("> ")).map((h)=>h.slice(2)).join(`
|
|
135
135
|
`);if(!d)return{kind:"other"};return{kind:"resolved",question:l,answer:d}}let n=t[t.length-1]??"",i,s;switch(n){case"_下のリアクションを 1 つ押すと回答になります。当てはまるものがなければ、このメッセージの *スレッド* で返信してください (チャンネルへの通常投稿は回答として拾いません)。_":i=!0,s=!0;break;case"_下のリアクションを 1 つ押すと回答になります。当てはまるものがなければ、このメッセージに返信してください。_":i=!1,s=!0;break;case"_このメッセージの *スレッド* で返信してください。本文がそのまま回答になります (チャンネルへの通常投稿は回答として拾いません)。_":i=!0,s=!1;break;case"_このメッセージに返信してください。本文がそのまま回答になります。_":i=!1,s=!1;break;default:return{kind:"other"}}let r=t[0].startsWith(":question: ")?t[0].slice(11):t[0];if(t[0]=r,!t[0].startsWith("*"))return{kind:"other"};let o=0;while(o<t.length&&!(t[o].endsWith("*")&&(o>0||t[0].length>1)))o++;if(o>=t.length)return{kind:"other"};let a=t.slice(0,o+1).join(`
|
|
136
|
-
`).replace(/^\*/,"").replace(/\*$/,""),c=[],u=[];if(s){let f=t.length-2;if(
|
|
136
|
+
`).replace(/^\*/,"").replace(/\*$/,""),c=[],u=[];if(s){let f=t.length-2;if(jl(t[f]))f--;if(t[f]!=="")return{kind:"other"};if(f--,t[f]==="_11 番目以降はリアクションがないので、返信で答えてください。_"){f--;while(f>=0&&/^\(\d+\) /.test(t[f]))u.unshift(t[f].replace(/^\(\d+\) /,"")),f--;if(t[f]!=="")return{kind:"other"};f--}let l=[];while(f>=0){let d=t[f];if(!Me.some((h)=>d.startsWith(`${h.glyph} `)||d===h.glyph))break;l.unshift(d),f--}if(!l.length||l.length>es)return{kind:"other"};for(let d=0;d<l.length;d++){let h=Me[d].glyph;if(!(l[d].startsWith(`${h} `)||l[d]===h))return{kind:"other"};c.push(l[d].slice(h.length+1))}if(t[f]!=="")return{kind:"other"};if(f<o+1)return{kind:"other"};for(let d=0;d<u.length;d++)if(!t.includes(`(${d+11}) ${u[d]}`))return{kind:"other"}}return{kind:"open",question:a,reactable:c,overflow:u,threadOnly:i}}var Fi=[{name:"one",glyph:"1️⃣"},{name:"two",glyph:"2️⃣"},{name:"three",glyph:"3️⃣"},{name:"four",glyph:"4️⃣"},{name:"five",glyph:"5️⃣"},{name:"six",glyph:"6️⃣"},{name:"seven",glyph:"7️⃣"},{name:"eight",glyph:"8️⃣"},{name:"nine",glyph:"9️⃣"},{name:"keycap_ten",glyph:"\uD83D\uDD1F"}],kg=Fi.length;function Ci(e){let t=e.split(`
|
|
137
137
|
`),n=t[t.length-2];if(n===void 0||!n.startsWith("_:warning: 同時に複数選ばれているため回答として数えていません — どれか 1 つだけ残してください: ")||!n.endsWith("_"))return[];return[...n.matchAll(/<@([UW][A-Z0-9]+)>/g)].map((i)=>i[1])}function ka(e,t){let n=e.split(`
|
|
138
138
|
`);if(n.length<2)return e;if(Ci(e).length)n.splice(n.length-2,1);if(t.length)n.splice(n.length-1,0,`${"_:warning: 同時に複数選ばれているため回答として数えていません — どれか 1 つだけ残してください: "}${t.map((s)=>`<@${s}>`).join(", ")}_`);let i=n.join(`
|
|
139
|
-
`);return i===e?e:i}function Aa(e){return e!==void 0&&e.startsWith("_:warning: 同時に複数選ばれているため回答として数えていません — どれか 1 つだけ残してください: ")&&e.endsWith("_")}var
|
|
140
|
-
`),s?[]:o)}function
|
|
139
|
+
`);return i===e?e:i}function Aa(e){return e!==void 0&&e.startsWith("_:warning: 同時に複数選ばれているため回答として数えていません — どれか 1 つだけ残してください: ")&&e.endsWith("_")}var Ll="white_check_mark",Ag=`:${Ll}: `;var Be=Fi,Ht=Be.length,cn="ballot_box_with_ballot",Ei=`:${cn}: `,Oa="_下のリアクションで投票してください (1 人 1 票、押し直しで変更できます)。_",Ia="_下のリアクションで投票してください (当てはまるものを *いくつでも* 押せます)。_",ns="_締切: ",ss="_",Si="bar_chart",xi=`:${Si}: `;function is(e){return`:${Be[e].name}:`}function $a(e,t){for(let n of[is(t),Be[t].glyph])if(e.startsWith(`${n} `))return e.slice(n.length+1);return null}function Wl(e){return Be.some((t,n)=>e.startsWith(`${is(n)} `)||e.startsWith(`${t.glyph} `))}function _i(e){return e.replace(/\s*\n\s*/g," ")}function Ta(e,t,n,i={}){let s=!!i.multi,r=i.deadline??"",o=i.invalid??[];if(!n.length||n.length>Ht)throw Error(`poll needs 1..${Ht} choices, got ${n.length}`);let a=[`${Ei}*${e}*`];if(t)a.push("",t);if(a.push(""),a.push(...n.map((c,u)=>`${is(u)} ${_i(c)}`)),a.push(""),r)a.push(`${ns}${_i(r)}${ss}`);return a.push(s?Ia:Oa),ka(a.join(`
|
|
140
|
+
`),s?[]:o)}function Pa(e,t){let n=t.reduce((s,r)=>s+r.count,0),i=[`${xi}*${e}*`,`_投票終了 (計 ${n} 票)_`,""];return i.push(...t.map((s,r)=>`${is(r)} ×${s.count} ${_i(s.choice)}`)),i.join(`
|
|
141
141
|
`)}function Ra(e){let t=e.split(`
|
|
142
142
|
`);if(e.startsWith(xi)){let d=t[0].slice(xi.length).replace(/^\*/,"").replace(/\*$/,""),h=[];for(let m=0;m<Be.length;m++){let p=t.map((E)=>$a(E,m)).find((E)=>E!==null&&E.startsWith("×"));if(p===void 0)break;let y=/^×(\d+) (.*)$/.exec(p);if(!y)return{kind:"other"};h.push({choice:y[2],count:Number(y[1])})}if(!h.length)return{kind:"other"};return{kind:"closed",question:d,tallies:h}}let n=t[t.length-1]??"",i;if(n===Oa)i=!1;else if(n===Ia)i=!0;else return{kind:"other"};if(t[0].startsWith(Ei))t[0]=t[0].slice(Ei.length);if(!t[0].startsWith("*"))return{kind:"other"};let s=0;while(s<t.length&&!(t[s].endsWith("*")&&(s>0||t[0].length>1)))s++;if(s>=t.length)return{kind:"other"};let r=t.slice(0,s+1).join(`
|
|
143
|
-
`).replace(/^\*/,"").replace(/\*$/,""),o=t.length-2,a=Ci(e);if(Aa(t[o]))o--;let c="",u=t[o];if(u!==void 0&&u.startsWith(ns)&&u.endsWith(ss)&&u.length>ns.length+ss.length)c=u.slice(ns.length,-ss.length),o--;if(t[o]!=="")return{kind:"other"};o--;let f=[];while(o>=0){let d=t[o];if(!
|
|
143
|
+
`).replace(/^\*/,"").replace(/\*$/,""),o=t.length-2,a=Ci(e);if(Aa(t[o]))o--;let c="",u=t[o];if(u!==void 0&&u.startsWith(ns)&&u.endsWith(ss)&&u.length>ns.length+ss.length)c=u.slice(ns.length,-ss.length),o--;if(t[o]!=="")return{kind:"other"};o--;let f=[];while(o>=0){let d=t[o];if(!Wl(d))break;f.unshift(d),o--}if(!f.length||f.length>Ht)return{kind:"other"};let l=[];for(let d=0;d<f.length;d++){let h=$a(f[d],d);if(h===null)return{kind:"other"};l.push(h)}if(t[o]!=="")return{kind:"other"};if(o<s+1)return{kind:"other"};return{kind:"open",question:r,choices:l,multi:i,deadline:c,invalid:a}}function Ma(e,t,n,i){let s=new Map(t.map((u)=>[u.name,u.users])),r=e.map((u,f)=>(s.get(Be[f].name)??[]).filter((l)=>!n.has(l))),o=[];if(!i){let u=new Map;for(let f of r)for(let l of f)u.set(l,(u.get(l)??0)+1);for(let[f,l]of u)if(l>1)o.push(f)}let a=new Set(o),c=r.map((u)=>u.filter((f)=>!a.has(f)));return{tallies:e.map((u,f)=>({choice:u,count:c[f].length})),voters:c,ambiguous:o}}class qt extends Error{retryAfter;constructor(e){super(`Slack rate limited — retry after ${e}s`);this.name="RateLimitError",this.retryAfter=e}}function ki(){return(process.env.SLACK_API_BASE??"https://slack.com/api").replace(/\/$/,"")}async function Na(e,t,n,i){let s={};if(i)s.Cookie=`d=${i}`;let r=await fetch(`${ki()}/${t}`,{...n,headers:{...n.headers??{},Authorization:`Bearer ${e}`,...s}});if(r.status===429){let a=parseInt(r.headers.get("retry-after")??"60",10);throw new qt(isNaN(a)?60:a)}let o=await r.json();if(o.ok!==!0){let a=o.error??"unknown";if(a==="ratelimited")throw new qt(60);if(a==="invalid_auth"&&e.startsWith("xoxc-")&&!i)throw Error(`Desktop app token (xoxc-) needs its session cookie to be accepted by the public Slack API.
|
|
144
144
|
Attach it: slack auth chrome (macOS) or slack auth firefox
|
|
145
145
|
Or replace the token with an xoxp- user token:
|
|
146
146
|
slack auth token`);if((a==="missing_scope"||a==="cannot_dm_bot")&&e.startsWith("xoxb-"))throw Error(`Slack error on ${t}: ${a} — ${a==="cannot_dm_bot"?`you're authenticated as a bot, so "@you" is the bot itself and it can't DM itself`:"this bot token lacks the user scope this action needs"}.
|
|
147
147
|
Tailing/DMing people and listing users need a user session, not a bot token.
|
|
148
148
|
Switch workspace: slack auth ls then slack auth use <name>
|
|
149
|
-
Or import your Slack desktop session: slack auth login`);throw Error(`Slack error on ${t}: ${a}`)}return o}async function
|
|
149
|
+
Or import your Slack desktop session: slack auth login`);throw Error(`Slack error on ${t}: ${a}`)}return o}async function Ul(e,t,n,i){let s={};if(i)s.Cookie=`d=${i}`;let r=await fetch(`${ki()}/${t}`,{...n,headers:{...n.headers??{},Authorization:`Bearer ${e}`,...s}});if(r.status===429){let a=parseInt(r.headers.get("retry-after")??"60",10);throw new qt(isNaN(a)?60:a)}let o=await r.json();if(o.ok!==!0){let a=o.error??"unknown";if(a==="ratelimited")throw new qt(60);if((a==="invalid_auth"||a==="not_authed")&&!e.startsWith("xoxc-"))throw Error(`The draft API requires a desktop app session token (xoxc-).
|
|
150
150
|
Import from Slack desktop: slack auth login`);if((a==="invalid_auth"||a==="not_authed")&&!i)throw Error(`drafts.list also requires the xoxd session cookie.
|
|
151
|
-
Attach it with: slack auth chrome (macOS) or slack auth firefox`);throw Error(`Slack error on ${t}: ${a}`)}return o}function Pt(e,t,n={},i){let s=new URLSearchParams({token:e,...n});return Wl(e,t,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s.toString()},i)}function ie(e,t,n,i){let s=new URLSearchParams(n).toString();return Na(e,`${t}?${s}`,{method:"GET"},i)}function Je(e,t,n,i){return Na(e,t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)},i)}async function va(e,t){let n=await ie(e,"auth.test",{},t);return{team:n.team??"",teamId:n.team_id??"",url:n.url??"",user:n.user??"",userId:n.user_id??""}}async function ja(e,t){let n={Authorization:`Bearer ${e}`};if(t)n.Cookie=`d=${t}`;let i=await fetch(`${ki()}/auth.test`,{method:"GET",headers:n});if(i.status===429){let o=parseInt(i.headers.get("retry-after")??"60",10);throw new qt(isNaN(o)?60:o)}let s=i.headers.get("x-oauth-scopes")??"",r=await i.json();if(r.ok!==!0)throw Error(`Slack error on auth.test: ${r.error??"unknown"}`);return{userId:r.user_id??"",user:r.user??"",botId:r.bot_id??"",team:r.team??"",url:r.url??"",scopes:s.split(",").map((o)=>o.trim()).filter(Boolean)}}async function Ze(e,t,n=20,i,s,r,o){let a={channel:t,limit:String(n)};if(i!==void 0)a.oldest=i;if(s!==void 0)a.cursor=s;if(o)a.inclusive="true";return ie(e,"conversations.history",a,r)}async function Ke(e,t,n,i=50,s){return ie(e,"conversations.replies",{channel:t,ts:n,limit:String(i)},s)}async function La(e,t,n){return ie(e,"files.info",{file:t},n)}async function Wa(e,t={},n){let i={count:String(Math.min(Math.max(t.count??100,1),200)),page:String(Math.max(t.page??1,1))};if(t.types)i.types=t.types;if(t.channel)i.channel=t.channel;if(t.user)i.user=t.user;return ie(e,"files.list",i,n)}async function Ua(e,t,n={},i){let s={list_id:t};if(n.limit)s.limit=String(n.limit);if(n.cursor)s.cursor=n.cursor;return Pt(e,"lists.records.list",s,i)}async function Ja(e,t,n,i,s){return ie(e,"search.messages",{query:t,sort:"timestamp",sort_dir:"desc",count:String(Math.min(Math.max(n,1),100)),page:String(Math.max(i,1))},s)}async function Ka(e,t,n){return Ja(e,t,100,1,n)}async function Ai(e,t,n,i){let r=1,o=[],a={ok:!0,messages:{}};while(!0){let u=await Ja(e,t,100,r,i),f=un(u,["messages","matches"]),l=Array.isArray(f)?f:[];o.push(...l);let d=Number(un(u,["messages","paging","pages"])??1);if(a=u,l.length===0||r>=d||o.length>=n)break;r+=1}let c=a;if(!c.messages)c.messages={};return c.messages.matches=o.slice(0,n),c}async function rs(e,t,n,i,s,r,o){let a=o?{channel:t,text:n}:{channel:t,text:n,blocks:[{type:"markdown",text:n}]};if(i!==void 0)a.thread_ts=i;if(s&&i!==void 0)a.reply_broadcast=!0;return(await Je(e,"chat.postMessage",a,r)).ts??""}async function za(e,t,n,i,s,r){let o={channel:t,text:n,post_at:i,blocks:[{type:"markdown",text:n}]};if(s!==void 0)o.thread_ts=s;return(await Je(e,"chat.scheduleMessage",o,r)).scheduled_message_id??""}async function Ha(e,t,n){let i={};if(t)i.channel=t;return ie(e,"chat.scheduledMessages.list",i,n)}async function qa(e,t,n,i){await Je(e,"chat.deleteScheduledMessage",{channel:t,scheduled_message_id:n},i)}async function ln(e,t,n,i){return(await ie(e,"chat.getPermalink",{channel:t,message_ts:n},i)).permalink??""}async function Yt(e,t,n,i,s,r){return(await Je(e,"chat.update",r?{channel:t,ts:n,text:i}:{channel:t,ts:n,text:i,blocks:[{type:"markdown",text:i}]},s)).ts??n}async function Ya(e,t,n,i){await Je(e,"chat.delete",{channel:t,ts:n},i)}async function ct(e,t,n,i,s){await Je(e,"reactions.add",{channel:t,timestamp:n,name:i},s)}async function Xa(e,t,n,i){return((await ie(e,"reactions.get",{channel:t,timestamp:n,full:"true"},i)).message?.reactions??[]).map((r)=>({name:String(r.name??""),users:Array.isArray(r.users)?r.users.map(String):[]}))}async function fn(e,t,n,i,s){await Je(e,"reactions.remove",{channel:t,timestamp:n,name:i},s)}async function Ga(e,t,n=!1,i){let s=await Je(e,"conversations.create",{name:t,is_private:n},i);return{id:s.channel?.id??"",name:s.channel?.name??t}}async function Va(e,t,n,i){await Je(e,"conversations.invite",{channel:t,users:n.join(",")},i)}async function dn(e,t){let n=[],i="";while(!0){let s={limit:"200",types:"public_channel,private_channel,im,mpim"};if(i)s.cursor=i;let r=await ie(e,"conversations.list",s,t);if(n.push(...r.channels??[]),i=r.response_metadata?.next_cursor??"",!i)break}return{channels:n}}async function Tt(e,t,n){let s=(await Je(e,"conversations.open",{users:t},n)).channel?.id;if(!s)throw Error(`Failed to open DM with user ${t}`);return s}function Ve(e){return e.toLowerCase().replace(/[-_\s]/g,"")}async function pn(e,t,n){if(!t.startsWith("@")){if(/^[UW][A-Za-z0-9]{6,}$/.test(t))return t;throw Error(`Expected @user or a user ID, got: ${t}`)}let i=Ve(t.slice(1)),s=await ie(e,"auth.test",{},n);if(i==="you"||i==="me"||Ve(s.user??"")===i){if(!s.user_id)throw Error("auth.test did not return user_id");return s.user_id}let r="";while(!0){let o={limit:"200"};if(r)o.cursor=r;let a=await ie(e,"users.list",o,n);for(let c of a.members??[]){let u=Ve(c.name??""),f=Ve(c.real_name??""),l=Ve(c.profile?.display_name??"");if(u===i||f===i||l&&l===i)return c.id??""}if(r=a.response_metadata?.next_cursor??"",!r)break}throw Error(`User not found: ${t}`)}function Rt(e){let t=e.match(/(?:app\.slack\.com\/client\/T[A-Za-z0-9]+|[A-Za-z0-9-]+\.slack\.com\/archives)\/([A-Za-z0-9]+)(?:\/p(\d{10})(\d{6}))?/);if(!t)return;let n=t[1],i=t[2]&&t[3]?`${t[2]}.${t[3]}`:void 0,s=e.indexOf("?"),r=s>=0?new URLSearchParams(e.slice(s)):void 0,o=r?.get("thread_ts")??void 0,u={channel:r?.get("cid")??void 0??n};if(i)u.ts=i;if(o)u.threadTs=o;return u}function Ul(e){return Rt(e)?.channel}function Ba(e){return/^[CDG][A-Z0-9]{8,}$/.test(e)}async function De(e,t,n){let i=Ul(t);if(i)return i;if(!t.startsWith("@")&&!t.startsWith("#")){if(Ba(t))return t;throw Error(`Target must start with # or @ (or be a Slack URL/ID), got: ${t}`)}if(t.startsWith("#")&&Ba(t.slice(1)))return t.slice(1);let s=t.startsWith("@"),r=t.slice(1),o=Ve(r);if(s){let u=await ie(e,"auth.test",{},n);if(o==="you"||o==="me"||Ve(u.user??"")===o){let m=u.user_id;if(!m)throw Error("auth.test did not return user_id");let y=((await ie(e,"conversations.list",{types:"im",limit:"200"},n)).channels??[]).find((E)=>E.user===m);if(y?.id)return String(y.id);return Tt(e,m,n)}let l="",d="";while(!0){let m={limit:"200"};if(d)m.cursor=d;let p=await ie(e,"users.list",m,n);for(let y of p.members??[]){let E=Ve(y.name??""),F=Ve(y.real_name??""),k=Ve(y.profile?.display_name??"");if(E===o||F===o||k&&k===o){l=y.id??"";break}}if(l)break;if(d=p.response_metadata?.next_cursor??"",!d)break}if(!l)throw Error(`User not found: ${t}`);let h="";while(!0){let m={types:"im",limit:"200"};if(h)m.cursor=h;let p=await ie(e,"conversations.list",m,n);for(let y of p.channels??[])if(y.user===l)return String(y.id??"");if(h=p.response_metadata?.next_cursor??"",!h)break}throw Error(`No existing DM with ${t} (${l}). Open it once in Slack first.`)}let a=r.toLowerCase(),c="";while(!0){let u={limit:"200",types:"public_channel,private_channel",exclude_archived:"true"};if(c)u.cursor=c;let f=await ie(e,"conversations.list",u,n);for(let l of f.channels??[])if(String(l.name??"").toLowerCase()===a)return String(l.id??"");if(c=f.response_metadata?.next_cursor??"",!c)break}throw Error(`channel not found: ${t}`)}async function hn(e,t,n){try{let i=await ie(e,"users.info",{user:t},n),s=i.user?.profile?.display_name,r=s&&s.length>0?s:i.user?.real_name??i.user?.name??t,o=i.user?.name??t;return[r,o]}catch{return[t,t]}}async function ze(e,t,n){try{let i=await ie(e,"users.info",{user:t},n),s=i.user?.profile?.display_name;if(s&&s.length>0)return s;return i.user?.real_name??i.user?.name??t}catch{return t}}async function $i(e,t){let n=[],i="";while(!0){let s={limit:"200"};if(i)s.cursor=i;let r=await ie(e,"users.list",s,t);if(n.push(...r.members??[]),i=r.response_metadata?.next_cursor??"",!i)break}return{members:n}}async function Za(e,t,n){let i=[],s="";while(!0){let r={channel:t,limit:"200"};if(s)r.cursor=s;let o=await ie(e,"conversations.members",r,n);if(i.push(...o.members??[]),s=o.response_metadata?.next_cursor??"",!s)break}return i}async function gn(e,t){return Pt(e,"drafts.list",{},t)}async function Qa(e,t,n,i){let{randomUUID:s}=await import("node:crypto"),r=JSON.stringify([{type:"rich_text",elements:[{type:"rich_text_section",elements:[{type:"text",text:n}]}]}]);return Pt(e,"drafts.create",{client_msg_id:s(),destinations:JSON.stringify([{channel_id:t}]),blocks:r,file_ids:JSON.stringify([]),is_from_composer:"true"},i)}async function ec(e,t,n,i,s){let r=JSON.stringify([{type:"rich_text",elements:[{type:"rich_text_section",elements:[{type:"text",text:i}]}]}]),o=(Date.now()/1000).toFixed(6);return Pt(e,"drafts.update",{draft_id:t,client_last_updated_ts:o,destinations:JSON.stringify([{channel_id:n}]),blocks:r,file_ids:JSON.stringify([])},s)}async function tc(e,t,n){return Pt(e,"conversations.info",{channel:t},n)}async function os(e,t,n){return ie(e,"users.info",{user:t},n)}async function mn(e,t,n){return ie(e,"conversations.info",{channel:t},n)}async function nc(e,t,n){let i=(Date.now()/1000).toFixed(6);return Pt(e,"drafts.delete",{draft_id:t,client_last_updated_ts:i},n)}async function Oi(e,t){let n=await Pt(e,"auth.test",{},t);return{userId:String(n.user_id??""),teamId:String(n.team_id??"")}}async function sc(e,t,n,i={},s){let{statSync:r,readFileSync:o}=await import("node:fs"),{basename:a}=await import("node:path"),c=r(n),u=a(n),f=await ie(e,"files.getUploadURLExternal",{filename:u,length:String(c.size)},s),l=f.upload_url,d=f.file_id;if(!l||!d)throw Error("files.getUploadURLExternal returned no upload_url/file_id");let h=o(n),m=await fetch(l,{method:"POST",headers:{"Content-Type":"application/octet-stream"},body:h});if(!m.ok)throw Error(`Upload PUT failed: ${m.status} ${m.statusText}`);let p={files:[{id:d,title:i.title??u}],channel_id:t};if(i.threadTs)p.thread_ts=i.threadTs;if(i.initialComment)p.initial_comment=i.initialComment;let y=await Je(e,"files.completeUploadExternal",p,s),E={fileId:d},F=y.files?.[0]?.permalink;if(F)E.permalink=F;return E}function un(e,t){let n=e;for(let i of t){if(n===void 0||n===null)return;if(typeof i==="number"){if(!Array.isArray(n))return;n=n[i]??void 0}else{if(typeof n!=="object"||Array.isArray(n))return;n=n[i]}}return n}import{existsSync as Zl,readFileSync as Ql}from"node:fs";import{homedir as ef}from"node:os";import{join as tf}from"node:path";import{existsSync as Jl,mkdirSync as Kl,readFileSync as zl,writeFileSync as Hl}from"node:fs";import{homedir as ql}from"node:os";import{dirname as Yl,join as Xl}from"node:path";var Gl=3600000,as={now:()=>Date.now(),path:()=>Xl(process.env.HOME||ql(),".config","slack-cli","cache.json")},cs=!0,ut;function ic(){return{channels:{},users:{}}}function Ii(){if(ut)return ut;if(ut=ic(),!cs)return ut;try{let e=as.path();if(!Jl(e))return ut;let t=JSON.parse(zl(e,"utf8"));for(let n of["channels","users"]){let i=t?.[n];if(!i||typeof i!=="object"||Array.isArray(i))continue;for(let[s,r]of Object.entries(i))if(r&&typeof r==="object"&&typeof r.value==="string"&&typeof r.expires==="number")ut[n][s]={value:r.value,expires:r.expires}}}catch{ut=ic()}return ut}function Vl(e){if(!cs)return;try{let t=as.path();Kl(Yl(t),{recursive:!0}),Hl(t,JSON.stringify(e,null,2)+`
|
|
152
|
-
`)}catch{}}function rc(e,t){return e?`${e} ${t}`:void 0}function
|
|
153
|
-
`)[0]??"",emoji:F,keep:F[0]})}if(f=h.response_metadata?.next_cursor||void 0,!f||m.length===0)break;if(u>=s){l=!0;break}}if(i.fix)for(let d of c)try{try{await Ae("reactions.add",()=>Wn(e,t,d.ts,d.keep,r))}catch(h){if(!(h instanceof Error)||!/already_reacted/.test(h.message))throw h}for(let h of d.emoji){if(h===d.keep)continue;await Ae("reactions.remove",()=>Un(e,t,d.ts,h,r))}d.fixed=!0}catch(h){d.fixed=!1,d.error=h instanceof Error?h.message:String(h)}return{scanned:u,findings:c,truncated:l}}var
|
|
154
|
-
`)),r=await Bt(e,t,n,i.cookie);for(let o of yn(r.unresolved))s(`warn: ${o}`);return r.text}var yc=["さん","さま","様","君","くん","ちゃん","氏","先生","先輩","殿","老师","老師","兄","姐","哥","姐妹"],wc="\\p{Script=Han}\\p{Script=Hiragana}\\p{Script=Katakana}A-Za-z0-9";function ji(e){return/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}]/u.test(e)}function
|
|
155
|
-
|
|
156
|
-
`)
|
|
151
|
+
Attach it with: slack auth chrome (macOS) or slack auth firefox`);throw Error(`Slack error on ${t}: ${a}`)}return o}function Tt(e,t,n={},i){let s=new URLSearchParams({token:e,...n});return Ul(e,t,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s.toString()},i)}function ie(e,t,n,i){let s=new URLSearchParams(n).toString();return Na(e,`${t}?${s}`,{method:"GET"},i)}function Je(e,t,n,i){return Na(e,t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)},i)}async function va(e,t){let n=await ie(e,"auth.test",{},t);return{team:n.team??"",teamId:n.team_id??"",url:n.url??"",user:n.user??"",userId:n.user_id??""}}async function ja(e,t){let n={Authorization:`Bearer ${e}`};if(t)n.Cookie=`d=${t}`;let i=await fetch(`${ki()}/auth.test`,{method:"GET",headers:n});if(i.status===429){let o=parseInt(i.headers.get("retry-after")??"60",10);throw new qt(isNaN(o)?60:o)}let s=i.headers.get("x-oauth-scopes")??"",r=await i.json();if(r.ok!==!0)throw Error(`Slack error on auth.test: ${r.error??"unknown"}`);return{userId:r.user_id??"",user:r.user??"",botId:r.bot_id??"",team:r.team??"",url:r.url??"",scopes:s.split(",").map((o)=>o.trim()).filter(Boolean)}}async function Ze(e,t,n=20,i,s,r,o){let a={channel:t,limit:String(n)};if(i!==void 0)a.oldest=i;if(s!==void 0)a.cursor=s;if(o)a.inclusive="true";return ie(e,"conversations.history",a,r)}async function Ke(e,t,n,i=50,s){return ie(e,"conversations.replies",{channel:t,ts:n,limit:String(i)},s)}async function La(e,t,n){return ie(e,"files.info",{file:t},n)}async function Wa(e,t={},n){let i={count:String(Math.min(Math.max(t.count??100,1),200)),page:String(Math.max(t.page??1,1))};if(t.types)i.types=t.types;if(t.channel)i.channel=t.channel;if(t.user)i.user=t.user;return ie(e,"files.list",i,n)}async function Ua(e,t,n={},i){let s={list_id:t};if(n.limit)s.limit=String(n.limit);if(n.cursor)s.cursor=n.cursor;return Tt(e,"lists.records.list",s,i)}async function Ja(e,t,n,i,s){return ie(e,"search.messages",{query:t,sort:"timestamp",sort_dir:"desc",count:String(Math.min(Math.max(n,1),100)),page:String(Math.max(i,1))},s)}async function Ka(e,t,n){return Ja(e,t,100,1,n)}async function Ai(e,t,n,i){let r=1,o=[],a={ok:!0,messages:{}};while(!0){let u=await Ja(e,t,100,r,i),f=un(u,["messages","matches"]),l=Array.isArray(f)?f:[];o.push(...l);let d=Number(un(u,["messages","paging","pages"])??1);if(a=u,l.length===0||r>=d||o.length>=n)break;r+=1}let c=a;if(!c.messages)c.messages={};return c.messages.matches=o.slice(0,n),c}async function rs(e,t,n,i,s,r,o){let a=o?{channel:t,text:n}:{channel:t,text:n,blocks:[{type:"markdown",text:n}]};if(i!==void 0)a.thread_ts=i;if(s&&i!==void 0)a.reply_broadcast=!0;return(await Je(e,"chat.postMessage",a,r)).ts??""}async function za(e,t,n,i,s,r){let o={channel:t,text:n,post_at:i,blocks:[{type:"markdown",text:n}]};if(s!==void 0)o.thread_ts=s;return(await Je(e,"chat.scheduleMessage",o,r)).scheduled_message_id??""}async function Ha(e,t,n){let i={};if(t)i.channel=t;return ie(e,"chat.scheduledMessages.list",i,n)}async function qa(e,t,n,i){await Je(e,"chat.deleteScheduledMessage",{channel:t,scheduled_message_id:n},i)}async function ln(e,t,n,i){return(await ie(e,"chat.getPermalink",{channel:t,message_ts:n},i)).permalink??""}async function Yt(e,t,n,i,s,r){return(await Je(e,"chat.update",r?{channel:t,ts:n,text:i}:{channel:t,ts:n,text:i,blocks:[{type:"markdown",text:i}]},s)).ts??n}async function Ya(e,t,n,i){await Je(e,"chat.delete",{channel:t,ts:n},i)}async function ct(e,t,n,i,s){await Je(e,"reactions.add",{channel:t,timestamp:n,name:i},s)}async function Xa(e,t,n,i){return((await ie(e,"reactions.get",{channel:t,timestamp:n,full:"true"},i)).message?.reactions??[]).map((r)=>({name:String(r.name??""),users:Array.isArray(r.users)?r.users.map(String):[]}))}async function fn(e,t,n,i,s){await Je(e,"reactions.remove",{channel:t,timestamp:n,name:i},s)}async function Ga(e,t,n=!1,i){let s=await Je(e,"conversations.create",{name:t,is_private:n},i);return{id:s.channel?.id??"",name:s.channel?.name??t}}async function Va(e,t,n,i){await Je(e,"conversations.invite",{channel:t,users:n.join(",")},i)}async function dn(e,t){let n=[],i="";while(!0){let s={limit:"200",types:"public_channel,private_channel,im,mpim"};if(i)s.cursor=i;let r=await ie(e,"conversations.list",s,t);if(n.push(...r.channels??[]),i=r.response_metadata?.next_cursor??"",!i)break}return{channels:n}}async function Pt(e,t,n){let s=(await Je(e,"conversations.open",{users:t},n)).channel?.id;if(!s)throw Error(`Failed to open DM with user ${t}`);return s}function Ve(e){return e.toLowerCase().replace(/[-_\s]/g,"")}async function pn(e,t,n){if(!t.startsWith("@")){if(/^[UW][A-Za-z0-9]{6,}$/.test(t))return t;throw Error(`Expected @user or a user ID, got: ${t}`)}let i=Ve(t.slice(1)),s=await ie(e,"auth.test",{},n);if(i==="you"||i==="me"||Ve(s.user??"")===i){if(!s.user_id)throw Error("auth.test did not return user_id");return s.user_id}let r="";while(!0){let o={limit:"200"};if(r)o.cursor=r;let a=await ie(e,"users.list",o,n);for(let c of a.members??[]){let u=Ve(c.name??""),f=Ve(c.real_name??""),l=Ve(c.profile?.display_name??"");if(u===i||f===i||l&&l===i)return c.id??""}if(r=a.response_metadata?.next_cursor??"",!r)break}throw Error(`User not found: ${t}`)}function Rt(e){let t=e.match(/(?:app\.slack\.com\/client\/T[A-Za-z0-9]+|[A-Za-z0-9-]+\.slack\.com\/archives)\/([A-Za-z0-9]+)(?:\/p(\d{10})(\d{6}))?/);if(!t)return;let n=t[1],i=t[2]&&t[3]?`${t[2]}.${t[3]}`:void 0,s=e.indexOf("?"),r=s>=0?new URLSearchParams(e.slice(s)):void 0,o=r?.get("thread_ts")??void 0,u={channel:r?.get("cid")??void 0??n};if(i)u.ts=i;if(o)u.threadTs=o;return u}function Jl(e){return Rt(e)?.channel}function Ba(e){return/^[CDG][A-Z0-9]{8,}$/.test(e)}async function De(e,t,n){let i=Jl(t);if(i)return i;if(!t.startsWith("@")&&!t.startsWith("#")){if(Ba(t))return t;throw Error(`Target must start with # or @ (or be a Slack URL/ID), got: ${t}`)}if(t.startsWith("#")&&Ba(t.slice(1)))return t.slice(1);let s=t.startsWith("@"),r=t.slice(1),o=Ve(r);if(s){let u=await ie(e,"auth.test",{},n);if(o==="you"||o==="me"||Ve(u.user??"")===o){let m=u.user_id;if(!m)throw Error("auth.test did not return user_id");let y=((await ie(e,"conversations.list",{types:"im",limit:"200"},n)).channels??[]).find((E)=>E.user===m);if(y?.id)return String(y.id);return Pt(e,m,n)}let l="",d="";while(!0){let m={limit:"200"};if(d)m.cursor=d;let p=await ie(e,"users.list",m,n);for(let y of p.members??[]){let E=Ve(y.name??""),F=Ve(y.real_name??""),k=Ve(y.profile?.display_name??"");if(E===o||F===o||k&&k===o){l=y.id??"";break}}if(l)break;if(d=p.response_metadata?.next_cursor??"",!d)break}if(!l)throw Error(`User not found: ${t}`);let h="";while(!0){let m={types:"im",limit:"200"};if(h)m.cursor=h;let p=await ie(e,"conversations.list",m,n);for(let y of p.channels??[])if(y.user===l)return String(y.id??"");if(h=p.response_metadata?.next_cursor??"",!h)break}throw Error(`No existing DM with ${t} (${l}). Open it once in Slack first.`)}let a=r.toLowerCase(),c="";while(!0){let u={limit:"200",types:"public_channel,private_channel",exclude_archived:"true"};if(c)u.cursor=c;let f=await ie(e,"conversations.list",u,n);for(let l of f.channels??[])if(String(l.name??"").toLowerCase()===a)return String(l.id??"");if(c=f.response_metadata?.next_cursor??"",!c)break}throw Error(`channel not found: ${t}`)}async function hn(e,t,n){try{let i=await ie(e,"users.info",{user:t},n),s=i.user?.profile?.display_name,r=s&&s.length>0?s:i.user?.real_name??i.user?.name??t,o=i.user?.name??t;return[r,o]}catch{return[t,t]}}async function ze(e,t,n){try{let i=await ie(e,"users.info",{user:t},n),s=i.user?.profile?.display_name;if(s&&s.length>0)return s;return i.user?.real_name??i.user?.name??t}catch{return t}}async function $i(e,t){let n=[],i="";while(!0){let s={limit:"200"};if(i)s.cursor=i;let r=await ie(e,"users.list",s,t);if(n.push(...r.members??[]),i=r.response_metadata?.next_cursor??"",!i)break}return{members:n}}async function Za(e,t,n){let i=[],s="";while(!0){let r={channel:t,limit:"200"};if(s)r.cursor=s;let o=await ie(e,"conversations.members",r,n);if(i.push(...o.members??[]),s=o.response_metadata?.next_cursor??"",!s)break}return i}async function gn(e,t){return Tt(e,"drafts.list",{},t)}async function Qa(e,t,n,i){let{randomUUID:s}=await import("node:crypto"),r=JSON.stringify([{type:"rich_text",elements:[{type:"rich_text_section",elements:[{type:"text",text:n}]}]}]);return Tt(e,"drafts.create",{client_msg_id:s(),destinations:JSON.stringify([{channel_id:t}]),blocks:r,file_ids:JSON.stringify([]),is_from_composer:"true"},i)}async function ec(e,t,n,i,s){let r=JSON.stringify([{type:"rich_text",elements:[{type:"rich_text_section",elements:[{type:"text",text:i}]}]}]),o=(Date.now()/1000).toFixed(6);return Tt(e,"drafts.update",{draft_id:t,client_last_updated_ts:o,destinations:JSON.stringify([{channel_id:n}]),blocks:r,file_ids:JSON.stringify([])},s)}async function tc(e,t,n){return Tt(e,"conversations.info",{channel:t},n)}async function os(e,t,n){return ie(e,"users.info",{user:t},n)}async function mn(e,t,n){return ie(e,"conversations.info",{channel:t},n)}async function nc(e,t,n){let i=(Date.now()/1000).toFixed(6);return Tt(e,"drafts.delete",{draft_id:t,client_last_updated_ts:i},n)}async function Oi(e,t){let n=await Tt(e,"auth.test",{},t);return{userId:String(n.user_id??""),teamId:String(n.team_id??"")}}async function sc(e,t,n,i={},s){let{statSync:r,readFileSync:o}=await import("node:fs"),{basename:a}=await import("node:path"),c=r(n),u=a(n),f=await ie(e,"files.getUploadURLExternal",{filename:u,length:String(c.size)},s),l=f.upload_url,d=f.file_id;if(!l||!d)throw Error("files.getUploadURLExternal returned no upload_url/file_id");let h=o(n),m=await fetch(l,{method:"POST",headers:{"Content-Type":"application/octet-stream"},body:h});if(!m.ok)throw Error(`Upload PUT failed: ${m.status} ${m.statusText}`);let p={files:[{id:d,title:i.title??u}],channel_id:t};if(i.threadTs)p.thread_ts=i.threadTs;if(i.initialComment)p.initial_comment=i.initialComment;let y=await Je(e,"files.completeUploadExternal",p,s),E={fileId:d},F=y.files?.[0]?.permalink;if(F)E.permalink=F;return E}function un(e,t){let n=e;for(let i of t){if(n===void 0||n===null)return;if(typeof i==="number"){if(!Array.isArray(n))return;n=n[i]??void 0}else{if(typeof n!=="object"||Array.isArray(n))return;n=n[i]}}return n}import{existsSync as Ql,readFileSync as ef}from"node:fs";import{homedir as tf}from"node:os";import{join as nf}from"node:path";import{existsSync as Kl,mkdirSync as zl,readFileSync as Hl,writeFileSync as ql}from"node:fs";import{homedir as Yl}from"node:os";import{dirname as Xl,join as Gl}from"node:path";var Vl=3600000,as={now:()=>Date.now(),path:()=>Gl(process.env.HOME||Yl(),".config","slack-cli","cache.json")},cs=!0,ut;function ic(){return{channels:{},users:{}}}function Ii(){if(ut)return ut;if(ut=ic(),!cs)return ut;try{let e=as.path();if(!Kl(e))return ut;let t=JSON.parse(Hl(e,"utf8"));for(let n of["channels","users"]){let i=t?.[n];if(!i||typeof i!=="object"||Array.isArray(i))continue;for(let[s,r]of Object.entries(i))if(r&&typeof r==="object"&&typeof r.value==="string"&&typeof r.expires==="number")ut[n][s]={value:r.value,expires:r.expires}}}catch{ut=ic()}return ut}function Zl(e){if(!cs)return;try{let t=as.path();zl(Xl(t),{recursive:!0}),ql(t,JSON.stringify(e,null,2)+`
|
|
152
|
+
`)}catch{}}function rc(e,t){return e?`${e} ${t}`:void 0}function Ti(e,t,n){if(!cs)return;let i=rc(t,n);if(!i)return;let s=Ii()[e][i];if(!s)return;if(s.expires<=as.now()){delete Ii()[e][i];return}return s.value}function Pi(e,t,n,i,s=Vl){if(!cs)return;let r=rc(t,n);if(!r)return;let o=Ii();o[e][r]={value:i,expires:as.now()+s},Zl(o)}var Ri={marker:"pushpin",progress:{done:"white_check_mark",dropped:"no_entry_sign",doing:"eyes",pending:"hourglass_flowing_sand"},flags:{alert:"exclamation","needs-discussion":"thinking_face",waiting:"speech_balloon",blocked:"lock"}},Xt=["done","dropped","doing","pending"],cc=["alert","needs-discussion","waiting","blocked"];function sf(){return nf(process.env.HOME||tf(),".config","slack-cli","todo.json")}function us(e){return e.replace(/^:+|:+$/g,"")}function Dn(e=sf()){let t={marker:Ri.marker,progress:{...Ri.progress},flags:{...Ri.flags}};try{if(!Ql(e))return t;let n=JSON.parse(ef(e,"utf8"));if(typeof n.marker==="string"&&n.marker.trim())t.marker=us(n.marker.trim());for(let i of Xt){let s=n.progress?.[i];if(typeof s==="string"&&s.trim())t.progress[i]=us(s.trim())}for(let i of cc){let s=n.flags?.[i];if(typeof s==="string"&&s.trim())t.flags[i]=us(s.trim())}}catch{}return t}function oc(e,t,n=!1){return`${n?"-":""}${t?"has":"hasmy"}::${us(e)}:`}function uc(e,t,n={}){let i=n.shared===!0,s=(a)=>oc(a,i),r=(a)=>oc(a,i,!0),o=[];if(e==="untriaged")o.push(s(t.marker),...Xt.map((a)=>r(t.progress[a])));else if(e==="stuck")o.push(s(t.marker),r(t.progress.done),r(t.progress.dropped),`(${cc.map((a)=>s(t.flags[a])).join(" OR ")})`);else if(e==="open")o.push(s(t.marker),r(t.progress.done),r(t.progress.dropped));else{let a=Xt.indexOf(e);o.push(s(t.progress[e]));for(let c of Xt.slice(0,a))o.push(r(t.progress[c]))}if(n.in){let a=n.in.startsWith("#")||n.in.startsWith("@")?n.in:`#${n.in}`;o.push(`in:${a}`)}if(n.from){let a=n.from==="me"||n.from.startsWith("@")?n.from:`@${n.from}`;o.push(`from:${a}`)}return o.join(" ")}var rf=3,of={sleep:(e)=>new Promise((t)=>setTimeout(t,e))};async function Ae(e,t,n=rf){for(let i=0;;i++)try{return await t()}catch(s){if(!(s instanceof Ge))throw s;if(i>=n)throw Error(`Slack rate limit hit on ${e} — gave up after ${n} retries. Try again in a minute.`);console.error(`Warning: Slack rate limit hit on ${e} — backing off for ${s.retryAfter}s`),await of.sleep(s.retryAfter*1000)}}var ac=new Map;async function lc(e,t){let n=ac.get(e);if(n)return n;let i=await Ae("auth.test",()=>zt(e,t)),s={userId:i.userId,teamId:i.teamId};return ac.set(e,s),s}async function fc(e,t){return(await lc(e,t)).userId}async function dc(e,t){try{return(await lc(e,t)).teamId}catch{return""}}async function Mi(e,t,n,i){if(!t.startsWith("#"))return n(e,t,i);let s=await dc(e,i),r=Ti("channels",s,t);if(r)return r;let o=await Ae("resolveChannel",()=>n(e,t,i));return Pi("channels",s,t,o),o}async function pc(e,t,n,i){let s=await dc(e,i),r=Ti("users",s,t);if(r)return r;let o=await Ae("users.info",()=>n(e,t,i));if(o&&o!==t)Pi("users",s,t,o);return o}async function hc(e,t,n,i,s,r){let o=s.progress[i],a=await fc(e,r),c=await Ae("reactions.get",()=>Jo(e,t,n,r)),u=new Set(c.filter((h)=>h.users.includes(a)).map((h)=>h.name)),f=Xt.map((h)=>s.progress[h]).filter((h)=>u.has(h));if(f.length===1&&f[0]===o)return{noop:!0,removed:[],leftover:[]};if(!u.has(o))await Ae("reactions.add",()=>Wn(e,t,n,o,r));let l=[],d=[];for(let h of f){if(h===o)continue;try{await Ae("reactions.remove",()=>Un(e,t,n,h,r)),l.push(h)}catch{d.push(h)}}return{noop:!1,added:i,removed:l,leftover:d}}async function gc(e,t,n,i,s,r,o){let a=s.flags[i];if(r)await Ae("reactions.remove",()=>Un(e,t,n,a,o));else await Ae("reactions.add",()=>Wn(e,t,n,a,o));return a}var Bi=1000;async function mc(e,t,n,i={}){let s=i.limit??Bi,r=i.cookie,o=await fc(e,r),a=Xt.map((d)=>n.progress[d]),c=[],u=0,f,l=!1;while(u<s){let d=Math.min(200,s-u),h=await Ae("conversations.history",()=>on(e,t,d,void 0,f,r)),m=h.messages??[];u+=m.length;for(let p of m){let y=String(p.ts??"");if(!y)continue;let E=new Set((p.reactions??[]).filter((k)=>(k.users??[]).map(String).includes(o)).map((k)=>String(k.name??""))),F=a.filter((k)=>E.has(k));if(F.length<2)continue;c.push({ts:y,text:String(p.text??"").split(`
|
|
153
|
+
`)[0]??"",emoji:F,keep:F[0]})}if(f=h.response_metadata?.next_cursor||void 0,!f||m.length===0)break;if(u>=s){l=!0;break}}if(i.fix)for(let d of c)try{try{await Ae("reactions.add",()=>Wn(e,t,d.ts,d.keep,r))}catch(h){if(!(h instanceof Error)||!/already_reacted/.test(h.message))throw h}for(let h of d.emoji){if(h===d.keep)continue;await Ae("reactions.remove",()=>Un(e,t,d.ts,h,r))}d.fixed=!0}catch(h){d.fixed=!1,d.error=h instanceof Error?h.message:String(h)}return{scanned:u,findings:c,truncated:l}}var af=!0,cf;function Ni(e){if(af=e,!e)cf=void 0}function Mt(e){return e.toLowerCase().replace(/[-_\s]/g,"")}function lt(e){return e&&typeof e==="object"&&!Array.isArray(e)?e:{}}function uf(e,t){let n=Mt(t),i=lt(e.profile);for(let r of[e.name,e.real_name,i.display_name,i.real_name])if(typeof r==="string"&&r&&Mt(r)===n)return!0;let s=typeof i.email==="string"?i.email.toLowerCase():"";return s!==""&&s===t.toLowerCase()}function lf(e){let t=lt(e.profile),n=new Set;for(let i of[t.display_name,e.real_name,e.name,t.real_name])if(typeof i==="string"&&i){let s=Mt(i);if(s.length>=2)n.add(s)}return[...n]}function ff(e,t){let n=Mt(e),i,s=!1;for(let r of t){let o=typeof r.id==="string"?r.id:"";if(!o)continue;for(let a of lf(r)){let c=-1;if(n===a)c=e.length;else for(let u of yc)if(e.length>u.length&&e.endsWith(u)&&Mt(e.slice(0,e.length-u.length))===a){c=e.length-u.length;break}if(c<0)continue;if(!i||a.length>i.formLen)i={userId:o,matchLen:c,formLen:a.length,display:Li(r)},s=!1;else if(a.length===i.formLen&&i.userId!==o)s=!0}}if(!i)return;return s?"ambiguous":{userId:i.userId,matchLen:i.matchLen,display:i.display}}async function Bt(e,t,n,i){let s=`[${wc}ー]+`,r=`${s}(?:[._-]+${s})*`,o=new RegExp(`(?<![A-Za-z0-9._@<-])@(${r})`,"gu"),a=new Set;for(let F of t.matchAll(o))a.add(F[1]);if(a.size===0)return{text:t,resolved:[],unresolved:[]};let c=new Map;for(let F of a)c.set(F,{status:"pending"});let u=(F)=>{for(let k of a){if(c.get(k).status!=="pending")continue;if(ji(k)){let C=ff(k,F);if(C==="ambiguous")c.set(k,{status:"ambiguous"});else if(C)c.set(k,{status:"resolved",userId:C.userId,matchLen:C.matchLen,display:C.display})}else{let C=F.filter((P)=>uf(P,k)),A=new Set(C.map((P)=>typeof P.id==="string"?P.id:"").filter(Boolean));if(A.size===1){let P=C.find((v)=>typeof v.id==="string");c.set(k,{status:"resolved",userId:P.id,matchLen:k.length,display:Li(P)})}else if(A.size>1)c.set(k,{status:"ambiguous"})}}},f=!1;try{let F=await zn(e,i);u((F.members??[]).map(lt)),f=!0}catch{f=!1}let l=[...a].some((F)=>c.get(F).status==="pending"),d=!1,h=!0;if(l&&n){d=!0;try{let F=await ii(e,n,i),k=[];for(let C of F){let A=lt(await ri(e,C,i)),P=lt(A.user);if(typeof P.id!=="string")P.id=C;k.push(P)}u(k)}catch{h=!1}}let m=f&&(n?d&&h:!0),p=[],y=[];for(let F of a){let k=c.get(F);if(k.status==="resolved")p.push({surface:`@${F.slice(0,k.matchLen)}`,display:k.display,userId:k.userId});else if(k.status==="ambiguous")y.push({surface:`@${F}`,reason:"ambiguous"});else y.push({surface:`@${F}`,reason:m?"no-match":"unavailable"})}return{text:t.replace(o,(F,k)=>{let C=c.get(k);if(C&&C.status==="resolved")return`<@${C.userId}>${k.slice(C.matchLen)}`;return F}),resolved:p,unresolved:y}}function yn(e){let t=[],n=!1;for(let i of e)if(i.reason==="ambiguous")t.push(`${i.surface} matches multiple people — not tagged, sent as plain text (use <@USERID> to tag)`);else if(i.reason==="unavailable"){if(n)continue;t.push("could not fetch the user list (users:read missing or an API/connection error) — @mentions not tagged, sent as plain text"),n=!0}else t.push(`${i.surface} matched no one — not tagged, sent as plain text`);return t}async function Dc(e,t,n,i={}){let s=i.warn??((o)=>process.stderr.write(`${o}
|
|
154
|
+
`)),r=await Bt(e,t,n,i.cookie);for(let o of yn(r.unresolved))s(`warn: ${o}`);return r.text}var yc=["さん","さま","様","君","くん","ちゃん","氏","先生","先輩","殿","老师","老師","兄","姐","哥","姐妹"],wc="\\p{Script=Han}\\p{Script=Hiragana}\\p{Script=Katakana}A-Za-z0-9";function ji(e){return/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}]/u.test(e)}function df(e){let t=[],n=new RegExp(`([${wc}]{1,12})(${yc.join("|")})`,"gu");for(let i of e.matchAll(n))t.push({ref:i[1],honorific:i[2]});for(let i of e.matchAll(/\b(?:dear|hi|hello|hey)\b[ \t]+([A-Z][A-Za-z'’-]{1,20})/gi))t.push({ref:i[1],honorific:""});for(let i of e.matchAll(/(?:^|\n)[ \t]*([A-Z][A-Za-z'’-]{1,20}),/g))t.push({ref:i[1],honorific:""});return t}function pf(e){let t=lt(e.profile),n=new Set;for(let i of[e.name,e.real_name,t.display_name,t.real_name]){if(typeof i!=="string"||!i)continue;for(let s of[i,...i.split(/\s+/)]){let r=Mt(s);if(r.length>=2)n.add(r)}}return[...n]}function hf(e,t){let n=Mt(e);if(n.length<2)return;for(let i of t)if(n===i)return i;if(ji(e)){for(let i of t)if(n.includes(i)||i.includes(n))return i}return}function Li(e){return[lt(e.profile).display_name,e.real_name,e.name].filter((i)=>typeof i==="string"&&i!=="")[0]??String(e.id??"?")}async function bc(e,t,n){let i=df(t);if(i.length===0)return[];let s=new Set;for(let u of t.matchAll(/<@([A-Z0-9]+)(?:\|[^>]*)?>/g))s.add(u[1]);let o=((await zn(e,n)).members??[]).map(lt).filter((u)=>u.deleted!==!0&&u.is_bot!==!0&&u.id!=="USLACKBOT").map((u)=>({id:typeof u.id==="string"?u.id:"",forms:pf(u),display:Li(u)})).filter((u)=>u.id!==""),a=[],c=new Set;for(let{ref:u,honorific:f}of i)for(let l of o){let d=hf(u,l.forms);if(!d)continue;if(s.has(l.id)||c.has(l.id))break;c.add(l.id),a.push({surface:ji(u)?`${d}${f}`:u,display:l.display,userId:l.id});break}return a}async function Gt(e,t,n,i){let s=t,r=[],o=s,a=0;while(!0){let c=o.indexOf("<@U",a);if(c===-1)break;let u=o.slice(c+2),f=u.search(/[>|]/),l=f===-1?u:u.slice(0,f);if(l.length>=9)r.push(l);a=c+1}for(let c of r){if(!n.has(c))n.set(c,await Kn(e,c,i));let u=n.get(c)??c;s=s.replaceAll(`<@${c}>`,`@${u}`),s=s.replace(new RegExp(`<@${c}\\|[^>]*>`,"g"),`@${u}`)}return s}function wn(e){return e.replace(/<!date\^(\d+)\^[^|>]*(?:\|([^>]*))?>/g,(t,n,i)=>{let s=Number(n);if(!Number.isFinite(s))return i??"date";let r=new Date(s*1000);if(Number.isNaN(r.getTime()))return i??"date";let o=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],a=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],c=o[r.getUTCDay()]??"",u=a[r.getUTCMonth()]??"";return`${c}, ${u} ${String(r.getUTCDate()).padStart(2,"0")}, ${r.getUTCFullYear()}`})}function Fc(e,t=new Date){let n=new Date(e*1000),i=vi(t),s=vi(new Date(t.getTime()-86400000)),r=vi(n);if(r===i)return"Today";if(r===s)return"Yesterday";let o=n.toLocaleDateString("en-US",{weekday:"long"}),a=n.toLocaleDateString("en-US",{month:"short"});return`${o}, ${a} ${String(n.getDate()).padStart(2,"0")}`}function vi(e){return`${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`}function Cc(e){let t=new Date(e*1000),n=t.getFullYear(),i=String(t.getMonth()+1).padStart(2,"0"),s=String(t.getDate()).padStart(2,"0"),r=String(t.getHours()).padStart(2,"0"),o=String(t.getMinutes()).padStart(2,"0");return`${n}-${i}-${s} ${r}:${o}`}function Ec(e=new Date){let t=process.env.SLACK_QUIET_TZ??"Asia/Tokyo",n=Number(process.env.SLACK_QUIET_START??23),i=Number(process.env.SLACK_QUIET_END??8),s,r;try{let c=new Intl.DateTimeFormat("en-GB",{timeZone:t,hour12:!1,weekday:"short",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"});r=c.format(e),s=Number(c.formatToParts(e).find((u)=>u.type==="hour")?.value??"12")}catch{return null}let o=n>i?s>=n||s<i:s>=n&&s<i,a=`\uD83D\uDD50 ${r} (${t})`;if(!o)return a;return`${a}
|
|
155
|
+
⚠ QUIET HOURS (${n}:00-${i}:00) — this will buzz a phone. Send only for a production incident; otherwise hold it until morning.`}function bn(e){if(!$c(e))return;let t=mf(e,"utf8");for(let n of t.split(`
|
|
156
|
+
`)){let i=n.trim();if(!i||i.startsWith("#"))continue;let s=i.indexOf("=");if(s===-1)continue;let r=i.slice(0,s).trim(),o=i.slice(s+1).trim();if(o.startsWith('"')&&o.endsWith('"')||o.startsWith("'")&&o.endsWith("'"))o=o.slice(1,-1);if(!(r in process.env))process.env[r]=o}}function yf(e){Df(e,{recursive:!0});let t=ft(e,".gitignore");if(!$c(t))Oc(t,`*
|
|
157
|
+
`)}function wf(){bn(ft(xc(),".slack-cli",".env.local")),bn(ft(xc(),".config/slack-cli",".env")),bn(ft(process.cwd(),".slack-cli",".env.local")),bn(ft(process.cwd(),".env.local")),bn(ft(process.cwd(),".env"))}function bf(e){return gf("sha256").update(e).digest("hex")}function T(e){return e&&typeof e==="object"&&!Array.isArray(e)?e:{}}function X(e){return Array.isArray(e)?e:[]}function ls(e){return Number(e.ts??0)}async function Ic(e,t,n){let i=t.user;if(typeof i==="string"){if(!n.has(i))n.set(i,await ze(e,i));return n.get(i)??i}return typeof t.username==="string"?t.username:"bot"}function Wi(e){let t=new Date(e*1000),n=t.getUTCFullYear(),i=String(t.getUTCMonth()+1).padStart(2,"0"),s=String(t.getUTCDate()).padStart(2,"0"),r=String(t.getUTCHours()).padStart(2,"0"),o=String(t.getUTCMinutes()).padStart(2,"0"),a=String(t.getUTCSeconds()).padStart(2,"0");return`${n}-${i}-${s} ${r}:${o}:${a}`}function Ji(e){let[t,n="000000"]=e.split("."),i=Number(t),s=new Date(i*1000),r=s.getUTCFullYear(),o=String(s.getUTCMonth()+1).padStart(2,"0"),a=String(s.getUTCDate()).padStart(2,"0"),c=String(s.getUTCHours()).padStart(2,"0"),u=String(s.getUTCMinutes()).padStart(2,"0"),f=String(s.getUTCSeconds()).padStart(2,"0"),l=n.padEnd(6,"0").slice(0,6);return`${r}-${o}-${a}T${c}:${u}:${f}.${l}`}function Ki(e){let t=e.match(/^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})\.(\d{6})$/);if(!t)throw Error(`Invalid message timestamp "${e}" \u2014 expected 2026-05-11T06:01:04.000100`);let n=Date.parse(t[1]+"Z");if(isNaN(n))throw Error(`Cannot parse date in "${e}"`);return`${Math.floor(n/1000)}.${t[2]}`}function Ff(e){return/^\d{4}-\d{2}-\d{2}T/.test(e)?Ki(e):e}async function ps(e,t,n,i,s){let r=typeof t.ts==="string"?t.ts:`${ls(t)}.000000`,o=Ji(r),a="?";if(typeof t.user==="string"){let F=t.user,k="@"+F;if(!n.has(k)){let C=await pc(e,F,async(A,P,v)=>(await hn(A,P,v))[1],s);n.set(k,C)}a=n.get(k)??F}else if(typeof t.username==="string")a=t.username;let c=typeof t.text==="string"?t.text:"",f=wn(await Gt(e,c,n,s)).split(`
|
|
157
158
|
`),l=f[0]+(f.length>1?`
|
|
158
159
|
`+f.slice(1).map((F)=>` ${F}`).join(`
|
|
159
|
-
`):""),d=i?`${i} @${a}`:`@${a}`,h=X(t.reactions).map(
|
|
160
|
+
`):""),d=i?`${i} @${a}`:`@${a}`,h=X(t.reactions).map(T).map((F)=>{let k=typeof F.name==="string"?F.name:"",C=Number(F.count??X(F.users).length??0);return k?`:${k}:\xD7${C}`:""}).filter(Boolean).join(" "),m=X(t.files).map(T).map((F)=>{let k=typeof F.name==="string"?F.name:typeof F.title==="string"?F.title:"(file)",C=typeof F.size==="number"?` (${hs(F.size)})`:"",A=typeof F.id==="string"?` [${F.id}]`:"";return`
|
|
160
161
|
\uD83D\uDCCE ${k}${C}${A}`}).join(""),p=Number(t.reply_count??0),y=p>0?` [+${p} ${p===1?"reply":"replies"}]`:"",E=(h?`
|
|
161
|
-
${h}`:"")+m;return`${o} ${d}: ${l}${y}${E}`}function hs(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function
|
|
162
|
-
`)[0]??"",d=await Gt(e,l,i);console.log(` ${f}: ${d}`)}}}async function
|
|
163
|
-
`)[0]?.slice(0,60)}`:"";console.log(`${d}${u} ${c}${h}${p}`)}}function
|
|
162
|
+
${h}`:"")+m;return`${o} ${d}: ${l}${y}${E}`}function hs(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function Cf(e){return X(e.files).map(T).map((t)=>({id:t.id??null,name:t.name??t.title??null,mimetype:t.mimetype??null,size:t.size??null,url_private_download:t.url_private_download??t.url_private??null,permalink:t.permalink??null}))}function Tc(e){let t=Cf(e);return{ts:e.ts??null,user:e.user??null,username:e.username??null,bot_id:e.bot_id??null,thread_ts:e.thread_ts??null,text:typeof e.text==="string"?e.text:"",...e.reply_count!==void 0?{reply_count:e.reply_count}:{},...e.reply_users_count!==void 0?{reply_users_count:e.reply_users_count}:{},...e.latest_reply!==void 0?{latest_reply:e.latest_reply}:{},...t.length>0?{files:t}:{}}}async function Ef(e,t,n,i,s){let r=[];for(let o of n){let a=o;if(Number(o.reply_count??0)>0&&typeof o.ts==="string"){let c=await Ke(e,t,o.ts,200,s),u=X(c.messages).map(T);a=u[u.length-1]??o}if(a.user!==i)r.push(o)}return r}async function xf(e,t,n,i="text",s=!1,r){let o=Rt(t),a=await De(e,t,r),c=new Map,f=await(async()=>{if(o?.threadTs){let d=await Ke(e,a,o.threadTs,n,r);return X(d.messages).map(T)}let l=await Ze(e,a,n,void 0,void 0,r);return X(l.messages).map(T).reverse()})();if(s){let{userId:l}=await va(e,r);f=await Ef(e,a,f,l,r)}if(i==="jsonl"){for(let l of f)console.log(JSON.stringify(Tc(l)));return}for(let l of f)console.log(await ps(e,l,c,void 0,r))}async function _f(e,t,n,i,s="text",r){let o=await De(e,t,r),a=await Ke(e,o,Ff(n),i,r),c=X(a.messages).map(T);if(s==="jsonl"){for(let f of c)console.log(JSON.stringify(Tc(f)));return}let u=new Map;for(let f of c)console.log(await ps(e,f,u,void 0,r))}async function Sf(e){let t=await dn(e),n=X(t.channels).map(T).filter((s)=>s.is_member===!0).sort((s,r)=>Number(r.updated??0)-Number(s.updated??0)).slice(0,10),i=new Map;for(let s of n){let r=String(s.id??""),o=typeof s.name==="string"?s.name:typeof s.user==="string"?s.user:r,a=await Ze(e,r,5),c=X(a.messages).map(T).filter((u)=>u.subtype===void 0||u.subtype===null).filter((u)=>{let f=typeof u.text==="string"?u.text:"";return f.length>0&&!f.startsWith("<@")}).slice(0,3).reverse();if(c.length===0)continue;console.log(`-- #${o} --------------------------------`);for(let u of c){let f=await Ic(e,u,i),l=(typeof u.text==="string"?u.text:"").split(`
|
|
163
|
+
`)[0]??"",d=await Gt(e,l,i);console.log(` ${f}: ${d}`)}}}async function kf(e,t){let n=await Ka(e,"to:me"),i=X(un(n,["messages","matches"])).map(T).slice(0,t),s=new Map,r=[];for(let o of i){let a=Fc(ls(o)),c=r[r.length-1];if(c?.label===a)c.msgs.push(o);else r.push({label:a,msgs:[o]})}for(let o=0;o<r.length;o++){let{label:a,msgs:c}=r[o];if(o>0)console.log("");console.log(` ${a}`),console.log(" ----------------------------");for(let u of[...c].reverse()){let f=T(u.channel),l=f.is_im===!0,d=typeof f.name==="string"?f.name:"dm",h;if(l&&d.startsWith("U")){let m="@"+d;if(!s.has(m)){let[,p]=await hn(e,d);s.set(m,p)}h=`@${s.get(m)??d}`}else if(l)h=`@${d}`;else h=`#${d}`;console.log(await ps(e,u,s,h))}}}async function Af(e,t,n,i,s="text"){let r=await dn(e),o=X(r.channels).map(T).filter((a)=>i||a.is_member===!0).filter((a)=>{if(!n)return!0;return(typeof a.name==="string"?a.name:"").toLowerCase().includes(n.toLowerCase())}).sort((a,c)=>Number(c.updated??0)-Number(a.updated??0)).slice(0,t);if(s==="jsonl"){for(let a of o)console.log(JSON.stringify(a));return}for(let a of o){let c=String(a.id??""),u=typeof a.name==="string"?a.name:typeof a.user==="string"?a.user:c,f=a.is_im===!0,l=a.is_mpim===!0,d=f||l?"@":"#",h=a.is_member===!0?"":" (not joined)",m=typeof T(a.purpose).value==="string"?String(T(a.purpose).value):"",p=m?` ${m.split(`
|
|
164
|
+
`)[0]?.slice(0,60)}`:"";console.log(`${d}${u} ${c}${h}${p}`)}}function $f(e){let t=(s)=>s.startsWith("xoxp-")||s.startsWith("xoxc-"),n=Qs(),i=n.find((s)=>s.profile.token===e);if(!i)return;return n.find((s)=>t(s.profile.token)&&s.profile.teamId===i.profile.teamId)}async function Pc(e,t,n,i,s){let r=e,o=s,a;try{a=await Ai(r,t,n,o)}catch(f){let l=f instanceof Error?f.message:String(f);if(e.startsWith("xoxb-")&&l.includes("not_allowed_token_type")){let d=$f(e);if(d)console.error(`Note: search.messages needs a user token \u2014 the active profile is a bot token (xoxb-); falling back to profile "${d.name}".`),r=d.profile.token,o=d.profile.cookie,a=await Ai(r,t,n,o);else console.error(`Error: search requires a user token (xoxp-/xoxc-) \u2014 the active profile is a bot token (xoxb-), which Slack rejects for search.messages.
|
|
164
165
|
`+` Add a user-token profile: slack auth login (or slack auth token)
|
|
165
|
-
Then select it: slack auth use <name> (or pass --workspace <name>)`),process.exit(1)}else throw f}if(i){console.log(JSON.stringify(a,null,2));return}let c=X(un(a,["messages","matches"])).map(
|
|
166
|
-
`);for(let p of[...m].reverse()){let y=await
|
|
167
|
-
`).join(" \u21B5 ");console.log(`[${Cc(ls(p))}] ${y}: ${k}`)}console.log("")}console.error(`Dumped ${c} messages across ${u} channels (cutoff: ${t}d)`)}function
|
|
168
|
-
`))console.log(` ${F}`)}}async function
|
|
169
|
-
`)).slice(0,4)}function te(e){return e.replace(/\x1b\[[0-9;:?]*[ -/]*[@-~]/g,"").replace(/[\x00-\x1f\x7f-\x9f]/g,"").replace(/[\u061c\u200e\u200f\u202a-\u202e\u2066-\u2069]/g,"")}var
|
|
170
|
-
`)[0]??"",o=r.length>n?`${r.slice(0,n)}\u2026`:r,a=typeof t.ts==="string"?t.ts:"";return`${a?Ji(a).slice(0,16).replace("T"," "):""} @${s}${o?`: ${o}`:""}`}async function
|
|
166
|
+
Then select it: slack auth use <name> (or pass --workspace <name>)`),process.exit(1)}else throw f}if(i){console.log(JSON.stringify(a,null,2));return}let c=X(un(a,["messages","matches"])).map(T),u=new Map;for(let f of c){let l=T(f.channel),d=l.is_im===!0,h=typeof l.name==="string"?l.name:"dm",m;if(d&&h.startsWith("U")){let p="@"+h;if(!u.has(p)){let[,y]=await hn(r,h,o);u.set(p,y)}m=`@${u.get(p)??h}`}else if(d)m=`@${h}`;else m=`#${h}`;console.log(await ps(r,f,u,m,o))}}async function Rc(e,t,n,i){let{ref:s,ts:r}=gs(t);if(!r)console.error("Error: target must embed a message ts (e.g. #chan:1700000000.000100 or a Slack permalink URL)"),process.exit(2);return{channelId:n??await Mi(e,s,De,i),ts:r}}async function Of(e,t){let n=Dn(),i={};if(!t.mine)i.shared=!0;if(t.in)i.in=t.in;if(t.from)i.from=t.from;let s=uc(t.state,n,i);if(!t.json){let r=await Vt(e,t.cookie),o=t.mine?"your reactions only [hasmy:]":"anyone's reactions [has:]";console.error(`(From: ${Bc(r)} \xB7 matching ${o})`),console.error(`(query: ${s})`)}await Ae("search.messages",()=>Pc(e,s,t.count,t.json,t.cookie))}async function If(e,t){let n=Dn(),{channelId:i,ts:s}=await Rc(e,t.target,t.channelId,t.cookie),r=await hc(e,i,s,t.state,n,t.cookie);if(r.noop){console.log(`= Already ${t.state} (ts: ${s})`);return}let o=r.removed.length?`, removed ${r.removed.map((a)=>`:${a}:`).join(" ")}`:"";if(console.log(`\u2713 ${t.state} :${n.progress[t.state]}: (ts: ${s})${o}`),r.leftover.length)console.error(`\u26A0 ${r.leftover.map((a)=>`:${a}:`).join(" ")} could not be removed \u2014 this message now carries more than one `+"progress reaction. Readers collapse by priority so nothing is lost; repair with: slack todo doctor --in <#chan> --fix")}async function Tf(e,t){let n=Dn(),{channelId:i,ts:s}=await Rc(e,t.target,t.channelId,t.cookie),r=await gc(e,i,s,t.flag,n,t.remove===!0,t.cookie);console.log(`\u2713 ${t.remove?"Cleared":"Flagged"} ${t.flag} :${r}: (ts: ${s})`)}async function Pf(e,t){let n=Dn(),i=t.channelId??await Mi(e,t.channel,De,t.cookie),s={limit:t.limit};if(t.fix)s.fix=!0;if(t.cookie)s.cookie=t.cookie;let r=await mc(e,i,n,s);if(r.findings.length===0)console.log(`\u2713 No multi-state tasks in ${r.scanned} message(s).`);else{for(let o of r.findings){let a=o.fixed===!0?"fixed":o.fixed===!1?`FAILED: ${o.error??"?"}`:"needs --fix";console.log(`${o.ts} ${o.emoji.map((c)=>`:${c}:`).join(" ")} \u2192 keep :${o.keep}: [${a}] ${te(o.text).slice(0,60)}`)}console.log(`${r.findings.length} multi-state task(s) in ${r.scanned} message(s).`)}if(r.truncated)console.error(`\u26A0 Scan limit reached (${t.limit} messages) \u2014 older history was NOT checked. Raise it with --limit N.`)}async function Rf(e,t,n,i){let s=Math.floor(Date.now()/1000)-t*86400,r=await dn(e),o=X(r.channels).map(T).filter((f)=>f.is_member===!0&&f.is_im!==!0&&f.is_mpim!==!0).filter((f)=>{if(!i)return!0;return(typeof f.name==="string"?f.name:"").toLowerCase().includes(i.toLowerCase())}).sort((f,l)=>Number(l.updated??0)-Number(f.updated??0)),a=new Map,c=0,u=0;for(let f of o){let l=String(f.id??""),d=typeof f.name==="string"?f.name:l,h;try{h=await Ze(e,l,n)}catch(p){console.error(` SKIP #${d}: ${p.message}`);continue}let m=X(h.messages).map(T).filter((p)=>(p.subtype===void 0||p.subtype===null)&&ls(p)>=s);if(m.length===0)continue;u+=1,c+=m.length,console.log(`## #${d} (${m.length} msgs)
|
|
167
|
+
`);for(let p of[...m].reverse()){let y=await Ic(e,p,a),E=typeof p.text==="string"?p.text:"",k=wn(await Gt(e,E,a)).split(`
|
|
168
|
+
`).join(" \u21B5 ");console.log(`[${Cc(ls(p))}] ${y}: ${k}`)}console.log("")}console.error(`Dumped ${c} messages across ${u} channels (cutoff: ${t}d)`)}function Mf(e){let t=[];function n(i){if(typeof i==="string"){t.push(i);return}if(Array.isArray(i)){for(let s of i)n(s);return}if(i&&typeof i==="object"){let s=i;if(typeof s.text==="string"){t.push(s.text);return}if(Array.isArray(s.elements))n(s.elements);else if(Array.isArray(s.content))n(s.content)}}for(let i of e)n(i);return t.join("").trim()}async function Mc(e,t,n){let i=new Map;return async(s)=>{if(!s)return"(unknown)";if(i.has(s))return i.get(s);try{let r=await tc(e,s,t),o=T(r.channel),a;if(o.is_im===!0){let c=typeof o.user==="string"?o.user:"";if(!c||c===n)a="@self";else{let[u]=await hn(e,c);a=`@${u}`}}else a=`#${typeof o.name==="string"?o.name:s}`;return i.set(s,a),a}catch{return s}}}function zi(e){let t=T(X(e.destinations)[0]);return String(t.channel_id??e.channel_id??e.channel??"")}function fs(e){return Mf(X(e.blocks))||(typeof e.text==="string"?e.text:"(no text)")}async function Bf(e,t,n=!1){let i=await gn(e,t),s=X(i.drafts??i.messages??[]).map(T).filter((u)=>u.is_deleted!==!0),r=n?s:s.filter((u)=>u.is_sent!==!0);if(r.length===0){console.log(n?"No drafts.":"No pending drafts. Run with --all to include sent.");return}let o="";try{({userId:o}=await Oi(e,t))}catch{}let a=await Mc(e,t,o),c=new Map;for(let u of r){let f=zi(u),l=fs(u),d=Number(u.date_created??u.date_create??0),h=d?Wi(d):"?",m=await a(f),p=typeof u.id==="string"?u.id:"",y=u.is_sent===!0?" [SENT]":"",E=wn(await Gt(e,l,c));console.log(`-- ${p} ${m} [${h}]${y}`);for(let F of E.split(`
|
|
169
|
+
`))console.log(` ${F}`)}}async function Nf(e,t,n){let i=await gn(e,t),s=X(i.drafts).map(T).find((m)=>String(m.id)===n);if(!s)console.error(`Draft not found: ${n}`),process.exit(1);let r="";try{({userId:r}=await Oi(e,t))}catch{}let o=await Mc(e,t,r),a=zi(s),c=fs(s),u=Number(s.date_created??0),f=String(s.last_updated_ts??"?"),l=await o(a),h=wn(await Gt(e,c,new Map));console.log(`id: ${s.id}`),console.log(`channel: ${l} (${a})`),console.log(`created: ${u?Wi(u):"?"}`),console.log(`updated: ${Wi(Number(f.split(".")[0]))}`),console.log(`status: ${s.is_sent===!0?"sent":"pending"}`),console.log("---"),console.log(h)}function He(...e){return bf(e.join(`
|
|
170
|
+
`)).slice(0,4)}function te(e){return e.replace(/\x1b\[[0-9;:?]*[ -/]*[@-~]/g,"").replace(/[\x00-\x1f\x7f-\x9f]/g,"").replace(/[\u061c\u200e\u200f\u202a-\u202e\u2066-\u2069]/g,"")}var vf={"reactions.add":"reactions:write","reactions.remove":"reactions:write","chat.postMessage":"chat:write","chat.update":"chat:write","chat.delete":"chat:write","conversations.replies":"channels:history (or groups:history)","conversations.history":"channels:history (or groups:history)"};function tt(e){let t=e instanceof Error?e.message:String(e),n=t.match(/Slack error on (\S+): (\w+)/);if(!n)return t;let[,i,s]=n;switch(s){case"missing_scope":return`Error: token lacks the ${vf[i]??"the required"} scope (needed for ${i}). Add it to your Slack App's User Token Scopes (or Bot Token Scopes if you use a bot token / --as-bot) \u2014 it must be on the token type the CLI actually uses \u2014 then reinstall to the workspace.`;case"invalid_name":return"Error: not a valid emoji shortcode \u2014 use the name without colons (e.g. white_check_mark), and make sure it exists in the workspace.";case"already_reacted":return"Error: you've already added that reaction to the message.";case"no_reaction":return"Error: that reaction isn't on the message \u2014 nothing to remove.";case"message_not_found":return"Error: no message found at that timestamp in the channel \u2014 check the target ts/permalink.";case"channel_not_found":return"Error: channel not found \u2014 check the target.";default:return t}}function ve(e,t,n){for(let s of n)console.log(s);let i=Ec();if(i)console.log(i);if(e!==void 0)console.error(`Code mismatch (got ${e}, expected ${t})`);console.error(`Rerun with --code=${t}`),process.exit(1)}function gs(e){let t=Rt(e);if(t)return t.ts?{ref:t.channel,ts:t.ts}:{ref:t.channel};if(e.startsWith("#")||e.startsWith("@")){let n=e.indexOf(":");if(n>0){let i=e.slice(n+1);if(/^\d{10}\.\d{6}$/.test(i))return{ref:e.slice(0,n),ts:i};if(/^\d{4}-\d{2}-\d{2}T/.test(i))return{ref:e.slice(0,n),ts:Ki(i)}}}return{ref:e}}function Fn(e,t=!0){let n=Rt(e);if(n){if(!t)return{ref:n.channel};let s=n.threadTs??n.ts;return s?{ref:n.channel,threadTs:s}:{ref:n.channel}}let i=e.indexOf(":");if(i>0){let s=e.slice(i+1);if(/^\d{10}\.\d{6}$/.test(s))return{ref:e.slice(0,i),threadTs:s};if(/^\d{4}-\d{2}-\d{2}T/.test(s))return{ref:e.slice(0,i),threadTs:Ki(s)}}return{ref:e}}async function ms(e,t,n,i){let s=n;if(/^#?[CDG][A-Z0-9]{8,}$/.test(n)||!n.startsWith("#")&&!n.startsWith("@"))try{let o=T(await mn(e,t,i)),a=T(o.channel);if(a.is_im===!0){let c=typeof a.user==="string"?a.user:"";s=c?`@${await ze(e,c,i)}`:t}else s=typeof a.name==="string"?`#${a.name}`:t}catch{s=t}return s===t?t:`${s} (${t})`}async function Vt(e,t){try{return await ja(e,t)}catch{return null}}function Nt(e,t){let n;return async()=>{if(n===void 0)n=await Vt(e,t);return n}}function Bc(e,t){let n=t?" [as bot]":"";if(!e)return`(unknown \u2014 auth.test failed)${n}`;let i=te(e.user||e.userId||"?"),s=e.userId?` (${e.userId})`:"",r=e.team?` \u2014 ${te(e.team)}`:"";return`@${i}${s}${r}${n}`}function je(e,t={}){return` ${"From:".padEnd(t.pad??6)}${Bc(e,t.asBot)}`}async function Ui(e,t,n=60,i){let s=typeof t.user==="string"?await ze(e,t.user,i):typeof t.username==="string"?t.username:"?",r=(typeof t.text==="string"?t.text:"").split(`
|
|
171
|
+
`)[0]??"",o=r.length>n?`${r.slice(0,n)}\u2026`:r,a=typeof t.ts==="string"?t.ts:"";return`${a?Ji(a).slice(0,16).replace("T"," "):""} @${s}${o?`: ${o}`:""}`}async function jf(e,t,n,i){let s=n.find((r)=>String(r.ts)===t)??n[0];if(!s)return t;return Ui(e,s,40,i)}function _c(e){return e.toLowerCase().replace(/<[@#!][^>]+>/g," ").replace(/[^\p{L}\p{N}\s]/gu," ").replace(/\s+/g," ").trim()}function Lf(e,t){let n=_c(e),i=_c(t);if(!n||!i)return 0;if(n===i)return 1;let s=(u)=>{let f=new Map;for(let l=0;l<u.length-1;l++){let d=u.slice(l,l+2);f.set(d,(f.get(d)??0)+1)}return f},r=s(n),o=s(i);if(r.size===0||o.size===0)return 0;let a=0;for(let[u,f]of r){let l=o.get(u);if(l)a+=Math.min(f,l)}let c=Sc(r)+Sc(o);return c===0?0:2*a/c}function Sc(e){let t=0;for(let n of e.values())t+=n;return t}async function Wf(e,t){let n=Nt(e,t.cookie),{ref:i,ts:s}=gs(t.target);if(!s)console.error("Error: target must embed a message ts (e.g. #chan:2026-05-11T06:01:04.000100 or a Slack permalink URL)"),process.exit(2);let r;if(t.channelId)r=t.channelId;else r=await De(e,i,t.cookie);let o=await Ke(e,r,s,1,t.cookie),c=X(o.messages).map(T).find((m)=>String(m.ts)===s);if(!c)console.error(`Message not found at ts=${s} in channel ${r}`),process.exit(1);let u=typeof c.text==="string"?c.text:"",f=t.mentions?await Dc(e,t.newText,r,t.cookie?{cookie:t.cookie}:{}):t.newText,l=await n(),d=He(u,f,l?.userId??"");if(t.code!==d)ve(t.code,d,["--- Editing as -------------------------------",je(l),"--- Original message -------------------------",...u.split(`
|
|
171
172
|
`).map((m)=>` ${m}`),"--- Replacing with ---------------------------",...f.split(`
|
|
172
|
-
`).map((m)=>` ${m}`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);let h=await Yt(e,r,s,f,t.cookie);console.log(`\u2713 Edited (ts: ${h})`)}async function
|
|
173
|
-
`).map((h)=>` ${h}`),"---------------------------------------------"])}await Ya(e,r,s,t.cookie),console.log(`\u2713 Deleted (ts: ${s})`)}async function
|
|
174
|
-
`+` To reach yourself with a notification, send as the bot: slack send '${t.target}' '...' --as-bot`);let a=t.message,c=null;if(t.mentions){c=await Bt(t.mentionToken??e,t.message,o,t.mentionCookie),a=c.text;for(let C of yn(c.unresolved))console.error(`\u26A0 ${te(C)}`)}try{for(let C of await bc(t.mentionToken??e,a,t.mentionCookie))console.error(`\u26A0 possible untagged mention: ${te(C.surface)} \u2014 @${te(C.display)} won't be notified (did you mean <@${C.userId}>?)`)}catch{}let u=[];if(c&&(c.resolved.length>0||c.unresolved.length>0)){u.push("--- Mentions ---------------------------------");for(let C of c.resolved)u.push(` \u2713 ${te(C.surface)} \u2192 @${te(C.display)} (${C.userId}) \u2014 will notify`);for(let C of c.unresolved){let A=C.reason==="ambiguous"?"ambiguous":C.reason==="unavailable"?"lookup unavailable":"no match";u.push(` \u26A0 ${te(C.surface)} \u2014 plain text, NOT notified (${A})`)}}let f="",l="?",d=[],h,m,p;if(i)try{let C=await Ke(e,o,i,100,s);d=X(C.messages).map(
|
|
175
|
-
`)[0]?.slice(0,100)??"(empty)"}`,...u,"--- Sending ----------------------------------",A,` \u2192 ${C} \u2014 NEW top-level message`,` Message: ${a}`,"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"])}let F=await rs(e,o,a,i,t.broadcast,s),k="";try{k=await ln(e,o,F,s)}catch{}if(k)console.log(`\u2713 Sent: ${k}`);else console.log(`\u2713 Sent (ts: ${F})`);if(t.asBot&&o.startsWith("D"))try{let C=await oi(e);if(!C.ok)for(let A of ai(C,!0))console.error(A);else{let A=C.appId?`https://api.slack.com/apps/${C.appId}`:"https://api.slack.com/apps";console.error(`Note: if ${t.target} can't reply (app messaging may be off), enable Messages Tab: ${A} \u2192 App Home.`)}}catch{}}var
|
|
176
|
-
`+` To reach yourself with a notification, ask as the bot: slack ask '${t.target}' '...' --as-bot`);let u=ds(t.question),f=ds(t.body??""),l=new Set([...u.kinds,...f.kinds]),d=t.mentionToken??e,h=await Bt(d,u.text,o,t.mentionCookie),m=f.text?await Bt(d,f.text,o,t.mentionCookie):{text:"",resolved:[],unresolved:[]},p=h.text,y=m.text,E=[...h.resolved,...m.resolved],F=[...h.unresolved,...m.unresolved];for(let J of yn(F))console.error(`\u26A0 ${te(J)}`);let k=l.size>0,C=new Set(E.map((J)=>J.userId).filter((J)=>J!==a)),A=new Map(E.map((J)=>[J.userId,J.display])),
|
|
173
|
+
`).map((m)=>` ${m}`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);let h=await Yt(e,r,s,f,t.cookie);console.log(`\u2713 Edited (ts: ${h})`)}async function Uf(e,t){let n=Nt(e,t.cookie),{ref:i,ts:s}=gs(t.target);if(!s)console.error("Error: target must embed a message ts (e.g. #chan:2026-05-11T06:01:04.000100 or a Slack permalink URL)"),process.exit(2);let r;if(t.channelId)r=t.channelId;else r=await De(e,i,t.cookie);let o=await Ke(e,r,s,1,t.cookie),c=X(o.messages).map(T).find((d)=>String(d.ts)===s);if(!c)console.error(`Message not found at ts=${s} in channel ${r}`),process.exit(1);let u=typeof c.text==="string"?c.text:"",f=await n(),l=He(r,s,u,f?.userId??"");if(t.code!==l){let d=await ms(e,r,i,t.cookie);ve(t.code,l,["--- Deleting message -------------------------",je(f),` \u2192 ${d} at ${Ji(s)}`,...u.split(`
|
|
174
|
+
`).map((h)=>` ${h}`),"---------------------------------------------"])}await Ya(e,r,s,t.cookie),console.log(`\u2713 Deleted (ts: ${s})`)}async function Jf(e,t){let{ref:n,ts:i}=gs(t.target);if(!i)console.error("Error: target must embed a message ts (e.g. #chan:2026-05-11T06:01:04.000100 or a Slack permalink URL)"),process.exit(2);let s=t.emoji.replace(/^:|:$/g,""),r;if(t.channelId)r=t.channelId;else r=await De(e,n,t.cookie);if(t.remove)await fn(e,r,i,s,t.cookie),console.log(`\u2713 Removed :${s}: (ts: ${i})`);else await ct(e,r,i,s,t.cookie),console.log(`\u2713 Reacted :${s}: (ts: ${i})`)}async function Hi(e,t,n,i){if(!n||!t.startsWith("D"))return!1;try{let s=T(await mn(e,t,i)),r=T(s.channel);return r.is_im===!0&&r.user===n}catch{return!1}}async function Kf(e,t){let{ref:n,threadTs:i}=Fn(t.target),s=t.cookie,r=Nt(e,s),o;if(t.channelId)o=t.channelId;else if(t.userId)o=await Pt(e,t.userId,s);else o=await De(e,n,s);if(!t.asBot&&await Hi(e,o,(await r())?.userId,s))console.error(`Warning: "${t.target}" is a DM to yourself \u2014 Slack will NOT notify you of your own message.
|
|
175
|
+
`+` To reach yourself with a notification, send as the bot: slack send '${t.target}' '...' --as-bot`);let a=t.message,c=null;if(t.mentions){c=await Bt(t.mentionToken??e,t.message,o,t.mentionCookie),a=c.text;for(let C of yn(c.unresolved))console.error(`\u26A0 ${te(C)}`)}try{for(let C of await bc(t.mentionToken??e,a,t.mentionCookie))console.error(`\u26A0 possible untagged mention: ${te(C.surface)} \u2014 @${te(C.display)} won't be notified (did you mean <@${C.userId}>?)`)}catch{}let u=[];if(c&&(c.resolved.length>0||c.unresolved.length>0)){u.push("--- Mentions ---------------------------------");for(let C of c.resolved)u.push(` \u2713 ${te(C.surface)} \u2192 @${te(C.display)} (${C.userId}) \u2014 will notify`);for(let C of c.unresolved){let A=C.reason==="ambiguous"?"ambiguous":C.reason==="unavailable"?"lookup unavailable":"no match";u.push(` \u26A0 ${te(C.surface)} \u2014 plain text, NOT notified (${A})`)}}let f="",l="?",d=[],h,m,p;if(i)try{let C=await Ke(e,o,i,100,s);d=X(C.messages).map(T);let A=d[d.length-1];f=typeof A?.text==="string"?A.text:"",h=typeof A?.user==="string"?A.user:void 0,m=typeof A?.bot_id==="string"?A.bot_id:void 0,p=typeof A?.ts==="string"?A.ts:void 0}catch{}else try{let C=await Ze(e,o,1,void 0,void 0,s),A=X(C.messages).map(T),P=A.filter((L)=>L.subtype===void 0||L.subtype===null)[0];f=typeof P?.text==="string"?P.text:"",l=typeof P?.user==="string"?await ze(e,P.user,s):typeof P?.username==="string"?P.username:"?";let v=A[0];h=typeof v?.user==="string"?v.user:void 0,m=typeof v?.bot_id==="string"?v.bot_id:void 0,p=typeof v?.ts==="string"?v.ts:void 0}catch{}if(process.env.SLACK_UNREPLIED_WARN!=="0"&&p&&(h||m))try{let C=await r();if(!!C&&(!!h&&!!C.userId&&C.userId===h||!!m&&!!C.botId&&C.botId===m)){let P=`slack edit "#${o}:${p}" "<\u65B0\u3057\u3044\u672C\u6587>" --channel-id ${o}`;try{let v=await ln(e,o,p,s);if(v)P=`slack edit "${v}" "<\u65B0\u3057\u3044\u672C\u6587>"`}catch{}console.error("\u26A0 \u76F8\u624B\u306F\u307E\u3060\u8FD4\u4FE1\u3057\u3066\u3044\u307E\u305B\u3093(\u6700\u5F8C\u306E\u30E1\u30C3\u30BB\u30FC\u30B8\u306F\u3042\u306A\u305F\u306E\u3082\u306E\u3067\u3059)\u3002"),console.error(" \u9023\u6295\u3092\u907F\u3051\u308B\u305F\u3081\u3001\u65B0\u898F\u9001\u4FE1\u3067\u306A\u304F\u76F4\u524D\u306E\u30E1\u30C3\u30BB\u30FC\u30B8\u306E edit \u3092\u691C\u8A0E\u3057\u3066\u304F\u3060\u3055\u3044:"),console.error(` ${P}`),console.error(" \u3053\u306E\u307E\u307E\u9001\u4FE1\u3059\u308B\u5834\u5408\u306F --code=XXXX \u3067\u78BA\u5B9A\u3002")}}catch{}if(i&&d.length){let C={sim:0,msg:null};for(let A of d){let P=typeof A.text==="string"?A.text:"";if(!P)continue;let v=Lf(a,P);if(v>C.sim)C={sim:v,msg:A}}if(C.msg&&C.sim>=0.82){let A=Math.round(C.sim*100);console.error(`\u26A0 possible duplicate: ${A}% similar to an existing thread message \u2014 ${await Ui(e,C.msg,60,s)}`)}}let y=await r(),E=He(o,i??"",f,a,y?.userId??"");if(t.code!==E){let C=await ms(e,o,n,s),A=je(y,{asBot:t.asBot});if(i){let P=await jf(e,i,d,s),v=d.slice(-3),L=v.length?await Promise.all(v.map(async(R)=>` ${await Ui(e,R,60,s)}`)):[" (thread context unavailable)"];ve(t.code,E,["--- Recent messages in thread ----------------",...L,...u,"--- Sending ----------------------------------",A,` \u2192 ${C} thread of ${P} \u2014 THREAD REPLY`,` Message: ${a}`,"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"])}else ve(t.code,E,["--- Last message in channel ------------------",` ${l}: ${f.split(`
|
|
176
|
+
`)[0]?.slice(0,100)??"(empty)"}`,...u,"--- Sending ----------------------------------",A,` \u2192 ${C} \u2014 NEW top-level message`,` Message: ${a}`,"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"])}let F=await rs(e,o,a,i,t.broadcast,s),k="";try{k=await ln(e,o,F,s)}catch{}if(k)console.log(`\u2713 Sent: ${k}`);else console.log(`\u2713 Sent (ts: ${F})`);if(t.asBot&&o.startsWith("D"))try{let C=await oi(e);if(!C.ok)for(let A of ai(C,!0))console.error(A);else{let A=C.appId?`https://api.slack.com/apps/${C.appId}`:"https://api.slack.com/apps";console.error(`Note: if ${t.target} can't reply (app messaging may be off), enable Messages Tab: ${A} \u2192 App Home.`)}}catch{}}var zf=2,Ce=3,Hf=1.618033988749895,qf=1000,Yf=5000,kc=8,Xf=(e)=>new Promise((t)=>setTimeout(t,e)),Gf=new Set(["thread_broadcast"]),Vf=/(?<![A-Za-z0-9._@<-])@(here|channel|everyone)(?![A-Za-z0-9._-])/giu;function ds(e){let t=new Set;return{text:e.replace(Vf,(i,s)=>{let r=s.toLowerCase();return t.add(r),`<!${r}>`}),kinds:t}}async function qi(e,t,n){if(!t.startsWith("D"))return;try{let i=T(await mn(e,t,n)),s=T(i.channel);return s.is_im===!0&&typeof s.user==="string"?s.user:void 0}catch{return}}async function Nc(e,t){let{channelId:n,ts:i,question:s,reactable:r,threadOnly:o,audience:a,broadcast:c,cookie:u,timeout:f,shown:l}=t,d=t.askerUserId,h=t.askerBotId,m=(L)=>typeof L==="string"&&!!L&&L!==d&&(c||a.has(L));function p(L){let R=X(L.reactions).map(T),G=[];for(let S=0;S<r.length;S++){let x=R.find((W)=>W.name===Me[S].name),O=x?X(x.users).filter(m):[];if(O.length)G.push({index:S,users:O})}return G}async function y(L,R){let G=typeof L.text==="string"?L.text:"";if(!G)return;let S=wi(G,R);if(S===G)return;try{await Yt(e,n,i,S,u,!0)}catch(x){console.error(` (\u8CEA\u554F\u6587\u306B\u6CE8\u610F\u66F8\u304D\u3092\u5165\u308C\u3089\u308C\u307E\u305B\u3093\u3067\u3057\u305F: ${x instanceof Error?x.message:String(x)})`)}}async function E(L){let R=p(L);if(R.length<=1&&yi(typeof L.text==="string"?L.text:"").length)await y(L,[]);if(!R.length)return null;if(R.length===1){let{index:x,users:O}=R[0];return{answer:r[x],how:`\u30EA\u30A2\u30AF\u30B7\u30E7\u30F3 ${Me[x].glyph}`,who:O[0]}}let G=R.map((x)=>Me[x.index].glyph).join(" / ");console.error(` (${G} \u304C\u540C\u6642\u306B\u9078\u3070\u308C\u3066\u3044\u307E\u3059\u30021 \u3064\u306B\u7D5E\u3063\u3066\u3082\u3089\u3046\u307E\u3067\u5F85\u3061\u307E\u3059)`);let S=[...new Set(R.flatMap((x)=>x.users))].sort();return await y(L,S),null}function F(L,R=1/0){let G=[...L].sort((S,x)=>Number(S.ts)-Number(x.ts));for(let S of G){if(!(Number(S.ts)>Number(i)))continue;if(!m(S.user))continue;if(typeof S.subtype==="string"&&!Gf.has(S.subtype))continue;if(Number(S.ts)>=R)break;let x=typeof S.text==="string"?S.text.trim():"";if(x)return{answer:x,how:"\u8FD4\u4FE1",who:S.user}}return null}async function k(){if(t.threadParentTs){let S=T(await Ke(e,n,t.threadParentTs,100,u)),x=X(S.messages).map(T),O=x.find((W)=>W.ts===i);if(O){let W=await E(O);if(W)return W}return F(x)}let L=T(await Ze(e,n,30,i,void 0,u,!0)),R=X(L.messages).map(T),G=R.find((S)=>S.ts===i);if(G){let S=await E(G);if(S)return S}if(!o){let S=R.filter((O)=>Number(O.ts)>Number(i)&&(h&&O.bot_id===h||d&&O.user===d)).reduce((O,W)=>Math.min(O,Number(W.ts)),1/0),x=F(R,S);if(x)return x}if(G&&Number(G.reply_count)>0){let S=T(await Ke(e,n,i,30,u)),x=F(X(S.messages).map(T));if(x)return x}return null}async function C(L){for(let G=0;G<r.length;G++)try{await fn(e,n,i,Me[G].name,u)}catch{}let R="";if(L.who)try{R=await ze(e,L.who,u)}catch{R=L.who}if(R)console.error(` \u56DE\u7B54\u8005: ${te(R)}`);try{await Yt(e,n,i,_a(s,L,R),u,!0);try{await ct(e,n,i,bi,u),await fn(e,n,i,ts,u)}catch{}}catch(G){console.error(` (\u5143\u30E1\u30C3\u30BB\u30FC\u30B8\u306E\u66F4\u65B0\u306B\u5931\u6557: ${G instanceof Error?G.message:String(G)})`)}}let A=Date.now()+f*1000,P=0,v=qf;for(;;){let L=null;try{L=await k(),P=0}catch(R){if(P++,P>=kc)console.error(`Error: Slack \u3078\u306E\u554F\u3044\u5408\u308F\u305B\u306B ${P} \u56DE\u9023\u7D9A\u3067\u5931\u6557\u3057\u307E\u3057\u305F: ${R instanceof Error?R.message:String(R)}`),process.exit(Ce);console.error(` (Slack \u30A8\u30E9\u30FC ${P}/${kc}, \u518D\u8A66\u884C\u3057\u307E\u3059: ${R instanceof Error?R.message:String(R)})`)}if(L)await C(L),console.log(L.answer),process.exit(0);if(Date.now()>=A)break;await Xf(Math.min(v,Math.max(0,A-Date.now()))),v=Math.min(v*Hf,Yf)}if(f===0)console.error(`\u307E\u3060\u56DE\u7B54\u304C\u3042\u308A\u307E\u305B\u3093: ${l}`);else console.error(`Error: ${f}s \u4EE5\u5185\u306B\u56DE\u7B54\u304C\u3042\u308A\u307E\u305B\u3093\u3067\u3057\u305F (\u30E1\u30C3\u30BB\u30FC\u30B8\u306F\u305D\u306E\u307E\u307E\u6B8B\u3063\u3066\u3044\u307E\u3059)`),console.error(` ${l}`),console.error(` \u3042\u3068\u3067\u56DE\u53CE\u3059\u308B: ${vc(l,t.asBot)}`);process.exit(zf)}function vc(e,t){return`slack ask --waitFor='${e}'${t?" --as-bot":""}`}async function Zf(e,t){let{ref:n,threadTs:i}=Fn(t.target,!1),s=t.cookie,r=Nt(e,s),o;if(t.channelId)o=t.channelId;else if(t.userId)o=await Pt(e,t.userId,s);else o=await De(e,n,s);let a=(await r())?.userId??"",c=await qi(e,o,s);if(!t.asBot&&!!a&&c===a)console.error(`Warning: "${t.target}" is a DM to yourself \u2014 Slack will NOT notify you of your own message.
|
|
177
|
+
`+` To reach yourself with a notification, ask as the bot: slack ask '${t.target}' '...' --as-bot`);let u=ds(t.question),f=ds(t.body??""),l=new Set([...u.kinds,...f.kinds]),d=t.mentionToken??e,h=await Bt(d,u.text,o,t.mentionCookie),m=f.text?await Bt(d,f.text,o,t.mentionCookie):{text:"",resolved:[],unresolved:[]},p=h.text,y=m.text,E=[...h.resolved,...m.resolved],F=[...h.unresolved,...m.unresolved];for(let J of yn(F))console.error(`\u26A0 ${te(J)}`);let k=l.size>0,C=new Set(E.map((J)=>J.userId).filter((J)=>J!==a)),A=new Map(E.map((J)=>[J.userId,J.display])),P;if(k)P=`anyone in ${n} (${[...l].map((J)=>`@${J}`).join(", ")})`;else{if(!C.size&&c&&c!==a)C.add(c),A.set(c,await ze(e,c,s));if(!C.size)console.error("Error: `ask` will not post a question nobody is addressed to \u2014 no one is tagged.\n"+(F.length?` (${F.map((J)=>te(J.surface)).join(", ")} matched no one, so it names nobody.)
|
|
177
178
|
`:"")+` Tag the person who should answer: slack ask '${t.target}' '@alice ${t.question}' ...
|
|
178
179
|
Or open it to the whole channel: slack ask '${t.target}' '@here ${t.question}' ...
|
|
179
|
-
(In a 1:1 DM the other person counts automatically.)`),process.exit(Ce);
|
|
180
|
-
`)[0]?.slice(0,100)??"(empty)"}`,...ae,"--- Asking -----------------------------------",je(O,{asBot:t.asBot}),` \u2192 ${J}${i?" \u2014 THREAD REPLY":" \u2014 NEW top-level message"}`,` Question: ${p}`,` Answerable by: ${
|
|
181
|
-
`+` Got: ${te(t.link)}`),process.exit(Ce);i=m[1],s=m[2]}let o;if(r){let m=
|
|
182
|
-
`+` To reach yourself with a notification, post as the bot: slack poll '${t.target}' '...' --as-bot`);let u=ds(t.question),f=ds(t.body??""),l=t.mentionToken??e,d=await Bt(l,u.text,o,t.mentionCookie),h=f.text?await Bt(l,f.text,o,t.mentionCookie):{text:"",resolved:[],unresolved:[]},m=d.text,p=h.text;for(let S of yn([...d.unresolved,...h.unresolved]))console.error(`\u26A0 ${te(S)}`);let y=t.choices,E=!!t.multi,F=t.until??"",k=
|
|
183
|
-
`)[0]?.slice(0,100)??"(empty)"}`,"--- Ballot (seeded as reactions) -------------",...y.map((x,O)=>` ${Be[O].glyph} ${x}`),"--- Posting ----------------------------------",je(
|
|
184
|
-
`+` Got: ${te(t)}`),process.exit(Ne);s=c[1],r=c[2]}let a;if(o){let c=
|
|
185
|
-
`+" \u30E1\u30C3\u30BB\u30FC\u30B8\u3092\u66F8\u304D\u63DB\u3048\u3089\u308C\u308B\u306E\u306F\u6295\u7A3F\u8005\u3060\u3051\u3067\u3059 \u2014 bot \u304C\u6295\u7A3F\u3057\u305F\u6295\u7968\u306A\u3089 --as-bot \u3092\u4ED8\u3051\u3066\u304F\u3060\u3055\u3044\u3002")}if(u.ambiguous.length){let h=await Promise.all(u.ambiguous.map((m)=>ze(e,m,t.cookie)));console.error(`\u26A0 1 \u4EBA 1 \u7968\u306A\u306E\u306B\u8907\u6570\u62BC\u3057\u3066\u3044\u308B\u4EBA\u304C\u3044\u307E\u3059 (\u7121\u52B9\u7968): ${h.map((m)=>`@${te(m)}`).join(", ")}`)}if(!t.close)return;await Yt(t.writeToken??e,n,i,
|
|
186
|
-
`)[0]?.slice(0,80)??""}`)}}async function
|
|
187
|
-
`+"Expected F\u2026 or https://<ws>.slack.com/lists/<TEAM>/<F-id>");let r=[],o;do{let c={limit:200};if(o)c.cursor=o;let u=
|
|
188
|
-
`+"Expected F\u2026 or https://<ws>.slack.com/files/<UID>/<FID>/<name>");let r=
|
|
189
|
-
`),await Vn(),process.exit(0);throw o}},!0).command(["read [target]","msgs [target]"],"Browse messages",(s)=>s.positional("target",{type:"string",describe:"#channel, @user, or URL"}).option("limit",{alias:"n",type:"number",default:20,describe:"Number of messages"}).option("format",{type:"string",choices:["text","jsonl"],default:"text",describe:"jsonl exposes raw ts/user/text (incl. external-guest user IDs)"}).option("json",{type:"boolean",default:!1,describe:"Alias for --format=jsonl"}).option("unreplied",{type:"boolean",default:!1,describe:"Only messages whose last word (incl. thread replies) is not yours \u2014 i.e. awaiting your answer"}),async(s)=>{let r=e(s),o=s.json?"jsonl":s.format;if(s.target)await
|
|
180
|
+
(In a 1:1 DM the other person counts automatically.)`),process.exit(Ce);P=[...C].map((J)=>`@${te(A.get(J)??J)} (${J})`).join(", ")}let v=t.choices.slice(0,es),L=t.choices.slice(es),R=!o.startsWith("D")||!!i,G=xa(p,y,v,L,R),S="",x="?";try{let J=await Ze(e,o,1,void 0,void 0,s),ae=X(J.messages).map(T).filter((Oe)=>Oe.subtype===void 0||Oe.subtype===null)[0];S=typeof ae?.text==="string"?ae.text:"",x=typeof ae?.user==="string"?await ze(e,ae.user,s):typeof ae?.username==="string"?ae.username:"?"}catch{}let O=await r(),W=He(o,i??"",S,G,O?.userId??"");if(t.code!==W){let J=await ms(e,o,n,s),ae=v.length?["--- Choices (seeded as reactions) ------------",...v.map((Oe,z)=>` ${Me[z].glyph} ${Oe}`),...L.map((Oe,z)=>` (${z+11}) ${Oe} \u2014 text answer only`)]:["--- Choices ----------------------------------"," (none \u2014 free-text reply)"];ve(t.code,W,["--- Last message in channel ------------------",` ${x}: ${S.split(`
|
|
181
|
+
`)[0]?.slice(0,100)??"(empty)"}`,...ae,"--- Asking -----------------------------------",je(O,{asBot:t.asBot}),` \u2192 ${J}${i?" \u2014 THREAD REPLY":" \u2014 NEW top-level message"}`,` Question: ${p}`,` Answerable by: ${P}`,` Via: ${R?"reactions or thread replies":"reactions or replies in this DM"}`,"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"])}let Z=await rs(e,o,G,i,!1,s,!0);try{await ct(e,o,Z,ts,s)}catch(J){console.error(` (marker ${ts} \u3092\u4ED8\u3051\u3089\u308C\u307E\u305B\u3093\u3067\u3057\u305F: ${J instanceof Error?J.message:String(J)})`)}for(let J=0;J<v.length;J++)try{await ct(e,o,Z,Me[J].name,s)}catch(ae){console.error(` (\u30EA\u30A2\u30AF\u30B7\u30E7\u30F3 ${Me[J].name} \u3092\u4ED8\u3051\u3089\u308C\u307E\u305B\u3093\u3067\u3057\u305F: ${ae instanceof Error?ae.message:String(ae)})`)}let re="";try{re=await ln(e,o,Z,s)}catch{}let Q=re||`${o}:${Z}`;if(console.error(`\u2713 Asked: ${Q}`),!t.wait){console.log(vc(Q,!!t.asBot));return}let oe=t.timeout??3600;console.error(` \u56DE\u7B54\u3092\u5F85\u3063\u3066\u3044\u307E\u3059 (\u6700\u5927 ${oe}s)\u2026 Ctrl-C \u3067\u4E2D\u65AD`);let $e={channelId:o,ts:Z,question:p,reactable:v,threadOnly:R,audience:C,broadcast:k,askerUserId:O?.userId??"",askerBotId:O?.botId??"",timeout:oe,shown:Q,asBot:!!t.asBot};if(i)$e.threadParentTs=i;if(s)$e.cookie=s;await Nc(e,$e)}async function Qf(e,t){let n=Rt(t.link),i,s,r;if(n?.ts)i=n.channel,s=n.ts,r=n.threadTs&&n.threadTs!==n.ts?n.threadTs:void 0;else{let m=t.link.match(/^([A-Za-z0-9]+):(\d{10}\.\d{6})$/);if(!m)console.error(`Error: --waitFor needs the permalink of a question (or 'C\u2026:1700000000.000100').
|
|
182
|
+
`+` Got: ${te(t.link)}`),process.exit(Ce);i=m[1],s=m[2]}let o;if(r){let m=T(await Ke(e,i,r,100,t.cookie));o=X(m.messages).map(T).find((p)=>p.ts===s)}else{let m=T(await Ze(e,i,1,s,void 0,t.cookie,!0));o=X(m.messages).map(T).find((p)=>p.ts===s)}if(!o)console.error(`Error: \u305D\u306E\u30E1\u30C3\u30BB\u30FC\u30B8\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093: ${te(t.link)}`),process.exit(Ce);let a=typeof o.text==="string"?o.text:"",c=Sa(a);if(c.kind==="other")console.error("Error: \u3053\u308C\u306F `slack ask` \u306E\u8CEA\u554F\u3067\u306F\u3042\u308A\u307E\u305B\u3093 (\u56DE\u7B54\u306E\u8AAD\u307F\u53D6\u308A\u65B9\u304C\u5206\u304B\u308A\u307E\u305B\u3093)\u3002\n"+` ${te(t.link)}`),process.exit(Ce);if(c.kind==="resolved"){console.error(`\u2713 \u56DE\u7B54\u6E08\u307F: ${te(c.question)}`),console.log(c.answer);return}let u=typeof o.user==="string"?o.user:"",f=typeof o.bot_id==="string"?o.bot_id:"",l=/<!(here|channel|everyone)(\^[^>]*)?(\|[^>]*)?>/.test(a),d=new Set;for(let m of a.matchAll(/<@([UW][A-Z0-9]+)>/g))if(m[1]!==u)d.add(m[1]);if(!d.size&&!l){let m=await qi(e,i,t.cookie);if(m&&m!==u)d.add(m)}if(!d.size&&!l)console.error(`Error: \u3053\u306E\u8CEA\u554F\u306F\u8AB0\u306B\u3082\u5B9B\u3066\u3089\u308C\u3066\u3044\u306A\u3044\u305F\u3081\u3001\u6709\u52B9\u306A\u56DE\u7B54\u8005\u3092\u5224\u5B9A\u3067\u304D\u307E\u305B\u3093: ${te(t.link)}`),process.exit(Ce);if(t.timeout>0)console.error(` \u56DE\u7B54\u3092\u5F85\u3063\u3066\u3044\u307E\u3059 (\u6700\u5927 ${t.timeout}s)\u2026 Ctrl-C \u3067\u4E2D\u65AD`);let h={channelId:i,ts:s,question:c.question,reactable:c.reactable,threadOnly:c.threadOnly,audience:d,broadcast:l,askerUserId:u,askerBotId:f,timeout:t.timeout,shown:t.link,asBot:t.asBot};if(r)h.threadParentTs=r;if(t.cookie)h.cookie=t.cookie;await Nc(e,h)}var Ne=3;function ed(e){return`slack poll --results='${e}'`}async function td(e,t){let{ref:n,threadTs:i}=Fn(t.target,!1),s=t.cookie,r=Nt(e,s),o;if(t.channelId)o=t.channelId;else if(t.userId)o=await Pt(e,t.userId,s);else o=await De(e,n,s);let a=(await r())?.userId??"",c=await qi(e,o,s);if(!t.asBot&&!!a&&c===a)console.error(`Warning: "${t.target}" is a DM to yourself \u2014 Slack will NOT notify you of your own message.
|
|
183
|
+
`+` To reach yourself with a notification, post as the bot: slack poll '${t.target}' '...' --as-bot`);let u=ds(t.question),f=ds(t.body??""),l=t.mentionToken??e,d=await Bt(l,u.text,o,t.mentionCookie),h=f.text?await Bt(l,f.text,o,t.mentionCookie):{text:"",resolved:[],unresolved:[]},m=d.text,p=h.text;for(let S of yn([...d.unresolved,...h.unresolved]))console.error(`\u26A0 ${te(S)}`);let y=t.choices,E=!!t.multi,F=t.until??"",k=Ta(m,p,y,{multi:E,deadline:F}),C="",A="?";try{let S=await Ze(e,o,1,void 0,void 0,s),x=X(S.messages).map(T).filter((O)=>O.subtype===void 0||O.subtype===null)[0];C=typeof x?.text==="string"?x.text:"",A=typeof x?.user==="string"?await ze(e,x.user,s):typeof x?.username==="string"?x.username:"?"}catch{}let P=await r(),v=He(o,i??"",C,k,P?.userId??"");if(t.code!==v){let S=await ms(e,o,n,s);ve(t.code,v,["--- Last message in channel ------------------",` ${A}: ${C.split(`
|
|
184
|
+
`)[0]?.slice(0,100)??"(empty)"}`,"--- Ballot (seeded as reactions) -------------",...y.map((x,O)=>` ${Be[O].glyph} ${x}`),"--- Posting ----------------------------------",je(P,{asBot:t.asBot}),` \u2192 ${S}${i?" \u2014 THREAD REPLY":" \u2014 NEW top-level message"}`,` Question: ${m}`,` Rule: ${E?"1 \u4EBA \u4F55\u7968\u3067\u3082 (--multi)":"1 \u4EBA 1 \u7968"}${F?` \u2014 \u7DE0\u5207 ${F}`:""}`," Note: \u3042\u306A\u305F\u81EA\u8EAB\u306E\u7968\u306F\u6570\u3048\u307E\u305B\u3093 (\u30D4\u30EB\u306F\u3042\u306A\u305F\u304C\u4ED8\u3051\u305F\u7A2E\u306A\u306E\u3067\u533A\u5225\u3067\u304D\u307E\u305B\u3093)","--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"])}let L=await rs(e,o,k,i,!1,s,!0);try{await ct(e,o,L,cn,s)}catch(S){console.error(` (marker ${cn} \u3092\u4ED8\u3051\u3089\u308C\u307E\u305B\u3093\u3067\u3057\u305F: ${S instanceof Error?S.message:String(S)})`)}for(let S=0;S<y.length;S++)try{await ct(e,o,L,Be[S].name,s)}catch(x){console.error(` (\u30EA\u30A2\u30AF\u30B7\u30E7\u30F3 ${Be[S].name} \u3092\u4ED8\u3051\u3089\u308C\u307E\u305B\u3093\u3067\u3057\u305F: ${x instanceof Error?x.message:String(x)})`)}let R="";try{R=await ln(e,o,L,s)}catch{}let G=R||`${o}:${L}`;console.error(`\u2713 Posted: ${G}`),console.log(ed(G)),console.error(` \u7DE0\u3081\u5207\u308B: slack poll --close='${G}'${t.asBot?" --as-bot":""}`)}async function nd(e,t,n){let i=Rt(t),s,r,o;if(i?.ts)s=i.channel,r=i.ts,o=i.threadTs&&i.threadTs!==i.ts?i.threadTs:void 0;else{let c=t.match(/^([A-Za-z0-9]+):(\d{10}\.\d{6})$/);if(!c)console.error(`Error: --results/--close needs the permalink of a poll (or 'C\u2026:1700000000.000100').
|
|
185
|
+
`+` Got: ${te(t)}`),process.exit(Ne);s=c[1],r=c[2]}let a;if(o){let c=T(await Ke(e,s,o,100,n));a=X(c.messages).map(T).find((u)=>u.ts===r)}else{let c=T(await Ze(e,s,1,r,void 0,n,!0));a=X(c.messages).map(T).find((u)=>u.ts===r)}if(!a)console.error(`Error: \u305D\u306E\u30E1\u30C3\u30BB\u30FC\u30B8\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093: ${te(t)}`),process.exit(Ne);return{channelId:s,ts:r,msg:a}}function Ac(e){let t=Math.max(1,...e.map((n)=>n.count));return e.map((n,i)=>`${Be[i].glyph} ${String(n.count).padStart(3)} ${"\u2588".repeat(Math.round(n.count/t*20))}${n.count?" ":""}${n.choice}`)}async function sd(e,t){let{channelId:n,ts:i,msg:s}=await nd(e,t.link,t.cookie),r=typeof s.text==="string"?s.text:"",o=Ra(r);if(o.kind==="other")console.error("Error: \u3053\u308C\u306F `slack poll` \u306E\u6295\u7968\u3067\u306F\u3042\u308A\u307E\u305B\u3093 (\u7968\u306E\u6570\u3048\u65B9\u304C\u5206\u304B\u308A\u307E\u305B\u3093)\u3002\n"+` ${te(t.link)}`),process.exit(Ne);if(o.kind==="closed"){console.error(`\u2713 \u6295\u7968\u7D42\u4E86: ${te(o.question)}`);for(let h of Ac(o.tallies))console.log(h);return}let a=new Set;if(typeof s.user==="string"&&s.user)a.add(s.user);let c=await Xa(e,n,i,t.cookie),u=Ma(o.choices,c,a,o.multi);console.error(`${te(o.question)}${o.deadline?` (\u7DE0\u5207 ${o.deadline})`:""}`);for(let h of Ac(u.tallies))console.log(h);let f=u.tallies.reduce((h,m)=>h+m.count,0);if(console.error(` \u8A08 ${f} \u7968${o.multi?" (\u8907\u6570\u9078\u629E\u53EF)":""}`),t.names)for(let h=0;h<u.voters.length;h++){if(!u.voters[h].length)continue;let m=await Promise.all(u.voters[h].map((p)=>ze(e,p,t.cookie)));console.error(` ${Be[h].glyph} ${m.map((p)=>`@${te(p)}`).join(", ")}`)}let l=o.multi?[]:u.ambiguous,d=wi(r,l);if(d!==r&&!t.noNotify)try{await Yt(t.writeToken??e,n,i,d,t.writeToken?t.writeCookie:t.cookie,!0)}catch(h){console.error(` (\u6295\u7968\u6587\u306B\u6CE8\u610F\u66F8\u304D\u3092\u5165\u308C\u3089\u308C\u307E\u305B\u3093\u3067\u3057\u305F: ${h instanceof Error?h.message:String(h)})
|
|
186
|
+
`+" \u30E1\u30C3\u30BB\u30FC\u30B8\u3092\u66F8\u304D\u63DB\u3048\u3089\u308C\u308B\u306E\u306F\u6295\u7A3F\u8005\u3060\u3051\u3067\u3059 \u2014 bot \u304C\u6295\u7A3F\u3057\u305F\u6295\u7968\u306A\u3089 --as-bot \u3092\u4ED8\u3051\u3066\u304F\u3060\u3055\u3044\u3002")}if(u.ambiguous.length){let h=await Promise.all(u.ambiguous.map((m)=>ze(e,m,t.cookie)));console.error(`\u26A0 1 \u4EBA 1 \u7968\u306A\u306E\u306B\u8907\u6570\u62BC\u3057\u3066\u3044\u308B\u4EBA\u304C\u3044\u307E\u3059 (\u7121\u52B9\u7968): ${h.map((m)=>`@${te(m)}`).join(", ")}`)}if(!t.close)return;await Yt(t.writeToken??e,n,i,Pa(o.question,u.tallies),t.writeToken?t.writeCookie:t.cookie,!0);try{await ct(t.writeToken??e,n,i,Si,t.writeToken?t.writeCookie:t.cookie),await fn(t.writeToken??e,n,i,cn,t.writeToken?t.writeCookie:t.cookie)}catch{}console.error(`\u2713 \u6295\u7968\u3092\u7DE0\u3081\u5207\u308A\u307E\u3057\u305F: ${te(t.link)}`)}async function id(e){let t=await oi(e);for(let n of ai(t,!1))console.log(n);if(!t.ok)process.exit(1)}function rd(e){if(/^\d{10,}$/.test(e))return parseInt(e,10);let t=new Date(e.replace(" ","T"));if(isNaN(t.getTime()))throw Error(`Cannot parse time: ${e}`);return Math.floor(t.getTime()/1000)}function od(e){let t=new Date(e*1000);return`${new Intl.DateTimeFormat("sv-SE",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,timeZoneName:"short"}).format(t).replace(/\u2212/g,"-")} (local) / ${t.toISOString()} (Unix: ${e})`}async function ad(e,t){let n=Nt(e,t.cookie),{ref:i,threadTs:s}=Fn(t.target),r;if(t.channelId)r=t.channelId;else if(t.userId)r=await Pt(e,t.userId,t.cookie);else r=await De(e,i,t.cookie);let o=rd(t.at),a=new Date(o*1000).toISOString(),c=await n();if(await Hi(e,r,c?.userId,t.cookie))console.error(`Warning: "${t.target}" is a DM to yourself \u2014 Slack will NOT notify you when this fires.`);let u=He(r,t.message,String(o),c?.userId??"");if(t.code!==u)ve(t.code,u,["--- Scheduling message -----------------------",je(c,{pad:9}),` To: ${i}${s?` (thread ${s})`:""}`,` At: ${od(o)}`,` Message: ${t.message}`,"---------------------------------------------"]);let f=await za(e,r,t.message,o,s,t.cookie);console.log(`\u2713 Scheduled (id: ${f}, at: ${a})`)}async function cd(e,t,n,i){let s;if(n)s=n;else if(t)s=await De(e,t,i);let o=(await Ha(e,s,i)).scheduled_messages??[];if(o.length===0){console.log("(no scheduled messages)");return}for(let a of o){let c=new Date(a.post_at*1000).toISOString();console.log(`${a.id} ${c} [${a.channel_id}] ${a.text.split(`
|
|
187
|
+
`)[0]?.slice(0,80)??""}`)}}async function ud(e,t){let n;if(t.channelId)n=t.channelId;else n=await De(e,t.target,t.cookie);let i=await Vt(e,t.cookie),s=He(n,t.id,i?.userId??"");if(t.code!==s)ve(t.code,s,["--- Deleting scheduled message ---------------",je(i,{pad:9}),` Channel: ${t.target}`,` ID: ${t.id}`,"---------------------------------------------"]);await qa(e,n,t.id,t.cookie),console.log(`\u2713 Deleted scheduled message ${t.id}`)}async function ld(e,t){let n=Nt(e,t.cookie),{statSync:i,existsSync:s}=await import("fs"),{basename:r}=await import("path");for(let m of t.filePaths)if(!s(m))console.error(`Error: file not found: ${m}`),process.exit(1);let{ref:o,threadTs:a}=Fn(t.target),c;if(t.channelId)c=t.channelId;else if(t.userId)c=await Pt(e,t.userId,t.cookie);else c=await De(e,o,t.cookie);if(await Hi(e,c,(await n())?.userId,t.cookie))console.error(`Warning: "${t.target}" is a DM to yourself \u2014 Slack will NOT notify you of your own upload.`);let u=t.filePaths.length>1,f=t.filePaths.map((m)=>{let p=r(m),y=u?p:t.title??p;return{fp:m,filename:p,title:y,sizeFmt:hs(i(m).size)}}),l=await n(),d=He(c,...f.flatMap((m)=>[m.fp,m.title]),l?.userId??"");if(t.code!==d){let m=` To: ${o}${a?` (thread ${a})`:""}`,p=u?[`--- Uploading ${f.length} files ------------------------`,je(l,{pad:7}),m,...f.map((y)=>` ${y.filename} (${y.sizeFmt})`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]:["--- Uploading file ---------------------------",je(l,{pad:7}),m,` File: ${f[0].fp}`,` Title: ${f[0].title}`,` Size: ${f[0].sizeFmt}`,"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"];ve(t.code,d,p)}let h=f.length;for(let m=0;m<h;m++){let p=f[m],y={title:p.title};if(a!==void 0)y.threadTs=a;if(t.comment!==void 0&&m===0)y.initialComment=t.comment;let{fileId:E,permalink:F}=await sc(e,c,p.fp,y,t.cookie),k=h>1?`[${m+1}/${h}] `:"";console.log(`${k}\u2713 Uploaded (file_id: ${E}${F?`, url: ${F}`:""})`)}}async function fd(e,t,n){let i=n.channel?await De(e,n.channel,t):void 0,s=[],r=1,o=1;do{let c={page:r,count:200};if(n.types)c.types=n.types;if(i)c.channel=i;if(n.user)c.user=n.user;let u=T(await Wa(e,c,t));for(let f of X(u.files))s.push(T(f));o=Number(T(u.paging).pages??1),r++}while(s.length<n.limit&&r<=o);let a=s.slice(0,n.limit);if(n.format==="jsonl"){for(let c of a)console.log(JSON.stringify({id:c.id??null,name:c.name??c.title??null,filetype:c.filetype??null,size:c.size??null,user:c.user??null,created:c.created??null,permalink:c.permalink??null}));return}for(let c of a){let u=String(c.id??""),f=typeof c.name==="string"?c.name:typeof c.title==="string"?c.title:u,l=typeof c.filetype==="string"?c.filetype:"?",d=typeof c.size==="number"?hs(c.size):"";console.log(`${u} ${l.padEnd(7)} ${d.padStart(9)} ${f}`)}}function dd(e){if(/^F[A-Z0-9]+$/i.test(e))return e;return e.match(/\/lists\/[A-Za-z0-9]+\/(F[A-Za-z0-9]+)/i)?.[1]??e.match(/\/lists\/(F[A-Za-z0-9]+)/i)?.[1]}function pd(e){if(typeof e.text==="string"&&e.text)return e.text;let t=e.value;if(typeof t==="string"||typeof t==="number"||typeof t==="boolean")return String(t);if(Array.isArray(t))return t.map((n)=>typeof n==="string"?n:String(T(n).text??T(n).name??T(n).value??"")).filter(Boolean).join(", ");for(let n of["rich_text","select","user","date","number","checkbox","email","phone"]){let i=e[n];if(i!=null)return typeof i==="object"?JSON.stringify(i):String(i)}return""}async function hd(e,t,n,i){let s=dd(n);if(!s)throw Error(`Not a list ID or list URL: ${n}
|
|
188
|
+
`+"Expected F\u2026 or https://<ws>.slack.com/lists/<TEAM>/<F-id>");let r=[],o;do{let c={limit:200};if(o)c.cursor=o;let u=T(await Ua(e,s,c,t));for(let l of X(u.items??u.records))r.push(T(l));let f=T(u.response_metadata).next_cursor;o=typeof f==="string"&&f?f:void 0}while(o&&r.length<i.limit);let a=r.slice(0,i.limit);if(i.format==="jsonl"){for(let c of a)console.log(JSON.stringify(c));return}for(let c of a){let u=String(c.id??""),f=X(c.fields).map(T).map((l)=>{let d=String(l.key??l.column_id??"?"),h=pd(l);return h?`${d}=${h}`:""}).filter(Boolean);console.log(`${u} ${f.join(" | ")}`)}}function gd(e){if(/^F[A-Z0-9]+$/i.test(e))return e;return e.match(/\/files\/[A-Za-z0-9]+\/(F[A-Za-z0-9]+)/)?.[1]}async function md(e,t,n,i){let s=gd(n);if(!s)throw Error(`Not a file ID or file permalink: ${n}
|
|
189
|
+
`+"Expected F\u2026 or https://<ws>.slack.com/files/<UID>/<FID>/<name>");let r=T(await La(e,s,t)),o=T(r.file),a=typeof o.name==="string"?o.name:typeof o.title==="string"?o.title:s,c=typeof o.url_private_download==="string"?o.url_private_download:typeof o.url_private==="string"?o.url_private:"";if(!c)throw Error(`files.info returned no download URL for ${s}`);let u={Authorization:`Bearer ${e}`};if(t)u.Cookie=`d=${t}`;let f=await fetch(c,{headers:u});if(!f.ok)throw Error(`Download failed: HTTP ${f.status} ${f.statusText}`);let l=Buffer.from(await f.arrayBuffer()),{statSync:d,existsSync:h}=await import("fs"),{basename:m}=await import("path"),p=i??a;if(i&&h(i)&&d(i).isDirectory())p=ft(i,m(a));Oc(p,l),console.log(`\u2713 Downloaded ${a} (${hs(l.length)}) \u2192 ${p}`)}async function Dd(){wf();let e=(s)=>ei(s.workspace),t=(s)=>No(s.workspace),n={state:{type:"string",choices:["open","untriaged","pending","doing","done","dropped","stuck"],default:"open",describe:"open (default) = marked and not done/dropped; untriaged = marked with no progress; stuck = unfinished with a reason flag"},in:{type:"string",describe:"Limit to a channel (#chan)"},from:{type:"string",describe:"Limit to a sender (@user, or 'me') \u2014 usually the person a task is waiting on"},n:{alias:"count",type:"number",default:50,describe:"Max results"},json:{type:"boolean",default:!1}},i=async(s,r)=>{let o={state:s.state??"open",mine:r||s.mine===!0,count:s.n??50,json:s.json===!0};if(s.in)o.in=s.in;if(s.from)o.from=s.from;let a=t(s);if(a)o.cookie=a;await Of(e(s),o)};await Oo(Is(process.argv)).scriptName("slack").showHelpOnFail(!1).fail((s,r,o)=>{if(r)console.error(r.message),process.exit(1);console.error(s),console.error(""),o.showHelp(),process.exit(1)}).option("workspace",{alias:"w",type:"string",describe:"Workspace name"}).middleware(async(s)=>{let r=String((s._??[])[0]??"");if(!r||r==="auth"||r==="login")return;try{ei(s.workspace)}catch(o){if((o instanceof Error?o.message:String(o)).startsWith("No profiles configured"))console.log(`No workspace configured. Let's set that up:
|
|
190
|
+
`),await Vn(),process.exit(0);throw o}},!0).command(["read [target]","msgs [target]"],"Browse messages",(s)=>s.positional("target",{type:"string",describe:"#channel, @user, or URL"}).option("limit",{alias:"n",type:"number",default:20,describe:"Number of messages"}).option("format",{type:"string",choices:["text","jsonl"],default:"text",describe:"jsonl exposes raw ts/user/text (incl. external-guest user IDs)"}).option("json",{type:"boolean",default:!1,describe:"Alias for --format=jsonl"}).option("unreplied",{type:"boolean",default:!1,describe:"Only messages whose last word (incl. thread replies) is not yours \u2014 i.e. awaiting your answer"}),async(s)=>{let r=e(s),o=s.json?"jsonl":s.format;if(s.target)await xf(r,s.target,s.limit,o,s.unreplied,t(s));else await Sf(r)}).command("thread <target> <ts>","Show thread messages",(s)=>s.positional("target",{type:"string",demandOption:!0}).positional("ts",{type:"string",demandOption:!0}).option("limit",{alias:"n",type:"number",default:100}).option("format",{type:"string",choices:["text","jsonl"],default:"text",describe:"jsonl exposes raw ts/user/text (incl. external-guest user IDs)"}).option("json",{type:"boolean",default:!1,describe:"Alias for --format=jsonl"}),async(s)=>{let r=s.json?"jsonl":s.format;await _f(e(s),s.target,s.ts,s.limit,r,t(s))}).command(["channel","channels","ch"],"Channel commands",(s)=>s.command(["ls","list"],"List channels",(r)=>r.option("limit",{alias:"n",type:"number",default:200}).option("filter",{alias:"f",type:"string"}).option("all",{type:"boolean",default:!1}).option("format",{type:"string",choices:["text","jsonl"],default:"text"}).option("json",{type:"boolean",default:!1,describe:"Alias for --format=jsonl"}),async(r)=>{await Af(e(r),r.limit,r.filter,r.all,r.json?"jsonl":r.format)}).command("get <channel>","Show channel details",(r)=>r.positional("channel",{type:"string",demandOption:!0,describe:"#name or channel ID"}),async(r)=>{let o=e(r),a=t(r),c=r.channel,u=c.startsWith("#")||c.startsWith("@")||c.startsWith("C")||c.startsWith("G")||c.startsWith("D")?c:`#${c}`,f=await De(o,u,a),l=T(await mn(o,f,a)),d=T(l.channel),h=typeof d.name==="string"?d.name:f,p=d.is_im===!0?"@":"#",y=String(T(d.purpose).value??""),E=String(T(d.topic).value??""),F=d.num_members??d.member_count??"";if(console.log(`${p}${h} ${f}`),E)console.log(`topic: ${E}`);if(y)console.log(`purpose: ${y}`);if(F)console.log(`members: ${F}`);console.log(`private: ${d.is_private===!0}`)}).command(["create <name>","new <name>"],"Create a channel (confirm-hash safety gate)",(r)=>r.positional("name",{type:"string",demandOption:!0,describe:"Channel name (Slack lowercases it; no spaces)"}).option("private",{type:"boolean",default:!1,describe:"Create a private channel"}).option("invite",{type:"string",array:!0,default:[],describe:"Users to invite after creating (@handle or Uxxxx, repeatable)"}).option("code",{type:"string",describe:"Safety hash to confirm create"}),async(r)=>{let o=e(r),a=t(r),c=r.name.replace(/^#/,"").toLowerCase(),u=r.private===!0,f=r.invite.filter(Boolean),l=await Vt(o,a),d=He(c,String(u),f.join(","),l?.userId??"");if(r.code!==d)ve(r.code,d,["--- Creating channel -------------------------",je(l,{pad:9}),` name: ${u?"\uD83D\uDD12 ":"#"}${c}`,` private: ${u}`,...f.length?[` invite: ${f.join(", ")}`]:[],"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);let h;try{h=await Ga(o,c,u,a)}catch(m){console.error(m instanceof Error?m.message:String(m)),process.exit(1)}if(console.log(`\u2713 Created ${u?"\uD83D\uDD12 ":"#"}${h.name} (${h.id})`),f.length){let m=[];for(let p of f)try{m.push(p.startsWith("U")||p.startsWith("W")?p:await pn(o,p,a))}catch(y){console.error(` ! could not resolve ${p}: ${y instanceof Error?y.message:String(y)}`)}for(let p of m)try{let y=T(await os(o,p,a)),E=T(y.user);if(E.is_ultra_restricted===!0)console.error(`\u26A0 ${p} is a single-channel guest \u2014 Slack restricts them to their one existing channel; this invite will likely report success but not actually add them.`);else if(E.is_restricted===!0)console.error(`\u26A0 ${p} is a multi-channel guest \u2014 double-check they were actually added (guest invites can silently no-op depending on workspace restrictions).`)}catch{}if(m.length)try{await Va(o,h.id,m,a),console.log(`\u2713 Invited ${m.length} member${m.length===1?"":"s"}`)}catch(p){console.error(` ! invite failed: ${p instanceof Error?p.message:String(p)}`)}}}).demandCommand(1,"").showHelpOnFail(!0)).command(["user","usr"],"User commands",(s)=>s.command(["ls","list"],"List workspace members",(r)=>r.option("limit",{alias:"n",type:"number",default:200}).option("filter",{alias:"f",type:"string"}).option("format",{type:"string",choices:["text","jsonl","yaml"],default:"text"}).option("json",{type:"boolean",default:!1,describe:"Alias for --format=jsonl"}).option("external",{type:"boolean",default:!1,describe:"Also include people reachable only through Slack Connect shared channels \u2014 they are in ANOTHER workspace, so users.list never returns them (costs one API call per shared channel)"}),async(r)=>{let o=r.json?"jsonl":r.format,a=e(r),c=t(r),u=await $i(a,c),f=r.filter?.toLowerCase(),l=X(u.members).map(T);if(r.external){let p=new Set(l.map((k)=>String(k.id))),y=T(await dn(a,c)),E=X(y.channels).map(T).filter((k)=>k.is_ext_shared===!0&&!!k.name),F=new Set;for(let k of E)try{for(let C of await Za(a,String(k.id),c))if(!p.has(C))F.add(C)}catch{}for(let k of F)try{let C=T(await os(a,k,c)),A=T(C.user);if(A.id)l.push(A)}catch{}}let d=l.filter((p)=>p.deleted!==!0&&p.is_bot!==!0&&String(p.id)!=="USLACKBOT").filter((p)=>{if(!f)return!0;let y=String(p.name??"").toLowerCase(),E=String(T(p.profile).real_name??"").toLowerCase(),F=String(T(p.profile).email??"").toLowerCase();return y.includes(f)||E.includes(f)||F.includes(f)}).slice(0,r.limit);if(o==="jsonl"){for(let p of d)console.log(JSON.stringify(p));return}if(o==="yaml"){for(let p of d){let y=function(E,F=""){if(E===null)return"null";if(typeof E==="string")return E.includes(`
|
|
190
191
|
`)?`|
|
|
191
192
|
${E.split(`
|
|
192
193
|
`).join(`
|
|
193
194
|
`)}`:E;if(typeof E!=="object")return String(E);if(Array.isArray(E))return E.map((k)=>`
|
|
194
195
|
${F} - ${y(k,F+" ")}`).join("");return Object.entries(E).map(([k,C])=>`
|
|
195
|
-
${F} ${k}: ${y(C,F+" ")}`).join("")};console.log("---");for(let[E,F]of Object.entries(p))console.log(`${E}: ${y(F)}`)}return}let h=Intl.DateTimeFormat().resolvedOptions().timeZone,m=d.length?String(
|
|
196
|
+
${F} ${k}: ${y(C,F+" ")}`).join("")};console.log("---");for(let[E,F]of Object.entries(p))console.log(`${E}: ${y(F)}`)}return}let h=Intl.DateTimeFormat().resolvedOptions().timeZone,m=d.length?String(T(X(u.members).map(T)[0]??{}).team_id??""):"";for(let p of d){let y=T(p.profile),E=String(p.name??p.id),F=String(p.id??""),k=String(y.display_name||""),C=String(y.real_name||""),A=String(y.email||""),P=String(p.tz??""),L=[...new Set([k,C].filter((O)=>O&&O!==E))].join(" / "),R=P&&P!==h?P:"",G=String(p.team_id??""),S=p.is_stranger===!0||m&&G&&G!==m?`external:${G||"?"}`:p.is_ultra_restricted===!0?"single-channel guest":p.is_restricted===!0?"guest":"",x=[A,R].filter(Boolean).join(" ");console.log(`@${E} ${F} ${L}${x?" "+x:""}${S?` [${S}]`:""}`)}}).command("get <user>","Show user details",(r)=>r.positional("user",{type:"string",demandOption:!0,describe:"@handle or user ID"}),async(r)=>{let o=e(r),a=r.user.startsWith("@")?r.user.slice(1):r.user,c=a;if(!/^U[A-Z0-9]+$/.test(a)){let P=await $i(o,t(r)),v=X(P.members).map(T).find((L)=>String(L.name??"")===a);if(!v)console.error(`User not found: @${a}`),process.exit(1);c=String(v.id)}let u=T(await os(o,c)),f=T(u.user),l=T(f.profile),d=Intl.DateTimeFormat().resolvedOptions().timeZone,h=String(f.name??c),m=String(f.id??c),p=String(l.display_name||""),y=String(l.real_name||""),E=String(l.email||""),F=String(f.tz??""),k=String(l.phone||""),C=String(l.title||"");console.log(`@${h} ${m}`);let A=[...new Set([p,y].filter((P)=>P&&P!==h))];if(A.length)console.log(`name: ${A.join(" / ")}`);if(E)console.log(`email: ${E}`);if(k)console.log(`phone: ${k}`);if(C)console.log(`title: ${C}`);if(F&&F!==d)console.log(`tz: ${F}`)}).demandCommand(1,"").showHelpOnFail(!0)).command("news","Activity feed (mentions to you)",(s)=>s.option("limit",{alias:"l",type:"number",default:20}),async(s)=>{await kf(e(s),s.limit)}).command("search <query>","Full-text search",(s)=>s.positional("query",{type:"string",demandOption:!0}).option("count",{alias:"n",type:"number",default:100}).option("json",{type:"boolean",default:!1,describe:"Output raw JSON"}),async(s)=>{await Pc(e(s),s.query,s.count,s.json,t(s))}).command("send <target> <message>","Send a message (confirm-hash safety gate)",(s)=>s.positional("target",{type:"string",demandOption:!0,describe:"#chan, @user, #chan:thread_ts, or permalink (a message permalink replies in its thread)"}).positional("message",{type:"string",demandOption:!0}).option("code",{type:"string",describe:"Safety hash to confirm send"}).option("channel-id",{type:"string",describe:"Raw channel ID"}).option("user-id",{type:"string",describe:"Raw user ID (opens DM)"}).option("as-bot",{type:"boolean",default:!1,describe:"Send via the bot token (xoxb / SLACK_BOT_TOKEN) so a DM notifies the recipient and can be two-way"}).option("broadcast",{type:"boolean",default:!1,describe:`Also send to channel: broadcast a threaded reply back to the channel (Slack's "Also send to #channel" checkbox). Only effective with a thread target.`}).option("mentions",{type:"boolean",default:!0,describe:"Convert @handle tokens to real <@USERID> mentions (on by default; resolves via users.list, then channel members for Slack Connect guests). Unresolved handles stay as plain text. The confirm preview shows the converted message before sending. Disable with --no-mentions for literal @text."}),async(s)=>{let r={target:s.target,message:s.message};if(s.code)r.code=s.code;if(s["channel-id"])r.channelId=s["channel-id"];if(s["user-id"])r.userId=s["user-id"];if(s.broadcast)r.broadcast=!0;if(s.mentions!==!1){r.mentions=!0,r.mentionToken=e(s);let a=t(s);if(a)r.mentionCookie=a}let o;if(s["as-bot"]){let a=Kt();if(!a)console.error(`Error: --as-bot needs a bot token, but no xoxb- token was found.
|
|
196
197
|
Set SLACK_BOT_TOKEN=xoxb-... in ~/.config/slack-cli/.env (or your shell).`),process.exit(1);if(!r.channelId&&!r.userId&&r.target.startsWith("@"))try{r.userId=await pn(e(s),r.target,t(s))}catch(c){console.error(`Error: could not resolve ${r.target} to a user for the bot DM.
|
|
197
198
|
${c instanceof Error?c.message:String(c)}
|
|
198
|
-
Tip: pass --user-id <Uxxxx> to skip the lookup.`),process.exit(1)}o=a,r.asBot=!0}else{o=e(s);let a=t(s);if(a)r.cookie=a}try{await
|
|
199
|
-
Set SLACK_BOT_TOKEN=xoxb-... in ~/.config/slack-cli/.env (or your shell).`),process.exit(Ce);l=h}else l=e(s),d=t(s);try{let h={link:r,timeout:o,asBot:!!s["as-bot"]};if(d)h.cookie=d;await
|
|
199
|
+
Tip: pass --user-id <Uxxxx> to skip the lookup.`),process.exit(1)}o=a,r.asBot=!0}else{o=e(s);let a=t(s);if(a)r.cookie=a}try{await Kf(o,r)}catch(a){console.error(tt(a)),process.exit(1)}}).command("ask [target] [question] [choices..]","Ask a question with its choices pre-seeded as 1\uFE0F\u20E3..\uD83D\uDD1F reactions (confirm-hash safety gate)",(s)=>s.positional("target",{type:"string",describe:"#chan, @user, #chan:thread_ts, or permalink (omit with --waitFor)"}).positional("question",{type:"string",describe:"The question. Must @tag whoever may answer (@alice), or the whole channel (@here / @channel / @everyone) \u2014 only their answer counts. In a 1:1 DM the other party counts automatically."}).positional("choices",{type:"string",array:!0,describe:"Up to 10 choices, seeded as 1\uFE0F\u20E3..\uD83D\uDD1F reactions. Beyond 10 they are listed but answerable only by text. With none, the question asks for a free-text reply."}).option("code",{type:"string",describe:"Safety hash to confirm the ask"}).option("body",{type:"string",describe:"Extra context shown under the question"}).option("wait",{type:"boolean",default:!1,describe:"Block until answered; print ONLY the answer on stdout. Exit 0 = answered, 2 = timed out, 3 = transport failure."}).option("waitFor",{type:"string",describe:"Collect the answer to a question already posted: pass its permalink. Nothing is posted. Same stdout/exit contract as --wait; --timeout 0 checks once and exits 2 if still open."}).option("timeout",{type:"number",default:3600,describe:"Overall limit for --wait / --waitFor, in seconds (0 with --waitFor = check once)"}).option("channel-id",{type:"string",describe:"Raw channel ID"}).option("user-id",{type:"string",describe:"Raw user ID (opens DM)"}).option("as-bot",{type:"boolean",default:!1,describe:"Ask via the bot token (xoxb / SLACK_BOT_TOKEN) so a DM notifies the recipient"}),async(s)=>{let r=s.waitFor?String(s.waitFor):"",o=Number(s.timeout);if(!Number.isFinite(o)||o<0||o===0&&!r)console.error("Error: --timeout must be a positive number of seconds"),process.exit(Ce);if(r){if(s.target||s.question||s.choices?.length)console.error("Error: --waitFor collects an existing question \u2014 do not also pass a target/question/choices."),process.exit(Ce);let l,d;if(s["as-bot"]){let h=Kt();if(!h)console.error(`Error: --as-bot needs a bot token, but no xoxb- token was found.
|
|
200
|
+
Set SLACK_BOT_TOKEN=xoxb-... in ~/.config/slack-cli/.env (or your shell).`),process.exit(Ce);l=h}else l=e(s),d=t(s);try{let h={link:r,timeout:o,asBot:!!s["as-bot"]};if(d)h.cookie=d;await Qf(l,h)}catch(h){console.error(tt(h)),process.exit(Ce)}return}if(!s.target)console.error("Error: target is required (or use --waitFor <permalink> to collect an answer)"),process.exit(Ce);let a=String(s.question??"").trim();if(!a)console.error("Error: question is empty"),process.exit(Ce);let c={target:s.target,question:a,choices:(s.choices??[]).map((l)=>String(l).trim()).filter(Boolean),timeout:o};if(s.code)c.code=s.code;if(s.body)c.body=s.body;if(s.wait)c.wait=!0;if(s["channel-id"])c.channelId=s["channel-id"];if(s["user-id"])c.userId=s["user-id"];c.mentionToken=e(s);let u=t(s);if(u)c.mentionCookie=u;let f;if(s["as-bot"]){let l=Kt();if(!l)console.error(`Error: --as-bot needs a bot token, but no xoxb- token was found.
|
|
200
201
|
Set SLACK_BOT_TOKEN=xoxb-... in ~/.config/slack-cli/.env (or your shell).`),process.exit(Ce);if(!c.channelId&&!c.userId&&c.target.startsWith("@"))try{c.userId=await pn(e(s),c.target,t(s))}catch(d){console.error(`Error: could not resolve ${c.target} to a user for the bot DM.
|
|
201
202
|
${d instanceof Error?d.message:String(d)}
|
|
202
|
-
Tip: pass --user-id <Uxxxx> to skip the lookup.`),process.exit(Ce)}f=l,c.asBot=!0}else{f=e(s);let l=t(s);if(l)c.cookie=l}try{await
|
|
203
|
-
Set SLACK_BOT_TOKEN=xoxb-... in ~/.config/slack-cli/.env (or your shell).`),process.exit(Ne);return d};if(r){if(s.target||s.question||s.choices?.length)console.error("Error: --results/--close reads an existing poll \u2014 do not also pass a target/question/choices."),process.exit(Ne);let d=e(s),h=t(s);try{let m={link:r};if(s.close)m.close=!0;if(s.names)m.names=!0;if(s["no-notify"])m.noNotify=!0;if(h)m.cookie=h;if(s["as-bot"])m.writeToken=o();await
|
|
203
|
+
Tip: pass --user-id <Uxxxx> to skip the lookup.`),process.exit(Ce)}f=l,c.asBot=!0}else{f=e(s);let l=t(s);if(l)c.cookie=l}try{await Zf(f,c)}catch(l){console.error(tt(l)),process.exit(Ce)}}).command(["poll [target] [question] [choices..]","vote [target] [question] [choices..]"],"Post a poll with its choices pre-seeded as 1\uFE0F\u20E3..\uD83D\uDD1F reactions, then count them (confirm-hash safety gate)",(s)=>s.positional("target",{type:"string",describe:"#chan, @user, #chan:thread_ts, or permalink (omit with --results/--close)"}).positional("question",{type:"string",describe:"The question. @tags are optional here \u2014 unlike `ask`, a poll needs no addressee: anyone who can see it may vote."}).positional("choices",{type:"string",array:!0,describe:"2..10 choices, seeded as 1\uFE0F\u20E3..\uD83D\uDD1F reactions for voters to click"}).option("multi",{type:"boolean",default:!1,describe:"Let one person pick several choices (default: 1 \u4EBA 1 \u7968)"}).option("until",{type:"string",describe:"Deadline shown in the message (display only \u2014 closing is still `--close`)"}).option("results",{type:"string",describe:"Count an existing poll: pass its permalink. Posts nothing; only edit is the invalid-ballot notice in the poll itself (--no-notify to suppress)."}).option("close",{type:"string",describe:"Count an existing poll AND freeze the tally into the message. Only the poster can do this."}).option("names",{type:"boolean",default:!1,describe:"Also list who voted for what (stderr)"}).option("no-notify",{type:"boolean",default:!1,describe:"With --results: do not write the invalid-ballot notice back into the message (keeps it strictly read-only)"}).option("code",{type:"string",describe:"Safety hash to confirm the post"}).option("body",{type:"string",describe:"Extra context shown under the question"}).option("channel-id",{type:"string",describe:"Raw channel ID"}).option("user-id",{type:"string",describe:"Raw user ID (opens DM)"}).option("as-bot",{type:"boolean",default:!1,describe:"Post via the bot token (xoxb / SLACK_BOT_TOKEN) so a DM notifies the recipient \u2014 and so YOUR OWN vote counts, since the seeds are then the bot's"}),async(s)=>{let r=s.close?String(s.close):s.results?String(s.results):"";if(s.results&&s.close)console.error("Error: pass --results or --close, not both (--close counts as well)."),process.exit(Ne);let o=()=>{let d=Kt();if(!d)console.error(`Error: --as-bot needs a bot token, but no xoxb- token was found.
|
|
204
|
+
Set SLACK_BOT_TOKEN=xoxb-... in ~/.config/slack-cli/.env (or your shell).`),process.exit(Ne);return d};if(r){if(s.target||s.question||s.choices?.length)console.error("Error: --results/--close reads an existing poll \u2014 do not also pass a target/question/choices."),process.exit(Ne);let d=e(s),h=t(s);try{let m={link:r};if(s.close)m.close=!0;if(s.names)m.names=!0;if(s["no-notify"])m.noNotify=!0;if(h)m.cookie=h;if(s["as-bot"])m.writeToken=o();await sd(d,m)}catch(m){console.error(tt(m)),process.exit(Ne)}return}if(!s.target)console.error("Error: target is required (or use --results <permalink> to count a poll)"),process.exit(Ne);let a=String(s.question??"").trim();if(!a)console.error("Error: question is empty"),process.exit(Ne);let c=(s.choices??[]).map((d)=>String(d).trim()).filter(Boolean);if(c.length<2||c.length>Ht)console.error(`Error: poll needs 2..${Ht} choices (got ${c.length}). For a free-text question use \`slack ask\`.`),process.exit(Ne);let u={target:s.target,question:a,choices:c};if(s.multi)u.multi=!0;if(s.until)u.until=String(s.until);if(s.code)u.code=s.code;if(s.body)u.body=s.body;if(s["channel-id"])u.channelId=s["channel-id"];if(s["user-id"])u.userId=s["user-id"];u.mentionToken=e(s);let f=t(s);if(f)u.mentionCookie=f;let l;if(s["as-bot"]){let d=o();if(!u.channelId&&!u.userId&&u.target.startsWith("@"))try{u.userId=await pn(e(s),u.target,t(s))}catch(h){console.error(`Error: could not resolve ${u.target} to a user for the bot DM.
|
|
204
205
|
${h instanceof Error?h.message:String(h)}
|
|
205
|
-
Tip: pass --user-id <Uxxxx> to skip the lookup.`),process.exit(Ne)}l=d,u.asBot=!0}else{l=e(s);let d=t(s);if(d)u.cookie=d}try{await
|
|
206
|
-
Set SLACK_BOT_TOKEN=xoxb-... in ~/.config/slack-cli/.env (or your shell).`),process.exit(1);await sd(s)}).command("schedule","Manage scheduled messages",(s)=>s.command("send <target> <message>","Schedule a message for later delivery",(r)=>r.positional("target",{type:"string",demandOption:!0,describe:"#chan, @user, #chan:thread_ts, or permalink (a message permalink replies in its thread)"}).positional("message",{type:"string",demandOption:!0}).option("at",{type:"string",demandOption:!0,describe:"Delivery time (ISO datetime or Unix ts)"}).option("code",{type:"string",describe:"Safety hash to confirm"}).option("channel-id",{type:"string",describe:"Raw channel ID"}).option("user-id",{type:"string",describe:"Raw user ID (opens DM)"}),async(r)=>{let o={target:r.target,message:r.message,at:r.at};if(r.code)o.code=r.code;if(r["channel-id"])o.channelId=r["channel-id"];if(r["user-id"])o.userId=r["user-id"];let a=t(r);if(a)o.cookie=a;await od(e(r),o)}).command(["ls","list"],"List pending scheduled messages",(r)=>r.positional("target",{type:"string",describe:"#channel to filter by"}).option("channel-id",{type:"string",describe:"Raw channel ID"}),async(r)=>{await ad(e(r),r.target,r["channel-id"],t(r))}).command("rm <target> <id>","Delete a scheduled message",(r)=>r.positional("target",{type:"string",demandOption:!0,describe:"#channel or @user"}).positional("id",{type:"string",demandOption:!0,describe:"Scheduled message ID"}).option("code",{type:"string",describe:"Safety hash to confirm"}).option("channel-id",{type:"string",describe:"Raw channel ID"}),async(r)=>{let o={target:r.target,id:r.id};if(r.code)o.code=r.code;let a=t(r);if(a)o.cookie=a;if(r["channel-id"])o.channelId=r["channel-id"];await cd(e(r),o)}).demandCommand(1,"").showHelpOnFail(!0),()=>{}).command("edit <target> <newText>","Edit a sent message",(s)=>s.positional("target",{type:"string",demandOption:!0,describe:"#chan:ts, @user:ts, or permalink"}).positional("newText",{type:"string",demandOption:!0}).option("code",{type:"string",describe:"Safety hash to confirm edit"}).option("channel-id",{type:"string",describe:"Raw channel ID"}).option("mentions",{type:"boolean",default:!0,describe:"Convert @handle tokens in the new text to real <@USERID> mentions (on by default). Unresolved handles stay as plain text. Disable with --no-mentions for literal @text."}),async(s)=>{let r={target:s.target,newText:s.newText};if(s.code)r.code=s.code;if(s["channel-id"])r.channelId=s["channel-id"];if(s.mentions!==!1)r.mentions=!0;let o=t(s);if(o)r.cookie=o;await Lf(e(s),r)}).command("delete <target>","Delete a sent message (confirm-hash safety gate)",(s)=>s.positional("target",{type:"string",demandOption:!0,describe:"#chan:ts, @user:ts, or permalink"}).option("code",{type:"string",describe:"Safety hash to confirm delete"}).option("channel-id",{type:"string",describe:"Raw channel ID"}),async(s)=>{let r={target:s.target};if(s.code)r.code=s.code;if(s["channel-id"])r.channelId=s["channel-id"];let o=t(s);if(o)r.cookie=o;await Wf(e(s),r)}).command("react <target> <emoji>","Add (or --remove) an emoji reaction \u2014 a lightweight ack that doesn't grow the thread",(s)=>s.positional("target",{type:"string",demandOption:!0,describe:"#chan:ts, @user:ts, or permalink"}).positional("emoji",{type:"string",demandOption:!0,describe:"Emoji shortcode without colons (e.g. eyes, white_check_mark, hourglass)"}).option("remove",{type:"boolean",default:!1,describe:"Remove the reaction instead of adding it"}).option("channel-id",{type:"string",describe:"Raw channel ID"}),async(s)=>{let r={target:s.target,emoji:s.emoji};if(s.remove)r.remove=!0;if(s["channel-id"])r.channelId=s["channel-id"];let o=t(s);if(o)r.cookie=o;try{await Uf(e(s),r)}catch(a){console.error(tt(a)),process.exit(1)}}).command("todo","Reaction-backed task tracking (:pushpin: marks a task, progress lives in a second reaction)",(s)=>s.option("cache",{type:"boolean",default:!0,describe:"Use ~/.config/slack-cli/cache.json for channel/user lookups (--no-cache to bypass)"}).middleware((r)=>{if(r.cache===!1)Ni(!1)}).command(["ls","list"],"List everyone's tasks (has: \u2014 read-only, one search per run)",(r)=>r.options(n).option("mine",{type:"boolean",default:!1,describe:"Only your own reactions (hasmy:) \u2014 same as `slack mytodo ls`"}).option("shared",{type:"boolean",default:!1,hidden:!0,describe:"Deprecated \u2014 anyone's reactions is the default for `todo ls`"}),async(r)=>{await i(r,!1)}).command("set <target> <state>","Move a task to a progress state (adds the new reaction before removing the old one)",(r)=>r.positional("target",{type:"string",demandOption:!0,describe:"#chan:ts or permalink"}).positional("state",{type:"string",demandOption:!0,choices:["pending","doing","done","dropped"]}).option("channel-id",{type:"string",describe:"Raw channel ID"}),async(r)=>{let o={target:r.target,state:r.state};if(r["channel-id"])o.channelId=r["channel-id"];let a=t(r);if(a)o.cookie=a;try{await Of(e(r),o)}catch(c){console.error(tt(c)),process.exit(1)}}).command("flag <target> <flag>","Add (or --remove) a reason flag (alert | needs-discussion | waiting | blocked) \u2014 flags stack, independent of progress",(r)=>r.positional("target",{type:"string",demandOption:!0,describe:"#chan:ts or permalink"}).positional("flag",{type:"string",demandOption:!0,choices:["alert","needs-discussion","waiting","blocked"],describe:"waiting = the other party in this conversation owes a reply; blocked = stuck on something outside it"}).option("remove",{type:"boolean",default:!1,describe:"Remove the flag instead of adding it"}).option("channel-id",{type:"string",describe:"Raw channel ID"}),async(r)=>{let o={target:r.target,flag:r.flag};if(r.remove)o.remove=!0;if(r["channel-id"])o.channelId=r["channel-id"];let a=t(r);if(a)o.cookie=a;try{await If(e(r),o)}catch(c){console.error(tt(c)),process.exit(1)}}).command("doctor","Find messages carrying two or more progress reactions (--fix repairs them)",(r)=>r.option("in",{type:"string",demandOption:!0,describe:"Channel to scan (#chan)"}).option("fix",{type:"boolean",default:!1,describe:"Repair findings (keeps the highest-priority state)"}).option("limit",{type:"number",default:Bi,describe:"Max messages to scan"}).option("channel-id",{type:"string",describe:"Raw channel ID"}),async(r)=>{let o={channel:r.in,limit:r.limit};if(r.fix)o.fix=!0;if(r["channel-id"])o.channelId=r["channel-id"];let a=t(r);if(a)o.cookie=a;await Pf(e(r),o)}).demandCommand(1,"Specify a todo subcommand (ls, set, flag, doctor)"),()=>{}).command("mytodo","Tasks carrying YOUR reactions (hasmy:) \u2014 the my-only half of `todo`",(s)=>s.option("cache",{type:"boolean",default:!0,describe:"Use ~/.config/slack-cli/cache.json for channel/user lookups (--no-cache to bypass)"}).middleware((r)=>{if(r.cache===!1)Ni(!1)}).command(["ls","list"],"List tasks you have reacted to (hasmy: \u2014 read-only, one search per run)",(r)=>r.options(n),async(r)=>{await i(r,!0)}).demandCommand(1,"Specify a mytodo subcommand (ls)"),()=>{}).command("upload <target> <file..>","Upload one or more files to a channel or DM",(s)=>s.positional("target",{type:"string",demandOption:!0,describe:"#chan, @user, #chan:thread_ts, or permalink (a message permalink replies in its thread)"}).positional("file",{type:"string",array:!0,demandOption:!0,describe:"Path(s) to file(s)"}).option("title",{type:"string",describe:"Title (single file only)"}).option("comment",{type:"string",describe:"Initial comment (first file)"}).option("code",{type:"string",describe:"4-hex safety code to confirm upload"}).option("channel-id",{type:"string"}).option("user-id",{type:"string"}),async(s)=>{let r={target:s.target,filePaths:s.file};if(s.title)r.title=s.title;if(s.comment)r.comment=s.comment;if(s.code)r.code=s.code;if(s["channel-id"])r.channelId=s["channel-id"];if(s["user-id"])r.userId=s["user-id"];let o=t(s);if(o)r.cookie=o;await ud(e(s),r)}).command("files","File commands",(s)=>s.command(["ls","list"],"List files visible to you (files.list)",(r)=>r.option("limit",{alias:"l",type:"number",default:100,describe:"Max files to list"}).option("type",{alias:"t",type:"string",describe:"Slack type filter: images, pdfs, gdocs, snippets, zips, spaces, all"}).option("channel",{alias:"c",type:"string",describe:"Only files in this channel (#name, @user, ID, or permalink)"}).option("user",{alias:"u",type:"string",describe:"Only files from this raw user ID"}).option("format",{type:"string",choices:["text","jsonl"],default:"text"}).option("json",{type:"boolean",default:!1,describe:"Alias for --format=jsonl"}),async(r)=>{let o={limit:r.limit,format:r.json?"jsonl":r.format};if(r.type)o.types=r.type;if(r.channel)o.channel=r.channel;if(r.user)o.user=r.user;await ld(e(r),t(r),o)}).demandCommand(1,"").showHelpOnFail(!0),()=>{}).command("lists <ref>","Read a Slack List's rows (by list URL or F-id) \u2014 read-only",(s)=>s.positional("ref",{type:"string",demandOption:!0,describe:"List URL (\u2026/lists/<TEAM>/<F-id>) or bare F-id"}).option("limit",{alias:"l",type:"number",default:100,describe:"Max rows to show"}).option("format",{type:"string",choices:["text","jsonl"],default:"text"}).option("json",{type:"boolean",default:!1,describe:"Alias for --format=jsonl (raw records)"}),async(s)=>{let r=s.json?"jsonl":s.format;try{await pd(e(s),t(s),s.ref,{limit:s.limit,format:r})}catch(o){console.error(tt(o)),process.exit(1)}}).command("download <ref> [dest]","Download a file attachment (by file ID or file permalink) to disk",(s)=>s.positional("ref",{type:"string",demandOption:!0,describe:"File ID (F\u2026) or Slack file permalink"}).positional("dest",{type:"string",describe:"Output path or directory (default: ./<filename>)"}),async(s)=>{await gd(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 Tf(e(s),s.days,s.limit,s.filter)}).command("drafts","Manage message drafts (requires xoxc desktop token)",(s)=>s.command(["$0","ls","list"],"List pending drafts",(r)=>r.option("all",{alias:"a",type:"boolean",default:!1,describe:"Include sent drafts"}),async(r)=>{await Mf(e(r),t(r),r.all)}).command(["new <channel> [text..]","save <channel> [text..]"],"Create a draft",(r)=>r.positional("channel",{type:"string",demandOption:!0}).positional("text",{type:"string",array:!0,default:[]}),async(r)=>{let o=e(r),a=t(r),c=r.text.join(" ");if(!c)console.error("Usage: slack drafts new <#channel|@user> <text>"),process.exit(2);let u=await De(o,r.channel,a),f=await Qa(o,u,c,a);console.log(`\u2713 Draft created (id: ${P(f.draft).id??"?"})`)}).command("get <id>","Show a draft",(r)=>r.positional("id",{type:"string",demandOption:!0}),async(r)=>{await Bf(e(r),t(r),r.id)}).command(["edit <id> [text..]","update <id> [text..]"],"Edit a draft",(r)=>r.positional("id",{type:"string",demandOption:!0}).positional("text",{type:"string",array:!0,default:[]}).option("code",{type:"string"}),async(r)=>{let o=e(r),a=t(r),c=r.text.join(" ");if(!c)console.error("Usage: slack drafts edit <id> <new-text>"),process.exit(2);let u=await gn(o,a),f=X(u.drafts).map(P).find((p)=>String(p.id)===r.id);if(!f)console.error(`Draft not found: ${r.id}`),process.exit(1);let l=fs(f),d=await Vt(o,a),h=He(l,c,d?.userId??"");if(r.code!==h)ve(r.code,h,["--- Editing draft as -------------------------",je(d),"--- Current draft ----------------------------",...l.split(`
|
|
206
|
+
Tip: pass --user-id <Uxxxx> to skip the lookup.`),process.exit(Ne)}l=d,u.asBot=!0}else{l=e(s);let d=t(s);if(d)u.cookie=d}try{await td(l,u)}catch(d){console.error(tt(d)),process.exit(Ne)}}).command("doctor","Check the bot token (xoxb) can carry a two-way DM (scopes + Messages Tab)",(s)=>s,async()=>{let s=Kt();if(!s)console.error(`Error: slack doctor checks the bot token, but no xoxb- token was found.
|
|
207
|
+
Set SLACK_BOT_TOKEN=xoxb-... in ~/.config/slack-cli/.env (or your shell).`),process.exit(1);await id(s)}).command("schedule","Manage scheduled messages",(s)=>s.command("send <target> <message>","Schedule a message for later delivery",(r)=>r.positional("target",{type:"string",demandOption:!0,describe:"#chan, @user, #chan:thread_ts, or permalink (a message permalink replies in its thread)"}).positional("message",{type:"string",demandOption:!0}).option("at",{type:"string",demandOption:!0,describe:"Delivery time (ISO datetime or Unix ts)"}).option("code",{type:"string",describe:"Safety hash to confirm"}).option("channel-id",{type:"string",describe:"Raw channel ID"}).option("user-id",{type:"string",describe:"Raw user ID (opens DM)"}),async(r)=>{let o={target:r.target,message:r.message,at:r.at};if(r.code)o.code=r.code;if(r["channel-id"])o.channelId=r["channel-id"];if(r["user-id"])o.userId=r["user-id"];let a=t(r);if(a)o.cookie=a;await ad(e(r),o)}).command(["ls","list"],"List pending scheduled messages",(r)=>r.positional("target",{type:"string",describe:"#channel to filter by"}).option("channel-id",{type:"string",describe:"Raw channel ID"}),async(r)=>{await cd(e(r),r.target,r["channel-id"],t(r))}).command("rm <target> <id>","Delete a scheduled message",(r)=>r.positional("target",{type:"string",demandOption:!0,describe:"#channel or @user"}).positional("id",{type:"string",demandOption:!0,describe:"Scheduled message ID"}).option("code",{type:"string",describe:"Safety hash to confirm"}).option("channel-id",{type:"string",describe:"Raw channel ID"}),async(r)=>{let o={target:r.target,id:r.id};if(r.code)o.code=r.code;let a=t(r);if(a)o.cookie=a;if(r["channel-id"])o.channelId=r["channel-id"];await ud(e(r),o)}).demandCommand(1,"").showHelpOnFail(!0),()=>{}).command("edit <target> <newText>","Edit a sent message",(s)=>s.positional("target",{type:"string",demandOption:!0,describe:"#chan:ts, @user:ts, or permalink"}).positional("newText",{type:"string",demandOption:!0}).option("code",{type:"string",describe:"Safety hash to confirm edit"}).option("channel-id",{type:"string",describe:"Raw channel ID"}).option("mentions",{type:"boolean",default:!0,describe:"Convert @handle tokens in the new text to real <@USERID> mentions (on by default). Unresolved handles stay as plain text. Disable with --no-mentions for literal @text."}),async(s)=>{let r={target:s.target,newText:s.newText};if(s.code)r.code=s.code;if(s["channel-id"])r.channelId=s["channel-id"];if(s.mentions!==!1)r.mentions=!0;let o=t(s);if(o)r.cookie=o;await Wf(e(s),r)}).command("delete <target>","Delete a sent message (confirm-hash safety gate)",(s)=>s.positional("target",{type:"string",demandOption:!0,describe:"#chan:ts, @user:ts, or permalink"}).option("code",{type:"string",describe:"Safety hash to confirm delete"}).option("channel-id",{type:"string",describe:"Raw channel ID"}),async(s)=>{let r={target:s.target};if(s.code)r.code=s.code;if(s["channel-id"])r.channelId=s["channel-id"];let o=t(s);if(o)r.cookie=o;await Uf(e(s),r)}).command("react <target> <emoji>","Add (or --remove) an emoji reaction \u2014 a lightweight ack that doesn't grow the thread",(s)=>s.positional("target",{type:"string",demandOption:!0,describe:"#chan:ts, @user:ts, or permalink"}).positional("emoji",{type:"string",demandOption:!0,describe:"Emoji shortcode without colons (e.g. eyes, white_check_mark, hourglass)"}).option("remove",{type:"boolean",default:!1,describe:"Remove the reaction instead of adding it"}).option("channel-id",{type:"string",describe:"Raw channel ID"}),async(s)=>{let r={target:s.target,emoji:s.emoji};if(s.remove)r.remove=!0;if(s["channel-id"])r.channelId=s["channel-id"];let o=t(s);if(o)r.cookie=o;try{await Jf(e(s),r)}catch(a){console.error(tt(a)),process.exit(1)}}).command("todo","Reaction-backed task tracking (:pushpin: marks a task, progress lives in a second reaction)",(s)=>s.option("cache",{type:"boolean",default:!0,describe:"Use ~/.config/slack-cli/cache.json for channel/user lookups (--no-cache to bypass)"}).middleware((r)=>{if(r.cache===!1)Ni(!1)}).command(["ls","list"],"List everyone's tasks (has: \u2014 read-only, one search per run)",(r)=>r.options(n).option("mine",{type:"boolean",default:!1,describe:"Only your own reactions (hasmy:) \u2014 same as `slack mytodo ls`"}).option("shared",{type:"boolean",default:!1,hidden:!0,describe:"Deprecated \u2014 anyone's reactions is the default for `todo ls`"}),async(r)=>{await i(r,!1)}).command("set <target> <state>","Move a task to a progress state (adds the new reaction before removing the old one)",(r)=>r.positional("target",{type:"string",demandOption:!0,describe:"#chan:ts or permalink"}).positional("state",{type:"string",demandOption:!0,choices:["pending","doing","done","dropped"]}).option("channel-id",{type:"string",describe:"Raw channel ID"}),async(r)=>{let o={target:r.target,state:r.state};if(r["channel-id"])o.channelId=r["channel-id"];let a=t(r);if(a)o.cookie=a;try{await If(e(r),o)}catch(c){console.error(tt(c)),process.exit(1)}}).command("flag <target> <flag>","Add (or --remove) a reason flag (alert | needs-discussion | waiting | blocked) \u2014 flags stack, independent of progress",(r)=>r.positional("target",{type:"string",demandOption:!0,describe:"#chan:ts or permalink"}).positional("flag",{type:"string",demandOption:!0,choices:["alert","needs-discussion","waiting","blocked"],describe:"waiting = the other party in this conversation owes a reply; blocked = stuck on something outside it"}).option("remove",{type:"boolean",default:!1,describe:"Remove the flag instead of adding it"}).option("channel-id",{type:"string",describe:"Raw channel ID"}),async(r)=>{let o={target:r.target,flag:r.flag};if(r.remove)o.remove=!0;if(r["channel-id"])o.channelId=r["channel-id"];let a=t(r);if(a)o.cookie=a;try{await Tf(e(r),o)}catch(c){console.error(tt(c)),process.exit(1)}}).command("doctor","Find messages carrying two or more progress reactions (--fix repairs them)",(r)=>r.option("in",{type:"string",demandOption:!0,describe:"Channel to scan (#chan)"}).option("fix",{type:"boolean",default:!1,describe:"Repair findings (keeps the highest-priority state)"}).option("limit",{type:"number",default:Bi,describe:"Max messages to scan"}).option("channel-id",{type:"string",describe:"Raw channel ID"}),async(r)=>{let o={channel:r.in,limit:r.limit};if(r.fix)o.fix=!0;if(r["channel-id"])o.channelId=r["channel-id"];let a=t(r);if(a)o.cookie=a;await Pf(e(r),o)}).demandCommand(1,"Specify a todo subcommand (ls, set, flag, doctor)"),()=>{}).command("mytodo","Tasks carrying YOUR reactions (hasmy:) \u2014 the my-only half of `todo`",(s)=>s.option("cache",{type:"boolean",default:!0,describe:"Use ~/.config/slack-cli/cache.json for channel/user lookups (--no-cache to bypass)"}).middleware((r)=>{if(r.cache===!1)Ni(!1)}).command(["ls","list"],"List tasks you have reacted to (hasmy: \u2014 read-only, one search per run)",(r)=>r.options(n),async(r)=>{await i(r,!0)}).demandCommand(1,"Specify a mytodo subcommand (ls)"),()=>{}).command("upload <target> <file..>","Upload one or more files to a channel or DM",(s)=>s.positional("target",{type:"string",demandOption:!0,describe:"#chan, @user, #chan:thread_ts, or permalink (a message permalink replies in its thread)"}).positional("file",{type:"string",array:!0,demandOption:!0,describe:"Path(s) to file(s)"}).option("title",{type:"string",describe:"Title (single file only)"}).option("comment",{type:"string",describe:"Initial comment (first file)"}).option("code",{type:"string",describe:"4-hex safety code to confirm upload"}).option("channel-id",{type:"string"}).option("user-id",{type:"string"}),async(s)=>{let r={target:s.target,filePaths:s.file};if(s.title)r.title=s.title;if(s.comment)r.comment=s.comment;if(s.code)r.code=s.code;if(s["channel-id"])r.channelId=s["channel-id"];if(s["user-id"])r.userId=s["user-id"];let o=t(s);if(o)r.cookie=o;await ld(e(s),r)}).command("files","File commands",(s)=>s.command(["ls","list"],"List files visible to you (files.list)",(r)=>r.option("limit",{alias:"l",type:"number",default:100,describe:"Max files to list"}).option("type",{alias:"t",type:"string",describe:"Slack type filter: images, pdfs, gdocs, snippets, zips, spaces, all"}).option("channel",{alias:"c",type:"string",describe:"Only files in this channel (#name, @user, ID, or permalink)"}).option("user",{alias:"u",type:"string",describe:"Only files from this raw user ID"}).option("format",{type:"string",choices:["text","jsonl"],default:"text"}).option("json",{type:"boolean",default:!1,describe:"Alias for --format=jsonl"}),async(r)=>{let o={limit:r.limit,format:r.json?"jsonl":r.format};if(r.type)o.types=r.type;if(r.channel)o.channel=r.channel;if(r.user)o.user=r.user;await fd(e(r),t(r),o)}).demandCommand(1,"").showHelpOnFail(!0),()=>{}).command("lists <ref>","Read a Slack List's rows (by list URL or F-id) \u2014 read-only",(s)=>s.positional("ref",{type:"string",demandOption:!0,describe:"List URL (\u2026/lists/<TEAM>/<F-id>) or bare F-id"}).option("limit",{alias:"l",type:"number",default:100,describe:"Max rows to show"}).option("format",{type:"string",choices:["text","jsonl"],default:"text"}).option("json",{type:"boolean",default:!1,describe:"Alias for --format=jsonl (raw records)"}),async(s)=>{let r=s.json?"jsonl":s.format;try{await hd(e(s),t(s),s.ref,{limit:s.limit,format:r})}catch(o){console.error(tt(o)),process.exit(1)}}).command("download <ref> [dest]","Download a file attachment (by file ID or file permalink) to disk",(s)=>s.positional("ref",{type:"string",demandOption:!0,describe:"File ID (F\u2026) or Slack file permalink"}).positional("dest",{type:"string",describe:"Output path or directory (default: ./<filename>)"}),async(s)=>{await md(e(s),t(s),s.ref,s.dest)}).command("dump","Bulk export channel history as markdown",(s)=>s.option("days",{alias:"d",type:"number",default:7,describe:"Days of history"}).option("limit",{alias:"l",type:"number",default:200}).option("filter",{alias:"f",type:"string",describe:"Filter channel names"}),async(s)=>{await Rf(e(s),s.days,s.limit,s.filter)}).command("drafts","Manage message drafts (requires xoxc desktop token)",(s)=>s.command(["$0","ls","list"],"List pending drafts",(r)=>r.option("all",{alias:"a",type:"boolean",default:!1,describe:"Include sent drafts"}),async(r)=>{await Bf(e(r),t(r),r.all)}).command(["new <channel> [text..]","save <channel> [text..]"],"Create a draft",(r)=>r.positional("channel",{type:"string",demandOption:!0}).positional("text",{type:"string",array:!0,default:[]}),async(r)=>{let o=e(r),a=t(r),c=r.text.join(" ");if(!c)console.error("Usage: slack drafts new <#channel|@user> <text>"),process.exit(2);let u=await De(o,r.channel,a),f=await Qa(o,u,c,a);console.log(`\u2713 Draft created (id: ${T(f.draft).id??"?"})`)}).command("get <id>","Show a draft",(r)=>r.positional("id",{type:"string",demandOption:!0}),async(r)=>{await Nf(e(r),t(r),r.id)}).command(["edit <id> [text..]","update <id> [text..]"],"Edit a draft",(r)=>r.positional("id",{type:"string",demandOption:!0}).positional("text",{type:"string",array:!0,default:[]}).option("code",{type:"string"}),async(r)=>{let o=e(r),a=t(r),c=r.text.join(" ");if(!c)console.error("Usage: slack drafts edit <id> <new-text>"),process.exit(2);let u=await gn(o,a),f=X(u.drafts).map(T).find((p)=>String(p.id)===r.id);if(!f)console.error(`Draft not found: ${r.id}`),process.exit(1);let l=fs(f),d=await Vt(o,a),h=He(l,c,d?.userId??"");if(r.code!==h)ve(r.code,h,["--- Editing draft as -------------------------",je(d),"--- Current draft ----------------------------",...l.split(`
|
|
207
208
|
`).map((p)=>` ${p}`),"--- Replacing with ---------------------------",...c.split(`
|
|
208
|
-
`).map((p)=>` ${p}`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);let m=await ec(o,r.id,zi(f),c,a);console.log(`\u2713 Draft updated (id: ${
|
|
209
|
-
`).map((h)=>` ${h}`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);await nc(o,r.id,a),console.log(`\u2713 Draft deleted (id: ${r.id})`)})).command("auth","Authentication and workspace management",(s)=>s.command("token","Add a workspace \u2014 paste an existing xoxp-/xoxb- token",(r)=>r.option("token",{type:"string",describe:"Token to save directly (non-interactive)"}).option("name",{type:"string",describe:"Workspace name (used with --token)"}),async(r)=>{await ha({...r.token!==void 0?{token:r.token}:{},...r.name!==void 0?{name:r.name}:{}})}).command("app","Create a new Slack app and obtain a token (guided wizard)",(r)=>r.option("bot",{type:"boolean",describe:"Create a bot token (xoxb-) instead of user (xoxp-)"}),async(r)=>{await ga({...r.bot!==void 0?{bot:r.bot}:{}})}).command("login","Interactive auth wizard (all auth methods: desktop app, token, new app)",(r)=>r.option("token",{type:"string",describe:"Token to save directly (non-interactive)"}).option("name",{type:"string",describe:"Workspace name (used with --token)"}),async(r)=>{await Vn({...r.token!==void 0?{token:r.token}:{},...r.name!==void 0?{name:r.name}:{}})}).command(["ls","status"],"Show auth status",()=>{},()=>{let r=Qs();if(r.length===0){console.log("No workspaces configured. Run: slack auth login");return}for(let{name:o,profile:a,current:c}of r)console.log(`${c?"* ":" "}${o} ${a.team} (${a.user}) ${a.url??""}`)}).command("use <name>","Switch active workspace",(r)=>r.positional("name",{type:"string",demandOption:!0}).option("g",{type:"boolean",default:!1,describe:"Write global lockfile (~/.slack-cli/workspace)"}),(r)=>{if(!r.g)
|
|
209
|
+
`).map((p)=>` ${p}`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);let m=await ec(o,r.id,zi(f),c,a);console.log(`\u2713 Draft updated (id: ${T(m.draft).id??"?"})`)}).command(["delete <id>","rm <id>"],"Delete a draft",(r)=>r.positional("id",{type:"string",demandOption:!0}).option("code",{type:"string"}),async(r)=>{let o=e(r),a=t(r),c=await gn(o,a),u=X(c.drafts).map(T).find((h)=>String(h.id)===r.id);if(!u)console.error(`Draft not found: ${r.id}`),process.exit(1);let f=fs(u),l=await Vt(o,a),d=He(r.id,f,l?.userId??"");if(r.code!==d)ve(r.code,d,["\u2500-- Deleting draft \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500",je(l),` id: ${r.id}`,...f.split(`
|
|
210
|
+
`).map((h)=>` ${h}`),"--------------------------------\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"]);await nc(o,r.id,a),console.log(`\u2713 Draft deleted (id: ${r.id})`)})).command("auth","Authentication and workspace management",(s)=>s.command("token","Add a workspace \u2014 paste an existing xoxp-/xoxb- token",(r)=>r.option("token",{type:"string",describe:"Token to save directly (non-interactive)"}).option("name",{type:"string",describe:"Workspace name (used with --token)"}),async(r)=>{await ha({...r.token!==void 0?{token:r.token}:{},...r.name!==void 0?{name:r.name}:{}})}).command("app","Create a new Slack app and obtain a token (guided wizard)",(r)=>r.option("bot",{type:"boolean",describe:"Create a bot token (xoxb-) instead of user (xoxp-)"}),async(r)=>{await ga({...r.bot!==void 0?{bot:r.bot}:{}})}).command("login","Interactive auth wizard (all auth methods: desktop app, token, new app)",(r)=>r.option("token",{type:"string",describe:"Token to save directly (non-interactive)"}).option("name",{type:"string",describe:"Workspace name (used with --token)"}),async(r)=>{await Vn({...r.token!==void 0?{token:r.token}:{},...r.name!==void 0?{name:r.name}:{}})}).command(["ls","status"],"Show auth status",()=>{},()=>{let r=Qs();if(r.length===0){console.log("No workspaces configured. Run: slack auth login");return}for(let{name:o,profile:a,current:c}of r)console.log(`${c?"* ":" "}${o} ${a.team} (${a.user}) ${a.url??""}`)}).command("use <name>","Switch active workspace",(r)=>r.positional("name",{type:"string",demandOption:!0}).option("g",{type:"boolean",default:!1,describe:"Write global lockfile (~/.slack-cli/workspace)"}),(r)=>{if(!r.g)yf(ft(process.cwd(),".slack-cli"));Bo(r.name,r.g),console.log(`Switched to workspace "${r.name}" ${r.g?"globally":"locally"}`)}).command(["logout <name>","rm <name>","remove <name>"],"Remove a workspace",(r)=>r.positional("name",{type:"string",demandOption:!0}),(r)=>{Mo(r.name),console.log(`Removed workspace "${r.name}"`)}).command(["chrome","cookie"],"Attach Chrome browser xoxd cookie to a workspace (macOS, interactive)",(r)=>r.option("workspace",{type:"string",alias:"w",describe:"Workspace name to update (default: active)"}),async(r)=>{await da({...r.workspace!==void 0?{workspace:r.workspace}:{}})}).command("firefox","Attach Firefox browser xoxd cookie to a workspace (all platforms)",(r)=>r.option("workspace",{type:"string",alias:"w",describe:"Workspace name to update (default: active)"}),async(r)=>{await pa({...r.workspace!==void 0?{workspace:r.workspace}:{}})}).command("$0",!1,()=>{},()=>{s.showHelp(),process.exit(0)})).command("tail [target]","Stream new messages in real time (like tail -f)",(s)=>s.positional("target",{type:"string",describe:"#channel or @user to follow"}).option("since",{type:"string",describe:"Backfill from N ago (e.g. 10m, 2h, 1d)"}).option("thread",{type:"string",describe:"Follow a single thread by timestamp"}).option("watch-thread",{type:"string",describe:"Watch the channel's top-level timeline AND one thread's replies together (ts or permalink)"}).option("me",{type:"boolean",default:!1,describe:"Filter to messages that mention you"}).option("interval",{type:"number",default:60000,describe:"Poll interval in ms (default 60s; use --interval=3000 for near-real-time)"}).option("timeout",{type:"string",describe:"Auto-stop after this long (e.g. 30m, 2h). Exit code 0 even if nothing arrived."}).option("exit-on-message",{type:"boolean",default:!1,describe:"Stop as soon as the first new message from someone else arrives (wait-for-reply)"}).option("rtm",{type:"boolean",default:!0,describe:"Use RTM WebSocket when available (xoxc + cookie); pass --no-rtm to force polling"}),async(s)=>{let r=e(s),o=t(s),a=new AbortController;process.on("SIGINT",()=>{a.abort(),process.exit(0)}),await Ca(r,s.target,{...s.since!==void 0?{since:s.since}:{},...s.thread!==void 0?{thread:s.thread}:{},...s["watch-thread"]!==void 0?{watchThread:s["watch-thread"]}:{},me:s.me,interval:s.interval,...s.timeout!==void 0?{timeout:s.timeout}:{},...s["exit-on-message"]===!0?{exitOnMessage:!0}:{},...o!==void 0?{cookie:o}:{},...s.rtm===!1?{noRtm:!0}:{}},a.signal)}).command("login",!1,(s)=>s.option("token",{type:"string"}).option("name",{type:"string"}),async(s)=>{await Vn({...s.token!==void 0?{token:s.token}:{},...s.name!==void 0?{name:s.name}:{}})}).demandCommand(1,"Specify a command. Run with --help for usage.").strict().help().alias("help","h").parseAsync()}Dd().catch((e)=>{console.error(e instanceof Error?e.message:String(e)),process.exit(1)});
|