@qwik.dev/core
Version:
An open source framework for building instant loading web apps at any scale, without the extra effort.
1,461 lines (1,460 loc) • 138 kB
JavaScript
const cn = (t, e = 0) => {
for (let n = 0; n < t.length; n++) {
const r = t.charCodeAt(n);
e = (e << 5) - e + r, e |= 0;
}
return Number(Math.abs(e)).toString(36);
}, dn = /* @__PURE__ */ new Set([
"_chk",
"_rsc",
"_res",
"_run",
"_task",
"_val",
// Each
"_eaC",
"_eaT",
// Suspense
"_suC",
"_suT",
// Reveal
"_reR",
"_reC",
"_reT"
]);
function un(t) {
const e = t.symbols;
return Object.keys(e).sort((n, r) => {
const i = e[n], s = e[r];
if (i.ctxKind === "eventHandler" && s.ctxKind !== "eventHandler")
return -1;
if (i.ctxKind !== "eventHandler" && s.ctxKind === "eventHandler")
return 1;
if (i.ctxKind === "eventHandler" && s.ctxKind === "eventHandler") {
const a = ht.indexOf(i.ctxName.toLowerCase()), l = ht.indexOf(s.ctxName.toLowerCase());
if (a > -1 && l > -1) {
if (a < l)
return -1;
if (a > l)
return 1;
} else {
if (a > -1)
return -1;
if (l > -1)
return 1;
}
} else if (i.ctxKind === "function" && s.ctxKind === "function") {
const a = ft.indexOf(i.ctxName.toLowerCase()), l = ft.indexOf(s.ctxName.toLowerCase());
if (a > -1 && l > -1) {
if (a < l)
return -1;
if (a > l)
return 1;
} else {
if (a > -1)
return -1;
if (l > -1)
return 1;
}
}
return !i.parent && s.parent ? -1 : i.parent && !s.parent ? 1 : i.hash < s.hash ? -1 : i.hash > s.hash ? 1 : 0;
});
}
const ht = [
// Click Events
"click",
"dblclick",
"contextmenu",
"auxclick",
// Pointer Events
"pointerdown",
"pointerup",
"pointermove",
"pointerover",
"pointerenter",
"pointerleave",
"pointerout",
"pointercancel",
"gotpointercapture",
"lostpointercapture",
// Touch Events
"touchstart",
"touchend",
"touchmove",
"touchcancel",
// Mouse Events
"mousedown",
"mouseup",
"mousemove",
"mouseenter",
"mouseleave",
"mouseover",
"mouseout",
"wheel",
// Gesture Events
"gesturestart",
"gesturechange",
"gestureend",
// Keyboard Events
"keydown",
"keyup",
"keypress",
// Input/Change Events
"input",
"change",
"search",
"invalid",
"beforeinput",
"select",
// Focus/Blur Events
"focusin",
"focusout",
"focus",
"blur",
// Form Events
"submit",
"reset",
// Scroll Events
"scroll"
].map((t) => `on${t.toLowerCase()}$`), ft = ["useTask$", "useVisibleTask$", "component$", "useStyles$", "useStylesScoped$"].map(
(t) => t.toLowerCase()
);
function hn(t) {
return Object.keys(t.bundles).sort(Qe);
}
function fn(t) {
const e = un(t), n = {}, r = {};
for (const a of e)
n[a] = t.symbols[a], r[a] = t.mapping[a];
const i = hn(t), s = {};
for (const a of i) {
s[a] = t.bundles[a];
const l = t.bundles[a];
Array.isArray(l.imports) && l.imports.sort(Qe), Array.isArray(l.dynamicImports) && l.dynamicImports.sort(Qe);
const c = [];
for (const o of e)
a === r[o] && c.push(o);
c.length > 0 && (c.sort(Qe), l.symbols = c);
}
return t.symbols = n, t.mapping = r, t.bundles = s, t;
}
function Qe(t, e) {
return t = t.toLocaleLowerCase(), e = e.toLocaleLowerCase(), t < e ? -1 : t > e ? 1 : 0;
}
function pt(t) {
if (t != null && t.mapping != null && typeof t.mapping == "object" && t.symbols != null && typeof t.symbols == "object" && t.bundles != null && typeof t.bundles == "object")
return t;
}
const pn = (t, e) => {
let n = 0;
if (t.symbols)
for (const r of t.symbols) {
let i = 1;
const s = e.symbols[r];
s && (s.ctxKind === "function" ? /(component|useStyles|useStylesScoped)/i.test(s.ctxName) ? i += 1 : /(useComputed|useTask|useVisibleTask|useOn)/i.test(s.ctxName) && (i += 2) : (i += 1, /(click|mouse|pointer|touch|key|scroll|gesture|wheel)/i.test(s.ctxName) && (i += 3))), n = Math.max(n, i);
}
return n;
};
function gn(t) {
let e = 0;
const n = [], r = [], i = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Set();
function l(d) {
i.set(d, e), s.set(d, e), e++, n.push(d), a.add(d);
const f = t[d].imports || [];
for (const u of f)
i.has(u) ? a.has(u) && s.set(d, Math.min(s.get(d), i.get(u))) : (l(u), s.set(d, Math.min(s.get(d), s.get(u))));
if (s.get(d) === i.get(d)) {
const u = [];
let w;
do
w = n.pop(), a.delete(w), u.push(w);
while (w !== d);
r.push(u);
}
}
for (const d of Object.keys(t))
i.has(d) || l(d);
const c = /* @__PURE__ */ new Map();
r.forEach((d, f) => {
for (const u of d)
c.set(u, f);
});
const o = Array.from({ length: r.length }, () => /* @__PURE__ */ new Set());
for (const d of Object.keys(t)) {
const f = c.get(d);
for (const u of t[d].imports || []) {
const w = c.get(u);
f !== w && o[f].add(w);
}
}
const g = /* @__PURE__ */ new Set(), m = [];
function b(d) {
g.add(d);
for (const f of o[d])
g.has(f) || b(f);
m.push(d);
}
for (let d = 0; d < r.length; d++)
g.has(d) || b(d);
m.reverse();
const h = new Array(r.length).fill(0);
for (let d = 0; d < r.length; d++) {
let f = 0;
for (const u of r[d])
f += t[u].size;
h[d] = f;
}
for (let d = m.length - 1; d >= 0; d--) {
const f = m[d];
let u = h[f];
for (const w of o[f])
u += h[w];
h[f] = u;
}
for (let d = 0; d < r.length; d++) {
const f = h[d];
for (const u of r[d])
t[u].total = f;
}
}
const gt = /[/\\](core|qwik)[/\\]dist[/\\]preloader\.(|c|m)js$/, mt = /[/\\](core|qwik)[/\\]dist[/\\]core(\.min|\.prod)?\.(|c|m)js$/, wt = /[/\\](core|qwik)[/\\](dist[/\\])?qwikloader(\.debug)?\.[^/]*js$/;
function mn(t, e, n, r, i, s, a) {
const l = {
version: "1",
manifestHash: "",
options: {
target: i.target,
buildMode: i.buildMode,
// don't copy the insights stuff
entryStrategy: i.entryStrategy && { type: i.entryStrategy.type }
},
core: void 0,
preloader: void 0,
qwikLoader: void 0,
bundleGraphAsset: void 0,
injections: n,
mapping: {},
bundles: {},
assets: {},
symbols: {},
bundleGraph: void 0
}, c = (h) => {
const d = r[h];
if (!d) {
console.warn(`Client manifest generation: skipping external import "${h}"`);
return;
}
return a(d.fileName);
};
let o, g, m;
for (const h of Object.values(r)) {
const d = c(h.fileName);
h.name === "core" && (o = d), h.name === "preloader" && (g = d), h.name === "handlers" && (m = d);
}
const b = new Set(e.map((h) => h.name));
for (const h of Object.values(r)) {
if (h.type === "asset") {
h.fileName.endsWith("js.map") || (l.assets[h.fileName] = {
name: h.names[0],
size: h.source.length
});
continue;
}
const d = a(h.fileName), u = {
size: h.code.length,
total: -1
};
for (const I of h.exports)
b.has(I) && (!l.mapping[I] || h.exports.length !== 1) && (l.mapping[I] = d);
const w = h.imports.filter((I) => h.code.includes(t.basename(I))).map((I) => c(I)).filter((I) => I !== g && I !== o && I !== m).filter(Boolean);
w.length > 0 && (u.imports = w);
const T = h.dynamicImports.filter((I) => h.code.includes(t.basename(I))).map((I) => c(I)).filter(Boolean);
T.length > 0 && (u.dynamicImports = T), h.facadeModuleId && (gt.test(h.facadeModuleId) ? l.preloader = d : mt.test(h.facadeModuleId) ? l.core = d : wt.test(h.facadeModuleId) && (l.qwikLoader = d));
const j = (h.moduleIds || Object.keys(h.modules)).filter((I) => !I.startsWith("\0")).map((I) => t.relative(i.rootDir, I));
j.length > 0 && (u.origins = j, !l.preloader && j.some((I) => gt.test(I)) && (l.preloader = d), !l.core && j.some((I) => mt.test(I)) && (l.core = d), !l.qwikLoader && j.some((I) => wt.test(I)) && (l.qwikLoader = d)), l.bundles[d] = u;
}
for (const h of e) {
const d = h.name, f = l.mapping[d];
if (!f) {
s(`Note: qrl ${h.name} is not in the bundle, likely tree shaken`, l);
continue;
}
(l.bundles[f].symbols ||= []).push(d), l.symbols[d] = {
displayName: h.displayName,
hash: h.hash,
ctxKind: h.ctxKind,
ctxName: h.ctxName,
captures: h.captures,
canonicalFilename: h.canonicalFilename,
parent: h.parent,
origin: h.origin,
loc: h.loc,
paramNames: h.paramNames,
captureNames: h.captureNames
};
}
if (m)
for (const h of dn)
l.symbols[h] = {
origin: "Qwik core",
displayName: h,
canonicalFilename: "",
hash: h,
ctxKind: "function",
ctxName: h,
captures: !1,
parent: null,
loc: [0, 0]
}, l.mapping[h] = m;
else
console.error("Qwik core bundle not found, is Qwik actually used in this project?");
for (const h of Object.values(l.bundles)) {
const d = pn(h, l);
h.interactivity = d;
}
return gn(l.bundles), fn(l);
}
const wn = 300, bn = 0.5 / (wn * 1024 / 8), vn = (t) => {
const e = t.lastIndexOf("_");
return e > -1 ? t.slice(e + 1) : t;
};
function yn(t, e) {
const n = [];
if (!t.bundles)
return [];
const r = { ...t.bundles };
for (const [c, o] of Object.entries(t.mapping)) {
if (c.startsWith("_") && c.length < 10)
continue;
const g = vn(c);
g && (r[g] = { dynamicImports: [o] });
}
if (e) {
const c = { ...t, bundles: r };
for (const o of e) {
const g = o(c);
g && Object.assign(r, g);
}
}
for (const c of Object.keys(r)) {
const o = r[c], g = o.imports?.filter((b) => r[b]) || [], m = o.dynamicImports?.filter(
// we only want to include dynamic imports that belong to the app
// e.g. not all languages supported by shiki
(b) => r[b] && // either there are qrls
(r[b].symbols || // or it's a dynamic import from the app source
r[b].origins?.some((h) => !h.includes("node_modules")))
) || [];
r[c] = {
...o,
imports: g,
dynamicImports: m
};
}
const i = new Set(Object.keys(r));
for (const c of Object.keys(r)) {
for (const o of r[c].imports)
i.delete(o);
for (const o of r[c].dynamicImports)
i.delete(o);
}
for (const c of i) {
const o = r[c];
!o.imports?.length && !o.dynamicImports?.length && delete r[c];
}
const s = Object.keys(r), a = /* @__PURE__ */ new Map(), l = (c, o, g = /* @__PURE__ */ new Set()) => {
const m = r[o];
for (const b of m.imports)
c.has(b) && c.delete(b), g.has(b) || (g.add(b), l(c, b, g));
};
for (const c of s) {
const o = r[c], g = new Set(o.imports);
for (const d of g)
l(g, d);
const m = new Set(o.dynamicImports), b = /* @__PURE__ */ new Map();
for (const d of m) {
l(m, d);
const f = r[d];
let u = 0.5;
if (u += (f.interactivity || 0) * 0.08, o.origins && f.origins) {
for (const w of o.origins)
if (f.origins.some((T) => T.startsWith(w))) {
u += 0.25;
break;
}
}
f.total > bn && (u += u > 0.5 ? 0.02 : -0.02), f.total < 1e3 && (u += 0.15), b.set(d, Math.min(u, 0.99));
}
if (m.size > 0) {
const d = Array.from(m).sort(
(u, w) => b.get(w) - b.get(u)
);
let f = -1;
for (const u of d)
b.get(u) !== f && (f = b.get(u), g.add(-Math.round(f * 10))), g.add(u);
}
const h = n.length;
n.push(c);
for (let d = 0; d < g.size; d++)
n.push(null);
a.set(c, { index: h, deps: g });
}
for (const c of s) {
const o = a.get(c);
let { index: g, deps: m } = o;
g++;
for (const b of m) {
if (typeof b == "number") {
n[g++] = b;
continue;
}
const d = a.get(b).index;
n[g++] = d;
}
}
return n;
}
async function xn(t, e, n) {
const r = await t.dynamicImport("eslint");
let i = new r.ESLint({ cache: !0 });
if ((await i.calculateConfigForFile("no-real-file.tsx")).parser === null) {
const l = {
cache: !0,
overrideConfig: {
languageOptions: {
parserOptions: {
tsconfigRootDir: e,
project: n,
ecmaVersion: 2021,
sourceType: "module",
ecmaFeatures: {
jsx: !0
}
}
}
}
};
i = new r.ESLint(l);
}
return {
async lint(l, c, o) {
try {
const g = kn(o);
if (await i.isPathIgnored(g))
return null;
(await i.lintText(c, {
filePath: g
})).forEach((b) => {
for (const h of b.messages) {
if (h.ruleId != null && !h.ruleId.startsWith("qwik/"))
continue;
const d = En(b.filePath, h);
l.warn(d);
}
});
} catch (g) {
console.warn(g);
}
}
};
}
function kn(t) {
return t.split("?", 2)[0];
}
function En(t, e) {
return Object.assign(new Error(e.message), {
id: t,
plugin: "vite-plugin-eslint",
loc: {
file: t,
column: e.column,
line: e.line
},
stack: ""
});
}
async function Sn(t, e) {
const n = e;
let r = n.loc;
if (!n.frame && !n.plugin && (r || (r = In(n)), r && (n.loc = r, r.file))) {
const i = await t.dynamicImport("node:fs"), { normalizePath: s } = await t.dynamicImport("vite");
n.id = s(n.loc.file);
try {
const a = i.readFileSync(n.loc.file, "utf-8");
n.frame = Cn(a, n.loc);
} catch {
}
}
return e;
}
const In = (t) => {
const e = t.stack;
if (typeof e == "string") {
const n = e.split(`
`).filter((r) => !r.includes("/node_modules/") && !r.includes("(node:"));
for (let r = 1; r < n.length; r++) {
const i = n[r].replace("file:///", "/");
if (/^\s+at/.test(i)) {
const s = i.indexOf("/"), a = i.lastIndexOf(")", s);
if (s > 0) {
const c = i.slice(s, a).split(":"), o = bt(c[c.length - 1]), g = bt(c[c.length - 2]);
return typeof o == "number" && typeof g == "number" ? (c.length -= 2, {
file: c.join(":"),
line: g,
column: o
}) : typeof o == "number" ? (c.length -= 1, {
file: c.join(":"),
line: o,
column: void 0
}) : {
file: c.join(":"),
line: void 0,
column: void 0
};
}
}
}
}
}, ae = (t) => t.startsWith("\0"), bt = (t) => {
try {
return parseInt(t, 10);
} catch {
return;
}
}, Ht = /\r?\n/, vt = 2;
function _n(t, e) {
if (typeof e == "number")
return e;
if (e.lo != null)
return e.lo;
const n = t.split(Ht), { line: r, column: i } = e;
let s = 0;
for (let a = 0; a < r - 1 && a < n.length; a++)
s += n[a].length + 1;
return s + i;
}
function Cn(t, e = 0, n) {
e = _n(t, e), n = n || e;
const r = t.split(Ht);
let i = 0;
const s = [];
for (let a = 0; a < r.length; a++)
if (i += r[a].length + 1, i >= e) {
for (let l = a - vt; l <= a + vt || n > i; l++) {
if (l < 0 || l >= r.length)
continue;
const c = l + 1;
s.push(`${c}${" ".repeat(Math.max(3 - String(c).length, 0))}| ${r[l]}`);
const o = r[l].length;
if (l === a) {
const g = Math.max(e - (i - o) + 1, 0), m = Math.max(1, n > i ? o - g : n - e);
s.push(" | " + " ".repeat(g) + "^".repeat(m));
} else if (l > a) {
if (n > i) {
const g = Math.max(Math.min(n - i, o), 1);
s.push(" | " + "^".repeat(g));
}
i += o + 1;
}
}
break;
}
return s.join(`
`);
}
function Tn(t) {
return t === "win32";
}
function We(t) {
const [e, n] = t.split("?"), r = n || "";
return {
originalId: t,
pathId: e,
query: r ? `?${n}` : "",
params: new URLSearchParams(r)
};
}
var Pn = 44, Nn = 59, yt = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", Gt = new Uint8Array(64), Dn = new Uint8Array(128);
for (let t = 0; t < yt.length; t++) {
const e = yt.charCodeAt(t);
Gt[t] = e, Dn[e] = t;
}
function ye(t, e, n) {
let r = e - n;
r = r < 0 ? -r << 1 | 1 : r << 1;
do {
let i = r & 31;
r >>>= 5, r > 0 && (i |= 32), t.write(Gt[i]);
} while (r > 0);
return e;
}
var xt = 1024 * 16, kt = typeof TextDecoder < "u" ? /* @__PURE__ */ new TextDecoder() : typeof Buffer < "u" ? {
decode(t) {
return Buffer.from(t.buffer, t.byteOffset, t.byteLength).toString();
}
} : {
decode(t) {
let e = "";
for (let n = 0; n < t.length; n++)
e += String.fromCharCode(t[n]);
return e;
}
}, Ln = class {
constructor() {
this.pos = 0, this.out = "", this.buffer = new Uint8Array(xt);
}
write(t) {
const { buffer: e } = this;
e[this.pos++] = t, this.pos === xt && (this.out += kt.decode(e), this.pos = 0);
}
flush() {
const { buffer: t, out: e, pos: n } = this;
return n > 0 ? e + kt.decode(t.subarray(0, n)) : e;
}
};
function On(t) {
const e = new Ln();
let n = 0, r = 0, i = 0, s = 0;
for (let a = 0; a < t.length; a++) {
const l = t[a];
if (a > 0 && e.write(Nn), l.length === 0) continue;
let c = 0;
for (let o = 0; o < l.length; o++) {
const g = l[o];
o > 0 && e.write(Pn), c = ye(e, g[0], c), g.length !== 1 && (n = ye(e, g[1], n), r = ye(e, g[2], r), i = ye(e, g[3], i), g.length !== 4 && (s = ye(e, g[4], s)));
}
}
return e.flush();
}
class Ke {
constructor(e) {
this.bits = e instanceof Ke ? e.bits.slice() : [];
}
add(e) {
this.bits[e >> 5] |= 1 << (e & 31);
}
has(e) {
return !!(this.bits[e >> 5] & 1 << (e & 31));
}
}
class Be {
constructor(e, n, r) {
this.start = e, this.end = n, this.original = r, this.intro = "", this.outro = "", this.content = r, this.storeName = !1, this.edited = !1, this.previous = null, this.next = null;
}
appendLeft(e) {
this.outro += e;
}
appendRight(e) {
this.intro = this.intro + e;
}
clone() {
const e = new Be(this.start, this.end, this.original);
return e.intro = this.intro, e.outro = this.outro, e.content = this.content, e.storeName = this.storeName, e.edited = this.edited, e;
}
contains(e) {
return this.start < e && e < this.end;
}
eachNext(e) {
let n = this;
for (; n; )
e(n), n = n.next;
}
eachPrevious(e) {
let n = this;
for (; n; )
e(n), n = n.previous;
}
edit(e, n, r) {
return this.content = e, r || (this.intro = "", this.outro = ""), this.storeName = n, this.edited = !0, this;
}
prependLeft(e) {
this.outro = e + this.outro;
}
prependRight(e) {
this.intro = e + this.intro;
}
reset() {
this.intro = "", this.outro = "", this.edited && (this.content = this.original, this.storeName = !1, this.edited = !1);
}
split(e) {
const n = e - this.start, r = this.original.slice(0, n), i = this.original.slice(n);
this.original = r;
const s = new Be(e, this.end, i);
return s.outro = this.outro, this.outro = "", this.end = e, this.edited ? (s.edit("", !1), this.content = "") : this.content = r, s.next = this.next, s.next && (s.next.previous = s), s.previous = this, this.next = s, s;
}
toString() {
return this.intro + this.content + this.outro;
}
trimEnd(e) {
if (this.outro = this.outro.replace(e, ""), this.outro.length) return !0;
const n = this.content.replace(e, "");
if (n.length)
return n !== this.content && (this.split(this.start + n.length).edit("", void 0, !0), this.edited && this.edit(n, this.storeName, !0)), !0;
if (this.edit("", void 0, !0), this.intro = this.intro.replace(e, ""), this.intro.length) return !0;
}
trimStart(e) {
if (this.intro = this.intro.replace(e, ""), this.intro.length) return !0;
const n = this.content.replace(e, "");
if (n.length) {
if (n !== this.content) {
const r = this.split(this.end - n.length);
this.edited && r.edit(n, this.storeName, !0), this.edit("", void 0, !0);
}
return !0;
} else if (this.edit("", void 0, !0), this.outro = this.outro.replace(e, ""), this.outro.length) return !0;
}
}
function Rn() {
return typeof globalThis < "u" && typeof globalThis.btoa == "function" ? (t) => globalThis.btoa(unescape(encodeURIComponent(t))) : typeof Buffer == "function" ? (t) => Buffer.from(t, "utf-8").toString("base64") : () => {
throw new Error("Unsupported environment: `window.btoa` or `Buffer` should be supported.");
};
}
const Mn = /* @__PURE__ */ Rn();
class jn {
constructor(e) {
this.version = 3, this.file = e.file, this.sources = e.sources, this.sourcesContent = e.sourcesContent, this.names = e.names, this.mappings = On(e.mappings), typeof e.x_google_ignoreList < "u" && (this.x_google_ignoreList = e.x_google_ignoreList), typeof e.debugId < "u" && (this.debugId = e.debugId);
}
toString() {
return JSON.stringify(this);
}
toUrl() {
return "data:application/json;charset=utf-8;base64," + Mn(this.toString());
}
}
function $n(t) {
const e = t.split(`
`), n = e.filter((s) => /^\t+/.test(s)), r = e.filter((s) => /^ {2,}/.test(s));
if (n.length === 0 && r.length === 0)
return null;
if (n.length >= r.length)
return " ";
const i = r.reduce((s, a) => {
const l = /^ +/.exec(a)[0].length;
return Math.min(l, s);
}, 1 / 0);
return new Array(i + 1).join(" ");
}
function Un(t, e) {
const n = t.split(/[/\\]/), r = e.split(/[/\\]/);
for (n.pop(); n[0] === r[0]; )
n.shift(), r.shift();
if (n.length) {
let i = n.length;
for (; i--; ) n[i] = "..";
}
return n.concat(r).join("/");
}
const qn = Object.prototype.toString;
function Bn(t) {
return qn.call(t) === "[object Object]";
}
function Et(t) {
const e = t.split(`
`), n = [];
for (let r = 0, i = 0; r < e.length; r++)
n.push(i), i += e[r].length + 1;
return function(i) {
let s = 0, a = n.length;
for (; s < a; ) {
const o = s + a >> 1;
i < n[o] ? a = o : s = o + 1;
}
const l = s - 1, c = i - n[l];
return { line: l, column: c };
};
}
const Fn = /\w/;
class An {
constructor(e) {
this.hires = e, this.generatedCodeLine = 0, this.generatedCodeColumn = 0, this.raw = [], this.rawSegments = this.raw[this.generatedCodeLine] = [], this.pending = null;
}
addEdit(e, n, r, i) {
if (n.length) {
const s = n.length - 1;
let a = n.indexOf(`
`, 0), l = -1;
for (; a >= 0 && s > a; ) {
const o = [this.generatedCodeColumn, e, r.line, r.column];
i >= 0 && o.push(i), this.rawSegments.push(o), this.generatedCodeLine += 1, this.raw[this.generatedCodeLine] = this.rawSegments = [], this.generatedCodeColumn = 0, l = a, a = n.indexOf(`
`, a + 1);
}
const c = [this.generatedCodeColumn, e, r.line, r.column];
i >= 0 && c.push(i), this.rawSegments.push(c), this.advance(n.slice(l + 1));
} else this.pending && (this.rawSegments.push(this.pending), this.advance(n));
this.pending = null;
}
addUneditedChunk(e, n, r, i, s) {
let a = n.start, l = !0, c = !1;
for (; a < n.end; ) {
if (r[a] === `
`)
i.line += 1, i.column = 0, this.generatedCodeLine += 1, this.raw[this.generatedCodeLine] = this.rawSegments = [], this.generatedCodeColumn = 0, l = !0, c = !1;
else {
if (this.hires || l || s.has(a)) {
const o = [this.generatedCodeColumn, e, i.line, i.column];
this.hires === "boundary" ? Fn.test(r[a]) ? c || (this.rawSegments.push(o), c = !0) : (this.rawSegments.push(o), c = !1) : this.rawSegments.push(o);
}
i.column += 1, this.generatedCodeColumn += 1, l = !1;
}
a += 1;
}
this.pending = null;
}
advance(e) {
if (!e) return;
const n = e.split(`
`);
if (n.length > 1) {
for (let r = 0; r < n.length - 1; r++)
this.generatedCodeLine++, this.raw[this.generatedCodeLine] = this.rawSegments = [];
this.generatedCodeColumn = 0;
}
this.generatedCodeColumn += n[n.length - 1].length;
}
}
const xe = `
`, me = {
insertLeft: !1,
insertRight: !1,
storeName: !1
};
class lt {
constructor(e, n = {}) {
const r = new Be(0, e.length, e);
Object.defineProperties(this, {
original: { writable: !0, value: e },
outro: { writable: !0, value: "" },
intro: { writable: !0, value: "" },
firstChunk: { writable: !0, value: r },
lastChunk: { writable: !0, value: r },
lastSearchedChunk: { writable: !0, value: r },
byStart: { writable: !0, value: {} },
byEnd: { writable: !0, value: {} },
filename: { writable: !0, value: n.filename },
indentExclusionRanges: { writable: !0, value: n.indentExclusionRanges },
sourcemapLocations: { writable: !0, value: new Ke() },
storedNames: { writable: !0, value: {} },
indentStr: { writable: !0, value: void 0 },
ignoreList: { writable: !0, value: n.ignoreList },
offset: { writable: !0, value: n.offset || 0 }
}), this.byStart[0] = r, this.byEnd[e.length] = r;
}
addSourcemapLocation(e) {
this.sourcemapLocations.add(e);
}
append(e) {
if (typeof e != "string") throw new TypeError("outro content must be a string");
return this.outro += e, this;
}
appendLeft(e, n) {
if (e = e + this.offset, typeof n != "string") throw new TypeError("inserted content must be a string");
this._split(e);
const r = this.byEnd[e];
return r ? r.appendLeft(n) : this.intro += n, this;
}
appendRight(e, n) {
if (e = e + this.offset, typeof n != "string") throw new TypeError("inserted content must be a string");
this._split(e);
const r = this.byStart[e];
return r ? r.appendRight(n) : this.outro += n, this;
}
clone() {
const e = new lt(this.original, { filename: this.filename, offset: this.offset });
let n = this.firstChunk, r = e.firstChunk = e.lastSearchedChunk = n.clone();
for (; n; ) {
e.byStart[r.start] = r, e.byEnd[r.end] = r;
const i = n.next, s = i && i.clone();
s && (r.next = s, s.previous = r, r = s), n = i;
}
return e.lastChunk = r, this.indentExclusionRanges && (e.indentExclusionRanges = this.indentExclusionRanges.slice()), e.sourcemapLocations = new Ke(this.sourcemapLocations), e.intro = this.intro, e.outro = this.outro, e;
}
generateDecodedMap(e) {
e = e || {};
const n = 0, r = Object.keys(this.storedNames), i = new An(e.hires), s = Et(this.original);
return this.intro && i.advance(this.intro), this.firstChunk.eachNext((a) => {
const l = s(a.start);
a.intro.length && i.advance(a.intro), a.edited ? i.addEdit(
n,
a.content,
l,
a.storeName ? r.indexOf(a.original) : -1
) : i.addUneditedChunk(n, a, this.original, l, this.sourcemapLocations), a.outro.length && i.advance(a.outro);
}), this.outro && i.advance(this.outro), {
file: e.file ? e.file.split(/[/\\]/).pop() : void 0,
sources: [
e.source ? Un(e.file || "", e.source) : e.file || ""
],
sourcesContent: e.includeContent ? [this.original] : void 0,
names: r,
mappings: i.raw,
x_google_ignoreList: this.ignoreList ? [n] : void 0
};
}
generateMap(e) {
return new jn(this.generateDecodedMap(e));
}
_ensureindentStr() {
this.indentStr === void 0 && (this.indentStr = $n(this.original));
}
_getRawIndentString() {
return this._ensureindentStr(), this.indentStr;
}
getIndentString() {
return this._ensureindentStr(), this.indentStr === null ? " " : this.indentStr;
}
indent(e, n) {
const r = /^[^\r\n]/gm;
if (Bn(e) && (n = e, e = void 0), e === void 0 && (this._ensureindentStr(), e = this.indentStr || " "), e === "") return this;
n = n || {};
const i = {};
n.exclude && (typeof n.exclude[0] == "number" ? [n.exclude] : n.exclude).forEach((g) => {
for (let m = g[0]; m < g[1]; m += 1)
i[m] = !0;
});
let s = n.indentStart !== !1;
const a = (o) => s ? `${e}${o}` : (s = !0, o);
this.intro = this.intro.replace(r, a);
let l = 0, c = this.firstChunk;
for (; c; ) {
const o = c.end;
if (c.edited)
i[l] || (c.content = c.content.replace(r, a), c.content.length && (s = c.content[c.content.length - 1] === `
`));
else
for (l = c.start; l < o; ) {
if (!i[l]) {
const g = this.original[l];
g === `
` ? s = !0 : g !== "\r" && s && (s = !1, l === c.start || (this._splitChunk(c, l), c = c.next), c.prependRight(e));
}
l += 1;
}
l = c.end, c = c.next;
}
return this.outro = this.outro.replace(r, a), this;
}
insert() {
throw new Error(
"magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)"
);
}
insertLeft(e, n) {
return me.insertLeft || (console.warn(
"magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead"
), me.insertLeft = !0), this.appendLeft(e, n);
}
insertRight(e, n) {
return me.insertRight || (console.warn(
"magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead"
), me.insertRight = !0), this.prependRight(e, n);
}
move(e, n, r) {
if (e = e + this.offset, n = n + this.offset, r = r + this.offset, r >= e && r <= n) throw new Error("Cannot move a selection inside itself");
this._split(e), this._split(n), this._split(r);
const i = this.byStart[e], s = this.byEnd[n], a = i.previous, l = s.next, c = this.byStart[r];
if (!c && s === this.lastChunk) return this;
const o = c ? c.previous : this.lastChunk;
return a && (a.next = l), l && (l.previous = a), o && (o.next = i), c && (c.previous = s), i.previous || (this.firstChunk = s.next), s.next || (this.lastChunk = i.previous, this.lastChunk.next = null), i.previous = o, s.next = c || null, o || (this.firstChunk = i), c || (this.lastChunk = s), this;
}
overwrite(e, n, r, i) {
return i = i || {}, this.update(e, n, r, { ...i, overwrite: !i.contentOnly });
}
update(e, n, r, i) {
if (e = e + this.offset, n = n + this.offset, typeof r != "string") throw new TypeError("replacement content must be a string");
if (this.original.length !== 0) {
for (; e < 0; ) e += this.original.length;
for (; n < 0; ) n += this.original.length;
}
if (n > this.original.length) throw new Error("end is out of bounds");
if (e === n)
throw new Error(
"Cannot overwrite a zero-length range – use appendLeft or prependRight instead"
);
this._split(e), this._split(n), i === !0 && (me.storeName || (console.warn(
"The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string"
), me.storeName = !0), i = { storeName: !0 });
const s = i !== void 0 ? i.storeName : !1, a = i !== void 0 ? i.overwrite : !1;
if (s) {
const o = this.original.slice(e, n);
Object.defineProperty(this.storedNames, o, {
writable: !0,
value: !0,
enumerable: !0
});
}
const l = this.byStart[e], c = this.byEnd[n];
if (l) {
let o = l;
for (; o !== c; ) {
if (o.next !== this.byStart[o.end])
throw new Error("Cannot overwrite across a split point");
o = o.next, o.edit("", !1);
}
l.edit(r, s, !a);
} else {
const o = new Be(e, n, "").edit(r, s);
c.next = o, o.previous = c;
}
return this;
}
prepend(e) {
if (typeof e != "string") throw new TypeError("outro content must be a string");
return this.intro = e + this.intro, this;
}
prependLeft(e, n) {
if (e = e + this.offset, typeof n != "string") throw new TypeError("inserted content must be a string");
this._split(e);
const r = this.byEnd[e];
return r ? r.prependLeft(n) : this.intro = n + this.intro, this;
}
prependRight(e, n) {
if (e = e + this.offset, typeof n != "string") throw new TypeError("inserted content must be a string");
this._split(e);
const r = this.byStart[e];
return r ? r.prependRight(n) : this.outro = n + this.outro, this;
}
remove(e, n) {
if (e = e + this.offset, n = n + this.offset, this.original.length !== 0) {
for (; e < 0; ) e += this.original.length;
for (; n < 0; ) n += this.original.length;
}
if (e === n) return this;
if (e < 0 || n > this.original.length) throw new Error("Character is out of bounds");
if (e > n) throw new Error("end must be greater than start");
this._split(e), this._split(n);
let r = this.byStart[e];
for (; r; )
r.intro = "", r.outro = "", r.edit(""), r = n > r.end ? this.byStart[r.end] : null;
return this;
}
reset(e, n) {
if (e = e + this.offset, n = n + this.offset, this.original.length !== 0) {
for (; e < 0; ) e += this.original.length;
for (; n < 0; ) n += this.original.length;
}
if (e === n) return this;
if (e < 0 || n > this.original.length) throw new Error("Character is out of bounds");
if (e > n) throw new Error("end must be greater than start");
this._split(e), this._split(n);
let r = this.byStart[e];
for (; r; )
r.reset(), r = n > r.end ? this.byStart[r.end] : null;
return this;
}
lastChar() {
if (this.outro.length) return this.outro[this.outro.length - 1];
let e = this.lastChunk;
do {
if (e.outro.length) return e.outro[e.outro.length - 1];
if (e.content.length) return e.content[e.content.length - 1];
if (e.intro.length) return e.intro[e.intro.length - 1];
} while (e = e.previous);
return this.intro.length ? this.intro[this.intro.length - 1] : "";
}
lastLine() {
let e = this.outro.lastIndexOf(xe);
if (e !== -1) return this.outro.substr(e + 1);
let n = this.outro, r = this.lastChunk;
do {
if (r.outro.length > 0) {
if (e = r.outro.lastIndexOf(xe), e !== -1) return r.outro.substr(e + 1) + n;
n = r.outro + n;
}
if (r.content.length > 0) {
if (e = r.content.lastIndexOf(xe), e !== -1) return r.content.substr(e + 1) + n;
n = r.content + n;
}
if (r.intro.length > 0) {
if (e = r.intro.lastIndexOf(xe), e !== -1) return r.intro.substr(e + 1) + n;
n = r.intro + n;
}
} while (r = r.previous);
return e = this.intro.lastIndexOf(xe), e !== -1 ? this.intro.substr(e + 1) + n : this.intro + n;
}
slice(e = 0, n = this.original.length - this.offset) {
if (e = e + this.offset, n = n + this.offset, this.original.length !== 0) {
for (; e < 0; ) e += this.original.length;
for (; n < 0; ) n += this.original.length;
}
let r = "", i = this.firstChunk;
for (; i && (i.start > e || i.end <= e); ) {
if (i.start < n && i.end >= n)
return r;
i = i.next;
}
if (i && i.edited && i.start !== e)
throw new Error(`Cannot use replaced character ${e} as slice start anchor.`);
const s = i;
for (; i; ) {
i.intro && (s !== i || i.start === e) && (r += i.intro);
const a = i.start < n && i.end >= n;
if (a && i.edited && i.end !== n)
throw new Error(`Cannot use replaced character ${n} as slice end anchor.`);
const l = s === i ? e - i.start : 0, c = a ? i.content.length + n - i.end : i.content.length;
if (r += i.content.slice(l, c), i.outro && (!a || i.end === n) && (r += i.outro), a)
break;
i = i.next;
}
return r;
}
// TODO deprecate this? not really very useful
snip(e, n) {
const r = this.clone();
return r.remove(0, e), r.remove(n, r.original.length), r;
}
_split(e) {
if (this.byStart[e] || this.byEnd[e]) return;
let n = this.lastSearchedChunk, r = n;
const i = e > n.end;
for (; n; ) {
if (n.contains(e)) return this._splitChunk(n, e);
if (n = i ? this.byStart[n.end] : this.byEnd[n.start], n === r) return;
r = n;
}
}
_splitChunk(e, n) {
if (e.edited && e.content.length) {
const i = Et(this.original)(n);
throw new Error(
`Cannot split a chunk that has already been edited (${i.line}:${i.column} – "${e.original}")`
);
}
const r = e.split(n);
return this.byEnd[n] = e, this.byStart[n] = r, this.byEnd[r.end] = r, e === this.lastChunk && (this.lastChunk = r), this.lastSearchedChunk = e, !0;
}
toString() {
let e = this.intro, n = this.firstChunk;
for (; n; )
e += n.toString(), n = n.next;
return e + this.outro;
}
isEmpty() {
let e = this.firstChunk;
do
if (e.intro.length && e.intro.trim() || e.content.length && e.content.trim() || e.outro.length && e.outro.trim())
return !1;
while (e = e.next);
return !0;
}
length() {
let e = this.firstChunk, n = 0;
do
n += e.intro.length + e.content.length + e.outro.length;
while (e = e.next);
return n;
}
trimLines() {
return this.trim("[\\r\\n]");
}
trim(e) {
return this.trimStart(e).trimEnd(e);
}
trimEndAborted(e) {
const n = new RegExp((e || "\\s") + "+$");
if (this.outro = this.outro.replace(n, ""), this.outro.length) return !0;
let r = this.lastChunk;
do {
const i = r.end, s = r.trimEnd(n);
if (r.end !== i && (this.lastChunk === r && (this.lastChunk = r.next), this.byEnd[r.end] = r, this.byStart[r.next.start] = r.next, this.byEnd[r.next.end] = r.next), s) return !0;
r = r.previous;
} while (r);
return !1;
}
trimEnd(e) {
return this.trimEndAborted(e), this;
}
trimStartAborted(e) {
const n = new RegExp("^" + (e || "\\s") + "+");
if (this.intro = this.intro.replace(n, ""), this.intro.length) return !0;
let r = this.firstChunk;
do {
const i = r.end, s = r.trimStart(n);
if (r.end !== i && (r === this.lastChunk && (this.lastChunk = r.next), this.byEnd[r.end] = r, this.byStart[r.next.start] = r.next, this.byEnd[r.next.end] = r.next), s) return !0;
r = r.next;
} while (r);
return !1;
}
trimStart(e) {
return this.trimStartAborted(e), this;
}
hasChanged() {
return this.original !== this.toString();
}
_replaceRegexp(e, n) {
function r(s, a) {
return typeof n == "string" ? n.replace(/\$(\$|&|\d+)/g, (l, c) => c === "$" ? "$" : c === "&" ? s[0] : +c < s.length ? s[+c] : `$${c}`) : n(...s, s.index, a, s.groups);
}
function i(s, a) {
let l;
const c = [];
for (; l = s.exec(a); )
c.push(l);
return c;
}
if (e.global)
i(e, this.original).forEach((a) => {
if (a.index != null) {
const l = r(a, this.original);
l !== a[0] && this.overwrite(a.index, a.index + a[0].length, l);
}
});
else {
const s = this.original.match(e);
if (s && s.index != null) {
const a = r(s, this.original);
a !== s[0] && this.overwrite(s.index, s.index + s[0].length, a);
}
}
return this;
}
_replaceString(e, n) {
const { original: r } = this, i = r.indexOf(e);
return i !== -1 && (typeof n == "function" && (n = n(e, i, r)), e !== n && this.overwrite(i, i + e.length, n)), this;
}
replace(e, n) {
return typeof e == "string" ? this._replaceString(e, n) : this._replaceRegexp(e, n);
}
_replaceAllString(e, n) {
const { original: r } = this, i = e.length;
for (let s = r.indexOf(e); s !== -1; s = r.indexOf(e, s + i)) {
const a = r.slice(s, s + i);
let l = n;
typeof n == "function" && (l = n(a, s, r)), a !== l && this.overwrite(s, s + i, l);
}
return this;
}
replaceAll(e, n) {
if (typeof e == "string")
return this._replaceAllString(e, n);
if (!e.global)
throw new TypeError(
"MagicString.prototype.replaceAll called with a non-global RegExp argument"
);
return this._replaceRegexp(e, n);
}
}
const zn = "__QWIK_WORKER_QRL__", Wn = `${zn}:`, rt = "__QWIK_WORKER_CORE__", Hn = new RegExp(`${Wn}([^"'\\\`\\s]+)`, "g"), it = (t, e) => `${t.endsWith("/") ? t : `${t}/`}${e}`.replace(/\/{2,}/g, "/"), Qt = (t) => {
const e = t.replace(/\/+$/, ""), n = e.lastIndexOf("/");
return n === -1 ? "." : n === 0 ? "/" : e.slice(0, n);
}, Gn = (t, e) => {
const n = e.replace(/^\.\//, "");
return n === "build" || n.startsWith("build/") || !n.startsWith("../") && /^[^./][^?]*\/build\//.test(n) ? it(t, n) : new URL(n, `https://qwik.dev${it(t, "build/")}`).pathname;
}, Qn = (t, e) => {
const n = /* @__PURE__ */ new Map();
for (const [r, i] of Object.entries(t.symbols)) {
const s = t.mapping[r];
s && n.set(
i.canonicalFilename,
e(s)
);
}
return (r) => n.get(
r.replace(/^\.\//, "").replace(/\.[^./?]+(?:\?.*)?$/, "")
);
}, Kt = (t, e) => t.replace(Hn, (n, r) => e(r) ?? n), Kn = (t, e) => Qn(
t,
(n) => Gn(e, n)
), Jn = (t) => {
const e = t.replace(/\\/g, "/"), n = Qt(e);
return (r) => {
const [, i = "", s = ""] = /^([^?#]*)(.*)$/.exec(r) ?? [], a = i.replace(/^\.\//, "").replace(/\.[^./?]+(?:\?.*)?$/, ""), l = it(n, `${a}.js`);
return s.startsWith("?") ? `${l}?worker_file&type=module&${s.slice(1)}` : s.startsWith("#") ? `${l}?worker_file&type=module${s}` : `${l}?worker_file&type=module`;
};
}, Yn = (t) => t.startsWith(".") ? t : `./${t}`, St = (t) => {
const e = [];
for (const n of t.replace(/\\/g, "/").split("/"))
!n || n === "." || (n === ".." && e.length > 0 && e[e.length - 1] !== ".." ? e.pop() : e.push(n));
return e;
}, Xn = (t, e) => {
const n = t === "." ? [] : St(t), r = St(e);
let i = 0;
for (; i < n.length && i < r.length && n[i] === r[i]; )
i++;
return [...n.slice(i).map(() => ".."), ...r.slice(i)].join("/");
}, Jt = (t) => (e) => {
const n = Xn(Qt(e), t);
return Yn(n);
}, It = (t, e) => {
if (!t.includes(rt))
return t;
const n = e();
return n ? t.replaceAll(rt, n) : t;
}, Zn = ["server"], Vn = [
"onGet",
"onPost",
"onPut",
"onRequest",
"onDelete",
"onHead",
"onOptions",
"onPatch",
"onStaticGenerate"
], er = [
"useServer",
"route",
"server",
"action$",
"loader$",
"zod$",
"validator$",
"globalAction$"
], tr = [
"useClient",
"useBrowser",
"useVisibleTask",
"client",
"browser",
"event$"
];
var Yt = /* @__PURE__ */ ((t) => (t.each = "each", t.suspense = "suspense", t.valibot = "valibot", t.noSPA = "noSPA", t.insights = "insights", t))(Yt || {});
function Xt(t = {}) {
const e = `${Math.round(Math.random() * 899) + 100}`, n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
let a = null, l, c = () => {
};
const o = {
csr: !1,
target: "client",
buildMode: "development",
debug: !1,
rootDir: void 0,
tsconfigFileNames: ["./tsconfig.json"],
input: void 0,
outDir: void 0,
assetsDir: void 0,
resolveQwikBuild: !0,
entryStrategy: void 0,
srcDir: void 0,
ssrOutDir: void 0,
clientOutDir: void 0,
sourcemap: !!t.sourcemap,
manifestInput: null,
manifestInputPath: null,
manifestOutput: null,
transformedModuleOutput: null,
scope: null,
devTools: {
imageDevTools: !0,
clickToSource: ["Alt"],
hmr: !0
},
inlineStylesUpToBytes: 2e4,
lint: !1,
experimental: void 0
};
let g, m;
const b = async () => {
if (!a) {
const y = (t._optimizer || await import("@qwik.dev/optimizer")).createOptimizer;
if (a = await y(t), g = nr(a.sys), a.sys.env !== "browsermain" && a.sys.env !== "webworker")
try {
m === void 0 && (m = await a.sys.dynamicImport("node:fs"));
} catch {
console.log("node:fs not available, disabling automatic manifest reading"), m = null;
}
}
}, h = () => {
if (!a)
throw new Error("Qwik plugin has not been initialized");
return a;
}, d = () => h().sys, f = () => h().sys.path;
let u;
const w = (y) => {
u = y;
}, T = async (y) => {
const p = Object.assign({}, y), E = h(), P = E.sys.path, C = (...D) => A(P.resolve(...D));
o.debug = !!p.debug, p.devTools && (o.devTools = {
...o.devTools,
...p.devTools
}), p.assetsDir && (o.assetsDir = p.assetsDir), p.target === "ssr" || p.target === "client" || p.target === "lib" || p.target === "test" ? o.target = p.target : o.target ||= "client", o.target === "lib" ? o.buildMode = "development" : p.buildMode === "production" || p.buildMode === "development" ? o.buildMode = p.buildMode : o.buildMode ||= "development", o.csr = !!p.csr, p.entryStrategy && typeof p.entryStrategy == "object" && (o.entryStrategy = { ...p.entryStrategy }), o.entryStrategy || (o.target === "ssr" || o.target === "test" ? o.entryStrategy = { type: "hoist" } : o.target === "lib" ? o.entryStrategy = { type: "inline" } : o.buildMode === "production" ? o.entryStrategy = { type: "smart" } : o.entryStrategy = { type: "segment" }), typeof p.rootDir == "string" && (o.rootDir = p.rootDir), typeof o.rootDir != "string" && (o.rootDir ||= E.sys.cwd()), o.rootDir = C(E.sys.cwd(), o.rootDir);
let S = C(o.rootDir, sr);
if (typeof p.srcDir == "string" ? (o.srcDir = C(o.rootDir, p.srcDir), S = o.srcDir) : o.srcDir ||= S, o.srcDir = C(o.rootDir, o.srcDir), Array.isArray(p.tsconfigFileNames) && p.tsconfigFileNames.length > 0 && (o.tsconfigFileNames = p.tsconfigFileNames), !o.csr && !p.input && !o.input && (o.target === "ssr" ? o.input = [C(S, "entry.ssr")] : o.target === "client" ? o.input = [C(S, "root")] : o.input = void 0), p.outDir && (o.outDir = C(o.rootDir, p.outDir)), o.clientOutDir = C(o.rootDir, p.clientOutDir || _t), o.ssrOutDir = C(o.rootDir, p.ssrOutDir || ar), o.target === "ssr" ? o.outDir ||= o.ssrOutDir : o.target === "lib" ? o.outDir ||= C(o.rootDir, lr) : o.outDir ||= o.clientOutDir, typeof p.manifestOutput == "function" && (o.manifestOutput = p.manifestOutput), p.manifestInput && (o.manifestInput = pt(p.manifestInput) || null), typeof p.transformedModuleOutput == "function" && (o.transformedModuleOutput = p.transformedModuleOutput), p.scope !== void 0)
o.scope = p.scope;
else if (!o.scope && m) {
let D = "";
try {
let U = o.rootDir;
for (; D = P.resolve(U, "package.json"), !await m.promises.stat(D).catch(() => !1); ) {
const L = P.resolve(U, "..");
if (L === U)
break;
U = L, D = "";
}
if (D) {
const L = await m.promises.readFile(D, "utf-8"), N = JSON.parse(L);
typeof N.name == "string" && (o.scope = N.name);
}
} catch (U) {
console.warn(
`could not read ${D || "package.json"} to determine package name, ignoring. (${U})`
);
}
}
if (typeof p.resolveQwikBuild == "boolean" && (o.resolveQwikBuild = p.resolveQwikBuild), typeof p.devTools == "object" && ("imageDevTools" in p.devTools && (o.devTools.imageDevTools = p.devTools.imageDevTools), "clickToSource" in p.devTools && (o.devTools.clickToSource = p.devTools.clickToSource)), "inlineStylesUpToBytes" in t && (typeof t.inlineStylesUpToBytes == "number" ? o.inlineStylesUpToBytes = t.inlineStylesUpToBytes : (typeof o.inlineStylesUpToBytes != "number" || o.inlineStylesUpToBytes < 0) && (o.inlineStylesUpToBytes = 0)), typeof p.lint == "boolean" && (o.lint = p.lint), "experimental" in p) {
o.experimental = void 0;
for (const D of p.experimental ?? [])
Yt[D] ? (o.experimental ||= {})[D] = !0 : console.error(`Qwik plugin: Unknown experimental feature: ${D}`);
}
const q = { ...o };
return o.input ||= p.input, o.input && typeof o.input == "string" && (o.input = [o.input]), q;
};
let Y = !1;
const j = async (y) => {
if (!Y) {
Y = !0;
const p = d();
if (p.env === "node") {
const E = await p.dynamicImport("node:fs");
if (!E.existsSync(o.rootDir))
throw new Error(`Qwik rootDir "${o.rootDir}" not found.`);
if (typeof o.srcDir == "string" && !E.existsSync(o.srcDir))
throw new Error(`Qwik srcDir "${o.srcDir}" not found.`);
for (const [P, C] of Object.entries(o.input || {}))
if (!await y(C))
throw new Error(`Qwik input "${C}" not found.`);
}
}
};
let I, v = !1;
const k = async (y) => {
if (M("buildStart()", o.buildMode, o.scope, o.target, o.rootDir, o.srcDir), I = h(), v = !u, I.sys.env === "node" && o.target === "ssr" && o.lint)
try {
l = await xn(I.sys, o.rootDir, o.tsconfigFileNames);
} catch {
}
if (M("transformedOutputs.clear()"), r.clear(), i.clear(), o.target === "client" && !u) {
const p = await y.resolve("@qwik.dev/core/qwikloader.js", void 0, {
skipSelf: !0
});
p && y.emitFile({
id: p.id,
type: "chunk",
preserveSignature: "allow-extension"
});
}
}, x = (y, p) => y.environment ? y.environment.config.consumer === "server" : u ? !!p?.ssr : o.target === "ssr" || o.target === "test";
let $ = 0, _ = !1;
const O = async (y, p, E, P) => {
if (ae(p))
return;
const C = u && /^(.*)\?editor(:(\d+)(:\d+)?)?$/.exec(p);
if (C) {
if (!_) {
_ = !0, setTimeout(() => _ = !1, 500);
const [, B, W] = C, ue = await y.resolve(B, E);
if (ue) {
const ne = y.environment.moduleGraph.getModuleById(ue.id)?.file;
if (ne) {
const re = `${ne}${W}`;
try {
console.warn(`Opening in editor: ${re}`);
const he = (await import("launch-editor")).default;
he(re);
} catch (he) {
console.error(`Failed to open editor: ${he.message}`);
}
}
}
}
return { id: "\0editor" };
}
const S = $++, q = x(y, P);
M(`resolveId(${S})`, `begin ${p} | ${q ? "server" : "client"} | ${E}`);