@symbo.ls/brender 3.14.677 → 3.14.679

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,60 @@
1
1
  # @symbo.ls/brender
2
2
 
3
+ ## 3.14.679
4
+
5
+ ### Patch Changes
6
+
7
+ - c80283f: The faces a built page takes are the faces it draws (XMA r12 results, item 2). `window.__smblsFacesReady` and `brender.faces.inline: true` took every face of a family the page's styles name when any character of the page was in its range: a page that draws a family only in bold headings asked for its regular face too, and a page that draws TBCContractica 300/400/500/700 loaded 100 and 900 as well.
8
+
9
+ `@symbo.ls/brender` exports `drawnFaces(html, { readSheet })` (also `@symbo.ls/brender/drawnFaces`): which `@font-face` rules of the page's faces sheet its elements draw, read as the browser picks them — each element's family, weight and style from the cascade (`!important`, specificity, order, inheritance, `var()`, the `font` shorthand, the browser's bold headings, italic emphasis and system-font form controls), each character of its own text in the face of its family list that holds it (style, then weight, then `unicode-range`). Rules under `@media` / `@supports` / `@container` / `@layer` and for states (`:hover`, `:focus`, …) count as possibilities where they would win; `::placeholder` and the strings of `::before` / `::after` count. It returns `Map<rule index, characters>`, or `null` when a stylesheet of the page cannot be read.
10
+
11
+ `smbls build` uses it: `inline: true` inlines the faces the page draws, the list form the drawn faces of the listed families, and the function form gets `face.drawn` (the characters drawn in that face; `null` when the page was not read). The faces promise loads the drawn faces by address, each with a character drawn in it. The page's `<link rel="stylesheet">` files and their `@import`s are read from the build output; a page with a stylesheet the build cannot read, or a build with a brender that predates the reader, keeps the earlier rule. The log says on how many pages the drawn faces were read (`Faces drawn: read on N of M pages`), and the report says it per page (`facesRead`).
12
+
13
+ - Updated dependencies [bfef7bf]
14
+ - Updated dependencies [0e57128]
15
+ - Updated dependencies [9f253fc]
16
+ - Updated dependencies [9f253fc]
17
+ - Updated dependencies [de2f734]
18
+ - Updated dependencies [d9194ce]
19
+ - @symbo.ls/element@3.14.819
20
+ - @symbo.ls/utils@3.14.855
21
+ - smbls@3.14.862
22
+ - @symbo.ls/fetch@3.14.675
23
+ - @symbo.ls/helmet@3.14.674
24
+
25
+ ## 3.14.678
26
+
27
+ ### Patch Changes
28
+
29
+ - 9e31e2f: The faces sheet `<style data-smbls-faces>` carries `data-smbls-faces-version` (sha256 of the sheet's rules, 12 hex: equal rules give an equal version) and `data-smbls-faces-files` (per `@font-face`, in rule order, the first `url()` of its `src`; `-` for a rule with no file). The helpers (`facesSheetTag`, `facesSheetMarks`, `markFacesSheet`, `faceFileOf`) are exported from the root and from the new light subpath `@symbo.ls/brender/faces`. `smbls build` / `smbls brender` mark each page again after its `file:` URLs are mapped into the output, so the version follows the shipped files. No sheet file is written.
30
+
31
+ The built-page script defines `window.__smblsFacesReady`: a promise for the faces the page draws (`document.fonts.load` per family, weight and style). It resolves with the loaded `FontFace` objects, at the time limit (the hold cap, else 3000 ms) with the ones loaded so far, and at once with `[]` when the page has no faces. It never rejects. A property that already exists is kept.
32
+
33
+ `brender.app: { start: 'afterFirstView', after: 'faces' | '<window property>' | [ … ] }`: the app's files also wait for the page's faces promise and/or project promises (a property set later is watched; a rejection counts as in; the first input and `wait` still start the app). Without `after` the start is unchanged; `after` with an eager start is an error.
34
+
35
+ A failed AVIF `<source>` (the one whose `srcset` names the image's `currentSrc`) is taken out of its `<picture>` once, on the image's error or when it failed before the script ran; the browser then picks the WebP or the `<img>` src. No loop; an image still loading is untouched.
36
+
37
+ The built-page script stays hand-written ES5: 2,115 → 4,084 B raw, 760 → 1,363 B Brotli.
38
+
39
+ - 2522f1c: A server render keeps the rules a browser keeps that linkedom's CSS parser cannot read: `@container` (the breakpoints of `breakpointsFrom: 'container'`), `@layer`, `@scope`, `@starting-style`, and an `@media` / `@supports` that holds one. They were dropped, so the page's classes went into the markup without their rules and a phone's first frame showed the desktop layout.
40
+
41
+ `smbls publish --ssr` honours a page's `prerender: false` and symbols.json `brender.exclude`, as `smbls build` and `smbls brender` do: an opted-out page costs no render and no budget, and the publish report lists it.
42
+
43
+ Page code that throws after its render (a timer, an animation frame, a rejected promise) is reported once per message and never ends the publish; each server window has its own timers.
44
+
45
+ - Updated dependencies [2522f1c]
46
+ - Updated dependencies [2522f1c]
47
+ - Updated dependencies [f718247]
48
+ - Updated dependencies [c21bff7]
49
+ - Updated dependencies [c62254b]
50
+ - Updated dependencies [77a4634]
51
+ - Updated dependencies [0d684b1]
52
+ - @symbo.ls/fetch@3.14.674
53
+ - smbls@3.14.860
54
+ - @symbo.ls/utils@3.14.854
55
+ - @symbo.ls/helmet@3.14.673
56
+ - @symbo.ls/scratch@3.14.796
57
+
3
58
  ## 3.14.677
4
59
 
5
60
  ### Patch Changes
package/README.md CHANGED
@@ -198,6 +198,18 @@ No inline script — a strict Content-Security-Policy (`script-src 'self'`, no `
198
198
  | `<script type="application/json" data-fetch-seed>[…]</script>` | after the markup | The anonymous GET answers the render got (`@symbo.ls/fetch`), adopted by the client request that sends exactly the same request |
199
199
  | `<meta name="brender-stamp" content="<stamp>" data-time="<ms>">` | `<head>`, after the mark | The build the page comes from: `stamp` (the `stamp` option, else the render time as an ISO string) and the render time in ms. App code reads it as `el.context.prerender` (`{ stamp, time }`) |
200
200
  | `<link rel="expect" href="#smbls-whole" blocking="render">` + `<template id="smbls-whole">` | after the charset declaration; after the markup | `paint: { whole: true }` only: the first paint waits for the whole markup |
201
+ | `<style data-smbls-faces data-smbls-faces-version="…" data-smbls-faces-files="…">` | `<head>`, ahead of the page's styles | Every `@font-face` rule of the page, in one sheet, with two marks for a host (below). Only when the page has faces |
202
+
203
+ **The faces sheet and its marks.** A host that serves a returning reader the faces it keeps by address, and the rest inline, reads two marks on the sheet; brender writes no other faces file:
204
+
205
+ | Mark | Value |
206
+ |------|-------|
207
+ | `data-smbls-faces-version` | A content hash of the sheet's rules (12 hex characters): equal rules in the same order give the same version on every page and every render; any change to a rule (a file, a range, a `font-display`), a rule more or less, or another order gives a new one. |
208
+ | `data-smbls-faces-files` | Per `@font-face` rule, in rule order, its file address: the first `url()` of its `src` — a `local()` before it is skipped, a later `url()` (another format) is not listed — as the rule names it. `-` for a rule that names no file (only `local()`, or a `data:` URL). Space-separated; a space in an address is written `%20`. |
209
+
210
+ The marks describe the faces by address. `smbls build` marks each page again after its `file:` URLs point into the build output, so the version follows the files the page ships (every page of a build carries the same one when the font URLs are site-root or absolute; a relative URL differs by the page's directory, and so does the version). Its `brender.faces.inline` step moves files into the sheet as `data:` URLs and keeps both marks as they were: an inlined face still names its file. A tool that changes the addresses in a page itself calls `markFacesSheet(html)` (exported): it writes both marks again from the rules the sheet holds, leaves the sheet's text and its other attributes as they are, and returns a page without a faces sheet unchanged. `facesSheetMarks(rules)` returns `{ version, files }` for a sheet's text or its rules (`null` without a `@font-face`).
211
+
212
+ **The faces a page draws.** `drawnFaces(html, { readSheet })` (exported, also as `@symbo.ls/brender/drawnFaces`) reads which faces of the sheet the page's elements draw, as the browser picks them: each element's family, weight and style from the cascade (`!important`, specificity, order, inheritance, `var()`, the `font` shorthand, the browser's own rules for headings, emphasis and form controls), each character of its text against the faces' `unicode-range`. Rules under `@media` / `@supports` / `@container` / `@layer` and for states (`:hover`, …) count as possibilities. It returns a `Map` from a `@font-face` rule's index in the sheet to the characters drawn in it, or `null` when a stylesheet of the page cannot be read: `readSheet(href, from)` returns the text of a `<link rel="stylesheet">` file or an `@import` (`from`: the address of the sheet that imports it), or `null`. A `<link data-smbls-font>` (a font service's `@font-face` sheet) is not read. `smbls build` uses it for `brender.faces.inline: true` and `window.__smblsFacesReady` (CLI README, "Which faces a page draws").
201
213
 
202
214
  The runtime also reads what pages from brender up to 3.14.664 carry — the inline `window.__BRENDER__` flag, `window.__BR_REGISTRY__`, `window.__BRENDER_HYDRATE__` — and, when a policy blocked that flag, takes a `data-br` element directly in the mount node for the mark. An smbls runtime older than this format does not know the `<meta>`: keep `smbls` and `@symbo.ls/brender` at the same release.
203
215
 
@@ -0,0 +1,3 @@
1
+ import{parseHTML as ue}from"linkedom";import{stylesheetRules as he}from"./pageWeight.js";const G=/<style\b[^>]*\bdata-smbls-faces\b[^>]*>([\s\S]*?)<\/style\s*>/i,me=/@font-face\s*\{([^}]*)\}/gi,de=/<(script|template|noscript)\b([^>]*)>[\s\S]*?<\/\1\s*>/gi,H=8,J=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","math","emoji","fangsong","-apple-system","blinkmacsystemfont"]),pe=new Set(["hover","focus","focus-visible","focus-within","active","visited","link","any-link","target","target-within","checked","indeterminate","default","disabled","enabled","read-only","read-write","required","optional","valid","invalid","user-valid","user-invalid","in-range","out-of-range","placeholder-shown","autofill","-webkit-autofill","open","closed","popover-open","modal","fullscreen","picture-in-picture","playing","paused","current","past","future","defined","lang","dir","state","blank","local-link","scope","host","host-context"]),V=new Set(["before","after","first-line","first-letter"]),B=new Set(["is","where","matches","-webkit-any","-moz-any","has"]),ge=`h1,h2,h3,h4,h5,h6,th{font-weight:bold}b,strong{font-weight:bolder}
2
+ em,i,cite,var,dfn,address{font-style:italic}code,kbd,samp,pre,tt,listing,xmp,plaintext{font-family:monospace}
3
+ input,textarea,select,button{font-family:system-ui;font-weight:400;font-style:normal}`,P=new Set(["font","font-family","font-weight","font-style"]),F=/^\s*(?:only\s+)?(?:all|screen)\s*$/i,K=/var\(\s*(--[\w-]+)/g,q=(t,s)=>{let n=0,o=null;for(let r=s;r<t.length;r++){const e=t[r];if(o){e==="\\"?r++:e===o&&(o=null);continue}if(e==='"'||e==="'")o=e;else if(e==="(")n++;else if(e===")"&&!--n)return r}return-1},L=(t,s)=>{const n=[];let o=0,r=null,e=0;for(let i=0;i<t.length;i++){const l=t[i];if(r){l==="\\"?i++:l===r&&(r=null);continue}l==='"'||l==="'"?r=l:l==="("||l==="["||l==="{"?o++:l===")"||l==="]"||l==="}"?o=Math.max(0,o-1):l===s&&!o&&(n.push(t.slice(e,i)),e=i+1)}return n.push(t.slice(e)),n},X=/[\w\- -￿]/,C=(t,s)=>{let n=s;for(;n<t.length;)if(t[n]==="\\")n+=2;else if(X.test(t[n]))n++;else break;return n},Q=t=>{let s=0,n=0,o=0;const r=e=>{s+=Math.floor(e/1e6),n+=Math.floor(e/1e3)%1e3,o+=e%1e3};for(let e=0;e<t.length;){const i=t[e];if(i==='"'||i==="'"){const l=t.indexOf(i,e+1);e=l===-1?t.length:l+1}else if(i==="#")s++,e=C(t,e+1);else if(i===".")n++,e=C(t,e+1);else if(i==="["){n++;const l=t.indexOf("]",e);e=l===-1?t.length:l+1}else if(i===":"){const l=t[e+1]===":",u=e+(l?2:1),f=C(t,u),h=t.slice(u,f).toLowerCase();let g=null,a=f;if(t[f]==="("){const m=q(t,f);g=t.slice(f+1,m===-1?t.length:m),a=m===-1?t.length:m+1}l||V.has(h)?o++:h==="where"||(B.has(h)||h==="not"?g&&r(Math.max(0,...L(g,",").map(m=>Q(m.trim())))):n++),e=a}else i==="*"||i===">"||i==="+"||i==="~"||i==="|"||/\s/.test(i)?e++:X.test(i)||i==="\\"?(o++,e=C(t,e)):e++}return s*1e6+n*1e3+o},Z=t=>{let s=!1,n="element";return{text:(e=>{let i="";for(let l=0;l<e.length;){const u=e[l];if(u==='"'||u==="'"){const f=e.indexOf(u,l+1),h=f===-1?e.length:f+1;i+=e.slice(l,h),l=h}else if(u==="["){const f=e.indexOf("]",l),h=f===-1?e.length:f+1;i+=e.slice(l,h),l=h}else if(u===":"){const f=e[l+1]===":",h=l+(f?2:1),g=C(e,h),a=e.slice(h,g).toLowerCase();let m=null,O=g;if(e[g]==="("){const d=q(e,g);m=e.slice(g+1,d===-1?e.length:d),O=d===-1?e.length:d+1}if(f||V.has(a))a==="placeholder"||a==="-webkit-input-placeholder"||a==="-moz-placeholder"?n="placeholder":a==="before"||a==="after"?n=a:a==="first-line"||a==="first-letter"?s=!0:n=null,i+=":is(*)";else if(a==="not"&&m!==null){const d=ee(m);d.conditional?(s=!0,i+=":is(*)"):i+=`:not(${d.text})`}else if(B.has(a)&&m!==null){const d=ee(m);d.conditional&&(s=!0),i+=`:${a==="matches"||a.endsWith("-any")?"is":a}(${d.text||"*"})`}else pe.has(a)||a.startsWith("-webkit-")||a.startsWith("-moz-")?(s=!0,i+=":is(*)"):i+=e.slice(l,O);l=O}else i+=u,l++}return i})(t),conditional:s,target:n}},ye=t=>{let s="";for(let n=0;n<t.length;){const o=t[n];if(o==='"'||o==="'"||o==="["){const r=t.indexOf(o==="["?"]":o,n+1),e=r===-1?t.length:r+1;s+=t.slice(n,e),n=e}else if(o===":"){let r=C(t,n+(t[n+1]===":"?2:1));if(t[r]==="("){const e=q(t,r);r=e===-1?t.length:e+1}s+=":is(*)",n=r}else s+=o,n++}return s},ee=t=>{let s=!1;return{text:L(t,",").map(o=>{const r=Z(o.trim());return r.conditional&&(s=!0),r.text||"*"}).join(", "),conditional:s}},te=t=>{const s=[];for(const n of L(t.replace(/\/\*[\s\S]*?\*\//g,""),";")){if(n.includes("{"))continue;const o=n.indexOf(":");if(o===-1)continue;const r=n.slice(0,o).trim(),e=r.startsWith("--")?r:r.toLowerCase();if(!P.has(e)&&e!=="content"&&!e.startsWith("--"))continue;let i=n.slice(o+1).trim();const l=/!\s*important\s*$/i.test(i);l&&(i=i.replace(/!\s*important\s*$/i,"").trim()),s.push({prop:e,value:i,important:l})}return s},we=/^@import\s+(?:url\(\s*)?(['"]?)([^'")\s]+)\1\s*\)?\s*([^;]*)/i,T=(t,s,n,o,r=null,e=[])=>{const i=he(t);if(!i)return n.unknown=!0,e;for(const l of i){const u=l.indexOf("{");if(u===-1){const a=we.exec(l);if(!a)continue;const m=n.readSheet?n.readSheet(a[2],o):null;typeof m!="string"?n.unknown=!0:T(m,s||!!a[3].trim()&&!F.test(a[3]),n,a[2],r,e);continue}if(!l.endsWith("}"))continue;const f=l.slice(0,u).trim(),h=l.slice(u+1,-1);if(f[0]==="@"){const a=(/^@([\w-]+)/.exec(f)||[])[1]?.toLowerCase();a==="media"?T(h,s||!F.test(f.slice(6)),n,o,r,e):(a==="supports"||a==="container"||a==="document"||a==="scope"||a==="starting-style"||a==="layer")&&T(h,!0,n,o,r,e);continue}const g=r?L(f,",").map(a=>a.includes("&")?a.replace(/&/g,`:is(${r})`):`:is(${r}) ${a.trim()}`).join(", "):f;if(e.push({selector:g,block:h,conditional:s}),h.includes("{")){const a=h.slice(h.search(/[^;{}]*\{/));T(a,s,n,o,g,e)}}return e},N=(t,s,n=0)=>{const o=t.indexOf("var(");if(o===-1)return[t];if(n>8)return[];const r=q(t,o+3);if(r===-1)return[];const e=t.slice(o+4,r),i=L(e,","),l=i[0].trim(),u=i.length>1?i.slice(1).join(",").trim():null,f=s.get(l),h=f&&f.length?f:u!==null?N(u,s,n+1):[],g=[];for(const a of h)for(const m of N(t.slice(0,o)+a+t.slice(r+1),s,n+1))if(g.includes(m)||g.push(m),g.length>=H)return g;return g},ne=t=>t.trim().replace(/^(['"])([\s\S]*)\1$/,"$2").replace(/\\(.)/g,"$1").trim().toLowerCase(),be=t=>L(t,",").map(ne).filter(Boolean),se={normal:400,bold:700},oe=(t,s)=>{const n=String(t).trim().toLowerCase();if(n in se)return se[n];if(n==="bolder")return s<350?400:s<550?700:900;if(n==="lighter")return s<550?100:s<750?400:700;const o=Number(n);return Number.isFinite(o)&&o>=1&&o<=1e3?o:null},ie=t=>{const s=String(t).trim().toLowerCase().split(/\s+/)[0];return s==="italic"||s==="oblique"||s==="normal"?s:null},Se=/\\([0-9a-f]{1,6})\s?|\\([\s\S])/gi,ke=(t,s)=>{let n="";for(const o of t.matchAll(/(["'])((?:\\[\s\S]|(?!\1)[^\\])*)\1|attr\(\s*([\w-]+)[^)]*\)/gi))o[3]?n+=s.getAttribute(o[3])||"":n+=o[2].replace(Se,(r,e,i)=>{if(!e)return i;const l=parseInt(e,16);return l>0&&l<=1114111?String.fromCodePoint(l):"\uFFFD"});return n},ve=new Set(["caption","icon","menu","message-box","small-caption","status-bar"]),Oe=t=>{const s=t.trim();if(ve.has(s.toLowerCase()))return{family:"system-ui",weight:"normal",style:"normal"};const n=[];let o=s;for(;;){const u=/^\s*([^\s,'"]+)/.exec(o);if(!u)break;const f=u[1];if(/^[\d.]/.test(f)&&!/^\d{1,4}$/.test(f)||/^\d{1,4}$/.test(f)&&Number(f)>1e3)break;const h=f.toLowerCase();if(/^(xx-small|x-small|small|medium|large|x-large|xx-large|xxx-large|larger|smaller|calc\(|clamp\(|min\(|max\()/.test(h)||(n.push(h),o=o.slice(u[0].length),n.length>4))break}const r=/^\s*(?:[^\s/]+|(?:calc|clamp|min|max)\([^)]*\))(?:\s*\/\s*[^\s]+)?\s+/.exec(o);if(!r)return null;const e=o.slice(r[0].length).trim();if(!e)return null;let i="normal",l="normal";for(const u of n)u==="italic"||u==="oblique"?l=u:(u==="bold"||u==="bolder"||u==="lighter"||/^\d{1,4}$/.test(u))&&(i=u);return{family:e,weight:i,style:l}},_=(t,s)=>{const n=new RegExp(`(?:^|;|\\s)${s}\\s*:\\s*([^;]+)`,"i").exec(t);return n?n[1].trim():null},Ae=t=>{if(!t)return null;const s=[];for(const n of String(t).split(",")){const o=n.trim().replace(/^u\+/i,"");if(!o)continue;if(o.includes("?")){s.push([parseInt(o.replace(/\?/g,"0"),16),parseInt(o.replace(/\?/g,"f"),16)]);continue}const[r,e]=o.split("-"),i=parseInt(r,16);s.push([i,e?parseInt(e,16):i])}return s.length?s:null},Ee=t=>{const s=[];let n=0;for(const o of t.matchAll(me)){const r=o[1],e=ne(_(r,"font-family")||""),i=String(_(r,"font-weight")||"400").trim().split(/\s+/).map(l=>oe(l,400)||400);s.push({index:n++,family:e,min:Math.min(...i),max:Math.max(...i),style:ie(_(r,"font-style")||"normal")||"normal",ranges:Ae(_(r,"unicode-range"))})}return s},le={italic:["italic","oblique","normal"],oblique:["oblique","italic","normal"],normal:["normal","oblique","italic"]},xe=(t,s)=>{for(const n of le[s]||le.normal){const o=t.filter(r=>r.style===n);if(o.length)return o}return t},Me=(t,s)=>{const n=t.filter(i=>i.min<=s&&s<=i.max);if(n.length)return n;const o=t.filter(i=>i.max<s).sort((i,l)=>l.max-i.max),r=t.filter(i=>i.min>s).sort((i,l)=>i.min-l.min);let e;return s>=400&&s<=500?e=r.find(i=>i.min<=500)||o[0]||r[0]:s<400?e=o[0]||r[0]:e=r[0]||o[0],e?t.filter(i=>i.min===e.min&&i.max===e.max):[]},Le=(t,s)=>!t.ranges||t.ranges.some(([n,o])=>s>=n&&s<=o),re=t=>t.ua?0:t.important?2:1,ce=(t,s)=>{const n=re(t),o=re(s);return n!==o?n>o:t.rank!==s.rank?t.rank>s.rank:t.order>s.order},D=t=>{let s=null;for(const o of t)!o.conditional&&(!s||ce(o,s))&&(s=o);const n=s?[s]:[];for(const o of t)o.conditional&&(!s||ce(o,s))&&n.push(o);return{list:n,inherit:!s}},U=t=>{const s=[],n=new Set;for(const o of t){const r=JSON.stringify(o);if(!n.has(r)&&(n.add(r),s.push(o),s.length>=H))break}return s},ae=(t,s)=>{K.lastIndex=0;let n;for(;n=K.exec(t);)s.add(n[1]);return s},fe={vars:new Map,family:[["serif"]],weight:[400],style:["normal"]},Ce=new Set(["script","style","template","noscript","head","title"]),Y=(t,s)=>{const n=new Map(s.vars),o=[...new Set(t.filter(e=>e.prop.startsWith("--")).map(e=>e.prop))];for(const e of o){const{list:i,inherit:l}=D(t.filter(f=>f.prop===e)),u=l?[...s.vars.get(e)||[]]:[];for(const f of i){const h=f.value.trim();/^(inherit|unset)$/i.test(h)?u.push(...s.vars.get(e)||[]):/^(initial|revert|revert-layer)$/i.test(h)||u.push(h)}n.set(e,U(u))}for(const e of o)n.set(e,U(n.get(e).flatMap(i=>N(i,n))));const r={vars:n};for(const e of["family","weight","style"]){const i="font-"+e,{list:l,inherit:u}=D(t.filter(h=>h.prop===i||h.prop==="font")),f=u?[...s[e]]:[];for(const h of l){const g=f.length;for(const a of N(h.value,n)){const m=a.trim().toLowerCase();if(m==="inherit"||m==="unset"){f.push(...s[e]);continue}if(m==="initial"||m==="revert"||m==="revert-layer"){f.push(...fe[e]);continue}let O=a;if(h.prop==="font"){const d=Oe(a);if(!d)continue;O=d[e]}if(e==="family")f.push(be(O));else if(e==="style"){const d=ie(O);d&&f.push(d)}else for(const d of s.weight){const $=oe(O,d);$&&f.push($)}}f.length===g&&f.push(...s[e])}r[e]=U(f)}return r},Ne=(t,s={})=>{const n=new Map,o=G.exec(t);if(!o)return n;const r=Ee(o[1]);if(!r.length)return n;const e=new Map;for(const c of r)e.has(c.family)||e.set(c.family,[]),e.get(c.family).push(c);const i=t.replace(G,"<style data-smbls-faces></style>").replace(de,"<$1$2></$1>"),{document:l}=ue(i),u={readSheet:typeof s.readSheet=="function"?s.readSheet:null,unknown:!1},f=[],h=(c,y,w,b)=>{for(const S of T(c,y,u,b)){const p=te(S.block);p.length&&f.push({selector:S.selector,decls:p,conditional:S.conditional,ua:w})}};h(ge,!1,!0);for(const c of l.querySelectorAll("style, link")){const y=c.getAttribute("media"),w=!!y&&!F.test(y);if(c.localName==="style"){c.hasAttribute("data-smbls-faces")||h(c.textContent||"",w,!1);continue}const b=(c.getAttribute("rel")||"").toLowerCase().split(/\s+/);if(!b.includes("stylesheet")||c.hasAttribute("data-smbls-font")||c.hasAttribute("disabled"))continue;const S=c.getAttribute("href")||"",p=u.readSheet&&S?u.readSheet(S):null;if(typeof p!="string")return null;h(p,w||b.includes("alternate"),!1,S)}if(u.unknown)return null;const g=[];for(const c of l.querySelectorAll("[style]")){const y=te(c.getAttribute("style")||"");y.length&&g.push({el:c,decls:y})}const a=new Set,m=[...f.flatMap(c=>c.decls),...g.flatMap(c=>c.decls)];for(const c of m)(P.has(c.prop)||c.prop==="content")&&ae(c.value,a);for(let c=-1;c!==a.size;){c=a.size;for(const y of m)a.has(y.prop)&&ae(y.value,a)}const O=c=>P.has(c.prop)||c.prop==="content"||a.has(c.prop),d={element:new Map,placeholder:new Map,before:new Map,after:new Map};let $=0;for(const c of f){const y=c.decls.filter(O);if(y.length)for(const w of L(c.selector,",")){const b=w.trim();if(!b)continue;let{text:S,conditional:p,target:E}=Z(b);if(!E)continue;let k;try{k=l.querySelectorAll(S)}catch{try{k=l.querySelectorAll(ye(S))}catch{continue}p=!0}const A=c.ua?0:Q(b),x=y.map(v=>({...v,rank:A,order:++$,conditional:p||c.conditional,ua:c.ua})),M=d[E];for(const v of k)M.has(v)||M.set(v,[]),M.get(v).push(...x)}}for(const{el:c,decls:y}of g){const w=y.filter(O);w.length&&(d.element.has(c)||d.element.set(c,[]),d.element.get(c).push(...w.map(b=>({...b,rank:1e9,order:++$,conditional:!1,ua:!1}))))}const I=new Map,W=(c,y)=>{if(y.trim())for(const w of c.family)for(const b of c.weight)for(const S of c.style){const p=JSON.stringify([w,b,S]);I.set(p,(I.get(p)||"")+y)}},j=(c,y)=>{const w=Y(d.element.get(c)||[],y);let b="";for(const p of c.childNodes)p.nodeType===3?b+=p.textContent:p.nodeType===1&&!Ce.has(p.localName)&&j(p,w);const S=c.localName;if(S==="input"||S==="textarea"){b+=" "+(c.getAttribute("value")||"");const p=c.getAttribute("placeholder");p&&W(d.placeholder.has(c)?Y(d.placeholder.get(c),w):w,p)}W(w,b);for(const p of["before","after"]){const E=d[p].get(c);if(!E)continue;const k=Y(E,w);for(const A of D(E.filter(x=>x.prop==="content")).list)for(const x of N(A.value,k.vars))W(k,ke(x,c))}};l.documentElement&&j(l.documentElement,fe);for(const[c,y]of I){const[w,b,S]=JSON.parse(c),p=new Map;for(const k of w){if(J.has(k))break;const A=e.get(k);A&&!p.has(k)&&p.set(k,Me(xe(A,S),b))}if(!p.size)continue;const E=new Set;for(const k of y){if(E.has(k))continue;E.add(k);const A=k.codePointAt(0);if(!(A<=32||A===160))for(const x of w){if(J.has(x))break;const M=p.get(x)||[];let v=null;for(let R=M.length-1;R>=0&&!v;R--)Le(M[R],A)&&(v=M[R]);if(!v)continue;const z=n.get(v.index)||"";z.includes(k)||n.set(v.index,z+k);break}}}return n};export{Ne as drawnFaces};
package/dist/esm/env.js CHANGED
@@ -1 +1 @@
1
- import{parseHTML as f}from"linkedom";const p=new WeakSet;class y{static[Symbol.hasInstance](e){return p.has(e)}}const m=o=>{let e=Object.getPrototypeOf(o.createElement("select")),t;for(;e&&!(t=Object.getOwnPropertyDescriptor(e,"value"));)e=Object.getPrototypeOf(e);!e||!t||!t.get||t.set||Object.defineProperty(e,"value",{configurable:!0,enumerable:t.enumerable,get:t.get,set(l){const s=l==null?"":String(l);let n=!1;for(const i of this.querySelectorAll("option")){const r=i.hasAttribute("value")?i.getAttribute("value"):i.textContent;!n&&r===s?(i.setAttribute("selected",""),n=!0):i.removeAttribute("selected")}}})},h=Symbol.for("@symbo.ls/brender:styleMap"),b=o=>typeof o=="string"&&o.charCodeAt(0)===45&&o.charCodeAt(1)===45,d=o=>{let e=Object.getPrototypeOf(o.createElement("div").style);for(;e&&!Object.prototype.hasOwnProperty.call(e,"setProperty");)e=Object.getPrototypeOf(e);if(!e||Object.prototype.hasOwnProperty.call(e,h))return;const{setProperty:t,removeProperty:l,getPropertyValue:s}=e;if(typeof t!="function"||typeof l!="function"||typeof s!="function")return;Object.defineProperty(e,h,{configurable:!0,get(){return this}});const n=(r,a)=>{let c="";for(;a.has(c);)c+=" ";l.call(r,c)},i=(r,a,c)=>{const u=r[h];n(r,u),c==null?u.delete(a):u.set(a,c),n(r,u)};Object.defineProperties(e,{setProperty:{configurable:!0,writable:!0,value:function(r,a){if(!b(r))return t.apply(this,arguments);i(this,r,a)}},removeProperty:{configurable:!0,writable:!0,value:function(r){if(!b(r))return l.apply(this,arguments);i(this,r,null)}},getPropertyValue:{configurable:!0,writable:!0,value:function(r){return b(r)?(s.call(this,r),this[h].get(r)):s.apply(this,arguments)}}})},g=()=>{const o={};return{getItem:e=>o[e]??null,setItem:(e,t)=>{o[e]=String(t)},removeItem:e=>{delete o[e]},clear:()=>{for(const e in o)delete o[e]},get length(){return Object.keys(o).length},key:e=>Object.keys(o)[e]??null}},T=(o="<!DOCTYPE html><html><head></head><body></body></html>")=>{const e={location:{pathname:"/",search:"",hash:"",origin:"http://localhost",protocol:"http:",host:"localhost",hostname:"localhost",port:"",href:"http://localhost/"},localStorage:g(),sessionStorage:g(),history:{pushState:()=>{},replaceState:()=>{},state:null}},{window:t,document:l}=f(o,e);return t.requestAnimationFrame||(t.requestAnimationFrame=s=>{const n=setTimeout(s,0);return n?.unref&&n.unref(),n}),t.cancelAnimationFrame||(t.cancelAnimationFrame=s=>clearTimeout(s)),t.URL||(t.URL=URL),t.scrollTo||(t.scrollTo=()=>{}),globalThis.localStorage=e.localStorage,globalThis.sessionStorage=e.sessionStorage,globalThis.history||(globalThis.history=e.history),m(l),d(l),t.MutationObserver||(t.MutationObserver=class{constructor(){}observe(){}disconnect(){}takeRecords(){return[]}}),globalThis.window=t,globalThis.document=l,globalThis.Node=t.Node||globalThis.Node,globalThis.Element=t.Element||globalThis.Element,globalThis.HTMLElement=t.HTMLElement||globalThis.HTMLElement,globalThis.MutationObserver=t.MutationObserver,p.add(t),t.constructor&&t.constructor!==Object?globalThis.Window=t.constructor:(typeof globalThis.Window!="function"||globalThis.Window===Object)&&(globalThis.Window=y),{window:t,document:l}};export{T as createEnv};
1
+ import{parseHTML as A}from"linkedom";const S=new WeakSet;class M{static[Symbol.hasInstance](t){return S.has(t)}}const C=r=>{let t=Object.getPrototypeOf(r.createElement("select")),e;for(;t&&!(e=Object.getOwnPropertyDescriptor(t,"value"));)t=Object.getPrototypeOf(t);!t||!e||!e.get||e.set||Object.defineProperty(t,"value",{configurable:!0,enumerable:e.enumerable,get:e.get,set(o){const s=o==null?"":String(o);let i=!1;for(const l of this.querySelectorAll("option")){const n=l.hasAttribute("value")?l.getAttribute("value"):l.textContent;!i&&n===s?(l.setAttribute("selected",""),i=!0):l.removeAttribute("selected")}}})},d=Symbol.for("@symbo.ls/brender:styleMap"),w=r=>typeof r=="string"&&r.charCodeAt(0)===45&&r.charCodeAt(1)===45,U=r=>{let t=Object.getPrototypeOf(r.createElement("div").style);for(;t&&!Object.prototype.hasOwnProperty.call(t,"setProperty");)t=Object.getPrototypeOf(t);if(!t||Object.prototype.hasOwnProperty.call(t,d))return;const{setProperty:e,removeProperty:o,getPropertyValue:s}=t;if(typeof e!="function"||typeof o!="function"||typeof s!="function")return;Object.defineProperty(t,d,{configurable:!0,get(){return this}});const i=(n,c)=>{let u="";for(;c.has(u);)u+=" ";o.call(n,u)},l=(n,c,u)=>{const a=n[d];i(n,a),u==null?a.delete(c):a.set(c,u),i(n,a)};Object.defineProperties(t,{setProperty:{configurable:!0,writable:!0,value:function(n,c){if(!w(n))return e.apply(this,arguments);l(this,n,c)}},removeProperty:{configurable:!0,writable:!0,value:function(n){if(!w(n))return o.apply(this,arguments);l(this,n,null)}},getPropertyValue:{configurable:!0,writable:!0,value:function(n){return w(n)?(s.call(this,n),this[d].get(n)):s.apply(this,arguments)}}})},T=Symbol.for("@symbo.ls/brender:groupRules"),W=/^@(container|layer|scope|starting-style|media|supports)(?![\w-])/i,_=/^@layer\s+[-\w.]+(?:\s*,\s*[-\w.]+)*\s*;?$/i,I={media:4,supports:12},O=r=>{const t=[];let e=0,o=0,s=null;const i=l=>{const n=r.slice(o,l).trim();n&&t.push(n),o=l};for(let l=0;l<r.length;l++){const n=r[l];if(s){n==="\\"?l++:n===s&&(s=null);continue}if(n==="\\"){l++;continue}if(n==="/"&&r[l+1]==="*"){const c=r.indexOf("*/",l+2);if(c===-1)return null;e===0&&!r.slice(o,l).trim()&&(o=c+2),l=c+1;continue}if(n==='"'||n==="'")s=n;else if(n==="{")e++;else if(n==="}"){if(e===0)return null;--e===0&&i(l+1)}else n===";"&&e===0&&i(l+1)}return s||e?null:(i(r.length),t)};class R{constructor(t,e,o){this.keyword=t,this.condition=e,this.cssRules=o,this.parentRule=null,this.parentStyleSheet=null;for(const s of o)s.parentRule=this}get type(){return I[this.keyword]||0}get conditionText(){return this.condition}get name(){return this.keyword==="layer"?this.condition:void 0}get cssText(){let t="";for(const e of this.cssRules)t+=e.cssText;return`@${this.keyword}${this.condition?" "+this.condition:""} {${t}}`}}class ${constructor(t){this.nameList=t,this.parentRule=null,this.parentStyleSheet=null}get type(){return 0}get cssText(){return`@layer ${this.nameList.join(", ")};`}}const N=(r,t)=>{const e={cssRules:[]};let o=null;try{if(t.call(e,r,0),e.cssRules[0])return e.cssRules[0]}catch(i){o=i}const s=P(String(r).trim(),t);if(s)return s;throw o||new SyntaxError(`Failed to parse the rule '${r}'`)},P=(r,t)=>{if(_.test(r))return new $(r.replace(/^@layer\s+/i,"").replace(/\s*;$/,"").split(/\s*,\s*/));const e=W.exec(r);if(!e)return null;const o=O(r);if(!o||o.length!==1||!r.endsWith("}"))return null;const s=q(r);if(s===-1)return null;const i=O(r.slice(s+1,-1));if(!i)return null;const l=[];for(const n of i)try{l.push(N(n,t))}catch{return null}return new R(e[1].toLowerCase(),r.slice(e[0].length,s).trim(),l)},q=r=>{let t=null;for(let e=0;e<r.length;e++){const o=r[e];if(t){o==="\\"?e++:o===t&&(t=null);continue}if(o==="\\"){e++;continue}if(o==="/"&&r[e+1]==="*"){const s=r.indexOf("*/",e+2);if(s===-1)return-1;e=s+1;continue}if(o==='"'||o==="'")t=o;else if(o==="{")return e}return-1},E=(r,t)=>{if(r.parentStyleSheet=t,r instanceof R)for(const e of r.cssRules)E(e,t)},F=r=>{const t=r.createElement("style");let e;try{e=t.sheet}catch{return}let o=e&&Object.getPrototypeOf(e);for(;o&&!Object.prototype.hasOwnProperty.call(o,"insertRule");)o=Object.getPrototypeOf(o);if(!o||Object.prototype.hasOwnProperty.call(o,T))return;const s=o.insertRule;if(typeof s!="function")return;const i=e.constructor;Object.defineProperty(o,T,{configurable:!0,value:!0}),Object.defineProperty(o,"insertRule",{configurable:!0,writable:!0,value:function(p,h){try{return s.apply(this,arguments)}catch(b){const f=String(p),g=P(f.trim(),s);if(!g)throw b;const y=h===void 0?0:Number(h);if(!(y>=0&&y<=this.cssRules.length))throw new RangeError("INDEX_SIZE_ERR");return E(g,this),this.cssRules.splice(y,0,g),y}}});let l=Object.getPrototypeOf(t),n;for(;l&&!(n=Object.getOwnPropertyDescriptor(l,"sheet"));)l=Object.getPrototypeOf(l);if(!l||!n||typeof n.get!="function"||typeof i!="function")return;const c=n.get,u=new WeakMap;Object.defineProperty(l,"sheet",{configurable:!0,enumerable:n.enumerable,get(){try{return c.call(this)}catch(a){const p=this.textContent,h=u.get(this);if(h&&h.text===p)return h.sheet;const b=O(p);if(!b)throw a;const f=new i;for(const g of b)try{f.insertRule(g,f.cssRules.length)}catch{}return u.set(this,{text:p,sheet:f}),f}}})},m=new Set,j=r=>{const t=r&&r.message||String(r);m.has(t)||(m.size>=200&&m.clear(),m.add(t),console.warn(`[brender] page code threw in a timer; reported as a browser reports it, the render goes on (once per message): ${t}`))},v=r=>function(...t){try{const e=r.apply(this,t);return e&&typeof e.then=="function"&&e.then(null,j),e}catch(e){j(e)}},L=r=>(t,...e)=>globalThis[r](typeof t=="function"?v(t):t,...e),k=()=>{const r={};return{getItem:t=>r[t]??null,setItem:(t,e)=>{r[t]=String(e)},removeItem:t=>{delete r[t]},clear:()=>{for(const t in r)delete r[t]},get length(){return Object.keys(r).length},key:t=>Object.keys(r)[t]??null}},G=(r="<!DOCTYPE html><html><head></head><body></body></html>")=>{const t={location:{pathname:"/",search:"",hash:"",origin:"http://localhost",protocol:"http:",host:"localhost",hostname:"localhost",port:"",href:"http://localhost/"},localStorage:k(),sessionStorage:k(),history:{pushState:()=>{},replaceState:()=>{},state:null},setTimeout:L("setTimeout"),setInterval:L("setInterval")},{window:e,document:o}=A(r,t);return e.requestAnimationFrame||(e.requestAnimationFrame=s=>{const i=setTimeout(typeof s=="function"?v(s):s,0);return i?.unref&&i.unref(),i}),e.cancelAnimationFrame||(e.cancelAnimationFrame=s=>clearTimeout(s)),e.URL||(e.URL=URL),e.scrollTo||(e.scrollTo=()=>{}),globalThis.localStorage=t.localStorage,globalThis.sessionStorage=t.sessionStorage,globalThis.history||(globalThis.history=t.history),C(o),U(o),F(o),e.MutationObserver||(e.MutationObserver=class{constructor(){}observe(){}disconnect(){}takeRecords(){return[]}}),globalThis.window=e,globalThis.document=o,globalThis.Node=e.Node||globalThis.Node,globalThis.Element=e.Element||globalThis.Element,globalThis.HTMLElement=e.HTMLElement||globalThis.HTMLElement,globalThis.MutationObserver=e.MutationObserver,S.add(e),e.constructor&&e.constructor!==Object?globalThis.Window=e.constructor:(typeof globalThis.Window!="function"||globalThis.Window===Object)&&(globalThis.Window=M),{window:e,document:o}};export{G as createEnv};
@@ -0,0 +1,5 @@
1
+ import{createHash as S}from"crypto";import{stylesheetRules as x}from"./pageWeight.js";const u="data-smbls-faces",h="data-smbls-faces-version",A="data-smbls-faces-files",F="-",y=/^@font-face\b/i,T=t=>typeof t=="string"&&y.test(t.trim()),E=t=>{const e={},s=t.indexOf("{");if(s===-1)return e;let o=s+1,n=null,i=0;const c=r=>{const l=t.slice(o,r),a=l.indexOf(":");if(a!==-1){const f=l.slice(0,a).trim().toLowerCase();f&&!(f in e)&&(e[f]=l.slice(a+1).trim())}o=r+1};for(let r=o;r<t.length;r++){const l=t[r];if(n){l==="\\"?r++:l===n&&(n=null);continue}if(l==="\\"){r++;continue}if(l==='"'||l==="'")n=l;else if(l==="(")i++;else if(l===")")i=Math.max(0,i-1);else{if(i)continue;if(l===";")c(r);else if(l==="}"){c(r);break}}}return e},_=t=>{const e=parseInt(t,16);return e>0&&e<=1114111&&!(e>=55296&&e<=57343)?String.fromCodePoint(e):"\uFFFD"},$=t=>{const e=t.trim(),s=e[0];return((s==='"'||s==="'")&&e.length>1&&e[e.length-1]===s?e.slice(1,-1):e).replace(/\\(?:([0-9a-fA-F]{1,6})\s?|([\s\S]))/g,(n,i,c)=>i?_(i):c).trim()},b=t=>{if(typeof t!="string")return null;let e=null;for(let s=0;s<t.length;s++){const o=t[s];if(e){o==="\\"?s++:o===e&&(e=null);continue}if(o==='"'||o==="'"){e=o;continue}if(!/^url\(/i.test(t.slice(s,s+4))||/[\w-]/.test(t[s-1]||""))continue;let n=s+4;for(;n<t.length&&/\s/.test(t[n]);)n++;let i;if(t[n]==='"'||t[n]==="'"){for(i=n+1;i<t.length&&t[i]!==t[n];)i+=t[i]==="\\"?2:1;i++}else i=t.indexOf(")",n),i===-1&&(i=t.length);const c=$(t.slice(n,i));return c&&!/^data:/i.test(c)?c:null}return null},R=t=>t?t.replace(/\s/g,e=>"%"+e.charCodeAt(0).toString(16).toUpperCase().padStart(2,"0")):F,p=t=>{const e=typeof t=="string"?x(t):Array.isArray(t)?t:null;if(!e)return null;const s=e.map(n=>String(n).trim()).filter(Boolean),o=s.filter(T);return o.length?{version:S("sha256").update(s.join(`
2
+ `)).digest("hex").slice(0,12),files:o.map(n=>R(b(E(n).src)))}:null},g=t=>String(t).replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;"),d=t=>t?` ${h}="${g(t.version)}" ${A}="${g(t.files.join(" "))}"`:"",I=t=>!Array.isArray(t)||!t.length?"":`<style ${u}${d(p(t))}>
3
+ ${t.join(`
4
+ `)}
5
+ </style>`,C=/<script\b[\s\S]*?<\/script\s*>|<style\b([^>]*)>([\s\S]*?)(<\/style\s*>)/gi,m=/(^|\s)data-smbls-faces(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+))?(?=[\s/]|$)/i,O=/\s(?:data-smbls-faces-version|data-smbls-faces-files)(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+))?/gi,j=t=>{if(typeof t!="string"||!t.includes(u))return t;let e=!1;return t.replace(C,(s,o,n,i)=>{if(e||o===void 0||!m.test(o))return s;e=!0;const c=p(n);if(!c)return s;const r=o.replace(O,""),l=m.exec(r),a=l.index+l[0].length;return`<style${r.slice(0,a)}${d(c)}${r.slice(a)}>${n}${i}`})};export{A as FACES_FILES_ATTR,u as FACES_SHEET_ATTR,h as FACES_VERSION_ATTR,F as NO_FACE_FILE,b as faceFileOf,p as facesSheetMarks,I as facesSheetTag,j as markFacesSheet};
package/dist/esm/index.js CHANGED
@@ -1 +1 @@
1
- import{createEnv as e}from"./env.js";import{resetKeys as r,assignKeys as t,mapKeysToElements as o}from"./keys.js";import{loadProject as a,loadAndRenderAll as m}from"./load.js";import{render as l,renderElement as p,renderRoute as i,renderPage as s,resetGlobalCSSCache as d,getAccumulatedEmotionCSS as n,replaceEmotionCSS as c,adoptionScripts as f,prerenderParts as S,buildStamp as g}from"./render.js";import{extractMetadata as u,generateHeadHtml as P}from"./metadata.js";import{collectBrNodes as h,hydrate as y}from"./hydrate.js";import{generateSitemap as C}from"./sitemap.js";import{prefetchPageData as E,injectPrefetchedState as R}from"./prefetch.js";import{composeIntoShell as b}from"./shell.js";import{trimSpriteToPage as x,classRulesForPage as A,markupClasses as K,trimVariablesToPage as T,stylesheetRules as j}from"./pageWeight.js";var V={createEnv:e,resetKeys:r,assignKeys:t,mapKeysToElements:o,loadProject:a,loadAndRenderAll:m,render:l,renderElement:p,renderRoute:i,renderPage:s,resetGlobalCSSCache:d,getAccumulatedEmotionCSS:n,replaceEmotionCSS:c,extractMetadata:u,generateHeadHtml:P,collectBrNodes:h,hydrate:y,generateSitemap:C,prefetchPageData:E,injectPrefetchedState:R,composeIntoShell:b,adoptionScripts:f,prerenderParts:S,buildStamp:g,trimSpriteToPage:x,classRulesForPage:A,markupClasses:K,trimVariablesToPage:T,stylesheetRules:j};export{f as adoptionScripts,t as assignKeys,g as buildStamp,A as classRulesForPage,h as collectBrNodes,b as composeIntoShell,e as createEnv,V as default,u as extractMetadata,P as generateHeadHtml,C as generateSitemap,n as getAccumulatedEmotionCSS,y as hydrate,R as injectPrefetchedState,m as loadAndRenderAll,a as loadProject,o as mapKeysToElements,K as markupClasses,E as prefetchPageData,S as prerenderParts,l as render,p as renderElement,s as renderPage,i as renderRoute,c as replaceEmotionCSS,d as resetGlobalCSSCache,r as resetKeys,j as stylesheetRules,x as trimSpriteToPage,T as trimVariablesToPage};
1
+ import{createEnv as e}from"./env.js";import{resetKeys as r,assignKeys as t,mapKeysToElements as o}from"./keys.js";import{loadProject as a,loadAndRenderAll as m}from"./load.js";import{render as s,renderElement as p,renderRoute as i,renderPage as l,resetGlobalCSSCache as d,getAccumulatedEmotionCSS as n,replaceEmotionCSS as c,adoptionScripts as f,prerenderParts as S,buildStamp as g}from"./render.js";import{extractMetadata as h,generateHeadHtml as u}from"./metadata.js";import{collectBrNodes as P,hydrate as y}from"./hydrate.js";import{generateSitemap as C}from"./sitemap.js";import{prefetchPageData as E,injectPrefetchedState as R}from"./prefetch.js";import{composeIntoShell as b}from"./shell.js";import{trimSpriteToPage as k,classRulesForPage as x,markupClasses as A,trimVariablesToPage as F,stylesheetRules as K}from"./pageWeight.js";import{markFacesSheet as T,facesSheetMarks as j}from"./faces.js";import{drawnFaces as H}from"./drawnFaces.js";var L={createEnv:e,resetKeys:r,assignKeys:t,mapKeysToElements:o,loadProject:a,loadAndRenderAll:m,render:s,renderElement:p,renderRoute:i,renderPage:l,resetGlobalCSSCache:d,getAccumulatedEmotionCSS:n,replaceEmotionCSS:c,extractMetadata:h,generateHeadHtml:u,collectBrNodes:P,hydrate:y,generateSitemap:C,prefetchPageData:E,injectPrefetchedState:R,composeIntoShell:b,adoptionScripts:f,prerenderParts:S,buildStamp:g,trimSpriteToPage:k,classRulesForPage:x,markupClasses:A,trimVariablesToPage:F,stylesheetRules:K,markFacesSheet:T,facesSheetMarks:j,drawnFaces:H};export{f as adoptionScripts,t as assignKeys,g as buildStamp,x as classRulesForPage,P as collectBrNodes,b as composeIntoShell,e as createEnv,L as default,H as drawnFaces,h as extractMetadata,j as facesSheetMarks,u as generateHeadHtml,C as generateSitemap,n as getAccumulatedEmotionCSS,y as hydrate,R as injectPrefetchedState,m as loadAndRenderAll,a as loadProject,o as mapKeysToElements,T as markFacesSheet,A as markupClasses,E as prefetchPageData,S as prerenderParts,s as render,p as renderElement,l as renderPage,i as renderRoute,c as replaceEmotionCSS,d as resetGlobalCSSCache,r as resetKeys,K as stylesheetRules,k as trimSpriteToPage,F as trimVariablesToPage};
@@ -1,23 +1,20 @@
1
- import{resolve as d,join as tt,dirname as j}from"path";import{existsSync as S,unlinkSync as ot,readFileSync as Y,realpathSync as nt}from"fs";import{resolvePackageEntry as st}from"./packageEntry.js";import{tmpdir as rt}from"os";import{randomBytes as ct}from"crypto";import{createRequire as ge}from"module";import{pathToFileURL as it}from"url";import{createEnv as je}from"./env.js";import{resetKeys as Te,assignKeys as ve,mapKeysToElements as Le}from"./keys.js";import{extractMetadata as he,generateHeadHtml as lt}from"./metadata.js";import"./hydrate.js";import{composeIntoShell as at}from"./shell.js";import{trimSpriteToPage as ft,classRulesForPage as pt,markupClasses as ut,trimVariablesToPage as mt}from"./pageWeight.js";import{fetchSSRTranslations as dt}from"./prefetch.js";import{createEarlySeedScript as gt}from"@symbo.ls/fetch";import{headerEntries as ht}from"@symbo.ls/fetch/rest";import{brenderStampMeta as yt,brenderLazyMeta as $e,escapeRegExp as bt,jsonForScript as St,libraryPackageSpecs as Rt,polyglotFallbackLang as ye,polyglotLangStorageKey as wt,polyglotAddressLang as kt,polyglotStartupScript as xt}from"@symbo.ls/utils";import{brenderRegistryBlock as _t,brenderRegistryTreeBlock as Et}from"@symbo.ls/utils/server";import*as jt from"@symbo.ls/utils/server";let ce=null;const Tt=async()=>{if(ce)return ce;try{return ce=(await import("@symbo.ls/funcql")).funcqlPlugin,ce}catch{return null}};import"linkedom";import{createEarlySeedBlock as vt,fetchRunsOf as Lt}from"@symbo.ls/fetch";import{reset as $t}from"@symbo.ls/css";const ie=(e,t)=>{if(!e||!t)return;if(e[t]!==void 0)return e[t];const o=t.split(".");let n=e;for(const s of o){if(n==null||typeof n!="object")return;n=n[s]}return n},le=(e,t)=>ye(e?.lang,t),At=e=>{const t=jt.revivePolyglotDefaultLang;if(typeof t!="function"||!e||typeof e!="object")return e;const o=e.polyglot?t(e.polyglot):e.polyglot,n=e.config&&e.config.polyglot,s=n&&t(n);if(o===e.polyglot&&s===n)return e;const r={...e};return o!==e.polyglot&&(r.polyglot=o),s!==n&&(r.config={...e.config,polyglot:s}),r},Ae=(e,t,o,n)=>{if(o?.translations){const r=o.translations[t];if(r){const i=ie(r,e);if(i!==void 0)return i}}if(n?.translations){const r=n.translations[t];if(r){const i=ie(r,e);if(i!==void 0)return i}}const s=ye(void 0,o);if(s!==t&&o?.translations){const r=o.translations[s];if(r){const i=ie(r,e);if(i!==void 0)return i}}},Dt=function(e,t){if(!e)return"";const o=this?.context,n=o?.polyglot,s=this?.state?.root||o?.state?.root,r=Ae(e,t||le(s,n),n,s);if(r!==void 0)return r;const i=we(Re);return n&&i&&i.labelKeys.add(e),e},De=function(){return le(this?.state?.root,this?.context?.polyglot)},L=(e,t=new WeakMap)=>{if(e===null||typeof e!="object")return e;if(t.has(e))return t.get(e);if(Array.isArray(e)){const n=[];t.set(e,n);for(const s of e)n.push(typeof s=="object"&&s!==null?L(s,t):s);return n}const o={};t.set(e,o);for(const n of Object.keys(e)){const s=e[n];o[n]=typeof s=="object"&&s!==null?L(s,t):s}return o};let q=null;try{import.meta.url&&(q=ge(import.meta.url))}catch{}const Ct=()=>{if(!import.meta.url||!q)return{isMonorepo:!1,monorepoRoot:null,resolvePackage:a=>a};const e=nt(new URL(".",import.meta.url).pathname),t=d(e,"../..");if(S(d(t,"packages","smbls","src","createDomql.js")))return{isMonorepo:!0,monorepoRoot:t};let n;try{const a=q.resolve("smbls/package.json");n=j(a)}catch{let a=e;for(;a!==j(a);){const g=d(a,"node_modules","smbls");if(S(d(g,"package.json"))){n=g;break}a=j(a)}}let s=q;if(n)try{s=ge(d(n,"package.json"))}catch{}let r,i=process.cwd();for(;i!==j(i);){if(S(d(i,"package.json"))){r=i;break}i=j(i)}let u=s;if(r)try{u=ge(d(r,"package.json"))}catch{}return{isMonorepo:!1,smblsRoot:n,brenderDir:e,projectRoot:r,_smblsRequire:s,_projectRequire:u}},H=(e,t)=>{const o=e.isMonorepo?[q]:[e._smblsRequire,e._projectRequire,q].filter(Boolean);for(const n of o)try{return n.resolve(t)}catch{}return null},en=(e,t,...o)=>{if(e.isMonorepo)return d(e.monorepoRoot,"packages",t,...o);const n=H(e,`${t}/package.json`);return n?d(j(n),...o):null},tn=(e,t,...o)=>{if(e.isMonorepo)return d(e.monorepoRoot,"plugins",t,...o);const n=H(e,`@symbo.ls/${t}/package.json`);return n?d(j(n),...o):null},be=(e,t,...o)=>{if(e.isMonorepo){for(const s of["packages","plugins"]){const r=d(e.monorepoRoot,s,t,...o);if(S(r))return r}return null}const n=H(e,`@symbo.ls/${t}/package.json`);return n?d(j(n),...o):null},Ce=(e,t,...o)=>{if(e.isMonorepo)return d(e.monorepoRoot,"packages","domql","packages",t,...o);const n=H(e,`@symbo.ls/${t}/package.json`);return n?d(j(n),...o):null};let ae=null;const Me="smbls/ssr",Mt=async()=>{const e=await import("smbls/ssr");if(typeof e?.createDomqlElement!="function")throw new Error("smbls/ssr does not export createDomqlElement");return e},Oe=()=>(ae||(ae=Ot().catch(e=>{throw ae=null,e})),ae),Ot=async()=>{const e=Ct();let t;if(q&&e.isMonorepo)t=d(e.monorepoRoot,"packages","smbls","src","createDomql.js");else{let f;try{return await Mt()}catch(l){f=l}if(!q)throw new Error(`brender: ${Me} is not available in this bundled runtime (${f.message}). Bundle smbls \u2265 the release that adds the smbls/ssr export alongside @symbo.ls/brender.`);const c=e.smblsRoot&&d(e.smblsRoot,"src","createDomql.js");if(c&&S(c))t=c;else throw new Error(`brender: cannot load ${Me} (${f.message}). Server rendering needs smbls installed in this project, at a release that exports smbls/ssr`+(e.smblsRoot?` (found smbls at ${e.smblsRoot}).`:" (no smbls package found)."))}const o=await import("esbuild"),n=tt(rt(),`br_createDomql_${ct(6).toString("hex")}.mjs`),s=st,r=e.isMonorepo?await import(it(d(e.monorepoRoot,"scripts","vite-workspace-source.mjs")).href):null,i=r?new Set(r.workspacePackageRoots().map(f=>r.workspacePackageAt(f).name)):null,u=/^(?:smbls(?:\/.*)?|domql|css-in-props(?:\/.*)?|@symbo\.ls\/[^/]+)$/,a={name:"workspace-resolve",setup(f){r&&(f.onResolve({filter:/^[^./]/},c=>{if(u.test(c.path))return;const l=c.path.split("/"),p=c.path.startsWith("@")?l.slice(0,2).join("/"):l[0];if(!i.has(p))return;const h=r.resolveWorkspaceSource(c.path,c.importer||t);return h?{path:h}:{errors:[{text:`"${c.path}" names no source file in the workspace`}]}}),f.onLoad({filter:/[\\/]dist[\\/]/},c=>r.isWorkspaceDist(c.path)?{errors:[{text:`${c.path} is a BUILD of a workspace package \u2014 the render bundles source`}]}:void 0)),f.onResolve({filter:/^smbls/},c=>{const l=c.path.replace(/^smbls\/?/,""),p=e.isMonorepo?d(e.monorepoRoot,"packages","smbls"):e.smblsRoot;if(!p)return;if(!l){const k=s(p);return k?{path:k}:void 0}const h=d(p,l);if(S(h))return{path:h};if(S(h+".js"))return{path:h+".js"};const R=d(h,"index.js");if(S(R))return{path:R}}),f.onResolve({filter:/^domql$/},c=>{if(e.isMonorepo){const l=d(e.monorepoRoot,"packages","domql","src","index.js");if(S(l))return{path:l};const p=d(e.monorepoRoot,"packages","domql","index.js");if(S(p))return{path:p}}else try{const l=_require.resolve("domql/package.json"),p=s(j(l));if(p)return{path:p}}catch{}}),f.onResolve({filter:/^@symbo\.ls\//},c=>{const l=c.path.replace("@symbo.ls/","");if(l==="sync")return{path:"sync-stub",namespace:"brender-stub"};if(e.isMonorepo){for(const h of["packages","plugins"]){const R=d(e.monorepoRoot,h,l,"src","index.js");if(S(R))return{path:R};const k=d(e.monorepoRoot,h,l,"index.js");if(S(k))return{path:k}}const p=d(e.monorepoRoot,"packages","default-config","blank","index.js");if(l==="default-config"&&S(p))return{path:p}}else{const p=be(e,l,"src","index.js");if(p&&S(p))return{path:p};const h=be(e,l,"index.js");if(h&&S(h))return{path:h};if(l==="default-config"){const R=be(e,"default-config","blank","index.js");if(R&&S(R))return{path:R}}}}),f.onResolve({filter:/^@domql\//},c=>{const l=c.path.replace("@symbo.ls/","");if(e.isMonorepo){const p=d(e.monorepoRoot,"packages","domql","packages",l,"src","index.js");if(S(p))return{path:p};const h=d(e.monorepoRoot,"packages","domql","packages",l,"index.js");if(S(h))return{path:h}}else{const p=Ce(e,l,"src","index.js");if(p&&S(p))return{path:p};const h=Ce(e,l,"index.js");if(h&&S(h))return{path:h}}}),f.onResolve({filter:/^css-in-props/},c=>{let l;if(e.isMonorepo)l=d(e.monorepoRoot,"packages","css-in-props");else{const R=H(e,"css-in-props/package.json");R&&(l=j(R))}if(!l)return;const p=c.path.replace(/^css-in-props\/?/,"");if(p){const R=d(l,p),k=d(R,"index.js");if(S(k))return{path:k};if(S(R+".js"))return{path:R+".js"};if(S(R))return{path:R}}const h=s(l);if(h)return{path:h}}),f.onResolve({filter:/^@emotion\//},c=>{let l;if(e.isMonorepo)l=d(e.monorepoRoot,"node_modules",c.path);else{const p=H(e,`${c.path}/package.json`);if(!p)return;l=j(p)}if(S(l)){const p=d(l,"package.json");if(S(p))try{const h=JSON.parse(Y(p,"utf8")),R=h.module||h.main||"dist/emotion-css.esm.js";return{path:d(l,R)}}catch{}return{path:l}}}),f.onResolve({filter:/\.json$/},c=>{if(c.resolveDir){const l=d(c.resolveDir,c.path);if(S(l))return{path:l}}}),f.onLoad({filter:/smbls\/.*options\.js$/},async c=>{if(!c.path.includes("smbls/")||!c.path.endsWith("options.js"))return;let l=Y(c.path,"utf8");return l=l.replace(/import\s*\{[^}]*version[^}]*\}\s*from\s*['"][^'"]*package\.json['"][^;\n]*/,"const version = '0.0.0'"),l=l.replace(/import\s*\{[^}]*createRequire[^}]*\}\s*from\s*['"]module['"][^;\n]*/g,"// createRequire removed for brender build"),{contents:l,loader:"js"}}),f.onLoad({filter:/smbls\/.*init\.js$/},async c=>{if(!c.path.includes("smbls/")||!c.path.endsWith("init.js"))return;let l=Y(c.path,"utf8");return l=l.replace(/import\s*\{[^}]*createRequire[^}]*\}\s*from\s*['"]module['"][^;\n]*/g,"// createRequire removed for brender build"),{contents:l,loader:"js"}}),f.onLoad({filter:/.*/,namespace:"brender-stub"},()=>({contents:"export const SyncComponent = {}; export const Inspect = {}; export const Notifications = {}; export const syncPlugin = () => ({}); export const notificationsPlugin = () => ({}); export const seedRawDesignSystem = () => {}; export const inspectPlugin = () => ({}); export default {}",loader:"js"})),f.onLoad({filter:/smbls\/src\/router\.js$/},async c=>{let l=Y(c.path,"utf8");return l=l.replace(/import\s*\{\s*Link\s*\}\s*from\s*['"]smbls['"]/,"const Link = { tag: 'a', attr: { href: (el) => el.href } }"),{contents:l,loader:"js"}}),f.onLoad({filter:/fetchOnCreate\.js$/},async c=>{if(!c.path.includes("smbls/"))return;let l=Y(c.path,"utf8");return l=l.replace(/window\s*&&\s*window\.location\s*\?\s*window\.location\.host\.includes/g,"window && window.location && window.location.host ? window.location.host.includes"),{contents:l,loader:"js"}})}};await o.build({entryPoints:[t],bundle:!0,format:"esm",platform:"node",outfile:n,write:!0,logLevel:"warning",plugins:[a],nodePaths:e.isMonorepo?[d(e.monorepoRoot,"node_modules")]:[...e.smblsRoot?[d(e.smblsRoot,"node_modules")]:[],...e.projectRoot?[d(e.projectRoot,"node_modules")]:[],...e.smblsRoot?[d(e.smblsRoot,"..","..","node_modules")]:[]].filter(f=>S(f)),supported:{"import-attributes":!1},external:["fs","path","os","crypto","url","http","https","stream","util","events","buffer","child_process","worker_threads","net","tls","dns","dgram","zlib","assert","querystring","string_decoder","readline","perf_hooks","async_hooks","v8","vm","cluster","inspector","module","process","tty","color-contrast-checker","linkedom"]});const g=await import(`file://${n}`);if(process.env.BRENDER_DEBUG)console.log("[brender] Bundle saved:",n);else try{ot(n)}catch{}return g},qt={Box:{},Focusable:{},Block:{display:"block"},Inline:{display:"inline"},Flex:{display:"flex"},InlineFlex:{display:"inline-flex"},Grid:{display:"grid"},InlineGrid:{display:"inline-grid"},Link:{tag:"a",attr:{href:e=>e.href,target:e=>e.target,rel:e=>e.rel}},A:{extends:"Link"},RouteLink:{extends:"Link"},Img:{tag:"img",attr:{src:e=>{let t=e.src;return typeof t=="string"&&t.includes("{{")&&(t=e.call("replaceLiteralsWithObjectFields",t,e.state)),t},alt:e=>e.alt,loading:e=>e.loading}},Image:{extends:"Img"},Button:{tag:"button"},FocusableComponent:{tag:"button"},Form:{tag:"form"},Input:{tag:"input"},TextArea:{tag:"textarea"},Textarea:{tag:"textarea"},Select:{tag:"select"},Label:{tag:"label"},Iframe:{tag:"iframe"},Video:{tag:"video"},Audio:{tag:"audio"},Canvas:{tag:"canvas"},Span:{tag:"span"},P:{tag:"p"},H1:{tag:"h1"},H2:{tag:"h2"},H3:{tag:"h3"},H4:{tag:"h4"},H5:{tag:"h5"},H6:{tag:"h6"},Svg:{tag:"svg",attr:{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink"}},Text:{tag:"span"}},Pt=(e,t)=>{const o={};return qe(e,(n,s)=>{if(!s.__brKey)return;const r=t(n);o[r===""?"__root":r]=s.__brKey}),o},qe=(e,t)=>{const o=n=>{const s=n&&n.__ref;if(s&&(t(n,s),s.__children))for(const r of s.__children)o(n[r])};o(e)},It=new Set(["app","config","pages","components","state","snippets","designSystem","dependencies","functions","methods","files","sharedLibraries"]);let z=0;const Pe=Symbol.for("brender.fetchTracked"),Se=()=>z,Ft=256*1024,Gt=1024*1024,Bt=new Set(["accept-language","accept"]),Ie={renders:0,record:null},Kt=50,Re={renders:0,record:null},Fe=(e,t)=>{e.renders++,e.renders===1?e.record=t():e.record&&(e.record.tainted=!0);const o=e.record;return{record:o,close:()=>{e.renders--,e.record===o&&(e.record=null)}}},we=e=>e.record&&!e.record.tainted?e.record:null,Nt=e=>{try{const t=new URL(e);return t.origin+t.pathname}catch{return String(e).split("?")[0]}},ke=(e,t,o)=>{!e||e.tainted||e.failures.length>=Kt||e.failures.push({url:Nt(t),reason:o})},Ge=e=>e&&typeof e=="object"&&typeof e.url=="string"?e.url:String(e),Ht=e=>{const[t,o]=e,n=t&&typeof t=="object"&&typeof t.url=="string",s=Ge(t),r=String(o&&o.method||n&&t.method||"GET").toUpperCase(),i={},u=a=>{if(!a)return;const g=!Array.isArray(a)&&typeof a.entries!="function";for(const[f,c]of ht(a))g&&c==null||(i[String(f).toLowerCase()]=String(c))};return n&&u(t.headers),o&&u(o.headers),{url:s,method:r,headers:i}},zt=(e,t,o,n)=>{if(!o||!o.ok||typeof o.clone!="function")return;const s=o.headers&&o.headers.get&&o.headers.get("content-type")||"";if(!/json|^text\//i.test(s))return;let r;try{r=o.clone()}catch{return}n(r.text().then(i=>{e.tainted||i.length>Ft||e.bytes+i.length>Gt||(e.bytes+=i.length,e.entries.push({url:t.url,lang:t.headers["accept-language"]||"",status:o.status,type:s,body:i}))},()=>{}))},Wt=()=>{const e=globalThis.fetch;if(typeof e!="function"||e[Pe])return;const t=function(...o){z++;let n=!1;const s=()=>{n||(n=!0,z--)},r=c=>{z++,c.then(()=>{z--},()=>{z--})},i=we(Ie),u=we(Re);let a=null;if(i)try{a=Ht(o),(a.method!=="GET"||!/^https?:/i.test(a.url)||Object.keys(a.headers).some(c=>!Bt.has(c)))&&(a=null)}catch{a=null}const g=()=>Ge(o[0]);let f;try{f=e.apply(this,o)}catch(c){throw ke(u,g(),c&&c.message||"failed"),s(),c}return f&&typeof f.then=="function"?f.then(c=>{a&&zt(i,a,c,r),u&&c&&c.ok===!1&&ke(u,g(),"HTTP "+c.status),s()},c=>{ke(u,g(),c&&c.message||"network error"),s()}):s(),f};t[Pe]=!0,globalThis.fetch=t},on=({brRegistry:e,fetchSeed:t,hydrateFlag:o=!0}={})=>{if(!e||!Object.keys(e).length)return"";const n=St(e);return o?`<script>window.__BR_REGISTRY__=${n};window.__BRENDER_HYDRATE__=true<\/script>`+(t&&t.length?`
2
- `+gt(t):""):`<script>window.__BR_REGISTRY__=${n}<\/script>`},Ut=e=>{const t=globalThis.__SMBLS_PKGS__,o=new Set(t&&typeof t=="object"?Object.getOwnPropertyNames(t):[]);return()=>{const n=globalThis.__SMBLS_PKGS__;if(!n||typeof n!="object")return;let s;try{s=Rt(e())}catch{return}for(const[r]of s)!o.has(r)&&Object.prototype.hasOwnProperty.call(n,r)&&Reflect.deleteProperty(n,r)}},Vt=3e4,Jt=2147483647;let Be=Promise.resolve();const Ke=()=>{},Yt=e=>{const t=Be.then(e);return Be=t.then(Ke,Ke),t},Xt=e=>{if(e===void 0)return Vt;if(e===0||e===!1||e===1/0)return 0;if(typeof e!="number"||!(e>0))throw new TypeError(`brender: options.timeout is a number of milliseconds, or 0 / false for no limit \u2014 not ${JSON.stringify(e)}`);return Math.min(e,Jt)},Qt=(e,t)=>{const o=e.route||"/",n=e.pathname||o,s=n===o?o:`${n} (route ${o})`,r=new Error(`brender: the render of ${s} did not finish within ${t} ms and was abandoned, so the renders after it can run (options.timeout)`);return r.code="BRENDER_RENDER_TIMEOUT",r.route=o,r.pathname=n,r.timeout=t,r},Zt=e=>{e.closed=!0;for(const t of e.undo.splice(0))t()},eo=e=>{let t=!1;return()=>{t||(t=!0,e())}},Ne=(e,t={})=>{let o;try{o=Xt(t.timeout)}catch(n){return Promise.reject(n)}return Yt(()=>to(e,t,o))},to=async(e,t,o)=>{await Oe();const n={closed:!1,undo:[]},s=oo(e,t,n);if(!o)return s;let r;const i=new Promise((u,a)=>{r=setTimeout(()=>{Zt(n),a(Qt(t,o))},o)});try{return await Promise.race([s,i])}finally{clearTimeout(r)}},oo=async(e,t,o)=>{const{route:n="/",pathname:s,state:r,context:i,prefetch:u=!1,lazyGroups:a}=t,g=s||n;Wt();const f=Fe(Re,()=>({failures:[],labelKeys:new Set,tainted:!1}));try{return await no(At(e),{route:n,locationPath:g,stateOverrides:r,contextOverrides:i,prefetch:u,lazyGroups:a},f.record,o)}finally{f.close()}},no=async(e,{route:t,locationPath:o,stateOverrides:n,contextOverrides:s,prefetch:r,lazyGroups:i},u,a)=>{const g=()=>{if(a.closed)throw new Error("brender: this render was abandoned at its timeout")};let f;if(r){try{f=await dt(e)}catch(k){a.closed||console.warn("[brender] SSR translation fetch failed:",k.message)}g()}const{window:c,document:l}=je(),p=l.body;c.location.pathname=o;let h=null;const R=[fe("document",l),fe("location",c.location),fe("localStorage",c.localStorage),fe("sessionStorage",c.sessionStorage),Ut(()=>h&&h.sharedLibraries)].map(eo);a.undo.push(...R);try{const{createDomqlElement:k,PRERENDER_REGISTRY_FORMATS:X}=await Oe();g();const me=L(e.app||{}),_={...e.config||{}};e.polyglot&&!_.polyglot&&(_.polyglot=e.polyglot),e.fetch&&!_.fetch&&(_.fetch=e.fetch),e.router&&!_.router&&(_.router=e.router);for(const m of fo)e[m]!=null&&_[m]==null&&(_[m]=e[m]);const E=_.polyglot?{..._.polyglot,prefetch:!1}:void 0,Q=kt(o,E);Q&&c.localStorage.setItem(wt(E),Q),f&&E&&(E.translations={...E.translations||{},...f});const Z=L(e.state||{});$t();const P={};for(const m in e){if(It.has(m))continue;const b=e[m];P[m]=b&&typeof b=="object"?L(b):b}const x={...P,state:Z,...n?{state:{...Z,...n}}:{},dependencies:L(e.dependencies||{}),components:L(e.components||{}),snippets:L(e.snippets||{}),pages:L(e.pages||{}),functions:{...e.functions||{},polyglot:Dt,getActiveLang:De,getLang:De},methods:e.methods||{},designSystem:L(e.designSystem||{}),files:e.files||{},sharedLibraries:e.sharedLibraries||[],..._,...E?{polyglot:E}:{},document:l,window:c,parent:{node:p},initOptions:{},domqlOptions:{sourcemap:!1},firstRender:!1,sync:!1,inspect:!1,notifications:!1,afterFirstView:null,isolateDesignSystem:!0,isolateFetchCache:!0,captureDesignSystem:!0,...so(i),...s||{},ssr:!0};h=x;const ee=await Tt();g(),ee&&(x.plugins=x.plugins||[],x.plugins.some(m=>m.name==="funcql")||x.plugins.push(ee)),Te();const B=Fe(Ie,()=>({entries:[],bytes:0,tainted:!1})),y=B.record;let w;try{if(w=await k(me,x),g(),x.lazyFirstView){const D=(w&&w.context||x).__firstNavigation;if(D&&typeof D.then=="function"){try{await D}catch{}g()}}const m=Date.now(),b=r?2e3:50,T=D=>new Promise(re=>setTimeout(re,D));for(await T(Math.min(50,b));r&&!a.closed&&Se()>0&&Date.now()-m<b;)await T(10),Se()===0&&await T(Math.max(0,Math.min(50,b-(Date.now()-m))));if(g(),r&&await ro(w,E)){g();const D=Date.now();for(await T(Math.min(50,b));!a.closed&&Se()>0&&Date.now()-D<b;)await T(10);g()}}finally{B.close()}const W=y&&!y.tainted&&!(_.fetch&&_.fetch.seed===!1)?y.entries.slice():[];ve(p);const $=Le(w),{elementPath:K}=await import("@symbo.ls/element");g();const U=Pt(w,K),te=W.length?Lt(w&&w.context||x,K):{},V=w?.context?.routerOptions?.contentElementKey||"content",I=w&&w[V],C=I&&typeof I=="object"&&I.__ref?I:void 0,Ee=he(e,t,w,w?.state,C),M=[],J=l.head||l.querySelector("head");if(J)for(const m of J.querySelectorAll("style")){if(m.sheet&&m.sheet.cssRules)for(const b of m.sheet.cssRules)b.cssText&&M.push(b);if(!M.length){const b=m.textContent||"";b&&M.push({cssText:b})}}const oe=M.map(m=>m.cssText),{globalCSS:ne,classRules:de}=yo(M);let v=We(p.innerHTML);const F=w?.state?.root,G=le(F,E),O=co(f,F);O&&(v=ze(v,He(O,G,E)));const N=u&&!u.tainted?{failedRequests:u.failures.slice(),rawLabelKeys:ao(u.labelKeys,v,G,E,F)}:null,A=(w&&w.context||x).__lazyFirstViews,se=A&&typeof A.forEach=="function"?[...A]:[];return{html:v,metadata:Ee,registry:$,brRegistry:U,element:w,emotionCSS:oe,lazyGroups:se,globalCSS:ne,classRules:de,fetchSeed:W,fetchRuns:te,document:l,window:c,ssrTranslations:O||void 0,activeLang:G,diagnostics:N,preparedDesignSystem:x.preparedDesignSystem||null,registryFormats:Array.isArray(X)?X.slice():["paths"]}}finally{for(const k of R)k()}},so=e=>{if(e==="load"||e===!0)return{lazyFirstView:!0};if(Array.isArray(e)){const t=e.filter(o=>typeof o=="string"&&o);return t.length?{lazyFirstView:t}:{}}return{}},fe=(e,t)=>{const o=Object.getOwnPropertyDescriptor(globalThis,e);return o&&!o.configurable?!o.writable&&!o.set?()=>{}:(globalThis[e]=t,()=>{}):(Object.defineProperty(globalThis,e,{value:t,writable:!0,configurable:!0,enumerable:!0}),()=>{o?Object.defineProperty(globalThis,e,o):delete globalThis[e]})},ro=async(e,t)=>{if(!t||!t.fetch||!e||typeof e.call!="function")return!1;const o=e.state&&e.state.root;if(!o)return!1;const n=le(o,t),s=o.translations&&o.translations[n];if(s&&typeof s=="object"&&Object.keys(s).length||t.translations&&t.translations[n])return!1;try{await e.call("loadTranslations",n,{inFlight:!0})}catch{}return!0},xe=/\{\{\s*([^|{}]+?)\s*\|\s*polyglot\s*\}\}/g,_e=e=>e&&typeof e.parse=="function"?e.parse():e,co=(e,t)=>{const o=_e(t?.translations),n={};for(const s of[e,o])if(!(!s||typeof s!="object"))for(const r in s){const i=_e(s[r]);i&&typeof i=="object"&&(n[r]={...n[r]||{},...i})}return Object.keys(n).length?n:null},He=(e,t,o)=>e[t]||e[ye(void 0,o)]||Object.values(e)[0]||{},ze=(e,t)=>e.replace(xe,(o,n)=>ie(t,n.trim())??o),io=/<script\b[^>]*\btype\s*=\s*["']?application\/json["']?[^>]*>[\s\S]*?<\/script\s*>/gi,lo=(e,t)=>new RegExp(`(?:^|[^\\w.-])${bt(t)}(?![\\w-]|\\.\\w)`).test(e),ao=(e,t,o,n,s)=>{const r=new Set,i=t.replace(io,"");for(const u of e)/\s/.test(u)||Ae(u,o,n,s)===void 0&&lo(i,u)&&r.add(u);for(const u of i.matchAll(xe))r.add(u[1].trim());return[...r]},nn=async(e,t={})=>{const{context:o={}}=t,{window:n,document:s}=je(),r=s.body,{create:i}=await import("@symbo.ls/element"),u=await import("@symbo.ls/utils"),a={...qt,...o.components||{}},g={...u,...o.utils||{},...o.functions||{}};Te();let f;try{f=i(e,{node:r},"root",{context:{document:s,window:n,...o,components:a,utils:g,ssr:!0}})}catch{}ve(r);const c=f?Le(f):{};return{html:We(r.innerHTML),registry:c,element:f}},We=e=>e.replace(/(<svg\b[^>]*>)([\s\S]*?)(<\/svg>)/gi,(t,o,n,s)=>{if(n.includes("&lt;")){const r=n.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&").replace(/&quot;/g,'"').replace(/&#39;/g,"'");return o+r+s}return t}),fo=["globalTheme","themeStorageKey","themeRoot","useReset","useVariable","useFontImport","useIconSprite","useSvgSprite","useDocumentTheme","useDefaultConfig","useDefaultIcons","useThemeSuffixedVars","verbose","semanticIcons"],po=new Set(["auto","system"]),Ue=e=>{if(!e||typeof e!="object")return null;const t=e.config&&typeof e.config=="object"?e.config:{};if((t.themeRoot!=null?t.themeRoot:e.themeRoot)!=null)return null;const n=t.globalTheme!=null?t.globalTheme:e.globalTheme;if(typeof n!="string")return null;const s=n.trim();return!s||po.has(s)?null:s},uo=e=>String(e).replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;"),mo=/\.[A-Za-z_\\-]/,go=e=>{if(typeof e!="string"||!e)return!1;const t=e.replace(/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'/g,'""').replace(/\[[^\]]*\]/g,"[]");return!mo.test(t)},ho=/^\s*(:root|\[data-theme|\[data-skin)/,Ve=e=>{const t=e&&e.cssText;if(typeof t!="string")return null;if(/^@(-webkit-)?keyframes\b/.test(t))return"keyframes";if(t.startsWith("@font-face"))return null;if(typeof e.selectorText=="string")return go(e.selectorText)?ho.test(e.selectorText)?"root":"reset":null;const o=e.cssRules&&Array.from(e.cssRules);if(o&&o.length&&/^@(media|supports|container)\b/.test(t)){const n=new Set(o.map(Ve));return n.has(null)||n.size!==1?n.has(null)?null:"reset":[...n][0]}return null},Je=e=>typeof e=="string"&&/^\s*@font-face\b/i.test(e),yo=e=>{const t={root:[],reset:[],keyframes:[]},o=[];for(const n of e||[]){const s=Ve(n);s?t[s].push(n.cssText):n&&n.cssText&&o.push(n.cssText)}return{globalCSS:{rootRule:t.root.join(`
1
+ import{resolve as d,join as tt,dirname as j}from"path";import{existsSync as S,unlinkSync as ot,readFileSync as J,realpathSync as nt}from"fs";import{resolvePackageEntry as st}from"./packageEntry.js";import{tmpdir as rt}from"os";import{randomBytes as ct}from"crypto";import{createRequire as ge}from"module";import{pathToFileURL as it}from"url";import{createEnv as je}from"./env.js";import{resetKeys as Te,assignKeys as ve,mapKeysToElements as Le}from"./keys.js";import{extractMetadata as he,generateHeadHtml as lt}from"./metadata.js";import"./hydrate.js";import{composeIntoShell as at}from"./shell.js";import{trimSpriteToPage as ft,classRulesForPage as pt,markupClasses as ut,trimVariablesToPage as mt}from"./pageWeight.js";import{facesSheetTag as dt}from"./faces.js";import{fetchSSRTranslations as gt}from"./prefetch.js";import{createEarlySeedScript as ht}from"@symbo.ls/fetch";import{headerEntries as yt}from"@symbo.ls/fetch/rest";import{brenderStampMeta as bt,brenderLazyMeta as Ae,escapeRegExp as St,jsonForScript as Rt,libraryPackageSpecs as wt,polyglotFallbackLang as ye,polyglotLangStorageKey as kt,polyglotAddressLang as xt,polyglotStartupScript as _t}from"@symbo.ls/utils";import{brenderRegistryBlock as Et,brenderRegistryTreeBlock as jt}from"@symbo.ls/utils/server";import*as Tt from"@symbo.ls/utils/server";let ce=null;const vt=async()=>{if(ce)return ce;try{return ce=(await import("@symbo.ls/funcql")).funcqlPlugin,ce}catch{return null}};import"linkedom";import{createEarlySeedBlock as Lt,fetchRunsOf as At}from"@symbo.ls/fetch";import{reset as $t}from"@symbo.ls/css";const ie=(e,t)=>{if(!e||!t)return;if(e[t]!==void 0)return e[t];const o=t.split(".");let n=e;for(const s of o){if(n==null||typeof n!="object")return;n=n[s]}return n},le=(e,t)=>ye(e?.lang,t),Dt=e=>{const t=Tt.revivePolyglotDefaultLang;if(typeof t!="function"||!e||typeof e!="object")return e;const o=e.polyglot?t(e.polyglot):e.polyglot,n=e.config&&e.config.polyglot,s=n&&t(n);if(o===e.polyglot&&s===n)return e;const r={...e};return o!==e.polyglot&&(r.polyglot=o),s!==n&&(r.config={...e.config,polyglot:s}),r},$e=(e,t,o,n)=>{if(o?.translations){const r=o.translations[t];if(r){const i=ie(r,e);if(i!==void 0)return i}}if(n?.translations){const r=n.translations[t];if(r){const i=ie(r,e);if(i!==void 0)return i}}const s=ye(void 0,o);if(s!==t&&o?.translations){const r=o.translations[s];if(r){const i=ie(r,e);if(i!==void 0)return i}}},Ct=function(e,t){if(!e)return"";const o=this?.context,n=o?.polyglot,s=this?.state?.root||o?.state?.root,r=$e(e,t||le(s,n),n,s);if(r!==void 0)return r;const i=we(Re);return n&&i&&i.labelKeys.add(e),e},De=function(){return le(this?.state?.root,this?.context?.polyglot)},L=(e,t=new WeakMap)=>{if(e===null||typeof e!="object")return e;if(t.has(e))return t.get(e);if(Array.isArray(e)){const n=[];t.set(e,n);for(const s of e)n.push(typeof s=="object"&&s!==null?L(s,t):s);return n}const o={};t.set(e,o);for(const n of Object.keys(e)){const s=e[n];o[n]=typeof s=="object"&&s!==null?L(s,t):s}return o};let q=null;try{import.meta.url&&(q=ge(import.meta.url))}catch{}const Mt=()=>{if(!import.meta.url||!q)return{isMonorepo:!1,monorepoRoot:null,resolvePackage:a=>a};const e=nt(new URL(".",import.meta.url).pathname),t=d(e,"../..");if(S(d(t,"packages","smbls","src","createDomql.js")))return{isMonorepo:!0,monorepoRoot:t};let n;try{const a=q.resolve("smbls/package.json");n=j(a)}catch{let a=e;for(;a!==j(a);){const g=d(a,"node_modules","smbls");if(S(d(g,"package.json"))){n=g;break}a=j(a)}}let s=q;if(n)try{s=ge(d(n,"package.json"))}catch{}let r,i=process.cwd();for(;i!==j(i);){if(S(d(i,"package.json"))){r=i;break}i=j(i)}let u=s;if(r)try{u=ge(d(r,"package.json"))}catch{}return{isMonorepo:!1,smblsRoot:n,brenderDir:e,projectRoot:r,_smblsRequire:s,_projectRequire:u}},H=(e,t)=>{const o=e.isMonorepo?[q]:[e._smblsRequire,e._projectRequire,q].filter(Boolean);for(const n of o)try{return n.resolve(t)}catch{}return null},on=(e,t,...o)=>{if(e.isMonorepo)return d(e.monorepoRoot,"packages",t,...o);const n=H(e,`${t}/package.json`);return n?d(j(n),...o):null},nn=(e,t,...o)=>{if(e.isMonorepo)return d(e.monorepoRoot,"plugins",t,...o);const n=H(e,`@symbo.ls/${t}/package.json`);return n?d(j(n),...o):null},be=(e,t,...o)=>{if(e.isMonorepo){for(const s of["packages","plugins"]){const r=d(e.monorepoRoot,s,t,...o);if(S(r))return r}return null}const n=H(e,`@symbo.ls/${t}/package.json`);return n?d(j(n),...o):null},Ce=(e,t,...o)=>{if(e.isMonorepo)return d(e.monorepoRoot,"packages","domql","packages",t,...o);const n=H(e,`@symbo.ls/${t}/package.json`);return n?d(j(n),...o):null};let ae=null;const Me="smbls/ssr",Ot=async()=>{const e=await import("smbls/ssr");if(typeof e?.createDomqlElement!="function")throw new Error("smbls/ssr does not export createDomqlElement");return e},Oe=()=>(ae||(ae=qt().catch(e=>{throw ae=null,e})),ae),qt=async()=>{const e=Mt();let t;if(q&&e.isMonorepo)t=d(e.monorepoRoot,"packages","smbls","src","createDomql.js");else{let f;try{return await Ot()}catch(l){f=l}if(!q)throw new Error(`brender: ${Me} is not available in this bundled runtime (${f.message}). Bundle smbls \u2265 the release that adds the smbls/ssr export alongside @symbo.ls/brender.`);const c=e.smblsRoot&&d(e.smblsRoot,"src","createDomql.js");if(c&&S(c))t=c;else throw new Error(`brender: cannot load ${Me} (${f.message}). Server rendering needs smbls installed in this project, at a release that exports smbls/ssr`+(e.smblsRoot?` (found smbls at ${e.smblsRoot}).`:" (no smbls package found)."))}const o=await import("esbuild"),n=tt(rt(),`br_createDomql_${ct(6).toString("hex")}.mjs`),s=st,r=e.isMonorepo?await import(it(d(e.monorepoRoot,"scripts","vite-workspace-source.mjs")).href):null,i=r?new Set(r.workspacePackageRoots().map(f=>r.workspacePackageAt(f).name)):null,u=/^(?:smbls(?:\/.*)?|domql|css-in-props(?:\/.*)?|@symbo\.ls\/[^/]+)$/,a={name:"workspace-resolve",setup(f){r&&(f.onResolve({filter:/^[^./]/},c=>{if(u.test(c.path))return;const l=c.path.split("/"),p=c.path.startsWith("@")?l.slice(0,2).join("/"):l[0];if(!i.has(p))return;const h=r.resolveWorkspaceSource(c.path,c.importer||t);return h?{path:h}:{errors:[{text:`"${c.path}" names no source file in the workspace`}]}}),f.onLoad({filter:/[\\/]dist[\\/]/},c=>r.isWorkspaceDist(c.path)?{errors:[{text:`${c.path} is a BUILD of a workspace package \u2014 the render bundles source`}]}:void 0)),f.onResolve({filter:/^smbls/},c=>{const l=c.path.replace(/^smbls\/?/,""),p=e.isMonorepo?d(e.monorepoRoot,"packages","smbls"):e.smblsRoot;if(!p)return;if(!l){const k=s(p);return k?{path:k}:void 0}const h=d(p,l);if(S(h))return{path:h};if(S(h+".js"))return{path:h+".js"};const R=d(h,"index.js");if(S(R))return{path:R}}),f.onResolve({filter:/^domql$/},c=>{if(e.isMonorepo){const l=d(e.monorepoRoot,"packages","domql","src","index.js");if(S(l))return{path:l};const p=d(e.monorepoRoot,"packages","domql","index.js");if(S(p))return{path:p}}else try{const l=_require.resolve("domql/package.json"),p=s(j(l));if(p)return{path:p}}catch{}}),f.onResolve({filter:/^@symbo\.ls\//},c=>{const l=c.path.replace("@symbo.ls/","");if(l==="sync")return{path:"sync-stub",namespace:"brender-stub"};if(e.isMonorepo){for(const h of["packages","plugins"]){const R=d(e.monorepoRoot,h,l,"src","index.js");if(S(R))return{path:R};const k=d(e.monorepoRoot,h,l,"index.js");if(S(k))return{path:k}}const p=d(e.monorepoRoot,"packages","default-config","blank","index.js");if(l==="default-config"&&S(p))return{path:p}}else{const p=be(e,l,"src","index.js");if(p&&S(p))return{path:p};const h=be(e,l,"index.js");if(h&&S(h))return{path:h};if(l==="default-config"){const R=be(e,"default-config","blank","index.js");if(R&&S(R))return{path:R}}}}),f.onResolve({filter:/^@domql\//},c=>{const l=c.path.replace("@symbo.ls/","");if(e.isMonorepo){const p=d(e.monorepoRoot,"packages","domql","packages",l,"src","index.js");if(S(p))return{path:p};const h=d(e.monorepoRoot,"packages","domql","packages",l,"index.js");if(S(h))return{path:h}}else{const p=Ce(e,l,"src","index.js");if(p&&S(p))return{path:p};const h=Ce(e,l,"index.js");if(h&&S(h))return{path:h}}}),f.onResolve({filter:/^css-in-props/},c=>{let l;if(e.isMonorepo)l=d(e.monorepoRoot,"packages","css-in-props");else{const R=H(e,"css-in-props/package.json");R&&(l=j(R))}if(!l)return;const p=c.path.replace(/^css-in-props\/?/,"");if(p){const R=d(l,p),k=d(R,"index.js");if(S(k))return{path:k};if(S(R+".js"))return{path:R+".js"};if(S(R))return{path:R}}const h=s(l);if(h)return{path:h}}),f.onResolve({filter:/^@emotion\//},c=>{let l;if(e.isMonorepo)l=d(e.monorepoRoot,"node_modules",c.path);else{const p=H(e,`${c.path}/package.json`);if(!p)return;l=j(p)}if(S(l)){const p=d(l,"package.json");if(S(p))try{const h=JSON.parse(J(p,"utf8")),R=h.module||h.main||"dist/emotion-css.esm.js";return{path:d(l,R)}}catch{}return{path:l}}}),f.onResolve({filter:/\.json$/},c=>{if(c.resolveDir){const l=d(c.resolveDir,c.path);if(S(l))return{path:l}}}),f.onLoad({filter:/smbls\/.*options\.js$/},async c=>{if(!c.path.includes("smbls/")||!c.path.endsWith("options.js"))return;let l=J(c.path,"utf8");return l=l.replace(/import\s*\{[^}]*version[^}]*\}\s*from\s*['"][^'"]*package\.json['"][^;\n]*/,"const version = '0.0.0'"),l=l.replace(/import\s*\{[^}]*createRequire[^}]*\}\s*from\s*['"]module['"][^;\n]*/g,"// createRequire removed for brender build"),{contents:l,loader:"js"}}),f.onLoad({filter:/smbls\/.*init\.js$/},async c=>{if(!c.path.includes("smbls/")||!c.path.endsWith("init.js"))return;let l=J(c.path,"utf8");return l=l.replace(/import\s*\{[^}]*createRequire[^}]*\}\s*from\s*['"]module['"][^;\n]*/g,"// createRequire removed for brender build"),{contents:l,loader:"js"}}),f.onLoad({filter:/.*/,namespace:"brender-stub"},()=>({contents:"export const SyncComponent = {}; export const Inspect = {}; export const Notifications = {}; export const syncPlugin = () => ({}); export const notificationsPlugin = () => ({}); export const seedRawDesignSystem = () => {}; export const inspectPlugin = () => ({}); export default {}",loader:"js"})),f.onLoad({filter:/smbls\/src\/router\.js$/},async c=>{let l=J(c.path,"utf8");return l=l.replace(/import\s*\{\s*Link\s*\}\s*from\s*['"]smbls['"]/,"const Link = { tag: 'a', attr: { href: (el) => el.href } }"),{contents:l,loader:"js"}}),f.onLoad({filter:/fetchOnCreate\.js$/},async c=>{if(!c.path.includes("smbls/"))return;let l=J(c.path,"utf8");return l=l.replace(/window\s*&&\s*window\.location\s*\?\s*window\.location\.host\.includes/g,"window && window.location && window.location.host ? window.location.host.includes"),{contents:l,loader:"js"}})}};await o.build({entryPoints:[t],bundle:!0,format:"esm",platform:"node",outfile:n,write:!0,logLevel:"warning",plugins:[a],nodePaths:e.isMonorepo?[d(e.monorepoRoot,"node_modules")]:[...e.smblsRoot?[d(e.smblsRoot,"node_modules")]:[],...e.projectRoot?[d(e.projectRoot,"node_modules")]:[],...e.smblsRoot?[d(e.smblsRoot,"..","..","node_modules")]:[]].filter(f=>S(f)),supported:{"import-attributes":!1},external:["fs","path","os","crypto","url","http","https","stream","util","events","buffer","child_process","worker_threads","net","tls","dns","dgram","zlib","assert","querystring","string_decoder","readline","perf_hooks","async_hooks","v8","vm","cluster","inspector","module","process","tty","color-contrast-checker","linkedom"]});const g=await import(`file://${n}`);if(process.env.BRENDER_DEBUG)console.log("[brender] Bundle saved:",n);else try{ot(n)}catch{}return g},Pt={Box:{},Focusable:{},Block:{display:"block"},Inline:{display:"inline"},Flex:{display:"flex"},InlineFlex:{display:"inline-flex"},Grid:{display:"grid"},InlineGrid:{display:"inline-grid"},Link:{tag:"a",attr:{href:e=>e.href,target:e=>e.target,rel:e=>e.rel}},A:{extends:"Link"},RouteLink:{extends:"Link"},Img:{tag:"img",attr:{src:e=>{let t=e.src;return typeof t=="string"&&t.includes("{{")&&(t=e.call("replaceLiteralsWithObjectFields",t,e.state)),t},alt:e=>e.alt,loading:e=>e.loading}},Image:{extends:"Img"},Button:{tag:"button"},FocusableComponent:{tag:"button"},Form:{tag:"form"},Input:{tag:"input"},TextArea:{tag:"textarea"},Textarea:{tag:"textarea"},Select:{tag:"select"},Label:{tag:"label"},Iframe:{tag:"iframe"},Video:{tag:"video"},Audio:{tag:"audio"},Canvas:{tag:"canvas"},Span:{tag:"span"},P:{tag:"p"},H1:{tag:"h1"},H2:{tag:"h2"},H3:{tag:"h3"},H4:{tag:"h4"},H5:{tag:"h5"},H6:{tag:"h6"},Svg:{tag:"svg",attr:{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink"}},Text:{tag:"span"}},It=(e,t)=>{const o={};return qe(e,(n,s)=>{if(!s.__brKey)return;const r=t(n);o[r===""?"__root":r]=s.__brKey}),o},qe=(e,t)=>{const o=n=>{const s=n&&n.__ref;if(s&&(t(n,s),s.__children))for(const r of s.__children)o(n[r])};o(e)},Ft=new Set(["app","config","pages","components","state","snippets","designSystem","dependencies","functions","methods","files","sharedLibraries"]);let z=0;const Pe=Symbol.for("brender.fetchTracked"),Se=()=>z,Gt=256*1024,Bt=1024*1024,Kt=new Set(["accept-language","accept"]),Ie={renders:0,record:null},Nt=50,Re={renders:0,record:null},Fe=(e,t)=>{e.renders++,e.renders===1?e.record=t():e.record&&(e.record.tainted=!0);const o=e.record;return{record:o,close:()=>{e.renders--,e.record===o&&(e.record=null)}}},we=e=>e.record&&!e.record.tainted?e.record:null,Ht=e=>{try{const t=new URL(e);return t.origin+t.pathname}catch{return String(e).split("?")[0]}},ke=(e,t,o)=>{!e||e.tainted||e.failures.length>=Nt||e.failures.push({url:Ht(t),reason:o})},Ge=e=>e&&typeof e=="object"&&typeof e.url=="string"?e.url:String(e),zt=e=>{const[t,o]=e,n=t&&typeof t=="object"&&typeof t.url=="string",s=Ge(t),r=String(o&&o.method||n&&t.method||"GET").toUpperCase(),i={},u=a=>{if(!a)return;const g=!Array.isArray(a)&&typeof a.entries!="function";for(const[f,c]of yt(a))g&&c==null||(i[String(f).toLowerCase()]=String(c))};return n&&u(t.headers),o&&u(o.headers),{url:s,method:r,headers:i}},Wt=(e,t,o,n)=>{if(!o||!o.ok||typeof o.clone!="function")return;const s=o.headers&&o.headers.get&&o.headers.get("content-type")||"";if(!/json|^text\//i.test(s))return;let r;try{r=o.clone()}catch{return}n(r.text().then(i=>{e.tainted||i.length>Gt||e.bytes+i.length>Bt||(e.bytes+=i.length,e.entries.push({url:t.url,lang:t.headers["accept-language"]||"",status:o.status,type:s,body:i}))},()=>{}))},Ut=()=>{const e=globalThis.fetch;if(typeof e!="function"||e[Pe])return;const t=function(...o){z++;let n=!1;const s=()=>{n||(n=!0,z--)},r=c=>{z++,c.then(()=>{z--},()=>{z--})},i=we(Ie),u=we(Re);let a=null;if(i)try{a=zt(o),(a.method!=="GET"||!/^https?:/i.test(a.url)||Object.keys(a.headers).some(c=>!Kt.has(c)))&&(a=null)}catch{a=null}const g=()=>Ge(o[0]);let f;try{f=e.apply(this,o)}catch(c){throw ke(u,g(),c&&c.message||"failed"),s(),c}return f&&typeof f.then=="function"?f.then(c=>{a&&Wt(i,a,c,r),u&&c&&c.ok===!1&&ke(u,g(),"HTTP "+c.status),s()},c=>{ke(u,g(),c&&c.message||"network error"),s()}):s(),f};t[Pe]=!0,globalThis.fetch=t},sn=({brRegistry:e,fetchSeed:t,hydrateFlag:o=!0}={})=>{if(!e||!Object.keys(e).length)return"";const n=Rt(e);return o?`<script>window.__BR_REGISTRY__=${n};window.__BRENDER_HYDRATE__=true<\/script>`+(t&&t.length?`
2
+ `+ht(t):""):`<script>window.__BR_REGISTRY__=${n}<\/script>`},Vt=e=>{const t=globalThis.__SMBLS_PKGS__,o=new Set(t&&typeof t=="object"?Object.getOwnPropertyNames(t):[]);return()=>{const n=globalThis.__SMBLS_PKGS__;if(!n||typeof n!="object")return;let s;try{s=wt(e())}catch{return}for(const[r]of s)!o.has(r)&&Object.prototype.hasOwnProperty.call(n,r)&&Reflect.deleteProperty(n,r)}},Jt=3e4,Yt=2147483647;let Be=Promise.resolve();const Ke=()=>{},Xt=e=>{const t=Be.then(e);return Be=t.then(Ke,Ke),t},Qt=e=>{if(e===void 0)return Jt;if(e===0||e===!1||e===1/0)return 0;if(typeof e!="number"||!(e>0))throw new TypeError(`brender: options.timeout is a number of milliseconds, or 0 / false for no limit \u2014 not ${JSON.stringify(e)}`);return Math.min(e,Yt)},Zt=(e,t)=>{const o=e.route||"/",n=e.pathname||o,s=n===o?o:`${n} (route ${o})`,r=new Error(`brender: the render of ${s} did not finish within ${t} ms and was abandoned, so the renders after it can run (options.timeout)`);return r.code="BRENDER_RENDER_TIMEOUT",r.route=o,r.pathname=n,r.timeout=t,r},eo=e=>{e.closed=!0;for(const t of e.undo.splice(0))t()},to=e=>{let t=!1;return()=>{t||(t=!0,e())}},Ne=(e,t={})=>{let o;try{o=Qt(t.timeout)}catch(n){return Promise.reject(n)}return Xt(()=>oo(e,t,o))},oo=async(e,t,o)=>{await Oe();const n={closed:!1,undo:[]},s=no(e,t,n);if(!o)return s;let r;const i=new Promise((u,a)=>{r=setTimeout(()=>{eo(n),a(Zt(t,o))},o)});try{return await Promise.race([s,i])}finally{clearTimeout(r)}},no=async(e,t,o)=>{const{route:n="/",pathname:s,state:r,context:i,prefetch:u=!1,lazyGroups:a}=t,g=s||n;Ut();const f=Fe(Re,()=>({failures:[],labelKeys:new Set,tainted:!1}));try{return await so(Dt(e),{route:n,locationPath:g,stateOverrides:r,contextOverrides:i,prefetch:u,lazyGroups:a},f.record,o)}finally{f.close()}},so=async(e,{route:t,locationPath:o,stateOverrides:n,contextOverrides:s,prefetch:r,lazyGroups:i},u,a)=>{const g=()=>{if(a.closed)throw new Error("brender: this render was abandoned at its timeout")};let f;if(r){try{f=await gt(e)}catch(k){a.closed||console.warn("[brender] SSR translation fetch failed:",k.message)}g()}const{window:c,document:l}=je(),p=l.body;c.location.pathname=o;let h=null;const R=[fe("document",l),fe("location",c.location),fe("localStorage",c.localStorage),fe("sessionStorage",c.sessionStorage),Vt(()=>h&&h.sharedLibraries)].map(to);a.undo.push(...R);try{const{createDomqlElement:k,PRERENDER_REGISTRY_FORMATS:Y}=await Oe();g();const me=L(e.app||{}),_={...e.config||{}};e.polyglot&&!_.polyglot&&(_.polyglot=e.polyglot),e.fetch&&!_.fetch&&(_.fetch=e.fetch),e.router&&!_.router&&(_.router=e.router);for(const m of po)e[m]!=null&&_[m]==null&&(_[m]=e[m]);const E=_.polyglot?{..._.polyglot,prefetch:!1}:void 0,X=xt(o,E);X&&c.localStorage.setItem(kt(E),X),f&&E&&(E.translations={...E.translations||{},...f});const Q=L(e.state||{});$t();const P={};for(const m in e){if(Ft.has(m))continue;const b=e[m];P[m]=b&&typeof b=="object"?L(b):b}const x={...P,state:Q,...n?{state:{...Q,...n}}:{},dependencies:L(e.dependencies||{}),components:L(e.components||{}),snippets:L(e.snippets||{}),pages:L(e.pages||{}),functions:{...e.functions||{},polyglot:Ct,getActiveLang:De,getLang:De},methods:e.methods||{},designSystem:L(e.designSystem||{}),files:e.files||{},sharedLibraries:e.sharedLibraries||[],..._,...E?{polyglot:E}:{},document:l,window:c,parent:{node:p},initOptions:{},domqlOptions:{sourcemap:!1},firstRender:!1,sync:!1,inspect:!1,notifications:!1,afterFirstView:null,isolateDesignSystem:!0,isolateFetchCache:!0,captureDesignSystem:!0,...ro(i),...s||{},ssr:!0};h=x;const Z=await vt();g(),Z&&(x.plugins=x.plugins||[],x.plugins.some(m=>m.name==="funcql")||x.plugins.push(Z)),Te();const B=Fe(Ie,()=>({entries:[],bytes:0,tainted:!1})),y=B.record;let w;try{if(w=await k(me,x),g(),x.lazyFirstView){const D=(w&&w.context||x).__firstNavigation;if(D&&typeof D.then=="function"){try{await D}catch{}g()}}const m=Date.now(),b=r?2e3:50,T=D=>new Promise(re=>setTimeout(re,D));for(await T(Math.min(50,b));r&&!a.closed&&Se()>0&&Date.now()-m<b;)await T(10),Se()===0&&await T(Math.max(0,Math.min(50,b-(Date.now()-m))));if(g(),r&&await co(w,E)){g();const D=Date.now();for(await T(Math.min(50,b));!a.closed&&Se()>0&&Date.now()-D<b;)await T(10);g()}}finally{B.close()}const W=y&&!y.tainted&&!(_.fetch&&_.fetch.seed===!1)?y.entries.slice():[];ve(p);const A=Le(w),{elementPath:K}=await import("@symbo.ls/element");g();const ee=It(w,K),te=W.length?At(w&&w.context||x,K):{},U=w?.context?.routerOptions?.contentElementKey||"content",I=w&&w[U],C=I&&typeof I=="object"&&I.__ref?I:void 0,Ee=he(e,t,w,w?.state,C),M=[],V=l.head||l.querySelector("head");if(V)for(const m of V.querySelectorAll("style")){if(m.sheet&&m.sheet.cssRules)for(const b of m.sheet.cssRules)b.cssText&&M.push(b);if(!M.length){const b=m.textContent||"";b&&M.push({cssText:b})}}const oe=M.map(m=>m.cssText),{globalCSS:ne,classRules:de}=bo(M);let v=We(p.innerHTML);const F=w?.state?.root,G=le(F,E),O=io(f,F);O&&(v=ze(v,He(O,G,E)));const N=u&&!u.tainted?{failedRequests:u.failures.slice(),rawLabelKeys:fo(u.labelKeys,v,G,E,F)}:null,$=(w&&w.context||x).__lazyFirstViews,se=$&&typeof $.forEach=="function"?[...$]:[];return{html:v,metadata:Ee,registry:A,brRegistry:ee,element:w,emotionCSS:oe,lazyGroups:se,globalCSS:ne,classRules:de,fetchSeed:W,fetchRuns:te,document:l,window:c,ssrTranslations:O||void 0,activeLang:G,diagnostics:N,preparedDesignSystem:x.preparedDesignSystem||null,registryFormats:Array.isArray(Y)?Y.slice():["paths"]}}finally{for(const k of R)k()}},ro=e=>{if(e==="load"||e===!0)return{lazyFirstView:!0};if(Array.isArray(e)){const t=e.filter(o=>typeof o=="string"&&o);return t.length?{lazyFirstView:t}:{}}return{}},fe=(e,t)=>{const o=Object.getOwnPropertyDescriptor(globalThis,e);return o&&!o.configurable?!o.writable&&!o.set?()=>{}:(globalThis[e]=t,()=>{}):(Object.defineProperty(globalThis,e,{value:t,writable:!0,configurable:!0,enumerable:!0}),()=>{o?Object.defineProperty(globalThis,e,o):delete globalThis[e]})},co=async(e,t)=>{if(!t||!t.fetch||!e||typeof e.call!="function")return!1;const o=e.state&&e.state.root;if(!o)return!1;const n=le(o,t),s=o.translations&&o.translations[n];if(s&&typeof s=="object"&&Object.keys(s).length||t.translations&&t.translations[n])return!1;try{await e.call("loadTranslations",n,{inFlight:!0})}catch{}return!0},xe=/\{\{\s*([^|{}]+?)\s*\|\s*polyglot\s*\}\}/g,_e=e=>e&&typeof e.parse=="function"?e.parse():e,io=(e,t)=>{const o=_e(t?.translations),n={};for(const s of[e,o])if(!(!s||typeof s!="object"))for(const r in s){const i=_e(s[r]);i&&typeof i=="object"&&(n[r]={...n[r]||{},...i})}return Object.keys(n).length?n:null},He=(e,t,o)=>e[t]||e[ye(void 0,o)]||Object.values(e)[0]||{},ze=(e,t)=>e.replace(xe,(o,n)=>ie(t,n.trim())??o),lo=/<script\b[^>]*\btype\s*=\s*["']?application\/json["']?[^>]*>[\s\S]*?<\/script\s*>/gi,ao=(e,t)=>new RegExp(`(?:^|[^\\w.-])${St(t)}(?![\\w-]|\\.\\w)`).test(e),fo=(e,t,o,n,s)=>{const r=new Set,i=t.replace(lo,"");for(const u of e)/\s/.test(u)||$e(u,o,n,s)===void 0&&ao(i,u)&&r.add(u);for(const u of i.matchAll(xe))r.add(u[1].trim());return[...r]},rn=async(e,t={})=>{const{context:o={}}=t,{window:n,document:s}=je(),r=s.body,{create:i}=await import("@symbo.ls/element"),u=await import("@symbo.ls/utils"),a={...Pt,...o.components||{}},g={...u,...o.utils||{},...o.functions||{}};Te();let f;try{f=i(e,{node:r},"root",{context:{document:s,window:n,...o,components:a,utils:g,ssr:!0}})}catch{}ve(r);const c=f?Le(f):{};return{html:We(r.innerHTML),registry:c,element:f}},We=e=>e.replace(/(<svg\b[^>]*>)([\s\S]*?)(<\/svg>)/gi,(t,o,n,s)=>{if(n.includes("&lt;")){const r=n.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&").replace(/&quot;/g,'"').replace(/&#39;/g,"'");return o+r+s}return t}),po=["globalTheme","themeStorageKey","themeRoot","useReset","useVariable","useFontImport","useIconSprite","useSvgSprite","useDocumentTheme","useDefaultConfig","useDefaultIcons","useThemeSuffixedVars","verbose","semanticIcons"],uo=new Set(["auto","system"]),Ue=e=>{if(!e||typeof e!="object")return null;const t=e.config&&typeof e.config=="object"?e.config:{};if((t.themeRoot!=null?t.themeRoot:e.themeRoot)!=null)return null;const n=t.globalTheme!=null?t.globalTheme:e.globalTheme;if(typeof n!="string")return null;const s=n.trim();return!s||uo.has(s)?null:s},mo=e=>String(e).replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;"),go=/\.[A-Za-z_\\-]/,ho=e=>{if(typeof e!="string"||!e)return!1;const t=e.replace(/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'/g,'""').replace(/\[[^\]]*\]/g,"[]");return!go.test(t)},yo=/^\s*(:root|\[data-theme|\[data-skin)/,Ve=e=>{const t=e&&e.cssText;if(typeof t!="string")return null;if(/^@(-webkit-)?keyframes\b/.test(t))return"keyframes";if(t.startsWith("@font-face"))return null;if(typeof e.selectorText=="string")return ho(e.selectorText)?yo.test(e.selectorText)?"root":"reset":null;const o=e.cssRules&&Array.from(e.cssRules);if(o&&o.length&&/^@(media|supports|container)\b/.test(t)){const n=new Set(o.map(Ve));return n.has(null)||n.size!==1?n.has(null)?null:"reset":[...n][0]}return null},Je=e=>typeof e=="string"&&/^\s*@font-face\b/i.test(e),bo=e=>{const t={root:[],reset:[],keyframes:[]},o=[];for(const n of e||[]){const s=Ve(n);s?t[s].push(n.cssText):n&&n.cssText&&o.push(n.cssText)}return{globalCSS:{rootRule:t.root.join(`
3
3
  `),resetRules:t.reset.join(`
4
4
  `),keyframeRules:t.keyframes.join(`
5
- `),fontFaceCSS:""},classRules:o}};let pe=new Set;const sn=()=>{pe=new Set},rn=()=>Array.from(pe).join(`
6
- `),cn=(e,t)=>e.replace(/<style data-emotion="smbls">[\s\S]*?<\/style>/,t?`<style data-emotion="smbls">
5
+ `),fontFaceCSS:""},classRules:o}};let pe=new Set;const cn=()=>{pe=new Set},ln=()=>Array.from(pe).join(`
6
+ `),an=(e,t)=>e.replace(/<style data-emotion="smbls">[\s\S]*?<\/style>/,t?`<style data-emotion="smbls">
7
7
  ${t}
8
- </style>`:""),ln=async(e,t={})=>{const{route:o="/",pathname:n,prefetch:s=!0,timeout:r}=t,i=await Ne(e,{route:o,pathname:n,prefetch:s,timeout:r});if(!i)return null;const u=e.designSystem||{},a=i.globalCSS;let g=null;try{const c=bo(i.element);Object.keys(c).length&&(g=c)}catch{}const f=i.activeLang;return{html:i.html,css:i.classRules.join(`
9
- `),classRules:i.classRules.slice(),globalCSS:a,resetCss:a.resetRules,fontLinks:et(u),metadata:i.metadata||he(e,o),brKeyCount:i.registry?Object.keys(i.registry).length:0,brRegistry:i.brRegistry||{},fetchSeed:i.fetchSeed||[],fetchRuns:i.fetchRuns||{},ssrTranslations:i.ssrTranslations,prefetchedState:g,activeLang:f,theme:Ue(e),diagnostics:i.diagnostics,preparedDesignSystem:i.preparedDesignSystem||null}},bo=e=>{const t={};return qe(e,o=>{const n=o.fetch;if(!(!n||typeof n!="object"||!o.state))for(const s of Array.isArray(n)?n:[n]){const r=s&&typeof s=="object"&&typeof s.as=="string"?s.as:null;if(!r)continue;const i=r.startsWith("~/"),u=i?r.slice(2):r,a=i?o.state.root:o.state,g=_e(a&&a[u]);u&&g!=null&&typeof g!="function"&&(t[u]=g)}}),t},an=async(e,t="/",o={})=>{const{lang:n,themeColor:s,isr:r,hydrate:i=!0,prefetch:u=!0,shell:a,adoptDom:g=!1,pathname:f,eagerImages:c=Ze,preloadScripts:l=!0,nonce:p,timeout:h,stamp:R,time:k,spriteIcons:X="all",cssClasses:me="all",cssVariables:_="all",registryFormat:E="paths",lazyGroups:Q,paint:Z}=o,P=So(Z),x=To(p),ee=n||e.state?.lang||e.app?.metadata?.lang||"en",B=Ue(e),y=await Ne(e,{route:t,pathname:f,prefetch:u,timeout:h,lazyGroups:Q});if(!y)return null;const w={...y.metadata};if(s&&(w["theme-color"]=s),typeof a=="string"&&!e.name){const m="\0brender-undeclared-title\0";if(he({...e,name:m},t,y.element,y.element?.state).title===m)for(const T of["title","og:title","twitter:title"])w[T]===y.metadata.title&&delete w[T]}const W=lt(w);for(const m of y.classRules)m&&pe.add(m);let $=_o(y.html,c);X==="page"&&($=ft($,typeof a=="string"?a:"").html);const K=Array.from(pe),U=K.filter(Je),te=U.length?K.filter(m=>!Je(m)):K,V=me==="page"?pt(te,ut($,typeof a=="string"?a:"")).join(`
8
+ </style>`:""),fn=async(e,t={})=>{const{route:o="/",pathname:n,prefetch:s=!0,timeout:r}=t,i=await Ne(e,{route:o,pathname:n,prefetch:s,timeout:r});if(!i)return null;const u=e.designSystem||{},a=i.globalCSS;let g=null;try{const c=So(i.element);Object.keys(c).length&&(g=c)}catch{}const f=i.activeLang;return{html:i.html,css:i.classRules.join(`
9
+ `),classRules:i.classRules.slice(),globalCSS:a,resetCss:a.resetRules,fontLinks:et(u),metadata:i.metadata||he(e,o),brKeyCount:i.registry?Object.keys(i.registry).length:0,brRegistry:i.brRegistry||{},fetchSeed:i.fetchSeed||[],fetchRuns:i.fetchRuns||{},ssrTranslations:i.ssrTranslations,prefetchedState:g,activeLang:f,theme:Ue(e),diagnostics:i.diagnostics,preparedDesignSystem:i.preparedDesignSystem||null}},So=e=>{const t={};return qe(e,o=>{const n=o.fetch;if(!(!n||typeof n!="object"||!o.state))for(const s of Array.isArray(n)?n:[n]){const r=s&&typeof s=="object"&&typeof s.as=="string"?s.as:null;if(!r)continue;const i=r.startsWith("~/"),u=i?r.slice(2):r,a=i?o.state.root:o.state,g=_e(a&&a[u]);u&&g!=null&&typeof g!="function"&&(t[u]=g)}}),t},pn=async(e,t="/",o={})=>{const{lang:n,themeColor:s,isr:r,hydrate:i=!0,prefetch:u=!0,shell:a,adoptDom:g=!1,pathname:f,eagerImages:c=Ze,preloadScripts:l=!0,nonce:p,timeout:h,stamp:R,time:k,spriteIcons:Y="all",cssClasses:me="all",cssVariables:_="all",registryFormat:E="paths",lazyGroups:X,paint:Q}=o,P=Ro(Q),x=vo(p),Z=n||e.state?.lang||e.app?.metadata?.lang||"en",B=Ue(e),y=await Ne(e,{route:t,pathname:f,prefetch:u,timeout:h,lazyGroups:X});if(!y)return null;const w={...y.metadata};if(s&&(w["theme-color"]=s),typeof a=="string"&&!e.name){const m="\0brender-undeclared-title\0";if(he({...e,name:m},t,y.element,y.element?.state).title===m)for(const T of["title","og:title","twitter:title"])w[T]===y.metadata.title&&delete w[T]}const W=lt(w);for(const m of y.classRules)m&&pe.add(m);let A=Eo(y.html,c);Y==="page"&&(A=ft(A,typeof a=="string"?a:"").html);const K=Array.from(pe),ee=K.filter(Je),te=ee.length?K.filter(m=>!Je(m)):K,U=me==="page"?pt(te,ut(A,typeof a=="string"?a:"")).join(`
10
10
  `):te.join(`
11
- `),I=U.length?`<style data-smbls-faces>
12
- ${U.join(`
13
- `)}
14
- </style>`:"",C=y.globalCSS,M=`<style data-brender>
15
- ${(_==="page"?mt(C.rootRule||"",C.resetRules,C.keyframeRules,V,$,typeof a=="string"?a:"").css:C.rootRule)||""}
11
+ `),I=dt(ee),C=y.globalCSS,M=`<style data-brender>
12
+ ${(_==="page"?mt(C.rootRule||"",C.resetRules,C.keyframeRules,U,A,typeof a=="string"?a:"").css:C.rootRule)||""}
16
13
  ${C.resetRules||""}
17
14
  ${C.keyframeRules||""}
18
- </style>`,J=V?`<style data-emotion="smbls">
19
- ${V}
20
- </style>`:"",oe=et(e.designSystem||{}),ne=Object.keys(y.registry).length,de=E==="tree"||E==="auto"&&(y.registryFormats||[]).includes("tree"),v=Eo({brRegistry:y.brRegistry,fetchSeed:y.fetchSeed,fetchRuns:y.fetchRuns,adoptDom:g,stamp:R,time:k,registryFormat:de?"tree":"paths",lazyGroups:y.lazyGroups});let F="";if(r&&r.clientScript){const m=Number.isInteger(o.depth)?o.depth:t==="/"?0:t.replace(/^\/|\/$/g,"").split("/").length,b=m>0?"../".repeat(m):"./";if(i){const T=xt({polyglot:e.polyglot||e.config?.polyglot,translations:y.ssrTranslations,lang:y.activeLang,pathname:f||t,attrs:x}),D=T?T+`
15
+ </style>`,V=U?`<style data-emotion="smbls">
16
+ ${U}
17
+ </style>`:"",oe=et(e.designSystem||{}),ne=Object.keys(y.registry).length,de=E==="tree"||E==="auto"&&(y.registryFormats||[]).includes("tree"),v=jo({brRegistry:y.brRegistry,fetchSeed:y.fetchSeed,fetchRuns:y.fetchRuns,adoptDom:g,stamp:R,time:k,registryFormat:de?"tree":"paths",lazyGroups:y.lazyGroups});let F="";if(r&&r.clientScript){const m=Number.isInteger(o.depth)?o.depth:t==="/"?0:t.replace(/^\/|\/$/g,"").split("/").length,b=m>0?"../".repeat(m):"./";if(i){const T=_t({polyglot:e.polyglot||e.config?.polyglot,translations:y.ssrTranslations,lang:y.activeLang,pathname:f||t,attrs:x}),D=T?T+`
21
18
  `:"",re=v.blocks?v.blocks+`
22
19
  `:"";F=`${D}${re}<script type="module" src="${b}${r.clientScript}"${x}><\/script>`}else F=`<script type="module"${x}>
23
20
  {
@@ -36,29 +33,29 @@ ${V}
36
33
  observer.observe(document.body, { childList: true })
37
34
  }
38
35
  <\/script>
39
- <script type="module" src="${b}${r.clientScript}"${x}><\/script>`}const G={...e.config||{}};e.polyglot&&!G.polyglot&&(G.polyglot=e.polyglot);const O=G.polyglot;let N=W;if(O){const m={...O.translations||{}};for(const b in y.ssrTranslations||{})m[b]={...m[b]||{},...y.ssrTranslations[b]};N=ze(W,He(m,y.activeLang,O))}const A=y.diagnostics;if(A)for(const m of N.matchAll(xe)){const b=m[1].trim();A.rawLabelKeys.includes(b)||A.rawLabelKeys.push(b)}if(typeof a=="string"){const m=at(a,{headTags:`${N}
40
- ${v.meta}`,headEnd:[oe,I,M,J].filter(Boolean).join(`
41
- `),body:P?$+`
42
- `+Xe:$,depth:Number.isInteger(o.depth)?o.depth:0,bootScripts:v.blocks,lang:n||(O?y.activeLang:void 0),theme:B,preloadScripts:l});return{html:P?Qe(m):m,route:t,brKeyCount:ne,shell:!0,diagnostics:A,preparedDesignSystem:y.preparedDesignSystem||null,lazyGroups:y.lazyGroups||[]}}const se=`<!DOCTYPE html>
43
- <html lang="${ee}"${B?` data-theme="${uo(B)}"`:""}>
36
+ <script type="module" src="${b}${r.clientScript}"${x}><\/script>`}const G={...e.config||{}};e.polyglot&&!G.polyglot&&(G.polyglot=e.polyglot);const O=G.polyglot;let N=W;if(O){const m={...O.translations||{}};for(const b in y.ssrTranslations||{})m[b]={...m[b]||{},...y.ssrTranslations[b]};N=ze(W,He(m,y.activeLang,O))}const $=y.diagnostics;if($)for(const m of N.matchAll(xe)){const b=m[1].trim();$.rawLabelKeys.includes(b)||$.rawLabelKeys.push(b)}if(typeof a=="string"){const m=at(a,{headTags:`${N}
37
+ ${v.meta}`,headEnd:[oe,I,M,V].filter(Boolean).join(`
38
+ `),body:P?A+`
39
+ `+Xe:A,depth:Number.isInteger(o.depth)?o.depth:0,bootScripts:v.blocks,lang:n||(O?y.activeLang:void 0),theme:B,preloadScripts:l});return{html:P?Qe(m):m,route:t,brKeyCount:ne,shell:!0,diagnostics:$,preparedDesignSystem:y.preparedDesignSystem||null,lazyGroups:y.lazyGroups||[]}}const se=`<!DOCTYPE html>
40
+ <html lang="${Z}"${B?` data-theme="${mo(B)}"`:""}>
44
41
  <head>
45
42
  ${N}${r&&r.clientScript&&i?`
46
43
  ${v.meta}`:""}
47
44
  ${oe}
48
45
  ${I}
49
46
  ${M}
50
- ${J}
47
+ ${V}
51
48
  </head>
52
49
  <body>
53
- ${$}${P?`
50
+ ${A}${P?`
54
51
  ${Xe}`:""}
55
52
  ${F}
56
53
  </body>
57
- </html>`;return{html:P?Qe(se):se,route:t,brKeyCount:ne,diagnostics:A,preparedDesignSystem:y.preparedDesignSystem||null,lazyGroups:y.lazyGroups||[]}},Ye="smbls-whole",Xe=`<template id="${Ye}"></template>`,ue=`<link rel="expect" href="#${Ye}" blocking="render">`,So=e=>!!(e&&typeof e=="object"&&e.whole===!0),Ro=/<meta\b[^>]*\bcharset\s*=[^>]*>/i,wo=[/<head\b[^>]*>/i,/<html\b[^>]*>/i,/^\s*<!doctype\b[^>]*>/i],Qe=e=>{if(typeof e!="string"||e.includes(ue))return e;const t=Ro.exec(e.slice(0,1024));if(t){const o=t.index+t[0].length;return e.slice(0,o)+`
58
- `+ue+e.slice(o)}for(const o of wo){const n=o.exec(e);if(n)return e.slice(0,n.index+n[0].length)+`
54
+ </html>`;return{html:P?Qe(se):se,route:t,brKeyCount:ne,diagnostics:$,preparedDesignSystem:y.preparedDesignSystem||null,lazyGroups:y.lazyGroups||[]}},Ye="smbls-whole",Xe=`<template id="${Ye}"></template>`,ue=`<link rel="expect" href="#${Ye}" blocking="render">`,Ro=e=>!!(e&&typeof e=="object"&&e.whole===!0),wo=/<meta\b[^>]*\bcharset\s*=[^>]*>/i,ko=[/<head\b[^>]*>/i,/<html\b[^>]*>/i,/^\s*<!doctype\b[^>]*>/i],Qe=e=>{if(typeof e!="string"||e.includes(ue))return e;const t=wo.exec(e.slice(0,1024));if(t){const o=t.index+t[0].length;return e.slice(0,o)+`
55
+ `+ue+e.slice(o)}for(const o of ko){const n=o.exec(e);if(n)return e.slice(0,n.index+n[0].length)+`
59
56
  `+ue+e.slice(n.index+n[0].length)}return ue+`
60
- `+e},Ze=2,ko=/<img\b(?:[^>"']|"[^"]*"|'[^']*')*>/gi,xo=/\sloading\s*=/i,_o=(e,t=Ze)=>{if(t===!1||t==null||typeof e!="string")return e;const o=Math.max(0,Number(t)||0);let n=0;return e.replace(ko,s=>n++<o||xo.test(s)?s:s.replace(/^<img\b/i,'<img loading="lazy"'))},et=e=>{if(!e)return"";const t=e.font_family||e.fontFamily||{},o=new Set;for(const s of Object.values(t)){if(typeof s!="string")continue;const r=s.match(/'([^']+)'/);r&&o.add(r[1])}return o.size?['<link rel="preconnect" href="https://fonts.googleapis.com">','<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>',`<link href="https://fonts.googleapis.com/css2?${[...o].map(s=>`family=${s.replace(/\s+/g,"+")}:wght@300;400;500;600;700`).join("&")}&display=swap" rel="stylesheet">`].join(`
61
- `):""},Eo=({brRegistry:e,fetchSeed:t,fetchRuns:o,adoptDom:n=!1,stamp:s,time:r,registryFormat:i="paths",lazyGroups:u}={})=>{const g=n&&e&&Object.keys(e).length?i==="tree"&&Et(e)||_t(e):"",f=vt(t,o);return{meta:`<meta name="brender" content="${g?"hydrate":"replace"}">
62
- `+yt(jo(s,r))+($e(u)?`
63
- `+$e(u):""),blocks:[g,f].filter(Boolean).join(`
64
- `)}},jo=(e,t)=>{const o=typeof t=="number"&&isFinite(t)?Math.round(t):Date.now();return{stamp:e!=null&&e!==""?String(e):new Date(o).toISOString(),time:o}},To=e=>{if(e==null||e==="")return"";const t=String(e);if(!/^[A-Za-z0-9+/=_-]+$/.test(t))throw new Error("brender: a nonce is base64 or base64url text");return` nonce="${t}"`};export{Ze as EAGER_IMAGES_DEFAULT,Me as SMBLS_SSR_SPECIFIER,Ye as WHOLE_MARKER_ID,on as adoptionScripts,jo as buildStamp,Ue as fixedThemeOf,rn as getAccumulatedEmotionCSS,_o as markLazyImages,So as paintsWhole,Eo as prerenderParts,Ne as render,nn as renderElement,an as renderPage,ln as renderRoute,cn as replaceEmotionCSS,sn as resetGlobalCSSCache,yo as splitCapturedCSS,Qe as withWholePaint};
57
+ `+e},Ze=2,xo=/<img\b(?:[^>"']|"[^"]*"|'[^']*')*>/gi,_o=/\sloading\s*=/i,Eo=(e,t=Ze)=>{if(t===!1||t==null||typeof e!="string")return e;const o=Math.max(0,Number(t)||0);let n=0;return e.replace(xo,s=>n++<o||_o.test(s)?s:s.replace(/^<img\b/i,'<img loading="lazy"'))},et=e=>{if(!e)return"";const t=e.font_family||e.fontFamily||{},o=new Set;for(const s of Object.values(t)){if(typeof s!="string")continue;const r=s.match(/'([^']+)'/);r&&o.add(r[1])}return o.size?['<link rel="preconnect" href="https://fonts.googleapis.com">','<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>',`<link href="https://fonts.googleapis.com/css2?${[...o].map(s=>`family=${s.replace(/\s+/g,"+")}:wght@300;400;500;600;700`).join("&")}&display=swap" rel="stylesheet">`].join(`
58
+ `):""},jo=({brRegistry:e,fetchSeed:t,fetchRuns:o,adoptDom:n=!1,stamp:s,time:r,registryFormat:i="paths",lazyGroups:u}={})=>{const g=n&&e&&Object.keys(e).length?i==="tree"&&jt(e)||Et(e):"",f=Lt(t,o);return{meta:`<meta name="brender" content="${g?"hydrate":"replace"}">
59
+ `+bt(To(s,r))+(Ae(u)?`
60
+ `+Ae(u):""),blocks:[g,f].filter(Boolean).join(`
61
+ `)}},To=(e,t)=>{const o=typeof t=="number"&&isFinite(t)?Math.round(t):Date.now();return{stamp:e!=null&&e!==""?String(e):new Date(o).toISOString(),time:o}},vo=e=>{if(e==null||e==="")return"";const t=String(e);if(!/^[A-Za-z0-9+/=_-]+$/.test(t))throw new Error("brender: a nonce is base64 or base64url text");return` nonce="${t}"`};export{Ze as EAGER_IMAGES_DEFAULT,Me as SMBLS_SSR_SPECIFIER,Ye as WHOLE_MARKER_ID,sn as adoptionScripts,To as buildStamp,Ue as fixedThemeOf,ln as getAccumulatedEmotionCSS,Eo as markLazyImages,Ro as paintsWhole,jo as prerenderParts,Ne as render,rn as renderElement,pn as renderPage,fn as renderRoute,an as replaceEmotionCSS,cn as resetGlobalCSSCache,bo as splitCapturedCSS,Qe as withWholePaint};