diff --git a/PHASE2-COMPLETE.md b/PHASE2-COMPLETE.md new file mode 100644 index 00000000..1a202694 --- /dev/null +++ b/PHASE2-COMPLETE.md @@ -0,0 +1,175 @@ +# Phase 2 Implementation Complete + +## Summary + +Phase 2 of the SDK Worker Process has been successfully implemented. This phase adds the background agent architecture that processes tool observations and generates session summaries. + +## Implementation Date + +October 15, 2025 + +## Files Created + +### 1. SDK Prompts Module +- **File**: [src/sdk/prompts.ts](src/sdk/prompts.ts) +- **Purpose**: Generates prompts for the Claude Agent SDK +- **Functions**: + - `buildInitPrompt()` - Initialize the memory agent + - `buildObservationPrompt()` - Send tool observations to agent + - `buildFinalizePrompt()` - Request session summary + +### 2. XML Parser Module +- **File**: [src/sdk/parser.ts](src/sdk/parser.ts) +- **Purpose**: Parse XML responses from SDK agent +- **Functions**: + - `parseObservations()` - Extract observation blocks + - `parseSummary()` - Extract session summary +- **Features**: + - Validates observation types (decision, bugfix, feature, refactor, discovery) + - Validates all required summary fields + - Handles file arrays in summaries + - No external dependencies (uses regex) + +### 3. SDK Worker Process +- **File**: [src/sdk/worker.ts](src/sdk/worker.ts) +- **Purpose**: Background agent that processes observations +- **Features**: + - Runs as detached background process + - Uses Claude Agent SDK streaming input mode + - Polls observation queue every 1 second + - Parses and stores observations and summaries + - Handles graceful shutdown via FINALIZE message + - Automatic error handling and session status updates + +### 4. SDK Index Module +- **File**: [src/sdk/index.ts](src/sdk/index.ts) +- **Purpose**: Export all SDK module functionality + +### 5. Test Suite +- **File**: [test-phase2.ts](test-phase2.ts) +- **Coverage**: + - SDK prompt generation (3 tests) + - XML observation parsing (4 tests) + - XML summary parsing (4 tests) + - Database integration (3 tests) +- **Result**: ✅ All 14 tests passing + +## Files Modified + +### 1. newHook Implementation +- **File**: [src/hooks/new.ts](src/hooks/new.ts:38-61) +- **Changes**: + - Uncommented SDK worker spawn code + - Added worker path resolution (dev vs production) + - Spawns worker as detached process with stdio: 'ignore' + - Worker receives session DB ID as argument + +## Architecture Validation + +### SDK Worker Flow +1. ✅ newHook spawns worker as detached process +2. ✅ Worker loads session from database +3. ✅ Worker initializes SDK agent with streaming input +4. ✅ Worker polls observation queue continuously +5. ✅ Worker sends observations to SDK agent +6. ✅ Worker parses XML responses +7. ✅ Worker stores observations and summaries +8. ✅ Worker handles FINALIZE message +9. ✅ Worker updates session status + +### Data Flow +``` +User Prompt → newHook → Create SDK Session → Spawn Worker + ↓ + Initialize SDK Agent + ↓ + ← Poll Observation Queue + ↓ + Send Observations to SDK + ↓ + ← Parse XML Response + ↓ + Store in Database + ↓ + Wait for FINALIZE + ↓ + Generate Summary → Exit +``` + +## Test Results + +```bash +$ bun test ./test-phase2.ts + +✅ SDK Prompts (3 tests) + ✅ should build init prompt with all required sections + ✅ should build observation prompt with tool details + ✅ should build finalize prompt with session context + +✅ XML Parser (8 tests) + ✅ parseObservations + ✅ should parse single observation + ✅ should parse multiple observations + ✅ should skip observations with invalid types + ✅ should handle observations with surrounding text + ✅ parseSummary + ✅ should parse complete summary with all fields + ✅ should handle empty file arrays + ✅ should return null if required fields are missing + ✅ should return null if no summary block found + +✅ HooksDatabase Integration (3 tests) + ✅ should store and retrieve observations + ✅ should store and retrieve summaries + ✅ should queue and process observations + +14 pass, 0 fail, 53 expect() calls +Ran 14 tests across 1 file. [60.00ms] +``` + +## Build Verification + +```bash +$ npm run build + +📌 Version: 3.9.16 +✓ Bun detected +✓ Cleaned dist directory +✓ Bundle created +✓ Shebang added +✓ Made executable +✅ Build complete! (344.57 KB) +``` + +## Success Criteria + +All Phase 2 success criteria have been met: + +- [x] SDK worker runs as detached process +- [x] Worker polls observation queue continuously +- [x] Worker sends observations to Claude SDK +- [x] Worker parses `` and `` XML correctly +- [x] Worker stores results in database using HooksDatabase +- [x] Worker handles FINALIZE message and exits gracefully +- [x] All tests pass +- [x] No blocking of main Claude Code session + +## Known Limitations + +1. **Bundled CLI**: The worker process is currently bundled into the main CLI. For production use, we may want to extract it as a separate executable. +2. **No logging**: Worker runs with `stdio: 'ignore'` for non-blocking behavior. Consider adding file-based logging for debugging. + +## Next Steps + +Phase 2 is complete and ready for integration testing with a real Claude Code session. The next phase would involve: + +1. Testing the full end-to-end flow with actual tool observations +2. Implementing the `saveHook` to queue observations +3. Implementing the `summaryHook` to send FINALIZE message +4. Verifying the context hook retrieves summaries correctly + +## Related Documentation + +- [REFACTOR-PLAN.md](REFACTOR-PLAN.md) - Original refactor plan +- [PHASE1-COMPLETE.md](PHASE1-COMPLETE.md) - Phase 1 completion +- [PHASE2-PROMPT.md](PHASE2-PROMPT.md) - Phase 2 implementation requirements diff --git a/dist/claude-mem.min.js b/dist/claude-mem.min.js index 64bcd9a0..5624aac3 100755 --- a/dist/claude-mem.min.js +++ b/dist/claude-mem.min.js @@ -1,38 +1,38 @@ #!/usr/bin/env bun // @bun -var qC=Object.create;var{getPrototypeOf:VC,defineProperty:WF,getOwnPropertyNames:AC}=Object;var HC=Object.prototype.hasOwnProperty;var F0=(D,u,F)=>{F=D!=null?qC(VC(D)):{};let C=u||!D||!D.__esModule?WF(F,"default",{value:D,enumerable:!0}):F;for(let B of AC(D))if(!HC.call(C,B))WF(C,B,{get:()=>D[B],enumerable:!0});return C};var e=(D,u)=>()=>(u||D((u={exports:{}}).exports,u),u.exports);var C0=(D,u)=>{for(var F in u)WF(D,F,{get:u[F],enumerable:!0,configurable:!0,set:(C)=>u[F]=()=>C})};var HD=(D,u)=>()=>(D&&(u=D(D=0)),u);var cD=import.meta.require;var h0=e((GC)=>{class LF extends Error{constructor(D,u,F){super(F);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=u,this.exitCode=D,this.nestedError=void 0}}class Y3 extends LF{constructor(D){super(1,"commander.invalidArgument",D);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}GC.CommanderError=LF;GC.InvalidArgumentError=Y3});var Ru=e((LC)=>{var{InvalidArgumentError:UC}=h0();class J3{constructor(D,u){switch(this.description=u||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,D[0]){case"<":this.required=!0,this._name=D.slice(1,-1);break;case"[":this.required=!1,this._name=D.slice(1,-1);break;default:this.required=!0,this._name=D;break}if(this._name.endsWith("..."))this.variadic=!0,this._name=this._name.slice(0,-3)}name(){return this._name}_collectValue(D,u){if(u===this.defaultValue||!Array.isArray(u))return[D];return u.push(D),u}default(D,u){return this.defaultValue=D,this.defaultValueDescription=u,this}argParser(D){return this.parseArg=D,this}choices(D){return this.argChoices=D.slice(),this.parseArg=(u,F)=>{if(!this.argChoices.includes(u))throw new UC(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._collectValue(u,F);return u},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}}function WC(D){let u=D.name()+(D.variadic===!0?"...":"");return D.required?"<"+u+">":"["+u+"]"}LC.Argument=J3;LC.humanReadableArgName=WC});var RF=e((NC)=>{var{humanReadableArgName:IC}=Ru();class K3{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(D){this.helpWidth=this.helpWidth??D.helpWidth??80}visibleCommands(D){let u=D.commands.filter((C)=>!C._hidden),F=D._getHelpCommand();if(F&&!F._hidden)u.push(F);if(this.sortSubcommands)u.sort((C,B)=>{return C.name().localeCompare(B.name())});return u}compareOptions(D,u){let F=(C)=>{return C.short?C.short.replace(/^-/,""):C.long.replace(/^--/,"")};return F(D).localeCompare(F(u))}visibleOptions(D){let u=D.options.filter((C)=>!C.hidden),F=D._getHelpOption();if(F&&!F.hidden){let C=F.short&&D._findOption(F.short),B=F.long&&D._findOption(F.long);if(!C&&!B)u.push(F);else if(F.long&&!B)u.push(D.createOption(F.long,F.description));else if(F.short&&!C)u.push(D.createOption(F.short,F.description))}if(this.sortOptions)u.sort(this.compareOptions);return u}visibleGlobalOptions(D){if(!this.showGlobalOptions)return[];let u=[];for(let F=D.parent;F;F=F.parent){let C=F.options.filter((B)=>!B.hidden);u.push(...C)}if(this.sortOptions)u.sort(this.compareOptions);return u}visibleArguments(D){if(D._argsDescription)D.registeredArguments.forEach((u)=>{u.description=u.description||D._argsDescription[u.name()]||""});if(D.registeredArguments.find((u)=>u.description))return D.registeredArguments;return[]}subcommandTerm(D){let u=D.registeredArguments.map((F)=>IC(F)).join(" ");return D._name+(D._aliases[0]?"|"+D._aliases[0]:"")+(D.options.length?" [options]":"")+(u?" "+u:"")}optionTerm(D){return D.flags}argumentTerm(D){return D.name()}longestSubcommandTermLength(D,u){return u.visibleCommands(D).reduce((F,C)=>{return Math.max(F,this.displayWidth(u.styleSubcommandTerm(u.subcommandTerm(C))))},0)}longestOptionTermLength(D,u){return u.visibleOptions(D).reduce((F,C)=>{return Math.max(F,this.displayWidth(u.styleOptionTerm(u.optionTerm(C))))},0)}longestGlobalOptionTermLength(D,u){return u.visibleGlobalOptions(D).reduce((F,C)=>{return Math.max(F,this.displayWidth(u.styleOptionTerm(u.optionTerm(C))))},0)}longestArgumentTermLength(D,u){return u.visibleArguments(D).reduce((F,C)=>{return Math.max(F,this.displayWidth(u.styleArgumentTerm(u.argumentTerm(C))))},0)}commandUsage(D){let u=D._name;if(D._aliases[0])u=u+"|"+D._aliases[0];let F="";for(let C=D.parent;C;C=C.parent)F=C.name()+" "+F;return F+u+" "+D.usage()}commandDescription(D){return D.description()}subcommandDescription(D){return D.summary()||D.description()}optionDescription(D){let u=[];if(D.argChoices)u.push(`choices: ${D.argChoices.map((F)=>JSON.stringify(F)).join(", ")}`);if(D.defaultValue!==void 0){if(D.required||D.optional||D.isBoolean()&&typeof D.defaultValue==="boolean")u.push(`default: ${D.defaultValueDescription||JSON.stringify(D.defaultValue)}`)}if(D.presetArg!==void 0&&D.optional)u.push(`preset: ${JSON.stringify(D.presetArg)}`);if(D.envVar!==void 0)u.push(`env: ${D.envVar}`);if(u.length>0){let F=`(${u.join(", ")})`;if(D.description)return`${D.description} ${F}`;return F}return D.description}argumentDescription(D){let u=[];if(D.argChoices)u.push(`choices: ${D.argChoices.map((F)=>JSON.stringify(F)).join(", ")}`);if(D.defaultValue!==void 0)u.push(`default: ${D.defaultValueDescription||JSON.stringify(D.defaultValue)}`);if(u.length>0){let F=`(${u.join(", ")})`;if(D.description)return`${D.description} ${F}`;return F}return D.description}formatItemList(D,u,F){if(u.length===0)return[];return[F.styleTitle(D),...u,""]}groupItems(D,u,F){let C=new Map;return D.forEach((B)=>{let $=F(B);if(!C.has($))C.set($,[])}),u.forEach((B)=>{let $=F(B);if(!C.has($))C.set($,[]);C.get($).push(B)}),C}formatHelp(D,u){let F=u.padWidth(D,u),C=u.helpWidth??80;function B(Y,J){return u.formatItem(Y,F,J,u)}let $=[`${u.styleTitle("Usage:")} ${u.styleUsage(u.commandUsage(D))}`,""],E=u.commandDescription(D);if(E.length>0)$=$.concat([u.boxWrap(u.styleCommandDescription(E),C),""]);let Q=u.visibleArguments(D).map((Y)=>{return B(u.styleArgumentTerm(u.argumentTerm(Y)),u.styleArgumentDescription(u.argumentDescription(Y)))});if($=$.concat(this.formatItemList("Arguments:",Q,u)),this.groupItems(D.options,u.visibleOptions(D),(Y)=>Y.helpGroupHeading??"Options:").forEach((Y,J)=>{let A=Y.map((H)=>{return B(u.styleOptionTerm(u.optionTerm(H)),u.styleOptionDescription(u.optionDescription(H)))});$=$.concat(this.formatItemList(J,A,u))}),u.showGlobalOptions){let Y=u.visibleGlobalOptions(D).map((J)=>{return B(u.styleOptionTerm(u.optionTerm(J)),u.styleOptionDescription(u.optionDescription(J)))});$=$.concat(this.formatItemList("Global Options:",Y,u))}return this.groupItems(D.commands,u.visibleCommands(D),(Y)=>Y.helpGroup()||"Commands:").forEach((Y,J)=>{let A=Y.map((H)=>{return B(u.styleSubcommandTerm(u.subcommandTerm(H)),u.styleSubcommandDescription(u.subcommandDescription(H)))});$=$.concat(this.formatItemList(J,A,u))}),$.join(` -`)}displayWidth(D){return q3(D).length}styleTitle(D){return D}styleUsage(D){return D.split(" ").map((u)=>{if(u==="[options]")return this.styleOptionText(u);if(u==="[command]")return this.styleSubcommandText(u);if(u[0]==="["||u[0]==="<")return this.styleArgumentText(u);return this.styleCommandText(u)}).join(" ")}styleCommandDescription(D){return this.styleDescriptionText(D)}styleOptionDescription(D){return this.styleDescriptionText(D)}styleSubcommandDescription(D){return this.styleDescriptionText(D)}styleArgumentDescription(D){return this.styleDescriptionText(D)}styleDescriptionText(D){return D}styleOptionTerm(D){return this.styleOptionText(D)}styleSubcommandTerm(D){return D.split(" ").map((u)=>{if(u==="[options]")return this.styleOptionText(u);if(u[0]==="["||u[0]==="<")return this.styleArgumentText(u);return this.styleSubcommandText(u)}).join(" ")}styleArgumentTerm(D){return this.styleArgumentText(D)}styleOptionText(D){return D}styleArgumentText(D){return D}styleSubcommandText(D){return D}styleCommandText(D){return D}padWidth(D,u){return Math.max(u.longestOptionTermLength(D,u),u.longestGlobalOptionTermLength(D,u),u.longestSubcommandTermLength(D,u),u.longestArgumentTermLength(D,u))}preformatted(D){return/\n[^\S\r\n]/.test(D)}formatItem(D,u,F,C){let $=" ".repeat(2);if(!F)return $+D;let E=D.padEnd(u+D.length-C.displayWidth(D)),Q=2,Z=(this.helpWidth??80)-u-Q-2,Y;if(Z{F=D!=null?AC(HC(D)):{};let C=u||!D||!D.__esModule?WF(F,"default",{value:D,enumerable:!0}):F;for(let B of GC(D))if(!zC.call(C,B))WF(C,B,{get:()=>D[B],enumerable:!0});return C};var e=(D,u)=>()=>(u||D((u={exports:{}}).exports,u),u.exports);var C0=(D,u)=>{for(var F in u)WF(D,F,{get:u[F],enumerable:!0,configurable:!0,set:(C)=>u[F]=()=>C})};var HD=(D,u)=>()=>(D&&(u=D(D=0)),u);var cD=import.meta.require;var h0=e((_C)=>{class LF extends Error{constructor(D,u,F){super(F);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=u,this.exitCode=D,this.nestedError=void 0}}class J3 extends LF{constructor(D){super(1,"commander.invalidArgument",D);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}_C.CommanderError=LF;_C.InvalidArgumentError=J3});var Ru=e((MC)=>{var{InvalidArgumentError:LC}=h0();class K3{constructor(D,u){switch(this.description=u||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,D[0]){case"<":this.required=!0,this._name=D.slice(1,-1);break;case"[":this.required=!1,this._name=D.slice(1,-1);break;default:this.required=!0,this._name=D;break}if(this._name.endsWith("..."))this.variadic=!0,this._name=this._name.slice(0,-3)}name(){return this._name}_collectValue(D,u){if(u===this.defaultValue||!Array.isArray(u))return[D];return u.push(D),u}default(D,u){return this.defaultValue=D,this.defaultValueDescription=u,this}argParser(D){return this.parseArg=D,this}choices(D){return this.argChoices=D.slice(),this.parseArg=(u,F)=>{if(!this.argChoices.includes(u))throw new LC(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._collectValue(u,F);return u},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}}function RC(D){let u=D.name()+(D.variadic===!0?"...":"");return D.required?"<"+u+">":"["+u+"]"}MC.Argument=K3;MC.humanReadableArgName=RC});var RF=e((jC)=>{var{humanReadableArgName:OC}=Ru();class q3{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(D){this.helpWidth=this.helpWidth??D.helpWidth??80}visibleCommands(D){let u=D.commands.filter((C)=>!C._hidden),F=D._getHelpCommand();if(F&&!F._hidden)u.push(F);if(this.sortSubcommands)u.sort((C,B)=>{return C.name().localeCompare(B.name())});return u}compareOptions(D,u){let F=(C)=>{return C.short?C.short.replace(/^-/,""):C.long.replace(/^--/,"")};return F(D).localeCompare(F(u))}visibleOptions(D){let u=D.options.filter((C)=>!C.hidden),F=D._getHelpOption();if(F&&!F.hidden){let C=F.short&&D._findOption(F.short),B=F.long&&D._findOption(F.long);if(!C&&!B)u.push(F);else if(F.long&&!B)u.push(D.createOption(F.long,F.description));else if(F.short&&!C)u.push(D.createOption(F.short,F.description))}if(this.sortOptions)u.sort(this.compareOptions);return u}visibleGlobalOptions(D){if(!this.showGlobalOptions)return[];let u=[];for(let F=D.parent;F;F=F.parent){let C=F.options.filter((B)=>!B.hidden);u.push(...C)}if(this.sortOptions)u.sort(this.compareOptions);return u}visibleArguments(D){if(D._argsDescription)D.registeredArguments.forEach((u)=>{u.description=u.description||D._argsDescription[u.name()]||""});if(D.registeredArguments.find((u)=>u.description))return D.registeredArguments;return[]}subcommandTerm(D){let u=D.registeredArguments.map((F)=>OC(F)).join(" ");return D._name+(D._aliases[0]?"|"+D._aliases[0]:"")+(D.options.length?" [options]":"")+(u?" "+u:"")}optionTerm(D){return D.flags}argumentTerm(D){return D.name()}longestSubcommandTermLength(D,u){return u.visibleCommands(D).reduce((F,C)=>{return Math.max(F,this.displayWidth(u.styleSubcommandTerm(u.subcommandTerm(C))))},0)}longestOptionTermLength(D,u){return u.visibleOptions(D).reduce((F,C)=>{return Math.max(F,this.displayWidth(u.styleOptionTerm(u.optionTerm(C))))},0)}longestGlobalOptionTermLength(D,u){return u.visibleGlobalOptions(D).reduce((F,C)=>{return Math.max(F,this.displayWidth(u.styleOptionTerm(u.optionTerm(C))))},0)}longestArgumentTermLength(D,u){return u.visibleArguments(D).reduce((F,C)=>{return Math.max(F,this.displayWidth(u.styleArgumentTerm(u.argumentTerm(C))))},0)}commandUsage(D){let u=D._name;if(D._aliases[0])u=u+"|"+D._aliases[0];let F="";for(let C=D.parent;C;C=C.parent)F=C.name()+" "+F;return F+u+" "+D.usage()}commandDescription(D){return D.description()}subcommandDescription(D){return D.summary()||D.description()}optionDescription(D){let u=[];if(D.argChoices)u.push(`choices: ${D.argChoices.map((F)=>JSON.stringify(F)).join(", ")}`);if(D.defaultValue!==void 0){if(D.required||D.optional||D.isBoolean()&&typeof D.defaultValue==="boolean")u.push(`default: ${D.defaultValueDescription||JSON.stringify(D.defaultValue)}`)}if(D.presetArg!==void 0&&D.optional)u.push(`preset: ${JSON.stringify(D.presetArg)}`);if(D.envVar!==void 0)u.push(`env: ${D.envVar}`);if(u.length>0){let F=`(${u.join(", ")})`;if(D.description)return`${D.description} ${F}`;return F}return D.description}argumentDescription(D){let u=[];if(D.argChoices)u.push(`choices: ${D.argChoices.map((F)=>JSON.stringify(F)).join(", ")}`);if(D.defaultValue!==void 0)u.push(`default: ${D.defaultValueDescription||JSON.stringify(D.defaultValue)}`);if(u.length>0){let F=`(${u.join(", ")})`;if(D.description)return`${D.description} ${F}`;return F}return D.description}formatItemList(D,u,F){if(u.length===0)return[];return[F.styleTitle(D),...u,""]}groupItems(D,u,F){let C=new Map;return D.forEach((B)=>{let $=F(B);if(!C.has($))C.set($,[])}),u.forEach((B)=>{let $=F(B);if(!C.has($))C.set($,[]);C.get($).push(B)}),C}formatHelp(D,u){let F=u.padWidth(D,u),C=u.helpWidth??80;function B(Y,J){return u.formatItem(Y,F,J,u)}let $=[`${u.styleTitle("Usage:")} ${u.styleUsage(u.commandUsage(D))}`,""],E=u.commandDescription(D);if(E.length>0)$=$.concat([u.boxWrap(u.styleCommandDescription(E),C),""]);let Q=u.visibleArguments(D).map((Y)=>{return B(u.styleArgumentTerm(u.argumentTerm(Y)),u.styleArgumentDescription(u.argumentDescription(Y)))});if($=$.concat(this.formatItemList("Arguments:",Q,u)),this.groupItems(D.options,u.visibleOptions(D),(Y)=>Y.helpGroupHeading??"Options:").forEach((Y,J)=>{let A=Y.map((H)=>{return B(u.styleOptionTerm(u.optionTerm(H)),u.styleOptionDescription(u.optionDescription(H)))});$=$.concat(this.formatItemList(J,A,u))}),u.showGlobalOptions){let Y=u.visibleGlobalOptions(D).map((J)=>{return B(u.styleOptionTerm(u.optionTerm(J)),u.styleOptionDescription(u.optionDescription(J)))});$=$.concat(this.formatItemList("Global Options:",Y,u))}return this.groupItems(D.commands,u.visibleCommands(D),(Y)=>Y.helpGroup()||"Commands:").forEach((Y,J)=>{let A=Y.map((H)=>{return B(u.styleSubcommandTerm(u.subcommandTerm(H)),u.styleSubcommandDescription(u.subcommandDescription(H)))});$=$.concat(this.formatItemList(J,A,u))}),$.join(` +`)}displayWidth(D){return V3(D).length}styleTitle(D){return D}styleUsage(D){return D.split(" ").map((u)=>{if(u==="[options]")return this.styleOptionText(u);if(u==="[command]")return this.styleSubcommandText(u);if(u[0]==="["||u[0]==="<")return this.styleArgumentText(u);return this.styleCommandText(u)}).join(" ")}styleCommandDescription(D){return this.styleDescriptionText(D)}styleOptionDescription(D){return this.styleDescriptionText(D)}styleSubcommandDescription(D){return this.styleDescriptionText(D)}styleArgumentDescription(D){return this.styleDescriptionText(D)}styleDescriptionText(D){return D}styleOptionTerm(D){return this.styleOptionText(D)}styleSubcommandTerm(D){return D.split(" ").map((u)=>{if(u==="[options]")return this.styleOptionText(u);if(u[0]==="["||u[0]==="<")return this.styleArgumentText(u);return this.styleSubcommandText(u)}).join(" ")}styleArgumentTerm(D){return this.styleArgumentText(D)}styleOptionText(D){return D}styleArgumentText(D){return D}styleSubcommandText(D){return D}styleCommandText(D){return D}padWidth(D,u){return Math.max(u.longestOptionTermLength(D,u),u.longestGlobalOptionTermLength(D,u),u.longestSubcommandTermLength(D,u),u.longestArgumentTermLength(D,u))}preformatted(D){return/\n[^\S\r\n]/.test(D)}formatItem(D,u,F,C){let $=" ".repeat(2);if(!F)return $+D;let E=D.padEnd(u+D.length-C.displayWidth(D)),Q=2,Z=(this.helpWidth??80)-u-Q-2,Y;if(Z{let E=$.match(C);if(E===null){B.push("");return}let Q=[E.shift()],X=this.displayWidth(Q[0]);E.forEach((Z)=>{let Y=this.displayWidth(Z);if(X+Y<=u){Q.push(Z),X+=Y;return}B.push(Q.join(""));let J=Z.trimStart();Q=[J],X=this.displayWidth(J)}),B.push(Q.join(""))}),B.join(` -`)}}function q3(D){let u=/\x1b\[\d*(;\d*)*m/g;return D.replace(u,"")}NC.Help=K3;NC.stripColor=q3});var MF=e((kC)=>{var{InvalidArgumentError:TC}=h0();class A3{constructor(D,u){this.flags=D,this.description=u||"",this.required=D.includes("<"),this.optional=D.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(D),this.mandatory=!1;let F=wC(D);if(this.short=F.shortFlag,this.long=F.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(D,u){return this.defaultValue=D,this.defaultValueDescription=u,this}preset(D){return this.presetArg=D,this}conflicts(D){return this.conflictsWith=this.conflictsWith.concat(D),this}implies(D){let u=D;if(typeof D==="string")u={[D]:!0};return this.implied=Object.assign(this.implied||{},u),this}env(D){return this.envVar=D,this}argParser(D){return this.parseArg=D,this}makeOptionMandatory(D=!0){return this.mandatory=!!D,this}hideHelp(D=!0){return this.hidden=!!D,this}_collectValue(D,u){if(u===this.defaultValue||!Array.isArray(u))return[D];return u.push(D),u}choices(D){return this.argChoices=D.slice(),this.parseArg=(u,F)=>{if(!this.argChoices.includes(u))throw new TC(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._collectValue(u,F);return u},this}name(){if(this.long)return this.long.replace(/^--/,"");return this.short.replace(/^-/,"")}attributeName(){if(this.negate)return V3(this.name().replace(/^no-/,""));return V3(this.name())}helpGroup(D){return this.helpGroupHeading=D,this}is(D){return this.short===D||this.long===D}isBoolean(){return!this.required&&!this.optional&&!this.negate}}class H3{constructor(D){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,D.forEach((u)=>{if(u.negate)this.negativeOptions.set(u.attributeName(),u);else this.positiveOptions.set(u.attributeName(),u)}),this.negativeOptions.forEach((u,F)=>{if(this.positiveOptions.has(F))this.dualOptions.add(F)})}valueFromOption(D,u){let F=u.attributeName();if(!this.dualOptions.has(F))return!0;let C=this.negativeOptions.get(F).presetArg,B=C!==void 0?C:!1;return u.negate===(B===D)}}function V3(D){return D.split("-").reduce((u,F)=>{return u+F[0].toUpperCase()+F.slice(1)})}function wC(D){let u,F,C=/^-[^-]$/,B=/^--[^-]/,$=D.split(/[ |,]+/).concat("guard");if(C.test($[0]))u=$.shift();if(B.test($[0]))F=$.shift();if(!u&&C.test($[0]))u=$.shift();if(!u&&B.test($[0]))u=F,F=$.shift();if($[0].startsWith("-")){let E=$[0],Q=`option creation failed due to '${E}' in option flags '${D}'`;if(/^-[^-][^-]/.test(E))throw new Error(`${Q} +`)}}function V3(D){let u=/\x1b\[\d*(;\d*)*m/g;return D.replace(u,"")}jC.Help=q3;jC.stripColor=V3});var MF=e((SC)=>{var{InvalidArgumentError:kC}=h0();class H3{constructor(D,u){this.flags=D,this.description=u||"",this.required=D.includes("<"),this.optional=D.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(D),this.mandatory=!1;let F=PC(D);if(this.short=F.shortFlag,this.long=F.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(D,u){return this.defaultValue=D,this.defaultValueDescription=u,this}preset(D){return this.presetArg=D,this}conflicts(D){return this.conflictsWith=this.conflictsWith.concat(D),this}implies(D){let u=D;if(typeof D==="string")u={[D]:!0};return this.implied=Object.assign(this.implied||{},u),this}env(D){return this.envVar=D,this}argParser(D){return this.parseArg=D,this}makeOptionMandatory(D=!0){return this.mandatory=!!D,this}hideHelp(D=!0){return this.hidden=!!D,this}_collectValue(D,u){if(u===this.defaultValue||!Array.isArray(u))return[D];return u.push(D),u}choices(D){return this.argChoices=D.slice(),this.parseArg=(u,F)=>{if(!this.argChoices.includes(u))throw new kC(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._collectValue(u,F);return u},this}name(){if(this.long)return this.long.replace(/^--/,"");return this.short.replace(/^-/,"")}attributeName(){if(this.negate)return A3(this.name().replace(/^no-/,""));return A3(this.name())}helpGroup(D){return this.helpGroupHeading=D,this}is(D){return this.short===D||this.long===D}isBoolean(){return!this.required&&!this.optional&&!this.negate}}class G3{constructor(D){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,D.forEach((u)=>{if(u.negate)this.negativeOptions.set(u.attributeName(),u);else this.positiveOptions.set(u.attributeName(),u)}),this.negativeOptions.forEach((u,F)=>{if(this.positiveOptions.has(F))this.dualOptions.add(F)})}valueFromOption(D,u){let F=u.attributeName();if(!this.dualOptions.has(F))return!0;let C=this.negativeOptions.get(F).presetArg,B=C!==void 0?C:!1;return u.negate===(B===D)}}function A3(D){return D.split("-").reduce((u,F)=>{return u+F[0].toUpperCase()+F.slice(1)})}function PC(D){let u,F,C=/^-[^-]$/,B=/^--[^-]/,$=D.split(/[ |,]+/).concat("guard");if(C.test($[0]))u=$.shift();if(B.test($[0]))F=$.shift();if(!u&&C.test($[0]))u=$.shift();if(!u&&B.test($[0]))u=F,F=$.shift();if($[0].startsWith("-")){let E=$[0],Q=`option creation failed due to '${E}' in option flags '${D}'`;if(/^-[^-][^-]/.test(E))throw new Error(`${Q} - a short flag is a single dash and a single character - either use a single dash and a single character (for a short flag) - or use a double dash for a long option (and can have two, like '--ws, --workspace')`);if(C.test(E))throw new Error(`${Q} - too many short flags`);if(B.test(E))throw new Error(`${Q} - too many long flags`);throw new Error(`${Q} -- unrecognised flag format`)}if(u===void 0&&F===void 0)throw new Error(`option creation failed due to no flags found in '${D}'.`);return{shortFlag:u,longFlag:F}}kC.Option=A3;kC.DualOptions=H3});var G3=e((vC)=>{function xC(D,u){if(Math.abs(D.length-u.length)>3)return Math.max(D.length,u.length);let F=[];for(let C=0;C<=D.length;C++)F[C]=[C];for(let C=0;C<=u.length;C++)F[0][C]=C;for(let C=1;C<=u.length;C++)for(let B=1;B<=D.length;B++){let $=1;if(D[B-1]===u[C-1])$=0;else $=1;if(F[B][C]=Math.min(F[B-1][C]+1,F[B][C-1]+1,F[B-1][C-1]+$),B>1&&C>1&&D[B-1]===u[C-2]&&D[B-2]===u[C-1])F[B][C]=Math.min(F[B][C],F[B-2][C-2]+1)}return F[D.length][u.length]}function bC(D,u){if(!u||u.length===0)return"";u=Array.from(new Set(u));let F=D.startsWith("--");if(F)D=D.slice(2),u=u.map((E)=>E.slice(2));let C=[],B=3,$=0.4;if(u.forEach((E)=>{if(E.length<=1)return;let Q=xC(D,E),X=Math.max(D.length,E.length);if((X-Q)/X>$){if(QE.localeCompare(Q)),F)C=C.map((E)=>`--${E}`);if(C.length>1)return` +- unrecognised flag format`)}if(u===void 0&&F===void 0)throw new Error(`option creation failed due to no flags found in '${D}'.`);return{shortFlag:u,longFlag:F}}SC.Option=H3;SC.DualOptions=G3});var z3=e((yC)=>{function vC(D,u){if(Math.abs(D.length-u.length)>3)return Math.max(D.length,u.length);let F=[];for(let C=0;C<=D.length;C++)F[C]=[C];for(let C=0;C<=u.length;C++)F[0][C]=C;for(let C=1;C<=u.length;C++)for(let B=1;B<=D.length;B++){let $=1;if(D[B-1]===u[C-1])$=0;else $=1;if(F[B][C]=Math.min(F[B-1][C]+1,F[B][C-1]+1,F[B-1][C-1]+$),B>1&&C>1&&D[B-1]===u[C-2]&&D[B-2]===u[C-1])F[B][C]=Math.min(F[B][C],F[B-2][C-2]+1)}return F[D.length][u.length]}function fC(D,u){if(!u||u.length===0)return"";u=Array.from(new Set(u));let F=D.startsWith("--");if(F)D=D.slice(2),u=u.map((E)=>E.slice(2));let C=[],B=3,$=0.4;if(u.forEach((E)=>{if(E.length<=1)return;let Q=vC(D,E),X=Math.max(D.length,E.length);if((X-Q)/X>$){if(QE.localeCompare(Q)),F)C=C.map((E)=>`--${E}`);if(C.length>1)return` (Did you mean one of ${C.join(", ")}?)`;if(C.length===1)return` -(Did you mean ${C[0]}?)`;return""}vC.suggestSimilar=bC});var W3=e((lC)=>{var yC=cD("events").EventEmitter,IF=cD("child_process"),B0=cD("path"),Mu=cD("fs"),y=cD("process"),{Argument:hC,humanReadableArgName:gC}=Ru(),{CommanderError:NF}=h0(),{Help:mC,stripColor:dC}=RF(),{Option:z3,DualOptions:cC}=MF(),{suggestSimilar:_3}=G3();class jF extends yC{constructor(D){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=D||"",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:(u)=>y.stdout.write(u),writeErr:(u)=>y.stderr.write(u),outputError:(u,F)=>F(u),getOutHelpWidth:()=>y.stdout.isTTY?y.stdout.columns:void 0,getErrHelpWidth:()=>y.stderr.isTTY?y.stderr.columns:void 0,getOutHasColors:()=>OF()??(y.stdout.isTTY&&y.stdout.hasColors?.()),getErrHasColors:()=>OF()??(y.stderr.isTTY&&y.stderr.hasColors?.()),stripColor:(u)=>dC(u)},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(D){return this._outputConfiguration=D._outputConfiguration,this._helpOption=D._helpOption,this._helpCommand=D._helpCommand,this._helpConfiguration=D._helpConfiguration,this._exitCallback=D._exitCallback,this._storeOptionsAsProperties=D._storeOptionsAsProperties,this._combineFlagAndOptionalValue=D._combineFlagAndOptionalValue,this._allowExcessArguments=D._allowExcessArguments,this._enablePositionalOptions=D._enablePositionalOptions,this._showHelpAfterError=D._showHelpAfterError,this._showSuggestionAfterError=D._showSuggestionAfterError,this}_getCommandAndAncestors(){let D=[];for(let u=this;u;u=u.parent)D.push(u);return D}command(D,u,F){let C=u,B=F;if(typeof C==="object"&&C!==null)B=C,C=null;B=B||{};let[,$,E]=D.match(/([^ ]+) *(.*)/),Q=this.createCommand($);if(C)Q.description(C),Q._executableHandler=!0;if(B.isDefault)this._defaultCommandName=Q._name;if(Q._hidden=!!(B.noHelp||B.hidden),Q._executableFile=B.executableFile||null,E)Q.arguments(E);if(this._registerCommand(Q),Q.parent=this,Q.copyInheritedSettings(this),C)return this;return Q}createCommand(D){return new jF(D)}createHelp(){return Object.assign(new mC,this.configureHelp())}configureHelp(D){if(D===void 0)return this._helpConfiguration;return this._helpConfiguration=D,this}configureOutput(D){if(D===void 0)return this._outputConfiguration;return this._outputConfiguration={...this._outputConfiguration,...D},this}showHelpAfterError(D=!0){if(typeof D!=="string")D=!!D;return this._showHelpAfterError=D,this}showSuggestionAfterError(D=!0){return this._showSuggestionAfterError=!!D,this}addCommand(D,u){if(!D._name)throw new Error(`Command passed to .addCommand() must have a name -- specify the name in Command constructor or using .name()`);if(u=u||{},u.isDefault)this._defaultCommandName=D._name;if(u.noHelp||u.hidden)D._hidden=!0;return this._registerCommand(D),D.parent=this,D._checkForBrokenPassThrough(),this}createArgument(D,u){return new hC(D,u)}argument(D,u,F,C){let B=this.createArgument(D,u);if(typeof F==="function")B.default(C).argParser(F);else B.default(F);return this.addArgument(B),this}arguments(D){return D.trim().split(/ +/).forEach((u)=>{this.argument(u)}),this}addArgument(D){let u=this.registeredArguments.slice(-1)[0];if(u?.variadic)throw new Error(`only the last argument can be variadic '${u.name()}'`);if(D.required&&D.defaultValue!==void 0&&D.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${D.name()}'`);return this.registeredArguments.push(D),this}helpCommand(D,u){if(typeof D==="boolean"){if(this._addImplicitHelpCommand=D,D&&this._defaultCommandGroup)this._initCommandGroup(this._getHelpCommand());return this}let F=D??"help [command]",[,C,B]=F.match(/([^ ]+) *(.*)/),$=u??"display help for command",E=this.createCommand(C);if(E.helpOption(!1),B)E.arguments(B);if($)E.description($);if(this._addImplicitHelpCommand=!0,this._helpCommand=E,D||u)this._initCommandGroup(E);return this}addHelpCommand(D,u){if(typeof D!=="object")return this.helpCommand(D,u),this;return this._addImplicitHelpCommand=!0,this._helpCommand=D,this._initCommandGroup(D),this}_getHelpCommand(){if(this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))){if(this._helpCommand===void 0)this.helpCommand(void 0,void 0);return this._helpCommand}return null}hook(D,u){let F=["preSubcommand","preAction","postAction"];if(!F.includes(D))throw new Error(`Unexpected value for event passed to hook : '${D}'. -Expecting one of '${F.join("', '")}'`);if(this._lifeCycleHooks[D])this._lifeCycleHooks[D].push(u);else this._lifeCycleHooks[D]=[u];return this}exitOverride(D){if(D)this._exitCallback=D;else this._exitCallback=(u)=>{if(u.code!=="commander.executeSubCommandAsync")throw u};return this}_exit(D,u,F){if(this._exitCallback)this._exitCallback(new NF(D,u,F));y.exit(D)}action(D){let u=(F)=>{let C=this.registeredArguments.length,B=F.slice(0,C);if(this._storeOptionsAsProperties)B[C]=this;else B[C]=this.opts();return B.push(this),D.apply(this,B)};return this._actionHandler=u,this}createOption(D,u){return new z3(D,u)}_callParseArg(D,u,F,C){try{return D.parseArg(u,F)}catch(B){if(B.code==="commander.invalidArgument"){let $=`${C} ${B.message}`;this.error($,{exitCode:B.exitCode,code:B.code})}throw B}}_registerOption(D){let u=D.short&&this._findOption(D.short)||D.long&&this._findOption(D.long);if(u){let F=D.long&&this._findOption(D.long)?D.long:D.short;throw new Error(`Cannot add option '${D.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${F}' -- already used by option '${u.flags}'`)}this._initOptionGroup(D),this.options.push(D)}_registerCommand(D){let u=(C)=>{return[C.name()].concat(C.aliases())},F=u(D).find((C)=>this._findCommand(C));if(F){let C=u(this._findCommand(F)).join("|"),B=u(D).join("|");throw new Error(`cannot add command '${B}' as already have command '${C}'`)}this._initCommandGroup(D),this.commands.push(D)}addOption(D){this._registerOption(D);let u=D.name(),F=D.attributeName();if(D.negate){let B=D.long.replace(/^--no-/,"--");if(!this._findOption(B))this.setOptionValueWithSource(F,D.defaultValue===void 0?!0:D.defaultValue,"default")}else if(D.defaultValue!==void 0)this.setOptionValueWithSource(F,D.defaultValue,"default");let C=(B,$,E)=>{if(B==null&&D.presetArg!==void 0)B=D.presetArg;let Q=this.getOptionValue(F);if(B!==null&&D.parseArg)B=this._callParseArg(D,B,Q,$);else if(B!==null&&D.variadic)B=D._collectValue(B,Q);if(B==null)if(D.negate)B=!1;else if(D.isBoolean()||D.optional)B=!0;else B="";this.setOptionValueWithSource(F,B,E)};if(this.on("option:"+u,(B)=>{let $=`error: option '${D.flags}' argument '${B}' is invalid.`;C(B,$,"cli")}),D.envVar)this.on("optionEnv:"+u,(B)=>{let $=`error: option '${D.flags}' value '${B}' from env '${D.envVar}' is invalid.`;C(B,$,"env")});return this}_optionEx(D,u,F,C,B){if(typeof u==="object"&&u instanceof z3)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let $=this.createOption(u,F);if($.makeOptionMandatory(!!D.mandatory),typeof C==="function")$.default(B).argParser(C);else if(C instanceof RegExp){let E=C;C=(Q,X)=>{let Z=E.exec(Q);return Z?Z[0]:X},$.default(B).argParser(C)}else $.default(C);return this.addOption($)}option(D,u,F,C){return this._optionEx({},D,u,F,C)}requiredOption(D,u,F,C){return this._optionEx({mandatory:!0},D,u,F,C)}combineFlagAndOptionalValue(D=!0){return this._combineFlagAndOptionalValue=!!D,this}allowUnknownOption(D=!0){return this._allowUnknownOption=!!D,this}allowExcessArguments(D=!0){return this._allowExcessArguments=!!D,this}enablePositionalOptions(D=!0){return this._enablePositionalOptions=!!D,this}passThroughOptions(D=!0){return this._passThroughOptions=!!D,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(D=!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=!!D,this}getOptionValue(D){if(this._storeOptionsAsProperties)return this[D];return this._optionValues[D]}setOptionValue(D,u){return this.setOptionValueWithSource(D,u,void 0)}setOptionValueWithSource(D,u,F){if(this._storeOptionsAsProperties)this[D]=u;else this._optionValues[D]=u;return this._optionValueSources[D]=F,this}getOptionValueSource(D){return this._optionValueSources[D]}getOptionValueSourceWithGlobals(D){let u;return this._getCommandAndAncestors().forEach((F)=>{if(F.getOptionValueSource(D)!==void 0)u=F.getOptionValueSource(D)}),u}_prepareUserArgs(D,u){if(D!==void 0&&!Array.isArray(D))throw new Error("first parameter to parse must be array or undefined");if(u=u||{},D===void 0&&u.from===void 0){if(y.versions?.electron)u.from="electron";let C=y.execArgv??[];if(C.includes("-e")||C.includes("--eval")||C.includes("-p")||C.includes("--print"))u.from="eval"}if(D===void 0)D=y.argv;this.rawArgs=D.slice();let F;switch(u.from){case void 0:case"node":this._scriptPath=D[1],F=D.slice(2);break;case"electron":if(y.defaultApp)this._scriptPath=D[1],F=D.slice(2);else F=D.slice(1);break;case"user":F=D.slice(0);break;case"eval":F=D.slice(1);break;default:throw new Error(`unexpected parse option { from: '${u.from}' }`)}if(!this._name&&this._scriptPath)this.nameFromFilename(this._scriptPath);return this._name=this._name||"program",F}parse(D,u){this._prepareForParse();let F=this._prepareUserArgs(D,u);return this._parseCommand([],F),this}async parseAsync(D,u){this._prepareForParse();let F=this._prepareUserArgs(D,u);return await this._parseCommand([],F),this}_prepareForParse(){if(this._savedState===null)this.saveStateBeforeParse();else 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. +(Did you mean ${C[0]}?)`;return""}yC.suggestSimilar=fC});var L3=e((aC)=>{var gC=cD("events").EventEmitter,IF=cD("child_process"),B0=cD("path"),Mu=cD("fs"),y=cD("process"),{Argument:mC,humanReadableArgName:dC}=Ru(),{CommanderError:NF}=h0(),{Help:cC,stripColor:lC}=RF(),{Option:_3,DualOptions:pC}=MF(),{suggestSimilar:U3}=z3();class jF extends gC{constructor(D){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=D||"",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:(u)=>y.stdout.write(u),writeErr:(u)=>y.stderr.write(u),outputError:(u,F)=>F(u),getOutHelpWidth:()=>y.stdout.isTTY?y.stdout.columns:void 0,getErrHelpWidth:()=>y.stderr.isTTY?y.stderr.columns:void 0,getOutHasColors:()=>OF()??(y.stdout.isTTY&&y.stdout.hasColors?.()),getErrHasColors:()=>OF()??(y.stderr.isTTY&&y.stderr.hasColors?.()),stripColor:(u)=>lC(u)},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(D){return this._outputConfiguration=D._outputConfiguration,this._helpOption=D._helpOption,this._helpCommand=D._helpCommand,this._helpConfiguration=D._helpConfiguration,this._exitCallback=D._exitCallback,this._storeOptionsAsProperties=D._storeOptionsAsProperties,this._combineFlagAndOptionalValue=D._combineFlagAndOptionalValue,this._allowExcessArguments=D._allowExcessArguments,this._enablePositionalOptions=D._enablePositionalOptions,this._showHelpAfterError=D._showHelpAfterError,this._showSuggestionAfterError=D._showSuggestionAfterError,this}_getCommandAndAncestors(){let D=[];for(let u=this;u;u=u.parent)D.push(u);return D}command(D,u,F){let C=u,B=F;if(typeof C==="object"&&C!==null)B=C,C=null;B=B||{};let[,$,E]=D.match(/([^ ]+) *(.*)/),Q=this.createCommand($);if(C)Q.description(C),Q._executableHandler=!0;if(B.isDefault)this._defaultCommandName=Q._name;if(Q._hidden=!!(B.noHelp||B.hidden),Q._executableFile=B.executableFile||null,E)Q.arguments(E);if(this._registerCommand(Q),Q.parent=this,Q.copyInheritedSettings(this),C)return this;return Q}createCommand(D){return new jF(D)}createHelp(){return Object.assign(new cC,this.configureHelp())}configureHelp(D){if(D===void 0)return this._helpConfiguration;return this._helpConfiguration=D,this}configureOutput(D){if(D===void 0)return this._outputConfiguration;return this._outputConfiguration={...this._outputConfiguration,...D},this}showHelpAfterError(D=!0){if(typeof D!=="string")D=!!D;return this._showHelpAfterError=D,this}showSuggestionAfterError(D=!0){return this._showSuggestionAfterError=!!D,this}addCommand(D,u){if(!D._name)throw new Error(`Command passed to .addCommand() must have a name +- specify the name in Command constructor or using .name()`);if(u=u||{},u.isDefault)this._defaultCommandName=D._name;if(u.noHelp||u.hidden)D._hidden=!0;return this._registerCommand(D),D.parent=this,D._checkForBrokenPassThrough(),this}createArgument(D,u){return new mC(D,u)}argument(D,u,F,C){let B=this.createArgument(D,u);if(typeof F==="function")B.default(C).argParser(F);else B.default(F);return this.addArgument(B),this}arguments(D){return D.trim().split(/ +/).forEach((u)=>{this.argument(u)}),this}addArgument(D){let u=this.registeredArguments.slice(-1)[0];if(u?.variadic)throw new Error(`only the last argument can be variadic '${u.name()}'`);if(D.required&&D.defaultValue!==void 0&&D.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${D.name()}'`);return this.registeredArguments.push(D),this}helpCommand(D,u){if(typeof D==="boolean"){if(this._addImplicitHelpCommand=D,D&&this._defaultCommandGroup)this._initCommandGroup(this._getHelpCommand());return this}let F=D??"help [command]",[,C,B]=F.match(/([^ ]+) *(.*)/),$=u??"display help for command",E=this.createCommand(C);if(E.helpOption(!1),B)E.arguments(B);if($)E.description($);if(this._addImplicitHelpCommand=!0,this._helpCommand=E,D||u)this._initCommandGroup(E);return this}addHelpCommand(D,u){if(typeof D!=="object")return this.helpCommand(D,u),this;return this._addImplicitHelpCommand=!0,this._helpCommand=D,this._initCommandGroup(D),this}_getHelpCommand(){if(this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))){if(this._helpCommand===void 0)this.helpCommand(void 0,void 0);return this._helpCommand}return null}hook(D,u){let F=["preSubcommand","preAction","postAction"];if(!F.includes(D))throw new Error(`Unexpected value for event passed to hook : '${D}'. +Expecting one of '${F.join("', '")}'`);if(this._lifeCycleHooks[D])this._lifeCycleHooks[D].push(u);else this._lifeCycleHooks[D]=[u];return this}exitOverride(D){if(D)this._exitCallback=D;else this._exitCallback=(u)=>{if(u.code!=="commander.executeSubCommandAsync")throw u};return this}_exit(D,u,F){if(this._exitCallback)this._exitCallback(new NF(D,u,F));y.exit(D)}action(D){let u=(F)=>{let C=this.registeredArguments.length,B=F.slice(0,C);if(this._storeOptionsAsProperties)B[C]=this;else B[C]=this.opts();return B.push(this),D.apply(this,B)};return this._actionHandler=u,this}createOption(D,u){return new _3(D,u)}_callParseArg(D,u,F,C){try{return D.parseArg(u,F)}catch(B){if(B.code==="commander.invalidArgument"){let $=`${C} ${B.message}`;this.error($,{exitCode:B.exitCode,code:B.code})}throw B}}_registerOption(D){let u=D.short&&this._findOption(D.short)||D.long&&this._findOption(D.long);if(u){let F=D.long&&this._findOption(D.long)?D.long:D.short;throw new Error(`Cannot add option '${D.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${F}' +- already used by option '${u.flags}'`)}this._initOptionGroup(D),this.options.push(D)}_registerCommand(D){let u=(C)=>{return[C.name()].concat(C.aliases())},F=u(D).find((C)=>this._findCommand(C));if(F){let C=u(this._findCommand(F)).join("|"),B=u(D).join("|");throw new Error(`cannot add command '${B}' as already have command '${C}'`)}this._initCommandGroup(D),this.commands.push(D)}addOption(D){this._registerOption(D);let u=D.name(),F=D.attributeName();if(D.negate){let B=D.long.replace(/^--no-/,"--");if(!this._findOption(B))this.setOptionValueWithSource(F,D.defaultValue===void 0?!0:D.defaultValue,"default")}else if(D.defaultValue!==void 0)this.setOptionValueWithSource(F,D.defaultValue,"default");let C=(B,$,E)=>{if(B==null&&D.presetArg!==void 0)B=D.presetArg;let Q=this.getOptionValue(F);if(B!==null&&D.parseArg)B=this._callParseArg(D,B,Q,$);else if(B!==null&&D.variadic)B=D._collectValue(B,Q);if(B==null)if(D.negate)B=!1;else if(D.isBoolean()||D.optional)B=!0;else B="";this.setOptionValueWithSource(F,B,E)};if(this.on("option:"+u,(B)=>{let $=`error: option '${D.flags}' argument '${B}' is invalid.`;C(B,$,"cli")}),D.envVar)this.on("optionEnv:"+u,(B)=>{let $=`error: option '${D.flags}' value '${B}' from env '${D.envVar}' is invalid.`;C(B,$,"env")});return this}_optionEx(D,u,F,C,B){if(typeof u==="object"&&u instanceof _3)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let $=this.createOption(u,F);if($.makeOptionMandatory(!!D.mandatory),typeof C==="function")$.default(B).argParser(C);else if(C instanceof RegExp){let E=C;C=(Q,X)=>{let Z=E.exec(Q);return Z?Z[0]:X},$.default(B).argParser(C)}else $.default(C);return this.addOption($)}option(D,u,F,C){return this._optionEx({},D,u,F,C)}requiredOption(D,u,F,C){return this._optionEx({mandatory:!0},D,u,F,C)}combineFlagAndOptionalValue(D=!0){return this._combineFlagAndOptionalValue=!!D,this}allowUnknownOption(D=!0){return this._allowUnknownOption=!!D,this}allowExcessArguments(D=!0){return this._allowExcessArguments=!!D,this}enablePositionalOptions(D=!0){return this._enablePositionalOptions=!!D,this}passThroughOptions(D=!0){return this._passThroughOptions=!!D,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(D=!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=!!D,this}getOptionValue(D){if(this._storeOptionsAsProperties)return this[D];return this._optionValues[D]}setOptionValue(D,u){return this.setOptionValueWithSource(D,u,void 0)}setOptionValueWithSource(D,u,F){if(this._storeOptionsAsProperties)this[D]=u;else this._optionValues[D]=u;return this._optionValueSources[D]=F,this}getOptionValueSource(D){return this._optionValueSources[D]}getOptionValueSourceWithGlobals(D){let u;return this._getCommandAndAncestors().forEach((F)=>{if(F.getOptionValueSource(D)!==void 0)u=F.getOptionValueSource(D)}),u}_prepareUserArgs(D,u){if(D!==void 0&&!Array.isArray(D))throw new Error("first parameter to parse must be array or undefined");if(u=u||{},D===void 0&&u.from===void 0){if(y.versions?.electron)u.from="electron";let C=y.execArgv??[];if(C.includes("-e")||C.includes("--eval")||C.includes("-p")||C.includes("--print"))u.from="eval"}if(D===void 0)D=y.argv;this.rawArgs=D.slice();let F;switch(u.from){case void 0:case"node":this._scriptPath=D[1],F=D.slice(2);break;case"electron":if(y.defaultApp)this._scriptPath=D[1],F=D.slice(2);else F=D.slice(1);break;case"user":F=D.slice(0);break;case"eval":F=D.slice(1);break;default:throw new Error(`unexpected parse option { from: '${u.from}' }`)}if(!this._name&&this._scriptPath)this.nameFromFilename(this._scriptPath);return this._name=this._name||"program",F}parse(D,u){this._prepareForParse();let F=this._prepareUserArgs(D,u);return this._parseCommand([],F),this}async parseAsync(D,u){this._prepareForParse();let F=this._prepareUserArgs(D,u);return await this._parseCommand([],F),this}_prepareForParse(){if(this._savedState===null)this.saveStateBeforeParse();else 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. - 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(D,u,F){if(Mu.existsSync(D))return;let C=u?`searched for local subcommand relative to directory '${u}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",B=`'${D}' does not exist - if '${F}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead - if the default executable name is not suitable, use the executableFile option to supply a custom name or path - - ${C}`;throw new Error(B)}_executeSubCommand(D,u){u=u.slice();let F=!1,C=[".js",".ts",".tsx",".mjs",".cjs"];function B(Z,Y){let J=B0.resolve(Z,Y);if(Mu.existsSync(J))return J;if(C.includes(B0.extname(Y)))return;let A=C.find((H)=>Mu.existsSync(`${J}${H}`));if(A)return`${J}${A}`;return}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let $=D._executableFile||`${this._name}-${D._name}`,E=this._executableDir||"";if(this._scriptPath){let Z;try{Z=Mu.realpathSync(this._scriptPath)}catch{Z=this._scriptPath}E=B0.resolve(B0.dirname(Z),E)}if(E){let Z=B(E,$);if(!Z&&!D._executableFile&&this._scriptPath){let Y=B0.basename(this._scriptPath,B0.extname(this._scriptPath));if(Y!==this._name)Z=B(E,`${Y}-${D._name}`)}$=Z||$}F=C.includes(B0.extname($));let Q;if(y.platform!=="win32")if(F)u.unshift($),u=U3(y.execArgv).concat(u),Q=IF.spawn(y.argv[0],u,{stdio:"inherit"});else Q=IF.spawn($,u,{stdio:"inherit"});else this._checkForMissingExecutable($,E,D._name),u.unshift($),u=U3(y.execArgv).concat(u),Q=IF.spawn(y.execPath,u,{stdio:"inherit"});if(!Q.killed)["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach((Y)=>{y.on(Y,()=>{if(Q.killed===!1&&Q.exitCode===null)Q.kill(Y)})});let X=this._exitCallback;Q.on("close",(Z)=>{if(Z=Z??1,!X)y.exit(Z);else X(new NF(Z,"commander.executeSubCommandAsync","(close)"))}),Q.on("error",(Z)=>{if(Z.code==="ENOENT")this._checkForMissingExecutable($,E,D._name);else if(Z.code==="EACCES")throw new Error(`'${$}' not executable`);if(!X)y.exit(1);else{let Y=new NF(1,"commander.executeSubCommandAsync","(error)");Y.nestedError=Z,X(Y)}}),this.runningCommand=Q}_dispatchSubcommand(D,u,F){let C=this._findCommand(D);if(!C)this.help({error:!0});C._prepareForParse();let B;return B=this._chainOrCallSubCommandHook(B,C,"preSubcommand"),B=this._chainOrCall(B,()=>{if(C._executableHandler)this._executeSubCommand(C,u.concat(F));else return C._parseCommand(u,F)}),B}_dispatchHelpCommand(D){if(!D)this.help();let u=this._findCommand(D);if(u&&!u._executableHandler)u.help();return this._dispatchSubcommand(D,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){if(this.registeredArguments.forEach((D,u)=>{if(D.required&&this.args[u]==null)this.missingArgument(D.name())}),this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)return;if(this.args.length>this.registeredArguments.length)this._excessArguments(this.args)}_processArguments(){let D=(F,C,B)=>{let $=C;if(C!==null&&F.parseArg){let E=`error: command-argument value '${C}' is invalid for argument '${F.name()}'.`;$=this._callParseArg(F,C,B,E)}return $};this._checkNumberOfArguments();let u=[];this.registeredArguments.forEach((F,C)=>{let B=F.defaultValue;if(F.variadic){if(C{return D(F,E,$)},F.defaultValue)}else if(B===void 0)B=[]}else if(Cu());return u()}_chainOrCallHooks(D,u){let F=D,C=[];if(this._getCommandAndAncestors().reverse().filter((B)=>B._lifeCycleHooks[u]!==void 0).forEach((B)=>{B._lifeCycleHooks[u].forEach(($)=>{C.push({hookedCommand:B,callback:$})})}),u==="postAction")C.reverse();return C.forEach((B)=>{F=this._chainOrCall(F,()=>{return B.callback(B.hookedCommand,this)})}),F}_chainOrCallSubCommandHook(D,u,F){let C=D;if(this._lifeCycleHooks[F]!==void 0)this._lifeCycleHooks[F].forEach((B)=>{C=this._chainOrCall(C,()=>{return B(this,u)})});return C}_parseCommand(D,u){let F=this.parseOptions(u);if(this._parseOptionsEnv(),this._parseOptionsImplied(),D=D.concat(F.operands),u=F.unknown,this.args=D.concat(u),D&&this._findCommand(D[0]))return this._dispatchSubcommand(D[0],D.slice(1),u);if(this._getHelpCommand()&&D[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(D[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(u),this._dispatchSubcommand(this._defaultCommandName,D,u);if(this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName)this.help({error:!0});this._outputHelpIfRequested(F.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let C=()=>{if(F.unknown.length>0)this.unknownOption(F.unknown[0])},B=`command:${this.name()}`;if(this._actionHandler){C(),this._processArguments();let $;if($=this._chainOrCallHooks($,"preAction"),$=this._chainOrCall($,()=>this._actionHandler(this.processedArgs)),this.parent)$=this._chainOrCall($,()=>{this.parent.emit(B,D,u)});return $=this._chainOrCallHooks($,"postAction"),$}if(this.parent?.listenerCount(B))C(),this._processArguments(),this.parent.emit(B,D,u);else if(D.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",D,u);if(this.listenerCount("command:*"))this.emit("command:*",D,u);else if(this.commands.length)this.unknownCommand();else C(),this._processArguments()}else if(this.commands.length)C(),this.help({error:!0});else C(),this._processArguments()}_findCommand(D){if(!D)return;return this.commands.find((u)=>u._name===D||u._aliases.includes(D))}_findOption(D){return this.options.find((u)=>u.is(D))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach((D)=>{D.options.forEach((u)=>{if(u.mandatory&&D.getOptionValue(u.attributeName())===void 0)D.missingMandatoryOptionValue(u)})})}_checkForConflictingLocalOptions(){let D=this.options.filter((F)=>{let C=F.attributeName();if(this.getOptionValue(C)===void 0)return!1;return this.getOptionValueSource(C)!=="default"});D.filter((F)=>F.conflictsWith.length>0).forEach((F)=>{let C=D.find((B)=>F.conflictsWith.includes(B.attributeName()));if(C)this._conflictingOption(F,C)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach((D)=>{D._checkForConflictingLocalOptions()})}parseOptions(D){let u=[],F=[],C=u;function B(Z){return Z.length>1&&Z[0]==="-"}let $=(Z)=>{if(!/^-\d*\.?\d+(e[+-]?\d+)?$/.test(Z))return!1;return!this._getCommandAndAncestors().some((Y)=>Y.options.map((J)=>J.short).some((J)=>/^-\d$/.test(J)))},E=null,Q=null,X=0;while(X2&&Z[0]==="-"&&Z[1]!=="-"){let Y=this._findOption(`-${Z[1]}`);if(Y){if(Y.required||Y.optional&&this._combineFlagAndOptionalValue)this.emit(`option:${Y.name()}`,Z.slice(2));else this.emit(`option:${Y.name()}`),Q=`-${Z.slice(2)}`;continue}}if(/^--[^=]+=/.test(Z)){let Y=Z.indexOf("="),J=this._findOption(Z.slice(0,Y));if(J&&(J.required||J.optional)){this.emit(`option:${J.name()}`,Z.slice(Y+1));continue}}if(C===u&&B(Z)&&!(this.commands.length===0&&$(Z)))C=F;if((this._enablePositionalOptions||this._passThroughOptions)&&u.length===0&&F.length===0){if(this._findCommand(Z)){u.push(Z),F.push(...D.slice(X));break}else if(this._getHelpCommand()&&Z===this._getHelpCommand().name()){u.push(Z,...D.slice(X));break}else if(this._defaultCommandName){F.push(Z,...D.slice(X));break}}if(this._passThroughOptions){C.push(Z,...D.slice(X));break}C.push(Z)}return{operands:u,unknown:F}}opts(){if(this._storeOptionsAsProperties){let D={},u=this.options.length;for(let F=0;FObject.assign(D,u.opts()),{})}error(D,u){if(this._outputConfiguration.outputError(`${D} + - ${C}`;throw new Error(B)}_executeSubCommand(D,u){u=u.slice();let F=!1,C=[".js",".ts",".tsx",".mjs",".cjs"];function B(Z,Y){let J=B0.resolve(Z,Y);if(Mu.existsSync(J))return J;if(C.includes(B0.extname(Y)))return;let A=C.find((H)=>Mu.existsSync(`${J}${H}`));if(A)return`${J}${A}`;return}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let $=D._executableFile||`${this._name}-${D._name}`,E=this._executableDir||"";if(this._scriptPath){let Z;try{Z=Mu.realpathSync(this._scriptPath)}catch{Z=this._scriptPath}E=B0.resolve(B0.dirname(Z),E)}if(E){let Z=B(E,$);if(!Z&&!D._executableFile&&this._scriptPath){let Y=B0.basename(this._scriptPath,B0.extname(this._scriptPath));if(Y!==this._name)Z=B(E,`${Y}-${D._name}`)}$=Z||$}F=C.includes(B0.extname($));let Q;if(y.platform!=="win32")if(F)u.unshift($),u=W3(y.execArgv).concat(u),Q=IF.spawn(y.argv[0],u,{stdio:"inherit"});else Q=IF.spawn($,u,{stdio:"inherit"});else this._checkForMissingExecutable($,E,D._name),u.unshift($),u=W3(y.execArgv).concat(u),Q=IF.spawn(y.execPath,u,{stdio:"inherit"});if(!Q.killed)["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach((Y)=>{y.on(Y,()=>{if(Q.killed===!1&&Q.exitCode===null)Q.kill(Y)})});let X=this._exitCallback;Q.on("close",(Z)=>{if(Z=Z??1,!X)y.exit(Z);else X(new NF(Z,"commander.executeSubCommandAsync","(close)"))}),Q.on("error",(Z)=>{if(Z.code==="ENOENT")this._checkForMissingExecutable($,E,D._name);else if(Z.code==="EACCES")throw new Error(`'${$}' not executable`);if(!X)y.exit(1);else{let Y=new NF(1,"commander.executeSubCommandAsync","(error)");Y.nestedError=Z,X(Y)}}),this.runningCommand=Q}_dispatchSubcommand(D,u,F){let C=this._findCommand(D);if(!C)this.help({error:!0});C._prepareForParse();let B;return B=this._chainOrCallSubCommandHook(B,C,"preSubcommand"),B=this._chainOrCall(B,()=>{if(C._executableHandler)this._executeSubCommand(C,u.concat(F));else return C._parseCommand(u,F)}),B}_dispatchHelpCommand(D){if(!D)this.help();let u=this._findCommand(D);if(u&&!u._executableHandler)u.help();return this._dispatchSubcommand(D,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){if(this.registeredArguments.forEach((D,u)=>{if(D.required&&this.args[u]==null)this.missingArgument(D.name())}),this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)return;if(this.args.length>this.registeredArguments.length)this._excessArguments(this.args)}_processArguments(){let D=(F,C,B)=>{let $=C;if(C!==null&&F.parseArg){let E=`error: command-argument value '${C}' is invalid for argument '${F.name()}'.`;$=this._callParseArg(F,C,B,E)}return $};this._checkNumberOfArguments();let u=[];this.registeredArguments.forEach((F,C)=>{let B=F.defaultValue;if(F.variadic){if(C{return D(F,E,$)},F.defaultValue)}else if(B===void 0)B=[]}else if(Cu());return u()}_chainOrCallHooks(D,u){let F=D,C=[];if(this._getCommandAndAncestors().reverse().filter((B)=>B._lifeCycleHooks[u]!==void 0).forEach((B)=>{B._lifeCycleHooks[u].forEach(($)=>{C.push({hookedCommand:B,callback:$})})}),u==="postAction")C.reverse();return C.forEach((B)=>{F=this._chainOrCall(F,()=>{return B.callback(B.hookedCommand,this)})}),F}_chainOrCallSubCommandHook(D,u,F){let C=D;if(this._lifeCycleHooks[F]!==void 0)this._lifeCycleHooks[F].forEach((B)=>{C=this._chainOrCall(C,()=>{return B(this,u)})});return C}_parseCommand(D,u){let F=this.parseOptions(u);if(this._parseOptionsEnv(),this._parseOptionsImplied(),D=D.concat(F.operands),u=F.unknown,this.args=D.concat(u),D&&this._findCommand(D[0]))return this._dispatchSubcommand(D[0],D.slice(1),u);if(this._getHelpCommand()&&D[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(D[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(u),this._dispatchSubcommand(this._defaultCommandName,D,u);if(this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName)this.help({error:!0});this._outputHelpIfRequested(F.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let C=()=>{if(F.unknown.length>0)this.unknownOption(F.unknown[0])},B=`command:${this.name()}`;if(this._actionHandler){C(),this._processArguments();let $;if($=this._chainOrCallHooks($,"preAction"),$=this._chainOrCall($,()=>this._actionHandler(this.processedArgs)),this.parent)$=this._chainOrCall($,()=>{this.parent.emit(B,D,u)});return $=this._chainOrCallHooks($,"postAction"),$}if(this.parent?.listenerCount(B))C(),this._processArguments(),this.parent.emit(B,D,u);else if(D.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",D,u);if(this.listenerCount("command:*"))this.emit("command:*",D,u);else if(this.commands.length)this.unknownCommand();else C(),this._processArguments()}else if(this.commands.length)C(),this.help({error:!0});else C(),this._processArguments()}_findCommand(D){if(!D)return;return this.commands.find((u)=>u._name===D||u._aliases.includes(D))}_findOption(D){return this.options.find((u)=>u.is(D))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach((D)=>{D.options.forEach((u)=>{if(u.mandatory&&D.getOptionValue(u.attributeName())===void 0)D.missingMandatoryOptionValue(u)})})}_checkForConflictingLocalOptions(){let D=this.options.filter((F)=>{let C=F.attributeName();if(this.getOptionValue(C)===void 0)return!1;return this.getOptionValueSource(C)!=="default"});D.filter((F)=>F.conflictsWith.length>0).forEach((F)=>{let C=D.find((B)=>F.conflictsWith.includes(B.attributeName()));if(C)this._conflictingOption(F,C)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach((D)=>{D._checkForConflictingLocalOptions()})}parseOptions(D){let u=[],F=[],C=u;function B(Z){return Z.length>1&&Z[0]==="-"}let $=(Z)=>{if(!/^-\d*\.?\d+(e[+-]?\d+)?$/.test(Z))return!1;return!this._getCommandAndAncestors().some((Y)=>Y.options.map((J)=>J.short).some((J)=>/^-\d$/.test(J)))},E=null,Q=null,X=0;while(X2&&Z[0]==="-"&&Z[1]!=="-"){let Y=this._findOption(`-${Z[1]}`);if(Y){if(Y.required||Y.optional&&this._combineFlagAndOptionalValue)this.emit(`option:${Y.name()}`,Z.slice(2));else this.emit(`option:${Y.name()}`),Q=`-${Z.slice(2)}`;continue}}if(/^--[^=]+=/.test(Z)){let Y=Z.indexOf("="),J=this._findOption(Z.slice(0,Y));if(J&&(J.required||J.optional)){this.emit(`option:${J.name()}`,Z.slice(Y+1));continue}}if(C===u&&B(Z)&&!(this.commands.length===0&&$(Z)))C=F;if((this._enablePositionalOptions||this._passThroughOptions)&&u.length===0&&F.length===0){if(this._findCommand(Z)){u.push(Z),F.push(...D.slice(X));break}else if(this._getHelpCommand()&&Z===this._getHelpCommand().name()){u.push(Z,...D.slice(X));break}else if(this._defaultCommandName){F.push(Z,...D.slice(X));break}}if(this._passThroughOptions){C.push(Z,...D.slice(X));break}C.push(Z)}return{operands:u,unknown:F}}opts(){if(this._storeOptionsAsProperties){let D={},u=this.options.length;for(let F=0;FObject.assign(D,u.opts()),{})}error(D,u){if(this._outputConfiguration.outputError(`${D} `,this._outputConfiguration.writeErr),typeof this._showHelpAfterError==="string")this._outputConfiguration.writeErr(`${this._showHelpAfterError} `);else if(this._showHelpAfterError)this._outputConfiguration.writeErr(` -`),this.outputHelp({error:!0});let F=u||{},C=F.exitCode||1,B=F.code||"commander.error";this._exit(C,B,D)}_parseOptionsEnv(){this.options.forEach((D)=>{if(D.envVar&&D.envVar in y.env){let u=D.attributeName();if(this.getOptionValue(u)===void 0||["default","config","env"].includes(this.getOptionValueSource(u)))if(D.required||D.optional)this.emit(`optionEnv:${D.name()}`,y.env[D.envVar]);else this.emit(`optionEnv:${D.name()}`)}})}_parseOptionsImplied(){let D=new cC(this.options),u=(F)=>{return this.getOptionValue(F)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(F))};this.options.filter((F)=>F.implied!==void 0&&u(F.attributeName())&&D.valueFromOption(this.getOptionValue(F.attributeName()),F)).forEach((F)=>{Object.keys(F.implied).filter((C)=>!u(C)).forEach((C)=>{this.setOptionValueWithSource(C,F.implied[C],"implied")})})}missingArgument(D){let u=`error: missing required argument '${D}'`;this.error(u,{code:"commander.missingArgument"})}optionMissingArgument(D){let u=`error: option '${D.flags}' argument missing`;this.error(u,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(D){let u=`error: required option '${D.flags}' not specified`;this.error(u,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(D,u){let F=($)=>{let E=$.attributeName(),Q=this.getOptionValue(E),X=this.options.find((Y)=>Y.negate&&E===Y.attributeName()),Z=this.options.find((Y)=>!Y.negate&&E===Y.attributeName());if(X&&(X.presetArg===void 0&&Q===!1||X.presetArg!==void 0&&Q===X.presetArg))return X;return Z||$},C=($)=>{let E=F($),Q=E.attributeName();if(this.getOptionValueSource(Q)==="env")return`environment variable '${E.envVar}'`;return`option '${E.flags}'`},B=`error: ${C(D)} cannot be used with ${C(u)}`;this.error(B,{code:"commander.conflictingOption"})}unknownOption(D){if(this._allowUnknownOption)return;let u="";if(D.startsWith("--")&&this._showSuggestionAfterError){let C=[],B=this;do{let $=B.createHelp().visibleOptions(B).filter((E)=>E.long).map((E)=>E.long);C=C.concat($),B=B.parent}while(B&&!B._enablePositionalOptions);u=_3(D,C)}let F=`error: unknown option '${D}'${u}`;this.error(F,{code:"commander.unknownOption"})}_excessArguments(D){if(this._allowExcessArguments)return;let u=this.registeredArguments.length,F=u===1?"":"s",B=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${u} argument${F} but got ${D.length}.`;this.error(B,{code:"commander.excessArguments"})}unknownCommand(){let D=this.args[0],u="";if(this._showSuggestionAfterError){let C=[];this.createHelp().visibleCommands(this).forEach((B)=>{if(C.push(B.name()),B.alias())C.push(B.alias())}),u=_3(D,C)}let F=`error: unknown command '${D}'${u}`;this.error(F,{code:"commander.unknownCommand"})}version(D,u,F){if(D===void 0)return this._version;this._version=D,u=u||"-V, --version",F=F||"output the version number";let C=this.createOption(u,F);return this._versionOptionName=C.attributeName(),this._registerOption(C),this.on("option:"+C.name(),()=>{this._outputConfiguration.writeOut(`${D} -`),this._exit(0,"commander.version",D)}),this}description(D,u){if(D===void 0&&u===void 0)return this._description;if(this._description=D,u)this._argsDescription=u;return this}summary(D){if(D===void 0)return this._summary;return this._summary=D,this}alias(D){if(D===void 0)return this._aliases[0];let u=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler)u=this.commands[this.commands.length-1];if(D===u._name)throw new Error("Command alias can't be the same as its name");let F=this.parent?._findCommand(D);if(F){let C=[F.name()].concat(F.aliases()).join("|");throw new Error(`cannot add alias '${D}' to command '${this.name()}' as already have command '${C}'`)}return u._aliases.push(D),this}aliases(D){if(D===void 0)return this._aliases;return D.forEach((u)=>this.alias(u)),this}usage(D){if(D===void 0){if(this._usage)return this._usage;let u=this.registeredArguments.map((F)=>{return gC(F)});return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?u:[]).join(" ")}return this._usage=D,this}name(D){if(D===void 0)return this._name;return this._name=D,this}helpGroup(D){if(D===void 0)return this._helpGroupHeading??"";return this._helpGroupHeading=D,this}commandsGroup(D){if(D===void 0)return this._defaultCommandGroup??"";return this._defaultCommandGroup=D,this}optionsGroup(D){if(D===void 0)return this._defaultOptionGroup??"";return this._defaultOptionGroup=D,this}_initOptionGroup(D){if(this._defaultOptionGroup&&!D.helpGroupHeading)D.helpGroup(this._defaultOptionGroup)}_initCommandGroup(D){if(this._defaultCommandGroup&&!D.helpGroup())D.helpGroup(this._defaultCommandGroup)}nameFromFilename(D){return this._name=B0.basename(D,B0.extname(D)),this}executableDir(D){if(D===void 0)return this._executableDir;return this._executableDir=D,this}helpInformation(D){let u=this.createHelp(),F=this._getOutputContext(D);u.prepareContext({error:F.error,helpWidth:F.helpWidth,outputHasColors:F.hasColors});let C=u.formatHelp(this,u);if(F.hasColors)return C;return this._outputConfiguration.stripColor(C)}_getOutputContext(D){D=D||{};let u=!!D.error,F,C,B;if(u)F=(E)=>this._outputConfiguration.writeErr(E),C=this._outputConfiguration.getErrHasColors(),B=this._outputConfiguration.getErrHelpWidth();else F=(E)=>this._outputConfiguration.writeOut(E),C=this._outputConfiguration.getOutHasColors(),B=this._outputConfiguration.getOutHelpWidth();return{error:u,write:(E)=>{if(!C)E=this._outputConfiguration.stripColor(E);return F(E)},hasColors:C,helpWidth:B}}outputHelp(D){let u;if(typeof D==="function")u=D,D=void 0;let F=this._getOutputContext(D),C={error:F.error,write:F.write,command:this};this._getCommandAndAncestors().reverse().forEach(($)=>$.emit("beforeAllHelp",C)),this.emit("beforeHelp",C);let B=this.helpInformation({error:F.error});if(u){if(B=u(B),typeof B!=="string"&&!Buffer.isBuffer(B))throw new Error("outputHelp callback must return a string or a Buffer")}if(F.write(B),this._getHelpOption()?.long)this.emit(this._getHelpOption().long);this.emit("afterHelp",C),this._getCommandAndAncestors().forEach(($)=>$.emit("afterAllHelp",C))}helpOption(D,u){if(typeof D==="boolean"){if(D){if(this._helpOption===null)this._helpOption=void 0;if(this._defaultOptionGroup)this._initOptionGroup(this._getHelpOption())}else this._helpOption=null;return this}if(this._helpOption=this.createOption(D??"-h, --help",u??"display help for command"),D||u)this._initOptionGroup(this._helpOption);return this}_getHelpOption(){if(this._helpOption===void 0)this.helpOption(void 0,void 0);return this._helpOption}addHelpOption(D){return this._helpOption=D,this._initOptionGroup(D),this}help(D){this.outputHelp(D);let u=Number(y.exitCode??0);if(u===0&&D&&typeof D!=="function"&&D.error)u=1;this._exit(u,"commander.help","(outputHelp)")}addHelpText(D,u){let F=["beforeAll","before","after","afterAll"];if(!F.includes(D))throw new Error(`Unexpected value for position to addHelpText. +`),this.outputHelp({error:!0});let F=u||{},C=F.exitCode||1,B=F.code||"commander.error";this._exit(C,B,D)}_parseOptionsEnv(){this.options.forEach((D)=>{if(D.envVar&&D.envVar in y.env){let u=D.attributeName();if(this.getOptionValue(u)===void 0||["default","config","env"].includes(this.getOptionValueSource(u)))if(D.required||D.optional)this.emit(`optionEnv:${D.name()}`,y.env[D.envVar]);else this.emit(`optionEnv:${D.name()}`)}})}_parseOptionsImplied(){let D=new pC(this.options),u=(F)=>{return this.getOptionValue(F)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(F))};this.options.filter((F)=>F.implied!==void 0&&u(F.attributeName())&&D.valueFromOption(this.getOptionValue(F.attributeName()),F)).forEach((F)=>{Object.keys(F.implied).filter((C)=>!u(C)).forEach((C)=>{this.setOptionValueWithSource(C,F.implied[C],"implied")})})}missingArgument(D){let u=`error: missing required argument '${D}'`;this.error(u,{code:"commander.missingArgument"})}optionMissingArgument(D){let u=`error: option '${D.flags}' argument missing`;this.error(u,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(D){let u=`error: required option '${D.flags}' not specified`;this.error(u,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(D,u){let F=($)=>{let E=$.attributeName(),Q=this.getOptionValue(E),X=this.options.find((Y)=>Y.negate&&E===Y.attributeName()),Z=this.options.find((Y)=>!Y.negate&&E===Y.attributeName());if(X&&(X.presetArg===void 0&&Q===!1||X.presetArg!==void 0&&Q===X.presetArg))return X;return Z||$},C=($)=>{let E=F($),Q=E.attributeName();if(this.getOptionValueSource(Q)==="env")return`environment variable '${E.envVar}'`;return`option '${E.flags}'`},B=`error: ${C(D)} cannot be used with ${C(u)}`;this.error(B,{code:"commander.conflictingOption"})}unknownOption(D){if(this._allowUnknownOption)return;let u="";if(D.startsWith("--")&&this._showSuggestionAfterError){let C=[],B=this;do{let $=B.createHelp().visibleOptions(B).filter((E)=>E.long).map((E)=>E.long);C=C.concat($),B=B.parent}while(B&&!B._enablePositionalOptions);u=U3(D,C)}let F=`error: unknown option '${D}'${u}`;this.error(F,{code:"commander.unknownOption"})}_excessArguments(D){if(this._allowExcessArguments)return;let u=this.registeredArguments.length,F=u===1?"":"s",B=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${u} argument${F} but got ${D.length}.`;this.error(B,{code:"commander.excessArguments"})}unknownCommand(){let D=this.args[0],u="";if(this._showSuggestionAfterError){let C=[];this.createHelp().visibleCommands(this).forEach((B)=>{if(C.push(B.name()),B.alias())C.push(B.alias())}),u=U3(D,C)}let F=`error: unknown command '${D}'${u}`;this.error(F,{code:"commander.unknownCommand"})}version(D,u,F){if(D===void 0)return this._version;this._version=D,u=u||"-V, --version",F=F||"output the version number";let C=this.createOption(u,F);return this._versionOptionName=C.attributeName(),this._registerOption(C),this.on("option:"+C.name(),()=>{this._outputConfiguration.writeOut(`${D} +`),this._exit(0,"commander.version",D)}),this}description(D,u){if(D===void 0&&u===void 0)return this._description;if(this._description=D,u)this._argsDescription=u;return this}summary(D){if(D===void 0)return this._summary;return this._summary=D,this}alias(D){if(D===void 0)return this._aliases[0];let u=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler)u=this.commands[this.commands.length-1];if(D===u._name)throw new Error("Command alias can't be the same as its name");let F=this.parent?._findCommand(D);if(F){let C=[F.name()].concat(F.aliases()).join("|");throw new Error(`cannot add alias '${D}' to command '${this.name()}' as already have command '${C}'`)}return u._aliases.push(D),this}aliases(D){if(D===void 0)return this._aliases;return D.forEach((u)=>this.alias(u)),this}usage(D){if(D===void 0){if(this._usage)return this._usage;let u=this.registeredArguments.map((F)=>{return dC(F)});return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?u:[]).join(" ")}return this._usage=D,this}name(D){if(D===void 0)return this._name;return this._name=D,this}helpGroup(D){if(D===void 0)return this._helpGroupHeading??"";return this._helpGroupHeading=D,this}commandsGroup(D){if(D===void 0)return this._defaultCommandGroup??"";return this._defaultCommandGroup=D,this}optionsGroup(D){if(D===void 0)return this._defaultOptionGroup??"";return this._defaultOptionGroup=D,this}_initOptionGroup(D){if(this._defaultOptionGroup&&!D.helpGroupHeading)D.helpGroup(this._defaultOptionGroup)}_initCommandGroup(D){if(this._defaultCommandGroup&&!D.helpGroup())D.helpGroup(this._defaultCommandGroup)}nameFromFilename(D){return this._name=B0.basename(D,B0.extname(D)),this}executableDir(D){if(D===void 0)return this._executableDir;return this._executableDir=D,this}helpInformation(D){let u=this.createHelp(),F=this._getOutputContext(D);u.prepareContext({error:F.error,helpWidth:F.helpWidth,outputHasColors:F.hasColors});let C=u.formatHelp(this,u);if(F.hasColors)return C;return this._outputConfiguration.stripColor(C)}_getOutputContext(D){D=D||{};let u=!!D.error,F,C,B;if(u)F=(E)=>this._outputConfiguration.writeErr(E),C=this._outputConfiguration.getErrHasColors(),B=this._outputConfiguration.getErrHelpWidth();else F=(E)=>this._outputConfiguration.writeOut(E),C=this._outputConfiguration.getOutHasColors(),B=this._outputConfiguration.getOutHelpWidth();return{error:u,write:(E)=>{if(!C)E=this._outputConfiguration.stripColor(E);return F(E)},hasColors:C,helpWidth:B}}outputHelp(D){let u;if(typeof D==="function")u=D,D=void 0;let F=this._getOutputContext(D),C={error:F.error,write:F.write,command:this};this._getCommandAndAncestors().reverse().forEach(($)=>$.emit("beforeAllHelp",C)),this.emit("beforeHelp",C);let B=this.helpInformation({error:F.error});if(u){if(B=u(B),typeof B!=="string"&&!Buffer.isBuffer(B))throw new Error("outputHelp callback must return a string or a Buffer")}if(F.write(B),this._getHelpOption()?.long)this.emit(this._getHelpOption().long);this.emit("afterHelp",C),this._getCommandAndAncestors().forEach(($)=>$.emit("afterAllHelp",C))}helpOption(D,u){if(typeof D==="boolean"){if(D){if(this._helpOption===null)this._helpOption=void 0;if(this._defaultOptionGroup)this._initOptionGroup(this._getHelpOption())}else this._helpOption=null;return this}if(this._helpOption=this.createOption(D??"-h, --help",u??"display help for command"),D||u)this._initOptionGroup(this._helpOption);return this}_getHelpOption(){if(this._helpOption===void 0)this.helpOption(void 0,void 0);return this._helpOption}addHelpOption(D){return this._helpOption=D,this._initOptionGroup(D),this}help(D){this.outputHelp(D);let u=Number(y.exitCode??0);if(u===0&&D&&typeof D!=="function"&&D.error)u=1;this._exit(u,"commander.help","(outputHelp)")}addHelpText(D,u){let F=["beforeAll","before","after","afterAll"];if(!F.includes(D))throw new Error(`Unexpected value for position to addHelpText. Expecting one of '${F.join("', '")}'`);let C=`${D}Help`;return this.on(C,(B)=>{let $;if(typeof u==="function")$=u({error:B.error,command:B.command});else $=u;if($)B.write(`${$} -`)}),this}_outputHelpIfRequested(D){let u=this._getHelpOption();if(u&&D.find((C)=>u.is(C)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function U3(D){return D.map((u)=>{if(!u.startsWith("--inspect"))return u;let F,C="127.0.0.1",B="9229",$;if(($=u.match(/^(--inspect(-brk)?)$/))!==null)F=$[1];else if(($=u.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null)if(F=$[1],/^\d+$/.test($[3]))B=$[3];else C=$[3];else if(($=u.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null)F=$[1],C=$[3],B=$[4];if(F&&B!=="0")return`${F}=${C}:${parseInt(B)+1}`;return u})}function OF(){if(y.env.NO_COLOR||y.env.FORCE_COLOR==="0"||y.env.FORCE_COLOR==="false")return!1;if(y.env.FORCE_COLOR||y.env.CLICOLOR_FORCE!==void 0)return!0;return}lC.Command=jF;lC.useColor=OF});var I3=e((iC)=>{var{Argument:L3}=Ru(),{Command:TF}=W3(),{CommanderError:nC,InvalidArgumentError:R3}=h0(),{Help:rC}=RF(),{Option:M3}=MF();iC.program=new TF;iC.createCommand=(D)=>new TF(D);iC.createOption=(D,u)=>new M3(D,u);iC.createArgument=(D,u)=>new L3(D,u);iC.Command=TF;iC.Option=M3;iC.Argument=L3;iC.Help=rC;iC.CommanderError=nC;iC.InvalidArgumentError=R3;iC.InvalidOptionArgumentError=R3});var kF=e((b5,v3)=>{var wF={to(D,u){if(!u)return`\x1B[${D+1}G`;return`\x1B[${u+1};${D+1}H`},move(D,u){let F="";if(D<0)F+=`\x1B[${-D}D`;else if(D>0)F+=`\x1B[${D}C`;if(u<0)F+=`\x1B[${-u}A`;else if(u>0)F+=`\x1B[${u}B`;return F},up:(D=1)=>`\x1B[${D}A`,down:(D=1)=>`\x1B[${D}B`,forward:(D=1)=>`\x1B[${D}C`,backward:(D=1)=>`\x1B[${D}D`,nextLine:(D=1)=>"\x1B[E".repeat(D),prevLine:(D=1)=>"\x1B[F".repeat(D),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},K7={up:(D=1)=>"\x1B[S".repeat(D),down:(D=1)=>"\x1B[T".repeat(D)},q7={screen:"\x1B[2J",up:(D=1)=>"\x1B[1J".repeat(D),down:(D=1)=>"\x1B[J".repeat(D),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines(D){let u="";for(let F=0;F{var Nu=process||{},f3=Nu.argv||[],Iu=Nu.env||{},V7=!(!!Iu.NO_COLOR||f3.includes("--no-color"))&&(!!Iu.FORCE_COLOR||f3.includes("--color")||Nu.platform==="win32"||(Nu.stdout||{}).isTTY&&Iu.TERM!=="dumb"||!!Iu.CI),A7=(D,u,F=D)=>(C)=>{let B=""+C,$=B.indexOf(u,D.length);return~$?D+H7(B,u,F,$)+u:D+B+u},H7=(D,u,F,C)=>{let B="",$=0;do B+=D.substring($,C)+F,$=C+u.length,C=D.indexOf(u,$);while(~C);return B+D.substring($)},y3=(D=V7)=>{let u=D?A7:()=>String;return{isColorSupported:D,reset:u("\x1B[0m","\x1B[0m"),bold:u("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:u("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:u("\x1B[3m","\x1B[23m"),underline:u("\x1B[4m","\x1B[24m"),inverse:u("\x1B[7m","\x1B[27m"),hidden:u("\x1B[8m","\x1B[28m"),strikethrough:u("\x1B[9m","\x1B[29m"),black:u("\x1B[30m","\x1B[39m"),red:u("\x1B[31m","\x1B[39m"),green:u("\x1B[32m","\x1B[39m"),yellow:u("\x1B[33m","\x1B[39m"),blue:u("\x1B[34m","\x1B[39m"),magenta:u("\x1B[35m","\x1B[39m"),cyan:u("\x1B[36m","\x1B[39m"),white:u("\x1B[37m","\x1B[39m"),gray:u("\x1B[90m","\x1B[39m"),bgBlack:u("\x1B[40m","\x1B[49m"),bgRed:u("\x1B[41m","\x1B[49m"),bgGreen:u("\x1B[42m","\x1B[49m"),bgYellow:u("\x1B[43m","\x1B[49m"),bgBlue:u("\x1B[44m","\x1B[49m"),bgMagenta:u("\x1B[45m","\x1B[49m"),bgCyan:u("\x1B[46m","\x1B[49m"),bgWhite:u("\x1B[47m","\x1B[49m"),blackBright:u("\x1B[90m","\x1B[39m"),redBright:u("\x1B[91m","\x1B[39m"),greenBright:u("\x1B[92m","\x1B[39m"),yellowBright:u("\x1B[93m","\x1B[39m"),blueBright:u("\x1B[94m","\x1B[39m"),magentaBright:u("\x1B[95m","\x1B[39m"),cyanBright:u("\x1B[96m","\x1B[39m"),whiteBright:u("\x1B[97m","\x1B[39m"),bgBlackBright:u("\x1B[100m","\x1B[49m"),bgRedBright:u("\x1B[101m","\x1B[49m"),bgGreenBright:u("\x1B[102m","\x1B[49m"),bgYellowBright:u("\x1B[103m","\x1B[49m"),bgBlueBright:u("\x1B[104m","\x1B[49m"),bgMagentaBright:u("\x1B[105m","\x1B[49m"),bgCyanBright:u("\x1B[106m","\x1B[49m"),bgWhiteBright:u("\x1B[107m","\x1B[49m")}};PF.exports=y3();PF.exports.createColors=y3});var G8=e((tF,eF)=>{(function(D,u){typeof tF==="object"&&typeof eF!=="undefined"?eF.exports=u():typeof define==="function"&&define.amd?define(u):(D=typeof globalThis!=="undefined"?globalThis:D||self,D.tinycolor=u())})(tF,function(){function D(K){return D=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(V){return typeof V}:function(V){return V&&typeof Symbol=="function"&&V.constructor===Symbol&&V!==Symbol.prototype?"symbol":typeof V},D(K)}var u=/^\s+/,F=/\s+$/;function C(K,V){if(K=K?K:"",V=V||{},K instanceof C)return K;if(!(this instanceof C))return new C(K,V);var q=B(K);if(this._originalInput=K,this._r=q.r,this._g=q.g,this._b=q.b,this._a=q.a,this._roundA=Math.round(100*this._a)/100,this._format=V.format||q.format,this._gradientType=V.gradientType,this._r<1)this._r=Math.round(this._r);if(this._g<1)this._g=Math.round(this._g);if(this._b<1)this._b=Math.round(this._b);this._ok=q.ok}C.prototype={isDark:function K(){return this.getBrightness()<128},isLight:function K(){return!this.isDark()},isValid:function K(){return this._ok},getOriginalInput:function K(){return this._originalInput},getFormat:function K(){return this._format},getAlpha:function K(){return this._a},getBrightness:function K(){var V=this.toRgb();return(V.r*299+V.g*587+V.b*114)/1000},getLuminance:function K(){var V=this.toRgb(),q,_,N,L,f,h;if(q=V.r/255,_=V.g/255,N=V.b/255,q<=0.03928)L=q/12.92;else L=Math.pow((q+0.055)/1.055,2.4);if(_<=0.03928)f=_/12.92;else f=Math.pow((_+0.055)/1.055,2.4);if(N<=0.03928)h=N/12.92;else h=Math.pow((N+0.055)/1.055,2.4);return 0.2126*L+0.7152*f+0.0722*h},setAlpha:function K(V){return this._a=v(V),this._roundA=Math.round(100*this._a)/100,this},toHsv:function K(){var V=X(this._r,this._g,this._b);return{h:V.h*360,s:V.s,v:V.v,a:this._a}},toHsvString:function K(){var V=X(this._r,this._g,this._b),q=Math.round(V.h*360),_=Math.round(V.s*100),N=Math.round(V.v*100);return this._a==1?"hsv("+q+", "+_+"%, "+N+"%)":"hsva("+q+", "+_+"%, "+N+"%, "+this._roundA+")"},toHsl:function K(){var V=E(this._r,this._g,this._b);return{h:V.h*360,s:V.s,l:V.l,a:this._a}},toHslString:function K(){var V=E(this._r,this._g,this._b),q=Math.round(V.h*360),_=Math.round(V.s*100),N=Math.round(V.l*100);return this._a==1?"hsl("+q+", "+_+"%, "+N+"%)":"hsla("+q+", "+_+"%, "+N+"%, "+this._roundA+")"},toHex:function K(V){return Y(this._r,this._g,this._b,V)},toHexString:function K(V){return"#"+this.toHex(V)},toHex8:function K(V){return J(this._r,this._g,this._b,this._a,V)},toHex8String:function K(V){return"#"+this.toHex8(V)},toRgb:function K(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function K(){return this._a==1?"rgb("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+")":"rgba("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+", "+this._roundA+")"},toPercentageRgb:function K(){return{r:Math.round(w(this._r,255)*100)+"%",g:Math.round(w(this._g,255)*100)+"%",b:Math.round(w(this._b,255)*100)+"%",a:this._a}},toPercentageRgbString:function K(){return this._a==1?"rgb("+Math.round(w(this._r,255)*100)+"%, "+Math.round(w(this._g,255)*100)+"%, "+Math.round(w(this._b,255)*100)+"%)":"rgba("+Math.round(w(this._r,255)*100)+"%, "+Math.round(w(this._g,255)*100)+"%, "+Math.round(w(this._b,255)*100)+"%, "+this._roundA+")"},toName:function K(){if(this._a===0)return"transparent";if(this._a<1)return!1;return T[Y(this._r,this._g,this._b,!0)]||!1},toFilter:function K(V){var q="#"+A(this._r,this._g,this._b,this._a),_=q,N=this._gradientType?"GradientType = 1, ":"";if(V){var L=C(V);_="#"+A(L._r,L._g,L._b,L._a)}return"progid:DXImageTransform.Microsoft.gradient("+N+"startColorstr="+q+",endColorstr="+_+")"},toString:function K(V){var q=!!V;V=V||this._format;var _=!1,N=this._a<1&&this._a>=0,L=!q&&N&&(V==="hex"||V==="hex6"||V==="hex3"||V==="hex4"||V==="hex8"||V==="name");if(L){if(V==="name"&&this._a===0)return this.toName();return this.toRgbString()}if(V==="rgb")_=this.toRgbString();if(V==="prgb")_=this.toPercentageRgbString();if(V==="hex"||V==="hex6")_=this.toHexString();if(V==="hex3")_=this.toHexString(!0);if(V==="hex4")_=this.toHex8String(!0);if(V==="hex8")_=this.toHex8String();if(V==="name")_=this.toName();if(V==="hsl")_=this.toHslString();if(V==="hsv")_=this.toHsvString();return _||this.toHexString()},clone:function K(){return C(this.toString())},_applyModification:function K(V,q){var _=V.apply(null,[this].concat([].slice.call(q)));return this._r=_._r,this._g=_._g,this._b=_._b,this.setAlpha(_._a),this},lighten:function K(){return this._applyModification(U,arguments)},brighten:function K(){return this._applyModification(I,arguments)},darken:function K(){return this._applyModification(j,arguments)},desaturate:function K(){return this._applyModification(H,arguments)},saturate:function K(){return this._applyModification(G,arguments)},greyscale:function K(){return this._applyModification(z,arguments)},spin:function K(){return this._applyModification(R,arguments)},_applyCombination:function K(V,q){return V.apply(null,[this].concat([].slice.call(q)))},analogous:function K(){return this._applyCombination(AD,arguments)},complement:function K(){return this._applyCombination(M,arguments)},monochromatic:function K(){return this._applyCombination(wD,arguments)},splitcomplement:function K(){return this._applyCombination(x,arguments)},triad:function K(){return this._applyCombination(P,[3])},tetrad:function K(){return this._applyCombination(P,[4])}},C.fromRatio=function(K,V){if(D(K)=="object"){var q={};for(var _ in K)if(K.hasOwnProperty(_))if(_==="a")q[_]=K[_];else q[_]=ZD(K[_]);K=q}return C(K,V)};function B(K){var V={r:0,g:0,b:0},q=1,_=null,N=null,L=null,f=!1,h=!1;if(typeof K=="string")K=f0(K);if(D(K)=="object"){if(YD(K.r)&&YD(K.g)&&YD(K.b))V=$(K.r,K.g,K.b),f=!0,h=String(K.r).substr(-1)==="%"?"prgb":"rgb";else if(YD(K.h)&&YD(K.s)&&YD(K.v))_=ZD(K.s),N=ZD(K.v),V=Z(K.h,_,N),f=!0,h="hsv";else if(YD(K.h)&&YD(K.s)&&YD(K.l))_=ZD(K.s),L=ZD(K.l),V=Q(K.h,_,L),f=!0,h="hsl";if(K.hasOwnProperty("a"))q=K.a}return q=v(q),{ok:f,format:K.format||h,r:Math.min(255,Math.max(V.r,0)),g:Math.min(255,Math.max(V.g,0)),b:Math.min(255,Math.max(V.b,0)),a:q}}function $(K,V,q){return{r:w(K,255)*255,g:w(V,255)*255,b:w(q,255)*255}}function E(K,V,q){K=w(K,255),V=w(V,255),q=w(q,255);var _=Math.max(K,V,q),N=Math.min(K,V,q),L,f,h=(_+N)/2;if(_==N)L=f=0;else{var i=_-N;switch(f=h>0.5?i/(2-_-N):i/(_+N),_){case K:L=(V-q)/i+(V1)dD-=1;if(dD<0.16666666666666666)return kD+(y0-kD)*6*dD;if(dD<0.5)return y0;if(dD<0.6666666666666666)return kD+(y0-kD)*(0.6666666666666666-dD)*6;return kD}if(V===0)_=N=L=q;else{var h=q<0.5?q*(1+V):q+V-q*V,i=2*q-h;_=f(i,h,K+0.3333333333333333),N=f(i,h,K),L=f(i,h,K-0.3333333333333333)}return{r:_*255,g:N*255,b:L*255}}function X(K,V,q){K=w(K,255),V=w(V,255),q=w(q,255);var _=Math.max(K,V,q),N=Math.min(K,V,q),L,f,h=_,i=_-N;if(f=_===0?0:i/_,_==N)L=0;else{switch(_){case K:L=(V-q)/i+(V>1)+720)%360;--V;)_.h=(_.h+N)%360,L.push(C(_));return L}function wD(K,V){V=V||6;var q=C(K).toHsv(),_=q.h,N=q.s,L=q.v,f=[],h=1/V;while(V--)f.push(C({h:_,s:N,v:L})),L=(L+h)%1;return f}C.mix=function(K,V,q){q=q===0?0:q||50;var _=C(K).toRgb(),N=C(V).toRgb(),L=q/100,f={r:(N.r-_.r)*L+_.r,g:(N.g-_.g)*L+_.g,b:(N.b-_.b)*L+_.b,a:(N.a-_.a)*L+_.a};return C(f)},C.readability=function(K,V){var q=C(K),_=C(V);return(Math.max(q.getLuminance(),_.getLuminance())+0.05)/(Math.min(q.getLuminance(),_.getLuminance())+0.05)},C.isReadable=function(K,V,q){var _=C.readability(K,V),N,L;switch(L=!1,N=UF(q),N.level+N.size){case"AAsmall":case"AAAlarge":L=_>=4.5;break;case"AAlarge":L=_>=3;break;case"AAAsmall":L=_>=7;break}return L},C.mostReadable=function(K,V,q){var _=null,N=0,L,f,h,i;q=q||{},f=q.includeFallbackColors,h=q.level,i=q.size;for(var kD=0;kDN)N=L,_=C(V[kD]);if(C.isReadable(K,_,{level:h,size:i})||!f)return _;else return q.includeFallbackColors=!1,C.mostReadable(K,["#fff","#000"],q)};var W=C.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},T=C.hexNames=b(W);function b(K){var V={};for(var q in K)if(K.hasOwnProperty(q))V[K[q]]=q;return V}function v(K){if(K=parseFloat(K),isNaN(K)||K<0||K>1)K=1;return K}function w(K,V){if(gD(K))K="100%";var q=Q0(K);if(K=Math.min(V,Math.max(0,parseFloat(K))),q)K=parseInt(K*V,10)/100;if(Math.abs(K-V)<0.000001)return 1;return K%V/parseFloat(V)}function g(K){return Math.min(1,Math.max(0,K))}function m(K){return parseInt(K,16)}function gD(K){return typeof K=="string"&&K.indexOf(".")!=-1&&parseFloat(K)===1}function Q0(K){return typeof K==="string"&&K.indexOf("%")!=-1}function r(K){return K.length==1?"0"+K:""+K}function ZD(K){if(K<=1)K=K*100+"%";return K}function mD(K){return Math.round(parseFloat(K)*255).toString(16)}function u0(K){return m(K)/255}var $D=function(){var K="[-\\+]?\\d+%?",V="[-\\+]?\\d*\\.\\d+%?",q="(?:"+V+")|(?:"+K+")",_="[\\s|\\(]+("+q+")[,|\\s]+("+q+")[,|\\s]+("+q+")\\s*\\)?",N="[\\s|\\(]+("+q+")[,|\\s]+("+q+")[,|\\s]+("+q+")[,|\\s]+("+q+")\\s*\\)?";return{CSS_UNIT:new RegExp(q),rgb:new RegExp("rgb"+_),rgba:new RegExp("rgba"+N),hsl:new RegExp("hsl"+_),hsla:new RegExp("hsla"+N),hsv:new RegExp("hsv"+_),hsva:new RegExp("hsva"+N),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();function YD(K){return!!$D.CSS_UNIT.exec(K)}function f0(K){K=K.replace(u,"").replace(F,"").toLowerCase();var V=!1;if(W[K])K=W[K],V=!0;else if(K=="transparent")return{r:0,g:0,b:0,a:0,format:"name"};var q;if(q=$D.rgb.exec(K))return{r:q[1],g:q[2],b:q[3]};if(q=$D.rgba.exec(K))return{r:q[1],g:q[2],b:q[3],a:q[4]};if(q=$D.hsl.exec(K))return{h:q[1],s:q[2],l:q[3]};if(q=$D.hsla.exec(K))return{h:q[1],s:q[2],l:q[3],a:q[4]};if(q=$D.hsv.exec(K))return{h:q[1],s:q[2],v:q[3]};if(q=$D.hsva.exec(K))return{h:q[1],s:q[2],v:q[3],a:q[4]};if(q=$D.hex8.exec(K))return{r:m(q[1]),g:m(q[2]),b:m(q[3]),a:u0(q[4]),format:V?"name":"hex8"};if(q=$D.hex6.exec(K))return{r:m(q[1]),g:m(q[2]),b:m(q[3]),format:V?"name":"hex"};if(q=$D.hex4.exec(K))return{r:m(q[1]+""+q[1]),g:m(q[2]+""+q[2]),b:m(q[3]+""+q[3]),a:u0(q[4]+""+q[4]),format:V?"name":"hex8"};if(q=$D.hex3.exec(K))return{r:m(q[1]+""+q[1]),g:m(q[2]+""+q[2]),b:m(q[3]+""+q[3]),format:V?"name":"hex"};return!1}function UF(K){var V,q;if(K=K||{level:"AA",size:"small"},V=(K.level||"AA").toUpperCase(),q=(K.size||"small").toLowerCase(),V!=="AA"&&V!=="AAA")V="AA";if(q!=="small"&&q!=="large")q="small";return{level:V,size:q}}return C})});var M8=e((z$,R8)=>{var l0=G8(),W8={r:256,g:256,b:256,a:1},L8={h:360,s:1,v:1,a:1};function u2(D,u,F){let C={};for(let B in D)if(D.hasOwnProperty(B))C[B]=F===0?0:(u[B]-D[B])/F;return C}function F2(D,u,F,C){let B={};for(let $ in u)if(u.hasOwnProperty($))B[$]=D[$]*F+u[$],B[$]=B[$]<0?B[$]+C[$]:C[$]!==1?B[$]%C[$]:B[$];return B}function D2(D,u,F){let C=D.color.toRgb(),B=u.color.toRgb(),$=u2(C,B,F),E=[D.color];for(let Q=1;Q$.h&&B.h-$.h>180;E=C==="long"&&Y||C==="short"&&!Y}let Q=u2(B,$,F),X=[D.color],Z;if(B.h<=$.h&&!E||B.h>=$.h&&E)Z=$.h-B.h;else if(E)Z=360-$.h+B.h;else Z=360-B.h+$.h;Q.h=Math.pow(-1,E?1:0)*Math.abs(Z)/F;for(let Y=1;Y1)throw new Error("Position must be between 0 and 1");let B,$;for(let X=0,Z=D.length;X=D[X].pos&&u{let Q=$.pos!==void 0;if(u^Q)throw new Error("Cannot mix positionned and not posionned color stops");if(Q){let X=$.color!==void 0;if(!X&&(B||E===0||E===F-1))throw new Error("Cannot define two consecutive position-only stops");if(B=!X,$={color:X?l0($.color):null,colorLess:!X,pos:$.pos},$.pos<0||$.pos>1)throw new Error("Color stops positions must be between 0 and 1");else if($.pos{D.push({color:F.color,pos:F.pos/2})}),this.stops.slice(0,-1).forEach((F)=>{u.push({color:F.color,pos:1-F.pos/2})}),new vu(D.concat(u.reverse()))}rgb(D){let u=_8(this.stops,D),F=[];this.stops.forEach((C,B)=>{if(C.colorLess)C.color=D2(this.stops[B-1],this.stops[B+1],2)[1]});for(let C=0,B=this.stops.length;C{if(B.colorLess)B.color=z8(this.stops[$-1],this.stops[$+1],2,u)[1]});for(let B=0,$=this.stops.length;B<$-1;B++){let E=z8(this.stops[B],this.stops[B+1],F[B],u);C.splice(C.length,0,...E)}return C.push(this.stops[this.stops.length-1].color),C}css(D,u){D=D||"linear",u=u||(D==="linear"?"to right":"ellipse at center");let F=D+"-gradient("+u;return this.stops.forEach(function(C){F+=", "+(C.colorLess?"":C.color.toRgbString()+" ")+C.pos*100+"%"}),F+=")",F}rgbAt(D){return U8(this.stops,D,"toRgb",W8)}hsvAt(D){return U8(this.stops,D,"toHsv",L8)}}R8.exports=function(D){if(arguments.length===1){if(!Array.isArray(arguments[0]))throw new Error('"stops" is not an array');D=arguments[0]}else D=Array.prototype.slice.call(arguments);return new vu(D)}});var k8=e((b$,j9)=>{j9.exports={single:{topLeft:"\u250C",top:"\u2500",topRight:"\u2510",right:"\u2502",bottomRight:"\u2518",bottom:"\u2500",bottomLeft:"\u2514",left:"\u2502"},double:{topLeft:"\u2554",top:"\u2550",topRight:"\u2557",right:"\u2551",bottomRight:"\u255D",bottom:"\u2550",bottomLeft:"\u255A",left:"\u2551"},round:{topLeft:"\u256D",top:"\u2500",topRight:"\u256E",right:"\u2502",bottomRight:"\u256F",bottom:"\u2500",bottomLeft:"\u2570",left:"\u2502"},bold:{topLeft:"\u250F",top:"\u2501",topRight:"\u2513",right:"\u2503",bottomRight:"\u251B",bottom:"\u2501",bottomLeft:"\u2517",left:"\u2503"},singleDouble:{topLeft:"\u2553",top:"\u2500",topRight:"\u2556",right:"\u2551",bottomRight:"\u255C",bottom:"\u2500",bottomLeft:"\u2559",left:"\u2551"},doubleSingle:{topLeft:"\u2552",top:"\u2550",topRight:"\u2555",right:"\u2502",bottomRight:"\u255B",bottom:"\u2550",bottomLeft:"\u2558",left:"\u2502"},classic:{topLeft:"+",top:"-",topRight:"+",right:"|",bottomRight:"+",bottom:"-",bottomLeft:"+",left:"|"},arrow:{topLeft:"\u2198",top:"\u2193",topRight:"\u2199",right:"\u2190",bottomRight:"\u2196",bottom:"\u2191",bottomLeft:"\u2197",left:"\u2192"}}});var X2=e((v$,Q2)=>{var P8=k8();Q2.exports=P8;Q2.exports.default=P8});var y8=e((y$,f8)=>{f8.exports=({onlyFirst:D=!1}={})=>{let u=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(u,D?void 0:"g")}});var g8=e((h$,h8)=>{var b9=y8();h8.exports=(D)=>typeof D==="string"?D.replace(b9(),""):D});var d8=e((g$,J2)=>{var m8=(D)=>{if(Number.isNaN(D))return!1;if(D>=4352&&(D<=4447||D===9001||D===9002||11904<=D&&D<=12871&&D!==12351||12880<=D&&D<=19903||19968<=D&&D<=42182||43360<=D&&D<=43388||44032<=D&&D<=55203||63744<=D&&D<=64255||65040<=D&&D<=65049||65072<=D&&D<=65131||65281<=D&&D<=65376||65504<=D&&D<=65510||110592<=D&&D<=110593||127488<=D&&D<=127569||131072<=D&&D<=262141))return!0;return!1};J2.exports=m8;J2.exports.default=m8});var l8=e((m$,c8)=>{c8.exports=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F|\uD83D\uDC68(?:\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68\uD83C\uDFFB|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|[\u2695\u2696\u2708]\uFE0F|\uD83D[\uDC66\uDC67]|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708])\uFE0F|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C[\uDFFB-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)\uD83C\uDFFB|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB\uDFFC])|\uD83D\uDC69(?:\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB-\uDFFD])|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|(?:(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)\uFE0F|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\u200D[\u2640\u2642])|\uD83C\uDFF4\u200D\u2620)\uFE0F|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF4\uD83C\uDDF2|\uD83C\uDDF6\uD83C\uDDE6|[#\*0-9]\uFE0F\u20E3|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270A-\u270D]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC70\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDCAA\uDD74\uDD7A\uDD90\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD36\uDDB5\uDDB6\uDDBB\uDDD2-\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5\uDEEB\uDEEC\uDEF4-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g}});var a8=e((d$,K2)=>{var v9=g8(),f9=d8(),y9=l8(),p8=(D)=>{if(typeof D!=="string"||D.length===0)return 0;if(D=v9(D),D.length===0)return 0;D=D.replace(y9()," ");let u=0;for(let F=0;F=127&&C<=159)continue;if(C>=768&&C<=879)continue;if(C>65535)F++;u+=f9(C)?2:1}return u};K2.exports=p8;K2.exports.default=p8});var r8=e((c$,n8)=>{var h9=a8();function H0(D,u){if(!D)return D;u=u||{};let F=u.align||"center";if(F==="left")return D;let C=u.split||` -`,B=u.pad||" ",$=F!=="right"?g9:m9,E=!1;if(!Array.isArray(D))E=!0,D=String(D).split(C);let Q,X=0;return D=D.map(function(Z){return Z=String(Z),Q=h9(Z),X=Math.max(Q,X),{str:Z,width:Q}}).map(function(Z){return new Array($(X,Z.width)+1).join(B)+Z.str}),E?D.join(C):D}H0.left=function D(u){return H0(u,{align:"left"})};H0.center=function D(u){return H0(u,{align:"center"})};H0.right=function D(u){return H0(u,{align:"right"})};n8.exports=H0;function g9(D,u){return Math.floor((D-u)/2)}function m9(D,u){return D-u}});import{join as s,dirname as cu,sep as $B}from"path";import{homedir as G2}from"os";import{existsSync as r0,statSync as QB}from"fs";import{execSync as X6}from"child_process";import{fileURLToPath as XB}from"url";class k{static instance=null;_dataDirectory=null;_packageRoot=null;_claudeConfigDirectory=null;static getInstance(){if(!k.instance)k.instance=new k;return k.instance}getDataDirectory(){if(this._dataDirectory)return this._dataDirectory;return this._dataDirectory=process.env.CLAUDE_MEM_DATA_DIR||s(G2(),".claude-mem"),this._dataDirectory}getArchivesDirectory(){return s(this.getDataDirectory(),"archives")}getHooksDirectory(){return s(this.getDataDirectory(),"hooks")}getLogsDirectory(){return s(this.getDataDirectory(),"logs")}getIndexDirectory(){return this.getDataDirectory()}getIndexPath(){return s(this.getIndexDirectory(),"claude-mem-index.jsonl")}getTrashDirectory(){return s(this.getDataDirectory(),"trash")}getBackupsDirectory(){return s(this.getDataDirectory(),"backups")}getChromaDirectory(){return s(this.getDataDirectory(),"chroma")}getProjectArchiveDirectory(D){return s(this.getArchivesDirectory(),D)}getUserSettingsPath(){return s(this.getDataDirectory(),"settings.json")}getClaudeConfigDirectory(){if(this._claudeConfigDirectory)return this._claudeConfigDirectory;return this._claudeConfigDirectory=process.env.CLAUDE_CONFIG_DIR||s(G2(),".claude"),this._claudeConfigDirectory}getClaudeSettingsPath(){return s(this.getClaudeConfigDirectory(),"settings.json")}getClaudeCommandsDirectory(){return s(this.getClaudeConfigDirectory(),"commands")}getClaudeMdPath(){return s(this.getClaudeConfigDirectory(),"CLAUDE.md")}getMcpConfigPath(){return s(G2(),".claude.json")}getProjectMcpConfigPath(){return s(process.cwd(),".mcp.json")}getPackageRoot(){if(this._packageRoot)return this._packageRoot;try{let F=cD.resolve("claude-mem/package.json");return this._packageRoot=cu(F),this._packageRoot}catch{}let D=XB(import.meta.url),u=cu(D);for(let F=0;F<10;F++){let C=s(u,"package.json");if(r0(C)){if(cD(C).name==="claude-mem")return this._packageRoot=u,this._packageRoot}let B=cu(u);if(B===u)break;u=B}try{let F=X6("npm list -g claude-mem --json 2>/dev/null || npm list claude-mem --json 2>/dev/null",{encoding:"utf8"}),C=JSON.parse(F);if(C.dependencies?.["claude-mem"]?.resolved)return this._packageRoot=cu(C.dependencies["claude-mem"].resolved),this._packageRoot}catch{}throw new Error("Cannot locate claude-mem package root. Ensure claude-mem is properly installed.")}findPackageHookTemplatesDirectory(){let D=this.getPackageRoot(),u=s(D,"hook-templates"),F=["session-start.js","stop.js","user-prompt-submit.js","post-tool-use.js"];for(let C of F)if(!r0(s(u,C)))throw new Error(`Package hook-templates directory missing required template file: ${C}`);return u}findPackageCommandsDirectory(){let D=this.getPackageRoot(),u=s(D,"commands"),F=["save.md"];for(let C of F)if(!r0(s(u,C)))throw new Error(`Package commands directory missing required file: ${C}`);return u}ensureDirectory(D){if(!r0(D))cD("fs").mkdirSync(D,{recursive:!0})}ensureDirectories(D){D.forEach((u)=>this.ensureDirectory(u))}ensureAllDataDirectories(){this.ensureDirectories([this.getDataDirectory(),this.getArchivesDirectory(),this.getHooksDirectory(),this.getLogsDirectory(),this.getTrashDirectory(),this.getBackupsDirectory(),this.getChromaDirectory()])}ensureAllClaudeDirectories(){this.ensureDirectories([this.getClaudeConfigDirectory(),this.getClaudeCommandsDirectory()])}static extractProjectName(D){let u=D.split($B),F=["src","lib","app","project","workspace"];for(let C=u.length-1;C>=0;C--)if(F.includes(u[C])&&C>0)return u[C-1];if(u.length>1)return u[u.length-2];return"unknown-project"}static getCurrentProjectName(){try{let D=X6("git rev-parse --show-toplevel",{cwd:process.cwd(),encoding:"utf8",stdio:["pipe","pipe","ignore"]}).trim();return cD("path").basename(D)}catch{return cD("path").basename(process.cwd())}}static createBackupFilename(D){let u=new Date().toISOString().replace(/[:.]/g,"-").replace("T","_").slice(0,19);return`${D}.backup.${u}`}static isPathAccessible(D){return r0(D)&&QB(D).isDirectory()}}var qD=()=>{};var G6={};C0(G6,{initializeDatabase:()=>L2,getDatabase:()=>_D,DatabaseManager:()=>jD,Database:()=>H6});import{Database as H6}from"bun:sqlite";import wB from"path";import kB from"fs";class jD{static instance;db=null;migrations=[];static getInstance(){if(!jD.instance)jD.instance=new jD;return jD.instance}registerMigration(D){this.migrations.push(D),this.migrations.sort((u,F)=>u.version-F.version)}async initialize(){if(this.db)return this.db;let D=k.getInstance().getDataDirectory();kB.mkdirSync(D,{recursive:!0});let u=wB.join(D,"claude-mem.db");return this.db=new H6(u,{create:!0,readwrite:!0}),this.db.run("PRAGMA journal_mode = WAL"),this.db.run("PRAGMA synchronous = NORMAL"),this.db.run("PRAGMA foreign_keys = ON"),this.db.run("PRAGMA temp_store = memory"),this.db.run("PRAGMA mmap_size = 268435456"),this.db.run("PRAGMA cache_size = 10000"),this.initializeSchemaVersions(),await this.runMigrations(),nu=this.db,this.db}getConnection(){if(!this.db)throw new Error("Database not initialized. Call initialize() first.");return this.db}withTransaction(D){let u=this.getConnection();return u.transaction(D)(u)}close(){if(this.db)this.db.close(),this.db=null,nu=null}initializeSchemaVersions(){if(!this.db)return;this.db.run(` +`)}),this}_outputHelpIfRequested(D){let u=this._getHelpOption();if(u&&D.find((C)=>u.is(C)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function W3(D){return D.map((u)=>{if(!u.startsWith("--inspect"))return u;let F,C="127.0.0.1",B="9229",$;if(($=u.match(/^(--inspect(-brk)?)$/))!==null)F=$[1];else if(($=u.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null)if(F=$[1],/^\d+$/.test($[3]))B=$[3];else C=$[3];else if(($=u.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null)F=$[1],C=$[3],B=$[4];if(F&&B!=="0")return`${F}=${C}:${parseInt(B)+1}`;return u})}function OF(){if(y.env.NO_COLOR||y.env.FORCE_COLOR==="0"||y.env.FORCE_COLOR==="false")return!1;if(y.env.FORCE_COLOR||y.env.CLICOLOR_FORCE!==void 0)return!0;return}aC.Command=jF;aC.useColor=OF});var N3=e((sC)=>{var{Argument:R3}=Ru(),{Command:TF}=L3(),{CommanderError:iC,InvalidArgumentError:M3}=h0(),{Help:oC}=RF(),{Option:I3}=MF();sC.program=new TF;sC.createCommand=(D)=>new TF(D);sC.createOption=(D,u)=>new I3(D,u);sC.createArgument=(D,u)=>new R3(D,u);sC.Command=TF;sC.Option=I3;sC.Argument=R3;sC.Help=oC;sC.CommanderError=iC;sC.InvalidArgumentError=M3;sC.InvalidOptionArgumentError=M3});var kF=e((f5,f3)=>{var wF={to(D,u){if(!u)return`\x1B[${D+1}G`;return`\x1B[${u+1};${D+1}H`},move(D,u){let F="";if(D<0)F+=`\x1B[${-D}D`;else if(D>0)F+=`\x1B[${D}C`;if(u<0)F+=`\x1B[${-u}A`;else if(u>0)F+=`\x1B[${u}B`;return F},up:(D=1)=>`\x1B[${D}A`,down:(D=1)=>`\x1B[${D}B`,forward:(D=1)=>`\x1B[${D}C`,backward:(D=1)=>`\x1B[${D}D`,nextLine:(D=1)=>"\x1B[E".repeat(D),prevLine:(D=1)=>"\x1B[F".repeat(D),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},V7={up:(D=1)=>"\x1B[S".repeat(D),down:(D=1)=>"\x1B[T".repeat(D)},A7={screen:"\x1B[2J",up:(D=1)=>"\x1B[1J".repeat(D),down:(D=1)=>"\x1B[J".repeat(D),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines(D){let u="";for(let F=0;F{var Nu=process||{},y3=Nu.argv||[],Iu=Nu.env||{},H7=!(!!Iu.NO_COLOR||y3.includes("--no-color"))&&(!!Iu.FORCE_COLOR||y3.includes("--color")||Nu.platform==="win32"||(Nu.stdout||{}).isTTY&&Iu.TERM!=="dumb"||!!Iu.CI),G7=(D,u,F=D)=>(C)=>{let B=""+C,$=B.indexOf(u,D.length);return~$?D+z7(B,u,F,$)+u:D+B+u},z7=(D,u,F,C)=>{let B="",$=0;do B+=D.substring($,C)+F,$=C+u.length,C=D.indexOf(u,$);while(~C);return B+D.substring($)},h3=(D=H7)=>{let u=D?G7:()=>String;return{isColorSupported:D,reset:u("\x1B[0m","\x1B[0m"),bold:u("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:u("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:u("\x1B[3m","\x1B[23m"),underline:u("\x1B[4m","\x1B[24m"),inverse:u("\x1B[7m","\x1B[27m"),hidden:u("\x1B[8m","\x1B[28m"),strikethrough:u("\x1B[9m","\x1B[29m"),black:u("\x1B[30m","\x1B[39m"),red:u("\x1B[31m","\x1B[39m"),green:u("\x1B[32m","\x1B[39m"),yellow:u("\x1B[33m","\x1B[39m"),blue:u("\x1B[34m","\x1B[39m"),magenta:u("\x1B[35m","\x1B[39m"),cyan:u("\x1B[36m","\x1B[39m"),white:u("\x1B[37m","\x1B[39m"),gray:u("\x1B[90m","\x1B[39m"),bgBlack:u("\x1B[40m","\x1B[49m"),bgRed:u("\x1B[41m","\x1B[49m"),bgGreen:u("\x1B[42m","\x1B[49m"),bgYellow:u("\x1B[43m","\x1B[49m"),bgBlue:u("\x1B[44m","\x1B[49m"),bgMagenta:u("\x1B[45m","\x1B[49m"),bgCyan:u("\x1B[46m","\x1B[49m"),bgWhite:u("\x1B[47m","\x1B[49m"),blackBright:u("\x1B[90m","\x1B[39m"),redBright:u("\x1B[91m","\x1B[39m"),greenBright:u("\x1B[92m","\x1B[39m"),yellowBright:u("\x1B[93m","\x1B[39m"),blueBright:u("\x1B[94m","\x1B[39m"),magentaBright:u("\x1B[95m","\x1B[39m"),cyanBright:u("\x1B[96m","\x1B[39m"),whiteBright:u("\x1B[97m","\x1B[39m"),bgBlackBright:u("\x1B[100m","\x1B[49m"),bgRedBright:u("\x1B[101m","\x1B[49m"),bgGreenBright:u("\x1B[102m","\x1B[49m"),bgYellowBright:u("\x1B[103m","\x1B[49m"),bgBlueBright:u("\x1B[104m","\x1B[49m"),bgMagentaBright:u("\x1B[105m","\x1B[49m"),bgCyanBright:u("\x1B[106m","\x1B[49m"),bgWhiteBright:u("\x1B[107m","\x1B[49m")}};PF.exports=h3();PF.exports.createColors=h3});var z8=e((tF,eF)=>{(function(D,u){typeof tF==="object"&&typeof eF!=="undefined"?eF.exports=u():typeof define==="function"&&define.amd?define(u):(D=typeof globalThis!=="undefined"?globalThis:D||self,D.tinycolor=u())})(tF,function(){function D(K){return D=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(V){return typeof V}:function(V){return V&&typeof Symbol=="function"&&V.constructor===Symbol&&V!==Symbol.prototype?"symbol":typeof V},D(K)}var u=/^\s+/,F=/\s+$/;function C(K,V){if(K=K?K:"",V=V||{},K instanceof C)return K;if(!(this instanceof C))return new C(K,V);var q=B(K);if(this._originalInput=K,this._r=q.r,this._g=q.g,this._b=q.b,this._a=q.a,this._roundA=Math.round(100*this._a)/100,this._format=V.format||q.format,this._gradientType=V.gradientType,this._r<1)this._r=Math.round(this._r);if(this._g<1)this._g=Math.round(this._g);if(this._b<1)this._b=Math.round(this._b);this._ok=q.ok}C.prototype={isDark:function K(){return this.getBrightness()<128},isLight:function K(){return!this.isDark()},isValid:function K(){return this._ok},getOriginalInput:function K(){return this._originalInput},getFormat:function K(){return this._format},getAlpha:function K(){return this._a},getBrightness:function K(){var V=this.toRgb();return(V.r*299+V.g*587+V.b*114)/1000},getLuminance:function K(){var V=this.toRgb(),q,_,N,L,f,h;if(q=V.r/255,_=V.g/255,N=V.b/255,q<=0.03928)L=q/12.92;else L=Math.pow((q+0.055)/1.055,2.4);if(_<=0.03928)f=_/12.92;else f=Math.pow((_+0.055)/1.055,2.4);if(N<=0.03928)h=N/12.92;else h=Math.pow((N+0.055)/1.055,2.4);return 0.2126*L+0.7152*f+0.0722*h},setAlpha:function K(V){return this._a=v(V),this._roundA=Math.round(100*this._a)/100,this},toHsv:function K(){var V=X(this._r,this._g,this._b);return{h:V.h*360,s:V.s,v:V.v,a:this._a}},toHsvString:function K(){var V=X(this._r,this._g,this._b),q=Math.round(V.h*360),_=Math.round(V.s*100),N=Math.round(V.v*100);return this._a==1?"hsv("+q+", "+_+"%, "+N+"%)":"hsva("+q+", "+_+"%, "+N+"%, "+this._roundA+")"},toHsl:function K(){var V=E(this._r,this._g,this._b);return{h:V.h*360,s:V.s,l:V.l,a:this._a}},toHslString:function K(){var V=E(this._r,this._g,this._b),q=Math.round(V.h*360),_=Math.round(V.s*100),N=Math.round(V.l*100);return this._a==1?"hsl("+q+", "+_+"%, "+N+"%)":"hsla("+q+", "+_+"%, "+N+"%, "+this._roundA+")"},toHex:function K(V){return Y(this._r,this._g,this._b,V)},toHexString:function K(V){return"#"+this.toHex(V)},toHex8:function K(V){return J(this._r,this._g,this._b,this._a,V)},toHex8String:function K(V){return"#"+this.toHex8(V)},toRgb:function K(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function K(){return this._a==1?"rgb("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+")":"rgba("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+", "+this._roundA+")"},toPercentageRgb:function K(){return{r:Math.round(w(this._r,255)*100)+"%",g:Math.round(w(this._g,255)*100)+"%",b:Math.round(w(this._b,255)*100)+"%",a:this._a}},toPercentageRgbString:function K(){return this._a==1?"rgb("+Math.round(w(this._r,255)*100)+"%, "+Math.round(w(this._g,255)*100)+"%, "+Math.round(w(this._b,255)*100)+"%)":"rgba("+Math.round(w(this._r,255)*100)+"%, "+Math.round(w(this._g,255)*100)+"%, "+Math.round(w(this._b,255)*100)+"%, "+this._roundA+")"},toName:function K(){if(this._a===0)return"transparent";if(this._a<1)return!1;return T[Y(this._r,this._g,this._b,!0)]||!1},toFilter:function K(V){var q="#"+A(this._r,this._g,this._b,this._a),_=q,N=this._gradientType?"GradientType = 1, ":"";if(V){var L=C(V);_="#"+A(L._r,L._g,L._b,L._a)}return"progid:DXImageTransform.Microsoft.gradient("+N+"startColorstr="+q+",endColorstr="+_+")"},toString:function K(V){var q=!!V;V=V||this._format;var _=!1,N=this._a<1&&this._a>=0,L=!q&&N&&(V==="hex"||V==="hex6"||V==="hex3"||V==="hex4"||V==="hex8"||V==="name");if(L){if(V==="name"&&this._a===0)return this.toName();return this.toRgbString()}if(V==="rgb")_=this.toRgbString();if(V==="prgb")_=this.toPercentageRgbString();if(V==="hex"||V==="hex6")_=this.toHexString();if(V==="hex3")_=this.toHexString(!0);if(V==="hex4")_=this.toHex8String(!0);if(V==="hex8")_=this.toHex8String();if(V==="name")_=this.toName();if(V==="hsl")_=this.toHslString();if(V==="hsv")_=this.toHsvString();return _||this.toHexString()},clone:function K(){return C(this.toString())},_applyModification:function K(V,q){var _=V.apply(null,[this].concat([].slice.call(q)));return this._r=_._r,this._g=_._g,this._b=_._b,this.setAlpha(_._a),this},lighten:function K(){return this._applyModification(U,arguments)},brighten:function K(){return this._applyModification(I,arguments)},darken:function K(){return this._applyModification(j,arguments)},desaturate:function K(){return this._applyModification(H,arguments)},saturate:function K(){return this._applyModification(G,arguments)},greyscale:function K(){return this._applyModification(z,arguments)},spin:function K(){return this._applyModification(R,arguments)},_applyCombination:function K(V,q){return V.apply(null,[this].concat([].slice.call(q)))},analogous:function K(){return this._applyCombination(AD,arguments)},complement:function K(){return this._applyCombination(M,arguments)},monochromatic:function K(){return this._applyCombination(wD,arguments)},splitcomplement:function K(){return this._applyCombination(x,arguments)},triad:function K(){return this._applyCombination(P,[3])},tetrad:function K(){return this._applyCombination(P,[4])}},C.fromRatio=function(K,V){if(D(K)=="object"){var q={};for(var _ in K)if(K.hasOwnProperty(_))if(_==="a")q[_]=K[_];else q[_]=ZD(K[_]);K=q}return C(K,V)};function B(K){var V={r:0,g:0,b:0},q=1,_=null,N=null,L=null,f=!1,h=!1;if(typeof K=="string")K=f0(K);if(D(K)=="object"){if(YD(K.r)&&YD(K.g)&&YD(K.b))V=$(K.r,K.g,K.b),f=!0,h=String(K.r).substr(-1)==="%"?"prgb":"rgb";else if(YD(K.h)&&YD(K.s)&&YD(K.v))_=ZD(K.s),N=ZD(K.v),V=Z(K.h,_,N),f=!0,h="hsv";else if(YD(K.h)&&YD(K.s)&&YD(K.l))_=ZD(K.s),L=ZD(K.l),V=Q(K.h,_,L),f=!0,h="hsl";if(K.hasOwnProperty("a"))q=K.a}return q=v(q),{ok:f,format:K.format||h,r:Math.min(255,Math.max(V.r,0)),g:Math.min(255,Math.max(V.g,0)),b:Math.min(255,Math.max(V.b,0)),a:q}}function $(K,V,q){return{r:w(K,255)*255,g:w(V,255)*255,b:w(q,255)*255}}function E(K,V,q){K=w(K,255),V=w(V,255),q=w(q,255);var _=Math.max(K,V,q),N=Math.min(K,V,q),L,f,h=(_+N)/2;if(_==N)L=f=0;else{var i=_-N;switch(f=h>0.5?i/(2-_-N):i/(_+N),_){case K:L=(V-q)/i+(V1)dD-=1;if(dD<0.16666666666666666)return kD+(y0-kD)*6*dD;if(dD<0.5)return y0;if(dD<0.6666666666666666)return kD+(y0-kD)*(0.6666666666666666-dD)*6;return kD}if(V===0)_=N=L=q;else{var h=q<0.5?q*(1+V):q+V-q*V,i=2*q-h;_=f(i,h,K+0.3333333333333333),N=f(i,h,K),L=f(i,h,K-0.3333333333333333)}return{r:_*255,g:N*255,b:L*255}}function X(K,V,q){K=w(K,255),V=w(V,255),q=w(q,255);var _=Math.max(K,V,q),N=Math.min(K,V,q),L,f,h=_,i=_-N;if(f=_===0?0:i/_,_==N)L=0;else{switch(_){case K:L=(V-q)/i+(V>1)+720)%360;--V;)_.h=(_.h+N)%360,L.push(C(_));return L}function wD(K,V){V=V||6;var q=C(K).toHsv(),_=q.h,N=q.s,L=q.v,f=[],h=1/V;while(V--)f.push(C({h:_,s:N,v:L})),L=(L+h)%1;return f}C.mix=function(K,V,q){q=q===0?0:q||50;var _=C(K).toRgb(),N=C(V).toRgb(),L=q/100,f={r:(N.r-_.r)*L+_.r,g:(N.g-_.g)*L+_.g,b:(N.b-_.b)*L+_.b,a:(N.a-_.a)*L+_.a};return C(f)},C.readability=function(K,V){var q=C(K),_=C(V);return(Math.max(q.getLuminance(),_.getLuminance())+0.05)/(Math.min(q.getLuminance(),_.getLuminance())+0.05)},C.isReadable=function(K,V,q){var _=C.readability(K,V),N,L;switch(L=!1,N=UF(q),N.level+N.size){case"AAsmall":case"AAAlarge":L=_>=4.5;break;case"AAlarge":L=_>=3;break;case"AAAsmall":L=_>=7;break}return L},C.mostReadable=function(K,V,q){var _=null,N=0,L,f,h,i;q=q||{},f=q.includeFallbackColors,h=q.level,i=q.size;for(var kD=0;kDN)N=L,_=C(V[kD]);if(C.isReadable(K,_,{level:h,size:i})||!f)return _;else return q.includeFallbackColors=!1,C.mostReadable(K,["#fff","#000"],q)};var W=C.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},T=C.hexNames=b(W);function b(K){var V={};for(var q in K)if(K.hasOwnProperty(q))V[K[q]]=q;return V}function v(K){if(K=parseFloat(K),isNaN(K)||K<0||K>1)K=1;return K}function w(K,V){if(gD(K))K="100%";var q=Q0(K);if(K=Math.min(V,Math.max(0,parseFloat(K))),q)K=parseInt(K*V,10)/100;if(Math.abs(K-V)<0.000001)return 1;return K%V/parseFloat(V)}function g(K){return Math.min(1,Math.max(0,K))}function m(K){return parseInt(K,16)}function gD(K){return typeof K=="string"&&K.indexOf(".")!=-1&&parseFloat(K)===1}function Q0(K){return typeof K==="string"&&K.indexOf("%")!=-1}function r(K){return K.length==1?"0"+K:""+K}function ZD(K){if(K<=1)K=K*100+"%";return K}function mD(K){return Math.round(parseFloat(K)*255).toString(16)}function u0(K){return m(K)/255}var $D=function(){var K="[-\\+]?\\d+%?",V="[-\\+]?\\d*\\.\\d+%?",q="(?:"+V+")|(?:"+K+")",_="[\\s|\\(]+("+q+")[,|\\s]+("+q+")[,|\\s]+("+q+")\\s*\\)?",N="[\\s|\\(]+("+q+")[,|\\s]+("+q+")[,|\\s]+("+q+")[,|\\s]+("+q+")\\s*\\)?";return{CSS_UNIT:new RegExp(q),rgb:new RegExp("rgb"+_),rgba:new RegExp("rgba"+N),hsl:new RegExp("hsl"+_),hsla:new RegExp("hsla"+N),hsv:new RegExp("hsv"+_),hsva:new RegExp("hsva"+N),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();function YD(K){return!!$D.CSS_UNIT.exec(K)}function f0(K){K=K.replace(u,"").replace(F,"").toLowerCase();var V=!1;if(W[K])K=W[K],V=!0;else if(K=="transparent")return{r:0,g:0,b:0,a:0,format:"name"};var q;if(q=$D.rgb.exec(K))return{r:q[1],g:q[2],b:q[3]};if(q=$D.rgba.exec(K))return{r:q[1],g:q[2],b:q[3],a:q[4]};if(q=$D.hsl.exec(K))return{h:q[1],s:q[2],l:q[3]};if(q=$D.hsla.exec(K))return{h:q[1],s:q[2],l:q[3],a:q[4]};if(q=$D.hsv.exec(K))return{h:q[1],s:q[2],v:q[3]};if(q=$D.hsva.exec(K))return{h:q[1],s:q[2],v:q[3],a:q[4]};if(q=$D.hex8.exec(K))return{r:m(q[1]),g:m(q[2]),b:m(q[3]),a:u0(q[4]),format:V?"name":"hex8"};if(q=$D.hex6.exec(K))return{r:m(q[1]),g:m(q[2]),b:m(q[3]),format:V?"name":"hex"};if(q=$D.hex4.exec(K))return{r:m(q[1]+""+q[1]),g:m(q[2]+""+q[2]),b:m(q[3]+""+q[3]),a:u0(q[4]+""+q[4]),format:V?"name":"hex8"};if(q=$D.hex3.exec(K))return{r:m(q[1]+""+q[1]),g:m(q[2]+""+q[2]),b:m(q[3]+""+q[3]),format:V?"name":"hex"};return!1}function UF(K){var V,q;if(K=K||{level:"AA",size:"small"},V=(K.level||"AA").toUpperCase(),q=(K.size||"small").toLowerCase(),V!=="AA"&&V!=="AAA")V="AA";if(q!=="small"&&q!=="large")q="small";return{level:V,size:q}}return C})});var I8=e((U$,M8)=>{var l0=z8(),L8={r:256,g:256,b:256,a:1},R8={h:360,s:1,v:1,a:1};function u2(D,u,F){let C={};for(let B in D)if(D.hasOwnProperty(B))C[B]=F===0?0:(u[B]-D[B])/F;return C}function F2(D,u,F,C){let B={};for(let $ in u)if(u.hasOwnProperty($))B[$]=D[$]*F+u[$],B[$]=B[$]<0?B[$]+C[$]:C[$]!==1?B[$]%C[$]:B[$];return B}function D2(D,u,F){let C=D.color.toRgb(),B=u.color.toRgb(),$=u2(C,B,F),E=[D.color];for(let Q=1;Q$.h&&B.h-$.h>180;E=C==="long"&&Y||C==="short"&&!Y}let Q=u2(B,$,F),X=[D.color],Z;if(B.h<=$.h&&!E||B.h>=$.h&&E)Z=$.h-B.h;else if(E)Z=360-$.h+B.h;else Z=360-B.h+$.h;Q.h=Math.pow(-1,E?1:0)*Math.abs(Z)/F;for(let Y=1;Y1)throw new Error("Position must be between 0 and 1");let B,$;for(let X=0,Z=D.length;X=D[X].pos&&u{let Q=$.pos!==void 0;if(u^Q)throw new Error("Cannot mix positionned and not posionned color stops");if(Q){let X=$.color!==void 0;if(!X&&(B||E===0||E===F-1))throw new Error("Cannot define two consecutive position-only stops");if(B=!X,$={color:X?l0($.color):null,colorLess:!X,pos:$.pos},$.pos<0||$.pos>1)throw new Error("Color stops positions must be between 0 and 1");else if($.pos{D.push({color:F.color,pos:F.pos/2})}),this.stops.slice(0,-1).forEach((F)=>{u.push({color:F.color,pos:1-F.pos/2})}),new vu(D.concat(u.reverse()))}rgb(D){let u=U8(this.stops,D),F=[];this.stops.forEach((C,B)=>{if(C.colorLess)C.color=D2(this.stops[B-1],this.stops[B+1],2)[1]});for(let C=0,B=this.stops.length;C{if(B.colorLess)B.color=_8(this.stops[$-1],this.stops[$+1],2,u)[1]});for(let B=0,$=this.stops.length;B<$-1;B++){let E=_8(this.stops[B],this.stops[B+1],F[B],u);C.splice(C.length,0,...E)}return C.push(this.stops[this.stops.length-1].color),C}css(D,u){D=D||"linear",u=u||(D==="linear"?"to right":"ellipse at center");let F=D+"-gradient("+u;return this.stops.forEach(function(C){F+=", "+(C.colorLess?"":C.color.toRgbString()+" ")+C.pos*100+"%"}),F+=")",F}rgbAt(D){return W8(this.stops,D,"toRgb",L8)}hsvAt(D){return W8(this.stops,D,"toHsv",R8)}}M8.exports=function(D){if(arguments.length===1){if(!Array.isArray(arguments[0]))throw new Error('"stops" is not an array');D=arguments[0]}else D=Array.prototype.slice.call(arguments);return new vu(D)}});var P8=e((f$,w9)=>{w9.exports={single:{topLeft:"\u250C",top:"\u2500",topRight:"\u2510",right:"\u2502",bottomRight:"\u2518",bottom:"\u2500",bottomLeft:"\u2514",left:"\u2502"},double:{topLeft:"\u2554",top:"\u2550",topRight:"\u2557",right:"\u2551",bottomRight:"\u255D",bottom:"\u2550",bottomLeft:"\u255A",left:"\u2551"},round:{topLeft:"\u256D",top:"\u2500",topRight:"\u256E",right:"\u2502",bottomRight:"\u256F",bottom:"\u2500",bottomLeft:"\u2570",left:"\u2502"},bold:{topLeft:"\u250F",top:"\u2501",topRight:"\u2513",right:"\u2503",bottomRight:"\u251B",bottom:"\u2501",bottomLeft:"\u2517",left:"\u2503"},singleDouble:{topLeft:"\u2553",top:"\u2500",topRight:"\u2556",right:"\u2551",bottomRight:"\u255C",bottom:"\u2500",bottomLeft:"\u2559",left:"\u2551"},doubleSingle:{topLeft:"\u2552",top:"\u2550",topRight:"\u2555",right:"\u2502",bottomRight:"\u255B",bottom:"\u2550",bottomLeft:"\u2558",left:"\u2502"},classic:{topLeft:"+",top:"-",topRight:"+",right:"|",bottomRight:"+",bottom:"-",bottomLeft:"+",left:"|"},arrow:{topLeft:"\u2198",top:"\u2193",topRight:"\u2199",right:"\u2190",bottomRight:"\u2196",bottom:"\u2191",bottomLeft:"\u2197",left:"\u2192"}}});var X2=e((y$,Q2)=>{var S8=P8();Q2.exports=S8;Q2.exports.default=S8});var h8=e((g$,y8)=>{y8.exports=({onlyFirst:D=!1}={})=>{let u=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(u,D?void 0:"g")}});var m8=e((m$,g8)=>{var f9=h8();g8.exports=(D)=>typeof D==="string"?D.replace(f9(),""):D});var c8=e((d$,J2)=>{var d8=(D)=>{if(Number.isNaN(D))return!1;if(D>=4352&&(D<=4447||D===9001||D===9002||11904<=D&&D<=12871&&D!==12351||12880<=D&&D<=19903||19968<=D&&D<=42182||43360<=D&&D<=43388||44032<=D&&D<=55203||63744<=D&&D<=64255||65040<=D&&D<=65049||65072<=D&&D<=65131||65281<=D&&D<=65376||65504<=D&&D<=65510||110592<=D&&D<=110593||127488<=D&&D<=127569||131072<=D&&D<=262141))return!0;return!1};J2.exports=d8;J2.exports.default=d8});var p8=e((c$,l8)=>{l8.exports=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F|\uD83D\uDC68(?:\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68\uD83C\uDFFB|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|[\u2695\u2696\u2708]\uFE0F|\uD83D[\uDC66\uDC67]|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708])\uFE0F|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C[\uDFFB-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)\uD83C\uDFFB|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB\uDFFC])|\uD83D\uDC69(?:\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB-\uDFFD])|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|(?:(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)\uFE0F|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\u200D[\u2640\u2642])|\uD83C\uDFF4\u200D\u2620)\uFE0F|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF4\uD83C\uDDF2|\uD83C\uDDF6\uD83C\uDDE6|[#\*0-9]\uFE0F\u20E3|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270A-\u270D]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC70\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDCAA\uDD74\uDD7A\uDD90\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD36\uDDB5\uDDB6\uDDBB\uDDD2-\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5\uDEEB\uDEEC\uDEF4-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g}});var n8=e((l$,K2)=>{var y9=m8(),h9=c8(),g9=p8(),a8=(D)=>{if(typeof D!=="string"||D.length===0)return 0;if(D=y9(D),D.length===0)return 0;D=D.replace(g9()," ");let u=0;for(let F=0;F=127&&C<=159)continue;if(C>=768&&C<=879)continue;if(C>65535)F++;u+=h9(C)?2:1}return u};K2.exports=a8;K2.exports.default=a8});var i8=e((p$,r8)=>{var m9=n8();function H0(D,u){if(!D)return D;u=u||{};let F=u.align||"center";if(F==="left")return D;let C=u.split||` +`,B=u.pad||" ",$=F!=="right"?d9:c9,E=!1;if(!Array.isArray(D))E=!0,D=String(D).split(C);let Q,X=0;return D=D.map(function(Z){return Z=String(Z),Q=m9(Z),X=Math.max(Q,X),{str:Z,width:Q}}).map(function(Z){return new Array($(X,Z.width)+1).join(B)+Z.str}),E?D.join(C):D}H0.left=function D(u){return H0(u,{align:"left"})};H0.center=function D(u){return H0(u,{align:"center"})};H0.right=function D(u){return H0(u,{align:"right"})};r8.exports=H0;function d9(D,u){return Math.floor((D-u)/2)}function c9(D,u){return D-u}});import{join as s,dirname as cu,sep as XB}from"path";import{homedir as G2}from"os";import{existsSync as r0,statSync as ZB}from"fs";import{execSync as Z6}from"child_process";import{fileURLToPath as YB}from"url";class k{static instance=null;_dataDirectory=null;_packageRoot=null;_claudeConfigDirectory=null;static getInstance(){if(!k.instance)k.instance=new k;return k.instance}getDataDirectory(){if(this._dataDirectory)return this._dataDirectory;return this._dataDirectory=process.env.CLAUDE_MEM_DATA_DIR||s(G2(),".claude-mem"),this._dataDirectory}getArchivesDirectory(){return s(this.getDataDirectory(),"archives")}getHooksDirectory(){return s(this.getDataDirectory(),"hooks")}getLogsDirectory(){return s(this.getDataDirectory(),"logs")}getIndexDirectory(){return this.getDataDirectory()}getIndexPath(){return s(this.getIndexDirectory(),"claude-mem-index.jsonl")}getTrashDirectory(){return s(this.getDataDirectory(),"trash")}getBackupsDirectory(){return s(this.getDataDirectory(),"backups")}getChromaDirectory(){return s(this.getDataDirectory(),"chroma")}getProjectArchiveDirectory(D){return s(this.getArchivesDirectory(),D)}getUserSettingsPath(){return s(this.getDataDirectory(),"settings.json")}getClaudeConfigDirectory(){if(this._claudeConfigDirectory)return this._claudeConfigDirectory;return this._claudeConfigDirectory=process.env.CLAUDE_CONFIG_DIR||s(G2(),".claude"),this._claudeConfigDirectory}getClaudeSettingsPath(){return s(this.getClaudeConfigDirectory(),"settings.json")}getClaudeCommandsDirectory(){return s(this.getClaudeConfigDirectory(),"commands")}getClaudeMdPath(){return s(this.getClaudeConfigDirectory(),"CLAUDE.md")}getMcpConfigPath(){return s(G2(),".claude.json")}getProjectMcpConfigPath(){return s(process.cwd(),".mcp.json")}getPackageRoot(){if(this._packageRoot)return this._packageRoot;try{let F=cD.resolve("claude-mem/package.json");return this._packageRoot=cu(F),this._packageRoot}catch{}let D=YB(import.meta.url),u=cu(D);for(let F=0;F<10;F++){let C=s(u,"package.json");if(r0(C)){if(cD(C).name==="claude-mem")return this._packageRoot=u,this._packageRoot}let B=cu(u);if(B===u)break;u=B}try{let F=Z6("npm list -g claude-mem --json 2>/dev/null || npm list claude-mem --json 2>/dev/null",{encoding:"utf8"}),C=JSON.parse(F);if(C.dependencies?.["claude-mem"]?.resolved)return this._packageRoot=cu(C.dependencies["claude-mem"].resolved),this._packageRoot}catch{}throw new Error("Cannot locate claude-mem package root. Ensure claude-mem is properly installed.")}findPackageHookTemplatesDirectory(){let D=this.getPackageRoot(),u=s(D,"hook-templates"),F=["session-start.js","stop.js","user-prompt-submit.js","post-tool-use.js"];for(let C of F)if(!r0(s(u,C)))throw new Error(`Package hook-templates directory missing required template file: ${C}`);return u}findPackageCommandsDirectory(){let D=this.getPackageRoot(),u=s(D,"commands"),F=["save.md"];for(let C of F)if(!r0(s(u,C)))throw new Error(`Package commands directory missing required file: ${C}`);return u}ensureDirectory(D){if(!r0(D))cD("fs").mkdirSync(D,{recursive:!0})}ensureDirectories(D){D.forEach((u)=>this.ensureDirectory(u))}ensureAllDataDirectories(){this.ensureDirectories([this.getDataDirectory(),this.getArchivesDirectory(),this.getHooksDirectory(),this.getLogsDirectory(),this.getTrashDirectory(),this.getBackupsDirectory(),this.getChromaDirectory()])}ensureAllClaudeDirectories(){this.ensureDirectories([this.getClaudeConfigDirectory(),this.getClaudeCommandsDirectory()])}static extractProjectName(D){let u=D.split(XB),F=["src","lib","app","project","workspace"];for(let C=u.length-1;C>=0;C--)if(F.includes(u[C])&&C>0)return u[C-1];if(u.length>1)return u[u.length-2];return"unknown-project"}static getCurrentProjectName(){try{let D=Z6("git rev-parse --show-toplevel",{cwd:process.cwd(),encoding:"utf8",stdio:["pipe","pipe","ignore"]}).trim();return cD("path").basename(D)}catch{return cD("path").basename(process.cwd())}}static createBackupFilename(D){let u=new Date().toISOString().replace(/[:.]/g,"-").replace("T","_").slice(0,19);return`${D}.backup.${u}`}static isPathAccessible(D){return r0(D)&&ZB(D).isDirectory()}}var qD=()=>{};var z6={};C0(z6,{initializeDatabase:()=>L2,getDatabase:()=>_D,DatabaseManager:()=>jD,Database:()=>G6});import{Database as G6}from"bun:sqlite";import PB from"path";import SB from"fs";class jD{static instance;db=null;migrations=[];static getInstance(){if(!jD.instance)jD.instance=new jD;return jD.instance}registerMigration(D){this.migrations.push(D),this.migrations.sort((u,F)=>u.version-F.version)}async initialize(){if(this.db)return this.db;let D=k.getInstance().getDataDirectory();SB.mkdirSync(D,{recursive:!0});let u=PB.join(D,"claude-mem.db");return this.db=new G6(u,{create:!0,readwrite:!0}),this.db.run("PRAGMA journal_mode = WAL"),this.db.run("PRAGMA synchronous = NORMAL"),this.db.run("PRAGMA foreign_keys = ON"),this.db.run("PRAGMA temp_store = memory"),this.db.run("PRAGMA mmap_size = 268435456"),this.db.run("PRAGMA cache_size = 10000"),this.initializeSchemaVersions(),await this.runMigrations(),nu=this.db,this.db}getConnection(){if(!this.db)throw new Error("Database not initialized. Call initialize() first.");return this.db}withTransaction(D){let u=this.getConnection();return u.transaction(D)(u)}close(){if(this.db)this.db.close(),this.db=null,nu=null}initializeSchemaVersions(){if(!this.db)return;this.db.run(` CREATE TABLE IF NOT EXISTS schema_versions ( id INTEGER PRIMARY KEY, version INTEGER UNIQUE NOT NULL, applied_at TEXT NOT NULL ) - `)}async runMigrations(){if(!this.db)return;let u=this.db.query("SELECT version FROM schema_versions ORDER BY version").all().map((C)=>C.version),F=u.length>0?Math.max(...u):0;for(let C of this.migrations)if(C.version>F)console.log(`Applying migration ${C.version}...`),this.db.transaction(()=>{C.up(this.db),this.db.query("INSERT INTO schema_versions (version, applied_at) VALUES (?, ?)").run(C.version,new Date().toISOString())})(),console.log(`Migration ${C.version} applied successfully`)}getCurrentVersion(){if(!this.db)return 0;return this.db.query("SELECT MAX(version) as version FROM schema_versions").get()?.version||0}}function _D(){if(!nu)throw new Error("Database not initialized. Call DatabaseManager.getInstance().initialize() first.");return nu}async function L2(){return await jD.getInstance().initialize()}var nu=null;var aD=HD(()=>{qD()});function FD(D){let u;if(!D)u=new Date;else if(D instanceof Date)u=D;else if(typeof D==="number")u=new Date(D);else if(typeof D==="string"){if(!D.trim())u=new Date;else if(u=new Date(D),isNaN(u.getTime())){let F=D.replace(/\s+/g,"T").replace(/T+/g,"T");if(u=new Date(F),isNaN(u.getTime()))u=new Date}}else u=new Date;return{isoString:u.toISOString(),epoch:u.getTime()}}var z6={};C0(z6,{SessionStore:()=>t0});class t0{db;constructor(D){this.db=D||_D()}create(D){let{isoString:u,epoch:F}=FD(D.created_at),B=this.db.query(` + `)}async runMigrations(){if(!this.db)return;let u=this.db.query("SELECT version FROM schema_versions ORDER BY version").all().map((C)=>C.version),F=u.length>0?Math.max(...u):0;for(let C of this.migrations)if(C.version>F)console.log(`Applying migration ${C.version}...`),this.db.transaction(()=>{C.up(this.db),this.db.query("INSERT INTO schema_versions (version, applied_at) VALUES (?, ?)").run(C.version,new Date().toISOString())})(),console.log(`Migration ${C.version} applied successfully`)}getCurrentVersion(){if(!this.db)return 0;return this.db.query("SELECT MAX(version) as version FROM schema_versions").get()?.version||0}}function _D(){if(!nu)throw new Error("Database not initialized. Call DatabaseManager.getInstance().initialize() first.");return nu}async function L2(){return await jD.getInstance().initialize()}var nu=null;var aD=HD(()=>{qD()});function FD(D){let u;if(!D)u=new Date;else if(D instanceof Date)u=D;else if(typeof D==="number")u=new Date(D);else if(typeof D==="string"){if(!D.trim())u=new Date;else if(u=new Date(D),isNaN(u.getTime())){let F=D.replace(/\s+/g,"T").replace(/T+/g,"T");if(u=new Date(F),isNaN(u.getTime()))u=new Date}}else u=new Date;return{isoString:u.toISOString(),epoch:u.getTime()}}var _6={};C0(_6,{SessionStore:()=>t0});class t0{db;constructor(D){this.db=D||_D()}create(D){let{isoString:u,epoch:F}=FD(D.created_at),B=this.db.query(` INSERT INTO sessions ( session_id, project, created_at, created_at_epoch, source, archive_path, archive_bytes, archive_checksum, archived_at, metadata_json @@ -51,7 +51,7 @@ Expecting one of '${F.join("', '")}'`);let C=`${D}Help`;return this.on(C,(B)=>{l SELECT * FROM sessions ORDER BY created_at_epoch DESC LIMIT ? - `).all(D)}getBySource(D,u){let F=u?"SELECT * FROM sessions WHERE source = ? ORDER BY created_at_epoch DESC LIMIT ?":"SELECT * FROM sessions WHERE source = ? ORDER BY created_at_epoch DESC",C=this.db.query(F),B=u?[D,u]:[D];return C.all(...B)}count(){return this.db.query("SELECT COUNT(*) as count FROM sessions").get().count}countByProject(D){return this.db.query("SELECT COUNT(*) as count FROM sessions WHERE project = ?").get(D).count}deleteById(D){return this.db.query("DELETE FROM sessions WHERE id = ?").run(D).changes>0}deleteBySessionId(D){return this.db.query("DELETE FROM sessions WHERE session_id = ?").run(D).changes>0}}var ru=HD(()=>{aD()});var I6={};C0(I6,{MemoryStore:()=>N2});class N2{db;constructor(D){this.db=D||_D()}create(D){let{isoString:u,epoch:F}=FD(D.created_at),B=this.db.query(` + `).all(D)}getBySource(D,u){let F=u?"SELECT * FROM sessions WHERE source = ? ORDER BY created_at_epoch DESC LIMIT ?":"SELECT * FROM sessions WHERE source = ? ORDER BY created_at_epoch DESC",C=this.db.query(F),B=u?[D,u]:[D];return C.all(...B)}count(){return this.db.query("SELECT COUNT(*) as count FROM sessions").get().count}countByProject(D){return this.db.query("SELECT COUNT(*) as count FROM sessions WHERE project = ?").get(D).count}deleteById(D){return this.db.query("DELETE FROM sessions WHERE id = ?").run(D).changes>0}deleteBySessionId(D){return this.db.query("DELETE FROM sessions WHERE session_id = ?").run(D).changes>0}}var ru=HD(()=>{aD()});var N6={};C0(N6,{MemoryStore:()=>N2});class N2{db;constructor(D){this.db=D||_D()}create(D){let{isoString:u,epoch:F}=FD(D.created_at),B=this.db.query(` INSERT INTO memories ( session_id, text, document_id, keywords, created_at, created_at_epoch, project, archive_basename, origin, title, subtitle, facts, concepts, files_touched @@ -88,7 +88,7 @@ Expecting one of '${F.join("', '")}'`);let C=`${D}Help`;return this.on(C,(B)=>{l project = ?, archive_basename = ?, origin = ?, title = ?, subtitle = ?, facts = ?, concepts = ?, files_touched = ? WHERE id = ? - `).run(u.text||F.text,u.document_id!==void 0?u.document_id:F.document_id,u.keywords!==void 0?u.keywords:F.keywords,C,B,u.project||F.project,u.archive_basename!==void 0?u.archive_basename:F.archive_basename,u.origin||F.origin,u.title!==void 0?u.title:F.title,u.subtitle!==void 0?u.subtitle:F.subtitle,u.facts!==void 0?u.facts:F.facts,u.concepts!==void 0?u.concepts:F.concepts,u.files_touched!==void 0?u.files_touched:F.files_touched,D),this.getById(D)}deleteById(D){return this.db.query("DELETE FROM memories WHERE id = ?").run(D).changes>0}deleteBySessionId(D){return this.db.query("DELETE FROM memories WHERE session_id = ?").run(D).changes}getUniqueProjects(){return this.db.query("SELECT DISTINCT project FROM memories ORDER BY project").all().map((F)=>F.project)}}var O2=HD(()=>{aD()});var N6={};C0(N6,{OverviewStore:()=>j2});class j2{db;constructor(D){this.db=D||_D()}create(D){let{isoString:u,epoch:F}=FD(D.created_at),B=this.db.query(` + `).run(u.text||F.text,u.document_id!==void 0?u.document_id:F.document_id,u.keywords!==void 0?u.keywords:F.keywords,C,B,u.project||F.project,u.archive_basename!==void 0?u.archive_basename:F.archive_basename,u.origin||F.origin,u.title!==void 0?u.title:F.title,u.subtitle!==void 0?u.subtitle:F.subtitle,u.facts!==void 0?u.facts:F.facts,u.concepts!==void 0?u.concepts:F.concepts,u.files_touched!==void 0?u.files_touched:F.files_touched,D),this.getById(D)}deleteById(D){return this.db.query("DELETE FROM memories WHERE id = ?").run(D).changes>0}deleteBySessionId(D){return this.db.query("DELETE FROM memories WHERE session_id = ?").run(D).changes}getUniqueProjects(){return this.db.query("SELECT DISTINCT project FROM memories ORDER BY project").all().map((F)=>F.project)}}var O2=HD(()=>{aD()});var O6={};C0(O6,{OverviewStore:()=>j2});class j2{db;constructor(D){this.db=D||_D()}create(D){let{isoString:u,epoch:F}=FD(D.created_at),B=this.db.query(` INSERT INTO overviews ( session_id, content, created_at, created_at_epoch, project, origin ) VALUES (?, ?, ?, ?, ?, ?) @@ -114,7 +114,7 @@ Expecting one of '${F.join("', '")}'`);let C=`${D}Help`;return this.on(C,(B)=>{l WHERE project = ? ORDER BY created_at_epoch DESC LIMIT 1 - `).get(D)||null}upsertByProject(D){let u=this.getByProject(D.project);if(u)return this.update(u.id,D);return this.create(D)}deleteByProject(D){return this.db.query("DELETE FROM overviews WHERE project = ?").run(D).changes>0}}var T2=HD(()=>{aD()});var O6={};C0(O6,{DiagnosticsStore:()=>w2});class w2{db;constructor(D){this.db=D||_D()}create(D){let{isoString:u,epoch:F}=FD(D.created_at),B=this.db.query(` + `).get(D)||null}upsertByProject(D){let u=this.getByProject(D.project);if(u)return this.update(u.id,D);return this.create(D)}deleteByProject(D){return this.db.query("DELETE FROM overviews WHERE project = ?").run(D).changes>0}}var T2=HD(()=>{aD()});var j6={};C0(j6,{DiagnosticsStore:()=>w2});class w2{db;constructor(D){this.db=D||_D()}create(D){let{isoString:u,epoch:F}=FD(D.created_at),B=this.db.query(` INSERT INTO diagnostics ( session_id, message, severity, created_at, created_at_epoch, project, origin ) VALUES (?, ?, ?, ?, ?, ?, ?) @@ -142,7 +142,7 @@ Expecting one of '${F.join("', '")}'`);let C=`${D}Help`;return this.on(C,(B)=>{l COUNT(CASE WHEN severity = 'warn' THEN 1 END) as warn, COUNT(CASE WHEN severity = 'error' THEN 1 END) as error FROM diagnostics - `).get()}}var k2=HD(()=>{aD()});var j6={};C0(j6,{TranscriptEventStore:()=>P2});class P2{db;constructor(D){this.db=D||_D()}upsert(D){let{isoString:u,epoch:F}=FD(D.captured_at);return this.db.query(` + `).get()}}var k2=HD(()=>{aD()});var T6={};C0(T6,{TranscriptEventStore:()=>P2});class P2{db;constructor(D){this.db=D||_D()}upsert(D){let{isoString:u,epoch:F}=FD(D.captured_at);return this.db.query(` INSERT INTO transcript_events ( session_id, project, @@ -170,7 +170,7 @@ Expecting one of '${F.join("', '")}'`);let C=`${D}Help`;return this.on(C,(B)=>{l WHERE session_id = ? ORDER BY event_index ASC LIMIT ? OFFSET ? - `).all(D,u,F)}}var S2=HD(()=>{aD()});var T6={};C0(T6,{StreamingSessionStore:()=>O0});class O0{db;constructor(D){this.db=D||_D()}create(D){let{isoString:u,epoch:F}=FD(D.started_at),B=this.db.query(` + `).all(D,u,F)}}var S2=HD(()=>{aD()});var w6={};C0(w6,{StreamingSessionStore:()=>O0});class O0{db;constructor(D){this.db=D||_D()}create(D){let{isoString:u,epoch:F}=FD(D.started_at),B=this.db.query(` INSERT INTO streaming_sessions ( claude_session_id, project, user_prompt, started_at, started_at_epoch, status ) VALUES (?, ?, ?, ?, ?, 'active') @@ -194,7 +194,7 @@ Expecting one of '${F.join("', '")}'`);let C=`${D}Help`;return this.on(C,(B)=>{l DELETE FROM streaming_sessions WHERE status IN ('completed', 'failed') AND completed_at_epoch < ? - `).run(u).changes}}var su=HD(()=>{aD()});import{Database as nB}from"bun:sqlite";import rB from"path";import iB from"fs";class sD{db;constructor(){let D=k.getInstance().getDataDirectory();iB.mkdirSync(D,{recursive:!0});let u=rB.join(D,"claude-mem.db");this.db=new nB(u,{create:!0,readwrite:!0}),this.db.run("PRAGMA journal_mode = WAL"),this.db.run("PRAGMA synchronous = NORMAL"),this.db.run("PRAGMA foreign_keys = ON")}getRecentSummaries(D,u=10){return this.db.query(` + `).run(u).changes}}var su=HD(()=>{aD()});import{Database as iB}from"bun:sqlite";import oB from"path";import sB from"fs";class sD{db;constructor(){let D=k.getInstance().getDataDirectory();sB.mkdirSync(D,{recursive:!0});let u=oB.join(D,"claude-mem.db");this.db=new iB(u,{create:!0,readwrite:!0}),this.db.run("PRAGMA journal_mode = WAL"),this.db.run("PRAGMA synchronous = NORMAL"),this.db.run("PRAGMA foreign_keys = ON")}getRecentSummaries(D,u=10){return this.db.query(` SELECT request, investigated, learned, completed, next_steps, files_read, files_edited, notes, created_at @@ -246,7 +246,7 @@ Expecting one of '${F.join("', '")}'`);let C=`${D}Help`;return this.on(C,(B)=>{l UPDATE sdk_sessions SET status = 'failed', completed_at = ?, completed_at_epoch = ? WHERE id = ? - `).run(u.toISOString(),F,D)}close(){this.db.close()}}var j0=HD(()=>{qD()});var x6={};C0(x6,{migrations:()=>uu,migration004:()=>S6,migration003:()=>P6,migration002:()=>k6,migration001:()=>w6});var w6,k6,P6,S6,uu;var tu=HD(()=>{w6={version:1,up:(D)=>{D.run(` + `).run(u.toISOString(),F,D)}close(){this.db.close()}}var j0=HD(()=>{qD()});var b6={};C0(b6,{migrations:()=>uu,migration004:()=>x6,migration003:()=>S6,migration002:()=>P6,migration001:()=>k6});var k6,P6,S6,x6,uu;var tu=HD(()=>{k6={version:1,up:(D)=>{D.run(` CREATE TABLE IF NOT EXISTS sessions ( id INTEGER PRIMARY KEY AUTOINCREMENT, session_id TEXT UNIQUE NOT NULL, @@ -343,7 +343,7 @@ Expecting one of '${F.join("', '")}'`);let C=`${D}Help`;return this.on(C,(B)=>{l DROP TABLE IF EXISTS overviews; DROP TABLE IF EXISTS memories; DROP TABLE IF EXISTS sessions; - `)}},k6={version:2,up:(D)=>{D.run(` + `)}},P6={version:2,up:(D)=>{D.run(` ALTER TABLE memories ADD COLUMN title TEXT; ALTER TABLE memories ADD COLUMN subtitle TEXT; ALTER TABLE memories ADD COLUMN facts TEXT; @@ -352,7 +352,7 @@ Expecting one of '${F.join("', '")}'`);let C=`${D}Help`;return this.on(C,(B)=>{l `),D.run(` CREATE INDEX IF NOT EXISTS idx_memories_title ON memories(title); CREATE INDEX IF NOT EXISTS idx_memories_concepts ON memories(concepts); - `),console.log("\u2705 Added hierarchical memory fields to memories table")},down:(D)=>{console.log("\u26A0\uFE0F Warning: SQLite ALTER TABLE DROP COLUMN not fully supported"),console.log("\u26A0\uFE0F To rollback, manually recreate the memories table")}},P6={version:3,up:(D)=>{D.run(` + `),console.log("\u2705 Added hierarchical memory fields to memories table")},down:(D)=>{console.log("\u26A0\uFE0F Warning: SQLite ALTER TABLE DROP COLUMN not fully supported"),console.log("\u26A0\uFE0F To rollback, manually recreate the memories table")}},S6={version:3,up:(D)=>{D.run(` CREATE TABLE IF NOT EXISTS streaming_sessions ( id INTEGER PRIMARY KEY AUTOINCREMENT, claude_session_id TEXT UNIQUE NOT NULL, @@ -377,7 +377,7 @@ Expecting one of '${F.join("', '")}'`);let C=`${D}Help`;return this.on(C,(B)=>{l CREATE INDEX IF NOT EXISTS idx_streaming_sessions_started ON streaming_sessions(started_at_epoch DESC); `),console.log("\u2705 Created streaming_sessions table for real-time session tracking")},down:(D)=>{D.run(` DROP TABLE IF EXISTS streaming_sessions; - `)}},S6={version:4,up:(D)=>{D.run(` + `)}},x6={version:4,up:(D)=>{D.run(` CREATE TABLE IF NOT EXISTS sdk_sessions ( id INTEGER PRIMARY KEY AUTOINCREMENT, claude_session_id TEXT UNIQUE NOT NULL, @@ -453,21 +453,21 @@ Expecting one of '${F.join("', '")}'`);let C=`${D}Help`;return this.on(C,(B)=>{l DROP TABLE IF EXISTS observations; DROP TABLE IF EXISTS observation_queue; DROP TABLE IF EXISTS sdk_sessions; - `)}},uu=[w6,k6,P6,S6]});import X5 from"path";function EC(D){try{if(D.source&&D.source!=="startup")console.log(""),process.exit(0);let u=X5.basename(D.cwd),F=new sD,C=F.getRecentSummaries(u,5);if(F.close(),C.length===0)console.log(""),process.exit(0);let B=[];B.push("# Recent Session Context"),B.push(""),B.push(`Here's what happened in recent ${u} sessions:`),B.push("");for(let $ of C){if(B.push("---"),B.push(""),$.request)B.push(`**Request:** ${$.request}`);if($.completed)B.push(`**Completed:** ${$.completed}`);if($.learned)B.push(`**Learned:** ${$.learned}`);if($.next_steps)B.push(`**Next Steps:** ${$.next_steps}`);if($.files_edited)try{let E=JSON.parse($.files_edited);if(Array.isArray(E)&&E.length>0)B.push(`**Files Edited:** ${E.join(", ")}`)}catch{if($.files_edited.trim())B.push(`**Files Edited:** ${$.files_edited}`)}B.push(`**Date:** ${$.created_at.split("T")[0]}`),B.push("")}console.log(B.join(` -`)),process.exit(0)}catch(u){console.error(`[claude-mem context error: ${u.message}]`),process.exit(0)}}var $C=HD(()=>{j0()});import Z5 from"path";function QC(D){try{let{session_id:u,cwd:F,tool_name:C,tool_input:B,tool_output:$}=D;if(Y5.has(C))console.log('{"continue": true, "suppressOutput": true}'),process.exit(0);let E=Z5.basename(F),Q=new sD,X=Q.findActiveSDKSession(u);if(!X)Q.close(),console.log('{"continue": true, "suppressOutput": true}'),process.exit(0);let Z=X.sdk_session_id||`pending-${X.id}`;Q.queueObservation(Z,C,JSON.stringify(B),JSON.stringify($)),Q.close(),console.log('{"continue": true, "suppressOutput": true}'),process.exit(0)}catch(u){console.error(`[claude-mem save error: ${u.message}]`),console.log('{"continue": true, "suppressOutput": true}'),process.exit(0)}}var Y5;var XC=HD(()=>{j0();Y5=new Set(["TodoWrite","ListMcpResourcesTool"])});import J5 from"path";function ZC(D){try{let{session_id:u,cwd:F,prompt:C}=D,B=J5.basename(F),$=new sD;if($.findActiveSDKSession(u))$.close(),console.log('{"continue": true, "suppressOutput": true}'),process.exit(0);let Q=$.createSDKSession(u,B,C);$.close(),console.log('{"continue": true, "suppressOutput": true}'),process.exit(0)}catch(u){console.error(`[claude-mem new error: ${u.message}]`),console.log('{"continue": true, "suppressOutput": true}'),process.exit(0)}}var YC=HD(()=>{j0()});function JC(D){try{let{session_id:u}=D,F=new sD,C=F.findActiveSDKSession(u);if(!C)F.close(),console.log('{"continue": true, "suppressOutput": true}'),process.exit(0);let B=C.sdk_session_id||`pending-${C.id}`;F.queueObservation(B,"FINALIZE","{}","{}"),F.close(),console.log('{"continue": true, "suppressOutput": true}'),process.exit(0)}catch(u){console.error(`[claude-mem summary error: ${u.message}]`),console.log('{"continue": true, "suppressOutput": true}'),process.exit(0)}}var KC=HD(()=>{j0()});var Wu={};C0(Wu,{summaryHook:()=>JC,saveHook:()=>QC,newHook:()=>ZC,contextHook:()=>EC});var Lu=HD(()=>{$C();XC();YC();KC()});var N3=F0(I3(),1),{program:U5,createCommand:W5,createArgument:L5,createOption:R5,CommanderError:M5,InvalidArgumentError:I5,InvalidOptionArgumentError:N5,Command:O3,Argument:O5,Option:j5,Help:T5}=N3.default;import{readFileSync as Q7,existsSync as X7}from"fs";import{join as Z7,dirname as Y7}from"path";import{fileURLToPath as J7}from"url";var j3="claude-mem",T3="3.9.16",w3="Memory compression system for Claude Code - persist context across sessions",k3=j3,P3=T3,S3=w3;try{let D=J7(import.meta.url),u=Y7(D),F=Z7(u,"..","..","package.json");if(X7(F)){let C=JSON.parse(Q7(F,"utf-8"));k3=C.name||j3,P3=C.version||T3,S3=C.description||w3}}catch{}var L0=k3,x3=P3,b3=S3;import{readFileSync as pu,writeFileSync as J0,existsSync as xD,mkdirSync as s0,copyFileSync as U2,statSync as KB,readdirSync as qB}from"fs";import{join as uD,dirname as W2}from"path";import{homedir as Y6}from"os";import{execSync as Z6}from"child_process";var JD=F0(kF(),1),i3=F0(SF(),1);import{stdin as n3,stdout as r3}from"process";import*as X0 from"readline";import h3 from"readline";import{Writable as G7}from"stream";function z7({onlyFirst:D=!1}={}){let u=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(u,D?void 0:"g")}var _7=z7();function o3(D){if(typeof D!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof D}\``);return D.replace(_7,"")}function s3(D){return D&&D.__esModule&&Object.prototype.hasOwnProperty.call(D,"default")?D.default:D}var t3={exports:{}};(function(D){var u={};D.exports=u,u.eastAsianWidth=function(C){var B=C.charCodeAt(0),$=C.length==2?C.charCodeAt(1):0,E=B;return 55296<=B&&B<=56319&&56320<=$&&$<=57343&&(B&=1023,$&=1023,E=B<<10|$,E+=65536),E==12288||65281<=E&&E<=65376||65504<=E&&E<=65510?"F":E==8361||65377<=E&&E<=65470||65474<=E&&E<=65479||65482<=E&&E<=65487||65490<=E&&E<=65495||65498<=E&&E<=65500||65512<=E&&E<=65518?"H":4352<=E&&E<=4447||4515<=E&&E<=4519||4602<=E&&E<=4607||9001<=E&&E<=9002||11904<=E&&E<=11929||11931<=E&&E<=12019||12032<=E&&E<=12245||12272<=E&&E<=12283||12289<=E&&E<=12350||12353<=E&&E<=12438||12441<=E&&E<=12543||12549<=E&&E<=12589||12593<=E&&E<=12686||12688<=E&&E<=12730||12736<=E&&E<=12771||12784<=E&&E<=12830||12832<=E&&E<=12871||12880<=E&&E<=13054||13056<=E&&E<=19903||19968<=E&&E<=42124||42128<=E&&E<=42182||43360<=E&&E<=43388||44032<=E&&E<=55203||55216<=E&&E<=55238||55243<=E&&E<=55291||63744<=E&&E<=64255||65040<=E&&E<=65049||65072<=E&&E<=65106||65108<=E&&E<=65126||65128<=E&&E<=65131||110592<=E&&E<=110593||127488<=E&&E<=127490||127504<=E&&E<=127546||127552<=E&&E<=127560||127568<=E&&E<=127569||131072<=E&&E<=194367||177984<=E&&E<=196605||196608<=E&&E<=262141?"W":32<=E&&E<=126||162<=E&&E<=163||165<=E&&E<=166||E==172||E==175||10214<=E&&E<=10221||10629<=E&&E<=10630?"Na":E==161||E==164||167<=E&&E<=168||E==170||173<=E&&E<=174||176<=E&&E<=180||182<=E&&E<=186||188<=E&&E<=191||E==198||E==208||215<=E&&E<=216||222<=E&&E<=225||E==230||232<=E&&E<=234||236<=E&&E<=237||E==240||242<=E&&E<=243||247<=E&&E<=250||E==252||E==254||E==257||E==273||E==275||E==283||294<=E&&E<=295||E==299||305<=E&&E<=307||E==312||319<=E&&E<=322||E==324||328<=E&&E<=331||E==333||338<=E&&E<=339||358<=E&&E<=359||E==363||E==462||E==464||E==466||E==468||E==470||E==472||E==474||E==476||E==593||E==609||E==708||E==711||713<=E&&E<=715||E==717||E==720||728<=E&&E<=731||E==733||E==735||768<=E&&E<=879||913<=E&&E<=929||931<=E&&E<=937||945<=E&&E<=961||963<=E&&E<=969||E==1025||1040<=E&&E<=1103||E==1105||E==8208||8211<=E&&E<=8214||8216<=E&&E<=8217||8220<=E&&E<=8221||8224<=E&&E<=8226||8228<=E&&E<=8231||E==8240||8242<=E&&E<=8243||E==8245||E==8251||E==8254||E==8308||E==8319||8321<=E&&E<=8324||E==8364||E==8451||E==8453||E==8457||E==8467||E==8470||8481<=E&&E<=8482||E==8486||E==8491||8531<=E&&E<=8532||8539<=E&&E<=8542||8544<=E&&E<=8555||8560<=E&&E<=8569||E==8585||8592<=E&&E<=8601||8632<=E&&E<=8633||E==8658||E==8660||E==8679||E==8704||8706<=E&&E<=8707||8711<=E&&E<=8712||E==8715||E==8719||E==8721||E==8725||E==8730||8733<=E&&E<=8736||E==8739||E==8741||8743<=E&&E<=8748||E==8750||8756<=E&&E<=8759||8764<=E&&E<=8765||E==8776||E==8780||E==8786||8800<=E&&E<=8801||8804<=E&&E<=8807||8810<=E&&E<=8811||8814<=E&&E<=8815||8834<=E&&E<=8835||8838<=E&&E<=8839||E==8853||E==8857||E==8869||E==8895||E==8978||9312<=E&&E<=9449||9451<=E&&E<=9547||9552<=E&&E<=9587||9600<=E&&E<=9615||9618<=E&&E<=9621||9632<=E&&E<=9633||9635<=E&&E<=9641||9650<=E&&E<=9651||9654<=E&&E<=9655||9660<=E&&E<=9661||9664<=E&&E<=9665||9670<=E&&E<=9672||E==9675||9678<=E&&E<=9681||9698<=E&&E<=9701||E==9711||9733<=E&&E<=9734||E==9737||9742<=E&&E<=9743||9748<=E&&E<=9749||E==9756||E==9758||E==9792||E==9794||9824<=E&&E<=9825||9827<=E&&E<=9829||9831<=E&&E<=9834||9836<=E&&E<=9837||E==9839||9886<=E&&E<=9887||9918<=E&&E<=9919||9924<=E&&E<=9933||9935<=E&&E<=9953||E==9955||9960<=E&&E<=9983||E==10045||E==10071||10102<=E&&E<=10111||11093<=E&&E<=11097||12872<=E&&E<=12879||57344<=E&&E<=63743||65024<=E&&E<=65039||E==65533||127232<=E&&E<=127242||127248<=E&&E<=127277||127280<=E&&E<=127337||127344<=E&&E<=127386||917760<=E&&E<=917999||983040<=E&&E<=1048573||1048576<=E&&E<=1114109?"A":"N"},u.characterLength=function(C){var B=this.eastAsianWidth(C);return B=="F"||B=="W"||B=="A"?2:1};function F(C){return C.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}u.length=function(C){for(var B=F(C),$=0,E=0;E=B-(J==2?1:0))if(Q+J<=$)E+=Y;else break;Q+=J}return E}})(t3);var U7=t3.exports,W7=s3(U7),L7=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g},R7=s3(L7);function g0(D,u={}){if(typeof D!="string"||D.length===0||(u={ambiguousIsNarrow:!0,...u},D=o3(D),D.length===0))return 0;D=D.replace(R7()," ");let F=u.ambiguousIsNarrow?1:2,C=0;for(let B of D){let $=B.codePointAt(0);if($<=31||$>=127&&$<=159||$>=768&&$<=879)continue;switch(W7.eastAsianWidth(B)){case"F":case"W":C+=2;break;case"A":C+=F;break;default:C+=1}}return C}var xF=10,g3=(D=0)=>(u)=>`\x1B[${u+D}m`,m3=(D=0)=>(u)=>`\x1B[${38+D};5;${u}m`,d3=(D=0)=>(u,F,C)=>`\x1B[${38+D};2;${u};${F};${C}m`,d={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]}};Object.keys(d.modifier);var M7=Object.keys(d.color),I7=Object.keys(d.bgColor);[...M7];function N7(){let D=new Map;for(let[u,F]of Object.entries(d)){for(let[C,B]of Object.entries(F))d[C]={open:`\x1B[${B[0]}m`,close:`\x1B[${B[1]}m`},F[C]=d[C],D.set(B[0],B[1]);Object.defineProperty(d,u,{value:F,enumerable:!1})}return Object.defineProperty(d,"codes",{value:D,enumerable:!1}),d.color.close="\x1B[39m",d.bgColor.close="\x1B[49m",d.color.ansi=g3(),d.color.ansi256=m3(),d.color.ansi16m=d3(),d.bgColor.ansi=g3(xF),d.bgColor.ansi256=m3(xF),d.bgColor.ansi16m=d3(xF),Object.defineProperties(d,{rgbToAnsi256:{value:(u,F,C)=>u===F&&F===C?u<8?16:u>248?231:Math.round((u-8)/247*24)+232:16+36*Math.round(u/255*5)+6*Math.round(F/255*5)+Math.round(C/255*5),enumerable:!1},hexToRgb:{value:(u)=>{let F=/[a-f\d]{6}|[a-f\d]{3}/i.exec(u.toString(16));if(!F)return[0,0,0];let[C]=F;C.length===3&&(C=[...C].map(($)=>$+$).join(""));let B=Number.parseInt(C,16);return[B>>16&255,B>>8&255,B&255]},enumerable:!1},hexToAnsi256:{value:(u)=>d.rgbToAnsi256(...d.hexToRgb(u)),enumerable:!1},ansi256ToAnsi:{value:(u)=>{if(u<8)return 30+u;if(u<16)return 90+(u-8);let F,C,B;if(u>=232)F=((u-232)*10+8)/255,C=F,B=F;else{u-=16;let Q=u%36;F=Math.floor(u/36)/5,C=Math.floor(Q/6)/5,B=Q%6/5}let $=Math.max(F,C,B)*2;if($===0)return 30;let E=30+(Math.round(B)<<2|Math.round(C)<<1|Math.round(F));return $===2&&(E+=60),E},enumerable:!1},rgbToAnsi:{value:(u,F,C)=>d.ansi256ToAnsi(d.rgbToAnsi256(u,F,C)),enumerable:!1},hexToAnsi:{value:(u)=>d.ansi256ToAnsi(d.hexToAnsi256(u)),enumerable:!1}}),d}var O7=N7(),Tu=new Set(["\x1B","\x9B"]),j7=39,fF="\x07",e3="[",T7="]",D8="m",yF=`${T7}8;;`,c3=(D)=>`${Tu.values().next().value}${e3}${D}${D8}`,l3=(D)=>`${Tu.values().next().value}${yF}${D}${fF}`,w7=(D)=>D.split(" ").map((u)=>g0(u)),bF=(D,u,F)=>{let C=[...u],B=!1,$=!1,E=g0(o3(D[D.length-1]));for(let[Q,X]of C.entries()){let Z=g0(X);if(E+Z<=F?D[D.length-1]+=X:(D.push(X),E=0),Tu.has(X)&&(B=!0,$=C.slice(Q+1).join("").startsWith(yF)),B){$?X===fF&&(B=!1,$=!1):X===D8&&(B=!1);continue}E+=Z,E===F&&Q0&&D.length>1&&(D[D.length-2]+=D.pop())},k7=(D)=>{let u=D.split(" "),F=u.length;for(;F>0&&!(g0(u[F-1])>0);)F--;return F===u.length?D:u.slice(0,F).join(" ")+u.slice(F).join("")},P7=(D,u,F={})=>{if(F.trim!==!1&&D.trim()==="")return"";let C="",B,$,E=w7(D),Q=[""];for(let[Z,Y]of D.split(" ").entries()){F.trim!==!1&&(Q[Q.length-1]=Q[Q.length-1].trimStart());let J=g0(Q[Q.length-1]);if(Z!==0&&(J>=u&&(F.wordWrap===!1||F.trim===!1)&&(Q.push(""),J=0),(J>0||F.trim===!1)&&(Q[Q.length-1]+=" ",J++)),F.hard&&E[Z]>u){let A=u-J,H=1+Math.floor((E[Z]-A-1)/u);Math.floor((E[Z]-1)/u)u&&J>0&&E[Z]>0){if(F.wordWrap===!1&&Ju&&F.wordWrap===!1){bF(Q,Y,u);continue}Q[Q.length-1]+=Y}F.trim!==!1&&(Q=Q.map((Z)=>k7(Z)));let X=[...Q.join(` -`)];for(let[Z,Y]of X.entries()){if(C+=Y,Tu.has(Y)){let{groups:A}=new RegExp(`(?:\\${e3}(?\\d+)m|\\${yF}(?.*)${fF})`).exec(X.slice(Z).join(""))||{groups:{}};if(A.code!==void 0){let H=Number.parseFloat(A.code);B=H===j7?void 0:H}else A.uri!==void 0&&($=A.uri.length===0?void 0:A.uri)}let J=O7.codes.get(Number(B));X[Z+1]===` -`?($&&(C+=l3("")),B&&J&&(C+=c3(J))):Y===` -`&&(B&&J&&(C+=c3(B)),$&&(C+=l3($)))}return C};function p3(D,u,F){return String(D).normalize().replace(/\r\n/g,` + `)}},uu=[k6,P6,S6,x6]});import Y5 from"path";function $C(D){try{if(D.source&&D.source!=="startup")console.log(""),process.exit(0);let u=Y5.basename(D.cwd),F=new sD,C=F.getRecentSummaries(u,5);if(F.close(),C.length===0)console.log(""),process.exit(0);let B=[];B.push("# Recent Session Context"),B.push(""),B.push(`Here's what happened in recent ${u} sessions:`),B.push("");for(let $ of C){if(B.push("---"),B.push(""),$.request)B.push(`**Request:** ${$.request}`);if($.completed)B.push(`**Completed:** ${$.completed}`);if($.learned)B.push(`**Learned:** ${$.learned}`);if($.next_steps)B.push(`**Next Steps:** ${$.next_steps}`);if($.files_edited)try{let E=JSON.parse($.files_edited);if(Array.isArray(E)&&E.length>0)B.push(`**Files Edited:** ${E.join(", ")}`)}catch{if($.files_edited.trim())B.push(`**Files Edited:** ${$.files_edited}`)}B.push(`**Date:** ${$.created_at.split("T")[0]}`),B.push("")}console.log(B.join(` +`)),process.exit(0)}catch(u){console.error(`[claude-mem context error: ${u.message}]`),process.exit(0)}}var QC=HD(()=>{j0()});import J5 from"path";function XC(D){try{let{session_id:u,cwd:F,tool_name:C,tool_input:B,tool_output:$}=D;if(K5.has(C))console.log('{"continue": true, "suppressOutput": true}'),process.exit(0);let E=J5.basename(F),Q=new sD,X=Q.findActiveSDKSession(u);if(!X)Q.close(),console.log('{"continue": true, "suppressOutput": true}'),process.exit(0);let Z=X.sdk_session_id||`pending-${X.id}`;Q.queueObservation(Z,C,JSON.stringify(B),JSON.stringify($)),Q.close(),console.log('{"continue": true, "suppressOutput": true}'),process.exit(0)}catch(u){console.error(`[claude-mem save error: ${u.message}]`),console.log('{"continue": true, "suppressOutput": true}'),process.exit(0)}}var K5;var ZC=HD(()=>{j0();K5=new Set(["TodoWrite","ListMcpResourcesTool"])});import Z3 from"path";import{spawn as q5}from"child_process";import YC from"fs";function JC(D){try{let{session_id:u,cwd:F,prompt:C}=D,B=Z3.basename(F),$=new sD;if($.findActiveSDKSession(u))$.close(),console.log('{"continue": true, "suppressOutput": true}'),process.exit(0);let Q=$.createSDKSession(u,B,C);$.close();let X=Z3.join(__dirname,"..","sdk","worker.ts"),Z=Z3.join(__dirname,"..","sdk","worker.js"),Y;if(YC.existsSync(X))Y=X;else if(YC.existsSync(Z))Y=Z;else console.error("[claude-mem] Worker not found, skipping background processing"),console.log('{"continue": true, "suppressOutput": true}'),process.exit(0);q5("bun",[Y,Q.toString()],{detached:!0,stdio:"ignore"}).unref(),console.log('{"continue": true, "suppressOutput": true}'),process.exit(0)}catch(u){console.error(`[claude-mem new error: ${u.message}]`),console.log('{"continue": true, "suppressOutput": true}'),process.exit(0)}}var __dirname="/Users/alexnewman/Scripts/claude-mem/src/hooks";var KC=HD(()=>{j0()});function qC(D){try{let{session_id:u}=D,F=new sD,C=F.findActiveSDKSession(u);if(!C)F.close(),console.log('{"continue": true, "suppressOutput": true}'),process.exit(0);let B=C.sdk_session_id||`pending-${C.id}`;F.queueObservation(B,"FINALIZE","{}","{}"),F.close(),console.log('{"continue": true, "suppressOutput": true}'),process.exit(0)}catch(u){console.error(`[claude-mem summary error: ${u.message}]`),console.log('{"continue": true, "suppressOutput": true}'),process.exit(0)}}var VC=HD(()=>{j0()});var Wu={};C0(Wu,{summaryHook:()=>qC,saveHook:()=>XC,newHook:()=>JC,contextHook:()=>$C});var Lu=HD(()=>{QC();ZC();KC();VC()});var O3=F0(N3(),1),{program:L5,createCommand:R5,createArgument:M5,createOption:I5,CommanderError:N5,InvalidArgumentError:O5,InvalidOptionArgumentError:j5,Command:j3,Argument:T5,Option:w5,Help:k5}=O3.default;import{readFileSync as Z7,existsSync as Y7}from"fs";import{join as J7,dirname as K7}from"path";import{fileURLToPath as q7}from"url";var T3="claude-mem",w3="3.9.16",k3="Memory compression system for Claude Code - persist context across sessions",P3=T3,S3=w3,x3=k3;try{let D=q7(import.meta.url),u=K7(D),F=J7(u,"..","..","package.json");if(Y7(F)){let C=JSON.parse(Z7(F,"utf-8"));P3=C.name||T3,S3=C.version||w3,x3=C.description||k3}}catch{}var L0=P3,b3=S3,v3=x3;import{readFileSync as pu,writeFileSync as J0,existsSync as xD,mkdirSync as s0,copyFileSync as U2,statSync as VB,readdirSync as AB}from"fs";import{join as uD,dirname as W2}from"path";import{homedir as J6}from"os";import{execSync as Y6}from"child_process";var JD=F0(kF(),1),o3=F0(SF(),1);import{stdin as r3,stdout as i3}from"process";import*as X0 from"readline";import g3 from"readline";import{Writable as _7}from"stream";function U7({onlyFirst:D=!1}={}){let u=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(u,D?void 0:"g")}var W7=U7();function s3(D){if(typeof D!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof D}\``);return D.replace(W7,"")}function t3(D){return D&&D.__esModule&&Object.prototype.hasOwnProperty.call(D,"default")?D.default:D}var e3={exports:{}};(function(D){var u={};D.exports=u,u.eastAsianWidth=function(C){var B=C.charCodeAt(0),$=C.length==2?C.charCodeAt(1):0,E=B;return 55296<=B&&B<=56319&&56320<=$&&$<=57343&&(B&=1023,$&=1023,E=B<<10|$,E+=65536),E==12288||65281<=E&&E<=65376||65504<=E&&E<=65510?"F":E==8361||65377<=E&&E<=65470||65474<=E&&E<=65479||65482<=E&&E<=65487||65490<=E&&E<=65495||65498<=E&&E<=65500||65512<=E&&E<=65518?"H":4352<=E&&E<=4447||4515<=E&&E<=4519||4602<=E&&E<=4607||9001<=E&&E<=9002||11904<=E&&E<=11929||11931<=E&&E<=12019||12032<=E&&E<=12245||12272<=E&&E<=12283||12289<=E&&E<=12350||12353<=E&&E<=12438||12441<=E&&E<=12543||12549<=E&&E<=12589||12593<=E&&E<=12686||12688<=E&&E<=12730||12736<=E&&E<=12771||12784<=E&&E<=12830||12832<=E&&E<=12871||12880<=E&&E<=13054||13056<=E&&E<=19903||19968<=E&&E<=42124||42128<=E&&E<=42182||43360<=E&&E<=43388||44032<=E&&E<=55203||55216<=E&&E<=55238||55243<=E&&E<=55291||63744<=E&&E<=64255||65040<=E&&E<=65049||65072<=E&&E<=65106||65108<=E&&E<=65126||65128<=E&&E<=65131||110592<=E&&E<=110593||127488<=E&&E<=127490||127504<=E&&E<=127546||127552<=E&&E<=127560||127568<=E&&E<=127569||131072<=E&&E<=194367||177984<=E&&E<=196605||196608<=E&&E<=262141?"W":32<=E&&E<=126||162<=E&&E<=163||165<=E&&E<=166||E==172||E==175||10214<=E&&E<=10221||10629<=E&&E<=10630?"Na":E==161||E==164||167<=E&&E<=168||E==170||173<=E&&E<=174||176<=E&&E<=180||182<=E&&E<=186||188<=E&&E<=191||E==198||E==208||215<=E&&E<=216||222<=E&&E<=225||E==230||232<=E&&E<=234||236<=E&&E<=237||E==240||242<=E&&E<=243||247<=E&&E<=250||E==252||E==254||E==257||E==273||E==275||E==283||294<=E&&E<=295||E==299||305<=E&&E<=307||E==312||319<=E&&E<=322||E==324||328<=E&&E<=331||E==333||338<=E&&E<=339||358<=E&&E<=359||E==363||E==462||E==464||E==466||E==468||E==470||E==472||E==474||E==476||E==593||E==609||E==708||E==711||713<=E&&E<=715||E==717||E==720||728<=E&&E<=731||E==733||E==735||768<=E&&E<=879||913<=E&&E<=929||931<=E&&E<=937||945<=E&&E<=961||963<=E&&E<=969||E==1025||1040<=E&&E<=1103||E==1105||E==8208||8211<=E&&E<=8214||8216<=E&&E<=8217||8220<=E&&E<=8221||8224<=E&&E<=8226||8228<=E&&E<=8231||E==8240||8242<=E&&E<=8243||E==8245||E==8251||E==8254||E==8308||E==8319||8321<=E&&E<=8324||E==8364||E==8451||E==8453||E==8457||E==8467||E==8470||8481<=E&&E<=8482||E==8486||E==8491||8531<=E&&E<=8532||8539<=E&&E<=8542||8544<=E&&E<=8555||8560<=E&&E<=8569||E==8585||8592<=E&&E<=8601||8632<=E&&E<=8633||E==8658||E==8660||E==8679||E==8704||8706<=E&&E<=8707||8711<=E&&E<=8712||E==8715||E==8719||E==8721||E==8725||E==8730||8733<=E&&E<=8736||E==8739||E==8741||8743<=E&&E<=8748||E==8750||8756<=E&&E<=8759||8764<=E&&E<=8765||E==8776||E==8780||E==8786||8800<=E&&E<=8801||8804<=E&&E<=8807||8810<=E&&E<=8811||8814<=E&&E<=8815||8834<=E&&E<=8835||8838<=E&&E<=8839||E==8853||E==8857||E==8869||E==8895||E==8978||9312<=E&&E<=9449||9451<=E&&E<=9547||9552<=E&&E<=9587||9600<=E&&E<=9615||9618<=E&&E<=9621||9632<=E&&E<=9633||9635<=E&&E<=9641||9650<=E&&E<=9651||9654<=E&&E<=9655||9660<=E&&E<=9661||9664<=E&&E<=9665||9670<=E&&E<=9672||E==9675||9678<=E&&E<=9681||9698<=E&&E<=9701||E==9711||9733<=E&&E<=9734||E==9737||9742<=E&&E<=9743||9748<=E&&E<=9749||E==9756||E==9758||E==9792||E==9794||9824<=E&&E<=9825||9827<=E&&E<=9829||9831<=E&&E<=9834||9836<=E&&E<=9837||E==9839||9886<=E&&E<=9887||9918<=E&&E<=9919||9924<=E&&E<=9933||9935<=E&&E<=9953||E==9955||9960<=E&&E<=9983||E==10045||E==10071||10102<=E&&E<=10111||11093<=E&&E<=11097||12872<=E&&E<=12879||57344<=E&&E<=63743||65024<=E&&E<=65039||E==65533||127232<=E&&E<=127242||127248<=E&&E<=127277||127280<=E&&E<=127337||127344<=E&&E<=127386||917760<=E&&E<=917999||983040<=E&&E<=1048573||1048576<=E&&E<=1114109?"A":"N"},u.characterLength=function(C){var B=this.eastAsianWidth(C);return B=="F"||B=="W"||B=="A"?2:1};function F(C){return C.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}u.length=function(C){for(var B=F(C),$=0,E=0;E=B-(J==2?1:0))if(Q+J<=$)E+=Y;else break;Q+=J}return E}})(e3);var L7=e3.exports,R7=t3(L7),M7=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g},I7=t3(M7);function g0(D,u={}){if(typeof D!="string"||D.length===0||(u={ambiguousIsNarrow:!0,...u},D=s3(D),D.length===0))return 0;D=D.replace(I7()," ");let F=u.ambiguousIsNarrow?1:2,C=0;for(let B of D){let $=B.codePointAt(0);if($<=31||$>=127&&$<=159||$>=768&&$<=879)continue;switch(R7.eastAsianWidth(B)){case"F":case"W":C+=2;break;case"A":C+=F;break;default:C+=1}}return C}var xF=10,m3=(D=0)=>(u)=>`\x1B[${u+D}m`,d3=(D=0)=>(u)=>`\x1B[${38+D};5;${u}m`,c3=(D=0)=>(u,F,C)=>`\x1B[${38+D};2;${u};${F};${C}m`,d={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]}};Object.keys(d.modifier);var N7=Object.keys(d.color),O7=Object.keys(d.bgColor);[...N7];function j7(){let D=new Map;for(let[u,F]of Object.entries(d)){for(let[C,B]of Object.entries(F))d[C]={open:`\x1B[${B[0]}m`,close:`\x1B[${B[1]}m`},F[C]=d[C],D.set(B[0],B[1]);Object.defineProperty(d,u,{value:F,enumerable:!1})}return Object.defineProperty(d,"codes",{value:D,enumerable:!1}),d.color.close="\x1B[39m",d.bgColor.close="\x1B[49m",d.color.ansi=m3(),d.color.ansi256=d3(),d.color.ansi16m=c3(),d.bgColor.ansi=m3(xF),d.bgColor.ansi256=d3(xF),d.bgColor.ansi16m=c3(xF),Object.defineProperties(d,{rgbToAnsi256:{value:(u,F,C)=>u===F&&F===C?u<8?16:u>248?231:Math.round((u-8)/247*24)+232:16+36*Math.round(u/255*5)+6*Math.round(F/255*5)+Math.round(C/255*5),enumerable:!1},hexToRgb:{value:(u)=>{let F=/[a-f\d]{6}|[a-f\d]{3}/i.exec(u.toString(16));if(!F)return[0,0,0];let[C]=F;C.length===3&&(C=[...C].map(($)=>$+$).join(""));let B=Number.parseInt(C,16);return[B>>16&255,B>>8&255,B&255]},enumerable:!1},hexToAnsi256:{value:(u)=>d.rgbToAnsi256(...d.hexToRgb(u)),enumerable:!1},ansi256ToAnsi:{value:(u)=>{if(u<8)return 30+u;if(u<16)return 90+(u-8);let F,C,B;if(u>=232)F=((u-232)*10+8)/255,C=F,B=F;else{u-=16;let Q=u%36;F=Math.floor(u/36)/5,C=Math.floor(Q/6)/5,B=Q%6/5}let $=Math.max(F,C,B)*2;if($===0)return 30;let E=30+(Math.round(B)<<2|Math.round(C)<<1|Math.round(F));return $===2&&(E+=60),E},enumerable:!1},rgbToAnsi:{value:(u,F,C)=>d.ansi256ToAnsi(d.rgbToAnsi256(u,F,C)),enumerable:!1},hexToAnsi:{value:(u)=>d.ansi256ToAnsi(d.hexToAnsi256(u)),enumerable:!1}}),d}var T7=j7(),Tu=new Set(["\x1B","\x9B"]),w7=39,fF="\x07",D8="[",k7="]",u8="m",yF=`${k7}8;;`,l3=(D)=>`${Tu.values().next().value}${D8}${D}${u8}`,p3=(D)=>`${Tu.values().next().value}${yF}${D}${fF}`,P7=(D)=>D.split(" ").map((u)=>g0(u)),bF=(D,u,F)=>{let C=[...u],B=!1,$=!1,E=g0(s3(D[D.length-1]));for(let[Q,X]of C.entries()){let Z=g0(X);if(E+Z<=F?D[D.length-1]+=X:(D.push(X),E=0),Tu.has(X)&&(B=!0,$=C.slice(Q+1).join("").startsWith(yF)),B){$?X===fF&&(B=!1,$=!1):X===u8&&(B=!1);continue}E+=Z,E===F&&Q0&&D.length>1&&(D[D.length-2]+=D.pop())},S7=(D)=>{let u=D.split(" "),F=u.length;for(;F>0&&!(g0(u[F-1])>0);)F--;return F===u.length?D:u.slice(0,F).join(" ")+u.slice(F).join("")},x7=(D,u,F={})=>{if(F.trim!==!1&&D.trim()==="")return"";let C="",B,$,E=P7(D),Q=[""];for(let[Z,Y]of D.split(" ").entries()){F.trim!==!1&&(Q[Q.length-1]=Q[Q.length-1].trimStart());let J=g0(Q[Q.length-1]);if(Z!==0&&(J>=u&&(F.wordWrap===!1||F.trim===!1)&&(Q.push(""),J=0),(J>0||F.trim===!1)&&(Q[Q.length-1]+=" ",J++)),F.hard&&E[Z]>u){let A=u-J,H=1+Math.floor((E[Z]-A-1)/u);Math.floor((E[Z]-1)/u)u&&J>0&&E[Z]>0){if(F.wordWrap===!1&&Ju&&F.wordWrap===!1){bF(Q,Y,u);continue}Q[Q.length-1]+=Y}F.trim!==!1&&(Q=Q.map((Z)=>S7(Z)));let X=[...Q.join(` +`)];for(let[Z,Y]of X.entries()){if(C+=Y,Tu.has(Y)){let{groups:A}=new RegExp(`(?:\\${D8}(?\\d+)m|\\${yF}(?.*)${fF})`).exec(X.slice(Z).join(""))||{groups:{}};if(A.code!==void 0){let H=Number.parseFloat(A.code);B=H===w7?void 0:H}else A.uri!==void 0&&($=A.uri.length===0?void 0:A.uri)}let J=T7.codes.get(Number(B));X[Z+1]===` +`?($&&(C+=p3("")),B&&J&&(C+=l3(J))):Y===` +`&&(B&&J&&(C+=l3(B)),$&&(C+=p3($)))}return C};function a3(D,u,F){return String(D).normalize().replace(/\r\n/g,` `).split(` -`).map((C)=>P7(C,u,F)).join(` -`)}var S7=["up","down","left","right","space","enter","cancel"],ju={actions:new Set(S7),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["\x03","cancel"],["escape","cancel"]])};function hF(D,u){if(typeof D=="string")return ju.aliases.get(D)===u;for(let F of D)if(F!==void 0&&hF(F,u))return!0;return!1}function x7(D,u){if(D===u)return;let F=D.split(` +`).map((C)=>x7(C,u,F)).join(` +`)}var b7=["up","down","left","right","space","enter","cancel"],ju={actions:new Set(b7),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["\x03","cancel"],["escape","cancel"]])};function hF(D,u){if(typeof D=="string")return ju.aliases.get(D)===u;for(let F of D)if(F!==void 0&&hF(F,u))return!0;return!1}function v7(D,u){if(D===u)return;let F=D.split(` `),C=u.split(` -`),B=[];for(let $=0;${let Z=String(E);if(hF([Z,Q,X],"cancel")){C&&u.write(JD.cursor.show),process.exit(0);return}if(!F)return;X0.moveCursor(u,Q==="return"?0:-1,Q==="return"?-1:0,()=>{X0.clearLine(u,1,()=>{D.once("keypress",$)})})};return C&&u.write(JD.cursor.hide),D.once("keypress",$),()=>{D.off("keypress",$),C&&u.write(JD.cursor.show),D.isTTY&&!b7&&D.setRawMode(!1),B.terminal=!1,B.close()}}var v7=Object.defineProperty,f7=(D,u,F)=>(u in D)?v7(D,u,{enumerable:!0,configurable:!0,writable:!0,value:F}):D[u]=F,MD=(D,u,F)=>(f7(D,typeof u!="symbol"?u+"":u,F),F);class wu{constructor(D,u=!0){MD(this,"input"),MD(this,"output"),MD(this,"_abortSignal"),MD(this,"rl"),MD(this,"opts"),MD(this,"_render"),MD(this,"_track",!1),MD(this,"_prevFrame",""),MD(this,"_subscribers",new Map),MD(this,"_cursor",0),MD(this,"state","initial"),MD(this,"error",""),MD(this,"value");let{input:F=n3,output:C=r3,render:B,signal:$,...E}=D;this.opts=E,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=B.bind(this),this._track=u,this._abortSignal=$,this.input=F,this.output=C}unsubscribe(){this._subscribers.clear()}setSubscriber(D,u){let F=this._subscribers.get(D)??[];F.push(u),this._subscribers.set(D,F)}on(D,u){this.setSubscriber(D,{cb:u})}once(D,u){this.setSubscriber(D,{cb:u,once:!0})}emit(D,...u){let F=this._subscribers.get(D)??[],C=[];for(let B of F)B.cb(...u),B.once&&C.push(()=>F.splice(F.indexOf(B),1));for(let B of C)B()}prompt(){return new Promise((D,u)=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),D(vF);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}let F=new G7;F._write=(C,B,$)=>{this._track&&(this.value=this.rl?.line.replace(/\t/g,""),this._cursor=this.rl?.cursor??0,this.emit("value",this.value)),$()},this.input.pipe(F),this.rl=h3.createInterface({input:this.input,output:F,tabSize:2,prompt:"",escapeCodeTimeout:50,terminal:!0}),h3.emitKeypressEvents(this.input,this.rl),this.rl.prompt(),this.opts.initialValue!==void 0&&this._track&&this.rl.write(this.opts.initialValue),this.input.on("keypress",this.onKeypress),Ou(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(JD.cursor.show),this.output.off("resize",this.render),Ou(this.input,!1),D(this.value)}),this.once("cancel",()=>{this.output.write(JD.cursor.show),this.output.off("resize",this.render),Ou(this.input,!1),D(vF)})})}onKeypress(D,u){if(this.state==="error"&&(this.state="active"),u?.name&&(!this._track&&ju.aliases.has(u.name)&&this.emit("cursor",ju.aliases.get(u.name)),ju.actions.has(u.name)&&this.emit("cursor",u.name)),D&&(D.toLowerCase()==="y"||D.toLowerCase()==="n")&&this.emit("confirm",D.toLowerCase()==="y"),D==="\t"&&this.opts.placeholder&&(this.value||(this.rl?.write(this.opts.placeholder),this.emit("value",this.opts.placeholder))),D&&this.emit("key",D.toLowerCase()),u?.name==="return"){if(this.opts.validate){let F=this.opts.validate(this.value);F&&(this.error=F instanceof Error?F.message:F,this.state="error",this.rl?.write(this.value))}this.state!=="error"&&(this.state="submit")}hF([D,u?.name,u?.sequence],"cancel")&&(this.state="cancel"),(this.state==="submit"||this.state==="cancel")&&this.emit("finalize"),this.render(),(this.state==="submit"||this.state==="cancel")&&this.close()}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(` -`),Ou(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let D=p3(this._prevFrame,process.stdout.columns,{hard:!0}).split(` -`).length-1;this.output.write(JD.cursor.move(-999,D*-1))}render(){let D=p3(this._render(this)??"",process.stdout.columns,{hard:!0});if(D!==this._prevFrame){if(this.state==="initial")this.output.write(JD.cursor.hide);else{let u=x7(this._prevFrame,D);if(this.restoreCursor(),u&&u?.length===1){let F=u[0];this.output.write(JD.cursor.move(0,F)),this.output.write(JD.erase.lines(1));let C=D.split(` +`),B=[];for(let $=0;${let Z=String(E);if(hF([Z,Q,X],"cancel")){C&&u.write(JD.cursor.show),process.exit(0);return}if(!F)return;X0.moveCursor(u,Q==="return"?0:-1,Q==="return"?-1:0,()=>{X0.clearLine(u,1,()=>{D.once("keypress",$)})})};return C&&u.write(JD.cursor.hide),D.once("keypress",$),()=>{D.off("keypress",$),C&&u.write(JD.cursor.show),D.isTTY&&!f7&&D.setRawMode(!1),B.terminal=!1,B.close()}}var y7=Object.defineProperty,h7=(D,u,F)=>(u in D)?y7(D,u,{enumerable:!0,configurable:!0,writable:!0,value:F}):D[u]=F,MD=(D,u,F)=>(h7(D,typeof u!="symbol"?u+"":u,F),F);class wu{constructor(D,u=!0){MD(this,"input"),MD(this,"output"),MD(this,"_abortSignal"),MD(this,"rl"),MD(this,"opts"),MD(this,"_render"),MD(this,"_track",!1),MD(this,"_prevFrame",""),MD(this,"_subscribers",new Map),MD(this,"_cursor",0),MD(this,"state","initial"),MD(this,"error",""),MD(this,"value");let{input:F=r3,output:C=i3,render:B,signal:$,...E}=D;this.opts=E,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=B.bind(this),this._track=u,this._abortSignal=$,this.input=F,this.output=C}unsubscribe(){this._subscribers.clear()}setSubscriber(D,u){let F=this._subscribers.get(D)??[];F.push(u),this._subscribers.set(D,F)}on(D,u){this.setSubscriber(D,{cb:u})}once(D,u){this.setSubscriber(D,{cb:u,once:!0})}emit(D,...u){let F=this._subscribers.get(D)??[],C=[];for(let B of F)B.cb(...u),B.once&&C.push(()=>F.splice(F.indexOf(B),1));for(let B of C)B()}prompt(){return new Promise((D,u)=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),D(vF);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}let F=new _7;F._write=(C,B,$)=>{this._track&&(this.value=this.rl?.line.replace(/\t/g,""),this._cursor=this.rl?.cursor??0,this.emit("value",this.value)),$()},this.input.pipe(F),this.rl=g3.createInterface({input:this.input,output:F,tabSize:2,prompt:"",escapeCodeTimeout:50,terminal:!0}),g3.emitKeypressEvents(this.input,this.rl),this.rl.prompt(),this.opts.initialValue!==void 0&&this._track&&this.rl.write(this.opts.initialValue),this.input.on("keypress",this.onKeypress),Ou(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(JD.cursor.show),this.output.off("resize",this.render),Ou(this.input,!1),D(this.value)}),this.once("cancel",()=>{this.output.write(JD.cursor.show),this.output.off("resize",this.render),Ou(this.input,!1),D(vF)})})}onKeypress(D,u){if(this.state==="error"&&(this.state="active"),u?.name&&(!this._track&&ju.aliases.has(u.name)&&this.emit("cursor",ju.aliases.get(u.name)),ju.actions.has(u.name)&&this.emit("cursor",u.name)),D&&(D.toLowerCase()==="y"||D.toLowerCase()==="n")&&this.emit("confirm",D.toLowerCase()==="y"),D==="\t"&&this.opts.placeholder&&(this.value||(this.rl?.write(this.opts.placeholder),this.emit("value",this.opts.placeholder))),D&&this.emit("key",D.toLowerCase()),u?.name==="return"){if(this.opts.validate){let F=this.opts.validate(this.value);F&&(this.error=F instanceof Error?F.message:F,this.state="error",this.rl?.write(this.value))}this.state!=="error"&&(this.state="submit")}hF([D,u?.name,u?.sequence],"cancel")&&(this.state="cancel"),(this.state==="submit"||this.state==="cancel")&&this.emit("finalize"),this.render(),(this.state==="submit"||this.state==="cancel")&&this.close()}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(` +`),Ou(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let D=a3(this._prevFrame,process.stdout.columns,{hard:!0}).split(` +`).length-1;this.output.write(JD.cursor.move(-999,D*-1))}render(){let D=a3(this._render(this)??"",process.stdout.columns,{hard:!0});if(D!==this._prevFrame){if(this.state==="initial")this.output.write(JD.cursor.hide);else{let u=v7(this._prevFrame,D);if(this.restoreCursor(),u&&u?.length===1){let F=u[0];this.output.write(JD.cursor.move(0,F)),this.output.write(JD.erase.lines(1));let C=D.split(` `);this.output.write(C[F]),this._prevFrame=D,this.output.write(JD.cursor.move(0,C.length-F-1));return}if(u&&u?.length>1){let F=u[0];this.output.write(JD.cursor.move(0,F)),this.output.write(JD.erase.down());let C=D.split(` `).slice(F);this.output.write(C.join(` -`)),this._prevFrame=D;return}this.output.write(JD.erase.down())}this.output.write(D),this.state==="initial"&&(this.state="active"),this._prevFrame=D}}}class gF extends wu{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(D){super(D,!1),this.value=!!D.initialValue,this.on("value",()=>{this.value=this._value}),this.on("confirm",(u)=>{this.output.write(JD.cursor.move(0,-1)),this.value=u,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}}var y7;y7=new WeakMap;var h7=Object.defineProperty,g7=(D,u,F)=>(u in D)?h7(D,u,{enumerable:!0,configurable:!0,writable:!0,value:F}):D[u]=F,a3=(D,u,F)=>(g7(D,typeof u!="symbol"?u+"":u,F),F);class mF extends wu{constructor(D){super(D,!1),a3(this,"options"),a3(this,"cursor",0),this.options=D.options,this.cursor=this.options.findIndex(({value:u})=>u===D.initialValue),this.cursor===-1&&(this.cursor=0),this.changeValue(),this.on("cursor",(u)=>{switch(u){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break}this.changeValue()})}get _value(){return this.options[this.cursor]}changeValue(){this.value=this._value.value}}class dF extends wu{get valueWithCursor(){if(this.state==="submit")return this.value;if(this.cursor>=this.value.length)return`${this.value}\u2588`;let D=this.value.slice(0,this.cursor),[u,...F]=this.value.slice(this.cursor);return`${D}${i3.default.inverse(u)}${F.join("")}`}get cursor(){return this._cursor}constructor(D){super(D),this.on("finalize",()=>{this.value||(this.value=D.defaultValue)})}}var O=F0(SF(),1),ku=F0(kF(),1);import lD from"process";function m7(){return lD.platform!=="win32"?lD.env.TERM!=="linux":!!lD.env.CI||!!lD.env.WT_SESSION||!!lD.env.TERMINUS_SUBLIME||lD.env.ConEmuTask==="{cmd::Cmder}"||lD.env.TERM_PROGRAM==="Terminus-Sublime"||lD.env.TERM_PROGRAM==="vscode"||lD.env.TERM==="xterm-256color"||lD.env.TERM==="alacritty"||lD.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var cF=m7(),o=(D,u)=>cF?D:u,d7=o("\u25C6","*"),F8=o("\u25A0","x"),C8=o("\u25B2","x"),aF=o("\u25C7","o"),r5=o("\u250C","T"),a=o("\u2502","|"),m0=o("\u2514","\u2014"),lF=o("\u25CF",">"),pF=o("\u25CB"," "),i5=o("\u25FB","[\u2022]"),o5=o("\u25FC","[+]"),s5=o("\u25FB","[ ]"),t5=o("\u25AA","\u2022"),e5=o("\u2500","-"),D$=o("\u256E","+"),u$=o("\u251C","+"),F$=o("\u256F","+"),c7=o("\u25CF","\u2022"),l7=o("\u25C6","*"),p7=o("\u25B2","!"),a7=o("\u25A0","x"),nF=(D)=>{switch(D){case"initial":case"active":return O.default.cyan(d7);case"cancel":return O.default.red(F8);case"error":return O.default.yellow(C8);case"submit":return O.default.green(aF)}},n7=(D)=>{let{cursor:u,options:F,style:C}=D,B=D.maxItems??Number.POSITIVE_INFINITY,$=Math.max(process.stdout.rows-4,0),E=Math.min($,Math.max(B,5)),Q=0;u>=Q+E-3?Q=Math.max(Math.min(u-E+3,F.length-E),0):u0,Z=E{let H=J===0&&X,G=J===A.length-1&&Z;return H||G?O.default.dim("..."):C(Y,J+Q===u)})},B8=(D)=>new dF({validate:D.validate,placeholder:D.placeholder,defaultValue:D.defaultValue,initialValue:D.initialValue,render(){let u=`${O.default.gray(a)} +`)),this._prevFrame=D;return}this.output.write(JD.erase.down())}this.output.write(D),this.state==="initial"&&(this.state="active"),this._prevFrame=D}}}class gF extends wu{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(D){super(D,!1),this.value=!!D.initialValue,this.on("value",()=>{this.value=this._value}),this.on("confirm",(u)=>{this.output.write(JD.cursor.move(0,-1)),this.value=u,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}}var g7;g7=new WeakMap;var m7=Object.defineProperty,d7=(D,u,F)=>(u in D)?m7(D,u,{enumerable:!0,configurable:!0,writable:!0,value:F}):D[u]=F,n3=(D,u,F)=>(d7(D,typeof u!="symbol"?u+"":u,F),F);class mF extends wu{constructor(D){super(D,!1),n3(this,"options"),n3(this,"cursor",0),this.options=D.options,this.cursor=this.options.findIndex(({value:u})=>u===D.initialValue),this.cursor===-1&&(this.cursor=0),this.changeValue(),this.on("cursor",(u)=>{switch(u){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break}this.changeValue()})}get _value(){return this.options[this.cursor]}changeValue(){this.value=this._value.value}}class dF extends wu{get valueWithCursor(){if(this.state==="submit")return this.value;if(this.cursor>=this.value.length)return`${this.value}\u2588`;let D=this.value.slice(0,this.cursor),[u,...F]=this.value.slice(this.cursor);return`${D}${o3.default.inverse(u)}${F.join("")}`}get cursor(){return this._cursor}constructor(D){super(D),this.on("finalize",()=>{this.value||(this.value=D.defaultValue)})}}var O=F0(SF(),1),ku=F0(kF(),1);import lD from"process";function c7(){return lD.platform!=="win32"?lD.env.TERM!=="linux":!!lD.env.CI||!!lD.env.WT_SESSION||!!lD.env.TERMINUS_SUBLIME||lD.env.ConEmuTask==="{cmd::Cmder}"||lD.env.TERM_PROGRAM==="Terminus-Sublime"||lD.env.TERM_PROGRAM==="vscode"||lD.env.TERM==="xterm-256color"||lD.env.TERM==="alacritty"||lD.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var cF=c7(),o=(D,u)=>cF?D:u,l7=o("\u25C6","*"),C8=o("\u25A0","x"),B8=o("\u25B2","x"),aF=o("\u25C7","o"),o5=o("\u250C","T"),a=o("\u2502","|"),m0=o("\u2514","\u2014"),lF=o("\u25CF",">"),pF=o("\u25CB"," "),s5=o("\u25FB","[\u2022]"),t5=o("\u25FC","[+]"),e5=o("\u25FB","[ ]"),D$=o("\u25AA","\u2022"),u$=o("\u2500","-"),F$=o("\u256E","+"),C$=o("\u251C","+"),B$=o("\u256F","+"),p7=o("\u25CF","\u2022"),a7=o("\u25C6","*"),n7=o("\u25B2","!"),r7=o("\u25A0","x"),nF=(D)=>{switch(D){case"initial":case"active":return O.default.cyan(l7);case"cancel":return O.default.red(C8);case"error":return O.default.yellow(B8);case"submit":return O.default.green(aF)}},i7=(D)=>{let{cursor:u,options:F,style:C}=D,B=D.maxItems??Number.POSITIVE_INFINITY,$=Math.max(process.stdout.rows-4,0),E=Math.min($,Math.max(B,5)),Q=0;u>=Q+E-3?Q=Math.max(Math.min(u-E+3,F.length-E),0):u0,Z=E{let H=J===0&&X,G=J===A.length-1&&Z;return H||G?O.default.dim("..."):C(Y,J+Q===u)})},E8=(D)=>new dF({validate:D.validate,placeholder:D.placeholder,defaultValue:D.defaultValue,initialValue:D.initialValue,render(){let u=`${O.default.gray(a)} ${nF(this.state)} ${D.message} `,F=D.placeholder?O.default.inverse(D.placeholder[0])+O.default.dim(D.placeholder.slice(1)):O.default.inverse(O.default.hidden("_")),C=this.value?this.valueWithCursor:F;switch(this.state){case"error":return`${u.trim()} ${O.default.yellow(a)} ${C} @@ -483,7 +483,7 @@ ${O.default.cyan(m0)} `}}}).prompt()},Pu=(D)=>{let u=(F,C)=>{let B=F.label??String(F.value);switch(C){case"selected":return`${O.default.dim(B)}`;case"active":return`${O.default.green(lF)} ${B} ${F.hint?O.default.dim(`(${F.hint})`):""}`;case"cancelled":return`${O.default.strikethrough(O.default.dim(B))}`;default:return`${O.default.dim(pF)} ${O.default.dim(B)}`}};return new mF({options:D.options,initialValue:D.initialValue,render(){let F=`${O.default.gray(a)} ${nF(this.state)} ${D.message} `;switch(this.state){case"submit":return`${F}${O.default.gray(a)} ${u(this.options[this.cursor],"selected")}`;case"cancel":return`${F}${O.default.gray(a)} ${u(this.options[this.cursor],"cancelled")} -${O.default.gray(a)}`;default:return`${F}${O.default.cyan(a)} ${n7({cursor:this.cursor,options:this.options,maxItems:D.maxItems,style:(C,B)=>u(C,B?"active":"inactive")}).join(` +${O.default.gray(a)}`;default:return`${F}${O.default.cyan(a)} ${i7({cursor:this.cursor,options:this.options,maxItems:D.maxItems,style:(C,B)=>u(C,B?"active":"inactive")}).join(` ${O.default.cyan(a)} `)} ${O.default.cyan(m0)} `}}}).prompt()};var M0=(D="")=>{process.stdout.write(`${O.default.gray(m0)} ${O.default.red(D)} @@ -491,31 +491,31 @@ ${O.default.cyan(m0)} `)};var GD={message:(D="",{symbol:u=O.default.gray(a)}={})=>{let F=[`${O.default.gray(a)}`];if(D){let[C,...B]=D.split(` `);F.push(`${u} ${C}`,...B.map(($)=>`${O.default.gray(a)} ${$}`))}process.stdout.write(`${F.join(` `)} -`)},info:(D)=>{GD.message(D,{symbol:O.default.blue(c7)})},success:(D)=>{GD.message(D,{symbol:O.default.green(l7)})},step:(D)=>{GD.message(D,{symbol:O.default.green(aF)})},warn:(D)=>{GD.message(D,{symbol:O.default.yellow(p7)})},warning:(D)=>{GD.warn(D)},error:(D)=>{GD.message(D,{symbol:O.default.red(a7)})}},C$=`${O.default.gray(a)} `;var E8=({indicator:D="dots"}={})=>{let u=cF?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],F=cF?80:120,C=process.env.CI==="true",B,$,E=!1,Q="",X,Z=performance.now(),Y=(M)=>{let P=M>1?"Something went wrong":"Canceled";E&&R(P,M)},J=()=>Y(2),A=()=>Y(1),H=()=>{process.on("uncaughtExceptionMonitor",J),process.on("unhandledRejection",J),process.on("SIGINT",A),process.on("SIGTERM",A),process.on("exit",Y)},G=()=>{process.removeListener("uncaughtExceptionMonitor",J),process.removeListener("unhandledRejection",J),process.removeListener("SIGINT",A),process.removeListener("SIGTERM",A),process.removeListener("exit",Y)},z=()=>{if(X===void 0)return;C&&process.stdout.write(` +`)},info:(D)=>{GD.message(D,{symbol:O.default.blue(p7)})},success:(D)=>{GD.message(D,{symbol:O.default.green(a7)})},step:(D)=>{GD.message(D,{symbol:O.default.green(aF)})},warn:(D)=>{GD.message(D,{symbol:O.default.yellow(n7)})},warning:(D)=>{GD.warn(D)},error:(D)=>{GD.message(D,{symbol:O.default.red(r7)})}},E$=`${O.default.gray(a)} `;var $8=({indicator:D="dots"}={})=>{let u=cF?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],F=cF?80:120,C=process.env.CI==="true",B,$,E=!1,Q="",X,Z=performance.now(),Y=(M)=>{let P=M>1?"Something went wrong":"Canceled";E&&R(P,M)},J=()=>Y(2),A=()=>Y(1),H=()=>{process.on("uncaughtExceptionMonitor",J),process.on("unhandledRejection",J),process.on("SIGINT",A),process.on("SIGTERM",A),process.on("exit",Y)},G=()=>{process.removeListener("uncaughtExceptionMonitor",J),process.removeListener("unhandledRejection",J),process.removeListener("SIGINT",A),process.removeListener("SIGTERM",A),process.removeListener("exit",Y)},z=()=>{if(X===void 0)return;C&&process.stdout.write(` `);let M=X.split(` -`);process.stdout.write(ku.cursor.move(-999,M.length-1)),process.stdout.write(ku.erase.down(M.length))},U=(M)=>M.replace(/\.+$/,""),I=(M)=>{let P=(performance.now()-M)/1000,x=Math.floor(P/60),AD=Math.floor(P%60);return x>0?`[${x}m ${AD}s]`:`[${AD}s]`},j=(M="")=>{E=!0,B=u8(),Q=U(M),Z=performance.now(),process.stdout.write(`${O.default.gray(a)} -`);let P=0,x=0;H(),$=setInterval(()=>{if(C&&Q===X)return;z(),X=Q;let AD=O.default.magenta(u[P]);if(C)process.stdout.write(`${AD} ${Q}...`);else if(D==="timer")process.stdout.write(`${AD} ${Q} ${I(Z)}`);else{let wD=".".repeat(Math.floor(x)).slice(0,3);process.stdout.write(`${AD} ${Q}${wD}`)}P=P+1{E=!1,clearInterval($),z();let x=P===0?O.default.green(aF):P===1?O.default.red(F8):O.default.red(C8);Q=U(M??Q),D==="timer"?process.stdout.write(`${x} ${Q} ${I(Z)} +`);process.stdout.write(ku.cursor.move(-999,M.length-1)),process.stdout.write(ku.erase.down(M.length))},U=(M)=>M.replace(/\.+$/,""),I=(M)=>{let P=(performance.now()-M)/1000,x=Math.floor(P/60),AD=Math.floor(P%60);return x>0?`[${x}m ${AD}s]`:`[${AD}s]`},j=(M="")=>{E=!0,B=F8(),Q=U(M),Z=performance.now(),process.stdout.write(`${O.default.gray(a)} +`);let P=0,x=0;H(),$=setInterval(()=>{if(C&&Q===X)return;z(),X=Q;let AD=O.default.magenta(u[P]);if(C)process.stdout.write(`${AD} ${Q}...`);else if(D==="timer")process.stdout.write(`${AD} ${Q} ${I(Z)}`);else{let wD=".".repeat(Math.floor(x)).slice(0,3);process.stdout.write(`${AD} ${Q}${wD}`)}P=P+1{E=!1,clearInterval($),z();let x=P===0?O.default.green(aF):P===1?O.default.red(C8):O.default.red(B8);Q=U(M??Q),D==="timer"?process.stdout.write(`${x} ${Q} ${I(Z)} `):process.stdout.write(`${x} ${Q} -`),G(),B()};return{start:j,stop:R,message:(M="")=>{Q=U(M??Q)}}};var $8=(D=0)=>(u)=>`\x1B[${u+D}m`,Q8=(D=0)=>(u)=>`\x1B[${38+D};5;${u}m`,X8=(D=0)=>(u,F,C)=>`\x1B[${38+D};2;${u};${F};${C}m`,c={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]}},E$=Object.keys(c.modifier),r7=Object.keys(c.color),i7=Object.keys(c.bgColor),$$=[...r7,...i7];function o7(){let D=new Map;for(let[u,F]of Object.entries(c)){for(let[C,B]of Object.entries(F))c[C]={open:`\x1B[${B[0]}m`,close:`\x1B[${B[1]}m`},F[C]=c[C],D.set(B[0],B[1]);Object.defineProperty(c,u,{value:F,enumerable:!1})}return Object.defineProperty(c,"codes",{value:D,enumerable:!1}),c.color.close="\x1B[39m",c.bgColor.close="\x1B[49m",c.color.ansi=$8(),c.color.ansi256=Q8(),c.color.ansi16m=X8(),c.bgColor.ansi=$8(10),c.bgColor.ansi256=Q8(10),c.bgColor.ansi16m=X8(10),Object.defineProperties(c,{rgbToAnsi256:{value(u,F,C){if(u===F&&F===C){if(u<8)return 16;if(u>248)return 231;return Math.round((u-8)/247*24)+232}return 16+36*Math.round(u/255*5)+6*Math.round(F/255*5)+Math.round(C/255*5)},enumerable:!1},hexToRgb:{value(u){let F=/[a-f\d]{6}|[a-f\d]{3}/i.exec(u.toString(16));if(!F)return[0,0,0];let[C]=F;if(C.length===3)C=[...C].map(($)=>$+$).join("");let B=Number.parseInt(C,16);return[B>>16&255,B>>8&255,B&255]},enumerable:!1},hexToAnsi256:{value:(u)=>c.rgbToAnsi256(...c.hexToRgb(u)),enumerable:!1},ansi256ToAnsi:{value(u){if(u<8)return 30+u;if(u<16)return 90+(u-8);let F,C,B;if(u>=232)F=((u-232)*10+8)/255,C=F,B=F;else{u-=16;let Q=u%36;F=Math.floor(u/36)/5,C=Math.floor(Q/6)/5,B=Q%6/5}let $=Math.max(F,C,B)*2;if($===0)return 30;let E=30+(Math.round(B)<<2|Math.round(C)<<1|Math.round(F));if($===2)E+=60;return E},enumerable:!1},rgbToAnsi:{value:(u,F,C)=>c.ansi256ToAnsi(c.rgbToAnsi256(u,F,C)),enumerable:!1},hexToAnsi:{value:(u)=>c.ansi256ToAnsi(c.hexToAnsi256(u)),enumerable:!1}}),c}var s7=o7(),pD=s7;import rF from"process";import t7 from"os";import Z8 from"tty";function SD(D,u=globalThis.Deno?globalThis.Deno.args:rF.argv){let F=D.startsWith("-")?"":D.length===1?"-":"--",C=u.indexOf(F+D),B=u.indexOf("--");return C!==-1&&(B===-1||C=2,has16m:D>=3}}function u9(D,{streamIsTTY:u,sniffFlags:F=!0}={}){let C=e7();if(C!==void 0)xu=C;let B=F?xu:C;if(B===0)return 0;if(F){if(SD("color=16m")||SD("color=full")||SD("color=truecolor"))return 3;if(SD("color=256"))return 2}if("TF_BUILD"in l&&"AGENT_NAME"in l)return 1;if(D&&!u&&B===void 0)return 0;let $=B||0;if(l.TERM==="dumb")return $;if(rF.platform==="win32"){let E=t7.release().split(".");if(Number(E[0])>=10&&Number(E[2])>=10586)return Number(E[2])>=14931?3:2;return 1}if("CI"in l){if(["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some((E)=>(E in l)))return 3;if(["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some((E)=>(E in l))||l.CI_NAME==="codeship")return 1;return $}if("TEAMCITY_VERSION"in l)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(l.TEAMCITY_VERSION)?1:0;if(l.COLORTERM==="truecolor")return 3;if(l.TERM==="xterm-kitty")return 3;if(l.TERM==="xterm-ghostty")return 3;if(l.TERM==="wezterm")return 3;if("TERM_PROGRAM"in l){let E=Number.parseInt((l.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(l.TERM_PROGRAM){case"iTerm.app":return E>=3?3:2;case"Apple_Terminal":return 2}}if(/-256(color)?$/i.test(l.TERM))return 2;if(/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(l.TERM))return 1;if("COLORTERM"in l)return 1;return $}function Y8(D,u={}){let F=u9(D,{streamIsTTY:D&&D.isTTY,...u});return D9(F)}var F9={stdout:Y8({isTTY:Z8.isatty(1)}),stderr:Y8({isTTY:Z8.isatty(2)})},J8=F9;function K8(D,u,F){let C=D.indexOf(u);if(C===-1)return D;let B=u.length,$=0,E="";do E+=D.slice($,C)+u+F,$=C+B,C=D.indexOf(u,$);while(C!==-1);return E+=D.slice($),E}function q8(D,u,F,C){let B=0,$="";do{let E=D[C-1]==="\r";$+=D.slice(B,E?C-1:C)+u+(E?`\r +`),G(),B()};return{start:j,stop:R,message:(M="")=>{Q=U(M??Q)}}};var Q8=(D=0)=>(u)=>`\x1B[${u+D}m`,X8=(D=0)=>(u)=>`\x1B[${38+D};5;${u}m`,Z8=(D=0)=>(u,F,C)=>`\x1B[${38+D};2;${u};${F};${C}m`,c={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]}},Q$=Object.keys(c.modifier),o7=Object.keys(c.color),s7=Object.keys(c.bgColor),X$=[...o7,...s7];function t7(){let D=new Map;for(let[u,F]of Object.entries(c)){for(let[C,B]of Object.entries(F))c[C]={open:`\x1B[${B[0]}m`,close:`\x1B[${B[1]}m`},F[C]=c[C],D.set(B[0],B[1]);Object.defineProperty(c,u,{value:F,enumerable:!1})}return Object.defineProperty(c,"codes",{value:D,enumerable:!1}),c.color.close="\x1B[39m",c.bgColor.close="\x1B[49m",c.color.ansi=Q8(),c.color.ansi256=X8(),c.color.ansi16m=Z8(),c.bgColor.ansi=Q8(10),c.bgColor.ansi256=X8(10),c.bgColor.ansi16m=Z8(10),Object.defineProperties(c,{rgbToAnsi256:{value(u,F,C){if(u===F&&F===C){if(u<8)return 16;if(u>248)return 231;return Math.round((u-8)/247*24)+232}return 16+36*Math.round(u/255*5)+6*Math.round(F/255*5)+Math.round(C/255*5)},enumerable:!1},hexToRgb:{value(u){let F=/[a-f\d]{6}|[a-f\d]{3}/i.exec(u.toString(16));if(!F)return[0,0,0];let[C]=F;if(C.length===3)C=[...C].map(($)=>$+$).join("");let B=Number.parseInt(C,16);return[B>>16&255,B>>8&255,B&255]},enumerable:!1},hexToAnsi256:{value:(u)=>c.rgbToAnsi256(...c.hexToRgb(u)),enumerable:!1},ansi256ToAnsi:{value(u){if(u<8)return 30+u;if(u<16)return 90+(u-8);let F,C,B;if(u>=232)F=((u-232)*10+8)/255,C=F,B=F;else{u-=16;let Q=u%36;F=Math.floor(u/36)/5,C=Math.floor(Q/6)/5,B=Q%6/5}let $=Math.max(F,C,B)*2;if($===0)return 30;let E=30+(Math.round(B)<<2|Math.round(C)<<1|Math.round(F));if($===2)E+=60;return E},enumerable:!1},rgbToAnsi:{value:(u,F,C)=>c.ansi256ToAnsi(c.rgbToAnsi256(u,F,C)),enumerable:!1},hexToAnsi:{value:(u)=>c.ansi256ToAnsi(c.hexToAnsi256(u)),enumerable:!1}}),c}var e7=t7(),pD=e7;import rF from"process";import D9 from"os";import Y8 from"tty";function SD(D,u=globalThis.Deno?globalThis.Deno.args:rF.argv){let F=D.startsWith("-")?"":D.length===1?"-":"--",C=u.indexOf(F+D),B=u.indexOf("--");return C!==-1&&(B===-1||C=2,has16m:D>=3}}function C9(D,{streamIsTTY:u,sniffFlags:F=!0}={}){let C=u9();if(C!==void 0)xu=C;let B=F?xu:C;if(B===0)return 0;if(F){if(SD("color=16m")||SD("color=full")||SD("color=truecolor"))return 3;if(SD("color=256"))return 2}if("TF_BUILD"in l&&"AGENT_NAME"in l)return 1;if(D&&!u&&B===void 0)return 0;let $=B||0;if(l.TERM==="dumb")return $;if(rF.platform==="win32"){let E=D9.release().split(".");if(Number(E[0])>=10&&Number(E[2])>=10586)return Number(E[2])>=14931?3:2;return 1}if("CI"in l){if(["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some((E)=>(E in l)))return 3;if(["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some((E)=>(E in l))||l.CI_NAME==="codeship")return 1;return $}if("TEAMCITY_VERSION"in l)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(l.TEAMCITY_VERSION)?1:0;if(l.COLORTERM==="truecolor")return 3;if(l.TERM==="xterm-kitty")return 3;if(l.TERM==="xterm-ghostty")return 3;if(l.TERM==="wezterm")return 3;if("TERM_PROGRAM"in l){let E=Number.parseInt((l.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(l.TERM_PROGRAM){case"iTerm.app":return E>=3?3:2;case"Apple_Terminal":return 2}}if(/-256(color)?$/i.test(l.TERM))return 2;if(/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(l.TERM))return 1;if("COLORTERM"in l)return 1;return $}function J8(D,u={}){let F=C9(D,{streamIsTTY:D&&D.isTTY,...u});return F9(F)}var B9={stdout:J8({isTTY:Y8.isatty(1)}),stderr:J8({isTTY:Y8.isatty(2)})},K8=B9;function q8(D,u,F){let C=D.indexOf(u);if(C===-1)return D;let B=u.length,$=0,E="";do E+=D.slice($,C)+u+F,$=C+B,C=D.indexOf(u,$);while(C!==-1);return E+=D.slice($),E}function V8(D,u,F,C){let B=0,$="";do{let E=D[C-1]==="\r";$+=D.slice(B,E?C-1:C)+u+(E?`\r `:` `)+F,B=C+1,C=D.indexOf(` -`,B)}while(C!==-1);return $+=D.slice(B),$}var{stdout:V8,stderr:A8}=J8,iF=Symbol("GENERATOR"),I0=Symbol("STYLER"),d0=Symbol("IS_EMPTY"),H8=["ansi","ansi","ansi256","ansi16m"],N0=Object.create(null),C9=(D,u={})=>{if(u.level&&!(Number.isInteger(u.level)&&u.level>=0&&u.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");let F=V8?V8.level:0;D.level=u.level===void 0?F:u.level};var B9=(D)=>{let u=(...F)=>F.join(" ");return C9(u,D),Object.setPrototypeOf(u,c0.prototype),u};function c0(D){return B9(D)}Object.setPrototypeOf(c0.prototype,Function.prototype);for(let[D,u]of Object.entries(pD))N0[D]={get(){let F=bu(this,sF(u.open,u.close,this[I0]),this[d0]);return Object.defineProperty(this,D,{value:F}),F}};N0.visible={get(){let D=bu(this,this[I0],!0);return Object.defineProperty(this,"visible",{value:D}),D}};var oF=(D,u,F,...C)=>{if(D==="rgb"){if(u==="ansi16m")return pD[F].ansi16m(...C);if(u==="ansi256")return pD[F].ansi256(pD.rgbToAnsi256(...C));return pD[F].ansi(pD.rgbToAnsi(...C))}if(D==="hex")return oF("rgb",u,F,...pD.hexToRgb(...C));return pD[F][D](...C)},E9=["rgb","hex","ansi256"];for(let D of E9){N0[D]={get(){let{level:F}=this;return function(...C){let B=sF(oF(D,H8[F],"color",...C),pD.color.close,this[I0]);return bu(this,B,this[d0])}}};let u="bg"+D[0].toUpperCase()+D.slice(1);N0[u]={get(){let{level:F}=this;return function(...C){let B=sF(oF(D,H8[F],"bgColor",...C),pD.bgColor.close,this[I0]);return bu(this,B,this[d0])}}}}var $9=Object.defineProperties(()=>{},{...N0,level:{enumerable:!0,get(){return this[iF].level},set(D){this[iF].level=D}}}),sF=(D,u,F)=>{let C,B;if(F===void 0)C=D,B=u;else C=F.openAll+D,B=u+F.closeAll;return{open:D,close:u,openAll:C,closeAll:B,parent:F}},bu=(D,u,F)=>{let C=(...B)=>Q9(C,B.length===1?""+B[0]:B.join(" "));return Object.setPrototypeOf(C,$9),C[iF]=D,C[I0]=u,C[d0]=F,C},Q9=(D,u)=>{if(D.level<=0||!u)return D[d0]?"":u;let F=D[I0];if(F===void 0)return u;let{openAll:C,closeAll:B}=F;if(u.includes("\x1B"))while(F!==void 0)u=K8(u,F.close,F.open),F=F.parent;let $=u.indexOf(` -`);if($!==-1)u=q8(u,B,C,$);return C+u+B};Object.defineProperties(c0.prototype,N0);var X9=c0(),H$=c0({level:A8?A8.level:0});var S=X9;var C2=F0(M8(),1),KD=(...D)=>{let u,F;if(D.length===0)throw new Error("Missing gradient colors");if(!Array.isArray(D[0])){if(D.length===1)throw new Error(`Expected an array of colors, received ${JSON.stringify(D[0])}`);u=C2.default(...D)}else u=C2.default(D[0]),F=B2(D[1]);let C=(B,$)=>{return Z9(B?B.toString():"",u,$??F)};return C.multiline=(B,$)=>Y9(B?B.toString():"",u,$??F),C},I8=(D,u,F)=>{return u.interpolation?.toLowerCase()==="hsv"?D.hsv(F,u.hsvSpin?.toLowerCase()||!1):D.rgb(F)};function Z9(D,u,F){let C=B2(F),B=Math.max(D.replace(/\s/g,"").length,u.stops.length),$=I8(u,C,B),E="";for(let Q of D)E+=Q.match(/\s/g)?Q:S.hex($.shift()?.toHex()||"#000")(Q);return E}function Y9(D,u,F){let C=B2(F),B=D.split(` -`),$=Math.max(...B.map((X)=>X.length),u.stops.length),E=I8(u,C,$),Q=[];for(let X of B){let Z=E.slice(0),Y="";for(let J of X)Y+=S.hex(Z.shift()?.toHex()||"#000")(J);Q.push(Y)}return Q.join(` -`)}function B2(D){let u={interpolation:"rgb",hsvSpin:"short",...D};if(D!==void 0&&typeof D!=="object")throw new TypeError(`Expected \`options\` to be an \`object\`, got \`${typeof D}\``);if(typeof u.interpolation!=="string")throw new TypeError(`Expected \`options.interpolation\` to be \`rgb\` or \`hsv\`, got \`${typeof u.interpolation}\``);if(u.interpolation.toLowerCase()==="hsv"&&typeof u.hsvSpin!=="string")throw new TypeError(`Expected \`options.hsvSpin\` to be a \`short\` or \`long\`, got \`${typeof u.hsvSpin}\``);return u}var ID={atlas:{colors:["#feac5e","#c779d0","#4bc0c8"],options:{}},cristal:{colors:["#bdfff3","#4ac29a"],options:{}},teen:{colors:["#77a1d3","#79cbca","#e684ae"],options:{}},mind:{colors:["#473b7b","#3584a7","#30d2be"],options:{}},morning:{colors:["#ff5f6d","#ffc371"],options:{interpolation:"hsv"}},vice:{colors:["#5ee7df","#b490ca"],options:{interpolation:"hsv"}},passion:{colors:["#f43b47","#453a94"],options:{}},fruit:{colors:["#ff4e50","#f9d423"],options:{}},instagram:{colors:["#833ab4","#fd1d1d","#fcb045"],options:{}},retro:{colors:["#3f51b1","#5a55ae","#7b5fac","#8f6aae","#a86aa4","#cc6b8e","#f18271","#f3a469","#f7c978"],options:{}},summer:{colors:["#fdbb2d","#22c1c3"],options:{}},rainbow:{colors:["#ff0000","#ff0100"],options:{interpolation:"hsv",hsvSpin:"long"}},pastel:{colors:["#74ebd5","#74ecd5"],options:{interpolation:"hsv",hsvSpin:"long"}}};function ND(D){let u=(F)=>KD(...D.colors)(F,D.options);return u.multiline=(F="")=>KD(...D.colors).multiline(F,D.options),u}var E2=KD,J9=ND(ID.atlas),K9=ND(ID.cristal),q9=ND(ID.teen),V9=ND(ID.mind),A9=ND(ID.morning),H9=ND(ID.vice),G9=ND(ID.passion),z9=ND(ID.fruit),_9=ND(ID.instagram),U9=ND(ID.retro),W9=ND(ID.summer),L9=ND(ID.rainbow),R9=ND(ID.pastel);KD.atlas=J9;KD.cristal=K9;KD.teen=q9;KD.mind=V9;KD.morning=A9;KD.vice=H9;KD.passion=G9;KD.fruit=z9;KD.instagram=_9;KD.retro=U9;KD.summer=W9;KD.rainbow=L9;KD.pastel=R9;import mu from"process";function $2({onlyFirst:D=!1}={}){return new RegExp("(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]",D?void 0:"g")}var M9=$2();function p0(D){if(typeof D!=="string")throw new TypeError(`Expected a \`string\`, got \`${typeof D}\``);return D.replace(M9,"")}function N8(D){return D===161||D===164||D===167||D===168||D===170||D===173||D===174||D>=176&&D<=180||D>=182&&D<=186||D>=188&&D<=191||D===198||D===208||D===215||D===216||D>=222&&D<=225||D===230||D>=232&&D<=234||D===236||D===237||D===240||D===242||D===243||D>=247&&D<=250||D===252||D===254||D===257||D===273||D===275||D===283||D===294||D===295||D===299||D>=305&&D<=307||D===312||D>=319&&D<=322||D===324||D>=328&&D<=331||D===333||D===338||D===339||D===358||D===359||D===363||D===462||D===464||D===466||D===468||D===470||D===472||D===474||D===476||D===593||D===609||D===708||D===711||D>=713&&D<=715||D===717||D===720||D>=728&&D<=731||D===733||D===735||D>=768&&D<=879||D>=913&&D<=929||D>=931&&D<=937||D>=945&&D<=961||D>=963&&D<=969||D===1025||D>=1040&&D<=1103||D===1105||D===8208||D>=8211&&D<=8214||D===8216||D===8217||D===8220||D===8221||D>=8224&&D<=8226||D>=8228&&D<=8231||D===8240||D===8242||D===8243||D===8245||D===8251||D===8254||D===8308||D===8319||D>=8321&&D<=8324||D===8364||D===8451||D===8453||D===8457||D===8467||D===8470||D===8481||D===8482||D===8486||D===8491||D===8531||D===8532||D>=8539&&D<=8542||D>=8544&&D<=8555||D>=8560&&D<=8569||D===8585||D>=8592&&D<=8601||D===8632||D===8633||D===8658||D===8660||D===8679||D===8704||D===8706||D===8707||D===8711||D===8712||D===8715||D===8719||D===8721||D===8725||D===8730||D>=8733&&D<=8736||D===8739||D===8741||D>=8743&&D<=8748||D===8750||D>=8756&&D<=8759||D===8764||D===8765||D===8776||D===8780||D===8786||D===8800||D===8801||D>=8804&&D<=8807||D===8810||D===8811||D===8814||D===8815||D===8834||D===8835||D===8838||D===8839||D===8853||D===8857||D===8869||D===8895||D===8978||D>=9312&&D<=9449||D>=9451&&D<=9547||D>=9552&&D<=9587||D>=9600&&D<=9615||D>=9618&&D<=9621||D===9632||D===9633||D>=9635&&D<=9641||D===9650||D===9651||D===9654||D===9655||D===9660||D===9661||D===9664||D===9665||D>=9670&&D<=9672||D===9675||D>=9678&&D<=9681||D>=9698&&D<=9701||D===9711||D===9733||D===9734||D===9737||D===9742||D===9743||D===9756||D===9758||D===9792||D===9794||D===9824||D===9825||D>=9827&&D<=9829||D>=9831&&D<=9834||D===9836||D===9837||D===9839||D===9886||D===9887||D===9919||D>=9926&&D<=9933||D>=9935&&D<=9939||D>=9941&&D<=9953||D===9955||D===9960||D===9961||D>=9963&&D<=9969||D===9972||D>=9974&&D<=9977||D===9979||D===9980||D===9982||D===9983||D===10045||D>=10102&&D<=10111||D>=11094&&D<=11097||D>=12872&&D<=12879||D>=57344&&D<=63743||D>=65024&&D<=65039||D===65533||D>=127232&&D<=127242||D>=127248&&D<=127277||D>=127280&&D<=127337||D>=127344&&D<=127373||D===127375||D===127376||D>=127387&&D<=127404||D>=917760&&D<=917999||D>=983040&&D<=1048573||D>=1048576&&D<=1114109}function O8(D){return D===12288||D>=65281&&D<=65376||D>=65504&&D<=65510}function j8(D){return D>=4352&&D<=4447||D===8986||D===8987||D===9001||D===9002||D>=9193&&D<=9196||D===9200||D===9203||D===9725||D===9726||D===9748||D===9749||D>=9776&&D<=9783||D>=9800&&D<=9811||D===9855||D>=9866&&D<=9871||D===9875||D===9889||D===9898||D===9899||D===9917||D===9918||D===9924||D===9925||D===9934||D===9940||D===9962||D===9970||D===9971||D===9973||D===9978||D===9981||D===9989||D===9994||D===9995||D===10024||D===10060||D===10062||D>=10067&&D<=10069||D===10071||D>=10133&&D<=10135||D===10160||D===10175||D===11035||D===11036||D===11088||D===11093||D>=11904&&D<=11929||D>=11931&&D<=12019||D>=12032&&D<=12245||D>=12272&&D<=12287||D>=12289&&D<=12350||D>=12353&&D<=12438||D>=12441&&D<=12543||D>=12549&&D<=12591||D>=12593&&D<=12686||D>=12688&&D<=12773||D>=12783&&D<=12830||D>=12832&&D<=12871||D>=12880&&D<=42124||D>=42128&&D<=42182||D>=43360&&D<=43388||D>=44032&&D<=55203||D>=63744&&D<=64255||D>=65040&&D<=65049||D>=65072&&D<=65106||D>=65108&&D<=65126||D>=65128&&D<=65131||D>=94176&&D<=94180||D>=94192&&D<=94198||D>=94208&&D<=101589||D>=101631&&D<=101662||D>=101760&&D<=101874||D>=110576&&D<=110579||D>=110581&&D<=110587||D===110589||D===110590||D>=110592&&D<=110882||D===110898||D>=110928&&D<=110930||D===110933||D>=110948&&D<=110951||D>=110960&&D<=111355||D>=119552&&D<=119638||D>=119648&&D<=119670||D===126980||D===127183||D===127374||D>=127377&&D<=127386||D>=127488&&D<=127490||D>=127504&&D<=127547||D>=127552&&D<=127560||D===127568||D===127569||D>=127584&&D<=127589||D>=127744&&D<=127776||D>=127789&&D<=127797||D>=127799&&D<=127868||D>=127870&&D<=127891||D>=127904&&D<=127946||D>=127951&&D<=127955||D>=127968&&D<=127984||D===127988||D>=127992&&D<=128062||D===128064||D>=128066&&D<=128252||D>=128255&&D<=128317||D>=128331&&D<=128334||D>=128336&&D<=128359||D===128378||D===128405||D===128406||D===128420||D>=128507&&D<=128591||D>=128640&&D<=128709||D===128716||D>=128720&&D<=128722||D>=128725&&D<=128728||D>=128732&&D<=128735||D===128747||D===128748||D>=128756&&D<=128764||D>=128992&&D<=129003||D===129008||D>=129292&&D<=129338||D>=129340&&D<=129349||D>=129351&&D<=129535||D>=129648&&D<=129660||D>=129664&&D<=129674||D>=129678&&D<=129734||D===129736||D>=129741&&D<=129756||D>=129759&&D<=129770||D>=129775&&D<=129784||D>=131072&&D<=196605||D>=196608&&D<=262141}function I9(D){if(!Number.isSafeInteger(D))throw new TypeError(`Expected a code point, got \`${typeof D}\`.`)}function T8(D,{ambiguousAsWide:u=!1}={}){if(I9(D),O8(D)||j8(D)||u&&N8(D))return 2;return 1}var w8=()=>{return/[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E-\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED8\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])))?))?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3C-\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE8A\uDE8E-\uDEC2\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF]|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g};var N9=new Intl.Segmenter,O9=/^\p{Default_Ignorable_Code_Point}$/u;function zD(D,u={}){if(typeof D!=="string"||D.length===0)return 0;let{ambiguousIsNarrow:F=!0,countAnsiEscapeCodes:C=!1}=u;if(!C)D=p0(D);if(D.length===0)return 0;let B=0,$={ambiguousAsWide:!F};for(let{segment:E}of N9.segment(D)){let Q=E.codePointAt(0);if(Q<=31||Q>=127&&Q<=159)continue;if(Q>=8203&&Q<=8207||Q===65279)continue;if(Q>=768&&Q<=879||Q>=6832&&Q<=6911||Q>=7616&&Q<=7679||Q>=8400&&Q<=8447||Q>=65056&&Q<=65071)continue;if(Q>=55296&&Q<=57343)continue;if(Q>=65024&&Q<=65039)continue;if(O9.test(E))continue;if(w8().test(E)){B+=2;continue}B+=T8(Q,$)}return B}function fu(D){let u=0;for(let F of D.split(` -`))u=Math.max(u,zD(F));return u}var $6=F0(X2(),1);var T9=/[\p{Lu}]/u,w9=/[\p{Ll}]/u,S8=/^[\p{Lu}](?![\p{Lu}])/gu,v8=/([\p{Alpha}\p{N}_]|$)/u,Z2=/[_.\- ]+/,k9=new RegExp("^"+Z2.source),x8=new RegExp(Z2.source+v8.source,"gu"),b8=new RegExp("\\d+"+v8.source,"gu"),P9=(D,u,F,C)=>{let B=!1,$=!1,E=!1,Q=!1;for(let X=0;X2?D[X-3]==="-":!0,B&&T9.test(Z))D=D.slice(0,X)+"-"+D.slice(X),B=!1,E=$,$=!0,X++;else if($&&E&&w9.test(Z)&&(!Q||C))D=D.slice(0,X-1)+"-"+D.slice(X-1),E=$,$=!1,B=!0;else B=u(Z)===Z&&F(Z)!==Z,E=$,$=F(Z)===Z&&u(Z)!==Z}return D},S9=(D,u)=>{return S8.lastIndex=0,D.replaceAll(S8,(F)=>u(F))},x9=(D,u)=>{return x8.lastIndex=0,b8.lastIndex=0,D.replaceAll(b8,(F,C,B)=>["_","-"].includes(D.charAt(B+F.length))?F:u(F)).replaceAll(x8,(F,C)=>u(C))};function Y2(D,u){if(!(typeof D==="string"||Array.isArray(D)))throw new TypeError("Expected the input to be `string | string[]`");if(u={pascalCase:!1,preserveConsecutiveUppercase:!1,...u},Array.isArray(D))D=D.map(($)=>$.trim()).filter(($)=>$.length).join("-");else D=D.trim();if(D.length===0)return"";let F=u.locale===!1?($)=>$.toLowerCase():($)=>$.toLocaleLowerCase(u.locale),C=u.locale===!1?($)=>$.toUpperCase():($)=>$.toLocaleUpperCase(u.locale);if(D.length===1){if(Z2.test(D))return"";return u.pascalCase?C(D):F(D)}if(D!==F(D))D=P9(D,F,C,u.preserveConsecutiveUppercase);if(D=D.replace(k9,""),D=u.preserveConsecutiveUppercase?S9(D,F):F(D),u.pascalCase)D=C(D.charAt(0))+D.slice(1);return x9(D,C)}var A2=F0(r8(),1);var i8=(D=0)=>(u)=>`\x1B[${u+D}m`,o8=(D=0)=>(u)=>`\x1B[${38+D};5;${u}m`,s8=(D=0)=>(u,F,C)=>`\x1B[${38+D};2;${u};${F};${C}m`,p={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]}},l$=Object.keys(p.modifier),d9=Object.keys(p.color),c9=Object.keys(p.bgColor),p$=[...d9,...c9];function l9(){let D=new Map;for(let[u,F]of Object.entries(p)){for(let[C,B]of Object.entries(F))p[C]={open:`\x1B[${B[0]}m`,close:`\x1B[${B[1]}m`},F[C]=p[C],D.set(B[0],B[1]);Object.defineProperty(p,u,{value:F,enumerable:!1})}return Object.defineProperty(p,"codes",{value:D,enumerable:!1}),p.color.close="\x1B[39m",p.bgColor.close="\x1B[49m",p.color.ansi=i8(),p.color.ansi256=o8(),p.color.ansi16m=s8(),p.bgColor.ansi=i8(10),p.bgColor.ansi256=o8(10),p.bgColor.ansi16m=s8(10),Object.defineProperties(p,{rgbToAnsi256:{value(u,F,C){if(u===F&&F===C){if(u<8)return 16;if(u>248)return 231;return Math.round((u-8)/247*24)+232}return 16+36*Math.round(u/255*5)+6*Math.round(F/255*5)+Math.round(C/255*5)},enumerable:!1},hexToRgb:{value(u){let F=/[a-f\d]{6}|[a-f\d]{3}/i.exec(u.toString(16));if(!F)return[0,0,0];let[C]=F;if(C.length===3)C=[...C].map(($)=>$+$).join("");let B=Number.parseInt(C,16);return[B>>16&255,B>>8&255,B&255]},enumerable:!1},hexToAnsi256:{value:(u)=>p.rgbToAnsi256(...p.hexToRgb(u)),enumerable:!1},ansi256ToAnsi:{value(u){if(u<8)return 30+u;if(u<16)return 90+(u-8);let F,C,B;if(u>=232)F=((u-232)*10+8)/255,C=F,B=F;else{u-=16;let Q=u%36;F=Math.floor(u/36)/5,C=Math.floor(Q/6)/5,B=Q%6/5}let $=Math.max(F,C,B)*2;if($===0)return 30;let E=30+(Math.round(B)<<2|Math.round(C)<<1|Math.round(F));if($===2)E+=60;return E},enumerable:!1},rgbToAnsi:{value:(u,F,C)=>p.ansi256ToAnsi(p.rgbToAnsi256(u,F,C)),enumerable:!1},hexToAnsi:{value:(u)=>p.ansi256ToAnsi(p.hexToAnsi256(u)),enumerable:!1}}),p}var p9=l9(),t8=p9;var hu=new Set(["\x1B","\x9B"]),a9=39,V2="\x07",u6="[",n9="]",F6="m",yu=`${n9}8;;`,e8=(D)=>`${hu.values().next().value}${u6}${D}${F6}`,D6=(D)=>`${hu.values().next().value}${yu}${D}${V2}`,r9=(D)=>D.split(" ").map((u)=>zD(u)),q2=(D,u,F)=>{let C=[...u],B=!1,$=!1,E=zD(p0(D.at(-1)));for(let[Q,X]of C.entries()){let Z=zD(X);if(E+Z<=F)D[D.length-1]+=X;else D.push(X),E=0;if(hu.has(X))B=!0,$=C.slice(Q+1,Q+1+yu.length).join("")===yu;if(B){if($){if(X===V2)B=!1,$=!1}else if(X===F6)B=!1;continue}if(E+=Z,E===F&&Q0&&D.length>1)D[D.length-2]+=D.pop()},i9=(D)=>{let u=D.split(" "),F=u.length;while(F>0){if(zD(u[F-1])>0)break;F--}if(F===u.length)return D;return u.slice(0,F).join(" ")+u.slice(F).join("")},o9=(D,u,F={})=>{if(F.trim!==!1&&D.trim()==="")return"";let C="",B,$,E=r9(D),Q=[""];for(let[J,A]of D.split(" ").entries()){if(F.trim!==!1)Q[Q.length-1]=Q.at(-1).trimStart();let H=zD(Q.at(-1));if(J!==0){if(H>=u&&(F.wordWrap===!1||F.trim===!1))Q.push(""),H=0;if(H>0||F.trim===!1)Q[Q.length-1]+=" ",H++}if(F.hard&&E[J]>u){let G=u-H,z=1+Math.floor((E[J]-G-1)/u);if(Math.floor((E[J]-1)/u)u&&H>0&&E[J]>0){if(F.wordWrap===!1&&Hu&&F.wordWrap===!1){q2(Q,A,u);continue}Q[Q.length-1]+=A}if(F.trim!==!1)Q=Q.map((J)=>i9(J));let X=Q.join(` -`),Z=[...X],Y=0;for(let[J,A]of Z.entries()){if(C+=A,hu.has(A)){let{groups:G}=new RegExp(`(?:\\${u6}(?\\d+)m|\\${yu}(?.*)${V2})`).exec(X.slice(Y))||{groups:{}};if(G.code!==void 0){let z=Number.parseFloat(G.code);B=z===a9?void 0:z}else if(G.uri!==void 0)$=G.uri.length===0?void 0:G.uri}let H=t8.codes.get(Number(B));if(Z[J+1]===` -`){if($)C+=D6("");if(B&&H)C+=e8(H)}else if(A===` -`){if(B&&H)C+=e8(B);if($)C+=D6($)}Y+=A.length}return C};function gu(D,u,F){return String(D).normalize().replaceAll(`\r +`,B)}while(C!==-1);return $+=D.slice(B),$}var{stdout:A8,stderr:H8}=K8,iF=Symbol("GENERATOR"),I0=Symbol("STYLER"),d0=Symbol("IS_EMPTY"),G8=["ansi","ansi","ansi256","ansi16m"],N0=Object.create(null),E9=(D,u={})=>{if(u.level&&!(Number.isInteger(u.level)&&u.level>=0&&u.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");let F=A8?A8.level:0;D.level=u.level===void 0?F:u.level};var $9=(D)=>{let u=(...F)=>F.join(" ");return E9(u,D),Object.setPrototypeOf(u,c0.prototype),u};function c0(D){return $9(D)}Object.setPrototypeOf(c0.prototype,Function.prototype);for(let[D,u]of Object.entries(pD))N0[D]={get(){let F=bu(this,sF(u.open,u.close,this[I0]),this[d0]);return Object.defineProperty(this,D,{value:F}),F}};N0.visible={get(){let D=bu(this,this[I0],!0);return Object.defineProperty(this,"visible",{value:D}),D}};var oF=(D,u,F,...C)=>{if(D==="rgb"){if(u==="ansi16m")return pD[F].ansi16m(...C);if(u==="ansi256")return pD[F].ansi256(pD.rgbToAnsi256(...C));return pD[F].ansi(pD.rgbToAnsi(...C))}if(D==="hex")return oF("rgb",u,F,...pD.hexToRgb(...C));return pD[F][D](...C)},Q9=["rgb","hex","ansi256"];for(let D of Q9){N0[D]={get(){let{level:F}=this;return function(...C){let B=sF(oF(D,G8[F],"color",...C),pD.color.close,this[I0]);return bu(this,B,this[d0])}}};let u="bg"+D[0].toUpperCase()+D.slice(1);N0[u]={get(){let{level:F}=this;return function(...C){let B=sF(oF(D,G8[F],"bgColor",...C),pD.bgColor.close,this[I0]);return bu(this,B,this[d0])}}}}var X9=Object.defineProperties(()=>{},{...N0,level:{enumerable:!0,get(){return this[iF].level},set(D){this[iF].level=D}}}),sF=(D,u,F)=>{let C,B;if(F===void 0)C=D,B=u;else C=F.openAll+D,B=u+F.closeAll;return{open:D,close:u,openAll:C,closeAll:B,parent:F}},bu=(D,u,F)=>{let C=(...B)=>Z9(C,B.length===1?""+B[0]:B.join(" "));return Object.setPrototypeOf(C,X9),C[iF]=D,C[I0]=u,C[d0]=F,C},Z9=(D,u)=>{if(D.level<=0||!u)return D[d0]?"":u;let F=D[I0];if(F===void 0)return u;let{openAll:C,closeAll:B}=F;if(u.includes("\x1B"))while(F!==void 0)u=q8(u,F.close,F.open),F=F.parent;let $=u.indexOf(` +`);if($!==-1)u=V8(u,B,C,$);return C+u+B};Object.defineProperties(c0.prototype,N0);var Y9=c0(),z$=c0({level:H8?H8.level:0});var S=Y9;var C2=F0(I8(),1),KD=(...D)=>{let u,F;if(D.length===0)throw new Error("Missing gradient colors");if(!Array.isArray(D[0])){if(D.length===1)throw new Error(`Expected an array of colors, received ${JSON.stringify(D[0])}`);u=C2.default(...D)}else u=C2.default(D[0]),F=B2(D[1]);let C=(B,$)=>{return J9(B?B.toString():"",u,$??F)};return C.multiline=(B,$)=>K9(B?B.toString():"",u,$??F),C},N8=(D,u,F)=>{return u.interpolation?.toLowerCase()==="hsv"?D.hsv(F,u.hsvSpin?.toLowerCase()||!1):D.rgb(F)};function J9(D,u,F){let C=B2(F),B=Math.max(D.replace(/\s/g,"").length,u.stops.length),$=N8(u,C,B),E="";for(let Q of D)E+=Q.match(/\s/g)?Q:S.hex($.shift()?.toHex()||"#000")(Q);return E}function K9(D,u,F){let C=B2(F),B=D.split(` +`),$=Math.max(...B.map((X)=>X.length),u.stops.length),E=N8(u,C,$),Q=[];for(let X of B){let Z=E.slice(0),Y="";for(let J of X)Y+=S.hex(Z.shift()?.toHex()||"#000")(J);Q.push(Y)}return Q.join(` +`)}function B2(D){let u={interpolation:"rgb",hsvSpin:"short",...D};if(D!==void 0&&typeof D!=="object")throw new TypeError(`Expected \`options\` to be an \`object\`, got \`${typeof D}\``);if(typeof u.interpolation!=="string")throw new TypeError(`Expected \`options.interpolation\` to be \`rgb\` or \`hsv\`, got \`${typeof u.interpolation}\``);if(u.interpolation.toLowerCase()==="hsv"&&typeof u.hsvSpin!=="string")throw new TypeError(`Expected \`options.hsvSpin\` to be a \`short\` or \`long\`, got \`${typeof u.hsvSpin}\``);return u}var ID={atlas:{colors:["#feac5e","#c779d0","#4bc0c8"],options:{}},cristal:{colors:["#bdfff3","#4ac29a"],options:{}},teen:{colors:["#77a1d3","#79cbca","#e684ae"],options:{}},mind:{colors:["#473b7b","#3584a7","#30d2be"],options:{}},morning:{colors:["#ff5f6d","#ffc371"],options:{interpolation:"hsv"}},vice:{colors:["#5ee7df","#b490ca"],options:{interpolation:"hsv"}},passion:{colors:["#f43b47","#453a94"],options:{}},fruit:{colors:["#ff4e50","#f9d423"],options:{}},instagram:{colors:["#833ab4","#fd1d1d","#fcb045"],options:{}},retro:{colors:["#3f51b1","#5a55ae","#7b5fac","#8f6aae","#a86aa4","#cc6b8e","#f18271","#f3a469","#f7c978"],options:{}},summer:{colors:["#fdbb2d","#22c1c3"],options:{}},rainbow:{colors:["#ff0000","#ff0100"],options:{interpolation:"hsv",hsvSpin:"long"}},pastel:{colors:["#74ebd5","#74ecd5"],options:{interpolation:"hsv",hsvSpin:"long"}}};function ND(D){let u=(F)=>KD(...D.colors)(F,D.options);return u.multiline=(F="")=>KD(...D.colors).multiline(F,D.options),u}var E2=KD,q9=ND(ID.atlas),V9=ND(ID.cristal),A9=ND(ID.teen),H9=ND(ID.mind),G9=ND(ID.morning),z9=ND(ID.vice),_9=ND(ID.passion),U9=ND(ID.fruit),W9=ND(ID.instagram),L9=ND(ID.retro),R9=ND(ID.summer),M9=ND(ID.rainbow),I9=ND(ID.pastel);KD.atlas=q9;KD.cristal=V9;KD.teen=A9;KD.mind=H9;KD.morning=G9;KD.vice=z9;KD.passion=_9;KD.fruit=U9;KD.instagram=W9;KD.retro=L9;KD.summer=R9;KD.rainbow=M9;KD.pastel=I9;import mu from"process";function $2({onlyFirst:D=!1}={}){return new RegExp("(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]",D?void 0:"g")}var N9=$2();function p0(D){if(typeof D!=="string")throw new TypeError(`Expected a \`string\`, got \`${typeof D}\``);return D.replace(N9,"")}function O8(D){return D===161||D===164||D===167||D===168||D===170||D===173||D===174||D>=176&&D<=180||D>=182&&D<=186||D>=188&&D<=191||D===198||D===208||D===215||D===216||D>=222&&D<=225||D===230||D>=232&&D<=234||D===236||D===237||D===240||D===242||D===243||D>=247&&D<=250||D===252||D===254||D===257||D===273||D===275||D===283||D===294||D===295||D===299||D>=305&&D<=307||D===312||D>=319&&D<=322||D===324||D>=328&&D<=331||D===333||D===338||D===339||D===358||D===359||D===363||D===462||D===464||D===466||D===468||D===470||D===472||D===474||D===476||D===593||D===609||D===708||D===711||D>=713&&D<=715||D===717||D===720||D>=728&&D<=731||D===733||D===735||D>=768&&D<=879||D>=913&&D<=929||D>=931&&D<=937||D>=945&&D<=961||D>=963&&D<=969||D===1025||D>=1040&&D<=1103||D===1105||D===8208||D>=8211&&D<=8214||D===8216||D===8217||D===8220||D===8221||D>=8224&&D<=8226||D>=8228&&D<=8231||D===8240||D===8242||D===8243||D===8245||D===8251||D===8254||D===8308||D===8319||D>=8321&&D<=8324||D===8364||D===8451||D===8453||D===8457||D===8467||D===8470||D===8481||D===8482||D===8486||D===8491||D===8531||D===8532||D>=8539&&D<=8542||D>=8544&&D<=8555||D>=8560&&D<=8569||D===8585||D>=8592&&D<=8601||D===8632||D===8633||D===8658||D===8660||D===8679||D===8704||D===8706||D===8707||D===8711||D===8712||D===8715||D===8719||D===8721||D===8725||D===8730||D>=8733&&D<=8736||D===8739||D===8741||D>=8743&&D<=8748||D===8750||D>=8756&&D<=8759||D===8764||D===8765||D===8776||D===8780||D===8786||D===8800||D===8801||D>=8804&&D<=8807||D===8810||D===8811||D===8814||D===8815||D===8834||D===8835||D===8838||D===8839||D===8853||D===8857||D===8869||D===8895||D===8978||D>=9312&&D<=9449||D>=9451&&D<=9547||D>=9552&&D<=9587||D>=9600&&D<=9615||D>=9618&&D<=9621||D===9632||D===9633||D>=9635&&D<=9641||D===9650||D===9651||D===9654||D===9655||D===9660||D===9661||D===9664||D===9665||D>=9670&&D<=9672||D===9675||D>=9678&&D<=9681||D>=9698&&D<=9701||D===9711||D===9733||D===9734||D===9737||D===9742||D===9743||D===9756||D===9758||D===9792||D===9794||D===9824||D===9825||D>=9827&&D<=9829||D>=9831&&D<=9834||D===9836||D===9837||D===9839||D===9886||D===9887||D===9919||D>=9926&&D<=9933||D>=9935&&D<=9939||D>=9941&&D<=9953||D===9955||D===9960||D===9961||D>=9963&&D<=9969||D===9972||D>=9974&&D<=9977||D===9979||D===9980||D===9982||D===9983||D===10045||D>=10102&&D<=10111||D>=11094&&D<=11097||D>=12872&&D<=12879||D>=57344&&D<=63743||D>=65024&&D<=65039||D===65533||D>=127232&&D<=127242||D>=127248&&D<=127277||D>=127280&&D<=127337||D>=127344&&D<=127373||D===127375||D===127376||D>=127387&&D<=127404||D>=917760&&D<=917999||D>=983040&&D<=1048573||D>=1048576&&D<=1114109}function j8(D){return D===12288||D>=65281&&D<=65376||D>=65504&&D<=65510}function T8(D){return D>=4352&&D<=4447||D===8986||D===8987||D===9001||D===9002||D>=9193&&D<=9196||D===9200||D===9203||D===9725||D===9726||D===9748||D===9749||D>=9776&&D<=9783||D>=9800&&D<=9811||D===9855||D>=9866&&D<=9871||D===9875||D===9889||D===9898||D===9899||D===9917||D===9918||D===9924||D===9925||D===9934||D===9940||D===9962||D===9970||D===9971||D===9973||D===9978||D===9981||D===9989||D===9994||D===9995||D===10024||D===10060||D===10062||D>=10067&&D<=10069||D===10071||D>=10133&&D<=10135||D===10160||D===10175||D===11035||D===11036||D===11088||D===11093||D>=11904&&D<=11929||D>=11931&&D<=12019||D>=12032&&D<=12245||D>=12272&&D<=12287||D>=12289&&D<=12350||D>=12353&&D<=12438||D>=12441&&D<=12543||D>=12549&&D<=12591||D>=12593&&D<=12686||D>=12688&&D<=12773||D>=12783&&D<=12830||D>=12832&&D<=12871||D>=12880&&D<=42124||D>=42128&&D<=42182||D>=43360&&D<=43388||D>=44032&&D<=55203||D>=63744&&D<=64255||D>=65040&&D<=65049||D>=65072&&D<=65106||D>=65108&&D<=65126||D>=65128&&D<=65131||D>=94176&&D<=94180||D>=94192&&D<=94198||D>=94208&&D<=101589||D>=101631&&D<=101662||D>=101760&&D<=101874||D>=110576&&D<=110579||D>=110581&&D<=110587||D===110589||D===110590||D>=110592&&D<=110882||D===110898||D>=110928&&D<=110930||D===110933||D>=110948&&D<=110951||D>=110960&&D<=111355||D>=119552&&D<=119638||D>=119648&&D<=119670||D===126980||D===127183||D===127374||D>=127377&&D<=127386||D>=127488&&D<=127490||D>=127504&&D<=127547||D>=127552&&D<=127560||D===127568||D===127569||D>=127584&&D<=127589||D>=127744&&D<=127776||D>=127789&&D<=127797||D>=127799&&D<=127868||D>=127870&&D<=127891||D>=127904&&D<=127946||D>=127951&&D<=127955||D>=127968&&D<=127984||D===127988||D>=127992&&D<=128062||D===128064||D>=128066&&D<=128252||D>=128255&&D<=128317||D>=128331&&D<=128334||D>=128336&&D<=128359||D===128378||D===128405||D===128406||D===128420||D>=128507&&D<=128591||D>=128640&&D<=128709||D===128716||D>=128720&&D<=128722||D>=128725&&D<=128728||D>=128732&&D<=128735||D===128747||D===128748||D>=128756&&D<=128764||D>=128992&&D<=129003||D===129008||D>=129292&&D<=129338||D>=129340&&D<=129349||D>=129351&&D<=129535||D>=129648&&D<=129660||D>=129664&&D<=129674||D>=129678&&D<=129734||D===129736||D>=129741&&D<=129756||D>=129759&&D<=129770||D>=129775&&D<=129784||D>=131072&&D<=196605||D>=196608&&D<=262141}function O9(D){if(!Number.isSafeInteger(D))throw new TypeError(`Expected a code point, got \`${typeof D}\`.`)}function w8(D,{ambiguousAsWide:u=!1}={}){if(O9(D),j8(D)||T8(D)||u&&O8(D))return 2;return 1}var k8=()=>{return/[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E-\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED8\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])))?))?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3C-\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE8A\uDE8E-\uDEC2\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF]|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g};var j9=new Intl.Segmenter,T9=/^\p{Default_Ignorable_Code_Point}$/u;function zD(D,u={}){if(typeof D!=="string"||D.length===0)return 0;let{ambiguousIsNarrow:F=!0,countAnsiEscapeCodes:C=!1}=u;if(!C)D=p0(D);if(D.length===0)return 0;let B=0,$={ambiguousAsWide:!F};for(let{segment:E}of j9.segment(D)){let Q=E.codePointAt(0);if(Q<=31||Q>=127&&Q<=159)continue;if(Q>=8203&&Q<=8207||Q===65279)continue;if(Q>=768&&Q<=879||Q>=6832&&Q<=6911||Q>=7616&&Q<=7679||Q>=8400&&Q<=8447||Q>=65056&&Q<=65071)continue;if(Q>=55296&&Q<=57343)continue;if(Q>=65024&&Q<=65039)continue;if(T9.test(E))continue;if(k8().test(E)){B+=2;continue}B+=w8(Q,$)}return B}function fu(D){let u=0;for(let F of D.split(` +`))u=Math.max(u,zD(F));return u}var Q6=F0(X2(),1);var k9=/[\p{Lu}]/u,P9=/[\p{Ll}]/u,x8=/^[\p{Lu}](?![\p{Lu}])/gu,f8=/([\p{Alpha}\p{N}_]|$)/u,Z2=/[_.\- ]+/,S9=new RegExp("^"+Z2.source),b8=new RegExp(Z2.source+f8.source,"gu"),v8=new RegExp("\\d+"+f8.source,"gu"),x9=(D,u,F,C)=>{let B=!1,$=!1,E=!1,Q=!1;for(let X=0;X2?D[X-3]==="-":!0,B&&k9.test(Z))D=D.slice(0,X)+"-"+D.slice(X),B=!1,E=$,$=!0,X++;else if($&&E&&P9.test(Z)&&(!Q||C))D=D.slice(0,X-1)+"-"+D.slice(X-1),E=$,$=!1,B=!0;else B=u(Z)===Z&&F(Z)!==Z,E=$,$=F(Z)===Z&&u(Z)!==Z}return D},b9=(D,u)=>{return x8.lastIndex=0,D.replaceAll(x8,(F)=>u(F))},v9=(D,u)=>{return b8.lastIndex=0,v8.lastIndex=0,D.replaceAll(v8,(F,C,B)=>["_","-"].includes(D.charAt(B+F.length))?F:u(F)).replaceAll(b8,(F,C)=>u(C))};function Y2(D,u){if(!(typeof D==="string"||Array.isArray(D)))throw new TypeError("Expected the input to be `string | string[]`");if(u={pascalCase:!1,preserveConsecutiveUppercase:!1,...u},Array.isArray(D))D=D.map(($)=>$.trim()).filter(($)=>$.length).join("-");else D=D.trim();if(D.length===0)return"";let F=u.locale===!1?($)=>$.toLowerCase():($)=>$.toLocaleLowerCase(u.locale),C=u.locale===!1?($)=>$.toUpperCase():($)=>$.toLocaleUpperCase(u.locale);if(D.length===1){if(Z2.test(D))return"";return u.pascalCase?C(D):F(D)}if(D!==F(D))D=x9(D,F,C,u.preserveConsecutiveUppercase);if(D=D.replace(S9,""),D=u.preserveConsecutiveUppercase?b9(D,F):F(D),u.pascalCase)D=C(D.charAt(0))+D.slice(1);return v9(D,C)}var A2=F0(i8(),1);var o8=(D=0)=>(u)=>`\x1B[${u+D}m`,s8=(D=0)=>(u)=>`\x1B[${38+D};5;${u}m`,t8=(D=0)=>(u,F,C)=>`\x1B[${38+D};2;${u};${F};${C}m`,p={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]}},a$=Object.keys(p.modifier),l9=Object.keys(p.color),p9=Object.keys(p.bgColor),n$=[...l9,...p9];function a9(){let D=new Map;for(let[u,F]of Object.entries(p)){for(let[C,B]of Object.entries(F))p[C]={open:`\x1B[${B[0]}m`,close:`\x1B[${B[1]}m`},F[C]=p[C],D.set(B[0],B[1]);Object.defineProperty(p,u,{value:F,enumerable:!1})}return Object.defineProperty(p,"codes",{value:D,enumerable:!1}),p.color.close="\x1B[39m",p.bgColor.close="\x1B[49m",p.color.ansi=o8(),p.color.ansi256=s8(),p.color.ansi16m=t8(),p.bgColor.ansi=o8(10),p.bgColor.ansi256=s8(10),p.bgColor.ansi16m=t8(10),Object.defineProperties(p,{rgbToAnsi256:{value(u,F,C){if(u===F&&F===C){if(u<8)return 16;if(u>248)return 231;return Math.round((u-8)/247*24)+232}return 16+36*Math.round(u/255*5)+6*Math.round(F/255*5)+Math.round(C/255*5)},enumerable:!1},hexToRgb:{value(u){let F=/[a-f\d]{6}|[a-f\d]{3}/i.exec(u.toString(16));if(!F)return[0,0,0];let[C]=F;if(C.length===3)C=[...C].map(($)=>$+$).join("");let B=Number.parseInt(C,16);return[B>>16&255,B>>8&255,B&255]},enumerable:!1},hexToAnsi256:{value:(u)=>p.rgbToAnsi256(...p.hexToRgb(u)),enumerable:!1},ansi256ToAnsi:{value(u){if(u<8)return 30+u;if(u<16)return 90+(u-8);let F,C,B;if(u>=232)F=((u-232)*10+8)/255,C=F,B=F;else{u-=16;let Q=u%36;F=Math.floor(u/36)/5,C=Math.floor(Q/6)/5,B=Q%6/5}let $=Math.max(F,C,B)*2;if($===0)return 30;let E=30+(Math.round(B)<<2|Math.round(C)<<1|Math.round(F));if($===2)E+=60;return E},enumerable:!1},rgbToAnsi:{value:(u,F,C)=>p.ansi256ToAnsi(p.rgbToAnsi256(u,F,C)),enumerable:!1},hexToAnsi:{value:(u)=>p.ansi256ToAnsi(p.hexToAnsi256(u)),enumerable:!1}}),p}var n9=a9(),e8=n9;var hu=new Set(["\x1B","\x9B"]),r9=39,V2="\x07",F6="[",i9="]",C6="m",yu=`${i9}8;;`,D6=(D)=>`${hu.values().next().value}${F6}${D}${C6}`,u6=(D)=>`${hu.values().next().value}${yu}${D}${V2}`,o9=(D)=>D.split(" ").map((u)=>zD(u)),q2=(D,u,F)=>{let C=[...u],B=!1,$=!1,E=zD(p0(D.at(-1)));for(let[Q,X]of C.entries()){let Z=zD(X);if(E+Z<=F)D[D.length-1]+=X;else D.push(X),E=0;if(hu.has(X))B=!0,$=C.slice(Q+1,Q+1+yu.length).join("")===yu;if(B){if($){if(X===V2)B=!1,$=!1}else if(X===C6)B=!1;continue}if(E+=Z,E===F&&Q0&&D.length>1)D[D.length-2]+=D.pop()},s9=(D)=>{let u=D.split(" "),F=u.length;while(F>0){if(zD(u[F-1])>0)break;F--}if(F===u.length)return D;return u.slice(0,F).join(" ")+u.slice(F).join("")},t9=(D,u,F={})=>{if(F.trim!==!1&&D.trim()==="")return"";let C="",B,$,E=o9(D),Q=[""];for(let[J,A]of D.split(" ").entries()){if(F.trim!==!1)Q[Q.length-1]=Q.at(-1).trimStart();let H=zD(Q.at(-1));if(J!==0){if(H>=u&&(F.wordWrap===!1||F.trim===!1))Q.push(""),H=0;if(H>0||F.trim===!1)Q[Q.length-1]+=" ",H++}if(F.hard&&E[J]>u){let G=u-H,z=1+Math.floor((E[J]-G-1)/u);if(Math.floor((E[J]-1)/u)u&&H>0&&E[J]>0){if(F.wordWrap===!1&&Hu&&F.wordWrap===!1){q2(Q,A,u);continue}Q[Q.length-1]+=A}if(F.trim!==!1)Q=Q.map((J)=>s9(J));let X=Q.join(` +`),Z=[...X],Y=0;for(let[J,A]of Z.entries()){if(C+=A,hu.has(A)){let{groups:G}=new RegExp(`(?:\\${F6}(?\\d+)m|\\${yu}(?.*)${V2})`).exec(X.slice(Y))||{groups:{}};if(G.code!==void 0){let z=Number.parseFloat(G.code);B=z===r9?void 0:z}else if(G.uri!==void 0)$=G.uri.length===0?void 0:G.uri}let H=e8.codes.get(Number(B));if(Z[J+1]===` +`){if($)C+=u6("");if(B&&H)C+=D6(H)}else if(A===` +`){if(B&&H)C+=D6(B);if($)C+=u6($)}Y+=A.length}return C};function gu(D,u,F){return String(D).normalize().replaceAll(`\r `,` `).split(` -`).map((C)=>o9(C,u,F)).join(` -`)}var EB=F0(X2(),1),Z0=` -`,OD=" ",a0="none",Q6=()=>{let{env:D,stdout:u,stderr:F}=mu;if(u?.columns)return u.columns;if(F?.columns)return F.columns;if(D.COLUMNS)return Number.parseInt(D.COLUMNS,10);return 80},C6=(D)=>typeof D==="number"?{top:D,right:D*3,bottom:D,left:D*3}:{top:0,right:0,bottom:0,left:0,...D},n0=(D)=>D===a0?0:2,s9=(D)=>{let u=["topLeft","topRight","bottomRight","bottomLeft","left","right","top","bottom"],F;if(D===a0){D={};for(let C of u)D[C]=""}if(typeof D==="string"){if(F=$6.default[D],!F)throw new TypeError(`Invalid border style: ${D}`)}else{if(typeof D?.vertical==="string")D.left=D.vertical,D.right=D.vertical;if(typeof D?.horizontal==="string")D.top=D.horizontal,D.bottom=D.horizontal;for(let C of u)if(D[C]===null||typeof D[C]!=="string")throw new TypeError(`Invalid border style: ${C}`);F=D}return F},t9=(D,u,F)=>{let C="",B=zD(D);switch(F){case"left":{C=D+u.slice(B);break}case"right":{C=u.slice(B)+D;break}default:{if(u=u.slice(B),u.length%2===1)u=u.slice(Math.floor(u.length/2)),C=u.slice(1)+D+u;else u=u.slice(u.length/2),C=u+D+u;break}}return C},e9=(D,{padding:u,width:F,textAlignment:C,height:B})=>{D=A2.default(D,{align:C});let $=D.split(Z0),E=fu(D),Q=F-u.left-u.right;if(E>Q){let Y=[];for(let J of $){let A=gu(J,Q,{hard:!0}),G=A2.default(A,{align:C}).split(` -`),z=Math.max(...G.map((U)=>zD(U)));for(let U of G){let I;switch(C){case"center":{I=OD.repeat((Q-z)/2)+U;break}case"right":{I=OD.repeat(Q-z)+U;break}default:{I=U;break}}Y.push(I)}}$=Y}if(C==="center"&&EOD.repeat((Q-E)/2)+Y);else if(C==="right"&&EOD.repeat(Q-E)+Y);let X=OD.repeat(u.left),Z=OD.repeat(u.right);if($=$.map((Y)=>{let J=X+Y+Z;return J+OD.repeat(F-zD(J))}),u.top>0)$=[...Array.from({length:u.top}).fill(OD.repeat(F)),...$];if(u.bottom>0)$=[...$,...Array.from({length:u.bottom}).fill(OD.repeat(F))];if(B&&$.length>B)$=$.slice(0,B);else if(B&&$.length{let C=(Y)=>{let J=F.borderColor?CB(F.borderColor)(Y):Y;return F.dimBorder?S.dim(J):J},B=(Y)=>F.backgroundColor?BB(F.backgroundColor)(Y):Y,$=s9(F.borderStyle),E=Q6(),Q=OD.repeat(F.margin.left);if(F.float==="center"){let Y=Math.max((E-u-n0(F.borderStyle))/2,0);Q=OD.repeat(Y)}else if(F.float==="right"){let Y=Math.max(E-u-F.margin.right-n0(F.borderStyle),0);Q=OD.repeat(Y)}let X="";if(F.margin.top)X+=Z0.repeat(F.margin.top);if(F.borderStyle!==a0||F.title)X+=C(Q+$.topLeft+(F.title?t9(F.title,$.top.repeat(u),F.titleAlignment):$.top.repeat(u))+$.topRight)+Z0;let Z=D.split(Z0);if(X+=Z.map((Y)=>Q+C($.left)+B(Y)+C($.right)).join(Z0),F.borderStyle!==a0)X+=Z0+C(Q+$.bottomLeft+$.bottom.repeat(u)+$.bottomRight);if(F.margin.bottom)X+=Z0.repeat(F.margin.bottom);return X},uB=(D)=>{if(D.fullscreen&&mu?.stdout){let u=[mu.stdout.columns,mu.stdout.rows];if(typeof D.fullscreen==="function")u=D.fullscreen(...u);D.width||=u[0],D.height||=u[1]}return D.width&&=Math.max(1,D.width-n0(D.borderStyle)),D.height&&=Math.max(1,D.height-n0(D.borderStyle)),D},B6=(D,u)=>u===a0?D:` ${D} `,FB=(D,u)=>{u=uB(u);let F=u.width!==void 0,C=Q6(),B=n0(u.borderStyle),$=C-u.margin.left-u.margin.right-B,E=fu(gu(D,C-B,{hard:!0,trim:!1}))+u.padding.left+u.padding.right;if(u.title&&F)u.title=u.title.slice(0,Math.max(0,u.width-2)),u.title&&=B6(u.title,u.borderStyle);else if(u.title){if(u.title=u.title.slice(0,Math.max(0,$-2)),u.title){if(u.title=B6(u.title,u.borderStyle),zD(u.title)>E)u.width=zD(u.title)}}if(u.width||=E,!F){if(u.margin.left&&u.margin.right&&u.width>$){let X=(C-u.width-B)/(u.margin.left+u.margin.right);u.margin.left=Math.max(0,Math.floor(u.margin.left*X)),u.margin.right=Math.max(0,Math.floor(u.margin.right*X))}u.width=Math.min(u.width,C-B-u.margin.left-u.margin.right)}if(u.width-(u.padding.left+u.padding.right)<=0)u.padding.left=0,u.padding.right=0;if(u.height&&u.height-(u.padding.top+u.padding.bottom)<=0)u.padding.top=0,u.padding.bottom=0;return u},H2=(D)=>D.match(/^#(?:[0-f]{3}){1,2}$/i),E6=(D)=>typeof D==="string"&&(S[D]??H2(D)),CB=(D)=>H2(D)?S.hex(D):S[D],BB=(D)=>H2(D)?S.bgHex(D):S[Y2(["bg",D])];function du(D,u){if(u={padding:0,borderStyle:"single",dimBorder:!1,textAlignment:"left",float:"left",titleAlignment:"left",...u},u.align)u.textAlignment=u.align;if(u.borderColor&&!E6(u.borderColor))throw new Error(`${u.borderColor} is not a valid borderColor`);if(u.backgroundColor&&!E6(u.backgroundColor))throw new Error(`${u.backgroundColor} is not a valid backgroundColor`);return u.padding=C6(u.padding),u.margin=C6(u.margin),u=FB(D,u),D=e9(D,u),DB(D,u.width,u)}qD();import{platform as ZB,homedir as YB}from"os";import{execSync as z2}from"child_process";import{chmodSync as JB}from"fs";import{join as i0}from"path";var Y0=ZB()==="win32",G0={getShell:()=>{return Y0?"powershell":"/bin/sh"},getHookExtension:()=>{return".js"},findExecutable:(D)=>{let u=Y0?`where ${D}`:`which ${D}`;return z2(u,{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim()},makeExecutable:(D)=>{if(!Y0)JB(D,493)},installUv:()=>{if(Y0)z2('powershell -Command "irm https://astral.sh/uv/install.ps1 | iex"',{stdio:"pipe"});else z2("curl -LsSf https://astral.sh/uv/install.sh | sh",{stdio:"pipe",shell:"/bin/sh"})},getShellConfigPaths:()=>{let D=YB();if(Y0)return[i0(D,"Documents","PowerShell","Microsoft.PowerShell_profile.ps1"),i0(D,"Documents","WindowsPowerShell","Microsoft.PowerShell_profile.ps1")];return[i0(D,".bashrc"),i0(D,".zshrc"),i0(D,".bash_profile")]},getAliasDefinition:(D,u)=>{if(Y0)return`function ${D} { ${u} $args }`;return`alias ${D}='${u}'`},isWindows:()=>Y0,isUnix:()=>!Y0};function VB(D){let u,F=0,C=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];return{start(){u=setInterval(()=>{process.stdout.write(`\r${S.cyan(C[F%C.length])} ${D}`),F++},50)},stop(B,$=!0){clearInterval(u);let E=$?S.green("\u2713"):S.red("\u2717");process.stdout.write(`\r${E} ${B} -`)}}}var o0=E2(["#ff0000","#ff4500","#ffa500","#ffff00","#00ff00","#00ffff","#0000ff","#8b00ff"]),_2=E2(["#ff006e","#fb5607","#ffbe0b","#8338ec","#3a86ff"]);function AB(){G0.installUv(),process.env.PATH=`${Y6()}/.cargo/bin:${process.env.PATH}`}function HB(){return G0.findExecutable("claude")}function GB(){let D=k.getInstance();return xD(D.getHooksDirectory())}async function zB(D){let u={};if(D){let $=await R0({message:`\uD83E\uDDE0 Existing claude-mem installation detected. Your memories and data are safe! +`).map((C)=>t9(C,u,F)).join(` +`)}var QB=F0(X2(),1),Z0=` +`,OD=" ",a0="none",X6=()=>{let{env:D,stdout:u,stderr:F}=mu;if(u?.columns)return u.columns;if(F?.columns)return F.columns;if(D.COLUMNS)return Number.parseInt(D.COLUMNS,10);return 80},B6=(D)=>typeof D==="number"?{top:D,right:D*3,bottom:D,left:D*3}:{top:0,right:0,bottom:0,left:0,...D},n0=(D)=>D===a0?0:2,e9=(D)=>{let u=["topLeft","topRight","bottomRight","bottomLeft","left","right","top","bottom"],F;if(D===a0){D={};for(let C of u)D[C]=""}if(typeof D==="string"){if(F=Q6.default[D],!F)throw new TypeError(`Invalid border style: ${D}`)}else{if(typeof D?.vertical==="string")D.left=D.vertical,D.right=D.vertical;if(typeof D?.horizontal==="string")D.top=D.horizontal,D.bottom=D.horizontal;for(let C of u)if(D[C]===null||typeof D[C]!=="string")throw new TypeError(`Invalid border style: ${C}`);F=D}return F},DB=(D,u,F)=>{let C="",B=zD(D);switch(F){case"left":{C=D+u.slice(B);break}case"right":{C=u.slice(B)+D;break}default:{if(u=u.slice(B),u.length%2===1)u=u.slice(Math.floor(u.length/2)),C=u.slice(1)+D+u;else u=u.slice(u.length/2),C=u+D+u;break}}return C},uB=(D,{padding:u,width:F,textAlignment:C,height:B})=>{D=A2.default(D,{align:C});let $=D.split(Z0),E=fu(D),Q=F-u.left-u.right;if(E>Q){let Y=[];for(let J of $){let A=gu(J,Q,{hard:!0}),G=A2.default(A,{align:C}).split(` +`),z=Math.max(...G.map((U)=>zD(U)));for(let U of G){let I;switch(C){case"center":{I=OD.repeat((Q-z)/2)+U;break}case"right":{I=OD.repeat(Q-z)+U;break}default:{I=U;break}}Y.push(I)}}$=Y}if(C==="center"&&EOD.repeat((Q-E)/2)+Y);else if(C==="right"&&EOD.repeat(Q-E)+Y);let X=OD.repeat(u.left),Z=OD.repeat(u.right);if($=$.map((Y)=>{let J=X+Y+Z;return J+OD.repeat(F-zD(J))}),u.top>0)$=[...Array.from({length:u.top}).fill(OD.repeat(F)),...$];if(u.bottom>0)$=[...$,...Array.from({length:u.bottom}).fill(OD.repeat(F))];if(B&&$.length>B)$=$.slice(0,B);else if(B&&$.length{let C=(Y)=>{let J=F.borderColor?EB(F.borderColor)(Y):Y;return F.dimBorder?S.dim(J):J},B=(Y)=>F.backgroundColor?$B(F.backgroundColor)(Y):Y,$=e9(F.borderStyle),E=X6(),Q=OD.repeat(F.margin.left);if(F.float==="center"){let Y=Math.max((E-u-n0(F.borderStyle))/2,0);Q=OD.repeat(Y)}else if(F.float==="right"){let Y=Math.max(E-u-F.margin.right-n0(F.borderStyle),0);Q=OD.repeat(Y)}let X="";if(F.margin.top)X+=Z0.repeat(F.margin.top);if(F.borderStyle!==a0||F.title)X+=C(Q+$.topLeft+(F.title?DB(F.title,$.top.repeat(u),F.titleAlignment):$.top.repeat(u))+$.topRight)+Z0;let Z=D.split(Z0);if(X+=Z.map((Y)=>Q+C($.left)+B(Y)+C($.right)).join(Z0),F.borderStyle!==a0)X+=Z0+C(Q+$.bottomLeft+$.bottom.repeat(u)+$.bottomRight);if(F.margin.bottom)X+=Z0.repeat(F.margin.bottom);return X},CB=(D)=>{if(D.fullscreen&&mu?.stdout){let u=[mu.stdout.columns,mu.stdout.rows];if(typeof D.fullscreen==="function")u=D.fullscreen(...u);D.width||=u[0],D.height||=u[1]}return D.width&&=Math.max(1,D.width-n0(D.borderStyle)),D.height&&=Math.max(1,D.height-n0(D.borderStyle)),D},E6=(D,u)=>u===a0?D:` ${D} `,BB=(D,u)=>{u=CB(u);let F=u.width!==void 0,C=X6(),B=n0(u.borderStyle),$=C-u.margin.left-u.margin.right-B,E=fu(gu(D,C-B,{hard:!0,trim:!1}))+u.padding.left+u.padding.right;if(u.title&&F)u.title=u.title.slice(0,Math.max(0,u.width-2)),u.title&&=E6(u.title,u.borderStyle);else if(u.title){if(u.title=u.title.slice(0,Math.max(0,$-2)),u.title){if(u.title=E6(u.title,u.borderStyle),zD(u.title)>E)u.width=zD(u.title)}}if(u.width||=E,!F){if(u.margin.left&&u.margin.right&&u.width>$){let X=(C-u.width-B)/(u.margin.left+u.margin.right);u.margin.left=Math.max(0,Math.floor(u.margin.left*X)),u.margin.right=Math.max(0,Math.floor(u.margin.right*X))}u.width=Math.min(u.width,C-B-u.margin.left-u.margin.right)}if(u.width-(u.padding.left+u.padding.right)<=0)u.padding.left=0,u.padding.right=0;if(u.height&&u.height-(u.padding.top+u.padding.bottom)<=0)u.padding.top=0,u.padding.bottom=0;return u},H2=(D)=>D.match(/^#(?:[0-f]{3}){1,2}$/i),$6=(D)=>typeof D==="string"&&(S[D]??H2(D)),EB=(D)=>H2(D)?S.hex(D):S[D],$B=(D)=>H2(D)?S.bgHex(D):S[Y2(["bg",D])];function du(D,u){if(u={padding:0,borderStyle:"single",dimBorder:!1,textAlignment:"left",float:"left",titleAlignment:"left",...u},u.align)u.textAlignment=u.align;if(u.borderColor&&!$6(u.borderColor))throw new Error(`${u.borderColor} is not a valid borderColor`);if(u.backgroundColor&&!$6(u.backgroundColor))throw new Error(`${u.backgroundColor} is not a valid backgroundColor`);return u.padding=B6(u.padding),u.margin=B6(u.margin),u=BB(D,u),D=uB(D,u),FB(D,u.width,u)}qD();import{platform as JB,homedir as KB}from"os";import{execSync as z2}from"child_process";import{chmodSync as qB}from"fs";import{join as i0}from"path";var Y0=JB()==="win32",G0={getShell:()=>{return Y0?"powershell":"/bin/sh"},getHookExtension:()=>{return".js"},findExecutable:(D)=>{let u=Y0?`where ${D}`:`which ${D}`;return z2(u,{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim()},makeExecutable:(D)=>{if(!Y0)qB(D,493)},installUv:()=>{if(Y0)z2('powershell -Command "irm https://astral.sh/uv/install.ps1 | iex"',{stdio:"pipe"});else z2("curl -LsSf https://astral.sh/uv/install.sh | sh",{stdio:"pipe",shell:"/bin/sh"})},getShellConfigPaths:()=>{let D=KB();if(Y0)return[i0(D,"Documents","PowerShell","Microsoft.PowerShell_profile.ps1"),i0(D,"Documents","WindowsPowerShell","Microsoft.PowerShell_profile.ps1")];return[i0(D,".bashrc"),i0(D,".zshrc"),i0(D,".bash_profile")]},getAliasDefinition:(D,u)=>{if(Y0)return`function ${D} { ${u} $args }`;return`alias ${D}='${u}'`},isWindows:()=>Y0,isUnix:()=>!Y0};function HB(D){let u,F=0,C=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];return{start(){u=setInterval(()=>{process.stdout.write(`\r${S.cyan(C[F%C.length])} ${D}`),F++},50)},stop(B,$=!0){clearInterval(u);let E=$?S.green("\u2713"):S.red("\u2717");process.stdout.write(`\r${E} ${B} +`)}}}var o0=E2(["#ff0000","#ff4500","#ffa500","#ffff00","#00ff00","#00ffff","#0000ff","#8b00ff"]),_2=E2(["#ff006e","#fb5607","#ffbe0b","#8338ec","#3a86ff"]);function GB(){G0.installUv(),process.env.PATH=`${J6()}/.cargo/bin:${process.env.PATH}`}function zB(){return G0.findExecutable("claude")}function _B(){let D=k.getInstance();return xD(D.getHooksDirectory())}async function UB(D){let u={};if(D){let $=await R0({message:`\uD83E\uDDE0 Existing claude-mem installation detected. Your memories and data are safe! -Reinstall to update hooks and configuration?`,initialValue:!0});if(PD($)||!$)return M0("Installation cancelled"),null;u.forceReinstall=!0}else u.forceReinstall=!1;let F=await Pu({message:"Select installation scope",options:[{value:"user",label:"User (Recommended)",hint:"Install for current user (~/.claude)"},{value:"project",label:"Project",hint:"Install for current project only (./.mcp.json)"},{value:"local",label:"Local",hint:"Custom local installation"}],initialValue:"user"});if(PD(F))return M0("Installation cancelled"),null;if(u.scope=F,F==="local"){let $=await B8({message:"Enter custom installation directory",placeholder:uD(process.cwd(),".claude-mem"),validate:(E)=>{if(!E)return"Path is required";if(!E.startsWith("/")&&!E.startsWith("~"))return"Please provide an absolute path"}});if(PD($))return M0("Installation cancelled"),null;u.customPath=$}u.hookTimeout=180000;let C=await R0({message:'Enable Smart Trash? This creates an alias for "rm" that moves files to ~/.claude-mem/trash instead of permanently deleting them. You can restore files anytime by typing "claude-mem restore".',initialValue:!0});if(PD(C))return M0("Installation cancelled"),null;u.enableSmartTrash=C;let B=await R0({message:'Would you like to save memories when you type "/clear" in Claude Code? When running /clear with this on, it takes about a minute to save memories before your new session starts.',initialValue:!1});if(PD(B))return M0("Installation cancelled"),null;return u.saveMemoriesOnClear=B,u}function _B(){let D=k.getInstance();D.ensureAllDataDirectories(),D.ensureAllClaudeDirectories();let u=uD(D.getDataDirectory(),"package.json");if(!xD(u))J0(u,JSON.stringify({name:"claude-mem-data",type:"module"},null,2))}function J6(D,u){if(KB(D).isDirectory()){if(!xD(u))s0(u,{recursive:!0});qB(D).forEach((B)=>{J6(uD(D,B),uD(u,B))})}else U2(D,u)}function UB(D=180000){let u=k.getInstance(),F=u.getHooksDirectory(),C=u.findPackageHookTemplatesDirectory(),B=["session-start.js","stop.js","user-prompt-submit.js","post-tool-use.js"];for(let Z of B){let Y=uD(C,Z),J=uD(F,Z);U2(Y,J),G0.makeExecutable(J)}let $=uD(C,"shared"),E=uD(F,"shared");if(xD($))J6($,E);let Q={packageName:L0,cliCommand:L0,backend:"chroma",timeout:D};J0(uD(F,"config.json"),JSON.stringify(Q,null,2));let X={name:"claude-mem-hooks",type:"module"};J0(uD(F,"package.json"),JSON.stringify(X,null,2))}function WB(){let u=k.getInstance().getClaudeMdPath(),F=W2(u);if(!xD(F))s0(F,{recursive:!0});let C=` +Reinstall to update hooks and configuration?`,initialValue:!0});if(PD($)||!$)return M0("Installation cancelled"),null;u.forceReinstall=!0}else u.forceReinstall=!1;let F=await Pu({message:"Select installation scope",options:[{value:"user",label:"User (Recommended)",hint:"Install for current user (~/.claude)"},{value:"project",label:"Project",hint:"Install for current project only (./.mcp.json)"},{value:"local",label:"Local",hint:"Custom local installation"}],initialValue:"user"});if(PD(F))return M0("Installation cancelled"),null;if(u.scope=F,F==="local"){let $=await E8({message:"Enter custom installation directory",placeholder:uD(process.cwd(),".claude-mem"),validate:(E)=>{if(!E)return"Path is required";if(!E.startsWith("/")&&!E.startsWith("~"))return"Please provide an absolute path"}});if(PD($))return M0("Installation cancelled"),null;u.customPath=$}u.hookTimeout=180000;let C=await R0({message:'Enable Smart Trash? This creates an alias for "rm" that moves files to ~/.claude-mem/trash instead of permanently deleting them. You can restore files anytime by typing "claude-mem restore".',initialValue:!0});if(PD(C))return M0("Installation cancelled"),null;u.enableSmartTrash=C;let B=await R0({message:'Would you like to save memories when you type "/clear" in Claude Code? When running /clear with this on, it takes about a minute to save memories before your new session starts.',initialValue:!1});if(PD(B))return M0("Installation cancelled"),null;return u.saveMemoriesOnClear=B,u}function WB(){let D=k.getInstance();D.ensureAllDataDirectories(),D.ensureAllClaudeDirectories();let u=uD(D.getDataDirectory(),"package.json");if(!xD(u))J0(u,JSON.stringify({name:"claude-mem-data",type:"module"},null,2))}function K6(D,u){if(VB(D).isDirectory()){if(!xD(u))s0(u,{recursive:!0});AB(D).forEach((B)=>{K6(uD(D,B),uD(u,B))})}else U2(D,u)}function LB(D=180000){let u=k.getInstance(),F=u.getHooksDirectory(),C=u.findPackageHookTemplatesDirectory(),B=["session-start.js","stop.js","user-prompt-submit.js","post-tool-use.js"];for(let Z of B){let Y=uD(C,Z),J=uD(F,Z);U2(Y,J),G0.makeExecutable(J)}let $=uD(C,"shared"),E=uD(F,"shared");if(xD($))K6($,E);let Q={packageName:L0,cliCommand:L0,backend:"chroma",timeout:D};J0(uD(F,"config.json"),JSON.stringify(Q,null,2));let X={name:"claude-mem-hooks",type:"module"};J0(uD(F,"package.json"),JSON.stringify(X,null,2))}function RB(){let u=k.getInstance().getClaudeMdPath(),F=W2(u);if(!xD(F))s0(F,{recursive:!0});let C=` ## \uD83E\uDDE0 Memory System Quick Reference @@ -541,16 +541,16 @@ Reinstall to update hooks and configuration?`,initialValue:!0});if(PD($)||!$)ret - Collection: "claude_memories" - Archives: ~/.claude-mem/archives/ `,B="";if(xD(u)){B=pu(u,"utf8");let $=B.includes(""),E=B.includes("");if($||E){let Q,X;if($)Q="",X="";else Q="",X="";let Z=B.indexOf(Q),Y=B.indexOf(X)+X.length;if(Z!==-1&&Y!==-1)B=B.substring(0,Z)+C.trim()+B.substring(Y)}else B=B.trim()+` -`+C}else B=C.trim();J0(u,B)}function LB(D=!1){let u=`${Y6()}/.cargo/bin`;if(xD(u)&&!process.env.PATH?.includes(u))process.env.PATH=`${u}:${process.env.PATH}`;if(D)try{Z6("claude mcp remove claude-mem",{stdio:"pipe"})}catch(C){}let F=`claude mcp add claude-mem -- uvx chroma-mcp --client-type persistent --data-dir ${k.getInstance().getChromaDirectory()}`;Z6(F,{stdio:"inherit"})}function lu(D,u,F){let C={hooks:[{type:"command",command:D,timeout:u}]};if(F)C.matcher=F;return C}function RB(D){let F=k.getInstance().getHooksDirectory(),C=xD(D)?JSON.parse(pu(D,"utf8")):{hooks:{}};if(s0(W2(D),{recursive:!0}),!C.hooks)C.hooks={};["SessionStart","Stop","UserPromptSubmit","PostToolUse"].forEach(($)=>{if(C.hooks[$])C.hooks[$]=C.hooks[$].filter((E)=>!E.hooks?.some((Q)=>Q.command?.includes(L0)))}),C.hooks.SessionStart=[lu(uD(F,"session-start.js"),180)],C.hooks.Stop=[lu(uD(F,"stop.js"),60)],C.hooks.UserPromptSubmit=[lu(uD(F,"user-prompt-submit.js"),60)],C.hooks.PostToolUse=[lu(uD(F,"post-tool-use.js"),180,"*")],J0(D,JSON.stringify(C,null,2))}function MB(D){if(D.scope==="local"&&D.customPath)return uD(D.customPath,"settings.local.json");else if(D.scope==="project")return uD(process.cwd(),".claude","settings.json");else return k.getInstance().getClaudeSettingsPath()}function IB(D){let F=k.getInstance().getUserSettingsPath(),C=xD(F)?JSON.parse(pu(F,"utf8")):{};C.backend="chroma",C.installed=!0,C.embedded=!0,C.saveMemoriesOnClear=D.saveMemoriesOnClear||!1,C.claudePath=HB(),J0(F,JSON.stringify(C,null,2))}function NB(){let D=G0.getShellConfigPaths(),u=G0.getAliasDefinition("rm","claude-mem trash"),F=G0.isWindows()?"# claude-mem smart trash alias":"# claude-mem smart trash alias";for(let C of D){if(!xD(C)){let E=W2(C);if(!xD(E))s0(E,{recursive:!0});J0(C,"")}let B=pu(C,"utf8");if(B.includes(u))continue;let $=` +`+C}else B=C.trim();J0(u,B)}function MB(D=!1){let u=`${J6()}/.cargo/bin`;if(xD(u)&&!process.env.PATH?.includes(u))process.env.PATH=`${u}:${process.env.PATH}`;if(D)try{Y6("claude mcp remove claude-mem",{stdio:"pipe"})}catch(C){}let F=`claude mcp add claude-mem -- uvx chroma-mcp --client-type persistent --data-dir ${k.getInstance().getChromaDirectory()}`;Y6(F,{stdio:"inherit"})}function lu(D,u,F){let C={hooks:[{type:"command",command:D,timeout:u}]};if(F)C.matcher=F;return C}function IB(D){let F=k.getInstance().getHooksDirectory(),C=xD(D)?JSON.parse(pu(D,"utf8")):{hooks:{}};if(s0(W2(D),{recursive:!0}),!C.hooks)C.hooks={};["SessionStart","Stop","UserPromptSubmit","PostToolUse"].forEach(($)=>{if(C.hooks[$])C.hooks[$]=C.hooks[$].filter((E)=>!E.hooks?.some((Q)=>Q.command?.includes(L0)))}),C.hooks.SessionStart=[lu(uD(F,"session-start.js"),180)],C.hooks.Stop=[lu(uD(F,"stop.js"),60)],C.hooks.UserPromptSubmit=[lu(uD(F,"user-prompt-submit.js"),60)],C.hooks.PostToolUse=[lu(uD(F,"post-tool-use.js"),180,"*")],J0(D,JSON.stringify(C,null,2))}function NB(D){if(D.scope==="local"&&D.customPath)return uD(D.customPath,"settings.local.json");else if(D.scope==="project")return uD(process.cwd(),".claude","settings.json");else return k.getInstance().getClaudeSettingsPath()}function OB(D){let F=k.getInstance().getUserSettingsPath(),C=xD(F)?JSON.parse(pu(F,"utf8")):{};C.backend="chroma",C.installed=!0,C.embedded=!0,C.saveMemoriesOnClear=D.saveMemoriesOnClear||!1,C.claudePath=zB(),J0(F,JSON.stringify(C,null,2))}function jB(){let D=G0.getShellConfigPaths(),u=G0.getAliasDefinition("rm","claude-mem trash"),F=G0.isWindows()?"# claude-mem smart trash alias":"# claude-mem smart trash alias";for(let C of D){if(!xD(C)){let E=W2(C);if(!xD(E))s0(E,{recursive:!0});J0(C,"")}let B=pu(C,"utf8");if(B.includes(u))continue;let $=` ${F} ${u} -`;B+=$,J0(C,B)}}function OB(){let D=k.getInstance(),u=D.getClaudeCommandsDirectory(),F=D.findPackageCommandsDirectory();s0(u,{recursive:!0});let C=["save.md","remember.md","claude-mem.md"];for(let B of C){let $=uD(F,B),E=uD(u,B);if(xD($))U2($,E)}}async function K6(D={}){console.log(o0(` +`;B+=$,J0(C,B)}}function TB(){let D=k.getInstance(),u=D.getClaudeCommandsDirectory(),F=D.findPackageCommandsDirectory();s0(u,{recursive:!0});let C=["save.md","remember.md","claude-mem.md"];for(let B of C){let $=uD(F,B),E=uD(u,B);if(xD($))U2($,E)}}async function q6(D={}){console.log(o0(` \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550`)),console.log(o0(" CLAUDE-MEM INSTALLER ")),console.log(o0("\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550")),console.log(du(_2(`\uD83E\uDDE0 Persistent Memory System for Claude Code \u2728 Transform your Claude experience with seamless context preservation -\uD83D\uDE80 Never lose your conversation history again`),{padding:2,margin:1,borderStyle:"double",borderColor:"magenta",textAlignment:"center"})),AB();let u=D.user||D.project||D.local||D.force,F;if(u)F={scope:D.local?"local":D.project?"project":"user",customPath:D.path,hookTimeout:D.timeout?parseInt(D.timeout):180,forceReinstall:!!D.force,enableSmartTrash:!1,saveMemoriesOnClear:!1};else{let X=GB(),Z=await zB(X);if(!Z)process.exit(0);F=Z}console.log(_2(` +\uD83D\uDE80 Never lose your conversation history again`),{padding:2,margin:1,borderStyle:"double",borderColor:"magenta",textAlignment:"center"})),GB();let u=D.user||D.project||D.local||D.force,F;if(u)F={scope:D.local?"local":D.project?"project":"user",customPath:D.path,hookTimeout:D.timeout?parseInt(D.timeout):180,forceReinstall:!!D.force,enableSmartTrash:!1,saveMemoriesOnClear:!1};else{let X=_B(),Z=await UB(X);if(!Z)process.exit(0);F=Z}console.log(_2(` \uD83D\uDE80 Beginning Installation Process -`));let C=[{name:"Creating directory structure",fn:()=>_B()},{name:"Installing Chroma MCP server",fn:()=>LB(F.forceReinstall)},{name:"Adding CLAUDE.md instructions",fn:()=>WB()},{name:"Installing Claude commands",fn:()=>OB()},{name:"Installing memory hooks",fn:()=>UB(F.hookTimeout)},{name:"Configuring Claude settings",fn:()=>RB(MB(F))},{name:"Configuring user settings",fn:()=>IB(F)}];if(F.enableSmartTrash)C.push({name:"Configuring Smart Trash alias",fn:()=>NB()});for(let X=0;XWB()},{name:"Installing Chroma MCP server",fn:()=>MB(F.forceReinstall)},{name:"Adding CLAUDE.md instructions",fn:()=>RB()},{name:"Installing Claude commands",fn:()=>TB()},{name:"Installing memory hooks",fn:()=>LB(F.hookTimeout)},{name:"Configuring Claude settings",fn:()=>IB(NB(F))},{name:"Configuring user settings",fn:()=>OB(F)}];if(F.enableSmartTrash)C.push({name:"Configuring Smart Trash alias",fn:()=>jB()});for(let X=0;X{if(Y.trim()==='alias rm="claude-mem trash"')return!1;for(let A of C)if(Y.trim()===A&&J+1!G.hooks?.some((z)=>z.command===B||z.command?.includes("pre-compact.js")||z.command?.includes("claude-mem")));if(H.length!==J.hooks.PreCompact.length)J.hooks.PreCompact=H.length?H:void 0,A=!0,console.log(`\u2705 Removed PreCompact hook from ${Z.name} settings`)}if(J.hooks.SessionStart){let H=J.hooks.SessionStart.filter((G)=>!G.hooks?.some((z)=>z.command===$||z.command?.includes("session-start.js")||z.command?.includes("claude-mem")));if(H.length!==J.hooks.SessionStart.length)J.hooks.SessionStart=H.length?H:void 0,A=!0,console.log(`\u2705 Removed SessionStart hook from ${Z.name} settings`)}if(J.hooks.SessionEnd){let H=J.hooks.SessionEnd.filter((G)=>!G.hooks?.some((z)=>z.command===E||z.command?.includes("session-end.js")||z.command?.includes("claude-mem")));if(H.length!==J.hooks.SessionEnd.length)J.hooks.SessionEnd=H.length?H:void 0,A=!0,console.log(`\u2705 Removed SessionEnd hook from ${Z.name} settings`)}if(J.hooks.PreCompact===void 0)delete J.hooks.PreCompact;if(J.hooks.SessionStart===void 0)delete J.hooks.SessionStart;if(J.hooks.SessionEnd===void 0)delete J.hooks.SessionEnd;if(!Object.keys(J.hooks).length)delete J.hooks;if(A){let H=Z.path+".backup."+Date.now();au(H,Y),console.log(`\uD83D\uDCCB Created backup: ${H}`),au(Z.path,JSON.stringify(J,null,2)),Q++,console.log(`\u2705 Updated ${Z.name} settings: ${Z.path}`)}else console.log(`\u2139\uFE0F No Claude Memory System hooks found in ${Z.name} settings`)}let X=await TB();if(console.log(""),Q>0||X){if(console.log("\u2728 Uninstallation complete!"),Q>0)console.log("The Claude Memory System hooks have been removed from your settings.");if(X)console.log("The Smart Trash alias has been removed from your shell configuration."),console.log("\u26A0\uFE0F Restart your terminal for the alias removal to take effect.");console.log(""),console.log("Note: Your compressed transcripts and archives are preserved."),console.log("To reinstall: claude-mem install")}else console.log("\u2139\uFE0F No Claude Memory System hooks or aliases were found to remove.")}qD();aD();ru();import{readFileSync as R2,existsSync as e0,readdirSync as SB,statSync as xB}from"fs";import{join as q0,dirname as bB}from"path";import{execSync as vB}from"child_process";import{fileURLToPath as fB}from"url";var sQ=bB(fB(import.meta.url));async function _6(){console.log("\uD83D\uDD0D Claude Memory System Status Check"),console.log(`===================================== -`),console.log("\uD83D\uDCC2 Runtime Hook Scripts (installed from hook-templates/):");let D=k.getInstance(),u=D.getHooksDirectory(),F=q0(u,"session-start.js"),C=q0(u,"stop.js"),B=q0(u,"user-prompt-submit.js"),$=q0(u,"post-tool-use.js"),E=(G,z)=>{if(e0(G))console.log(` \u2705 ${z}: Found at ${G}`);else console.log(` \u274C ${z}: Not found at ${G}`)};E(F,"session-start.js"),E(C,"stop.js"),E(B,"user-prompt-submit.js"),E($,"post-tool-use.js"),console.log(""),console.log("\u2699\uFE0F Settings Configuration:");let Q=(G,z)=>{if(!e0(z)){console.log(` \u23ED\uFE0F ${G}: No settings file`);return}console.log(` \uD83D\uDCCB ${G}: ${z}`);try{let U=JSON.parse(R2(z,"utf8")),I=U.hooks?.SessionStart?.some((P)=>P.hooks?.some((x)=>x.command?.includes("session-start.js")||x.command?.includes("claude-mem"))),j=U.hooks?.Stop?.some((P)=>P.hooks?.some((x)=>x.command?.includes("stop.js")||x.command?.includes("claude-mem"))),R=U.hooks?.UserPromptSubmit?.some((P)=>P.hooks?.some((x)=>x.command?.includes("user-prompt-submit.js")||x.command?.includes("claude-mem"))),M=U.hooks?.PostToolUse?.some((P)=>P.hooks?.some((x)=>x.command?.includes("post-tool-use.js")||x.command?.includes("claude-mem")));console.log(` SessionStart: ${I?"\u2705":"\u274C"}`),console.log(` Stop: ${j?"\u2705":"\u274C"}`),console.log(` UserPromptSubmit: ${R?"\u2705":"\u274C"}`),console.log(` PostToolUse: ${M?"\u2705":"\u274C"}`)}catch(U){console.log(" \u26A0\uFE0F Could not parse settings")}};Q("Global",D.getClaudeSettingsPath()),Q("Project",q0(process.cwd(),".claude","settings.json")),console.log(""),console.log("\uD83D\uDCE6 Compressed Transcripts:");let X=q0(D.getClaudeConfigDirectory(),"projects");if(e0(X))try{let G=0,z=0,U=(I,j=0)=>{if(j>3)return;let R=SB(I);for(let M of R){let P=q0(I,M);if(xB(P).isDirectory()&&!M.startsWith("."))U(P,j+1);else if(M.endsWith(".jsonl.compressed"))G++;else if(M.endsWith(".jsonl.archive"))z++}};U(X),console.log(` Compressed files: ${G}`),console.log(` Archive files: ${z}`)}catch(G){console.log(" \u26A0\uFE0F Could not scan projects directory")}else console.log(" \u2139\uFE0F No Claude projects directory found");console.log(""),console.log("\uD83D\uDD27 Runtime Environment:");let Z=(G,z)=>{try{let U=vB(`${G} --version`,{encoding:"utf8"}).trim();console.log(` \u2705 ${z}: ${U}`)}catch{console.log(` \u274C ${z}: Not found`)}};Z("node","Node.js"),Z("bun","Bun"),console.log(""),console.log("\uD83E\uDDE0 Chroma Storage Status:"),console.log(" \u2705 Storage backend: Chroma MCP"),console.log(` \uD83D\uDCCD Data location: ${D.getChromaDirectory()}`),console.log(" \uD83D\uDD0D Features: Vector search, semantic similarity, document storage"),console.log(""),console.log("\uD83E\uDD16 Claude Agent SDK Sessions:");try{await jD.getInstance().initialize();let U=new t0().getAll();if(U.length===0)console.log(S.gray(" No active sessions"));else{let I=U.filter((j)=>{return(Date.now()-j.last_used_epoch)/86400000<7}).length;console.log(` \uD83D\uDCCA Total sessions: ${U.length}`),console.log(` \u2705 Active (< 7 days): ${I}`),console.log(S.dim(" \uD83D\uDCA1 View details: claude-mem sessions list"))}}catch(G){console.log(S.gray(" \u26A0\uFE0F Could not load session info"))}console.log(""),console.log("\uD83D\uDCCA Summary:");let Y=D.getClaudeSettingsPath(),J=q0(process.cwd(),".claude","settings.json"),A=!1,H="Not installed";try{if(e0(Y)){let G=JSON.parse(R2(Y,"utf8"));if(G.hooks?.SessionStart||G.hooks?.Stop||G.hooks?.PostToolUse)A=!0,H="Global"}if(e0(J)){let G=JSON.parse(R2(J,"utf8"));if(G.hooks?.SessionStart||G.hooks?.Stop||G.hooks?.PostToolUse)A=!0,H=H==="Global"?"Global + Project":"Project"}}catch{}if(A)console.log(` \u2705 Claude Memory System is installed (${H})`),console.log(""),console.log("\uD83D\uDCA1 To test: Use /compact in Claude Code");else console.log(" \u274C Claude Memory System is not installed"),console.log(""),console.log("\uD83D\uDCA1 To install: claude-mem install")}qD();import{readFileSync as yB,readdirSync as hB,statSync as gB}from"fs";import{join as U6}from"path";async function mB(D,u,F){try{let $=yB(D,"utf8").split(` -`).filter((E)=>E.trim()).slice(-F);if(console.log(`\uD83D\uDCCB ${u} Logs (last ${F} lines):`),console.log(` File: ${D}`),console.log(""),$.length===0)console.log(" No log entries found");else $.forEach((E)=>{console.log(` ${E}`)});console.log("")}catch(C){console.log(`\u274C Could not read ${u.toLowerCase()} log: ${D}`)}}async function W6(D={}){let u=k.getLogsDirectory(),F=parseInt(D.tail)||20;try{let B=hB(u).filter(($)=>$.startsWith("claude-mem-")&&$.endsWith(".log")).map(($)=>({name:$,path:U6(u,$),mtime:gB(U6(u,$)).mtime})).sort(($,E)=>E.mtime.getTime()-$.mtime.getTime());if(B.length===0){console.log("\u274C No log files found in ~/.claude-mem/logs/");return}if(await mB(B[0].path,"Most Recent",F),D.all&&B.length>1)console.log(`\uD83D\uDCDA Found ${B.length} total log files`)}catch(C){console.log("\u274C Could not read logs directory: ~/.claude-mem/logs/"),console.log(" Run a compression first to generate logs")}if(D.follow)console.log("Following logs... (Press Ctrl+C to stop)"),setInterval(()=>{},1000)}qD();import Cu from"fs";import{join as B4}from"path";function L6(D){try{let u=D instanceof Date?D:new Date(D),C=new Date().getTime()-u.getTime(),B=Math.floor(C/1000),$=Math.floor(B/60),E=Math.floor($/60),Q=Math.floor(E/24),X=Math.floor(Q/7),Z=Math.floor(Q/30);if(B<60)return"Just now";else if($<60)return $===1?"1 minute ago":`${$} minutes ago`;else if(E<24)return E===1?"1 hour ago":`${E} hours ago`;else if(Q===1)return"Yesterday";else if(Q<7)return`${Q} days ago`;else if(X===1)return"1 week ago";else if(X<4)return`${X} weeks ago`;else if(Z===1)return"1 month ago";else if(Z<12)return`${Z} months ago`;else{let Y=Math.floor(Z/12);return Y===1?"1 year ago":`${Y} years ago`}}catch(u){return"Recently"}}function ou(){let D=process.env.CLAUDE_MEM_WRAP_WIDTH;if(D){let u=parseInt(D,10);if(!Number.isNaN(u)&&u>40&&u<=200)return u}return 80}function dB(D,u){if(!D)return"";if(/^[\-=\u2014_\u2500\u2550]{5,}$/.test(D.trim()))return D;if(D.length<=u)return D;let F=D.match(/^\s*/),C=F?F[0]:"",B=D.slice(C.length),$=Math.max(10,u-C.length),E=B.split(/(\s+)/),Q=[],X="",Z=()=>{Q.push(C+X.trimEnd()),X=""};for(let Y of E){if(Y==="")continue;if(!/\s/.test(Y)&&Y.length>$){if(X.trim().length>0)Z();let J=0;while(Ju)Z();X+=Y}if(X.trim().length>0||Q.length===0)Z();return Q.join(` +`);if(Z!==E){let Y=$+".backup."+Date.now();au(Y,E),au($,Z),console.log(`\u2705 Removed Smart Trash alias from ${$.replace(D,"~")}`),B=!0}}return B}async function H6(D={}){console.log("\uD83D\uDD04 Uninstalling Claude Memory System hooks...");let u=[];if(D.all)u.push({name:"User",path:k.getInstance().getClaudeSettingsPath()}),u.push({name:"Project",path:K0(process.cwd(),".claude","settings.json")});else{let Z=D.project,Y=k.getInstance();u.push({name:Z?"Project":"User",path:Z?K0(process.cwd(),".claude","settings.json"):Y.getClaudeSettingsPath()})}let C=k.getInstance().getHooksDirectory(),B=K0(C,"pre-compact.js"),$=K0(C,"session-start.js"),E=K0(C,"session-end.js"),Q=0;for(let Z of u){if(!A6(Z.path)){console.log(`\u23ED\uFE0F No settings found at ${Z.name} location`);continue}let Y=V6(Z.path,"utf8"),J=JSON.parse(Y);if(!J.hooks){console.log(`\u23ED\uFE0F No hooks configured in ${Z.name} settings`);continue}let A=!1;if(J.hooks.PreCompact){let H=J.hooks.PreCompact.filter((G)=>!G.hooks?.some((z)=>z.command===B||z.command?.includes("pre-compact.js")||z.command?.includes("claude-mem")));if(H.length!==J.hooks.PreCompact.length)J.hooks.PreCompact=H.length?H:void 0,A=!0,console.log(`\u2705 Removed PreCompact hook from ${Z.name} settings`)}if(J.hooks.SessionStart){let H=J.hooks.SessionStart.filter((G)=>!G.hooks?.some((z)=>z.command===$||z.command?.includes("session-start.js")||z.command?.includes("claude-mem")));if(H.length!==J.hooks.SessionStart.length)J.hooks.SessionStart=H.length?H:void 0,A=!0,console.log(`\u2705 Removed SessionStart hook from ${Z.name} settings`)}if(J.hooks.SessionEnd){let H=J.hooks.SessionEnd.filter((G)=>!G.hooks?.some((z)=>z.command===E||z.command?.includes("session-end.js")||z.command?.includes("claude-mem")));if(H.length!==J.hooks.SessionEnd.length)J.hooks.SessionEnd=H.length?H:void 0,A=!0,console.log(`\u2705 Removed SessionEnd hook from ${Z.name} settings`)}if(J.hooks.PreCompact===void 0)delete J.hooks.PreCompact;if(J.hooks.SessionStart===void 0)delete J.hooks.SessionStart;if(J.hooks.SessionEnd===void 0)delete J.hooks.SessionEnd;if(!Object.keys(J.hooks).length)delete J.hooks;if(A){let H=Z.path+".backup."+Date.now();au(H,Y),console.log(`\uD83D\uDCCB Created backup: ${H}`),au(Z.path,JSON.stringify(J,null,2)),Q++,console.log(`\u2705 Updated ${Z.name} settings: ${Z.path}`)}else console.log(`\u2139\uFE0F No Claude Memory System hooks found in ${Z.name} settings`)}let X=await kB();if(console.log(""),Q>0||X){if(console.log("\u2728 Uninstallation complete!"),Q>0)console.log("The Claude Memory System hooks have been removed from your settings.");if(X)console.log("The Smart Trash alias has been removed from your shell configuration."),console.log("\u26A0\uFE0F Restart your terminal for the alias removal to take effect.");console.log(""),console.log("Note: Your compressed transcripts and archives are preserved."),console.log("To reinstall: claude-mem install")}else console.log("\u2139\uFE0F No Claude Memory System hooks or aliases were found to remove.")}qD();aD();ru();import{readFileSync as R2,existsSync as e0,readdirSync as bB,statSync as vB}from"fs";import{join as q0,dirname as fB}from"path";import{execSync as yB}from"child_process";import{fileURLToPath as hB}from"url";var eQ=fB(hB(import.meta.url));async function U6(){console.log("\uD83D\uDD0D Claude Memory System Status Check"),console.log(`===================================== +`),console.log("\uD83D\uDCC2 Runtime Hook Scripts (installed from hook-templates/):");let D=k.getInstance(),u=D.getHooksDirectory(),F=q0(u,"session-start.js"),C=q0(u,"stop.js"),B=q0(u,"user-prompt-submit.js"),$=q0(u,"post-tool-use.js"),E=(G,z)=>{if(e0(G))console.log(` \u2705 ${z}: Found at ${G}`);else console.log(` \u274C ${z}: Not found at ${G}`)};E(F,"session-start.js"),E(C,"stop.js"),E(B,"user-prompt-submit.js"),E($,"post-tool-use.js"),console.log(""),console.log("\u2699\uFE0F Settings Configuration:");let Q=(G,z)=>{if(!e0(z)){console.log(` \u23ED\uFE0F ${G}: No settings file`);return}console.log(` \uD83D\uDCCB ${G}: ${z}`);try{let U=JSON.parse(R2(z,"utf8")),I=U.hooks?.SessionStart?.some((P)=>P.hooks?.some((x)=>x.command?.includes("session-start.js")||x.command?.includes("claude-mem"))),j=U.hooks?.Stop?.some((P)=>P.hooks?.some((x)=>x.command?.includes("stop.js")||x.command?.includes("claude-mem"))),R=U.hooks?.UserPromptSubmit?.some((P)=>P.hooks?.some((x)=>x.command?.includes("user-prompt-submit.js")||x.command?.includes("claude-mem"))),M=U.hooks?.PostToolUse?.some((P)=>P.hooks?.some((x)=>x.command?.includes("post-tool-use.js")||x.command?.includes("claude-mem")));console.log(` SessionStart: ${I?"\u2705":"\u274C"}`),console.log(` Stop: ${j?"\u2705":"\u274C"}`),console.log(` UserPromptSubmit: ${R?"\u2705":"\u274C"}`),console.log(` PostToolUse: ${M?"\u2705":"\u274C"}`)}catch(U){console.log(" \u26A0\uFE0F Could not parse settings")}};Q("Global",D.getClaudeSettingsPath()),Q("Project",q0(process.cwd(),".claude","settings.json")),console.log(""),console.log("\uD83D\uDCE6 Compressed Transcripts:");let X=q0(D.getClaudeConfigDirectory(),"projects");if(e0(X))try{let G=0,z=0,U=(I,j=0)=>{if(j>3)return;let R=bB(I);for(let M of R){let P=q0(I,M);if(vB(P).isDirectory()&&!M.startsWith("."))U(P,j+1);else if(M.endsWith(".jsonl.compressed"))G++;else if(M.endsWith(".jsonl.archive"))z++}};U(X),console.log(` Compressed files: ${G}`),console.log(` Archive files: ${z}`)}catch(G){console.log(" \u26A0\uFE0F Could not scan projects directory")}else console.log(" \u2139\uFE0F No Claude projects directory found");console.log(""),console.log("\uD83D\uDD27 Runtime Environment:");let Z=(G,z)=>{try{let U=yB(`${G} --version`,{encoding:"utf8"}).trim();console.log(` \u2705 ${z}: ${U}`)}catch{console.log(` \u274C ${z}: Not found`)}};Z("node","Node.js"),Z("bun","Bun"),console.log(""),console.log("\uD83E\uDDE0 Chroma Storage Status:"),console.log(" \u2705 Storage backend: Chroma MCP"),console.log(` \uD83D\uDCCD Data location: ${D.getChromaDirectory()}`),console.log(" \uD83D\uDD0D Features: Vector search, semantic similarity, document storage"),console.log(""),console.log("\uD83E\uDD16 Claude Agent SDK Sessions:");try{await jD.getInstance().initialize();let U=new t0().getAll();if(U.length===0)console.log(S.gray(" No active sessions"));else{let I=U.filter((j)=>{return(Date.now()-j.last_used_epoch)/86400000<7}).length;console.log(` \uD83D\uDCCA Total sessions: ${U.length}`),console.log(` \u2705 Active (< 7 days): ${I}`),console.log(S.dim(" \uD83D\uDCA1 View details: claude-mem sessions list"))}}catch(G){console.log(S.gray(" \u26A0\uFE0F Could not load session info"))}console.log(""),console.log("\uD83D\uDCCA Summary:");let Y=D.getClaudeSettingsPath(),J=q0(process.cwd(),".claude","settings.json"),A=!1,H="Not installed";try{if(e0(Y)){let G=JSON.parse(R2(Y,"utf8"));if(G.hooks?.SessionStart||G.hooks?.Stop||G.hooks?.PostToolUse)A=!0,H="Global"}if(e0(J)){let G=JSON.parse(R2(J,"utf8"));if(G.hooks?.SessionStart||G.hooks?.Stop||G.hooks?.PostToolUse)A=!0,H=H==="Global"?"Global + Project":"Project"}}catch{}if(A)console.log(` \u2705 Claude Memory System is installed (${H})`),console.log(""),console.log("\uD83D\uDCA1 To test: Use /compact in Claude Code");else console.log(" \u274C Claude Memory System is not installed"),console.log(""),console.log("\uD83D\uDCA1 To install: claude-mem install")}qD();import{readFileSync as gB,readdirSync as mB,statSync as dB}from"fs";import{join as W6}from"path";async function cB(D,u,F){try{let $=gB(D,"utf8").split(` +`).filter((E)=>E.trim()).slice(-F);if(console.log(`\uD83D\uDCCB ${u} Logs (last ${F} lines):`),console.log(` File: ${D}`),console.log(""),$.length===0)console.log(" No log entries found");else $.forEach((E)=>{console.log(` ${E}`)});console.log("")}catch(C){console.log(`\u274C Could not read ${u.toLowerCase()} log: ${D}`)}}async function L6(D={}){let u=k.getLogsDirectory(),F=parseInt(D.tail)||20;try{let B=mB(u).filter(($)=>$.startsWith("claude-mem-")&&$.endsWith(".log")).map(($)=>({name:$,path:W6(u,$),mtime:dB(W6(u,$)).mtime})).sort(($,E)=>E.mtime.getTime()-$.mtime.getTime());if(B.length===0){console.log("\u274C No log files found in ~/.claude-mem/logs/");return}if(await cB(B[0].path,"Most Recent",F),D.all&&B.length>1)console.log(`\uD83D\uDCDA Found ${B.length} total log files`)}catch(C){console.log("\u274C Could not read logs directory: ~/.claude-mem/logs/"),console.log(" Run a compression first to generate logs")}if(D.follow)console.log("Following logs... (Press Ctrl+C to stop)"),setInterval(()=>{},1000)}qD();import Cu from"fs";import{join as $4}from"path";function R6(D){try{let u=D instanceof Date?D:new Date(D),C=new Date().getTime()-u.getTime(),B=Math.floor(C/1000),$=Math.floor(B/60),E=Math.floor($/60),Q=Math.floor(E/24),X=Math.floor(Q/7),Z=Math.floor(Q/30);if(B<60)return"Just now";else if($<60)return $===1?"1 minute ago":`${$} minutes ago`;else if(E<24)return E===1?"1 hour ago":`${E} hours ago`;else if(Q===1)return"Yesterday";else if(Q<7)return`${Q} days ago`;else if(X===1)return"1 week ago";else if(X<4)return`${X} weeks ago`;else if(Z===1)return"1 month ago";else if(Z<12)return`${Z} months ago`;else{let Y=Math.floor(Z/12);return Y===1?"1 year ago":`${Y} years ago`}}catch(u){return"Recently"}}function ou(){let D=process.env.CLAUDE_MEM_WRAP_WIDTH;if(D){let u=parseInt(D,10);if(!Number.isNaN(u)&&u>40&&u<=200)return u}return 80}function lB(D,u){if(!D)return"";if(/^[\-=\u2014_\u2500\u2550]{5,}$/.test(D.trim()))return D;if(D.length<=u)return D;let F=D.match(/^\s*/),C=F?F[0]:"",B=D.slice(C.length),$=Math.max(10,u-C.length),E=B.split(/(\s+)/),Q=[],X="",Z=()=>{Q.push(C+X.trimEnd()),X=""};for(let Y of E){if(Y==="")continue;if(!/\s/.test(Y)&&Y.length>$){if(X.trim().length>0)Z();let J=0;while(Ju)Z();X+=Y}if(X.trim().length>0||Q.length===0)Z();return Q.join(` `)}function bD(D,u){if(!D)return"";return D.split(` -`).map((F)=>dB(F,u)).join(` +`).map((F)=>lB(F,u)).join(` `)}function iu(D="\u2500",u=ou()){if(!D||D.length===0)D="-";return D.repeat(u).slice(0,u)}function M2(D,u,F){let C=u!==void 0?` (${u} items)`:"",B=F?` ${F}`:"",$=ou();return bD(`\u2705 ${D} completed successfully${C}${B}`,$)}function I2(D,u,F){let C=F?` -\uD83D\uDCA1 ${F}`:"",B=ou();return bD(`\u274C ${D} encountered an issue: ${u}${C}`,B)}var cB={NO_MEMORIES:(D)=>({message:`No previous memories found for ${D}`,suggestion:"This appears to be your first session. Memories will be created as you work."}),CONNECTION_FAILED:()=>({message:"Could not connect to memory system",suggestion:"Try restarting Claude Code or check if the MCP server is properly configured."}),SEARCH_FAILED:(D)=>({message:`Search for "${D}" didn't return any results`,suggestion:"Try using different keywords or check if memories exist for this project."}),LOAD_TIMEOUT:()=>({message:"Memory loading timed out",suggestion:"The operation is taking longer than expected. You can continue without loaded context."})};function Du(D,...u){let F=cB[D](...u);return I2("Memory system",F.message,F.suggestion)}function R6(D){let u=typeof D==="string"?new Date(D):D,C=new Date().getTime()-u.getTime(),B=Math.floor(C/60000),$=Math.floor(C/3600000),E=Math.floor(C/86400000);if(B<1)return"just now";if(B<60)return`${B} minute${B>1?"s":""} ago`;if($<24)return`${$} hour${$>1?"s":""} ago`;if(E<7)return`${E} day${E>1?"s":""} ago`;return u.toLocaleDateString()}function lB(D){if(D.length===0)return[];return D.filter((u)=>u.type==="memory").map((u)=>{let F={summary:u.text||"",sessionId:u.session_id||""};if(u.keywords)F.keywords=u.keywords;if(u.document_id&&!u.document_id.includes("Session:"))F.location=u.document_id;return F}).filter((u)=>u.summary.length>0)}function pB(D){let u=new Map;return D.forEach((F)=>{let C=F.sessionId;if(C){if(!u.has(C))u.set(C,[]);u.get(C).push(F)}}),Array.from(u.entries()).map(([F,C])=>{let B=C.map(($,E)=>({...$,number:E+1}));return{sessionId:F,memories:B}})}function aB(D){let u=new Map;return D.forEach((F)=>{let C=F.sessionId||"unknown";if(!u.has(C))u.set(C,[]);u.get(C).push(F)}),Array.from(u.entries()).map(([F,C])=>{let B=C.map((E)=>E.timestamp).filter((E)=>E!==void 0).sort((E,Q)=>E.getTime()-Q.getTime()),$={sessionId:F,overviews:C};if(B.length>0)$.earliestTimestamp=B[0],$.timeAgo=L6(B[0]);return $})}function M6(D){let{projectName:u,memoryCount:F,lastSessionTime:C,recentObjects:B}=D,$=ou(),Q=new Date().toLocaleString("en-US",{weekday:"long",year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit",timeZoneName:"short"});console.log(""),console.log(bD(`\uD83D\uDCC5 ${Q}`,$)),console.log(iu("\u2500",$));let X=extractOverviews(B,10,u);console.error(`[DEBUG] recentObjects has ${B.length} items`),console.error(`[DEBUG] overviews extracted: ${X.length}`);let Z=lB(B),Y=(J,A)=>{let H=J.includes(",")||J.includes(` -`)?J.split(/[\n,]+/):[J];for(let G of H){let z=G.trim();if(!z)continue;let U=z.toLowerCase();if(!A.has(U))A.set(U,z)}};if(Z.length>0){let J=pB(Z);console.log(""),console.log(""),console.log(bD("\uD83D\uDCDA Memories",$)),J.forEach((A)=>{console.log(iu("\u2500",$)),console.log(""),console.log(bD(`\uD83D\uDD0D ${A.sessionId}`,$));let H=new Map;A.memories.forEach((z)=>{if(console.log(""),console.log(bD(`${z.number}. ${z.summary}`,$)),z.keywords)Y(z.keywords,H)});let G=Array.from(H.values());if(G.length>0)console.log(""),console.log(bD(`\uD83C\uDFF7\uFE0F ${G.join(", ")}`,$));console.log("")})}if(X.length>0){let J=aB(X);J.sort((A,H)=>{let G=A.earliestTimestamp?.getTime()||0,z=H.earliestTimestamp?.getTime()||0;return G-z}),console.log(""),console.log(bD("\uD83E\uDDE0 Overviews",$)),console.log(iu("\u2500",$)),J.forEach((A)=>{console.log(""),console.log(bD(`\uD83D\uDD0D ${A.sessionId}`,$)),A.overviews.forEach((H,G)=>{if(console.log(""),console.log(bD(`${G+1}. ${H.content}`,$)),console.log(""),H.timeAgo)console.log(bD(`\uD83D\uDCC5 ${H.timeAgo}`,$))}),console.log(""),console.log(iu("\u2500",$))})}else if(Z.length===0)console.log(bD(`\uD83E\uDDE0 No recent context found for ${u}`,$))}qD();import z0 from"fs";aD();ru();O2();T2();k2();S2();su();j0();tu();async function nD(){let{DatabaseManager:D}=await Promise.resolve().then(() => (aD(),G6)),{migrations:u}=await Promise.resolve().then(() => (tu(),x6)),F=D.getInstance();for(let Y of u)F.registerMigration(Y);let C=await F.initialize(),{SessionStore:B}=await Promise.resolve().then(() => (ru(),z6)),{MemoryStore:$}=await Promise.resolve().then(() => (O2(),I6)),{OverviewStore:E}=await Promise.resolve().then(() => (T2(),N6)),{DiagnosticsStore:Q}=await Promise.resolve().then(() => (k2(),O6)),{TranscriptEventStore:X}=await Promise.resolve().then(() => (S2(),j6)),{StreamingSessionStore:Z}=await Promise.resolve().then(() => (su(),T6));return{sessions:new B(C),memories:new $(C),overviews:new E(C),diagnostics:new Q(C),transcriptEvents:new X(C),streamingSessions:new Z(C)}}class x2{backend="sqlite";stores;async getStores(){if(!this.stores)this.stores=await nD();return this.stores}async isAvailable(){try{return await this.getStores(),!0}catch(D){return!1}}async createSession(D){return(await this.getStores()).sessions.create(D)}async getSession(D){return(await this.getStores()).sessions.getBySessionId(D)}async hasSession(D){return(await this.getStores()).sessions.has(D)}async getAllSessionIds(){return(await this.getStores()).sessions.getAllSessionIds()}async getRecentSessions(D=5){return(await this.getStores()).sessions.getRecent(D)}async getRecentSessionsForProject(D,u=5){return(await this.getStores()).sessions.getRecentForProject(D,u)}async createMemory(D){return(await this.getStores()).memories.create(D)}async createMemories(D){(await this.getStores()).memories.createMany(D)}async getRecentMemories(D=10){return(await this.getStores()).memories.getRecent(D)}async getRecentMemoriesForProject(D,u=10){return(await this.getStores()).memories.getRecentForProject(D,u)}async hasDocumentId(D){return(await this.getStores()).memories.hasDocumentId(D)}async createOverview(D){return(await this.getStores()).overviews.create(D)}async upsertOverview(D){return(await this.getStores()).overviews.upsert(D)}async getRecentOverviews(D=5){return(await this.getStores()).overviews.getRecent(D)}async getRecentOverviewsForProject(D,u=5){return(await this.getStores()).overviews.getRecentForProject(D,u)}async createDiagnostic(D){return(await this.getStores()).diagnostics.create(D)}}class b6{backend="jsonl";pathDiscovery=k.getInstance();async isAvailable(){try{let D=this.pathDiscovery.getDataDirectory();return z0.mkdirSync(D,{recursive:!0}),!0}catch{return!1}}appendToIndex(D){let u=this.pathDiscovery.getIndexPath();z0.appendFileSync(u,JSON.stringify(D)+"\\n","utf8")}async createSession(D){let u={type:"session",session_id:D.session_id,project:D.project,timestamp:D.created_at};this.appendToIndex(u)}async getSession(){return null}async hasSession(D){return(await this.getAllSessionIds()).has(D)}async getAllSessionIds(){let D=this.pathDiscovery.getIndexPath();if(!z0.existsSync(D))return new Set;let F=z0.readFileSync(D,"utf-8").trim().split("\\n").filter((B)=>B.trim()),C=new Set;for(let B of F)try{let $=JSON.parse(B);if($.session_id)C.add($.session_id)}catch{}return C}async getRecentSessions(){return[]}async getRecentSessionsForProject(){return[]}async createMemory(D){let u={type:"memory",text:D.text,document_id:D.document_id,keywords:D.keywords,session_id:D.session_id,project:D.project,timestamp:D.created_at,archive:D.archive_basename};this.appendToIndex(u)}async createMemories(D){for(let u of D)await this.createMemory(u)}async getRecentMemories(){return[]}async getRecentMemoriesForProject(){return[]}async hasDocumentId(D){let u=this.pathDiscovery.getIndexPath();if(!z0.existsSync(u))return!1;let C=z0.readFileSync(u,"utf-8").trim().split("\\n").filter((B)=>B.trim());for(let B of C)try{let $=JSON.parse(B);if($.type==="memory"&&$.document_id===D)return!0}catch{}return!1}async createOverview(D){let u={type:"overview",content:D.content,session_id:D.session_id,project:D.project,timestamp:D.created_at};this.appendToIndex(u)}async upsertOverview(D){await this.createOverview(D)}async getRecentOverviews(){return[]}async getRecentOverviewsForProject(){return[]}async createDiagnostic(D){let u={type:"diagnostic",message:D.message,session_id:D.session_id,project:D.project,timestamp:D.created_at};this.appendToIndex(u)}}var T0=null;async function v6(){if(T0)return T0;let D=new x2;if(await D.isAvailable())return T0=D,T0;let u=new b6;if(await u.isAvailable())return T0=u,T0;throw new Error("No storage backend available")}async function f6(){let u=k.getInstance().getIndexPath();if(z0.existsSync(u)){if(!await new x2().isAvailable())return!0;try{return(await nD()).sessions.count()===0}catch{return!0}}return!1}import{readFileSync as oB,existsSync as sB}from"fs";import{join as tB}from"path";qD();class b2{pathDiscovery;constructor(){this.pathDiscovery=k.getInstance()}getConfigDir(){return this.pathDiscovery.getDataDirectory()}getIndexDir(){return this.pathDiscovery.getIndexDirectory()}getIndexPath(){return this.pathDiscovery.getIndexPath()}getArchiveDir(){return this.pathDiscovery.getArchivesDirectory()}getProjectArchiveDir(D){return this.pathDiscovery.getProjectArchiveDirectory(D)}getLogsDir(){return this.pathDiscovery.getLogsDirectory()}static ensureDirectory(D){k.getInstance().ensureDirectory(D)}static ensureDirectories(D){k.getInstance().ensureDirectories(D)}static extractProjectName(D){return k.extractProjectName(D)}static getCurrentProjectPrefix(){return k.getCurrentProjectName()}static getCurrentProjectName(){return k.getCurrentProjectName()}}class v2{static settingsPath;static cachedSettings=null;static{let D=new b2;this.settingsPath=tB(D.getConfigDir(),"settings.json")}static readSettings(){if(this.cachedSettings!==null)return this.cachedSettings;try{if(sB(this.settingsPath)){let u=oB(this.settingsPath,"utf-8"),F=JSON.parse(u);return this.cachedSettings=F,F}}catch{}let D={};return this.cachedSettings=D,D}static getSetting(D,u){return this.readSettings()[D]??u}static getClaudePath(){return this.getSetting("claudePath","claude")}static clearCache(){this.cachedSettings=null}}function Fu(){return v2.getClaudePath()}function y6(){return v2.readSettings()}var w0={captureEnabled:!0,summaryEnabled:!0,sessionStartEnabled:!0,chunkTokenLimit:600,chunkOverlapTokens:200,summaryTurnLimit:20};function f2(D,u){if(typeof D==="boolean")return D;if(typeof D==="string"){let F=D.toLowerCase();if(F==="true")return!0;if(F==="false")return!1}return u}function y2(D,u){if(typeof D==="number"&&Number.isFinite(D))return D;if(typeof D==="string"){let F=Number(D);if(!Number.isNaN(F)&&Number.isFinite(F))return F}return u}function h6(){let D=y6();return{captureEnabled:f2(D.rollingCaptureEnabled,w0.captureEnabled),summaryEnabled:f2(D.rollingSummaryEnabled,w0.summaryEnabled),sessionStartEnabled:f2(D.rollingSessionStartEnabled,w0.sessionStartEnabled),chunkTokenLimit:y2(D.rollingChunkTokens,w0.chunkTokenLimit),chunkOverlapTokens:y2(D.rollingChunkOverlapTokens,w0.chunkOverlapTokens),summaryTurnLimit:y2(D.rollingSummaryTurnLimit,w0.summaryTurnLimit)}}qD();import{appendFileSync as eB,existsSync as D4,mkdirSync as u4}from"fs";import{join as F4}from"path";var eu=null;function C4(){if(eu)return eu;let u=k.getInstance().getLogsDirectory();if(!D4(u))u4(u,{recursive:!0});return eu=F4(u,"rolling-memory.log"),eu}function DF(D,u,F={}){try{let C=C4(),B={timestamp:new Date().toISOString(),level:D,message:u,...F};eB(C,`${JSON.stringify(B)} -`,"utf8")}catch{}}function g6(D=new Date){return D.toLocaleString("en-US",{weekday:"long",month:"long",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit",timeZoneName:"short"})}function h2(D,u,F){let C=D.split(" "),B=[],$=F,E=" ".repeat(F.length);for(let Q of C){let Z=$+($!==F&&$!==E?" ":"")+Q;if(Z.length<=u)$=Z;else{if($.trim())B.push($);$=E+Q}}if($.trim())B.push($);return B.join(` -`)}function E4(D){let u=new Set;return u.add(D),u.add(D.replace(/-/g,"_")),u.add(D.replace(/_/g,"-")),(F)=>!!F&&u.has(F)}function g2(D){if(D===0)return"0 B";let u=1024,F=["B","KB","MB","GB"],C=Math.floor(Math.log(D)/Math.log(u));return parseFloat((D/Math.pow(u,C)).toFixed(1))+" "+F[C]}function m2(){let D=k.getInstance().getTrashDirectory();if(!Cu.existsSync(D))return{folderCount:0,fileCount:0,totalSize:0,isEmpty:!0};let u=Cu.readdirSync(D);if(u.length===0)return{folderCount:0,fileCount:0,totalSize:0,isEmpty:!0};let F=0,C=0,B=0;for(let $ of u){let E=B4(D,$),Q=Cu.statSync(E);if(Q.isDirectory())F++;else C++;B+=Q.size}return{folderCount:F,fileCount:C,totalSize:B,isEmpty:!1}}async function $4(D){if(!h6().sessionStartEnabled){console.log("Rolling session-start output disabled in settings."),DF("info","session-start output skipped (disabled)",{project:D});return}let F=await nD(),C=D||k.getCurrentProjectName(),$=F.overviews.getAllForProject(C).slice(-10);if($.length===0){console.log("==============================================================================="),console.log(`What's new | ${g6()}`),console.log("==============================================================================="),console.log("No previous sessions found for this project."),console.log("Start working and claude-mem will automatically capture context for future sessions."),console.log("===============================================================================");let Q=m2();if(!Q.isEmpty){let X=g2(Q.totalSize);console.log(`\uD83D\uDDD1\uFE0F Trash \u2013 ${Q.folderCount} folders | ${Q.fileCount} files | ${X} \u2013 use \`claude-mem restore\``),console.log("===============================================================================")}return}console.log("==============================================================================="),console.log(`What's new | ${g6()}`),console.log("==============================================================================="),$.forEach((Q)=>{let X=new Date(Q.created_at),Z=X.getFullYear(),Y=String(X.getMonth()+1).padStart(2,"0"),J=String(X.getDate()).padStart(2,"0"),A=X.getHours(),H=String(X.getMinutes()).padStart(2,"0"),G=A>=12?"PM":"AM",z=A%12||12;console.log(`[${Z}-${Y}-${J} at ${z}:${H} ${G}]`);let U=F.memories.getBySessionId(Q.session_id),I=U.map((M)=>({title:M.title,subtitle:M.subtitle})).filter((M)=>M.title),j=new Set,R=new Set;if(U.forEach((M)=>{if(M.files_touched)try{let P=JSON.parse(M.files_touched);if(Array.isArray(P))P.forEach((x)=>j.add(x))}catch(P){}if(M.keywords)M.keywords.split(",").forEach((P)=>R.add(P.trim()))}),console.log(""),console.log(h2(Q.content,80,"")),j.size>0)console.log(""),console.log(h2(`- ${Array.from(j).join(", ")}`,80,""));if(R.size>0)console.log(""),console.log(h2(`Tags: ${Array.from(R).join(", ")}`,80,""));console.log("")}),console.log("===============================================================================");let E=m2();if(!E.isEmpty){let Q=g2(E.totalSize);console.log(`\uD83D\uDDD1\uFE0F Trash \u2013 ${E.folderCount} folders | ${E.fileCount} files | ${Q} \u2013 use \`claude-mem restore\``),console.log("===============================================================================")}}async function m6(D={}){try{if(await f6())console.warn("\u26A0\uFE0F JSONL to SQLite migration recommended. Run: claude-mem migrate-index");let u=await v6();if(u.backend==="jsonl")return await Q4(D);let F=[],C=[],B=D.project;if(!B&&D.format==="session-start")B=k.getCurrentProjectName();if(D.format==="session-start"){await $4(B);return}let $=D.format==="json"?5:3;if(B)F=await u.getRecentMemoriesForProject(B,10),C=await u.getRecentOverviewsForProject(B,$);else F=await u.getRecentMemories(10),C=await u.getRecentOverviews($);let E=F.map((X)=>({type:"memory",text:X.text,document_id:X.document_id,keywords:X.keywords,session_id:X.session_id,project:X.project,timestamp:X.created_at,archive:X.archive_basename})),Q=C.map((X)=>({type:"overview",content:X.content,session_id:X.session_id,project:X.project,timestamp:X.created_at}));if(E.length===0&&Q.length===0)return;if(D.format==="json"){let X=[...E,...Q];console.log(JSON.stringify(X))}else{let X=E.length+Q.length;console.log(M2("Context loading",X,"recent entries found")),E.forEach((Z)=>{console.log(`${Z.text} | ${Z.document_id} | ${Z.keywords}`)}),Q.forEach((Z)=>{console.log(`**Overview:** ${Z.content}`)})}if(D.format!=="json"){let X=m2();if(!X.isEmpty){let Z=g2(X.totalSize);console.log(`\uD83D\uDDD1\uFE0F Trash \u2013 ${X.folderCount} folders | ${X.fileCount} files | ${Z} \u2013 use \`claude-mem restore\``),console.log("")}}}catch(u){let F=u instanceof Error?u.message:String(u);if(D.format==="session-start")console.log(Du("CONNECTION_FAILED",F));else console.log(I2("Context loading",F,"Check file permissions and try again"))}}async function Q4(D={}){let F=k.getInstance().getIndexPath(),C=D.project;if(!C&&D.format==="session-start")C=k.getCurrentProjectName();if(!Cu.existsSync(F)){if(D.format==="session-start")console.log(Du("NO_MEMORIES",C||"this project"));return}let $=Cu.readFileSync(F,"utf-8").trim().split(` -`).filter((H)=>H.trim());if($.length===0){if(D.format==="session-start")console.log(Du("NO_MEMORIES",C||"this project"));return}let E=[];for(let H of $)try{if(!H.trim().startsWith("{"))continue;let G=JSON.parse(H);E.push(G)}catch(G){continue}if(E.length===0){if(D.format==="session-start")console.log(Du("NO_MEMORIES",C||"this project"));return}let Q=E.filter((H)=>H.type==="memory"),X=E.filter((H)=>H.type==="overview"),Z=E.filter((H)=>H.type==="session"),Y=Q,J=X,A=Z;if(C){let H=E4(C);Y=Q.filter((G)=>H(G.project)),J=X.filter((G)=>H(G.project)),A=Z.filter((G)=>H(G.project))}if(D.format==="session-start"){let H=Y.slice(-10),G=J.slice(-10),U=[...A.slice(-10),...H,...G],I="recently",j=U.map((R)=>{return R.timestamp?new Date(R.timestamp):null}).filter((R)=>R!==null).sort((R,M)=>M.getTime()-R.getTime());if(j.length>0)I=R6(j[0]);M6({projectName:C||"your project",memoryCount:H.length,lastSessionTime:I,recentObjects:U})}else if(D.format==="json"){let H=Y.slice(-10),G=J.slice(-3),z=[...H,...G];console.log(JSON.stringify(z))}else{let H=Y.slice(-10),G=J.slice(-3),z=H.length+G.length;console.log(M2("Context loading",z,"recent entries found")),H.forEach((U)=>{console.log(`${U.text} | ${U.document_id} | ${U.keywords}`)}),G.forEach((U)=>{console.log(`**Overview:** ${U.content}`)})}}import{renameSync as aE,existsSync as v1,mkdirSync as nE,statSync as rE}from"fs";import{join as iE,basename as oE}from"path";var d2=(D,u,F)=>{let C=D instanceof RegExp?d6(D,F):D,B=u instanceof RegExp?d6(u,F):u,$=C!==null&&B!=null&&X4(C,B,F);return $&&{start:$[0],end:$[1],pre:F.slice(0,$[0]),body:F.slice($[0]+C.length,$[1]),post:F.slice($[1]+B.length)}},d6=(D,u)=>{let F=u.match(D);return F?F[0]:null},X4=(D,u,F)=>{let C,B,$,E=void 0,Q,X=F.indexOf(D),Z=F.indexOf(u,X+1),Y=X;if(X>=0&&Z>0){if(D===u)return[X,Z];C=[],$=F.length;while(Y>=0&&!Q){if(Y===X)C.push(Y),X=F.indexOf(D,Y+1);else if(C.length===1){let J=C.pop();if(J!==void 0)Q=[J,Z]}else{if(B=C.pop(),B!==void 0&&B<$)$=B,E=Z;Z=F.indexOf(u,Y+1)}Y=X=0?X:Z}if(C.length&&E!==void 0)Q=[$,E]}return Q};var c6="\x00SLASH"+Math.random()+"\x00",l6="\x00OPEN"+Math.random()+"\x00",l2="\x00CLOSE"+Math.random()+"\x00",p6="\x00COMMA"+Math.random()+"\x00",a6="\x00PERIOD"+Math.random()+"\x00",Z4=new RegExp(c6,"g"),Y4=new RegExp(l6,"g"),J4=new RegExp(l2,"g"),K4=new RegExp(p6,"g"),q4=new RegExp(a6,"g"),V4=/\\\\/g,A4=/\\{/g,H4=/\\}/g,G4=/\\,/g,z4=/\\./g;function c2(D){return!isNaN(D)?parseInt(D,10):D.charCodeAt(0)}function _4(D){return D.replace(V4,c6).replace(A4,l6).replace(H4,l2).replace(G4,p6).replace(z4,a6)}function U4(D){return D.replace(Z4,"\\").replace(Y4,"{").replace(J4,"}").replace(K4,",").replace(q4,".")}function n6(D){if(!D)return[""];let u=[],F=d2("{","}",D);if(!F)return D.split(",");let{pre:C,body:B,post:$}=F,E=C.split(",");E[E.length-1]+="{"+B+"}";let Q=n6($);if($.length)E[E.length-1]+=Q.shift(),E.push.apply(E,Q);return u.push.apply(u,E),u}function r6(D){if(!D)return[];if(D.slice(0,2)==="{}")D="\\{\\}"+D.slice(2);return Bu(_4(D),!0).map(U4)}function W4(D){return"{"+D+"}"}function L4(D){return/^-?0\d/.test(D)}function R4(D,u){return D<=u}function M4(D,u){return D>=u}function Bu(D,u){let F=[],C=d2("{","}",D);if(!C)return[D];let B=C.pre,$=C.post.length?Bu(C.post,!1):[""];if(/\$$/.test(C.pre))for(let E=0;E<$.length;E++){let Q=B+"{"+C.body+"}"+$[E];F.push(Q)}else{let E=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(C.body),Q=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(C.body),X=E||Q,Z=C.body.indexOf(",")>=0;if(!X&&!Z){if(C.post.match(/,(?!,).*\}/))return D=C.pre+"{"+C.body+l2+C.post,Bu(D);return[D]}let Y;if(X)Y=C.body.split(/\.\./);else if(Y=n6(C.body),Y.length===1&&Y[0]!==void 0){if(Y=Bu(Y[0],!1).map(W4),Y.length===1)return $.map((A)=>C.pre+Y[0]+A)}let J;if(X&&Y[0]!==void 0&&Y[1]!==void 0){let A=c2(Y[0]),H=c2(Y[1]),G=Math.max(Y[0].length,Y[1].length),z=Y.length===3&&Y[2]!==void 0?Math.abs(c2(Y[2])):1,U=R4;if(H0){let x=new Array(P+1).join("0");if(R<0)M="-"+x+M.slice(1);else M=x+M}}J.push(M)}}else{J=[];for(let A=0;A{if(typeof D!=="string")throw new TypeError("invalid pattern");if(D.length>65536)throw new TypeError("pattern is too long")};var I4={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},$u=(D)=>D.replace(/[[\]\\-]/g,"\\$&"),N4=(D)=>D.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),i6=(D)=>D.join(""),o6=(D,u)=>{let F=u;if(D.charAt(F)!=="[")throw new Error("not in a brace expression");let C=[],B=[],$=F+1,E=!1,Q=!1,X=!1,Z=!1,Y=F,J="";D:while($J)C.push($u(J)+"-"+$u(z));else if(z===J)C.push($u(z));J="",$++;continue}if(D.startsWith("-]",$+1)){C.push($u(z+"-")),$+=2;continue}if(D.startsWith("-",$+1)){J=z,$+=2;continue}C.push($u(z)),$++}if(Y<$)return["",!1,0,!1];if(!C.length&&!B.length)return["$.",!1,D.length-F,!0];if(B.length===0&&C.length===1&&/^\\?.$/.test(C[0])&&!Z){let z=C[0].length===2?C[0].slice(-1):C[0];return[N4(z),!1,Y-F,!1]}let A="["+(Z?"^":"")+i6(C)+"]",H="["+(Z?"":"^")+i6(B)+"]";return[C.length&&B.length?"("+A+"|"+H+")":C.length?A:H,Q,Y-F,!0]};var rD=(D,{windowsPathsNoEscape:u=!1}={})=>{return u?D.replace(/\[([^\/\\])\]/g,"$1"):D.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1")};var O4=new Set(["!","?","+","*","@"]),s6=(D)=>O4.has(D),j4="(?!(?:^|/)\\.\\.?(?:$|/))",uF="(?!\\.)",T4=new Set(["[","."]),w4=new Set(["..","."]),k4=new Set("().*{}+?[]^$\\!"),P4=(D)=>D.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),p2="[^/]",t6=p2+"*?",e6=p2+"+?";class QD{type;#D;#u;#E=!1;#B=[];#$;#U;#z;#Y=!1;#Q;#K;#J=!1;constructor(D,u,F={}){if(this.type=D,D)this.#u=!0;if(this.#$=u,this.#D=this.#$?this.#$.#D:this,this.#Q=this.#D===this?F:this.#D.#Q,this.#z=this.#D===this?[]:this.#D.#z,D==="!"&&!this.#D.#Y)this.#z.push(this);this.#U=this.#$?this.#$.#B.length:0}get hasMagic(){if(this.#u!==void 0)return this.#u;for(let D of this.#B){if(typeof D==="string")continue;if(D.type||D.hasMagic)return this.#u=!0}return this.#u}toString(){if(this.#K!==void 0)return this.#K;if(!this.type)return this.#K=this.#B.map((D)=>String(D)).join("");else return this.#K=this.type+"("+this.#B.map((D)=>String(D)).join("|")+")"}#X(){if(this!==this.#D)throw new Error("should only call on root");if(this.#Y)return this;this.toString(),this.#Y=!0;let D;while(D=this.#z.pop()){if(D.type!=="!")continue;let u=D,F=u.#$;while(F){for(let C=u.#U+1;!F.type&&Ctypeof u==="string"?u:u.toJSON()):[this.type,...this.#B.map((u)=>u.toJSON())];if(this.isStart()&&!this.type)D.unshift([]);if(this.isEnd()&&(this===this.#D||this.#D.#Y&&this.#$?.type==="!"))D.push({});return D}isStart(){if(this.#D===this)return!0;if(!this.#$?.isStart())return!1;if(this.#U===0)return!0;let D=this.#$;for(let u=0;u{let[H,G,z,U]=typeof A==="string"?QD.#W(A,this.#u,Q):A.toRegExpSource(D);return this.#u=this.#u||z,this.#E=this.#E||U,H}).join(""),Z="";if(this.isStart()){if(typeof this.#B[0]==="string"){if(!(this.#B.length===1&&w4.has(this.#B[0]))){let H=T4,G=u&&H.has(X.charAt(0))||X.startsWith("\\.")&&H.has(X.charAt(2))||X.startsWith("\\.\\.")&&H.has(X.charAt(4)),z=!u&&!D&&H.has(X.charAt(0));Z=G?j4:z?uF:""}}}let Y="";if(this.isEnd()&&this.#D.#Y&&this.#$?.type==="!")Y="(?:$|\\/)";return[Z+X+Y,rD(X),this.#u=!!this.#u,this.#E]}let F=this.type==="*"||this.type==="+",C=this.type==="!"?"(?:(?!(?:":"(?:",B=this.#V(u);if(this.isStart()&&this.isEnd()&&!B&&this.type!=="!"){let Q=this.toString();return this.#B=[Q],this.type=null,this.#u=void 0,[Q,rD(this.toString()),!1,!1]}let $=!F||D||u||!uF?"":this.#V(!0);if($===B)$="";if($)B=`(?:${B})(?:${$})*?`;let E="";if(this.type==="!"&&this.#J)E=(this.isStart()&&!u?uF:"")+e6;else{let Q=this.type==="!"?"))"+(this.isStart()&&!u&&!D?uF:"")+t6+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&$?")":this.type==="*"&&$?")?":`)${this.type}`;E=C+B+Q}return[E,rD(B),this.#u=!!this.#u,this.#E]}#V(D){return this.#B.map((u)=>{if(typeof u==="string")throw new Error("string type in extglob ast??");let[F,C,B,$]=u.toRegExpSource(D);return this.#E=this.#E||$,F}).filter((u)=>!(this.isStart()&&this.isEnd())||!!u).join("|")}static#W(D,u,F=!1){let C=!1,B="",$=!1;for(let E=0;E{return u?D.replace(/[?*()[\]]/g,"[$&]"):D.replace(/[?*()[\]\\]/g,"\\$&")};var UD=(D,u,F={})=>{if(Eu(u),!F.nocomment&&u.charAt(0)==="#")return!1;return new fD(u,F).match(D)},S4=/^\*+([^+@!?\*\[\(]*)$/,x4=(D)=>(u)=>!u.startsWith(".")&&u.endsWith(D),b4=(D)=>(u)=>u.endsWith(D),v4=(D)=>{return D=D.toLowerCase(),(u)=>!u.startsWith(".")&&u.toLowerCase().endsWith(D)},f4=(D)=>{return D=D.toLowerCase(),(u)=>u.toLowerCase().endsWith(D)},y4=/^\*+\.\*+$/,h4=(D)=>!D.startsWith(".")&&D.includes("."),g4=(D)=>D!=="."&&D!==".."&&D.includes("."),m4=/^\.\*+$/,d4=(D)=>D!=="."&&D!==".."&&D.startsWith("."),c4=/^\*+$/,l4=(D)=>D.length!==0&&!D.startsWith("."),p4=(D)=>D.length!==0&&D!=="."&&D!=="..",a4=/^\?+([^+@!?\*\[\(]*)?$/,n4=([D,u=""])=>{let F=F1([D]);if(!u)return F;return u=u.toLowerCase(),(C)=>F(C)&&C.toLowerCase().endsWith(u)},r4=([D,u=""])=>{let F=C1([D]);if(!u)return F;return u=u.toLowerCase(),(C)=>F(C)&&C.toLowerCase().endsWith(u)},i4=([D,u=""])=>{let F=C1([D]);return!u?F:(C)=>F(C)&&C.endsWith(u)},o4=([D,u=""])=>{let F=F1([D]);return!u?F:(C)=>F(C)&&C.endsWith(u)},F1=([D])=>{let u=D.length;return(F)=>F.length===u&&!F.startsWith(".")},C1=([D])=>{let u=D.length;return(F)=>F.length===u&&F!=="."&&F!==".."},B1=typeof process==="object"&&process?typeof process.env==="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",D1={win32:{sep:"\\"},posix:{sep:"/"}},s4=B1==="win32"?D1.win32.sep:D1.posix.sep;UD.sep=s4;var XD=Symbol("globstar **");UD.GLOBSTAR=XD;var t4="[^/]",e4=t4+"*?",DE="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",uE="(?:(?!(?:\\/|^)\\.).)*?",FE=(D,u={})=>(F)=>UD(F,D,u);UD.filter=FE;var vD=(D,u={})=>Object.assign({},D,u),CE=(D)=>{if(!D||typeof D!=="object"||!Object.keys(D).length)return UD;let u=UD;return Object.assign((C,B,$={})=>u(C,B,vD(D,$)),{Minimatch:class C extends u.Minimatch{constructor(B,$={}){super(B,vD(D,$))}static defaults(B){return u.defaults(vD(D,B)).Minimatch}},AST:class C extends u.AST{constructor(B,$,E={}){super(B,$,vD(D,E))}static fromGlob(B,$={}){return u.AST.fromGlob(B,vD(D,$))}},unescape:(C,B={})=>u.unescape(C,vD(D,B)),escape:(C,B={})=>u.escape(C,vD(D,B)),filter:(C,B={})=>u.filter(C,vD(D,B)),defaults:(C)=>u.defaults(vD(D,C)),makeRe:(C,B={})=>u.makeRe(C,vD(D,B)),braceExpand:(C,B={})=>u.braceExpand(C,vD(D,B)),match:(C,B,$={})=>u.match(C,B,vD(D,$)),sep:u.sep,GLOBSTAR:XD})};UD.defaults=CE;var E1=(D,u={})=>{if(Eu(D),u.nobrace||!/\{(?:(?!\{).)*\}/.test(D))return[D];return r6(D)};UD.braceExpand=E1;var BE=(D,u={})=>new fD(D,u).makeRe();UD.makeRe=BE;var EE=(D,u,F={})=>{let C=new fD(u,F);if(D=D.filter((B)=>C.match(B)),C.options.nonull&&!D.length)D.push(u);return D};UD.match=EE;var u1=/[?*]|[+@!]\(.*?\)|\[|\]/,$E=(D)=>D.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");class fD{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(D,u={}){if(Eu(D),u=u||{},this.options=u,this.pattern=D,this.platform=u.platform||B1,this.isWindows=this.platform==="win32",this.windowsPathsNoEscape=!!u.windowsPathsNoEscape||u.allowWindowsEscape===!1,this.windowsPathsNoEscape)this.pattern=this.pattern.replace(/\\/g,"/");this.preserveMultipleSlashes=!!u.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!u.nonegate,this.comment=!1,this.empty=!1,this.partial=!!u.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=u.windowsNoMagicRoot!==void 0?u.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let D of this.set)for(let u of D)if(typeof u!=="string")return!0;return!1}debug(...D){}make(){let D=this.pattern,u=this.options;if(!u.nocomment&&D.charAt(0)==="#"){this.comment=!0;return}if(!D){this.empty=!0;return}if(this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],u.debug)this.debug=(...B)=>console.error(...B);this.debug(this.pattern,this.globSet);let F=this.globSet.map((B)=>this.slashSplit(B));this.globParts=this.preprocess(F),this.debug(this.pattern,this.globParts);let C=this.globParts.map((B,$,E)=>{if(this.isWindows&&this.windowsNoMagicRoot){let Q=B[0]===""&&B[1]===""&&(B[2]==="?"||!u1.test(B[2]))&&!u1.test(B[3]),X=/^[a-z]:/i.test(B[0]);if(Q)return[...B.slice(0,4),...B.slice(4).map((Z)=>this.parse(Z))];else if(X)return[B[0],...B.slice(1).map((Z)=>this.parse(Z))]}return B.map((Q)=>this.parse(Q))});if(this.debug(this.pattern,C),this.set=C.filter((B)=>B.indexOf(!1)===-1),this.isWindows)for(let B=0;B=2)D=this.firstPhasePreProcess(D),D=this.secondPhasePreProcess(D);else if(u>=1)D=this.levelOneOptimize(D);else D=this.adjascentGlobstarOptimize(D);return D}adjascentGlobstarOptimize(D){return D.map((u)=>{let F=-1;while((F=u.indexOf("**",F+1))!==-1){let C=F;while(u[C+1]==="**")C++;if(C!==F)u.splice(F,C-F)}return u})}levelOneOptimize(D){return D.map((u)=>{return u=u.reduce((F,C)=>{let B=F[F.length-1];if(C==="**"&&B==="**")return F;if(C===".."){if(B&&B!==".."&&B!=="."&&B!=="**")return F.pop(),F}return F.push(C),F},[]),u.length===0?[""]:u})}levelTwoFileOptimize(D){if(!Array.isArray(D))D=this.slashSplit(D);let u=!1;do{if(u=!1,!this.preserveMultipleSlashes){for(let C=1;CC)F.splice(C+1,$-C);let E=F[C+1],Q=F[C+2],X=F[C+3];if(E!=="..")continue;if(!Q||Q==="."||Q===".."||!X||X==="."||X==="..")continue;u=!0,F.splice(C,1);let Z=F.slice(0);Z[C]="**",D.push(Z),C--}if(!this.preserveMultipleSlashes){for(let $=1;$u.length)}partsMatch(D,u,F=!1){let C=0,B=0,$=[],E="";while(Cj)u=u.slice(R);else if(j>R)D=D.slice(j)}}}let{optimizationLevel:B=1}=this.options;if(B>=2)D=this.levelTwoFileOptimize(D);this.debug("matchOne",this,{file:D,pattern:u}),this.debug("matchOne",D.length,u.length);for(var $=0,E=0,Q=D.length,X=u.length;$({message:`No previous memories found for ${D}`,suggestion:"This appears to be your first session. Memories will be created as you work."}),CONNECTION_FAILED:()=>({message:"Could not connect to memory system",suggestion:"Try restarting Claude Code or check if the MCP server is properly configured."}),SEARCH_FAILED:(D)=>({message:`Search for "${D}" didn't return any results`,suggestion:"Try using different keywords or check if memories exist for this project."}),LOAD_TIMEOUT:()=>({message:"Memory loading timed out",suggestion:"The operation is taking longer than expected. You can continue without loaded context."})};function Du(D,...u){let F=pB[D](...u);return I2("Memory system",F.message,F.suggestion)}function M6(D){let u=typeof D==="string"?new Date(D):D,C=new Date().getTime()-u.getTime(),B=Math.floor(C/60000),$=Math.floor(C/3600000),E=Math.floor(C/86400000);if(B<1)return"just now";if(B<60)return`${B} minute${B>1?"s":""} ago`;if($<24)return`${$} hour${$>1?"s":""} ago`;if(E<7)return`${E} day${E>1?"s":""} ago`;return u.toLocaleDateString()}function aB(D){if(D.length===0)return[];return D.filter((u)=>u.type==="memory").map((u)=>{let F={summary:u.text||"",sessionId:u.session_id||""};if(u.keywords)F.keywords=u.keywords;if(u.document_id&&!u.document_id.includes("Session:"))F.location=u.document_id;return F}).filter((u)=>u.summary.length>0)}function nB(D){let u=new Map;return D.forEach((F)=>{let C=F.sessionId;if(C){if(!u.has(C))u.set(C,[]);u.get(C).push(F)}}),Array.from(u.entries()).map(([F,C])=>{let B=C.map(($,E)=>({...$,number:E+1}));return{sessionId:F,memories:B}})}function rB(D){let u=new Map;return D.forEach((F)=>{let C=F.sessionId||"unknown";if(!u.has(C))u.set(C,[]);u.get(C).push(F)}),Array.from(u.entries()).map(([F,C])=>{let B=C.map((E)=>E.timestamp).filter((E)=>E!==void 0).sort((E,Q)=>E.getTime()-Q.getTime()),$={sessionId:F,overviews:C};if(B.length>0)$.earliestTimestamp=B[0],$.timeAgo=R6(B[0]);return $})}function I6(D){let{projectName:u,memoryCount:F,lastSessionTime:C,recentObjects:B}=D,$=ou(),Q=new Date().toLocaleString("en-US",{weekday:"long",year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit",timeZoneName:"short"});console.log(""),console.log(bD(`\uD83D\uDCC5 ${Q}`,$)),console.log(iu("\u2500",$));let X=extractOverviews(B,10,u);console.error(`[DEBUG] recentObjects has ${B.length} items`),console.error(`[DEBUG] overviews extracted: ${X.length}`);let Z=aB(B),Y=(J,A)=>{let H=J.includes(",")||J.includes(` +`)?J.split(/[\n,]+/):[J];for(let G of H){let z=G.trim();if(!z)continue;let U=z.toLowerCase();if(!A.has(U))A.set(U,z)}};if(Z.length>0){let J=nB(Z);console.log(""),console.log(""),console.log(bD("\uD83D\uDCDA Memories",$)),J.forEach((A)=>{console.log(iu("\u2500",$)),console.log(""),console.log(bD(`\uD83D\uDD0D ${A.sessionId}`,$));let H=new Map;A.memories.forEach((z)=>{if(console.log(""),console.log(bD(`${z.number}. ${z.summary}`,$)),z.keywords)Y(z.keywords,H)});let G=Array.from(H.values());if(G.length>0)console.log(""),console.log(bD(`\uD83C\uDFF7\uFE0F ${G.join(", ")}`,$));console.log("")})}if(X.length>0){let J=rB(X);J.sort((A,H)=>{let G=A.earliestTimestamp?.getTime()||0,z=H.earliestTimestamp?.getTime()||0;return G-z}),console.log(""),console.log(bD("\uD83E\uDDE0 Overviews",$)),console.log(iu("\u2500",$)),J.forEach((A)=>{console.log(""),console.log(bD(`\uD83D\uDD0D ${A.sessionId}`,$)),A.overviews.forEach((H,G)=>{if(console.log(""),console.log(bD(`${G+1}. ${H.content}`,$)),console.log(""),H.timeAgo)console.log(bD(`\uD83D\uDCC5 ${H.timeAgo}`,$))}),console.log(""),console.log(iu("\u2500",$))})}else if(Z.length===0)console.log(bD(`\uD83E\uDDE0 No recent context found for ${u}`,$))}qD();import z0 from"fs";aD();ru();O2();T2();k2();S2();su();j0();tu();async function nD(){let{DatabaseManager:D}=await Promise.resolve().then(() => (aD(),z6)),{migrations:u}=await Promise.resolve().then(() => (tu(),b6)),F=D.getInstance();for(let Y of u)F.registerMigration(Y);let C=await F.initialize(),{SessionStore:B}=await Promise.resolve().then(() => (ru(),_6)),{MemoryStore:$}=await Promise.resolve().then(() => (O2(),N6)),{OverviewStore:E}=await Promise.resolve().then(() => (T2(),O6)),{DiagnosticsStore:Q}=await Promise.resolve().then(() => (k2(),j6)),{TranscriptEventStore:X}=await Promise.resolve().then(() => (S2(),T6)),{StreamingSessionStore:Z}=await Promise.resolve().then(() => (su(),w6));return{sessions:new B(C),memories:new $(C),overviews:new E(C),diagnostics:new Q(C),transcriptEvents:new X(C),streamingSessions:new Z(C)}}class x2{backend="sqlite";stores;async getStores(){if(!this.stores)this.stores=await nD();return this.stores}async isAvailable(){try{return await this.getStores(),!0}catch(D){return!1}}async createSession(D){return(await this.getStores()).sessions.create(D)}async getSession(D){return(await this.getStores()).sessions.getBySessionId(D)}async hasSession(D){return(await this.getStores()).sessions.has(D)}async getAllSessionIds(){return(await this.getStores()).sessions.getAllSessionIds()}async getRecentSessions(D=5){return(await this.getStores()).sessions.getRecent(D)}async getRecentSessionsForProject(D,u=5){return(await this.getStores()).sessions.getRecentForProject(D,u)}async createMemory(D){return(await this.getStores()).memories.create(D)}async createMemories(D){(await this.getStores()).memories.createMany(D)}async getRecentMemories(D=10){return(await this.getStores()).memories.getRecent(D)}async getRecentMemoriesForProject(D,u=10){return(await this.getStores()).memories.getRecentForProject(D,u)}async hasDocumentId(D){return(await this.getStores()).memories.hasDocumentId(D)}async createOverview(D){return(await this.getStores()).overviews.create(D)}async upsertOverview(D){return(await this.getStores()).overviews.upsert(D)}async getRecentOverviews(D=5){return(await this.getStores()).overviews.getRecent(D)}async getRecentOverviewsForProject(D,u=5){return(await this.getStores()).overviews.getRecentForProject(D,u)}async createDiagnostic(D){return(await this.getStores()).diagnostics.create(D)}}class v6{backend="jsonl";pathDiscovery=k.getInstance();async isAvailable(){try{let D=this.pathDiscovery.getDataDirectory();return z0.mkdirSync(D,{recursive:!0}),!0}catch{return!1}}appendToIndex(D){let u=this.pathDiscovery.getIndexPath();z0.appendFileSync(u,JSON.stringify(D)+"\\n","utf8")}async createSession(D){let u={type:"session",session_id:D.session_id,project:D.project,timestamp:D.created_at};this.appendToIndex(u)}async getSession(){return null}async hasSession(D){return(await this.getAllSessionIds()).has(D)}async getAllSessionIds(){let D=this.pathDiscovery.getIndexPath();if(!z0.existsSync(D))return new Set;let F=z0.readFileSync(D,"utf-8").trim().split("\\n").filter((B)=>B.trim()),C=new Set;for(let B of F)try{let $=JSON.parse(B);if($.session_id)C.add($.session_id)}catch{}return C}async getRecentSessions(){return[]}async getRecentSessionsForProject(){return[]}async createMemory(D){let u={type:"memory",text:D.text,document_id:D.document_id,keywords:D.keywords,session_id:D.session_id,project:D.project,timestamp:D.created_at,archive:D.archive_basename};this.appendToIndex(u)}async createMemories(D){for(let u of D)await this.createMemory(u)}async getRecentMemories(){return[]}async getRecentMemoriesForProject(){return[]}async hasDocumentId(D){let u=this.pathDiscovery.getIndexPath();if(!z0.existsSync(u))return!1;let C=z0.readFileSync(u,"utf-8").trim().split("\\n").filter((B)=>B.trim());for(let B of C)try{let $=JSON.parse(B);if($.type==="memory"&&$.document_id===D)return!0}catch{}return!1}async createOverview(D){let u={type:"overview",content:D.content,session_id:D.session_id,project:D.project,timestamp:D.created_at};this.appendToIndex(u)}async upsertOverview(D){await this.createOverview(D)}async getRecentOverviews(){return[]}async getRecentOverviewsForProject(){return[]}async createDiagnostic(D){let u={type:"diagnostic",message:D.message,session_id:D.session_id,project:D.project,timestamp:D.created_at};this.appendToIndex(u)}}var T0=null;async function f6(){if(T0)return T0;let D=new x2;if(await D.isAvailable())return T0=D,T0;let u=new v6;if(await u.isAvailable())return T0=u,T0;throw new Error("No storage backend available")}async function y6(){let u=k.getInstance().getIndexPath();if(z0.existsSync(u)){if(!await new x2().isAvailable())return!0;try{return(await nD()).sessions.count()===0}catch{return!0}}return!1}import{readFileSync as tB,existsSync as eB}from"fs";import{join as D4}from"path";qD();class b2{pathDiscovery;constructor(){this.pathDiscovery=k.getInstance()}getConfigDir(){return this.pathDiscovery.getDataDirectory()}getIndexDir(){return this.pathDiscovery.getIndexDirectory()}getIndexPath(){return this.pathDiscovery.getIndexPath()}getArchiveDir(){return this.pathDiscovery.getArchivesDirectory()}getProjectArchiveDir(D){return this.pathDiscovery.getProjectArchiveDirectory(D)}getLogsDir(){return this.pathDiscovery.getLogsDirectory()}static ensureDirectory(D){k.getInstance().ensureDirectory(D)}static ensureDirectories(D){k.getInstance().ensureDirectories(D)}static extractProjectName(D){return k.extractProjectName(D)}static getCurrentProjectPrefix(){return k.getCurrentProjectName()}static getCurrentProjectName(){return k.getCurrentProjectName()}}class v2{static settingsPath;static cachedSettings=null;static{let D=new b2;this.settingsPath=D4(D.getConfigDir(),"settings.json")}static readSettings(){if(this.cachedSettings!==null)return this.cachedSettings;try{if(eB(this.settingsPath)){let u=tB(this.settingsPath,"utf-8"),F=JSON.parse(u);return this.cachedSettings=F,F}}catch{}let D={};return this.cachedSettings=D,D}static getSetting(D,u){return this.readSettings()[D]??u}static getClaudePath(){return this.getSetting("claudePath","claude")}static clearCache(){this.cachedSettings=null}}function Fu(){return v2.getClaudePath()}function h6(){return v2.readSettings()}var w0={captureEnabled:!0,summaryEnabled:!0,sessionStartEnabled:!0,chunkTokenLimit:600,chunkOverlapTokens:200,summaryTurnLimit:20};function f2(D,u){if(typeof D==="boolean")return D;if(typeof D==="string"){let F=D.toLowerCase();if(F==="true")return!0;if(F==="false")return!1}return u}function y2(D,u){if(typeof D==="number"&&Number.isFinite(D))return D;if(typeof D==="string"){let F=Number(D);if(!Number.isNaN(F)&&Number.isFinite(F))return F}return u}function g6(){let D=h6();return{captureEnabled:f2(D.rollingCaptureEnabled,w0.captureEnabled),summaryEnabled:f2(D.rollingSummaryEnabled,w0.summaryEnabled),sessionStartEnabled:f2(D.rollingSessionStartEnabled,w0.sessionStartEnabled),chunkTokenLimit:y2(D.rollingChunkTokens,w0.chunkTokenLimit),chunkOverlapTokens:y2(D.rollingChunkOverlapTokens,w0.chunkOverlapTokens),summaryTurnLimit:y2(D.rollingSummaryTurnLimit,w0.summaryTurnLimit)}}qD();import{appendFileSync as u4,existsSync as F4,mkdirSync as C4}from"fs";import{join as B4}from"path";var eu=null;function E4(){if(eu)return eu;let u=k.getInstance().getLogsDirectory();if(!F4(u))C4(u,{recursive:!0});return eu=B4(u,"rolling-memory.log"),eu}function DF(D,u,F={}){try{let C=E4(),B={timestamp:new Date().toISOString(),level:D,message:u,...F};u4(C,`${JSON.stringify(B)} +`,"utf8")}catch{}}function m6(D=new Date){return D.toLocaleString("en-US",{weekday:"long",month:"long",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit",timeZoneName:"short"})}function h2(D,u,F){let C=D.split(" "),B=[],$=F,E=" ".repeat(F.length);for(let Q of C){let Z=$+($!==F&&$!==E?" ":"")+Q;if(Z.length<=u)$=Z;else{if($.trim())B.push($);$=E+Q}}if($.trim())B.push($);return B.join(` +`)}function Q4(D){let u=new Set;return u.add(D),u.add(D.replace(/-/g,"_")),u.add(D.replace(/_/g,"-")),(F)=>!!F&&u.has(F)}function g2(D){if(D===0)return"0 B";let u=1024,F=["B","KB","MB","GB"],C=Math.floor(Math.log(D)/Math.log(u));return parseFloat((D/Math.pow(u,C)).toFixed(1))+" "+F[C]}function m2(){let D=k.getInstance().getTrashDirectory();if(!Cu.existsSync(D))return{folderCount:0,fileCount:0,totalSize:0,isEmpty:!0};let u=Cu.readdirSync(D);if(u.length===0)return{folderCount:0,fileCount:0,totalSize:0,isEmpty:!0};let F=0,C=0,B=0;for(let $ of u){let E=$4(D,$),Q=Cu.statSync(E);if(Q.isDirectory())F++;else C++;B+=Q.size}return{folderCount:F,fileCount:C,totalSize:B,isEmpty:!1}}async function X4(D){if(!g6().sessionStartEnabled){console.log("Rolling session-start output disabled in settings."),DF("info","session-start output skipped (disabled)",{project:D});return}let F=await nD(),C=D||k.getCurrentProjectName(),$=F.overviews.getAllForProject(C).slice(-10);if($.length===0){console.log("==============================================================================="),console.log(`What's new | ${m6()}`),console.log("==============================================================================="),console.log("No previous sessions found for this project."),console.log("Start working and claude-mem will automatically capture context for future sessions."),console.log("===============================================================================");let Q=m2();if(!Q.isEmpty){let X=g2(Q.totalSize);console.log(`\uD83D\uDDD1\uFE0F Trash \u2013 ${Q.folderCount} folders | ${Q.fileCount} files | ${X} \u2013 use \`claude-mem restore\``),console.log("===============================================================================")}return}console.log("==============================================================================="),console.log(`What's new | ${m6()}`),console.log("==============================================================================="),$.forEach((Q)=>{let X=new Date(Q.created_at),Z=X.getFullYear(),Y=String(X.getMonth()+1).padStart(2,"0"),J=String(X.getDate()).padStart(2,"0"),A=X.getHours(),H=String(X.getMinutes()).padStart(2,"0"),G=A>=12?"PM":"AM",z=A%12||12;console.log(`[${Z}-${Y}-${J} at ${z}:${H} ${G}]`);let U=F.memories.getBySessionId(Q.session_id),I=U.map((M)=>({title:M.title,subtitle:M.subtitle})).filter((M)=>M.title),j=new Set,R=new Set;if(U.forEach((M)=>{if(M.files_touched)try{let P=JSON.parse(M.files_touched);if(Array.isArray(P))P.forEach((x)=>j.add(x))}catch(P){}if(M.keywords)M.keywords.split(",").forEach((P)=>R.add(P.trim()))}),console.log(""),console.log(h2(Q.content,80,"")),j.size>0)console.log(""),console.log(h2(`- ${Array.from(j).join(", ")}`,80,""));if(R.size>0)console.log(""),console.log(h2(`Tags: ${Array.from(R).join(", ")}`,80,""));console.log("")}),console.log("===============================================================================");let E=m2();if(!E.isEmpty){let Q=g2(E.totalSize);console.log(`\uD83D\uDDD1\uFE0F Trash \u2013 ${E.folderCount} folders | ${E.fileCount} files | ${Q} \u2013 use \`claude-mem restore\``),console.log("===============================================================================")}}async function d6(D={}){try{if(await y6())console.warn("\u26A0\uFE0F JSONL to SQLite migration recommended. Run: claude-mem migrate-index");let u=await f6();if(u.backend==="jsonl")return await Z4(D);let F=[],C=[],B=D.project;if(!B&&D.format==="session-start")B=k.getCurrentProjectName();if(D.format==="session-start"){await X4(B);return}let $=D.format==="json"?5:3;if(B)F=await u.getRecentMemoriesForProject(B,10),C=await u.getRecentOverviewsForProject(B,$);else F=await u.getRecentMemories(10),C=await u.getRecentOverviews($);let E=F.map((X)=>({type:"memory",text:X.text,document_id:X.document_id,keywords:X.keywords,session_id:X.session_id,project:X.project,timestamp:X.created_at,archive:X.archive_basename})),Q=C.map((X)=>({type:"overview",content:X.content,session_id:X.session_id,project:X.project,timestamp:X.created_at}));if(E.length===0&&Q.length===0)return;if(D.format==="json"){let X=[...E,...Q];console.log(JSON.stringify(X))}else{let X=E.length+Q.length;console.log(M2("Context loading",X,"recent entries found")),E.forEach((Z)=>{console.log(`${Z.text} | ${Z.document_id} | ${Z.keywords}`)}),Q.forEach((Z)=>{console.log(`**Overview:** ${Z.content}`)})}if(D.format!=="json"){let X=m2();if(!X.isEmpty){let Z=g2(X.totalSize);console.log(`\uD83D\uDDD1\uFE0F Trash \u2013 ${X.folderCount} folders | ${X.fileCount} files | ${Z} \u2013 use \`claude-mem restore\``),console.log("")}}}catch(u){let F=u instanceof Error?u.message:String(u);if(D.format==="session-start")console.log(Du("CONNECTION_FAILED",F));else console.log(I2("Context loading",F,"Check file permissions and try again"))}}async function Z4(D={}){let F=k.getInstance().getIndexPath(),C=D.project;if(!C&&D.format==="session-start")C=k.getCurrentProjectName();if(!Cu.existsSync(F)){if(D.format==="session-start")console.log(Du("NO_MEMORIES",C||"this project"));return}let $=Cu.readFileSync(F,"utf-8").trim().split(` +`).filter((H)=>H.trim());if($.length===0){if(D.format==="session-start")console.log(Du("NO_MEMORIES",C||"this project"));return}let E=[];for(let H of $)try{if(!H.trim().startsWith("{"))continue;let G=JSON.parse(H);E.push(G)}catch(G){continue}if(E.length===0){if(D.format==="session-start")console.log(Du("NO_MEMORIES",C||"this project"));return}let Q=E.filter((H)=>H.type==="memory"),X=E.filter((H)=>H.type==="overview"),Z=E.filter((H)=>H.type==="session"),Y=Q,J=X,A=Z;if(C){let H=Q4(C);Y=Q.filter((G)=>H(G.project)),J=X.filter((G)=>H(G.project)),A=Z.filter((G)=>H(G.project))}if(D.format==="session-start"){let H=Y.slice(-10),G=J.slice(-10),U=[...A.slice(-10),...H,...G],I="recently",j=U.map((R)=>{return R.timestamp?new Date(R.timestamp):null}).filter((R)=>R!==null).sort((R,M)=>M.getTime()-R.getTime());if(j.length>0)I=M6(j[0]);I6({projectName:C||"your project",memoryCount:H.length,lastSessionTime:I,recentObjects:U})}else if(D.format==="json"){let H=Y.slice(-10),G=J.slice(-3),z=[...H,...G];console.log(JSON.stringify(z))}else{let H=Y.slice(-10),G=J.slice(-3),z=H.length+G.length;console.log(M2("Context loading",z,"recent entries found")),H.forEach((U)=>{console.log(`${U.text} | ${U.document_id} | ${U.keywords}`)}),G.forEach((U)=>{console.log(`**Overview:** ${U.content}`)})}}import{renameSync as rE,existsSync as f1,mkdirSync as iE,statSync as oE}from"fs";import{join as sE,basename as tE}from"path";var d2=(D,u,F)=>{let C=D instanceof RegExp?c6(D,F):D,B=u instanceof RegExp?c6(u,F):u,$=C!==null&&B!=null&&Y4(C,B,F);return $&&{start:$[0],end:$[1],pre:F.slice(0,$[0]),body:F.slice($[0]+C.length,$[1]),post:F.slice($[1]+B.length)}},c6=(D,u)=>{let F=u.match(D);return F?F[0]:null},Y4=(D,u,F)=>{let C,B,$,E=void 0,Q,X=F.indexOf(D),Z=F.indexOf(u,X+1),Y=X;if(X>=0&&Z>0){if(D===u)return[X,Z];C=[],$=F.length;while(Y>=0&&!Q){if(Y===X)C.push(Y),X=F.indexOf(D,Y+1);else if(C.length===1){let J=C.pop();if(J!==void 0)Q=[J,Z]}else{if(B=C.pop(),B!==void 0&&B<$)$=B,E=Z;Z=F.indexOf(u,Y+1)}Y=X=0?X:Z}if(C.length&&E!==void 0)Q=[$,E]}return Q};var l6="\x00SLASH"+Math.random()+"\x00",p6="\x00OPEN"+Math.random()+"\x00",l2="\x00CLOSE"+Math.random()+"\x00",a6="\x00COMMA"+Math.random()+"\x00",n6="\x00PERIOD"+Math.random()+"\x00",J4=new RegExp(l6,"g"),K4=new RegExp(p6,"g"),q4=new RegExp(l2,"g"),V4=new RegExp(a6,"g"),A4=new RegExp(n6,"g"),H4=/\\\\/g,G4=/\\{/g,z4=/\\}/g,_4=/\\,/g,U4=/\\./g;function c2(D){return!isNaN(D)?parseInt(D,10):D.charCodeAt(0)}function W4(D){return D.replace(H4,l6).replace(G4,p6).replace(z4,l2).replace(_4,a6).replace(U4,n6)}function L4(D){return D.replace(J4,"\\").replace(K4,"{").replace(q4,"}").replace(V4,",").replace(A4,".")}function r6(D){if(!D)return[""];let u=[],F=d2("{","}",D);if(!F)return D.split(",");let{pre:C,body:B,post:$}=F,E=C.split(",");E[E.length-1]+="{"+B+"}";let Q=r6($);if($.length)E[E.length-1]+=Q.shift(),E.push.apply(E,Q);return u.push.apply(u,E),u}function i6(D){if(!D)return[];if(D.slice(0,2)==="{}")D="\\{\\}"+D.slice(2);return Bu(W4(D),!0).map(L4)}function R4(D){return"{"+D+"}"}function M4(D){return/^-?0\d/.test(D)}function I4(D,u){return D<=u}function N4(D,u){return D>=u}function Bu(D,u){let F=[],C=d2("{","}",D);if(!C)return[D];let B=C.pre,$=C.post.length?Bu(C.post,!1):[""];if(/\$$/.test(C.pre))for(let E=0;E<$.length;E++){let Q=B+"{"+C.body+"}"+$[E];F.push(Q)}else{let E=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(C.body),Q=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(C.body),X=E||Q,Z=C.body.indexOf(",")>=0;if(!X&&!Z){if(C.post.match(/,(?!,).*\}/))return D=C.pre+"{"+C.body+l2+C.post,Bu(D);return[D]}let Y;if(X)Y=C.body.split(/\.\./);else if(Y=r6(C.body),Y.length===1&&Y[0]!==void 0){if(Y=Bu(Y[0],!1).map(R4),Y.length===1)return $.map((A)=>C.pre+Y[0]+A)}let J;if(X&&Y[0]!==void 0&&Y[1]!==void 0){let A=c2(Y[0]),H=c2(Y[1]),G=Math.max(Y[0].length,Y[1].length),z=Y.length===3&&Y[2]!==void 0?Math.abs(c2(Y[2])):1,U=I4;if(H0){let x=new Array(P+1).join("0");if(R<0)M="-"+x+M.slice(1);else M=x+M}}J.push(M)}}else{J=[];for(let A=0;A{if(typeof D!=="string")throw new TypeError("invalid pattern");if(D.length>65536)throw new TypeError("pattern is too long")};var O4={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},$u=(D)=>D.replace(/[[\]\\-]/g,"\\$&"),j4=(D)=>D.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),o6=(D)=>D.join(""),s6=(D,u)=>{let F=u;if(D.charAt(F)!=="[")throw new Error("not in a brace expression");let C=[],B=[],$=F+1,E=!1,Q=!1,X=!1,Z=!1,Y=F,J="";D:while($J)C.push($u(J)+"-"+$u(z));else if(z===J)C.push($u(z));J="",$++;continue}if(D.startsWith("-]",$+1)){C.push($u(z+"-")),$+=2;continue}if(D.startsWith("-",$+1)){J=z,$+=2;continue}C.push($u(z)),$++}if(Y<$)return["",!1,0,!1];if(!C.length&&!B.length)return["$.",!1,D.length-F,!0];if(B.length===0&&C.length===1&&/^\\?.$/.test(C[0])&&!Z){let z=C[0].length===2?C[0].slice(-1):C[0];return[j4(z),!1,Y-F,!1]}let A="["+(Z?"^":"")+o6(C)+"]",H="["+(Z?"":"^")+o6(B)+"]";return[C.length&&B.length?"("+A+"|"+H+")":C.length?A:H,Q,Y-F,!0]};var rD=(D,{windowsPathsNoEscape:u=!1}={})=>{return u?D.replace(/\[([^\/\\])\]/g,"$1"):D.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1")};var T4=new Set(["!","?","+","*","@"]),t6=(D)=>T4.has(D),w4="(?!(?:^|/)\\.\\.?(?:$|/))",uF="(?!\\.)",k4=new Set(["[","."]),P4=new Set(["..","."]),S4=new Set("().*{}+?[]^$\\!"),x4=(D)=>D.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),p2="[^/]",e6=p2+"*?",D1=p2+"+?";class QD{type;#D;#u;#E=!1;#B=[];#$;#U;#z;#Y=!1;#Q;#K;#J=!1;constructor(D,u,F={}){if(this.type=D,D)this.#u=!0;if(this.#$=u,this.#D=this.#$?this.#$.#D:this,this.#Q=this.#D===this?F:this.#D.#Q,this.#z=this.#D===this?[]:this.#D.#z,D==="!"&&!this.#D.#Y)this.#z.push(this);this.#U=this.#$?this.#$.#B.length:0}get hasMagic(){if(this.#u!==void 0)return this.#u;for(let D of this.#B){if(typeof D==="string")continue;if(D.type||D.hasMagic)return this.#u=!0}return this.#u}toString(){if(this.#K!==void 0)return this.#K;if(!this.type)return this.#K=this.#B.map((D)=>String(D)).join("");else return this.#K=this.type+"("+this.#B.map((D)=>String(D)).join("|")+")"}#X(){if(this!==this.#D)throw new Error("should only call on root");if(this.#Y)return this;this.toString(),this.#Y=!0;let D;while(D=this.#z.pop()){if(D.type!=="!")continue;let u=D,F=u.#$;while(F){for(let C=u.#U+1;!F.type&&Ctypeof u==="string"?u:u.toJSON()):[this.type,...this.#B.map((u)=>u.toJSON())];if(this.isStart()&&!this.type)D.unshift([]);if(this.isEnd()&&(this===this.#D||this.#D.#Y&&this.#$?.type==="!"))D.push({});return D}isStart(){if(this.#D===this)return!0;if(!this.#$?.isStart())return!1;if(this.#U===0)return!0;let D=this.#$;for(let u=0;u{let[H,G,z,U]=typeof A==="string"?QD.#W(A,this.#u,Q):A.toRegExpSource(D);return this.#u=this.#u||z,this.#E=this.#E||U,H}).join(""),Z="";if(this.isStart()){if(typeof this.#B[0]==="string"){if(!(this.#B.length===1&&P4.has(this.#B[0]))){let H=k4,G=u&&H.has(X.charAt(0))||X.startsWith("\\.")&&H.has(X.charAt(2))||X.startsWith("\\.\\.")&&H.has(X.charAt(4)),z=!u&&!D&&H.has(X.charAt(0));Z=G?w4:z?uF:""}}}let Y="";if(this.isEnd()&&this.#D.#Y&&this.#$?.type==="!")Y="(?:$|\\/)";return[Z+X+Y,rD(X),this.#u=!!this.#u,this.#E]}let F=this.type==="*"||this.type==="+",C=this.type==="!"?"(?:(?!(?:":"(?:",B=this.#V(u);if(this.isStart()&&this.isEnd()&&!B&&this.type!=="!"){let Q=this.toString();return this.#B=[Q],this.type=null,this.#u=void 0,[Q,rD(this.toString()),!1,!1]}let $=!F||D||u||!uF?"":this.#V(!0);if($===B)$="";if($)B=`(?:${B})(?:${$})*?`;let E="";if(this.type==="!"&&this.#J)E=(this.isStart()&&!u?uF:"")+D1;else{let Q=this.type==="!"?"))"+(this.isStart()&&!u&&!D?uF:"")+e6+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&$?")":this.type==="*"&&$?")?":`)${this.type}`;E=C+B+Q}return[E,rD(B),this.#u=!!this.#u,this.#E]}#V(D){return this.#B.map((u)=>{if(typeof u==="string")throw new Error("string type in extglob ast??");let[F,C,B,$]=u.toRegExpSource(D);return this.#E=this.#E||$,F}).filter((u)=>!(this.isStart()&&this.isEnd())||!!u).join("|")}static#W(D,u,F=!1){let C=!1,B="",$=!1;for(let E=0;E{return u?D.replace(/[?*()[\]]/g,"[$&]"):D.replace(/[?*()[\]\\]/g,"\\$&")};var UD=(D,u,F={})=>{if(Eu(u),!F.nocomment&&u.charAt(0)==="#")return!1;return new fD(u,F).match(D)},b4=/^\*+([^+@!?\*\[\(]*)$/,v4=(D)=>(u)=>!u.startsWith(".")&&u.endsWith(D),f4=(D)=>(u)=>u.endsWith(D),y4=(D)=>{return D=D.toLowerCase(),(u)=>!u.startsWith(".")&&u.toLowerCase().endsWith(D)},h4=(D)=>{return D=D.toLowerCase(),(u)=>u.toLowerCase().endsWith(D)},g4=/^\*+\.\*+$/,m4=(D)=>!D.startsWith(".")&&D.includes("."),d4=(D)=>D!=="."&&D!==".."&&D.includes("."),c4=/^\.\*+$/,l4=(D)=>D!=="."&&D!==".."&&D.startsWith("."),p4=/^\*+$/,a4=(D)=>D.length!==0&&!D.startsWith("."),n4=(D)=>D.length!==0&&D!=="."&&D!=="..",r4=/^\?+([^+@!?\*\[\(]*)?$/,i4=([D,u=""])=>{let F=C1([D]);if(!u)return F;return u=u.toLowerCase(),(C)=>F(C)&&C.toLowerCase().endsWith(u)},o4=([D,u=""])=>{let F=B1([D]);if(!u)return F;return u=u.toLowerCase(),(C)=>F(C)&&C.toLowerCase().endsWith(u)},s4=([D,u=""])=>{let F=B1([D]);return!u?F:(C)=>F(C)&&C.endsWith(u)},t4=([D,u=""])=>{let F=C1([D]);return!u?F:(C)=>F(C)&&C.endsWith(u)},C1=([D])=>{let u=D.length;return(F)=>F.length===u&&!F.startsWith(".")},B1=([D])=>{let u=D.length;return(F)=>F.length===u&&F!=="."&&F!==".."},E1=typeof process==="object"&&process?typeof process.env==="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",u1={win32:{sep:"\\"},posix:{sep:"/"}},e4=E1==="win32"?u1.win32.sep:u1.posix.sep;UD.sep=e4;var XD=Symbol("globstar **");UD.GLOBSTAR=XD;var DE="[^/]",uE=DE+"*?",FE="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",CE="(?:(?!(?:\\/|^)\\.).)*?",BE=(D,u={})=>(F)=>UD(F,D,u);UD.filter=BE;var vD=(D,u={})=>Object.assign({},D,u),EE=(D)=>{if(!D||typeof D!=="object"||!Object.keys(D).length)return UD;let u=UD;return Object.assign((C,B,$={})=>u(C,B,vD(D,$)),{Minimatch:class C extends u.Minimatch{constructor(B,$={}){super(B,vD(D,$))}static defaults(B){return u.defaults(vD(D,B)).Minimatch}},AST:class C extends u.AST{constructor(B,$,E={}){super(B,$,vD(D,E))}static fromGlob(B,$={}){return u.AST.fromGlob(B,vD(D,$))}},unescape:(C,B={})=>u.unescape(C,vD(D,B)),escape:(C,B={})=>u.escape(C,vD(D,B)),filter:(C,B={})=>u.filter(C,vD(D,B)),defaults:(C)=>u.defaults(vD(D,C)),makeRe:(C,B={})=>u.makeRe(C,vD(D,B)),braceExpand:(C,B={})=>u.braceExpand(C,vD(D,B)),match:(C,B,$={})=>u.match(C,B,vD(D,$)),sep:u.sep,GLOBSTAR:XD})};UD.defaults=EE;var $1=(D,u={})=>{if(Eu(D),u.nobrace||!/\{(?:(?!\{).)*\}/.test(D))return[D];return i6(D)};UD.braceExpand=$1;var $E=(D,u={})=>new fD(D,u).makeRe();UD.makeRe=$E;var QE=(D,u,F={})=>{let C=new fD(u,F);if(D=D.filter((B)=>C.match(B)),C.options.nonull&&!D.length)D.push(u);return D};UD.match=QE;var F1=/[?*]|[+@!]\(.*?\)|\[|\]/,XE=(D)=>D.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");class fD{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(D,u={}){if(Eu(D),u=u||{},this.options=u,this.pattern=D,this.platform=u.platform||E1,this.isWindows=this.platform==="win32",this.windowsPathsNoEscape=!!u.windowsPathsNoEscape||u.allowWindowsEscape===!1,this.windowsPathsNoEscape)this.pattern=this.pattern.replace(/\\/g,"/");this.preserveMultipleSlashes=!!u.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!u.nonegate,this.comment=!1,this.empty=!1,this.partial=!!u.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=u.windowsNoMagicRoot!==void 0?u.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let D of this.set)for(let u of D)if(typeof u!=="string")return!0;return!1}debug(...D){}make(){let D=this.pattern,u=this.options;if(!u.nocomment&&D.charAt(0)==="#"){this.comment=!0;return}if(!D){this.empty=!0;return}if(this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],u.debug)this.debug=(...B)=>console.error(...B);this.debug(this.pattern,this.globSet);let F=this.globSet.map((B)=>this.slashSplit(B));this.globParts=this.preprocess(F),this.debug(this.pattern,this.globParts);let C=this.globParts.map((B,$,E)=>{if(this.isWindows&&this.windowsNoMagicRoot){let Q=B[0]===""&&B[1]===""&&(B[2]==="?"||!F1.test(B[2]))&&!F1.test(B[3]),X=/^[a-z]:/i.test(B[0]);if(Q)return[...B.slice(0,4),...B.slice(4).map((Z)=>this.parse(Z))];else if(X)return[B[0],...B.slice(1).map((Z)=>this.parse(Z))]}return B.map((Q)=>this.parse(Q))});if(this.debug(this.pattern,C),this.set=C.filter((B)=>B.indexOf(!1)===-1),this.isWindows)for(let B=0;B=2)D=this.firstPhasePreProcess(D),D=this.secondPhasePreProcess(D);else if(u>=1)D=this.levelOneOptimize(D);else D=this.adjascentGlobstarOptimize(D);return D}adjascentGlobstarOptimize(D){return D.map((u)=>{let F=-1;while((F=u.indexOf("**",F+1))!==-1){let C=F;while(u[C+1]==="**")C++;if(C!==F)u.splice(F,C-F)}return u})}levelOneOptimize(D){return D.map((u)=>{return u=u.reduce((F,C)=>{let B=F[F.length-1];if(C==="**"&&B==="**")return F;if(C===".."){if(B&&B!==".."&&B!=="."&&B!=="**")return F.pop(),F}return F.push(C),F},[]),u.length===0?[""]:u})}levelTwoFileOptimize(D){if(!Array.isArray(D))D=this.slashSplit(D);let u=!1;do{if(u=!1,!this.preserveMultipleSlashes){for(let C=1;CC)F.splice(C+1,$-C);let E=F[C+1],Q=F[C+2],X=F[C+3];if(E!=="..")continue;if(!Q||Q==="."||Q===".."||!X||X==="."||X==="..")continue;u=!0,F.splice(C,1);let Z=F.slice(0);Z[C]="**",D.push(Z),C--}if(!this.preserveMultipleSlashes){for(let $=1;$u.length)}partsMatch(D,u,F=!1){let C=0,B=0,$=[],E="";while(Cj)u=u.slice(R);else if(j>R)D=D.slice(j)}}}let{optimizationLevel:B=1}=this.options;if(B>=2)D=this.levelTwoFileOptimize(D);this.debug("matchOne",this,{file:D,pattern:u}),this.debug("matchOne",D.length,u.length);for(var $=0,E=0,Q=D.length,X=u.length;$>> no match, partial?`,D,J,u,A),J===Q)return!0}return!1}let G;if(typeof Z==="string")G=Y===Z,this.debug("string match",Z,Y,G);else G=Z.test(Y),this.debug("pattern match",Z,Y,G);if(!G)return!1}if($===Q&&E===X)return!0;else if($===Q)return F;else if(E===X)return $===Q-1&&D[$]==="";else throw new Error("wtf?")}braceExpand(){return E1(this.pattern,this.options)}parse(D){Eu(D);let u=this.options;if(D==="**")return XD;if(D==="")return"";let F,C=null;if(F=D.match(c4))C=u.dot?p4:l4;else if(F=D.match(S4))C=(u.nocase?u.dot?f4:v4:u.dot?b4:x4)(F[1]);else if(F=D.match(a4))C=(u.nocase?u.dot?r4:n4:u.dot?i4:o4)(F);else if(F=D.match(y4))C=u.dot?g4:h4;else if(F=D.match(m4))C=d4;let B=QD.fromGlob(D,this.options).toMMPattern();if(C&&typeof B==="object")Reflect.defineProperty(B,"test",{value:C});return B}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let D=this.set;if(!D.length)return this.regexp=!1,this.regexp;let u=this.options,F=u.noglobstar?e4:u.dot?DE:uE,C=new Set(u.nocase?["i"]:[]),B=D.map((Q)=>{let X=Q.map((Z)=>{if(Z instanceof RegExp)for(let Y of Z.flags.split(""))C.add(Y);return typeof Z==="string"?$E(Z):Z===XD?XD:Z._src});return X.forEach((Z,Y)=>{let J=X[Y+1],A=X[Y-1];if(Z!==XD||A===XD)return;if(A===void 0)if(J!==void 0&&J!==XD)X[Y+1]="(?:\\/|"+F+"\\/)?"+J;else X[Y]=F;else if(J===void 0)X[Y-1]=A+"(?:\\/|"+F+")?";else if(J!==XD)X[Y-1]=A+"(?:\\/|\\/"+F+"\\/)"+J,X[Y+1]=XD}),X.filter((Z)=>Z!==XD).join("/")}).join("|"),[$,E]=D.length>1?["(?:",")"]:["",""];if(B="^"+$+B+E+"$",this.negate)B="^(?!"+B+").+$";try{this.regexp=new RegExp(B,[...C].join(""))}catch(Q){this.regexp=!1}return this.regexp}slashSplit(D){if(this.preserveMultipleSlashes)return D.split("/");else if(this.isWindows&&/^\/\/[^\/]+/.test(D))return["",...D.split(/\/+/)];else return D.split(/\/+/)}match(D,u=this.partial){if(this.debug("match",D,this.pattern),this.comment)return!1;if(this.empty)return D==="";if(D==="/"&&u)return!0;let F=this.options;if(this.isWindows)D=D.split("\\").join("/");let C=this.slashSplit(D);this.debug(this.pattern,"split",C);let B=this.set;this.debug(this.pattern,"set",B);let $=C[C.length-1];if(!$)for(let E=C.length-2;!$&&E>=0;E--)$=C[E];for(let E=0;E{typeof a2.emitWarning==="function"?a2.emitWarning(D,u,F,C):console.error(`[${F}] ${u}: ${D}`)},FF=globalThis.AbortController,$1=globalThis.AbortSignal;if(typeof FF==="undefined"){$1=class F{onabort;_onabort=[];reason;aborted=!1;addEventListener(C,B){this._onabort.push(B)}},FF=class F{constructor(){u()}signal=new $1;abort(C){if(this.signal.aborted)return;this.signal.reason=C,this.signal.aborted=!0;for(let B of this.signal._onabort)B(C);this.signal.onabort?.(C)}};let D=a2.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",u=()=>{if(!D)return;D=!1,X1("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",u)}}var XE=(D)=>!Q1.has(D),lZ=Symbol("type"),V0=(D)=>D&&D===Math.floor(D)&&D>0&&isFinite(D),Z1=(D)=>!V0(D)?null:D<=Math.pow(2,8)?Uint8Array:D<=Math.pow(2,16)?Uint16Array:D<=Math.pow(2,32)?Uint32Array:D<=Number.MAX_SAFE_INTEGER?Qu:null;class Qu extends Array{constructor(D){super(D);this.fill(0)}}class P0{heap;length;static#D=!1;static create(D){let u=Z1(D);if(!u)return[];P0.#D=!0;let F=new P0(D,u);return P0.#D=!1,F}constructor(D,u){if(!P0.#D)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new u(D),this.length=0}push(D){this.heap[this.length++]=D}pop(){return this.heap[--this.length]}}class Xu{#D;#u;#E;#B;#$;#U;#z;#Y;get perf(){return this.#Y}ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#Q;#K;#J;#X;#F;#V;#W;#_;#A;#j;#H;#R;#N;#G;#L;#O;#q;#C;static unsafeExposeInternals(D){return{starts:D.#N,ttls:D.#G,sizes:D.#R,keyMap:D.#J,keyList:D.#X,valList:D.#F,next:D.#V,prev:D.#W,get head(){return D.#_},get tail(){return D.#A},free:D.#j,isBackgroundFetch:(u)=>D.#Z(u),backgroundFetch:(u,F,C,B)=>D.#c(u,F,C,B),moveToTail:(u)=>D.#f(u),indexes:(u)=>D.#w(u),rindexes:(u)=>D.#P(u),isStale:(u)=>D.#I(u)}}get max(){return this.#D}get maxSize(){return this.#u}get calculatedSize(){return this.#K}get size(){return this.#Q}get fetchMethod(){return this.#U}get memoMethod(){return this.#z}get dispose(){return this.#E}get onInsert(){return this.#B}get disposeAfter(){return this.#$}constructor(D){let{max:u=0,ttl:F,ttlResolution:C=1,ttlAutopurge:B,updateAgeOnGet:$,updateAgeOnHas:E,allowStale:Q,dispose:X,onInsert:Z,disposeAfter:Y,noDisposeOnSet:J,noUpdateTTL:A,maxSize:H=0,maxEntrySize:G=0,sizeCalculation:z,fetchMethod:U,memoMethod:I,noDeleteOnFetchRejection:j,noDeleteOnStaleGet:R,allowStaleOnFetchRejection:M,allowStaleOnFetchAbort:P,ignoreFetchAbort:x,perf:AD}=D;if(AD!==void 0){if(typeof AD?.now!=="function")throw new TypeError("perf option must have a now() method if specified")}if(this.#Y=AD??QE,u!==0&&!V0(u))throw new TypeError("max option must be a nonnegative integer");let wD=u?Z1(u):Array;if(!wD)throw new Error("invalid max value: "+u);if(this.#D=u,this.#u=H,this.maxEntrySize=G||this.#u,this.sizeCalculation=z,this.sizeCalculation){if(!this.#u&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!=="function")throw new TypeError("sizeCalculation set to non-function")}if(I!==void 0&&typeof I!=="function")throw new TypeError("memoMethod must be a function if defined");if(this.#z=I,U!==void 0&&typeof U!=="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#U=U,this.#O=!!U,this.#J=new Map,this.#X=new Array(u).fill(void 0),this.#F=new Array(u).fill(void 0),this.#V=new wD(u),this.#W=new wD(u),this.#_=0,this.#A=0,this.#j=P0.create(u),this.#Q=0,this.#K=0,typeof X==="function")this.#E=X;if(typeof Z==="function")this.#B=Z;if(typeof Y==="function")this.#$=Y,this.#H=[];else this.#$=void 0,this.#H=void 0;if(this.#L=!!this.#E,this.#C=!!this.#B,this.#q=!!this.#$,this.noDisposeOnSet=!!J,this.noUpdateTTL=!!A,this.noDeleteOnFetchRejection=!!j,this.allowStaleOnFetchRejection=!!M,this.allowStaleOnFetchAbort=!!P,this.ignoreFetchAbort=!!x,this.maxEntrySize!==0){if(this.#u!==0){if(!V0(this.#u))throw new TypeError("maxSize must be a positive integer if specified")}if(!V0(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#y()}if(this.allowStale=!!Q,this.noDeleteOnStaleGet=!!R,this.updateAgeOnGet=!!$,this.updateAgeOnHas=!!E,this.ttlResolution=V0(C)||C===0?C:1,this.ttlAutopurge=!!B,this.ttl=F||0,this.ttl){if(!V0(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#S()}if(this.#D===0&&this.ttl===0&&this.#u===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#D&&!this.#u){if(XE("LRU_CACHE_UNBOUNDED"))Q1.add("LRU_CACHE_UNBOUNDED"),X1("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning","LRU_CACHE_UNBOUNDED",Xu)}}getRemainingTTL(D){return this.#J.has(D)?1/0:0}#S(){let D=new Qu(this.#D),u=new Qu(this.#D);this.#G=D,this.#N=u,this.#m=(B,$,E=this.#Y.now())=>{if(u[B]=$!==0?E:0,D[B]=$,$!==0&&this.ttlAutopurge){let Q=setTimeout(()=>{if(this.#I(B))this.#k(this.#X[B],"expire")},$+1);if(Q.unref)Q.unref()}},this.#T=(B)=>{u[B]=D[B]!==0?this.#Y.now():0},this.#M=(B,$)=>{if(D[$]){let E=D[$],Q=u[$];if(!E||!Q)return;B.ttl=E,B.start=Q,B.now=F||C();let X=B.now-Q;B.remainingTTL=E-X}};let F=0,C=()=>{let B=this.#Y.now();if(this.ttlResolution>0){F=B;let $=setTimeout(()=>F=0,this.ttlResolution);if($.unref)$.unref()}return B};this.getRemainingTTL=(B)=>{let $=this.#J.get(B);if($===void 0)return 0;let E=D[$],Q=u[$];if(!E||!Q)return 1/0;let X=(F||C())-Q;return E-X},this.#I=(B)=>{let $=u[B],E=D[B];return!!E&&!!$&&(F||C())-$>E}}#T=()=>{};#M=()=>{};#m=()=>{};#I=()=>!1;#y(){let D=new Qu(this.#D);this.#K=0,this.#R=D,this.#x=(u)=>{this.#K-=D[u],D[u]=0},this.#b=(u,F,C,B)=>{if(this.#Z(F))return 0;if(!V0(C))if(B){if(typeof B!=="function")throw new TypeError("sizeCalculation must be a function");if(C=B(F,u),!V0(C))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return C},this.#h=(u,F,C)=>{if(D[u]=F,this.#u){let B=this.#u-D[u];while(this.#K>B)this.#v(!0)}if(this.#K+=D[u],C)C.entrySize=F,C.totalCalculatedSize=this.#K}}#x=(D)=>{};#h=(D,u,F)=>{};#b=(D,u,F,C)=>{if(F||C)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#w({allowStale:D=this.allowStale}={}){if(this.#Q)for(let u=this.#A;;){if(!this.#d(u))break;if(D||!this.#I(u))yield u;if(u===this.#_)break;else u=this.#W[u]}}*#P({allowStale:D=this.allowStale}={}){if(this.#Q)for(let u=this.#_;;){if(!this.#d(u))break;if(D||!this.#I(u))yield u;if(u===this.#A)break;else u=this.#V[u]}}#d(D){return D!==void 0&&this.#J.get(this.#X[D])===D}*entries(){for(let D of this.#w())if(this.#F[D]!==void 0&&this.#X[D]!==void 0&&!this.#Z(this.#F[D]))yield[this.#X[D],this.#F[D]]}*rentries(){for(let D of this.#P())if(this.#F[D]!==void 0&&this.#X[D]!==void 0&&!this.#Z(this.#F[D]))yield[this.#X[D],this.#F[D]]}*keys(){for(let D of this.#w()){let u=this.#X[D];if(u!==void 0&&!this.#Z(this.#F[D]))yield u}}*rkeys(){for(let D of this.#P()){let u=this.#X[D];if(u!==void 0&&!this.#Z(this.#F[D]))yield u}}*values(){for(let D of this.#w())if(this.#F[D]!==void 0&&!this.#Z(this.#F[D]))yield this.#F[D]}*rvalues(){for(let D of this.#P())if(this.#F[D]!==void 0&&!this.#Z(this.#F[D]))yield this.#F[D]}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(D,u={}){for(let F of this.#w()){let C=this.#F[F],B=this.#Z(C)?C.__staleWhileFetching:C;if(B===void 0)continue;if(D(B,this.#X[F],this))return this.get(this.#X[F],u)}}forEach(D,u=this){for(let F of this.#w()){let C=this.#F[F],B=this.#Z(C)?C.__staleWhileFetching:C;if(B===void 0)continue;D.call(u,B,this.#X[F],this)}}rforEach(D,u=this){for(let F of this.#P()){let C=this.#F[F],B=this.#Z(C)?C.__staleWhileFetching:C;if(B===void 0)continue;D.call(u,B,this.#X[F],this)}}purgeStale(){let D=!1;for(let u of this.#P({allowStale:!0}))if(this.#I(u))this.#k(this.#X[u],"expire"),D=!0;return D}info(D){let u=this.#J.get(D);if(u===void 0)return;let F=this.#F[u],C=this.#Z(F)?F.__staleWhileFetching:F;if(C===void 0)return;let B={value:C};if(this.#G&&this.#N){let $=this.#G[u],E=this.#N[u];if($&&E){let Q=$-(this.#Y.now()-E);B.ttl=Q,B.start=Date.now()}}if(this.#R)B.size=this.#R[u];return B}dump(){let D=[];for(let u of this.#w({allowStale:!0})){let F=this.#X[u],C=this.#F[u],B=this.#Z(C)?C.__staleWhileFetching:C;if(B===void 0||F===void 0)continue;let $={value:B};if(this.#G&&this.#N){$.ttl=this.#G[u];let E=this.#Y.now()-this.#N[u];$.start=Math.floor(Date.now()-E)}if(this.#R)$.size=this.#R[u];D.unshift([F,$])}return D}load(D){this.clear();for(let[u,F]of D){if(F.start){let C=Date.now()-F.start;F.start=this.#Y.now()-C}this.set(u,F.value,F)}}set(D,u,F={}){if(u===void 0)return this.delete(D),this;let{ttl:C=this.ttl,start:B,noDisposeOnSet:$=this.noDisposeOnSet,sizeCalculation:E=this.sizeCalculation,status:Q}=F,{noUpdateTTL:X=this.noUpdateTTL}=F,Z=this.#b(D,u,F.size||0,E);if(this.maxEntrySize&&Z>this.maxEntrySize){if(Q)Q.set="miss",Q.maxEntrySizeExceeded=!0;return this.#k(D,"set"),this}let Y=this.#Q===0?void 0:this.#J.get(D);if(Y===void 0){if(Y=this.#Q===0?this.#A:this.#j.length!==0?this.#j.pop():this.#Q===this.#D?this.#v(!1):this.#Q,this.#X[Y]=D,this.#F[Y]=u,this.#J.set(D,Y),this.#V[this.#A]=Y,this.#W[Y]=this.#A,this.#A=Y,this.#Q++,this.#h(Y,Z,Q),Q)Q.set="add";if(X=!1,this.#C)this.#B?.(u,D,"add")}else{this.#f(Y);let J=this.#F[Y];if(u!==J){if(this.#O&&this.#Z(J)){J.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:A}=J;if(A!==void 0&&!$){if(this.#L)this.#E?.(A,D,"set");if(this.#q)this.#H?.push([A,D,"set"])}}else if(!$){if(this.#L)this.#E?.(J,D,"set");if(this.#q)this.#H?.push([J,D,"set"])}if(this.#x(Y),this.#h(Y,Z,Q),this.#F[Y]=u,Q){Q.set="replace";let A=J&&this.#Z(J)?J.__staleWhileFetching:J;if(A!==void 0)Q.oldValue=A}}else if(Q)Q.set="update";if(this.#C)this.onInsert?.(u,D,u===J?"update":"replace")}if(C!==0&&!this.#G)this.#S();if(this.#G){if(!X)this.#m(Y,C,B);if(Q)this.#M(Q,Y)}if(!$&&this.#q&&this.#H){let J=this.#H,A;while(A=J?.shift())this.#$?.(...A)}return this}pop(){try{while(this.#Q){let D=this.#F[this.#_];if(this.#v(!0),this.#Z(D)){if(D.__staleWhileFetching)return D.__staleWhileFetching}else if(D!==void 0)return D}}finally{if(this.#q&&this.#H){let D=this.#H,u;while(u=D?.shift())this.#$?.(...u)}}}#v(D){let u=this.#_,F=this.#X[u],C=this.#F[u];if(this.#O&&this.#Z(C))C.__abortController.abort(new Error("evicted"));else if(this.#L||this.#q){if(this.#L)this.#E?.(C,F,"evict");if(this.#q)this.#H?.push([C,F,"evict"])}if(this.#x(u),D)this.#X[u]=void 0,this.#F[u]=void 0,this.#j.push(u);if(this.#Q===1)this.#_=this.#A=0,this.#j.length=0;else this.#_=this.#V[u];return this.#J.delete(F),this.#Q--,u}has(D,u={}){let{updateAgeOnHas:F=this.updateAgeOnHas,status:C}=u,B=this.#J.get(D);if(B!==void 0){let $=this.#F[B];if(this.#Z($)&&$.__staleWhileFetching===void 0)return!1;if(!this.#I(B)){if(F)this.#T(B);if(C)C.has="hit",this.#M(C,B);return!0}else if(C)C.has="stale",this.#M(C,B)}else if(C)C.has="miss";return!1}peek(D,u={}){let{allowStale:F=this.allowStale}=u,C=this.#J.get(D);if(C===void 0||!F&&this.#I(C))return;let B=this.#F[C];return this.#Z(B)?B.__staleWhileFetching:B}#c(D,u,F,C){let B=u===void 0?void 0:this.#F[u];if(this.#Z(B))return B;let $=new FF,{signal:E}=F;E?.addEventListener("abort",()=>$.abort(E.reason),{signal:$.signal});let Q={signal:$.signal,options:F,context:C},X=(G,z=!1)=>{let{aborted:U}=$.signal,I=F.ignoreFetchAbort&&G!==void 0;if(F.status)if(U&&!z){if(F.status.fetchAborted=!0,F.status.fetchError=$.signal.reason,I)F.status.fetchAbortIgnored=!0}else F.status.fetchResolved=!0;if(U&&!I&&!z)return Y($.signal.reason);let j=A,R=this.#F[u];if(R===A||I&&z&&R===void 0)if(G===void 0)if(j.__staleWhileFetching!==void 0)this.#F[u]=j.__staleWhileFetching;else this.#k(D,"fetch");else{if(F.status)F.status.fetchUpdated=!0;this.set(D,G,Q.options)}return G},Z=(G)=>{if(F.status)F.status.fetchRejected=!0,F.status.fetchError=G;return Y(G)},Y=(G)=>{let{aborted:z}=$.signal,U=z&&F.allowStaleOnFetchAbort,I=U||F.allowStaleOnFetchRejection,j=I||F.noDeleteOnFetchRejection,R=A;if(this.#F[u]===A){if(!j||R.__staleWhileFetching===void 0)this.#k(D,"fetch");else if(!U)this.#F[u]=R.__staleWhileFetching}if(I){if(F.status&&R.__staleWhileFetching!==void 0)F.status.returnedStale=!0;return R.__staleWhileFetching}else if(R.__returned===R)throw G},J=(G,z)=>{let U=this.#U?.(D,B,Q);if(U&&U instanceof Promise)U.then((I)=>G(I===void 0?void 0:I),z);$.signal.addEventListener("abort",()=>{if(!F.ignoreFetchAbort||F.allowStaleOnFetchAbort){if(G(void 0),F.allowStaleOnFetchAbort)G=(I)=>X(I,!0)}})};if(F.status)F.status.fetchDispatched=!0;let A=new Promise(J).then(X,Z),H=Object.assign(A,{__abortController:$,__staleWhileFetching:B,__returned:void 0});if(u===void 0)this.set(D,H,{...Q.options,status:void 0}),u=this.#J.get(D);else this.#F[u]=H;return H}#Z(D){if(!this.#O)return!1;let u=D;return!!u&&u instanceof Promise&&u.hasOwnProperty("__staleWhileFetching")&&u.__abortController instanceof FF}async fetch(D,u={}){let{allowStale:F=this.allowStale,updateAgeOnGet:C=this.updateAgeOnGet,noDeleteOnStaleGet:B=this.noDeleteOnStaleGet,ttl:$=this.ttl,noDisposeOnSet:E=this.noDisposeOnSet,size:Q=0,sizeCalculation:X=this.sizeCalculation,noUpdateTTL:Z=this.noUpdateTTL,noDeleteOnFetchRejection:Y=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:J=this.allowStaleOnFetchRejection,ignoreFetchAbort:A=this.ignoreFetchAbort,allowStaleOnFetchAbort:H=this.allowStaleOnFetchAbort,context:G,forceRefresh:z=!1,status:U,signal:I}=u;if(!this.#O){if(U)U.fetch="get";return this.get(D,{allowStale:F,updateAgeOnGet:C,noDeleteOnStaleGet:B,status:U})}let j={allowStale:F,updateAgeOnGet:C,noDeleteOnStaleGet:B,ttl:$,noDisposeOnSet:E,size:Q,sizeCalculation:X,noUpdateTTL:Z,noDeleteOnFetchRejection:Y,allowStaleOnFetchRejection:J,allowStaleOnFetchAbort:H,ignoreFetchAbort:A,status:U,signal:I},R=this.#J.get(D);if(R===void 0){if(U)U.fetch="miss";let M=this.#c(D,R,j,G);return M.__returned=M}else{let M=this.#F[R];if(this.#Z(M)){let W=F&&M.__staleWhileFetching!==void 0;if(U){if(U.fetch="inflight",W)U.returnedStale=!0}return W?M.__staleWhileFetching:M.__returned=M}let P=this.#I(R);if(!z&&!P){if(U)U.fetch="hit";if(this.#f(R),C)this.#T(R);if(U)this.#M(U,R);return M}let x=this.#c(D,R,j,G),wD=x.__staleWhileFetching!==void 0&&F;if(U){if(U.fetch=P?"stale":"refresh",wD&&P)U.returnedStale=!0}return wD?x.__staleWhileFetching:x.__returned=x}}async forceFetch(D,u={}){let F=await this.fetch(D,u);if(F===void 0)throw new Error("fetch() returned undefined");return F}memo(D,u={}){let F=this.#z;if(!F)throw new Error("no memoMethod provided to constructor");let{context:C,forceRefresh:B,...$}=u,E=this.get(D,$);if(!B&&E!==void 0)return E;let Q=F(D,E,{options:$,context:C});return this.set(D,Q,$),Q}get(D,u={}){let{allowStale:F=this.allowStale,updateAgeOnGet:C=this.updateAgeOnGet,noDeleteOnStaleGet:B=this.noDeleteOnStaleGet,status:$}=u,E=this.#J.get(D);if(E!==void 0){let Q=this.#F[E],X=this.#Z(Q);if($)this.#M($,E);if(this.#I(E)){if($)$.get="stale";if(!X){if(!B)this.#k(D,"expire");if($&&F)$.returnedStale=!0;return F?Q:void 0}else{if($&&F&&Q.__staleWhileFetching!==void 0)$.returnedStale=!0;return F?Q.__staleWhileFetching:void 0}}else{if($)$.get="hit";if(X)return Q.__staleWhileFetching;if(this.#f(E),C)this.#T(E);return Q}}else if($)$.get="miss"}#l(D,u){this.#W[u]=D,this.#V[D]=u}#f(D){if(D!==this.#A){if(D===this.#_)this.#_=this.#V[D];else this.#l(this.#W[D],this.#V[D]);this.#l(this.#A,D),this.#A=D}}delete(D){return this.#k(D,"delete")}#k(D,u){let F=!1;if(this.#Q!==0){let C=this.#J.get(D);if(C!==void 0)if(F=!0,this.#Q===1)this.#g(u);else{this.#x(C);let B=this.#F[C];if(this.#Z(B))B.__abortController.abort(new Error("deleted"));else if(this.#L||this.#q){if(this.#L)this.#E?.(B,D,u);if(this.#q)this.#H?.push([B,D,u])}if(this.#J.delete(D),this.#X[C]=void 0,this.#F[C]=void 0,C===this.#A)this.#A=this.#W[C];else if(C===this.#_)this.#_=this.#V[C];else{let $=this.#W[C];this.#V[$]=this.#V[C];let E=this.#V[C];this.#W[E]=this.#W[C]}this.#Q--,this.#j.push(C)}}if(this.#q&&this.#H?.length){let C=this.#H,B;while(B=C?.shift())this.#$?.(...B)}return F}clear(){return this.#g("delete")}#g(D){for(let u of this.#P({allowStale:!0})){let F=this.#F[u];if(this.#Z(F))F.__abortController.abort(new Error("deleted"));else{let C=this.#X[u];if(this.#L)this.#E?.(F,C,D);if(this.#q)this.#H?.push([F,C,D])}}if(this.#J.clear(),this.#F.fill(void 0),this.#X.fill(void 0),this.#G&&this.#N)this.#G.fill(0),this.#N.fill(0);if(this.#R)this.#R.fill(0);if(this.#_=0,this.#A=0,this.#j.length=0,this.#K=0,this.#Q=0,this.#q&&this.#H){let u=this.#H,F;while(F=u?.shift())this.#$?.(...F)}}}import{posix as _E,win32 as F3}from"path";import{fileURLToPath as UE}from"url";import{lstatSync as WE,readdir as LE,readdirSync as RE,readlinkSync as ME,realpathSync as IE}from"fs";import*as NE from"fs";import{lstat as jE,readdir as TE,readlink as wE,realpath as kE}from"fs/promises";import{EventEmitter as t2}from"events";import V1 from"stream";import{StringDecoder as ZE}from"string_decoder";var Y1=typeof process==="object"&&process?process:{stdout:null,stderr:null},YE=(D)=>!!D&&typeof D==="object"&&(D instanceof U0||D instanceof V1||JE(D)||KE(D)),JE=(D)=>!!D&&typeof D==="object"&&D instanceof t2&&typeof D.pipe==="function"&&D.pipe!==V1.Writable.prototype.pipe,KE=(D)=>!!D&&typeof D==="object"&&D instanceof t2&&typeof D.write==="function"&&typeof D.end==="function",E0=Symbol("EOF"),$0=Symbol("maybeEmitEnd"),A0=Symbol("emittedEnd"),CF=Symbol("emittingEnd"),Zu=Symbol("emittedError"),BF=Symbol("closed"),J1=Symbol("read"),EF=Symbol("flush"),K1=Symbol("flushChunk"),iD=Symbol("encoding"),S0=Symbol("decoder"),CD=Symbol("flowing"),Yu=Symbol("paused"),x0=Symbol("resume"),BD=Symbol("buffer"),WD=Symbol("pipes"),ED=Symbol("bufferLength"),n2=Symbol("bufferPush"),$F=Symbol("bufferShift"),VD=Symbol("objectMode"),t=Symbol("destroyed"),r2=Symbol("error"),i2=Symbol("emitData"),q1=Symbol("emitEnd"),o2=Symbol("emitEnd2"),tD=Symbol("async"),s2=Symbol("abort"),QF=Symbol("aborted"),Ju=Symbol("signal"),_0=Symbol("dataListeners"),TD=Symbol("discarded"),Ku=(D)=>Promise.resolve().then(D),qE=(D)=>D(),VE=(D)=>D==="end"||D==="finish"||D==="prefinish",AE=(D)=>D instanceof ArrayBuffer||!!D&&typeof D==="object"&&D.constructor&&D.constructor.name==="ArrayBuffer"&&D.byteLength>=0,HE=(D)=>!Buffer.isBuffer(D)&&ArrayBuffer.isView(D);class e2{src;dest;opts;ondrain;constructor(D,u,F){this.src=D,this.dest=u,this.opts=F,this.ondrain=()=>D[x0](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(D){}end(){if(this.unpipe(),this.opts.end)this.dest.end()}}class A1 extends e2{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(D,u,F){super(D,u,F);this.proxyErrors=(C)=>u.emit("error",C),D.on("error",this.proxyErrors)}}var GE=(D)=>!!D.objectMode,zE=(D)=>!D.objectMode&&!!D.encoding&&D.encoding!=="buffer";class U0 extends t2{[CD]=!1;[Yu]=!1;[WD]=[];[BD]=[];[VD];[iD];[tD];[S0];[E0]=!1;[A0]=!1;[CF]=!1;[BF]=!1;[Zu]=null;[ED]=0;[t]=!1;[Ju];[QF]=!1;[_0]=0;[TD]=!1;writable=!0;readable=!0;constructor(...D){let u=D[0]||{};super();if(u.objectMode&&typeof u.encoding==="string")throw new TypeError("Encoding and objectMode may not be used together");if(GE(u))this[VD]=!0,this[iD]=null;else if(zE(u))this[iD]=u.encoding,this[VD]=!1;else this[VD]=!1,this[iD]=null;if(this[tD]=!!u.async,this[S0]=this[iD]?new ZE(this[iD]):null,u&&u.debugExposeBuffer===!0)Object.defineProperty(this,"buffer",{get:()=>this[BD]});if(u&&u.debugExposePipes===!0)Object.defineProperty(this,"pipes",{get:()=>this[WD]});let{signal:F}=u;if(F)if(this[Ju]=F,F.aborted)this[s2]();else F.addEventListener("abort",()=>this[s2]())}get bufferLength(){return this[ED]}get encoding(){return this[iD]}set encoding(D){throw new Error("Encoding must be set at instantiation time")}setEncoding(D){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[VD]}set objectMode(D){throw new Error("objectMode must be set at instantiation time")}get["async"](){return this[tD]}set["async"](D){this[tD]=this[tD]||!!D}[s2](){this[QF]=!0,this.emit("abort",this[Ju]?.reason),this.destroy(this[Ju]?.reason)}get aborted(){return this[QF]}set aborted(D){}write(D,u,F){if(this[QF])return!1;if(this[E0])throw new Error("write after end");if(this[t])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;if(typeof u==="function")F=u,u="utf8";if(!u)u="utf8";let C=this[tD]?Ku:qE;if(!this[VD]&&!Buffer.isBuffer(D)){if(HE(D))D=Buffer.from(D.buffer,D.byteOffset,D.byteLength);else if(AE(D))D=Buffer.from(D);else if(typeof D!=="string")throw new Error("Non-contiguous data written to non-objectMode stream")}if(this[VD]){if(this[CD]&&this[ED]!==0)this[EF](!0);if(this[CD])this.emit("data",D);else this[n2](D);if(this[ED]!==0)this.emit("readable");if(F)C(F);return this[CD]}if(!D.length){if(this[ED]!==0)this.emit("readable");if(F)C(F);return this[CD]}if(typeof D==="string"&&!(u===this[iD]&&!this[S0]?.lastNeed))D=Buffer.from(D,u);if(Buffer.isBuffer(D)&&this[iD])D=this[S0].write(D);if(this[CD]&&this[ED]!==0)this[EF](!0);if(this[CD])this.emit("data",D);else this[n2](D);if(this[ED]!==0)this.emit("readable");if(F)C(F);return this[CD]}read(D){if(this[t])return null;if(this[TD]=!1,this[ED]===0||D===0||D&&D>this[ED])return this[$0](),null;if(this[VD])D=null;if(this[BD].length>1&&!this[VD])this[BD]=[this[iD]?this[BD].join(""):Buffer.concat(this[BD],this[ED])];let u=this[J1](D||null,this[BD][0]);return this[$0](),u}[J1](D,u){if(this[VD])this[$F]();else{let F=u;if(D===F.length||D===null)this[$F]();else if(typeof F==="string")this[BD][0]=F.slice(D),u=F.slice(0,D),this[ED]-=D;else this[BD][0]=F.subarray(D),u=F.subarray(0,D),this[ED]-=D}if(this.emit("data",u),!this[BD].length&&!this[E0])this.emit("drain");return u}end(D,u,F){if(typeof D==="function")F=D,D=void 0;if(typeof u==="function")F=u,u="utf8";if(D!==void 0)this.write(D,u);if(F)this.once("end",F);if(this[E0]=!0,this.writable=!1,this[CD]||!this[Yu])this[$0]();return this}[x0](){if(this[t])return;if(!this[_0]&&!this[WD].length)this[TD]=!0;if(this[Yu]=!1,this[CD]=!0,this.emit("resume"),this[BD].length)this[EF]();else if(this[E0])this[$0]();else this.emit("drain")}resume(){return this[x0]()}pause(){this[CD]=!1,this[Yu]=!0,this[TD]=!1}get destroyed(){return this[t]}get flowing(){return this[CD]}get paused(){return this[Yu]}[n2](D){if(this[VD])this[ED]+=1;else this[ED]+=D.length;this[BD].push(D)}[$F](){if(this[VD])this[ED]-=1;else this[ED]-=this[BD][0].length;return this[BD].shift()}[EF](D=!1){do;while(this[K1](this[$F]())&&this[BD].length);if(!D&&!this[BD].length&&!this[E0])this.emit("drain")}[K1](D){return this.emit("data",D),this[CD]}pipe(D,u){if(this[t])return D;this[TD]=!1;let F=this[A0];if(u=u||{},D===Y1.stdout||D===Y1.stderr)u.end=!1;else u.end=u.end!==!1;if(u.proxyErrors=!!u.proxyErrors,F){if(u.end)D.end()}else if(this[WD].push(!u.proxyErrors?new e2(this,D,u):new A1(this,D,u)),this[tD])Ku(()=>this[x0]());else this[x0]();return D}unpipe(D){let u=this[WD].find((F)=>F.dest===D);if(u){if(this[WD].length===1){if(this[CD]&&this[_0]===0)this[CD]=!1;this[WD]=[]}else this[WD].splice(this[WD].indexOf(u),1);u.unpipe()}}addListener(D,u){return this.on(D,u)}on(D,u){let F=super.on(D,u);if(D==="data"){if(this[TD]=!1,this[_0]++,!this[WD].length&&!this[CD])this[x0]()}else if(D==="readable"&&this[ED]!==0)super.emit("readable");else if(VE(D)&&this[A0])super.emit(D),this.removeAllListeners(D);else if(D==="error"&&this[Zu]){let C=u;if(this[tD])Ku(()=>C.call(this,this[Zu]));else C.call(this,this[Zu])}return F}removeListener(D,u){return this.off(D,u)}off(D,u){let F=super.off(D,u);if(D==="data"){if(this[_0]=this.listeners("data").length,this[_0]===0&&!this[TD]&&!this[WD].length)this[CD]=!1}return F}removeAllListeners(D){let u=super.removeAllListeners(D);if(D==="data"||D===void 0){if(this[_0]=0,!this[TD]&&!this[WD].length)this[CD]=!1}return u}get emittedEnd(){return this[A0]}[$0](){if(!this[CF]&&!this[A0]&&!this[t]&&this[BD].length===0&&this[E0]){if(this[CF]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[BF])this.emit("close");this[CF]=!1}}emit(D,...u){let F=u[0];if(D!=="error"&&D!=="close"&&D!==t&&this[t])return!1;else if(D==="data")return!this[VD]&&!F?!1:this[tD]?(Ku(()=>this[i2](F)),!0):this[i2](F);else if(D==="end")return this[q1]();else if(D==="close"){if(this[BF]=!0,!this[A0]&&!this[t])return!1;let B=super.emit("close");return this.removeAllListeners("close"),B}else if(D==="error"){this[Zu]=F,super.emit(r2,F);let B=!this[Ju]||this.listeners("error").length?super.emit("error",F):!1;return this[$0](),B}else if(D==="resume"){let B=super.emit("resume");return this[$0](),B}else if(D==="finish"||D==="prefinish"){let B=super.emit(D);return this.removeAllListeners(D),B}let C=super.emit(D,...u);return this[$0](),C}[i2](D){for(let F of this[WD])if(F.dest.write(D)===!1)this.pause();let u=this[TD]?!1:super.emit("data",D);return this[$0](),u}[q1](){if(this[A0])return!1;return this[A0]=!0,this.readable=!1,this[tD]?(Ku(()=>this[o2]()),!0):this[o2]()}[o2](){if(this[S0]){let u=this[S0].end();if(u){for(let F of this[WD])F.dest.write(u);if(!this[TD])super.emit("data",u)}}for(let u of this[WD])u.end();let D=super.emit("end");return this.removeAllListeners("end"),D}async collect(){let D=Object.assign([],{dataLength:0});if(!this[VD])D.dataLength=0;let u=this.promise();return this.on("data",(F)=>{if(D.push(F),!this[VD])D.dataLength+=F.length}),await u,D}async concat(){if(this[VD])throw new Error("cannot concat in objectMode");let D=await this.collect();return this[iD]?D.join(""):Buffer.concat(D,D.dataLength)}async promise(){return new Promise((D,u)=>{this.on(t,()=>u(new Error("stream destroyed"))),this.on("error",(F)=>u(F)),this.on("end",()=>D())})}[Symbol.asyncIterator](){this[TD]=!1;let D=!1,u=async()=>{return this.pause(),D=!0,{value:void 0,done:!0}};return{next:()=>{if(D)return u();let C=this.read();if(C!==null)return Promise.resolve({done:!1,value:C});if(this[E0])return u();let B,$,E=(Y)=>{this.off("data",Q),this.off("end",X),this.off(t,Z),u(),$(Y)},Q=(Y)=>{this.off("error",E),this.off("end",X),this.off(t,Z),this.pause(),B({value:Y,done:!!this[E0]})},X=()=>{this.off("error",E),this.off("data",Q),this.off(t,Z),u(),B({done:!0,value:void 0})},Z=()=>E(new Error("stream destroyed"));return new Promise((Y,J)=>{$=J,B=Y,this.once(t,Z),this.once("error",E),this.once("end",X),this.once("data",Q)})},throw:u,return:u,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[TD]=!1;let D=!1,u=()=>{return this.pause(),this.off(r2,u),this.off(t,u),this.off("end",u),D=!0,{done:!0,value:void 0}},F=()=>{if(D)return u();let C=this.read();return C===null?u():{done:!1,value:C}};return this.once("end",u),this.once(r2,u),this.once(t,u),{next:F,throw:u,return:u,[Symbol.iterator](){return this}}}destroy(D){if(this[t]){if(D)this.emit("error",D);else this.emit(t);return this}this[t]=!0,this[TD]=!0,this[BD].length=0,this[ED]=0;let u=this;if(typeof u.close==="function"&&!this[BF])u.close();if(D)this.emit("error",D);else this.emit(t);return this}static get isStream(){return YE}}var OE=IE.native,Vu={lstatSync:WE,readdir:LE,readdirSync:RE,readlinkSync:ME,realpathSync:OE,promises:{lstat:jE,readdir:TE,readlink:wE,realpath:kE}},U1=(D)=>!D||D===Vu||D===NE?Vu:{...Vu,...D,promises:{...Vu.promises,...D.promises||{}}},W1=/^\\\\\?\\([a-z]:)\\?$/i,PE=(D)=>D.replace(/\//g,"\\").replace(W1,"$1\\"),SE=/[\\\/]/,hD=0,L1=1,R1=2,eD=4,M1=6,I1=8,W0=10,N1=12,yD=15,qu=~yD,D3=16,H1=32,Au=64,oD=128,XF=256,YF=512,G1=Au|oD|YF,xE=1023,u3=(D)=>D.isFile()?I1:D.isDirectory()?eD:D.isSymbolicLink()?W0:D.isCharacterDevice()?R1:D.isBlockDevice()?M1:D.isSocket()?N1:D.isFIFO()?L1:hD,z1=new Map,Hu=(D)=>{let u=z1.get(D);if(u)return u;let F=D.normalize("NFKD");return z1.set(D,F),F},_1=new Map,ZF=(D)=>{let u=_1.get(D);if(u)return u;let F=Hu(D.toLowerCase());return _1.set(D,F),F};class C3 extends Xu{constructor(){super({max:256})}}class O1 extends Xu{constructor(D=16384){super({maxSize:D,sizeCalculation:(u)=>u.length+1})}}var j1=Symbol("PathScurry setAsCwd");class LD{name;root;roots;parent;nocase;isCWD=!1;#D;#u;get dev(){return this.#u}#E;get mode(){return this.#E}#B;get nlink(){return this.#B}#$;get uid(){return this.#$}#U;get gid(){return this.#U}#z;get rdev(){return this.#z}#Y;get blksize(){return this.#Y}#Q;get ino(){return this.#Q}#K;get size(){return this.#K}#J;get blocks(){return this.#J}#X;get atimeMs(){return this.#X}#F;get mtimeMs(){return this.#F}#V;get ctimeMs(){return this.#V}#W;get birthtimeMs(){return this.#W}#_;get atime(){return this.#_}#A;get mtime(){return this.#A}#j;get ctime(){return this.#j}#H;get birthtime(){return this.#H}#R;#N;#G;#L;#O;#q;#C;#S;#T;#M;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(D,u=hD,F,C,B,$,E){if(this.name=D,this.#R=B?ZF(D):Hu(D),this.#C=u&xE,this.nocase=B,this.roots=C,this.root=F||this,this.#S=$,this.#G=E.fullpath,this.#O=E.relative,this.#q=E.relativePosix,this.parent=E.parent,this.parent)this.#D=this.parent.#D;else this.#D=U1(E.fs)}depth(){if(this.#N!==void 0)return this.#N;if(!this.parent)return this.#N=0;return this.#N=this.parent.depth()+1}childrenCache(){return this.#S}resolve(D){if(!D)return this;let u=this.getRootString(D),C=D.substring(u.length).split(this.splitSep);return u?this.getRoot(u).#m(C):this.#m(C)}#m(D){let u=this;for(let F of D)u=u.child(F);return u}children(){let D=this.#S.get(this);if(D)return D;let u=Object.assign([],{provisional:0});return this.#S.set(this,u),this.#C&=~D3,u}child(D,u){if(D===""||D===".")return this;if(D==="..")return this.parent||this;let F=this.children(),C=this.nocase?ZF(D):Hu(D);for(let Q of F)if(Q.#R===C)return Q;let B=this.parent?this.sep:"",$=this.#G?this.#G+B+D:void 0,E=this.newChild(D,hD,{...u,parent:this,fullpath:$});if(!this.canReaddir())E.#C|=oD;return F.push(E),E}relative(){if(this.isCWD)return"";if(this.#O!==void 0)return this.#O;let D=this.name,u=this.parent;if(!u)return this.#O=this.name;let F=u.relative();return F+(!F||!u.parent?"":this.sep)+D}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#q!==void 0)return this.#q;let D=this.name,u=this.parent;if(!u)return this.#q=this.fullpathPosix();let F=u.relativePosix();return F+(!F||!u.parent?"":"/")+D}fullpath(){if(this.#G!==void 0)return this.#G;let D=this.name,u=this.parent;if(!u)return this.#G=this.name;let C=u.fullpath()+(!u.parent?"":this.sep)+D;return this.#G=C}fullpathPosix(){if(this.#L!==void 0)return this.#L;if(this.sep==="/")return this.#L=this.fullpath();if(!this.parent){let C=this.fullpath().replace(/\\/g,"/");if(/^[a-z]:\//i.test(C))return this.#L=`//?/${C}`;else return this.#L=C}let D=this.parent,u=D.fullpathPosix(),F=u+(!u||!D.parent?"":"/")+this.name;return this.#L=F}isUnknown(){return(this.#C&yD)===hD}isType(D){return this[`is${D}`]()}getType(){return this.isUnknown()?"Unknown":this.isDirectory()?"Directory":this.isFile()?"File":this.isSymbolicLink()?"SymbolicLink":this.isFIFO()?"FIFO":this.isCharacterDevice()?"CharacterDevice":this.isBlockDevice()?"BlockDevice":this.isSocket()?"Socket":"Unknown"}isFile(){return(this.#C&yD)===I1}isDirectory(){return(this.#C&yD)===eD}isCharacterDevice(){return(this.#C&yD)===R1}isBlockDevice(){return(this.#C&yD)===M1}isFIFO(){return(this.#C&yD)===L1}isSocket(){return(this.#C&yD)===N1}isSymbolicLink(){return(this.#C&W0)===W0}lstatCached(){return this.#C&H1?this:void 0}readlinkCached(){return this.#T}realpathCached(){return this.#M}readdirCached(){let D=this.children();return D.slice(0,D.provisional)}canReadlink(){if(this.#T)return!0;if(!this.parent)return!1;let D=this.#C&yD;return!(D!==hD&&D!==W0||this.#C&XF||this.#C&oD)}calledReaddir(){return!!(this.#C&D3)}isENOENT(){return!!(this.#C&oD)}isNamed(D){return!this.nocase?this.#R===Hu(D):this.#R===ZF(D)}async readlink(){let D=this.#T;if(D)return D;if(!this.canReadlink())return;if(!this.parent)return;try{let u=await this.#D.promises.readlink(this.fullpath()),F=(await this.parent.realpath())?.resolve(u);if(F)return this.#T=F}catch(u){this.#d(u.code);return}}readlinkSync(){let D=this.#T;if(D)return D;if(!this.canReadlink())return;if(!this.parent)return;try{let u=this.#D.readlinkSync(this.fullpath()),F=this.parent.realpathSync()?.resolve(u);if(F)return this.#T=F}catch(u){this.#d(u.code);return}}#I(D){this.#C|=D3;for(let u=D.provisional;uF(null,D))}readdirCB(D,u=!1){if(!this.canReaddir()){if(u)D(null,[]);else queueMicrotask(()=>D(null,[]));return}let F=this.children();if(this.calledReaddir()){let B=F.slice(0,F.provisional);if(u)D(null,B);else queueMicrotask(()=>D(null,B));return}if(this.#k.push(D),this.#g)return;this.#g=!0;let C=this.fullpath();this.#D.readdir(C,{withFileTypes:!0},(B,$)=>{if(B)this.#w(B.code),F.provisional=0;else{for(let E of $)this.#v(E,F);this.#I(F)}this.#a(F.slice(0,F.provisional));return})}#p;async readdir(){if(!this.canReaddir())return[];let D=this.children();if(this.calledReaddir())return D.slice(0,D.provisional);let u=this.fullpath();if(this.#p)await this.#p;else{let F=()=>{};this.#p=new Promise((C)=>F=C);try{for(let C of await this.#D.promises.readdir(u,{withFileTypes:!0}))this.#v(C,D);this.#I(D)}catch(C){this.#w(C.code),D.provisional=0}this.#p=void 0,F()}return D.slice(0,D.provisional)}readdirSync(){if(!this.canReaddir())return[];let D=this.children();if(this.calledReaddir())return D.slice(0,D.provisional);let u=this.fullpath();try{for(let F of this.#D.readdirSync(u,{withFileTypes:!0}))this.#v(F,D);this.#I(D)}catch(F){this.#w(F.code),D.provisional=0}return D.slice(0,D.provisional)}canReaddir(){if(this.#C&G1)return!1;let D=yD&this.#C;if(!(D===hD||D===eD||D===W0))return!1;return!0}shouldWalk(D,u){return(this.#C&eD)===eD&&!(this.#C&G1)&&!D.has(this)&&(!u||u(this))}async realpath(){if(this.#M)return this.#M;if((YF|XF|oD)&this.#C)return;try{let D=await this.#D.promises.realpath(this.fullpath());return this.#M=this.resolve(D)}catch(D){this.#h()}}realpathSync(){if(this.#M)return this.#M;if((YF|XF|oD)&this.#C)return;try{let D=this.#D.realpathSync(this.fullpath());return this.#M=this.resolve(D)}catch(D){this.#h()}}[j1](D){if(D===this)return;D.isCWD=!1,this.isCWD=!0;let u=new Set([]),F=[],C=this;while(C&&C.parent)u.add(C),C.#O=F.join(this.sep),C.#q=F.join("/"),C=C.parent,F.push("..");C=D;while(C&&C.parent&&!u.has(C))C.#O=void 0,C.#q=void 0,C=C.parent}}class JF extends LD{sep="\\";splitSep=SE;constructor(D,u=hD,F,C,B,$,E){super(D,u,F,C,B,$,E)}newChild(D,u=hD,F={}){return new JF(D,u,this.root,this.roots,this.nocase,this.childrenCache(),F)}getRootString(D){return F3.parse(D).root}getRoot(D){if(D=PE(D.toUpperCase()),D===this.root.name)return this.root;for(let[u,F]of Object.entries(this.roots))if(this.sameRoot(D,u))return this.roots[D]=F;return this.roots[D]=new Gu(D,this).root}sameRoot(D,u=this.root.name){return D=D.toUpperCase().replace(/\//g,"\\").replace(W1,"$1\\"),D===u}}class KF extends LD{splitSep="/";sep="/";constructor(D,u=hD,F,C,B,$,E){super(D,u,F,C,B,$,E)}getRootString(D){return D.startsWith("/")?"/":""}getRoot(D){return this.root}newChild(D,u=hD,F={}){return new KF(D,u,this.root,this.roots,this.nocase,this.childrenCache(),F)}}class B3{root;rootPath;roots;cwd;#D;#u;#E;nocase;#B;constructor(D=process.cwd(),u,F,{nocase:C,childrenCacheSize:B=16384,fs:$=Vu}={}){if(this.#B=U1($),D instanceof URL||D.startsWith("file://"))D=UE(D);let E=u.resolve(D);this.roots=Object.create(null),this.rootPath=this.parseRootPath(E),this.#D=new C3,this.#u=new C3,this.#E=new O1(B);let Q=E.substring(this.rootPath.length).split(F);if(Q.length===1&&!Q[0])Q.pop();if(C===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=C,this.root=this.newRoot(this.#B),this.roots[this.rootPath]=this.root;let X=this.root,Z=Q.length-1,Y=u.sep,J=this.rootPath,A=!1;for(let H of Q){let G=Z--;X=X.child(H,{relative:new Array(G).fill("..").join(Y),relativePosix:new Array(G).fill("..").join("/"),fullpath:J+=(A?"":Y)+H}),A=!0}this.cwd=X}depth(D=this.cwd){if(typeof D==="string")D=this.cwd.resolve(D);return D.depth()}childrenCache(){return this.#E}resolve(...D){let u="";for(let B=D.length-1;B>=0;B--){let $=D[B];if(!$||$===".")continue;if(u=u?`${$}/${u}`:$,this.isAbsolute($))break}let F=this.#D.get(u);if(F!==void 0)return F;let C=this.cwd.resolve(u).fullpath();return this.#D.set(u,C),C}resolvePosix(...D){let u="";for(let B=D.length-1;B>=0;B--){let $=D[B];if(!$||$===".")continue;if(u=u?`${$}/${u}`:$,this.isAbsolute($))break}let F=this.#u.get(u);if(F!==void 0)return F;let C=this.cwd.resolve(u).fullpathPosix();return this.#u.set(u,C),C}relative(D=this.cwd){if(typeof D==="string")D=this.cwd.resolve(D);return D.relative()}relativePosix(D=this.cwd){if(typeof D==="string")D=this.cwd.resolve(D);return D.relativePosix()}basename(D=this.cwd){if(typeof D==="string")D=this.cwd.resolve(D);return D.name}dirname(D=this.cwd){if(typeof D==="string")D=this.cwd.resolve(D);return(D.parent||D).fullpath()}async readdir(D=this.cwd,u={withFileTypes:!0}){if(typeof D==="string")D=this.cwd.resolve(D);else if(!(D instanceof LD))u=D,D=this.cwd;let{withFileTypes:F}=u;if(!D.canReaddir())return[];else{let C=await D.readdir();return F?C:C.map((B)=>B.name)}}readdirSync(D=this.cwd,u={withFileTypes:!0}){if(typeof D==="string")D=this.cwd.resolve(D);else if(!(D instanceof LD))u=D,D=this.cwd;let{withFileTypes:F=!0}=u;if(!D.canReaddir())return[];else if(F)return D.readdirSync();else return D.readdirSync().map((C)=>C.name)}async lstat(D=this.cwd){if(typeof D==="string")D=this.cwd.resolve(D);return D.lstat()}lstatSync(D=this.cwd){if(typeof D==="string")D=this.cwd.resolve(D);return D.lstatSync()}async readlink(D=this.cwd,{withFileTypes:u}={withFileTypes:!1}){if(typeof D==="string")D=this.cwd.resolve(D);else if(!(D instanceof LD))u=D.withFileTypes,D=this.cwd;let F=await D.readlink();return u?F:F?.fullpath()}readlinkSync(D=this.cwd,{withFileTypes:u}={withFileTypes:!1}){if(typeof D==="string")D=this.cwd.resolve(D);else if(!(D instanceof LD))u=D.withFileTypes,D=this.cwd;let F=D.readlinkSync();return u?F:F?.fullpath()}async realpath(D=this.cwd,{withFileTypes:u}={withFileTypes:!1}){if(typeof D==="string")D=this.cwd.resolve(D);else if(!(D instanceof LD))u=D.withFileTypes,D=this.cwd;let F=await D.realpath();return u?F:F?.fullpath()}realpathSync(D=this.cwd,{withFileTypes:u}={withFileTypes:!1}){if(typeof D==="string")D=this.cwd.resolve(D);else if(!(D instanceof LD))u=D.withFileTypes,D=this.cwd;let F=D.realpathSync();return u?F:F?.fullpath()}async walk(D=this.cwd,u={}){if(typeof D==="string")D=this.cwd.resolve(D);else if(!(D instanceof LD))u=D,D=this.cwd;let{withFileTypes:F=!0,follow:C=!1,filter:B,walkFilter:$}=u,E=[];if(!B||B(D))E.push(F?D:D.fullpath());let Q=new Set,X=(Y,J)=>{Q.add(Y),Y.readdirCB((A,H)=>{if(A)return J(A);let G=H.length;if(!G)return J();let z=()=>{if(--G===0)J()};for(let U of H){if(!B||B(U))E.push(F?U:U.fullpath());if(C&&U.isSymbolicLink())U.realpath().then((I)=>I?.isUnknown()?I.lstat():I).then((I)=>I?.shouldWalk(Q,$)?X(I,z):z());else if(U.shouldWalk(Q,$))X(U,z);else z()}},!0)},Z=D;return new Promise((Y,J)=>{X(Z,(A)=>{if(A)return J(A);Y(E)})})}walkSync(D=this.cwd,u={}){if(typeof D==="string")D=this.cwd.resolve(D);else if(!(D instanceof LD))u=D,D=this.cwd;let{withFileTypes:F=!0,follow:C=!1,filter:B,walkFilter:$}=u,E=[];if(!B||B(D))E.push(F?D:D.fullpath());let Q=new Set([D]);for(let X of Q){let Z=X.readdirSync();for(let Y of Z){if(!B||B(Y))E.push(F?Y:Y.fullpath());let J=Y;if(Y.isSymbolicLink()){if(!(C&&(J=Y.realpathSync())))continue;if(J.isUnknown())J.lstatSync()}if(J.shouldWalk(Q,$))Q.add(J)}}return E}[Symbol.asyncIterator](){return this.iterate()}iterate(D=this.cwd,u={}){if(typeof D==="string")D=this.cwd.resolve(D);else if(!(D instanceof LD))u=D,D=this.cwd;return this.stream(D,u)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(D=this.cwd,u={}){if(typeof D==="string")D=this.cwd.resolve(D);else if(!(D instanceof LD))u=D,D=this.cwd;let{withFileTypes:F=!0,follow:C=!1,filter:B,walkFilter:$}=u;if(!B||B(D))yield F?D:D.fullpath();let E=new Set([D]);for(let Q of E){let X=Q.readdirSync();for(let Z of X){if(!B||B(Z))yield F?Z:Z.fullpath();let Y=Z;if(Z.isSymbolicLink()){if(!(C&&(Y=Z.realpathSync())))continue;if(Y.isUnknown())Y.lstatSync()}if(Y.shouldWalk(E,$))E.add(Y)}}}stream(D=this.cwd,u={}){if(typeof D==="string")D=this.cwd.resolve(D);else if(!(D instanceof LD))u=D,D=this.cwd;let{withFileTypes:F=!0,follow:C=!1,filter:B,walkFilter:$}=u,E=new U0({objectMode:!0});if(!B||B(D))E.write(F?D:D.fullpath());let Q=new Set,X=[D],Z=0,Y=()=>{let J=!1;while(!J){let A=X.shift();if(!A){if(Z===0)E.end();return}Z++,Q.add(A);let H=(z,U,I=!1)=>{if(z)return E.emit("error",z);if(C&&!I){let j=[];for(let R of U)if(R.isSymbolicLink())j.push(R.realpath().then((M)=>M?.isUnknown()?M.lstat():M));if(j.length){Promise.all(j).then(()=>H(null,U,!0));return}}for(let j of U)if(j&&(!B||B(j))){if(!E.write(F?j:j.fullpath()))J=!0}Z--;for(let j of U){let R=j.realpathCached()||j;if(R.shouldWalk(Q,$))X.push(R)}if(J&&!E.flowing)E.once("drain",Y);else if(!G)Y()},G=!0;A.readdirCB(H,!0),G=!1}};return Y(),E}streamSync(D=this.cwd,u={}){if(typeof D==="string")D=this.cwd.resolve(D);else if(!(D instanceof LD))u=D,D=this.cwd;let{withFileTypes:F=!0,follow:C=!1,filter:B,walkFilter:$}=u,E=new U0({objectMode:!0}),Q=new Set;if(!B||B(D))E.write(F?D:D.fullpath());let X=[D],Z=0,Y=()=>{let J=!1;while(!J){let A=X.shift();if(!A){if(Z===0)E.end();return}Z++,Q.add(A);let H=A.readdirSync();for(let G of H)if(!B||B(G)){if(!E.write(F?G:G.fullpath()))J=!0}Z--;for(let G of H){let z=G;if(G.isSymbolicLink()){if(!(C&&(z=G.realpathSync())))continue;if(z.isUnknown())z.lstatSync()}if(z.shouldWalk(Q,$))X.push(z)}}if(J&&!E.flowing)E.once("drain",Y)};return Y(),E}chdir(D=this.cwd){let u=this.cwd;this.cwd=typeof D==="string"?this.cwd.resolve(D):D,this.cwd[j1](u)}}class Gu extends B3{sep="\\";constructor(D=process.cwd(),u={}){let{nocase:F=!0}=u;super(D,F3,"\\",{...u,nocase:F});this.nocase=F;for(let C=this.cwd;C;C=C.parent)C.nocase=this.nocase}parseRootPath(D){return F3.parse(D).root.toUpperCase()}newRoot(D){return new JF(this.rootPath,eD,void 0,this.roots,this.nocase,this.childrenCache(),{fs:D})}isAbsolute(D){return D.startsWith("/")||D.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(D)}}class zu extends B3{sep="/";constructor(D=process.cwd(),u={}){let{nocase:F=!1}=u;super(D,_E,"/",{...u,nocase:F});this.nocase=F}parseRootPath(D){return"/"}newRoot(D){return new KF(this.rootPath,eD,void 0,this.roots,this.nocase,this.childrenCache(),{fs:D})}isAbsolute(D){return D.startsWith("/")}}class qF extends zu{constructor(D=process.cwd(),u={}){let{nocase:F=!0}=u;super(D,{...u,nocase:F})}}var FY=process.platform==="win32"?JF:KF,T1=process.platform==="win32"?Gu:process.platform==="darwin"?qF:zu;var bE=(D)=>D.length>=1,vE=(D)=>D.length>=1;class b0{#D;#u;#E;length;#B;#$;#U;#z;#Y;#Q;#K=!0;constructor(D,u,F,C){if(!bE(D))throw new TypeError("empty pattern list");if(!vE(u))throw new TypeError("empty glob list");if(u.length!==D.length)throw new TypeError("mismatched pattern list and glob list lengths");if(this.length=D.length,F<0||F>=this.length)throw new TypeError("index out of range");if(this.#D=D,this.#u=u,this.#E=F,this.#B=C,this.#E===0){if(this.isUNC()){let[B,$,E,Q,...X]=this.#D,[Z,Y,J,A,...H]=this.#u;if(X[0]==="")X.shift(),H.shift();let G=[B,$,E,Q,""].join("/"),z=[Z,Y,J,A,""].join("/");this.#D=[G,...X],this.#u=[z,...H],this.length=this.#D.length}else if(this.isDrive()||this.isAbsolute()){let[B,...$]=this.#D,[E,...Q]=this.#u;if($[0]==="")$.shift(),Q.shift();let X=B+"/",Z=E+"/";this.#D=[X,...$],this.#u=[Z,...Q],this.length=this.#D.length}}}pattern(){return this.#D[this.#E]}isString(){return typeof this.#D[this.#E]==="string"}isGlobstar(){return this.#D[this.#E]===XD}isRegExp(){return this.#D[this.#E]instanceof RegExp}globString(){return this.#U=this.#U||(this.#E===0?this.isAbsolute()?this.#u[0]+this.#u.slice(1).join("/"):this.#u.join("/"):this.#u.slice(this.#E).join("/"))}hasMore(){return this.length>this.#E+1}rest(){if(this.#$!==void 0)return this.#$;if(!this.hasMore())return this.#$=null;return this.#$=new b0(this.#D,this.#u,this.#E+1,this.#B),this.#$.#Q=this.#Q,this.#$.#Y=this.#Y,this.#$.#z=this.#z,this.#$}isUNC(){let D=this.#D;return this.#Y!==void 0?this.#Y:this.#Y=this.#B==="win32"&&this.#E===0&&D[0]===""&&D[1]===""&&typeof D[2]==="string"&&!!D[2]&&typeof D[3]==="string"&&!!D[3]}isDrive(){let D=this.#D;return this.#z!==void 0?this.#z:this.#z=this.#B==="win32"&&this.#E===0&&this.length>1&&typeof D[0]==="string"&&/^[a-z]:$/i.test(D[0])}isAbsolute(){let D=this.#D;return this.#Q!==void 0?this.#Q:this.#Q=D[0]===""&&D.length>1||this.isDrive()||this.isUNC()}root(){let D=this.#D[0];return typeof D==="string"&&this.isAbsolute()&&this.#E===0?D:""}checkFollowGlobstar(){return!(this.#E===0||!this.isGlobstar()||!this.#K)}markFollowGlobstar(){if(this.#E===0||!this.isGlobstar()||!this.#K)return!1;return this.#K=!1,!0}}var fE=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class _u{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(D,{nobrace:u,nocase:F,noext:C,noglobstar:B,platform:$=fE}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=$,this.mmopts={dot:!0,nobrace:u,nocase:F,noext:C,noglobstar:B,optimizationLevel:2,platform:$,nocomment:!0,nonegate:!0};for(let E of D)this.add(E)}add(D){let u=new fD(D,this.mmopts);for(let F=0;F[D,!!(u&2),!!(u&1)])}}class k1{store=new Map;add(D,u){if(!D.canReaddir())return;let F=this.store.get(D);if(F){if(!F.find((C)=>C.globString()===u.globString()))F.push(u)}else this.store.set(D,[u])}get(D){let u=this.store.get(D);if(!u)throw new Error("attempting to walk unknown path");return u}entries(){return this.keys().map((D)=>[D,this.store.get(D)])}keys(){return[...this.store.keys()].filter((D)=>D.canReaddir())}}class Uu{hasWalkedCache;matches=new w1;subwalks=new k1;patterns;follow;dot;opts;constructor(D,u){this.opts=D,this.follow=!!D.follow,this.dot=!!D.dot,this.hasWalkedCache=u?u.copy():new E3}processPatterns(D,u){this.patterns=u;let F=u.map((C)=>[D,C]);for(let[C,B]of F){this.hasWalkedCache.storeWalked(C,B);let $=B.root(),E=B.isAbsolute()&&this.opts.absolute!==!1;if($){C=C.resolve($==="/"&&this.opts.root!==void 0?this.opts.root:$);let Y=B.rest();if(!Y){this.matches.add(C,!0,!1);continue}else B=Y}if(C.isENOENT())continue;let Q,X,Z=!1;while(typeof(Q=B.pattern())==="string"&&(X=B.rest()))C=C.resolve(Q),B=X,Z=!0;if(Q=B.pattern(),X=B.rest(),Z){if(this.hasWalkedCache.hasWalked(C,B))continue;this.hasWalkedCache.storeWalked(C,B)}if(typeof Q==="string"){let Y=Q===".."||Q===""||Q===".";this.matches.add(C.resolve(Q),E,Y);continue}else if(Q===XD){if(!C.isSymbolicLink()||this.follow||B.checkFollowGlobstar())this.subwalks.add(C,B);let Y=X?.pattern(),J=X?.rest();if(!X||(Y===""||Y===".")&&!J)this.matches.add(C,E,Y===""||Y===".");else if(Y===".."){let A=C.parent||C;if(!J)this.matches.add(A,E,!0);else if(!this.hasWalkedCache.hasWalked(A,J))this.subwalks.add(A,J)}}else if(Q instanceof RegExp)this.subwalks.add(C,B)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new Uu(this.opts,this.hasWalkedCache)}filterEntries(D,u){let F=this.subwalks.get(D),C=this.child();for(let B of u)for(let $ of F){let E=$.isAbsolute(),Q=$.pattern(),X=$.rest();if(Q===XD)C.testGlobstar(B,$,X,E);else if(Q instanceof RegExp)C.testRegExp(B,Q,X,E);else C.testString(B,Q,X,E)}return C}testGlobstar(D,u,F,C){if(this.dot||!D.name.startsWith(".")){if(!u.hasMore())this.matches.add(D,C,!1);if(D.canReaddir()){if(this.follow||!D.isSymbolicLink())this.subwalks.add(D,u);else if(D.isSymbolicLink()){if(F&&u.checkFollowGlobstar())this.subwalks.add(D,F);else if(u.markFollowGlobstar())this.subwalks.add(D,u)}}}if(F){let B=F.pattern();if(typeof B==="string"&&B!==".."&&B!==""&&B!==".")this.testString(D,B,F.rest(),C);else if(B===".."){let $=D.parent||D;this.subwalks.add($,F)}else if(B instanceof RegExp)this.testRegExp(D,B,F.rest(),C)}}testRegExp(D,u,F,C){if(!u.test(D.name))return;if(!F)this.matches.add(D,C,!1);else this.subwalks.add(D,F)}testString(D,u,F,C){if(!D.isNamed(u))return;if(!F)this.matches.add(D,C,!1);else this.subwalks.add(D,F)}}var yE=(D,u)=>typeof D==="string"?new _u([D],u):Array.isArray(D)?new _u(D,u):D;class $3{path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#D=[];#u;#E;signal;maxDepth;includeChildMatches;constructor(D,u,F){if(this.patterns=D,this.path=u,this.opts=F,this.#E=!F.posix&&F.platform==="win32"?"\\":"/",this.includeChildMatches=F.includeChildMatches!==!1,F.ignore||!this.includeChildMatches){if(this.#u=yE(F.ignore??[],F),!this.includeChildMatches&&typeof this.#u.add!=="function")throw new Error("cannot ignore child matches, ignore lacks add() method.")}if(this.maxDepth=F.maxDepth||1/0,F.signal)this.signal=F.signal,this.signal.addEventListener("abort",()=>{this.#D.length=0})}#B(D){return this.seen.has(D)||!!this.#u?.ignored?.(D)}#$(D){return!!this.#u?.childrenIgnored?.(D)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let D=void 0;while(!this.paused&&(D=this.#D.shift()))D()}onResume(D){if(this.signal?.aborted)return;if(!this.paused)D();else this.#D.push(D)}async matchCheck(D,u){if(u&&this.opts.nodir)return;let F;if(this.opts.realpath){if(F=D.realpathCached()||await D.realpath(),!F)return;D=F}let B=D.isUnknown()||this.opts.stat?await D.lstat():D;if(this.opts.follow&&this.opts.nodir&&B?.isSymbolicLink()){let $=await B.realpath();if($&&($.isUnknown()||this.opts.stat))await $.lstat()}return this.matchCheckTest(B,u)}matchCheckTest(D,u){return D&&(this.maxDepth===1/0||D.depth()<=this.maxDepth)&&(!u||D.canReaddir())&&(!this.opts.nodir||!D.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!D.isSymbolicLink()||!D.realpathCached()?.isDirectory())&&!this.#B(D)?D:void 0}matchCheckSync(D,u){if(u&&this.opts.nodir)return;let F;if(this.opts.realpath){if(F=D.realpathCached()||D.realpathSync(),!F)return;D=F}let B=D.isUnknown()||this.opts.stat?D.lstatSync():D;if(this.opts.follow&&this.opts.nodir&&B?.isSymbolicLink()){let $=B.realpathSync();if($&&($?.isUnknown()||this.opts.stat))$.lstatSync()}return this.matchCheckTest(B,u)}matchFinish(D,u){if(this.#B(D))return;if(!this.includeChildMatches&&this.#u?.add){let B=`${D.relativePosix()}/**`;this.#u.add(B)}let F=this.opts.absolute===void 0?u:this.opts.absolute;this.seen.add(D);let C=this.opts.mark&&D.isDirectory()?this.#E:"";if(this.opts.withFileTypes)this.matchEmit(D);else if(F){let B=this.opts.posix?D.fullpathPosix():D.fullpath();this.matchEmit(B+C)}else{let B=this.opts.posix?D.relativePosix():D.relative(),$=this.opts.dotRelative&&!B.startsWith(".."+this.#E)?"."+this.#E:"";this.matchEmit(!B?"."+C:$+B+C)}}async match(D,u,F){let C=await this.matchCheck(D,F);if(C)this.matchFinish(C,u)}matchSync(D,u,F){let C=this.matchCheckSync(D,F);if(C)this.matchFinish(C,u)}walkCB(D,u,F){if(this.signal?.aborted)F();this.walkCB2(D,u,new Uu(this.opts),F)}walkCB2(D,u,F,C){if(this.#$(D))return C();if(this.signal?.aborted)C();if(this.paused){this.onResume(()=>this.walkCB2(D,u,F,C));return}F.processPatterns(D,u);let B=1,$=()=>{if(--B===0)C()};for(let[E,Q,X]of F.matches.entries()){if(this.#B(E))continue;B++,this.match(E,Q,X).then(()=>$())}for(let E of F.subwalkTargets()){if(this.maxDepth!==1/0&&E.depth()>=this.maxDepth)continue;B++;let Q=E.readdirCached();if(E.calledReaddir())this.walkCB3(E,Q,F,$);else E.readdirCB((X,Z)=>this.walkCB3(E,Z,F,$),!0)}$()}walkCB3(D,u,F,C){F=F.filterEntries(D,u);let B=1,$=()=>{if(--B===0)C()};for(let[E,Q,X]of F.matches.entries()){if(this.#B(E))continue;B++,this.match(E,Q,X).then(()=>$())}for(let[E,Q]of F.subwalks.entries())B++,this.walkCB2(E,Q,F.child(),$);$()}walkCBSync(D,u,F){if(this.signal?.aborted)F();this.walkCB2Sync(D,u,new Uu(this.opts),F)}walkCB2Sync(D,u,F,C){if(this.#$(D))return C();if(this.signal?.aborted)C();if(this.paused){this.onResume(()=>this.walkCB2Sync(D,u,F,C));return}F.processPatterns(D,u);let B=1,$=()=>{if(--B===0)C()};for(let[E,Q,X]of F.matches.entries()){if(this.#B(E))continue;this.matchSync(E,Q,X)}for(let E of F.subwalkTargets()){if(this.maxDepth!==1/0&&E.depth()>=this.maxDepth)continue;B++;let Q=E.readdirSync();this.walkCB3Sync(E,Q,F,$)}$()}walkCB3Sync(D,u,F,C){F=F.filterEntries(D,u);let B=1,$=()=>{if(--B===0)C()};for(let[E,Q,X]of F.matches.entries()){if(this.#B(E))continue;this.matchSync(E,Q,X)}for(let[E,Q]of F.subwalks.entries())B++,this.walkCB2Sync(E,Q,F.child(),$);$()}}class VF extends $3{matches=new Set;constructor(D,u,F){super(D,u,F)}matchEmit(D){this.matches.add(D)}async walk(){if(this.signal?.aborted)throw this.signal.reason;if(this.path.isUnknown())await this.path.lstat();return await new Promise((D,u)=>{this.walkCB(this.path,this.patterns,()=>{if(this.signal?.aborted)u(this.signal.reason);else D(this.matches)})}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;if(this.path.isUnknown())this.path.lstatSync();return this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}}class AF extends $3{results;constructor(D,u,F){super(D,u,F);this.results=new U0({signal:this.signal,objectMode:!0}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume())}matchEmit(D){if(this.results.write(D),!this.results.flowing)this.pause()}stream(){let D=this.path;if(D.isUnknown())D.lstat().then(()=>{this.walkCB(D,this.patterns,()=>this.results.end())});else this.walkCB(D,this.patterns,()=>this.results.end());return this.results}streamSync(){if(this.path.isUnknown())this.path.lstatSync();return this.walkCBSync(this.path,this.patterns,()=>this.results.end()),this.results}}var gE=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class D0{absolute;cwd;root;dot;dotRelative;follow;ignore;magicalBraces;mark;matchBase;maxDepth;nobrace;nocase;nodir;noext;noglobstar;pattern;platform;realpath;scurry;stat;signal;windowsPathsNoEscape;withFileTypes;includeChildMatches;opts;patterns;constructor(D,u){if(!u)throw new TypeError("glob options required");if(this.withFileTypes=!!u.withFileTypes,this.signal=u.signal,this.follow=!!u.follow,this.dot=!!u.dot,this.dotRelative=!!u.dotRelative,this.nodir=!!u.nodir,this.mark=!!u.mark,!u.cwd)this.cwd="";else if(u.cwd instanceof URL||u.cwd.startsWith("file://"))u.cwd=hE(u.cwd);if(this.cwd=u.cwd||"",this.root=u.root,this.magicalBraces=!!u.magicalBraces,this.nobrace=!!u.nobrace,this.noext=!!u.noext,this.realpath=!!u.realpath,this.absolute=u.absolute,this.includeChildMatches=u.includeChildMatches!==!1,this.noglobstar=!!u.noglobstar,this.matchBase=!!u.matchBase,this.maxDepth=typeof u.maxDepth==="number"?u.maxDepth:1/0,this.stat=!!u.stat,this.ignore=u.ignore,this.withFileTypes&&this.absolute!==void 0)throw new Error("cannot set absolute and withFileTypes:true");if(typeof D==="string")D=[D];if(this.windowsPathsNoEscape=!!u.windowsPathsNoEscape||u.allowWindowsEscape===!1,this.windowsPathsNoEscape)D=D.map((Q)=>Q.replace(/\\/g,"/"));if(this.matchBase){if(u.noglobstar)throw new TypeError("base matching requires globstar");D=D.map((Q)=>Q.includes("/")?Q:`./**/${Q}`)}if(this.pattern=D,this.platform=u.platform||gE,this.opts={...u,platform:this.platform},u.scurry){if(this.scurry=u.scurry,u.nocase!==void 0&&u.nocase!==u.scurry.nocase)throw new Error("nocase option contradicts provided scurry option")}else{let Q=u.platform==="win32"?Gu:u.platform==="darwin"?qF:u.platform?zu:T1;this.scurry=new Q(this.cwd,{nocase:u.nocase,fs:u.fs})}this.nocase=this.scurry.nocase;let F=this.platform==="darwin"||this.platform==="win32",C={...u,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:F,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},B=this.pattern.map((Q)=>new fD(Q,C)),[$,E]=B.reduce((Q,X)=>{return Q[0].push(...X.set),Q[1].push(...X.globParts),Q},[[],[]]);this.patterns=$.map((Q,X)=>{let Z=E[X];if(!Z)throw new Error("invalid pattern object");return new b0(Q,Z,0,this.platform)})}async walk(){return[...await new VF(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walk()]}walkSync(){return[...new VF(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walkSync()]}stream(){return new AF(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).stream()}streamSync(){return new AF(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).streamSync()}iterateSync(){return this.streamSync()[Symbol.iterator]()}[Symbol.iterator](){return this.iterateSync()}iterate(){return this.stream()[Symbol.asyncIterator]()}[Symbol.asyncIterator](){return this.iterate()}}var Q3=(D,u={})=>{if(!Array.isArray(D))D=[D];for(let F of D)if(new fD(F,u).hasMagic())return!0;return!1};function GF(D,u={}){return new D0(D,u).streamSync()}function S1(D,u={}){return new D0(D,u).stream()}function x1(D,u={}){return new D0(D,u).walkSync()}async function P1(D,u={}){return new D0(D,u).walk()}function zF(D,u={}){return new D0(D,u).iterateSync()}function b1(D,u={}){return new D0(D,u).iterate()}var mE=GF,dE=Object.assign(S1,{sync:GF}),cE=zF,lE=Object.assign(b1,{sync:zF}),pE=Object.assign(x1,{stream:GF,iterate:zF}),HF=Object.assign(P1,{glob:P1,globSync:x1,sync:pE,globStream:S1,stream:dE,globStreamSync:GF,streamSync:mE,globIterate:b1,iterate:lE,globIterateSync:zF,iterateSync:cE,Glob:D0,hasMagic:Q3,escape:k0,unescape:rD});HF.glob=HF;qD();async function f1(D,u={}){let F=k.getInstance().getTrashDirectory();if(!v1(F))nE(F,{recursive:!0});let C=Array.isArray(D)?D:[D];for(let B of C){let $=await HF(B),E=$.length>0?$:[B];for(let Q of E)try{if(!v1(Q)){if(!u.force){console.error(`trash: ${Q}: No such file or directory`);continue}continue}if(rE(Q).isDirectory()&&!u.recursive){if(!u.force){console.error(`trash: ${Q}: is a directory`);continue}}let Z=oE(Q),Y=Date.now(),J=iE(F,`${Z}.${Y}`);aE(Q,J),console.log(`Moved ${Z} to trash`)}catch(X){if(!u.force){let Z=X instanceof Error?X.message:String(X);console.error(`trash: ${Q}: ${Z}`)}}}}import{readdirSync as h1,statSync as g1}from"fs";import{join as m1}from"path";qD();function sE(D){let u=D.lastIndexOf(".");if(u===-1)return{name:D,timestamp:0};let F=parseInt(D.substring(u+1));if(isNaN(F))return{name:D,timestamp:0};return{name:D.substring(0,u),timestamp:F}}function y1(D){if(D===0)return"0 B";let u=1024,F=["B","KB","MB","GB"],C=Math.floor(Math.log(D)/Math.log(u));return parseFloat((D/Math.pow(u,C)).toFixed(2))+" "+F[C]}function d1(D){let u=0,F=h1(D);for(let C of F){let B=m1(D,C),$=g1(B);if($.isDirectory())u+=d1(B);else u+=$.size}return u}async function c1(){let D=k.getInstance().getTrashDirectory();try{let u=h1(D);if(u.length===0){GD.info("\uD83D\uDDD1\uFE0F Trash is empty");return}let F=u.map((E)=>{let Q=m1(D,E),X=g1(Q),{name:Z,timestamp:Y}=sE(E),J=X.isDirectory()?d1(Q):X.size;return{originalName:Z,trashedName:E,size:J,trashedAt:new Date(Y),isDirectory:X.isDirectory()}});F.sort((E,Q)=>Q.trashedAt.getTime()-E.trashedAt.getTime()),console.log(` +>>> no match, partial?`,D,J,u,A),J===Q)return!0}return!1}let G;if(typeof Z==="string")G=Y===Z,this.debug("string match",Z,Y,G);else G=Z.test(Y),this.debug("pattern match",Z,Y,G);if(!G)return!1}if($===Q&&E===X)return!0;else if($===Q)return F;else if(E===X)return $===Q-1&&D[$]==="";else throw new Error("wtf?")}braceExpand(){return $1(this.pattern,this.options)}parse(D){Eu(D);let u=this.options;if(D==="**")return XD;if(D==="")return"";let F,C=null;if(F=D.match(p4))C=u.dot?n4:a4;else if(F=D.match(b4))C=(u.nocase?u.dot?h4:y4:u.dot?f4:v4)(F[1]);else if(F=D.match(r4))C=(u.nocase?u.dot?o4:i4:u.dot?s4:t4)(F);else if(F=D.match(g4))C=u.dot?d4:m4;else if(F=D.match(c4))C=l4;let B=QD.fromGlob(D,this.options).toMMPattern();if(C&&typeof B==="object")Reflect.defineProperty(B,"test",{value:C});return B}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let D=this.set;if(!D.length)return this.regexp=!1,this.regexp;let u=this.options,F=u.noglobstar?uE:u.dot?FE:CE,C=new Set(u.nocase?["i"]:[]),B=D.map((Q)=>{let X=Q.map((Z)=>{if(Z instanceof RegExp)for(let Y of Z.flags.split(""))C.add(Y);return typeof Z==="string"?XE(Z):Z===XD?XD:Z._src});return X.forEach((Z,Y)=>{let J=X[Y+1],A=X[Y-1];if(Z!==XD||A===XD)return;if(A===void 0)if(J!==void 0&&J!==XD)X[Y+1]="(?:\\/|"+F+"\\/)?"+J;else X[Y]=F;else if(J===void 0)X[Y-1]=A+"(?:\\/|"+F+")?";else if(J!==XD)X[Y-1]=A+"(?:\\/|\\/"+F+"\\/)"+J,X[Y+1]=XD}),X.filter((Z)=>Z!==XD).join("/")}).join("|"),[$,E]=D.length>1?["(?:",")"]:["",""];if(B="^"+$+B+E+"$",this.negate)B="^(?!"+B+").+$";try{this.regexp=new RegExp(B,[...C].join(""))}catch(Q){this.regexp=!1}return this.regexp}slashSplit(D){if(this.preserveMultipleSlashes)return D.split("/");else if(this.isWindows&&/^\/\/[^\/]+/.test(D))return["",...D.split(/\/+/)];else return D.split(/\/+/)}match(D,u=this.partial){if(this.debug("match",D,this.pattern),this.comment)return!1;if(this.empty)return D==="";if(D==="/"&&u)return!0;let F=this.options;if(this.isWindows)D=D.split("\\").join("/");let C=this.slashSplit(D);this.debug(this.pattern,"split",C);let B=this.set;this.debug(this.pattern,"set",B);let $=C[C.length-1];if(!$)for(let E=C.length-2;!$&&E>=0;E--)$=C[E];for(let E=0;E{typeof a2.emitWarning==="function"?a2.emitWarning(D,u,F,C):console.error(`[${F}] ${u}: ${D}`)},FF=globalThis.AbortController,Q1=globalThis.AbortSignal;if(typeof FF==="undefined"){Q1=class F{onabort;_onabort=[];reason;aborted=!1;addEventListener(C,B){this._onabort.push(B)}},FF=class F{constructor(){u()}signal=new Q1;abort(C){if(this.signal.aborted)return;this.signal.reason=C,this.signal.aborted=!0;for(let B of this.signal._onabort)B(C);this.signal.onabort?.(C)}};let D=a2.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",u=()=>{if(!D)return;D=!1,Z1("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",u)}}var YE=(D)=>!X1.has(D),aZ=Symbol("type"),V0=(D)=>D&&D===Math.floor(D)&&D>0&&isFinite(D),Y1=(D)=>!V0(D)?null:D<=Math.pow(2,8)?Uint8Array:D<=Math.pow(2,16)?Uint16Array:D<=Math.pow(2,32)?Uint32Array:D<=Number.MAX_SAFE_INTEGER?Qu:null;class Qu extends Array{constructor(D){super(D);this.fill(0)}}class P0{heap;length;static#D=!1;static create(D){let u=Y1(D);if(!u)return[];P0.#D=!0;let F=new P0(D,u);return P0.#D=!1,F}constructor(D,u){if(!P0.#D)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new u(D),this.length=0}push(D){this.heap[this.length++]=D}pop(){return this.heap[--this.length]}}class Xu{#D;#u;#E;#B;#$;#U;#z;#Y;get perf(){return this.#Y}ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#Q;#K;#J;#X;#F;#V;#W;#_;#A;#j;#H;#R;#N;#G;#L;#O;#q;#C;static unsafeExposeInternals(D){return{starts:D.#N,ttls:D.#G,sizes:D.#R,keyMap:D.#J,keyList:D.#X,valList:D.#F,next:D.#V,prev:D.#W,get head(){return D.#_},get tail(){return D.#A},free:D.#j,isBackgroundFetch:(u)=>D.#Z(u),backgroundFetch:(u,F,C,B)=>D.#c(u,F,C,B),moveToTail:(u)=>D.#f(u),indexes:(u)=>D.#w(u),rindexes:(u)=>D.#P(u),isStale:(u)=>D.#I(u)}}get max(){return this.#D}get maxSize(){return this.#u}get calculatedSize(){return this.#K}get size(){return this.#Q}get fetchMethod(){return this.#U}get memoMethod(){return this.#z}get dispose(){return this.#E}get onInsert(){return this.#B}get disposeAfter(){return this.#$}constructor(D){let{max:u=0,ttl:F,ttlResolution:C=1,ttlAutopurge:B,updateAgeOnGet:$,updateAgeOnHas:E,allowStale:Q,dispose:X,onInsert:Z,disposeAfter:Y,noDisposeOnSet:J,noUpdateTTL:A,maxSize:H=0,maxEntrySize:G=0,sizeCalculation:z,fetchMethod:U,memoMethod:I,noDeleteOnFetchRejection:j,noDeleteOnStaleGet:R,allowStaleOnFetchRejection:M,allowStaleOnFetchAbort:P,ignoreFetchAbort:x,perf:AD}=D;if(AD!==void 0){if(typeof AD?.now!=="function")throw new TypeError("perf option must have a now() method if specified")}if(this.#Y=AD??ZE,u!==0&&!V0(u))throw new TypeError("max option must be a nonnegative integer");let wD=u?Y1(u):Array;if(!wD)throw new Error("invalid max value: "+u);if(this.#D=u,this.#u=H,this.maxEntrySize=G||this.#u,this.sizeCalculation=z,this.sizeCalculation){if(!this.#u&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!=="function")throw new TypeError("sizeCalculation set to non-function")}if(I!==void 0&&typeof I!=="function")throw new TypeError("memoMethod must be a function if defined");if(this.#z=I,U!==void 0&&typeof U!=="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#U=U,this.#O=!!U,this.#J=new Map,this.#X=new Array(u).fill(void 0),this.#F=new Array(u).fill(void 0),this.#V=new wD(u),this.#W=new wD(u),this.#_=0,this.#A=0,this.#j=P0.create(u),this.#Q=0,this.#K=0,typeof X==="function")this.#E=X;if(typeof Z==="function")this.#B=Z;if(typeof Y==="function")this.#$=Y,this.#H=[];else this.#$=void 0,this.#H=void 0;if(this.#L=!!this.#E,this.#C=!!this.#B,this.#q=!!this.#$,this.noDisposeOnSet=!!J,this.noUpdateTTL=!!A,this.noDeleteOnFetchRejection=!!j,this.allowStaleOnFetchRejection=!!M,this.allowStaleOnFetchAbort=!!P,this.ignoreFetchAbort=!!x,this.maxEntrySize!==0){if(this.#u!==0){if(!V0(this.#u))throw new TypeError("maxSize must be a positive integer if specified")}if(!V0(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#y()}if(this.allowStale=!!Q,this.noDeleteOnStaleGet=!!R,this.updateAgeOnGet=!!$,this.updateAgeOnHas=!!E,this.ttlResolution=V0(C)||C===0?C:1,this.ttlAutopurge=!!B,this.ttl=F||0,this.ttl){if(!V0(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#S()}if(this.#D===0&&this.ttl===0&&this.#u===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#D&&!this.#u){if(YE("LRU_CACHE_UNBOUNDED"))X1.add("LRU_CACHE_UNBOUNDED"),Z1("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning","LRU_CACHE_UNBOUNDED",Xu)}}getRemainingTTL(D){return this.#J.has(D)?1/0:0}#S(){let D=new Qu(this.#D),u=new Qu(this.#D);this.#G=D,this.#N=u,this.#m=(B,$,E=this.#Y.now())=>{if(u[B]=$!==0?E:0,D[B]=$,$!==0&&this.ttlAutopurge){let Q=setTimeout(()=>{if(this.#I(B))this.#k(this.#X[B],"expire")},$+1);if(Q.unref)Q.unref()}},this.#T=(B)=>{u[B]=D[B]!==0?this.#Y.now():0},this.#M=(B,$)=>{if(D[$]){let E=D[$],Q=u[$];if(!E||!Q)return;B.ttl=E,B.start=Q,B.now=F||C();let X=B.now-Q;B.remainingTTL=E-X}};let F=0,C=()=>{let B=this.#Y.now();if(this.ttlResolution>0){F=B;let $=setTimeout(()=>F=0,this.ttlResolution);if($.unref)$.unref()}return B};this.getRemainingTTL=(B)=>{let $=this.#J.get(B);if($===void 0)return 0;let E=D[$],Q=u[$];if(!E||!Q)return 1/0;let X=(F||C())-Q;return E-X},this.#I=(B)=>{let $=u[B],E=D[B];return!!E&&!!$&&(F||C())-$>E}}#T=()=>{};#M=()=>{};#m=()=>{};#I=()=>!1;#y(){let D=new Qu(this.#D);this.#K=0,this.#R=D,this.#x=(u)=>{this.#K-=D[u],D[u]=0},this.#b=(u,F,C,B)=>{if(this.#Z(F))return 0;if(!V0(C))if(B){if(typeof B!=="function")throw new TypeError("sizeCalculation must be a function");if(C=B(F,u),!V0(C))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return C},this.#h=(u,F,C)=>{if(D[u]=F,this.#u){let B=this.#u-D[u];while(this.#K>B)this.#v(!0)}if(this.#K+=D[u],C)C.entrySize=F,C.totalCalculatedSize=this.#K}}#x=(D)=>{};#h=(D,u,F)=>{};#b=(D,u,F,C)=>{if(F||C)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#w({allowStale:D=this.allowStale}={}){if(this.#Q)for(let u=this.#A;;){if(!this.#d(u))break;if(D||!this.#I(u))yield u;if(u===this.#_)break;else u=this.#W[u]}}*#P({allowStale:D=this.allowStale}={}){if(this.#Q)for(let u=this.#_;;){if(!this.#d(u))break;if(D||!this.#I(u))yield u;if(u===this.#A)break;else u=this.#V[u]}}#d(D){return D!==void 0&&this.#J.get(this.#X[D])===D}*entries(){for(let D of this.#w())if(this.#F[D]!==void 0&&this.#X[D]!==void 0&&!this.#Z(this.#F[D]))yield[this.#X[D],this.#F[D]]}*rentries(){for(let D of this.#P())if(this.#F[D]!==void 0&&this.#X[D]!==void 0&&!this.#Z(this.#F[D]))yield[this.#X[D],this.#F[D]]}*keys(){for(let D of this.#w()){let u=this.#X[D];if(u!==void 0&&!this.#Z(this.#F[D]))yield u}}*rkeys(){for(let D of this.#P()){let u=this.#X[D];if(u!==void 0&&!this.#Z(this.#F[D]))yield u}}*values(){for(let D of this.#w())if(this.#F[D]!==void 0&&!this.#Z(this.#F[D]))yield this.#F[D]}*rvalues(){for(let D of this.#P())if(this.#F[D]!==void 0&&!this.#Z(this.#F[D]))yield this.#F[D]}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(D,u={}){for(let F of this.#w()){let C=this.#F[F],B=this.#Z(C)?C.__staleWhileFetching:C;if(B===void 0)continue;if(D(B,this.#X[F],this))return this.get(this.#X[F],u)}}forEach(D,u=this){for(let F of this.#w()){let C=this.#F[F],B=this.#Z(C)?C.__staleWhileFetching:C;if(B===void 0)continue;D.call(u,B,this.#X[F],this)}}rforEach(D,u=this){for(let F of this.#P()){let C=this.#F[F],B=this.#Z(C)?C.__staleWhileFetching:C;if(B===void 0)continue;D.call(u,B,this.#X[F],this)}}purgeStale(){let D=!1;for(let u of this.#P({allowStale:!0}))if(this.#I(u))this.#k(this.#X[u],"expire"),D=!0;return D}info(D){let u=this.#J.get(D);if(u===void 0)return;let F=this.#F[u],C=this.#Z(F)?F.__staleWhileFetching:F;if(C===void 0)return;let B={value:C};if(this.#G&&this.#N){let $=this.#G[u],E=this.#N[u];if($&&E){let Q=$-(this.#Y.now()-E);B.ttl=Q,B.start=Date.now()}}if(this.#R)B.size=this.#R[u];return B}dump(){let D=[];for(let u of this.#w({allowStale:!0})){let F=this.#X[u],C=this.#F[u],B=this.#Z(C)?C.__staleWhileFetching:C;if(B===void 0||F===void 0)continue;let $={value:B};if(this.#G&&this.#N){$.ttl=this.#G[u];let E=this.#Y.now()-this.#N[u];$.start=Math.floor(Date.now()-E)}if(this.#R)$.size=this.#R[u];D.unshift([F,$])}return D}load(D){this.clear();for(let[u,F]of D){if(F.start){let C=Date.now()-F.start;F.start=this.#Y.now()-C}this.set(u,F.value,F)}}set(D,u,F={}){if(u===void 0)return this.delete(D),this;let{ttl:C=this.ttl,start:B,noDisposeOnSet:$=this.noDisposeOnSet,sizeCalculation:E=this.sizeCalculation,status:Q}=F,{noUpdateTTL:X=this.noUpdateTTL}=F,Z=this.#b(D,u,F.size||0,E);if(this.maxEntrySize&&Z>this.maxEntrySize){if(Q)Q.set="miss",Q.maxEntrySizeExceeded=!0;return this.#k(D,"set"),this}let Y=this.#Q===0?void 0:this.#J.get(D);if(Y===void 0){if(Y=this.#Q===0?this.#A:this.#j.length!==0?this.#j.pop():this.#Q===this.#D?this.#v(!1):this.#Q,this.#X[Y]=D,this.#F[Y]=u,this.#J.set(D,Y),this.#V[this.#A]=Y,this.#W[Y]=this.#A,this.#A=Y,this.#Q++,this.#h(Y,Z,Q),Q)Q.set="add";if(X=!1,this.#C)this.#B?.(u,D,"add")}else{this.#f(Y);let J=this.#F[Y];if(u!==J){if(this.#O&&this.#Z(J)){J.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:A}=J;if(A!==void 0&&!$){if(this.#L)this.#E?.(A,D,"set");if(this.#q)this.#H?.push([A,D,"set"])}}else if(!$){if(this.#L)this.#E?.(J,D,"set");if(this.#q)this.#H?.push([J,D,"set"])}if(this.#x(Y),this.#h(Y,Z,Q),this.#F[Y]=u,Q){Q.set="replace";let A=J&&this.#Z(J)?J.__staleWhileFetching:J;if(A!==void 0)Q.oldValue=A}}else if(Q)Q.set="update";if(this.#C)this.onInsert?.(u,D,u===J?"update":"replace")}if(C!==0&&!this.#G)this.#S();if(this.#G){if(!X)this.#m(Y,C,B);if(Q)this.#M(Q,Y)}if(!$&&this.#q&&this.#H){let J=this.#H,A;while(A=J?.shift())this.#$?.(...A)}return this}pop(){try{while(this.#Q){let D=this.#F[this.#_];if(this.#v(!0),this.#Z(D)){if(D.__staleWhileFetching)return D.__staleWhileFetching}else if(D!==void 0)return D}}finally{if(this.#q&&this.#H){let D=this.#H,u;while(u=D?.shift())this.#$?.(...u)}}}#v(D){let u=this.#_,F=this.#X[u],C=this.#F[u];if(this.#O&&this.#Z(C))C.__abortController.abort(new Error("evicted"));else if(this.#L||this.#q){if(this.#L)this.#E?.(C,F,"evict");if(this.#q)this.#H?.push([C,F,"evict"])}if(this.#x(u),D)this.#X[u]=void 0,this.#F[u]=void 0,this.#j.push(u);if(this.#Q===1)this.#_=this.#A=0,this.#j.length=0;else this.#_=this.#V[u];return this.#J.delete(F),this.#Q--,u}has(D,u={}){let{updateAgeOnHas:F=this.updateAgeOnHas,status:C}=u,B=this.#J.get(D);if(B!==void 0){let $=this.#F[B];if(this.#Z($)&&$.__staleWhileFetching===void 0)return!1;if(!this.#I(B)){if(F)this.#T(B);if(C)C.has="hit",this.#M(C,B);return!0}else if(C)C.has="stale",this.#M(C,B)}else if(C)C.has="miss";return!1}peek(D,u={}){let{allowStale:F=this.allowStale}=u,C=this.#J.get(D);if(C===void 0||!F&&this.#I(C))return;let B=this.#F[C];return this.#Z(B)?B.__staleWhileFetching:B}#c(D,u,F,C){let B=u===void 0?void 0:this.#F[u];if(this.#Z(B))return B;let $=new FF,{signal:E}=F;E?.addEventListener("abort",()=>$.abort(E.reason),{signal:$.signal});let Q={signal:$.signal,options:F,context:C},X=(G,z=!1)=>{let{aborted:U}=$.signal,I=F.ignoreFetchAbort&&G!==void 0;if(F.status)if(U&&!z){if(F.status.fetchAborted=!0,F.status.fetchError=$.signal.reason,I)F.status.fetchAbortIgnored=!0}else F.status.fetchResolved=!0;if(U&&!I&&!z)return Y($.signal.reason);let j=A,R=this.#F[u];if(R===A||I&&z&&R===void 0)if(G===void 0)if(j.__staleWhileFetching!==void 0)this.#F[u]=j.__staleWhileFetching;else this.#k(D,"fetch");else{if(F.status)F.status.fetchUpdated=!0;this.set(D,G,Q.options)}return G},Z=(G)=>{if(F.status)F.status.fetchRejected=!0,F.status.fetchError=G;return Y(G)},Y=(G)=>{let{aborted:z}=$.signal,U=z&&F.allowStaleOnFetchAbort,I=U||F.allowStaleOnFetchRejection,j=I||F.noDeleteOnFetchRejection,R=A;if(this.#F[u]===A){if(!j||R.__staleWhileFetching===void 0)this.#k(D,"fetch");else if(!U)this.#F[u]=R.__staleWhileFetching}if(I){if(F.status&&R.__staleWhileFetching!==void 0)F.status.returnedStale=!0;return R.__staleWhileFetching}else if(R.__returned===R)throw G},J=(G,z)=>{let U=this.#U?.(D,B,Q);if(U&&U instanceof Promise)U.then((I)=>G(I===void 0?void 0:I),z);$.signal.addEventListener("abort",()=>{if(!F.ignoreFetchAbort||F.allowStaleOnFetchAbort){if(G(void 0),F.allowStaleOnFetchAbort)G=(I)=>X(I,!0)}})};if(F.status)F.status.fetchDispatched=!0;let A=new Promise(J).then(X,Z),H=Object.assign(A,{__abortController:$,__staleWhileFetching:B,__returned:void 0});if(u===void 0)this.set(D,H,{...Q.options,status:void 0}),u=this.#J.get(D);else this.#F[u]=H;return H}#Z(D){if(!this.#O)return!1;let u=D;return!!u&&u instanceof Promise&&u.hasOwnProperty("__staleWhileFetching")&&u.__abortController instanceof FF}async fetch(D,u={}){let{allowStale:F=this.allowStale,updateAgeOnGet:C=this.updateAgeOnGet,noDeleteOnStaleGet:B=this.noDeleteOnStaleGet,ttl:$=this.ttl,noDisposeOnSet:E=this.noDisposeOnSet,size:Q=0,sizeCalculation:X=this.sizeCalculation,noUpdateTTL:Z=this.noUpdateTTL,noDeleteOnFetchRejection:Y=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:J=this.allowStaleOnFetchRejection,ignoreFetchAbort:A=this.ignoreFetchAbort,allowStaleOnFetchAbort:H=this.allowStaleOnFetchAbort,context:G,forceRefresh:z=!1,status:U,signal:I}=u;if(!this.#O){if(U)U.fetch="get";return this.get(D,{allowStale:F,updateAgeOnGet:C,noDeleteOnStaleGet:B,status:U})}let j={allowStale:F,updateAgeOnGet:C,noDeleteOnStaleGet:B,ttl:$,noDisposeOnSet:E,size:Q,sizeCalculation:X,noUpdateTTL:Z,noDeleteOnFetchRejection:Y,allowStaleOnFetchRejection:J,allowStaleOnFetchAbort:H,ignoreFetchAbort:A,status:U,signal:I},R=this.#J.get(D);if(R===void 0){if(U)U.fetch="miss";let M=this.#c(D,R,j,G);return M.__returned=M}else{let M=this.#F[R];if(this.#Z(M)){let W=F&&M.__staleWhileFetching!==void 0;if(U){if(U.fetch="inflight",W)U.returnedStale=!0}return W?M.__staleWhileFetching:M.__returned=M}let P=this.#I(R);if(!z&&!P){if(U)U.fetch="hit";if(this.#f(R),C)this.#T(R);if(U)this.#M(U,R);return M}let x=this.#c(D,R,j,G),wD=x.__staleWhileFetching!==void 0&&F;if(U){if(U.fetch=P?"stale":"refresh",wD&&P)U.returnedStale=!0}return wD?x.__staleWhileFetching:x.__returned=x}}async forceFetch(D,u={}){let F=await this.fetch(D,u);if(F===void 0)throw new Error("fetch() returned undefined");return F}memo(D,u={}){let F=this.#z;if(!F)throw new Error("no memoMethod provided to constructor");let{context:C,forceRefresh:B,...$}=u,E=this.get(D,$);if(!B&&E!==void 0)return E;let Q=F(D,E,{options:$,context:C});return this.set(D,Q,$),Q}get(D,u={}){let{allowStale:F=this.allowStale,updateAgeOnGet:C=this.updateAgeOnGet,noDeleteOnStaleGet:B=this.noDeleteOnStaleGet,status:$}=u,E=this.#J.get(D);if(E!==void 0){let Q=this.#F[E],X=this.#Z(Q);if($)this.#M($,E);if(this.#I(E)){if($)$.get="stale";if(!X){if(!B)this.#k(D,"expire");if($&&F)$.returnedStale=!0;return F?Q:void 0}else{if($&&F&&Q.__staleWhileFetching!==void 0)$.returnedStale=!0;return F?Q.__staleWhileFetching:void 0}}else{if($)$.get="hit";if(X)return Q.__staleWhileFetching;if(this.#f(E),C)this.#T(E);return Q}}else if($)$.get="miss"}#l(D,u){this.#W[u]=D,this.#V[D]=u}#f(D){if(D!==this.#A){if(D===this.#_)this.#_=this.#V[D];else this.#l(this.#W[D],this.#V[D]);this.#l(this.#A,D),this.#A=D}}delete(D){return this.#k(D,"delete")}#k(D,u){let F=!1;if(this.#Q!==0){let C=this.#J.get(D);if(C!==void 0)if(F=!0,this.#Q===1)this.#g(u);else{this.#x(C);let B=this.#F[C];if(this.#Z(B))B.__abortController.abort(new Error("deleted"));else if(this.#L||this.#q){if(this.#L)this.#E?.(B,D,u);if(this.#q)this.#H?.push([B,D,u])}if(this.#J.delete(D),this.#X[C]=void 0,this.#F[C]=void 0,C===this.#A)this.#A=this.#W[C];else if(C===this.#_)this.#_=this.#V[C];else{let $=this.#W[C];this.#V[$]=this.#V[C];let E=this.#V[C];this.#W[E]=this.#W[C]}this.#Q--,this.#j.push(C)}}if(this.#q&&this.#H?.length){let C=this.#H,B;while(B=C?.shift())this.#$?.(...B)}return F}clear(){return this.#g("delete")}#g(D){for(let u of this.#P({allowStale:!0})){let F=this.#F[u];if(this.#Z(F))F.__abortController.abort(new Error("deleted"));else{let C=this.#X[u];if(this.#L)this.#E?.(F,C,D);if(this.#q)this.#H?.push([F,C,D])}}if(this.#J.clear(),this.#F.fill(void 0),this.#X.fill(void 0),this.#G&&this.#N)this.#G.fill(0),this.#N.fill(0);if(this.#R)this.#R.fill(0);if(this.#_=0,this.#A=0,this.#j.length=0,this.#K=0,this.#Q=0,this.#q&&this.#H){let u=this.#H,F;while(F=u?.shift())this.#$?.(...F)}}}import{posix as WE,win32 as F3}from"path";import{fileURLToPath as LE}from"url";import{lstatSync as RE,readdir as ME,readdirSync as IE,readlinkSync as NE,realpathSync as OE}from"fs";import*as jE from"fs";import{lstat as wE,readdir as kE,readlink as PE,realpath as SE}from"fs/promises";import{EventEmitter as t2}from"events";import A1 from"stream";import{StringDecoder as JE}from"string_decoder";var J1=typeof process==="object"&&process?process:{stdout:null,stderr:null},KE=(D)=>!!D&&typeof D==="object"&&(D instanceof U0||D instanceof A1||qE(D)||VE(D)),qE=(D)=>!!D&&typeof D==="object"&&D instanceof t2&&typeof D.pipe==="function"&&D.pipe!==A1.Writable.prototype.pipe,VE=(D)=>!!D&&typeof D==="object"&&D instanceof t2&&typeof D.write==="function"&&typeof D.end==="function",E0=Symbol("EOF"),$0=Symbol("maybeEmitEnd"),A0=Symbol("emittedEnd"),CF=Symbol("emittingEnd"),Zu=Symbol("emittedError"),BF=Symbol("closed"),K1=Symbol("read"),EF=Symbol("flush"),q1=Symbol("flushChunk"),iD=Symbol("encoding"),S0=Symbol("decoder"),CD=Symbol("flowing"),Yu=Symbol("paused"),x0=Symbol("resume"),BD=Symbol("buffer"),WD=Symbol("pipes"),ED=Symbol("bufferLength"),n2=Symbol("bufferPush"),$F=Symbol("bufferShift"),VD=Symbol("objectMode"),t=Symbol("destroyed"),r2=Symbol("error"),i2=Symbol("emitData"),V1=Symbol("emitEnd"),o2=Symbol("emitEnd2"),tD=Symbol("async"),s2=Symbol("abort"),QF=Symbol("aborted"),Ju=Symbol("signal"),_0=Symbol("dataListeners"),TD=Symbol("discarded"),Ku=(D)=>Promise.resolve().then(D),AE=(D)=>D(),HE=(D)=>D==="end"||D==="finish"||D==="prefinish",GE=(D)=>D instanceof ArrayBuffer||!!D&&typeof D==="object"&&D.constructor&&D.constructor.name==="ArrayBuffer"&&D.byteLength>=0,zE=(D)=>!Buffer.isBuffer(D)&&ArrayBuffer.isView(D);class e2{src;dest;opts;ondrain;constructor(D,u,F){this.src=D,this.dest=u,this.opts=F,this.ondrain=()=>D[x0](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(D){}end(){if(this.unpipe(),this.opts.end)this.dest.end()}}class H1 extends e2{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(D,u,F){super(D,u,F);this.proxyErrors=(C)=>u.emit("error",C),D.on("error",this.proxyErrors)}}var _E=(D)=>!!D.objectMode,UE=(D)=>!D.objectMode&&!!D.encoding&&D.encoding!=="buffer";class U0 extends t2{[CD]=!1;[Yu]=!1;[WD]=[];[BD]=[];[VD];[iD];[tD];[S0];[E0]=!1;[A0]=!1;[CF]=!1;[BF]=!1;[Zu]=null;[ED]=0;[t]=!1;[Ju];[QF]=!1;[_0]=0;[TD]=!1;writable=!0;readable=!0;constructor(...D){let u=D[0]||{};super();if(u.objectMode&&typeof u.encoding==="string")throw new TypeError("Encoding and objectMode may not be used together");if(_E(u))this[VD]=!0,this[iD]=null;else if(UE(u))this[iD]=u.encoding,this[VD]=!1;else this[VD]=!1,this[iD]=null;if(this[tD]=!!u.async,this[S0]=this[iD]?new JE(this[iD]):null,u&&u.debugExposeBuffer===!0)Object.defineProperty(this,"buffer",{get:()=>this[BD]});if(u&&u.debugExposePipes===!0)Object.defineProperty(this,"pipes",{get:()=>this[WD]});let{signal:F}=u;if(F)if(this[Ju]=F,F.aborted)this[s2]();else F.addEventListener("abort",()=>this[s2]())}get bufferLength(){return this[ED]}get encoding(){return this[iD]}set encoding(D){throw new Error("Encoding must be set at instantiation time")}setEncoding(D){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[VD]}set objectMode(D){throw new Error("objectMode must be set at instantiation time")}get["async"](){return this[tD]}set["async"](D){this[tD]=this[tD]||!!D}[s2](){this[QF]=!0,this.emit("abort",this[Ju]?.reason),this.destroy(this[Ju]?.reason)}get aborted(){return this[QF]}set aborted(D){}write(D,u,F){if(this[QF])return!1;if(this[E0])throw new Error("write after end");if(this[t])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;if(typeof u==="function")F=u,u="utf8";if(!u)u="utf8";let C=this[tD]?Ku:AE;if(!this[VD]&&!Buffer.isBuffer(D)){if(zE(D))D=Buffer.from(D.buffer,D.byteOffset,D.byteLength);else if(GE(D))D=Buffer.from(D);else if(typeof D!=="string")throw new Error("Non-contiguous data written to non-objectMode stream")}if(this[VD]){if(this[CD]&&this[ED]!==0)this[EF](!0);if(this[CD])this.emit("data",D);else this[n2](D);if(this[ED]!==0)this.emit("readable");if(F)C(F);return this[CD]}if(!D.length){if(this[ED]!==0)this.emit("readable");if(F)C(F);return this[CD]}if(typeof D==="string"&&!(u===this[iD]&&!this[S0]?.lastNeed))D=Buffer.from(D,u);if(Buffer.isBuffer(D)&&this[iD])D=this[S0].write(D);if(this[CD]&&this[ED]!==0)this[EF](!0);if(this[CD])this.emit("data",D);else this[n2](D);if(this[ED]!==0)this.emit("readable");if(F)C(F);return this[CD]}read(D){if(this[t])return null;if(this[TD]=!1,this[ED]===0||D===0||D&&D>this[ED])return this[$0](),null;if(this[VD])D=null;if(this[BD].length>1&&!this[VD])this[BD]=[this[iD]?this[BD].join(""):Buffer.concat(this[BD],this[ED])];let u=this[K1](D||null,this[BD][0]);return this[$0](),u}[K1](D,u){if(this[VD])this[$F]();else{let F=u;if(D===F.length||D===null)this[$F]();else if(typeof F==="string")this[BD][0]=F.slice(D),u=F.slice(0,D),this[ED]-=D;else this[BD][0]=F.subarray(D),u=F.subarray(0,D),this[ED]-=D}if(this.emit("data",u),!this[BD].length&&!this[E0])this.emit("drain");return u}end(D,u,F){if(typeof D==="function")F=D,D=void 0;if(typeof u==="function")F=u,u="utf8";if(D!==void 0)this.write(D,u);if(F)this.once("end",F);if(this[E0]=!0,this.writable=!1,this[CD]||!this[Yu])this[$0]();return this}[x0](){if(this[t])return;if(!this[_0]&&!this[WD].length)this[TD]=!0;if(this[Yu]=!1,this[CD]=!0,this.emit("resume"),this[BD].length)this[EF]();else if(this[E0])this[$0]();else this.emit("drain")}resume(){return this[x0]()}pause(){this[CD]=!1,this[Yu]=!0,this[TD]=!1}get destroyed(){return this[t]}get flowing(){return this[CD]}get paused(){return this[Yu]}[n2](D){if(this[VD])this[ED]+=1;else this[ED]+=D.length;this[BD].push(D)}[$F](){if(this[VD])this[ED]-=1;else this[ED]-=this[BD][0].length;return this[BD].shift()}[EF](D=!1){do;while(this[q1](this[$F]())&&this[BD].length);if(!D&&!this[BD].length&&!this[E0])this.emit("drain")}[q1](D){return this.emit("data",D),this[CD]}pipe(D,u){if(this[t])return D;this[TD]=!1;let F=this[A0];if(u=u||{},D===J1.stdout||D===J1.stderr)u.end=!1;else u.end=u.end!==!1;if(u.proxyErrors=!!u.proxyErrors,F){if(u.end)D.end()}else if(this[WD].push(!u.proxyErrors?new e2(this,D,u):new H1(this,D,u)),this[tD])Ku(()=>this[x0]());else this[x0]();return D}unpipe(D){let u=this[WD].find((F)=>F.dest===D);if(u){if(this[WD].length===1){if(this[CD]&&this[_0]===0)this[CD]=!1;this[WD]=[]}else this[WD].splice(this[WD].indexOf(u),1);u.unpipe()}}addListener(D,u){return this.on(D,u)}on(D,u){let F=super.on(D,u);if(D==="data"){if(this[TD]=!1,this[_0]++,!this[WD].length&&!this[CD])this[x0]()}else if(D==="readable"&&this[ED]!==0)super.emit("readable");else if(HE(D)&&this[A0])super.emit(D),this.removeAllListeners(D);else if(D==="error"&&this[Zu]){let C=u;if(this[tD])Ku(()=>C.call(this,this[Zu]));else C.call(this,this[Zu])}return F}removeListener(D,u){return this.off(D,u)}off(D,u){let F=super.off(D,u);if(D==="data"){if(this[_0]=this.listeners("data").length,this[_0]===0&&!this[TD]&&!this[WD].length)this[CD]=!1}return F}removeAllListeners(D){let u=super.removeAllListeners(D);if(D==="data"||D===void 0){if(this[_0]=0,!this[TD]&&!this[WD].length)this[CD]=!1}return u}get emittedEnd(){return this[A0]}[$0](){if(!this[CF]&&!this[A0]&&!this[t]&&this[BD].length===0&&this[E0]){if(this[CF]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[BF])this.emit("close");this[CF]=!1}}emit(D,...u){let F=u[0];if(D!=="error"&&D!=="close"&&D!==t&&this[t])return!1;else if(D==="data")return!this[VD]&&!F?!1:this[tD]?(Ku(()=>this[i2](F)),!0):this[i2](F);else if(D==="end")return this[V1]();else if(D==="close"){if(this[BF]=!0,!this[A0]&&!this[t])return!1;let B=super.emit("close");return this.removeAllListeners("close"),B}else if(D==="error"){this[Zu]=F,super.emit(r2,F);let B=!this[Ju]||this.listeners("error").length?super.emit("error",F):!1;return this[$0](),B}else if(D==="resume"){let B=super.emit("resume");return this[$0](),B}else if(D==="finish"||D==="prefinish"){let B=super.emit(D);return this.removeAllListeners(D),B}let C=super.emit(D,...u);return this[$0](),C}[i2](D){for(let F of this[WD])if(F.dest.write(D)===!1)this.pause();let u=this[TD]?!1:super.emit("data",D);return this[$0](),u}[V1](){if(this[A0])return!1;return this[A0]=!0,this.readable=!1,this[tD]?(Ku(()=>this[o2]()),!0):this[o2]()}[o2](){if(this[S0]){let u=this[S0].end();if(u){for(let F of this[WD])F.dest.write(u);if(!this[TD])super.emit("data",u)}}for(let u of this[WD])u.end();let D=super.emit("end");return this.removeAllListeners("end"),D}async collect(){let D=Object.assign([],{dataLength:0});if(!this[VD])D.dataLength=0;let u=this.promise();return this.on("data",(F)=>{if(D.push(F),!this[VD])D.dataLength+=F.length}),await u,D}async concat(){if(this[VD])throw new Error("cannot concat in objectMode");let D=await this.collect();return this[iD]?D.join(""):Buffer.concat(D,D.dataLength)}async promise(){return new Promise((D,u)=>{this.on(t,()=>u(new Error("stream destroyed"))),this.on("error",(F)=>u(F)),this.on("end",()=>D())})}[Symbol.asyncIterator](){this[TD]=!1;let D=!1,u=async()=>{return this.pause(),D=!0,{value:void 0,done:!0}};return{next:()=>{if(D)return u();let C=this.read();if(C!==null)return Promise.resolve({done:!1,value:C});if(this[E0])return u();let B,$,E=(Y)=>{this.off("data",Q),this.off("end",X),this.off(t,Z),u(),$(Y)},Q=(Y)=>{this.off("error",E),this.off("end",X),this.off(t,Z),this.pause(),B({value:Y,done:!!this[E0]})},X=()=>{this.off("error",E),this.off("data",Q),this.off(t,Z),u(),B({done:!0,value:void 0})},Z=()=>E(new Error("stream destroyed"));return new Promise((Y,J)=>{$=J,B=Y,this.once(t,Z),this.once("error",E),this.once("end",X),this.once("data",Q)})},throw:u,return:u,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[TD]=!1;let D=!1,u=()=>{return this.pause(),this.off(r2,u),this.off(t,u),this.off("end",u),D=!0,{done:!0,value:void 0}},F=()=>{if(D)return u();let C=this.read();return C===null?u():{done:!1,value:C}};return this.once("end",u),this.once(r2,u),this.once(t,u),{next:F,throw:u,return:u,[Symbol.iterator](){return this}}}destroy(D){if(this[t]){if(D)this.emit("error",D);else this.emit(t);return this}this[t]=!0,this[TD]=!0,this[BD].length=0,this[ED]=0;let u=this;if(typeof u.close==="function"&&!this[BF])u.close();if(D)this.emit("error",D);else this.emit(t);return this}static get isStream(){return KE}}var TE=OE.native,Vu={lstatSync:RE,readdir:ME,readdirSync:IE,readlinkSync:NE,realpathSync:TE,promises:{lstat:wE,readdir:kE,readlink:PE,realpath:SE}},W1=(D)=>!D||D===Vu||D===jE?Vu:{...Vu,...D,promises:{...Vu.promises,...D.promises||{}}},L1=/^\\\\\?\\([a-z]:)\\?$/i,xE=(D)=>D.replace(/\//g,"\\").replace(L1,"$1\\"),bE=/[\\\/]/,hD=0,R1=1,M1=2,eD=4,I1=6,N1=8,W0=10,O1=12,yD=15,qu=~yD,D3=16,G1=32,Au=64,oD=128,XF=256,YF=512,z1=Au|oD|YF,vE=1023,u3=(D)=>D.isFile()?N1:D.isDirectory()?eD:D.isSymbolicLink()?W0:D.isCharacterDevice()?M1:D.isBlockDevice()?I1:D.isSocket()?O1:D.isFIFO()?R1:hD,_1=new Map,Hu=(D)=>{let u=_1.get(D);if(u)return u;let F=D.normalize("NFKD");return _1.set(D,F),F},U1=new Map,ZF=(D)=>{let u=U1.get(D);if(u)return u;let F=Hu(D.toLowerCase());return U1.set(D,F),F};class C3 extends Xu{constructor(){super({max:256})}}class j1 extends Xu{constructor(D=16384){super({maxSize:D,sizeCalculation:(u)=>u.length+1})}}var T1=Symbol("PathScurry setAsCwd");class LD{name;root;roots;parent;nocase;isCWD=!1;#D;#u;get dev(){return this.#u}#E;get mode(){return this.#E}#B;get nlink(){return this.#B}#$;get uid(){return this.#$}#U;get gid(){return this.#U}#z;get rdev(){return this.#z}#Y;get blksize(){return this.#Y}#Q;get ino(){return this.#Q}#K;get size(){return this.#K}#J;get blocks(){return this.#J}#X;get atimeMs(){return this.#X}#F;get mtimeMs(){return this.#F}#V;get ctimeMs(){return this.#V}#W;get birthtimeMs(){return this.#W}#_;get atime(){return this.#_}#A;get mtime(){return this.#A}#j;get ctime(){return this.#j}#H;get birthtime(){return this.#H}#R;#N;#G;#L;#O;#q;#C;#S;#T;#M;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(D,u=hD,F,C,B,$,E){if(this.name=D,this.#R=B?ZF(D):Hu(D),this.#C=u&vE,this.nocase=B,this.roots=C,this.root=F||this,this.#S=$,this.#G=E.fullpath,this.#O=E.relative,this.#q=E.relativePosix,this.parent=E.parent,this.parent)this.#D=this.parent.#D;else this.#D=W1(E.fs)}depth(){if(this.#N!==void 0)return this.#N;if(!this.parent)return this.#N=0;return this.#N=this.parent.depth()+1}childrenCache(){return this.#S}resolve(D){if(!D)return this;let u=this.getRootString(D),C=D.substring(u.length).split(this.splitSep);return u?this.getRoot(u).#m(C):this.#m(C)}#m(D){let u=this;for(let F of D)u=u.child(F);return u}children(){let D=this.#S.get(this);if(D)return D;let u=Object.assign([],{provisional:0});return this.#S.set(this,u),this.#C&=~D3,u}child(D,u){if(D===""||D===".")return this;if(D==="..")return this.parent||this;let F=this.children(),C=this.nocase?ZF(D):Hu(D);for(let Q of F)if(Q.#R===C)return Q;let B=this.parent?this.sep:"",$=this.#G?this.#G+B+D:void 0,E=this.newChild(D,hD,{...u,parent:this,fullpath:$});if(!this.canReaddir())E.#C|=oD;return F.push(E),E}relative(){if(this.isCWD)return"";if(this.#O!==void 0)return this.#O;let D=this.name,u=this.parent;if(!u)return this.#O=this.name;let F=u.relative();return F+(!F||!u.parent?"":this.sep)+D}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#q!==void 0)return this.#q;let D=this.name,u=this.parent;if(!u)return this.#q=this.fullpathPosix();let F=u.relativePosix();return F+(!F||!u.parent?"":"/")+D}fullpath(){if(this.#G!==void 0)return this.#G;let D=this.name,u=this.parent;if(!u)return this.#G=this.name;let C=u.fullpath()+(!u.parent?"":this.sep)+D;return this.#G=C}fullpathPosix(){if(this.#L!==void 0)return this.#L;if(this.sep==="/")return this.#L=this.fullpath();if(!this.parent){let C=this.fullpath().replace(/\\/g,"/");if(/^[a-z]:\//i.test(C))return this.#L=`//?/${C}`;else return this.#L=C}let D=this.parent,u=D.fullpathPosix(),F=u+(!u||!D.parent?"":"/")+this.name;return this.#L=F}isUnknown(){return(this.#C&yD)===hD}isType(D){return this[`is${D}`]()}getType(){return this.isUnknown()?"Unknown":this.isDirectory()?"Directory":this.isFile()?"File":this.isSymbolicLink()?"SymbolicLink":this.isFIFO()?"FIFO":this.isCharacterDevice()?"CharacterDevice":this.isBlockDevice()?"BlockDevice":this.isSocket()?"Socket":"Unknown"}isFile(){return(this.#C&yD)===N1}isDirectory(){return(this.#C&yD)===eD}isCharacterDevice(){return(this.#C&yD)===M1}isBlockDevice(){return(this.#C&yD)===I1}isFIFO(){return(this.#C&yD)===R1}isSocket(){return(this.#C&yD)===O1}isSymbolicLink(){return(this.#C&W0)===W0}lstatCached(){return this.#C&G1?this:void 0}readlinkCached(){return this.#T}realpathCached(){return this.#M}readdirCached(){let D=this.children();return D.slice(0,D.provisional)}canReadlink(){if(this.#T)return!0;if(!this.parent)return!1;let D=this.#C&yD;return!(D!==hD&&D!==W0||this.#C&XF||this.#C&oD)}calledReaddir(){return!!(this.#C&D3)}isENOENT(){return!!(this.#C&oD)}isNamed(D){return!this.nocase?this.#R===Hu(D):this.#R===ZF(D)}async readlink(){let D=this.#T;if(D)return D;if(!this.canReadlink())return;if(!this.parent)return;try{let u=await this.#D.promises.readlink(this.fullpath()),F=(await this.parent.realpath())?.resolve(u);if(F)return this.#T=F}catch(u){this.#d(u.code);return}}readlinkSync(){let D=this.#T;if(D)return D;if(!this.canReadlink())return;if(!this.parent)return;try{let u=this.#D.readlinkSync(this.fullpath()),F=this.parent.realpathSync()?.resolve(u);if(F)return this.#T=F}catch(u){this.#d(u.code);return}}#I(D){this.#C|=D3;for(let u=D.provisional;uF(null,D))}readdirCB(D,u=!1){if(!this.canReaddir()){if(u)D(null,[]);else queueMicrotask(()=>D(null,[]));return}let F=this.children();if(this.calledReaddir()){let B=F.slice(0,F.provisional);if(u)D(null,B);else queueMicrotask(()=>D(null,B));return}if(this.#k.push(D),this.#g)return;this.#g=!0;let C=this.fullpath();this.#D.readdir(C,{withFileTypes:!0},(B,$)=>{if(B)this.#w(B.code),F.provisional=0;else{for(let E of $)this.#v(E,F);this.#I(F)}this.#a(F.slice(0,F.provisional));return})}#p;async readdir(){if(!this.canReaddir())return[];let D=this.children();if(this.calledReaddir())return D.slice(0,D.provisional);let u=this.fullpath();if(this.#p)await this.#p;else{let F=()=>{};this.#p=new Promise((C)=>F=C);try{for(let C of await this.#D.promises.readdir(u,{withFileTypes:!0}))this.#v(C,D);this.#I(D)}catch(C){this.#w(C.code),D.provisional=0}this.#p=void 0,F()}return D.slice(0,D.provisional)}readdirSync(){if(!this.canReaddir())return[];let D=this.children();if(this.calledReaddir())return D.slice(0,D.provisional);let u=this.fullpath();try{for(let F of this.#D.readdirSync(u,{withFileTypes:!0}))this.#v(F,D);this.#I(D)}catch(F){this.#w(F.code),D.provisional=0}return D.slice(0,D.provisional)}canReaddir(){if(this.#C&z1)return!1;let D=yD&this.#C;if(!(D===hD||D===eD||D===W0))return!1;return!0}shouldWalk(D,u){return(this.#C&eD)===eD&&!(this.#C&z1)&&!D.has(this)&&(!u||u(this))}async realpath(){if(this.#M)return this.#M;if((YF|XF|oD)&this.#C)return;try{let D=await this.#D.promises.realpath(this.fullpath());return this.#M=this.resolve(D)}catch(D){this.#h()}}realpathSync(){if(this.#M)return this.#M;if((YF|XF|oD)&this.#C)return;try{let D=this.#D.realpathSync(this.fullpath());return this.#M=this.resolve(D)}catch(D){this.#h()}}[T1](D){if(D===this)return;D.isCWD=!1,this.isCWD=!0;let u=new Set([]),F=[],C=this;while(C&&C.parent)u.add(C),C.#O=F.join(this.sep),C.#q=F.join("/"),C=C.parent,F.push("..");C=D;while(C&&C.parent&&!u.has(C))C.#O=void 0,C.#q=void 0,C=C.parent}}class JF extends LD{sep="\\";splitSep=bE;constructor(D,u=hD,F,C,B,$,E){super(D,u,F,C,B,$,E)}newChild(D,u=hD,F={}){return new JF(D,u,this.root,this.roots,this.nocase,this.childrenCache(),F)}getRootString(D){return F3.parse(D).root}getRoot(D){if(D=xE(D.toUpperCase()),D===this.root.name)return this.root;for(let[u,F]of Object.entries(this.roots))if(this.sameRoot(D,u))return this.roots[D]=F;return this.roots[D]=new Gu(D,this).root}sameRoot(D,u=this.root.name){return D=D.toUpperCase().replace(/\//g,"\\").replace(L1,"$1\\"),D===u}}class KF extends LD{splitSep="/";sep="/";constructor(D,u=hD,F,C,B,$,E){super(D,u,F,C,B,$,E)}getRootString(D){return D.startsWith("/")?"/":""}getRoot(D){return this.root}newChild(D,u=hD,F={}){return new KF(D,u,this.root,this.roots,this.nocase,this.childrenCache(),F)}}class B3{root;rootPath;roots;cwd;#D;#u;#E;nocase;#B;constructor(D=process.cwd(),u,F,{nocase:C,childrenCacheSize:B=16384,fs:$=Vu}={}){if(this.#B=W1($),D instanceof URL||D.startsWith("file://"))D=LE(D);let E=u.resolve(D);this.roots=Object.create(null),this.rootPath=this.parseRootPath(E),this.#D=new C3,this.#u=new C3,this.#E=new j1(B);let Q=E.substring(this.rootPath.length).split(F);if(Q.length===1&&!Q[0])Q.pop();if(C===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=C,this.root=this.newRoot(this.#B),this.roots[this.rootPath]=this.root;let X=this.root,Z=Q.length-1,Y=u.sep,J=this.rootPath,A=!1;for(let H of Q){let G=Z--;X=X.child(H,{relative:new Array(G).fill("..").join(Y),relativePosix:new Array(G).fill("..").join("/"),fullpath:J+=(A?"":Y)+H}),A=!0}this.cwd=X}depth(D=this.cwd){if(typeof D==="string")D=this.cwd.resolve(D);return D.depth()}childrenCache(){return this.#E}resolve(...D){let u="";for(let B=D.length-1;B>=0;B--){let $=D[B];if(!$||$===".")continue;if(u=u?`${$}/${u}`:$,this.isAbsolute($))break}let F=this.#D.get(u);if(F!==void 0)return F;let C=this.cwd.resolve(u).fullpath();return this.#D.set(u,C),C}resolvePosix(...D){let u="";for(let B=D.length-1;B>=0;B--){let $=D[B];if(!$||$===".")continue;if(u=u?`${$}/${u}`:$,this.isAbsolute($))break}let F=this.#u.get(u);if(F!==void 0)return F;let C=this.cwd.resolve(u).fullpathPosix();return this.#u.set(u,C),C}relative(D=this.cwd){if(typeof D==="string")D=this.cwd.resolve(D);return D.relative()}relativePosix(D=this.cwd){if(typeof D==="string")D=this.cwd.resolve(D);return D.relativePosix()}basename(D=this.cwd){if(typeof D==="string")D=this.cwd.resolve(D);return D.name}dirname(D=this.cwd){if(typeof D==="string")D=this.cwd.resolve(D);return(D.parent||D).fullpath()}async readdir(D=this.cwd,u={withFileTypes:!0}){if(typeof D==="string")D=this.cwd.resolve(D);else if(!(D instanceof LD))u=D,D=this.cwd;let{withFileTypes:F}=u;if(!D.canReaddir())return[];else{let C=await D.readdir();return F?C:C.map((B)=>B.name)}}readdirSync(D=this.cwd,u={withFileTypes:!0}){if(typeof D==="string")D=this.cwd.resolve(D);else if(!(D instanceof LD))u=D,D=this.cwd;let{withFileTypes:F=!0}=u;if(!D.canReaddir())return[];else if(F)return D.readdirSync();else return D.readdirSync().map((C)=>C.name)}async lstat(D=this.cwd){if(typeof D==="string")D=this.cwd.resolve(D);return D.lstat()}lstatSync(D=this.cwd){if(typeof D==="string")D=this.cwd.resolve(D);return D.lstatSync()}async readlink(D=this.cwd,{withFileTypes:u}={withFileTypes:!1}){if(typeof D==="string")D=this.cwd.resolve(D);else if(!(D instanceof LD))u=D.withFileTypes,D=this.cwd;let F=await D.readlink();return u?F:F?.fullpath()}readlinkSync(D=this.cwd,{withFileTypes:u}={withFileTypes:!1}){if(typeof D==="string")D=this.cwd.resolve(D);else if(!(D instanceof LD))u=D.withFileTypes,D=this.cwd;let F=D.readlinkSync();return u?F:F?.fullpath()}async realpath(D=this.cwd,{withFileTypes:u}={withFileTypes:!1}){if(typeof D==="string")D=this.cwd.resolve(D);else if(!(D instanceof LD))u=D.withFileTypes,D=this.cwd;let F=await D.realpath();return u?F:F?.fullpath()}realpathSync(D=this.cwd,{withFileTypes:u}={withFileTypes:!1}){if(typeof D==="string")D=this.cwd.resolve(D);else if(!(D instanceof LD))u=D.withFileTypes,D=this.cwd;let F=D.realpathSync();return u?F:F?.fullpath()}async walk(D=this.cwd,u={}){if(typeof D==="string")D=this.cwd.resolve(D);else if(!(D instanceof LD))u=D,D=this.cwd;let{withFileTypes:F=!0,follow:C=!1,filter:B,walkFilter:$}=u,E=[];if(!B||B(D))E.push(F?D:D.fullpath());let Q=new Set,X=(Y,J)=>{Q.add(Y),Y.readdirCB((A,H)=>{if(A)return J(A);let G=H.length;if(!G)return J();let z=()=>{if(--G===0)J()};for(let U of H){if(!B||B(U))E.push(F?U:U.fullpath());if(C&&U.isSymbolicLink())U.realpath().then((I)=>I?.isUnknown()?I.lstat():I).then((I)=>I?.shouldWalk(Q,$)?X(I,z):z());else if(U.shouldWalk(Q,$))X(U,z);else z()}},!0)},Z=D;return new Promise((Y,J)=>{X(Z,(A)=>{if(A)return J(A);Y(E)})})}walkSync(D=this.cwd,u={}){if(typeof D==="string")D=this.cwd.resolve(D);else if(!(D instanceof LD))u=D,D=this.cwd;let{withFileTypes:F=!0,follow:C=!1,filter:B,walkFilter:$}=u,E=[];if(!B||B(D))E.push(F?D:D.fullpath());let Q=new Set([D]);for(let X of Q){let Z=X.readdirSync();for(let Y of Z){if(!B||B(Y))E.push(F?Y:Y.fullpath());let J=Y;if(Y.isSymbolicLink()){if(!(C&&(J=Y.realpathSync())))continue;if(J.isUnknown())J.lstatSync()}if(J.shouldWalk(Q,$))Q.add(J)}}return E}[Symbol.asyncIterator](){return this.iterate()}iterate(D=this.cwd,u={}){if(typeof D==="string")D=this.cwd.resolve(D);else if(!(D instanceof LD))u=D,D=this.cwd;return this.stream(D,u)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(D=this.cwd,u={}){if(typeof D==="string")D=this.cwd.resolve(D);else if(!(D instanceof LD))u=D,D=this.cwd;let{withFileTypes:F=!0,follow:C=!1,filter:B,walkFilter:$}=u;if(!B||B(D))yield F?D:D.fullpath();let E=new Set([D]);for(let Q of E){let X=Q.readdirSync();for(let Z of X){if(!B||B(Z))yield F?Z:Z.fullpath();let Y=Z;if(Z.isSymbolicLink()){if(!(C&&(Y=Z.realpathSync())))continue;if(Y.isUnknown())Y.lstatSync()}if(Y.shouldWalk(E,$))E.add(Y)}}}stream(D=this.cwd,u={}){if(typeof D==="string")D=this.cwd.resolve(D);else if(!(D instanceof LD))u=D,D=this.cwd;let{withFileTypes:F=!0,follow:C=!1,filter:B,walkFilter:$}=u,E=new U0({objectMode:!0});if(!B||B(D))E.write(F?D:D.fullpath());let Q=new Set,X=[D],Z=0,Y=()=>{let J=!1;while(!J){let A=X.shift();if(!A){if(Z===0)E.end();return}Z++,Q.add(A);let H=(z,U,I=!1)=>{if(z)return E.emit("error",z);if(C&&!I){let j=[];for(let R of U)if(R.isSymbolicLink())j.push(R.realpath().then((M)=>M?.isUnknown()?M.lstat():M));if(j.length){Promise.all(j).then(()=>H(null,U,!0));return}}for(let j of U)if(j&&(!B||B(j))){if(!E.write(F?j:j.fullpath()))J=!0}Z--;for(let j of U){let R=j.realpathCached()||j;if(R.shouldWalk(Q,$))X.push(R)}if(J&&!E.flowing)E.once("drain",Y);else if(!G)Y()},G=!0;A.readdirCB(H,!0),G=!1}};return Y(),E}streamSync(D=this.cwd,u={}){if(typeof D==="string")D=this.cwd.resolve(D);else if(!(D instanceof LD))u=D,D=this.cwd;let{withFileTypes:F=!0,follow:C=!1,filter:B,walkFilter:$}=u,E=new U0({objectMode:!0}),Q=new Set;if(!B||B(D))E.write(F?D:D.fullpath());let X=[D],Z=0,Y=()=>{let J=!1;while(!J){let A=X.shift();if(!A){if(Z===0)E.end();return}Z++,Q.add(A);let H=A.readdirSync();for(let G of H)if(!B||B(G)){if(!E.write(F?G:G.fullpath()))J=!0}Z--;for(let G of H){let z=G;if(G.isSymbolicLink()){if(!(C&&(z=G.realpathSync())))continue;if(z.isUnknown())z.lstatSync()}if(z.shouldWalk(Q,$))X.push(z)}}if(J&&!E.flowing)E.once("drain",Y)};return Y(),E}chdir(D=this.cwd){let u=this.cwd;this.cwd=typeof D==="string"?this.cwd.resolve(D):D,this.cwd[T1](u)}}class Gu extends B3{sep="\\";constructor(D=process.cwd(),u={}){let{nocase:F=!0}=u;super(D,F3,"\\",{...u,nocase:F});this.nocase=F;for(let C=this.cwd;C;C=C.parent)C.nocase=this.nocase}parseRootPath(D){return F3.parse(D).root.toUpperCase()}newRoot(D){return new JF(this.rootPath,eD,void 0,this.roots,this.nocase,this.childrenCache(),{fs:D})}isAbsolute(D){return D.startsWith("/")||D.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(D)}}class zu extends B3{sep="/";constructor(D=process.cwd(),u={}){let{nocase:F=!1}=u;super(D,WE,"/",{...u,nocase:F});this.nocase=F}parseRootPath(D){return"/"}newRoot(D){return new KF(this.rootPath,eD,void 0,this.roots,this.nocase,this.childrenCache(),{fs:D})}isAbsolute(D){return D.startsWith("/")}}class qF extends zu{constructor(D=process.cwd(),u={}){let{nocase:F=!0}=u;super(D,{...u,nocase:F})}}var BY=process.platform==="win32"?JF:KF,w1=process.platform==="win32"?Gu:process.platform==="darwin"?qF:zu;var fE=(D)=>D.length>=1,yE=(D)=>D.length>=1;class b0{#D;#u;#E;length;#B;#$;#U;#z;#Y;#Q;#K=!0;constructor(D,u,F,C){if(!fE(D))throw new TypeError("empty pattern list");if(!yE(u))throw new TypeError("empty glob list");if(u.length!==D.length)throw new TypeError("mismatched pattern list and glob list lengths");if(this.length=D.length,F<0||F>=this.length)throw new TypeError("index out of range");if(this.#D=D,this.#u=u,this.#E=F,this.#B=C,this.#E===0){if(this.isUNC()){let[B,$,E,Q,...X]=this.#D,[Z,Y,J,A,...H]=this.#u;if(X[0]==="")X.shift(),H.shift();let G=[B,$,E,Q,""].join("/"),z=[Z,Y,J,A,""].join("/");this.#D=[G,...X],this.#u=[z,...H],this.length=this.#D.length}else if(this.isDrive()||this.isAbsolute()){let[B,...$]=this.#D,[E,...Q]=this.#u;if($[0]==="")$.shift(),Q.shift();let X=B+"/",Z=E+"/";this.#D=[X,...$],this.#u=[Z,...Q],this.length=this.#D.length}}}pattern(){return this.#D[this.#E]}isString(){return typeof this.#D[this.#E]==="string"}isGlobstar(){return this.#D[this.#E]===XD}isRegExp(){return this.#D[this.#E]instanceof RegExp}globString(){return this.#U=this.#U||(this.#E===0?this.isAbsolute()?this.#u[0]+this.#u.slice(1).join("/"):this.#u.join("/"):this.#u.slice(this.#E).join("/"))}hasMore(){return this.length>this.#E+1}rest(){if(this.#$!==void 0)return this.#$;if(!this.hasMore())return this.#$=null;return this.#$=new b0(this.#D,this.#u,this.#E+1,this.#B),this.#$.#Q=this.#Q,this.#$.#Y=this.#Y,this.#$.#z=this.#z,this.#$}isUNC(){let D=this.#D;return this.#Y!==void 0?this.#Y:this.#Y=this.#B==="win32"&&this.#E===0&&D[0]===""&&D[1]===""&&typeof D[2]==="string"&&!!D[2]&&typeof D[3]==="string"&&!!D[3]}isDrive(){let D=this.#D;return this.#z!==void 0?this.#z:this.#z=this.#B==="win32"&&this.#E===0&&this.length>1&&typeof D[0]==="string"&&/^[a-z]:$/i.test(D[0])}isAbsolute(){let D=this.#D;return this.#Q!==void 0?this.#Q:this.#Q=D[0]===""&&D.length>1||this.isDrive()||this.isUNC()}root(){let D=this.#D[0];return typeof D==="string"&&this.isAbsolute()&&this.#E===0?D:""}checkFollowGlobstar(){return!(this.#E===0||!this.isGlobstar()||!this.#K)}markFollowGlobstar(){if(this.#E===0||!this.isGlobstar()||!this.#K)return!1;return this.#K=!1,!0}}var hE=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class _u{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(D,{nobrace:u,nocase:F,noext:C,noglobstar:B,platform:$=hE}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=$,this.mmopts={dot:!0,nobrace:u,nocase:F,noext:C,noglobstar:B,optimizationLevel:2,platform:$,nocomment:!0,nonegate:!0};for(let E of D)this.add(E)}add(D){let u=new fD(D,this.mmopts);for(let F=0;F[D,!!(u&2),!!(u&1)])}}class P1{store=new Map;add(D,u){if(!D.canReaddir())return;let F=this.store.get(D);if(F){if(!F.find((C)=>C.globString()===u.globString()))F.push(u)}else this.store.set(D,[u])}get(D){let u=this.store.get(D);if(!u)throw new Error("attempting to walk unknown path");return u}entries(){return this.keys().map((D)=>[D,this.store.get(D)])}keys(){return[...this.store.keys()].filter((D)=>D.canReaddir())}}class Uu{hasWalkedCache;matches=new k1;subwalks=new P1;patterns;follow;dot;opts;constructor(D,u){this.opts=D,this.follow=!!D.follow,this.dot=!!D.dot,this.hasWalkedCache=u?u.copy():new E3}processPatterns(D,u){this.patterns=u;let F=u.map((C)=>[D,C]);for(let[C,B]of F){this.hasWalkedCache.storeWalked(C,B);let $=B.root(),E=B.isAbsolute()&&this.opts.absolute!==!1;if($){C=C.resolve($==="/"&&this.opts.root!==void 0?this.opts.root:$);let Y=B.rest();if(!Y){this.matches.add(C,!0,!1);continue}else B=Y}if(C.isENOENT())continue;let Q,X,Z=!1;while(typeof(Q=B.pattern())==="string"&&(X=B.rest()))C=C.resolve(Q),B=X,Z=!0;if(Q=B.pattern(),X=B.rest(),Z){if(this.hasWalkedCache.hasWalked(C,B))continue;this.hasWalkedCache.storeWalked(C,B)}if(typeof Q==="string"){let Y=Q===".."||Q===""||Q===".";this.matches.add(C.resolve(Q),E,Y);continue}else if(Q===XD){if(!C.isSymbolicLink()||this.follow||B.checkFollowGlobstar())this.subwalks.add(C,B);let Y=X?.pattern(),J=X?.rest();if(!X||(Y===""||Y===".")&&!J)this.matches.add(C,E,Y===""||Y===".");else if(Y===".."){let A=C.parent||C;if(!J)this.matches.add(A,E,!0);else if(!this.hasWalkedCache.hasWalked(A,J))this.subwalks.add(A,J)}}else if(Q instanceof RegExp)this.subwalks.add(C,B)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new Uu(this.opts,this.hasWalkedCache)}filterEntries(D,u){let F=this.subwalks.get(D),C=this.child();for(let B of u)for(let $ of F){let E=$.isAbsolute(),Q=$.pattern(),X=$.rest();if(Q===XD)C.testGlobstar(B,$,X,E);else if(Q instanceof RegExp)C.testRegExp(B,Q,X,E);else C.testString(B,Q,X,E)}return C}testGlobstar(D,u,F,C){if(this.dot||!D.name.startsWith(".")){if(!u.hasMore())this.matches.add(D,C,!1);if(D.canReaddir()){if(this.follow||!D.isSymbolicLink())this.subwalks.add(D,u);else if(D.isSymbolicLink()){if(F&&u.checkFollowGlobstar())this.subwalks.add(D,F);else if(u.markFollowGlobstar())this.subwalks.add(D,u)}}}if(F){let B=F.pattern();if(typeof B==="string"&&B!==".."&&B!==""&&B!==".")this.testString(D,B,F.rest(),C);else if(B===".."){let $=D.parent||D;this.subwalks.add($,F)}else if(B instanceof RegExp)this.testRegExp(D,B,F.rest(),C)}}testRegExp(D,u,F,C){if(!u.test(D.name))return;if(!F)this.matches.add(D,C,!1);else this.subwalks.add(D,F)}testString(D,u,F,C){if(!D.isNamed(u))return;if(!F)this.matches.add(D,C,!1);else this.subwalks.add(D,F)}}var gE=(D,u)=>typeof D==="string"?new _u([D],u):Array.isArray(D)?new _u(D,u):D;class $3{path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#D=[];#u;#E;signal;maxDepth;includeChildMatches;constructor(D,u,F){if(this.patterns=D,this.path=u,this.opts=F,this.#E=!F.posix&&F.platform==="win32"?"\\":"/",this.includeChildMatches=F.includeChildMatches!==!1,F.ignore||!this.includeChildMatches){if(this.#u=gE(F.ignore??[],F),!this.includeChildMatches&&typeof this.#u.add!=="function")throw new Error("cannot ignore child matches, ignore lacks add() method.")}if(this.maxDepth=F.maxDepth||1/0,F.signal)this.signal=F.signal,this.signal.addEventListener("abort",()=>{this.#D.length=0})}#B(D){return this.seen.has(D)||!!this.#u?.ignored?.(D)}#$(D){return!!this.#u?.childrenIgnored?.(D)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let D=void 0;while(!this.paused&&(D=this.#D.shift()))D()}onResume(D){if(this.signal?.aborted)return;if(!this.paused)D();else this.#D.push(D)}async matchCheck(D,u){if(u&&this.opts.nodir)return;let F;if(this.opts.realpath){if(F=D.realpathCached()||await D.realpath(),!F)return;D=F}let B=D.isUnknown()||this.opts.stat?await D.lstat():D;if(this.opts.follow&&this.opts.nodir&&B?.isSymbolicLink()){let $=await B.realpath();if($&&($.isUnknown()||this.opts.stat))await $.lstat()}return this.matchCheckTest(B,u)}matchCheckTest(D,u){return D&&(this.maxDepth===1/0||D.depth()<=this.maxDepth)&&(!u||D.canReaddir())&&(!this.opts.nodir||!D.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!D.isSymbolicLink()||!D.realpathCached()?.isDirectory())&&!this.#B(D)?D:void 0}matchCheckSync(D,u){if(u&&this.opts.nodir)return;let F;if(this.opts.realpath){if(F=D.realpathCached()||D.realpathSync(),!F)return;D=F}let B=D.isUnknown()||this.opts.stat?D.lstatSync():D;if(this.opts.follow&&this.opts.nodir&&B?.isSymbolicLink()){let $=B.realpathSync();if($&&($?.isUnknown()||this.opts.stat))$.lstatSync()}return this.matchCheckTest(B,u)}matchFinish(D,u){if(this.#B(D))return;if(!this.includeChildMatches&&this.#u?.add){let B=`${D.relativePosix()}/**`;this.#u.add(B)}let F=this.opts.absolute===void 0?u:this.opts.absolute;this.seen.add(D);let C=this.opts.mark&&D.isDirectory()?this.#E:"";if(this.opts.withFileTypes)this.matchEmit(D);else if(F){let B=this.opts.posix?D.fullpathPosix():D.fullpath();this.matchEmit(B+C)}else{let B=this.opts.posix?D.relativePosix():D.relative(),$=this.opts.dotRelative&&!B.startsWith(".."+this.#E)?"."+this.#E:"";this.matchEmit(!B?"."+C:$+B+C)}}async match(D,u,F){let C=await this.matchCheck(D,F);if(C)this.matchFinish(C,u)}matchSync(D,u,F){let C=this.matchCheckSync(D,F);if(C)this.matchFinish(C,u)}walkCB(D,u,F){if(this.signal?.aborted)F();this.walkCB2(D,u,new Uu(this.opts),F)}walkCB2(D,u,F,C){if(this.#$(D))return C();if(this.signal?.aborted)C();if(this.paused){this.onResume(()=>this.walkCB2(D,u,F,C));return}F.processPatterns(D,u);let B=1,$=()=>{if(--B===0)C()};for(let[E,Q,X]of F.matches.entries()){if(this.#B(E))continue;B++,this.match(E,Q,X).then(()=>$())}for(let E of F.subwalkTargets()){if(this.maxDepth!==1/0&&E.depth()>=this.maxDepth)continue;B++;let Q=E.readdirCached();if(E.calledReaddir())this.walkCB3(E,Q,F,$);else E.readdirCB((X,Z)=>this.walkCB3(E,Z,F,$),!0)}$()}walkCB3(D,u,F,C){F=F.filterEntries(D,u);let B=1,$=()=>{if(--B===0)C()};for(let[E,Q,X]of F.matches.entries()){if(this.#B(E))continue;B++,this.match(E,Q,X).then(()=>$())}for(let[E,Q]of F.subwalks.entries())B++,this.walkCB2(E,Q,F.child(),$);$()}walkCBSync(D,u,F){if(this.signal?.aborted)F();this.walkCB2Sync(D,u,new Uu(this.opts),F)}walkCB2Sync(D,u,F,C){if(this.#$(D))return C();if(this.signal?.aborted)C();if(this.paused){this.onResume(()=>this.walkCB2Sync(D,u,F,C));return}F.processPatterns(D,u);let B=1,$=()=>{if(--B===0)C()};for(let[E,Q,X]of F.matches.entries()){if(this.#B(E))continue;this.matchSync(E,Q,X)}for(let E of F.subwalkTargets()){if(this.maxDepth!==1/0&&E.depth()>=this.maxDepth)continue;B++;let Q=E.readdirSync();this.walkCB3Sync(E,Q,F,$)}$()}walkCB3Sync(D,u,F,C){F=F.filterEntries(D,u);let B=1,$=()=>{if(--B===0)C()};for(let[E,Q,X]of F.matches.entries()){if(this.#B(E))continue;this.matchSync(E,Q,X)}for(let[E,Q]of F.subwalks.entries())B++,this.walkCB2Sync(E,Q,F.child(),$);$()}}class VF extends $3{matches=new Set;constructor(D,u,F){super(D,u,F)}matchEmit(D){this.matches.add(D)}async walk(){if(this.signal?.aborted)throw this.signal.reason;if(this.path.isUnknown())await this.path.lstat();return await new Promise((D,u)=>{this.walkCB(this.path,this.patterns,()=>{if(this.signal?.aborted)u(this.signal.reason);else D(this.matches)})}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;if(this.path.isUnknown())this.path.lstatSync();return this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}}class AF extends $3{results;constructor(D,u,F){super(D,u,F);this.results=new U0({signal:this.signal,objectMode:!0}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume())}matchEmit(D){if(this.results.write(D),!this.results.flowing)this.pause()}stream(){let D=this.path;if(D.isUnknown())D.lstat().then(()=>{this.walkCB(D,this.patterns,()=>this.results.end())});else this.walkCB(D,this.patterns,()=>this.results.end());return this.results}streamSync(){if(this.path.isUnknown())this.path.lstatSync();return this.walkCBSync(this.path,this.patterns,()=>this.results.end()),this.results}}var dE=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class D0{absolute;cwd;root;dot;dotRelative;follow;ignore;magicalBraces;mark;matchBase;maxDepth;nobrace;nocase;nodir;noext;noglobstar;pattern;platform;realpath;scurry;stat;signal;windowsPathsNoEscape;withFileTypes;includeChildMatches;opts;patterns;constructor(D,u){if(!u)throw new TypeError("glob options required");if(this.withFileTypes=!!u.withFileTypes,this.signal=u.signal,this.follow=!!u.follow,this.dot=!!u.dot,this.dotRelative=!!u.dotRelative,this.nodir=!!u.nodir,this.mark=!!u.mark,!u.cwd)this.cwd="";else if(u.cwd instanceof URL||u.cwd.startsWith("file://"))u.cwd=mE(u.cwd);if(this.cwd=u.cwd||"",this.root=u.root,this.magicalBraces=!!u.magicalBraces,this.nobrace=!!u.nobrace,this.noext=!!u.noext,this.realpath=!!u.realpath,this.absolute=u.absolute,this.includeChildMatches=u.includeChildMatches!==!1,this.noglobstar=!!u.noglobstar,this.matchBase=!!u.matchBase,this.maxDepth=typeof u.maxDepth==="number"?u.maxDepth:1/0,this.stat=!!u.stat,this.ignore=u.ignore,this.withFileTypes&&this.absolute!==void 0)throw new Error("cannot set absolute and withFileTypes:true");if(typeof D==="string")D=[D];if(this.windowsPathsNoEscape=!!u.windowsPathsNoEscape||u.allowWindowsEscape===!1,this.windowsPathsNoEscape)D=D.map((Q)=>Q.replace(/\\/g,"/"));if(this.matchBase){if(u.noglobstar)throw new TypeError("base matching requires globstar");D=D.map((Q)=>Q.includes("/")?Q:`./**/${Q}`)}if(this.pattern=D,this.platform=u.platform||dE,this.opts={...u,platform:this.platform},u.scurry){if(this.scurry=u.scurry,u.nocase!==void 0&&u.nocase!==u.scurry.nocase)throw new Error("nocase option contradicts provided scurry option")}else{let Q=u.platform==="win32"?Gu:u.platform==="darwin"?qF:u.platform?zu:w1;this.scurry=new Q(this.cwd,{nocase:u.nocase,fs:u.fs})}this.nocase=this.scurry.nocase;let F=this.platform==="darwin"||this.platform==="win32",C={...u,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:F,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},B=this.pattern.map((Q)=>new fD(Q,C)),[$,E]=B.reduce((Q,X)=>{return Q[0].push(...X.set),Q[1].push(...X.globParts),Q},[[],[]]);this.patterns=$.map((Q,X)=>{let Z=E[X];if(!Z)throw new Error("invalid pattern object");return new b0(Q,Z,0,this.platform)})}async walk(){return[...await new VF(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walk()]}walkSync(){return[...new VF(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walkSync()]}stream(){return new AF(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).stream()}streamSync(){return new AF(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).streamSync()}iterateSync(){return this.streamSync()[Symbol.iterator]()}[Symbol.iterator](){return this.iterateSync()}iterate(){return this.stream()[Symbol.asyncIterator]()}[Symbol.asyncIterator](){return this.iterate()}}var Q3=(D,u={})=>{if(!Array.isArray(D))D=[D];for(let F of D)if(new fD(F,u).hasMagic())return!0;return!1};function GF(D,u={}){return new D0(D,u).streamSync()}function x1(D,u={}){return new D0(D,u).stream()}function b1(D,u={}){return new D0(D,u).walkSync()}async function S1(D,u={}){return new D0(D,u).walk()}function zF(D,u={}){return new D0(D,u).iterateSync()}function v1(D,u={}){return new D0(D,u).iterate()}var cE=GF,lE=Object.assign(x1,{sync:GF}),pE=zF,aE=Object.assign(v1,{sync:zF}),nE=Object.assign(b1,{stream:GF,iterate:zF}),HF=Object.assign(S1,{glob:S1,globSync:b1,sync:nE,globStream:x1,stream:lE,globStreamSync:GF,streamSync:cE,globIterate:v1,iterate:aE,globIterateSync:zF,iterateSync:pE,Glob:D0,hasMagic:Q3,escape:k0,unescape:rD});HF.glob=HF;qD();async function y1(D,u={}){let F=k.getInstance().getTrashDirectory();if(!f1(F))iE(F,{recursive:!0});let C=Array.isArray(D)?D:[D];for(let B of C){let $=await HF(B),E=$.length>0?$:[B];for(let Q of E)try{if(!f1(Q)){if(!u.force){console.error(`trash: ${Q}: No such file or directory`);continue}continue}if(oE(Q).isDirectory()&&!u.recursive){if(!u.force){console.error(`trash: ${Q}: is a directory`);continue}}let Z=tE(Q),Y=Date.now(),J=sE(F,`${Z}.${Y}`);rE(Q,J),console.log(`Moved ${Z} to trash`)}catch(X){if(!u.force){let Z=X instanceof Error?X.message:String(X);console.error(`trash: ${Q}: ${Z}`)}}}}import{readdirSync as g1,statSync as m1}from"fs";import{join as d1}from"path";qD();function eE(D){let u=D.lastIndexOf(".");if(u===-1)return{name:D,timestamp:0};let F=parseInt(D.substring(u+1));if(isNaN(F))return{name:D,timestamp:0};return{name:D.substring(0,u),timestamp:F}}function h1(D){if(D===0)return"0 B";let u=1024,F=["B","KB","MB","GB"],C=Math.floor(Math.log(D)/Math.log(u));return parseFloat((D/Math.pow(u,C)).toFixed(2))+" "+F[C]}function c1(D){let u=0,F=g1(D);for(let C of F){let B=d1(D,C),$=m1(B);if($.isDirectory())u+=c1(B);else u+=$.size}return u}async function l1(){let D=k.getInstance().getTrashDirectory();try{let u=g1(D);if(u.length===0){GD.info("\uD83D\uDDD1\uFE0F Trash is empty");return}let F=u.map((E)=>{let Q=d1(D,E),X=m1(Q),{name:Z,timestamp:Y}=eE(E),J=X.isDirectory()?c1(Q):X.size;return{originalName:Z,trashedName:E,size:J,trashedAt:new Date(Y),isDirectory:X.isDirectory()}});F.sort((E,Q)=>Q.trashedAt.getTime()-E.trashedAt.getTime()),console.log(` \uD83D\uDDD1\uFE0F Trash Contents -`),console.log("\u2500".repeat(80));let C=0,B=0,$=0;for(let E of F){if(C+=E.size,E.isDirectory)B++;else $++;let Q=E.isDirectory?"\uD83D\uDCC1":"\uD83D\uDCC4",X=E.trashedAt.toLocaleString(),Z=y1(E.size);console.log(`${Q} ${E.originalName}`),console.log(` Size: ${Z} | Trashed: ${X}`),console.log(` ID: ${E.trashedName}`),console.log()}console.log("\u2500".repeat(80)),console.log(`Total: ${B} folders, ${$} files (${y1(C)})`),console.log(` -To restore files: claude-mem restore`),console.log("To empty trash: claude-mem trash empty")}catch(u){if(u.code==="ENOENT")GD.info("\uD83D\uDDD1\uFE0F Trash is empty");else GD.error("Failed to read trash directory"),console.error(u)}}import{rmSync as tE,readdirSync as eE,existsSync as D5,statSync as u5}from"fs";import{join as l1}from"path";qD();async function p1(D={}){let u=k.getInstance().getTrashDirectory();if(!D5(u)){GD.info("\uD83D\uDDD1\uFE0F Trash is already empty");return}try{let F=eE(u);if(F.length===0){GD.info("\uD83D\uDDD1\uFE0F Trash is already empty");return}let C=0,B=0;for(let E of F){let Q=l1(u,E);if(u5(Q).isDirectory())C++;else B++}if(!D.force){let E=await R0({message:`Permanently delete ${C} folders and ${B} files from trash?`,initialValue:!1});if(PD(E)||!E){GD.info("Cancelled - trash not emptied");return}}let $=E8();$.start("Emptying trash...");for(let E of F){let Q=l1(u,E);tE(Q,{recursive:!0,force:!0})}$.stop(`\uD83D\uDDD1\uFE0F Trash emptied - permanently deleted ${C} folders and ${B} files`)}catch(F){GD.error("Failed to empty trash"),console.error(F),process.exit(1)}}import{readdirSync as F5,renameSync as C5}from"fs";import{join as a1}from"path";qD();async function n1(){let D=k.getInstance().getTrashDirectory(),u=F5(D);if(u.length===0){console.log("Trash is empty");return}let F=await Pu({message:"Select file to restore:",options:u.map((C)=>({value:C,label:C}))});if(PD(F))return;C5(a1(D,F),a1(process.cwd(),F)),console.log(`Restored ${F}`)}import{query as r1}from"@anthropic-ai/claude-agent-sdk";import n from"fs";import RD from"path";import{execSync as i1}from"child_process";async function s1(D){try{if(D.update){await o1(D);return}let u=RD.join(process.cwd(),"package.json"),F="unknown",C="unknown";if(n.existsSync(u))try{let W=JSON.parse(n.readFileSync(u,"utf-8"));F=W.version||"unknown",C=W.name||RD.basename(process.cwd())}catch(W){C=RD.basename(process.cwd())}let B=[],$=D.historical||1;if(D.generate)B.push(D.generate),$=1,console.log(`\uD83C\uDFAF Generating changelog for specific version: ${D.generate}`);else if(F!=="unknown"){let W=F.split(".");if(W.length===3){let T=parseInt(W[0]),b=parseInt(W[1]),v=parseInt(W[2]);for(let w=0;w<$;w++)if(B.push(`${T}.${b}.${v}`),v===0){if(b===0)break;b--,v=9}else v--}}if(B.length===0)console.log("\u26A0\uFE0F Could not determine versions to search. Please check package.json"),process.exit(1);let E=RD.join(process.env.HOME||process.env.USERPROFILE||"",".claude-mem","projects"),Q=RD.join(E,`${C}-changelog.jsonl`),X=!1;if(n.existsSync(Q)){let W=n.readFileSync(Q,"utf-8").split(` +`),console.log("\u2500".repeat(80));let C=0,B=0,$=0;for(let E of F){if(C+=E.size,E.isDirectory)B++;else $++;let Q=E.isDirectory?"\uD83D\uDCC1":"\uD83D\uDCC4",X=E.trashedAt.toLocaleString(),Z=h1(E.size);console.log(`${Q} ${E.originalName}`),console.log(` Size: ${Z} | Trashed: ${X}`),console.log(` ID: ${E.trashedName}`),console.log()}console.log("\u2500".repeat(80)),console.log(`Total: ${B} folders, ${$} files (${h1(C)})`),console.log(` +To restore files: claude-mem restore`),console.log("To empty trash: claude-mem trash empty")}catch(u){if(u.code==="ENOENT")GD.info("\uD83D\uDDD1\uFE0F Trash is empty");else GD.error("Failed to read trash directory"),console.error(u)}}import{rmSync as D5,readdirSync as u5,existsSync as F5,statSync as C5}from"fs";import{join as p1}from"path";qD();async function a1(D={}){let u=k.getInstance().getTrashDirectory();if(!F5(u)){GD.info("\uD83D\uDDD1\uFE0F Trash is already empty");return}try{let F=u5(u);if(F.length===0){GD.info("\uD83D\uDDD1\uFE0F Trash is already empty");return}let C=0,B=0;for(let E of F){let Q=p1(u,E);if(C5(Q).isDirectory())C++;else B++}if(!D.force){let E=await R0({message:`Permanently delete ${C} folders and ${B} files from trash?`,initialValue:!1});if(PD(E)||!E){GD.info("Cancelled - trash not emptied");return}}let $=$8();$.start("Emptying trash...");for(let E of F){let Q=p1(u,E);D5(Q,{recursive:!0,force:!0})}$.stop(`\uD83D\uDDD1\uFE0F Trash emptied - permanently deleted ${C} folders and ${B} files`)}catch(F){GD.error("Failed to empty trash"),console.error(F),process.exit(1)}}import{readdirSync as B5,renameSync as E5}from"fs";import{join as n1}from"path";qD();async function r1(){let D=k.getInstance().getTrashDirectory(),u=B5(D);if(u.length===0){console.log("Trash is empty");return}let F=await Pu({message:"Select file to restore:",options:u.map((C)=>({value:C,label:C}))});if(PD(F))return;E5(n1(D,F),n1(process.cwd(),F)),console.log(`Restored ${F}`)}import{query as i1}from"@anthropic-ai/claude-agent-sdk";import n from"fs";import RD from"path";import{execSync as o1}from"child_process";async function t1(D){try{if(D.update){await s1(D);return}let u=RD.join(process.cwd(),"package.json"),F="unknown",C="unknown";if(n.existsSync(u))try{let W=JSON.parse(n.readFileSync(u,"utf-8"));F=W.version||"unknown",C=W.name||RD.basename(process.cwd())}catch(W){C=RD.basename(process.cwd())}let B=[],$=D.historical||1;if(D.generate)B.push(D.generate),$=1,console.log(`\uD83C\uDFAF Generating changelog for specific version: ${D.generate}`);else if(F!=="unknown"){let W=F.split(".");if(W.length===3){let T=parseInt(W[0]),b=parseInt(W[1]),v=parseInt(W[2]);for(let w=0;w<$;w++)if(B.push(`${T}.${b}.${v}`),v===0){if(b===0)break;b--,v=9}else v--}}if(B.length===0)console.log("\u26A0\uFE0F Could not determine versions to search. Please check package.json"),process.exit(1);let E=RD.join(process.env.HOME||process.env.USERPROFILE||"",".claude-mem","projects"),Q=RD.join(E,`${C}-changelog.jsonl`),X=!1;if(n.existsSync(Q)){let W=n.readFileSync(Q,"utf-8").split(` `).filter((T)=>T.trim());for(let T of W)try{if(JSON.parse(T).version===F)X=!0}catch(b){}if(!D.historical&&!D.generate&&$===1){if(X)console.log(`\u274C Version ${F} already has changelog entries.`),console.log(` \uD83D\uDCDD Workflow:`),console.log(" 1. Make your code updates"),console.log(" 2. Build and test: bun run build"),console.log(" 3. Bump version: npm version patch"),console.log(" 4. Generate changelog: claude-mem changelog"),console.log(` 5. Commit and push -`),console.log("\uD83D\uDCA1 Or use --historical 1 to regenerate this version's changelog"),process.exit(1)}}let Z=[];if(D.start&&D.end){let W=D.generate||F;Z.push({version:W,startTime:D.start,endTime:D.end}),console.log(`\uD83D\uDCC5 Using custom time range for ${W}:`),console.log(` Start: ${new Date(D.start).toLocaleString()}`),console.log(` End: ${new Date(D.end).toLocaleString()}`)}else try{let W=i1(`npm view ${C} time --json`,{encoding:"utf-8",timeout:5000}),T=JSON.parse(W),b="";if($>1){let w=B[B.length-1].split("."),g=parseInt(w[0]),m=parseInt(w[1]),gD=parseInt(w[2]);if(gD>0)b=`${g}.${m}.${gD-1}`;else if(m>0){let Q0=`${g}.${m-1}.`,r=Object.keys(T).filter((ZD)=>ZD.startsWith(Q0)).sort((ZD,mD)=>{let u0=parseInt(ZD.split(".")[2]||"0");return parseInt(mD.split(".")[2]||"0")-u0});if(r.length>0)b=r[0]}else if(g>0){let Q0=`${g-1}.`,r=Object.keys(T).filter((ZD)=>ZD.startsWith(Q0)).sort((ZD,mD)=>{let[,u0,$D]=ZD.split(".").map(Number),[,YD,f0]=mD.split(".").map(Number);if(u0!==YD)return YD-u0;return f0-$D});if(r.length>0)b=r[0]}if(D.verbose&&b&&T[b])console.log(`\uD83D\uDCCD Using ${b} as start boundary for time ranges`)}for(let v=0;v0)mD=`${Q0}.${r}.${ZD-1}`;else if(r>0){let u0=`${Q0}.${r-1}.`,$D=Object.keys(T).filter((YD)=>YD.startsWith(u0)).sort((YD,f0)=>{let UF=parseInt(YD.split(".")[2]||"0");return parseInt(f0.split(".")[2]||"0")-UF});if($D.length>0)mD=$D[0]}if(T[mD])g=T[mD]}else if(v1){let w=B[B.length-1].split("."),g=parseInt(w[0]),m=parseInt(w[1]),gD=parseInt(w[2]);if(gD>0)b=`${g}.${m}.${gD-1}`;else if(m>0){let Q0=`${g}.${m-1}.`,r=Object.keys(T).filter((ZD)=>ZD.startsWith(Q0)).sort((ZD,mD)=>{let u0=parseInt(ZD.split(".")[2]||"0");return parseInt(mD.split(".")[2]||"0")-u0});if(r.length>0)b=r[0]}else if(g>0){let Q0=`${g-1}.`,r=Object.keys(T).filter((ZD)=>ZD.startsWith(Q0)).sort((ZD,mD)=>{let[,u0,$D]=ZD.split(".").map(Number),[,YD,f0]=mD.split(".").map(Number);if(u0!==YD)return YD-u0;return f0-$D});if(r.length>0)b=r[0]}if(D.verbose&&b&&T[b])console.log(`\uD83D\uDCCD Using ${b} as start boundary for time ranges`)}for(let v=0;v0)mD=`${Q0}.${r}.${ZD-1}`;else if(r>0){let u0=`${Q0}.${r-1}.`,$D=Object.keys(T).filter((YD)=>YD.startsWith(u0)).sort((YD,f0)=>{let UF=parseInt(YD.split(".")[2]||"0");return parseInt(f0.split(".")[2]||"0")-UF});if($D.length>0)mD=$D[0]}if(T[mD])g=T[mD]}else if(v0?`You are helping generate a changelog by searching for memories within specific time ranges for multiple versions. PROJECT: ${C} @@ -648,10 +648,10 @@ Return a JSON object with this structure: } Group memories by the version they belong to based on timestamp. -Start searching now.`:"ERROR: No time ranges available. This should never happen.";if(Z.length===0)console.log("\u274C No time ranges available. Cannot search memories."),process.exit(1);if(D.verbose)console.log("\uD83D\uDCDD Calling Claude to search memories...");let J=await r1({prompt:Y,options:{allowedTools:["mcp__claude-mem__chroma_query_documents","mcp__claude-mem__chroma_get_documents"],pathToClaudeCodeExecutable:Fu()}}),A="";if(J&&typeof J==="object"&&Symbol.asyncIterator in J){for await(let W of J)if(W?.type==="assistant"&&W?.message?.content){let T=W.message.content;if(typeof T==="string")A+=T;else if(Array.isArray(T)){for(let b of T)if(b.type==="text"&&b.text)A+=b.text}}}let H=[];try{let W=A.match(/```json\n([\s\S]*?)\n```/)||A.match(/\{[\s\S]*\}/);if(W){let T=JSON.parse(W[1]||W[0]);if(T.memories&&Array.isArray(T.memories))H=T.memories}}catch(W){console.error("\u26A0\uFE0F Could not parse memory search results:",W)}if(H.length===0){console.log(` +Start searching now.`:"ERROR: No time ranges available. This should never happen.";if(Z.length===0)console.log("\u274C No time ranges available. Cannot search memories."),process.exit(1);if(D.verbose)console.log("\uD83D\uDCDD Calling Claude to search memories...");let J=await i1({prompt:Y,options:{allowedTools:["mcp__claude-mem__chroma_query_documents","mcp__claude-mem__chroma_get_documents"],pathToClaudeCodeExecutable:Fu()}}),A="";if(J&&typeof J==="object"&&Symbol.asyncIterator in J){for await(let W of J)if(W?.type==="assistant"&&W?.message?.content){let T=W.message.content;if(typeof T==="string")A+=T;else if(Array.isArray(T)){for(let b of T)if(b.type==="text"&&b.text)A+=b.text}}}let H=[];try{let W=A.match(/```json\n([\s\S]*?)\n```/)||A.match(/\{[\s\S]*\}/);if(W){let T=JSON.parse(W[1]||W[0]);if(T.memories&&Array.isArray(T.memories))H=T.memories}}catch(W){console.error("\u26A0\uFE0F Could not parse memory search results:",W)}if(H.length===0){console.log(` \u26A0\uFE0F No version-related memories found for this version.`),console.log(" This is normal for the first release or when no changes were tracked."),console.log(" Creating a placeholder changelog entry...");let W={version:B[0],date:z,type:"Changed",description:"Initial release or minor updates",timestamp:new Date().toISOString(),generatedAt:new Date().toISOString()};if(!n.existsSync(E))n.mkdirSync(E,{recursive:!0});let T=JSON.stringify(W)+` -`;n.appendFileSync(Q,T),console.log(`\u2705 Created placeholder changelog entry for v${B[0]}`),await o1(D);return}console.log(`\u2705 Found ${H.length} version-related memories -`);let z=i1('date "+%Y-%m-%d %H:%M:%S %Z"').toString().trim().split(" ")[0],U=`Analyze these memories and generate changelog entries. +`;n.appendFileSync(Q,T),console.log(`\u2705 Created placeholder changelog entry for v${B[0]}`),await s1(D);return}console.log(`\u2705 Found ${H.length} version-related memories +`);let z=o1('date "+%Y-%m-%d %H:%M:%S %Z"').toString().trim().split(" ")[0],U=`Analyze these memories and generate changelog entries. PROJECT: ${C} DATE: ${z} @@ -683,7 +683,7 @@ Return ONLY a JSON array with this structure: "type": "Fixed", "description": "Bug fix description" } -]`;console.log("\uD83D\uDD04 Generating changelog entries...");let I=await r1({prompt:U,options:{allowedTools:[],pathToClaudeCodeExecutable:Fu()}}),j="";if(I&&typeof I==="object"&&Symbol.asyncIterator in I){for await(let W of I)if(W?.type==="assistant"&&W?.message?.content){let T=W.message.content;if(typeof T==="string")j+=T;else if(Array.isArray(T)){for(let b of T)if(b.type==="text"&&b.text)j+=b.text}}}let R=[];try{let W=j.match(/```json\n([\s\S]*?)\n```/)||j.match(/\[[\s\S]*\]/);if(W){let T=JSON.parse(W[1]||W[0]);if(Array.isArray(T)){let b=new Date().toISOString();R=T.map((v)=>({...v,date:z,timestamp:v.timestamp||b,generatedAt:b}))}}}catch(W){console.error("\u26A0\uFE0F Could not parse changelog entries:",W)}if(R.length===0)console.log("\u26A0\uFE0F No changelog entries generated."),process.exit(1);if(!n.existsSync(E))n.mkdirSync(E,{recursive:!0});if(console.log(` +]`;console.log("\uD83D\uDD04 Generating changelog entries...");let I=await i1({prompt:U,options:{allowedTools:[],pathToClaudeCodeExecutable:Fu()}}),j="";if(I&&typeof I==="object"&&Symbol.asyncIterator in I){for await(let W of I)if(W?.type==="assistant"&&W?.message?.content){let T=W.message.content;if(typeof T==="string")j+=T;else if(Array.isArray(T)){for(let b of T)if(b.type==="text"&&b.text)j+=b.text}}}let R=[];try{let W=j.match(/```json\n([\s\S]*?)\n```/)||j.match(/\[[\s\S]*\]/);if(W){let T=JSON.parse(W[1]||W[0]);if(Array.isArray(T)){let b=new Date().toISOString();R=T.map((v)=>({...v,date:z,timestamp:v.timestamp||b,generatedAt:b}))}}}catch(W){console.error("\u26A0\uFE0F Could not parse changelog entries:",W)}if(R.length===0)console.log("\u26A0\uFE0F No changelog entries generated."),process.exit(1);if(!n.existsSync(E))n.mkdirSync(E,{recursive:!0});if(console.log(` \uD83D\uDCBE Saving ${R.length} changelog entries to ${RD.basename(Q)}`),D.historical&&$>1||D.generate){let W=[];if(n.existsSync(Q)){let v=n.readFileSync(Q,"utf-8").split(` `).filter((w)=>w.trim());for(let w of v)try{let g=JSON.parse(w);if(!B.includes(g.version))W.push(g)}catch(g){}}let b=[...W,...R].map((v)=>JSON.stringify(v)).join(` `)+` @@ -709,7 +709,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). `).slice(0,30).join(` `)),x.split(` `).length>30)console.log(` -... (truncated for preview)`)}}catch(u){if(console.error("\u274C Error generating changelog:",u instanceof Error?u.message:u),u instanceof Error&&u.stack)console.error("Stack:",u.stack);process.exit(1)}}async function o1(D){try{let u=RD.join(process.cwd(),"package.json"),F="unknown";if(n.existsSync(u))try{F=JSON.parse(n.readFileSync(u,"utf-8")).name||RD.basename(process.cwd())}catch(J){F=RD.basename(process.cwd())}let C=RD.join(process.env.HOME||process.env.USERPROFILE||"",".claude-mem","projects"),B=RD.join(C,`${F}-changelog.jsonl`);if(!n.existsSync(B))console.log("\u274C No changelog entries found. Generate some first with: claude-mem changelog"),process.exit(1);console.log("\uD83D\uDCDD Updating CHANGELOG.md from JSONL entries...");let $=[],E=n.readFileSync(B,"utf-8").split(` +... (truncated for preview)`)}}catch(u){if(console.error("\u274C Error generating changelog:",u instanceof Error?u.message:u),u instanceof Error&&u.stack)console.error("Stack:",u.stack);process.exit(1)}}async function s1(D){try{let u=RD.join(process.cwd(),"package.json"),F="unknown";if(n.existsSync(u))try{F=JSON.parse(n.readFileSync(u,"utf-8")).name||RD.basename(process.cwd())}catch(J){F=RD.basename(process.cwd())}let C=RD.join(process.env.HOME||process.env.USERPROFILE||"",".claude-mem","projects"),B=RD.join(C,`${F}-changelog.jsonl`);if(!n.existsSync(B))console.log("\u274C No changelog entries found. Generate some first with: claude-mem changelog"),process.exit(1);console.log("\uD83D\uDCDD Updating CHANGELOG.md from JSONL entries...");let $=[],E=n.readFileSync(B,"utf-8").split(` `).filter((J)=>J.trim());for(let J of E)try{$.push(JSON.parse(J))}catch(A){}if($.length===0)console.log("\u274C No valid entries found in JSONL file"),process.exit(1);let Q=new Map;for(let J of $){if(!Q.has(J.version))Q.set(J.version,[]);Q.get(J.version).push(J)}let X=`# Changelog All notable changes to this project will be documented in this file. @@ -728,11 +728,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). `).slice(0,30).join(` `)),X.split(` `).length>30)console.log(` -... (truncated for preview)`)}}catch(u){console.error("\u274C Error updating changelog:",u instanceof Error?u.message:u),process.exit(1)}}qD();import v0 from"fs";import B5 from"path";function E5(D){let u=D.status==="pass"?"\u2705":D.status==="warn"?"\u26A0\uFE0F ":"\u274C",F=D.details?`${D.name}: ${D.details}`:D.name;console.log(`${u} ${F}`)}async function t1(D={}){let u=k.getInstance(),F=[];try{let B=u.getDataDirectory();if(!v0.existsSync(B))v0.mkdirSync(B,{recursive:!0}),F.push({name:`Data directory created at ${B}`,status:"warn"});else{let $=v0.statSync(B),E=!1;try{v0.accessSync(B,v0.constants.W_OK),E=!0}catch{}F.push({name:`Data directory ${B}`,status:$.isDirectory()&&E?"pass":"fail",details:$.isDirectory()&&E?"accessible":"not writable"})}}catch(B){F.push({name:"Data directory",status:"fail",details:B?.message||String(B)})}let C;try{C=await nD();let B=C.sessions.count();F.push({name:"SQLite database",status:"pass",details:`${B} session${B===1?"":"s"} present`})}catch(B){F.push({name:"SQLite database",status:"fail",details:B?.message||String(B)})}try{let B=u.getChromaDirectory(),$=v0.existsSync(B);F.push({name:"Chroma vector store",status:$?"pass":"warn",details:$?`data dir ${B5.resolve(B)}`:"Not yet initialized"})}catch(B){F.push({name:"Chroma vector store",status:"warn",details:B?.message||"Unable to check Chroma directory"})}if(D.json)console.log(JSON.stringify({checks:F},null,2));else console.log("claude-mem doctor"),console.log("================="),F.forEach(E5);DF("info","doctor run completed",{status:F.map((B)=>B.status)})}import{spawnSync as e1}from"child_process";async function DC(D){let{id:u,project:F,session:C,date:B,title:$,subtitle:E,facts:Q,concepts:X,files:Z}=D;if(!u||!F||!C||!B)console.error("Error: All fields required: --id, --project, --session, --date"),process.exit(1);if(!$||!E||!Q)console.error("Error: Hierarchical format required: --title, --subtitle, --facts"),process.exit(1);try{let Y=await nD(),J=new Date().toISOString();if(!await Y.sessions.has(C))await Y.sessions.create({session_id:C,project:F,created_at:J,source:"save"});let H,G,z;try{H=Q?JSON.stringify(JSON.parse(Q)):void 0}catch(I){H=Q}try{G=X?JSON.stringify(JSON.parse(X)):void 0}catch(I){G=X}try{z=Z?JSON.stringify(JSON.parse(Z)):void 0}catch(I){z=Z}if(!Y.memories.hasDocumentId(u))Y.memories.create({document_id:u,text:"",keywords:"",session_id:C,project:F,created_at:J,origin:"streaming-sdk",title:$||void 0,subtitle:E||void 0,facts:H,concepts:G,files_touched:z});if(H){let I=JSON.parse(H),j=G?JSON.parse(G):[],R=z?JSON.parse(z):[];I.forEach((M,P)=>{e1("claude-mem",["chroma_add_documents","--collection_name","claude_memories","--documents",JSON.stringify([M]),"--ids",JSON.stringify([`${u}_fact_${String(P).padStart(3,"0")}`]),"--metadatas",JSON.stringify([{type:"fact",parent_id:u,fact_index:P,title:$,subtitle:E,project:F,session_id:C,created_at:J,created_at_epoch:Date.parse(J),keywords:"",concepts:JSON.stringify(j),files_touched:JSON.stringify(R),origin:"streaming-sdk"}])])}),e1("claude-mem",["chroma_add_documents","--collection_name","claude_memories","--documents",JSON.stringify([`${$} +... (truncated for preview)`)}}catch(u){console.error("\u274C Error updating changelog:",u instanceof Error?u.message:u),process.exit(1)}}qD();import v0 from"fs";import $5 from"path";function Q5(D){let u=D.status==="pass"?"\u2705":D.status==="warn"?"\u26A0\uFE0F ":"\u274C",F=D.details?`${D.name}: ${D.details}`:D.name;console.log(`${u} ${F}`)}async function e1(D={}){let u=k.getInstance(),F=[];try{let B=u.getDataDirectory();if(!v0.existsSync(B))v0.mkdirSync(B,{recursive:!0}),F.push({name:`Data directory created at ${B}`,status:"warn"});else{let $=v0.statSync(B),E=!1;try{v0.accessSync(B,v0.constants.W_OK),E=!0}catch{}F.push({name:`Data directory ${B}`,status:$.isDirectory()&&E?"pass":"fail",details:$.isDirectory()&&E?"accessible":"not writable"})}}catch(B){F.push({name:"Data directory",status:"fail",details:B?.message||String(B)})}let C;try{C=await nD();let B=C.sessions.count();F.push({name:"SQLite database",status:"pass",details:`${B} session${B===1?"":"s"} present`})}catch(B){F.push({name:"SQLite database",status:"fail",details:B?.message||String(B)})}try{let B=u.getChromaDirectory(),$=v0.existsSync(B);F.push({name:"Chroma vector store",status:$?"pass":"warn",details:$?`data dir ${$5.resolve(B)}`:"Not yet initialized"})}catch(B){F.push({name:"Chroma vector store",status:"warn",details:B?.message||"Unable to check Chroma directory"})}if(D.json)console.log(JSON.stringify({checks:F},null,2));else console.log("claude-mem doctor"),console.log("================="),F.forEach(Q5);DF("info","doctor run completed",{status:F.map((B)=>B.status)})}import{spawnSync as DC}from"child_process";async function uC(D){let{id:u,project:F,session:C,date:B,title:$,subtitle:E,facts:Q,concepts:X,files:Z}=D;if(!u||!F||!C||!B)console.error("Error: All fields required: --id, --project, --session, --date"),process.exit(1);if(!$||!E||!Q)console.error("Error: Hierarchical format required: --title, --subtitle, --facts"),process.exit(1);try{let Y=await nD(),J=new Date().toISOString();if(!await Y.sessions.has(C))await Y.sessions.create({session_id:C,project:F,created_at:J,source:"save"});let H,G,z;try{H=Q?JSON.stringify(JSON.parse(Q)):void 0}catch(I){H=Q}try{G=X?JSON.stringify(JSON.parse(X)):void 0}catch(I){G=X}try{z=Z?JSON.stringify(JSON.parse(Z)):void 0}catch(I){z=Z}if(!Y.memories.hasDocumentId(u))Y.memories.create({document_id:u,text:"",keywords:"",session_id:C,project:F,created_at:J,origin:"streaming-sdk",title:$||void 0,subtitle:E||void 0,facts:H,concepts:G,files_touched:z});if(H){let I=JSON.parse(H),j=G?JSON.parse(G):[],R=z?JSON.parse(z):[];I.forEach((M,P)=>{DC("claude-mem",["chroma_add_documents","--collection_name","claude_memories","--documents",JSON.stringify([M]),"--ids",JSON.stringify([`${u}_fact_${String(P).padStart(3,"0")}`]),"--metadatas",JSON.stringify([{type:"fact",parent_id:u,fact_index:P,title:$,subtitle:E,project:F,session_id:C,created_at:J,created_at_epoch:Date.parse(J),keywords:"",concepts:JSON.stringify(j),files_touched:JSON.stringify(R),origin:"streaming-sdk"}])])}),DC("claude-mem",["chroma_add_documents","--collection_name","claude_memories","--documents",JSON.stringify([`${$} ${E} ${I.join(` -`)}`]),"--ids",JSON.stringify([u]),"--metadatas",JSON.stringify([{type:"narrative",title:$,subtitle:E,facts_count:I.length,project:F,session_id:C,created_at:J,created_at_epoch:Date.parse(J),keywords:"",concepts:JSON.stringify(j),files_touched:JSON.stringify(R),origin:"streaming-sdk"}])])}console.log(JSON.stringify({success:!0,memory_id:u,project:F,session:C,date:B,timestamp:J,hierarchical:!!($&&E&&Q)}))}catch(Y){console.error(JSON.stringify({success:!1,error:Y.message||"Unknown error storing memory"})),process.exit(1)}}async function uC(D){let{project:u,session:F,content:C}=D;if(!u||!F||!C)console.error("Error: All fields required: --project, --session, --content"),process.exit(1);try{let B=await nD(),$=new Date().toISOString();B.overviews.upsert({session_id:F,content:C,created_at:$,project:u,origin:"streaming-sdk"}),console.log(JSON.stringify({success:!0,project:u,session:F,timestamp:$}))}catch(B){console.error(JSON.stringify({success:!1,error:B.message||"Unknown error storing overview"})),process.exit(1)}}import FC from"path";import X3 from"fs";var $5=FC.join(process.env.HOME||"",".claude-mem","sessions");async function CC(D){let{project:u,session:F,title:C,subtitle:B}=D;if(!u||!F)console.error(JSON.stringify({success:!1,error:"Missing required fields: --project, --session"})),process.exit(1);if(!C)console.error(JSON.stringify({success:!1,error:"Missing required field: --title"})),process.exit(1);try{let $=FC.join($5,`${u}_streaming.json`);if(!X3.existsSync($))console.error(JSON.stringify({success:!1,error:`Session file not found: ${$}`})),process.exit(1);let E={};try{E=JSON.parse(X3.readFileSync($,"utf8"))}catch(Q){console.error(JSON.stringify({success:!1,error:"Failed to parse session file"})),process.exit(1)}if(E.promptTitle=C,B)E.promptSubtitle=B;E.updatedAt=new Date().toISOString(),X3.writeFileSync($,JSON.stringify(E,null,2)),console.log(JSON.stringify({success:!0,title:C,subtitle:B||null,project:u,session:F}))}catch($){console.error(JSON.stringify({success:!1,error:$.message||"Unknown error updating session metadata"})),process.exit(1)}}import{query as Q5}from"@anthropic-ai/claude-agent-sdk";aD();su();tu();async function BC(D,u){if(!D||D.trim().length===0)console.error(JSON.stringify({success:!1,error:"Prompt is required"})),process.exit(1);let F=null,C=null;if(u.sessionId)try{let $=jD.getInstance();for(let Q of uu)$.registerMigration(Q);let E=await $.initialize();if(F=new O0(E),C=F.getByClaudeSessionId(u.sessionId),!C)console.error(JSON.stringify({success:!1,error:`Session not found: ${u.sessionId}`})),process.exit(1)}catch($){console.error(JSON.stringify({success:!1,error:`Database error: ${$.message}`})),process.exit(1)}let B=`You are a title and subtitle generator for claude-mem session metadata. +`)}`]),"--ids",JSON.stringify([u]),"--metadatas",JSON.stringify([{type:"narrative",title:$,subtitle:E,facts_count:I.length,project:F,session_id:C,created_at:J,created_at_epoch:Date.parse(J),keywords:"",concepts:JSON.stringify(j),files_touched:JSON.stringify(R),origin:"streaming-sdk"}])])}console.log(JSON.stringify({success:!0,memory_id:u,project:F,session:C,date:B,timestamp:J,hierarchical:!!($&&E&&Q)}))}catch(Y){console.error(JSON.stringify({success:!1,error:Y.message||"Unknown error storing memory"})),process.exit(1)}}async function FC(D){let{project:u,session:F,content:C}=D;if(!u||!F||!C)console.error("Error: All fields required: --project, --session, --content"),process.exit(1);try{let B=await nD(),$=new Date().toISOString();B.overviews.upsert({session_id:F,content:C,created_at:$,project:u,origin:"streaming-sdk"}),console.log(JSON.stringify({success:!0,project:u,session:F,timestamp:$}))}catch(B){console.error(JSON.stringify({success:!1,error:B.message||"Unknown error storing overview"})),process.exit(1)}}import CC from"path";import X3 from"fs";var X5=CC.join(process.env.HOME||"",".claude-mem","sessions");async function BC(D){let{project:u,session:F,title:C,subtitle:B}=D;if(!u||!F)console.error(JSON.stringify({success:!1,error:"Missing required fields: --project, --session"})),process.exit(1);if(!C)console.error(JSON.stringify({success:!1,error:"Missing required field: --title"})),process.exit(1);try{let $=CC.join(X5,`${u}_streaming.json`);if(!X3.existsSync($))console.error(JSON.stringify({success:!1,error:`Session file not found: ${$}`})),process.exit(1);let E={};try{E=JSON.parse(X3.readFileSync($,"utf8"))}catch(Q){console.error(JSON.stringify({success:!1,error:"Failed to parse session file"})),process.exit(1)}if(E.promptTitle=C,B)E.promptSubtitle=B;E.updatedAt=new Date().toISOString(),X3.writeFileSync($,JSON.stringify(E,null,2)),console.log(JSON.stringify({success:!0,title:C,subtitle:B||null,project:u,session:F}))}catch($){console.error(JSON.stringify({success:!1,error:$.message||"Unknown error updating session metadata"})),process.exit(1)}}import{query as Z5}from"@anthropic-ai/claude-agent-sdk";aD();su();tu();async function EC(D,u){if(!D||D.trim().length===0)console.error(JSON.stringify({success:!1,error:"Prompt is required"})),process.exit(1);let F=null,C=null;if(u.sessionId)try{let $=jD.getInstance();for(let Q of uu)$.registerMigration(Q);let E=await $.initialize();if(F=new O0(E),C=F.getByClaudeSessionId(u.sessionId),!C)console.error(JSON.stringify({success:!1,error:`Session not found: ${u.sessionId}`})),process.exit(1)}catch($){console.error(JSON.stringify({success:!1,error:`Database error: ${$.message}`})),process.exit(1)}let B=`You are a title and subtitle generator for claude-mem session metadata. Your job is to analyze a user's request and generate: 1. A concise title (3-8 words) @@ -775,5 +775,5 @@ Adding theme toggle and dark color scheme support to the application USER REQUEST: ${D} -Now generate the title and subtitle (two lines exactly):`;try{let $=await Q5({prompt:B,options:{allowedTools:[],pathToClaudeCodeExecutable:Fu()}}),E="";if($&&typeof $==="object"&&Symbol.asyncIterator in $){for await(let Y of $)if(Y?.type==="assistant"&&Y?.message?.content){let J=Y.message.content;if(typeof J==="string")E+=J;else if(Array.isArray(J)){for(let A of J)if(A.type==="text"&&A.text)E+=A.text}}}let Q=E.trim().split(` -`).filter((Y)=>Y.trim().length>0);if(Q.length<2)console.error(JSON.stringify({success:!1,error:"Could not generate title and subtitle",response:E})),process.exit(1);let X=Q[0].trim(),Z=Q[1].trim();if(u.save&&F&&C)try{F.update(C.id,{title:X,subtitle:Z})}catch(Y){console.error(JSON.stringify({success:!1,error:`Failed to save title: ${Y.message}`})),process.exit(1)}if(u.json)console.log(JSON.stringify({success:!0,title:X,subtitle:Z,sessionId:C?.claude_session_id},null,2));else if(u.oneline)console.log(`${X} - ${Z}`);else console.log(X),console.log(Z)}catch($){console.error(JSON.stringify({success:!1,error:$.message||"Unknown error generating title"})),process.exit(1)}}var DD=new O3;DD.name(L0).description(b3).version(x3);DD.command("install").description("Install Claude Code hooks for automatic compression").option("--user","Install for current user (default)").option("--project","Install for current project only").option("--local","Install to custom local directory").option("--path ","Custom installation path (with --local)").option("--timeout ","Hook execution timeout in milliseconds","180000").option("--skip-mcp","Skip Chroma MCP server installation").option("--force","Force installation even if already installed").action(K6);DD.command("uninstall").description("Remove Claude Code hooks").option("--user","Remove from user settings (default)").option("--project","Remove from project settings").option("--all","Remove from both user and project settings").action(A6);DD.command("status").description("Check installation status of Claude Memory System").action(_6);DD.command("doctor").description("Run environment and pipeline diagnostics for rolling memory").option("--json","Output JSON instead of text").action(async(D)=>{try{await t1(D)}catch(u){console.error(`doctor failed: ${u.message||u}`),process.exitCode=1}});DD.command("logs").description("View claude-mem operation logs").option("--debug","Show debug logs only").option("--error","Show error logs only").option("--tail [n]","Show last n lines","50").option("--follow","Follow log output").action(W6);DD.command("load-context").description("Load compressed memories for current session").option("--project ","Filter by project name").option("--count ","Number of memories to load","10").option("--raw","Output raw JSON instead of formatted text").option("--format ","Output format: json, session-start, or default").action(m6);var Z3=DD.command("trash").description("Manage trash bin for safe file deletion").argument("[files...]","Files to move to trash").option("-r, --recursive","Remove directories recursively").option("-R","Remove directories recursively (same as -r)").option("-f, --force","Suppress errors for nonexistent files").action(async(D,u)=>{if(!D||D.length===0){Z3.outputHelp();return}if(u.R)u.recursive=!0;await f1(D,{force:u.force,recursive:u.recursive})});Z3.command("view").description("View contents of trash bin").action(c1);Z3.command("empty").description("Permanently delete all files in trash").option("-f, --force","Skip confirmation prompt").action(p1);DD.command("restore").description("Restore files from trash interactively").action(n1);DD.command("store-memory").description("Store a memory to all storage layers (used by SDK)").requiredOption("--id ","Memory ID").requiredOption("--project ","Project name").requiredOption("--session ","Session ID").requiredOption("--date ","Date (YYYY-MM-DD)").requiredOption("--title ","Memory title (3-8 words)").requiredOption("--subtitle <subtitle>","Memory subtitle (max 24 words)").requiredOption("--facts <json>","Atomic facts as JSON array").option("--concepts <json>","Concept tags as JSON array").option("--files <json>","Files touched as JSON array").action(DC);DD.command("store-overview").description("Store a session overview (used by SDK)").requiredOption("--project <project>","Project name").requiredOption("--session <session>","Session ID").requiredOption("--content <content>","Overview content").action(uC);DD.command("update-session-metadata").description("Update session title and subtitle (used by SDK)").requiredOption("--project <project>","Project name").requiredOption("--session <session>","Session ID").requiredOption("--title <title>","Session title (3-6 words)").option("--subtitle <subtitle>","Session subtitle (max 20 words)").action(CC);DD.command("changelog").description("Generate CHANGELOG.md from claude-mem memories").option("--historical <n>","Number of versions to search (default: current version only)").option("--generate <version>","Generate changelog for a specific version").option("--start <time>","Start time for memory search (ISO format)").option("--end <time>","End time for memory search (ISO format)").option("--update","Update CHANGELOG.md from JSONL entries").option("--preview","Preview the generated changelog").option("-v, --verbose","Show detailed output").action(s1);DD.command("generate-title <prompt>").description("Generate a session title and subtitle from a prompt").option("--json","Output as JSON").option("--oneline","Output as single line (title - subtitle)").option("--session-id <id>","Claude session ID to update").option("--save","Save the generated title to the database (requires --session-id)").action(BC);DD.command("context").description("SessionStart hook - show recent session context").action(async()=>{let{contextHook:D}=await Promise.resolve().then(() => (Lu(),Wu)),u=await _F();D(JSON.parse(u))});DD.command("new").description("UserPromptSubmit hook - initialize SDK session").action(async()=>{let{newHook:D}=await Promise.resolve().then(() => (Lu(),Wu)),u=await _F();D(JSON.parse(u))});DD.command("save").description("PostToolUse hook - queue observation").action(async()=>{let{saveHook:D}=await Promise.resolve().then(() => (Lu(),Wu)),u=await _F();D(JSON.parse(u))});DD.command("summary").description("Stop hook - finalize session").action(async()=>{let{summaryHook:D}=await Promise.resolve().then(() => (Lu(),Wu)),u=await _F();D(JSON.parse(u))});async function _F(){return new Promise((D)=>{let u="";process.stdin.on("data",(F)=>{u+=F}),process.stdin.on("end",()=>{D(u)})})}DD.parse();export{uu as migrations,L2 as initializeDatabase,_D as getDatabase,O0 as StreamingSessionStore,jD as DatabaseManager}; +Now generate the title and subtitle (two lines exactly):`;try{let $=await Z5({prompt:B,options:{allowedTools:[],pathToClaudeCodeExecutable:Fu()}}),E="";if($&&typeof $==="object"&&Symbol.asyncIterator in $){for await(let Y of $)if(Y?.type==="assistant"&&Y?.message?.content){let J=Y.message.content;if(typeof J==="string")E+=J;else if(Array.isArray(J)){for(let A of J)if(A.type==="text"&&A.text)E+=A.text}}}let Q=E.trim().split(` +`).filter((Y)=>Y.trim().length>0);if(Q.length<2)console.error(JSON.stringify({success:!1,error:"Could not generate title and subtitle",response:E})),process.exit(1);let X=Q[0].trim(),Z=Q[1].trim();if(u.save&&F&&C)try{F.update(C.id,{title:X,subtitle:Z})}catch(Y){console.error(JSON.stringify({success:!1,error:`Failed to save title: ${Y.message}`})),process.exit(1)}if(u.json)console.log(JSON.stringify({success:!0,title:X,subtitle:Z,sessionId:C?.claude_session_id},null,2));else if(u.oneline)console.log(`${X} - ${Z}`);else console.log(X),console.log(Z)}catch($){console.error(JSON.stringify({success:!1,error:$.message||"Unknown error generating title"})),process.exit(1)}}var DD=new j3;DD.name(L0).description(v3).version(b3);DD.command("install").description("Install Claude Code hooks for automatic compression").option("--user","Install for current user (default)").option("--project","Install for current project only").option("--local","Install to custom local directory").option("--path <path>","Custom installation path (with --local)").option("--timeout <ms>","Hook execution timeout in milliseconds","180000").option("--skip-mcp","Skip Chroma MCP server installation").option("--force","Force installation even if already installed").action(q6);DD.command("uninstall").description("Remove Claude Code hooks").option("--user","Remove from user settings (default)").option("--project","Remove from project settings").option("--all","Remove from both user and project settings").action(H6);DD.command("status").description("Check installation status of Claude Memory System").action(U6);DD.command("doctor").description("Run environment and pipeline diagnostics for rolling memory").option("--json","Output JSON instead of text").action(async(D)=>{try{await e1(D)}catch(u){console.error(`doctor failed: ${u.message||u}`),process.exitCode=1}});DD.command("logs").description("View claude-mem operation logs").option("--debug","Show debug logs only").option("--error","Show error logs only").option("--tail [n]","Show last n lines","50").option("--follow","Follow log output").action(L6);DD.command("load-context").description("Load compressed memories for current session").option("--project <name>","Filter by project name").option("--count <n>","Number of memories to load","10").option("--raw","Output raw JSON instead of formatted text").option("--format <type>","Output format: json, session-start, or default").action(d6);var Y3=DD.command("trash").description("Manage trash bin for safe file deletion").argument("[files...]","Files to move to trash").option("-r, --recursive","Remove directories recursively").option("-R","Remove directories recursively (same as -r)").option("-f, --force","Suppress errors for nonexistent files").action(async(D,u)=>{if(!D||D.length===0){Y3.outputHelp();return}if(u.R)u.recursive=!0;await y1(D,{force:u.force,recursive:u.recursive})});Y3.command("view").description("View contents of trash bin").action(l1);Y3.command("empty").description("Permanently delete all files in trash").option("-f, --force","Skip confirmation prompt").action(a1);DD.command("restore").description("Restore files from trash interactively").action(r1);DD.command("store-memory").description("Store a memory to all storage layers (used by SDK)").requiredOption("--id <id>","Memory ID").requiredOption("--project <project>","Project name").requiredOption("--session <session>","Session ID").requiredOption("--date <date>","Date (YYYY-MM-DD)").requiredOption("--title <title>","Memory title (3-8 words)").requiredOption("--subtitle <subtitle>","Memory subtitle (max 24 words)").requiredOption("--facts <json>","Atomic facts as JSON array").option("--concepts <json>","Concept tags as JSON array").option("--files <json>","Files touched as JSON array").action(uC);DD.command("store-overview").description("Store a session overview (used by SDK)").requiredOption("--project <project>","Project name").requiredOption("--session <session>","Session ID").requiredOption("--content <content>","Overview content").action(FC);DD.command("update-session-metadata").description("Update session title and subtitle (used by SDK)").requiredOption("--project <project>","Project name").requiredOption("--session <session>","Session ID").requiredOption("--title <title>","Session title (3-6 words)").option("--subtitle <subtitle>","Session subtitle (max 20 words)").action(BC);DD.command("changelog").description("Generate CHANGELOG.md from claude-mem memories").option("--historical <n>","Number of versions to search (default: current version only)").option("--generate <version>","Generate changelog for a specific version").option("--start <time>","Start time for memory search (ISO format)").option("--end <time>","End time for memory search (ISO format)").option("--update","Update CHANGELOG.md from JSONL entries").option("--preview","Preview the generated changelog").option("-v, --verbose","Show detailed output").action(t1);DD.command("generate-title <prompt>").description("Generate a session title and subtitle from a prompt").option("--json","Output as JSON").option("--oneline","Output as single line (title - subtitle)").option("--session-id <id>","Claude session ID to update").option("--save","Save the generated title to the database (requires --session-id)").action(EC);DD.command("context").description("SessionStart hook - show recent session context").action(async()=>{let{contextHook:D}=await Promise.resolve().then(() => (Lu(),Wu)),u=await _F();D(JSON.parse(u))});DD.command("new").description("UserPromptSubmit hook - initialize SDK session").action(async()=>{let{newHook:D}=await Promise.resolve().then(() => (Lu(),Wu)),u=await _F();D(JSON.parse(u))});DD.command("save").description("PostToolUse hook - queue observation").action(async()=>{let{saveHook:D}=await Promise.resolve().then(() => (Lu(),Wu)),u=await _F();D(JSON.parse(u))});DD.command("summary").description("Stop hook - finalize session").action(async()=>{let{summaryHook:D}=await Promise.resolve().then(() => (Lu(),Wu)),u=await _F();D(JSON.parse(u))});async function _F(){return new Promise((D)=>{let u="";process.stdin.on("data",(F)=>{u+=F}),process.stdin.on("end",()=>{D(u)})})}DD.parse();export{uu as migrations,L2 as initializeDatabase,_D as getDatabase,O0 as StreamingSessionStore,jD as DatabaseManager}; diff --git a/src/hooks/new.ts b/src/hooks/new.ts index 59d0b981..81a873ed 100644 --- a/src/hooks/new.ts +++ b/src/hooks/new.ts @@ -1,6 +1,7 @@ import { HooksDatabase } from '../services/sqlite/HooksDatabase.js'; import path from 'path'; import { spawn } from 'child_process'; +import fs from 'fs'; export interface UserPromptSubmitInput { session_id: string; @@ -35,17 +36,30 @@ export function newHook(input: UserPromptSubmitInput): void { const sessionId = db.createSDKSession(session_id, project, prompt); db.close(); - // Start SDK worker in background - // The SDK worker will be implemented in a separate file - // For now, we just create the session record + // Start SDK worker in background as detached process + // Try source first (development), then fall back to dist (production) + const srcWorkerPath = path.join(__dirname, '..', 'sdk', 'worker.ts'); + const distWorkerPath = path.join(__dirname, '..', 'sdk', 'worker.js'); - // TODO: Spawn SDK worker as detached process - // const workerPath = path.join(__dirname, '..', 'sdk', 'worker.js'); - // const child = spawn('bun', [workerPath, sessionId.toString()], { - // detached: true, - // stdio: 'ignore' - // }); - // child.unref(); + let workerPath: string; + if (fs.existsSync(srcWorkerPath)) { + workerPath = srcWorkerPath; + } else if (fs.existsSync(distWorkerPath)) { + workerPath = distWorkerPath; + } else { + // Fallback: assume we're in the bundled CLI + // In this case, we can't spawn the worker since it's bundled + // This is a limitation we'll need to address + console.error('[claude-mem] Worker not found, skipping background processing'); + console.log('{"continue": true, "suppressOutput": true}'); + process.exit(0); + } + + const child = spawn('bun', [workerPath, sessionId.toString()], { + detached: true, + stdio: 'ignore' + }); + child.unref(); // Output hook response console.log('{"continue": true, "suppressOutput": true}'); diff --git a/src/sdk/index.ts b/src/sdk/index.ts new file mode 100644 index 00000000..da7357be --- /dev/null +++ b/src/sdk/index.ts @@ -0,0 +1,8 @@ +/** + * SDK Module Exports + */ + +export { buildInitPrompt, buildObservationPrompt, buildFinalizePrompt } from './prompts.js'; +export { parseObservations, parseSummary } from './parser.js'; +export type { Observation, SDKSession } from './prompts.js'; +export type { ParsedObservation, ParsedSummary } from './parser.js'; diff --git a/src/sdk/parser.ts b/src/sdk/parser.ts new file mode 100644 index 00000000..b39ff6f9 --- /dev/null +++ b/src/sdk/parser.ts @@ -0,0 +1,132 @@ +/** + * XML Parser Module + * Parses observation and summary XML blocks from SDK responses + */ + +export interface ParsedObservation { + type: string; + text: string; +} + +export interface ParsedSummary { + request: string; + investigated: string; + learned: string; + completed: string; + next_steps: string; + files_read: string[]; + files_edited: string[]; + notes: string; +} + +/** + * Parse observation XML blocks from SDK response + * Returns all observations found in the response + */ +export function parseObservations(text: string): ParsedObservation[] { + const observations: ParsedObservation[] = []; + + // Match <observation>...</observation> blocks (non-greedy) + const observationRegex = /<observation>\s*<type>([^<]+)<\/type>\s*<text>([^<]+)<\/text>\s*<\/observation>/g; + + let match; + while ((match = observationRegex.exec(text)) !== null) { + const type = match[1].trim(); + const observationText = match[2].trim(); + + // Validate type + const validTypes = ['decision', 'bugfix', 'feature', 'refactor', 'discovery']; + if (!validTypes.includes(type)) { + console.warn(`[SDK Parser] Invalid observation type: ${type}, skipping`); + continue; + } + + observations.push({ + type, + text: observationText + }); + } + + return observations; +} + +/** + * Parse summary XML block from SDK response + * Returns null if no valid summary found + */ +export function parseSummary(text: string): ParsedSummary | null { + // Match <summary>...</summary> block (non-greedy) + const summaryRegex = /<summary>([\s\S]*?)<\/summary>/; + const summaryMatch = summaryRegex.exec(text); + + if (!summaryMatch) { + return null; + } + + const summaryContent = summaryMatch[1]; + + // Extract required fields + const request = extractField(summaryContent, 'request'); + const investigated = extractField(summaryContent, 'investigated'); + const learned = extractField(summaryContent, 'learned'); + const completed = extractField(summaryContent, 'completed'); + const next_steps = extractField(summaryContent, 'next_steps'); + const notes = extractField(summaryContent, 'notes'); + + // Extract file arrays + const files_read = extractFileArray(summaryContent, 'files_read'); + const files_edited = extractFileArray(summaryContent, 'files_edited'); + + // Validate all required fields are present + if (!request || !investigated || !learned || !completed || !next_steps || !notes) { + console.warn('[SDK Parser] Summary missing required fields'); + return null; + } + + return { + request, + investigated, + learned, + completed, + next_steps, + files_read, + files_edited, + notes + }; +} + +/** + * Extract a simple field value from XML content + */ +function extractField(content: string, fieldName: string): string | null { + const regex = new RegExp(`<${fieldName}>([^<]*)</${fieldName}>`); + const match = regex.exec(content); + return match ? match[1].trim() : null; +} + +/** + * Extract file array from XML content + * Handles both <file> children and empty tags + */ +function extractFileArray(content: string, arrayName: string): string[] { + const files: string[] = []; + + // Match the array block + const arrayRegex = new RegExp(`<${arrayName}>(.*?)</${arrayName}>`, 's'); + const arrayMatch = arrayRegex.exec(content); + + if (!arrayMatch) { + return files; + } + + const arrayContent = arrayMatch[1]; + + // Extract individual <file> elements + const fileRegex = /<file>([^<]+)<\/file>/g; + let fileMatch; + while ((fileMatch = fileRegex.exec(arrayContent)) !== null) { + files.push(fileMatch[1].trim()); + } + + return files; +} diff --git a/src/sdk/prompts.ts b/src/sdk/prompts.ts new file mode 100644 index 00000000..ac0ca878 --- /dev/null +++ b/src/sdk/prompts.ts @@ -0,0 +1,177 @@ +/** + * SDK Prompts Module + * Generates prompts for the Claude Agent SDK memory worker + */ + +export interface Observation { + id: number; + tool_name: string; + tool_input: string; + tool_output: string; + created_at_epoch: number; +} + +export interface SDKSession { + id: number; + sdk_session_id: string | null; + project: string; + user_prompt: string; +} + +/** + * Build initial prompt to initialize the SDK agent + */ +export function buildInitPrompt(project: string, sessionId: string, userPrompt: string): string { + return `You are a memory assistant for the "${project}" project. + +SESSION CONTEXT +--------------- +Session ID: ${sessionId} +User's Goal: ${userPrompt} +Date: ${new Date().toISOString().split('T')[0]} + +YOUR ROLE +--------- +You will observe tool executions during this Claude Code session. Your job is to: + +1. Extract meaningful insights (not just raw data) +2. Store atomic observations in SQLite +3. Focus on: key decisions, patterns discovered, problems solved, technical insights + +WHAT TO CAPTURE +---------------- +✓ Architecture decisions (e.g., "chose PostgreSQL over MongoDB for ACID guarantees") +✓ Bug fixes (e.g., "fixed race condition in auth middleware by adding mutex") +✓ New features (e.g., "implemented JWT refresh token flow") +✓ Refactorings (e.g., "extracted validation logic into separate service") +✓ Discoveries (e.g., "found that API rate limit is 100 req/min") + +✗ NOT routine operations (reading files, listing directories) +✗ NOT work-in-progress (only completed work) +✗ NOT obvious facts (e.g., "TypeScript file has types") + +HOW TO STORE OBSERVATIONS +-------------------------- +When you identify something worth remembering, output your observation in this EXACT XML format: + +\`\`\`xml +<observation> + <type>feature</type> + <text>Implemented JWT token refresh flow with 7-day expiry</text> +</observation> +\`\`\` + +Valid types: decision, bugfix, feature, refactor, discovery + +Structure requirements: +- <observation> is the root element +- <type> must be one of the 5 valid types (single word) +- <text> contains your concise observation (one sentence preferred) +- No additional fields or nesting + +The SDK worker will parse all <observation> blocks from your response using regex and store them in SQLite. + +You can include your reasoning before or after the observation block, or just output the observation by itself. + +EXAMPLE +------- +Bad: "Read src/auth.ts file" +Good: "Implemented JWT token refresh flow with 7-day expiry" + +Wait for tool observations. Acknowledge this message briefly.`; +} + +/** + * Build prompt to send tool observation to SDK agent + */ +export function buildObservationPrompt(obs: Observation): string { + return `TOOL OBSERVATION +================ +Tool: ${obs.tool_name} +Time: ${new Date(obs.created_at_epoch).toISOString()} + +Input: +${JSON.stringify(JSON.parse(obs.tool_input), null, 2)} + +Output: +${JSON.stringify(JSON.parse(obs.tool_output), null, 2)} + +ANALYSIS TASK +------------- +1. Does this observation contain something worth remembering? +2. If YES: Output the observation in this EXACT XML format: + + \`\`\`xml + <observation> + <type>feature</type> + <text>Your concise observation here</text> + </observation> + \`\`\` + + Requirements: + - Use one of these types: decision, bugfix, feature, refactor, discovery + - Keep text concise (one sentence preferred) + - No markdown formatting inside <text> + - No additional XML fields + +3. If NO: Just acknowledge and wait for next observation + +Remember: Quality over quantity. Only store meaningful insights.`; +} + +/** + * Build finalization prompt to generate session summary + */ +export function buildFinalizePrompt(session: SDKSession): string { + return `SESSION ENDING +============== +The Claude Code session is finishing. + +FINAL TASK +---------- +1. Review the observations you've stored this session +2. Generate a structured summary that answers these questions: + - What did user request? + - What did you investigate? + - What did you learn? + - What did you do? + - What's next? + - Files read + - Files edited + - Notes + +3. Generate the structured summary and output it in this EXACT XML format: + +\`\`\`xml +<summary> + <request>Implement JWT authentication system</request> + <investigated>Existing auth middleware, session management, token storage patterns</investigated> + <learned>Current system uses session cookies; no JWT support; race condition in middleware</learned> + <completed>Implemented JWT token + refresh flow with 7-day expiry; fixed race condition with mutex; added token validation middleware</completed> + <next_steps>Add token revocation API endpoint; write integration tests</next_steps> + <files_read> + <file>src/auth.ts</file> + <file>src/middleware/session.ts</file> + <file>src/types/user.ts</file> + </files_read> + <files_edited> + <file>src/auth.ts</file> + <file>src/middleware/auth.ts</file> + <file>src/routes/auth.ts</file> + </files_edited> + <notes>Token secret stored in .env; refresh tokens use rotation strategy</notes> +</summary> +\`\`\` + +Structure requirements: +- <summary> is the root element +- All 8 child elements are REQUIRED: request, investigated, learned, completed, next_steps, files_read, files_edited, notes +- <files_read> and <files_edited> must contain <file> child elements (one per file) +- If no files were read/edited, use empty tags: <files_read></files_read> +- Text fields can be multiple sentences but avoid markdown formatting +- Use underscores in element names: next_steps, files_read, files_edited + +The SDK worker will parse the <summary> block and extract all fields to store in SQLite. + +Generate the summary now in the required XML format.`; +} diff --git a/src/sdk/worker.ts b/src/sdk/worker.ts new file mode 100644 index 00000000..7c2aa11a --- /dev/null +++ b/src/sdk/worker.ts @@ -0,0 +1,217 @@ +#!/usr/bin/env bun +/** + * SDK Worker Process + * Background agent that processes tool observations and generates session summaries + */ + +import { query } from '@anthropic-ai/claude-agent-sdk'; +import { HooksDatabase } from '../services/sqlite/HooksDatabase.js'; +import { buildInitPrompt, buildObservationPrompt, buildFinalizePrompt } from './prompts.js'; +import { parseObservations, parseSummary } from './parser.js'; +import type { Observation, SDKSession } from './prompts.js'; + +const POLL_INTERVAL_MS = 1000; // 1 second +const MODEL = 'claude-sonnet-4-5'; +const DISALLOWED_TOOLS = ['Glob', 'Grep', 'ListMcpResourcesTool', 'WebSearch']; + +/** + * Main worker process entry point + */ +async function main() { + const sessionDbId = parseInt(process.argv[2], 10); + + if (!sessionDbId) { + console.error('[SDK Worker] Missing session ID argument'); + process.exit(1); + } + + const worker = new SDKWorker(sessionDbId); + await worker.run(); +} + +/** + * SDK Worker class - handles the full lifecycle of observation processing + */ +class SDKWorker { + private sessionDbId: number; + private db: HooksDatabase; + private sdkSessionId: string | null = null; + private project: string = ''; + private userPrompt: string = ''; + private abortController: AbortController; + private isFinalized = false; + + constructor(sessionDbId: number) { + this.sessionDbId = sessionDbId; + this.db = new HooksDatabase(); + this.abortController = new AbortController(); + } + + /** + * Main run loop + */ + async run(): Promise<void> { + try { + // Load session info + const session = await this.loadSession(); + if (!session) { + console.error('[SDK Worker] Session not found'); + process.exit(1); + } + + this.project = session.project; + this.userPrompt = session.user_prompt; + + // Run SDK agent with streaming input + await this.runSDKAgent(); + + // Mark session as completed + this.db.markSessionCompleted(this.sessionDbId); + this.db.close(); + + } catch (error: any) { + console.error('[SDK Worker] Error:', error.message); + this.db.markSessionFailed(this.sessionDbId); + this.db.close(); + process.exit(1); + } + } + + /** + * Load session from database + */ + private async loadSession(): Promise<SDKSession | null> { + // Query session by ID + const db = this.db as any; + const query = db.db.query(` + SELECT id, sdk_session_id, project, user_prompt + FROM sdk_sessions + WHERE id = ? + LIMIT 1 + `); + + const session = query.get(this.sessionDbId); + return session as SDKSession | null; + } + + /** + * Run SDK agent with streaming input mode + */ + private async runSDKAgent(): Promise<void> { + const messageGenerator = this.createMessageGenerator(); + + await query({ + model: MODEL, + messages: messageGenerator, + disallowedTools: DISALLOWED_TOOLS, + signal: this.abortController.signal, + onSystemInitMessage: (msg) => { + // Capture SDK session ID from init message + if (msg.session_id) { + this.sdkSessionId = msg.session_id; + this.db.updateSDKSessionId(this.sessionDbId, msg.session_id); + } + }, + onAgentMessage: (msg) => { + // Parse and store observations from agent response + this.handleAgentMessage(msg.content); + } + }); + } + + /** + * Create async message generator for SDK streaming input + */ + private async* createMessageGenerator(): AsyncIterable<{ role: 'user'; content: string }> { + // Yield initial prompt + const claudeSessionId = `session-${this.sessionDbId}`; + const initPrompt = buildInitPrompt(this.project, claudeSessionId, this.userPrompt); + yield { role: 'user', content: initPrompt }; + + // Poll observation queue + while (!this.isFinalized) { + await this.sleep(POLL_INTERVAL_MS); + + if (!this.sdkSessionId) { + continue; // Wait for SDK session ID to be captured + } + + // Get pending observations + const observations = this.db.getPendingObservations(this.sdkSessionId, 10); + + for (const obs of observations) { + // Check for FINALIZE message + if (this.isFinalizationMessage(obs)) { + this.isFinalized = true; + const session = await this.loadSession(); + if (session) { + const finalizePrompt = buildFinalizePrompt(session); + yield { role: 'user', content: finalizePrompt }; + } + this.db.markObservationProcessed(obs.id); + break; + } + + // Send observation to SDK + const observationPrompt = buildObservationPrompt(obs); + yield { role: 'user', content: observationPrompt }; + + // Mark as processed + this.db.markObservationProcessed(obs.id); + } + } + } + + /** + * Handle agent message and parse observations/summaries + */ + private handleAgentMessage(content: string): void { + // Parse observations + const observations = parseObservations(content); + for (const obs of observations) { + if (this.sdkSessionId) { + this.db.storeObservation(this.sdkSessionId, this.project, obs.type, obs.text); + } + } + + // Parse summary (if present) + const summary = parseSummary(content); + if (summary && this.sdkSessionId) { + // Convert file arrays to JSON strings + const summaryWithArrays = { + request: summary.request, + investigated: summary.investigated, + learned: summary.learned, + completed: summary.completed, + next_steps: summary.next_steps, + files_read: JSON.stringify(summary.files_read), + files_edited: JSON.stringify(summary.files_edited), + notes: summary.notes + }; + + this.db.storeSummary(this.sdkSessionId, this.project, summaryWithArrays); + } + } + + /** + * Check if observation is a FINALIZE message + */ + private isFinalizationMessage(obs: Observation): boolean { + return obs.tool_name === 'FINALIZE'; + } + + /** + * Sleep helper + */ + private sleep(ms: number): Promise<void> { + return new Promise(resolve => setTimeout(resolve, ms)); + } +} + +// Run if executed directly +if (import.meta.main) { + main().catch((error) => { + console.error('[SDK Worker] Fatal error:', error); + process.exit(1); + }); +} diff --git a/test-phase2.ts b/test-phase2.ts new file mode 100644 index 00000000..5272d20d --- /dev/null +++ b/test-phase2.ts @@ -0,0 +1,336 @@ +#!/usr/bin/env bun +/** + * Phase 2 End-to-End Tests + * Tests SDK prompts, parser, and integration with HooksDatabase + */ + +import { describe, it, expect, beforeAll, afterAll } from 'bun:test'; +import { buildInitPrompt, buildObservationPrompt, buildFinalizePrompt } from './src/sdk/prompts.js'; +import { parseObservations, parseSummary } from './src/sdk/parser.js'; +import { HooksDatabase } from './src/services/sqlite/HooksDatabase.js'; +import { DatabaseManager } from './src/services/sqlite/Database.js'; +import { migrations } from './src/services/sqlite/migrations.js'; +import fs from 'fs'; +import path from 'path'; + +// Test database path +const TEST_DB_DIR = '/tmp/claude-mem-test'; +const TEST_DB_PATH = path.join(TEST_DB_DIR, 'claude-mem.db'); + +describe('SDK Prompts', () => { + it('should build init prompt with all required sections', () => { + const prompt = buildInitPrompt('test-project', 'session-123', 'Implement JWT auth'); + + expect(prompt).toContain('test-project'); + expect(prompt).toContain('session-123'); + expect(prompt).toContain('Implement JWT auth'); + expect(prompt).toContain('SESSION CONTEXT'); + expect(prompt).toContain('YOUR ROLE'); + expect(prompt).toContain('WHAT TO CAPTURE'); + expect(prompt).toContain('HOW TO STORE OBSERVATIONS'); + expect(prompt).toContain('<observation>'); + expect(prompt).toContain('<type>'); + expect(prompt).toContain('<text>'); + }); + + it('should build observation prompt with tool details', () => { + const obs = { + id: 1, + tool_name: 'Edit', + tool_input: JSON.stringify({ file: 'src/auth.ts' }), + tool_output: JSON.stringify({ success: true }), + created_at_epoch: Date.now() + }; + + const prompt = buildObservationPrompt(obs); + + expect(prompt).toContain('TOOL OBSERVATION'); + expect(prompt).toContain('Edit'); + expect(prompt).toContain('src/auth.ts'); + expect(prompt).toContain('ANALYSIS TASK'); + }); + + it('should build finalize prompt with session context', () => { + const session = { + id: 1, + sdk_session_id: 'sdk-123', + project: 'test-project', + user_prompt: 'Implement JWT auth' + }; + + const prompt = buildFinalizePrompt(session); + + expect(prompt).toContain('SESSION ENDING'); + expect(prompt).toContain('FINAL TASK'); + expect(prompt).toContain('<summary>'); + expect(prompt).toContain('<request>'); + expect(prompt).toContain('<files_read>'); + }); +}); + +describe('XML Parser', () => { + describe('parseObservations', () => { + it('should parse single observation', () => { + const text = ` + <observation> + <type>feature</type> + <text>Implemented JWT token refresh flow</text> + </observation> + `; + + const observations = parseObservations(text); + + expect(observations).toHaveLength(1); + expect(observations[0].type).toBe('feature'); + expect(observations[0].text).toBe('Implemented JWT token refresh flow'); + }); + + it('should parse multiple observations', () => { + const text = ` + <observation> + <type>feature</type> + <text>Implemented JWT token refresh flow</text> + </observation> + <observation> + <type>bugfix</type> + <text>Fixed race condition in auth middleware</text> + </observation> + `; + + const observations = parseObservations(text); + + expect(observations).toHaveLength(2); + expect(observations[0].type).toBe('feature'); + expect(observations[1].type).toBe('bugfix'); + }); + + it('should skip observations with invalid types', () => { + const text = ` + <observation> + <type>invalid-type</type> + <text>This should be skipped</text> + </observation> + <observation> + <type>feature</type> + <text>This should be kept</text> + </observation> + `; + + const observations = parseObservations(text); + + expect(observations).toHaveLength(1); + expect(observations[0].type).toBe('feature'); + }); + + it('should handle observations with surrounding text', () => { + const text = ` + I analyzed the code and found something interesting: + + <observation> + <type>discovery</type> + <text>API rate limit is 100 requests per minute</text> + </observation> + + This is an important finding. + `; + + const observations = parseObservations(text); + + expect(observations).toHaveLength(1); + expect(observations[0].type).toBe('discovery'); + }); + }); + + describe('parseSummary', () => { + it('should parse complete summary with all fields', () => { + const text = ` + <summary> + <request>Implement JWT authentication system</request> + <investigated>Existing auth middleware, session management</investigated> + <learned>Current system uses session cookies; no JWT support</learned> + <completed>Implemented JWT token + refresh flow with 7-day expiry</completed> + <next_steps>Add token revocation API endpoint; write integration tests</next_steps> + <files_read> + <file>src/auth.ts</file> + <file>src/middleware/session.ts</file> + </files_read> + <files_edited> + <file>src/auth.ts</file> + <file>src/middleware/auth.ts</file> + </files_edited> + <notes>Token secret stored in .env</notes> + </summary> + `; + + const summary = parseSummary(text); + + expect(summary).not.toBeNull(); + expect(summary!.request).toBe('Implement JWT authentication system'); + expect(summary!.investigated).toBe('Existing auth middleware, session management'); + expect(summary!.learned).toBe('Current system uses session cookies; no JWT support'); + expect(summary!.completed).toBe('Implemented JWT token + refresh flow with 7-day expiry'); + expect(summary!.next_steps).toBe('Add token revocation API endpoint; write integration tests'); + expect(summary!.files_read).toEqual(['src/auth.ts', 'src/middleware/session.ts']); + expect(summary!.files_edited).toEqual(['src/auth.ts', 'src/middleware/auth.ts']); + expect(summary!.notes).toBe('Token secret stored in .env'); + }); + + it('should handle empty file arrays', () => { + const text = ` + <summary> + <request>Research API documentation</request> + <investigated>API endpoints and authentication methods</investigated> + <learned>API uses OAuth 2.0</learned> + <completed>Documented authentication flow</completed> + <next_steps>Implement OAuth client</next_steps> + <files_read></files_read> + <files_edited></files_edited> + <notes>Documentation is incomplete</notes> + </summary> + `; + + const summary = parseSummary(text); + + expect(summary).not.toBeNull(); + expect(summary!.files_read).toEqual([]); + expect(summary!.files_edited).toEqual([]); + }); + + it('should return null if required fields are missing', () => { + const text = ` + <summary> + <request>Implement JWT authentication system</request> + <investigated>Existing auth middleware</investigated> + </summary> + `; + + const summary = parseSummary(text); + + expect(summary).toBeNull(); + }); + + it('should return null if no summary block found', () => { + const text = 'This is just regular text without a summary.'; + + const summary = parseSummary(text); + + expect(summary).toBeNull(); + }); + }); +}); + +describe('HooksDatabase Integration', () => { + let db: HooksDatabase; + + beforeAll(async () => { + // Create test directory + fs.mkdirSync(TEST_DB_DIR, { recursive: true }); + + // Set test environment + process.env.CLAUDE_MEM_DATA_DIR = TEST_DB_DIR; + + // Initialize database with migrations + const dbManager = DatabaseManager.getInstance(); + migrations.forEach(m => dbManager.registerMigration(m)); + await dbManager.initialize(); + dbManager.close(); + }); + + afterAll(() => { + // Clean up test database and all files + if (fs.existsSync(TEST_DB_DIR)) { + const files = fs.readdirSync(TEST_DB_DIR); + files.forEach(file => { + fs.unlinkSync(path.join(TEST_DB_DIR, file)); + }); + fs.rmdirSync(TEST_DB_DIR); + } + }); + + it('should store and retrieve observations', () => { + db = new HooksDatabase(); + + // Create session + const sessionId = db.createSDKSession('claude-123', 'test-project', 'Test prompt'); + db.updateSDKSessionId(sessionId, 'sdk-123'); + + // Store observation + db.storeObservation('sdk-123', 'test-project', 'feature', 'Implemented JWT auth'); + + // Verify storage + const dbInstance = (db as any).db; + const query = dbInstance.query('SELECT * FROM observations WHERE sdk_session_id = ?'); + const observations = query.all('sdk-123'); + + expect(observations).toHaveLength(1); + expect(observations[0].type).toBe('feature'); + expect(observations[0].text).toBe('Implemented JWT auth'); + expect(observations[0].project).toBe('test-project'); + + db.close(); + }); + + it('should store and retrieve summaries', () => { + db = new HooksDatabase(); + + // Create session + const sessionId = db.createSDKSession('claude-456', 'test-project', 'Test prompt'); + db.updateSDKSessionId(sessionId, 'sdk-456'); + + // Store summary + const summaryData = { + request: 'Implement feature', + investigated: 'Existing code', + learned: 'Found patterns', + completed: 'Implemented feature', + next_steps: 'Add tests', + files_read: JSON.stringify(['src/app.ts']), + files_edited: JSON.stringify(['src/app.ts']), + notes: 'Used TypeScript' + }; + + db.storeSummary('sdk-456', 'test-project', summaryData); + + // Verify storage + const summaries = db.getRecentSummaries('test-project', 10); + + expect(summaries).toHaveLength(1); + expect(summaries[0].request).toBe('Implement feature'); + expect(summaries[0].completed).toBe('Implemented feature'); + + db.close(); + }); + + it('should queue and process observations', () => { + db = new HooksDatabase(); + + // Create session + const sessionId = db.createSDKSession('claude-789', 'test-project', 'Test prompt'); + db.updateSDKSessionId(sessionId, 'sdk-789'); + + // Queue observation + db.queueObservation( + 'sdk-789', + 'Edit', + JSON.stringify({ file: 'src/auth.ts' }), + JSON.stringify({ success: true }) + ); + + // Get pending observations + const pending = db.getPendingObservations('sdk-789', 10); + + expect(pending).toHaveLength(1); + expect(pending[0].tool_name).toBe('Edit'); + + // Mark as processed + db.markObservationProcessed(pending[0].id); + + // Verify no pending observations + const pendingAfter = db.getPendingObservations('sdk-789', 10); + expect(pendingAfter).toHaveLength(0); + + db.close(); + }); +}); + +console.log('Running Phase 2 Tests...');