@qwik.dev/router 2.0.0-beta.10 → 2.0.0-beta.11

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.
Files changed (36) hide show
  1. package/lib/adapters/azure-swa/vite/index.cjs +2 -2
  2. package/lib/adapters/azure-swa/vite/index.mjs +73 -69
  3. package/lib/adapters/bun-server/vite/index.cjs +2 -2
  4. package/lib/adapters/bun-server/vite/index.mjs +77 -73
  5. package/lib/adapters/cloud-run/vite/index.cjs +2 -2
  6. package/lib/adapters/cloud-run/vite/index.mjs +104 -100
  7. package/lib/adapters/cloudflare-pages/vite/{index-DwovcBp3.js → index-Bg_9YkM5.js} +1 -1
  8. package/lib/adapters/cloudflare-pages/vite/{index-C455V8_A.cjs → index-C1aDmh1S.cjs} +1 -1
  9. package/lib/adapters/cloudflare-pages/vite/index-CHT9Y93A.js +254 -0
  10. package/lib/adapters/cloudflare-pages/vite/{index-DKcVHRBy.cjs → index-Ck7KvpK1.cjs} +1 -1
  11. package/lib/adapters/cloudflare-pages/vite/{index-D3HITboM.js → index-Cp1cjAds.js} +1 -1
  12. package/lib/adapters/cloudflare-pages/vite/index-D9RL9dvJ.cjs +5 -0
  13. package/lib/adapters/cloudflare-pages/vite/index.cjs +1 -1
  14. package/lib/adapters/cloudflare-pages/vite/index.mjs +1 -1
  15. package/lib/adapters/deno-server/vite/index.cjs +2 -2
  16. package/lib/adapters/deno-server/vite/index.mjs +81 -77
  17. package/lib/adapters/netlify-edge/vite/index.cjs +3 -3
  18. package/lib/adapters/netlify-edge/vite/index.mjs +119 -115
  19. package/lib/adapters/node-server/vite/index.cjs +2 -2
  20. package/lib/adapters/node-server/vite/index.mjs +78 -74
  21. package/lib/adapters/shared/vite/index.cjs +2 -2
  22. package/lib/adapters/shared/vite/index.mjs +108 -104
  23. package/lib/adapters/ssg/vite/index.cjs +2 -2
  24. package/lib/adapters/ssg/vite/index.mjs +100 -96
  25. package/lib/adapters/vercel-edge/vite/index.cjs +2 -2
  26. package/lib/adapters/vercel-edge/vite/index.mjs +114 -110
  27. package/lib/index.qwik.cjs +39 -33
  28. package/lib/index.qwik.mjs +39 -33
  29. package/lib/middleware/request-handler/index.cjs +8 -8
  30. package/lib/middleware/request-handler/index.mjs +598 -587
  31. package/lib/vite/index.cjs +17 -17
  32. package/lib/vite/index.d.ts +3 -3
  33. package/lib/vite/index.mjs +242 -230
  34. package/package.json +4 -4
  35. package/lib/adapters/cloudflare-pages/vite/index-BIeHg2Cj.cjs +0 -5
  36. package/lib/adapters/cloudflare-pages/vite/index-bogwy7wh.js +0 -250
@@ -57,7 +57,9 @@ const loadClientData = async (url, element, opts, retryCount = 0) => {
57
57
  const redirectedURL = new URL(rsp.url);
58
58
  const isQData = redirectedURL.pathname.endsWith("/q-data.json");
59
59
  if (!isQData || redirectedURL.origin !== location.origin) {
60
- location.href = redirectedURL.href;
60
+ if (!opts?.isPrefetch) {
61
+ location.href = redirectedURL.href;
62
+ }
61
63
  return;
62
64
  }
63
65
  }
@@ -358,23 +360,31 @@ const resolveHead = (endpoint, routeLocation, contentModules, locale, defaults)
358
360
  }
359
361
  return data;
360
362
  };
361
- const headProps = {
362
- head,
363
- withLocale: (fn) => withLocale(locale, fn),
364
- resolveValue: getData,
365
- ...routeLocation
366
- };
367
- for (let i = contentModules.length - 1; i >= 0; i--) {
368
- const contentModuleHead = contentModules[i] && contentModules[i].head;
363
+ const fns = [];
364
+ for (const contentModule of contentModules) {
365
+ const contentModuleHead = contentModule?.head;
369
366
  if (contentModuleHead) {
370
367
  if (typeof contentModuleHead === "function") {
371
- resolveDocumentHead(head, withLocale(locale, () => contentModuleHead(headProps)));
368
+ fns.unshift(contentModuleHead);
372
369
  } else if (typeof contentModuleHead === "object") {
373
370
  resolveDocumentHead(head, contentModuleHead);
374
371
  }
375
372
  }
376
373
  }
377
- return headProps.head;
374
+ if (fns.length) {
375
+ const headProps = {
376
+ head,
377
+ withLocale: (fn) => withLocale(locale, fn),
378
+ resolveValue: getData,
379
+ ...routeLocation
380
+ };
381
+ withLocale(locale, () => {
382
+ for (const fn of fns) {
383
+ resolveDocumentHead(head, fn(headProps));
384
+ }
385
+ });
386
+ }
387
+ return head;
378
388
  };
379
389
  const resolveDocumentHead = (resolvedHead, updatedHead) => {
380
390
  if (typeof updatedHead.title === "string") {
@@ -554,7 +564,7 @@ const deepFreeze = (obj) => {
554
564
  });
555
565
  return Object.freeze(obj);
556
566
  };
557
- const loadRoute = async (routes, menus, cacheModules, pathname) => {
567
+ const loadRoute = async (routes, menus, cacheModules, pathname, isInternal) => {
558
568
  if (!Array.isArray(routes)) {
559
569
  return null;
560
570
  }
@@ -571,9 +581,11 @@ const loadRoute = async (routes, menus, cacheModules, pathname) => {
571
581
  loaders.forEach((moduleLoader, i) => {
572
582
  loadModule(moduleLoader, pendingLoads, (routeModule) => modules[i] = routeModule, cacheModules);
573
583
  });
574
- const menuLoader = getMenuLoader(menus, pathname);
575
584
  let menu = void 0;
576
- loadModule(menuLoader, pendingLoads, (menuModule) => menu = menuModule?.default, cacheModules);
585
+ {
586
+ const menuLoader = getMenuLoader(menus, pathname);
587
+ loadModule(menuLoader, pendingLoads, (menuModule) => menu = menuModule?.default, cacheModules);
588
+ }
577
589
  if (pendingLoads.length > 0) {
578
590
  await Promise.all(pendingLoads);
579
591
  }
@@ -610,7 +622,7 @@ const loadModule = (moduleLoader, pendingLoads, moduleSetter, cacheModules) => {
610
622
  const getMenuLoader = (menus, pathname) => {
611
623
  if (menus) {
612
624
  pathname = pathname.endsWith("/") ? pathname : pathname + "/";
613
- const menu = menus.find((m) => m[MenuDataProp.Pathname] === pathname || pathname.startsWith(m[MenuDataProp.Pathname] + (pathname.endsWith("/") ? "" : "/")));
625
+ const menu = menus.find((m) => m[MenuDataProp.Pathname] === pathname || pathname.startsWith(m[MenuDataProp.Pathname]));
614
626
  if (menu) {
615
627
  return menu[MenuDataProp.MenuLoader];
616
628
  }
@@ -837,6 +849,7 @@ const startViewTransition = (params) => {
837
849
  params.update?.();
838
850
  }
839
851
  };
852
+ const transitionCss = "@layer qwik {\n @supports selector(html:active-view-transition-type(type)) {\n html:active-view-transition-type(qwik-navigation) {\n :root {\n view-transition-name: none;\n }\n }\n }\n @supports not selector(html:active-view-transition-type(type)) {\n :root {\n view-transition-name: none;\n }\n }\n}\n";
840
853
  const QWIK_CITY_SCROLLER = "_qCityScroller";
841
854
  const QWIK_ROUTER_SCROLLER = "_qRouterScroller";
842
855
  const preventNav = {};
@@ -844,18 +857,7 @@ const internalState = {
844
857
  navCount: 0
845
858
  };
846
859
  const useQwikRouter = (props) => {
847
- useStyles$(`
848
- @layer qwik {
849
- @supports selector(html:active-view-transition-type(type)) {
850
- html:active-view-transition-type(qwik-navigation) {
851
- :root{view-transition-name:none}
852
- }
853
- }
854
- @supports not selector(html:active-view-transition-type(type)) {
855
- :root{view-transition-name:none}
856
- }
857
- }
858
- `);
860
+ useStyles$(transitionCss);
859
861
  const env = useQwikRouterEnv();
860
862
  if (!env?.params) {
861
863
  throw new Error(`Missing Qwik Router Env Data for help visit https://github.com/QwikDev/qwik/issues/6237`);
@@ -1409,6 +1411,7 @@ const RouterOutlet = component$(() => {
1409
1411
  return SkipRender;
1410
1412
  });
1411
1413
  var store;
1414
+ // @__NO_SIDE_EFFECTS__
1412
1415
  function getGlobalConfig(config2) {
1413
1416
  return {
1414
1417
  lang: config2?.lang ?? store?.lang,
@@ -1417,6 +1420,7 @@ function getGlobalConfig(config2) {
1417
1420
  abortPipeEarly: config2?.abortPipeEarly ?? store?.abortPipeEarly
1418
1421
  };
1419
1422
  }
1423
+ // @__NO_SIDE_EFFECTS__
1420
1424
  function getDotPath(issue) {
1421
1425
  if (issue.path) {
1422
1426
  let key = "";
@@ -1435,11 +1439,12 @@ function getDotPath(issue) {
1435
1439
  }
1436
1440
  return null;
1437
1441
  }
1442
+ // @__NO_SIDE_EFFECTS__
1438
1443
  function flatten(issues) {
1439
1444
  const flatErrors = {};
1440
1445
  for (const issue of issues) {
1441
1446
  if (issue.path) {
1442
- const dotPath = getDotPath(issue);
1447
+ const dotPath = /* @__PURE__ */ getDotPath(issue);
1443
1448
  if (dotPath) {
1444
1449
  if (!flatErrors.nested) {
1445
1450
  flatErrors.nested = {};
@@ -1466,10 +1471,11 @@ function flatten(issues) {
1466
1471
  }
1467
1472
  return flatErrors;
1468
1473
  }
1474
+ // @__NO_SIDE_EFFECTS__
1469
1475
  async function safeParseAsync(schema, input, config2) {
1470
- const dataset = await schema._run(
1471
- { typed: false, value: input },
1472
- getGlobalConfig(config2)
1476
+ const dataset = await schema["~run"](
1477
+ { value: input },
1478
+ /* @__PURE__ */ getGlobalConfig(config2)
1473
1479
  );
1474
1480
  return {
1475
1481
  typed: dataset.typed,
@@ -1645,7 +1651,7 @@ const valibotQrl = (qrl) => {
1645
1651
  async validate(ev, inputData) {
1646
1652
  const schema = await qrl.resolve().then((obj) => typeof obj === "function" ? obj(ev) : obj);
1647
1653
  const data = inputData ?? await ev.parseBody();
1648
- const result = await safeParseAsync(schema, data);
1654
+ const result = await /* @__PURE__ */ safeParseAsync(schema, data);
1649
1655
  if (result.success) {
1650
1656
  return {
1651
1657
  success: true,
@@ -1659,7 +1665,7 @@ const valibotQrl = (qrl) => {
1659
1665
  success: false,
1660
1666
  status: 400,
1661
1667
  error: {
1662
- formErrors: flatten(result.issues).root ?? [],
1668
+ formErrors: (/* @__PURE__ */ flatten(result.issues)).root ?? [],
1663
1669
  fieldErrors: flattenValibotIssues(result.issues)
1664
1670
  }
1665
1671
  };
@@ -1,18 +1,18 @@
1
- "use strict";var De=Object.create;var ne=Object.defineProperty;var Se=Object.getOwnPropertyDescriptor;var $e=Object.getOwnPropertyNames;var Fe=Object.getPrototypeOf,Qe=Object.prototype.hasOwnProperty;var Ee=(e,r,n,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of $e(r))!Qe.call(e,i)&&i!==n&&ne(e,i,{get:()=>r[i],enumerable:!(t=Se(r,i))||t.enumerable});return e};var re=(e,r,n)=>(n=e!=null?De(Fe(e)):{},Ee(r||!e||!e.__esModule?ne(n,"default",{value:e,enumerable:!0}):n,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("@qwik.dev/core/internal");require("@qwik.dev/core");const _=require("@qwik.dev/router/middleware/request-handler"),te=new WeakMap,ie="qaction",Y="qloaders",ze="qfunc",oe="qdata",je="q:route";function Ge(e,r){const n=ce(e),t=ae(e),i=ce(r),o=ae(r);return pe(e,n,t,r,i,o)}function pe(e,r,n,t,i,o){if(t.startsWith("/build/"))return null;let a=null;for(;r<n;){const s=e.charCodeAt(r++),c=t.charCodeAt(i++);if(s===91){const f=Re(e,r),l=r+(f?3:0),u=K(e,l,n,93),h=e.substring(l,u),y=K(e,u+1,n,47),w=e.substring(u+1,y);r=u+1;const R=i-1;if(f){const x=Ke(h,w,t,R,o,e,r+w.length+1,n);if(x)return Object.assign(a||(a={}),x)}const p=K(t,R,o,47,w);if(p==-1)return null;const N=t.substring(R,p);if(!f&&!w&&!N)return null;i=p,(a||(a={}))[h]=decodeURIComponent(N)}else if(s!==c&&!(isNaN(c)&&Be(e,r)))return null}return se(e,r)&&se(t,i)?a||{}:null}function Be(e,r){return e.charCodeAt(r)===91&&Re(e,r+1)}function ae(e){const r=e.length;return r>1&&e.charCodeAt(r-1)===47?r-1:r}function se(e,r){const n=e.length;return r>=n||r==n-1&&e.charCodeAt(r)===47}function ce(e){return e.charCodeAt(0)===47?1:0}function Re(e,r){return e.charCodeAt(r)===46&&e.charCodeAt(r+1)===46&&e.charCodeAt(r+2)===46}function K(e,r,n,t,i=""){for(;r<n&&e.charCodeAt(r)!==t;)r++;const o=i.length;for(let a=0;a<o;a++)if(e.charCodeAt(r-o+a)!==i.charCodeAt(a))return-1;return r-o}function Ke(e,r,n,t,i,o,a,s){n.charCodeAt(t)===47&&t++;let c=i;const f=r+"/";for(;c>=t;){const l=pe(o,a,s,n,c,i);if(l){let h=n.substring(t,Math.min(c,i));return h.endsWith(f)&&(h=h.substring(0,h.length-f.length)),l[e]=decodeURIComponent(h),l}const u=ve(n,t,f,c,t-1)+f.length;if(c===u)break;c=u}return null}function ve(e,r,n,t,i){let o=e.lastIndexOf(n,t);return o==t-n.length&&(o=e.lastIndexOf(n,t-n.length-1)),o>r?o:i}var S=(e=>(e[e.RouteName=0]="RouteName",e[e.Loaders=1]="Loaders",e[e.OriginalPathname=2]="OriginalPathname",e[e.RouteBundleNames=3]="RouteBundleNames",e))(S||{}),$=(e=>(e[e.Pathname=0]="Pathname",e[e.MenuLoader=1]="MenuLoader",e))($||{}),U=(e=>(e[e.RouteName=0]="RouteName",e[e.Params=1]="Params",e[e.Mods=2]="Mods",e[e.Menu=3]="Menu",e[e.RouteBundleNames=4]="RouteBundleNames",e))(U||{});const be=e=>e==null?e:(Object.getOwnPropertyNames(e).forEach(r=>{const n=e[r];n&&typeof n=="object"&&!Object.isFrozen(n)&&be(n)}),Object.freeze(e)),Je=async(e,r,n,t)=>{if(!Array.isArray(e))return null;for(const i of e){const o=i[S.RouteName],a=Ge(o,t);if(!a)continue;const s=i[S.Loaders],c=i[S.RouteBundleNames],f=new Array(s.length),l=[];s.forEach((y,w)=>{le(y,l,R=>f[w]=R,n)});const u=Ye(r,t);let h;return le(u,l,y=>h=y?.default,n),l.length>0&&await Promise.all(l),[o,a,f,be(h),c]}return null},le=(e,r,n,t)=>{if(typeof e=="function"){const i=te.get(e);if(i)n(i);else{const o=e();typeof o.then=="function"?r.push(o.then(a=>{t!==!1&&te.set(e,a),n(a)})):o&&n(o)}}},Ye=(e,r)=>{if(e){r=r.endsWith("/")?r:r+"/";const n=e.find(t=>t[$.Pathname]===r||r.startsWith(t[$.Pathname]+(r.endsWith("/")?"":"/")));if(n)return n[$.MenuLoader]}};var V=(e=>(e[e.Continue=100]="Continue",e[e.SwitchingProtocols=101]="SwitchingProtocols",e[e.Processing=102]="Processing",e[e.Ok=200]="Ok",e[e.Created=201]="Created",e[e.Accepted=202]="Accepted",e[e.NonAuthoritativeInformation=203]="NonAuthoritativeInformation",e[e.NoContent=204]="NoContent",e[e.ResetContent=205]="ResetContent",e[e.PartialContent=206]="PartialContent",e[e.MultiStatus=207]="MultiStatus",e[e.AlreadyReported=208]="AlreadyReported",e[e.ImUsed=226]="ImUsed",e[e.MultipleChoices=300]="MultipleChoices",e[e.MovedPermanently=301]="MovedPermanently",e[e.Found=302]="Found",e[e.SeeOther=303]="SeeOther",e[e.NotModified=304]="NotModified",e[e.UseProxy=305]="UseProxy",e[e.SwitchProxy=306]="SwitchProxy",e[e.TemporaryRedirect=307]="TemporaryRedirect",e[e.PermanentRedirect=308]="PermanentRedirect",e[e.BadRequest=400]="BadRequest",e[e.Unauthorized=401]="Unauthorized",e[e.PaymentRequired=402]="PaymentRequired",e[e.Forbidden=403]="Forbidden",e[e.NotFound=404]="NotFound",e[e.MethodNotAllowed=405]="MethodNotAllowed",e[e.NotAcceptable=406]="NotAcceptable",e[e.ProxyAuthenticationRequired=407]="ProxyAuthenticationRequired",e[e.RequestTimeout=408]="RequestTimeout",e[e.Conflict=409]="Conflict",e[e.Gone=410]="Gone",e[e.LengthRequired=411]="LengthRequired",e[e.PreconditionFailed=412]="PreconditionFailed",e[e.PayloadTooLarge=413]="PayloadTooLarge",e[e.UriTooLong=414]="UriTooLong",e[e.UnsupportedMediaType=415]="UnsupportedMediaType",e[e.RangeNotSatisfiable=416]="RangeNotSatisfiable",e[e.ExpectationFailed=417]="ExpectationFailed",e[e.IAmATeapot=418]="IAmATeapot",e[e.MisdirectedRequest=421]="MisdirectedRequest",e[e.UnprocessableEntity=422]="UnprocessableEntity",e[e.Locked=423]="Locked",e[e.FailedDependency=424]="FailedDependency",e[e.UpgradeRequired=426]="UpgradeRequired",e[e.PreconditionRequired=428]="PreconditionRequired",e[e.TooManyRequests=429]="TooManyRequests",e[e.RequestHeaderFieldsTooLarge=431]="RequestHeaderFieldsTooLarge",e[e.UnavailableForLegalReasons=451]="UnavailableForLegalReasons",e[e.InternalServerError=500]="InternalServerError",e[e.NotImplemented=501]="NotImplemented",e[e.BadGateway=502]="BadGateway",e[e.ServiceUnavailable=503]="ServiceUnavailable",e[e.GatewayTimeout=504]="GatewayTimeout",e[e.HttpVersionNotSupported=505]="HttpVersionNotSupported",e[e.VariantAlsoNegotiates=506]="VariantAlsoNegotiates",e[e.InsufficientStorage=507]="InsufficientStorage",e[e.LoopDetected=508]="LoopDetected",e[e.NotExtended=510]="NotExtended",e[e.NetworkAuthenticationRequired=511]="NetworkAuthenticationRequired",e))(V||{});const Ve=e=>e&&typeof e.then=="function";function Xe(e){const r=[];return e==="day"?e=3600*24:e==="week"?e=3600*24*7:e==="month"?e=3600*24*30:e==="year"?e=3600*24*365:e==="private"?e={private:!0,noCache:!0}:e==="immutable"?e={public:!0,immutable:!0,maxAge:3600*24*365}:e==="no-cache"&&(e={noCache:!0}),typeof e=="number"&&(e={maxAge:e,sMaxAge:e}),e.immutable&&r.push("immutable"),e.maxAge&&r.push(`max-age=${e.maxAge}`),e.sMaxAge&&r.push(`s-maxage=${e.sMaxAge}`),e.noStore&&r.push("no-store"),e.noCache&&r.push("no-cache"),e.private&&r.push("private"),e.public&&r.push("public"),e.staleWhileRevalidate&&r.push(`stale-while-revalidate=${e.staleWhileRevalidate}`),e.staleIfError&&r.push(`stale-if-error=${e.staleIfError}`),r.join(", ")}const Ze={lax:"Lax",Lax:"Lax",None:"None",none:"None",strict:"Strict",Strict:"Strict"},He={seconds:1,minutes:60,hours:3600,days:3600*24,weeks:3600*24*7},de=(e,r,n)=>{const t=[`${e}=${r}`];typeof n.domain=="string"&&t.push(`Domain=${n.domain}`),typeof n.maxAge=="number"?t.push(`Max-Age=${n.maxAge}`):Array.isArray(n.maxAge)?t.push(`Max-Age=${n.maxAge[0]*He[n.maxAge[1]]}`):typeof n.expires=="number"||typeof n.expires=="string"?t.push(`Expires=${n.expires}`):n.expires instanceof Date&&t.push(`Expires=${n.expires.toUTCString()}`),n.httpOnly&&t.push("HttpOnly"),typeof n.path=="string"&&t.push(`Path=${n.path}`);const i=nn(n.sameSite);return i&&t.push(`SameSite=${i}`),n.secure&&t.push("Secure"),t.join("; ")};function fe(e){try{return decodeURIComponent(e)}catch{return e}}const en=e=>{const r={};if(typeof e=="string"&&e!==""){const n=e.split(";");for(const t of n){const i=t.indexOf("=");i!==-1&&(r[fe(t.slice(0,i).trim())]=fe(t.slice(i+1).trim()))}}return r};function nn(e){if(e===!0)return"Strict";if(e===!1)return"None";if(e)return Ze[e]}const P=Symbol("request-cookies"),D=Symbol("response-cookies"),M=Symbol("live-cookies");class rn{[P];[D]={};[M]={};appendCounter=0;constructor(r){this[P]=en(r),this[M]={...this[P]}}get(r,n=!0){const t=this[n?M:P][r];return t?{value:t,json(){return JSON.parse(t)},number(){return Number(t)}}:null}getAll(r=!0){return Object.keys(this[r?M:P]).reduce((n,t)=>(n[t]=this.get(t),n),{})}has(r,n=!0){return!!this[n?M:P][r]}set(r,n,t={}){this[M][r]=typeof n=="string"?n:JSON.stringify(n);const i=typeof n=="string"?n:encodeURIComponent(JSON.stringify(n));this[D][r]=de(r,i,t)}append(r,n,t={}){this[M][r]=typeof n=="string"?n:JSON.stringify(n);const i=typeof n=="string"?n:encodeURIComponent(JSON.stringify(n));this[D][++this.appendCounter]=de(r,i,t)}delete(r,n){this.set(r,"deleted",{...n,maxAge:0}),this[M][r]=null}headers(){return Object.values(this[D])}}const tn=(e,r)=>{const n=r.headers();if(n.length>0){const t=new Headers(e);for(const i of n)t.append("Set-Cookie",i);return t}return e};function F(e,r){let n="Server Error";return r!=null&&(typeof r.message=="string"?n=r.message:n=String(r)),"<html>"+_e(e,n)+"</html>"}function _e(e,r){typeof e!="number"&&(e=500),typeof r=="string"?r=an(r):r="";const n=typeof r=="string"?"600px":"300px",t=e>=500?cn:sn;return`
1
+ "use strict";var De=Object.create;var te=Object.defineProperty;var Se=Object.getOwnPropertyDescriptor;var Fe=Object.getOwnPropertyNames;var Qe=Object.getPrototypeOf,Ee=Object.prototype.hasOwnProperty;var ze=(e,n,r,t)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of Fe(n))!Ee.call(e,i)&&i!==r&&te(e,i,{get:()=>n[i],enumerable:!(t=Se(n,i))||t.enumerable});return e};var ie=(e,n,r)=>(r=e!=null?De(Qe(e)):{},ze(n||!e||!e.__esModule?te(r,"default",{value:e,enumerable:!0}):r,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const M=require("@qwik.dev/core/internal");require("@qwik.dev/core");const b=require("@qwik.dev/router/middleware/request-handler"),oe=new WeakMap,ae="qaction",J="qloaders",je="qfunc",se="qdata",Ge="q:route";function Be(e,n){const r=de(e),t=ce(e),i=de(n),o=ce(n);return pe(e,r,t,n,i,o)}function pe(e,n,r,t,i,o){if(t.startsWith("/build/"))return null;let a=null;for(;n<r;){const c=e.charCodeAt(n++),s=t.charCodeAt(i++);if(c===91){const l=Re(e,n),f=n+(l?3:0),u=G(e,f,r,93),m=e.substring(f,u),p=G(e,u+1,r,47),g=e.substring(u+1,p);n=u+1;const w=i-1;if(l){const R=Ke(m,g,t,w,o,e,n+g.length+1,r);if(R)return Object.assign(a||(a={}),R)}const A=G(t,w,o,47,g);if(A==-1)return null;const x=t.substring(w,A);if(!l&&!g&&!x)return null;i=A,(a||(a={}))[m]=decodeURIComponent(x)}else if(c!==s&&!(isNaN(s)&&ve(e,n)))return null}return le(e,n)&&le(t,i)?a||{}:null}function ve(e,n){return e.charCodeAt(n)===91&&Re(e,n+1)}function ce(e){const n=e.length;return n>1&&e.charCodeAt(n-1)===47?n-1:n}function le(e,n){const r=e.length;return n>=r||n==r-1&&e.charCodeAt(n)===47}function de(e){return e.charCodeAt(0)===47?1:0}function Re(e,n){return e.charCodeAt(n)===46&&e.charCodeAt(n+1)===46&&e.charCodeAt(n+2)===46}function G(e,n,r,t,i=""){for(;n<r&&e.charCodeAt(n)!==t;)n++;const o=i.length;for(let a=0;a<o;a++)if(e.charCodeAt(n-o+a)!==i.charCodeAt(a))return-1;return n-o}function Ke(e,n,r,t,i,o,a,c){r.charCodeAt(t)===47&&t++;let s=i;const l=n+"/";for(;s>=t;){const f=pe(o,a,c,r,s,i);if(f){let m=r.substring(t,Math.min(s,i));return m.endsWith(l)&&(m=m.substring(0,m.length-l.length)),f[e]=decodeURIComponent(m),f}const u=Je(r,t,l,s,t-1)+l.length;if(s===u)break;s=u}return null}function Je(e,n,r,t,i){let o=e.lastIndexOf(r,t);return o==t-r.length&&(o=e.lastIndexOf(r,t-r.length-1)),o>n?o:i}var $=(e=>(e[e.RouteName=0]="RouteName",e[e.Loaders=1]="Loaders",e[e.OriginalPathname=2]="OriginalPathname",e[e.RouteBundleNames=3]="RouteBundleNames",e))($||{}),D=(e=>(e[e.Pathname=0]="Pathname",e[e.MenuLoader=1]="MenuLoader",e))(D||{}),U=(e=>(e[e.RouteName=0]="RouteName",e[e.Params=1]="Params",e[e.Mods=2]="Mods",e[e.Menu=3]="Menu",e[e.RouteBundleNames=4]="RouteBundleNames",e))(U||{});const be=e=>e==null?e:(Object.getOwnPropertyNames(e).forEach(n=>{const r=e[n];r&&typeof r=="object"&&!Object.isFrozen(r)&&be(r)}),Object.freeze(e)),Ye=async(e,n,r,t,i)=>{if(!Array.isArray(e))return null;for(const o of e){const a=o[$.RouteName],c=Be(a,t);if(!c)continue;const s=o[$.Loaders],l=o[$.RouteBundleNames],f=new Array(s.length),u=[];s.forEach((p,g)=>{fe(p,u,w=>f[g]=w,r)});let m;if(!i){const p=Ve(n,t);fe(p,u,g=>m=g?.default,r)}return u.length>0&&await Promise.all(u),[a,c,f,be(m),l]}return null},fe=(e,n,r,t)=>{if(typeof e=="function"){const i=oe.get(e);if(i)r(i);else{const o=e();typeof o.then=="function"?n.push(o.then(a=>{t!==!1&&oe.set(e,a),r(a)})):o&&r(o)}}},Ve=(e,n)=>{if(e){n=n.endsWith("/")?n:n+"/";const r=e.find(t=>t[D.Pathname]===n||n.startsWith(t[D.Pathname]));if(r)return r[D.MenuLoader]}};var Y=(e=>(e[e.Continue=100]="Continue",e[e.SwitchingProtocols=101]="SwitchingProtocols",e[e.Processing=102]="Processing",e[e.Ok=200]="Ok",e[e.Created=201]="Created",e[e.Accepted=202]="Accepted",e[e.NonAuthoritativeInformation=203]="NonAuthoritativeInformation",e[e.NoContent=204]="NoContent",e[e.ResetContent=205]="ResetContent",e[e.PartialContent=206]="PartialContent",e[e.MultiStatus=207]="MultiStatus",e[e.AlreadyReported=208]="AlreadyReported",e[e.ImUsed=226]="ImUsed",e[e.MultipleChoices=300]="MultipleChoices",e[e.MovedPermanently=301]="MovedPermanently",e[e.Found=302]="Found",e[e.SeeOther=303]="SeeOther",e[e.NotModified=304]="NotModified",e[e.UseProxy=305]="UseProxy",e[e.SwitchProxy=306]="SwitchProxy",e[e.TemporaryRedirect=307]="TemporaryRedirect",e[e.PermanentRedirect=308]="PermanentRedirect",e[e.BadRequest=400]="BadRequest",e[e.Unauthorized=401]="Unauthorized",e[e.PaymentRequired=402]="PaymentRequired",e[e.Forbidden=403]="Forbidden",e[e.NotFound=404]="NotFound",e[e.MethodNotAllowed=405]="MethodNotAllowed",e[e.NotAcceptable=406]="NotAcceptable",e[e.ProxyAuthenticationRequired=407]="ProxyAuthenticationRequired",e[e.RequestTimeout=408]="RequestTimeout",e[e.Conflict=409]="Conflict",e[e.Gone=410]="Gone",e[e.LengthRequired=411]="LengthRequired",e[e.PreconditionFailed=412]="PreconditionFailed",e[e.PayloadTooLarge=413]="PayloadTooLarge",e[e.UriTooLong=414]="UriTooLong",e[e.UnsupportedMediaType=415]="UnsupportedMediaType",e[e.RangeNotSatisfiable=416]="RangeNotSatisfiable",e[e.ExpectationFailed=417]="ExpectationFailed",e[e.IAmATeapot=418]="IAmATeapot",e[e.MisdirectedRequest=421]="MisdirectedRequest",e[e.UnprocessableEntity=422]="UnprocessableEntity",e[e.Locked=423]="Locked",e[e.FailedDependency=424]="FailedDependency",e[e.UpgradeRequired=426]="UpgradeRequired",e[e.PreconditionRequired=428]="PreconditionRequired",e[e.TooManyRequests=429]="TooManyRequests",e[e.RequestHeaderFieldsTooLarge=431]="RequestHeaderFieldsTooLarge",e[e.UnavailableForLegalReasons=451]="UnavailableForLegalReasons",e[e.InternalServerError=500]="InternalServerError",e[e.NotImplemented=501]="NotImplemented",e[e.BadGateway=502]="BadGateway",e[e.ServiceUnavailable=503]="ServiceUnavailable",e[e.GatewayTimeout=504]="GatewayTimeout",e[e.HttpVersionNotSupported=505]="HttpVersionNotSupported",e[e.VariantAlsoNegotiates=506]="VariantAlsoNegotiates",e[e.InsufficientStorage=507]="InsufficientStorage",e[e.LoopDetected=508]="LoopDetected",e[e.NotExtended=510]="NotExtended",e[e.NetworkAuthenticationRequired=511]="NetworkAuthenticationRequired",e))(Y||{});const Xe=e=>e&&typeof e.then=="function";function Ze(e){const n=[];return e==="day"?e=3600*24:e==="week"?e=3600*24*7:e==="month"?e=3600*24*30:e==="year"?e=3600*24*365:e==="private"?e={private:!0,noCache:!0}:e==="immutable"?e={public:!0,immutable:!0,maxAge:3600*24*365}:e==="no-cache"&&(e={noCache:!0}),typeof e=="number"&&(e={maxAge:e,sMaxAge:e}),e.immutable&&n.push("immutable"),e.maxAge&&n.push(`max-age=${e.maxAge}`),e.sMaxAge&&n.push(`s-maxage=${e.sMaxAge}`),e.noStore&&n.push("no-store"),e.noCache&&n.push("no-cache"),e.private&&n.push("private"),e.public&&n.push("public"),e.staleWhileRevalidate&&n.push(`stale-while-revalidate=${e.staleWhileRevalidate}`),e.staleIfError&&n.push(`stale-if-error=${e.staleIfError}`),n.join(", ")}const He={lax:"Lax",Lax:"Lax",None:"None",none:"None",strict:"Strict",Strict:"Strict"},en={seconds:1,minutes:60,hours:3600,days:3600*24,weeks:3600*24*7},ue=(e,n,r)=>{const t=[`${e}=${n}`];typeof r.domain=="string"&&t.push(`Domain=${r.domain}`),typeof r.maxAge=="number"?t.push(`Max-Age=${r.maxAge}`):Array.isArray(r.maxAge)?t.push(`Max-Age=${r.maxAge[0]*en[r.maxAge[1]]}`):typeof r.expires=="number"||typeof r.expires=="string"?t.push(`Expires=${r.expires}`):r.expires instanceof Date&&t.push(`Expires=${r.expires.toUTCString()}`),r.httpOnly&&t.push("HttpOnly"),typeof r.path=="string"&&t.push(`Path=${r.path}`);const i=rn(r.sameSite);return i&&t.push(`SameSite=${i}`),r.secure&&t.push("Secure"),t.join("; ")};function he(e){try{return decodeURIComponent(e)}catch{return e}}const nn=e=>{const n={};if(typeof e=="string"&&e!==""){const r=e.split(";");for(const t of r){const i=t.indexOf("=");i!==-1&&(n[he(t.slice(0,i).trim())]=he(t.slice(i+1).trim()))}}return n};function rn(e){if(e===!0)return"Strict";if(e===!1)return"None";if(e)return He[e]}const I=Symbol("request-cookies"),W=Symbol("response-cookies"),N=Symbol("live-cookies");class tn{[I];[W]={};[N]={};appendCounter=0;constructor(n){this[I]=nn(n),this[N]={...this[I]}}get(n,r=!0){const t=this[r?N:I][n];return t?{value:t,json(){return JSON.parse(t)},number(){return Number(t)}}:null}getAll(n=!0){return Object.keys(this[n?N:I]).reduce((r,t)=>(r[t]=this.get(t),r),{})}has(n,r=!0){return!!this[r?N:I][n]}set(n,r,t={}){this[N][n]=typeof r=="string"?r:JSON.stringify(r);const i=typeof r=="string"?r:encodeURIComponent(JSON.stringify(r));this[W][n]=ue(n,i,t)}append(n,r,t={}){this[N][n]=typeof r=="string"?r:JSON.stringify(r);const i=typeof r=="string"?r:encodeURIComponent(JSON.stringify(r));this[W][++this.appendCounter]=ue(n,i,t)}delete(n,r){this.set(n,"deleted",{...r,maxAge:0}),this[N][n]=null}headers(){return Object.values(this[W])}}const on=(e,n)=>{const r=n.headers();if(r.length>0){const t=new Headers(e);for(const i of r)t.append("Set-Cookie",i);return t}return e};function S(e,n){let r="Server Error";return n!=null&&(typeof n.message=="string"?r=n.message:r=String(n)),"<html>"+Ae(e,r)+"</html>"}function Ae(e,n){typeof e!="number"&&(e=500),typeof n=="string"?n=sn(n):n="";const r=typeof n=="string"?"600px":"300px",t=e>=500?ln:cn;return`
2
2
  <head>
3
3
  <meta charset="utf-8">
4
4
  <meta http-equiv="Status" content="${e}">
5
- <title>${e} ${r}</title>
5
+ <title>${e} ${n}</title>
6
6
  <meta name="viewport" content="width=device-width,initial-scale=1">
7
7
  <style>
8
8
  body { color: ${t}; background-color: #fafafa; padding: 30px; font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, Roboto, sans-serif; }
9
- p { max-width: ${n}; margin: 60px auto 30px auto; background: white; border-radius: 4px; box-shadow: 0px 0px 50px -20px ${t}; overflow: hidden; }
9
+ p { max-width: ${r}; margin: 60px auto 30px auto; background: white; border-radius: 4px; box-shadow: 0px 0px 50px -20px ${t}; overflow: hidden; }
10
10
  strong { display: inline-block; padding: 15px; background: ${t}; color: white; }
11
11
  span { display: inline-block; padding: 15px; }
12
12
  </style>
13
13
  </head>
14
- <body><p><strong>${e}</strong> <span>${r}</span></p></body>
15
- `}const on=/[&<>]/g,an=e=>e.replace(on,r=>{switch(r){case"&":return"&amp;";case"<":return"&lt;";case">":return"&gt;";default:return""}}),sn="#006ce9",cn="#713fc2";let Q;import("node:async_hooks").then(e=>{const r=e.AsyncLocalStorage;Q=new r,globalThis.qcAsyncRequestStore=Q}).catch(e=>{console.warn("AsyncLocalStorage not available, continuing without it. This might impact concurrent server calls.",e)});function ln(e,r,n,t,i="/"){let o;const a=new Promise(c=>o=c),s=fn(e,r,n,i,o);return{response:a,requestEv:s,completion:Q?Q.run(s,ue,s,t,o):ue(s,t,o)}}async function ue(e,r,n){try{(a=>new URL(a.pathname+a.search,a))(e.originalUrl)}catch{const a="Resource Not Found";e.status(404);const s=F(404,a);return e.html(404,s),new _.ServerError(404,a)}let t=1;async function i(){try{await e.next()}catch(o){if(o instanceof _.RedirectMessage)await e.getWritableStream().close();else if(o instanceof _.RewriteMessage){if(t>50)throw new Error("Infinite rewrite loop");t+=1;const a=new URL(e.url);a.pathname=o.pathname;const{loadedRoute:s,requestHandlers:c}=await r(a);return e.resetRoute(s,c,a),await i()}else if(o instanceof _.ServerError){if(!e.headersSent){const a=o.status,s=e.request.headers.get("Accept");if(s&&!s.includes("text/html"))e.headers.set("Content-Type","application/qwik-json"),e.send(a,await T._serialize([o.data]));else{const c=F(o.status,o.data);e.html(a,c)}}}else if(!(o instanceof _.AbortMessage)){if(L(e)!=="dev")try{e.headersSent||(e.headers.set("content-type","text/html; charset=utf-8"),e.cacheControl({noCache:!0}),e.status(500));const a=e.getWritableStream();if(!a.locked){const s=a.getWriter();await s.write(j.encode(F(500,"Internal Server Error"))),await s.close()}}catch{console.error("Unable to render error page")}return o}}}try{return await i()}finally{e.isDirty()||n(null)}}function he(e){if(e.endsWith(I)){const r=e.length-Ae+(globalThis.__NO_TRAILING_SLASH__?0:1);e=e.slice(0,r),e===""&&(e="/")}return e}const q="@isQData",I="/q-data.json",Ae=I.length,Te=Symbol("RequestEvLoaders"),Me=Symbol("RequestEvMode"),Ne=Symbol("RequestEvRoute"),xe=Symbol("RequestEvLoaderSerializationStrategyMap"),Ce="@routeName",z="@actionId",Pe="@actionFormData",dn="@nonce",Ie="@rewrite",X="@serverTiming",H="qData";function fn(e,r,n,t,i){const{request:o,platform:a,env:s}=e,c=new Map,f=new rn(o.headers.get("cookie")),l=new Headers,u=new URL(o.url);u.pathname.endsWith(I)&&(u.pathname=u.pathname.slice(0,-Ae),!globalThis.__NO_TRAILING_SLASH__&&!u.pathname.endsWith("/")&&(u.pathname+="/"),c.set(q,!0));let h=-1,y=null,w,R=e.locale,p=200;const N=async()=>{for(h++;h<n.length;){const d=n[h],m=globalThis.qcAsyncRequestStore,g=m?.run?m.run(b,d,b):d(b);Ve(g)&&await g,h++}},x=(d,m,g=u)=>{r=d,n=m,u.pathname=g.pathname,u.search=g.search,h=-1},C=()=>{if(y!==null)throw new Error("Response already sent")},k=(d,m)=>{if(C(),typeof d=="number"){p=d;const A=b.getWritableStream().getWriter();A.write(typeof m=="string"?j.encode(m):m),A.close()}else if(p=d.status,d.headers.forEach((g,A)=>{A.toLowerCase()!=="set-cookie"&&l.append(A,g)}),d.headers.getSetCookie().forEach(g=>{const A=g.indexOf("=");if(A===-1)return;const We=g.slice(0,A).trim(),ke=g.slice(A+1).trim();f.set(We,ke)}),d.body){const g=b.getWritableStream();d.body.pipeTo(g)}else b.getWritableStream().getWriter().close();return B()},B=()=>(h=me,new _.AbortMessage),O={},b={[Te]:O,[xe]:new Map,[Me]:e.mode,get[Ne](){return r},cookie:f,headers:l,env:s,method:o.method,signal:o.signal,originalUrl:new URL(u),get params(){return r?.[U.Params]??{}},get pathname(){return u.pathname},platform:a,get query(){return u.searchParams},request:o,url:u,basePathname:t,sharedMap:c,get headersSent(){return y!==null},get exited(){return h>=me},get clientConn(){return e.getClientConn()},next:N,resetRoute:x,exit:B,cacheControl:(d,m="Cache-Control")=>{C(),l.set(m,Xe(d))},resolveValue:(async d=>{const m=d.__id;if(d.__brand==="server_loader"){if(!(m in O))throw new Error("You can not get the returned data of a loader that has not been executed for this request.");if(O[m]===T._UNINITIALIZED){const g=L(b)==="dev";await Oe(d,O,b,g)}}return O[m]}),status:d=>typeof d=="number"?(C(),p=d,d):p,locale:d=>(typeof d=="string"&&(R=d),R||""),error:(d,m)=>(p=d,l.delete("Cache-Control"),new _.ServerError(d,m)),redirect:(d,m)=>{if(C(),p=d,m){const g=m.replace(/([^:])\/{2,}/g,"$1/");m!==g&&console.warn(`Redirect URL ${m} is invalid, fixing to ${g}`),l.set("Location",g)}return l.delete("Cache-Control"),d>301&&l.set("Cache-Control","no-store"),B(),new _.RedirectMessage},rewrite:d=>{if(C(),d.startsWith("http"))throw new Error("Rewrite does not support absolute urls");return c.set(Ie,!0),new _.RewriteMessage(d.replace(/\/+/g,"/"))},defer:d=>typeof d=="function"?d:()=>d,fail:(d,m)=>(C(),p=d,l.delete("Cache-Control"),{failed:!0,...m}),text:(d,m)=>(l.set("Content-Type","text/plain; charset=utf-8"),k(d,m)),html:(d,m)=>(l.set("Content-Type","text/html; charset=utf-8"),k(d,m)),parseBody:async()=>w!==void 0?w:w=hn(b,c),json:(d,m)=>(l.set("Content-Type","application/json; charset=utf-8"),k(d,JSON.stringify(m))),send:k,isDirty:()=>y!==null,getWritableStream:()=>{if(y===null){if(e.mode==="dev"){const d=c.get(X);d&&l.set("Server-Timing",d.map(([m,g])=>`${m};dur=${g}`).join(","))}y=e.getWritableStream(p,l,f,i,b)}return y}};return Object.freeze(b)}function W(e){return e[Te]}function Le(e){return e[xe]}function un(e){return e[Ne]}function L(e){return e[Me]}const me=Number.MAX_SAFE_INTEGER,hn=async({request:e,method:r,query:n},t)=>{const i=e.headers.get("content-type")?.split(/[;,]/,1)[0].trim()??"";if(i==="application/x-www-form-urlencoded"||i==="multipart/form-data"){const o=await e.formData();return t.set(Pe,o),mn(o)}else{if(i==="application/json")return await e.json();if(i==="application/qwik-json"){if(r==="GET"&&n.has(oe)){const o=n.get(oe);if(o)try{return T._deserialize(decodeURIComponent(o))}catch{}}return T._deserialize(await e.text())}}},mn=e=>[...e.entries()].reduce((n,[t,i])=>(t.split(".").reduce((o,a,s,c)=>{if(a.endsWith("[]")){const f=a.slice(0,-2);return o[f]=o[f]||[],o[f]=[...o[f],i]}return s<c.length-1?o[a]=o[a]||(Number.isNaN(+c[s+1])?{}:[]):o[a]=i},n),n),{});function gn(e){const{params:r,request:n,status:t,locale:i,originalUrl:o}=e,a={};n.headers.forEach((N,x)=>a[x]=N);const s=e.sharedMap.get(z),c=e.sharedMap.get(Pe),f=e.sharedMap.get(Ce),l=e.sharedMap.get(dn),u=e.request.headers,h=new URL(o.pathname+o.search,o),y=u.get("X-Forwarded-Host"),w=u.get("X-Forwarded-Proto");y&&(h.port="",h.host=y),w&&(h.protocol=w);const R=W(e),p=Le(e);return{url:h.href,requestHeaders:a,locale:i(),nonce:l,containerAttributes:{[je]:f},qwikrouter:{routeName:f,ev:e,params:{...r},loadedRoute:un(e),response:{status:t(),loaders:R,loadersSerializationStrategy:p,action:s,formData:c}}}}const yn=(e,r,n,t,i)=>{const o=[],a=[],s=[],c=!!(r&&Tn(r[U.Mods]));if(e&&ge(o,a,s,e,c,n),r){const f=r[U.RouteName];t&&(n==="POST"||n==="PUT"||n==="PATCH"||n==="DELETE")&&(t==="lax-proto"?s.unshift(Mn):s.unshift(Nn)),c&&((n==="POST"||n==="GET")&&s.push(bn),s.push(_n),s.push(Pn));const l=r[U.Mods];s.push(Cn),ge(o,a,s,l,c,n),c&&(s.push(u=>{u.sharedMap.set(Ce,f)}),s.push(wn(a)),s.push(pn(o)),s.push(i))}return s},ge=(e,r,n,t,i,o)=>{for(const a of t){typeof a.onRequest=="function"?n.push(a.onRequest):Array.isArray(a.onRequest)&&n.push(...a.onRequest);let s;switch(o){case"GET":{s=a.onGet;break}case"POST":{s=a.onPost;break}case"PUT":{s=a.onPut;break}case"PATCH":{s=a.onPatch;break}case"DELETE":{s=a.onDelete;break}case"OPTIONS":{s=a.onOptions;break}case"HEAD":{s=a.onHead;break}}if(typeof s=="function"?n.push(s):Array.isArray(s)&&n.push(...s),i)for(const c of Object.values(a))typeof c=="function"&&(c.__brand==="server_loader"?e.push(c):c.__brand==="server_action"&&r.push(c))}};function wn(e){return async r=>{const n=r;if(n.headersSent){n.exit();return}const{method:t}=n,i=W(n),o=L(n)==="dev";if(o&&t==="GET"&&n.query.has(ie)&&console.warn(`Seems like you are submitting a Qwik Action via GET request. Qwik Actions should be submitted via POST request.
16
- Make sure your <form> has method="POST" attribute, like this: <form method="POST">`),t==="POST"){const a=n.query.get(ie);if(a){const s=globalThis._qwikActionsMap,c=e.find(f=>f.__id===a)??s?.get(a);if(c){n.sharedMap.set(z,a);const f=await n.parseBody();if(!f||typeof f!="object")throw new Error(`Expected request data for the action id ${a} to be an object`);const l=await Ue(n,c.__validators,f,o);if(!l.success)i[a]=n.fail(l.status??500,l.error);else{const u=o?await G(n,c.__qrl.getHash(),()=>c.__qrl.call(n,l.data,n)):await c.__qrl.call(n,l.data,n);o&&E(u,c.__qrl),i[a]=u}}}}}}function pn(e){return async r=>{const n=r;if(n.headersSent){n.exit();return}const t=W(n),i=L(n)==="dev";if(e.length>0){let o=[];if(n.query.has(Y)){const s=n.query.getAll(Y);for(const c of e)s.includes(c.__id)?o.push(c):t[c.__id]=T._UNINITIALIZED}else o=e;const a=o.map(s=>Oe(s,t,n,i));await Promise.all(a)}}}async function Oe(e,r,n,t){const i=e.__id;return r[i]=Ue(n,e.__validators,void 0,t).then(a=>a.success?t?G(n,e.__qrl.getHash(),()=>e.__qrl.call(n,n)):e.__qrl.call(n,n):n.fail(a.status??500,a.error)).then(a=>(typeof a=="function"?r[i]=a():(t&&E(a,e.__qrl),r[i]=a),a)),Le(n).set(i,e.__serializationStrategy),r[i]}async function Ue(e,r,n,t){let i={success:!0,data:n};if(r)for(const o of r)if(t?i=await G(e,"validator$",()=>o.validate(e,n)):i=await o.validate(e,n),i.success)n=i.data;else return i;return i}function Rn(e){return e?typeof e=="object"&&Symbol.asyncIterator in e:!1}async function bn(e){const r=e.query.get(ze);if(r&&e.request.headers.get("X-QRL")===r&&e.request.headers.get("Content-Type")==="application/qwik-json"){e.exit();const n=L(e)==="dev",t=await e.parseBody();if(Array.isArray(t)){const[i,...o]=t;if(An(i)&&i.getHash()===r){let a;try{n?a=await G(e,`server_${i.getSymbol()}`,()=>i.apply(e,o)):a=await i.apply(e,o)}catch(s){throw s instanceof _.ServerError?e.error(s.status,s.data):e.error(500,"Invalid request")}if(Rn(a)){e.headers.set("Content-Type","text/qwik-json-stream");const c=e.getWritableStream().getWriter();for await(const f of a){n&&E(f,i);const l=await T._serialize([f]);if(e.signal.aborted)break;await c.write(j.encode(`${l}
17
- `))}c.close()}else{E(a,i),e.headers.set("Content-Type","application/qwik-json");const s=await T._serialize([a]);e.send(200,s)}return}}throw e.error(500,"Invalid request")}}function _n(e){const{basePathname:r,originalUrl:n,sharedMap:t}=e,{pathname:i,search:o}=n;if(!t.has(q)&&i!==r&&!i.endsWith(".html")){if(globalThis.__NO_TRAILING_SLASH__){if(i.endsWith("/"))throw e.redirect(V.MovedPermanently,i.slice(0,i.length-1)+o)}else if(!i.endsWith("/"))throw e.redirect(V.MovedPermanently,i+"/"+o)}}function E(e,r){try{T._verifySerializable(e,void 0)}catch(n){throw n instanceof Error&&r.dev&&(n.loc=r.dev),n}}const An=e=>typeof e=="function"&&typeof e.getSymbol=="function";function Tn(e){const r=e[e.length-1];return r&&typeof r.default=="function"}function Z(e){e=new URL(e),e.pathname.endsWith(I)&&(e.pathname=e.pathname.slice(0,-I.length)),globalThis.__NO_TRAILING_SLASH__?e.pathname.endsWith("/")&&(e.pathname=e.pathname.slice(0,-1)):e.pathname.endsWith("/")||(e.pathname+="/");const r=e.search.slice(1).replaceAll(/&?q(action|data|func|loaders)=[^&]+/g,"");return`${e.pathname}${r?`?${r}`:""}${e.hash}`}const j=new TextEncoder;function Mn(e){qe(e,"lax-proto")}function Nn(e){qe(e)}function qe(e,r){if(Ln(e.request.headers,"application/x-www-form-urlencoded","multipart/form-data","text/plain")){const t=e.request.headers.get("origin"),i=e.url.origin;let o=t!==i;if(o&&r&&t?.replace(/^http(s)?/g,"")===i.replace(/^http(s)?/g,"")&&(o=!1),o)throw e.error(403,`CSRF check failed. Cross-site ${e.method} form submissions are forbidden.
18
- The request origin "${t}" does not match the server origin "${i}".`)}}function xn(e){return async r=>{if(r.headersSent||r.sharedMap.has(q))return;r.request.headers.forEach((l,u)=>l);const t=r.headers;t.has("Content-Type")||t.set("Content-Type","text/html; charset=utf-8");const{readable:i,writable:o}=new TextEncoderStream,a=r.getWritableStream(),s=i.pipeTo(a,{preventClose:!0}),c=o.getWriter(),f=r.status();try{const l=L(r)==="static",u=gn(r),h=await e({base:r.basePathname+"build/",stream:c,serverData:u,containerAttributes:{"q:render":l?"static":"",...u.containerAttributes}}),y={loaders:W(r),action:r.sharedMap.get(z),status:f!==200?f:200,href:Z(r.url)};typeof h.html=="string"&&await c.write(h.html),r.sharedMap.set(H,y)}finally{await c.ready,await c.close(),await s}await a.close()}}async function Cn(e){if(!e.sharedMap.has(q))return;try{await e.next()}catch(o){if(!(o instanceof _.RedirectMessage))throw o}if(e.headersSent)return;const n=e.status(),t=e.headers.get("Location");if(n>=301&&n<=308&&t){const o=In(t);if(o){e.headers.set("Location",o),e.getWritableStream().close();return}else e.status(200),e.headers.delete("Location")}}async function Pn(e){if(!e.sharedMap.has(q)||(await e.next(),e.headersSent||e.exited))return;const n=e.status(),t=e.headers.get("Location");e.request.headers.forEach((l,u)=>l),e.headers.set("Content-Type","application/json; charset=utf-8");let i=W(e);const o=e.query.getAll(Y),a=o.length>0;if(a){const l={};for(const u of o){const h=i[u];l[u]=h}i=l}const s=a?{loaders:i,status:n!==200?n:200,href:Z(e.url)}:{loaders:i,action:e.sharedMap.get(z),status:n!==200?n:200,href:Z(e.url),redirect:t??void 0,isRewrite:e.sharedMap.get(Ie)},c=e.getWritableStream().getWriter(),f=await T._serialize([s]);c.write(j.encode(f)),e.sharedMap.set(H,s),c.close()}function In(e){if(e.startsWith("/")){const r=I,n=new URL(e,"http://localhost");return(n.pathname.endsWith("/")?n.pathname.slice(0,-1):n.pathname)+(r.startsWith("/")?"":"/")+r+n.search}else return}function ye(){return typeof performance<"u"?performance.now():0}async function G(e,r,n){const t=ye();try{return await n()}finally{const i=ye()-t;let o=e.sharedMap.get(X);o||e.sharedMap.set(X,o=[]),o.push([r,i])}}function Ln(e,...r){const n=e.get("content-type")?.split(/;/,1)[0].trim()??"";return r.includes(n)}let v;async function On(e,r){const{render:n,checkOrigin:t}=r;let{qwikRouterConfig:i}=r;if(i||(v||(v=await import("@qwik-router-config")),i=v),!i)throw new Error("qwikRouterConfig is required.");const o=e.url.pathname,a=he(o),s=await we(i,a,e.request.method,t??!0,n);if(s){const[c,f]=s;return ln(e,c,f,async u=>{const h=he(u.pathname),y=await we(i,h,e.request.method,t??!0,n);if(y){const[w,R]=y;return{loadedRoute:w,requestHandlers:R}}else return{loadedRoute:null,requestHandlers:[]}},i.basePathname)}return null}async function we(e,r,n,t,i){const{routes:o,serverPlugins:a,menus:s,cacheModules:c}=e,f=await Je(o,s,c,r),l=yn(a,f,n,t,xn(i));return l.length>0?[f,l]:null}const Un=["__QWIK_ROUTER_NOT_FOUND_ARRAY__"];function qn(e){for(const[r,n]of Un)if(e.startsWith(r))return n;return _e(404,"Resource Not Found")}const J=new Set(["__QWIK_ROUTER_STATIC_PATHS_ARRAY__"]);function Wn(e,r){if(e.toUpperCase()!=="GET")return!1;const n=r.pathname;if(n.startsWith("/"+(globalThis.__QWIK_BUILD_DIR__||"build")+"/")||n.startsWith("/"+(globalThis.__QWIK_ASSETS_DIR__||"assets")+"/")||J.has(n))return!0;if(n.endsWith("/q-data.json")){const t=n.replace(/\/q-data.json$/,"");if(J.has(t+"/")||J.has(t))return!0}return!1}class kn extends Error{constructor(r,n){super(typeof n=="string"?n:void 0),this.status=r,this.data=n}}class ee{}class Dn extends ee{}class Sn extends ee{constructor(r){super(),this.pathname=r}}class $n{#e=null;#n=new TextEncoder;#r=new TransformStream({transform:(r,n)=>{r=String(r);let t="";for(let i=0;i<r.length;i++){const o=r[i],a=o.charCodeAt(0);if(this.#e!==null){const s=this.#e;if(this.#e=null,56320<=a&&a<=57343){t+=s+o;continue}t+="�"}if(55296<=a&&a<=56319){this.#e=o;continue}if(56320<=a&&a<=57343){t+="�";continue}t+=o}t&&n.enqueue(this.#n.encode(t))},flush:r=>{this.#e!==null&&r.enqueue(new Uint8Array([239,191,189]))}});get encoding(){return this.#n.encoding}get readable(){return this.#r.readable}get writable(){return this.#r.writable}get[Symbol.toStringTag](){return"TextEncoderStream"}}exports.AbortMessage=ee;exports.RedirectMessage=Dn;exports.RequestEvShareQData=H;exports.RewriteMessage=Sn;exports.ServerError=kn;exports._TextEncoderStream_polyfill=$n;exports.getErrorHtml=F;exports.getNotFound=qn;exports.isStaticPath=Wn;exports.mergeHeadersCookies=tn;exports.requestHandler=On;
14
+ <body><p><strong>${e}</strong> <span>${n}</span></p></body>
15
+ `}const an=/[&<>]/g,sn=e=>e.replace(an,n=>{switch(n){case"&":return"&amp;";case"<":return"&lt;";case">":return"&gt;";default:return""}}),cn="#006ce9",ln="#713fc2";let F;import("node:async_hooks").then(e=>{const n=e.AsyncLocalStorage;F=new n,globalThis.qcAsyncRequestStore=F}).catch(e=>{console.warn("AsyncLocalStorage not available, continuing without it. This might impact concurrent server calls.",e)});function dn(e,n,r,t,i="/"){let o;const a=new Promise(s=>o=s),c=un(e,n,r,i,o);return{response:a,requestEv:c,completion:F?F.run(c,me,c,t,o):me(c,t,o)}}async function me(e,n,r){try{(a=>new URL(a.pathname+a.search,a))(e.originalUrl)}catch{const a="Resource Not Found";e.status(404);const c=S(404,a);return e.html(404,c),new b.ServerError(404,a)}let t=1;async function i(){try{await e.next()}catch(o){if(o instanceof b.RedirectMessage)await e.getWritableStream().close();else if(o instanceof b.RewriteMessage){if(t>50)throw new Error("Infinite rewrite loop");t+=1;const a=new URL(e.url);a.pathname=o.pathname;const{loadedRoute:c,requestHandlers:s}=await n(a);return e.resetRoute(c,s,a),await i()}else if(o instanceof b.ServerError){if(!e.headersSent){const a=o.status,c=e.request.headers.get("Accept");if(c&&!c.includes("text/html"))e.headers.set("Content-Type","application/qwik-json"),e.send(a,await M._serialize([o.data]));else{const s=S(o.status,o.data);e.html(a,s)}}}else if(!(o instanceof b.AbortMessage)){if(L(e)!=="dev")try{e.headersSent||(e.headers.set("content-type","text/html; charset=utf-8"),e.cacheControl({noCache:!0}),e.status(500));const a=e.getWritableStream();if(!a.locked){const c=a.getWriter();await c.write(z.encode(S(500,"Internal Server Error"))),await c.close()}}catch{console.error("Unable to render error page")}return o}}}try{return await i()}finally{e.isDirty()||r(null)}}function V(e){const n=e.endsWith(P);if(n){const r=e.length-P.length+(globalThis.__NO_TRAILING_SLASH__?0:1);e=e.slice(0,r),e===""&&(e="/")}return{pathname:e,isInternal:n}}const H="@isQData",P="/q-data.json",_e=Symbol("RequestEvLoaders"),Te=Symbol("RequestEvMode"),Me=Symbol("RequestEvRoute"),Ne=Symbol("RequestEvLoaderSerializationStrategyMap"),xe="@routeName",E="@actionId",Ce="@actionFormData",fn="@nonce",Ie="@rewrite",X="@serverTiming",ee="qData";function un(e,n,r,t,i){const{request:o,platform:a,env:c}=e,s=new Map,l=new tn(o.headers.get("cookie")),f=new Headers,u=new URL(o.url),{pathname:m,isInternal:p}=V(u.pathname);p&&(u.pathname=m,s.set(H,!0));let g=-1,w=null,A,x=e.locale,R=200;const qe=async()=>{for(g++;g<r.length;){const d=r[g],h=d(_);Xe(h)&&await h,g++}},ke=(d,h,y=u)=>{n=d,r=h,u.pathname=y.pathname,u.search=y.search,g=-1},C=()=>{if(w!==null)throw new Error("Response already sent")},k=(d,h)=>{if(C(),typeof d=="number"){R=d;const T=_.getWritableStream().getWriter();T.write(typeof h=="string"?z.encode(h):h),T.close()}else if(R=d.status,d.headers.forEach((y,T)=>{T.toLowerCase()!=="set-cookie"&&f.append(T,y)}),d.headers.getSetCookie().forEach(y=>{const T=y.indexOf("=");if(T===-1)return;const We=y.slice(0,T).trim(),$e=y.slice(T+1).trim();l.set(We,$e)}),d.body){const y=_.getWritableStream();d.body.pipeTo(y)}else _.getWritableStream().getWriter().close();return re()},re=()=>(g=B,new b.AbortMessage),O={},_={[_e]:O,[Ne]:new Map,[Te]:e.mode,get[Me](){return n},cookie:l,headers:f,env:c,method:o.method,signal:o.signal,originalUrl:new URL(u),get params(){return n?.[U.Params]??{}},get pathname(){return u.pathname},platform:a,get query(){return u.searchParams},request:o,url:u,basePathname:t,sharedMap:s,get headersSent(){return w!==null},get exited(){return g>=B},get clientConn(){return e.getClientConn()},next:qe,resetRoute:ke,exit:re,cacheControl:(d,h="Cache-Control")=>{C(),f.set(h,Ze(d))},resolveValue:(async d=>{const h=d.__id;if(d.__brand==="server_loader"){if(!(h in O))throw new Error("You can not get the returned data of a loader that has not been executed for this request.");if(O[h]===M._UNINITIALIZED){const y=L(_)==="dev";await Le(d,O,_,y)}}return O[h]}),status:d=>typeof d=="number"?(C(),R=d,d):R,locale:d=>(typeof d=="string"&&(x=d),x||""),error:(d,h)=>(R=d,f.delete("Cache-Control"),new b.ServerError(d,h)),redirect:(d,h)=>{if(C(),R=d,h){if(/([^:])\/{2,}/.test(h)){const y=h.replace(/([^:])\/{2,}/g,"$1/");console.warn(`Redirect URL ${h} is invalid, fixing to ${y}`),h=y}f.set("Location",h)}return f.delete("Cache-Control"),d>301&&f.set("Cache-Control","no-store"),g=B,new b.RedirectMessage},rewrite:d=>{if(C(),d.startsWith("http"))throw new Error("Rewrite does not support absolute urls");return s.set(Ie,!0),new b.RewriteMessage(d.replace(/\/+/g,"/"))},defer:d=>typeof d=="function"?d:()=>d,fail:(d,h)=>(C(),R=d,f.delete("Cache-Control"),{failed:!0,...h}),text:(d,h)=>(f.set("Content-Type","text/plain; charset=utf-8"),k(d,h)),html:(d,h)=>(f.set("Content-Type","text/html; charset=utf-8"),k(d,h)),parseBody:async()=>A!==void 0?A:A=mn(_,s),json:(d,h)=>(f.set("Content-Type","application/json; charset=utf-8"),k(d,JSON.stringify(h))),send:k,isDirty:()=>w!==null,getWritableStream:()=>{if(w===null){if(e.mode==="dev"){const d=s.get(X);d&&f.set("Server-Timing",d.map(([h,y])=>`${h};dur=${y}`).join(","))}w=e.getWritableStream(R,f,l,i,_)}return w}};return Object.freeze(_)}function q(e){return e[_e]}function Pe(e){return e[Ne]}function hn(e){return e[Me]}function L(e){return e[Te]}const B=Number.MAX_SAFE_INTEGER,mn=async({request:e,method:n,query:r},t)=>{const i=e.headers.get("content-type")?.split(/[;,]/,1)[0].trim()??"";if(i==="application/x-www-form-urlencoded"||i==="multipart/form-data"){const o=await e.formData();return t.set(Ce,o),gn(o)}else{if(i==="application/json")return await e.json();if(i==="application/qwik-json"){if(n==="GET"&&r.has(se)){const o=r.get(se);if(o)try{return M._deserialize(decodeURIComponent(o))}catch{}}return M._deserialize(await e.text())}}},gn=e=>[...e.entries()].reduce((r,[t,i])=>(t.split(".").reduce((o,a,c,s)=>{if(a.endsWith("[]")){const l=a.slice(0,-2);return o[l]=o[l]||[],o[l]=[...o[l],i]}return c<s.length-1?o[a]=o[a]||(Number.isNaN(+s[c+1])?{}:[]):o[a]=i},r),r),{});function yn(e){const{params:n,request:r,status:t,locale:i,originalUrl:o}=e,a={};r.headers.forEach((x,R)=>a[R]=x);const c=e.sharedMap.get(E),s=e.sharedMap.get(Ce),l=e.sharedMap.get(xe),f=e.sharedMap.get(fn),u=e.request.headers,m=new URL(o.pathname+o.search,o),p=u.get("X-Forwarded-Host"),g=u.get("X-Forwarded-Proto");p&&(m.port="",m.host=p),g&&(m.protocol=g);const w=q(e),A=Pe(e);return{url:m.href,requestHeaders:a,locale:i(),nonce:f,containerAttributes:{[Ge]:l},qwikrouter:{routeName:l,ev:e,params:{...n},loadedRoute:hn(e),response:{status:t(),loaders:w,loadersSerializationStrategy:A,action:c,formData:s}}}}const wn=(e,n,r,t,i,o)=>{const a=[],c=[],s=[],l=!!(n&&Mn(n[U.Mods]));if(o&&s.push(In),e&&ge(a,c,s,e,l,r),n){const f=n[U.RouteName];t&&(r==="POST"||r==="PUT"||r==="PATCH"||r==="DELETE")&&(t==="lax-proto"?s.unshift(Nn):s.unshift(xn)),l&&((r==="POST"||r==="GET")&&s.push(An),s.push(_n),o&&s.push(Pn));const u=n[U.Mods];ge(a,c,s,u,l,r),l&&(s.push(m=>{m.sharedMap.set(xe,f)}),s.push(pn(c)),s.push(Rn(a)),s.push(i))}return s},ge=(e,n,r,t,i,o)=>{for(const a of t){typeof a.onRequest=="function"?r.push(a.onRequest):Array.isArray(a.onRequest)&&r.push(...a.onRequest);let c;switch(o){case"GET":{c=a.onGet;break}case"POST":{c=a.onPost;break}case"PUT":{c=a.onPut;break}case"PATCH":{c=a.onPatch;break}case"DELETE":{c=a.onDelete;break}case"OPTIONS":{c=a.onOptions;break}case"HEAD":{c=a.onHead;break}}if(typeof c=="function"?r.push(c):Array.isArray(c)&&r.push(...c),i)for(const s of Object.values(a))typeof s=="function"&&(s.__brand==="server_loader"?e.push(s):s.__brand==="server_action"&&n.push(s))}};function pn(e){return async n=>{const r=n;if(r.headersSent){r.exit();return}const{method:t}=r,i=q(r),o=L(r)==="dev";if(o&&t==="GET"&&r.query.has(ae)&&console.warn(`Seems like you are submitting a Qwik Action via GET request. Qwik Actions should be submitted via POST request.
16
+ Make sure your <form> has method="POST" attribute, like this: <form method="POST">`),t==="POST"){const a=r.query.get(ae);if(a){const c=globalThis._qwikActionsMap,s=e.find(l=>l.__id===a)??c?.get(a);if(s){r.sharedMap.set(E,a);const l=await r.parseBody();if(!l||typeof l!="object")throw new Error(`Expected request data for the action id ${a} to be an object`);const f=await Oe(r,s.__validators,l,o);if(!f.success)i[a]=r.fail(f.status??500,f.error);else{const u=o?await j(r,s.__qrl.getHash(),()=>s.__qrl.call(r,f.data,r)):await s.__qrl.call(r,f.data,r);o&&Q(u,s.__qrl),i[a]=u}}}}}}function Rn(e){return async n=>{const r=n;if(r.headersSent){r.exit();return}const t=q(r),i=L(r)==="dev";if(e.length>0){let o=[];if(r.query.has(J)){const c=r.query.getAll(J);for(const s of e)c.includes(s.__id)?o.push(s):t[s.__id]=M._UNINITIALIZED}else o=e;const a=o.map(c=>Le(c,t,r,i));await Promise.all(a)}}}async function Le(e,n,r,t){const i=e.__id;return n[i]=Oe(r,e.__validators,void 0,t).then(a=>a.success?t?j(r,e.__qrl.getHash(),()=>e.__qrl.call(r,r)):e.__qrl.call(r,r):r.fail(a.status??500,a.error)).then(a=>(typeof a=="function"?n[i]=a():(t&&Q(a,e.__qrl),n[i]=a),a)),Pe(r).set(i,e.__serializationStrategy),n[i]}async function Oe(e,n,r,t){let i={success:!0,data:r};if(n)for(const o of n)if(t?i=await j(e,"validator$",()=>o.validate(e,r)):i=await o.validate(e,r),i.success)r=i.data;else return i;return i}function bn(e){return e?typeof e=="object"&&Symbol.asyncIterator in e:!1}async function An(e){const n=e.query.get(je);if(n&&e.request.headers.get("X-QRL")===n&&e.request.headers.get("Content-Type")==="application/qwik-json"){e.exit();const r=L(e)==="dev",t=await e.parseBody();if(Array.isArray(t)){const[i,...o]=t;if(Tn(i)&&i.getHash()===n){let a;try{r?a=await j(e,`server_${i.getSymbol()}`,()=>i.apply(e,o)):a=await i.apply(e,o)}catch(c){throw c instanceof b.ServerError?e.error(c.status,c.data):e.error(500,"Invalid request")}if(bn(a)){e.headers.set("Content-Type","text/qwik-json-stream");const s=e.getWritableStream().getWriter();for await(const l of a){r&&Q(l,i);const f=await M._serialize([l]);if(e.signal.aborted)break;await s.write(z.encode(`${f}
17
+ `))}s.close()}else{Q(a,i),e.headers.set("Content-Type","application/qwik-json");const c=await M._serialize([a]);e.send(200,c)}return}}throw e.error(500,"Invalid request")}}function _n(e){const{basePathname:n,originalUrl:r,sharedMap:t}=e,{pathname:i,search:o}=r;if(!t.has(H)&&i!==n&&!i.endsWith(".html")){if(globalThis.__NO_TRAILING_SLASH__){if(i.endsWith("/"))throw e.redirect(Y.MovedPermanently,i.slice(0,i.length-1)+o)}else if(!i.endsWith("/"))throw e.redirect(Y.MovedPermanently,i+"/"+o)}}function Q(e,n){try{M._verifySerializable(e,void 0)}catch(r){throw r instanceof Error&&n.dev&&(r.loc=n.dev),r}}const Tn=e=>typeof e=="function"&&typeof e.getSymbol=="function";function Mn(e){const n=e[e.length-1];return n&&typeof n.default=="function"}function Z(e){e=new URL(e),e.pathname.endsWith(P)&&(e.pathname=e.pathname.slice(0,-P.length)),globalThis.__NO_TRAILING_SLASH__?e.pathname.endsWith("/")&&(e.pathname=e.pathname.slice(0,-1)):e.pathname.endsWith("/")||(e.pathname+="/");const n=e.search.slice(1).replaceAll(/&?q(action|data|func|loaders)=[^&]+/g,"");return`${e.pathname}${n?`?${n}`:""}${e.hash}`}const z=new TextEncoder;function Nn(e){Ue(e,"lax-proto")}function xn(e){Ue(e)}function Ue(e,n){if(On(e.request.headers,"application/x-www-form-urlencoded","multipart/form-data","text/plain")){const t=e.request.headers.get("origin"),i=e.url.origin;let o=t!==i;if(o&&n&&t?.replace(/^http(s)?/g,"")===i.replace(/^http(s)?/g,"")&&(o=!1),o)throw e.error(403,`CSRF check failed. Cross-site ${e.method} form submissions are forbidden.
18
+ The request origin "${t}" does not match the server origin "${i}".`)}}function Cn(e){return async n=>{if(n.headersSent||n.sharedMap.has(H))return;n.request.headers.forEach((f,u)=>f);const t=n.headers;t.has("Content-Type")||t.set("Content-Type","text/html; charset=utf-8");const{readable:i,writable:o}=new TextEncoderStream,a=n.getWritableStream(),c=i.pipeTo(a,{preventClose:!0}),s=o.getWriter(),l=n.status();try{const f=L(n)==="static",u=yn(n),m=await e({base:n.basePathname+"build/",stream:s,serverData:u,containerAttributes:{"q:render":f?"static":"",...u.containerAttributes}}),p={loaders:q(n),action:n.sharedMap.get(E),status:l!==200?l:200,href:Z(n.url)};typeof m.html=="string"&&await s.write(m.html),n.sharedMap.set(ee,p)}finally{await s.ready,await s.close(),await c}await a.close()}}async function In(e){try{await e.next()}catch(i){if(!(i instanceof b.RedirectMessage))throw i}if(e.headersSent)return;const n=e.status(),r=e.headers.get("Location");if(n>=301&&n<=308&&r){const i=Ln(r);if(i){e.headers.set("Location",i),e.getWritableStream().close();return}else e.status(200),e.headers.delete("Location")}}async function Pn(e){if(await e.next(),e.headersSent||e.exited)return;const n=e.status(),r=e.headers.get("Location");e.request.headers.forEach((l,f)=>l),e.headers.set("Content-Type","application/json; charset=utf-8");let t=q(e);const i=e.query.getAll(J),o=i.length>0;if(o){const l={};for(const f of i){const u=t[f];l[f]=u}t=l}const a=o?{loaders:t,status:n!==200?n:200,href:Z(e.url)}:{loaders:t,action:e.sharedMap.get(E),status:n!==200?n:200,href:Z(e.url),redirect:r??void 0,isRewrite:e.sharedMap.get(Ie)},c=e.getWritableStream().getWriter(),s=await M._serialize([a]);c.write(z.encode(s)),e.sharedMap.set(ee,a),c.close()}function Ln(e){if(e.startsWith("/")){if(!e.includes(P)){const n=new URL(e,"http://localhost");return(n.pathname.endsWith("/")?n.pathname.slice(0,-1):n.pathname)+P+n.search}return e}else return}function ye(){return typeof performance<"u"?performance.now():0}async function j(e,n,r){const t=ye();try{return await r()}finally{const i=ye()-t;let o=e.sharedMap.get(X);o||e.sharedMap.set(X,o=[]),o.push([n,i])}}function On(e,...n){const r=e.get("content-type")?.split(/;/,1)[0].trim()??"";return n.includes(r)}let v;async function Un(e,n){const{render:r,checkOrigin:t}=n;let{qwikRouterConfig:i}=n;if(i||(v||(v=await import("@qwik-router-config")),i=v),!i)throw new Error("qwikRouterConfig is required.");const{pathname:o,isInternal:a}=V(e.url.pathname),c=await we(i,o,e.request.method,t??!0,r,a);if(c){const[s,l]=c;return dn(e,s,l,async u=>{const{pathname:m}=V(u.pathname),p=await we(i,m,e.request.method,t??!0,r,a);if(p){const[g,w]=p;return{loadedRoute:g,requestHandlers:w}}else return{loadedRoute:null,requestHandlers:[]}},i.basePathname)}return null}async function we(e,n,r,t,i,o){const{routes:a,serverPlugins:c,menus:s,cacheModules:l}=e,f=await Ye(a,s,l,n,o),u=wn(c,f,r,t,Cn(i),o);return u.length>0?[f,u]:null}const qn=["__QWIK_ROUTER_NOT_FOUND_ARRAY__"];function kn(e){for(const[n,r]of qn)if(e.startsWith(n))return r;return Ae(404,"Resource Not Found")}const K=new Set(["__QWIK_ROUTER_STATIC_PATHS_ARRAY__"]);function Wn(e,n){if(e.toUpperCase()!=="GET")return!1;const r=n.pathname;if(r.startsWith("/"+(globalThis.__QWIK_BUILD_DIR__||"build")+"/")||r.startsWith("/"+(globalThis.__QWIK_ASSETS_DIR__||"assets")+"/")||K.has(r))return!0;if(r.endsWith("/q-data.json")){const t=r.replace(/\/q-data.json$/,"");if(K.has(t+"/")||K.has(t))return!0}return!1}class $n extends Error{constructor(n,r){super(typeof r=="string"?r:void 0),this.status=n,this.data=r}}class ne{}class Dn extends ne{}class Sn extends ne{constructor(n){super(),this.pathname=n}}class Fn{#e=null;#n=new TextEncoder;#r=new TransformStream({transform:(n,r)=>{n=String(n);let t="";for(let i=0;i<n.length;i++){const o=n[i],a=o.charCodeAt(0);if(this.#e!==null){const c=this.#e;if(this.#e=null,56320<=a&&a<=57343){t+=c+o;continue}t+="�"}if(55296<=a&&a<=56319){this.#e=o;continue}if(56320<=a&&a<=57343){t+="�";continue}t+=o}t&&r.enqueue(this.#n.encode(t))},flush:n=>{this.#e!==null&&n.enqueue(new Uint8Array([239,191,189]))}});get encoding(){return this.#n.encoding}get readable(){return this.#r.readable}get writable(){return this.#r.writable}get[Symbol.toStringTag](){return"TextEncoderStream"}}exports.AbortMessage=ne;exports.RedirectMessage=Dn;exports.RequestEvShareQData=ee;exports.RewriteMessage=Sn;exports.ServerError=$n;exports._TextEncoderStream_polyfill=Fn;exports.getErrorHtml=S;exports.getNotFound=kn;exports.isStaticPath=Wn;exports.mergeHeadersCookies=on;exports.requestHandler=Un;