UNPKG

@qwik.dev/core

Version:

An open source framework for building instant loading web apps at any scale, without the extra effort.

1,262 lines (1,231 loc) 148 kB
/** * @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 } 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 } 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 = (message, ...optionalParams) => { const error = createAndLogError(false, message, ...optionalParams); debugger; throw error; }; var logErrorAndStop = (message, ...optionalParams) => { const err = createAndLogError(qDev, message, ...optionalParams); debugger; return err; }; var createAndLogError = (asyncThrow, message, ...optionalParams) => { const err = message instanceof Error ? message : new Error(message); !qTest && console.error("%cQWIK ERROR", STYLE, err.message, ...optionalParams, err.stack); asyncThrow && !qTest && setTimeout(() => { throw err; }, 0); return err; }; // packages/qwik/src/core/shared/error/assert.ts var ASSERT_DISCLAIMER = "Internal assert, this is likely caused by a bug in Qwik: "; function assertTrue(value1, text, ...parts) { if (isDev) { if (value1 === true) { return; } throwErrorAndStop(ASSERT_DISCLAIMER + text, ...parts); } } // packages/qwik/src/core/client/util-mapArray.ts var mapApp_findIndx = (array, key, start) => { isDev2 && assertTrue(start % 2 === 0, "Expecting even number."); let bottom = start >> 1; let top = array.length - 2 >> 1; while (bottom <= top) { const mid = bottom + (top - bottom >> 1); const midKey = array[mid << 1]; if (midKey === key) { return mid << 1; } if (midKey < key) { bottom = mid + 1; } else { top = mid - 1; } } return bottom << 1 ^ -1; }; var mapArray_set = (array, key, value, start, allowNullValue = false) => { const indx = mapApp_findIndx(array, key, start); if (indx >= 0) { if (value == null && !allowNullValue) { array.splice(indx, 2); } else { array[indx + 1] = value; } } else if (value != null || allowNullValue) { array.splice(indx ^ -1, 0, key, value); } }; var mapApp_remove = (array, key, start) => { const indx = mapApp_findIndx(array, key, start); let value = null; if (indx >= 0) { value = array[indx + 1]; array.splice(indx, 2); return value; } return value; }; var mapArray_get = (array, key, start) => { const indx = mapApp_findIndx(array, key, start); if (indx >= 0) { return array[indx + 1]; } else { return null; } }; var mapArray_has = (array, key, start) => { return mapApp_findIndx(array, key, start) >= 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 isObject = (v) => { return typeof v === "object" && v !== null; }; var isArray = (v) => { return Array.isArray(v); }; var isString = (v) => { return typeof v === "string"; }; // packages/qwik/src/core/shared/error/error.ts var baseUrl = "https://qwikdev-build-v2.qwik-8nx.pages.dev/docs/errors/#q"; var codeToText = (code, ...parts) => { if (isDev3) { const MAP = [ "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. See 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 `=== Qwik version {{0}} already imported while importing {{1}}. This can lead to issues due to duplicated shared structures. Verify that the Qwik libraries you're using are in "resolve.noExternal[]" and in "optimizeDeps.exclude". === `, // 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." // 35 ]; let text = MAP[code] ?? ""; if (parts.length) { text = text.replaceAll(/{{(\d+)}}/g, (_, index) => { let v = parts[index]; if (v && isObject(v) && v.constructor === Object) { v = JSON.stringify(v).slice(0, 50); } return v; }); } return `Code(Q${code}): ${text}`; } else { return `Code(Q${code}) ${baseUrl}${code}`; } }; var qError = (code, errorMessageArgs = []) => { const text = codeToText(code, ...errorMessageArgs); return logErrorAndStop(text, ...errorMessageArgs); }; // packages/qwik/src/core/shared/qrl/qrl-utils.ts import { isDev as isDev4 } from "@qwik.dev/core/build"; var SYNC_QRL = "<sync>"; // packages/qwik/src/core/shared/types.ts var DEBUG_TYPE = "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 ) // `.` is vNodeData separator skipping 4096. }; 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 getSegmentVNodeRefId = (segmentId, localIndex) => { const segmentIndex = parseInt(segmentId, 10) - 1; const diagonal = segmentIndex + localIndex; return -(diagonal * (diagonal + 1) / 2 + localIndex + 1); }; // packages/qwik/src/core/shared/utils/character-escaping.ts function escapeHTML(html) { let escapedHTML = ""; const length = html.length; let idx = 0; let lastIdx = idx; for (; idx < length; idx++) { const ch = html.charCodeAt(idx); if (ch === 60) { escapedHTML += html.substring(lastIdx, idx) + "&lt;"; } else if (ch === 62) { escapedHTML += html.substring(lastIdx, idx) + "&gt;"; } else if (ch === 38) { escapedHTML += html.substring(lastIdx, idx) + "&amp;"; } else if (ch === 34) { escapedHTML += html.substring(lastIdx, idx) + "&quot;"; } else if (ch === 39) { escapedHTML += html.substring(lastIdx, idx) + "&#39;"; } else { continue; } lastIdx = idx + 1; } if (lastIdx === 0) { return html; } else { return escapedHTML + html.substring(lastIdx); } } function encodeVNodeDataString(str) { let escapedHTML = ""; const length = str.length; let idx = 0; let lastIdx = idx; for (; idx < length; idx++) { const ch = str.charCodeAt(idx); if (ch >= VNodeDataSeparator.ADVANCE_1 && ch <= VNodeDataSeparator.ADVANCE_8192) { escapedHTML += str.substring(lastIdx, idx) + "\\" + str.charAt(idx); } else { continue; } lastIdx = idx + 1; } if (lastIdx === 0) { return str; } else { return escapedHTML + str.substring(lastIdx); } } function encodeVNodeDataKey(str) { const encoded = encodeURI(str); let encodedKey = ""; const length = encoded.length; let idx = 0; let lastIdx = idx; for (; idx < length; idx++) { const ch = encoded.charCodeAt(idx); let replacement = null; if (ch === 59) { replacement = "%3B"; } else if (ch === 61) { replacement = "%3D"; } else if (ch === 63) { replacement = "%3F"; } else if (ch === 64) { replacement = "%40"; } else if (ch === 126) { replacement = "%7E"; } else { continue; } encodedKey += encoded.substring(lastIdx, idx) + replacement; lastIdx = idx + 1; } if (lastIdx === 0) { return encoded; } else { return encodedKey + encoded.substring(lastIdx); } } // packages/qwik/src/core/shared/utils/markers.ts var OnRenderProp = "q:renderFn"; var QSlot = "q:slot"; var QSlotParent = "q:sparent"; var QStatePatchAttr = "q:patch"; var QSuspenseResolved = "q:r"; var QStyle = "q:style"; var QStyleSelector = "style[q\\:style]"; var QStyleSSelector = "style[q\\:sstyle]"; var QStylesAllSelector = QStyleSelector + "," + QStyleSSelector; var QScopedStyle = "q:sstyle"; var QCtxAttr = "q:ctx"; var QBackRefs = "q:brefs"; var QRenderAttr = "q:render"; var QRuntimeAttr = "q:runtime"; var QVersionAttr = "q:version"; var QBaseAttr = "q:base"; var QLocaleAttr = "q:locale"; var QManifestHashAttr = "q:manifest-hash"; var QInstanceAttr = "q:instance"; var QContainerIsland = "q:container-island"; var QContainerIslandEnd = "/" + QContainerIsland; var QIgnore = "q:ignore"; var QIgnoreEnd = "/" + QIgnore; var QContainerAttr = "q:container"; var QContainerAttrEnd = "/" + QContainerAttr; var QTemplate = "q:template"; var QContainerSelector = "[q\\:container]:not([q\\:container=" + "html" /* HTML */ + "]):not([q\\:container=" + "text" /* TEXT */ + "])"; var QDefaultSlot = ""; var ELEMENT_ID = "q:id"; var ELEMENT_KEY = "q:key"; var ELEMENT_PROPS = "q:props"; var ELEMENT_SEQ = "q:seq"; var ELEMENT_SEQ_IDX = "q:seqIdx"; var ELEMENT_BACKPATCH_DATA = "qwik/backpatch"; var ITERATION_ITEM_SINGLE = "q:p"; var ITERATION_ITEM_MULTI = "q:ps"; var NON_SERIALIZABLE_MARKER_PREFIX = ":"; var USE_ON_LOCAL = NON_SERIALIZABLE_MARKER_PREFIX + "on"; var USE_ON_LOCAL_SEQ_IDX = NON_SERIALIZABLE_MARKER_PREFIX + "onIdx"; var USE_ON_LOCAL_FLAGS = NON_SERIALIZABLE_MARKER_PREFIX + "onFlags"; var NEAREST_CURSOR_BOUNDARY = NON_SERIALIZABLE_MARKER_PREFIX + "nearestCursorBoundary"; var Q_PROPS_SEPARATOR = ":"; var dangerouslySetInnerHTML = "dangerouslySetInnerHTML"; // packages/qwik/src/core/shared/utils/promises.ts import { isDev as isDev5, isServer } from "@qwik.dev/core/build"; var MAX_RETRY_ON_PROMISE_COUNT = 100; var isPromise = (value) => { return !!value && typeof value == "object" && typeof value.then === "function"; }; var maybeThen = (valueOrPromise, thenFn) => { return isPromise(valueOrPromise) ? valueOrPromise.then(thenFn) : thenFn(valueOrPromise); }; var checkError = (e) => { if (isServer && e instanceof ReferenceError && e.message.includes("window")) { e.message = 'It seems like you forgot to add "if (isBrowser) {...}" here:' + e.message; } }; var justThrow = (e) => { throw e; }; function retryOnPromise(fn, onError = justThrow) { let ok = false; let result; try { result = fn(); ok = true; } catch (e) { result = e; } if (!isPromise(result)) { if (ok) { return result; } isDev5 && checkError(result); return onError(result); } let retryCount = MAX_RETRY_ON_PROMISE_COUNT; const retry = async (p) => { while (isPromise(p)) { try { await p; return await fn(); } catch (err) { if (isPromise(err)) { if (!--retryCount) { p = new Error("Exceeded max retry count in retryOnPromise"); break; } else { p = err; } } else { p = err; break; } } } isDev5 && checkError(p); return onError(p); }; return ok ? result.catch(retry) : retry(result); } // packages/qwik/src/core/shared/utils/scoped-styles.ts function isClassAttr(key) { return key === "class"; } function convertStyleIdsToString(scopedStyleIds) { return Array.from(scopedStyleIds).join(" "); } // packages/qwik/src/core/shared/utils/event-names.ts var isHtmlAttributeAnEventName = (name) => { return name.charCodeAt(0) === 113 && name.charCodeAt(1) === 45 && (name.charCodeAt(3) === 58 || name.charCodeAt(3) === 112 && name.charCodeAt(4) === 58); }; function isPreventDefault(key) { return key.startsWith("preventdefault:"); } // packages/qwik/src/core/shared/utils/unitless_number.ts var unitlessNumbers = /* @__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 = (name) => { return unitlessNumbers.has(name); }; // packages/qwik/src/core/shared/utils/styles.ts var serializeClass = (obj) => { if (!obj) { return ""; } if (isString(obj)) { return obj.trim(); } const classes = []; if (isArray(obj)) { for (let i = 0; i < obj.length; i++) { const o = obj[i]; const classList = serializeClass(o); if (classList) { classes.push(classList); } } } else { for (const [key, value] of Object.entries(obj)) { if (value) { classes.push(key.trim()); } } } return classes.join(" "); }; var fromCamelToKebabCaseWithDash = (text) => { return text.replace(/([A-Z])/g, "-$1").toLowerCase(); }; var stringifyStyle = (obj) => { if (obj == null) { return ""; } if (typeof obj == "object") { if (isArray(obj)) { throw qError(0 /* stringifyClassOrStyle */, [obj, "style"]); } else { const chunks = []; for (const key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { const value = obj[key]; if (value != null && typeof value !== "function") { if (key.startsWith("--")) { chunks.push(key + ":" + value); } else { chunks.push(fromCamelToKebabCaseWithDash(key) + ":" + setValueForStyle(key, value)); } } } } return chunks.join(";"); } } return String(obj); }; var serializeBooleanOrNumberAttribute = (value) => { return value != null ? String(value) : null; }; function serializeAttribute(key, value, styleScopedId) { if (isClassAttr(key)) { const serializedClass = serializeClass(value); value = styleScopedId ? styleScopedId + (serializedClass.length ? " " + serializedClass : serializedClass) : serializedClass; } else if (key === "style") { value = stringifyStyle(value); } else if (isEnumeratedBooleanAttribute(key) || typeof value === "number") { value = serializeBooleanOrNumberAttribute(value); } else if (value === false || value == null) { value = null; } else if (value === true && isPreventDefault(key)) { value = ""; } return value; } function isEnumeratedBooleanAttribute(key) { return isAriaAttribute(key) || ["spellcheck", "draggable", "contenteditable"].includes(key); } var setValueForStyle = (styleName, value) => { if (typeof value === "number" && value !== 0 && !isUnitlessNumber(styleName)) { return value + "px"; } return value; }; function isAriaAttribute(prop) { return prop.startsWith("aria-"); } // packages/qwik/src/core/preloader/bundle-graph.ts var base; var graph; var parseBundleGraph = (serialized) => { const graph2 = /* @__PURE__ */ new Map(); let i = 0; while (i < serialized.length) { const name = serialized[i++]; const deps = []; let idx; let probability = 1; while (idx = serialized[i], typeof idx === "number") { if (idx < 0) { probability = -idx / 10; } else { deps.push({ $name$: serialized[idx], $importProbability$: probability, $factor$: 1 }); } i++; } graph2.set(name, deps); } return graph2; }; var initPreloader = (serializedBundleGraph) => { if (base != null || !serializedBundleGraph) { return; } base = ""; graph = parseBundleGraph(serializedBundleGraph); }; // packages/qwik/src/core/shared/utils/objects.ts var isObjectEmpty = (obj) => { for (const key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { return false; } } return true; }; // packages/qwik/src/core/ssr/stream-writer.ts var stringifyRootRefPath = (path) => { let text = String(path[0]); for (let i = 1; i < path.length; i++) { text += " " + path[i]; } return text; }; var writeStringRootRef = (writer, id) => writer.write(String(id)); var writeStringRootRefPath = (writer, path) => writer.write(stringifyRootRefPath(path)); var createStringStreamWriter = (write) => ({ write, writeRootRef(id) { return writeStringRootRef(this, id); }, writeRootRefPath(path) { return writeStringRootRefPath(this, path); } }); // packages/qwik/src/core/shared/ssr-const.ts var LT = "<"; var GT = ">"; var CLOSE_TAG = "</"; var SPACE = " "; var ATTR_EQUALS_QUOTE = '="'; var QUOTE = '"'; var EMPTY_ATTR = '=""'; var BRACKET_OPEN = "["; var BRACKET_CLOSE = "]"; var PAREN_CLOSE = ")"; var COMMA = ","; // packages/qwik/src/server/platform.ts var getDevSegmentPath = (mapper, hash, symbolName, parent) => { const existing = mapper?.[hash]; if (existing) { return existing; } if (symbolName === SYNC_QRL) { return [symbolName, ""]; } if (!parent) { if (symbolName.startsWith("_") && symbolName.length < 6) { return [symbolName, `${import.meta.env?.BASE_URL}@qwik-handlers`]; } console.error("qwik symbolMapper: unknown qrl requested without parent:", symbolName); return [symbolName, `${import.meta.env?.BASE_URL}${symbolName}.js`]; } const qrlFile = `${import.meta.env?.BASE_URL}${parent.startsWith("/") ? parent.slice(1) : parent}_${symbolName}.js`; return [symbolName, qrlFile]; }; function createPlatform(opts, resolvedManifest) { const mapper = resolvedManifest?.mapper; const mapperFn = opts.symbolMapper ? opts.symbolMapper : (symbolName, _chunk, parent) => { if (mapper || isDev6 && import.meta.env?.MODE !== "test") { const hash = getSymbolHash(symbolName); const result = !isDev6 ? mapper[hash] : getDevSegmentPath(mapper, hash, symbolName, parent); if (!result) { if (hash === SYNC_QRL) { return [hash, ""]; } const isRegistered = globalThis.__qwik_reg_symbols?.has(hash); if (isRegistered) { return [symbolName, "_"]; } console.error("Cannot resolve symbol", symbolName, "in", mapper, parent); } return result; } }; const serverPlatform = { isServer: true, async importSymbol(_containerEl, url, symbolName) { const hash = getSymbolHash(symbolName); const regSym = globalThis.__qwik_reg_symbols?.get(hash); if (regSym) { return regSym; } throw qError(6 /* dynamicImportFailed */, [symbolName]); }, raf: () => { console.error("server can not rerender"); return Promise.resolve(); }, chunkForSymbol(symbolName, _chunk, parent) { return mapperFn(symbolName, mapper, parent); } }; return serverPlatform; } async function setServerPlatform(opts, manifest) { const platform = createPlatform(opts, manifest); setPlatform(platform); } var getSymbolHash = (symbolName) => { const index = symbolName.lastIndexOf("_"); if (index > -1) { return symbolName.slice(index + 1); } return symbolName; }; // packages/qwik/src/server/ssr-render.ts import { getClientManifest } from "@qwik.dev/core"; // packages/qwik/src/server/ssr-container.ts import { isDev as isDev8 } from "@qwik.dev/core/build"; import { _SubscriptionData as SubscriptionData, _SharedContainer, _jsxSorted, _jsxSplit, _res, _setEvent, _walkJSX, _createQRL as createQRL, isSignal } from "@qwik.dev/core/internal"; // packages/qwik/src/server/ooos-utils.ts import { _SubscriptionPatch as SubscriptionPatch } from "@qwik.dev/core/internal"; var recordExternalRootEffect = (rootCtx, segmentCtx, storeProxyMap, records, producer, effect, prop, sourceEffects) => { if (!records || prop !== null && !sourceEffects) { return; } let rootObj = producer; if (prop !== null && producer && (typeof producer === "object" || typeof producer === "function")) { rootObj = storeProxyMap.get(producer) || producer; } const rootId = rootCtx.$hasRootId$(rootObj); segmentCtx.$addRoot$(rootObj); segmentCtx.$addRoot$(effect); if (prop !== null && typeof prop !== "string") { segmentCtx.$addRoot$(prop); } records.push({ rootObj, rootId, effect, prop }); }; var collectSubscriptionPatches = (rootCtx, records, rootLimit) => { if (!records?.length) { return; } const patches = []; const patchesByRoot = /* @__PURE__ */ new Map(); for (let i = 0; i < records.length; i++) { const entry = records[i]; const rootId = entry.rootId === void 0 ? rootCtx.$hasRootId$(entry.rootObj) : entry.rootId; if (rootId === void 0 || rootId >= rootLimit) { continue; } let patch = patchesByRoot.get(rootId); if (!patch) { patch = new SubscriptionPatch( rootId, entry.prop === null ? /* @__PURE__ */ new Set() : /* @__PURE__ */ new Map() ); patchesByRoot.set(rootId, patch); patches.push(patch); } const subscriptions = patch.subscriptions; if (entry.prop === null) { if (subscriptions instanceof Set) { subscriptions.add(entry.effect); } } else { if (subscriptions instanceof Map) { let effects = subscriptions.get(entry.prop); if (!effects) { effects = /* @__PURE__ */ new Set(); subscriptions.set(entry.prop, effects); } effects.add(entry.effect); } } } return patches.length ? patches : void 0; }; // packages/qwik/src/server/preload-impl.ts import { getPlatform } from "@qwik.dev/core"; var simplifyPath = (base2, path) => { if (path == null) { return null; } const segments = `${base2}${path}`.split("/"); const simplified = []; for (let i = 0; i < segments.length; i++) { const segment = segments[i]; if (segment === ".." && simplified.length > 0) { simplified.pop(); } else { simplified.push(segment); } } return simplified.join("/"); }; var getBase = (container) => { let base2 = container.$buildBase$; if (import.meta.env?.DEV && !qTest) { base2 = import.meta.env?.BASE_URL; } return base2; }; var preloaderPre = (container, options, nonce) => { const { resolvedManifest } = container; const base2 = getBase(container); const preloaderBundle = simplifyPath(base2, resolvedManifest?.manifest?.preloader); let bundleGraphPath = resolvedManifest?.manifest.bundleGraphAsset; if (bundleGraphPath) { bundleGraphPath = (import.meta.env?.BASE_URL || "/") + bundleGraphPath; } if (!(import.meta.env?.DEV && !qTest) && preloaderBundle && bundleGraphPath && options !== false) { const bundleGraph = container.resolvedManifest?.manifest.bundleGraph; initPreloader(bundleGraph); const opts = []; if (options) { if (options.maxIdlePreloads) { opts.push(`P:${options.maxIdlePreloads}`); } } const optsStr = opts.length ? `,{${opts.join(",")}}` : ""; const preloaderLinkAttrs = { rel: "modulepreload", href: preloaderBundle }; if (nonce) { preloaderLinkAttrs["nonce"] = nonce; } container.openElement("link", null, preloaderLinkAttrs, null, null, null); container.closeElement(); container.openElement( "link", null, { rel: "preload", href: bundleGraphPath, as: "fetch", crossorigin: "anonymous" }, null, null, null ); container.closeElement(); const script = `let b=fetch("${bundleGraphPath}");import("${preloaderBundle}").then(({l})=>l(${JSON.stringify(base2)},b${optsStr}));`; const scriptAttrs = { type: "module", async: true, crossorigin: "anonymous" }; if (nonce) { scriptAttrs["nonce"] = nonce; } container.writeScript(scriptAttrs, script); } const corePath = simplifyPath(base2, resolvedManifest?.manifest.core); if (corePath) { const linkAttrs = { rel: "modulepreload", href: corePath }; if (nonce) { linkAttrs["nonce"] = nonce; } container.openElement("link", null, linkAttrs, null, null, null); container.closeElement(); } }; var includePreloader = (container, options, referencedBundles, nonce) => { if (referencedBundles.length === 0 || options === false) { return null; } const { ssrPreloads } = normalizePreLoaderOptions( typeof options === "boolean" ? void 0 : options ); let allowedSsrPreloads = ssrPreloads; const base2 = getBase(container); const links = []; const { resolvedManifest } = container; if (allowedSsrPreloads) { const preloaderBundle2 = resolvedManifest?.manifest.preloader; const coreBundle = resolvedManifest?.manifest.core; for (let i = 0; i < referencedBundles.length; i++) { const href = referencedBundles[i]; if (href === preloaderBundle2 || href === coreBundle) { continue; } links.push(href); if (--allowedSsrPreloads === 0) { break; } } } const preloaderBundle = simplifyPath(base2, resolvedManifest?.manifest.preloader); const insertLinks = links.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(links)}.map((l,e)=>{e=document.createElement('link');e.rel='modulepreload';e.href=${JSON.stringify(base2)}+l;document.head.appendChild(e)});` ) : ""; let script = insertLinks; if (preloaderBundle) { script += `window.addEventListener('load',f=>{f=_=>import("${preloaderBundle}").then(({p})=>p(${JSON.stringify(referencedBundles)}));try{requestIdleCallback(f,{timeout:2000})}catch(e){setTimeout(f,200)}})`; } if (script) { const attrs = { type: "module", async: "true", "q:type": "preload" }; if (nonce) { attrs["nonce"] = nonce; } container.writeScript(attrs, script); } return null; }; var preloaderPost = (ssrContainer, opts, nonce) => { if (import.meta.env?.DEV && !qTest) { return; } if (opts.preloader !== false) { const qrls = Array.from(ssrContainer.serializationCtx.$eventQrls$); const preloadBundles = getBundles(qrls); includePreloader(ssrContainer, opts.preloader, preloadBundles, nonce); } }; function normalizePreLoaderOptions(input) { return { ...preLoaderOptionsDefault, ...input }; } var getBundles = (qrls) => { const platform = getPlatform(); const bundles = qrls?.map((qrl) => { const symbol = qrl.$symbol$; const chunk = qrl.$chunk$; const result = platform.chunkForSymbol(symbol, chunk, qrl.dev?.file); if (result) { return result[1]; } return chunk; }).filter(Boolean); return [...new Set(bundles)]; }; 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