PageSourceSearch

https://deepsearch.com/support.js

js deepsearch.com collected 2026-10-04 16:27:48 UTC 66,457 bytes, 1,841 lines download raw bytes

1// GENERATED from dc-runtime/src/*.ts — do not edit. Rebuild with `cd dc-runtime && bun run build`.
2"use strict";
3(() => {
4  var __defProp = Object.defineProperty;
5  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
7
8  
8// src/react.ts
9  function getReact() {
10    const R = window.React;
11    if (!R) throw new Error("dc-runtime: window.React is not available yet");
12    return R;
13  }
14  function getReactDOM() {
15    const RD = window.ReactDOM;
16    if (!RD) throw new Error("dc-runtime: window.ReactDOM is not available yet");
17    return RD;
18  }
19  var h = ((...args) => getReact().createElement(
20    ...args
21  ));
22
23  
23// src/parse.ts
24  function parseDcDocument(doc) {
25    const dc = doc.querySelector("x-dc");
26    if (!dc) return null;
27    const scriptEl = doc.querySelector("script[data-dc-script]");
28    const { props, preview } = parseDataProps(
29      scriptEl?.getAttribute("data-props") ?? null
30    );
31    return {
32      template: dc.innerHTML,
33      js: scriptEl ? scriptEl.textContent || "" : "",
34      props,
35      preview
36    };
37  }
38  function parseDcText(src) {
39    const openMatch = /<x-dc(?:\s[^>]*)?>/.exec(src);
40    if (!openMatch) return null;
41    const close = src.lastIndexOf("</x-dc>");
42    if (close === -1 || close < openMatch.index) return null;
43    const template = src.slice(openMatch.index + openMatch[0].length, close);
44    const doc = new DOMParser().parseFromString(src, "text/html");
45    const scriptEl = doc.querySelector("script[data-dc-script]");
46    const { props, preview } = parseDataProps(
47      scriptEl?.getAttribute("data-props") ?? null
48    );
49    return {
50      template,
51      js: scriptEl ? scriptEl.textContent || "" : "",
52      props,
53      preview
54    };
55  }
56  function parseDataProps(raw) {
57    if (!raw) return { props: null, preview: null };
58    let parsed;
59    try {
60      parsed = JSON.parse(raw);
61    } catch {
62      return { props: null, preview: null };
63    }
64    if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
65      return { props: null, preview: null };
66    }
67    const obj = parsed;
68    const preview = obj.$preview && typeof obj.$preview === "object" ? obj.$preview : null;
69    const rest = {};
70    for (const k of Object.keys(obj)) {
71      if (k[0] !== "$") rest[k] = obj[k];
72    }
73    return { props: Object.keys(rest).length ? rest : null, preview };
74  }
75  function dcNameFromPath(pathname) {
76    let p = pathname || "";
77    try {
78      p = decodeURIComponent(p);
79    } catch {
80    }
81    const base = p.split("/").pop() || "Root";
82    return base.replace(/\.dc\.html$/, "").replace(/\.html?$/, "") || "Root";
83  }
84
85  
85// src/boot.ts
86  var BASE_CSS = `
87    .sc-placeholder{background:color-mix(in srgb,currentColor 8%,transparent);
88      border:1px solid color-mix(in srgb,currentColor 50%,transparent);
89      border-radius:2px;box-sizing:border-box;overflow:hidden}
90    @keyframes sc-shine{0%{background-position:100% 50%}100%{background-position:0% 50%}}
91    html.sc-dc-streaming .sc-placeholder,
92    html.sc-dc-streaming .sc-interp.sc-missing{position:relative;
93      background:color-mix(in srgb,currentColor 5%,transparent);
94      border-color:transparent}
95    html.sc-dc-streaming .sc-placeholder::before,
96    html.sc-dc-streaming .sc-interp.sc-missing::before{content:'';
97      position:absolute;inset:0;pointer-events:none;
98      background:linear-gradient(90deg,rgba(217,119,87,0) 25%,rgba(247,225,211,.95) 37%,rgba(217,119,87,0) 63%);
99      background-size:400% 100%;animation:sc-shine 1.4s ease infinite}
100    html.sc-dc-streaming .sc-placeholder:nth-child(n+9 of .sc-placeholder)::before,
101    html.sc-dc-streaming .sc-interp.sc-missing:nth-child(n+9 of .sc-interp.sc-missing)::before{animation:none;
102      background:color-mix(in srgb,currentColor 8%,transparent)}
103    .sc-placeholder-error{padding:4px 8px;font:11px/1.4 ui-monospace,monospace;
104      color:color-mix(in srgb,currentColor 70%,transparent);word-break:break-word}
105    .sc-interp.sc-missing{display:inline-block;width:2em;height:1em;overflow:hidden;
106      vertical-align:text-bottom;background:rgba(255,255,255,.3);border:1px solid rgba(0,0,0,.5);
107      border-radius:2px;box-sizing:border-box;color:transparent;
108      user-select:none}
109    .sc-interp.sc-unresolved{font-family:ui-monospace,monospace;font-size:.85em;
110      color:color-mix(in srgb,currentColor 50%,transparent);
111      background:color-mix(in srgb,currentColor 10%,transparent);border-radius:3px;
112      padding:0 3px}
113    .sc-host.sc-has-error{position:relative}
114    .sc-logic-error{position:absolute;top:8px;left:8px;z-index:2147483647;max-width:60ch;
115      padding:6px 10px;background:#b00020;color:#fff;font:12px/1.4 ui-monospace,monospace;
116      border-radius:4px;white-space:pre-wrap;pointer-events:none}
117    /* Mirrors PRINT_BASELINE_CSS in apps/web deck-stage-export.ts \u2014 keep both
118       in sync until dc-runtime regains a build step. */
119    @media print {
120      @page { margin: 0.5cm; }
121      figure, table { break-inside: avoid; }
122      #dc-root, #dc-root > .sc-host { height: auto; }
123      *, *::before, *::after {
124        print-color-adjust: exact; -webkit-print-color-adjust: exact;
125        backdrop-filter: none !important; -webkit-backdrop-filter: none !important;
126        animation-delay: -99s !important; animation-duration: .001s !important;
127        animation-iteration-count: 1 !important; animation-fill-mode: both !important;
128        animation-play-state: running !important; transition-duration: 0s !important;
129      }
130    }
131  `;
132  var FULL_PAGE_CSS = "html,body{height:100%;margin:0}#dc-root,#dc-root>.sc-host{height:100%}";
133  function rootNameForDocument(doc, loc) {
134    let bootPath = loc.pathname || "";
135    if (!/\.dc\.html?$/i.test(safeDecode(bootPath))) {
136      try {
137        bootPath = new URL(doc.baseURI || "/").pathname;
138      } catch {
139      }
140    }
141    return dcNameFromPath(bootPath);
142  }
143  function safeDecode(s) {
144    try {
145      return decodeURIComponent(s);
146    } catch {
147      return s;
148    }
149  }
150  function boot(runtime, doc = document) {
151    const parsed = parseDcDocument(doc);
152    if (!parsed) return null;
153    const React = getReact();
154    const rootName = rootNameForDocument(doc, location);
155    runtime.markFetched(rootName);
156    runtime.setRootName(rootName);
157    runtime.adoptParsed(rootName, parsed);
158    if (!window.__resources) {
159      fetch(location.href).then((res) => res.ok ? res.text() : "").then((t) => {
160        const raw = t ? parseDcText(t) : null;
161        if (raw?.template) runtime.updateHtml(rootName, raw.template);
162      }).catch(() => {
163      });
164    }
165    const dc = doc.querySelector("x-dc");
166    const hostEl = doc.createElement("div");
167    hostEl.id = "dc-root";
168    dc.replaceWith(hostEl);
169    if (!parsed.preview) {
170      const s = doc.createElement("style");
171      s.textContent = FULL_PAGE_CSS;
172      doc.head.appendChild(s);
173    }
174    const Root = runtime.getDC(rootName);
175    const entry = runtime.registry.get(rootName);
176    function StandaloneRoot() {
177      const [, setTick] = React.useState(0);
178      React.useEffect(() => {
179        const sub = () => setTick((n) => n + 1);
180        entry.subs.add(sub);
181        return () => {
182          entry.subs.delete(sub);
183        };
184      }, []);
185      const defaults = React.useMemo(() => {
186        const d = {};
187        for (const k in entry.propsMeta || {}) {
188          const v = entry.propsMeta?.[k]?.default;
189          if (v !== void 0) d[k] = v;
190        }
191        return d;
192      }, [entry.propsMeta]);
193      return h(Root, { ...defaults, ...entry.propOverrides || {} });
194    }
195    const ReactDOM = getReactDOM();
196    if (ReactDOM.createRoot)
197      ReactDOM.createRoot(hostEl).render(h(StandaloneRoot));
198    else ReactDOM.render(h(StandaloneRoot), hostEl);
199    return rootName;
200  }
201
202  
202// src/expr.ts
203  var IDENT_RE = /^[A-Za-z_$][A-Za-z0-9_$]*/;
204  var NUMBER_RE = /^-?\d+(\.\d+)?$/;
205  function resolve(vals, src) {
206    const expr = String(src).trim();
207    if (!expr) return void 0;
208    if (expr[0] === "(" && expr[expr.length - 1] === ")" && parensWrapWhole(expr)) {
209      return resolve(vals, expr.slice(1, -1));
210    }
211    const eq = findTopLevelEquality(expr);
212    if (eq) {
213      const lv = resolve(vals, expr.slice(0, eq.index));
214      const rv = resolve(vals, expr.slice(eq.index + eq.op.length));
215      switch (eq.op) {
216        case "===":
217          return lv === rv;
218        case "!==":
219          return lv !== rv;
220        case "==":
221          return lv == rv;
222        default:
223          return lv != rv;
224      }
225    }
226    if (expr[0] === "!") return !resolve(vals, expr.slice(1));
227    if (expr === "true") return true;
228    if (expr === "false") return false;
229    if (expr === "null") return null;
230    if (expr === "undefined") return void 0;
231    if (NUMBER_RE.test(expr)) return Number(expr);
232    if (expr.length >= 2 && (expr[0] === '"' || expr[0] === "'") && expr[expr.length - 1] === expr[0]) {
233      return expr.slice(1, -1);
234    }
235    return resolvePath(vals, expr);
236  }
237  function parensWrapWhole(expr) {
238    let depth = 0;
239    for (let i = 0; i < expr.length - 1; i++) {
240      if (expr[i] === "(") depth++;
241      else if (expr[i] === ")") {
242        depth--;
243        if (depth === 0) return false;
244      }
245    }
246    return true;
247  }
248  function findTopLevelEquality(expr) {
249    let depth = 0;
250    for (let i = 0; i < expr.length; i++) {
251      const c = expr[i];
252      if (c === "[" || c === "(") depth++;
253      else if (c === "]" || c === ")") depth--;
254      else if (depth === 0 && (c === "=" || c === "!") && expr[i + 1] === "=") {
255        if (i > 0 && (expr[i - 1] === "=" || expr[i - 1] === "!")) continue;
256        if (!expr.slice(0, i).trim()) continue;
257        const op = expr[i + 2] === "=" ? c + "==" : c + "=";
258        return { index: i, op };
259      }
260    }
261    return null;
262  }
263  function resolvePath(vals, expr) {
264    const head = expr.match(IDENT_RE);
265    if (!head) return void 0;
266    let cur = vals == null ? void 0 : vals[head[0]];
267    let i = head[0].length;
268    while (i < expr.length) {
269      if (expr[i] === ".") {
270        const m = expr.slice(i + 1).match(IDENT_RE) || expr.slice(i + 1).match(/^\d+/);
271        if (!m) return void 0;
272        cur = cur == null ? void 0 : cur[m[0]];
273        i += 1 + m[0].length;
274      } else if (expr[i] === "[") {
275        let depth = 1;
276        let j = i + 1;
277        while (j < expr.length && depth > 0) {
278          if (expr[j] === "[") depth++;
279          else if (expr[j] === "]") {
280            depth--;
281            if (depth === 0) break;
282          }
283          j++;
284        }
285        if (depth !== 0) return void 0;
286        const key = resolve(vals, expr.slice(i + 1, j));
287        cur = cur == null ? void 0 : cur[key];
288        i = j + 1;
289      } else {
290        return void 0;
291      }
292    }
293    return cur;
294  }
295
296  
296// src/encode.ts
297  var CAMEL_ATTR = "sc-camel-";
298  var INLINE_TEXT_TAGS = new Set(
299    "a abbr b bdi bdo br cite code del dfn em i ins kbd mark q s samp small span strike strong sub sup u var wbr".split(
300      " "
301    )
302  );
303  var RAW_WRAP = {
304    select: "sc-raw-select",
305    table: "sc-raw-table",
306    tbody: "sc-raw-tbody",
307    thead: "sc-raw-thead",
308    tfoot: "sc-raw-tfoot",
309    tr: "sc-raw-tr",
310    td: "sc-raw-td",
311    th: "sc-raw-th",
312    caption: "sc-raw-caption"
313  };
314  var RAW_UNWRAP = Object.fromEntries(
315    Object.entries(RAW_WRAP).map(([k, v]) => [v, k])
316  );
317  var EVENT_MAP = {
318    onclick: "onClick",
319    onchange: "onChange",
320    oninput: "onInput",
321    onsubmit: "onSubmit",
322    onkeydown: "onKeyDown",
323    onkeyup: "onKeyUp",
324    onkeypress: "onKeyPress",
325    onmousedown: "onMouseDown",
326    onmouseup: "onMouseUp",
327    onmouseenter: "onMouseEnter",
328    onmouseleave: "onMouseLeave",
329    onfocus: "onFocus",
330    onblur: "onBlur",
331    ondoubleclick: "onDoubleClick",
332    oncontextmenu: "onContextMenu",
333    onmousemove: "onMouseMove",
334    onmouseover: "onMouseOver",
335    onmouseout: "onMouseOut",
336    onpointerdown: "onPointerDown",
337    onpointerup: "onPointerUp",
338    onpointermove: "onPointerMove",
339    onpointerenter: "onPointerEnter",
340    onpointerleave: "onPointerLeave",
341    onpointercancel: "onPointerCancel",
342    onpointerover: "onPointerOver",
343    onpointerout: "onPointerOut",
344    ongotpointercapture: "onGotPointerCapture",
345    onlostpointercapture: "onLostPointerCapture",
346    ontouchstart: "onTouchStart",
347    ontouchend: "onTouchEnd",
348    ontouchmove: "onTouchMove",
349    ontouchcancel: "onTouchCancel",
350    ondragstart: "onDragStart",
351    ondragend: "onDragEnd",
352    ondragenter: "onDragEnter",
353    ondragleave: "onDragLeave",
354    ondragover: "onDragOver",
355    onanimationstart: "onAnimationStart",
356    onanimationend: "onAnimationEnd",
357    onanimationiteration: "onAnimationIteration",
358    ontransitionend: "onTransitionEnd"
359  };
360  var ATTRS = `(?:[^>"']|"[^"]*"|'[^']*')*`;
361  var IMPORT_SELF_CLOSE_RE = new RegExp(
362    "<(x-import|dc-import)(" + ATTRS + ")/>",
363    "gi"
364  );
365  var CAMEL_ATTR_RE = /(\s)([a-z]+[A-Z][A-Za-z0-9]*)(\s*=)/g;
366  function encodeCamelAttrs(html) {
367    return html.replace(
368      CAMEL_ATTR_RE,
369      (_, sp, name, eq) => sp + CAMEL_ATTR + name.replace(/[A-Z]/g, (c) => "-" + c.toLowerCase()) + eq
370    );
371  }
372  function encodeCase(html) {
373    html = html.replace(
374      IMPORT_SELF_CLOSE_RE,
375      (_, t, a) => "<" + t + a + "></" + t + ">"
376    );
377    html = html.replace(/<helmet(\s|>)/gi, "<sc-helmet$1");
378    html = html.replace(/<\/helmet\s*>/gi, "</sc-helmet>");
379    html = encodeCamelAttrs(html);
380    for (const [real, alias] of Object.entries(RAW_WRAP)) {
381      html = html.replace(
382        new RegExp("(</?)" + real + "(?=[\\s>])", "gi"),
383        "$1" + alias
384      );
385    }
386    return html;
387  }
388  function kebabToCamel(s) {
389    return s.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
390  }
391  function cssToObj(css) {
392    const o = {};
393    for (const decl of css.split(";")) {
394      const i = decl.indexOf(":");
395      if (i < 0) continue;
396      const prop = decl.slice(0, i).trim();
397      o[prop.startsWith("--") ? prop : kebabToCamel(prop)] = decl.slice(i + 1).trim();
398    }
399    return o;
400  }
401  function compileAttr(raw) {
402    const whole = raw.match(/^\s*\{\{([\s\S]+?)\}\}\s*$/);
403    if (whole) {
404      const path = whole[1];
405      return (vals) => resolve(vals, path);
406    }
407    if (raw.includes("{{")) {
408      const parts = raw.split(/\{\{([\s\S]+?)\}\}/g);
409      return (vals) => parts.map((s, i) => i & 1 ? resolve(vals, s) ?? "" : s).join("");
410    }
411    return () => raw;
412  }
413
414  
414// src/compile.ts
415  function collectProps(node, kind, host) {
416    const propGetters = [];
417    const pseudoClasses = [];
418    let hintSize = null;
419    for (const { name, value } of [...node.attributes]) {
420      if (name === "sc-name" || name === "data-dc-tpl") continue;
421      let key = name;
422      if (key.startsWith(CAMEL_ATTR))
423        key = kebabToCamel(key.slice(CAMEL_ATTR.length));
424      if (key === "hint-size") {
425        hintSize = value;
426        continue;
427      }
428      if (key.startsWith("style-")) {
429        pseudoClasses.push(host.pseudoClass(key.slice(6), value));
430        continue;
431      }
432      if (kind !== "dom") {
433        if (key.includes("-") && !(kind === "x-import" && (key.startsWith("aria-") || key.startsWith("data-"))))
434          key = kebabToCamel(key);
435      } else {
436        if (key === "class") key = "className";
437        else if (key === "for") key = "htmlFor";
438        else if (key.startsWith("on"))
439          key = EVENT_MAP[key] || "on" + key[2].toUpperCase() + key.slice(3);
440      }
441      propGetters.push([key, compileAttr(value)]);
442    }
443    return { propGetters, pseudoClasses, hintSize };
444  }
445  var HOST_STYLE_PROPS = /* @__PURE__ */ new Set([
446    "position",
447    "left",
448    "right",
449    "top",
450    "bottom",
451    "inset",
452    "width",
453    "height",
454    "z-index",
455    "transform"
456  ]);
457  function hostPositionStyle(style) {
458    const all = typeof style === "string" ? cssToObj(style) : style != null && typeof style === "object" ? style : null;
459    if (!all) return void 0;
460    const out = {};
461    for (const [k, v] of Object.entries(all)) {
462      const kebab = k.replace(/[A-Z]/g, (c) => "-" + c.toLowerCase());
463      if (HOST_STYLE_PROPS.has(kebab)) out[k] = v;
464    }
465    return Object.keys(out).length ? out : void 0;
466  }
467  function compileTemplate(html, host) {
468    const tpl = document.createElement("template");
469    //! nosemgrep: direct-inner-html-assignment
470    tpl.innerHTML = encodeCase(html);
471    let tplN = 0;
472    (function stamp(node) {
473      if (node.nodeType === Node.ELEMENT_NODE) {
474        node.setAttribute("data-dc-tpl", String(tplN++));
475      }
476      for (const c of node.childNodes) stamp(c);
477    })(tpl.content);
478    const builders = walkChildren(tpl.content, host);
479    const render = ((vals, ctx) => builders.map((b, i) => b(vals || {}, ctx, i)));
480    render.__annotated = tpl.innerHTML;
481    return render;
482  }
483  function walkChildren(node, host) {
484    return [...node.childNodes].map((c) => walk(c, host)).filter((b) => b != null);
485  }
486  function walk(node, host) {
487    if (node.nodeType === Node.TEXT_NODE) return walkText(node);
488    if (node.nodeType !== Node.ELEMENT_NODE) return null;
489    const el = node;
490    const tag = el.tagName.toLowerCase();
491    if (tag === "sc-for") return walkFor(el, host);
492    if (tag === "sc-if") return walkIf(el, host);
493    if (tag === "x-import") return walkXImport(el, host);
494    if (tag === "sc-helmet") return host.helmet(el);
495    if (tag === "dc-import") return walkComponent(el, host);
496    return walkElement(el, host);
497  }
498  var warnedHoles = /* @__PURE__ */ new Set();
499  function warnUnresolved(ctx, what) {
500    const key = (ctx?.__name || "?") + "\0" + what;
501    if (warnedHoles.has(key)) return;
502    warnedHoles.add(key);
503    console.warn("[dc-runtime] " + (ctx?.__name || "template") + ": " + what);
504  }
505  function walkText(node) {
506    const txt = node.nodeValue ?? "";
507    if (!txt.includes("{{")) {
508      if (!txt.trim() && !txt.includes(" ")) return null;
509      return () => txt;
510    }
511    const parts = txt.split(/\{\{([\s\S]+?)\}\}/g);
512    return (vals, ctx, key) => h(
513      getReact().Fragment,
514      { key },
515      ...parts.map((p, i) => {
516        if (!(i & 1)) return p;
517        const v = resolve(vals, p);
518        if (v === void 0) {
519          if (!ctx?.__streamingNow) {
520            if (document.body?.hasAttribute("data-dc-editor-on")) {
521              return h(
522                "span",
523                { key: i, className: "sc-interp sc-unresolved" },
524                "{{ " + p.trim() + " }}"
525              );
526            }
527            warnUnresolved(
528              ctx,
529              "{{ " + p.trim() + " }} never resolved \u2014 rendered as empty"
530            );
531            return null;
532          }
533          return h(
534            "span",
535            { key: i, className: "sc-interp sc-missing" },
536            p.trim()
537          );
538        }
539        if (getReact().isValidElement(v) || Array.isArray(v)) {
540          return h(getReact().Fragment, { key: i }, v);
541        }
542        if (v === null || typeof v === "boolean") return null;
543        return h("span", { key: i, className: "sc-interp" }, String(v));
544      })
545    );
546  }
547  function walkFor(el, host) {
548    const listGet = compileAttr(el.getAttribute("list") || "");
549    const asName = el.getAttribute("as") || "item";
550    const hintN = parseInt(el.getAttribute("hint-placeholder-count") || "0", 10);
551    const kids = walkChildren(el, host);
552    const listSrc = el.getAttribute("list") || "";
553    return (vals, ctx, key) => {
554      let list = listGet(vals);
555      if (!Array.isArray(list)) {
556        if (!ctx?.__streamingNow) {
557          if (list !== void 0 && list !== null) {
558            warnUnresolved(
559              ctx,
560              'sc-for list="' + listSrc + '" is not an array (' + typeof list + ")"
561            );
562          }
563          list = [];
564        } else {
565          list = hintN > 0 ? Array(hintN).fill(void 0) : [];
566        }
567      }
568      return h(
569        getReact().Fragment,
570        { key },
571        list.map((item, i) => {
572          const sub = { ...vals, [asName]: item, $index: i };
573          return h(
574            getReact().Fragment,
575            { key: i },
576            kids.map((b, j) => b(sub, ctx, j))
577          );
578        })
579      );
580    };
581  }
582  function walkIf(el, host) {
583    const valGet = compileAttr(el.getAttribute("value") || "");
584    const hintRaw = el.getAttribute("hint-placeholder-val");
585    const hintGet = hintRaw != null ? compileAttr(hintRaw) : null;
586    const kids = walkChildren(el, host);
587    return (vals, ctx, key) => {
588      let v = valGet(vals);
589      if (v === void 0 && hintGet && ctx?.__streamingNow) v = hintGet(vals);
590      return v ? h(
591        getReact().Fragment,
592        { key },
593        kids.map((b, j) => b(vals, ctx, j))
594      ) : null;
595    };
596  }
597  function walkComponent(el, host) {
598    const name = el.getAttribute("name") || el.getAttribute("component") || "";
599    el.removeAttribute("name");
600    el.removeAttribute("component");
601    const tplId = el.getAttribute("data-dc-tpl");
602    const styleRaw = el.getAttribute("style");
603    el.removeAttribute("style");
604    const styleGet = styleRaw != null ? compileAttr(styleRaw) : null;
605    const { propGetters, hintSize } = collectProps(el, "dc-import", host);
606    const kids = walkChildren(el, host);
607    return (vals, ctx, key) => {
608      const props = {
609        key,
610        __hintSize: hintSize,
611        __tplId: tplId,
612        __hostStyle: styleGet ? hostPositionStyle(styleGet(vals)) : void 0
613      };
614      for (const [k, g] of propGetters) {
615        const v = g(vals);
616        if (k === "dcProps") {
617          if (v && typeof v === "object") Object.assign(props, v);
618          continue;
619        }
620        props[k] = v;
621      }
622      if (kids.length) props.children = kids.map((b, j) => b(vals, ctx, j));
623      return h(host.component(name), props);
624    };
625  }
626  function walkXImport(el, host) {
627    const globalNameGet = compileAttr(
628      el.getAttribute("component-from-global-scope") || ""
629    );
630    const exportNameGet = compileAttr(
631      el.getAttribute("component") || el.getAttribute("name") || ""
632    );
633    const fromRaw = el.getAttribute("from") || (el.getAttribute("component-from-global-scope") ? "" : el.getAttribute("src") || el.getAttribute("import") || "");
634    const urls = fromRaw.trim() ? fromRaw.trim().split(/\s+/) : [];
635    const url = urls.length ? urls[urls.length - 1] : "";
636    const kindOf = (u) => /\.(jsx|tsx)(\?|#|$)/i.test(u) ? "jsx" : "js";
637    const tplId = el.getAttribute("data-dc-tpl");
638    const styleRaw = el.getAttribute("style");
639    el.removeAttribute("style");
640    const styleGet = styleRaw != null ? compileAttr(styleRaw) : null;
641    const wrap = tplId != null || styleGet != null;
642    const { propGetters, hintSize } = collectProps(el, "x-import", host);
643    const hasContent = el.children.length > 0 || !!(el.textContent || "").trim();
644    const kids = hasContent ? walkChildren(el, host) : [];
645    const urlBindable = fromRaw.includes("{{");
646    if (urls.length && !urlBindable) {
647      let prev;
648      for (const u of urls) prev = host.loadExternal(kindOf(u), u, prev);
649    }
650    const evalName = (g, vals) => {
651      const v = g(vals);
652      const s = v == null ? "" : String(v);
653      return s.includes("{{") ? "" : s;
654    };
655    return (vals, ctx, key) => {
656      const globalName = evalName(globalNameGet, vals);
657      const name = globalName || evalName(exportNameGet, vals);
658      const C = !name || urlBindable ? null : globalName ? host.resolveExternalGlobal(url, globalName) : host.resolveExternal(url, name);
659      const hostStyle = styleGet ? hostPositionStyle(styleGet(vals)) : void 0;
660      const wrapper = wrap ? {
661        key,
662        className: "sc-host-x",
663        "data-dc-tpl": tplId,
664        style: hostStyle || { display: "contents" }
665      } : null;
666      if (!C) {
667        const error = urlBindable ? "x-import `from` cannot contain {{ \u2026 }} \u2014 module URLs are resolved at parse time; use a literal URL" : host.resolveExternalError(url, name);
668        const ph = host.placeholder({
669          key: wrapper ? void 0 : key,
670          name,
671          hintSize,
672          error
673        });
674        return wrapper ? h("div", wrapper, ph) : ph;
675      }
676      const props = wrapper ? {} : { key };
677      let unresolvedHole = false;
678      for (const [k, g] of propGetters) {
679        if (k === "component" || k === "componentFromGlobalScope" || k === "from") {
680          continue;
681        }
682        const v = g(vals);
683        if (v === void 0) unresolvedHole = true;
684        if (k === "dcProps") {
685          if (v && typeof v === "object") Object.assign(props, v);
686          continue;
687        }
688        props[k] = v;
689      }
690      if (unresolvedHole && ctx?.__htmlStreamingNow) {
691        const ph = host.placeholder({
692          key: wrapper ? void 0 : key,
693          name,
694          hintSize,
695          error: null
696        });
697        return wrapper ? h("div", wrapper, ph) : ph;
698      }
699      if (kids.length) props.children = kids.map((b, j) => b(vals, ctx, j));
700      return wrapper ? h("div", wrapper, h(C, props)) : h(C, props);
701    };
702  }
703  function contentKey(el) {
704    const clone = el.cloneNode(true);
705    for (const d of clone.querySelectorAll("*")) {
706      while (d.attributes.length) d.removeAttribute(d.attributes[0].name);
707    }
708    const s = clone.innerHTML;
709    let h2 = 5381;
710    for (let i = 0; i < s.length; i++) h2 = (h2 << 5) + h2 + s.charCodeAt(i) | 0;
711    return s.length + "." + (h2 >>> 0).toString(36);
712  }
713  var NEVER_CONTENT_KEYED = new Set(
714    "script style textarea option title select canvas iframe video audio".split(
715      " "
716    )
717  );
718  var NOT_INLINE_SELECTOR = ":not(" + [...INLINE_TEXT_TAGS].join(",") + ")";
719  function walkElement(el, host) {
720    const realTag = RAW_UNWRAP[el.localName] || el.localName;
721    const tplId = el.getAttribute("data-dc-tpl");
722    const inlineOnly = el.childNodes.length > 0 && !NEVER_CONTENT_KEYED.has(realTag) && el.querySelector(NOT_INLINE_SELECTOR) === null;
723    const keySuffix = inlineOnly ? "|" + contentKey(el) : "";
724    const { propGetters, pseudoClasses } = collectProps(el, "dom", host);
725    const kids = walkChildren(el, host);
726    return (vals, ctx, key) => {
727      const props = {
728        key: key + keySuffix,
729        "data-dc-tpl": tplId
730      };
731      for (const [k, g] of propGetters) {
732        let v = g(vals);
733        if (k === "style" && typeof v === "string") v = cssToObj(v);
734        if ((k === "value" || k === "checked") && v === void 0) {
735          v = k === "checked" ? false : "";
736        }
737        props[k] = v;
738      }
739      if (pseudoClasses.length) {
740        props.className = [props.className, ...pseudoClasses].filter(Boolean).join(" ");
741      }
742      return h(realTag, props, ...kids.map((b, j) => b(vals, ctx, j)));
743    };
744  }
745
746  
746// src/logic.ts
747  var StreamableLogic = class {
748    constructor(props) {
749      __publicField(this, "props");
750      __publicField(this, "state", {});
751      /** Back-pointer to the wrapper component, installed after construction. */
752      __publicField(this, "__host");
753      this.props = props || {};
754    }
755    setState(update, cb) {
756      this.__host && this.__host.__setLogicState(update, cb);
757    }
758    forceUpdate() {
759      this.__host && this.__host.forceUpdate();
760    }
761    componentDidMount() {
762    }
763    componentDidUpdate(_prevProps) {
764    }
765    componentWillUnmount() {
766    }
767    /** The flat object the template renders against (merged over props). */
768    renderVals() {
769      return {};
770    }
771  };
772  function evalDcLogic(src) {
773    //! nosemgrep: eval-and-function-constructor
774    const fn = new Function(
775      "DCLogic",
776      "StreamableLogic",
777      "React",
778      src + '\n;return (typeof Component!=="undefined"&&Component)||undefined;'
779    );
780    return fn(StreamableLogic, StreamableLogic, getReact());
781  }
782
783  
783// src/component.ts
784  function shallowEqual(a, b) {
785    if (!b) return false;
786    const ak = Object.keys(a).filter((k) => k !== "children");
787    const bk = Object.keys(b).filter((k) => k !== "children");
788    if (ak.length !== bk.length) return false;
789    for (const k of ak) if (a[k] !== b[k]) return false;
790    return true;
791  }
792  function Placeholder({
793    name,
794    hintSize,
795    streaming,
796    error
797  }) {
798    const [w, hgt] = (hintSize || "100%,60px").split(",");
799    return h(
800      "div",
801      {
802        className: "sc-placeholder" + (streaming ? " sc-streaming" : ""),
803        style: { width: w.trim(), height: hgt && hgt.trim() },
804        title: name
805      },
806      error ? h(
807        "div",
808        { className: "sc-placeholder-error" },
809        (name ? name + ": " : "") + error
810      ) : null
811    );
812  }
813  function hintToMin(hint) {
814    if (!hint) return void 0;
815    const [w, hgt] = hint.split(",");
816    return { minWidth: w.trim(), minHeight: hgt && hgt.trim() };
817  }
818  function createComponentFactory(registry, ensureFetched) {
819    const React = getReact();
820    const AncestorContext = React.createContext([]);
821    class StreamableComponent extends React.Component {
822      constructor(props) {
823        super(props);
824        __publicField(this, "__name");
825        __publicField(this, "__sub");
826        __publicField(this, "__needsDidMount", false);
827        /** Snapshot of the registry's streaming flags taken at render time —
828         *  builders read it off the RenderCtx (this) to pick placeholder vs
829         *  render-nothing for unresolved values. */
830        __publicField(this, "__streamingNow", false);
831        __publicField(this, "__htmlStreamingNow", false);
832        /** When a construct throws, remember the (class, registry.ver, props)
833         *  triple so render-time reconcile doesn't re-attempt it on every parent
834         *  re-render. A registry bump (new class, template, external module
835         *  resolving via bumpAll) changes `ver` and breaks the memo so an
836         *  env-dependent constructor can self-heal. */
837        __publicField(this, "__failedLogic", null);
838        __publicField(this, "__failedUserProps", null);
839        __publicField(this, "__failedVer", -1);
840        /** Per-instance constructor error — kept here (not on the registry entry)
841         *  so one instance's successful construct can't hide a sibling's failure,
842         *  and a construct can never wipe an eval error `updateJs` recorded on
843         *  `r.logicError`. */
844        __publicField(this, "__ctorError", null);
845        __publicField(this, "logic");
846        this.__name = props.__name;
847        this.state = { __v: 0, __err: null };
848        this.__sub = () => {
849          if (this.state.__err) this.setState({ __err: null });
850          this.forceUpdate();
851        };
852        this.__makeLogic(registry.get(this.__name).Logic, null);
853        ensureFetched(this.__name);
854      }
855      /** Error-boundary hook: a render crash anywhere in this DC's subtree
856       *  (its own template, an x-import'd component, a child DC without its
857       *  own deeper boundary) lands here instead of unmounting the page. */
858      static getDerivedStateFromError(e) {
859        return { __err: e instanceof Error && e.message ? e.message : String(e) };
860      }
861      componentDidCatch(e, info) {
862        console.error(
863          "[dc-runtime] render error in <" + this.__name + ">:",
864          e,
865          info?.componentStack || ""
866        );
867      }
868      /** Instantiate the logic class (or the no-op base) and adopt `prevState`
869       *  over its initial state — used both at mount and on hot-swap. */
870      __makeLogic(Logic, prevState) {
871        const L = Logic || StreamableLogic;
872        try {
873          this.logic = new L(this.__userProps());
874          this.__failedLogic = null;
875          this.__failedUserProps = null;
876          this.__ctorError = null;
877        } catch (e) {
878          console.error(e);
879          this.__failedLogic = Logic;
880          this.__failedUserProps = this.__userProps();
881          this.__failedVer = registry.get(this.__name).ver;
882          this.__ctorError = this.__name + ": " + (e instanceof Error && e.message ? e.message : 
882String(e));
883          this.logic = new StreamableLogic(
884            this.__userProps()
885          );
886        }
887        this.logic.__host = this;
888        if (prevState)
889          this.logic.state = { ...this.logic.state || {}, ...prevState };
890      }
891      /** The props the author's logic + template see — internal __-prefixed
892       *  wiring stripped. */
893      __userProps() {
894        const { __name, __hintSize, __tplId, __hostStyle, ...rest } = this.props;
895        return rest;
896      }
897      __setLogicState(update, cb) {
898        const prev = this.logic.state;
899        const patch = typeof update === "function" ? update(prev) : update;
900        this.logic.state = { ...prev, ...patch };
901        this.setState((s) => ({ __v: s.__v + 1 }), cb);
902      }
903      /** Swap the logic instance when the registry's Logic class changed
904       *  (streaming completion, hot reload). State carries over; didMount
905       *  re-fires after the swap commits so refs exist. */
906      __reconcileLogic() {
907        const r = registry.get(this.__name);
908        const Next = r.Logic;
909        const Cur = this.logic.constructor;
910        if (Next === Cur || !Next && Cur === StreamableLogic || Next === this.__failedLogic && r.ver === this.__failedVer && shallowEqual(this.__userProps(), this.__failedUserProps)) {
911          return;
912        }
913        if (!this.__needsDidMount) {
914          try {
915            this.logic.componentWillUnmount();
916          } catch (e) {
917            console.error(e);
918          }
919        }
920        this.__makeLogic(Next, this.logic.state);
921        this.__needsDidMount = true;
922      }
923      componentDidMount() {
924        registry.get(this.__name).subs.add(this.__sub);
925        try {
926          this.logic.componentDidMount();
927        } catch (e) {
928          console.error(e);
929        }
930      }
931      componentDidUpdate(prevProps) {
932        this.logic.props = this.__userProps();
933        if (this.__needsDidMount) {
934          if (this.state.__err || !registry.get(this.__name).tpl) return;
935          this.__needsDidMount = false;
936          try {
937            this.logic.componentDidMount();
938          } catch (e) {
939            console.error(e);
940          }
941        } else {
942          try {
943            this.logic.componentDidUpdate(prevProps);
944          } catch (e) {
945            console.error(e);
946          }
947        }
948      }
949      componentWillUnmount() {
950        registry.get(this.__name).subs.delete(this.__sub);
951        if (!this.__needsDidMount) {
952          try {
953            this.logic.componentWillUnmount();
954          } catch (e) {
955            console.error(e);
956          }
957        }
958      }
959      render() {
960        const r = registry.get(this.__name);
961        const cls = "sc-host" + (r.htmlStreaming ? " sc-streaming-html" : "") + (r.jsStreaming ? " sc-streaming-js" : "");
962        const hintStyle = r.htmlStreaming ? hintToMin(this.props.__hintSize) : void 0;
963        const hostStyle = this.props.__hostStyle || hintStyle ? { ...hintStyle || {}, ...this.props.__hostStyle || {} } : void 0;
964        const hostBase = {
965          className: cls,
966          style: hostStyle,
967          "data-sc-name": this.__name,
968          "data-dc-tpl": this.props.__tplId
969        };
970        const chain = Array.isArray(this.context) ? this.context : [];
971        if (chain.includes(this.__name)) {
972          const cycle = [
973            ...chain.slice(chain.indexOf(this.__name)),
974            this.__name
975          ].join(" \u2192 ");
976          return h(
977            "div",
978            { ...hostBase, className: cls + " sc-has-error" },
979            h(Placeholder, {
980              name: this.__name,
981              hintSize: this.props.__hintSize,
982              error: "circular import: " + cycle
983            })
984          );
985        }
986        if (this.state.__err) {
987          return h(
988            "div",
989            { ...hostBase, className: cls + " sc-has-error" },
990            h(
991              "div",
992              { className: "sc-logic-error", "data-omelette-chrome": "" },
993              this.__name + ": " + this.state.__err
994            ),
995            h(Placeholder, {
996              name: this.__name,
997              hintSize: this.props.__hintSize,
998              error: this.state.__err
999            })
1000          );
1001        }
1002        this.__reconcileLogic();
1003        if (!r.tpl) {
1004          return h(
1005            "div",
1006            hostBase,
1007            h(Placeholder, { name: this.__name, hintSize: this.props.__hintSize })
1008          );
1009        }
1010        const userProps = this.__userProps();
1011        this.logic.props = userProps;
1012        let vals = userProps;
1013        let renderErr = r.logicError || this.__ctorError;
1014        try {
1015          vals = { ...userProps, ...this.logic.renderVals() || {} };
1016        } catch (e) {
1017          console.error(e);
1018          renderErr = this.__name + ".renderVals(): " + (e instanceof Error && e.message ? e.message : 
1018String(e));
1019        }
1020        this.__streamingNow = !!(r.htmlStreaming || r.jsStreaming);
1021        this.__htmlStreamingNow = !!r.htmlStreaming;
1022        return h(
1023          "div",
1024          { ...hostBase, className: cls + (renderErr ? " sc-has-error" : "") },
1025          renderErr && h(
1026            "div",
1027            { className: "sc-logic-error", "data-omelette-chrome": "" },
1028            renderErr
1029          ),
1030          h(
1031            AncestorContext.Provider,
1032            { value: [...chain, this.__name] },
1033            r.tpl(vals, this)
1034          )
1035        );
1036      }
1037    }
1038    __publicField(StreamableComponent, "contextType", AncestorContext);
1039    const named = /* @__PURE__ */ new Map();
1040    function getDC(name) {
1041      const hit = named.get(name);
1042      if (hit) return hit;
1043      function Dispatcher(p) {
1044        const [, setTick] = React.useState(0);
1045        React.useEffect(() => {
1046          const sub = () => setTick((n) => n + 1);
1047          registry.get(name).subs.add(sub);
1048          return () => {
1049            registry.get(name).subs.delete(sub);
1050          };
1051        }, []);
1052        ensureFetched(name);
1053        return h(StreamableComponent, { ...p, __name: name });
1054      }
1055      Dispatcher.displayName = name;
1056      named.set(name, Dispatcher);
1057      return Dispatcher;
1058    }
1059    return {
1060      getDC,
1061      StreamableComponent
1062    };
1063  }
1064
1065  
1065// src/bundled.ts
1066  function bundledBlob(url) {
1067    const blobs = window.__resourceBlobs;
1068    const b = blobs ? blobs[url.split("#")[0]] : void 0;
1069    return b instanceof Blob ? b : null;
1070  }
1071
1072  
1072// src/cdn.ts
1073  var REACT_URL = "https://unpkg.com/[email protected]/umd/react.production.min.js";
1074  var REACT_SRI = "sha384-DGyLxAyjq0f9SPpVevD6IgztCFlnMF6oW/XQGmfe+IsZ8TqEiDrcHkMLKI6fiB/Z";
1075  var REACT_DOM_URL = "https://unpkg.com/[email protected]/umd/react-dom.production.min.js";
1076  var REACT_DOM_SRI = "sha384-gTGxhz21lVGYNMcdJOyq01Edg0jhn/c22nsx0kyqP0TxaV5WVdsSH1fSDUf5YJj1";
1077  var BABEL_URL = "https://unpkg.com/@babel/[email protected]/babel.min.js";
1078  var BABEL_SRI = "sha384-m08KidiNqLdpJqLq95G/LEi8Qvjl/xUYll3QILypMoQ65QorJ9Lvtp2RXYGBFj1y";
1079  function cdnScriptFor(url, sri) {
1080    const res = window.__resources;
1081    const v = res ? res[url] : void 0;
1082    return typeof v === "string" && v ? { src: v } : { src: url, integrity: sri };
1083  }
1084
1085  
1085// src/external.ts
1086  var isCustomElementName = (n) => !n.includes(".") && n.includes("-");
1087  function isRenderableType(g) {
1088    if (typeof g === "function") return !isElementClass(g);
1089    return typeof g === "object" && g !== null && typeof g.$$typeof === "symbol";
1090  }
1091  function resolveDottedPath(root, name) {
1092    let cur = root;
1093    for (const seg of name.split(".")) {
1094      if (cur == null) return void 0;
1095      cur = cur[seg];
1096    }
1097    return cur;
1098  }
1099  var GLOBAL_POLL_INTERVAL_MS = 50;
1100  var GLOBAL_POLL_TIMEOUT_MS = 3e4;
1101  function createExternalModules(onResolved) {
1102    const cache = /* @__PURE__ */ new Map();
1103    let babelLoading = null;
1104    const reportedMissing = /* @__PURE__ */ new Map();
1105    const polling = /* @__PURE__ */ new Set();
1106    function ensureBabel() {
1107      if (window.Babel) return Promise.resolve();
1108      if (babelLoading) return babelLoading;
1109      const babel = cdnScriptFor(BABEL_URL, BABEL_SRI);
1110      babelLoading = new Promise((res, rej) => {
1111        const s = document.createElement("script");
1112        s.src = babel.src;
1113        if (babel.integrity) {
1114          s.integrity = babel.integrity;
1115          s.crossOrigin = "anonymous";
1116        }
1117        s.onload = () => res();
1118        s.onerror = rej;
1119        document.head.appendChild(s);
1120      });
1121      return babelLoading;
1122    }
1123    const pending = /* @__PURE__ */ new Map();
1124    function load(kind, url, after) {
1125      const existing = pending.get(url);
1126      if (existing) return existing;
1127      cache.set(url, null);
1128      console.info("[dc-runtime] x-import: loading", url, "(" + kind + ")");
1129      const ready = Promise.all([
1130        kind === "jsx" ? ensureBabel() : Promise.resolve(),
1131        after ?? Promise.resolve()
1132      ]);
1133      const p = ready.then(() => {
1134        const pre = bundledBlob(url);
1135        if (pre) return pre.text();
1136        return fetch(url).then((r) => {
1137          if (!r.ok) throw new Error("HTTP " + r.status);
1138          return r.text();
1139        });
1140      }).then((src) => {
1141        const code = kind === "jsx" ? window.Babel.transform(src, {
1142          filename: url,
1143          presets: ["react", "typescript"]
1144        }).code : src;
1145        const module = { exports: {} };
1146        const before = new Set(Object.keys(window));
1147        //! nosemgrep: eval-and-function-constructor
1148        new Function("React", "module", "exports", "require", code)(
1149          getReact(),
1150          module,
1151          module.exports,
1152          () => ({})
1153        );
1154        const globals = {};
1155        for (const k of Object.keys(window)) {
1156          if (!before.has(k) && typeof window[k] === "function") {
1157            globals[k] = window[k];
1158          }
1159        }
1160        cache.set(url, { mod: module.exports, globals });
1161        console.info(
1162          "[dc-runtime] x-import: loaded",
1163          url,
1164          "\u2014 exports:",
1165          Object.keys(module.exports),
1166          "window globals:",
1167          Object.keys(globals)
1168        );
1169        onResolved();
1170      }).catch((e) => {
1171        cache.set(url, {
1172          mod: {},
1173          globals: {},
1174          error: "failed to load: " + (e instanceof Error && e.message ? e.message : String(e))
1175        });
1176        console.error(
1177          "[dc-runtime] x-import: FAILED to load",
1178          url,
1179          "(" + kind + ")",
1180          e
1181        );
1182        onResolved();
1183      });
1184      pending.set(url, p);
1185      return p;
1186    }
1187    function resolve2(url, name) {
1188      const entry = cache.get(url);
1189      if (!entry) return null;
1190      const { mod, globals } = entry;
1191      const C = mod && mod[name] || globals && globals[name] || typeof window !== "undefined" && window[name] || mod && mod.default;
1192      if (typeof C === "function") return C;
1193      const key = url + "\0" + name;
1194      if (!reportedMissing.has(key)) {
1195        reportedMissing.set(
1196          key,
1197          entry.error || 'no export named "' + name + '" (has: ' + Object.keys(mod).join(", ") + ")"
1198        );
1199        console.error(
1200          "[dc-runtime] x-import: module",
1201          url,
1202          "loaded but has no component named",
1203          JSON.stringify(name),
1204          "\u2014 available exports:",
1205          Object.keys(mod),
1206          "window globals:",
1207          Object.keys(globals),
1208          ". The module must `module.exports = {" + name + "}` or set `window." + name + "`."
1209        );
1210      }
1211      return null;
1212    }
1213    function waitForGlobal(name) {
1214      if (polling.has(name)) return;
1215      polling.add(name);
1216      const started = Date.now();
1217      const isCE = isCustomElementName(name);
1218      const tick = () => {
1219        const found = isCE ? customElements.get(name) : isRenderableType(resolveDottedPath(window, name));
1220        if (found) {
1221          polling.delete(name);
1222          onResolved();
1223          return;
1224        }
1225        if (Date.now() - started >= GLOBAL_POLL_TIMEOUT_MS) {
1226          console.warn(
1227            "[dc-runtime] x-import: global",
1228            JSON.stringify(name),
1229            "never appeared on window after " + GLOBAL_POLL_TIMEOUT_MS + "ms"
1230          );
1231          return;
1232        }
1233        setTimeout(tick, GLOBAL_POLL_INTERVAL_MS);
1234      };
1235      setTimeout(tick, GLOBAL_POLL_INTERVAL_MS);
1236    }
1237    function resolveGlobal(url, name) {
1238      const isCE = isCustomElementName(name);
1239      if (!url) {
1240        if (isCE) {
1241          if (customElements.get(name)) return name;
1242          waitForGlobal(name);
1243          return null;
1244        }
1245        const g2 = resolveDottedPath(window, name);
1246        if (isRenderableType(g2)) return g2;
1247        waitForGlobal(name);
1248        return null;
1249      }
1250      const entry = cache.get(url);
1251      if (!entry) return null;
1252      if (isCE && customElements.get(name)) return name;
1253      const g = entry.globals[name] ?? resolveDottedPath(window, name);
1254      if (isRenderableType(g)) return g;
1255      if (name.includes(".")) return null;
1256      const key = url + "\0global\0" + name;
1257      if (!reportedMissing.has(key)) {
1258        reportedMissing.set(key, null);
1259        if (isCE && !customElements.get(name)) {
1260          console.warn(
1261            "[dc-runtime] x-import:",
1262            url,
1263            "loaded but no custom element",
1264            JSON.stringify(name),
1265            "is registered and window." + name + " is not a function \u2014 rendering <" + name + "> as an unknown element."
1266          );
1267        }
1268      }
1269      return name;
1270    }
1271    function getError(url, name) {
1272      const entry = cache.get(url);
1273      if (entry?.error) return entry.error;
1274      return reportedMissing.get(url + "\0" + name) || null;
1275    }
1276    return { load, resolve: resolve2, resolveGlobal, getError };
1277  }
1278  function isElementClass(g) {
1279    try {
1280      return typeof g === "function" && typeof HTMLElement !== "undefined" && g.prototype instanceof HTMLElement;
1281    } catch {
1282      return false;
1283    }
1284  }
1285
1286  
1286// src/atomics.ts
1287  var ATOMIC_CSS = (
1288    // layout
1289    ".fx{display:flex}.col{display:flex;flex-direction:column}.grid{display:grid}.ac{align-items:center}.jc{justify-content:center}.jb{justify-content:space-between}.f1{flex:1}.noshrink{flex-shrink:0}.wrap{flex-wrap:wrap}.fw5{font-weight:500}.fw6{font-weight:600}.fw7{font-weight:700}.fw8{font-weight:800}.fs11{font-size:11px}.fs12{font-size:12px}.fs13{font-size:13px}.fs14{font-size:14px}.fs15{font-size:15px}.fs16{font-size:16px}.fs20{font-size:20px}.fs22{font-size:22px}.upper{text-transform:uppercase}.tc{text-align:center}.nowrap{white-space:nowrap}.gap8{gap:8px}.gap10{gap:10px}.gap12{gap:12px}.gap16{gap:16px}.gap24{gap:24px}.m0{margin:0}.mt8{margin-top:8px}.mt12{margin-top:12px}.mt16{margin-top:16px}.mb8{margin-bottom:8px}.mb12{margin-bottom:12px}.mb16{margin-bottom:16px}.posrel{position:relative}.posabs{position:absolute}.round{border-radius:50%}.ohide{overflow:hidden}.bbox{box-sizing:border-box}.pointer{cursor:pointer}.w100{width:100%}.b0{border:none}"
1290  );
1291
1292  
1292// src/helmet.ts
1293  var DESIGN_DOC_MODE_RE = /<meta\b[^>]*\bname\s*=\s*["']design_doc_mode["'][^>]*\b(?:content|value)\s*=\s*["'](\w+)["']/i;
1294  var CANVAS_BG_LIGHT = "#f0eee6";
1295  var CANVAS_BG_DARK = "#2e2c26";
1296  function createHelmetManager(doc, isStreaming) {
1297    const mounted = /* @__PURE__ */ new Set();
1298    const live = /* @__PURE__ */ new Map();
1299    let designDocMode = null;
1300    let canvasStyleEl = null;
1301    let appTheme = "light";
1302    try {
1303      const ds = doc.documentElement.dataset.theme;
1304      appTheme = ds === "dark" || ds === "light" ? ds : new URLSearchParams(doc.defaultView?.location.search ?? "").get(
1305        "theme"
1306      ) === "dark" ? "dark" : "light";
1307    } catch {
1308    }
1309    function applyCanvasBg() {
1310      if (!canvasStyleEl) return;
1311      const bg = appTheme === "dark" ? CANVAS_BG_DARK : CANVAS_BG_LIGHT;
1312      canvasStyleEl.textContent = `html,body{background:${bg}}#dc-root>.sc-host{position:relative}`;
1313    }
1314    function postDesignMode(mode) {
1315      if (window.parent === window) return;
1316      try {
1317        window.parent.postMessage({ type: "__dc_design_mode", mode }, "*");
1318      } catch {
1319      }
1320    }
1321    function setDesignDocMode(mode) {
1322      if (mode === designDocMode) return;
1323      designDocMode = mode;
1324      postDesignMode(mode);
1325      if (mode === "canvas") {
1326        doc.documentElement.setAttribute("data-dc-canvas", "");
1327        canvasStyleEl = doc.createElement("style");
1328        canvasStyleEl.setAttribute("data-dc-canvas", "");
1329        applyCanvasBg();
1330        doc.head.appendChild(canvasStyleEl);
1331      } else {
1332        doc.documentElement.removeAttribute("data-dc-canvas");
1333        canvasStyleEl?.remove();
1334        canvasStyleEl = null;
1335      }
1336    }
1337    window.addEventListener("message", (e) => {
1338      const type = e.data && e.data.type;
1339      if (type === "__dc_theme") {
1340        const t = e.data.theme;
1341        if (t === "light" || t === "dark") {
1342          appTheme = t;
1343          applyCanvasBg();
1344        }
1345        return;
1346      }
1347      if (!designDocMode || type !== "__dc_probe") return;
1348      postDesignMode(designDocMode);
1349    });
1350    function compile(node) {
1351      const raw = [...node.children];
1352      const helmetClosed = node.nextSibling != null || node.parentNode?.nextSibling != null;
1353      if (node.hasAttribute("data-dc-atomics") && !mounted.has("__dc-atomics")) {
1354        mounted.add("__dc-atomics");
1355        const el = doc.createElement("style");
1356        el.id = "__dc-atomics";
1357        el.textContent = ATOMIC_CSS;
1358        doc.head.appendChild(el);
1359      }
1360      return (_vals, ctx) => {
1361        const name = ctx && ctx.__name || "";
1362        const streaming = !!(name && isStreaming(name));
1363        for (let i = 0; i < raw.length; i++) {
1364          const child = raw[i];
1365          const tag = child.tagName;
1366          const mayBePartial = streaming && !helmetClosed && i === raw.length - 1;
1367          if (tag === "SCRIPT") {
1368            if (mayBePartial) continue;
1369            const key = "SCRIPT|" + (child.getAttribute("src") || child.textContent || "");
1370            if (mounted.has(key)) continue;
1371            mounted.add(key);
1372            const el = doc.createElement("script");
1373            for (const { name: an, value } of [...child.attributes])
1374              el.setAttribute(an, value);
1375            if (child.textContent) el.textContent = child.textContent;
1376            doc.head.appendChild(el);
1377          } else if (tag === "LINK" || tag === "META") {
1378            if (mayBePartial) continue;
1379            const key = tag + "|" + (child.getAttribute("href") || child.getAttribute("src") || child.outerHTML);
1380            if (mounted.has(key)) continue;
1381            mounted.add(key);
1382            if (tag === "LINK") {
1383              const rel = (child.getAttribute("rel") || "").toLowerCase().split(/\s+/);
1384              const href = (child.getAttribute("href") || "").trim();
1385              const res = window.__resources;
1386              const pre = res && rel.includes("stylesheet") && !rel.includes("alternate") ? res[href] : void 0;
1387              const blob = typeof pre === "string" && pre ? bundledBlob(pre) : null;
1388              if (blob) {
1389                const el = doc.createElement("style");
1390                if (child.hasAttribute("disabled")) {
1391                  el.setAttribute("media", "not all");
1392                } else if (child.getAttribute("media")) {
1393                  el.setAttribute("media", child.getAttribute("media"));
1394                }
1395                if (child.getAttribute("title"))
1396                  el.setAttribute("title", child.getAttribute("title"));
1397                void blob.text().then((css) => {
1398                  el.textContent = css;
1399                });
1400                doc.head.appendChild(el);
1401                continue;
1402              }
1403            }
1404            doc.head.appendChild(child.cloneNode(true));
1405          } else {
1406            const key = name + "|" + i;
1407            let el = live.get(key);
1408            if (!el || el.tagName !== tag) {
1409              if (el) el.remove();
1410              el = doc.createElement(tag.toLowerCase());
1411              live.set(key, el);
1412              doc.head.appendChild(el);
1413            }
1414            for (const { name: an, value } of [...child.attributes]) {
1415              if (el.getAttribute(an) !== value) el.setAttribute(an, value);
1416            }
1417            if (el.textContent !== child.textContent)
1418              el.textContent = child.textContent;
1419          }
1420        }
1421        return null;
1422      };
1423    }
1424    return { compile, setDesignDocMode };
1425  }
1426
1427  
1427// src/pseudo.ts
1428  function scanUnquotedUrl(css, i) {
1429    if (css[i] !== "u" && css[i] !== "U" || css.slice(i, i + 4).toLowerCase() !== "url(" || /[a-z0-9_-]/i.test(css[i - 1] ?? "")) {
1430      return -1;
1431    }
1432    let j = i + 4;
1433    while (j < css.length && /\s/.test(css[j])) j++;
1434    if (css[j] === '"' || css[j] === "'") return -1;
1435    while (j < css.length && css[j] !== ")") {
1436      if (css[j] === "\\") j++;
1437      j++;
1438    }
1439    return j < css.length ? j + 1 : css.length;
1440  }
1441  function stripComments(css) {
1442    let out = "";
1443    let quote = "";
1444    for (let i = 0; i < css.length; i++) {
1445      const c = css[i];
1446      if (quote) {
1447        if (c === "\\") {
1448          out += c + (css[i + 1] ?? "");
1449          i++;
1450          continue;
1451        }
1452        if (c === quote) quote = "";
1453        out += c;
1454      } else if (c === "'" || c === '"') {
1455        quote = c;
1456        out += c;
1457      } else if (c === "/" && css[i + 1] === "*") {
1458        const end = css.indexOf("*/", i + 2);
1459        i = end === -1 ? css.length : end + 1;
1460        out += " ";
1461      } else {
1462        const end = scanUnquotedUrl(css, i);
1463        if (end === -1) out += c;
1464        else {
1465          out += css.slice(i, end);
1466          i = end - 1;
1467        }
1468      }
1469    }
1470    return out;
1471  }
1472  function importantify(css) {
1473    css = stripComments(css);
1474    const decls = [];
1475    let start = 0;
1476    let depth = 0;
1477    let quote = "";
1478    for (let i = 0; i < css.length; i++) {
1479      const c = css[i];
1480      if (quote) {
1481        if (c === "\\") i++;
1482        else if (c === quote) quote = "";
1483      } else if (c === "'" || c === '"') quote = c;
1484      else if (c === "(") depth++;
1485      else if (c === ")") depth = Math.max(0, depth - 1);
1486      else if (c === ";" && depth === 0) {
1487        decls.push(css.slice(start, i));
1488        start = i + 1;
1489      } else {
1490        const end = scanUnquotedUrl(css, i);
1491        if (end !== -1) i = end - 1;
1492      }
1493    }
1494    decls.push(css.slice(start));
1495    return decls.map((d) => d.trim()).filter(Boolean).map((d) => /!\s*important$/i.test(d) ? d : d + " !important").join(";");
1496  }
1497  function createPseudoSheet(doc) {
1498    let el = null;
1499    const cache = /* @__PURE__ */ new Map();
1500    let n = 0;
1501    return (pseudo, css) => {
1502      const k = pseudo + "|" + css;
1503      const hit = cache.get(k);
1504      if (hit) return hit;
1505      if (!el) {
1506        el = doc.createElement("style");
1507        doc.head.appendChild(el);
1508      }
1509      const cls = "scp" + (n++).toString(36);
1510      const isPseudoElement = pseudo === "before" || pseudo === "after";
1511      const sel = isPseudoElement ? "." + cls + "::" + pseudo : "." + cls + ":" + pseudo;
1512      el.sheet.insertRule(
1513        sel + "{" + (isPseudoElement ? css : importantify(css)) + "}",
1514        el.sheet.cssRules.length
1515      );
1516      cache.set(k, cls);
1517      return cls;
1518    };
1519  }
1520
1521  
1521// src/registry.ts
1522  function createRegistry() {
1523    const entries = /* @__PURE__ */ Object.create(null);
1524    function get(name) {
1525      return entries[name] || (entries[name] = {
1526        html: "",
1527        tpl: null,
1528        Logic: null,
1529        jsStreaming: false,
1530        htmlStreaming: false,
1531        ver: 0,
1532        subs: /* @__PURE__ */ new Set(),
1533        fetched: false
1534      });
1535    }
1536    function bump(name) {
1537      const r = get(name);
1538      r.ver++;
1539      for (const fn of r.subs) fn();
1540    }
1541    return {
1542      entries,
1543      get,
1544      bump,
1545      bumpAll() {
1546        for (const n in entries) bump(n);
1547      }
1548    };
1549  }
1550
1551  
1551// src/runtime.ts
1552  var COMPONENT_DIR = (typeof window !== "undefined" && window.__BASE__) || "";
1553  function createRuntime(doc = document) {
1554    const registry = createRegistry();
1555    const pseudoClass = createPseudoSheet(doc);
1556    const helmet = createHelmetManager(
1557      doc,
1558      (name) => registry.get(name).htmlStreaming
1559    );
1560    const external = createExternalModules(() => registry.bumpAll());
1561    const factory = createComponentFactory(registry, ensureFetched);
1562    const host = {
1563      component: (name) => factory.getDC(name),
1564      placeholder: (props) => h(Placeholder, props),
1565      helmet: (node) => helmet.compile(node),
1566      loadExternal: (kind, url, after) => external.load(kind, url, after),
1567      resolveExternal: (url, name) => external.resolve(url, name),
1568      resolveExternalGlobal: (url, name) => external.resolveGlobal(url, name),
1569      resolveExternalError: (url, name) => external.getError(url, name),
1570      pseudoClass
1571    };
1572    function ensureFetched(name) {
1573      const r = registry.get(name);
1574      if (r.fetched) return;
1575      r.fetched = true;
1576      const url = COMPONENT_DIR + "/" + encodeURIComponent(name) + ".dc.html";
1577      const res = window.__resources;
1578      const pre = res ? res[url] : void 0;
1579      const target = typeof pre === "string" && pre ? pre : url;
1580      const blob = bundledBlob(target);
1581      (blob ? blob.text() : fetch(target).then((res2) => {
1582        if (!res2.ok) {
1583          console.error(
1584            '[dc-runtime] sibling fetch for "' + name + '" failed:',
1585            url,
1586            "returned",
1587            res2.status,
1588            "\u2014 the reference renders as an empty placeholder."
1589          );
1590          return "";
1591        }
1592        return res2.text();
1593      })).then((t) => {
1594        if (!t) return;
1595        const parsed = parseDcText(t);
1596        if (!parsed) {
1597          console.error(
1598            '[dc-runtime] sibling fetch for "' + name + '":',
1599            url,
1600            "has no <x-dc> block \u2014 not a Design Component."
1601          );
1602          return;
1603        }
1604        if (parsed.props) r.propsMeta = parsed.props;
1605        if (parsed.preview) r.preview = parsed.preview;
1606        if (parsed.template && !r.html) updateHtml(name, parsed.template);
1607        if (parsed.js && !r.Logic) updateJs(name, parsed.js);
1608      }).catch(
1609        (e) => console.error(
1610          '[dc-runtime] sibling fetch for "' + name + '" threw:',
1611          url,
1612          e
1613        )
1614      );
1615    }
1616    let rootName = null;
1617    function updateHtml(name, html) {
1618      const r = registry.get(name);
1619      r.html = html;
1620      if (name === rootName) {
1621        const mode = DESIGN_DOC_MODE_RE.exec(html)?.[1] ?? null;
1622        if (mode || !r.htmlStreaming) helmet.setDesignDocMode(mode);
1623      }
1624      try {
1625        r.tpl = compileTemplate(html, host);
1626      } catch (e) {
1627        console.error("[dc-runtime] template compile FAILED for", name, e);
1628      }
1629      registry.bump(name);
1630    }
1631    function updateJs(name, src) {
1632      const r = registry.get(name);
1633      const seq = r.jsSeq = (r.jsSeq || 0) + 1;
1634      try {
1635        const Cls = evalDcLogic(src);
1636        if (r.jsSeq !== seq) return;
1637        if (typeof Cls !== "function") {
1638          r.logicError = name + ".dc.html: <script data-dc-script> must define `class Component extends DCLogic`";
1639        } else {
1640          r.logicError = null;
1641          r.Logic = Cls;
1642        }
1643      } catch (e) {
1644        if (r.jsSeq !== seq) return;
1645        console.error(
1646          "[dc-runtime] logic class eval FAILED for",
1647          name,
1648          "\u2014 the template renders with props only.",
1649          e
1650        );
1651        r.logicError = name + ": " + (e instanceof Error && e.message ? e.message : String(e));
1652      }
1653      registry.bump(name);
1654    }
1655    function setStreaming(name, kind, on) {
1656      const r = registry.get(name);
1657      if (kind === "html") r.htmlStreaming = !!on;
1658      else r.jsStreaming = !!on;
1659      let any = false;
1660      for (const n in registry.entries) {
1661        const e = registry.entries[n];
1662        if (e && (e.htmlStreaming || e.jsStreaming)) {
1663          any = true;
1664          break;
1665        }
1666      }
1667      doc.documentElement.classList.toggle("sc-dc-streaming", any);
1668      registry.bump(name);
1669    }
1670    function dcUpdate(name, kind, content, streaming) {
1671      if (streaming) registry.get(name).fetched = true;
1672      if (kind === "html") {
1673        setStreaming(name, "html", !!streaming);
1674        updateHtml(name, content);
1675      }
1675 else if (kind === "js") {
1676        setStreaming(name, "js", !!streaming);
1677        if (!streaming) updateJs(name, content);
1678      } else if (kind === "props") {
1679        const { props, preview } = parseDataProps(content);
1680        const r = registry.get(name);
1681        r.propsMeta = props ?? void 0;
1682        r.preview = preview;
1683        registry.bump(name);
1684      }
1685    }
1686    function setProps(name, overrides) {
1687      registry.get(name).propOverrides = overrides && typeof overrides === "object" ? { ...overrides } : null;
1688      registry.bump(name);
1689    }
1690    function adoptParsed(name, parsed) {
1691      if (!parsed) return;
1692      const r = registry.get(name);
1693      if (parsed.props) r.propsMeta = parsed.props;
1694      if (parsed.preview) r.preview = parsed.preview;
1695      if (parsed.template) updateHtml(name, parsed.template);
1696      if (parsed.js) updateJs(name, parsed.js);
1697    }
1698    return {
1699      registry,
1700      getDC: factory.getDC,
1701      updateHtml,
1702      updateJs,
1703      dcUpdate,
1704      setProps,
1705      adoptParsed,
1706      setRootName: (name) => {
1707        rootName = name;
1708      },
1709      markFetched: (name) => {
1710        registry.get(name).fetched = true;
1711      },
1712      annotatedTemplate: (name) => {
1713        const r = registry.get(name);
1714        return r.tpl && r.tpl.__annotated || null;
1715      },
1716      templateSource: (name) => registry.get(name).html || null,
1717      StreamableLogic
1718    };
1719  }
1720
1721  
1721// src/stream-state.ts
1722  function createStreamTracker(staleMs = 6e4, now = Date.now) {
1723    const since = /* @__PURE__ */ new Map();
1724    const liveOne = (n) => {
1725      const t = since.get(n);
1726      if (t === void 0) return false;
1727      if (now() - t > staleMs) {
1728        since.delete(n);
1729        return false;
1730      }
1731      return true;
1732    };
1733    return {
1734      push(name, streaming, viewportKey) {
1735        if (viewportKey === "dc-model") return;
1736        if (streaming) since.set(name, now());
1737        else since.delete(name);
1738      },
1739      live(name) {
1740        if (name !== void 0) return liveOne(name);
1741        for (const n of [...since.keys()]) if (liveOne(n)) return true;
1742        return false;
1743      }
1744    };
1745  }
1746
1747  
1747// src/index.ts
1748  function hideRawTemplate() {
1749    const s = document.createElement("style");
1750    s.textContent = "x-dc{display:none!important}";
1751    document.head.appendChild(s);
1752  }
1753  function loadScript(src, integrity) {
1754    return new Promise((resolve2, reject) => {
1755      //! nosemgrep: create-script-element
1756      const s = document.createElement("script");
1757      s.src = src;
1758      if (integrity) {
1759        s.integrity = integrity;
1760        s.crossOrigin = "anonymous";
1761      }
1762      s.async = false;
1763      s.onload = () => resolve2();
1764      s.onerror = () => reject(new Error(`failed to load ${src}`));
1765      document.head.appendChild(s);
1766    });
1767  }
1768  function loadReactUmd() {
1769    const w = window;
1770    if (w.React && w.ReactDOM) return Promise.resolve();
1771    const react = cdnScriptFor(REACT_URL, REACT_SRI);
1772    const reactDom = cdnScriptFor(REACT_DOM_URL, REACT_DOM_SRI);
1773    return Promise.all([
1774      loadScript(react.src, react.integrity),
1775      loadScript(reactDom.src, reactDom.integrity)
1776    ]).then(() => void 0);
1777  }
1778  function init() {
1779    const runtime = createRuntime(document);
1780    let rootName = "Root";
1781    const baseCss = document.createElement("style");
1782    baseCss.textContent = BASE_CSS;
1783    document.head.prepend(baseCss);
1784    const notifyHost = () => {
1785      if (window.parent === window) return;
1786      const r = runtime.registry.entries[rootName];
1787      try {
1788        window.parent.postMessage(
1789          {
1790            type: "__dc_booted",
1791            rootName,
1792            propsMeta: r && r.propsMeta || null,
1793            preview: r && r.preview || null
1794          },
1795          "*"
1796        );
1797      } catch {
1798      }
1799    };
1800    const streams = createStreamTracker();
1801    const api = {
1802      __dcUpdate: (name, kind, content, streaming, viewportKey) => {
1803        streams.push(name, streaming, viewportKey);
1804        runtime.dcUpdate(name, kind, content, streaming);
1805        if (name === rootName && !streaming && kind === "props") notifyHost();
1806      },
1807      __dcStreaming: (name) => streams.live(name),
1808      __dcSetProps: (name, overrides) => runtime.setProps(name, overrides),
1809      /** Name of the component currently mounted as the page root — DC tools
1810       *  push their template-stream here when targeting "the open page". */
1811      __dcRootName: () => rootName,
1812      /** Editor bridge — the encoded, `data-dc-tpl`-annotated template source.
1813       *  The host editor parses this into its own template DOM so it can map a
1814       *  rendered node (carrying the same `data-dc-tpl`) back to the source
1815       *  node that emitted it. Returns the encoded form (`sc-camel-*` attrs,
1816       *  `<sc-raw-*>`/`<sc-helmet>` tags); the editor decodes on serialize. */
1817      __dcAnnotatedTemplate: (name) => runtime.annotatedTemplate(name),
1818      /** Editor bridge — the *original* (decoded) template source. */
1819      __dcTemplateSource: (name) => runtime.templateSource(name),
1820      __dcBoot: () => {
1821        rootName = boot(runtime, document) ?? rootName;
1822        notifyHost();
1823      },
1824      __dcRegistry: runtime.registry.entries,
1825      getDC: (name) => runtime.getDC(name),
1826      // `DCLogic` is the documented base class name; `StreamableLogic` is the
1827      // implementation alias kept for any project that already references it.
1828      DCLogic: runtime.StreamableLogic,
1829      StreamableLogic: runtime.StreamableLogic
1830    };
1831    Object.assign(window, api);
1832    window.__dcContentKeyed = true;
1833    if (document.readyState !== "loading") api.__dcBoot();
1834    else document.addEventListener("DOMContentLoaded", () => api.__dcBoot());
1835  }
1836  hideRawTemplate();
1837  loadReactUmd().then(init).catch((err) => {
1838    console.error("[dc] failed to load React or boot:", err);
1839    throw err;
1840  });
1841})();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.