@photon-ai/cli 2.3.0-staging.42987892882.1 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/photon.js +1 -1
- package/package.json +1 -1
package/dist/photon.js
CHANGED
|
@@ -30,7 +30,7 @@ Expecting one of '${B.join("', '")}'`);if(this._lifeCycleHooks[D])this._lifeCycl
|
|
|
30
30
|
`),this.outputHelp({error:!0});let B=F||{},Z=B.exitCode||1,E=B.code||"commander.error";this._exit(Z,E,D)}_parseOptionsEnv(){this.options.forEach((D)=>{if(D.envVar&&D.envVar in d.env){let F=D.attributeName();if(this.getOptionValue(F)===void 0||["default","config","env"].includes(this.getOptionValueSource(F)))if(D.required||D.optional)this.emit(`optionEnv:${D.name()}`,d.env[D.envVar]);else this.emit(`optionEnv:${D.name()}`)}})}_parseOptionsImplied(){let D=new qB(this.options),F=(B)=>{return this.getOptionValue(B)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(B))};this.options.filter((B)=>B.implied!==void 0&&F(B.attributeName())&&D.valueFromOption(this.getOptionValue(B.attributeName()),B)).forEach((B)=>{Object.keys(B.implied).filter((Z)=>!F(Z)).forEach((Z)=>{this.setOptionValueWithSource(Z,B.implied[Z],"implied")})})}missingArgument(D){let F=`error: missing required argument '${D}'`;this.error(F,{code:"commander.missingArgument"})}optionMissingArgument(D){let F=`error: option '${D.flags}' argument missing`;this.error(F,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(D){let F=`error: required option '${D.flags}' not specified`;this.error(F,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(D,F){let B=(Y)=>{let J=Y.attributeName(),Q=this.getOptionValue(J),X=this.options.find((q)=>q.negate&&J===q.attributeName()),H=this.options.find((q)=>!q.negate&&J===q.attributeName());if(X&&(X.presetArg===void 0&&Q===!1||X.presetArg!==void 0&&Q===X.presetArg))return X;return H||Y},Z=(Y)=>{let J=B(Y),Q=J.attributeName();if(this.getOptionValueSource(Q)==="env")return`environment variable '${J.envVar}'`;return`option '${J.flags}'`},E=`error: ${Z(D)} cannot be used with ${Z(F)}`;this.error(E,{code:"commander.conflictingOption"})}unknownOption(D){if(this._allowUnknownOption)return;let F="";if(D.startsWith("--")&&this._showSuggestionAfterError){let Z=[],E=this;do{let Y=E.createHelp().visibleOptions(E).filter((J)=>J.long).map((J)=>J.long);Z=Z.concat(Y),E=E.parent}while(E&&!E._enablePositionalOptions);F=i8(D,Z)}let B=`error: unknown option '${D}'${F}`;this.error(B,{code:"commander.unknownOption"})}_excessArguments(D){if(this._allowExcessArguments)return;let F=this.registeredArguments.length,B=F===1?"":"s",E=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${F} argument${B} but got ${D.length}.`;this.error(E,{code:"commander.excessArguments"})}unknownCommand(){let D=this.args[0],F="";if(this._showSuggestionAfterError){let Z=[];this.createHelp().visibleCommands(this).forEach((E)=>{if(Z.push(E.name()),E.alias())Z.push(E.alias())}),F=i8(D,Z)}let B=`error: unknown command '${D}'${F}`;this.error(B,{code:"commander.unknownCommand"})}version(D,F,B){if(D===void 0)return this._version;this._version=D,F=F||"-V, --version",B=B||"output the version number";let Z=this.createOption(F,B);return this._versionOptionName=Z.attributeName(),this._registerOption(Z),this.on("option:"+Z.name(),()=>{this._outputConfiguration.writeOut(`${D}
|
|
31
31
|
`),this._exit(0,"commander.version",D)}),this}description(D,F){if(D===void 0&&F===void 0)return this._description;if(this._description=D,F)this._argsDescription=F;return this}summary(D){if(D===void 0)return this._summary;return this._summary=D,this}alias(D){if(D===void 0)return this._aliases[0];let F=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler)F=this.commands[this.commands.length-1];if(D===F._name)throw Error("Command alias can't be the same as its name");let B=this.parent?._findCommand(D);if(B){let Z=[B.name()].concat(B.aliases()).join("|");throw Error(`cannot add alias '${D}' to command '${this.name()}' as already have command '${Z}'`)}return F._aliases.push(D),this}aliases(D){if(D===void 0)return this._aliases;return D.forEach((F)=>this.alias(F)),this}usage(D){if(D===void 0){if(this._usage)return this._usage;let F=this.registeredArguments.map((B)=>{return QB(B)});return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?F:[]).join(" ")}return this._usage=D,this}name(D){if(D===void 0)return this._name;return this._name=D,this}helpGroup(D){if(D===void 0)return this._helpGroupHeading??"";return this._helpGroupHeading=D,this}commandsGroup(D){if(D===void 0)return this._defaultCommandGroup??"";return this._defaultCommandGroup=D,this}optionsGroup(D){if(D===void 0)return this._defaultOptionGroup??"";return this._defaultOptionGroup=D,this}_initOptionGroup(D){if(this._defaultOptionGroup&&!D.helpGroupHeading)D.helpGroup(this._defaultOptionGroup)}_initCommandGroup(D){if(this._defaultCommandGroup&&!D.helpGroup())D.helpGroup(this._defaultCommandGroup)}nameFromFilename(D){return this._name=fD.basename(D,fD.extname(D)),this}executableDir(D){if(D===void 0)return this._executableDir;return this._executableDir=D,this}helpInformation(D){let F=this.createHelp(),B=this._getOutputContext(D);F.prepareContext({error:B.error,helpWidth:B.helpWidth,outputHasColors:B.hasColors});let Z=F.formatHelp(this,F);if(B.hasColors)return Z;return this._outputConfiguration.stripColor(Z)}_getOutputContext(D){D=D||{};let F=!!D.error,B,Z,E;if(F)B=(J)=>this._outputConfiguration.writeErr(J),Z=this._outputConfiguration.getErrHasColors(),E=this._outputConfiguration.getErrHelpWidth();else B=(J)=>this._outputConfiguration.writeOut(J),Z=this._outputConfiguration.getOutHasColors(),E=this._outputConfiguration.getOutHelpWidth();return{error:F,write:(J)=>{if(!Z)J=this._outputConfiguration.stripColor(J);return B(J)},hasColors:Z,helpWidth:E}}outputHelp(D){let F;if(typeof D==="function")F=D,D=void 0;let B=this._getOutputContext(D),Z={error:B.error,write:B.write,command:this};this._getCommandAndAncestors().reverse().forEach((Y)=>Y.emit("beforeAllHelp",Z)),this.emit("beforeHelp",Z);let E=this.helpInformation({error:B.error});if(F){if(E=F(E),typeof E!=="string"&&!Buffer.isBuffer(E))throw Error("outputHelp callback must return a string or a Buffer")}if(B.write(E),this._getHelpOption()?.long)this.emit(this._getHelpOption().long);this.emit("afterHelp",Z),this._getCommandAndAncestors().forEach((Y)=>Y.emit("afterAllHelp",Z))}helpOption(D,F){if(typeof D==="boolean"){if(D){if(this._helpOption===null)this._helpOption=void 0;if(this._defaultOptionGroup)this._initOptionGroup(this._getHelpOption())}else this._helpOption=null;return this}if(this._helpOption=this.createOption(D??"-h, --help",F??"display help for command"),D||F)this._initOptionGroup(this._helpOption);return this}_getHelpOption(){if(this._helpOption===void 0)this.helpOption(void 0,void 0);return this._helpOption}addHelpOption(D){return this._helpOption=D,this._initOptionGroup(D),this}help(D){this.outputHelp(D);let F=Number(d.exitCode??0);if(F===0&&D&&typeof D!=="function"&&D.error)F=1;this._exit(F,"commander.help","(outputHelp)")}addHelpText(D,F){let B=["beforeAll","before","after","afterAll"];if(!B.includes(D))throw Error(`Unexpected value for position to addHelpText.
|
|
32
32
|
Expecting one of '${B.join("', '")}'`);let Z=`${D}Help`;return this.on(Z,(E)=>{let Y;if(typeof F==="function")Y=F({error:E.error,command:E.command});else Y=F;if(Y)E.write(`${Y}
|
|
33
|
-
`)}),this}_outputHelpIfRequested(D){let F=this._getHelpOption();if(F&&D.find((Z)=>F.is(Z)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function n8(D){return D.map((F)=>{if(!F.startsWith("--inspect"))return F;let B,Z="127.0.0.1",E="9229",Y;if((Y=F.match(/^(--inspect(-brk)?)$/))!==null)B=Y[1];else if((Y=F.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null)if(B=Y[1],/^\d+$/.test(Y[3]))E=Y[3];else Z=Y[3];else if((Y=F.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null)B=Y[1],Z=Y[3],E=Y[4];if(B&&E!=="0")return`${B}=${Z}:${parseInt(E)+1}`;return F})}function RF(){if(d.env.NO_COLOR||d.env.FORCE_COLOR==="0"||d.env.FORCE_COLOR==="false")return!1;if(d.env.FORCE_COLOR||d.env.CLICOLOR_FORCE!==void 0)return!0;return}KB.Command=SF;KB.useColor=RF});var kF=O(($B)=>{var{Argument:s8}=e0(),{Command:_F}=r8(),{CommanderError:CB,InvalidArgumentError:o8}=N0(),{Help:WB}=MF(),{Option:t8}=TF();$B.program=new _F;$B.createCommand=(D)=>new _F(D);$B.createOption=(D,F)=>new t8(D,F);$B.createArgument=(D,F)=>new s8(D,F);$B.Command=_F;$B.Option=t8;$B.Argument=s8;$B.Help=WB;$B.CommanderError=CB;$B.InvalidArgumentError=o8;$B.InvalidOptionArgumentError=o8});var D6=O((zD,e8)=>{var ND=kF();zD=e8.exports={};zD.program=new ND.Command;zD.Argument=ND.Argument;zD.Command=ND.Command;zD.CommanderError=ND.CommanderError;zD.Help=ND.Help;zD.InvalidArgumentError=ND.InvalidArgumentError;zD.InvalidOptionArgumentError=ND.InvalidArgumentError;zD.Option=ND.Option;zD.createCommand=(D)=>new ND.Command(D);zD.createOption=(D,F)=>new ND.Option(D,F);zD.createArgument=(D,F)=>new ND.Argument(D,F)});var lF=O((fH,_6)=>{var cF={to(D,F){if(!F)return`\x1B[${D+1}G`;return`\x1B[${F+1};${D+1}H`},move(D,F){let B="";if(D<0)B+=`\x1B[${-D}D`;else if(D>0)B+=`\x1B[${D}C`;if(F<0)B+=`\x1B[${-F}A`;else if(F>0)B+=`\x1B[${F}B`;return B},up:(D=1)=>`\x1B[${D}A`,down:(D=1)=>`\x1B[${D}B`,forward:(D=1)=>`\x1B[${D}C`,backward:(D=1)=>`\x1B[${D}D`,nextLine:(D=1)=>"\x1B[E".repeat(D),prevLine:(D=1)=>"\x1B[F".repeat(D),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},JZ={up:(D=1)=>"\x1B[S".repeat(D),down:(D=1)=>"\x1B[T".repeat(D)},QZ={screen:"\x1B[2J",up:(D=1)=>"\x1B[1J".repeat(D),down:(D=1)=>"\x1B[J".repeat(D),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines(D){let F="";for(let B=0;B<D;B++)F+=this.line+(B<D-1?cF.up():"");if(D)F+=cF.left;return F}};_6.exports={cursor:cF,scroll:JZ,erase:QZ,beep:"\x07"}});class K0 extends Error{envName;constructor(D){super(`Not authenticated for backend "${D}".`);this.envName=D;this.name="NotAuthenticatedError"}}class D0 extends Error{constructor(){super("Authorization was denied.");this.name="DeviceFlowDenied"}}class lD extends Error{constructor(){super("Device code expired.");this.name="DeviceFlowExpired"}}class f extends Error{envName;constructor(D){super(`Session expired for "${D}".`);this.envName=D;this.name="SessionExpiredError"}}var b3=TD(y3(),1),t=TD(qF(),1),G={bold:t.default.bold,dim:t.default.dim,italic:t.default.italic,underline:t.default.underline,cyan:t.default.cyan,green:t.default.green,yellow:t.default.yellow,red:t.default.red,gray:t.default.gray,blue:t.default.blue,magenta:t.default.magenta,success:(D)=>t.default.green(`✓ ${D}`),error:(D)=>t.default.red(`✗ ${D}`),info:(D)=>t.default.cyan(`◆ ${D}`),warn:(D)=>t.default.yellow(`! ${D}`),hint:(D)=>t.default.dim(D)};function $D(D,F){let B=new b3.default({head:D.map((Z)=>G.bold(Z)),style:{head:[],border:["gray"]}});for(let Z of F)B.push(Z);console.log(B.toString())}function w(D){console.log(JSON.stringify(D,null,2))}function k(D){if(D instanceof Error)return D.message;if(typeof D==="string")return D;if(typeof D==="object"&&D!==null){let F=D,B=F.status?` [${F.status}]`:"";if(typeof F.value==="string")return F.value+B;if(typeof F.value==="object"&&F.value!==null){let Z=F.value;if(Z.error)return String(Z.error)+B;if(Z.message)return String(Z.message)+B}return JSON.stringify(F.value??D)+B}return String(D)}function $(D,F={}){if(console.error(G.error(D)),F.hint)console.error(G.hint(` Hint: ${F.hint}`));if(F.context)console.error(G.dim(` ${F.context}`));process.exit(F.code??1)}var w8=TD(T8(),1);import w7 from"update-notifier";var f8=TD(CF(),1),t0=TD(_8(),1);import{spawn as O8}from"node:child_process";import{createHash as M7}from"node:crypto";import OD from"node:fs";import NF from"node:path";import T7 from"update-notifier";var DD={name:"@photon-ai/cli",version:"2.3.0-staging.42987892882.1",description:"Photon CLI — typed terminal UI for the Photon Dashboard. Binary: `photon` (alias `pho`).",keywords:["photon","cli","dashboard","spectrum","messaging","imessage","developer-tools"],author:"Photon",license:"MIT",homepage:"https://github.com/photon-hq/cli#readme",repository:{type:"git",url:"git+https://github.com/photon-hq/cli.git"},bugs:{url:"https://github.com/photon-hq/cli/issues"},type:"module",bin:{photon:"./dist/photon.js",pho:"./dist/photon.js"},files:["dist","README.md"],publishConfig:{access:"public"},engines:{bun:">=1.3.0",node:">=18.0.0"},scripts:{start:"bun run src/index.ts",dev:"bun run --watch src/index.ts",build:"bun build ./src/index.ts --outfile dist/photon.js --target node --minify --external update-notifier && chmod +x dist/photon.js",compile:"bun build ./src/index.ts --compile --outfile dist/photon",typecheck:"tsc --noEmit",test:"bun test",check:"bun run typecheck && bun test && bun run build",manifest:"bun run scripts/generate-route-manifest.ts",prepublishOnly:"bun run typecheck && bun run build","docs:reference":"bun run scripts/export-docs.ts"},devDependencies:{"@photon-ai/dashboard-api":"1.6.12","@types/bun":"latest","@types/node":"^25.6.2","@types/semver":"^7.7.1","@types/update-notifier":"^6.0.8",elysia:"1.4.28",typescript:"^5"},dependencies:{"@clack/prompts":"^1.2.0","@commander-js/extra-typings":"^14.0.0","@elysiajs/eden":"1.4.9","better-auth":"1.4.18","cli-table3":"^0.6.5",commander:"^14.0.3",open:"^11.0.0",picocolors:"^1.1.1",semver:"^7.8.5","update-notifier":"^7.3.1"}};var uF=["npm","pnpm","yarn","bun"],iD="legacy";async function I7(){let D=process.env.NO_UPDATE_NOTIFIER;process.env.NO_UPDATE_NOTIFIER="1";let F;try{({latest:F}=await T7({pkg:{name:DD.name,version:DD.version},distTag:iD}).fetchInfo())}catch(B){if(B instanceof Error&&B.name==="VersionNotFoundError")throw Error(`The Photon update registry has no ${iD} release of ${DD.name}.`,{cause:B});throw Error("Could not reach the Photon update registry.",{cause:B})}finally{if(D===void 0)delete process.env.NO_UPDATE_NOTIFIER;else process.env.NO_UPDATE_NOTIFIER=D}if(!t0.default(F))throw Error("The Photon update registry returned an invalid version.");return F}function AF(D){try{return OD.realpathSync.native(D)}catch{return NF.resolve(D)}}function L7(D=process.argv[1]??"",F=process.execPath,B=process.env){if(!D)return{kind:"unknown",entryPath:D};let Z=NF.resolve(D),E=AF(D),Y=AF(F),J=D.replaceAll("\\","/");if(E===Y||J.startsWith("/$bunfs/root/"))return{kind:"standalone",entryPath:NF.resolve(F)};let Q=E.replaceAll("\\","/").toLowerCase();if(Q.includes("/.npm/_npx/")||Q.includes("/.bun/install/cache/@photon-ai/cli@")||Q.includes("/node_modules/.cache/bunx-")||Q.includes("/tmp/dlx-")&&Q.includes("/node_modules/"))return{kind:"ephemeral",entryPath:Z};if(Q.includes("/.bun/install/global/"))return{kind:"bun",entryPath:Z};if(Q.includes("/pnpm/global/")||Q.includes("/.pnpm/global/"))return{kind:"pnpm",entryPath:Z};if(Q.includes("/.config/yarn/global/")||Q.includes("/yarn/global/"))return{kind:"yarn",entryPath:Z};if(Q.includes("/lib/node_modules/@photon-ai/cli/")||Q.includes("/npm/node_modules/@photon-ai/cli/"))return{kind:"npm",entryPath:Z};let X=/^yarn\/(\d+)(?:\.|\s|$)/i.exec(B.npm_config_user_agent??"")?.[1];if(X&&Number(X)>=2){let H=(B.INIT_CWD??"").replaceAll("\\","/"),q=/\/dlx-[^/]+(?:\/|$)/i;if(q.test(J)&&(J.includes("/.yarn/")||q.test(H)))return{kind:"yarn-dlx",entryPath:Z};return{kind:"yarn-berry",entryPath:Z}}if(!Q.includes("/node_modules/@photon-ai/cli/"))return{kind:"development",entryPath:Z};return{kind:"unknown",entryPath:Z}}function P8(D){if(uF.includes(D))return D;throw Error(`Unknown installer "${D}". Expected one of: ${uF.join(", ")}.`)}function R7(D,F,B=!1){let Z=`${DD.name}@${F}`,E=B?["--force"]:[];if(D==="npm")return{command:D,args:["install","--global",...E,Z]};if(D==="yarn")return{command:D,args:["global","add",...E,Z]};return{command:D,args:["add","--global",...E,Z]}}async function S7(D,F){await new Promise((B,Z)=>{let E=O8(D.command,D.args,{shell:!1,stdio:F?["ignore","ignore","pipe"]:"inherit"}),Y="";E.stderr?.on("data",(J)=>{Y=(Y+String(J)).slice(-8192)}),E.on("error",(J)=>{Z(Error(`Could not start ${D.command}. Make sure it is installed and on PATH.`,{cause:J}))}),E.on("close",(J,Q)=>{if(J===0){B();return}let X=Y.trim(),H=Q?`signal ${Q}`:`exit code ${J??"unknown"}`;Z(Error(`The ${D.command} updater failed with ${H}.${X?` ${X}`:""}`))})})}async function _7(D,F){let B=await new Promise((Z,E)=>{let Y=O8(process.execPath,[D,"--version"],{shell:!1,stdio:["ignore","pipe","pipe"],env:{...process.env,PHOTON_NO_UPDATE_NOTIFIER:"1"}}),J="",Q="";Y.stdout.on("data",(X)=>{J=(J+String(X)).slice(-8192)}),Y.stderr.on("data",(X)=>{Q=(Q+String(X)).slice(-8192)}),Y.on("error",(X)=>{E(Error("Could not launch the updated Photon executable.",{cause:X}))}),Y.on("close",(X,H)=>{if(X===0){Z(J.trim());return}let q=H?`signal ${H}`:`exit code ${X??"unknown"}`;E(Error(`The updated Photon executable failed with ${q}.${Q.trim()?` ${Q.trim()}`:""}`))})});if(B!==F)throw Error(`The installer completed, but ${D} reports ${B||"no version"} instead of ${F}.`)}function k7(){let D=process.platform==="darwin"?"darwin":process.platform;if(D!=="darwin"&&D!=="linux")throw Error(`Standalone updates are not supported on ${process.platform}.`);if(process.arch!=="arm64"&&process.arch!=="x64")throw Error(`Standalone updates are not supported on ${process.arch}.`);return`photon-${D}-${process.arch}`}async function O7(D,F,B={}){let Z=k7(),Y=`${(B.releaseBase??"https://github.com/photon-hq/cli/releases/download").replace(/\/$/,"")}/v${F}/${Z}`,J={signal:AbortSignal.timeout(60000)},Q,X;try{[Q,X]=await Promise.all([fetch(Y,J),fetch(`${Y}.sha256`,J)])}catch(z){throw Error("Could not reach the Photon release downloads.",{cause:z})}if(!Q.ok||!X.ok)throw Error(`Could not download Photon ${F} (${Q.status}/${X.status}).`);let H;try{H=await X.text()}catch(z){throw Error("Could not read the Photon release checksum.",{cause:z})}let q=H.trim().split(/\s+/,1)[0]?.toLowerCase();if(!q||!/^[a-f0-9]{64}$/.test(q))throw Error("The standalone checksum file is invalid.");let K=AF(D),C=`${K}.update-${process.pid}-${Date.now()}`,W;try{if(!Q.body)throw Error("The standalone download returned an empty body.");let z;try{let U=OD.statSync(K).mode&511;W=OD.openSync(C,"wx",U||493);let u=M7("sha256"),I=Q.body.getReader();while(!0){let{done:A,value:N}=await I.read();if(A)break;u.update(N);let V=0;while(V<N.byteLength){let L=OD.writeSync(W,N,V,N.byteLength-V);if(L===0)throw Error("Writing the update made no progress.");V+=L}}OD.fsyncSync(W),OD.closeSync(W),W=void 0,z=u.digest("hex")}catch(U){throw Error(`Could not stage the Photon update beside ${K}. Check the download and file permissions.`,{cause:U})}if(z!==q)throw Error("The downloaded Photon binary failed checksum verification.");try{OD.renameSync(C,K)}catch(U){throw Error(`Could not replace ${K}. Check that the file is writable.`,{cause:U})}}finally{if(W!==void 0)try{OD.closeSync(W)}catch{}try{OD.rmSync(C,{force:!0})}catch{}}}function y8(D){return D.slice(2).find((B)=>!B.startsWith("-"))==="update"}function k8(D){if(D.kind==="npm"||D.kind==="pnpm"||D.kind==="yarn"||D.kind==="bun"||D.kind==="standalone")return D.kind;if(D.kind==="ephemeral")throw Error(`A one-off Photon invocation cannot update itself. Run your package runner with ${DD.name}@${iD} instead.`);if(D.kind==="development")throw Error("A development checkout cannot update itself. Update the checkout with Git instead.");if(D.kind==="yarn-dlx")throw Error(`A Yarn dlx invocation cannot update itself. Run \`yarn dlx --package ${DD.name}@${iD} photon\` instead.`);if(D.kind==="yarn-berry")throw Error(`Yarn 2+ does not provide global installs. Run \`yarn up ${DD.name}@${iD}\` from the project that owns this dependency.`);throw Error(`Cannot detect this Photon installation automatically. Re-run with --installer ${uF.join("|")}.`)}function f7(D,F){if(!F)return k8(D);if(D.kind==="unknown")return F;if(D.kind===F)return F;if(D.kind==="development"||D.kind==="ephemeral")return k8(D);throw Error(`This Photon invocation was detected as ${D.kind}; refusing to update a different ${F} installation.`)}async function x8(D={},F={}){let B=F.currentVersion??DD.version,Z=await(F.latestVersion??I7)();if(!t0.default(B)||!t0.default(Z))throw Error("Cannot compare invalid Photon release versions.");let E=f8.default(Z,B);if(!E&&!D.force)return{status:"up-to-date",currentVersion:B,latestVersion:Z,installer:null};if(D.check)return{status:E?"update-available":"up-to-date",currentVersion:B,latestVersion:Z,installer:null};let Y=F.installation??L7(),J=f7(Y,D.installer),Q=E?Z:B;if(J==="standalone")await(F.replaceStandalone??O7)(Y.entryPath,Q);else await(F.runInstaller??S7)(R7(J,Q,D.force),D.quiet??!1),await(F.verifyInstalled??_7)(Y.entryPath,Q);return{status:E?"updated":"reinstalled",currentVersion:B,latestVersion:Z,installer:J}}var P7=()=>Boolean(process.stdout.isTTY),y7=()=>Boolean(process.stdin.isTTY),x7=()=>Boolean(process.env.CI||process.env.GITHUB_ACTIONS||process.env.GITLAB_CI||process.env.CIRCLECI||process.env.BUILDKITE||process.env.TF_BUILD);var GD=()=>P7()&&y7()&&!x7();var b7=`Update available ${G.dim("{currentVersion}")} → ${G.green("{latestVersion}")}
|
|
33
|
+
`)}),this}_outputHelpIfRequested(D){let F=this._getHelpOption();if(F&&D.find((Z)=>F.is(Z)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function n8(D){return D.map((F)=>{if(!F.startsWith("--inspect"))return F;let B,Z="127.0.0.1",E="9229",Y;if((Y=F.match(/^(--inspect(-brk)?)$/))!==null)B=Y[1];else if((Y=F.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null)if(B=Y[1],/^\d+$/.test(Y[3]))E=Y[3];else Z=Y[3];else if((Y=F.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null)B=Y[1],Z=Y[3],E=Y[4];if(B&&E!=="0")return`${B}=${Z}:${parseInt(E)+1}`;return F})}function RF(){if(d.env.NO_COLOR||d.env.FORCE_COLOR==="0"||d.env.FORCE_COLOR==="false")return!1;if(d.env.FORCE_COLOR||d.env.CLICOLOR_FORCE!==void 0)return!0;return}KB.Command=SF;KB.useColor=RF});var kF=O(($B)=>{var{Argument:s8}=e0(),{Command:_F}=r8(),{CommanderError:CB,InvalidArgumentError:o8}=N0(),{Help:WB}=MF(),{Option:t8}=TF();$B.program=new _F;$B.createCommand=(D)=>new _F(D);$B.createOption=(D,F)=>new t8(D,F);$B.createArgument=(D,F)=>new s8(D,F);$B.Command=_F;$B.Option=t8;$B.Argument=s8;$B.Help=WB;$B.CommanderError=CB;$B.InvalidArgumentError=o8;$B.InvalidOptionArgumentError=o8});var D6=O((zD,e8)=>{var ND=kF();zD=e8.exports={};zD.program=new ND.Command;zD.Argument=ND.Argument;zD.Command=ND.Command;zD.CommanderError=ND.CommanderError;zD.Help=ND.Help;zD.InvalidArgumentError=ND.InvalidArgumentError;zD.InvalidOptionArgumentError=ND.InvalidArgumentError;zD.Option=ND.Option;zD.createCommand=(D)=>new ND.Command(D);zD.createOption=(D,F)=>new ND.Option(D,F);zD.createArgument=(D,F)=>new ND.Argument(D,F)});var lF=O((fH,_6)=>{var cF={to(D,F){if(!F)return`\x1B[${D+1}G`;return`\x1B[${F+1};${D+1}H`},move(D,F){let B="";if(D<0)B+=`\x1B[${-D}D`;else if(D>0)B+=`\x1B[${D}C`;if(F<0)B+=`\x1B[${-F}A`;else if(F>0)B+=`\x1B[${F}B`;return B},up:(D=1)=>`\x1B[${D}A`,down:(D=1)=>`\x1B[${D}B`,forward:(D=1)=>`\x1B[${D}C`,backward:(D=1)=>`\x1B[${D}D`,nextLine:(D=1)=>"\x1B[E".repeat(D),prevLine:(D=1)=>"\x1B[F".repeat(D),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},JZ={up:(D=1)=>"\x1B[S".repeat(D),down:(D=1)=>"\x1B[T".repeat(D)},QZ={screen:"\x1B[2J",up:(D=1)=>"\x1B[1J".repeat(D),down:(D=1)=>"\x1B[J".repeat(D),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines(D){let F="";for(let B=0;B<D;B++)F+=this.line+(B<D-1?cF.up():"");if(D)F+=cF.left;return F}};_6.exports={cursor:cF,scroll:JZ,erase:QZ,beep:"\x07"}});class K0 extends Error{envName;constructor(D){super(`Not authenticated for backend "${D}".`);this.envName=D;this.name="NotAuthenticatedError"}}class D0 extends Error{constructor(){super("Authorization was denied.");this.name="DeviceFlowDenied"}}class lD extends Error{constructor(){super("Device code expired.");this.name="DeviceFlowExpired"}}class f extends Error{envName;constructor(D){super(`Session expired for "${D}".`);this.envName=D;this.name="SessionExpiredError"}}var b3=TD(y3(),1),t=TD(qF(),1),G={bold:t.default.bold,dim:t.default.dim,italic:t.default.italic,underline:t.default.underline,cyan:t.default.cyan,green:t.default.green,yellow:t.default.yellow,red:t.default.red,gray:t.default.gray,blue:t.default.blue,magenta:t.default.magenta,success:(D)=>t.default.green(`✓ ${D}`),error:(D)=>t.default.red(`✗ ${D}`),info:(D)=>t.default.cyan(`◆ ${D}`),warn:(D)=>t.default.yellow(`! ${D}`),hint:(D)=>t.default.dim(D)};function $D(D,F){let B=new b3.default({head:D.map((Z)=>G.bold(Z)),style:{head:[],border:["gray"]}});for(let Z of F)B.push(Z);console.log(B.toString())}function w(D){console.log(JSON.stringify(D,null,2))}function k(D){if(D instanceof Error)return D.message;if(typeof D==="string")return D;if(typeof D==="object"&&D!==null){let F=D,B=F.status?` [${F.status}]`:"";if(typeof F.value==="string")return F.value+B;if(typeof F.value==="object"&&F.value!==null){let Z=F.value;if(Z.error)return String(Z.error)+B;if(Z.message)return String(Z.message)+B}return JSON.stringify(F.value??D)+B}return String(D)}function $(D,F={}){if(console.error(G.error(D)),F.hint)console.error(G.hint(` Hint: ${F.hint}`));if(F.context)console.error(G.dim(` ${F.context}`));process.exit(F.code??1)}var w8=TD(T8(),1);import w7 from"update-notifier";var f8=TD(CF(),1),t0=TD(_8(),1);import{spawn as O8}from"node:child_process";import{createHash as M7}from"node:crypto";import OD from"node:fs";import NF from"node:path";import T7 from"update-notifier";var DD={name:"@photon-ai/cli",version:"2.3.0",description:"Photon CLI — typed terminal UI for the Photon Dashboard. Binary: `photon` (alias `pho`).",keywords:["photon","cli","dashboard","spectrum","messaging","imessage","developer-tools"],author:"Photon",license:"MIT",homepage:"https://github.com/photon-hq/cli#readme",repository:{type:"git",url:"git+https://github.com/photon-hq/cli.git"},bugs:{url:"https://github.com/photon-hq/cli/issues"},type:"module",bin:{photon:"./dist/photon.js",pho:"./dist/photon.js"},files:["dist","README.md"],publishConfig:{access:"public"},engines:{bun:">=1.3.0",node:">=18.0.0"},scripts:{start:"bun run src/index.ts",dev:"bun run --watch src/index.ts",build:"bun build ./src/index.ts --outfile dist/photon.js --target node --minify --external update-notifier && chmod +x dist/photon.js",compile:"bun build ./src/index.ts --compile --outfile dist/photon",typecheck:"tsc --noEmit",test:"bun test",check:"bun run typecheck && bun test && bun run build",manifest:"bun run scripts/generate-route-manifest.ts",prepublishOnly:"bun run typecheck && bun run build","docs:reference":"bun run scripts/export-docs.ts"},devDependencies:{"@photon-ai/dashboard-api":"1.6.12","@types/bun":"latest","@types/node":"^25.6.2","@types/semver":"^7.7.1","@types/update-notifier":"^6.0.8",elysia:"1.4.28",typescript:"^5"},dependencies:{"@clack/prompts":"^1.2.0","@commander-js/extra-typings":"^14.0.0","@elysiajs/eden":"1.4.9","better-auth":"1.4.18","cli-table3":"^0.6.5",commander:"^14.0.3",open:"^11.0.0",picocolors:"^1.1.1",semver:"^7.8.5","update-notifier":"^7.3.1"}};var uF=["npm","pnpm","yarn","bun"],iD="legacy";async function I7(){let D=process.env.NO_UPDATE_NOTIFIER;process.env.NO_UPDATE_NOTIFIER="1";let F;try{({latest:F}=await T7({pkg:{name:DD.name,version:DD.version},distTag:iD}).fetchInfo())}catch(B){if(B instanceof Error&&B.name==="VersionNotFoundError")throw Error(`The Photon update registry has no ${iD} release of ${DD.name}.`,{cause:B});throw Error("Could not reach the Photon update registry.",{cause:B})}finally{if(D===void 0)delete process.env.NO_UPDATE_NOTIFIER;else process.env.NO_UPDATE_NOTIFIER=D}if(!t0.default(F))throw Error("The Photon update registry returned an invalid version.");return F}function AF(D){try{return OD.realpathSync.native(D)}catch{return NF.resolve(D)}}function L7(D=process.argv[1]??"",F=process.execPath,B=process.env){if(!D)return{kind:"unknown",entryPath:D};let Z=NF.resolve(D),E=AF(D),Y=AF(F),J=D.replaceAll("\\","/");if(E===Y||J.startsWith("/$bunfs/root/"))return{kind:"standalone",entryPath:NF.resolve(F)};let Q=E.replaceAll("\\","/").toLowerCase();if(Q.includes("/.npm/_npx/")||Q.includes("/.bun/install/cache/@photon-ai/cli@")||Q.includes("/node_modules/.cache/bunx-")||Q.includes("/tmp/dlx-")&&Q.includes("/node_modules/"))return{kind:"ephemeral",entryPath:Z};if(Q.includes("/.bun/install/global/"))return{kind:"bun",entryPath:Z};if(Q.includes("/pnpm/global/")||Q.includes("/.pnpm/global/"))return{kind:"pnpm",entryPath:Z};if(Q.includes("/.config/yarn/global/")||Q.includes("/yarn/global/"))return{kind:"yarn",entryPath:Z};if(Q.includes("/lib/node_modules/@photon-ai/cli/")||Q.includes("/npm/node_modules/@photon-ai/cli/"))return{kind:"npm",entryPath:Z};let X=/^yarn\/(\d+)(?:\.|\s|$)/i.exec(B.npm_config_user_agent??"")?.[1];if(X&&Number(X)>=2){let H=(B.INIT_CWD??"").replaceAll("\\","/"),q=/\/dlx-[^/]+(?:\/|$)/i;if(q.test(J)&&(J.includes("/.yarn/")||q.test(H)))return{kind:"yarn-dlx",entryPath:Z};return{kind:"yarn-berry",entryPath:Z}}if(!Q.includes("/node_modules/@photon-ai/cli/"))return{kind:"development",entryPath:Z};return{kind:"unknown",entryPath:Z}}function P8(D){if(uF.includes(D))return D;throw Error(`Unknown installer "${D}". Expected one of: ${uF.join(", ")}.`)}function R7(D,F,B=!1){let Z=`${DD.name}@${F}`,E=B?["--force"]:[];if(D==="npm")return{command:D,args:["install","--global",...E,Z]};if(D==="yarn")return{command:D,args:["global","add",...E,Z]};return{command:D,args:["add","--global",...E,Z]}}async function S7(D,F){await new Promise((B,Z)=>{let E=O8(D.command,D.args,{shell:!1,stdio:F?["ignore","ignore","pipe"]:"inherit"}),Y="";E.stderr?.on("data",(J)=>{Y=(Y+String(J)).slice(-8192)}),E.on("error",(J)=>{Z(Error(`Could not start ${D.command}. Make sure it is installed and on PATH.`,{cause:J}))}),E.on("close",(J,Q)=>{if(J===0){B();return}let X=Y.trim(),H=Q?`signal ${Q}`:`exit code ${J??"unknown"}`;Z(Error(`The ${D.command} updater failed with ${H}.${X?` ${X}`:""}`))})})}async function _7(D,F){let B=await new Promise((Z,E)=>{let Y=O8(process.execPath,[D,"--version"],{shell:!1,stdio:["ignore","pipe","pipe"],env:{...process.env,PHOTON_NO_UPDATE_NOTIFIER:"1"}}),J="",Q="";Y.stdout.on("data",(X)=>{J=(J+String(X)).slice(-8192)}),Y.stderr.on("data",(X)=>{Q=(Q+String(X)).slice(-8192)}),Y.on("error",(X)=>{E(Error("Could not launch the updated Photon executable.",{cause:X}))}),Y.on("close",(X,H)=>{if(X===0){Z(J.trim());return}let q=H?`signal ${H}`:`exit code ${X??"unknown"}`;E(Error(`The updated Photon executable failed with ${q}.${Q.trim()?` ${Q.trim()}`:""}`))})});if(B!==F)throw Error(`The installer completed, but ${D} reports ${B||"no version"} instead of ${F}.`)}function k7(){let D=process.platform==="darwin"?"darwin":process.platform;if(D!=="darwin"&&D!=="linux")throw Error(`Standalone updates are not supported on ${process.platform}.`);if(process.arch!=="arm64"&&process.arch!=="x64")throw Error(`Standalone updates are not supported on ${process.arch}.`);return`photon-${D}-${process.arch}`}async function O7(D,F,B={}){let Z=k7(),Y=`${(B.releaseBase??"https://github.com/photon-hq/cli/releases/download").replace(/\/$/,"")}/v${F}/${Z}`,J={signal:AbortSignal.timeout(60000)},Q,X;try{[Q,X]=await Promise.all([fetch(Y,J),fetch(`${Y}.sha256`,J)])}catch(z){throw Error("Could not reach the Photon release downloads.",{cause:z})}if(!Q.ok||!X.ok)throw Error(`Could not download Photon ${F} (${Q.status}/${X.status}).`);let H;try{H=await X.text()}catch(z){throw Error("Could not read the Photon release checksum.",{cause:z})}let q=H.trim().split(/\s+/,1)[0]?.toLowerCase();if(!q||!/^[a-f0-9]{64}$/.test(q))throw Error("The standalone checksum file is invalid.");let K=AF(D),C=`${K}.update-${process.pid}-${Date.now()}`,W;try{if(!Q.body)throw Error("The standalone download returned an empty body.");let z;try{let U=OD.statSync(K).mode&511;W=OD.openSync(C,"wx",U||493);let u=M7("sha256"),I=Q.body.getReader();while(!0){let{done:A,value:N}=await I.read();if(A)break;u.update(N);let V=0;while(V<N.byteLength){let L=OD.writeSync(W,N,V,N.byteLength-V);if(L===0)throw Error("Writing the update made no progress.");V+=L}}OD.fsyncSync(W),OD.closeSync(W),W=void 0,z=u.digest("hex")}catch(U){throw Error(`Could not stage the Photon update beside ${K}. Check the download and file permissions.`,{cause:U})}if(z!==q)throw Error("The downloaded Photon binary failed checksum verification.");try{OD.renameSync(C,K)}catch(U){throw Error(`Could not replace ${K}. Check that the file is writable.`,{cause:U})}}finally{if(W!==void 0)try{OD.closeSync(W)}catch{}try{OD.rmSync(C,{force:!0})}catch{}}}function y8(D){return D.slice(2).find((B)=>!B.startsWith("-"))==="update"}function k8(D){if(D.kind==="npm"||D.kind==="pnpm"||D.kind==="yarn"||D.kind==="bun"||D.kind==="standalone")return D.kind;if(D.kind==="ephemeral")throw Error(`A one-off Photon invocation cannot update itself. Run your package runner with ${DD.name}@${iD} instead.`);if(D.kind==="development")throw Error("A development checkout cannot update itself. Update the checkout with Git instead.");if(D.kind==="yarn-dlx")throw Error(`A Yarn dlx invocation cannot update itself. Run \`yarn dlx --package ${DD.name}@${iD} photon\` instead.`);if(D.kind==="yarn-berry")throw Error(`Yarn 2+ does not provide global installs. Run \`yarn up ${DD.name}@${iD}\` from the project that owns this dependency.`);throw Error(`Cannot detect this Photon installation automatically. Re-run with --installer ${uF.join("|")}.`)}function f7(D,F){if(!F)return k8(D);if(D.kind==="unknown")return F;if(D.kind===F)return F;if(D.kind==="development"||D.kind==="ephemeral")return k8(D);throw Error(`This Photon invocation was detected as ${D.kind}; refusing to update a different ${F} installation.`)}async function x8(D={},F={}){let B=F.currentVersion??DD.version,Z=await(F.latestVersion??I7)();if(!t0.default(B)||!t0.default(Z))throw Error("Cannot compare invalid Photon release versions.");let E=f8.default(Z,B);if(!E&&!D.force)return{status:"up-to-date",currentVersion:B,latestVersion:Z,installer:null};if(D.check)return{status:E?"update-available":"up-to-date",currentVersion:B,latestVersion:Z,installer:null};let Y=F.installation??L7(),J=f7(Y,D.installer),Q=E?Z:B;if(J==="standalone")await(F.replaceStandalone??O7)(Y.entryPath,Q);else await(F.runInstaller??S7)(R7(J,Q,D.force),D.quiet??!1),await(F.verifyInstalled??_7)(Y.entryPath,Q);return{status:E?"updated":"reinstalled",currentVersion:B,latestVersion:Z,installer:J}}var P7=()=>Boolean(process.stdout.isTTY),y7=()=>Boolean(process.stdin.isTTY),x7=()=>Boolean(process.env.CI||process.env.GITHUB_ACTIONS||process.env.GITLAB_CI||process.env.CIRCLECI||process.env.BUILDKITE||process.env.TF_BUILD);var GD=()=>P7()&&y7()&&!x7();var b7=`Update available ${G.dim("{currentVersion}")} → ${G.green("{latestVersion}")}
|
|
34
34
|
Run ${G.cyan("photon update")} to update`;function b8(D={}){if(!(D.interactive??GD)())return;if(process.env.PHOTON_NO_UPDATE_NOTIFIER==="1")return;let Z=(D.createNotifier??w7)({pkg:{name:DD.name,version:DD.version},distTag:iD,updateCheckInterval:86400000}),{update:E}=Z;if(E&&(typeof E.latest!=="string"||!w8.default(E.latest,`^${DD.version}`)))return;Z.notify({defer:!0,isGlobal:!0,message:b7})}var F6=TD(D6(),1),{program:LQ,createCommand:RQ,createArgument:SQ,createOption:_Q,CommanderError:kQ,InvalidArgumentError:OQ,InvalidOptionArgumentError:fQ,Command:B6,Argument:PQ,Option:yQ,Help:xQ}=F6.default;import{existsSync as Z6,renameSync as SB}from"node:fs";import E6 from"node:os";import Z0 from"node:path";var Y6="https://app.photon.codes";function _B(D){return D??process.env.PHOTON_API_HOST??Y6}function OF(D){try{return new URL(D).origin}catch{throw Error(`Invalid API host URL: "${D}". Must include scheme — e.g. https://your.host.tld.`)}}function J6(D){let F=OF(_B(D));return{name:kB(F),url:F}}function kB(D){let F;try{F=new URL(D)}catch{throw Error(`Invalid API host URL: "${D}". Must include scheme — e.g. https://your.host.tld.`)}if(F.origin===Y6)return"production";let B=F.hostname.toLowerCase().replace(/[[\]]/g,"").replace(/[.:%]/g,"_"),Z=F.port?`_${F.port}`:"",E=`${B}${Z}`;if(E.length>64)throw Error(`API host "${D}" produces a key longer than 64 characters (got ${E.length}). Use a shorter hostname or alias the host in your local hosts file / DNS.`);return E}var OB=/^[a-z0-9_][a-z0-9_-]{0,63}$/;function fB(D){if(!OB.test(D))throw Error(`Invalid environment key "${D}" — must be 1-64 chars, `+"start with a-z, 0-9, or '_', and only contain a-z, 0-9, '-', '_'.")}function F2(){let D=process.env.PHOTON_CONFIG_DIR??process.env.DASHBOARD_CONFIG_DIR;if(D)return D;let F=process.env.XDG_CONFIG_HOME,B=F?Z0.join(F,"photon"):Z0.join(E6.homedir(),".config","photon"),Z=F?Z0.join(F,"photon-dashboard"):Z0.join(E6.homedir(),".config","photon-dashboard"),E=B;if(!Z6(B)&&Z6(Z))try{SB(Z,B)}catch{E=Z}return E}var fF=()=>Z0.join(F2(),"credentials"),B2=(D)=>{return fB(D),Z0.join(fF(),`${D}.json`)};async function XD(D){return J6(D)}import{chmod as PB,mkdir as yB,readdir as xB,readFile as wB,unlink as bB,writeFile as vB}from"node:fs/promises";import{dirname as hB}from"node:path";async function E0(D){try{let F=await wB(B2(D),"utf-8");return JSON.parse(F)}catch{return null}}async function Q6(D){let F=B2(D.envName);await yB(hB(F),{recursive:!0}),await vB(F,JSON.stringify(D,null,2)+`
|
|
35
35
|
`,"utf-8"),await PB(F,384)}async function H6(D){let F=B2(D);try{await bB(F)}catch(B){if(B.code!=="ENOENT")throw B}}async function Z2(){try{return(await xB(fF())).filter((F)=>F.endsWith(".json")).map((F)=>F.slice(0,-5)).sort()}catch(D){if(D.code==="ENOENT")return[];throw D}}function X6(D){D.command("auth").description("inspect authentication state across backends").command("status").description("show login status for every backend you've authenticated against").option("--json","output JSON").action(async(B)=>{let Z=await XD(),E=await Z2(),Y=Array.from(new Set([Z.name,...E])).sort(),J=await Promise.all(Y.map(async(H)=>{let q=await E0(H);if(!q)return{name:H,url:H===Z.name?Z.url:null,loggedIn:!1,user:null,issuedAt:null,corrupt:E.includes(H)};return{name:H,url:q.apiUrl,loggedIn:!0,user:q.user,issuedAt:q.issuedAt,corrupt:!1}}));if(B.json)return w(J);let Q=J.map((H)=>[H.name===Z.name?G.green("●"):" ",H.name,H.url??G.dim("—"),H.loggedIn?G.green(H.user?.email??"yes"):H.corrupt?G.yellow("corrupt"):G.dim("no"),H.issuedAt?new Date(H.issuedAt).toLocaleDateString():G.dim("—")]);$D(["","key","url","logged in","since"],Q);let X=J.filter((H)=>H.corrupt).map((H)=>H.name);if(X.length>0)console.log(),console.log(G.warn(`Credentials file for ${X.join(", ")} is unreadable. Re-login with \`photon login --api-host <url>\`.`))})}var xD=class extends Error{constructor(D,F){super(F+"");this.status=D,this.value=F}},gB=/(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))/,mB=/(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)\s(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{2}\s\d{4}\s\d{2}:\d{2}:\d{2}\sGMT(?:\+|-)\d{4}\s\([^)]+\)/,dB=/^(?:(?:(?:(?:0?[1-9]|[12][0-9]|3[01])[/\s-](?:0?[1-9]|1[0-2])[/\s-](?:19|20)\d{2})|(?:(?:19|20)\d{2}[/\s-](?:0?[1-9]|1[0-2])[/\s-](?:0?[1-9]|[12][0-9]|3[01]))))(?:\s(?:1[012]|0?[1-9]):[0-5][0-9](?::[0-5][0-9])?(?:\s[AP]M)?)?$/,cB=(D)=>D.trim().length!==0&&!Number.isNaN(Number(D)),E2=(D,F)=>{if(typeof D!="string"||F?.parseDate===!1)return null;let B=D.replace(/"/g,"");if(gB.test(B)||mB.test(B)||dB.test(B)){let Z=new Date(B);if(!Number.isNaN(Z.getTime()))return Z}return null},lB=(D)=>{let F=D.charCodeAt(0),B=D.charCodeAt(D.length-1);return F===123&&B===125||F===91&&B===93},pB=(D,F)=>JSON.parse(D,(B,Z)=>{return E2(Z,F)||Z}),nD=(D,F)=>{if(!D)return D;if(cB(D))return+D;if(D==="true")return!0;if(D==="false")return!1;if(F?.parseDate!==!1){let B=E2(D,F);if(B)return B}if(lB(D))try{return pB(D,F)}catch{}return D},PF=(D,F)=>{let B=D.data.toString();return B==="null"?null:nD(B,F)};var aB=class{constructor(D){this.url=D,this.ws=new WebSocket(D)}ws;send(D){return Array.isArray(D)?(D.forEach((F)=>this.send(F)),this):(this.ws.send(typeof D=="object"?JSON.stringify(D):D.toString()),this)}on(D,F,B){return this.addEventListener(D,F,B)}off(D,F,B){return this.ws.removeEventListener(D,F,B),this}subscribe(D,F){return this.addEventListener("message",D,F)}addEventListener(D,F,B){return this.ws.addEventListener(D,(Z)=>{if(D==="message"){let E=PF(Z);F({...Z,data:E})}else F(Z)},B),this}removeEventListener(D,F,B){return this.off(D,F,B),this}close(){return this.ws.close(),this}},iB=["get","post","put","delete","patch","options","head","connect","subscribe"],q6=(D,F)=>typeof F=="function"?F(D):F===!0,z6=["localhost","127.0.0.1","0.0.0.0"],xF=typeof FileList>"u",Y2=(D)=>xF?D instanceof Blob:D instanceof FileList||D instanceof File,nB=(D)=>{if(!D)return!1;for(let F in D)if(Y2(D[F])||Array.isArray(D[F])&&D[F].find(Y2))return!0;return!1},yF=(D)=>xF?D:new Promise((F)=>{let B=new FileReader;B.onload=()=>{let Z=new File([B.result],D.name,{lastModified:D.lastModified,type:D.type});F(Z)},B.readAsArrayBuffer(D)}),rD=async(D,F,B={},Z={})=>{if(Array.isArray(D)){for(let E of D)if(!Array.isArray(E))Z=await rD(E,F,B,Z);else{let Y=E[0];if(typeof Y=="string")Z[Y.toLowerCase()]=E[1];else for(let[J,Q]of Y)Z[J.toLowerCase()]=Q}return Z}if(!D)return Z;switch(typeof D){case"function":if(D instanceof Headers)return rD(D,F,B,Z);let E=await D(F,B);return E?rD(E,F,B,Z):Z;case"object":if(D instanceof Headers)return D.forEach((Y,J)=>{Z[J.toLowerCase()]=Y}),Z;for(let[Y,J]of Object.entries(D))Z[Y.toLowerCase()]=J;return Z;default:return Z}};function C6(D,F){let B=D.split(`
|
|
36
36
|
`),Z={};for(let E of B){if(!E||E.startsWith(":"))continue;let Y=E.indexOf(":");if(Y>0){let J=E.slice(0,Y).trim(),Q=E.slice(Y+1).replace(/^ /,"");Z[J]=Q&&nD(Q,F)}}return Object.keys(Z).length>0?Z:null}function*K6(D,F){let B;for(;(B=D.value.indexOf(`
|