@rajbos/ai-engineering-fluency 0.0.10 → 0.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +60 -54
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1,69 +1,75 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var
|
|
3
|
-
`)}displayWidth(e){return
|
|
4
|
-
`+" ".repeat(t+
|
|
5
|
-
${
|
|
6
|
-
`)}};function
|
|
2
|
+
"use strict";var jl=Object.create;var er=Object.defineProperty;var $l=Object.getOwnPropertyDescriptor;var Ll=Object.getOwnPropertyNames;var ql=Object.getPrototypeOf,Gl=Object.prototype.hasOwnProperty;var oe=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var Bl=(r,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Ll(e))!Gl.call(r,o)&&o!==t&&er(r,o,{get:()=>e[o],enumerable:!(s=$l(e,o))||s.enumerable});return r};var R=(r,e,t)=>(t=r!=null?jl(ql(r)):{},Bl(e||!r||!r.__esModule?er(t,"default",{value:r,enumerable:!0}):t,r));var ms=oe(pn=>{var Qs=class extends Error{constructor(e,t,s){super(s),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},dn=class extends Qs{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};pn.CommanderError=Qs;pn.InvalidArgumentError=dn});var Xs=oe(hn=>{var{InvalidArgumentError:zl}=ms(),mn=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,s)=>{if(!this.argChoices.includes(t))throw new zl(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(t,s):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function Wl(r){let e=r.name()+(r.variadic===!0?"...":"");return r.required?"<"+e+">":"["+e+"]"}hn.Argument=mn;hn.humanReadableArgName=Wl});var yn=oe(gn=>{var{humanReadableArgName:Vl}=Xs(),fn=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(o=>!o._hidden),s=e._getHelpCommand();return s&&!s._hidden&&t.push(s),this.sortSubcommands&&t.sort((o,n)=>o.name().localeCompare(n.name())),t}compareOptions(e,t){let s=o=>o.short?o.short.replace(/^-/,""):o.long.replace(/^--/,"");return s(e).localeCompare(s(t))}visibleOptions(e){let t=e.options.filter(o=>!o.hidden),s=e._getHelpOption();if(s&&!s.hidden){let o=s.short&&e._findOption(s.short),n=s.long&&e._findOption(s.long);!o&&!n?t.push(s):s.long&&!n?t.push(e.createOption(s.long,s.description)):s.short&&!o&&t.push(e.createOption(s.short,s.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let s=e.parent;s;s=s.parent){let o=s.options.filter(n=>!n.hidden);t.push(...o)}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(s=>Vl(s)).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((s,o)=>Math.max(s,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(o)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((s,o)=>Math.max(s,this.displayWidth(t.styleOptionTerm(t.optionTerm(o)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((s,o)=>Math.max(s,this.displayWidth(t.styleOptionTerm(t.optionTerm(o)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((s,o)=>Math.max(s,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(o)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let s="";for(let o=e.parent;o;o=o.parent)s=o.name()+" "+s;return s+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(s=>JSON.stringify(s)).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 s=`(${t.join(", ")})`;return e.description?`${e.description} ${s}`:s}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(s=>JSON.stringify(s)).join(", ")}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let s=`(${t.join(", ")})`;return e.description?`${e.description} ${s}`:s}return e.description}formatItemList(e,t,s){return t.length===0?[]:[s.styleTitle(e),...t,""]}groupItems(e,t,s){let o=new Map;return e.forEach(n=>{let a=s(n);o.has(a)||o.set(a,[])}),t.forEach(n=>{let a=s(n);o.has(a)||o.set(a,[]),o.get(a).push(n)}),o}formatHelp(e,t){let s=t.padWidth(e,t),o=t.helpWidth??80;function n(p,g){return t.formatItem(p,s,g,t)}let a=[`${t.styleTitle("Usage:")} ${t.styleUsage(t.commandUsage(e))}`,""],d=t.commandDescription(e);d.length>0&&(a=a.concat([t.boxWrap(t.styleCommandDescription(d),o),""]));let c=t.visibleArguments(e).map(p=>n(t.styleArgumentTerm(t.argumentTerm(p)),t.styleArgumentDescription(t.argumentDescription(p))));if(a=a.concat(this.formatItemList("Arguments:",c,t)),this.groupItems(e.options,t.visibleOptions(e),p=>p.helpGroupHeading??"Options:").forEach((p,g)=>{let w=p.map(k=>n(t.styleOptionTerm(t.optionTerm(k)),t.styleOptionDescription(t.optionDescription(k))));a=a.concat(this.formatItemList(g,w,t))}),t.showGlobalOptions){let p=t.visibleGlobalOptions(e).map(g=>n(t.styleOptionTerm(t.optionTerm(g)),t.styleOptionDescription(t.optionDescription(g))));a=a.concat(this.formatItemList("Global Options:",p,t))}return this.groupItems(e.commands,t.visibleCommands(e),p=>p.helpGroup()||"Commands:").forEach((p,g)=>{let w=p.map(k=>n(t.styleSubcommandTerm(t.subcommandTerm(k)),t.styleSubcommandDescription(t.subcommandDescription(k))));a=a.concat(this.formatItemList(g,w,t))}),a.join(`
|
|
3
|
+
`)}displayWidth(e){return tr(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,s,o){let a=" ".repeat(2);if(!s)return a+e;let d=e.padEnd(t+e.length-o.displayWidth(e)),c=2,m=(this.helpWidth??80)-t-c-2,p;return m<this.minWidthToWrap||o.preformatted(s)?p=s:p=o.boxWrap(s,m).replace(/\n/g,`
|
|
4
|
+
`+" ".repeat(t+c)),a+d+" ".repeat(c)+p.replace(/\n/g,`
|
|
5
|
+
${a}`)}boxWrap(e,t){if(t<this.minWidthToWrap)return e;let s=e.split(/\r\n|\n/),o=/[\s]*[^\s]+/g,n=[];return s.forEach(a=>{let d=a.match(o);if(d===null){n.push("");return}let c=[d.shift()],h=this.displayWidth(c[0]);d.forEach(m=>{let p=this.displayWidth(m);if(h+p<=t){c.push(m),h+=p;return}n.push(c.join(""));let g=m.trimStart();c=[g],h=this.displayWidth(g)}),n.push(c.join(""))}),n.join(`
|
|
6
|
+
`)}};function tr(r){let e=/\x1b\[\d*(;\d*)*m/g;return r.replace(e,"")}gn.Help=fn;gn.stripColor=tr});var wn=oe(Cn=>{var{InvalidArgumentError:Hl}=ms(),_n=class{constructor(e,t){this.flags=e,this.description=t||"",this.required=e.includes("<"),this.optional=e.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let s=Jl(e);this.short=s.shortFlag,this.long=s.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return typeof e=="string"&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,s)=>{if(!this.argChoices.includes(t))throw new Hl(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(t,s):t},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.negate?sr(this.name().replace(/^no-/,"")):sr(this.name())}helpGroup(e){return this.helpGroupHeading=e,this}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},bn=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(t=>{t.negate?this.negativeOptions.set(t.attributeName(),t):this.positiveOptions.set(t.attributeName(),t)}),this.negativeOptions.forEach((t,s)=>{this.positiveOptions.has(s)&&this.dualOptions.add(s)})}valueFromOption(e,t){let s=t.attributeName();if(!this.dualOptions.has(s))return!0;let o=this.negativeOptions.get(s).presetArg,n=o!==void 0?o:!1;return t.negate===(n===e)}};function sr(r){return r.split("-").reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function Jl(r){let e,t,s=/^-[^-]$/,o=/^--[^-]/,n=r.split(/[ |,]+/).concat("guard");if(s.test(n[0])&&(e=n.shift()),o.test(n[0])&&(t=n.shift()),!e&&s.test(n[0])&&(e=n.shift()),!e&&o.test(n[0])&&(e=t,t=n.shift()),n[0].startsWith("-")){let a=n[0],d=`option creation failed due to '${a}' in option flags '${r}'`;throw/^-[^-][^-]/.test(a)?new Error(`${d}
|
|
7
7
|
- a short flag is a single dash and a single character
|
|
8
8
|
- either use a single dash and a single character (for a short flag)
|
|
9
|
-
- or use a double dash for a long option (and can have two, like '--ws, --workspace')`):
|
|
10
|
-
- too many short flags`):
|
|
11
|
-
- too many long flags`):new Error(`${
|
|
12
|
-
- unrecognised flag format`)}if(e===void 0&&t===void 0)throw new Error(`option creation failed due to no flags found in '${
|
|
13
|
-
(Did you mean one of ${
|
|
14
|
-
(Did you mean ${
|
|
15
|
-
- specify the name in Command constructor or using .name()`);return t=t||{},t.isDefault&&(this._defaultCommandName=e._name),(t.noHelp||t.hidden)&&(e._hidden=!0),this._registerCommand(e),e.parent=this,e._checkForBrokenPassThrough(),this}createArgument(e,t){return new
|
|
16
|
-
Expecting one of '${
|
|
17
|
-
- already used by option '${t.flags}'`)}this._initOptionGroup(e),this.options.push(e)}_registerCommand(e){let t=
|
|
18
|
-
- 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,
|
|
19
|
-
- if '${
|
|
9
|
+
- or use a double dash for a long option (and can have two, like '--ws, --workspace')`):s.test(a)?new Error(`${d}
|
|
10
|
+
- too many short flags`):o.test(a)?new Error(`${d}
|
|
11
|
+
- too many long flags`):new Error(`${d}
|
|
12
|
+
- unrecognised flag format`)}if(e===void 0&&t===void 0)throw new Error(`option creation failed due to no flags found in '${r}'.`);return{shortFlag:e,longFlag:t}}Cn.Option=_n;Cn.DualOptions=bn});var nr=oe(or=>{function Kl(r,e){if(Math.abs(r.length-e.length)>3)return Math.max(r.length,e.length);let t=[];for(let s=0;s<=r.length;s++)t[s]=[s];for(let s=0;s<=e.length;s++)t[0][s]=s;for(let s=1;s<=e.length;s++)for(let o=1;o<=r.length;o++){let n=1;r[o-1]===e[s-1]?n=0:n=1,t[o][s]=Math.min(t[o-1][s]+1,t[o][s-1]+1,t[o-1][s-1]+n),o>1&&s>1&&r[o-1]===e[s-2]&&r[o-2]===e[s-1]&&(t[o][s]=Math.min(t[o][s],t[o-2][s-2]+1))}return t[r.length][e.length]}function Yl(r,e){if(!e||e.length===0)return"";e=Array.from(new Set(e));let t=r.startsWith("--");t&&(r=r.slice(2),e=e.map(a=>a.slice(2)));let s=[],o=3,n=.4;return e.forEach(a=>{if(a.length<=1)return;let d=Kl(r,a),c=Math.max(r.length,a.length);(c-d)/c>n&&(d<o?(o=d,s=[a]):d===o&&s.push(a))}),s.sort((a,d)=>a.localeCompare(d)),t&&(s=s.map(a=>`--${a}`)),s.length>1?`
|
|
13
|
+
(Did you mean one of ${s.join(", ")}?)`:s.length===1?`
|
|
14
|
+
(Did you mean ${s[0]}?)`:""}or.suggestSimilar=Yl});var lr=oe(Tn=>{var Ql=require("node:events").EventEmitter,Sn=require("node:child_process"),nt=require("node:path"),Zs=require("node:fs"),J=require("node:process"),{Argument:Xl,humanReadableArgName:Zl}=Xs(),{CommanderError:kn}=ms(),{Help:ec,stripColor:tc}=yn(),{Option:ir,DualOptions:sc}=wn(),{suggestSimilar:rr}=nr(),vn=class r extends Ql{constructor(e){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=e||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:t=>J.stdout.write(t),writeErr:t=>J.stderr.write(t),outputError:(t,s)=>s(t),getOutHelpWidth:()=>J.stdout.isTTY?J.stdout.columns:void 0,getErrHelpWidth:()=>J.stderr.isTTY?J.stderr.columns:void 0,getOutHasColors:()=>xn()??(J.stdout.isTTY&&J.stdout.hasColors?.()),getErrHasColors:()=>xn()??(J.stderr.isTTY&&J.stderr.hasColors?.()),stripColor:t=>tc(t)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={},this._helpGroupHeading=void 0,this._defaultCommandGroup=void 0,this._defaultOptionGroup=void 0}copyInheritedSettings(e){return this._outputConfiguration=e._outputConfiguration,this._helpOption=e._helpOption,this._helpCommand=e._helpCommand,this._helpConfiguration=e._helpConfiguration,this._exitCallback=e._exitCallback,this._storeOptionsAsProperties=e._storeOptionsAsProperties,this._combineFlagAndOptionalValue=e._combineFlagAndOptionalValue,this._allowExcessArguments=e._allowExcessArguments,this._enablePositionalOptions=e._enablePositionalOptions,this._showHelpAfterError=e._showHelpAfterError,this._showSuggestionAfterError=e._showSuggestionAfterError,this}_getCommandAndAncestors(){let e=[];for(let t=this;t;t=t.parent)e.push(t);return e}command(e,t,s){let o=t,n=s;typeof o=="object"&&o!==null&&(n=o,o=null),n=n||{};let[,a,d]=e.match(/([^ ]+) *(.*)/),c=this.createCommand(a);return o&&(c.description(o),c._executableHandler=!0),n.isDefault&&(this._defaultCommandName=c._name),c._hidden=!!(n.noHelp||n.hidden),c._executableFile=n.executableFile||null,d&&c.arguments(d),this._registerCommand(c),c.parent=this,c.copyInheritedSettings(this),o?this:c}createCommand(e){return new r(e)}createHelp(){return Object.assign(new ec,this.configureHelp())}configureHelp(e){return e===void 0?this._helpConfiguration:(this._helpConfiguration=e,this)}configureOutput(e){return e===void 0?this._outputConfiguration:(this._outputConfiguration={...this._outputConfiguration,...e},this)}showHelpAfterError(e=!0){return typeof e!="string"&&(e=!!e),this._showHelpAfterError=e,this}showSuggestionAfterError(e=!0){return this._showSuggestionAfterError=!!e,this}addCommand(e,t){if(!e._name)throw new Error(`Command passed to .addCommand() must have a name
|
|
15
|
+
- specify the name in Command constructor or using .name()`);return t=t||{},t.isDefault&&(this._defaultCommandName=e._name),(t.noHelp||t.hidden)&&(e._hidden=!0),this._registerCommand(e),e.parent=this,e._checkForBrokenPassThrough(),this}createArgument(e,t){return new Xl(e,t)}argument(e,t,s,o){let n=this.createArgument(e,t);return typeof s=="function"?n.default(o).argParser(s):n.default(s),this.addArgument(n),this}arguments(e){return e.trim().split(/ +/).forEach(t=>{this.argument(t)}),this}addArgument(e){let t=this.registeredArguments.slice(-1)[0];if(t?.variadic)throw new Error(`only the last argument can be variadic '${t.name()}'`);if(e.required&&e.defaultValue!==void 0&&e.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${e.name()}'`);return this.registeredArguments.push(e),this}helpCommand(e,t){if(typeof e=="boolean")return this._addImplicitHelpCommand=e,e&&this._defaultCommandGroup&&this._initCommandGroup(this._getHelpCommand()),this;let s=e??"help [command]",[,o,n]=s.match(/([^ ]+) *(.*)/),a=t??"display help for command",d=this.createCommand(o);return d.helpOption(!1),n&&d.arguments(n),a&&d.description(a),this._addImplicitHelpCommand=!0,this._helpCommand=d,(e||t)&&this._initCommandGroup(d),this}addHelpCommand(e,t){return typeof e!="object"?(this.helpCommand(e,t),this):(this._addImplicitHelpCommand=!0,this._helpCommand=e,this._initCommandGroup(e),this)}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))?(this._helpCommand===void 0&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(e,t){let s=["preSubcommand","preAction","postAction"];if(!s.includes(e))throw new Error(`Unexpected value for event passed to hook : '${e}'.
|
|
16
|
+
Expecting one of '${s.join("', '")}'`);return this._lifeCycleHooks[e]?this._lifeCycleHooks[e].push(t):this._lifeCycleHooks[e]=[t],this}exitOverride(e){return e?this._exitCallback=e:this._exitCallback=t=>{if(t.code!=="commander.executeSubCommandAsync")throw t},this}_exit(e,t,s){this._exitCallback&&this._exitCallback(new kn(e,t,s)),J.exit(e)}action(e){let t=s=>{let o=this.registeredArguments.length,n=s.slice(0,o);return this._storeOptionsAsProperties?n[o]=this:n[o]=this.opts(),n.push(this),e.apply(this,n)};return this._actionHandler=t,this}createOption(e,t){return new ir(e,t)}_callParseArg(e,t,s,o){try{return e.parseArg(t,s)}catch(n){if(n.code==="commander.invalidArgument"){let a=`${o} ${n.message}`;this.error(a,{exitCode:n.exitCode,code:n.code})}throw n}}_registerOption(e){let t=e.short&&this._findOption(e.short)||e.long&&this._findOption(e.long);if(t){let s=e.long&&this._findOption(e.long)?e.long:e.short;throw new Error(`Cannot add option '${e.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${s}'
|
|
17
|
+
- already used by option '${t.flags}'`)}this._initOptionGroup(e),this.options.push(e)}_registerCommand(e){let t=o=>[o.name()].concat(o.aliases()),s=t(e).find(o=>this._findCommand(o));if(s){let o=t(this._findCommand(s)).join("|"),n=t(e).join("|");throw new Error(`cannot add command '${n}' as already have command '${o}'`)}this._initCommandGroup(e),this.commands.push(e)}addOption(e){this._registerOption(e);let t=e.name(),s=e.attributeName();if(e.negate){let n=e.long.replace(/^--no-/,"--");this._findOption(n)||this.setOptionValueWithSource(s,e.defaultValue===void 0?!0:e.defaultValue,"default")}else e.defaultValue!==void 0&&this.setOptionValueWithSource(s,e.defaultValue,"default");let o=(n,a,d)=>{n==null&&e.presetArg!==void 0&&(n=e.presetArg);let c=this.getOptionValue(s);n!==null&&e.parseArg?n=this._callParseArg(e,n,c,a):n!==null&&e.variadic&&(n=e._collectValue(n,c)),n==null&&(e.negate?n=!1:e.isBoolean()||e.optional?n=!0:n=""),this.setOptionValueWithSource(s,n,d)};return this.on("option:"+t,n=>{let a=`error: option '${e.flags}' argument '${n}' is invalid.`;o(n,a,"cli")}),e.envVar&&this.on("optionEnv:"+t,n=>{let a=`error: option '${e.flags}' value '${n}' from env '${e.envVar}' is invalid.`;o(n,a,"env")}),this}_optionEx(e,t,s,o,n){if(typeof t=="object"&&t instanceof ir)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let a=this.createOption(t,s);if(a.makeOptionMandatory(!!e.mandatory),typeof o=="function")a.default(n).argParser(o);else if(o instanceof RegExp){let d=o;o=(c,h)=>{let m=d.exec(c);return m?m[0]:h},a.default(n).argParser(o)}else a.default(o);return this.addOption(a)}option(e,t,s,o){return this._optionEx({},e,t,s,o)}requiredOption(e,t,s,o){return this._optionEx({mandatory:!0},e,t,s,o)}combineFlagAndOptionalValue(e=!0){return this._combineFlagAndOptionalValue=!!e,this}allowUnknownOption(e=!0){return this._allowUnknownOption=!!e,this}allowExcessArguments(e=!0){return this._allowExcessArguments=!!e,this}enablePositionalOptions(e=!0){return this._enablePositionalOptions=!!e,this}passThroughOptions(e=!0){return this._passThroughOptions=!!e,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(e=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw new Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!e,this}getOptionValue(e){return this._storeOptionsAsProperties?this[e]:this._optionValues[e]}setOptionValue(e,t){return this.setOptionValueWithSource(e,t,void 0)}setOptionValueWithSource(e,t,s){return this._storeOptionsAsProperties?this[e]=t:this._optionValues[e]=t,this._optionValueSources[e]=s,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let t;return this._getCommandAndAncestors().forEach(s=>{s.getOptionValueSource(e)!==void 0&&(t=s.getOptionValueSource(e))}),t}_prepareUserArgs(e,t){if(e!==void 0&&!Array.isArray(e))throw new Error("first parameter to parse must be array or undefined");if(t=t||{},e===void 0&&t.from===void 0){J.versions?.electron&&(t.from="electron");let o=J.execArgv??[];(o.includes("-e")||o.includes("--eval")||o.includes("-p")||o.includes("--print"))&&(t.from="eval")}e===void 0&&(e=J.argv),this.rawArgs=e.slice();let s;switch(t.from){case void 0:case"node":this._scriptPath=e[1],s=e.slice(2);break;case"electron":J.defaultApp?(this._scriptPath=e[1],s=e.slice(2)):s=e.slice(1);break;case"user":s=e.slice(0);break;case"eval":s=e.slice(1);break;default:throw new Error(`unexpected parse option { from: '${t.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",s}parse(e,t){this._prepareForParse();let s=this._prepareUserArgs(e,t);return this._parseCommand([],s),this}async parseAsync(e,t){this._prepareForParse();let s=this._prepareUserArgs(e,t);return await this._parseCommand([],s),this}_prepareForParse(){this._savedState===null?this.saveStateBeforeParse():this.restoreStateBeforeParse()}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw new Error(`Can not call parse again when storeOptionsAsProperties is true.
|
|
18
|
+
- 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,s){if(Zs.existsSync(e))return;let o=t?`searched for local subcommand relative to directory '${t}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",n=`'${e}' does not exist
|
|
19
|
+
- if '${s}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
|
|
20
20
|
- if the default executable name is not suitable, use the executableFile option to supply a custom name or path
|
|
21
|
-
- ${
|
|
21
|
+
- ${o}`;throw new Error(n)}_executeSubCommand(e,t){t=t.slice();let s=!1,o=[".js",".ts",".tsx",".mjs",".cjs"];function n(m,p){let g=nt.resolve(m,p);if(Zs.existsSync(g))return g;if(o.includes(nt.extname(p)))return;let w=o.find(k=>Zs.existsSync(`${g}${k}`));if(w)return`${g}${w}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let a=e._executableFile||`${this._name}-${e._name}`,d=this._executableDir||"";if(this._scriptPath){let m;try{m=Zs.realpathSync(this._scriptPath)}catch{m=this._scriptPath}d=nt.resolve(nt.dirname(m),d)}if(d){let m=n(d,a);if(!m&&!e._executableFile&&this._scriptPath){let p=nt.basename(this._scriptPath,nt.extname(this._scriptPath));p!==this._name&&(m=n(d,`${p}-${e._name}`))}a=m||a}s=o.includes(nt.extname(a));let c;J.platform!=="win32"?s?(t.unshift(a),t=ar(J.execArgv).concat(t),c=Sn.spawn(J.argv[0],t,{stdio:"inherit"})):c=Sn.spawn(a,t,{stdio:"inherit"}):(this._checkForMissingExecutable(a,d,e._name),t.unshift(a),t=ar(J.execArgv).concat(t),c=Sn.spawn(J.execPath,t,{stdio:"inherit"})),c.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(p=>{J.on(p,()=>{c.killed===!1&&c.exitCode===null&&c.kill(p)})});let h=this._exitCallback;c.on("close",m=>{m=m??1,h?h(new kn(m,"commander.executeSubCommandAsync","(close)")):J.exit(m)}),c.on("error",m=>{if(m.code==="ENOENT")this._checkForMissingExecutable(a,d,e._name);else if(m.code==="EACCES")throw new Error(`'${a}' not executable`);if(!h)J.exit(1);else{let p=new kn(1,"commander.executeSubCommandAsync","(error)");p.nestedError=m,h(p)}}),this.runningCommand=c}_dispatchSubcommand(e,t,s){let o=this._findCommand(e);o||this.help({error:!0}),o._prepareForParse();let n;return n=this._chainOrCallSubCommandHook(n,o,"preSubcommand"),n=this._chainOrCall(n,()=>{if(o._executableHandler)this._executeSubCommand(o,t.concat(s));else return o._parseCommand(t,s)}),n}_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=(s,o,n)=>{let a=o;if(o!==null&&s.parseArg){let d=`error: command-argument value '${o}' is invalid for argument '${s.name()}'.`;a=this._callParseArg(s,o,n,d)}return a};this._checkNumberOfArguments();let t=[];this.registeredArguments.forEach((s,o)=>{let n=s.defaultValue;s.variadic?o<this.args.length?(n=this.args.slice(o),s.parseArg&&(n=n.reduce((a,d)=>e(s,d,a),s.defaultValue))):n===void 0&&(n=[]):o<this.args.length&&(n=this.args[o],s.parseArg&&(n=e(s,n,s.defaultValue))),t[o]=n}),this.processedArgs=t}_chainOrCall(e,t){return e?.then&&typeof e.then=="function"?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let s=e,o=[];return this._getCommandAndAncestors().reverse().filter(n=>n._lifeCycleHooks[t]!==void 0).forEach(n=>{n._lifeCycleHooks[t].forEach(a=>{o.push({hookedCommand:n,callback:a})})}),t==="postAction"&&o.reverse(),o.forEach(n=>{s=this._chainOrCall(s,()=>n.callback(n.hookedCommand,this))}),s}_chainOrCallSubCommandHook(e,t,s){let o=e;return this._lifeCycleHooks[s]!==void 0&&this._lifeCycleHooks[s].forEach(n=>{o=this._chainOrCall(o,()=>n(this,t))}),o}_parseCommand(e,t){let s=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(s.operands),t=s.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(s.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let o=()=>{s.unknown.length>0&&this.unknownOption(s.unknown[0])},n=`command:${this.name()}`;if(this._actionHandler){o(),this._processArguments();let a;return a=this._chainOrCallHooks(a,"preAction"),a=this._chainOrCall(a,()=>this._actionHandler(this.processedArgs)),this.parent&&(a=this._chainOrCall(a,()=>{this.parent.emit(n,e,t)})),a=this._chainOrCallHooks(a,"postAction"),a}if(this.parent?.listenerCount(n))o(),this._processArguments(),this.parent.emit(n,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():(o(),this._processArguments())}else this.commands.length?(o(),this.help({error:!0})):(o(),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(s=>{let o=s.attributeName();return this.getOptionValue(o)===void 0?!1:this.getOptionValueSource(o)!=="default"});e.filter(s=>s.conflictsWith.length>0).forEach(s=>{let o=e.find(n=>s.conflictsWith.includes(n.attributeName()));o&&this._conflictingOption(s,o)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],s=[],o=t;function n(m){return m.length>1&&m[0]==="-"}let a=m=>/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(m)?!this._getCommandAndAncestors().some(p=>p.options.map(g=>g.short).some(g=>/^-\d$/.test(g))):!1,d=null,c=null,h=0;for(;h<e.length||c;){let m=c??e[h++];if(c=null,m==="--"){o===s&&o.push(m),o.push(...e.slice(h));break}if(d&&(!n(m)||a(m))){this.emit(`option:${d.name()}`,m);continue}if(d=null,n(m)){let p=this._findOption(m);if(p){if(p.required){let g=e[h++];g===void 0&&this.optionMissingArgument(p),this.emit(`option:${p.name()}`,g)}else if(p.optional){let g=null;h<e.length&&(!n(e[h])||a(e[h]))&&(g=e[h++]),this.emit(`option:${p.name()}`,g)}else this.emit(`option:${p.name()}`);d=p.variadic?p:null;continue}}if(m.length>2&&m[0]==="-"&&m[1]!=="-"){let p=this._findOption(`-${m[1]}`);if(p){p.required||p.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${p.name()}`,m.slice(2)):(this.emit(`option:${p.name()}`),c=`-${m.slice(2)}`);continue}}if(/^--[^=]+=/.test(m)){let p=m.indexOf("="),g=this._findOption(m.slice(0,p));if(g&&(g.required||g.optional)){this.emit(`option:${g.name()}`,m.slice(p+1));continue}}if(o===t&&n(m)&&!(this.commands.length===0&&a(m))&&(o=s),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&s.length===0){if(this._findCommand(m)){t.push(m),s.push(...e.slice(h));break}else if(this._getHelpCommand()&&m===this._getHelpCommand().name()){t.push(m,...e.slice(h));break}else if(this._defaultCommandName){s.push(m,...e.slice(h));break}}if(this._passThroughOptions){o.push(m,...e.slice(h));break}o.push(m)}return{operands:t,unknown:s}}opts(){if(this._storeOptionsAsProperties){let e={},t=this.options.length;for(let s=0;s<t;s++){let o=this.options[s].attributeName();e[o]=o===this._versionOptionName?this._version:this[o]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){this._outputConfiguration.outputError(`${e}
|
|
22
22
|
`,this._outputConfiguration.writeErr),typeof this._showHelpAfterError=="string"?this._outputConfiguration.writeErr(`${this._showHelpAfterError}
|
|
23
23
|
`):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
|
|
24
|
-
`),this.outputHelp({error:!0}));let
|
|
25
|
-
`),this._exit(0,"commander.version",e)}),this}description(e,t){return e===void 0&&t===void 0?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw new Error("Command alias can't be the same as its name");let
|
|
26
|
-
Expecting one of '${
|
|
27
|
-
`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(s=>t.is(s))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function $i(n){return n.map(e=>{if(!e.startsWith("--inspect"))return e;let t,o="127.0.0.1",s="9229",r;return(r=e.match(/^(--inspect(-brk)?)$/))!==null?t=r[1]:(r=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(t=r[1],/^\d+$/.test(r[3])?s=r[3]:o=r[3]):(r=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=r[1],o=r[3],s=r[4]),t&&s!=="0"?`${t}=${o}:${parseInt(s)+1}`:e})}function an(){if(J.env.NO_COLOR||J.env.FORCE_COLOR==="0"||J.env.FORCE_COLOR==="false")return!1;if(J.env.FORCE_COLOR||J.env.CLICOLOR_FORCE!==void 0)return!0}ln.Command=rn;ln.useColor=an});var Bi=ee(Re=>{var{Argument:Ni}=qo(),{Command:cn}=ji(),{CommanderError:Tl,InvalidArgumentError:qi}=uo(),{Help:Ml}=Xs(),{Option:Li}=on();Re.program=new cn;Re.createCommand=n=>new cn(n);Re.createOption=(n,e)=>new Li(n,e);Re.createArgument=(n,e)=>new Ni(n,e);Re.Command=cn;Re.Option=Li;Re.Argument=Ni;Re.Help=Ml;Re.CommanderError=Tl;Re.InvalidArgumentError=qi;Re.InvalidOptionArgumentError=qi});var gn=ee((Jo,St)=>{var Ho=void 0,Vo=function(n){return Ho||(Ho=new Promise(function(e,t){var o=typeof n<"u"?n:{},s=o.onAbort;o.onAbort=function(i){t(new Error(i)),s&&s(i)},o.postRun=o.postRun||[],o.postRun.push(function(){e(o)}),St=void 0;var r;r||=typeof o<"u"?o:{};var l=!!globalThis.window,u=!!globalThis.WorkerGlobalScope,d=globalThis.process?.versions?.node&&globalThis.process?.type!="renderer";r.onRuntimeInitialized=function(){function i(k,A){switch(typeof A){case"boolean":il(k,A?1:0);break;case"number":ol(k,A);break;case"string":sl(k,A,-1,-1);break;case"object":if(A===null)Ti(k);else if(A.length!=null){var R=Ro(A.length);O.set(A,R),nl(k,R,A.length,-1),co(R)}else jo(k,"Wrong API use : tried to return a value of an unknown type ("+A+").",-1);break;default:Ti(k)}}function a(k,A){for(var R=[],F=0;F<k;F+=1){var G=xe(A+4*F,"i32"),Y=Qa(G);if(Y===1||Y===2)G=tl(G);else if(Y===3)G=Za(G);else if(Y===4){Y=G,G=Xa(Y),Y=el(Y);for(var Ne=new Uint8Array(G),Ie=0;Ie<G;Ie+=1)Ne[Ie]=O[Y+Ie];G=Ne}else G=null;R.push(G)}return R}function c(k,A){this.Qa=k,this.db=A,this.Oa=1,this.mb=[]}function f(k,A){if(this.db=A,this.fb=Io(k),this.fb===null)throw Error("Unable to allocate memory for the SQL string");this.lb=this.fb,this.$a=this.sb=null}function C(k){if(this.filename="dbfile_"+(4294967295*Math.random()>>>0),k!=null){var A=this.filename,R="/",F=A;if(R&&(R=typeof R=="string"?R:Os(R),F=A?We(R+"/"+A):R),A=Zn(!0,!0),F=Ta(F,A),k){if(typeof k=="string"){R=Array(k.length);for(var G=0,Y=k.length;G<Y;++G)R[G]=k.charCodeAt(G);k=R}Po(F,A|146),R=Nt(F,577),hi(R,k,0,k.length,0),js(R),Po(F,A)}}this.handleError(j(this.filename,x)),this.db=xe(x,"i32"),Ai(this.db),this.gb={},this.Sa={}}var x=Ct(4),M=r.cwrap,j=M("sqlite3_open","number",["string","number"]),K=M("sqlite3_close_v2","number",["number"]),L=M("sqlite3_exec","number",["number","string","number","number","number"]),Z=M("sqlite3_changes","number",["number"]),he=M("sqlite3_prepare_v2","number",["number","string","number","number","number"]),wi=M("sqlite3_sql","string",["number"]),Ra=M("sqlite3_normalized_sql","string",["number"]),Si=M("sqlite3_prepare_v2","number",["number","number","number","number","number"]),Ua=M("sqlite3_bind_text","number",["number","number","number","number","number"]),ki=M("sqlite3_bind_blob","number",["number","number","number","number","number"]),Fa=M("sqlite3_bind_double","number",["number","number","number"]),$a=M("sqlite3_bind_int","number",["number","number","number"]),ja=M("sqlite3_bind_parameter_index","number",["number","string"]),Na=M("sqlite3_step","number",["number"]),qa=M("sqlite3_errmsg","string",["number"]),La=M("sqlite3_column_count","number",["number"]),Ba=M("sqlite3_data_count","number",["number"]),Ga=M("sqlite3_column_double","number",["number","number"]),vi=M("sqlite3_column_text","string",["number","number"]),za=M("sqlite3_column_blob","number",["number","number"]),Wa=M("sqlite3_column_bytes","number",["number","number"]),Ha=M("sqlite3_column_type","number",["number","number"]),Va=M("sqlite3_column_name","string",["number","number"]),Ja=M("sqlite3_reset","number",["number"]),Ka=M("sqlite3_clear_bindings","number",["number"]),Ya=M("sqlite3_finalize","number",["number"]),xi=M("sqlite3_create_function_v2","number","number string number number number number number number number".split(" ")),Qa=M("sqlite3_value_type","number",["number"]),Xa=M("sqlite3_value_bytes","number",["number"]),Za=M("sqlite3_value_text","string",["number"]),el=M("sqlite3_value_blob","number",["number"]),tl=M("sqlite3_value_double","number",["number"]),ol=M("sqlite3_result_double","",["number","number"]),Ti=M("sqlite3_result_null","",["number"]),sl=M("sqlite3_result_text","",["number","string","number","number"]),nl=M("sqlite3_result_blob","",["number","number","number","number"]),il=M("sqlite3_result_int","",["number","number"]),jo=M("sqlite3_result_error","",["number","string","number"]),Mi=M("sqlite3_aggregate_context","number",["number","number"]),Ai=M("RegisterExtensionFunctions","number",["number"]),Pi=M("sqlite3_update_hook","number",["number","number","number"]);c.prototype.bind=function(k){if(!this.Qa)throw"Statement closed";return this.reset(),Array.isArray(k)?this.Gb(k):k!=null&&typeof k=="object"?this.Hb(k):!0},c.prototype.step=function(){if(!this.Qa)throw"Statement closed";this.Oa=1;var k=Na(this.Qa);switch(k){case 100:return!0;case 101:return!1;default:throw this.db.handleError(k)}},c.prototype.Ab=function(k){return k==null&&(k=this.Oa,this.Oa+=1),Ga(this.Qa,k)},c.prototype.Ob=function(k){if(k==null&&(k=this.Oa,this.Oa+=1),k=vi(this.Qa,k),typeof BigInt!="function")throw Error("BigInt is not supported");return BigInt(k)},c.prototype.Tb=function(k){return k==null&&(k=this.Oa,this.Oa+=1),vi(this.Qa,k)},c.prototype.getBlob=function(k){k==null&&(k=this.Oa,this.Oa+=1);var A=Wa(this.Qa,k);k=za(this.Qa,k);for(var R=new Uint8Array(A),F=0;F<A;F+=1)R[F]=O[k+F];return R},c.prototype.get=function(k,A){A=A||{},k!=null&&this.bind(k)&&this.step(),k=[];for(var R=Ba(this.Qa),F=0;F<R;F+=1)switch(Ha(this.Qa,F)){case 1:var G=A.useBigInt?this.Ob(F):this.Ab(F);k.push(G);break;case 2:k.push(this.Ab(F));break;case 3:k.push(this.Tb(F));break;case 4:k.push(this.getBlob(F));break;default:k.push(null)}return k},c.prototype.qb=function(){for(var k=[],A=La(this.Qa),R=0;R<A;R+=1)k.push(Va(this.Qa,R));return k},c.prototype.zb=function(k,A){k=this.get(k,A),A=this.qb();for(var R={},F=0;F<A.length;F+=1)R[A[F]]=k[F];return R},c.prototype.Sb=function(){return wi(this.Qa)},c.prototype.Pb=function(){return Ra(this.Qa)},c.prototype.run=function(k){return k!=null&&this.bind(k),this.step(),this.reset()},c.prototype.wb=function(k,A){A==null&&(A=this.Oa,this.Oa+=1),k=Io(k),this.mb.push(k),this.db.handleError(Ua(this.Qa,A,k,-1,0))},c.prototype.Fb=function(k,A){A==null&&(A=this.Oa,this.Oa+=1);var R=Ro(k.length);O.set(k,R),this.mb.push(R),this.db.handleError(ki(this.Qa,A,R,k.length,0))},c.prototype.vb=function(k,A){A==null&&(A=this.Oa,this.Oa+=1),this.db.handleError((k===(k|0)?$a:Fa)(this.Qa,A,k))},c.prototype.Ib=function(k){k==null&&(k=this.Oa,this.Oa+=1),ki(this.Qa,k,0,0,0)},c.prototype.xb=function(k,A){switch(A==null&&(A=this.Oa,this.Oa+=1),typeof k){case"string":this.wb(k,A);return;case"number":this.vb(k,A);return;case"bigint":this.wb(k.toString(),A);return;case"boolean":this.vb(k+0,A);return;case"object":if(k===null){this.Ib(A);return}if(k.length!=null){this.Fb(k,A);return}}throw"Wrong API use : tried to bind a value of an unknown type ("+k+")."},c.prototype.Hb=function(k){var A=this;return Object.keys(k).forEach(function(R){var F=ja(A.Qa,R);F!==0&&A.xb(k[R],F)}),!0},c.prototype.Gb=function(k){for(var A=0;A<k.length;A+=1)this.xb(k[A],A+1);return!0},c.prototype.reset=function(){return this.freemem(),Ka(this.Qa)===0&&Ja(this.Qa)===0},c.prototype.freemem=function(){for(var k;(k=this.mb.pop())!==void 0;)co(k)},c.prototype.Ya=function(){this.freemem();var k=Ya(this.Qa)===0;return delete this.db.gb[this.Qa],this.Qa=0,k},f.prototype.next=function(){if(this.fb===null)return{done:!0};if(this.$a!==null&&(this.$a.Ya(),this.$a=null),!this.db.db)throw this.ob(),Error("Database closed");var k=Fo(),A=Ct(4);$e(x),$e(A);try{this.db.handleError(Si(this.db.db,this.lb,-1,x,A)),this.lb=xe(A,"i32");var R=xe(x,"i32");return R===0?(this.ob(),{done:!0}):(this.$a=new c(R,this.db),this.db.gb[R]=this.$a,{value:this.$a,done:!1})}catch(F){throw this.sb=$(this.lb),this.ob(),F}finally{Uo(k)}},f.prototype.ob=function(){co(this.fb),this.fb=null},f.prototype.Qb=function(){return this.sb!==null?this.sb:$(this.lb)},typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"&&(f.prototype[Symbol.iterator]=function(){return this}),C.prototype.run=function(k,A){if(!this.db)throw"Database closed";if(A){k=this.tb(k,A);try{k.step()}finally{k.Ya()}}else this.handleError(L(this.db,k,0,0,x));return this},C.prototype.exec=function(k,A,R){if(!this.db)throw"Database closed";var F=null,G=null,Y=null;try{Y=G=Io(k);var Ne=Ct(4);for(k=[];xe(Y,"i8")!==0;){$e(x),$e(Ne),this.handleError(Si(this.db,Y,-1,x,Ne));var Ie=xe(x,"i32");if(Y=xe(Ne,"i32"),Ie!==0){var Ee=null;for(F=new c(Ie,this),A!=null&&F.bind(A);F.step();)Ee===null&&(Ee={columns:F.qb(),values:[]},k.push(Ee)),Ee.values.push(F.get(null,R));F.Ya()}}return k}catch(qe){throw F&&F.Ya(),qe}finally{G&&co(G)}},C.prototype.Mb=function(k,A,R,F,G){typeof A=="function"&&(F=R,R=A,A=void 0),k=this.tb(k,A);try{for(;k.step();)R(k.zb(null,G))}finally{k.Ya()}if(typeof F=="function")return F()},C.prototype.tb=function(k,A){if($e(x),this.handleError(he(this.db,k,-1,x,0)),k=xe(x,"i32"),k===0)throw"Nothing to prepare";var R=new c(k,this);return A!=null&&R.bind(A),this.gb[k]=R},C.prototype.Ub=function(k){return new f(k,this)},C.prototype.Nb=function(){Object.values(this.gb).forEach(function(A){A.Ya()}),Object.values(this.Sa).forEach(at),this.Sa={},this.handleError(K(this.db));var k=Ma(this.filename);return this.handleError(j(this.filename,x)),this.db=xe(x,"i32"),Ai(this.db),k},C.prototype.close=function(){this.db!==null&&(Object.values(this.gb).forEach(function(k){k.Ya()}),Object.values(this.Sa).forEach(at),this.Sa={},this.Za&&(at(this.Za),this.Za=void 0),this.handleError(K(this.db)),ci("/"+this.filename),this.db=null)},C.prototype.handleError=function(k){if(k===0)return null;throw k=qa(this.db),Error(k)},C.prototype.Rb=function(){return Z(this.db)},C.prototype.Kb=function(k,A){Object.prototype.hasOwnProperty.call(this.Sa,k)&&(at(this.Sa[k]),delete this.Sa[k]);var R=lo(function(F,G,Y){G=a(G,Y);try{var Ne=A.apply(null,G)}catch(Ie){jo(F,Ie,-1);return}i(F,Ne)},"viii");return this.Sa[k]=R,this.handleError(xi(this.db,k,A.length,1,0,R,0,0,0)),this},C.prototype.Jb=function(k,A){var R=A.init||function(){return null},F=A.finalize||function(Ee){return Ee},G=A.step;if(!G)throw"An aggregate function must have a step function in "+k;var Y={};Object.hasOwnProperty.call(this.Sa,k)&&(at(this.Sa[k]),delete this.Sa[k]),A=k+"__finalize",Object.hasOwnProperty.call(this.Sa,A)&&(at(this.Sa[A]),delete this.Sa[A]);var Ne=lo(function(Ee,qe,Ws){var wt=Mi(Ee,1);Object.hasOwnProperty.call(Y,wt)||(Y[wt]=R()),qe=a(qe,Ws),qe=[Y[wt]].concat(qe);try{Y[wt]=G.apply(null,qe)}catch(rl){delete Y[wt],jo(Ee,rl,-1)}},"viii"),Ie=lo(function(Ee){var qe=Mi(Ee,1);try{var Ws=F(Y[qe])}catch(wt){delete Y[qe],jo(Ee,wt,-1);return}i(Ee,Ws),delete Y[qe]},"vi");return this.Sa[k]=Ne,this.Sa[A]=Ie,this.handleError(xi(this.db,k,G.length-1,1,0,0,Ne,Ie,0)),this},C.prototype.Zb=function(k){return this.Za&&(Pi(this.db,0,0),at(this.Za),this.Za=void 0),k?(this.Za=lo(function(A,R,F,G,Y){switch(R){case 18:A="insert";break;case 23:A="update";break;case 9:A="delete";break;default:throw"unknown operationCode in updateHook callback: "+R}if(F=$(F),G=$(G),Y>Number.MAX_SAFE_INTEGER)throw"rowId too big to fit inside a Number";k(A,F,G,Number(Y))},"viiiij"),Pi(this.db,this.Za,0),this):this},c.prototype.bind=c.prototype.bind,c.prototype.step=c.prototype.step,c.prototype.get=c.prototype.get,c.prototype.getColumnNames=c.prototype.qb,c.prototype.getAsObject=c.prototype.zb,c.prototype.getSQL=c.prototype.Sb,c.prototype.getNormalizedSQL=c.prototype.Pb,c.prototype.run=c.prototype.run,c.prototype.reset=c.prototype.reset,c.prototype.freemem=c.prototype.freemem,c.prototype.free=c.prototype.Ya,f.prototype.next=f.prototype.next,f.prototype.getRemainingSQL=f.prototype.Qb,C.prototype.run=C.prototype.run,C.prototype.exec=C.prototype.exec,C.prototype.each=C.prototype.Mb,C.prototype.prepare=C.prototype.tb,C.prototype.iterateStatements=C.prototype.Ub,C.prototype.export=C.prototype.Nb,C.prototype.close=C.prototype.close,C.prototype.handleError=C.prototype.handleError,C.prototype.getRowsModified=C.prototype.Rb,C.prototype.create_function=C.prototype.Kb,C.prototype.create_aggregate=C.prototype.Jb,C.prototype.updateHook=C.prototype.Zb,r.Database=C};var h="./this.program",m=(i,a)=>{throw a},p=globalThis.document?.currentScript?.src;typeof __filename<"u"?p=__filename:u&&(p=self.location.href);var g="",_,w;if(d){var b=require("node:fs");g=__dirname+"/",w=i=>(i=I(i)?new URL(i):i,b.readFileSync(i)),_=async i=>(i=I(i)?new URL(i):i,b.readFileSync(i,void 0)),1<process.argv.length&&(h=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2),typeof St<"u"&&(St.exports=r),m=(i,a)=>{throw process.exitCode=i,a}}else if(l||u){try{g=new URL(".",p).href}catch{}u&&(w=i=>{var a=new XMLHttpRequest;return a.open("GET",i,!1),a.responseType="arraybuffer",a.send(null),new Uint8Array(a.response)}),_=async i=>{if(I(i))return new Promise((c,f)=>{var C=new XMLHttpRequest;C.open("GET",i,!0),C.responseType="arraybuffer",C.onload=()=>{C.status==200||C.status==0&&C.response?c(C.response):f(C.status)},C.onerror=f,C.send(null)});var a=await fetch(i,{credentials:"same-origin"});if(a.ok)return a.arrayBuffer();throw Error(a.status+" : "+a.url)}}var y=console.log.bind(console),S=console.error.bind(console),v,E=!1,P,I=i=>i.startsWith("file://"),O,U,fe,V,H,ke,le,ge;function Pe(){var i=$o.buffer;O=new Int8Array(i),fe=new Int16Array(i),U=new Uint8Array(i),new Uint16Array(i),V=new Int32Array(i),H=new Uint32Array(i),ke=new Float32Array(i),le=new Float64Array(i),ge=new BigInt64Array(i),new BigUint64Array(i)}function be(i){throw r.onAbort?.(i),i="Aborted("+i+")",S(i),E=!0,new WebAssembly.RuntimeError(i+". Build with -sASSERTIONS for more info.")}var Ge;async function ze(i){if(!v)try{var a=await _(i);return new Uint8Array(a)}catch{}if(i==Ge&&v)i=new Uint8Array(v);else if(w)i=w(i);else throw"both async and sync fetching of the wasm failed";return i}async function ue(i,a){try{var c=await ze(i);return await WebAssembly.instantiate(c,a)}catch(f){S(`failed to asynchronously prepare wasm: ${f}`),be(f)}}async function oo(i){var a=Ge;if(!v&&!I(a)&&!d)try{var c=fetch(a,{credentials:"same-origin"});return await WebAssembly.instantiateStreaming(c,i)}catch(f){S(`wasm streaming compile failed: ${f}`),S("falling back to ArrayBuffer instantiation")}return ue(a,i)}class me{name="ExitStatus";constructor(a){this.message=`Program terminated with exit(${a})`,this.status=a}}var Ce=i=>{for(;0<i.length;)i.shift()(r)},so=[],gt=[],Ke=()=>{var i=r.preRun.shift();gt.push(i)},ve=0,ce=null;function xe(i,a="i8"){switch(a.endsWith("*")&&(a="*"),a){case"i1":return O[i];case"i8":return O[i];case"i16":return fe[i>>1];case"i32":return V[i>>2];case"i64":return ge[i>>3];case"float":return ke[i>>2];case"double":return le[i>>3];case"*":return H[i>>2];default:be(`invalid type for getValue: ${a}`)}}var no=!0;function $e(i){var a="i32";switch(a.endsWith("*")&&(a="*"),a){case"i1":O[i]=0;break;case"i8":O[i]=0;break;case"i16":fe[i>>1]=0;break;case"i32":V[i>>2]=0;break;case"i64":ge[i>>3]=BigInt(0);break;case"float":ke[i>>2]=0;break;case"double":le[i>>3]=0;break;case"*":H[i>>2]=0;break;default:be(`invalid type for setValue: ${a}`)}}var It=new TextDecoder,Rt=(i,a,c,f)=>{if(c=a+c,f)return c;for(;i[a]&&!(a>=c);)++a;return a},$=(i,a,c)=>i?It.decode(U.subarray(i,Rt(U,i,a,c))):"",Ye=(i,a)=>{for(var c=0,f=i.length-1;0<=f;f--){var C=i[f];C==="."?i.splice(f,1):C===".."?(i.splice(f,1),c++):c&&(i.splice(f,1),c--)}if(a)for(;c;c--)i.unshift("..");return i},We=i=>{var a=i.charAt(0)==="/",c=i.slice(-1)==="/";return(i=Ye(i.split("/").filter(f=>!!f),!a).join("/"))||a||(i="."),i&&c&&(i+="/"),(a?"/":"")+i},Ut=i=>{var a=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(i).slice(1);return i=a[0],a=a[1],!i&&!a?".":(a&&=a.slice(0,-1),i+a)},ne=i=>i&&i.match(/([^\/]+|\/)\/*$/)[1],re=()=>{if(d){var i=require("node:crypto");return a=>i.randomFillSync(a)}return a=>crypto.getRandomValues(a)},je=i=>{(je=re())(i)},Ps=(...i)=>{for(var a="",c=!1,f=i.length-1;-1<=f&&!c;f--){if(c=0<=f?i[f]:"/",typeof c!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!c)return"";a=c+"/"+a,c=c.charAt(0)==="/"}return a=Ye(a.split("/").filter(C=>!!C),!c).join("/"),(c?"/":"")+a||"."},io=i=>{var a=Rt(i,0);return It.decode(i.buffer?i.subarray(0,a):new Uint8Array(i.slice(0,a)))},Es=[],Ft=i=>{for(var a=0,c=0;c<i.length;++c){var f=i.charCodeAt(c);127>=f?a++:2047>=f?a+=2:55296<=f&&57343>=f?(a+=4,++c):a+=3}return a},He=(i,a,c,f)=>{if(!(0<f))return 0;var C=c;f=c+f-1;for(var x=0;x<i.length;++x){var M=i.codePointAt(x);if(127>=M){if(c>=f)break;a[c++]=M}else if(2047>=M){if(c+1>=f)break;a[c++]=192|M>>6,a[c++]=128|M&63}else if(65535>=M){if(c+2>=f)break;a[c++]=224|M>>12,a[c++]=128|M>>6&63,a[c++]=128|M&63}else{if(c+3>=f)break;a[c++]=240|M>>18,a[c++]=128|M>>12&63,a[c++]=128|M>>6&63,a[c++]=128|M&63,x++}}return a[c]=0,c-C},Qn=[];function Xn(i,a){Qn[i]={input:[],output:[],eb:a},Fs(i,_a)}var _a={open(i){var a=Qn[i.node.rdev];if(!a)throw new D(43);i.tty=a,i.seekable=!1},close(i){i.tty.eb.fsync(i.tty)},fsync(i){i.tty.eb.fsync(i.tty)},read(i,a,c,f){if(!i.tty||!i.tty.eb.Bb)throw new D(60);for(var C=0,x=0;x<f;x++){try{var M=i.tty.eb.Bb(i.tty)}catch{throw new D(29)}if(M===void 0&&C===0)throw new D(6);if(M==null)break;C++,a[c+x]=M}return C&&(i.node.atime=Date.now()),C},write(i,a,c,f){if(!i.tty||!i.tty.eb.ub)throw new D(60);try{for(var C=0;C<f;C++)i.tty.eb.ub(i.tty,a[c+C])}catch{throw new D(29)}return f&&(i.node.mtime=i.node.ctime=Date.now()),C}},ba={Bb(){e:{if(!Es.length){var i=null;if(d){var a=Buffer.alloc(256),c=0,f=process.stdin.fd;try{c=b.readSync(f,a,0,256)}catch(C){if(C.toString().includes("EOF"))c=0;else throw C}0<c&&(i=a.slice(0,c).toString("utf-8"))}else globalThis.window?.prompt&&(i=window.prompt("Input: "),i!==null&&(i+=`
|
|
28
|
-
`));if(!i){i=null;break e}a=Array(Ft(i)+1),i=He(i,a,0,a.length),a.length=i,Es=a}i=Es.shift()}return i},ub(i,a){a===null||a===10?(y(io(i.output)),i.output=[]):a!=0&&i.output.push(a)},fsync(i){0<i.output?.length&&(y(io(i.output)),i.output=[])},hc(){return{bc:25856,dc:5,ac:191,cc:35387,$b:[3,28,127,21,4,0,1,0,17,19,26,0,18,15,23,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},ic(){return 0},jc(){return[24,80]}},Ca={ub(i,a){a===null||a===10?(S(io(i.output)),i.output=[]):a!=0&&i.output.push(a)},fsync(i){0<i.output?.length&&(S(io(i.output)),i.output=[])}},q={Wa:null,Xa(){return q.createNode(null,"/",16895,0)},createNode(i,a,c,f){if((c&61440)===24576||(c&61440)===4096)throw new D(63);return q.Wa||(q.Wa={dir:{node:{Ta:q.La.Ta,Ua:q.La.Ua,lookup:q.La.lookup,ib:q.La.ib,rename:q.La.rename,unlink:q.La.unlink,rmdir:q.La.rmdir,readdir:q.La.readdir,symlink:q.La.symlink},stream:{Va:q.Ma.Va}},file:{node:{Ta:q.La.Ta,Ua:q.La.Ua},stream:{Va:q.Ma.Va,read:q.Ma.read,write:q.Ma.write,jb:q.Ma.jb,kb:q.Ma.kb}},link:{node:{Ta:q.La.Ta,Ua:q.La.Ua,readlink:q.La.readlink},stream:{}},yb:{node:{Ta:q.La.Ta,Ua:q.La.Ua},stream:xa}}),c=si(i,a,c,f),Te(c.mode)?(c.La=q.Wa.dir.node,c.Ma=q.Wa.dir.stream,c.Na={}):(c.mode&61440)===32768?(c.La=q.Wa.file.node,c.Ma=q.Wa.file.stream,c.Ra=0,c.Na=null):(c.mode&61440)===40960?(c.La=q.Wa.link.node,c.Ma=q.Wa.link.stream):(c.mode&61440)===8192&&(c.La=q.Wa.yb.node,c.Ma=q.Wa.yb.stream),c.atime=c.mtime=c.ctime=Date.now(),i&&(i.Na[a]=c,i.atime=i.mtime=i.ctime=c.atime),c},fc(i){return i.Na?i.Na.subarray?i.Na.subarray(0,i.Ra):new Uint8Array(i.Na):new Uint8Array(0)},La:{Ta(i){var a={};return a.dev=(i.mode&61440)===8192?i.id:1,a.ino=i.id,a.mode=i.mode,a.nlink=1,a.uid=0,a.gid=0,a.rdev=i.rdev,Te(i.mode)?a.size=4096:(i.mode&61440)===32768?a.size=i.Ra:(i.mode&61440)===40960?a.size=i.link.length:a.size=0,a.atime=new Date(i.atime),a.mtime=new Date(i.mtime),a.ctime=new Date(i.ctime),a.blksize=4096,a.blocks=Math.ceil(a.size/a.blksize),a},Ua(i,a){for(var c of["mode","atime","mtime","ctime"])a[c]!=null&&(i[c]=a[c]);a.size!==void 0&&(a=a.size,i.Ra!=a&&(a==0?(i.Na=null,i.Ra=0):(c=i.Na,i.Na=new Uint8Array(a),c&&i.Na.set(c.subarray(0,Math.min(a,i.Ra))),i.Ra=a)))},lookup(){throw q.nb||(q.nb=new D(44),q.nb.stack="<generic error, no stack>"),q.nb},ib(i,a,c,f){return q.createNode(i,a,c,f)},rename(i,a,c){try{var f=yt(a,c)}catch{}if(f){if(Te(i.mode))for(var C in f.Na)throw new D(55);Rs(f)}delete i.parent.Na[i.name],a.Na[c]=i,i.name=c,a.ctime=a.mtime=i.parent.ctime=i.parent.mtime=Date.now()},unlink(i,a){delete i.Na[a],i.ctime=i.mtime=Date.now()},rmdir(i,a){var c=yt(i,a),f;for(f in c.Na)throw new D(55);delete i.Na[a],i.ctime=i.mtime=Date.now()},readdir(i){return[".","..",...Object.keys(i.Na)]},symlink(i,a,c){return i=q.createNode(i,a,41471,0),i.link=c,i},readlink(i){if((i.mode&61440)!==40960)throw new D(28);return i.link}},Ma:{read(i,a,c,f,C){var x=i.node.Na;if(C>=i.node.Ra)return 0;if(i=Math.min(i.node.Ra-C,f),8<i&&x.subarray)a.set(x.subarray(C,C+i),c);else for(f=0;f<i;f++)a[c+f]=x[C+f];return i},write(i,a,c,f,C,x){if(a.buffer===O.buffer&&(x=!1),!f)return 0;if(i=i.node,i.mtime=i.ctime=Date.now(),a.subarray&&(!i.Na||i.Na.subarray)){if(x)return i.Na=a.subarray(c,c+f),i.Ra=f;if(i.Ra===0&&C===0)return i.Na=a.slice(c,c+f),i.Ra=f;if(C+f<=i.Ra)return i.Na.set(a.subarray(c,c+f),C),f}x=C+f;var M=i.Na?i.Na.length:0;if(M>=x||(x=Math.max(x,M*(1048576>M?2:1.125)>>>0),M!=0&&(x=Math.max(x,256)),M=i.Na,i.Na=new Uint8Array(x),0<i.Ra&&i.Na.set(M.subarray(0,i.Ra),0)),i.Na.subarray&&a.subarray)i.Na.set(a.subarray(c,c+f),C);else for(x=0;x<f;x++)i.Na[C+x]=a[c+x];return i.Ra=Math.max(i.Ra,C+f),f},Va(i,a,c){if(c===1?a+=i.position:c===2&&(i.node.mode&61440)===32768&&(a+=i.node.Ra),0>a)throw new D(28);return a},jb(i,a,c,f,C){if((i.node.mode&61440)!==32768)throw new D(43);if(i=i.node.Na,C&2||!i||i.buffer!==O.buffer){C=!0,f=65536*Math.ceil(a/65536);var x=bi(65536,f);if(x&&U.fill(0,x,x+f),f=x,!f)throw new D(48);i&&((0<c||c+a<i.length)&&(i.subarray?i=i.subarray(c,c+a):i=Array.prototype.slice.call(i,c,c+a)),O.set(i,f))}else C=!1,f=i.byteOffset;return{Xb:f,Eb:C}},kb(i,a,c,f){return q.Ma.write(i,a,0,f,c,!1),0}}},Zn=(i,a)=>{var c=0;return i&&(c|=365),a&&(c|=146),c},Ds=null,ei={},$t=[],wa=1,it=null,ti=!1,oi=!0,D=class{name="ErrnoError";constructor(i){this.Pa=i}},Sa=class{hb={};node=null;get flags(){return this.hb.flags}set flags(i){this.hb.flags=i}get position(){return this.hb.position}set position(i){this.hb.position=i}},ka=class{La={};Ma={};bb=null;constructor(i,a,c,f){i||=this,this.parent=i,this.Xa=i.Xa,this.id=wa++,this.name=a,this.mode=c,this.rdev=f,this.atime=this.mtime=this.ctime=Date.now()}get read(){return(this.mode&365)===365}set read(i){i?this.mode|=365:this.mode&=-366}get write(){return(this.mode&146)===146}set write(i){i?this.mode|=146:this.mode&=-147}};function Oe(i,a={}){if(!i)throw new D(44);a.pb??(a.pb=!0),i.charAt(0)==="/"||(i="//"+i);var c=0;e:for(;40>c;c++){i=i.split("/").filter(j=>!!j);for(var f=Ds,C="/",x=0;x<i.length;x++){var M=x===i.length-1;if(M&&a.parent)break;if(i[x]!==".")if(i[x]==="..")if(C=Ut(C),f===f.parent){i=C+"/"+i.slice(x+1).join("/"),c--;continue e}else f=f.parent;else{C=We(C+"/"+i[x]);try{f=yt(f,i[x])}catch(j){if(j?.Pa===44&&M&&a.Wb)return{path:C};throw j}if(!f.bb||M&&!a.pb||(f=f.bb.root),(f.mode&61440)===40960&&(!M||a.ab)){if(!f.La.readlink)throw new D(52);f=f.La.readlink(f),f.charAt(0)==="/"||(f=Ut(C)+"/"+f),i=f+"/"+i.slice(x+1).join("/");continue e}}}return{path:C,node:f}}throw new D(32)}function Os(i){for(var a;;){if(i===i.parent)return i=i.Xa.Db,a?i[i.length-1]!=="/"?`${i}/${a}`:i+a:i;a=a?`${i.name}/${a}`:i.name,i=i.parent}}function Is(i,a){for(var c=0,f=0;f<a.length;f++)c=(c<<5)-c+a.charCodeAt(f)|0;return(i+c>>>0)%it.length}function Rs(i){var a=Is(i.parent.id,i.name);if(it[a]===i)it[a]=i.cb;else for(a=it[a];a;){if(a.cb===i){a.cb=i.cb;break}a=a.cb}}function yt(i,a){var c=Te(i.mode)?(c=jt(i,"x"))?c:i.La.lookup?0:2:54;if(c)throw new D(c);for(c=it[Is(i.id,a)];c;c=c.cb){var f=c.name;if(c.parent.id===i.id&&f===a)return c}return i.La.lookup(i,a)}function si(i,a,c,f){return i=new ka(i,a,c,f),a=Is(i.parent.id,i.name),i.cb=it[a],it[a]=i}function Te(i){return(i&61440)===16384}function jt(i,a){return oi?0:a.includes("r")&&!(i.mode&292)||a.includes("w")&&!(i.mode&146)||a.includes("x")&&!(i.mode&73)?2:0}function ni(i,a){if(!Te(i.mode))return 54;try{return yt(i,a),20}catch{}return jt(i,"wx")}function ii(i,a,c){try{var f=yt(i,a)}catch(C){return C.Pa}if(i=jt(i,"wx"))return i;if(c){if(!Te(f.mode))return 54;if(f===f.parent||Os(f)==="/")return 10}else if(Te(f.mode))return 31;return 0}function To(i){if(!i)throw new D(63);return i}function we(i){if(i=$t[i],!i)throw new D(8);return i}function ri(i,a=-1){if(i=Object.assign(new Sa,i),a==-1)e:{for(a=0;4096>=a;a++)if(!$t[a])break e;throw new D(33)}return i.fd=a,$t[a]=i}function va(i,a=-1){return i=ri(i,a),i.Ma?.ec?.(i),i}function Us(i,a,c){var f=i?.Ma.Ua;i=f?i:a,f??=a.La.Ua,To(f),f(i,c)}var xa={open(i){i.Ma=ei[i.node.rdev].Ma,i.Ma.open?.(i)},Va(){throw new D(70)}};function Fs(i,a){ei[i]={Ma:a}}function ai(i,a){var c=a==="/";if(c&&Ds)throw new D(10);if(!c&&a){var f=Oe(a,{pb:!1});if(a=f.path,f=f.node,f.bb)throw new D(10);if(!Te(f.mode))throw new D(54)}a={type:i,kc:{},Db:a,Vb:[]},i=i.Xa(a),i.Xa=a,a.root=i,c?Ds=i:f&&(f.bb=a,f.Xa&&f.Xa.Vb.push(a))}function Mo(i,a,c){var f=Oe(i,{parent:!0}).node;if(i=ne(i),!i)throw new D(28);if(i==="."||i==="..")throw new D(20);var C=ni(f,i);if(C)throw new D(C);if(!f.La.ib)throw new D(63);return f.La.ib(f,i,a,c)}function Ta(i,a=438){return Mo(i,a&4095|32768,0)}function Ve(i,a=511){return Mo(i,a&1023|16384,0)}function Ao(i,a,c){typeof c>"u"&&(c=a,a=438),Mo(i,a|8192,c)}function $s(i,a){if(!Ps(i))throw new D(44);var c=Oe(a,{parent:!0}).node;if(!c)throw new D(44);a=ne(a);var f=ni(c,a);if(f)throw new D(f);if(!c.La.symlink)throw new D(63);c.La.symlink(c,a,i)}function li(i){var a=Oe(i,{parent:!0}).node;i=ne(i);var c=yt(a,i),f=ii(a,i,!0);if(f)throw new D(f);if(!a.La.rmdir)throw new D(63);if(c.bb)throw new D(10);a.La.rmdir(a,i),Rs(c)}function ci(i){var a=Oe(i,{parent:!0}).node;if(!a)throw new D(44);i=ne(i);var c=yt(a,i),f=ii(a,i,!1);if(f)throw new D(f);if(!a.La.unlink)throw new D(63);if(c.bb)throw new D(10);a.La.unlink(a,i),Rs(c)}function ro(i,a){return i=Oe(i,{ab:!a}).node,To(i.La.Ta)(i)}function ui(i,a,c,f){Us(i,a,{mode:c&4095|a.mode&-4096,ctime:Date.now(),Lb:f})}function Po(i,a){i=typeof i=="string"?Oe(i,{ab:!0}).node:i,ui(null,i,a)}function di(i,a,c){if(Te(a.mode))throw new D(31);if((a.mode&61440)!==32768)throw new D(28);var f=jt(a,"w");if(f)throw new D(f);Us(i,a,{size:c,timestamp:Date.now()})}function Nt(i,a,c=438){if(i==="")throw new D(44);if(typeof a=="string"){var f={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090}[a];if(typeof f>"u")throw Error(`Unknown file open mode: ${a}`);a=f}if(c=a&64?c&4095|32768:0,typeof i=="object")f=i;else{var C=i.endsWith("/"),x=Oe(i,{ab:!(a&131072),Wb:!0});f=x.node,i=x.path}if(x=!1,a&64)if(f){if(a&128)throw new D(20)}else{if(C)throw new D(31);f=Mo(i,c|511,0),x=!0}if(!f)throw new D(44);if((f.mode&61440)===8192&&(a&=-513),a&65536&&!Te(f.mode))throw new D(54);if(!x&&(f?(f.mode&61440)===40960?C=32:(C=["r","w","rw"][a&3],a&512&&(C+="w"),C=Te(f.mode)&&(C!=="r"||a&576)?31:jt(f,C)):C=44,C))throw new D(C);return a&512&&!x&&(C=f,C=typeof C=="string"?Oe(C,{ab:!0}).node:C,di(null,C,0)),a=ri({node:f,path:Os(f),flags:a&-131713,seekable:!0,position:0,Ma:f.Ma,Yb:[],error:!1}),a.Ma.open&&a.Ma.open(a),x&&Po(f,c&511),a}function js(i){if(i.fd===null)throw new D(8);i.rb&&(i.rb=null);try{i.Ma.close&&i.Ma.close(i)}catch(a){throw a}finally{$t[i.fd]=null}i.fd=null}function pi(i,a,c){if(i.fd===null)throw new D(8);if(!i.seekable||!i.Ma.Va)throw new D(70);if(c!=0&&c!=1&&c!=2)throw new D(28);i.position=i.Ma.Va(i,a,c),i.Yb=[]}function mi(i,a,c,f,C){if(0>f||0>C)throw new D(28);if(i.fd===null)throw new D(8);if((i.flags&2097155)===1)throw new D(8);if(Te(i.node.mode))throw new D(31);if(!i.Ma.read)throw new D(28);var x=typeof C<"u";if(!x)C=i.position;else if(!i.seekable)throw new D(70);return a=i.Ma.read(i,a,c,f,C),x||(i.position+=a),a}function hi(i,a,c,f,C){if(0>f||0>C)throw new D(28);if(i.fd===null)throw new D(8);if((i.flags&2097155)===0)throw new D(8);if(Te(i.node.mode))throw new D(31);if(!i.Ma.write)throw new D(28);i.seekable&&i.flags&1024&&pi(i,0,2);var x=typeof C<"u";if(!x)C=i.position;else if(!i.seekable)throw new D(70);return a=i.Ma.write(i,a,c,f,C,void 0),x||(i.position+=a),a}function Ma(i){var a=a||0,c="binary";c!=="utf8"&&c!=="binary"&&be(`Invalid encoding type "${c}"`),a=Nt(i,a),i=ro(i).size;var f=new Uint8Array(i);return mi(a,f,0,i,0),c==="utf8"&&(f=io(f)),js(a),f}function rt(i,a,c){i=We("/dev/"+i);var f=Zn(!!a,!!c);rt.Cb??(rt.Cb=64);var C=rt.Cb++<<8|0;Fs(C,{open(x){x.seekable=!1},close(){c?.buffer?.length&&c(10)},read(x,M,j,K){for(var L=0,Z=0;Z<K;Z++){try{var he=a()}catch{throw new D(29)}if(he===void 0&&L===0)throw new D(6);if(he==null)break;L++,M[j+Z]=he}return L&&(x.node.atime=Date.now()),L},write(x,M,j,K){for(var L=0;L<K;L++)try{c(M[j+L])}catch{throw new D(29)}return K&&(x.node.mtime=x.node.ctime=Date.now()),L}}),Ao(i,f,C)}var X={};function _t(i,a,c){if(a.charAt(0)==="/")return a;if(i=i===-100?"/":we(i).path,a.length==0){if(!c)throw new D(44);return i}return i+"/"+a}function Eo(i,a){H[i>>2]=a.dev,H[i+4>>2]=a.mode,H[i+8>>2]=a.nlink,H[i+12>>2]=a.uid,H[i+16>>2]=a.gid,H[i+20>>2]=a.rdev,ge[i+24>>3]=BigInt(a.size),V[i+32>>2]=4096,V[i+36>>2]=a.blocks;var c=a.atime.getTime(),f=a.mtime.getTime(),C=a.ctime.getTime();return ge[i+40>>3]=BigInt(Math.floor(c/1e3)),H[i+48>>2]=c%1e3*1e6,ge[i+56>>3]=BigInt(Math.floor(f/1e3)),H[i+64>>2]=f%1e3*1e6,ge[i+72>>3]=BigInt(Math.floor(C/1e3)),H[i+80>>2]=C%1e3*1e6,ge[i+88>>3]=BigInt(a.ino),0}var Do=void 0,Oo=()=>{var i=V[+Do>>2];return Do+=4,i},Ns=0,Aa=[0,31,60,91,121,152,182,213,244,274,305,335],Pa=[0,31,59,90,120,151,181,212,243,273,304,334],ao={},fi=i=>{P=i,no||0<Ns||(r.onExit?.(i),E=!0),m(i,new me(i))},Ea=i=>{if(!E)try{i()}catch(a){a instanceof me||a=="unwind"||m(1,a)}finally{if(!(no||0<Ns))try{P=i=P,fi(i)}catch(a){a instanceof me||a=="unwind"||m(1,a)}}},qs={},gi=()=>{if(!Ls){var i={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(globalThis.navigator?.language??"C").replace("-","_")+".UTF-8",_:h||"./this.program"},a;for(a in qs)qs[a]===void 0?delete i[a]:i[a]=qs[a];var c=[];for(a in i)c.push(`${a}=${i[a]}`);Ls=c}return Ls},Ls,Da=(i,a,c,f)=>{var C={string:L=>{var Z=0;if(L!=null&&L!==0){Z=Ft(L)+1;var he=Ct(Z);He(L,U,he,Z),Z=he}return Z},array:L=>{var Z=Ct(L.length);return O.set(L,Z),Z}};i=r["_"+i];var x=[],M=0;if(f)for(var j=0;j<f.length;j++){var K=C[c[j]];K?(M===0&&(M=Fo()),x[j]=K(f[j])):x[j]=f[j]}return c=i(...x),c=(function(L){return M!==0&&Uo(M),a==="string"?$(L):a==="boolean"?!!L:L})(c)},Io=i=>{var a=Ft(i)+1,c=Ro(a);return c&&He(i,U,c,a),c},bt,Bs=[],at=i=>{bt.delete(lt.get(i)),lt.set(i,null),Bs.push(i)},yi=i=>{let a=i.length;return[a%128|128,a>>7,...i]},Oa={i:127,p:127,j:126,f:125,d:124,e:111},_i=i=>yi(Array.from(i,a=>Oa[a])),lo=(i,a)=>{if(!bt){bt=new WeakMap;var c=lt.length;if(bt)for(var f=0;f<0+c;f++){var C=lt.get(f);C&&bt.set(C,f)}}if(c=bt.get(i)||0)return c;c=Bs.length?Bs.pop():lt.grow(1);try{lt.set(c,i)}catch(x){if(!(x instanceof TypeError))throw x;a=Uint8Array.of(0,97,115,109,1,0,0,0,1,...yi([1,96,..._i(a.slice(1)),..._i(a[0]==="v"?"":a[0])]),2,7,1,1,101,1,102,0,0,7,5,1,1,102,0,0),a=new WebAssembly.Module(a),a=new WebAssembly.Instance(a,{e:{f:i}}).exports.f,lt.set(c,a)}return bt.set(i,c),c};if(it=Array(4096),ai(q,"/"),Ve("/tmp"),Ve("/home"),Ve("/home/web_user"),(function(){Ve("/dev"),Fs(259,{read:()=>0,write:(f,C,x,M)=>M,Va:()=>0}),Ao("/dev/null",259),Xn(1280,ba),Xn(1536,Ca),Ao("/dev/tty",1280),Ao("/dev/tty1",1536);var i=new Uint8Array(1024),a=0,c=()=>(a===0&&(je(i),a=i.byteLength),i[--a]);rt("random",c),rt("urandom",c),Ve("/dev/shm"),Ve("/dev/shm/tmp")})(),(function(){Ve("/proc");var i=Ve("/proc/self");Ve("/proc/self/fd"),ai({Xa(){var a=si(i,"fd",16895,73);return a.Ma={Va:q.Ma.Va},a.La={lookup(c,f){c=+f;var C=we(c);return c={parent:null,Xa:{Db:"fake"},La:{readlink:()=>C.path},id:c+1},c.parent=c},readdir(){return Array.from($t.entries()).filter(([,c])=>c).map(([c])=>c.toString())}},a}},"/proc/self/fd")})(),r.noExitRuntime&&(no=r.noExitRuntime),r.print&&(y=r.print),r.printErr&&(S=r.printErr),r.wasmBinary&&(v=r.wasmBinary),r.thisProgram&&(h=r.thisProgram),r.preInit)for(typeof r.preInit=="function"&&(r.preInit=[r.preInit]);0<r.preInit.length;)r.preInit.shift()();r.stackSave=()=>Fo(),r.stackRestore=i=>Uo(i),r.stackAlloc=i=>Ct(i),r.cwrap=(i,a,c,f)=>{var C=!c||c.every(x=>x==="number"||x==="boolean");return a!=="string"&&C&&!f?r["_"+i]:(...x)=>Da(i,a,c,x)},r.addFunction=lo,r.removeFunction=at,r.UTF8ToString=$,r.stringToNewUTF8=Io,r.writeArrayToMemory=(i,a)=>{O.set(i,a)};var Ro,co,bi,Ci,Uo,Ct,Fo,$o,lt,Ia={a:(i,a,c,f)=>be(`Assertion failed: ${$(i)}, at: `+[a?$(a):"unknown filename",c,f?$(f):"unknown function"]),i:function(i,a){try{return i=$(i),Po(i,a),0}catch(c){if(typeof X>"u"||c.name!=="ErrnoError")throw c;return-c.Pa}},L:function(i,a,c){try{if(a=$(a),a=_t(i,a),c&-8)return-28;var f=Oe(a,{ab:!0}).node;return f?(i="",c&4&&(i+="r"),c&2&&(i+="w"),c&1&&(i+="x"),i&&jt(f,i)?-2:0):-44}catch(C){if(typeof X>"u"||C.name!=="ErrnoError")throw C;return-C.Pa}},j:function(i,a){try{var c=we(i);return ui(c,c.node,a,!1),0}catch(f){if(typeof X>"u"||f.name!=="ErrnoError")throw f;return-f.Pa}},h:function(i){try{var a=we(i);return Us(a,a.node,{timestamp:Date.now(),Lb:!1}),0}catch(c){if(typeof X>"u"||c.name!=="ErrnoError")throw c;return-c.Pa}},b:function(i,a,c){Do=c;try{var f=we(i);switch(a){case 0:var C=Oo();if(0>C)break;for(;$t[C];)C++;return va(f,C).fd;case 1:case 2:return 0;case 3:return f.flags;case 4:return C=Oo(),f.flags|=C,0;case 12:return C=Oo(),fe[C+0>>1]=2,0;case 13:case 14:return 0}return-28}catch(x){if(typeof X>"u"||x.name!=="ErrnoError")throw x;return-x.Pa}},g:function(i,a){try{var c=we(i),f=c.node,C=c.Ma.Ta;i=C?c:f,C??=f.La.Ta,To(C);var x=C(i);return Eo(a,x)}catch(M){if(typeof X>"u"||M.name!=="ErrnoError")throw M;return-M.Pa}},H:function(i,a){a=-9007199254740992>a||9007199254740992<a?NaN:Number(a);try{if(isNaN(a))return-61;var c=we(i);if(0>a||(c.flags&2097155)===0)throw new D(28);return di(c,c.node,a),0}catch(f){if(typeof X>"u"||f.name!=="ErrnoError")throw f;return-f.Pa}},G:function(i,a){try{if(a===0)return-28;var c=Ft("/")+1;return a<c?-68:(He("/",U,i,a),c)}catch(f){if(typeof X>"u"||f.name!=="ErrnoError")throw f;return-f.Pa}},K:function(i,a){try{return i=$(i),Eo(a,ro(i,!0))}catch(c){if(typeof X>"u"||c.name!=="ErrnoError")throw c;return-c.Pa}},C:function(i,a,c){try{return a=$(a),a=_t(i,a),Ve(a,c),0}catch(f){if(typeof X>"u"||f.name!=="ErrnoError")throw f;return-f.Pa}},J:function(i,a,c,f){try{a=$(a);var C=f&256;return a=_t(i,a,f&4096),Eo(c,C?ro(a,!0):ro(a))}catch(x){if(typeof X>"u"||x.name!=="ErrnoError")throw x;return-x.Pa}},x:function(i,a,c,f){Do=f;try{a=$(a),a=_t(i,a);var C=f?Oo():0;return Nt(a,c,C).fd}catch(x){if(typeof X>"u"||x.name!=="ErrnoError")throw x;return-x.Pa}},v:function(i,a,c,f){try{if(a=$(a),a=_t(i,a),0>=f)return-28;var C=Oe(a).node;if(!C)throw new D(44);if(!C.La.readlink)throw new D(28);var x=C.La.readlink(C),M=Math.min(f,Ft(x)),j=O[c+M];return He(x,U,c,f+1),O[c+M]=j,M}catch(K){if(typeof X>"u"||K.name!=="ErrnoError")throw K;return-K.Pa}},u:function(i){try{return i=$(i),li(i),0}catch(a){if(typeof X>"u"||a.name!=="ErrnoError")throw a;return-a.Pa}},f:function(i,a){try{return i=$(i),Eo(a,ro(i))}catch(c){if(typeof X>"u"||c.name!=="ErrnoError")throw c;return-c.Pa}},r:function(i,a,c){try{if(a=$(a),a=_t(i,a),c)if(c===512)li(a);else return-28;else ci(a);return 0}catch(f){if(typeof X>"u"||f.name!=="ErrnoError")throw f;return-f.Pa}},q:function(i,a,c){try{a=$(a),a=_t(i,a,!0);var f=Date.now(),C,x;if(c){var M=H[c>>2]+4294967296*V[c+4>>2],j=V[c+8>>2];j==1073741823?C=f:j==1073741822?C=null:C=1e3*M+j/1e6,c+=16,M=H[c>>2]+4294967296*V[c+4>>2],j=V[c+8>>2],j==1073741823?x=f:j==1073741822?x=null:x=1e3*M+j/1e6}else x=C=f;if((x??C)!==null){i=C;var K=Oe(a,{ab:!0}).node;To(K.La.Ua)(K,{atime:i,mtime:x})}return 0}catch(L){if(typeof X>"u"||L.name!=="ErrnoError")throw L;return-L.Pa}},m:()=>be(""),l:()=>{no=!1,Ns=0},A:function(i,a){i=-9007199254740992>i||9007199254740992<i?NaN:Number(i),i=new Date(1e3*i),V[a>>2]=i.getSeconds(),V[a+4>>2]=i.getMinutes(),V[a+8>>2]=i.getHours(),V[a+12>>2]=i.getDate(),V[a+16>>2]=i.getMonth(),V[a+20>>2]=i.getFullYear()-1900,V[a+24>>2]=i.getDay();var c=i.getFullYear();V[a+28>>2]=(c%4!==0||c%100===0&&c%400!==0?Pa:Aa)[i.getMonth()]+i.getDate()-1|0,V[a+36>>2]=-(60*i.getTimezoneOffset()),c=new Date(i.getFullYear(),6,1).getTimezoneOffset();var f=new Date(i.getFullYear(),0,1).getTimezoneOffset();V[a+32>>2]=(c!=f&&i.getTimezoneOffset()==Math.min(f,c))|0},y:function(i,a,c,f,C,x,M){C=-9007199254740992>C||9007199254740992<C?NaN:Number(C);try{var j=we(f);if((a&2)!==0&&(c&2)===0&&(j.flags&2097155)!==2)throw new D(2);if((j.flags&2097155)===1)throw new D(2);if(!j.Ma.jb)throw new D(43);if(!i)throw new D(28);var K=j.Ma.jb(j,i,C,a,c),L=K.Xb;return V[x>>2]=K.Eb,H[M>>2]=L,0}catch(Z){if(typeof X>"u"||Z.name!=="ErrnoError")throw Z;return-Z.Pa}},z:function(i,a,c,f,C,x){x=-9007199254740992>x||9007199254740992<x?NaN:Number(x);try{var M=we(C);if(c&2){if(c=x,(M.node.mode&61440)!==32768)throw new D(43);if(!(f&2)){var j=U.slice(i,i+a);M.Ma.kb&&M.Ma.kb(M,j,c,a,f)}}}catch(K){if(typeof X>"u"||K.name!=="ErrnoError")throw K;return-K.Pa}},n:(i,a)=>{if(ao[i]&&(clearTimeout(ao[i].id),delete ao[i]),!a)return 0;var c=setTimeout(()=>{delete ao[i],Ea(()=>Ci(i,performance.now()))},a);return ao[i]={id:c,lc:a},0},B:(i,a,c,f)=>{var C=new Date().getFullYear(),x=new Date(C,0,1).getTimezoneOffset();C=new Date(C,6,1).getTimezoneOffset(),H[i>>2]=60*Math.max(x,C),V[a>>2]=+(x!=C),a=M=>{var j=Math.abs(M);return`UTC${0<=M?"-":"+"}${String(Math.floor(j/60)).padStart(2,"0")}${String(j%60).padStart(2,"0")}`},i=a(x),a=a(C),C<x?(He(i,U,c,17),He(a,U,f,17)):(He(i,U,f,17),He(a,U,c,17))},d:()=>Date.now(),s:()=>2147483648,c:()=>performance.now(),o:i=>{var a=U.length;if(i>>>=0,2147483648<i)return!1;for(var c=1;4>=c;c*=2){var f=a*(1+.2/c);f=Math.min(f,i+100663296);e:{f=(Math.min(2147483648,65536*Math.ceil(Math.max(i,f)/65536))-$o.buffer.byteLength+65535)/65536|0;try{$o.grow(f),Pe();var C=1;break e}catch{}C=void 0}if(C)return!0}return!1},E:(i,a)=>{var c=0,f=0,C;for(C of gi()){var x=a+c;H[i+f>>2]=x,c+=He(C,U,x,1/0)+1,f+=4}return 0},F:(i,a)=>{var c=gi();H[i>>2]=c.length,i=0;for(var f of c)i+=Ft(f)+1;return H[a>>2]=i,0},e:function(i){try{var a=we(i);return js(a),0}catch(c){if(typeof X>"u"||c.name!=="ErrnoError")throw c;return c.Pa}},p:function(i,a){try{var c=we(i);return O[a]=c.tty?2:Te(c.mode)?3:(c.mode&61440)===40960?7:4,fe[a+2>>1]=0,ge[a+8>>3]=BigInt(0),ge[a+16>>3]=BigInt(0),0}catch(f){if(typeof X>"u"||f.name!=="ErrnoError")throw f;return f.Pa}},w:function(i,a,c,f){try{e:{var C=we(i);i=a;for(var x,M=a=0;M<c;M++){var j=H[i>>2],K=H[i+4>>2];i+=8;var L=mi(C,O,j,K,x);if(0>L){var Z=-1;break e}if(a+=L,L<K)break;typeof x<"u"&&(x+=L)}Z=a}return H[f>>2]=Z,0}catch(he){if(typeof X>"u"||he.name!=="ErrnoError")throw he;return he.Pa}},D:function(i,a,c,f){a=-9007199254740992>a||9007199254740992<a?NaN:Number(a);try{if(isNaN(a))return 61;var C=we(i);return pi(C,a,c),ge[f>>3]=BigInt(C.position),C.rb&&a===0&&c===0&&(C.rb=null),0}catch(x){if(typeof X>"u"||x.name!=="ErrnoError")throw x;return x.Pa}},I:function(i){try{var a=we(i);return a.Ma?.fsync?.(a)}catch(c){if(typeof X>"u"||c.name!=="ErrnoError")throw c;return c.Pa}},t:function(i,a,c,f){try{e:{var C=we(i);i=a;for(var x,M=a=0;M<c;M++){var j=H[i>>2],K=H[i+4>>2];i+=8;var L=hi(C,O,j,K,x);if(0>L){var Z=-1;break e}if(a+=L,L<K)break;typeof x<"u"&&(x+=L)}Z=a}return H[f>>2]=Z,0}catch(he){if(typeof X>"u"||he.name!=="ErrnoError")throw he;return he.Pa}},k:fi};function Gs(){function i(){if(r.calledRun=!0,!E){if(!r.noFSInit&&!ti){var a,c;ti=!0,a??=r.stdin,c??=r.stdout,f??=r.stderr,a?rt("stdin",a):$s("/dev/tty","/dev/stdin"),c?rt("stdout",null,c):$s("/dev/tty","/dev/stdout"),f?rt("stderr",null,f):$s("/dev/tty1","/dev/stderr"),Nt("/dev/stdin",0),Nt("/dev/stdout",1),Nt("/dev/stderr",1)}if(zs.N(),oi=!1,r.onRuntimeInitialized?.(),r.postRun)for(typeof r.postRun=="function"&&(r.postRun=[r.postRun]);r.postRun.length;){var f=r.postRun.shift();so.push(f)}Ce(so)}}if(0<ve)ce=Gs;else{if(r.preRun)for(typeof r.preRun=="function"&&(r.preRun=[r.preRun]);r.preRun.length;)Ke();Ce(gt),0<ve?ce=Gs:r.setStatus?(r.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>r.setStatus(""),1),i()},1)):i()}}var zs;return(async function(){function i(c){return c=zs=c.exports,r._sqlite3_free=c.P,r._sqlite3_value_text=c.Q,r._sqlite3_prepare_v2=c.R,r._sqlite3_step=c.S,r._sqlite3_reset=c.T,r._sqlite3_exec=c.U,r._sqlite3_finalize=c.V,r._sqlite3_column_name=c.W,r._sqlite3_column_text=c.X,r._sqlite3_column_type=c.Y,r._sqlite3_errmsg=c.Z,r._sqlite3_clear_bindings=c._,r._sqlite3_value_blob=c.$,r._sqlite3_value_bytes=c.aa,r._sqlite3_value_double=c.ba,r._sqlite3_value_int=c.ca,r._sqlite3_value_type=c.da,r._sqlite3_result_blob=c.ea,r._sqlite3_result_double=c.fa,r._sqlite3_result_error=c.ga,r._sqlite3_result_int=c.ha,r._sqlite3_result_int64=c.ia,r._sqlite3_result_null=c.ja,r._sqlite3_result_text=c.ka,r._sqlite3_aggregate_context=c.la,r._sqlite3_column_count=c.ma,r._sqlite3_data_count=c.na,r._sqlite3_column_blob=c.oa,r._sqlite3_column_bytes=c.pa,r._sqlite3_column_double=c.qa,r._sqlite3_bind_blob=c.ra,r._sqlite3_bind_double=c.sa,r._sqlite3_bind_int=c.ta,r._sqlite3_bind_text=c.ua,r._sqlite3_bind_parameter_index=c.va,r._sqlite3_sql=c.wa,r._sqlite3_normalized_sql=c.xa,r._sqlite3_changes=c.ya,r._sqlite3_close_v2=c.za,r._sqlite3_create_function_v2=c.Aa,r._sqlite3_update_hook=c.Ba,r._sqlite3_open=c.Ca,Ro=r._malloc=c.Da,co=r._free=c.Ea,r._RegisterExtensionFunctions=c.Fa,bi=c.Ga,Ci=c.Ha,Uo=c.Ia,Ct=c.Ja,Fo=c.Ka,$o=c.M,lt=c.O,Pe(),ve--,r.monitorRunDependencies?.(ve),ve==0&&ce&&(c=ce,ce=null,c()),zs}ve++,r.monitorRunDependencies?.(ve);var a={a:Ia};return r.instantiateWasm?new Promise(c=>{r.instantiateWasm(a,(f,C)=>{c(i(f,C))})}):(Ge??=r.locateFile?r.locateFile("sql-wasm.wasm",g):g+"sql-wasm.wasm",i((await oo(a)).instance))})(),Gs(),o}),Ho)};typeof Jo=="object"&&typeof St=="object"?(St.exports=Vo,St.exports.default=Vo):typeof define=="function"&&define.amd?define([],function(){return Vo}):typeof Jo=="object"&&(Jo.Module=Vo)});var Zo=ee(Xe=>{"use strict";Object.defineProperty(Xe,"__esModule",{value:!0});Xe.utf8Count=Bl;Xe.utf8EncodeJs=ir;Xe.utf8EncodeTE=rr;Xe.utf8Encode=Wl;Xe.utf8DecodeJs=ar;Xe.utf8DecodeTD=lr;Xe.utf8Decode=Kl;function Bl(n){let e=n.length,t=0,o=0;for(;o<e;){let s=n.charCodeAt(o++);if((s&4294967168)===0){t++;continue}else if((s&4294965248)===0)t+=2;else{if(s>=55296&&s<=56319&&o<e){let r=n.charCodeAt(o);(r&64512)===56320&&(++o,s=((s&1023)<<10)+(r&1023)+65536)}(s&4294901760)===0?t+=3:t+=4}}return t}function ir(n,e,t){let o=n.length,s=t,r=0;for(;r<o;){let l=n.charCodeAt(r++);if((l&4294967168)===0){e[s++]=l;continue}else if((l&4294965248)===0)e[s++]=l>>6&31|192;else{if(l>=55296&&l<=56319&&r<o){let u=n.charCodeAt(r);(u&64512)===56320&&(++r,l=((l&1023)<<10)+(u&1023)+65536)}(l&4294901760)===0?(e[s++]=l>>12&15|224,e[s++]=l>>6&63|128):(e[s++]=l>>18&7|240,e[s++]=l>>12&63|128,e[s++]=l>>6&63|128)}e[s++]=l&63|128}}var Gl=new TextEncoder,zl=50;function rr(n,e,t){Gl.encodeInto(n,e.subarray(t))}function Wl(n,e,t){n.length>zl?rr(n,e,t):ir(n,e,t)}var Hl=4096;function ar(n,e,t){let o=e,s=o+t,r=[],l="";for(;o<s;){let u=n[o++];if((u&128)===0)r.push(u);else if((u&224)===192){let d=n[o++]&63;r.push((u&31)<<6|d)}else if((u&240)===224){let d=n[o++]&63,h=n[o++]&63;r.push((u&31)<<12|d<<6|h)}else if((u&248)===240){let d=n[o++]&63,h=n[o++]&63,m=n[o++]&63,p=(u&7)<<18|d<<12|h<<6|m;p>65535&&(p-=65536,r.push(p>>>10&1023|55296),p=56320|p&1023),r.push(p)}else r.push(u);r.length>=Hl&&(l+=String.fromCharCode(...r),r.length=0)}return r.length>0&&(l+=String.fromCharCode(...r)),l}var Vl=new TextDecoder,Jl=200;function lr(n,e,t){let o=n.subarray(e,e+t);return Vl.decode(o)}function Kl(n,e,t){return t>Jl?lr(n,e,t):ar(n,e,t)}});var _n=ee(es=>{"use strict";Object.defineProperty(es,"__esModule",{value:!0});es.ExtData=void 0;var yn=class{type;data;constructor(e,t){this.type=e,this.data=t}};es.ExtData=yn});var os=ee(ts=>{"use strict";Object.defineProperty(ts,"__esModule",{value:!0});ts.DecodeError=void 0;var bn=class n extends Error{constructor(e){super(e);let t=Object.create(n.prototype);Object.setPrototypeOf(this,t),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:n.name})}};ts.DecodeError=bn});var ss=ee(ut=>{"use strict";Object.defineProperty(ut,"__esModule",{value:!0});ut.UINT32_MAX=void 0;ut.setUint64=Yl;ut.setInt64=Ql;ut.getInt64=Xl;ut.getUint64=Zl;ut.UINT32_MAX=4294967295;function Yl(n,e,t){let o=t/4294967296,s=t;n.setUint32(e,o),n.setUint32(e+4,s)}function Ql(n,e,t){let o=Math.floor(t/4294967296),s=t;n.setUint32(e,o),n.setUint32(e+4,s)}function Xl(n,e){let t=n.getInt32(e),o=n.getUint32(e+4);return t*4294967296+o}function Zl(n,e){let t=n.getUint32(e),o=n.getUint32(e+4);return t*4294967296+o}});var Cn=ee(Fe=>{"use strict";Object.defineProperty(Fe,"__esModule",{value:!0});Fe.timestampExtension=Fe.EXT_TIMESTAMP=void 0;Fe.encodeTimeSpecToTimestamp=ur;Fe.encodeDateToTimeSpec=dr;Fe.encodeTimestampExtension=pr;Fe.decodeTimestampToTimeSpec=mr;Fe.decodeTimestampExtension=hr;var ec=os(),cr=ss();Fe.EXT_TIMESTAMP=-1;var tc=4294967296-1,oc=17179869184-1;function ur({sec:n,nsec:e}){if(n>=0&&e>=0&&n<=oc)if(e===0&&n<=tc){let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,n),t}else{let t=n/4294967296,o=n&4294967295,s=new Uint8Array(8),r=new DataView(s.buffer);return r.setUint32(0,e<<2|t&3),r.setUint32(4,o),s}else{let t=new Uint8Array(12),o=new DataView(t.buffer);return o.setUint32(0,e),(0,cr.setInt64)(o,4,n),t}}function dr(n){let e=n.getTime(),t=Math.floor(e/1e3),o=(e-t*1e3)*1e6,s=Math.floor(o/1e9);return{sec:t+s,nsec:o-s*1e9}}function pr(n){if(n instanceof Date){let e=dr(n);return ur(e)}else return null}function mr(n){let e=new DataView(n.buffer,n.byteOffset,n.byteLength);switch(n.byteLength){case 4:return{sec:e.getUint32(0),nsec:0};case 8:{let t=e.getUint32(0),o=e.getUint32(4),s=(t&3)*4294967296+o,r=t>>>2;return{sec:s,nsec:r}}case 12:{let t=(0,cr.getInt64)(e,4),o=e.getUint32(0);return{sec:t,nsec:o}}default:throw new ec.DecodeError(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${n.length}`)}}function hr(n){let e=mr(n);return new Date(e.sec*1e3+e.nsec/1e6)}Fe.timestampExtension={type:Fe.EXT_TIMESTAMP,encode:pr,decode:hr}});var rs=ee(is=>{"use strict";Object.defineProperty(is,"__esModule",{value:!0});is.ExtensionCodec=void 0;var ns=_n(),sc=Cn(),wn=class n{static defaultCodec=new n;__brand;builtInEncoders=[];builtInDecoders=[];encoders=[];decoders=[];constructor(){this.register(sc.timestampExtension)}register({type:e,encode:t,decode:o}){if(e>=0)this.encoders[e]=t,this.decoders[e]=o;else{let s=-1-e;this.builtInEncoders[s]=t,this.builtInDecoders[s]=o}}tryToEncode(e,t){for(let o=0;o<this.builtInEncoders.length;o++){let s=this.builtInEncoders[o];if(s!=null){let r=s(e,t);if(r!=null){let l=-1-o;return new ns.ExtData(l,r)}}}for(let o=0;o<this.encoders.length;o++){let s=this.encoders[o];if(s!=null){let r=s(e,t);if(r!=null){let l=o;return new ns.ExtData(l,r)}}}return e instanceof ns.ExtData?e:null}decode(e,t,o){let s=t<0?this.builtInDecoders[-1-t]:this.decoders[t];return s?s(e,t,o):new ns.ExtData(t,e)}};is.ExtensionCodec=wn});var kn=ee(Sn=>{"use strict";Object.defineProperty(Sn,"__esModule",{value:!0});Sn.ensureUint8Array=ic;function nc(n){return n instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&n instanceof SharedArrayBuffer}function ic(n){return n instanceof Uint8Array?n:ArrayBuffer.isView(n)?new Uint8Array(n.buffer,n.byteOffset,n.byteLength):nc(n)?new Uint8Array(n):Uint8Array.from(n)}});var xn=ee(Je=>{"use strict";Object.defineProperty(Je,"__esModule",{value:!0});Je.Encoder=Je.DEFAULT_INITIAL_BUFFER_SIZE=Je.DEFAULT_MAX_DEPTH=void 0;var fr=Zo(),rc=rs(),gr=ss(),ac=kn();Je.DEFAULT_MAX_DEPTH=100;Je.DEFAULT_INITIAL_BUFFER_SIZE=2048;var vn=class n{extensionCodec;context;useBigInt64;maxDepth;initialBufferSize;sortKeys;forceFloat32;ignoreUndefined;forceIntegerToFloat;pos;view;bytes;entered=!1;constructor(e){this.extensionCodec=e?.extensionCodec??rc.ExtensionCodec.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.maxDepth=e?.maxDepth??Je.DEFAULT_MAX_DEPTH,this.initialBufferSize=e?.initialBufferSize??Je.DEFAULT_INITIAL_BUFFER_SIZE,this.sortKeys=e?.sortKeys??!1,this.forceFloat32=e?.forceFloat32??!1,this.ignoreUndefined=e?.ignoreUndefined??!1,this.forceIntegerToFloat=e?.forceIntegerToFloat??!1,this.pos=0,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}clone(){return new n({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,maxDepth:this.maxDepth,initialBufferSize:this.initialBufferSize,sortKeys:this.sortKeys,forceFloat32:this.forceFloat32,ignoreUndefined:this.ignoreUndefined,forceIntegerToFloat:this.forceIntegerToFloat})}reinitializeState(){this.pos=0}encodeSharedRef(e){if(this.entered)return this.clone().encodeSharedRef(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.subarray(0,this.pos)}finally{this.entered=!1}}encode(e){if(this.entered)return this.clone().encode(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.slice(0,this.pos)}finally{this.entered=!1}}doEncode(e,t){if(t>this.maxDepth)throw new Error(`Too deep objects in depth ${t}`);e==null?this.encodeNil():typeof e=="boolean"?this.encodeBoolean(e):typeof e=="number"?this.forceIntegerToFloat?this.encodeNumberAsFloat(e):this.encodeNumber(e):typeof e=="string"?this.encodeString(e):this.useBigInt64&&typeof e=="bigint"?this.encodeBigInt64(e):this.encodeObject(e,t)}ensureBufferSizeToWrite(e){let t=this.pos+e;this.view.byteLength<t&&this.resizeBuffer(t*2)}resizeBuffer(e){let t=new ArrayBuffer(e),o=new Uint8Array(t),s=new DataView(t);o.set(this.bytes),this.view=s,this.bytes=o}encodeNil(){this.writeU8(192)}encodeBoolean(e){e===!1?this.writeU8(194):this.writeU8(195)}encodeNumber(e){!this.forceIntegerToFloat&&Number.isSafeInteger(e)?e>=0?e<128?this.writeU8(e):e<256?(this.writeU8(204),this.writeU8(e)):e<65536?(this.writeU8(205),this.writeU16(e)):e<4294967296?(this.writeU8(206),this.writeU32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(207),this.writeU64(e)):e>=-32?this.writeU8(224|e+32):e>=-128?(this.writeU8(208),this.writeI8(e)):e>=-32768?(this.writeU8(209),this.writeI16(e)):e>=-2147483648?(this.writeU8(210),this.writeI32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(211),this.writeI64(e)):this.encodeNumberAsFloat(e)}encodeNumberAsFloat(e){this.forceFloat32?(this.writeU8(202),this.writeF32(e)):(this.writeU8(203),this.writeF64(e))}encodeBigInt64(e){e>=BigInt(0)?(this.writeU8(207),this.writeBigUint64(e)):(this.writeU8(211),this.writeBigInt64(e))}writeStringHeader(e){if(e<32)this.writeU8(160+e);else if(e<256)this.writeU8(217),this.writeU8(e);else if(e<65536)this.writeU8(218),this.writeU16(e);else if(e<4294967296)this.writeU8(219),this.writeU32(e);else throw new Error(`Too long string: ${e} bytes in UTF-8`)}encodeString(e){let o=(0,fr.utf8Count)(e);this.ensureBufferSizeToWrite(5+o),this.writeStringHeader(o),(0,fr.utf8Encode)(e,this.bytes,this.pos),this.pos+=o}encodeObject(e,t){let o=this.extensionCodec.tryToEncode(e,this.context);if(o!=null)this.encodeExtension(o);else if(Array.isArray(e))this.encodeArray(e,t);else if(ArrayBuffer.isView(e))this.encodeBinary(e);else if(typeof e=="object")this.encodeMap(e,t);else throw new Error(`Unrecognized object: ${Object.prototype.toString.apply(e)}`)}encodeBinary(e){let t=e.byteLength;if(t<256)this.writeU8(196),this.writeU8(t);else if(t<65536)this.writeU8(197),this.writeU16(t);else if(t<4294967296)this.writeU8(198),this.writeU32(t);else throw new Error(`Too large binary: ${t}`);let o=(0,ac.ensureUint8Array)(e);this.writeU8a(o)}encodeArray(e,t){let o=e.length;if(o<16)this.writeU8(144+o);else if(o<65536)this.writeU8(220),this.writeU16(o);else if(o<4294967296)this.writeU8(221),this.writeU32(o);else throw new Error(`Too large array: ${o}`);for(let s of e)this.doEncode(s,t+1)}countWithoutUndefined(e,t){let o=0;for(let s of t)e[s]!==void 0&&o++;return o}encodeMap(e,t){let o=Object.keys(e);this.sortKeys&&o.sort();let s=this.ignoreUndefined?this.countWithoutUndefined(e,o):o.length;if(s<16)this.writeU8(128+s);else if(s<65536)this.writeU8(222),this.writeU16(s);else if(s<4294967296)this.writeU8(223),this.writeU32(s);else throw new Error(`Too large map object: ${s}`);for(let r of o){let l=e[r];this.ignoreUndefined&&l===void 0||(this.encodeString(r),this.doEncode(l,t+1))}}encodeExtension(e){if(typeof e.data=="function"){let o=e.data(this.pos+6),s=o.length;if(s>=4294967296)throw new Error(`Too large extension object: ${s}`);this.writeU8(201),this.writeU32(s),this.writeI8(e.type),this.writeU8a(o);return}let t=e.data.length;if(t===1)this.writeU8(212);else if(t===2)this.writeU8(213);else if(t===4)this.writeU8(214);else if(t===8)this.writeU8(215);else if(t===16)this.writeU8(216);else if(t<256)this.writeU8(199),this.writeU8(t);else if(t<65536)this.writeU8(200),this.writeU16(t);else if(t<4294967296)this.writeU8(201),this.writeU32(t);else throw new Error(`Too large extension object: ${t}`);this.writeI8(e.type),this.writeU8a(e.data)}writeU8(e){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,e),this.pos++}writeU8a(e){let t=e.length;this.ensureBufferSizeToWrite(t),this.bytes.set(e,this.pos),this.pos+=t}writeI8(e){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,e),this.pos++}writeU16(e){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,e),this.pos+=2}writeI16(e){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,e),this.pos+=2}writeU32(e){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,e),this.pos+=4}writeI32(e){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,e),this.pos+=4}writeF32(e){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,e),this.pos+=4}writeF64(e){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,e),this.pos+=8}writeU64(e){this.ensureBufferSizeToWrite(8),(0,gr.setUint64)(this.view,this.pos,e),this.pos+=8}writeI64(e){this.ensureBufferSizeToWrite(8),(0,gr.setInt64)(this.view,this.pos,e),this.pos+=8}writeBigUint64(e){this.ensureBufferSizeToWrite(8),this.view.setBigUint64(this.pos,e),this.pos+=8}writeBigInt64(e){this.ensureBufferSizeToWrite(8),this.view.setBigInt64(this.pos,e),this.pos+=8}};Je.Encoder=vn});var yr=ee(Tn=>{"use strict";Object.defineProperty(Tn,"__esModule",{value:!0});Tn.encode=cc;var lc=xn();function cc(n,e){return new lc.Encoder(e).encodeSharedRef(n)}});var _r=ee(Mn=>{"use strict";Object.defineProperty(Mn,"__esModule",{value:!0});Mn.prettyByte=uc;function uc(n){return`${n<0?"-":""}0x${Math.abs(n).toString(16).padStart(2,"0")}`}});var br=ee(as=>{"use strict";Object.defineProperty(as,"__esModule",{value:!0});as.CachedKeyDecoder=void 0;var dc=Zo(),pc=16,mc=16,An=class{hit=0;miss=0;caches;maxKeyLength;maxLengthPerKey;constructor(e=pc,t=mc){this.maxKeyLength=e,this.maxLengthPerKey=t,this.caches=[];for(let o=0;o<this.maxKeyLength;o++)this.caches.push([])}canBeCached(e){return e>0&&e<=this.maxKeyLength}find(e,t,o){let s=this.caches[o-1];e:for(let r of s){let l=r.bytes;for(let u=0;u<o;u++)if(l[u]!==e[t+u])continue e;return r.str}return null}store(e,t){let o=this.caches[e.length-1],s={bytes:e,str:t};o.length>=this.maxLengthPerKey?o[Math.random()*o.length|0]=s:o.push(s)}decode(e,t,o){let s=this.find(e,t,o);if(s!=null)return this.hit++,s;this.miss++;let r=(0,dc.utf8DecodeJs)(e,t,o),l=Uint8Array.prototype.slice.call(e,t,t+o);return this.store(l,r),r}};as.CachedKeyDecoder=An});var cs=ee(ls=>{"use strict";Object.defineProperty(ls,"__esModule",{value:!0});ls.Decoder=void 0;var Pn=_r(),hc=rs(),Tt=ss(),fc=Zo(),Cr=kn(),gc=br(),Ze=os(),En="array",go="map_key",Sr="map_value",yc=n=>{if(typeof n=="string"||typeof n=="number")return n;throw new Ze.DecodeError("The type of key must be string or number but "+typeof n)},Dn=class{stack=[];stackHeadPosition=-1;get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState(e){let t=this.getUninitializedStateFromPool();t.type=En,t.position=0,t.size=e,t.array=new Array(e)}pushMapState(e){let t=this.getUninitializedStateFromPool();t.type=go,t.readCount=0,t.size=e,t.map={}}getUninitializedStateFromPool(){if(this.stackHeadPosition++,this.stackHeadPosition===this.stack.length){let e={type:void 0,size:0,array:void 0,position:0,readCount:0,map:void 0,key:null};this.stack.push(e)}return this.stack[this.stackHeadPosition]}release(e){if(this.stack[this.stackHeadPosition]!==e)throw new Error("Invalid stack state. Released state is not on top of the stack.");if(e.type===En){let o=e;o.size=0,o.array=void 0,o.position=0,o.type=void 0}if(e.type===go||e.type===Sr){let o=e;o.size=0,o.map=void 0,o.readCount=0,o.type=void 0}this.stackHeadPosition--}reset(){this.stack.length=0,this.stackHeadPosition=-1}},fo=-1,In=new DataView(new ArrayBuffer(0)),_c=new Uint8Array(In.buffer);try{In.getInt8(0)}catch(n){if(!(n instanceof RangeError))throw new Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access")}var wr=new RangeError("Insufficient data"),bc=new gc.CachedKeyDecoder,On=class n{extensionCodec;context;useBigInt64;rawStrings;maxStrLength;maxBinLength;maxArrayLength;maxMapLength;maxExtLength;keyDecoder;mapKeyConverter;totalPos=0;pos=0;view=In;bytes=_c;headByte=fo;stack=new Dn;entered=!1;constructor(e){this.extensionCodec=e?.extensionCodec??hc.ExtensionCodec.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.rawStrings=e?.rawStrings??!1,this.maxStrLength=e?.maxStrLength??Tt.UINT32_MAX,this.maxBinLength=e?.maxBinLength??Tt.UINT32_MAX,this.maxArrayLength=e?.maxArrayLength??Tt.UINT32_MAX,this.maxMapLength=e?.maxMapLength??Tt.UINT32_MAX,this.maxExtLength=e?.maxExtLength??Tt.UINT32_MAX,this.keyDecoder=e?.keyDecoder!==void 0?e.keyDecoder:bc,this.mapKeyConverter=e?.mapKeyConverter??yc}clone(){return new n({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,rawStrings:this.rawStrings,maxStrLength:this.maxStrLength,maxBinLength:this.maxBinLength,maxArrayLength:this.maxArrayLength,maxMapLength:this.maxMapLength,maxExtLength:this.maxExtLength,keyDecoder:this.keyDecoder})}reinitializeState(){this.totalPos=0,this.headByte=fo,this.stack.reset()}setBuffer(e){let t=(0,Cr.ensureUint8Array)(e);this.bytes=t,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength),this.pos=0}appendBuffer(e){if(this.headByte===fo&&!this.hasRemaining(1))this.setBuffer(e);else{let t=this.bytes.subarray(this.pos),o=(0,Cr.ensureUint8Array)(e),s=new Uint8Array(t.length+o.length);s.set(t),s.set(o,t.length),this.setBuffer(s)}}hasRemaining(e){return this.view.byteLength-this.pos>=e}createExtraByteError(e){let{view:t,pos:o}=this;return new RangeError(`Extra ${t.byteLength-o} of ${t.byteLength} byte(s) found at buffer[${e}]`)}decode(e){if(this.entered)return this.clone().decode(e);try{this.entered=!0,this.reinitializeState(),this.setBuffer(e);let t=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return t}finally{this.entered=!1}}*decodeMulti(e){if(this.entered){yield*this.clone().decodeMulti(e);return}try{for(this.entered=!0,this.reinitializeState(),this.setBuffer(e);this.hasRemaining(1);)yield this.doDecodeSync()}finally{this.entered=!1}}async decodeAsync(e){if(this.entered)return this.clone().decodeAsync(e);try{this.entered=!0;let t=!1,o;for await(let u of e){if(t)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(u);try{o=this.doDecodeSync(),t=!0}catch(d){if(!(d instanceof RangeError))throw d}this.totalPos+=this.pos}if(t){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return o}let{headByte:s,pos:r,totalPos:l}=this;throw new RangeError(`Insufficient data in parsing ${(0,Pn.prettyByte)(s)} at ${l} (${r} in the current buffer)`)}finally{this.entered=!1}}decodeArrayStream(e){return this.decodeMultiAsync(e,!0)}decodeStream(e){return this.decodeMultiAsync(e,!1)}async*decodeMultiAsync(e,t){if(this.entered){yield*this.clone().decodeMultiAsync(e,t);return}try{this.entered=!0;let o=t,s=-1;for await(let r of e){if(t&&s===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(r),o&&(s=this.readArraySize(),o=!1,this.complete());try{for(;yield this.doDecodeSync(),--s!==0;);}catch(l){if(!(l instanceof RangeError))throw l}this.totalPos+=this.pos}}finally{this.entered=!1}}doDecodeSync(){e:for(;;){let e=this.readHeadByte(),t;if(e>=224)t=e-256;else if(e<192)if(e<128)t=e;else if(e<144){let s=e-128;if(s!==0){this.pushMapState(s),this.complete();continue e}else t={}}else if(e<160){let s=e-144;if(s!==0){this.pushArrayState(s),this.complete();continue e}else t=[]}else{let s=e-160;t=this.decodeString(s,0)}else if(e===192)t=null;else if(e===194)t=!1;else if(e===195)t=!0;else if(e===202)t=this.readF32();else if(e===203)t=this.readF64();else if(e===204)t=this.readU8();else if(e===205)t=this.readU16();else if(e===206)t=this.readU32();else if(e===207)this.useBigInt64?t=this.readU64AsBigInt():t=this.readU64();else if(e===208)t=this.readI8();else if(e===209)t=this.readI16();else if(e===210)t=this.readI32();else if(e===211)this.useBigInt64?t=this.readI64AsBigInt():t=this.readI64();else if(e===217){let s=this.lookU8();t=this.decodeString(s,1)}else if(e===218){let s=this.lookU16();t=this.decodeString(s,2)}else if(e===219){let s=this.lookU32();t=this.decodeString(s,4)}else if(e===220){let s=this.readU16();if(s!==0){this.pushArrayState(s),this.complete();continue e}else t=[]}else if(e===221){let s=this.readU32();if(s!==0){this.pushArrayState(s),this.complete();continue e}else t=[]}else if(e===222){let s=this.readU16();if(s!==0){this.pushMapState(s),this.complete();continue e}else t={}}else if(e===223){let s=this.readU32();if(s!==0){this.pushMapState(s),this.complete();continue e}else t={}}else if(e===196){let s=this.lookU8();t=this.decodeBinary(s,1)}else if(e===197){let s=this.lookU16();t=this.decodeBinary(s,2)}else if(e===198){let s=this.lookU32();t=this.decodeBinary(s,4)}else if(e===212)t=this.decodeExtension(1,0);else if(e===213)t=this.decodeExtension(2,0);else if(e===214)t=this.decodeExtension(4,0);else if(e===215)t=this.decodeExtension(8,0);else if(e===216)t=this.decodeExtension(16,0);else if(e===199){let s=this.lookU8();t=this.decodeExtension(s,1)}else if(e===200){let s=this.lookU16();t=this.decodeExtension(s,2)}else if(e===201){let s=this.lookU32();t=this.decodeExtension(s,4)}else throw new Ze.DecodeError(`Unrecognized type byte: ${(0,Pn.prettyByte)(e)}`);this.complete();let o=this.stack;for(;o.length>0;){let s=o.top();if(s.type===En)if(s.array[s.position]=t,s.position++,s.position===s.size)t=s.array,o.release(s);else continue e;else if(s.type===go){if(t==="__proto__")throw new Ze.DecodeError("The key __proto__ is not allowed");s.key=this.mapKeyConverter(t),s.type=Sr;continue e}else if(s.map[s.key]=t,s.readCount++,s.readCount===s.size)t=s.map,o.release(s);else{s.key=null,s.type=go;continue e}}return t}}readHeadByte(){return this.headByte===fo&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=fo}readArraySize(){let e=this.readHeadByte();switch(e){case 220:return this.readU16();case 221:return this.readU32();default:{if(e<160)return e-144;throw new Ze.DecodeError(`Unrecognized array type byte: ${(0,Pn.prettyByte)(e)}`)}}}pushMapState(e){if(e>this.maxMapLength)throw new Ze.DecodeError(`Max length exceeded: map length (${e}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(e)}pushArrayState(e){if(e>this.maxArrayLength)throw new Ze.DecodeError(`Max length exceeded: array length (${e}) > maxArrayLength (${this.maxArrayLength})`);this.stack.pushArrayState(e)}decodeString(e,t){return!this.rawStrings||this.stateIsMapKey()?this.decodeUtf8String(e,t):this.decodeBinary(e,t)}decodeUtf8String(e,t){if(e>this.maxStrLength)throw new Ze.DecodeError(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+t+e)throw wr;let o=this.pos+t,s;return this.stateIsMapKey()&&this.keyDecoder?.canBeCached(e)?s=this.keyDecoder.decode(this.bytes,o,e):s=(0,fc.utf8Decode)(this.bytes,o,e),this.pos+=t+e,s}stateIsMapKey(){return this.stack.length>0?this.stack.top().type===go:!1}decodeBinary(e,t){if(e>this.maxBinLength)throw new Ze.DecodeError(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(e+t))throw wr;let o=this.pos+t,s=this.bytes.subarray(o,o+e);return this.pos+=t+e,s}decodeExtension(e,t){if(e>this.maxExtLength)throw new Ze.DecodeError(`Max length exceeded: ext length (${e}) > maxExtLength (${this.maxExtLength})`);let o=this.view.getInt8(this.pos+t),s=this.decodeBinary(e,t+1);return this.extensionCodec.decode(s,o,this.context)}lookU8(){return this.view.getUint8(this.pos)}lookU16(){return this.view.getUint16(this.pos)}lookU32(){return this.view.getUint32(this.pos)}readU8(){let e=this.view.getUint8(this.pos);return this.pos++,e}readI8(){let e=this.view.getInt8(this.pos);return this.pos++,e}readU16(){let e=this.view.getUint16(this.pos);return this.pos+=2,e}readI16(){let e=this.view.getInt16(this.pos);return this.pos+=2,e}readU32(){let e=this.view.getUint32(this.pos);return this.pos+=4,e}readI32(){let e=this.view.getInt32(this.pos);return this.pos+=4,e}readU64(){let e=(0,Tt.getUint64)(this.view,this.pos);return this.pos+=8,e}readI64(){let e=(0,Tt.getInt64)(this.view,this.pos);return this.pos+=8,e}readU64AsBigInt(){let e=this.view.getBigUint64(this.pos);return this.pos+=8,e}readI64AsBigInt(){let e=this.view.getBigInt64(this.pos);return this.pos+=8,e}readF32(){let e=this.view.getFloat32(this.pos);return this.pos+=4,e}readF64(){let e=this.view.getFloat64(this.pos);return this.pos+=8,e}};ls.Decoder=On});var vr=ee(us=>{"use strict";Object.defineProperty(us,"__esModule",{value:!0});us.decode=Cc;us.decodeMulti=wc;var kr=cs();function Cc(n,e){return new kr.Decoder(e).decode(n)}function wc(n,e){return new kr.Decoder(e).decodeMulti(n)}});var Mr=ee(yo=>{"use strict";Object.defineProperty(yo,"__esModule",{value:!0});yo.isAsyncIterable=xr;yo.asyncIterableFromStream=Tr;yo.ensureAsyncIterable=Sc;function xr(n){return n[Symbol.asyncIterator]!=null}async function*Tr(n){let e=n.getReader();try{for(;;){let{done:t,value:o}=await e.read();if(t)return;yield o}}finally{e.releaseLock()}}function Sc(n){return xr(n)?n:Tr(n)}});var Ar=ee(_o=>{"use strict";Object.defineProperty(_o,"__esModule",{value:!0});_o.decodeAsync=kc;_o.decodeArrayStream=vc;_o.decodeMultiStream=xc;var Rn=cs(),Un=Mr();async function kc(n,e){let t=(0,Un.ensureAsyncIterable)(n);return new Rn.Decoder(e).decodeAsync(t)}function vc(n,e){let t=(0,Un.ensureAsyncIterable)(n);return new Rn.Decoder(e).decodeArrayStream(t)}function xc(n,e){let t=(0,Un.ensureAsyncIterable)(n);return new Rn.Decoder(e).decodeStream(t)}});var Er=ee(W=>{"use strict";Object.defineProperty(W,"__esModule",{value:!0});W.decodeTimestampExtension=W.encodeTimestampExtension=W.decodeTimestampToTimeSpec=W.encodeTimeSpecToTimestamp=W.encodeDateToTimeSpec=W.EXT_TIMESTAMP=W.ExtData=W.ExtensionCodec=W.Encoder=W.DecodeError=W.Decoder=W.decodeMultiStream=W.decodeArrayStream=W.decodeAsync=W.decodeMulti=W.decode=W.encode=void 0;var Tc=yr();Object.defineProperty(W,"encode",{enumerable:!0,get:function(){return Tc.encode}});var Pr=vr();Object.defineProperty(W,"decode",{enumerable:!0,get:function(){return Pr.decode}});Object.defineProperty(W,"decodeMulti",{enumerable:!0,get:function(){return Pr.decodeMulti}});var Fn=Ar();Object.defineProperty(W,"decodeAsync",{enumerable:!0,get:function(){return Fn.decodeAsync}});Object.defineProperty(W,"decodeArrayStream",{enumerable:!0,get:function(){return Fn.decodeArrayStream}});Object.defineProperty(W,"decodeMultiStream",{enumerable:!0,get:function(){return Fn.decodeMultiStream}});var Mc=cs();Object.defineProperty(W,"Decoder",{enumerable:!0,get:function(){return Mc.Decoder}});var Ac=os();Object.defineProperty(W,"DecodeError",{enumerable:!0,get:function(){return Ac.DecodeError}});var Pc=xn();Object.defineProperty(W,"Encoder",{enumerable:!0,get:function(){return Pc.Encoder}});var Ec=rs();Object.defineProperty(W,"ExtensionCodec",{enumerable:!0,get:function(){return Ec.ExtensionCodec}});var Dc=_n();Object.defineProperty(W,"ExtData",{enumerable:!0,get:function(){return Dc.ExtData}});var Gt=Cn();Object.defineProperty(W,"EXT_TIMESTAMP",{enumerable:!0,get:function(){return Gt.EXT_TIMESTAMP}});Object.defineProperty(W,"encodeDateToTimeSpec",{enumerable:!0,get:function(){return Gt.encodeDateToTimeSpec}});Object.defineProperty(W,"encodeTimeSpecToTimestamp",{enumerable:!0,get:function(){return Gt.encodeTimeSpecToTimestamp}});Object.defineProperty(W,"decodeTimestampToTimeSpec",{enumerable:!0,get:function(){return Gt.decodeTimestampToTimeSpec}});Object.defineProperty(W,"encodeTimestampExtension",{enumerable:!0,get:function(){return Gt.encodeTimestampExtension}});Object.defineProperty(W,"decodeTimestampExtension",{enumerable:!0,get:function(){return Gt.decodeTimestampExtension}})});var ya=ee((Rp,du)=>{du.exports={name:"@rajbos/ai-engineering-fluency",version:"0.0.9",description:"AI Engineering Fluency - CLI tool to analyze GitHub Copilot token usage from local session files",license:"MIT",author:"RobBos",repository:{type:"git",url:"git+https://github.com/rajbos/github-copilot-token-usage.git",directory:"cli"},keywords:["github-copilot","token-usage","copilot","cli","token-tracker"],bin:{"ai-engineering-fluency":"dist/cli.js"},files:["dist/**/*"],scripts:{build:"node esbuild.js","build:production":"node esbuild.js --production","bundle-exe":"pwsh -NoProfile -File bundle-exe.ps1",lint:"eslint src","check-types":"tsc --noEmit",test:"node dist/cli.js --help && node dist/cli.js --version"},devDependencies:{commander:"^14.0.3",chalk:"^5.6.2",esbuild:"^0.28.0",typescript:"^6.0.2","@types/node":"^25.5.0","sql.js":"^1.12.0"},engines:{node:">=22.14.0"}}});var Gi=z(Bi(),1),{program:wu,createCommand:Su,createArgument:ku,createOption:vu,CommanderError:xu,InvalidArgumentError:Tu,InvalidOptionArgumentError:Mu,Command:de,Argument:Au,Option:Pu,Help:Eu}=Gi.default;var zi=(n=0)=>e=>`\x1B[${e+n}m`,Wi=(n=0)=>e=>`\x1B[${38+n};5;${e}m`,Hi=(n=0)=>(e,t,o)=>`\x1B[${38+n};2;${e};${t};${o}m`,oe={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},Ou=Object.keys(oe.modifier),Al=Object.keys(oe.color),Pl=Object.keys(oe.bgColor),Iu=[...Al,...Pl];function El(){let n=new Map;for(let[e,t]of Object.entries(oe)){for(let[o,s]of Object.entries(t))oe[o]={open:`\x1B[${s[0]}m`,close:`\x1B[${s[1]}m`},t[o]=oe[o],n.set(s[0],s[1]);Object.defineProperty(oe,e,{value:t,enumerable:!1})}return Object.defineProperty(oe,"codes",{value:n,enumerable:!1}),oe.color.close="\x1B[39m",oe.bgColor.close="\x1B[49m",oe.color.ansi=zi(),oe.color.ansi256=Wi(),oe.color.ansi16m=Hi(),oe.bgColor.ansi=zi(10),oe.bgColor.ansi256=Wi(10),oe.bgColor.ansi16m=Hi(10),Object.defineProperties(oe,{rgbToAnsi256:{value(e,t,o){return e===t&&t===o?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(o/255*5)},enumerable:!1},hexToRgb:{value(e){let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[o]=t;o.length===3&&(o=[...o].map(r=>r+r).join(""));let s=Number.parseInt(o,16);return[s>>16&255,s>>8&255,s&255]},enumerable:!1},hexToAnsi256:{value:e=>oe.rgbToAnsi256(...oe.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){if(e<8)return 30+e;if(e<16)return 90+(e-8);let t,o,s;if(e>=232)t=((e-232)*10+8)/255,o=t,s=t;else{e-=16;let u=e%36;t=Math.floor(e/36)/5,o=Math.floor(u/6)/5,s=u%6/5}let r=Math.max(t,o,s)*2;if(r===0)return 30;let l=30+(Math.round(s)<<2|Math.round(o)<<1|Math.round(t));return r===2&&(l+=60),l},enumerable:!1},rgbToAnsi:{value:(e,t,o)=>oe.ansi256ToAnsi(oe.rgbToAnsi256(e,t,o)),enumerable:!1},hexToAnsi:{value:e=>oe.ansi256ToAnsi(oe.hexToAnsi256(e)),enumerable:!1}}),oe}var Dl=El(),Le=Dl;var Go=z(require("node:process"),1),Ji=z(require("node:os"),1),un=z(require("node:tty"),1);function Ue(n,e=globalThis.Deno?globalThis.Deno.args:Go.default.argv){let t=n.startsWith("-")?"":n.length===1?"-":"--",o=e.indexOf(t+n),s=e.indexOf("--");return o!==-1&&(s===-1||o<s)}var{env:se}=Go.default,Bo;Ue("no-color")||Ue("no-colors")||Ue("color=false")||Ue("color=never")?Bo=0:(Ue("color")||Ue("colors")||Ue("color=true")||Ue("color=always"))&&(Bo=1);function Ol(){if("FORCE_COLOR"in se)return se.FORCE_COLOR==="true"?1:se.FORCE_COLOR==="false"?0:se.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(se.FORCE_COLOR,10),3)}function Il(n){return n===0?!1:{level:n,hasBasic:!0,has256:n>=2,has16m:n>=3}}function Rl(n,{streamIsTTY:e,sniffFlags:t=!0}={}){let o=Ol();o!==void 0&&(Bo=o);let s=t?Bo:o;if(s===0)return 0;if(t){if(Ue("color=16m")||Ue("color=full")||Ue("color=truecolor"))return 3;if(Ue("color=256"))return 2}if("TF_BUILD"in se&&"AGENT_NAME"in se)return 1;if(n&&!e&&s===void 0)return 0;let r=s||0;if(se.TERM==="dumb")return r;if(Go.default.platform==="win32"){let l=Ji.default.release().split(".");return Number(l[0])>=10&&Number(l[2])>=10586?Number(l[2])>=14931?3:2:1}if("CI"in se)return["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some(l=>l in se)?3:["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(l=>l in se)||se.CI_NAME==="codeship"?1:r;if("TEAMCITY_VERSION"in se)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(se.TEAMCITY_VERSION)?1:0;if(se.COLORTERM==="truecolor"||se.TERM==="xterm-kitty"||se.TERM==="xterm-ghostty"||se.TERM==="wezterm")return 3;if("TERM_PROGRAM"in se){let l=Number.parseInt((se.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(se.TERM_PROGRAM){case"iTerm.app":return l>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(se.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(se.TERM)||"COLORTERM"in se?1:r}function Vi(n,e={}){let t=Rl(n,{streamIsTTY:n&&n.isTTY,...e});return Il(t)}var Ul={stdout:Vi({isTTY:un.default.isatty(1)}),stderr:Vi({isTTY:un.default.isatty(2)})},Ki=Ul;function Yi(n,e,t){let o=n.indexOf(e);if(o===-1)return n;let s=e.length,r=0,l="";do l+=n.slice(r,o)+e+t,r=o+s,o=n.indexOf(e,r);while(o!==-1);return l+=n.slice(r),l}function Qi(n,e,t,o){let s=0,r="";do{let l=n[o-1]==="\r";r+=n.slice(s,l?o-1:o)+e+(l?`\r
|
|
24
|
+
`),this.outputHelp({error:!0}));let s=t||{},o=s.exitCode||1,n=s.code||"commander.error";this._exit(o,n,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in J.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()}`,J.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new sc(this.options),t=s=>this.getOptionValue(s)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(s));this.options.filter(s=>s.implied!==void 0&&t(s.attributeName())&&e.valueFromOption(this.getOptionValue(s.attributeName()),s)).forEach(s=>{Object.keys(s.implied).filter(o=>!t(o)).forEach(o=>{this.setOptionValueWithSource(o,s.implied[o],"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 s=a=>{let d=a.attributeName(),c=this.getOptionValue(d),h=this.options.find(p=>p.negate&&d===p.attributeName()),m=this.options.find(p=>!p.negate&&d===p.attributeName());return h&&(h.presetArg===void 0&&c===!1||h.presetArg!==void 0&&c===h.presetArg)?h:m||a},o=a=>{let d=s(a),c=d.attributeName();return this.getOptionValueSource(c)==="env"?`environment variable '${d.envVar}'`:`option '${d.flags}'`},n=`error: ${o(e)} cannot be used with ${o(t)}`;this.error(n,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let o=[],n=this;do{let a=n.createHelp().visibleOptions(n).filter(d=>d.long).map(d=>d.long);o=o.concat(a),n=n.parent}while(n&&!n._enablePositionalOptions);t=rr(e,o)}let s=`error: unknown option '${e}'${t}`;this.error(s,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this.registeredArguments.length,s=t===1?"":"s",n=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${t} argument${s} but got ${e.length}.`;this.error(n,{code:"commander.excessArguments"})}unknownCommand(){let e=this.args[0],t="";if(this._showSuggestionAfterError){let o=[];this.createHelp().visibleCommands(this).forEach(n=>{o.push(n.name()),n.alias()&&o.push(n.alias())}),t=rr(e,o)}let s=`error: unknown command '${e}'${t}`;this.error(s,{code:"commander.unknownCommand"})}version(e,t,s){if(e===void 0)return this._version;this._version=e,t=t||"-V, --version",s=s||"output the version number";let o=this.createOption(t,s);return this._versionOptionName=o.attributeName(),this._registerOption(o),this.on("option:"+o.name(),()=>{this._outputConfiguration.writeOut(`${e}
|
|
25
|
+
`),this._exit(0,"commander.version",e)}),this}description(e,t){return e===void 0&&t===void 0?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw new Error("Command alias can't be the same as its name");let s=this.parent?._findCommand(e);if(s){let o=[s.name()].concat(s.aliases()).join("|");throw new Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${o}'`)}return t._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(t=>this.alias(t)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let t=this.registeredArguments.map(s=>Zl(s));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?t:[]).join(" ")}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}helpGroup(e){return e===void 0?this._helpGroupHeading??"":(this._helpGroupHeading=e,this)}commandsGroup(e){return e===void 0?this._defaultCommandGroup??"":(this._defaultCommandGroup=e,this)}optionsGroup(e){return e===void 0?this._defaultOptionGroup??"":(this._defaultOptionGroup=e,this)}_initOptionGroup(e){this._defaultOptionGroup&&!e.helpGroupHeading&&e.helpGroup(this._defaultOptionGroup)}_initCommandGroup(e){this._defaultCommandGroup&&!e.helpGroup()&&e.helpGroup(this._defaultCommandGroup)}nameFromFilename(e){return this._name=nt.basename(e,nt.extname(e)),this}executableDir(e){return e===void 0?this._executableDir:(this._executableDir=e,this)}helpInformation(e){let t=this.createHelp(),s=this._getOutputContext(e);t.prepareContext({error:s.error,helpWidth:s.helpWidth,outputHasColors:s.hasColors});let o=t.formatHelp(this,t);return s.hasColors?o:this._outputConfiguration.stripColor(o)}_getOutputContext(e){e=e||{};let t=!!e.error,s,o,n;return t?(s=d=>this._outputConfiguration.writeErr(d),o=this._outputConfiguration.getErrHasColors(),n=this._outputConfiguration.getErrHelpWidth()):(s=d=>this._outputConfiguration.writeOut(d),o=this._outputConfiguration.getOutHasColors(),n=this._outputConfiguration.getOutHelpWidth()),{error:t,write:d=>(o||(d=this._outputConfiguration.stripColor(d)),s(d)),hasColors:o,helpWidth:n}}outputHelp(e){let t;typeof e=="function"&&(t=e,e=void 0);let s=this._getOutputContext(e),o={error:s.error,write:s.write,command:this};this._getCommandAndAncestors().reverse().forEach(a=>a.emit("beforeAllHelp",o)),this.emit("beforeHelp",o);let n=this.helpInformation({error:s.error});if(t&&(n=t(n),typeof n!="string"&&!Buffer.isBuffer(n)))throw new Error("outputHelp callback must return a string or a Buffer");s.write(n),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",o),this._getCommandAndAncestors().forEach(a=>a.emit("afterAllHelp",o))}helpOption(e,t){return typeof e=="boolean"?(e?(this._helpOption===null&&(this._helpOption=void 0),this._defaultOptionGroup&&this._initOptionGroup(this._getHelpOption())):this._helpOption=null,this):(this._helpOption=this.createOption(e??"-h, --help",t??"display help for command"),(e||t)&&this._initOptionGroup(this._helpOption),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this._initOptionGroup(e),this}help(e){this.outputHelp(e);let t=Number(J.exitCode??0);t===0&&e&&typeof e!="function"&&e.error&&(t=1),this._exit(t,"commander.help","(outputHelp)")}addHelpText(e,t){let s=["beforeAll","before","after","afterAll"];if(!s.includes(e))throw new Error(`Unexpected value for position to addHelpText.
|
|
26
|
+
Expecting one of '${s.join("', '")}'`);let o=`${e}Help`;return this.on(o,n=>{let a;typeof t=="function"?a=t({error:n.error,command:n.command}):a=t,a&&n.write(`${a}
|
|
27
|
+
`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(o=>t.is(o))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function ar(r){return r.map(e=>{if(!e.startsWith("--inspect"))return e;let t,s="127.0.0.1",o="9229",n;return(n=e.match(/^(--inspect(-brk)?)$/))!==null?t=n[1]:(n=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(t=n[1],/^\d+$/.test(n[3])?o=n[3]:s=n[3]):(n=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=n[1],s=n[3],o=n[4]),t&&o!=="0"?`${t}=${s}:${parseInt(o)+1}`:e})}function xn(){if(J.env.NO_COLOR||J.env.FORCE_COLOR==="0"||J.env.FORCE_COLOR==="false")return!1;if(J.env.FORCE_COLOR||J.env.CLICOLOR_FORCE!==void 0)return!0}Tn.Command=vn;Tn.useColor=xn});var pr=oe(je=>{var{Argument:cr}=Xs(),{Command:Pn}=lr(),{CommanderError:oc,InvalidArgumentError:ur}=ms(),{Help:nc}=yn(),{Option:dr}=wn();je.program=new Pn;je.createCommand=r=>new Pn(r);je.createOption=(r,e)=>new dr(r,e);je.createArgument=(r,e)=>new cr(r,e);je.Command=Pn;je.Option=dr;je.Argument=cr;je.Help=nc;je.CommanderError=oc;je.InvalidArgumentError=ur;je.InvalidOptionArgumentError=ur});var Un=oe((ao,Rt)=>{var io=void 0,ro=function(r){return io||(io=new Promise(function(e,t){var s=typeof r<"u"?r:{},o=s.onAbort;s.onAbort=function(i){t(new Error(i)),o&&o(i)},s.postRun=s.postRun||[],s.postRun.push(function(){e(s)}),Rt=void 0;var n;n||=typeof s<"u"?s:{};var a=!!globalThis.window,d=!!globalThis.WorkerGlobalScope,c=globalThis.process?.versions?.node&&globalThis.process?.type!="renderer";n.onRuntimeInitialized=function(){function i(S,E){switch(typeof E){case"boolean":Fl(S,E?1:0);break;case"number":Ol(S,E);break;case"string":Ul(S,E,-1,-1);break;case"object":if(E===null)Yi(S);else if(E.length!=null){var O=Vs(E.length);D.set(E,O),Rl(S,O,E.length,-1),ps(O)}else Ys(S,"Wrong API use : tried to return a value of an unknown type ("+E+").",-1);break;default:Yi(S)}}function l(S,E){for(var O=[],U=0;U<S;U+=1){var B=ae(E+4*U,"i32"),Q=Ml(B);if(Q===1||Q===2)B=Il(B);else if(Q===3)B=El(B);else if(Q===4){Q=B,B=Al(Q),Q=Dl(Q);for(var Ge=new Uint8Array(B),Ne=0;Ne<B;Ne+=1)Ge[Ne]=D[Q+Ne];B=Ge}else B=null;O.push(B)}return O}function u(S,E){this.Qa=S,this.db=E,this.Oa=1,this.mb=[]}function f(S,E){if(this.db=E,this.fb=Ws(S),this.fb===null)throw Error("Unable to allocate memory for the SQL string");this.lb=this.fb,this.$a=this.sb=null}function _(S){if(this.filename="dbfile_"+(4294967295*Math.random()>>>0),S!=null){var E=this.filename,O="/",U=E;if(O&&(O=typeof O=="string"?O:Yo(O),U=E?He(O+"/"+E):O),E=ki(!0,!0),U=ol(U,E),S){if(typeof S=="string"){O=Array(S.length);for(var B=0,Q=S.length;B<Q;++B)O[B]=S.charCodeAt(B);S=O}qs(U,E|146),O=Yt(U,577),ji(O,S,0,S.length,0),sn(O),qs(U,E)}}this.handleError($(this.filename,x)),this.db=ae(x,"i32"),Xi(this.db),this.gb={},this.Sa={}}var x=Ot(4),A=n.cwrap,$=A("sqlite3_open","number",["string","number"]),Y=A("sqlite3_close_v2","number",["number"]),q=A("sqlite3_exec","number",["number","string","number","number","number"]),se=A("sqlite3_changes","number",["number"]),he=A("sqlite3_prepare_v2","number",["number","string","number","number","number"]),Wi=A("sqlite3_sql","string",["number"]),dl=A("sqlite3_normalized_sql","string",["number"]),Vi=A("sqlite3_prepare_v2","number",["number","number","number","number","number"]),pl=A("sqlite3_bind_text","number",["number","number","number","number","number"]),Hi=A("sqlite3_bind_blob","number",["number","number","number","number","number"]),ml=A("sqlite3_bind_double","number",["number","number","number"]),hl=A("sqlite3_bind_int","number",["number","number","number"]),fl=A("sqlite3_bind_parameter_index","number",["number","string"]),gl=A("sqlite3_step","number",["number"]),yl=A("sqlite3_errmsg","string",["number"]),_l=A("sqlite3_column_count","number",["number"]),bl=A("sqlite3_data_count","number",["number"]),Cl=A("sqlite3_column_double","number",["number","number"]),Ji=A("sqlite3_column_text","string",["number","number"]),wl=A("sqlite3_column_blob","number",["number","number"]),Sl=A("sqlite3_column_bytes","number",["number","number"]),kl=A("sqlite3_column_type","number",["number","number"]),vl=A("sqlite3_column_name","string",["number","number"]),xl=A("sqlite3_reset","number",["number"]),Tl=A("sqlite3_clear_bindings","number",["number"]),Pl=A("sqlite3_finalize","number",["number"]),Ki=A("sqlite3_create_function_v2","number","number string number number number number number number number".split(" ")),Ml=A("sqlite3_value_type","number",["number"]),Al=A("sqlite3_value_bytes","number",["number"]),El=A("sqlite3_value_text","string",["number"]),Dl=A("sqlite3_value_blob","number",["number"]),Il=A("sqlite3_value_double","number",["number"]),Ol=A("sqlite3_result_double","",["number","number"]),Yi=A("sqlite3_result_null","",["number"]),Ul=A("sqlite3_result_text","",["number","string","number","number"]),Rl=A("sqlite3_result_blob","",["number","number","number","number"]),Fl=A("sqlite3_result_int","",["number","number"]),Ys=A("sqlite3_result_error","",["number","string","number"]),Qi=A("sqlite3_aggregate_context","number",["number","number"]),Xi=A("RegisterExtensionFunctions","number",["number"]),Zi=A("sqlite3_update_hook","number",["number","number","number"]);u.prototype.bind=function(S){if(!this.Qa)throw"Statement closed";return this.reset(),Array.isArray(S)?this.Gb(S):S!=null&&typeof S=="object"?this.Hb(S):!0},u.prototype.step=function(){if(!this.Qa)throw"Statement closed";this.Oa=1;var S=gl(this.Qa);switch(S){case 100:return!0;case 101:return!1;default:throw this.db.handleError(S)}},u.prototype.Ab=function(S){return S==null&&(S=this.Oa,this.Oa+=1),Cl(this.Qa,S)},u.prototype.Ob=function(S){if(S==null&&(S=this.Oa,this.Oa+=1),S=Ji(this.Qa,S),typeof BigInt!="function")throw Error("BigInt is not supported");return BigInt(S)},u.prototype.Tb=function(S){return S==null&&(S=this.Oa,this.Oa+=1),Ji(this.Qa,S)},u.prototype.getBlob=function(S){S==null&&(S=this.Oa,this.Oa+=1);var E=Sl(this.Qa,S);S=wl(this.Qa,S);for(var O=new Uint8Array(E),U=0;U<E;U+=1)O[U]=D[S+U];return O},u.prototype.get=function(S,E){E=E||{},S!=null&&this.bind(S)&&this.step(),S=[];for(var O=bl(this.Qa),U=0;U<O;U+=1)switch(kl(this.Qa,U)){case 1:var B=E.useBigInt?this.Ob(U):this.Ab(U);S.push(B);break;case 2:S.push(this.Ab(U));break;case 3:S.push(this.Tb(U));break;case 4:S.push(this.getBlob(U));break;default:S.push(null)}return S},u.prototype.qb=function(){for(var S=[],E=_l(this.Qa),O=0;O<E;O+=1)S.push(vl(this.Qa,O));return S},u.prototype.zb=function(S,E){S=this.get(S,E),E=this.qb();for(var O={},U=0;U<E.length;U+=1)O[E[U]]=S[U];return O},u.prototype.Sb=function(){return Wi(this.Qa)},u.prototype.Pb=function(){return dl(this.Qa)},u.prototype.run=function(S){return S!=null&&this.bind(S),this.step(),this.reset()},u.prototype.wb=function(S,E){E==null&&(E=this.Oa,this.Oa+=1),S=Ws(S),this.mb.push(S),this.db.handleError(pl(this.Qa,E,S,-1,0))},u.prototype.Fb=function(S,E){E==null&&(E=this.Oa,this.Oa+=1);var O=Vs(S.length);D.set(S,O),this.mb.push(O),this.db.handleError(Hi(this.Qa,E,O,S.length,0))},u.prototype.vb=function(S,E){E==null&&(E=this.Oa,this.Oa+=1),this.db.handleError((S===(S|0)?hl:ml)(this.Qa,E,S))},u.prototype.Ib=function(S){S==null&&(S=this.Oa,this.Oa+=1),Hi(this.Qa,S,0,0,0)},u.prototype.xb=function(S,E){switch(E==null&&(E=this.Oa,this.Oa+=1),typeof S){case"string":this.wb(S,E);return;case"number":this.vb(S,E);return;case"bigint":this.wb(S.toString(),E);return;case"boolean":this.vb(S+0,E);return;case"object":if(S===null){this.Ib(E);return}if(S.length!=null){this.Fb(S,E);return}}throw"Wrong API use : tried to bind a value of an unknown type ("+S+")."},u.prototype.Hb=function(S){var E=this;return Object.keys(S).forEach(function(O){var U=fl(E.Qa,O);U!==0&&E.xb(S[O],U)}),!0},u.prototype.Gb=function(S){for(var E=0;E<S.length;E+=1)this.xb(S[E],E+1);return!0},u.prototype.reset=function(){return this.freemem(),Tl(this.Qa)===0&&xl(this.Qa)===0},u.prototype.freemem=function(){for(var S;(S=this.mb.pop())!==void 0;)ps(S)},u.prototype.Ya=function(){this.freemem();var S=Pl(this.Qa)===0;return delete this.db.gb[this.Qa],this.Qa=0,S},f.prototype.next=function(){if(this.fb===null)return{done:!0};if(this.$a!==null&&(this.$a.Ya(),this.$a=null),!this.db.db)throw this.ob(),Error("Database closed");var S=Js(),E=Ot(4);Wt(x),Wt(E);try{this.db.handleError(Vi(this.db.db,this.lb,-1,x,E)),this.lb=ae(E,"i32");var O=ae(x,"i32");return O===0?(this.ob(),{done:!0}):(this.$a=new u(O,this.db),this.db.gb[O]=this.$a,{value:this.$a,done:!1})}catch(U){throw this.sb=ne(this.lb),this.ob(),U}finally{Hs(S)}},f.prototype.ob=function(){ps(this.fb),this.fb=null},f.prototype.Qb=function(){return this.sb!==null?this.sb:ne(this.lb)},typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"&&(f.prototype[Symbol.iterator]=function(){return this}),_.prototype.run=function(S,E){if(!this.db)throw"Database closed";if(E){S=this.tb(S,E);try{S.step()}finally{S.Ya()}}else this.handleError(q(this.db,S,0,0,x));return this},_.prototype.exec=function(S,E,O){if(!this.db)throw"Database closed";var U=null,B=null,Q=null;try{Q=B=Ws(S);var Ge=Ot(4);for(S=[];ae(Q,"i8")!==0;){Wt(x),Wt(Ge),this.handleError(Vi(this.db,Q,-1,x,Ge));var Ne=ae(x,"i32");if(Q=ae(Ge,"i32"),Ne!==0){var Ee=null;for(U=new u(Ne,this),E!=null&&U.bind(E);U.step();)Ee===null&&(Ee={columns:U.qb(),values:[]},S.push(Ee)),Ee.values.push(U.get(null,O));U.Ya()}}return S}catch(Be){throw U&&U.Ya(),Be}finally{B&&ps(B)}},_.prototype.Mb=function(S,E,O,U,B){typeof E=="function"&&(U=O,O=E,E=void 0),S=this.tb(S,E);try{for(;S.step();)O(S.zb(null,B))}finally{S.Ya()}if(typeof U=="function")return U()},_.prototype.tb=function(S,E){if(Wt(x),this.handleError(he(this.db,S,-1,x,0)),S=ae(x,"i32"),S===0)throw"Nothing to prepare";var O=new u(S,this);return E!=null&&O.bind(E),this.gb[S]=O},_.prototype.Ub=function(S){return new f(S,this)},_.prototype.Nb=function(){Object.values(this.gb).forEach(function(E){E.Ya()}),Object.values(this.Sa).forEach(Ct),this.Sa={},this.handleError(Y(this.db));var S=nl(this.filename);return this.handleError($(this.filename,x)),this.db=ae(x,"i32"),Xi(this.db),S},_.prototype.close=function(){this.db!==null&&(Object.values(this.gb).forEach(function(S){S.Ya()}),Object.values(this.Sa).forEach(Ct),this.Sa={},this.Za&&(Ct(this.Za),this.Za=void 0),this.handleError(Y(this.db)),Oi("/"+this.filename),this.db=null)},_.prototype.handleError=function(S){if(S===0)return null;throw S=yl(this.db),Error(S)},_.prototype.Rb=function(){return se(this.db)},_.prototype.Kb=function(S,E){Object.prototype.hasOwnProperty.call(this.Sa,S)&&(Ct(this.Sa[S]),delete this.Sa[S]);var O=ds(function(U,B,Q){B=l(B,Q);try{var Ge=E.apply(null,B)}catch(Ne){Ys(U,Ne,-1);return}i(U,Ge)},"viii");return this.Sa[S]=O,this.handleError(Ki(this.db,S,E.length,1,0,O,0,0,0)),this},_.prototype.Jb=function(S,E){var O=E.init||function(){return null},U=E.finalize||function(Ee){return Ee},B=E.step;if(!B)throw"An aggregate function must have a step function in "+S;var Q={};Object.hasOwnProperty.call(this.Sa,S)&&(Ct(this.Sa[S]),delete this.Sa[S]),E=S+"__finalize",Object.hasOwnProperty.call(this.Sa,E)&&(Ct(this.Sa[E]),delete this.Sa[E]);var Ge=ds(function(Ee,Be,un){var Ut=Qi(Ee,1);Object.hasOwnProperty.call(Q,Ut)||(Q[Ut]=O()),Be=l(Be,un),Be=[Q[Ut]].concat(Be);try{Q[Ut]=B.apply(null,Be)}catch(Nl){delete Q[Ut],Ys(Ee,Nl,-1)}},"viii"),Ne=ds(function(Ee){var Be=Qi(Ee,1);try{var un=U(Q[Be])}catch(Ut){delete Q[Be],Ys(Ee,Ut,-1);return}i(Ee,un),delete Q[Be]},"vi");return this.Sa[S]=Ge,this.Sa[E]=Ne,this.handleError(Ki(this.db,S,B.length-1,1,0,0,Ge,Ne,0)),this},_.prototype.Zb=function(S){return this.Za&&(Zi(this.db,0,0),Ct(this.Za),this.Za=void 0),S?(this.Za=ds(function(E,O,U,B,Q){switch(O){case 18:E="insert";break;case 23:E="update";break;case 9:E="delete";break;default:throw"unknown operationCode in updateHook callback: "+O}if(U=ne(U),B=ne(B),Q>Number.MAX_SAFE_INTEGER)throw"rowId too big to fit inside a Number";S(E,U,B,Number(Q))},"viiiij"),Zi(this.db,this.Za,0),this):this},u.prototype.bind=u.prototype.bind,u.prototype.step=u.prototype.step,u.prototype.get=u.prototype.get,u.prototype.getColumnNames=u.prototype.qb,u.prototype.getAsObject=u.prototype.zb,u.prototype.getSQL=u.prototype.Sb,u.prototype.getNormalizedSQL=u.prototype.Pb,u.prototype.run=u.prototype.run,u.prototype.reset=u.prototype.reset,u.prototype.freemem=u.prototype.freemem,u.prototype.free=u.prototype.Ya,f.prototype.next=f.prototype.next,f.prototype.getRemainingSQL=f.prototype.Qb,_.prototype.run=_.prototype.run,_.prototype.exec=_.prototype.exec,_.prototype.each=_.prototype.Mb,_.prototype.prepare=_.prototype.tb,_.prototype.iterateStatements=_.prototype.Ub,_.prototype.export=_.prototype.Nb,_.prototype.close=_.prototype.close,_.prototype.handleError=_.prototype.handleError,_.prototype.getRowsModified=_.prototype.Rb,_.prototype.create_function=_.prototype.Kb,_.prototype.create_aggregate=_.prototype.Jb,_.prototype.updateHook=_.prototype.Zb,n.Database=_};var h="./this.program",m=(i,l)=>{throw l},p=globalThis.document?.currentScript?.src;typeof __filename<"u"?p=__filename:d&&(p=self.location.href);var g="",w,k;if(c){var b=require("node:fs");g=__dirname+"/",k=i=>(i=F(i)?new URL(i):i,b.readFileSync(i)),w=async i=>(i=F(i)?new URL(i):i,b.readFileSync(i,void 0)),1<process.argv.length&&(h=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2),typeof Rt<"u"&&(Rt.exports=n),m=(i,l)=>{throw process.exitCode=i,l}}else if(a||d){try{g=new URL(".",p).href}catch{}d&&(k=i=>{var l=new XMLHttpRequest;return l.open("GET",i,!1),l.responseType="arraybuffer",l.send(null),new Uint8Array(l.response)}),w=async i=>{if(F(i))return new Promise((u,f)=>{var _=new XMLHttpRequest;_.open("GET",i,!0),_.responseType="arraybuffer",_.onload=()=>{_.status==200||_.status==0&&_.response?u(_.response):f(_.status)},_.onerror=f,_.send(null)});var l=await fetch(i,{credentials:"same-origin"});if(l.ok)return l.arrayBuffer();throw Error(l.status+" : "+l.url)}}var y=console.log.bind(console),v=console.error.bind(console),C,P=!1,M,F=i=>i.startsWith("file://"),D,N,H,K,W,Me,ve,Z;function Ue(){var i=Ks.buffer;D=new Int8Array(i),H=new Int16Array(i),N=new Uint8Array(i),new Uint16Array(i),K=new Int32Array(i),W=new Uint32Array(i),Me=new Float32Array(i),ve=new Float64Array(i),Z=new BigInt64Array(i),new BigUint64Array(i)}function Ae(i){throw n.onAbort?.(i),i="Aborted("+i+")",v(i),P=!0,new WebAssembly.RuntimeError(i+". Build with -sASSERTIONS for more info.")}var tt;async function ft(i){if(!C)try{var l=await w(i);return new Uint8Array(l)}catch{}if(i==tt&&C)i=new Uint8Array(C);else if(k)i=k(i);else throw"both async and sync fetching of the wasm failed";return i}async function Ve(i,l){try{var u=await ft(i);return await WebAssembly.instantiate(u,l)}catch(f){v(`failed to asynchronously prepare wasm: ${f}`),Ae(f)}}async function de(i){var l=tt;if(!C&&!F(l)&&!c)try{var u=fetch(l,{credentials:"same-origin"});return await WebAssembly.instantiateStreaming(u,i)}catch(f){v(`wasm streaming compile failed: ${f}`),v("falling back to ArrayBuffer instantiation")}return Ve(l,i)}class Mt{name="ExitStatus";constructor(l){this.message=`Program terminated with exit(${l})`,this.status=l}}var fe=i=>{for(;0<i.length;)i.shift()(n)},be=[],ls=[],zt=()=>{var i=n.preRun.shift();ls.push(i)},Ce=0,Re=null;function ae(i,l="i8"){switch(l.endsWith("*")&&(l="*"),l){case"i1":return D[i];case"i8":return D[i];case"i16":return H[i>>1];case"i32":return K[i>>2];case"i64":return Z[i>>3];case"float":return Me[i>>2];case"double":return ve[i>>3];case"*":return W[i>>2];default:Ae(`invalid type for getValue: ${l}`)}}var st=!0;function Wt(i){var l="i32";switch(l.endsWith("*")&&(l="*"),l){case"i1":D[i]=0;break;case"i8":D[i]=0;break;case"i16":H[i>>1]=0;break;case"i32":K[i>>2]=0;break;case"i64":Z[i>>3]=BigInt(0);break;case"float":Me[i>>2]=0;break;case"double":ve[i>>3]=0;break;case"*":W[i>>2]=0;break;default:Ae(`invalid type for setValue: ${l}`)}}var gt=new TextDecoder,Vt=(i,l,u,f)=>{if(u=l+u,f)return u;for(;i[l]&&!(l>=u);)++l;return l},ne=(i,l,u)=>i?gt.decode(N.subarray(i,Vt(N,i,l,u))):"",G=(i,l)=>{for(var u=0,f=i.length-1;0<=f;f--){var _=i[f];_==="."?i.splice(f,1):_===".."?(i.splice(f,1),u++):u&&(i.splice(f,1),u--)}if(l)for(;u;u--)i.unshift("..");return i},He=i=>{var l=i.charAt(0)==="/",u=i.slice(-1)==="/";return(i=G(i.split("/").filter(f=>!!f),!l).join("/"))||l||(i="."),i&&u&&(i+="/"),(l?"/":"")+i},ot=i=>{var l=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(i).slice(1);return i=l[0],l=l[1],!i&&!l?".":(l&&=l.slice(0,-1),i+l)},yt=i=>i&&i.match(/([^\/]+|\/)\/*$/)[1],ue=()=>{if(c){var i=require("node:crypto");return l=>i.randomFillSync(l)}return l=>crypto.getRandomValues(l)},le=i=>{(le=ue())(i)},Je=(...i)=>{for(var l="",u=!1,f=i.length-1;-1<=f&&!u;f--){if(u=0<=f?i[f]:"/",typeof u!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!u)return"";l=u+"/"+l,u=u.charAt(0)==="/"}return l=G(l.split("/").filter(_=>!!_),!u).join("/"),(u?"/":"")+l||"."},At=i=>{var l=Vt(i,0);return gt.decode(i.buffer?i.subarray(0,l):new Uint8Array(i.slice(0,l)))},Jo=[],Ht=i=>{for(var l=0,u=0;u<i.length;++u){var f=i.charCodeAt(u);127>=f?l++:2047>=f?l+=2:55296<=f&&57343>=f?(l+=4,++u):l+=3}return l},Ke=(i,l,u,f)=>{if(!(0<f))return 0;var _=u;f=u+f-1;for(var x=0;x<i.length;++x){var A=i.codePointAt(x);if(127>=A){if(u>=f)break;l[u++]=A}else if(2047>=A){if(u+1>=f)break;l[u++]=192|A>>6,l[u++]=128|A&63}else if(65535>=A){if(u+2>=f)break;l[u++]=224|A>>12,l[u++]=128|A>>6&63,l[u++]=128|A&63}else{if(u+3>=f)break;l[u++]=240|A>>18,l[u++]=128|A>>12&63,l[u++]=128|A>>6&63,l[u++]=128|A&63,x++}}return l[u]=0,u-_},wi=[];function Si(i,l){wi[i]={input:[],output:[],eb:l},en(i,Ka)}var Ka={open(i){var l=wi[i.node.rdev];if(!l)throw new I(43);i.tty=l,i.seekable=!1},close(i){i.tty.eb.fsync(i.tty)},fsync(i){i.tty.eb.fsync(i.tty)},read(i,l,u,f){if(!i.tty||!i.tty.eb.Bb)throw new I(60);for(var _=0,x=0;x<f;x++){try{var A=i.tty.eb.Bb(i.tty)}catch{throw new I(29)}if(A===void 0&&_===0)throw new I(6);if(A==null)break;_++,l[u+x]=A}return _&&(i.node.atime=Date.now()),_},write(i,l,u,f){if(!i.tty||!i.tty.eb.ub)throw new I(60);try{for(var _=0;_<f;_++)i.tty.eb.ub(i.tty,l[u+_])}catch{throw new I(29)}return f&&(i.node.mtime=i.node.ctime=Date.now()),_}},Ya={Bb(){e:{if(!Jo.length){var i=null;if(c){var l=Buffer.alloc(256),u=0,f=process.stdin.fd;try{u=b.readSync(f,l,0,256)}catch(_){if(_.toString().includes("EOF"))u=0;else throw _}0<u&&(i=l.slice(0,u).toString("utf-8"))}else globalThis.window?.prompt&&(i=window.prompt("Input: "),i!==null&&(i+=`
|
|
28
|
+
`));if(!i){i=null;break e}l=Array(Ht(i)+1),i=Ke(i,l,0,l.length),l.length=i,Jo=l}i=Jo.shift()}return i},ub(i,l){l===null||l===10?(y(At(i.output)),i.output=[]):l!=0&&i.output.push(l)},fsync(i){0<i.output?.length&&(y(At(i.output)),i.output=[])},hc(){return{bc:25856,dc:5,ac:191,cc:35387,$b:[3,28,127,21,4,0,1,0,17,19,26,0,18,15,23,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},ic(){return 0},jc(){return[24,80]}},Qa={ub(i,l){l===null||l===10?(v(At(i.output)),i.output=[]):l!=0&&i.output.push(l)},fsync(i){0<i.output?.length&&(v(At(i.output)),i.output=[])}},L={Wa:null,Xa(){return L.createNode(null,"/",16895,0)},createNode(i,l,u,f){if((u&61440)===24576||(u&61440)===4096)throw new I(63);return L.Wa||(L.Wa={dir:{node:{Ta:L.La.Ta,Ua:L.La.Ua,lookup:L.La.lookup,ib:L.La.ib,rename:L.La.rename,unlink:L.La.unlink,rmdir:L.La.rmdir,readdir:L.La.readdir,symlink:L.La.symlink},stream:{Va:L.Ma.Va}},file:{node:{Ta:L.La.Ta,Ua:L.La.Ua},stream:{Va:L.Ma.Va,read:L.Ma.read,write:L.Ma.write,jb:L.Ma.jb,kb:L.Ma.kb}},link:{node:{Ta:L.La.Ta,Ua:L.La.Ua,readlink:L.La.readlink},stream:{}},yb:{node:{Ta:L.La.Ta,Ua:L.La.Ua},stream:sl}}),u=Pi(i,l,u,f),xe(u.mode)?(u.La=L.Wa.dir.node,u.Ma=L.Wa.dir.stream,u.Na={}):(u.mode&61440)===32768?(u.La=L.Wa.file.node,u.Ma=L.Wa.file.stream,u.Ra=0,u.Na=null):(u.mode&61440)===40960?(u.La=L.Wa.link.node,u.Ma=L.Wa.link.stream):(u.mode&61440)===8192&&(u.La=L.Wa.yb.node,u.Ma=L.Wa.yb.stream),u.atime=u.mtime=u.ctime=Date.now(),i&&(i.Na[l]=u,i.atime=i.mtime=i.ctime=u.atime),u},fc(i){return i.Na?i.Na.subarray?i.Na.subarray(0,i.Ra):new Uint8Array(i.Na):new Uint8Array(0)},La:{Ta(i){var l={};return l.dev=(i.mode&61440)===8192?i.id:1,l.ino=i.id,l.mode=i.mode,l.nlink=1,l.uid=0,l.gid=0,l.rdev=i.rdev,xe(i.mode)?l.size=4096:(i.mode&61440)===32768?l.size=i.Ra:(i.mode&61440)===40960?l.size=i.link.length:l.size=0,l.atime=new Date(i.atime),l.mtime=new Date(i.mtime),l.ctime=new Date(i.ctime),l.blksize=4096,l.blocks=Math.ceil(l.size/l.blksize),l},Ua(i,l){for(var u of["mode","atime","mtime","ctime"])l[u]!=null&&(i[u]=l[u]);l.size!==void 0&&(l=l.size,i.Ra!=l&&(l==0?(i.Na=null,i.Ra=0):(u=i.Na,i.Na=new Uint8Array(l),u&&i.Na.set(u.subarray(0,Math.min(l,i.Ra))),i.Ra=l)))},lookup(){throw L.nb||(L.nb=new I(44),L.nb.stack="<generic error, no stack>"),L.nb},ib(i,l,u,f){return L.createNode(i,l,u,f)},rename(i,l,u){try{var f=Et(l,u)}catch{}if(f){if(xe(i.mode))for(var _ in f.Na)throw new I(55);Xo(f)}delete i.parent.Na[i.name],l.Na[u]=i,i.name=u,l.ctime=l.mtime=i.parent.ctime=i.parent.mtime=Date.now()},unlink(i,l){delete i.Na[l],i.ctime=i.mtime=Date.now()},rmdir(i,l){var u=Et(i,l),f;for(f in u.Na)throw new I(55);delete i.Na[l],i.ctime=i.mtime=Date.now()},readdir(i){return[".","..",...Object.keys(i.Na)]},symlink(i,l,u){return i=L.createNode(i,l,41471,0),i.link=u,i},readlink(i){if((i.mode&61440)!==40960)throw new I(28);return i.link}},Ma:{read(i,l,u,f,_){var x=i.node.Na;if(_>=i.node.Ra)return 0;if(i=Math.min(i.node.Ra-_,f),8<i&&x.subarray)l.set(x.subarray(_,_+i),u);else for(f=0;f<i;f++)l[u+f]=x[_+f];return i},write(i,l,u,f,_,x){if(l.buffer===D.buffer&&(x=!1),!f)return 0;if(i=i.node,i.mtime=i.ctime=Date.now(),l.subarray&&(!i.Na||i.Na.subarray)){if(x)return i.Na=l.subarray(u,u+f),i.Ra=f;if(i.Ra===0&&_===0)return i.Na=l.slice(u,u+f),i.Ra=f;if(_+f<=i.Ra)return i.Na.set(l.subarray(u,u+f),_),f}x=_+f;var A=i.Na?i.Na.length:0;if(A>=x||(x=Math.max(x,A*(1048576>A?2:1.125)>>>0),A!=0&&(x=Math.max(x,256)),A=i.Na,i.Na=new Uint8Array(x),0<i.Ra&&i.Na.set(A.subarray(0,i.Ra),0)),i.Na.subarray&&l.subarray)i.Na.set(l.subarray(u,u+f),_);else for(x=0;x<f;x++)i.Na[_+x]=l[u+x];return i.Ra=Math.max(i.Ra,_+f),f},Va(i,l,u){if(u===1?l+=i.position:u===2&&(i.node.mode&61440)===32768&&(l+=i.node.Ra),0>l)throw new I(28);return l},jb(i,l,u,f,_){if((i.node.mode&61440)!==32768)throw new I(43);if(i=i.node.Na,_&2||!i||i.buffer!==D.buffer){_=!0,f=65536*Math.ceil(l/65536);var x=Bi(65536,f);if(x&&N.fill(0,x,x+f),f=x,!f)throw new I(48);i&&((0<u||u+l<i.length)&&(i.subarray?i=i.subarray(u,u+l):i=Array.prototype.slice.call(i,u,u+l)),D.set(i,f))}else _=!1,f=i.byteOffset;return{Xb:f,Eb:_}},kb(i,l,u,f){return L.Ma.write(i,l,0,f,u,!1),0}}},ki=(i,l)=>{var u=0;return i&&(u|=365),l&&(u|=146),u},Ko=null,vi={},Jt=[],Xa=1,_t=null,xi=!1,Ti=!0,I=class{name="ErrnoError";constructor(i){this.Pa=i}},Za=class{hb={};node=null;get flags(){return this.hb.flags}set flags(i){this.hb.flags=i}get position(){return this.hb.position}set position(i){this.hb.position=i}},el=class{La={};Ma={};bb=null;constructor(i,l,u,f){i||=this,this.parent=i,this.Xa=i.Xa,this.id=Xa++,this.name=l,this.mode=u,this.rdev=f,this.atime=this.mtime=this.ctime=Date.now()}get read(){return(this.mode&365)===365}set read(i){i?this.mode|=365:this.mode&=-366}get write(){return(this.mode&146)===146}set write(i){i?this.mode|=146:this.mode&=-147}};function Fe(i,l={}){if(!i)throw new I(44);l.pb??(l.pb=!0),i.charAt(0)==="/"||(i="//"+i);var u=0;e:for(;40>u;u++){i=i.split("/").filter($=>!!$);for(var f=Ko,_="/",x=0;x<i.length;x++){var A=x===i.length-1;if(A&&l.parent)break;if(i[x]!==".")if(i[x]==="..")if(_=ot(_),f===f.parent){i=_+"/"+i.slice(x+1).join("/"),u--;continue e}else f=f.parent;else{_=He(_+"/"+i[x]);try{f=Et(f,i[x])}catch($){if($?.Pa===44&&A&&l.Wb)return{path:_};throw $}if(!f.bb||A&&!l.pb||(f=f.bb.root),(f.mode&61440)===40960&&(!A||l.ab)){if(!f.La.readlink)throw new I(52);f=f.La.readlink(f),f.charAt(0)==="/"||(f=ot(_)+"/"+f),i=f+"/"+i.slice(x+1).join("/");continue e}}}return{path:_,node:f}}throw new I(32)}function Yo(i){for(var l;;){if(i===i.parent)return i=i.Xa.Db,l?i[i.length-1]!=="/"?`${i}/${l}`:i+l:i;l=l?`${i.name}/${l}`:i.name,i=i.parent}}function Qo(i,l){for(var u=0,f=0;f<l.length;f++)u=(u<<5)-u+l.charCodeAt(f)|0;return(i+u>>>0)%_t.length}function Xo(i){var l=Qo(i.parent.id,i.name);if(_t[l]===i)_t[l]=i.cb;else for(l=_t[l];l;){if(l.cb===i){l.cb=i.cb;break}l=l.cb}}function Et(i,l){var u=xe(i.mode)?(u=Kt(i,"x"))?u:i.La.lookup?0:2:54;if(u)throw new I(u);for(u=_t[Qo(i.id,l)];u;u=u.cb){var f=u.name;if(u.parent.id===i.id&&f===l)return u}return i.La.lookup(i,l)}function Pi(i,l,u,f){return i=new el(i,l,u,f),l=Qo(i.parent.id,i.name),i.cb=_t[l],_t[l]=i}function xe(i){return(i&61440)===16384}function Kt(i,l){return Ti?0:l.includes("r")&&!(i.mode&292)||l.includes("w")&&!(i.mode&146)||l.includes("x")&&!(i.mode&73)?2:0}function Mi(i,l){if(!xe(i.mode))return 54;try{return Et(i,l),20}catch{}return Kt(i,"wx")}function Ai(i,l,u){try{var f=Et(i,l)}catch(_){return _.Pa}if(i=Kt(i,"wx"))return i;if(u){if(!xe(f.mode))return 54;if(f===f.parent||Yo(f)==="/")return 10}else if(xe(f.mode))return 31;return 0}function js(i){if(!i)throw new I(63);return i}function we(i){if(i=Jt[i],!i)throw new I(8);return i}function Ei(i,l=-1){if(i=Object.assign(new Za,i),l==-1)e:{for(l=0;4096>=l;l++)if(!Jt[l])break e;throw new I(33)}return i.fd=l,Jt[l]=i}function tl(i,l=-1){return i=Ei(i,l),i.Ma?.ec?.(i),i}function Zo(i,l,u){var f=i?.Ma.Ua;i=f?i:l,f??=l.La.Ua,js(f),f(i,u)}var sl={open(i){i.Ma=vi[i.node.rdev].Ma,i.Ma.open?.(i)},Va(){throw new I(70)}};function en(i,l){vi[i]={Ma:l}}function Di(i,l){var u=l==="/";if(u&&Ko)throw new I(10);if(!u&&l){var f=Fe(l,{pb:!1});if(l=f.path,f=f.node,f.bb)throw new I(10);if(!xe(f.mode))throw new I(54)}l={type:i,kc:{},Db:l,Vb:[]},i=i.Xa(l),i.Xa=l,l.root=i,u?Ko=i:f&&(f.bb=l,f.Xa&&f.Xa.Vb.push(l))}function $s(i,l,u){var f=Fe(i,{parent:!0}).node;if(i=yt(i),!i)throw new I(28);if(i==="."||i==="..")throw new I(20);var _=Mi(f,i);if(_)throw new I(_);if(!f.La.ib)throw new I(63);return f.La.ib(f,i,l,u)}function ol(i,l=438){return $s(i,l&4095|32768,0)}function Ye(i,l=511){return $s(i,l&1023|16384,0)}function Ls(i,l,u){typeof u>"u"&&(u=l,l=438),$s(i,l|8192,u)}function tn(i,l){if(!Je(i))throw new I(44);var u=Fe(l,{parent:!0}).node;if(!u)throw new I(44);l=yt(l);var f=Mi(u,l);if(f)throw new I(f);if(!u.La.symlink)throw new I(63);u.La.symlink(u,l,i)}function Ii(i){var l=Fe(i,{parent:!0}).node;i=yt(i);var u=Et(l,i),f=Ai(l,i,!0);if(f)throw new I(f);if(!l.La.rmdir)throw new I(63);if(u.bb)throw new I(10);l.La.rmdir(l,i),Xo(u)}function Oi(i){var l=Fe(i,{parent:!0}).node;if(!l)throw new I(44);i=yt(i);var u=Et(l,i),f=Ai(l,i,!1);if(f)throw new I(f);if(!l.La.unlink)throw new I(63);if(u.bb)throw new I(10);l.La.unlink(l,i),Xo(u)}function cs(i,l){return i=Fe(i,{ab:!l}).node,js(i.La.Ta)(i)}function Ui(i,l,u,f){Zo(i,l,{mode:u&4095|l.mode&-4096,ctime:Date.now(),Lb:f})}function qs(i,l){i=typeof i=="string"?Fe(i,{ab:!0}).node:i,Ui(null,i,l)}function Ri(i,l,u){if(xe(l.mode))throw new I(31);if((l.mode&61440)!==32768)throw new I(28);var f=Kt(l,"w");if(f)throw new I(f);Zo(i,l,{size:u,timestamp:Date.now()})}function Yt(i,l,u=438){if(i==="")throw new I(44);if(typeof l=="string"){var f={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090}[l];if(typeof f>"u")throw Error(`Unknown file open mode: ${l}`);l=f}if(u=l&64?u&4095|32768:0,typeof i=="object")f=i;else{var _=i.endsWith("/"),x=Fe(i,{ab:!(l&131072),Wb:!0});f=x.node,i=x.path}if(x=!1,l&64)if(f){if(l&128)throw new I(20)}else{if(_)throw new I(31);f=$s(i,u|511,0),x=!0}if(!f)throw new I(44);if((f.mode&61440)===8192&&(l&=-513),l&65536&&!xe(f.mode))throw new I(54);if(!x&&(f?(f.mode&61440)===40960?_=32:(_=["r","w","rw"][l&3],l&512&&(_+="w"),_=xe(f.mode)&&(_!=="r"||l&576)?31:Kt(f,_)):_=44,_))throw new I(_);return l&512&&!x&&(_=f,_=typeof _=="string"?Fe(_,{ab:!0}).node:_,Ri(null,_,0)),l=Ei({node:f,path:Yo(f),flags:l&-131713,seekable:!0,position:0,Ma:f.Ma,Yb:[],error:!1}),l.Ma.open&&l.Ma.open(l),x&&qs(f,u&511),l}function sn(i){if(i.fd===null)throw new I(8);i.rb&&(i.rb=null);try{i.Ma.close&&i.Ma.close(i)}catch(l){throw l}finally{Jt[i.fd]=null}i.fd=null}function Fi(i,l,u){if(i.fd===null)throw new I(8);if(!i.seekable||!i.Ma.Va)throw new I(70);if(u!=0&&u!=1&&u!=2)throw new I(28);i.position=i.Ma.Va(i,l,u),i.Yb=[]}function Ni(i,l,u,f,_){if(0>f||0>_)throw new I(28);if(i.fd===null)throw new I(8);if((i.flags&2097155)===1)throw new I(8);if(xe(i.node.mode))throw new I(31);if(!i.Ma.read)throw new I(28);var x=typeof _<"u";if(!x)_=i.position;else if(!i.seekable)throw new I(70);return l=i.Ma.read(i,l,u,f,_),x||(i.position+=l),l}function ji(i,l,u,f,_){if(0>f||0>_)throw new I(28);if(i.fd===null)throw new I(8);if((i.flags&2097155)===0)throw new I(8);if(xe(i.node.mode))throw new I(31);if(!i.Ma.write)throw new I(28);i.seekable&&i.flags&1024&&Fi(i,0,2);var x=typeof _<"u";if(!x)_=i.position;else if(!i.seekable)throw new I(70);return l=i.Ma.write(i,l,u,f,_,void 0),x||(i.position+=l),l}function nl(i){var l=l||0,u="binary";u!=="utf8"&&u!=="binary"&&Ae(`Invalid encoding type "${u}"`),l=Yt(i,l),i=cs(i).size;var f=new Uint8Array(i);return Ni(l,f,0,i,0),u==="utf8"&&(f=At(f)),sn(l),f}function bt(i,l,u){i=He("/dev/"+i);var f=ki(!!l,!!u);bt.Cb??(bt.Cb=64);var _=bt.Cb++<<8|0;en(_,{open(x){x.seekable=!1},close(){u?.buffer?.length&&u(10)},read(x,A,$,Y){for(var q=0,se=0;se<Y;se++){try{var he=l()}catch{throw new I(29)}if(he===void 0&&q===0)throw new I(6);if(he==null)break;q++,A[$+se]=he}return q&&(x.node.atime=Date.now()),q},write(x,A,$,Y){for(var q=0;q<Y;q++)try{u(A[$+q])}catch{throw new I(29)}return Y&&(x.node.mtime=x.node.ctime=Date.now()),q}}),Ls(i,f,_)}var te={};function Dt(i,l,u){if(l.charAt(0)==="/")return l;if(i=i===-100?"/":we(i).path,l.length==0){if(!u)throw new I(44);return i}return i+"/"+l}function Gs(i,l){W[i>>2]=l.dev,W[i+4>>2]=l.mode,W[i+8>>2]=l.nlink,W[i+12>>2]=l.uid,W[i+16>>2]=l.gid,W[i+20>>2]=l.rdev,Z[i+24>>3]=BigInt(l.size),K[i+32>>2]=4096,K[i+36>>2]=l.blocks;var u=l.atime.getTime(),f=l.mtime.getTime(),_=l.ctime.getTime();return Z[i+40>>3]=BigInt(Math.floor(u/1e3)),W[i+48>>2]=u%1e3*1e6,Z[i+56>>3]=BigInt(Math.floor(f/1e3)),W[i+64>>2]=f%1e3*1e6,Z[i+72>>3]=BigInt(Math.floor(_/1e3)),W[i+80>>2]=_%1e3*1e6,Z[i+88>>3]=BigInt(l.ino),0}var Bs=void 0,zs=()=>{var i=K[+Bs>>2];return Bs+=4,i},on=0,il=[0,31,60,91,121,152,182,213,244,274,305,335],rl=[0,31,59,90,120,151,181,212,243,273,304,334],us={},$i=i=>{M=i,st||0<on||(n.onExit?.(i),P=!0),m(i,new Mt(i))},al=i=>{if(!P)try{i()}catch(l){l instanceof Mt||l=="unwind"||m(1,l)}finally{if(!(st||0<on))try{M=i=M,$i(i)}catch(l){l instanceof Mt||l=="unwind"||m(1,l)}}},nn={},Li=()=>{if(!rn){var i={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(globalThis.navigator?.language??"C").replace("-","_")+".UTF-8",_:h||"./this.program"},l;for(l in nn)nn[l]===void 0?delete i[l]:i[l]=nn[l];var u=[];for(l in i)u.push(`${l}=${i[l]}`);rn=u}return rn},rn,ll=(i,l,u,f)=>{var _={string:q=>{var se=0;if(q!=null&&q!==0){se=Ht(q)+1;var he=Ot(se);Ke(q,N,he,se),se=he}return se},array:q=>{var se=Ot(q.length);return D.set(q,se),se}};i=n["_"+i];var x=[],A=0;if(f)for(var $=0;$<f.length;$++){var Y=_[u[$]];Y?(A===0&&(A=Js()),x[$]=Y(f[$])):x[$]=f[$]}return u=i(...x),u=(function(q){return A!==0&&Hs(A),l==="string"?ne(q):l==="boolean"?!!q:q})(u)},Ws=i=>{var l=Ht(i)+1,u=Vs(l);return u&&Ke(i,N,u,l),u},It,an=[],Ct=i=>{It.delete(wt.get(i)),wt.set(i,null),an.push(i)},qi=i=>{let l=i.length;return[l%128|128,l>>7,...i]},cl={i:127,p:127,j:126,f:125,d:124,e:111},Gi=i=>qi(Array.from(i,l=>cl[l])),ds=(i,l)=>{if(!It){It=new WeakMap;var u=wt.length;if(It)for(var f=0;f<0+u;f++){var _=wt.get(f);_&&It.set(_,f)}}if(u=It.get(i)||0)return u;u=an.length?an.pop():wt.grow(1);try{wt.set(u,i)}catch(x){if(!(x instanceof TypeError))throw x;l=Uint8Array.of(0,97,115,109,1,0,0,0,1,...qi([1,96,...Gi(l.slice(1)),...Gi(l[0]==="v"?"":l[0])]),2,7,1,1,101,1,102,0,0,7,5,1,1,102,0,0),l=new WebAssembly.Module(l),l=new WebAssembly.Instance(l,{e:{f:i}}).exports.f,wt.set(u,l)}return It.set(i,u),u};if(_t=Array(4096),Di(L,"/"),Ye("/tmp"),Ye("/home"),Ye("/home/web_user"),(function(){Ye("/dev"),en(259,{read:()=>0,write:(f,_,x,A)=>A,Va:()=>0}),Ls("/dev/null",259),Si(1280,Ya),Si(1536,Qa),Ls("/dev/tty",1280),Ls("/dev/tty1",1536);var i=new Uint8Array(1024),l=0,u=()=>(l===0&&(le(i),l=i.byteLength),i[--l]);bt("random",u),bt("urandom",u),Ye("/dev/shm"),Ye("/dev/shm/tmp")})(),(function(){Ye("/proc");var i=Ye("/proc/self");Ye("/proc/self/fd"),Di({Xa(){var l=Pi(i,"fd",16895,73);return l.Ma={Va:L.Ma.Va},l.La={lookup(u,f){u=+f;var _=we(u);return u={parent:null,Xa:{Db:"fake"},La:{readlink:()=>_.path},id:u+1},u.parent=u},readdir(){return Array.from(Jt.entries()).filter(([,u])=>u).map(([u])=>u.toString())}},l}},"/proc/self/fd")})(),n.noExitRuntime&&(st=n.noExitRuntime),n.print&&(y=n.print),n.printErr&&(v=n.printErr),n.wasmBinary&&(C=n.wasmBinary),n.thisProgram&&(h=n.thisProgram),n.preInit)for(typeof n.preInit=="function"&&(n.preInit=[n.preInit]);0<n.preInit.length;)n.preInit.shift()();n.stackSave=()=>Js(),n.stackRestore=i=>Hs(i),n.stackAlloc=i=>Ot(i),n.cwrap=(i,l,u,f)=>{var _=!u||u.every(x=>x==="number"||x==="boolean");return l!=="string"&&_&&!f?n["_"+i]:(...x)=>ll(i,l,u,x)},n.addFunction=ds,n.removeFunction=Ct,n.UTF8ToString=ne,n.stringToNewUTF8=Ws,n.writeArrayToMemory=(i,l)=>{D.set(i,l)};var Vs,ps,Bi,zi,Hs,Ot,Js,Ks,wt,ul={a:(i,l,u,f)=>Ae(`Assertion failed: ${ne(i)}, at: `+[l?ne(l):"unknown filename",u,f?ne(f):"unknown function"]),i:function(i,l){try{return i=ne(i),qs(i,l),0}catch(u){if(typeof te>"u"||u.name!=="ErrnoError")throw u;return-u.Pa}},L:function(i,l,u){try{if(l=ne(l),l=Dt(i,l),u&-8)return-28;var f=Fe(l,{ab:!0}).node;return f?(i="",u&4&&(i+="r"),u&2&&(i+="w"),u&1&&(i+="x"),i&&Kt(f,i)?-2:0):-44}catch(_){if(typeof te>"u"||_.name!=="ErrnoError")throw _;return-_.Pa}},j:function(i,l){try{var u=we(i);return Ui(u,u.node,l,!1),0}catch(f){if(typeof te>"u"||f.name!=="ErrnoError")throw f;return-f.Pa}},h:function(i){try{var l=we(i);return Zo(l,l.node,{timestamp:Date.now(),Lb:!1}),0}catch(u){if(typeof te>"u"||u.name!=="ErrnoError")throw u;return-u.Pa}},b:function(i,l,u){Bs=u;try{var f=we(i);switch(l){case 0:var _=zs();if(0>_)break;for(;Jt[_];)_++;return tl(f,_).fd;case 1:case 2:return 0;case 3:return f.flags;case 4:return _=zs(),f.flags|=_,0;case 12:return _=zs(),H[_+0>>1]=2,0;case 13:case 14:return 0}return-28}catch(x){if(typeof te>"u"||x.name!=="ErrnoError")throw x;return-x.Pa}},g:function(i,l){try{var u=we(i),f=u.node,_=u.Ma.Ta;i=_?u:f,_??=f.La.Ta,js(_);var x=_(i);return Gs(l,x)}catch(A){if(typeof te>"u"||A.name!=="ErrnoError")throw A;return-A.Pa}},H:function(i,l){l=-9007199254740992>l||9007199254740992<l?NaN:Number(l);try{if(isNaN(l))return-61;var u=we(i);if(0>l||(u.flags&2097155)===0)throw new I(28);return Ri(u,u.node,l),0}catch(f){if(typeof te>"u"||f.name!=="ErrnoError")throw f;return-f.Pa}},G:function(i,l){try{if(l===0)return-28;var u=Ht("/")+1;return l<u?-68:(Ke("/",N,i,l),u)}catch(f){if(typeof te>"u"||f.name!=="ErrnoError")throw f;return-f.Pa}},K:function(i,l){try{return i=ne(i),Gs(l,cs(i,!0))}catch(u){if(typeof te>"u"||u.name!=="ErrnoError")throw u;return-u.Pa}},C:function(i,l,u){try{return l=ne(l),l=Dt(i,l),Ye(l,u),0}catch(f){if(typeof te>"u"||f.name!=="ErrnoError")throw f;return-f.Pa}},J:function(i,l,u,f){try{l=ne(l);var _=f&256;return l=Dt(i,l,f&4096),Gs(u,_?cs(l,!0):cs(l))}catch(x){if(typeof te>"u"||x.name!=="ErrnoError")throw x;return-x.Pa}},x:function(i,l,u,f){Bs=f;try{l=ne(l),l=Dt(i,l);var _=f?zs():0;return Yt(l,u,_).fd}catch(x){if(typeof te>"u"||x.name!=="ErrnoError")throw x;return-x.Pa}},v:function(i,l,u,f){try{if(l=ne(l),l=Dt(i,l),0>=f)return-28;var _=Fe(l).node;if(!_)throw new I(44);if(!_.La.readlink)throw new I(28);var x=_.La.readlink(_),A=Math.min(f,Ht(x)),$=D[u+A];return Ke(x,N,u,f+1),D[u+A]=$,A}catch(Y){if(typeof te>"u"||Y.name!=="ErrnoError")throw Y;return-Y.Pa}},u:function(i){try{return i=ne(i),Ii(i),0}catch(l){if(typeof te>"u"||l.name!=="ErrnoError")throw l;return-l.Pa}},f:function(i,l){try{return i=ne(i),Gs(l,cs(i))}catch(u){if(typeof te>"u"||u.name!=="ErrnoError")throw u;return-u.Pa}},r:function(i,l,u){try{if(l=ne(l),l=Dt(i,l),u)if(u===512)Ii(l);else return-28;else Oi(l);return 0}catch(f){if(typeof te>"u"||f.name!=="ErrnoError")throw f;return-f.Pa}},q:function(i,l,u){try{l=ne(l),l=Dt(i,l,!0);var f=Date.now(),_,x;if(u){var A=W[u>>2]+4294967296*K[u+4>>2],$=K[u+8>>2];$==1073741823?_=f:$==1073741822?_=null:_=1e3*A+$/1e6,u+=16,A=W[u>>2]+4294967296*K[u+4>>2],$=K[u+8>>2],$==1073741823?x=f:$==1073741822?x=null:x=1e3*A+$/1e6}else x=_=f;if((x??_)!==null){i=_;var Y=Fe(l,{ab:!0}).node;js(Y.La.Ua)(Y,{atime:i,mtime:x})}return 0}catch(q){if(typeof te>"u"||q.name!=="ErrnoError")throw q;return-q.Pa}},m:()=>Ae(""),l:()=>{st=!1,on=0},A:function(i,l){i=-9007199254740992>i||9007199254740992<i?NaN:Number(i),i=new Date(1e3*i),K[l>>2]=i.getSeconds(),K[l+4>>2]=i.getMinutes(),K[l+8>>2]=i.getHours(),K[l+12>>2]=i.getDate(),K[l+16>>2]=i.getMonth(),K[l+20>>2]=i.getFullYear()-1900,K[l+24>>2]=i.getDay();var u=i.getFullYear();K[l+28>>2]=(u%4!==0||u%100===0&&u%400!==0?rl:il)[i.getMonth()]+i.getDate()-1|0,K[l+36>>2]=-(60*i.getTimezoneOffset()),u=new Date(i.getFullYear(),6,1).getTimezoneOffset();var f=new Date(i.getFullYear(),0,1).getTimezoneOffset();K[l+32>>2]=(u!=f&&i.getTimezoneOffset()==Math.min(f,u))|0},y:function(i,l,u,f,_,x,A){_=-9007199254740992>_||9007199254740992<_?NaN:Number(_);try{var $=we(f);if((l&2)!==0&&(u&2)===0&&($.flags&2097155)!==2)throw new I(2);if(($.flags&2097155)===1)throw new I(2);if(!$.Ma.jb)throw new I(43);if(!i)throw new I(28);var Y=$.Ma.jb($,i,_,l,u),q=Y.Xb;return K[x>>2]=Y.Eb,W[A>>2]=q,0}catch(se){if(typeof te>"u"||se.name!=="ErrnoError")throw se;return-se.Pa}},z:function(i,l,u,f,_,x){x=-9007199254740992>x||9007199254740992<x?NaN:Number(x);try{var A=we(_);if(u&2){if(u=x,(A.node.mode&61440)!==32768)throw new I(43);if(!(f&2)){var $=N.slice(i,i+l);A.Ma.kb&&A.Ma.kb(A,$,u,l,f)}}}catch(Y){if(typeof te>"u"||Y.name!=="ErrnoError")throw Y;return-Y.Pa}},n:(i,l)=>{if(us[i]&&(clearTimeout(us[i].id),delete us[i]),!l)return 0;var u=setTimeout(()=>{delete us[i],al(()=>zi(i,performance.now()))},l);return us[i]={id:u,lc:l},0},B:(i,l,u,f)=>{var _=new Date().getFullYear(),x=new Date(_,0,1).getTimezoneOffset();_=new Date(_,6,1).getTimezoneOffset(),W[i>>2]=60*Math.max(x,_),K[l>>2]=+(x!=_),l=A=>{var $=Math.abs(A);return`UTC${0<=A?"-":"+"}${String(Math.floor($/60)).padStart(2,"0")}${String($%60).padStart(2,"0")}`},i=l(x),l=l(_),_<x?(Ke(i,N,u,17),Ke(l,N,f,17)):(Ke(i,N,f,17),Ke(l,N,u,17))},d:()=>Date.now(),s:()=>2147483648,c:()=>performance.now(),o:i=>{var l=N.length;if(i>>>=0,2147483648<i)return!1;for(var u=1;4>=u;u*=2){var f=l*(1+.2/u);f=Math.min(f,i+100663296);e:{f=(Math.min(2147483648,65536*Math.ceil(Math.max(i,f)/65536))-Ks.buffer.byteLength+65535)/65536|0;try{Ks.grow(f),Ue();var _=1;break e}catch{}_=void 0}if(_)return!0}return!1},E:(i,l)=>{var u=0,f=0,_;for(_ of Li()){var x=l+u;W[i+f>>2]=x,u+=Ke(_,N,x,1/0)+1,f+=4}return 0},F:(i,l)=>{var u=Li();W[i>>2]=u.length,i=0;for(var f of u)i+=Ht(f)+1;return W[l>>2]=i,0},e:function(i){try{var l=we(i);return sn(l),0}catch(u){if(typeof te>"u"||u.name!=="ErrnoError")throw u;return u.Pa}},p:function(i,l){try{var u=we(i);return D[l]=u.tty?2:xe(u.mode)?3:(u.mode&61440)===40960?7:4,H[l+2>>1]=0,Z[l+8>>3]=BigInt(0),Z[l+16>>3]=BigInt(0),0}catch(f){if(typeof te>"u"||f.name!=="ErrnoError")throw f;return f.Pa}},w:function(i,l,u,f){try{e:{var _=we(i);i=l;for(var x,A=l=0;A<u;A++){var $=W[i>>2],Y=W[i+4>>2];i+=8;var q=Ni(_,D,$,Y,x);if(0>q){var se=-1;break e}if(l+=q,q<Y)break;typeof x<"u"&&(x+=q)}se=l}return W[f>>2]=se,0}catch(he){if(typeof te>"u"||he.name!=="ErrnoError")throw he;return he.Pa}},D:function(i,l,u,f){l=-9007199254740992>l||9007199254740992<l?NaN:Number(l);try{if(isNaN(l))return 61;var _=we(i);return Fi(_,l,u),Z[f>>3]=BigInt(_.position),_.rb&&l===0&&u===0&&(_.rb=null),0}catch(x){if(typeof te>"u"||x.name!=="ErrnoError")throw x;return x.Pa}},I:function(i){try{var l=we(i);return l.Ma?.fsync?.(l)}catch(u){if(typeof te>"u"||u.name!=="ErrnoError")throw u;return u.Pa}},t:function(i,l,u,f){try{e:{var _=we(i);i=l;for(var x,A=l=0;A<u;A++){var $=W[i>>2],Y=W[i+4>>2];i+=8;var q=ji(_,D,$,Y,x);if(0>q){var se=-1;break e}if(l+=q,q<Y)break;typeof x<"u"&&(x+=q)}se=l}return W[f>>2]=se,0}catch(he){if(typeof te>"u"||he.name!=="ErrnoError")throw he;return he.Pa}},k:$i};function ln(){function i(){if(n.calledRun=!0,!P){if(!n.noFSInit&&!xi){var l,u;xi=!0,l??=n.stdin,u??=n.stdout,f??=n.stderr,l?bt("stdin",l):tn("/dev/tty","/dev/stdin"),u?bt("stdout",null,u):tn("/dev/tty","/dev/stdout"),f?bt("stderr",null,f):tn("/dev/tty1","/dev/stderr"),Yt("/dev/stdin",0),Yt("/dev/stdout",1),Yt("/dev/stderr",1)}if(cn.N(),Ti=!1,n.onRuntimeInitialized?.(),n.postRun)for(typeof n.postRun=="function"&&(n.postRun=[n.postRun]);n.postRun.length;){var f=n.postRun.shift();be.push(f)}fe(be)}}if(0<Ce)Re=ln;else{if(n.preRun)for(typeof n.preRun=="function"&&(n.preRun=[n.preRun]);n.preRun.length;)zt();fe(ls),0<Ce?Re=ln:n.setStatus?(n.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>n.setStatus(""),1),i()},1)):i()}}var cn;return(async function(){function i(u){return u=cn=u.exports,n._sqlite3_free=u.P,n._sqlite3_value_text=u.Q,n._sqlite3_prepare_v2=u.R,n._sqlite3_step=u.S,n._sqlite3_reset=u.T,n._sqlite3_exec=u.U,n._sqlite3_finalize=u.V,n._sqlite3_column_name=u.W,n._sqlite3_column_text=u.X,n._sqlite3_column_type=u.Y,n._sqlite3_errmsg=u.Z,n._sqlite3_clear_bindings=u._,n._sqlite3_value_blob=u.$,n._sqlite3_value_bytes=u.aa,n._sqlite3_value_double=u.ba,n._sqlite3_value_int=u.ca,n._sqlite3_value_type=u.da,n._sqlite3_result_blob=u.ea,n._sqlite3_result_double=u.fa,n._sqlite3_result_error=u.ga,n._sqlite3_result_int=u.ha,n._sqlite3_result_int64=u.ia,n._sqlite3_result_null=u.ja,n._sqlite3_result_text=u.ka,n._sqlite3_aggregate_context=u.la,n._sqlite3_column_count=u.ma,n._sqlite3_data_count=u.na,n._sqlite3_column_blob=u.oa,n._sqlite3_column_bytes=u.pa,n._sqlite3_column_double=u.qa,n._sqlite3_bind_blob=u.ra,n._sqlite3_bind_double=u.sa,n._sqlite3_bind_int=u.ta,n._sqlite3_bind_text=u.ua,n._sqlite3_bind_parameter_index=u.va,n._sqlite3_sql=u.wa,n._sqlite3_normalized_sql=u.xa,n._sqlite3_changes=u.ya,n._sqlite3_close_v2=u.za,n._sqlite3_create_function_v2=u.Aa,n._sqlite3_update_hook=u.Ba,n._sqlite3_open=u.Ca,Vs=n._malloc=u.Da,ps=n._free=u.Ea,n._RegisterExtensionFunctions=u.Fa,Bi=u.Ga,zi=u.Ha,Hs=u.Ia,Ot=u.Ja,Js=u.Ka,Ks=u.M,wt=u.O,Ue(),Ce--,n.monitorRunDependencies?.(Ce),Ce==0&&Re&&(u=Re,Re=null,u()),cn}Ce++,n.monitorRunDependencies?.(Ce);var l={a:ul};return n.instantiateWasm?new Promise(u=>{n.instantiateWasm(l,(f,_)=>{u(i(f,_))})}):(tt??=n.locateFile?n.locateFile("sql-wasm.wasm",g):g+"sql-wasm.wasm",i((await de(l)).instance))})(),ln(),s}),io)};typeof ao=="object"&&typeof Rt=="object"?(Rt.exports=ro,Rt.exports.default=ro):typeof define=="function"&&define.amd?define([],function(){return ro}):typeof ao=="object"&&(ao.Module=ro)});var mo=oe(it=>{"use strict";Object.defineProperty(it,"__esModule",{value:!0});it.utf8Count=Cc;it.utf8EncodeJs=Ir;it.utf8EncodeTE=Or;it.utf8Encode=kc;it.utf8DecodeJs=Ur;it.utf8DecodeTD=Rr;it.utf8Decode=Pc;function Cc(r){let e=r.length,t=0,s=0;for(;s<e;){let o=r.charCodeAt(s++);if((o&4294967168)===0){t++;continue}else if((o&4294965248)===0)t+=2;else{if(o>=55296&&o<=56319&&s<e){let n=r.charCodeAt(s);(n&64512)===56320&&(++s,o=((o&1023)<<10)+(n&1023)+65536)}(o&4294901760)===0?t+=3:t+=4}}return t}function Ir(r,e,t){let s=r.length,o=t,n=0;for(;n<s;){let a=r.charCodeAt(n++);if((a&4294967168)===0){e[o++]=a;continue}else if((a&4294965248)===0)e[o++]=a>>6&31|192;else{if(a>=55296&&a<=56319&&n<s){let d=r.charCodeAt(n);(d&64512)===56320&&(++n,a=((a&1023)<<10)+(d&1023)+65536)}(a&4294901760)===0?(e[o++]=a>>12&15|224,e[o++]=a>>6&63|128):(e[o++]=a>>18&7|240,e[o++]=a>>12&63|128,e[o++]=a>>6&63|128)}e[o++]=a&63|128}}var wc=new TextEncoder,Sc=50;function Or(r,e,t){wc.encodeInto(r,e.subarray(t))}function kc(r,e,t){r.length>Sc?Or(r,e,t):Ir(r,e,t)}var vc=4096;function Ur(r,e,t){let s=e,o=s+t,n=[],a="";for(;s<o;){let d=r[s++];if((d&128)===0)n.push(d);else if((d&224)===192){let c=r[s++]&63;n.push((d&31)<<6|c)}else if((d&240)===224){let c=r[s++]&63,h=r[s++]&63;n.push((d&31)<<12|c<<6|h)}else if((d&248)===240){let c=r[s++]&63,h=r[s++]&63,m=r[s++]&63,p=(d&7)<<18|c<<12|h<<6|m;p>65535&&(p-=65536,n.push(p>>>10&1023|55296),p=56320|p&1023),n.push(p)}else n.push(d);n.length>=vc&&(a+=String.fromCharCode(...n),n.length=0)}return n.length>0&&(a+=String.fromCharCode(...n)),a}var xc=new TextDecoder,Tc=200;function Rr(r,e,t){let s=r.subarray(e,e+t);return xc.decode(s)}function Pc(r,e,t){return t>Tc?Rr(r,e,t):Ur(r,e,t)}});var Fn=oe(ho=>{"use strict";Object.defineProperty(ho,"__esModule",{value:!0});ho.ExtData=void 0;var Rn=class{type;data;constructor(e,t){this.type=e,this.data=t}};ho.ExtData=Rn});var go=oe(fo=>{"use strict";Object.defineProperty(fo,"__esModule",{value:!0});fo.DecodeError=void 0;var Nn=class r extends Error{constructor(e){super(e);let t=Object.create(r.prototype);Object.setPrototypeOf(this,t),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:r.name})}};fo.DecodeError=Nn});var yo=oe(St=>{"use strict";Object.defineProperty(St,"__esModule",{value:!0});St.UINT32_MAX=void 0;St.setUint64=Mc;St.setInt64=Ac;St.getInt64=Ec;St.getUint64=Dc;St.UINT32_MAX=4294967295;function Mc(r,e,t){let s=t/4294967296,o=t;r.setUint32(e,s),r.setUint32(e+4,o)}function Ac(r,e,t){let s=Math.floor(t/4294967296),o=t;r.setUint32(e,s),r.setUint32(e+4,o)}function Ec(r,e){let t=r.getInt32(e),s=r.getUint32(e+4);return t*4294967296+s}function Dc(r,e){let t=r.getUint32(e),s=r.getUint32(e+4);return t*4294967296+s}});var jn=oe(Le=>{"use strict";Object.defineProperty(Le,"__esModule",{value:!0});Le.timestampExtension=Le.EXT_TIMESTAMP=void 0;Le.encodeTimeSpecToTimestamp=Nr;Le.encodeDateToTimeSpec=jr;Le.encodeTimestampExtension=$r;Le.decodeTimestampToTimeSpec=Lr;Le.decodeTimestampExtension=qr;var Ic=go(),Fr=yo();Le.EXT_TIMESTAMP=-1;var Oc=4294967296-1,Uc=17179869184-1;function Nr({sec:r,nsec:e}){if(r>=0&&e>=0&&r<=Uc)if(e===0&&r<=Oc){let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,r),t}else{let t=r/4294967296,s=r&4294967295,o=new Uint8Array(8),n=new DataView(o.buffer);return n.setUint32(0,e<<2|t&3),n.setUint32(4,s),o}else{let t=new Uint8Array(12),s=new DataView(t.buffer);return s.setUint32(0,e),(0,Fr.setInt64)(s,4,r),t}}function jr(r){let e=r.getTime(),t=Math.floor(e/1e3),s=(e-t*1e3)*1e6,o=Math.floor(s/1e9);return{sec:t+o,nsec:s-o*1e9}}function $r(r){if(r instanceof Date){let e=jr(r);return Nr(e)}else return null}function Lr(r){let e=new DataView(r.buffer,r.byteOffset,r.byteLength);switch(r.byteLength){case 4:return{sec:e.getUint32(0),nsec:0};case 8:{let t=e.getUint32(0),s=e.getUint32(4),o=(t&3)*4294967296+s,n=t>>>2;return{sec:o,nsec:n}}case 12:{let t=(0,Fr.getInt64)(e,4),s=e.getUint32(0);return{sec:t,nsec:s}}default:throw new Ic.DecodeError(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${r.length}`)}}function qr(r){let e=Lr(r);return new Date(e.sec*1e3+e.nsec/1e6)}Le.timestampExtension={type:Le.EXT_TIMESTAMP,encode:$r,decode:qr}});var Co=oe(bo=>{"use strict";Object.defineProperty(bo,"__esModule",{value:!0});bo.ExtensionCodec=void 0;var _o=Fn(),Rc=jn(),$n=class r{static defaultCodec=new r;__brand;builtInEncoders=[];builtInDecoders=[];encoders=[];decoders=[];constructor(){this.register(Rc.timestampExtension)}register({type:e,encode:t,decode:s}){if(e>=0)this.encoders[e]=t,this.decoders[e]=s;else{let o=-1-e;this.builtInEncoders[o]=t,this.builtInDecoders[o]=s}}tryToEncode(e,t){for(let s=0;s<this.builtInEncoders.length;s++){let o=this.builtInEncoders[s];if(o!=null){let n=o(e,t);if(n!=null){let a=-1-s;return new _o.ExtData(a,n)}}}for(let s=0;s<this.encoders.length;s++){let o=this.encoders[s];if(o!=null){let n=o(e,t);if(n!=null){let a=s;return new _o.ExtData(a,n)}}}return e instanceof _o.ExtData?e:null}decode(e,t,s){let o=t<0?this.builtInDecoders[-1-t]:this.decoders[t];return o?o(e,t,s):new _o.ExtData(t,e)}};bo.ExtensionCodec=$n});var qn=oe(Ln=>{"use strict";Object.defineProperty(Ln,"__esModule",{value:!0});Ln.ensureUint8Array=Nc;function Fc(r){return r instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&r instanceof SharedArrayBuffer}function Nc(r){return r instanceof Uint8Array?r:ArrayBuffer.isView(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):Fc(r)?new Uint8Array(r):Uint8Array.from(r)}});var Bn=oe(Qe=>{"use strict";Object.defineProperty(Qe,"__esModule",{value:!0});Qe.Encoder=Qe.DEFAULT_INITIAL_BUFFER_SIZE=Qe.DEFAULT_MAX_DEPTH=void 0;var Gr=mo(),jc=Co(),Br=yo(),$c=qn();Qe.DEFAULT_MAX_DEPTH=100;Qe.DEFAULT_INITIAL_BUFFER_SIZE=2048;var Gn=class r{extensionCodec;context;useBigInt64;maxDepth;initialBufferSize;sortKeys;forceFloat32;ignoreUndefined;forceIntegerToFloat;pos;view;bytes;entered=!1;constructor(e){this.extensionCodec=e?.extensionCodec??jc.ExtensionCodec.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.maxDepth=e?.maxDepth??Qe.DEFAULT_MAX_DEPTH,this.initialBufferSize=e?.initialBufferSize??Qe.DEFAULT_INITIAL_BUFFER_SIZE,this.sortKeys=e?.sortKeys??!1,this.forceFloat32=e?.forceFloat32??!1,this.ignoreUndefined=e?.ignoreUndefined??!1,this.forceIntegerToFloat=e?.forceIntegerToFloat??!1,this.pos=0,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}clone(){return new r({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,maxDepth:this.maxDepth,initialBufferSize:this.initialBufferSize,sortKeys:this.sortKeys,forceFloat32:this.forceFloat32,ignoreUndefined:this.ignoreUndefined,forceIntegerToFloat:this.forceIntegerToFloat})}reinitializeState(){this.pos=0}encodeSharedRef(e){if(this.entered)return this.clone().encodeSharedRef(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.subarray(0,this.pos)}finally{this.entered=!1}}encode(e){if(this.entered)return this.clone().encode(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.slice(0,this.pos)}finally{this.entered=!1}}doEncode(e,t){if(t>this.maxDepth)throw new Error(`Too deep objects in depth ${t}`);e==null?this.encodeNil():typeof e=="boolean"?this.encodeBoolean(e):typeof e=="number"?this.forceIntegerToFloat?this.encodeNumberAsFloat(e):this.encodeNumber(e):typeof e=="string"?this.encodeString(e):this.useBigInt64&&typeof e=="bigint"?this.encodeBigInt64(e):this.encodeObject(e,t)}ensureBufferSizeToWrite(e){let t=this.pos+e;this.view.byteLength<t&&this.resizeBuffer(t*2)}resizeBuffer(e){let t=new ArrayBuffer(e),s=new Uint8Array(t),o=new DataView(t);s.set(this.bytes),this.view=o,this.bytes=s}encodeNil(){this.writeU8(192)}encodeBoolean(e){e===!1?this.writeU8(194):this.writeU8(195)}encodeNumber(e){!this.forceIntegerToFloat&&Number.isSafeInteger(e)?e>=0?e<128?this.writeU8(e):e<256?(this.writeU8(204),this.writeU8(e)):e<65536?(this.writeU8(205),this.writeU16(e)):e<4294967296?(this.writeU8(206),this.writeU32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(207),this.writeU64(e)):e>=-32?this.writeU8(224|e+32):e>=-128?(this.writeU8(208),this.writeI8(e)):e>=-32768?(this.writeU8(209),this.writeI16(e)):e>=-2147483648?(this.writeU8(210),this.writeI32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(211),this.writeI64(e)):this.encodeNumberAsFloat(e)}encodeNumberAsFloat(e){this.forceFloat32?(this.writeU8(202),this.writeF32(e)):(this.writeU8(203),this.writeF64(e))}encodeBigInt64(e){e>=BigInt(0)?(this.writeU8(207),this.writeBigUint64(e)):(this.writeU8(211),this.writeBigInt64(e))}writeStringHeader(e){if(e<32)this.writeU8(160+e);else if(e<256)this.writeU8(217),this.writeU8(e);else if(e<65536)this.writeU8(218),this.writeU16(e);else if(e<4294967296)this.writeU8(219),this.writeU32(e);else throw new Error(`Too long string: ${e} bytes in UTF-8`)}encodeString(e){let s=(0,Gr.utf8Count)(e);this.ensureBufferSizeToWrite(5+s),this.writeStringHeader(s),(0,Gr.utf8Encode)(e,this.bytes,this.pos),this.pos+=s}encodeObject(e,t){let s=this.extensionCodec.tryToEncode(e,this.context);if(s!=null)this.encodeExtension(s);else if(Array.isArray(e))this.encodeArray(e,t);else if(ArrayBuffer.isView(e))this.encodeBinary(e);else if(typeof e=="object")this.encodeMap(e,t);else throw new Error(`Unrecognized object: ${Object.prototype.toString.apply(e)}`)}encodeBinary(e){let t=e.byteLength;if(t<256)this.writeU8(196),this.writeU8(t);else if(t<65536)this.writeU8(197),this.writeU16(t);else if(t<4294967296)this.writeU8(198),this.writeU32(t);else throw new Error(`Too large binary: ${t}`);let s=(0,$c.ensureUint8Array)(e);this.writeU8a(s)}encodeArray(e,t){let s=e.length;if(s<16)this.writeU8(144+s);else if(s<65536)this.writeU8(220),this.writeU16(s);else if(s<4294967296)this.writeU8(221),this.writeU32(s);else throw new Error(`Too large array: ${s}`);for(let o of e)this.doEncode(o,t+1)}countWithoutUndefined(e,t){let s=0;for(let o of t)e[o]!==void 0&&s++;return s}encodeMap(e,t){let s=Object.keys(e);this.sortKeys&&s.sort();let o=this.ignoreUndefined?this.countWithoutUndefined(e,s):s.length;if(o<16)this.writeU8(128+o);else if(o<65536)this.writeU8(222),this.writeU16(o);else if(o<4294967296)this.writeU8(223),this.writeU32(o);else throw new Error(`Too large map object: ${o}`);for(let n of s){let a=e[n];this.ignoreUndefined&&a===void 0||(this.encodeString(n),this.doEncode(a,t+1))}}encodeExtension(e){if(typeof e.data=="function"){let s=e.data(this.pos+6),o=s.length;if(o>=4294967296)throw new Error(`Too large extension object: ${o}`);this.writeU8(201),this.writeU32(o),this.writeI8(e.type),this.writeU8a(s);return}let t=e.data.length;if(t===1)this.writeU8(212);else if(t===2)this.writeU8(213);else if(t===4)this.writeU8(214);else if(t===8)this.writeU8(215);else if(t===16)this.writeU8(216);else if(t<256)this.writeU8(199),this.writeU8(t);else if(t<65536)this.writeU8(200),this.writeU16(t);else if(t<4294967296)this.writeU8(201),this.writeU32(t);else throw new Error(`Too large extension object: ${t}`);this.writeI8(e.type),this.writeU8a(e.data)}writeU8(e){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,e),this.pos++}writeU8a(e){let t=e.length;this.ensureBufferSizeToWrite(t),this.bytes.set(e,this.pos),this.pos+=t}writeI8(e){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,e),this.pos++}writeU16(e){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,e),this.pos+=2}writeI16(e){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,e),this.pos+=2}writeU32(e){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,e),this.pos+=4}writeI32(e){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,e),this.pos+=4}writeF32(e){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,e),this.pos+=4}writeF64(e){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,e),this.pos+=8}writeU64(e){this.ensureBufferSizeToWrite(8),(0,Br.setUint64)(this.view,this.pos,e),this.pos+=8}writeI64(e){this.ensureBufferSizeToWrite(8),(0,Br.setInt64)(this.view,this.pos,e),this.pos+=8}writeBigUint64(e){this.ensureBufferSizeToWrite(8),this.view.setBigUint64(this.pos,e),this.pos+=8}writeBigInt64(e){this.ensureBufferSizeToWrite(8),this.view.setBigInt64(this.pos,e),this.pos+=8}};Qe.Encoder=Gn});var zr=oe(zn=>{"use strict";Object.defineProperty(zn,"__esModule",{value:!0});zn.encode=qc;var Lc=Bn();function qc(r,e){return new Lc.Encoder(e).encodeSharedRef(r)}});var Wr=oe(Wn=>{"use strict";Object.defineProperty(Wn,"__esModule",{value:!0});Wn.prettyByte=Gc;function Gc(r){return`${r<0?"-":""}0x${Math.abs(r).toString(16).padStart(2,"0")}`}});var Vr=oe(wo=>{"use strict";Object.defineProperty(wo,"__esModule",{value:!0});wo.CachedKeyDecoder=void 0;var Bc=mo(),zc=16,Wc=16,Vn=class{hit=0;miss=0;caches;maxKeyLength;maxLengthPerKey;constructor(e=zc,t=Wc){this.maxKeyLength=e,this.maxLengthPerKey=t,this.caches=[];for(let s=0;s<this.maxKeyLength;s++)this.caches.push([])}canBeCached(e){return e>0&&e<=this.maxKeyLength}find(e,t,s){let o=this.caches[s-1];e:for(let n of o){let a=n.bytes;for(let d=0;d<s;d++)if(a[d]!==e[t+d])continue e;return n.str}return null}store(e,t){let s=this.caches[e.length-1],o={bytes:e,str:t};s.length>=this.maxLengthPerKey?s[Math.random()*s.length|0]=o:s.push(o)}decode(e,t,s){let o=this.find(e,t,s);if(o!=null)return this.hit++,o;this.miss++;let n=(0,Bc.utf8DecodeJs)(e,t,s),a=Uint8Array.prototype.slice.call(e,t,t+s);return this.store(a,n),n}};wo.CachedKeyDecoder=Vn});var ko=oe(So=>{"use strict";Object.defineProperty(So,"__esModule",{value:!0});So.Decoder=void 0;var Hn=Wr(),Vc=Co(),$t=yo(),Hc=mo(),Hr=qn(),Jc=Vr(),rt=go(),Jn="array",bs="map_key",Kr="map_value",Kc=r=>{if(typeof r=="string"||typeof r=="number")return r;throw new rt.DecodeError("The type of key must be string or number but "+typeof r)},Kn=class{stack=[];stackHeadPosition=-1;get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState(e){let t=this.getUninitializedStateFromPool();t.type=Jn,t.position=0,t.size=e,t.array=new Array(e)}pushMapState(e){let t=this.getUninitializedStateFromPool();t.type=bs,t.readCount=0,t.size=e,t.map={}}getUninitializedStateFromPool(){if(this.stackHeadPosition++,this.stackHeadPosition===this.stack.length){let e={type:void 0,size:0,array:void 0,position:0,readCount:0,map:void 0,key:null};this.stack.push(e)}return this.stack[this.stackHeadPosition]}release(e){if(this.stack[this.stackHeadPosition]!==e)throw new Error("Invalid stack state. Released state is not on top of the stack.");if(e.type===Jn){let s=e;s.size=0,s.array=void 0,s.position=0,s.type=void 0}if(e.type===bs||e.type===Kr){let s=e;s.size=0,s.map=void 0,s.readCount=0,s.type=void 0}this.stackHeadPosition--}reset(){this.stack.length=0,this.stackHeadPosition=-1}},_s=-1,Qn=new DataView(new ArrayBuffer(0)),Yc=new Uint8Array(Qn.buffer);try{Qn.getInt8(0)}catch(r){if(!(r instanceof RangeError))throw new Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access")}var Jr=new RangeError("Insufficient data"),Qc=new Jc.CachedKeyDecoder,Yn=class r{extensionCodec;context;useBigInt64;rawStrings;maxStrLength;maxBinLength;maxArrayLength;maxMapLength;maxExtLength;keyDecoder;mapKeyConverter;totalPos=0;pos=0;view=Qn;bytes=Yc;headByte=_s;stack=new Kn;entered=!1;constructor(e){this.extensionCodec=e?.extensionCodec??Vc.ExtensionCodec.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.rawStrings=e?.rawStrings??!1,this.maxStrLength=e?.maxStrLength??$t.UINT32_MAX,this.maxBinLength=e?.maxBinLength??$t.UINT32_MAX,this.maxArrayLength=e?.maxArrayLength??$t.UINT32_MAX,this.maxMapLength=e?.maxMapLength??$t.UINT32_MAX,this.maxExtLength=e?.maxExtLength??$t.UINT32_MAX,this.keyDecoder=e?.keyDecoder!==void 0?e.keyDecoder:Qc,this.mapKeyConverter=e?.mapKeyConverter??Kc}clone(){return new r({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,rawStrings:this.rawStrings,maxStrLength:this.maxStrLength,maxBinLength:this.maxBinLength,maxArrayLength:this.maxArrayLength,maxMapLength:this.maxMapLength,maxExtLength:this.maxExtLength,keyDecoder:this.keyDecoder})}reinitializeState(){this.totalPos=0,this.headByte=_s,this.stack.reset()}setBuffer(e){let t=(0,Hr.ensureUint8Array)(e);this.bytes=t,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength),this.pos=0}appendBuffer(e){if(this.headByte===_s&&!this.hasRemaining(1))this.setBuffer(e);else{let t=this.bytes.subarray(this.pos),s=(0,Hr.ensureUint8Array)(e),o=new Uint8Array(t.length+s.length);o.set(t),o.set(s,t.length),this.setBuffer(o)}}hasRemaining(e){return this.view.byteLength-this.pos>=e}createExtraByteError(e){let{view:t,pos:s}=this;return new RangeError(`Extra ${t.byteLength-s} of ${t.byteLength} byte(s) found at buffer[${e}]`)}decode(e){if(this.entered)return this.clone().decode(e);try{this.entered=!0,this.reinitializeState(),this.setBuffer(e);let t=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return t}finally{this.entered=!1}}*decodeMulti(e){if(this.entered){yield*this.clone().decodeMulti(e);return}try{for(this.entered=!0,this.reinitializeState(),this.setBuffer(e);this.hasRemaining(1);)yield this.doDecodeSync()}finally{this.entered=!1}}async decodeAsync(e){if(this.entered)return this.clone().decodeAsync(e);try{this.entered=!0;let t=!1,s;for await(let d of e){if(t)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(d);try{s=this.doDecodeSync(),t=!0}catch(c){if(!(c instanceof RangeError))throw c}this.totalPos+=this.pos}if(t){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return s}let{headByte:o,pos:n,totalPos:a}=this;throw new RangeError(`Insufficient data in parsing ${(0,Hn.prettyByte)(o)} at ${a} (${n} in the current buffer)`)}finally{this.entered=!1}}decodeArrayStream(e){return this.decodeMultiAsync(e,!0)}decodeStream(e){return this.decodeMultiAsync(e,!1)}async*decodeMultiAsync(e,t){if(this.entered){yield*this.clone().decodeMultiAsync(e,t);return}try{this.entered=!0;let s=t,o=-1;for await(let n of e){if(t&&o===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(n),s&&(o=this.readArraySize(),s=!1,this.complete());try{for(;yield this.doDecodeSync(),--o!==0;);}catch(a){if(!(a instanceof RangeError))throw a}this.totalPos+=this.pos}}finally{this.entered=!1}}doDecodeSync(){e:for(;;){let e=this.readHeadByte(),t;if(e>=224)t=e-256;else if(e<192)if(e<128)t=e;else if(e<144){let o=e-128;if(o!==0){this.pushMapState(o),this.complete();continue e}else t={}}else if(e<160){let o=e-144;if(o!==0){this.pushArrayState(o),this.complete();continue e}else t=[]}else{let o=e-160;t=this.decodeString(o,0)}else if(e===192)t=null;else if(e===194)t=!1;else if(e===195)t=!0;else if(e===202)t=this.readF32();else if(e===203)t=this.readF64();else if(e===204)t=this.readU8();else if(e===205)t=this.readU16();else if(e===206)t=this.readU32();else if(e===207)this.useBigInt64?t=this.readU64AsBigInt():t=this.readU64();else if(e===208)t=this.readI8();else if(e===209)t=this.readI16();else if(e===210)t=this.readI32();else if(e===211)this.useBigInt64?t=this.readI64AsBigInt():t=this.readI64();else if(e===217){let o=this.lookU8();t=this.decodeString(o,1)}else if(e===218){let o=this.lookU16();t=this.decodeString(o,2)}else if(e===219){let o=this.lookU32();t=this.decodeString(o,4)}else if(e===220){let o=this.readU16();if(o!==0){this.pushArrayState(o),this.complete();continue e}else t=[]}else if(e===221){let o=this.readU32();if(o!==0){this.pushArrayState(o),this.complete();continue e}else t=[]}else if(e===222){let o=this.readU16();if(o!==0){this.pushMapState(o),this.complete();continue e}else t={}}else if(e===223){let o=this.readU32();if(o!==0){this.pushMapState(o),this.complete();continue e}else t={}}else if(e===196){let o=this.lookU8();t=this.decodeBinary(o,1)}else if(e===197){let o=this.lookU16();t=this.decodeBinary(o,2)}else if(e===198){let o=this.lookU32();t=this.decodeBinary(o,4)}else if(e===212)t=this.decodeExtension(1,0);else if(e===213)t=this.decodeExtension(2,0);else if(e===214)t=this.decodeExtension(4,0);else if(e===215)t=this.decodeExtension(8,0);else if(e===216)t=this.decodeExtension(16,0);else if(e===199){let o=this.lookU8();t=this.decodeExtension(o,1)}else if(e===200){let o=this.lookU16();t=this.decodeExtension(o,2)}else if(e===201){let o=this.lookU32();t=this.decodeExtension(o,4)}else throw new rt.DecodeError(`Unrecognized type byte: ${(0,Hn.prettyByte)(e)}`);this.complete();let s=this.stack;for(;s.length>0;){let o=s.top();if(o.type===Jn)if(o.array[o.position]=t,o.position++,o.position===o.size)t=o.array,s.release(o);else continue e;else if(o.type===bs){if(t==="__proto__")throw new rt.DecodeError("The key __proto__ is not allowed");o.key=this.mapKeyConverter(t),o.type=Kr;continue e}else if(o.map[o.key]=t,o.readCount++,o.readCount===o.size)t=o.map,s.release(o);else{o.key=null,o.type=bs;continue e}}return t}}readHeadByte(){return this.headByte===_s&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=_s}readArraySize(){let e=this.readHeadByte();switch(e){case 220:return this.readU16();case 221:return this.readU32();default:{if(e<160)return e-144;throw new rt.DecodeError(`Unrecognized array type byte: ${(0,Hn.prettyByte)(e)}`)}}}pushMapState(e){if(e>this.maxMapLength)throw new rt.DecodeError(`Max length exceeded: map length (${e}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(e)}pushArrayState(e){if(e>this.maxArrayLength)throw new rt.DecodeError(`Max length exceeded: array length (${e}) > maxArrayLength (${this.maxArrayLength})`);this.stack.pushArrayState(e)}decodeString(e,t){return!this.rawStrings||this.stateIsMapKey()?this.decodeUtf8String(e,t):this.decodeBinary(e,t)}decodeUtf8String(e,t){if(e>this.maxStrLength)throw new rt.DecodeError(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+t+e)throw Jr;let s=this.pos+t,o;return this.stateIsMapKey()&&this.keyDecoder?.canBeCached(e)?o=this.keyDecoder.decode(this.bytes,s,e):o=(0,Hc.utf8Decode)(this.bytes,s,e),this.pos+=t+e,o}stateIsMapKey(){return this.stack.length>0?this.stack.top().type===bs:!1}decodeBinary(e,t){if(e>this.maxBinLength)throw new rt.DecodeError(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(e+t))throw Jr;let s=this.pos+t,o=this.bytes.subarray(s,s+e);return this.pos+=t+e,o}decodeExtension(e,t){if(e>this.maxExtLength)throw new rt.DecodeError(`Max length exceeded: ext length (${e}) > maxExtLength (${this.maxExtLength})`);let s=this.view.getInt8(this.pos+t),o=this.decodeBinary(e,t+1);return this.extensionCodec.decode(o,s,this.context)}lookU8(){return this.view.getUint8(this.pos)}lookU16(){return this.view.getUint16(this.pos)}lookU32(){return this.view.getUint32(this.pos)}readU8(){let e=this.view.getUint8(this.pos);return this.pos++,e}readI8(){let e=this.view.getInt8(this.pos);return this.pos++,e}readU16(){let e=this.view.getUint16(this.pos);return this.pos+=2,e}readI16(){let e=this.view.getInt16(this.pos);return this.pos+=2,e}readU32(){let e=this.view.getUint32(this.pos);return this.pos+=4,e}readI32(){let e=this.view.getInt32(this.pos);return this.pos+=4,e}readU64(){let e=(0,$t.getUint64)(this.view,this.pos);return this.pos+=8,e}readI64(){let e=(0,$t.getInt64)(this.view,this.pos);return this.pos+=8,e}readU64AsBigInt(){let e=this.view.getBigUint64(this.pos);return this.pos+=8,e}readI64AsBigInt(){let e=this.view.getBigInt64(this.pos);return this.pos+=8,e}readF32(){let e=this.view.getFloat32(this.pos);return this.pos+=4,e}readF64(){let e=this.view.getFloat64(this.pos);return this.pos+=8,e}};So.Decoder=Yn});var Qr=oe(vo=>{"use strict";Object.defineProperty(vo,"__esModule",{value:!0});vo.decode=Xc;vo.decodeMulti=Zc;var Yr=ko();function Xc(r,e){return new Yr.Decoder(e).decode(r)}function Zc(r,e){return new Yr.Decoder(e).decodeMulti(r)}});var ea=oe(Cs=>{"use strict";Object.defineProperty(Cs,"__esModule",{value:!0});Cs.isAsyncIterable=Xr;Cs.asyncIterableFromStream=Zr;Cs.ensureAsyncIterable=eu;function Xr(r){return r[Symbol.asyncIterator]!=null}async function*Zr(r){let e=r.getReader();try{for(;;){let{done:t,value:s}=await e.read();if(t)return;yield s}}finally{e.releaseLock()}}function eu(r){return Xr(r)?r:Zr(r)}});var ta=oe(ws=>{"use strict";Object.defineProperty(ws,"__esModule",{value:!0});ws.decodeAsync=tu;ws.decodeArrayStream=su;ws.decodeMultiStream=ou;var Xn=ko(),Zn=ea();async function tu(r,e){let t=(0,Zn.ensureAsyncIterable)(r);return new Xn.Decoder(e).decodeAsync(t)}function su(r,e){let t=(0,Zn.ensureAsyncIterable)(r);return new Xn.Decoder(e).decodeArrayStream(t)}function ou(r,e){let t=(0,Zn.ensureAsyncIterable)(r);return new Xn.Decoder(e).decodeStream(t)}});var oa=oe(z=>{"use strict";Object.defineProperty(z,"__esModule",{value:!0});z.decodeTimestampExtension=z.encodeTimestampExtension=z.decodeTimestampToTimeSpec=z.encodeTimeSpecToTimestamp=z.encodeDateToTimeSpec=z.EXT_TIMESTAMP=z.ExtData=z.ExtensionCodec=z.Encoder=z.DecodeError=z.Decoder=z.decodeMultiStream=z.decodeArrayStream=z.decodeAsync=z.decodeMulti=z.decode=z.encode=void 0;var nu=zr();Object.defineProperty(z,"encode",{enumerable:!0,get:function(){return nu.encode}});var sa=Qr();Object.defineProperty(z,"decode",{enumerable:!0,get:function(){return sa.decode}});Object.defineProperty(z,"decodeMulti",{enumerable:!0,get:function(){return sa.decodeMulti}});var ei=ta();Object.defineProperty(z,"decodeAsync",{enumerable:!0,get:function(){return ei.decodeAsync}});Object.defineProperty(z,"decodeArrayStream",{enumerable:!0,get:function(){return ei.decodeArrayStream}});Object.defineProperty(z,"decodeMultiStream",{enumerable:!0,get:function(){return ei.decodeMultiStream}});var iu=ko();Object.defineProperty(z,"Decoder",{enumerable:!0,get:function(){return iu.Decoder}});var ru=go();Object.defineProperty(z,"DecodeError",{enumerable:!0,get:function(){return ru.DecodeError}});var au=Bn();Object.defineProperty(z,"Encoder",{enumerable:!0,get:function(){return au.Encoder}});var lu=Co();Object.defineProperty(z,"ExtensionCodec",{enumerable:!0,get:function(){return lu.ExtensionCodec}});var cu=Fn();Object.defineProperty(z,"ExtData",{enumerable:!0,get:function(){return cu.ExtData}});var es=jn();Object.defineProperty(z,"EXT_TIMESTAMP",{enumerable:!0,get:function(){return es.EXT_TIMESTAMP}});Object.defineProperty(z,"encodeDateToTimeSpec",{enumerable:!0,get:function(){return es.encodeDateToTimeSpec}});Object.defineProperty(z,"encodeTimeSpecToTimestamp",{enumerable:!0,get:function(){return es.encodeTimeSpecToTimestamp}});Object.defineProperty(z,"decodeTimestampToTimeSpec",{enumerable:!0,get:function(){return es.decodeTimestampToTimeSpec}});Object.defineProperty(z,"encodeTimestampExtension",{enumerable:!0,get:function(){return es.encodeTimestampExtension}});Object.defineProperty(z,"decodeTimestampExtension",{enumerable:!0,get:function(){return es.decodeTimestampExtension}})});var Ja=oe((gh,sd)=>{sd.exports={name:"@rajbos/ai-engineering-fluency",version:"0.0.13",description:"AI Engineering Fluency - CLI tool to analyze GitHub Copilot token usage from local session files",license:"MIT",author:"RobBos",repository:{type:"git",url:"git+https://github.com/rajbos/github-copilot-token-usage.git",directory:"cli"},keywords:["github-copilot","token-usage","copilot","cli","token-tracker"],bin:{"ai-engineering-fluency":"dist/cli.js"},files:["dist/**/*"],scripts:{build:"node esbuild.js","build:production":"node esbuild.js --production","bundle-exe":"pwsh -NoProfile -File bundle-exe.ps1",lint:"eslint src","check-types":"tsc --noEmit",test:"node dist/cli.js --help && node dist/cli.js --version"},devDependencies:{commander:"^14.0.3",chalk:"^5.6.2",esbuild:"^0.28.0",typescript:"^6.0.2","@types/node":"^25.5.0","sql.js":"^1.12.0"},engines:{node:">=22.14.0"}}});var mr=R(pr(),1),{program:pd,createCommand:md,createArgument:hd,createOption:fd,CommanderError:gd,InvalidArgumentError:yd,InvalidOptionArgumentError:_d,Command:pe,Argument:bd,Option:Cd,Help:wd}=mr.default;var hr=(r=0)=>e=>`\x1B[${e+r}m`,fr=(r=0)=>e=>`\x1B[${38+r};5;${e}m`,gr=(r=0)=>(e,t,s)=>`\x1B[${38+r};2;${e};${t};${s}m`,ie={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},kd=Object.keys(ie.modifier),ic=Object.keys(ie.color),rc=Object.keys(ie.bgColor),vd=[...ic,...rc];function ac(){let r=new Map;for(let[e,t]of Object.entries(ie)){for(let[s,o]of Object.entries(t))ie[s]={open:`\x1B[${o[0]}m`,close:`\x1B[${o[1]}m`},t[s]=ie[s],r.set(o[0],o[1]);Object.defineProperty(ie,e,{value:t,enumerable:!1})}return Object.defineProperty(ie,"codes",{value:r,enumerable:!1}),ie.color.close="\x1B[39m",ie.bgColor.close="\x1B[49m",ie.color.ansi=hr(),ie.color.ansi256=fr(),ie.color.ansi16m=gr(),ie.bgColor.ansi=hr(10),ie.bgColor.ansi256=fr(10),ie.bgColor.ansi16m=gr(10),Object.defineProperties(ie,{rgbToAnsi256:{value(e,t,s){return e===t&&t===s?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(s/255*5)},enumerable:!1},hexToRgb:{value(e){let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[s]=t;s.length===3&&(s=[...s].map(n=>n+n).join(""));let o=Number.parseInt(s,16);return[o>>16&255,o>>8&255,o&255]},enumerable:!1},hexToAnsi256:{value:e=>ie.rgbToAnsi256(...ie.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){if(e<8)return 30+e;if(e<16)return 90+(e-8);let t,s,o;if(e>=232)t=((e-232)*10+8)/255,s=t,o=t;else{e-=16;let d=e%36;t=Math.floor(e/36)/5,s=Math.floor(d/6)/5,o=d%6/5}let n=Math.max(t,s,o)*2;if(n===0)return 30;let a=30+(Math.round(o)<<2|Math.round(s)<<1|Math.round(t));return n===2&&(a+=60),a},enumerable:!1},rgbToAnsi:{value:(e,t,s)=>ie.ansi256ToAnsi(ie.rgbToAnsi256(e,t,s)),enumerable:!1},hexToAnsi:{value:e=>ie.ansi256ToAnsi(ie.hexToAnsi256(e)),enumerable:!1}}),ie}var lc=ac(),ze=lc;var to=R(require("node:process"),1),_r=R(require("node:os"),1),Mn=R(require("node:tty"),1);function $e(r,e=globalThis.Deno?globalThis.Deno.args:to.default.argv){let t=r.startsWith("-")?"":r.length===1?"-":"--",s=e.indexOf(t+r),o=e.indexOf("--");return s!==-1&&(o===-1||s<o)}var{env:re}=to.default,eo;$e("no-color")||$e("no-colors")||$e("color=false")||$e("color=never")?eo=0:($e("color")||$e("colors")||$e("color=true")||$e("color=always"))&&(eo=1);function cc(){if("FORCE_COLOR"in re)return re.FORCE_COLOR==="true"?1:re.FORCE_COLOR==="false"?0:re.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(re.FORCE_COLOR,10),3)}function uc(r){return r===0?!1:{level:r,hasBasic:!0,has256:r>=2,has16m:r>=3}}function dc(r,{streamIsTTY:e,sniffFlags:t=!0}={}){let s=cc();s!==void 0&&(eo=s);let o=t?eo:s;if(o===0)return 0;if(t){if($e("color=16m")||$e("color=full")||$e("color=truecolor"))return 3;if($e("color=256"))return 2}if("TF_BUILD"in re&&"AGENT_NAME"in re)return 1;if(r&&!e&&o===void 0)return 0;let n=o||0;if(re.TERM==="dumb")return n;if(to.default.platform==="win32"){let a=_r.default.release().split(".");return Number(a[0])>=10&&Number(a[2])>=10586?Number(a[2])>=14931?3:2:1}if("CI"in re)return["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some(a=>a in re)?3:["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(a=>a in re)||re.CI_NAME==="codeship"?1:n;if("TEAMCITY_VERSION"in re)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(re.TEAMCITY_VERSION)?1:0;if(re.COLORTERM==="truecolor"||re.TERM==="xterm-kitty"||re.TERM==="xterm-ghostty"||re.TERM==="wezterm")return 3;if("TERM_PROGRAM"in re){let a=Number.parseInt((re.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(re.TERM_PROGRAM){case"iTerm.app":return a>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(re.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(re.TERM)||"COLORTERM"in re?1:n}function yr(r,e={}){let t=dc(r,{streamIsTTY:r&&r.isTTY,...e});return uc(t)}var pc={stdout:yr({isTTY:Mn.default.isatty(1)}),stderr:yr({isTTY:Mn.default.isatty(2)})},br=pc;function Cr(r,e,t){let s=r.indexOf(e);if(s===-1)return r;let o=e.length,n=0,a="";do a+=r.slice(n,s)+e+t,n=s+o,s=r.indexOf(e,n);while(s!==-1);return a+=r.slice(n),a}function wr(r,e,t,s){let o=0,n="";do{let a=r[s-1]==="\r";n+=r.slice(o,a?s-1:s)+e+(a?`\r
|
|
29
29
|
`:`
|
|
30
|
-
`)+t,s
|
|
31
|
-
`,
|
|
32
|
-
`);return r!==-1&&(e=Qi(e,s,o,r)),o+e+s};Object.defineProperties(mo.prototype,Lt);var Ll=mo(),qu=mo({level:Zi?Zi.level:0});var T=Ll;var vs=z(require("fs"));var tr={getConfiguration:()=>({get:()=>{}})},hn={getExtension:()=>{}},Bt=class n{fsPath;scheme;path;constructor(e){this.fsPath=e,this.scheme="file",this.path=e}static file(e){return new n(e)}static joinPath(e,...t){let o=[e.fsPath,...t].join("/");return new n(o)}toString(){return this.fsPath}};var ie=z(require("fs")),B=z(require("path")),ct=z(require("os")),Wo=class n{deps;_sessionFilesCache=null;_sessionFilesCacheTime=0;static SESSION_FILES_CACHE_TTL=6e4;constructor(e){this.deps=e}clearCache(){this._sessionFilesCache=null,this._sessionFilesCacheTime=0}async pathExists(e){try{return await ie.promises.access(e),!0}catch{return!1}}async runWithConcurrency(e,t,o=8){if(e.length===0)return;let s=0,r=Array.from({length:Math.min(o,e.length)},async()=>{for(;s<e.length;){let l=s++;try{await t(e[l],l)}catch(u){this.deps.warn(`Failed to process session discovery item at index ${l}: ${u instanceof Error?u.message:String(u)}`)}}});await Promise.all(r)}getVSCodeUserPaths(){let e=ct.platform(),t=ct.homedir(),o=[],s=["Code","Code - Insiders","Code - Exploration","VSCodium","Cursor"];if(e==="win32"){let l=process.env.APPDATA||B.join(t,"AppData","Roaming");for(let u of s)o.push(B.join(l,u,"User"))}else if(e==="darwin")for(let l of s)o.push(B.join(t,"Library","Application Support",l,"User"));else{let l=process.env.XDG_CONFIG_HOME||B.join(t,".config");for(let u of s)o.push(B.join(l,u,"User"))}let r=[B.join(t,".vscode-server","data","User"),B.join(t,".vscode-server-insiders","data","User"),B.join(t,".vscode-remote","data","User"),B.join("/tmp",".vscode-server","data","User"),B.join("/workspace",".vscode-server","data","User")];return o.push(...r),o}getDiagnosticCandidatePaths(){let e=[],t=this.getVSCodeUserPaths();for(let I of t){let O=!1;try{O=ie.existsSync(I)}catch{}e.push({path:I,exists:O,source:"VS Code"})}let o=B.join(ct.homedir(),".copilot","session-state"),s=!1;try{s=ie.existsSync(o)}catch{}e.push({path:o,exists:s,source:"Copilot CLI"});let r=this.deps.openCode.getOpenCodeDataDir(),l=B.join(r,"storage","session"),u=!1;try{u=ie.existsSync(l)}catch{}e.push({path:l,exists:u,source:"OpenCode (JSON)"});let d=B.join(r,"opencode.db"),h=!1;try{h=ie.existsSync(d)}catch{}e.push({path:d,exists:h,source:"OpenCode (DB)"});let m=this.deps.crush.getCrushConfigDir(),p=B.join(m,"projects.json"),g=!1;try{g=ie.existsSync(p)}catch{}e.push({path:p,exists:g,source:"Crush (projects.json)"});let _=this.deps.crush.readCrushProjects();for(let I of _){let O=B.join(I.data_dir,"crush.db"),U=!1;try{U=ie.existsSync(O)}catch{}e.push({path:O,exists:U,source:`Crush (${B.basename(I.path)})`})}let w=this.deps.visualStudio.getLogDir(),b=!1;try{b=ie.existsSync(w)}catch{}e.push({path:w,exists:b,source:"Visual Studio (log dir)"});let y=this.deps.continue_.getContinueSessionsDir(),S=!1;try{S=ie.existsSync(y)}catch{}e.push({path:y,exists:S,source:"Continue"});let v=this.deps.claudeCode.getClaudeCodeProjectsDir(),E=!1;try{E=ie.existsSync(v)}catch{}e.push({path:v,exists:E,source:"Claude Code"});let P=this.deps.claudeDesktopCowork.getCoworkBaseDir();if(P){let I=!1;try{I=ie.existsSync(P)}catch{}e.push({path:P,exists:I,source:"Claude Desktop (Cowork)"})}return e}checkCopilotExtension(){let e=hn.getExtension("GitHub.copilot"),t=hn.getExtension("GitHub.copilot-chat");if(!e&&!t)this.deps.log("\u26A0\uFE0F GitHub Copilot extensions not found");else{let s=e?e.isActive?"\u2705 Active":"\u23F3 Loading":"\u274C Not found",r=t?t.isActive?"\u2705 Active":"\u23F3 Loading":"\u274C Not found";this.deps.log(`GitHub Copilot: ${s}, Chat: ${r}`)}process.env.CODESPACES==="true"&&(!e?.isActive||!t?.isActive)&&this.deps.warn("\u26A0\uFE0F Running in Codespaces with inactive Copilot extensions")}async getCopilotSessionFiles(){let e=Date.now();if(this._sessionFilesCache&&e-this._sessionFilesCacheTime<n.SESSION_FILES_CACHE_TTL)return this.deps.log(`\u{1F4A8} Using cached session files list (${this._sessionFilesCache.length} files, cached ${Math.round((e-this._sessionFilesCacheTime)/1e3)}s ago)`),this._sessionFilesCache;let t=this.deps.sampleDataDirectoryOverride?.()??tr.getConfiguration("copilot-token-tracker").get("sampleDataDirectory");if(t&&t.trim().length>0){let h=t.trim();try{if(await this.pathExists(h)){let m=(await ie.promises.readdir(h)).filter(p=>p.endsWith(".json")||p.endsWith(".jsonl")).map(p=>B.join(h,p));return this.deps.log(`\u{1F4F8} Sample data mode: using ${m.length} file(s) from ${h}`),this._sessionFilesCache=m,this._sessionFilesCacheTime=e,m}else this.deps.warn(`Sample data directory not found: ${h}`)}catch(m){this.deps.warn(`Error reading sample data directory: ${m}`)}}let o=[],s=ct.platform(),r=ct.homedir();this.deps.log(`\u{1F50D} Searching for Copilot session files on ${s}`);let l=this.getVSCodeUserPaths();this.deps.log(`\u{1F4C2} Considering ${l.length} candidate VS Code paths:`);for(let h of l)this.deps.log(` \u{1F4C1} ${h}`);let u=await Promise.all(l.map(h=>this.pathExists(h).catch(()=>!1))),d=l.filter((h,m)=>u[m]);this.deps.log(`\u2705 Found ${d.length} of ${l.length} VS Code paths exist on disk:`);for(let h of d)this.deps.log(` \u2705 ${h}`);try{await this.runWithConcurrency(d,async _=>{let w=B.basename(B.dirname(_)),b=B.join(_,"workspaceStorage");try{if(await this.pathExists(b)){let v=await ie.promises.readdir(b);await this.runWithConcurrency(v,async E=>{let P=B.join(b,E,"chatSessions");try{if(await this.pathExists(P)){let I=(await ie.promises.readdir(P)).filter(O=>O.endsWith(".json")||O.endsWith(".jsonl")).map(O=>B.join(P,O));I.length>0&&(this.deps.log(`\u{1F4C4} Found ${I.length} session files in ${w}/workspaceStorage/${E}`),o.push(...I))}}catch{}},6)}}catch(v){this.deps.warn(`Could not check workspace storage path ${b}: ${v}`)}let y=B.join(_,"globalStorage","emptyWindowChatSessions");try{if(await this.pathExists(y)){let v=(await ie.promises.readdir(y)).filter(E=>E.endsWith(".json")||E.endsWith(".jsonl")).map(E=>B.join(y,E));v.length>0&&(this.deps.log(`\u{1F4C4} Found ${v.length} session files in ${w}/globalStorage/emptyWindowChatSessions`),o.push(...v))}}catch(v){this.deps.warn(`Could not check global storage path ${y}: ${v}`)}let S=B.join(_,"globalStorage","github.copilot-chat");try{await this.pathExists(S)&&(this.deps.log(`\u{1F4C4} Scanning ${w}/globalStorage/github.copilot-chat`),await this.scanDirectoryForSessionFiles(S,o))}catch(v){this.deps.warn(`Could not check Copilot Chat global storage path ${S}: ${v}`)}},4);let h=B.join(ct.homedir(),".copilot","session-state");this.deps.log(`\u{1F4C1} Checking Copilot CLI path: ${h}`);try{if(await this.pathExists(h))try{let _=await ie.promises.readdir(h,{withFileTypes:!0}),w=_.filter(S=>!S.isDirectory()&&(S.name.endsWith(".json")||S.name.endsWith(".jsonl"))).map(S=>B.join(h,S.name));w.length>0&&(this.deps.log(`\u{1F4C4} Found ${w.length} session files in Copilot CLI directory`),o.push(...w));let b=_.filter(S=>S.isDirectory()),y=(await Promise.all(b.map(async S=>{let v=B.join(h,S.name,"events.jsonl");try{return(await ie.promises.stat(v)).size>0?v:null}catch{return null}}))).filter(S=>S!==null);y.length>0&&(this.deps.log(`\u{1F4C4} Found ${y.length} session files in Copilot CLI subdirectories`),o.push(...y))}catch(_){this.deps.warn(`Could not read Copilot CLI session path in ${h}: ${_}`)}}catch(_){this.deps.warn(`Could not check Copilot CLI session path ${h}: ${_}`)}let m=this.deps.openCode.getOpenCodeDataDir(),p=B.join(m,"storage","session"),g=B.join(m,"opencode.db");this.deps.log(`\u{1F4C1} Checking OpenCode JSON path: ${p}`),this.deps.log(`\u{1F4C1} Checking OpenCode DB path: ${g}`);try{if(await this.pathExists(p)){let _=async b=>{try{let y=await ie.promises.readdir(b,{withFileTypes:!0});for(let S of y)if(S.isDirectory())await _(B.join(b,S.name));else if(S.name.startsWith("ses_")&&S.name.endsWith(".json")){let v=B.join(b,S.name);try{(await ie.promises.stat(v)).size>0&&o.push(v)}catch{}}}catch{}};await _(p);let w=o.length-o.filter(b=>!this.deps.openCode.isOpenCodeSessionFile(b)).length;w>0&&this.deps.log(`\u{1F4C4} Found ${w} session files in OpenCode storage`)}}catch(_){this.deps.warn(`Could not check OpenCode session path: ${_}`)}try{if(await this.pathExists(g)){let _=new Set(o.filter(y=>this.deps.openCode.isOpenCodeSessionFile(y)).map(y=>this.deps.openCode.getOpenCodeSessionId(y)).filter(Boolean)),w=await this.deps.openCode.discoverOpenCodeDbSessions(),b=0;for(let y of w)_.has(y)||(o.push(B.join(m,`opencode.db#${y}`)),b++);b>0&&this.deps.log(`\u{1F4C4} Found ${b} additional session(s) in OpenCode database`)}}catch(_){this.deps.warn(`Could not read OpenCode database: ${_}`)}try{let _=this.deps.crush.readCrushProjects();this.deps.log(`\u{1F4C1} Crush: found ${_.length} project(s) in projects.json`);let w=await Promise.all(_.map(async y=>{let S=B.join(y.data_dir,"crush.db");this.deps.log(`\u{1F4C1} Checking Crush DB path: ${S}`);try{if(await this.pathExists(S))return(await this.deps.crush.discoverSessionsInDb(S)).map(E=>B.join(y.data_dir,`crush.db#${E}`))}catch(v){this.deps.warn(`Could not read Crush database for ${y.path}: ${v}`)}return[]})),b=w.reduce((y,S)=>y+S.length,0);b>0&&this.deps.log(`\u{1F4C4} Found ${b} session(s) in Crush database(s)`),o.push(...w.flat())}catch(_){this.deps.warn(`Could not read Crush projects: ${_}`)}try{let _=this.deps.continue_.getContinueSessionFiles();_.length>0&&(this.deps.log(`\u{1F4C4} Found ${_.length} session file(s) in Continue (~/.continue/sessions)`),o.push(..._))}catch(_){this.deps.warn(`Could not read Continue session files: ${_}`)}try{let _=this.deps.visualStudio.discoverSessions();_.length>0&&(this.deps.log(`\u{1F4C4} Found ${_.length} session file(s) in Visual Studio Copilot`),o.push(..._))}catch(_){this.deps.warn(`Could not read Visual Studio session files: ${_}`)}try{let _=this.deps.claudeCode.getClaudeCodeSessionFiles();_.length>0&&(this.deps.log(`\u{1F4C4} Found ${_.length} session file(s) in Claude Code (~/.claude/projects)`),o.push(..._))}catch(_){this.deps.warn(`Could not read Claude Code session files: ${_}`)}try{let _=this.deps.claudeDesktopCowork.getCoworkSessionFiles();_.length>0&&(this.deps.log(`\u{1F4C4} Found ${_.length} session file(s) in Claude Desktop Cowork`),o.push(..._))}catch(_){this.deps.warn(`Could not read Claude Desktop Cowork session files: ${_}`)}this.deps.log(`\u2728 Total: ${o.length} session file(s) discovered`),o.length===0&&this.deps.warn("\u26A0\uFE0F No session files found - Have you used GitHub Copilot Chat yet?"),this._sessionFilesCache=o,this._sessionFilesCacheTime=Date.now()}catch(h){this.deps.error("Error getting session files:",h)}return o}async scanDirectoryForSessionFiles(e,t){try{let o=await ie.promises.readdir(e,{withFileTypes:!0});for(let s of o){let r=B.join(e,s.name);if(s.isDirectory())await this.scanDirectoryForSessionFiles(r,t);else if(s.name.endsWith(".json")||s.name.endsWith(".jsonl")){if(this.isNonSessionFile(s.name))continue;try{(await ie.promises.stat(r)).size>0&&t.push(r)}catch{}}}}catch(o){this.deps.warn(`Could not scan directory ${e}: ${o}`)}}isNonSessionFile(e){let t=["embeddings","index","cache","preferences","settings","config","workspacesessions","globalsessions","api.json"],o=e.toLowerCase();return t.some(s=>o.includes(s))}};var ae=z(require("fs")),ye=z(require("path")),Yo=z(require("os")),or=z(gn()),Ko=class{_sqlJsModule=null;extensionUri;constructor(e){this.extensionUri=e}getOpenCodeDataDir(){let e=Yo.platform(),t=Yo.homedir();if(e==="win32")return ye.join(t,".local","share","opencode");let o=process.env.XDG_DATA_HOME||ye.join(t,".local","share");return ye.join(o,"opencode")}isOpenCodeSessionFile(e){let t=e.toLowerCase().replace(/\\/g,"/");return t.includes("/opencode/storage/session/")||t.includes("/opencode/opencode.db#ses_")}isOpenCodeDbSession(e){return e.includes("opencode.db#ses_")}async initSqlJs(){if(this._sqlJsModule)return this._sqlJsModule;let e=ye.join(__dirname,"sql-wasm.wasm"),t;return ae.existsSync(e)&&(t=ae.readFileSync(e)),this._sqlJsModule=await(0,or.default)(t?{wasmBinary:t}:void 0),this._sqlJsModule}async readOpenCodeDbSession(e){let t=ye.join(this.getOpenCodeDataDir(),"opencode.db");if(!ae.existsSync(t))return null;try{let o=await this.initSqlJs(),s=ae.readFileSync(t),r=new o.Database(s);try{let l=r.exec("SELECT id, slug, title, time_created, time_updated, project_id, directory FROM session WHERE id = ?",[e]);if(l.length===0||l[0].values.length===0)return null;let u=l[0].values[0],d=l[0].columns,h={};for(let m=0;m<d.length;m++)h[d[m]]=u[m];return{id:h.id,slug:h.slug,title:h.title,projectID:h.project_id,directory:h.directory,time:{created:h.time_created,updated:h.time_updated}}}finally{r.close()}}catch{return null}}async readOpenCodeDbMessages(e){let t=ye.join(this.getOpenCodeDataDir(),"opencode.db");if(!ae.existsSync(t))return[];try{let o=await this.initSqlJs(),s=ae.readFileSync(t),r=new o.Database(s);try{let l=r.exec("SELECT id, data, time_created FROM message WHERE session_id = ? ORDER BY time_created ASC",[e]);return l.length===0?[]:l[0].values.map(u=>{let d=JSON.parse(u[1]);return d.id=u[0],d.time=d.time||{},d.time.created=d.time.created||u[2],d})}finally{r.close()}}catch{return[]}}async readOpenCodeDbParts(e){let t=ye.join(this.getOpenCodeDataDir(),"opencode.db");if(!ae.existsSync(t))return[];try{let o=await this.initSqlJs(),s=ae.readFileSync(t),r=new o.Database(s);try{let l=r.exec("SELECT id, data, time_created FROM part WHERE message_id = ? ORDER BY time_created ASC",[e]);return l.length===0?[]:l[0].values.map(u=>{let d=JSON.parse(u[1]);return d.id=u[0],d.time=d.time||{},d.time.created=d.time.created||u[2],d})}finally{r.close()}}catch{return[]}}async discoverOpenCodeDbSessions(){let e=ye.join(this.getOpenCodeDataDir(),"opencode.db");if(!ae.existsSync(e))return[];try{let t=await this.initSqlJs(),o=ae.readFileSync(e),s=new t.Database(o);try{let r=s.exec("SELECT id FROM session");return r.length===0?[]:r[0].values.map(l=>l[0])}finally{s.close()}}catch{return[]}}async statSessionFile(e){if(this.isOpenCodeDbSession(e)){let t=ye.join(this.getOpenCodeDataDir(),"opencode.db");return ae.promises.stat(t)}return ae.promises.stat(e)}readOpenCodeMessages(e){let t=this.getOpenCodeDataDir(),o=ye.join(t,"storage","message",e),s=[];try{if(!ae.existsSync(o))return s;let r=ae.readdirSync(o,{withFileTypes:!0});for(let l of r)if(!(!l.isFile()||!l.name.endsWith(".json")))try{let u=ae.readFileSync(ye.join(o,l.name),"utf8"),d=JSON.parse(u);s.push(d)}catch{}}catch{}return s.sort((r,l)=>(r.time?.created||0)-(l.time?.created||0)),s}readOpenCodeParts(e){let t=this.getOpenCodeDataDir(),o=ye.join(t,"storage","part",e),s=[];try{if(!ae.existsSync(o))return s;let r=ae.readdirSync(o,{withFileTypes:!0});for(let l of r)if(!(!l.isFile()||!l.name.endsWith(".json")))try{let u=ae.readFileSync(ye.join(o,l.name),"utf8"),d=JSON.parse(u);s.push(d)}catch{}}catch{}return s.sort((r,l)=>(r.time?.start||0)-(l.time?.start||0)),s}getOpenCodeSessionId(e){let t=e.indexOf("opencode.db#");if(t!==-1)return e.substring(t+12);let o=ye.basename(e,".json");return o.startsWith("ses_")?o:null}async getOpenCodeMessagesForSession(e){let t=this.getOpenCodeSessionId(e);if(!t)return[];if(this.isOpenCodeDbSession(e))return this.readOpenCodeDbMessages(t);let o=await this.readOpenCodeDbMessages(t);return o.length>0?o:this.readOpenCodeMessages(t)}async getOpenCodePartsForMessage(e){let t=await this.readOpenCodeDbParts(e);return t.length>0?t:this.readOpenCodeParts(e)}async getTokensFromOpenCodeSession(e){let t=await this.getOpenCodeMessagesForSession(e),o=0,s=0;for(let r of t)r.role==="assistant"&&r.tokens&&(typeof r.tokens.total=="number"&&(s=r.tokens.total),o+=r.tokens.reasoning||0);return{tokens:s,thinkingTokens:o}}async countOpenCodeInteractions(e){return(await this.getOpenCodeMessagesForSession(e)).filter(o=>o.role==="user").length}async getOpenCodeModelUsage(e){let t={},o=await this.getOpenCodeMessagesForSession(e),s=0;for(let r=0;r<o.length;r++){let l=o[r];if(l.role!=="user")continue;let u=o.filter((b,y)=>y>r&&b.role==="assistant"&&b.parentID===l.id);if(u.length===0)continue;let d=s;for(let b of u)typeof b.tokens?.total=="number"&&(d=Math.max(d,b.tokens.total));let h=d-s;if(h<=0){s=d;continue}let m=u[0].modelID||u[0].model?.modelID||"unknown";t[m]||(t[m]={inputTokens:0,outputTokens:0});let p=u.reduce((b,y)=>b+(y.tokens?.output||0)+(y.tokens?.reasoning||0),0),g=Math.max(0,h-p);t[m].inputTokens+=g,t[m].outputTokens+=p;let _=u.reduce((b,y)=>b+(y.tokens?.cache?.read||0),0),w=u.reduce((b,y)=>b+(y.tokens?.cache?.write||0),0);_>0&&(t[m].cachedReadTokens=(t[m].cachedReadTokens??0)+_),w>0&&(t[m].cacheCreationTokens=(t[m].cacheCreationTokens??0)+w),s=d}return t}async getOpenCodeSessionData(e){let t=await this.getOpenCodeMessagesForSession(e),o=Date.now();t.length>0&&t[0].time_created&&(o=t[0].time_created);let{tokens:s}=await this.getTokensFromOpenCodeSession(e),r=await this.countOpenCodeInteractions(e),l=await this.getOpenCodeModelUsage(e),u={},d=0;for(let m=0;m<t.length;m++){let p=t[m];if(p.role!=="user")continue;let g=t.filter((w,b)=>b>m&&w.role==="assistant"&&w.parentID===p.id);if(g.length===0)continue;let _=g[0].modelID||g[0].model?.modelID||"unknown";u[_]=(u[_]||0)+1}let h={};for(let[m,p]of Object.entries(l))h[m]={...p,interactions:u[m]||0};return{tokens:s,interactions:r,modelUsage:h,timestamp:o}}};var Me=z(require("fs")),kt=z(require("path")),ho=z(require("os")),sr=z(gn()),Qo=class{_sqlJsModule=null;extensionUri;constructor(e){this.extensionUri=e}getCrushConfigDir(){if(ho.platform()==="win32"){let o=process.env.LOCALAPPDATA||kt.join(ho.homedir(),"AppData","Local");return kt.join(o,"crush")}let t=process.env.XDG_CONFIG_HOME||kt.join(ho.homedir(),".config");return kt.join(t,"crush")}readCrushProjects(){let e=kt.join(this.getCrushConfigDir(),"projects.json");if(!Me.existsSync(e))return[];try{let t=Me.readFileSync(e,"utf8"),o=JSON.parse(t);return Array.isArray(o.projects)?o.projects:[]}catch{return[]}}isCrushSessionFile(e){return e.replace(/\\/g,"/").includes("/.crush/crush.db#")}getCrushDbPath(e){let t=e.indexOf("crush.db#");return t===-1?e:e.substring(0,t+8)}getCrushSessionId(e){let t=e.indexOf("crush.db#");return t===-1?null:e.substring(t+9)}async initSqlJs(){if(this._sqlJsModule)return this._sqlJsModule;let e=kt.join(__dirname,"sql-wasm.wasm"),t;return Me.existsSync(e)&&(t=Me.readFileSync(e)),this._sqlJsModule=await(0,sr.default)(t?{wasmBinary:t}:void 0),this._sqlJsModule}async statSessionFile(e){let t=this.getCrushDbPath(e);return Me.promises.stat(t)}async discoverSessionsInDb(e){if(!Me.existsSync(e))return[];try{let t=await this.initSqlJs(),o=Me.readFileSync(e),s=new t.Database(o);try{let r=s.exec("SELECT id FROM sessions");return r.length===0?[]:r[0].values.map(l=>l[0])}finally{s.close()}}catch{return[]}}async readCrushSession(e){let t=this.getCrushDbPath(e),o=this.getCrushSessionId(e);if(!o||!Me.existsSync(t))return null;try{let s=await this.initSqlJs(),r=Me.readFileSync(t),l=new s.Database(r);try{let u=l.exec("SELECT id, title, message_count, prompt_tokens, completion_tokens, created_at, updated_at FROM sessions WHERE id = ?",[o]);if(u.length===0||u[0].values.length===0)return null;let d=u[0].columns,h=u[0].values[0],m={};return d.forEach((p,g)=>{m[p]=h[g]}),m}finally{l.close()}}catch{return null}}async getCrushMessages(e){let t=this.getCrushDbPath(e),o=this.getCrushSessionId(e);if(!o||!Me.existsSync(t))return[];try{let s=await this.initSqlJs(),r=Me.readFileSync(t),l=new s.Database(r);try{let u=l.exec("SELECT id, session_id, role, parts, model, provider, created_at, updated_at, finished_at FROM messages WHERE session_id = ? AND is_summary_message = 0 ORDER BY created_at ASC",[o]);if(u.length===0)return[];let d=u[0].columns;return u[0].values.map(h=>{let m={};if(d.forEach((p,g)=>{m[p]=h[g]}),typeof m.parts=="string")try{m.parts=JSON.parse(m.parts)}catch{m.parts=[]}return m})}finally{l.close()}}catch{return[]}}async getTokensFromCrushSession(e){let t=await this.readCrushSession(e);if(!t)return{tokens:0,thinkingTokens:0};let o=typeof t.prompt_tokens=="number"?t.prompt_tokens:0,s=typeof t.completion_tokens=="number"?t.completion_tokens:0;return{tokens:o+s,thinkingTokens:0}}async countCrushInteractions(e){return(await this.getCrushMessages(e)).filter(o=>o.role==="user").length}async getCrushModelUsage(e){let t={},o=await this.readCrushSession(e);if(!o)return t;let s=typeof o.prompt_tokens=="number"?o.prompt_tokens:0,r=typeof o.completion_tokens=="number"?o.completion_tokens:0;if(s+r===0)return t;let u=(await this.getCrushMessages(e)).filter(m=>m.role==="assistant"&&m.model);if(u.length===0)return t.unknown={inputTokens:s,outputTokens:r},t;let d={};for(let m of u){let p=m.model||"unknown";d[p]=(d[p]||0)+1}let h=u.length;for(let[m,p]of Object.entries(d)){let g=p/h;t[m]={inputTokens:Math.round(s*g),outputTokens:Math.round(r*g)}}return t}async getCrushSessionData(e){let t=await this.readCrushSession(e);if(!t)return{tokens:0,interactions:0,modelUsage:{},timestamp:0};let o=typeof t.prompt_tokens=="number"?t.prompt_tokens:0,s=typeof t.completion_tokens=="number"?t.completion_tokens:0,r=o+s,l=typeof t.created_at=="number"?t.created_at*1e3:Date.now(),u=await this.getCrushModelUsage(e),h=(await this.getCrushMessages(e)).filter(g=>g.role==="user").length,m=o+s,p={};for(let[g,_]of Object.entries(u)){let w=_.inputTokens+_.outputTokens,b=m>0?w/m:0;p[g]={inputTokens:_.inputTokens,outputTokens:_.outputTokens,interactions:Math.round(h*b)}}return{tokens:r,interactions:h,modelUsage:p,timestamp:l}}getToolCallsFromMessages(e){let t=[];for(let o of e)if(!(o.role!=="assistant"||!Array.isArray(o.parts)))for(let s of o.parts)s?.type==="tool_call"&&s?.data?.name&&t.push(s.data.name);return t}};var xt=z(require("fs")),vt=z(require("path")),nr=z(require("os")),Xo=class{getContinueDataDir(){return vt.join(nr.homedir(),".continue")}getContinueSessionsDir(){return vt.join(this.getContinueDataDir(),"sessions")}isContinueSessionFile(e){let t=e.toLowerCase().replace(/\\/g,"/");return t.includes("/.continue/sessions/")&&t.endsWith(".json")}getContinueSessionFiles(){let e=this.getContinueSessionsDir();if(!xt.existsSync(e))return[];try{return xt.readdirSync(e).filter(t=>t.endsWith(".json")&&t!=="sessions.json").map(t=>vt.join(e,t))}catch{return[]}}readSessionFile(e){try{let t=xt.readFileSync(e,"utf8");return JSON.parse(t)}catch{return null}}estimateTokens(e){return e?Math.ceil(e.length/4):0}getTokensFromContinueSession(e){let t=this.readSessionFile(e);if(!t||!Array.isArray(t.history))return{tokens:0,thinkingTokens:0};let o=0,s=0;for(let r of t.history)if(Array.isArray(r.promptLogs))for(let l of r.promptLogs)o+=this.estimateTokens(l.prompt||""),s+=this.estimateTokens(l.completion||"");return{tokens:o+s,thinkingTokens:0}}countContinueInteractions(e){let t=this.readSessionFile(e);return!t||!Array.isArray(t.history)?0:t.history.filter(o=>o.message?.role==="user").length}getContinueModelUsage(e){let t=this.readSessionFile(e);if(!t||!Array.isArray(t.history))return{};let o={};for(let s of t.history)if(Array.isArray(s.promptLogs))for(let r of s.promptLogs){let l=r.modelTitle||t.chatModelTitle||"unknown";o[l]||(o[l]={inputTokens:0,outputTokens:0}),o[l].inputTokens+=this.estimateTokens(r.prompt||""),o[l].outputTokens+=this.estimateTokens(r.completion||"")}return o}getContinueSessionMeta(e){let t=this.readSessionFile(e);return t?{title:t.title,model:t.chatModelTitle,workspaceDirectory:t.workspaceDirectory,mode:t.mode}:null}readSessionsIndex(){let e=vt.join(this.getContinueSessionsDir(),"sessions.json"),t=new Map;try{let o=xt.readFileSync(e,"utf8"),s=JSON.parse(o);if(!Array.isArray(s))return t;for(let r of s)r.sessionId&&t.set(r.sessionId,{dateCreated:r.dateCreated?Number(r.dateCreated):void 0,title:r.title,workspaceDirectory:r.workspaceDirectory})}catch{}return t}getContinueSessionId(e){return vt.basename(e,".json")}extractUserText(e){return typeof e=="string"?e:Array.isArray(e)?e.filter(t=>t.type==="text"&&typeof t.text=="string").map(t=>t.text).join(`
|
|
33
|
-
`):""}buildContinueTurns(e){let t=this.readSessionFile(e);if(!t||!Array.isArray(t.history))return[];let
|
|
34
|
-
`)){let h=
|
|
35
|
-
`)}extractContextText(e){if(!Array.isArray(e))return"";let t=[];for(let
|
|
36
|
-
`)}getModelId(e,t){if(!e)return null;if(t)return e.Model?.ModelId||null;let
|
|
37
|
-
`),
|
|
38
|
-
`),
|
|
39
|
-
`),
|
|
30
|
+
`)+t,o=s+1,s=r.indexOf(`
|
|
31
|
+
`,o)}while(s!==-1);return n+=r.slice(o),n}var{stdout:Sr,stderr:kr}=br,An=Symbol("GENERATOR"),Qt=Symbol("STYLER"),hs=Symbol("IS_EMPTY"),vr=["ansi","ansi","ansi256","ansi16m"],Xt=Object.create(null),mc=(r,e={})=>{if(e.level&&!(Number.isInteger(e.level)&&e.level>=0&&e.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");let t=Sr?Sr.level:0;r.level=e.level===void 0?t:e.level};var hc=r=>{let e=(...t)=>t.join(" ");return mc(e,r),Object.setPrototypeOf(e,fs.prototype),e};function fs(r){return hc(r)}Object.setPrototypeOf(fs.prototype,Function.prototype);for(let[r,e]of Object.entries(ze))Xt[r]={get(){let t=so(this,Dn(e.open,e.close,this[Qt]),this[hs]);return Object.defineProperty(this,r,{value:t}),t}};Xt.visible={get(){let r=so(this,this[Qt],!0);return Object.defineProperty(this,"visible",{value:r}),r}};var En=(r,e,t,...s)=>r==="rgb"?e==="ansi16m"?ze[t].ansi16m(...s):e==="ansi256"?ze[t].ansi256(ze.rgbToAnsi256(...s)):ze[t].ansi(ze.rgbToAnsi(...s)):r==="hex"?En("rgb",e,t,...ze.hexToRgb(...s)):ze[t][r](...s),fc=["rgb","hex","ansi256"];for(let r of fc){Xt[r]={get(){let{level:t}=this;return function(...s){let o=Dn(En(r,vr[t],"color",...s),ze.color.close,this[Qt]);return so(this,o,this[hs])}}};let e="bg"+r[0].toUpperCase()+r.slice(1);Xt[e]={get(){let{level:t}=this;return function(...s){let o=Dn(En(r,vr[t],"bgColor",...s),ze.bgColor.close,this[Qt]);return so(this,o,this[hs])}}}}var gc=Object.defineProperties(()=>{},{...Xt,level:{enumerable:!0,get(){return this[An].level},set(r){this[An].level=r}}}),Dn=(r,e,t)=>{let s,o;return t===void 0?(s=r,o=e):(s=t.openAll+r,o=e+t.closeAll),{open:r,close:e,openAll:s,closeAll:o,parent:t}},so=(r,e,t)=>{let s=(...o)=>yc(s,o.length===1?""+o[0]:o.join(" "));return Object.setPrototypeOf(s,gc),s[An]=r,s[Qt]=e,s[hs]=t,s},yc=(r,e)=>{if(r.level<=0||!e)return r[hs]?"":e;let t=r[Qt];if(t===void 0)return e;let{openAll:s,closeAll:o}=t;if(e.includes("\x1B"))for(;t!==void 0;)e=Cr(e,t.close,t.open),t=t.parent;let n=e.indexOf(`
|
|
32
|
+
`);return n!==-1&&(e=wr(e,o,s,n)),s+e+o};Object.defineProperties(fs.prototype,Xt);var _c=fs(),Dd=fs({level:kr?kr.level:0});var T=_c;var et=R(require("fs")),Ie=R(require("path")),Ea=R(require("os"));var xr={getConfiguration:()=>({get:()=>{}})},In={getExtension:()=>{}},Zt=class r{fsPath;scheme;path;constructor(e){this.fsPath=e,this.scheme="file",this.path=e}static file(e){return new r(e)}static joinPath(e,...t){let s=[e.fsPath,...t].join("/");return new r(s)}toString(){return this.fsPath}};var gs=R(require("fs")),Pr=R(require("os")),Mr=R(require("path"));function oo(r){return typeof r.discover=="function"}function Tr(r){return typeof r.analyzeUsage=="function"}function bc(r){let e=r.replace(/\\/g,"/");return Pr.platform()==="linux"?e:e.toLowerCase()}var no=class r{deps;_sessionFilesCache=null;_sessionFilesCacheTime=0;static SESSION_FILES_CACHE_TTL=6e4;constructor(e){this.deps=e}clearCache(){this._sessionFilesCache=null,this._sessionFilesCacheTime=0}async pathExists(e){try{return await gs.promises.access(e),!0}catch{return!1}}getDiagnosticCandidatePaths(){let e=[];for(let t of this.deps.ecosystems)if(oo(t))try{let s=t.getCandidatePaths();for(let o of s){let n=!1;try{n=gs.existsSync(o.path)}catch{}e.push({path:o.path,exists:n,source:o.source})}}catch{}return e}checkCopilotExtension(){let e=In.getExtension("GitHub.copilot"),t=In.getExtension("GitHub.copilot-chat");if(!e&&!t)this.deps.log("\u26A0\uFE0F GitHub Copilot extensions not found");else{let o=e?e.isActive?"\u2705 Active":"\u23F3 Loading":"\u274C Not found",n=t?t.isActive?"\u2705 Active":"\u23F3 Loading":"\u274C Not found";this.deps.log(`GitHub Copilot: ${o}, Chat: ${n}`)}process.env.CODESPACES==="true"&&(!e?.isActive||!t?.isActive)&&this.deps.warn("\u26A0\uFE0F Running in Codespaces with inactive Copilot extensions")}async getCopilotSessionFiles(){let e=Date.now();if(this._sessionFilesCache&&e-this._sessionFilesCacheTime<r.SESSION_FILES_CACHE_TTL)return this.deps.log(`\u{1F4A8} Using cached session files list (${this._sessionFilesCache.length} files, cached ${Math.round((e-this._sessionFilesCacheTime)/1e3)}s ago)`),this._sessionFilesCache;let t=this.deps.sampleDataDirectoryOverride?.()??xr.getConfiguration("aiEngineeringFluency").get("sampleDataDirectory");if(t&&t.trim().length>0){let o=t.trim();try{if(await this.pathExists(o)){let n=(await gs.promises.readdir(o)).filter(a=>a.endsWith(".json")||a.endsWith(".jsonl")).map(a=>Mr.join(o,a));return this.deps.log(`\u{1F4F8} Sample data mode: using ${n.length} file(s) from ${o}`),this._sessionFilesCache=n,this._sessionFilesCacheTime=e,n}else this.deps.warn(`Sample data directory not found: ${o}`)}catch(n){this.deps.warn(`Error reading sample data directory: ${n}`)}}let s=[];try{this.deps.log(`\u{1F50D} Searching for session files via ${this.deps.ecosystems.filter(oo).length} discoverable ecosystem adapter(s)`);for(let d of this.deps.ecosystems)if(oo(d))try{let c=await d.discover(this.deps.log);s.push(...c.sessionFiles)}catch(c){this.deps.warn(`Could not discover ${d.displayName} sessions: ${c}`)}let o=new Set,n=[];for(let d of s){let c=bc(d);o.has(c)||(o.add(c),n.push(d))}let a=s.length-n.length;return a>0&&this.deps.log(`\u{1F9F9} Deduplicated ${a} duplicate session path(s)`),this.deps.log(`\u2728 Total: ${n.length} session file(s) discovered`),n.length===0&&this.deps.warn("\u26A0\uFE0F No session files found - Have you used GitHub Copilot Chat yet?"),this._sessionFilesCache=n,this._sessionFilesCacheTime=Date.now(),n}catch(o){return this.deps.error("Error getting session files:",o),s}}};var ce=R(require("fs")),ge=R(require("path")),co=R(require("os")),Ar=R(Un()),lo=class{_sqlJsModule=null;extensionUri;constructor(e){this.extensionUri=e}getOpenCodeDataDir(){let e=co.platform(),t=co.homedir();if(e==="win32")return ge.join(t,".local","share","opencode");let s=process.env.XDG_DATA_HOME||ge.join(t,".local","share");return ge.join(s,"opencode")}isOpenCodeSessionFile(e){let t=e.toLowerCase().replace(/\\/g,"/");return t.includes("/opencode/storage/session/")||t.includes("/opencode/opencode.db#ses_")}isOpenCodeDbSession(e){return e.includes("opencode.db#ses_")}async initSqlJs(){if(this._sqlJsModule)return this._sqlJsModule;let e=ge.join(__dirname,"sql-wasm.wasm"),t;return ce.existsSync(e)&&(t=ce.readFileSync(e)),this._sqlJsModule=await(0,Ar.default)(t?{wasmBinary:t}:void 0),this._sqlJsModule}async readOpenCodeDbSession(e){let t=ge.join(this.getOpenCodeDataDir(),"opencode.db");if(!ce.existsSync(t))return null;try{let s=await this.initSqlJs(),o=ce.readFileSync(t),n=new s.Database(o);try{let a=n.exec("SELECT id, slug, title, time_created, time_updated, project_id, directory FROM session WHERE id = ?",[e]);if(a.length===0||a[0].values.length===0)return null;let d=a[0].values[0],c=a[0].columns,h={};for(let m=0;m<c.length;m++)h[c[m]]=d[m];return{id:h.id,slug:h.slug,title:h.title,projectID:h.project_id,directory:h.directory,time:{created:h.time_created,updated:h.time_updated}}}finally{n.close()}}catch{return null}}async readOpenCodeDbMessages(e){let t=ge.join(this.getOpenCodeDataDir(),"opencode.db");if(!ce.existsSync(t))return[];try{let s=await this.initSqlJs(),o=ce.readFileSync(t),n=new s.Database(o);try{let a=n.exec("SELECT id, data, time_created FROM message WHERE session_id = ? ORDER BY time_created ASC",[e]);return a.length===0?[]:a[0].values.map(d=>{let c=JSON.parse(d[1]);return c.id=d[0],c.time=c.time||{},c.time.created=c.time.created||d[2],c})}finally{n.close()}}catch{return[]}}async readOpenCodeDbParts(e){let t=ge.join(this.getOpenCodeDataDir(),"opencode.db");if(!ce.existsSync(t))return[];try{let s=await this.initSqlJs(),o=ce.readFileSync(t),n=new s.Database(o);try{let a=n.exec("SELECT id, data, time_created FROM part WHERE message_id = ? ORDER BY time_created ASC",[e]);return a.length===0?[]:a[0].values.map(d=>{let c=JSON.parse(d[1]);return c.id=d[0],c.time=c.time||{},c.time.created=c.time.created||d[2],c})}finally{n.close()}}catch{return[]}}async discoverOpenCodeDbSessions(){let e=ge.join(this.getOpenCodeDataDir(),"opencode.db");if(!ce.existsSync(e))return[];try{let t=await this.initSqlJs(),s=ce.readFileSync(e),o=new t.Database(s);try{let n=o.exec("SELECT id FROM session");return n.length===0?[]:n[0].values.map(a=>a[0])}finally{o.close()}}catch{return[]}}async statSessionFile(e){if(this.isOpenCodeDbSession(e)){let t=ge.join(this.getOpenCodeDataDir(),"opencode.db");return ce.promises.stat(t)}return ce.promises.stat(e)}readOpenCodeMessages(e){let t=this.getOpenCodeDataDir(),s=ge.join(t,"storage","message",e),o=[];try{if(!ce.existsSync(s))return o;let n=ce.readdirSync(s,{withFileTypes:!0});for(let a of n)if(!(!a.isFile()||!a.name.endsWith(".json")))try{let d=ce.readFileSync(ge.join(s,a.name),"utf8"),c=JSON.parse(d);o.push(c)}catch{}}catch{}return o.sort((n,a)=>(n.time?.created||0)-(a.time?.created||0)),o}readOpenCodeParts(e){let t=this.getOpenCodeDataDir(),s=ge.join(t,"storage","part",e),o=[];try{if(!ce.existsSync(s))return o;let n=ce.readdirSync(s,{withFileTypes:!0});for(let a of n)if(!(!a.isFile()||!a.name.endsWith(".json")))try{let d=ce.readFileSync(ge.join(s,a.name),"utf8"),c=JSON.parse(d);o.push(c)}catch{}}catch{}return o.sort((n,a)=>(n.time?.start||0)-(a.time?.start||0)),o}getOpenCodeSessionId(e){let t=e.indexOf("opencode.db#");if(t!==-1)return e.substring(t+12);let s=ge.basename(e,".json");return s.startsWith("ses_")?s:null}async getOpenCodeMessagesForSession(e){let t=this.getOpenCodeSessionId(e);if(!t)return[];if(this.isOpenCodeDbSession(e))return this.readOpenCodeDbMessages(t);let s=await this.readOpenCodeDbMessages(t);return s.length>0?s:this.readOpenCodeMessages(t)}async getOpenCodePartsForMessage(e){let t=await this.readOpenCodeDbParts(e);return t.length>0?t:this.readOpenCodeParts(e)}async getTokensFromOpenCodeSession(e){let t=await this.getOpenCodeMessagesForSession(e),s=0,o=0;for(let n of t)n.role==="assistant"&&n.tokens&&(typeof n.tokens.total=="number"&&(o=n.tokens.total),s+=n.tokens.reasoning||0);return{tokens:o,thinkingTokens:s}}async countOpenCodeInteractions(e){return(await this.getOpenCodeMessagesForSession(e)).filter(s=>s.role==="user").length}async getOpenCodeModelUsage(e){let t={},s=await this.getOpenCodeMessagesForSession(e),o=0;for(let n=0;n<s.length;n++){let a=s[n];if(a.role!=="user")continue;let d=s.filter((b,y)=>y>n&&b.role==="assistant"&&b.parentID===a.id);if(d.length===0)continue;let c=o;for(let b of d)typeof b.tokens?.total=="number"&&(c=Math.max(c,b.tokens.total));let h=c-o;if(h<=0){o=c;continue}let m=d[0].modelID||d[0].model?.modelID||"unknown";t[m]||(t[m]={inputTokens:0,outputTokens:0});let p=d.reduce((b,y)=>b+(y.tokens?.output||0)+(y.tokens?.reasoning||0),0),g=Math.max(0,h-p);t[m].inputTokens+=g,t[m].outputTokens+=p;let w=d.reduce((b,y)=>b+(y.tokens?.cache?.read||0),0),k=d.reduce((b,y)=>b+(y.tokens?.cache?.write||0),0);w>0&&(t[m].cachedReadTokens=(t[m].cachedReadTokens??0)+w),k>0&&(t[m].cacheCreationTokens=(t[m].cacheCreationTokens??0)+k),o=c}return t}async getOpenCodeSessionData(e){let t=await this.getOpenCodeMessagesForSession(e),s=Date.now();t.length>0&&t[0].time_created&&(s=t[0].time_created);let{tokens:o}=await this.getTokensFromOpenCodeSession(e),n=await this.countOpenCodeInteractions(e),a=await this.getOpenCodeModelUsage(e),d={},c=0;for(let m=0;m<t.length;m++){let p=t[m];if(p.role!=="user")continue;let g=t.filter((k,b)=>b>m&&k.role==="assistant"&&k.parentID===p.id);if(g.length===0)continue;let w=g[0].modelID||g[0].model?.modelID||"unknown";d[w]=(d[w]||0)+1}let h={};for(let[m,p]of Object.entries(a))h[m]={...p,interactions:d[m]||0};return{tokens:o,interactions:n,modelUsage:h,timestamp:s}}};var Te=R(require("fs")),Ft=R(require("path")),ys=R(require("os")),Er=R(Un()),uo=class{_sqlJsModule=null;extensionUri;constructor(e){this.extensionUri=e}getCrushConfigDir(){if(ys.platform()==="win32"){let s=process.env.LOCALAPPDATA||Ft.join(ys.homedir(),"AppData","Local");return Ft.join(s,"crush")}let t=process.env.XDG_CONFIG_HOME||Ft.join(ys.homedir(),".config");return Ft.join(t,"crush")}readCrushProjects(){let e=Ft.join(this.getCrushConfigDir(),"projects.json");if(!Te.existsSync(e))return[];try{let t=Te.readFileSync(e,"utf8"),s=JSON.parse(t);return Array.isArray(s.projects)?s.projects:[]}catch{return[]}}isCrushSessionFile(e){return e.replace(/\\/g,"/").includes("/.crush/crush.db#")}getCrushDbPath(e){let t=e.indexOf("crush.db#");return t===-1?e:e.substring(0,t+8)}getCrushSessionId(e){let t=e.indexOf("crush.db#");return t===-1?null:e.substring(t+9)}async initSqlJs(){if(this._sqlJsModule)return this._sqlJsModule;let e=Ft.join(__dirname,"sql-wasm.wasm"),t;return Te.existsSync(e)&&(t=Te.readFileSync(e)),this._sqlJsModule=await(0,Er.default)(t?{wasmBinary:t}:void 0),this._sqlJsModule}async statSessionFile(e){let t=this.getCrushDbPath(e);return Te.promises.stat(t)}async discoverSessionsInDb(e){if(!Te.existsSync(e))return[];try{let t=await this.initSqlJs(),s=Te.readFileSync(e),o=new t.Database(s);try{let n=o.exec("SELECT id FROM sessions");return n.length===0?[]:n[0].values.map(a=>a[0])}finally{o.close()}}catch{return[]}}async readCrushSession(e){let t=this.getCrushDbPath(e),s=this.getCrushSessionId(e);if(!s||!Te.existsSync(t))return null;try{let o=await this.initSqlJs(),n=Te.readFileSync(t),a=new o.Database(n);try{let d=a.exec("SELECT id, title, message_count, prompt_tokens, completion_tokens, created_at, updated_at FROM sessions WHERE id = ?",[s]);if(d.length===0||d[0].values.length===0)return null;let c=d[0].columns,h=d[0].values[0],m={};return c.forEach((p,g)=>{m[p]=h[g]}),m}finally{a.close()}}catch{return null}}async getCrushMessages(e){let t=this.getCrushDbPath(e),s=this.getCrushSessionId(e);if(!s||!Te.existsSync(t))return[];try{let o=await this.initSqlJs(),n=Te.readFileSync(t),a=new o.Database(n);try{let d=a.exec("SELECT id, session_id, role, parts, model, provider, created_at, updated_at, finished_at FROM messages WHERE session_id = ? AND is_summary_message = 0 ORDER BY created_at ASC",[s]);if(d.length===0)return[];let c=d[0].columns;return d[0].values.map(h=>{let m={};if(c.forEach((p,g)=>{m[p]=h[g]}),typeof m.parts=="string")try{m.parts=JSON.parse(m.parts)}catch{m.parts=[]}return m})}finally{a.close()}}catch{return[]}}async getTokensFromCrushSession(e){let t=await this.readCrushSession(e);if(!t)return{tokens:0,thinkingTokens:0};let s=typeof t.prompt_tokens=="number"?t.prompt_tokens:0,o=typeof t.completion_tokens=="number"?t.completion_tokens:0;return{tokens:s+o,thinkingTokens:0}}async countCrushInteractions(e){return(await this.getCrushMessages(e)).filter(s=>s.role==="user").length}async getCrushModelUsage(e){let t={},s=await this.readCrushSession(e);if(!s)return t;let o=typeof s.prompt_tokens=="number"?s.prompt_tokens:0,n=typeof s.completion_tokens=="number"?s.completion_tokens:0;if(o+n===0)return t;let d=(await this.getCrushMessages(e)).filter(m=>m.role==="assistant"&&m.model);if(d.length===0)return t.unknown={inputTokens:o,outputTokens:n},t;let c={};for(let m of d){let p=m.model||"unknown";c[p]=(c[p]||0)+1}let h=d.length;for(let[m,p]of Object.entries(c)){let g=p/h;t[m]={inputTokens:Math.round(o*g),outputTokens:Math.round(n*g)}}return t}async getCrushSessionData(e){let t=await this.readCrushSession(e);if(!t)return{tokens:0,interactions:0,modelUsage:{},timestamp:0};let s=typeof t.prompt_tokens=="number"?t.prompt_tokens:0,o=typeof t.completion_tokens=="number"?t.completion_tokens:0,n=s+o,a=typeof t.created_at=="number"?t.created_at*1e3:Date.now(),d=await this.getCrushModelUsage(e),h=(await this.getCrushMessages(e)).filter(g=>g.role==="user").length,m=s+o,p={};for(let[g,w]of Object.entries(d)){let k=w.inputTokens+w.outputTokens,b=m>0?k/m:0;p[g]={inputTokens:w.inputTokens,outputTokens:w.outputTokens,interactions:Math.round(h*b)}}return{tokens:n,interactions:h,modelUsage:p,timestamp:a}}getToolCallsFromMessages(e){let t=[];for(let s of e)if(!(s.role!=="assistant"||!Array.isArray(s.parts)))for(let o of s.parts)o?.type==="tool_call"&&o?.data?.name&&t.push(o.data.name);return t}};var jt=R(require("fs")),Nt=R(require("path")),Dr=R(require("os")),po=class{getContinueDataDir(){return Nt.join(Dr.homedir(),".continue")}getContinueSessionsDir(){return Nt.join(this.getContinueDataDir(),"sessions")}isContinueSessionFile(e){let t=e.toLowerCase().replace(/\\/g,"/");return t.includes("/.continue/sessions/")&&t.endsWith(".json")}getContinueSessionFiles(){let e=this.getContinueSessionsDir();if(!jt.existsSync(e))return[];try{return jt.readdirSync(e).filter(t=>t.endsWith(".json")&&t!=="sessions.json").map(t=>Nt.join(e,t))}catch{return[]}}readSessionFile(e){try{let t=jt.readFileSync(e,"utf8");return JSON.parse(t)}catch{return null}}estimateTokens(e){return e?Math.ceil(e.length/4):0}getTokensFromContinueSession(e){let t=this.readSessionFile(e);if(!t||!Array.isArray(t.history))return{tokens:0,thinkingTokens:0};let s=0,o=0;for(let n of t.history)if(Array.isArray(n.promptLogs))for(let a of n.promptLogs)s+=this.estimateTokens(a.prompt||""),o+=this.estimateTokens(a.completion||"");return{tokens:s+o,thinkingTokens:0}}countContinueInteractions(e){let t=this.readSessionFile(e);return!t||!Array.isArray(t.history)?0:t.history.filter(s=>s.message?.role==="user").length}getContinueModelUsage(e){let t=this.readSessionFile(e);if(!t||!Array.isArray(t.history))return{};let s={};for(let o of t.history)if(Array.isArray(o.promptLogs))for(let n of o.promptLogs){let a=n.modelTitle||t.chatModelTitle||"unknown";s[a]||(s[a]={inputTokens:0,outputTokens:0}),s[a].inputTokens+=this.estimateTokens(n.prompt||""),s[a].outputTokens+=this.estimateTokens(n.completion||"")}return s}getContinueSessionMeta(e){let t=this.readSessionFile(e);return t?{title:t.title,model:t.chatModelTitle,workspaceDirectory:t.workspaceDirectory,mode:t.mode}:null}readSessionsIndex(){let e=Nt.join(this.getContinueSessionsDir(),"sessions.json"),t=new Map;try{let s=jt.readFileSync(e,"utf8"),o=JSON.parse(s);if(!Array.isArray(o))return t;for(let n of o)n.sessionId&&t.set(n.sessionId,{dateCreated:n.dateCreated?Number(n.dateCreated):void 0,title:n.title,workspaceDirectory:n.workspaceDirectory})}catch{}return t}getContinueSessionId(e){return Nt.basename(e,".json")}extractUserText(e){return typeof e=="string"?e:Array.isArray(e)?e.filter(t=>t.type==="text"&&typeof t.text=="string").map(t=>t.text).join(`
|
|
33
|
+
`):""}buildContinueTurns(e){let t=this.readSessionFile(e);if(!t||!Array.isArray(t.history))return[];let s=t.history,o=[],n=0;for(;n<s.length;){let a=s[n];if(a.message?.role!=="user"){n++;continue}let d=this.extractUserText(a.message.content),c="",h=[],m=t.chatModelTitle||null,p=0,g=0,w=new Map,k=n+1;for(;k<s.length&&s[k].message?.role!=="user";){let b=s[k],y=b.message?.role;if(y==="assistant"){if(typeof b.message.content=="string"&&b.message.content&&(c+=b.message.content),Array.isArray(b.promptLogs)&&b.promptLogs.length>0){let v=b.promptLogs[0];v.modelTitle&&(m=v.modelTitle);for(let C of b.promptLogs)p+=this.estimateTokens(C.prompt||""),g+=this.estimateTokens(C.completion||"")}if(Array.isArray(b.message.toolCalls))for(let v of b.message.toolCalls){let C=v.function?.name||v.name||"unknown",P=v.function?.arguments,M=v.id||C;w.set(M,{toolName:C,arguments:P})}}else if(y==="tool"){let v=b.message.toolCallId||"",C=this.extractUserText(b.message.content),P=w.get(v);P?(h.push({...P,result:C}),w.delete(v)):h.push({toolName:"unknown",result:C})}k++}for(let[,b]of w)h.push(b);o.push({userText:d,assistantText:c,model:m,toolCalls:h,inputTokens:p,outputTokens:g}),n=k}return o}};var Se=R(require("fs")),kt=R(require("path")),Ss=R(require("os")),To=R(oa()),uu=new Set(["node_modules",".git",".github","bin","obj","out","dist","build","target","packages","vendor","__pycache__",".tox",".venv","venv","env","Windows","Program Files","Program Files (x86)","ProgramData","$Recycle.Bin","System Volume Information","Recovery"]),xo=class{isVSSessionFile(e){let t=e.replace(/\\/g,"/");return t.includes("/.vs/")&&t.includes("/copilot-chat/")&&t.includes("/sessions/")}async statSessionFile(e){return Se.promises.stat(e)}getLogDir(){let e=process.env.LOCALAPPDATA||kt.join(Ss.homedir(),"AppData","Local");return kt.join(e,"Temp","VSGitHubCopilotLogs")}discoverSessions(){let e=new Set,t=[];return this._discoverFromLogs(e,t),this._discoverFromFilesystem(e,t),t}_discoverFromLogs(e,t){let s=this.getLogDir();if(!Se.existsSync(s))return;let o;try{o=Se.readdirSync(s).filter(a=>a.endsWith(".chat.log")).map(a=>kt.join(s,a))}catch{return}let n=/Updating session file '([^']+)'/;for(let a of o)try{let d=Se.readFileSync(a,"utf8");for(let c of d.split(`
|
|
34
|
+
`)){let h=n.exec(c);if(!h)continue;let m=h[1];if(!e.has(m)){e.add(m);try{Se.existsSync(m)&&t.push(m)}catch{}}}}catch{}}_discoverFromFilesystem(e,t){if(Ss.platform()!=="win32")return;let s=Ss.homedir(),o=["C","D"],n=[s];for(let a of o)for(let d of["repos","code","src","projects","dev"]){let c=a+":\\"+d;try{Se.existsSync(c)&&n.push(c)}catch{}}for(let a of n){let d=a===s?7:5;this._scanForVsDirs(a,0,d,e,t)}}_scanForVsDirs(e,t,s,o,n){if(t>s)return;let a;try{a=Se.readdirSync(e,{withFileTypes:!0})}catch{return}for(let d of a){if(!d.isDirectory())continue;let c=d.name;if(uu.has(c)||c.startsWith(".")&&c!==".vs")continue;let h=kt.join(e,c);c===".vs"?this._findSessionsInVsDir(h,o,n):this._scanForVsDirs(h,t+1,s,o,n)}}_findSessionsInVsDir(e,t,s){let o;try{o=Se.readdirSync(e,{withFileTypes:!0})}catch{return}for(let n of o){if(!n.isDirectory())continue;let a=kt.join(e,n.name,"copilot-chat"),d;try{d=Se.readdirSync(a,{withFileTypes:!0})}catch{continue}for(let c of d){if(!c.isDirectory())continue;let h=kt.join(a,c.name,"sessions"),m;try{m=Se.readdirSync(h,{withFileTypes:!0})}catch{continue}for(let p of m){if(!p.isFile())continue;let g=kt.join(h,p.name);t.has(g)||(t.add(g),s.push(g))}}}}decodeSessionFile(e){try{let t=Se.readFileSync(e);return t.length<2?[]:Array.from((0,To.decodeMulti)(t.slice(1)))}catch{return[]}}getSessionTitle(e){let s=e.find((n,a)=>a>0&&a%2===1)?.[1];if(!s?.Content)return;let o=this.extractTextFromContent(s.Content).trim();if(o)return o.length>80?o.substring(0,80)+"\u2026":o}getSessionTimestamps(e){let t=e[0];return t?{timeCreated:t.TimeCreated?new Date(t.TimeCreated).toISOString():null,timeUpdated:t.TimeUpdated?new Date(t.TimeUpdated).toISOString():null}:{timeCreated:null,timeUpdated:null}}countInteractions(e){return e.filter((t,s)=>s>0&&s%2===1).length}extractTextFromContent(e){if(!Array.isArray(e))return"";let t=[];for(let s of e){let o=s?.[1];o&&typeof o.Content=="string"&&o.Content&&t.push(o.Content)}return t.join(`
|
|
35
|
+
`)}extractContextText(e){if(!Array.isArray(e))return"";let t=[];for(let s of e){let o=s?.ValueContainer;if(!Array.isArray(o)||o.length<2)continue;let n=o[1];if(!n||typeof n!="object")continue;let a=Object.keys(n);if(a.length!==0)if(isNaN(Number(a[0])))n.Content&&typeof n.Content=="string"&&t.push(n.Content);else try{let d=a.map(Number).sort((p,g)=>p-g),c=Buffer.from(d.map(p=>n[p])),h=(0,To.decode)(c),m=Array.isArray(h)?h[1]:h;m?.Content&&typeof m.Content=="string"&&t.push(m.Content)}catch{}}return t.join(`
|
|
36
|
+
`)}getModelId(e,t){if(!e)return null;if(t)return e.Model?.ModelId||null;let s=e.Model;return Array.isArray(s)&&s.length>=2&&s[1]?.Id?s[1].Id:null}getTokenEstimates(e,t){let s=this.decodeSessionFile(e),o=0;for(let n=1;n<s.length;n++){let a=s[n]?.[1];if(!a?.Content)continue;let d=this.extractTextFromContent(a.Content),c=n%2===1,h=c?this.extractContextText(a.Context):"";if(!d&&!h)continue;let m=this.getModelId(a,c)||void 0;o+=t(d+h,m)}return{tokens:o,thinkingTokens:0}}getModelUsage(e,t){let s={},o=this.decodeSessionFile(e),n={};for(let a=1;a<o.length;a++){let d=o[a]?.[1];if(!d?.Content)continue;let c=this.extractTextFromContent(d.Content),h=a%2===1,m=h?this.extractContextText(d.Context):"";if(!c&&!m)continue;let p=this.getModelId(d,h)||"unknown";n[p]||(n[p]={input:"",output:""}),h?n[p].input+=c+m:n[p].output+=c}for(let[a,d]of Object.entries(n))s[a]={inputTokens:t(d.input,a),outputTokens:t(d.output,a)};return s}};var at=R(require("fs")),Lt=R(require("path")),Mo=R(require("os"));function qt(r){if(!r||/claude-.+-\d+\.\d+/.test(r))return r;let e=r.match(/^(claude-.+)-(\d)-(\d)(-\d{8})?$/);return e?`${e[1]}-${e[2]}.${e[3]}`:r}var Po=class{getClaudeCodeDataDir(){return Lt.join(Mo.homedir(),".claude")}getClaudeCodeProjectsDir(){return Lt.join(this.getClaudeCodeDataDir(),"projects")}isClaudeCodeSessionFile(e){let t=e.toLowerCase().replace(/\\/g,"/"),s=this.getClaudeCodeProjectsDir().toLowerCase().replace(/\\/g,"/");return t.startsWith(s)&&t.endsWith(".jsonl")}getClaudeCodeSessionFiles(){let e=this.getClaudeCodeProjectsDir();if(!at.existsSync(e))return[];let t=[];try{let s=at.readdirSync(e,{withFileTypes:!0});for(let o of s){if(!o.isDirectory())continue;let n=Lt.join(e,o.name);try{let a=at.readdirSync(n,{withFileTypes:!0});for(let d of a)if(!d.isDirectory()&&d.name.endsWith(".jsonl")){let c=Lt.join(n,d.name);try{at.statSync(c).size>0&&t.push(c)}catch{}}}catch{}}}catch{}return t}readSessionEvents(e){try{let s=at.readFileSync(e,"utf8").trim().split(`
|
|
37
|
+
`),o=[];for(let n of s)if(n.trim())try{o.push(JSON.parse(n))}catch{}return o}catch{return[]}}getTokensFromClaudeCodeSession(e){let t=this.readSessionEvents(e),s=0,o=0,n=new Set;for(let a of t){if(a.type!=="assistant")continue;let d=a.message?.usage;if(!d)continue;let c=a.requestId;if(c){if(a.message?.stop_reason===null||a.message?.stop_reason===void 0||n.has(c))continue;n.add(c)}let h=(typeof d.input_tokens=="number"?d.input_tokens:0)+(typeof d.cache_creation_input_tokens=="number"?d.cache_creation_input_tokens:0)+(typeof d.cache_read_input_tokens=="number"?d.cache_read_input_tokens:0),m=typeof d.output_tokens=="number"?d.output_tokens:0;s+=h,o+=m}return{tokens:s+o,thinkingTokens:0}}countClaudeCodeInteractions(e){let t=this.readSessionEvents(e),s=0;for(let o of t)if(o.type==="user"&&!o.isSidechain&&o.message?.role==="user"){let n=o.message?.content;(typeof n=="string"||Array.isArray(n)&&n.some(d=>d.type==="text")&&!n.some(d=>d.type==="tool_result"))&&s++}return s}getClaudeCodeModelUsage(e){let t=this.readSessionEvents(e),s={},o=new Set;for(let n of t){if(n.type!=="assistant")continue;let a=n.message?.usage;if(!a)continue;let d=n.requestId;if(d){if(n.message?.stop_reason===null||n.message?.stop_reason===void 0||o.has(d))continue;o.add(d)}let c=qt(n.message?.model||"unknown");s[c]||(s[c]={inputTokens:0,outputTokens:0});let h=typeof a.cache_creation_input_tokens=="number"?a.cache_creation_input_tokens:0,m=typeof a.cache_read_input_tokens=="number"?a.cache_read_input_tokens:0,p=(typeof a.input_tokens=="number"?a.input_tokens:0)+h+m,g=typeof a.output_tokens=="number"?a.output_tokens:0;s[c].inputTokens+=p,s[c].outputTokens+=g,h>0&&(s[c].cacheCreationTokens=(s[c].cacheCreationTokens??0)+h),m>0&&(s[c].cachedReadTokens=(s[c].cachedReadTokens??0)+m)}return s}getClaudeCodeSessionMeta(e){let t=this.readSessionEvents(e);if(t.length===0)return null;let s,o,n,a=[];for(let h of t)if(h.type==="ai-title"&&h.aiTitle&&(s=h.aiTitle),!o&&h.entrypoint&&(o=h.entrypoint),!n&&h.cwd&&(n=h.cwd),h.timestamp){let m=new Date(h.timestamp).getTime();isNaN(m)||a.push(m)}let d,c;return a.length>0&&(a.sort((h,m)=>h-m),d=new Date(a[0]).toISOString(),c=new Date(a[a.length-1]).toISOString()),{title:s,entrypoint:o,firstInteraction:d,lastInteraction:c,cwd:n}}getClaudeCodeSessionId(e){return Lt.basename(e,".jsonl")}getProjectPathFromHash(e){if(Mo.platform()==="win32"){let s=e.split("-");if(s.length>=2&&s[0].length===1&&s[1]===""){let o=s[0].toUpperCase(),n=s.slice(2).join("\\");return`${o}:\\${n}`}}return"/"+e.replace(/-/g,"/")}};var lt=R(require("fs")),Ao=R(require("path")),Do=R(require("os"));var du="Claude_pzs8sxrjxfjjc",Eo=class{getCoworkBaseDir(){if(Do.platform()!=="win32")return"";let e=process.env.LOCALAPPDATA||Ao.join(Do.homedir(),"AppData","Local");return Ao.join(e,"Packages",du,"LocalCache","Roaming","Claude","local-agent-mode-sessions")}isCoworkSessionFile(e){let t=e.toLowerCase().replace(/\\/g,"/");return t.includes("/local-agent-mode-sessions/")&&t.endsWith(".jsonl")}getCoworkSessionFiles(){let e=this.getCoworkBaseDir();if(!e||!lt.existsSync(e))return[];let t=[];try{this.walkForJsonlFiles(e,t,0,8)}catch{}return t}walkForJsonlFiles(e,t,s,o){if(s>o)return;let n;try{n=lt.readdirSync(e,{withFileTypes:!0})}catch{return}for(let a of n){let d=Ao.join(e,a.name);if(a.isDirectory()){if(a.name==="agent")continue;this.walkForJsonlFiles(d,t,s+1,o)}else if(a.name.endsWith(".jsonl")&&a.name!=="audit.jsonl")try{lt.statSync(d).size>0&&t.push(d)}catch{}}}readCoworkEvents(e){try{let s=lt.readFileSync(e,"utf8").trim().split(`
|
|
38
|
+
`),o=[];for(let n of s)if(n.trim())try{o.push(JSON.parse(n))}catch{}return o}catch{return[]}}getTokensFromCoworkSession(e){let t=this.readCoworkEvents(e),s=0,o=0,n=new Set;for(let a of t){if(a.type!=="assistant")continue;let d=a.message?.usage;if(!d)continue;let c=a.requestId;if(c){if(!a.message?.stop_reason||n.has(c))continue;n.add(c)}let h=(typeof d.input_tokens=="number"?d.input_tokens:0)+(typeof d.cache_creation_input_tokens=="number"?d.cache_creation_input_tokens:0)+(typeof d.cache_read_input_tokens=="number"?d.cache_read_input_tokens:0),m=typeof d.output_tokens=="number"?d.output_tokens:0;s+=h,o+=m}return{tokens:s+o,thinkingTokens:0}}countCoworkInteractions(e){let t=this.readCoworkEvents(e),s=0;for(let o of t)if(o.type==="user"&&!o.isSidechain&&o.message?.role==="user"){let n=o.message?.content;(typeof n=="string"||Array.isArray(n)&&n.some(d=>d.type==="text")&&!n.some(d=>d.type==="tool_result"))&&s++}return s}getCoworkModelUsage(e){let t=this.readCoworkEvents(e),s={},o=new Set;for(let n of t){if(n.type!=="assistant")continue;let a=n.message?.usage;if(!a)continue;let d=n.requestId;if(d){if(!n.message?.stop_reason||o.has(d))continue;o.add(d)}let c=qt(n.message?.model||"unknown");s[c]||(s[c]={inputTokens:0,outputTokens:0});let h=typeof a.cache_creation_input_tokens=="number"?a.cache_creation_input_tokens:0,m=typeof a.cache_read_input_tokens=="number"?a.cache_read_input_tokens:0,p=(typeof a.input_tokens=="number"?a.input_tokens:0)+h+m,g=typeof a.output_tokens=="number"?a.output_tokens:0;s[c].inputTokens+=p,s[c].outputTokens+=g,h>0&&(s[c].cacheCreationTokens=(s[c].cacheCreationTokens??0)+h),m>0&&(s[c].cachedReadTokens=(s[c].cachedReadTokens??0)+m)}return s}getMetadataPathFromJsonl(e){let s=e.replace(/\\/g,"/").split("/"),o=s.lastIndexOf(".claude");if(o<1)return null;let n=s[o-1];return n.startsWith("local_")?`${s.slice(0,o-1).join("/")}/${n}.json`:null}getCoworkSessionMeta(e){let t=this.getMetadataPathFromJsonl(e);if(!t)return null;try{let s=lt.readFileSync(t,"utf8"),o=JSON.parse(s),n=o.createdAt?new Date(o.createdAt).toISOString():void 0,a=o.lastActivityAt?new Date(o.lastActivityAt).toISOString():void 0,d=Array.isArray(o.userSelectedFolders)&&o.userSelectedFolders.length>0?o.userSelectedFolders[0]:o.cwd;return{title:o.title||void 0,firstInteraction:n,lastInteraction:a,cwd:typeof d=="string"?d:void 0}}catch{return null}}};var ut=R(require("fs")),ct=R(require("path")),ti=R(require("os")),Io=class{getVibeHomeDir(){let e=process.env.VIBE_HOME;return e?ct.resolve(e.replace(/^~/,ti.homedir())):ct.join(ti.homedir(),".vibe")}getSessionLogDir(){return ct.join(this.getVibeHomeDir(),"logs","session")}isVibeSessionFile(e){let t=e.replace(/\\/g,"/");return t.includes("/.vibe/logs/session/")&&t.endsWith("/meta.json")}getSessionDir(e){return ct.dirname(e)}discoverSessions(){let e=this.getSessionLogDir();if(!ut.existsSync(e))return[];try{let t=ut.readdirSync(e,{withFileTypes:!0}),s=[];for(let o of t){if(!o.isDirectory())continue;let n=ct.join(e,o.name,"meta.json");ut.existsSync(n)&&s.push(n)}return s}catch{return[]}}readSessionMeta(e){try{let t=ut.readFileSync(e,"utf8");return JSON.parse(t)}catch{return null}}readSessionMessages(e){let t=ct.join(this.getSessionDir(e),"messages.jsonl");if(!ut.existsSync(t))return[];try{let o=ut.readFileSync(t,"utf8").trim().split(`
|
|
39
|
+
`),n=[];for(let a of o)if(a.trim())try{n.push(JSON.parse(a))}catch{}return n}catch{return[]}}getTokensFromSession(e){let t=this.readSessionMeta(e);if(!t?.stats)return{tokens:0,thinkingTokens:0};let s=typeof t.stats.session_prompt_tokens=="number"?t.stats.session_prompt_tokens:0,o=typeof t.stats.session_completion_tokens=="number"?t.stats.session_completion_tokens:0;return{tokens:s+o,thinkingTokens:0}}countInteractions(e){return this.readSessionMessages(e).filter(s=>s.role==="user"&&s.injected!==!0).length}getModelUsage(e){let t=this.readSessionMeta(e);if(!t)return{};let s=typeof t.stats?.session_prompt_tokens=="number"?t.stats.session_prompt_tokens:0,o=typeof t.stats?.session_completion_tokens=="number"?t.stats.session_completion_tokens:0;return s+o===0?{}:{[t.config?.active_model||"devstral"]:{inputTokens:s,outputTokens:o}}}getSessionMeta(e){let t=this.readSessionMeta(e);return t?{title:t.title||void 0,firstInteraction:t.start_time||null,lastInteraction:t.end_time||null,model:t.config?.active_model||void 0}:{title:void 0,firstInteraction:null,lastInteraction:null,model:void 0}}getSessionData(e){let t=this.readSessionMeta(e);if(!t)return{tokens:0,interactions:0,modelUsage:{},timestamp:0};let{tokens:s}=this.getTokensFromSession(e),o=this.countInteractions(e),n=this.getModelUsage(e),a={};for(let[c,h]of Object.entries(n))a[c]={...h,interactions:o};let d=t.start_time?new Date(t.start_time).getTime():0;return{tokens:s,interactions:o,modelUsage:a,timestamp:d}}};var ss=R(require("fs")),mt=R(require("path"));function ee(r,e="gpt-4",t={}){let s=.25;for(let[o,n]of Object.entries(t))if(e.includes(o)||e.includes(o.replace("-",""))){s=n;break}return Math.ceil(r.length*s)}function pu(r){return r.trim().toLowerCase().replace(/\s+/g,"-")}function vt(r){if(!r||typeof r!="object")return null;let e=r;if(e.kind!=="toolInvocationSerialized")return null;let t=e.toolSpecificData;if(!t||typeof t!="object")return null;let s=t;if(s.kind!=="subagent")return null;let o=typeof s.prompt=="string"?s.prompt:"",n="",a=s.result;if(typeof a=="string")n=a;else if(a&&typeof a=="object"){let h=Object.entries(a);h.sort(([m],[p])=>Number(m)-Number(p)),n=h.map(([,m])=>typeof m=="string"?m:"").join("")}let d=typeof s.modelName=="string"?s.modelName:"",c=d?pu(d):"";return o||n?{prompt:o,result:n,modelName:c}:null}function Oo(r){let e=0,t=0,s=r.trim().split(`
|
|
40
|
+
`),o={},n=!1,a=0,d=0;for(let m of s)if(m.trim())try{let p=JSON.parse(m);if(typeof p.kind=="number"&&(n=!0,o=ks(o,p)),p.type==="session.shutdown"&&p.data?.modelMetrics)for(let g of Object.values(p.data.modelMetrics)){let w=g?.usage;w&&(d+=(typeof w.inputTokens=="number"?w.inputTokens:0)+(typeof w.outputTokens=="number"?w.outputTokens:0))}if(p.type==="user.message"&&p.data?.content||p.type==="assistant.message"&&p.data?.content?e+=ee(p.data.content):p.type==="tool.result"&&p.data?.output?e+=ee(p.data.output):p.content&&(e+=ee(p.content)),p.kind===2&&p.k?.[0]==="requests"&&Array.isArray(p.v))for(let g of p.v)g.message?.text&&(e+=ee(g.message.text));if(p.kind===2&&p.k?.includes("response")&&Array.isArray(p.v))for(let g of p.v){if(g.kind==="thinking"&&g.value){t+=ee(g.value);continue}vt(g)||(g.value?e+=ee(g.value):g.kind==="markdownContent"&&g.content?.value&&(e+=ee(g.content.value)))}}catch{a++}let c=0;if(n){let m=a>0?si(s):new Map,p=o.requests&&Array.isArray(o.requests)?o.requests:[],g=p.length;for(let w of m.keys())w+1>g&&(g=w+1);for(let w=0;w<g;w++){let k=p[w],b=!1;if(k?.result){let y=k.result;if(typeof y.promptTokens=="number"&&typeof y.outputTokens=="number")c+=y.promptTokens+y.outputTokens,b=!0;else if(y.metadata&&typeof y.metadata.promptTokens=="number"&&typeof y.metadata.outputTokens=="number")c+=y.metadata.promptTokens+y.metadata.outputTokens,b=!0;else if(y.usage){let v=y.usage,C=typeof v.promptTokens=="number"?v.promptTokens:0,P=typeof v.completionTokens=="number"?v.completionTokens:0;c+=C+P,b=!0}}if(!b){let y=m.get(w);y&&(c+=y.promptTokens+y.outputTokens)}}}let h=!n&&d>0?d:c;if(n){let m=Array.isArray(o.requests)?o.requests:[];for(let p of m)if(!(!p?.response||!Array.isArray(p.response)))for(let g of p.response){let w=vt(g);w&&(w.prompt&&(e+=ee(w.prompt)),w.result&&(e+=ee(w.result)))}}return{tokens:e+t,thinkingTokens:t,actualTokens:h}}function na(r){let e=new Map,t=null,s=null,o=0;function n(a){if(!a||typeof a!="object")return null;let c=a.metadata;if(!c||typeof c!="object")return null;let m=c.configurationSchema;if(!m||typeof m!="object")return null;let g=m.properties;if(!g||typeof g!="object")return null;let k=g.reasoningEffort;if(!k||typeof k!="object")return null;let b=k;return typeof b.default=="string"?b.default:null}for(let a of r){if(!a.trim())continue;let d;try{d=JSON.parse(a)}catch{continue}if(typeof d.kind=="number"){if(d.kind===0){let c=d.v?.inputState?.selectedModel,h=n(c);h!==null&&(t=h,s=h)}else if(d.kind===1){let c=d.k;if(Array.isArray(c)&&c[0]==="inputState"&&c[1]==="selectedModel"){let h=n(d.v);h!==null&&h!==t&&(t!==null&&o++,t=h)}}else if(d.kind===2){let c=d.k;if(Array.isArray(c)&&c[0]==="requests"&&typeof c[1]=="number"&&t!==null){let h=d.v;if(h&&typeof h=="object"){let m=h,p=typeof m.requestId=="string"?m.requestId:null;p&&e.set(p,t)}}}}}return{effortByRequestId:e,defaultEffort:s,switchCount:o}}function si(r){let e=new Map;for(let t of r){if(!t.includes('"result"'))continue;let s=t.match(/"k":\s*\["requests",\s*(\d+),\s*"result"\]/);if(!s)continue;let o=parseInt(s[1],10),n=t.match(/"promptTokens":(\d+)/),a=t.match(/"outputTokens":(\d+)/),d=t.match(/"completionTokens":(\d+)/);n&&(a||d)&&e.set(o,{promptTokens:parseInt(n[1],10),outputTokens:parseInt(a?.[1]||d[1],10)})}return e}function xt(r,e={}){if(r.modelId)return r.modelId.replace(/^copilot\//,"");if(r.result&&r.result.metadata&&r.result.metadata.modelId)return r.result.metadata.modelId.replace(/^copilot\//,"");if(r.result&&r.result.details){let t={};for(let[o,n]of Object.entries(e))if(n.displayNames)for(let a of n.displayNames)t[a]=o;let s=Object.keys(t).sort((o,n)=>n.length-o.length);for(let o of s)if(r.result.details.includes(o))return t[o]}return"gpt-4"}function dt(r){let e=r.trim();if(!e.includes(`
|
|
40
41
|
`))return!1;let t=e.split(`
|
|
41
|
-
`).filter(r=>r.trim());if(t.length<2)return!1;let o=t[0].trim(),s=t[1].trim();return o.startsWith("{")&&o.endsWith("}")&&s.startsWith("{")&&s.endsWith("}")}function _s(n){let e=n.trim();return/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i.test(e)}function Co(n,e){if(typeof e!="object"||e===null)return n;let{kind:t,k:o,v:s}=e;if(t===0)return s;if(!Array.isArray(o)||o.length===0)return n;let r=o.map(String),l=typeof n=="object"&&n!==null?n:{},u=l;for(let h=0;h<r.length-1;h++){let m=r[h],p=r[h+1],g=/^\d+$/.test(p);if(Array.isArray(u)){let _=Number(m);(!u[_]||typeof u[_]!="object")&&(u[_]=g?[]:{}),u=u[_]}else(!u[m]||typeof u[m]!="object")&&(u[m]=g?[]:{}),u=u[m]}let d=r[r.length-1];if(t===1)return Array.isArray(u)?u[Number(d)]=s:u[d]=s,l;if(t===2){let h;if(Array.isArray(u)){let m=Number(d);Array.isArray(u[m])||(u[m]=[]),h=u[m]}else Array.isArray(u[d])||(u[d]=[]),h=u[d];return Array.isArray(s)?h.push(...s):h.push(s),l}return l}function ot(n,e={}){let t=e[n];if(t&&typeof t.multiplier=="number")return t.multiplier===0?"standard":"premium";for(let[o,s]of Object.entries(e))if((n.includes(o)||o.includes(n))&&typeof s.multiplier=="number")return s.multiplier===0?"standard":"premium";return"unknown"}function Ir(n,e={}){let t=0;for(let[o,s]of Object.entries(n)){let r=e[o]??e["gpt-4o-mini"],l=s.cachedReadTokens??0,u=s.cacheCreationTokens??0,h=Math.max(0,s.inputTokens-l-u)/1e6*r.inputCostPerMillion,m=l/1e6*(r.cachedInputCostPerMillion??r.inputCostPerMillion),p=u/1e6*(r.cacheCreationCostPerMillion??r.inputCostPerMillion),g=s.outputTokens/1e6*r.outputCostPerMillion;t+=h+m+p+g}return t}function Rr(){return{file:0,selection:0,implicitSelection:0,symbol:0,codebase:0,workspace:0,terminal:0,vscode:0,terminalLastCommand:0,terminalSelection:0,clipboard:0,changes:0,outputPanel:0,problemsPanel:0,byKind:{},copilotInstructions:0,agentsMd:0,byPath:{}}}function Ae(n){return typeof n=="object"&&n!==null}function Uc(n){return typeof n!="string"?!1:!["__proto__","prototype","constructor","hasOwnProperty"].includes(n)&&!n.startsWith("__")}function wo(n){return/^\d+$/.test(n)}function jn(n,e){if(typeof n!="string")return e;let t=n.trim();return t?t.startsWith("copilot/")?t.substring(8):t:e}function Fc(n,e){if(!Ae(e))return n;let t=e.kind,o=e.k,s=e.v;if(t===0)return s;if(!Array.isArray(o)||o.length===0)return n;let r=o.map(String);for(let m of r)if(!Uc(m))return n;let l=Ae(n)?n:Object.create(null),u=l,d=(m,p,g)=>{let _=wo(g),w=m[p];return Ae(w)||(w=_?[]:Object.create(null),m[p]=w),w};for(let m=0;m<r.length-1;m++){let p=r[m],g=r[m+1];if(Array.isArray(u)&&wo(p)){let _=Number(p),w=u[_];Ae(w)||(w=wo(g)?[]:Object.create(null),u[_]=w),u=w;continue}if(!Ae(u))return l;u=d(u,p,g)}let h=r[r.length-1];if(t===1)return Array.isArray(u)&&wo(h)?(u[Number(h)]=s,l):(Ae(u)&&Object.defineProperty(u,h,{value:s,writable:!0,enumerable:!0,configurable:!0}),l);if(t===2){let m;if(Array.isArray(u)&&wo(h)){let p=Number(h);Array.isArray(u[p])||(u[p]=[]),m=u[p]}else Ae(u)&&(Array.isArray(u[h])||Object.defineProperty(u,h,{value:[],writable:!0,enumerable:!0,configurable:!0}),m=u[h]);return Array.isArray(m)&&(Array.isArray(s)?m.push(...s):m.push(s)),l}return l}function $c(n){if(!Array.isArray(n))return{responseText:"",thinkingText:""};let e="",t="";for(let o of n){if(!Ae(o))continue;if(o.kind==="thinking"){let l=o.value;typeof l=="string"&&l&&(t+=l);continue}let s=Ae(o.content)?o.content.value:void 0,r=o.value;if(typeof s=="string"&&s){e+=s;continue}typeof r=="string"&&r&&(e+=r)}return{responseText:e,thinkingText:t}}function Ur(n,e,t,o){let s={},r=0,l=0,u=0,d=0,h=0,m,p="gpt-4o",g=y=>typeof y=="string"&&y?y:p,_=(y,S)=>{let v=g(y);s[v]||(s[v]={inputTokens:0,outputTokens:0});let E=t(S,v);s[v].inputTokens+=E,l+=E},w=(y,S)=>{let v=g(y);s[v]||(s[v]={inputTokens:0,outputTokens:0});let E=t(S,v);s[v].outputTokens+=E,u+=E};if(n.endsWith(".jsonl")){let y=e.split(/\r?\n/).filter(v=>v.trim()),S=!1;if(y.length>0)try{let v=JSON.parse(y[0]);v&&typeof v.kind=="number"&&(S=!0)}catch{}if(S){let v=Object.create(null);for(let P of y)try{let I=JSON.parse(P);v=Fc(v,I)}catch{}let E=Ae(v)&&Array.isArray(v.requests)?v.requests:[];if(E.length>0){r=E.filter(P=>Ae(P)&&Ae(P.message)&&typeof P.message.text=="string"&&P.message.text.trim()).length;for(let P of E){if(!Ae(P))continue;let I=jn(P.modelId??P.selectedModel?.identifier??P.model,p),O=o?o(P):void 0,U=jn(O,""),fe=U&&U!==p?U:I,V=P.message;Ae(V)&&typeof V.text=="string"&&_(fe,V.text);let{responseText:H,thinkingText:ke}=$c(P.response);H&&w(fe,H),ke&&(d+=t(ke,fe));let le=P.response;if(Array.isArray(le))for(let ge of le){let Pe=pt(ge);if(Pe){let be=Pe.modelName||fe;Pe.prompt&&_(be,Pe.prompt),Pe.result&&w(be,Pe.result)}}}}return{tokens:l+u+d,interactions:r,modelUsage:s,thinkingTokens:d,actualTokens:0}}try{m=JSON.parse(e.trim())}catch{return{tokens:0,interactions:0,modelUsage:{},thinkingTokens:0,actualTokens:0}}}if(!m)try{m=JSON.parse(e)}catch{return{tokens:0,interactions:0,modelUsage:{},thinkingTokens:0,actualTokens:0}}let b=Array.isArray(m.requests)?m.requests:Array.isArray(m.history)?m.history:[];r=b.length;for(let y of b){let S=o?o(y):y?.model||p,v=jn(S,p);if(s[v]||(s[v]={inputTokens:0,outputTokens:0}),y?.message?.parts){for(let P of y.message.parts)if(typeof P?.text=="string"&&P.text){let I=t(P.text,v);s[v].inputTokens+=I,l+=I}}else if(typeof y?.message?.text=="string"){let P=t(y.message.text,v);s[v].inputTokens+=P,l+=P}let E=Array.isArray(y?.response)?y.response:Array.isArray(y?.responses)?y.responses:[];for(let P of E){if(P?.kind==="thinking"&&typeof P?.value=="string"&&P.value){d+=t(P.value,v);continue}let I=pt(P);if(I){let O=I.modelName||v;I.prompt&&_(O,I.prompt),I.result&&w(O,I.result);continue}if(typeof P?.value=="string"&&P.value){let O=t(P.value,v);s[v].outputTokens+=O,u+=O}if(P?.message?.parts){for(let O of P.message.parts)if(typeof O?.text=="string"&&O.text){let U=t(O.text,v);s[v].outputTokens+=U,u+=U}}}if(y?.result?.usage){let P=y.result.usage,I=typeof P.promptTokens=="number"?P.promptTokens:0,O=typeof P.completionTokens=="number"?P.completionTokens:0;h+=I+O}else typeof y?.result?.promptTokens=="number"&&typeof y?.result?.outputTokens=="number"?h+=y.result.promptTokens+y.result.outputTokens:y?.result?.metadata&&typeof y?.result?.metadata?.promptTokens=="number"&&typeof y?.result?.metadata?.outputTokens=="number"&&(h+=y.result.metadata.promptTokens+y.result.metadata.outputTokens)}return{tokens:l+u+d,interactions:r,modelUsage:s,thinkingTokens:d,actualTokens:h}}var Pt=z(require("fs"));function bs(n){return!n||!n.kind?"ask":n.kind==="edit"?"edit":n.kind==="ask"?"ask":n.kind==="agent"?!n.id||n.id==="agent"?"agent":typeof n.id=="string"&&n.id.includes("plan-agent/Plan.agent.md")?"plan":typeof n.id=="string"&&n.id.includes(".agent.md")?"customAgent":"agent":"ask"}function So(n){return n.startsWith("mcp.")||n.startsWith("mcp_")}function Wt(n){return n.startsWith("mcp_github_github_")?"mcp_io_github_git_"+n.substring(18):n.startsWith("mcp.github.github.")?"mcp.io.github.git."+n.substring(18):n}function ko(n,e={}){let t=e[n]??e[n.toLowerCase()];return t&&t.includes(":")?t.split(":")[0].trim():n.startsWith("mcp_io_github_git_")||n.startsWith("mcp.io.github.git.")?"GitHub MCP (Local)":n.startsWith("mcp_github_github_")||n.startsWith("mcp.github.github.")?"GitHub MCP (Remote)":n.replace(/^mcp[._]/,"").split(/[._]/)[0]||"unknown"}function Cs(n,e){n.toolCalls.total+=e.toolCalls.total;for(let[t,o]of Object.entries(e.toolCalls.byTool))n.toolCalls.byTool[t]=(n.toolCalls.byTool[t]||0)+o;n.modeUsage.ask+=e.modeUsage.ask,n.modeUsage.edit+=e.modeUsage.edit,n.modeUsage.agent+=e.modeUsage.agent,n.modeUsage.plan+=e.modeUsage.plan,n.modeUsage.customAgent+=e.modeUsage.customAgent,n.contextReferences.file+=e.contextReferences.file,n.contextReferences.selection+=e.contextReferences.selection,n.contextReferences.implicitSelection+=e.contextReferences.implicitSelection||0,n.contextReferences.symbol+=e.contextReferences.symbol,n.contextReferences.codebase+=e.contextReferences.codebase,n.contextReferences.workspace+=e.contextReferences.workspace,n.contextReferences.terminal+=e.contextReferences.terminal,n.contextReferences.vscode+=e.contextReferences.vscode,n.contextReferences.terminalLastCommand+=e.contextReferences.terminalLastCommand||0,n.contextReferences.terminalSelection+=e.contextReferences.terminalSelection||0,n.contextReferences.clipboard+=e.contextReferences.clipboard||0,n.contextReferences.changes+=e.contextReferences.changes||0,n.contextReferences.outputPanel+=e.contextReferences.outputPanel||0,n.contextReferences.problemsPanel+=e.contextReferences.problemsPanel||0,n.contextReferences.copilotInstructions+=e.contextReferences.copilotInstructions||0,n.contextReferences.agentsMd+=e.contextReferences.agentsMd||0;for(let[t,o]of Object.entries(e.contextReferences.byKind||{}))n.contextReferences.byKind[t]=(n.contextReferences.byKind[t]||0)+o;for(let[t,o]of Object.entries(e.contextReferences.byPath||{}))n.contextReferences.byPath[t]=(n.contextReferences.byPath[t]||0)+o;n.mcpTools.total+=e.mcpTools.total;for(let[t,o]of Object.entries(e.mcpTools.byServer))n.mcpTools.byServer[t]=(n.mcpTools.byServer[t]||0)+o;for(let[t,o]of Object.entries(e.mcpTools.byTool))n.mcpTools.byTool[t]=(n.mcpTools.byTool[t]||0)+o;if(e.modelSwitching||(e.modelSwitching={uniqueModels:[],modelCount:0,switchCount:0,tiers:{standard:[],premium:[],unknown:[]},hasMixedTiers:!1,standardRequests:0,premiumRequests:0,unknownRequests:0,totalRequests:0}),e.modelSwitching.modelCount>0){n.modelSwitching.totalSessions++,n.modelSwitching.modelsPerSession.push(e.modelSwitching.modelCount);for(let t of e.modelSwitching.tiers.standard)n.modelSwitching.standardModels.includes(t)||n.modelSwitching.standardModels.push(t);for(let t of e.modelSwitching.tiers.premium)n.modelSwitching.premiumModels.includes(t)||n.modelSwitching.premiumModels.push(t);for(let t of e.modelSwitching.tiers.unknown)n.modelSwitching.unknownModels.includes(t)||n.modelSwitching.unknownModels.push(t);if(e.modelSwitching.hasMixedTiers&&n.modelSwitching.mixedTierSessions++,n.modelSwitching.standardRequests+=e.modelSwitching.standardRequests||0,n.modelSwitching.premiumRequests+=e.modelSwitching.premiumRequests||0,n.modelSwitching.unknownRequests+=e.modelSwitching.unknownRequests||0,n.modelSwitching.totalRequests+=e.modelSwitching.totalRequests||0,n.modelSwitching.modelsPerSession.length>0){let t=n.modelSwitching.modelsPerSession;n.modelSwitching.averageModelsPerSession=t.reduce((o,s)=>o+s,0)/t.length,n.modelSwitching.maxModelsPerSession=Math.max(...t),n.modelSwitching.minModelsPerSession=Math.min(...t),n.modelSwitching.switchingFrequency=t.filter(o=>o>1).length/t.length*100}}if(e.editScope){n.editScope.singleFileEdits+=e.editScope.singleFileEdits,n.editScope.multiFileEdits+=e.editScope.multiFileEdits,n.editScope.totalEditedFiles+=e.editScope.totalEditedFiles;let t=n.editScope.singleFileEdits+n.editScope.multiFileEdits;n.editScope.avgFilesPerSession=t>0?n.editScope.totalEditedFiles/t:0}if(e.applyUsage&&(n.applyUsage.totalApplies+=e.applyUsage.totalApplies,n.applyUsage.totalCodeBlocks+=e.applyUsage.totalCodeBlocks,n.applyUsage.applyRate=n.applyUsage.totalCodeBlocks>0?n.applyUsage.totalApplies/n.applyUsage.totalCodeBlocks*100:0),e.sessionDuration){n.sessionDuration.totalDurationMs+=e.sessionDuration.totalDurationMs;let t=n.sessions;if(t>0){n.sessionDuration.avgDurationMs=n.sessionDuration.totalDurationMs/t;let o=n.sessionDuration.avgFirstProgressMs*(t-1);n.sessionDuration.avgFirstProgressMs=(o+e.sessionDuration.avgFirstProgressMs)/t;let s=n.sessionDuration.avgTotalElapsedMs*(t-1);n.sessionDuration.avgTotalElapsedMs=(s+e.sessionDuration.avgTotalElapsedMs)/t;let r=n.sessionDuration.avgWaitTimeMs*(t-1);n.sessionDuration.avgWaitTimeMs=(r+e.sessionDuration.avgWaitTimeMs)/t}}if(e.conversationPatterns){n.conversationPatterns.multiTurnSessions+=e.conversationPatterns.multiTurnSessions,n.conversationPatterns.singleTurnSessions+=e.conversationPatterns.singleTurnSessions,n.conversationPatterns.maxTurnsInSession=Math.max(n.conversationPatterns.maxTurnsInSession,e.conversationPatterns.maxTurnsInSession);let t=n.conversationPatterns.multiTurnSessions+n.conversationPatterns.singleTurnSessions;if(t>0){let s=n.conversationPatterns.avgTurnsPerSession*(t-1)+e.conversationPatterns.avgTurnsPerSession;n.conversationPatterns.avgTurnsPerSession=s/t}}if(e.agentTypes&&(n.agentTypes.editsAgent+=e.agentTypes.editsAgent,n.agentTypes.defaultAgent+=e.agentTypes.defaultAgent,n.agentTypes.workspaceAgent+=e.agentTypes.workspaceAgent,n.agentTypes.other+=e.agentTypes.other),e.thinkingEffort){n.thinkingEffortUsage||(n.thinkingEffortUsage={byEffort:{},sessionCount:0,switchCount:0}),n.thinkingEffortUsage.sessionCount++,n.thinkingEffortUsage.switchCount+=e.thinkingEffort.switchCount;for(let[t,o]of Object.entries(e.thinkingEffort.byEffort))n.thinkingEffortUsage.byEffort[t]=(n.thinkingEffortUsage.byEffort[t]||0)+o}}function Fr(n,e){let t=n.match(/#file/gi);t&&(e.file+=t.length);let o=n.match(/#selection/gi);o&&(e.selection+=o.length);let s=n.match(/#symbol/gi),r=n.match(/#sym(?![:\w])/gi);s&&(e.symbol+=s.length),r&&(e.symbol+=r.length);let l=n.match(/#codebase/gi);l&&(e.codebase+=l.length);let u=n.match(/#terminalLastCommand/gi);u&&(e.terminalLastCommand+=u.length);let d=n.match(/#terminalSelection/gi);d&&(e.terminalSelection+=d.length);let h=n.match(/#clipboard/gi);h&&(e.clipboard+=h.length);let m=n.match(/#changes/gi);m&&(e.changes+=m.length);let p=n.match(/#outputPanel/gi);p&&(e.outputPanel+=p.length);let g=n.match(/#problemsPanel/gi);g&&(e.problemsPanel+=g.length);let _=n.match(/@workspace/gi);_&&(e.workspace+=_.length);let w=n.match(/@terminal/gi);w&&(e.terminal+=w.length);let b=n.match(/@vscode/gi);b&&(e.vscode+=b.length)}function qn(n,e){if(Array.isArray(n))for(let t of n){if(!t||typeof t!="object")continue;let o=t.kind;typeof o=="string"&&(e.byKind[o]=(e.byKind[o]||0)+1);let s=null;if(o==="reference"&&t.reference?s=t.reference:o==="inlineReference"&&t.inlineReference&&(s=t.inlineReference),s){let r=s.fsPath||s.path;if(typeof r=="string"){let u=r.replace(/\\/g,"/").toLowerCase();u.endsWith("/.github/copilot-instructions.md")||u.includes(".github/copilot-instructions.md")?e.copilotInstructions++:u.endsWith("/agents.md")||u.match(/\/agents\.md$/i)?e.agentsMd++:u.endsWith(".instructions.md")||u.includes(".instructions.md")?e.copilotInstructions++:e.file++;let d=r.length>100?"..."+r.substring(r.length-97):r;e.byPath[d]=(e.byPath[d]||0)+1}let l=s.name;if(typeof l=="string"&&o==="reference"){e.symbol++;let u=`#sym:${l}`;e.byPath[u]=(e.byPath[u]||0)+1}}}}function Nr(n,e){if(!(!n||!Array.isArray(n.variables)))for(let t of n.variables){if(!t||typeof t!="object")continue;let o=t.kind;if(typeof o=="string"&&(e.byKind[o]=(e.byKind[o]||0)+1),o==="generic"&&typeof t.name=="string"&&t.name.startsWith("sym:")){e.symbol++;let s=`#${t.name}`;e.byPath[s]=(e.byPath[s]||0)+1}if(o==="promptFile"&&t.value){let s=t.value,r=s.fsPath||s.path||s.external;if(typeof r=="string"){let l=r.replace(/\\/g,"/").toLowerCase();l.endsWith("/.github/copilot-instructions.md")||l.includes(".github/copilot-instructions.md")||l.endsWith("/agents.md")||l.match(/\/agents\.md$/i)}}}}function Ln(n){let e=n.modeUsage.ask+n.modeUsage.edit+n.modeUsage.agent;n.conversationPatterns={multiTurnSessions:e>1?1:0,singleTurnSessions:e===1?1:0,avgTurnsPerSession:e,maxTurnsInSession:e}}function Nn(n,e){if(n.message&&(n.message.text&&Fr(n.message.text,e),n.message.parts))for(let t of n.message.parts)t.text&&Fr(t.text,e);n.contentReferences&&Array.isArray(n.contentReferences)&&qn(n.contentReferences,e),n.variableData&&Nr(n.variableData,e)}function $r(n){try{let t=Pt.readFileSync(n,"utf8").trim().split(`
|
|
42
|
-
`),
|
|
43
|
-
`),
|
|
44
|
-
`).filter(
|
|
45
|
-
`).filter(
|
|
46
|
-
`),h="gpt-4o",m={},p=!1,g=null;for(let w of d)if(w.trim())try{let b=JSON.parse(w);if(typeof b.kind=="number"&&(p=!0,m=Co(m,b)),b.type==="session.start"&&typeof b.data?.selectedModel=="string"&&(h=b.data.selectedModel),b.kind===0){let S=b.v?.selectedModel?.identifier||b.v?.selectedModel?.metadata?.id||b.v?.inputState?.selectedModel?.metadata?.id;S&&(h=S.replace(/^copilot\//,""))}if(b.kind===2&&b.k?.[0]==="selectedModel"){let S=b.v?.identifier||b.v?.metadata?.id;S&&(h=S.replace(/^copilot\//,""))}let y=b.model||h;if(o[y]||(o[y]={inputTokens:0,outputTokens:0}),!p)if(b.type==="session.shutdown"&&b.data?.modelMetrics){g||(g={});for(let[S,v]of Object.entries(b.data.modelMetrics)){let E=v?.usage;E&&(g[S]||(g[S]={inputTokens:0,outputTokens:0}),g[S].inputTokens+=typeof E.inputTokens=="number"?E.inputTokens:0,g[S].outputTokens+=typeof E.outputTokens=="number"?E.outputTokens:0)}}else b.type==="user.message"&&b.data?.content?o[y].inputTokens+=te(b.data.content,y,n.tokenEstimators):b.type==="assistant.message"&&b.data?.content?o[y].outputTokens+=te(b.data.content,y,n.tokenEstimators):b.type==="tool.result"&&b.data?.output&&(o[y].inputTokens+=te(b.data.output,y,n.tokenEstimators))}catch{}if(!p&&g)return g;if(p&&m.requests&&Array.isArray(m.requests))for(let w of m.requests){if(!w||!w.requestId)continue;let b=h;if(w.modelId?b=w.modelId.replace(/^copilot\//,""):w.result?.metadata?.modelId?b=w.result.metadata.modelId.replace(/^copilot\//,""):w.result?.details&&(b=mt(w,n.modelPricing)),o[b]||(o[b]={inputTokens:0,outputTokens:0}),w.result?.usage){let y=w.result.usage;o[b].inputTokens+=typeof y.promptTokens=="number"?y.promptTokens:0,o[b].outputTokens+=typeof y.completionTokens=="number"?y.completionTokens:0}else if(typeof w.result?.promptTokens=="number"&&typeof w.result?.outputTokens=="number")o[b].inputTokens+=w.result.promptTokens,o[b].outputTokens+=w.result.outputTokens;else if(w.result?.metadata&&typeof w.result.metadata.promptTokens=="number"&&typeof w.result.metadata.outputTokens=="number")o[b].inputTokens+=w.result.metadata.promptTokens,o[b].outputTokens+=w.result.metadata.outputTokens;else if(w.message?.text&&(o[b].inputTokens+=te(w.message.text,b,n.tokenEstimators)),w.response&&Array.isArray(w.response))for(let y of w.response)y?.value&&(o[b].outputTokens+=te(y.value,b,n.tokenEstimators));if(w.response&&Array.isArray(w.response))for(let y of w.response){let S=pt(y);if(S){let v=S.modelName||b;o[v]||(o[v]={inputTokens:0,outputTokens:0}),S.prompt&&(o[v].inputTokens+=te(S.prompt,v,n.tokenEstimators)),S.result&&(o[v].outputTokens+=te(S.result,v,n.tokenEstimators))}}}let _=$n(d);for(let[w,b]of _){let y=m.requests?.[w];if(!y||y.result?.usage||typeof y.result?.promptTokens=="number"||y.result?.metadata&&typeof y.result.metadata.promptTokens=="number")continue;let S=h;y.modelId&&(S=y.modelId.replace(/^copilot\//,"")),o[S]||(o[S]={inputTokens:0,outputTokens:0}),o[S].inputTokens+=b.promptTokens,o[S].outputTokens+=b.outputTokens}return o}let u=JSON.parse(r);if(u.requests&&Array.isArray(u.requests))for(let d of u.requests){let h=mt(d,n.modelPricing);if(o[h]||(o[h]={inputTokens:0,outputTokens:0}),d.result?.usage){let m=d.result.usage;o[h].inputTokens+=typeof m.promptTokens=="number"?m.promptTokens:0,o[h].outputTokens+=typeof m.completionTokens=="number"?m.completionTokens:0}else if(typeof d.result?.promptTokens=="number"&&typeof d.result?.outputTokens=="number")o[h].inputTokens+=d.result.promptTokens,o[h].outputTokens+=d.result.outputTokens;else if(d.result?.metadata&&typeof d.result.metadata.promptTokens=="number"&&typeof d.result.metadata.outputTokens=="number")o[h].inputTokens+=d.result.metadata.promptTokens,o[h].outputTokens+=d.result.metadata.outputTokens;else{if(d.message&&d.message.parts){for(let m of d.message.parts)if(m.text){let p=te(m.text,h,n.tokenEstimators);o[h].inputTokens+=p}}if(d.response&&Array.isArray(d.response)){for(let m of d.response)if(m?.value){let p=te(m.value,h,n.tokenEstimators);o[h].outputTokens+=p}}}if(d.response&&Array.isArray(d.response))for(let m of d.response){let p=pt(m);if(p){let g=p.modelName||h;o[g]||(o[g]={inputTokens:0,outputTokens:0}),p.prompt&&(o[g].inputTokens+=te(p.prompt,g,n.tokenEstimators)),p.result&&(o[g].outputTokens+=te(p.result,g,n.tokenEstimators))}}}}catch(r){n.warn(`Error getting model usage from ${e}: ${r}`)}return o}var ht=z(require("fs")),Gn=z(require("path")),Br=z(require("os")),Gr=1,Lr=2e3,zr=Gn.join(Br.homedir(),".copilot-token-tracker"),Bn=Gn.join(zr,"cli-cache.json"),Be=new Map,Vt=!0,Wr=!1;function zn(){Vt=!1,Be.clear()}function Wn(){if(Vt)try{if(!ht.existsSync(Bn))return;let n=ht.readFileSync(Bn,"utf-8"),e=JSON.parse(n);if(e.version!==Gr){Be.clear();return}Be=new Map(Object.entries(e.entries))}catch{Be.clear()}}function Hn(){if(!(!Vt||!Wr))try{if(Be.size>Lr){let e=[...Be.entries()].sort((t,o)=>o[1].mtime-t[1].mtime);Be=new Map(e.slice(0,Lr))}ht.mkdirSync(zr,{recursive:!0});let n={version:Gr,entries:Object.fromEntries(Be)};ht.writeFileSync(Bn,JSON.stringify(n),"utf-8")}catch{}}function Hr(n,e,t){if(!Vt)return null;let o=Be.get(n);return!o||o.mtime!==e||o.size!==t?null:{...o.data,lastModified:new Date(o.data.lastModified)}}function Et(n,e,t,o){Vt&&(Wr=!0,Be.set(n,{mtime:e,size:t,data:{...o,lastModified:o.lastModified.toISOString()}}))}function Vn(){return{entries:Be.size,enabled:Vt}}var Vr={$schema:"http://json-schema.org/draft-07/schema#",description:"Character-to-token ratio estimators for different AI models. Used to estimate token counts from text length.",estimators:{"gpt-4":.25,"gpt-4.1":.25,"gpt-4.1-mini":.25,"gpt-4o":.25,"gpt-4o-mini":.25,"gpt-4-turbo":.25,"gpt-3.5-turbo":.25,"gpt-5":.25,"gpt-5-codex":.25,"gpt-5-mini":.25,"gpt-5.1":.25,"gpt-5.1-codex":.25,"gpt-5.1-codex-max":.25,"gpt-5.1-codex-mini":.25,"gpt-5.2":.25,"gpt-5.2-codex":.25,"gpt-5.2-pro":.25,"gpt-5.3-codex":.25,"gpt-5.4":.25,"gpt-5.4-mini":.25,"gpt-4.1-nano":.25,"gemini-2.0-flash":.25,"gemini-2.0-flash-lite":.25,"gemini-2.5-flash":.25,"gemini-2.5-flash-lite":.25,"claude-sonnet-3.5":.24,"claude-sonnet-3.7":.24,"claude-sonnet-4":.24,"claude-sonnet-4.5":.24,"claude-sonnet-4.6":.24,"claude-haiku":.24,"claude-haiku-4.5":.24,"claude-opus-4.1":.24,"claude-opus-4.5":.24,"claude-opus-4.6":.24,"claude-opus-4.6-(fast-mode)-(preview)":.24,"claude-opus-4.6-fast":.24,"gemini-2.5-pro":.25,"gemini-3-flash":.25,"gemini-3-pro":.25,"gemini-3-pro-preview":.25,"gemini-3.1-pro":.25,"gemini-3.1-flash-lite":.25,"grok-code-fast-1":.25,"raptor-mini":.25,goldeneye:.25,"o1-preview":.25,"o1-mini":.25,"o3-mini":.25,"o4-mini":.25}};var Jr={$schema:"http://json-schema.org/draft-07/schema#",description:"Model pricing data - costs per million tokens for input and output",metadata:{lastUpdated:"2026-03-30",sources:[{name:"OpenAI API Pricing",url:"https://openai.com/api/pricing/",retrievedDate:"2026-03-30"},{name:"Anthropic Claude Pricing",url:"https://www.anthropic.com/pricing",note:"Standard rates; also see https://platform.claude.com/docs/en/about-claude/pricing",retrievedDate:"2026-03-30"},{name:"Google AI Gemini API Pricing",url:"https://ai.google.dev/gemini-api/docs/pricing",retrievedDate:"2026-03-30"},{name:"xAI Grok API Pricing",url:"https://x.ai/api",retrievedDate:"2026-03-30"},{name:"GitHub Copilot Supported Models",url:"https://docs.github.com/en/copilot/reference/ai-models/supported-models",retrievedDate:"2026-03-30",note:"Source for tier/multiplier data"},{name:"GitHub Copilot Premium Requests",url:"https://docs.github.com/en/copilot/managing-copilot/monitoring-usage-and-entitlements/about-premium-requests",retrievedDate:"2026-03-30",note:"Source for premium request multiplier values"},{name:"OpenRouter Model Pricing",url:"https://openrouter.ai",retrievedDate:"2026-03-30",note:"Cross-provider pricing aggregator used for verification"}],disclaimer:"GitHub Copilot uses these models but pricing may differ from direct API usage. These are reference prices for cost estimation purposes only."},pricing:{"gpt-5":{inputCostPerMillion:1.25,outputCostPerMillion:10,category:"GPT-5 models",tier:"premium",multiplier:1,displayNames:["GPT-5"]},"gpt-5-codex":{inputCostPerMillion:1.25,outputCostPerMillion:10,category:"GPT-5 models",tier:"premium",multiplier:1},"gpt-5-mini":{inputCostPerMillion:.25,outputCostPerMillion:2,category:"GPT-5 models",tier:"standard",multiplier:0},"gpt-5.1":{inputCostPerMillion:1.25,outputCostPerMillion:10,category:"GPT-5 models",tier:"premium",multiplier:1},"gpt-5.1-codex":{inputCostPerMillion:1.25,outputCostPerMillion:10,category:"GPT-5 models",tier:"premium",multiplier:1},"gpt-5.1-codex-max":{inputCostPerMillion:1.75,outputCostPerMillion:14,category:"GPT-5 models",tier:"premium",multiplier:1},"gpt-5.1-codex-mini":{inputCostPerMillion:.25,outputCostPerMillion:2,category:"GPT-5 models",tier:"premium",multiplier:.33},"gpt-5.2":{inputCostPerMillion:1.75,outputCostPerMillion:14,category:"GPT-5 models",tier:"premium",multiplier:1},"gpt-5.2-codex":{inputCostPerMillion:1.75,outputCostPerMillion:14,category:"GPT-5 models",tier:"premium",multiplier:1},"gpt-5.2-pro":{inputCostPerMillion:21,outputCostPerMillion:168,category:"GPT-5 models",tier:"premium",multiplier:1},"gpt-5.3-codex":{inputCostPerMillion:1.75,outputCostPerMillion:14,category:"GPT-5 models",tier:"premium",multiplier:1},"gpt-5.4":{inputCostPerMillion:2.5,outputCostPerMillion:15,category:"GPT-5 models",tier:"premium",multiplier:1,displayNames:["GPT-5.4"]},"gpt-5.4-mini":{inputCostPerMillion:.25,outputCostPerMillion:2,category:"GPT-5 models",tier:"standard",multiplier:0,displayNames:["GPT-5.4 mini"]},"gpt-4":{inputCostPerMillion:3,outputCostPerMillion:12,category:"GPT-4 models",tier:"unknown",multiplier:1,displayNames:["GPT-4"]},"gpt-4.1":{inputCostPerMillion:3,outputCostPerMillion:12,category:"GPT-4 models",tier:"standard",multiplier:0,displayNames:["GPT-4.1"]},"gpt-4.1-mini":{inputCostPerMillion:.8,outputCostPerMillion:3.2,category:"GPT-4 models",tier:"standard",multiplier:0},"gpt-4.1-nano":{inputCostPerMillion:.2,outputCostPerMillion:.8,category:"GPT-4 models",tier:"standard",multiplier:0},"gpt-4o":{inputCostPerMillion:2.5,outputCostPerMillion:10,cachedInputCostPerMillion:1.25,category:"GPT-4 models",tier:"standard",multiplier:0,displayNames:["GPT-4o"]},"gpt-4o-mini":{inputCostPerMillion:.15,outputCostPerMillion:.6,cachedInputCostPerMillion:.075,category:"GPT-4 models",tier:"standard",multiplier:0,displayNames:["GPT-4o-mini","GPT-4o Mini"]},"gpt-4-turbo":{inputCostPerMillion:10,outputCostPerMillion:30,category:"GPT-4 models",tier:"standard",multiplier:0,displayNames:["GPT-4 Turbo"]},"claude-sonnet-3.5":{inputCostPerMillion:3,outputCostPerMillion:15,cachedInputCostPerMillion:.3,cacheCreationCostPerMillion:3.75,category:"Claude models (Anthropic)",tier:"unknown",multiplier:1,displayNames:["Claude Sonnet 3.5"]},"claude-sonnet-3.7":{inputCostPerMillion:3,outputCostPerMillion:15,cachedInputCostPerMillion:.3,cacheCreationCostPerMillion:3.75,category:"Claude models (Anthropic)",tier:"unknown",multiplier:1,displayNames:["Claude Sonnet 3.7"]},"claude-sonnet-4":{inputCostPerMillion:3,outputCostPerMillion:15,cachedInputCostPerMillion:.3,cacheCreationCostPerMillion:3.75,category:"Claude models (Anthropic)",tier:"premium",multiplier:1,displayNames:["Claude Sonnet 4"]},"claude-sonnet-4.5":{inputCostPerMillion:3,outputCostPerMillion:15,cachedInputCostPerMillion:.3,cacheCreationCostPerMillion:3.75,category:"Claude models (Anthropic)",tier:"premium",multiplier:1},"claude-sonnet-4.6":{inputCostPerMillion:3,outputCostPerMillion:15,cachedInputCostPerMillion:.3,cacheCreationCostPerMillion:3.75,category:"Claude models (Anthropic)",tier:"premium",multiplier:3,displayNames:["Claude Sonnet 4.6"]},"claude-haiku":{inputCostPerMillion:.25,outputCostPerMillion:1.25,cachedInputCostPerMillion:.025,cacheCreationCostPerMillion:.3125,category:"Claude models (Anthropic)",tier:"standard",multiplier:0},"claude-haiku-4.5":{inputCostPerMillion:1,outputCostPerMillion:5,cachedInputCostPerMillion:.1,cacheCreationCostPerMillion:1.25,category:"Claude models (Anthropic)",tier:"premium",multiplier:.33},"claude-opus-4.1":{inputCostPerMillion:15,outputCostPerMillion:75,cachedInputCostPerMillion:1.5,cacheCreationCostPerMillion:18.75,category:"Claude models (Anthropic)",tier:"premium",multiplier:10},"claude-opus-4.5":{inputCostPerMillion:5,outputCostPerMillion:25,cachedInputCostPerMillion:.5,cacheCreationCostPerMillion:6.25,category:"Claude models (Anthropic)",tier:"premium",multiplier:3},"claude-opus-4.6":{inputCostPerMillion:5,outputCostPerMillion:25,cachedInputCostPerMillion:.5,cacheCreationCostPerMillion:6.25,category:"Claude models (Anthropic)",tier:"premium",multiplier:3},"claude-opus-4.6-(fast-mode)-(preview)":{inputCostPerMillion:5,outputCostPerMillion:25,cachedInputCostPerMillion:.5,cacheCreationCostPerMillion:6.25,category:"Claude models (Anthropic)",tier:"premium",multiplier:30},"claude-opus-4.6-fast":{inputCostPerMillion:5,outputCostPerMillion:25,cachedInputCostPerMillion:.5,cacheCreationCostPerMillion:6.25,category:"Claude models (Anthropic)",tier:"premium",multiplier:30},"o3-mini":{inputCostPerMillion:1.1,outputCostPerMillion:4.4,category:"OpenAI reasoning models",tier:"premium",multiplier:1,displayNames:["o3-mini"]},"o4-mini":{inputCostPerMillion:1.1,outputCostPerMillion:4.4,category:"OpenAI reasoning models",tier:"premium",multiplier:1,displayNames:["o4-mini"]},"o1-preview":{inputCostPerMillion:15,outputCostPerMillion:60,category:"OpenAI reasoning models",tier:"premium",multiplier:1,displayNames:["o1-preview"]},"o1-mini":{inputCostPerMillion:3,outputCostPerMillion:12,category:"OpenAI reasoning models",tier:"premium",multiplier:1,displayNames:["o1-mini"]},"gpt-3.5-turbo":{inputCostPerMillion:.5,outputCostPerMillion:1.5,category:"Legacy models",tier:"standard",multiplier:0,displayNames:["GPT-3.5-Turbo","GPT-3.5 Turbo"]},"gemini-2.5-pro":{inputCostPerMillion:1.25,outputCostPerMillion:10,category:"Google Gemini models",tier:"premium",multiplier:1,displayNames:["Gemini 2.5 Pro"]},"gemini-2.5-flash":{inputCostPerMillion:.3,outputCostPerMillion:2.5,category:"Google Gemini models",tier:"unknown",multiplier:1},"gemini-2.5-flash-lite":{inputCostPerMillion:.1,outputCostPerMillion:.4,category:"Google Gemini models",tier:"unknown",multiplier:1},"gemini-2.0-flash":{inputCostPerMillion:.1,outputCostPerMillion:.4,category:"Google Gemini models",tier:"standard",multiplier:0},"gemini-2.0-flash-lite":{inputCostPerMillion:.075,outputCostPerMillion:.3,category:"Google Gemini models",tier:"standard",multiplier:0},"gemini-3-flash":{inputCostPerMillion:.5,outputCostPerMillion:3,category:"Google Gemini models",tier:"premium",multiplier:.33},"gemini-3-pro":{inputCostPerMillion:2,outputCostPerMillion:12,category:"Google Gemini models",tier:"premium",multiplier:1,displayNames:["Gemini 3 Pro"]},"gemini-3-pro-preview":{inputCostPerMillion:2,outputCostPerMillion:12,category:"Google Gemini models",tier:"premium",multiplier:1,displayNames:["Gemini 3 Pro (Preview)"]},"gemini-3.1-pro":{inputCostPerMillion:2,outputCostPerMillion:12,category:"Google Gemini models",tier:"premium",multiplier:1,displayNames:["Gemini 3.1 Pro","Gemini 3.1 Pro (Preview)"]},"gemini-3.1-flash-lite":{inputCostPerMillion:.25,outputCostPerMillion:1.5,category:"Google Gemini models",tier:"unknown",multiplier:.33,displayNames:["Gemini 3.1 Flash Lite"]},"grok-code-fast-1":{inputCostPerMillion:.2,outputCostPerMillion:1.5,category:"xAI Grok models",tier:"premium",multiplier:.25},"raptor-mini":{inputCostPerMillion:.25,outputCostPerMillion:2,category:"GitHub Copilot fine-tuned models",tier:"standard",multiplier:0},goldeneye:{inputCostPerMillion:0,outputCostPerMillion:0,category:"GitHub Copilot fine-tuned models",tier:"standard",multiplier:0}}};var Kr={unknown:"Unknown",run_in_terminal:"Run In Terminal",run_build:"Run Build",run_command_in_terminal:"Run Command In Terminal","mcp.io.github.git.assign_copilot_to_issue":"GitHub MCP (Local): Assign Copilot to Issue","mcp.io.github.git.create_or_update_file":"GitHub MCP (Local): Create/Update File",mcp_io_github_git_create_or_update_file:"GitHub MCP (Local): Create/Update File",mcp_io_github_git_assign_copilot_to_issue:"GitHub MCP (Local): Assign Copilot to Issue",mcp_io_github_git_pull_request_read:"GitHub MCP (Local): Pull Request Read",mcp_io_github_git_issue_read:"GitHub MCP (Local): Issue Read",mcp_io_github_git_issue_write:"GitHub MCP (Local): Issue Write",mcp_io_github_git_list_issues:"GitHub MCP (Local): List Issues",mcp_io_github_git_create_pull_request:"GitHub MCP (Local): Create Pull Request",mcp_io_github_git_get_file_contents:"GitHub MCP (Local): Get File Contents",mcp_io_github_git_search_code:"GitHub MCP (Local): Search Code",mcp_io_github_git_search_pull_requests:"GitHub MCP (Local): Search Pull Requests",mcp_io_github_git_get_release_by_tag:"GitHub MCP (Local): Get Release By Tag",mcp_io_github_git_search_issues:"GitHub MCP (Local): Search Issues",mcp_io_github_git_add_issue_comment:"GitHub MCP (Local): Add Issue Comment",mcp_io_github_git_list_pull_requests:"GitHub MCP (Local): List Pull Requests",mcp_io_github_git_get_commit:"GitHub MCP (Local): Get Commit",mcp_io_github_git_list_commits:"GitHub MCP (Local): List Commits",mcp_io_github_git_list_code_scanning_alerts:"GitHub MCP (Local): List Code Scanning Alerts",mcp_io_github_git_get_repository_tree:"GitHub MCP (Local): Get Repository Tree",mcp_io_github_git_list_tags:"GitHub MCP (Local): List Tags",mcp_io_github_git_search_repositories:"GitHub MCP (Local): Search Repositories",mcp_github_github_assign_copilot_to_issue:"GitHub MCP (Remote): Assign Copilot to Issue",mcp_github_github_issue_read:"GitHub MCP (Remote): Issue Read",mcp_github_github_issue_write:"GitHub MCP (Remote): Issue Write",mcp_github_github_list_issues:"GitHub MCP (Remote): List Issues",mcp_github_get_file_contents:"GitHub MCP (Remote): Get File Contents",mcp_github_get_latest_release:"GitHub MCP (Remote): Get Latest Release",mcp_github_get_release_by_tag:"GitHub MCP (Remote): Get Release By Tag",mcp_github_list_releases:"GitHub MCP (Remote): List Releases",mcp_github_list_tags:"GitHub MCP (Remote): List Tags",mcp_github_search_code:"GitHub MCP (Remote): Search Code",mcp_github_search_issues:"GitHub MCP (Remote): Search Issues",mcp_github_issue_write:"GitHub MCP (Remote): Issue Write",mcp_github_list_issues:"GitHub MCP (Remote): List Issues",mcp_github_create_pull_request:"GitHub MCP (Remote): Create Pull Request",mcp_github_pull_request_read:"GitHub MCP (Remote): Pull Request Read","mcp_github-code-s_get_code_scanning_alert":"GitHub MCP (Code Scanning): Get Alert","mcp_github-code-s_list_code_scanning_alerts":"GitHub MCP (Code Scanning): List Alerts",mcp_com_microsoft_get_bestpractices:"GitHub MCP: Get Best Practices",mcp_microsoft_doc_microsoft_code_sample_search:"Microsoft Docs MCP: Code Sample Search",mcp_microsoft_doc_microsoft_docs_search:"Microsoft Docs MCP: Docs Search",mcp_microsoftdocs_microsoft_docs_search:"Microsoft Docs MCP: Docs Search",mcp_gitkraken_git_add_or_commit:"GitKraken MCP: Git Add or Commit",mcp_gitkraken_git_status:"GitKraken MCP: Git Status",mcp_gitkraken_git_branch:"GitKraken MCP: Git Branch",mcp_gitkraken_git_checkout:"GitKraken MCP: Git Checkout",mcp_gitkraken_git_log_or_diff:"GitKraken MCP: Git Log or Diff",mcp_gitkraken_gitkraken_workspace_list:"GitKraken MCP: List Workspaces",mcp_pencil_batch_design:"Pencil MCP: Batch Design",mcp_pencil_get_editor_state:"Pencil MCP: Get Editor State",mcp_pencil_get_guidelines:"Pencil MCP: Get Guidelines",mcp_pencil_get_screenshot:"Pencil MCP: Get Screenshot",mcp_pencil_snapshot_layout:"Pencil MCP: Snapshot Layout",mcp_azure_aks:"Azure MCP: AKS",mcp_azure_mcp_azureterraformbestpractices:"Azure MCP: Azure Terraform Best Practices",mcp_azure_mcp_documentation:"Azure MCP: Documentation",mcp_bicep_format_bicep_file:"Bicep MCP: Format Bicep File",mcp_bicep_get_az_resource_type_schema:"Bicep MCP: Get Az Resource Type Schema",mcp_bicep_get_bicep_best_practices:"Bicep MCP: Get Bicep Best Practices",mcp_bicep_get_bicep_file_diagnostics:"Bicep MCP: Get Bicep File Diagnostics",mcp_bicep_list_az_resource_types_for_provider:"Bicep MCP: List Az Resource Types For Provider","azure_bicep-get_azure_verified_module":"Azure Bicep: Get Azure Verified Module","azure_development-recommend_custom_modes":"Azure Development: Recommend Custom Modes","azure_resources-query_azure_resource_graph":"Azure Resources: Query Azure Resource Graph",manage_todo_list:"Manage TODO List",copilot_readFile:"Read File",copilot_viewImage:"Copilot View Image",opilot_findFiles:"Find Files",copilot_writeFile:"Write File",copilot_applyPatch:"Apply Patch",copilot_findTextInFiles:"Find Text In Files",copilot_findFiles:"Find Files",copilot_replaceString:"Replace String",copilot_createFile:"Create File",copilot_listDirectory:"List Directory",copilot_fetchWebPage:"Fetch Web Page",copilot_getErrors:"Get Errors",copilot_multiReplaceString:"Multi Replace String",copilot_searchCodebase:"Search Codebase",get_terminal_output:"Get Terminal Output",run_task:"Run Task: Investigate",await_terminal:"Await Terminal command","github.copilot.editsAgent":"GitHub Copilot Edits Agent",todoList:"TODO List",terminal:"Terminal",terminal_last_command:"Terminal Last Command",github_pull_request:"GitHub Pull Request",github_repo:"GitHub Repository",editFiles:"Edit Files",listFiles:"List Files",search_subagent:"Search Subagent",execution_subagent:"Execution Subagent",apply_patch:"Apply Patch",ask_questions:"Ask Questions",AskUserQuestion:"Ask User Question",copilot_askQuestions:"Ask Questions",copilot_createAndRunTask:"Create And Run Task",copilot_createDirectory:"Create Directory",copilot_createNewJupyterNotebook:"Create New Jupyter Notebook",copilot_createNewWorkspace:"Create New Workspace",copilot_editFiles:"Edit Files",copilot_editNotebook:"Edit Notebook",copilot_findTestFiles:"Find Test Files",copilot_getChangedFiles:"Get Changed Files",copilot_getDocInfo:"Get Doc Info",copilot_getNotebookSummary:"Get Notebook Summary",copilot_getProjectSetupInfo:"Get Project Setup Info",copilot_getSearchResults:"Get Search Results",copilot_getVSCodeAPI:"Get VSCode API",copilot_githubRepo:"GitHub Repository",copilot_insertEdit:"Insert Edit",copilot_installExtension:"Install Extension",copilot_memory:"Memory",copilot_openIntegratedBrowser:"Open Integrated Browser",copilot_openSimpleBrowser:"Open Simple Browser",copilot_readNotebookCellOutput:"Read Notebook Cell Output",copilot_readProjectStructure:"Read Project Structure",copilot_runNotebookCell:"Run Notebook Cell",copilot_runInTerminal:"Run In Terminal",copilot_runTests1:"Run Tests",copilot_runVscodeCommand:"Run VSCode Command",copilot_searchWorkspaceSymbols:"Search Workspace Symbols",copilot_switchAgent:"Switch Agent",copilot_testFailure:"Test Failure",copilot_toolReplay:"Tool Replay",create_and_run_task:"Create And Run Task",create_directory:"Create Directory",create_file:"Create File",remove_file:"Remove File",create_new_jupyter_notebook:"Create New Jupyter Notebook",create_new_workspace:"Create New Workspace",create_virtual_environment:"Create Virtual Environment",edit_files:"Edit Files",edit_file:"Edit File",edit_notebook_file:"Edit Notebook File",fetch_webpage:"Fetch Webpage",file_search:"File Search",get_changed_files:"Get Changed Files",get_doc_info:"Get Doc Info",get_errors:"Get Errors",get_project_setup_info:"Get Project Setup Info",get_files_in_project:"Get Files In Project",get_projects_in_solution:"Get Projects In Solution",configure_python_environment:"Configure Python Environment",get_python_executable_details:"Get Python Executable Details",get_search_view_results:"Get Search View Results",get_task_output:"Get Task Output",job_output:"Job Output",get_vscode_api:"Get VSCode API",grep_search:"Grep Search",insert_edit_into_file:"Insert Edit Into File",install_extension:"Install Extension",install_python_packages:"Install Python Packages",list_dir:"List Dir",ls:"Ls",memory:"Memory",multi_replace_string_in_file:"Multi Replace String In File",open_integrated_browser:"Open Integrated Browser",open_simple_browser:"Open Simple Browser",read_file:"Read File",view_image:"View Image",read_notebook_cell_output:"Read Notebook Cell Output",read_project_structure:"Read Project Structure",replace_string_in_file:"Replace String In File","setup.agent":"Setup Agent",selectEnvironment:"Select Environment",run_notebook_cell:"Run Notebook Cell",run_vscode_command:"Run VSCode Command",runSubagent:"Run Subagent",renderMermaidDiagram:"Render Mermaid Diagram",runTests:"Run Tests",search_workspace_symbols:"Search Workspace Symbols",semantic_search:"Semantic Search",switch_agent:"Switch Agent",terminal_selection:"Terminal Selection",test_failure:"Test Failure",test_search:"Test Search",tool_replay:"Tool Replay",tool_search:"Tool Search",vscode_askQuestions:"VSCode Ask Questions",vscode_get_confirmation:"VSCode Get Confirmation",vscode_get_confirmation_with_options:"VSCode Get Confirmation With Options",vscode_get_terminal_confirmation:"VSCode Get Terminal Confirmation",vscode_get_modified_files_confirmation:"VSCode Get Modified Files Confirmation",vscode_listCodeUsages:"VSCode List Code Usages",vscode_renameSymbol:"VSCode Rename Symbol","mcp_io_github_ups_get-library-docs":"Context7 MCP: Get Library Docs","mcp_io_github_ups_query-docs":"Context7 MCP: Query Docs","mcp_io_github_ups_resolve-library-id":"Context7 MCP: Resolve Library ID","mcp_context7_query-docs":"Context7 MCP: Query Docs","mcp_context7_resolve-library-id":"Context7 MCP: Resolve Library ID",mcp_microsoft_pla_browser_evaluate:"Playwright MCP: Browser Evaluate",mcp_microsoft_pla_browser_install:"Playwright MCP: Browser Install",mcp_microsoft_pla_browser_navigate:"Playwright MCP: Browser Navigate",mcp_microsoft_pla_browser_run_code:"Playwright MCP: Browser Run Code",mcp_microsoft_pla_browser_click:"Playwright MCP: Browser Click",mcp_microsoft_pla_browser_fill_form:"Playwright MCP: Browser Fill Form",mcp_microsoft_pla_browser_press_key:"Playwright MCP: Browser Press Key",mcp_microsoft_pla_browser_resize:"Playwright MCP: Browser Resize",mcp_microsoft_pla_browser_snapshot:"Playwright MCP: Browser Snapshot",mcp_microsoft_pla_browser_tabs:"Playwright MCP: Browser Tabs",mcp_microsoft_pla_browser_take_screenshot:"Playwright MCP: Browser Take Screenshot",mcp_microsoft_pla_browser_type:"Playwright MCP: Browser Type",mcp_playwright_browser_click:"Playwright MCP: Browser Click",mcp_playwright_browser_navigate:"Playwright MCP: Browser Navigate",mcp_playwright_browser_snapshot:"Playwright MCP: Browser Snapshot",mcp_playwright_browser_take_screenshot:"Playwright MCP: Browser Take Screenshot",mcp_pylance_mcp_s_pylanceDocString:"Pylance MCP: Pylance Doc String",mcp_pylance_mcp_s_pylanceRunCodeSnippet:"Pylance MCP: Run Code Snippet",mcp_pylance_mcp_s_pylanceWorkspaceRoots:"Pylance MCP: Workspace Roots","mcp_chrome-devtoo_click":"Chrome DevTools MCP: Click","mcp_chrome-devtoo_evaluate_script":"Chrome DevTools MCP: Evaluate Script","mcp_chrome-devtoo_fill":"Chrome DevTools MCP: Fill","mcp_chrome-devtoo_get_network_request":"Chrome DevTools MCP: Get Network Request","mcp_chrome-devtoo_list_console_messages":"Chrome DevTools MCP: List Console Messages","mcp_chrome-devtoo_list_pages":"Chrome DevTools MCP: List Pages","mcp_chrome-devtoo_navigate_page":"Chrome DevTools MCP: Navigate Page","mcp_chrome-devtoo_new_page":"Chrome DevTools MCP: New Page","mcp_chrome-devtoo_select_page":"Chrome DevTools MCP: Select Page","mcp_chrome-devtoo_take_screenshot":"Chrome DevTools MCP: Take Screenshot","mcp_chrome-devtoo_fill_form":"Chrome DevTools MCP: Fill Form","mcp_chrome-devtoo_hover":"Chrome DevTools MCP: Hover","mcp_chrome-devtoo_list_network_requests":"Chrome DevTools MCP: List Network Requests","mcp_chrome-devtoo_press_key":"Chrome DevTools MCP: Press Key","mcp_chrome-devtoo_take_snapshot":"Chrome DevTools MCP: Take Snapshot","mcp_chrome-devtoo_wait_for":"Chrome DevTools MCP: Wait For",mcp_chrome_devtoo_click:"Chrome DevTools MCP: Click",mcp_chrome_devtoo_evaluate_script:"Chrome DevTools MCP: Evaluate Script",mcp_chrome_devtoo_fill:"Chrome DevTools MCP: Fill",mcp_chrome_devtoo_get_console_message:"Chrome DevTools MCP: Get Console Message",mcp_chrome_devtoo_get_network_request:"Chrome DevTools MCP: Get Network Request",mcp_chrome_devtoo_list_console_messages:"Chrome DevTools MCP: List Console Messages",mcp_chrome_devtoo_list_network_requests:"Chrome DevTools MCP: List Network Requests",mcp_chrome_devtoo_list_pages:"Chrome DevTools MCP: List Pages",mcp_chrome_devtoo_navigate_page:"Chrome DevTools MCP: Navigate Page",mcp_chrome_devtoo_new_page:"Chrome DevTools MCP: New Page",mcp_chrome_devtoo_take_snapshot:"Chrome DevTools MCP: Take Snapshot",mcp_chrome_devtoo_wait_for:"Chrome DevTools MCP: Wait For",mcp_io_github_chr_click:"Chrome DevTools MCP: Click",mcp_io_github_chr_emulate:"Chrome DevTools MCP: Emulate",mcp_io_github_chr_evaluate_script:"Chrome DevTools MCP: Evaluate Script",mcp_io_github_chr_list_network_requests:"Chrome DevTools MCP: List Network Requests",mcp_io_github_chr_list_pages:"Chrome DevTools MCP: List Pages",mcp_io_github_chr_navigate_page:"Chrome DevTools MCP: Navigate Page",mcp_io_github_chr_new_page:"Chrome DevTools MCP: New Page",mcp_io_github_chr_resize_page:"Chrome DevTools MCP: Resize Page",mcp_io_github_chr_select_page:"Chrome DevTools MCP: Select Page",mcp_io_github_chr_take_snapshot:"Chrome DevTools MCP: Take Snapshot",mcp_oraios_serena_activate_project:"Serena: Activate Project",mcp_oraios_serena_check_onboarding_performed:"Serena: Check Onboarding Performed",mcp_oraios_serena_create_text_file:"Serena: Create Text File",mcp_oraios_serena_delete_lines:"Serena: Delete Lines",mcp_oraios_serena_delete_memory:"Serena: Delete Memory",mcp_oraios_serena_edit_memory:"Serena: Edit Memory",mcp_oraios_serena_execute_shell_command:"Serena: Execute Shell Command",mcp_oraios_serena_find_file:"Serena: Find File",mcp_oraios_serena_find_referencing_symbols:"Serena: Find Referencing Symbols",mcp_oraios_serena_find_symbol:"Serena: Find Symbol",mcp_oraios_serena_get_current_config:"Serena: Get Current Config",mcp_oraios_serena_get_symbols_overview:"Serena: Get Symbols Overview",mcp_oraios_serena_initial_instructions:"Serena: Initial Instructions",mcp_oraios_serena_insert_after_symbol:"Serena: Insert After Symbol",mcp_oraios_serena_insert_at_line:"Serena: Insert At Line",mcp_oraios_serena_insert_before_symbol:"Serena: Insert Before Symbol",mcp_oraios_serena_jet_brains_find_referencing_symbols:"Serena: JetBrains Find Referencing Symbols",mcp_oraios_serena_jet_brains_find_symbol:"Serena: JetBrains Find Symbol",mcp_oraios_serena_jet_brains_get_symbols_overview:"Serena: JetBrains Get Symbols Overview",mcp_oraios_serena_jet_brains_type_hierarchy:"Serena: JetBrains Type Hierarchy",mcp_oraios_serena_list_dir:"Serena: List Dir",mcp_oraios_serena_list_memories:"Serena: List Memories",mcp_oraios_serena_onboarding:"Serena: Onboarding",mcp_oraios_serena_open_dashboard:"Serena: Open Dashboard",mcp_oraios_serena_prepare_for_new_conversation:"Serena: Prepare For New Conversation",mcp_oraios_serena_read_file:"Serena: Read File",mcp_oraios_serena_read_memory:"Serena: Read Memory",mcp_oraios_serena_remove_project:"Serena: Remove Project",mcp_oraios_serena_rename_symbol:"Serena: Rename Symbol",mcp_oraios_serena_replace_content:"Serena: Replace Content",mcp_oraios_serena_replace_lines:"Serena: Replace Lines",mcp_oraios_serena_replace_symbol_body:"Serena: Replace Symbol Body",mcp_oraios_serena_restart_language_server:"Serena: Restart Language Server",mcp_oraios_serena_search_for_pattern:"Serena: Search For Pattern",mcp_oraios_serena_summarize_changes:"Serena: Summarize Changes",mcp_oraios_serena_switch_modes:"Serena: Switch Modes",mcp_oraios_serena_think_about_collected_information:"Serena: Think About Collected Information",mcp_oraios_serena_think_about_task_adherence:"Serena: Think About Task Adherence",mcp_oraios_serena_think_about_whether_you_are_done:"Serena: Think About Whether You Are Done",mcp_oraios_serena_write_memory:"Serena: Write Memory","mcp_visuals-mcp_display_image":"Visuals MCP: Display Image","mcp_laravel-boost_tinker":"Laravel Boost MCP: Tinker",bash:"Bash",Bash:"Bash",code_search:"Code Search",detect_memories:"Detect Memories",get_currentfile:"Get Current File",get_file:"Get File",get_symbols_by_name:"Get Symbols By Name","claude-code":"Claude Code","copilot-cloud-agent":"Copilot Cloud Agent",agent:"Agent",copilotcli:"Copilot CLI","github.copilot.default":"GitHub Copilot Default","github.copilot.workspace":"GitHub Copilot Workspace","github.copilot.vscode":"GitHub Copilot VSCode","github.copilot-dynamic.platform":"GitHub Copilot Dynamic: Platform",glob:"Glob",file_glob_search:"File Glob Search",grep:"Grep",kill_terminal:"Kill Terminal",read:"Read",view:"View",vscode_editFile_internal:"VSCode Edit File (Internal)",vscode_fetchWebPage_internal:"VSCode Fetch Web Page (Internal)",vscode_searchExtensions_internal:"VSCode Search Extensions (Internal)","vscode-websearchforcopilot_webSearch":"VSCode WebSearch for Copilot: Web Search",Build_CMakeTools:"CMake Tools: Build",ListBuildTargets_CMakeTools:"CMake Tools: List Build Targets",ListTests_CMakeTools:"CMake Tools: List Tests",RunCtest_CMakeTools:"CMake Tools: Run CTest","nuget_get-nuget-solver":"NuGet: Get NuGet Solver",webfetch:"Web Fetch",write:"Write",edit:"Edit",multiedit:"Multi Edit",question:"Question",skill:"Skill",read_skill:"Read Skill",task:"Task",todowrite:"Todo Write",TodoWrite:"Todo Write",todos:"Todos",websearch:"Web Search",WebSearch:"Web Search",click_element:"Click Element",navigate_page:"Navigate Page",open_browser_page:"Open Browser Page",read_page:"Read Page",run_playwright_code:"Run Playwright Code",screenshot_page:"Screenshot Page",type_in_page:"Type in Page",task_complete:"Task Complete","pdf-utilities.pdf":"PDF Utilities: PDF","container-tools_get-config":"Container Tools: Get Config","github-pull-request_activePullRequest":"GitHub Pull Request: Active Pull Request","github-pull-request_issue_fetch":"GitHub Pull Request: Issue Fetch","github-pull-request_pullRequestStatusChecks":"GitHub Pull Request: Pull Request Status Checks","mcp_powerbi-model_connection_operations":"Power BI MCP: Connection Operations",MiniMax_web_search:"MiniMax: Web Search",dingDocuments_get_document_content:"Ding Documents: Get Document Content",dingDocuments_list_nodes:"Ding Documents: List Nodes",dingDocuments_search_documents:"Ding Documents: Search Documents",fetch_fetch:"Fetch: Fetch",mcp__Claude_in_Chrome__computer:"Claude in Chrome MCP: Computer",mcp__Claude_in_Chrome__navigate:"Claude in Chrome MCP: Navigate",mcp__Claude_in_Chrome__tabs_context_mcp:"Claude in Chrome MCP: Tabs Context",mcp__cowork__allow_cowork_file_delete:"Cowork MCP: Allow Cowork File Delete",mcp__cowork__present_files:"Cowork MCP: Present Files",mcp__cowork__request_cowork_directory:"Cowork MCP: Request Cowork Directory","mcp__cowork-onboarding__show_onboarding_role_picker":"Cowork Onboarding MCP: Show Onboarding Role Picker",mcp__plugins__search_plugins:"Plugins MCP: Search Plugins",mcp__plugins__suggest_plugin_install:"Plugins MCP: Suggest Plugin Install",mcp__workspace__bash:"Workspace MCP: Bash",mcp__workspace__web_fetch:"Workspace MCP: Web Fetch",invalid:"Invalid"};var Yr=.2,Qr=21e3,Xr=.3,Zr=Vr.estimators,xo=Jr.pricing,Gc=Kr,zc=n=>{},ea=n=>{},Wc=(n,e)=>console.error(T.red(n),e||"");function Hc(){let n=Bt.file(__dirname);return new Ko(n)}function Vc(){let n=Bt.file(__dirname);return new Qo(n)}function Jc(){return new Xo}function Kc(){return new ds}function Yc(){return new ms}function Qc(){return new gs}var vo=Hc(),Ot=Vc(),ta=Jc(),Dt=Kc(),Kt=Yc(),Yt=Qc();function oa(){return new Wo({log:zc,warn:ea,error:Wc,openCode:vo,crush:Ot,continue_:ta,visualStudio:Dt,claudeCode:Kt,claudeDesktopCowork:Yt})}async function _e(){return oa().getCopilotSessionFiles()}function xs(){return oa().getDiagnosticCandidatePaths()}function Jn(n,e){return te(n,e||"gpt-4",Zr)}function Xc(n){return mt(n,xo)}function sa(n){return n.includes("opencode.db#ses_")}function na(n){return Ot.isCrushSessionFile(n)}async function ia(n){if(na(n))return Ot.statSessionFile(n);if(sa(n)){let e=n.split("#")[0];return vs.promises.stat(e)}return vs.promises.stat(n)}function Jt(n){let e=n.toLowerCase().replace(/\\/g,"/");return e.includes("/cursor/")?"cursor":e.includes("/code - insiders/")?"vscode-insiders":e.includes("/code - exploration/")?"vscode-exploration":e.includes("/vscodium/")?"vscodium":e.includes("/.copilot/")?"copilot-cli":e.includes("/.crush/crush.db#")?"crush":e.includes("/opencode/")?"opencode":e.includes("/local-agent-mode-sessions/")?"claude-desktop-cowork":e.includes("/.claude/projects/")?"claude-code":e.includes(".vscode-server")?"vscode-remote":e.includes("/.vs/")&&e.includes("/copilot-chat/")?"Visual Studio":"vscode"}async function Zc(n,e,t=20){if(n.length===0)return[];let o=new Array(n.length),s=0,r=Array.from({length:Math.min(t,n.length)},async()=>{for(;s<n.length;){let l=s++;try{o[l]=await e(n[l],l)}catch{o[l]=void 0}}});return await Promise.all(r),o}async function Qt(n){try{let e=await ia(n),t=Hr(n,e.mtimeMs,e.size);if(t)return t;if(na(n)){let m=await Ot.getTokensFromCrushSession(n),p=await Ot.countCrushInteractions(n),g=await Ot.getCrushModelUsage(n),_={file:n,tokens:m.tokens,thinkingTokens:m.thinkingTokens,interactions:p,modelUsage:g,lastModified:e.mtime,editorSource:Jt(n)};return Et(n,e.mtimeMs,e.size,_),_}if(sa(n)){let m=await vo.getTokensFromOpenCodeSession(n),p=await vo.countOpenCodeInteractions(n),g=await vo.getOpenCodeModelUsage(n),_={file:n,tokens:m.tokens,thinkingTokens:m.thinkingTokens,interactions:p,modelUsage:g,lastModified:e.mtime,editorSource:Jt(n)};return Et(n,e.mtimeMs,e.size,_),_}if(Dt.isVSSessionFile(n)){let m=Dt.getTokenEstimates(n,Jn),p=Dt.decodeSessionFile(n),g=Dt.countInteractions(p),_=Dt.getModelUsage(n,Jn),w={file:n,tokens:m.tokens,thinkingTokens:m.thinkingTokens,interactions:g,modelUsage:_,lastModified:e.mtime,editorSource:Jt(n)};return Et(n,e.mtimeMs,e.size,w),w}if(Yt.isCoworkSessionFile(n)){let m=Yt.getTokensFromCoworkSession(n),p=Yt.countCoworkInteractions(n),g=Yt.getCoworkModelUsage(n),_={file:n,tokens:m.tokens,thinkingTokens:m.thinkingTokens,interactions:p,modelUsage:g,lastModified:e.mtime,editorSource:Jt(n)};return Et(n,e.mtimeMs,e.size,_),_}if(Kt.isClaudeCodeSessionFile(n)){let m=Kt.getTokensFromClaudeCodeSession(n),p=Kt.countClaudeCodeInteractions(n),g=Kt.getClaudeCodeModelUsage(n),_={file:n,tokens:m.tokens,thinkingTokens:m.thinkingTokens,interactions:p,modelUsage:g,lastModified:e.mtime,editorSource:Jt(n)};return Et(n,e.mtimeMs,e.size,_),_}let o=await vs.promises.readFile(n,"utf-8");if(!o.trim())return null;let s=n.endsWith(".jsonl")||At(o),r=0,l=0,u=0,d={};if(s){let m=Dr(o);r=m.tokens,l=m.thinkingTokens;let p=o.trim().split(`
|
|
47
|
-
`);for(let
|
|
42
|
+
`).filter(n=>n.trim());if(t.length<2)return!1;let s=t[0].trim(),o=t[1].trim();return s.startsWith("{")&&s.endsWith("}")&&o.startsWith("{")&&o.endsWith("}")}function ts(r){let e=r.trim();return/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i.test(e)}function ks(r,e){if(typeof e!="object"||e===null)return r;let{kind:t,k:s,v:o}=e;if(t===0)return o;if(!Array.isArray(s)||s.length===0)return r;let n=s.map(String),a=typeof r=="object"&&r!==null?r:{},d=a;for(let h=0;h<n.length-1;h++){let m=n[h],p=n[h+1],g=/^\d+$/.test(p);if(Array.isArray(d)){let w=Number(m);(!d[w]||typeof d[w]!="object")&&(d[w]=g?[]:{}),d=d[w]}else(!d[m]||typeof d[m]!="object")&&(d[m]=g?[]:{}),d=d[m]}let c=n[n.length-1];if(t===1)return Array.isArray(d)?d[Number(c)]=o:d[c]=o,a;if(t===2){let h;if(Array.isArray(d)){let m=Number(c);Array.isArray(d[m])||(d[m]=[]),h=d[m]}else Array.isArray(d[c])||(d[c]=[]),h=d[c];return Array.isArray(o)?h.push(...o):h.push(o),a}return a}function pt(r,e={}){let t=e[r];if(t&&typeof t.multiplier=="number")return t.multiplier===0?"standard":"premium";for(let[s,o]of Object.entries(e))if((r.includes(s)||s.includes(r))&&typeof o.multiplier=="number")return o.multiplier===0?"standard":"premium";return"unknown"}function oi(r,e={},t="provider"){let s=0;for(let[o,n]of Object.entries(r)){let a=e[o]??e["gpt-4o-mini"];if(!a)continue;let d=t==="copilot"&&a.copilotPricing?a.copilotPricing:a,c=n.cachedReadTokens??0,h=n.cacheCreationTokens??0,p=Math.max(0,n.inputTokens-c-h)/1e6*d.inputCostPerMillion,g=c/1e6*(d.cachedInputCostPerMillion??d.inputCostPerMillion),w=h/1e6*(d.cacheCreationCostPerMillion??d.inputCostPerMillion),k=n.outputTokens/1e6*d.outputCostPerMillion;s+=p+g+w+k}return s}function ye(){return{file:0,selection:0,implicitSelection:0,symbol:0,codebase:0,workspace:0,terminal:0,vscode:0,terminalLastCommand:0,terminalSelection:0,clipboard:0,changes:0,outputPanel:0,problemsPanel:0,byKind:{},copilotInstructions:0,agentsMd:0,byPath:{}}}var Bt=R(require("fs"));function Uo(r){return!r||!r.kind?"ask":r.kind==="edit"?"edit":r.kind==="ask"?"ask":r.kind==="agent"?!r.id||r.id==="agent"?"agent":typeof r.id=="string"&&r.id.includes("plan-agent/Plan.agent.md")?"plan":typeof r.id=="string"&&r.id.includes(".agent.md")?"customAgent":"agent":"ask"}function Xe(r){return r.startsWith("mcp.")||r.startsWith("mcp_")||r.startsWith("mcp__")}function Gt(r){return r.startsWith("mcp_github_github_")?"mcp_io_github_git_"+r.substring(18):r.startsWith("mcp.github.github.")?"mcp.io.github.git."+r.substring(18):r}function Ze(r,e={}){let t=e[r]??e[r.toLowerCase()];if(t&&t.includes(":"))return t.split(":")[0].trim();if(r.startsWith("mcp_io_github_git_")||r.startsWith("mcp.io.github.git."))return"GitHub MCP (Local)";if(r.startsWith("mcp_github_github_")||r.startsWith("mcp.github.github."))return"GitHub MCP (Remote)";if(r.startsWith("mcp__")){let n=r.slice(5),a=n.indexOf("__");return(a>=0?n.slice(0,a):n)||"unknown"}return r.replace(/^mcp[._]/,"").split(/[._]/)[0]||"unknown"}function Ro(r,e){r.toolCalls.total+=e.toolCalls.total;for(let[t,s]of Object.entries(e.toolCalls.byTool))r.toolCalls.byTool[t]=(r.toolCalls.byTool[t]||0)+s;r.modeUsage.ask+=e.modeUsage.ask,r.modeUsage.edit+=e.modeUsage.edit,r.modeUsage.agent+=e.modeUsage.agent,r.modeUsage.plan+=e.modeUsage.plan,r.modeUsage.customAgent+=e.modeUsage.customAgent,r.modeUsage.cli+=e.modeUsage.cli,r.contextReferences.file+=e.contextReferences.file,r.contextReferences.selection+=e.contextReferences.selection,r.contextReferences.implicitSelection+=e.contextReferences.implicitSelection||0,r.contextReferences.symbol+=e.contextReferences.symbol,r.contextReferences.codebase+=e.contextReferences.codebase,r.contextReferences.workspace+=e.contextReferences.workspace,r.contextReferences.terminal+=e.contextReferences.terminal,r.contextReferences.vscode+=e.contextReferences.vscode,r.contextReferences.terminalLastCommand+=e.contextReferences.terminalLastCommand||0,r.contextReferences.terminalSelection+=e.contextReferences.terminalSelection||0,r.contextReferences.clipboard+=e.contextReferences.clipboard||0,r.contextReferences.changes+=e.contextReferences.changes||0,r.contextReferences.outputPanel+=e.contextReferences.outputPanel||0,r.contextReferences.problemsPanel+=e.contextReferences.problemsPanel||0,r.contextReferences.copilotInstructions+=e.contextReferences.copilotInstructions||0,r.contextReferences.agentsMd+=e.contextReferences.agentsMd||0;for(let[t,s]of Object.entries(e.contextReferences.byKind||{}))r.contextReferences.byKind[t]=(r.contextReferences.byKind[t]||0)+s;for(let[t,s]of Object.entries(e.contextReferences.byPath||{}))r.contextReferences.byPath[t]=(r.contextReferences.byPath[t]||0)+s;r.mcpTools.total+=e.mcpTools.total;for(let[t,s]of Object.entries(e.mcpTools.byServer))r.mcpTools.byServer[t]=(r.mcpTools.byServer[t]||0)+s;for(let[t,s]of Object.entries(e.mcpTools.byTool))r.mcpTools.byTool[t]=(r.mcpTools.byTool[t]||0)+s;if(e.modelSwitching||(e.modelSwitching={uniqueModels:[],modelCount:0,switchCount:0,tiers:{standard:[],premium:[],unknown:[]},hasMixedTiers:!1,standardRequests:0,premiumRequests:0,unknownRequests:0,totalRequests:0}),e.modelSwitching.modelCount>0){r.modelSwitching.totalSessions++,r.modelSwitching.modelsPerSession.push(e.modelSwitching.modelCount);for(let t of e.modelSwitching.tiers.standard)r.modelSwitching.standardModels.includes(t)||r.modelSwitching.standardModels.push(t);for(let t of e.modelSwitching.tiers.premium)r.modelSwitching.premiumModels.includes(t)||r.modelSwitching.premiumModels.push(t);for(let t of e.modelSwitching.tiers.unknown)r.modelSwitching.unknownModels.includes(t)||r.modelSwitching.unknownModels.push(t);if(e.modelSwitching.hasMixedTiers&&r.modelSwitching.mixedTierSessions++,r.modelSwitching.standardRequests+=e.modelSwitching.standardRequests||0,r.modelSwitching.premiumRequests+=e.modelSwitching.premiumRequests||0,r.modelSwitching.unknownRequests+=e.modelSwitching.unknownRequests||0,r.modelSwitching.totalRequests+=e.modelSwitching.totalRequests||0,r.modelSwitching.modelsPerSession.length>0){let t=r.modelSwitching.modelsPerSession;r.modelSwitching.averageModelsPerSession=t.reduce((s,o)=>s+o,0)/t.length,r.modelSwitching.maxModelsPerSession=Math.max(...t),r.modelSwitching.minModelsPerSession=Math.min(...t),r.modelSwitching.switchingFrequency=t.filter(s=>s>1).length/t.length*100}}if(e.editScope){r.editScope.singleFileEdits+=e.editScope.singleFileEdits,r.editScope.multiFileEdits+=e.editScope.multiFileEdits,r.editScope.totalEditedFiles+=e.editScope.totalEditedFiles;let t=r.editScope.singleFileEdits+r.editScope.multiFileEdits;r.editScope.avgFilesPerSession=t>0?r.editScope.totalEditedFiles/t:0}if(e.applyUsage&&(r.applyUsage.totalApplies+=e.applyUsage.totalApplies,r.applyUsage.totalCodeBlocks+=e.applyUsage.totalCodeBlocks,r.applyUsage.applyRate=r.applyUsage.totalCodeBlocks>0?r.applyUsage.totalApplies/r.applyUsage.totalCodeBlocks*100:0),e.sessionDuration){r.sessionDuration.totalDurationMs+=e.sessionDuration.totalDurationMs;let t=r.sessions;if(t>0){r.sessionDuration.avgDurationMs=r.sessionDuration.totalDurationMs/t;let s=r.sessionDuration.avgFirstProgressMs*(t-1);r.sessionDuration.avgFirstProgressMs=(s+e.sessionDuration.avgFirstProgressMs)/t;let o=r.sessionDuration.avgTotalElapsedMs*(t-1);r.sessionDuration.avgTotalElapsedMs=(o+e.sessionDuration.avgTotalElapsedMs)/t;let n=r.sessionDuration.avgWaitTimeMs*(t-1);r.sessionDuration.avgWaitTimeMs=(n+e.sessionDuration.avgWaitTimeMs)/t}}if(e.conversationPatterns){r.conversationPatterns.multiTurnSessions+=e.conversationPatterns.multiTurnSessions,r.conversationPatterns.singleTurnSessions+=e.conversationPatterns.singleTurnSessions,r.conversationPatterns.maxTurnsInSession=Math.max(r.conversationPatterns.maxTurnsInSession,e.conversationPatterns.maxTurnsInSession);let t=r.conversationPatterns.multiTurnSessions+r.conversationPatterns.singleTurnSessions;if(t>0){let o=r.conversationPatterns.avgTurnsPerSession*(t-1)+e.conversationPatterns.avgTurnsPerSession;r.conversationPatterns.avgTurnsPerSession=o/t}}if(e.agentTypes&&(r.agentTypes.editsAgent+=e.agentTypes.editsAgent,r.agentTypes.defaultAgent+=e.agentTypes.defaultAgent,r.agentTypes.workspaceAgent+=e.agentTypes.workspaceAgent,r.agentTypes.other+=e.agentTypes.other),e.thinkingEffort){r.thinkingEffortUsage||(r.thinkingEffortUsage={byEffort:{},sessionCount:0,switchCount:0}),r.thinkingEffortUsage.sessionCount++,r.thinkingEffortUsage.switchCount+=e.thinkingEffort.switchCount;for(let[t,s]of Object.entries(e.thinkingEffort.byEffort))r.thinkingEffortUsage.byEffort[t]=(r.thinkingEffortUsage.byEffort[t]||0)+s}}function ia(r,e){let t=r.match(/#file/gi);t&&(e.file+=t.length);let s=r.match(/#selection/gi);s&&(e.selection+=s.length);let o=r.match(/#symbol/gi),n=r.match(/#sym(?![:\w])/gi);o&&(e.symbol+=o.length),n&&(e.symbol+=n.length);let a=r.match(/#codebase/gi);a&&(e.codebase+=a.length);let d=r.match(/#terminalLastCommand/gi);d&&(e.terminalLastCommand+=d.length);let c=r.match(/#terminalSelection/gi);c&&(e.terminalSelection+=c.length);let h=r.match(/#clipboard/gi);h&&(e.clipboard+=h.length);let m=r.match(/#changes/gi);m&&(e.changes+=m.length);let p=r.match(/#outputPanel/gi);p&&(e.outputPanel+=p.length);let g=r.match(/#problemsPanel/gi);g&&(e.problemsPanel+=g.length);let w=r.match(/@workspace/gi);w&&(e.workspace+=w.length);let k=r.match(/@terminal/gi);k&&(e.terminal+=k.length);let b=r.match(/@vscode/gi);b&&(e.vscode+=b.length)}function ii(r,e){if(Array.isArray(r))for(let t of r){if(!t||typeof t!="object")continue;let s=t.kind;typeof s=="string"&&(e.byKind[s]=(e.byKind[s]||0)+1);let o=null;if(s==="reference"&&t.reference?o=t.reference:s==="inlineReference"&&t.inlineReference&&(o=t.inlineReference),o){let n=o.fsPath||o.path;if(typeof n=="string"){let d=n.replace(/\\/g,"/").toLowerCase();d.endsWith("/.github/copilot-instructions.md")||d.includes(".github/copilot-instructions.md")?e.copilotInstructions++:d.endsWith("/agents.md")||d.match(/\/agents\.md$/i)?e.agentsMd++:d.endsWith(".instructions.md")||d.includes(".instructions.md")?e.copilotInstructions++:e.file++;let c=n.length>100?"..."+n.substring(n.length-97):n;e.byPath[c]=(e.byPath[c]||0)+1}let a=o.name;if(typeof a=="string"&&s==="reference"){e.symbol++;let d=`#sym:${a}`;e.byPath[d]=(e.byPath[d]||0)+1}}}}function aa(r,e){if(!(!r||!Array.isArray(r.variables)))for(let t of r.variables){if(!t||typeof t!="object")continue;let s=t.kind;if(typeof s=="string"&&(e.byKind[s]=(e.byKind[s]||0)+1),s==="generic"&&typeof t.name=="string"&&t.name.startsWith("sym:")){e.symbol++;let o=`#${t.name}`;e.byPath[o]=(e.byPath[o]||0)+1}if(s==="promptFile"&&t.value){let o=t.value,n=o.fsPath||o.path||o.external;if(typeof n=="string"){let a=n.replace(/\\/g,"/").toLowerCase();a.endsWith("/.github/copilot-instructions.md")||a.includes(".github/copilot-instructions.md")||a.endsWith("/agents.md")||a.match(/\/agents\.md$/i)}}}}function ri(r){let e=r.modeUsage.ask+r.modeUsage.edit+r.modeUsage.agent+r.modeUsage.cli;r.conversationPatterns={multiTurnSessions:e>1?1:0,singleTurnSessions:e===1?1:0,avgTurnsPerSession:e,maxTurnsInSession:e}}function ni(r,e){if(r.message&&(r.message.text&&ia(r.message.text,e),r.message.parts))for(let t of r.message.parts)t.text&&ia(t.text,e);r.contentReferences&&Array.isArray(r.contentReferences)&&ii(r.contentReferences,e),r.variableData&&aa(r.variableData,e)}function Fo(r){try{let t=Bt.readFileSync(r,"utf8").trim().split(`
|
|
43
|
+
`),s=[];for(let o of t)if(o.trim())try{s.push(JSON.parse(o))}catch{}return s}catch{return[]}}function De(r,e,t,s){let o=[],n=[],a=[];for(let m of e){let p=pt(m,r);p==="standard"?o.push(m):p==="premium"?n.push(m):a.push(m)}s.modelSwitching.tiers={standard:o,premium:n,unknown:a},s.modelSwitching.hasMixedTiers=o.length>0&&n.length>0;let d=0,c=0,h=0;for(let m of t){let p=pt(m,r);p==="standard"?d++:p==="premium"?c++:h++}s.modelSwitching.standardRequests=d,s.modelSwitching.premiumRequests=c,s.modelSwitching.unknownRequests=h}async function ra(r,e,t,s){try{let o=await hu(r,e,s),n=o?Object.keys(o).length:0;if(!o||n===0)return;let a=Object.keys(o);t.modelSwitching.uniqueModels=a,t.modelSwitching.modelCount=a.length;let d=[],c=[],h=[];for(let g of a){let w=pt(g,r.modelPricing);w==="standard"?d.push(g):w==="premium"?c.push(g):h.push(g)}t.modelSwitching.tiers={standard:d,premium:c,unknown:h},t.modelSwitching.hasMixedTiers=d.length>0&&c.length>0;let m=s??await Bt.promises.readFile(e,"utf8");if(ts(m))return;if(e.endsWith(".jsonl")||dt(m)){let g=m.trim().split(`
|
|
44
|
+
`),w={standard:0,premium:0,unknown:0},k="gpt-4o";for(let b of g)if(b.trim())try{let y=JSON.parse(b);if(y.kind===0){let v=y.v?.selectedModel?.identifier||y.v?.selectedModel?.metadata?.id||y.v?.inputState?.selectedModel?.metadata?.id;v&&(k=v.replace(/^copilot\//,""))}if(y.kind===2&&y.k?.[0]==="selectedModel"){let v=y.v?.identifier||y.v?.metadata?.id;v&&(k=v.replace(/^copilot\//,""))}if(y.type==="user.message"){let v=y.model||k,C=pt(v,r.modelPricing);C==="standard"?w.standard++:C==="premium"?w.premium++:w.unknown++}if(y.kind===2&&y.k?.[0]==="requests"&&Array.isArray(y.v))for(let v of y.v){let C=k;v.modelId?C=v.modelId.replace(/^copilot\//,""):v.result?.metadata?.modelId?C=v.result.metadata.modelId.replace(/^copilot\//,""):v.result?.details&&(C=xt(v,r.modelPricing));let P=pt(C,r.modelPricing);P==="standard"?w.standard++:P==="premium"?w.premium++:w.unknown++}}catch{}t.modelSwitching.standardRequests=w.standard,t.modelSwitching.premiumRequests=w.premium,t.modelSwitching.unknownRequests=w.unknown,t.modelSwitching.totalRequests=w.standard+w.premium+w.unknown}else{let g=JSON.parse(m);if(g.requests&&Array.isArray(g.requests)){let w=null,k=0,b={standard:0,premium:0,unknown:0};for(let y of g.requests){let v=xt(y,r.modelPricing);w&&v!==w&&k++,w=v;let C=pt(v,r.modelPricing);C==="standard"?b.standard++:C==="premium"?b.premium++:b.unknown++}t.modelSwitching.switchCount=k,t.modelSwitching.standardRequests=b.standard,t.modelSwitching.premiumRequests=b.premium,t.modelSwitching.unknownRequests=b.unknown,t.modelSwitching.totalRequests=b.standard+b.premium+b.unknown}}}catch(o){r.warn(`Error calculating model switching for ${e}: ${o}`)}}async function mu(r,e,t,s){try{let o=s??await Bt.promises.readFile(e,"utf8");if(ts(o))return;let n=e.endsWith(".jsonl")||dt(o),a=new Set,d=0,c=0,h=[],m=[],p=[],g={editsAgent:0,defaultAgent:0,workspaceAgent:0,other:0};if(n){let C=o.trim().split(`
|
|
45
|
+
`).filter(M=>M.trim()),P=!1;if(C.length>0)try{let M=JSON.parse(C[0]);M&&typeof M.kind=="number"&&(P=!0)}catch{}if(P){let M={};for(let D of C)try{let N=JSON.parse(D);M=ks(M,N)}catch{}M.creationDate&&h.push(M.creationDate),M.lastMessageDate&&h.push(M.lastMessageDate);let F=M.requests||[];for(let D of F)if(D){if(D.timestamp&&h.push(D.timestamp),D.result?.timings&&m.push(D.result.timings),D.timeSpentWaiting!==void 0&&p.push(D.timeSpentWaiting),D.agent?.id){let N=D.agent.id;N.includes("edit")?g.editsAgent++:N.includes("default")?g.defaultAgent++:N.includes("workspace")?g.workspaceAgent++:g.other++}if(D.response&&Array.isArray(D.response)){for(let N of D.response)if(N){if(N.kind==="textEditGroup"&&N.uri){let H=N.uri.path||JSON.stringify(N.uri);a.add(H)}N.kind==="codeblockUri"&&(c++,N.isEdit===!0&&d++)}}}}}else{let C=JSON.parse(o);if(C.creationDate&&h.push(C.creationDate),C.lastMessageDate&&h.push(C.lastMessageDate),C.requests&&Array.isArray(C.requests))for(let P of C.requests){if(P.timestamp&&h.push(P.timestamp),P.result?.timings&&m.push(P.result.timings),P.timeSpentWaiting!==void 0&&p.push(P.timeSpentWaiting),P.agent?.id){let M=P.agent.id;M.includes("edit")?g.editsAgent++:M.includes("default")?g.defaultAgent++:M.includes("workspace")?g.workspaceAgent++:g.other++}if(P.response&&Array.isArray(P.response)){for(let M of P.response)if(M){if(M.kind==="textEditGroup"&&M.uri){let F=M.uri.path||JSON.stringify(M.uri);a.add(F)}M.kind==="codeblockUri"&&(c++,M.isEdit===!0&&d++)}}}}let w=a.size>0?1:0;t.editScope={singleFileEdits:a.size===1?1:0,multiFileEdits:a.size>1?1:0,totalEditedFiles:a.size,avgFilesPerSession:w>0?a.size/w:0},t.applyUsage={totalApplies:d,totalCodeBlocks:c,applyRate:c>0?d/c*100:0};let k=h.length>=2?Math.max(...h)-Math.min(...h):0,b=m.length>0?m.reduce((C,P)=>C+(P.firstProgress||0),0)/m.length:0,y=m.length>0?m.reduce((C,P)=>C+(P.totalElapsed||0),0)/m.length:0,v=p.length>0?p.reduce((C,P)=>C+P,0)/p.length:0;t.sessionDuration={totalDurationMs:k,avgDurationMs:k,avgFirstProgressMs:b,avgTotalElapsedMs:y,avgWaitTimeMs:v},ri(t),t.agentTypes=g}catch(o){r.warn(`Error tracking enhanced metrics from ${e}: ${o}`)}}function ke(){return{toolCalls:{total:0,byTool:{}},modeUsage:{ask:0,edit:0,agent:0,plan:0,customAgent:0,cli:0},contextReferences:ye(),mcpTools:{total:0,byServer:{},byTool:{}},modelSwitching:{uniqueModels:[],modelCount:0,switchCount:0,tiers:{standard:[],premium:[],unknown:[]},hasMixedTiers:!1,standardRequests:0,premiumRequests:0,unknownRequests:0,totalRequests:0}}}async function la(r,e,t){let s=ke();try{let o=r.ecosystems.find(c=>c.handles(e));if(o&&Tr(o))return o.analyzeUsage(e,{modelPricing:r.modelPricing,toolNameMap:r.toolNameMap});let n=t??await Bt.promises.readFile(e,"utf8");if(e.endsWith(".jsonl")||dt(n)){let c=n.trim().split(`
|
|
46
|
+
`).filter(b=>b.trim()),h=!1;if(c.length>0)try{let b=JSON.parse(c[0]);b&&typeof b.kind=="number"&&(h=!0)}catch{}if(h){let b={};for(let C of c)try{let P=JSON.parse(C);b=ks(b,P)}catch{}let y=b.inputState?.mode?Uo(b.inputState.mode):"ask";if(b.inputState?.selections&&Array.isArray(b.inputState.selections)){for(let C of b.inputState.selections)if(C&&(C.startLineNumber!==C.endLineNumber||C.startColumn!==C.endColumn)){s.contextReferences.implicitSelection++;break}}let v=b.requests||[];for(let C of v)if(!(!C||!C.requestId)){if(y==="agent"?s.modeUsage.agent++:y==="edit"?s.modeUsage.edit++:y==="plan"?s.modeUsage.plan++:y==="customAgent"?s.modeUsage.customAgent++:s.modeUsage.ask++,C.agent?.id){let P=C.agent.id;s.toolCalls.total++,s.toolCalls.byTool[P]=(s.toolCalls.byTool[P]||0)+1}if(ni(C,s.contextReferences),C.response&&Array.isArray(C.response)){for(let P of C.response)if(P&&(P.kind==="toolInvocationSerialized"||P.kind==="prepareToolInvocation")){let M=P.toolId||P.toolName||P.invocationMessage?.toolName||P.toolSpecificData?.kind||"unknown";if(Xe(M)){s.mcpTools.total++;let F=Ze(M,r.toolNameMap);s.mcpTools.byServer[F]=(s.mcpTools.byServer[F]||0)+1;let D=Gt(M);s.mcpTools.byTool[D]=(s.mcpTools.byTool[D]||0)+1}else s.toolCalls.total++,s.toolCalls.byTool[M]=(s.toolCalls.byTool[M]||0)+1}}}{let C=(b.selectedModel?.identifier||b.selectedModel?.metadata?.id||b.inputState?.selectedModel?.metadata?.id||"gpt-4o").replace(/^copilot\//,""),P=[];for(let D of v){if(!D||!D.requestId)continue;let N=C;D.modelId?N=D.modelId.replace(/^copilot\//,""):D.result?.metadata?.modelId?N=D.result.metadata.modelId.replace(/^copilot\//,""):D.result?.details&&(N=xt(D,r.modelPricing)),P.push(N)}let M=[...new Set(P)];s.modelSwitching.uniqueModels=M,s.modelSwitching.modelCount=M.length,s.modelSwitching.totalRequests=P.length;let F=0;for(let D=1;D<P.length;D++)P[D]!==P[D-1]&&F++;s.modelSwitching.switchCount=F,De(r.modelPricing,M,P,s)}{let{effortByRequestId:C,defaultEffort:P,switchCount:M}=na(c);if(P!==null||C.size>0){let F={};for(let[,D]of C)F[D]=(F[D]||0)+1;C.size===0&&P!==null&&(F[P]=v.length),s.thinkingEffort={byEffort:F,switchCount:M,defaultEffort:P}}}return ri(s),s}let m="ask",p="gpt-4o",g=null,w=0,k={};for(let b of c)if(b.trim())try{let y=JSON.parse(b);if(y.type==="session.start"&&y.data&&(typeof y.data.selectedModel=="string"&&(p=y.data.selectedModel),typeof y.data.reasoningEffort=="string"&&(g=y.data.reasoningEffort)),y.type==="user.message"){w++;let v=typeof y.data?.reasoningEffort=="string"?y.data.reasoningEffort:g;v&&(k[v]=(k[v]||0)+1)}if(y.kind===0&&y.v?.inputState?.mode&&(m=Uo(y.v.inputState.mode),y.v?.inputState?.selections&&Array.isArray(y.v.inputState.selections))){for(let v of y.v.inputState.selections)if(v.startLineNumber!==v.endLineNumber||v.startColumn!==v.endColumn){s.contextReferences.implicitSelection++;break}}if(y.kind===1&&y.k?.includes("mode")&&y.v&&(m=Uo(y.v)),y.kind===1&&y.k?.includes("selections")&&Array.isArray(y.v)){for(let v of y.v)if(v&&(v.startLineNumber!==v.endLineNumber||v.startColumn!==v.endColumn)){s.contextReferences.implicitSelection++;break}}if(y.kind===1&&y.k?.includes("contentReferences")&&Array.isArray(y.v)&&ii(y.v,s.contextReferences),y.kind===1&&y.k?.includes("variableData")&&y.v&&aa(y.v,s.contextReferences),y.kind===2&&y.k?.[0]==="requests"&&Array.isArray(y.v))for(let v of y.v){if(v.requestId&&(m==="agent"?s.modeUsage.agent++:m==="edit"?s.modeUsage.edit++:m==="plan"?s.modeUsage.plan++:m==="customAgent"?s.modeUsage.customAgent++:s.modeUsage.ask++),v.agent?.id){let C=v.agent.id;s.toolCalls.total++,s.toolCalls.byTool[C]=(s.toolCalls.byTool[C]||0)+1}if(ni(v,s.contextReferences),v.response&&Array.isArray(v.response)){for(let C of v.response)if(C&&(C.kind==="toolInvocationSerialized"||C.kind==="prepareToolInvocation")){s.toolCalls.total++;let P=C.toolId||C.toolName||C.invocationMessage?.toolName||C.toolSpecificData?.kind||"unknown";s.toolCalls.byTool[P]=(s.toolCalls.byTool[P]||0)+1}}}if(y.kind===2&&y.k?.includes("response")&&Array.isArray(y.v)){for(let v of y.v)if(v&&v.kind==="toolInvocationSerialized"){s.toolCalls.total++;let C=v.toolId||v.toolName||v.invocationMessage?.toolName||v.toolSpecificData?.kind||"unknown";s.toolCalls.byTool[C]=(s.toolCalls.byTool[C]||0)+1}}if(y.type==="user.message"&&s.modeUsage.cli++,y.type==="tool.call"||y.type==="tool.result"){let v=y.data?.toolName||y.toolName||"unknown";if(Xe(v)){s.mcpTools.total++;let C=Ze(v,r.toolNameMap);s.mcpTools.byServer[C]=(s.mcpTools.byServer[C]||0)+1;let P=Gt(v);s.mcpTools.byTool[P]=(s.mcpTools.byTool[P]||0)+1}else s.toolCalls.total++,s.toolCalls.byTool[v]=(s.toolCalls.byTool[v]||0)+1}if(y.type==="mcp.tool.call"||y.data?.mcpServer){s.mcpTools.total++;let v=y.data?.mcpServer||"unknown",C=y.data?.toolName||y.toolName||"unknown";s.mcpTools.byServer[v]=(s.mcpTools.byServer[v]||0)+1;let P=Gt(C);s.mcpTools.byTool[P]=(s.mcpTools.byTool[P]||0)+1}}catch{}if(g!==null||Object.keys(k).length>0){let b=Object.keys(k).length>0?k:g!==null?{[g]:w}:{};s.thinkingEffort={byEffort:b,switchCount:0,defaultEffort:g}}return await ra(r,e,s,n),ri(s),s}let d=JSON.parse(n);if(d.requests&&Array.isArray(d.requests))for(let c of d.requests){let h="ask";if(c.agent?.id){let m=c.agent.id.toLowerCase();m.includes("edit")?h="edit":m.includes("agent")&&(h="agent")}else if(d.mode?.id){let m=d.mode.id.toLowerCase();m.includes("agent")?h="agent":m.includes("edit")&&(h="edit")}if(h==="agent"?s.modeUsage.agent++:h==="edit"?s.modeUsage.edit++:s.modeUsage.ask++,ni(c,s.contextReferences),c.response&&Array.isArray(c.response)){for(let m of c.response)if(m){if(m.kind==="toolInvocationSerialized"||m.kind==="prepareToolInvocation"){let p=m.toolId||m.toolName||m.invocationMessage?.toolName||"unknown";if(Xe(p)){s.mcpTools.total++;let g=Ze(p,r.toolNameMap);s.mcpTools.byServer[g]=(s.mcpTools.byServer[g]||0)+1;let w=Gt(p);s.mcpTools.byTool[w]=(s.mcpTools.byTool[w]||0)+1}else s.toolCalls.total++,s.toolCalls.byTool[p]=(s.toolCalls.byTool[p]||0)+1}if(m.kind==="mcpServersStarting"&&m.didStartServerIds)for(let p of m.didStartServerIds)s.mcpTools.total++,s.mcpTools.byServer[p]=(s.mcpTools.byServer[p]||0)+1;m.kind==="inlineReference"&&m.inlineReference&&ii([m],s.contextReferences)}}}await ra(r,e,s,n),await mu(r,e,s,n)}catch(o){r.warn(`Error analyzing session usage from ${e}: ${o}`)}return s}async function hu(r,e,t){let s={};if(r.ecosystems){let n=r.ecosystems.find(a=>a.handles(e));if(n)return n.getModelUsage(e)}let o=e.split(/[/\\]/).pop()||e;try{let n=t??await Bt.promises.readFile(e,"utf8");if(ts(n))return s;if(e.endsWith(".jsonl")||dt(n)){let c=n.trim().split(`
|
|
47
|
+
`),h="gpt-4o",m={},p=!1,g=null;for(let k of c)if(k.trim())try{let b=JSON.parse(k);if(typeof b.kind=="number"&&(p=!0,m=ks(m,b)),b.type==="session.start"&&typeof b.data?.selectedModel=="string"&&(h=b.data.selectedModel),b.kind===0){let v=b.v?.selectedModel?.identifier||b.v?.selectedModel?.metadata?.id||b.v?.inputState?.selectedModel?.metadata?.id;v&&(h=v.replace(/^copilot\//,""))}if(b.kind===2&&b.k?.[0]==="selectedModel"){let v=b.v?.identifier||b.v?.metadata?.id;v&&(h=v.replace(/^copilot\//,""))}let y=b.model||h;if(s[y]||(s[y]={inputTokens:0,outputTokens:0}),!p)if(b.type==="session.shutdown"&&b.data?.modelMetrics){g||(g={});for(let[v,C]of Object.entries(b.data.modelMetrics)){let P=C?.usage;P&&(g[v]||(g[v]={inputTokens:0,outputTokens:0}),g[v].inputTokens+=typeof P.inputTokens=="number"?P.inputTokens:0,g[v].outputTokens+=typeof P.outputTokens=="number"?P.outputTokens:0)}}else b.type==="user.message"&&b.data?.content?s[y].inputTokens+=ee(b.data.content,y,r.tokenEstimators):b.type==="assistant.message"&&b.data?.content?s[y].outputTokens+=ee(b.data.content,y,r.tokenEstimators):b.type==="tool.result"&&b.data?.output&&(s[y].inputTokens+=ee(b.data.output,y,r.tokenEstimators))}catch{}if(!p&&g)return g;if(p&&m.requests&&Array.isArray(m.requests))for(let k of m.requests){if(!k||!k.requestId)continue;let b=h;if(k.modelId?b=k.modelId.replace(/^copilot\//,""):k.result?.metadata?.modelId?b=k.result.metadata.modelId.replace(/^copilot\//,""):k.result?.details&&(b=xt(k,r.modelPricing)),s[b]||(s[b]={inputTokens:0,outputTokens:0}),k.result?.usage){let y=k.result.usage;s[b].inputTokens+=typeof y.promptTokens=="number"?y.promptTokens:0,s[b].outputTokens+=typeof y.completionTokens=="number"?y.completionTokens:0}else if(typeof k.result?.promptTokens=="number"&&typeof k.result?.outputTokens=="number")s[b].inputTokens+=k.result.promptTokens,s[b].outputTokens+=k.result.outputTokens;else if(k.result?.metadata&&typeof k.result.metadata.promptTokens=="number"&&typeof k.result.metadata.outputTokens=="number")s[b].inputTokens+=k.result.metadata.promptTokens,s[b].outputTokens+=k.result.metadata.outputTokens;else if(k.message?.text&&(s[b].inputTokens+=ee(k.message.text,b,r.tokenEstimators)),k.response&&Array.isArray(k.response))for(let y of k.response)y?.value&&(s[b].outputTokens+=ee(y.value,b,r.tokenEstimators));if(k.response&&Array.isArray(k.response))for(let y of k.response){let v=vt(y);if(v){let C=v.modelName||b;s[C]||(s[C]={inputTokens:0,outputTokens:0}),v.prompt&&(s[C].inputTokens+=ee(v.prompt,C,r.tokenEstimators)),v.result&&(s[C].outputTokens+=ee(v.result,C,r.tokenEstimators))}}}let w=si(c);for(let[k,b]of w){let y=m.requests?.[k];if(!y||y.result?.usage||typeof y.result?.promptTokens=="number"||y.result?.metadata&&typeof y.result.metadata.promptTokens=="number")continue;let v=h;y.modelId&&(v=y.modelId.replace(/^copilot\//,"")),s[v]||(s[v]={inputTokens:0,outputTokens:0}),s[v].inputTokens+=b.promptTokens,s[v].outputTokens+=b.outputTokens}return s}let d=JSON.parse(n);if(d.requests&&Array.isArray(d.requests))for(let c of d.requests){let h=xt(c,r.modelPricing);if(s[h]||(s[h]={inputTokens:0,outputTokens:0}),c.result?.usage){let m=c.result.usage;s[h].inputTokens+=typeof m.promptTokens=="number"?m.promptTokens:0,s[h].outputTokens+=typeof m.completionTokens=="number"?m.completionTokens:0}else if(typeof c.result?.promptTokens=="number"&&typeof c.result?.outputTokens=="number")s[h].inputTokens+=c.result.promptTokens,s[h].outputTokens+=c.result.outputTokens;else if(c.result?.metadata&&typeof c.result.metadata.promptTokens=="number"&&typeof c.result.metadata.outputTokens=="number")s[h].inputTokens+=c.result.metadata.promptTokens,s[h].outputTokens+=c.result.metadata.outputTokens;else{if(c.message&&c.message.parts){for(let m of c.message.parts)if(m.text){let p=ee(m.text,h,r.tokenEstimators);s[h].inputTokens+=p}}if(c.response&&Array.isArray(c.response)){for(let m of c.response)if(m?.value){let p=ee(m.value,h,r.tokenEstimators);s[h].outputTokens+=p}}}if(c.response&&Array.isArray(c.response))for(let m of c.response){let p=vt(m);if(p){let g=p.modelName||h;s[g]||(s[g]={inputTokens:0,outputTokens:0}),p.prompt&&(s[g].inputTokens+=ee(p.prompt,g,r.tokenEstimators)),p.result&&(s[g].outputTokens+=ee(p.result,g,r.tokenEstimators))}}}}catch(n){r.warn(`Error getting model usage from ${e}: ${n}`)}return s}var vs=class{constructor(e){this.openCode=e}openCode;id="opencode";displayName="OpenCode";handles(e){return this.openCode.isOpenCodeSessionFile(e)}getBackingPath(e){return this.openCode.isOpenCodeDbSession(e)?mt.join(this.openCode.getOpenCodeDataDir(),"opencode.db"):e}async stat(e){return this.openCode.statSessionFile(e)}async getTokens(e){let t=await this.openCode.getTokensFromOpenCodeSession(e);return{...t,actualTokens:t.tokens}}async countInteractions(e){return this.openCode.countOpenCodeInteractions(e)}async getModelUsage(e){return this.openCode.getOpenCodeModelUsage(e)}async getMeta(e){let t=[],s,o,n=this.openCode.getOpenCodeSessionId(e),a=null;if(this.openCode.isOpenCodeDbSession(e)&&n)a=await this.openCode.readOpenCodeDbSession(n);else try{let c=await ss.promises.readFile(e,"utf8");a=JSON.parse(c)}catch{}a&&(s=a.title||a.slug,o=a.directory||void 0,a.time?.created&&t.push(a.time.created),a.time?.updated&&t.push(a.time.updated));let d=await this.openCode.getOpenCodeMessagesForSession(e);for(let c of d)c.time?.created&&t.push(c.time.created),c.time?.completed&&t.push(c.time.completed);return t.sort((c,h)=>c-h),{title:s,firstInteraction:t.length>0?new Date(t[0]).toISOString():null,lastInteraction:t.length>0?new Date(t[t.length-1]).toISOString():null,workspacePath:o}}getEditorRoot(e){return this.openCode.getOpenCodeDataDir()}async discover(e){let t=this.getCandidatePaths(),s=[],o=this.openCode.getOpenCodeDataDir(),n=mt.join(o,"storage","session"),a=mt.join(o,"opencode.db");e(`\u{1F4C1} Checking OpenCode JSON path: ${n}`),e(`\u{1F4C1} Checking OpenCode DB path: ${a}`);try{await ss.promises.access(n);let d=async h=>{try{let m=await ss.promises.readdir(h,{withFileTypes:!0});for(let p of m)if(p.isDirectory())await d(mt.join(h,p.name));else if(p.name.startsWith("ses_")&&p.name.endsWith(".json")){let g=mt.join(h,p.name);try{(await ss.promises.stat(g)).size>0&&s.push(g)}catch{}}}catch{}};await d(n);let c=s.length;c>0&&e(`\u{1F4C4} Found ${c} session files in OpenCode storage`)}catch{}try{await ss.promises.access(a);let d=new Set(s.filter(m=>this.openCode.isOpenCodeSessionFile(m)).map(m=>this.openCode.getOpenCodeSessionId(m)).filter(Boolean)),c=await this.openCode.discoverOpenCodeDbSessions(),h=0;for(let m of c)d.has(m)||(s.push(mt.join(o,`opencode.db#${m}`)),h++);h>0&&e(`\u{1F4C4} Found ${h} additional session(s) in OpenCode database`)}catch{}return{sessionFiles:s,candidatePaths:t}}getCandidatePaths(){let e=this.openCode.getOpenCodeDataDir();return[{path:mt.join(e,"storage","session"),source:"OpenCode (JSON)"},{path:mt.join(e,"opencode.db"),source:"OpenCode (DB)"}]}async buildTurns(e){let t=[],s=await this.openCode.getOpenCodeMessagesForSession(e);if(s.length>0){let o=0,n=0;for(let a=0;a<s.length;a++){let d=s[a];if(d.role!=="user")continue;o++;let c=s.filter((P,M)=>M>a&&P.role==="assistant"&&P.parentID===d.id),m=(await this.openCode.getOpenCodePartsForMessage(d.id)).filter(P=>P.type==="text").map(P=>P.text||"").join(`
|
|
48
|
+
`),p="",g=[],w=null,k=0,b=n;for(let P of c){w||(w=P.modelID||null),k+=P.tokens?.reasoning||0,typeof P.tokens?.total=="number"&&(b=Math.max(b,P.tokens.total));let M=await this.openCode.getOpenCodePartsForMessage(P.id);for(let F of M)F.type==="text"&&F.text?p+=F.text:F.type==="tool"&&F.tool&&g.push({toolName:F.tool,arguments:F.state?.input?JSON.stringify(F.state.input):void 0,result:F.state?.output||void 0})}let y=b-n,v=c.reduce((P,M)=>P+(M.tokens?.output||0)+(M.tokens?.reasoning||0),0),C=Math.max(0,y-v);t.push({turnNumber:o,timestamp:d.time?.created?new Date(d.time.created).toISOString():null,mode:"cli",userMessage:m,assistantResponse:p,model:w,toolCalls:g,contextReferences:ye(),mcpTools:[],inputTokensEstimate:C,outputTokensEstimate:v-k,thinkingTokensEstimate:k}),n=b}}return{turns:t}}async getSyncData(e){return this.openCode.getOpenCodeSessionData(e)}async analyzeUsage(e,t){let s=ke(),o=await this.openCode.getOpenCodeMessagesForSession(e);if(o.length>0){let n=[];for(let c of o)if(c.role==="user"&&s.modeUsage.cli++,c.role==="assistant"){let h=c.modelID||"unknown";n.push(h);let m=await this.openCode.getOpenCodePartsForMessage(c.id);for(let p of m)if(p.type==="tool"&&p.tool){s.toolCalls.total++;let g=p.tool;s.toolCalls.byTool[g]=(s.toolCalls.byTool[g]||0)+1}}let a=[...new Set(n)];s.modelSwitching.uniqueModels=a,s.modelSwitching.modelCount=a.length,s.modelSwitching.totalRequests=n.length;let d=0;for(let c=1;c<n.length;c++)n[c]!==n[c-1]&&d++;s.modelSwitching.switchCount=d}return s}};var ca=R(require("fs")),ht=R(require("path"));var xs=class{constructor(e){this.crush=e}crush;id="crush";displayName="Crush";handles(e){return this.crush.isCrushSessionFile(e)}getBackingPath(e){return this.crush.getCrushDbPath(e)}async stat(e){return this.crush.statSessionFile(e)}async getTokens(e){let t=await this.crush.getTokensFromCrushSession(e);return{...t,actualTokens:t.tokens}}async countInteractions(e){return this.crush.countCrushInteractions(e)}async getModelUsage(e){return this.crush.getCrushModelUsage(e)}async getMeta(e){let t=[],s=await this.crush.readCrushSession(e),o;s&&(o=s.title||void 0,s.created_at&&t.push(s.created_at*1e3),s.updated_at&&t.push(s.updated_at*1e3));let n=await this.crush.getCrushMessages(e);for(let a of n)a.created_at&&t.push(a.created_at*1e3),a.finished_at&&t.push(a.finished_at*1e3);return t.sort((a,d)=>a-d),{title:o,firstInteraction:t.length>0?new Date(t[0]).toISOString():null,lastInteraction:t.length>0?new Date(t[t.length-1]).toISOString():null}}getEditorRoot(e){return ht.dirname(this.crush.getCrushDbPath(e))}async discover(e){let t=this.getCandidatePaths(),s=[];try{let o=this.crush.readCrushProjects();e(`\u{1F4C1} Crush: found ${o.length} project(s) in projects.json`);let n=await Promise.all(o.map(async d=>{let c=ht.join(d.data_dir,"crush.db");e(`\u{1F4C1} Checking Crush DB path: ${c}`);try{return await ca.promises.access(c),(await this.crush.discoverSessionsInDb(c)).map(m=>ht.join(d.data_dir,`crush.db#${m}`))}catch(h){e(`Could not read Crush database for ${d.path}: ${h}`)}return[]})),a=n.reduce((d,c)=>d+c.length,0);a>0&&e(`\u{1F4C4} Found ${a} session(s) in Crush database(s)`),s.push(...n.flat())}catch(o){e(`Could not read Crush projects: ${o}`)}return{sessionFiles:s,candidatePaths:t}}getCandidatePaths(){let e=this.crush.getCrushConfigDir(),t=[{path:ht.join(e,"projects.json"),source:"Crush (projects.json)"}];try{let s=this.crush.readCrushProjects();for(let o of s)t.push({path:ht.join(o.data_dir,"crush.db"),source:`Crush (${ht.basename(o.path)})`})}catch{}return t}async buildTurns(e){let t=[],s=await this.crush.getCrushMessages(e),o=await this.crush.readCrushSession(e),a=s.filter(c=>c.role==="user").length,d=0;for(let c=0;c<s.length;c++){let h=s[c];if(h.role!=="user")continue;d++;let m=[];for(let C=c+1;C<s.length&&s[C].role!=="user";C++)s[C].role==="assistant"&&m.push(s[C]);let g=(Array.isArray(h.parts)?h.parts:[]).filter(C=>C?.type==="text"&&C?.text).map(C=>C.text).join(`
|
|
49
|
+
`),w="",k=[],b=null;for(let C of m){b||(b=C.model||null);let P=Array.isArray(C.parts)?C.parts:[];for(let M of P)M?.type==="text"&&M?.text?w+=M.text:M?.type==="tool_call"&&M?.data?.name&&k.push({toolName:M.data.name,arguments:M.data.arguments?JSON.stringify(M.data.arguments):void 0})}let y=o?.prompt_tokens&&a>0?Math.round(o.prompt_tokens/a):0,v=o?.completion_tokens&&a>0?Math.round(o.completion_tokens/a):0;t.push({turnNumber:d,timestamp:h.created_at?new Date(h.created_at*1e3).toISOString():null,mode:"cli",userMessage:g,assistantResponse:w,model:b,toolCalls:k,contextReferences:ye(),mcpTools:[],inputTokensEstimate:y,outputTokensEstimate:v,thinkingTokensEstimate:0})}return{turns:t}}async getSyncData(e){return this.crush.getCrushSessionData(e)}async analyzeUsage(e,t){let s=ke(),o=await this.crush.getCrushMessages(e),n=[];for(let c of o)if(c.role==="user"&&s.modeUsage.cli++,c.role==="assistant"){let h=c.model||"unknown";n.push(h);let m=Array.isArray(c.parts)?c.parts:[];for(let p of m)if(p?.type==="tool_call"&&p?.data?.name){s.toolCalls.total++;let g=p.data.name;s.toolCalls.byTool[g]=(s.toolCalls.byTool[g]||0)+1}}let a=[...new Set(n)];s.modelSwitching.uniqueModels=a,s.modelSwitching.modelCount=a.length,s.modelSwitching.totalRequests=n.length;let d=0;for(let c=1;c<n.length;c++)n[c]!==n[c-1]&&d++;return s.modelSwitching.switchCount=d,De(t.modelPricing,a,n,s),s}};var ai=R(require("fs"));var Ts=class{constructor(e){this.continue_=e}continue_;id="continue";displayName="Continue";handles(e){return this.continue_.isContinueSessionFile(e)}getBackingPath(e){return e}async stat(e){return ai.promises.stat(e)}async getTokens(e){let t=this.continue_.getTokensFromContinueSession(e);return{...t,actualTokens:t.tokens}}async countInteractions(e){return Promise.resolve(this.continue_.countContinueInteractions(e))}async getModelUsage(e){return Promise.resolve(this.continue_.getContinueModelUsage(e))}async getMeta(e){let t=this.continue_.getContinueSessionMeta(e),s=this.continue_.getContinueSessionId(e),o=this.continue_.readSessionsIndex().get(s),n=null,a=null;if(o?.dateCreated){n=new Date(o.dateCreated).toISOString();try{a=(await ai.promises.stat(e)).mtime.toISOString()}catch{}}let d;if(t?.workspaceDirectory)try{d=decodeURIComponent(t.workspaceDirectory.replace(/^file:\/\/\//,"").replace(/^file:\/\//,""))}catch{}return{title:t?.title,firstInteraction:n,lastInteraction:a,workspacePath:d}}getEditorRoot(e){return this.continue_.getContinueDataDir()}async discover(e){let t=this.getCandidatePaths(),s=[];try{let o=this.continue_.getContinueSessionFiles();o.length>0&&(e(`\u{1F4C4} Found ${o.length} session file(s) in Continue (~/.continue/sessions)`),s.push(...o))}catch(o){e(`Could not read Continue session files: ${o}`)}return{sessionFiles:s,candidatePaths:t}}getCandidatePaths(){return[{path:this.continue_.getContinueSessionsDir(),source:"Continue"}]}async buildTurns(e){let t=[],s=this.continue_.buildContinueTurns(e),o=ye();for(let n of s)t.push({turnNumber:t.length+1,timestamp:null,mode:"ask",userMessage:n.userText,assistantResponse:n.assistantText,model:n.model,toolCalls:n.toolCalls,contextReferences:o,mcpTools:[],inputTokensEstimate:n.inputTokens,outputTokensEstimate:n.outputTokens,thinkingTokensEstimate:0});return{turns:t}}async analyzeUsage(e,t){let s=ke(),o=this.continue_.buildContinueTurns(e),n=this.continue_.getContinueSessionMeta(e),a=[];for(let h of o){s.modeUsage.ask++,h.model&&a.push(h.model);for(let m of h.toolCalls)s.toolCalls.total++,s.toolCalls.byTool[m.toolName]=(s.toolCalls.byTool[m.toolName]||0)+1}if(n?.mode==="agent")for(let h=0;h<o.length;h++)s.modeUsage.ask--,s.modeUsage.agent++;let d=[...new Set(a)];s.modelSwitching.uniqueModels=d,s.modelSwitching.modelCount=d.length,s.modelSwitching.totalRequests=a.length;let c=0;for(let h=1;h<a.length;h++)a[h]!==a[h-1]&&c++;return s.modelSwitching.switchCount=c,De(t.modelPricing,d,a,s),s}};var da=R(require("fs"));var ua=R(require("fs"));var fu=new Set(["review","bug","think","compact","pr_comments"]);function li(r){let e="";if(typeof r=="string")e=r;else if(Array.isArray(r)){for(let n of r)if(n?.type==="text"&&typeof n.text=="string"){e=n.text;break}}let s=e.trimStart().split(`
|
|
50
|
+
`)[0].trim().match(/^\/([a-z_]+)(?:\s|$)/i);if(!s)return null;let o=s[1].toLowerCase();return fu.has(o)?o:null}var Ps=class{constructor(e){this.claudeCode=e}claudeCode;id="claudecode";displayName="Claude Code";handles(e){return this.claudeCode.isClaudeCodeSessionFile(e)}getBackingPath(e){return e}async stat(e){return ua.promises.stat(e)}async getTokens(e){let t=this.claudeCode.getTokensFromClaudeCodeSession(e);return{...t,actualTokens:t.tokens}}async countInteractions(e){return Promise.resolve(this.claudeCode.countClaudeCodeInteractions(e))}async getModelUsage(e){return Promise.resolve(this.claudeCode.getClaudeCodeModelUsage(e))}async getMeta(e){let t=this.claudeCode.getClaudeCodeSessionMeta(e);return{title:t?.title,firstInteraction:t?.firstInteraction||null,lastInteraction:t?.lastInteraction||null,workspacePath:t?.cwd}}getEditorRoot(e){return this.claudeCode.getClaudeCodeProjectsDir()}async discover(e){let t=this.getCandidatePaths(),s=[];try{let o=this.claudeCode.getClaudeCodeSessionFiles();o.length>0&&(e(`\u{1F4C4} Found ${o.length} session file(s) in Claude Code (~/.claude/projects)`),s.push(...o))}catch(o){e(`Could not read Claude Code session files: ${o}`)}return{sessionFiles:s,candidatePaths:t}}getCandidatePaths(){return[{path:this.claudeCode.getClaudeCodeProjectsDir(),source:"Claude Code"}]}async analyzeUsage(e,t){let s=ke(),o=await Fo(e),n=[];for(let c of o)if(c.type==="user"&&c.message?.role==="user"&&!c.isSidechain){s.modeUsage.cli++;let h=li(c.message?.content);if(h){let m=`__slash__${h}`;s.toolCalls.byTool[m]=(s.toolCalls.byTool[m]||0)+1}}else if(c.type==="assistant"){let h=qt(c.message?.model||"unknown");n.push(h);let m=Array.isArray(c.message?.content)?c.message.content:[];for(let p of m)if(p?.type==="tool_use"){let g=String(p.name||"tool");if(Xe(g)){let w=Ze(g,t.toolNameMap);s.mcpTools.total++,s.mcpTools.byServer[w]=(s.mcpTools.byServer[w]||0)+1,s.mcpTools.byTool[g]=(s.mcpTools.byTool[g]||0)+1}else s.toolCalls.total++,s.toolCalls.byTool[g]=(s.toolCalls.byTool[g]||0)+1}}let a=[...new Set(n)];s.modelSwitching.uniqueModels=a,s.modelSwitching.modelCount=a.length,s.modelSwitching.totalRequests=n.length;let d=0;for(let c=1;c<n.length;c++)n[c]!==n[c-1]&&d++;return s.modelSwitching.switchCount=d,De(t.modelPricing,a,n,s),s}};var Ms=class{constructor(e,t,s,o){this.claudeDesktopCowork=e;this.isMcpToolFn=t;this.extractMcpServerNameFn=s;this.estimateTokensFn=o}claudeDesktopCowork;isMcpToolFn;extractMcpServerNameFn;estimateTokensFn;id="claudedesktop";displayName="Claude Desktop Cowork";handles(e){return this.claudeDesktopCowork.isCoworkSessionFile(e)}getBackingPath(e){return e}async stat(e){return da.promises.stat(e)}async getTokens(e){let t=this.claudeDesktopCowork.getTokensFromCoworkSession(e);return{...t,actualTokens:t.tokens}}async countInteractions(e){return Promise.resolve(this.claudeDesktopCowork.countCoworkInteractions(e))}async getModelUsage(e){return Promise.resolve(this.claudeDesktopCowork.getCoworkModelUsage(e))}async getMeta(e){let t=this.claudeDesktopCowork.getCoworkSessionMeta(e);return{title:t?.title,firstInteraction:t?.firstInteraction||null,lastInteraction:t?.lastInteraction||null,workspacePath:t?.cwd}}getEditorRoot(e){return this.claudeDesktopCowork.getCoworkBaseDir()}async discover(e){let t=this.getCandidatePaths(),s=[];try{let o=this.claudeDesktopCowork.getCoworkSessionFiles();o.length>0&&(e(`\u{1F4C4} Found ${o.length} session file(s) in Claude Desktop Cowork`),s.push(...o))}catch(o){e(`Could not read Claude Desktop Cowork session files: ${o}`)}return{sessionFiles:s,candidatePaths:t}}getCandidatePaths(){let e=this.claudeDesktopCowork.getCoworkBaseDir();return e?[{path:e,source:"Claude Desktop (Cowork)"}]:[]}async buildTurns(e){let t=[],s=this.claudeDesktopCowork.readCoworkEvents(e),o=null,n=[],a=()=>{if(!o)return;let c=o.message?.content,h=typeof c=="string"?c:Array.isArray(c)?c.filter(C=>C.type==="text").map(C=>C.text||"").join(`
|
|
51
|
+
`):"",m="",p=0,g=0,w=null,k=[],b=[];for(let C of n){let P=C.message;!w&&P?.model&&(w=P.model);let M=P?.usage;M&&(p+=(M.input_tokens||0)+(M.cache_creation_input_tokens||0)+(M.cache_read_input_tokens||0),g+=M.output_tokens||0);let F=Array.isArray(P?.content)?P.content:[];for(let D of F)if(D.type==="text")m+=D.text||"";else if(D.type==="tool_use"){let N=D.name||"unknown";this.isMcpToolFn(N)?b.push({server:this.extractMcpServerNameFn(N),tool:N}):k.push({toolName:N,arguments:D.input?JSON.stringify(D.input):void 0})}}let y=w||"claude-sonnet-4-6",v=p>0||g>0?{promptTokens:p,completionTokens:g}:void 0;t.push({turnNumber:t.length+1,timestamp:o.timestamp?new Date(o.timestamp).toISOString():null,mode:"agent",userMessage:h,assistantResponse:m,model:y,toolCalls:k,contextReferences:ye(),mcpTools:b,inputTokensEstimate:p||this.estimateTokensFn(h,y),outputTokensEstimate:g||this.estimateTokensFn(m,y),thinkingTokensEstimate:0,actualUsage:v})},d=c=>{let h=c.message?.content;if(typeof h=="string")return!!h.trim();if(!Array.isArray(h))return!1;let m=h.some(g=>g.type==="text"),p=h.some(g=>g.type==="tool_result");return m&&!p};for(let c of s)c.type==="user"&&!c.isSidechain&&c.message?.role==="user"&&d(c)?(a(),o=c,n.length=0):c.type==="assistant"&&c.message?.stop_reason&&c.message?.role==="assistant"&&n.push(c);return a(),{turns:t}}async analyzeUsage(e,t){let s=ke(),o=await Fo(e),n=[];for(let c of o)if(c.type==="user"&&c.message?.role==="user"&&!c.isSidechain){s.modeUsage.ask++;let h=li(c.message?.content);if(h){let m=`__slash__${h}`;s.toolCalls.byTool[m]=(s.toolCalls.byTool[m]||0)+1}}else if(c.type==="assistant"){let h=qt(c.message?.model||"unknown");n.push(h);let m=Array.isArray(c.message?.content)?c.message.content:[];for(let p of m)if(p?.type==="tool_use"){s.toolCalls.total++;let g=String(p.name||"tool");s.toolCalls.byTool[g]=(s.toolCalls.byTool[g]||0)+1}}let a=[...new Set(n)];s.modelSwitching.uniqueModels=a,s.modelSwitching.modelCount=a.length,s.modelSwitching.totalRequests=n.length;let d=0;for(let c=1;c<n.length;c++)n[c]!==n[c-1]&&d++;return s.modelSwitching.switchCount=d,De(t.modelPricing,a,n,s),s}};var pa=R(require("path"));var As=class{constructor(e,t){this.visualStudio=e;this.estimateTokens=t}visualStudio;estimateTokens;id="visualstudio";displayName="Visual Studio";handles(e){return this.visualStudio.isVSSessionFile(e)}getBackingPath(e){return e}async stat(e){return this.visualStudio.statSessionFile(e)}async getTokens(e){let t=this.visualStudio.getTokenEstimates(e,this.estimateTokens);return{...t,actualTokens:t.tokens}}async countInteractions(e){let t=this.visualStudio.decodeSessionFile(e);return Promise.resolve(this.visualStudio.countInteractions(t))}async getModelUsage(e){return Promise.resolve(this.visualStudio.getModelUsage(e,this.estimateTokens))}async getMeta(e){let t=this.visualStudio.decodeSessionFile(e),s=this.visualStudio.getSessionTitle(t),o=this.visualStudio.getSessionTimestamps(t),n=[];return o.timeCreated&&n.push(new Date(o.timeCreated).getTime()),o.timeUpdated&&n.push(new Date(o.timeUpdated).getTime()),n.sort((a,d)=>a-d),{title:s,firstInteraction:n.length>0?new Date(n[0]).toISOString():null,lastInteraction:n.length>0?new Date(n[n.length-1]).toISOString():null}}getEditorRoot(e){return pa.dirname(e)}skipBackendSync=!0;async discover(e){let t=this.getCandidatePaths(),s=[];try{let o=this.visualStudio.discoverSessions();o.length>0&&(e(`\u{1F4C4} Found ${o.length} session file(s) in Visual Studio Copilot`),s.push(...o))}catch(o){e(`Could not read Visual Studio session files: ${o}`)}return{sessionFiles:s,candidatePaths:t}}getCandidatePaths(){return[{path:this.visualStudio.getLogDir(),source:"Visual Studio (log dir)"}]}getRawFileContent(e){let s=this.visualStudio.decodeSessionFile(e).map((o,n)=>n===0?o:o?.[1]??o);return JSON.stringify(s,null,2)}async buildTurns(e){let t=[],s=this.visualStudio.decodeSessionFile(e),o=0;for(let n=1;n<s.length;n+=2){let a=s[n],d=s[n+1];if(!a)continue;let c=a[1],h=d?.[1];o++;let m=this.visualStudio.extractTextFromContent(c?.Content||[]),p=d?this.visualStudio.extractTextFromContent(h?.Content||[]):"",g=this.visualStudio.getModelId(h??c,!h),w=this.visualStudio.extractContextText(c?.Context),k=this.estimateTokens(m+w,g??"gpt-4"),b=d?this.estimateTokens(p,g??"gpt-4"):0,y=[];for(let v of h?.Content||[]){let C=Array.isArray(v)?v[1]:null;C?.Function&&y.push({toolName:String(C.Function.Description||"tool"),result:typeof C.Function.Result=="string"?C.Function.Result:void 0})}t.push({turnNumber:o,timestamp:c?.Timestamp?new Date(c.Timestamp).toISOString():null,mode:"ask",userMessage:m,assistantResponse:p,model:g,toolCalls:y,contextReferences:ye(),mcpTools:[],inputTokensEstimate:k,outputTokensEstimate:b,thinkingTokensEstimate:0})}return{turns:t}}async analyzeUsage(e,t){let s=ke(),o=this.visualStudio.decodeSessionFile(e),n=[];for(let c=1;c<o.length;c++){let h=c%2===1,m=o[c]?.[1];if(h)s.modeUsage.ask++;else{let p=this.visualStudio.getModelId(m,!1);p&&n.push(p);for(let g of m?.Content??[]){let w=Array.isArray(g)?g[1]:null;if(w?.Function){s.toolCalls.total++;let k=String(w.Function.Name||w.Function.Description||"tool");if(Xe(k)){s.mcpTools.total++;let b=Ze(k,t.toolNameMap);s.mcpTools.byServer[b]=(s.mcpTools.byServer[b]||0)+1;let y=Gt(k);s.mcpTools.byTool[y]=(s.mcpTools.byTool[y]||0)+1,s.toolCalls.total--}else s.toolCalls.byTool[k]=(s.toolCalls.byTool[k]||0)+1}}}}let a=[...new Set(n)];s.modelSwitching.uniqueModels=a,s.modelSwitching.modelCount=a.length,s.modelSwitching.totalRequests=n.length;let d=0;for(let c=1;c<n.length;c++)n[c]!==n[c-1]&&d++;return s.modelSwitching.switchCount=d,De(t.modelPricing,a,n,s),s}};var ma=R(require("fs"));var Es=class{constructor(e){this.mistralVibe=e}mistralVibe;id="mistralvibe";displayName="Mistral Vibe";handles(e){return this.mistralVibe.isVibeSessionFile(e)}getBackingPath(e){return e}async stat(e){return ma.promises.stat(e)}async getTokens(e){let t=this.mistralVibe.getTokensFromSession(e);return{...t,actualTokens:t.tokens}}async countInteractions(e){return Promise.resolve(this.mistralVibe.countInteractions(e))}async getModelUsage(e){return Promise.resolve(this.mistralVibe.getModelUsage(e))}async getMeta(e){let t=this.mistralVibe.getSessionMeta(e);return{title:t.title,firstInteraction:t.firstInteraction,lastInteraction:t.lastInteraction}}getEditorRoot(e){return this.mistralVibe.getSessionLogDir()}async discover(e){let t=this.getCandidatePaths(),s=[];try{let o=this.mistralVibe.discoverSessions();o.length>0&&(e(`\u{1F4C4} Found ${o.length} session file(s) in Mistral Vibe (~/.vibe/logs/session)`),s.push(...o))}catch(o){e(`Could not read Mistral Vibe session files: ${o}`)}return{sessionFiles:s,candidatePaths:t}}getCandidatePaths(){return[{path:this.mistralVibe.getSessionLogDir(),source:"Mistral Vibe"}]}async buildTurns(e){let t=[],s=this.mistralVibe.readSessionMessages(e),o=this.mistralVibe.getSessionMeta(e),n=this.mistralVibe.getTokensFromSession(e),a=o.model||"devstral",d=[];for(let c=0;c<s.length;c++)s[c].role==="user"&&s[c].injected!==!0&&d.push(c);for(let c=0;c<d.length;c++){let h=d[c],m=c+1<d.length?d[c+1]:s.length,p=s[h],g=typeof p.content=="string"?p.content:"",w="",k=[];for(let b=h+1;b<m;b++){let y=s[b];if(y.role==="assistant"){if(typeof y.content=="string"&&(w+=y.content),Array.isArray(y.tool_calls))for(let v of y.tool_calls)k.push({toolName:v.function?.name||v.name||"unknown",arguments:v.function?.arguments?JSON.stringify(v.function.arguments):void 0})}else if(y.role==="tool"){let v=k[k.length-1];v&&(v.result=typeof y.content=="string"?y.content:void 0)}}t.push({turnNumber:c+1,timestamp:o.firstInteraction,mode:"cli",userMessage:g,assistantResponse:w,model:a,toolCalls:k,contextReferences:ye(),mcpTools:[],inputTokensEstimate:0,outputTokensEstimate:0,thinkingTokensEstimate:0})}return{turns:t,actualTokens:n.tokens}}async analyzeUsage(e,t){let s=ke(),o=this.mistralVibe.readSessionMessages(e),a=this.mistralVibe.getSessionMeta(e).model||"devstral",d=[];for(let h of o)if(h.role==="user"&&h.injected!==!0)s.modeUsage.cli++;else if(h.role==="assistant"&&(d.push(a),Array.isArray(h.tool_calls)))for(let m of h.tool_calls){s.toolCalls.total++;let p=String(m.function?.name||m.name||"tool");s.toolCalls.byTool[p]=(s.toolCalls.byTool[p]||0)+1}let c=[...new Set(d)];return s.modelSwitching.uniqueModels=c,s.modelSwitching.modelCount=c.length,s.modelSwitching.totalRequests=d.length,s.modelSwitching.switchCount=0,De(t.modelPricing,c,d,s),s}};var qe=R(require("fs")),V=R(require("path")),Us=R(require("os"));var Is=["Code","Code - Insiders","Code - Exploration","VSCodium","Cursor"],ga=new Set(["Public","Default","Default User","All Users"]);function ci(){return Us.platform()==="linux"&&(typeof process.env.WSL_DISTRO_NAME=="string"||typeof process.env.WSL_INTEROP=="string")}function ha(){let r=Us.platform(),e=Us.homedir(),t=[];if(r==="win32"){let s=process.env.APPDATA||V.join(e,"AppData","Roaming");for(let o of Is)t.push(V.join(s,o,"User"))}else if(r==="darwin")for(let s of Is)t.push(V.join(e,"Library","Application Support",s,"User"));else{let s=process.env.XDG_CONFIG_HOME||V.join(e,".config");for(let o of Is)t.push(V.join(s,o,"User"))}return t.push(V.join(e,".vscode-server","data","User"),V.join(e,".vscode-server-insiders","data","User"),V.join(e,".vscode-remote","data","User"),V.join("/tmp",".vscode-server","data","User"),V.join("/workspace",".vscode-server","data","User")),t}async function gu(){if(!ci())return[];let r=[],e=[],t=process.env.USERPROFILE;if(t){let o=t.match(/^\/mnt\/[a-z]\/Users\/([^/]+)/);o&&e.push(o[1])}let s="/mnt/c/Users";try{let o=await qe.promises.readdir(s,{withFileTypes:!0});for(let n of o){if(!n.isDirectory())continue;let a=n.name;ga.has(a)||a.startsWith(".")||e.includes(a)||e.push(a)}}catch{return[]}for(let o of e){let n=V.join(s,o,"AppData","Roaming");for(let a of Is)r.push(V.join(n,a,"User"))}return r}function yu(){if(!ci())return[];let r=[],e="/mnt/c/Users";try{let t=qe.readdirSync(e,{withFileTypes:!0});for(let s of t)if(!(!s.isDirectory()||s.name.startsWith(".")||ga.has(s.name)))for(let o of Is)r.push(V.join(e,s.name,"AppData","Roaming",o,"User"))}catch{}return r}var _u=["embeddings","index","cache","preferences","settings","config","workspacesessions","globalsessions","api.json"];function bu(r){let e=r.toLowerCase();return _u.some(t=>e.includes(t))}async function Ds(r){try{return await qe.promises.access(r),!0}catch{return!1}}async function fa(r,e,t,s){if(r.length===0)return;let o=0,n=Array.from({length:Math.min(t,r.length)},async()=>{for(;o<r.length;){let a=o++;try{await e(r[a],a)}catch(d){s?.(r[a],a,d)}}});await Promise.all(n)}async function ya(r,e,t){let s;try{s=await qe.promises.readdir(r,{withFileTypes:!0})}catch(o){t(`Could not scan directory ${r}: ${o}`);return}for(let o of s){let n=V.join(r,o.name);if(o.isDirectory()){await ya(n,e,t);continue}if(!(!o.name.endsWith(".json")&&!o.name.endsWith(".jsonl"))&&!bu(o.name))try{(await qe.promises.stat(n)).size>0&&e.push(n)}catch{}}}var Os=class{id="copilotchat";displayName="GitHub Copilot Chat";handles(e){return!1}getBackingPath(e){return e}async stat(e){return qe.promises.stat(e)}async getTokens(e){try{let t=await qe.promises.readFile(e,"utf8");return ts(t)?{tokens:0,thinkingTokens:0,actualTokens:0}:e.endsWith(".jsonl")||dt(t)?Oo(t):{tokens:0,thinkingTokens:0,actualTokens:0}}catch{return{tokens:0,thinkingTokens:0,actualTokens:0}}}async countInteractions(e){return 0}async getModelUsage(e){return{}}async getMeta(e){return{title:void 0,firstInteraction:null,lastInteraction:null}}getEditorRoot(e){let t=e.replace(/\\/g,"/"),s=t.lastIndexOf("/User/");return s>=0?t.substring(0,s+5):V.dirname(e)}getCandidatePaths(){let e=[];for(let t of ha())e.push({path:t,source:"VS Code"});for(let t of yu())e.push({path:t,source:"VS Code (Windows via WSL)"});return e}async discover(e){let t=this.getCandidatePaths(),s=[],o=ha();if(ci()){e("\u{1FA9F} WSL environment detected \u2014 probing Windows-side VS Code paths");let d=await gu();d.length>0?(e(`\u{1FA9F} Adding ${d.length} Windows-side candidate paths from WSL`),o.push(...d)):e("\u{1FA9F} No Windows-side paths found (Windows drive may not be mounted)")}e(`\u{1F4C2} Considering ${o.length} candidate VS Code paths`);let n=await Promise.all(o.map(d=>Ds(d).catch(()=>!1))),a=o.filter((d,c)=>n[c]);return e(`\u2705 Found ${a.length} of ${o.length} VS Code paths exist on disk`),await fa(a,async d=>{let c=V.basename(V.dirname(d)),h=V.join(d,"workspaceStorage");try{if(await Ds(h)){let p=await qe.promises.readdir(h);await fa(p,async g=>{let w=[V.join(h,g,"chatSessions"),V.join(h,g,"GitHub.copilot-chat","chatSessions"),V.join(h,g,"github.copilot-chat","chatSessions"),V.join(h,g,"GitHub.copilot","chatSessions"),V.join(h,g,"github.copilot","chatSessions"),V.join(h,g,"GitHub.copilot-chat","debug-logs"),V.join(h,g,"github.copilot-chat","debug-logs"),V.join(h,g,"GitHub.copilot","debug-logs"),V.join(h,g,"github.copilot","debug-logs")];for(let k of w)try{if(!await Ds(k))continue;let b=(await qe.promises.readdir(k)).filter(y=>y.endsWith(".json")||y.endsWith(".jsonl")).map(y=>V.join(k,y));b.length>0&&(e(`\u{1F4C4} Found ${b.length} session files in ${c}/workspaceStorage/${g}`),s.push(...b))}catch{}},6)}}catch(p){e(`Could not check workspace storage path ${h}: ${p}`)}let m=V.join(d,"globalStorage","emptyWindowChatSessions");try{if(await Ds(m)){let p=(await qe.promises.readdir(m)).filter(g=>g.endsWith(".json")||g.endsWith(".jsonl")).map(g=>V.join(m,g));p.length>0&&(e(`\u{1F4C4} Found ${p.length} session files in ${c}/globalStorage/emptyWindowChatSessions`),s.push(...p))}}catch(p){e(`Could not check global storage path ${m}: ${p}`)}for(let p of["GitHub.copilot-chat","github.copilot-chat","GitHub.copilot","github.copilot"]){let g=V.join(d,"globalStorage",p);try{await Ds(g)&&(e(`\u{1F4C4} Scanning ${c}/globalStorage/${p}`),await ya(g,s,e))}catch(w){e(`Could not check Copilot Chat global storage path ${g}: ${w}`)}}},4,(d,c,h)=>{e(`Failed to scan VS Code user path ${d}: ${h instanceof Error?h.message:String(h)}`)}),{sessionFiles:s,candidatePaths:t}}};var Rs=R(require("fs")),No=R(require("path")),_a=R(require("os"));function ui(){return No.join(_a.homedir(),".copilot","session-state")}async function Cu(r){try{return await Rs.promises.access(r),!0}catch{return!1}}var Fs=class{id="copilotcli";displayName="GitHub Copilot CLI";handles(e){return!1}getBackingPath(e){return e}async stat(e){return Rs.promises.stat(e)}async getTokens(e){return{tokens:0,thinkingTokens:0,actualTokens:0}}async countInteractions(e){return 0}async getModelUsage(e){return{}}async getMeta(e){return{title:void 0,firstInteraction:null,lastInteraction:null}}getEditorRoot(e){return ui()}getCandidatePaths(){return[{path:ui(),source:"Copilot CLI"}]}async discover(e){let t=this.getCandidatePaths(),s=[],o=ui();try{if(!await Cu(o))return{sessionFiles:s,candidatePaths:t};let n;try{n=await Rs.promises.readdir(o,{withFileTypes:!0})}catch(h){return e(`Could not read Copilot CLI session path in ${o}: ${h}`),{sessionFiles:s,candidatePaths:t}}let a=n.filter(h=>!h.isDirectory()&&(h.name.endsWith(".json")||h.name.endsWith(".jsonl"))).map(h=>No.join(o,h.name));a.length>0&&(e(`\u{1F4C4} Found ${a.length} session files in Copilot CLI directory`),s.push(...a));let d=n.filter(h=>h.isDirectory()),c=(await Promise.all(d.map(async h=>{let m=No.join(o,h.name,"events.jsonl");try{return(await Rs.promises.stat(m)).size>0?m:null}catch{return null}}))).filter(h=>h!==null);c.length>0&&(e(`\u{1F4C4} Found ${c.length} session files in Copilot CLI subdirectories`),s.push(...c))}catch(n){e(`Could not check Copilot CLI session path ${o}: ${n}`)}return{sessionFiles:s,candidatePaths:t}}};function Pe(r){return typeof r=="object"&&r!==null}function wu(r){return typeof r!="string"?!1:!["__proto__","prototype","constructor","hasOwnProperty"].includes(r)&&!r.startsWith("__")}function Ns(r){return/^\d+$/.test(r)}function di(r,e){if(typeof r!="string")return e;let t=r.trim();return t?t.startsWith("copilot/")?t.substring(8):t:e}function Su(r,e){if(!Pe(e))return r;let t=e.kind,s=e.k,o=e.v;if(t===0)return o;if(!Array.isArray(s)||s.length===0)return r;let n=s.map(String);for(let m of n)if(!wu(m))return r;let a=Pe(r)?r:Object.create(null),d=a,c=(m,p,g)=>{let w=Ns(g),k=m[p];return Pe(k)||(k=w?[]:Object.create(null),m[p]=k),k};for(let m=0;m<n.length-1;m++){let p=n[m],g=n[m+1];if(Array.isArray(d)&&Ns(p)){let w=Number(p),k=d[w];Pe(k)||(k=Ns(g)?[]:Object.create(null),d[w]=k),d=k;continue}if(!Pe(d))return a;d=c(d,p,g)}let h=n[n.length-1];if(t===1)return Array.isArray(d)&&Ns(h)?(d[Number(h)]=o,a):(Pe(d)&&Object.defineProperty(d,h,{value:o,writable:!0,enumerable:!0,configurable:!0}),a);if(t===2){let m;if(Array.isArray(d)&&Ns(h)){let p=Number(h);Array.isArray(d[p])||(d[p]=[]),m=d[p]}else Pe(d)&&(Array.isArray(d[h])||Object.defineProperty(d,h,{value:[],writable:!0,enumerable:!0,configurable:!0}),m=d[h]);return Array.isArray(m)&&(Array.isArray(o)?m.push(...o):m.push(o)),a}return a}function ku(r){if(!Array.isArray(r))return{responseText:"",thinkingText:""};let e="",t="";for(let s of r){if(!Pe(s))continue;if(s.kind==="thinking"){let a=s.value;typeof a=="string"&&a&&(t+=a);continue}let o=Pe(s.content)?s.content.value:void 0,n=s.value;if(typeof o=="string"&&o){e+=o;continue}typeof n=="string"&&n&&(e+=n)}return{responseText:e,thinkingText:t}}function ba(r,e,t,s){let o={},n=0,a=0,d=0,c=0,h=0,m,p="gpt-4o",g=y=>typeof y=="string"&&y?y:p,w=(y,v)=>{let C=g(y);o[C]||(o[C]={inputTokens:0,outputTokens:0});let P=t(v,C);o[C].inputTokens+=P,a+=P},k=(y,v)=>{let C=g(y);o[C]||(o[C]={inputTokens:0,outputTokens:0});let P=t(v,C);o[C].outputTokens+=P,d+=P};if(r.endsWith(".jsonl")){let y=e.split(/\r?\n/).filter(C=>C.trim()),v=!1;if(y.length>0)try{let C=JSON.parse(y[0]);C&&typeof C.kind=="number"&&(v=!0)}catch{}if(v){let C=Object.create(null);for(let M of y)try{let F=JSON.parse(M);C=Su(C,F)}catch{}let P=Pe(C)&&Array.isArray(C.requests)?C.requests:[];if(P.length>0){n=P.filter(M=>Pe(M)&&Pe(M.message)&&typeof M.message.text=="string"&&M.message.text.trim()).length;for(let M of P){if(!Pe(M))continue;let F=di(M.modelId??M.selectedModel?.identifier??M.model,p),D=s?s(M):void 0,N=di(D,""),H=N&&N!==p?N:F,K=M.message;Pe(K)&&typeof K.text=="string"&&w(H,K.text);let{responseText:W,thinkingText:Me}=ku(M.response);W&&k(H,W),Me&&(c+=t(Me,H));let ve=M.response;if(Array.isArray(ve))for(let Z of ve){let Ue=vt(Z);if(Ue){let Ae=Ue.modelName||H;Ue.prompt&&w(Ae,Ue.prompt),Ue.result&&k(Ae,Ue.result)}}}}return{tokens:a+d+c,interactions:n,modelUsage:o,thinkingTokens:c,actualTokens:0}}try{m=JSON.parse(e.trim())}catch{return{tokens:0,interactions:0,modelUsage:{},thinkingTokens:0,actualTokens:0}}}if(!m)try{m=JSON.parse(e)}catch{return{tokens:0,interactions:0,modelUsage:{},thinkingTokens:0,actualTokens:0}}let b=Array.isArray(m.requests)?m.requests:Array.isArray(m.history)?m.history:[];n=b.length;for(let y of b){let v=s?s(y):y?.model||p,C=di(v,p);if(o[C]||(o[C]={inputTokens:0,outputTokens:0}),y?.message?.parts){for(let M of y.message.parts)if(typeof M?.text=="string"&&M.text){let F=t(M.text,C);o[C].inputTokens+=F,a+=F}}else if(typeof y?.message?.text=="string"){let M=t(y.message.text,C);o[C].inputTokens+=M,a+=M}let P=Array.isArray(y?.response)?y.response:Array.isArray(y?.responses)?y.responses:[];for(let M of P){if(M?.kind==="thinking"&&typeof M?.value=="string"&&M.value){c+=t(M.value,C);continue}let F=vt(M);if(F){let D=F.modelName||C;F.prompt&&w(D,F.prompt),F.result&&k(D,F.result);continue}if(typeof M?.value=="string"&&M.value){let D=t(M.value,C);o[C].outputTokens+=D,d+=D}if(M?.message?.parts){for(let D of M.message.parts)if(typeof D?.text=="string"&&D.text){let N=t(D.text,C);o[C].outputTokens+=N,d+=N}}}if(y?.result?.usage){let M=y.result.usage,F=typeof M.promptTokens=="number"?M.promptTokens:0,D=typeof M.completionTokens=="number"?M.completionTokens:0;h+=F+D}else typeof y?.result?.promptTokens=="number"&&typeof y?.result?.outputTokens=="number"?h+=y.result.promptTokens+y.result.outputTokens:y?.result?.metadata&&typeof y?.result?.metadata?.promptTokens=="number"&&typeof y?.result?.metadata?.outputTokens=="number"&&(h+=y.result.metadata.promptTokens+y.result.metadata.outputTokens)}return{tokens:a+d+c,interactions:n,modelUsage:o,thinkingTokens:c,actualTokens:h}}var Tt=R(require("fs")),mi=R(require("path")),wa=R(require("os")),Sa=2,Ca=2e3,ka=mi.join(wa.homedir(),".copilot-token-tracker"),pi=mi.join(ka,"cli-cache.json"),We=new Map,os=!0,va=!1;function hi(){os=!1,We.clear()}function fi(){if(os)try{if(!Tt.existsSync(pi))return;let r=Tt.readFileSync(pi,"utf-8"),e=JSON.parse(r);if(e.version!==Sa){We.clear();return}We=new Map(Object.entries(e.entries))}catch{We.clear()}}function gi(){if(!(!os||!va))try{if(We.size>Ca){let e=[...We.entries()].sort((t,s)=>s[1].mtime-t[1].mtime);We=new Map(e.slice(0,Ca))}Tt.mkdirSync(ka,{recursive:!0});let r={version:Sa,entries:Object.fromEntries(We)};Tt.writeFileSync(pi,JSON.stringify(r),"utf-8")}catch{}}function xa(r,e,t){if(!os)return null;let s=We.get(r);return!s||s.mtime!==e||s.size!==t?null:{...s.data,lastModified:new Date(s.data.lastModified)}}function yi(r,e,t,s){os&&(va=!0,We.set(r,{mtime:e,size:t,data:{...s,lastModified:s.lastModified.toISOString()}}))}function _i(){return{entries:We.size,enabled:os}}var Ta={$schema:"http://json-schema.org/draft-07/schema#",description:"Character-to-token ratio estimators for different AI models. Used to estimate token counts from text length.",estimators:{"gpt-4":.25,"gpt-4.1":.25,"gpt-4.1-mini":.25,"gpt-4o":.25,"gpt-4o-mini":.25,"gpt-4-turbo":.25,"gpt-3.5-turbo":.25,"gpt-5":.25,"gpt-5-codex":.25,"gpt-5-mini":.25,"gpt-5.1":.25,"gpt-5.1-codex":.25,"gpt-5.1-codex-max":.25,"gpt-5.1-codex-mini":.25,"gpt-5.2":.25,"gpt-5.2-codex":.25,"gpt-5.2-pro":.25,"gpt-5.3-codex":.25,"gpt-5.4":.25,"gpt-5.4-mini":.25,"gpt-4.1-nano":.25,"gemini-2.0-flash":.25,"gemini-2.0-flash-lite":.25,"gemini-2.5-flash":.25,"gemini-2.5-flash-lite":.25,"claude-sonnet-3.5":.24,"claude-sonnet-3.7":.24,"claude-sonnet-4":.24,"claude-sonnet-4.5":.24,"claude-sonnet-4.6":.24,"claude-haiku":.24,"claude-haiku-4.5":.24,"claude-opus-4.1":.24,"claude-opus-4.5":.24,"claude-opus-4.6":.24,"claude-opus-4.6-(fast-mode)-(preview)":.24,"claude-opus-4.6-fast":.24,"gemini-2.5-pro":.25,"gemini-3-flash":.25,"gemini-3-pro":.25,"gemini-3-pro-preview":.25,"gemini-3.1-pro":.25,"gemini-3.1-flash-lite":.25,"grok-code-fast-1":.25,"raptor-mini":.25,goldeneye:.25,"o1-preview":.25,"o1-mini":.25,"o3-mini":.25,"o4-mini":.25}};var Pa={$schema:"http://json-schema.org/draft-07/schema#",description:"Model pricing data - costs per million tokens. Each model has direct provider/API pricing at the top level (used as a reference); models billed through GitHub Copilot AI Credits also include a `copilotPricing` block reflecting GitHub's published per-token rates (1 AI credit = $0.01).",metadata:{lastUpdated:"2026-04-27",sources:[{name:"OpenAI API Pricing",url:"https://developers.openai.com/api/docs/pricing",retrievedDate:"2026-04-24"},{name:"Anthropic Claude Pricing",url:"https://www.anthropic.com/pricing",note:"Standard rates; also see https://platform.claude.com/docs/en/about-claude/pricing",retrievedDate:"2026-03-30"},{name:"Google AI Gemini API Pricing",url:"https://ai.google.dev/gemini-api/docs/pricing",retrievedDate:"2026-03-30"},{name:"xAI Grok API Pricing",url:"https://x.ai/api",retrievedDate:"2026-03-30"},{name:"GitHub Copilot Supported Models",url:"https://docs.github.com/en/copilot/reference/ai-models/supported-models",retrievedDate:"2026-03-30",note:"Source for tier/multiplier data"},{name:"GitHub Copilot Premium Requests",url:"https://docs.github.com/en/copilot/managing-copilot/monitoring-usage-and-entitlements/about-premium-requests",retrievedDate:"2026-03-30",note:"Source for premium request multiplier values"},{name:"OpenRouter Model Pricing",url:"https://openrouter.ai",retrievedDate:"2026-03-30",note:"Cross-provider pricing aggregator used for verification"},{name:"GitHub Copilot Models and Pricing",url:"https://docs.github.com/en/copilot/reference/copilot-billing/models-and-pricing",retrievedDate:"2026-04-27",note:"Source for the `copilotPricing` per-model block (GitHub AI Credit per-token rates)"}],disclaimer:"GitHub Copilot uses these models but pricing may differ from direct API usage. These are reference prices for cost estimation purposes only."},pricing:{"gpt-5":{inputCostPerMillion:1.25,outputCostPerMillion:10,category:"GPT-5 models",tier:"premium",multiplier:1,displayNames:["GPT-5"]},"gpt-5-codex":{inputCostPerMillion:1.25,outputCostPerMillion:10,category:"GPT-5 models",tier:"premium",multiplier:1},"gpt-5-mini":{inputCostPerMillion:.25,outputCostPerMillion:2,category:"GPT-5 models",tier:"standard",multiplier:0,copilotPricing:{inputCostPerMillion:.25,cachedInputCostPerMillion:.025,outputCostPerMillion:2,releaseStatus:"GA",category:"Lightweight"}},"gpt-5.1":{inputCostPerMillion:1.25,outputCostPerMillion:10,category:"GPT-5 models",tier:"premium",multiplier:1},"gpt-5.1-codex":{inputCostPerMillion:1.25,outputCostPerMillion:10,category:"GPT-5 models",tier:"premium",multiplier:1},"gpt-5.1-codex-max":{inputCostPerMillion:1.75,outputCostPerMillion:14,category:"GPT-5 models",tier:"premium",multiplier:1},"gpt-5.1-codex-mini":{inputCostPerMillion:.25,outputCostPerMillion:2,category:"GPT-5 models",tier:"premium",multiplier:.33},"gpt-5.2":{inputCostPerMillion:1.75,outputCostPerMillion:14,category:"GPT-5 models",tier:"premium",multiplier:1,copilotPricing:{inputCostPerMillion:1.75,cachedInputCostPerMillion:.175,outputCostPerMillion:14,releaseStatus:"GA",category:"Versatile"}},"gpt-5.2-codex":{inputCostPerMillion:1.75,outputCostPerMillion:14,category:"GPT-5 models",tier:"premium",multiplier:1,copilotPricing:{inputCostPerMillion:1.75,cachedInputCostPerMillion:.175,outputCostPerMillion:14,releaseStatus:"GA",category:"Powerful"}},"gpt-5.2-pro":{inputCostPerMillion:21,outputCostPerMillion:168,category:"GPT-5 models",tier:"premium",multiplier:1},"gpt-5.3-codex":{inputCostPerMillion:1.75,outputCostPerMillion:14,category:"GPT-5 models",tier:"premium",multiplier:1,copilotPricing:{inputCostPerMillion:1.75,cachedInputCostPerMillion:.175,outputCostPerMillion:14,releaseStatus:"GA",category:"Powerful"}},"gpt-5.4":{inputCostPerMillion:2.5,cachedInputCostPerMillion:.25,outputCostPerMillion:15,category:"GPT-5 models",tier:"premium",multiplier:1,displayNames:["GPT-5.4"],copilotPricing:{inputCostPerMillion:2.5,cachedInputCostPerMillion:.25,outputCostPerMillion:15,releaseStatus:"GA",category:"Versatile"}},"gpt-5.4-mini":{inputCostPerMillion:.75,cachedInputCostPerMillion:.075,outputCostPerMillion:4.5,category:"GPT-5 models",tier:"standard",multiplier:0,displayNames:["GPT-5.4 mini"],copilotPricing:{inputCostPerMillion:.75,cachedInputCostPerMillion:.075,outputCostPerMillion:4.5,releaseStatus:"GA",category:"Lightweight"}},"gpt-5.4-nano":{inputCostPerMillion:.2,cachedInputCostPerMillion:.02,outputCostPerMillion:1.25,category:"GPT-5 models",tier:"standard",multiplier:0,displayNames:["GPT-5.4 nano"],copilotPricing:{inputCostPerMillion:.2,cachedInputCostPerMillion:.02,outputCostPerMillion:1.25,releaseStatus:"GA",category:"Lightweight"}},"gpt-4":{inputCostPerMillion:3,outputCostPerMillion:12,category:"GPT-4 models",tier:"unknown",multiplier:1,displayNames:["GPT-4"]},"gpt-4.1":{inputCostPerMillion:2,cachedInputCostPerMillion:.5,outputCostPerMillion:8,category:"GPT-4 models",tier:"standard",multiplier:0,displayNames:["GPT-4.1"],copilotPricing:{inputCostPerMillion:2,cachedInputCostPerMillion:.5,outputCostPerMillion:8,releaseStatus:"GA",category:"Versatile"}},"gpt-4.1-mini":{inputCostPerMillion:.4,cachedInputCostPerMillion:.1,outputCostPerMillion:1.6,category:"GPT-4 models",tier:"standard",multiplier:0},"gpt-4.1-nano":{inputCostPerMillion:.1,cachedInputCostPerMillion:.025,outputCostPerMillion:.4,category:"GPT-4 models",tier:"standard",multiplier:0},"gpt-4o":{inputCostPerMillion:2.5,outputCostPerMillion:10,cachedInputCostPerMillion:1.25,category:"GPT-4 models",tier:"standard",multiplier:0,displayNames:["GPT-4o"]},"gpt-4o-mini":{inputCostPerMillion:.15,outputCostPerMillion:.6,cachedInputCostPerMillion:.075,category:"GPT-4 models",tier:"standard",multiplier:0,displayNames:["GPT-4o-mini","GPT-4o Mini"]},"gpt-4-turbo":{inputCostPerMillion:10,outputCostPerMillion:30,category:"GPT-4 models",tier:"standard",multiplier:0,displayNames:["GPT-4 Turbo"]},"claude-sonnet-3.5":{inputCostPerMillion:3,outputCostPerMillion:15,cachedInputCostPerMillion:.3,cacheCreationCostPerMillion:3.75,category:"Claude models (Anthropic)",tier:"unknown",multiplier:1,displayNames:["Claude Sonnet 3.5"]},"claude-sonnet-3.7":{inputCostPerMillion:3,outputCostPerMillion:15,cachedInputCostPerMillion:.3,cacheCreationCostPerMillion:3.75,category:"Claude models (Anthropic)",tier:"unknown",multiplier:1,displayNames:["Claude Sonnet 3.7"]},"claude-sonnet-4":{inputCostPerMillion:3,outputCostPerMillion:15,cachedInputCostPerMillion:.3,cacheCreationCostPerMillion:3.75,category:"Claude models (Anthropic)",tier:"premium",multiplier:1,displayNames:["Claude Sonnet 4"],copilotPricing:{inputCostPerMillion:3,cachedInputCostPerMillion:.3,cacheCreationCostPerMillion:3.75,outputCostPerMillion:15,releaseStatus:"GA",category:"Versatile"}},"claude-sonnet-4.5":{inputCostPerMillion:3,outputCostPerMillion:15,cachedInputCostPerMillion:.3,cacheCreationCostPerMillion:3.75,category:"Claude models (Anthropic)",tier:"premium",multiplier:1,copilotPricing:{inputCostPerMillion:3,cachedInputCostPerMillion:.3,cacheCreationCostPerMillion:3.75,outputCostPerMillion:15,releaseStatus:"GA",category:"Versatile"}},"claude-sonnet-4.6":{inputCostPerMillion:3,outputCostPerMillion:15,cachedInputCostPerMillion:.3,cacheCreationCostPerMillion:3.75,category:"Claude models (Anthropic)",tier:"premium",multiplier:3,displayNames:["Claude Sonnet 4.6"],copilotPricing:{inputCostPerMillion:3,cachedInputCostPerMillion:.3,cacheCreationCostPerMillion:3.75,outputCostPerMillion:15,releaseStatus:"GA",category:"Versatile"}},"claude-haiku":{inputCostPerMillion:.25,outputCostPerMillion:1.25,cachedInputCostPerMillion:.025,cacheCreationCostPerMillion:.3125,category:"Claude models (Anthropic)",tier:"standard",multiplier:0},"claude-haiku-4.5":{inputCostPerMillion:1,outputCostPerMillion:5,cachedInputCostPerMillion:.1,cacheCreationCostPerMillion:1.25,category:"Claude models (Anthropic)",tier:"premium",multiplier:.33,copilotPricing:{inputCostPerMillion:1,cachedInputCostPerMillion:.1,cacheCreationCostPerMillion:1.25,outputCostPerMillion:5,releaseStatus:"GA",category:"Versatile"}},"claude-opus-4.1":{inputCostPerMillion:15,outputCostPerMillion:75,cachedInputCostPerMillion:1.5,cacheCreationCostPerMillion:18.75,category:"Claude models (Anthropic)",tier:"premium",multiplier:10},"claude-opus-4.5":{inputCostPerMillion:5,outputCostPerMillion:25,cachedInputCostPerMillion:.5,cacheCreationCostPerMillion:6.25,category:"Claude models (Anthropic)",tier:"premium",multiplier:3,copilotPricing:{inputCostPerMillion:5,cachedInputCostPerMillion:.5,cacheCreationCostPerMillion:6.25,outputCostPerMillion:25,releaseStatus:"GA",category:"Powerful"}},"claude-opus-4.6":{inputCostPerMillion:5,outputCostPerMillion:25,cachedInputCostPerMillion:.5,cacheCreationCostPerMillion:6.25,category:"Claude models (Anthropic)",tier:"premium",multiplier:3,copilotPricing:{inputCostPerMillion:5,cachedInputCostPerMillion:.5,cacheCreationCostPerMillion:6.25,outputCostPerMillion:25,releaseStatus:"GA",category:"Powerful"}},"claude-opus-4.7":{inputCostPerMillion:5,outputCostPerMillion:25,cachedInputCostPerMillion:.5,cacheCreationCostPerMillion:6.25,category:"Claude models (Anthropic)",tier:"premium",multiplier:3,displayNames:["Claude Opus 4.7"],copilotPricing:{inputCostPerMillion:5,cachedInputCostPerMillion:.5,cacheCreationCostPerMillion:6.25,outputCostPerMillion:25,releaseStatus:"GA",category:"Powerful"}},"claude-opus-4.6-(fast-mode)-(preview)":{inputCostPerMillion:5,outputCostPerMillion:25,cachedInputCostPerMillion:.5,cacheCreationCostPerMillion:6.25,category:"Claude models (Anthropic)",tier:"premium",multiplier:30,copilotPricing:{inputCostPerMillion:30,cachedInputCostPerMillion:3,cacheCreationCostPerMillion:37.5,outputCostPerMillion:150,releaseStatus:"Public preview",category:"Powerful"}},"claude-opus-4.6-fast":{inputCostPerMillion:5,outputCostPerMillion:25,cachedInputCostPerMillion:.5,cacheCreationCostPerMillion:6.25,category:"Claude models (Anthropic)",tier:"premium",multiplier:30,copilotPricing:{inputCostPerMillion:30,cachedInputCostPerMillion:3,cacheCreationCostPerMillion:37.5,outputCostPerMillion:150,releaseStatus:"Public preview",category:"Powerful"}},"o3-mini":{inputCostPerMillion:1.1,outputCostPerMillion:4.4,category:"OpenAI reasoning models",tier:"premium",multiplier:1,displayNames:["o3-mini"]},"o4-mini":{inputCostPerMillion:1.1,outputCostPerMillion:4.4,category:"OpenAI reasoning models",tier:"premium",multiplier:1,displayNames:["o4-mini"]},"o1-preview":{inputCostPerMillion:15,outputCostPerMillion:60,category:"OpenAI reasoning models",tier:"premium",multiplier:1,displayNames:["o1-preview"]},"o1-mini":{inputCostPerMillion:3,outputCostPerMillion:12,category:"OpenAI reasoning models",tier:"premium",multiplier:1,displayNames:["o1-mini"]},"gpt-3.5-turbo":{inputCostPerMillion:.5,outputCostPerMillion:1.5,category:"Legacy models",tier:"standard",multiplier:0,displayNames:["GPT-3.5-Turbo","GPT-3.5 Turbo"]},"gemini-2.5-pro":{inputCostPerMillion:1.25,outputCostPerMillion:10,category:"Google Gemini models",tier:"premium",multiplier:1,displayNames:["Gemini 2.5 Pro"],copilotPricing:{inputCostPerMillion:1.25,cachedInputCostPerMillion:.125,outputCostPerMillion:10,releaseStatus:"GA",category:"Powerful"}},"gemini-2.5-flash":{inputCostPerMillion:.3,outputCostPerMillion:2.5,category:"Google Gemini models",tier:"unknown",multiplier:1},"gemini-2.5-flash-lite":{inputCostPerMillion:.1,outputCostPerMillion:.4,category:"Google Gemini models",tier:"unknown",multiplier:1},"gemini-2.0-flash":{inputCostPerMillion:.1,outputCostPerMillion:.4,category:"Google Gemini models",tier:"standard",multiplier:0},"gemini-2.0-flash-lite":{inputCostPerMillion:.075,outputCostPerMillion:.3,category:"Google Gemini models",tier:"standard",multiplier:0},"gemini-3-flash":{inputCostPerMillion:.5,outputCostPerMillion:3,category:"Google Gemini models",tier:"premium",multiplier:.33,copilotPricing:{inputCostPerMillion:.5,cachedInputCostPerMillion:.05,outputCostPerMillion:3,releaseStatus:"Public preview",category:"Lightweight"}},"gemini-3-pro":{inputCostPerMillion:2,outputCostPerMillion:12,category:"Google Gemini models",tier:"premium",multiplier:1,displayNames:["Gemini 3 Pro"]},"gemini-3-pro-preview":{inputCostPerMillion:2,outputCostPerMillion:12,category:"Google Gemini models",tier:"premium",multiplier:1,displayNames:["Gemini 3 Pro (Preview)"]},"gemini-3.1-pro":{inputCostPerMillion:2,outputCostPerMillion:12,category:"Google Gemini models",tier:"premium",multiplier:1,displayNames:["Gemini 3.1 Pro","Gemini 3.1 Pro (Preview)"],copilotPricing:{inputCostPerMillion:2,cachedInputCostPerMillion:.2,outputCostPerMillion:12,releaseStatus:"Public preview",category:"Powerful"}},"gemini-3.1-flash-lite":{inputCostPerMillion:.25,outputCostPerMillion:1.5,category:"Google Gemini models",tier:"unknown",multiplier:.33,displayNames:["Gemini 3.1 Flash Lite"]},"grok-code-fast-1":{inputCostPerMillion:.2,outputCostPerMillion:1.5,category:"xAI Grok models",tier:"premium",multiplier:.25,copilotPricing:{inputCostPerMillion:.2,cachedInputCostPerMillion:.02,outputCostPerMillion:1.5,releaseStatus:"GA",category:"Lightweight"}},"raptor-mini":{inputCostPerMillion:.25,outputCostPerMillion:2,category:"GitHub Copilot fine-tuned models",tier:"standard",multiplier:0,copilotPricing:{inputCostPerMillion:.25,cachedInputCostPerMillion:.025,outputCostPerMillion:2,releaseStatus:"Public preview",category:"Versatile"}},goldeneye:{inputCostPerMillion:0,outputCostPerMillion:0,category:"GitHub Copilot fine-tuned models",tier:"standard",multiplier:0,copilotPricing:{inputCostPerMillion:1.25,cachedInputCostPerMillion:.125,outputCostPerMillion:10,releaseStatus:"Public preview",category:"Powerful"}}}};var Ma={unknown:"Unknown",run_in_terminal:"Run In Terminal",send_to_terminal:"Send To Terminal",run_build:"Run Build",run_command_in_terminal:"Run Command In Terminal","mcp.io.github.git.assign_copilot_to_issue":"GitHub MCP (Local): Assign Copilot to Issue","mcp.io.github.git.create_or_update_file":"GitHub MCP (Local): Create/Update File",mcp_io_github_git_create_or_update_file:"GitHub MCP (Local): Create/Update File",mcp_io_github_git_assign_copilot_to_issue:"GitHub MCP (Local): Assign Copilot to Issue",mcp_io_github_git_pull_request_read:"GitHub MCP (Local): Pull Request Read",mcp_io_github_git_issue_read:"GitHub MCP (Local): Issue Read",mcp_io_github_git_issue_write:"GitHub MCP (Local): Issue Write",mcp_io_github_git_list_issues:"GitHub MCP (Local): List Issues",mcp_io_github_git_create_pull_request:"GitHub MCP (Local): Create Pull Request",mcp_io_github_git_get_file_contents:"GitHub MCP (Local): Get File Contents",mcp_io_github_git_search_code:"GitHub MCP (Local): Search Code",mcp_io_github_git_search_pull_requests:"GitHub MCP (Local): Search Pull Requests",mcp_io_github_git_get_release_by_tag:"GitHub MCP (Local): Get Release By Tag",mcp_io_github_git_search_issues:"GitHub MCP (Local): Search Issues",mcp_io_github_git_add_issue_comment:"GitHub MCP (Local): Add Issue Comment",mcp_io_github_git_list_pull_requests:"GitHub MCP (Local): List Pull Requests",mcp_io_github_git_get_commit:"GitHub MCP (Local): Get Commit",mcp_io_github_git_list_commits:"GitHub MCP (Local): List Commits",mcp_io_github_git_list_code_scanning_alerts:"GitHub MCP (Local): List Code Scanning Alerts",mcp_io_github_git_get_repository_tree:"GitHub MCP (Local): Get Repository Tree",mcp_io_github_git_list_tags:"GitHub MCP (Local): List Tags",mcp_io_github_git_search_repositories:"GitHub MCP (Local): Search Repositories",mcp_github_github_assign_copilot_to_issue:"GitHub MCP (Remote): Assign Copilot to Issue",mcp_github_github_issue_read:"GitHub MCP (Remote): Issue Read",mcp_github_github_issue_write:"GitHub MCP (Remote): Issue Write",mcp_github_github_list_issues:"GitHub MCP (Remote): List Issues",mcp_github_get_file_contents:"GitHub MCP (Remote): Get File Contents",mcp_github_get_latest_release:"GitHub MCP (Remote): Get Latest Release",mcp_github_get_release_by_tag:"GitHub MCP (Remote): Get Release By Tag",mcp_github_list_releases:"GitHub MCP (Remote): List Releases",mcp_github_list_tags:"GitHub MCP (Remote): List Tags",mcp_github_search_code:"GitHub MCP (Remote): Search Code",mcp_github_search_issues:"GitHub MCP (Remote): Search Issues",mcp_github_issue_write:"GitHub MCP (Remote): Issue Write",mcp_github_list_issues:"GitHub MCP (Remote): List Issues",mcp_github_create_pull_request:"GitHub MCP (Remote): Create Pull Request",mcp_github_pull_request_read:"GitHub MCP (Remote): Pull Request Read","mcp_github-code-s_get_code_scanning_alert":"GitHub MCP (Code Scanning): Get Alert","mcp_github-code-s_list_code_scanning_alerts":"GitHub MCP (Code Scanning): List Alerts",mcp_com_microsoft_get_bestpractices:"GitHub MCP: Get Best Practices",mcp_microsoft_doc_microsoft_code_sample_search:"Microsoft Docs MCP: Code Sample Search",mcp_microsoft_doc_microsoft_docs_search:"Microsoft Docs MCP: Docs Search",mcp_microsoftdocs_microsoft_docs_search:"Microsoft Docs MCP: Docs Search",Microsoft_Learn_microsoft_docs_search:"Microsoft Learn: Docs Search",mcp_gitkraken_git_add_or_commit:"GitKraken MCP: Git Add or Commit",mcp_gitkraken_git_status:"GitKraken MCP: Git Status",mcp_gitkraken_git_branch:"GitKraken MCP: Git Branch",mcp_gitkraken_git_checkout:"GitKraken MCP: Git Checkout",mcp_gitkraken_git_log_or_diff:"GitKraken MCP: Git Log or Diff",mcp_gitkraken_gitkraken_workspace_list:"GitKraken MCP: List Workspaces",mcp_pencil_batch_design:"Pencil MCP: Batch Design",mcp_pencil_get_editor_state:"Pencil MCP: Get Editor State",mcp_pencil_get_guidelines:"Pencil MCP: Get Guidelines",mcp_pencil_get_screenshot:"Pencil MCP: Get Screenshot",mcp_pencil_snapshot_layout:"Pencil MCP: Snapshot Layout",mcp_figma_get_design_context:"Figma MCP: Get Design Context",mcp_figma_get_screenshot:"Figma MCP: Get Screenshot",mcp_figma_get_variable_defs:"Figma MCP: Get Variable Defs",mcp_azure_aks:"Azure MCP: AKS",mcp_azure_mcp_azureterraformbestpractices:"Azure MCP: Azure Terraform Best Practices",mcp_azure_mcp_documentation:"Azure MCP: Documentation",mcp_azure_mcp_get_bestpractices:"Azure MCP: Get Best Practices",mcp_bicep_format_bicep_file:"Bicep MCP: Format Bicep File",mcp_bicep_get_az_resource_type_schema:"Bicep MCP: Get Az Resource Type Schema",mcp_bicep_get_bicep_best_practices:"Bicep MCP: Get Bicep Best Practices",mcp_bicep_get_bicep_file_diagnostics:"Bicep MCP: Get Bicep File Diagnostics",mcp_bicep_list_az_resource_types_for_provider:"Bicep MCP: List Az Resource Types For Provider","azure_bicep-get_azure_verified_module":"Azure Bicep: Get Azure Verified Module","azure_development-recommend_custom_modes":"Azure Development: Recommend Custom Modes","azure_resources-query_azure_resource_graph":"Azure Resources: Query Azure Resource Graph",manage_todo_list:"Manage TODO List",copilot_readFile:"Read File",copilot_viewImage:"Copilot View Image",opilot_findFiles:"Find Files",copilot_writeFile:"Write File",copilot_applyPatch:"Apply Patch",copilot_findTextInFiles:"Find Text In Files",copilot_findFiles:"Find Files",copilot_replaceString:"Replace String",copilot_createFile:"Create File",copilot_listDirectory:"List Directory",copilot_fetchWebPage:"Fetch Web Page",copilot_getErrors:"Get Errors",copilot_multiReplaceString:"Multi Replace String",copilot_searchCodebase:"Search Codebase",get_terminal_output:"Get Terminal Output",run_task:"Run Task: Investigate",await_terminal:"Await Terminal command","github.copilot.editsAgent":"GitHub Copilot Edits Agent",todoList:"TODO List",terminal:"Terminal",terminal_last_command:"Terminal Last Command",github_pull_request:"GitHub Pull Request",github_repo:"GitHub Repository",editFiles:"Edit Files",listFiles:"List Files",search_subagent:"Search Subagent",execution_subagent:"Execution Subagent",apply_patch:"Apply Patch",ask_questions:"Ask Questions",AskUserQuestion:"Ask User Question",copilot_askQuestions:"Ask Questions",copilot_createAndRunTask:"Create And Run Task",copilot_createDirectory:"Create Directory",copilot_createNewJupyterNotebook:"Create New Jupyter Notebook",copilot_createNewWorkspace:"Create New Workspace",copilot_editFiles:"Edit Files",copilot_editNotebook:"Edit Notebook",copilot_findTestFiles:"Find Test Files",copilot_getChangedFiles:"Get Changed Files",copilot_getDocInfo:"Get Doc Info",copilot_getNotebookSummary:"Get Notebook Summary",copilot_getProjectSetupInfo:"Get Project Setup Info",copilot_getSearchResults:"Get Search Results",copilot_getVSCodeAPI:"Get VSCode API",copilot_githubRepo:"GitHub Repository",copilot_insertEdit:"Insert Edit",copilot_installExtension:"Install Extension",copilot_memory:"Memory",copilot_openIntegratedBrowser:"Open Integrated Browser",copilot_openSimpleBrowser:"Open Simple Browser",copilot_readNotebookCellOutput:"Read Notebook Cell Output",copilot_readProjectStructure:"Read Project Structure",copilot_runNotebookCell:"Run Notebook Cell",copilot_runInTerminal:"Run In Terminal",copilot_runTests1:"Run Tests",copilot_runVscodeCommand:"Run VSCode Command",copilot_searchWorkspaceSymbols:"Search Workspace Symbols",copilot_switchAgent:"Switch Agent",copilot_testFailure:"Test Failure",copilot_toolReplay:"Tool Replay",create_and_run_task:"Create And Run Task",create_directory:"Create Directory",create_file:"Create File",remove_file:"Remove File",create_new_jupyter_notebook:"Create New Jupyter Notebook",create_new_workspace:"Create New Workspace",create_virtual_environment:"Create Virtual Environment",edit_files:"Edit Files",edit_file:"Edit File",edit_notebook_file:"Edit Notebook File",fetch_webpage:"Fetch Webpage",file_search:"File Search",get_changed_files:"Get Changed Files",get_doc_info:"Get Doc Info",get_errors:"Get Errors",get_project_setup_info:"Get Project Setup Info",get_files_in_project:"Get Files In Project",get_projects_in_solution:"Get Projects In Solution",configure_python_environment:"Configure Python Environment",get_python_executable_details:"Get Python Executable Details",get_search_view_results:"Get Search View Results",get_task_output:"Get Task Output",get_output_window_logs:"Get Output Window Logs",job_output:"Job Output",get_vscode_api:"Get VSCode API",grep_search:"Grep Search",insert_edit_into_file:"Insert Edit Into File",install_extension:"Install Extension",install_python_packages:"Install Python Packages",list_dir:"List Dir",ls:"Ls",memory:"Memory",multi_replace_string_in_file:"Multi Replace String In File",open_integrated_browser:"Open Integrated Browser",open_simple_browser:"Open Simple Browser",read_file:"Read File",view_image:"View Image",read_notebook_cell_output:"Read Notebook Cell Output",read_project_structure:"Read Project Structure",replace_string_in_file:"Replace String In File","setup.agent":"Setup Agent",selectEnvironment:"Select Environment",run_notebook_cell:"Run Notebook Cell",run_vscode_command:"Run VSCode Command",runSubagent:"Run Subagent",renderMermaidDiagram:"Render Mermaid Diagram",runTests:"Run Tests",search_workspace_symbols:"Search Workspace Symbols",semantic_search:"Semantic Search",switch_agent:"Switch Agent",terminal_selection:"Terminal Selection",test_failure:"Test Failure",test_search:"Test Search",tool_replay:"Tool Replay",tool_search:"Tool Search",vscode_askQuestions:"VSCode Ask Questions",vscode_get_confirmation:"VSCode Get Confirmation",vscode_get_confirmation_with_options:"VSCode Get Confirmation With Options",vscode_get_terminal_confirmation:"VSCode Get Terminal Confirmation",vscode_get_modified_files_confirmation:"VSCode Get Modified Files Confirmation",vscode_listCodeUsages:"VSCode List Code Usages",vscode_renameSymbol:"VSCode Rename Symbol","mcp_io_github_ups_get-library-docs":"Context7 MCP: Get Library Docs","mcp_io_github_ups_query-docs":"Context7 MCP: Query Docs","mcp_io_github_ups_resolve-library-id":"Context7 MCP: Resolve Library ID","mcp_context7_query-docs":"Context7 MCP: Query Docs","mcp_context7_resolve-library-id":"Context7 MCP: Resolve Library ID",mcp_microsoft_pla_browser_evaluate:"Playwright MCP: Browser Evaluate",mcp_microsoft_pla_browser_install:"Playwright MCP: Browser Install",mcp_microsoft_pla_browser_navigate:"Playwright MCP: Browser Navigate",mcp_microsoft_pla_browser_run_code:"Playwright MCP: Browser Run Code",mcp_microsoft_pla_browser_click:"Playwright MCP: Browser Click",mcp_microsoft_pla_browser_fill_form:"Playwright MCP: Browser Fill Form",mcp_microsoft_pla_browser_press_key:"Playwright MCP: Browser Press Key",mcp_microsoft_pla_browser_resize:"Playwright MCP: Browser Resize",mcp_microsoft_pla_browser_snapshot:"Playwright MCP: Browser Snapshot",mcp_microsoft_pla_browser_tabs:"Playwright MCP: Browser Tabs",mcp_microsoft_pla_browser_take_screenshot:"Playwright MCP: Browser Take Screenshot",mcp_microsoft_pla_browser_type:"Playwright MCP: Browser Type",mcp_playwright_browser_click:"Playwright MCP: Browser Click",mcp_playwright_browser_navigate:"Playwright MCP: Browser Navigate",mcp_playwright_browser_snapshot:"Playwright MCP: Browser Snapshot",mcp_playwright_browser_take_screenshot:"Playwright MCP: Browser Take Screenshot",mcp_pylance_mcp_s_pylanceDocString:"Pylance MCP: Pylance Doc String",mcp_pylance_mcp_s_pylanceRunCodeSnippet:"Pylance MCP: Run Code Snippet",mcp_pylance_mcp_s_pylanceWorkspaceRoots:"Pylance MCP: Workspace Roots",mcp_pylance_mcp_s_pylanceFileSyntaxErrors:"Pylance MCP: File Syntax Errors",mcp_pylance_mcp_s_pylanceSyntaxErrors:"Pylance MCP: Syntax Errors","mcp_chrome-devtoo_click":"Chrome DevTools MCP: Click","mcp_chrome-devtoo_evaluate_script":"Chrome DevTools MCP: Evaluate Script","mcp_chrome-devtoo_fill":"Chrome DevTools MCP: Fill","mcp_chrome-devtoo_get_network_request":"Chrome DevTools MCP: Get Network Request","mcp_chrome-devtoo_list_console_messages":"Chrome DevTools MCP: List Console Messages","mcp_chrome-devtoo_list_pages":"Chrome DevTools MCP: List Pages","mcp_chrome-devtoo_navigate_page":"Chrome DevTools MCP: Navigate Page","mcp_chrome-devtoo_new_page":"Chrome DevTools MCP: New Page","mcp_chrome-devtoo_select_page":"Chrome DevTools MCP: Select Page","mcp_chrome-devtoo_take_screenshot":"Chrome DevTools MCP: Take Screenshot","mcp_chrome-devtoo_fill_form":"Chrome DevTools MCP: Fill Form","mcp_chrome-devtoo_hover":"Chrome DevTools MCP: Hover","mcp_chrome-devtoo_list_network_requests":"Chrome DevTools MCP: List Network Requests","mcp_chrome-devtoo_press_key":"Chrome DevTools MCP: Press Key","mcp_chrome-devtoo_take_snapshot":"Chrome DevTools MCP: Take Snapshot","mcp_chrome-devtoo_wait_for":"Chrome DevTools MCP: Wait For","mcp_chrome-devtoo_close_page":"Chrome DevTools MCP: Close Page","mcp_chrome-devtoo_lighthouse_audit":"Chrome DevTools MCP: Lighthouse Audit","mcp_chrome-devtoo_performance_analyze_insight":"Chrome DevTools MCP: Performance Analyze Insight","mcp_chrome-devtoo_performance_start_trace":"Chrome DevTools MCP: Performance Start Trace","mcp_chrome-devtoo_resize_page":"Chrome DevTools MCP: Resize Page","mcp_chrome-devtoo_type_text":"Chrome DevTools MCP: Type Text",mcp_chrome_devtoo_click:"Chrome DevTools MCP: Click",mcp_chrome_devtoo_evaluate_script:"Chrome DevTools MCP: Evaluate Script",mcp_chrome_devtoo_fill:"Chrome DevTools MCP: Fill",mcp_chrome_devtoo_get_console_message:"Chrome DevTools MCP: Get Console Message",mcp_chrome_devtoo_get_network_request:"Chrome DevTools MCP: Get Network Request",mcp_chrome_devtoo_list_console_messages:"Chrome DevTools MCP: List Console Messages",mcp_chrome_devtoo_list_network_requests:"Chrome DevTools MCP: List Network Requests",mcp_chrome_devtoo_list_pages:"Chrome DevTools MCP: List Pages",mcp_chrome_devtoo_navigate_page:"Chrome DevTools MCP: Navigate Page",mcp_chrome_devtoo_new_page:"Chrome DevTools MCP: New Page",mcp_chrome_devtoo_take_snapshot:"Chrome DevTools MCP: Take Snapshot",mcp_chrome_devtoo_wait_for:"Chrome DevTools MCP: Wait For",mcp_io_github_chr_click:"Chrome DevTools MCP: Click",mcp_io_github_chr_emulate:"Chrome DevTools MCP: Emulate",mcp_io_github_chr_evaluate_script:"Chrome DevTools MCP: Evaluate Script",mcp_io_github_chr_list_network_requests:"Chrome DevTools MCP: List Network Requests",mcp_io_github_chr_list_pages:"Chrome DevTools MCP: List Pages",mcp_io_github_chr_navigate_page:"Chrome DevTools MCP: Navigate Page",mcp_io_github_chr_new_page:"Chrome DevTools MCP: New Page",mcp_io_github_chr_resize_page:"Chrome DevTools MCP: Resize Page",mcp_io_github_chr_select_page:"Chrome DevTools MCP: Select Page",mcp_io_github_chr_take_snapshot:"Chrome DevTools MCP: Take Snapshot",mcp_oraios_serena_activate_project:"Serena: Activate Project",mcp_oraios_serena_check_onboarding_performed:"Serena: Check Onboarding Performed",mcp_oraios_serena_create_text_file:"Serena: Create Text File",mcp_oraios_serena_delete_lines:"Serena: Delete Lines",mcp_oraios_serena_delete_memory:"Serena: Delete Memory",mcp_oraios_serena_edit_memory:"Serena: Edit Memory",mcp_oraios_serena_execute_shell_command:"Serena: Execute Shell Command",mcp_oraios_serena_find_file:"Serena: Find File",mcp_oraios_serena_find_referencing_symbols:"Serena: Find Referencing Symbols",mcp_oraios_serena_find_symbol:"Serena: Find Symbol",mcp_oraios_serena_get_current_config:"Serena: Get Current Config",mcp_oraios_serena_get_symbols_overview:"Serena: Get Symbols Overview",mcp_oraios_serena_initial_instructions:"Serena: Initial Instructions",mcp_oraios_serena_insert_after_symbol:"Serena: Insert After Symbol",mcp_oraios_serena_insert_at_line:"Serena: Insert At Line",mcp_oraios_serena_insert_before_symbol:"Serena: Insert Before Symbol",mcp_oraios_serena_jet_brains_find_referencing_symbols:"Serena: JetBrains Find Referencing Symbols",mcp_oraios_serena_jet_brains_find_symbol:"Serena: JetBrains Find Symbol",mcp_oraios_serena_jet_brains_get_symbols_overview:"Serena: JetBrains Get Symbols Overview",mcp_oraios_serena_jet_brains_type_hierarchy:"Serena: JetBrains Type Hierarchy",mcp_oraios_serena_list_dir:"Serena: List Dir",mcp_oraios_serena_list_memories:"Serena: List Memories",mcp_oraios_serena_onboarding:"Serena: Onboarding",mcp_oraios_serena_open_dashboard:"Serena: Open Dashboard",mcp_oraios_serena_prepare_for_new_conversation:"Serena: Prepare For New Conversation",mcp_oraios_serena_read_file:"Serena: Read File",mcp_oraios_serena_read_memory:"Serena: Read Memory",mcp_oraios_serena_remove_project:"Serena: Remove Project",mcp_oraios_serena_rename_symbol:"Serena: Rename Symbol",mcp_oraios_serena_replace_content:"Serena: Replace Content",mcp_oraios_serena_replace_lines:"Serena: Replace Lines",mcp_oraios_serena_replace_symbol_body:"Serena: Replace Symbol Body",mcp_oraios_serena_restart_language_server:"Serena: Restart Language Server",mcp_oraios_serena_search_for_pattern:"Serena: Search For Pattern",mcp_oraios_serena_summarize_changes:"Serena: Summarize Changes",mcp_oraios_serena_switch_modes:"Serena: Switch Modes",mcp_oraios_serena_think_about_collected_information:"Serena: Think About Collected Information",mcp_oraios_serena_think_about_task_adherence:"Serena: Think About Task Adherence",mcp_oraios_serena_think_about_whether_you_are_done:"Serena: Think About Whether You Are Done",mcp_oraios_serena_write_memory:"Serena: Write Memory","mcp_visuals-mcp_display_image":"Visuals MCP: Display Image","mcp_laravel-boost_tinker":"Laravel Boost MCP: Tinker",bash:"Bash",Bash:"Bash",code_search:"Code Search",detect_memories:"Detect Memories",get_currentfile:"Get Current File",get_file:"Get File",get_symbols_by_name:"Get Symbols By Name","claude-code":"Claude Code","copilot-cloud-agent":"Copilot Cloud Agent",agent:"Agent",copilotcli:"Copilot CLI","github.copilot.default":"GitHub Copilot Default","github.copilot.workspace":"GitHub Copilot Workspace","github.copilot.vscode":"GitHub Copilot VSCode","github.copilot-dynamic.platform":"GitHub Copilot Dynamic: Platform",glob:"Glob",file_glob_search:"File Glob Search",grep:"Grep",kill_terminal:"Kill Terminal",read:"Read",view:"View",vscode_editFile_internal:"VSCode Edit File (Internal)",vscode_fetchWebPage_internal:"VSCode Fetch Web Page (Internal)",vscode_searchExtensions_internal:"VSCode Search Extensions (Internal)","vscode-websearchforcopilot_webSearch":"VSCode WebSearch for Copilot: Web Search",Build_CMakeTools:"CMake Tools: Build",ListBuildTargets_CMakeTools:"CMake Tools: List Build Targets",ListTests_CMakeTools:"CMake Tools: List Tests",RunCtest_CMakeTools:"CMake Tools: Run CTest","nuget_get-nuget-solver":"NuGet: Get NuGet Solver",webfetch:"Web Fetch",web_fetch:"Web Fetch",write:"Write",edit:"Edit",search_replace:"Search Replace",write_file:"Write File",multiedit:"Multi Edit",question:"Question",skill:"Skill",read_skill:"Read Skill",task:"Task",todowrite:"Todo Write",TodoWrite:"Todo Write",todos:"Todos",todo:"Todo",websearch:"Web Search",WebSearch:"Web Search",click_element:"Click Element",navigate_page:"Navigate Page",open_browser_page:"Open Browser Page",read_page:"Read Page",run_playwright_code:"Run Playwright Code",screenshot_page:"Screenshot Page",type_in_page:"Type in Page",task_complete:"Task Complete","pdf-utilities.pdf":"PDF Utilities: PDF","container-tools_get-config":"Container Tools: Get Config","github-pull-request_activePullRequest":"GitHub Pull Request: Active Pull Request","github-pull-request_currentActivePullRequest":"GitHub Pull Request: Current Active Pull Request","github-pull-request_issue_fetch":"GitHub Pull Request: Issue Fetch","github-pull-request_pullRequestStatusChecks":"GitHub Pull Request: Pull Request Status Checks","mcp_powerbi-model_connection_operations":"Power BI MCP: Connection Operations",MiniMax_web_search:"MiniMax: Web Search",dingDocuments_get_document_content:"Ding Documents: Get Document Content",dingDocuments_list_nodes:"Ding Documents: List Nodes",dingDocuments_search_documents:"Ding Documents: Search Documents",fetch_fetch:"Fetch: Fetch",mcp__Claude_in_Chrome__computer:"Claude in Chrome MCP: Computer",mcp__Claude_in_Chrome__navigate:"Claude in Chrome MCP: Navigate",mcp__Claude_in_Chrome__tabs_context_mcp:"Claude in Chrome MCP: Tabs Context",mcp__cowork__allow_cowork_file_delete:"Cowork MCP: Allow Cowork File Delete",mcp__cowork__present_files:"Cowork MCP: Present Files",mcp__cowork__request_cowork_directory:"Cowork MCP: Request Cowork Directory","mcp__cowork-onboarding__show_onboarding_role_picker":"Cowork Onboarding MCP: Show Onboarding Role Picker",mcp__plugins__search_plugins:"Plugins MCP: Search Plugins",mcp__plugins__suggest_plugin_install:"Plugins MCP: Suggest Plugin Install",mcp__workspace__bash:"Workspace MCP: Bash",mcp__workspace__web_fetch:"Workspace MCP: Web Fetch","mcp__mcp-registry__search_mcp_registry":"MCP Registry: Search MCP Registry",Agent:"Agent",Edit:"Edit",Glob:"Glob",Grep:"Grep",NotebookEdit:"Notebook Edit",Read:"Read",Skill:"Skill",ToolSearch:"Tool Search",Write:"Write","mcp__claude_ai_Context7__resolve-library-id":"Context7 MCP (Claude): Resolve Library ID",mcp__claude_ai_Excalidraw__create_view:"Excalidraw MCP (Claude): Create View",mcp__claude_ai_Excalidraw__read_me:"Excalidraw MCP (Claude): Read Me","mcp__claude_ai_Notion__notion-create-pages":"Notion MCP (Claude): Create Pages","mcp__claude_ai_Notion__notion-fetch":"Notion MCP (Claude): Fetch","mcp__claude_ai_Notion__notion-search":"Notion MCP (Claude): Search","mcp__claude_ai_Notion__notion-update-page":"Notion MCP (Claude): Update Page","mcp__context7__query-docs":"Context7 MCP: Query Docs","mcp__context7__resolve-library-id":"Context7 MCP: Resolve Library ID","mcp__databricks-sql-allscopes__authenticate":"Databricks SQL MCP: Authenticate","mcp__databricks-sql-allscopes__complete_authentication":"Databricks SQL MCP: Complete Authentication","mcp__databricks-sql__authenticate":"Databricks SQL MCP: Authenticate",mcp__playwright__browser_evaluate:"Playwright MCP: Browser Evaluate",mcp__playwright__browser_navigate:"Playwright MCP: Browser Navigate","mcp__plugin_context7_context7__query-docs":"Context7 MCP: Query Docs","mcp__plugin_context7_context7__resolve-library-id":"Context7 MCP: Resolve Library ID","mcp__shopify-dev-mcp__learn_shopify_api":"Shopify Dev MCP: Learn Shopify API","mcp__shopify-dev-mcp__search_docs_chunks":"Shopify Dev MCP: Search Docs Chunks","mcp__shopify-dev-mcp__validate_graphql_codeblocks":"Shopify Dev MCP: Validate GraphQL Codeblocks",invalid:"Invalid"};var Da=.2,Ia=21e3,Oa=.3,qo=Ta.estimators,ns=Pa.pricing,Pu=Ma,Mu=r=>{},Ua=r=>{},Au=(r,e)=>console.error(T.red(r),e||"");function Eu(){let r=Zt.file(__dirname);return new lo(r)}function Du(){let r=Zt.file(__dirname);return new uo(r)}function Iu(){return new po}function Ou(){return new xo}function Uu(){return new Po}function Ru(){return new Eo}function Fu(){return new Io}var Nu=Eu(),ju=Du(),$u=Iu(),Lu=Ou(),qu=Uu(),Gu=Ru(),Bu=Fu(),Go=[new vs(Nu),new xs(ju),new As(Lu,(r,e)=>ee(r,e??"gpt-4",qo)),new Ts($u),new Ms(Gu,Xe,Ze,(r,e)=>ee(r,e??"gpt-4",qo)),new Ps(qu),new Es(Bu),new Os,new Fs];function Ra(){return new no({log:Mu,warn:Ua,error:Au,ecosystems:Go})}async function _e(){return Ra().getCopilotSessionFiles()}async function Bo(r){let e=new Set,t=Ie.join(Ea.homedir(),".claude","projects");for(let o of r){if(o.startsWith(t+Ie.sep)||o.startsWith(t+"/")){try{let h=(await et.promises.readFile(o,"utf-8")).split(`
|
|
52
|
+
`).slice(0,30);for(let m of h)if(m.trim())try{let p=JSON.parse(m);if(p.cwd&&typeof p.cwd=="string"){e.add(p.cwd);break}}catch{}}catch{}continue}let n=Ie.dirname(o);if(Ie.basename(n)!=="chatSessions")continue;let a=Ie.dirname(n),d=Ie.join(a,"workspace.json");try{if(!et.existsSync(d))continue;let h=JSON.parse(await et.promises.readFile(d,"utf-8")).folder;if(!h||!h.startsWith("file://"))continue;let m=decodeURIComponent(h.replace(/^file:\/\//,""));/^\/[A-Za-z]:/.test(m)&&(m=m.slice(1)),e.add(m)}catch{}}if(e.size===0)return;let s=0;for(let o of e)try{let n=et.existsSync(Ie.join(o,".github","copilot-instructions.md")),a=et.existsSync(Ie.join(o,"agents.md")),d=et.existsSync(Ie.join(o,"CLAUDE.md"));!n&&!a&&!d&&s++}catch{s++}return{customizationTypes:[],workspaces:[],totalWorkspaces:e.size,workspacesWithIssues:s}}function zo(){return Ra().getDiagnosticCandidatePaths()}function zu(r,e){return ee(r,e||"gpt-4",qo)}function Wu(r){return xt(r,ns)}async function Fa(r){let e=Go.find(t=>t.handles(r));return e?e.stat(r):et.promises.stat(r)}function Aa(r){let e=r.toLowerCase().replace(/\\/g,"/");return e.includes("/cursor/")?"cursor":e.includes("/code - insiders/")?"vscode-insiders":e.includes("/code - exploration/")?"vscode-exploration":e.includes("/vscodium/")?"vscodium":e.includes("/.copilot/")?"copilot-cli":e.includes("/.crush/crush.db#")?"crush":e.includes("/opencode/")?"opencode":e.includes("/local-agent-mode-sessions/")?"claude-desktop-cowork":e.includes("/.claude/projects/")?"claude-code":e.includes("/.vibe/logs/session/")?"mistral-vibe":e.includes(".vscode-server")?"vscode-remote":e.includes("/.vs/")&&e.includes("/copilot-chat/")?"Visual Studio":"vscode"}async function Vu(r,e,t=20){if(r.length===0)return[];let s=new Array(r.length),o=0,n=Array.from({length:Math.min(t,r.length)},async()=>{for(;o<r.length;){let a=o++;try{s[a]=await e(r[a],a)}catch{s[a]=void 0}}});return await Promise.all(n),s}async function is(r){try{let e=await Fa(r),t=xa(r,e.mtimeMs,e.size);if(t)return t;let s=Go.find(p=>p.handles(r));if(s){let[p,g,w]=await Promise.all([s.getTokens(r),s.countInteractions(r),s.getModelUsage(r)]),k={file:r,tokens:p.tokens,thinkingTokens:p.thinkingTokens,interactions:g,modelUsage:w,lastModified:e.mtime,editorSource:Aa(r)};return yi(r,e.mtimeMs,e.size,k),k}let o=await et.promises.readFile(r,"utf-8");if(!o.trim())return null;let n=r.endsWith(".jsonl")||dt(o),a=0,d=0,c=0,h={};if(n){let p=Oo(o);a=p.tokens,d=p.thinkingTokens;let g=o.trim().split(`
|
|
53
|
+
`);for(let w of g)try{let k=JSON.parse(w);(k.type==="user.message"||k.kind===2&&k.k?.[0]==="requests")&&c++}catch{}}else{let p=ba(r,o,zu,Wu);a=p.tokens,d=p.thinkingTokens,c=p.interactions,h=p.modelUsage}let m={file:r,tokens:a,thinkingTokens:d,interactions:c,modelUsage:h,lastModified:e.mtime,editorSource:Aa(r)};return yi(r,e.mtimeMs,e.size,m),m}catch{return null}}async function rs(r,e){let t=new Date,s=new Date(t.getFullYear(),t.getMonth(),t.getDate()),o=new Date(t.getFullYear(),t.getMonth(),1),n=new Date(t.getFullYear(),t.getMonth()-1,1),a=new Date(t.getFullYear(),t.getMonth(),0,23,59,59),d=new Date(t.getFullYear(),t.getMonth(),t.getDate()-30),c={today:jo(),month:jo(),lastMonth:jo(),last30Days:jo()},h=0,m=await Vu(r,async p=>{let g=await is(p);return e&&e(++h,r.length),g});for(let p of m){if(!p||p.tokens===0)continue;let g=p.lastModified;g<n||(g>=s&&$o(c.today,p),g>=o&&$o(c.month,p),g>=n&&g<=a&&$o(c.lastMonth,p),g>=d&&$o(c.last30Days,p))}for(let p of Object.values(c))p.sessions>0&&(p.avgTokensPerSession=Math.round(p.tokens/p.sessions)),p.co2=p.tokens/1e3*Da,p.treesEquivalent=p.co2/Ia,p.waterUsage=p.tokens/1e3*Oa,p.estimatedCost=oi(p.modelUsage,ns),p.estimatedCostCopilot=oi(p.modelUsage,ns,"copilot");return{...c,lastUpdated:t}}function jo(){return{tokens:0,thinkingTokens:0,estimatedTokens:0,actualTokens:0,sessions:0,avgInteractionsPerSession:0,avgTokensPerSession:0,modelUsage:{},editorUsage:{},co2:0,treesEquivalent:0,waterUsage:0,estimatedCost:0}}function $o(r,e){r.tokens+=e.tokens,r.thinkingTokens+=e.thinkingTokens,r.estimatedTokens+=e.tokens,r.sessions++;for(let[s,o]of Object.entries(e.modelUsage))r.modelUsage[s]||(r.modelUsage[s]={inputTokens:0,outputTokens:0}),r.modelUsage[s].inputTokens+=o.inputTokens,r.modelUsage[s].outputTokens+=o.outputTokens;let t=r.avgInteractionsPerSession*(r.sessions-1)+e.interactions;r.avgInteractionsPerSession=r.sessions>0?t/r.sessions:0,r.editorUsage[e.editorSource]||(r.editorUsage[e.editorSource]={tokens:0,sessions:0}),r.editorUsage[e.editorSource].tokens+=e.tokens,r.editorUsage[e.editorSource].sessions++}async function as(r){let e={warn:Ua,tokenEstimators:qo,modelPricing:ns,toolNameMap:Pu,ecosystems:Go},t=new Date,s=new Date(t.getFullYear(),t.getMonth(),t.getDate()),o=new Date(t.getFullYear(),t.getMonth(),t.getDate()-30),n=new Date(t.getFullYear(),t.getMonth(),1),a=bi(),d=bi(),c=bi();for(let h of r)try{let p=(await Fa(h)).mtime;if(p<o)continue;let g=await la(e,h);p>=o&&(Ro(d,g),d.sessions++),p>=n&&(Ro(c,g),c.sessions++),p>=s&&(Ro(a,g),a.sessions++)}catch{}return{today:a,last30Days:d,month:c,lastUpdated:t}}function bi(){return{sessions:0,toolCalls:{total:0,byTool:{}},modeUsage:{ask:0,edit:0,agent:0,plan:0,customAgent:0,cli:0},contextReferences:ye(),mcpTools:{total:0,byServer:{},byTool:{}},modelSwitching:{modelsPerSession:[],totalSessions:0,averageModelsPerSession:0,maxModelsPerSession:0,minModelsPerSession:0,switchingFrequency:0,standardModels:[],premiumModels:[],unknownModels:[],mixedTierSessions:0,standardRequests:0,premiumRequests:0,unknownRequests:0,totalRequests:0},repositories:[],repositoriesWithCustomization:[],editScope:{singleFileEdits:0,multiFileEdits:0,totalEditedFiles:0,avgFilesPerSession:0},applyUsage:{totalApplies:0,totalCodeBlocks:0,applyRate:0},sessionDuration:{totalDurationMs:0,avgDurationMs:0,avgFirstProgressMs:0,avgTotalElapsedMs:0,avgWaitTimeMs:0},conversationPatterns:{multiTurnSessions:0,singleTurnSessions:0,avgTurnsPerSession:0,maxTurnsInSession:0},agentTypes:{editsAgent:0,defaultAgent:0,workspaceAgent:0,other:0}}}async function Wo(r){let e=new Date,t=new Date(e.getFullYear(),e.getMonth(),e.getDate()-30),s=new Map,o=new Date(t);for(;o<=e;){let d=`${o.getFullYear()}-${String(o.getMonth()+1).padStart(2,"0")}-${String(o.getDate()).padStart(2,"0")}`;s.set(d,{tokens:0,sessions:0,modelUsage:{},editorUsage:{}}),o.setDate(o.getDate()+1)}for(let d of r){let c=await is(d);if(!c||c.tokens===0||c.interactions===0||c.lastModified<t)continue;let h=c.lastModified,m=`${h.getFullYear()}-${String(h.getMonth()+1).padStart(2,"0")}-${String(h.getDate()).padStart(2,"0")}`,p=s.get(m);if(!p)continue;p.tokens+=c.tokens,p.sessions++;for(let[w,k]of Object.entries(c.modelUsage))p.modelUsage[w]||(p.modelUsage[w]={inputTokens:0,outputTokens:0}),p.modelUsage[w].inputTokens+=k.inputTokens,p.modelUsage[w].outputTokens+=k.outputTokens;let g=c.editorSource;p.editorUsage[g]||(p.editorUsage[g]={tokens:0,sessions:0}),p.editorUsage[g].tokens+=c.tokens,p.editorUsage[g].sessions++}let n=Array.from(s.keys()).sort(),a=n.map(d=>s.get(d));return{labels:n,days:a}}var Lo=[{bg:"rgba(54, 162, 235, 0.6)",border:"rgba(54, 162, 235, 1)"},{bg:"rgba(255, 99, 132, 0.6)",border:"rgba(255, 99, 132, 1)"},{bg:"rgba(75, 192, 192, 0.6)",border:"rgba(75, 192, 192, 1)"},{bg:"rgba(153, 102, 255, 0.6)",border:"rgba(153, 102, 255, 1)"},{bg:"rgba(255, 159, 64, 0.6)",border:"rgba(255, 159, 64, 1)"},{bg:"rgba(255, 205, 86, 0.6)",border:"rgba(255, 205, 86, 1)"},{bg:"rgba(201, 203, 207, 0.6)",border:"rgba(201, 203, 207, 1)"},{bg:"rgba(100, 181, 246, 0.6)",border:"rgba(100, 181, 246, 1)"}];function Vo(r,e){let t=e.map(p=>p.tokens),s=e.map(p=>p.sessions),o=new Set;e.forEach(p=>Object.keys(p.modelUsage).forEach(g=>o.add(g)));let n=Array.from(o).map((p,g)=>{let w=Lo[g%Lo.length];return{label:p,data:e.map(k=>{let b=k.modelUsage[p];return b?b.inputTokens+b.outputTokens:0}),backgroundColor:w.bg,borderColor:w.border,borderWidth:1}}),a=new Set;e.forEach(p=>Object.keys(p.editorUsage).forEach(g=>a.add(g)));let d=Array.from(a).map((p,g)=>{let w=Lo[g%Lo.length];return{label:p,data:e.map(k=>k.editorUsage[p]?.tokens||0),backgroundColor:w.bg,borderColor:w.border,borderWidth:1}}),c={};e.forEach(p=>{Object.entries(p.editorUsage).forEach(([g,w])=>{c[g]=(c[g]||0)+w.tokens})});let h=t.reduce((p,g)=>p+g,0),m=s.reduce((p,g)=>p+g,0);return{labels:r,tokensData:t,sessionsData:s,modelDatasets:n,editorDatasets:d,editorTotalsMap:c,repositoryDatasets:[],repositoryTotalsMap:{},dailyCount:r.length,totalTokens:h,avgTokensPerDay:r.length>0?Math.round(h/r.length):0,totalSessions:m,lastUpdated:new Date().toISOString(),backendConfigured:!1}}function X(r){return r.toLocaleString("en-US")}function me(r){return r>=1e6?`${(r/1e6).toFixed(1)}M`:r>=1e3?`${(r/1e3).toFixed(1)}K`:r.toString()}var Pt={CO2_PER_1K_TOKENS:Da,CO2_ABSORPTION_PER_TREE_PER_YEAR:Ia,WATER_USAGE_PER_1K_TOKENS:Oa,CO2_PER_KM_DRIVING:120,CO2_PER_PHONE_CHARGE:8.22,WATER_PER_COFFEE_CUP:140,CO2_PER_LED_HOUR:20};var Na=new pe("stats").description("Show overview of discovered session files, sessions, chat turns, and tokens").option("-v, --verbose","Show detailed per-folder breakdown").action(async r=>{if(console.log(T.bold.cyan(`
|
|
48
54
|
\u{1F50D} Copilot Token Tracker - Session Statistics
|
|
49
|
-
`)),
|
|
50
|
-
`));let t=0,
|
|
55
|
+
`)),r.verbose){let p=zo();console.log(T.dim("Search paths:"));for(let g of p){let w=g.exists?T.green("\u2705"):T.dim("\u274C");console.log(` ${w} ${T.dim(g.source)}: ${g.path}`)}console.log()}process.stdout.write(T.dim("Scanning for session files..."));let e=await _e();if(process.stdout.write("\r"+" ".repeat(50)+"\r"),e.length===0){console.log(T.yellow("\u26A0\uFE0F No session files found.")),console.log(T.dim("Have you used GitHub Copilot Chat in VS Code yet?"));return}console.log(T.green(`\u{1F4C2} Found ${T.bold(X(e.length))} session file(s)
|
|
56
|
+
`));let t=0,s=0,o=0,n=0,a=0,d={},c={};for(let p=0;p<e.length;p++){let g=await is(e[p]);if(!g||g.tokens===0){a++;continue}if(n++,t+=g.tokens,s+=g.thinkingTokens,o+=g.interactions,d[g.editorSource]||(d[g.editorSource]={files:0,tokens:0,interactions:0}),d[g.editorSource].files++,d[g.editorSource].tokens+=g.tokens,d[g.editorSource].interactions+=g.interactions,r.verbose){let w=Ju(e[p]);c[w]||(c[w]={files:0,tokens:0}),c[w].files++,c[w].tokens+=g.tokens}((p+1)%50===0||p===e.length-1)&&process.stdout.write(`\r${T.dim(`Processing: ${p+1}/${e.length}`)}`)}process.stdout.write("\r"+" ".repeat(50)+"\r"),console.log(T.bold("\u{1F4CA} Summary")),console.log(T.dim("\u2500".repeat(50))),console.log(` Session files (with data): ${T.bold(X(n))}`),a>0&&console.log(` Empty/skipped files: ${T.dim(X(a))}`),console.log(` Total chat turns: ${T.bold(X(o))}`),console.log(` Total estimated tokens: ${T.bold.yellow(me(t))}`),s>0&&console.log(` Thinking tokens (included): ${T.dim(me(s))}`);let h=_i();h.enabled&&h.entries>0&&console.log(T.dim(` Cache: ${X(h.entries)} entries loaded`)),console.log();let m=Object.entries(d).sort((p,g)=>g[1].tokens-p[1].tokens);if(m.length>0){console.log(T.bold("\u{1F5A5}\uFE0F By Editor")),console.log(T.dim("\u2500".repeat(50)));for(let[p,g]of m){let w=Hu(p);console.log(` ${w.padEnd(25)} ${X(g.files).padStart(5)} files ${me(g.tokens).padStart(8)} tokens ${X(g.interactions).padStart(6)} turns`)}console.log()}if(r.verbose&&Object.keys(c).length>0){let p=Object.entries(c).sort((g,w)=>w[1].tokens-g[1].tokens);console.log(T.bold("\u{1F4C1} By Folder")),console.log(T.dim("\u2500".repeat(70)));for(let[g,w]of p.slice(0,20))console.log(` ${g.substring(0,50).padEnd(50)} ${X(w.files).padStart(5)} files ${me(w.tokens).padStart(8)} tokens`);p.length>20&&console.log(T.dim(` ... and ${p.length-20} more folders`)),console.log()}});function Hu(r){return{vscode:"VS Code","vscode-insiders":"VS Code Insiders","vscode-exploration":"VS Code Exploration","vscode-remote":"VS Code Remote",vscodium:"VSCodium",cursor:"Cursor","copilot-cli":"Copilot CLI",opencode:"OpenCode","claude-code":"Claude Code","claude-desktop-cowork":"Claude Desktop (Cowork)","mistral-vibe":"Mistral Vibe"}[r]||r}function Ju(r){let e=r.split(/[/\\]/),t=e.indexOf("chatSessions");return t>=2?e.slice(t-1,t+1).join("/"):e.slice(-3,-1).join("/")}var ja=new pe("usage").description("Show token usage for today, current month, last month, and last 30 days").option("-m, --models","Show per-model token breakdown").option("-c, --cost","Show estimated cost breakdown").option("--json","Output raw JSON (for machine consumption)").action(async r=>{let e=await Ku(r);if(!e)return;let t=await Yu(e,r);if(r.json){let o={today:t.today,month:t.month,lastMonth:t.lastMonth,last30Days:t.last30Days,lastUpdated:t.lastUpdated.toISOString(),backendConfigured:!1};process.stdout.write(JSON.stringify(o));return}console.log(T.bold.cyan(`
|
|
51
57
|
\u{1F4CA} Copilot Token Tracker - Usage Report
|
|
52
|
-
`));let
|
|
53
|
-
`))});async function
|
|
58
|
+
`));let s=[{label:"Today",emoji:"\u{1F4C5}",stats:t.today},{label:"This Month",emoji:"\u{1F4C6}",stats:t.month},{label:"Last Month",emoji:"\u{1F5D3}\uFE0F",stats:t.lastMonth},{label:"Last 30 Days",emoji:"\u{1F4C8}",stats:t.last30Days}];for(let o of s)Qu(o.label,o.emoji,o.stats,r);console.log(T.dim(`Last updated: ${t.lastUpdated.toLocaleString()}
|
|
59
|
+
`))});async function Ku(r){r.json||process.stdout.write(T.dim("Scanning for session files..."));let e=await _e();return r.json||process.stdout.write("\r"+" ".repeat(50)+"\r"),e.length===0?(r.json?process.stdout.write("{}"):console.log(T.yellow("\u26A0\uFE0F No session files found.")),null):e}async function Yu(r,e){e.json||process.stdout.write(T.dim("Calculating token usage..."));let t=await rs(r,e.json?void 0:(s,o)=>{process.stdout.write(`\r${T.dim(`Processing: ${s}/${o} files`)}`)});return e.json||process.stdout.write("\r"+" ".repeat(50)+"\r"),t}function Qu(r,e,t,s){if(console.log(T.bold(`${e} ${r}`)),console.log(T.dim("\u2500".repeat(55))),t.sessions===0){console.log(T.dim(" No activity in this period")),console.log();return}if(console.log(` Sessions: ${T.bold(X(t.sessions))}`),console.log(` Avg interactions/sess: ${T.bold(t.avgInteractionsPerSession.toFixed(1))}`),console.log(` Total tokens: ${T.bold.yellow(me(t.tokens))}`),t.thinkingTokens>0&&console.log(` Thinking tokens: ${T.dim(me(t.thinkingTokens))} (included in total)`),console.log(` Avg tokens/session: ${T.bold(me(t.avgTokensPerSession))}`),s.cost&&t.estimatedCost>0&&(console.log(` Estimated cost (est.): ${T.green("$"+t.estimatedCost.toFixed(4))} ${T.dim("(provider API rates)")}`),(t.estimatedCostCopilot??0)>0&&console.log(` Estimated cost (TBB): ${T.green("$"+(t.estimatedCostCopilot??0).toFixed(4))} ${T.dim("(Copilot AI Credits)")}`)),s.models&&Object.keys(t.modelUsage).length>0){console.log(),console.log(T.dim(" Model Breakdown:"));let o=Object.entries(t.modelUsage).sort((n,a)=>a[1].inputTokens+a[1].outputTokens-(n[1].inputTokens+n[1].outputTokens));for(let[n,a]of o){let d=a.inputTokens+a.outputTokens,c=pt(n,ns),h=c==="premium"?T.yellow(" \u2B50"):c==="standard"?T.dim(" \u25CB"):"";console.log(` ${(n+h).padEnd(35)} ${me(a.inputTokens).padStart(8)} in ${me(a.outputTokens).padStart(8)} out ${me(d).padStart(8)} total`)}}if(Object.keys(t.editorUsage).length>1){console.log(),console.log(T.dim(" Editor Breakdown:"));let o=Object.entries(t.editorUsage).sort((n,a)=>a[1].tokens-n[1].tokens);for(let[n,a]of o)console.log(` ${n.padEnd(25)} ${X(a.sessions).padStart(5)} sessions ${me(a.tokens).padStart(8)} tokens`)}console.log()}var $a=new pe("environmental").alias("env").description("Show environmental impact of your Copilot usage (CO2, water, trees)").action(async()=>{console.log(T.bold.cyan(`
|
|
54
60
|
\u{1F30D} Copilot Token Tracker - Environmental Impact
|
|
55
|
-
`)),process.stdout.write(T.dim("Scanning for session files..."));let
|
|
56
|
-
`));for(let
|
|
57
|
-
`))});function ca(n){return n>=1e3?`${(n/1e3).toFixed(2)} kgCO\u2082e`:`${n.toFixed(3)} gCO\u2082e`}function iu(n,e,t){if(console.log(T.bold(`${e} ${n}`)),console.log(T.dim("\u2500".repeat(55))),t.sessions===0){console.log(T.dim(" No activity in this period")),console.log();return}if(console.log(` Tokens used: ${T.bold.yellow(pe(t.tokens))}`),console.log(` CO\u2082 emissions: ${T.bold(ca(t.co2))}`),console.log(` Water usage: ${T.bold(t.waterUsage.toFixed(3))} liters`),t.treesEquivalent>0){let o=t.treesEquivalent<.001?t.treesEquivalent.toExponential(2):t.treesEquivalent.toFixed(6);console.log(` Trees to offset: ${T.green(o)} trees/year`)}console.log()}var eo=z(require("fs")),st=z(require("path"));var ua=["read_file","copilot_readFile","read","view","view_image","copilot_viewImage","list_dir","ls","copilot_listDirectory","find_files","file_search","file_glob_search","copilot_findFiles","opilot_findFiles","copilot_findTextInFiles","copilot_findTestFiles","test_search","grep_search","grep","glob","semantic_search","copilot_searchCodebase","code_search","copilot_getSearchResults","get_search_view_results","search_workspace_symbols","copilot_searchWorkspaceSymbols","vscode_listCodeUsages","get_symbols_by_name","get_errors","copilot_getErrors","get_changed_files","copilot_getChangedFiles","read_project_structure","copilot_readProjectStructure","get_doc_info","copilot_getDocInfo","get_vscode_api","copilot_getVSCodeAPI","get_project_setup_info","copilot_getProjectSetupInfo","get_files_in_project","get_projects_in_solution","get_python_executable_details","get_currentfile","get_file","vscode_get_confirmation","vscode_get_confirmation_with_options","vscode_get_terminal_confirmation","vscode_get_modified_files_confirmation","memory","copilot_memory","detect_memories","tool_replay","copilot_toolReplay","tool_search","get_task_output","job_output","get_terminal_output","await_terminal","terminal_selection","terminal_last_command","read_notebook_cell_output","copilot_readNotebookCellOutput","copilot_getNotebookSummary","test_failure","copilot_testFailure","ask_questions","AskUserQuestion","copilot_askQuestions","switch_agent","copilot_switchAgent","bash","vscode_editFile_internal","vscode_fetchWebPage_internal","vscode_searchExtensions_internal"];var au=new Set(ua.map(n=>n.toLowerCase()));function N(n){return n.toLocaleString("en-US")}async function As(n,e,t=!0){let o=await e(t),s=o.last30Days,r={1:"Stage 1: AI Skeptic",2:"Stage 2: AI Explorer",3:"Stage 3: AI Collaborator",4:"Stage 4: AI Strategist"},l=[],u=[],d=1,h=s.modeUsage.ask+s.modeUsage.edit+s.modeUsage.agent;if(h>0&&l.push(`${N(h)} total interactions`),s.modeUsage.ask>0&&l.push(`${N(s.modeUsage.ask)} ask-mode conversations`),s.modeUsage.agent>0&&l.push(`${N(s.modeUsage.agent)} agent-mode interactions`),s.conversationPatterns){let $=s.sessions>0?Math.round(s.conversationPatterns.multiTurnSessions/s.sessions*100):0;s.conversationPatterns.multiTurnSessions>0&&l.push(`${N(s.conversationPatterns.multiTurnSessions)} multi-turn sessions (${$}%)`),s.conversationPatterns.avgTurnsPerSession>=3&&(l.push(`Avg ${s.conversationPatterns.avgTurnsPerSession.toFixed(1)} exchanges per session`),d=Math.max(d,2)),s.conversationPatterns.avgTurnsPerSession>=5&&(d=Math.max(d,3))}h>=5&&(d=2);let p=["explain","fix","tests","doc","generate","optimize","new","newNotebook","search","fixTestFailure","setupTests"].filter($=>(s.toolCalls.byTool[$]||0)>0);p.length>0&&l.push(`Used slash commands: /${p.join(", /")}`);let g=s.modelSwitching.mixedTierSessions>0||s.modelSwitching.switchingFrequency>0,_=s.modeUsage.agent>0;h>=30&&(p.length>=2||_)&&(d=3),h>=100&&_&&(g||p.length>=3)&&(d=4),g&&(l.push(`Switched models in ${Math.round(s.modelSwitching.switchingFrequency)}% of sessions`),d<4&&s.modelSwitching.mixedTierSessions>0&&(d=Math.max(d,3))),d<2&&u.push("Try asking Copilot a question using the Chat panel"),d<3&&(_||u.push("Try [agent mode](https://code.visualstudio.com/docs/copilot/agents/overview) for multi-file changes"),p.length<2&&u.push("Use [slash commands](https://code.visualstudio.com/docs/copilot/chat/copilot-chat#_add-context-to-your-prompts) like /explain, /fix, or /tests to give structured prompts")),d<4&&(_||u.push("Try [agent mode](https://code.visualstudio.com/docs/copilot/agents/overview) for autonomous, multi-step coding tasks"),g||u.push("Experiment with [different models](https://code.visualstudio.com/docs/copilot/chat/copilot-chat#_choose-a-language-model) for different tasks - use fast models for simple queries and reasoning models for complex problems"),p.length<3&&_&&g&&u.push("Explore more [slash commands](https://code.visualstudio.com/docs/copilot/chat/copilot-chat#_add-context-to-your-prompts) like /explain, /tests, or /doc to diversify your prompting"));let w=[],b=[],y=1,S=s.contextReferences.file+s.contextReferences.selection+s.contextReferences.symbol+s.contextReferences.codebase+s.contextReferences.workspace,E=[s.contextReferences.file>0,s.contextReferences.selection>0,s.contextReferences.symbol>0,s.contextReferences.codebase>0,s.contextReferences.workspace>0,s.contextReferences.terminal>0,s.contextReferences.vscode>0,s.contextReferences.clipboard>0,s.contextReferences.changes>0,s.contextReferences.problemsPanel>0,s.contextReferences.outputPanel>0,s.contextReferences.terminalLastCommand>0,s.contextReferences.terminalSelection>0].filter(Boolean).length;s.contextReferences.file>0&&w.push(`${N(s.contextReferences.file)} #file references`),s.contextReferences.selection>0&&w.push(`${N(s.contextReferences.selection)} #selection references`),s.contextReferences.codebase>0&&w.push(`${N(s.contextReferences.codebase)} #codebase references`),s.contextReferences.workspace>0&&w.push(`${N(s.contextReferences.workspace)} @workspace references`),s.contextReferences.terminal>0&&w.push(`${N(s.contextReferences.terminal)} @terminal references`),s.contextReferences.vscode>0&&w.push(`${N(s.contextReferences.vscode)} @vscode references`),s.contextReferences.clipboard>0&&w.push(`${N(s.contextReferences.clipboard)} #clipboard references`),s.contextReferences.changes>0&&w.push(`${N(s.contextReferences.changes)} #changes references`),s.contextReferences.problemsPanel>0&&w.push(`${N(s.contextReferences.problemsPanel)} #problemsPanel references`),s.contextReferences.outputPanel>0&&w.push(`${N(s.contextReferences.outputPanel)} #outputPanel references`),s.contextReferences.terminalLastCommand>0&&w.push(`${N(s.contextReferences.terminalLastCommand)} #terminalLastCommand references`),s.contextReferences.terminalSelection>0&&w.push(`${N(s.contextReferences.terminalSelection)} #terminalSelection references`),S>=1&&(y=2),E>=3&&S>=10&&(y=3),E>=5&&S>=30&&(y=4);let P=s.contextReferences.byKind["copilot.image"]||0;if(P>0&&(w.push(`${N(P)} image references (vision)`),y=Math.max(y,3)),y<2&&b.push("Try adding [#file or #selection](https://code.visualstudio.com/docs/copilot/chat/copilot-chat#_add-context-to-your-prompts) references to give Copilot more context"),y<3&&b.push("Explore [@workspace, #codebase, and @terminal](https://code.visualstudio.com/docs/copilot/chat/copilot-chat#_add-context-to-your-prompts) for broader context"),y<4){let $=Math.max(0,5-E),Ye=Math.max(0,30-S),We=[{name:"image attachments",used:P>0},{name:"#changes",used:s.contextReferences.changes>0},{name:"#problemsPanel",used:s.contextReferences.problemsPanel>0},{name:"#outputPanel",used:s.contextReferences.outputPanel>0},{name:"#terminalLastCommand",used:s.contextReferences.terminalLastCommand>0},{name:"#terminalSelection",used:s.contextReferences.terminalSelection>0},{name:"#clipboard",used:s.contextReferences.clipboard>0},{name:"@vscode",used:s.contextReferences.vscode>0}];if(We.filter(ne=>ne.used).length>=2){let ne=[{name:"#symbol",used:s.contextReferences.symbol>0},{name:"@workspace",used:s.contextReferences.workspace>0},{name:"#codebase",used:s.contextReferences.codebase>0},{name:"@terminal",used:s.contextReferences.terminal>0},...We].filter(je=>!je.used).map(je=>je.name),re=[];if($>0&&re.push(`${N(E)} of 5 different reference types used`),Ye>0&&re.push(`${N(S)} of 30 total references`),re.length>0){let je=ne.slice(0,3),Ps=je.length>0?` \u2014 try ${je.join(", ")}`:"";b.push(`Stage 4 needs ${re.join(" and ")}${Ps}`)}}else{let ne=We.filter(re=>!re.used).map(re=>re.name);if(ne.length>0){let re=ne.slice(0,3),je=ne.length>3?` and ${ne.length-3} more`:"";b.push(`Try ${re.join(", ")}${je} \u2014 see [specialized context variables](https://code.visualstudio.com/docs/copilot/chat/copilot-chat#_add-context-to-your-prompts) to reach Stage 4`)}}}let I=[],O=[],U=1;if(s.modeUsage.agent>0&&(I.push(`${N(s.modeUsage.agent)} agent-mode interactions`),U=2),s.toolCalls.total>0&&I.push(`${N(s.toolCalls.total)} tool calls executed`),s.modeUsage.edit>0&&I.push(`${N(s.modeUsage.edit)} edit-mode interactions`),s.editScope){let $=s.editScope.totalEditedFiles>0?Math.round(s.editScope.multiFileEdits/(s.editScope.singleFileEdits+s.editScope.multiFileEdits)*100):0;s.editScope.multiFileEdits>0&&(I.push(`${N(s.editScope.multiFileEdits)} multi-file edit sessions (${$}%)`),U=Math.max(U,2)),s.editScope.avgFilesPerSession>=3&&(I.push(`Avg ${s.editScope.avgFilesPerSession.toFixed(1)} files per edit session`),U=Math.max(U,3))}s.agentTypes&&s.agentTypes.editsAgent>0&&(I.push(`${N(s.agentTypes.editsAgent)} edits agent sessions`),U=Math.max(U,2));let fe=Object.keys(s.toolCalls.byTool).length,V=Object.keys(s.toolCalls.byTool).filter($=>!au.has($.toLowerCase())).length;s.modeUsage.agent>=10&&V>=3&&(U=3),s.modeUsage.agent>=50&&V>=5&&(U=4),s.editScope&&s.editScope.multiFileEdits>=20&&s.editScope.avgFilesPerSession>=3&&(U=Math.max(U,4)),U<2&&O.push("Try [agent mode](https://code.visualstudio.com/docs/copilot/agents/overview) \u2014 it can run terminal commands, edit files, and explore your codebase autonomously"),U<3&&O.push("Use [agent mode](https://code.visualstudio.com/docs/copilot/agents/overview) for multi-step tasks; let it chain tools like file search, terminal, and code edits"),U<4&&O.push("Tackle complex refactoring or debugging tasks in [agent mode](https://code.visualstudio.com/docs/copilot/agents/overview) for deeper autonomous workflows");let H=[],ke=[],le=1;if(V>0){let $=fe-V,Ye=$>0?` (+ ${N($)} automatic)`:"";H.push(`${N(V)} intentional tools used${Ye}`),le=2}else fe>0&&H.push(`${N(fe)} tools used (all automatic \u2014 agent reads/searches)`);s.agentTypes&&s.agentTypes.workspaceAgent>0&&(H.push(`${N(s.agentTypes.workspaceAgent)} @workspace agent sessions`),le=Math.max(le,3));let ge={github_pull_request:"GitHub Pull Request",github_repo:"GitHub Repository",run_in_terminal:"Run In Terminal",editFiles:"Edit Files",listFiles:"List Files"},Pe=Object.keys(ge).filter($=>(s.toolCalls.byTool[$]||0)>0);Pe.length>0&&(H.push(`Advanced tools: ${Pe.map($=>ge[$]).join(", ")}`),Pe.length>=2&&(le=Math.max(le,3)));let be=Object.keys(s.mcpTools.byServer);s.mcpTools.total>0&&(H.push(`${N(s.mcpTools.total)} MCP tool calls across ${be.length} server(s)`),le=Math.max(le,3),be.length>=2&&(le=4)),le<2&&ke.push("Try [agent mode](https://code.visualstudio.com/docs/copilot/agents/overview) to let Copilot use built-in tools for file operations and terminal commands"),le<3&&(be.length===0?ke.push("Set up [MCP servers](https://code.visualstudio.com/docs/copilot/customization/mcp-servers) to connect Copilot to external tools (databases, APIs, cloud services)"):ke.push("Explore [GitHub integrations](https://code.visualstudio.com/docs/copilot/agents/agent-tools) and advanced tools like editFiles and run_in_terminal")),le<4&&(be.length===1?ke.push("Add more [MCP servers](https://code.visualstudio.com/docs/copilot/customization/mcp-servers) to expand Copilot's capabilities - check the VS Code MCP registry"):be.length===0?ke.push("Explore the [VS Code MCP registry](https://code.visualstudio.com/docs/copilot/customization/mcp-servers) for tools that integrate with your workflow"):ke.push("You're using multiple MCP servers - keep exploring advanced tool combinations"));let Ge=[],ze=[],ue=1,oo=n,me=oo?.totalWorkspaces??0,Ce=me-(oo?.workspacesWithIssues??0),so=me>0?Ce/me:0;me>0&&Ge.push(`Worked in ${me} repositor${me===1?"y":"ies"}`),Ce>0&&(ue=2),so>=.3&&Ce>=2&&(ue=3),so>=.7&&Ce>=3&&(ue=4);let gt=[...new Set([...s.modelSwitching.standardModels,...s.modelSwitching.premiumModels])];if(gt.length>=3){let $=gt.length>=5&&Ce>=3;Ge.push(`Used ${gt.length} different models`),$?ue=4:(gt.length>=5,ue=Math.max(ue,3))}if(ue>=4?Ge.push(`${N(Ce)} of ${N(me)} repos customized (70%+ with 3+ repos \u2192 Stage 4)`):ue>=3?Ge.push(`${N(Ce)} of ${N(me)} repos customized (30%+ with 2+ repos \u2192 Stage 3)`):Ce>0&&Ge.push(`${N(Ce)} of ${N(me)} repos with custom instructions or agents.md`),ue<2&&ze.push("Create a [.github/copilot-instructions.md](https://code.visualstudio.com/docs/copilot/customization/custom-instructions) file with project-specific guidelines"),ue<3&&ze.push("Add [custom instructions](https://code.visualstudio.com/docs/copilot/customization/custom-instructions) to more repositories to standardize your Copilot experience"),ue<4){let $=me-Ce;me>0&&$>0?ze.push(`${N(Ce)} of ${N(me)} repos have customization \u2014 add [instructions and agents.md](https://code.visualstudio.com/docs/copilot/customization/custom-instructions) to the remaining ${N($)} repo${$===1?"":"s"} for Stage 4`):ze.push("Aim for consistent customization across all projects with [instructions and agents.md](https://code.visualstudio.com/docs/copilot/customization/custom-instructions)")}if(ue>=4){let $=me-Ce;if($>0){let We=(oo?.workspaces||[]).filter(ne=>Object.values(ne.typeStatuses).every(re=>re==="\u274C")).filter(ne=>!ne.workspacePath.startsWith("<unresolved:")).sort((ne,re)=>re.interactionCount!==ne.interactionCount?re.interactionCount-ne.interactionCount:re.sessionCount-ne.sessionCount).slice(0,3),Ut=`${N($)} repo${$===1?"":"s"} still missing customization \u2014 add [instructions](https://code.visualstudio.com/docs/copilot/customization/custom-instructions), [agents.md](https://code.visualstudio.com/docs/copilot/customization/custom-instructions), or [MCP configs](https://code.visualstudio.com/docs/copilot/customization/mcp-servers) for full coverage.`;if(We.length>0){let ne=We.map(re=>`${re.workspaceName} (${N(re.interactionCount)} interaction${re.interactionCount===1?"":"s"})`).join(`
|
|
58
|
-
`);
|
|
61
|
+
`)),process.stdout.write(T.dim("Scanning for session files..."));let r=await _e();if(process.stdout.write("\r"+" ".repeat(50)+"\r"),r.length===0){console.log(T.yellow("\u26A0\uFE0F No session files found."));return}process.stdout.write(T.dim("Calculating usage..."));let e=await rs(r,(o,n)=>{process.stdout.write(`\r${T.dim(`Processing: ${o}/${n} files`)}`)});process.stdout.write("\r"+" ".repeat(50)+"\r");let t=[{label:"Today",emoji:"\u{1F4C5}",stats:e.today},{label:"This Month",emoji:"\u{1F4C6}",stats:e.month},{label:"Last Month",emoji:"\u{1F5D3}\uFE0F",stats:e.lastMonth},{label:"Last 30 Days",emoji:"\u{1F4C8}",stats:e.last30Days}];console.log(T.dim("Methodology: Estimates based on industry averages for AI inference")),console.log(T.dim(` CO\u2082: ${Pt.CO2_PER_1K_TOKENS} gCO\u2082e per 1K tokens`)),console.log(T.dim(` Water: ${Pt.WATER_USAGE_PER_1K_TOKENS} L per 1K tokens`)),console.log(T.dim(` Tree absorption: ${La(Pt.CO2_ABSORPTION_PER_TREE_PER_YEAR)} CO\u2082/year
|
|
62
|
+
`));for(let o of t)Xu(o.label,o.emoji,o.stats);let s=e.last30Days;if(s.tokens>0){console.log(T.bold("\u{1F504} Context Comparisons (Last 30 Days)")),console.log(T.dim("\u2500".repeat(55)));let o=s.co2,n=s.waterUsage,a=o/Pt.CO2_PER_KM_DRIVING;console.log(` \u{1F697} Equivalent to driving: ${a.toFixed(3)} km`);let d=o/Pt.CO2_PER_PHONE_CHARGE;console.log(` \u{1F4F1} Smartphone charges: ${d.toFixed(1)}`);let c=n/Pt.WATER_PER_COFFEE_CUP;console.log(` \u2615 Cups of coffee (water): ${c.toFixed(4)}`);let h=o/Pt.CO2_PER_LED_HOUR;console.log(` \u{1F4A1} LED bulb hours: ${h.toFixed(2)}`),console.log()}console.log(T.dim(`Last updated: ${e.lastUpdated.toLocaleString()}
|
|
63
|
+
`))});function La(r){return r>=1e3?`${(r/1e3).toFixed(2)} kgCO\u2082e`:`${r.toFixed(3)} gCO\u2082e`}function Xu(r,e,t){if(console.log(T.bold(`${e} ${r}`)),console.log(T.dim("\u2500".repeat(55))),t.sessions===0){console.log(T.dim(" No activity in this period")),console.log();return}if(console.log(` Tokens used: ${T.bold.yellow(me(t.tokens))}`),console.log(` CO\u2082 emissions: ${T.bold(La(t.co2))}`),console.log(` Water usage: ${T.bold(t.waterUsage.toFixed(3))} liters`),t.treesEquivalent>0){let s=t.treesEquivalent<.001?t.treesEquivalent.toExponential(2):t.treesEquivalent.toFixed(6);console.log(` Trees to offset: ${T.green(s)} trees/year`)}console.log()}var qa=["read_file","copilot_readFile","read","view","view_image","copilot_viewImage","list_dir","ls","copilot_listDirectory","find_files","file_search","file_glob_search","copilot_findFiles","opilot_findFiles","copilot_findTextInFiles","copilot_findTestFiles","test_search","grep_search","grep","glob","semantic_search","copilot_searchCodebase","code_search","copilot_getSearchResults","get_search_view_results","search_workspace_symbols","copilot_searchWorkspaceSymbols","vscode_listCodeUsages","get_symbols_by_name","get_errors","copilot_getErrors","get_changed_files","copilot_getChangedFiles","read_project_structure","copilot_readProjectStructure","get_doc_info","copilot_getDocInfo","get_vscode_api","copilot_getVSCodeAPI","get_project_setup_info","copilot_getProjectSetupInfo","get_files_in_project","get_projects_in_solution","get_python_executable_details","get_currentfile","get_file","vscode_get_confirmation","vscode_get_confirmation_with_options","vscode_get_terminal_confirmation","vscode_get_modified_files_confirmation","memory","copilot_memory","detect_memories","todo","tool_replay","copilot_toolReplay","tool_search","get_task_output","get_output_window_logs","job_output","get_terminal_output","await_terminal","terminal_selection","terminal_last_command","read_notebook_cell_output","copilot_readNotebookCellOutput","copilot_getNotebookSummary","test_failure","copilot_testFailure","ask_questions","AskUserQuestion","copilot_askQuestions","switch_agent","copilot_switchAgent","bash","vscode_editFile_internal","vscode_fetchWebPage_internal","vscode_searchExtensions_internal"];var ed=new Set(qa.map(r=>r.toLowerCase()));function j(r){return r.toLocaleString("en-US")}async function Ho(r,e,t=!0){let s=await e(t),o=s.last30Days,n={1:"Stage 1: AI Skeptic",2:"Stage 2: AI Explorer",3:"Stage 3: AI Collaborator",4:"Stage 4: AI Strategist"},a=[],d=[],c=1,h=o.modeUsage.ask+o.modeUsage.edit+o.modeUsage.agent+o.modeUsage.cli;if(h>0&&a.push(`${j(h)} total interactions`),o.modeUsage.ask>0&&a.push(`${j(o.modeUsage.ask)} ask-mode conversations`),o.modeUsage.agent>0&&a.push(`${j(o.modeUsage.agent)} agent-mode interactions`),o.modeUsage.cli>0&&a.push(`${j(o.modeUsage.cli)} CLI interactions`),o.conversationPatterns){let G=o.sessions>0?Math.round(o.conversationPatterns.multiTurnSessions/o.sessions*100):0;o.conversationPatterns.multiTurnSessions>0&&a.push(`${j(o.conversationPatterns.multiTurnSessions)} multi-turn sessions (${G}%)`),o.conversationPatterns.avgTurnsPerSession>=3&&(a.push(`Avg ${o.conversationPatterns.avgTurnsPerSession.toFixed(1)} exchanges per session`),c=Math.max(c,2)),o.conversationPatterns.avgTurnsPerSession>=5&&(c=Math.max(c,3))}h>=5&&(c=2);let m=["explain","fix","tests","doc","generate","optimize","new","newNotebook","search","fixTestFailure","setupTests"],p=["review","bug","think","compact","pr_comments"],g=[...m.filter(G=>(o.toolCalls.byTool[G]||0)>0),...p.filter(G=>(o.toolCalls.byTool[`__slash__${G}`]||0)>0)];g.length>0&&a.push(`Used slash commands: /${g.join(", /")}`);let w=o.modelSwitching.mixedTierSessions>0||o.modelSwitching.switchingFrequency>0,k=o.modeUsage.agent>0||o.modeUsage.cli>0;h>=30&&(g.length>=2||k)&&(c=3),h>=100&&k&&(w||g.length>=3)&&(c=4),w&&(a.push(`Switched models in ${Math.round(o.modelSwitching.switchingFrequency)}% of sessions`),c<4&&o.modelSwitching.mixedTierSessions>0&&(c=Math.max(c,3))),c<2&&d.push("Try asking Copilot a question using the Chat panel"),c<3&&(k||d.push("Try [agent mode](https://code.visualstudio.com/docs/copilot/agents/overview) for multi-file changes"),g.length<2&&d.push("Use [slash commands](https://code.visualstudio.com/docs/copilot/chat/copilot-chat#_add-context-to-your-prompts) like /explain, /fix, or /tests to give structured prompts")),c<4&&(k||d.push("Try [agent mode](https://code.visualstudio.com/docs/copilot/agents/overview) for autonomous, multi-step coding tasks"),w||d.push("Experiment with [different models](https://code.visualstudio.com/docs/copilot/chat/copilot-chat#_choose-a-language-model) for different tasks - use fast models for simple queries and reasoning models for complex problems"),g.length<3&&k&&w&&d.push("Explore more [slash commands](https://code.visualstudio.com/docs/copilot/chat/copilot-chat#_add-context-to-your-prompts) like /explain, /tests, or /doc to diversify your prompting"));let b=[],y=[],v=1,C=o.contextReferences.file+o.contextReferences.selection+o.contextReferences.symbol+o.contextReferences.codebase+o.contextReferences.workspace,M=[o.contextReferences.file>0,o.contextReferences.selection>0,o.contextReferences.symbol>0,o.contextReferences.codebase>0,o.contextReferences.workspace>0,o.contextReferences.terminal>0,o.contextReferences.vscode>0,o.contextReferences.clipboard>0,o.contextReferences.changes>0,o.contextReferences.problemsPanel>0,o.contextReferences.outputPanel>0,o.contextReferences.terminalLastCommand>0,o.contextReferences.terminalSelection>0].filter(Boolean).length;o.contextReferences.file>0&&b.push(`${j(o.contextReferences.file)} #file references`),o.contextReferences.selection>0&&b.push(`${j(o.contextReferences.selection)} #selection references`),o.contextReferences.codebase>0&&b.push(`${j(o.contextReferences.codebase)} #codebase references`),o.contextReferences.workspace>0&&b.push(`${j(o.contextReferences.workspace)} @workspace references`),o.contextReferences.terminal>0&&b.push(`${j(o.contextReferences.terminal)} @terminal references`),o.contextReferences.vscode>0&&b.push(`${j(o.contextReferences.vscode)} @vscode references`),o.contextReferences.clipboard>0&&b.push(`${j(o.contextReferences.clipboard)} #clipboard references`),o.contextReferences.changes>0&&b.push(`${j(o.contextReferences.changes)} #changes references`),o.contextReferences.problemsPanel>0&&b.push(`${j(o.contextReferences.problemsPanel)} #problemsPanel references`),o.contextReferences.outputPanel>0&&b.push(`${j(o.contextReferences.outputPanel)} #outputPanel references`),o.contextReferences.terminalLastCommand>0&&b.push(`${j(o.contextReferences.terminalLastCommand)} #terminalLastCommand references`),o.contextReferences.terminalSelection>0&&b.push(`${j(o.contextReferences.terminalSelection)} #terminalSelection references`),C>=1&&(v=2),M>=3&&C>=10&&(v=3),M>=5&&C>=30&&(v=4);let F=o.contextReferences.byKind["copilot.image"]||0;if(F>0&&(b.push(`${j(F)} image references (vision)`),v=Math.max(v,3)),v<2&&y.push("Try adding [#file or #selection](https://code.visualstudio.com/docs/copilot/chat/copilot-chat#_add-context-to-your-prompts) references to give Copilot more context"),v<3&&y.push("Explore [@workspace, #codebase, and @terminal](https://code.visualstudio.com/docs/copilot/chat/copilot-chat#_add-context-to-your-prompts) for broader context"),v<4){let G=Math.max(0,5-M),He=Math.max(0,30-C),ot=[{name:"image attachments",used:F>0},{name:"#changes",used:o.contextReferences.changes>0},{name:"#problemsPanel",used:o.contextReferences.problemsPanel>0},{name:"#outputPanel",used:o.contextReferences.outputPanel>0},{name:"#terminalLastCommand",used:o.contextReferences.terminalLastCommand>0},{name:"#terminalSelection",used:o.contextReferences.terminalSelection>0},{name:"#clipboard",used:o.contextReferences.clipboard>0},{name:"@vscode",used:o.contextReferences.vscode>0}];if(ot.filter(ue=>ue.used).length>=2){let ue=[{name:"#symbol",used:o.contextReferences.symbol>0},{name:"@workspace",used:o.contextReferences.workspace>0},{name:"#codebase",used:o.contextReferences.codebase>0},{name:"@terminal",used:o.contextReferences.terminal>0},...ot].filter(Je=>!Je.used).map(Je=>Je.name),le=[];if(G>0&&le.push(`${j(M)} of 5 different reference types used`),He>0&&le.push(`${j(C)} of 30 total references`),le.length>0){let Je=ue.slice(0,3),At=Je.length>0?` \u2014 try ${Je.join(", ")}`:"";y.push(`Stage 4 needs ${le.join(" and ")}${At}`)}}else{let ue=ot.filter(le=>!le.used).map(le=>le.name);if(ue.length>0){let le=ue.slice(0,3),Je=ue.length>3?` and ${ue.length-3} more`:"";y.push(`Try ${le.join(", ")}${Je} \u2014 see [specialized context variables](https://code.visualstudio.com/docs/copilot/chat/copilot-chat#_add-context-to-your-prompts) to reach Stage 4`)}}}let D=[],N=[],H=1;if(o.modeUsage.agent>0&&(D.push(`${j(o.modeUsage.agent)} agent-mode interactions`),H=2),o.modeUsage.cli>0&&(D.push(`${j(o.modeUsage.cli)} CLI interactions`),H=Math.max(H,2)),o.toolCalls.total>0&&D.push(`${j(o.toolCalls.total)} tool calls executed`),o.modeUsage.edit>0&&D.push(`${j(o.modeUsage.edit)} edit-mode interactions`),o.editScope){let G=o.editScope.totalEditedFiles>0?Math.round(o.editScope.multiFileEdits/(o.editScope.singleFileEdits+o.editScope.multiFileEdits)*100):0;o.editScope.multiFileEdits>0&&(D.push(`${j(o.editScope.multiFileEdits)} multi-file edit sessions (${G}%)`),H=Math.max(H,2)),o.editScope.avgFilesPerSession>=3&&(D.push(`Avg ${o.editScope.avgFilesPerSession.toFixed(1)} files per edit session`),H=Math.max(H,3))}o.agentTypes&&o.agentTypes.editsAgent>0&&(D.push(`${j(o.agentTypes.editsAgent)} edits agent sessions`),H=Math.max(H,2));let K=Object.keys(o.toolCalls.byTool).length,W=Object.keys(o.toolCalls.byTool).filter(G=>!ed.has(G.toLowerCase())&&!G.startsWith("__slash__")).length;o.modeUsage.agent+o.modeUsage.cli>=10&&W>=3&&(H=3),o.modeUsage.agent+o.modeUsage.cli>=50&&W>=5&&(H=4),o.editScope&&o.editScope.multiFileEdits>=20&&o.editScope.avgFilesPerSession>=3&&(H=Math.max(H,4)),H<2&&N.push("Try [agent mode](https://code.visualstudio.com/docs/copilot/agents/overview) \u2014 it can run terminal commands, edit files, and explore your codebase autonomously"),H<3&&N.push("Use [agent mode](https://code.visualstudio.com/docs/copilot/agents/overview) for multi-step tasks; let it chain tools like file search, terminal, and code edits"),H<4&&N.push("Tackle complex refactoring or debugging tasks in [agent mode](https://code.visualstudio.com/docs/copilot/agents/overview) for deeper autonomous workflows");let Me=[],ve=[],Z=1;if(W>0){let G=K-W,He=G>0?` (+ ${j(G)} automatic)`:"";Me.push(`${j(W)} intentional tools used${He}`),Z=2}else K>0&&Me.push(`${j(K)} tools used (all automatic \u2014 agent reads/searches)`);o.agentTypes&&o.agentTypes.workspaceAgent>0&&(Me.push(`${j(o.agentTypes.workspaceAgent)} @workspace agent sessions`),Z=Math.max(Z,3));let Ue={github_pull_request:"GitHub Pull Request",github_repo:"GitHub Repository",run_in_terminal:"Run In Terminal",editFiles:"Edit Files",listFiles:"List Files"},Ae=Object.keys(Ue).filter(G=>(o.toolCalls.byTool[G]||0)>0);Ae.length>0&&(Me.push(`Advanced tools: ${Ae.map(G=>Ue[G]).join(", ")}`),Ae.length>=2&&(Z=Math.max(Z,3)));let tt=Object.keys(o.mcpTools.byServer);o.mcpTools.total>0&&(Me.push(`${j(o.mcpTools.total)} MCP tool calls across ${tt.length} server(s)`),Z=Math.max(Z,3),tt.length>=2&&(Z=4)),Z<2&&ve.push("Try [agent mode](https://code.visualstudio.com/docs/copilot/agents/overview) to let Copilot use built-in tools for file operations and terminal commands"),Z<3&&(tt.length===0?ve.push("Set up [MCP servers](https://code.visualstudio.com/docs/copilot/customization/mcp-servers) to connect Copilot to external tools (databases, APIs, cloud services)"):ve.push("Explore [GitHub integrations](https://code.visualstudio.com/docs/copilot/agents/agent-tools) and advanced tools like editFiles and run_in_terminal")),Z<4&&(tt.length===1?ve.push("Add more [MCP servers](https://code.visualstudio.com/docs/copilot/customization/mcp-servers) to expand Copilot's capabilities - check the VS Code MCP registry"):tt.length===0?ve.push("Explore the [VS Code MCP registry](https://code.visualstudio.com/docs/copilot/customization/mcp-servers) for tools that integrate with your workflow"):ve.push("You're using multiple MCP servers - keep exploring advanced tool combinations"));let ft=[],Ve=[],de=1,Mt=r,fe=Mt?.totalWorkspaces??0,be=fe-(Mt?.workspacesWithIssues??0),ls=fe>0?be/fe:0;fe>0&&ft.push(`Worked in ${fe} repositor${fe===1?"y":"ies"}`),be>0&&(de=2),ls>=.3&&be>=2&&(de=3),ls>=.7&&be>=3&&(de=4);let zt=[...new Set([...o.modelSwitching.standardModels,...o.modelSwitching.premiumModels])];if(zt.length>=3){let G=zt.length>=5&&be>=3;ft.push(`Used ${zt.length} different models`),G?de=4:(zt.length>=5,de=Math.max(de,3))}if(de>=4?ft.push(`${j(be)} of ${j(fe)} repos customized (70%+ with 3+ repos \u2192 Stage 4)`):de>=3?ft.push(`${j(be)} of ${j(fe)} repos customized (30%+ with 2+ repos \u2192 Stage 3)`):be>0&&ft.push(`${j(be)} of ${j(fe)} repos with custom instructions or agents.md`),de<2&&Ve.push("Create a [.github/copilot-instructions.md](https://code.visualstudio.com/docs/copilot/customization/custom-instructions) or [CLAUDE.md](https://docs.anthropic.com/en/docs/claude-code/memory) file with project-specific guidelines"),de<3&&Ve.push("Add [custom instructions](https://code.visualstudio.com/docs/copilot/customization/custom-instructions) to more repositories to standardize your Copilot experience"),de<4){let G=fe-be;fe>0&&G>0?Ve.push(`${j(be)} of ${j(fe)} repos have customization \u2014 add [instructions and agents.md](https://code.visualstudio.com/docs/copilot/customization/custom-instructions) to the remaining ${j(G)} repo${G===1?"":"s"} for Stage 4`):Ve.push("Aim for consistent customization across all projects with [instructions and agents.md](https://code.visualstudio.com/docs/copilot/customization/custom-instructions)")}if(de>=4){let G=fe-be;if(G>0){let ot=(Mt?.workspaces||[]).filter(ue=>Object.values(ue.typeStatuses).every(le=>le==="\u274C")).filter(ue=>!ue.workspacePath.startsWith("<unresolved:")).sort((ue,le)=>le.interactionCount!==ue.interactionCount?le.interactionCount-ue.interactionCount:le.sessionCount-ue.sessionCount).slice(0,3),yt=`${j(G)} repo${G===1?"":"s"} still missing customization \u2014 add [instructions](https://code.visualstudio.com/docs/copilot/customization/custom-instructions), [agents.md](https://code.visualstudio.com/docs/copilot/customization/custom-instructions), or [MCP configs](https://code.visualstudio.com/docs/copilot/customization/mcp-servers) for full coverage.`;if(ot.length>0){let ue=ot.map(le=>`${le.workspaceName} (${j(le.interactionCount)} interaction${le.interactionCount===1?"":"s"})`).join(`
|
|
64
|
+
`);Ve.push(`${yt}
|
|
59
65
|
|
|
60
66
|
Top repos to customize first:
|
|
61
|
-
${
|
|
67
|
+
${ue}`)}else Ve.push(yt)}else Ve.push("All repos customized! Keep instructions up to date and add [skill files](https://code.visualstudio.com/docs/copilot/customization/agent-skills) or [MCP server configs](https://code.visualstudio.com/docs/copilot/customization/mcp-servers) for deeper integration")}let Ce=[],Re=[],ae=1;if(o.sessions>=3&&(Ce.push(`${j(o.sessions)} sessions in the last 30 days`),ae=2),o.applyUsage&&o.applyUsage.totalCodeBlocks>0){let G=Math.round(o.applyUsage.applyRate);Ce.push(`${G}% code block apply rate (${j(o.applyUsage.totalApplies)}/${j(o.applyUsage.totalCodeBlocks)})`),G>=50&&(ae=Math.max(ae,2))}if(o.sessionDuration&&o.sessionDuration.avgDurationMs>0){let G=Math.round(o.sessionDuration.avgDurationMs/6e4);Ce.push(`Avg ${G}min session duration`)}let st=[o.modeUsage.ask>0,o.modeUsage.agent>0,o.modeUsage.cli>0].filter(Boolean).length;st>=2&&(Ce.push(`Uses ${st} modes (ask/agent/cli)`),ae=Math.max(ae,3)),C>=10&&(Ce.push(`${j(C)} explicit context references`),C>=20&&(ae=Math.max(ae,3))),o.sessions>=15&&st>=2&&C>=20&&(ae=4,Ce.push("Deep integration: regular usage with multi-mode and explicit context")),ae<2&&Re.push("Use AI more regularly - even for quick questions"),ae<3&&(st<2&&Re.push("Combine [ask mode with agent mode](https://code.visualstudio.com/docs/copilot/agents/overview) in your daily workflow"),C<10&&Re.push("Use explicit [context references](https://code.visualstudio.com/docs/copilot/chat/copilot-chat#_add-context-to-your-prompts) like #file, @workspace, and #selection")),ae<4&&(C<20&&Re.push("Make explicit context a habit - use [#file, @workspace, and other references](https://code.visualstudio.com/docs/copilot/chat/copilot-chat#_add-context-to-your-prompts) consistently"),Re.push("Make AI part of every coding task: planning, coding, testing, and reviewing"));let gt=[c,v,H,Z,de,ae].sort((G,He)=>G-He),Vt=Math.floor(gt.length/2),ne=gt.length%2===0?Math.round((gt[Vt-1]+gt[Vt])/2):gt[Vt];return{overallStage:ne,overallLabel:n[ne]||`Stage ${ne}`,categories:[{category:"Prompt Engineering",icon:"\u{1F4AC}",stage:c,evidence:a,tips:d},{category:"Context Engineering",icon:"\u{1F4CE}",stage:v,evidence:b,tips:y},{category:"Agentic",icon:"\u{1F916}",stage:H,evidence:D,tips:N},{category:"Tool Usage",icon:"\u{1F527}",stage:Z,evidence:Me,tips:ve},{category:"Customization",icon:"\u2699\uFE0F",stage:de,evidence:ft,tips:Ve},{category:"Workflow Integration",icon:"\u{1F504}",stage:ae,evidence:Ce,tips:Re}],period:o,lastUpdated:s.lastUpdated.toISOString()}}var Ga=new pe("fluency").description("Show your Copilot Fluency Score and improvement tips").option("-t, --tips","Show improvement tips for each category").option("--json","Output raw JSON (for machine consumption)").action(async r=>{r.json||console.log(T.bold.cyan(`
|
|
62
68
|
\u{1F3AF} Copilot Token Tracker - Fluency Score
|
|
63
|
-
`)),
|
|
64
|
-
`))});function
|
|
69
|
+
`)),r.json||process.stdout.write(T.dim("Scanning for session files..."));let e=await _e();if(r.json||process.stdout.write("\r"+" ".repeat(50)+"\r"),e.length===0){r.json?process.stdout.write("{}"):console.log(T.yellow("\u26A0\uFE0F No session files found."));return}r.json||process.stdout.write(T.dim("Analyzing usage patterns..."));let t=await as(e);r.json||process.stdout.write("\r"+" ".repeat(50)+"\r");let s=await Bo(e),o=await Ho(s,async()=>t,!1);if(r.json){let p={overallStage:o.overallStage,overallLabel:o.overallLabel,categories:o.categories,period:o.period,lastUpdated:o.lastUpdated,backendConfigured:!1};process.stdout.write(JSON.stringify(p));return}let n={1:T.red,2:T.yellow,3:T.blue,4:T.green},a=p=>{let g="\u2588".repeat(p),w="\u2591".repeat(4-p);return g+w};console.log(T.bold("Overall Fluency Score")),console.log(T.dim("\u2500".repeat(55)));let d=n[o.overallStage]||T.white;console.log(` ${d(a(o.overallStage))} ${T.bold(o.overallLabel)}`),console.log(),console.log(T.bold("Category Breakdown")),console.log(T.dim("\u2500".repeat(55)));for(let p of o.categories){let g=n[p.stage]||T.white;if(console.log(` ${p.icon} ${T.bold(p.category)}`),console.log(` ${g(a(p.stage))} Stage ${p.stage}/4`),p.evidence.length>0){let w=p.evidence.slice(0,3);for(let k of w)console.log(T.dim(` \u2713 ${k}`));p.evidence.length>3&&console.log(T.dim(` ... and ${p.evidence.length-3} more`))}if(p.tips.length>0&&p.stage<4){console.log(T.yellow(" \u{1F4A1} Tips:"));for(let w of p.tips.slice(0,2)){let k=w.replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/\[▶ [^\]]+\]\([^)]+\)/g,"").trim();console.log(T.yellow(` \u2192 ${k}`))}}console.log()}let c=o.period;console.log(T.bold("\u{1F4CA} Analysis Period (Last 30 Days)")),console.log(T.dim("\u2500".repeat(55))),console.log(` Sessions analyzed: ${T.bold(X(c.sessions))}`);let h=c.modeUsage.ask+c.modeUsage.edit+c.modeUsage.agent+c.modeUsage.cli;console.log(` Total interactions: ${T.bold(X(h))}`),c.modeUsage.ask>0&&console.log(` Ask mode: ${X(c.modeUsage.ask)}`),c.modeUsage.edit>0&&console.log(` Edit mode: ${X(c.modeUsage.edit)}`),c.modeUsage.agent>0&&console.log(` Agent mode: ${X(c.modeUsage.agent)}`),c.modeUsage.cli>0&&console.log(` CLI: ${X(c.modeUsage.cli)}`),c.toolCalls.total>0&&console.log(` Tool calls: ${X(c.toolCalls.total)}`),c.mcpTools.total>0&&console.log(` MCP tool calls: ${X(c.mcpTools.total)}`);let m=c.contextReferences.file+c.contextReferences.selection+c.contextReferences.codebase+c.contextReferences.workspace+c.contextReferences.terminal+c.contextReferences.vscode;m>0&&console.log(` Context references: ${X(m)}`),console.log(),console.log(T.dim(`Last updated: ${o.lastUpdated}
|
|
70
|
+
`))});function td(r,e){let t=r.replace(/\\/g,"/"),s=t.includes("opencode.db#")?t.split("#")[0]:t,o=null,n=0;for(let a of e){let d=a.path.replace(/\\/g,"/");s.startsWith(d)&&d.length>n&&(o={path:a.path,source:a.source},n=d.length)}return o}function Ci(r,e=55){if(r.length<=e)return r;let t=r.replace(/\\/g,"/").split("/"),s=r;for(let o=t.length-1;o>1&&(s="\u2026/"+t.slice(-o).join("/"),!(s.length<=e));o--);return s}function Ba(r,e,t){let s=T.dim("\u2500".repeat(t.reduce((n,a)=>n+a+3,-1))),o=r.map((n,a)=>T.bold(n.padEnd(t[a]))).join(" \u2502 ");console.log(" "+o),console.log(" "+s);for(let n of e){let a=n.map((d,c)=>{let h=d.padEnd(t[c]);return c===0?T.dim(h):h}).join(T.dim(" \u2502 "));console.log(" "+a)}console.log(" "+s)}var za=new pe("diagnostics").description("Show session file search locations and per-location usage stats").action(async()=>{console.log(T.bold.cyan(`
|
|
65
71
|
\u{1F52C} Copilot Token Tracker - Diagnostics
|
|
66
|
-
`));let
|
|
67
|
-
`);return}let e=await _e();if(e.length===0){process.stdout.write(JSON.stringify({labels:[],tokensData:[],sessionsData:[],modelDatasets:[],editorDatasets:[],editorTotalsMap:{},repositoryDatasets:[],repositoryTotalsMap:{},dailyCount:0,totalTokens:0,avgTokensPerDay:0,totalSessions:0,lastUpdated:new Date().toISOString(),backendConfigured:!1}));return}let{labels:t,days:
|
|
68
|
-
`);return}let e=await _e(),t=new Date;if(e.length===0){process.stdout.write(JSON.stringify({today:{},last30Days:{},month:{},locale:Intl.DateTimeFormat().resolvedOptions().locale,lastUpdated:t.toISOString(),backendConfigured:!1}));return}let
|
|
69
|
-
`);return}let e=new Date,t=await _e();if(t.length===0){let
|
|
72
|
+
`));let r=zo(),e=r.filter(y=>y.exists),t=r.filter(y=>!y.exists);console.log(T.bold(`\u{1F4C2} Search Locations (${e.length} found / ${r.length} total)`)),console.log(T.dim("\u2500".repeat(65)));let s=["Source","Exists","Path"],o=[18,6,55],n=r.map(y=>[y.source,y.exists?T.green("yes"):T.dim("no"),Ci(y.path,55)]);if(Ba(s,n,o),console.log(),e.length===0){console.log(T.yellow("\u26A0\uFE0F No search paths exist on this machine.")),console.log(T.dim("Have you used GitHub Copilot Chat in VS Code yet?"));return}process.stdout.write(T.dim("Scanning for session files..."));let a=await _e();if(process.stdout.write("\r"+" ".repeat(60)+"\r"),a.length===0){console.log(T.yellow("\u26A0\uFE0F No session files found in any search path."));return}let d=new Map;for(let y of e)d.set(y.path,{label:Ci(y.path,45),source:y.source,files:0,sessions:0,interactions:0,tokens:0});let c=0,h=0,m=0,p=0;for(let y=0;y<a.length;y++){((y+1)%25===0||y===a.length-1)&&process.stdout.write(`\r${T.dim(`Processing: ${y+1}/${a.length} files...`)}`);let v=td(a[y],r),C=v?v.path:"__unknown__";d.has(C)||d.set(C,{label:v?Ci(v.path,45):"(unknown)",source:v?v.source:"unknown",files:0,sessions:0,interactions:0,tokens:0});let P=d.get(C);P.files++,c++;let M=await is(a[y]);M&&M.tokens>0&&(P.sessions++,P.interactions+=M.interactions,P.tokens+=M.tokens,h++,m+=M.interactions,p+=M.tokens)}process.stdout.write("\r"+" ".repeat(60)+"\r"),console.log(T.bold("\u{1F4CA} Stats per Search Location")),console.log(T.dim("\u2500".repeat(65)));let g=["Source","Files","Sessions","Turns","Tokens"],w=[18,6,9,8,14],k=[],b=[...d.values()].filter(y=>y.files>0).sort((y,v)=>v.tokens-y.tokens||y.source.localeCompare(v.source));for(let y of b)k.push([y.source,X(y.files),X(y.sessions),X(y.interactions),me(y.tokens)]);k.length===0?console.log(T.dim(" No session data found in any location.")):Ba(g,k,w),console.log(),console.log(T.bold("\u{1F4C8} Totals (all time)")),console.log(T.dim("\u2500".repeat(65))),console.log(` Total files found: ${T.bold(X(c))}`),console.log(` Files with data: ${T.bold(X(h))}`),console.log(` Total chat turns: ${T.bold(X(m))}`),console.log(` Total tokens (est.): ${T.bold.yellow(me(p))}`),t.length>0&&(console.log(),console.log(T.dim(`\u2139\uFE0F ${t.length} search path(s) not present on this machine \u2014 this is normal if you don't use all VS Code variants.`))),console.log()});var Wa=new pe("chart").description("Output daily token usage data for the chart webview").option("--json","Output raw JSON (for machine consumption)").action(async r=>{if(!r.json){process.stderr.write(`Use --json flag for chart data output
|
|
73
|
+
`);return}let e=await _e();if(e.length===0){process.stdout.write(JSON.stringify({labels:[],tokensData:[],sessionsData:[],modelDatasets:[],editorDatasets:[],editorTotalsMap:{},repositoryDatasets:[],repositoryTotalsMap:{},dailyCount:0,totalTokens:0,avgTokensPerDay:0,totalSessions:0,lastUpdated:new Date().toISOString(),backendConfigured:!1}));return}let{labels:t,days:s}=await Wo(e),o=Vo(t,s);process.stdout.write(JSON.stringify(o))});var Va=new pe("usage-analysis").description("Output usage analysis stats for the usage analysis webview").option("--json","Output raw JSON (for machine consumption)").action(async r=>{if(!r.json){process.stderr.write(`Use --json flag for usage analysis data output
|
|
74
|
+
`);return}let e=await _e(),t=new Date;if(e.length===0){process.stdout.write(JSON.stringify({today:{},last30Days:{},month:{},locale:Intl.DateTimeFormat().resolvedOptions().locale,lastUpdated:t.toISOString(),backendConfigured:!1}));return}let o={...await as(e),locale:Intl.DateTimeFormat().resolvedOptions().locale,lastUpdated:t.toISOString(),backendConfigured:!1};process.stdout.write(JSON.stringify(o))});var Ha=new pe("all").description("Output all view data in a single JSON response (for Visual Studio extension)").option("--json","Output raw JSON (required)").action(async r=>{if(!r.json){process.stderr.write(`Use --json flag for all data output
|
|
75
|
+
`);return}let e=new Date,t=await _e();if(t.length===0){let k={details:{today:{},month:{},lastMonth:{},last30Days:{},lastUpdated:e.toISOString(),backendConfigured:!1},chart:{labels:[],tokensData:[],sessionsData:[],modelDatasets:[],editorDatasets:[],editorTotalsMap:{},repositoryDatasets:[],repositoryTotalsMap:{},dailyCount:0,totalTokens:0,avgTokensPerDay:0,totalSessions:0,lastUpdated:e.toISOString(),backendConfigured:!1},usage:{today:{},last30Days:{},month:{},locale:Intl.DateTimeFormat().resolvedOptions().locale,lastUpdated:e.toISOString(),backendConfigured:!1},fluency:{}};process.stdout.write(JSON.stringify(k));return}let[s,{labels:o,days:n},a]=await Promise.all([rs(t),Wo(t),as(t)]),d=Vo(o,n),c={today:s.today,month:s.month,lastMonth:s.lastMonth,last30Days:s.last30Days,lastUpdated:s.lastUpdated.toISOString(),backendConfigured:!1},h={...a,locale:Intl.DateTimeFormat().resolvedOptions().locale,lastUpdated:e.toISOString(),backendConfigured:!1},m=await Bo(t),p=await Ho(m,async()=>a,!1),g={overallStage:p.overallStage,overallLabel:p.overallLabel,categories:p.categories,period:p.period,lastUpdated:p.lastUpdated,backendConfigured:!1},w={details:c,chart:d,usage:h,fluency:g};process.stdout.write(JSON.stringify(w))});var od=Ja(),Oe=new pe;Oe.name("copilot-token-tracker").description("Analyze GitHub Copilot token usage from local session files").version(od.version).option("--no-cache","Bypass the session file cache and re-parse everything");Oe.hook("preAction",()=>{Oe.opts().cache===!1?hi():fi()});Oe.hook("postAction",()=>{gi()});Oe.addCommand(Na);Oe.addCommand(ja);Oe.addCommand($a);Oe.addCommand(Ga);Oe.addCommand(za);Oe.addCommand(Wa);Oe.addCommand(Va);Oe.addCommand(Ha);Oe.parse();
|