@qwik.dev/core
Version:
An open source framework for building instant loading web apps at any scale, without the extra effort.
1,172 lines (1,031 loc) • 140 kB
JavaScript
/**
* @license
* @qwik.dev/core/server 2.0.0-beta.36-dev+3268fab
* Copyright QwikDev. All Rights Reserved.
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/QwikDev/qwik/blob/main/LICENSE
*/
// packages/qwik/src/server/index.ts
import { setPlatform as setPlatform2 } from "@qwik.dev/core";
// packages/qwik/src/server/platform.ts
import { setPlatform as Bs } from "@qwik.dev/core";
import { isDev as isDev6 } from "@qwik.dev/core/build";
// packages/qwik/src/core/client/util-mapArray.ts
import { isDev as isDev2 } from "@qwik.dev/core/build";
// packages/qwik/src/core/shared/error/assert.ts
import { isDev as me } from "@qwik.dev/core/build";
// packages/qwik/src/core/shared/utils/qdev.ts
var qDev = globalThis.qDev !== false;
var qInspector = globalThis.qInspector === true;
var qDynamicPlatform = globalThis.qDynamicPlatform !== false;
var qTest = globalThis.qTest === true;
var qRuntimeQrl = globalThis.qRuntimeQrl === true;
// packages/qwik/src/core/shared/utils/log.ts
var STYLE = qDev ? `background: #564CE0; color: white; padding: 2px 3px; border-radius: 2px; font-size: 0.8em;` : "";
var throwErrorAndStop = (e, ...t) => {
const n = be(false, e, ...t);
debugger;
throw n;
};
var logErrorAndStop = (e, ...t) => {
const n = be(qDev, e, ...t);
debugger;
return n;
};
var be = (e, t, ...n) => {
const r = t instanceof Error ? t : new Error(t);
!qTest && console.error("%cQWIK ERROR", STYLE, r.message, ...n, r.stack);
e && !qTest && setTimeout(() => {
throw r;
}, 0);
return r;
};
// packages/qwik/src/core/shared/error/assert.ts
var ASSERT_DISCLAIMER = "Internal assert, this is likely caused by a bug in Qwik: ";
function assertTrue(e, t, ...n) {
if (me) {
if (e === true) {
return;
}
throwErrorAndStop(ASSERT_DISCLAIMER + t, ...n);
}
}
// packages/qwik/src/core/client/util-mapArray.ts
var ve = (e, t, n) => {
isDev2 && assertTrue(n % 2 === 0, "Expecting even number.");
let r = n >> 1;
let s = e.length - 2 >> 1;
while (r <= s) {
const n = r + (s - r >> 1);
const i = e[n << 1];
if (i === t) {
return n << 1;
}
if (i < t) {
r = n + 1;
} else {
s = n - 1;
}
}
return r << 1 ^ -1;
};
var _e = (e, t, n, r, s = false) => {
const i = ve(e, t, r);
if (i >= 0) {
if (n == null && !s) {
e.splice(i, 2);
} else {
e[i + 1] = n;
}
} else if (n != null || s) {
e.splice(i ^ -1, 0, t, n);
}
};
var mapApp_remove = (e, t, n) => {
const r = ve(e, t, n);
let s = null;
if (r >= 0) {
s = e[r + 1];
e.splice(r, 2);
return s;
}
return s;
};
var ge = (e, t, n) => {
const r = ve(e, t, n);
if (r >= 0) {
return e[r + 1];
} else {
return null;
}
};
var Ee = (e, t, n) => ve(e, t, n) >= 0;
// packages/qwik/src/core/shared/error/error.ts
import { isDev as isDev3 } from "@qwik.dev/core/build";
// packages/qwik/src/core/shared/utils/types.ts
var ke = e => typeof e === "object" && e !== null;
var Re = e => Array.isArray(e);
var Pe = e => typeof e === "string";
// packages/qwik/src/core/shared/error/error.ts
var baseUrl = "https://qwikdev-build-v2.qwik-8nx.pages.dev/docs/errors/#q";
var codeToText = (e, ...t) => {
if (isDev3) {
const n = [ "Error while serializing class or style attributes",
// 0
"Scheduler not found",
// 1
"track() received object, without prop to track",
// 2
"Only primitive and object literals can be serialized. {{0}}",
// 3
"You can render over a existing q:container. Skipping render().",
// 4
"QRL is not a function",
// 5
"Dynamic import {{0}} not found",
// 6
"Unknown type argument",
// 7
`Actual value for useContext({{0}}) can not be found, make sure some ancestor component has set a value using useContextProvider(). In the browser make sure that the context was used during SSR so its state was serialized.`,
// 8
"Invoking 'use*()' method outside of invocation context.",
// 9
`Calling a 'use*()' method outside 'component$(() => { HERE })' is not allowed. 'use*()' methods provide hooks to the 'component$' state and lifecycle, ie 'use' hooks can only be called synchronously within the 'component$' function or another 'use' method.\nSee https://qwik.dev/docs/core/tasks/#use-method-rules`,
// 10
'The provided Context reference "{{0}}" is not a valid context created by createContextId()',
// 11
"SsrError(tag): {{0}}",
// 12
"QRLs can not be resolved because it does not have an attached container. This means that the QRL does not know where it belongs inside the DOM, so it cant dynamically import() from a relative path.",
// 13
"QRLs can not be dynamically resolved, because it does not have a chunk path",
// 14
"{{0}}\nThe JSX ref attribute must be a Signal",
// 15
"Serialization Error: Deserialization of data type {{0}} is not implemented",
// 16
"Serialization Error: Expected vnode for ref prop, but got {{0}}",
// 17
"Serialization Error: Cannot allocate data type {{0}}",
// 18
"Serialization Error: Missing root id for {{0}}",
// 19
"Serialization Error: Serialization of data type {{0}} is not implemented",
// 20
"Serialization Error: Unvisited {{0}}",
// 21
"Serialization Error: Missing QRL chunk for {{0}}",
// 22
"{{0}}\nThe value of the textarea must be a string found {{1}}",
// 23
"Unable to find q:container",
// 24
"Element must have 'q:container' attribute.",
// 25
"Unknown vnode type {{0}}.",
// 26
"Materialize error: missing element: {{0}} {{1}} {{2}}",
// 27
"Cannot coerce a Signal, use `.value` instead",
// 28
"useComputed$ QRL {{0}} {{1}} cannot return a Promise",
// 29
`===\nQwik version {{0}} already imported while importing {{1}}.\nThis can lead to issues due to duplicated shared structures.\nVerify that the Qwik libraries you're using are in "resolve.noExternal[]" and in "optimizeDeps.exclude".\n===\n`,
// 30
"WrappedSignal is read-only",
// 31
"Attribute value is unsafe for SSR {{0}}",
// 32
"SerializerSymbol function returned rejected promise",
// 33
"Serialization Error: Cannot serialize function: {{0}}",
// 34
"Cannot read .value of a clientOnly async signal during SSR. Use .loading to check state, or provide an initial value." ];
let r = n[e] ?? "";
if (t.length) {
r = r.replaceAll(/{{(\d+)}}/g, (e, n) => {
let r = t[n];
if (r && ke(r) && r.constructor === Object) {
r = JSON.stringify(r).slice(0, 50);
}
return r;
});
}
return `Code(Q${e}): ${r}`;
} else {
return `Code(Q${e}) ${baseUrl}${e}`;
}
};
var qe = (e, t = []) => {
const n = codeToText(e, ...t);
return logErrorAndStop(n, ...t);
};
// packages/qwik/src/core/shared/qrl/qrl-utils.ts
import { isDev as isDev4 } from "@qwik.dev/core/build";
var Me = "<sync>";
// packages/qwik/src/core/shared/types.ts
var xe = "q:type";
// packages/qwik/src/core/shared/vnode-data-types.ts
var VNodeDataSeparator = {
REFERENCE_CH:
/* ***** */ `~`,
// `~` is a reference to the node. Save it.
REFERENCE:
/* ******** */ 126,
// `~` is a reference to the node. Save it.
ADVANCE_1_CH:
/* ***** */ `!`,
// `!` is vNodeData separator skipping 0. (ie next vNode)
ADVANCE_1:
/* ********* */ 33,
// `!` is vNodeData separator skipping 0. (ie next vNode)
ADVANCE_2_CH:
/* ***** */ `"`,
// `"` is vNodeData separator skipping 1.
ADVANCE_2:
/* ********* */ 34,
// `"` is vNodeData separator skipping 1.
ADVANCE_4_CH:
/* ***** */ `#`,
// `#` is vNodeData separator skipping 2.
ADVANCE_4:
/* ********* */ 35,
// `#` is vNodeData separator skipping 2.
ADVANCE_8_CH:
/* ***** */ `$`,
// `$` is vNodeData separator skipping 4.
ADVANCE_8:
/* ********* */ 36,
// `$` is vNodeData separator skipping 4.
ADVANCE_16_CH:
/* **** */ `%`,
// `%` is vNodeData separator skipping 8.
ADVANCE_16:
/* ******** */ 37,
// `%` is vNodeData separator skipping 8.
ADVANCE_32_CH:
/* **** */ `&`,
// `&` is vNodeData separator skipping 16.
ADVANCE_32:
/* ******** */ 38,
// `&` is vNodeData separator skipping 16.
ADVANCE_64_CH:
/* **** */ `'`,
// `'` is vNodeData separator skipping 32.
ADVANCE_64:
/* ******** */ 39,
// `'` is vNodeData separator skipping 32.
ADVANCE_128_CH:
/* *** */ `(`,
// `(` is vNodeData separator skipping 64.
ADVANCE_128:
/* ******* */ 40,
// `(` is vNodeData separator skipping 64.
ADVANCE_256_CH:
/* *** */ `)`,
// `)` is vNodeData separator skipping 128.
ADVANCE_256:
/* ******* */ 41,
// `)` is vNodeData separator skipping 128.
ADVANCE_512_CH:
/* *** */ `*`,
// `*` is vNodeData separator skipping 256.
ADVANCE_512:
/* ******* */ 42,
// `*` is vNodeData separator skipping 256.
ADVANCE_1024_CH:
/* ** */ `+`,
// `+` is vNodeData separator skipping 512.
ADVANCE_1024:
/* ****** */ 43,
// `+` is vNodeData separator skipping 512.
ADVANCE_2048_CH:
/* * */ ",",
// ',' is vNodeData separator skipping 1024.
ADVANCE_2048:
/* ****** */ 44,
// ',' is vNodeData separator skipping 1024.
ADVANCE_4096_CH:
/* * */ `-`,
// `-` is vNodeData separator skipping 2048.
ADVANCE_4096:
/* ****** */ 45,
// `-` is vNodeData separator skipping 2048.
ADVANCE_8192_CH:
/* * */ `.`,
// `.` is vNodeData separator skipping 4096.
ADVANCE_8192:
/* ****** */ 46
};
var VNodeDataChar = {
OPEN:
/* ************** */ 123,
// `{` is the start of the VNodeData for a virtual element.
OPEN_CHAR:
/* ****** */ "{",
CLOSE:
/* ************* */ 125,
// `}` is the end of the VNodeData for a virtual element.
CLOSE_CHAR:
/* ***** */ "}",
SCOPED_STYLE:
/* ******* */ 59,
// `;` - `q:sstyle` - Style attribute.
SCOPED_STYLE_CHAR:
";",
RENDER_FN:
/* ********** */ 60,
// `<` - `q:renderFn' - Component QRL render function (body)
RENDER_FN_CHAR:
/* ** */ "<",
ID:
/* ***************** */ 61,
// `=` - `q:id` - ID of the element.
ID_CHAR:
/* ********* */ "=",
PROPS:
/* ************** */ 62,
// `>` - `q:props' - Component Props
PROPS_CHAR:
/* ****** */ ">",
SLOT_PARENT:
/* ******** */ 63,
// `?` - `q:sparent` - Slot parent.
SLOT_PARENT_CHAR:
"?",
KEY:
/* **************** */ 64,
// `@` - `q:key` - Element key.
KEY_CHAR:
/* ******** */ "@",
SEQ:
/* **************** */ 91,
// `[` - `q:seq' - Seq value from `useSequentialScope()`
SEQ_CHAR:
/* ******** */ "[",
DON_T_USE:
/* ********** */ 92,
// `\` - SKIP because `\` is used as escaping
DON_T_USE_CHAR: "\\",
CONTEXT:
/* ************ */ 93,
// `]` - `q:ctx' - Component context/props
CONTEXT_CHAR:
/* **** */ "]",
SEQ_IDX:
/* ************ */ 94,
// `^` - `q:seqIdx' - Sequential scope id
SEQ_IDX_CHAR:
/* **** */ "^",
BACK_REFS:
/* ********** */ 96,
// '`' - `q:brefs' - Effect dependencies/subscriptions
BACK_REFS_CHAR:
/* ** */ "`",
SEPARATOR:
/* ********* */ 124,
// `|` - Separator char to encode any key/value pairs.
SEPARATOR_CHAR:
/* ** */ "|",
SLOT:
/* ************** */ 126,
// `~` - `q:slot' - Slot name
SLOT_CHAR:
/* ******* */ "~"
};
var je = (e, t) => {
const n = parseInt(e, 10) - 1;
const r = n + t;
return -(r * (r + 1) / 2 + t + 1);
};
// packages/qwik/src/core/shared/utils/character-escaping.ts
function escapeHTML(e) {
let t = "";
const n = e.length;
let r = 0;
let s = r;
for (;r < n; r++) {
const n = e.charCodeAt(r);
if (n === 60) {
t += e.substring(s, r) + "<";
} else if (n === 62) {
t += e.substring(s, r) + ">";
} else if (n === 38) {
t += e.substring(s, r) + "&";
} else if (n === 34) {
t += e.substring(s, r) + """;
} else if (n === 39) {
t += e.substring(s, r) + "'";
} else {
continue;
}
s = r + 1;
}
if (s === 0) {
return e;
} else {
return t + e.substring(s);
}
}
function encodeVNodeDataString(e) {
let t = "";
const n = e.length;
let r = 0;
let s = r;
for (;r < n; r++) {
const n = e.charCodeAt(r);
if (n >= VNodeDataSeparator.ADVANCE_1 && n <= VNodeDataSeparator.ADVANCE_8192) {
t += e.substring(s, r) + "\\" + e.charAt(r);
} else {
continue;
}
s = r + 1;
}
if (s === 0) {
return e;
} else {
return t + e.substring(s);
}
}
function encodeVNodeDataKey(e) {
const t = encodeURI(e);
let n = "";
const r = t.length;
let s = 0;
let i = s;
for (;s < r; s++) {
const e = t.charCodeAt(s);
let r = null;
if (e === 59) {
r = "%3B";
} else if (e === 61) {
r = "%3D";
} else if (e === 63) {
r = "%3F";
} else if (e === 64) {
r = "%40";
} else if (e === 126) {
r = "%7E";
} else {
continue;
}
n += t.substring(i, s) + r;
i = s + 1;
}
if (i === 0) {
return t;
} else {
return n + t.substring(i);
}
}
// packages/qwik/src/core/shared/utils/markers.ts
var Le = "q:renderFn";
var De = "q:slot";
var QSlotParent = "q:sparent";
var QStatePatchAttr = "q:patch";
var kh = "q:r";
var Ue = "q:style";
var ze = "style[q\\:style]";
var QStyleSSelector = "style[q\\:sstyle]";
var Be = ze + "," + QStyleSSelector;
var He = "q:sstyle";
var Je = "q:ctx";
var Qe = "q:brefs";
var QRenderAttr = "q:render";
var QRuntimeAttr = "q:runtime";
var QVersionAttr = "q:version";
var Ge = "q:base";
var QLocaleAttr = "q:locale";
var QManifestHashAttr = "q:manifest-hash";
var QInstanceAttr = "q:instance";
var Ke = "q:container-island";
var Ze = "/" + Ke;
var ts = "q:ignore";
var ns = "/" + ts;
var es = "q:container";
var ss = "/" + es;
var is = "q:template";
var os = "[q\\:container]:not([q\\:container=" + "html" /* HTML */ + "]):not([q\\:container=" + "text" /* TEXT */ + "])";
var QDefaultSlot = "";
var as = "q:id";
var hs = "q:key";
var ds = "q:props";
var ps = "q:seq";
var $s = "q:seqIdx";
var ELEMENT_BACKPATCH_DATA = "qwik/backpatch";
var ys = "q:p";
var ms = "q:ps";
var ws = ":";
var bs = ws + "on";
var vs = ws + "onIdx";
var _s = ws + "onFlags";
var gs = ws + "nearestCursorBoundary";
var Es = ":";
var Ss = "dangerouslySetInnerHTML";
// packages/qwik/src/core/shared/utils/promises.ts
import { isDev as isDev5, isServer as $e } from "@qwik.dev/core/build";
var Rs = 100;
var Ps = e => !!e && typeof e == "object" && typeof e.then === "function";
var qs = (e, t) => Ps(e) ? e.then(t) : t(e);
var checkError = e => {
if ($e && e instanceof ReferenceError && e.message.includes("window")) {
e.message = 'It seems like you forgot to add "if (isBrowser) {...}" here:' + e.message;
}
};
var Ms = e => {
throw e;
};
function n(e, t = Ms) {
let n = false;
let r;
try {
r = e();
n = true;
} catch (e) {
r = e;
}
if (!Ps(r)) {
if (n) {
return r;
}
isDev5 && checkError(r);
return t(r);
}
let s = Rs;
const i = async n => {
while (Ps(n)) {
try {
await n;
return await e();
} catch (e) {
if (Ps(e)) {
if (! --s) {
n = new Error("Exceeded max retry count in retryOnPromise");
break;
} else {
n = e;
}
} else {
n = e;
break;
}
}
}
isDev5 && checkError(n);
return t(n);
};
return n ? r.catch(i) : i(r);
}
// packages/qwik/src/core/shared/utils/scoped-styles.ts
function isClassAttr(e) {
return e === "class";
}
function convertStyleIdsToString(e) {
return Array.from(e).join(" ");
}
// packages/qwik/src/core/shared/utils/event-names.ts
var Is = e => e.charCodeAt(0) === 113 && e.charCodeAt(1) === 45 && (e.charCodeAt(3) === 58 || e.charCodeAt(3) === 112 && e.charCodeAt(4) === 58);
function isPreventDefault(e) {
return e.startsWith("preventdefault:");
}
// packages/qwik/src/core/shared/utils/unitless_number.ts
var js = /* @__PURE__ */ new Set([ "animationIterationCount", "aspectRatio", "borderImageOutset", "borderImageSlice", "borderImageWidth", "boxFlex", "boxFlexGroup", "boxOrdinalGroup", "columnCount", "columns", "flex", "flexGrow", "flexShrink", "gridArea", "gridRow", "gridRowEnd", "gridRowStart", "gridColumn", "gridColumnEnd", "gridColumnStart", "fontWeight", "lineClamp", "lineHeight", "opacity", "order", "orphans", "scale", "tabSize", "widows", "zIndex", "zoom", "MozAnimationIterationCount",
// Known Prefixed Properties
"MozBoxFlex",
// TODO: Remove these since they shouldn't be used in modern code
"msFlex", "msFlexPositive", "WebkitAnimationIterationCount", "WebkitBoxFlex", "WebkitBoxOrdinalGroup", "WebkitColumnCount", "WebkitColumns", "WebkitFlex", "WebkitFlexGrow", "WebkitFlexShrink", "WebkitLineClamp" ]);
var isUnitlessNumber = e => js.has(e);
// packages/qwik/src/core/shared/utils/styles.ts
var Fs = e => {
if (!e) {
return "";
}
if (Pe(e)) {
return e.trim();
}
const t = [];
if (Re(e)) {
for (let n = 0; n < e.length; n++) {
const r = e[n];
const s = Fs(r);
if (s) {
t.push(s);
}
}
} else {
for (const [n, r] of Object.entries(e)) {
if (r) {
t.push(n.trim());
}
}
}
return t.join(" ");
};
var Xs = e => e.replace(/([A-Z])/g, "-$1").toLowerCase();
var stringifyStyle = e => {
if (e == null) {
return "";
}
if (typeof e == "object") {
if (Re(e)) {
throw qe(0 /* stringifyClassOrStyle */ , [ e, "style" ]);
} else {
const t = [];
for (const n in e) {
if (Object.prototype.hasOwnProperty.call(e, n)) {
const r = e[n];
if (r != null && typeof r !== "function") {
if (n.startsWith("--")) {
t.push(n + ":" + r);
} else {
t.push(Xs(n) + ":" + Ds(n, r));
}
}
}
}
return t.join(";");
}
}
return String(e);
};
var serializeBooleanOrNumberAttribute = e => e != null ? String(e) : null;
function s(e, t, n) {
if (isClassAttr(e)) {
const e = Fs(t);
t = n ? n + (e.length ? " " + e : e) : e;
} else if (e === "style") {
t = stringifyStyle(t);
} else if (isEnumeratedBooleanAttribute(e) || typeof t === "number") {
t = serializeBooleanOrNumberAttribute(t);
} else if (t === false || t == null) {
t = null;
} else if (t === true && isPreventDefault(e)) {
t = "";
}
return t;
}
function isEnumeratedBooleanAttribute(e) {
return isAriaAttribute(e) || [ "spellcheck", "draggable", "contenteditable" ].includes(e);
}
var Ds = (e, t) => {
if (typeof t === "number" && t !== 0 && !isUnitlessNumber(e)) {
return t + "px";
}
return t;
};
function isAriaAttribute(e) {
return e.startsWith("aria-");
}
// packages/qwik/src/core/preloader/bundle-graph.ts
var base;
var graph;
var parseBundleGraph = e => {
const t = /* @__PURE__ */ new Map;
let n = 0;
while (n < e.length) {
const r = e[n++];
const s = [];
let i;
let o = 1;
while (i = e[n], typeof i === "number") {
if (i < 0) {
o = -i / 10;
} else {
s.push({
Wt: e[i],
Yt: o,
Gt: 1
});
}
n++;
}
t.set(r, s);
}
return t;
};
var initPreloader = e => {
if (base != null || !e) {
return;
}
base = "";
graph = parseBundleGraph(e);
};
// packages/qwik/src/core/shared/utils/objects.ts
var hr = e => {
for (const t in e) {
if (Object.prototype.hasOwnProperty.call(e, t)) {
return false;
}
}
return true;
};
// packages/qwik/src/core/ssr/stream-writer.ts
var stringifyRootRefPath = e => {
let t = String(e[0]);
for (let n = 1; n < e.length; n++) {
t += " " + e[n];
}
return t;
};
var writeStringRootRef = (e, t) => e.write(String(t));
var writeStringRootRefPath = (e, t) => e.write(stringifyRootRefPath(t));
var dr = e => ({
write: e,
writeRootRef(e) {
return writeStringRootRef(this, e);
},
writeRootRefPath(e) {
return writeStringRootRefPath(this, e);
}
});
// packages/qwik/src/core/shared/ssr-const.ts
var LT = "<";
var GT = ">";
var CLOSE_TAG = "</";
var va = " ";
var ATTR_EQUALS_QUOTE = '="';
var pr = '"';
var EMPTY_ATTR = '=""';
var $r = "[";
var yr = "]";
var PAREN_CLOSE = ")";
var mr = ",";
// packages/qwik/src/server/platform.ts
var getDevSegmentPath = (e, t, n, r) => {
const s = e?.[t];
if (s) {
return s;
}
if (n === Me) {
return [ n, "" ];
}
if (!r) {
if (n.startsWith("_") && n.length < 6) {
return [ n, `${import.meta.env?.BASE_URL}@qwik-handlers` ];
}
console.error("qwik symbolMapper: unknown qrl requested without parent:", n);
return [ n, `${import.meta.env?.BASE_URL}${n}.js` ];
}
const i = `${import.meta.env?.BASE_URL}${r.startsWith("/") ? r.slice(1) : r}_${n}.js`;
return [ n, i ];
};
function Vs(e, t) {
const n = t?.mapper;
const r = e.symbolMapper ? e.symbolMapper : (e, t, r) => {
if (n || isDev6 && import.meta.env?.MODE !== "test") {
const t = Sh(e);
const s = !isDev6 ? n[t] : getDevSegmentPath(n, t, e, r);
if (!s) {
if (t === Me) {
return [ t, "" ];
}
const s = globalThis.__qwik_reg_symbols?.has(t);
if (s) {
return [ e, "_" ];
}
console.error("Cannot resolve symbol", e, "in", n, r);
}
return s;
}
};
const s = {
isServer: true,
async importSymbol(e, t, n) {
const r = Sh(n);
const s = globalThis.__qwik_reg_symbols?.get(r);
if (s) {
return s;
}
throw qe(6 /* dynamicImportFailed */ , [ n ]);
},
raf: () => {
console.error("server can not rerender");
return Promise.resolve();
},
chunkForSymbol(e, t, s) {
return r(e, n, s);
}
};
return s;
}
async function setServerPlatform(e, t) {
const n = Vs(e, t);
Bs(n);
}
var Sh = e => {
const t = e.lastIndexOf("_");
if (t > -1) {
return e.slice(t + 1);
}
return e;
};
// packages/qwik/src/server/ssr-render.ts
import { getClientManifest as Hf } from "@qwik.dev/core";
// packages/qwik/src/server/ssr-container.ts
import { isDev as isDev8 } from "@qwik.dev/core/build";
import { _SubscriptionData as Ri, _SharedContainer as ic, _jsxSorted as Fi, _jsxSplit as Xi, _res as _, _setEvent, _walkJSX as Xn, _createQRL as Mf, isSignal as iu } from "@qwik.dev/core/internal";
// packages/qwik/src/server/ooos-utils.ts
import { _SubscriptionPatch as Pu } from "@qwik.dev/core/internal";
var recordExternalRootEffect = (e, t, n, r, s, i, o, a) => {
if (!r || o !== null && !a) {
return;
}
let c = s;
if (o !== null && s && (typeof s === "object" || typeof s === "function")) {
c = n.get(s) || s;
}
const l = e.ge(c);
t.St(c);
t.St(i);
if (o !== null && typeof o !== "string") {
t.St(o);
}
r.push({
rootObj: c,
rootId: l,
effect: i,
prop: o
});
};
var collectSubscriptionPatches = (e, t, n) => {
if (!t?.length) {
return;
}
const r = [];
const s = /* @__PURE__ */ new Map;
for (let i = 0; i < t.length; i++) {
const o = t[i];
const a = o.rootId === void 0 ? e.ge(o.rootObj) : o.rootId;
if (a === void 0 || a >= n) {
continue;
}
let c = s.get(a);
if (!c) {
c = new Pu(a, o.prop === null ? /* @__PURE__ */ new Set : /* @__PURE__ */ new Map);
s.set(a, c);
r.push(c);
}
const l = c.subscriptions;
if (o.prop === null) {
if (l instanceof Set) {
l.add(o.effect);
}
} else {
if (l instanceof Map) {
let e = l.get(o.prop);
if (!e) {
e = /* @__PURE__ */ new Set;
l.set(o.prop, e);
}
e.add(o.effect);
}
}
}
return r.length ? r : void 0;
};
// packages/qwik/src/server/preload-impl.ts
import { getPlatform as Hs } from "@qwik.dev/core";
var simplifyPath = (e, t) => {
if (t == null) {
return null;
}
const n = `${e}${t}`.split("/");
const r = [];
for (let e = 0; e < n.length; e++) {
const t = n[e];
if (t === ".." && r.length > 0) {
r.pop();
} else {
r.push(t);
}
}
return r.join("/");
};
var getBase = e => {
let t = e.qe;
if (import.meta.env?.DEV && !qTest) {
t = import.meta.env?.BASE_URL;
}
return t;
};
var preloaderPre = (e, t, n) => {
const {resolvedManifest: r} = e;
const s = getBase(e);
const i = simplifyPath(s, r?.manifest?.preloader);
let o = r?.manifest.bundleGraphAsset;
if (o) {
o = (import.meta.env?.BASE_URL || "/") + o;
}
if (!(import.meta.env?.DEV && !qTest) && i && o && t !== false) {
const r = e.resolvedManifest?.manifest.bundleGraph;
initPreloader(r);
const a = [];
if (t) {
if (t.maxIdlePreloads) {
a.push(`P:${t.maxIdlePreloads}`);
}
}
const c = a.length ? `,{${a.join(",")}}` : "";
const l = {
rel: "modulepreload",
href: i
};
if (n) {
l["nonce"] = n;
}
e.openElement("link", null, l, null, null, null);
e.closeElement();
e.openElement("link", null, {
rel: "preload",
href: o,
as: "fetch",
crossorigin: "anonymous"
}, null, null, null);
e.closeElement();
const u = `let b=fetch("${o}");import("${i}").then(({l})=>l(${JSON.stringify(s)},b${c}));`;
const h = {
type: "module",
async: true,
crossorigin: "anonymous"
};
if (n) {
h["nonce"] = n;
}
e.writeScript(h, u);
}
const a = simplifyPath(s, r?.manifest.core);
if (a) {
const t = {
rel: "modulepreload",
href: a
};
if (n) {
t["nonce"] = n;
}
e.openElement("link", null, t, null, null, null);
e.closeElement();
}
};
var includePreloader = (e, t, n, r) => {
if (n.length === 0 || t === false) {
return null;
}
const {ssrPreloads: s} = normalizePreLoaderOptions(typeof t === "boolean" ? void 0 : t);
let i = s;
const o = getBase(e);
const a = [];
const {resolvedManifest: c} = e;
if (i) {
const e = c?.manifest.preloader;
const t = c?.manifest.core;
for (let r = 0; r < n.length; r++) {
const s = n[r];
if (s === e || s === t) {
continue;
}
a.push(s);
if (--i === 0) {
break;
}
}
}
const l = simplifyPath(o, c?.manifest.preloader);
const u = a.length ?
/**
* We only use modulepreload links because they behave best. Older browsers can rely on the
* preloader which does feature detection and which will be available soon after inserting these
* links.
*/ `${JSON.stringify(a)}.map((l,e)=>{e=document.createElement('link');e.rel='modulepreload';e.href=${JSON.stringify(o)}+l;document.head.appendChild(e)});` : "";
let h = u;
if (l) {
h += `window.addEventListener('load',f=>{f=_=>import("${l}").then(({p})=>p(${JSON.stringify(n)}));try{requestIdleCallback(f,{timeout:2000})}catch(e){setTimeout(f,200)}})`;
}
if (h) {
const t = {
type: "module",
async: "true",
"q:type": "preload"
};
if (r) {
t["nonce"] = r;
}
e.writeScript(t, h);
}
return null;
};
var preloaderPost = (e, t, n) => {
if (import.meta.env?.DEV && !qTest) {
return;
}
if (t.preloader !== false) {
const r = Array.from(e.serializationCtx.xt);
const s = getBundles(r);
includePreloader(e, t.preloader, s, n);
}
};
function normalizePreLoaderOptions(e) {
return {
...preLoaderOptionsDefault,
...e
};
}
var getBundles = e => {
const t = Hs();
const n = e?.map(e => {
const n = e.vt;
const r = e._t;
const s = t.chunkForSymbol(n, r, e.dev?.file);
if (s) {
return s[1];
}
return r;
}).filter(Boolean);
return [ ...new Set(n) ];
};
var preLoaderOptionsDefault = {
ssrPreloads: 7,
maxIdlePreloads: 25
};
// packages/qwik/src/server/scripts.ts
var QWIK_LOADER_DEFAULT_MINIFIED = 'const e=document,t=window,n="w",r="wp",o="d",s="dp",i="e",c="ep",a="capture:",l="readystatechange",p="qready",u=new Set,q=new Set([e]),d=new Map;let h,f,b;const g=(e,t)=>Array.from(e.querySelectorAll(t)),m=e=>{const t=[];return q.forEach(n=>t.push(...g(n,e))),t},v=(e,t,n,r=!1,o=!1)=>e.addEventListener(t,n,{capture:r,passive:o}),y=e=>{z(e);const t=g(e,"[q\\\\:shadowroot]");for(let e=0;e<t.length;e++){const n=t[e].shadowRoot;n&&y(n)}},w=e=>e&&"function"==typeof e.then,E=async e=>{for(let t=0;t<e.length;t++)await e[t]()},A=e=>{if(e.length){const t=()=>E(e);b=b?b.then(t,t):t()}},C=t=>{if(void 0===t._qwikjson_){let n=(t===e.documentElement?e.body:t).lastElementChild;for(;n;){if("SCRIPT"===n.tagName&&"qwik/json"===n.getAttribute("type")){t._qwikjson_=JSON.parse(n.textContent.replace(/\\\\x3C(\\/?script)/gi,"<$1"));break}n=n.previousElementSibling}}},_=t=>{const n=t.getAttribute("q:instance");return"paused"===t.getAttribute("q:container")&&"loading"===e.readyState&&!e[p]?.[n]&&new Promise(t=>{const r=o=>{o.detail===n&&(e.removeEventListener(p,r),t())};v(e,l,t),v(e,p,r)})},k=(e,t)=>new CustomEvent(e,{detail:t}),S=(t,n)=>{e.dispatchEvent(k(t,n))},$=e=>e.replace(/([A-Z-])/g,e=>"-"+e.toLowerCase()),I=e=>e.replace(/-./g,e=>e[1].toUpperCase()),L=e=>{const t=e.indexOf(":");return{scope:e.slice(0,t),eventName:I(e.slice(t+1))}},N=e=>2===e.length,R=e=>e.charAt(0),T=e=>!!e&&1===e.nodeType,x=(e,t,n)=>e.hasAttribute(n)&&(!!e._qDispatch?.[t]||e.hasAttribute("q-"+t)),B=(t,n,r,o,s,i,c,a=!0)=>{const l={qBase:r,symbol:i,element:n,reqTime:c};if(!s){const n=(e["qFuncs_"+t.getAttribute("q:instance")]||[])[+i];if(!n&&a){const e=Error("sym:"+i);S("qerror",{importError:"sync",error:e,...l}),console.error(e)}return n}const p=`${i}|${r}|${s}`,u=d.get(p);if(u)return u;const q=new URL(s,o).href,h=import(q);return C(t),h.then(e=>{const t=e[i];if(t)d.set(p,t),S("qsymbol",l);else{const e=Error(`${i} not in ${q}`);S("qerror",{importError:"no-symbol",error:e,...l}),console.error(e)}return t},e=>{S("qerror",{importError:"async",error:e,...l}),console.error(e)})},U=(t,n,r,o,s,i=!0)=>{let c=!1;s&&(i&&t.hasAttribute("preventdefault:"+s)&&n.preventDefault(),t.hasAttribute("stoppropagation:"+s)&&n.stopPropagation());const a=t._qDispatch?.[r];if(a){if("function"==typeof a){const e=()=>a(n,t);if(c)o.push(async()=>{const t=e();w(t)&&await t});else{const t=e();w(t)&&(c=!0,o.push(()=>t))}}else if(a.length)for(let e=0;e<a.length;e++){const r=a[e];if(r){const e=()=>r(n,t);if(c)o.push(async()=>{const t=e();w(t)&&await t});else{const t=e();w(t)&&(c=!0,o.push(()=>t))}}}return}const l=t.getAttribute("q-"+r);if(l){const r=t.closest("[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])"),s=r.getAttribute("q:base"),i=new URL(s,e.baseURI),a=l.split("|"),p=_(r);for(let e=0;e<a.length;e++){const l=a[e],u=performance.now(),[q,d,h]=l.split("#"),f=e=>{if(e&&t.isConnected){const o=n=>{const o=_(r);if(o)return o.then(()=>f(e));S("qerror",{error:n,qBase:s,symbol:d,element:t,reqTime:u})};try{const r=e.call(h,n,t);if(w(r))return r.catch(o)}catch(e){return o(e)}}},b=(e=!0)=>B(r,t,s,i,q,d,u,e),g=p&&!q?b(!1):b();if(w(g))c=!0,o.push(()=>g.then(f));else if(c||p&&!q&&!g)c=!0,o.push(async()=>{let e=g;!e&&p&&(await p,e=b(!1)),await f(e||await b())});else{const e=f(g);w(e)&&(c=!0,o.push(()=>e))}}}},j=(e,t=i,n=!0)=>{const r=$(e.type),o=t+":"+r,s=a+r,c=[],l=[],p=[];let u=e.target;for(;u;)T(u)?(c.push(u),l.push(x(u,o,s)),u=u.parentElement):u=u.parentElement;for(let t=c.length-1;t>=0;t--)if(l[t]&&(U(c[t],e,o,p,r,n),e.cancelBubble))return void A(p);for(let t=0;t<c.length;t++)if(!l[t]&&(U(c[t],e,o,p,r,n),!e.bubbles||e.cancelBubble))return void A(p);A(p)},D=e=>j(e,c,!1),O=(e,t,n=!0)=>{const r=$(t.type),o=e+":"+r,s=m("[q-"+e+"\\\\:"+r+"]"),i=[];for(let e=0;e<s.length;e++){const c=s[e];U(c,t,o,i,r,n)}A(i)},P=e=>{O(o,e)},F=e=>{O(s,e,!1)},J=e=>{O(n,e)},M=e=>{O(r,e,!1)},Z=()=>{const n=e.readyState;if("interactive"==n||"complete"==n){if(f=1,q.forEach(y),u.has("d:qinit")){u.delete("d:qinit");const e=k("qinit"),t=m("[q-d\\\\:qinit]"),n=[];for(let r=0;r<t.length;r++){const o=t[r];U(o,e,"d:qinit",n),o.removeAttribute("q-d:qinit")}A(n)}if(u.has("d:qidle")&&(u.delete("d:qidle"),(t.requestIdleCallback??t.setTimeout).bind(t)(()=>{const e=k("qidle"),t=m("[q-d\\\\:qidle]"),n=[];for(let r=0;r<t.length;r++){const o=t[r];U(o,e,"d:qidle",n),o.removeAttribute("q-d:qidle")}A(n)})),u.has("e:qvisible")){h||(h=new IntersectionObserver(e=>{const t=[];for(let n=0;n<e.length;n++){const r=e[n];r.isIntersecting&&(h.unobserve(r.target),U(r.target,k("qvisible",r),"e:qvisible",t))}A(t)}));const e=m("[q-e\\\\:qvisible]:not([q\\\\:observed])");for(let t=0;t<e.length;t++){const n=e[t];h.observe(n),n.setAttribute("q:observed","true")}}}},z=(...e)=>{for(let r=0;r<e.length;r++){const s=e[r];if("string"==typeof s){if(!u.has(s)){u.add(s);const{scope:e,eventName:r}=L(s),i=N(e),c=R(e);c===n?v(t,r,i?M:J,!0,i):q.forEach(e=>v(e,r,c===o?i?F:P:i?D:j,!0,i)),1!==f||"e:qvisible"!==s&&"d:qinit"!==s&&"d:qidle"!==s||Z()}}else q.has(s)||(u.forEach(e=>{const{scope:t,eventName:r}=L(e),i=N(t),c=R(t);c!==n&&v(s,r,c===o?i?F:P:i?D:j,!0,i)}),q.add(s))}},G=t._qwikEv;G?.roots||(Array.isArray(G)?z(...G):z("e:click","e:input"),t._qwikEv={events:u,roots:q,push:z},v(e,l,Z),Z())';
var QWIK_LOADER_DEFAULT_DEBUG = 'const doc = document;\nconst win = window;\nconst windowPrefix = "w";\nconst passiveWindowPrefix = "wp";\nconst documentPrefix = "d";\nconst passiveDocumentPrefix = "dp";\nconst elementPrefix = "e";\nconst passiveElementPrefix = "ep";\nconst capturePrefix = "capture:";\nconst readyStateChange = "readystatechange";\nconst containerReady = "qready";\nconst events = /* @__PURE__ */ new Set();\nconst roots = /* @__PURE__ */ new Set([doc]);\nconst symbols = /* @__PURE__ */ new Map();\nlet observer;\nlet hasInitialized;\nlet queuedTasks;\nconst nativeQuerySelectorAll = (root, selector) => Array.from(root.querySelectorAll(selector));\nconst querySelectorAll = (query) => {\n const elements = [];\n roots.forEach((root) => elements.push(...nativeQuerySelectorAll(root, query)));\n return elements;\n};\nconst addEventListener = (el, eventName, handler, capture = false, passive = false) => el.addEventListener(eventName, handler, { capture, passive });\nconst findShadowRoots = (fragment) => {\n addEventOrRoot(fragment);\n const shadowRoots = nativeQuerySelectorAll(fragment, "[q\\\\:shadowroot]");\n for (let i = 0; i < shadowRoots.length; i++) {\n const parent = shadowRoots[i];\n const shadowRoot = parent.shadowRoot;\n shadowRoot && findShadowRoots(shadowRoot);\n }\n};\nconst isPromise = (promise) => promise && typeof promise.then === "function";\nconst runTasks = async (tasks) => {\n for (let i = 0; i < tasks.length; i++) {\n await tasks[i]();\n }\n};\nconst queueTasks = (tasks) => {\n if (tasks.length) {\n const run = () => runTasks(tasks);\n queuedTasks = queuedTasks ? queuedTasks.then(run, run) : run();\n }\n};\nconst resolveContainer = (containerEl) => {\n if (containerEl._qwikjson_ === void 0) {\n const parentJSON = containerEl === doc.documentElement ? doc.body : containerEl;\n let script = parentJSON.lastElementChild;\n while (script) {\n if (script.tagName === "SCRIPT" && script.getAttribute("type") === "qwik/json") {\n containerEl._qwikjson_ = JSON.parse(\n script.textContent.replace(/\\\\x3C(\\/?script)/gi, "<$1")\n );\n break;\n }\n script = script.previousElementSibling;\n }\n }\n};\nconst waitForContainerReady = (container) => {\n const hash = container.getAttribute("q:instance");\n return container.getAttribute("q:container") === "paused" && doc.readyState === "loading" && !doc[containerReady]?.[hash] && new Promise((resolve) => {\n const ready = (ev) => {\n if (ev.detail === hash) {\n doc.removeEventListener(containerReady, ready);\n resolve();\n }\n };\n addEventListener(doc, readyStateChange, resolve);\n addEventListener(doc, containerReady, ready);\n });\n};\nconst createEvent = (eventName, detail) => new CustomEvent(eventName, { detail });\nconst emitEvent = (eventName, detail) => {\n doc.dispatchEvent(createEvent(eventName, detail));\n};\nconst camelToKebab = (str) => str.replace(/([A-Z-])/g, (a) => "-" + a.toLowerCase());\nconst kebabToCamel = (eventName) => eventName.replace(/-./g, (a) => a[1].toUpperCase());\nconst parseKebabEvent = (event) => {\n const separatorIndex = event.indexOf(":");\n const scope = event.slice(0, separatorIndex);\n return {\n scope,\n eventName: kebabToCamel(event.slice(separatorIndex + 1))\n };\n};\nconst isPassiveScope = (scope) => scope.length === 2;\nconst getRootScope = (scope) => scope.charAt(0);\nconst isElementNode = (node) => !!node && node.nodeType === 1;\nconst isCaptureHandlerElement = (element, scopedKebabName, captureAttribute) => element.hasAttribute(captureAttribute) && (!!element._qDispatch?.[scopedKebabName] || element.hasAttribute("q-" + scopedKebabName));\nconst resolveHandler = (container, element, qBase, base, chunk, symbol, reqTime, reportSyncError = true) => {\n const eventData = {\n qBase,\n symbol,\n element,\n reqTime\n };\n if (!chunk) {\n const handler2 = (doc["qFuncs_" + container.getAttribute("q:instance")] || [])[+symbol];\n if (!handler2 && reportSyncError) {\n const error = new Error("sym:" + symbol);\n emitEvent("qerror", {\n importError: "sync",\n error,\n ...eventData\n });\n console.error(error);\n }\n return handler2;\n }\n const key = `${symbol}|${qBase}|${chunk}`;\n const handler = symbols.get(key);\n if (handler) {\n return handler;\n }\n const href = new URL(chunk, base).href;\n const module = import(\n href\n );\n resolveContainer(container);\n return module.then(\n (module2) => {\n const handler2 = module2[symbol];\n if (!handler2) {\n const error = new Error(`${symbol} not in ${href}`);\n emitEvent("qerror", {\n importError: "no-symbol",\n error,\n ...eventData\n });\n console.error(error);\n } else {\n symbols.set(key, handler2);\n emitEvent("qsymbol", eventData);\n }\n return handler2;\n },\n (error) => {\n emitEvent("qerror", {\n importError: "async",\n error,\n ...eventData\n });\n console.error(error);\n return void 0;\n }\n );\n};\nconst dispatch = (element, ev, scopedKebabName, tasks, kebabName, allowPreventDefault = true) => {\n let defer = false;\n if (kebabName) {\n if (allowPreventDefault && element.hasAttribute("preventdefault:" + kebabName)) {\n ev.preventDefault();\n }\n if (element.hasAttribute("stoppropagation:" + kebabName)) {\n ev.stopPropagation();\n }\n }\n const handlers = element._qDispatch?.[scopedKebabName];\n if (handlers) {\n if (typeof handlers === "function") {\n const run = () => handlers(ev, element);\n if (defer) {\n tasks.push(async () => {\n const result = run();\n if (isPromise(result)) {\n await result;\n }\n });\n } else {\n const result = run();\n if (isPromise(result)) {\n defer = true;\n tasks.push(() => result);\n }\n }\n } else if (handlers.length) {\n for (let i = 0; i < handlers.length; i++) {\n const handler = handlers[i];\n if (handler) {\n const run = () => handler(ev, element);\n if (defer) {\n tasks.push(async () => {\n const result = run();\n if (isPromise(result)) {\n await result;\n }\n });\n } else {\n const result = run();\n if (isPromise(result)) {\n defer = true;\n tasks.push(() => result);\n }\n }\n }\n }\n }\n return;\n }\n const attrValue = element.getAttribute("q-" + scopedKebabName);\n if (attrValue) {\n const container = element.closest(\n "[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])"\n );\n const qBase = container.getAttribute("q:base");\n const base = new URL(qBase, doc.baseURI);\n const qrls = attrValue.split("|");\n const waitForReady = waitForContainerReady(container);\n for (let i = 0; i < qrls.length; i++) {\n const qrl = qrls[i];\n const reqTime = performance.now();\n const [chunk, symbol, capturedIds] = qrl.split("#");\n const run = (handler2) => {\n if (handler2 && element.isConnected) {\n const onError = (error) => {\n const retry = waitForContainerReady(container);\n if (retry) {\n return retry.then(() => run(handler2));\n }\n emitEvent("qerror", {\n error,\n qBase,\n symbol,\n element,\n reqTime\n });\n };\n try {\n const result = handler2.call(capturedIds, ev, element);\n if (isPromise(result)) {\n return result.catch(onError);\n }\n } catch (error) {\n return onError(error);\n }\n }\n };\n const resolve = (reportSyncError = true) => resolveHandler(container, element, qBase, base, chunk, symbol, reqTime, reportSyncError);\n const handler = waitForReady && !chunk ? resolve(false) : resolve();\n if (isPromise(handler)) {\n defer = true;\n tasks.push(() => handler.then(run));\n } else if (defer || waitForReady && !chunk && !handler) {\n defer = true;\n tasks.push(async () => {\n let retryHandler = handler;\n if (!retryHandler && waitForReady) {\n await waitForReady;\n retryHandler = resolve(false);\n }\n await run(retryHandler || await resolve());\n });\n } else {\n const result = run(handler);\n if (isPromise(result)) {\n defer = true;\n tasks.push(() => result);\n }\n }\n }\n }\n};\nconst processElementEvent = (ev, scope = elementPrefix, allowPreventDefault = true) => {\n const kebabName = camelToKebab(ev.type);\n const scopedKebabName = scope + ":" + kebabName;\n const captureAttribute = capturePrefix + kebabName;\n const elements = [];\n const captureHandlers = [];\n const tasks = [];\n let current = ev.target;\n while (current) {\n if (isElementNode(current)) {\n elements.push(current);\n captureHandlers.push(isCaptureHandlerElement(current, scopedKebabName, captureAttribute));\n current = current.parentElement;\n } else {\n current = current.parentElement;\n }\n }\n for (let i = elements.length - 1; i >= 0; i--) {\n if (captureHandlers[i]) {\n dispatch(elements[i], ev, scopedKebabName, tasks, kebabName, allowPreventDefault);\n if (ev.cancelBubble) {\n queueTasks(tasks);\n return;\n }\n }\n }\n for (let i = 0; i < elements.length; i++) {\n if (!captureHandlers[i]) {\n dispatch(elements[i], ev, scopedKebabName, tasks, kebabName, allowPreventDefault);\n if (!ev.bubbles || ev.cancelBubble) {\n queueTasks(tasks);\n return;\n }\n }\n }\n queueTasks(tasks);\n};\nconst processPassiveElementEvent = (ev) => processElementEvent(ev, passiveElementPrefix, false);\nconst broadcast = (scope, ev, allowPreventDefault = true) => {\n const kebabName = camelToKebab(ev.type);\n const scopedKebabName = scope + ":" + kebabName;\n const elements = querySelectorAll("[q-" + scope + "\\\\:" + kebabName + "]");\n const tasks = [];\n for (let i = 0; i < elements.length; i++) {\n const el = elements[i];\n dispatch(el, ev, scopedKebabName, tasks, kebabName, allowPreventDefault);\n }\n queueTasks(tasks);\n};\nconst processDocumentEvent = (ev) => {\n broadcast(documentPrefix, ev);\n};\nconst processPassiveDocumentEvent = (ev) => {\n broadcast(passiveDocumentPrefix, ev, false);\n};\nconst processWindowEvent = (ev) => {\n broadcast(windowPrefix, ev);\n};\nconst processPassiveWindowEvent = (ev) => {\n broadcast(passiveWindowPrefix, ev, false);\n};\nconst processReadyStateChange = () => {\n const readyState = doc.readyState;\n if (readyState == "interactive" || readyState == "complete") {\n hasInitialized = 1;\n roots.forEach(findShadowRoots);\n if (events.has("d:qinit")) {\n events.delete("d:qinit");\n const ev = createEvent("qinit");\n const elements = querySelectorAll("[q-d\\\\:qinit]");\n const tasks = [];\n for (let i = 0; i < elements.length; i++) {\n const el = elements[i];\n dispatch(el, ev, "d:qinit", tasks);\n el.removeAttribute("q-d:qinit");\n }\n queueTasks(tasks);\n }\n if (events.has("d:qidle")) {\n events.delete("d:qidle");\n const riC = win.requestIdleCallback ?? win.setTimeout;\n riC.bind(win)(() => {\n const ev = createEvent("qidle");\n const elements = querySelectorAll("[q-d\\\\:qidle]");\n const tasks = [];\n for (let i = 0; i < elements.length; i++) {\n const el = elements[i];\n dispatch(el, ev, "d:qidle", tasks);\n el.removeAttribute("q-d:qidle");\n }\n queueTasks(tasks);\n });\n }\n if (events.has("e:qvisible")) {\n observer || (observer = new IntersectionObserver((entries) => {\n const tasks = [];\n for (let i = 0; i < entries.length; i++) {\n const entry = entries[i];\n if (entry.isIntersecting) {\n observer.unobserve(entry.target);\n dispatch(\n entry.target,\n createEvent("qvisible", entry),\n "e:qvisible",\n tasks\n );\n }\n }\n queueTasks(tasks);\n }));\n const elements = querySelectorAll("[q-e\\\\:qvisible]:not([q\\\\:observed])");\n for (let i = 0; i < elements.length; i++) {\n const el = elements[i];\n observer.observe(el);\n el.setAttribute("q:observed", "true");\n }\n }\n }\n};\nconst addEventOrRoot = (...eventNames) => {\n for (let i = 0; i < eventNames.length; i++) {\n const eventNameOrRoot = eventNames[i];\n if (typeof eventNameOrRoot === "string") {\n if (!events.has(eventNameOrRoot)) {\n events.add(eventNameOrRoot);\n const { scope, eventName } = parseKebabEvent(eventNameOrRoot);\n const passive = isPassiveScope(scope);\n const rootScope = getRootScope(scope);\n if (rootScope === windowPrefix) {\n addEventListener(\n win,\n eventName,\n passive ? processPassiveWindowEvent : processWindowEvent,\n true,\n passive\n );\n