function $e(){return!(typeof process>"u"||!process.cwd||!process.versions||typeof process.versions.node>"u"||!process.release||process.release.name!=="node")}function V(e,t){let n;{var r=Error.stackTraceLimit;Error.stackTraceLimit=1/0,n=new Error(e),Error.stackTraceLimit=r}return $e()&&(n.stack=be(n.stack,t)),n}function be(e,t){if(!e)return e;const n=Se(e);let r=0;return n.filter(o=>o.includes(" (internal/")||o.includes(" (node:internal")?!1:r1&&_(!1,B,{onlyOnce:!0,showStackTrace:!0})}function Bt(e){_(E.isClientRouting!==!0,ie,{onlyOnce:!0,showStackTrace:!0}),_(E.isClientRouting===void 0,B,{onlyOnce:!0,showStackTrace:!0}),E.isClientRouting=!1,e&&(E.checkSingleInstance=!0),H()}function Ht(e){_(E.isClientRouting!==!1,ie,{onlyOnce:!0,showStackTrace:!0}),_(E.isClientRouting===void 0,B,{onlyOnce:!0,showStackTrace:!0}),E.isClientRouting=!0,e&&(E.checkSingleInstance=!0),H()}function ve(e){E.instances.push(e),H()}function Re(e,t){if(e)return;const n=`[vite-plugin-ssr][Wrong Usage] ${t}`;throw new Error(n)}function _(e,t,{onlyOnce:n,showStackTrace:r}){if(e)return;const i=`[vite-plugin-ssr][Warning] ${t}`;if(n){const{alreadyLogged:o}=E,a=n===!0?i:n;if(o.has(a))return;o.add(a)}console.warn(r?new Error(i):i)}const Pe="0.4.142",R={projectName:"vite-plugin-ssr",projectVersion:Pe,npmPackageName:"vite-plugin-ssr",githubRepository:"https://github.com/brillout/vite-plugin-ssr"};ve(R.projectVersion);const p=new Proxy({},{get:(e,t)=>n=>t!=="code"?n:`\`${n}\``}),$=x("utils/assert.ts",{alreadyLogged:new Set,logger(e,t){t==="info"?console.log(e):console.warn(e)},showStackTraceList:new WeakSet}),Te=`[${R.npmPackageName}]`,xe=`[${R.npmPackageName}@${R.projectVersion}]`,G=2;function s(e,t){if(e)return;const n=(()=>{if(!t)return null;const a=typeof t=="string"?t:JSON.stringify(t);return p.dim(`Debug info (for ${R.projectName} maintainers; you can ignore this): ${a}`)})(),r=`${R.githubRepository}/issues/new`;let i=[`You stumbled upon a bug in ${R.projectName}'s source code.`,`Go to ${p.blue(r)} and copy-paste this error; a maintainer will fix the bug (usually under 24 hours).`,n].filter(Boolean).join(" ");i=j(i),i=W(i,"Bug"),i=L(i,!0);const o=V(i,G);throw $.onBeforeLog?.(),o}function h(e,t,{showStackTrace:n}={}){if(e)return;t=j(t),t=W(t,"Wrong Usage"),t=L(t);const r=V(t,G);throw n&&$.showStackTraceList.add(r),$.onBeforeLog?.(),r}function Ie(e){return e=j(e),e=W(e,"Error"),e=L(e),V(e,G)}function P(e,t,{onlyOnce:n,showStackTrace:r}){if(!e){if(t=j(t),t=W(t,"Warning"),t=L(t),n){const{alreadyLogged:i}=$,o=n===!0?t:n;if(i.has(o))return;i.add(o)}if($.onBeforeLog?.(),r){const i=new Error(t);$.showStackTraceList.add(i),$.logger(i,"warn")}else $.logger(t,"warn")}}function Gt(e,t,{onlyOnce:n}){if(!e){if(t=j(t),t=L(t),n){const{alreadyLogged:r}=$,i=t;if(r.has(i))return;r.add(i)}$.onBeforeLog?.(),$.logger(t,"info")}}function W(e,t){let n=`[${t}]`;const r=t==="Warning"?"yellow":"red";return n=p.bold(p[r](n)),`${n}${e}`}function j(e){return e.startsWith("[")?e:` ${e}`}function L(e,t=!1){return`${t?xe:Te}${e}`}function M(){return typeof window<"u"&&typeof window.scrollY=="number"}const C=x("utils/assertRouterType.ts",{});function Mt(){se(_e()),C.isClientRouting=!0}function _e(){return C.isClientRouting!==!1}function Jt(){se(C.isClientRouting!==!0),C.isClientRouting=!1}function se(e){h(M(),`${p.cyan("import { something } from 'vite-plugin-ssr/client/router'")} is forbidden on the server-side`,{showStackTrace:!0}),P(e,"You shouldn't `import { something } from 'vite-plugin-ssr/client/router'` when using Server Routing. The 'vite-plugin-ssr/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})}const je=["js","ts","cjs","cts","mjs","mts","jsx","tsx","cjsx","ctsx","mjsx","mtsx"],oe=["vue","svelte","marko","md","mdx"],Le=[...je,...oe];function ae(e){const t=Le.some(n=>e.endsWith("."+n));return s(!Oe(e)||t),t}function Oe(e){return/\.(c|m)?(j|t)sx?$/.test(e)}function Ce(e){return oe.some(t=>e.endsWith("."+t))}function k(e,t,n){return typeof e=="string"?K(e.split(""),t,n).join(""):K(e,t,n)}function K(e,t,n){const r=[];let i=t>=0?t:e.length+t;s(i>=0&&i<=e.length);let o=n>=0?n:e.length+n;for(s(o>=0&&o<=e.length);!(i===o||(i===e.length&&(i=0),i===o));){const a=e[i];s(a!==void 0),r.push(a),i++}return r}const le=["http://","https://","tauri://"];function ce(e){return le.some(t=>e.startsWith(t))||e.startsWith("/")||e.startsWith(".")||e.startsWith("?")||e.startsWith("#")||e===""}function Yt(e,t){s(t.includes(" but ")),h(typeof e=="string",`${t} should be a string`),!ce(e)&&(!e.startsWith("/")&&!e.includes(":")?h(!1,`${t} is ${p.cyan(e)} and it should be /${p.cyan(e)} instead (URL pathnames should start with a leading slash)`):h(!1,`${t} isn't a valid URL`))}function ke(e,t){s(ce(e)),s(t.startsWith("/"));const[n,...r]=e.split("#");s(n!==void 0);const i=["",...r].join("#")||null;s(i===null||i.startsWith("#"));const o=i===null?"":D(i.slice(1)),[a,...l]=n.split("?");s(a!==void 0);const c=["",...l].join("?")||null;s(c===null||c.startsWith("?"));const u={},g={};Array.from(new URLSearchParams(c||"")).forEach(([S,q])=>{u[S]=q,g[S]=[...g[S]||[],q]});const{origin:f,pathname:w}=We(a,t);s(f===null||f===D(f)),s(w.startsWith("/")),s(f===null||e.startsWith(f));const d=a.slice((f||"").length);Ve(e,f,d,c,i);let{pathname:y,hasBaseServer:I}=Ne(w,t);return y=Fe(y),s(y.startsWith("/")),{origin:f,pathname:y,pathnameOriginal:d,hasBaseServer:I,search:u,searchAll:g,searchOriginal:c,hash:o,hashOriginal:i}}function D(e){try{return decodeURIComponent(e)}catch{}try{return decodeURI(e)}catch{}return e}function Fe(e){return e=e.split("/").map(t=>D(t).split("/").join("%2F")).join("/"),e=e.replace(/\s/g,""),e}function We(e,t){{const{origin:n,pathname:r}=Q(e);if(n)return{origin:n,pathname:r};s(r===e)}if(e.startsWith("/"))return{origin:null,pathname:e};{const n=typeof window<"u"&&window?.document?.baseURI||t,r=Ae(e,n);return Q(r)}}function Q(e){if(le.some(t=>e.startsWith(t))){const[t,n,r,...i]=e.split("/"),o=[t,n,r].join("/"),a=["",...i].join("/")||"/";return{origin:o,pathname:a}}else return{pathname:e,origin:null}}function Ae(e,t){const n=t.split("/"),r=e.split("/");let i=t.endsWith("/");e.startsWith(".")&&n.pop();for(const a in r){const l=r[a];l==""&&a==="0"||l!="."&&(l==".."?n.pop():(i=!1,n.push(l)))}let o=n.join("/");return i&&!o.endsWith("/")&&(o+="/"),o}function De(e){s(e.startsWith("/")),s(!e.includes("?")),s(!e.includes("#"))}function Ne(e,t){De(e),s(ze(t));let n=e;if(s(n.startsWith("/")),s(t.startsWith("/")),t==="/")return{pathname:e,hasBaseServer:!0};let r=t;return t.endsWith("/")&&n===k(t,0,-1)&&(r=k(t,0,-1),s(n===r)),n.startsWith(r)?(s(n.startsWith("/")||n.startsWith("http")),s(n.startsWith(r)),n=n.slice(r.length),n.startsWith("/")||(n="/"+n),s(n.startsWith("/")),{pathname:n,hasBaseServer:!0}):{pathname:e,hasBaseServer:!1}}function ze(e){return e.startsWith("/")}function Ve(e,t,n,r,i){const o=Ue(t,n,r,i);s(e===o)}function Ue(e,t,n,r){return`${e||""}${t}${n||""}${r||""}`}function J(e,t){Object.defineProperties(e,Object.getOwnPropertyDescriptors(t))}function Y(e){return e instanceof Function||typeof e=="function"}function qt(e){return(t,n)=>{const r=e(t),i=e(n);return r===i?0:r>i?-1:1}}function Be(e){return(t,n)=>{const r=e(t),i=e(n);if(s([!0,!1,null].includes(r)),s([!0,!1,null].includes(i)),r===i)return 0;if(r===!0||i===!1)return-1;if(i===!0||r===!1)return 1;s(!1)}}function He(e){return Be(t=>{const n=e(t);return n===null?null:!n})}function m(e,t,n="unknown"){if(!b(e))return!1;if(!(t in e))return n==="undefined";if(n==="unknown")return!0;const r=e[t];return n==="array"?Array.isArray(r):n==="object"?b(r):n==="string[]"?Array.isArray(r)&&r.every(i=>typeof i=="string"):n==="function"?Y(r):Array.isArray(n)?typeof r=="string"&&n.includes(r):n==="null"?r===null:n==="undefined"?r===void 0:n==="true"?r===!0:n==="false"?r===!1:typeof r===n}function Ge(e,t){return e.toLowerCase()t.toLowerCase()?1:0}const Me=e=>e!=null;function ue(e){const t=n=>`Not a posix path: ${n}`;s(e!==null,t("null")),s(typeof e=="string",t(`typeof path === ${JSON.stringify(typeof e)}`)),s(e!=="",t("(empty string)")),s(e),s(!e.includes("\\"),t(e))}const Je=["$$registrations","_rerender_only"],Ye=[".md",".mdx"];function qe(e,t){Ke(e,t,!0)}function Ke(e,t,n){const i=Object.keys(e).filter(l=>!Je.includes(l)),o=i.filter(l=>l!=="default"),a=i.includes("default");if(o.length===0){if(a)return;s(i.length===0),h(!1,`${t} doesn't export any value, but it should have a ${p.cyan("export default")} instead`)}else if(!Ye.some(l=>t.endsWith(l)))if(n)o.forEach(l=>{P(o.length===0,`${t} should only have a default export: move ${p.cyan(`export { ${l} }`)} to +config.h.js or its own +${o}.js`,{onlyOnce:!0})});else{const l=o.join(", ");P(o.length===0,`${t} replace ${p.cyan(`export { ${l} }`)} with ${p.cyan(`export default { ${l} }`)}`,{onlyOnce:!0})}}function Qe(e){return[null,void 0].includes(e)?String(e):["undefined","boolean","number","string"].includes(typeof e)?JSON.stringify(e):null}const Xe=["clientRouting"];function Ze(e){Xe.forEach(t=>{if(s(e.fileExports),!(t in e.fileExports))return;const n=`The value of \`${t}\` is only allowed to be \`true\`.`;h(e.fileExports[t]!==!1,`${e.filePath} has \`export { ${t} }\` with the value \`false\` which is prohibited: remove \`export { ${t} }\` instead. (${n})`),h(e.fileExports[t]===!0,`${e.filePath} has \`export { ${t} }\` with a forbidden value. ${n}`)})}const fe=["render","clientRouting","prerender","doNotPrerender"];function et(e,t){h(!fe.includes(e),`${t} has \`export default { ${e} }\` which is prohibited, use \`export { ${e} }\` instead.`)}function tt(e){let t="",n="",[r,...i]=e;return r?r==="*"?(s(i.length===0),"export *"):(r==="default"?t="export default":(t="export",i=[r,...i]),i.forEach(a=>{t=`${t} { ${a}`,n=` }${n}`}),t+n):null}function Kt(e,t,n){const r=de(e,t);if(r===null)return null;const{value:i,definedAtInfo:o}=r;return n&&nt(i,n,t,o),{value:i}}function Qt(e,t){const n=de(e,t);s(n);const{definedAtInfo:r}=n;return s(r),r}function de(e,t){const n=e.configValues[t];if(!n)return null;const{value:r,definedAtInfo:i}=n;return r===null?null:{value:r,definedAtInfo:i}}function Xt(e,t){const n=t.find(r=>r.pageId===e);return s(t.length>0),s(n),n}function nt(e,t,n,r){s(e!==null);const i=typeof e;if(i===t)return;const o=Qe(e),a=o!==null?`value ${p.cyan(o)}`:`type ${p.cyan(i)}`,l=ge(n,{definedAtInfo:r},!0);h(!1,`${l} has an invalid ${a}: is should be a ${p.cyan(t)} instead`)}function ge(e,{definedAtInfo:t},n,r){let i=`${n?"Config":"config"} ${p.cyan(e)}`;return t!==null&&(i=`${i} defined at ${rt(t,r)}`),i}function rt(e,t){const{filePath:n,fileExportPath:r}=e;let i=n;const o=tt(r);return o&&(i=`${i} > ${p.cyan(o)}`),t&&(i=`${i} > (${p.blue(t)})`),i}function it(e,t){const n={},r={},i={};e.forEach(l=>{st(l).forEach(({exportName:u,exportValue:g,isFromDefaultExport:f})=>{s(u!=="default"),i[u]=i[u]??[],i[u].push({exportValue:g,exportSource:`${l.filePath} > ${f?`\`export default { ${u} }\``:`\`export { ${u} }\``}`,filePath:l.filePath,_filePath:l.filePath,_fileType:l.fileType,_isFromDefaultExport:f})})}),t&&Object.entries(t.configValues).forEach(([l,c])=>{const{value:u,definedAtInfo:g}=c;let f=null;g&&(f=g.filePath);const w=ge(l,c,!0);r[l]=r[l]??u,n[l]=n[l]??[],s(n[l].length===0),n[l].push({configValue:u,configDefinedAt:w,configDefinedByFile:f});const d=l;i[d]=i[d]??[],i[d].push({exportValue:u,exportSource:w,filePath:f,_filePath:f,_fileType:null,_isFromDefaultExport:null})});const o=ot(),a={};return Object.entries(i).forEach(([l,c])=>{c.forEach(({exportValue:u,_fileType:g,_isFromDefaultExport:f})=>{a[l]=a[l]??u,g===".page"&&!f&&(l in o||(o[l]=u))})}),s(!("default"in a)),s(!("default"in i)),{config:r,configEntries:n,exports:a,exportsAll:i,pageExports:o}}function st(e){const{filePath:t,fileExports:n}=e;s(n),s(ae(t));const r=[];return Object.entries(n).sort(He(([i])=>i==="default")).forEach(([i,o])=>{let a=i==="default";if(a)if(Ce(t))i="Page";else{h(b(o),`The ${p.cyan("export default")} of ${t} should be an object.`),Object.entries(o).forEach(([l,c])=>{et(l,t),r.push({exportName:l,exportValue:c,isFromDefaultExport:a})});return}r.push({exportName:i,exportValue:o,isFromDefaultExport:a})}),r.forEach(({exportName:i,isFromDefaultExport:o})=>{s(!(o&&fe.includes(i)))}),r}function ot(){return new Proxy({},{get(...e){return M()||P(!1,"`pageContext.pageExports` is outdated. Use `pageContext.exports` instead, see https://vite-plugin-ssr.com/exports",{onlyOnce:!0,showStackTrace:!0}),Reflect.get(...e)}})}function at(e){const t=".page.",n=k(e.split(t),0,-1).join(t);return s(!n.includes("\\")),n}function T(e){ue(e)}function Zt(e,t){if(t.length>0){const r=t.filter(i=>i.isErrorPage);return r.length===0?null:(h(r.length===1,"Only one error page can be defined"),r[0].pageId)}const n=U(e.map(({pageId:r})=>r).filter(r=>A(r)));if(h(n.length<=1,`Only one _error.page.js is allowed, but found several: ${n.join(" ")}`),n.length>0){const r=n[0];return s(r),r}return null}function A(e,t){return s(!e.includes("\\")),e.includes("/_error")}function lt(e,t){if(t.length>0){const n=t.find(r=>r.pageId===e);return s(n),n.isErrorPage}else return A(e)}const ct=[".page",".page.server",".page.route",".page.client",".css"];function ut(e){if(ue(e),e.endsWith(".css"))return".css";s(ae(e),e);const n=e.split("/").slice(-1)[0].split("."),r=n.slice(-3)[0],i=n.slice(-2)[0];if(i==="page")return".page";if(s(r==="page",e),i==="server")return".page.server";if(i==="client")return".page.client";if(i==="route")return".page.route";s(!1,e)}function he(e){const t=o=>i.pageId===o||i.isDefaultPageFile&&(X(i.filePath)||ft(o,i.filePath)),n=ut(e),i={filePath:e,fileType:n,isEnv:o=>{if(s(n!==".page.route"),o==="CLIENT_ONLY")return n===".page.client"||n===".css";if(o==="SERVER_ONLY")return n===".page.server";if(o==="CLIENT_AND_SERVER")return n===".page";s(!1)},isRelevant:t,isDefaultPageFile:N(e),isRendererPageFile:n!==".css"&&N(e)&&X(e),isErrorPageFile:A(e),pageId:at(e)};return i}function N(e){return T(e),A(e)?!1:e.includes("/_default")}function X(e){return T(e),e.includes("/renderer/")}function ft(e,t){T(e),T(t),s(!e.endsWith("/")),s(!t.endsWith("/")),s(N(t));const n=k(t.split("/"),0,-1).filter(r=>r!=="_default").join("/");return e.startsWith(n)}function dt(e){s(Array.isArray(e)),e.forEach(t=>{s(b(t)),s(m(t,"pageId","string")),s(m(t,"routeFilesystem"))})}function gt(e){s(e),s(m(e,"onBeforeRoute")),s(m(e,"onPrerenderStart"))}function ht(e){s(m(e,"isGeneratedFile")),s(e.isGeneratedFile!==!1,"vite-plugin-ssr was re-installed(/re-built). Restart your app."),s(e.isGeneratedFile===!0,`\`isGeneratedFile === ${e.isGeneratedFile}\``),s(m(e,"pageFilesLazy","object")),s(m(e,"pageFilesEager","object")),s(m(e,"pageFilesExportNamesLazy","object")),s(m(e,"pageFilesExportNamesEager","object")),s(m(e.pageFilesLazy,".page")),s(m(e.pageFilesLazy,".page.client")||m(e.pageFilesLazy,".page.server")),s(m(e,"pageFilesList","string[]")),s(m(e,"pageConfigs")),s(m(e,"pageConfigGlobal"));const{pageConfigs:t,pageConfigGlobal:n}=e;dt(t),gt(n);const r={};O(e.pageFilesLazy).forEach(({filePath:o,pageFile:a,globValue:l})=>{a=r[o]=r[o]??a;const c=l;Z(c),a.loadFile=async()=>{"fileExports"in a||(a.fileExports=await c(),Ze(a))}}),O(e.pageFilesExportNamesLazy).forEach(({filePath:o,pageFile:a,globValue:l})=>{a=r[o]=r[o]??a;const c=l;Z(c),a.loadExportNames=async()=>{if(!("exportNames"in a)){const u=await c();h("exportNames"in u,"You seem to be using Vite 2 but the latest vite-plugin-ssr versions only work with Vite 3"),s(m(u,"exportNames","string[]"),a.filePath),a.exportNames=u.exportNames}}}),O(e.pageFilesEager).forEach(({filePath:o,pageFile:a,globValue:l})=>{a=r[o]=r[o]??a;const c=l;s(b(c)),a.fileExports=c}),O(e.pageFilesExportNamesEager).forEach(({filePath:o,pageFile:a,globValue:l})=>{a=r[o]=r[o]??a;const c=l;s(b(c)),s(m(c,"exportNames","string[]"),a.filePath),a.exportNames=c.exportNames}),e.pageFilesList.forEach(o=>{r[o]=r[o]??he(o)});const i=Object.values(r);return i.forEach(({filePath:o})=>{s(!o.includes("\\"))}),{pageFiles:i,pageConfigs:t,pageConfigGlobal:n}}function O(e){const t=[];return Object.entries(e).forEach(([n,r])=>{s(ct.includes(n)),s(b(r)),Object.entries(r).forEach(([i,o])=>{const a=he(i);s(a.fileType===n),t.push({filePath:i,pageFile:a,globValue:o})})}),t}function Z(e){s(Y(e))}const v=x("setPageFiles.ts",{});function en(e){const{pageFiles:t,pageConfigs:n,pageConfigGlobal:r}=ht(e);v.pageFilesAll=t,v.pageConfigs=n,v.pageConfigGlobal=r}async function tn(e,t){e?(s(!v.pageFilesGetter),s(t===void 0)):(s(v.pageFilesGetter),s(typeof t=="boolean"),(!v.pageFilesAll||!t)&&await v.pageFilesGetter());const{pageFilesAll:n,pageConfigs:r,pageConfigGlobal:i}=v;s(n&&r&&i);const o=pt(n,r);return{pageFilesAll:n,allPageIds:o,pageConfigs:r,pageConfigGlobal:i}}function pt(e,t){const n=e.filter(({isDefaultPageFile:o})=>!o).map(({pageId:o})=>o),r=U(n),i=t.map(o=>o.pageId);return[...r,...i]}function mt(e,t){return pe(e,t,!0)}function nn(e,t){return pe(e,t,!1)}function pe(e,t,n){const r=n?"CLIENT_ONLY":"SERVER_ONLY",i=e.filter(d=>d.isRelevant(t)&&d.fileType!==".page.route").sort(yt(n,t)),o=d=>{const y=i.filter(S=>S.pageId===t&&S.isEnv(d?"CLIENT_AND_SERVER":r));h(y.length<=1,`Merge the following files into a single file: ${y.map(S=>S.filePath).join(" ")}`);const I=y[0];return s(I===void 0||!I.isDefaultPageFile),I},a=o(!1),l=o(!0),c=d=>i.filter(y=>y.isRendererPageFile&&y.isEnv(d?"CLIENT_AND_SERVER":r))[0],u=c(!1),g=c(!0),f=i.filter(d=>d.isDefaultPageFile&&!d.isRendererPageFile&&(d.isEnv(r)||d.isEnv("CLIENT_AND_SERVER")));return[a,l,...f,u,g].filter(Me)}function yt(e,t){const n=e?"CLIENT_ONLY":"SERVER_ONLY",r=-1,i=1,o=0;return(a,l)=>{if(!a.isDefaultPageFile&&l.isDefaultPageFile)return r;if(!l.isDefaultPageFile&&a.isDefaultPageFile)return i;{const c=a.isRendererPageFile,u=l.isRendererPageFile;if(!c&&u)return r;if(!u&&c)return i;s(c===u)}{const c=ee(t,a.filePath),u=ee(t,l.filePath);if(c{o=d=>{c(),f(d)},a=d=>{c(),w(d)}}),c=()=>{clearTimeout(u),clearTimeout(g)},u=setTimeout(()=>{P(!1,`The ${t}() hook defined by ${n} is taking more than ${te(i)}`,{onlyOnce:!1})},i),g=setTimeout(()=>{const f=Ie(`Hook timeout: the ${t}() hook defined by ${n} didn't finish after ${te(r)}`);a(f)},r);return(async()=>{try{const f=await e();o(f)}catch(f){b(f)&&bt.userHookErrors.set(f,{hookName:t,hookFilePath:n}),a(f)}})(),l}function St(e){return e==="onBeforeRoute"?{timeoutErr:5*1e3,timeoutWarn:1*1e3}:e==="onBeforePrerender"?{timeoutErr:10*60*1e3,timeoutWarn:30*1e3}:{timeoutErr:40*1e3,timeoutWarn:4*1e3}}function rn(e){const t=window.location.href,{searchOriginal:n,hashOriginal:r,pathname:i}=ke(t,"/");let o;return e?.withoutHash?o=`${i}${n||""}`:o=`${i}${n||""}${r||""}`,s(o.startsWith("/")),o}$t();const vt=[{is:e=>e===void 0,match:e=>e==="!undefined",serialize:()=>"!undefined",deserialize:()=>{}},{is:e=>e===1/0,match:e=>e==="!Infinity",serialize:()=>"!Infinity",deserialize:()=>1/0},{is:e=>e===-1/0,match:e=>e==="!-Infinity",serialize:()=>"!-Infinity",deserialize:()=>-1/0},{is:e=>typeof e=="number"&&isNaN(e),match:e=>e==="!NaN",serialize:()=>"!NaN",deserialize:()=>NaN},{is:e=>e instanceof Date,match:e=>e.startsWith("!Date:"),serialize:e=>"!Date:"+e.toISOString(),deserialize:e=>new Date(e.slice(6))},{is:e=>typeof e=="bigint",match:e=>e.startsWith("!BigInt:"),serialize:e=>"!BigInt:"+e.toString(),deserialize:e=>{if(typeof BigInt>"u")throw new Error("Your JavaScript environement does not support BigInt. Consider adding a polyfill.");return BigInt(e.slice(8))}},{is:e=>e instanceof RegExp,match:e=>e.startsWith("!RegExp:"),serialize:e=>"!RegExp:"+e.toString(),deserialize:e=>{e=e.slice(8);const t=e.match(/\/(.*)\/(.*)?/),n=t[1],r=t[2];return new RegExp(n,r)}},{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)))},{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)))},{is:e=>typeof e=="string"&&e.startsWith("!"),match:e=>e.startsWith("!"),serialize:e=>"!"+e,deserialize:e=>e.slice(1)}];function me(e){const t=JSON.parse(e);return ye(t)}function ye(e){return typeof e=="string"?Rt(e):(typeof e=="object"&&e!==null&&Object.entries(e).forEach(([t,n])=>{e[t]=ye(n)}),e)}function Rt(e){for(const{match:t,deserialize:n}of vt)if(t(e))return n(e,me);return e}function sn(){const e="vite-plugin-ssr_pageContext",t=document.getElementById(e);h(t,`The element #${e} (which vite-plugin-ssr automatically injects into the HTML) is missing from the DOM. This may happen if your HTML is malformed. Make sure your HTML isn't malformed, and make sure you don't remove #${e} from the HTML nor from the DOM.`);const n=t.textContent;s(n);const r=me(n);return s(m(r,"_pageId","string")),J(r,{_hasPageContextFromServer:!0}),r}function z(e,t){if(!(t in e.exports))return null;const n=e.exports[t],r=e.exportsAll[t][0];if(s(r.exportValue===n),n===null)return null;const i=r.exportSource;return Pt(n,{hookName:t,hookFilePath:i}),{hookFn:n,hookName:t,hookFilePath:i}}function on(e,t){z(e,t)}function Pt(e,{hookName:t,hookFilePath:n}){s(t&&n),s(!t.endsWith(")")),h(Y(e),`hook ${t}() defined by ${n} should be a function`)}function Tt(e){const t=Object.entries(e);for(const n in e)delete e[n];t.sort(([n],[r])=>Ge(n,r)).forEach(([n,r])=>{e[n]=r})}function xt(e){It(e),_t(e)}function It(e){lt(e._pageId,e._pageConfigs)&&s(m(e,"is404","boolean"))}function _t(e){if(e.is404===void 0||e.is404===null)return;const t=e.pageProps||{};if(!b(t)){P(!1,"pageContext.pageProps should be an object",{showStackTrace:!0,onlyOnce:!0});return}t.is404=t.is404||e.is404,e.pageProps=t}const jt="not-serializable",F=x("getPageContextProxyForUser.ts",{});function Lt(e){return s([!0,!1].includes(e._hasPageContextFromServer)),s([!0,!1].includes(e._hasPageContextFromClient)),new Proxy(e,{get(t,n){const r=e[n],i=JSON.stringify(n);return h(r!==jt,`pageContext[${i}] couldn't be serialized and, therefore, is missing on the client-side. Check the server logs for more information.`),Ot(e,n,`pageContext[${i}] isn't available on the client-side because ${i} is missing in passToClient, see https://vite-plugin-ssr.com/passToClient`),r}})}function Ot(e,t,n){F.prev===t||F.prev==="__v_raw"||(Ft(t),!(t in e)&&(kt(t)||e._hasPageContextFromServer&&!e._hasPageContextFromClient&&h(!1,n)))}const Ct=["then","toJSON"];function kt(e){return!!(Ct.includes(e)||typeof e=="symbol"||typeof e!="string"||e.startsWith("__v_"))}function Ft(e){F.prev=e,window.setTimeout(()=>{F.prev=void 0},0)}function Wt(e,t){if(t){const i=e;s([!0,!1].includes(i.isHydration)),s([!0,!1,null].includes(i.isBackwardNavigation))}else{const i=e;s(i.isHydration===!0),s(i.isBackwardNavigation===null)}s("config"in e),s("configEntries"in e),s("exports"in e),s("exportsAll"in e),s("pageExports"in e),s(b(e.pageExports));const n=e.exports.Page;J(e,{Page:n}),At(e),Tt(e);const r=Lt(e);return xt(e),r}function At(e){Object.entries(e).forEach(([t,n])=>{delete e[t],e[t]=n})}function Dt(e,t){const n=e.filter(i=>i.pageId===t);return s(n.length<=1),n[0]??null}async function Nt(e,t){if(e.isLoaded&&!t)return e;const n=await e.loadConfigValuesAll(),r=(i,o,a,l)=>{e.configValues[i]={value:o,definedAtInfo:{filePath:a,fileExportPath:[l]}},zt(o,i,a)};return n.forEach(i=>{if(i.isPlusFile){const{importFileExports:o,importFilePath:a}=i;i.configName!=="client"&&qe(o,a),Object.entries(o).forEach(([l,c])=>{const u=l!=="default",g=u?l:i.configName;u&&g in e.configValues||r(g,c,a,l)})}else{const{configName:o,importFilePath:a,importFileExportValue:l,importFileExportName:c}=i;r(o,l,a,c)}}),J(e,{isLoaded:!0}),e}function zt(e,t,n){s(!n.includes("+config.")),h(e!==null,`Set ${p.cyan(t)} to ${p.cyan("null")} in a +config.h.js file instead of ${n}`)}const Ee="__whileFetchingAssets";async function an(e,t,n){const r=mt(e,n),i=Dt(t,n);let o;const a=!1;try{o=(await Promise.all([i&&Nt(i,a),...r.map(y=>y.loadFile?.())]))[0]}catch(d){throw Vt(d)&&Object.assign(d,{[Ee]:!0}),d}const{config:l,configEntries:c,exports:u,exportsAll:g,pageExports:f}=it(r,o);return{config:l,configEntries:c,exports:u,exportsAll:g,pageExports:f,_pageFilesLoaded:r}}function ln(e){return e?e[Ee]===!0:!1}function Vt(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(n=>e.message.toLowerCase().includes(n.toLowerCase())):!1}async function cn(e,t){const n=Wt(e,t);let r=null,i;r=z(e,"render"),i="render";{const l=z(e,"onRenderClient");l&&(r=l,i="onRenderClient")}if(!r){const l=Ut(e);if(e._pageConfigs.length>0)h(!1,`No onRenderClient() hook defined for URL '${l}', but it's needed, see https://vite-plugin-ssr.com/onRenderClient`);else{const c=e._pageFilesLoaded.filter(g=>g.fileType===".page.client");let u;c.length===0?u="No file `*.page.client.*` found for URL "+l:u="One of the following files should export a `render()` hook: "+c.map(g=>g.filePath).join(" "),h(!1,u)}}s(r);const o=r.hookFn;s(i);const a=await wt(()=>o(n),i,r.hookFilePath);h(a===void 0,`The ${i}() hook defined by ${r.hookFilePath} isn't allowed to return a value`)}function Ut(e){let t;try{t=e.urlPathname??e.urlOriginal}catch{}return t=t??window.location.href,t}export{Wt as A,Xt as B,Kt as C,me as D,Ie as E,Qt as F,rt as G,A as H,tn as I,ze as J,mt as K,Dt as L,ce as M,_e as N,ln as O,on as P,cn as Q,Ht as R,Jt as S,Bt as T,Et as a,Mt as b,b as c,rn as d,nn as e,s as f,x as g,M as h,Y as i,P as j,p as k,h as l,Be as m,qt as n,m as o,ke as p,Yt as q,J as r,en as s,k as t,z as u,wt as v,Gt as w,sn as x,an as y,Zt as z};