spacetime-studio 0.0.2 → 0.0.3

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.
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env bun
2
+ // @bun
3
+ var Sq=Object.create;var{getPrototypeOf:Fq,defineProperty:n,getOwnPropertyNames:Nq}=Object;var wq=Object.prototype.hasOwnProperty;function Aq(q){return this[q]}var Cq,kq,xq=(q,z,J)=>{var Q=q!=null&&typeof q==="object";if(Q){var X=z?Cq??=new WeakMap:kq??=new WeakMap,Z=X.get(q);if(Z)return Z}J=q!=null?Sq(Fq(q)):{};let $=z||!q||!q.__esModule?n(J,"default",{value:q,enumerable:!0}):J;for(let G of Nq(q))if(!wq.call($,G))n($,G,{get:Aq.bind(q,G),enumerable:!0});if(Q)X.set(q,$);return $};var D=(q,z)=>()=>(z||q((z={exports:{}}).exports,z),z.exports);var N=import.meta.require;var C=D((sq)=>{class g extends Error{constructor(q,z,J){super(J);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=z,this.exitCode=q,this.nestedError=void 0}}class Wq extends g{constructor(q){super(1,"commander.invalidArgument",q);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}sq.CommanderError=g;sq.InvalidArgumentError=Wq});var O=D((eq)=>{var{InvalidArgumentError:aq}=C();class Bq{constructor(q,z){switch(this.description=z||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,q[0]){case"<":this.required=!0,this._name=q.slice(1,-1);break;case"[":this.required=!1,this._name=q.slice(1,-1);break;default:this.required=!0,this._name=q;break}if(this._name.length>3&&this._name.slice(-3)==="...")this.variadic=!0,this._name=this._name.slice(0,-3)}name(){return this._name}_concatValue(q,z){if(z===this.defaultValue||!Array.isArray(z))return[q];return z.concat(q)}default(q,z){return this.defaultValue=q,this.defaultValueDescription=z,this}argParser(q){return this.parseArg=q,this}choices(q){return this.argChoices=q.slice(),this.parseArg=(z,J)=>{if(!this.argChoices.includes(z))throw new aq(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._concatValue(z,J);return z},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}}function oq(q){let z=q.name()+(q.variadic===!0?"...":"");return q.required?"<"+z+">":"["+z+"]"}eq.Argument=Bq;eq.humanReadableArgName=oq});var c=D((Q1)=>{var{humanReadableArgName:J1}=O();class Uq{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}visibleCommands(q){let z=q.commands.filter((Q)=>!Q._hidden),J=q._getHelpCommand();if(J&&!J._hidden)z.push(J);if(this.sortSubcommands)z.sort((Q,X)=>{return Q.name().localeCompare(X.name())});return z}compareOptions(q,z){let J=(Q)=>{return Q.short?Q.short.replace(/^-/,""):Q.long.replace(/^--/,"")};return J(q).localeCompare(J(z))}visibleOptions(q){let z=q.options.filter((Q)=>!Q.hidden),J=q._getHelpOption();if(J&&!J.hidden){let Q=J.short&&q._findOption(J.short),X=J.long&&q._findOption(J.long);if(!Q&&!X)z.push(J);else if(J.long&&!X)z.push(q.createOption(J.long,J.description));else if(J.short&&!Q)z.push(q.createOption(J.short,J.description))}if(this.sortOptions)z.sort(this.compareOptions);return z}visibleGlobalOptions(q){if(!this.showGlobalOptions)return[];let z=[];for(let J=q.parent;J;J=J.parent){let Q=J.options.filter((X)=>!X.hidden);z.push(...Q)}if(this.sortOptions)z.sort(this.compareOptions);return z}visibleArguments(q){if(q._argsDescription)q.registeredArguments.forEach((z)=>{z.description=z.description||q._argsDescription[z.name()]||""});if(q.registeredArguments.find((z)=>z.description))return q.registeredArguments;return[]}subcommandTerm(q){let z=q.registeredArguments.map((J)=>J1(J)).join(" ");return q._name+(q._aliases[0]?"|"+q._aliases[0]:"")+(q.options.length?" [options]":"")+(z?" "+z:"")}optionTerm(q){return q.flags}argumentTerm(q){return q.name()}longestSubcommandTermLength(q,z){return z.visibleCommands(q).reduce((J,Q)=>{return Math.max(J,z.subcommandTerm(Q).length)},0)}longestOptionTermLength(q,z){return z.visibleOptions(q).reduce((J,Q)=>{return Math.max(J,z.optionTerm(Q).length)},0)}longestGlobalOptionTermLength(q,z){return z.visibleGlobalOptions(q).reduce((J,Q)=>{return Math.max(J,z.optionTerm(Q).length)},0)}longestArgumentTermLength(q,z){return z.visibleArguments(q).reduce((J,Q)=>{return Math.max(J,z.argumentTerm(Q).length)},0)}commandUsage(q){let z=q._name;if(q._aliases[0])z=z+"|"+q._aliases[0];let J="";for(let Q=q.parent;Q;Q=Q.parent)J=Q.name()+" "+J;return J+z+" "+q.usage()}commandDescription(q){return q.description()}subcommandDescription(q){return q.summary()||q.description()}optionDescription(q){let z=[];if(q.argChoices)z.push(`choices: ${q.argChoices.map((J)=>JSON.stringify(J)).join(", ")}`);if(q.defaultValue!==void 0){if(q.required||q.optional||q.isBoolean()&&typeof q.defaultValue==="boolean")z.push(`default: ${q.defaultValueDescription||JSON.stringify(q.defaultValue)}`)}if(q.presetArg!==void 0&&q.optional)z.push(`preset: ${JSON.stringify(q.presetArg)}`);if(q.envVar!==void 0)z.push(`env: ${q.envVar}`);if(z.length>0)return`${q.description} (${z.join(", ")})`;return q.description}argumentDescription(q){let z=[];if(q.argChoices)z.push(`choices: ${q.argChoices.map((J)=>JSON.stringify(J)).join(", ")}`);if(q.defaultValue!==void 0)z.push(`default: ${q.defaultValueDescription||JSON.stringify(q.defaultValue)}`);if(z.length>0){let J=`(${z.join(", ")})`;if(q.description)return`${q.description} ${J}`;return J}return q.description}formatHelp(q,z){let J=z.padWidth(q,z),Q=z.helpWidth||80,X=2,Z=2;function $(T,P){if(P){let b=`${T.padEnd(J+2)}${P}`;return z.wrap(b,Q-2,J+2)}return T}function G(T){return T.join(`
4
+ `).replace(/^/gm," ".repeat(2))}let W=[`Usage: ${z.commandUsage(q)}`,""],B=z.commandDescription(q);if(B.length>0)W=W.concat([z.wrap(B,Q,0),""]);let Y=z.visibleArguments(q).map((T)=>{return $(z.argumentTerm(T),z.argumentDescription(T))});if(Y.length>0)W=W.concat(["Arguments:",G(Y),""]);let M=z.visibleOptions(q).map((T)=>{return $(z.optionTerm(T),z.optionDescription(T))});if(M.length>0)W=W.concat(["Options:",G(M),""]);if(this.showGlobalOptions){let T=z.visibleGlobalOptions(q).map((P)=>{return $(z.optionTerm(P),z.optionDescription(P))});if(T.length>0)W=W.concat(["Global Options:",G(T),""])}let E=z.visibleCommands(q).map((T)=>{return $(z.subcommandTerm(T),z.subcommandDescription(T))});if(E.length>0)W=W.concat(["Commands:",G(E),""]);return W.join(`
5
+ `)}padWidth(q,z){return Math.max(z.longestOptionTermLength(q,z),z.longestGlobalOptionTermLength(q,z),z.longestSubcommandTermLength(q,z),z.longestArgumentTermLength(q,z))}wrap(q,z,J,Q=40){let Z=new RegExp(`[\\n][${" \\f\\t\\v\xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF"}]+`);if(q.match(Z))return q;let $=z-J;if($<Q)return q;let G=q.slice(0,J),W=q.slice(J).replace(`\r
6
+ `,`
7
+ `),B=" ".repeat(J),M=`\\s${"\u200B"}`,E=new RegExp(`
8
+ |.{1,${$-1}}([${M}]|$)|[^${M}]+?([${M}]|$)`,"g"),T=W.match(E)||[];return G+T.map((P,b)=>{if(P===`
9
+ `)return"";return(b>0?B:"")+P.trimEnd()}).join(`
10
+ `)}}Q1.Help=Uq});var m=D((W1)=>{var{InvalidArgumentError:Z1}=C();class Yq{constructor(q,z){this.flags=q,this.description=z||"",this.required=q.includes("<"),this.optional=q.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(q),this.mandatory=!1;let J=G1(q);if(this.short=J.shortFlag,this.long=J.longFlag,this.negate=!1,this.long)this.negate=this.long.startsWith("--no-");this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0}default(q,z){return this.defaultValue=q,this.defaultValueDescription=z,this}preset(q){return this.presetArg=q,this}conflicts(q){return this.conflictsWith=this.conflictsWith.concat(q),this}implies(q){let z=q;if(typeof q==="string")z={[q]:!0};return this.implied=Object.assign(this.implied||{},z),this}env(q){return this.envVar=q,this}argParser(q){return this.parseArg=q,this}makeOptionMandatory(q=!0){return this.mandatory=!!q,this}hideHelp(q=!0){return this.hidden=!!q,this}_concatValue(q,z){if(z===this.defaultValue||!Array.isArray(z))return[q];return z.concat(q)}choices(q){return this.argChoices=q.slice(),this.parseArg=(z,J)=>{if(!this.argChoices.includes(z))throw new Z1(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._concatValue(z,J);return z},this}name(){if(this.long)return this.long.replace(/^--/,"");return this.short.replace(/^-/,"")}attributeName(){return $1(this.name().replace(/^no-/,""))}is(q){return this.short===q||this.long===q}isBoolean(){return!this.required&&!this.optional&&!this.negate}}class Hq{constructor(q){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,q.forEach((z)=>{if(z.negate)this.negativeOptions.set(z.attributeName(),z);else this.positiveOptions.set(z.attributeName(),z)}),this.negativeOptions.forEach((z,J)=>{if(this.positiveOptions.has(J))this.dualOptions.add(J)})}valueFromOption(q,z){let J=z.attributeName();if(!this.dualOptions.has(J))return!0;let Q=this.negativeOptions.get(J).presetArg,X=Q!==void 0?Q:!1;return z.negate===(X===q)}}function $1(q){return q.split("-").reduce((z,J)=>{return z+J[0].toUpperCase()+J.slice(1)})}function G1(q){let z,J,Q=q.split(/[ |,]+/);if(Q.length>1&&!/^[[<]/.test(Q[1]))z=Q.shift();if(J=Q.shift(),!z&&/^-[^-]$/.test(J))z=J,J=void 0;return{shortFlag:z,longFlag:J}}W1.Option=Yq;W1.DualOptions=Hq});var Rq=D((R1)=>{function Y1(q,z){if(Math.abs(q.length-z.length)>3)return Math.max(q.length,z.length);let J=[];for(let Q=0;Q<=q.length;Q++)J[Q]=[Q];for(let Q=0;Q<=z.length;Q++)J[0][Q]=Q;for(let Q=1;Q<=z.length;Q++)for(let X=1;X<=q.length;X++){let Z=1;if(q[X-1]===z[Q-1])Z=0;else Z=1;if(J[X][Q]=Math.min(J[X-1][Q]+1,J[X][Q-1]+1,J[X-1][Q-1]+Z),X>1&&Q>1&&q[X-1]===z[Q-2]&&q[X-2]===z[Q-1])J[X][Q]=Math.min(J[X][Q],J[X-2][Q-2]+1)}return J[q.length][z.length]}function H1(q,z){if(!z||z.length===0)return"";z=Array.from(new Set(z));let J=q.startsWith("--");if(J)q=q.slice(2),z=z.map(($)=>$.slice(2));let Q=[],X=3,Z=0.4;if(z.forEach(($)=>{if($.length<=1)return;let G=Y1(q,$),W=Math.max(q.length,$.length);if((W-G)/W>Z){if(G<X)X=G,Q=[$];else if(G===X)Q.push($)}}),Q.sort(($,G)=>$.localeCompare(G)),J)Q=Q.map(($)=>`--${$}`);if(Q.length>1)return`
11
+ (Did you mean one of ${Q.join(", ")}?)`;if(Q.length===1)return`
12
+ (Did you mean ${Q[0]}?)`;return""}R1.suggestSimilar=H1});var Mq=D((j1)=>{var L1=N("events").EventEmitter,d=N("child_process"),j=N("path"),l=N("fs"),L=N("process"),{Argument:T1,humanReadableArgName:M1}=O(),{CommanderError:p}=C(),{Help:I1}=c(),{Option:Kq,DualOptions:_1}=m(),{suggestSimilar:Lq}=Rq();class i extends L1{constructor(q){super();this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!0,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=q||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._outputConfiguration={writeOut:(z)=>L.stdout.write(z),writeErr:(z)=>L.stderr.write(z),getOutHelpWidth:()=>L.stdout.isTTY?L.stdout.columns:void 0,getErrHelpWidth:()=>L.stderr.isTTY?L.stderr.columns:void 0,outputError:(z,J)=>J(z)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={}}copyInheritedSettings(q){return this._outputConfiguration=q._outputConfiguration,this._helpOption=q._helpOption,this._helpCommand=q._helpCommand,this._helpConfiguration=q._helpConfiguration,this._exitCallback=q._exitCallback,this._storeOptionsAsProperties=q._storeOptionsAsProperties,this._combineFlagAndOptionalValue=q._combineFlagAndOptionalValue,this._allowExcessArguments=q._allowExcessArguments,this._enablePositionalOptions=q._enablePositionalOptions,this._showHelpAfterError=q._showHelpAfterError,this._showSuggestionAfterError=q._showSuggestionAfterError,this}_getCommandAndAncestors(){let q=[];for(let z=this;z;z=z.parent)q.push(z);return q}command(q,z,J){let Q=z,X=J;if(typeof Q==="object"&&Q!==null)X=Q,Q=null;X=X||{};let[,Z,$]=q.match(/([^ ]+) *(.*)/),G=this.createCommand(Z);if(Q)G.description(Q),G._executableHandler=!0;if(X.isDefault)this._defaultCommandName=G._name;if(G._hidden=!!(X.noHelp||X.hidden),G._executableFile=X.executableFile||null,$)G.arguments($);if(this._registerCommand(G),G.parent=this,G.copyInheritedSettings(this),Q)return this;return G}createCommand(q){return new i(q)}createHelp(){return Object.assign(new I1,this.configureHelp())}configureHelp(q){if(q===void 0)return this._helpConfiguration;return this._helpConfiguration=q,this}configureOutput(q){if(q===void 0)return this._outputConfiguration;return Object.assign(this._outputConfiguration,q),this}showHelpAfterError(q=!0){if(typeof q!=="string")q=!!q;return this._showHelpAfterError=q,this}showSuggestionAfterError(q=!0){return this._showSuggestionAfterError=!!q,this}addCommand(q,z){if(!q._name)throw Error(`Command passed to .addCommand() must have a name
13
+ - specify the name in Command constructor or using .name()`);if(z=z||{},z.isDefault)this._defaultCommandName=q._name;if(z.noHelp||z.hidden)q._hidden=!0;return this._registerCommand(q),q.parent=this,q._checkForBrokenPassThrough(),this}createArgument(q,z){return new T1(q,z)}argument(q,z,J,Q){let X=this.createArgument(q,z);if(typeof J==="function")X.default(Q).argParser(J);else X.default(J);return this.addArgument(X),this}arguments(q){return q.trim().split(/ +/).forEach((z)=>{this.argument(z)}),this}addArgument(q){let z=this.registeredArguments.slice(-1)[0];if(z&&z.variadic)throw Error(`only the last argument can be variadic '${z.name()}'`);if(q.required&&q.defaultValue!==void 0&&q.parseArg===void 0)throw Error(`a default value for a required argument is never used: '${q.name()}'`);return this.registeredArguments.push(q),this}helpCommand(q,z){if(typeof q==="boolean")return this._addImplicitHelpCommand=q,this;q=q??"help [command]";let[,J,Q]=q.match(/([^ ]+) *(.*)/),X=z??"display help for command",Z=this.createCommand(J);if(Z.helpOption(!1),Q)Z.arguments(Q);if(X)Z.description(X);return this._addImplicitHelpCommand=!0,this._helpCommand=Z,this}addHelpCommand(q,z){if(typeof q!=="object")return this.helpCommand(q,z),this;return this._addImplicitHelpCommand=!0,this._helpCommand=q,this}_getHelpCommand(){if(this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))){if(this._helpCommand===void 0)this.helpCommand(void 0,void 0);return this._helpCommand}return null}hook(q,z){let J=["preSubcommand","preAction","postAction"];if(!J.includes(q))throw Error(`Unexpected value for event passed to hook : '${q}'.
14
+ Expecting one of '${J.join("', '")}'`);if(this._lifeCycleHooks[q])this._lifeCycleHooks[q].push(z);else this._lifeCycleHooks[q]=[z];return this}exitOverride(q){if(q)this._exitCallback=q;else this._exitCallback=(z)=>{if(z.code!=="commander.executeSubCommandAsync")throw z};return this}_exit(q,z,J){if(this._exitCallback)this._exitCallback(new p(q,z,J));L.exit(q)}action(q){let z=(J)=>{let Q=this.registeredArguments.length,X=J.slice(0,Q);if(this._storeOptionsAsProperties)X[Q]=this;else X[Q]=this.opts();return X.push(this),q.apply(this,X)};return this._actionHandler=z,this}createOption(q,z){return new Kq(q,z)}_callParseArg(q,z,J,Q){try{return q.parseArg(z,J)}catch(X){if(X.code==="commander.invalidArgument"){let Z=`${Q} ${X.message}`;this.error(Z,{exitCode:X.exitCode,code:X.code})}throw X}}_registerOption(q){let z=q.short&&this._findOption(q.short)||q.long&&this._findOption(q.long);if(z){let J=q.long&&this._findOption(q.long)?q.long:q.short;throw Error(`Cannot add option '${q.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${J}'
15
+ - already used by option '${z.flags}'`)}this.options.push(q)}_registerCommand(q){let z=(Q)=>{return[Q.name()].concat(Q.aliases())},J=z(q).find((Q)=>this._findCommand(Q));if(J){let Q=z(this._findCommand(J)).join("|"),X=z(q).join("|");throw Error(`cannot add command '${X}' as already have command '${Q}'`)}this.commands.push(q)}addOption(q){this._registerOption(q);let z=q.name(),J=q.attributeName();if(q.negate){let X=q.long.replace(/^--no-/,"--");if(!this._findOption(X))this.setOptionValueWithSource(J,q.defaultValue===void 0?!0:q.defaultValue,"default")}else if(q.defaultValue!==void 0)this.setOptionValueWithSource(J,q.defaultValue,"default");let Q=(X,Z,$)=>{if(X==null&&q.presetArg!==void 0)X=q.presetArg;let G=this.getOptionValue(J);if(X!==null&&q.parseArg)X=this._callParseArg(q,X,G,Z);else if(X!==null&&q.variadic)X=q._concatValue(X,G);if(X==null)if(q.negate)X=!1;else if(q.isBoolean()||q.optional)X=!0;else X="";this.setOptionValueWithSource(J,X,$)};if(this.on("option:"+z,(X)=>{let Z=`error: option '${q.flags}' argument '${X}' is invalid.`;Q(X,Z,"cli")}),q.envVar)this.on("optionEnv:"+z,(X)=>{let Z=`error: option '${q.flags}' value '${X}' from env '${q.envVar}' is invalid.`;Q(X,Z,"env")});return this}_optionEx(q,z,J,Q,X){if(typeof z==="object"&&z instanceof Kq)throw Error("To add an Option object use addOption() instead of option() or requiredOption()");let Z=this.createOption(z,J);if(Z.makeOptionMandatory(!!q.mandatory),typeof Q==="function")Z.default(X).argParser(Q);else if(Q instanceof RegExp){let $=Q;Q=(G,W)=>{let B=$.exec(G);return B?B[0]:W},Z.default(X).argParser(Q)}else Z.default(Q);return this.addOption(Z)}option(q,z,J,Q){return this._optionEx({},q,z,J,Q)}requiredOption(q,z,J,Q){return this._optionEx({mandatory:!0},q,z,J,Q)}combineFlagAndOptionalValue(q=!0){return this._combineFlagAndOptionalValue=!!q,this}allowUnknownOption(q=!0){return this._allowUnknownOption=!!q,this}allowExcessArguments(q=!0){return this._allowExcessArguments=!!q,this}enablePositionalOptions(q=!0){return this._enablePositionalOptions=!!q,this}passThroughOptions(q=!0){return this._passThroughOptions=!!q,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(q=!0){if(this.options.length)throw Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!q,this}getOptionValue(q){if(this._storeOptionsAsProperties)return this[q];return this._optionValues[q]}setOptionValue(q,z){return this.setOptionValueWithSource(q,z,void 0)}setOptionValueWithSource(q,z,J){if(this._storeOptionsAsProperties)this[q]=z;else this._optionValues[q]=z;return this._optionValueSources[q]=J,this}getOptionValueSource(q){return this._optionValueSources[q]}getOptionValueSourceWithGlobals(q){let z;return this._getCommandAndAncestors().forEach((J)=>{if(J.getOptionValueSource(q)!==void 0)z=J.getOptionValueSource(q)}),z}_prepareUserArgs(q,z){if(q!==void 0&&!Array.isArray(q))throw Error("first parameter to parse must be array or undefined");if(z=z||{},q===void 0&&z.from===void 0){if(L.versions?.electron)z.from="electron";let Q=L.execArgv??[];if(Q.includes("-e")||Q.includes("--eval")||Q.includes("-p")||Q.includes("--print"))z.from="eval"}if(q===void 0)q=L.argv;this.rawArgs=q.slice();let J;switch(z.from){case void 0:case"node":this._scriptPath=q[1],J=q.slice(2);break;case"electron":if(L.defaultApp)this._scriptPath=q[1],J=q.slice(2);else J=q.slice(1);break;case"user":J=q.slice(0);break;case"eval":J=q.slice(1);break;default:throw Error(`unexpected parse option { from: '${z.from}' }`)}if(!this._name&&this._scriptPath)this.nameFromFilename(this._scriptPath);return this._name=this._name||"program",J}parse(q,z){let J=this._prepareUserArgs(q,z);return this._parseCommand([],J),this}async parseAsync(q,z){let J=this._prepareUserArgs(q,z);return await this._parseCommand([],J),this}_executeSubCommand(q,z){z=z.slice();let J=!1,Q=[".js",".ts",".tsx",".mjs",".cjs"];function X(B,Y){let M=j.resolve(B,Y);if(l.existsSync(M))return M;if(Q.includes(j.extname(Y)))return;let E=Q.find((T)=>l.existsSync(`${M}${T}`));if(E)return`${M}${E}`;return}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let Z=q._executableFile||`${this._name}-${q._name}`,$=this._executableDir||"";if(this._scriptPath){let B;try{B=l.realpathSync(this._scriptPath)}catch(Y){B=this._scriptPath}$=j.resolve(j.dirname(B),$)}if($){let B=X($,Z);if(!B&&!q._executableFile&&this._scriptPath){let Y=j.basename(this._scriptPath,j.extname(this._scriptPath));if(Y!==this._name)B=X($,`${Y}-${q._name}`)}Z=B||Z}J=Q.includes(j.extname(Z));let G;if(L.platform!=="win32")if(J)z.unshift(Z),z=Tq(L.execArgv).concat(z),G=d.spawn(L.argv[0],z,{stdio:"inherit"});else G=d.spawn(Z,z,{stdio:"inherit"});else z.unshift(Z),z=Tq(L.execArgv).concat(z),G=d.spawn(L.execPath,z,{stdio:"inherit"});if(!G.killed)["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach((Y)=>{L.on(Y,()=>{if(G.killed===!1&&G.exitCode===null)G.kill(Y)})});let W=this._exitCallback;G.on("close",(B)=>{if(B=B??1,!W)L.exit(B);else W(new p(B,"commander.executeSubCommandAsync","(close)"))}),G.on("error",(B)=>{if(B.code==="ENOENT"){let Y=$?`searched for local subcommand relative to directory '${$}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",M=`'${Z}' does not exist
16
+ - if '${q._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
17
+ - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
18
+ - ${Y}`;throw Error(M)}else if(B.code==="EACCES")throw Error(`'${Z}' not executable`);if(!W)L.exit(1);else{let Y=new p(1,"commander.executeSubCommandAsync","(error)");Y.nestedError=B,W(Y)}}),this.runningCommand=G}_dispatchSubcommand(q,z,J){let Q=this._findCommand(q);if(!Q)this.help({error:!0});let X;return X=this._chainOrCallSubCommandHook(X,Q,"preSubcommand"),X=this._chainOrCall(X,()=>{if(Q._executableHandler)this._executeSubCommand(Q,z.concat(J));else return Q._parseCommand(z,J)}),X}_dispatchHelpCommand(q){if(!q)this.help();let z=this._findCommand(q);if(z&&!z._executableHandler)z.help();return this._dispatchSubcommand(q,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){if(this.registeredArguments.forEach((q,z)=>{if(q.required&&this.args[z]==null)this.missingArgument(q.name())}),this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)return;if(this.args.length>this.registeredArguments.length)this._excessArguments(this.args)}_processArguments(){let q=(J,Q,X)=>{let Z=Q;if(Q!==null&&J.parseArg){let $=`error: command-argument value '${Q}' is invalid for argument '${J.name()}'.`;Z=this._callParseArg(J,Q,X,$)}return Z};this._checkNumberOfArguments();let z=[];this.registeredArguments.forEach((J,Q)=>{let X=J.defaultValue;if(J.variadic){if(Q<this.args.length){if(X=this.args.slice(Q),J.parseArg)X=X.reduce((Z,$)=>{return q(J,$,Z)},J.defaultValue)}else if(X===void 0)X=[]}else if(Q<this.args.length){if(X=this.args[Q],J.parseArg)X=q(J,X,J.defaultValue)}z[Q]=X}),this.processedArgs=z}_chainOrCall(q,z){if(q&&q.then&&typeof q.then==="function")return q.then(()=>z());return z()}_chainOrCallHooks(q,z){let J=q,Q=[];if(this._getCommandAndAncestors().reverse().filter((X)=>X._lifeCycleHooks[z]!==void 0).forEach((X)=>{X._lifeCycleHooks[z].forEach((Z)=>{Q.push({hookedCommand:X,callback:Z})})}),z==="postAction")Q.reverse();return Q.forEach((X)=>{J=this._chainOrCall(J,()=>{return X.callback(X.hookedCommand,this)})}),J}_chainOrCallSubCommandHook(q,z,J){let Q=q;if(this._lifeCycleHooks[J]!==void 0)this._lifeCycleHooks[J].forEach((X)=>{Q=this._chainOrCall(Q,()=>{return X(this,z)})});return Q}_parseCommand(q,z){let J=this.parseOptions(z);if(this._parseOptionsEnv(),this._parseOptionsImplied(),q=q.concat(J.operands),z=J.unknown,this.args=q.concat(z),q&&this._findCommand(q[0]))return this._dispatchSubcommand(q[0],q.slice(1),z);if(this._getHelpCommand()&&q[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(q[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(z),this._dispatchSubcommand(this._defaultCommandName,q,z);if(this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName)this.help({error:!0});this._outputHelpIfRequested(J.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let Q=()=>{if(J.unknown.length>0)this.unknownOption(J.unknown[0])},X=`command:${this.name()}`;if(this._actionHandler){Q(),this._processArguments();let Z;if(Z=this._chainOrCallHooks(Z,"preAction"),Z=this._chainOrCall(Z,()=>this._actionHandler(this.processedArgs)),this.parent)Z=this._chainOrCall(Z,()=>{this.parent.emit(X,q,z)});return Z=this._chainOrCallHooks(Z,"postAction"),Z}if(this.parent&&this.parent.listenerCount(X))Q(),this._processArguments(),this.parent.emit(X,q,z);else if(q.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",q,z);if(this.listenerCount("command:*"))this.emit("command:*",q,z);else if(this.commands.length)this.unknownCommand();else Q(),this._processArguments()}else if(this.commands.length)Q(),this.help({error:!0});else Q(),this._processArguments()}_findCommand(q){if(!q)return;return this.commands.find((z)=>z._name===q||z._aliases.includes(q))}_findOption(q){return this.options.find((z)=>z.is(q))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach((q)=>{q.options.forEach((z)=>{if(z.mandatory&&q.getOptionValue(z.attributeName())===void 0)q.missingMandatoryOptionValue(z)})})}_checkForConflictingLocalOptions(){let q=this.options.filter((J)=>{let Q=J.attributeName();if(this.getOptionValue(Q)===void 0)return!1;return this.getOptionValueSource(Q)!=="default"});q.filter((J)=>J.conflictsWith.length>0).forEach((J)=>{let Q=q.find((X)=>J.conflictsWith.includes(X.attributeName()));if(Q)this._conflictingOption(J,Q)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach((q)=>{q._checkForConflictingLocalOptions()})}parseOptions(q){let z=[],J=[],Q=z,X=q.slice();function Z(G){return G.length>1&&G[0]==="-"}let $=null;while(X.length){let G=X.shift();if(G==="--"){if(Q===J)Q.push(G);Q.push(...X);break}if($&&!Z(G)){this.emit(`option:${$.name()}`,G);continue}if($=null,Z(G)){let W=this._findOption(G);if(W){if(W.required){let B=X.shift();if(B===void 0)this.optionMissingArgument(W);this.emit(`option:${W.name()}`,B)}else if(W.optional){let B=null;if(X.length>0&&!Z(X[0]))B=X.shift();this.emit(`option:${W.name()}`,B)}else this.emit(`option:${W.name()}`);$=W.variadic?W:null;continue}}if(G.length>2&&G[0]==="-"&&G[1]!=="-"){let W=this._findOption(`-${G[1]}`);if(W){if(W.required||W.optional&&this._combineFlagAndOptionalValue)this.emit(`option:${W.name()}`,G.slice(2));else this.emit(`option:${W.name()}`),X.unshift(`-${G.slice(2)}`);continue}}if(/^--[^=]+=/.test(G)){let W=G.indexOf("="),B=this._findOption(G.slice(0,W));if(B&&(B.required||B.optional)){this.emit(`option:${B.name()}`,G.slice(W+1));continue}}if(Z(G))Q=J;if((this._enablePositionalOptions||this._passThroughOptions)&&z.length===0&&J.length===0){if(this._findCommand(G)){if(z.push(G),X.length>0)J.push(...X);break}else if(this._getHelpCommand()&&G===this._getHelpCommand().name()){if(z.push(G),X.length>0)z.push(...X);break}else if(this._defaultCommandName){if(J.push(G),X.length>0)J.push(...X);break}}if(this._passThroughOptions){if(Q.push(G),X.length>0)Q.push(...X);break}Q.push(G)}return{operands:z,unknown:J}}opts(){if(this._storeOptionsAsProperties){let q={},z=this.options.length;for(let J=0;J<z;J++){let Q=this.options[J].attributeName();q[Q]=Q===this._versionOptionName?this._version:this[Q]}return q}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((q,z)=>Object.assign(q,z.opts()),{})}error(q,z){if(this._outputConfiguration.outputError(`${q}
19
+ `,this._outputConfiguration.writeErr),typeof this._showHelpAfterError==="string")this._outputConfiguration.writeErr(`${this._showHelpAfterError}
20
+ `);else if(this._showHelpAfterError)this._outputConfiguration.writeErr(`
21
+ `),this.outputHelp({error:!0});let J=z||{},Q=J.exitCode||1,X=J.code||"commander.error";this._exit(Q,X,q)}_parseOptionsEnv(){this.options.forEach((q)=>{if(q.envVar&&q.envVar in L.env){let z=q.attributeName();if(this.getOptionValue(z)===void 0||["default","config","env"].includes(this.getOptionValueSource(z)))if(q.required||q.optional)this.emit(`optionEnv:${q.name()}`,L.env[q.envVar]);else this.emit(`optionEnv:${q.name()}`)}})}_parseOptionsImplied(){let q=new _1(this.options),z=(J)=>{return this.getOptionValue(J)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(J))};this.options.filter((J)=>J.implied!==void 0&&z(J.attributeName())&&q.valueFromOption(this.getOptionValue(J.attributeName()),J)).forEach((J)=>{Object.keys(J.implied).filter((Q)=>!z(Q)).forEach((Q)=>{this.setOptionValueWithSource(Q,J.implied[Q],"implied")})})}missingArgument(q){let z=`error: missing required argument '${q}'`;this.error(z,{code:"commander.missingArgument"})}optionMissingArgument(q){let z=`error: option '${q.flags}' argument missing`;this.error(z,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(q){let z=`error: required option '${q.flags}' not specified`;this.error(z,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(q,z){let J=(Z)=>{let $=Z.attributeName(),G=this.getOptionValue($),W=this.options.find((Y)=>Y.negate&&$===Y.attributeName()),B=this.options.find((Y)=>!Y.negate&&$===Y.attributeName());if(W&&(W.presetArg===void 0&&G===!1||W.presetArg!==void 0&&G===W.presetArg))return W;return B||Z},Q=(Z)=>{let $=J(Z),G=$.attributeName();if(this.getOptionValueSource(G)==="env")return`environment variable '${$.envVar}'`;return`option '${$.flags}'`},X=`error: ${Q(q)} cannot be used with ${Q(z)}`;this.error(X,{code:"commander.conflictingOption"})}unknownOption(q){if(this._allowUnknownOption)return;let z="";if(q.startsWith("--")&&this._showSuggestionAfterError){let Q=[],X=this;do{let Z=X.createHelp().visibleOptions(X).filter(($)=>$.long).map(($)=>$.long);Q=Q.concat(Z),X=X.parent}while(X&&!X._enablePositionalOptions);z=Lq(q,Q)}let J=`error: unknown option '${q}'${z}`;this.error(J,{code:"commander.unknownOption"})}_excessArguments(q){if(this._allowExcessArguments)return;let z=this.registeredArguments.length,J=z===1?"":"s",X=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${z} argument${J} but got ${q.length}.`;this.error(X,{code:"commander.excessArguments"})}unknownCommand(){let q=this.args[0],z="";if(this._showSuggestionAfterError){let Q=[];this.createHelp().visibleCommands(this).forEach((X)=>{if(Q.push(X.name()),X.alias())Q.push(X.alias())}),z=Lq(q,Q)}let J=`error: unknown command '${q}'${z}`;this.error(J,{code:"commander.unknownCommand"})}version(q,z,J){if(q===void 0)return this._version;this._version=q,z=z||"-V, --version",J=J||"output the version number";let Q=this.createOption(z,J);return this._versionOptionName=Q.attributeName(),this._registerOption(Q),this.on("option:"+Q.name(),()=>{this._outputConfiguration.writeOut(`${q}
22
+ `),this._exit(0,"commander.version",q)}),this}description(q,z){if(q===void 0&&z===void 0)return this._description;if(this._description=q,z)this._argsDescription=z;return this}summary(q){if(q===void 0)return this._summary;return this._summary=q,this}alias(q){if(q===void 0)return this._aliases[0];let z=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler)z=this.commands[this.commands.length-1];if(q===z._name)throw Error("Command alias can't be the same as its name");let J=this.parent?._findCommand(q);if(J){let Q=[J.name()].concat(J.aliases()).join("|");throw Error(`cannot add alias '${q}' to command '${this.name()}' as already have command '${Q}'`)}return z._aliases.push(q),this}aliases(q){if(q===void 0)return this._aliases;return q.forEach((z)=>this.alias(z)),this}usage(q){if(q===void 0){if(this._usage)return this._usage;let z=this.registeredArguments.map((J)=>{return M1(J)});return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?z:[]).join(" ")}return this._usage=q,this}name(q){if(q===void 0)return this._name;return this._name=q,this}nameFromFilename(q){return this._name=j.basename(q,j.extname(q)),this}executableDir(q){if(q===void 0)return this._executableDir;return this._executableDir=q,this}helpInformation(q){let z=this.createHelp();if(z.helpWidth===void 0)z.helpWidth=q&&q.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth();return z.formatHelp(this,z)}_getHelpContext(q){q=q||{};let z={error:!!q.error},J;if(z.error)J=(Q)=>this._outputConfiguration.writeErr(Q);else J=(Q)=>this._outputConfiguration.writeOut(Q);return z.write=q.write||J,z.command=this,z}outputHelp(q){let z;if(typeof q==="function")z=q,q=void 0;let J=this._getHelpContext(q);this._getCommandAndAncestors().reverse().forEach((X)=>X.emit("beforeAllHelp",J)),this.emit("beforeHelp",J);let Q=this.helpInformation(J);if(z){if(Q=z(Q),typeof Q!=="string"&&!Buffer.isBuffer(Q))throw Error("outputHelp callback must return a string or a Buffer")}if(J.write(Q),this._getHelpOption()?.long)this.emit(this._getHelpOption().long);this.emit("afterHelp",J),this._getCommandAndAncestors().forEach((X)=>X.emit("afterAllHelp",J))}helpOption(q,z){if(typeof q==="boolean"){if(q)this._helpOption=this._helpOption??void 0;else this._helpOption=null;return this}return q=q??"-h, --help",z=z??"display help for command",this._helpOption=this.createOption(q,z),this}_getHelpOption(){if(this._helpOption===void 0)this.helpOption(void 0,void 0);return this._helpOption}addHelpOption(q){return this._helpOption=q,this}help(q){this.outputHelp(q);let z=L.exitCode||0;if(z===0&&q&&typeof q!=="function"&&q.error)z=1;this._exit(z,"commander.help","(outputHelp)")}addHelpText(q,z){let J=["beforeAll","before","after","afterAll"];if(!J.includes(q))throw Error(`Unexpected value for position to addHelpText.
23
+ Expecting one of '${J.join("', '")}'`);let Q=`${q}Help`;return this.on(Q,(X)=>{let Z;if(typeof z==="function")Z=z({error:X.error,command:X.command});else Z=z;if(Z)X.write(`${Z}
24
+ `)}),this}_outputHelpIfRequested(q){let z=this._getHelpOption();if(z&&q.find((Q)=>z.is(Q)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function Tq(q){return q.map((z)=>{if(!z.startsWith("--inspect"))return z;let J,Q="127.0.0.1",X="9229",Z;if((Z=z.match(/^(--inspect(-brk)?)$/))!==null)J=Z[1];else if((Z=z.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null)if(J=Z[1],/^\d+$/.test(Z[3]))X=Z[3];else Q=Z[3];else if((Z=z.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null)J=Z[1],Q=Z[3],X=Z[4];if(J&&X!=="0")return`${J}=${Q}:${parseInt(X)+1}`;return z})}j1.Command=i});var Pq=D((D1)=>{var{Argument:Iq}=O(),{Command:r}=Mq(),{CommanderError:V1,InvalidArgumentError:_q}=C(),{Help:E1}=c(),{Option:jq}=m();D1.program=new r;D1.createCommand=(q)=>new r(q);D1.createOption=(q,z)=>new jq(q,z);D1.createArgument=(q,z)=>new Iq(q,z);D1.Command=r;D1.Option=jq;D1.Argument=Iq;D1.Help=E1;D1.CommanderError=V1;D1.InvalidArgumentError=_q;D1.InvalidOptionArgumentError=_q});import H from"process";var a=(q=0)=>(z)=>`\x1B[${z+q}m`,o=(q=0)=>(z)=>`\x1B[${38+q};5;${z}m`,e=(q=0)=>(z,J,Q)=>`\x1B[${38+q};2;${z};${J};${Q}m`,R={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},m1=Object.keys(R.modifier),Oq=Object.keys(R.color),yq=Object.keys(R.bgColor),d1=[...Oq,...yq];function bq(){let q=new Map;for(let[z,J]of Object.entries(R)){for(let[Q,X]of Object.entries(J))R[Q]={open:`\x1B[${X[0]}m`,close:`\x1B[${X[1]}m`},J[Q]=R[Q],q.set(X[0],X[1]);Object.defineProperty(R,z,{value:J,enumerable:!1})}return Object.defineProperty(R,"codes",{value:q,enumerable:!1}),R.color.close="\x1B[39m",R.bgColor.close="\x1B[49m",R.color.ansi=a(),R.color.ansi256=o(),R.color.ansi16m=e(),R.bgColor.ansi=a(10),R.bgColor.ansi256=o(10),R.bgColor.ansi16m=e(10),Object.defineProperties(R,{rgbToAnsi256:{value(z,J,Q){if(z===J&&J===Q){if(z<8)return 16;if(z>248)return 231;return Math.round((z-8)/247*24)+232}return 16+36*Math.round(z/255*5)+6*Math.round(J/255*5)+Math.round(Q/255*5)},enumerable:!1},hexToRgb:{value(z){let J=/[a-f\d]{6}|[a-f\d]{3}/i.exec(z.toString(16));if(!J)return[0,0,0];let[Q]=J;if(Q.length===3)Q=[...Q].map((Z)=>Z+Z).join("");let X=Number.parseInt(Q,16);return[X>>16&255,X>>8&255,X&255]},enumerable:!1},hexToAnsi256:{value:(z)=>R.rgbToAnsi256(...R.hexToRgb(z)),enumerable:!1},ansi256ToAnsi:{value(z){if(z<8)return 30+z;if(z<16)return 90+(z-8);let J,Q,X;if(z>=232)J=((z-232)*10+8)/255,Q=J,X=J;else{z-=16;let G=z%36;J=Math.floor(z/36)/5,Q=Math.floor(G/6)/5,X=G%6/5}let Z=Math.max(J,Q,X)*2;if(Z===0)return 30;let $=30+(Math.round(X)<<2|Math.round(Q)<<1|Math.round(J));if(Z===2)$+=60;return $},enumerable:!1},rgbToAnsi:{value:(z,J,Q)=>R.ansi256ToAnsi(R.rgbToAnsi256(z,J,Q)),enumerable:!1},hexToAnsi:{value:(z)=>R.ansi256ToAnsi(R.hexToAnsi256(z)),enumerable:!1}}),R}var fq=bq(),_=fq;import f from"process";import vq from"os";import qq from"tty";function I(q,z=globalThis.Deno?globalThis.Deno.args:f.argv){let J=q.startsWith("-")?"":q.length===1?"-":"--",Q=z.indexOf(J+q),X=z.indexOf("--");return Q!==-1&&(X===-1||Q<X)}var{env:K}=f,k;if(I("no-color")||I("no-colors")||I("color=false")||I("color=never"))k=0;else if(I("color")||I("colors")||I("color=true")||I("color=always"))k=1;function hq(){if("FORCE_COLOR"in K){if(K.FORCE_COLOR==="true")return 1;if(K.FORCE_COLOR==="false")return 0;return K.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(K.FORCE_COLOR,10),3)}}function uq(q){if(q===0)return!1;return{level:q,hasBasic:!0,has256:q>=2,has16m:q>=3}}function gq(q,{streamIsTTY:z,sniffFlags:J=!0}={}){let Q=hq();if(Q!==void 0)k=Q;let X=J?k:Q;if(X===0)return 0;if(J){if(I("color=16m")||I("color=full")||I("color=truecolor"))return 3;if(I("color=256"))return 2}if("TF_BUILD"in K&&"AGENT_NAME"in K)return 1;if(q&&!z&&X===void 0)return 0;let Z=X||0;if(K.TERM==="dumb")return Z;if(f.platform==="win32"){let $=vq.release().split(".");if(Number($[0])>=10&&Number($[2])>=10586)return Number($[2])>=14931?3:2;return 1}if("CI"in K){if(["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some(($)=>($ in K)))return 3;if(["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(($)=>($ in K))||K.CI_NAME==="codeship")return 1;return Z}if("TEAMCITY_VERSION"in K)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(K.TEAMCITY_VERSION)?1:0;if(K.COLORTERM==="truecolor")return 3;if(K.TERM==="xterm-kitty")return 3;if(K.TERM==="xterm-ghostty")return 3;if(K.TERM==="wezterm")return 3;if("TERM_PROGRAM"in K){let $=Number.parseInt((K.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(K.TERM_PROGRAM){case"iTerm.app":return $>=3?3:2;case"Apple_Terminal":return 2}}if(/-256(color)?$/i.test(K.TERM))return 2;if(/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(K.TERM))return 1;if("COLORTERM"in K)return 1;return Z}function zq(q,z={}){let J=gq(q,{streamIsTTY:q&&q.isTTY,...z});return uq(J)}var cq={stdout:zq({isTTY:qq.isatty(1)}),stderr:zq({isTTY:qq.isatty(2)})},Jq=cq;function Qq(q,z,J){let Q=q.indexOf(z);if(Q===-1)return q;let X=z.length,Z=0,$="";do $+=q.slice(Z,Q)+z+J,Z=Q+X,Q=q.indexOf(z,Z);while(Q!==-1);return $+=q.slice(Z),$}function Xq(q,z,J,Q){let X=0,Z="";do{let $=q[Q-1]==="\r";Z+=q.slice(X,$?Q-1:Q)+z+($?`\r
25
+ `:`
26
+ `)+J,X=Q+1,Q=q.indexOf(`
27
+ `,X)}while(Q!==-1);return Z+=q.slice(X),Z}var{stdout:Zq,stderr:$q}=Jq,v=Symbol("GENERATOR"),S=Symbol("STYLER"),w=Symbol("IS_EMPTY"),Gq=["ansi","ansi","ansi256","ansi16m"],F=Object.create(null),mq=(q,z={})=>{if(z.level&&!(Number.isInteger(z.level)&&z.level>=0&&z.level<=3))throw Error("The `level` option should be an integer from 0 to 3");let J=Zq?Zq.level:0;q.level=z.level===void 0?J:z.level};var dq=(q)=>{let z=(...J)=>J.join(" ");return mq(z,q),Object.setPrototypeOf(z,A.prototype),z};function A(q){return dq(q)}Object.setPrototypeOf(A.prototype,Function.prototype);for(let[q,z]of Object.entries(_))F[q]={get(){let J=x(this,u(z.open,z.close,this[S]),this[w]);return Object.defineProperty(this,q,{value:J}),J}};F.visible={get(){let q=x(this,this[S],!0);return Object.defineProperty(this,"visible",{value:q}),q}};var h=(q,z,J,...Q)=>{if(q==="rgb"){if(z==="ansi16m")return _[J].ansi16m(...Q);if(z==="ansi256")return _[J].ansi256(_.rgbToAnsi256(...Q));return _[J].ansi(_.rgbToAnsi(...Q))}if(q==="hex")return h("rgb",z,J,..._.hexToRgb(...Q));return _[J][q](...Q)},lq=["rgb","hex","ansi256"];for(let q of lq){F[q]={get(){let{level:J}=this;return function(...Q){let X=u(h(q,Gq[J],"color",...Q),_.color.close,this[S]);return x(this,X,this[w])}}};let z="bg"+q[0].toUpperCase()+q.slice(1);F[z]={get(){let{level:J}=this;return function(...Q){let X=u(h(q,Gq[J],"bgColor",...Q),_.bgColor.close,this[S]);return x(this,X,this[w])}}}}var pq=Object.defineProperties(()=>{},{...F,level:{enumerable:!0,get(){return this[v].level},set(q){this[v].level=q}}}),u=(q,z,J)=>{let Q,X;if(J===void 0)Q=q,X=z;else Q=J.openAll+q,X=z+J.closeAll;return{open:q,close:z,openAll:Q,closeAll:X,parent:J}},x=(q,z,J)=>{let Q=(...X)=>iq(Q,X.length===1?""+X[0]:X.join(" "));return Object.setPrototypeOf(Q,pq),Q[v]=q,Q[S]=z,Q[w]=J,Q},iq=(q,z)=>{if(q.level<=0||!z)return q[w]?"":z;let J=q[S];if(J===void 0)return z;let{openAll:Q,closeAll:X}=J;if(z.includes("\x1B"))while(J!==void 0)z=Qq(z,J.close,J.open),J=J.parent;let Z=z.indexOf(`
28
+ `);if(Z!==-1)z=Xq(z,X,Q,Z);return Q+z+X};Object.defineProperties(A.prototype,F);var rq=A(),e1=A({level:$q?$q.level:0});var U=rq;import{spawn as t}from"child_process";var Vq=xq(Pq(),1),{program:s,createCommand:W0,createArgument:B0,createOption:U0,CommanderError:Y0,InvalidArgumentError:H0,InvalidOptionArgumentError:R0,Command:K0,Argument:L0,Option:T0,Help:M0}=Vq.default;import{existsSync as y}from"fs";import{join as V,resolve as Eq}from"path";var f1=5555,v1="localhost";function Dq(){if(H.env.SPACETIME_STUDIO_PATH){if(y(H.env.SPACETIME_STUDIO_PATH))return H.env.SPACETIME_STUDIO_PATH}let q=import.meta.dir,J=q==="/$bunfs/root"||q==="/$bunfs"?[V(H.cwd(),"dist/studio/server.mjs"),V(H.cwd(),"../../apps/studio/dist/server/bundled.mjs")]:[Eq(q,"../../../apps/studio/dist/server/bundled.mjs"),V(q,"studio/server.mjs"),V(H.cwd(),"apps/studio/dist/server/bundled.mjs"),V(H.cwd(),"dist/studio/server.mjs")];for(let Q of J)if(y(Q))return Q;return null}function h1(){let z=Eq(import.meta.dir,"../../../apps/studio");if(y(V(z,"dist/server/index.mjs")))return z;let J=V(H.cwd(),"apps/studio");if(y(V(J,"dist/server/index.mjs")))return J;return null}function u1(){let q=import.meta.dir,z=q==="/$bunfs/root"||q==="/$bunfs";console.log("Debug: Path resolution"),console.log(U.gray(` import.meta.dir: ${q}`)),console.log(U.gray(` isCompiled: ${z}`)),console.log(U.gray(` cwd: ${H.cwd()}`));let J=Dq();console.log(U.gray(` studio server: ${J??"not found"}`))}s.name("spacetime-studio").description("A local web-based database studio for SpacetimeDB databases").version("0.0.1").argument("[database]","Database name to connect to").option("-d, --db <database>","Database name to connect to").option("-p, --port <port>","Port to run studio on",String(f1)).option("-h, --host <host>","Host to bind to",v1).option("--dev","Run in development mode with hot reload").option("--debug","Show debug information about paths").action(async(q,z)=>{let J=q||z.db;if(z.debug)u1(),H.exit(0);if(!J)console.error(U.red("Error: Database name is required")),console.log(U.gray("Usage: spacetime-studio <database>")),console.log(U.gray(" spacetime-studio --db <database>")),H.exit(1);let Q=parseInt(z.port,10),X=z.host,Z=z.dev;console.log(U.cyan(`
29
+ SpacetimeDB Studio
30
+ `)),console.log(U.gray(` Database: ${U.white(J)}`)),console.log(U.gray(` Host: ${X}`)),console.log(U.gray(` Port: ${Q}`)),console.log(U.dim(`
31
+ Validating database...`));let $=await g1(J);if(!$.valid)console.error(U.red(`
32
+ Error: ${$.error}`)),console.log(U.gray(`
33
+ Make sure:`)),console.log(U.gray(" 1. SpacetimeDB is running: spacetime start")),console.log(U.cyan(` 2. Database exists: spacetime publish ${J}`)),H.exit(1);if(console.log(U.green(` \u2713 Database "${J}" found`)),$.tables!==void 0)console.log(U.dim(` ${$.tables} table(s), ${$.reducers} reducer(s)`));let G=`http://${X}:${Q}`;if(console.log(U.green(`
34
+ Studio running at: ${U.bold(G)}`)),Z)console.log(U.dim(" Mode: development (hot reload enabled)"));console.log(U.gray(` Press Ctrl+C to stop
35
+ `));let W={...H.env,SPACETIME_DB:J,PORT:String(Q),HOST:X,NODE_ENV:"production"};if(Z){let B=h1();if(!B)console.error(U.red(`
36
+ Error: Studio source not found for dev mode.`)),console.log(U.gray(" Run from the monorepo root with apps/studio built.")),H.exit(1);let Y=t("bun",["run","dev"],{cwd:B,env:{...W,NODE_ENV:"development"},stdio:"inherit",shell:!0});Y.on("error",(M)=>{console.error(U.red(`Server error: ${M.message}`)),H.exit(1)}),H.on("SIGINT",()=>{console.log(U.yellow(`
37
+ Shutting down...`)),Y.kill(),H.exit(0)})}else{let B=Dq();if(!B)console.error(U.red(`
38
+ Error: studio-server not found.`)),console.log(U.gray(`
39
+ Build the studio first:`)),console.log(U.cyan(" bun run build")),H.exit(1);let Y=t("bun",["run",B],{env:W,stdio:"inherit"});Y.on("error",(M)=>{console.error(U.red(`
40
+ Server error: ${M.message}`)),H.exit(1)}),H.on("SIGINT",()=>{console.log(U.yellow(`
41
+ Shutting down...`)),Y.kill(),H.exit(0)})}});async function g1(q){return new Promise((z)=>{let J=t("spacetime",["describe",q,"--json"],{stdio:["ignore","pipe","pipe"]}),Q="",X="";J.stdout.on("data",(Z)=>{Q+=Z.toString()}),J.stderr.on("data",(Z)=>{X+=Z.toString()}),J.on("close",(Z)=>{if(Z!==0){let $=X.trim()||`Database "${q}" not found`;z({valid:!1,error:$.includes("not find")||$.includes("failed to find")||$.includes("Connection refused")?`"${q}" - Check if SpacetimeDB is running (spacetime start) and database exists (spacetime publish ${q})`:$});return}try{let $=JSON.parse(Q);z({valid:!0,tables:$.tables?.length??0,reducers:$.reducers?.length??0})}catch{z({valid:!0})}}),J.on("error",(Z)=>{z({valid:!1,error:`Failed to run spacetime CLI: ${Z.message}. Is SpacetimeDB installed?`})})})}s.parse();
@@ -0,0 +1,3 @@
1
+ function e(e){return Array.from(new Set(e))}function t(e,t){let r=n();return r[e]??(r[e]=t)}function n(){var e;return globalThis._vike??(globalThis._vike={}),(e=globalThis._vike).globals??(e.globals={}),globalThis._vike.globals}var r=new Proxy({},{get:(e,t)=>e=>t===`code`?`\`${e}\``:t===`string`?`'${e}'`:e}),i=`0.4.255`,a;a??=o();function o(){return t(`utils/assertSingleInstance.ts`,{instances:[],alreadyLogged:new Set})}function s(){return a??=o(),a}var c=`Client runtime of both Server Routing and Client Routing loaded https://vike.dev/client-runtimes-conflict`,l=`Client runtime loaded twice https://vike.dev/client-runtime-duplicated`;function u(){let t=s();{let n=e(t.instances);p(n.length<=1,`vike@${r.bold(n[0])} and vike@${r.bold(n[1])} loaded which is highly discouraged ${r.underline(`https://vike.dev/warning/version-mismatch`)}`,{onlyOnce:!0,showStackTrace:!1})}t.checkSingleInstance&&t.instances.length>1&&p(!1,l,{onlyOnce:!0,showStackTrace:!0})}function d(e){let t=s();p(t.isClientRouting!==!1,c,{onlyOnce:!0,showStackTrace:!0}),p(t.isClientRouting===void 0,l,{onlyOnce:!0,showStackTrace:!0}),t.isClientRouting=!0,e&&(t.checkSingleInstance=!0),u()}function f(){s().instances.push(i),u()}function p(e,t,{onlyOnce:n,showStackTrace:r}){let i=s();if(e)return;let a=`[Vike][Warning] ${t}`;if(n){let{alreadyLogged:e}=i,t=n===!0?a:n;if(e.has(t))return;e.add(t)}r?console.warn(Error(a)):console.warn(a)}function m(){return!(typeof process>`u`||!process.cwd||!process.versions||process.versions.node===void 0||!process.release||process.release.name!==`node`)}function ee(e,t){let n=Error(e);return m()&&(n.stack=h(n.stack,t)),n}function h(e,t){if(!e)return e;let n=ne(e),r=0;return n.filter(e=>e.includes(` (internal/`)||e.includes(` (node:internal`)?!1:r<t&&te(e)?(r++,!1):!0).join(`
2
+ `)}function te(e){return e.startsWith(` at `)}function ne(e){return e.split(/\r?\n/)}function re(e){return r.bold(r.yellow(e))}function ie(e){return r.bold(r.red(e))}function ae(e){return r.yellow(e)}var g=t(`utils/assert.ts`,{alreadyLogged:new Set});f();var oe=`[vike]`,se=`[vike@${i}]`,ce=`Bug`;function _(e,t){if(e)return;let n=(()=>{if(!t)return null;let e=typeof t==`string`?t:JSON.stringify(t);return r.dim(`Debug for maintainers (you can ignore this): ${e}`)})(),i=[`You stumbled upon a Vike bug. Go to ${r.underline(`https://github.com/vikejs/vike/issues/new?template=bug.yml`)} and copy-paste this error. A maintainer will fix the bug (usually within 24 hours).`,n].filter(Boolean).join(` `);i=b(i,ce,!0);let a=me(i);throw g.onBeforeLog?.(),g.onBeforeErr?.(a),a}function v(e,t,{showStackTrace:n,exitOnError:r}={}){if(e)return;n||=g.alwaysShowStackTrace,t=b(t,`Wrong Usage`);let i=me(t);if(g.onBeforeLog?.(),g.onBeforeErr?.(i),r)console.error(n?i:t),process.exit(1);else throw i}function le(e){return e=b(e,`Error`),me(e)}function y(e,t,{onlyOnce:n,showStackTrace:r}){if(e)return;if(r||=g.alwaysShowStackTrace,n){let{alreadyLogged:e}=g,r=n===!0?t:n;if(e.has(r))return;e.add(r)}let i=b(t,`Warning`);if(g.onBeforeLog?.(),r){let e=me(i);g.onBeforeErr?.(e),console.warn(e)}else console.warn(i)}function ue(e,t,{onlyOnce:n}){if(!e){if(t=b(t,null),n){let{alreadyLogged:e}=g,n=t;if(e.has(n))return;e.add(n)}g.onBeforeLog?.(),console.log(t)}}function b(e,t,n=!1){let r=pe(n),i=fe(t),a=de(e);return g.addAssertTagsDev?`${g.addAssertTagsDev(r,i)}${a}${e}`:`${`${r}${i}`}${a}${e}`}function de(e){return e.startsWith(`[`)?``:` `}function fe(e){if(!e)return``;let t=`[${e}]`;return t=e===`Warning`?ae(t):ie(t),t}function pe(e=!1){return re(e?se:oe)}function me(e){let t=ee(e,3);return g.addAssertTagsDev&&(t.stack=t.stack?.replace(/^Error:\s*/,``)),t}function he(e){let t=e/1e3;if(t<120){let e=ge(t);return`${e} second${_e(e)}`}{let e=ge(t/60);return`${e} minute${_e(e)}`}}function ge(e){let t=e.toFixed(1);return t.endsWith(`.0`)&&(t=t.slice(0,-2)),t}function _e(e){return e===`1`?``:`s`}function x(e){return typeof e==`object`&&!!e}function S(e){return Array.isArray(e)}function ve(e,t){let n=t.find(t=>t.pageId===e);return _(t.length>0),_(n),n}function ye(e){if(!e||S(e)||e.definedBy)return null;let{filePathToShowToUser:t}=e;return _(t),t}function be(e){let t=ye(e);return _(t),t}function xe(e){return[null,void 0].includes(e)?String(e):[`boolean`,`number`,`string`].includes(typeof e)?JSON.stringify(e):null}function Se(e,t){if(!e)return null;let[n,...r]=e;if(!n||r.length===0&&[`*`,`default`,t].includes(n))return null;_(n!==`*`);let i=``,a=``;return n===`default`?i=`export default`:(i=`export`,r=[n,...r]),r.forEach(e=>{i=`${i} { ${e}`,a=` }${a}`}),i+a}function Ce(e,t,n){return`${Te(e,t)} at ${C(n,t)}`}function we(e,t,n){return n?`${Te(e,t)} at ${C(n,t)}`:`${Te(e,t)} internally`}function Te(e,t){return`${e} ${r.cyan(t)} defined`}function C(e,t){let n;return n=S(e)?e:[e],_(n.length>=1),n.map(e=>{if(e.definedBy)return Ee(e,t);let{filePathToShowToUser:n,fileExportPathToShowToUser:i}=e,a=Se(i,t);return a?`${n} > ${r.cyan(a)}`:n}).join(` / `)}function Ee(e,t){if(e.definedBy===`api`)return`API call ${r.cyan(`${e.operation}({ vikeConfig: { ${t} } })`)}`;let{definedBy:n}=e;if(n===`cli`)return`CLI option ${r.cyan(`--${t}`)}`;if(n===`env`)return`environment variable ${r.cyan(`VIKE_CONFIG="{${t}}"`)}`;_(!1)}function De(e,t,n){let{value:r,definedAtData:i}=e;return n&&Oe(r,n,t,i),e}function Oe(e,t,n,i){_(e!==null);let a=typeof e;if(a===t)return;let o=xe(e),s=o===null?`type ${r.cyan(a)}`:`value ${r.cyan(o)}`;v(!1,`${we(`Config`,n,i)} has an invalid ${s}: it should be a ${r.cyan(t)} instead`)}function w(e,t,n){let r=e.configValues[t];return r?De(r,t,n):null}function T(e){return e instanceof Function||typeof e==`function`}var ke=t(`hooks/getHook.ts`,{});function Ae(e,t){if(!(t in e.exports))return null;let{hooksTimeout:n}=e.config,r=Le(n,t),i=e.exports[t];if(i===null)return null;let a=e.exportsAll[t][0];_(a.exportValue===i);let o=a.filePath;return _(o),E(i,t,o,r)}function je(e,t){let{hooksTimeout:n}=t.config,r=Le(n,e),i=[];return t.exportsAll[e]?.forEach(t=>{let n=t.exportValue;if(n===null)return;let a=t.filePath;_(a),i.push(E(n,e,a,r))}),i}function Me(e,t){let n=e.configValues[t];if(!n?.value)return null;let{hookFn:r,hookFilePath:i}=Fe(n);return E(r,t,i,Pe(t))}function Ne(e,t){let n=e.configValues[t];if(!n?.value)return[];let r=n.value;return _(S(r)),r.map((e,r)=>{let i=e,a=Pe(t);return _(S(n.definedAtData)),E(i,t,be(n.definedAtData[r]),a)})}function Pe(e){return D(e)}function E(e,t,n,r){return _(n),Ie(e,{hookName:t,hookFilePath:n}),{hookFn:e,hookName:t,hookFilePath:n,hookTimeout:r}}function Fe(e){let t=e.value;return _(t),{hookFn:t,hookFilePath:be(e.definedAtData)}}function Ie(e,{hookName:t,hookFilePath:n}){_(t&&n),_(!t.endsWith(`)`)),_(!n.endsWith(` `)),v(T(e),`Hook ${t}() defined by ${n} should be a function`)}function Le(e,t){let n=Re(e);if(n===!1)return{error:!1,warning:!1};let r=n[t],i=D(t);return r?.error!==void 0&&(i.error=r.error),r?.warning!==void 0&&(i.warning=r.warning),i}function Re(e){if(e===void 0)return{};if(e===!1)return!1;v(x(e),`Setting ${r.cyan(`hooksTimeout`)} should be ${r.cyan(`false`)} or an object`);let t={};return Object.entries(e).forEach(([e,n])=>{if(n===!1){t[e]={error:!1,warning:!1};return}v(x(n),`Setting ${r.cyan(`hooksTimeout.${e}`)} should be ${r.cyan(`false`)} or an object`);let[i,a]=[`error`,`warning`].map(t=>{let i=n[t];if(i===void 0||i===!1)return i;let a=`Setting ${r.cyan(`hooksTimeout.${e}.${t}`)} should be`;return v(typeof i==`number`,`${a} ${r.cyan(`false`)} or a number`),v(i>0,`${a} a positive number`),i});t[e]={error:i,warning:a}}),t}function D(e){return e===`onBeforeRoute`?{error:5*1e3,warning:1*1e3}:ke.isPrerendering?{error:120*1e3,warning:30*1e3}:(_(!e.toLowerCase().includes(`prerender`)),{error:30*1e3,warning:4*1e3})}function ze(e,t){let n=Object.getOwnPropertyDescriptor(e,t);return!!n&&!(`value`in n)&&!!n.get}function Be(e){Ve(e)}function Ve(e){if(e.is404===void 0||e.is404===null)return;let t=e.pageProps||{};if(!x(t)){y(!1,`pageContext.pageProps should be an object`,{showStackTrace:!0,onlyOnce:!0});return}t.is404=t.is404||e.is404,e.pageProps=t}function He(e){return typeof e==`string`&&Ue(e)?`.${e}`:`[${JSON.stringify(e)}]`}function Ue(e){return/^[a-z0-9\$_]+$/i.test(e)}function O(){return Object.getOwnPropertyDescriptor(globalThis,`window`)?.get?.toString().includes(`[native code]`)??!1}function We(e,t,n,r){return new Proxy(e,{get:(i,a)=>Ge(a,e,t,n,r)})}function Ge(e,...t){let[n,r,i,a]=t,o=String(e);if(e===`_isProxyObject`)return!0;if(e===`dangerouslyUseInternals`)return t[2]=!0,We(...t);if(e===`_originalObject`)return n;if(a&&!(e in n))return a(e);let s=n[e];return Ke(o,s,r),s}function Ke(e,t,n){if(t!==`__VIKE__NOT_SERIALIZABLE__`)return;let r=He(e);_(O()),v(!1,`Can't access ${n}${r} on the client side. Because it can't be serialized, see server logs.`)}function qe(e){return _(e._isOriginalObject),We(e,`globalContext`)}function k(e){_(!e._isProxyObject),_(!e.globalContext),_(e._isOriginalObject),Be(e),`_pageId`in e||Object.defineProperty(e,`_pageId`,{get(){return y(!1,`pageContext._pageId has been renamed to pageContext.pageId`,{showStackTrace:!0,onlyOnce:!0}),e.pageId},enumerable:!1});let t=qe(e._globalContext);return We(e,`pageContext`,!0,e=>{if(e===`globalContext`)return t;if(e in t)return t[e]})}function Je(e){[`urlPathname`,`urlParsed`,`url`,`pageExports`].forEach(t=>{e.prop&&_(ze(e,t))})}var A=t(`utils/execHook.ts`,{userHookErrors:new WeakMap,pageContext:null});async function Ye(e,t,n){return await Ze(je(e,t),t,n)}async function Xe(e,t,n){let r=Ne(t._pageConfigGlobal,e),i=n(t);await Promise.all(r.map(async e=>{await tt(()=>e.hookFn(i),e,t,null)}))}async function Ze(e,t,n){if(!e.length)return[];let r=n(t);return await Promise.all(e.map(async e=>{let n=await tt(()=>e.hookFn(r),e,t._globalContext,r);return{...e,hookReturn:n}}))}async function Qe(e,t,n){let{hookReturn:r}=(await Ze([e],t,n))[0];v(r===void 0,`The ${e.hookName}() hook defined by ${e.hookFilePath} isn't allowed to return a value`)}function $e(e){return x(e)?A.userHookErrors.get(e)??!1:!1}function et(e,t,n,r,i){let a=n&&r(n);return i??=()=>e.hookFn(a),{hookReturn:nt(i,e,t,a)}}function tt(e,t,n,r){let{hookName:i,hookFilePath:a,hookTimeout:{error:o,warning:s}}=t,c,l,u=new Promise((e,t)=>{c=t=>{d(),e(t)},l=e=>{d(),t(e)}}),d=()=>{f&&clearTimeout(f),p&&clearTimeout(p)},f=rt(s)&&setTimeout(()=>{y(!1,`The ${i}() hook defined by ${a} is slow: it's taking more than ${he(s)} (https://vike.dev/hooksTimeout)`,{onlyOnce:!1})},s),p=rt(o)&&setTimeout(()=>{let e=le(`The ${i}() hook defined by ${a} timed out: it didn't finish after ${he(o)} (https://vike.dev/hooksTimeout)`);l(e)},o);return(async()=>{try{let i=await nt(e,t,n,r);c(i)}catch(e){x(e)&&A.userHookErrors.set(e,{hookName:i,hookFilePath:a}),l(e)}})(),u}function nt(e,t,n,r){let{hookName:i,hookFilePath:a}=t;_(i!==`onHookCall`);let o=n._pageConfigGlobal.configValues.onHookCall,s=()=>(ot(r),e());if(!o?.value)return s();let c=!1,l,u,d=()=>{c=!0;try{l=s()}catch(e){throw u=e,e}return l};for(let e of o.value){let t={name:i,filePath:a,call:d};d=()=>((async()=>{try{await e(t,r)}catch(e){e!==u&&console.error(e)}})(),v(c,`onHookCall() must run hook.call()`),l)}if(d(),u)throw u;return l}function rt(e){return!!e&&e!==1/0}function it(){let{pageContext:e}=A;return e?e._isProxyObject?e:k(e):null}function at(e){ot(e)}function ot(e){A.pageContext=e,Promise.resolve().then(()=>{A.pageContext=null})}var j={},st=99,ct=5*1e3;function lt(e){let t=new Date().getTime();Object.keys(j).forEach(e=>{t-j[e].startTime>ct&&delete j[e]});let n=j[e]??(j[e]={count:0,startTime:t});n.count++;let r=`${e} called ${n.count} times within ${he(ct)} — infinite loop?`;n.count>st&&v(!1,r),!n.warned&&n.count>st*.5&&(y(!1,r,{onlyOnce:!1,showStackTrace:!0}),n.warned=!0)}var ut=25*1e3;function dt({timeout:e=ut}={}){let t,n,r=!1,i=new Promise((e,i)=>{t=(...t)=>(r=!0,a(),e(...t)),n=(...e)=>(r=!0,a(),i(...e))}),a=()=>o.forEach(e=>clearTimeout(e)),o=[],s;return s=e?new Proxy(i,{get(t,n){if(n===`then`&&!r){let t=Error(`Promise hasn't resolved after ${he(e)}`);o.push(setTimeout(()=>{_(t.stack),y(!1,ft(t.stack),{onlyOnce:!1})},e))}let i=Reflect.get(t,n);return typeof i==`function`?i.bind(t):i}}):i,{promise:s,resolve:t,reject:n}}function ft(e){return e.startsWith(`Error: `)&&(e=e.slice(7)),e}function pt(e){return S(e)&&e.every(e=>typeof e==`string`)}function mt(e){return x(e)&&Object.values(e).every(e=>typeof e==`string`)}function M(e,t,n){if(!x(e))return!1;if(!(t in e))return n===`undefined`;if(n===void 0)return!0;let r=e[t];return n===`undefined`?r===void 0:n===`array`?S(r):n===`object`?x(r):n===`string[]`?pt(r):n===`string{}`?mt(r):n===`function`?T(r):S(n)?typeof r==`string`&&n.includes(r):n===`null`?r===null:n===`true`?r===!0:n===`false`?r===!1:typeof r===n}function N(e,t,n){t&&(n||_(!t._isOriginalObject),Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)))}function P(e){window.location.href=e}function F(e,t){_(e===t)}var ht=[I({is:e=>e===void 0,match:e=>e===`!undefined`,serialize:()=>`!undefined`,deserialize:()=>void 0}),I({is:e=>e===1/0,match:e=>e===`!Infinity`,serialize:()=>`!Infinity`,deserialize:()=>1/0}),I({is:e=>e===-1/0,match:e=>e===`!-Infinity`,serialize:()=>`!-Infinity`,deserialize:()=>-1/0}),I({is:e=>typeof e==`number`&&isNaN(e),match:e=>e===`!NaN`,serialize:()=>`!NaN`,deserialize:()=>NaN}),I({is:e=>e instanceof Date,match:e=>e.startsWith(`!Date:`),serialize:e=>`!Date:`+e.toISOString(),deserialize:e=>new Date(e.slice(6))}),I({is:e=>typeof e==`bigint`,match:e=>e.startsWith(`!BigInt:`),serialize:e=>`!BigInt:`+e.toString(),deserialize:e=>{if(typeof BigInt>`u`)throw Error(`Your JavaScript environement does not support BigInt. Consider adding a polyfill.`);return BigInt(e.slice(8))}}),I({is:e=>e instanceof RegExp,match:e=>e.startsWith(`!RegExp:`),serialize:e=>`!RegExp:`+e.toString(),deserialize:e=>{e=e.slice(8);let t=e.match(/\/(.*)\/(.*)?/),n=t[1],r=t[2];return new RegExp(n,r)}}),I({is:e=>e instanceof Map,match:e=>e.startsWith(`!Map:`),serialize:(e,t)=>`!Map:`+t(Array.from(e.entries())),deserialize:(e,t)=>new Map(t(e.slice(5)))}),I({is:e=>e instanceof Set,match:e=>e.startsWith(`!Set:`),serialize:(e,t)=>`!Set:`+t(Array.from(e.values())),deserialize:(e,t)=>new Set(t(e.slice(5)))}),I({is:e=>typeof e==`string`&&e.startsWith(`!`),match:e=>e.startsWith(`!`),serialize:e=>`!`+e,deserialize:e=>e.slice(1)})];function I(e){return e}function gt(e,t={}){return _t(JSON.parse(e),t)}function _t(e,t={}){return typeof e==`string`?vt(e,t):(typeof e==`object`&&e&&Object.entries(e).forEach(([n,r])=>{e[n]=_t(r,t)}),e)}function vt(e,t){let n=e=>gt(e,t);{let r=t.reviver?.(void 0,e,n);if(r){if(typeof r.replacement!=`string`)return r.replacement;if(e=r.replacement,r.resolved)return e}}for(let{match:t,deserialize:r}of ht)if(t(e))return r(e,n);return e}var yt=`vike_pageContext`,bt=`vike_globalContext`;function xt(){_(O())}St();function St(){xt()}function Ct(){let e=Tt(yt);return _(M(e,`pageId`,`string`)),_(M(e,`routeParams`,`string{}`)),e}function wt(){return Tt(bt)}function Tt(e){let t=document.getElementById(e);v(t,`Couldn't find #${e} (which Vike automatically injects in the HTML): make sure it exists (i.e. don't remove it and make sure your HTML isn't malformed)`);let n=t.textContent;return _(n),gt(n,{reviver(e,t){if(typeof t==`string`)return{replacement:t.replaceAll(`\\/`,`/`),resolved:!1}}})}function Et(e){return e==null}function Dt(e){return!Et(e)}function Ot(e,t){return At(e,t,!0)}function kt(e,t){return At(e,t,!1)}function At(e,t,n){let r=n?`CLIENT_ONLY`:`SERVER_ONLY`,i=e.filter(e=>e.isRelevant(t)&&e.fileType!==`.page.route`).sort(jt(n,t)),a=e=>{let n=i.filter(n=>n.pageId===t&&n.isEnv(e?`CLIENT_AND_SERVER`:r));v(n.length<=1,`Merge the following files into a single file: ${n.map(e=>e.filePath).join(` `)}`);let a=n[0];return _(a===void 0||!a.isDefaultPageFile),a},o=a(!1),s=a(!0),c=e=>i.filter(t=>t.isRendererPageFile&&t.isEnv(e?`CLIENT_AND_SERVER`:r))[0],l=c(!1),u=c(!0);return[o,s,...i.filter(e=>e.isDefaultPageFile&&!e.isRendererPageFile&&(e.isEnv(r)||e.isEnv(`CLIENT_AND_SERVER`))),l,u].filter(Dt)}function jt(e,t){let n=e?`CLIENT_ONLY`:`SERVER_ONLY`;return(e,r)=>{if(!e.isDefaultPageFile&&r.isDefaultPageFile)return-1;if(!r.isDefaultPageFile&&e.isDefaultPageFile)return 1;{let t=e.isRendererPageFile,n=r.isRendererPageFile;if(!t&&n)return-1;if(!n&&t)return 1;_(t===n)}{let n=Mt(t,e.filePath),i=Mt(t,r.filePath);if(n<i)return-1;if(i<n)return 1;_(n===i)}return e.isEnv(n)&&r.isEnv(`CLIENT_AND_SERVER`)?-1:r.isEnv(n)&&e.isEnv(`CLIENT_AND_SERVER`)?1:0}}function Mt(e,t){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];n++);let r=e.slice(n),i=t.slice(n);return r.split(`/`).length+i.split(`/`).length}async function Nt(e,t){let n=kt(e,t).filter(e=>e.fileType===`.page.server`);return await Promise.all(n.map(async e=>{e.exportNames||(_(e.loadExportNames,t),await e.loadExportNames())})),{hasOnBeforeRenderServerSideOnlyHook:n.some(({exportNames:e})=>(_(e),e.includes(`onBeforeRender`)))}}var Pt=[`urlPathname`,`urlParsed`],Ft=[`Page`,`pageExports`,`exports`];function It(e){[...Ft,...Pt].forEach(t=>{t in e&&(Pt.includes(t)?(_(t.startsWith(`url`)),y(!1,`pageContext.${t} is already available in the browser when using Client Routing; adding '${t}' to passToClient has no effect`,{onlyOnce:!0})):y(!1,`pageContext.${t} is a built-in that cannot be overridden; adding '${t}' to passToClient has no effect`,{onlyOnce:!0}),delete e[t])})}function L(e,t,n){return typeof e==`string`?Lt(e.split(``),t,n).join(``):Lt(e,t,n)}function Lt(e,t,n){let r=[],i=t>=0?t:e.length+t;_(i>=0&&i<=e.length);let a=n>=0?n:e.length+n;for(_(a>=0&&a<=e.length);!(i===a||(i===e.length&&(i=0),i===a));){let t=e[i];_(t!==void 0),r.push(t),i++}return r}function R(e,t){_($t(e),e),_(t.startsWith(`/`));let{hashString:n,withoutHash:r}=Rt(e);_(n===null||n.startsWith(`#`));let i=n===null?``:Bt(n.slice(1)),{searchString:a,withoutSearch:o}=zt(r);_(a===null||a.startsWith(`?`));let s=``;if(a!==null)s=a;else if(e.startsWith(`#`)){let e=Ut();s=e&&zt(e).searchString||``}let c={},l={};Array.from(new URLSearchParams(s)).forEach(([e,t])=>{c[e]=t,l[e]=[...l.hasOwnProperty(e)?l[e]:[],t]});let{protocol:u,origin:d,pathnameAbsoluteWithBase:f}=Ht(o,t),p=o.slice((d||``).length);Zt(e,d,p,a,n);let{pathname:m,isBaseMissing:ee}=Yt(f,t),h=Qt(d,m,a,n),{hostname:te,port:ne}=Gt(d?d.slice(u.length):null,e);return m=Vt(m),_(m.startsWith(`/`)),{href:h,protocol:u,hostname:te,port:ne,origin:d,pathname:m,pathnameOriginal:p,isBaseMissing:ee,search:c,searchAll:l,searchOriginal:a,hash:i,hashOriginal:n}}function Rt(e){let[t,...n]=e.split(`#`);return{hashString:[``,...n].join(`#`)||null,withoutHash:t}}function zt(e){let[t,...n]=e.split(`?`);return{searchString:[``,...n].join(`?`)||null,withoutSearch:t}}function Bt(e){try{return decodeURIComponent(e)}catch{}try{return decodeURI(e)}catch{}return e}function Vt(e){return e=e.replace(/\s+$/,``),e=e.split(`/`).map(e=>Bt(e).split(`/`).join(`%2F`)).join(`/`),e}function Ht(e,t){_(!e.includes(`?`)&&!e.includes(`#`));{let{protocol:t,origin:n,pathname:r}=Wt(e);if(n)return{protocol:t,origin:n,pathnameAbsoluteWithBase:r};_(r===e)}if(e.startsWith(`/`))return{protocol:null,origin:null,pathnameAbsoluteWithBase:e};{let n=Ut(),r;return r=n?Wt(n.split(`?`)[0].split(`#`)[0]).pathname:t,{protocol:null,origin:null,pathnameAbsoluteWithBase:Jt(e,r)}}}function Ut(){return typeof window<`u`?window?.document?.baseURI:void 0}function Wt(e){if(an(e)){let{protocol:t,uriWithoutProtocol:n}=Kt(e);_(t);let[r,...i]=n.split(`/`),a=t+r;return{pathname:`/`+i.join(`/`),origin:a,protocol:t}}else return{pathname:e,origin:null,protocol:null}}function Gt(e,t){let n={hostname:null,port:null};if(!e)return n;let r=e.split(`:`);if(r.length>1){let e=parseInt(r.pop(),10);_(e||e===0,t),n.port=e}return n.hostname=r.join(`:`),n}function Kt(e){let[t,...n]=e.split(`:`);if(n.length===0||!/^[a-z][a-z0-9\+\-]*$/i.test(t))return{protocol:null,uriWithoutProtocol:e};let r=t+`:`,i=n.join(`:`);return i.startsWith(`//`)&&(r+=`//`,i=i.slice(2)),{protocol:r,uriWithoutProtocol:i}}function qt(e){return[`ipfs://`,`ipns://`].includes(e)?!1:e.endsWith(`://`)}function Jt(e,t){let n=t.split(`/`),r=e.split(`/`),i=t.endsWith(`/`);e.startsWith(`.`)&&n.pop();for(let e in r){let t=r[e];t==``&&e===`0`||t!=`.`&&(t==`..`?n.pop():(i=!1,n.push(t)))}let a=n.join(`/`);return i&&!a.endsWith(`/`)&&(a+=`/`),a.startsWith(`/`)||(a=`/`+a),a}function Yt(e,t){_(e.startsWith(`/`)),_(Xt(t));let n=e;if(_(n.startsWith(`/`)),_(t.startsWith(`/`)),t===`/`)return{pathname:e,isBaseMissing:!1};let r=t;return t.endsWith(`/`)&&n===L(t,0,-1)&&(r=L(t,0,-1),_(n===r)),n.startsWith(r)?(_(n.startsWith(`/`)||n.startsWith(`http`)),_(n.startsWith(r)),n=n.slice(r.length),n.startsWith(`/`)||(n=`/`+n),_(n.startsWith(`/`)),{pathname:n,isBaseMissing:!1}):{pathname:e,isBaseMissing:!0}}function Xt(e){return e.startsWith(`/`)}function Zt(e,t,n,r,i){_(e===Qt(t,n,r,i))}function Qt(e,t,n,r){return`${e||``}${t}${n||``}${r||``}`}function $t(e){return en(e)||nn(e)}function en(e){return tn(e)||an(e)}function tn(e){return e.startsWith(`/`)}function nn(e){return[`.`,`?`,`#`].some(t=>e.startsWith(t))||e===``}function rn(e){return!e.startsWith(`/`)&&!nn(e)}function an(e){let{protocol:t}=Kt(e);return!!t&&qt(t)}function on(e,t){v(en(e),sn(e,t,!0))}function sn(e,t,n,i){let a=`${t} is ${r.string(e)} but it should start with ${r.string(`/`)}`;return n&&(a+=` or a protocol (e.g. ${r.string(`http://`)})`),i&&(a+=`, or be ${r.string(`*`)}`),a}function cn(e,t,n){let{pathnameOriginal:r,searchOriginal:i,hashOriginal:a}=R(e,`/`);e.startsWith(`/`)&&_(e===`${r}${i||``}${a||``}`,{url:e});let o=r.endsWith(`/`),s;return n&&r!==`/`?(s=o?L(r,0,-1):r,_(!s.endsWith(`/`),{url:e}),_(s!==``)):s=r+(o?``:`/`)+`index`,_(s),s+=t,`${s}${i||``}${a||``}`}var ln=`.pageContext.json`;function un(e){return cn(e,ln,!1)}function z(e){return typeof e!=`object`||!e?!1:Object.getPrototypeOf(e)===null?!0:e.constructor.name===`Object`}function dn(e,{hookName:t,hookFilePath:n}){if(e==null)return;_(!t.endsWith(`)`));let i=`The ${r.cyan(`pageContext`)} object provided by the ${t}() hook defined by ${n}`;v(x(e),`${i} should be an object (but it's ${r.cyan(`typeof pageContext === ${JSON.stringify(typeof e)}`)} instead)`),v(!(`isPageContext`in e),`${i} shouldn't be the whole ${r.cyan(`pageContext`)} object, see https://vike.dev/pageContext-manipulation#do-not-return-entire-pagecontext`),y(!(`pageId`in e),`${i} sets ${r.cyan(`pageContext.pageId`)} which means that Vike's routing is overridden. This is an experimental feature: make sure to contact a vike maintainer before using this.`,{onlyOnce:!0}),v(!(`is404`in e),`${i} sets ${r.cyan(`pageContext.is404`)} which is forbidden, use ${r.cyan(`throw render()`)} instead, see https://vike.dev/render`)}function fn(e){return`[`+e.map(e=>`'`+e+`'`).join(`, `)+`]`}function pn(e,t,n){_(!n.endsWith(` `));let r=[],i=Object.keys(e);for(let e of i)t.includes(e)||r.push(e);v(r.length===0,[n,`returned an object with following unknown keys:`,fn(r)+`.`,`Only following keys are allowed:`,fn(t)+`.`].join(` `))}function mn(e,t){if(e==null)return;let n=`The onBeforeRender() hook defined by ${t}`;v(z(e),`${n} should return a plain JavaScript object, ${r.cyan(`undefined`)}, or ${r.cyan(`null`)}`),pn(e,[`pageContext`],n),e.pageContext&&dn(e.pageContext,{hookName:`onBeforeRender`,hookFilePath:t})}var hn=`The guard() hook defined by`;async function gn(e,t){let n;e._globalContext._pageFilesAll.length>0?(_(e._globalContext._pageConfigs.length===0),n=_n(e.pageId,e._globalContext._pageFilesAll)):n=Ae(e,`guard`),n&&await Qe(n,e,t)}function _n(e,t){let n=t.find(t=>t.pageId===e&&t.fileType===`.page.route`);if(!n)return null;let{filePath:r,fileExports:i}=n;_(i);let a=i.guard;if(!a)return null;let o=r,s=D(`guard`);return v(T(a),`${hn} ${o} should be a function`),{hookFn:a,hookName:`guard`,hookFilePath:o,hookTimeout:s}}function vn(e,t,n=e=>e){if(_(e.length>0),e.length===1)return n(e[0]);let r=e.slice(0,e.length-1),i=e[e.length-1],a=e.length>2?`,`:``;return r.map(n).join(`, `)+`${a} ${t} `+n(i)}function yn(e){let t=Error(`AbortRender`);return N(t,{_pageContextAbort:e,[bn]:!0}),t}var bn=`_isAbortError`;function xn(e){return typeof e==`object`&&!!e&&bn in e}function Sn(e){return e._urlRewrite||e._urlRedirect||e.abortStatusCode?(_(M(e,`_abortCall`,`string`)),!0):!1}function Cn(e,t,n){if(t)return;let i=n._urlRewrite??n.urlOriginal;_(i);let a=e._pageContextAbort._abortCall;_(a);let o=$e(e),s=``;o&&(s=` by ${r.cyan(`${o.hookName}()`)} hook defined at ${o.hookFilePath}`),ue(!1,`${r.cyan(a)} thrown${s} while rendering ${r.cyan(i)}`,{onlyOnce:!1})}function wn(e){let t=e.at(-1);if(!t)return null;let n=t._pageContextAbort;return _(n),n}function Tn(e,t,n){N(t,{_pageContextAbort:n}),e.push(t),En(e)}function En(t){if(t.length<10)return;let n=t.map(e=>e._pageContextAbort._abortCall);e(n).length!==n.length&&v(!1,`Infinite loop: ${n.join(` => `)}`)}var Dn=`_isServerSideError`;function On(e){return N(e,{Page:e.config?.Page||e.exports?.Page}),Je(e),An(e),kn(e)}function kn(e){return k(e)}function An(e){jn(e)}function jn(e){Object.entries(e).forEach(([t,n])=>{delete e[t],e[t]=n})}function B(e){return On(e)}var Mn=t(`getPageContextFromHooks.ts`,{}),Nn=[`guard`,`data`,`onBeforeRender`];function Pn(){let e=Ct();return Jn(e),N(e,{_hasPageContextFromServer:!0}),e}async function Fn(e){for(let t of Nn)Gn(t,e)&&(t===`guard`?await Xn(e):await zn(t,e));return e}async function In(e,t){let n={_hasPageContextFromServer:!1};if(!t&&await Un(e)){let t=await qn(e);if(`is404ServerSideRouted`in t)return{is404ServerSideRouted:!0};let{pageContextFromServer:r}=t;n._hasPageContextFromServer=!0,_(!(Dn in r)),_(!(`serverSideError`in r)),N(n,r)}return{pageContextFromHooksServer:n}}async function Ln(e,t){let n=!1;for(let r of Nn)if(!(!Gn(r,e)&&e._hasPageContextFromServer))if(r===`guard`){if(t)continue;await Xn(e)}else r===`data`&&(n=!0),await zn(r,e);let r=Kn(`data`,e);return(n&&r.client||e._hasPageContextFromServer&&r.server)&&await Rn(`onData`,e),e}async function Rn(e,t){return await Ye(e,t,e=>B(e))}async function zn(e,t){let n;n=e===`data`?await Bn(t):await Vn(t),Object.assign(t,n)}async function Bn(e){let t=(await Rn(`data`,e))[0];if(!t)return;let{hookReturn:n}=t;return{data:n}}async function Vn(e){let t=(await Rn(`onBeforeRender`,e))[0];if(!t)return;let{hookReturn:n,hookFilePath:r}=t,i={};mn(n,r);let a=n?.pageContext;return a&&N(i,a),i}function Hn(e){e._pageContextInitIsPassedToClient&&(Mn.pageContextInitIsPassedToClient=!0)}async function Un(e){if(Yn(e)){let{hasOnBeforeRenderServerSideOnlyHook:t}=await Nt(e._pageFilesAll,e.pageId);return t}return!!Mn.pageContextInitIsPassedToClient||Wn(e)}function Wn(e){if(Yn(e))return!1;let t=w(ve(e.pageId,e._globalContext._pageConfigs),`hasServerOnlyHook`)?.value;return _(t===!0||t===!1),t}function Gn(e,t){let n=Kn(e,t);return!!n.client&&!n.server}function Kn(e,t){return Yn(t)?{client:!1,server:!0}:w(ve(t.pageId,t._globalContext._pageConfigs),`${e}Env`)?.value??{}}async function qn(e){let t=un(e._urlRewrite??e.urlOriginal),n=await fetch(t);{let r=n.headers.get(`content-type`),i=`application/json`,a=r&&r.includes(i);if(!a&&n.status===404)return P(e.urlOriginal),{is404ServerSideRouted:!0};v(a,`Wrong Content-Type for ${t}: it should be ${i} but it's ${r} instead. Make sure to properly use pageContext.httpResponse.headers, see https://vike.dev/renderPage`)}let r=gt(await n.text());if(_(x(r)),Sn(r))throw yn(r);if(`serverSideError`in r||`_isServerSideError`in r)throw le(`pageContext couldn't be fetched because an error occurred on the server-side`);return Jn(r),{pageContextFromServer:r}}function Jn(e){v(!(`urlOriginal`in e),`Adding 'urlOriginal' to passToClient is forbidden`),_(M(e,`pageId`,`string`)),It(e)}function Yn(e){return e._globalContext._pageConfigs.length===0}async function Xn(e){await gn(e,e=>B(e))}function V(e,t,n){let r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(e,t,{...r,enumerable:n})}function Zn(e,t){return N(e,t),e}function Qn(){let e={_isOriginalObject:!0,isPageContext:!0};return V(e,`_isOriginalObject`,!1),e}function H(e,t,{get:n,...r}){Object.defineProperty(e,t,{...r,get:n})}function $n(e){_(typeof e.urlOriginal==`string`),Je(e);let t={};return H(t,`urlPathname`,{get:tr,enumerable:!0,configurable:!0}),H(t,`url`,{get:nr,enumerable:!1,configurable:!0}),H(t,`urlParsed`,{get:rr,enumerable:!0,configurable:!0}),t}function er(e){let t=e=>_(typeof n==`string`,{src:e,urlResolved:n}),n,r;e.urlLogical?(n=e.urlLogical,r=!1,t(1)):e._urlRewrite?(n=e._urlRewrite,r=!1,t(2)):(n=e.urlOriginal,r=!0,t(3)),t(4);let i=e._urlHandler;i||=e=>e,n=i(n);let a=r?e._baseServer:`/`;return R(n,a)}function tr(){let{pathname:e}=er(this),t=e;return _(t.startsWith(`/`)),t}function nr(){return y(!1,"`pageContext.url` is outdated. Use `pageContext.urlPathname`, `pageContext.urlParsed`, or `pageContext.urlOriginal` instead. (See https://vike.dev/migration/0.4.23 for more information.)",{onlyOnce:!0,showStackTrace:!0}),tr.call(this)}function rr(){let{isBaseMissing:e,...t}=er(this),n=O(),r=e=>{y(n,`pageContext.urlParsed.${e} isn't available on the server-side (HTTP requests don't include the URL hash)`,{onlyOnce:!0,showStackTrace:!0})},i={...t,get hash(){return r(`hash`),t.hash},get hashOriginal(){return r(`hashOriginal`),t.hashOriginal},get hashString(){return y(!1,`pageContext.urlParsed.hashString has been renamed to pageContext.urlParsed.hashOriginal`,{onlyOnce:!0,showStackTrace:!0}),r(`hashString`),t.hashOriginal},get searchString(){return y(!1,`pageContext.urlParsed.searchString has been renamed to pageContext.urlParsed.searchOriginal`,{onlyOnce:!0,showStackTrace:!0}),t.searchOriginal}};return V(i,`hashString`,!1),V(i,`searchString`,!1),n||(V(i,`hash`,!1),V(i,`hashOriginal`,!1)),i}function ir(){return _(ar(`/`)),`/`}function ar(e){return e.startsWith(`/`)}function or(e,t,n){Object.keys(e).filter(e=>!n?.includes(e)).forEach(t=>delete e[t]),Object.defineProperties(e,Object.getOwnPropertyDescriptors(t))}var sr=[`clientRouting`];function cr(e){sr.forEach(t=>{if(_(e.fileExports),!(t in e.fileExports))return;let n=`The value of \`${t}\` is only allowed to be \`true\`.`;v(e.fileExports[t]!==!1,`${e.filePath} has \`export { ${t} }\` with the value \`false\` which is prohibited: remove \`export { ${t} }\` instead. (${n})`),v(e.fileExports[t]===!0,`${e.filePath} has \`export { ${t} }\` with a forbidden value. ${n}`)})}var lr=[`render`,`clientRouting`,`prerender`,`doNotPrerender`];function ur(e,t){v(!lr.includes(e),`${t} has \`export default { ${e} }\` which is prohibited, use \`export { ${e} }\` instead.`)}function dr(e){let t=`.page.`,n=L(e.split(t),0,-1).join(t);return _(!n.includes(`\\`)),n}function fr(t,n){if(n.length>0){let e=n.filter(e=>e.isErrorPage);return e.length===0?null:(v(e.length===1,`Only one error page can be defined`),e[0].pageId)}let r=e(t.map(({pageId:e})=>e).filter(e=>U(e,!1)));if(v(r.length<=1,`Only one _error.page.js is allowed, but found several: ${r.join(` `)}`),r.length>0){let e=r[0];return _(e),e}return null}function U(e,t){return _(!e.includes(`\\`)),e.includes(`/_error`)}var pr=[`js`,`cjs`,`mjs`],mr=[`ts`,`cts`,`mts`],hr=[...pr,...mr],gr=[`jsx`,`cjsx`,`mjsx`],_r=[`tsx`,`ctsx`,`mtsx`],vr=[...gr,..._r],yr=[`vue`,`svelte`,`marko`,`md`,`mdx`],br=[...hr,...vr,...yr];``+br.join(`,`);function xr(e){return br.some(t=>e.endsWith(`.`+t))}function Sr(e){return yr.some(t=>e.endsWith(`.`+t))}var Cr=[`.page`,`.page.server`,`.page.route`,`.page.client`,`.css`];function wr(e){if(e.endsWith(`.css`))return`.css`;_(xr(e),e);let t=e.split(`/`).slice(-1)[0].split(`.`),n=t.slice(-3)[0],r=t.slice(-2)[0];if(r===`page`)return`.page`;if(_(n===`page`,e),r===`server`)return`.page.server`;if(r===`client`)return`.page.client`;if(r===`route`)return`.page.route`;_(!1,e)}function Tr(e){let t=e=>r.pageId===e||r.isDefaultPageFile&&(Dr(r.filePath)||Or(e,r.filePath)),n=wr(e),r={filePath:e,fileType:n,isEnv:e=>{if(_(n!==`.page.route`),e===`CLIENT_ONLY`)return n===`.page.client`||n===`.css`;if(e===`SERVER_ONLY`)return n===`.page.server`;if(e===`CLIENT_AND_SERVER`)return n===`.page`;_(!1)},isRelevant:t,isDefaultPageFile:Er(e),isRendererPageFile:n!==`.css`&&Er(e)&&Dr(e),isErrorPageFile:U(e,!1),pageId:dr(e)};return r}function Er(e){return U(e,!1)?!1:e.includes(`/_default`)}function Dr(e){return e.includes(`/renderer/`)}function Or(e,t){_(!e.endsWith(`/`)),_(!t.endsWith(`/`)),_(Er(t));let n=L(t.split(`/`),0,-1).filter(e=>e!==`_default`).join(`/`);return e.startsWith(n)}var kr=[`$$registrations`,`_rerender_only`],Ar=[`.md`,`.mdx`];function jr(e,t,n){let i=Object.keys(e),a=e=>e===`default`||e===n,o=i.filter(a),s=r.code(`export default`),c=r.code(`export { ${n} }`);o.length===0&&v(!1,`${t} should define ${c} or ${s}`),o.length===2&&v(!1,`${t} is ambiguous: remove ${s} or ${c}`),_(o.length===1);let l=i.filter(e=>!a(e)).filter(e=>!kr.includes(e));Ar.some(e=>t.endsWith(e))||l.forEach(e=>{y(!1,`${t} unexpected ${r.cyan(`export { ${e} }`)}, see https://vike.dev/no-side-exports`,{onlyOnce:!0})})}function Mr(e,t){let n=e.map(e=>{let t=Pr(e.configValuesSerialized);return Nr(t),{...e,configValues:t}}),r={configValues:{}};{let e=Pr(t.configValuesSerialized);Object.assign(r.configValues,e)}return{pageConfigs:n,pageConfigGlobal:r}}function Nr(e){let t=`route`,n=e[t];if(!n)return;let{value:r,definedAtData:i}=n,a=typeof r;_(i);let o=Ce(`Config`,t,i);v(a===`string`||T(r),`${o} has an invalid type '${a}': it should be a string or a function instead, see https://vike.dev/route`)}function Pr(e){let t={};return Object.entries(e).forEach(([e,r])=>{let i;if(r.type===`cumulative`){let{valueSerialized:t,...a}=r;i={value:t.map((t,i)=>{let{value:a,sideExports:o}=Fr(t,e,()=>{let e=r.definedAtData[i];return _(e),e});return n(o),a}),...a}}else{let{valueSerialized:t,...a}=r,{value:o,sideExports:s}=Fr(t,e,()=>{_(r.type!==`computed`);let{definedAtData:e}=r;return Array.isArray(e)?e[0]:e});n(s),i={value:o,...a}}t[e]=i}),t;function n(e){e.forEach(e=>{let{configName:n,configValue:r}=e;t[n]||(t[n]=r)})}}function Fr(e,t,n){if(e.type===`js-serialized`){let{value:t}=e;return t=_t(t),{value:t,sideExports:[]}}if(e.type===`pointer-import`){let{value:t}=e;return{value:t,sideExports:[]}}if(e.type===`plus-file`){let r=n(),{exportValues:i}=e;_(!r.definedBy),jr(i,r.filePathToShowToUser,t);let a,o=!1,s=[];return Object.entries(i).forEach(([e,n])=>{e!==`default`&&e!==t?s.push({configName:e,configValue:{type:`standard`,value:n,definedAtData:{filePathToShowToUser:r.filePathToShowToUser,fileExportPathToShowToUser:[e]}}}):(a=n,_(!o),o=!0)}),_(o),{value:a,sideExports:s}}_(!1)}function Ir(e,t,n){_(e,typeof e),t(e)||_(!1,{moduleExports:e,moduleExportsKeys:Lr(e),moduleId:n})}function Lr(e){return[...Object.getOwnPropertyNames(e),...Object.getOwnPropertySymbols(e),...Object.keys(e)]}function Rr(e){Ir(e,e=>`pageFilesLazy`in e),_(M(e,`pageFilesLazy`,`object`)),_(M(e,`pageFilesEager`,`object`)),_(M(e,`pageFilesExportNamesLazy`,`object`)),_(M(e,`pageFilesExportNamesEager`,`object`)),_(M(e.pageFilesLazy,`.page`)),_(M(e.pageFilesLazy,`.page.client`)||M(e.pageFilesLazy,`.page.server`)),_(M(e,`pageFilesList`,`string[]`)),_(M(e,`pageConfigsSerialized`)),_(M(e,`pageConfigGlobalSerialized`));let{pageConfigsSerialized:t,pageConfigGlobalSerialized:n}=e;Br(t),Vr(n);let{pageConfigs:r,pageConfigGlobal:i}=Mr(t,n),a={};W(e.pageFilesLazy).forEach(({filePath:e,pageFile:t,globValue:n})=>{t=a[e]=a[e]??t;let r=n;zr(r),t.loadFile=async()=>{`fileExports`in t||(t.fileExports=await r(),cr(t))}}),W(e.pageFilesExportNamesLazy).forEach(({filePath:e,pageFile:t,globValue:n})=>{t=a[e]=a[e]??t;let r=n;zr(r),t.loadExportNames=async()=>{if(!(`exportNames`in t)){let e=await r();_(M(e,`exportNames`,`string[]`),t.filePath),t.exportNames=e.exportNames}}}),W(e.pageFilesEager).forEach(({filePath:e,pageFile:t,globValue:n})=>{t=a[e]=a[e]??t;let r=n;_(x(r)),t.fileExports=r}),W(e.pageFilesExportNamesEager).forEach(({filePath:e,pageFile:t,globValue:n})=>{t=a[e]=a[e]??t;let r=n;_(x(r)),_(M(r,`exportNames`,`string[]`),t.filePath),t.exportNames=r.exportNames}),e.pageFilesList.forEach(e=>{a[e]=a[e]??Tr(e)});let o=Object.values(a);return o.forEach(({filePath:e})=>{_(!e.includes(`\\`))}),{pageFilesAll:o,pageConfigs:r,pageConfigGlobal:i}}function W(e){let t=[];return Object.entries(e).forEach(([e,n])=>{_(Cr.includes(e)),_(x(n)),Object.entries(n).forEach(([n,r])=>{let i=Tr(n);_(i.fileType===e),t.push({filePath:n,pageFile:i,globValue:r})})}),t}function zr(e){_(T(e))}function Br(e){_(S(e)),e.forEach(e=>{_(x(e)),_(M(e,`pageId`,`string`)),_(M(e,`routeFilesystem`)),_(M(e,`configValuesSerialized`))})}function Vr(e){_(M(e,`configValuesSerialized`))}function Hr(e){return(t,n)=>{let r=e(t),i=e(n);return r===i?0:r>i?-1:1}}function Ur(e){return(t,n)=>{let r=e(t),i=e(n);return r===i?0:r<i?-1:1}}function G(e){return(t,n)=>{let r=e(t),i=e(n);if(_([!0,!1,null].includes(r)),_([!0,!1,null].includes(i)),r===i)return 0;if(r===!0||i===!1)return-1;if(i===!0||r===!1)return 1;_(!1)}}function Wr(e){return G(t=>{let n=e(t);return n===null?null:!n})}function Gr(e,t,n){let r=Kr(qr({pageConfigGlobalValues:e,pageConfigValues:n})),i=(()=>{if(t.isErrorPage)return{...r,isErrorPage:!0};{let e=r.config.route??t.routeFilesystem.routeString;return{...r,route:e}}})();return[t.pageId,i]}function Kr(e){return{config:e.config,_source:e.source,_sources:e.sources,_from:e.from}}function qr({pageConfigGlobalValues:e,pageConfigValues:t}){return Zr({configValues:{...e,...t}})}function Jr(e,t,n){let r={},i={},a={};e.forEach(e=>{Qr(e).forEach(({exportName:t,exportValue:n,isFromDefaultExport:r})=>{_(t!==`default`),a[t]=a[t]??[],a[t].push({exportValue:n,exportSource:`${e.filePath} > ${r?`\`export default { ${t} }\``:`\`export { ${t} }\``}`,filePath:e.filePath,_filePath:e.filePath,_fileType:e.fileType,_isFromDefaultExport:r})})});let o,s,c;if(t){let e=qr({pageConfigGlobalValues:n.configValues,pageConfigValues:t.configValues});o=e.source,s=e.sources,c=e.from,Object.assign(r,e.config),Object.assign(i,e.configEntries),Object.assign(a,e.exportsAll)}else o={},s={},c={configsStandard:{},configsCumulative:{},configsComputed:{}};let l={},u={};Object.entries(a).forEach(([e,t])=>{t.forEach(({exportValue:t,_fileType:n,_isFromDefaultExport:r})=>{u[e]=u[e]??t,n===`.page`&&!r&&(e in l||(l[e]=t))})}),_(!(`default`in u)),_(!(`default`in a));let d={config:r,from:c,source:o,sources:s,configEntries:i,exports:u,exportsAll:a};return H(d,`pageExports`,{get:()=>(O()||y(!1,`pageContext.pageExports is outdated, use pageContext.exports instead`,{onlyOnce:!0,showStackTrace:!0}),l),enumerable:!1,configurable:!0}),d}function Yr(e,t){return Xr(e,t,e=>e.configValues)}function Xr(e,t,n){let r=n(t,!0),i=Kr(Zr({configValues:r})),a=Object.fromEntries(e.map(e=>Gr(r,e,n(e)))),o={...i,pages:a};return{...o,_globalConfigPublic:o}}function Zr(e){let t={},n={},r={},i={},a={},o={configsStandard:{},configsCumulative:{},configsComputed:{}},s=(e,t)=>{i[t]=e,a[t]??(a[t]=[]),a[t].push(e)},c=(e,t,i)=>{let a=ye(i),o=we(`Config`,e,i);n[e]=n[e]??[],n[e].push({configValue:t,configDefinedAt:o,configDefinedByFile:a});let s=e;r[s]=r[s]??[],r[s].push({exportValue:t,exportSource:o,filePath:a,_filePath:a,_fileType:null,_isFromDefaultExport:null})};return Object.entries(e.configValues).forEach(([e,n])=>{let{value:r}=n;if(t[e]=t[e]??r,n.type===`standard`){let t={type:`configsStandard`,value:n.value,definedAt:C(n.definedAtData,e)};s(t,e),o.configsStandard[e]=t,c(e,r,n.definedAtData)}if(n.type===`cumulative`){let t={type:`configsCumulative`,definedAt:C(n.definedAtData,e),values:n.value.map((t,r)=>{let i=n.definedAtData[r];_(i);let a=C(i,e);return c(e,t,i),{value:t,definedAt:a}})};s(t,e),o.configsCumulative[e]=t}if(n.type===`computed`){let t={type:`configsComputed`,definedAt:`Vike`,value:n.value};s(t,e),o.configsComputed[e]=t,c(e,r,n.definedAtData)}}),{config:t,configEntries:n,exportsAll:r,source:i,sources:a,from:o}}function Qr(e){let{filePath:t,fileExports:n}=e;_(n),_(xr(t));let i=[];return Object.entries(n).sort(Wr(([e])=>e===`default`)).forEach(([e,n])=>{let a=e===`default`;if(a)if(Sr(t))e=`Page`;else{v(x(n),`The ${r.cyan(`export default`)} of ${t} should be an object.`),Object.entries(n).forEach(([e,n])=>{ur(e,t),i.push({exportName:e,exportValue:n,isFromDefaultExport:a})});return}i.push({exportName:e,exportValue:n,isFromDefaultExport:a})}),i.forEach(({exportName:e,isFromDefaultExport:t})=>{_(!(t&&lr.includes(e)))}),i}async function $r(e,t,n,r,i){let{previousCreateGlobalContextPromise:a}=t,{promise:o,resolve:s}=dt({timeout:null});t.previousCreateGlobalContextPromise=o,a&&(_(t.globalContext),await a);try{let a=ei(e),o;if(t.globalContext?o=!0:(t.globalContext=a,o=!1),n&&a._pageConfigs.length>0){let e=n?.(a);N(a,e)}else N(a,await r?.(a));N(a,await i?.(a));let s=Ne(a._pageConfigGlobal,`onCreateGlobalContext`),c=!1;return ni(t.onCreateGlobalContextHooks??[],s)||(t.onCreateGlobalContextHooks=s,await Xe(`onCreateGlobalContext`,a,qe),c=!0),o&&(c?or(t.globalContext,a):N(t.globalContext,a,!0)),t.globalContext}finally{s()}}function ei(e){let{pageFilesAll:t,pageConfigs:n,pageConfigGlobal:r}=Rr(e),i={isGlobalContext:!0,_isOriginalObject:!0,_virtualFileExportsGlobalEntry:e,_pageFilesAll:t,_pageConfigs:n,_pageConfigGlobal:r,_allPageIds:ti(t,n),...Yr(n,r)};return V(i,`_isOriginalObject`,!1),i}function ti(t,n){let r=e(t.filter(({isDefaultPageFile:e})=>!e).map(({pageId:e})=>e)),i=n.map(e=>e.pageId);return[...r,...i]}function ni(e,t){let n=e.map(e=>e.hookFn),r=t.map(e=>e.hookFn);return n.every(e=>r.includes(e))&&r.every(e=>n.includes(e))}var K=t(`getGlobalContextClientInternalShared.ts`,(()=>{let{promise:e,resolve:t}=dt();return{globalContextInitialPromise:e,globalContextInitialPromiseResolve:t}})());async function ri(){if(K.globalContextPromise)return await K.globalContextPromise;let e=$r(K.virtualFileExportsGlobalEntry,K,()=>{let e={isClientSide:!0};return N(e,wt()),e});K.globalContextPromise=e;let t=await e;return _(K.globalContext===t),K.globalContextInitialPromiseResolve(),t}async function ii(e){K.virtualFileExportsGlobalEntry!==e&&(delete K.globalContextPromise,K.virtualFileExportsGlobalEntry=e,await ri())}function ai(e,t){let n=t.filter(({filesystemRoot:t})=>e.startsWith(t)).sort(Hr(({filesystemRoot:e})=>e.length))[0],r;if(n){let{filesystemRoot:t,urlRoot:i}=n,a={pageId:e,filesystemRoot:t,urlRoot:i};_(i.startsWith(`/`)&&e.startsWith(`/`)&&t.startsWith(`/`),a),_(e.startsWith(t),a),t===`/`?r=e:(_(!t.endsWith(`/`),a),r=L(e,t.length,0)),_(r.startsWith(`/`),a),r=i+(i.endsWith(`/`)?``:`/`)+L(r,1,0)}else r=e;return _(r.startsWith(`/`)),r=r.split(`/`).filter(e=>e!==`pages`&&e!==`src`&&e!==`index`).join(`/`),_(!r.includes(`.page.`)),_(!r.endsWith(`.`)),r.endsWith(`/index`)&&(r=L(r,0,-6)),r===``&&(r=`/`),_(r.startsWith(`/`)),_(!r.endsWith(`/`)||r===`/`),r}function oi(e){return typeof e==`object`&&!!e&&`then`in e&&T(e.then)}async function si(e,t,n){let{hookReturn:i}=et({hookFn:e,hookFilePath:n,hookName:`route`},t._globalContext,t,k);if(ci(i,`The Route Function ${n}`),i=await i,i===!1)return null;if(i===!0&&(i={}),v(z(i),`The Route Function ${n} should return a boolean or a plain JavaScript object (but it's ${r.cyan(`typeof result === ${JSON.stringify(typeof i)}`)} instead)`),`match`in i){let{match:e}=i;if(v(typeof e==`boolean`,`The ${r.cyan(`match`)} value returned by the Route Function ${n} should be a boolean.`),!e)return null}let a=null;`precedence`in i&&(a=i.precedence,v(typeof a==`number`,`The ${r.cyan(`precedence`)} value returned by the Route Function ${n} should be a number.`)),ui(i,`The ${r.cyan(`routeParams`)} object returned by the Route Function ${n} should`);let o=i.routeParams||{};return v(!(`pageContext`in i),`Providing ${r.cyan(`pageContext`)} in Route Functions is prohibited, see https://vike.dev/route-function#cannot-provide-pagecontext`),_(z(o)),Object.keys(i).forEach(e=>{v(e===`match`||e===`routeParams`||e===`precedence`,`The Route Function ${n} returned an object with an unknown property ${r.cyan(e)} (the known properties are ${r.cyan(`match`)}, ${r.cyan(`routeParams`)}, and ${r.cyan(`precedence`)})`)}),{precedence:a,routeParams:o}}function ci(e,t){y(!oi(e),`${t} returned a promise, but asynchronous routing is deprecated and will be removed in the next major release, see https://vike.dev/route-function#async`,{onlyOnce:!0})}function li(){y(!1,`${r.cyan(`iKnowThePerformanceRisksOfAsyncRouteFunctions`)} is deprecated and will be removed in the next major release`,{onlyOnce:!0})}function ui(e,t){_(t.endsWith(` should`)),M(e,`routeParams`)&&v(M(e,`routeParams`,`string{}`),`${t} be ${r.bold(`Record<string, string>`)}`)}async function di(e,t,n,r){return await Promise.all(e.filter(e=>e.fileType===`.page.route`).map(e=>e.loadFile?.())),fi(e,t,n,r)}function fi(e,t,n,r){let{onBeforeRouteHook:i,filesystemRoots:a}=mi(e,t,n);return{pageRoutes:pi(a,e,t,r),onBeforeRouteHook:i}}function pi(e,t,n,r){let i=[];return n.length>0&&(_(e===null),n.filter(e=>!e.isErrorPage).forEach(e=>{let t=e.pageId,n=null;{let r=`route`,i=w(e,r);if(i){let a=i.value;_(i.definedAtData);let o=C(i.definedAtData,r);if(typeof a==`string`)n={pageId:t,comesFromV1PageConfig:!0,routeString:a,routeDefinedAtString:o,routeType:`STRING`};else{let{definedAtData:r}=i;_(!S(r)&&!r.definedBy);let{filePathToShowToUser:s}=r;_(s),_(T(a)),w(e,`iKnowThePerformanceRisksOfAsyncRouteFunctions`,`boolean`)&&li(),n={pageId:t,comesFromV1PageConfig:!0,routeFunction:a,routeFunctionFilePath:s,routeDefinedAtString:o,routeType:`FUNCTION`}}}}if(!n){let{routeFilesystem:r}=e;_(r);let{routeString:i,definedAtLocation:a}=r;_(r.routeString.startsWith(`/`)),n={pageId:t,routeFilesystemDefinedBy:a,comesFromV1PageConfig:!0,routeString:i,routeDefinedAtString:null,routeType:`FILESYSTEM`}}_(n),i.push(n)})),n.length===0&&(_(e),r.filter(e=>!U(e,!1)).forEach(n=>{let r=t.find(e=>e.pageId===n&&e.fileType===`.page.route`);if(!r||!(`default`in r.fileExports)){let t=ai(n,e);_(t.startsWith(`/`)),_(!t.endsWith(`/`)||t===`/`),i.push({pageId:n,comesFromV1PageConfig:!1,routeString:t,routeDefinedAtString:null,routeFilesystemDefinedBy:`${n}.page.*`,routeType:`FILESYSTEM`})}else{let{filePath:e,fileExports:t}=r;if(_(t.default),M(t,`default`,`string`)){let r=t.default;v(r.startsWith(`/`),`A Route String should start with a leading slash '/' but ${e} has \`export default '${r}'\`. Make sure to \`export default '/${r}'\` instead.`),i.push({pageId:n,comesFromV1PageConfig:!1,routeString:r,routeDefinedAtString:e,routeType:`STRING`});return}if(M(t,`default`,`function`)){let r=t.default;`iKnowThePerformanceRisksOfAsyncRouteFunctions`in t&&li(),i.push({pageId:n,comesFromV1PageConfig:!1,routeFunction:r,routeFunctionFilePath:e,routeDefinedAtString:e,routeType:`FUNCTION`});return}v(!1,`The default export of ${e} should be a string or a function.`)}})),i}function mi(e,t,n){if(t.length>0)return{onBeforeRouteHook:Me(n,`onBeforeRoute`),filesystemRoots:null};let r=null,i=[];return e.filter(e=>e.fileType===`.page.route`&&e.isDefaultPageFile).forEach(({filePath:e,fileExports:t})=>{if(_(t),`onBeforeRoute`in t){v(M(t,`onBeforeRoute`,`function`),`\`export { onBeforeRoute }\` of ${e} should be a function.`);let{onBeforeRoute:n}=t,i=`onBeforeRoute`;r={hookFilePath:e,hookFn:n,hookName:i,hookTimeout:D(i)}}`filesystemRoutingRoot`in t&&(v(M(t,`filesystemRoutingRoot`,`string`),`\`export { filesystemRoutingRoot }\` of ${e} should be a string.`),v(M(t,`filesystemRoutingRoot`,`string`),`\`export { filesystemRoutingRoot }\` of ${e} is \`'${t.filesystemRoutingRoot}'\` but it should start with a leading slash \`/\`.`),i.push({filesystemRoot:hi(e),urlRoot:t.filesystemRoutingRoot}))}),{onBeforeRouteHook:r,filesystemRoots:i}}function hi(e){_(e.startsWith(`/`)),_(!e.endsWith(`/`));let t=L(e.split(`/`),0,-1).join(`/`)||`/`;return _(t.startsWith(`/`)),_(!t.endsWith(`/`)||t===`/`),t}async function gi(){let e=await ri();return N(e,await _i(e)),e}async function _i(e){let{pageRoutes:t,onBeforeRouteHook:n}=await di(e._pageFilesAll,e._pageConfigs,e._pageConfigGlobal,e._allPageIds);return{_pageRoutes:t,_onBeforeRouteHook:n}}async function vi(e){let t=yi(e),n=await gi();return N(t,{_globalContext:n,_pageFilesAll:n._pageFilesAll}),F(t,Zn(t,n._globalConfigPublic)),t}function yi(e){let t=Qn();N(t,{isClientSide:!0,isPrerendering:!1,urlOriginal:e,_urlHandler:null});let n=ir();return _(Xt(n)),N(t,{_baseServer:n}),N(t,$n(t)),t}var bi=t(`utils/assertRouterType.ts`,{});function xi(){Ci(Si()),bi.isClientRouting=!0}function Si(){return bi.isClientRouting!==!1}function Ci(e){v(O(),`${r.cyan(`import { something } from 'vike/client/router'`)} is forbidden on the server-side`,{showStackTrace:!0}),y(e,"You shouldn't `import { something } from 'vike/client/router'` when using Server Routing. The 'vike/client/router' utilities work only with Client Routing. In particular, don't `import { navigate }` nor `import { prefetch }` as they unnecessarily bloat your client-side bundle sizes.",{showStackTrace:!0,onlyOnce:!0})}function wi(e,t){let n=e.filter(e=>e.pageId===t);return _(n.length<=1),n[0]??null}async function Ti(e,t){if(`isPageEntryLoaded`in e&&!t)return e;let{moduleId:n,moduleExportsPromise:r}=e.loadVirtualFilePageEntry(),i=await r;Ir(i,()=>`configValuesSerialized`in i,n);let a=i,o;try{o=Ei(a)}catch(e){if(!(e instanceof ReferenceError))throw e;await new Promise(e=>setTimeout(e)),o=Ei(a)}return Object.assign(e.configValues,o),N(e,{isPageEntryLoaded:!0}),e}function Ei(e){return Pr(e.configValuesSerialized)}var Di=`_isAssetsError`;async function Oi(e,t,n,r){let i=Ot(t,e),a=wi(n,e),o;try{o=(await Promise.all([a&&Ti(a,!1),...i.map(e=>e.loadFile?.())]))[0]}catch(e){throw Ai(e)&&Object.assign(e,{[Di]:!0}),e}let s={};return N(s,Jr(i,o,r)),N(s,{_pageFilesLoaded:i}),s}function ki(e){return e?e[Di]===!0:!1}function Ai(e){return e instanceof Error?[`Failed to fetch dynamically imported module`,`error loading dynamically imported module`,`Importing a module script failed`,`error resolving module specifier`,`failed to resolve module`].some(t=>e.message.toLowerCase().includes(t.toLowerCase())):!1}function q(e,t){_(!e.startsWith(`#`));let{searchOriginal:n,hashOriginal:r,pathname:i}=R(e,`/`),a=`${i}${n||``}`;return t?.withoutHash||(a+=r||``),_(a.startsWith(`/`)),a}function ji(e){let t=e.getAttribute(`href`);return t===null||!$t(t)||t===``||rn(t)||Fi(t)||Ni(e)||Pi(e)||!Li(t)||!Mi(e)}function Mi(e){if(Ri()){let t=e.getAttribute(`data-vike-link`);return t!==null&&t!==`false`}else return!0}function Ni(e){let t=e.getAttribute(`target`),n=e.getAttribute(`rel`);return t===`_blank`||t===`_external`||n===`external`||e.hasAttribute(`download`)}function Pi(e){return e.getAttribute(`data-vike`)===`false`}function Fi(e){return!!(e.startsWith(`#`)||e.includes(`#`)&&q(e,{withoutHash:!0})===q(window.location.href,{withoutHash:!0}))}function Ii(e){return e.startsWith(`#`)?e===window.location.hash:q(e)===q(window.location.href)}function Li(e){let t=ir();_(Xt(t));let{isBaseMissing:n}=R(e,t);return!n}function Ri(){return!!window._disableAutomaticLinkInterception}function J(e){return e.fileType===`.css`?[]:e.exportNames?e.exportNames:(_(e.fileExports,e.filePath),Object.keys(e.fileExports))}function zi({pageFilesClientSide:e,pageFilesServerSide:t,pageId:n}){return{isHtmlOnly:r(),isClientRouting:a()};function r(){return t.some(e=>e.pageId===n&&e.fileType===`.page`)?(i(),!1):!(!t.some(e=>e.pageId===n&&e.fileType===`.page.server`)||e.some(e=>e.pageId===n&&e.fileType===`.page.client`&&J(e).includes(`render`)))}function i(){v(e.some(e=>J(e).includes(`render`)),["No client-side `render()` hook found.",`See https://vike.dev/render-modes for more information.`,["Loaded client-side page files (none of them `export { render }`):",...e.map((e,t)=>` (${t+1}): ${e.filePath}`)].join(`
3
+ `)].join(` `))}function a(){return e.some(e=>J(e).includes(`clientRouting`))}}function Bi({pageFilesClientSide:e,pageFilesServerSide:t,isHtmlOnly:n,isClientRouting:r}){let i=[],a=t.filter(t=>!e.includes(t)),o=[];if(o.push(...e.map(e=>({id:e.filePath,onlyAssets:!1,eagerlyImported:!1}))),o.push(...a.map(e=>({id:e.filePath,onlyAssets:!0,eagerlyImported:!1}))),n)i=e.map(e=>e.filePath);else{let e=Vi(r);o.push({id:e,onlyAssets:!1,eagerlyImported:!1}),i=[e]}return{clientEntries:i,clientDependencies:o}}function Vi(e){return e?`@@vike/dist/client/runtime-client-routing/entry.js`:`@@vike/dist/client/runtime-server-routing/entry.js`}function Hi(e,t){let n=Ot(e,t),r=kt(e,t),{isHtmlOnly:i,isClientRouting:a}=zi({pageFilesClientSide:n,pageFilesServerSide:r,pageId:t});i&&(n=n.filter(e=>e.isEnv(`CLIENT_ONLY`)&&!J(e).includes(`render`)),n=Wi(n));let{clientEntries:o,clientDependencies:s}=Bi({pageFilesClientSide:n,pageFilesServerSide:r,isHtmlOnly:i,isClientRouting:a});return{isHtmlOnly:i,isClientRouting:a,clientEntries:o,clientDependencies:s,pageFilesClientSide:n,pageFilesServerSide:r}}async function Ui(e,t,{sharedPageFilesAlreadyLoaded:n}){let r=Ot(e,t);await Promise.all(r.map(async e=>{_(e.isEnv(`CLIENT_ONLY`)||e.isEnv(`CLIENT_AND_SERVER`)),!(n&&e.isEnv(`CLIENT_AND_SERVER`))&&await e.loadExportNames?.()}))}function Wi(e){let t=[];for(let n of e)if(t.push(n),J(n).includes(`overrideDefaultPages`))break;return t}function Gi(e,t,n){if(e){let t=w(e,`clientRouting`,`boolean`)?.value??!1;return{isClientRuntimeLoaded:w(e,`isClientRuntimeLoaded`,`boolean`)?.value??!1,isClientRouting:t}}else{let{isHtmlOnly:e,isClientRouting:r}=Hi(t,n);return{isClientRuntimeLoaded:!e,isClientRouting:r}}}async function Ki(e,t){await Ui(t._pageFilesAll,e,{sharedPageFilesAlreadyLoaded:!1});let{isClientRuntimeLoaded:n,isClientRouting:r}=Gi(wi(t._globalContext._pageConfigs,e),t._pageFilesAll,e);return n&&r}function qi(e){return e.replace(/[/\-\\^$*+?.()|[\]{}]/g,`\\$&`)}var Ji=`@`,Yi=`:`;function Xi(e,t=`Invalid`){let n=`${t} Route String ${Y(e)}`;v(e!==``,`${n} (empty string): set it to ${Y(`/`)} instead`),v([`/`,`*`].includes(e[0]),`${n}: it should start with ${Y(`/`)} or ${Y(`*`)}`),v(!e.includes(`**`),`${n}: set it to ${Y(e.split(`**`).join(`*`))} instead`)}function Zi(e,t){Xi(e);let n=Qi(e),r=n.map(e=>e.param?`[^/]+`:e.glob?`.*`:qi(e.static)).map(e=>`(${e})`).join(``),i=RegExp(`^${r}/?$`),a=t.match(i);if(!a)return null;let o={},[s,...c]=a,l=0,u=n.filter(e=>e.glob).length>1;return n.forEach((e,t)=>{let n=c[t];if(e.param&&(o[e.param]=n),e.glob){let e=`*${u?++l:``}`;o[e]=n}}),{routeParams:o}}function Qi(e){let t=[],n=e=>{let n=t[t.length-1];n?.static?n.static+=e:t.push({static:e})},r=e.split(`/`);return r.forEach((i,a)=>{a!==0&&n(`/`),ta(i)?(y(!i.startsWith(Yi),`Outdated Route String ${Y(e)}, use ${Y(e.split(Yi).join(Ji))} instead`,{onlyOnce:!0}),t.push({param:i.slice(1)})):i===`*`&&a===r.length-1&&e!==`*`&&e!==`/*`?t.push({glob:!0}):i.split(`*`).forEach((e,r)=>{r!==0&&t.push({glob:!0}),e!==``&&n(e)})}),t}function $i(e){let t=[];return Qi(e).forEach(e=>{e.param&&t.push(e.param)}),t}function ea(e){let t=Qi(e),n=e=>e?.split(`/`).filter(Boolean).length||0,r=0;for(let e of t){if(!e.static)break;r+=n(e.static)}let i=t.map(e=>n(e.static)).reduce((e,t)=>e+t,0),a=t.filter(e=>e.param).length,o=t.filter(e=>e.glob).length;return{numberOfStaticPartsBeginning:r,numberOfStaticParts:i,numberOfParams:a,numberOfGlobs:o}}function ta(e){return e.startsWith(Ji)||e.startsWith(Yi)}function na(e){let t=Zi(e,e);return _(t),Object.keys(t.routeParams).length===0}function Y(e){return O()?`'${e}'`:(e===``&&(e=`''`),r.cyan(e))}function ra(e){e.sort(ia).sort(G(e=>e.routeType===`FUNCTION`&&!!e.precedence&&e.precedence<0)).sort(G(e=>e.routeType===`STRING`&&na(e.routeString)===!1)).sort(G(e=>e.routeType===`FUNCTION`&&!e.precedence)).sort(G(e=>e.routeType===`STRING`&&na(e.routeString)===!0)).sort(G(e=>e.routeType===`FILESYSTEM`)).sort(G(e=>e.routeType===`FUNCTION`&&!!e.precedence&&e.precedence>0))}function ia(e,t){{let n=e.precedence??0,r=t.precedence??0;if(n!==r)return n>r?-1:1}if(!t.routeString||!e.routeString)return 0;{let n=Hr(e=>ea(e).numberOfStaticPartsBeginning)(e.routeString,t.routeString);if(n!==0)return n}{let n=Hr(e=>ea(e).numberOfStaticParts)(e.routeString,t.routeString);if(n!==0)return n}{let n=Ur(e=>ea(e).numberOfGlobs)(e.routeString,t.routeString);if(n!==0)return n}{let n=Hr(e=>ea(e).numberOfParams)(e.routeString,t.routeString);if(n!==0)return n}return 0}function aa(e,t){if(!z(e))return!1;for(let n of Object.keys(e))if(!t.includes(n))return!1;return!0}async function oa(e){let t={};if(!e._globalContext._onBeforeRouteHook)return null;let n=await sa(e._globalContext._onBeforeRouteHook,e);return n&&(N(t,n),M(t,`pageId`,`string`)||M(t,`pageId`,`null`))?(M(t,`routeParams`)?_(M(t,`routeParams`,`object`)):N(t,{routeParams:{}}),N(t,{_routingProvidedByOnBeforeRouteHook:!0}),t):(N(t,{_routingProvidedByOnBeforeRouteHook:!1}),t)}async function sa(e,t){let{hookReturn:n}=et(e,t._globalContext,t,k);ci(n,`The onBeforeRoute() hook ${e.hookFilePath}`),n=await n;let i=`The onBeforeRoute() hook defined by ${e.hookFilePath}`;if(v(n==null||aa(n,[`pageContext`])&&M(n,`pageContext`),`${i} should return ${r.cyan(`null`)}, ${r.cyan(`undefined`)}, or a plain JavaScript object ${r.cyan(`{ pageContext: { /* ... */ } }`)}`),n==null)return null;if(v(M(n,`pageContext`,`object`),`${i} returned ${r.cyan(`{ pageContext }`)} but pageContext should be a plain JavaScript object.`),M(n.pageContext,`pageId`)&&!M(n.pageContext,`pageId`,`null`)){let e=`${i} returned ${r.cyan(`{ pageContext: { pageId } }`)} but ${r.cyan(`pageId`)} should be`;v(M(n.pageContext,`pageId`,`string`),`${e} a string or null`),v(t._globalContext._allPageIds.includes(n.pageContext.pageId),`${e} ${vn(t._globalContext._allPageIds.map(e=>r.cyan(e)),`or`)}`)}M(n.pageContext,`routeParams`)&&ui(n.pageContext,`${i} returned ${r.cyan(`{ pageContext: { routeParams } }`)} but routeParams should`);let a=e=>`${i} returned ${r.cyan(`{ pageContext: { ${e} } }`)} which is deprecated. Return ${r.cyan(`{ pageContext: { urlLogical } }`)} instead.`;M(n.pageContext,`url`)&&(y(!1,a(`url`),{onlyOnce:!0}),n.pageContext.urlLogical=n.pageContext.url,delete n.pageContext.url),M(n.pageContext,`urlOriginal`)&&(y(!1,a(`urlOriginal`),{onlyOnce:!0}),n.pageContext.urlLogical=n.pageContext.urlOriginal,delete n.pageContext.urlOriginal),M(n.pageContext,`urlLogical`)&&on(n.pageContext.urlLogical,`${i} returned ${r.cyan(`{ pageContext: { urlLogical } }`)} and ${r.cyan(`urlLogical`)}`),dn(n.pageContext,{hookFilePath:e.hookFilePath,hookName:`onBeforeRoute`});let o={};return N(o,n.pageContext),o}O()&&xi();async function ca(e,t){let n={};if(!t){let t=await oa(e);if(t){if(t._routingProvidedByOnBeforeRouteHook)return _(t.pageId),t;N(n,t)}N(e,t)}let r=e._globalContext._allPageIds;v(r.length>0,`No page found. You must create at least one page.`),_(e._globalContext._pageFilesAll.length>0||e._globalContext._pageConfigs.length>0);let{urlPathname:i}=e;_(i.startsWith(`/`));let a=[];await Promise.all(e._globalContext._pageRoutes.map(async t=>{let{pageId:n,routeType:r}=t;if(t.routeType===`FILESYSTEM`){let{routeString:e}=t,o=Zi(e,i);if(o){let{routeParams:t}=o;a.push({pageId:n,routeParams:t,routeString:e,routeType:r})}return}if(t.routeType===`STRING`){let{routeString:e}=t,o=Zi(e,i);if(o){let{routeParams:t}=o;_(r===`STRING`),a.push({pageId:n,routeString:e,routeParams:t,routeType:r})}return}if(t.routeType===`FUNCTION`){let{routeFunction:i,routeFunctionFilePath:o}=t,s=await si(i,e,o);if(s){let{routeParams:e,precedence:t}=s;a.push({pageId:n,precedence:t,routeParams:e,routeType:r})}return}_(!1)})),ra(a);let o=a[0]??null;if(N(n,{_routeMatch:o}),!o)return N(n,{pageId:null,routeParams:{}}),n;{let{routeParams:e}=o;_(z(e)),N(n,{pageId:o.pageId,routeParams:o.routeParams})}return n}var la=t(`getPageContextCurrent.ts`,{pageContextCurrent:null});function ua(){let{pageContextCurrent:e}=la;return e}function da(e){la.pageContextCurrent=e}var fa=5e3,pa={staticAssets:`hover`,pageContext:fa},ma={staticAssets:`hover`,pageContext:!1},ha=ma;function ga(e,t){let n=ha;if(`prefetchLinks`in e.exports&&v(!1,"`export { prefetchLinks }` is deprecated, use `export { prefetchStaticAssets }` instead."),`prefetchStaticAssets`in e.exports){let t=e.exports.prefetchStaticAssets;n.staticAssets=t}if(`prefetch`in e.exports){let{prefetch:t}=e.exports;t===!0&&(n=pa),t===!1&&(n=ma),Object.assign(n,t),n.pageContext===!0&&(n.pageContext=fa)}if(n.staticAssets,t){{let e=t.getAttribute(`data-prefetch`);e!==null&&(e===``&&(e=`true`),e===`true`&&(n=pa),e===`false`&&(n=ma))}{let e=t.getAttribute(`data-prefetch-static-assets`);e!==null&&(e===`false`&&(n.staticAssets=!1),n.staticAssets=e)}{let e=t.getAttribute(`data-prefetch-page-context`);if(e!==null){e===``&&(e=`true`),e===`true`&&(n.pageContext=fa),e===`false`&&(n.pageContext=!1);let t=parseInt(e,10);Number.isNaN(t)||(n.pageContext=t)}}}return n}xi();var X=t(`prefetch.ts`,{linkPrefetchHandlerAdded:new WeakSet,addLinkPrefetchHandlers_debounce:null,mutationObserver:new MutationObserver(Ca),linkTags:document.getElementsByTagName(`A`),prefetchedPageContexts:{}});function _a(e){if(!ga(e,null).pageContext)return null;let t=ja(e.urlPathname),n=X.prefetchedPageContexts[t];return!n||n.result.is404ServerSideRouted||ka(n)?null:n.result.pageContextFromHooksServer}async function va(e){try{await Oi(e.pageId,e._pageFilesAll,e._globalContext._pageConfigs,e._globalContext._pageConfigGlobal)}catch(e){if(ki(e))yo(e,!0);else throw e}}async function ya(e,t){xa(e,await In(e,!1),t)}function ba(e,t){Ma()&&xa(e,t,null)}function xa(e,t,n){n===null&&(n=Sa());let r=ja(e.urlPathname);_(Ma()),X.prefetchedPageContexts[r]={resultFetchedAt:Date.now(),resultMaxAge:n,result:t}}function Sa(){let e=ua();if(!e)return 1/0;let t=ga(e,null);return typeof t.pageContext==`number`?t.pageContext:fa}function Ca(){X.addLinkPrefetchHandlers_debounce&&clearTimeout(X.addLinkPrefetchHandlers_debounce),X.addLinkPrefetchHandlers_debounce=setTimeout(()=>{`requestIdleCallback`in window?requestIdleCallback(Da,{timeout:300}):setTimeout(Da,150)},250)}function wa(){Ca()}function Ta(){X.mutationObserver.observe(document.body,{childList:!0,subtree:!0})}function Ea(){X.mutationObserver.disconnect()}function Da(){for(let e of X.linkTags)X.linkPrefetchHandlerAdded.has(e)||(X.linkPrefetchHandlerAdded.add(e),!ji(e)&&(e.addEventListener(`mouseover`,()=>{Oa(e,`hover`)},{passive:!0}),e.addEventListener(`touchstart`,()=>{Oa(e,`hover`)},{passive:!0}),new IntersectionObserver(t=>{t.forEach(t=>{t.isIntersecting&&Oa(e,`viewport`)})}).observe(e)))}async function Oa(e,t){let n,r=ua();if(r)n=ga(r,e);else if(Ma())n={staticAssets:`hover`,pageContext:1/0};else return;if(ji(e))return;let i=e.getAttribute(`href`),a=await Aa(i);a?.pageId&&(_(M(a,`pageId`,`string`)),await Ki(a.pageId,a)&&await Promise.all([(async()=>{n.staticAssets===t&&await va(a)})(),(async()=>{if(t!==`viewport`&&n.pageContext){let e=ja(i),t=X.prefetchedPageContexts[e];if(!t||ka(t)){let e=n.pageContext;await ya(a,e)}}})()]))}function ka(e){return Date.now()-e.resultFetchedAt>e.resultMaxAge}async function Aa(e){let t=await vi(e),n;try{n=await ca(t)}catch{return null}return N(t,n),t}function ja(e){return e.startsWith(`#`)&&(e=`/`),_(e.startsWith(`/`),{urlPathname:e}),e.split(`#`)[0]}function Ma(){return`_isBrilloutDocpress`in window}async function Na(e,t){let n=null;n=Ae(e,`render`);{let t=Ae(e,`onRenderClient`);t&&(n=t)}if(!n){let t=Pa(e);if(_(t),e._globalContext._pageConfigs.length>0)v(!1,`No onRenderClient() hook defined for URL '${t}', but it's needed, see https://vike.dev/onRenderClient`);else{let n=e._pageFilesLoaded.filter(e=>e.fileType===`.page.client`),r;r=n.length===0?"No file `*.page.client.*` found for URL "+t:`One of the following files should export a render() hook: `+n.map(e=>e.filePath).join(` `),v(!1,r)}}await Qe(n,e,t)}function Pa(e){let t;try{t=e.urlPathname??e.urlOriginal}catch{}return t??=window.location.href,t}function Fa(e){return q(window.location.href,e)}var Z=t(`history.ts`,{monkeyPatched:!1,previous:void 0});Ja(),Z.previous=Ka();function Ia(){Q(window.history.state)||Ha({vike:{timestamp:za(),scrollPosition:Ra(),triggeredBy:`browser`}})}function La(){let e=window.history.state;return Ga(e),e}function Ra(){return{x:window.scrollX,y:window.scrollY}}function za(){return new Date().getTime()}function Ba(e){if(e||=Ra(),!Q(window.history.state))return;let t=La();Ha({...t,vike:{...t.vike,scrollPosition:e}})}function Va(e,t){if(t)Ha(La(),e);else{let t={vike:{timestamp:za(),scrollPosition:null,triggeredBy:`vike`}};window.history.pushState(t,``,e)}}function Ha(e,t){let n=t??null;window.history.replaceState(e,``,n),Ga(window.history.state)}function Ua(e,t){History.prototype.replaceState.bind(window.history)(e,``,t)}function Wa(){Z.monkeyPatched||(Z.monkeyPatched=!0,[`pushState`,`replaceState`].forEach(e=>{let t=window.history[e].bind(window.history);window.history[e]=(n={},...r)=>{v(n==null||x(n),`history.${e}(state) argument state must be an object`);let i=Q(n)?n:{...n,vike:{scrollPosition:Ra(),timestamp:za(),triggeredBy:`user`}};t(i,...r),Ga(window.history.state),Z.previous=Ka(),queueMicrotask(()=>{Q(window.history.state)||(Object.assign(i,window.history.state),Ua(i))})}}))}function Q(e){return!!e?.vike}function Ga(e){Q(e)||_(!1,{state:e})}function Ka(){return{url:Fa(),state:La()}}function qa(){let{previous:e}=Z,t=Q(window.history.state),n=window.history.state===null;if(!t&&!n)return P(Fa()),{skip:!0};t||Ia();let r=Ka();return Z.previous=r,n?{skip:!0}:{previous:e,current:r}}function Ja(){Wa(),Ia()}function Ya(e){window.addEventListener(`visibilitychange`,()=>{document.visibilityState===`hidden`&&e()})}function Xa(e){window.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&e()})}function Za(e){return new Promise(t=>setTimeout(t,e))}function Qa(e,t){let n=!1;return()=>{n||(n=!0,setTimeout(()=>{n=!1,e()},t))}}function $a(e,t){if(!e&&t&&to(t)){eo(t);return}if(io(e)){ao(e);return}e?.preserveScroll||no(oo())}function eo(e){let t=window.history.state;Ua(null,e),_(window.history.state===null),window.location.replace(e),Ua(t,e)}function to(e){return e.includes(`#`)&&e.includes(`:~:text`)}function no(e){if(!e)ro();else{let t=decodeURIComponent(e),n=document.getElementById(t)||document.getElementsByName(t)[0];n?(n.scrollIntoView(),n.focus()):e===`top`&&ro()}}function ro(){ao({x:0,y:0})}function io(e){return e?.y!==void 0}function ao(e){let t=()=>{window.scrollTo(e.x,e.y)},n=()=>window.scrollX===e.x&&window.scrollY===e.y;n()||(t(),!n()&&requestAnimationFrame(()=>{t(),!n()&&setTimeout(async()=>{if(t(),n())return;let e=new Date().getTime();for(;;)if(await Za(10),t(),n()||new Date().getTime()-e>100)return},0)}))}function oo(){let{hash:e}=window.location;return e===``?null:(_(e.startsWith(`#`)),e=e.slice(1),e)}function so(){window.addEventListener(`scroll`,Qa(Ba,300),{passive:!0}),Ya(Ba)}var co=t(`scrollRestoration.ts`,{});function lo(){po(),Ya(po),Xa(()=>co.initialRenderIsDone&&fo())}function uo(){co.initialRenderIsDone=!0,fo()}function fo(){`scrollRestoration`in window.history&&(window.history.scrollRestoration=`manual`)}function po(){`scrollRestoration`in window.history&&(window.history.scrollRestoration=`auto`)}function mo(e){x(e)&&e.isAlreadyLogged||console.error(e)}var $=t(`renderPageClient.ts`,(()=>{let{promise:e,resolve:t}=dt();return{renderCounter:0,hydrationAwaitPromise:e,hydrationAwaitPromiseResolve:t}})());async function ho(e){lt(`renderPageClient()`);let{urlOriginal:t=Fa(),overwriteLastHistoryEntry:n=!1,isBackwardNavigation:r=!1,isHistoryNavigation:i=!1,doNotRenderIfSamePage:a,isClientSideNavigation:o=!0,pageContextInitClient:s,pageContextsAborted:c=[]}=e,{scrollTarget:l}=e,{previousPageContext:u}=$;Ea();let{isRenderOutdated:d,setHydrationCanBeAborted:f,isFirstRender:p}=bo(),m={urlOriginal:t,isBackwardNavigation:r,isHistoryNavigation:i,pageContextsAborted:c,isClientSideNavigation:o,pageContextInitClient:s,isFirstRender:p};if($.clientRoutingIsDisabled){P(t);return}if(!p&&(await $.hydrationAwaitPromise,d())||(await $.onRenderClientPreviousPromise,d()))return;return await ee();async function ee(){let e=async e=>{await h({err:e})},n=await go(!1,m);if(d())return;if($.isFirstRenderDone&&(_(u),!$.isTransitioning)){$.isTransitioning=!0;let t=je(`onPageTransitionStart`,u);try{await Ze(t,n,kn)}catch(t){await e(t);return}if(d())return}if(p){let e=Pn();_(!(`urlOriginal`in e)),N(n,e),ba(n,{pageContextFromHooksServer:e})}{let r;try{r=await ca(n)}catch(t){await e(t);return}if(d())return;if(_(!(`urlOriginal`in r)),p){let{pageId:e,routeParams:t,...i}=r;N(n,i),_(M(n,`routeParams`,`string{}`))}else N(n,r);if(!p){if(!r.pageId){P(t);return}let e=await Ki(r.pageId,n);if(d())return;if(!e){P(t);return}let i=r.pageId&&u?.pageId&&r.pageId===u.pageId;if(a&&i)return}}_(M(n,`pageId`,`string`));let r=await To(n,p,d);if(!r.skip){if(`err`in r){await e(r.err);return}if(F(n,r.pageContext),da(n),n.exports.hydrationCanBeAborted&&f(),!d())if(p){_(M(n,`_hasPageContextFromServer`,`true`));let t;try{t=await Fn(n)}catch(t){await e(t);return}return d()?void 0:(F(n,t),await re(n))}else{let t,r=_a(n);if(r)t=r;else try{let e=await In(n,!1);if(e.is404ServerSideRouted)return;t=e.pageContextFromHooksServer,ba(n,e)}catch(t){await e(t);return}if(d())return;_(!(`urlOriginal`in t)),N(n,t);let i;try{i=await Ln(n,!1)}catch(t){await e(t);return}return d()?void 0:(F(n,i),await re(n))}}}async function h(e){let{err:t}=e;_(t),xn(t)||mo(t);let n=await go(!0,m);if(d())return;N(n,{errorWhileRendering:t});let r;if(xn(t)){let e=await ne(t,n);if(e.skip)return;r=e.pageContextAbort}await te(n,e,r)}async function te(e,n,r){let i=e=>{mo(e)},a=fr(e._pageFilesAll,e._globalContext._pageConfigs);if(!a)throw Error(`No error page defined.`);N(e,{pageId:a,routeParams:{}}),r?(_(r.abortStatusCode),_(!(`urlOriginal`in r)),N(e,r),N(e,{is404:r.abortStatusCode===404})):N(e,{is404:!1});let o=await Ki(e.pageId,e);if(d())return;if(!o){P(t);return}let s=await To(e,p,d);if(s.skip)return;if(`err`in s){i(s.err);return}F(e,s.pageContext),da(e);let c;try{let t=await In(e,!0);if(t.is404ServerSideRouted)return;c=t.pageContextFromHooksServer}catch(e){i(e);return}if(d())return;_(!(`urlOriginal`in c)),N(e,c);let l;try{l=await Ln(e,!0)}catch(e){i(e);return}d()||(F(e,l),await re(e,n))}async function ne(t,n){let r=t;Cn(t,!0,n);let i=r._pageContextAbort;if(Tn(c,n,i),i._urlRewrite)return await ho({...e,scrollTarget:void 0,pageContextsAborted:c}),{skip:!0};if(i._urlRedirect){let t=i._urlRedirect.url;if(t.startsWith(`/`))await ho({...e,scrollTarget:void 0,urlOriginal:t,overwriteLastHistoryEntry:!1,pageContextsAborted:c});else return P(t),{skip:!0};return{skip:!0}}return{pageContextAbort:i}}async function re(e,r){let i=async e=>{r?mo(e):await h({err:e})};vo(t,n),$.previousPageContext=e,_($.onRenderClientPreviousPromise===void 0);let a=(async()=>{let t;try{await Na(e,B)}catch(e){_(e),t=e}return $.onRenderClientPreviousPromise=void 0,$.isFirstRenderDone=!0,t})();$.onRenderClientPreviousPromise=a;let o=await a;if(!(o&&(await i(o),!r))){if(p&&!o){try{await Ye(`onHydrationEnd`,e,B)}catch(e){if(await i(e),!r)return}if(d(!0))return}if(!d(!0)){if($.isTransitioning){$.isTransitioning=void 0,_(u);let t=je(`onPageTransitionEnd`,u);try{await Ze(t,e,B)}catch(e){if(await i(e),!r)return}if(d(!0))return}if(!l&&u){let t=So(u),n=So(e);n!==!1&&t!==!1&&Co(n,t)&&(l={preserveScroll:!0})}return $a(l,t),io(l)&&Ba(l),uo(),e._hasPageContextFromServer&&Hn(e),Ta(),Ca(),$.renderedPageContext=e,_o(t),$.hydrationAwaitPromiseResolve(),e}}}}async function go(e,{urlOriginal:t,isBackwardNavigation:n,isHistoryNavigation:r,pageContextsAborted:i,isClientSideNavigation:a,pageContextInitClient:o,isFirstRender:s}){let c=$.previousPageContext??null,l=await vi(t);N(l,{isBackwardNavigation:n,isHistoryNavigation:r,isClientSideNavigation:a,isHydration:s&&!e,previousPageContext:c,pageContextsAborted:i,...o}),$.currentPageContext=l,Object.defineProperty(l,`_previousPageContext`,{get(){return y(!1,`pageContext._previousPageContext has been renamed pageContext.previousPageContext`,{showStackTrace:!0,onlyOnce:!0}),c},enumerable:!1});{let e=wn(i);_(!e||!(`urlOriginal`in e)),N(l,e)}return l}function _o(e){window._vike??(window._vike={}),window._vike.fullyRenderedUrl=e}function vo(e,t){Fa()!==e&&Va(e,t)}function yo(e,t){$.clientRoutingIsDisabled=!0,_(ki(e)),t&&console.log(e),ue(!1,[`Failed to fetch static asset.`,`This usually happens when a new frontend is deployed.`,`Falling back to Server Routing.`,`(The next page navigation will use Server Routing instead of Client Routing.)`].filter(Boolean).join(` `),{onlyOnce:!0})}function bo(){let e=++$.renderCounter;_(e>=1);let t=!1;return{isRenderOutdated:n=>e===1&&!t&&!n?!1:e!==$.renderCounter,setHydrationCanBeAborted:()=>{t=!0,$.hydrationAwaitPromiseResolve()},isFirstRender:e===1}}function xo(){return $.renderCounter}function So(e){let t=e.from.configsStandard.keepScrollPosition;if(!t)return!1;let n=t.value,r=t.definedAt;_(r);let i=$i(r);return T(n)&&(n=n(e,{configDefinedAt:t.definedAt})),n===!0?[r,...i.map(t=>{let n=e.routeParams[t];return _(n),n})]:n}function Co(e,t){return e===t?!0:!Array.isArray(e)||!Array.isArray(t)?!1:e.length===t.length&&e.every((n,r)=>e[r]===t[r])}function wo(){let e=$.currentPageContext;return e?B(e):null}async function To(e,t,n){let r=!1,i,a;try{a=await Oi(e.pageId,e._pageFilesAll,e._globalContext._pageConfigs,e._globalContext._pageConfigGlobal)}catch(n){if(i=n,r=!0,Eo(i,e,t))return{skip:!0}}if(n())return{skip:!0};if(r)return{err:i};N(e,a);try{await Ye(`onCreatePageContext`,e,B)}catch{i=i,r=!0}return n()?{skip:!0}:r?{err:i}:{pageContext:e}}function Eo(e,t,n){if(!ki(e))return!1;if(n)throw yo(e,!1),e;return yo(e,!0),P(t.urlOriginal),!0}var Do=`modulepreload`,Oo=function(e){return`/`+e},ko={},Ao=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=function(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))},i=document.getElementsByTagName(`link`),a=document.querySelector(`meta[property=csp-nonce]`),o=a?.nonce||a?.getAttribute(`nonce`);r=e(t.map(e=>{if(e=Oo(e,n),e in ko)return;ko[e]=!0;let t=e.endsWith(`.css`),r=t?`[rel="stylesheet"]`:``;if(n)for(let n=i.length-1;n>=0;n--){let r=i[n];if(r.href===e&&(!t||r.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${e}"]${r}`))return;let a=document.createElement(`link`);if(a.rel=t?`stylesheet`:Do,t||(a.as=`script`),a.crossOrigin=``,a.href=e,o&&a.setAttribute(`nonce`,o),document.head.appendChild(a),t)return new Promise((t,n)=>{a.addEventListener(`load`,t),a.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${e}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})};export{t as S,lt as _,lo as a,_ as b,$a as c,wa as d,Ii as f,ii as g,xi as h,ho as i,Ja as l,ji as m,wo as n,so as o,Pi as p,xo as r,no as s,Ao as t,qa as u,it as v,d as x,at as y};