@php-wasm/xdebug-bridge 2.0.3 → 2.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cli.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";const i=require("./run-cli-DpXpnvR3.cjs");i.main();
1
+ "use strict";const i=require("./run-cli-BKbM-eYC.cjs");i.main();
package/cli.js CHANGED
@@ -1,2 +1,2 @@
1
- import { m } from "./run-cli-II34aG2V.js";
1
+ import { m } from "./run-cli-Cs104r6H.js";
2
2
  m();
package/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./run-cli-DpXpnvR3.cjs");exports.CDPServer=e.CDPServer;exports.DbgpSession=e.DbgpSession;exports.XdebugCDPBridge=e.XdebugCDPBridge;exports.main=e.main;exports.startBridge=e.startBridge;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./run-cli-BKbM-eYC.cjs");exports.CDPServer=e.CDPServer;exports.DbgpSession=e.DbgpSession;exports.XdebugCDPBridge=e.XdebugCDPBridge;exports.main=e.main;exports.startBridge=e.startBridge;
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { C as e, D as r, X as g, m as i, s as D } from "./run-cli-II34aG2V.js";
1
+ import { C as e, D as r, X as g, m as i, s as D } from "./run-cli-Cs104r6H.js";
2
2
  export {
3
3
  e as CDPServer,
4
4
  r as DbgpSession,
@@ -8,6 +8,6 @@ export type StartBridgeConfig = {
8
8
  remoteRoot?: string;
9
9
  localRoot?: string;
10
10
  phpInstance?: PHP;
11
- getPHPFile?: (path: string) => string;
11
+ getPHPFile?: (path: string) => string | Promise<string>;
12
12
  };
13
13
  export declare function startBridge(config: StartBridgeConfig): Promise<XdebugCDPBridge>;
@@ -4,7 +4,7 @@ export interface XdebugCDPBridgeConfig {
4
4
  knownScriptUrls: string[];
5
5
  remoteRoot?: string;
6
6
  localRoot?: string;
7
- getPHPFile(path: string): string;
7
+ getPHPFile(path: string): string | Promise<string>;
8
8
  }
9
9
  export declare class XdebugCDPBridge {
10
10
  private dbgp;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@php-wasm/xdebug-bridge",
3
- "version": "2.0.3",
3
+ "version": "2.0.4",
4
4
  "description": "XDebug bridge server for PHP.wasm",
5
5
  "repository": {
6
6
  "type": "git",
@@ -39,7 +39,7 @@
39
39
  },
40
40
  "license": "GPL-2.0-or-later",
41
41
  "types": "index.d.ts",
42
- "gitHead": "6355c320ae2de93d4a0176e45ded2ad4cc6f4ae2",
42
+ "gitHead": "8fc1b0f5379a854c9df792c14da17a2ba697e562",
43
43
  "engines": {
44
44
  "node": ">=20.18.3",
45
45
  "npm": ">=10.1.0"
@@ -49,7 +49,7 @@
49
49
  "ws": "8.18.1",
50
50
  "xml2js": "0.6.2",
51
51
  "yargs": "17.7.2",
52
- "@php-wasm/universal": "2.0.3"
52
+ "@php-wasm/universal": "2.0.4"
53
53
  },
54
54
  "overrides": {
55
55
  "rollup": "^4.34.6",
@@ -26,7 +26,7 @@
26
26
  * @license
27
27
  * Copyright (c) 2016, Contributors
28
28
  * SPDX-License-Identifier: ISC
29
- */var We,Ve,He;const gr=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):12,yr=(Ve=(We=process==null?void 0:process.versions)===null||We===void 0?void 0:We.node)!==null&&Ve!==void 0?Ve:(He=process==null?void 0:process.version)===null||He===void 0?void 0:He.slice(1);if(yr&&Number(yr.match(/^([^.]+)/)[1])<gr)throw Error(`yargs parser supports a minimum Node.js version of ${gr}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`);const Ls=process?process.env:{},Gi=new As({cwd:process.cwd,env:()=>Ls,format:Vn.format,normalize:xt.normalize,resolve:xt.resolve,require:a=>{if(typeof require<"u")return require(a);if(a.match(/\.json$/))return JSON.parse(Bt.readFileSync(a,"utf8"));throw Error("only .json config files are supported in ESM")}}),Ee=function(t,e){return Gi.parse(t.slice(),e).argv};Ee.detailed=function(a,t){return Gi.parse(a.slice(),t)};Ee.camelCase=he;Ee.decamelize=zi;Ee.looksLikeNumber=Yi;function ki(){return Ss()?0:1}function Ss(){return Fs()&&!process.defaultApp}function Fs(){return!!process.versions.electron}function js(a){return a.slice(ki()+1)}function Rs(){return process.argv[ki()]}class gt extends Error{constructor(t){super(t||"yargs error"),this.name="YError",Error.captureStackTrace&&Error.captureStackTrace(this,gt)}}const Bs={fs:{readFileSync:Bt.readFileSync,writeFile:Bt.writeFile},format:Vn.format,resolve:xt.resolve,exists:a=>{try{return Bt.statSync(a).isFile()}catch{return!1}}};let Lt;class Us{constructor(t){t=t||{},this.directory=t.directory||"./locales",this.updateFiles=typeof t.updateFiles=="boolean"?t.updateFiles:!0,this.locale=t.locale||"en",this.fallbackToLanguage=typeof t.fallbackToLanguage=="boolean"?t.fallbackToLanguage:!0,this.cache=Object.create(null),this.writeQueue=[]}__(...t){if(typeof arguments[0]!="string")return this._taggedLiteral(arguments[0],...arguments);const e=t.shift();let n=function(){};return typeof t[t.length-1]=="function"&&(n=t.pop()),n=n||function(){},this.cache[this.locale]||this._readLocaleFile(),!this.cache[this.locale][e]&&this.updateFiles?(this.cache[this.locale][e]=e,this._enqueueWrite({directory:this.directory,locale:this.locale,cb:n})):n(),Lt.format.apply(Lt.format,[this.cache[this.locale][e]||e].concat(t))}__n(){const t=Array.prototype.slice.call(arguments),e=t.shift(),n=t.shift(),o=t.shift();let i=function(){};typeof t[t.length-1]=="function"&&(i=t.pop()),this.cache[this.locale]||this._readLocaleFile();let r=o===1?e:n;this.cache[this.locale][e]&&(r=this.cache[this.locale][e][o===1?"one":"other"]),!this.cache[this.locale][e]&&this.updateFiles?(this.cache[this.locale][e]={one:e,other:n},this._enqueueWrite({directory:this.directory,locale:this.locale,cb:i})):i();const s=[r];return~r.indexOf("%d")&&s.push(o),Lt.format.apply(Lt.format,s.concat(t))}setLocale(t){this.locale=t}getLocale(){return this.locale}updateLocale(t){this.cache[this.locale]||this._readLocaleFile();for(const e in t)Object.prototype.hasOwnProperty.call(t,e)&&(this.cache[this.locale][e]=t[e])}_taggedLiteral(t,...e){let n="";return t.forEach(function(o,i){const r=e[i+1];n+=o,typeof r<"u"&&(n+="%s")}),this.__.apply(this,[n].concat([].slice.call(e,1)))}_enqueueWrite(t){this.writeQueue.push(t),this.writeQueue.length===1&&this._processWriteQueue()}_processWriteQueue(){const t=this,e=this.writeQueue[0],n=e.directory,o=e.locale,i=e.cb,r=this._resolveLocaleFile(n,o),s=JSON.stringify(this.cache[o],null,2);Lt.fs.writeFile(r,s,"utf-8",function(f){t.writeQueue.shift(),t.writeQueue.length>0&&t._processWriteQueue(),i(f)})}_readLocaleFile(){let t={};const e=this._resolveLocaleFile(this.directory,this.locale);try{Lt.fs.readFileSync&&(t=JSON.parse(Lt.fs.readFileSync(e,"utf-8")))}catch(n){if(n instanceof SyntaxError&&(n.message="syntax error in "+e),n.code==="ENOENT")t={};else throw n}this.cache[this.locale]=t}_resolveLocaleFile(t,e){let n=Lt.resolve(t,"./",e+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(n)&&~e.lastIndexOf("_")){const o=Lt.resolve(t,"./",e.split("_")[0]+".json");this._fileExistsSync(o)&&(n=o)}return n}_fileExistsSync(t){return Lt.exists(t)}}function Xs(a,t){Lt=t;const e=new Us(a);return{__:e.__.bind(e),__n:e.__n.bind(e),setLocale:e.setLocale.bind(e),getLocale:e.getLocale.bind(e),updateLocale:e.updateLocale.bind(e),locale:e.locale}}const $s=a=>Xs(a,Bs),qs="require is not supported by ESM",br="loading a directory of commands is not supported yet for ESM";let be;try{be=as.fileURLToPath(typeof document>"u"?require("url").pathToFileURL(__filename).href:$e&&$e.tagName.toUpperCase()==="SCRIPT"&&$e.src||new URL("run-cli-DpXpnvR3.cjs",document.baseURI).href)}catch{be=process.cwd()}const Ws=be.substring(0,be.lastIndexOf("node_modules")),Vs={assert:{notStrictEqual:fr.notStrictEqual,strictEqual:fr.strictEqual},cliui:_s,findUp:vs,getEnv:a=>process.env[a],inspect:Vn.inspect,getCallerFile:()=>{throw new gt(br)},getProcessArgvBin:Rs,mainFilename:Ws||process.cwd(),Parser:Ee,path:{basename:xt.basename,dirname:xt.dirname,extname:xt.extname,relative:xt.relative,resolve:xt.resolve},process:{argv:()=>process.argv,cwd:process.cwd,emitWarning:(a,t)=>process.emitWarning(a,t),execPath:()=>process.execPath,exit:process.exit,nextTick:process.nextTick,stdColumns:typeof process.stdout.columns<"u"?process.stdout.columns:null},readFileSync:Bt.readFileSync,require:()=>{throw new gt(qs)},requireDirectory:()=>{throw new gt(br)},stringWidth:a=>[...a].length,y18n:$s({directory:xt.resolve(be,"../../../locales"),updateFiles:!1})};function Ft(a,t,e,n){e.assert.notStrictEqual(a,t,n)}function wr(a,t){t.assert.strictEqual(typeof a,"string")}function Re(a){return Object.keys(a)}function yt(a){return!!a&&!!a.then&&typeof a.then=="function"}function me(a){const e=a.replace(/\s{2,}/g," ").split(/\s+(?![^[]*]|[^<]*>)/),n=/\.*[\][<>]/g,o=e.shift();if(!o)throw new Error(`No command found in: ${a}`);const i={cmd:o.replace(n,""),demanded:[],optional:[]};return e.forEach((r,s)=>{let f=!1;r=r.replace(/\s/g,""),/\.+[\]>]/.test(r)&&s===e.length-1&&(f=!0),/^\[/.test(r)?i.optional.push({cmd:r.replace(n,"").split("|"),variadic:f}):i.demanded.push({cmd:r.replace(n,"").split("|"),variadic:f})}),i}const Hs=["first","second","third","fourth","fifth","sixth"];function z(a,t,e){function n(){return typeof a=="object"?[{demanded:[],optional:[]},a,t]:[me(`cmd ${a}`),t,e]}try{let o=0;const[i,r,s]=n(),f=[].slice.call(r);for(;f.length&&f[f.length-1]===void 0;)f.pop();const E=s||f.length;if(E<i.demanded.length)throw new gt(`Not enough arguments provided. Expected ${i.demanded.length} but received ${f.length}.`);const d=i.demanded.length+i.optional.length;if(E>d)throw new gt(`Too many arguments provided. Expected max ${d} but received ${E}.`);i.demanded.forEach(p=>{const b=f.shift(),w=Er(b);p.cmd.filter(v=>v===w||v==="*").length===0&&xr(w,p.cmd,o),o+=1}),i.optional.forEach(p=>{if(f.length===0)return;const b=f.shift(),w=Er(b);p.cmd.filter(v=>v===w||v==="*").length===0&&xr(w,p.cmd,o),o+=1})}catch(o){console.warn(o.stack)}}function Er(a){return Array.isArray(a)?"array":a===null?"null":typeof a}function xr(a,t,e){throw new gt(`Invalid ${Hs[e]||"manyith"} argument. Expected ${t.join(" or ")} but received ${a}.`)}class zs{constructor(t){this.globalMiddleware=[],this.frozens=[],this.yargs=t}addMiddleware(t,e,n=!0,o=!1){if(z("<array|function> [boolean] [boolean] [boolean]",[t,e,n],arguments.length),Array.isArray(t)){for(let i=0;i<t.length;i++){if(typeof t[i]!="function")throw Error("middleware must be a function");const r=t[i];r.applyBeforeValidation=e,r.global=n}Array.prototype.push.apply(this.globalMiddleware,t)}else if(typeof t=="function"){const i=t;i.applyBeforeValidation=e,i.global=n,i.mutates=o,this.globalMiddleware.push(t)}return this.yargs}addCoerceMiddleware(t,e){const n=this.yargs.getAliases();return this.globalMiddleware=this.globalMiddleware.filter(o=>{const i=[...n[e]||[],e];return o.option?!i.includes(o.option):!0}),t.option=e,this.addMiddleware(t,!0,!0,!0)}getMiddleware(){return this.globalMiddleware}freeze(){this.frozens.push([...this.globalMiddleware])}unfreeze(){const t=this.frozens.pop();t!==void 0&&(this.globalMiddleware=t)}reset(){this.globalMiddleware=this.globalMiddleware.filter(t=>t.global)}}function Ys(a){return a?a.map(t=>(t.applyBeforeValidation=!1,t)):[]}function ge(a,t,e,n){return e.reduce((o,i)=>{if(i.applyBeforeValidation!==n)return o;if(i.mutates){if(i.applied)return o;i.applied=!0}if(yt(o))return o.then(r=>Promise.all([r,i(r,t)])).then(([r,s])=>Object.assign(r,s));{const r=i(o,t);return yt(r)?r.then(s=>Object.assign(o,s)):Object.assign(o,r)}},a)}function ye(a,t,e=n=>{throw n}){try{const n=Gs(a)?a():a;return yt(n)?n.then(o=>t(o)):t(n)}catch(n){return e(n)}}function Gs(a){return typeof a=="function"}function ks(a){if(typeof require>"u")return null;for(let t=0,e=Object.keys(require.cache),n;t<e.length;t++)if(n=require.cache[e[t]],n.exports===a)return n;return null}const ie=/(^\*)|(^\$0)/;class Ks{constructor(t,e,n,o){this.requireCache=new Set,this.handlers={},this.aliasMap={},this.frozens=[],this.shim=o,this.usage=t,this.globalMiddleware=n,this.validation=e}addDirectory(t,e,n,o){o=o||{},typeof o.recurse!="boolean"&&(o.recurse=!1),Array.isArray(o.extensions)||(o.extensions=["js"]);const i=typeof o.visit=="function"?o.visit:r=>r;o.visit=(r,s,f)=>{const E=i(r,s,f);if(E){if(this.requireCache.has(s))return E;this.requireCache.add(s),this.addHandler(E)}return E},this.shim.requireDirectory({require:e,filename:n},t,o)}addHandler(t,e,n,o,i,r){let s=[];const f=Ys(i);if(o=o||(()=>{}),Array.isArray(t))if(Js(t))[t,...s]=t;else for(const E of t)this.addHandler(E);else if(to(t)){let E=Array.isArray(t.command)||typeof t.command=="string"?t.command:this.moduleName(t);t.aliases&&(E=[].concat(E).concat(t.aliases)),this.addHandler(E,this.extractDesc(t),t.builder,t.handler,t.middlewares,t.deprecated);return}else if(Or(n)){this.addHandler([t].concat(s),e,n.builder,n.handler,n.middlewares,n.deprecated);return}if(typeof t=="string"){const E=me(t);s=s.map(b=>me(b).cmd);let d=!1;const p=[E.cmd].concat(s).filter(b=>ie.test(b)?(d=!0,!1):!0);p.length===0&&d&&p.push("$0"),d&&(E.cmd=p[0],s=p.slice(1),t=t.replace(ie,E.cmd)),s.forEach(b=>{this.aliasMap[b]=E.cmd}),e!==!1&&this.usage.command(t,e,d,s,r),this.handlers[E.cmd]={original:t,description:e,handler:o,builder:n||{},middlewares:f,deprecated:r,demanded:E.demanded,optional:E.optional},d&&(this.defaultCommand=this.handlers[E.cmd])}}getCommandHandlers(){return this.handlers}getCommands(){return Object.keys(this.handlers).concat(Object.keys(this.aliasMap))}hasDefaultCommand(){return!!this.defaultCommand}runCommand(t,e,n,o,i,r){const s=this.handlers[t]||this.handlers[this.aliasMap[t]]||this.defaultCommand,f=e.getInternalMethods().getContext(),E=f.commands.slice(),d=!t;t&&(f.commands.push(t),f.fullCommands.push(s.original));const p=this.applyBuilderUpdateUsageAndParse(d,s,e,n.aliases,E,o,i,r);return yt(p)?p.then(b=>this.applyMiddlewareAndGetResult(d,s,b.innerArgv,f,i,b.aliases,e)):this.applyMiddlewareAndGetResult(d,s,p.innerArgv,f,i,p.aliases,e)}applyBuilderUpdateUsageAndParse(t,e,n,o,i,r,s,f){const E=e.builder;let d=n;if($n(E)){n.getInternalMethods().getUsageInstance().freeze();const p=E(n.getInternalMethods().reset(o),f);if(yt(p))return p.then(b=>(d=yo(b)?b:n,this.parseAndUpdateUsage(t,e,d,i,r,s)))}else Zs(E)&&(n.getInternalMethods().getUsageInstance().freeze(),d=n.getInternalMethods().reset(o),Object.keys(e.builder).forEach(p=>{d.option(p,E[p])}));return this.parseAndUpdateUsage(t,e,d,i,r,s)}parseAndUpdateUsage(t,e,n,o,i,r){t&&n.getInternalMethods().getUsageInstance().unfreeze(!0),this.shouldUpdateUsage(n)&&n.getInternalMethods().getUsageInstance().usage(this.usageFromParentCommandsCommandHandler(o,e),e.description);const s=n.getInternalMethods().runYargsParserAndExecuteCommands(null,void 0,!0,i,r);return yt(s)?s.then(f=>({aliases:n.parsed.aliases,innerArgv:f})):{aliases:n.parsed.aliases,innerArgv:s}}shouldUpdateUsage(t){return!t.getInternalMethods().getUsageInstance().getUsageDisabled()&&t.getInternalMethods().getUsageInstance().getUsage().length===0}usageFromParentCommandsCommandHandler(t,e){const n=ie.test(e.original)?e.original.replace(ie,"").trim():e.original,o=t.filter(i=>!ie.test(i));return o.push(n),`$0 ${o.join(" ")}`}handleValidationAndGetResult(t,e,n,o,i,r,s,f){if(!r.getInternalMethods().getHasOutput()){const E=r.getInternalMethods().runValidation(i,f,r.parsed.error,t);n=ye(n,d=>(E(d),d))}if(e.handler&&!r.getInternalMethods().getHasOutput()){r.getInternalMethods().setHasOutput();const E=!!r.getOptions().configuration["populate--"];r.getInternalMethods().postProcess(n,E,!1,!1),n=ge(n,r,s,!1),n=ye(n,d=>{const p=e.handler(d);return yt(p)?p.then(()=>d):d}),t||r.getInternalMethods().getUsageInstance().cacheHelpMessage(),yt(n)&&!r.getInternalMethods().hasParseCallback()&&n.catch(d=>{try{r.getInternalMethods().getUsageInstance().fail(null,d)}catch{}})}return t||(o.commands.pop(),o.fullCommands.pop()),n}applyMiddlewareAndGetResult(t,e,n,o,i,r,s){let f={};if(i)return n;s.getInternalMethods().getHasOutput()||(f=this.populatePositionals(e,n,o,s));const E=this.globalMiddleware.getMiddleware().slice(0).concat(e.middlewares),d=ge(n,s,E,!0);return yt(d)?d.then(p=>this.handleValidationAndGetResult(t,e,p,o,r,s,E,f)):this.handleValidationAndGetResult(t,e,d,o,r,s,E,f)}populatePositionals(t,e,n,o){e._=e._.slice(n.commands.length);const i=t.demanded.slice(0),r=t.optional.slice(0),s={};for(this.validation.positionalCount(i.length,e._.length);i.length;){const f=i.shift();this.populatePositional(f,e,s)}for(;r.length;){const f=r.shift();this.populatePositional(f,e,s)}return e._=n.commands.concat(e._.map(f=>""+f)),this.postProcessPositionals(e,s,this.cmdToParseOptions(t.original),o),s}populatePositional(t,e,n){const o=t.cmd[0];t.variadic?n[o]=e._.splice(0).map(String):e._.length&&(n[o]=[String(e._.shift())])}cmdToParseOptions(t){const e={array:[],default:{},alias:{},demand:{}},n=me(t);return n.demanded.forEach(o=>{const[i,...r]=o.cmd;o.variadic&&(e.array.push(i),e.default[i]=[]),e.alias[i]=r,e.demand[i]=!0}),n.optional.forEach(o=>{const[i,...r]=o.cmd;o.variadic&&(e.array.push(i),e.default[i]=[]),e.alias[i]=r}),e}postProcessPositionals(t,e,n,o){const i=Object.assign({},o.getOptions());i.default=Object.assign(n.default,i.default);for(const E of Object.keys(n.alias))i.alias[E]=(i.alias[E]||[]).concat(n.alias[E]);i.array=i.array.concat(n.array),i.config={};const r=[];if(Object.keys(e).forEach(E=>{e[E].map(d=>{i.configuration["unknown-options-as-args"]&&(i.key[E]=!0),r.push(`--${E}`),r.push(d)})}),!r.length)return;const s=Object.assign({},i.configuration,{"populate--":!1}),f=this.shim.Parser.detailed(r,Object.assign({},i,{configuration:s}));if(f.error)o.getInternalMethods().getUsageInstance().fail(f.error.message,f.error);else{const E=Object.keys(e);Object.keys(e).forEach(d=>{E.push(...f.aliases[d])}),Object.keys(f.argv).forEach(d=>{E.includes(d)&&(e[d]||(e[d]=f.argv[d]),!this.isInConfigs(o,d)&&!this.isDefaulted(o,d)&&Object.prototype.hasOwnProperty.call(t,d)&&Object.prototype.hasOwnProperty.call(f.argv,d)&&(Array.isArray(t[d])||Array.isArray(f.argv[d]))?t[d]=[].concat(t[d],f.argv[d]):t[d]=f.argv[d])})}}isDefaulted(t,e){const{default:n}=t.getOptions();return Object.prototype.hasOwnProperty.call(n,e)||Object.prototype.hasOwnProperty.call(n,this.shim.Parser.camelCase(e))}isInConfigs(t,e){const{configObjects:n}=t.getOptions();return n.some(o=>Object.prototype.hasOwnProperty.call(o,e))||n.some(o=>Object.prototype.hasOwnProperty.call(o,this.shim.Parser.camelCase(e)))}runDefaultBuilderOn(t){if(!this.defaultCommand)return;if(this.shouldUpdateUsage(t)){const n=ie.test(this.defaultCommand.original)?this.defaultCommand.original:this.defaultCommand.original.replace(/^[^[\]<>]*/,"$0 ");t.getInternalMethods().getUsageInstance().usage(n,this.defaultCommand.description)}const e=this.defaultCommand.builder;if($n(e))return e(t,!0);Or(e)||Object.keys(e).forEach(n=>{t.option(n,e[n])})}moduleName(t){const e=ks(t);if(!e)throw new Error(`No command name given for module: ${this.shim.inspect(t)}`);return this.commandFromFilename(e.filename)}commandFromFilename(t){return this.shim.path.basename(t,this.shim.path.extname(t))}extractDesc({describe:t,description:e,desc:n}){for(const o of[t,e,n]){if(typeof o=="string"||o===!1)return o;Ft(o,!0,this.shim)}return!1}freeze(){this.frozens.push({handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand})}unfreeze(){const t=this.frozens.pop();Ft(t,void 0,this.shim),{handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand}=t}reset(){return this.handlers={},this.aliasMap={},this.defaultCommand=void 0,this.requireCache=new Set,this}}function Qs(a,t,e,n){return new Ks(a,t,e,n)}function Or(a){return typeof a=="object"&&!!a.builder&&typeof a.handler=="function"}function Js(a){return a.every(t=>typeof t=="string")}function $n(a){return typeof a=="function"}function Zs(a){return typeof a=="object"}function to(a){return typeof a=="object"&&!Array.isArray(a)}function we(a={},t=()=>!0){const e={};return Re(a).forEach(n=>{t(n,a[n])&&(e[n]=a[n])}),e}function pe(a){typeof process>"u"||[process.stdout,process.stderr].forEach(t=>{const e=t;e._handle&&e.isTTY&&typeof e._handle.setBlocking=="function"&&e._handle.setBlocking(a)})}function eo(a){return typeof a=="boolean"}function no(a,t){const e=t.y18n.__,n={},o=[];n.failFn=function(B){o.push(B)};let i=null,r=null,s=!0;n.showHelpOnFail=function(B=!0,$){const[W,Y]=typeof B=="string"?[!0,B]:[B,$];return a.getInternalMethods().isGlobalContext()&&(r=Y),i=Y,s=W,n};let f=!1;n.fail=function(B,$){const W=a.getInternalMethods().getLoggerInstance();if(o.length)for(let Y=o.length-1;Y>=0;--Y){const k=o[Y];if(eo(k)){if($)throw $;if(B)throw Error(B)}else k(B,$,n)}else{if(a.getExitProcess()&&pe(!0),!f){f=!0,s&&(a.showHelp("error"),W.error()),(B||$)&&W.error(B||$);const Y=i||r;Y&&((B||$)&&W.error(""),W.error(Y))}if($=$||new gt(B),a.getExitProcess())return a.exit(1);if(a.getInternalMethods().hasParseCallback())return a.exit(1,$);throw $}};let E=[],d=!1;n.usage=(S,B)=>S===null?(d=!0,E=[],n):(d=!1,E.push([S,B||""]),n),n.getUsage=()=>E,n.getUsageDisabled=()=>d,n.getPositionalGroupName=()=>e("Positionals:");let p=[];n.example=(S,B)=>{p.push([S,B||""])};let b=[];n.command=function(B,$,W,Y,k=!1){W&&(b=b.map(V=>(V[2]=!1,V))),b.push([B,$||"",W,Y,k])},n.getCommands=()=>b;let w={};n.describe=function(B,$){Array.isArray(B)?B.forEach(W=>{n.describe(W,$)}):typeof B=="object"?Object.keys(B).forEach(W=>{n.describe(W,B[W])}):w[B]=$},n.getDescriptions=()=>w;let T=[];n.epilog=S=>{T.push(S)};let v=!1,I;n.wrap=S=>{v=!0,I=S},n.getWrap=()=>t.getEnv("YARGS_DISABLE_WRAP")?null:(v||(I=U(),v=!0),I);const D="__yargsString__:";n.deferY18nLookup=S=>D+S,n.help=function(){if(_)return _;g();const B=a.customScriptName?a.$0:t.path.basename(a.$0),$=a.getDemandedOptions(),W=a.getDemandedCommands(),Y=a.getDeprecatedOptions(),k=a.getGroups(),V=a.getOptions();let ft=[];ft=ft.concat(Object.keys(w)),ft=ft.concat(Object.keys($)),ft=ft.concat(Object.keys(W)),ft=ft.concat(Object.keys(V.default)),ft=ft.filter(X),ft=Object.keys(ft.reduce((Q,x)=>(x!=="_"&&(Q[x]=!0),Q),{}));const Ot=n.getWrap(),at=t.cliui({width:Ot,wrap:!!Ot});if(!d){if(E.length)E.forEach(Q=>{at.div({text:`${Q[0].replace(/\$0/g,B)}`}),Q[1]&&at.div({text:`${Q[1]}`,padding:[1,0,0,0]})}),at.div();else if(b.length){let Q=null;W._?Q=`${B} <${e("command")}>
29
+ */var We,Ve,He;const gr=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):12,yr=(Ve=(We=process==null?void 0:process.versions)===null||We===void 0?void 0:We.node)!==null&&Ve!==void 0?Ve:(He=process==null?void 0:process.version)===null||He===void 0?void 0:He.slice(1);if(yr&&Number(yr.match(/^([^.]+)/)[1])<gr)throw Error(`yargs parser supports a minimum Node.js version of ${gr}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`);const Ls=process?process.env:{},Gi=new As({cwd:process.cwd,env:()=>Ls,format:Vn.format,normalize:xt.normalize,resolve:xt.resolve,require:a=>{if(typeof require<"u")return require(a);if(a.match(/\.json$/))return JSON.parse(Bt.readFileSync(a,"utf8"));throw Error("only .json config files are supported in ESM")}}),Ee=function(t,e){return Gi.parse(t.slice(),e).argv};Ee.detailed=function(a,t){return Gi.parse(a.slice(),t)};Ee.camelCase=he;Ee.decamelize=zi;Ee.looksLikeNumber=Yi;function ki(){return Ss()?0:1}function Ss(){return Fs()&&!process.defaultApp}function Fs(){return!!process.versions.electron}function js(a){return a.slice(ki()+1)}function Rs(){return process.argv[ki()]}class gt extends Error{constructor(t){super(t||"yargs error"),this.name="YError",Error.captureStackTrace&&Error.captureStackTrace(this,gt)}}const Bs={fs:{readFileSync:Bt.readFileSync,writeFile:Bt.writeFile},format:Vn.format,resolve:xt.resolve,exists:a=>{try{return Bt.statSync(a).isFile()}catch{return!1}}};let Lt;class Us{constructor(t){t=t||{},this.directory=t.directory||"./locales",this.updateFiles=typeof t.updateFiles=="boolean"?t.updateFiles:!0,this.locale=t.locale||"en",this.fallbackToLanguage=typeof t.fallbackToLanguage=="boolean"?t.fallbackToLanguage:!0,this.cache=Object.create(null),this.writeQueue=[]}__(...t){if(typeof arguments[0]!="string")return this._taggedLiteral(arguments[0],...arguments);const e=t.shift();let n=function(){};return typeof t[t.length-1]=="function"&&(n=t.pop()),n=n||function(){},this.cache[this.locale]||this._readLocaleFile(),!this.cache[this.locale][e]&&this.updateFiles?(this.cache[this.locale][e]=e,this._enqueueWrite({directory:this.directory,locale:this.locale,cb:n})):n(),Lt.format.apply(Lt.format,[this.cache[this.locale][e]||e].concat(t))}__n(){const t=Array.prototype.slice.call(arguments),e=t.shift(),n=t.shift(),o=t.shift();let i=function(){};typeof t[t.length-1]=="function"&&(i=t.pop()),this.cache[this.locale]||this._readLocaleFile();let r=o===1?e:n;this.cache[this.locale][e]&&(r=this.cache[this.locale][e][o===1?"one":"other"]),!this.cache[this.locale][e]&&this.updateFiles?(this.cache[this.locale][e]={one:e,other:n},this._enqueueWrite({directory:this.directory,locale:this.locale,cb:i})):i();const s=[r];return~r.indexOf("%d")&&s.push(o),Lt.format.apply(Lt.format,s.concat(t))}setLocale(t){this.locale=t}getLocale(){return this.locale}updateLocale(t){this.cache[this.locale]||this._readLocaleFile();for(const e in t)Object.prototype.hasOwnProperty.call(t,e)&&(this.cache[this.locale][e]=t[e])}_taggedLiteral(t,...e){let n="";return t.forEach(function(o,i){const r=e[i+1];n+=o,typeof r<"u"&&(n+="%s")}),this.__.apply(this,[n].concat([].slice.call(e,1)))}_enqueueWrite(t){this.writeQueue.push(t),this.writeQueue.length===1&&this._processWriteQueue()}_processWriteQueue(){const t=this,e=this.writeQueue[0],n=e.directory,o=e.locale,i=e.cb,r=this._resolveLocaleFile(n,o),s=JSON.stringify(this.cache[o],null,2);Lt.fs.writeFile(r,s,"utf-8",function(f){t.writeQueue.shift(),t.writeQueue.length>0&&t._processWriteQueue(),i(f)})}_readLocaleFile(){let t={};const e=this._resolveLocaleFile(this.directory,this.locale);try{Lt.fs.readFileSync&&(t=JSON.parse(Lt.fs.readFileSync(e,"utf-8")))}catch(n){if(n instanceof SyntaxError&&(n.message="syntax error in "+e),n.code==="ENOENT")t={};else throw n}this.cache[this.locale]=t}_resolveLocaleFile(t,e){let n=Lt.resolve(t,"./",e+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(n)&&~e.lastIndexOf("_")){const o=Lt.resolve(t,"./",e.split("_")[0]+".json");this._fileExistsSync(o)&&(n=o)}return n}_fileExistsSync(t){return Lt.exists(t)}}function Xs(a,t){Lt=t;const e=new Us(a);return{__:e.__.bind(e),__n:e.__n.bind(e),setLocale:e.setLocale.bind(e),getLocale:e.getLocale.bind(e),updateLocale:e.updateLocale.bind(e),locale:e.locale}}const $s=a=>Xs(a,Bs),qs="require is not supported by ESM",br="loading a directory of commands is not supported yet for ESM";let be;try{be=as.fileURLToPath(typeof document>"u"?require("url").pathToFileURL(__filename).href:$e&&$e.tagName.toUpperCase()==="SCRIPT"&&$e.src||new URL("run-cli-BKbM-eYC.cjs",document.baseURI).href)}catch{be=process.cwd()}const Ws=be.substring(0,be.lastIndexOf("node_modules")),Vs={assert:{notStrictEqual:fr.notStrictEqual,strictEqual:fr.strictEqual},cliui:_s,findUp:vs,getEnv:a=>process.env[a],inspect:Vn.inspect,getCallerFile:()=>{throw new gt(br)},getProcessArgvBin:Rs,mainFilename:Ws||process.cwd(),Parser:Ee,path:{basename:xt.basename,dirname:xt.dirname,extname:xt.extname,relative:xt.relative,resolve:xt.resolve},process:{argv:()=>process.argv,cwd:process.cwd,emitWarning:(a,t)=>process.emitWarning(a,t),execPath:()=>process.execPath,exit:process.exit,nextTick:process.nextTick,stdColumns:typeof process.stdout.columns<"u"?process.stdout.columns:null},readFileSync:Bt.readFileSync,require:()=>{throw new gt(qs)},requireDirectory:()=>{throw new gt(br)},stringWidth:a=>[...a].length,y18n:$s({directory:xt.resolve(be,"../../../locales"),updateFiles:!1})};function Ft(a,t,e,n){e.assert.notStrictEqual(a,t,n)}function wr(a,t){t.assert.strictEqual(typeof a,"string")}function Re(a){return Object.keys(a)}function yt(a){return!!a&&!!a.then&&typeof a.then=="function"}function me(a){const e=a.replace(/\s{2,}/g," ").split(/\s+(?![^[]*]|[^<]*>)/),n=/\.*[\][<>]/g,o=e.shift();if(!o)throw new Error(`No command found in: ${a}`);const i={cmd:o.replace(n,""),demanded:[],optional:[]};return e.forEach((r,s)=>{let f=!1;r=r.replace(/\s/g,""),/\.+[\]>]/.test(r)&&s===e.length-1&&(f=!0),/^\[/.test(r)?i.optional.push({cmd:r.replace(n,"").split("|"),variadic:f}):i.demanded.push({cmd:r.replace(n,"").split("|"),variadic:f})}),i}const Hs=["first","second","third","fourth","fifth","sixth"];function z(a,t,e){function n(){return typeof a=="object"?[{demanded:[],optional:[]},a,t]:[me(`cmd ${a}`),t,e]}try{let o=0;const[i,r,s]=n(),f=[].slice.call(r);for(;f.length&&f[f.length-1]===void 0;)f.pop();const E=s||f.length;if(E<i.demanded.length)throw new gt(`Not enough arguments provided. Expected ${i.demanded.length} but received ${f.length}.`);const d=i.demanded.length+i.optional.length;if(E>d)throw new gt(`Too many arguments provided. Expected max ${d} but received ${E}.`);i.demanded.forEach(p=>{const b=f.shift(),w=Er(b);p.cmd.filter(v=>v===w||v==="*").length===0&&xr(w,p.cmd,o),o+=1}),i.optional.forEach(p=>{if(f.length===0)return;const b=f.shift(),w=Er(b);p.cmd.filter(v=>v===w||v==="*").length===0&&xr(w,p.cmd,o),o+=1})}catch(o){console.warn(o.stack)}}function Er(a){return Array.isArray(a)?"array":a===null?"null":typeof a}function xr(a,t,e){throw new gt(`Invalid ${Hs[e]||"manyith"} argument. Expected ${t.join(" or ")} but received ${a}.`)}class zs{constructor(t){this.globalMiddleware=[],this.frozens=[],this.yargs=t}addMiddleware(t,e,n=!0,o=!1){if(z("<array|function> [boolean] [boolean] [boolean]",[t,e,n],arguments.length),Array.isArray(t)){for(let i=0;i<t.length;i++){if(typeof t[i]!="function")throw Error("middleware must be a function");const r=t[i];r.applyBeforeValidation=e,r.global=n}Array.prototype.push.apply(this.globalMiddleware,t)}else if(typeof t=="function"){const i=t;i.applyBeforeValidation=e,i.global=n,i.mutates=o,this.globalMiddleware.push(t)}return this.yargs}addCoerceMiddleware(t,e){const n=this.yargs.getAliases();return this.globalMiddleware=this.globalMiddleware.filter(o=>{const i=[...n[e]||[],e];return o.option?!i.includes(o.option):!0}),t.option=e,this.addMiddleware(t,!0,!0,!0)}getMiddleware(){return this.globalMiddleware}freeze(){this.frozens.push([...this.globalMiddleware])}unfreeze(){const t=this.frozens.pop();t!==void 0&&(this.globalMiddleware=t)}reset(){this.globalMiddleware=this.globalMiddleware.filter(t=>t.global)}}function Ys(a){return a?a.map(t=>(t.applyBeforeValidation=!1,t)):[]}function ge(a,t,e,n){return e.reduce((o,i)=>{if(i.applyBeforeValidation!==n)return o;if(i.mutates){if(i.applied)return o;i.applied=!0}if(yt(o))return o.then(r=>Promise.all([r,i(r,t)])).then(([r,s])=>Object.assign(r,s));{const r=i(o,t);return yt(r)?r.then(s=>Object.assign(o,s)):Object.assign(o,r)}},a)}function ye(a,t,e=n=>{throw n}){try{const n=Gs(a)?a():a;return yt(n)?n.then(o=>t(o)):t(n)}catch(n){return e(n)}}function Gs(a){return typeof a=="function"}function ks(a){if(typeof require>"u")return null;for(let t=0,e=Object.keys(require.cache),n;t<e.length;t++)if(n=require.cache[e[t]],n.exports===a)return n;return null}const ie=/(^\*)|(^\$0)/;class Ks{constructor(t,e,n,o){this.requireCache=new Set,this.handlers={},this.aliasMap={},this.frozens=[],this.shim=o,this.usage=t,this.globalMiddleware=n,this.validation=e}addDirectory(t,e,n,o){o=o||{},typeof o.recurse!="boolean"&&(o.recurse=!1),Array.isArray(o.extensions)||(o.extensions=["js"]);const i=typeof o.visit=="function"?o.visit:r=>r;o.visit=(r,s,f)=>{const E=i(r,s,f);if(E){if(this.requireCache.has(s))return E;this.requireCache.add(s),this.addHandler(E)}return E},this.shim.requireDirectory({require:e,filename:n},t,o)}addHandler(t,e,n,o,i,r){let s=[];const f=Ys(i);if(o=o||(()=>{}),Array.isArray(t))if(Js(t))[t,...s]=t;else for(const E of t)this.addHandler(E);else if(to(t)){let E=Array.isArray(t.command)||typeof t.command=="string"?t.command:this.moduleName(t);t.aliases&&(E=[].concat(E).concat(t.aliases)),this.addHandler(E,this.extractDesc(t),t.builder,t.handler,t.middlewares,t.deprecated);return}else if(Or(n)){this.addHandler([t].concat(s),e,n.builder,n.handler,n.middlewares,n.deprecated);return}if(typeof t=="string"){const E=me(t);s=s.map(b=>me(b).cmd);let d=!1;const p=[E.cmd].concat(s).filter(b=>ie.test(b)?(d=!0,!1):!0);p.length===0&&d&&p.push("$0"),d&&(E.cmd=p[0],s=p.slice(1),t=t.replace(ie,E.cmd)),s.forEach(b=>{this.aliasMap[b]=E.cmd}),e!==!1&&this.usage.command(t,e,d,s,r),this.handlers[E.cmd]={original:t,description:e,handler:o,builder:n||{},middlewares:f,deprecated:r,demanded:E.demanded,optional:E.optional},d&&(this.defaultCommand=this.handlers[E.cmd])}}getCommandHandlers(){return this.handlers}getCommands(){return Object.keys(this.handlers).concat(Object.keys(this.aliasMap))}hasDefaultCommand(){return!!this.defaultCommand}runCommand(t,e,n,o,i,r){const s=this.handlers[t]||this.handlers[this.aliasMap[t]]||this.defaultCommand,f=e.getInternalMethods().getContext(),E=f.commands.slice(),d=!t;t&&(f.commands.push(t),f.fullCommands.push(s.original));const p=this.applyBuilderUpdateUsageAndParse(d,s,e,n.aliases,E,o,i,r);return yt(p)?p.then(b=>this.applyMiddlewareAndGetResult(d,s,b.innerArgv,f,i,b.aliases,e)):this.applyMiddlewareAndGetResult(d,s,p.innerArgv,f,i,p.aliases,e)}applyBuilderUpdateUsageAndParse(t,e,n,o,i,r,s,f){const E=e.builder;let d=n;if($n(E)){n.getInternalMethods().getUsageInstance().freeze();const p=E(n.getInternalMethods().reset(o),f);if(yt(p))return p.then(b=>(d=yo(b)?b:n,this.parseAndUpdateUsage(t,e,d,i,r,s)))}else Zs(E)&&(n.getInternalMethods().getUsageInstance().freeze(),d=n.getInternalMethods().reset(o),Object.keys(e.builder).forEach(p=>{d.option(p,E[p])}));return this.parseAndUpdateUsage(t,e,d,i,r,s)}parseAndUpdateUsage(t,e,n,o,i,r){t&&n.getInternalMethods().getUsageInstance().unfreeze(!0),this.shouldUpdateUsage(n)&&n.getInternalMethods().getUsageInstance().usage(this.usageFromParentCommandsCommandHandler(o,e),e.description);const s=n.getInternalMethods().runYargsParserAndExecuteCommands(null,void 0,!0,i,r);return yt(s)?s.then(f=>({aliases:n.parsed.aliases,innerArgv:f})):{aliases:n.parsed.aliases,innerArgv:s}}shouldUpdateUsage(t){return!t.getInternalMethods().getUsageInstance().getUsageDisabled()&&t.getInternalMethods().getUsageInstance().getUsage().length===0}usageFromParentCommandsCommandHandler(t,e){const n=ie.test(e.original)?e.original.replace(ie,"").trim():e.original,o=t.filter(i=>!ie.test(i));return o.push(n),`$0 ${o.join(" ")}`}handleValidationAndGetResult(t,e,n,o,i,r,s,f){if(!r.getInternalMethods().getHasOutput()){const E=r.getInternalMethods().runValidation(i,f,r.parsed.error,t);n=ye(n,d=>(E(d),d))}if(e.handler&&!r.getInternalMethods().getHasOutput()){r.getInternalMethods().setHasOutput();const E=!!r.getOptions().configuration["populate--"];r.getInternalMethods().postProcess(n,E,!1,!1),n=ge(n,r,s,!1),n=ye(n,d=>{const p=e.handler(d);return yt(p)?p.then(()=>d):d}),t||r.getInternalMethods().getUsageInstance().cacheHelpMessage(),yt(n)&&!r.getInternalMethods().hasParseCallback()&&n.catch(d=>{try{r.getInternalMethods().getUsageInstance().fail(null,d)}catch{}})}return t||(o.commands.pop(),o.fullCommands.pop()),n}applyMiddlewareAndGetResult(t,e,n,o,i,r,s){let f={};if(i)return n;s.getInternalMethods().getHasOutput()||(f=this.populatePositionals(e,n,o,s));const E=this.globalMiddleware.getMiddleware().slice(0).concat(e.middlewares),d=ge(n,s,E,!0);return yt(d)?d.then(p=>this.handleValidationAndGetResult(t,e,p,o,r,s,E,f)):this.handleValidationAndGetResult(t,e,d,o,r,s,E,f)}populatePositionals(t,e,n,o){e._=e._.slice(n.commands.length);const i=t.demanded.slice(0),r=t.optional.slice(0),s={};for(this.validation.positionalCount(i.length,e._.length);i.length;){const f=i.shift();this.populatePositional(f,e,s)}for(;r.length;){const f=r.shift();this.populatePositional(f,e,s)}return e._=n.commands.concat(e._.map(f=>""+f)),this.postProcessPositionals(e,s,this.cmdToParseOptions(t.original),o),s}populatePositional(t,e,n){const o=t.cmd[0];t.variadic?n[o]=e._.splice(0).map(String):e._.length&&(n[o]=[String(e._.shift())])}cmdToParseOptions(t){const e={array:[],default:{},alias:{},demand:{}},n=me(t);return n.demanded.forEach(o=>{const[i,...r]=o.cmd;o.variadic&&(e.array.push(i),e.default[i]=[]),e.alias[i]=r,e.demand[i]=!0}),n.optional.forEach(o=>{const[i,...r]=o.cmd;o.variadic&&(e.array.push(i),e.default[i]=[]),e.alias[i]=r}),e}postProcessPositionals(t,e,n,o){const i=Object.assign({},o.getOptions());i.default=Object.assign(n.default,i.default);for(const E of Object.keys(n.alias))i.alias[E]=(i.alias[E]||[]).concat(n.alias[E]);i.array=i.array.concat(n.array),i.config={};const r=[];if(Object.keys(e).forEach(E=>{e[E].map(d=>{i.configuration["unknown-options-as-args"]&&(i.key[E]=!0),r.push(`--${E}`),r.push(d)})}),!r.length)return;const s=Object.assign({},i.configuration,{"populate--":!1}),f=this.shim.Parser.detailed(r,Object.assign({},i,{configuration:s}));if(f.error)o.getInternalMethods().getUsageInstance().fail(f.error.message,f.error);else{const E=Object.keys(e);Object.keys(e).forEach(d=>{E.push(...f.aliases[d])}),Object.keys(f.argv).forEach(d=>{E.includes(d)&&(e[d]||(e[d]=f.argv[d]),!this.isInConfigs(o,d)&&!this.isDefaulted(o,d)&&Object.prototype.hasOwnProperty.call(t,d)&&Object.prototype.hasOwnProperty.call(f.argv,d)&&(Array.isArray(t[d])||Array.isArray(f.argv[d]))?t[d]=[].concat(t[d],f.argv[d]):t[d]=f.argv[d])})}}isDefaulted(t,e){const{default:n}=t.getOptions();return Object.prototype.hasOwnProperty.call(n,e)||Object.prototype.hasOwnProperty.call(n,this.shim.Parser.camelCase(e))}isInConfigs(t,e){const{configObjects:n}=t.getOptions();return n.some(o=>Object.prototype.hasOwnProperty.call(o,e))||n.some(o=>Object.prototype.hasOwnProperty.call(o,this.shim.Parser.camelCase(e)))}runDefaultBuilderOn(t){if(!this.defaultCommand)return;if(this.shouldUpdateUsage(t)){const n=ie.test(this.defaultCommand.original)?this.defaultCommand.original:this.defaultCommand.original.replace(/^[^[\]<>]*/,"$0 ");t.getInternalMethods().getUsageInstance().usage(n,this.defaultCommand.description)}const e=this.defaultCommand.builder;if($n(e))return e(t,!0);Or(e)||Object.keys(e).forEach(n=>{t.option(n,e[n])})}moduleName(t){const e=ks(t);if(!e)throw new Error(`No command name given for module: ${this.shim.inspect(t)}`);return this.commandFromFilename(e.filename)}commandFromFilename(t){return this.shim.path.basename(t,this.shim.path.extname(t))}extractDesc({describe:t,description:e,desc:n}){for(const o of[t,e,n]){if(typeof o=="string"||o===!1)return o;Ft(o,!0,this.shim)}return!1}freeze(){this.frozens.push({handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand})}unfreeze(){const t=this.frozens.pop();Ft(t,void 0,this.shim),{handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand}=t}reset(){return this.handlers={},this.aliasMap={},this.defaultCommand=void 0,this.requireCache=new Set,this}}function Qs(a,t,e,n){return new Ks(a,t,e,n)}function Or(a){return typeof a=="object"&&!!a.builder&&typeof a.handler=="function"}function Js(a){return a.every(t=>typeof t=="string")}function $n(a){return typeof a=="function"}function Zs(a){return typeof a=="object"}function to(a){return typeof a=="object"&&!Array.isArray(a)}function we(a={},t=()=>!0){const e={};return Re(a).forEach(n=>{t(n,a[n])&&(e[n]=a[n])}),e}function pe(a){typeof process>"u"||[process.stdout,process.stderr].forEach(t=>{const e=t;e._handle&&e.isTTY&&typeof e._handle.setBlocking=="function"&&e._handle.setBlocking(a)})}function eo(a){return typeof a=="boolean"}function no(a,t){const e=t.y18n.__,n={},o=[];n.failFn=function(B){o.push(B)};let i=null,r=null,s=!0;n.showHelpOnFail=function(B=!0,$){const[W,Y]=typeof B=="string"?[!0,B]:[B,$];return a.getInternalMethods().isGlobalContext()&&(r=Y),i=Y,s=W,n};let f=!1;n.fail=function(B,$){const W=a.getInternalMethods().getLoggerInstance();if(o.length)for(let Y=o.length-1;Y>=0;--Y){const k=o[Y];if(eo(k)){if($)throw $;if(B)throw Error(B)}else k(B,$,n)}else{if(a.getExitProcess()&&pe(!0),!f){f=!0,s&&(a.showHelp("error"),W.error()),(B||$)&&W.error(B||$);const Y=i||r;Y&&((B||$)&&W.error(""),W.error(Y))}if($=$||new gt(B),a.getExitProcess())return a.exit(1);if(a.getInternalMethods().hasParseCallback())return a.exit(1,$);throw $}};let E=[],d=!1;n.usage=(S,B)=>S===null?(d=!0,E=[],n):(d=!1,E.push([S,B||""]),n),n.getUsage=()=>E,n.getUsageDisabled=()=>d,n.getPositionalGroupName=()=>e("Positionals:");let p=[];n.example=(S,B)=>{p.push([S,B||""])};let b=[];n.command=function(B,$,W,Y,k=!1){W&&(b=b.map(V=>(V[2]=!1,V))),b.push([B,$||"",W,Y,k])},n.getCommands=()=>b;let w={};n.describe=function(B,$){Array.isArray(B)?B.forEach(W=>{n.describe(W,$)}):typeof B=="object"?Object.keys(B).forEach(W=>{n.describe(W,B[W])}):w[B]=$},n.getDescriptions=()=>w;let T=[];n.epilog=S=>{T.push(S)};let v=!1,I;n.wrap=S=>{v=!0,I=S},n.getWrap=()=>t.getEnv("YARGS_DISABLE_WRAP")?null:(v||(I=U(),v=!0),I);const D="__yargsString__:";n.deferY18nLookup=S=>D+S,n.help=function(){if(_)return _;g();const B=a.customScriptName?a.$0:t.path.basename(a.$0),$=a.getDemandedOptions(),W=a.getDemandedCommands(),Y=a.getDeprecatedOptions(),k=a.getGroups(),V=a.getOptions();let ft=[];ft=ft.concat(Object.keys(w)),ft=ft.concat(Object.keys($)),ft=ft.concat(Object.keys(W)),ft=ft.concat(Object.keys(V.default)),ft=ft.filter(X),ft=Object.keys(ft.reduce((Q,x)=>(x!=="_"&&(Q[x]=!0),Q),{}));const Ot=n.getWrap(),at=t.cliui({width:Ot,wrap:!!Ot});if(!d){if(E.length)E.forEach(Q=>{at.div({text:`${Q[0].replace(/\$0/g,B)}`}),Q[1]&&at.div({text:`${Q[1]}`,padding:[1,0,0,0]})}),at.div();else if(b.length){let Q=null;W._?Q=`${B} <${e("command")}>
30
30
  `:Q=`${B} [${e("command")}]
31
31
  `,at.div(`${Q}`)}}if(b.length>1||b.length===1&&!b[0][2]){at.div(e("Commands:"));const Q=a.getInternalMethods().getContext(),x=Q.commands.length?`${Q.commands.join(" ")} `:"";a.getInternalMethods().getParserConfiguration()["sort-commands"]===!0&&(b=b.sort((j,P)=>j[0].localeCompare(P[0])));const y=B?`${B} `:"";b.forEach(j=>{const P=`${y}${x}${j[0].replace(/^\$0 ?/,"")}`;at.span({text:P,padding:[0,2,0,2],width:C(b,Ot,`${B}${x}`)+4},{text:j[1]});const J=[];j[2]&&J.push(`[${e("default")}]`),j[3]&&j[3].length&&J.push(`[${e("aliases:")} ${j[3].join(", ")}]`),j[4]&&(typeof j[4]=="string"?J.push(`[${e("deprecated: %s",j[4])}]`):J.push(`[${e("deprecated")}]`)),J.length?at.div({text:J.join(" "),padding:[0,0,0,2],align:"right"}):at.div()}),at.div()}const st=(Object.keys(V.alias)||[]).concat(Object.keys(a.parsed.newAliases)||[]);ft=ft.filter(Q=>!a.parsed.newAliases[Q]&&st.every(x=>(V.alias[x]||[]).indexOf(Q)===-1));const ut=e("Options:");k[ut]||(k[ut]=[]),M(ft,V.alias,k,ut);const _t=Q=>/^--/.test(Oe(Q)),K=Object.keys(k).filter(Q=>k[Q].length>0).map(Q=>{const x=k[Q].filter(X).map(y=>{if(st.includes(y))return y;for(let j=0,P;(P=st[j])!==void 0;j++)if((V.alias[P]||[]).includes(y))return P;return y});return{groupName:Q,normalizedKeys:x}}).filter(({normalizedKeys:Q})=>Q.length>0).map(({groupName:Q,normalizedKeys:x})=>{const y=x.reduce((j,P)=>(j[P]=[P].concat(V.alias[P]||[]).map(J=>Q===n.getPositionalGroupName()?J:(/^[0-9]$/.test(J)?V.boolean.includes(P)?"-":"--":J.length>1?"--":"-")+J).sort((J,ot)=>_t(J)===_t(ot)?0:_t(J)?1:-1).join(", "),j),{});return{groupName:Q,normalizedKeys:x,switches:y}});if(K.filter(({groupName:Q})=>Q!==n.getPositionalGroupName()).some(({normalizedKeys:Q,switches:x})=>!Q.every(y=>_t(x[y])))&&K.filter(({groupName:Q})=>Q!==n.getPositionalGroupName()).forEach(({normalizedKeys:Q,switches:x})=>{Q.forEach(y=>{_t(x[y])&&(x[y]=ro(x[y],4))})}),K.forEach(({groupName:Q,normalizedKeys:x,switches:y})=>{at.div(Q),x.forEach(j=>{const P=y[j];let J=w[j]||"",ot=null;J.includes(D)&&(J=e(J.substring(D.length))),V.boolean.includes(j)&&(ot=`[${e("boolean")}]`),V.count.includes(j)&&(ot=`[${e("count")}]`),V.string.includes(j)&&(ot=`[${e("string")}]`),V.normalize.includes(j)&&(ot=`[${e("string")}]`),V.array.includes(j)&&(ot=`[${e("array")}]`),V.number.includes(j)&&(ot=`[${e("number")}]`);const rt=l=>typeof l=="string"?`[${e("deprecated: %s",l)}]`:`[${e("deprecated")}]`,ht=[j in Y?rt(Y[j]):null,ot,j in $?`[${e("required")}]`:null,V.choices&&V.choices[j]?`[${e("choices:")} ${n.stringifiedValues(V.choices[j])}]`:null,q(V.default[j],V.defaultDescription[j])].filter(Boolean).join(" ");at.span({text:Oe(P),padding:[0,2,0,2+Ir(P)],width:C(y,Ot)+4},J);const A=a.getInternalMethods().getUsageConfiguration()["hide-types"]===!0;ht&&!A?at.div({text:ht,padding:[0,0,0,2],align:"right"}):at.div()}),at.div()}),p.length&&(at.div(e("Examples:")),p.forEach(Q=>{Q[0]=Q[0].replace(/\$0/g,B)}),p.forEach(Q=>{Q[1]===""?at.div({text:Q[0],padding:[0,2,0,2]}):at.div({text:Q[0],padding:[0,2,0,2],width:C(p,Ot)+4},{text:Q[1]})}),at.div()),T.length>0){const Q=T.map(x=>x.replace(/\$0/g,B)).join(`
32
32
  `);at.div(`${Q}
@@ -99,7 +99,7 @@ Char: `+x.c),y=new Error(y),x.error=y,S(x,"onerror",y),x}function k(x){return x.
99
99
  Actual: `+x.attribValue);else if(P==="xmlns"&&x.attribValue!==T)V(x,"xmlns: prefix must be bound to "+T+`
100
100
  Actual: `+x.attribValue);else{var J=x.tag,ot=x.tags[x.tags.length-1]||x;J.ns===ot.ns&&(J.ns=Object.create(ot.ns)),J.ns[P]=x.attribValue}x.attribList.push([x.attribName,x.attribValue])}else x.tag.attributes[x.attribName]=x.attribValue,B(x,"onattribute",{name:x.attribName,value:x.attribValue});x.attribName=x.attribValue=""}function st(x,y){if(x.opt.xmlns){var j=x.tag,P=Ot(x.tagName);j.prefix=P.prefix,j.local=P.local,j.uri=j.ns[P.prefix]||"",j.prefix&&!j.uri&&(V(x,"Unbound namespace prefix: "+JSON.stringify(x.tagName)),j.uri=P.prefix);var J=x.tags[x.tags.length-1]||x;j.ns&&J.ns!==j.ns&&Object.keys(j.ns).forEach(function(F){B(x,"onopennamespace",{prefix:F,uri:j.ns[F]})});for(var ot=0,rt=x.attribList.length;ot<rt;ot++){var ht=x.attribList[ot],A=ht[0],l=ht[1],u=Ot(A,!0),c=u.prefix,h=u.local,N=c===""?"":j.ns[c]||"",L={name:A,value:l,prefix:c,local:h,uri:N};c&&c!=="xmlns"&&!N&&(V(x,"Unbound namespace prefix: "+JSON.stringify(c)),L.uri=c),x.tag.attributes[A]=L,B(x,"onattribute",L)}x.attribList.length=0}x.tag.isSelfClosing=!!y,x.sawRoot=!0,x.tags.push(x.tag),B(x,"onopentag",x.tag),y||(!x.noscript&&x.tagName.toLowerCase()==="script"?x.state=m.SCRIPT:x.state=m.TEXT,x.tag=null,x.tagName=""),x.attribName=x.attribValue="",x.attribList.length=0}function ut(x){if(!x.tagName){V(x,"Weird empty close tag."),x.textNode+="</>",x.state=m.TEXT;return}if(x.script){if(x.tagName!=="script"){x.script+="</"+x.tagName+">",x.tagName="",x.state=m.SCRIPT;return}B(x,"onscript",x.script),x.script=""}var y=x.tags.length,j=x.tagName;x.strict||(j=j[x.looseCase]());for(var P=j;y--;){var J=x.tags[y];if(J.name!==P)V(x,"Unexpected close tag");else break}if(y<0){V(x,"Unmatched closing tag: "+x.tagName),x.textNode+="</"+x.tagName+">",x.state=m.TEXT;return}x.tagName=j;for(var ot=x.tags.length;ot-- >y;){var rt=x.tag=x.tags.pop();x.tagName=x.tag.name,B(x,"onclosetag",x.tagName);var ht={};for(var A in rt.ns)ht[A]=rt.ns[A];var l=x.tags[x.tags.length-1]||x;x.opt.xmlns&&rt.ns!==l.ns&&Object.keys(rt.ns).forEach(function(u){var c=rt.ns[u];B(x,"onclosenamespace",{prefix:u,uri:c})})}y===0&&(x.closedRoot=!0),x.tagName=x.attribValue=x.attribName="",x.attribList.length=0,x.state=m.TEXT}function _t(x){var y=x.entity,j=y.toLowerCase(),P,J="";return x.ENTITIES[y]?x.ENTITIES[y]:x.ENTITIES[j]?x.ENTITIES[j]:(y=j,y.charAt(0)==="#"&&(y.charAt(1)==="x"?(y=y.slice(2),P=parseInt(y,16),J=P.toString(16)):(y=y.slice(1),P=parseInt(y,10),J=P.toString(10))),y=y.replace(/^0+/,""),isNaN(P)||J.toLowerCase()!==y?(V(x,"Invalid character entity"),"&"+x.entity+";"):String.fromCodePoint(P))}function K(x,y){y==="<"?(x.state=m.OPEN_WAKA,x.startTagPosition=x.position):_(y)||(V(x,"Non-whitespace before first tag."),x.textNode=y,x.state=m.TEXT)}function Ut(x,y){var j="";return y<x.length&&(j=x.charAt(y)),j}function Q(x){var y=this;if(this.error)throw this.error;if(y.closed)return Y(y,"Cannot write after close. Assign an onready handler.");if(x===null)return k(y);typeof x=="object"&&(x=x.toString());for(var j=0,P="";P=Ut(x,j++),y.c=P,!!P;)switch(y.trackPosition&&(y.position++,P===`
101
101
  `?(y.line++,y.column=0):y.column++),y.state){case m.BEGIN:if(y.state=m.BEGIN_WHITESPACE,P==="\uFEFF")continue;K(y,P);continue;case m.BEGIN_WHITESPACE:K(y,P);continue;case m.TEXT:if(y.sawRoot&&!y.closedRoot){for(var J=j-1;P&&P!=="<"&&P!=="&";)P=Ut(x,j++),P&&y.trackPosition&&(y.position++,P===`
102
- `?(y.line++,y.column=0):y.column++);y.textNode+=x.substring(J,j-1)}P==="<"&&!(y.sawRoot&&y.closedRoot&&!y.strict)?(y.state=m.OPEN_WAKA,y.startTagPosition=y.position):(!_(P)&&(!y.sawRoot||y.closedRoot)&&V(y,"Text data outside of root node."),P==="&"?y.state=m.TEXT_ENTITY:y.textNode+=P);continue;case m.SCRIPT:P==="<"?y.state=m.SCRIPT_ENDING:y.script+=P;continue;case m.SCRIPT_ENDING:P==="/"?y.state=m.CLOSE_TAG:(y.script+="<"+P,y.state=m.SCRIPT);continue;case m.OPEN_WAKA:if(P==="!")y.state=m.SGML_DECL,y.sgmlDecl="";else if(!_(P))if(q(I,P))y.state=m.OPEN_TAG,y.tagName=P;else if(P==="/")y.state=m.CLOSE_TAG,y.tagName="";else if(P==="?")y.state=m.PROC_INST,y.procInstName=y.procInstBody="";else{if(V(y,"Unencoded <"),y.startTagPosition+1<y.position){var ot=y.position-y.startTagPosition;P=new Array(ot).join(" ")+P}y.textNode+="<"+P,y.state=m.TEXT}continue;case m.SGML_DECL:if(y.sgmlDecl+P==="--"){y.state=m.COMMENT,y.comment="",y.sgmlDecl="";continue}y.doctype&&y.doctype!==!0&&y.sgmlDecl?(y.state=m.DOCTYPE_DTD,y.doctype+="<!"+y.sgmlDecl+P,y.sgmlDecl=""):(y.sgmlDecl+P).toUpperCase()===p?(B(y,"onopencdata"),y.state=m.CDATA,y.sgmlDecl="",y.cdata=""):(y.sgmlDecl+P).toUpperCase()===b?(y.state=m.DOCTYPE,(y.doctype||y.sawRoot)&&V(y,"Inappropriately located doctype declaration"),y.doctype="",y.sgmlDecl=""):P===">"?(B(y,"onsgmldeclaration",y.sgmlDecl),y.sgmlDecl="",y.state=m.TEXT):(M(P)&&(y.state=m.SGML_DECL_QUOTED),y.sgmlDecl+=P);continue;case m.SGML_DECL_QUOTED:P===y.q&&(y.state=m.SGML_DECL,y.q=""),y.sgmlDecl+=P;continue;case m.DOCTYPE:P===">"?(y.state=m.TEXT,B(y,"ondoctype",y.doctype),y.doctype=!0):(y.doctype+=P,P==="["?y.state=m.DOCTYPE_DTD:M(P)&&(y.state=m.DOCTYPE_QUOTED,y.q=P));continue;case m.DOCTYPE_QUOTED:y.doctype+=P,P===y.q&&(y.q="",y.state=m.DOCTYPE);continue;case m.DOCTYPE_DTD:P==="]"?(y.doctype+=P,y.state=m.DOCTYPE):P==="<"?(y.state=m.OPEN_WAKA,y.startTagPosition=y.position):M(P)?(y.doctype+=P,y.state=m.DOCTYPE_DTD_QUOTED,y.q=P):y.doctype+=P;continue;case m.DOCTYPE_DTD_QUOTED:y.doctype+=P,P===y.q&&(y.state=m.DOCTYPE_DTD,y.q="");continue;case m.COMMENT:P==="-"?y.state=m.COMMENT_ENDING:y.comment+=P;continue;case m.COMMENT_ENDING:P==="-"?(y.state=m.COMMENT_ENDED,y.comment=W(y.opt,y.comment),y.comment&&B(y,"oncomment",y.comment),y.comment=""):(y.comment+="-"+P,y.state=m.COMMENT);continue;case m.COMMENT_ENDED:P!==">"?(V(y,"Malformed comment"),y.comment+="--"+P,y.state=m.COMMENT):y.doctype&&y.doctype!==!0?y.state=m.DOCTYPE_DTD:y.state=m.TEXT;continue;case m.CDATA:P==="]"?y.state=m.CDATA_ENDING:y.cdata+=P;continue;case m.CDATA_ENDING:P==="]"?y.state=m.CDATA_ENDING_2:(y.cdata+="]"+P,y.state=m.CDATA);continue;case m.CDATA_ENDING_2:P===">"?(y.cdata&&B(y,"oncdata",y.cdata),B(y,"onclosecdata"),y.cdata="",y.state=m.TEXT):P==="]"?y.cdata+="]":(y.cdata+="]]"+P,y.state=m.CDATA);continue;case m.PROC_INST:P==="?"?y.state=m.PROC_INST_ENDING:_(P)?y.state=m.PROC_INST_BODY:y.procInstName+=P;continue;case m.PROC_INST_BODY:if(!y.procInstBody&&_(P))continue;P==="?"?y.state=m.PROC_INST_ENDING:y.procInstBody+=P;continue;case m.PROC_INST_ENDING:P===">"?(B(y,"onprocessinginstruction",{name:y.procInstName,body:y.procInstBody}),y.procInstName=y.procInstBody="",y.state=m.TEXT):(y.procInstBody+="?"+P,y.state=m.PROC_INST_BODY);continue;case m.OPEN_TAG:q(D,P)?y.tagName+=P:(ft(y),P===">"?st(y):P==="/"?y.state=m.OPEN_TAG_SLASH:(_(P)||V(y,"Invalid character in tag name"),y.state=m.ATTRIB));continue;case m.OPEN_TAG_SLASH:P===">"?(st(y,!0),ut(y)):(V(y,"Forward-slash in opening tag not followed by >"),y.state=m.ATTRIB);continue;case m.ATTRIB:if(_(P))continue;P===">"?st(y):P==="/"?y.state=m.OPEN_TAG_SLASH:q(I,P)?(y.attribName=P,y.attribValue="",y.state=m.ATTRIB_NAME):V(y,"Invalid attribute name");continue;case m.ATTRIB_NAME:P==="="?y.state=m.ATTRIB_VALUE:P===">"?(V(y,"Attribute without value"),y.attribValue=y.attribName,at(y),st(y)):_(P)?y.state=m.ATTRIB_NAME_SAW_WHITE:q(D,P)?y.attribName+=P:V(y,"Invalid attribute name");continue;case m.ATTRIB_NAME_SAW_WHITE:if(P==="=")y.state=m.ATTRIB_VALUE;else{if(_(P))continue;V(y,"Attribute without value"),y.tag.attributes[y.attribName]="",y.attribValue="",B(y,"onattribute",{name:y.attribName,value:""}),y.attribName="",P===">"?st(y):q(I,P)?(y.attribName=P,y.state=m.ATTRIB_NAME):(V(y,"Invalid attribute name"),y.state=m.ATTRIB)}continue;case m.ATTRIB_VALUE:if(_(P))continue;M(P)?(y.q=P,y.state=m.ATTRIB_VALUE_QUOTED):(y.opt.unquotedAttributeValues||Y(y,"Unquoted attribute value"),y.state=m.ATTRIB_VALUE_UNQUOTED,y.attribValue=P);continue;case m.ATTRIB_VALUE_QUOTED:if(P!==y.q){P==="&"?y.state=m.ATTRIB_VALUE_ENTITY_Q:y.attribValue+=P;continue}at(y),y.q="",y.state=m.ATTRIB_VALUE_CLOSED;continue;case m.ATTRIB_VALUE_CLOSED:_(P)?y.state=m.ATTRIB:P===">"?st(y):P==="/"?y.state=m.OPEN_TAG_SLASH:q(I,P)?(V(y,"No whitespace between attributes"),y.attribName=P,y.attribValue="",y.state=m.ATTRIB_NAME):V(y,"Invalid attribute name");continue;case m.ATTRIB_VALUE_UNQUOTED:if(!X(P)){P==="&"?y.state=m.ATTRIB_VALUE_ENTITY_U:y.attribValue+=P;continue}at(y),P===">"?st(y):y.state=m.ATTRIB;continue;case m.CLOSE_TAG:if(y.tagName)P===">"?ut(y):q(D,P)?y.tagName+=P:y.script?(y.script+="</"+y.tagName,y.tagName="",y.state=m.SCRIPT):(_(P)||V(y,"Invalid tagname in closing tag"),y.state=m.CLOSE_TAG_SAW_WHITE);else{if(_(P))continue;U(I,P)?y.script?(y.script+="</"+P,y.state=m.SCRIPT):V(y,"Invalid tagname in closing tag."):y.tagName=P}continue;case m.CLOSE_TAG_SAW_WHITE:if(_(P))continue;P===">"?ut(y):V(y,"Invalid characters in closing tag");continue;case m.TEXT_ENTITY:case m.ATTRIB_VALUE_ENTITY_Q:case m.ATTRIB_VALUE_ENTITY_U:var rt,ht;switch(y.state){case m.TEXT_ENTITY:rt=m.TEXT,ht="textNode";break;case m.ATTRIB_VALUE_ENTITY_Q:rt=m.ATTRIB_VALUE_QUOTED,ht="attribValue";break;case m.ATTRIB_VALUE_ENTITY_U:rt=m.ATTRIB_VALUE_UNQUOTED,ht="attribValue";break}if(P===";"){var A=_t(y);y.opt.unparsedEntities&&!Object.values(t.XML_ENTITIES).includes(A)?(y.entity="",y.state=rt,y.write(A)):(y[ht]+=A,y.entity="",y.state=rt)}else q(y.entity.length?g:C,P)?y.entity+=P:(V(y,"Invalid character in entity name"),y[ht]+="&"+y.entity+P,y.entity="",y.state=rt);continue;default:throw new Error(y,"Unknown state: "+y.state)}return y.position>=y.bufferCheckPosition&&o(y),y}/*! http://mths.be/fromcodepoint v0.1.0 by @mathias */String.fromCodePoint||function(){var x=String.fromCharCode,y=Math.floor,j=function(){var P=16384,J=[],ot,rt,ht=-1,A=arguments.length;if(!A)return"";for(var l="";++ht<A;){var u=Number(arguments[ht]);if(!isFinite(u)||u<0||u>1114111||y(u)!==u)throw RangeError("Invalid code point: "+u);u<=65535?J.push(u):(u-=65536,ot=(u>>10)+55296,rt=u%1024+56320,J.push(ot,rt)),(ht+1===A||J.length>P)&&(l+=x.apply(null,J),J.length=0)}return l};Object.defineProperty?Object.defineProperty(String,"fromCodePoint",{value:j,configurable:!0,writable:!0}):String.fromCodePoint=j}()})(a)}(Rn)),Rn}var Xn={},Mi;function So(){return Mi||(Mi=1,function(){Xn.stripBOM=function(a){return a[0]==="\uFEFF"?a.substring(1):a}}.call(it)),Xn}var re={},Pi;function rs(){return Pi||(Pi=1,function(){var a;a=new RegExp(/(?!xmlns)^.*:/),re.normalize=function(t){return t.toLowerCase()},re.firstCharLowerCase=function(t){return t.charAt(0).toLowerCase()+t.slice(1)},re.stripPrefix=function(t){return t.replace(a,"")},re.parseNumbers=function(t){return isNaN(t)||(t=t%1===0?parseInt(t,10):parseFloat(t)),t},re.parseBooleans=function(t){return/^(?:true|false)$/i.test(t)&&(t=t.toLowerCase()==="true"),t}}.call(it)),re}var Li;function Fo(){return Li||(Li=1,function(a){(function(){var t,e,n,o,i,r,s,f,E,d=function(w,T){return function(){return w.apply(T,arguments)}},p=function(w,T){for(var v in T)b.call(T,v)&&(w[v]=T[v]);function I(){this.constructor=w}return I.prototype=T.prototype,w.prototype=new I,w.__super__=T.prototype,w},b={}.hasOwnProperty;f=Lo(),o=zn,t=So(),s=rs(),E=ls.setImmediate,e=Gn().defaults,i=function(w){return typeof w=="object"&&w!=null&&Object.keys(w).length===0},r=function(w,T,v){var I,D,C;for(I=0,D=w.length;I<D;I++)C=w[I],T=C(T,v);return T},n=function(w,T,v){var I;return I=Object.create(null),I.value=v,I.writable=!0,I.enumerable=!0,I.configurable=!0,Object.defineProperty(w,T,I)},a.Parser=function(w){p(T,w);function T(v){this.parseStringPromise=d(this.parseStringPromise,this),this.parseString=d(this.parseString,this),this.reset=d(this.reset,this),this.assignOrPush=d(this.assignOrPush,this),this.processAsync=d(this.processAsync,this);var I,D,C;if(!(this instanceof a.Parser))return new a.Parser(v);this.options={},D=e["0.2"];for(I in D)b.call(D,I)&&(C=D[I],this.options[I]=C);for(I in v)b.call(v,I)&&(C=v[I],this.options[I]=C);this.options.xmlns&&(this.options.xmlnskey=this.options.attrkey+"ns"),this.options.normalizeTags&&(this.options.tagNameProcessors||(this.options.tagNameProcessors=[]),this.options.tagNameProcessors.unshift(s.normalize)),this.reset()}return T.prototype.processAsync=function(){var v,I;try{return this.remaining.length<=this.options.chunkSize?(v=this.remaining,this.remaining="",this.saxParser=this.saxParser.write(v),this.saxParser.close()):(v=this.remaining.substr(0,this.options.chunkSize),this.remaining=this.remaining.substr(this.options.chunkSize,this.remaining.length),this.saxParser=this.saxParser.write(v),E(this.processAsync))}catch(D){if(I=D,!this.saxParser.errThrown)return this.saxParser.errThrown=!0,this.emit(I)}},T.prototype.assignOrPush=function(v,I,D){return I in v?(v[I]instanceof Array||n(v,I,[v[I]]),v[I].push(D)):this.options.explicitArray?n(v,I,[D]):n(v,I,D)},T.prototype.reset=function(){var v,I,D,C;return this.removeAllListeners(),this.saxParser=f.parser(this.options.strict,{trim:!1,normalize:!1,xmlns:this.options.xmlns}),this.saxParser.errThrown=!1,this.saxParser.onerror=function(g){return function(_){if(g.saxParser.resume(),!g.saxParser.errThrown)return g.saxParser.errThrown=!0,g.emit("error",_)}}(this),this.saxParser.onend=function(g){return function(){if(!g.saxParser.ended)return g.saxParser.ended=!0,g.emit("end",g.resultObject)}}(this),this.saxParser.ended=!1,this.EXPLICIT_CHARKEY=this.options.explicitCharkey,this.resultObject=null,C=[],v=this.options.attrkey,I=this.options.charkey,this.saxParser.onopentag=function(g){return function(_){var M,X,q,U,m;if(q={},q[I]="",!g.options.ignoreAttrs){m=_.attributes;for(M in m)b.call(m,M)&&(!(v in q)&&!g.options.mergeAttrs&&(q[v]={}),X=g.options.attrValueProcessors?r(g.options.attrValueProcessors,_.attributes[M],M):_.attributes[M],U=g.options.attrNameProcessors?r(g.options.attrNameProcessors,M):M,g.options.mergeAttrs?g.assignOrPush(q,U,X):n(q[v],U,X))}return q["#name"]=g.options.tagNameProcessors?r(g.options.tagNameProcessors,_.name):_.name,g.options.xmlns&&(q[g.options.xmlnskey]={uri:_.uri,local:_.local}),C.push(q)}}(this),this.saxParser.onclosetag=function(g){return function(){var _,M,X,q,U,m,R,S,B,$;if(m=C.pop(),U=m["#name"],(!g.options.explicitChildren||!g.options.preserveChildrenOrder)&&delete m["#name"],m.cdata===!0&&(_=m.cdata,delete m.cdata),B=C[C.length-1],m[I].match(/^\s*$/)&&!_?(M=m[I],delete m[I]):(g.options.trim&&(m[I]=m[I].trim()),g.options.normalize&&(m[I]=m[I].replace(/\s{2,}/g," ").trim()),m[I]=g.options.valueProcessors?r(g.options.valueProcessors,m[I],U):m[I],Object.keys(m).length===1&&I in m&&!g.EXPLICIT_CHARKEY&&(m=m[I])),i(m)&&(typeof g.options.emptyTag=="function"?m=g.options.emptyTag():m=g.options.emptyTag!==""?g.options.emptyTag:M),g.options.validator!=null&&($="/"+function(){var W,Y,k;for(k=[],W=0,Y=C.length;W<Y;W++)q=C[W],k.push(q["#name"]);return k}().concat(U).join("/"),function(){var W;try{return m=g.options.validator($,B&&B[U],m)}catch(Y){return W=Y,g.emit("error",W)}}()),g.options.explicitChildren&&!g.options.mergeAttrs&&typeof m=="object"){if(!g.options.preserveChildrenOrder)q={},g.options.attrkey in m&&(q[g.options.attrkey]=m[g.options.attrkey],delete m[g.options.attrkey]),!g.options.charsAsChildren&&g.options.charkey in m&&(q[g.options.charkey]=m[g.options.charkey],delete m[g.options.charkey]),Object.getOwnPropertyNames(m).length>0&&(q[g.options.childkey]=m),m=q;else if(B){B[g.options.childkey]=B[g.options.childkey]||[],R={};for(X in m)b.call(m,X)&&n(R,X,m[X]);B[g.options.childkey].push(R),delete m["#name"],Object.keys(m).length===1&&I in m&&!g.EXPLICIT_CHARKEY&&(m=m[I])}}return C.length>0?g.assignOrPush(B,U,m):(g.options.explicitRoot&&(S=m,m={},n(m,U,S)),g.resultObject=m,g.saxParser.ended=!0,g.emit("end",g.resultObject))}}(this),D=function(g){return function(_){var M,X;if(X=C[C.length-1],X)return X[I]+=_,g.options.explicitChildren&&g.options.preserveChildrenOrder&&g.options.charsAsChildren&&(g.options.includeWhiteChars||_.replace(/\\n/g,"").trim()!=="")&&(X[g.options.childkey]=X[g.options.childkey]||[],M={"#name":"__text__"},M[I]=_,g.options.normalize&&(M[I]=M[I].replace(/\s{2,}/g," ").trim()),X[g.options.childkey].push(M)),X}}(this),this.saxParser.ontext=D,this.saxParser.oncdata=function(g){return function(_){var M;if(M=D(_),M)return M.cdata=!0}}()},T.prototype.parseString=function(v,I){var D;I!=null&&typeof I=="function"&&(this.on("end",function(C){return this.reset(),I(null,C)}),this.on("error",function(C){return this.reset(),I(C)}));try{return v=v.toString(),v.trim()===""?(this.emit("end",null),!0):(v=t.stripBOM(v),this.options.async?(this.remaining=v,E(this.processAsync),this.saxParser):this.saxParser.write(v).close())}catch(C){if(D=C,this.saxParser.errThrown||this.saxParser.ended){if(this.saxParser.ended)throw D}else return this.emit("error",D),this.saxParser.errThrown=!0}},T.prototype.parseStringPromise=function(v){return new Promise(function(I){return function(D,C){return I.parseString(v,function(g,_){return g?C(g):D(_)})}}(this))},T}(o),a.parseString=function(w,T,v){var I,D,C;return v!=null?(typeof v=="function"&&(I=v),typeof T=="object"&&(D=T)):(typeof T=="function"&&(I=T),D={}),C=new a.Parser(D),C.parseString(w,I)},a.parseStringPromise=function(w,T){var v,I;return typeof T=="object"&&(v=T),I=new a.Parser(v),I.parseStringPromise(w)}}).call(it)}(jn)),jn}var is;(function(){var a,t,e,n=function(i,r){for(var s in r)o.call(r,s)&&(i[s]=r[s]);function f(){this.constructor=i}return f.prototype=r.prototype,i.prototype=new f,i.__super__=r.prototype,i},o={}.hasOwnProperty;t=Gn(),a=_o(),e=Fo(),rs(),t.defaults,function(i){n(r,i);function r(s){this.message=s}return r}(Error),a.Builder,e.Parser,e.parseString,is=e.parseStringPromise}).call(it);class ss{constructor(t,e,n){this.nextTxnId=1,this.pendingCommands=new Map,this.breakpoints=new Map,this.scriptIdByUrl=new Map,this.nextScriptId=1,this.objectHandles=new Map,this.nextObjectId=1,this.callFramesMap=new Map,this.xdebugConnected=!1,this.xdebugStatus="starting",this.initFileUri=null,this.dbgp=t,this.cdp=e,this.readPHPFile=n.getPHPFile,this.remoteRoot=n.remoteRoot||"",this.localRoot=n.localRoot||"";for(const o of n.knownScriptUrls)this.scriptIdByUrl.set(o,this.getOrCreateScriptId(o))}start(){this.dbgp.on("connected",()=>{this.xdebugConnected=!0,this.sendDbgpCommand("stdout","-c 1"),this.sendDbgpCommand("stderr","-c 1")}),this.dbgp.on("message",async t=>{try{const e=await is(t,{explicitArray:!1});await this.handleDbgpMessage(e)}catch{}}),this.dbgp.on("close",()=>{this.xdebugConnected=!1,this.cdp.sendMessage({method:"Debugger.paused",params:{reason:"terminated",callFrames:[]}}),setTimeout(()=>{this.cdp.ws&&this.cdp.ws.close()},100)}),this.cdp.on("clientConnected",()=>{if(this.xdebugConnected&&(this.sendInitialScripts(),this.xdebugStatus==="starting"||this.xdebugStatus==="break")){const t=this.sendDbgpCommand("stack_get");this.pendingCommands.set(t,{})}}),this.cdp.on("message",t=>{this.handleCdpMessage(t)}),this.cdp.on("clientDisconnected",()=>{this.xdebugConnected&&this.sendDbgpCommand("detach")})}sendInitialScripts(){if(this.initFileUri&&!this.scriptIdByUrl.has(this.initFileUri)){const t=this.getOrCreateScriptId(this.initFileUri);this.cdp.sendMessage({method:"Debugger.scriptParsed",params:{scriptId:t,url:this.initFileUri,startLine:0,startColumn:0,executionContextId:1}})}for(const[t,e]of this.scriptIdByUrl.entries())this.cdp.sendMessage({method:"Debugger.scriptParsed",params:{scriptId:e,url:t,startLine:0,startColumn:0,executionContextId:1}})}getOrCreateScriptId(t){let e=this.scriptIdByUrl.get(t);return e||(e=String(this.nextScriptId++),this.scriptIdByUrl.set(t,e)),e}formatPropertyFullName(t){let e=!1,n="";for(const o of t)o==='"'||o==="\\"||o==="\0"?(n+="\\"+o,e=!0):o===" "?(n+=o,e=!0):n+=o;return(e||t.includes("'"))&&(n=`"${n}"`),n}sendDbgpCommand(t,e){console.log("\x1B[1;32m[XDebug][send]\x1B[0m",t,e);const o=(this.nextTxnId++).toString();let i=`${t} -i ${o}`;return e!==void 0&&(i+=` ${e}`),this.dbgp.sendCommand(i),o}handleCdpMessage(t){const{id:e,method:n,params:o}=t;let i={},r=!0;switch(n){case"Debugger.enable":case"Runtime.enable":i={};break;case"Debugger.setBreakpointByUrl":{const{url:s,lineNumber:f}=o,E=s,d=(typeof f=="number"?f:0)+1,p=String(this.breakpoints.size+1);if(this.xdebugConnected){const b=`breakpoint_set -t line -f ${this.formatPropertyFullName(E)} -n ${d}`,w=this.sendDbgpCommand(b);this.pendingCommands.set(w,{cdpId:e,cdpMethod:n,params:{breakpointId:p,fileUri:E,line:d}}),r=!1}else this.breakpoints.set(p,{cdpId:p,xdebugId:null,file:E,line:d}),i={breakpointId:p,locations:[{scriptId:this.getOrCreateScriptId(E),lineNumber:d-1,columnNumber:0}]};break}case"Debugger.removeBreakpoint":{const{breakpointId:s}=o,f=String(s),E=this.breakpoints.get(f);if(E){if(E.xdebugId&&this.xdebugConnected){const d=`breakpoint_remove -d ${E.xdebugId}`,p=this.sendDbgpCommand(d);this.pendingCommands.set(p,{cdpId:e,cdpMethod:n}),r=!1}this.breakpoints.delete(f)}i={};break}case"Debugger.resume":{this.xdebugConnected&&(this.xdebugStatus="running",this.sendDbgpCommand("run")),i={};break}case"Debugger.stepOver":{this.xdebugConnected&&(this.xdebugStatus="running",this.sendDbgpCommand("step_over")),i={};break}case"Debugger.stepInto":{this.xdebugConnected&&(this.xdebugStatus="running",this.sendDbgpCommand("step_into")),i={};break}case"Debugger.stepOut":{this.xdebugConnected&&(this.xdebugStatus="running",this.sendDbgpCommand("step_out")),i={};break}case"Debugger.pause":{this.xdebugConnected&&this.sendDbgpCommand("break"),i={};break}case"Runtime.evaluate":case"Debugger.evaluateOnCallFrame":{const s=o.expression||"",f=o.callFrameId;if(n==="Debugger.evaluateOnCallFrame"){if(f===void 0||!this.callFramesMap.has(f)){this.cdp.sendMessage({id:e,error:{code:-32e3,message:"No such call frame"}});return}if(this.callFramesMap.get(f)!==0){this.cdp.sendMessage({id:e,error:{code:-32e3,message:"Evaluation in this frame not supported"}});return}}if(this.xdebugConnected){const E=Buffer.from(s).toString("base64"),d=this.sendDbgpCommand("eval",`-- ${E}`);this.pendingCommands.set(d,{cdpId:e,cdpMethod:n}),r=!1}else i={result:{type:"undefined",value:void 0}};break}case"Runtime.getProperties":{const{objectId:s}=o,f=this.objectHandles.get(s);if(f&&this.xdebugConnected)if(f.type==="context"){const E=f.contextId??0,p=`context_get -d ${f.depth} -c ${E}`,b=this.sendDbgpCommand(p);this.pendingCommands.set(b,{cdpId:e,cdpMethod:n}),r=!1}else if(f.type==="property"){const E=f.depth,d=f.fullname,p=this.formatPropertyFullName(d),b=`property_get -d ${E} -n ${p}`,w=this.sendDbgpCommand(b);this.pendingCommands.set(w,{cdpId:e,cdpMethod:n,params:{parentObjectId:s}}),r=!1}else i={result:[]};else i={result:[]};break}case"Debugger.getScriptSource":{const s=o.scriptId,f=[...this.scriptIdByUrl.entries()].find(([,d])=>d===s)?.[0];let E="";f&&(E=this.readPHPFile(this.uriToRemotePath(f))),i={scriptSource:E};break}default:i={};break}r&&this.cdp.sendMessage({id:e,result:i})}uriToRemotePath(t){return t.startsWith("file://")?t.slice(7):t}remoteToLocal(t){let e=t;return this.remoteRoot&&e.startsWith(this.remoteRoot)&&(e=xt.join(this.localRoot||"",e.slice(this.remoteRoot.length))),process.platform==="win32"&&e.startsWith("/")&&(e=e.slice(1)),e}async handleDbgpMessage(t){if(t.init){const e=t.init.$;this.initFileUri=e.fileuri||e.fileuri,this.xdebugStatus="starting";const n=this.sendDbgpCommand("step_into");this.pendingCommands.set(n,{}),this.cdp.ws&&this.sendInitialScripts();return}if(t.response){const e=t.response,n=e.$,o=n.command,i=n.transaction_id,r=this.pendingCommands.get(i);switch(o){case"breakpoint_set":{if(r&&r.cdpId!==void 0&&r.cdpMethod==="Debugger.setBreakpointByUrl"){const s=n.id,f=r.params;if(f){const{breakpointId:E,fileUri:d,line:p}=f;this.breakpoints.set(E,{cdpId:E,xdebugId:s,file:d,line:p});const b=this.getOrCreateScriptId(d),w={breakpointId:E,locations:[{scriptId:b,lineNumber:p-1,columnNumber:0}]};this.cdp.sendMessage({id:r.cdpId,result:w})}this.pendingCommands.delete(i)}break}case"breakpoint_remove":{r&&r.cdpId!==void 0&&(this.cdp.sendMessage({id:r.cdpId,result:{}}),this.pendingCommands.delete(i));break}case"run":case"step_into":case"step_over":case"step_out":{const s=n.status;if(this.xdebugStatus=s,e["xdebug:message"]){const f=e["xdebug:message"].$.filename;if(f&&!this.scriptIdByUrl.has(f)){const E=this.getOrCreateScriptId(f);this.cdp.sendMessage({method:"Debugger.scriptParsed",params:{scriptId:E,url:f,startLine:0,startColumn:0,executionContextId:1}})}}if(s==="break"){const f=this.sendDbgpCommand("stack_get");this.pendingCommands.set(f,{}),this.pendingCommands.delete(i)}else(s==="stopping"||s==="stopped")&&this.cdp.sendMessage({method:"Debugger.resumed",params:{}});break}case"eval":{if(r&&r.cdpId!==void 0){let s;if(e.property){const E=e.property,d=E.$.type,p=E.$.encoding;let b=null;if(Object.prototype.hasOwnProperty.call(E,"_")?b=E._:typeof E.$value<"u"&&(b=E.$value),p==="base64"&&b!==null)try{b=Buffer.from(b,"base64").toString()}catch{}if(d==="string")s={type:"string",value:b??""};else if(d==="int"||d==="float"||d==="bool"||d==="boolen"||d==="integer"||d==="double"){let w=b;d.startsWith("int")||d==="integer"?w=parseInt(b||"0",10):d==="float"||d==="double"?w=parseFloat(b||"0"):d.startsWith("bool")&&(w=b==="1"||b==="true"),s={type:"number",value:w}}else if(d==="array"||d==="object"){const w=E.$.classname||(d==="array"?"Array":"Object"),T=String(this.nextObjectId++),v=E.$.fullname||"";this.objectHandles.set(T,{type:"property",depth:0,contextId:0,fullname:v}),s={type:"object",objectId:T,className:w,description:w}}else d==="null"?s={type:"object",subtype:"null",value:null}:s={type:"undefined",value:void 0}}else s={type:"undefined",value:void 0};const f={result:s};this.cdp.sendMessage({id:r.cdpId,result:f}),this.pendingCommands.delete(i)}break}case"context_get":case"property_get":{if(r&&r.cdpId!==void 0){const s=[],f=e.property;if(f){const d=Array.isArray(f)?f:[f];for(const p of d){const b=p.$.name||p.$.fullname||"";let w=p.$.type||"undefined";const T=p.$.children==="1",v=p.$.encoding;let I=null;if(typeof p._<"u"&&(I=p._),v==="base64"&&I!==null)try{I=Buffer.from(I,"base64").toString()}catch{}if(T){const D=p.$.classname||(w==="array"?"Array":"Object"),C=String(this.nextObjectId++),g=r.cdpMethod==="Runtime.getProperties"&&r.params?.parentObjectId&&this.objectHandles.get(r.params.parentObjectId)?.contextId||0,_=r.cdpMethod==="Runtime.getProperties"&&r.params?.parentObjectId&&this.objectHandles.get(r.params.parentObjectId)?.depth||0;this.objectHandles.set(C,{type:"property",depth:_,contextId:g,fullname:p.$.fullname||b}),s.push({name:p.$.key||b,value:{type:"object",className:D,description:D,objectId:C},writable:!1,configurable:!1,enumerable:!0})}else{let D,C;w==="string"?D=I??"":w==="int"||w==="integer"?D=parseInt(I||"0",10):w==="float"||w==="double"?D=parseFloat(I||"0"):w==="bool"||w==="boolean"?(D=I==="1"||I==="true",w="boolean"):w==="null"?(D=null,C="null"):D=I;const g={type:w==="integer"?"number":w};C&&(g.subtype=C),g.value=D,s.push({name:p.$.key||b,value:g,writable:!1,configurable:!1,enumerable:!0})}}}const E={result:s};this.cdp.sendMessage({id:r.cdpId,result:E}),this.pendingCommands.delete(i)}break}case"stack_get":{if(e.stack){const s=Array.isArray(e.stack)?e.stack:[e.stack],f=[];this.callFramesMap.clear();for(const d of s){const p=d.$.filename,b=this.getOrCreateScriptId(p);this.scriptIdByUrl.has(p)||(this.scriptIdByUrl.set(p,b),this.cdp.sendMessage({method:"Debugger.scriptParsed",params:{scriptId:b,url:p,startLine:0,startColumn:0,executionContextId:1}}))}for(const d of s){const p=parseInt(d.$.level,10),b=d.$.filename,w=parseInt(d.$.lineno,10),T=d.$.where&&d.$.where!=="{main}"?d.$.where:"(anonymous)",v=this.getOrCreateScriptId(b),I=`frame:${p}`;this.callFramesMap.set(I,p);const D=[],C=String(this.nextObjectId++);this.objectHandles.set(C,{type:"context",contextId:0,depth:p}),D.push({type:"local",object:{objectId:C,className:"Object",description:"Local"}});const g=String(this.nextObjectId++);this.objectHandles.set(g,{type:"context",contextId:1,depth:p}),D.push({type:"global",object:{objectId:g,className:"Object",description:"Global"}}),f.push({callFrameId:I,functionName:T,location:{scriptId:v,lineNumber:w-1,columnNumber:0},scopeChain:D,this:{type:"object",className:"Object",description:"Object",objectId:g}})}let E="pause";if(s.length>0){const d=s[0];if(d.$.filename&&d.$.lineno){const p=d.$.filename,b=parseInt(d.$.lineno,10);for(const w of this.breakpoints.values())if(w.file===p&&w.line===b){E="breakpoint";break}}}this.cdp.sendMessage({method:"Debugger.paused",params:{reason:E,callFrames:f,hitBreakpoints:E==="breakpoint"?[""]:[]}})}this.pendingCommands.delete(i);break}default:{r&&r.cdpId!==void 0&&(this.cdp.sendMessage({id:r.cdpId,result:{}}),this.pendingCommands.delete(i));break}}}else if(t.stream){const e=t.stream,n=e.$.type,o=e.$.encoding||"none";let i=typeof e._=="string"?e._:"";o==="base64"&&(i=Buffer.from(i,"base64").toString()),this.cdp.sendMessage({method:"Log.entryAdded",params:{entry:{source:"other",level:n==="stderr"?"error":"info",text:i,timestamp:Date.now(),stackTrace:{callFrames:[]}}}})}else t.notify}}async function os(a){const t=a.cdpPort??9229,e=a.dbgpPort??9003,n=a.cdpHost??"localhost",o=a.phpRoot??void 0,i=new qi(t);console.log("Connect Chrome DevTools to CDP at:"),console.log(`devtools://devtools/bundled/inspector.html?ws=${n}:${t}`),await new Promise(d=>i.on("clientConnected",d)),await new Promise(d=>setTimeout(d,2e3)),console.log("Chrome connected! Initializing Xdebug receiver...");const r=new Wi(e);console.log(`XDebug receiver running on port ${e}`),console.log("Running a PHP script with Xdebug enabled...");function s(d){const p=[],b=Bt.readdirSync(d);for(const w of b){const T=xt.join(d,w),v=Bt.lstatSync(T);v&&v.isDirectory()?p.push(...s(T)):w.endsWith(".php")&&p.push(`file://${T}`)}return p}const f=a.phpInstance?d=>a.phpInstance.readFileAsText(d):a.getPHPFile?a.getPHPFile:d=>{const p=d.startsWith("file://")?d.replace("file://",""):d;return Bt.readFileSync(p,"utf-8")},E=s(o);return new ss(r,i,{knownScriptUrls:E,remoteRoot:a.remoteRoot,localRoot:a.localRoot,getPHPFile:f})}function jo(){return bo(js(process.argv)).usage(`
102
+ `?(y.line++,y.column=0):y.column++);y.textNode+=x.substring(J,j-1)}P==="<"&&!(y.sawRoot&&y.closedRoot&&!y.strict)?(y.state=m.OPEN_WAKA,y.startTagPosition=y.position):(!_(P)&&(!y.sawRoot||y.closedRoot)&&V(y,"Text data outside of root node."),P==="&"?y.state=m.TEXT_ENTITY:y.textNode+=P);continue;case m.SCRIPT:P==="<"?y.state=m.SCRIPT_ENDING:y.script+=P;continue;case m.SCRIPT_ENDING:P==="/"?y.state=m.CLOSE_TAG:(y.script+="<"+P,y.state=m.SCRIPT);continue;case m.OPEN_WAKA:if(P==="!")y.state=m.SGML_DECL,y.sgmlDecl="";else if(!_(P))if(q(I,P))y.state=m.OPEN_TAG,y.tagName=P;else if(P==="/")y.state=m.CLOSE_TAG,y.tagName="";else if(P==="?")y.state=m.PROC_INST,y.procInstName=y.procInstBody="";else{if(V(y,"Unencoded <"),y.startTagPosition+1<y.position){var ot=y.position-y.startTagPosition;P=new Array(ot).join(" ")+P}y.textNode+="<"+P,y.state=m.TEXT}continue;case m.SGML_DECL:if(y.sgmlDecl+P==="--"){y.state=m.COMMENT,y.comment="",y.sgmlDecl="";continue}y.doctype&&y.doctype!==!0&&y.sgmlDecl?(y.state=m.DOCTYPE_DTD,y.doctype+="<!"+y.sgmlDecl+P,y.sgmlDecl=""):(y.sgmlDecl+P).toUpperCase()===p?(B(y,"onopencdata"),y.state=m.CDATA,y.sgmlDecl="",y.cdata=""):(y.sgmlDecl+P).toUpperCase()===b?(y.state=m.DOCTYPE,(y.doctype||y.sawRoot)&&V(y,"Inappropriately located doctype declaration"),y.doctype="",y.sgmlDecl=""):P===">"?(B(y,"onsgmldeclaration",y.sgmlDecl),y.sgmlDecl="",y.state=m.TEXT):(M(P)&&(y.state=m.SGML_DECL_QUOTED),y.sgmlDecl+=P);continue;case m.SGML_DECL_QUOTED:P===y.q&&(y.state=m.SGML_DECL,y.q=""),y.sgmlDecl+=P;continue;case m.DOCTYPE:P===">"?(y.state=m.TEXT,B(y,"ondoctype",y.doctype),y.doctype=!0):(y.doctype+=P,P==="["?y.state=m.DOCTYPE_DTD:M(P)&&(y.state=m.DOCTYPE_QUOTED,y.q=P));continue;case m.DOCTYPE_QUOTED:y.doctype+=P,P===y.q&&(y.q="",y.state=m.DOCTYPE);continue;case m.DOCTYPE_DTD:P==="]"?(y.doctype+=P,y.state=m.DOCTYPE):P==="<"?(y.state=m.OPEN_WAKA,y.startTagPosition=y.position):M(P)?(y.doctype+=P,y.state=m.DOCTYPE_DTD_QUOTED,y.q=P):y.doctype+=P;continue;case m.DOCTYPE_DTD_QUOTED:y.doctype+=P,P===y.q&&(y.state=m.DOCTYPE_DTD,y.q="");continue;case m.COMMENT:P==="-"?y.state=m.COMMENT_ENDING:y.comment+=P;continue;case m.COMMENT_ENDING:P==="-"?(y.state=m.COMMENT_ENDED,y.comment=W(y.opt,y.comment),y.comment&&B(y,"oncomment",y.comment),y.comment=""):(y.comment+="-"+P,y.state=m.COMMENT);continue;case m.COMMENT_ENDED:P!==">"?(V(y,"Malformed comment"),y.comment+="--"+P,y.state=m.COMMENT):y.doctype&&y.doctype!==!0?y.state=m.DOCTYPE_DTD:y.state=m.TEXT;continue;case m.CDATA:P==="]"?y.state=m.CDATA_ENDING:y.cdata+=P;continue;case m.CDATA_ENDING:P==="]"?y.state=m.CDATA_ENDING_2:(y.cdata+="]"+P,y.state=m.CDATA);continue;case m.CDATA_ENDING_2:P===">"?(y.cdata&&B(y,"oncdata",y.cdata),B(y,"onclosecdata"),y.cdata="",y.state=m.TEXT):P==="]"?y.cdata+="]":(y.cdata+="]]"+P,y.state=m.CDATA);continue;case m.PROC_INST:P==="?"?y.state=m.PROC_INST_ENDING:_(P)?y.state=m.PROC_INST_BODY:y.procInstName+=P;continue;case m.PROC_INST_BODY:if(!y.procInstBody&&_(P))continue;P==="?"?y.state=m.PROC_INST_ENDING:y.procInstBody+=P;continue;case m.PROC_INST_ENDING:P===">"?(B(y,"onprocessinginstruction",{name:y.procInstName,body:y.procInstBody}),y.procInstName=y.procInstBody="",y.state=m.TEXT):(y.procInstBody+="?"+P,y.state=m.PROC_INST_BODY);continue;case m.OPEN_TAG:q(D,P)?y.tagName+=P:(ft(y),P===">"?st(y):P==="/"?y.state=m.OPEN_TAG_SLASH:(_(P)||V(y,"Invalid character in tag name"),y.state=m.ATTRIB));continue;case m.OPEN_TAG_SLASH:P===">"?(st(y,!0),ut(y)):(V(y,"Forward-slash in opening tag not followed by >"),y.state=m.ATTRIB);continue;case m.ATTRIB:if(_(P))continue;P===">"?st(y):P==="/"?y.state=m.OPEN_TAG_SLASH:q(I,P)?(y.attribName=P,y.attribValue="",y.state=m.ATTRIB_NAME):V(y,"Invalid attribute name");continue;case m.ATTRIB_NAME:P==="="?y.state=m.ATTRIB_VALUE:P===">"?(V(y,"Attribute without value"),y.attribValue=y.attribName,at(y),st(y)):_(P)?y.state=m.ATTRIB_NAME_SAW_WHITE:q(D,P)?y.attribName+=P:V(y,"Invalid attribute name");continue;case m.ATTRIB_NAME_SAW_WHITE:if(P==="=")y.state=m.ATTRIB_VALUE;else{if(_(P))continue;V(y,"Attribute without value"),y.tag.attributes[y.attribName]="",y.attribValue="",B(y,"onattribute",{name:y.attribName,value:""}),y.attribName="",P===">"?st(y):q(I,P)?(y.attribName=P,y.state=m.ATTRIB_NAME):(V(y,"Invalid attribute name"),y.state=m.ATTRIB)}continue;case m.ATTRIB_VALUE:if(_(P))continue;M(P)?(y.q=P,y.state=m.ATTRIB_VALUE_QUOTED):(y.opt.unquotedAttributeValues||Y(y,"Unquoted attribute value"),y.state=m.ATTRIB_VALUE_UNQUOTED,y.attribValue=P);continue;case m.ATTRIB_VALUE_QUOTED:if(P!==y.q){P==="&"?y.state=m.ATTRIB_VALUE_ENTITY_Q:y.attribValue+=P;continue}at(y),y.q="",y.state=m.ATTRIB_VALUE_CLOSED;continue;case m.ATTRIB_VALUE_CLOSED:_(P)?y.state=m.ATTRIB:P===">"?st(y):P==="/"?y.state=m.OPEN_TAG_SLASH:q(I,P)?(V(y,"No whitespace between attributes"),y.attribName=P,y.attribValue="",y.state=m.ATTRIB_NAME):V(y,"Invalid attribute name");continue;case m.ATTRIB_VALUE_UNQUOTED:if(!X(P)){P==="&"?y.state=m.ATTRIB_VALUE_ENTITY_U:y.attribValue+=P;continue}at(y),P===">"?st(y):y.state=m.ATTRIB;continue;case m.CLOSE_TAG:if(y.tagName)P===">"?ut(y):q(D,P)?y.tagName+=P:y.script?(y.script+="</"+y.tagName,y.tagName="",y.state=m.SCRIPT):(_(P)||V(y,"Invalid tagname in closing tag"),y.state=m.CLOSE_TAG_SAW_WHITE);else{if(_(P))continue;U(I,P)?y.script?(y.script+="</"+P,y.state=m.SCRIPT):V(y,"Invalid tagname in closing tag."):y.tagName=P}continue;case m.CLOSE_TAG_SAW_WHITE:if(_(P))continue;P===">"?ut(y):V(y,"Invalid characters in closing tag");continue;case m.TEXT_ENTITY:case m.ATTRIB_VALUE_ENTITY_Q:case m.ATTRIB_VALUE_ENTITY_U:var rt,ht;switch(y.state){case m.TEXT_ENTITY:rt=m.TEXT,ht="textNode";break;case m.ATTRIB_VALUE_ENTITY_Q:rt=m.ATTRIB_VALUE_QUOTED,ht="attribValue";break;case m.ATTRIB_VALUE_ENTITY_U:rt=m.ATTRIB_VALUE_UNQUOTED,ht="attribValue";break}if(P===";"){var A=_t(y);y.opt.unparsedEntities&&!Object.values(t.XML_ENTITIES).includes(A)?(y.entity="",y.state=rt,y.write(A)):(y[ht]+=A,y.entity="",y.state=rt)}else q(y.entity.length?g:C,P)?y.entity+=P:(V(y,"Invalid character in entity name"),y[ht]+="&"+y.entity+P,y.entity="",y.state=rt);continue;default:throw new Error(y,"Unknown state: "+y.state)}return y.position>=y.bufferCheckPosition&&o(y),y}/*! http://mths.be/fromcodepoint v0.1.0 by @mathias */String.fromCodePoint||function(){var x=String.fromCharCode,y=Math.floor,j=function(){var P=16384,J=[],ot,rt,ht=-1,A=arguments.length;if(!A)return"";for(var l="";++ht<A;){var u=Number(arguments[ht]);if(!isFinite(u)||u<0||u>1114111||y(u)!==u)throw RangeError("Invalid code point: "+u);u<=65535?J.push(u):(u-=65536,ot=(u>>10)+55296,rt=u%1024+56320,J.push(ot,rt)),(ht+1===A||J.length>P)&&(l+=x.apply(null,J),J.length=0)}return l};Object.defineProperty?Object.defineProperty(String,"fromCodePoint",{value:j,configurable:!0,writable:!0}):String.fromCodePoint=j}()})(a)}(Rn)),Rn}var Xn={},Mi;function So(){return Mi||(Mi=1,function(){Xn.stripBOM=function(a){return a[0]==="\uFEFF"?a.substring(1):a}}.call(it)),Xn}var re={},Pi;function rs(){return Pi||(Pi=1,function(){var a;a=new RegExp(/(?!xmlns)^.*:/),re.normalize=function(t){return t.toLowerCase()},re.firstCharLowerCase=function(t){return t.charAt(0).toLowerCase()+t.slice(1)},re.stripPrefix=function(t){return t.replace(a,"")},re.parseNumbers=function(t){return isNaN(t)||(t=t%1===0?parseInt(t,10):parseFloat(t)),t},re.parseBooleans=function(t){return/^(?:true|false)$/i.test(t)&&(t=t.toLowerCase()==="true"),t}}.call(it)),re}var Li;function Fo(){return Li||(Li=1,function(a){(function(){var t,e,n,o,i,r,s,f,E,d=function(w,T){return function(){return w.apply(T,arguments)}},p=function(w,T){for(var v in T)b.call(T,v)&&(w[v]=T[v]);function I(){this.constructor=w}return I.prototype=T.prototype,w.prototype=new I,w.__super__=T.prototype,w},b={}.hasOwnProperty;f=Lo(),o=zn,t=So(),s=rs(),E=ls.setImmediate,e=Gn().defaults,i=function(w){return typeof w=="object"&&w!=null&&Object.keys(w).length===0},r=function(w,T,v){var I,D,C;for(I=0,D=w.length;I<D;I++)C=w[I],T=C(T,v);return T},n=function(w,T,v){var I;return I=Object.create(null),I.value=v,I.writable=!0,I.enumerable=!0,I.configurable=!0,Object.defineProperty(w,T,I)},a.Parser=function(w){p(T,w);function T(v){this.parseStringPromise=d(this.parseStringPromise,this),this.parseString=d(this.parseString,this),this.reset=d(this.reset,this),this.assignOrPush=d(this.assignOrPush,this),this.processAsync=d(this.processAsync,this);var I,D,C;if(!(this instanceof a.Parser))return new a.Parser(v);this.options={},D=e["0.2"];for(I in D)b.call(D,I)&&(C=D[I],this.options[I]=C);for(I in v)b.call(v,I)&&(C=v[I],this.options[I]=C);this.options.xmlns&&(this.options.xmlnskey=this.options.attrkey+"ns"),this.options.normalizeTags&&(this.options.tagNameProcessors||(this.options.tagNameProcessors=[]),this.options.tagNameProcessors.unshift(s.normalize)),this.reset()}return T.prototype.processAsync=function(){var v,I;try{return this.remaining.length<=this.options.chunkSize?(v=this.remaining,this.remaining="",this.saxParser=this.saxParser.write(v),this.saxParser.close()):(v=this.remaining.substr(0,this.options.chunkSize),this.remaining=this.remaining.substr(this.options.chunkSize,this.remaining.length),this.saxParser=this.saxParser.write(v),E(this.processAsync))}catch(D){if(I=D,!this.saxParser.errThrown)return this.saxParser.errThrown=!0,this.emit(I)}},T.prototype.assignOrPush=function(v,I,D){return I in v?(v[I]instanceof Array||n(v,I,[v[I]]),v[I].push(D)):this.options.explicitArray?n(v,I,[D]):n(v,I,D)},T.prototype.reset=function(){var v,I,D,C;return this.removeAllListeners(),this.saxParser=f.parser(this.options.strict,{trim:!1,normalize:!1,xmlns:this.options.xmlns}),this.saxParser.errThrown=!1,this.saxParser.onerror=function(g){return function(_){if(g.saxParser.resume(),!g.saxParser.errThrown)return g.saxParser.errThrown=!0,g.emit("error",_)}}(this),this.saxParser.onend=function(g){return function(){if(!g.saxParser.ended)return g.saxParser.ended=!0,g.emit("end",g.resultObject)}}(this),this.saxParser.ended=!1,this.EXPLICIT_CHARKEY=this.options.explicitCharkey,this.resultObject=null,C=[],v=this.options.attrkey,I=this.options.charkey,this.saxParser.onopentag=function(g){return function(_){var M,X,q,U,m;if(q={},q[I]="",!g.options.ignoreAttrs){m=_.attributes;for(M in m)b.call(m,M)&&(!(v in q)&&!g.options.mergeAttrs&&(q[v]={}),X=g.options.attrValueProcessors?r(g.options.attrValueProcessors,_.attributes[M],M):_.attributes[M],U=g.options.attrNameProcessors?r(g.options.attrNameProcessors,M):M,g.options.mergeAttrs?g.assignOrPush(q,U,X):n(q[v],U,X))}return q["#name"]=g.options.tagNameProcessors?r(g.options.tagNameProcessors,_.name):_.name,g.options.xmlns&&(q[g.options.xmlnskey]={uri:_.uri,local:_.local}),C.push(q)}}(this),this.saxParser.onclosetag=function(g){return function(){var _,M,X,q,U,m,R,S,B,$;if(m=C.pop(),U=m["#name"],(!g.options.explicitChildren||!g.options.preserveChildrenOrder)&&delete m["#name"],m.cdata===!0&&(_=m.cdata,delete m.cdata),B=C[C.length-1],m[I].match(/^\s*$/)&&!_?(M=m[I],delete m[I]):(g.options.trim&&(m[I]=m[I].trim()),g.options.normalize&&(m[I]=m[I].replace(/\s{2,}/g," ").trim()),m[I]=g.options.valueProcessors?r(g.options.valueProcessors,m[I],U):m[I],Object.keys(m).length===1&&I in m&&!g.EXPLICIT_CHARKEY&&(m=m[I])),i(m)&&(typeof g.options.emptyTag=="function"?m=g.options.emptyTag():m=g.options.emptyTag!==""?g.options.emptyTag:M),g.options.validator!=null&&($="/"+function(){var W,Y,k;for(k=[],W=0,Y=C.length;W<Y;W++)q=C[W],k.push(q["#name"]);return k}().concat(U).join("/"),function(){var W;try{return m=g.options.validator($,B&&B[U],m)}catch(Y){return W=Y,g.emit("error",W)}}()),g.options.explicitChildren&&!g.options.mergeAttrs&&typeof m=="object"){if(!g.options.preserveChildrenOrder)q={},g.options.attrkey in m&&(q[g.options.attrkey]=m[g.options.attrkey],delete m[g.options.attrkey]),!g.options.charsAsChildren&&g.options.charkey in m&&(q[g.options.charkey]=m[g.options.charkey],delete m[g.options.charkey]),Object.getOwnPropertyNames(m).length>0&&(q[g.options.childkey]=m),m=q;else if(B){B[g.options.childkey]=B[g.options.childkey]||[],R={};for(X in m)b.call(m,X)&&n(R,X,m[X]);B[g.options.childkey].push(R),delete m["#name"],Object.keys(m).length===1&&I in m&&!g.EXPLICIT_CHARKEY&&(m=m[I])}}return C.length>0?g.assignOrPush(B,U,m):(g.options.explicitRoot&&(S=m,m={},n(m,U,S)),g.resultObject=m,g.saxParser.ended=!0,g.emit("end",g.resultObject))}}(this),D=function(g){return function(_){var M,X;if(X=C[C.length-1],X)return X[I]+=_,g.options.explicitChildren&&g.options.preserveChildrenOrder&&g.options.charsAsChildren&&(g.options.includeWhiteChars||_.replace(/\\n/g,"").trim()!=="")&&(X[g.options.childkey]=X[g.options.childkey]||[],M={"#name":"__text__"},M[I]=_,g.options.normalize&&(M[I]=M[I].replace(/\s{2,}/g," ").trim()),X[g.options.childkey].push(M)),X}}(this),this.saxParser.ontext=D,this.saxParser.oncdata=function(g){return function(_){var M;if(M=D(_),M)return M.cdata=!0}}()},T.prototype.parseString=function(v,I){var D;I!=null&&typeof I=="function"&&(this.on("end",function(C){return this.reset(),I(null,C)}),this.on("error",function(C){return this.reset(),I(C)}));try{return v=v.toString(),v.trim()===""?(this.emit("end",null),!0):(v=t.stripBOM(v),this.options.async?(this.remaining=v,E(this.processAsync),this.saxParser):this.saxParser.write(v).close())}catch(C){if(D=C,this.saxParser.errThrown||this.saxParser.ended){if(this.saxParser.ended)throw D}else return this.emit("error",D),this.saxParser.errThrown=!0}},T.prototype.parseStringPromise=function(v){return new Promise(function(I){return function(D,C){return I.parseString(v,function(g,_){return g?C(g):D(_)})}}(this))},T}(o),a.parseString=function(w,T,v){var I,D,C;return v!=null?(typeof v=="function"&&(I=v),typeof T=="object"&&(D=T)):(typeof T=="function"&&(I=T),D={}),C=new a.Parser(D),C.parseString(w,I)},a.parseStringPromise=function(w,T){var v,I;return typeof T=="object"&&(v=T),I=new a.Parser(v),I.parseStringPromise(w)}}).call(it)}(jn)),jn}var is;(function(){var a,t,e,n=function(i,r){for(var s in r)o.call(r,s)&&(i[s]=r[s]);function f(){this.constructor=i}return f.prototype=r.prototype,i.prototype=new f,i.__super__=r.prototype,i},o={}.hasOwnProperty;t=Gn(),a=_o(),e=Fo(),rs(),t.defaults,function(i){n(r,i);function r(s){this.message=s}return r}(Error),a.Builder,e.Parser,e.parseString,is=e.parseStringPromise}).call(it);class ss{constructor(t,e,n){this.nextTxnId=1,this.pendingCommands=new Map,this.breakpoints=new Map,this.scriptIdByUrl=new Map,this.nextScriptId=1,this.objectHandles=new Map,this.nextObjectId=1,this.callFramesMap=new Map,this.xdebugConnected=!1,this.xdebugStatus="starting",this.initFileUri=null,this.dbgp=t,this.cdp=e,this.readPHPFile=n.getPHPFile,this.remoteRoot=n.remoteRoot||"",this.localRoot=n.localRoot||"";for(const o of n.knownScriptUrls)this.scriptIdByUrl.set(o,this.getOrCreateScriptId(o))}start(){this.dbgp.on("connected",()=>{this.xdebugConnected=!0,this.sendDbgpCommand("stdout","-c 1"),this.sendDbgpCommand("stderr","-c 1")}),this.dbgp.on("message",async t=>{try{const e=await is(t,{explicitArray:!1});await this.handleDbgpMessage(e)}catch{}}),this.dbgp.on("close",()=>{this.xdebugConnected=!1,this.cdp.sendMessage({method:"Debugger.paused",params:{reason:"terminated",callFrames:[]}}),setTimeout(()=>{this.cdp.ws&&this.cdp.ws.close()},100)}),this.cdp.on("clientConnected",()=>{if(this.xdebugConnected&&(this.sendInitialScripts(),this.xdebugStatus==="starting"||this.xdebugStatus==="break")){const t=this.sendDbgpCommand("stack_get");this.pendingCommands.set(t,{})}}),this.cdp.on("message",t=>{this.handleCdpMessage(t)}),this.cdp.on("clientDisconnected",()=>{this.xdebugConnected&&this.sendDbgpCommand("detach")})}sendInitialScripts(){if(this.initFileUri&&!this.scriptIdByUrl.has(this.initFileUri)){const t=this.getOrCreateScriptId(this.initFileUri);this.cdp.sendMessage({method:"Debugger.scriptParsed",params:{scriptId:t,url:this.initFileUri,startLine:0,startColumn:0,executionContextId:1}})}for(const[t,e]of this.scriptIdByUrl.entries())this.cdp.sendMessage({method:"Debugger.scriptParsed",params:{scriptId:e,url:t,startLine:0,startColumn:0,executionContextId:1}})}getOrCreateScriptId(t){let e=this.scriptIdByUrl.get(t);return e||(e=String(this.nextScriptId++),this.scriptIdByUrl.set(t,e)),e}formatPropertyFullName(t){let e=!1,n="";for(const o of t)o==='"'||o==="\\"||o==="\0"?(n+="\\"+o,e=!0):o===" "?(n+=o,e=!0):n+=o;return(e||t.includes("'"))&&(n=`"${n}"`),n}sendDbgpCommand(t,e){console.log("\x1B[1;32m[XDebug][send]\x1B[0m",t,e);const o=(this.nextTxnId++).toString();let i=`${t} -i ${o}`;return e!==void 0&&(i+=` ${e}`),this.dbgp.sendCommand(i),o}async handleCdpMessage(t){const{id:e,method:n,params:o}=t;let i={},r=!0;switch(n){case"Debugger.enable":case"Runtime.enable":i={};break;case"Debugger.setBreakpointByUrl":{const{url:s,lineNumber:f}=o,E=s,d=(typeof f=="number"?f:0)+1,p=String(this.breakpoints.size+1);if(this.xdebugConnected){const b=`breakpoint_set -t line -f ${this.formatPropertyFullName(E)} -n ${d}`,w=this.sendDbgpCommand(b);this.pendingCommands.set(w,{cdpId:e,cdpMethod:n,params:{breakpointId:p,fileUri:E,line:d}}),r=!1}else this.breakpoints.set(p,{cdpId:p,xdebugId:null,file:E,line:d}),i={breakpointId:p,locations:[{scriptId:this.getOrCreateScriptId(E),lineNumber:d-1,columnNumber:0}]};break}case"Debugger.removeBreakpoint":{const{breakpointId:s}=o,f=String(s),E=this.breakpoints.get(f);if(E){if(E.xdebugId&&this.xdebugConnected){const d=`breakpoint_remove -d ${E.xdebugId}`,p=this.sendDbgpCommand(d);this.pendingCommands.set(p,{cdpId:e,cdpMethod:n}),r=!1}this.breakpoints.delete(f)}i={};break}case"Debugger.resume":{this.xdebugConnected&&(this.xdebugStatus="running",this.sendDbgpCommand("run")),i={};break}case"Debugger.stepOver":{this.xdebugConnected&&(this.xdebugStatus="running",this.sendDbgpCommand("step_over")),i={};break}case"Debugger.stepInto":{this.xdebugConnected&&(this.xdebugStatus="running",this.sendDbgpCommand("step_into")),i={};break}case"Debugger.stepOut":{this.xdebugConnected&&(this.xdebugStatus="running",this.sendDbgpCommand("step_out")),i={};break}case"Debugger.pause":{this.xdebugConnected&&this.sendDbgpCommand("break"),i={};break}case"Runtime.evaluate":case"Debugger.evaluateOnCallFrame":{const s=o.expression||"",f=o.callFrameId;if(n==="Debugger.evaluateOnCallFrame"){if(f===void 0||!this.callFramesMap.has(f)){this.cdp.sendMessage({id:e,error:{code:-32e3,message:"No such call frame"}});return}if(this.callFramesMap.get(f)!==0){this.cdp.sendMessage({id:e,error:{code:-32e3,message:"Evaluation in this frame not supported"}});return}}if(this.xdebugConnected){const E=Buffer.from(s).toString("base64"),d=this.sendDbgpCommand("eval",`-- ${E}`);this.pendingCommands.set(d,{cdpId:e,cdpMethod:n}),r=!1}else i={result:{type:"undefined",value:void 0}};break}case"Runtime.getProperties":{const{objectId:s}=o,f=this.objectHandles.get(s);if(f&&this.xdebugConnected)if(f.type==="context"){const E=f.contextId??0,p=`context_get -d ${f.depth} -c ${E}`,b=this.sendDbgpCommand(p);this.pendingCommands.set(b,{cdpId:e,cdpMethod:n}),r=!1}else if(f.type==="property"){const E=f.depth,d=f.fullname,p=this.formatPropertyFullName(d),b=`property_get -d ${E} -n ${p}`,w=this.sendDbgpCommand(b);this.pendingCommands.set(w,{cdpId:e,cdpMethod:n,params:{parentObjectId:s}}),r=!1}else i={result:[]};else i={result:[]};break}case"Debugger.getScriptSource":{const s=o.scriptId,f=[...this.scriptIdByUrl.entries()].find(([,d])=>d===s)?.[0];let E="";f&&(E=await this.readPHPFile(this.uriToRemotePath(f))),i={scriptSource:E};break}default:i={};break}r&&this.cdp.sendMessage({id:e,result:i})}uriToRemotePath(t){return t.startsWith("file://")?t.slice(7):t}remoteToLocal(t){let e=t;return this.remoteRoot&&e.startsWith(this.remoteRoot)&&(e=xt.join(this.localRoot||"",e.slice(this.remoteRoot.length))),process.platform==="win32"&&e.startsWith("/")&&(e=e.slice(1)),e}async handleDbgpMessage(t){if(t.init){const e=t.init.$;this.initFileUri=e.fileuri||e.fileuri,this.xdebugStatus="starting";const n=this.sendDbgpCommand("step_into");this.pendingCommands.set(n,{}),this.cdp.ws&&this.sendInitialScripts();return}if(t.response){const e=t.response,n=e.$,o=n.command,i=n.transaction_id,r=this.pendingCommands.get(i);switch(o){case"breakpoint_set":{if(r&&r.cdpId!==void 0&&r.cdpMethod==="Debugger.setBreakpointByUrl"){const s=n.id,f=r.params;if(f){const{breakpointId:E,fileUri:d,line:p}=f;this.breakpoints.set(E,{cdpId:E,xdebugId:s,file:d,line:p});const b=this.getOrCreateScriptId(d),w={breakpointId:E,locations:[{scriptId:b,lineNumber:p-1,columnNumber:0}]};this.cdp.sendMessage({id:r.cdpId,result:w})}this.pendingCommands.delete(i)}break}case"breakpoint_remove":{r&&r.cdpId!==void 0&&(this.cdp.sendMessage({id:r.cdpId,result:{}}),this.pendingCommands.delete(i));break}case"run":case"step_into":case"step_over":case"step_out":{const s=n.status;if(this.xdebugStatus=s,e["xdebug:message"]){const f=e["xdebug:message"].$.filename;if(f&&!this.scriptIdByUrl.has(f)){const E=this.getOrCreateScriptId(f);this.cdp.sendMessage({method:"Debugger.scriptParsed",params:{scriptId:E,url:f,startLine:0,startColumn:0,executionContextId:1}})}}if(s==="break"){const f=this.sendDbgpCommand("stack_get");this.pendingCommands.set(f,{}),this.pendingCommands.delete(i)}else(s==="stopping"||s==="stopped")&&this.cdp.sendMessage({method:"Debugger.resumed",params:{}});break}case"eval":{if(r&&r.cdpId!==void 0){let s;if(e.property){const E=e.property,d=E.$.type,p=E.$.encoding;let b=null;if(Object.prototype.hasOwnProperty.call(E,"_")?b=E._:typeof E.$value<"u"&&(b=E.$value),p==="base64"&&b!==null)try{b=Buffer.from(b,"base64").toString()}catch{}if(d==="string")s={type:"string",value:b??""};else if(d==="int"||d==="float"||d==="bool"||d==="boolen"||d==="integer"||d==="double"){let w=b;d.startsWith("int")||d==="integer"?w=parseInt(b||"0",10):d==="float"||d==="double"?w=parseFloat(b||"0"):d.startsWith("bool")&&(w=b==="1"||b==="true"),s={type:"number",value:w}}else if(d==="array"||d==="object"){const w=E.$.classname||(d==="array"?"Array":"Object"),T=String(this.nextObjectId++),v=E.$.fullname||"";this.objectHandles.set(T,{type:"property",depth:0,contextId:0,fullname:v}),s={type:"object",objectId:T,className:w,description:w}}else d==="null"?s={type:"object",subtype:"null",value:null}:s={type:"undefined",value:void 0}}else s={type:"undefined",value:void 0};const f={result:s};this.cdp.sendMessage({id:r.cdpId,result:f}),this.pendingCommands.delete(i)}break}case"context_get":case"property_get":{if(r&&r.cdpId!==void 0){const s=[],f=e.property;if(f){const d=Array.isArray(f)?f:[f];for(const p of d){const b=p.$.name||p.$.fullname||"";let w=p.$.type||"undefined";const T=p.$.children==="1",v=p.$.encoding;let I=null;if(typeof p._<"u"&&(I=p._),v==="base64"&&I!==null)try{I=Buffer.from(I,"base64").toString()}catch{}if(T){const D=p.$.classname||(w==="array"?"Array":"Object"),C=String(this.nextObjectId++),g=r.cdpMethod==="Runtime.getProperties"&&r.params?.parentObjectId&&this.objectHandles.get(r.params.parentObjectId)?.contextId||0,_=r.cdpMethod==="Runtime.getProperties"&&r.params?.parentObjectId&&this.objectHandles.get(r.params.parentObjectId)?.depth||0;this.objectHandles.set(C,{type:"property",depth:_,contextId:g,fullname:p.$.fullname||b}),s.push({name:p.$.key||b,value:{type:"object",className:D,description:D,objectId:C},writable:!1,configurable:!1,enumerable:!0})}else{let D,C;w==="string"?D=I??"":w==="int"||w==="integer"?D=parseInt(I||"0",10):w==="float"||w==="double"?D=parseFloat(I||"0"):w==="bool"||w==="boolean"?(D=I==="1"||I==="true",w="boolean"):w==="null"?(D=null,C="null"):D=I;const g={type:w==="integer"?"number":w};C&&(g.subtype=C),g.value=D,s.push({name:p.$.key||b,value:g,writable:!1,configurable:!1,enumerable:!0})}}}const E={result:s};this.cdp.sendMessage({id:r.cdpId,result:E}),this.pendingCommands.delete(i)}break}case"stack_get":{if(e.stack){const s=Array.isArray(e.stack)?e.stack:[e.stack],f=[];this.callFramesMap.clear();for(const d of s){const p=d.$.filename,b=this.getOrCreateScriptId(p);this.scriptIdByUrl.has(p)||(this.scriptIdByUrl.set(p,b),this.cdp.sendMessage({method:"Debugger.scriptParsed",params:{scriptId:b,url:p,startLine:0,startColumn:0,executionContextId:1}}))}for(const d of s){const p=parseInt(d.$.level,10),b=d.$.filename,w=parseInt(d.$.lineno,10),T=d.$.where&&d.$.where!=="{main}"?d.$.where:"(anonymous)",v=this.getOrCreateScriptId(b),I=`frame:${p}`;this.callFramesMap.set(I,p);const D=[],C=String(this.nextObjectId++);this.objectHandles.set(C,{type:"context",contextId:0,depth:p}),D.push({type:"local",object:{objectId:C,className:"Object",description:"Local"}});const g=String(this.nextObjectId++);this.objectHandles.set(g,{type:"context",contextId:1,depth:p}),D.push({type:"global",object:{objectId:g,className:"Object",description:"Global"}}),f.push({callFrameId:I,functionName:T,location:{scriptId:v,lineNumber:w-1,columnNumber:0},scopeChain:D,this:{type:"object",className:"Object",description:"Object",objectId:g}})}let E="pause";if(s.length>0){const d=s[0];if(d.$.filename&&d.$.lineno){const p=d.$.filename,b=parseInt(d.$.lineno,10);for(const w of this.breakpoints.values())if(w.file===p&&w.line===b){E="breakpoint";break}}}this.cdp.sendMessage({method:"Debugger.paused",params:{reason:E,callFrames:f,hitBreakpoints:E==="breakpoint"?[""]:[]}})}this.pendingCommands.delete(i);break}default:{r&&r.cdpId!==void 0&&(this.cdp.sendMessage({id:r.cdpId,result:{}}),this.pendingCommands.delete(i));break}}}else if(t.stream){const e=t.stream,n=e.$.type,o=e.$.encoding||"none";let i=typeof e._=="string"?e._:"";o==="base64"&&(i=Buffer.from(i,"base64").toString()),this.cdp.sendMessage({method:"Log.entryAdded",params:{entry:{source:"other",level:n==="stderr"?"error":"info",text:i,timestamp:Date.now(),stackTrace:{callFrames:[]}}}})}else t.notify}}async function os(a){const t=a.cdpPort??9229,e=a.dbgpPort??9003,n=a.cdpHost??"localhost",o=a.phpRoot??void 0,i=new qi(t);console.log("Connect Chrome DevTools to CDP at:"),console.log(`devtools://devtools/bundled/inspector.html?ws=${n}:${t}`),await new Promise(d=>i.on("clientConnected",d)),await new Promise(d=>setTimeout(d,2e3)),console.log("Chrome connected! Initializing Xdebug receiver...");const r=new Wi(e);console.log(`XDebug receiver running on port ${e}`),console.log("Running a PHP script with Xdebug enabled...");function s(d){const p=[],b=Bt.readdirSync(d);for(const w of b){const T=xt.join(d,w),v=Bt.lstatSync(T);v&&v.isDirectory()?p.push(...s(T)):w.endsWith(".php")&&p.push(`file://${T}`)}return p}const f=a.phpInstance?d=>a.phpInstance.readFileAsText(d):a.getPHPFile?a.getPHPFile:d=>{const p=d.startsWith("file://")?d.replace("file://",""):d;return Bt.readFileSync(p,"utf-8")},E=s(o);return new ss(r,i,{knownScriptUrls:E,remoteRoot:a.remoteRoot,localRoot:a.localRoot,getPHPFile:f})}function jo(){return bo(js(process.argv)).usage(`
103
103
  XDebug Bridge Server CLI
104
104
 
105
105
  Usage: xdebug-bridge [options]
@@ -7311,7 +7311,7 @@ class zo {
7311
7311
  let i = `${t} -i ${o}`;
7312
7312
  return e !== void 0 && (i += ` ${e}`), this.dbgp.sendCommand(i), o;
7313
7313
  }
7314
- handleCdpMessage(t) {
7314
+ async handleCdpMessage(t) {
7315
7315
  const { id: e, method: n, params: o } = t;
7316
7316
  let i = {}, r = !0;
7317
7317
  switch (n) {
@@ -7451,7 +7451,9 @@ class zo {
7451
7451
  ([, d]) => d === s
7452
7452
  )?.[0];
7453
7453
  let E = "";
7454
- f && (E = this.readPHPFile(this.uriToRemotePath(f))), i = { scriptSource: E };
7454
+ f && (E = await this.readPHPFile(
7455
+ this.uriToRemotePath(f)
7456
+ )), i = { scriptSource: E };
7455
7457
  break;
7456
7458
  }
7457
7459
  default: